@nextblock-cms/editor 0.2.20 → 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +25 -25
- package/index.mjs +1752 -1600
- package/lib/extensions/SpanNode.d.ts +5 -0
- package/lib/extensions/SvgNode.d.ts +5 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C=require("react"),tu=require("react-dom"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C=require("react"),tu=require("react-dom"),De=require("@nextblock-cms/utils"),gt=require("@nextblock-cms/ui/popover"),le=require("@nextblock-cms/ui/button"),ns=require("@nextblock-cms/ui/input"),Ft=require("@nextblock-cms/ui/separator"),We=require("@nextblock-cms/ui/dropdown-menu"),at=require("@nextblock-cms/ui/card"),a1=require("@nextblock-cms/ui/badge");function rg(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const ne=rg(C),c1=rg(tu);function sg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var io={exports:{}},Ls={};var Yh;function d1(){if(Yh)return Ls;Yh=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,i){var o=null;if(i!==void 0&&(o=""+i),s.key!==void 0&&(o=""+s.key),"key"in s){i={};for(var l in s)l!=="key"&&(i[l]=s[l])}else i=s;return s=i.ref,{$$typeof:t,type:r,key:o,ref:s!==void 0?s:null,props:i}}return Ls.Fragment=e,Ls.jsx=n,Ls.jsxs=n,Ls}var Is={};var Xh;function u1(){return Xh||(Xh=1,process.env.NODE_ENV!=="production"&&(function(){function t(_){if(_==null)return null;if(typeof _=="function")return _.$$typeof===H?null:_.displayName||_.name||null;if(typeof _=="string")return _;switch(_){case y:return"Fragment";case w:return"Profiler";case b:return"StrictMode";case x:return"Suspense";case k:return"SuspenseList";case N:return"Activity"}if(typeof _=="object")switch(typeof _.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),_.$$typeof){case g:return"Portal";case S:return _.displayName||"Context";case M:return(_._context.displayName||"Context")+".Consumer";case A:var Z=_.render;return _=_.displayName,_||(_=Z.displayName||Z.name||"",_=_!==""?"ForwardRef("+_+")":"ForwardRef"),_;case v:return Z=_.displayName||null,Z!==null?Z:t(_.type)||"Memo";case T:Z=_._payload,_=_._init;try{return t(_(Z))}catch{}}return null}function e(_){return""+_}function n(_){try{e(_);var Z=!1}catch{Z=!0}if(Z){Z=console;var fe=Z.error,Se=typeof Symbol=="function"&&Symbol.toStringTag&&_[Symbol.toStringTag]||_.constructor.name||"Object";return fe.call(Z,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",Se),e(_)}}function r(_){if(_===y)return"<>";if(typeof _=="object"&&_!==null&&_.$$typeof===T)return"<...>";try{var Z=t(_);return Z?"<"+Z+">":"<...>"}catch{return"<...>"}}function s(){var _=V.A;return _===null?null:_.getOwner()}function i(){return Error("react-stack-top-frame")}function o(_){if($.call(_,"key")){var Z=Object.getOwnPropertyDescriptor(_,"key").get;if(Z&&Z.isReactWarning)return!1}return _.key!==void 0}function l(_,Z){function fe(){Q||(Q=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",Z))}fe.isReactWarning=!0,Object.defineProperty(_,"key",{get:fe,configurable:!0})}function a(){var _=t(this.type);return ie[_]||(ie[_]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),_=this.props.ref,_!==void 0?_:null}function c(_,Z,fe,Se,pn,fr){var $e=fe.ref;return _={$$typeof:p,type:_,key:Z,props:fe,_owner:Se},($e!==void 0?$e:null)!==null?Object.defineProperty(_,"ref",{enumerable:!1,get:a}):Object.defineProperty(_,"ref",{enumerable:!1,value:null}),_._store={},Object.defineProperty(_._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(_,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(_,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:pn}),Object.defineProperty(_,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:fr}),Object.freeze&&(Object.freeze(_.props),Object.freeze(_)),_}function d(_,Z,fe,Se,pn,fr){var $e=Z.children;if($e!==void 0)if(Se)if(I($e)){for(Se=0;Se<$e.length;Se++)u($e[Se]);Object.freeze&&Object.freeze($e)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else u($e);if($.call(Z,"key")){$e=t(_);var Ln=Object.keys(Z).filter(function(qr){return qr!=="key"});Se=0<Ln.length?"{key: someKey, "+Ln.join(": ..., ")+": ...}":"{key: someKey}",xe[$e+Se]||(Ln=0<Ln.length?"{"+Ln.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
@@ -7,15 +7,15 @@ React keys must be passed directly to JSX without using spread:
|
|
|
7
7
|
`)}}_r.empty=new _r(!0);class w1{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 pg(t){let e=[];do e.push(k1(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function k1(t){let e=[];do e.push(v1(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function v1(t){let e=E1(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=S1(t,e);else break;return e}function rf(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function S1(t,e){let n=rf(t),r=n;return t.eat(",")&&(t.next!="}"?r=rf(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function C1(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let i in n){let o=n[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function E1(t){if(t.eat("(")){let e=pg(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=C1(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 M1(t){let e=[[]];return s(i(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function s(o,l){o.forEach(a=>a.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=i(o.exprs[a],l);if(a==o.exprs.length-1)return c;s(c,l=n())}else if(o.type=="star"){let a=n();return r(l,a),s(i(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=n();return s(i(o.expr,l),a),s(i(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let d=n();s(i(o.expr,a),d),a=d}if(o.max==-1)s(i(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let d=n();r(a,d),s(i(o.expr,a),d),a=d}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function mg(t,e){return e-t}function sf(t,e){let n=[];return r(e),n.sort(mg);function r(s){let i=t[s];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(s);for(let o=0;o<i.length;o++){let{term:l,to:a}=i[o];!l&&n.indexOf(a)==-1&&r(a)}}}function A1(t){let e=Object.create(null);return n(sf(t,0));function n(r){let s=[];r.forEach(o=>{t[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<s.length;d++)s[d][0]==l&&(c=s[d][1]);sf(t,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[r.join(",")]=new _r(r.indexOf(t.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(mg);i.next.push({type:s[o][0],next:e[l.join(",")]||n(l)})}return i}}function T1(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],i=!s.validEnd,o=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];o.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function gg(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function yg(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let i=t[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function bg(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${s}`);for(let s in t){let i=t[s];i.validate&&i.validate(e[s])}}function xg(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new _1(t,r,e[r]);return n}let of=class wg{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=xg(e,r.attrs),this.defaultAttrs=gg(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==_r.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:yg(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Zn(this,this.computeAttrs(e),O.from(n),Ee.setFrom(r))}createChecked(e=null,n,r){return n=O.from(n),this.checkContent(n),new Zn(this,this.computeAttrs(e),n,Ee.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=O.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let s=this.contentMatch.matchFragment(n),i=s&&s.fillBefore(O.empty,!0);return i?new Zn(this,e,n.append(i),Ee.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){bg(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:Ee.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,o)=>r[i]=new wg(i,n,o));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function N1(t,e,n){let r=n.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class _1{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?N1(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Zl{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=xg(e,s.attrs),this.excluded=null;let i=gg(this.attrs);this.instance=i?new Ee(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Ee(this,yg(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new Zl(i,s++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){bg(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class kg{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=rt.from(e.nodes),n.marks=rt.from(e.marks||{}),this.nodes=of.compile(this.spec.nodes,this),this.marks=Zl.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=_r.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?lf(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:lf(this,o.split(" "))}this.nodeFromJSON=s=>Zn.fromJSON(this,s),this.markFromJSON=s=>Ee.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof of){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,s)}text(e,n){let r=this.nodes.text;return new Yo(r,r.defaultAttrs,e,Ee.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function lf(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],i=t.marks[s],o=i;if(i)n.push(i);else for(let l in t.marks){let a=t.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function R1(t){return t.tag!=null}function O1(t){return t.style!=null}let Ws=class Uc{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(R1(s))this.tags.push(s);else if(O1(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new cf(this,n,!1);return r.addAll(e,Ee.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new cf(this,n,!0);return r.addAll(e,Ee.none,n.from,n.to),P.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(I1(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let a=o.getAttrs(n);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=df(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=df(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Uc(e,Uc.schemaRules(e)))}};const vg={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},D1={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Sg={ol:!0,ul:!0},li=1,Vc=2,qs=4;function af(t,e,n){return e!=null?(e?li:0)|(e==="full"?Vc:0):t&&t.whitespace=="pre"?li|Vc:n&~qs}class ao{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=Ee.none,this.match=i||(o&qs?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,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&li)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=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}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!vg.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class cf{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=af(null,n.preserveWhitespace,0)|(r?qs:0);s?i=new ao(s.type,s.attrs,Ee.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new ao(null,null,Ee.none,!0,null,o):i=new ao(e.schema.topNodeType,null,Ee.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&Vc?"full":this.localPreserveWS||(s.options&li)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
|
|
8
8
|
`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(o.text(l[a]),n,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Sg.hasOwnProperty(o)&&this.parser.normalizeLists&&L1(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:D1.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,d=this.needsBlock;if(vg.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let u=a&&a.skip?n:this.readStyles(e,n);u&&this.addAll(e,u),c&&this.sync(i),this.needsBlock=d}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
9
9
|
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(i,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,s){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=Ee.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):uf(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=af(e,i,o.options);o.options&qs&&o.content.length==0&&(l|=qs);let a=Ee.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):uf(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new ao(e,n,a,s,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=li)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function L1(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Sg.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function I1(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function df(t){let e={};for(let n in t)e[n]=t[n];return e}function uf(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||i.indexOf(d)<0&&o(d))return!0}};if(o(s.contentMatch))return!0}}class Fr{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Ga(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],d=this.serializeMark(c,o.isInline,n);d&&(i.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=Oo(Ga(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&Oo(Ga(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return Oo(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Fr(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=hf(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return hf(e.marks)}}function hf(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Ga(t){return t.document||window.document}const ff=new WeakMap;function j1(t){let e=ff.get(t);return e===void 0&&ff.set(t,e=P1(t)),e}function P1(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function Oo(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=j1(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let l,a=n?t.createElementNS(n,s):t.createElement(s),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let h=u.indexOf(" ");h>0?a.setAttributeNS(u.slice(0,h),u.slice(h+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let h=e[u];if(h===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:p}=Oo(t,h,n,r);if(a.appendChild(f),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Cg=65535,Eg=Math.pow(2,16);function B1(t,e){return t+e*Eg}function pf(t){return t&Cg}function $1(t){return(t-(t&Cg))/Eg}const Mg=1,Ag=2,Do=4,Tg=8;class Wc{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Tg)>0}get deletedBefore(){return(this.delInfo&(Mg|Do))>0}get deletedAfter(){return(this.delInfo&(Ag|Do))>0}get deletedAcross(){return(this.delInfo&Do)>0}}class _t{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&_t.empty)return _t.empty}recover(e){let n=0,r=pf(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+$1(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],d=this.ranges[l+o],u=a+c;if(e<=u){let h=c?e==a?-1:e==u?1:n:n,f=a+s+(h<0?0:d);if(r)return f;let p=e==(n<0?a:u)?null:B1(l/3,e-a),g=e==a?Ag:e==u?Mg:Do;return(n<0?e!=a:e!=u)&&(g|=Tg),new Wc(f,g,p)}s+=d-c}return r?e+s:new Wc(e+s,0,null)}touches(e,n){let r=0,s=pf(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+n],d=this.ranges[s+r];e(l,l+c,a,a+d),i+=d-c}}invert(){return new _t(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?_t.empty:new _t(e<0?[0,-e,0]:[0,0,e])}}_t.empty=new _t([]);class ai{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new ai(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new ai;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new Wc(e,s,null)}}const Ja=Object.create(null);class mt{getMap(){return _t.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Ja[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Ja)throw new RangeError("Duplicate use of step JSON ID "+e);return Ja[e]=n,n.prototype.jsonID=e,n}}class qe{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new qe(e,null)}static fail(e){return new qe(null,e)}static fromReplace(e,n,r,s){try{return qe.ok(e.replace(n,r,s))}catch(i){if(i instanceof Go)return qe.fail(i.message);throw i}}}function ru(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(ru(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return O.fromArray(r)}class Kn extends mt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new P(ru(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return qe.fromReplace(e,this.from,this.to,i)}invert(){return new Wt(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 Kn(n.pos,r.pos,this.mark)}merge(e){return e instanceof Kn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Kn(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 Kn(n.from,n.to,e.markFromJSON(n.mark))}}mt.jsonID("addMark",Kn);class Wt extends mt{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(ru(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return qe.fromReplace(e,this.from,this.to,r)}invert(){return new Kn(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 Wt(n.pos,r.pos,this.mark)}merge(e){return e instanceof Wt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Wt(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 Wt(n.from,n.to,e.markFromJSON(n.mark))}}mt.jsonID("removeMark",Wt);class Gn extends mt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return qe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return qe.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 s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new Gn(this.pos,n.marks[s]);return new Gn(this.pos,this.mark)}}return new Rr(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Gn(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Gn(n.pos,e.markFromJSON(n.mark))}}mt.jsonID("addNodeMark",Gn);class Rr extends mt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return qe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return qe.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);return!n||!this.mark.isInSet(n.marks)?this:new Gn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Rr(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Rr(n.pos,e.markFromJSON(n.mark))}}mt.jsonID("removeNodeMark",Rr);class Ze extends mt{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&qc(e,this.from,this.to)?qe.fail("Structure replace would overwrite content"):qe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new _t([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ze(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new Ze(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ze)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?P.empty:new P(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ze(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?P.empty:new P(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ze(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ze(n.from,n.to,P.fromJSON(e,n.slice),!!n.structure)}}mt.jsonID("replace",Ze);class Qe extends mt{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(qc(e,this.from,this.gapFrom)||qc(e,this.gapTo,this.to)))return qe.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return qe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?qe.fromReplace(e,this.from,this.to,r):qe.fail("Content does not fit in gap")}getMap(){return new _t([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Qe(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new Qe(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Qe(n.from,n.to,n.gapFrom,n.gapTo,P.fromJSON(e,n.slice),n.insert,!!n.structure)}}mt.jsonID("replaceAround",Qe);function qc(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function H1(t,e,n,r){let s=[],i=[],o,l;t.doc.nodesBetween(e,n,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let h=Math.max(c,e),f=Math.min(c+a.nodeSize,n),p=r.addToSet(u);for(let g=0;g<u.length;g++)u[g].isInSet(p)||(o&&o.to==h&&o.mark.eq(u[g])?o.to=f:s.push(o=new Wt(h,f,u[g])));l&&l.to==h?l.to=f:i.push(l=new Kn(h,f,r))}}),s.forEach(a=>t.step(a)),i.forEach(a=>t.step(a))}function z1(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;i++;let a=null;if(r instanceof Zl){let c=o.marks,d;for(;d=r.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,n);for(let d=0;d<a.length;d++){let u=a[d],h;for(let f=0;f<s.length;f++){let p=s[f];p.step==i-1&&u.eq(s[f].style)&&(h=p)}h?(h.to=c,h.step=i):s.push({style:u,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(o=>t.step(new Wt(o.from,o.to,o.style)))}function su(t,e,n,r=n.contentMatch,s=!0){let i=t.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),d=l+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Ze(l,d,P.empty));else{r=u;for(let h=0;h<c.marks.length;h++)n.allowsMarkType(c.marks[h].type)||t.step(new Wt(l,d,c.marks[h]));if(s&&c.isText&&n.whitespace!="pre"){let h,f=/\r?\n|\r/g,p;for(;h=f.exec(c.text);)p||(p=new P(O.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),o.push(new Ze(l+h.index,l+h.index+h[0].length,p))}}l=d}if(!r.validEnd){let a=r.fillBefore(O.empty,!0);t.replace(l,l,new P(a,0,0))}for(let a=o.length-1;a>=0;a--)t.step(o[a])}function F1(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Cs(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let s=t.$from.node(r),i=t.$from.index(r),o=t.$to.indexAfter(r);if(r<t.depth&&s.canReplace(i,o,n))return r;if(r==0||s.type.spec.isolating||!F1(s,i,o))break}return null}function U1(t,e,n){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),l=s.after(i+1),a=o,c=l,d=O.empty,u=0;for(let p=i,g=!1;p>n;p--)g||r.index(p)>0?(g=!0,d=O.from(r.node(p).copy(d)),u++):a--;let h=O.empty,f=0;for(let p=i,g=!1;p>n;p--)g||s.after(p+1)<s.end(p)?(g=!0,h=O.from(s.node(p).copy(h)),f++):c++;t.step(new Qe(a,c,o,l,new P(d.append(h),u,f),d.size-u,!0))}function iu(t,e,n=null,r=t){let s=V1(t,e),i=s&&W1(r,e);return i?s.map(mf).concat({type:e,attrs:n}).concat(i.map(mf)):null}function mf(t){return{type:t,attrs:null}}function V1(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return n.canReplaceWith(r,s,o)?i:null}function W1(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:o}function q1(t,e,n){let r=O.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=O.from(n[o].type.create(n[o].attrs,r))}let s=e.start,i=e.end;t.step(new Qe(s,i,s,i,new P(r,0,0),n.length,!0))}function K1(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let a=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,a)&&G1(t.doc,t.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&_g(t,o,l,i),su(t,t.mapping.slice(i).map(l,1),r,void 0,c===null);let d=t.mapping.slice(i),u=d.map(l,1),h=d.map(l+o.nodeSize,1);return t.step(new Qe(u,h,u+1,h-1,new P(O.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&Ng(t,o,l,i),!1}})}function Ng(t,e,n,r){e.forEach((s,i)=>{if(s.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(s.text);){let a=t.mapping.slice(r).map(n+1+i+o.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function _g(t,e,n,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(`
|
|
10
|
-
`))}})}function G1(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function J1(t,e,n,r,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Qe(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new P(O.from(o),0,0),1,!0))}function Mn(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=n-2;c>i;c--,d--){let u=s.node(c),h=s.index(c);if(u.type.spec.isolating)return!1;let f=u.content.cutByIndex(h,u.childCount),p=r&&r[d+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[d]||u;if(!u.canReplace(h+1,u.childCount)||!g.type.validContent(f))return!1}let l=s.indexAfter(i),a=r&&r[0];return s.node(i).canReplaceWith(l,l,a?a.type:s.node(i+1).type)}function Y1(t,e,n=1,r){let s=t.doc.resolve(e),i=O.empty,o=O.empty;for(let l=s.depth,a=s.depth-n,c=n-1;l>a;l--,c--){i=O.from(s.node(l).copy(i));let d=r&&r[c];o=O.from(d?d.type.create(d.attrs,o):s.node(l).copy(o))}t.step(new Ze(e,e,new P(i.append(o),n,n),!0))}function ur(t,e){let n=t.resolve(e),r=n.index();return Rg(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function X1(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function Rg(t,e){return!!(t&&e&&!t.isLeaf&&X1(t,e))}function Ql(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let i,o,l=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):n>0?(i=r.node(s+1),l++,o=r.node(s).maybeChild(l)):(i=r.node(s).maybeChild(l-1),o=r.node(s+1)),i&&!i.isTextblock&&Rg(i,o)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function Z1(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(s&&o.inlineContent){let d=o.whitespace=="pre",u=!!o.contentMatch.matchType(s);d&&!u?r=!1:!d&&u&&(r=!0)}let l=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);_g(t,d.node(),d.before(),l)}o.inlineContent&&su(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new Ze(c,a.map(e+n,-1),P.empty,!0)),r===!0){let d=t.doc.resolve(c);Ng(t,d.node(),d.before(),t.steps.length)}return t}function Q1(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,n))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,n))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function Og(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),d=!1;if(i==1)d=c.canReplace(a,a,s);else{let u=c.contentMatchAt(a).findWrapping(s.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function ea(t,e,n=e,r=P.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return Dg(s,i,r)?new Ze(e,n,r):new ek(s,i,r).fit()}function Dg(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class ek{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=O.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=O.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let a=new P(i,o,l);return e>-1?new Qe(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new Ze(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=Ya(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(n==1&&(o?c.matchType(o.type)||(u=c.fillBefore(O.from(o),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:u};if(n==2&&o&&(d=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Ya(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new P(e,n+1,Math.max(r,s.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Ya(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new P(Hs(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new P(Hs(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let g=0;g<i.length;g++)this.openFrontierNode(i[g]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,d=[],{match:u,type:h}=this.frontier[n];if(s){for(let g=0;g<s.childCount;g++)d.push(s.child(g));u=u.matchFragment(s)}let f=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let g=l.child(c),y=u.matchType(g.type);if(!y)break;c++,(c>1||a==0||g.content.size)&&(u=y,d.push(Lg(g.mark(h.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?f:-1)))}let p=c==l.childCount;p||(f=-1),this.placed=zs(this.placed,n,O.from(d)),this.frontier[n].match=u,p&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=l;g<f;g++){let b=y.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),y=b.content}this.unplaced=p?e==0?P.empty:new P(Hs(o.content,e-1,1),e-1,f<0?o.openEnd:e-1):new P(Hs(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Xa(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=Xa(e,n,s,r,i);if(o){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Xa(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=zs(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=zs(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=zs(this.placed,this.frontier.length,n))}}function Hs(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Hs(t.firstChild.content,e-1,n)))}function zs(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(zs(t.lastChild.content,e-1,n)))}function Ya(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Lg(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Lg(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 Xa(t,e,n,r,s){let i=t.node(e),o=s?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!tk(n,i.content,o)?l:null}function tk(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function nk(t){return t.spec.defining||t.spec.definingForContent}function rk(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(Dg(s,i,r))return t.step(new Ze(e,n,r));let o=jg(s,t.doc.resolve(n));o[o.length-1]==0&&o.pop();let l=-(s.depth+1);o.unshift(l);for(let h=s.depth,f=s.pos-1;h>0;h--,f--){let p=s.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(h)>-1?l=h:s.before(h)==f&&o.splice(1,0,-h)}let a=o.indexOf(l),c=[],d=r.openStart;for(let h=r.content,f=0;;f++){let p=h.firstChild;if(c.push(p),f==r.openStart)break;h=p.content}for(let h=d-1;h>=0;h--){let f=c[h],p=nk(f.type);if(p&&!f.sameMarkup(s.node(Math.abs(l)-1)))d=h;else if(p||!f.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let f=(h+d+1)%(r.openStart+1),p=c[f];if(p)for(let g=0;g<o.length;g++){let y=o[(g+a)%o.length],b=!0;y<0&&(b=!1,y=-y);let w=s.node(y-1),M=s.index(y-1);if(w.canReplaceWith(M,M,p.type,p.marks))return t.replace(s.before(y),b?i.after(y):n,new P(Ig(r.content,0,r.openStart,f),f,r.openEnd))}}let u=t.steps.length;for(let h=o.length-1;h>=0&&(t.replace(e,n,r),!(t.steps.length>u));h--){let f=o[h];f<0||(e=s.before(f),n=i.after(f))}}function Ig(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(Ig(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(O.empty,!0))}return t}function sk(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=Q1(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new P(O.from(r),0,0))}function ik(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n),i=jg(r,s);for(let o=0;o<i.length;o++){let l=i[o],a=o==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return t.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function jg(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}class rs extends mt{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 qe.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return qe.fromReplace(e,this.pos,this.pos+1,new P(O.from(s),0,n.isLeaf?0:1))}getMap(){return _t.empty}invert(e){return new rs(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 rs(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 rs(n.pos,n.attr,n.value)}}mt.jsonID("attr",rs);class ci extends mt{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return qe.ok(r)}getMap(){return _t.empty}invert(e){return new ci(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 ci(n.attr,n.value)}}mt.jsonID("docAttr",ci);let us=class extends Error{};us=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};us.prototype=Object.create(Error.prototype);us.prototype.constructor=us;us.prototype.name="TransformError";class ou{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ai}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new us(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 s=ea(this.doc,e,n,r);return s&&this.step(s),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 rk(this,e,n,r),this}replaceRangeWith(e,n,r){return sk(this,e,n,r),this}deleteRange(e,n){return ik(this,e,n),this}lift(e,n){return U1(this,e,n),this}join(e,n=1){return Z1(this,e,n),this}wrap(e,n){return q1(this,e,n),this}setBlockType(e,n=e,r,s=null){return K1(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return J1(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new rs(e,n,r)),this}setDocAttribute(e,n){return this.step(new ci(e,n)),this}addNodeMark(e,n){return this.step(new Gn(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof Ee)n.isInSet(r.marks)&&this.step(new Rr(e,n));else{let s=r.marks,i,o=[];for(;i=n.isInSet(s);)o.push(new Rr(e,i)),s=i.removeFromSet(s);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return Y1(this,e,n,r),this}addMark(e,n,r){return H1(this,e,n,r),this}removeMark(e,n,r){return z1(this,e,n,r),this}clearIncompatible(e,n,r){return su(this,e,n,r),this}}const Za=Object.create(null);class ee{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new lu(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=P.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(c.pos),l?P.empty:n),l==0&&bf(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],a=e.mapping.slice(r),c=a.map(o.pos),d=a.map(l.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,n),bf(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new J(e):Xr(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?Xr(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Xr(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new St(e.node(0))}static atStart(e){return Xr(e,e,0,0,1)||new St(e)}static atEnd(e){return Xr(e,e,e.content.size,e.childCount,-1)||new St(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Za[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 Za)throw new RangeError("Duplicate use of selection JSON ID "+e);return Za[e]=n,n.prototype.jsonID=e,n}getBookmark(){return J.between(this.$anchor,this.$head).getBookmark()}}ee.prototype.visible=!0;class lu{constructor(e,n){this.$from=e,this.$to=n}}let gf=!1;function yf(t){!gf&&!t.parent.inlineContent&&(gf=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class J extends ee{constructor(e,n=e){yf(e),yf(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 ee.near(r);let s=e.resolve(n.map(this.anchor));return new J(s.parent.inlineContent?s: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 J&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ta(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 J(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=ee.findFrom(n,r,!0)||ee.findFrom(n,-r,!0);if(i)n=i.$head;else return ee.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(ee.findFrom(e,-r,!0)||ee.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new J(e,n)}}ee.jsonID("text",J);class ta{constructor(e,n){this.anchor=e,this.head=n}map(e){return new ta(e.map(this.anchor),e.map(this.head))}resolve(e){return J.between(e.resolve(this.anchor),e.resolve(this.head))}}class q extends ee{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?ee.near(i):new q(i)}content(){return new P(O.from(this.node),0,0)}eq(e){return e instanceof q&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new au(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new q(e.resolve(n.anchor))}static create(e,n){return new q(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}q.prototype.visible=!1;ee.jsonID("node",q);class au{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new ta(r,r):new au(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&q.isSelectable(r)?new q(n):ee.near(n)}}class St extends ee{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=P.empty){if(n==P.empty){e.delete(0,e.doc.content.size);let r=ee.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new St(e)}map(e){return new St(e)}eq(e){return e instanceof St}getBookmark(){return ok}}ee.jsonID("all",St);const ok={map(){return this},resolve(t){return new St(t)}};function Xr(t,e,n,r,s,i=!1){if(e.inlineContent)return J.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&q.isSelectable(l))return q.create(t,n-(s<0?l.nodeSize:0))}else{let a=Xr(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function bf(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Ze||s instanceof Qe))return;let i=t.mapping.maps[r],o;i.forEach((l,a,c,d)=>{o==null&&(o=d)}),t.setSelection(ee.near(t.doc.resolve(o),n))}const xf=1,co=2,wf=4;let lk=class extends ou{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|xf)&~co,this.storedMarks=null,this}get selectionSet(){return(this.updated&xf)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=co,this}ensureMarks(e){return Ee.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&co)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~co,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)||Ee.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(ee.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|=wf,this}get scrolledIntoView(){return(this.updated&wf)>0}};function kf(t,e){return!e||!t?t:t.bind(e)}class Fs{constructor(e,n,r){this.name=e,this.init=kf(n.init,r),this.apply=kf(n.apply,r)}}const ak=[new Fs("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Fs("selection",{init(t,e){return t.selection||ee.atStart(e.doc)},apply(t){return t.selection}}),new Fs("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Fs("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Qa{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ak.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 Fs(r.key,r.spec.state,r))})}}class ts{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=s?s[o].n:0,c=s?s[o].state:this,d=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(d&&r.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<o?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),i=!0}s&&(s[o]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new ts(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new lk(this)}static create(e){let n=new Qa(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new ts(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new Qa(this.schema,e.plugins),r=n.fields,s=new ts(n);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Qa(e.schema,e.plugins),i=new ts(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=Zn.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=ee.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[o.name]=c.fromJSON.call(a,e,n[l],i);return}}i[o.name]=o.init(e,i)}}),i}}function Pg(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Pg(s,e,{})),n[r]=s}return n}class pe{constructor(e){this.spec=e,this.props={},e.props&&Pg(e.props,this,this.props),this.key=e.key?e.key.key:Bg("plugin")}getState(e){return e[this.key]}}const ec=Object.create(null);function Bg(t){return t in ec?t+"$"+ ++ec[t]:(ec[t]=0,t+"$")}class ge{constructor(e="key"){this.key=Bg(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const cu=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function $g(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Hg=(t,e,n)=>{let r=$g(t,n);if(!r)return!1;let s=du(r);if(!s){let o=r.blockRange(),l=o&&Cs(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(Jg(t,s,e,-1))return!0;if(r.parent.content.size==0&&(hs(i,"end")||q.isSelectable(i)))for(let o=r.depth;;o--){let l=ea(t.doc,r.before(o),r.after(o),P.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(hs(i,"end")?ee.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):q.create(a.doc,s.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},ck=(t,e,n)=>{let r=$g(t,n);if(!r)return!1;let s=du(r);return s?zg(t,s,e):!1},dk=(t,e,n)=>{let r=Ug(t,n);if(!r)return!1;let s=uu(r);return s?zg(t,s,e):!1};function zg(t,e,n){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let d=s.lastChild;if(!d)return!1;s=d}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=ea(t.doc,i,a,P.empty);if(!c||c.from!=i||c instanceof Ze&&c.slice.size>=a-i)return!1;if(n){let d=t.tr.step(c);d.setSelection(J.create(d.doc,i)),n(d.scrollIntoView())}return!0}function hs(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 Fg=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=du(r)}let o=i&&i.nodeBefore;return!o||!q.isSelectable(o)?!1:(e&&e(t.tr.setSelection(q.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function du(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 Ug(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Vg=(t,e,n)=>{let r=Ug(t,n);if(!r)return!1;let s=uu(r);if(!s)return!1;let i=s.nodeAfter;if(Jg(t,s,e,1))return!0;if(r.parent.content.size==0&&(hs(i,"start")||q.isSelectable(i))){let o=ea(t.doc,r.before(),r.after(),P.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(hs(i,"start")?ee.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):q.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},Wg=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=uu(r)}let o=i&&i.nodeAfter;return!o||!q.isSelectable(o)?!1:(e&&e(t.tr.setSelection(q.create(t.doc,i.pos)).scrollIntoView()),!0)};function uu(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const uk=(t,e)=>{let n=t.selection,r=n instanceof q,s;if(r){if(n.node.isTextblock||!ur(t.doc,n.from))return!1;s=n.from}else if(s=Ql(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(q.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},hk=(t,e)=>{let n=t.selection,r;if(n instanceof q){if(n.node.isTextblock||!ur(t.doc,n.to))return!1;r=n.to}else if(r=Ql(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},fk=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&Cs(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},qg=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
|
|
10
|
+
`))}})}function G1(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function J1(t,e,n,r,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Qe(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new P(O.from(o),0,0),1,!0))}function Mn(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=n-2;c>i;c--,d--){let u=s.node(c),h=s.index(c);if(u.type.spec.isolating)return!1;let f=u.content.cutByIndex(h,u.childCount),p=r&&r[d+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[d]||u;if(!u.canReplace(h+1,u.childCount)||!g.type.validContent(f))return!1}let l=s.indexAfter(i),a=r&&r[0];return s.node(i).canReplaceWith(l,l,a?a.type:s.node(i+1).type)}function Y1(t,e,n=1,r){let s=t.doc.resolve(e),i=O.empty,o=O.empty;for(let l=s.depth,a=s.depth-n,c=n-1;l>a;l--,c--){i=O.from(s.node(l).copy(i));let d=r&&r[c];o=O.from(d?d.type.create(d.attrs,o):s.node(l).copy(o))}t.step(new Ze(e,e,new P(i.append(o),n,n),!0))}function ur(t,e){let n=t.resolve(e),r=n.index();return Rg(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function X1(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function Rg(t,e){return!!(t&&e&&!t.isLeaf&&X1(t,e))}function Ql(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let i,o,l=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):n>0?(i=r.node(s+1),l++,o=r.node(s).maybeChild(l)):(i=r.node(s).maybeChild(l-1),o=r.node(s+1)),i&&!i.isTextblock&&Rg(i,o)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function Z1(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(s&&o.inlineContent){let d=o.whitespace=="pre",u=!!o.contentMatch.matchType(s);d&&!u?r=!1:!d&&u&&(r=!0)}let l=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);_g(t,d.node(),d.before(),l)}o.inlineContent&&su(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new Ze(c,a.map(e+n,-1),P.empty,!0)),r===!0){let d=t.doc.resolve(c);Ng(t,d.node(),d.before(),t.steps.length)}return t}function Q1(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,n))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,n))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function Og(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),d=!1;if(i==1)d=c.canReplace(a,a,s);else{let u=c.contentMatchAt(a).findWrapping(s.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function ea(t,e,n=e,r=P.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return Dg(s,i,r)?new Ze(e,n,r):new ek(s,i,r).fit()}function Dg(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class ek{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=O.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=O.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let a=new P(i,o,l);return e>-1?new Qe(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new Ze(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=Ya(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(n==1&&(o?c.matchType(o.type)||(u=c.fillBefore(O.from(o),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:u};if(n==2&&o&&(d=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Ya(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new P(e,n+1,Math.max(r,s.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Ya(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new P(Hs(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new P(Hs(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let g=0;g<i.length;g++)this.openFrontierNode(i[g]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,d=[],{match:u,type:h}=this.frontier[n];if(s){for(let g=0;g<s.childCount;g++)d.push(s.child(g));u=u.matchFragment(s)}let f=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let g=l.child(c),y=u.matchType(g.type);if(!y)break;c++,(c>1||a==0||g.content.size)&&(u=y,d.push(Lg(g.mark(h.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?f:-1)))}let p=c==l.childCount;p||(f=-1),this.placed=zs(this.placed,n,O.from(d)),this.frontier[n].match=u,p&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=l;g<f;g++){let b=y.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),y=b.content}this.unplaced=p?e==0?P.empty:new P(Hs(o.content,e-1,1),e-1,f<0?o.openEnd:e-1):new P(Hs(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Xa(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=Xa(e,n,s,r,i);if(o){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Xa(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=zs(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=zs(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=zs(this.placed,this.frontier.length,n))}}function Hs(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Hs(t.firstChild.content,e-1,n)))}function zs(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(zs(t.lastChild.content,e-1,n)))}function Ya(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Lg(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Lg(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 Xa(t,e,n,r,s){let i=t.node(e),o=s?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!tk(n,i.content,o)?l:null}function tk(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function nk(t){return t.spec.defining||t.spec.definingForContent}function rk(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(Dg(s,i,r))return t.step(new Ze(e,n,r));let o=jg(s,t.doc.resolve(n));o[o.length-1]==0&&o.pop();let l=-(s.depth+1);o.unshift(l);for(let h=s.depth,f=s.pos-1;h>0;h--,f--){let p=s.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(h)>-1?l=h:s.before(h)==f&&o.splice(1,0,-h)}let a=o.indexOf(l),c=[],d=r.openStart;for(let h=r.content,f=0;;f++){let p=h.firstChild;if(c.push(p),f==r.openStart)break;h=p.content}for(let h=d-1;h>=0;h--){let f=c[h],p=nk(f.type);if(p&&!f.sameMarkup(s.node(Math.abs(l)-1)))d=h;else if(p||!f.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let f=(h+d+1)%(r.openStart+1),p=c[f];if(p)for(let g=0;g<o.length;g++){let y=o[(g+a)%o.length],b=!0;y<0&&(b=!1,y=-y);let w=s.node(y-1),M=s.index(y-1);if(w.canReplaceWith(M,M,p.type,p.marks))return t.replace(s.before(y),b?i.after(y):n,new P(Ig(r.content,0,r.openStart,f),f,r.openEnd))}}let u=t.steps.length;for(let h=o.length-1;h>=0&&(t.replace(e,n,r),!(t.steps.length>u));h--){let f=o[h];f<0||(e=s.before(f),n=i.after(f))}}function Ig(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(Ig(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(O.empty,!0))}return t}function sk(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=Q1(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new P(O.from(r),0,0))}function ik(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n),i=jg(r,s);for(let o=0;o<i.length;o++){let l=i[o],a=o==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return t.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function jg(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}class rs extends mt{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 qe.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return qe.fromReplace(e,this.pos,this.pos+1,new P(O.from(s),0,n.isLeaf?0:1))}getMap(){return _t.empty}invert(e){return new rs(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 rs(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 rs(n.pos,n.attr,n.value)}}mt.jsonID("attr",rs);class ci extends mt{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return qe.ok(r)}getMap(){return _t.empty}invert(e){return new ci(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 ci(n.attr,n.value)}}mt.jsonID("docAttr",ci);let us=class extends Error{};us=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};us.prototype=Object.create(Error.prototype);us.prototype.constructor=us;us.prototype.name="TransformError";class ou{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ai}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new us(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 s=ea(this.doc,e,n,r);return s&&this.step(s),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 rk(this,e,n,r),this}replaceRangeWith(e,n,r){return sk(this,e,n,r),this}deleteRange(e,n){return ik(this,e,n),this}lift(e,n){return U1(this,e,n),this}join(e,n=1){return Z1(this,e,n),this}wrap(e,n){return q1(this,e,n),this}setBlockType(e,n=e,r,s=null){return K1(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return J1(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new rs(e,n,r)),this}setDocAttribute(e,n){return this.step(new ci(e,n)),this}addNodeMark(e,n){return this.step(new Gn(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof Ee)n.isInSet(r.marks)&&this.step(new Rr(e,n));else{let s=r.marks,i,o=[];for(;i=n.isInSet(s);)o.push(new Rr(e,i)),s=i.removeFromSet(s);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return Y1(this,e,n,r),this}addMark(e,n,r){return H1(this,e,n,r),this}removeMark(e,n,r){return z1(this,e,n,r),this}clearIncompatible(e,n,r){return su(this,e,n,r),this}}const Za=Object.create(null);class ee{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new lu(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=P.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(c.pos),l?P.empty:n),l==0&&bf(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],a=e.mapping.slice(r),c=a.map(o.pos),d=a.map(l.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,n),bf(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new J(e):Xr(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?Xr(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Xr(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new St(e.node(0))}static atStart(e){return Xr(e,e,0,0,1)||new St(e)}static atEnd(e){return Xr(e,e,e.content.size,e.childCount,-1)||new St(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Za[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 Za)throw new RangeError("Duplicate use of selection JSON ID "+e);return Za[e]=n,n.prototype.jsonID=e,n}getBookmark(){return J.between(this.$anchor,this.$head).getBookmark()}}ee.prototype.visible=!0;class lu{constructor(e,n){this.$from=e,this.$to=n}}let gf=!1;function yf(t){!gf&&!t.parent.inlineContent&&(gf=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class J extends ee{constructor(e,n=e){yf(e),yf(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 ee.near(r);let s=e.resolve(n.map(this.anchor));return new J(s.parent.inlineContent?s: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 J&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ta(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 J(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=ee.findFrom(n,r,!0)||ee.findFrom(n,-r,!0);if(i)n=i.$head;else return ee.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(ee.findFrom(e,-r,!0)||ee.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new J(e,n)}}ee.jsonID("text",J);class ta{constructor(e,n){this.anchor=e,this.head=n}map(e){return new ta(e.map(this.anchor),e.map(this.head))}resolve(e){return J.between(e.resolve(this.anchor),e.resolve(this.head))}}class q extends ee{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?ee.near(i):new q(i)}content(){return new P(O.from(this.node),0,0)}eq(e){return e instanceof q&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new au(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new q(e.resolve(n.anchor))}static create(e,n){return new q(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}q.prototype.visible=!1;ee.jsonID("node",q);class au{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new ta(r,r):new au(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&q.isSelectable(r)?new q(n):ee.near(n)}}class St extends ee{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=P.empty){if(n==P.empty){e.delete(0,e.doc.content.size);let r=ee.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new St(e)}map(e){return new St(e)}eq(e){return e instanceof St}getBookmark(){return ok}}ee.jsonID("all",St);const ok={map(){return this},resolve(t){return new St(t)}};function Xr(t,e,n,r,s,i=!1){if(e.inlineContent)return J.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&q.isSelectable(l))return q.create(t,n-(s<0?l.nodeSize:0))}else{let a=Xr(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function bf(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Ze||s instanceof Qe))return;let i=t.mapping.maps[r],o;i.forEach((l,a,c,d)=>{o==null&&(o=d)}),t.setSelection(ee.near(t.doc.resolve(o),n))}const xf=1,co=2,wf=4;let lk=class extends ou{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|xf)&~co,this.storedMarks=null,this}get selectionSet(){return(this.updated&xf)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=co,this}ensureMarks(e){return Ee.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&co)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~co,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)||Ee.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(ee.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|=wf,this}get scrolledIntoView(){return(this.updated&wf)>0}};function kf(t,e){return!e||!t?t:t.bind(e)}class Fs{constructor(e,n,r){this.name=e,this.init=kf(n.init,r),this.apply=kf(n.apply,r)}}const ak=[new Fs("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Fs("selection",{init(t,e){return t.selection||ee.atStart(e.doc)},apply(t){return t.selection}}),new Fs("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Fs("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Qa{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ak.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 Fs(r.key,r.spec.state,r))})}}class ts{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=s?s[o].n:0,c=s?s[o].state:this,d=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(d&&r.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<o?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),i=!0}s&&(s[o]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new ts(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new lk(this)}static create(e){let n=new Qa(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new ts(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new Qa(this.schema,e.plugins),r=n.fields,s=new ts(n);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Qa(e.schema,e.plugins),i=new ts(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=Zn.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=ee.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[o.name]=c.fromJSON.call(a,e,n[l],i);return}}i[o.name]=o.init(e,i)}}),i}}function Pg(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Pg(s,e,{})),n[r]=s}return n}class me{constructor(e){this.spec=e,this.props={},e.props&&Pg(e.props,this,this.props),this.key=e.key?e.key.key:Bg("plugin")}getState(e){return e[this.key]}}const ec=Object.create(null);function Bg(t){return t in ec?t+"$"+ ++ec[t]:(ec[t]=0,t+"$")}class ye{constructor(e="key"){this.key=Bg(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const cu=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function $g(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Hg=(t,e,n)=>{let r=$g(t,n);if(!r)return!1;let s=du(r);if(!s){let o=r.blockRange(),l=o&&Cs(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(Jg(t,s,e,-1))return!0;if(r.parent.content.size==0&&(hs(i,"end")||q.isSelectable(i)))for(let o=r.depth;;o--){let l=ea(t.doc,r.before(o),r.after(o),P.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(hs(i,"end")?ee.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):q.create(a.doc,s.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},ck=(t,e,n)=>{let r=$g(t,n);if(!r)return!1;let s=du(r);return s?zg(t,s,e):!1},dk=(t,e,n)=>{let r=Ug(t,n);if(!r)return!1;let s=uu(r);return s?zg(t,s,e):!1};function zg(t,e,n){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let d=s.lastChild;if(!d)return!1;s=d}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=ea(t.doc,i,a,P.empty);if(!c||c.from!=i||c instanceof Ze&&c.slice.size>=a-i)return!1;if(n){let d=t.tr.step(c);d.setSelection(J.create(d.doc,i)),n(d.scrollIntoView())}return!0}function hs(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 Fg=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=du(r)}let o=i&&i.nodeBefore;return!o||!q.isSelectable(o)?!1:(e&&e(t.tr.setSelection(q.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function du(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 Ug(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Vg=(t,e,n)=>{let r=Ug(t,n);if(!r)return!1;let s=uu(r);if(!s)return!1;let i=s.nodeAfter;if(Jg(t,s,e,1))return!0;if(r.parent.content.size==0&&(hs(i,"start")||q.isSelectable(i))){let o=ea(t.doc,r.before(),r.after(),P.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(hs(i,"start")?ee.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):q.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},Wg=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=uu(r)}let o=i&&i.nodeAfter;return!o||!q.isSelectable(o)?!1:(e&&e(t.tr.setSelection(q.create(t.doc,i.pos)).scrollIntoView()),!0)};function uu(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const uk=(t,e)=>{let n=t.selection,r=n instanceof q,s;if(r){if(n.node.isTextblock||!ur(t.doc,n.from))return!1;s=n.from}else if(s=Ql(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(q.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},hk=(t,e)=>{let n=t.selection,r;if(n instanceof q){if(n.node.isTextblock||!ur(t.doc,n.to))return!1;r=n.to}else if(r=Ql(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},fk=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&Cs(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},qg=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
|
|
11
11
|
`).scrollIntoView()),!0)};function hu(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const pk=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),i=n.indexAfter(-1),o=hu(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,o.createAndFill());a.setSelection(ee.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Kg=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof St||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=hu(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=t.tr.insert(o,i.createAndFill());l.setSelection(J.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Gg=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Mn(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Cs(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function mk(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof q&&e.selection.node.isBlock)return!r.parentOffset||!Mn(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,l,a=!1,c=!1;for(let f=r.depth;;f--)if(r.node(f).isBlock){a=r.end(f)==r.pos+(r.depth-f),c=r.start(f)==r.pos-(r.depth-f),l=hu(r.node(f-1).contentMatchAt(r.indexAfter(f-1))),i.unshift(a&&l?{type:l}:null),o=f;break}else{if(f==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof J||e.selection instanceof St)&&d.deleteSelection();let u=d.mapping.map(r.pos),h=Mn(d.doc,u,i.length,i);if(h||(i[0]=l?{type:l}:null,h=Mn(d.doc,u,i.length,i)),!h)return!1;if(d.split(u,i.length,i),!a&&c&&r.node(o).type!=l){let f=d.mapping.map(r.before(o)),p=d.doc.resolve(f);l&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(o)),l)}return n&&n(d.scrollIntoView()),!0}}const gk=mk(),yk=(t,e)=>{let{$from:n,to:r}=t.selection,s,i=n.sharedDepth(r);return i==0?!1:(s=n.before(i),e&&e(t.tr.setSelection(q.create(t.doc,s))),!0)};function bk(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||ur(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Jg(t,e,n,r){let s=e.nodeBefore,i=e.nodeAfter,o,l,a=s.type.spec.isolating||i.type.spec.isolating;if(!a&&bk(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(o[0]||i.type).validEnd){if(n){let f=e.pos+i.nodeSize,p=O.empty;for(let b=o.length-1;b>=0;b--)p=O.from(o[b].create(null,p));p=O.from(s.copy(p));let g=t.tr.step(new Qe(e.pos-1,f,e.pos,f,new P(p,1,0),o.length,!0)),y=g.doc.resolve(f+2*o.length);y.nodeAfter&&y.nodeAfter.type==s.type&&ur(g.doc,y.pos)&&g.join(y.pos),n(g.scrollIntoView())}return!0}let d=i.type.spec.isolating||r>0&&a?null:ee.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),h=u&&Cs(u);if(h!=null&&h>=e.depth)return n&&n(t.tr.lift(u,h).scrollIntoView()),!0;if(c&&hs(i,"start",!0)&&hs(s,"end")){let f=s,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let g=i,y=1;for(;!g.isTextblock;g=g.firstChild)y++;if(f.canReplace(f.childCount,f.childCount,g.content)){if(n){let b=O.empty;for(let M=p.length-1;M>=0;M--)b=O.from(p[M].copy(b));let w=t.tr.step(new Qe(e.pos-p.length,e.pos+i.nodeSize,e.pos+y,e.pos+i.nodeSize-y,new P(b,p.length,0),0,!0));n(w.scrollIntoView())}return!0}}return!1}function Yg(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(n&&n(e.tr.setSelection(J.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const xk=Yg(-1),wk=Yg(1);function kk(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i),l=o&&iu(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function vf(t,e=null){return function(n,r){let s=!1;for(let i=0;i<n.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(o,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)s=!0;else{let d=n.doc.resolve(c),u=d.index();s=d.parent.canReplaceWith(u,u+1,t)}})}if(!s)return!1;if(r){let i=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[o];i.setBlockType(l,a,t,e)}r(i.scrollIntoView())}return!0}}function fu(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}fu(cu,Hg,Fg);fu(cu,Vg,Wg);fu(qg,Kg,Gg,gk);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function vk(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i);if(!o)return!1;let l=r?n.tr:null;return Sk(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Sk(t,e,n,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);i=new oi(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new oi(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=iu(i,n,r,e);return l?(t&&Ck(t,e,l,s,n),!0):!1}function Ck(t,e,n,r,s){let i=O.empty;for(let d=n.length-1;d>=0;d--)i=O.from(n[d].type.create(n[d].attrs,i));t.step(new Qe(e.start-(r?2:0),e.end,e.start,e.end,new P(i,0,0),n.length,!0));let o=0;for(let d=0;d<n.length;d++)n[d].type==s&&(o=d+1);let l=n.length-o,a=e.start+n.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,h=!0;d<u;d++,h=!1)!h&&Mn(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return t}function Ek(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?Mk(e,n,t,i):Ak(e,n,i):!0:!1}}function Mk(t,e,n,r){let s=t.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new Qe(i-1,o,i,o,new P(O.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new oi(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const l=Cs(r);if(l==null)return!1;s.lift(r,l);let a=s.doc.resolve(s.mapping.map(i,-1)-1);return ur(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function Ak(t,e,n){let r=t.tr,s=n.parent;for(let f=n.end,p=n.endIndex-1,g=n.startIndex;p>g;p--)f-=s.child(p).nodeSize,r.delete(f-1,f+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==s.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,o.content.append(a?O.empty:O.from(s))))return!1;let u=i.pos,h=u+o.nodeSize;return r.step(new Qe(u-(l?1:0),h+(a?1:0),u+1,h-1,new P((l?O.empty:O.from(s.copy(O.empty))).append(a?O.empty:O.from(s.copy(O.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Tk(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==t);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let l=i.parent,a=l.child(o-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,d=O.from(c?t.create():null),u=new P(O.from(t.create(null,O.from(l.type.create(null,d)))),c?3:1,0),h=i.start,f=i.end;n(e.tr.step(new Qe(h-(c?3:1),f,h,f,u,1,!0)).scrollIntoView())}return!0}}const st=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},fs=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Kc=null;const vn=function(t,e,n){let r=Kc||(Kc=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Nk=function(){Kc=null},Or=function(t,e,n,r){return n&&(Sf(t,e,n,r,-1)||Sf(t,e,n,r,1))},_k=/^(img|br|input|textarea|hr)$/i;function Sf(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:Pt(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Ri(t)||_k.test(t.nodeName)||t.contentEditable=="false")return!1;e=st(t)+(s<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=o,e=s<0?Pt(t):0}else return!1}}function Pt(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Rk(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=Pt(t)}else if(t.parentNode&&!Ri(t))e=st(t),t=t.parentNode;else return null}}function Ok(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Ri(t))e=st(t)+1,t=t.parentNode;else return null}}function Dk(t,e,n){for(let r=e==0,s=e==Pt(t);r||s;){if(t==n)return!0;let i=st(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==Pt(t)}}function Ri(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const na=function(t){return t.focusNode&&Or(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function yr(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Lk(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Ik(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Pt(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Pt(r.startContainer),r.startOffset)}}}const cn=typeof navigator<"u"?navigator:null,Cf=typeof document<"u"?document:null,hr=cn&&cn.userAgent||"",Gc=/Edge\/(\d+)/.exec(hr),Xg=/MSIE \d/.exec(hr),Jc=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(hr),Ct=!!(Xg||Jc||Gc),Qn=Xg?document.documentMode:Jc?+Jc[1]:Gc?+Gc[1]:0,$t=!Ct&&/gecko\/(\d+)/i.test(hr);$t&&+(/Firefox\/(\d+)/.exec(hr)||[0,0])[1];const Yc=!Ct&&/Chrome\/(\d+)/.exec(hr),dt=!!Yc,Zg=Yc?+Yc[1]:0,bt=!Ct&&!!cn&&/Apple Computer/.test(cn.vendor),ps=bt&&(/Mobile\/\w+/.test(hr)||!!cn&&cn.maxTouchPoints>2),jt=ps||(cn?/Mac/.test(cn.platform):!1),jk=cn?/Win/.test(cn.platform):!1,Cn=/Android \d/.test(hr),Oi=!!Cf&&"webkitFontSmoothing"in Cf.documentElement.style,Pk=Oi?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Bk(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 gn(t,e){return typeof t=="number"?t:t[e]}function $k(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 Ef(t,e,n){let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=fs(o);continue}let l=o,a=l==i.body,c=a?Bk(i):$k(l),d=0,u=0;if(e.top<c.top+gn(r,"top")?u=-(c.top-e.top+gn(s,"top")):e.bottom>c.bottom-gn(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+gn(s,"top")-c.top:e.bottom-c.bottom+gn(s,"bottom")),e.left<c.left+gn(r,"left")?d=-(c.left-e.left+gn(s,"left")):e.right>c.right-gn(r,"right")&&(d=e.right-c.right+gn(s,"right")),d||u)if(a)i.defaultView.scrollBy(d,u);else{let f=l.scrollLeft,p=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let g=l.scrollLeft-f,y=l.scrollTop-p;e={left:e.left-g,top:e.top-y,right:e.right-g,bottom:e.bottom-y}}let h=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(h))break;o=h=="absolute"?o.offsetParent:fs(o)}}function Hk(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(i,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:Qg(t.dom)}}function Qg(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=fs(r));return e}function zk({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;ey(n,r==0?0:r-e)}function ey(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:i}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let Jr=null;function Fk(t){if(t.setActive)return t.setActive();if(Jr)return t.focus(Jr);let e=Qg(t);t.focus(Jr==null?{get preventScroll(){return Jr={preventScroll:!0},!0}}:void 0),Jr||(Jr=!1,ey(e,0))}function ty(t,e){let n,r=2e8,s,i=0,o=e.top,l=e.top,a,c;for(let d=t.firstChild,u=0;d;d=d.nextSibling,u++){let h;if(d.nodeType==1)h=d.getClientRects();else if(d.nodeType==3)h=vn(d).getClientRects();else continue;for(let f=0;f<h.length;f++){let p=h[f];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let g=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(g<r){n=d,r=g,s=g&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&g&&(i=u+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=u+1)}}return!n&&a&&(n=a,s=c,r=0),n&&n.nodeType==3?Uk(n,s):!n||r&&n.nodeType==1?{node:t,offset:i}:ty(n,s)}function Uk(t,e){let n=t.nodeValue.length,r=document.createRange();for(let s=0;s<n;s++){r.setEnd(t,s+1),r.setStart(t,s);let i=$n(r,1);if(i.top!=i.bottom&&pu(e,i))return{node:t,offset:s+(e.left>=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}function pu(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Vk(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Wk(t,e,n){let{node:r,offset:s}=ty(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,s,i)}function qk(t,e,n,r){let s=-1;for(let i=e,o=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&a.left>r.left||a.top>r.top?s=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(s=l.posAfter),o=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function ny(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=s;;){let o=t.childNodes[i];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(pu(e,c))return ny(o,e,c)}}if((i=(i+1)%r)==s)break}return t}function Kk(t,e){let n=t.dom.ownerDocument,r,s=0,i=Ik(n,e.left,e.top);i&&({node:r,offset:s}=i);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=t.dom.getBoundingClientRect();if(!pu(e,c)||(o=ny(t.dom,e,c),!o))return null}if(bt)for(let c=o;r&&c;c=fs(c))c.draggable&&(r=void 0);if(o=Vk(o,e),r){if($t&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let d=r.childNodes[s],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&s++}let c;Oi&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=qk(t,r,s,e))}l==null&&(l=Wk(t,o,e));let a=t.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Mf(t){return t.top<t.bottom||t.left<t.right}function $n(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Mf(r))return r}return Array.prototype.find.call(n,Mf)||t.getBoundingClientRect()}const Gk=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ry(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),o=Oi||$t;if(r.nodeType==3)if(o&&(Gk.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let a=$n(vn(r,s,s),n);if($t&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=$n(vn(r,s-1,s-1),-1);if(c.top==a.top){let d=$n(vn(r,s,s+1),-1);if(d.top!=a.top)return js(d,d.left<c.left)}}return a}else{let a=s,c=s,d=n<0?1:-1;return n<0&&!s?(c++,d=-1):n>=0&&s==r.nodeValue.length?(a--,d=1):n<0?a--:c++,js($n(vn(r,a,c),d),d<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==Pt(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return tc(a.getBoundingClientRect(),!1)}if(i==null&&s<Pt(r)){let a=r.childNodes[s];if(a.nodeType==1)return tc(a.getBoundingClientRect(),!0)}return tc(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==Pt(r))){let a=r.childNodes[s-1],c=a.nodeType==3?vn(a,Pt(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return js($n(c,1),!1)}if(i==null&&s<Pt(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?vn(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return js($n(c,-1),!0)}return js($n(r.nodeType==3?vn(r):r,-n),n>=0)}function js(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 tc(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 sy(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function Jk(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return sy(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let o=ry(t,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=vn(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(n=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const Yk=/[\u0590-\u08ac]/;function Xk(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,l=t.domSelection();return l?!Yk.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:o:sy(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=t.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",n,"character");let f=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:g}=t.domSelectionRange(),y=p&&!f.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==g;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return h!=null&&(l.caretBidiLevel=h),y}):r.pos==r.start()||r.pos==r.end()}let Af=null,Tf=null,Nf=!1;function Zk(t,e,n){return Af==e&&Tf==n?Nf:(Af=e,Tf=n,Nf=n=="up"||n=="down"?Jk(t,e,n):Xk(t,e,n))}const Ht=0,_f=1,xr=2,dn=3;class Di{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=Ht,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let s=this.children[n];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>st(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!n||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let l=s.children[o];if(l.size){s=l;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],l=i+o.size;if(l>e||o instanceof oy){s=e-i;break}i=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof iy&&i.side>=0;r--);if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?st(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?st(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(s==-1&&e<=c){let d=o+a.border;if(e>=d&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,d);e=o;for(let u=l;u>0;u--){let h=this.children[u-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){s=st(h.dom)+1;break}e-=h.size}s==-1&&(s=0)}if(s>-1&&(c>n||l==this.children.length-1)){n=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){i=st(u.dom);break}n+=u.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let i=Math.min(e,n),o=Math.max(e,n);for(let f=0,p=0;f<this.children.length;f++){let g=this.children[f],y=p+g.size;if(i>p&&o<y)return g.setSelection(e-p-g.border,n-p-g.border,r,s);p=y}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if(($t||bt)&&e==n){let{node:f,offset:p}=l;if(f.nodeType==3){if(u=!!(p&&f.nodeValue[p-1]==`
|
|
12
12
|
`),u&&p==f.nodeValue.length)for(let g=f,y;g;g=g.parentNode){if(y=g.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:st(y)+1});break}let b=g.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let g=f.childNodes[p-1];u=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if($t&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let f=d.focusNode.childNodes[d.focusOffset];f&&f.contentEditable=="false"&&(s=!0)}if(!(s||u&&bt)&&Or(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Or(a.node,a.offset,d.focusNode,d.focusOffset))return;let h=!1;if((c.extend||e==n)&&!(u&&$t)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),h=!0}catch{}}if(!h){if(e>n){let p=l;l=a,a=p}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+i.border,a=o-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==o?xr:_f,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=dn:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?xr:dn}r=o}this.dirty=xr}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?xr:_f;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class iy extends Di{constructor(e,n,r,s){let i,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==Ht&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Qk extends Di{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Dr extends Di{constructor(e,n,r,s,i){super(e,[],r,s),this.mark=n,this.spec=i}static create(e,n,r,s){let i=s.nodeViews[n.type.name],o=i&&i(n,s,r);return(!o||!o.dom)&&(o=Fr.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Dr(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&dn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=dn&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Ht){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ht}}slice(e,n,r){let s=Dr.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;n<o&&(i=Zc(i,n,o,r)),e>0&&(i=Zc(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class er extends Di{constructor(e,n,r,s,i,o,l,a,c){super(e,[],i,o),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,n,r,s,i,o){let l=i.nodeViews[n.type.name],a,c=l&&l(n,i,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,s),d=c&&c.dom,u=c&&c.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Fr.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!u&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let h=d;return d=cy(d,r,n),c?a=new ev(e,n,r,s,d,u||null,h,c,i,o+1):n.isText?new ra(e,n,r,s,d,h,i):new er(e,n,r,s,d,u||null,h,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>O.empty)}return e}matchesNode(e,n,r){return this.dirty==Ht&&e.eq(this.node)&&Xo(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new nv(this,o&&o.node,e);iv(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?Ee.none:this.node.child(d).marks,r,e),a.placeWidget(c,e,s)},(c,d,u,h)=>{a.syncToMarks(c.marks,r,e);let f;a.findNodeMatch(c,d,u,h)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(f=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,d,u,f,e)||a.updateNextNode(c,d,u,e,h,s)||a.addNode(c,d,u,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==xr)&&(o&&this.protectLocalComposition(e,o),ly(this.contentDOM,this.children,e),ps&&ov(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof J)||r<n||s>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,l=lv(this.node.content,o,r-n,s-n);return l<0?null:{node:i,pos:l,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new Qk(this,i,n,s);e.input.compositionNodes.push(o),this.children=Zc(this.children,r,r+s.length,e,o)}update(e,n,r,s){return this.dirty==dn||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=Ht}updateOuterDeco(e){if(Xo(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=ay(this.dom,this.nodeDOM,Xc(this.outerDeco,this.node,n),Xc(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Rf(t,e,n,r,s){cy(r,e,t);let i=new er(void 0,t,e,n,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class ra extends er{constructor(e,n,r,s,i,o,l){super(e,n,r,s,i,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,s){return this.dirty==dn||this.dirty!=Ht&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Ht||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=Ht,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),i=document.createTextNode(s.text);return new ra(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=dn)}get domAtom(){return!1}isText(e){return this.node.text==e}}class oy extends Di{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ht&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class ev extends er{constructor(e,n,r,s,i,o,l,a,c,d){super(e,n,r,s,i,o,l,c,d),this.spec=a}update(e,n,r,s){if(this.dirty==dn)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function ly(t,e,n){let r=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=Of(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(l,r);if(o instanceof Dr){let a=r?r.previousSibling:t.lastChild;ly(o.contentDOM,o.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=Of(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const Ks=function(t){t&&(this.nodeName=t)};Ks.prototype=Object.create(null);const wr=[new Ks];function Xc(t,e,n){if(t.length==0)return wr;let r=n?wr[0]:new Ks,s=[r];for(let i=0;i<t.length;i++){let o=t[i].type.attrs;if(o){o.nodeName&&s.push(r=new Ks(o.nodeName));for(let l in o){let a=o[l];a!=null&&(n&&s.length==1&&s.push(r=new Ks(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return s}function ay(t,e,n,r){if(n==wr&&r==wr)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],l=n[i];if(i){let a;l&&l.nodeName==o.nodeName&&s!=t&&(a=s.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=wr[0]),s=a}tv(s,l||wr[0],o)}return s}function tv(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&t.classList.add(s[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function cy(t,e,n){return ay(t,t,wr,Xc(e,n,t.nodeType!=1))}function Xo(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Of(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class nv{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=rv(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let s=0,i=this.stack.length>>1,o=Math.min(i,e.length);for(;s<o&&(s==i-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<i;)this.destroyRest(),this.top.dirty=Ht,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[i])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Dr.create(this.top,e[i],n,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,n,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))i=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,s,i){let o=this.top.children[s];return o.dirty==dn&&o.dom==o.contentDOM&&(o.dirty=xr),o.update(e,n,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,i,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof er){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let d=a.dom,u,h=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=dn&&Xo(n,a.outerDeco));if(!h&&a.update(e,n,r,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(u=this.recreateWrapper(a,e,n,r,s,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=xr,u.updateChildren(s,o+1),u.dirty=Ht),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,i,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Xo(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=er.create(this.top,n,r,s,i,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,s,i){let o=er.create(this.top,e,n,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new iy(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Dr;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof ra)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((bt||dt)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new oy(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function rv(t,e){let n=e,r=n.children.length,s=t.childCount,i=new Map,o=[];e:for(;s>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof Dr)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(s-1))break;--s,i.set(l,s),o.push(l)}}return{index:s,matched:i,matches:o.reverse()}}function sv(t,e){return t.type.side-e.type.side}function iv(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let c=0;c<t.childCount;c++){let d=t.child(c);r(d,s,e.forChild(i,d),c),i+=d.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let d,u;for(;o<s.length&&s[o].to==i;){let y=s[o++];y.widget&&(d?(u||(u=[d])).push(y):d=y)}if(d)if(u){u.sort(sv);for(let y=0;y<u.length;y++)n(u[y],c,!!a)}else n(d,c,!!a);let h,f;if(a)f=-1,h=a,a=null;else if(c<t.childCount)f=c,h=t.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=i&&l.splice(y--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)l.push(s[o++]);let p=i+h.nodeSize;if(h.isText){let y=p;o<s.length&&s[o].from<y&&(y=s[o].from);for(let b=0;b<l.length;b++)l[b].to<y&&(y=l[b].to);y<p&&(a=h.cut(y-i),h=h.cut(0,y-i),p=y,f=-1)}else for(;o<s.length&&s[o].to<p;)o++;let g=h.isInline&&!h.isLeaf?l.filter(y=>!y.inline):l.slice();r(h,g,e.forChild(i,h),f),i=p}}function ov(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 lv(t,e,n,r){for(let s=0,i=0;s<t.childCount&&i<=r;){let o=t.child(s++),l=i;if(i+=o.nodeSize,!o.isText)continue;let a=o.text;for(;s<t.childCount;){let c=t.child(s++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Zc(t,e,n,r,s){let i=[];for(let o=0,l=0;o<t.length;o++){let a=t[o],c=l,d=l+=a.size;c>=n||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),s&&(i.push(s),s=void 0),d>n&&i.push(a.slice(n-c,a.size,r)))}return i}function mu(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(na(n)){for(a=o;s&&!s.node;)s=s.parent;let u=s.node;if(s&&u.isAtom&&q.isSelectable(u)&&s.parent&&!(u.isInline&&Dk(n.focusNode,n.focusOffset,s.dom))){let h=s.posBefore;c=new q(o==h?l:r.resolve(h))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let u=o,h=o;for(let f=0;f<n.rangeCount;f++){let p=n.getRangeAt(f);u=Math.min(u,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),h=Math.max(h,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,o]=h==t.state.selection.anchor?[h,u]:[u,h],l=r.resolve(o)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!c){let u=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;c=gu(t,d,l,u)}return c}function dy(t){return t.editable?t.hasFocus():hy(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function An(t,e=!1){let n=t.state.selection;if(uy(t,n),!!dy(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&dt){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Or(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)cv(t);else{let{anchor:r,head:s}=n,i,o;Df&&!(n instanceof J)&&(n.$from.parent.inlineContent||(i=Lf(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=Lf(t,n.to))),t.docView.setSelection(r,s,t,e),Df&&(i&&If(i),o&&If(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&av(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Df=bt||dt&&Zg<63;function Lf(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(bt&&s&&s.contentEditable=="false")return nc(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return nc(s);if(i)return nc(i)}}function nc(t){return t.contentEditable="true",bt&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function If(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function av(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!dy(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function cv(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,st(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ct&&Qn<=11&&(n.disabled=!0,n.disabled=!1)}function uy(t,e){if(e instanceof q){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(jf(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else jf(t)}function jf(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function gu(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||J.between(e,n,r)}function Pf(t){return t.editable&&!t.hasFocus()?!1:hy(t)}function hy(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 dv(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Or(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Qc(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&ee.findFrom(i,e)}function zn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Bf(t,e,n){let r=t.state.selection;if(r instanceof J)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return zn(t,new J(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Qc(t.state,e);return s&&s instanceof q?zn(t,s):!1}else if(!(jt&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?q.isSelectable(i)?zn(t,new q(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):Oi?zn(t,new J(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof q&&r.node.isInline)return zn(t,new J(e>0?r.$to:r.$from));{let s=Qc(t.state,e);return s?zn(t,s):!1}}}function Zo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Gs(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Yr(t,e){return e<0?uv(t):hv(t)}function uv(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for($t&&n.nodeType==1&&r<Zo(n)&&Gs(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Gs(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(fy(n))break;{let l=n.previousSibling;for(;l&&Gs(l,-1);)s=n.parentNode,i=st(l),l=l.previousSibling;if(l)n=l,r=Zo(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?ed(t,n,r):s&&ed(t,s,i)}function hv(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=Zo(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Gs(l,1))i=n,o=++r;else break}else{if(fy(n))break;{let l=n.nextSibling;for(;l&&Gs(l,1);)i=l.parentNode,o=st(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=Zo(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&ed(t,i,o)}function fy(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function fv(t,e){for(;t&&e==t.childNodes.length&&!Ri(t);)e=st(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function pv(t,e){for(;t&&!e&&!Ri(t);)e=st(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function ed(t,e,n){if(e.nodeType!=3){let i,o;(o=fv(e,n))?(e=o,n=0):(i=pv(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(na(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&An(t)},50)}function $f(t,e){let n=t.state.doc.resolve(e);if(!(dt||jk)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Hf(t,e,n){let r=t.state.selection;if(r instanceof J&&!r.empty||n.indexOf("s")>-1||jt&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Qc(t.state,e);if(o&&o instanceof q)return zn(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof St?ee.near(o,e):ee.findFrom(o,e);return l?zn(t,l):!1}return!1}function zf(t,e){if(!(t.state.selection instanceof J))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function Ff(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function mv(t){if(!bt||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;Ff(t,r,"true"),setTimeout(()=>Ff(t,r,"false"),20)}return!1}function gv(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function yv(t,e){let n=e.keyCode,r=gv(e);if(n==8||jt&&n==72&&r=="c")return zf(t,-1)||Yr(t,-1);if(n==46&&!e.shiftKey||jt&&n==68&&r=="c")return zf(t,1)||Yr(t,1);if(n==13||n==27)return!0;if(n==37||jt&&n==66&&r=="c"){let s=n==37?$f(t,t.state.selection.from)=="ltr"?-1:1:-1;return Bf(t,s,r)||Yr(t,s)}else if(n==39||jt&&n==70&&r=="c"){let s=n==39?$f(t,t.state.selection.from)=="ltr"?1:-1:1;return Bf(t,s,r)||Yr(t,s)}else{if(n==38||jt&&n==80&&r=="c")return Hf(t,-1,r)||Yr(t,-1);if(n==40||jt&&n==78&&r=="c")return mv(t)||Hf(t,1,r)||Yr(t,1);if(r==(jt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function yu(t,e){t.someProp("transformCopied",f=>{e=f(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let f=r.firstChild;n.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let o=t.someProp("clipboardSerializer")||Fr.fromSchema(t.state.schema),l=xy(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=by[c.nodeName.toLowerCase()]);){for(let f=d.length-1;f>=0;f--){let p=l.createElement(d[f]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${u?` -${u}`:""} ${JSON.stringify(n)}`);let h=t.someProp("clipboardTextSerializer",f=>f(e,t))||e.content.textBetween(0,e.content.size,`
|
|
13
13
|
|
|
14
14
|
`);return{dom:a,text:h,slice:e}}function py(t,e,n,r,s){let i=s.parent.type.spec.code,o,l;if(!n&&!e)return null;let a=!!e&&(r||i||!n);if(a){if(t.someProp("transformPastedText",h=>{e=h(e,i||r,t)}),i)return l=new P(O.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
15
|
-
`))),0,0),t.someProp("transformPasted",h=>{l=h(l,t,!0)}),l;let u=t.someProp("clipboardTextParser",h=>h(e,s,r,t));if(u)l=u;else{let h=s.marks(),{schema:f}=t.state,p=Fr.fromSchema(f);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=o.appendChild(document.createElement("p"));g&&y.appendChild(p.serializeNode(f.text(g,h)))})}}else t.someProp("transformPastedHTML",u=>{n=u(n,t)}),o=kv(n),Oi&&vv(o);let c=o&&o.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let h=o.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;o=h}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Ws.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!bv.test(h.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Sv(Uf(l,+d[1],+d[2]),d[4]);else if(l=P.maxOpen(xv(l.content,s),!0),l.openStart||l.openEnd){let u=0,h=0;for(let f=l.content.firstChild;u<l.openStart&&!f.type.spec.isolating;u++,f=f.firstChild);for(let f=l.content.lastChild;h<l.openEnd&&!f.type.spec.isolating;h++,f=f.lastChild);l=Uf(l,u,h)}return t.someProp("transformPasted",u=>{l=u(l,t,a)}),l}const bv=/^(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 xv(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&i.length&&gy(a,i,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=yy(o[o.length-1],i.length));let d=my(l,a);o.push(d),s=s.matchType(d.type),i=a}}),o)return O.from(o)}return t}function my(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,O.from(t));return t}function gy(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=gy(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(O.from(my(n,t,s+1))))}}function yy(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,yy(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(O.empty,!0);return t.copy(n.append(r))}function td(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(i=0),s<r-1&&(l=td(l,e,n,r,s+1,i)),s>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(O.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function Uf(t,e,n){return e<t.openStart&&(t=new P(td(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new P(td(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const by={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Vf=null;function xy(){return Vf||(Vf=document.implementation.createHTMLDocument("title"))}let rc=null;function wv(t){let e=window.trustedTypes;return e?(rc||(rc=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),rc.createHTML(t)):t}function kv(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=xy().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&by[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=wv(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function vv(t){let e=t.querySelectorAll(dt?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function Sv(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=O.from(a.create(r[l+1],s)),i++,o++}return new P(s,i,o)}const xt={},wt={},Cv={touchstart:!0,touchmove:!0};class Ev{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Mv(t){for(let e in xt){let n=xt[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Tv(t,r)&&!bu(t,r)&&(t.editable||!(r.type in wt))&&n(t,r)},Cv[e]?{passive:!0}:void 0)}bt&&t.dom.addEventListener("input",()=>null),nd(t)}function Jn(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Av(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 nd(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>bu(t,r))})}function bu(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Tv(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 Nv(t,e){!bu(t,e)&&xt[e.type]&&(t.editable||!(e.type in wt))&&xt[e.type](t,e)}wt.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!ky(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Cn&&dt&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),ps&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,yr(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||yv(t,n)?n.preventDefault():Jn(t,"key")};wt.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};wt.keypress=(t,e)=>{let n=e;if(ky(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||jt&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof J)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function sa(t){return{left:t.clientX,top:t.clientY}}function _v(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function xu(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,l=>o>i.depth?l(t,n,i.nodeAfter,i.before(o),s,!0):l(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function ss(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function Rv(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&q.isSelectable(r)?(ss(t,new q(n)),!0):!1}function Ov(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof q&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(q.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(ss(t,q.create(t.state.doc,s)),!0):!1}function Dv(t,e,n,r,s){return xu(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?Ov(t,n):Rv(t,n))}function Lv(t,e,n,r){return xu(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function Iv(t,e,n,r){return xu(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||jv(t,n,r)}function jv(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(ss(t,J.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)ss(t,J.create(r,l+1,l+1+o.content.size));else if(q.isSelectable(o))ss(t,q.create(r,l));else continue;return!0}}function wu(t){return Qo(t)}const wy=jt?"metaKey":"ctrlKey";xt.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=wu(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&_v(n,t.input.lastClick)&&!n[wy]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=t.posAtCoords(sa(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Pv(t,o,n,!!r)):(i=="doubleClick"?Lv:Iv)(t,o.pos,o.inside,n)?n.preventDefault():Jn(t,"pointer"))};class Pv{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[wy],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);i=d.parent,o=d.depth?d.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof q&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&$t&&!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)),Jn(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(()=>An(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(sa(e))),this.updateAllowDefault(e),this.allowDefault||!n?Jn(this.view,"pointer"):Dv(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||bt&&this.mightDrag&&!this.mightDrag.node.isAtom||dt&&!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)?(ss(this.view,ee.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Jn(this.view,"pointer")}move(e){this.updateAllowDefault(e),Jn(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)}}xt.touchstart=t=>{t.input.lastTouch=Date.now(),wu(t),Jn(t,"pointer")};xt.touchmove=t=>{t.input.lastTouch=Date.now(),Jn(t,"pointer")};xt.contextmenu=t=>wu(t);function ky(t,e){return t.composing?!0:bt&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Bv=Cn?5e3:-1;wt.compositionstart=wt.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof J&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),Qo(t,!0),t.markCursor=null;else if(Qo(t,!e.selection.empty),$t&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}vy(t,Bv)};wt.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++,vy(t,20))};function vy(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Qo(t),e))}function Sy(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Hv());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function $v(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Rk(e.focusNode,e.focusOffset),r=Ok(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function Hv(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Qo(t,e=!1){if(!(Cn&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Sy(t),e||t.docView&&t.docView.dirty){let n=mu(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function zv(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const di=Ct&&Qn<15||ps&&Pk<604;xt.copy=wt.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=di?null:n.clipboardData,o=r.content(),{dom:l,text:a}=yu(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):zv(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Fv(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Uv(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ui(t,r.value,null,s,e):ui(t,r.textContent,r.innerHTML,s,e)},50)}function ui(t,e,n,r,s){let i=py(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,s,i||P.empty)))return!0;if(!i)return!1;let o=Fv(i),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Cy(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," "):""}wt.paste=(t,e)=>{let n=e;if(t.composing&&!Cn)return;let r=di?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&ui(t,Cy(r),r.getData("text/html"),s,n)?n.preventDefault():Uv(t,n)};class Ey{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const Vv=jt?"altKey":"ctrlKey";function My(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[Vv]}xt.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(sa(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof q?s.to-1:s.to))){if(r&&r.mightDrag)o=q.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let u=t.docView.nearestDesc(n.target,!0);u&&u.node.type.spec.draggable&&u!=t.docView&&(o=q.create(t.state.doc,u.posBefore))}}let l=(o||t.state.selection).content(),{dom:a,text:c,slice:d}=yu(t,l);(!n.dataTransfer.files.length||!dt||Zg>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(di?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",di||n.dataTransfer.setData("text/plain",c),t.dragging=new Ey(d,My(t,n),o)};xt.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};wt.dragover=wt.dragenter=(t,e)=>e.preventDefault();wt.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let s=t.posAtCoords(sa(n));if(!s)return;let i=t.state.doc.resolve(s.pos),o=r&&r.slice;o?t.someProp("transformPasted",p=>{o=p(o,t,!1)}):o=py(t,Cy(n.dataTransfer),di?null:n.dataTransfer.getData("text/html"),!1,i);let l=!!(r&&My(t,n));if(t.someProp("handleDrop",p=>p(t,n,o||P.empty,l))){n.preventDefault();return}if(!o)return;n.preventDefault();let a=o?Og(t.state.doc,i.pos,o):i.pos;a==null&&(a=i.pos);let c=t.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,h=c.doc;if(u?c.replaceRangeWith(d,d,o.content.firstChild):c.replaceRange(d,d,o),c.doc.eq(h))return;let f=c.doc.resolve(d);if(u&&q.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new q(f));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((g,y,b,w)=>p=w),c.setSelection(gu(t,f,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))};xt.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())&&An(t)},20))};xt.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)};xt.beforeinput=(t,e)=>{if(dt&&Cn&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,yr(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in wt)xt[t]=wt[t];function hi(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 el{constructor(e,n){this.toDOM=e,this.spec=n||Er,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new _e(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof el&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&hi(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class tr{constructor(e,n){this.attrs=e,this.spec=n||Er}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new _e(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof tr&&hi(this.attrs,e.attrs)&&hi(this.spec,e.spec)}static is(e){return e.type instanceof tr}destroy(){}}class ku{constructor(e,n){this.attrs=e,this.spec=n||Er}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new _e(i.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof ku&&hi(this.attrs,e.attrs)&&hi(this.spec,e.spec)}destroy(){}}class _e{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new _e(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new _e(e,e,new el(n,r))}static inline(e,n,r,s){return new _e(e,n,new tr(r,s))}static node(e,n,r,s){return new _e(e,n,new ku(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof tr}get widget(){return this.type instanceof el}}const Zr=[],Er={};class ye{constructor(e,n){this.local=e.length?e:Zr,this.children=n.length?n:Zr}static create(e,n){return n.length?tl(n,e,0,Er):ct}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,s+l,i)}}map(e,n,r){return this==ct||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Er)}mapInner(e,n,r,s,i){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(n,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?Wv(this.children,o||[],e,n,r,s,i):o?new ye(o.sort(Mr),Zr):ct}add(e,n){return n.length?this==ct?ye.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((l,a)=>{let c=a+r,d;if(d=Ty(n,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,d,c+1):s.splice(i,0,a,a+l.nodeSize,tl(d,l,c+1,Er)),i+=3}});let o=Ay(i?Ny(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new ye(o.length?this.local.concat(o).sort(Mr):this.local,s||this.children)}remove(e){return e.length==0||this==ct?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+n,a=r[i+1]+n;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(o||(o=[])).push(u));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(o,l+1);c!=ct?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new ye(s,r):ct}forChild(e,n){if(this==ct)return this;if(n.isLeaf)return ye.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>i&&a.type instanceof tr){let c=Math.max(i,a.from)-i,d=Math.min(o,a.to)-i;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new ye(s.sort(Mr),Zr);return r?new Vn([l,r]):l}return r||ct}eq(e){if(this==e)return!0;if(!(e instanceof ye)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return vu(this.localsInner(e))}localsInner(e){if(this==ct)return Zr;if(e.inlineContent||!this.local.some(tr.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof tr||n.push(this.local[r]);return n}forEachSet(e){e(this)}}ye.empty=new ye([],[]);ye.removeOverlap=vu;const ct=ye.empty;class Vn{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,Er));return Vn.from(r)}forChild(e,n){if(n.isLeaf)return ye.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=ct&&(i instanceof Vn?r=r.concat(i.members):r.push(i))}return Vn.from(r)}eq(e){if(!(e instanceof Vn)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?vu(r?n:n.sort(Mr)):Zr}static from(e){switch(e.length){case 0:return ct;case 1:return e[0];default:return new Vn(e.every(n=>n instanceof ye)?e:e.reduce((n,r)=>n.concat(r instanceof ye?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function Wv(t,e,n,r,s,i,o){let l=t.slice();for(let c=0,d=i;c<n.maps.length;c++){let u=0;n.maps[c].forEach((h,f,p,g)=>{let y=g-p-(f-h);for(let b=0;b<l.length;b+=3){let w=l[b+1];if(w<0||h>w+d-u)continue;let M=l[b]+d-u;f>=M?l[b+1]=h<=M?-2:-1:h>=d&&y&&(l[b]+=y,l[b+1]+=y)}u+=y}),d=n.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=n.map(t[c]+i),u=d-s;if(u<0||u>=r.content.size){a=!0;continue}let h=n.map(t[c+1]+i,-1),f=h-s,{index:p,offset:g}=r.content.findIndex(u),y=r.maybeChild(p);if(y&&g==u&&g+y.nodeSize==f){let b=l[c+2].mapInner(n,y,d+1,t[c]+i+1,o);b!=ct?(l[c]=u,l[c+1]=f,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=qv(l,t,e,n,s,i,o),d=tl(c,r,0,o);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,h=0;u<d.children.length;u+=3){let f=d.children[u];for(;h<l.length&&l[h]<f;)h+=3;l.splice(h,0,d.children[u],d.children[u+1],d.children[u+2])}}return new ye(e.sort(Mr),l)}function Ay(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new _e(s.from+e,s.to+e,s.type))}return n}function qv(t,e,n,r,s,i,o){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(r,s,c);u?n.push(u):o.onRemove&&o.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function Ty(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function Ny(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function tl(t,e,n,r){let s=[],i=!1;e.forEach((l,a)=>{let c=Ty(t,l,a+n);if(c){i=!0;let d=tl(c,l,n+a+1,r);d!=ct&&s.push(a,a+l.nodeSize,d)}});let o=Ay(i?Ny(t):t,-n).sort(Mr);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new ye(o,s):ct}function Mr(t,e){return t.from-e.from||t.to-e.to}function vu(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),Wf(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),Wf(e,s,r.copy(i.from,r.to)));break}}}return e}function Wf(t,e,n){for(;e<t.length&&Mr(n,t[e])>0;)e++;t.splice(e,0,n)}function sc(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ct&&e.push(r)}),t.cursorWrapper&&e.push(ye.create(t.state.doc,[t.cursorWrapper.deco])),Vn.from(e)}const Kv={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Gv=Ct&&Qn<=11;class Jv{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 Yv{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Jv,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);Ct&&Qn<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),Gv&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Kv)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Pf(this.view)){if(this.suppressingSelectionUpdates)return An(this.view);if(Ct&&Qn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Or(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=fs(i))n.add(i);for(let i=e.anchorNode;i;i=fs(i))if(n.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Pf(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,l=!1,a=[];if(e.editable)for(let d=0;d<n.length;d++){let u=this.registerMutation(n[d],a);u&&(i=i<0?u.from:Math.min(u.from,i),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(l=!0))}if($t&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,h]=d;u.parentNode&&u.parentNode.parentNode==h.parentNode?h.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let h of d){let f=h.parentNode;f&&f.nodeName=="LI"&&(!u||Qv(e,u)!=f)&&h.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&na(r)&&(c=mu(e))&&c.eq(ee.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,An(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),Xv(e)),this.handleDOMChange(i,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||An(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 d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];n.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(Ct&&Qn<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:h}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h)}let o=s&&s.parentNode==e.target?st(s)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=i&&i.parentNode==e.target?st(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let qf=new WeakMap,Kf=!1;function Xv(t){if(!qf.has(t)&&(qf.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=$t,Kf)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Kf=!0}}function Gf(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Or(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function Zv(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return Gf(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Gf(t,n):null}function Qv(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function eS(t,e,n){let{node:r,fromOffset:s,toOffset:i,from:o,to:l}=t.docView.parseRange(e,n),a=t.domSelectionRange(),c,d=a.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],na(a)||c.push({node:a.focusNode,offset:a.focusOffset})),dt&&t.input.lastKeyCode===8)for(let y=i;y>s;y--){let b=r.childNodes[y-1],w=b.pmViewDesc;if(b.nodeName=="BR"&&!w){i=y;break}if(!w||w.size)break}let u=t.state.doc,h=t.someProp("domParser")||Ws.fromSchema(t.state.schema),f=u.resolve(o),p=null,g=h.parse(r,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:s,to:i,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:tS,context:f});if(c&&c[0].pos!=null){let y=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=y),p={anchor:y+o,head:b+o}}return{doc:g,sel:p,from:o,to:l}}function tS(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(bt&&/^(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||bt&&/^(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 nS=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function rS(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let k=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,v=mu(t,k);if(v&&!t.state.selection.eq(v)){if(dt&&Cn&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",N=>N(t,yr(13,"Enter"))))return;let T=t.state.tr.setSelection(v);k=="pointer"?T.setMeta("pointer",!0):k=="key"&&T.scrollIntoView(),i&&T.setMeta("composition",i),t.dispatch(T)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=eS(t,e,n),d=t.state.doc,u=d.slice(c.from,c.to),h,f;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(h=t.state.selection.to,f="end"):(h=t.state.selection.from,f="start"),t.input.lastKeyCode=null;let p=oS(u.content,c.doc.content,c.from,h,f);if(p&&t.input.domChangeCount++,(ps&&t.input.lastIOSEnter>Date.now()-225||Cn)&&s.some(k=>k.nodeType==1&&!nS.test(k.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",k=>k(t,yr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof J&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let k=Jf(t,t.state.doc,c.sel);if(k&&!k.eq(t.state.selection)){let v=t.state.tr.setSelection(k);i&&v.setMeta("composition",i),t.dispatch(v)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof J&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),Ct&&Qn<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let g=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),b=d.resolve(p.start),w=g.sameParent(y)&&g.parent.inlineContent&&b.end()>=p.endA;if((ps&&t.input.lastIOSEnter>Date.now()-225&&(!w||s.some(k=>k.nodeName=="DIV"||k.nodeName=="P"))||!w&&g.pos<c.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(c.doc.textBetween(g.pos,y.pos,"","")))&&t.someProp("handleKeyDown",k=>k(t,yr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&iS(d,p.start,p.endA,g,y)&&t.someProp("handleKeyDown",k=>k(t,yr(8,"Backspace")))){Cn&&dt&&t.domObserver.suppressSelectionUpdates();return}dt&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),Cn&&!w&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(k){return k(t,yr(13,"Enter"))})},20));let M=p.start,S=p.endA,A=k=>{let v=k||t.state.tr.replace(M,S,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let T=Jf(t,v.doc,c.sel);T&&!(dt&&t.composing&&T.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(T.head==M||T.head==v.mapping.map(S)-1)||Ct&&T.empty&&T.head==M)&&v.setSelection(T)}return i&&v.setMeta("composition",i),v.scrollIntoView()},x;if(w)if(g.pos==y.pos){Ct&&Qn<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>An(t),20));let k=A(t.state.tr.delete(M,S)),v=d.resolve(p.start).marksAcross(d.resolve(p.endA));v&&k.ensureMarks(v),t.dispatch(k)}else if(p.endA==p.endB&&(x=sS(g.parent.content.cut(g.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start())))){let k=A(t.state.tr);x.type=="add"?k.addMark(M,S,x.mark):k.removeMark(M,S,x.mark),t.dispatch(k)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let k=g.parent.textBetween(g.parentOffset,y.parentOffset),v=()=>A(t.state.tr.insertText(k,M,S));t.someProp("handleTextInput",T=>T(t,M,S,k,v))||t.dispatch(v())}else t.dispatch(A());else t.dispatch(A())}function Jf(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:gu(t,e.resolve(n.anchor),e.resolve(n.head))}function sS(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,o,l,a;for(let d=0;d<r.length;d++)s=r[d].removeFromSet(s);for(let d=0;d<n.length;d++)i=n[d].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],o="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&i.length==1)l=i[0],o="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(O.from(c).eq(t))return{mark:l,type:o}}function iS(t,e,n,r,s){if(n-e<=s.pos-r.pos||ic(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=t.resolve(ic(i,!0,!0));return!o.parent.isTextblock||o.pos>n||ic(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function ic(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function oS(t,e,n,r,s){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(s=="end"){let a=Math.max(0,i-Math.min(o,l));r-=o+a-i}if(o<i&&t.size<e.size){let a=r<=i&&r>=o?i-r:0;i-=a,i&&i<e.size&&Yf(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-o),o=i}else if(l<i){let a=r<=i&&r>=l?i-r:0;i-=a,i&&i<t.size&&Yf(t.textBetween(i-1,i+1))&&(i+=a?1:-1),o=i+(o-l),l=i}return{start:i,endA:o,endB:l}}function Yf(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class _y{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 Ev,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(tp),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=Qf(this),Zf(this),this.nodeViews=ep(this),this.docView=Rf(this.state.doc,Xf(this),sc(this),this.dom,this),this.domObserver=new Yv(this,(r,s,i,o)=>rS(this,r,s,i,o)),this.domObserver.start(),Mv(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&&nd(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(tp),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(Sy(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let f=ep(this);aS(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&nd(this),this.editable=Qf(this),Zf(this);let a=sc(this),c=Xf(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(s.selection))&&(o=!0);let h=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Hk(this);if(o){this.domObserver.stop();let f=u&&(Ct||dt)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&lS(s.selection,e.selection);if(u){let p=dt?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=$v(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Rf(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&dv(this))?An(this,f):(uy(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():h&&zk(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof q){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Ef(this,n.getBoundingClientRect(),e)}else Ef(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new Ey(e.slice,e.move,s<0?void 0:q.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(s=n?n(l):l))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let l=i[o].props[e];if(l!=null&&(s=n?n(l):l))return s}}hasFocus(){if(Ct){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Fk(this.dom),An(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Kk(this,e)}coordsAtPos(e,n=1){return ry(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return Zk(this,n||this.state,e)}pasteHTML(e,n){return ui(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return ui(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return yu(this,e)}destroy(){this.docView&&(Av(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],sc(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Nk())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Nv(this,e)}domSelectionRange(){let e=this.domSelection();return e?bt&&this.root.nodeType===11&&Lk(this.dom.ownerDocument)==this.dom&&Zv(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}_y.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Xf(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"),[_e.node(0,t.state.doc.content.size,e)]}function Zf(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:_e.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Qf(t){return!t.someProp("editable",e=>e(t.state)===!1)}function lS(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 ep(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function aS(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function tp(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 nr={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:"'"},nl={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},cS=typeof navigator<"u"&&/Mac/.test(navigator.platform),dS=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var it=0;it<10;it++)nr[48+it]=nr[96+it]=String(it);for(var it=1;it<=24;it++)nr[it+111]="F"+it;for(var it=65;it<=90;it++)nr[it]=String.fromCharCode(it+32),nl[it]=String.fromCharCode(it);for(var oc in nr)nl.hasOwnProperty(oc)||(nl[oc]=nr[oc]);function uS(t){var e=cS&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||dS&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?nl:nr)[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 hS=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),fS=typeof navigator<"u"&&/Win/.test(navigator.platform);function pS(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))hS?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function mS(t){let e=Object.create(null);for(let n in t)e[pS(n)]=t[n];return e}function lc(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function gS(t){return new pe({props:{handleKeyDown:Su(t)}})}function Su(t){let e=mS(t);return function(n,r){let s=uS(r),i,o=e[lc(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[lc(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(fS&&r.ctrlKey&&r.altKey)&&(i=nr[r.keyCode])&&i!=s){let l=e[lc(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var yS=Object.defineProperty,Cu=(t,e)=>{for(var n in e)yS(t,n,{get:e[n],enumerable:!0})};function ia(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}var oa=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:s}=n,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...c)=>{const d=l(...c)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o=[],l=!!t,a=t||s.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(a),o.every(u=>u===!0)),d={...Object.fromEntries(Object.entries(n).map(([u,h])=>[u,(...p)=>{const g=this.buildProps(a,e),y=h(...p)(g);return o.push(y),d}])),run:c};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.tr,i=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o={tr:t,editor:r,view:i,state:ia({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)(o)]))}};return o}},Ry={};Cu(Ry,{blur:()=>bS,clearContent:()=>xS,clearNodes:()=>wS,command:()=>kS,createParagraphNear:()=>vS,cut:()=>SS,deleteCurrentNode:()=>CS,deleteNode:()=>ES,deleteRange:()=>MS,deleteSelection:()=>AS,enter:()=>TS,exitCode:()=>NS,extendMarkRange:()=>_S,first:()=>RS,focus:()=>OS,forEach:()=>DS,insertContent:()=>LS,insertContentAt:()=>PS,joinBackward:()=>HS,joinDown:()=>$S,joinForward:()=>zS,joinItemBackward:()=>FS,joinItemForward:()=>US,joinTextblockBackward:()=>VS,joinTextblockForward:()=>WS,joinUp:()=>BS,keyboardShortcut:()=>KS,lift:()=>GS,liftEmptyBlock:()=>JS,liftListItem:()=>YS,newlineInCode:()=>XS,resetAttributes:()=>ZS,scrollIntoView:()=>QS,selectAll:()=>eC,selectNodeBackward:()=>tC,selectNodeForward:()=>nC,selectParentNode:()=>rC,selectTextblockEnd:()=>sC,selectTextblockStart:()=>iC,setContent:()=>oC,setMark:()=>SC,setMeta:()=>CC,setNode:()=>EC,setNodeSelection:()=>MC,setTextSelection:()=>AC,sinkListItem:()=>TC,splitBlock:()=>NC,splitListItem:()=>_C,toggleList:()=>RC,toggleMark:()=>OC,toggleNode:()=>DC,toggleWrap:()=>LC,undoInputRule:()=>IC,unsetAllMarks:()=>jC,unsetMark:()=>PC,updateAttributes:()=>BC,wrapIn:()=>$C,wrapInList:()=>HC});var bS=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),xS=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),wS=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:i,$to:o})=>{t.doc.nodesBetween(i.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(a)),h=c.resolve(d.map(a+l.nodeSize)),f=u.blockRange(h);if(!f)return;const p=Cs(f);if(l.type.isTextblock){const{defaultType:g}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(f.start,g)}(p||p===0)&&e.lift(f,p)})}),!0},kS=t=>e=>t(e),vS=()=>({state:t,dispatch:e})=>Kg(t,e),SS=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,i=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new J(r.doc.resolve(Math.max(o-1,0)))),!0},CS=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const l=s.before(i),a=s.after(i);t.delete(l,a).scrollIntoView()}return!0}return!1};function Ke(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var ES=t=>({tr:e,state:n,dispatch:r})=>{const s=Ke(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const a=i.before(o),c=i.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},MS=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},AS=()=>({state:t,dispatch:e})=>cu(t,e),TS=()=>({commands:t})=>t.keyboardShortcut("Enter"),NS=()=>({state:t,dispatch:e})=>pk(t,e);function Eu(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function rl(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:Eu(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function Oy(t,e,n={}){return t.find(r=>r.type===e&&rl(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function np(t,e,n={}){return!!Oy(t,e,n)}function Mu(t,e,n){var r;if(!t||!e)return;let s=t.parent.childAfter(t.parentOffset);if((!s.node||!s.node.marks.some(d=>d.type===e))&&(s=t.parent.childBefore(t.parentOffset)),!s.node||!s.node.marks.some(d=>d.type===e)||(n=n||((r=s.node.marks[0])==null?void 0:r.attrs),!Oy([...s.node.marks],e,n)))return;let o=s.index,l=t.start()+s.offset,a=o+1,c=l+s.node.nodeSize;for(;o>0&&np([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;a<t.parent.childCount&&np([...t.parent.child(a).marks],e,n);)c+=t.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function Rn(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var _S=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const i=Rn(t,r.schema),{doc:o,selection:l}=n,{$from:a,from:c,to:d}=l;if(s){const u=Mu(a,i,e);if(u&&u.from<=c&&u.to>=d){const h=J.create(o,u.from,u.to);n.setSelection(h)}}return!0},RS=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function Dy(t){return t instanceof J}function kr(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Ly(t,e=null){if(!e)return null;const n=ee.atStart(t),r=ee.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,i=r.to;return e==="all"?J.create(t,kr(0,s,i),kr(t.content.size,s,i)):J.create(t,kr(e,s,i),kr(e,s,i))}function Iy(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function la(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var OS=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(la()||Iy())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(i&&t===null&&!Dy(n.state.selection))return o(),!0;const l=Ly(s.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},DS=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),LS=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),jy=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&&jy(r)}return t};function uo(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return jy(n)}function fi(t,e,n){if(t instanceof Zn||t instanceof O)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return O.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),fi("",e,n)}if(s){if(n.errorOnInvalidContent){let o=!1,l="";const a=new kg({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?Ws.fromSchema(a).parseSlice(uo(t),n.parseOptions):Ws.fromSchema(a).parse(uo(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=Ws.fromSchema(e);return n.slice?i.parseSlice(uo(t),n.parseOptions).content:i.parse(uo(t),n.parseOptions)}return fi("",e,n)}function IS(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof Ze||s instanceof Qe))return;const i=t.mapping.maps[r];let o=0;i.forEach((l,a,c,d)=>{o===0&&(o=d)}),t.setSelection(ee.near(t.doc.resolve(o),n))}var jS=t=>!("type"in t),PS=(t,e,n)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const a=y=>{i.emit("contentError",{editor:i,error:y,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{fi(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(y){a(y)}try{l=fi(e,i.schema,{parseOptions:c,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(y){return a(y),!1}let{from:d,to:u}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},h=!0,f=!0;if((jS(l)?l:[l]).forEach(y=>{y.check(),h=h?y.isText&&y.marks.length===0:!1,f=f?y.isBlock:!1}),d===u&&f){const{parent:y}=r.doc.resolve(d);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(d-=1,u+=1)}let g;if(h){if(Array.isArray(e))g=e.map(y=>y.text||"").join("");else if(e instanceof O){let y="";e.forEach(b=>{b.text&&(y+=b.text)}),g=y}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,d,u)}else{g=l;const y=r.doc.resolve(d),b=y.node(),w=y.parentOffset===0,M=b.isText||b.isTextblock,S=b.content.size>0;w&&M&&S&&(d=Math.max(0,d-1)),r.replaceWith(d,u,g)}n.updateSelection&&IS(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:g}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:g})}return!0},BS=()=>({state:t,dispatch:e})=>uk(t,e),$S=()=>({state:t,dispatch:e})=>hk(t,e),HS=()=>({state:t,dispatch:e})=>Hg(t,e),zS=()=>({state:t,dispatch:e})=>Vg(t,e),FS=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Ql(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},US=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Ql(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},VS=()=>({state:t,dispatch:e})=>ck(t,e),WS=()=>({state:t,dispatch:e})=>dk(t,e);function Py(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function qS(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))la()||Py()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var KS=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const i=qS(t).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a?.steps.forEach(c=>{const d=c.map(r.mapping);d&&s&&r.maybeStep(d)}),!0};function rr(t,e,n={}){const{from:r,to:s,empty:i}=t.selection,o=e?Ke(e,t.schema):null,l=[];t.doc.nodesBetween(r,s,(u,h)=>{if(u.isText)return;const f=Math.max(r,h),p=Math.min(s,h+u.nodeSize);l.push({node:u,from:f,to:p})});const a=s-r,c=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>rl(u.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((u,h)=>u+h.to-h.from,0)>=a}var GS=(t,e={})=>({state:n,dispatch:r})=>{const s=Ke(t,n.schema);return rr(n,s,e)?fk(n,r):!1},JS=()=>({state:t,dispatch:e})=>Gg(t,e),YS=t=>({state:e,dispatch:n})=>{const r=Ke(t,e.schema);return Ek(r)(e,n)},XS=()=>({state:t,dispatch:e})=>qg(t,e);function aa(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function rp(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var ZS=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=aa(typeof t=="string"?t:t.name,r.schema);return l?(l==="node"&&(i=Ke(t,r.schema)),l==="mark"&&(o=Rn(t,r.schema)),s&&n.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,d)=>{i&&i===c.type&&n.setNodeMarkup(d,void 0,rp(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(u=>{o===u.type&&n.addMark(d,d+c.nodeSize,o.create(rp(u.attrs,e)))})})}),!0):!1},QS=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),eC=()=>({tr:t,dispatch:e})=>{if(e){const n=new St(t.doc);t.setSelection(n)}return!0},tC=()=>({state:t,dispatch:e})=>Fg(t,e),nC=()=>({state:t,dispatch:e})=>Wg(t,e),rC=()=>({state:t,dispatch:e})=>yk(t,e),sC=()=>({state:t,dispatch:e})=>wk(t,e),iC=()=>({state:t,dispatch:e})=>xk(t,e);function rd(t,e,n={},r={}){return fi(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var oC=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:l})=>{const{doc:a}=i;if(r.preserveWhitespace!=="full"){const c=rd(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return o&&i.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function By(t,e){const n=Rn(e,t.schema),{from:r,to:s,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function $y(t,e){const n=new ou(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function lC(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function sd(t,e){const n=[];return t.descendants((r,s)=>{e(r)&&n.push({node:r,pos:s})}),n}function aC(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function Hy(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 ca(t){return e=>Hy(e.$from,t)}function G(t,e,n){return t.config[e]===void 0&&t.parent?G(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?G(t.parent,e,n):null}):t.config[e]}function Au(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=G(e,"addExtensions",n);return r?[e,...Au(r())]:e}).flat(10)}function Tu(t,e){const n=Fr.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function zy(t){return typeof t=="function"}function we(t,e=void 0,...n){return zy(t)?e?t.bind(e)(...n):t(...n):t}function cC(t={}){return Object.keys(t).length===0&&t.constructor===Object}function pi(t){const e=t.filter(s=>s.type==="extension"),n=t.filter(s=>s.type==="node"),r=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Fy(t){const e=[],{nodeExtensions:n,markExtensions:r}=pi(t),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:s},a=G(o,"addGlobalAttributes",l);if(!a)return;a().forEach(d=>{d.types.forEach(u=>{Object.entries(d.attributes).forEach(([h,f])=>{e.push({type:u,name:h,attribute:{...i,...f}})})})})}),s.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=G(o,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([d,u])=>{const h={...i,...u};typeof h?.default=="function"&&(h.default=h.default()),h?.isRequired&&h?.default===void 0&&delete h.default,e.push({type:o.name,name:d,attribute:h})})}),e}function be(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const l=i?String(i).split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(d=>!a.includes(d));r[s]=[...a,...c].join(" ")}else if(s==="style"){const l=i?i.split(";").map(d=>d.trim()).filter(Boolean):[],a=r[s]?r[s].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;a.forEach(d=>{const[u,h]=d.split(":").map(f=>f.trim());c.set(u,h)}),l.forEach(d=>{const[u,h]=d.split(":").map(f=>f.trim());c.set(u,h)}),r[s]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else r[s]=i}),r},{})}function mi(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>be(n,r),{})}function dC(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function sp(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):dC(n.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function ip(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&cC(n)?!1:n!=null))}function uC(t,e){var n;const r=Fy(t),{nodeExtensions:s,markExtensions:i}=pi(t),o=(n=s.find(c=>G(c,"topNode")))==null?void 0:n.name,l=Object.fromEntries(s.map(c=>{const d=r.filter(b=>b.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((b,w)=>{const M=G(w,"extendNodeSchema",u);return{...b,...M?M(c):{}}},{}),f=ip({...h,content:we(G(c,"content",u)),marks:we(G(c,"marks",u)),group:we(G(c,"group",u)),inline:we(G(c,"inline",u)),atom:we(G(c,"atom",u)),selectable:we(G(c,"selectable",u)),draggable:we(G(c,"draggable",u)),code:we(G(c,"code",u)),whitespace:we(G(c,"whitespace",u)),linebreakReplacement:we(G(c,"linebreakReplacement",u)),defining:we(G(c,"defining",u)),isolating:we(G(c,"isolating",u)),attrs:Object.fromEntries(d.map(b=>{var w,M;return[b.name,{default:(w=b?.attribute)==null?void 0:w.default,validate:(M=b?.attribute)==null?void 0:M.validate}]}))}),p=we(G(c,"parseHTML",u));p&&(f.parseDOM=p.map(b=>sp(b,d)));const g=G(c,"renderHTML",u);g&&(f.toDOM=b=>g({node:b,HTMLAttributes:mi(b,d)}));const y=G(c,"renderText",u);return y&&(f.toText=y),[c.name,f]})),a=Object.fromEntries(i.map(c=>{const d=r.filter(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((y,b)=>{const w=G(b,"extendMarkSchema",u);return{...y,...w?w(c):{}}},{}),f=ip({...h,inclusive:we(G(c,"inclusive",u)),excludes:we(G(c,"excludes",u)),group:we(G(c,"group",u)),spanning:we(G(c,"spanning",u)),code:we(G(c,"code",u)),attrs:Object.fromEntries(d.map(y=>{var b,w;return[y.name,{default:(b=y?.attribute)==null?void 0:b.default,validate:(w=y?.attribute)==null?void 0:w.validate}]}))}),p=we(G(c,"parseHTML",u));p&&(f.parseDOM=p.map(y=>sp(y,d)));const g=G(c,"renderHTML",u);return g&&(f.toDOM=y=>g({mark:y,HTMLAttributes:mi(y,d)})),[c.name,f]}));return new kg({topNode:o,nodes:l,marks:a})}function hC(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Nu(t){return t.sort((n,r)=>{const s=G(n,"priority")||100,i=G(r,"priority")||100;return s>i?-1:s<i?1:0})}function Uy(t){const e=Nu(Au(t)),n=hC(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Vy(t,e,n){const{from:r,to:s}=e,{blockSeparator:i=`
|
|
15
|
+
`))),0,0),t.someProp("transformPasted",h=>{l=h(l,t,!0)}),l;let u=t.someProp("clipboardTextParser",h=>h(e,s,r,t));if(u)l=u;else{let h=s.marks(),{schema:f}=t.state,p=Fr.fromSchema(f);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=o.appendChild(document.createElement("p"));g&&y.appendChild(p.serializeNode(f.text(g,h)))})}}else t.someProp("transformPastedHTML",u=>{n=u(n,t)}),o=kv(n),Oi&&vv(o);let c=o&&o.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let h=o.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;o=h}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Ws.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!bv.test(h.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Sv(Uf(l,+d[1],+d[2]),d[4]);else if(l=P.maxOpen(xv(l.content,s),!0),l.openStart||l.openEnd){let u=0,h=0;for(let f=l.content.firstChild;u<l.openStart&&!f.type.spec.isolating;u++,f=f.firstChild);for(let f=l.content.lastChild;h<l.openEnd&&!f.type.spec.isolating;h++,f=f.lastChild);l=Uf(l,u,h)}return t.someProp("transformPasted",u=>{l=u(l,t,a)}),l}const bv=/^(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 xv(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&i.length&&gy(a,i,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=yy(o[o.length-1],i.length));let d=my(l,a);o.push(d),s=s.matchType(d.type),i=a}}),o)return O.from(o)}return t}function my(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,O.from(t));return t}function gy(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=gy(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(O.from(my(n,t,s+1))))}}function yy(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,yy(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(O.empty,!0);return t.copy(n.append(r))}function td(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(i=0),s<r-1&&(l=td(l,e,n,r,s+1,i)),s>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(O.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function Uf(t,e,n){return e<t.openStart&&(t=new P(td(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new P(td(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const by={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Vf=null;function xy(){return Vf||(Vf=document.implementation.createHTMLDocument("title"))}let rc=null;function wv(t){let e=window.trustedTypes;return e?(rc||(rc=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),rc.createHTML(t)):t}function kv(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=xy().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&by[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=wv(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function vv(t){let e=t.querySelectorAll(dt?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function Sv(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=O.from(a.create(r[l+1],s)),i++,o++}return new P(s,i,o)}const xt={},wt={},Cv={touchstart:!0,touchmove:!0};class Ev{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Mv(t){for(let e in xt){let n=xt[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Tv(t,r)&&!bu(t,r)&&(t.editable||!(r.type in wt))&&n(t,r)},Cv[e]?{passive:!0}:void 0)}bt&&t.dom.addEventListener("input",()=>null),nd(t)}function Jn(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Av(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 nd(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>bu(t,r))})}function bu(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Tv(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 Nv(t,e){!bu(t,e)&&xt[e.type]&&(t.editable||!(e.type in wt))&&xt[e.type](t,e)}wt.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!ky(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Cn&&dt&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),ps&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,yr(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||yv(t,n)?n.preventDefault():Jn(t,"key")};wt.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};wt.keypress=(t,e)=>{let n=e;if(ky(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||jt&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof J)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function sa(t){return{left:t.clientX,top:t.clientY}}function _v(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function xu(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,l=>o>i.depth?l(t,n,i.nodeAfter,i.before(o),s,!0):l(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function ss(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function Rv(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&q.isSelectable(r)?(ss(t,new q(n)),!0):!1}function Ov(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof q&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(q.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(ss(t,q.create(t.state.doc,s)),!0):!1}function Dv(t,e,n,r,s){return xu(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?Ov(t,n):Rv(t,n))}function Lv(t,e,n,r){return xu(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function Iv(t,e,n,r){return xu(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||jv(t,n,r)}function jv(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(ss(t,J.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)ss(t,J.create(r,l+1,l+1+o.content.size));else if(q.isSelectable(o))ss(t,q.create(r,l));else continue;return!0}}function wu(t){return Qo(t)}const wy=jt?"metaKey":"ctrlKey";xt.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=wu(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&_v(n,t.input.lastClick)&&!n[wy]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=t.posAtCoords(sa(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Pv(t,o,n,!!r)):(i=="doubleClick"?Lv:Iv)(t,o.pos,o.inside,n)?n.preventDefault():Jn(t,"pointer"))};class Pv{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[wy],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);i=d.parent,o=d.depth?d.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof q&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&$t&&!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)),Jn(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(()=>An(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(sa(e))),this.updateAllowDefault(e),this.allowDefault||!n?Jn(this.view,"pointer"):Dv(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||bt&&this.mightDrag&&!this.mightDrag.node.isAtom||dt&&!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)?(ss(this.view,ee.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Jn(this.view,"pointer")}move(e){this.updateAllowDefault(e),Jn(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)}}xt.touchstart=t=>{t.input.lastTouch=Date.now(),wu(t),Jn(t,"pointer")};xt.touchmove=t=>{t.input.lastTouch=Date.now(),Jn(t,"pointer")};xt.contextmenu=t=>wu(t);function ky(t,e){return t.composing?!0:bt&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Bv=Cn?5e3:-1;wt.compositionstart=wt.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof J&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),Qo(t,!0),t.markCursor=null;else if(Qo(t,!e.selection.empty),$t&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}vy(t,Bv)};wt.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++,vy(t,20))};function vy(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Qo(t),e))}function Sy(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Hv());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function $v(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Rk(e.focusNode,e.focusOffset),r=Ok(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function Hv(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Qo(t,e=!1){if(!(Cn&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Sy(t),e||t.docView&&t.docView.dirty){let n=mu(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function zv(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const di=Ct&&Qn<15||ps&&Pk<604;xt.copy=wt.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=di?null:n.clipboardData,o=r.content(),{dom:l,text:a}=yu(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):zv(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Fv(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Uv(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ui(t,r.value,null,s,e):ui(t,r.textContent,r.innerHTML,s,e)},50)}function ui(t,e,n,r,s){let i=py(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,s,i||P.empty)))return!0;if(!i)return!1;let o=Fv(i),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Cy(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," "):""}wt.paste=(t,e)=>{let n=e;if(t.composing&&!Cn)return;let r=di?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&ui(t,Cy(r),r.getData("text/html"),s,n)?n.preventDefault():Uv(t,n)};class Ey{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const Vv=jt?"altKey":"ctrlKey";function My(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[Vv]}xt.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(sa(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof q?s.to-1:s.to))){if(r&&r.mightDrag)o=q.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let u=t.docView.nearestDesc(n.target,!0);u&&u.node.type.spec.draggable&&u!=t.docView&&(o=q.create(t.state.doc,u.posBefore))}}let l=(o||t.state.selection).content(),{dom:a,text:c,slice:d}=yu(t,l);(!n.dataTransfer.files.length||!dt||Zg>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(di?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",di||n.dataTransfer.setData("text/plain",c),t.dragging=new Ey(d,My(t,n),o)};xt.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};wt.dragover=wt.dragenter=(t,e)=>e.preventDefault();wt.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let s=t.posAtCoords(sa(n));if(!s)return;let i=t.state.doc.resolve(s.pos),o=r&&r.slice;o?t.someProp("transformPasted",p=>{o=p(o,t,!1)}):o=py(t,Cy(n.dataTransfer),di?null:n.dataTransfer.getData("text/html"),!1,i);let l=!!(r&&My(t,n));if(t.someProp("handleDrop",p=>p(t,n,o||P.empty,l))){n.preventDefault();return}if(!o)return;n.preventDefault();let a=o?Og(t.state.doc,i.pos,o):i.pos;a==null&&(a=i.pos);let c=t.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,h=c.doc;if(u?c.replaceRangeWith(d,d,o.content.firstChild):c.replaceRange(d,d,o),c.doc.eq(h))return;let f=c.doc.resolve(d);if(u&&q.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new q(f));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((g,y,b,w)=>p=w),c.setSelection(gu(t,f,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))};xt.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())&&An(t)},20))};xt.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)};xt.beforeinput=(t,e)=>{if(dt&&Cn&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,yr(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in wt)xt[t]=wt[t];function hi(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 el{constructor(e,n){this.toDOM=e,this.spec=n||Er,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new _e(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof el&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&hi(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class tr{constructor(e,n){this.attrs=e,this.spec=n||Er}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new _e(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof tr&&hi(this.attrs,e.attrs)&&hi(this.spec,e.spec)}static is(e){return e.type instanceof tr}destroy(){}}class ku{constructor(e,n){this.attrs=e,this.spec=n||Er}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new _e(i.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof ku&&hi(this.attrs,e.attrs)&&hi(this.spec,e.spec)}destroy(){}}class _e{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new _e(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new _e(e,e,new el(n,r))}static inline(e,n,r,s){return new _e(e,n,new tr(r,s))}static node(e,n,r,s){return new _e(e,n,new ku(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof tr}get widget(){return this.type instanceof el}}const Zr=[],Er={};class be{constructor(e,n){this.local=e.length?e:Zr,this.children=n.length?n:Zr}static create(e,n){return n.length?tl(n,e,0,Er):ct}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,s+l,i)}}map(e,n,r){return this==ct||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Er)}mapInner(e,n,r,s,i){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(n,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?Wv(this.children,o||[],e,n,r,s,i):o?new be(o.sort(Mr),Zr):ct}add(e,n){return n.length?this==ct?be.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((l,a)=>{let c=a+r,d;if(d=Ty(n,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,d,c+1):s.splice(i,0,a,a+l.nodeSize,tl(d,l,c+1,Er)),i+=3}});let o=Ay(i?Ny(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new be(o.length?this.local.concat(o).sort(Mr):this.local,s||this.children)}remove(e){return e.length==0||this==ct?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+n,a=r[i+1]+n;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(o||(o=[])).push(u));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(o,l+1);c!=ct?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new be(s,r):ct}forChild(e,n){if(this==ct)return this;if(n.isLeaf)return be.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>i&&a.type instanceof tr){let c=Math.max(i,a.from)-i,d=Math.min(o,a.to)-i;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new be(s.sort(Mr),Zr);return r?new Vn([l,r]):l}return r||ct}eq(e){if(this==e)return!0;if(!(e instanceof be)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return vu(this.localsInner(e))}localsInner(e){if(this==ct)return Zr;if(e.inlineContent||!this.local.some(tr.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof tr||n.push(this.local[r]);return n}forEachSet(e){e(this)}}be.empty=new be([],[]);be.removeOverlap=vu;const ct=be.empty;class Vn{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,Er));return Vn.from(r)}forChild(e,n){if(n.isLeaf)return be.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=ct&&(i instanceof Vn?r=r.concat(i.members):r.push(i))}return Vn.from(r)}eq(e){if(!(e instanceof Vn)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?vu(r?n:n.sort(Mr)):Zr}static from(e){switch(e.length){case 0:return ct;case 1:return e[0];default:return new Vn(e.every(n=>n instanceof be)?e:e.reduce((n,r)=>n.concat(r instanceof be?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function Wv(t,e,n,r,s,i,o){let l=t.slice();for(let c=0,d=i;c<n.maps.length;c++){let u=0;n.maps[c].forEach((h,f,p,g)=>{let y=g-p-(f-h);for(let b=0;b<l.length;b+=3){let w=l[b+1];if(w<0||h>w+d-u)continue;let M=l[b]+d-u;f>=M?l[b+1]=h<=M?-2:-1:h>=d&&y&&(l[b]+=y,l[b+1]+=y)}u+=y}),d=n.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=n.map(t[c]+i),u=d-s;if(u<0||u>=r.content.size){a=!0;continue}let h=n.map(t[c+1]+i,-1),f=h-s,{index:p,offset:g}=r.content.findIndex(u),y=r.maybeChild(p);if(y&&g==u&&g+y.nodeSize==f){let b=l[c+2].mapInner(n,y,d+1,t[c]+i+1,o);b!=ct?(l[c]=u,l[c+1]=f,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=qv(l,t,e,n,s,i,o),d=tl(c,r,0,o);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,h=0;u<d.children.length;u+=3){let f=d.children[u];for(;h<l.length&&l[h]<f;)h+=3;l.splice(h,0,d.children[u],d.children[u+1],d.children[u+2])}}return new be(e.sort(Mr),l)}function Ay(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new _e(s.from+e,s.to+e,s.type))}return n}function qv(t,e,n,r,s,i,o){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(r,s,c);u?n.push(u):o.onRemove&&o.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function Ty(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function Ny(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function tl(t,e,n,r){let s=[],i=!1;e.forEach((l,a)=>{let c=Ty(t,l,a+n);if(c){i=!0;let d=tl(c,l,n+a+1,r);d!=ct&&s.push(a,a+l.nodeSize,d)}});let o=Ay(i?Ny(t):t,-n).sort(Mr);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new be(o,s):ct}function Mr(t,e){return t.from-e.from||t.to-e.to}function vu(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),Wf(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),Wf(e,s,r.copy(i.from,r.to)));break}}}return e}function Wf(t,e,n){for(;e<t.length&&Mr(n,t[e])>0;)e++;t.splice(e,0,n)}function sc(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ct&&e.push(r)}),t.cursorWrapper&&e.push(be.create(t.state.doc,[t.cursorWrapper.deco])),Vn.from(e)}const Kv={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Gv=Ct&&Qn<=11;class Jv{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 Yv{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Jv,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);Ct&&Qn<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),Gv&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Kv)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Pf(this.view)){if(this.suppressingSelectionUpdates)return An(this.view);if(Ct&&Qn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Or(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=fs(i))n.add(i);for(let i=e.anchorNode;i;i=fs(i))if(n.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Pf(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,l=!1,a=[];if(e.editable)for(let d=0;d<n.length;d++){let u=this.registerMutation(n[d],a);u&&(i=i<0?u.from:Math.min(u.from,i),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(l=!0))}if($t&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,h]=d;u.parentNode&&u.parentNode.parentNode==h.parentNode?h.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let h of d){let f=h.parentNode;f&&f.nodeName=="LI"&&(!u||Qv(e,u)!=f)&&h.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&na(r)&&(c=mu(e))&&c.eq(ee.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,An(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),Xv(e)),this.handleDOMChange(i,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||An(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 d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];n.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(Ct&&Qn<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:h}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h)}let o=s&&s.parentNode==e.target?st(s)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=i&&i.parentNode==e.target?st(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let qf=new WeakMap,Kf=!1;function Xv(t){if(!qf.has(t)&&(qf.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=$t,Kf)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Kf=!0}}function Gf(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Or(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function Zv(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return Gf(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Gf(t,n):null}function Qv(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function eS(t,e,n){let{node:r,fromOffset:s,toOffset:i,from:o,to:l}=t.docView.parseRange(e,n),a=t.domSelectionRange(),c,d=a.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],na(a)||c.push({node:a.focusNode,offset:a.focusOffset})),dt&&t.input.lastKeyCode===8)for(let y=i;y>s;y--){let b=r.childNodes[y-1],w=b.pmViewDesc;if(b.nodeName=="BR"&&!w){i=y;break}if(!w||w.size)break}let u=t.state.doc,h=t.someProp("domParser")||Ws.fromSchema(t.state.schema),f=u.resolve(o),p=null,g=h.parse(r,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:s,to:i,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:tS,context:f});if(c&&c[0].pos!=null){let y=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=y),p={anchor:y+o,head:b+o}}return{doc:g,sel:p,from:o,to:l}}function tS(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(bt&&/^(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||bt&&/^(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 nS=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function rS(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let k=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,v=mu(t,k);if(v&&!t.state.selection.eq(v)){if(dt&&Cn&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",N=>N(t,yr(13,"Enter"))))return;let T=t.state.tr.setSelection(v);k=="pointer"?T.setMeta("pointer",!0):k=="key"&&T.scrollIntoView(),i&&T.setMeta("composition",i),t.dispatch(T)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=eS(t,e,n),d=t.state.doc,u=d.slice(c.from,c.to),h,f;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(h=t.state.selection.to,f="end"):(h=t.state.selection.from,f="start"),t.input.lastKeyCode=null;let p=oS(u.content,c.doc.content,c.from,h,f);if(p&&t.input.domChangeCount++,(ps&&t.input.lastIOSEnter>Date.now()-225||Cn)&&s.some(k=>k.nodeType==1&&!nS.test(k.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",k=>k(t,yr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof J&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let k=Jf(t,t.state.doc,c.sel);if(k&&!k.eq(t.state.selection)){let v=t.state.tr.setSelection(k);i&&v.setMeta("composition",i),t.dispatch(v)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof J&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),Ct&&Qn<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let g=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),b=d.resolve(p.start),w=g.sameParent(y)&&g.parent.inlineContent&&b.end()>=p.endA;if((ps&&t.input.lastIOSEnter>Date.now()-225&&(!w||s.some(k=>k.nodeName=="DIV"||k.nodeName=="P"))||!w&&g.pos<c.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(c.doc.textBetween(g.pos,y.pos,"","")))&&t.someProp("handleKeyDown",k=>k(t,yr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&iS(d,p.start,p.endA,g,y)&&t.someProp("handleKeyDown",k=>k(t,yr(8,"Backspace")))){Cn&&dt&&t.domObserver.suppressSelectionUpdates();return}dt&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),Cn&&!w&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(k){return k(t,yr(13,"Enter"))})},20));let M=p.start,S=p.endA,A=k=>{let v=k||t.state.tr.replace(M,S,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let T=Jf(t,v.doc,c.sel);T&&!(dt&&t.composing&&T.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(T.head==M||T.head==v.mapping.map(S)-1)||Ct&&T.empty&&T.head==M)&&v.setSelection(T)}return i&&v.setMeta("composition",i),v.scrollIntoView()},x;if(w)if(g.pos==y.pos){Ct&&Qn<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>An(t),20));let k=A(t.state.tr.delete(M,S)),v=d.resolve(p.start).marksAcross(d.resolve(p.endA));v&&k.ensureMarks(v),t.dispatch(k)}else if(p.endA==p.endB&&(x=sS(g.parent.content.cut(g.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start())))){let k=A(t.state.tr);x.type=="add"?k.addMark(M,S,x.mark):k.removeMark(M,S,x.mark),t.dispatch(k)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let k=g.parent.textBetween(g.parentOffset,y.parentOffset),v=()=>A(t.state.tr.insertText(k,M,S));t.someProp("handleTextInput",T=>T(t,M,S,k,v))||t.dispatch(v())}else t.dispatch(A());else t.dispatch(A())}function Jf(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:gu(t,e.resolve(n.anchor),e.resolve(n.head))}function sS(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,o,l,a;for(let d=0;d<r.length;d++)s=r[d].removeFromSet(s);for(let d=0;d<n.length;d++)i=n[d].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],o="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&i.length==1)l=i[0],o="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(O.from(c).eq(t))return{mark:l,type:o}}function iS(t,e,n,r,s){if(n-e<=s.pos-r.pos||ic(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=t.resolve(ic(i,!0,!0));return!o.parent.isTextblock||o.pos>n||ic(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function ic(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function oS(t,e,n,r,s){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(s=="end"){let a=Math.max(0,i-Math.min(o,l));r-=o+a-i}if(o<i&&t.size<e.size){let a=r<=i&&r>=o?i-r:0;i-=a,i&&i<e.size&&Yf(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-o),o=i}else if(l<i){let a=r<=i&&r>=l?i-r:0;i-=a,i&&i<t.size&&Yf(t.textBetween(i-1,i+1))&&(i+=a?1:-1),o=i+(o-l),l=i}return{start:i,endA:o,endB:l}}function Yf(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class _y{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 Ev,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(tp),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=Qf(this),Zf(this),this.nodeViews=ep(this),this.docView=Rf(this.state.doc,Xf(this),sc(this),this.dom,this),this.domObserver=new Yv(this,(r,s,i,o)=>rS(this,r,s,i,o)),this.domObserver.start(),Mv(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&&nd(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(tp),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(Sy(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let f=ep(this);aS(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&nd(this),this.editable=Qf(this),Zf(this);let a=sc(this),c=Xf(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(s.selection))&&(o=!0);let h=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Hk(this);if(o){this.domObserver.stop();let f=u&&(Ct||dt)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&lS(s.selection,e.selection);if(u){let p=dt?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=$v(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Rf(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&dv(this))?An(this,f):(uy(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():h&&zk(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof q){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Ef(this,n.getBoundingClientRect(),e)}else Ef(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new Ey(e.slice,e.move,s<0?void 0:q.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(s=n?n(l):l))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let l=i[o].props[e];if(l!=null&&(s=n?n(l):l))return s}}hasFocus(){if(Ct){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Fk(this.dom),An(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Kk(this,e)}coordsAtPos(e,n=1){return ry(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return Zk(this,n||this.state,e)}pasteHTML(e,n){return ui(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return ui(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return yu(this,e)}destroy(){this.docView&&(Av(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],sc(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Nk())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Nv(this,e)}domSelectionRange(){let e=this.domSelection();return e?bt&&this.root.nodeType===11&&Lk(this.dom.ownerDocument)==this.dom&&Zv(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}_y.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Xf(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"),[_e.node(0,t.state.doc.content.size,e)]}function Zf(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:_e.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Qf(t){return!t.someProp("editable",e=>e(t.state)===!1)}function lS(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 ep(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function aS(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function tp(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 nr={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:"'"},nl={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},cS=typeof navigator<"u"&&/Mac/.test(navigator.platform),dS=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var it=0;it<10;it++)nr[48+it]=nr[96+it]=String(it);for(var it=1;it<=24;it++)nr[it+111]="F"+it;for(var it=65;it<=90;it++)nr[it]=String.fromCharCode(it+32),nl[it]=String.fromCharCode(it);for(var oc in nr)nl.hasOwnProperty(oc)||(nl[oc]=nr[oc]);function uS(t){var e=cS&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||dS&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?nl:nr)[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 hS=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),fS=typeof navigator<"u"&&/Win/.test(navigator.platform);function pS(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))hS?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function mS(t){let e=Object.create(null);for(let n in t)e[pS(n)]=t[n];return e}function lc(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function gS(t){return new me({props:{handleKeyDown:Su(t)}})}function Su(t){let e=mS(t);return function(n,r){let s=uS(r),i,o=e[lc(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[lc(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(fS&&r.ctrlKey&&r.altKey)&&(i=nr[r.keyCode])&&i!=s){let l=e[lc(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var yS=Object.defineProperty,Cu=(t,e)=>{for(var n in e)yS(t,n,{get:e[n],enumerable:!0})};function ia(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}var oa=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:s}=n,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...c)=>{const d=l(...c)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o=[],l=!!t,a=t||s.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(a),o.every(u=>u===!0)),d={...Object.fromEntries(Object.entries(n).map(([u,h])=>[u,(...p)=>{const g=this.buildProps(a,e),y=h(...p)(g);return o.push(y),d}])),run:c};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.tr,i=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o={tr:t,editor:r,view:i,state:ia({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)(o)]))}};return o}},Ry={};Cu(Ry,{blur:()=>bS,clearContent:()=>xS,clearNodes:()=>wS,command:()=>kS,createParagraphNear:()=>vS,cut:()=>SS,deleteCurrentNode:()=>CS,deleteNode:()=>ES,deleteRange:()=>MS,deleteSelection:()=>AS,enter:()=>TS,exitCode:()=>NS,extendMarkRange:()=>_S,first:()=>RS,focus:()=>OS,forEach:()=>DS,insertContent:()=>LS,insertContentAt:()=>PS,joinBackward:()=>HS,joinDown:()=>$S,joinForward:()=>zS,joinItemBackward:()=>FS,joinItemForward:()=>US,joinTextblockBackward:()=>VS,joinTextblockForward:()=>WS,joinUp:()=>BS,keyboardShortcut:()=>KS,lift:()=>GS,liftEmptyBlock:()=>JS,liftListItem:()=>YS,newlineInCode:()=>XS,resetAttributes:()=>ZS,scrollIntoView:()=>QS,selectAll:()=>eC,selectNodeBackward:()=>tC,selectNodeForward:()=>nC,selectParentNode:()=>rC,selectTextblockEnd:()=>sC,selectTextblockStart:()=>iC,setContent:()=>oC,setMark:()=>SC,setMeta:()=>CC,setNode:()=>EC,setNodeSelection:()=>MC,setTextSelection:()=>AC,sinkListItem:()=>TC,splitBlock:()=>NC,splitListItem:()=>_C,toggleList:()=>RC,toggleMark:()=>OC,toggleNode:()=>DC,toggleWrap:()=>LC,undoInputRule:()=>IC,unsetAllMarks:()=>jC,unsetMark:()=>PC,updateAttributes:()=>BC,wrapIn:()=>$C,wrapInList:()=>HC});var bS=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),xS=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),wS=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:i,$to:o})=>{t.doc.nodesBetween(i.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(a)),h=c.resolve(d.map(a+l.nodeSize)),f=u.blockRange(h);if(!f)return;const p=Cs(f);if(l.type.isTextblock){const{defaultType:g}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(f.start,g)}(p||p===0)&&e.lift(f,p)})}),!0},kS=t=>e=>t(e),vS=()=>({state:t,dispatch:e})=>Kg(t,e),SS=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,i=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new J(r.doc.resolve(Math.max(o-1,0)))),!0},CS=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const l=s.before(i),a=s.after(i);t.delete(l,a).scrollIntoView()}return!0}return!1};function Ke(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var ES=t=>({tr:e,state:n,dispatch:r})=>{const s=Ke(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const a=i.before(o),c=i.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},MS=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},AS=()=>({state:t,dispatch:e})=>cu(t,e),TS=()=>({commands:t})=>t.keyboardShortcut("Enter"),NS=()=>({state:t,dispatch:e})=>pk(t,e);function Eu(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function rl(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:Eu(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function Oy(t,e,n={}){return t.find(r=>r.type===e&&rl(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function np(t,e,n={}){return!!Oy(t,e,n)}function Mu(t,e,n){var r;if(!t||!e)return;let s=t.parent.childAfter(t.parentOffset);if((!s.node||!s.node.marks.some(d=>d.type===e))&&(s=t.parent.childBefore(t.parentOffset)),!s.node||!s.node.marks.some(d=>d.type===e)||(n=n||((r=s.node.marks[0])==null?void 0:r.attrs),!Oy([...s.node.marks],e,n)))return;let o=s.index,l=t.start()+s.offset,a=o+1,c=l+s.node.nodeSize;for(;o>0&&np([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;a<t.parent.childCount&&np([...t.parent.child(a).marks],e,n);)c+=t.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function Rn(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var _S=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const i=Rn(t,r.schema),{doc:o,selection:l}=n,{$from:a,from:c,to:d}=l;if(s){const u=Mu(a,i,e);if(u&&u.from<=c&&u.to>=d){const h=J.create(o,u.from,u.to);n.setSelection(h)}}return!0},RS=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function Dy(t){return t instanceof J}function kr(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Ly(t,e=null){if(!e)return null;const n=ee.atStart(t),r=ee.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,i=r.to;return e==="all"?J.create(t,kr(0,s,i),kr(t.content.size,s,i)):J.create(t,kr(e,s,i),kr(e,s,i))}function Iy(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function la(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var OS=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(la()||Iy())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(i&&t===null&&!Dy(n.state.selection))return o(),!0;const l=Ly(s.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},DS=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),LS=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),jy=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&&jy(r)}return t};function uo(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return jy(n)}function fi(t,e,n){if(t instanceof Zn||t instanceof O)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return O.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),fi("",e,n)}if(s){if(n.errorOnInvalidContent){let o=!1,l="";const a=new kg({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?Ws.fromSchema(a).parseSlice(uo(t),n.parseOptions):Ws.fromSchema(a).parse(uo(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=Ws.fromSchema(e);return n.slice?i.parseSlice(uo(t),n.parseOptions).content:i.parse(uo(t),n.parseOptions)}return fi("",e,n)}function IS(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof Ze||s instanceof Qe))return;const i=t.mapping.maps[r];let o=0;i.forEach((l,a,c,d)=>{o===0&&(o=d)}),t.setSelection(ee.near(t.doc.resolve(o),n))}var jS=t=>!("type"in t),PS=(t,e,n)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const a=y=>{i.emit("contentError",{editor:i,error:y,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{fi(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(y){a(y)}try{l=fi(e,i.schema,{parseOptions:c,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(y){return a(y),!1}let{from:d,to:u}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},h=!0,f=!0;if((jS(l)?l:[l]).forEach(y=>{y.check(),h=h?y.isText&&y.marks.length===0:!1,f=f?y.isBlock:!1}),d===u&&f){const{parent:y}=r.doc.resolve(d);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(d-=1,u+=1)}let g;if(h){if(Array.isArray(e))g=e.map(y=>y.text||"").join("");else if(e instanceof O){let y="";e.forEach(b=>{b.text&&(y+=b.text)}),g=y}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,d,u)}else{g=l;const y=r.doc.resolve(d),b=y.node(),w=y.parentOffset===0,M=b.isText||b.isTextblock,S=b.content.size>0;w&&M&&S&&(d=Math.max(0,d-1)),r.replaceWith(d,u,g)}n.updateSelection&&IS(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:g}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:g})}return!0},BS=()=>({state:t,dispatch:e})=>uk(t,e),$S=()=>({state:t,dispatch:e})=>hk(t,e),HS=()=>({state:t,dispatch:e})=>Hg(t,e),zS=()=>({state:t,dispatch:e})=>Vg(t,e),FS=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Ql(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},US=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Ql(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},VS=()=>({state:t,dispatch:e})=>ck(t,e),WS=()=>({state:t,dispatch:e})=>dk(t,e);function Py(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function qS(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))la()||Py()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var KS=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const i=qS(t).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a?.steps.forEach(c=>{const d=c.map(r.mapping);d&&s&&r.maybeStep(d)}),!0};function rr(t,e,n={}){const{from:r,to:s,empty:i}=t.selection,o=e?Ke(e,t.schema):null,l=[];t.doc.nodesBetween(r,s,(u,h)=>{if(u.isText)return;const f=Math.max(r,h),p=Math.min(s,h+u.nodeSize);l.push({node:u,from:f,to:p})});const a=s-r,c=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>rl(u.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((u,h)=>u+h.to-h.from,0)>=a}var GS=(t,e={})=>({state:n,dispatch:r})=>{const s=Ke(t,n.schema);return rr(n,s,e)?fk(n,r):!1},JS=()=>({state:t,dispatch:e})=>Gg(t,e),YS=t=>({state:e,dispatch:n})=>{const r=Ke(t,e.schema);return Ek(r)(e,n)},XS=()=>({state:t,dispatch:e})=>qg(t,e);function aa(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function rp(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var ZS=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=aa(typeof t=="string"?t:t.name,r.schema);return l?(l==="node"&&(i=Ke(t,r.schema)),l==="mark"&&(o=Rn(t,r.schema)),s&&n.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,d)=>{i&&i===c.type&&n.setNodeMarkup(d,void 0,rp(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(u=>{o===u.type&&n.addMark(d,d+c.nodeSize,o.create(rp(u.attrs,e)))})})}),!0):!1},QS=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),eC=()=>({tr:t,dispatch:e})=>{if(e){const n=new St(t.doc);t.setSelection(n)}return!0},tC=()=>({state:t,dispatch:e})=>Fg(t,e),nC=()=>({state:t,dispatch:e})=>Wg(t,e),rC=()=>({state:t,dispatch:e})=>yk(t,e),sC=()=>({state:t,dispatch:e})=>wk(t,e),iC=()=>({state:t,dispatch:e})=>xk(t,e);function rd(t,e,n={},r={}){return fi(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var oC=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:l})=>{const{doc:a}=i;if(r.preserveWhitespace!=="full"){const c=rd(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return o&&i.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function By(t,e){const n=Rn(e,t.schema),{from:r,to:s,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function $y(t,e){const n=new ou(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function lC(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function sd(t,e){const n=[];return t.descendants((r,s)=>{e(r)&&n.push({node:r,pos:s})}),n}function aC(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function Hy(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 ca(t){return e=>Hy(e.$from,t)}function G(t,e,n){return t.config[e]===void 0&&t.parent?G(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?G(t.parent,e,n):null}):t.config[e]}function Au(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=G(e,"addExtensions",n);return r?[e,...Au(r())]:e}).flat(10)}function Tu(t,e){const n=Fr.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function zy(t){return typeof t=="function"}function we(t,e=void 0,...n){return zy(t)?e?t.bind(e)(...n):t(...n):t}function cC(t={}){return Object.keys(t).length===0&&t.constructor===Object}function pi(t){const e=t.filter(s=>s.type==="extension"),n=t.filter(s=>s.type==="node"),r=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Fy(t){const e=[],{nodeExtensions:n,markExtensions:r}=pi(t),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:s},a=G(o,"addGlobalAttributes",l);if(!a)return;a().forEach(d=>{d.types.forEach(u=>{Object.entries(d.attributes).forEach(([h,f])=>{e.push({type:u,name:h,attribute:{...i,...f}})})})})}),s.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=G(o,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([d,u])=>{const h={...i,...u};typeof h?.default=="function"&&(h.default=h.default()),h?.isRequired&&h?.default===void 0&&delete h.default,e.push({type:o.name,name:d,attribute:h})})}),e}function pe(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const l=i?String(i).split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(d=>!a.includes(d));r[s]=[...a,...c].join(" ")}else if(s==="style"){const l=i?i.split(";").map(d=>d.trim()).filter(Boolean):[],a=r[s]?r[s].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;a.forEach(d=>{const[u,h]=d.split(":").map(f=>f.trim());c.set(u,h)}),l.forEach(d=>{const[u,h]=d.split(":").map(f=>f.trim());c.set(u,h)}),r[s]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else r[s]=i}),r},{})}function mi(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>pe(n,r),{})}function dC(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function sp(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):dC(n.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function ip(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&cC(n)?!1:n!=null))}function uC(t,e){var n;const r=Fy(t),{nodeExtensions:s,markExtensions:i}=pi(t),o=(n=s.find(c=>G(c,"topNode")))==null?void 0:n.name,l=Object.fromEntries(s.map(c=>{const d=r.filter(b=>b.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((b,w)=>{const M=G(w,"extendNodeSchema",u);return{...b,...M?M(c):{}}},{}),f=ip({...h,content:we(G(c,"content",u)),marks:we(G(c,"marks",u)),group:we(G(c,"group",u)),inline:we(G(c,"inline",u)),atom:we(G(c,"atom",u)),selectable:we(G(c,"selectable",u)),draggable:we(G(c,"draggable",u)),code:we(G(c,"code",u)),whitespace:we(G(c,"whitespace",u)),linebreakReplacement:we(G(c,"linebreakReplacement",u)),defining:we(G(c,"defining",u)),isolating:we(G(c,"isolating",u)),attrs:Object.fromEntries(d.map(b=>{var w,M;return[b.name,{default:(w=b?.attribute)==null?void 0:w.default,validate:(M=b?.attribute)==null?void 0:M.validate}]}))}),p=we(G(c,"parseHTML",u));p&&(f.parseDOM=p.map(b=>sp(b,d)));const g=G(c,"renderHTML",u);g&&(f.toDOM=b=>g({node:b,HTMLAttributes:mi(b,d)}));const y=G(c,"renderText",u);return y&&(f.toText=y),[c.name,f]})),a=Object.fromEntries(i.map(c=>{const d=r.filter(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((y,b)=>{const w=G(b,"extendMarkSchema",u);return{...y,...w?w(c):{}}},{}),f=ip({...h,inclusive:we(G(c,"inclusive",u)),excludes:we(G(c,"excludes",u)),group:we(G(c,"group",u)),spanning:we(G(c,"spanning",u)),code:we(G(c,"code",u)),attrs:Object.fromEntries(d.map(y=>{var b,w;return[y.name,{default:(b=y?.attribute)==null?void 0:b.default,validate:(w=y?.attribute)==null?void 0:w.validate}]}))}),p=we(G(c,"parseHTML",u));p&&(f.parseDOM=p.map(y=>sp(y,d)));const g=G(c,"renderHTML",u);return g&&(f.toDOM=y=>g({mark:y,HTMLAttributes:mi(y,d)})),[c.name,f]}));return new kg({topNode:o,nodes:l,marks:a})}function hC(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Nu(t){return t.sort((n,r)=>{const s=G(n,"priority")||100,i=G(r,"priority")||100;return s>i?-1:s<i?1:0})}function Uy(t){const e=Nu(Au(t)),n=hC(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Vy(t,e,n){const{from:r,to:s}=e,{blockSeparator:i=`
|
|
16
16
|
|
|
17
|
-
`,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,s,(a,c,d,u)=>{var h;a.isBlock&&c>r&&(l+=i);const f=o?.[a.type.name];if(f)return d&&(l+=f({node:a,pos:c,parent:d,index:u,range:e})),!1;a.isText&&(l+=(h=a?.text)==null?void 0:h.slice(Math.max(r,c)-c,s-c))}),l}function fC(t,e){const n={from:0,to:t.content.size};return Vy(t,n,e)}function Wy(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function pC(t,e){const n=Ke(e,t.schema),{from:r,to:s}=t.selection,i=[];t.doc.nodesBetween(r,s,l=>{i.push(l)});const o=i.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function qy(t,e){const n=aa(typeof e=="string"?e:e.name,t.schema);return n==="node"?pC(t,e):n==="mark"?By(t,e):{}}function mC(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function gC(t){const e=mC(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,o)=>o!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function Ky(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=n[i];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(i).map(l,-1),d=e.slice(i).map(a),u=e.invert().map(c,-1),h=e.invert().map(d);r.push({oldRange:{from:u,to:h},newRange:{from:c,to:d}})})}),gC(r)}function _u(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const i=n.resolve(t),o=Mu(i,s.type);o&&r.push({mark:s,...o})}):n.nodesBetween(t,e,(s,i)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}var yC=(t,e,n,r=20)=>{const s=t.doc.resolve(n);let i=r,o=null;for(;i>0&&o===null;){const l=s.node(i);l?.type.name===e?o=l:i-=1}return[o,i]};function ac(t,e){return e.nodes[t]||e.marks[t]||null}function Lo(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}var bC=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,l)=>{var a,c;const d=((c=(a=s.type.spec).toText)==null?void 0:c.call(a,{node:s,pos:i,parent:o,index:l}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?d:d.slice(0,Math.max(0,r-i))}),n};function id(t,e,n={}){const{empty:r,ranges:s}=t.selection,i=e?Rn(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>rl(u.attrs,n,{strict:!1}));let o=0;const l=[];if(s.forEach(({$from:u,$to:h})=>{const f=u.pos,p=h.pos;t.doc.nodesBetween(f,p,(g,y)=>{if(!g.isText&&!g.marks.length)return;const b=Math.max(f,y),w=Math.min(p,y+g.nodeSize),M=w-b;o+=M,l.push(...g.marks.map(S=>({mark:S,from:b,to:w})))})}),o===0)return!1;const a=l.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>rl(u.mark.attrs,n,{strict:!1})).reduce((u,h)=>u+h.to-h.from,0),c=l.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,h)=>u+h.to-h.from,0);return(a>0?a+c:a)>=o}function xC(t,e,n={}){if(!e)return rr(t,null,n)||id(t,null,n);const r=aa(e,t.schema);return r==="node"?rr(t,e,n):r==="mark"?id(t,e,n):!1}var wC=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const i=ca(l=>l.type.name===e)(t.selection);if(!i)return!1;const o=t.doc.resolve(i.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},kC=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function op(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function lp(t,e){const{nodeExtensions:n}=pi(e),r=n.find(o=>o.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=we(G(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function Li(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(i=>{s!==!1&&(Li(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function Gy(t){return t instanceof q}function vC(t,e,n){var r;const{selection:s}=e;let i=null;if(Dy(s)&&(i=s.$cursor),i){const l=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(c=>c.type.excludes(n)))}const{ranges:o}=s;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(d,u,h)=>{if(c)return!1;if(d.isInline){const f=!h||h.type.allowsMarkType(n),p=!!n.isInSet(d.marks)||!d.marks.some(g=>g.type.excludes(n));c=f&&p}return!c}),c})}var SC=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:o,ranges:l}=i,a=Rn(t,r.schema);if(s)if(o){const c=By(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(h,f)=>{const p=Math.max(f,d),g=Math.min(f+h.nodeSize,u);h.marks.find(b=>b.type===a)?h.marks.forEach(b=>{a===b.type&&n.addMark(p,g,a.create({...b.attrs,...e}))}):n.addMark(p,g,a.create(e))})});return vC(r,n,a)},CC=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),EC=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const i=Ke(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:l})=>vf(i,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>vf(i,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},MC=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=kr(t,0,r.content.size),i=q.create(r,s);e.setSelection(i)}return!0},AC=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,o=J.atStart(r).from,l=J.atEnd(r).to,a=kr(s,o,l),c=kr(i,o,l),d=J.create(r,a,c);e.setSelection(d)}return!0},TC=t=>({state:e,dispatch:n})=>{const r=Ke(t,e.schema);return Tk(r)(e,n)};function ap(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e?.includes(s.type.name));t.tr.ensureMarks(r)}}var NC=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:l,$to:a}=i,c=s.extensionManager.attributes,d=Lo(c,l.node().type.name,l.node().attrs);if(i instanceof q&&i.node.isBlock)return!l.parentOffset||!Mn(o,l.pos)?!1:(r&&(t&&ap(n,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const u=a.parentOffset===a.parent.content.size,h=l.depth===0?void 0:lC(l.node(-1).contentMatchAt(l.indexAfter(-1)));let f=u&&h?[{type:h,attrs:d}]:void 0,p=Mn(e.doc,e.mapping.map(l.pos),1,f);if(!f&&!p&&Mn(e.doc,e.mapping.map(l.pos),1,h?[{type:h}]:void 0)&&(p=!0,f=h?[{type:h,attrs:d}]:void 0),r){if(p&&(i instanceof J&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,f),h&&!u&&!l.parentOffset&&l.parent.type!==h)){const g=e.mapping.map(l.before()),y=e.doc.resolve(g);l.node(-1).canReplaceWith(y.index(),y.index()+1,h)&&e.setNodeMarkup(e.mapping.map(l.before()),h)}t&&ap(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return p},_C=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var o;const l=Ke(t,r.schema),{$from:a,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||a.depth<2||!a.sameParent(c))return!1;const u=a.node(-1);if(u.type!==l)return!1;const h=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(s){let b=O.empty;const w=a.index(-1)?1:a.index(-2)?2:3;for(let v=a.depth-w;v>=a.depth-3;v-=1)b=O.from(a.node(v).copy(b));const M=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,S={...Lo(h,a.node().type.name,a.node().attrs),...e},A=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(S))||void 0;b=b.append(O.from(l.createAndFill(null,A)||void 0));const x=a.before(a.depth-(w-1));n.replace(x,a.after(-M),new P(b,4-w,0));let k=-1;n.doc.nodesBetween(x,n.doc.content.size,(v,T)=>{if(k>-1)return!1;v.isTextblock&&v.content.size===0&&(k=T+1)}),k>-1&&n.setSelection(J.near(n.doc.resolve(k))),n.scrollIntoView()}return!0}const f=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,p={...Lo(h,u.type.name,u.attrs),...e},g={...Lo(h,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);const y=f?[{type:l,attrs:p},{type:f,attrs:g}]:[{type:l,attrs:p}];if(!Mn(n.doc,a.pos,2))return!1;if(s){const{selection:b,storedMarks:w}=r,{splittableMarks:M}=i.extensionManager,S=w||b.$to.parentOffset&&b.$from.marks();if(n.split(a.pos,2,y).scrollIntoView(),!S||!s)return!0;const A=S.filter(x=>M.includes(x.type.name));n.ensureMarks(A)}return!0},cc=(t,e)=>{const n=ca(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===s?.type&&ur(t.doc,n.pos)&&t.join(n.pos),!0},dc=(t,e)=>{const n=ca(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===s?.type&&ur(t.doc,r)&&t.join(r),!0},RC=(t,e,n,r={})=>({editor:s,tr:i,state:o,dispatch:l,chain:a,commands:c,can:d})=>{const{extensions:u,splittableMarks:h}=s.extensionManager,f=Ke(t,o.schema),p=Ke(e,o.schema),{selection:g,storedMarks:y}=o,{$from:b,$to:w}=g,M=b.blockRange(w),S=y||g.$to.parentOffset&&g.$from.marks();if(!M)return!1;const A=ca(x=>lp(x.type.name,u))(g);if(M.depth>=1&&A&&M.depth-A.depth<=1){if(A.node.type===f)return c.liftListItem(p);if(lp(A.node.type.name,u)&&f.validContent(A.node.content)&&l)return a().command(()=>(i.setNodeMarkup(A.pos,f),!0)).command(()=>cc(i,f)).command(()=>dc(i,f)).run()}return!n||!S||!l?a().command(()=>d().wrapInList(f,r)?!0:c.clearNodes()).wrapInList(f,r).command(()=>cc(i,f)).command(()=>dc(i,f)).run():a().command(()=>{const x=d().wrapInList(f,r),k=S.filter(v=>h.includes(v.type.name));return i.ensureMarks(k),x?!0:c.clearNodes()}).wrapInList(f,r).command(()=>cc(i,f)).command(()=>dc(i,f)).run()},OC=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,o=Rn(t,r.schema);return id(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},DC=(t,e,n={})=>({state:r,commands:s})=>{const i=Ke(t,r.schema),o=Ke(e,r.schema),l=rr(r,i,n);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(o,a):s.setNode(i,{...a,...n})},LC=(t,e={})=>({state:n,commands:r})=>{const s=Ke(t,n.schema);return rr(n,s,e)?r.lift(s):r.wrapIn(s,e)},IC=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let i;if(s.spec.isInputRules&&(i=s.getState(t))){if(e){const o=t.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(i.text){const a=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else o.delete(i.from,i.to)}return!0}}return!1},jC=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:s}=n;return r||e&&s.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},PC=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,a=Rn(t,r.schema),{$from:c,empty:d,ranges:u}=l;if(!s)return!0;if(d&&o){let{from:h,to:f}=l;const p=(i=c.marks().find(y=>y.type===a))==null?void 0:i.attrs,g=Mu(c,a,p);g&&(h=g.from,f=g.to),n.removeMark(h,f,a)}else u.forEach(h=>{n.removeMark(h.$from.pos,h.$to.pos,a)});return n.removeStoredMark(a),!0},BC=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=aa(typeof t=="string"?t:t.name,r.schema);return l?(l==="node"&&(i=Ke(t,r.schema)),l==="mark"&&(o=Rn(t,r.schema)),s&&n.selection.ranges.forEach(a=>{const c=a.$from.pos,d=a.$to.pos;let u,h,f,p;n.selection.empty?r.doc.nodesBetween(c,d,(g,y)=>{i&&i===g.type&&(f=Math.max(y,c),p=Math.min(y+g.nodeSize,d),u=y,h=g)}):r.doc.nodesBetween(c,d,(g,y)=>{y<c&&i&&i===g.type&&(f=Math.max(y,c),p=Math.min(y+g.nodeSize,d),u=y,h=g),y>=c&&y<=d&&(i&&i===g.type&&n.setNodeMarkup(y,void 0,{...g.attrs,...e}),o&&g.marks.length&&g.marks.forEach(b=>{if(o===b.type){const w=Math.max(y,c),M=Math.min(y+g.nodeSize,d);n.addMark(w,M,o.create({...b.attrs,...e}))}}))}),h&&(u!==void 0&&n.setNodeMarkup(u,void 0,{...h.attrs,...e}),o&&h.marks.length&&h.marks.forEach(g=>{o===g.type&&n.addMark(f,p,o.create({...g.attrs,...e}))}))}),!0):!1},$C=(t,e={})=>({state:n,dispatch:r})=>{const s=Ke(t,n.schema);return kk(s,e)(n,r)},HC=(t,e={})=>({state:n,dispatch:r})=>{const s=Ke(t,n.schema);return vk(s,e)(n,r)},zC=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Ii=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},FC=(t,e)=>{if(Eu(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 ho(t){var e;const{editor:n,from:r,to:s,text:i,rules:o,plugin:l}=t,{view:a}=n;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(h=>h.type.spec.code))return!1;let d=!1;const u=bC(c)+i;return o.forEach(h=>{if(d)return;const f=FC(u,h.find);if(!f)return;const p=a.state.tr,g=ia({state:a.state,transaction:p}),y={from:r-(f[0].length-i.length),to:s},{commands:b,chain:w,can:M}=new oa({editor:n,state:g});h.handler({state:g,range:y,match:f,commands:b,chain:w,can:M})===null||!p.steps.length||(h.undoable&&p.setMeta(l,{transform:p,from:r,to:s,text:i}),a.dispatch(p),d=!0)}),d}function UC(t){const{editor:e,rules:n}=t,r=new pe({state:{init(){return null},apply(s,i,o){const l=s.getMeta(r);if(l)return l;const a=s.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:d}=a;typeof d=="string"?d=d:d=Tu(O.from(d),o.schema);const{from:u}=a,h=u+d.length;ho({editor:e,from:u,to:h,text:d,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,l){return ho({editor:e,from:i,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&ho({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?ho({editor:e,from:o.pos,to:o.pos,text:`
|
|
18
|
-
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function VC(t){return Object.prototype.toString.call(t).slice(8,-1)}function fo(t){return VC(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Jy(t,e){const n={...t};return fo(t)&&fo(e)&&Object.keys(e).forEach(r=>{fo(e[r])&&fo(t[r])?n[r]=Jy(t[r],e[r]):n[r]=e[r]}),n}var Ru=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...we(G(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...we(G(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Jy(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Zt=class Yy extends Ru{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Yy(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(c=>c?.type.name===n.name))return!1;const a=o.find(c=>c?.type.name===n.name);return a&&r.removeStoredMark(a),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function WC(t){return typeof t=="number"}var qC=class{constructor(t){this.find=t.find,this.handler=t.handler}},KC=(t,e,n)=>{if(Eu(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=t,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function GC(t){const{editor:e,state:n,from:r,to:s,rule:i,pasteEvent:o,dropEvent:l}=t,{commands:a,chain:c,can:d}=new oa({editor:e,state:n}),u=[];return n.doc.nodesBetween(r,s,(f,p)=>{var g,y,b,w,M;if((y=(g=f.type)==null?void 0:g.spec)!=null&&y.code||!(f.isText||f.isTextblock||f.isInline))return;const S=(M=(w=(b=f.content)==null?void 0:b.size)!=null?w:f.nodeSize)!=null?M:0,A=Math.max(r,p),x=Math.min(s,p+S);if(A>=x)return;const k=f.isText?f.text||"":f.textBetween(A-p,x-p,void 0,"");KC(k,i.find,o).forEach(T=>{if(T.index===void 0)return;const N=A+T.index+1,H=N+T[0].length,V={from:n.tr.mapping.map(N),to:n.tr.mapping.map(H)},$=i.handler({state:n,range:V,match:T,commands:a,chain:c,can:d,pasteEvent:o,dropEvent:l});u.push($)})}),u.every(f=>f!==null)}var po=null,JC=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function YC(t){const{editor:e,rules:n}=t;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:d,from:u,to:h,rule:f,pasteEvt:p})=>{const g=d.tr,y=ia({state:d,transaction:g});if(!(!GC({editor:e,state:y,from:Math.max(u-1,0),to:h.b-1,rule:f,pasteEvent:p,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return n.map(d=>new pe({view(u){const h=p=>{var g;r=(g=u.dom.parentElement)!=null&&g.contains(p.target)?u.dom.parentElement:null,r&&(po=e)},f=()=>{po&&(po=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(u,h)=>{if(i=r===u.dom.parentElement,l=h,!i){const f=po;f?.isEditable&&setTimeout(()=>{const p=f.state.selection;p&&f.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(u,h)=>{var f;const p=(f=h.clipboardData)==null?void 0:f.getData("text/html");return o=h,s=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(u,h,f)=>{const p=u[0],g=p.getMeta("uiEvent")==="paste"&&!s,y=p.getMeta("uiEvent")==="drop"&&!i,b=p.getMeta("applyPasteRules"),w=!!b;if(!g&&!y&&!w)return;if(w){let{text:A}=b;typeof A=="string"?A=A:A=Tu(O.from(A),f.schema);const{from:x}=b,k=x+A.length,v=JC(A);return a({rule:d,state:f,from:x,to:{b:k},pasteEvt:v})}const M=h.doc.content.findDiffStart(f.doc.content),S=h.doc.content.findDiffEnd(f.doc.content);if(!(!WC(M)||!S||M===S.b))return a({rule:d,state:f,from:M,to:S,pasteEvt:o})}}))}var da=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Uy(t),this.schema=uC(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ac(e.name,this.schema)},r=G(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Nu([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:ac(r.name,this.schema)},i=[],o=G(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&G(r,"exitable",s)&&(l.ArrowRight=()=>Zt.handleExit({editor:t,mark:r})),o){const h=Object.fromEntries(Object.entries(o()).map(([f,p])=>[f,()=>p({editor:t})]));l={...l,...h}}const a=gS(l);i.push(a);const c=G(r,"addInputRules",s);if(op(r,t.options.enableInputRules)&&c){const h=c();if(h&&h.length){const f=UC({editor:t,rules:h}),p=Array.isArray(f)?f:[f];i.push(...p)}}const d=G(r,"addPasteRules",s);if(op(r,t.options.enablePasteRules)&&d){const h=d();if(h&&h.length){const f=YC({editor:t,rules:h});i.push(...f)}}const u=G(r,"addProseMirrorPlugins",s);if(u){const h=u();i.push(...h)}return i})}get attributes(){return Fy(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=pi(this.extensions);return Object.fromEntries(e.filter(n=>!!G(n,"addNodeView")).map(n=>{const r=this.attributes.filter(a=>a.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ke(n.name,this.schema)},i=G(n,"addNodeView",s);if(!i)return[];const o=i();if(!o)return[];const l=(a,c,d,u,h)=>{const f=mi(a,r);return o({node:a,view:c,getPos:d,decorations:u,innerDecorations:h,editor:t,extension:n,HTMLAttributes:f})};return[n.name,l]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=pi(this.extensions);return Object.fromEntries(e.filter(n=>!!G(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Rn(n.name,this.schema)},i=G(n,"addMarkView",s);if(!i)return[];const o=(l,a,c)=>{const d=mi(l,r);return i()({mark:l,view:a,inline:c,editor:t,extension:n,HTMLAttributes:d,updateAttributes:u=>{hE(l,t,u)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ac(e.name,this.schema)};e.type==="mark"&&((n=we(G(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const s=G(e,"onBeforeCreate",r),i=G(e,"onCreate",r),o=G(e,"onUpdate",r),l=G(e,"onSelectionUpdate",r),a=G(e,"onTransaction",r),c=G(e,"onFocus",r),d=G(e,"onBlur",r),u=G(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}};da.resolve=Uy;da.sort=Nu;da.flatten=Au;var XC={};Cu(XC,{ClipboardTextSerializer:()=>Zy,Commands:()=>Qy,Delete:()=>eb,Drop:()=>tb,Editable:()=>nb,FocusEvents:()=>sb,Keymap:()=>ib,Paste:()=>ob,Tabindex:()=>lb,focusEventsPluginKey:()=>rb});var de=class Xy extends Ru{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Xy(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Zy=de.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new pe({key:new ge("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,{ranges:i}=s,o=Math.min(...i.map(d=>d.$from.pos)),l=Math.max(...i.map(d=>d.$to.pos)),a=Wy(n);return Vy(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Qy=de.create({name:"commands",addCommands(){return{...Ry}}}),eb=de.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,s;const i=()=>{var o,l,a,c;if((c=(a=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,t))!=null?c:t.getMeta("y-sync$"))return;const d=$y(t.before,[t,...e]);Ky(d).forEach(f=>{d.mapping.mapResult(f.oldRange.from).deletedAfter&&d.mapping.mapResult(f.oldRange.to).deletedBefore&&d.before.nodesBetween(f.oldRange.from,f.oldRange.to,(p,g)=>{const y=g+p.nodeSize-2,b=f.oldRange.from<=g&&y<=f.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:g,to:y,newFrom:d.mapping.map(g),newTo:d.mapping.map(y),deletedRange:f.oldRange,newRange:f.newRange,partial:!b,editor:this.editor,transaction:t,combinedTransform:d})})});const h=d.mapping;d.steps.forEach((f,p)=>{var g,y;if(f instanceof Wt){const b=h.slice(p).map(f.from,-1),w=h.slice(p).map(f.to),M=h.invert().map(b,-1),S=h.invert().map(w),A=(g=d.doc.nodeAt(b-1))==null?void 0:g.marks.some(k=>k.eq(f.mark)),x=(y=d.doc.nodeAt(w))==null?void 0:y.marks.some(k=>k.eq(f.mark));this.editor.emit("delete",{type:"mark",mark:f.mark,from:f.from,to:f.to,deletedRange:{from:M,to:S},newRange:{from:b,to:w},partial:!!(x||A),editor:this.editor,transaction:t,combinedTransform:d})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(i,0):i()}}),tb=de.create({name:"drop",addProseMirrorPlugins(){return[new pe({key:new ge("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),nb=de.create({name:"editable",addProseMirrorPlugins(){return[new pe({key:new ge("editable"),props:{editable:()=>this.editor.options.editable}})]}}),rb=new ge("focusEvents"),sb=de.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new pe({key:rb,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}}}})]}}),ib=de.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:h,parent:f}=u,p=u.parent.isTextblock&&h>0?l.doc.resolve(h-1):u,g=p.parent.type.spec.isolating,y=u.pos-u.parentOffset,b=g&&p.parent.childCount===1?y===u.pos:ee.atStart(c).from===h;return!d||!f.type.isTextblock||f.textContent.length||!b||b&&u.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return la()||Py()?i:s},addProseMirrorPlugins(){return[new pe({key:new ge("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(g=>g.getMeta("composition")))return;const r=t.some(g=>g.docChanged)&&!e.doc.eq(n.doc),s=t.some(g=>g.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:l}=e.selection,a=ee.atStart(e.doc).from,c=ee.atEnd(e.doc).to;if(i||!(o===a&&l===c)||!Li(n.doc))return;const h=n.tr,f=ia({state:n,transaction:h}),{commands:p}=new oa({editor:this.editor,state:f});if(p.clearNodes(),!!h.steps.length)return h}})]}}),ob=de.create({name:"paste",addProseMirrorPlugins(){return[new pe({key:new ge("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),lb=de.create({name:"tabindex",addProseMirrorPlugins(){return[new pe({key:new ge("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),ZC=class Qr{constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Qr(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 Qr(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 Qr(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=this.pos+r+(i?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!s&&l.depth<=this.depth)return;const a=new Qr(l,this.editor,s,s?n:null);s&&(a.actualDepth=this.depth+1),e.push(new Qr(l,this.editor,s,s?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,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){const i=s.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const a=o[l];if(i[a]!==n[a])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(n);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(a=>n[a]===o.node.attrs[a])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,n,r))))}),s}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},QC=`.ProseMirror {
|
|
17
|
+
`,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,s,(a,c,d,u)=>{var h;a.isBlock&&c>r&&(l+=i);const f=o?.[a.type.name];if(f)return d&&(l+=f({node:a,pos:c,parent:d,index:u,range:e})),!1;a.isText&&(l+=(h=a?.text)==null?void 0:h.slice(Math.max(r,c)-c,s-c))}),l}function fC(t,e){const n={from:0,to:t.content.size};return Vy(t,n,e)}function Wy(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function pC(t,e){const n=Ke(e,t.schema),{from:r,to:s}=t.selection,i=[];t.doc.nodesBetween(r,s,l=>{i.push(l)});const o=i.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function qy(t,e){const n=aa(typeof e=="string"?e:e.name,t.schema);return n==="node"?pC(t,e):n==="mark"?By(t,e):{}}function mC(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function gC(t){const e=mC(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,o)=>o!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function Ky(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=n[i];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(i).map(l,-1),d=e.slice(i).map(a),u=e.invert().map(c,-1),h=e.invert().map(d);r.push({oldRange:{from:u,to:h},newRange:{from:c,to:d}})})}),gC(r)}function _u(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const i=n.resolve(t),o=Mu(i,s.type);o&&r.push({mark:s,...o})}):n.nodesBetween(t,e,(s,i)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}var yC=(t,e,n,r=20)=>{const s=t.doc.resolve(n);let i=r,o=null;for(;i>0&&o===null;){const l=s.node(i);l?.type.name===e?o=l:i-=1}return[o,i]};function ac(t,e){return e.nodes[t]||e.marks[t]||null}function Lo(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}var bC=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,l)=>{var a,c;const d=((c=(a=s.type.spec).toText)==null?void 0:c.call(a,{node:s,pos:i,parent:o,index:l}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?d:d.slice(0,Math.max(0,r-i))}),n};function id(t,e,n={}){const{empty:r,ranges:s}=t.selection,i=e?Rn(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>rl(u.attrs,n,{strict:!1}));let o=0;const l=[];if(s.forEach(({$from:u,$to:h})=>{const f=u.pos,p=h.pos;t.doc.nodesBetween(f,p,(g,y)=>{if(!g.isText&&!g.marks.length)return;const b=Math.max(f,y),w=Math.min(p,y+g.nodeSize),M=w-b;o+=M,l.push(...g.marks.map(S=>({mark:S,from:b,to:w})))})}),o===0)return!1;const a=l.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>rl(u.mark.attrs,n,{strict:!1})).reduce((u,h)=>u+h.to-h.from,0),c=l.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,h)=>u+h.to-h.from,0);return(a>0?a+c:a)>=o}function xC(t,e,n={}){if(!e)return rr(t,null,n)||id(t,null,n);const r=aa(e,t.schema);return r==="node"?rr(t,e,n):r==="mark"?id(t,e,n):!1}var wC=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const i=ca(l=>l.type.name===e)(t.selection);if(!i)return!1;const o=t.doc.resolve(i.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},kC=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function op(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function lp(t,e){const{nodeExtensions:n}=pi(e),r=n.find(o=>o.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=we(G(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function Li(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(i=>{s!==!1&&(Li(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function Gy(t){return t instanceof q}function vC(t,e,n){var r;const{selection:s}=e;let i=null;if(Dy(s)&&(i=s.$cursor),i){const l=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(c=>c.type.excludes(n)))}const{ranges:o}=s;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(d,u,h)=>{if(c)return!1;if(d.isInline){const f=!h||h.type.allowsMarkType(n),p=!!n.isInSet(d.marks)||!d.marks.some(g=>g.type.excludes(n));c=f&&p}return!c}),c})}var SC=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:o,ranges:l}=i,a=Rn(t,r.schema);if(s)if(o){const c=By(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(h,f)=>{const p=Math.max(f,d),g=Math.min(f+h.nodeSize,u);h.marks.find(b=>b.type===a)?h.marks.forEach(b=>{a===b.type&&n.addMark(p,g,a.create({...b.attrs,...e}))}):n.addMark(p,g,a.create(e))})});return vC(r,n,a)},CC=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),EC=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const i=Ke(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:l})=>vf(i,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>vf(i,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},MC=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=kr(t,0,r.content.size),i=q.create(r,s);e.setSelection(i)}return!0},AC=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,o=J.atStart(r).from,l=J.atEnd(r).to,a=kr(s,o,l),c=kr(i,o,l),d=J.create(r,a,c);e.setSelection(d)}return!0},TC=t=>({state:e,dispatch:n})=>{const r=Ke(t,e.schema);return Tk(r)(e,n)};function ap(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e?.includes(s.type.name));t.tr.ensureMarks(r)}}var NC=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:l,$to:a}=i,c=s.extensionManager.attributes,d=Lo(c,l.node().type.name,l.node().attrs);if(i instanceof q&&i.node.isBlock)return!l.parentOffset||!Mn(o,l.pos)?!1:(r&&(t&&ap(n,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const u=a.parentOffset===a.parent.content.size,h=l.depth===0?void 0:lC(l.node(-1).contentMatchAt(l.indexAfter(-1)));let f=u&&h?[{type:h,attrs:d}]:void 0,p=Mn(e.doc,e.mapping.map(l.pos),1,f);if(!f&&!p&&Mn(e.doc,e.mapping.map(l.pos),1,h?[{type:h}]:void 0)&&(p=!0,f=h?[{type:h,attrs:d}]:void 0),r){if(p&&(i instanceof J&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,f),h&&!u&&!l.parentOffset&&l.parent.type!==h)){const g=e.mapping.map(l.before()),y=e.doc.resolve(g);l.node(-1).canReplaceWith(y.index(),y.index()+1,h)&&e.setNodeMarkup(e.mapping.map(l.before()),h)}t&&ap(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return p},_C=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var o;const l=Ke(t,r.schema),{$from:a,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||a.depth<2||!a.sameParent(c))return!1;const u=a.node(-1);if(u.type!==l)return!1;const h=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(s){let b=O.empty;const w=a.index(-1)?1:a.index(-2)?2:3;for(let v=a.depth-w;v>=a.depth-3;v-=1)b=O.from(a.node(v).copy(b));const M=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,S={...Lo(h,a.node().type.name,a.node().attrs),...e},A=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(S))||void 0;b=b.append(O.from(l.createAndFill(null,A)||void 0));const x=a.before(a.depth-(w-1));n.replace(x,a.after(-M),new P(b,4-w,0));let k=-1;n.doc.nodesBetween(x,n.doc.content.size,(v,T)=>{if(k>-1)return!1;v.isTextblock&&v.content.size===0&&(k=T+1)}),k>-1&&n.setSelection(J.near(n.doc.resolve(k))),n.scrollIntoView()}return!0}const f=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,p={...Lo(h,u.type.name,u.attrs),...e},g={...Lo(h,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);const y=f?[{type:l,attrs:p},{type:f,attrs:g}]:[{type:l,attrs:p}];if(!Mn(n.doc,a.pos,2))return!1;if(s){const{selection:b,storedMarks:w}=r,{splittableMarks:M}=i.extensionManager,S=w||b.$to.parentOffset&&b.$from.marks();if(n.split(a.pos,2,y).scrollIntoView(),!S||!s)return!0;const A=S.filter(x=>M.includes(x.type.name));n.ensureMarks(A)}return!0},cc=(t,e)=>{const n=ca(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===s?.type&&ur(t.doc,n.pos)&&t.join(n.pos),!0},dc=(t,e)=>{const n=ca(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===s?.type&&ur(t.doc,r)&&t.join(r),!0},RC=(t,e,n,r={})=>({editor:s,tr:i,state:o,dispatch:l,chain:a,commands:c,can:d})=>{const{extensions:u,splittableMarks:h}=s.extensionManager,f=Ke(t,o.schema),p=Ke(e,o.schema),{selection:g,storedMarks:y}=o,{$from:b,$to:w}=g,M=b.blockRange(w),S=y||g.$to.parentOffset&&g.$from.marks();if(!M)return!1;const A=ca(x=>lp(x.type.name,u))(g);if(M.depth>=1&&A&&M.depth-A.depth<=1){if(A.node.type===f)return c.liftListItem(p);if(lp(A.node.type.name,u)&&f.validContent(A.node.content)&&l)return a().command(()=>(i.setNodeMarkup(A.pos,f),!0)).command(()=>cc(i,f)).command(()=>dc(i,f)).run()}return!n||!S||!l?a().command(()=>d().wrapInList(f,r)?!0:c.clearNodes()).wrapInList(f,r).command(()=>cc(i,f)).command(()=>dc(i,f)).run():a().command(()=>{const x=d().wrapInList(f,r),k=S.filter(v=>h.includes(v.type.name));return i.ensureMarks(k),x?!0:c.clearNodes()}).wrapInList(f,r).command(()=>cc(i,f)).command(()=>dc(i,f)).run()},OC=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,o=Rn(t,r.schema);return id(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},DC=(t,e,n={})=>({state:r,commands:s})=>{const i=Ke(t,r.schema),o=Ke(e,r.schema),l=rr(r,i,n);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(o,a):s.setNode(i,{...a,...n})},LC=(t,e={})=>({state:n,commands:r})=>{const s=Ke(t,n.schema);return rr(n,s,e)?r.lift(s):r.wrapIn(s,e)},IC=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let i;if(s.spec.isInputRules&&(i=s.getState(t))){if(e){const o=t.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(i.text){const a=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else o.delete(i.from,i.to)}return!0}}return!1},jC=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:s}=n;return r||e&&s.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},PC=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,a=Rn(t,r.schema),{$from:c,empty:d,ranges:u}=l;if(!s)return!0;if(d&&o){let{from:h,to:f}=l;const p=(i=c.marks().find(y=>y.type===a))==null?void 0:i.attrs,g=Mu(c,a,p);g&&(h=g.from,f=g.to),n.removeMark(h,f,a)}else u.forEach(h=>{n.removeMark(h.$from.pos,h.$to.pos,a)});return n.removeStoredMark(a),!0},BC=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=aa(typeof t=="string"?t:t.name,r.schema);return l?(l==="node"&&(i=Ke(t,r.schema)),l==="mark"&&(o=Rn(t,r.schema)),s&&n.selection.ranges.forEach(a=>{const c=a.$from.pos,d=a.$to.pos;let u,h,f,p;n.selection.empty?r.doc.nodesBetween(c,d,(g,y)=>{i&&i===g.type&&(f=Math.max(y,c),p=Math.min(y+g.nodeSize,d),u=y,h=g)}):r.doc.nodesBetween(c,d,(g,y)=>{y<c&&i&&i===g.type&&(f=Math.max(y,c),p=Math.min(y+g.nodeSize,d),u=y,h=g),y>=c&&y<=d&&(i&&i===g.type&&n.setNodeMarkup(y,void 0,{...g.attrs,...e}),o&&g.marks.length&&g.marks.forEach(b=>{if(o===b.type){const w=Math.max(y,c),M=Math.min(y+g.nodeSize,d);n.addMark(w,M,o.create({...b.attrs,...e}))}}))}),h&&(u!==void 0&&n.setNodeMarkup(u,void 0,{...h.attrs,...e}),o&&h.marks.length&&h.marks.forEach(g=>{o===g.type&&n.addMark(f,p,o.create({...g.attrs,...e}))}))}),!0):!1},$C=(t,e={})=>({state:n,dispatch:r})=>{const s=Ke(t,n.schema);return kk(s,e)(n,r)},HC=(t,e={})=>({state:n,dispatch:r})=>{const s=Ke(t,n.schema);return vk(s,e)(n,r)},zC=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Ii=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},FC=(t,e)=>{if(Eu(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 ho(t){var e;const{editor:n,from:r,to:s,text:i,rules:o,plugin:l}=t,{view:a}=n;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(h=>h.type.spec.code))return!1;let d=!1;const u=bC(c)+i;return o.forEach(h=>{if(d)return;const f=FC(u,h.find);if(!f)return;const p=a.state.tr,g=ia({state:a.state,transaction:p}),y={from:r-(f[0].length-i.length),to:s},{commands:b,chain:w,can:M}=new oa({editor:n,state:g});h.handler({state:g,range:y,match:f,commands:b,chain:w,can:M})===null||!p.steps.length||(h.undoable&&p.setMeta(l,{transform:p,from:r,to:s,text:i}),a.dispatch(p),d=!0)}),d}function UC(t){const{editor:e,rules:n}=t,r=new me({state:{init(){return null},apply(s,i,o){const l=s.getMeta(r);if(l)return l;const a=s.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:d}=a;typeof d=="string"?d=d:d=Tu(O.from(d),o.schema);const{from:u}=a,h=u+d.length;ho({editor:e,from:u,to:h,text:d,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,l){return ho({editor:e,from:i,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&ho({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?ho({editor:e,from:o.pos,to:o.pos,text:`
|
|
18
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function VC(t){return Object.prototype.toString.call(t).slice(8,-1)}function fo(t){return VC(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Jy(t,e){const n={...t};return fo(t)&&fo(e)&&Object.keys(e).forEach(r=>{fo(e[r])&&fo(t[r])?n[r]=Jy(t[r],e[r]):n[r]=e[r]}),n}var Ru=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...we(G(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...we(G(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Jy(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Zt=class Yy extends Ru{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Yy(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(c=>c?.type.name===n.name))return!1;const a=o.find(c=>c?.type.name===n.name);return a&&r.removeStoredMark(a),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function WC(t){return typeof t=="number"}var qC=class{constructor(t){this.find=t.find,this.handler=t.handler}},KC=(t,e,n)=>{if(Eu(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=t,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function GC(t){const{editor:e,state:n,from:r,to:s,rule:i,pasteEvent:o,dropEvent:l}=t,{commands:a,chain:c,can:d}=new oa({editor:e,state:n}),u=[];return n.doc.nodesBetween(r,s,(f,p)=>{var g,y,b,w,M;if((y=(g=f.type)==null?void 0:g.spec)!=null&&y.code||!(f.isText||f.isTextblock||f.isInline))return;const S=(M=(w=(b=f.content)==null?void 0:b.size)!=null?w:f.nodeSize)!=null?M:0,A=Math.max(r,p),x=Math.min(s,p+S);if(A>=x)return;const k=f.isText?f.text||"":f.textBetween(A-p,x-p,void 0,"");KC(k,i.find,o).forEach(T=>{if(T.index===void 0)return;const N=A+T.index+1,H=N+T[0].length,V={from:n.tr.mapping.map(N),to:n.tr.mapping.map(H)},$=i.handler({state:n,range:V,match:T,commands:a,chain:c,can:d,pasteEvent:o,dropEvent:l});u.push($)})}),u.every(f=>f!==null)}var po=null,JC=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function YC(t){const{editor:e,rules:n}=t;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:d,from:u,to:h,rule:f,pasteEvt:p})=>{const g=d.tr,y=ia({state:d,transaction:g});if(!(!GC({editor:e,state:y,from:Math.max(u-1,0),to:h.b-1,rule:f,pasteEvent:p,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return n.map(d=>new me({view(u){const h=p=>{var g;r=(g=u.dom.parentElement)!=null&&g.contains(p.target)?u.dom.parentElement:null,r&&(po=e)},f=()=>{po&&(po=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(u,h)=>{if(i=r===u.dom.parentElement,l=h,!i){const f=po;f?.isEditable&&setTimeout(()=>{const p=f.state.selection;p&&f.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(u,h)=>{var f;const p=(f=h.clipboardData)==null?void 0:f.getData("text/html");return o=h,s=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(u,h,f)=>{const p=u[0],g=p.getMeta("uiEvent")==="paste"&&!s,y=p.getMeta("uiEvent")==="drop"&&!i,b=p.getMeta("applyPasteRules"),w=!!b;if(!g&&!y&&!w)return;if(w){let{text:A}=b;typeof A=="string"?A=A:A=Tu(O.from(A),f.schema);const{from:x}=b,k=x+A.length,v=JC(A);return a({rule:d,state:f,from:x,to:{b:k},pasteEvt:v})}const M=h.doc.content.findDiffStart(f.doc.content),S=h.doc.content.findDiffEnd(f.doc.content);if(!(!WC(M)||!S||M===S.b))return a({rule:d,state:f,from:M,to:S,pasteEvt:o})}}))}var da=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Uy(t),this.schema=uC(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ac(e.name,this.schema)},r=G(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Nu([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:ac(r.name,this.schema)},i=[],o=G(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&G(r,"exitable",s)&&(l.ArrowRight=()=>Zt.handleExit({editor:t,mark:r})),o){const h=Object.fromEntries(Object.entries(o()).map(([f,p])=>[f,()=>p({editor:t})]));l={...l,...h}}const a=gS(l);i.push(a);const c=G(r,"addInputRules",s);if(op(r,t.options.enableInputRules)&&c){const h=c();if(h&&h.length){const f=UC({editor:t,rules:h}),p=Array.isArray(f)?f:[f];i.push(...p)}}const d=G(r,"addPasteRules",s);if(op(r,t.options.enablePasteRules)&&d){const h=d();if(h&&h.length){const f=YC({editor:t,rules:h});i.push(...f)}}const u=G(r,"addProseMirrorPlugins",s);if(u){const h=u();i.push(...h)}return i})}get attributes(){return Fy(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=pi(this.extensions);return Object.fromEntries(e.filter(n=>!!G(n,"addNodeView")).map(n=>{const r=this.attributes.filter(a=>a.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ke(n.name,this.schema)},i=G(n,"addNodeView",s);if(!i)return[];const o=i();if(!o)return[];const l=(a,c,d,u,h)=>{const f=mi(a,r);return o({node:a,view:c,getPos:d,decorations:u,innerDecorations:h,editor:t,extension:n,HTMLAttributes:f})};return[n.name,l]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=pi(this.extensions);return Object.fromEntries(e.filter(n=>!!G(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Rn(n.name,this.schema)},i=G(n,"addMarkView",s);if(!i)return[];const o=(l,a,c)=>{const d=mi(l,r);return i()({mark:l,view:a,inline:c,editor:t,extension:n,HTMLAttributes:d,updateAttributes:u=>{hE(l,t,u)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ac(e.name,this.schema)};e.type==="mark"&&((n=we(G(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const s=G(e,"onBeforeCreate",r),i=G(e,"onCreate",r),o=G(e,"onUpdate",r),l=G(e,"onSelectionUpdate",r),a=G(e,"onTransaction",r),c=G(e,"onFocus",r),d=G(e,"onBlur",r),u=G(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}};da.resolve=Uy;da.sort=Nu;da.flatten=Au;var XC={};Cu(XC,{ClipboardTextSerializer:()=>Zy,Commands:()=>Qy,Delete:()=>eb,Drop:()=>tb,Editable:()=>nb,FocusEvents:()=>sb,Keymap:()=>ib,Paste:()=>ob,Tabindex:()=>lb,focusEventsPluginKey:()=>rb});var de=class Xy extends Ru{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Xy(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Zy=de.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new me({key:new ye("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,{ranges:i}=s,o=Math.min(...i.map(d=>d.$from.pos)),l=Math.max(...i.map(d=>d.$to.pos)),a=Wy(n);return Vy(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Qy=de.create({name:"commands",addCommands(){return{...Ry}}}),eb=de.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,s;const i=()=>{var o,l,a,c;if((c=(a=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,t))!=null?c:t.getMeta("y-sync$"))return;const d=$y(t.before,[t,...e]);Ky(d).forEach(f=>{d.mapping.mapResult(f.oldRange.from).deletedAfter&&d.mapping.mapResult(f.oldRange.to).deletedBefore&&d.before.nodesBetween(f.oldRange.from,f.oldRange.to,(p,g)=>{const y=g+p.nodeSize-2,b=f.oldRange.from<=g&&y<=f.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:g,to:y,newFrom:d.mapping.map(g),newTo:d.mapping.map(y),deletedRange:f.oldRange,newRange:f.newRange,partial:!b,editor:this.editor,transaction:t,combinedTransform:d})})});const h=d.mapping;d.steps.forEach((f,p)=>{var g,y;if(f instanceof Wt){const b=h.slice(p).map(f.from,-1),w=h.slice(p).map(f.to),M=h.invert().map(b,-1),S=h.invert().map(w),A=(g=d.doc.nodeAt(b-1))==null?void 0:g.marks.some(k=>k.eq(f.mark)),x=(y=d.doc.nodeAt(w))==null?void 0:y.marks.some(k=>k.eq(f.mark));this.editor.emit("delete",{type:"mark",mark:f.mark,from:f.from,to:f.to,deletedRange:{from:M,to:S},newRange:{from:b,to:w},partial:!!(x||A),editor:this.editor,transaction:t,combinedTransform:d})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(i,0):i()}}),tb=de.create({name:"drop",addProseMirrorPlugins(){return[new me({key:new ye("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),nb=de.create({name:"editable",addProseMirrorPlugins(){return[new me({key:new ye("editable"),props:{editable:()=>this.editor.options.editable}})]}}),rb=new ye("focusEvents"),sb=de.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new me({key:rb,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}}}})]}}),ib=de.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:h,parent:f}=u,p=u.parent.isTextblock&&h>0?l.doc.resolve(h-1):u,g=p.parent.type.spec.isolating,y=u.pos-u.parentOffset,b=g&&p.parent.childCount===1?y===u.pos:ee.atStart(c).from===h;return!d||!f.type.isTextblock||f.textContent.length||!b||b&&u.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return la()||Py()?i:s},addProseMirrorPlugins(){return[new me({key:new ye("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(g=>g.getMeta("composition")))return;const r=t.some(g=>g.docChanged)&&!e.doc.eq(n.doc),s=t.some(g=>g.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:l}=e.selection,a=ee.atStart(e.doc).from,c=ee.atEnd(e.doc).to;if(i||!(o===a&&l===c)||!Li(n.doc))return;const h=n.tr,f=ia({state:n,transaction:h}),{commands:p}=new oa({editor:this.editor,state:f});if(p.clearNodes(),!!h.steps.length)return h}})]}}),ob=de.create({name:"paste",addProseMirrorPlugins(){return[new me({key:new ye("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),lb=de.create({name:"tabindex",addProseMirrorPlugins(){return[new me({key:new ye("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),ZC=class Qr{constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Qr(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 Qr(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 Qr(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=this.pos+r+(i?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!s&&l.depth<=this.depth)return;const a=new Qr(l,this.editor,s,s?n:null);s&&(a.actualDepth=this.depth+1),e.push(new Qr(l,this.editor,s,s?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,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){const i=s.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const a=o[l];if(i[a]!==n[a])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(n);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(a=>n[a]===o.node.attrs[a])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,n,r))))}),s}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},QC=`.ProseMirror {
|
|
19
19
|
position: relative;
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -101,10 +101,10 @@ ${y}
|
|
|
101
101
|
`);A.trim()&&(e.customNestedParser?w=e.customNestedParser(A):w=n.blockTokens(A))}const S=e.createToken(p,w);a.push(S)}if(a.length!==0)return{items:a,raw:c.trim()}}function Lu(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[i,...o]=t.content,l=e.renderChildren([i]),a=[`${s}${l}`];return o&&o.length>0&&o.forEach(c=>{const d=e.renderChildren([c]);if(d){const u=d.split(`
|
|
102
102
|
`).map(h=>h?e.indent(h):"").join(`
|
|
103
103
|
`);a.push(u)}}),a.join(`
|
|
104
|
-
`)}function hE(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,o=t;s.descendants((l,a)=>{const c=i.mapping.map(a),d=i.mapping.map(a)+l.nodeSize;let u=null;if(l.marks.forEach(f=>{if(f!==o)return!1;u=f}),!u)return;let h=!1;if(Object.keys(n).forEach(f=>{n[f]!==u.attrs[f]&&(h=!0)}),h){const f=t.type.create({...t.attrs,...n});i.removeMark(c,d,t.type),i.addMark(c,d,f)}}),i.docChanged&&e.view.dispatch(i)}var De=class cb extends Ru{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new cb(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},fE=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,s,i,o,l;const{view:a}=this.editor,c=t.target,d=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(c)||!d)return;let u=0,h=0;if(this.dom!==d){const w=this.dom.getBoundingClientRect(),M=d.getBoundingClientRect(),S=(s=t.offsetX)!=null?s:(r=t.nativeEvent)==null?void 0:r.offsetX,A=(o=t.offsetY)!=null?o:(i=t.nativeEvent)==null?void 0:i.offsetY;u=M.x-w.x+S,h=M.y-w.y+A}const f=this.dom.cloneNode(!0);try{const w=this.dom.getBoundingClientRect();f.style.width=`${Math.round(w.width)}px`,f.style.height=`${Math.round(w.height)}px`,f.style.boxSizing="border-box",f.style.pointerEvents="none"}catch{}let p=null;try{p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(f),document.body.appendChild(p),(l=t.dataTransfer)==null||l.setDragImage(f,u,h)}finally{p&&setTimeout(()=>{try{p?.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const y=q.create(a.state.doc,g),b=a.state.tr.setSelection(y);a.dispatch(b)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const s=t.type.startsWith("drag"),i=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!i&&!s)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,d=q.isSelectable(this.node),u=t.type==="copy",h=t.type==="paste",f=t.type==="cut",p=t.type==="mousedown";if(!c&&d&&s&&t.target===this.dom&&t.preventDefault(),c&&s&&!a&&t.target===this.dom)return t.preventDefault(),!1;if(c&&l&&!a&&p){const g=n.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(a||i||u||h||f||p&&d)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(la()||Iy())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function sr(t){return new qC({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const i=we(t.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=n.to;if(l){const d=a.search(/\S/),u=n.from+a.indexOf(l),h=u+l.length;if(_u(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(y=>y===t.type&&y!==p.mark.type)).filter(p=>p.to>u).length)return null;h<n.to&&o.delete(h,n.to),u>n.from&&o.delete(n.from+d,u),c=n.from+d+l.length,o.addMark(n.from+d,c,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}var uc,cp;function pE(){return cp||(cp=1,uc=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,s,i;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(s=r;s--!==0;)if(!t(e[s],n[s]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(s of e.entries())if(!n.has(s[0]))return!1;for(s of e.entries())if(!t(s[1],n.get(s[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(s of e.entries())if(!n.has(s[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(s=r;s--!==0;)if(e[s]!==n[s])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(n).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[s]))return!1;for(s=r;s--!==0;){var o=i[s];if(!(o==="_owner"&&e.$$typeof)&&!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}),uc}var mE=pE();const gE=sg(mE);var mo={exports:{}},hc={};var dp;function yE(){if(dp)return hc;dp=1;var t=C,e=nu();function n(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,i=t.useRef,o=t.useEffect,l=t.useMemo,a=t.useDebugValue;return hc.useSyncExternalStoreWithSelector=function(c,d,u,h,f){var p=i(null);if(p.current===null){var g={hasValue:!1,value:null};p.current=g}else g=p.current;p=l(function(){function b(x){if(!w){if(w=!0,M=x,x=h(x),f!==void 0&&g.hasValue){var k=g.value;if(f(k,x))return S=k}return S=x}if(k=S,r(M,x))return k;var v=h(x);return f!==void 0&&f(k,v)?(M=x,k):(M=x,S=v)}var w=!1,M,S,A=u===void 0?null:u;return[function(){return b(d())},A===null?void 0:function(){return b(A())}]},[d,u,h,f]);var y=s(c,p[0],p[1]);return o(function(){g.hasValue=!0,g.value=y},[y]),a(y),y},hc}var fc={};var up;function bE(){return up||(up=1,process.env.NODE_ENV!=="production"&&(function(){function t(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var e=C,n=nu(),r=typeof Object.is=="function"?Object.is:t,s=n.useSyncExternalStore,i=e.useRef,o=e.useEffect,l=e.useMemo,a=e.useDebugValue;fc.useSyncExternalStoreWithSelector=function(c,d,u,h,f){var p=i(null);if(p.current===null){var g={hasValue:!1,value:null};p.current=g}else g=p.current;p=l(function(){function b(x){if(!w){if(w=!0,M=x,x=h(x),f!==void 0&&g.hasValue){var k=g.value;if(f(k,x))return S=k}return S=x}if(k=S,r(M,x))return k;var v=h(x);return f!==void 0&&f(k,v)?(M=x,k):(M=x,S=v)}var w=!1,M,S,A=u===void 0?null:u;return[function(){return b(d())},A===null?void 0:function(){return b(A())}]},[d,u,h,f]);var y=s(c,p[0],p[1]);return o(function(){g.hasValue=!0,g.value=y},[y]),a(y),y},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),fc}var hp;function xE(){return hp||(hp=1,process.env.NODE_ENV==="production"?mo.exports=yE():mo.exports=bE()),mo.exports}var wE=xE(),kE=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},vE=({contentComponent:t})=>{const e=ig.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return m.jsx(m.Fragment,{children:Object.values(e)})};function SE(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:tu.createPortal(r.reactElement,r.element,n)},t.forEach(s=>s())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(s=>s())}}}var CE=class extends C.Component{constructor(t){var e;super(t),this.editorContentRef=C.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(t.view.dom),t.setOptions({element:e}),t.contentComponent=SE(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return m.jsxs(m.Fragment,{children:[m.jsx("div",{ref:kE(e,this.editorContentRef),...n}),t?.contentComponent&&m.jsx(vE,{contentComponent:t.contentComponent})]})}},EE=C.forwardRef((t,e)=>{const n=C.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return C.createElement(CE,{key:n,innerRef:e,...t})}),db=C.memo(EE),ME=typeof window<"u"?C.useLayoutEffect:C.useEffect,AE=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function TE(t){var e;const[n]=C.useState(()=>new AE(t.editor)),r=wE.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:gE);return ME(()=>n.watch(t.editor),[t.editor,n]),C.useDebugValue(r),r}var fp=process.env.NODE_ENV!=="production",ad=typeof window>"u",NE=ad||!!(typeof window<"u"&&window.next),_E=class ub{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0){if(ad||NE){if(fp)throw new Error("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches.");return null}return this.createEditor()}if(this.options.current.immediatelyRender&&ad&&fp)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)==null?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)==null?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)==null?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)==null?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)==null?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)==null?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)==null?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)==null?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)==null?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)==null?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)==null?void 0:i.call(s,...r)},onDelete:(...r)=>{var s,i;return(i=(s=this.options.current).onDelete)==null?void 0:i.call(s,...r)}};return new tE(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((s,i)=>{var o;return s===((o=n.extensions)==null?void 0:o[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?ub.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function hb(t={},e=[]){const n=C.useRef(t);n.current=t;const[r]=C.useState(()=>new _E(n)),s=ig.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return C.useDebugValue(s),C.useEffect(r.onRender(e)),TE({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var RE=C.createContext({editor:null});RE.Consumer;var fb=C.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),OE=()=>C.useContext(fb),Iu=C.forwardRef((t,e)=>{const{onDragStart:n}=OE(),r=t.as||"div";return m.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function pp(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function mp(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function DE(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function LE(t){if(pp(t)||mp(t))return!0;if(DE(t)){const e=t.type;if(e)return pp(e)||mp(e)}return!1}function IE(){try{if(C.version)return parseInt(C.version.split(".")[0],10)>=19}catch{}return!1}var pb=class{constructor(t,{editor:e,props:n={},as:r="div",className:s=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?tu.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var t;const e=this.component,n=this.props,r=this.editor,s=IE(),i=LE(e),o={...n};o.ref&&!(s||i)&&delete o.ref,!o.ref&&(s||i)&&(o.ref=l=>{this.ref=l}),this.reactElement=m.jsx(e,{...o}),(t=r?.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){this.props={...this.props,...t},this.render()}destroy(){var t;const e=this.editor;(t=e?.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};C.createContext({markViewContentRef:()=>{}});var jE=class extends fE{constructor(t,e,n){if(super(t,e,n),!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}mount(){const t={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:C.createRef()};if(!this.component.displayName){const a=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=a(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement&&(a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper"),a.appendChild(this.contentDOMElement))}},s=this.component,i=C.memo(a=>m.jsx(fb.Provider,{value:r,children:C.createElement(s,a)}));i.displayName="ReactNodeView";let o=this.node.isInline?"span":"div";this.options.as&&(o=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new pb(i,{editor:this.editor,props:t,as:o,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:t,to:e}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(t<=n&&e>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(t,e,n){const r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const s=this.node,i=this.decorations,o=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.options.update({oldNode:s,oldDecorations:i,newNode:t,newDecorations:e,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n})})}return t===this.node&&this.decorations===e&&this.innerDecorations===n||(this.node=t,this.decorations=e,this.innerDecorations=n,r({node:t,decorations:e,innerDecorations:n})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=mi(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function ju(t,e){return n=>n.editor.contentComponent?new jE(t,n,e):{}}const gs=Math.min,Nt=Math.max,sl=Math.round,go=Math.floor,ln=t=>({x:t,y:t}),PE={left:"right",right:"left",bottom:"top",top:"bottom"},BE={start:"end",end:"start"};function gp(t,e,n){return Nt(t,gs(e,n))}function ji(t,e){return typeof t=="function"?t(e):t}function ir(t){return t.split("-")[0]}function Pi(t){return t.split("-")[1]}function mb(t){return t==="x"?"y":"x"}function gb(t){return t==="y"?"height":"width"}const $E=new Set(["top","bottom"]);function En(t){return $E.has(ir(t))?"y":"x"}function yb(t){return mb(En(t))}function HE(t,e,n){n===void 0&&(n=!1);const r=Pi(t),s=yb(t),i=gb(s);let o=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=il(o)),[o,il(o)]}function zE(t){const e=il(t);return[cd(t),e,cd(e)]}function cd(t){return t.replace(/start|end/g,e=>BE[e])}const yp=["left","right"],bp=["right","left"],FE=["top","bottom"],UE=["bottom","top"];function VE(t,e,n){switch(t){case"top":case"bottom":return n?e?bp:yp:e?yp:bp;case"left":case"right":return e?FE:UE;default:return[]}}function WE(t,e,n,r){const s=Pi(t);let i=VE(ir(t),n==="start",r);return s&&(i=i.map(o=>o+"-"+s),e&&(i=i.concat(i.map(cd)))),i}function il(t){return t.replace(/left|right|bottom|top/g,e=>PE[e])}function qE(t){return{top:0,right:0,bottom:0,left:0,...t}}function KE(t){return typeof t!="number"?qE(t):{top:t,right:t,bottom:t,left:t}}function ol(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function xp(t,e,n){let{reference:r,floating:s}=t;const i=En(e),o=yb(e),l=gb(o),a=ir(e),c=i==="y",d=r.x+r.width/2-s.width/2,u=r.y+r.height/2-s.height/2,h=r[l]/2-s[l]/2;let f;switch(a){case"top":f={x:d,y:r.y-s.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:u};break;case"left":f={x:r.x-s.width,y:u};break;default:f={x:r.x,y:r.y}}switch(Pi(e)){case"start":f[o]-=h*(n&&c?-1:1);break;case"end":f[o]+=h*(n&&c?-1:1);break}return f}const GE=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:o}=n,l=i.filter(Boolean),a=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:s}),{x:d,y:u}=xp(c,r,a),h=r,f={},p=0;for(let g=0;g<l.length;g++){const{name:y,fn:b}=l[g],{x:w,y:M,data:S,reset:A}=await b({x:d,y:u,initialPlacement:r,placement:h,strategy:s,middlewareData:f,rects:c,platform:o,elements:{reference:t,floating:e}});d=w??d,u=M??u,f={...f,[y]:{...f[y],...S}},A&&p<=50&&(p++,typeof A=="object"&&(A.placement&&(h=A.placement),A.rects&&(c=A.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:s}):A.rects),{x:d,y:u}=xp(c,h,a)),g=-1)}return{x:d,y:u,placement:h,strategy:s,middlewareData:f}};async function Pu(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:i,rects:o,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:h=!1,padding:f=0}=ji(e,t),p=KE(f),y=l[h?u==="floating"?"reference":"floating":u],b=ol(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(y)))==null||n?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:c,rootBoundary:d,strategy:a})),w=u==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,M=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),S=await(i.isElement==null?void 0:i.isElement(M))?await(i.getScale==null?void 0:i.getScale(M))||{x:1,y:1}:{x:1,y:1},A=ol(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:M,strategy:a}):w);return{top:(b.top-A.top+p.top)/S.y,bottom:(A.bottom-b.bottom+p.bottom)/S.y,left:(b.left-A.left+p.left)/S.x,right:(A.right-b.right+p.right)/S.x}}const JE=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:i,rects:o,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:h,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...y}=ji(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const b=ir(s),w=En(l),M=ir(l)===l,S=await(a.isRTL==null?void 0:a.isRTL(c.floating)),A=h||(M||!g?[il(l)]:zE(l)),x=p!=="none";!h&&x&&A.push(...WE(l,g,p,S));const k=[l,...A],v=await Pu(e,y),T=[];let N=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&T.push(v[b]),u){const I=HE(s,o,S);T.push(v[I[0]],v[I[1]])}if(N=[...N,{placement:s,overflows:T}],!T.every(I=>I<=0)){var H,V;const I=(((H=i.flip)==null?void 0:H.index)||0)+1,j=k[I];if(j&&(!(u==="alignment"?w!==En(j):!1)||N.every(F=>En(F.placement)===w?F.overflows[0]>0:!0)))return{data:{index:I,overflows:N},reset:{placement:j}};let Q=(V=N.filter(ie=>ie.overflows[0]<=0).sort((ie,F)=>ie.overflows[1]-F.overflows[1])[0])==null?void 0:V.placement;if(!Q)switch(f){case"bestFit":{var $;const ie=($=N.filter(F=>{if(x){const ue=En(F.placement);return ue===w||ue==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(ue=>ue>0).reduce((ue,xe)=>ue+xe,0)]).sort((F,ue)=>F[1]-ue[1])[0])==null?void 0:$[0];ie&&(Q=ie);break}case"initialPlacement":Q=l;break}if(s!==Q)return{reset:{placement:Q}}}return{}}}},YE=new Set(["left","top"]);async function XE(t,e){const{placement:n,platform:r,elements:s}=t,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=ir(n),l=Pi(n),a=En(n)==="y",c=YE.has(o)?-1:1,d=i&&a?-1:1,u=ji(e,t);let{mainAxis:h,crossAxis:f,alignmentAxis:p}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof p=="number"&&(f=l==="end"?p*-1:p),a?{x:f*d,y:h*c}:{x:h*c,y:f*d}}const ZE=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:i,placement:o,middlewareData:l}=e,a=await XE(e,t);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+a.x,y:i+a.y,data:{...a,placement:o}}}}},QE=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s}=e,{mainAxis:i=!0,crossAxis:o=!1,limiter:l={fn:y=>{let{x:b,y:w}=y;return{x:b,y:w}}},...a}=ji(t,e),c={x:n,y:r},d=await Pu(e,a),u=En(ir(s)),h=mb(u);let f=c[h],p=c[u];if(i){const y=h==="y"?"top":"left",b=h==="y"?"bottom":"right",w=f+d[y],M=f-d[b];f=gp(w,f,M)}if(o){const y=u==="y"?"top":"left",b=u==="y"?"bottom":"right",w=p+d[y],M=p-d[b];p=gp(w,p,M)}const g=l.fn({...e,[h]:f,[u]:p});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[h]:i,[u]:o}}}}}},eM=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:s,rects:i,platform:o,elements:l}=e,{apply:a=()=>{},...c}=ji(t,e),d=await Pu(e,c),u=ir(s),h=Pi(s),f=En(s)==="y",{width:p,height:g}=i.floating;let y,b;u==="top"||u==="bottom"?(y=u,b=h===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(b=u,y=h==="end"?"top":"bottom");const w=g-d.top-d.bottom,M=p-d.left-d.right,S=gs(g-d[y],w),A=gs(p-d[b],M),x=!e.middlewareData.shift;let k=S,v=A;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(v=M),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(k=w),x&&!h){const N=Nt(d.left,0),H=Nt(d.right,0),V=Nt(d.top,0),$=Nt(d.bottom,0);f?v=p-2*(N!==0||H!==0?N+H:Nt(d.left,d.right)):k=g-2*(V!==0||$!==0?V+$:Nt(d.top,d.bottom))}await a({...e,availableWidth:v,availableHeight:k});const T=await o.getDimensions(l.floating);return p!==T.width||g!==T.height?{reset:{rects:!0}}:{}}}};function ua(){return typeof window<"u"}function Es(t){return bb(t)?(t.nodeName||"").toLowerCase():"#document"}function Ot(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function hn(t){var e;return(e=(bb(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function bb(t){return ua()?t instanceof Node||t instanceof Ot(t).Node:!1}function ut(t){return ua()?t instanceof Element||t instanceof Ot(t).Element:!1}function un(t){return ua()?t instanceof HTMLElement||t instanceof Ot(t).HTMLElement:!1}function wp(t){return!ua()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Ot(t).ShadowRoot}const tM=new Set(["inline","contents"]);function Bi(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=Jt(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!tM.has(s)}const nM=new Set(["table","td","th"]);function rM(t){return nM.has(Es(t))}const sM=[":popover-open",":modal"];function ha(t){return sM.some(e=>{try{return t.matches(e)}catch{return!1}})}const iM=["transform","translate","scale","rotate","perspective"],oM=["transform","translate","scale","rotate","perspective","filter"],lM=["paint","layout","strict","content"];function Bu(t){const e=$u(),n=ut(t)?Jt(t):t;return iM.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||oM.some(r=>(n.willChange||"").includes(r))||lM.some(r=>(n.contain||"").includes(r))}function aM(t){let e=or(t);for(;un(e)&&!ys(e);){if(Bu(e))return e;if(ha(e))return null;e=or(e)}return null}function $u(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const cM=new Set(["html","body","#document"]);function ys(t){return cM.has(Es(t))}function Jt(t){return Ot(t).getComputedStyle(t)}function fa(t){return ut(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function or(t){if(Es(t)==="html")return t;const e=t.assignedSlot||t.parentNode||wp(t)&&t.host||hn(t);return wp(e)?e.host:e}function xb(t){const e=or(t);return ys(e)?t.ownerDocument?t.ownerDocument.body:t.body:un(e)&&Bi(e)?e:xb(e)}function gi(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const s=xb(t),i=s===((r=t.ownerDocument)==null?void 0:r.body),o=Ot(s);if(i){const l=dd(o);return e.concat(o,o.visualViewport||[],Bi(s)?s:[],l&&n?gi(l):[])}return e.concat(s,gi(s,[],n))}function dd(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function wb(t){const e=Jt(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=un(t),i=s?t.offsetWidth:n,o=s?t.offsetHeight:r,l=sl(n)!==i||sl(r)!==o;return l&&(n=i,r=o),{width:n,height:r,$:l}}function Hu(t){return ut(t)?t:t.contextElement}function is(t){const e=Hu(t);if(!un(e))return ln(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:i}=wb(e);let o=(i?sl(n.width):n.width)/r,l=(i?sl(n.height):n.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const dM=ln(0);function kb(t){const e=Ot(t);return!$u()||!e.visualViewport?dM:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function uM(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Ot(t)?!1:e}function Ir(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),i=Hu(t);let o=ln(1);e&&(r?ut(r)&&(o=is(r)):o=is(t));const l=uM(i,n,r)?kb(i):ln(0);let a=(s.left+l.x)/o.x,c=(s.top+l.y)/o.y,d=s.width/o.x,u=s.height/o.y;if(i){const h=Ot(i),f=r&&ut(r)?Ot(r):r;let p=h,g=dd(p);for(;g&&r&&f!==p;){const y=is(g),b=g.getBoundingClientRect(),w=Jt(g),M=b.left+(g.clientLeft+parseFloat(w.paddingLeft))*y.x,S=b.top+(g.clientTop+parseFloat(w.paddingTop))*y.y;a*=y.x,c*=y.y,d*=y.x,u*=y.y,a+=M,c+=S,p=Ot(g),g=dd(p)}}return ol({width:d,height:u,x:a,y:c})}function pa(t,e){const n=fa(t).scrollLeft;return e?e.left+n:Ir(hn(t)).left+n}function vb(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-pa(t,n),s=n.top+e.scrollTop;return{x:r,y:s}}function hM(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const i=s==="fixed",o=hn(r),l=e?ha(e.floating):!1;if(r===o||l&&i)return n;let a={scrollLeft:0,scrollTop:0},c=ln(1);const d=ln(0),u=un(r);if((u||!u&&!i)&&((Es(r)!=="body"||Bi(o))&&(a=fa(r)),un(r))){const f=Ir(r);c=is(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const h=o&&!u&&!i?vb(o,a):ln(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+d.x+h.x,y:n.y*c.y-a.scrollTop*c.y+d.y+h.y}}function fM(t){return Array.from(t.getClientRects())}function pM(t){const e=hn(t),n=fa(t),r=t.ownerDocument.body,s=Nt(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=Nt(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+pa(t);const l=-n.scrollTop;return Jt(r).direction==="rtl"&&(o+=Nt(e.clientWidth,r.clientWidth)-s),{width:s,height:i,x:o,y:l}}const kp=25;function mM(t,e){const n=Ot(t),r=hn(t),s=n.visualViewport;let i=r.clientWidth,o=r.clientHeight,l=0,a=0;if(s){i=s.width,o=s.height;const d=$u();(!d||d&&e==="fixed")&&(l=s.offsetLeft,a=s.offsetTop)}const c=pa(r);if(c<=0){const d=r.ownerDocument,u=d.body,h=getComputedStyle(u),f=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,p=Math.abs(r.clientWidth-u.clientWidth-f);p<=kp&&(i-=p)}else c<=kp&&(i+=c);return{width:i,height:o,x:l,y:a}}const gM=new Set(["absolute","fixed"]);function yM(t,e){const n=Ir(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,i=un(t)?is(t):ln(1),o=t.clientWidth*i.x,l=t.clientHeight*i.y,a=s*i.x,c=r*i.y;return{width:o,height:l,x:a,y:c}}function vp(t,e,n){let r;if(e==="viewport")r=mM(t,n);else if(e==="document")r=pM(hn(t));else if(ut(e))r=yM(e,n);else{const s=kb(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return ol(r)}function Sb(t,e){const n=or(t);return n===e||!ut(n)||ys(n)?!1:Jt(n).position==="fixed"||Sb(n,e)}function bM(t,e){const n=e.get(t);if(n)return n;let r=gi(t,[],!1).filter(l=>ut(l)&&Es(l)!=="body"),s=null;const i=Jt(t).position==="fixed";let o=i?or(t):t;for(;ut(o)&&!ys(o);){const l=Jt(o),a=Bu(o);!a&&l.position==="fixed"&&(s=null),(i?!a&&!s:!a&&l.position==="static"&&!!s&&gM.has(s.position)||Bi(o)&&!a&&Sb(t,o))?r=r.filter(d=>d!==o):s=l,o=or(o)}return e.set(t,r),r}function xM(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const o=[...n==="clippingAncestors"?ha(e)?[]:bM(e,this._c):[].concat(n),r],l=o[0],a=o.reduce((c,d)=>{const u=vp(e,d,s);return c.top=Nt(u.top,c.top),c.right=gs(u.right,c.right),c.bottom=gs(u.bottom,c.bottom),c.left=Nt(u.left,c.left),c},vp(e,l,s));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function wM(t){const{width:e,height:n}=wb(t);return{width:e,height:n}}function kM(t,e,n){const r=un(e),s=hn(e),i=n==="fixed",o=Ir(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const a=ln(0);function c(){a.x=pa(s)}if(r||!r&&!i)if((Es(e)!=="body"||Bi(s))&&(l=fa(e)),r){const f=Ir(e,!0,i,e);a.x=f.x+e.clientLeft,a.y=f.y+e.clientTop}else s&&c();i&&!r&&s&&c();const d=s&&!r&&!i?vb(s,l):ln(0),u=o.left+l.scrollLeft-a.x-d.x,h=o.top+l.scrollTop-a.y-d.y;return{x:u,y:h,width:o.width,height:o.height}}function pc(t){return Jt(t).position==="static"}function Sp(t,e){if(!un(t)||Jt(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return hn(t)===n&&(n=n.ownerDocument.body),n}function Cb(t,e){const n=Ot(t);if(ha(t))return n;if(!un(t)){let s=or(t);for(;s&&!ys(s);){if(ut(s)&&!pc(s))return s;s=or(s)}return n}let r=Sp(t,e);for(;r&&rM(r)&&pc(r);)r=Sp(r,e);return r&&ys(r)&&pc(r)&&!Bu(r)?n:r||aM(t)||n}const vM=async function(t){const e=this.getOffsetParent||Cb,n=this.getDimensions,r=await n(t.floating);return{reference:kM(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function SM(t){return Jt(t).direction==="rtl"}const CM={convertOffsetParentRelativeRectToViewportRelativeRect:hM,getDocumentElement:hn,getClippingRect:xM,getOffsetParent:Cb,getElementRects:vM,getClientRects:fM,getDimensions:wM,getScale:is,isElement:ut,isRTL:SM};function Eb(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function EM(t,e){let n=null,r;const s=hn(t);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function o(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),i();const c=t.getBoundingClientRect(),{left:d,top:u,width:h,height:f}=c;if(l||e(),!h||!f)return;const p=go(u),g=go(s.clientWidth-(d+h)),y=go(s.clientHeight-(u+f)),b=go(d),M={rootMargin:-p+"px "+-g+"px "+-y+"px "+-b+"px",threshold:Nt(0,gs(1,a))||1};let S=!0;function A(x){const k=x[0].intersectionRatio;if(k!==a){if(!S)return o();k?o(!1,k):r=setTimeout(()=>{o(!1,1e-7)},1e3)}k===1&&!Eb(c,t.getBoundingClientRect())&&o(),S=!1}try{n=new IntersectionObserver(A,{...M,root:s.ownerDocument})}catch{n=new IntersectionObserver(A,M)}n.observe(t)}return o(!0),i}function Ms(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,c=Hu(t),d=s||i?[...c?gi(c):[],...gi(e)]:[];d.forEach(b=>{s&&b.addEventListener("scroll",n,{passive:!0}),i&&b.addEventListener("resize",n)});const u=c&&l?EM(c,n):null;let h=-1,f=null;o&&(f=new ResizeObserver(b=>{let[w]=b;w&&w.target===c&&f&&(f.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var M;(M=f)==null||M.observe(e)})),n()}),c&&!a&&f.observe(c),f.observe(e));let p,g=a?Ir(t):null;a&&y();function y(){const b=Ir(t);g&&!Eb(g,b)&&n(),g=b,p=requestAnimationFrame(y)}return n(),()=>{var b;d.forEach(w=>{s&&w.removeEventListener("scroll",n),i&&w.removeEventListener("resize",n)}),u?.(),(b=f)==null||b.disconnect(),f=null,a&&cancelAnimationFrame(p)}}const zu=ZE,Mb=QE,Ab=JE,Tb=eM,Fu=(t,e,n)=>{const r=new Map,s={platform:CM,...n},i={...s.platform,_c:r};return GE(t,e,{...s,platform:i})};var ll=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},MM=/^\s*>\s$/,Nb=De.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return ll("blockquote",{...be(this.options.HTMLAttributes,t),children:ll("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=[];return t.content.forEach(s=>{const o=e.renderChildren(s).split(`
|
|
104
|
+
`)}function hE(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,o=t;s.descendants((l,a)=>{const c=i.mapping.map(a),d=i.mapping.map(a)+l.nodeSize;let u=null;if(l.marks.forEach(f=>{if(f!==o)return!1;u=f}),!u)return;let h=!1;if(Object.keys(n).forEach(f=>{n[f]!==u.attrs[f]&&(h=!0)}),h){const f=t.type.create({...t.attrs,...n});i.removeMark(c,d,t.type),i.addMark(c,d,f)}}),i.docChanged&&e.view.dispatch(i)}var Oe=class cb extends Ru{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new cb(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},fE=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,s,i,o,l;const{view:a}=this.editor,c=t.target,d=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(c)||!d)return;let u=0,h=0;if(this.dom!==d){const w=this.dom.getBoundingClientRect(),M=d.getBoundingClientRect(),S=(s=t.offsetX)!=null?s:(r=t.nativeEvent)==null?void 0:r.offsetX,A=(o=t.offsetY)!=null?o:(i=t.nativeEvent)==null?void 0:i.offsetY;u=M.x-w.x+S,h=M.y-w.y+A}const f=this.dom.cloneNode(!0);try{const w=this.dom.getBoundingClientRect();f.style.width=`${Math.round(w.width)}px`,f.style.height=`${Math.round(w.height)}px`,f.style.boxSizing="border-box",f.style.pointerEvents="none"}catch{}let p=null;try{p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(f),document.body.appendChild(p),(l=t.dataTransfer)==null||l.setDragImage(f,u,h)}finally{p&&setTimeout(()=>{try{p?.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const y=q.create(a.state.doc,g),b=a.state.tr.setSelection(y);a.dispatch(b)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const s=t.type.startsWith("drag"),i=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!i&&!s)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,d=q.isSelectable(this.node),u=t.type==="copy",h=t.type==="paste",f=t.type==="cut",p=t.type==="mousedown";if(!c&&d&&s&&t.target===this.dom&&t.preventDefault(),c&&s&&!a&&t.target===this.dom)return t.preventDefault(),!1;if(c&&l&&!a&&p){const g=n.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(a||i||u||h||f||p&&d)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(la()||Iy())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function sr(t){return new qC({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const i=we(t.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=n.to;if(l){const d=a.search(/\S/),u=n.from+a.indexOf(l),h=u+l.length;if(_u(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(y=>y===t.type&&y!==p.mark.type)).filter(p=>p.to>u).length)return null;h<n.to&&o.delete(h,n.to),u>n.from&&o.delete(n.from+d,u),c=n.from+d+l.length,o.addMark(n.from+d,c,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}var uc,cp;function pE(){return cp||(cp=1,uc=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,s,i;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(s=r;s--!==0;)if(!t(e[s],n[s]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(s of e.entries())if(!n.has(s[0]))return!1;for(s of e.entries())if(!t(s[1],n.get(s[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(s of e.entries())if(!n.has(s[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(s=r;s--!==0;)if(e[s]!==n[s])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(n).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[s]))return!1;for(s=r;s--!==0;){var o=i[s];if(!(o==="_owner"&&e.$$typeof)&&!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}),uc}var mE=pE();const gE=sg(mE);var mo={exports:{}},hc={};var dp;function yE(){if(dp)return hc;dp=1;var t=C,e=nu();function n(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,i=t.useRef,o=t.useEffect,l=t.useMemo,a=t.useDebugValue;return hc.useSyncExternalStoreWithSelector=function(c,d,u,h,f){var p=i(null);if(p.current===null){var g={hasValue:!1,value:null};p.current=g}else g=p.current;p=l(function(){function b(x){if(!w){if(w=!0,M=x,x=h(x),f!==void 0&&g.hasValue){var k=g.value;if(f(k,x))return S=k}return S=x}if(k=S,r(M,x))return k;var v=h(x);return f!==void 0&&f(k,v)?(M=x,k):(M=x,S=v)}var w=!1,M,S,A=u===void 0?null:u;return[function(){return b(d())},A===null?void 0:function(){return b(A())}]},[d,u,h,f]);var y=s(c,p[0],p[1]);return o(function(){g.hasValue=!0,g.value=y},[y]),a(y),y},hc}var fc={};var up;function bE(){return up||(up=1,process.env.NODE_ENV!=="production"&&(function(){function t(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var e=C,n=nu(),r=typeof Object.is=="function"?Object.is:t,s=n.useSyncExternalStore,i=e.useRef,o=e.useEffect,l=e.useMemo,a=e.useDebugValue;fc.useSyncExternalStoreWithSelector=function(c,d,u,h,f){var p=i(null);if(p.current===null){var g={hasValue:!1,value:null};p.current=g}else g=p.current;p=l(function(){function b(x){if(!w){if(w=!0,M=x,x=h(x),f!==void 0&&g.hasValue){var k=g.value;if(f(k,x))return S=k}return S=x}if(k=S,r(M,x))return k;var v=h(x);return f!==void 0&&f(k,v)?(M=x,k):(M=x,S=v)}var w=!1,M,S,A=u===void 0?null:u;return[function(){return b(d())},A===null?void 0:function(){return b(A())}]},[d,u,h,f]);var y=s(c,p[0],p[1]);return o(function(){g.hasValue=!0,g.value=y},[y]),a(y),y},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),fc}var hp;function xE(){return hp||(hp=1,process.env.NODE_ENV==="production"?mo.exports=yE():mo.exports=bE()),mo.exports}var wE=xE(),kE=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},vE=({contentComponent:t})=>{const e=ig.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return m.jsx(m.Fragment,{children:Object.values(e)})};function SE(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:tu.createPortal(r.reactElement,r.element,n)},t.forEach(s=>s())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(s=>s())}}}var CE=class extends C.Component{constructor(t){var e;super(t),this.editorContentRef=C.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(t.view.dom),t.setOptions({element:e}),t.contentComponent=SE(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return m.jsxs(m.Fragment,{children:[m.jsx("div",{ref:kE(e,this.editorContentRef),...n}),t?.contentComponent&&m.jsx(vE,{contentComponent:t.contentComponent})]})}},EE=C.forwardRef((t,e)=>{const n=C.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return C.createElement(CE,{key:n,innerRef:e,...t})}),db=C.memo(EE),ME=typeof window<"u"?C.useLayoutEffect:C.useEffect,AE=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function TE(t){var e;const[n]=C.useState(()=>new AE(t.editor)),r=wE.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:gE);return ME(()=>n.watch(t.editor),[t.editor,n]),C.useDebugValue(r),r}var fp=process.env.NODE_ENV!=="production",ad=typeof window>"u",NE=ad||!!(typeof window<"u"&&window.next),_E=class ub{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0){if(ad||NE){if(fp)throw new Error("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches.");return null}return this.createEditor()}if(this.options.current.immediatelyRender&&ad&&fp)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)==null?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)==null?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)==null?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)==null?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)==null?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)==null?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)==null?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)==null?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)==null?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)==null?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)==null?void 0:i.call(s,...r)},onDelete:(...r)=>{var s,i;return(i=(s=this.options.current).onDelete)==null?void 0:i.call(s,...r)}};return new tE(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((s,i)=>{var o;return s===((o=n.extensions)==null?void 0:o[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?ub.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function hb(t={},e=[]){const n=C.useRef(t);n.current=t;const[r]=C.useState(()=>new _E(n)),s=ig.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return C.useDebugValue(s),C.useEffect(r.onRender(e)),TE({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var RE=C.createContext({editor:null});RE.Consumer;var fb=C.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),OE=()=>C.useContext(fb),Iu=C.forwardRef((t,e)=>{const{onDragStart:n}=OE(),r=t.as||"div";return m.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function pp(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function mp(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function DE(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function LE(t){if(pp(t)||mp(t))return!0;if(DE(t)){const e=t.type;if(e)return pp(e)||mp(e)}return!1}function IE(){try{if(C.version)return parseInt(C.version.split(".")[0],10)>=19}catch{}return!1}var pb=class{constructor(t,{editor:e,props:n={},as:r="div",className:s=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?tu.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var t;const e=this.component,n=this.props,r=this.editor,s=IE(),i=LE(e),o={...n};o.ref&&!(s||i)&&delete o.ref,!o.ref&&(s||i)&&(o.ref=l=>{this.ref=l}),this.reactElement=m.jsx(e,{...o}),(t=r?.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){this.props={...this.props,...t},this.render()}destroy(){var t;const e=this.editor;(t=e?.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};C.createContext({markViewContentRef:()=>{}});var jE=class extends fE{constructor(t,e,n){if(super(t,e,n),!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}mount(){const t={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:C.createRef()};if(!this.component.displayName){const a=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=a(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement&&(a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper"),a.appendChild(this.contentDOMElement))}},s=this.component,i=C.memo(a=>m.jsx(fb.Provider,{value:r,children:C.createElement(s,a)}));i.displayName="ReactNodeView";let o=this.node.isInline?"span":"div";this.options.as&&(o=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new pb(i,{editor:this.editor,props:t,as:o,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:t,to:e}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(t<=n&&e>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(t,e,n){const r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const s=this.node,i=this.decorations,o=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.options.update({oldNode:s,oldDecorations:i,newNode:t,newDecorations:e,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n})})}return t===this.node&&this.decorations===e&&this.innerDecorations===n||(this.node=t,this.decorations=e,this.innerDecorations=n,r({node:t,decorations:e,innerDecorations:n})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=mi(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function ju(t,e){return n=>n.editor.contentComponent?new jE(t,n,e):{}}const gs=Math.min,Nt=Math.max,sl=Math.round,go=Math.floor,ln=t=>({x:t,y:t}),PE={left:"right",right:"left",bottom:"top",top:"bottom"},BE={start:"end",end:"start"};function gp(t,e,n){return Nt(t,gs(e,n))}function ji(t,e){return typeof t=="function"?t(e):t}function ir(t){return t.split("-")[0]}function Pi(t){return t.split("-")[1]}function mb(t){return t==="x"?"y":"x"}function gb(t){return t==="y"?"height":"width"}const $E=new Set(["top","bottom"]);function En(t){return $E.has(ir(t))?"y":"x"}function yb(t){return mb(En(t))}function HE(t,e,n){n===void 0&&(n=!1);const r=Pi(t),s=yb(t),i=gb(s);let o=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=il(o)),[o,il(o)]}function zE(t){const e=il(t);return[cd(t),e,cd(e)]}function cd(t){return t.replace(/start|end/g,e=>BE[e])}const yp=["left","right"],bp=["right","left"],FE=["top","bottom"],UE=["bottom","top"];function VE(t,e,n){switch(t){case"top":case"bottom":return n?e?bp:yp:e?yp:bp;case"left":case"right":return e?FE:UE;default:return[]}}function WE(t,e,n,r){const s=Pi(t);let i=VE(ir(t),n==="start",r);return s&&(i=i.map(o=>o+"-"+s),e&&(i=i.concat(i.map(cd)))),i}function il(t){return t.replace(/left|right|bottom|top/g,e=>PE[e])}function qE(t){return{top:0,right:0,bottom:0,left:0,...t}}function KE(t){return typeof t!="number"?qE(t):{top:t,right:t,bottom:t,left:t}}function ol(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function xp(t,e,n){let{reference:r,floating:s}=t;const i=En(e),o=yb(e),l=gb(o),a=ir(e),c=i==="y",d=r.x+r.width/2-s.width/2,u=r.y+r.height/2-s.height/2,h=r[l]/2-s[l]/2;let f;switch(a){case"top":f={x:d,y:r.y-s.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:u};break;case"left":f={x:r.x-s.width,y:u};break;default:f={x:r.x,y:r.y}}switch(Pi(e)){case"start":f[o]-=h*(n&&c?-1:1);break;case"end":f[o]+=h*(n&&c?-1:1);break}return f}const GE=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:o}=n,l=i.filter(Boolean),a=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:s}),{x:d,y:u}=xp(c,r,a),h=r,f={},p=0;for(let g=0;g<l.length;g++){const{name:y,fn:b}=l[g],{x:w,y:M,data:S,reset:A}=await b({x:d,y:u,initialPlacement:r,placement:h,strategy:s,middlewareData:f,rects:c,platform:o,elements:{reference:t,floating:e}});d=w??d,u=M??u,f={...f,[y]:{...f[y],...S}},A&&p<=50&&(p++,typeof A=="object"&&(A.placement&&(h=A.placement),A.rects&&(c=A.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:s}):A.rects),{x:d,y:u}=xp(c,h,a)),g=-1)}return{x:d,y:u,placement:h,strategy:s,middlewareData:f}};async function Pu(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:i,rects:o,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:h=!1,padding:f=0}=ji(e,t),p=KE(f),y=l[h?u==="floating"?"reference":"floating":u],b=ol(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(y)))==null||n?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:c,rootBoundary:d,strategy:a})),w=u==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,M=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),S=await(i.isElement==null?void 0:i.isElement(M))?await(i.getScale==null?void 0:i.getScale(M))||{x:1,y:1}:{x:1,y:1},A=ol(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:M,strategy:a}):w);return{top:(b.top-A.top+p.top)/S.y,bottom:(A.bottom-b.bottom+p.bottom)/S.y,left:(b.left-A.left+p.left)/S.x,right:(A.right-b.right+p.right)/S.x}}const JE=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:i,rects:o,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:h,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...y}=ji(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const b=ir(s),w=En(l),M=ir(l)===l,S=await(a.isRTL==null?void 0:a.isRTL(c.floating)),A=h||(M||!g?[il(l)]:zE(l)),x=p!=="none";!h&&x&&A.push(...WE(l,g,p,S));const k=[l,...A],v=await Pu(e,y),T=[];let N=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&T.push(v[b]),u){const I=HE(s,o,S);T.push(v[I[0]],v[I[1]])}if(N=[...N,{placement:s,overflows:T}],!T.every(I=>I<=0)){var H,V;const I=(((H=i.flip)==null?void 0:H.index)||0)+1,j=k[I];if(j&&(!(u==="alignment"?w!==En(j):!1)||N.every(F=>En(F.placement)===w?F.overflows[0]>0:!0)))return{data:{index:I,overflows:N},reset:{placement:j}};let Q=(V=N.filter(ie=>ie.overflows[0]<=0).sort((ie,F)=>ie.overflows[1]-F.overflows[1])[0])==null?void 0:V.placement;if(!Q)switch(f){case"bestFit":{var $;const ie=($=N.filter(F=>{if(x){const ue=En(F.placement);return ue===w||ue==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(ue=>ue>0).reduce((ue,xe)=>ue+xe,0)]).sort((F,ue)=>F[1]-ue[1])[0])==null?void 0:$[0];ie&&(Q=ie);break}case"initialPlacement":Q=l;break}if(s!==Q)return{reset:{placement:Q}}}return{}}}},YE=new Set(["left","top"]);async function XE(t,e){const{placement:n,platform:r,elements:s}=t,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=ir(n),l=Pi(n),a=En(n)==="y",c=YE.has(o)?-1:1,d=i&&a?-1:1,u=ji(e,t);let{mainAxis:h,crossAxis:f,alignmentAxis:p}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof p=="number"&&(f=l==="end"?p*-1:p),a?{x:f*d,y:h*c}:{x:h*c,y:f*d}}const ZE=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:i,placement:o,middlewareData:l}=e,a=await XE(e,t);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+a.x,y:i+a.y,data:{...a,placement:o}}}}},QE=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s}=e,{mainAxis:i=!0,crossAxis:o=!1,limiter:l={fn:y=>{let{x:b,y:w}=y;return{x:b,y:w}}},...a}=ji(t,e),c={x:n,y:r},d=await Pu(e,a),u=En(ir(s)),h=mb(u);let f=c[h],p=c[u];if(i){const y=h==="y"?"top":"left",b=h==="y"?"bottom":"right",w=f+d[y],M=f-d[b];f=gp(w,f,M)}if(o){const y=u==="y"?"top":"left",b=u==="y"?"bottom":"right",w=p+d[y],M=p-d[b];p=gp(w,p,M)}const g=l.fn({...e,[h]:f,[u]:p});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[h]:i,[u]:o}}}}}},eM=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:s,rects:i,platform:o,elements:l}=e,{apply:a=()=>{},...c}=ji(t,e),d=await Pu(e,c),u=ir(s),h=Pi(s),f=En(s)==="y",{width:p,height:g}=i.floating;let y,b;u==="top"||u==="bottom"?(y=u,b=h===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(b=u,y=h==="end"?"top":"bottom");const w=g-d.top-d.bottom,M=p-d.left-d.right,S=gs(g-d[y],w),A=gs(p-d[b],M),x=!e.middlewareData.shift;let k=S,v=A;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(v=M),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(k=w),x&&!h){const N=Nt(d.left,0),H=Nt(d.right,0),V=Nt(d.top,0),$=Nt(d.bottom,0);f?v=p-2*(N!==0||H!==0?N+H:Nt(d.left,d.right)):k=g-2*(V!==0||$!==0?V+$:Nt(d.top,d.bottom))}await a({...e,availableWidth:v,availableHeight:k});const T=await o.getDimensions(l.floating);return p!==T.width||g!==T.height?{reset:{rects:!0}}:{}}}};function ua(){return typeof window<"u"}function Es(t){return bb(t)?(t.nodeName||"").toLowerCase():"#document"}function Ot(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function hn(t){var e;return(e=(bb(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function bb(t){return ua()?t instanceof Node||t instanceof Ot(t).Node:!1}function ut(t){return ua()?t instanceof Element||t instanceof Ot(t).Element:!1}function un(t){return ua()?t instanceof HTMLElement||t instanceof Ot(t).HTMLElement:!1}function wp(t){return!ua()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Ot(t).ShadowRoot}const tM=new Set(["inline","contents"]);function Bi(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=Jt(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!tM.has(s)}const nM=new Set(["table","td","th"]);function rM(t){return nM.has(Es(t))}const sM=[":popover-open",":modal"];function ha(t){return sM.some(e=>{try{return t.matches(e)}catch{return!1}})}const iM=["transform","translate","scale","rotate","perspective"],oM=["transform","translate","scale","rotate","perspective","filter"],lM=["paint","layout","strict","content"];function Bu(t){const e=$u(),n=ut(t)?Jt(t):t;return iM.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||oM.some(r=>(n.willChange||"").includes(r))||lM.some(r=>(n.contain||"").includes(r))}function aM(t){let e=or(t);for(;un(e)&&!ys(e);){if(Bu(e))return e;if(ha(e))return null;e=or(e)}return null}function $u(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const cM=new Set(["html","body","#document"]);function ys(t){return cM.has(Es(t))}function Jt(t){return Ot(t).getComputedStyle(t)}function fa(t){return ut(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function or(t){if(Es(t)==="html")return t;const e=t.assignedSlot||t.parentNode||wp(t)&&t.host||hn(t);return wp(e)?e.host:e}function xb(t){const e=or(t);return ys(e)?t.ownerDocument?t.ownerDocument.body:t.body:un(e)&&Bi(e)?e:xb(e)}function gi(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const s=xb(t),i=s===((r=t.ownerDocument)==null?void 0:r.body),o=Ot(s);if(i){const l=dd(o);return e.concat(o,o.visualViewport||[],Bi(s)?s:[],l&&n?gi(l):[])}return e.concat(s,gi(s,[],n))}function dd(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function wb(t){const e=Jt(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=un(t),i=s?t.offsetWidth:n,o=s?t.offsetHeight:r,l=sl(n)!==i||sl(r)!==o;return l&&(n=i,r=o),{width:n,height:r,$:l}}function Hu(t){return ut(t)?t:t.contextElement}function is(t){const e=Hu(t);if(!un(e))return ln(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:i}=wb(e);let o=(i?sl(n.width):n.width)/r,l=(i?sl(n.height):n.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const dM=ln(0);function kb(t){const e=Ot(t);return!$u()||!e.visualViewport?dM:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function uM(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Ot(t)?!1:e}function Ir(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),i=Hu(t);let o=ln(1);e&&(r?ut(r)&&(o=is(r)):o=is(t));const l=uM(i,n,r)?kb(i):ln(0);let a=(s.left+l.x)/o.x,c=(s.top+l.y)/o.y,d=s.width/o.x,u=s.height/o.y;if(i){const h=Ot(i),f=r&&ut(r)?Ot(r):r;let p=h,g=dd(p);for(;g&&r&&f!==p;){const y=is(g),b=g.getBoundingClientRect(),w=Jt(g),M=b.left+(g.clientLeft+parseFloat(w.paddingLeft))*y.x,S=b.top+(g.clientTop+parseFloat(w.paddingTop))*y.y;a*=y.x,c*=y.y,d*=y.x,u*=y.y,a+=M,c+=S,p=Ot(g),g=dd(p)}}return ol({width:d,height:u,x:a,y:c})}function pa(t,e){const n=fa(t).scrollLeft;return e?e.left+n:Ir(hn(t)).left+n}function vb(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-pa(t,n),s=n.top+e.scrollTop;return{x:r,y:s}}function hM(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const i=s==="fixed",o=hn(r),l=e?ha(e.floating):!1;if(r===o||l&&i)return n;let a={scrollLeft:0,scrollTop:0},c=ln(1);const d=ln(0),u=un(r);if((u||!u&&!i)&&((Es(r)!=="body"||Bi(o))&&(a=fa(r)),un(r))){const f=Ir(r);c=is(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const h=o&&!u&&!i?vb(o,a):ln(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+d.x+h.x,y:n.y*c.y-a.scrollTop*c.y+d.y+h.y}}function fM(t){return Array.from(t.getClientRects())}function pM(t){const e=hn(t),n=fa(t),r=t.ownerDocument.body,s=Nt(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=Nt(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+pa(t);const l=-n.scrollTop;return Jt(r).direction==="rtl"&&(o+=Nt(e.clientWidth,r.clientWidth)-s),{width:s,height:i,x:o,y:l}}const kp=25;function mM(t,e){const n=Ot(t),r=hn(t),s=n.visualViewport;let i=r.clientWidth,o=r.clientHeight,l=0,a=0;if(s){i=s.width,o=s.height;const d=$u();(!d||d&&e==="fixed")&&(l=s.offsetLeft,a=s.offsetTop)}const c=pa(r);if(c<=0){const d=r.ownerDocument,u=d.body,h=getComputedStyle(u),f=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,p=Math.abs(r.clientWidth-u.clientWidth-f);p<=kp&&(i-=p)}else c<=kp&&(i+=c);return{width:i,height:o,x:l,y:a}}const gM=new Set(["absolute","fixed"]);function yM(t,e){const n=Ir(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,i=un(t)?is(t):ln(1),o=t.clientWidth*i.x,l=t.clientHeight*i.y,a=s*i.x,c=r*i.y;return{width:o,height:l,x:a,y:c}}function vp(t,e,n){let r;if(e==="viewport")r=mM(t,n);else if(e==="document")r=pM(hn(t));else if(ut(e))r=yM(e,n);else{const s=kb(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return ol(r)}function Sb(t,e){const n=or(t);return n===e||!ut(n)||ys(n)?!1:Jt(n).position==="fixed"||Sb(n,e)}function bM(t,e){const n=e.get(t);if(n)return n;let r=gi(t,[],!1).filter(l=>ut(l)&&Es(l)!=="body"),s=null;const i=Jt(t).position==="fixed";let o=i?or(t):t;for(;ut(o)&&!ys(o);){const l=Jt(o),a=Bu(o);!a&&l.position==="fixed"&&(s=null),(i?!a&&!s:!a&&l.position==="static"&&!!s&&gM.has(s.position)||Bi(o)&&!a&&Sb(t,o))?r=r.filter(d=>d!==o):s=l,o=or(o)}return e.set(t,r),r}function xM(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const o=[...n==="clippingAncestors"?ha(e)?[]:bM(e,this._c):[].concat(n),r],l=o[0],a=o.reduce((c,d)=>{const u=vp(e,d,s);return c.top=Nt(u.top,c.top),c.right=gs(u.right,c.right),c.bottom=gs(u.bottom,c.bottom),c.left=Nt(u.left,c.left),c},vp(e,l,s));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function wM(t){const{width:e,height:n}=wb(t);return{width:e,height:n}}function kM(t,e,n){const r=un(e),s=hn(e),i=n==="fixed",o=Ir(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const a=ln(0);function c(){a.x=pa(s)}if(r||!r&&!i)if((Es(e)!=="body"||Bi(s))&&(l=fa(e)),r){const f=Ir(e,!0,i,e);a.x=f.x+e.clientLeft,a.y=f.y+e.clientTop}else s&&c();i&&!r&&s&&c();const d=s&&!r&&!i?vb(s,l):ln(0),u=o.left+l.scrollLeft-a.x-d.x,h=o.top+l.scrollTop-a.y-d.y;return{x:u,y:h,width:o.width,height:o.height}}function pc(t){return Jt(t).position==="static"}function Sp(t,e){if(!un(t)||Jt(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return hn(t)===n&&(n=n.ownerDocument.body),n}function Cb(t,e){const n=Ot(t);if(ha(t))return n;if(!un(t)){let s=or(t);for(;s&&!ys(s);){if(ut(s)&&!pc(s))return s;s=or(s)}return n}let r=Sp(t,e);for(;r&&rM(r)&&pc(r);)r=Sp(r,e);return r&&ys(r)&&pc(r)&&!Bu(r)?n:r||aM(t)||n}const vM=async function(t){const e=this.getOffsetParent||Cb,n=this.getDimensions,r=await n(t.floating);return{reference:kM(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function SM(t){return Jt(t).direction==="rtl"}const CM={convertOffsetParentRelativeRectToViewportRelativeRect:hM,getDocumentElement:hn,getClippingRect:xM,getOffsetParent:Cb,getElementRects:vM,getClientRects:fM,getDimensions:wM,getScale:is,isElement:ut,isRTL:SM};function Eb(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function EM(t,e){let n=null,r;const s=hn(t);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function o(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),i();const c=t.getBoundingClientRect(),{left:d,top:u,width:h,height:f}=c;if(l||e(),!h||!f)return;const p=go(u),g=go(s.clientWidth-(d+h)),y=go(s.clientHeight-(u+f)),b=go(d),M={rootMargin:-p+"px "+-g+"px "+-y+"px "+-b+"px",threshold:Nt(0,gs(1,a))||1};let S=!0;function A(x){const k=x[0].intersectionRatio;if(k!==a){if(!S)return o();k?o(!1,k):r=setTimeout(()=>{o(!1,1e-7)},1e3)}k===1&&!Eb(c,t.getBoundingClientRect())&&o(),S=!1}try{n=new IntersectionObserver(A,{...M,root:s.ownerDocument})}catch{n=new IntersectionObserver(A,M)}n.observe(t)}return o(!0),i}function Ms(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,c=Hu(t),d=s||i?[...c?gi(c):[],...gi(e)]:[];d.forEach(b=>{s&&b.addEventListener("scroll",n,{passive:!0}),i&&b.addEventListener("resize",n)});const u=c&&l?EM(c,n):null;let h=-1,f=null;o&&(f=new ResizeObserver(b=>{let[w]=b;w&&w.target===c&&f&&(f.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var M;(M=f)==null||M.observe(e)})),n()}),c&&!a&&f.observe(c),f.observe(e));let p,g=a?Ir(t):null;a&&y();function y(){const b=Ir(t);g&&!Eb(g,b)&&n(),g=b,p=requestAnimationFrame(y)}return n(),()=>{var b;d.forEach(w=>{s&&w.removeEventListener("scroll",n),i&&w.removeEventListener("resize",n)}),u?.(),(b=f)==null||b.disconnect(),f=null,a&&cancelAnimationFrame(p)}}const zu=ZE,Mb=QE,Ab=JE,Tb=eM,Fu=(t,e,n)=>{const r=new Map,s={platform:CM,...n},i={...s.platform,_c:r};return GE(t,e,{...s,platform:i})};var ll=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},MM=/^\s*>\s$/,Nb=Oe.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return ll("blockquote",{...pe(this.options.HTMLAttributes,t),children:ll("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=[];return t.content.forEach(s=>{const o=e.renderChildren(s).split(`
|
|
105
105
|
`).map(l=>`> ${l}`).join(`
|
|
106
106
|
`);n.push(o)}),n.flatMap(s=>[s,"> "]).slice(0,-1).join(`
|
|
107
|
-
`)},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[ms({find:MM,type:this.type})]}}),AM=Nb,TM=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,NM=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,_M=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,RM=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,OM=Zt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return ll("strong",{...
|
|
107
|
+
`)},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[ms({find:MM,type:this.type})]}}),AM=Nb,TM=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,NM=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,_M=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,RM=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,OM=Zt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return ll("strong",{...pe(this.options.HTMLAttributes,t),children:ll("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Lr({find:TM,type:this.type}),Lr({find:_M,type:this.type})]},addPasteRules(){return[sr({find:NM,type:this.type}),sr({find:RM,type:this.type})]}}),DM=/(^|[^`])`([^`]+)`(?!`)$/,LM=/(^|[^`])`([^`]+)`(?!`)/g,IM=Zt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",pe(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Lr({find:DM,type:this.type})]},addPasteRules(){return[sr({find:LM,type:this.type})]}}),mc=4,jM=/^```([a-z]+)?[\s\n]$/,PM=/^~~~([a-z]+)?[\s\n]$/,_b=Oe.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:mc,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",pe(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const s=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${s}`,e.renderChildren(t.content),"```"].join(`
|
|
108
108
|
`):r=`\`\`\`${s}
|
|
109
109
|
|
|
110
110
|
\`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:mc,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;if(i.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:a})=>{const{from:c,to:d}=s,f=r.doc.textBetween(c,d,`
|
|
@@ -120,43 +120,43 @@ ${y}
|
|
|
120
120
|
`).map(f=>{var p;const g=((p=f.match(/^ */))==null?void 0:p[0])||"",y=Math.min(g.length,n);return f.slice(y)}).join(`
|
|
121
121
|
`);return l.replaceWith(a,c,r.schema.text(h)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
122
122
|
|
|
123
|
-
`);return!i||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:c})=>(c.setSelection(ee.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[od({find:jM,type:this.type,getAttributes:t=>({language:t[1]})}),od({find:PM,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new
|
|
124
|
-
`));return o.replaceSelectionWith(this.type.create({language:i},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(J.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),BM=_b,$M=
|
|
123
|
+
`);return!i||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:c})=>(c.setSelection(ee.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[od({find:jM,type:this.type,getAttributes:t=>({language:t[1]})}),od({find:PM,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new me({key:new ye("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!n||!i)return!1;const{tr:o,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,`
|
|
124
|
+
`));return o.replaceSelectionWith(this.type.create({language:i},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(J.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),BM=_b,$M=Oe.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
125
125
|
|
|
126
|
-
`):""}),HM=
|
|
126
|
+
`):""}),HM=Oe.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",pe(this.options.HTMLAttributes,t)]},renderText(){return`
|
|
127
127
|
`},renderMarkdown:(t,e)=>e.indent(`
|
|
128
|
-
`),parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&o){const u=a.filter(h=>l.includes(h.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Rb=De.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]}`,be(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>od({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),zM=Rb,FM=De.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",be(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!sE(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return Gy(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:o,dispatch:l})=>{if(l){const{$to:a}=o.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?o.setSelection(J.create(o.doc,a.pos+1)):a.nodeAfter.isBlock?o.setSelection(q.create(o.doc,a.pos)):o.setSelection(J.create(o.doc,a.pos));else{const d=i.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,u=d?.create();u&&(o.insert(c,u),o.setSelection(J.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ab({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),UM=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,VM=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,WM=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,qM=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,KM=Zt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",be(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Lr({find:UM,type:this.type}),Lr({find:WM,type:this.type})]},addPasteRules(){return[sr({find:VM,type:this.type}),sr({find:qM,type:this.type})]}});const GM="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",JM="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",ud="numeric",hd="ascii",fd="alpha",Js="asciinumeric",Us="alphanumeric",pd="domain",Ob="emoji",YM="scheme",XM="slashscheme",gc="whitespace";function ZM(t,e){return t in e||(e[t]=[]),e[t]}function vr(t,e,n){e[ud]&&(e[Js]=!0,e[Us]=!0),e[hd]&&(e[Js]=!0,e[fd]=!0),e[Js]&&(e[Us]=!0),e[fd]&&(e[Us]=!0),e[Us]&&(e[pd]=!0),e[Ob]&&(e[pd]=!0);for(const r in e){const s=ZM(r,n);s.indexOf(t)<0&&s.push(t)}}function QM(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function kt(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}kt.groups={};kt.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||kt.groups;let s;return e&&e.j?s=e:(s=new kt(e),n&&r&&vr(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const i=t.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(t[o]);return s.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||kt.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const i=e;let o,l=s.go(t);if(l?(o=new kt,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new kt,i){if(r)if(o.t&&typeof o.t=="string"){const a=Object.assign(QM(o.t,r),n);vr(i,a,r)}else n&&vr(i,n,r);o.t=i}return s.j[t]=o,o}};const oe=(t,e,n,r,s)=>t.ta(e,n,r,s),Le=(t,e,n,r,s)=>t.tr(e,n,r,s),Cp=(t,e,n,r,s)=>t.ts(e,n,r,s),D=(t,e,n,r,s)=>t.tt(e,n,r,s),wn="WORD",md="UWORD",Db="ASCIINUMERICAL",Lb="ALPHANUMERICAL",yi="LOCALHOST",gd="TLD",yd="UTLD",Io="SCHEME",es="SLASH_SCHEME",Uu="NUM",bd="WS",Vu="NL",Ys="OPENBRACE",Xs="CLOSEBRACE",al="OPENBRACKET",cl="CLOSEBRACKET",dl="OPENPAREN",ul="CLOSEPAREN",hl="OPENANGLEBRACKET",fl="CLOSEANGLEBRACKET",pl="FULLWIDTHLEFTPAREN",ml="FULLWIDTHRIGHTPAREN",gl="LEFTCORNERBRACKET",yl="RIGHTCORNERBRACKET",bl="LEFTWHITECORNERBRACKET",xl="RIGHTWHITECORNERBRACKET",wl="FULLWIDTHLESSTHAN",kl="FULLWIDTHGREATERTHAN",vl="AMPERSAND",Sl="APOSTROPHE",Cl="ASTERISK",Fn="AT",El="BACKSLASH",Ml="BACKTICK",Al="CARET",Wn="COLON",Wu="COMMA",Tl="DOLLAR",sn="DOT",Nl="EQUALS",qu="EXCLAMATION",Lt="HYPHEN",Zs="PERCENT",_l="PIPE",Rl="PLUS",Ol="POUND",Qs="QUERY",Ku="QUOTE",Ib="FULLWIDTHMIDDLEDOT",Gu="SEMI",on="SLASH",ei="TILDE",Dl="UNDERSCORE",jb="EMOJI",Ll="SYM";var Pb=Object.freeze({__proto__:null,ALPHANUMERICAL:Lb,AMPERSAND:vl,APOSTROPHE:Sl,ASCIINUMERICAL:Db,ASTERISK:Cl,AT:Fn,BACKSLASH:El,BACKTICK:Ml,CARET:Al,CLOSEANGLEBRACKET:fl,CLOSEBRACE:Xs,CLOSEBRACKET:cl,CLOSEPAREN:ul,COLON:Wn,COMMA:Wu,DOLLAR:Tl,DOT:sn,EMOJI:jb,EQUALS:Nl,EXCLAMATION:qu,FULLWIDTHGREATERTHAN:kl,FULLWIDTHLEFTPAREN:pl,FULLWIDTHLESSTHAN:wl,FULLWIDTHMIDDLEDOT:Ib,FULLWIDTHRIGHTPAREN:ml,HYPHEN:Lt,LEFTCORNERBRACKET:gl,LEFTWHITECORNERBRACKET:bl,LOCALHOST:yi,NL:Vu,NUM:Uu,OPENANGLEBRACKET:hl,OPENBRACE:Ys,OPENBRACKET:al,OPENPAREN:dl,PERCENT:Zs,PIPE:_l,PLUS:Rl,POUND:Ol,QUERY:Qs,QUOTE:Ku,RIGHTCORNERBRACKET:yl,RIGHTWHITECORNERBRACKET:xl,SCHEME:Io,SEMI:Gu,SLASH:on,SLASH_SCHEME:es,SYM:Ll,TILDE:ei,TLD:gd,UNDERSCORE:Dl,UTLD:yd,UWORD:md,WORD:wn,WS:bd});const yn=/[a-z]/,Ps=new RegExp("\\p{L}","u"),yc=new RegExp("\\p{Emoji}","u"),bn=/\d/,bc=/\s/,Ep="\r",xc=`
|
|
128
|
+
`),parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&o){const u=a.filter(h=>l.includes(h.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Rb=Oe.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]}`,pe(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>od({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),zM=Rb,FM=Oe.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",pe(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!sE(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return Gy(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:o,dispatch:l})=>{if(l){const{$to:a}=o.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?o.setSelection(J.create(o.doc,a.pos+1)):a.nodeAfter.isBlock?o.setSelection(q.create(o.doc,a.pos)):o.setSelection(J.create(o.doc,a.pos));else{const d=i.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,u=d?.create();u&&(o.insert(c,u),o.setSelection(J.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ab({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),UM=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,VM=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,WM=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,qM=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,KM=Zt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",pe(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Lr({find:UM,type:this.type}),Lr({find:WM,type:this.type})]},addPasteRules(){return[sr({find:VM,type:this.type}),sr({find:qM,type:this.type})]}});const GM="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",JM="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",ud="numeric",hd="ascii",fd="alpha",Js="asciinumeric",Us="alphanumeric",pd="domain",Ob="emoji",YM="scheme",XM="slashscheme",gc="whitespace";function ZM(t,e){return t in e||(e[t]=[]),e[t]}function vr(t,e,n){e[ud]&&(e[Js]=!0,e[Us]=!0),e[hd]&&(e[Js]=!0,e[fd]=!0),e[Js]&&(e[Us]=!0),e[fd]&&(e[Us]=!0),e[Us]&&(e[pd]=!0),e[Ob]&&(e[pd]=!0);for(const r in e){const s=ZM(r,n);s.indexOf(t)<0&&s.push(t)}}function QM(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function kt(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}kt.groups={};kt.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||kt.groups;let s;return e&&e.j?s=e:(s=new kt(e),n&&r&&vr(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const i=t.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(t[o]);return s.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||kt.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const i=e;let o,l=s.go(t);if(l?(o=new kt,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new kt,i){if(r)if(o.t&&typeof o.t=="string"){const a=Object.assign(QM(o.t,r),n);vr(i,a,r)}else n&&vr(i,n,r);o.t=i}return s.j[t]=o,o}};const oe=(t,e,n,r,s)=>t.ta(e,n,r,s),Le=(t,e,n,r,s)=>t.tr(e,n,r,s),Cp=(t,e,n,r,s)=>t.ts(e,n,r,s),D=(t,e,n,r,s)=>t.tt(e,n,r,s),wn="WORD",md="UWORD",Db="ASCIINUMERICAL",Lb="ALPHANUMERICAL",yi="LOCALHOST",gd="TLD",yd="UTLD",Io="SCHEME",es="SLASH_SCHEME",Uu="NUM",bd="WS",Vu="NL",Ys="OPENBRACE",Xs="CLOSEBRACE",al="OPENBRACKET",cl="CLOSEBRACKET",dl="OPENPAREN",ul="CLOSEPAREN",hl="OPENANGLEBRACKET",fl="CLOSEANGLEBRACKET",pl="FULLWIDTHLEFTPAREN",ml="FULLWIDTHRIGHTPAREN",gl="LEFTCORNERBRACKET",yl="RIGHTCORNERBRACKET",bl="LEFTWHITECORNERBRACKET",xl="RIGHTWHITECORNERBRACKET",wl="FULLWIDTHLESSTHAN",kl="FULLWIDTHGREATERTHAN",vl="AMPERSAND",Sl="APOSTROPHE",Cl="ASTERISK",Fn="AT",El="BACKSLASH",Ml="BACKTICK",Al="CARET",Wn="COLON",Wu="COMMA",Tl="DOLLAR",sn="DOT",Nl="EQUALS",qu="EXCLAMATION",Lt="HYPHEN",Zs="PERCENT",_l="PIPE",Rl="PLUS",Ol="POUND",Qs="QUERY",Ku="QUOTE",Ib="FULLWIDTHMIDDLEDOT",Gu="SEMI",on="SLASH",ei="TILDE",Dl="UNDERSCORE",jb="EMOJI",Ll="SYM";var Pb=Object.freeze({__proto__:null,ALPHANUMERICAL:Lb,AMPERSAND:vl,APOSTROPHE:Sl,ASCIINUMERICAL:Db,ASTERISK:Cl,AT:Fn,BACKSLASH:El,BACKTICK:Ml,CARET:Al,CLOSEANGLEBRACKET:fl,CLOSEBRACE:Xs,CLOSEBRACKET:cl,CLOSEPAREN:ul,COLON:Wn,COMMA:Wu,DOLLAR:Tl,DOT:sn,EMOJI:jb,EQUALS:Nl,EXCLAMATION:qu,FULLWIDTHGREATERTHAN:kl,FULLWIDTHLEFTPAREN:pl,FULLWIDTHLESSTHAN:wl,FULLWIDTHMIDDLEDOT:Ib,FULLWIDTHRIGHTPAREN:ml,HYPHEN:Lt,LEFTCORNERBRACKET:gl,LEFTWHITECORNERBRACKET:bl,LOCALHOST:yi,NL:Vu,NUM:Uu,OPENANGLEBRACKET:hl,OPENBRACE:Ys,OPENBRACKET:al,OPENPAREN:dl,PERCENT:Zs,PIPE:_l,PLUS:Rl,POUND:Ol,QUERY:Qs,QUOTE:Ku,RIGHTCORNERBRACKET:yl,RIGHTWHITECORNERBRACKET:xl,SCHEME:Io,SEMI:Gu,SLASH:on,SLASH_SCHEME:es,SYM:Ll,TILDE:ei,TLD:gd,UNDERSCORE:Dl,UTLD:yd,UWORD:md,WORD:wn,WS:bd});const yn=/[a-z]/,Ps=new RegExp("\\p{L}","u"),yc=new RegExp("\\p{Emoji}","u"),bn=/\d/,bc=/\s/,Ep="\r",xc=`
|
|
129
129
|
`,eA="️",tA="",wc="";let yo=null,bo=null;function nA(t=[]){const e={};kt.groups=e;const n=new kt;yo==null&&(yo=Mp(GM)),bo==null&&(bo=Mp(JM)),D(n,"'",Sl),D(n,"{",Ys),D(n,"}",Xs),D(n,"[",al),D(n,"]",cl),D(n,"(",dl),D(n,")",ul),D(n,"<",hl),D(n,">",fl),D(n,"(",pl),D(n,")",ml),D(n,"「",gl),D(n,"」",yl),D(n,"『",bl),D(n,"』",xl),D(n,"<",wl),D(n,">",kl),D(n,"&",vl),D(n,"*",Cl),D(n,"@",Fn),D(n,"`",Ml),D(n,"^",Al),D(n,":",Wn),D(n,",",Wu),D(n,"$",Tl),D(n,".",sn),D(n,"=",Nl),D(n,"!",qu),D(n,"-",Lt),D(n,"%",Zs),D(n,"|",_l),D(n,"+",Rl),D(n,"#",Ol),D(n,"?",Qs),D(n,'"',Ku),D(n,"/",on),D(n,";",Gu),D(n,"~",ei),D(n,"_",Dl),D(n,"\\",El),D(n,"・",Ib);const r=Le(n,bn,Uu,{[ud]:!0});Le(r,bn,r);const s=Le(r,yn,Db,{[Js]:!0}),i=Le(r,Ps,Lb,{[Us]:!0}),o=Le(n,yn,wn,{[hd]:!0});Le(o,bn,s),Le(o,yn,o),Le(s,bn,s),Le(s,yn,s);const l=Le(n,Ps,md,{[fd]:!0});Le(l,yn),Le(l,bn,i),Le(l,Ps,l),Le(i,bn,i),Le(i,yn),Le(i,Ps,i);const a=D(n,xc,Vu,{[gc]:!0}),c=D(n,Ep,bd,{[gc]:!0}),d=Le(n,bc,bd,{[gc]:!0});D(n,wc,d),D(c,xc,a),D(c,wc,d),Le(c,bc,d),D(d,Ep),D(d,xc),Le(d,bc,d),D(d,wc,d);const u=Le(n,yc,jb,{[Ob]:!0});D(u,"#"),Le(u,yc,u),D(u,eA,u);const h=D(u,tA);D(h,"#"),Le(h,yc,u);const f=[[yn,o],[bn,s]],p=[[yn,null],[Ps,l],[bn,i]];for(let g=0;g<yo.length;g++)Pn(n,yo[g],gd,wn,f);for(let g=0;g<bo.length;g++)Pn(n,bo[g],yd,md,p);vr(gd,{tld:!0,ascii:!0},e),vr(yd,{utld:!0,alpha:!0},e),Pn(n,"file",Io,wn,f),Pn(n,"mailto",Io,wn,f),Pn(n,"http",es,wn,f),Pn(n,"https",es,wn,f),Pn(n,"ftp",es,wn,f),Pn(n,"ftps",es,wn,f),vr(Io,{scheme:!0,ascii:!0},e),vr(es,{slashscheme:!0,ascii:!0},e),t=t.sort((g,y)=>g[0]>y[0]?1:-1);for(let g=0;g<t.length;g++){const y=t[g][0],w=t[g][1]?{[YM]:!0}:{[XM]:!0};y.indexOf("-")>=0?w[pd]=!0:yn.test(y)?bn.test(y)?w[Js]=!0:w[hd]=!0:w[ud]=!0,Cp(n,y,y,w)}return Cp(n,"localhost",yi,{ascii:!0}),n.jd=new kt(Ll),{start:n,tokens:Object.assign({groups:e},Pb)}}function Bb(t,e){const n=rA(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,s=[];let i=0,o=0;for(;o<r;){let l=t,a=null,c=0,d=null,u=-1,h=-1;for(;o<r&&(a=l.go(n[o]));)l=a,l.accepts()?(u=0,h=0,d=l):u>=0&&(u+=n[o].length,h++),c+=n[o].length,i+=n[o].length,o++;i-=u,o-=h,c-=u,s.push({t:d.t,v:e.slice(i-c,i),s:i-c,e:i})}return s}function rA(t){const e=[],n=t.length;let r=0;for(;r<n;){let s=t.charCodeAt(r),i,o=s<55296||s>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Pn(t,e,n,r,s){let i;const o=e.length;for(let l=0;l<o-1;l++){const a=e[l];t.j[a]?i=t.j[a]:(i=new kt(r),i.jr=s.slice(),t.j[a]=i),t=i}return i=new kt(n),i.jr=s.slice(),t.j[e[o-1]]=i,i}function Mp(t){const e=[],n=[];let r=0,s="0123456789";for(;r<t.length;){let i=0;for(;s.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+i),10);o>0;o--)n.pop();r+=i}else n.push(t[r]),r++}return e}const bi={defaultProtocol:"http",events:null,format:Ap,formatHref:Ap,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Ju(t,e=null){let n=Object.assign({},bi);t&&(n=Object.assign(n,t instanceof Ju?t.o:t));const r=n.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=s}Ju.prototype={o:bi,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let s=this.o[t];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:bi[t],typeof s=="function"&&r&&(s=s(e,n))):typeof s=="function"&&r&&(s=s(e,n.t,n)),s)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Ap(t){return t}function $b(t,e){this.t="token",this.v=t,this.tk=e}$b.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=bi.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),s=t.get("tagName",n,e),i=this.toFormattedString(t),o={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),d=t.getObj("attributes",n,e),u=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),d&&Object.assign(o,d),{tagName:s,attributes:o,content:i,eventListeners:u}}};function ma(t,e){class n extends $b{constructor(s,i){super(s,i),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const Tp=ma("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Np=ma("text"),sA=ma("nl"),xo=ma("url",{isLink:!0,toHref(t=bi.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==yi&&t[1].t===Wn}}),Dt=t=>new kt(t);function iA({groups:t}){const e=t.domain.concat([vl,Cl,Fn,El,Ml,Al,Tl,Nl,Lt,Uu,Zs,_l,Rl,Ol,on,Ll,ei,Dl]),n=[Sl,Wn,Wu,sn,qu,Zs,Qs,Ku,Gu,hl,fl,Ys,Xs,cl,al,dl,ul,pl,ml,gl,yl,bl,xl,wl,kl],r=[vl,Sl,Cl,El,Ml,Al,Tl,Nl,Lt,Ys,Xs,Zs,_l,Rl,Ol,Qs,on,Ll,ei,Dl],s=Dt(),i=D(s,ei);oe(i,r,i),oe(i,t.domain,i);const o=Dt(),l=Dt(),a=Dt();oe(s,t.domain,o),oe(s,t.scheme,l),oe(s,t.slashscheme,a),oe(o,r,i),oe(o,t.domain,o);const c=D(o,Fn);D(i,Fn,c),D(l,Fn,c),D(a,Fn,c);const d=D(i,sn);oe(d,r,i),oe(d,t.domain,i);const u=Dt();oe(c,t.domain,u),oe(u,t.domain,u);const h=D(u,sn);oe(h,t.domain,u);const f=Dt(Tp);oe(h,t.tld,f),oe(h,t.utld,f),D(c,yi,f);const p=D(u,Lt);D(p,Lt,p),oe(p,t.domain,u),oe(f,t.domain,u),D(f,sn,h),D(f,Lt,p);const g=D(f,Wn);oe(g,t.numeric,Tp);const y=D(o,Lt),b=D(o,sn);D(y,Lt,y),oe(y,t.domain,o),oe(b,r,i),oe(b,t.domain,o);const w=Dt(xo);oe(b,t.tld,w),oe(b,t.utld,w),oe(w,t.domain,o),oe(w,r,i),D(w,sn,b),D(w,Lt,y),D(w,Fn,c);const M=D(w,Wn),S=Dt(xo);oe(M,t.numeric,S);const A=Dt(xo),x=Dt();oe(A,e,A),oe(A,n,x),oe(x,e,A),oe(x,n,x),D(w,on,A),D(S,on,A);const k=D(l,Wn),v=D(a,Wn),T=D(v,on),N=D(T,on);oe(l,t.domain,o),D(l,sn,b),D(l,Lt,y),oe(a,t.domain,o),D(a,sn,b),D(a,Lt,y),oe(k,t.domain,A),D(k,on,A),D(k,Qs,A),oe(N,t.domain,A),oe(N,e,A),D(N,on,A);const H=[[Ys,Xs],[al,cl],[dl,ul],[hl,fl],[pl,ml],[gl,yl],[bl,xl],[wl,kl]];for(let V=0;V<H.length;V++){const[$,I]=H[V],j=D(A,$);D(x,$,j),D(j,I,A);const Q=Dt(xo);oe(j,e,Q);const ie=Dt();oe(j,n),oe(Q,e,Q),oe(Q,n,ie),oe(ie,e,Q),oe(ie,n,ie),D(Q,I,A),D(ie,I,A)}return D(s,yi,w),D(s,Vu,sA),{start:s,tokens:Pb}}function oA(t,e,n){let r=n.length,s=0,i=[],o=[];for(;s<r;){let l=t,a=null,c=null,d=0,u=null,h=-1;for(;s<r&&!(a=l.go(n[s].t));)o.push(n[s++]);for(;s<r&&(c=a||l.go(n[s].t));)a=null,l=c,l.accepts()?(h=0,u=l):h>=0&&h++,s++,d++;if(h<0)s-=d,s<r&&(o.push(n[s]),s++);else{o.length>0&&(i.push(kc(Np,e,o)),o=[]),s-=h,d-=h;const f=u.t,p=n.slice(s-d,s);i.push(kc(f,e,p))}}return o.length>0&&i.push(kc(Np,e,o)),i}function kc(t,e,n){const r=n[0].s,s=n[n.length-1].e,i=e.slice(r,s);return new t(i,n)}const lA=typeof console<"u"&&console&&console.warn||(()=>{}),aA="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Ne={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function cA(){return kt.groups={},Ne.scanner=null,Ne.parser=null,Ne.tokenQueue=[],Ne.pluginQueue=[],Ne.customSchemes=[],Ne.initialized=!1,Ne}function _p(t,e=!1){if(Ne.initialized&&lA(`linkifyjs: already initialized - will not register custom scheme "${t}" ${aA}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
|
|
130
130
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
131
131
|
2. Cannot start or end with "-"
|
|
132
|
-
3. "-" cannot repeat`);Ne.customSchemes.push([t,e])}function dA(){Ne.scanner=nA(Ne.customSchemes);for(let t=0;t<Ne.tokenQueue.length;t++)Ne.tokenQueue[t][1]({scanner:Ne.scanner});Ne.parser=iA(Ne.scanner.tokens);for(let t=0;t<Ne.pluginQueue.length;t++)Ne.pluginQueue[t][1]({scanner:Ne.scanner,parser:Ne.parser});return Ne.initialized=!0,Ne}function Yu(t){return Ne.initialized||dA(),oA(Ne.parser.start,t,Bb(Ne.scanner.start,t))}Yu.scan=Bb;function Hb(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new Ju(n),s=Yu(t),i=[];for(let o=0;o<s.length;o++){const l=s[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var Xu="[\0- -\u2029 ]",uA=new RegExp(Xu),hA=new RegExp(`${Xu}$`),fA=new RegExp(Xu,"g");function pA(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function mA(t){return new
|
|
133
|
-
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(kA,this.editor.getAttributes(Rp)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=ms({find:Op,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ms({find:Op,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Rp),editor:this.editor})),[t]}}),Fb=
|
|
132
|
+
3. "-" cannot repeat`);Ne.customSchemes.push([t,e])}function dA(){Ne.scanner=nA(Ne.customSchemes);for(let t=0;t<Ne.tokenQueue.length;t++)Ne.tokenQueue[t][1]({scanner:Ne.scanner});Ne.parser=iA(Ne.scanner.tokens);for(let t=0;t<Ne.pluginQueue.length;t++)Ne.pluginQueue[t][1]({scanner:Ne.scanner,parser:Ne.parser});return Ne.initialized=!0,Ne}function Yu(t){return Ne.initialized||dA(),oA(Ne.parser.start,t,Bb(Ne.scanner.start,t))}Yu.scan=Bb;function Hb(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new Ju(n),s=Yu(t),i=[];for(let o=0;o<s.length;o++){const l=s[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var Xu="[\0- -\u2029 ]",uA=new RegExp(Xu),hA=new RegExp(`${Xu}$`),fA=new RegExp(Xu,"g");function pA(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function mA(t){return new me({key:new ye("autolink"),appendTransaction:(e,n,r)=>{const s=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,l=$y(n.doc,[...e]);if(Ky(l).forEach(({newRange:c})=>{const d=aC(r.doc,c,f=>f.isTextblock);let u,h;if(d.length>1)u=d[0],h=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){const f=r.doc.textBetween(c.from,c.to," "," ");if(!hA.test(f))return;u=d[0],h=r.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&h){const f=h.split(uA).filter(Boolean);if(f.length<=0)return!1;const p=f[f.length-1],g=u.pos+h.lastIndexOf(p);if(!p)return!1;const y=Yu(p).map(b=>b.toObject(t.defaultProtocol));if(!pA(y))return!1;y.filter(b=>b.isLink).map(b=>({...b,from:g+b.start+1,to:g+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{_u(b.from,b.to,r.doc).some(w=>w.mark.type===t.type)||o.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!o.steps.length)return o}})}function gA(t){return new me({key:new ye("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,i;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let d=r.target;const u=[];for(;d.nodeName!=="DIV";)u.push(d),d=d.parentNode;o=u.find(h=>h.nodeName==="A")}if(!o)return!1;const l=qy(e.state,t.type.name),a=(s=o?.href)!=null?s:l.href,c=(i=o?.target)!=null?i:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),o&&a?(window.open(a,c),!0):!1}}})}function yA(t){return new me({key:new ye("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:i}=e,{selection:o}=i,{empty:l}=o;if(l)return!1;let a="";r.content.forEach(d=>{a+=d.textContent});const c=Hb(a,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===a);return!a||!c||s!==void 0&&!s(c.href)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function gr(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace(fA,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var zb=Zt.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){_p(t);return}_p(t.scheme,t.optionalSlashes)})},onDestroy(){cA()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!gr(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!gr(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!gr(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",pe(this.options.HTMLAttributes,t),0]:["a",pe(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n;const r=((n=t.attrs)==null?void 0:n.href)||"";return`[${e.renderChildren(t)}](${r})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!gr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!gr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[sr({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,s=Hb(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!gr(o,n),protocols:n,defaultProtocol:r}));s.length&&s.forEach(i=>{this.options.shouldAutoLink(i.value)&&e.push({text:i.value,data:{href:i.href},index:i.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(mA({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!gr(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(gA({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(yA({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),bA=zb,xA=Object.defineProperty,wA=(t,e)=>{for(var n in e)xA(t,n,{get:e[n],enumerable:!0})},kA="listItem",Rp="textStyle",Op=/^\s*([-+*])\s$/,Zu=Oe.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",pe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
133
|
+
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(kA,this.editor.getAttributes(Rp)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=ms({find:Op,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ms({find:Op,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Rp),editor:this.editor})),[t]}}),Fb=Oe.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",pe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(s=>s.type==="paragraph"))n=e.parseChildren(t.tokens);else{const s=t.tokens[0];if(s&&s.type==="text"&&s.tokens&&s.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(s.tokens)}],t.tokens.length>1){const o=t.tokens.slice(1),l=e.parseChildren(o);n.push(...l)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>Lu(t,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),vA={};wA(vA,{findListItemPos:()=>$i,getNextListDepth:()=>Qu,handleBackspace:()=>xd,handleDelete:()=>wd,hasListBefore:()=>Ub,hasListItemAfter:()=>SA,hasListItemBefore:()=>Vb,listItemHasSubList:()=>Wb,nextListIsDeeper:()=>qb,nextListIsHigher:()=>Kb});var $i=(t,e)=>{const{$from:n}=e.selection,r=Ke(t,e.schema);let s=null,i=n.depth,o=n.pos,l=null;for(;i>0&&l===null;)s=n.node(i),s.type===r?l=i:(i-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},Qu=(t,e)=>{const n=$i(t,e);if(!n)return!1;const[,r]=yC(e,t,n.$pos.pos+4);return r},Ub=(t,e,n)=>{const{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),i=t.doc.resolve(s).node();return!(!i||!n.includes(i.type.name))},Vb=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((n=s.nodeBefore)==null?void 0:n.type.name)!==t)},Wb=(t,e,n)=>{if(!n)return!1;const r=Ke(t,e.schema);let s=!1;return n.descendants(i=>{i.type===r&&(s=!0)}),s},xd=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!rr(t.state,e)&&Ub(t.state,e,n)){const{$anchor:l}=t.state.selection,a=t.state.doc.resolve(l.before()-1),c=[];a.node().descendants((h,f)=>{h.type.name===e&&c.push({node:h,pos:f})});const d=c.at(-1);if(!d)return!1;const u=t.state.doc.resolve(a.start()+d.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},u.end()).joinForward().run()}if(!rr(t.state,e)||!kC(t.state))return!1;const r=$i(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Wb(e,t.state,i);return Vb(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},qb=(t,e)=>{const n=Qu(t,e),r=$i(t,e);return!r||!n?!1:n>r.depth},Kb=(t,e)=>{const n=Qu(t,e),r=$i(t,e);return!r||!n?!1:n<r.depth},wd=(t,e)=>{if(!rr(t.state,e)||!wC(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:qb(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Kb(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},SA=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((n=s.nodeAfter)==null?void 0:n.type.name)!==t)},Gb=de.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&wd(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&wd(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&xd(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&xd(t,n,r)&&(e=!0)}),e}}}}),Dp=/^(\s*)(\d+)\.\s+(.*)$/,CA=/^\s/;function EA(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],i=s.match(Dp);if(!i)break;const[,o,l,a]=i,c=o.length;let d=a,u=n+1;const h=[s];for(;u<t.length;){const f=t[u];if(f.match(Dp))break;if(f.trim()==="")h.push(f),d+=`
|
|
134
134
|
`,u+=1;else if(f.match(CA))h.push(f),d+=`
|
|
135
135
|
${f.slice(c+2)}`,u+=1;else break}e.push({indent:c,number:parseInt(l,10),content:d.trim(),raw:h.join(`
|
|
136
136
|
`)}),r=u,n=u}return[e,r]}function Jb(t,e,n){var r;const s=[];let i=0;for(;i<t.length;){const o=t[i];if(o.indent===e){const l=o.content.split(`
|
|
137
137
|
`),a=((r=l[0])==null?void 0:r.trim())||"",c=[];a&&c.push({type:"paragraph",raw:a,tokens:n.inlineTokens(a)});const d=l.slice(1).join(`
|
|
138
138
|
`).trim();if(d){const f=n.blockTokens(d);c.push(...f)}let u=i+1;const h=[];for(;u<t.length&&t[u].indent>e;)h.push(t[u]),u+=1;if(h.length>0){const f=Math.min(...h.map(g=>g.indent)),p=Jb(h,f,n);c.push({type:"list",ordered:!0,start:h[0].number,items:p,raw:h.map(g=>g.raw).join(`
|
|
139
|
-
`)})}s.push({type:"list_item",raw:o.raw,tokens:c}),i=u}else i+=1}return s}function MA(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const i=e.parseChildren([s]);r.push({type:"paragraph",content:i})}else{const i=e.parseChildren([s]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var AA="listItem",Lp="textStyle",Ip=/^(\d+)\.\s$/,eh=
|
|
139
|
+
`)})}s.push({type:"list_item",raw:o.raw,tokens:c}),i=u}else i+=1}return s}function MA(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const i=e.parseChildren([s]);r.push({type:"paragraph",content:i})}else{const i=e.parseChildren([s]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var AA="listItem",Lp="textStyle",Ip=/^(\d+)\.\s$/,eh=Oe.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",pe(this.options.HTMLAttributes,n),0]:["ol",pe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?MA(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
140
140
|
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const s=t.split(`
|
|
141
141
|
`),[i,o]=EA(s);if(i.length===0)return;const l=Jb(i,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=i[0])==null?void 0:r.number)||1,items:l,raw:s.slice(0,o).join(`
|
|
142
|
-
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(AA,this.editor.getAttributes(Lp)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=ms({find:Ip,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=ms({find:Ip,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Lp)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),TA=/^\s*(\[([( |x])?\])\s$/,Yb=
|
|
143
|
-
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=i=>{const o=ld(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(i)},s=ld(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});de.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Zu.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Fb.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Gb.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(eh.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Yb.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Xb.configure(this.options.taskList)),t}});var Zb=De.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",be(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];return n.length===1&&n[0].type==="image"?e.parseChildren([n[0]]):e.createNode("paragraph",void 0,e.parseInline(n))},renderMarkdown:(t,e)=>!t||!Array.isArray(t.content)?"":e.renderChildren(t.content),addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),NA=Zb,_A=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,RA=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,OA=Zt.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",be(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Lr({find:_A,type:this.type})]},addPasteRules(){return[sr({find:RA,type:this.type})]}}),DA=De.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Qb=Zt.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",be(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!s)return;const i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),LA=Qb;function IA(t={}){return new pe({view(e){return new jA(e,t)}})}class jA{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let u=e.nodeBefore,h=e.nodeAfter;if(u||h){let f=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(f){let p=f.getBoundingClientRect(),g=u?p.bottom:p.top;u&&h&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:p.left,right:p.right,top:g-y,bottom:g+y}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*o;r={left:u.left-h,right:u.left+h,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),h=u.width/a.offsetWidth,f=u.height/a.offsetHeight;c=u.left-a.scrollLeft*h,d=u.top-a.scrollTop*f}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Og(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class je extends ee{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return je.valid(r)?new je(r):ee.near(r)}content(){return P.empty}eq(e){return e instanceof je&&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 je(e.resolve(n.pos))}getBookmark(){return new th(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!PA(e)||!BA(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&je.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let a=e.doc.resolve(s);if(je.valid(a))return a}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!q.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let l=e.doc.resolve(s);if(je.valid(l))return l}return null}}}je.prototype.visible=!1;je.findFrom=je.findGapCursorFrom;ee.jsonID("gapcursor",je);class th{constructor(e){this.pos=e}map(e){return new th(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return je.valid(n)?new je(n):ee.near(n)}}function e0(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function PA(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||e0(s.type))return!0;if(s.inlineContent)return!1}}return!0}function BA(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||e0(s.type))return!0;if(s.inlineContent)return!1}}return!0}function $A(){return new pe({props:{decorations:UA,createSelectionBetween(t,e,n){return e.pos==n.pos&&je.valid(n)?new je(n):null},handleClick:zA,handleKeyDown:HA,handleDOMEvents:{beforeinput:FA}}})}const HA=Su({ArrowLeft:wo("horiz",-1),ArrowRight:wo("horiz",1),ArrowUp:wo("vert",-1),ArrowDown:wo("vert",1)});function wo(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof J){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=je.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new je(c))),!0):!1}}function zA(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!je.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&q.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new je(r))),!0)}function FA(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof je))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=O.empty;for(let o=r.length-1;o>=0;o--)s=O.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new P(s,0,0));return i.setSelection(J.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function UA(t){if(!(t.selection instanceof je))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ye.create(t.doc,[_e.widget(t.selection.head,e,{key:"gapcursor"})])}var Il=200,et=function(){};et.prototype.append=function(e){return e.length?(e=et.from(e),!this.length&&e||e.length<Il&&this.leafAppend(e)||this.length<Il&&e.leafPrepend(this)||this.appendInner(e)):this};et.prototype.prepend=function(e){return e.length?et.from(e).append(this):this};et.prototype.appendInner=function(e){return new VA(this,e)};et.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?et.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};et.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};et.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)};et.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},n,r),s};et.from=function(e){return e instanceof et?e:e&&e.length?new t0(e):et.empty};var t0=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Il)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Il)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(et);et.empty=new t0([]);var VA=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(et);const WA=500;class Ut{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],d=[];return this.items.forEach((u,h)=>{if(!u.step){s||(s=this.remapping(r,h+1),i=s.maps.length),i--,d.push(u);return}if(s){d.push(new Bn(u.map));let f=u.step.map(s.slice(i)),p;f&&o.maybeStep(f).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Bn(p,void 0,void 0,c.length+d.length))),i--,p&&s.appendMap(p,i)}else o.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(i)):u.selection,a=new Ut(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,n,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),h=new Bn(e.mapping.maps[d],u,n),f;(f=a&&a.merge(h))&&(h=f,d?i.pop():l=l.slice(0,l.length-1)),i.push(h),n&&(o++,n=void 0),s||(a=h)}let c=o-r.depth;return c>KA&&(l=qA(l,c),o-=c),new Ut(l.append(i),o)}remapping(e,n){let r=new ai;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new Ut(this.items.append(e.map(n=>new Bn(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},s);let a=n;this.items.forEach(h=>{let f=i.getMirror(--a);if(f==null)return;o=Math.min(o,f);let p=i.maps[f];if(h.step){let g=e.steps[f].invert(e.docs[f]),y=h.selection&&h.selection.map(i.slice(a+1,f));y&&l++,r.push(new Bn(p,g,y))}else r.push(new Bn(p))},s);let c=[];for(let h=n;h<o;h++)c.push(new Bn(i.maps[h]));let d=this.items.slice(0,s).append(c).append(r),u=new Ut(d,l);return u.emptyItemCount()>WA&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let d=o.selection&&o.selection.map(n.slice(r));d&&i++;let u=new Bn(c.invert(),a,d),h,f=s.length-1;(h=s.length&&s[f].merge(u))?s[f]=h:s.push(u)}}else o.map&&r--},this.items.length,0),new Ut(et.from(s.reverse()),i)}}Ut.empty=new Ut(et.empty,0);function qA(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}let Bn=class n0{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new n0(n.getMap().invert(),n,this.selection)}}};class Un{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const KA=20;function GA(t,e,n,r){let s=n.getMeta(Ar),i;if(s)return s.historyState;n.getMeta(XA)&&(t=new Un(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Ar))return o.getMeta(Ar).redo?new Un(t.done.addTransform(n,void 0,r,jo(e)),t.undone,jp(n.mapping.maps),t.prevTime,t.prevComposition):new Un(t.done,t.undone.addTransform(n,void 0,r,jo(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!JA(n,t.prevRanges)),c=o?vc(t.prevRanges,n.mapping):jp(n.mapping.maps);return new Un(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,jo(e)),Ut.empty,c,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Un(t.done.rebased(n,i),t.undone.rebased(n,i),vc(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Un(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),vc(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function JA(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function jp(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function vc(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function YA(t,e,n){let r=jo(e),s=Ar.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new Un(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(Ar,{redo:n,historyState:a})}let Sc=!1,Pp=null;function jo(t){let e=t.plugins;if(Pp!=e){Sc=!1,Pp=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Sc=!0;break}}return Sc}const Ar=new ge("history"),XA=new ge("closeHistory");function ZA(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new pe({key:Ar,state:{init(){return new Un(Ut.empty,Ut.empty,null,0,-1)},apply(e,n,r){return GA(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?s0:r=="historyRedo"?i0:null;return s?(n.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function r0(t,e){return(n,r)=>{let s=Ar.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=YA(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const s0=r0(!1,!0),i0=r0(!0,!0);var QA=de.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new pe({key:new ge("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit;if(s==null||s===0){t=!0;return}const i=this.storage.characters({node:r.doc});if(i>s){const o=i-s,l=0,a=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return t=!0,c}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=i-r,c=l-a,d=l;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>r)}})]}}),eT=de.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[IA(this.options)]}});de.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new pe({key:new ge("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return ye.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(_e.node(c,c+a.nodeSize,{class:this.options.className}))}),ye.create(t,i)}}})]}});var o0=de.create({name:"gapCursor",addProseMirrorPlugins(){return[$A()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=we(G(t,"allowGapCursor",n)))!=null?e:null}}}),tT=de.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new pe({key:new ge("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(!n)return null;const i=this.editor.isEmpty;return t.descendants((o,l)=>{const a=r>=l&&r<=l+o.nodeSize,c=!o.isLeaf&&Li(o);if((a||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];i&&d.push(this.options.emptyEditorClass);const u=_e.node(l,l+o.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:a}):this.options.placeholder});s.push(u)}return this.options.includeChildren}),ye.create(t,s)}}})]}});de.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new pe({key:new ge("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Gy(n.selection)||t.view.dragging?null:ye.create(n.doc,[_e.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Bp({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var nT=de.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ge(this.name),n=((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||this.options.node||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new pe({key:e,appendTransaction:(s,i,o)=>{const{doc:l,tr:a,schema:c}=o,d=e.getState(o),u=l.content.size,h=c.nodes[n];if(d)return a.insert(u,h.create())},state:{init:(s,i)=>{const o=i.tr.doc.lastChild;return!Bp({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged)return i;const o=s.doc.lastChild;return!Bp({node:o,types:r})}}})]}}),l0=de.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>s0(t,e),redo:()=>({state:t,dispatch:e})=>i0(t,e)}},addProseMirrorPlugins(){return[ZA(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()}}}),rT=de.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(OM.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(Nb.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(Zu.configure(this.options.bulletList)),this.options.code!==!1&&s.push(IM.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(_b.configure(this.options.codeBlock)),this.options.document!==!1&&s.push($M.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(eT.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(o0.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(HM.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(Rb.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(l0.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(FM.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(KM.configure(this.options.italic)),this.options.listItem!==!1&&s.push(Fb.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(Gb.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(zb.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(eh.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(Zb.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(OA.configure(this.options.strike)),this.options.text!==!1&&s.push(DA.configure(this.options.text)),this.options.underline!==!1&&s.push(Qb.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(nT.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),sT=rT,Cc,$p;function iT(){if($p)return Cc;$p=1;function t(E){return E instanceof Map?E.clear=E.delete=E.set=function(){throw new Error("map is read-only")}:E instanceof Set&&(E.add=E.clear=E.delete=function(){throw new Error("set is read-only")}),Object.freeze(E),Object.getOwnPropertyNames(E).forEach(R=>{const B=E[R],re=typeof B;(re==="object"||re==="function")&&!Object.isFrozen(B)&&t(B)}),E}class e{constructor(R){R.data===void 0&&(R.data={}),this.data=R.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(E){return E.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(E,...R){const B=Object.create(null);for(const re in E)B[re]=E[re];return R.forEach(function(re){for(const He in re)B[He]=re[He]}),B}const s="</span>",i=E=>!!E.scope,o=(E,{prefix:R})=>{if(E.startsWith("language:"))return E.replace("language:","language-");if(E.includes(".")){const B=E.split(".");return[`${R}${B.shift()}`,...B.map((re,He)=>`${re}${"_".repeat(He+1)}`)].join(" ")}return`${R}${E}`};class l{constructor(R,B){this.buffer="",this.classPrefix=B.classPrefix,R.walk(this)}addText(R){this.buffer+=n(R)}openNode(R){if(!i(R))return;const B=o(R.scope,{prefix:this.classPrefix});this.span(B)}closeNode(R){i(R)&&(this.buffer+=s)}value(){return this.buffer}span(R){this.buffer+=`<span class="${R}">`}}const a=(E={})=>{const R={children:[]};return Object.assign(R,E),R};class c{constructor(){this.rootNode=a(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(R){this.top.children.push(R)}openNode(R){const B=a({scope:R});this.add(B),this.stack.push(B)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(R){return this.constructor._walk(R,this.rootNode)}static _walk(R,B){return typeof B=="string"?R.addText(B):B.children&&(R.openNode(B),B.children.forEach(re=>this._walk(R,re)),R.closeNode(B)),R}static _collapse(R){typeof R!="string"&&R.children&&(R.children.every(B=>typeof B=="string")?R.children=[R.children.join("")]:R.children.forEach(B=>{c._collapse(B)}))}}class d extends c{constructor(R){super(),this.options=R}addText(R){R!==""&&this.add(R)}startScope(R){this.openNode(R)}endScope(){this.closeNode()}__addSublanguage(R,B){const re=R.root;B&&(re.scope=`language:${B}`),this.add(re)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function u(E){return E?typeof E=="string"?E:E.source:null}function h(E){return g("(?=",E,")")}function f(E){return g("(?:",E,")*")}function p(E){return g("(?:",E,")?")}function g(...E){return E.map(B=>u(B)).join("")}function y(E){const R=E[E.length-1];return typeof R=="object"&&R.constructor===Object?(E.splice(E.length-1,1),R):{}}function b(...E){return"("+(y(E).capture?"":"?:")+E.map(re=>u(re)).join("|")+")"}function w(E){return new RegExp(E.toString()+"|").exec("").length-1}function M(E,R){const B=E&&E.exec(R);return B&&B.index===0}const S=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function A(E,{joinWith:R}){let B=0;return E.map(re=>{B+=1;const He=B;let ze=u(re),W="";for(;ze.length>0;){const U=S.exec(ze);if(!U){W+=ze;break}W+=ze.substring(0,U.index),ze=ze.substring(U.index+U[0].length),U[0][0]==="\\"&&U[1]?W+="\\"+String(Number(U[1])+He):(W+=U[0],U[0]==="("&&B++)}return W}).map(re=>`(${re})`).join(R)}const x=/\b\B/,k="[a-zA-Z]\\w*",v="[a-zA-Z_]\\w*",T="\\b\\d+(\\.\\d+)?",N="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",H="\\b(0b[01]+)",V="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",$=(E={})=>{const R=/^#![ ]*\//;return E.binary&&(E.begin=g(R,/.*\b/,E.binary,/\b.*/)),r({scope:"meta",begin:R,end:/$/,relevance:0,"on:begin":(B,re)=>{B.index!==0&&re.ignoreMatch()}},E)},I={begin:"\\\\[\\s\\S]",relevance:0},j={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[I]},Q={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[I]},ie={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/},F=function(E,R,B={}){const re=r({scope:"comment",begin:E,end:R,contains:[]},B);re.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 He=b("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 re.contains.push({begin:g(/[ ]+/,"(",He,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),re},ue=F("//","$"),xe=F("/\\*","\\*/"),_=F("#","$"),Z={scope:"number",begin:T,relevance:0},fe={scope:"number",begin:N,relevance:0},Se={scope:"number",begin:H,relevance:0},pn={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[I,{begin:/\[/,end:/\]/,relevance:0,contains:[I]}]},fr={scope:"title",begin:k,relevance:0},$e={scope:"title",begin:v,relevance:0},Ln={begin:"\\.\\s*"+v,relevance:0};var qr=Object.freeze({__proto__:null,APOS_STRING_MODE:j,BACKSLASH_ESCAPE:I,BINARY_NUMBER_MODE:Se,BINARY_NUMBER_RE:H,COMMENT:F,C_BLOCK_COMMENT_MODE:xe,C_LINE_COMMENT_MODE:ue,C_NUMBER_MODE:fe,C_NUMBER_RE:N,END_SAME_AS_BEGIN:function(E){return Object.assign(E,{"on:begin":(R,B)=>{B.data._beginMatch=R[1]},"on:end":(R,B)=>{B.data._beginMatch!==R[1]&&B.ignoreMatch()}})},HASH_COMMENT_MODE:_,IDENT_RE:k,MATCH_NOTHING_RE:x,METHOD_GUARD:Ln,NUMBER_MODE:Z,NUMBER_RE:T,PHRASAL_WORDS_MODE:ie,QUOTE_STRING_MODE:Q,REGEXP_MODE:pn,RE_STARTERS_RE:V,SHEBANG:$,TITLE_MODE:fr,UNDERSCORE_IDENT_RE:v,UNDERSCORE_TITLE_MODE:$e});function Cw(E,R){E.input[E.index-1]==="."&&R.ignoreMatch()}function Ew(E,R){E.className!==void 0&&(E.scope=E.className,delete E.className)}function Mw(E,R){R&&E.beginKeywords&&(E.begin="\\b("+E.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",E.__beforeBegin=Cw,E.keywords=E.keywords||E.beginKeywords,delete E.beginKeywords,E.relevance===void 0&&(E.relevance=0))}function Aw(E,R){Array.isArray(E.illegal)&&(E.illegal=b(...E.illegal))}function Tw(E,R){if(E.match){if(E.begin||E.end)throw new Error("begin & end are not supported with match");E.begin=E.match,delete E.match}}function Nw(E,R){E.relevance===void 0&&(E.relevance=1)}const _w=(E,R)=>{if(!E.beforeMatch)return;if(E.starts)throw new Error("beforeMatch cannot be used with starts");const B=Object.assign({},E);Object.keys(E).forEach(re=>{delete E[re]}),E.keywords=B.keywords,E.begin=g(B.beforeMatch,h(B.begin)),E.starts={relevance:0,contains:[Object.assign(B,{endsParent:!0})]},E.relevance=0,delete B.beforeMatch},Rw=["of","and","for","in","not","or","if","then","parent","list","value"],Ow="keyword";function Lh(E,R,B=Ow){const re=Object.create(null);return typeof E=="string"?He(B,E.split(" ")):Array.isArray(E)?He(B,E):Object.keys(E).forEach(function(ze){Object.assign(re,Lh(E[ze],R,ze))}),re;function He(ze,W){R&&(W=W.map(U=>U.toLowerCase())),W.forEach(function(U){const te=U.split("|");re[te[0]]=[ze,Dw(te[0],te[1])]})}}function Dw(E,R){return R?Number(R):Lw(E)?0:1}function Lw(E){return Rw.includes(E.toLowerCase())}const Ih={},pr=E=>{console.error(E)},jh=(E,...R)=>{console.log(`WARN: ${E}`,...R)},Kr=(E,R)=>{Ih[`${E}/${R}`]||(console.log(`Deprecated as of ${E}. ${R}`),Ih[`${E}/${R}`]=!0)},Qi=new Error;function Ph(E,R,{key:B}){let re=0;const He=E[B],ze={},W={};for(let U=1;U<=R.length;U++)W[U+re]=He[U],ze[U+re]=!0,re+=w(R[U-1]);E[B]=W,E[B]._emit=ze,E[B]._multi=!0}function Iw(E){if(Array.isArray(E.begin)){if(E.skip||E.excludeBegin||E.returnBegin)throw pr("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Qi;if(typeof E.beginScope!="object"||E.beginScope===null)throw pr("beginScope must be object"),Qi;Ph(E,E.begin,{key:"beginScope"}),E.begin=A(E.begin,{joinWith:""})}}function jw(E){if(Array.isArray(E.end)){if(E.skip||E.excludeEnd||E.returnEnd)throw pr("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Qi;if(typeof E.endScope!="object"||E.endScope===null)throw pr("endScope must be object"),Qi;Ph(E,E.end,{key:"endScope"}),E.end=A(E.end,{joinWith:""})}}function Pw(E){E.scope&&typeof E.scope=="object"&&E.scope!==null&&(E.beginScope=E.scope,delete E.scope)}function Bw(E){Pw(E),typeof E.beginScope=="string"&&(E.beginScope={_wrap:E.beginScope}),typeof E.endScope=="string"&&(E.endScope={_wrap:E.endScope}),Iw(E),jw(E)}function $w(E){function R(W,U){return new RegExp(u(W),"m"+(E.case_insensitive?"i":"")+(E.unicodeRegex?"u":"")+(U?"g":""))}class B{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(U,te){te.position=this.position++,this.matchIndexes[this.matchAt]=te,this.regexes.push([te,U]),this.matchAt+=w(U)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const U=this.regexes.map(te=>te[1]);this.matcherRe=R(A(U,{joinWith:"|"}),!0),this.lastIndex=0}exec(U){this.matcherRe.lastIndex=this.lastIndex;const te=this.matcherRe.exec(U);if(!te)return null;const Ye=te.findIndex((Ds,$a)=>$a>0&&Ds!==void 0),Ve=this.matchIndexes[Ye];return te.splice(0,Ye),Object.assign(te,Ve)}}class re{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(U){if(this.multiRegexes[U])return this.multiRegexes[U];const te=new B;return this.rules.slice(U).forEach(([Ye,Ve])=>te.addRule(Ye,Ve)),te.compile(),this.multiRegexes[U]=te,te}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(U,te){this.rules.push([U,te]),te.type==="begin"&&this.count++}exec(U){const te=this.getMatcher(this.regexIndex);te.lastIndex=this.lastIndex;let Ye=te.exec(U);if(this.resumingScanAtSamePosition()&&!(Ye&&Ye.index===this.lastIndex)){const Ve=this.getMatcher(0);Ve.lastIndex=this.lastIndex+1,Ye=Ve.exec(U)}return Ye&&(this.regexIndex+=Ye.position+1,this.regexIndex===this.count&&this.considerAll()),Ye}}function He(W){const U=new re;return W.contains.forEach(te=>U.addRule(te.begin,{rule:te,type:"begin"})),W.terminatorEnd&&U.addRule(W.terminatorEnd,{type:"end"}),W.illegal&&U.addRule(W.illegal,{type:"illegal"}),U}function ze(W,U){const te=W;if(W.isCompiled)return te;[Ew,Tw,Bw,_w].forEach(Ve=>Ve(W,U)),E.compilerExtensions.forEach(Ve=>Ve(W,U)),W.__beforeBegin=null,[Mw,Aw,Nw].forEach(Ve=>Ve(W,U)),W.isCompiled=!0;let Ye=null;return typeof W.keywords=="object"&&W.keywords.$pattern&&(W.keywords=Object.assign({},W.keywords),Ye=W.keywords.$pattern,delete W.keywords.$pattern),Ye=Ye||/\w+/,W.keywords&&(W.keywords=Lh(W.keywords,E.case_insensitive)),te.keywordPatternRe=R(Ye,!0),U&&(W.begin||(W.begin=/\B|\b/),te.beginRe=R(te.begin),!W.end&&!W.endsWithParent&&(W.end=/\B|\b/),W.end&&(te.endRe=R(te.end)),te.terminatorEnd=u(te.end)||"",W.endsWithParent&&U.terminatorEnd&&(te.terminatorEnd+=(W.end?"|":"")+U.terminatorEnd)),W.illegal&&(te.illegalRe=R(W.illegal)),W.contains||(W.contains=[]),W.contains=[].concat(...W.contains.map(function(Ve){return Hw(Ve==="self"?W:Ve)})),W.contains.forEach(function(Ve){ze(Ve,te)}),W.starts&&ze(W.starts,U),te.matcher=He(te),te}if(E.compilerExtensions||(E.compilerExtensions=[]),E.contains&&E.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return E.classNameAliases=r(E.classNameAliases||{}),ze(E)}function Bh(E){return E?E.endsWithParent||Bh(E.starts):!1}function Hw(E){return E.variants&&!E.cachedVariants&&(E.cachedVariants=E.variants.map(function(R){return r(E,{variants:null},R)})),E.cachedVariants?E.cachedVariants:Bh(E)?r(E,{starts:E.starts?r(E.starts):null}):Object.isFrozen(E)?r(E):E}var zw="11.11.1";class Fw extends Error{constructor(R,B){super(R),this.name="HTMLInjectionError",this.html=B}}const Ba=n,$h=r,Hh=Symbol("nomatch"),Uw=7,zh=function(E){const R=Object.create(null),B=Object.create(null),re=[];let He=!0;const ze="Could not find the language '{}', did you forget to load/include a language module?",W={disableAutodetect:!0,name:"Plain text",contains:[]};let U={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:d};function te(L){return U.noHighlightRe.test(L)}function Ye(L){let Y=L.className+" ";Y+=L.parentNode?L.parentNode.className:"";const he=U.languageDetectRe.exec(Y);if(he){const Me=In(he[1]);return Me||(jh(ze.replace("{}",he[1])),jh("Falling back to no-highlight mode for this block.",L)),Me?he[1]:"no-highlight"}return Y.split(/\s+/).find(Me=>te(Me)||In(Me))}function Ve(L,Y,he){let Me="",Je="";typeof Y=="object"?(Me=L,he=Y.ignoreIllegals,Je=Y.language):(Kr("10.7.0","highlight(lang, code, ...args) has been deprecated."),Kr("10.7.0",`Please use highlight(code, options) instead.
|
|
142
|
+
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(AA,this.editor.getAttributes(Lp)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=ms({find:Ip,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=ms({find:Ip,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Lp)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),TA=/^\s*(\[([( |x])?\])\s$/,Yb=Oe.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",pe(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const s=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Lu(t,e,s)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=d=>{var u,h;l.ariaLabel=((h=(u=this.options.a11y)==null?void 0:u.checkboxLabel)==null?void 0:h.call(u,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return c(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:u}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const f=n();if(typeof f!="number")return!1;const p=h.doc.nodeAt(f);return h.setNodeMarkup(f,void 0,{...p?.attrs,checked:u}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,u)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,u])=>{s.setAttribute(d,u)}),s.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,o),s.append(i,a),Object.entries(e).forEach(([d,u])=>{s.setAttribute(d,u)}),{dom:s,contentDOM:a,update:d=>d.type!==this.type?!1:(s.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d),!0)}}},addInputRules(){return[ms({find:TA,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Xb=Oe.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",pe(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
143
|
+
`):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=i=>{const o=ld(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(i)},s=ld(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});de.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Zu.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Fb.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Gb.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(eh.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Yb.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Xb.configure(this.options.taskList)),t}});var Zb=Oe.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",pe(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];return n.length===1&&n[0].type==="image"?e.parseChildren([n[0]]):e.createNode("paragraph",void 0,e.parseInline(n))},renderMarkdown:(t,e)=>!t||!Array.isArray(t.content)?"":e.renderChildren(t.content),addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),NA=Zb,_A=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,RA=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,OA=Zt.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",pe(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Lr({find:_A,type:this.type})]},addPasteRules(){return[sr({find:RA,type:this.type})]}}),DA=Oe.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Qb=Zt.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",pe(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!s)return;const i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),LA=Qb;function IA(t={}){return new me({view(e){return new jA(e,t)}})}class jA{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let u=e.nodeBefore,h=e.nodeAfter;if(u||h){let f=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(f){let p=f.getBoundingClientRect(),g=u?p.bottom:p.top;u&&h&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:p.left,right:p.right,top:g-y,bottom:g+y}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*o;r={left:u.left-h,right:u.left+h,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),h=u.width/a.offsetWidth,f=u.height/a.offsetHeight;c=u.left-a.scrollLeft*h,d=u.top-a.scrollTop*f}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Og(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class je extends ee{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return je.valid(r)?new je(r):ee.near(r)}content(){return P.empty}eq(e){return e instanceof je&&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 je(e.resolve(n.pos))}getBookmark(){return new th(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!PA(e)||!BA(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&je.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let a=e.doc.resolve(s);if(je.valid(a))return a}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!q.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let l=e.doc.resolve(s);if(je.valid(l))return l}return null}}}je.prototype.visible=!1;je.findFrom=je.findGapCursorFrom;ee.jsonID("gapcursor",je);class th{constructor(e){this.pos=e}map(e){return new th(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return je.valid(n)?new je(n):ee.near(n)}}function e0(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function PA(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||e0(s.type))return!0;if(s.inlineContent)return!1}}return!0}function BA(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||e0(s.type))return!0;if(s.inlineContent)return!1}}return!0}function $A(){return new me({props:{decorations:UA,createSelectionBetween(t,e,n){return e.pos==n.pos&&je.valid(n)?new je(n):null},handleClick:zA,handleKeyDown:HA,handleDOMEvents:{beforeinput:FA}}})}const HA=Su({ArrowLeft:wo("horiz",-1),ArrowRight:wo("horiz",1),ArrowUp:wo("vert",-1),ArrowDown:wo("vert",1)});function wo(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof J){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=je.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new je(c))),!0):!1}}function zA(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!je.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&q.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new je(r))),!0)}function FA(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof je))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=O.empty;for(let o=r.length-1;o>=0;o--)s=O.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new P(s,0,0));return i.setSelection(J.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function UA(t){if(!(t.selection instanceof je))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",be.create(t.doc,[_e.widget(t.selection.head,e,{key:"gapcursor"})])}var Il=200,et=function(){};et.prototype.append=function(e){return e.length?(e=et.from(e),!this.length&&e||e.length<Il&&this.leafAppend(e)||this.length<Il&&e.leafPrepend(this)||this.appendInner(e)):this};et.prototype.prepend=function(e){return e.length?et.from(e).append(this):this};et.prototype.appendInner=function(e){return new VA(this,e)};et.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?et.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};et.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};et.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)};et.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},n,r),s};et.from=function(e){return e instanceof et?e:e&&e.length?new t0(e):et.empty};var t0=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Il)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Il)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(et);et.empty=new t0([]);var VA=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(et);const WA=500;class Ut{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],d=[];return this.items.forEach((u,h)=>{if(!u.step){s||(s=this.remapping(r,h+1),i=s.maps.length),i--,d.push(u);return}if(s){d.push(new Bn(u.map));let f=u.step.map(s.slice(i)),p;f&&o.maybeStep(f).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Bn(p,void 0,void 0,c.length+d.length))),i--,p&&s.appendMap(p,i)}else o.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(i)):u.selection,a=new Ut(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,n,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),h=new Bn(e.mapping.maps[d],u,n),f;(f=a&&a.merge(h))&&(h=f,d?i.pop():l=l.slice(0,l.length-1)),i.push(h),n&&(o++,n=void 0),s||(a=h)}let c=o-r.depth;return c>KA&&(l=qA(l,c),o-=c),new Ut(l.append(i),o)}remapping(e,n){let r=new ai;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new Ut(this.items.append(e.map(n=>new Bn(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},s);let a=n;this.items.forEach(h=>{let f=i.getMirror(--a);if(f==null)return;o=Math.min(o,f);let p=i.maps[f];if(h.step){let g=e.steps[f].invert(e.docs[f]),y=h.selection&&h.selection.map(i.slice(a+1,f));y&&l++,r.push(new Bn(p,g,y))}else r.push(new Bn(p))},s);let c=[];for(let h=n;h<o;h++)c.push(new Bn(i.maps[h]));let d=this.items.slice(0,s).append(c).append(r),u=new Ut(d,l);return u.emptyItemCount()>WA&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let d=o.selection&&o.selection.map(n.slice(r));d&&i++;let u=new Bn(c.invert(),a,d),h,f=s.length-1;(h=s.length&&s[f].merge(u))?s[f]=h:s.push(u)}}else o.map&&r--},this.items.length,0),new Ut(et.from(s.reverse()),i)}}Ut.empty=new Ut(et.empty,0);function qA(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}let Bn=class n0{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new n0(n.getMap().invert(),n,this.selection)}}};class Un{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const KA=20;function GA(t,e,n,r){let s=n.getMeta(Ar),i;if(s)return s.historyState;n.getMeta(XA)&&(t=new Un(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Ar))return o.getMeta(Ar).redo?new Un(t.done.addTransform(n,void 0,r,jo(e)),t.undone,jp(n.mapping.maps),t.prevTime,t.prevComposition):new Un(t.done,t.undone.addTransform(n,void 0,r,jo(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!JA(n,t.prevRanges)),c=o?vc(t.prevRanges,n.mapping):jp(n.mapping.maps);return new Un(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,jo(e)),Ut.empty,c,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Un(t.done.rebased(n,i),t.undone.rebased(n,i),vc(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Un(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),vc(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function JA(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function jp(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function vc(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function YA(t,e,n){let r=jo(e),s=Ar.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new Un(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(Ar,{redo:n,historyState:a})}let Sc=!1,Pp=null;function jo(t){let e=t.plugins;if(Pp!=e){Sc=!1,Pp=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Sc=!0;break}}return Sc}const Ar=new ye("history"),XA=new ye("closeHistory");function ZA(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new me({key:Ar,state:{init(){return new Un(Ut.empty,Ut.empty,null,0,-1)},apply(e,n,r){return GA(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?s0:r=="historyRedo"?i0:null;return s?(n.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function r0(t,e){return(n,r)=>{let s=Ar.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=YA(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const s0=r0(!1,!0),i0=r0(!0,!0);var QA=de.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new me({key:new ye("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit;if(s==null||s===0){t=!0;return}const i=this.storage.characters({node:r.doc});if(i>s){const o=i-s,l=0,a=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return t=!0,c}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=i-r,c=l-a,d=l;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>r)}})]}}),eT=de.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[IA(this.options)]}});de.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new me({key:new ye("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return be.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(_e.node(c,c+a.nodeSize,{class:this.options.className}))}),be.create(t,i)}}})]}});var o0=de.create({name:"gapCursor",addProseMirrorPlugins(){return[$A()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=we(G(t,"allowGapCursor",n)))!=null?e:null}}}),tT=de.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new me({key:new ye("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(!n)return null;const i=this.editor.isEmpty;return t.descendants((o,l)=>{const a=r>=l&&r<=l+o.nodeSize,c=!o.isLeaf&&Li(o);if((a||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];i&&d.push(this.options.emptyEditorClass);const u=_e.node(l,l+o.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:a}):this.options.placeholder});s.push(u)}return this.options.includeChildren}),be.create(t,s)}}})]}});de.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new me({key:new ye("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Gy(n.selection)||t.view.dragging?null:be.create(n.doc,[_e.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Bp({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var nT=de.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ye(this.name),n=((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||this.options.node||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new me({key:e,appendTransaction:(s,i,o)=>{const{doc:l,tr:a,schema:c}=o,d=e.getState(o),u=l.content.size,h=c.nodes[n];if(d)return a.insert(u,h.create())},state:{init:(s,i)=>{const o=i.tr.doc.lastChild;return!Bp({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged)return i;const o=s.doc.lastChild;return!Bp({node:o,types:r})}}})]}}),l0=de.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>s0(t,e),redo:()=>({state:t,dispatch:e})=>i0(t,e)}},addProseMirrorPlugins(){return[ZA(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()}}}),rT=de.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(OM.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(Nb.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(Zu.configure(this.options.bulletList)),this.options.code!==!1&&s.push(IM.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(_b.configure(this.options.codeBlock)),this.options.document!==!1&&s.push($M.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(eT.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(o0.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(HM.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(Rb.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(l0.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(FM.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(KM.configure(this.options.italic)),this.options.listItem!==!1&&s.push(Fb.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(Gb.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(zb.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(eh.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(Zb.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(OA.configure(this.options.strike)),this.options.text!==!1&&s.push(DA.configure(this.options.text)),this.options.underline!==!1&&s.push(Qb.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(nT.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),sT=rT,Cc,$p;function iT(){if($p)return Cc;$p=1;function t(E){return E instanceof Map?E.clear=E.delete=E.set=function(){throw new Error("map is read-only")}:E instanceof Set&&(E.add=E.clear=E.delete=function(){throw new Error("set is read-only")}),Object.freeze(E),Object.getOwnPropertyNames(E).forEach(R=>{const B=E[R],re=typeof B;(re==="object"||re==="function")&&!Object.isFrozen(B)&&t(B)}),E}class e{constructor(R){R.data===void 0&&(R.data={}),this.data=R.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(E){return E.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function r(E,...R){const B=Object.create(null);for(const re in E)B[re]=E[re];return R.forEach(function(re){for(const He in re)B[He]=re[He]}),B}const s="</span>",i=E=>!!E.scope,o=(E,{prefix:R})=>{if(E.startsWith("language:"))return E.replace("language:","language-");if(E.includes(".")){const B=E.split(".");return[`${R}${B.shift()}`,...B.map((re,He)=>`${re}${"_".repeat(He+1)}`)].join(" ")}return`${R}${E}`};class l{constructor(R,B){this.buffer="",this.classPrefix=B.classPrefix,R.walk(this)}addText(R){this.buffer+=n(R)}openNode(R){if(!i(R))return;const B=o(R.scope,{prefix:this.classPrefix});this.span(B)}closeNode(R){i(R)&&(this.buffer+=s)}value(){return this.buffer}span(R){this.buffer+=`<span class="${R}">`}}const a=(E={})=>{const R={children:[]};return Object.assign(R,E),R};class c{constructor(){this.rootNode=a(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(R){this.top.children.push(R)}openNode(R){const B=a({scope:R});this.add(B),this.stack.push(B)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(R){return this.constructor._walk(R,this.rootNode)}static _walk(R,B){return typeof B=="string"?R.addText(B):B.children&&(R.openNode(B),B.children.forEach(re=>this._walk(R,re)),R.closeNode(B)),R}static _collapse(R){typeof R!="string"&&R.children&&(R.children.every(B=>typeof B=="string")?R.children=[R.children.join("")]:R.children.forEach(B=>{c._collapse(B)}))}}class d extends c{constructor(R){super(),this.options=R}addText(R){R!==""&&this.add(R)}startScope(R){this.openNode(R)}endScope(){this.closeNode()}__addSublanguage(R,B){const re=R.root;B&&(re.scope=`language:${B}`),this.add(re)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function u(E){return E?typeof E=="string"?E:E.source:null}function h(E){return g("(?=",E,")")}function f(E){return g("(?:",E,")*")}function p(E){return g("(?:",E,")?")}function g(...E){return E.map(B=>u(B)).join("")}function y(E){const R=E[E.length-1];return typeof R=="object"&&R.constructor===Object?(E.splice(E.length-1,1),R):{}}function b(...E){return"("+(y(E).capture?"":"?:")+E.map(re=>u(re)).join("|")+")"}function w(E){return new RegExp(E.toString()+"|").exec("").length-1}function M(E,R){const B=E&&E.exec(R);return B&&B.index===0}const S=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function A(E,{joinWith:R}){let B=0;return E.map(re=>{B+=1;const He=B;let ze=u(re),W="";for(;ze.length>0;){const U=S.exec(ze);if(!U){W+=ze;break}W+=ze.substring(0,U.index),ze=ze.substring(U.index+U[0].length),U[0][0]==="\\"&&U[1]?W+="\\"+String(Number(U[1])+He):(W+=U[0],U[0]==="("&&B++)}return W}).map(re=>`(${re})`).join(R)}const x=/\b\B/,k="[a-zA-Z]\\w*",v="[a-zA-Z_]\\w*",T="\\b\\d+(\\.\\d+)?",N="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",H="\\b(0b[01]+)",V="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",$=(E={})=>{const R=/^#![ ]*\//;return E.binary&&(E.begin=g(R,/.*\b/,E.binary,/\b.*/)),r({scope:"meta",begin:R,end:/$/,relevance:0,"on:begin":(B,re)=>{B.index!==0&&re.ignoreMatch()}},E)},I={begin:"\\\\[\\s\\S]",relevance:0},j={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[I]},Q={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[I]},ie={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/},F=function(E,R,B={}){const re=r({scope:"comment",begin:E,end:R,contains:[]},B);re.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 He=b("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 re.contains.push({begin:g(/[ ]+/,"(",He,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),re},ue=F("//","$"),xe=F("/\\*","\\*/"),_=F("#","$"),Z={scope:"number",begin:T,relevance:0},fe={scope:"number",begin:N,relevance:0},Se={scope:"number",begin:H,relevance:0},pn={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[I,{begin:/\[/,end:/\]/,relevance:0,contains:[I]}]},fr={scope:"title",begin:k,relevance:0},$e={scope:"title",begin:v,relevance:0},Ln={begin:"\\.\\s*"+v,relevance:0};var qr=Object.freeze({__proto__:null,APOS_STRING_MODE:j,BACKSLASH_ESCAPE:I,BINARY_NUMBER_MODE:Se,BINARY_NUMBER_RE:H,COMMENT:F,C_BLOCK_COMMENT_MODE:xe,C_LINE_COMMENT_MODE:ue,C_NUMBER_MODE:fe,C_NUMBER_RE:N,END_SAME_AS_BEGIN:function(E){return Object.assign(E,{"on:begin":(R,B)=>{B.data._beginMatch=R[1]},"on:end":(R,B)=>{B.data._beginMatch!==R[1]&&B.ignoreMatch()}})},HASH_COMMENT_MODE:_,IDENT_RE:k,MATCH_NOTHING_RE:x,METHOD_GUARD:Ln,NUMBER_MODE:Z,NUMBER_RE:T,PHRASAL_WORDS_MODE:ie,QUOTE_STRING_MODE:Q,REGEXP_MODE:pn,RE_STARTERS_RE:V,SHEBANG:$,TITLE_MODE:fr,UNDERSCORE_IDENT_RE:v,UNDERSCORE_TITLE_MODE:$e});function Cw(E,R){E.input[E.index-1]==="."&&R.ignoreMatch()}function Ew(E,R){E.className!==void 0&&(E.scope=E.className,delete E.className)}function Mw(E,R){R&&E.beginKeywords&&(E.begin="\\b("+E.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",E.__beforeBegin=Cw,E.keywords=E.keywords||E.beginKeywords,delete E.beginKeywords,E.relevance===void 0&&(E.relevance=0))}function Aw(E,R){Array.isArray(E.illegal)&&(E.illegal=b(...E.illegal))}function Tw(E,R){if(E.match){if(E.begin||E.end)throw new Error("begin & end are not supported with match");E.begin=E.match,delete E.match}}function Nw(E,R){E.relevance===void 0&&(E.relevance=1)}const _w=(E,R)=>{if(!E.beforeMatch)return;if(E.starts)throw new Error("beforeMatch cannot be used with starts");const B=Object.assign({},E);Object.keys(E).forEach(re=>{delete E[re]}),E.keywords=B.keywords,E.begin=g(B.beforeMatch,h(B.begin)),E.starts={relevance:0,contains:[Object.assign(B,{endsParent:!0})]},E.relevance=0,delete B.beforeMatch},Rw=["of","and","for","in","not","or","if","then","parent","list","value"],Ow="keyword";function Lh(E,R,B=Ow){const re=Object.create(null);return typeof E=="string"?He(B,E.split(" ")):Array.isArray(E)?He(B,E):Object.keys(E).forEach(function(ze){Object.assign(re,Lh(E[ze],R,ze))}),re;function He(ze,W){R&&(W=W.map(U=>U.toLowerCase())),W.forEach(function(U){const te=U.split("|");re[te[0]]=[ze,Dw(te[0],te[1])]})}}function Dw(E,R){return R?Number(R):Lw(E)?0:1}function Lw(E){return Rw.includes(E.toLowerCase())}const Ih={},pr=E=>{console.error(E)},jh=(E,...R)=>{console.log(`WARN: ${E}`,...R)},Kr=(E,R)=>{Ih[`${E}/${R}`]||(console.log(`Deprecated as of ${E}. ${R}`),Ih[`${E}/${R}`]=!0)},Qi=new Error;function Ph(E,R,{key:B}){let re=0;const He=E[B],ze={},W={};for(let U=1;U<=R.length;U++)W[U+re]=He[U],ze[U+re]=!0,re+=w(R[U-1]);E[B]=W,E[B]._emit=ze,E[B]._multi=!0}function Iw(E){if(Array.isArray(E.begin)){if(E.skip||E.excludeBegin||E.returnBegin)throw pr("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Qi;if(typeof E.beginScope!="object"||E.beginScope===null)throw pr("beginScope must be object"),Qi;Ph(E,E.begin,{key:"beginScope"}),E.begin=A(E.begin,{joinWith:""})}}function jw(E){if(Array.isArray(E.end)){if(E.skip||E.excludeEnd||E.returnEnd)throw pr("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Qi;if(typeof E.endScope!="object"||E.endScope===null)throw pr("endScope must be object"),Qi;Ph(E,E.end,{key:"endScope"}),E.end=A(E.end,{joinWith:""})}}function Pw(E){E.scope&&typeof E.scope=="object"&&E.scope!==null&&(E.beginScope=E.scope,delete E.scope)}function Bw(E){Pw(E),typeof E.beginScope=="string"&&(E.beginScope={_wrap:E.beginScope}),typeof E.endScope=="string"&&(E.endScope={_wrap:E.endScope}),Iw(E),jw(E)}function $w(E){function R(W,U){return new RegExp(u(W),"m"+(E.case_insensitive?"i":"")+(E.unicodeRegex?"u":"")+(U?"g":""))}class B{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(U,te){te.position=this.position++,this.matchIndexes[this.matchAt]=te,this.regexes.push([te,U]),this.matchAt+=w(U)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const U=this.regexes.map(te=>te[1]);this.matcherRe=R(A(U,{joinWith:"|"}),!0),this.lastIndex=0}exec(U){this.matcherRe.lastIndex=this.lastIndex;const te=this.matcherRe.exec(U);if(!te)return null;const Ye=te.findIndex((Ds,$a)=>$a>0&&Ds!==void 0),Ve=this.matchIndexes[Ye];return te.splice(0,Ye),Object.assign(te,Ve)}}class re{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(U){if(this.multiRegexes[U])return this.multiRegexes[U];const te=new B;return this.rules.slice(U).forEach(([Ye,Ve])=>te.addRule(Ye,Ve)),te.compile(),this.multiRegexes[U]=te,te}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(U,te){this.rules.push([U,te]),te.type==="begin"&&this.count++}exec(U){const te=this.getMatcher(this.regexIndex);te.lastIndex=this.lastIndex;let Ye=te.exec(U);if(this.resumingScanAtSamePosition()&&!(Ye&&Ye.index===this.lastIndex)){const Ve=this.getMatcher(0);Ve.lastIndex=this.lastIndex+1,Ye=Ve.exec(U)}return Ye&&(this.regexIndex+=Ye.position+1,this.regexIndex===this.count&&this.considerAll()),Ye}}function He(W){const U=new re;return W.contains.forEach(te=>U.addRule(te.begin,{rule:te,type:"begin"})),W.terminatorEnd&&U.addRule(W.terminatorEnd,{type:"end"}),W.illegal&&U.addRule(W.illegal,{type:"illegal"}),U}function ze(W,U){const te=W;if(W.isCompiled)return te;[Ew,Tw,Bw,_w].forEach(Ve=>Ve(W,U)),E.compilerExtensions.forEach(Ve=>Ve(W,U)),W.__beforeBegin=null,[Mw,Aw,Nw].forEach(Ve=>Ve(W,U)),W.isCompiled=!0;let Ye=null;return typeof W.keywords=="object"&&W.keywords.$pattern&&(W.keywords=Object.assign({},W.keywords),Ye=W.keywords.$pattern,delete W.keywords.$pattern),Ye=Ye||/\w+/,W.keywords&&(W.keywords=Lh(W.keywords,E.case_insensitive)),te.keywordPatternRe=R(Ye,!0),U&&(W.begin||(W.begin=/\B|\b/),te.beginRe=R(te.begin),!W.end&&!W.endsWithParent&&(W.end=/\B|\b/),W.end&&(te.endRe=R(te.end)),te.terminatorEnd=u(te.end)||"",W.endsWithParent&&U.terminatorEnd&&(te.terminatorEnd+=(W.end?"|":"")+U.terminatorEnd)),W.illegal&&(te.illegalRe=R(W.illegal)),W.contains||(W.contains=[]),W.contains=[].concat(...W.contains.map(function(Ve){return Hw(Ve==="self"?W:Ve)})),W.contains.forEach(function(Ve){ze(Ve,te)}),W.starts&&ze(W.starts,U),te.matcher=He(te),te}if(E.compilerExtensions||(E.compilerExtensions=[]),E.contains&&E.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return E.classNameAliases=r(E.classNameAliases||{}),ze(E)}function Bh(E){return E?E.endsWithParent||Bh(E.starts):!1}function Hw(E){return E.variants&&!E.cachedVariants&&(E.cachedVariants=E.variants.map(function(R){return r(E,{variants:null},R)})),E.cachedVariants?E.cachedVariants:Bh(E)?r(E,{starts:E.starts?r(E.starts):null}):Object.isFrozen(E)?r(E):E}var zw="11.11.1";class Fw extends Error{constructor(R,B){super(R),this.name="HTMLInjectionError",this.html=B}}const Ba=n,$h=r,Hh=Symbol("nomatch"),Uw=7,zh=function(E){const R=Object.create(null),B=Object.create(null),re=[];let He=!0;const ze="Could not find the language '{}', did you forget to load/include a language module?",W={disableAutodetect:!0,name:"Plain text",contains:[]};let U={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:d};function te(L){return U.noHighlightRe.test(L)}function Ye(L){let Y=L.className+" ";Y+=L.parentNode?L.parentNode.className:"";const he=U.languageDetectRe.exec(Y);if(he){const Me=In(he[1]);return Me||(jh(ze.replace("{}",he[1])),jh("Falling back to no-highlight mode for this block.",L)),Me?he[1]:"no-highlight"}return Y.split(/\s+/).find(Me=>te(Me)||In(Me))}function Ve(L,Y,he){let Me="",Je="";typeof Y=="object"?(Me=L,he=Y.ignoreIllegals,Je=Y.language):(Kr("10.7.0","highlight(lang, code, ...args) has been deprecated."),Kr("10.7.0",`Please use highlight(code, options) instead.
|
|
144
144
|
https://github.com/highlightjs/highlight.js/issues/2277`),Je=L,Me=Y),he===void 0&&(he=!0);const zt={code:Me,language:Je};to("before:highlight",zt);const jn=zt.result?zt.result:Ds(zt.language,zt.code,he);return jn.code=zt.code,to("after:highlight",jn),jn}function Ds(L,Y,he,Me){const Je=Object.create(null);function zt(z,K){return z.keywords[K]}function jn(){if(!se.keywords){nt.addText(Ae);return}let z=0;se.keywordPatternRe.lastIndex=0;let K=se.keywordPatternRe.exec(Ae),ae="";for(;K;){ae+=Ae.substring(z,K.index);const ke=nn.case_insensitive?K[0].toLowerCase():K[0],lt=zt(se,ke);if(lt){const[mn,o1]=lt;if(nt.addText(ae),ae="",Je[ke]=(Je[ke]||0)+1,Je[ke]<=Uw&&(so+=o1),mn.startsWith("_"))ae+=K[0];else{const l1=nn.classNameAliases[mn]||mn;tn(K[0],l1)}}else ae+=K[0];z=se.keywordPatternRe.lastIndex,K=se.keywordPatternRe.exec(Ae)}ae+=Ae.substring(z),nt.addText(ae)}function no(){if(Ae==="")return;let z=null;if(typeof se.subLanguage=="string"){if(!R[se.subLanguage]){nt.addText(Ae);return}z=Ds(se.subLanguage,Ae,!0,Jh[se.subLanguage]),Jh[se.subLanguage]=z._top}else z=Ha(Ae,se.subLanguage.length?se.subLanguage:null);se.relevance>0&&(so+=z.relevance),nt.__addSublanguage(z._emitter,z.language)}function At(){se.subLanguage!=null?no():jn(),Ae=""}function tn(z,K){z!==""&&(nt.startScope(K),nt.addText(z),nt.endScope())}function Wh(z,K){let ae=1;const ke=K.length-1;for(;ae<=ke;){if(!z._emit[ae]){ae++;continue}const lt=nn.classNameAliases[z[ae]]||z[ae],mn=K[ae];lt?tn(mn,lt):(Ae=mn,jn(),Ae=""),ae++}}function qh(z,K){return z.scope&&typeof z.scope=="string"&&nt.openNode(nn.classNameAliases[z.scope]||z.scope),z.beginScope&&(z.beginScope._wrap?(tn(Ae,nn.classNameAliases[z.beginScope._wrap]||z.beginScope._wrap),Ae=""):z.beginScope._multi&&(Wh(z.beginScope,K),Ae="")),se=Object.create(z,{parent:{value:se}}),se}function Kh(z,K,ae){let ke=M(z.endRe,ae);if(ke){if(z["on:end"]){const lt=new e(z);z["on:end"](K,lt),lt.isMatchIgnored&&(ke=!1)}if(ke){for(;z.endsParent&&z.parent;)z=z.parent;return z}}if(z.endsWithParent)return Kh(z.parent,K,ae)}function t1(z){return se.matcher.regexIndex===0?(Ae+=z[0],1):(Va=!0,0)}function n1(z){const K=z[0],ae=z.rule,ke=new e(ae),lt=[ae.__beforeBegin,ae["on:begin"]];for(const mn of lt)if(mn&&(mn(z,ke),ke.isMatchIgnored))return t1(K);return ae.skip?Ae+=K:(ae.excludeBegin&&(Ae+=K),At(),!ae.returnBegin&&!ae.excludeBegin&&(Ae=K)),qh(ae,z),ae.returnBegin?0:K.length}function r1(z){const K=z[0],ae=Y.substring(z.index),ke=Kh(se,z,ae);if(!ke)return Hh;const lt=se;se.endScope&&se.endScope._wrap?(At(),tn(K,se.endScope._wrap)):se.endScope&&se.endScope._multi?(At(),Wh(se.endScope,z)):lt.skip?Ae+=K:(lt.returnEnd||lt.excludeEnd||(Ae+=K),At(),lt.excludeEnd&&(Ae=K));do se.scope&&nt.closeNode(),!se.skip&&!se.subLanguage&&(so+=se.relevance),se=se.parent;while(se!==ke.parent);return ke.starts&&qh(ke.starts,z),lt.returnEnd?0:K.length}function s1(){const z=[];for(let K=se;K!==nn;K=K.parent)K.scope&&z.unshift(K.scope);z.forEach(K=>nt.openNode(K))}let ro={};function Gh(z,K){const ae=K&&K[0];if(Ae+=z,ae==null)return At(),0;if(ro.type==="begin"&&K.type==="end"&&ro.index===K.index&&ae===""){if(Ae+=Y.slice(K.index,K.index+1),!He){const ke=new Error(`0 width match regex (${L})`);throw ke.languageName=L,ke.badRule=ro.rule,ke}return 1}if(ro=K,K.type==="begin")return n1(K);if(K.type==="illegal"&&!he){const ke=new Error('Illegal lexeme "'+ae+'" for mode "'+(se.scope||"<unnamed>")+'"');throw ke.mode=se,ke}else if(K.type==="end"){const ke=r1(K);if(ke!==Hh)return ke}if(K.type==="illegal"&&ae==="")return Ae+=`
|
|
145
|
-
`,1;if(Ua>1e5&&Ua>K.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Ae+=ae,ae.length}const nn=In(L);if(!nn)throw pr(ze.replace("{}",L)),new Error('Unknown language: "'+L+'"');const i1=$w(nn);let Fa="",se=Me||i1;const Jh={},nt=new U.__emitter(U);s1();let Ae="",so=0,mr=0,Ua=0,Va=!1;try{if(nn.__emitTokens)nn.__emitTokens(Y,nt);else{for(se.matcher.considerAll();;){Ua++,Va?Va=!1:se.matcher.considerAll(),se.matcher.lastIndex=mr;const z=se.matcher.exec(Y);if(!z)break;const K=Y.substring(mr,z.index),ae=Gh(K,z);mr=z.index+ae}Gh(Y.substring(mr))}return nt.finalize(),Fa=nt.toHTML(),{language:L,value:Fa,relevance:so,illegal:!1,_emitter:nt,_top:se}}catch(z){if(z.message&&z.message.includes("Illegal"))return{language:L,value:Ba(Y),illegal:!0,relevance:0,_illegalBy:{message:z.message,index:mr,context:Y.slice(mr-100,mr+100),mode:z.mode,resultSoFar:Fa},_emitter:nt};if(He)return{language:L,value:Ba(Y),illegal:!1,relevance:0,errorRaised:z,_emitter:nt,_top:se};throw z}}function $a(L){const Y={value:Ba(L),illegal:!1,relevance:0,_top:W,_emitter:new U.__emitter(U)};return Y._emitter.addText(L),Y}function Ha(L,Y){Y=Y||U.languages||Object.keys(R);const he=$a(L),Me=Y.filter(In).filter(Vh).map(At=>Ds(At,L,!1));Me.unshift(he);const Je=Me.sort((At,tn)=>{if(At.relevance!==tn.relevance)return tn.relevance-At.relevance;if(At.language&&tn.language){if(In(At.language).supersetOf===tn.language)return 1;if(In(tn.language).supersetOf===At.language)return-1}return 0}),[zt,jn]=Je,no=zt;return no.secondBest=jn,no}function Vw(L,Y,he){const Me=Y&&B[Y]||he;L.classList.add("hljs"),L.classList.add(`language-${Me}`)}function za(L){let Y=null;const he=Ye(L);if(te(he))return;if(to("before:highlightElement",{el:L,language:he}),L.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",L);return}if(L.children.length>0&&(U.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(L)),U.throwUnescapedHTML))throw new Fw("One of your code blocks includes unescaped HTML.",L.innerHTML);Y=L;const Me=Y.textContent,Je=he?Ve(Me,{language:he,ignoreIllegals:!0}):Ha(Me);L.innerHTML=Je.value,L.dataset.highlighted="yes",Vw(L,he,Je.language),L.result={language:Je.language,re:Je.relevance,relevance:Je.relevance},Je.secondBest&&(L.secondBest={language:Je.secondBest.language,relevance:Je.secondBest.relevance}),to("after:highlightElement",{el:L,result:Je,text:Me})}function Ww(L){U=$h(U,L)}const qw=()=>{eo(),Kr("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Kw(){eo(),Kr("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Fh=!1;function eo(){function L(){eo()}if(document.readyState==="loading"){Fh||window.addEventListener("DOMContentLoaded",L,!1),Fh=!0;return}document.querySelectorAll(U.cssSelector).forEach(za)}function Gw(L,Y){let he=null;try{he=Y(E)}catch(Me){if(pr("Language definition for '{}' could not be registered.".replace("{}",L)),He)pr(Me);else throw Me;he=W}he.name||(he.name=L),R[L]=he,he.rawDefinition=Y.bind(null,E),he.aliases&&Uh(he.aliases,{languageName:L})}function Jw(L){delete R[L];for(const Y of Object.keys(B))B[Y]===L&&delete B[Y]}function Yw(){return Object.keys(R)}function In(L){return L=(L||"").toLowerCase(),R[L]||R[B[L]]}function Uh(L,{languageName:Y}){typeof L=="string"&&(L=[L]),L.forEach(he=>{B[he.toLowerCase()]=Y})}function Vh(L){const Y=In(L);return Y&&!Y.disableAutodetect}function Xw(L){L["before:highlightBlock"]&&!L["before:highlightElement"]&&(L["before:highlightElement"]=Y=>{L["before:highlightBlock"](Object.assign({block:Y.el},Y))}),L["after:highlightBlock"]&&!L["after:highlightElement"]&&(L["after:highlightElement"]=Y=>{L["after:highlightBlock"](Object.assign({block:Y.el},Y))})}function Zw(L){Xw(L),re.push(L)}function Qw(L){const Y=re.indexOf(L);Y!==-1&&re.splice(Y,1)}function to(L,Y){const he=L;re.forEach(function(Me){Me[he]&&Me[he](Y)})}function e1(L){return Kr("10.7.0","highlightBlock will be removed entirely in v12.0"),Kr("10.7.0","Please use highlightElement now."),za(L)}Object.assign(E,{highlight:Ve,highlightAuto:Ha,highlightAll:eo,highlightElement:za,highlightBlock:e1,configure:Ww,initHighlighting:qw,initHighlightingOnLoad:Kw,registerLanguage:Gw,unregisterLanguage:Jw,listLanguages:Yw,getLanguage:In,registerAliases:Uh,autoDetection:Vh,inherit:$h,addPlugin:Zw,removePlugin:Qw}),E.debugMode=function(){He=!1},E.safeMode=function(){He=!0},E.versionString=zw,E.regex={concat:g,lookahead:h,either:b,optional:p,anyNumberOfTimes:f};for(const L in qr)typeof qr[L]=="object"&&t(qr[L]);return Object.assign(E,qr),E},Gr=zh({});return Gr.newInstance=()=>zh({}),Cc=Gr,Gr.HighlightJS=Gr,Gr.default=Gr,Cc}var oT=iT();const a0=sg(oT);function c0(t,e=[]){return t.flatMap(n=>{const r=[...e,...n.properties?n.properties.className:[]];return n.children?c0(n.children,r):{text:n.value,classes:r}})}function Hp(t){return t.value||t.children||[]}function lT(t){return!!a0.getLanguage(t)}function zp({doc:t,name:e,lowlight:n,defaultLanguage:r}){const s=[];return sd(t,i=>i.type.name===e).forEach(i=>{var o;let l=i.pos+1;const a=i.node.attrs.language||r,c=n.listLanguages(),d=a&&(c.includes(a)||lT(a)||(o=n.registered)!=null&&o.call(n,a))?Hp(n.highlight(a,i.node.textContent)):Hp(n.highlightAuto(i.node.textContent));c0(d).forEach(u=>{const h=l+u.text.length;if(u.classes.length){const f=_e.inline(l,h,{class:u.classes.join(" ")});s.push(f)}l=h})}),ye.create(t,s)}function aT(t){return typeof t=="function"}function cT({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(s=>aT(e[s])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new pe({key:new ge("lowlight"),state:{init:(s,{doc:i})=>zp({doc:i,name:t,lowlight:e,defaultLanguage:n}),apply:(s,i,o,l)=>{const a=o.selection.$head.parent.type.name,c=l.selection.$head.parent.type.name,d=sd(o.doc,h=>h.type.name===t),u=sd(l.doc,h=>h.type.name===t);return s.docChanged&&([a,c].includes(t)||u.length!==d.length||s.steps.some(h=>h.from!==void 0&&h.to!==void 0&&d.some(f=>f.pos>=h.from&&f.pos+f.node.nodeSize<=h.to)))?zp({doc:s.doc,name:t,lowlight:e,defaultLanguage:n}):i.map(s.mapping,s.doc)}},props:{decorations(s){return r.getState(s)}}});return r}var dT=BM.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],cT({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),d0=dT,uT=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,hT=De.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},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},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",be(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,s,i,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",a=(s=(r=t.attrs)==null?void 0:r.alt)!=null?s:"",c=(o=(i=t.attrs)==null?void 0:i.title)!=null?o:"";return c?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:s,getPos:i,HTMLAttributes:o})=>{const l=document.createElement("img");Object.entries(o).forEach(([d,u])=>{if(u!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,u);break}}),l.src=o.src;const a=new rE({element:l,node:s,getPos:i,onResize:(d,u)=>{l.style.width=`${d}px`,l.style.height=`${u}px`},onCommit:(d,u)=>{const h=i();h!==void 0&&this.editor.chain().setNodeSelection(h).updateAttributes(this.name,{width:d,height:u}).run()},onUpdate:(d,u,h)=>d.type===s.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),c=a.dom;return c.style.visibility="hidden",c.style.pointerEvents="none",l.onload=()=>{c.style.visibility="",c.style.pointerEvents=""},a}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[ab({find:uT,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),u0=hT;const Ec=(t,e,n)=>Math.max(e,Math.min(n,t));function fT(t){const e=ne.useRef(null),[n,r]=ne.useState(!1),[s,i]=ne.useState(null),o=t.node.attrs,l=ne.useMemo(()=>{const h=o.width;return typeof h=="string"&&h.trim().endsWith("%")?Ec(parseFloat(h)||100,1,100):100},[o.width]),a=s??l,c=h=>f=>{f.preventDefault(),f.stopPropagation();const p=f.clientX,g=a,b=(e.current?.closest(".ProseMirror")||void 0)?.getBoundingClientRect().width||e.current?.parentElement?.getBoundingClientRect().width||e.current?.getBoundingClientRect().width||window.innerWidth;let w=g;const M=A=>{const k=(A.clientX-p)/b*100,v=h==="east"?g+k:g-k,T=Ec(v,1,100);w=T,i(T)},S=()=>{r(!1),window.removeEventListener("pointermove",M),window.removeEventListener("pointerup",S);const A=Ec(w,1,100);t.updateAttributes({width:`${A.toFixed(2)}%`}),i(null)};r(!0),window.addEventListener("pointermove",M),window.addEventListener("pointerup",S,{once:!0})},d=(()=>{const h={width:`${a}%`,maxWidth:"100%",display:"block"};return o.height?(typeof o.height=="number"||typeof o.height=="string")&&(h.height=o.height):h.height="auto",o.align==="left"&&(h.marginLeft=0,h.marginRight="auto"),o.align==="right"&&(h.marginLeft="auto",h.marginRight=0),o.align==="center"&&(h.margin="0 auto"),h})(),u=t.selected||n;return m.jsxs(Iu,{ref:e,className:"tiptap-image-wrapper relative block","data-dragging":n?"true":"false",contentEditable:!1,style:d,onClick:h=>h.stopPropagation(),children:[m.jsx("img",{src:o.src,alt:o.alt||"",style:{display:"block",width:"100%",height:"100%",objectFit:"cover",objectPosition:`${o.focalX??50}% ${o.focalY??50}%`,borderRadius:6},draggable:!1,onClick:h=>{if(o.focusMode){const f=h.target.getBoundingClientRect(),p=Math.round((h.clientX-f.left)/f.width*100),g=Math.round((h.clientY-f.top)/f.height*100);t.updateAttributes({focalX:p,focalY:g,focusMode:!1})}}}),u&&m.jsxs(m.Fragment,{children:[m.jsx("div",{role:"slider","aria-label":"Resize image","aria-valuemin":1,"aria-valuemax":100,"aria-valuenow":a,onPointerDown:c("west"),className:"absolute left-0 top-1/2 -translate-y-1/2 h-16 w-2 rounded-sm bg-primary cursor-ew-resize shadow border border-primary/40"}),m.jsx("div",{role:"slider","aria-label":"Resize image","aria-valuemin":1,"aria-valuemax":100,"aria-valuenow":a,onPointerDown:c("east"),className:"absolute right-0 top-1/2 -translate-y-1/2 h-16 w-2 rounded-sm bg-primary cursor-ew-resize shadow border border-primary/40"})]}),u&&m.jsx("div",{className:"pointer-events-none absolute inset-0 rounded-md ring-2 ring-primary/60"}),n&&m.jsxs("div",{className:"pointer-events-none absolute -top-6 right-0 text-xs bg-primary text-primary-foreground px-2 py-0.5 rounded",children:[Number(a.toFixed(1)),"%"]})]})}const pT=u0.extend({name:"image",addAttributes(){return{...this.parent?.()||{},width:{default:null,parseHTML:t=>t.getAttribute("width")||t.style.width||null,renderHTML:t=>{const e={};return typeof t.width=="number"?e.width=t.width:typeof t.width=="string"&&t.width.trim().length>0&&(e.style=`width: ${t.width};`),e}},height:{default:null,parseHTML:t=>t.getAttribute("height")||t.style.height||null,renderHTML:t=>{const e={};if(typeof t.height=="number")e.height=t.height;else if(typeof t.height=="string"&&t.height.trim().length>0){const n=`height: ${t.height};`;e.style=e.style?`${e.style} ${n}`:n}return e}},blurDataURL:{default:null,parseHTML:t=>t.getAttribute("data-blur")||null,renderHTML:t=>t.blurDataURL?{"data-blur":t.blurDataURL}:{}},lockAspect:{default:!0,parseHTML:t=>t.getAttribute("data-lock-aspect")!=="false",renderHTML:t=>({"data-lock-aspect":String(t.lockAspect)})},align:{default:null,parseHTML:t=>t.getAttribute("data-align"),renderHTML:t=>t.align?{"data-align":t.align}:{}},caption:{default:null,parseHTML:t=>t.getAttribute("data-caption"),renderHTML:t=>t.caption?{"data-caption":t.caption}:{}},focalX:{default:null,parseHTML:t=>t.getAttribute("data-focal-x"),renderHTML:t=>t.focalX!=null?{"data-focal-x":String(t.focalX)}:{}},focalY:{default:null,parseHTML:t=>t.getAttribute("data-focal-y"),renderHTML:t=>t.focalY!=null?{"data-focal-y":String(t.focalY)}:{}},focusMode:{default:!1,parseHTML:t=>t.getAttribute("data-focus-mode")==="true",renderHTML:t=>t.focusMode?{"data-focus-mode":"true"}:{}}}},addKeyboardShortcuts(){const e=n=>()=>{const s=(this.editor.getAttributes("image")||{}).width;let i=100;typeof s=="string"&&s.endsWith("%")&&(i=parseFloat(s)||100);const o=Math.max(1,Math.min(100,i+n));return this.editor.chain().focus().updateAttributes("image",{width:`${o}%`}).run()};return{"Alt-=":e(5),"Alt-+":e(5),"Alt--":e(-5),"Alt-_":e(-5)}},addNodeView(){return ju(fT)}});var h0=Xb,f0=Yb,kd,vd;if(typeof WeakMap<"u"){let t=new WeakMap;kd=e=>t.get(e),vd=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;kd=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},vd=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var Pe=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,s=e/this.width|0;let i=r+1,o=s+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;o<this.height&&this.map[e+this.width*l]==n;l++)o++;return{left:r,top:s,right:i,bottom:o}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:s,top:i,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[i*this.width+(n<0?r-1:s)]:(n<0?i==0:o==this.height)?null:this.map[r+this.width*(n<0?i-1:o)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(s,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const i=r*this.width+s,o=this.map[i];n[o]||(n[o]=!0,!(s==t.left&&s&&this.map[i-1]==o||r==t.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const i=s+n.child(r).nodeSize;if(r==t){let o=e+t*this.width;const l=(t+1)*this.width;for(;o<l&&this.map[o]<s;)o++;return o==l?i-1:this.map[o]}s=i}}static get(t){return kd(t)||vd(t,mT(t))}};function mT(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=gT(t),n=t.childCount,r=[];let s=0,i=null;const o=[];for(let c=0,d=e*n;c<d;c++)r[c]=0;for(let c=0,d=0;c<n;c++){const u=t.child(c);d++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==u.childCount)break;const g=u.child(p),{colspan:y,rowspan:b,colwidth:w}=g.attrs;for(let M=0;M<b;M++){if(M+c>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:b-M});break}const S=s+M*e;for(let A=0;A<y;A++){r[S+A]==0?r[S+A]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:y-A});const x=w&&w[A];if(x){const k=(S+A)%e*2,v=o[k];v==null||v!=x&&o[k+1]==1?(o[k]=x,o[k+1]=1):v==x&&o[k+1]++}}}s+=y,d+=g.nodeSize}const h=(c+1)*e;let f=0;for(;s<h;)r[s++]==0&&f++;f&&(i||(i=[])).push({type:"missing",row:c,n:f}),d++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new Pe(e,n,r,i);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<n&&(a=!0);return a&&yT(l,o,t),l}function gT(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let i=0;if(n)for(let o=0;o<r;o++){const l=t.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const l=s.child(o);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function yT(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const i=t.map[s];if(r[i])continue;r[i]=!0;const o=n.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const d=(s+c)%t.width,u=e[d*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=bT(a)))[c]=u)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function bT(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function pt(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}var qn=new ge("selectingCells");function As(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function xT(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 Qt(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 ga(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=As(e.$head)||wT(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function wT(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 Sd(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function kT(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function nh(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function p0(t,e,n){const r=t.node(-1),s=Pe.get(r),i=t.start(-1),o=s.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function jr(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function m0(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<n;s++)r.colwidth.splice(e,0,0)}return r}function vT(t,e,n){const r=pt(e.type.schema).header_cell;for(let s=0;s<t.height;s++)if(e.nodeAt(t.map[n+s*t.width]).type!=r)return!1;return!0}var Te=class kn extends ee{constructor(e,n=e){const r=e.node(-1),s=Pe.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,n.pos-i),l=e.node(0),a=s.cellsInRect(o).filter(d=>d!=n.pos-i);a.unshift(n.pos-i);const c=a.map(d=>{const u=r.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);const h=i+d+1;return new lu(l.resolve(h),l.resolve(h+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(Sd(r)&&Sd(s)&&nh(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?kn.rowSelection(r,s):i&&this.isColSelection()?kn.colSelection(r,s):new kn(r,s)}return J.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=Pe.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let d=a*n.width+s.left,u=s.left;u<s.right;u++,d++){const h=n.map[d];if(i[h])continue;i[h]=!0;const f=n.findCell(h);let p=e.nodeAt(h);if(!p)throw RangeError(`No cell with offset ${h} found`);const g=s.left-f.left,y=f.right-s.right;if(g>0||y>0){let b=p.attrs;if(g>0&&(b=jr(b,0,g)),y>0&&(b=jr(b,b.colspan-y,y)),f.left<s.left){if(p=p.type.createAndFill(b),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else p=p.type.create(b,p.content)}if(f.top<s.top||f.bottom>s.bottom){const b={...p.attrs,rowspan:Math.min(f.bottom,s.bottom)-Math.max(f.top,s.top)};f.top<s.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}o.push(e.child(a).copy(O.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new P(O.from(l),1,1)}replace(e,n=P.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:l,$to:a}=s[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?P.empty:n)}const i=ee.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new P(O.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=Pe.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(n.nodeAt(i[o]),s+i[o])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),s=Pe.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(i+s.map[o.left])),l.bottom<s.height&&(n=a.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+s.map[l.left])),o.bottom<s.height&&(e=a.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new kn(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=Pe.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==n.width}eq(e){return e instanceof kn&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=Pe.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(i+s.map[o.top*s.width])),l.right<s.width&&(n=a.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+s.map[l.top*s.width])),o.right<s.width&&(e=a.resolve(i+s.map[s.width*(o.top+1)-1]))),new kn(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new kn(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new kn(e.resolve(n),e.resolve(r))}getBookmark(){return new ST(this.$anchorCell.pos,this.$headCell.pos)}};Te.prototype.visible=!1;ee.jsonID("cell",Te);var ST=class g0{constructor(e,n){this.anchor=e,this.head=n}map(e){return new g0(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&nh(n,r)?new Te(n,r):ee.near(r,1)}};function CT(t){if(!(t.selection instanceof Te))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(_e.node(r,r+n.nodeSize,{class:"selectedCell"}))}),ye.create(t.doc,e)}function ET({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,s=t.depth;for(;s>=0&&!(t.after(s+1)<t.end(s));s--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(s).type.spec.tableRole)}function MT({$from:t,$to:e}){let n,r;for(let s=t.depth;s>0;s--){const i=t.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function AT(t,e,n){const r=(e||t).selection,s=(e||t).doc;let i,o;if(r instanceof q&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=Te.create(s,r.from);else if(o=="row"){const l=s.resolve(r.from+1);i=Te.rowSelection(l,l)}else if(!n){const l=Pe.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=Te.create(s,a+1,c)}}else r instanceof J&&ET(r)?i=J.create(s,r.from):r instanceof J&&MT(r)&&(i=J.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}var TT=new ge("fix-tables");function y0(t,e,n,r){const s=t.childCount,i=e.childCount;e:for(let o=0,l=0;o<i;o++){const a=e.child(o);for(let c=l,d=Math.min(s,o+3);c<d;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<s&&t.child(l).sameMarkup(a)?y0(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function b0(t,e){let n;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=NT(t,s,i,n))};return e?e.doc!=t.doc&&y0(e.doc,t.doc,0,r):t.doc.descendants(r),n}function NT(t,e,n,r){const s=Pe.get(e);if(!s.problems)return r;r||(r=t.tr);const i=[];for(let a=0;a<s.height;a++)i.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let h=0;h<u.rowspan;h++)i[c.row+h]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,jr(u,u.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const d=r.mapping.map(n);r.delete(d,d+e.nodeSize)}}let o,l;for(let a=0;a<i.length;a++)i[a]&&(o==null&&(o=a),l=a);for(let a=0,c=n+1;a<s.height;a++){const d=e.child(a),u=c+d.nodeSize,h=i[a];if(h>0){let f="cell";d.firstChild&&(f=d.firstChild.type.spec.tableRole);const p=[];for(let y=0;y<h;y++){const b=pt(t.schema)[f].createAndFill();b&&p.push(b)}const g=(a==0||o==a-1)&&l==a?c+1:u-1;r.insert(r.mapping.map(g),p)}c=u}return r.setMeta(TT,{fixTables:!0})}function fn(t){const e=t.selection,n=ga(t),r=n.node(-1),s=n.start(-1),i=Pe.get(r);return{...e instanceof Te?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function x0(t,{map:e,tableStart:n,table:r},s){let i=s>0?-1:0;vT(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){const l=o*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,m0(c.attrs,s-e.colCount(a))),o+=c.attrs.rowspan-1}else{const a=i==null?pt(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(o,s,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function _T(t,e){if(!Qt(t))return!1;if(e){const n=fn(t);e(x0(t.tr,n,n.left))}return!0}function RT(t,e){if(!Qt(t))return!1;if(e){const n=fn(t);e(x0(t.tr,n,n.right))}return!0}function OT(t,{map:e,table:n,tableStart:r},s){const i=t.mapping.maps.length;for(let o=0;o<e.height;){const l=o*e.width+s,a=e.map[l],c=n.nodeAt(a),d=c.attrs;if(s>0&&e.map[l-1]==a||s<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(i).map(r+a),null,jr(d,s-e.colCount(a)));else{const u=t.mapping.slice(i).map(r+a);t.delete(u,u+c.nodeSize)}o+=d.rowspan}}function DT(t,e){if(!Qt(t))return!1;if(e){const n=fn(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;OT(r,n,s),s!=n.left;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw RangeError("No table found");n.table=i,n.map=Pe.get(i)}e(r)}return!0}function LT(t,e,n){var r;const s=pt(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))==null?void 0:r.type)!=s)return!1;return!0}function w0(t,{map:e,tableStart:n,table:r},s){var i;let o=n;for(let c=0;c<s;c++)o+=r.child(c).nodeSize;const l=[];let a=s>0?-1:0;LT(e,r,s+a)&&(a=s==0||s==e.height?null:0);for(let c=0,d=e.width*s;c<e.width;c++,d++)if(s>0&&s<e.height&&e.map[d]==e.map[d-e.width]){const u=e.map[d],h=r.nodeAt(u).attrs;t.setNodeMarkup(n+u,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{const u=a==null?pt(r.type.schema).cell:(i=r.nodeAt(e.map[d+a*e.width]))==null?void 0:i.type,h=u?.createAndFill();h&&l.push(h)}return t.insert(o,pt(r.type.schema).row.create(null,l)),t}function IT(t,e){if(!Qt(t))return!1;if(e){const n=fn(t);e(w0(t.tr,n,n.top))}return!0}function jT(t,e){if(!Qt(t))return!1;if(e){const n=fn(t);e(w0(t.tr,n,n.bottom))}return!0}function PT(t,{map:e,table:n,tableStart:r},s){let i=0;for(let c=0;c<s;c++)i+=n.child(c).nodeSize;const o=i+n.child(s).nodeSize,l=t.mapping.maps.length;t.delete(i+r,o+r);const a=new Set;for(let c=0,d=s*e.width;c<e.width;c++,d++){const u=e.map[d];if(!a.has(u)){if(a.add(u),s>0&&u==e.map[d-e.width]){const h=n.nodeAt(u).attrs;t.setNodeMarkup(t.mapping.slice(l).map(u+r),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(s<e.height&&u==e.map[d+e.width]){const h=n.nodeAt(u),f=h.attrs,p=h.type.create({...f,rowspan:h.attrs.rowspan-1},h.content),g=e.positionAt(s+1,c,n);t.insert(t.mapping.slice(l).map(r+g),p),c+=f.colspan-1}}}}function BT(t,e){if(!Qt(t))return!1;if(e){const n=fn(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;PT(r,n,s),s!=n.top;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw RangeError("No table found");n.table=i,n.map=Pe.get(n.table)}e(r)}return!0}function Fp(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function $T({width:t,height:e,map:n},r){let s=r.top*t+r.left,i=s,o=(r.bottom-1)*t+r.left,l=s+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[o]==n[o+t])return!0;s++,o++}return!1}function Up(t,e){const n=t.selection;if(!(n instanceof Te)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=fn(t),{map:s}=r;if($T(s,r))return!1;if(e){const i=t.tr,o={};let l=O.empty,a,c;for(let d=r.top;d<r.bottom;d++)for(let u=r.left;u<r.right;u++){const h=s.map[d*s.width+u],f=r.table.nodeAt(h);if(!(o[h]||!f))if(o[h]=!0,a==null)a=h,c=f;else{Fp(f)||(l=l.append(f.content));const p=i.mapping.map(h+r.tableStart);i.delete(p,p+f.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...m0(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size){const d=a+1+c.content.size,u=Fp(c)?a+1:d;i.replaceWith(u+r.tableStart,d+r.tableStart,l)}i.setSelection(new Te(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function Vp(t,e){const n=pt(t.schema);return HT(({node:r})=>n[r.type.spec.tableRole])(t,e)}function HT(t){return(e,n)=>{var r;const s=e.selection;let i,o;if(s instanceof Te){if(s.$anchorCell.pos!=s.$headCell.pos)return!1;i=s.$anchorCell.nodeAfter,o=s.$anchorCell.pos}else{if(i=xT(s.$from),!i)return!1;o=(r=As(s.$from))==null?void 0:r.pos}if(i==null||o==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let l=i.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const d=fn(e),u=e.tr;for(let f=0;f<d.right-d.left;f++)a.push(c?{...l,colwidth:c&&c[f]?[c[f]]:null}:l);let h;for(let f=d.top;f<d.bottom;f++){let p=d.map.positionAt(f,d.left,d.table);f==d.top&&(p+=i.nodeSize);for(let g=d.left,y=0;g<d.right;g++,y++)g==d.left&&f==d.top||u.insert(h=u.mapping.map(p+d.tableStart,1),t({node:i,row:f,col:g}).createAndFill(a[y]))}u.setNodeMarkup(o,t({node:i,row:d.top,col:d.left}),a[0]),s instanceof Te&&u.setSelection(new Te(u.doc.resolve(s.$anchorCell.pos),h?u.doc.resolve(h):void 0)),n(u)}return!0}}function zT(t,e){return function(n,r){if(!Qt(n))return!1;const s=ga(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof Te?n.selection.forEachCell((o,l)=>{o.attrs[t]!==e&&i.setNodeMarkup(l,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function FT(t){return function(e,n){if(!Qt(e))return!1;if(n){const r=pt(e.schema),s=fn(e),i=e.tr,o=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=o.map(a=>s.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[a],r.cell,l[a].attrs);if(i.steps.length==0)for(let a=0;a<o.length;a++)i.setNodeMarkup(s.tableStart+o[a],r.header_cell,l[a].attrs);n(i)}return!0}}function Wp(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function xi(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?FT(t):function(n,r){if(!Qt(n))return!1;if(r){const s=pt(n.schema),i=fn(n),o=n.tr,l=Wp("row",i,s),a=Wp("column",i,s),d=(t==="column"?l:t==="row"?a:!1)?1:0,u=t=="column"?{left:0,top:d,right:1,bottom:i.map.height}:t=="row"?{left:d,top:0,right:i.map.width,bottom:1}:i,h=t=="column"?a?s.cell:s.header_cell:t=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(u).forEach(f=>{const p=f+i.tableStart,g=o.doc.nodeAt(p);g&&o.setNodeMarkup(p,h,g.attrs)}),r(o)}return!0}}xi("row",{useDeprecatedLogic:!0});xi("column",{useDeprecatedLogic:!0});var UT=xi("cell",{useDeprecatedLogic:!0});function VT(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,s=t.before();r>=0;r--){const i=t.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),s=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function qp(t){return function(e,n){if(!Qt(e))return!1;const r=VT(ga(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection(J.between(s,kT(s))).scrollIntoView())}return!0}}function WT(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function ko(t,e){const n=t.selection;if(!(n instanceof Te))return!1;if(e){const r=t.tr,s=pt(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new P(s,0,0))}),r.docChanged&&e(r)}return!0}function qT(t){if(!t.size)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,n-1),u=a<e.childCount-1?0:Math.max(0,r-1);(d||u)&&(c=Cd(pt(o).row,new P(c,d,u)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(n||r?Cd(pt(o).row,new P(e,n,r)).content:e);else return null;return KT(o,l)}function KT(t,e){const n=[];for(let s=0;s<e.length;s++){const i=e[s];for(let o=i.childCount-1;o>=0;o--){const{rowspan:l,colspan:a}=i.child(o).attrs;for(let c=s;c<s+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,n[s]);for(let s=0;s<n.length;s++)if(s>=e.length&&e.push(O.empty),n[s]<r){const i=pt(t).cell.createAndFill(),o=[];for(let l=n[s];l<r;l++)o.push(i);e[s]=e[s].append(O.from(o))}return{height:e.length,width:r,rows:e}}function Cd(t,e){const n=t.createAndFill();return new ou(n).replace(0,n.content.size,e).doc}function GT({width:t,height:e,rows:n},r,s){if(t!=r){const i=[],o=[];for(let l=0;l<n.length;l++){const a=n[l],c=[];for(let d=i[l]||0,u=0;d<r;u++){let h=a.child(u%a.childCount);d+h.attrs.colspan>r&&(h=h.type.createChecked(jr(h.attrs,h.attrs.colspan,d+h.attrs.colspan-r),h.content)),c.push(h),d+=h.attrs.colspan;for(let f=1;f<h.attrs.rowspan;f++)i[l+f]=(i[l+f]||0)+h.attrs.colspan}o.push(O.from(c))}n=o,t=r}if(e!=s){const i=[];for(let o=0,l=0;o<s;o++,l++){const a=[],c=n[l%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);o+u.attrs.rowspan>s&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,s-u.attrs.rowspan)},u.content)),a.push(u)}i.push(O.from(a))}n=i,e=s}return{width:t,height:e,rows:n}}function JT(t,e,n,r,s,i,o){const l=t.doc.type.schema,a=pt(l);let c,d;if(s>e.width)for(let u=0,h=0;u<e.height;u++){const f=n.child(u);h+=f.nodeSize;const p=[];let g;f.lastChild==null||f.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=d||(d=a.header_cell.createAndFill());for(let y=e.width;y<s;y++)p.push(g);t.insert(t.mapping.slice(o).map(h-1+r),p)}if(i>e.height){const u=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,s);p++){const y=p>=e.width?!1:n.nodeAt(e.map[g+p]).type==a.header_cell;u.push(y?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const h=a.row.create(null,O.from(u)),f=[];for(let p=e.height;p<i;p++)f.push(h);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(c||d)}function Kp(t,e,n,r,s,i,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=s;c<i;c++){const d=o*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;const h=n.nodeAt(u),{top:f,left:p}=e.findCell(u);t.setNodeMarkup(t.mapping.slice(l).map(u+r),null,{...h.attrs,rowspan:o-f}),t.insert(t.mapping.slice(l).map(e.positionAt(o,p,n)),h.type.createAndFill({...h.attrs,rowspan:f+h.attrs.rowspan-o})),c+=h.attrs.colspan-1}}return a}function Gp(t,e,n,r,s,i,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=s;c<i;c++){const d=c*e.width+o,u=e.map[d];if(e.map[d-1]==u){a=!0;const h=n.nodeAt(u),f=e.colCount(u),p=t.mapping.slice(l).map(u+r);t.setNodeMarkup(p,null,jr(h.attrs,o-f,h.attrs.colspan-(o-f))),t.insert(p+h.nodeSize,h.type.createAndFill(jr(h.attrs,0,o-f))),c+=h.attrs.rowspan-1}}return a}function Jp(t,e,n,r,s){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let o=Pe.get(i);const{top:l,left:a}=r,c=a+s.width,d=l+s.height,u=t.tr;let h=0;function f(){if(i=n?u.doc.nodeAt(n-1):u.doc,!i)throw new Error("No table found");o=Pe.get(i),h=u.mapping.maps.length}JT(u,o,i,n,c,d,h)&&f(),Kp(u,o,i,n,a,c,l,h)&&f(),Kp(u,o,i,n,a,c,d,h)&&f(),Gp(u,o,i,n,l,d,a,h)&&f(),Gp(u,o,i,n,l,d,c,h)&&f();for(let p=l;p<d;p++){const g=o.positionAt(p,a,i),y=o.positionAt(p,c,i);u.replace(u.mapping.slice(h).map(g+n),u.mapping.slice(h).map(y+n),new P(s.rows[p-l],0,0))}f(),u.setSelection(new Te(u.doc.resolve(n+o.positionAt(l,a,i)),u.doc.resolve(n+o.positionAt(d-1,c-1,i)))),e(u)}var YT=Su({ArrowLeft:vo("horiz",-1),ArrowRight:vo("horiz",1),ArrowUp:vo("vert",-1),ArrowDown:vo("vert",1),"Shift-ArrowLeft":So("horiz",-1),"Shift-ArrowRight":So("horiz",1),"Shift-ArrowUp":So("vert",-1),"Shift-ArrowDown":So("vert",1),Backspace:ko,"Mod-Backspace":ko,Delete:ko,"Mod-Delete":ko});function Po(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function vo(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof Te)return Po(n,r,ee.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=k0(s,t,e);if(o==null)return!1;if(t=="horiz")return Po(n,r,ee.near(n.doc.resolve(i.head+e),e));{const l=n.doc.resolve(o),a=p0(l,t,e);let c;return a?c=ee.near(a,1):e<0?c=ee.near(n.doc.resolve(l.before(-1)),-1):c=ee.near(n.doc.resolve(l.after(-1)),1),Po(n,r,c)}}}function So(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let o;if(i instanceof Te)o=i;else{const a=k0(s,t,e);if(a==null)return!1;o=new Te(n.doc.resolve(a))}const l=p0(o.$headCell,t,e);return l?Po(n,r,new Te(o.$anchorCell,l)):!1}}function XT(t,e){const n=t.state.doc,r=As(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Te(r))),!0):!1}function ZT(t,e,n){if(!Qt(t.state))return!1;let r=qT(n);const s=t.state.selection;if(s instanceof Te){r||(r={width:1,height:1,rows:[O.from(Cd(pt(t.state.schema).cell,n))]});const i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),l=Pe.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=GT(r,l.right-l.left,l.bottom-l.top),Jp(t.state,t.dispatch,o,l,r),!0}else if(r){const i=ga(t.state),o=i.start(-1);return Jp(t.state,t.dispatch,o,Pe.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function QT(t,e){var n;if(e.ctrlKey||e.metaKey)return;const r=Yp(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof Te)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=As(t.state.selection.$anchor))!=null&&((n=Mc(t,e))==null?void 0:n.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(a,c){let d=Mc(t,c);const u=qn.getState(t.state)==null;if(!d||!nh(a,d))if(u)d=a;else return;const h=new Te(a,d);if(u||!t.state.selection.eq(h)){const f=t.state.tr.setSelection(h);u&&f.setMeta(qn,a.pos),t.dispatch(f)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),qn.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(qn,-1))}function l(a){const c=a,d=qn.getState(t.state);let u;if(d!=null)u=t.state.doc.resolve(d);else if(Yp(t,c.target)!=r&&(u=Mc(t,e),!u))return o();u&&i(u,c)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",l)}function k0(t,e,n){if(!(t.state.selection instanceof J))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=r.before(s),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?l:null}}return null}function Yp(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Mc(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?As(t.state.doc.resolve(n.pos)):null}var eN=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Ed(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,Ed(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Ed(t,e,n,r,s,i){var o;let l=0,a=!0,c=e.firstChild;const d=t.firstChild;if(d){for(let u=0,h=0;u<d.childCount;u++){const{colspan:f,colwidth:p}=d.child(u).attrs;for(let g=0;g<f;g++,h++){const y=s==h?i:p&&p[g],b=y?y+"px":"";if(l+=y||r,y||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const w=document.createElement("col");w.style.width=b,e.appendChild(w)}}}for(;c;){const u=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=u}a?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}var Rt=new ge("tableColumnResizing");function tN({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=eN,lastColumnResizable:s=!0}={}){const i=new pe({key:Rt,state:{init(o,l){var a,c;const d=(c=(a=i.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,u=pt(l.schema).table.name;return r&&d&&(d[u]=(h,f)=>new r(h,n,f)),new nN(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=Rt.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{rN(o,l,t,s)},mouseleave:o=>{sN(o)},mousedown:(o,l)=>{iN(o,l,e,n)}},decorations:o=>{const l=Rt.getState(o);if(l&&l.activeHandle>-1)return dN(o,l.activeHandle)},nodeViews:{}}});return i}var nN=class Bo{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Rt);if(r&&r.setHandle!=null)return new Bo(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Bo(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return Sd(e.doc.resolve(s))||(s=-1),new Bo(s,n.dragging)}return n}};function rN(t,e,n,r){if(!t.editable)return;const s=Rt.getState(t.state);if(s&&!s.dragging){const i=lN(e.target);let o=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=n?o=Xp(t,e,"left",n):a-e.clientX<=n&&(o=Xp(t,e,"right",n))}if(o!=s.activeHandle){if(!r&&o!==-1){const l=t.state.doc.resolve(o),a=l.node(-1),c=Pe.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}v0(t,o)}}}function sN(t){if(!t.editable)return;const e=Rt.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&v0(t,-1)}function iN(t,e,n,r){var s;if(!t.editable)return!1;const i=(s=t.dom.ownerDocument.defaultView)!=null?s:window,o=Rt.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=t.state.doc.nodeAt(o.activeHandle),a=oN(t,o.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Rt,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const h=Rt.getState(t.state);h?.dragging&&(aN(t,h.activeHandle,Zp(h.dragging,u,n)),t.dispatch(t.state.tr.setMeta(Rt,{setDragging:null})))}function d(u){if(!u.which)return c(u);const h=Rt.getState(t.state);if(h&&h.dragging){const f=Zp(h.dragging,u,n);Qp(t,h.activeHandle,f,r)}}return Qp(t,o.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function oN(t,e,{colspan:n,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=t.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,a=n;if(r)for(let c=0;c<n;c++)r[c]&&(l-=r[c],a--);return l/a}function lN(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Xp(t,e,n,r){const s=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:o}=i,l=As(t.state.doc.resolve(o));if(!l)return-1;if(n=="right")return l.pos;const a=Pe.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function Zp(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function v0(t,e){t.dispatch(t.state.tr.setMeta(Rt,{setHandle:e}))}function aN(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),i=Pe.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<i.height;c++){const d=c*i.width+l;if(c&&i.map[d]==i.map[d-i.width])continue;const u=i.map[d],h=s.nodeAt(u).attrs,f=h.colspan==1?0:l-i.colCount(u);if(h.colwidth&&h.colwidth[f]==n)continue;const p=h.colwidth?h.colwidth.slice():cN(h.colspan);p[f]=n,a.setNodeMarkup(o+u,null,{...h,colwidth:p})}a.docChanged&&t.dispatch(a)}function Qp(t,e,n,r){const s=t.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),l=Pe.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;let a=t.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Ed(i,a.firstChild,a,r,l,n)}function cN(t){return Array(t).fill(0)}function dN(t,e){var n;const r=[],s=t.doc.resolve(e),i=s.node(-1);if(!i)return ye.empty;const o=Pe.get(i),l=s.start(-1),a=o.colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;for(let c=0;c<o.height;c++){const d=a+c*o.width;if((a==o.width-1||o.map[d]!=o.map[d+1])&&(c==0||o.map[d]!=o.map[d-o.width])){const u=o.map[d],h=l+u+i.nodeAt(u).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",(n=Rt.getState(t))!=null&&n.dragging&&r.push(_e.node(l+u,l+u+i.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),r.push(_e.widget(h,f))}}return ye.create(t.doc,r)}function uN({allowTableNodeSelection:t=!1}={}){return new pe({key:qn,state:{init(){return null},apply(e,n){const r=e.getMeta(qn);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:s,pos:i}=e.mapping.mapResult(n);return s?null:i}},props:{decorations:CT,handleDOMEvents:{mousedown:QT},createSelectionBetween(e){return qn.getState(e.state)!=null?e.state.selection:null},handleTripleClick:XT,handleKeyDown:YT,handlePaste:ZT},appendTransaction(e,n,r){return AT(r,b0(r,n),t)}})}var S0=De.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const r=t.getAttribute("colwidth"),s=r?r.split(",").map(i=>parseInt(i,10)):null;if(!s){const i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),o=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(o&&o>-1&&i&&i[o]){const l=i[o].getAttribute("width");return l?[parseInt(l,10)]:null}}return s}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",be(this.options.HTMLAttributes,t),0]}}),C0=De.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",be(this.options.HTMLAttributes,t),0]}}),E0=De.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",be(this.options.HTMLAttributes,t),0]}});function Md(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function em(t,e,n,r,s,i){var o;let l=0,a=!0,c=e.firstChild;const d=t.firstChild;if(d!==null)for(let u=0,h=0;u<d.childCount;u+=1){const{colspan:f,colwidth:p}=d.child(u).attrs;for(let g=0;g<f;g+=1,h+=1){const y=s===h?i:p&&p[g],b=y?`${y}px`:"";if(l+=y||r,y||(a=!1),c){if(c.style.width!==b){const[w,M]=Md(r,y);c.style.setProperty(w,M)}c=c.nextSibling}else{const w=document.createElement("col"),[M,S]=Md(r,y);w.style.setProperty(M,S),e.appendChild(w)}}}for(;c;){const u=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=u}a?(n.style.width=`${l}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${l}px`)}var hN=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),em(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,em(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function fN(t,e,n,r){let s=0,i=!0;const o=[],l=t.firstChild;if(!l)return{};for(let u=0,h=0;u<l.childCount;u+=1){const{colspan:f,colwidth:p}=l.child(u).attrs;for(let g=0;g<f;g+=1,h+=1){const y=n===h?r:p&&p[g];s+=y||e,y||(i=!1);const[b,w]=Md(e,y);o.push(["col",{style:`${b}: ${w}`}])}}const a=i?`${s}px`:"",c=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:a,tableMinWidth:c}}function tm(t,e){return t.createAndFill()}function pN(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function mN(t,e,n,r,s){const i=pN(t),o=[],l=[];for(let c=0;c<n;c+=1){const d=tm(i.cell);if(d&&l.push(d),r){const u=tm(i.header_cell);u&&o.push(u)}}const a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?o:l));return i.table.createChecked(null,a)}function gN(t){return t instanceof Te}var Co=({editor:t})=>{const{selection:e}=t.state;if(!gN(e))return!1;let n=0;const r=Hy(e.ranges[0].$from,i=>i.type.name==="table");return r?.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},yN="";function bN(t){return(t||"").replace(/\s+/g," ").trim()}function xN(t,e,n={}){var r;const s=(r=n.cellLineSeparator)!=null?r:yN;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(p=>{const g=[];p.content&&p.content.forEach(y=>{let b="";y.content&&Array.isArray(y.content)&&y.content.length>1?b=y.content.map(A=>e.renderChildren(A)).join(s):b=y.content?e.renderChildren(y.content):"";const w=bN(b),M=y.type==="tableHeader";g.push({text:w,isHeader:M})}),i.push(g)});const o=i.reduce((p,g)=>Math.max(p,g.length),0);if(o===0)return"";const l=new Array(o).fill(0);i.forEach(p=>{var g;for(let y=0;y<o;y+=1){const w=(((g=p[y])==null?void 0:g.text)||"").length;w>l[y]&&(l[y]=w),l[y]<3&&(l[y]=3)}});const a=(p,g)=>p+" ".repeat(Math.max(0,g-p.length)),c=i[0],d=c.some(p=>p.isHeader);let u=`
|
|
145
|
+
`,1;if(Ua>1e5&&Ua>K.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Ae+=ae,ae.length}const nn=In(L);if(!nn)throw pr(ze.replace("{}",L)),new Error('Unknown language: "'+L+'"');const i1=$w(nn);let Fa="",se=Me||i1;const Jh={},nt=new U.__emitter(U);s1();let Ae="",so=0,mr=0,Ua=0,Va=!1;try{if(nn.__emitTokens)nn.__emitTokens(Y,nt);else{for(se.matcher.considerAll();;){Ua++,Va?Va=!1:se.matcher.considerAll(),se.matcher.lastIndex=mr;const z=se.matcher.exec(Y);if(!z)break;const K=Y.substring(mr,z.index),ae=Gh(K,z);mr=z.index+ae}Gh(Y.substring(mr))}return nt.finalize(),Fa=nt.toHTML(),{language:L,value:Fa,relevance:so,illegal:!1,_emitter:nt,_top:se}}catch(z){if(z.message&&z.message.includes("Illegal"))return{language:L,value:Ba(Y),illegal:!0,relevance:0,_illegalBy:{message:z.message,index:mr,context:Y.slice(mr-100,mr+100),mode:z.mode,resultSoFar:Fa},_emitter:nt};if(He)return{language:L,value:Ba(Y),illegal:!1,relevance:0,errorRaised:z,_emitter:nt,_top:se};throw z}}function $a(L){const Y={value:Ba(L),illegal:!1,relevance:0,_top:W,_emitter:new U.__emitter(U)};return Y._emitter.addText(L),Y}function Ha(L,Y){Y=Y||U.languages||Object.keys(R);const he=$a(L),Me=Y.filter(In).filter(Vh).map(At=>Ds(At,L,!1));Me.unshift(he);const Je=Me.sort((At,tn)=>{if(At.relevance!==tn.relevance)return tn.relevance-At.relevance;if(At.language&&tn.language){if(In(At.language).supersetOf===tn.language)return 1;if(In(tn.language).supersetOf===At.language)return-1}return 0}),[zt,jn]=Je,no=zt;return no.secondBest=jn,no}function Vw(L,Y,he){const Me=Y&&B[Y]||he;L.classList.add("hljs"),L.classList.add(`language-${Me}`)}function za(L){let Y=null;const he=Ye(L);if(te(he))return;if(to("before:highlightElement",{el:L,language:he}),L.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",L);return}if(L.children.length>0&&(U.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(L)),U.throwUnescapedHTML))throw new Fw("One of your code blocks includes unescaped HTML.",L.innerHTML);Y=L;const Me=Y.textContent,Je=he?Ve(Me,{language:he,ignoreIllegals:!0}):Ha(Me);L.innerHTML=Je.value,L.dataset.highlighted="yes",Vw(L,he,Je.language),L.result={language:Je.language,re:Je.relevance,relevance:Je.relevance},Je.secondBest&&(L.secondBest={language:Je.secondBest.language,relevance:Je.secondBest.relevance}),to("after:highlightElement",{el:L,result:Je,text:Me})}function Ww(L){U=$h(U,L)}const qw=()=>{eo(),Kr("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Kw(){eo(),Kr("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Fh=!1;function eo(){function L(){eo()}if(document.readyState==="loading"){Fh||window.addEventListener("DOMContentLoaded",L,!1),Fh=!0;return}document.querySelectorAll(U.cssSelector).forEach(za)}function Gw(L,Y){let he=null;try{he=Y(E)}catch(Me){if(pr("Language definition for '{}' could not be registered.".replace("{}",L)),He)pr(Me);else throw Me;he=W}he.name||(he.name=L),R[L]=he,he.rawDefinition=Y.bind(null,E),he.aliases&&Uh(he.aliases,{languageName:L})}function Jw(L){delete R[L];for(const Y of Object.keys(B))B[Y]===L&&delete B[Y]}function Yw(){return Object.keys(R)}function In(L){return L=(L||"").toLowerCase(),R[L]||R[B[L]]}function Uh(L,{languageName:Y}){typeof L=="string"&&(L=[L]),L.forEach(he=>{B[he.toLowerCase()]=Y})}function Vh(L){const Y=In(L);return Y&&!Y.disableAutodetect}function Xw(L){L["before:highlightBlock"]&&!L["before:highlightElement"]&&(L["before:highlightElement"]=Y=>{L["before:highlightBlock"](Object.assign({block:Y.el},Y))}),L["after:highlightBlock"]&&!L["after:highlightElement"]&&(L["after:highlightElement"]=Y=>{L["after:highlightBlock"](Object.assign({block:Y.el},Y))})}function Zw(L){Xw(L),re.push(L)}function Qw(L){const Y=re.indexOf(L);Y!==-1&&re.splice(Y,1)}function to(L,Y){const he=L;re.forEach(function(Me){Me[he]&&Me[he](Y)})}function e1(L){return Kr("10.7.0","highlightBlock will be removed entirely in v12.0"),Kr("10.7.0","Please use highlightElement now."),za(L)}Object.assign(E,{highlight:Ve,highlightAuto:Ha,highlightAll:eo,highlightElement:za,highlightBlock:e1,configure:Ww,initHighlighting:qw,initHighlightingOnLoad:Kw,registerLanguage:Gw,unregisterLanguage:Jw,listLanguages:Yw,getLanguage:In,registerAliases:Uh,autoDetection:Vh,inherit:$h,addPlugin:Zw,removePlugin:Qw}),E.debugMode=function(){He=!1},E.safeMode=function(){He=!0},E.versionString=zw,E.regex={concat:g,lookahead:h,either:b,optional:p,anyNumberOfTimes:f};for(const L in qr)typeof qr[L]=="object"&&t(qr[L]);return Object.assign(E,qr),E},Gr=zh({});return Gr.newInstance=()=>zh({}),Cc=Gr,Gr.HighlightJS=Gr,Gr.default=Gr,Cc}var oT=iT();const a0=sg(oT);function c0(t,e=[]){return t.flatMap(n=>{const r=[...e,...n.properties?n.properties.className:[]];return n.children?c0(n.children,r):{text:n.value,classes:r}})}function Hp(t){return t.value||t.children||[]}function lT(t){return!!a0.getLanguage(t)}function zp({doc:t,name:e,lowlight:n,defaultLanguage:r}){const s=[];return sd(t,i=>i.type.name===e).forEach(i=>{var o;let l=i.pos+1;const a=i.node.attrs.language||r,c=n.listLanguages(),d=a&&(c.includes(a)||lT(a)||(o=n.registered)!=null&&o.call(n,a))?Hp(n.highlight(a,i.node.textContent)):Hp(n.highlightAuto(i.node.textContent));c0(d).forEach(u=>{const h=l+u.text.length;if(u.classes.length){const f=_e.inline(l,h,{class:u.classes.join(" ")});s.push(f)}l=h})}),be.create(t,s)}function aT(t){return typeof t=="function"}function cT({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(s=>aT(e[s])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new me({key:new ye("lowlight"),state:{init:(s,{doc:i})=>zp({doc:i,name:t,lowlight:e,defaultLanguage:n}),apply:(s,i,o,l)=>{const a=o.selection.$head.parent.type.name,c=l.selection.$head.parent.type.name,d=sd(o.doc,h=>h.type.name===t),u=sd(l.doc,h=>h.type.name===t);return s.docChanged&&([a,c].includes(t)||u.length!==d.length||s.steps.some(h=>h.from!==void 0&&h.to!==void 0&&d.some(f=>f.pos>=h.from&&f.pos+f.node.nodeSize<=h.to)))?zp({doc:s.doc,name:t,lowlight:e,defaultLanguage:n}):i.map(s.mapping,s.doc)}},props:{decorations(s){return r.getState(s)}}});return r}var dT=BM.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],cT({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),d0=dT,uT=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,hT=Oe.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},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},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",pe(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,s,i,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",a=(s=(r=t.attrs)==null?void 0:r.alt)!=null?s:"",c=(o=(i=t.attrs)==null?void 0:i.title)!=null?o:"";return c?``:``},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:s,getPos:i,HTMLAttributes:o})=>{const l=document.createElement("img");Object.entries(o).forEach(([d,u])=>{if(u!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,u);break}}),l.src=o.src;const a=new rE({element:l,node:s,getPos:i,onResize:(d,u)=>{l.style.width=`${d}px`,l.style.height=`${u}px`},onCommit:(d,u)=>{const h=i();h!==void 0&&this.editor.chain().setNodeSelection(h).updateAttributes(this.name,{width:d,height:u}).run()},onUpdate:(d,u,h)=>d.type===s.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),c=a.dom;return c.style.visibility="hidden",c.style.pointerEvents="none",l.onload=()=>{c.style.visibility="",c.style.pointerEvents=""},a}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[ab({find:uT,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),u0=hT;const Ec=(t,e,n)=>Math.max(e,Math.min(n,t));function fT(t){const e=ne.useRef(null),[n,r]=ne.useState(!1),[s,i]=ne.useState(null),o=t.node.attrs,l=ne.useMemo(()=>{const h=o.width;return typeof h=="string"&&h.trim().endsWith("%")?Ec(parseFloat(h)||100,1,100):100},[o.width]),a=s??l,c=h=>f=>{f.preventDefault(),f.stopPropagation();const p=f.clientX,g=a,b=(e.current?.closest(".ProseMirror")||void 0)?.getBoundingClientRect().width||e.current?.parentElement?.getBoundingClientRect().width||e.current?.getBoundingClientRect().width||window.innerWidth;let w=g;const M=A=>{const k=(A.clientX-p)/b*100,v=h==="east"?g+k:g-k,T=Ec(v,1,100);w=T,i(T)},S=()=>{r(!1),window.removeEventListener("pointermove",M),window.removeEventListener("pointerup",S);const A=Ec(w,1,100);t.updateAttributes({width:`${A.toFixed(2)}%`}),i(null)};r(!0),window.addEventListener("pointermove",M),window.addEventListener("pointerup",S,{once:!0})},d=(()=>{const h={width:`${a}%`,maxWidth:"100%",display:"block"};return o.height?(typeof o.height=="number"||typeof o.height=="string")&&(h.height=o.height):h.height="auto",o.align==="left"&&(h.marginLeft=0,h.marginRight="auto"),o.align==="right"&&(h.marginLeft="auto",h.marginRight=0),o.align==="center"&&(h.margin="0 auto"),h})(),u=t.selected||n;return m.jsxs(Iu,{ref:e,className:"tiptap-image-wrapper relative block","data-dragging":n?"true":"false",contentEditable:!1,style:d,onClick:h=>h.stopPropagation(),children:[m.jsx("img",{src:o.src,alt:o.alt||"",style:{display:"block",width:"100%",height:"100%",objectFit:"cover",objectPosition:`${o.focalX??50}% ${o.focalY??50}%`,borderRadius:6},draggable:!1,onClick:h=>{if(o.focusMode){const f=h.target.getBoundingClientRect(),p=Math.round((h.clientX-f.left)/f.width*100),g=Math.round((h.clientY-f.top)/f.height*100);t.updateAttributes({focalX:p,focalY:g,focusMode:!1})}}}),u&&m.jsxs(m.Fragment,{children:[m.jsx("div",{role:"slider","aria-label":"Resize image","aria-valuemin":1,"aria-valuemax":100,"aria-valuenow":a,onPointerDown:c("west"),className:"absolute left-0 top-1/2 -translate-y-1/2 h-16 w-2 rounded-sm bg-primary cursor-ew-resize shadow border border-primary/40"}),m.jsx("div",{role:"slider","aria-label":"Resize image","aria-valuemin":1,"aria-valuemax":100,"aria-valuenow":a,onPointerDown:c("east"),className:"absolute right-0 top-1/2 -translate-y-1/2 h-16 w-2 rounded-sm bg-primary cursor-ew-resize shadow border border-primary/40"})]}),u&&m.jsx("div",{className:"pointer-events-none absolute inset-0 rounded-md ring-2 ring-primary/60"}),n&&m.jsxs("div",{className:"pointer-events-none absolute -top-6 right-0 text-xs bg-primary text-primary-foreground px-2 py-0.5 rounded",children:[Number(a.toFixed(1)),"%"]})]})}const pT=u0.extend({name:"image",addAttributes(){return{...this.parent?.()||{},width:{default:null,parseHTML:t=>t.getAttribute("width")||t.style.width||null,renderHTML:t=>{const e={};return typeof t.width=="number"?e.width=t.width:typeof t.width=="string"&&t.width.trim().length>0&&(e.style=`width: ${t.width};`),e}},height:{default:null,parseHTML:t=>t.getAttribute("height")||t.style.height||null,renderHTML:t=>{const e={};if(typeof t.height=="number")e.height=t.height;else if(typeof t.height=="string"&&t.height.trim().length>0){const n=`height: ${t.height};`;e.style=e.style?`${e.style} ${n}`:n}return e}},blurDataURL:{default:null,parseHTML:t=>t.getAttribute("data-blur")||null,renderHTML:t=>t.blurDataURL?{"data-blur":t.blurDataURL}:{}},lockAspect:{default:!0,parseHTML:t=>t.getAttribute("data-lock-aspect")!=="false",renderHTML:t=>({"data-lock-aspect":String(t.lockAspect)})},align:{default:null,parseHTML:t=>t.getAttribute("data-align"),renderHTML:t=>t.align?{"data-align":t.align}:{}},caption:{default:null,parseHTML:t=>t.getAttribute("data-caption"),renderHTML:t=>t.caption?{"data-caption":t.caption}:{}},focalX:{default:null,parseHTML:t=>t.getAttribute("data-focal-x"),renderHTML:t=>t.focalX!=null?{"data-focal-x":String(t.focalX)}:{}},focalY:{default:null,parseHTML:t=>t.getAttribute("data-focal-y"),renderHTML:t=>t.focalY!=null?{"data-focal-y":String(t.focalY)}:{}},focusMode:{default:!1,parseHTML:t=>t.getAttribute("data-focus-mode")==="true",renderHTML:t=>t.focusMode?{"data-focus-mode":"true"}:{}}}},addKeyboardShortcuts(){const e=n=>()=>{const s=(this.editor.getAttributes("image")||{}).width;let i=100;typeof s=="string"&&s.endsWith("%")&&(i=parseFloat(s)||100);const o=Math.max(1,Math.min(100,i+n));return this.editor.chain().focus().updateAttributes("image",{width:`${o}%`}).run()};return{"Alt-=":e(5),"Alt-+":e(5),"Alt--":e(-5),"Alt-_":e(-5)}},addNodeView(){return ju(fT)}});var h0=Xb,f0=Yb,kd,vd;if(typeof WeakMap<"u"){let t=new WeakMap;kd=e=>t.get(e),vd=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;kd=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},vd=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var Pe=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,s=e/this.width|0;let i=r+1,o=s+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;o<this.height&&this.map[e+this.width*l]==n;l++)o++;return{left:r,top:s,right:i,bottom:o}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:s,top:i,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[i*this.width+(n<0?r-1:s)]:(n<0?i==0:o==this.height)?null:this.map[r+this.width*(n<0?i-1:o)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(s,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const i=r*this.width+s,o=this.map[i];n[o]||(n[o]=!0,!(s==t.left&&s&&this.map[i-1]==o||r==t.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const i=s+n.child(r).nodeSize;if(r==t){let o=e+t*this.width;const l=(t+1)*this.width;for(;o<l&&this.map[o]<s;)o++;return o==l?i-1:this.map[o]}s=i}}static get(t){return kd(t)||vd(t,mT(t))}};function mT(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=gT(t),n=t.childCount,r=[];let s=0,i=null;const o=[];for(let c=0,d=e*n;c<d;c++)r[c]=0;for(let c=0,d=0;c<n;c++){const u=t.child(c);d++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==u.childCount)break;const g=u.child(p),{colspan:y,rowspan:b,colwidth:w}=g.attrs;for(let M=0;M<b;M++){if(M+c>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:b-M});break}const S=s+M*e;for(let A=0;A<y;A++){r[S+A]==0?r[S+A]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:y-A});const x=w&&w[A];if(x){const k=(S+A)%e*2,v=o[k];v==null||v!=x&&o[k+1]==1?(o[k]=x,o[k+1]=1):v==x&&o[k+1]++}}}s+=y,d+=g.nodeSize}const h=(c+1)*e;let f=0;for(;s<h;)r[s++]==0&&f++;f&&(i||(i=[])).push({type:"missing",row:c,n:f}),d++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new Pe(e,n,r,i);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<n&&(a=!0);return a&&yT(l,o,t),l}function gT(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let i=0;if(n)for(let o=0;o<r;o++){const l=t.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const l=s.child(o);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function yT(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const i=t.map[s];if(r[i])continue;r[i]=!0;const o=n.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const d=(s+c)%t.width,u=e[d*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=bT(a)))[c]=u)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function bT(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function pt(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}var qn=new ye("selectingCells");function As(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function xT(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 Qt(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 ga(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=As(e.$head)||wT(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function wT(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 Sd(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function kT(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function nh(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function p0(t,e,n){const r=t.node(-1),s=Pe.get(r),i=t.start(-1),o=s.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function jr(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function m0(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<n;s++)r.colwidth.splice(e,0,0)}return r}function vT(t,e,n){const r=pt(e.type.schema).header_cell;for(let s=0;s<t.height;s++)if(e.nodeAt(t.map[n+s*t.width]).type!=r)return!1;return!0}var Te=class kn extends ee{constructor(e,n=e){const r=e.node(-1),s=Pe.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,n.pos-i),l=e.node(0),a=s.cellsInRect(o).filter(d=>d!=n.pos-i);a.unshift(n.pos-i);const c=a.map(d=>{const u=r.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);const h=i+d+1;return new lu(l.resolve(h),l.resolve(h+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(Sd(r)&&Sd(s)&&nh(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?kn.rowSelection(r,s):i&&this.isColSelection()?kn.colSelection(r,s):new kn(r,s)}return J.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=Pe.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let d=a*n.width+s.left,u=s.left;u<s.right;u++,d++){const h=n.map[d];if(i[h])continue;i[h]=!0;const f=n.findCell(h);let p=e.nodeAt(h);if(!p)throw RangeError(`No cell with offset ${h} found`);const g=s.left-f.left,y=f.right-s.right;if(g>0||y>0){let b=p.attrs;if(g>0&&(b=jr(b,0,g)),y>0&&(b=jr(b,b.colspan-y,y)),f.left<s.left){if(p=p.type.createAndFill(b),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else p=p.type.create(b,p.content)}if(f.top<s.top||f.bottom>s.bottom){const b={...p.attrs,rowspan:Math.min(f.bottom,s.bottom)-Math.max(f.top,s.top)};f.top<s.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}o.push(e.child(a).copy(O.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new P(O.from(l),1,1)}replace(e,n=P.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:l,$to:a}=s[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?P.empty:n)}const i=ee.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new P(O.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=Pe.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(n.nodeAt(i[o]),s+i[o])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),s=Pe.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(i+s.map[o.left])),l.bottom<s.height&&(n=a.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+s.map[l.left])),o.bottom<s.height&&(e=a.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new kn(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=Pe.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==n.width}eq(e){return e instanceof kn&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=Pe.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(i+s.map[o.top*s.width])),l.right<s.width&&(n=a.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+s.map[l.top*s.width])),o.right<s.width&&(e=a.resolve(i+s.map[s.width*(o.top+1)-1]))),new kn(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new kn(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new kn(e.resolve(n),e.resolve(r))}getBookmark(){return new ST(this.$anchorCell.pos,this.$headCell.pos)}};Te.prototype.visible=!1;ee.jsonID("cell",Te);var ST=class g0{constructor(e,n){this.anchor=e,this.head=n}map(e){return new g0(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&nh(n,r)?new Te(n,r):ee.near(r,1)}};function CT(t){if(!(t.selection instanceof Te))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(_e.node(r,r+n.nodeSize,{class:"selectedCell"}))}),be.create(t.doc,e)}function ET({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,s=t.depth;for(;s>=0&&!(t.after(s+1)<t.end(s));s--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(s).type.spec.tableRole)}function MT({$from:t,$to:e}){let n,r;for(let s=t.depth;s>0;s--){const i=t.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function AT(t,e,n){const r=(e||t).selection,s=(e||t).doc;let i,o;if(r instanceof q&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=Te.create(s,r.from);else if(o=="row"){const l=s.resolve(r.from+1);i=Te.rowSelection(l,l)}else if(!n){const l=Pe.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=Te.create(s,a+1,c)}}else r instanceof J&&ET(r)?i=J.create(s,r.from):r instanceof J&&MT(r)&&(i=J.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}var TT=new ye("fix-tables");function y0(t,e,n,r){const s=t.childCount,i=e.childCount;e:for(let o=0,l=0;o<i;o++){const a=e.child(o);for(let c=l,d=Math.min(s,o+3);c<d;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<s&&t.child(l).sameMarkup(a)?y0(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function b0(t,e){let n;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=NT(t,s,i,n))};return e?e.doc!=t.doc&&y0(e.doc,t.doc,0,r):t.doc.descendants(r),n}function NT(t,e,n,r){const s=Pe.get(e);if(!s.problems)return r;r||(r=t.tr);const i=[];for(let a=0;a<s.height;a++)i.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let h=0;h<u.rowspan;h++)i[c.row+h]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,jr(u,u.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const d=r.mapping.map(n);r.delete(d,d+e.nodeSize)}}let o,l;for(let a=0;a<i.length;a++)i[a]&&(o==null&&(o=a),l=a);for(let a=0,c=n+1;a<s.height;a++){const d=e.child(a),u=c+d.nodeSize,h=i[a];if(h>0){let f="cell";d.firstChild&&(f=d.firstChild.type.spec.tableRole);const p=[];for(let y=0;y<h;y++){const b=pt(t.schema)[f].createAndFill();b&&p.push(b)}const g=(a==0||o==a-1)&&l==a?c+1:u-1;r.insert(r.mapping.map(g),p)}c=u}return r.setMeta(TT,{fixTables:!0})}function fn(t){const e=t.selection,n=ga(t),r=n.node(-1),s=n.start(-1),i=Pe.get(r);return{...e instanceof Te?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function x0(t,{map:e,tableStart:n,table:r},s){let i=s>0?-1:0;vT(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){const l=o*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,m0(c.attrs,s-e.colCount(a))),o+=c.attrs.rowspan-1}else{const a=i==null?pt(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(o,s,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function _T(t,e){if(!Qt(t))return!1;if(e){const n=fn(t);e(x0(t.tr,n,n.left))}return!0}function RT(t,e){if(!Qt(t))return!1;if(e){const n=fn(t);e(x0(t.tr,n,n.right))}return!0}function OT(t,{map:e,table:n,tableStart:r},s){const i=t.mapping.maps.length;for(let o=0;o<e.height;){const l=o*e.width+s,a=e.map[l],c=n.nodeAt(a),d=c.attrs;if(s>0&&e.map[l-1]==a||s<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(i).map(r+a),null,jr(d,s-e.colCount(a)));else{const u=t.mapping.slice(i).map(r+a);t.delete(u,u+c.nodeSize)}o+=d.rowspan}}function DT(t,e){if(!Qt(t))return!1;if(e){const n=fn(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;OT(r,n,s),s!=n.left;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw RangeError("No table found");n.table=i,n.map=Pe.get(i)}e(r)}return!0}function LT(t,e,n){var r;const s=pt(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))==null?void 0:r.type)!=s)return!1;return!0}function w0(t,{map:e,tableStart:n,table:r},s){var i;let o=n;for(let c=0;c<s;c++)o+=r.child(c).nodeSize;const l=[];let a=s>0?-1:0;LT(e,r,s+a)&&(a=s==0||s==e.height?null:0);for(let c=0,d=e.width*s;c<e.width;c++,d++)if(s>0&&s<e.height&&e.map[d]==e.map[d-e.width]){const u=e.map[d],h=r.nodeAt(u).attrs;t.setNodeMarkup(n+u,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{const u=a==null?pt(r.type.schema).cell:(i=r.nodeAt(e.map[d+a*e.width]))==null?void 0:i.type,h=u?.createAndFill();h&&l.push(h)}return t.insert(o,pt(r.type.schema).row.create(null,l)),t}function IT(t,e){if(!Qt(t))return!1;if(e){const n=fn(t);e(w0(t.tr,n,n.top))}return!0}function jT(t,e){if(!Qt(t))return!1;if(e){const n=fn(t);e(w0(t.tr,n,n.bottom))}return!0}function PT(t,{map:e,table:n,tableStart:r},s){let i=0;for(let c=0;c<s;c++)i+=n.child(c).nodeSize;const o=i+n.child(s).nodeSize,l=t.mapping.maps.length;t.delete(i+r,o+r);const a=new Set;for(let c=0,d=s*e.width;c<e.width;c++,d++){const u=e.map[d];if(!a.has(u)){if(a.add(u),s>0&&u==e.map[d-e.width]){const h=n.nodeAt(u).attrs;t.setNodeMarkup(t.mapping.slice(l).map(u+r),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(s<e.height&&u==e.map[d+e.width]){const h=n.nodeAt(u),f=h.attrs,p=h.type.create({...f,rowspan:h.attrs.rowspan-1},h.content),g=e.positionAt(s+1,c,n);t.insert(t.mapping.slice(l).map(r+g),p),c+=f.colspan-1}}}}function BT(t,e){if(!Qt(t))return!1;if(e){const n=fn(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;PT(r,n,s),s!=n.top;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw RangeError("No table found");n.table=i,n.map=Pe.get(n.table)}e(r)}return!0}function Fp(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function $T({width:t,height:e,map:n},r){let s=r.top*t+r.left,i=s,o=(r.bottom-1)*t+r.left,l=s+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[o]==n[o+t])return!0;s++,o++}return!1}function Up(t,e){const n=t.selection;if(!(n instanceof Te)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=fn(t),{map:s}=r;if($T(s,r))return!1;if(e){const i=t.tr,o={};let l=O.empty,a,c;for(let d=r.top;d<r.bottom;d++)for(let u=r.left;u<r.right;u++){const h=s.map[d*s.width+u],f=r.table.nodeAt(h);if(!(o[h]||!f))if(o[h]=!0,a==null)a=h,c=f;else{Fp(f)||(l=l.append(f.content));const p=i.mapping.map(h+r.tableStart);i.delete(p,p+f.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...m0(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size){const d=a+1+c.content.size,u=Fp(c)?a+1:d;i.replaceWith(u+r.tableStart,d+r.tableStart,l)}i.setSelection(new Te(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function Vp(t,e){const n=pt(t.schema);return HT(({node:r})=>n[r.type.spec.tableRole])(t,e)}function HT(t){return(e,n)=>{var r;const s=e.selection;let i,o;if(s instanceof Te){if(s.$anchorCell.pos!=s.$headCell.pos)return!1;i=s.$anchorCell.nodeAfter,o=s.$anchorCell.pos}else{if(i=xT(s.$from),!i)return!1;o=(r=As(s.$from))==null?void 0:r.pos}if(i==null||o==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let l=i.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const d=fn(e),u=e.tr;for(let f=0;f<d.right-d.left;f++)a.push(c?{...l,colwidth:c&&c[f]?[c[f]]:null}:l);let h;for(let f=d.top;f<d.bottom;f++){let p=d.map.positionAt(f,d.left,d.table);f==d.top&&(p+=i.nodeSize);for(let g=d.left,y=0;g<d.right;g++,y++)g==d.left&&f==d.top||u.insert(h=u.mapping.map(p+d.tableStart,1),t({node:i,row:f,col:g}).createAndFill(a[y]))}u.setNodeMarkup(o,t({node:i,row:d.top,col:d.left}),a[0]),s instanceof Te&&u.setSelection(new Te(u.doc.resolve(s.$anchorCell.pos),h?u.doc.resolve(h):void 0)),n(u)}return!0}}function zT(t,e){return function(n,r){if(!Qt(n))return!1;const s=ga(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof Te?n.selection.forEachCell((o,l)=>{o.attrs[t]!==e&&i.setNodeMarkup(l,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function FT(t){return function(e,n){if(!Qt(e))return!1;if(n){const r=pt(e.schema),s=fn(e),i=e.tr,o=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=o.map(a=>s.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[a],r.cell,l[a].attrs);if(i.steps.length==0)for(let a=0;a<o.length;a++)i.setNodeMarkup(s.tableStart+o[a],r.header_cell,l[a].attrs);n(i)}return!0}}function Wp(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function xi(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?FT(t):function(n,r){if(!Qt(n))return!1;if(r){const s=pt(n.schema),i=fn(n),o=n.tr,l=Wp("row",i,s),a=Wp("column",i,s),d=(t==="column"?l:t==="row"?a:!1)?1:0,u=t=="column"?{left:0,top:d,right:1,bottom:i.map.height}:t=="row"?{left:d,top:0,right:i.map.width,bottom:1}:i,h=t=="column"?a?s.cell:s.header_cell:t=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(u).forEach(f=>{const p=f+i.tableStart,g=o.doc.nodeAt(p);g&&o.setNodeMarkup(p,h,g.attrs)}),r(o)}return!0}}xi("row",{useDeprecatedLogic:!0});xi("column",{useDeprecatedLogic:!0});var UT=xi("cell",{useDeprecatedLogic:!0});function VT(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,s=t.before();r>=0;r--){const i=t.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),s=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function qp(t){return function(e,n){if(!Qt(e))return!1;const r=VT(ga(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection(J.between(s,kT(s))).scrollIntoView())}return!0}}function WT(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function ko(t,e){const n=t.selection;if(!(n instanceof Te))return!1;if(e){const r=t.tr,s=pt(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new P(s,0,0))}),r.docChanged&&e(r)}return!0}function qT(t){if(!t.size)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,n-1),u=a<e.childCount-1?0:Math.max(0,r-1);(d||u)&&(c=Cd(pt(o).row,new P(c,d,u)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(n||r?Cd(pt(o).row,new P(e,n,r)).content:e);else return null;return KT(o,l)}function KT(t,e){const n=[];for(let s=0;s<e.length;s++){const i=e[s];for(let o=i.childCount-1;o>=0;o--){const{rowspan:l,colspan:a}=i.child(o).attrs;for(let c=s;c<s+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,n[s]);for(let s=0;s<n.length;s++)if(s>=e.length&&e.push(O.empty),n[s]<r){const i=pt(t).cell.createAndFill(),o=[];for(let l=n[s];l<r;l++)o.push(i);e[s]=e[s].append(O.from(o))}return{height:e.length,width:r,rows:e}}function Cd(t,e){const n=t.createAndFill();return new ou(n).replace(0,n.content.size,e).doc}function GT({width:t,height:e,rows:n},r,s){if(t!=r){const i=[],o=[];for(let l=0;l<n.length;l++){const a=n[l],c=[];for(let d=i[l]||0,u=0;d<r;u++){let h=a.child(u%a.childCount);d+h.attrs.colspan>r&&(h=h.type.createChecked(jr(h.attrs,h.attrs.colspan,d+h.attrs.colspan-r),h.content)),c.push(h),d+=h.attrs.colspan;for(let f=1;f<h.attrs.rowspan;f++)i[l+f]=(i[l+f]||0)+h.attrs.colspan}o.push(O.from(c))}n=o,t=r}if(e!=s){const i=[];for(let o=0,l=0;o<s;o++,l++){const a=[],c=n[l%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);o+u.attrs.rowspan>s&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,s-u.attrs.rowspan)},u.content)),a.push(u)}i.push(O.from(a))}n=i,e=s}return{width:t,height:e,rows:n}}function JT(t,e,n,r,s,i,o){const l=t.doc.type.schema,a=pt(l);let c,d;if(s>e.width)for(let u=0,h=0;u<e.height;u++){const f=n.child(u);h+=f.nodeSize;const p=[];let g;f.lastChild==null||f.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=d||(d=a.header_cell.createAndFill());for(let y=e.width;y<s;y++)p.push(g);t.insert(t.mapping.slice(o).map(h-1+r),p)}if(i>e.height){const u=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,s);p++){const y=p>=e.width?!1:n.nodeAt(e.map[g+p]).type==a.header_cell;u.push(y?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const h=a.row.create(null,O.from(u)),f=[];for(let p=e.height;p<i;p++)f.push(h);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(c||d)}function Kp(t,e,n,r,s,i,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=s;c<i;c++){const d=o*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;const h=n.nodeAt(u),{top:f,left:p}=e.findCell(u);t.setNodeMarkup(t.mapping.slice(l).map(u+r),null,{...h.attrs,rowspan:o-f}),t.insert(t.mapping.slice(l).map(e.positionAt(o,p,n)),h.type.createAndFill({...h.attrs,rowspan:f+h.attrs.rowspan-o})),c+=h.attrs.colspan-1}}return a}function Gp(t,e,n,r,s,i,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=s;c<i;c++){const d=c*e.width+o,u=e.map[d];if(e.map[d-1]==u){a=!0;const h=n.nodeAt(u),f=e.colCount(u),p=t.mapping.slice(l).map(u+r);t.setNodeMarkup(p,null,jr(h.attrs,o-f,h.attrs.colspan-(o-f))),t.insert(p+h.nodeSize,h.type.createAndFill(jr(h.attrs,0,o-f))),c+=h.attrs.rowspan-1}}return a}function Jp(t,e,n,r,s){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let o=Pe.get(i);const{top:l,left:a}=r,c=a+s.width,d=l+s.height,u=t.tr;let h=0;function f(){if(i=n?u.doc.nodeAt(n-1):u.doc,!i)throw new Error("No table found");o=Pe.get(i),h=u.mapping.maps.length}JT(u,o,i,n,c,d,h)&&f(),Kp(u,o,i,n,a,c,l,h)&&f(),Kp(u,o,i,n,a,c,d,h)&&f(),Gp(u,o,i,n,l,d,a,h)&&f(),Gp(u,o,i,n,l,d,c,h)&&f();for(let p=l;p<d;p++){const g=o.positionAt(p,a,i),y=o.positionAt(p,c,i);u.replace(u.mapping.slice(h).map(g+n),u.mapping.slice(h).map(y+n),new P(s.rows[p-l],0,0))}f(),u.setSelection(new Te(u.doc.resolve(n+o.positionAt(l,a,i)),u.doc.resolve(n+o.positionAt(d-1,c-1,i)))),e(u)}var YT=Su({ArrowLeft:vo("horiz",-1),ArrowRight:vo("horiz",1),ArrowUp:vo("vert",-1),ArrowDown:vo("vert",1),"Shift-ArrowLeft":So("horiz",-1),"Shift-ArrowRight":So("horiz",1),"Shift-ArrowUp":So("vert",-1),"Shift-ArrowDown":So("vert",1),Backspace:ko,"Mod-Backspace":ko,Delete:ko,"Mod-Delete":ko});function Po(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function vo(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof Te)return Po(n,r,ee.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=k0(s,t,e);if(o==null)return!1;if(t=="horiz")return Po(n,r,ee.near(n.doc.resolve(i.head+e),e));{const l=n.doc.resolve(o),a=p0(l,t,e);let c;return a?c=ee.near(a,1):e<0?c=ee.near(n.doc.resolve(l.before(-1)),-1):c=ee.near(n.doc.resolve(l.after(-1)),1),Po(n,r,c)}}}function So(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let o;if(i instanceof Te)o=i;else{const a=k0(s,t,e);if(a==null)return!1;o=new Te(n.doc.resolve(a))}const l=p0(o.$headCell,t,e);return l?Po(n,r,new Te(o.$anchorCell,l)):!1}}function XT(t,e){const n=t.state.doc,r=As(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Te(r))),!0):!1}function ZT(t,e,n){if(!Qt(t.state))return!1;let r=qT(n);const s=t.state.selection;if(s instanceof Te){r||(r={width:1,height:1,rows:[O.from(Cd(pt(t.state.schema).cell,n))]});const i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),l=Pe.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=GT(r,l.right-l.left,l.bottom-l.top),Jp(t.state,t.dispatch,o,l,r),!0}else if(r){const i=ga(t.state),o=i.start(-1);return Jp(t.state,t.dispatch,o,Pe.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function QT(t,e){var n;if(e.ctrlKey||e.metaKey)return;const r=Yp(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof Te)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=As(t.state.selection.$anchor))!=null&&((n=Mc(t,e))==null?void 0:n.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(a,c){let d=Mc(t,c);const u=qn.getState(t.state)==null;if(!d||!nh(a,d))if(u)d=a;else return;const h=new Te(a,d);if(u||!t.state.selection.eq(h)){const f=t.state.tr.setSelection(h);u&&f.setMeta(qn,a.pos),t.dispatch(f)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),qn.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(qn,-1))}function l(a){const c=a,d=qn.getState(t.state);let u;if(d!=null)u=t.state.doc.resolve(d);else if(Yp(t,c.target)!=r&&(u=Mc(t,e),!u))return o();u&&i(u,c)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",l)}function k0(t,e,n){if(!(t.state.selection instanceof J))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=r.before(s),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?l:null}}return null}function Yp(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Mc(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?As(t.state.doc.resolve(n.pos)):null}var eN=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Ed(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,Ed(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Ed(t,e,n,r,s,i){var o;let l=0,a=!0,c=e.firstChild;const d=t.firstChild;if(d){for(let u=0,h=0;u<d.childCount;u++){const{colspan:f,colwidth:p}=d.child(u).attrs;for(let g=0;g<f;g++,h++){const y=s==h?i:p&&p[g],b=y?y+"px":"";if(l+=y||r,y||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const w=document.createElement("col");w.style.width=b,e.appendChild(w)}}}for(;c;){const u=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=u}a?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}var Rt=new ye("tableColumnResizing");function tN({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=eN,lastColumnResizable:s=!0}={}){const i=new me({key:Rt,state:{init(o,l){var a,c;const d=(c=(a=i.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,u=pt(l.schema).table.name;return r&&d&&(d[u]=(h,f)=>new r(h,n,f)),new nN(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=Rt.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{rN(o,l,t,s)},mouseleave:o=>{sN(o)},mousedown:(o,l)=>{iN(o,l,e,n)}},decorations:o=>{const l=Rt.getState(o);if(l&&l.activeHandle>-1)return dN(o,l.activeHandle)},nodeViews:{}}});return i}var nN=class Bo{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Rt);if(r&&r.setHandle!=null)return new Bo(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Bo(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return Sd(e.doc.resolve(s))||(s=-1),new Bo(s,n.dragging)}return n}};function rN(t,e,n,r){if(!t.editable)return;const s=Rt.getState(t.state);if(s&&!s.dragging){const i=lN(e.target);let o=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=n?o=Xp(t,e,"left",n):a-e.clientX<=n&&(o=Xp(t,e,"right",n))}if(o!=s.activeHandle){if(!r&&o!==-1){const l=t.state.doc.resolve(o),a=l.node(-1),c=Pe.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}v0(t,o)}}}function sN(t){if(!t.editable)return;const e=Rt.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&v0(t,-1)}function iN(t,e,n,r){var s;if(!t.editable)return!1;const i=(s=t.dom.ownerDocument.defaultView)!=null?s:window,o=Rt.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=t.state.doc.nodeAt(o.activeHandle),a=oN(t,o.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Rt,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const h=Rt.getState(t.state);h?.dragging&&(aN(t,h.activeHandle,Zp(h.dragging,u,n)),t.dispatch(t.state.tr.setMeta(Rt,{setDragging:null})))}function d(u){if(!u.which)return c(u);const h=Rt.getState(t.state);if(h&&h.dragging){const f=Zp(h.dragging,u,n);Qp(t,h.activeHandle,f,r)}}return Qp(t,o.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function oN(t,e,{colspan:n,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=t.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,a=n;if(r)for(let c=0;c<n;c++)r[c]&&(l-=r[c],a--);return l/a}function lN(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Xp(t,e,n,r){const s=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:o}=i,l=As(t.state.doc.resolve(o));if(!l)return-1;if(n=="right")return l.pos;const a=Pe.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function Zp(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function v0(t,e){t.dispatch(t.state.tr.setMeta(Rt,{setHandle:e}))}function aN(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),i=Pe.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<i.height;c++){const d=c*i.width+l;if(c&&i.map[d]==i.map[d-i.width])continue;const u=i.map[d],h=s.nodeAt(u).attrs,f=h.colspan==1?0:l-i.colCount(u);if(h.colwidth&&h.colwidth[f]==n)continue;const p=h.colwidth?h.colwidth.slice():cN(h.colspan);p[f]=n,a.setNodeMarkup(o+u,null,{...h,colwidth:p})}a.docChanged&&t.dispatch(a)}function Qp(t,e,n,r){const s=t.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),l=Pe.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;let a=t.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Ed(i,a.firstChild,a,r,l,n)}function cN(t){return Array(t).fill(0)}function dN(t,e){var n;const r=[],s=t.doc.resolve(e),i=s.node(-1);if(!i)return be.empty;const o=Pe.get(i),l=s.start(-1),a=o.colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;for(let c=0;c<o.height;c++){const d=a+c*o.width;if((a==o.width-1||o.map[d]!=o.map[d+1])&&(c==0||o.map[d]!=o.map[d-o.width])){const u=o.map[d],h=l+u+i.nodeAt(u).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",(n=Rt.getState(t))!=null&&n.dragging&&r.push(_e.node(l+u,l+u+i.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),r.push(_e.widget(h,f))}}return be.create(t.doc,r)}function uN({allowTableNodeSelection:t=!1}={}){return new me({key:qn,state:{init(){return null},apply(e,n){const r=e.getMeta(qn);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:s,pos:i}=e.mapping.mapResult(n);return s?null:i}},props:{decorations:CT,handleDOMEvents:{mousedown:QT},createSelectionBetween(e){return qn.getState(e.state)!=null?e.state.selection:null},handleTripleClick:XT,handleKeyDown:YT,handlePaste:ZT},appendTransaction(e,n,r){return AT(r,b0(r,n),t)}})}var S0=Oe.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const r=t.getAttribute("colwidth"),s=r?r.split(",").map(i=>parseInt(i,10)):null;if(!s){const i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),o=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(o&&o>-1&&i&&i[o]){const l=i[o].getAttribute("width");return l?[parseInt(l,10)]:null}}return s}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",pe(this.options.HTMLAttributes,t),0]}}),C0=Oe.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",pe(this.options.HTMLAttributes,t),0]}}),E0=Oe.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",pe(this.options.HTMLAttributes,t),0]}});function Md(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function em(t,e,n,r,s,i){var o;let l=0,a=!0,c=e.firstChild;const d=t.firstChild;if(d!==null)for(let u=0,h=0;u<d.childCount;u+=1){const{colspan:f,colwidth:p}=d.child(u).attrs;for(let g=0;g<f;g+=1,h+=1){const y=s===h?i:p&&p[g],b=y?`${y}px`:"";if(l+=y||r,y||(a=!1),c){if(c.style.width!==b){const[w,M]=Md(r,y);c.style.setProperty(w,M)}c=c.nextSibling}else{const w=document.createElement("col"),[M,S]=Md(r,y);w.style.setProperty(M,S),e.appendChild(w)}}}for(;c;){const u=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=u}a?(n.style.width=`${l}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${l}px`)}var hN=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),em(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,em(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function fN(t,e,n,r){let s=0,i=!0;const o=[],l=t.firstChild;if(!l)return{};for(let u=0,h=0;u<l.childCount;u+=1){const{colspan:f,colwidth:p}=l.child(u).attrs;for(let g=0;g<f;g+=1,h+=1){const y=n===h?r:p&&p[g];s+=y||e,y||(i=!1);const[b,w]=Md(e,y);o.push(["col",{style:`${b}: ${w}`}])}}const a=i?`${s}px`:"",c=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:a,tableMinWidth:c}}function tm(t,e){return t.createAndFill()}function pN(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function mN(t,e,n,r,s){const i=pN(t),o=[],l=[];for(let c=0;c<n;c+=1){const d=tm(i.cell);if(d&&l.push(d),r){const u=tm(i.header_cell);u&&o.push(u)}}const a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?o:l));return i.table.createChecked(null,a)}function gN(t){return t instanceof Te}var Co=({editor:t})=>{const{selection:e}=t.state;if(!gN(e))return!1;let n=0;const r=Hy(e.ranges[0].$from,i=>i.type.name==="table");return r?.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},yN="";function bN(t){return(t||"").replace(/\s+/g," ").trim()}function xN(t,e,n={}){var r;const s=(r=n.cellLineSeparator)!=null?r:yN;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(p=>{const g=[];p.content&&p.content.forEach(y=>{let b="";y.content&&Array.isArray(y.content)&&y.content.length>1?b=y.content.map(A=>e.renderChildren(A)).join(s):b=y.content?e.renderChildren(y.content):"";const w=bN(b),M=y.type==="tableHeader";g.push({text:w,isHeader:M})}),i.push(g)});const o=i.reduce((p,g)=>Math.max(p,g.length),0);if(o===0)return"";const l=new Array(o).fill(0);i.forEach(p=>{var g;for(let y=0;y<o;y+=1){const w=(((g=p[y])==null?void 0:g.text)||"").length;w>l[y]&&(l[y]=w),l[y]<3&&(l[y]=3)}});const a=(p,g)=>p+" ".repeat(Math.max(0,g-p.length)),c=i[0],d=c.some(p=>p.isHeader);let u=`
|
|
146
146
|
`;const h=new Array(o).fill(0).map((p,g)=>d&&c[g]&&c[g].text||"");return u+=`| ${h.map((p,g)=>a(p,l[g])).join(" | ")} |
|
|
147
147
|
`,u+=`| ${l.map(p=>"-".repeat(Math.max(3,p))).join(" | ")} |
|
|
148
148
|
`,(d?i.slice(1):i).forEach(p=>{u+=`| ${new Array(o).fill(0).map((g,y)=>a(p[y]&&p[y].text||"",l[y])).join(" | ")} |
|
|
149
|
-
`}),u}var wN=xN,M0=De.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:hN,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:s}=fN(t,this.options.cellMinWidth),i=["table",be(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${s}`}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},i]:i},parseMarkdown:(t,e)=>{const n=[];if(t.header){const r=[];t.header.forEach(s=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(r=>{const s=[];r.forEach(i=>{s.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>wN(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const o=mN(i.schema,t,e,n);if(s){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(J.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>_T(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>RT(t,e),deleteColumn:()=>({state:t,dispatch:e})=>DT(t,e),addRowBefore:()=>({state:t,dispatch:e})=>IT(t,e),addRowAfter:()=>({state:t,dispatch:e})=>jT(t,e),deleteRow:()=>({state:t,dispatch:e})=>BT(t,e),deleteTable:()=>({state:t,dispatch:e})=>WT(t,e),mergeCells:()=>({state:t,dispatch:e})=>Up(t,e),splitCell:()=>({state:t,dispatch:e})=>Vp(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})=>UT(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Up(t,e)?!0:Vp(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>zT(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>qp(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>qp(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&b0(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Te.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:Co,"Mod-Backspace":Co,Delete:Co,"Mod-Delete":Co}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[tN({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],uN({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:we(G(t,"tableRole",e))}}});de.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(M0.configure(this.options.table)),this.options.tableCell!==!1&&t.push(S0.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(C0.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(E0.configure(this.options.tableRow)),t}});var kN=E0,vN=C0,SN=S0,CN=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,EN=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,MN=Zt.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",be(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){const s=/^(==)([^=]+)(==)/.exec(t);if(s){const i=s[2].trim(),o=n.inlineTokens(i);return{type:"highlight",raw:s[0],text:i,tokens:o}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Lr({find:CN,type:this.type})]},addPasteRules(){return[sr({find:EN,type:this.type})]}}),AN=MN,TN=Zt.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",be(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()}}}),NN=TN,_N=Zt.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",be(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()}}}),RN=_N,ON=de.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).every(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),DN=ON,LN=20,A0=(t,e=0)=>{const n=[];return!t.children.length||e>LN||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...A0(r,e+1))}),n},IN=t=>{if(!t.children.length)return;const e=A0(t);e&&e.forEach(n=>{var r,s;const i=n.getAttribute("style"),o=(s=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:s.getAttribute("style");n.setAttribute("style",`${o};${i}`)})},jN=Zt.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&IN(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",be(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),PN=de.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(s=>s.trim()).filter(Boolean);for(let s=r.length-1;s>=0;s-=1){const i=r[s].split(":");if(i.length>=2){const o=i[0].trim().toLowerCase(),l=i.slice(1).join(":").trim();if(o==="background-color")return l.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),BN=de.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(s=>s.trim()).filter(Boolean);for(let s=r.length-1;s>=0;s-=1){const i=r[s].split(":");if(i.length>=2){const o=i[0].trim().toLowerCase(),l=i.slice(1).join(":").trim();if(o==="color")return l.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?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()}}}),$N=de.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),HN=de.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),zN=de.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}}),FN=de.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(PN.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(BN.configure(this.options.color)),this.options.fontFamily!==!1&&t.push($N.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(HN.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(zN.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(jN.configure(this.options.textStyle)),t}}),UN=QA,VN=t=>Be({find:/--$/,replace:t??"—"}),WN=t=>Be({find:/\.\.\.$/,replace:t??"…"}),qN=t=>Be({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"“"}),KN=t=>Be({find:/"$/,replace:t??"”"}),GN=t=>Be({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"‘"}),JN=t=>Be({find:/'$/,replace:t??"’"}),YN=t=>Be({find:/<-$/,replace:t??"←"}),XN=t=>Be({find:/->$/,replace:t??"→"}),ZN=t=>Be({find:/\(c\)$/,replace:t??"©"}),QN=t=>Be({find:/\(tm\)$/,replace:t??"™"}),e_=t=>Be({find:/\(sm\)$/,replace:t??"℠"}),t_=t=>Be({find:/\(r\)$/,replace:t??"®"}),n_=t=>Be({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),r_=t=>Be({find:/\+\/-$/,replace:t??"±"}),s_=t=>Be({find:/!=$/,replace:t??"≠"}),i_=t=>Be({find:/<<$/,replace:t??"«"}),o_=t=>Be({find:/>>$/,replace:t??"»"}),l_=t=>Be({find:/\d+\s?([*x])\s?\d+$/,replace:t??"×"}),a_=t=>Be({find:/\^2$/,replace:t??"²"}),c_=t=>Be({find:/\^3$/,replace:t??"³"}),d_=t=>Be({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),u_=t=>Be({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),h_=de.create({name:"typography",addOptions(){return{closeDoubleQuote:"”",closeSingleQuote:"’",copyright:"©",ellipsis:"…",emDash:"—",laquo:"«",leftArrow:"←",multiplication:"×",notEqual:"≠",oneHalf:"½",oneQuarter:"¼",openDoubleQuote:"“",openSingleQuote:"‘",plusMinus:"±",raquo:"»",registeredTrademark:"®",rightArrow:"→",servicemark:"℠",superscriptThree:"³",superscriptTwo:"²",threeQuarters:"¾",trademark:"™"}},addInputRules(){const t=[];return this.options.emDash!==!1&&t.push(VN(this.options.emDash)),this.options.ellipsis!==!1&&t.push(WN(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&t.push(qN(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&t.push(KN(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&t.push(GN(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&t.push(JN(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&t.push(YN(this.options.leftArrow)),this.options.rightArrow!==!1&&t.push(XN(this.options.rightArrow)),this.options.copyright!==!1&&t.push(ZN(this.options.copyright)),this.options.trademark!==!1&&t.push(QN(this.options.trademark)),this.options.servicemark!==!1&&t.push(e_(this.options.servicemark)),this.options.registeredTrademark!==!1&&t.push(t_(this.options.registeredTrademark)),this.options.oneHalf!==!1&&t.push(n_(this.options.oneHalf)),this.options.plusMinus!==!1&&t.push(r_(this.options.plusMinus)),this.options.notEqual!==!1&&t.push(s_(this.options.notEqual)),this.options.laquo!==!1&&t.push(i_(this.options.laquo)),this.options.raquo!==!1&&t.push(o_(this.options.raquo)),this.options.multiplication!==!1&&t.push(l_(this.options.multiplication)),this.options.superscriptTwo!==!1&&t.push(a_(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&t.push(c_(this.options.superscriptThree)),this.options.oneQuarter!==!1&&t.push(d_(this.options.oneQuarter)),this.options.threeQuarters!==!1&&t.push(u_(this.options.threeQuarters)),t}}),f_=h_,p_=o0,m_=l0;const Kt=()=>new Map,Ad=t=>{const e=Kt();return t.forEach((n,r)=>{e.set(r,n)}),e},On=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},g_=(t,e)=>{const n=[];for(const[r,s]of t)n.push(e(s,r));return n},y_=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},Pr=()=>new Set,Ac=t=>t[t.length-1],b_=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},Br=Array.from,x_=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},Td=Array.isArray;class T0{constructor(){this._observers=Kt()}on(e,n){return On(this._observers,e,Pr).add(n),n}once(e,n){const r=(...s)=>{this.off(e,r),n(...s)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return Br((this._observers.get(e)||Kt()).values()).forEach(r=>r(...n))}destroy(){this._observers=Kt()}}const _n=Math.floor,$o=Math.abs,bs=(t,e)=>t<e?t:e,lr=(t,e)=>t>e?t:e,N0=t=>t!==0?t<0:1/t<0,nm=1,rm=2,Tc=4,Nc=8,wi=32,Tn=64,yt=128,w_=1<<29,ya=31,Nd=63,Tr=127,k_=2147483647,_0=Number.MAX_SAFE_INTEGER,v_=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&_n(t)===t),S_=String.fromCharCode,C_=t=>t.toLowerCase(),E_=/^\s*/g,M_=t=>t.replace(E_,""),A_=/([A-Z])/g,sm=(t,e)=>M_(t.replace(A_,n=>`${e}${C_(n)}`)),T_=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},ki=typeof TextEncoder<"u"?new TextEncoder:null,N_=t=>ki.encode(t),__=ki?N_:T_;let ti=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});ti&&ti.decode(new Uint8Array).length===1&&(ti=null);class Hi{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const zi=()=>new Hi,R_=t=>{const e=zi();return t(e),qt(e)},O_=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},qt=t=>{const e=new Uint8Array(O_(t));let n=0;for(let r=0;r<t.bufs.length;r++){const s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},D_=(t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(lr(n,e)*2),t.cpos=0)},Xe=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},_d=Xe,me=(t,e)=>{for(;e>Tr;)Xe(t,yt|Tr&e),e=_n(e/128);Xe(t,Tr&e)},rh=(t,e)=>{const n=N0(e);for(n&&(e=-e),Xe(t,(e>Nd?yt:0)|(n?Tn:0)|Nd&e),e=_n(e/64);e>0;)Xe(t,(e>Tr?yt:0)|Tr&e),e=_n(e/128)},Rd=new Uint8Array(3e4),L_=Rd.length/3,I_=(t,e)=>{if(e.length<L_){const n=ki.encodeInto(e,Rd).written||0;me(t,n);for(let r=0;r<n;r++)Xe(t,Rd[r])}else Tt(t,__(e))},j_=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;me(t,r);for(let s=0;s<r;s++)Xe(t,n.codePointAt(s))},ls=ki&&ki.encodeInto?I_:j_,ba=(t,e)=>{const n=t.cbuf.length,r=t.cpos,s=bs(n-r,e.length),i=e.length-s;t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,i>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(lr(n*2,i)),t.cbuf.set(e.subarray(s)),t.cpos=i)},Tt=(t,e)=>{me(t,e.byteLength),ba(t,e)},sh=(t,e)=>{D_(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},P_=(t,e)=>sh(t,4).setFloat32(0,e,!1),B_=(t,e)=>sh(t,8).setFloat64(0,e,!1),$_=(t,e)=>sh(t,8).setBigInt64(0,e,!1),im=new DataView(new ArrayBuffer(4)),H_=t=>(im.setFloat32(0,t),im.getFloat32(0)===t),xs=(t,e)=>{switch(typeof e){case"string":Xe(t,119),ls(t,e);break;case"number":v_(e)&&$o(e)<=k_?(Xe(t,125),rh(t,e)):H_(e)?(Xe(t,124),P_(t,e)):(Xe(t,123),B_(t,e));break;case"bigint":Xe(t,122),$_(t,e);break;case"object":if(e===null)Xe(t,126);else if(Td(e)){Xe(t,117),me(t,e.length);for(let n=0;n<e.length;n++)xs(t,e[n])}else if(e instanceof Uint8Array)Xe(t,116),Tt(t,e);else{Xe(t,118);const n=Object.keys(e);me(t,n.length);for(let r=0;r<n.length;r++){const s=n[r];ls(t,s),xs(t,e[s])}}break;case"boolean":Xe(t,e?120:121);break;default:Xe(t,127)}};class om extends Hi{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&me(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const lm=t=>{t.count>0&&(rh(t.encoder,t.count===1?t.s:-t.s),t.count>1&&me(t.encoder,t.count-2))};class Ho{constructor(){this.encoder=new Hi,this.s=0,this.count=0}write(e){this.s===e?this.count++:(lm(this),this.count=1,this.s=e)}toUint8Array(){return lm(this),qt(this.encoder)}}const am=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);rh(t.encoder,e),t.count>1&&me(t.encoder,t.count-2)}};class _c{constructor(){this.encoder=new Hi,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(am(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return am(this),qt(this.encoder)}}class z_{constructor(){this.sarr=[],this.s="",this.lensE=new Ho}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Hi;return this.sarr.push(this.s),this.s="",ls(e,this.sarr.join("")),ba(e,this.lensE.toUint8Array()),qt(e)}}const ar=t=>new Error(t),Gt=()=>{throw ar("Method unimplemented")},Mt=()=>{throw ar("Unexpected case")},R0=ar("Unexpected end of array"),O0=ar("Integer out of Range");class xa{constructor(e){this.arr=e,this.pos=0}}const ih=t=>new xa(t),F_=t=>t.pos!==t.arr.length,U_=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},It=t=>U_(t,Re(t)),vi=t=>t.arr[t.pos++],Re=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const s=t.arr[t.pos++];if(e=e+(s&Tr)*n,n*=128,s<yt)return e;if(e>_0)throw O0}throw R0},oh=t=>{let e=t.arr[t.pos++],n=e&Nd,r=64;const s=(e&Tn)>0?-1:1;if((e&yt)===0)return s*n;const i=t.arr.length;for(;t.pos<i;){if(e=t.arr[t.pos++],n=n+(e&Tr)*r,r*=128,e<yt)return s*n;if(n>_0)throw O0}throw R0},V_=t=>{let e=Re(t);if(e===0)return"";{let n=String.fromCodePoint(vi(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(vi(t));else for(;e>0;){const r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},W_=t=>ti.decode(It(t)),Od=ti?W_:V_,lh=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},q_=t=>lh(t,4).getFloat32(0,!1),K_=t=>lh(t,8).getFloat64(0,!1),G_=t=>lh(t,8).getBigInt64(0,!1),J_=[t=>{},t=>null,oh,q_,K_,G_,t=>!1,t=>!0,Od,t=>{const e=Re(t),n={};for(let r=0;r<e;r++){const s=Od(t);n[s]=jl(t)}return n},t=>{const e=Re(t),n=[];for(let r=0;r<e;r++)n.push(jl(t));return n},It],jl=t=>J_[127-vi(t)](t);class cm extends xa{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),F_(this)?this.count=Re(this)+1:this.count=-1),this.count--,this.s}}class zo extends xa{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=oh(this);const e=N0(this.s);this.count=1,e&&(this.s=-this.s,this.count=Re(this)+2)}return this.count--,this.s}}class Rc extends xa{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=oh(this),n=e&1;this.diff=_n(e/2),this.count=1,n&&(this.count=Re(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Y_{constructor(e){this.decoder=new zo(e),this.str=Od(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const X_=crypto.getRandomValues.bind(crypto),Z_=Math.random,D0=()=>X_(new Uint32Array(1))[0],Q_=t=>t[_n(Z_()*t.length)],eR="10000000-1000-4000-8000"+-1e11,tR=()=>eR.replace(/[018]/g,t=>(t^D0()&15>>t/4).toString(16)),nR=Date.now,dm=t=>new Promise(t);Promise.all.bind(Promise);const um=t=>t===void 0?null:t;class rR{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let L0=new rR,sR=!0;try{typeof localStorage<"u"&&localStorage&&(L0=localStorage,sR=!1)}catch{}const iR=L0,oR=Object.assign,I0=Object.keys,lR=(t,e)=>{for(const n in t)e(t[n],n)},hm=t=>I0(t).length,aR=t=>{for(const e in t)return!1;return!0},j0=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},cR=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),dR=(t,e)=>t===e||hm(t)===hm(e)&&j0(t,(n,r)=>(n!==void 0||cR(e,r))&&e[r]===n),uR=Object.freeze,P0=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&P0(t[e])}return uR(t)},ah=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&ah(t,e,n+1)}},hR=(t,e)=>e.includes(t),ws=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",B0=typeof window<"u"&&typeof document<"u"&&!ws;let rn;const fR=()=>{if(rn===void 0)if(ws){rn=Kt();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&rn.set(e,""),e=r):e!==null&&(rn.set(e,r),e=null)}e!==null&&rn.set(e,"")}else typeof location=="object"?(rn=Kt(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");rn.set(`--${sm(e,"-")}`,n),rn.set(`-${sm(e,"-")}`,n)}})):rn=Kt();return rn},Dd=t=>fR().has(t),Pl=t=>um(ws?process.env[t.toUpperCase().replaceAll("-","_")]:iR.getItem(t)),$0=t=>Dd("--"+t)||Pl(t)!==null;$0("production");const pR=ws&&hR(process.env.FORCE_COLOR,["true","1","2"]),mR=pR||!Dd("--no-colors")&&!$0("no-color")&&(!ws||process.stdout.isTTY)&&(!ws||Dd("--color")||Pl("COLORTERM")!==null||(Pl("TERM")||"").includes("color")),gR=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=S_(t[n]);return btoa(e)},yR=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),bR=B0?gR:yR,xR=t=>R_(e=>xs(e,t));class wR{constructor(e,n){this.left=e,this.right=n}}const xn=(t,e)=>new wR(t,e),kR=typeof document<"u"?document:{};typeof DOMParser<"u"&&new DOMParser;const vR=t=>g_(t,(e,n)=>`${n}:${e};`).join(""),SR=t=>class{constructor(n){this._=n}destroy(){t(this._)}},CR=SR(clearTimeout),H0=(t,e)=>new CR(setTimeout(e,t)),Dn=Symbol,z0=Dn(),F0=Dn(),ER=Dn(),MR=Dn(),AR=Dn(),U0=Dn(),TR=Dn(),ch=Dn(),NR=Dn(),_R=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r<t.length;r++){const s=t[r];if(s===void 0)break;if(s.constructor===String||s.constructor===Number)e.push(s);else if(s.constructor===Object)break}for(r>0&&n.push(e.join(""));r<t.length;r++){const s=t[r];s instanceof Symbol||n.push(s)}return n},RR={[z0]:xn("font-weight","bold"),[F0]:xn("font-weight","normal"),[ER]:xn("color","blue"),[AR]:xn("color","green"),[MR]:xn("color","grey"),[U0]:xn("color","red"),[TR]:xn("color","purple"),[ch]:xn("color","orange"),[NR]:xn("color","black")},OR=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[],r=Kt();let s=[],i=0;for(;i<t.length;i++){const o=t[i],l=RR[o];if(l!==void 0)r.set(l.left,l.right);else{if(o===void 0)break;if(o.constructor===String||o.constructor===Number){const a=vR(r);i>0||a.length>0?(e.push("%c"+o),n.push(a)):e.push(o)}else break}}for(i>0&&(s=n,s.unshift(e.join("")));i<t.length;i++){const o=t[i];o instanceof Symbol||s.push(o)}return s},V0=mR?OR:_R,DR=(...t)=>{console.log(...V0(t)),q0.forEach(e=>e.print(t))},W0=(...t)=>{console.warn(...V0(t)),t.unshift(ch),q0.forEach(e=>e.print(t))},q0=Pr(),K0=t=>({[Symbol.iterator](){return this},next:t}),LR=(t,e)=>K0(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Oc=(t,e)=>K0(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class dh{constructor(e,n){this.clock=e,this.len=n}}class Ts{constructor(){this.clients=new Map}}const cr=(t,e,n)=>e.clients.forEach((r,s)=>{const i=t.doc.store.clients.get(s);if(i!=null){const o=i[i.length-1],l=o.id.clock+o.length;for(let a=0,c=r[a];a<r.length&&c.clock<l;c=r[++a])tx(t,i,c.clock,c.len,n)}}),IR=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const s=_n((n+r)/2),i=t[s],o=i.clock;if(o<=e){if(e<o+i.len)return s;n=s+1}else r=s-1}return null},Ns=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&IR(n,e.clock)!==null},uh=t=>{t.clients.forEach(e=>{e.sort((s,i)=>s.clock-i.clock);let n,r;for(n=1,r=1;n<e.length;n++){const s=e[r-1],i=e[n];s.clock+s.len>=i.clock?s.len=lr(s.len,i.clock+i.len-s.clock):(r<n&&(e[r]=i),r++)}e.length=r})},Ld=t=>{const e=new Ts;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){const i=r.slice();for(let o=n+1;o<t.length;o++)b_(i,t[o].clients.get(s)||[]);e.clients.set(s,i)}});return uh(e),e},Si=(t,e,n,r)=>{On(t.clients,e,()=>[]).push(new dh(n,r))},G0=()=>new Ts,jR=t=>{const e=G0();return t.clients.forEach((n,r)=>{const s=[];for(let i=0;i<n.length;i++){const o=n[i];if(o.deleted){const l=o.id.clock;let a=o.length;if(i+1<n.length)for(let c=n[i+1];i+1<n.length&&c.deleted;c=n[++i+1])a+=c.length;s.push(new dh(l,a))}}s.length>0&&e.clients.set(r,s)}),e},hh=(t,e)=>{me(t.restEncoder,e.clients.size),Br(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),me(t.restEncoder,n);const s=r.length;me(t.restEncoder,s);for(let i=0;i<s;i++){const o=r[i];t.writeDsClock(o.clock),t.writeDsLen(o.len)}})},PR=t=>{const e=new Ts,n=Re(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const s=Re(t.restDecoder),i=Re(t.restDecoder);if(i>0){const o=On(e.clients,s,()=>[]);for(let l=0;l<i;l++)o.push(new dh(t.readDsClock(),t.readDsLen()))}}return e},fm=(t,e,n)=>{const r=new Ts,s=Re(t.restDecoder);for(let i=0;i<s;i++){t.resetDsCurVal();const o=Re(t.restDecoder),l=Re(t.restDecoder),a=n.clients.get(o)||[],c=Ue(n,o);for(let d=0;d<l;d++){const u=t.readDsClock(),h=u+t.readDsLen();if(u<c){c<h&&Si(r,o,c,h-c);let f=Yt(a,u),p=a[f];for(!p.deleted&&p.id.clock<u&&(a.splice(f+1,0,Vl(e,p,u-p.id.clock)),f++);f<a.length&&(p=a[f++],p.id.clock<h);)p.deleted||(h<p.id.clock+p.length&&a.splice(f,0,Vl(e,p,h-p.id.clock)),p.delete(e))}else Si(r,o,u,h-u)}}if(r.clients.size>0){const i=new wa;return me(i.restEncoder,0),hh(i,r),i.toUint8Array()}return null},J0=D0;class Ur extends T0{constructor({guid:e=tR(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:l=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=J0(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new Q0,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=dm(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const a=()=>dm(c=>{const d=u=>{(u===void 0||u===!0)&&(this.off("sync",d),c())};this.on("sync",d)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=a()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=a()}load(){const e=this._item;e!==null&&!this.shouldLoad&&Ce(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Br(this.subdocs).map(e=>e.guid))}transact(e,n=null){return Ce(this,e,n)}get(e,n=tt){const r=On(this.share,e,()=>{const i=new n;return i._integrate(this,null),i}),s=r.constructor;if(n!==tt&&s!==n)if(s===tt){const i=new n;i._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(e,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,ds)}getText(e=""){return this.get(e,dr)}getMap(e=""){return this.get(e,ks)}getXmlElement(e=""){return this.get(e,ht)}getXmlFragment(e=""){return this.get(e,$r)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,Br(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new Ur({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,Ce(e.parent.doc,r=>{const s=n.doc;e.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class BR{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Re(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Re(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Bl extends BR{constructor(e){super(e),this.keys=[],Re(e),this.keyClockDecoder=new Rc(It(e)),this.clientDecoder=new zo(It(e)),this.leftClockDecoder=new Rc(It(e)),this.rightClockDecoder=new Rc(It(e)),this.infoDecoder=new cm(It(e),vi),this.stringDecoder=new Y_(It(e)),this.parentInfoDecoder=new cm(It(e),vi),this.typeRefDecoder=new zo(It(e)),this.lenDecoder=new zo(It(e))}readLeftID(){return new as(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new as(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return jl(this.restDecoder)}readBuf(){return It(this.restDecoder)}readJSON(){return jl(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class $R{constructor(){this.restEncoder=zi()}toUint8Array(){return qt(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){me(this.restEncoder,e)}writeDsLen(e){me(this.restEncoder,e)}}class HR extends $R{writeLeftID(e){me(this.restEncoder,e.client),me(this.restEncoder,e.clock)}writeRightID(e){me(this.restEncoder,e.client),me(this.restEncoder,e.clock)}writeClient(e){me(this.restEncoder,e)}writeInfo(e){_d(this.restEncoder,e)}writeString(e){ls(this.restEncoder,e)}writeParentInfo(e){me(this.restEncoder,e?1:0)}writeTypeRef(e){me(this.restEncoder,e)}writeLen(e){me(this.restEncoder,e)}writeAny(e){xs(this.restEncoder,e)}writeBuf(e){Tt(this.restEncoder,e)}writeJSON(e){ls(this.restEncoder,JSON.stringify(e))}writeKey(e){ls(this.restEncoder,e)}}class zR{constructor(){this.restEncoder=zi(),this.dsCurrVal=0}toUint8Array(){return qt(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,me(this.restEncoder,n)}writeDsLen(e){e===0&&Mt(),me(this.restEncoder,e-1),this.dsCurrVal+=e}}class wa extends zR{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new _c,this.clientEncoder=new Ho,this.leftClockEncoder=new _c,this.rightClockEncoder=new _c,this.infoEncoder=new om(_d),this.stringEncoder=new z_,this.parentInfoEncoder=new om(_d),this.typeRefEncoder=new Ho,this.lenEncoder=new Ho}toUint8Array(){const e=zi();return me(e,0),Tt(e,this.keyClockEncoder.toUint8Array()),Tt(e,this.clientEncoder.toUint8Array()),Tt(e,this.leftClockEncoder.toUint8Array()),Tt(e,this.rightClockEncoder.toUint8Array()),Tt(e,qt(this.infoEncoder)),Tt(e,this.stringEncoder.toUint8Array()),Tt(e,qt(this.parentInfoEncoder)),Tt(e,this.typeRefEncoder.toUint8Array()),Tt(e,this.lenEncoder.toUint8Array()),ba(e,qt(this.restEncoder)),qt(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){xs(this.restEncoder,e)}writeBuf(e){Tt(this.restEncoder,e)}writeJSON(e){xs(this.restEncoder,e)}writeKey(e){const n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}}const FR=(t,e,n,r)=>{r=lr(r,e[0].id.clock);const s=Yt(e,r);me(t.restEncoder,e.length-s),t.writeClient(n),me(t.restEncoder,r);const i=e[s];i.write(t,r-i.id.clock);for(let o=s+1;o<e.length;o++)e[o].write(t,0)},Y0=(t,e,n)=>{const r=new Map;n.forEach((s,i)=>{Ue(e,i)>s&&r.set(i,s)}),ka(e).forEach((s,i)=>{n.has(i)||r.set(i,0)}),me(t.restEncoder,r.size),Br(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{FR(t,e.clients.get(s),s,i)})},UR=(t,e)=>{const n=Kt(),r=Re(t.restDecoder);for(let s=0;s<r;s++){const i=Re(t.restDecoder),o=new Array(i),l=t.readClient();let a=Re(t.restDecoder);n.set(l,{i:0,refs:o});for(let c=0;c<i;c++){const d=t.readInfo();switch(ya&d){case 0:{const u=t.readLen();o[c]=new Bt(ce(l,a),u),a+=u;break}case 10:{const u=Re(t.restDecoder);o[c]=new Vt(ce(l,a),u),a+=u;break}default:{const u=(d&(Tn|yt))===0,h=new ve(ce(l,a),null,(d&yt)===yt?t.readLeftID():null,null,(d&Tn)===Tn?t.readRightID():null,u?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,u&&(d&wi)===wi?t.readString():null,Sx(t,d));o[c]=h,a+=h.length}}}}return n},VR=(t,e,n)=>{const r=[];let s=Br(n.keys()).sort((f,p)=>f-p);if(s.length===0)return null;const i=()=>{if(s.length===0)return null;let f=n.get(s[s.length-1]);for(;f.refs.length===f.i;)if(s.pop(),s.length>0)f=n.get(s[s.length-1]);else return null;return f};let o=i();if(o===null)return null;const l=new Q0,a=new Map,c=(f,p)=>{const g=a.get(f);(g==null||g>p)&&a.set(f,p)};let d=o.refs[o.i++];const u=new Map,h=()=>{for(const f of r){const p=f.id.client,g=n.get(p);g?(g.i--,l.clients.set(p,g.refs.slice(g.i)),n.delete(p),g.i=0,g.refs=[]):l.clients.set(p,[f]),s=s.filter(y=>y!==p)}r.length=0};for(;;){if(d.constructor!==Vt){const p=On(u,d.id.client,()=>Ue(e,d.id.client))-d.id.clock;if(p<0)r.push(d),c(d.id.client,d.id.clock-1),h();else{const g=d.getMissing(t,e);if(g!==null){r.push(d);const y=n.get(g)||{refs:[],i:0};if(y.refs.length===y.i)c(g,Ue(e,g)),h();else{d=y.refs[y.i++];continue}}else(p===0||p<d.length)&&(d.integrate(t,p),u.set(d.id.client,d.id.clock+d.length))}}if(r.length>0)d=r.pop();else if(o!==null&&o.i<o.refs.length)d=o.refs[o.i++];else{if(o=i(),o===null)break;d=o.refs[o.i++]}}if(l.clients.size>0){const f=new wa;return Y0(f,l,new Map),me(f.restEncoder,0),{missing:a,update:f.toUint8Array()}}return null},WR=(t,e)=>Y0(t,e.doc.store,e.beforeState),qR=(t,e,n,r=new Bl(t))=>Ce(e,s=>{s.local=!1;let i=!1;const o=s.doc,l=o.store,a=UR(r,o),c=VR(s,l,a),d=l.pendingStructs;if(d){for(const[h,f]of d.missing)if(f<Ue(l,h)){i=!0;break}if(c){for(const[h,f]of c.missing){const p=d.missing.get(h);(p==null||p>f)&&d.missing.set(h,f)}d.update=vm([d.update,c.update])}}else l.pendingStructs=c;const u=fm(r,s,l);if(l.pendingDs){const h=new Bl(ih(l.pendingDs));Re(h.restDecoder);const f=fm(h,s,l);u&&f?l.pendingDs=vm([u,f]):l.pendingDs=u||f}else l.pendingDs=u;if(i){const h=l.pendingStructs.update;l.pendingStructs=null,Id(s.doc,h)}},n,!1),Id=(t,e,n,r=Bl)=>{const s=ih(e);qR(s,t,n,new r(s))};class KR{constructor(){this.l=[]}}const pm=()=>new KR,mm=(t,e)=>t.l.push(e),gm=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(s=>e!==s),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},X0=(t,e,n)=>ah(t.l,[e,n]);class as{constructor(e,n){this.client=e,this.clock=n}}const Eo=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,ce=(t,e)=>new as(t,e),Ci=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Mt()},Ei=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class $l{constructor(e,n,r,s=0){this.type=e,this.tname=n,this.item=r,this.assoc=s}}class GR{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const JR=(t,e,n=0)=>new GR(t,e,n),Mo=(t,e,n)=>{let r=null,s=null;return t._item===null?s=Ci(t):r=ce(t._item.id.client,t._item.id.clock),new $l(r,s,e,n)},Dc=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Mo(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Mo(t,ce(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Mo(t,r.lastId,n);r=r.right}return Mo(t,null,n)},YR=(t,e)=>{const n=cs(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},XR=(t,e,n=!0)=>{const r=e.store,s=t.item,i=t.type,o=t.tname,l=t.assoc;let a=null,c=0;if(s!==null){if(Ue(r,s.client)<=s.clock)return null;const d=n?$d(r,s):YR(r,s),u=d.item;if(!(u instanceof ve))return null;if(a=u.parent,a._item===null||!a._item.deleted){c=u.deleted||!u.countable?0:d.diff+(l>=0?0:1);let h=u.left;for(;h!==null;)!h.deleted&&h.countable&&(c+=h.length),h=h.left}}else{if(o!==null)a=e.get(o);else if(i!==null){if(Ue(r,i.client)<=i.clock)return null;const{item:d}=n?$d(r,i):{item:cs(r,i)};if(d instanceof ve&&d.content instanceof en)a=d.content.type;else return null}else throw Mt();l>=0?c=a._length:c=0}return JR(a,c,t.assoc)};class fh{constructor(e,n){this.ds=e,this.sv=n}}const Z0=(t,e)=>new fh(t,e),Lc=t=>Z0(jR(t.store),ka(t.store)),br=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Ns(e.ds,t.id),jd=(t,e)=>{const n=On(t.meta,jd,Pr),r=t.doc.store;n.has(e)||(e.sv.forEach((s,i)=>{s<Ue(r,i)&&vt(t,ce(i,s))}),cr(t,e.ds,s=>{}),n.add(e))};class Q0{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const ka=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},Ue=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},ex=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw Mt()}n.push(e)},Yt=(t,e)=>{let n=0,r=t.length-1,s=t[r],i=s.id.clock;if(i===e)return r;let o=_n(e/(i+s.length-1)*r);for(;n<=r;){if(s=t[o],i=s.id.clock,i<=e){if(e<i+s.length)return o;n=o+1}else r=o-1;o=_n((n+r)/2)}throw Mt()},ZR=(t,e)=>{const n=t.clients.get(e.client);return n[Yt(n,e.clock)]},cs=ZR,Pd=(t,e,n)=>{const r=Yt(e,n),s=e[r];return s.id.clock<n&&s instanceof ve?(e.splice(r+1,0,Vl(t,s,n-s.id.clock)),r+1):r},vt=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[Pd(t,n,e.clock)]},ym=(t,e,n)=>{const r=e.clients.get(n.client),s=Yt(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==Bt&&r.splice(s+1,0,Vl(t,i,n.clock-i.id.clock+1)),i},QR=(t,e,n)=>{const r=t.clients.get(e.id.client);r[Yt(r,e.id.clock)]=n},tx=(t,e,n,r,s)=>{if(r===0)return;const i=n+r;let o=Pd(t,e,n),l;do l=e[o++],i<l.id.clock+l.length&&Pd(t,e,i),s(l);while(o<e.length&&e[o].id.clock<i)};class eO{constructor(e,n,r){this.doc=e,this.deleteSet=new Ts,this.beforeState=ka(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const bm=(t,e)=>e.deleteSet.clients.size===0&&!y_(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(uh(e.deleteSet),WR(t,e),hh(t,e.deleteSet),!0),xm=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&On(t.changed,e,Pr).add(n)},Fo=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof ve&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const i=e-s;return i&&t.splice(e+1-i,i),i},tO=(t,e,n)=>{for(const[r,s]of t.clients.entries()){const i=e.clients.get(r);for(let o=s.length-1;o>=0;o--){const l=s[o],a=l.clock+l.len;for(let c=Yt(i,l.clock),d=i[c];c<i.length&&d.id.clock<a;d=i[++c]){const u=i[c];if(l.clock+l.len<=u.id.clock)break;u instanceof ve&&u.deleted&&!u.keep&&n(u)&&u.gc(e,!1)}}}},nO=(t,e)=>{t.clients.forEach((n,r)=>{const s=e.clients.get(r);for(let i=n.length-1;i>=0;i--){const o=n[i],l=bs(s.length-1,1+Yt(s,o.clock+o.len-1));for(let a=l,c=s[a];a>0&&c.id.clock>=o.clock;c=s[a])a-=1+Fo(s,a)}})},nx=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{uh(i),n.afterState=ka(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const l=[];n.changed.forEach((a,c)=>l.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(n,a)})),l.push(()=>{n.changedParentTypes.forEach((a,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(a=a.filter(d=>d.target._item===null||!d.target._item.deleted),a.forEach(d=>{d.currentTarget=c,d._path=null}),a.sort((d,u)=>d.path.length-u.path.length),X0(c._dEH,a,n))})}),l.push(()=>r.emit("afterTransaction",[n,r])),ah(l,[]),n._needFormattingCleanup&&vO(n)}finally{r.gc&&tO(i,s,r.gcFilter),nO(i,s),n.afterState.forEach((d,u)=>{const h=n.beforeState.get(u)||0;if(h!==d){const f=s.clients.get(u),p=lr(Yt(f,h),1);for(let g=f.length-1;g>=p;)g-=1+Fo(f,g)}});for(let d=o.length-1;d>=0;d--){const{client:u,clock:h}=o[d].id,f=s.clients.get(u),p=Yt(f,h);p+1<f.length&&Fo(f,p+1)>1||p>0&&Fo(f,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(DR(ch,z0,"[yjs] ",F0,U0,"Changed the client-id because another client seems to be using it."),r.clientID=J0()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const d=new HR;bm(d,n)&&r.emit("update",[d.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const d=new wa;bm(d,n)&&r.emit("updateV2",[d.toUint8Array(),n.origin,r,n])}const{subdocsAdded:l,subdocsLoaded:a,subdocsRemoved:c}=n;(l.size>0||c.size>0||a.size>0)&&(l.forEach(d=>{d.clientID=r.clientID,d.collectionid==null&&(d.collectionid=r.collectionid),r.subdocs.add(d)}),c.forEach(d=>r.subdocs.delete(d)),r.emit("subdocs",[{loaded:a,added:l,removed:c},r,n]),c.forEach(d=>d.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):nx(t,e+1)}}},Ce=(t,e,n=null,r=!0)=>{const s=t._transactionCleanups;let i=!1,o=null;t._transaction===null&&(i=!0,t._transaction=new eO(t,n,r),s.push(t._transaction),s.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(i){const l=t._transaction===s[0];t._transaction=null,l&&nx(s,0)}}return o};class rO{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const wm=(t,e,n)=>{cr(t,n.deletions,r=>{r instanceof ve&&e.scope.some(s=>s===t.doc||Ei(s,r))&&bh(r,!1)})},km=(t,e,n)=>{let r=null;const s=t.doc,i=t.scope;Ce(s,l=>{for(;e.length>0&&t.currStackItem===null;){const a=s.store,c=e.pop(),d=new Set,u=[];let h=!1;cr(l,c.insertions,f=>{if(f instanceof ve){if(f.redone!==null){let{item:p,diff:g}=$d(a,f.id);g>0&&(p=vt(l,ce(p.id.client,p.id.clock+g))),f=p}!f.deleted&&i.some(p=>p===l.doc||Ei(p,f))&&u.push(f)}}),cr(l,c.deletions,f=>{f instanceof ve&&i.some(p=>p===l.doc||Ei(p,f))&&!Ns(c.insertions,f.id)&&d.add(f)}),d.forEach(f=>{h=vx(l,f,d,c.insertions,t.ignoreRemoteMapChanges,t)!==null||h});for(let f=u.length-1;f>=0;f--){const p=u[f];t.deleteFilter(p)&&(p.delete(l),h=!0)}t.currStackItem=h?c:null}l.changed.forEach((a,c)=>{a.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=l},t);const o=t.currStackItem;if(o!=null){const l=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return o};class rx extends T0{constructor(e,{captureTimeout:n=500,captureTransaction:r=a=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:l=Td(e)?e[0].doc:e instanceof Ur?e:e.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(e),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=a=>{if(!this.captureTransaction(a)||!this.scope.some(y=>a.changedParentTypes.has(y)||y===this.doc)||!this.trackedOrigins.has(a.origin)&&(!a.origin||!this.trackedOrigins.has(a.origin.constructor)))return;const c=this.undoing,d=this.redoing,u=c?this.redoStack:this.undoStack;c?this.stopCapturing():d||this.clear(!1,!0);const h=new Ts;a.afterState.forEach((y,b)=>{const w=a.beforeState.get(b)||0,M=y-w;M>0&&Si(h,b,w,M)});const f=nR();let p=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&u.length>0&&!c&&!d){const y=u[u.length-1];y.deletions=Ld([y.deletions,a.deleteSet]),y.insertions=Ld([y.insertions,h])}else u.push(new rO(a.deleteSet,h)),p=!0;!c&&!d&&(this.lastChange=f),cr(a,a.deleteSet,y=>{y instanceof ve&&this.scope.some(b=>b===a.doc||Ei(b,y))&&bh(y,!0)});const g=[{stackItem:u[u.length-1],origin:a.origin,type:c?"redo":"undo",changedParentTypes:a.changedParentTypes},this];p?this.emit("stack-item-added",g):this.emit("stack-item-updated",g)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const n=new Set(this.scope);e=Td(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof tt?r.doc!==this.doc:r!==this.doc)&&W0("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(s=>wm(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>wm(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=km(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=km(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*sO(t){const e=Re(t.restDecoder);for(let n=0;n<e;n++){const r=Re(t.restDecoder),s=t.readClient();let i=Re(t.restDecoder);for(let o=0;o<r;o++){const l=t.readInfo();if(l===10){const a=Re(t.restDecoder);yield new Vt(ce(s,i),a),i+=a}else if((ya&l)!==0){const a=(l&(Tn|yt))===0,c=new ve(ce(s,i),null,(l&yt)===yt?t.readLeftID():null,null,(l&Tn)===Tn?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(l&wi)===wi?t.readString():null,Sx(t,l));yield c,i+=c.length}else{const a=t.readLen();yield new Bt(ce(s,i),a),i+=a}}}}class iO{constructor(e,n){this.gen=sO(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Vt);return this.curr}}class oO{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const lO=(t,e)=>{if(t.constructor===Bt){const{client:n,clock:r}=t.id;return new Bt(ce(n,r+e),t.length-e)}else if(t.constructor===Vt){const{client:n,clock:r}=t.id;return new Vt(ce(n,r+e),t.length-e)}else{const n=t,{client:r,clock:s}=n.id;return new ve(ce(r,s+e),null,ce(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},vm=(t,e=Bl,n=wa)=>{if(t.length===1)return t[0];const r=t.map(d=>new e(ih(d)));let s=r.map(d=>new iO(d,!0)),i=null;const o=new n,l=new oO(o);for(;s=s.filter(h=>h.curr!==null),s.sort((h,f)=>{if(h.curr.id.client===f.curr.id.client){const p=h.curr.id.clock-f.curr.id.clock;return p===0?h.curr.constructor===f.curr.constructor?0:h.curr.constructor===Vt?1:-1:p}else return f.curr.id.client-h.curr.id.client}),s.length!==0;){const d=s[0],u=d.curr.id.client;if(i!==null){let h=d.curr,f=!1;for(;h!==null&&h.id.clock+h.length<=i.struct.id.clock+i.struct.length&&h.id.client>=i.struct.id.client;)h=d.next(),f=!0;if(h===null||h.id.client!==u||f&&h.id.clock>i.struct.id.clock+i.struct.length)continue;if(u!==i.struct.id.client)Bs(l,i.struct,i.offset),i={struct:h,offset:0},d.next();else if(i.struct.id.clock+i.struct.length<h.id.clock)if(i.struct.constructor===Vt)i.struct.length=h.id.clock+h.length-i.struct.id.clock;else{Bs(l,i.struct,i.offset);const p=h.id.clock-i.struct.id.clock-i.struct.length;i={struct:new Vt(ce(u,i.struct.id.clock+i.struct.length),p),offset:0}}else{const p=i.struct.id.clock+i.struct.length-h.id.clock;p>0&&(i.struct.constructor===Vt?i.struct.length-=p:h=lO(h,p)),i.struct.mergeWith(h)||(Bs(l,i.struct,i.offset),i={struct:h,offset:0},d.next())}}else i={struct:d.curr,offset:0},d.next();for(let h=d.curr;h!==null&&h.id.client===u&&h.id.clock===i.struct.id.clock+i.struct.length&&h.constructor!==Vt;h=d.next())Bs(l,i.struct,i.offset),i={struct:h,offset:0}}i!==null&&(Bs(l,i.struct,i.offset),i=null),aO(l);const a=r.map(d=>PR(d)),c=Ld(a);return hh(o,c),o.toUint8Array()},sx=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:qt(t.encoder.restEncoder)}),t.encoder.restEncoder=zi(),t.written=0)},Bs=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&sx(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),me(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},aO=t=>{sx(t);const e=t.encoder.restEncoder;me(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];me(e,r.written),ba(e,r.restEncoder)}},Sm="You must not compute changes after the event-handler fired.";class va{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=cO(this.currentTarget,this.target))}deletes(e){return Ns(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw ar(Sm);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){const i=n._map.get(s);let o,l;if(this.adds(i)){let a=i.left;for(;a!==null&&this.adds(a);)a=a.left;if(this.deletes(i))if(a!==null&&this.deletes(a))o="delete",l=Ac(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",l=Ac(a.content.getContent())):(o="add",l=void 0)}else if(this.deletes(i))o="delete",l=Ac(i.content.getContent());else return;e.set(s,{action:o,oldValue:l})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw ar(Sm);const n=this.target,r=Pr(),s=Pr(),i=[];if(e={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let l=null;const a=()=>{l&&i.push(l)};for(let c=n._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((l===null||l.delete===void 0)&&(a(),l={delete:0}),l.delete+=c.length,s.add(c)):this.adds(c)?((l===null||l.insert===void 0)&&(a(),l={insert:[]}),l.insert=l.insert.concat(c.content.getContent()),r.add(c)):((l===null||l.retain===void 0)&&(a(),l={retain:0}),l.retain+=c.length);l!==null&&l.retain===void 0&&a()}this._changes=e}return e}}const cO=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;n.unshift(r)}e=e._item.parent}return n},ft=()=>{W0("Invalid access: Add Yjs type to a document before reading data.")},ix=80;let ph=0;class dO{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=ph++}}const uO=t=>{t.timestamp=ph++},ox=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=ph++},hO=(t,e,n)=>{if(t.length>=ix){const r=t.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return ox(r,e,n),r}else{const r=new dO(e,n);return t.push(r),r}},Sa=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((i,o)=>$o(e-i.index)<$o(e-o.index)?i:o);let r=t._start,s=0;for(n!==null&&(r=n.p,s=n.index,uO(n));r.right!==null&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return n!==null&&$o(n.index-s)<r.parent.length/ix?(ox(n,r,s),n):hO(t._searchMarker,r,s)},Mi=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const s=t[r];if(n>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){t.splice(r,1);continue}s.p=i,i.marker=!0}(e<s.index||n>0&&e===s.index)&&(s.index=lr(e,s.index+n))}},Ca=(t,e,n)=>{const r=t,s=e.changedParentTypes;for(;On(s,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;X0(r._eH,n,e)};class tt{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=pm(),this._dEH=pm(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw Gt()}clone(){throw Gt()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){mm(this._eH,e)}observeDeep(e){mm(this._dEH,e)}unobserve(e){gm(this._eH,e)}unobserveDeep(e){gm(this._dEH,e)}toJSON(){}}const lx=(t,e,n)=>{t.doc??ft(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const s=[];let i=t._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){const o=i.content.getContent();if(o.length<=e)e-=o.length;else{for(let l=e;l<o.length&&r>0;l++)s.push(o[l]),r--;e=0}}i=i.right}return s},ax=t=>{t.doc??ft();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e},cx=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&br(r,e)){const s=r.content.getContent();for(let i=0;i<s.length;i++)n.push(s[i])}r=r.right}return n},Ai=(t,e)=>{let n=0,r=t._start;for(t.doc??ft();r!==null;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let i=0;i<s.length;i++)e(s[i],n++,t)}r=r.right}},dx=(t,e)=>{const n=[];return Ai(t,(r,s)=>{n.push(e(r,s,t))}),n},fO=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},ux=(t,e)=>{t.doc??ft();const n=Sa(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Hl=(t,e,n,r)=>{let s=n;const i=t.doc,o=i.clientID,l=i.store,a=n===null?e._start:n.right;let c=[];const d=()=>{c.length>0&&(s=new ve(ce(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Hr(c)),s.integrate(t,0),c=[])};r.forEach(u=>{if(u===null)c.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(u);break;default:switch(d(),u.constructor){case Uint8Array:case ArrayBuffer:s=new ve(ce(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Fi(new Uint8Array(u))),s.integrate(t,0);break;case Ur:s=new ve(ce(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Ui(u)),s.integrate(t,0);break;default:if(u instanceof tt)s=new ve(ce(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new en(u)),s.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),d()},hx=()=>ar("Length exceeded!"),fx=(t,e,n,r)=>{if(n>e._length)throw hx();if(n===0)return e._searchMarker&&Mi(e._searchMarker,n,r.length),Hl(t,e,null,r);const s=n,i=Sa(e,n);let o=e._start;for(i!==null&&(o=i.p,n-=i.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&vt(t,ce(o.id.client,o.id.clock+n));break}n-=o.length}return e._searchMarker&&Mi(e._searchMarker,s,r.length),Hl(t,e,o,r)},pO=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:e._start}).p;if(s)for(;s.right;)s=s.right;return Hl(t,e,s,n)},px=(t,e,n,r)=>{if(r===0)return;const s=n,i=r,o=Sa(e,n);let l=e._start;for(o!==null&&(l=o.p,n-=o.index);l!==null&&n>0;l=l.right)!l.deleted&&l.countable&&(n<l.length&&vt(t,ce(l.id.client,l.id.clock+n)),n-=l.length);for(;r>0&&l!==null;)l.deleted||(r<l.length&&vt(t,ce(l.id.client,l.id.clock+r)),l.delete(t),r-=l.length),l=l.right;if(r>0)throw hx();e._searchMarker&&Mi(e._searchMarker,s,-i+r)},zl=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},mh=(t,e,n,r)=>{const s=e._map.get(n)||null,i=t.doc,o=i.clientID;let l;if(r==null)l=new Hr([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new Hr([r]);break;case Uint8Array:l=new Fi(r);break;case Ur:l=new Ui(r);break;default:if(r instanceof tt)l=new en(r);else throw new Error("Unexpected content type")}new ve(ce(o,Ue(i.store,o)),s,s&&s.lastId,null,null,e,n,l).integrate(t,0)},gh=(t,e)=>{t.doc??ft();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},mx=t=>{const e={};return t.doc??ft(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},gx=(t,e)=>{t.doc??ft();const n=t._map.get(e);return n!==void 0&&!n.deleted},mO=(t,e)=>{const n={};return t._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&&br(i,e)&&(n[s]=i.content.getContent()[i.length-1])}),n},Ao=t=>(t.doc??ft(),LR(t._map.entries(),e=>!e[1].deleted));class gO extends va{}class ds extends tt{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new ds;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ds}clone(){const e=new ds;return e.insert(0,this.toArray().map(n=>n instanceof tt?n.clone():n)),e}get length(){return this.doc??ft(),this._length}_callObserver(e,n){super._callObserver(e,n),Ca(this,e,new gO(this,e))}insert(e,n){this.doc!==null?Ce(this.doc,r=>{fx(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?Ce(this.doc,n=>{pO(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?Ce(this.doc,r=>{px(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return ux(this,e)}toArray(){return ax(this)}slice(e=0,n=this.length){return lx(this,e,n)}toJSON(){return this.map(e=>e instanceof tt?e.toJSON():e)}map(e){return dx(this,e)}forEach(e){Ai(this,e)}[Symbol.iterator](){return fO(this)}_write(e){e.writeTypeRef(zO)}}const yO=t=>new ds;class bO extends va{constructor(e,n,r){super(e,n),this.keysChanged=r}}class ks extends tt{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new ks}clone(){const e=new ks;return this.forEach((n,r)=>{e.set(r,n instanceof tt?n.clone():n)}),e}_callObserver(e,n){Ca(this,e,new bO(this,e,n))}toJSON(){this.doc??ft();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const s=n.content.getContent()[n.length-1];e[r]=s instanceof tt?s.toJSON():s}}),e}get size(){return[...Ao(this)].length}keys(){return Oc(Ao(this),e=>e[0])}values(){return Oc(Ao(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Oc(Ao(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??ft(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?Ce(this.doc,n=>{zl(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?Ce(this.doc,r=>{mh(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return gh(this,e)}has(e){return gx(this,e)}clear(){this.doc!==null?Ce(this.doc,e=>{this.forEach(function(n,r,s){zl(e,s,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(FO)}}const xO=t=>new ks,Yn=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&dR(t,e);class Bd{constructor(e,n,r,s){this.left=e,this.right=n,this.index=r,this.currentAttributes=s}forward(){switch(this.right===null&&Mt(),this.right.content.constructor){case Ge:this.right.deleted||_s(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const Cm=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case Ge:e.right.deleted||_s(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n<e.right.length&&vt(t,ce(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},To=(t,e,n,r)=>{const s=new Map,i=r?Sa(e,n):null;if(i){const o=new Bd(i.p.left,i.p,i.index,s);return Cm(t,o,n-i.index)}else{const o=new Bd(null,e._start,0,s);return Cm(t,o,n)}},yx=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Ge&&Yn(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const s=t.doc,i=s.clientID;r.forEach((o,l)=>{const a=n.left,c=n.right,d=new ve(ce(i,Ue(s.store,i)),a,a&&a.lastId,c,c&&c.id,e,null,new Ge(l,o));d.integrate(t,0),n.right=d,n.forward()})},_s=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},bx=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Ge&&Yn(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},xx=(t,e,n,r)=>{const s=t.doc,i=s.clientID,o=new Map;for(const l in r){const a=r[l],c=n.currentAttributes.get(l)??null;if(!Yn(c,a)){o.set(l,c);const{left:d,right:u}=n;n.right=new ve(ce(i,Ue(s.store,i)),d,d&&d.lastId,u,u&&u.id,e,null,new Ge(l,a)),n.right.integrate(t,0),n.forward()}}return o},Ic=(t,e,n,r,s)=>{n.currentAttributes.forEach((h,f)=>{s[f]===void 0&&(s[f]=null)});const i=t.doc,o=i.clientID;bx(n,s);const l=xx(t,e,n,s),a=r.constructor===String?new Xt(r):r instanceof tt?new en(r):new Vr(r);let{left:c,right:d,index:u}=n;e._searchMarker&&Mi(e._searchMarker,n.index,a.getLength()),d=new ve(ce(o,Ue(i.store,o)),c,c&&c.lastId,d,d&&d.id,e,null,a),d.integrate(t,0),n.right=d,n.index=u,n.forward(),yx(t,e,n,l)},Em=(t,e,n,r,s)=>{const i=t.doc,o=i.clientID;bx(n,s);const l=xx(t,e,n,s);e:for(;n.right!==null&&(r>0||l.size>0&&(n.right.deleted||n.right.content.constructor===Ge));){if(!n.right.deleted)switch(n.right.content.constructor){case Ge:{const{key:a,value:c}=n.right.content,d=s[a];if(d!==void 0){if(Yn(d,c))l.delete(a);else{if(r===0)break e;l.set(a,c)}n.right.delete(t)}else n.currentAttributes.set(a,c);break}default:r<n.right.length&&vt(t,ce(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
|
|
149
|
+
`}),u}var wN=xN,M0=Oe.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:hN,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:s}=fN(t,this.options.cellMinWidth),i=["table",pe(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${s}`}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},i]:i},parseMarkdown:(t,e)=>{const n=[];if(t.header){const r=[];t.header.forEach(s=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(r=>{const s=[];r.forEach(i=>{s.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>wN(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const o=mN(i.schema,t,e,n);if(s){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(J.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>_T(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>RT(t,e),deleteColumn:()=>({state:t,dispatch:e})=>DT(t,e),addRowBefore:()=>({state:t,dispatch:e})=>IT(t,e),addRowAfter:()=>({state:t,dispatch:e})=>jT(t,e),deleteRow:()=>({state:t,dispatch:e})=>BT(t,e),deleteTable:()=>({state:t,dispatch:e})=>WT(t,e),mergeCells:()=>({state:t,dispatch:e})=>Up(t,e),splitCell:()=>({state:t,dispatch:e})=>Vp(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})=>UT(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Up(t,e)?!0:Vp(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>zT(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>qp(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>qp(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&b0(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Te.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:Co,"Mod-Backspace":Co,Delete:Co,"Mod-Delete":Co}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[tN({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],uN({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:we(G(t,"tableRole",e))}}});de.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(M0.configure(this.options.table)),this.options.tableCell!==!1&&t.push(S0.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(C0.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(E0.configure(this.options.tableRow)),t}});var kN=E0,vN=C0,SN=S0,CN=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,EN=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,MN=Zt.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",pe(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){const s=/^(==)([^=]+)(==)/.exec(t);if(s){const i=s[2].trim(),o=n.inlineTokens(i);return{type:"highlight",raw:s[0],text:i,tokens:o}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Lr({find:CN,type:this.type})]},addPasteRules(){return[sr({find:EN,type:this.type})]}}),AN=MN,TN=Zt.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",pe(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()}}}),NN=TN,_N=Zt.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",pe(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()}}}),RN=_N,ON=de.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).every(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),DN=ON,LN=20,A0=(t,e=0)=>{const n=[];return!t.children.length||e>LN||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...A0(r,e+1))}),n},IN=t=>{if(!t.children.length)return;const e=A0(t);e&&e.forEach(n=>{var r,s;const i=n.getAttribute("style"),o=(s=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:s.getAttribute("style");n.setAttribute("style",`${o};${i}`)})},jN=Zt.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&IN(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",pe(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),PN=de.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(s=>s.trim()).filter(Boolean);for(let s=r.length-1;s>=0;s-=1){const i=r[s].split(":");if(i.length>=2){const o=i[0].trim().toLowerCase(),l=i.slice(1).join(":").trim();if(o==="background-color")return l.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),BN=de.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(s=>s.trim()).filter(Boolean);for(let s=r.length-1;s>=0;s-=1){const i=r[s].split(":");if(i.length>=2){const o=i[0].trim().toLowerCase(),l=i.slice(1).join(":").trim();if(o==="color")return l.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?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()}}}),$N=de.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),HN=de.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),zN=de.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}}),FN=de.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(PN.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(BN.configure(this.options.color)),this.options.fontFamily!==!1&&t.push($N.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(HN.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(zN.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(jN.configure(this.options.textStyle)),t}}),UN=QA,VN=t=>Be({find:/--$/,replace:t??"—"}),WN=t=>Be({find:/\.\.\.$/,replace:t??"…"}),qN=t=>Be({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"“"}),KN=t=>Be({find:/"$/,replace:t??"”"}),GN=t=>Be({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"‘"}),JN=t=>Be({find:/'$/,replace:t??"’"}),YN=t=>Be({find:/<-$/,replace:t??"←"}),XN=t=>Be({find:/->$/,replace:t??"→"}),ZN=t=>Be({find:/\(c\)$/,replace:t??"©"}),QN=t=>Be({find:/\(tm\)$/,replace:t??"™"}),e_=t=>Be({find:/\(sm\)$/,replace:t??"℠"}),t_=t=>Be({find:/\(r\)$/,replace:t??"®"}),n_=t=>Be({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),r_=t=>Be({find:/\+\/-$/,replace:t??"±"}),s_=t=>Be({find:/!=$/,replace:t??"≠"}),i_=t=>Be({find:/<<$/,replace:t??"«"}),o_=t=>Be({find:/>>$/,replace:t??"»"}),l_=t=>Be({find:/\d+\s?([*x])\s?\d+$/,replace:t??"×"}),a_=t=>Be({find:/\^2$/,replace:t??"²"}),c_=t=>Be({find:/\^3$/,replace:t??"³"}),d_=t=>Be({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),u_=t=>Be({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),h_=de.create({name:"typography",addOptions(){return{closeDoubleQuote:"”",closeSingleQuote:"’",copyright:"©",ellipsis:"…",emDash:"—",laquo:"«",leftArrow:"←",multiplication:"×",notEqual:"≠",oneHalf:"½",oneQuarter:"¼",openDoubleQuote:"“",openSingleQuote:"‘",plusMinus:"±",raquo:"»",registeredTrademark:"®",rightArrow:"→",servicemark:"℠",superscriptThree:"³",superscriptTwo:"²",threeQuarters:"¾",trademark:"™"}},addInputRules(){const t=[];return this.options.emDash!==!1&&t.push(VN(this.options.emDash)),this.options.ellipsis!==!1&&t.push(WN(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&t.push(qN(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&t.push(KN(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&t.push(GN(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&t.push(JN(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&t.push(YN(this.options.leftArrow)),this.options.rightArrow!==!1&&t.push(XN(this.options.rightArrow)),this.options.copyright!==!1&&t.push(ZN(this.options.copyright)),this.options.trademark!==!1&&t.push(QN(this.options.trademark)),this.options.servicemark!==!1&&t.push(e_(this.options.servicemark)),this.options.registeredTrademark!==!1&&t.push(t_(this.options.registeredTrademark)),this.options.oneHalf!==!1&&t.push(n_(this.options.oneHalf)),this.options.plusMinus!==!1&&t.push(r_(this.options.plusMinus)),this.options.notEqual!==!1&&t.push(s_(this.options.notEqual)),this.options.laquo!==!1&&t.push(i_(this.options.laquo)),this.options.raquo!==!1&&t.push(o_(this.options.raquo)),this.options.multiplication!==!1&&t.push(l_(this.options.multiplication)),this.options.superscriptTwo!==!1&&t.push(a_(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&t.push(c_(this.options.superscriptThree)),this.options.oneQuarter!==!1&&t.push(d_(this.options.oneQuarter)),this.options.threeQuarters!==!1&&t.push(u_(this.options.threeQuarters)),t}}),f_=h_,p_=o0,m_=l0;const Kt=()=>new Map,Ad=t=>{const e=Kt();return t.forEach((n,r)=>{e.set(r,n)}),e},On=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},g_=(t,e)=>{const n=[];for(const[r,s]of t)n.push(e(s,r));return n},y_=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},Pr=()=>new Set,Ac=t=>t[t.length-1],b_=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},Br=Array.from,x_=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},Td=Array.isArray;class T0{constructor(){this._observers=Kt()}on(e,n){return On(this._observers,e,Pr).add(n),n}once(e,n){const r=(...s)=>{this.off(e,r),n(...s)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return Br((this._observers.get(e)||Kt()).values()).forEach(r=>r(...n))}destroy(){this._observers=Kt()}}const _n=Math.floor,$o=Math.abs,bs=(t,e)=>t<e?t:e,lr=(t,e)=>t>e?t:e,N0=t=>t!==0?t<0:1/t<0,nm=1,rm=2,Tc=4,Nc=8,wi=32,Tn=64,yt=128,w_=1<<29,ya=31,Nd=63,Tr=127,k_=2147483647,_0=Number.MAX_SAFE_INTEGER,v_=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&_n(t)===t),S_=String.fromCharCode,C_=t=>t.toLowerCase(),E_=/^\s*/g,M_=t=>t.replace(E_,""),A_=/([A-Z])/g,sm=(t,e)=>M_(t.replace(A_,n=>`${e}${C_(n)}`)),T_=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},ki=typeof TextEncoder<"u"?new TextEncoder:null,N_=t=>ki.encode(t),__=ki?N_:T_;let ti=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});ti&&ti.decode(new Uint8Array).length===1&&(ti=null);class Hi{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const zi=()=>new Hi,R_=t=>{const e=zi();return t(e),qt(e)},O_=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},qt=t=>{const e=new Uint8Array(O_(t));let n=0;for(let r=0;r<t.bufs.length;r++){const s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},D_=(t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(lr(n,e)*2),t.cpos=0)},Xe=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},_d=Xe,ge=(t,e)=>{for(;e>Tr;)Xe(t,yt|Tr&e),e=_n(e/128);Xe(t,Tr&e)},rh=(t,e)=>{const n=N0(e);for(n&&(e=-e),Xe(t,(e>Nd?yt:0)|(n?Tn:0)|Nd&e),e=_n(e/64);e>0;)Xe(t,(e>Tr?yt:0)|Tr&e),e=_n(e/128)},Rd=new Uint8Array(3e4),L_=Rd.length/3,I_=(t,e)=>{if(e.length<L_){const n=ki.encodeInto(e,Rd).written||0;ge(t,n);for(let r=0;r<n;r++)Xe(t,Rd[r])}else Tt(t,__(e))},j_=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;ge(t,r);for(let s=0;s<r;s++)Xe(t,n.codePointAt(s))},ls=ki&&ki.encodeInto?I_:j_,ba=(t,e)=>{const n=t.cbuf.length,r=t.cpos,s=bs(n-r,e.length),i=e.length-s;t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,i>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(lr(n*2,i)),t.cbuf.set(e.subarray(s)),t.cpos=i)},Tt=(t,e)=>{ge(t,e.byteLength),ba(t,e)},sh=(t,e)=>{D_(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},P_=(t,e)=>sh(t,4).setFloat32(0,e,!1),B_=(t,e)=>sh(t,8).setFloat64(0,e,!1),$_=(t,e)=>sh(t,8).setBigInt64(0,e,!1),im=new DataView(new ArrayBuffer(4)),H_=t=>(im.setFloat32(0,t),im.getFloat32(0)===t),xs=(t,e)=>{switch(typeof e){case"string":Xe(t,119),ls(t,e);break;case"number":v_(e)&&$o(e)<=k_?(Xe(t,125),rh(t,e)):H_(e)?(Xe(t,124),P_(t,e)):(Xe(t,123),B_(t,e));break;case"bigint":Xe(t,122),$_(t,e);break;case"object":if(e===null)Xe(t,126);else if(Td(e)){Xe(t,117),ge(t,e.length);for(let n=0;n<e.length;n++)xs(t,e[n])}else if(e instanceof Uint8Array)Xe(t,116),Tt(t,e);else{Xe(t,118);const n=Object.keys(e);ge(t,n.length);for(let r=0;r<n.length;r++){const s=n[r];ls(t,s),xs(t,e[s])}}break;case"boolean":Xe(t,e?120:121);break;default:Xe(t,127)}};class om extends Hi{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&ge(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const lm=t=>{t.count>0&&(rh(t.encoder,t.count===1?t.s:-t.s),t.count>1&&ge(t.encoder,t.count-2))};class Ho{constructor(){this.encoder=new Hi,this.s=0,this.count=0}write(e){this.s===e?this.count++:(lm(this),this.count=1,this.s=e)}toUint8Array(){return lm(this),qt(this.encoder)}}const am=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);rh(t.encoder,e),t.count>1&&ge(t.encoder,t.count-2)}};class _c{constructor(){this.encoder=new Hi,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(am(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return am(this),qt(this.encoder)}}class z_{constructor(){this.sarr=[],this.s="",this.lensE=new Ho}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Hi;return this.sarr.push(this.s),this.s="",ls(e,this.sarr.join("")),ba(e,this.lensE.toUint8Array()),qt(e)}}const ar=t=>new Error(t),Gt=()=>{throw ar("Method unimplemented")},Mt=()=>{throw ar("Unexpected case")},R0=ar("Unexpected end of array"),O0=ar("Integer out of Range");class xa{constructor(e){this.arr=e,this.pos=0}}const ih=t=>new xa(t),F_=t=>t.pos!==t.arr.length,U_=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},It=t=>U_(t,Re(t)),vi=t=>t.arr[t.pos++],Re=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const s=t.arr[t.pos++];if(e=e+(s&Tr)*n,n*=128,s<yt)return e;if(e>_0)throw O0}throw R0},oh=t=>{let e=t.arr[t.pos++],n=e&Nd,r=64;const s=(e&Tn)>0?-1:1;if((e&yt)===0)return s*n;const i=t.arr.length;for(;t.pos<i;){if(e=t.arr[t.pos++],n=n+(e&Tr)*r,r*=128,e<yt)return s*n;if(n>_0)throw O0}throw R0},V_=t=>{let e=Re(t);if(e===0)return"";{let n=String.fromCodePoint(vi(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(vi(t));else for(;e>0;){const r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},W_=t=>ti.decode(It(t)),Od=ti?W_:V_,lh=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},q_=t=>lh(t,4).getFloat32(0,!1),K_=t=>lh(t,8).getFloat64(0,!1),G_=t=>lh(t,8).getBigInt64(0,!1),J_=[t=>{},t=>null,oh,q_,K_,G_,t=>!1,t=>!0,Od,t=>{const e=Re(t),n={};for(let r=0;r<e;r++){const s=Od(t);n[s]=jl(t)}return n},t=>{const e=Re(t),n=[];for(let r=0;r<e;r++)n.push(jl(t));return n},It],jl=t=>J_[127-vi(t)](t);class cm extends xa{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),F_(this)?this.count=Re(this)+1:this.count=-1),this.count--,this.s}}class zo extends xa{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=oh(this);const e=N0(this.s);this.count=1,e&&(this.s=-this.s,this.count=Re(this)+2)}return this.count--,this.s}}class Rc extends xa{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=oh(this),n=e&1;this.diff=_n(e/2),this.count=1,n&&(this.count=Re(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Y_{constructor(e){this.decoder=new zo(e),this.str=Od(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const X_=crypto.getRandomValues.bind(crypto),Z_=Math.random,D0=()=>X_(new Uint32Array(1))[0],Q_=t=>t[_n(Z_()*t.length)],eR="10000000-1000-4000-8000"+-1e11,tR=()=>eR.replace(/[018]/g,t=>(t^D0()&15>>t/4).toString(16)),nR=Date.now,dm=t=>new Promise(t);Promise.all.bind(Promise);const um=t=>t===void 0?null:t;class rR{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let L0=new rR,sR=!0;try{typeof localStorage<"u"&&localStorage&&(L0=localStorage,sR=!1)}catch{}const iR=L0,oR=Object.assign,I0=Object.keys,lR=(t,e)=>{for(const n in t)e(t[n],n)},hm=t=>I0(t).length,aR=t=>{for(const e in t)return!1;return!0},j0=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},cR=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),dR=(t,e)=>t===e||hm(t)===hm(e)&&j0(t,(n,r)=>(n!==void 0||cR(e,r))&&e[r]===n),uR=Object.freeze,P0=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&P0(t[e])}return uR(t)},ah=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&ah(t,e,n+1)}},hR=(t,e)=>e.includes(t),ws=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",B0=typeof window<"u"&&typeof document<"u"&&!ws;let rn;const fR=()=>{if(rn===void 0)if(ws){rn=Kt();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&rn.set(e,""),e=r):e!==null&&(rn.set(e,r),e=null)}e!==null&&rn.set(e,"")}else typeof location=="object"?(rn=Kt(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");rn.set(`--${sm(e,"-")}`,n),rn.set(`-${sm(e,"-")}`,n)}})):rn=Kt();return rn},Dd=t=>fR().has(t),Pl=t=>um(ws?process.env[t.toUpperCase().replaceAll("-","_")]:iR.getItem(t)),$0=t=>Dd("--"+t)||Pl(t)!==null;$0("production");const pR=ws&&hR(process.env.FORCE_COLOR,["true","1","2"]),mR=pR||!Dd("--no-colors")&&!$0("no-color")&&(!ws||process.stdout.isTTY)&&(!ws||Dd("--color")||Pl("COLORTERM")!==null||(Pl("TERM")||"").includes("color")),gR=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=S_(t[n]);return btoa(e)},yR=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),bR=B0?gR:yR,xR=t=>R_(e=>xs(e,t));class wR{constructor(e,n){this.left=e,this.right=n}}const xn=(t,e)=>new wR(t,e),kR=typeof document<"u"?document:{};typeof DOMParser<"u"&&new DOMParser;const vR=t=>g_(t,(e,n)=>`${n}:${e};`).join(""),SR=t=>class{constructor(n){this._=n}destroy(){t(this._)}},CR=SR(clearTimeout),H0=(t,e)=>new CR(setTimeout(e,t)),Dn=Symbol,z0=Dn(),F0=Dn(),ER=Dn(),MR=Dn(),AR=Dn(),U0=Dn(),TR=Dn(),ch=Dn(),NR=Dn(),_R=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r<t.length;r++){const s=t[r];if(s===void 0)break;if(s.constructor===String||s.constructor===Number)e.push(s);else if(s.constructor===Object)break}for(r>0&&n.push(e.join(""));r<t.length;r++){const s=t[r];s instanceof Symbol||n.push(s)}return n},RR={[z0]:xn("font-weight","bold"),[F0]:xn("font-weight","normal"),[ER]:xn("color","blue"),[AR]:xn("color","green"),[MR]:xn("color","grey"),[U0]:xn("color","red"),[TR]:xn("color","purple"),[ch]:xn("color","orange"),[NR]:xn("color","black")},OR=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[],r=Kt();let s=[],i=0;for(;i<t.length;i++){const o=t[i],l=RR[o];if(l!==void 0)r.set(l.left,l.right);else{if(o===void 0)break;if(o.constructor===String||o.constructor===Number){const a=vR(r);i>0||a.length>0?(e.push("%c"+o),n.push(a)):e.push(o)}else break}}for(i>0&&(s=n,s.unshift(e.join("")));i<t.length;i++){const o=t[i];o instanceof Symbol||s.push(o)}return s},V0=mR?OR:_R,DR=(...t)=>{console.log(...V0(t)),q0.forEach(e=>e.print(t))},W0=(...t)=>{console.warn(...V0(t)),t.unshift(ch),q0.forEach(e=>e.print(t))},q0=Pr(),K0=t=>({[Symbol.iterator](){return this},next:t}),LR=(t,e)=>K0(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Oc=(t,e)=>K0(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class dh{constructor(e,n){this.clock=e,this.len=n}}class Ts{constructor(){this.clients=new Map}}const cr=(t,e,n)=>e.clients.forEach((r,s)=>{const i=t.doc.store.clients.get(s);if(i!=null){const o=i[i.length-1],l=o.id.clock+o.length;for(let a=0,c=r[a];a<r.length&&c.clock<l;c=r[++a])tx(t,i,c.clock,c.len,n)}}),IR=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const s=_n((n+r)/2),i=t[s],o=i.clock;if(o<=e){if(e<o+i.len)return s;n=s+1}else r=s-1}return null},Ns=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&IR(n,e.clock)!==null},uh=t=>{t.clients.forEach(e=>{e.sort((s,i)=>s.clock-i.clock);let n,r;for(n=1,r=1;n<e.length;n++){const s=e[r-1],i=e[n];s.clock+s.len>=i.clock?s.len=lr(s.len,i.clock+i.len-s.clock):(r<n&&(e[r]=i),r++)}e.length=r})},Ld=t=>{const e=new Ts;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){const i=r.slice();for(let o=n+1;o<t.length;o++)b_(i,t[o].clients.get(s)||[]);e.clients.set(s,i)}});return uh(e),e},Si=(t,e,n,r)=>{On(t.clients,e,()=>[]).push(new dh(n,r))},G0=()=>new Ts,jR=t=>{const e=G0();return t.clients.forEach((n,r)=>{const s=[];for(let i=0;i<n.length;i++){const o=n[i];if(o.deleted){const l=o.id.clock;let a=o.length;if(i+1<n.length)for(let c=n[i+1];i+1<n.length&&c.deleted;c=n[++i+1])a+=c.length;s.push(new dh(l,a))}}s.length>0&&e.clients.set(r,s)}),e},hh=(t,e)=>{ge(t.restEncoder,e.clients.size),Br(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),ge(t.restEncoder,n);const s=r.length;ge(t.restEncoder,s);for(let i=0;i<s;i++){const o=r[i];t.writeDsClock(o.clock),t.writeDsLen(o.len)}})},PR=t=>{const e=new Ts,n=Re(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const s=Re(t.restDecoder),i=Re(t.restDecoder);if(i>0){const o=On(e.clients,s,()=>[]);for(let l=0;l<i;l++)o.push(new dh(t.readDsClock(),t.readDsLen()))}}return e},fm=(t,e,n)=>{const r=new Ts,s=Re(t.restDecoder);for(let i=0;i<s;i++){t.resetDsCurVal();const o=Re(t.restDecoder),l=Re(t.restDecoder),a=n.clients.get(o)||[],c=Ue(n,o);for(let d=0;d<l;d++){const u=t.readDsClock(),h=u+t.readDsLen();if(u<c){c<h&&Si(r,o,c,h-c);let f=Yt(a,u),p=a[f];for(!p.deleted&&p.id.clock<u&&(a.splice(f+1,0,Vl(e,p,u-p.id.clock)),f++);f<a.length&&(p=a[f++],p.id.clock<h);)p.deleted||(h<p.id.clock+p.length&&a.splice(f,0,Vl(e,p,h-p.id.clock)),p.delete(e))}else Si(r,o,u,h-u)}}if(r.clients.size>0){const i=new wa;return ge(i.restEncoder,0),hh(i,r),i.toUint8Array()}return null},J0=D0;class Ur extends T0{constructor({guid:e=tR(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:l=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=J0(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new Q0,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=dm(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const a=()=>dm(c=>{const d=u=>{(u===void 0||u===!0)&&(this.off("sync",d),c())};this.on("sync",d)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=a()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=a()}load(){const e=this._item;e!==null&&!this.shouldLoad&&Ce(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Br(this.subdocs).map(e=>e.guid))}transact(e,n=null){return Ce(this,e,n)}get(e,n=tt){const r=On(this.share,e,()=>{const i=new n;return i._integrate(this,null),i}),s=r.constructor;if(n!==tt&&s!==n)if(s===tt){const i=new n;i._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(e,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,ds)}getText(e=""){return this.get(e,dr)}getMap(e=""){return this.get(e,ks)}getXmlElement(e=""){return this.get(e,ht)}getXmlFragment(e=""){return this.get(e,$r)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,Br(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new Ur({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,Ce(e.parent.doc,r=>{const s=n.doc;e.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class BR{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Re(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Re(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Bl extends BR{constructor(e){super(e),this.keys=[],Re(e),this.keyClockDecoder=new Rc(It(e)),this.clientDecoder=new zo(It(e)),this.leftClockDecoder=new Rc(It(e)),this.rightClockDecoder=new Rc(It(e)),this.infoDecoder=new cm(It(e),vi),this.stringDecoder=new Y_(It(e)),this.parentInfoDecoder=new cm(It(e),vi),this.typeRefDecoder=new zo(It(e)),this.lenDecoder=new zo(It(e))}readLeftID(){return new as(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new as(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return jl(this.restDecoder)}readBuf(){return It(this.restDecoder)}readJSON(){return jl(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class $R{constructor(){this.restEncoder=zi()}toUint8Array(){return qt(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){ge(this.restEncoder,e)}writeDsLen(e){ge(this.restEncoder,e)}}class HR extends $R{writeLeftID(e){ge(this.restEncoder,e.client),ge(this.restEncoder,e.clock)}writeRightID(e){ge(this.restEncoder,e.client),ge(this.restEncoder,e.clock)}writeClient(e){ge(this.restEncoder,e)}writeInfo(e){_d(this.restEncoder,e)}writeString(e){ls(this.restEncoder,e)}writeParentInfo(e){ge(this.restEncoder,e?1:0)}writeTypeRef(e){ge(this.restEncoder,e)}writeLen(e){ge(this.restEncoder,e)}writeAny(e){xs(this.restEncoder,e)}writeBuf(e){Tt(this.restEncoder,e)}writeJSON(e){ls(this.restEncoder,JSON.stringify(e))}writeKey(e){ls(this.restEncoder,e)}}class zR{constructor(){this.restEncoder=zi(),this.dsCurrVal=0}toUint8Array(){return qt(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,ge(this.restEncoder,n)}writeDsLen(e){e===0&&Mt(),ge(this.restEncoder,e-1),this.dsCurrVal+=e}}class wa extends zR{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new _c,this.clientEncoder=new Ho,this.leftClockEncoder=new _c,this.rightClockEncoder=new _c,this.infoEncoder=new om(_d),this.stringEncoder=new z_,this.parentInfoEncoder=new om(_d),this.typeRefEncoder=new Ho,this.lenEncoder=new Ho}toUint8Array(){const e=zi();return ge(e,0),Tt(e,this.keyClockEncoder.toUint8Array()),Tt(e,this.clientEncoder.toUint8Array()),Tt(e,this.leftClockEncoder.toUint8Array()),Tt(e,this.rightClockEncoder.toUint8Array()),Tt(e,qt(this.infoEncoder)),Tt(e,this.stringEncoder.toUint8Array()),Tt(e,qt(this.parentInfoEncoder)),Tt(e,this.typeRefEncoder.toUint8Array()),Tt(e,this.lenEncoder.toUint8Array()),ba(e,qt(this.restEncoder)),qt(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){xs(this.restEncoder,e)}writeBuf(e){Tt(this.restEncoder,e)}writeJSON(e){xs(this.restEncoder,e)}writeKey(e){const n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}}const FR=(t,e,n,r)=>{r=lr(r,e[0].id.clock);const s=Yt(e,r);ge(t.restEncoder,e.length-s),t.writeClient(n),ge(t.restEncoder,r);const i=e[s];i.write(t,r-i.id.clock);for(let o=s+1;o<e.length;o++)e[o].write(t,0)},Y0=(t,e,n)=>{const r=new Map;n.forEach((s,i)=>{Ue(e,i)>s&&r.set(i,s)}),ka(e).forEach((s,i)=>{n.has(i)||r.set(i,0)}),ge(t.restEncoder,r.size),Br(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{FR(t,e.clients.get(s),s,i)})},UR=(t,e)=>{const n=Kt(),r=Re(t.restDecoder);for(let s=0;s<r;s++){const i=Re(t.restDecoder),o=new Array(i),l=t.readClient();let a=Re(t.restDecoder);n.set(l,{i:0,refs:o});for(let c=0;c<i;c++){const d=t.readInfo();switch(ya&d){case 0:{const u=t.readLen();o[c]=new Bt(ce(l,a),u),a+=u;break}case 10:{const u=Re(t.restDecoder);o[c]=new Vt(ce(l,a),u),a+=u;break}default:{const u=(d&(Tn|yt))===0,h=new ve(ce(l,a),null,(d&yt)===yt?t.readLeftID():null,null,(d&Tn)===Tn?t.readRightID():null,u?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,u&&(d&wi)===wi?t.readString():null,Sx(t,d));o[c]=h,a+=h.length}}}}return n},VR=(t,e,n)=>{const r=[];let s=Br(n.keys()).sort((f,p)=>f-p);if(s.length===0)return null;const i=()=>{if(s.length===0)return null;let f=n.get(s[s.length-1]);for(;f.refs.length===f.i;)if(s.pop(),s.length>0)f=n.get(s[s.length-1]);else return null;return f};let o=i();if(o===null)return null;const l=new Q0,a=new Map,c=(f,p)=>{const g=a.get(f);(g==null||g>p)&&a.set(f,p)};let d=o.refs[o.i++];const u=new Map,h=()=>{for(const f of r){const p=f.id.client,g=n.get(p);g?(g.i--,l.clients.set(p,g.refs.slice(g.i)),n.delete(p),g.i=0,g.refs=[]):l.clients.set(p,[f]),s=s.filter(y=>y!==p)}r.length=0};for(;;){if(d.constructor!==Vt){const p=On(u,d.id.client,()=>Ue(e,d.id.client))-d.id.clock;if(p<0)r.push(d),c(d.id.client,d.id.clock-1),h();else{const g=d.getMissing(t,e);if(g!==null){r.push(d);const y=n.get(g)||{refs:[],i:0};if(y.refs.length===y.i)c(g,Ue(e,g)),h();else{d=y.refs[y.i++];continue}}else(p===0||p<d.length)&&(d.integrate(t,p),u.set(d.id.client,d.id.clock+d.length))}}if(r.length>0)d=r.pop();else if(o!==null&&o.i<o.refs.length)d=o.refs[o.i++];else{if(o=i(),o===null)break;d=o.refs[o.i++]}}if(l.clients.size>0){const f=new wa;return Y0(f,l,new Map),ge(f.restEncoder,0),{missing:a,update:f.toUint8Array()}}return null},WR=(t,e)=>Y0(t,e.doc.store,e.beforeState),qR=(t,e,n,r=new Bl(t))=>Ce(e,s=>{s.local=!1;let i=!1;const o=s.doc,l=o.store,a=UR(r,o),c=VR(s,l,a),d=l.pendingStructs;if(d){for(const[h,f]of d.missing)if(f<Ue(l,h)){i=!0;break}if(c){for(const[h,f]of c.missing){const p=d.missing.get(h);(p==null||p>f)&&d.missing.set(h,f)}d.update=vm([d.update,c.update])}}else l.pendingStructs=c;const u=fm(r,s,l);if(l.pendingDs){const h=new Bl(ih(l.pendingDs));Re(h.restDecoder);const f=fm(h,s,l);u&&f?l.pendingDs=vm([u,f]):l.pendingDs=u||f}else l.pendingDs=u;if(i){const h=l.pendingStructs.update;l.pendingStructs=null,Id(s.doc,h)}},n,!1),Id=(t,e,n,r=Bl)=>{const s=ih(e);qR(s,t,n,new r(s))};class KR{constructor(){this.l=[]}}const pm=()=>new KR,mm=(t,e)=>t.l.push(e),gm=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(s=>e!==s),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},X0=(t,e,n)=>ah(t.l,[e,n]);class as{constructor(e,n){this.client=e,this.clock=n}}const Eo=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,ce=(t,e)=>new as(t,e),Ci=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Mt()},Ei=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class $l{constructor(e,n,r,s=0){this.type=e,this.tname=n,this.item=r,this.assoc=s}}class GR{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const JR=(t,e,n=0)=>new GR(t,e,n),Mo=(t,e,n)=>{let r=null,s=null;return t._item===null?s=Ci(t):r=ce(t._item.id.client,t._item.id.clock),new $l(r,s,e,n)},Dc=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Mo(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Mo(t,ce(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Mo(t,r.lastId,n);r=r.right}return Mo(t,null,n)},YR=(t,e)=>{const n=cs(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},XR=(t,e,n=!0)=>{const r=e.store,s=t.item,i=t.type,o=t.tname,l=t.assoc;let a=null,c=0;if(s!==null){if(Ue(r,s.client)<=s.clock)return null;const d=n?$d(r,s):YR(r,s),u=d.item;if(!(u instanceof ve))return null;if(a=u.parent,a._item===null||!a._item.deleted){c=u.deleted||!u.countable?0:d.diff+(l>=0?0:1);let h=u.left;for(;h!==null;)!h.deleted&&h.countable&&(c+=h.length),h=h.left}}else{if(o!==null)a=e.get(o);else if(i!==null){if(Ue(r,i.client)<=i.clock)return null;const{item:d}=n?$d(r,i):{item:cs(r,i)};if(d instanceof ve&&d.content instanceof en)a=d.content.type;else return null}else throw Mt();l>=0?c=a._length:c=0}return JR(a,c,t.assoc)};class fh{constructor(e,n){this.ds=e,this.sv=n}}const Z0=(t,e)=>new fh(t,e),Lc=t=>Z0(jR(t.store),ka(t.store)),br=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Ns(e.ds,t.id),jd=(t,e)=>{const n=On(t.meta,jd,Pr),r=t.doc.store;n.has(e)||(e.sv.forEach((s,i)=>{s<Ue(r,i)&&vt(t,ce(i,s))}),cr(t,e.ds,s=>{}),n.add(e))};class Q0{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const ka=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},Ue=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},ex=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw Mt()}n.push(e)},Yt=(t,e)=>{let n=0,r=t.length-1,s=t[r],i=s.id.clock;if(i===e)return r;let o=_n(e/(i+s.length-1)*r);for(;n<=r;){if(s=t[o],i=s.id.clock,i<=e){if(e<i+s.length)return o;n=o+1}else r=o-1;o=_n((n+r)/2)}throw Mt()},ZR=(t,e)=>{const n=t.clients.get(e.client);return n[Yt(n,e.clock)]},cs=ZR,Pd=(t,e,n)=>{const r=Yt(e,n),s=e[r];return s.id.clock<n&&s instanceof ve?(e.splice(r+1,0,Vl(t,s,n-s.id.clock)),r+1):r},vt=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[Pd(t,n,e.clock)]},ym=(t,e,n)=>{const r=e.clients.get(n.client),s=Yt(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==Bt&&r.splice(s+1,0,Vl(t,i,n.clock-i.id.clock+1)),i},QR=(t,e,n)=>{const r=t.clients.get(e.id.client);r[Yt(r,e.id.clock)]=n},tx=(t,e,n,r,s)=>{if(r===0)return;const i=n+r;let o=Pd(t,e,n),l;do l=e[o++],i<l.id.clock+l.length&&Pd(t,e,i),s(l);while(o<e.length&&e[o].id.clock<i)};class eO{constructor(e,n,r){this.doc=e,this.deleteSet=new Ts,this.beforeState=ka(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const bm=(t,e)=>e.deleteSet.clients.size===0&&!y_(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(uh(e.deleteSet),WR(t,e),hh(t,e.deleteSet),!0),xm=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&On(t.changed,e,Pr).add(n)},Fo=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof ve&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const i=e-s;return i&&t.splice(e+1-i,i),i},tO=(t,e,n)=>{for(const[r,s]of t.clients.entries()){const i=e.clients.get(r);for(let o=s.length-1;o>=0;o--){const l=s[o],a=l.clock+l.len;for(let c=Yt(i,l.clock),d=i[c];c<i.length&&d.id.clock<a;d=i[++c]){const u=i[c];if(l.clock+l.len<=u.id.clock)break;u instanceof ve&&u.deleted&&!u.keep&&n(u)&&u.gc(e,!1)}}}},nO=(t,e)=>{t.clients.forEach((n,r)=>{const s=e.clients.get(r);for(let i=n.length-1;i>=0;i--){const o=n[i],l=bs(s.length-1,1+Yt(s,o.clock+o.len-1));for(let a=l,c=s[a];a>0&&c.id.clock>=o.clock;c=s[a])a-=1+Fo(s,a)}})},nx=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{uh(i),n.afterState=ka(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const l=[];n.changed.forEach((a,c)=>l.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(n,a)})),l.push(()=>{n.changedParentTypes.forEach((a,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(a=a.filter(d=>d.target._item===null||!d.target._item.deleted),a.forEach(d=>{d.currentTarget=c,d._path=null}),a.sort((d,u)=>d.path.length-u.path.length),X0(c._dEH,a,n))})}),l.push(()=>r.emit("afterTransaction",[n,r])),ah(l,[]),n._needFormattingCleanup&&vO(n)}finally{r.gc&&tO(i,s,r.gcFilter),nO(i,s),n.afterState.forEach((d,u)=>{const h=n.beforeState.get(u)||0;if(h!==d){const f=s.clients.get(u),p=lr(Yt(f,h),1);for(let g=f.length-1;g>=p;)g-=1+Fo(f,g)}});for(let d=o.length-1;d>=0;d--){const{client:u,clock:h}=o[d].id,f=s.clients.get(u),p=Yt(f,h);p+1<f.length&&Fo(f,p+1)>1||p>0&&Fo(f,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(DR(ch,z0,"[yjs] ",F0,U0,"Changed the client-id because another client seems to be using it."),r.clientID=J0()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const d=new HR;bm(d,n)&&r.emit("update",[d.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const d=new wa;bm(d,n)&&r.emit("updateV2",[d.toUint8Array(),n.origin,r,n])}const{subdocsAdded:l,subdocsLoaded:a,subdocsRemoved:c}=n;(l.size>0||c.size>0||a.size>0)&&(l.forEach(d=>{d.clientID=r.clientID,d.collectionid==null&&(d.collectionid=r.collectionid),r.subdocs.add(d)}),c.forEach(d=>r.subdocs.delete(d)),r.emit("subdocs",[{loaded:a,added:l,removed:c},r,n]),c.forEach(d=>d.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):nx(t,e+1)}}},Ce=(t,e,n=null,r=!0)=>{const s=t._transactionCleanups;let i=!1,o=null;t._transaction===null&&(i=!0,t._transaction=new eO(t,n,r),s.push(t._transaction),s.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(i){const l=t._transaction===s[0];t._transaction=null,l&&nx(s,0)}}return o};class rO{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const wm=(t,e,n)=>{cr(t,n.deletions,r=>{r instanceof ve&&e.scope.some(s=>s===t.doc||Ei(s,r))&&bh(r,!1)})},km=(t,e,n)=>{let r=null;const s=t.doc,i=t.scope;Ce(s,l=>{for(;e.length>0&&t.currStackItem===null;){const a=s.store,c=e.pop(),d=new Set,u=[];let h=!1;cr(l,c.insertions,f=>{if(f instanceof ve){if(f.redone!==null){let{item:p,diff:g}=$d(a,f.id);g>0&&(p=vt(l,ce(p.id.client,p.id.clock+g))),f=p}!f.deleted&&i.some(p=>p===l.doc||Ei(p,f))&&u.push(f)}}),cr(l,c.deletions,f=>{f instanceof ve&&i.some(p=>p===l.doc||Ei(p,f))&&!Ns(c.insertions,f.id)&&d.add(f)}),d.forEach(f=>{h=vx(l,f,d,c.insertions,t.ignoreRemoteMapChanges,t)!==null||h});for(let f=u.length-1;f>=0;f--){const p=u[f];t.deleteFilter(p)&&(p.delete(l),h=!0)}t.currStackItem=h?c:null}l.changed.forEach((a,c)=>{a.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=l},t);const o=t.currStackItem;if(o!=null){const l=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return o};class rx extends T0{constructor(e,{captureTimeout:n=500,captureTransaction:r=a=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:l=Td(e)?e[0].doc:e instanceof Ur?e:e.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(e),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=a=>{if(!this.captureTransaction(a)||!this.scope.some(y=>a.changedParentTypes.has(y)||y===this.doc)||!this.trackedOrigins.has(a.origin)&&(!a.origin||!this.trackedOrigins.has(a.origin.constructor)))return;const c=this.undoing,d=this.redoing,u=c?this.redoStack:this.undoStack;c?this.stopCapturing():d||this.clear(!1,!0);const h=new Ts;a.afterState.forEach((y,b)=>{const w=a.beforeState.get(b)||0,M=y-w;M>0&&Si(h,b,w,M)});const f=nR();let p=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&u.length>0&&!c&&!d){const y=u[u.length-1];y.deletions=Ld([y.deletions,a.deleteSet]),y.insertions=Ld([y.insertions,h])}else u.push(new rO(a.deleteSet,h)),p=!0;!c&&!d&&(this.lastChange=f),cr(a,a.deleteSet,y=>{y instanceof ve&&this.scope.some(b=>b===a.doc||Ei(b,y))&&bh(y,!0)});const g=[{stackItem:u[u.length-1],origin:a.origin,type:c?"redo":"undo",changedParentTypes:a.changedParentTypes},this];p?this.emit("stack-item-added",g):this.emit("stack-item-updated",g)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const n=new Set(this.scope);e=Td(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof tt?r.doc!==this.doc:r!==this.doc)&&W0("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(s=>wm(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>wm(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=km(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=km(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*sO(t){const e=Re(t.restDecoder);for(let n=0;n<e;n++){const r=Re(t.restDecoder),s=t.readClient();let i=Re(t.restDecoder);for(let o=0;o<r;o++){const l=t.readInfo();if(l===10){const a=Re(t.restDecoder);yield new Vt(ce(s,i),a),i+=a}else if((ya&l)!==0){const a=(l&(Tn|yt))===0,c=new ve(ce(s,i),null,(l&yt)===yt?t.readLeftID():null,null,(l&Tn)===Tn?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(l&wi)===wi?t.readString():null,Sx(t,l));yield c,i+=c.length}else{const a=t.readLen();yield new Bt(ce(s,i),a),i+=a}}}}class iO{constructor(e,n){this.gen=sO(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Vt);return this.curr}}class oO{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const lO=(t,e)=>{if(t.constructor===Bt){const{client:n,clock:r}=t.id;return new Bt(ce(n,r+e),t.length-e)}else if(t.constructor===Vt){const{client:n,clock:r}=t.id;return new Vt(ce(n,r+e),t.length-e)}else{const n=t,{client:r,clock:s}=n.id;return new ve(ce(r,s+e),null,ce(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},vm=(t,e=Bl,n=wa)=>{if(t.length===1)return t[0];const r=t.map(d=>new e(ih(d)));let s=r.map(d=>new iO(d,!0)),i=null;const o=new n,l=new oO(o);for(;s=s.filter(h=>h.curr!==null),s.sort((h,f)=>{if(h.curr.id.client===f.curr.id.client){const p=h.curr.id.clock-f.curr.id.clock;return p===0?h.curr.constructor===f.curr.constructor?0:h.curr.constructor===Vt?1:-1:p}else return f.curr.id.client-h.curr.id.client}),s.length!==0;){const d=s[0],u=d.curr.id.client;if(i!==null){let h=d.curr,f=!1;for(;h!==null&&h.id.clock+h.length<=i.struct.id.clock+i.struct.length&&h.id.client>=i.struct.id.client;)h=d.next(),f=!0;if(h===null||h.id.client!==u||f&&h.id.clock>i.struct.id.clock+i.struct.length)continue;if(u!==i.struct.id.client)Bs(l,i.struct,i.offset),i={struct:h,offset:0},d.next();else if(i.struct.id.clock+i.struct.length<h.id.clock)if(i.struct.constructor===Vt)i.struct.length=h.id.clock+h.length-i.struct.id.clock;else{Bs(l,i.struct,i.offset);const p=h.id.clock-i.struct.id.clock-i.struct.length;i={struct:new Vt(ce(u,i.struct.id.clock+i.struct.length),p),offset:0}}else{const p=i.struct.id.clock+i.struct.length-h.id.clock;p>0&&(i.struct.constructor===Vt?i.struct.length-=p:h=lO(h,p)),i.struct.mergeWith(h)||(Bs(l,i.struct,i.offset),i={struct:h,offset:0},d.next())}}else i={struct:d.curr,offset:0},d.next();for(let h=d.curr;h!==null&&h.id.client===u&&h.id.clock===i.struct.id.clock+i.struct.length&&h.constructor!==Vt;h=d.next())Bs(l,i.struct,i.offset),i={struct:h,offset:0}}i!==null&&(Bs(l,i.struct,i.offset),i=null),aO(l);const a=r.map(d=>PR(d)),c=Ld(a);return hh(o,c),o.toUint8Array()},sx=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:qt(t.encoder.restEncoder)}),t.encoder.restEncoder=zi(),t.written=0)},Bs=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&sx(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),ge(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},aO=t=>{sx(t);const e=t.encoder.restEncoder;ge(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];ge(e,r.written),ba(e,r.restEncoder)}},Sm="You must not compute changes after the event-handler fired.";class va{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=cO(this.currentTarget,this.target))}deletes(e){return Ns(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw ar(Sm);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){const i=n._map.get(s);let o,l;if(this.adds(i)){let a=i.left;for(;a!==null&&this.adds(a);)a=a.left;if(this.deletes(i))if(a!==null&&this.deletes(a))o="delete",l=Ac(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",l=Ac(a.content.getContent())):(o="add",l=void 0)}else if(this.deletes(i))o="delete",l=Ac(i.content.getContent());else return;e.set(s,{action:o,oldValue:l})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw ar(Sm);const n=this.target,r=Pr(),s=Pr(),i=[];if(e={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let l=null;const a=()=>{l&&i.push(l)};for(let c=n._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((l===null||l.delete===void 0)&&(a(),l={delete:0}),l.delete+=c.length,s.add(c)):this.adds(c)?((l===null||l.insert===void 0)&&(a(),l={insert:[]}),l.insert=l.insert.concat(c.content.getContent()),r.add(c)):((l===null||l.retain===void 0)&&(a(),l={retain:0}),l.retain+=c.length);l!==null&&l.retain===void 0&&a()}this._changes=e}return e}}const cO=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;n.unshift(r)}e=e._item.parent}return n},ft=()=>{W0("Invalid access: Add Yjs type to a document before reading data.")},ix=80;let ph=0;class dO{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=ph++}}const uO=t=>{t.timestamp=ph++},ox=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=ph++},hO=(t,e,n)=>{if(t.length>=ix){const r=t.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return ox(r,e,n),r}else{const r=new dO(e,n);return t.push(r),r}},Sa=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((i,o)=>$o(e-i.index)<$o(e-o.index)?i:o);let r=t._start,s=0;for(n!==null&&(r=n.p,s=n.index,uO(n));r.right!==null&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return n!==null&&$o(n.index-s)<r.parent.length/ix?(ox(n,r,s),n):hO(t._searchMarker,r,s)},Mi=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const s=t[r];if(n>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){t.splice(r,1);continue}s.p=i,i.marker=!0}(e<s.index||n>0&&e===s.index)&&(s.index=lr(e,s.index+n))}},Ca=(t,e,n)=>{const r=t,s=e.changedParentTypes;for(;On(s,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;X0(r._eH,n,e)};class tt{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=pm(),this._dEH=pm(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw Gt()}clone(){throw Gt()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){mm(this._eH,e)}observeDeep(e){mm(this._dEH,e)}unobserve(e){gm(this._eH,e)}unobserveDeep(e){gm(this._dEH,e)}toJSON(){}}const lx=(t,e,n)=>{t.doc??ft(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const s=[];let i=t._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){const o=i.content.getContent();if(o.length<=e)e-=o.length;else{for(let l=e;l<o.length&&r>0;l++)s.push(o[l]),r--;e=0}}i=i.right}return s},ax=t=>{t.doc??ft();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e},cx=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&br(r,e)){const s=r.content.getContent();for(let i=0;i<s.length;i++)n.push(s[i])}r=r.right}return n},Ai=(t,e)=>{let n=0,r=t._start;for(t.doc??ft();r!==null;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let i=0;i<s.length;i++)e(s[i],n++,t)}r=r.right}},dx=(t,e)=>{const n=[];return Ai(t,(r,s)=>{n.push(e(r,s,t))}),n},fO=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},ux=(t,e)=>{t.doc??ft();const n=Sa(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Hl=(t,e,n,r)=>{let s=n;const i=t.doc,o=i.clientID,l=i.store,a=n===null?e._start:n.right;let c=[];const d=()=>{c.length>0&&(s=new ve(ce(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Hr(c)),s.integrate(t,0),c=[])};r.forEach(u=>{if(u===null)c.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(u);break;default:switch(d(),u.constructor){case Uint8Array:case ArrayBuffer:s=new ve(ce(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Fi(new Uint8Array(u))),s.integrate(t,0);break;case Ur:s=new ve(ce(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Ui(u)),s.integrate(t,0);break;default:if(u instanceof tt)s=new ve(ce(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new en(u)),s.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),d()},hx=()=>ar("Length exceeded!"),fx=(t,e,n,r)=>{if(n>e._length)throw hx();if(n===0)return e._searchMarker&&Mi(e._searchMarker,n,r.length),Hl(t,e,null,r);const s=n,i=Sa(e,n);let o=e._start;for(i!==null&&(o=i.p,n-=i.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&vt(t,ce(o.id.client,o.id.clock+n));break}n-=o.length}return e._searchMarker&&Mi(e._searchMarker,s,r.length),Hl(t,e,o,r)},pO=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:e._start}).p;if(s)for(;s.right;)s=s.right;return Hl(t,e,s,n)},px=(t,e,n,r)=>{if(r===0)return;const s=n,i=r,o=Sa(e,n);let l=e._start;for(o!==null&&(l=o.p,n-=o.index);l!==null&&n>0;l=l.right)!l.deleted&&l.countable&&(n<l.length&&vt(t,ce(l.id.client,l.id.clock+n)),n-=l.length);for(;r>0&&l!==null;)l.deleted||(r<l.length&&vt(t,ce(l.id.client,l.id.clock+r)),l.delete(t),r-=l.length),l=l.right;if(r>0)throw hx();e._searchMarker&&Mi(e._searchMarker,s,-i+r)},zl=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},mh=(t,e,n,r)=>{const s=e._map.get(n)||null,i=t.doc,o=i.clientID;let l;if(r==null)l=new Hr([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new Hr([r]);break;case Uint8Array:l=new Fi(r);break;case Ur:l=new Ui(r);break;default:if(r instanceof tt)l=new en(r);else throw new Error("Unexpected content type")}new ve(ce(o,Ue(i.store,o)),s,s&&s.lastId,null,null,e,n,l).integrate(t,0)},gh=(t,e)=>{t.doc??ft();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},mx=t=>{const e={};return t.doc??ft(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},gx=(t,e)=>{t.doc??ft();const n=t._map.get(e);return n!==void 0&&!n.deleted},mO=(t,e)=>{const n={};return t._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&&br(i,e)&&(n[s]=i.content.getContent()[i.length-1])}),n},Ao=t=>(t.doc??ft(),LR(t._map.entries(),e=>!e[1].deleted));class gO extends va{}class ds extends tt{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new ds;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ds}clone(){const e=new ds;return e.insert(0,this.toArray().map(n=>n instanceof tt?n.clone():n)),e}get length(){return this.doc??ft(),this._length}_callObserver(e,n){super._callObserver(e,n),Ca(this,e,new gO(this,e))}insert(e,n){this.doc!==null?Ce(this.doc,r=>{fx(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?Ce(this.doc,n=>{pO(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?Ce(this.doc,r=>{px(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return ux(this,e)}toArray(){return ax(this)}slice(e=0,n=this.length){return lx(this,e,n)}toJSON(){return this.map(e=>e instanceof tt?e.toJSON():e)}map(e){return dx(this,e)}forEach(e){Ai(this,e)}[Symbol.iterator](){return fO(this)}_write(e){e.writeTypeRef(zO)}}const yO=t=>new ds;class bO extends va{constructor(e,n,r){super(e,n),this.keysChanged=r}}class ks extends tt{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new ks}clone(){const e=new ks;return this.forEach((n,r)=>{e.set(r,n instanceof tt?n.clone():n)}),e}_callObserver(e,n){Ca(this,e,new bO(this,e,n))}toJSON(){this.doc??ft();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const s=n.content.getContent()[n.length-1];e[r]=s instanceof tt?s.toJSON():s}}),e}get size(){return[...Ao(this)].length}keys(){return Oc(Ao(this),e=>e[0])}values(){return Oc(Ao(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Oc(Ao(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??ft(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?Ce(this.doc,n=>{zl(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?Ce(this.doc,r=>{mh(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return gh(this,e)}has(e){return gx(this,e)}clear(){this.doc!==null?Ce(this.doc,e=>{this.forEach(function(n,r,s){zl(e,s,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(FO)}}const xO=t=>new ks,Yn=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&dR(t,e);class Bd{constructor(e,n,r,s){this.left=e,this.right=n,this.index=r,this.currentAttributes=s}forward(){switch(this.right===null&&Mt(),this.right.content.constructor){case Ge:this.right.deleted||_s(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const Cm=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case Ge:e.right.deleted||_s(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n<e.right.length&&vt(t,ce(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},To=(t,e,n,r)=>{const s=new Map,i=r?Sa(e,n):null;if(i){const o=new Bd(i.p.left,i.p,i.index,s);return Cm(t,o,n-i.index)}else{const o=new Bd(null,e._start,0,s);return Cm(t,o,n)}},yx=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Ge&&Yn(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const s=t.doc,i=s.clientID;r.forEach((o,l)=>{const a=n.left,c=n.right,d=new ve(ce(i,Ue(s.store,i)),a,a&&a.lastId,c,c&&c.id,e,null,new Ge(l,o));d.integrate(t,0),n.right=d,n.forward()})},_s=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},bx=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Ge&&Yn(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},xx=(t,e,n,r)=>{const s=t.doc,i=s.clientID,o=new Map;for(const l in r){const a=r[l],c=n.currentAttributes.get(l)??null;if(!Yn(c,a)){o.set(l,c);const{left:d,right:u}=n;n.right=new ve(ce(i,Ue(s.store,i)),d,d&&d.lastId,u,u&&u.id,e,null,new Ge(l,a)),n.right.integrate(t,0),n.forward()}}return o},Ic=(t,e,n,r,s)=>{n.currentAttributes.forEach((h,f)=>{s[f]===void 0&&(s[f]=null)});const i=t.doc,o=i.clientID;bx(n,s);const l=xx(t,e,n,s),a=r.constructor===String?new Xt(r):r instanceof tt?new en(r):new Vr(r);let{left:c,right:d,index:u}=n;e._searchMarker&&Mi(e._searchMarker,n.index,a.getLength()),d=new ve(ce(o,Ue(i.store,o)),c,c&&c.lastId,d,d&&d.id,e,null,a),d.integrate(t,0),n.right=d,n.index=u,n.forward(),yx(t,e,n,l)},Em=(t,e,n,r,s)=>{const i=t.doc,o=i.clientID;bx(n,s);const l=xx(t,e,n,s);e:for(;n.right!==null&&(r>0||l.size>0&&(n.right.deleted||n.right.content.constructor===Ge));){if(!n.right.deleted)switch(n.right.content.constructor){case Ge:{const{key:a,value:c}=n.right.content,d=s[a];if(d!==void 0){if(Yn(d,c))l.delete(a);else{if(r===0)break e;l.set(a,c)}n.right.delete(t)}else n.currentAttributes.set(a,c);break}default:r<n.right.length&&vt(t,ce(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
|
|
150
150
|
`;n.right=new ve(ce(o,Ue(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new Xt(a)),n.right.integrate(t,0),n.forward()}yx(t,e,n,l)},wx=(t,e,n,r,s)=>{let i=e;const o=Kt();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===Ge){const c=i.content;o.set(c.key,c)}i=i.right}let l=0,a=!1;for(;e!==i;){if(n===e&&(a=!0),!e.deleted){const c=e.content;switch(c.constructor){case Ge:{const{key:d,value:u}=c,h=r.get(d)??null;(o.get(d)!==c||h===u)&&(e.delete(t),l++,!a&&(s.get(d)??null)===u&&h!==u&&(h===null?s.delete(d):s.set(d,h))),!a&&!e.deleted&&_s(s,c);break}}}e=e.right}return l},wO=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Ge){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},kO=t=>{let e=0;return Ce(t.doc,n=>{let r=t._start,s=t._start,i=Kt();const o=Ad(i);for(;s;){if(s.deleted===!1)switch(s.content.constructor){case Ge:_s(o,s.content);break;default:e+=wx(n,r,s,i,o),i=Ad(o),r=s;break}s=s.right}}),e},vO=t=>{const e=new Set,n=t.doc;for(const[r,s]of t.afterState.entries()){const i=t.beforeState.get(r)||0;s!==i&&tx(t,n.store.clients.get(r),i,s,o=>{!o.deleted&&o.content.constructor===Ge&&o.constructor!==Bt&&e.add(o.parent)})}Ce(n,r=>{cr(t,t.deleteSet,s=>{if(s instanceof Bt||!s.parent._hasFormatting||e.has(s.parent))return;const i=s.parent;s.content.constructor===Ge?e.add(i):wO(r,s)});for(const s of e)kO(s)})},Mm=(t,e,n)=>{const r=n,s=Ad(e.currentAttributes),i=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case en:case Vr:case Xt:n<e.right.length&&vt(t,ce(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}i&&wx(t,i,e.right,s,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&Mi(o._searchMarker,e.index,-r+n),e};class SO extends va{constructor(e,n,r){super(e,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(s=>{s===null?this.childListChanged=!0:this.keysChanged.add(s)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,n=[];Ce(e,r=>{const s=new Map,i=new Map;let o=this.target._start,l=null;const a={};let c="",d=0,u=0;const h=()=>{if(l!==null){let f=null;switch(l){case"delete":u>0&&(f={delete:u}),u=0;break;case"insert":(typeof c=="object"||c.length>0)&&(f={insert:c},s.size>0&&(f.attributes={},s.forEach((p,g)=>{p!==null&&(f.attributes[g]=p)}))),c="";break;case"retain":d>0&&(f={retain:d},aR(a)||(f.attributes=oR({},a))),d=0;break}f&&n.push(f),l=null}};for(;o!==null;){switch(o.content.constructor){case en:case Vr:this.adds(o)?this.deletes(o)||(h(),l="insert",c=o.content.getContent()[0],h()):this.deletes(o)?(l!=="delete"&&(h(),l="delete"),u+=1):o.deleted||(l!=="retain"&&(h(),l="retain"),d+=1);break;case Xt:this.adds(o)?this.deletes(o)||(l!=="insert"&&(h(),l="insert"),c+=o.content.str):this.deletes(o)?(l!=="delete"&&(h(),l="delete"),u+=o.length):o.deleted||(l!=="retain"&&(h(),l="retain"),d+=o.length);break;case Ge:{const{key:f,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){const g=s.get(f)??null;Yn(g,p)?p!==null&&o.delete(r):(l==="retain"&&h(),Yn(p,i.get(f)??null)?delete a[f]:a[f]=p)}}else if(this.deletes(o)){i.set(f,p);const g=s.get(f)??null;Yn(g,p)||(l==="retain"&&h(),a[f]=g)}else if(!o.deleted){i.set(f,p);const g=a[f];g!==void 0&&(Yn(g,p)?g!==null&&o.delete(r):(l==="retain"&&h(),p===null?delete a[f]:a[f]=p))}o.deleted||(l==="insert"&&h(),_s(s,o.content));break}}o=o.right}for(h();n.length>0;){const f=n[n.length-1];if(f.retain!==void 0&&f.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class dr extends tt{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??ft(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new dr}clone(){const e=new dr;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new SO(this,e,n);Ca(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??ft();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Xt&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?Ce(this.doc,r=>{const s=new Bd(null,this._start,0,new Map);for(let i=0;i<e.length;i++){const o=e[i];if(o.insert!==void 0){const l=!n&&typeof o.insert=="string"&&i===e.length-1&&s.right===null&&o.insert.slice(-1)===`
|
|
151
|
-
`?o.insert.slice(0,-1):o.insert;(typeof l!="string"||l.length>0)&&Ic(r,this,s,l,o.attributes||{})}else o.retain!==void 0?Em(r,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&Mm(r,s,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??ft();const s=[],i=new Map,o=this.doc;let l="",a=this._start;function c(){if(l.length>0){const u={};let h=!1;i.forEach((p,g)=>{h=!0,u[g]=p});const f={insert:l};h&&(f.attributes=u),s.push(f),l=""}}const d=()=>{for(;a!==null;){if(br(a,e)||n!==void 0&&br(a,n))switch(a.content.constructor){case Xt:{const u=i.get("ychange");e!==void 0&&!br(a,e)?(u===void 0||u.user!==a.id.client||u.type!=="removed")&&(c(),i.set("ychange",r?r("removed",a.id):{type:"removed"})):n!==void 0&&!br(a,n)?(u===void 0||u.user!==a.id.client||u.type!=="added")&&(c(),i.set("ychange",r?r("added",a.id):{type:"added"})):u!==void 0&&(c(),i.delete("ychange")),l+=a.content.str;break}case en:case Vr:{c();const u={insert:a.content.getContent()[0]};if(i.size>0){const h={};u.attributes=h,i.forEach((f,p)=>{h[p]=f})}s.push(u);break}case Ge:br(a,e)&&(c(),_s(i,a.content));break}a=a.right}c()};return e||n?Ce(o,u=>{e&&jd(u,e),n&&jd(u,n),d()},"cleanup"):d(),s}insert(e,n,r){if(n.length<=0)return;const s=this.doc;s!==null?Ce(s,i=>{const o=To(i,this,e,!r);r||(r={},o.currentAttributes.forEach((l,a)=>{r[a]=l})),Ic(i,this,o,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const s=this.doc;s!==null?Ce(s,i=>{const o=To(i,this,e,!r);Ic(i,this,o,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;const r=this.doc;r!==null?Ce(r,s=>{Mm(s,To(s,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const s=this.doc;s!==null?Ce(s,i=>{const o=To(i,this,e,!1);o.right!==null&&Em(i,this,o,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?Ce(this.doc,n=>{zl(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?Ce(this.doc,r=>{mh(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return gh(this,e)}getAttributes(){return mx(this)}_write(e){e.writeTypeRef(UO)}}const CO=t=>new dr;class jc{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??ft()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===ht||n.constructor===$r)&&n._start!==null)e=n._start;else for(;e!==null;){const r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class $r extends tt{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new $r}clone(){const e=new $r;return e.insert(0,this.toArray().map(n=>n instanceof tt?n.clone():n)),e}get length(){return this.doc??ft(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new jc(this,e)}querySelector(e){e=e.toUpperCase();const r=new jc(this,s=>s.nodeName&&s.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),Br(new jc(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){Ca(this,e,new AO(this,n,e))}toString(){return dx(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const s=e.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),Ai(this,i=>{s.insertBefore(i.toDOM(e,n,r),null)}),s}insert(e,n){this.doc!==null?Ce(this.doc,r=>{fx(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)Ce(this.doc,r=>{const s=e&&e instanceof tt?e._item:e;Hl(r,this,s,n)});else{const r=this._prelimContent,s=e===null?0:r.findIndex(i=>i===e)+1;if(s===0&&e!==null)throw ar("Reference item not found");r.splice(s,0,...n)}}delete(e,n=1){this.doc!==null?Ce(this.doc,r=>{px(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return ax(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return ux(this,e)}slice(e=0,n=this.length){return lx(this,e,n)}forEach(e){Ai(this,e)}_write(e){e.writeTypeRef(WO)}}const EO=t=>new $r;class ht extends $r{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new ht(this.nodeName)}clone(){const e=new ht(this.nodeName),n=this.getAttributes();return lR(n,(r,s)=>{typeof r=="string"&&e.setAttribute(s,r)}),e.insert(0,this.toArray().map(r=>r instanceof tt?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const l in e)r.push(l);r.sort();const s=r.length;for(let l=0;l<s;l++){const a=r[l];n.push(a+'="'+e[a]+'"')}const i=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(e){this.doc!==null?Ce(this.doc,n=>{zl(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?Ce(this.doc,r=>{mh(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return gh(this,e)}hasAttribute(e){return gx(this,e)}getAttributes(e){return e?mO(this,e):mx(this)}toDOM(e=document,n={},r){const s=e.createElement(this.nodeName),i=this.getAttributes();for(const o in i){const l=i[o];typeof l=="string"&&s.setAttribute(o,l)}return Ai(this,o=>{s.appendChild(o.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef(VO),e.writeKey(this.nodeName)}}const MO=t=>new ht(t.readKey());class AO extends va{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}}class Fl extends ks{constructor(e){super(),this.hookName=e}_copy(){return new Fl(this.hookName)}clone(){const e=new Fl(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const s=n[this.hookName];let i;return s!==void 0?i=s.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(qO),e.writeKey(this.hookName)}}const TO=t=>new Fl(t.readKey());class Et extends dr{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new Et}clone(){const e=new Et;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const s=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(e=>{const n=[];for(const s in e.attributes){const i=[];for(const o in e.attributes[s])i.push({key:o,value:e.attributes[s][o]});i.sort((o,l)=>o.key<l.key?-1:1),n.push({nodeName:s,attrs:i})}n.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<n.length;s++){const i=n[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){const l=i.attrs[o];r+=` ${l.key}="${l.value}"`}r+=">"}r+=e.insert;for(let s=n.length-1;s>=0;s--)r+=`</${n[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(KO)}}const NO=t=>new Et;class yh{constructor(e,n){this.id=e,this.length=n}get deleted(){throw Gt()}mergeWith(e){return!1}write(e,n,r){throw Gt()}integrate(e,n){throw Gt()}}const _O=0;class Bt extends yh{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),ex(e.doc.store,this)}write(e,n){e.writeInfo(_O),e.writeLen(this.length-n)}getMissing(e,n){return null}}class Fi{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Fi(this.content)}splice(e){throw Gt()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const RO=t=>new Fi(t.readBuf());class Ti{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Ti(this.len)}splice(e){const n=new Ti(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){Si(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const OO=t=>new Ti(t.readLen()),kx=(t,e)=>new Ur({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Ui{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Ui(kx(this.doc.guid,this.opts))}splice(e){throw Gt()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const DO=t=>new Ui(kx(t.readString(),t.readAny()));class Vr{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Vr(this.embed)}splice(e){throw Gt()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const LO=t=>new Vr(t.readJSON());class Ge{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Ge(this.key,this.value)}splice(e){throw Gt()}mergeWith(e){return!1}integrate(e,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const IO=t=>new Ge(t.readKey(),t.readJSON());class Ul{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Ul(this.arr)}splice(e){const n=new Ul(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const i=this.arr[s];e.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}const jO=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const s=t.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new Ul(n)},PO=Pl("node_env")==="development";class Hr{constructor(e){this.arr=e,PO&&P0(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Hr(this.arr)}splice(e){const n=new Hr(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const i=this.arr[s];e.writeAny(i)}}getRef(){return 8}}const BO=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new Hr(n)};class Xt{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Xt(this.str)}splice(e){const n=new Xt(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const $O=t=>new Xt(t.readString()),HO=[yO,xO,CO,MO,EO,TO,NO],zO=0,FO=1,UO=2,VO=3,WO=4,qO=5,KO=6;class en{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new en(this.type._copy())}splice(e){throw Gt()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const GO=t=>new en(HO[t.readTypeRef()](t)),$d=(t,e)=>{let n=e,r=0,s;do r>0&&(n=ce(n.client,n.clock+r)),s=cs(t,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof ve);return{item:s,diff:r}},bh=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},Vl=(t,e,n)=>{const{client:r,clock:s}=e.id,i=new ve(ce(r,s+n),e,ce(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),e.redone!==null&&(i.redone=ce(e.redone.client,e.redone.clock+n)),e.right=i,i.right!==null&&(i.right.left=i),t._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),e.length=n,i},Am=(t,e)=>x_(t,n=>Ns(n.deletions,e)),vx=(t,e,n,r,s,i)=>{const o=t.doc,l=o.store,a=o.clientID,c=e.redone;if(c!==null)return vt(t,c);let d=e.parent._item,u=null,h;if(d!==null&&d.deleted===!0){if(d.redone===null&&(!n.has(d)||vx(t,d,n,r,s,i)===null))return null;for(;d.redone!==null;)d=vt(t,d.redone)}const f=d===null?e.parent:d.content.type;if(e.parentSub===null){for(u=e.left,h=e;u!==null;){let b=u;for(;b!==null&&b.parent._item!==d;)b=b.redone===null?null:vt(t,b.redone);if(b!==null&&b.parent._item===d){u=b;break}u=u.left}for(;h!==null;){let b=h;for(;b!==null&&b.parent._item!==d;)b=b.redone===null?null:vt(t,b.redone);if(b!==null&&b.parent._item===d){h=b;break}h=h.right}}else if(h=null,e.right&&!s){for(u=e;u!==null&&u.right!==null&&(u.right.redone||Ns(r,u.right.id)||Am(i.undoStack,u.right.id)||Am(i.redoStack,u.right.id));)for(u=u.right;u.redone;)u=vt(t,u.redone);if(u&&u.right!==null)return null}else u=f._map.get(e.parentSub)||null;const p=Ue(l,a),g=ce(a,p),y=new ve(g,u,u&&u.lastId,h,h&&h.id,f,e.parentSub,e.content.copy());return e.redone=g,bh(y,!0),y.integrate(t,0),y};class ve extends yh{constructor(e,n,r,s,i,o,l,a){super(e,a.getLength()),this.origin=r,this.left=n,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=l,this.redone=null,this.content=a,this.info=this.content.isCountable()?rm:0}set marker(e){(this.info&Nc)>0!==e&&(this.info^=Nc)}get marker(){return(this.info&Nc)>0}get keep(){return(this.info&nm)>0}set keep(e){this.keep!==e&&(this.info^=nm)}get countable(){return(this.info&rm)>0}get deleted(){return(this.info&Tc)>0}set deleted(e){this.deleted!==e&&(this.info^=Tc)}markDeleted(){this.info|=Tc}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Ue(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Ue(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===as&&this.id.client!==this.parent.client&&this.parent.clock>=Ue(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=ym(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=vt(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Bt||this.right&&this.right.constructor===Bt)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===ve?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===ve&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===as){const r=cs(n,this.parent);r.constructor===Bt?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=ym(e,e.doc.store,ce(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;const i=new Set,o=new Set;for(;s!==null&&s!==this.right;){if(o.add(s),i.add(s),Eo(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if(Eo(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(cs(e.doc.store,s.origin)))i.has(cs(e.doc.store,s.origin))||(r=s,i.clear());else break;s=s.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),ex(e.doc.store,this),this.content.integrate(e,this),xm(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Bt(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:ce(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Eo(e.origin,this.lastId)&&this.right===e&&Eo(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Si(e.deleteSet,this.id.client,this.id.clock,this.length),xm(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw Mt();this.content.gc(e),n?QR(e,this,new Bt(this.id,this.length)):this.content=new Ti(this.length)}write(e,n){const r=n>0?ce(this.id.client,this.id.clock+n-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&ya|(r===null?0:yt)|(s===null?0:Tn)|(i===null?0:wi);if(e.writeInfo(o),r!==null&&e.writeLeftID(r),s!==null&&e.writeRightID(s),r===null&&s===null){const l=this.parent;if(l._item!==void 0){const a=l._item;if(a===null){const c=Ci(l);e.writeParentInfo(!0),e.writeString(c)}else e.writeParentInfo(!1),e.writeLeftID(a.id)}else l.constructor===String?(e.writeParentInfo(!0),e.writeString(l)):l.constructor===as?(e.writeParentInfo(!1),e.writeLeftID(l)):Mt();i!==null&&e.writeString(i)}this.content.write(e,n)}}const Sx=(t,e)=>JO[e&ya](t),JO=[()=>{Mt()},OO,jO,RO,$O,LO,IO,GO,BO,DO,()=>{Mt()}],YO=10;class Vt extends yh{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){Mt()}write(e,n){e.writeInfo(YO),me(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const Cx=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Ex="__ $YJS$ __";Cx[Ex]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Cx[Ex]=!0;const XO=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},ZO=/[\uD800-\uDBFF]/,QO=/[\uDC00-\uDFFF]/,eD=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&ZO.test(t[n-1])&&n--;r+n<t.length&&r+n<e.length&&t[t.length-r-1]===e[e.length-r-1];)r++;return r>0&&QO.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},tD=eD,an=(t,e)=>t>>>e|t<<32-e,nD=t=>an(t,2)^an(t,13)^an(t,22),rD=t=>an(t,6)^an(t,11)^an(t,25),sD=t=>an(t,7)^an(t,18)^t>>>3,iD=t=>an(t,17)^an(t,19)^t>>>10,oD=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),lD=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class aD{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(lD),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let u=16;u<64;u++)n[u]=iD(n[u-2])+n[u-7]+sD(n[u-15])+n[u-16];let r=e[0],s=e[1],i=e[2],o=e[3],l=e[4],a=e[5],c=e[6],d=e[7];for(let u=0,h,f;u<64;u++)h=d+rD(l)+(l&a^~l&c)+oD[u]+n[u]>>>0,f=nD(r)+(r&s^r&i^s&i)>>>0,d=c,c=a,a=l,l=o+h>>>0,o=i,i=s,s=r,r=h+f>>>0;e[0]+=r,e[1]+=s,e[2]+=i,e[3]+=o,e[4]+=l,e[5]+=a,e[6]+=c,e[7]+=d}digest(e){let n=0;for(;n+56<=e.length;){let o=0;for(;o<16&&n+3<e.length;o++)this._W[o]=e[n++]<<24|e[n++]<<16|e[n++]<<8|e[n++];if(n%64!==0){for(this._W.fill(0,o,16);n<e.length;)this._W[o]|=e[n]<<(3-n%4)*8,n++;this._W[o]|=yt<<(3-n%4)*8}this._updateHash()}const r=n%64!==0;this._W.fill(0,0,16);let s=0;for(;n<e.length;s++)for(let o=3;o>=0&&n<e.length;o--)this._W[s]|=e[n++]<<o*8;r||(this._W[s-(n%4===0?0:1)]|=yt<<(3-n%4)*8),this._W[14]=e.byteLength/w_,this._W[15]=e.byteLength*8,this._updateHash();const i=new Uint8Array(32);for(let o=0;o<this._H.length;o++)for(let l=0;l<4;l++)i[o*4+l]=this._H[o]>>>(3-l)*8;return i}}const cD=t=>new aD().digest(t),Ie=new ge("y-sync"),Nn=new ge("y-undo");new ge("yjs-cursor");const dD=t=>{for(let n=6;n<t.length;n++)t[n%6]=t[n%6]^t[n];return t.slice(0,6)},uD=t=>bR(dD(cD(xR(t)))),Wl=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!Ns(e.ds,t.id),hD=[{light:"#ecd44433",dark:"#ecd444"}],fD=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=Pr();t.forEach(s=>r.add(s)),e=e.filter(s=>!r.has(s))}t.set(n,Q_(e))}return t.get(n)},pD=(t,{colors:e=hD,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:s=()=>{},mapping:i}={})=>{let o=!1;const l=new gD(t,i),a=new pe({props:{editable:c=>{const d=Ie.getState(c);return d.snapshot==null&&d.prevSnapshot==null}},key:Ie,state:{init:(c,d)=>({type:t,doc:t.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(c,d)=>{const u=c.getMeta(Ie);if(u!==void 0){d=Object.assign({},d);for(const h in u)d[h]=u[h]}return d.addToHistory=c.getMeta("addToHistory")!==!1,d.isChangeOrigin=u!==void 0&&!!u.isChangeOrigin,d.isUndoRedoOperation=u!==void 0&&!!u.isChangeOrigin&&!!u.isUndoRedoOperation,l.prosemirrorView!==null&&u!==void 0&&(u.snapshot!=null||u.prevSnapshot!=null)&&H0(0,()=>{l.prosemirrorView!=null&&(u.restore==null?l._renderSnapshot(u.snapshot,u.prevSnapshot,d):(l._renderSnapshot(u.snapshot,u.snapshot,d),delete d.restore,delete d.snapshot,delete d.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))}),d}},view:c=>(l.initView(c),i==null&&l._forceRerender(),s(),{update:()=>{const d=a.getState(c.state);if(d.snapshot==null&&d.prevSnapshot==null&&(o||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(o=!0,d.addToHistory===!1&&!d.isChangeOrigin){const u=Nn.getState(c.state),h=u&&u.undoManager;h&&h.stopCapturing()}l.mux(()=>{d.doc.transact(u=>{u.meta.set("addToHistory",d.addToHistory),l._prosemirrorChanged(c.state.doc)},Ie)})}},destroy:()=>{l.destroy()}})});return a},mD=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new St(t.doc));else if(e.type==="node"){const r=Vo(n.doc,n.type,e.anchor,n.mapping);t.setSelection(q.create(t.doc,r))}else{const r=Vo(n.doc,n.type,e.anchor,n.mapping),s=Vo(n.doc,n.type,e.head,n.mapping);r!==null&&s!==null&&t.setSelection(J.between(t.doc.resolve(r),t.doc.resolve(s)))}},Hd=(t,e)=>({type:e.selection.jsonID,anchor:Vd(e.selection.anchor,t.type,t.mapping),head:Vd(e.selection.head,t.type,t.mapping)});class gD{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=XO(),this.mapping=n,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=Hd(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(B0&&this._domSelectionInView===null&&(H0(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;const n=this.prosemirrorView._root.createRange();n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const s=n.getBoundingClientRect(),i=kR.documentElement;return s.bottom>=0&&s.right>=0&&s.left<=(window.innerWidth||i.clientWidth||0)&&s.top<=(window.innerHeight||i.clientHeight||0)}renderSnapshot(e,n){n||(n=Z0(G0(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Ie,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>Uo(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new P(O.from(e),0,0));n.setMeta(Ie,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(s=>Uo(s,this.prosemirrorView.state.schema,this)).filter(s=>s!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new P(O.from(n),0,0));if(e){const s=bs(lr(e.anchor,0),r.doc.content.size),i=bs(lr(e.head,0),r.doc.content.size);r.setSelection(J.create(r.doc,s,i))}this.prosemirrorView.dispatch(r.setMeta(Ie,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let s=this.doc,i=this.type;if(e||(e=Lc(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&Mt(),s=new Ur({gc:!1}),Id(s,n),n=Lc(s),Id(s,e),e=Lc(s),i._item===null){const o=Array.from(this.doc.share.keys()).find(l=>this.doc.share.get(l)===this.type);i=s.getXmlFragment(o)}else{const o=s.store.clients.get(i._item.id.client)??[],l=Yt(o,i._item.id.clock);i=o[l].content.type}this.mapping.clear(),this.mux(()=>{s.transact(o=>{const l=r.permanentUserData;l&&l.dss.forEach(u=>{cr(o,u,h=>{})});const a=(u,h)=>{const f=u==="added"?l.getUserByClientId(h.client):l.getUserByDeletedId(h);return{user:f,type:u,color:fD(r.colorMapping,r.colors,f)}},c=cx(i,new fh(n.ds,e.sv)).map(u=>!u._item.deleted||Wl(u._item,e)||Wl(u._item,n)?Uo(u,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,n,a):null).filter(u=>u!==null),d=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new P(O.from(c),0,0));this.prosemirrorView.dispatch(d.setMeta(Ie,{isChangeOrigin:!0}))},Ie)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=Ie.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const s=(l,a)=>this.mapping.delete(a);cr(n,n.deleteSet,l=>{if(l.constructor===ve){const a=l.content.type;a&&this.mapping.delete(a)}}),n.changed.forEach(s),n.changedParentTypes.forEach(s);const i=this.type.toArray().map(l=>Mx(l,this.prosemirrorView.state.schema,this)).filter(l=>l!==null);let o=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new P(O.from(i),0,0));mD(o,this.beforeTransactionSelection,this),o=o.setMeta(Ie,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof rx}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(e){this.doc.transact(()=>{Fd(this.doc,this.type,e,this),this.beforeTransactionSelection=Hd(this,this.prosemirrorView.state)},Ie)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const Mx=(t,e,n,r,s,i)=>{const o=n.mapping.get(t);if(o===void 0){if(t instanceof ht)return Uo(t,e,n,r,s,i);throw Gt()}return o},Uo=(t,e,n,r,s,i)=>{const o=[],l=a=>{if(a instanceof ht){const c=Mx(a,e,n,r,s,i);c!==null&&o.push(c)}else{const c=a._item.right?.content?.type;c instanceof dr&&!c._item.deleted&&c._item.id.client===c.doc.clientID&&(a.applyDelta([{retain:a.length},...c.toDelta()]),c.doc.transact(u=>{c._item.delete(u)}));const d=yD(a,e,n,r,s,i);d!==null&&d.forEach(u=>{u!==null&&o.push(u)})}};r===void 0||s===void 0?t.toArray().forEach(l):cx(t,new fh(s.ds,r.sv)).forEach(l);try{const a=t.getAttributes(r);r!==void 0&&(Wl(t._item,r)?Wl(t._item,s)||(a.ychange=i?i("added",t._item.id):{type:"added"}):a.ychange=i?i("removed",t._item.id):{type:"removed"});const c=e.node(t.nodeName,a,o);return n.mapping.set(t,c),c}catch{return t.doc.transact(c=>{t._item.delete(c)},Ie),n.mapping.delete(t),null}},yD=(t,e,n,r,s,i)=>{const o=[],l=t.toDelta(r,s,i);try{for(let a=0;a<l.length;a++){const c=l[a];o.push(e.text(c.insert,SD(c.attributes,e)))}}catch{return t.doc.transact(c=>{t._item.delete(c)},Ie),null}return o},bD=(t,e)=>{const n=new Et,r=t.map(s=>({insert:s.text,attributes:Tx(s.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},xD=(t,e)=>{const n=new ht(t.type.name);for(const r in t.attrs){const s=t.attrs[r];s!==null&&r!=="ychange"&&n.setAttribute(r,s)}return n.insert(0,Ea(t).map(r=>zd(r,e))),e.mapping.set(n,t),n},zd=(t,e)=>t instanceof Array?bD(t,e):xD(t,e),Tm=t=>typeof t=="object"&&t!==null,xh=(t,e)=>{const n=Object.keys(t).filter(s=>t[s]!==null);let r=n.length===Object.keys(e).filter(s=>e[s]!==null).length;for(let s=0;s<n.length&&r;s++){const i=n[s],o=t[i],l=e[i];r=i==="ychange"||o===l||Tm(o)&&Tm(l)&&xh(o,l)}return r},Ea=t=>{const e=t.content.content,n=[];for(let r=0;r<e.length;r++){const s=e[r];if(s.isText){const i=[];for(let o=e[r];r<e.length&&o.isText;o=e[++r])i.push(o);r--,n.push(i)}else n.push(s)}return n},Ax=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,s)=>r.insert===e[s].text&&I0(r.attributes||{}).length===e[s].marks.length&&j0(r.attributes,(i,o)=>{const l=wh(o),a=e[s].marks;return xh(i,a.find(c=>c.type.name===l)?.attrs)}))},Ni=(t,e)=>{if(t instanceof ht&&!(e instanceof Array)&&Ud(t,e)){const n=Ea(e);return t._length===n.length&&xh(t.getAttributes(),e.attrs)&&t.toArray().every((r,s)=>Ni(r,n[s]))}return t instanceof Et&&e instanceof Array&&Ax(t,e)},ql=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),Nm=(t,e,n)=>{const r=t.toArray(),s=Ea(e),i=s.length,o=r.length,l=bs(o,i);let a=0,c=0,d=!1;for(;a<l;a++){const u=r[a],h=s[a];if(ql(n.mapping.get(u),h))d=!0;else if(!Ni(u,h))break}for(;a+c<l;c++){const u=r[o-c-1],h=s[i-c-1];if(ql(n.mapping.get(u),h))d=!0;else if(!Ni(u,h))break}return{equalityFactor:a+c,foundMappedChild:d}},wD=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Xt?e+=n.content.str:n.content instanceof Ge&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},kD=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:s}=wD(t),i=e.map(c=>({insert:c.text,attributes:Object.assign({},r,Tx(c.marks,n))})),{insert:o,remove:l,index:a}=tD(s,i.map(c=>c.insert).join(""));t.delete(a,l),t.insert(a,o),t.applyDelta(i.map(c=>({retain:c.insert.length,attributes:c.attributes})))},vD=/(.*)(--[a-zA-Z0-9+/=]{8})$/,wh=t=>vD.exec(t)?.[1]??t,SD=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(wh(r),t[r]));return n},Tx=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const s=On(e.isOMark,r.type,()=>!r.type.excludes(r.type));n[s?`${r.type.name}--${uD(r.toJSON())}`:r.type.name]=r.attrs}}),n},Fd=(t,e,n,r)=>{if(e instanceof ht&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof ht){const u=e.getAttributes(),h=n.attrs;for(const f in h)h[f]!==null?u[f]!==h[f]&&f!=="ychange"&&e.setAttribute(f,h[f]):e.removeAttribute(f);for(const f in u)h[f]===void 0&&e.removeAttribute(f)}const s=Ea(n),i=s.length,o=e.toArray(),l=o.length,a=bs(i,l);let c=0,d=0;for(;c<a;c++){const u=o[c],h=s[c];if(!ql(r.mapping.get(u),h))if(Ni(u,h))r.mapping.set(u,h);else break}for(;d+c+1<a;d++){const u=o[l-d-1],h=s[i-d-1];if(!ql(r.mapping.get(u),h))if(Ni(u,h))r.mapping.set(u,h);else break}t.transact(()=>{for(;l-c-d>0&&i-c-d>0;){const h=o[c],f=s[c],p=o[l-d-1],g=s[i-d-1];if(h instanceof Et&&f instanceof Array)Ax(h,f)||kD(h,f,r),c+=1;else{let y=h instanceof ht&&Ud(h,f),b=p instanceof ht&&Ud(p,g);if(y&&b){const w=Nm(h,f,r),M=Nm(p,g,r);w.foundMappedChild&&!M.foundMappedChild?b=!1:!w.foundMappedChild&&M.foundMappedChild||w.equalityFactor<M.equalityFactor?y=!1:b=!1}y?(Fd(t,h,f,r),c+=1):b?(Fd(t,p,g,r),d+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[zd(f,r)]),c+=1)}}const u=l-c-d;if(l===1&&i===0&&o[0]instanceof Et?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):u>0&&(e.slice(c,c+u).forEach(h=>r.mapping.delete(h)),e.delete(c,u)),c+d<i){const h=[];for(let f=c;f<i-d;f++)h.push(zd(s[f],r));e.insert(c,h)}},Ie)},Ud=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name,Vd=(t,e,n)=>{if(t===0)return Dc(e,0,-1);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof Et){if(r._length>=t)return Dc(r,t,-1);if(t-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,t--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const s=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t<s)r=r._first.content.type,t--;else{if(t===1&&r._length===0&&s>1)return new $l(r._item===null?null:r._item.id,r._item===null?Ci(r):null,null);if(t-=s,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(t===0)return r=r._item===null?r:r._item.parent,new $l(r._item===null?null:r._item.id,r._item===null?Ci(r):null,null);do r=r._item.parent,t--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw Mt();if(t===0&&r.constructor!==Et&&r!==e)return CD(r._item.parent,r._item)}return Dc(e,e._length,-1)},CD=(t,e)=>{let n=null,r=null;return t._item===null?r=Ci(t):n=ce(t._item.id.client,t._item.id.clock),new $l(n,r,e.id)},Vo=(t,e,n,r)=>{const s=XR(n,t);if(s===null||s.type!==e&&!Ei(e,s.type._item))return null;let i=s.type,o=0;if(i.constructor===Et)o=s.index;else if(i._item===null||!i._item.deleted){let l=i._first,a=0;for(;a<i._length&&a<s.index&&l!==null;){if(!l.deleted){const c=l.content.type;a++,c instanceof Et?o+=c._length:o+=r.get(c).nodeSize}l=l.right}o+=1}for(;i!==e&&i._item!==null;){const l=i._item.parent;if(l._item===null||!l._item.deleted){o+=1;let a=l._first;for(;a!==null;){const c=a.content.type;if(c===i)break;a.deleted||(c instanceof Et?o+=c._length:o+=r.get(c).nodeSize),a=a.right}}i=l}return o-1};function ED(t){const e=t.toArray(),n=r=>{let s;if(r instanceof Et)s=r.toDelta().map(o=>{const l={type:"text",text:o.insert};return o.attributes&&(l.marks=Object.keys(o.attributes).map(a=>{const c=o.attributes[a],u={type:wh(a)};return Object.keys(c)&&(u.attrs=c),u})),l});else if(r instanceof ht){s={type:r.nodeName};const i=r.getAttributes();Object.keys(i).length&&(s.attrs=i);const o=r.toArray();o.length&&(s.content=o.map(n).flat())}else Mt();return s};return{type:"doc",content:e.map(n)}}const MD=t=>{const e=Nn.getState(t).undoManager;if(e!=null)return e.undo(),!0},AD=t=>{const e=Nn.getState(t).undoManager;if(e!=null)return e.redo(),!0},TD=new Set(["paragraph"]),ND=(t,e)=>!(t instanceof ve)||!(t.content instanceof en)||!(t.content.type instanceof dr||t.content.type instanceof ht&&e.has(t.content.type.nodeName))||t.content.type._length===0,_D=({protectedNodes:t=TD,trackedOrigins:e=[],undoManager:n=null}={})=>new pe({key:Nn,state:{init:(r,s)=>{const i=Ie.getState(s),o=n||new rx(i.type,{trackedOrigins:new Set([Ie].concat(e)),deleteFilter:l=>ND(l,t),captureTransaction:l=>l.meta.get("addToHistory")!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(r,s,i,o)=>{const l=Ie.getState(o).binding,a=s.undoManager,c=a.undoStack.length>0,d=a.redoStack.length>0;return l?{undoManager:a,prevSel:Hd(l,i),hasUndoOps:c,hasRedoOps:d}:c!==s.hasUndoOps||d!==s.hasRedoOps?Object.assign({},s,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):s}},view:r=>{const s=Ie.getState(r.state),i=Nn.getState(r.state).undoManager;return i.on("stack-item-added",({stackItem:o})=>{const l=s.binding;l&&o.meta.set(l,Nn.getState(r.state).prevSel)}),i.on("stack-item-popped",({stackItem:o})=>{const l=s.binding;l&&(l.beforeTransactionSelection=o.meta.get(l)||l.beforeTransactionSelection)}),{destroy:()=>{i.destroy()}}}});de.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(t=>t.name==="undoRedo")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".')},addCommands(){return{undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Nn.getState(e).undoManager.undoStack.length===0?!1:n?MD(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Nn.getState(e).undoManager.redoStack.length===0?!1:n?AD(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){var t;const e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),n=_D(this.options.yUndoOptions),r=n.spec.view;n.spec.view=o=>{const{undoManager:l}=Nn.getState(o.state);l.restore&&(l.restore(),l.restore=()=>{});const a=r?r(o):void 0;return{destroy:()=>{const c=l.trackedOrigins.has(l),d=l._observers;l.restore=()=>{c&&l.trackedOrigins.add(l),l.doc.on("afterTransaction",l.afterTransactionHandler),l._observers=d},a?.destroy&&a.destroy()}}};const s={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender},i=pD(e,s);return this.editor.options.enableContentCheck&&((t=e.doc)==null||t.on("beforeTransaction",()=>{try{const o=ED(e);if(o.content.length===0)return;this.editor.schema.nodeFromJSON(o).check()}catch(o){return this.editor.emit("contentError",{error:o,editor:this.editor,disableCollaboration:()=>{var l;(l=e.doc)==null||l.destroy(),this.storage.isDisabled=!0}}),!1}})),[i,n,this.editor.options.enableContentCheck&&new pe({key:new ge("filterInvalidContent"),filterTransaction:()=>{var o;return this.storage.isDisabled!==!1&&((o=e.doc)==null||o.destroy()),!0}})].filter(Boolean)}});function RD(t){return!!t.getMeta(Ie)}function _m(t){if(!t.length)return ye.empty;const e=[],n=t[0].$from.node(0);return t.forEach(r=>{const s=r.$from.pos,i=r.$from.nodeAfter;i&&e.push(_e.node(s,s+i.nodeSize,{class:"ProseMirror-selectednoderange"}))}),ye.create(n,e)}function Ma(t,e,n){const r=[],s=t.node(0);typeof n=="number"&&n>=0||(t.sameParent(e)?n=Math.max(0,t.sharedDepth(e.pos)-1):n=t.sharedDepth(e.pos));const i=new oi(t,e,n),o=i.depth===0?0:s.resolve(i.start).posAtIndex(0);return i.parent.forEach((l,a)=>{const c=o+a,d=c+l.nodeSize;if(c<i.start||c>=i.end)return;const u=new lu(s.resolve(c),s.resolve(d));r.push(u)}),r}var OD=class Nx{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Nx(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return new Xn(n,r)}},Xn=class Hn extends ee{constructor(e,n,r,s=1){const{doc:i}=e,o=e===n,l=e.pos===i.content.size&&n.pos===i.content.size,a=o&&!l?i.resolve(n.pos+(s>0?1:-1)):n,c=o&&l?i.resolve(e.pos-(s>0?1:-1)):e,d=Ma(c.min(a),c.max(a),r),u=a.pos>=e.pos?d[0].$from:d[d.length-1].$to,h=a.pos>=e.pos?d[d.length-1].$to:d[0].$from;super(u,h,d),this.depth=r}get $to(){return this.ranges[this.ranges.length-1].$to}eq(e){return e instanceof Hn&&e.$from.pos===this.$from.pos&&e.$to.pos===this.$to.pos}map(e,n){const r=e.resolve(n.map(this.anchor)),s=e.resolve(n.map(this.head));return new Hn(r,s)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:e}=this.$from;if(this.isForwards&&this.ranges.length>1){const s=this.ranges.slice(0,-1),i=s[0].$from,o=s[s.length-1].$to;return new Hn(i,o,this.depth)}const n=this.ranges[0],r=e.resolve(Math.max(0,n.$from.pos-1));return new Hn(this.$anchor,r,this.depth)}extendForwards(){const{doc:e}=this.$from;if(this.isBackwards&&this.ranges.length>1){const s=this.ranges.slice(1),i=s[0].$from,o=s[s.length-1].$to;return new Hn(o,i,this.depth)}const n=this.ranges[this.ranges.length-1],r=e.resolve(Math.min(e.content.size,n.$to.pos+1));return new Hn(this.$anchor,r,this.depth)}static fromJSON(e,n){return new Hn(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r,s,i=1){return new this(e.resolve(n),e.resolve(r),s,i)}getBookmark(){return new OD(this.anchor,this.head)}};Xn.prototype.visible=!1;function No(t){return t instanceof Xn}var DD=de.create({name:"nodeRange",addOptions(){return{depth:void 0,key:"Mod"}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,selection:i,tr:o}=r,{anchor:l,head:a}=i;if(!No(i)){const d=Xn.create(s,l,a,e,-1);return o.setSelection(d),n.dispatch(o),!0}const c=i.extendBackwards();return o.setSelection(c),n.dispatch(o),!0},"Shift-ArrowDown":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,selection:i,tr:o}=r,{anchor:l,head:a}=i;if(!No(i)){const d=Xn.create(s,l,a,e);return o.setSelection(d),n.dispatch(o),!0}const c=i.extendForwards();return o.setSelection(c),n.dispatch(o),!0},"Mod-a":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,tr:i}=r,o=Xn.create(s,0,s.content.size,e);return i.setSelection(o),n.dispatch(i),!0}}},onSelectionUpdate(){const{selection:t}=this.editor.state;No(t)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let t=!1,e=!1;return[new pe({key:new ge("nodeRange"),props:{attributes:()=>t?{class:"ProseMirror-noderangeselection"}:{class:""},handleDOMEvents:{mousedown:(n,r)=>{const{key:s}=this.options,i=/Mac/.test(navigator.platform),o=!!r.shiftKey,l=!!r.ctrlKey,a=!!r.altKey,c=!!r.metaKey,d=i?c:l;return(s==null||s==="Shift"&&o||s==="Control"&&l||s==="Alt"&&a||s==="Meta"&&c||s==="Mod"&&d)&&(e=!0),e&&document.addEventListener("mouseup",()=>{e=!1;const{state:u}=n,{doc:h,selection:f,tr:p}=u,{$anchor:g,$head:y}=f;if(g.sameParent(y))return;const b=Xn.create(h,g.pos,y.pos,this.options.depth);p.setSelection(b),n.dispatch(p)},{once:!0}),!1}},decorations:n=>{const{selection:r}=n,s=No(r);if(t=!1,!e)return s?(t=!0,_m(r.ranges)):null;const{$from:i,$to:o}=r;if(!s&&i.sameParent(o))return null;const l=Ma(i,o,this.options.depth);return l.length?(t=!0,_m(l)):null}}})]}}),LD=DD;function ID(t){let e="";const n=getComputedStyle(t);for(let r=0;r<n.length;r+=1)e+=`${n[r]}:${n.getPropertyValue(n[r])};`;return e}function jD(t){const e=t.cloneNode(!0),n=[t,...Array.from(t.getElementsByTagName("*"))],r=[e,...Array.from(e.getElementsByTagName("*"))];return n.forEach((s,i)=>{r[i].style.cssText=ID(s)}),e}function PD(t,e){let n=t;for(;n?.parentElement&&n.parentElement!==e.dom;)n=n.parentElement;return n?.parentElement===e.dom?n:void 0}function BD(t,e,n,r=5){const s=t.dom,i=s.firstElementChild,o=s.lastElementChild;if(!i||!o)return{x:e,y:n};const l=i.getBoundingClientRect(),a=o.getBoundingClientRect(),c=Math.min(Math.max(l.top+r,n),a.bottom-r),d=.5,u=Math.abs(l.left-a.left)<d,h=Math.abs(l.right-a.right)<d;let f=l;return u&&h&&(f=l),{x:Math.min(Math.max(f.left+r,e),f.right-r),y:c}}var _x=t=>{const{x:e,y:n,editor:r}=t,{view:s,state:i}=r,{x:o,y:l}=BD(s,e,n,5),a=s.root.elementsFromPoint(o,l);let c;if(Array.prototype.some.call(a,h=>{if(!s.dom.contains(h))return!1;const f=PD(h,s);return f?(c=f,!0):!1}),!c)return{resultElement:null,resultNode:null,pos:null};let d;try{d=s.posAtDOM(c,0)}catch{return{resultElement:null,resultNode:null,pos:null}}const u=i.doc.nodeAt(d);return{resultElement:c,resultNode:u,pos:d}};function _o(t,e){return window.getComputedStyle(t)[e]}function $D(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function HD(t,e,n){const r=parseInt(_o(t.dom,"paddingLeft"),10),s=parseInt(_o(t.dom,"paddingRight"),10),i=parseInt(_o(t.dom,"borderLeftWidth"),10),o=parseInt(_o(t.dom,"borderLeftWidth"),10),l=t.dom.getBoundingClientRect();return{left:$D(e,l.left+r+i,l.right-s-o),top:n}}function Rx(t){var e;(e=t.parentNode)==null||e.removeChild(t)}function zD(t,e){const{doc:n}=e.view.state,r=_x({editor:e,x:t.clientX,y:t.clientY});if(!r.resultNode||r.pos===null)return[];const s=t.clientX,i=HD(e.view,s,t.clientY),o=e.view.posAtCoords(i);if(!o)return[];const{pos:l}=o;if(!n.resolve(l).parent)return[];const c=n.resolve(r.pos),d=n.resolve(r.pos+1);return Ma(c,d,0)}function FD(t,e){const{view:n}=e;if(!t.dataTransfer)return;const{empty:r,$from:s,$to:i}=n.state.selection,o=zD(t,e),l=Ma(s,i,0),a=l.some(y=>o.find(b=>b.$from===y.$from&&b.$to===y.$to)),c=r||!a?o:l;if(!c.length)return;const{tr:d}=n.state,u=document.createElement("div"),h=c[0].$from.pos,f=c[c.length-1].$to.pos,p=Xn.create(n.state.doc,h,f),g=p.content();c.forEach(y=>{const b=n.nodeDOM(y.$from.pos),w=jD(b);u.append(w)}),u.style.position="absolute",u.style.top="-10000px",document.body.append(u),t.dataTransfer.clearData(),t.dataTransfer.setDragImage(u,0,0),n.dragging={slice:g,move:!0},d.setSelection(p),n.dispatch(d),document.addEventListener("drop",()=>Rx(u),{once:!0})}var Rm=(t,e)=>{const n=t.resolve(e),{depth:r}=n;return r===0?e:n.pos-n.parentOffset-1},Om=(t,e)=>{const n=t.nodeAt(e),r=t.resolve(e);let{depth:s}=r,i=n;for(;s>0;){const o=r.node(s);s-=1,s===0&&(i=o)}return i},Pc=(t,e)=>{const n=Ie.getState(t);return n?Vd(e,n.type,n.binding.mapping):null},UD=(t,e)=>{const n=Ie.getState(t);return n?Vo(n.doc,n.type,e,n.binding.mapping)||0:-1},Dm=(t,e)=>{let n=e;for(;n?.parentNode&&n.parentNode!==t.dom;)n=n.parentNode;return n},Ox=new ge("dragHandle"),Dx=({pluginKey:t=Ox,element:e,editor:n,computePositionConfig:r,getReferencedVirtualElement:s,onNodeChange:i,onElementDragStart:o,onElementDragEnd:l})=>{const a=document.createElement("div");let c=!1,d=null,u=-1,h,f=null,p=null;function g(){e&&(e.style.visibility="hidden",e.style.pointerEvents="none")}function y(){if(e){if(!n.isEditable){g();return}e.style.visibility="",e.style.pointerEvents="auto"}}function b(S){const A=s?.()||{getBoundingClientRect:()=>S.getBoundingClientRect()};Fu(A,e,r).then(x=>{Object.assign(e.style,{position:x.strategy,left:`${x.x}px`,top:`${x.y}px`})})}function w(S){o?.(S),FD(S,n),setTimeout(()=>{e&&(e.style.pointerEvents="none")},0)}function M(S){l?.(S),g(),e&&(e.style.pointerEvents="auto")}return e.addEventListener("dragstart",w),e.addEventListener("dragend",M),a.appendChild(e),{unbind(){e.removeEventListener("dragstart",w),e.removeEventListener("dragend",M),f&&(cancelAnimationFrame(f),f=null,p=null)},plugin:new pe({key:typeof t=="string"?new ge(t):t,state:{init(){return{locked:!1}},apply(S,A,x,k){const v=S.getMeta("lockDragHandle"),T=S.getMeta("hideDragHandle");if(v!==void 0&&(c=v),T)return g(),c=!1,d=null,u=-1,i?.({editor:n,node:null,pos:-1}),A;if(S.docChanged&&u!==-1&&e)if(RD(S)){const N=UD(k,h);N!==u&&(u=N)}else{const N=S.mapping.map(u);N!==u&&(u=N,h=Pc(k,u))}return A}},view:S=>{var A;return e.draggable=!0,e.style.pointerEvents="auto",(A=n.view.dom.parentElement)==null||A.appendChild(a),a.style.pointerEvents="none",a.style.position="absolute",a.style.top="0",a.style.left="0",{update(x,k){if(!e)return;if(!n.isEditable){g();return}if(c?e.draggable=!1:e.draggable=!0,S.state.doc.eq(k.doc)||u===-1)return;let v=S.nodeDOM(u);if(v=Dm(S,v),v===S.dom||v?.nodeType!==1)return;const T=S.posAtDOM(v,0),N=Om(n.state.doc,T),H=Rm(n.state.doc,T);d=N,u=H,h=Pc(S.state,u),i?.({editor:n,node:d,pos:u}),b(v)},destroy(){f&&(cancelAnimationFrame(f),f=null,p=null),e&&Rx(a)}}},props:{handleDOMEvents:{keydown(S){return!e||c||S.hasFocus()&&(g(),d=null,u=-1,i?.({editor:n,node:null,pos:-1})),!1},mouseleave(S,A){return c||A.target&&!a.contains(A.relatedTarget)&&(g(),d=null,u=-1,i?.({editor:n,node:null,pos:-1})),!1},mousemove(S,A){return!e||c||(p={x:A.clientX,y:A.clientY},f)||(f=requestAnimationFrame(()=>{if(f=null,!p)return;const{x,y:k}=p;p=null;const v=_x({x,y:k,editor:n});if(!v.resultElement)return;let T=v.resultElement;if(T=Dm(S,T),T===S.dom||T?.nodeType!==1)return;const N=S.posAtDOM(T,0),H=Om(n.state.doc,N);if(H!==d){const V=Rm(n.state.doc,N);d=H,u=V,h=Pc(S.state,u),i?.({editor:n,node:d,pos:u}),b(T),y()}})),!1}}}})}},Wd={placement:"left-start",strategy:"absolute"},VD=de.create({name:"dragHandle",addOptions(){return{render(){const t=document.createElement("div");return t.classList.add("drag-handle"),t},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0}},addCommands(){return{lockDragHandle:()=>({editor:t})=>(this.options.locked=!0,t.commands.setMeta("lockDragHandle",this.options.locked)),unlockDragHandle:()=>({editor:t})=>(this.options.locked=!1,t.commands.setMeta("lockDragHandle",this.options.locked)),toggleDragHandle:()=>({editor:t})=>(this.options.locked=!this.options.locked,t.commands.setMeta("lockDragHandle",this.options.locked))}},addProseMirrorPlugins(){const t=this.options.render();return[Dx({computePositionConfig:{...Wd,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:t,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd}).plugin]}}),WD=VD;function qD(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 s={className:"subst",begin:/\$\(/,end:/\)/,contains:[t.BACKSLASH_ESCAPE]},i=t.inherit(t.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},l={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,n,s]};s.contains.push(l);const a={match:/\\"/},c={className:"string",begin:/'/,end:/'/},d={match:/\\'/},u={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},t.NUMBER_MODE,n]},h=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],f=t.SHEBANG({binary:`(${h.join("|")})`,relevance:10}),p={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[t.inherit(t.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},g=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],y=["true","false"],b={match:/(\/[a-z._-]+)+/},w=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],M=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],S=["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"],A=["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","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:g,literal:y,built_in:[...w,...M,"set","shopt",...S,...A]},contains:[f,t.SHEBANG(),p,u,i,o,b,l,a,c,d,n]}}const KD=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_-]*/}}),GD=["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","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],JD=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],YD=[...GD,...JD],XD=["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"].sort().reverse(),ZD=["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"].sort().reverse(),QD=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),eL=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","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-end-end-radius","border-end-start-radius","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-start-end-radius","border-start-start-radius","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-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","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","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","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","margin-trim","marker","marker-end","marker-mid","marker-start","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","masonry-auto-flow","math-depth","math-shift","math-style","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","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-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","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","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","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function tL(t){const e=t.regex,n=KD(t),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},s="and or not only",i=/@-?\w[\w]*(-\w+)*/,o="[a-zA-Z-][a-zA-Z0-9_-]*",l=[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:":("+ZD.join("|")+")"},{begin:":(:)?("+QD.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+eL.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...l,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...l,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:e.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:XD.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...l,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+YD.join("|")+")\\b"}]}}const Lm="[A-Za-z$_][0-9A-Za-z$_]*",nL=["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","using"],rL=["true","false","null","undefined","NaN","Infinity"],Lx=["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"],Ix=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],jx=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],sL=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],iL=[].concat(jx,Lx,Ix);function oL(t){const e=t.regex,n=(F,{after:ue})=>{const xe="</"+F[0].slice(1);return F.input.indexOf(xe,ue)!==-1},r=Lm,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(F,ue)=>{const xe=F[0].length+F.index,_=F.input[xe];if(_==="<"||_===","){ue.ignoreMatch();return}_===">"&&(n(F,{after:xe})||ue.ignoreMatch());let Z;const fe=F.input.substring(xe);if(Z=fe.match(/^\s*=/)){ue.ignoreMatch();return}if((Z=fe.match(/^\s+extends\s+/))&&Z.index===0){ue.ignoreMatch();return}}},l={$pattern:Lm,keyword:nL,literal:rL,built_in:iL,"variable.language":sL},a="[0-9](_?[0-9])*",c=`\\.(${a})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",u={className:"number",variants:[{begin:`(\\b(${d})((${c})|\\.)?|(${c}))[eE][+-]?(${a})\\b`},{begin:`\\b(${d})\\b((${c})\\b|\\.)?|(${c})\\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},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},f={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},p={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"css"}},g={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,h]},w={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]},M=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,g,y,{match:/\$\d+/},u];h.contains=M.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(M)});const S=[].concat(w,h.contains),A=S.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(S)}]),x={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:A},k={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"}}]},v={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:{_:[...Lx,...Ix]}},T={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:[x],illegal:/%/},H={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function V(F){return e.concat("(?!",F.join("|"),")")}const $={match:e.concat(/\b/,V([...jx,"super","import"].map(F=>`${F}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},I={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},j={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},x]},Q="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",ie={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(Q)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[x]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:A,CLASS_REFERENCE:v},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),T,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,g,y,w,{match:/\$\d+/},u,v,{scope:"attr",match:r+e.lookahead(":"),relevance:0},ie,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[w,t.REGEXP_MODE,{className:"function",begin:Q,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:A}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{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:[x,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},I,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[x]},$,H,k,j,{match:/\$[(.]/}]}}function lL(t){const e={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],s={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[e,n,t.QUOTE_STRING_MODE,s,t.C_NUMBER_MODE,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function aL(t){const e=t.regex,n=new RegExp("[\\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"],l={$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"]},a={className:"meta",begin:/^(>>>|\.\.\.) /},c={className:"subst",begin:/\{/,end:/\}/,keywords:l,illegal:/#/},d={begin:/\{\{/,relevance:0},u={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,a,d,c]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,a,d,c]},{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,d,c]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,d,c]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},h="[0-9](_?[0-9])*",f=`(\\b(${h}))?\\.(${h})|\\b(${h})\\.`,p=`\\b|${r.join("|")}`,g={className:"number",relevance:0,variants:[{begin:`(\\b(${h})|(${f}))[eE][+-]?(${h})[jJ]?(?=${p})`},{begin:`(${f})[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(${h})[jJ](?=${p})`}]},y={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:l,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},b={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:["self",a,g,u,t.HASH_COMMENT_MODE]}]};return c.contains=[u,g,a],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:l,illegal:/(<\/|\?)|=>/,contains:[a,g,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},u,y,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[b]},{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:[g,b,u]}]}}function cL(t){const e=t.regex,n=t.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},s={begin:/"/,end:/"/,contains:[{match:/""/}]},i=["true","false","unknown"],o=["double precision","large object","with timezone","without timezone"],l=["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"],a=["add","asc","collation","desc","final","first","last","view"],c=["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"],d=["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"],u=["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"],h=["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"],f=d,p=[...c,...a].filter(A=>!d.includes(A)),g={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},y={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},b={match:e.concat(/\b/,e.either(...f),/\s*\(/),relevance:0,keywords:{built_in:f}};function w(A){return e.concat(/\b/,e.either(...A.map(x=>x.replace(/\s+/,"\\s+"))),/\b/)}const M={scope:"keyword",match:w(h),relevance:0};function S(A,{exceptions:x,when:k}={}){const v=k;return x=x||[],A.map(T=>T.match(/\|\d+$/)||x.includes(T)?T:v(T)?`${T}|0`:T)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:S(p,{when:A=>A.length<3}),literal:i,type:l,built_in:u},contains:[{scope:"type",match:w(o)},M,b,g,r,s,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,y]}}const Kl="[A-Za-z$_][0-9A-Za-z$_]*",Px=["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","using"],Bx=["true","false","null","undefined","NaN","Infinity"],$x=["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"],Hx=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],zx=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Fx=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Ux=[].concat(zx,$x,Hx);function dL(t){const e=t.regex,n=(F,{after:ue})=>{const xe="</"+F[0].slice(1);return F.input.indexOf(xe,ue)!==-1},r=Kl,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(F,ue)=>{const xe=F[0].length+F.index,_=F.input[xe];if(_==="<"||_===","){ue.ignoreMatch();return}_===">"&&(n(F,{after:xe})||ue.ignoreMatch());let Z;const fe=F.input.substring(xe);if(Z=fe.match(/^\s*=/)){ue.ignoreMatch();return}if((Z=fe.match(/^\s+extends\s+/))&&Z.index===0){ue.ignoreMatch();return}}},l={$pattern:Kl,keyword:Px,literal:Bx,built_in:Ux,"variable.language":Fx},a="[0-9](_?[0-9])*",c=`\\.(${a})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",u={className:"number",variants:[{begin:`(\\b(${d})((${c})|\\.)?|(${c}))[eE][+-]?(${a})\\b`},{begin:`\\b(${d})\\b((${c})\\b|\\.)?|(${c})\\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},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},f={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},p={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"css"}},g={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,h]},w={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]},M=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,g,y,{match:/\$\d+/},u];h.contains=M.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(M)});const S=[].concat(w,h.contains),A=S.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(S)}]),x={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:A},k={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"}}]},v={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:{_:[...$x,...Hx]}},T={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:[x],illegal:/%/},H={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function V(F){return e.concat("(?!",F.join("|"),")")}const $={match:e.concat(/\b/,V([...zx,"super","import"].map(F=>`${F}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},I={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},j={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},x]},Q="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",ie={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(Q)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[x]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:A,CLASS_REFERENCE:v},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),T,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,g,y,w,{match:/\$\d+/},u,v,{scope:"attr",match:r+e.lookahead(":"),relevance:0},ie,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[w,t.REGEXP_MODE,{className:"function",begin:Q,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:A}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{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:[x,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},I,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[x]},$,H,k,j,{match:/\$[(.]/}]}}function uL(t){const e=t.regex,n=dL(t),r=Kl,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},o={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},l={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},a=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],c={$pattern:Kl,keyword:Px.concat(a),literal:Bx,built_in:Ux.concat(s),"variable.language":Fx},d={className:"meta",begin:"@"+r},u=(g,y,b)=>{const w=g.contains.findIndex(M=>M.label===y);if(w===-1)throw new Error("can not find mode to replace");g.contains.splice(w,1,b)};Object.assign(n.keywords,c),n.exports.PARAMS_CONTAINS.push(d);const h=n.contains.find(g=>g.scope==="attr"),f=Object.assign({},h,{match:e.concat(r,e.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,h,f]),n.contains=n.contains.concat([d,i,o,f]),u(n,"shebang",t.SHEBANG()),u(n,"use_strict",l);const p=n.contains.find(g=>g.label==="func.def");return p.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function hL(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,s={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=t.inherit(i,{begin:/\(/,end:/\)/}),l=t.inherit(t.APOS_STRING_MODE,{className:"string"}),a=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),c={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[s]},{begin:/'/,end:/'/,contains:[s]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[i,a,l,o,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,o,a,l]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[a]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[c],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[c],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:e.concat(/</,e.lookahead(e.concat(n,e.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:c}]},{className:"tag",begin:e.concat(/<\//,e.lookahead(e.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}const Im={},fL="hljs-";function pL(t){const e=a0.newInstance();return t&&i(t),{highlight:n,highlightAuto:r,listLanguages:s,register:i,registerAlias:o,registered:l};function n(a,c,d){const u=d||Im,h=typeof u.prefix=="string"?u.prefix:fL;if(!e.getLanguage(a))throw new Error("Unknown language: `"+a+"` is not registered");e.configure({__emitter:mL,classPrefix:h});const f=e.highlight(c,{ignoreIllegals:!0,language:a});if(f.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:f.errorRaised});const p=f._emitter.root,g=p.data;return g.language=f.language,g.relevance=f.relevance,p}function r(a,c){const u=(c||Im).subset||s();let h=-1,f=0,p;for(;++h<u.length;){const g=u[h];if(!e.getLanguage(g))continue;const y=n(g,a,c);y.data&&y.data.relevance!==void 0&&y.data.relevance>f&&(f=y.data.relevance,p=y)}return p||{type:"root",children:[],data:{language:void 0,relevance:f}}}function s(){return e.listLanguages()}function i(a,c){if(typeof a=="string")e.registerLanguage(a,c);else{let d;for(d in a)Object.hasOwn(a,d)&&e.registerLanguage(d,a[d])}}function o(a,c){if(typeof a=="string")e.registerAliases(typeof c=="string"?c:[...c],{languageName:a});else{let d;for(d in a)if(Object.hasOwn(a,d)){const u=a[d];e.registerAliases(typeof u=="string"?u:[...u],{languageName:d})}}}function l(a){return!!e.getLanguage(a)}}class mL{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],s=e.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:s}):r.children.push(...s)}openNode(e){const n=this,r=e.split(".").map(function(o,l){return l?o+"_".repeat(l):n.options.classPrefix+o}),s=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:r},children:[]};s.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const Vx=de.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:[]}},addProseMirrorPlugins(){const t=new ge("trailingNode");return[new pe({key:t,appendTransaction:(e,n,r)=>{if(!e.some(h=>h.docChanged))return null;const{doc:i,schema:o}=r,l=i.lastChild,a=this.options.node,c=o.nodes[a];if(!c||l?.type.name===a||l&&this.options.notAfter.includes(l.type.name))return null;const d=i.content.size;return r.tr.insert(d,c.create())}})]}});var gL=tT;const yL=t=>{const{editor:e,pos:n}=t,r=e.state.doc.resolve(Math.max(n,0));return r.depth>0?r.node(r.depth-1):null},bL=t=>{const e='Press "/" to insert or start typing...',{node:n}=t,r=n.type.name,s=yL(t);if(r==="heading"){const i=n.attrs.level??1;switch(i){case 1:return"Add a title...";case 2:return"Add a section heading...";case 3:return"Add a subheading...";default:return`Heading ${i}`}}if(r==="taskItem")return"Add a task...";if(r==="listItem"){const i=s?.type.name;return i==="bulletList"?"Add a bullet...":i==="orderedList"?"Add a numbered item...":"Add a list item..."}if(r==="codeBlock"){const i=n.attrs.language;return i?`Write ${i} code...`:"Write some code..."}if(r==="paragraph"){const i=s?.type.name;if(!i||i==="doc")return e}return r==="doc"?e:""},Wx=gL.extend({addOptions(){return{...this.parent?.(),emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",includeChildren:!0,showOnlyCurrent:!0,showOnlyWhenEditable:!0,placeholder:e=>bL(e)}},addProseMirrorPlugins(){const t=new Set(["table","tableCell","tableHeader","tableRow"]),e=n=>{const r=this.editor.state.doc.resolve(n);for(let s=r.depth;s>=0;s-=1){const i=r.node(s);if(t.has(i.type.name))return!0}return!1};return[new pe({key:new ge("placeholder"),props:{decorations:({doc:n,selection:r})=>{if(!(this.editor.isEditable||!this.options.showOnlyWhenEditable))return null;const{anchor:i}=r,o=[],l=this.editor.isEmpty;return n.descendants((a,c)=>{if(e(c))return this.options.includeChildren;const d=i>=c&&i<=c+a.nodeSize,u=!a.isLeaf&&Li(a);if((d||!this.options.showOnlyCurrent)&&u){const h=[this.options.emptyNodeClass];l&&h.push(this.options.emptyEditorClass);const f=typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:c,hasAnchor:d}):this.options.placeholder,p=_e.node(c,c+a.nodeSize,{class:h.join(" "),"data-placeholder":f});o.push(p)}return this.options.includeChildren}),o.length?ye.create(n,o):null}}})]}}),xL=({node:t,updateAttributes:e,editor:n})=>{const[r,s]=C.useState(!1),{type:i,title:o,message:l,align:a,size:c,textAlign:d}=t.attrs,u={info:"bg-blue-50 text-blue-900 border-2 border-blue-200 dark:bg-blue-900/20 dark:text-blue-100 dark:border-blue-800",warning:"bg-yellow-50 text-yellow-900 border-2 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-100 dark:border-yellow-800",error:"bg-red-50 text-red-900 border-2 border-red-200 dark:bg-red-900/20 dark:text-red-100 dark:border-red-800",success:"bg-green-50 text-green-900 border-2 border-green-200 dark:bg-green-900/20 dark:text-green-100 dark:border-green-800"},h={small:"text-sm p-2",medium:"text-base p-3",large:"text-lg p-4"},f={left:"text-left",center:"text-center",right:"text-right"},p={left:"text-left",center:"text-center",right:"text-right"};return m.jsxs(Iu,{children:[m.jsx("div",{className:`${f[a]||"text-left"} cursor-grab`,onClick:()=>s(!0),"data-drag-handle":!0,children:m.jsxs("div",{className:`inline-block rounded-lg border p-2 m-1 ${u[i]||u.info} ${h[c]||h["fit-content"]} ${p[d]||p.left}`,children:[m.jsx("strong",{className:"font-bold block",children:o}),m.jsx("span",{children:l})]})}),r&&m.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center",onClick:()=>s(!1),children:m.jsxs("div",{className:"bg-white p-6 rounded-lg shadow-xl w-full max-w-md",onClick:g=>g.stopPropagation(),children:[m.jsx("h3",{className:"text-xl font-semibold mb-4 text-gray-800",children:"Edit Alert"}),m.jsxs("div",{className:"space-y-4",children:[m.jsxs("div",{children:[m.jsx("label",{htmlFor:"title",className:"block text-sm font-medium text-gray-700 mb-1",children:"Title"}),m.jsx("input",{type:"text",id:"title",defaultValue:o,onBlur:g=>e({title:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"message",className:"block text-sm font-medium text-gray-700 mb-1",children:"Message"}),m.jsx("textarea",{id:"message",defaultValue:l,onBlur:g=>e({message:g.target.value}),rows:3,className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"type",className:"block text-sm font-medium text-gray-700 mb-1",children:"Type"}),m.jsxs("select",{id:"type",defaultValue:i,onChange:g=>e({type:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"info",children:"Info"}),m.jsx("option",{value:"warning",children:"Warning"}),m.jsx("option",{value:"error",children:"Error"}),m.jsx("option",{value:"success",children:"Success"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"align",className:"block text-sm font-medium text-gray-700 mb-1",children:"Alignment"}),m.jsxs("select",{id:"align",defaultValue:a,onChange:g=>e({align:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"left",children:"Left"}),m.jsx("option",{value:"center",children:"Center"}),m.jsx("option",{value:"right",children:"Right"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"size",className:"block text-sm font-medium text-gray-700 mb-1",children:"Size"}),m.jsxs("select",{id:"size",defaultValue:c,onChange:g=>e({size:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"small",children:"Small"}),m.jsx("option",{value:"medium",children:"Medium"}),m.jsx("option",{value:"large",children:"Large"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"textAlign",className:"block text-sm font-medium text-gray-700 mb-1",children:"Text Alignment"}),m.jsxs("select",{id:"textAlign",defaultValue:d,onChange:g=>e({textAlign:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"left",children:"Left"}),m.jsx("option",{value:"center",children:"Center"}),m.jsx("option",{value:"right",children:"Right"})]})]})]}),m.jsx("div",{className:"mt-6 flex justify-end",children:m.jsx("button",{onClick:()=>s(!1),className:"px-4 py-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500",children:"Done"})})]})})]})},qx=De.create({name:"alertWidget",group:"block",atom:!0,draggable:!0,defining:!0,addAttributes(){return{type:{default:"info",parseHTML:t=>t.getAttribute("data-type"),renderHTML:t=>({"data-type":t.type})},title:{default:"Alert",parseHTML:t=>t.getAttribute("data-title"),renderHTML:t=>({"data-title":t.title})},message:{default:"This is an alert message.",parseHTML:t=>t.getAttribute("data-message"),renderHTML:t=>({"data-message":t.message})},align:{default:"center",parseHTML:t=>t.getAttribute("data-align"),renderHTML:t=>({"data-align":t.align})},size:{default:"medium",parseHTML:t=>t.getAttribute("data-size"),renderHTML:t=>({"data-size":t.size})},textAlign:{default:"left",parseHTML:t=>t.getAttribute("data-text-align"),renderHTML:t=>({"data-text-align":t.textAlign})}}},parseHTML(){return[{tag:"div[data-alert-widget]",priority:52}]},renderHTML({HTMLAttributes:t}){return["div",be(t,{"data-alert-widget":""})]},addNodeView(){return ju(xL)},addCommands(){return{setAlertWidget:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}}),wL=({node:t,updateAttributes:e,editor:n})=>{const[r,s]=C.useState(!1),{text:i,url:o,style:l,size:a,textAlign:c}=t.attrs,d={primary:"bg-primary text-primary-foreground hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80"},u={"fit-content":"w-auto","full-width":"w-full"},h={left:"text-left",center:"text-center",right:"text-right"};return m.jsxs(Iu,{children:[m.jsx("div",{className:`p-2 ${h[c]||h.left} cursor-grab`,"data-drag-handle":!0,onClick:()=>s(!0),children:m.jsx("div",{role:"button",tabIndex:0,className:`inline-block px-4 py-2 rounded-md ${d[l]} ${u[a]||u["fit-content"]}`,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),s(!0))},children:i})}),r&&m.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center",onClick:()=>s(!1),children:m.jsxs("div",{className:"bg-white p-6 rounded-lg shadow-xl w-full max-w-md",onClick:f=>f.stopPropagation(),children:[m.jsx("h3",{className:"text-xl font-semibold mb-4 text-gray-800",children:"Edit CTA Button"}),m.jsxs("div",{className:"space-y-4",children:[m.jsxs("div",{children:[m.jsx("label",{htmlFor:"text",className:"block text-sm font-medium text-gray-700 mb-1",children:"Button Text"}),m.jsx("input",{type:"text",id:"text",defaultValue:i,onBlur:f=>e({text:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"url",className:"block text-sm font-medium text-gray-700 mb-1",children:"URL"}),m.jsx("input",{type:"text",id:"url",defaultValue:o,onBlur:f=>e({url:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"style",className:"block text-sm font-medium text-gray-700 mb-1",children:"Style"}),m.jsxs("select",{id:"style",defaultValue:l,onChange:f=>e({style:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"primary",children:"Primary"}),m.jsx("option",{value:"secondary",children:"Secondary"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"size",className:"block text-sm font-medium text-gray-700 mb-1",children:"Size"}),m.jsxs("select",{id:"size",defaultValue:a,onChange:f=>e({size:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"fit-content",children:"Fit Content"}),m.jsx("option",{value:"full-width",children:"Full Width"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"textAlign",className:"block text-sm font-medium text-gray-700 mb-1",children:"Text Alignment"}),m.jsxs("select",{id:"textAlign",defaultValue:c,onChange:f=>e({textAlign:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"left",children:"Left"}),m.jsx("option",{value:"center",children:"Center"}),m.jsx("option",{value:"right",children:"Right"})]})]})]}),m.jsx("div",{className:"mt-6 flex justify-end",children:m.jsx("button",{onClick:()=>s(!1),className:"px-4 py-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500",children:"Done"})})]})})]})},Kx=De.create({name:"ctaWidget",group:"block",draggable:!0,atom:!0,defining:!0,addAttributes(){return{text:{default:"Click Here",parseHTML:t=>t.getAttribute("data-text"),renderHTML:t=>({"data-text":t.text})},url:{default:"#",parseHTML:t=>t.getAttribute("data-url"),renderHTML:t=>({"data-url":t.url})},style:{default:"primary",parseHTML:t=>t.getAttribute("data-style"),renderHTML:t=>({"data-style":t.style})},size:{default:"fit-content",parseHTML:t=>t.getAttribute("data-size"),renderHTML:t=>({"data-size":t.size})},textAlign:{default:"left",parseHTML:t=>t.getAttribute("data-text-align"),renderHTML:t=>({"data-text-align":t.textAlign})}}},parseHTML(){return[{tag:"div[data-cta-widget]",priority:52}]},renderHTML({HTMLAttributes:t}){return["div",be(t,{"data-cta-widget":""})]},addNodeView(){return ju(wL)},addCommands(){return{setCtaWidget:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}});function kL(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:l}=t,a=r&&!s,c=iE(n),d=new RegExp(`\\s${c}$`),u=o?"^":"",h=s?"":c,f=a?new RegExp(`${u}${c}.*?(?=\\s${h}|$)`,"gm"):new RegExp(`${u}(?:^)?${c}[^\\s${h}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const g=l.pos-p.length,y=Array.from(p.matchAll(f)).pop();if(!y||y.input===void 0||y.index===void 0)return null;const b=y.input.slice(Math.max(0,y.index-1),y.index),w=new RegExp(`^[${i?.join("")}\0]?$`).test(b);if(i!==null&&!w)return null;const M=g+y.index;let S=M+y[0].length;return a&&d.test(p.slice(S-1,S+1))&&(y[0]+=" ",S+=1),M<l.pos&&S>=l.pos?{range:{from:M,to:S},query:y[0].slice(n.length),text:y[0]}:null}var vL=new ge("suggestion");function SL({pluginKey:t=vL,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:i=[" "],startOfLine:o=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:d="is-empty",command:u=()=>null,items:h=()=>[],render:f=()=>({}),allow:p=()=>!0,findSuggestionMatch:g=kL}){let y;const b=f?.(),w=()=>{const x=e.state.selection.$anchor.pos,k=e.view.coordsAtPos(x),{top:v,right:T,bottom:N,left:H}=k;try{return new DOMRect(H,v,T-H,N-v)}catch{return null}},M=(x,k)=>k?()=>{const v=t.getState(e.state),T=v?.decorationId,N=x.dom.querySelector(`[data-decoration-id="${T}"]`);return N?.getBoundingClientRect()||null}:w;function S(x,k){var v;try{const N=t.getState(x.state),H=N?.decorationId?x.dom.querySelector(`[data-decoration-id="${N.decorationId}"]`):null,V={editor:e,range:N?.range||{from:0,to:0},query:N?.query||null,text:N?.text||null,items:[],command:$=>u({editor:e,range:N?.range||{from:0,to:0},props:$}),decorationNode:H,clientRect:M(x,H)};(v=b?.onExit)==null||v.call(b,V)}catch{}const T=x.state.tr.setMeta(k,{exit:!0});x.dispatch(T)}const A=new pe({key:t,view(){return{update:async(x,k)=>{var v,T,N,H,V,$,I;const j=(v=this.key)==null?void 0:v.getState(k),Q=(T=this.key)==null?void 0:T.getState(x.state),ie=j.active&&Q.active&&j.range.from!==Q.range.from,F=!j.active&&Q.active,ue=j.active&&!Q.active,xe=!F&&!ue&&j.query!==Q.query,_=F||ie&&xe,Z=xe||ie,fe=ue||ie&&xe;if(!_&&!Z&&!fe)return;const Se=fe&&!_?j:Q,pn=x.dom.querySelector(`[data-decoration-id="${Se.decorationId}"]`);y={editor:e,range:Se.range,query:Se.query,text:Se.text,items:[],command:fr=>u({editor:e,range:Se.range,props:fr}),decorationNode:pn,clientRect:M(x,pn)},_&&((N=b?.onBeforeStart)==null||N.call(b,y)),Z&&((H=b?.onBeforeUpdate)==null||H.call(b,y)),(Z||_)&&(y.items=await h({editor:e,query:Se.query})),fe&&((V=b?.onExit)==null||V.call(b,y)),Z&&(($=b?.onUpdate)==null||$.call(b,y)),_&&((I=b?.onStart)==null||I.call(b,y))},destroy:()=>{var x;y&&((x=b?.onExit)==null||x.call(b,y))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(x,k,v,T){const{isEditable:N}=e,{composing:H}=e.view,{selection:V}=x,{empty:$,from:I}=V,j={...k},Q=x.getMeta(t);if(Q&&Q.exit)return j.active=!1,j.decorationId=null,j.range={from:0,to:0},j.query=null,j.text=null,j;if(j.composing=H,N&&($||e.view.composing)){(I<k.range.from||I>k.range.to)&&!H&&!k.composing&&(j.active=!1);const ie=g({char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:V.$from}),F=`id_${Math.floor(Math.random()*4294967295)}`;ie&&p({editor:e,state:T,range:ie.range,isActive:k.active})?(j.active=!0,j.decorationId=k.decorationId?k.decorationId:F,j.range=ie.range,j.query=ie.query,j.text=ie.text):j.active=!1}else j.active=!1;return j.active||(j.decorationId=null,j.range={from:0,to:0},j.query=null,j.text=null),j}},props:{handleKeyDown(x,k){var v,T,N,H;const{active:V,range:$}=A.getState(x.state);if(!V)return!1;if(k.key==="Escape"||k.key==="Esc"){const j=A.getState(x.state),Q=(v=y?.decorationNode)!=null?v:null,ie=Q??(j?.decorationId?x.dom.querySelector(`[data-decoration-id="${j.decorationId}"]`):null);if(((T=b?.onKeyDown)==null?void 0:T.call(b,{view:x,event:k,range:j.range}))||!1)return!0;const ue={editor:e,range:j.range,query:j.query,text:j.text,items:[],command:xe=>u({editor:e,range:j.range,props:xe}),decorationNode:ie,clientRect:ie?()=>ie.getBoundingClientRect()||null:null};return(N=b?.onExit)==null||N.call(b,ue),S(x,t),!0}return((H=b?.onKeyDown)==null?void 0:H.call(b,{view:x,event:k,range:$}))||!1},decorations(x){const{active:k,range:v,decorationId:T,query:N}=A.getState(x);if(!k)return null;const H=!N?.length,V=[a];return H&&V.push(d),ye.create(x.doc,[_e.inline(v.from,v.to,{nodeName:l,class:V.join(" "),"data-decoration-id":T,"data-decoration-content":c})])}}});return A}const CL=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),EL=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),jm=t=>{const e=EL(t);return e.charAt(0).toUpperCase()+e.slice(1)},Gx=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),ML=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var AL={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const TL=C.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:i,iconNode:o,...l},a)=>C.createElement("svg",{ref:a,...AL,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:Gx("lucide",s),...!i&&!ML(l)&&{"aria-hidden":"true"},...l},[...o.map(([c,d])=>C.createElement(c,d)),...Array.isArray(i)?i:[i]]));const X=(t,e)=>{const n=C.forwardRef(({className:r,...s},i)=>C.createElement(TL,{ref:i,iconNode:e,className:Gx(`lucide-${CL(jm(t))}`,`lucide-${t}`,r),...s}));return n.displayName=jm(t),n};const NL=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],Gl=X("bold",NL);const _L=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Pm=X("circle-alert",_L);const RL=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],OL=X("circle-check-big",RL);const DL=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],LL=X("circle-plus",DL);const IL=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],jL=X("circle-x",IL);const PL=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Nr=X("code-xml",PL);const BL=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],Rs=X("code",BL);const $L=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],HL=X("columns-2",$L);const zL=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],FL=X("columns-3",zL);const UL=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Jx=X("download",UL);const VL=[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]],WL=X("eraser",VL);const qL=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],KL=X("eye",qL);const GL=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],JL=X("file-code-2",GL);const YL=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],XL=X("hash",YL);const ZL=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],vs=X("heading-1",ZL);const QL=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],Vi=X("heading-2",QL);const eI=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],Aa=X("heading-3",eI);const tI=[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]],nI=X("heading-4",tI);const rI=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]],sI=X("heading-5",rI);const iI=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]],oI=X("heading-6",iI);const lI=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],zr=X("image",lI);const aI=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],kh=X("italic",aI);const cI=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Ta=X("link-2",cI);const dI=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],Wi=X("list-ordered",dI);const uI=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],Os=X("list",uI);const hI=[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]],Na=X("megaphone",hI);const fI=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],pI=X("menu",fI);const mI=[["path",{d:"M5 12h14",key:"1ays0h"}]],_a=X("minus",mI);const gI=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],vh=X("palette",gI);const yI=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],bI=X("play",yI);const xI=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],wI=X("redo-2",xI);const kI=[["path",{d:"M14 4a1 1 0 0 1 1-1",key:"dhj8ez"}],["path",{d:"M15 10a1 1 0 0 1-1-1",key:"1mnyi5"}],["path",{d:"M21 4a1 1 0 0 0-1-1",key:"sfs9ap"}],["path",{d:"M21 9a1 1 0 0 1-1 1",key:"mp6qeo"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a2 2 0 0 1 2-2h2",key:"15xut4"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}]],vI=X("replace",kI);const SI=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],CI=X("rotate-ccw",SI);const EI=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]],MI=X("rows-2",EI);const AI=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],TI=X("rows-3",AI);const NI=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],_I=X("search",NI);const RI=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ra=X("square-check-big",RI);const OI=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],Yx=X("strikethrough",OI);const DI=[["path",{d:"m4 5 8 8",key:"1eunvl"}],["path",{d:"m12 5-8 8",key:"1ah0jp"}],["path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07",key:"e8ta8j"}]],Xx=X("subscript",DI);const LI=[["path",{d:"m4 19 8-8",key:"hr47gm"}],["path",{d:"m12 19-8-8",key:"1dhhmo"}],["path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06",key:"1dfcux"}]],Zx=X("superscript",LI);const II=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],qi=X("table-2",II);const jI=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],PI=X("terminal",jI);const BI=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Ki=X("text-align-center",BI);const $I=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Gi=X("text-align-end",$I);const HI=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],Sh=X("text-align-justify",HI);const zI=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Ss=X("text-align-start",zI);const FI=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],Ji=X("text-quote",FI);const UI=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Qx=X("trash-2",UI);const VI=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Oa=X("triangle-alert",VI);const WI=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],Wr=X("type",WI);const qI=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Ch=X("underline",qI);const KI=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],GI=X("undo-2",KI);const JI=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],ew=X("video",JI);const YI=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],tw=X("x",YI),Eh=C.forwardRef(({items:t,command:e},n)=>{const[r,s]=C.useState(-1),i=C.useRef(null),o=a=>{const c=t[a];c&&e(c)};C.useEffect(()=>{if(t.length===0){s(-1);return}s(a=>{if(a===-1)return-1;const c=Math.min(Math.max(a,0),t.length-1);return Number.isFinite(c)?c:-1})},[t]),C.useEffect(()=>{if(!i.current||r===-1)return;const a=i.current.querySelector(`[data-index="${r}"]`);a&&a.scrollIntoView({block:"nearest"})},[r]),C.useImperativeHandle(n,()=>({onKeyDown:({event:a})=>t.length===0?!1:a.key==="ArrowUp"?(a.preventDefault(),s(c=>c===-1?t.length-1:(c-1+t.length)%t.length),!0):a.key==="ArrowDown"?(a.preventDefault(),s(c=>c===-1?0:(c+1)%t.length),!0):a.key==="Enter"?(a.preventDefault(),r!==-1&&o(r),!0):!1}));const l=a=>{a.stopPropagation()};return m.jsx("div",{ref:i,className:"z-50 max-h-72 w-72 overflow-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md",role:"listbox","aria-activedescendant":r!==-1?`cmd-opt-${r}`:void 0,tabIndex:-1,onWheel:l,style:{scrollbarWidth:"thin",scrollbarColor:"rgb(148 163 184) transparent"},children:t.length>0?t.map((a,c)=>{const d=r!==-1&&c===r;return m.jsxs("button",{id:`cmd-opt-${c}`,"data-index":c,role:"option","aria-selected":d,type:"button",onMouseDown:u=>u.preventDefault(),onClick:()=>o(c),className:Oe.cn("flex w-full items-center gap-2 rounded-sm p-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",d&&"bg-accent text-accent-foreground"),children:[m.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border bg-background",children:a.icon}),m.jsxs("div",{className:"min-w-0",children:[m.jsx("p",{className:"truncate font-medium",children:a.title}),a.description?m.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a.description}):null]})]},`${a.title}-${c}`)}):m.jsx("div",{className:"p-2 text-sm text-muted-foreground",children:"No results"})})});Eh.displayName="SlashCommandList";const XI=[{title:"Text",description:"Start writing with plain text.",icon:C.createElement(Wr,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).clearNodes().run()}},{title:"Heading 1",description:"Large section heading.",icon:C.createElement(vs,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:1}).run()}},{title:"Heading 2",description:"Medium section heading.",icon:C.createElement(Vi,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:2}).run()}},{title:"Heading 3",description:"Small section heading.",icon:C.createElement(Aa,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:3}).run()}},{title:"Heading 4",description:"Extra small section heading.",icon:C.createElement(nI,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:4}).run()}},{title:"Heading 5",description:"Tiny section heading.",icon:C.createElement(sI,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:5}).run()}},{title:"Heading 6",description:"Smallest section heading.",icon:C.createElement(oI,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:6}).run()}},{title:"Bullet List",description:"Create a simple bulleted list.",icon:C.createElement(Os,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBulletList().run()}},{title:"Numbered List",description:"Create a list with numbering.",icon:C.createElement(Wi,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleOrderedList().run()}},{title:"Task List",description:"Create a list with checkboxes.",icon:C.createElement(Ra,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleTaskList().run()}},{title:"Blockquote",description:"Create a quote or citation.",icon:C.createElement(Ji,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBlockquote().run()}},{title:"Code Block",description:"Create a code block with syntax highlighting.",icon:C.createElement(Rs,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleCodeBlock().run()}},{title:"Horizontal Rule",description:"Insert a horizontal divider.",icon:C.createElement(_a,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHorizontalRule().run()}},{title:"Image",description:"Insert an image from URL.",icon:C.createElement(zr,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{const n=window.prompt("Enter image URL:");n&&t.chain().focus().deleteRange(e).setImage({src:n}).run()}},{title:"Table",description:"Insert a table with rows and columns.",icon:C.createElement(qi,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{title:"Align Left",description:"Align text to the left.",icon:C.createElement(Ss,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("left").run()}},{title:"Align Center",description:"Center align text.",icon:C.createElement(Ki,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("center").run()}},{title:"Align Right",description:"Align text to the right.",icon:C.createElement(Gi,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("right").run()}},{title:"Justify",description:"Justify text alignment.",icon:C.createElement(Sh,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("justify").run()}},{title:"Video",description:"Embed a video from URL.",icon:C.createElement(ew,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{const n=window.prompt("Enter video URL (YouTube, Vimeo, etc.):");n&&t.chain().focus().deleteRange(e).insertContent(`<p><a href="${n}" target="_blank">Video: ${n}</a></p>`).run()}},{title:"Alert",description:"Insert an alert or notice.",icon:C.createElement(Oa,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.can().setAlertWidget()?t.chain().focus().deleteRange(e).setAlertWidget().run():t.chain().focus().deleteRange(e).toggleBlockquote().run()}},{title:"Call to Action",description:"Insert a call to action button.",icon:C.createElement(Na,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.can().setCtaWidget()?t.chain().focus().deleteRange(e).setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}).run():t.chain().focus().deleteRange(e).insertContent("Call to Action").run()}}],nw=de.create({name:"slashCommand",addOptions(){return{suggestion:{char:"/",allowSpaces:!1,allowedPrefixes:[" "],startOfLine:!1,decorationTag:"span",decorationClass:"slash-command"}}},addProseMirrorPlugins(){return[SL({char:"/",allowSpaces:!1,allowedPrefixes:[" "],startOfLine:!1,decorationTag:"span",decorationClass:"slash-command",editor:this.editor,items:({query:t})=>XI.filter(n=>n.title.toLowerCase().includes(t.toLowerCase())||n.description.toLowerCase().includes(t.toLowerCase())).slice(0,10),command:({editor:t,range:e,props:n})=>{n.command({editor:t,range:e})},render:()=>{let t=null,e=null,n=null;const r=i=>({getBoundingClientRect:()=>i()||new DOMRect(0,0,0,0)}),s=async i=>{if(!e)return;const o=r(i),{x:l,y:a}=await Fu(o,e,{placement:"bottom-start",middleware:[zu(6),Ab({fallbackPlacements:["top-start","bottom-start"]}),Mb({padding:8}),Tb({apply({availableWidth:c,availableHeight:d,elements:u}){Object.assign(u.floating.style,{maxWidth:`${Math.min(288,c-16)}px`,maxHeight:`${Math.min(288,d-16)}px`})}})],strategy:"fixed"});e.style.left=`${Math.round(l)}px`,e.style.top=`${Math.round(a)}px`};return{onStart:i=>{if(!i.clientRect)return;const o=i.clientRect;t=new pb(Eh,{props:i,editor:i.editor}),e=document.createElement("div"),e.style.position="fixed",e.style.zIndex="10000",e.style.top="0",e.style.left="0",e.style.pointerEvents="none",e.appendChild(t.element),t.element.style.pointerEvents="auto",t.element.addEventListener("wheel",a=>{a.stopPropagation()},{passive:!0}),document.body.appendChild(e);const l=r(o);n=Ms(l,e,()=>s(o)),s(o)},onUpdate:i=>{t?.updateProps(i),i.clientRect&&s(i.clientRect)},onKeyDown:({event:i})=>i.key==="Escape"?!0:t?.ref?.onKeyDown({event:i})??!1,onExit:()=>{n?.(),n=null,t?.destroy(),t=null,e?.remove(),e=null}}}})]}});var ZI=Zu,QI=eh;NA.extend({draggable:!0});zM.extend({draggable:!0});AM.extend({draggable:!0});ZI.extend({draggable:!0});QI.extend({draggable:!0});h0.extend({draggable:!0});f0.extend({draggable:!0});d0.extend({draggable:!0});u0.extend({draggable:!0});const rw=de.create({name:"draggableNodes",addGlobalAttributes(){return[{types:["paragraph","heading","blockquote","bulletList","orderedList","taskList","taskItem","codeBlock","image"],attributes:{draggable:{default:!0,parseHTML:()=>!0,renderHTML:()=>({"data-draggable":"true"})}}}]}}),e2=De.create({name:"styleTag",group:"block",atom:!0,isolating:!0,defining:!0,draggable:!1,addAttributes(){return{cssContent:{default:"",parseHTML:t=>t.innerHTML},type:{default:"text/css",parseHTML:t=>t.getAttribute("type"),renderHTML:t=>t.type?{type:t.type}:{}},media:{default:null,parseHTML:t=>t.getAttribute("media"),renderHTML:t=>t.media?{media:t.media}:{}}}},parseHTML(){return[{tag:"style",getAttrs:t=>{const e=t,n={cssContent:e.innerHTML,type:e.getAttribute("type")},r=e.getAttribute("media");return r!==null&&(n.media=r),n}}]},renderHTML({HTMLAttributes:t,node:e}){const n={...t};return delete n.cssContent,["style",n,e.attrs.cssContent||""]},addNodeView(){return({node:t,editor:e,getPos:n})=>{const r=document.createElement("div");return r.setAttribute("data-style-node-placeholder","true"),r.style.border="1px dashed #999",r.style.padding="8px",r.style.margin="1rem 0",r.style.fontFamily="monospace",r.style.fontSize="0.9em",r.style.color="#555",r.style.cursor="pointer",r.textContent="[Custom CSS Block - Edit in Source View]",r.contentEditable="false",r.title="Click to open Source View",r.addEventListener("click",()=>{try{e?.chain().focus()}catch{}try{window.dispatchEvent(new CustomEvent("editor:openSourceView"))}catch{}}),{dom:r}}}}),t2=De.create({name:"divBlock",group:"block",content:"block*",defining:!0,draggable:!0,addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}},id:{default:null,parseHTML:t=>t.getAttribute("id"),renderHTML:t=>t.id?{id:t.id}:{}}}},parseHTML(){return[{tag:"div",priority:51,getAttrs:t=>{const e=t,n={};for(let r=0;r<e.attributes.length;r++){const s=e.attributes[r];n[s.name]=s.value}return n}}]},renderHTML({node:t}){return["div",be(this.options.HTMLAttributes,t.attrs),0]}}),n2=de.create({name:"preserveAllAttributesExtension",addGlobalAttributes(){return[{types:["paragraph","heading","listItem","blockquote","codeBlock","bulletList","orderedList","textStyle"],attributes:{style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}},class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},id:{default:null,parseHTML:t=>t.getAttribute("id"),renderHTML:t=>t.id?{id:t.id}:{}},dataAttributes:{default:null,parseHTML:t=>{const e={};for(let n=0;n<t.attributes.length;n++){const r=t.attributes[n];r.name.startsWith("data-")&&(e[r.name]=r.value)}return Object.keys(e).length>0?e:null},renderHTML:t=>t.dataAttributes||{}}}}]}}),r2=De.create({name:"scriptTag",group:"block",atom:!0,isolating:!0,defining:!0,draggable:!1,addAttributes(){return{jsContent:{default:"",parseHTML:t=>t.innerHTML},type:{default:"text/javascript",parseHTML:t=>t.getAttribute("type"),renderHTML:t=>t.type?{type:t.type}:{}},src:{default:null,parseHTML:t=>t.getAttribute("src"),renderHTML:t=>t.src?{src:t.src}:{}},async:{default:null,parseHTML:t=>t.getAttribute("async"),renderHTML:t=>t.async!=null?{async:""}:{}},defer:{default:null,parseHTML:t=>t.getAttribute("defer"),renderHTML:t=>t.defer!=null?{defer:""}:{}}}},parseHTML(){return[{tag:"script",getAttrs:t=>{const e=t,n={jsContent:e.innerHTML,type:e.getAttribute("type")},r=e.getAttribute("src");return r!==null&&(n.src=r),e.hasAttribute("async")&&(n.async=""),e.hasAttribute("defer")&&(n.defer=""),n}}]},renderHTML({HTMLAttributes:t,node:e}){const n={...t};return delete n.jsContent,["script",n,e.attrs.src?"":e.attrs.jsContent||""]},addNodeView(){return({editor:t})=>{const e=document.createElement("div");return e.setAttribute("data-script-node-placeholder","true"),e.style.border="1px dashed #999",e.style.padding="8px",e.style.margin="1rem 0",e.style.fontFamily="monospace",e.style.fontSize="0.9em",e.style.color="#555",e.style.cursor="pointer",e.textContent="[Custom JavaScript Block - Edit in Source View]",e.contentEditable="false",e.title="Click to open Source View",e.addEventListener("click",()=>{try{t?.chain().focus()}catch{}try{window.dispatchEvent(new CustomEvent("editor:openSourceView"))}catch{}}),{dom:e}}}}),s2=pL({html:hL,css:tL,js:oL,ts:uL,python:aL,json:lL,bash:qD,sql:cL}),Bm="http://www.w3.org/2000/svg";function $m(t){const e=document.createElementNS(Bm,"svg");return e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor"),e.classList.add("tiptap-drag-handle__icon","tiptap-drag-handle__icon--filled"),t.forEach(n=>{const r=document.createElementNS(Bm,"path");r.setAttribute("d",n),e.appendChild(r)}),e}const Mh=[sT.configure({codeBlock:!1,link:!1,undoRedo:!1,bulletList:{HTMLAttributes:{class:"list-disc pl-4"},keepMarks:!0,keepAttributes:!1},orderedList:{HTMLAttributes:{class:"list-decimal pl-4"},keepMarks:!0,keepAttributes:!1},dropcursor:{color:"#60A5FA",width:2},gapcursor:!1}),bA.configure({openOnClick:!1,autolink:!0,defaultProtocol:"https",protocols:["http","https","ftp","mailto"],validate:t=>/^https?:\/\//.test(t),HTMLAttributes:{class:"text-primary underline underline-offset-2 hover:text-primary/80 cursor-pointer",rel:"noopener noreferrer",target:"_blank"}}),p_,LA,m_.configure({depth:100,newGroupDelay:500}),d0.configure({lowlight:s2,defaultLanguage:"plaintext",HTMLAttributes:{class:"relative rounded-md bg-muted p-4 font-mono text-sm"}}),t2,e2,r2,n2,pT.configure({inline:!0,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-md"}}),h0.configure({HTMLAttributes:{class:"list-none pl-0 space-y-1"}}),f0.configure({nested:!0,HTMLAttributes:{class:"flex items-start gap-2 my-1"}}),M0.configure({resizable:!0,cellMinWidth:100,HTMLAttributes:{class:"w-full border-collapse border border-gray-300 dark:border-gray-700 my-4"}}),kN.configure({HTMLAttributes:{class:"border-b border-gray-300 dark:border-gray-700"}}),vN.configure({HTMLAttributes:{class:"bg-gray-100 dark:bg-gray-800 font-bold p-3 text-left border border-gray-300 dark:border-gray-700"}}),SN.configure({HTMLAttributes:{class:"p-3 border border-gray-300 dark:border-gray-700 min-w-[100px]"}}),FN.configure({color:{types:["textStyle"]},fontFamily:{types:["textStyle"]},fontSize:{types:["textStyle"]}}),AN.configure({multicolor:!0,HTMLAttributes:{class:"rounded-sm px-1 py-0.5"}}),NN,RN,DN.configure({types:["heading","paragraph","div"],alignments:["left","center","right","justify"],defaultAlignment:"left"}),f_,Wx,UN.configure({limit:5e4,mode:"textSize"}),Vx,qx,Kx,nw,rw,LD,WD.configure({computePositionConfig:{placement:"left-start",strategy:"absolute",middleware:[zu({mainAxis:5,crossAxis:0})]},onElementDragStart:()=>{typeof document<"u"&&document.body.classList.add("dragging")},onElementDragEnd:()=>{typeof document<"u"&&document.body.classList.remove("dragging")},onNodeChange:({editor:t})=>{},render(){const t=document.createElement("div");t.classList.add("drag-handle","tiptap-drag-handle"),typeof window<"u"&&(window.__dragHandleElement=t);const e=document.createElement("div");e.classList.add("tiptap-drag-handle__group"),e.setAttribute("role","group"),e.dataset.orientation="horizontal",t.appendChild(e);const n=document.createElement("button");n.type="button",n.classList.add("tiptap-drag-handle__button","tiptap-drag-handle__button--ghost","tiptap-drag-handle__plus"),n.setAttribute("aria-label","Insert block"),n.setAttribute("title","Insert block");const r=$m(["M13 5C13 4.44772 12.5523 4 12 4C11.4477 4 11 4.44772 11 5V11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H11V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V13H19C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11H13V5Z"]);n.appendChild(r),e.appendChild(n);const s=document.createElement("button");s.type="button",s.classList.add("tiptap-drag-handle__button","tiptap-drag-handle__button--ghost","tiptap-drag-handle__grip"),s.setAttribute("aria-label","Drag to reorder"),s.setAttribute("title","Drag to reorder"),s.setAttribute("tabindex","0"),s.setAttribute("aria-haspopup","menu"),s.setAttribute("aria-expanded","false");const i=$m(["M9 3C7.89543 3 7 3.89543 7 5C7 6.10457 7.89543 7 9 7C10.1046 7 11 6.10457 11 5C11 3.89543 10.1046 3 9 3Z","M9 10C7.89543 10 7 10.8954 7 12C7 13.1046 7.89543 14 9 14C10.1046 14 11 13.1046 11 12C11 10.8954 10.1046 10 9 10Z","M7 19C7 17.8954 7.89543 17 9 17C10.1046 17 11 17.8954 11 19C11 20.1046 10.1046 21 9 21C7.89543 21 7 20.1046 7 19Z","M15 10C13.8954 10 13 10.8954 13 12C13 13.1046 13.8954 14 15 14C16.1046 14 17 13.1046 17 12C17 10.8954 16.1046 10 15 10Z","M13 5C13 3.89543 13.8954 3 15 3C16.1046 3 17 3.89543 17 5C17 6.10457 16.1046 7 15 7C13.8954 7 13 6.10457 13 5Z","M15 17C13.8954 17 13 17.8954 13 19C13 20.1046 13.8954 21 15 21C16.1046 21 17 20.1046 17 19C17 17.8954 16.1046 17 15 17Z"]);s.appendChild(i),e.appendChild(s);const o=()=>{const l=new CustomEvent("tiptap-gutter-toggle",{bubbles:!0,detail:{handle:e,button:n}});e.dispatchEvent(l)};return n.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),o()}),n.addEventListener("keydown",l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),o())}),s.addEventListener("mousedown",()=>{s.setAttribute("aria-expanded","true")}),s.addEventListener("mouseup",()=>{s.setAttribute("aria-expanded","false")}),t}})];var i2=typeof document<"u",o2=function(){},qd=i2?C.useLayoutEffect:o2;const l2={...ne},a2=l2.useInsertionEffect,c2=a2||(t=>t());function d2(t){const e=ne.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return c2(()=>{e.current=t}),ne.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return e.current==null?void 0:e.current(...r)},[])}var u2=typeof document<"u",h2=function(){},Wo=u2?C.useLayoutEffect:h2;function Jl(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,s;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!Jl(t[r],e[r]))return!1;return!0}if(s=Object.keys(t),n=s.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,s[r]))return!1;for(r=n;r--!==0;){const i=s[r];if(!(i==="_owner"&&t.$$typeof)&&!Jl(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function sw(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Hm(t,e){const n=sw(t);return Math.round(e*n)/n}function Bc(t){const e=ne.useRef(t);return Wo(()=>{e.current=t}),e}function f2(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:o}={},transform:l=!0,whileElementsMounted:a,open:c}=t,[d,u]=ne.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[h,f]=ne.useState(r);Jl(h,r)||f(r);const[p,g]=ne.useState(null),[y,b]=ne.useState(null),w=ne.useCallback(F=>{F!==x.current&&(x.current=F,g(F))},[]),M=ne.useCallback(F=>{F!==k.current&&(k.current=F,b(F))},[]),S=i||p,A=o||y,x=ne.useRef(null),k=ne.useRef(null),v=ne.useRef(d),T=a!=null,N=Bc(a),H=Bc(s),V=Bc(c),$=ne.useCallback(()=>{if(!x.current||!k.current)return;const F={placement:e,strategy:n,middleware:h};H.current&&(F.platform=H.current),Fu(x.current,k.current,F).then(ue=>{const xe={...ue,isPositioned:V.current!==!1};I.current&&!Jl(v.current,xe)&&(v.current=xe,c1.flushSync(()=>{u(xe)}))})},[h,e,n,H,V]);Wo(()=>{c===!1&&v.current.isPositioned&&(v.current.isPositioned=!1,u(F=>({...F,isPositioned:!1})))},[c]);const I=ne.useRef(!1);Wo(()=>(I.current=!0,()=>{I.current=!1}),[]),Wo(()=>{if(S&&(x.current=S),A&&(k.current=A),S&&A){if(N.current)return N.current(S,A,$);$()}},[S,A,$,N,T]);const j=ne.useMemo(()=>({reference:x,floating:k,setReference:w,setFloating:M}),[w,M]),Q=ne.useMemo(()=>({reference:S,floating:A}),[S,A]),ie=ne.useMemo(()=>{const F={position:n,left:0,top:0};if(!Q.floating)return F;const ue=Hm(Q.floating,d.x),xe=Hm(Q.floating,d.y);return l?{...F,transform:"translate("+ue+"px, "+xe+"px)",...sw(Q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:ue,top:xe}},[n,l,Q.floating,d.x,d.y]);return ne.useMemo(()=>({...d,update:$,refs:j,elements:Q,floatingStyles:ie}),[d,$,j,Q,ie])}const Yi=(t,e)=>({...zu(t),options:[t,e]}),Da=(t,e)=>({...Mb(t),options:[t,e]}),La=(t,e)=>({...Ab(t),options:[t,e]}),p2=(t,e)=>({...Tb(t),options:[t,e]}),m2={...ne};let zm=!1,g2=0;const Fm=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+g2++;function y2(){const[t,e]=ne.useState(()=>zm?Fm():void 0);return qd(()=>{t==null&&e(Fm())},[]),ne.useEffect(()=>{zm=!0},[]),t}const b2=m2.useId,x2=b2||y2;let Kd;process.env.NODE_ENV!=="production"&&(Kd=new Set);function w2(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((t=Kd)!=null&&t.has(s))){var i;(i=Kd)==null||i.add(s),console.error(s)}}function k2(){const t=new Map;return{emit(e,n){var r;(r=t.get(e))==null||r.forEach(s=>s(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var r;(r=t.get(e))==null||r.delete(n)}}}const v2=ne.createContext(null),S2=ne.createContext(null),C2=()=>{var t;return((t=ne.useContext(v2))==null?void 0:t.id)||null},E2=()=>ne.useContext(S2);function M2(t){const{open:e=!1,onOpenChange:n,elements:r}=t,s=x2(),i=ne.useRef({}),[o]=ne.useState(()=>k2()),l=C2()!=null;if(process.env.NODE_ENV!=="production"){const f=r.reference;f&&!ut(f)&&w2("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[a,c]=ne.useState(r.reference),d=d2((f,p,g)=>{i.current.openEvent=f?p:void 0,o.emit("openchange",{open:f,event:p,reason:g,nested:l}),n?.(f,p,g)}),u=ne.useMemo(()=>({setPositionReference:c}),[]),h=ne.useMemo(()=>({reference:a||r.reference||null,floating:r.floating||null,domReference:r.reference}),[a,r.reference,r.floating]);return ne.useMemo(()=>({dataRef:i,open:e,onOpenChange:d,elements:h,events:o,floatingId:s,refs:u}),[e,d,h,o,s,u])}function Xi(t){t===void 0&&(t={});const{nodeId:e}=t,n=M2({...t,elements:{reference:null,floating:null,...t.elements}}),r=t.rootContext||n,s=r.elements,[i,o]=ne.useState(null),[l,a]=ne.useState(null),d=s?.domReference||i,u=ne.useRef(null),h=E2();qd(()=>{d&&(u.current=d)},[d]);const f=f2({...t,elements:{...s,...l&&{reference:l}}}),p=ne.useCallback(M=>{const S=ut(M)?{getBoundingClientRect:()=>M.getBoundingClientRect(),getClientRects:()=>M.getClientRects(),contextElement:M}:M;a(S),f.refs.setReference(S)},[f.refs]),g=ne.useCallback(M=>{(ut(M)||M===null)&&(u.current=M,o(M)),(ut(f.refs.reference.current)||f.refs.reference.current===null||M!==null&&!ut(M))&&f.refs.setReference(M)},[f.refs]),y=ne.useMemo(()=>({...f.refs,setReference:g,setPositionReference:p,domReference:u}),[f.refs,g,p]),b=ne.useMemo(()=>({...f.elements,domReference:d}),[f.elements,d]),w=ne.useMemo(()=>({...f,...r,refs:y,elements:b,nodeId:e}),[f,y,b,e,r]);return qd(()=>{r.dataRef.current.floatingContext=w;const M=h?.nodesRef.current.find(S=>S.id===e);M&&(M.context=w)}),ne.useMemo(()=>({...f,context:w,refs:y,elements:b}),[f,y,b,w])}const A2="_pickerRoot_1wq30_1",T2="_picker_1wq30_1",Um={pickerRoot:A2,picker:T2};function Ia(){return(Ia=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function iw(t,e){if(t==null)return{};var n,r,s={},i=Object.keys(t);for(r=0;r<i.length;r++)e.indexOf(n=i[r])>=0||(s[n]=t[n]);return s}function Gd(t){var e=C.useRef(t),n=C.useRef(function(r){e.current&&e.current(r)});return e.current=t,n.current}var _i=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t<e?e:t},ni=function(t){return"touches"in t},Jd=function(t){return t&&t.ownerDocument.defaultView||self},Vm=function(t,e,n){var r=t.getBoundingClientRect(),s=ni(e)?(function(i,o){for(var l=0;l<i.length;l++)if(i[l].identifier===o)return i[l];return i[0]})(e.touches,n):e;return{left:_i((s.pageX-(r.left+Jd(t).pageXOffset))/r.width),top:_i((s.pageY-(r.top+Jd(t).pageYOffset))/r.height)}},Wm=function(t){!ni(t)&&t.preventDefault()},ow=C.memo(function(t){var e=t.onMove,n=t.onKey,r=iw(t,["onMove","onKey"]),s=C.useRef(null),i=Gd(e),o=Gd(n),l=C.useRef(null),a=C.useRef(!1),c=C.useMemo(function(){var f=function(y){Wm(y),(ni(y)?y.touches.length>0:y.buttons>0)&&s.current?i(Vm(s.current,y,l.current)):g(!1)},p=function(){return g(!1)};function g(y){var b=a.current,w=Jd(s.current),M=y?w.addEventListener:w.removeEventListener;M(b?"touchmove":"mousemove",f),M(b?"touchend":"mouseup",p)}return[function(y){var b=y.nativeEvent,w=s.current;if(w&&(Wm(b),!(function(S,A){return A&&!ni(S)})(b,a.current)&&w)){if(ni(b)){a.current=!0;var M=b.changedTouches||[];M.length&&(l.current=M[0].identifier)}w.focus(),i(Vm(w,b,l.current)),g(!0)}},function(y){var b=y.which||y.keyCode;b<37||b>40||(y.preventDefault(),o({left:b===39?.05:b===37?-.05:0,top:b===40?.05:b===38?-.05:0}))},g]},[o,i]),d=c[0],u=c[1],h=c[2];return C.useEffect(function(){return h},[h]),C.createElement("div",Ia({},r,{onTouchStart:d,onMouseDown:d,className:"react-colorful__interactive",ref:s,onKeyDown:u,tabIndex:0,role:"slider"}))}),Ah=function(t){return t.filter(Boolean).join(" ")},lw=function(t){var e=t.color,n=t.left,r=t.top,s=r===void 0?.5:r,i=Ah(["react-colorful__pointer",t.className]);return C.createElement("div",{className:i,style:{top:100*s+"%",left:100*n+"%"}},C.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:e}}))},ot=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n},N2=function(t){return L2(Yd(t))},Yd=function(t){return t[0]==="#"&&(t=t.substring(1)),t.length<6?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?ot(parseInt(t[3]+t[3],16)/255,2):1}:{r:parseInt(t.substring(0,2),16),g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16),a:t.length===8?ot(parseInt(t.substring(6,8),16)/255,2):1}},_2=function(t){return D2(O2(t))},R2=function(t){var e=t.s,n=t.v,r=t.a,s=(200-e)*n/100;return{h:ot(t.h),s:ot(s>0&&s<200?e*n/100/(s<=100?s:200-s)*100:0),l:ot(s/2),a:ot(r,2)}},Xd=function(t){var e=R2(t);return"hsl("+e.h+", "+e.s+"%, "+e.l+"%)"},O2=function(t){var e=t.h,n=t.s,r=t.v,s=t.a;e=e/360*6,n/=100,r/=100;var i=Math.floor(e),o=r*(1-n),l=r*(1-(e-i)*n),a=r*(1-(1-e+i)*n),c=i%6;return{r:ot(255*[r,l,o,o,a,r][c]),g:ot(255*[a,r,r,l,o,o][c]),b:ot(255*[o,o,a,r,r,l][c]),a:ot(s,2)}},Ro=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},D2=function(t){var e=t.r,n=t.g,r=t.b,s=t.a,i=s<1?Ro(ot(255*s)):"";return"#"+Ro(e)+Ro(n)+Ro(r)+i},L2=function(t){var e=t.r,n=t.g,r=t.b,s=t.a,i=Math.max(e,n,r),o=i-Math.min(e,n,r),l=o?i===e?(n-r)/o:i===n?2+(r-e)/o:4+(e-n)/o:0;return{h:ot(60*(l<0?l+6:l)),s:ot(i?o/i*100:0),v:ot(i/255*100),a:s}},I2=C.memo(function(t){var e=t.hue,n=t.onChange,r=Ah(["react-colorful__hue",t.className]);return C.createElement("div",{className:r},C.createElement(ow,{onMove:function(s){n({h:360*s.left})},onKey:function(s){n({h:_i(e+360*s.left,0,360)})},"aria-label":"Hue","aria-valuenow":ot(e),"aria-valuemax":"360","aria-valuemin":"0"},C.createElement(lw,{className:"react-colorful__hue-pointer",left:e/360,color:Xd({h:e,s:100,v:100,a:1})})))}),j2=C.memo(function(t){var e=t.hsva,n=t.onChange,r={backgroundColor:Xd({h:e.h,s:100,v:100,a:1})};return C.createElement("div",{className:"react-colorful__saturation",style:r},C.createElement(ow,{onMove:function(s){n({s:100*s.left,v:100-100*s.top})},onKey:function(s){n({s:_i(e.s+100*s.left,0,100),v:_i(e.v-100*s.top,0,100)})},"aria-label":"Color","aria-valuetext":"Saturation "+ot(e.s)+"%, Brightness "+ot(e.v)+"%"},C.createElement(lw,{className:"react-colorful__saturation-pointer",top:1-e.v/100,left:e.s/100,color:Xd(e)})))}),aw=function(t,e){if(t===e)return!0;for(var n in t)if(t[n]!==e[n])return!1;return!0},P2=function(t,e){return t.toLowerCase()===e.toLowerCase()||aw(Yd(t),Yd(e))};function B2(t,e,n){var r=Gd(n),s=C.useState(function(){return t.toHsva(e)}),i=s[0],o=s[1],l=C.useRef({color:e,hsva:i});C.useEffect(function(){if(!t.equal(e,l.current.color)){var c=t.toHsva(e);l.current={hsva:c,color:e},o(c)}},[e,t]),C.useEffect(function(){var c;aw(i,l.current.hsva)||t.equal(c=t.fromHsva(i),l.current.color)||(l.current={hsva:i,color:c},r(c))},[i,t,r]);var a=C.useCallback(function(c){o(function(d){return Object.assign({},d,c)})},[]);return[i,a]}var $2=typeof window<"u"?C.useLayoutEffect:C.useEffect,H2=function(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0},qm=new Map,z2=function(t){$2(function(){var e=t.current?t.current.ownerDocument:document;if(e!==void 0&&!qm.has(e)){var n=e.createElement("style");n.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`,qm.set(e,n);var r=H2();r&&n.setAttribute("nonce",r),e.head.appendChild(n)}},[])},F2=function(t){var e=t.className,n=t.colorModel,r=t.color,s=r===void 0?n.defaultColor:r,i=t.onChange,o=iw(t,["className","colorModel","color","onChange"]),l=C.useRef(null);z2(l);var a=B2(n,s,i),c=a[0],d=a[1],u=Ah(["react-colorful",e]);return C.createElement("div",Ia({},o,{ref:l,className:u}),C.createElement(j2,{hsva:c,onChange:d}),C.createElement(I2,{hue:c.h,onChange:d,className:"react-colorful__last-control"}))},U2={defaultColor:"000",toHsva:N2,fromHsva:function(t){return _2({h:t.h,s:t.s,v:t.v,a:1})},equal:P2},V2=function(t){return C.createElement(F2,Ia({},t,{colorModel:U2}))};const Km="#1F2937",Gm="#FFF7D1",W2=["#FFF7D1","#FFEAE3","#DCFCE7","#DBEAFE"],q2=[{title:"Brand",colors:[{label:"Primary",value:"hsl(var(--primary))"},{label:"Secondary",value:"hsl(var(--secondary))"},{label:"Accent",value:"hsl(var(--accent))"},{label:"Ring",value:"hsl(var(--ring))"}]},{title:"Neutrals",colors:[{label:"Foreground",value:"hsl(var(--foreground))"},{label:"Muted",value:"hsl(var(--muted-foreground))"},{label:"Background",value:"hsl(var(--background))"},{label:"Card",value:"hsl(var(--card))"}]},{title:"States",colors:[{label:"Warning",value:"hsl(var(--warning))"},{label:"Destructive",value:"hsl(var(--destructive))"},{label:"Success",value:"hsl(var(--chart-2))"},{label:"Info",value:"hsl(var(--chart-5))"}]},{title:"Utility",colors:[{label:"Secondary FG",value:"hsl(var(--secondary-foreground))"},{label:"Accent FG",value:"hsl(var(--accent-foreground))"},{label:"Primary FG",value:"hsl(var(--primary-foreground))"},{label:"Border",value:"hsl(var(--border))"}]}],K2=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,G2=/^#[0-9a-f]{6}$/i,cw=/^rgba?\((\s*\d{1,3}\s*,){2}\s*\d{1,3}\s*(,\s*(0|1|0?\.\d+)\s*)?\)$/i,dw=/^hsla?\((\s*\d{1,3}\s*,)(\s*\d{1,3}%\s*,)\s*\d{1,3}%\s*(,\s*(0|1|0?\.\d+)\s*)?\)$/i;function Yl(t){const e=t.replace("#","").trim();return e.length===3||e.length===4?`#${e.split("").map(r=>r+r).join("").toUpperCase()}`:e.length===6||e.length===8?`#${e.toUpperCase()}`:t}function uw(t){const e=Yl(t).replace("#","");if(e.length!==6&&e.length!==8)return null;const n=parseInt(e.slice(0,2),16),r=parseInt(e.slice(2,4),16),s=parseInt(e.slice(4,6),16),i=e.length===8?parseInt(e.slice(6,8),16)/255:1;return{r:n,g:r,b:s,a:i}}function Zd(t,e,n){return`#${[t,e,n].map(r=>Math.max(0,Math.min(255,Math.round(r))).toString(16).padStart(2,"0")).join("").toUpperCase()}`}function ri(t,e=2){const n=10**e;return Math.round(t*n)/n}function si(t,e,n,r=1){const s=t/255,i=e/255,o=n/255,l=Math.max(s,i,o),a=Math.min(s,i,o);let c=0,d=0;const u=(l+a)/2;if(l!==a){const g=l-a;switch(d=u>.5?g/(2-l-a):g/(l+a),l){case s:c=(i-o)/g+(i<o?6:0);break;case i:c=(o-s)/g+2;break;case o:c=(s-i)/g+4;break}c/=6}const h=Math.round(c*360),f=Math.round(d*100),p=Math.round(u*100);return r!==1?`hsla(${h}, ${f}%, ${p}%, ${ri(r,2)})`:`hsl(${h}, ${f}%, ${p}%)`}function Jm(t){if(typeof window>"u"||typeof document>"u")return null;const e=document.createElement("span");if(e.style.color="",e.style.color=t,!e.style.color)return null;e.style.position="absolute",e.style.visibility="hidden",e.style.pointerEvents="none",document.body.appendChild(e);const n=getComputedStyle(e).color;document.body.removeChild(e);const r=n.match(/rgba?\(([^)]+)\)/i);if(!r)return null;const[s,i,o,l]=r[1].split(",").map(a=>a.trim()).map((a,c)=>c===3?parseFloat(a):parseInt(a,10));return[s,i,o].some(a=>Number.isNaN(a))?null:{r:s,g:i,b:o,a:typeof l=="number"&&!Number.isNaN(l)?l:1}}function Sn(t){if(!t)return null;const e=t.trim();if(K2.test(e)){const r=Yl(e),s=uw(r);if(!s)return null;const i=`#${r.replace("#","").slice(0,6)}`;return{source:r,hex:i,rgb:s.a===1?`rgb(${s.r}, ${s.g}, ${s.b})`:`rgba(${s.r}, ${s.g}, ${s.b}, ${ri(s.a,2)})`,hsl:si(s.r,s.g,s.b,s.a),alpha:s.a}}if(cw.test(e)||dw.test(e)){const r=Jm(e);return r?{source:e,hex:Zd(r.r,r.g,r.b),rgb:r.a===1?`rgb(${r.r}, ${r.g}, ${r.b})`:`rgba(${r.r}, ${r.g}, ${r.b}, ${ri(r.a,2)})`,hsl:si(r.r,r.g,r.b,r.a),alpha:r.a}:null}const n=Jm(e);return n?{source:e,hex:Zd(n.r,n.g,n.b),rgb:n.a===1?`rgb(${n.r}, ${n.g}, ${n.b})`:`rgba(${n.r}, ${n.g}, ${n.b}, ${ri(n.a,2)})`,hsl:si(n.r,n.g,n.b,n.a),alpha:n.a}:null}function hw(t){const e=uw(t);if(e)return{source:Yl(t),hex:Zd(e.r,e.g,e.b),rgb:e.a===1?`rgb(${e.r}, ${e.g}, ${e.b})`:`rgba(${e.r}, ${e.g}, ${e.b}, ${ri(e.a,2)})`,hsl:si(e.r,e.g,e.b,e.a),alpha:e.a};const n=Yl(t);return{source:n,hex:n.slice(0,7),rgb:"rgb(0, 0, 0)",hsl:si(0,0,0,1),alpha:1}}const $s=Sn(Km)??hw(Km),Ym=Sn(Gm)??hw(Gm);function fw({editor:t,className:e,initialMode:n="text"}){const r=C.useRef(null),[s,i]=C.useState(n),[o,l]=C.useState(null),[a,c]=C.useState($s),[d,u]=C.useState(Ym);C.useEffect(()=>{i(n)},[n]);const[h,f]=C.useState($s.hex),[p,g]=C.useState(!1),[y,b]=C.useState($s.rgb),[w,M]=C.useState(!1),[S,A]=C.useState($s.hsl),[x,k]=C.useState(!1),v=s==="text"?a:d;C.useEffect(()=>{const $=()=>{if(o)return;const I=t.getAttributes("textStyle").color,j=t.getAttributes("highlight").color,Q=Sn(I)??$s,ie=Sn(j)??Ym;c(Q),u(ie)};return $(),t.on("selectionUpdate",$),t.on("transaction",$),()=>{t.off("selectionUpdate",$),t.off("transaction",$)}},[t,o,s]),C.useEffect(()=>{o!=="hex"&&f(v.hex),o!=="rgb"&&b(v.rgb),o!=="hsl"&&A(v.hsl),o===null&&(g(!1),M(!1),k(!1))},[v,o]);const T=C.useCallback(($,I,j=!0)=>{const Q=t.chain();j&&Q.focus(),$==="text"?(c(I),Q.setColor(I.source).run()):(u(I),Q.setHighlight({color:I.source}).run())},[t,c,u]),N=C.useCallback(($,I)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{T($,I,!1)},300)},[T]),H=C.useCallback($=>{r.current&&clearTimeout(r.current);const I=Sn($);I&&(T(s,I,!1),g(!1))},[T,s,g]),V=C.useCallback($=>{r.current&&clearTimeout(r.current);const I=Sn($);I&&(T(s,I),g(!1))},[T,s,g]);return m.jsxs("div",{className:Oe.cn("flex w-full sm:w-auto flex-col gap-3 sm:gap-4",e),children:[m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsxs("div",{className:"inline-flex items-center gap-1 rounded-md bg-muted/60 p-1",children:[m.jsx(le.Button,{type:"button",variant:s==="text"?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs",onClick:()=>i("text"),children:"Text"}),m.jsx(le.Button,{type:"button",variant:s==="highlight"?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs",onClick:()=>i("highlight"),children:"Highlight"})]}),m.jsx("div",{className:"flex items-center",children:m.jsx(le.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>{s==="text"?t.chain().focus().unsetColor().run():t.chain().focus().unsetHighlight().run()},children:"Remove Color"})})]}),m.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:gap-4",children:[m.jsx("div",{className:Um.pickerRoot,children:m.jsx(V2,{color:v.hex,onChange:H,className:Um.picker})}),m.jsxs("div",{className:"flex w-full flex-col gap-2 text-[11px] sm:w-[150px]",children:[m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"HEX"}),m.jsx(ns.Input,{value:h,onFocus:()=>l("hex"),onChange:$=>{const I=$.target.value;if(f(I),G2.test(I)){const j=Sn(I);j&&(N(s,j),g(!1))}else g(!0)},onBlur:()=>{l(null),p&&(f(v.hex),g(!1))},spellCheck:!1,className:Oe.cn("h-8 w-full text-xs",p&&"border-destructive focus-visible:ring-destructive")})]}),m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"RGB"}),m.jsx(ns.Input,{value:y,onFocus:()=>l("rgb"),onChange:$=>{const I=$.target.value;if(b(I),cw.test(I)){const j=Sn(I);j&&(N(s,j),M(!1))}else M(!0)},onBlur:()=>{l(null),w&&(b(v.rgb),M(!1))},spellCheck:!1,className:Oe.cn("h-8 w-full text-xs",w&&"border-destructive focus-visible:ring-destructive")})]}),m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"HSL"}),m.jsx(ns.Input,{value:S,onFocus:()=>l("hsl"),onChange:$=>{const I=$.target.value;if(A(I),dw.test(I)){const j=Sn(I);j&&(N(s,j),k(!1))}else k(!0)},onBlur:()=>{l(null),x&&(A(v.hsl),k(!1))},spellCheck:!1,className:Oe.cn("h-8 w-full text-xs",x&&"border-destructive focus-visible:ring-destructive")})]})]})]}),m.jsxs("div",{className:"space-y-1.5",children:[m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Theme colors"}),m.jsx("div",{className:"space-y-1",children:q2.map($=>m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground/80",children:$.title}),m.jsx("div",{className:"flex items-center gap-1.5",children:$.colors.map(I=>m.jsx("button",{type:"button",onClick:()=>V(I.value),className:"h-6 w-6 rounded border border-border bg-background shadow-sm transition hover:border-primary/40 hover:shadow-sm",style:{background:I.value},"aria-label":`${$.title} color ${I.label}`,title:`${$.title} color ${I.label}`},I.label))})]},$.title))})]}),s==="highlight"?m.jsxs("div",{className:"space-y-2",children:[m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Highlight presets"}),m.jsx("div",{className:"flex flex-wrap gap-1.5",children:W2.map($=>m.jsxs("button",{type:"button",onClick:()=>V($),className:"flex items-center gap-1 rounded-full border bg-background px-2 py-1 text-[11px] shadow-sm transition hover:border-primary/40 hover:shadow-sm",children:[m.jsx("span",{className:"h-3.5 w-3.5 rounded-full border",style:{background:$},"aria-hidden":!0}),$]},$))})]}):null]})}const J2=["px","pt","rem","em","%"];function qo(t){if(!t)return null;const n=String(t).trim().match(/^(-?\d*\.?\d+)(px|pt|rem|em|%)$/i);if(!n)return null;const r=parseFloat(n[1]),s=n[2].toLowerCase();return Number.isFinite(r)?{value:r,unit:s}:null}function Qd(t){if(!t)return null;const{value:e,unit:n}=t;return n==="%"?`${Math.max(1,Math.round(e))}%`:n==="px"||n==="pt"?`${Math.max(1,Math.round(e))}${n}`:`${Math.max(.01,Math.round(e*100)/100)}${n}`}function Y2(t){const e=qo(t);return e?Qd(e):null}function X2(){if(typeof document>"u")return[];const t=[];try{const n=Array.from(document.styleSheets),r=[],s=[];for(const l of n){const a=l.href,c=l.ownerNode;`${a||""} ${c?.textContent||""}`.toLowerCase().includes("globals.css")?r.push(l):s.push(l)}const i=[...r,...s],o=new Set(["h1","h2","h3","h4","h5","h6"]);for(const l of i){let a=null;try{a=l.cssRules}catch{continue}if(a){for(const c of Array.from(a))if(c.style){const u=c.style.fontSize,h=c.selectorText;if(u&&h&&o.has(h)){const f=Y2(u)??u.trim();if(f){const p=parseInt(h.replace("h",""),10);t.push({level:p,value:f})}}}}}}catch{}const e=new Map;for(const n of t)e.has(n.level)||e.set(n.level,n.value);return Array.from(e.entries()).map(([n,r])=>({level:n,value:r}))}function Z2(t){if(typeof document>"u")return 0;try{const e=document.createElement("span");e.style.position="absolute",e.style.visibility="hidden",e.style.fontSize=t,document.body.appendChild(e);const n=parseFloat(getComputedStyle(e).fontSize);return document.body.removeChild(e),Number.isFinite(n)?n:0}catch{return 0}}function Xl(){if(typeof document>"u")return 16;try{const t=parseFloat(getComputedStyle(document.documentElement).fontSize);return Number.isFinite(t)&&t>0?t:16}catch{return 16}}function Th(t){try{const e=t.state.selection.from,n=t.view.domAtPos(e),r=n&&n.node||t.view.dom,s=r.nodeType===1?r:t.view.dom,i=parseFloat(getComputedStyle(s).fontSize);return Number.isFinite(i)&&i>0?i:Xl()}catch{return Xl()}}function Q2(t,e,n){const r=Xl(),s=Th(n);switch(e){case"px":return t;case"pt":return t*(96/72);case"rem":return t*r;case"em":return t*s;case"%":return t/100*s}}function ej(t,e,n){const r=Xl(),s=Th(n);switch(e){case"px":return t;case"pt":return t*(72/96);case"rem":return t/r;case"em":return t/s;case"%":return t/s*100}}function pw({editor:t,className:e}){const[n,r]=C.useState([]),[s,i]=C.useState(null),[o,l]=C.useState(""),[a,c]=C.useState("px"),[d,u]=C.useState(!1),h=C.useRef(null),f=C.useCallback(()=>{const S=t.getAttributes("textStyle").fontSize,A=qo(S);if(A)l(String(A.value)),c(A.unit),u(!1);else{if(S&&typeof S=="string"){const x=Z2(S);if(x>0&&!s){l(String(Math.round(x))),c("px"),u(!1);return}}s||(l(""),c("px"),u(!1))}},[t,s]);C.useEffect(()=>{f();const S=()=>f();return t.on("selectionUpdate",S),t.on("transaction",S),()=>{t.off("selectionUpdate",S),t.off("transaction",S)}},[t,f]),C.useEffect(()=>{r(X2())},[]);const p=C.useCallback((S,A=!0)=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{const x=t.chain();A&&x.focus(),x.setFontSize(S).run()},120)},[t]),g=C.useCallback(S=>{l(S);const A=`${S}${a}`,x=qo(A);if(x){u(!1);const k=Qd(x);k&&p(k,!1)}else u(S.trim().length>0)},[a,p]),y=C.useCallback(S=>{const A=a;c(S);let x=0;const k=parseFloat(o);Number.isFinite(k)?x=Q2(k,A,t):x=Th(t);const v=ej(x,S,t);let T;S==="px"||S==="pt"||S==="%"?T=String(Math.round(v)):T=String(Math.max(.01,Math.round(v*100)/100)),l(T);const N=Qd(qo(`${T}${S}`));N&&p(N)},[a,o,t,p]),b=C.useCallback(()=>{h.current&&clearTimeout(h.current),t.chain().focus().unsetFontSize().run(),u(!1)},[t]),w=C.useMemo(()=>a==="px"||a==="pt"||a==="%"?1:.01,[a]),M=C.useMemo(()=>{switch(a){case"%":return"100";case"px":return"16";case"pt":return"12";case"rem":return"1";case"em":return"1";default:return""}},[a]);return m.jsxs("div",{className:Oe.cn("space-y-3",e),onMouseDown:S=>S.stopPropagation(),children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(Wr,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Font size"})]}),m.jsxs(le.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:b,title:"Erase font size","aria-label":"Erase font size",children:[m.jsx(WL,{className:"h-3.5 w-3.5 mr-1"}),"Erase"]})]}),m.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-2 items-end",children:[m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"Value"}),m.jsx(ns.Input,{type:"number",inputMode:"decimal",step:w,placeholder:M,value:o,onFocus:()=>i("value"),onChange:S=>g(S.target.value),onBlur:()=>i(null),className:Oe.cn("h-9",d&&"border-destructive focus-visible:ring-destructive"),spellCheck:!1})]}),m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"Unit"}),m.jsx("div",{className:"flex gap-1",children:m.jsx("select",{value:a,onChange:S=>y(S.target.value),onFocus:()=>i("unit"),onBlur:()=>i(null),className:"h-9 w-[84px] rounded-md border border-input bg-background px-2 text-sm shadow-sm outline-none focus-visible:ring-2 focus-visible:ring-ring",children:J2.map(S=>m.jsx("option",{value:S,children:S},S))})})]})]}),m.jsxs("div",{className:"space-y-2",children:[n.length>0?m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Headings"}),m.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:n.map(({level:S,value:A})=>m.jsx("button",{type:"button",onClick:()=>p(A),className:"h-8 w-full rounded-md border bg-background px-2 text-xs font-medium shadow-sm transition hover:border-primary/40 hover:shadow-sm",title:`Apply H${S} (${A})`,children:`H${S} (${A})`},`h${S}`))})]}):null,m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Keywords"}),m.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:["xx-small","x-small","small","medium","large","x-large"].map(S=>m.jsx("button",{type:"button",onClick:()=>p(S),className:"h-8 w-full rounded-md border bg-background px-2 text-xs font-medium shadow-sm transition hover:border-primary/40 hover:shadow-sm",title:`Apply ${S}`,children:S.replace(/\b\w/g,A=>A.toUpperCase())},S))})]})]})]})}const tj=({editor:t})=>{const[e,n]=C.useState(t.getAttributes("link")?.href??"");C.useEffect(()=>{const s=()=>{n(t.getAttributes("link")?.href??"")};return t.on("selectionUpdate",s),t.on("transaction",s),()=>{t.off("selectionUpdate",s),t.off("transaction",s)}},[t]);const r=()=>{const s=e.trim();s?t.chain().focus().extendMarkRange("link").setLink({href:s}).run():t.chain().focus().extendMarkRange("link").unsetLink().run()};return m.jsxs("div",{className:"p-2 flex items-center gap-2",onMouseDown:s=>s.preventDefault(),children:[m.jsx("input",{type:"url",value:e,onChange:s=>n(s.target.value),placeholder:"Enter URL",className:"bg-background p-1 rounded border border-input text-sm",onKeyDown:s=>s.key==="Enter"&&r()}),m.jsx(le.Button,{type:"button",size:"sm",onClick:r,children:"Set Link"})]})},nj=({editor:t})=>m.jsx("div",{className:"w-[380px]",children:m.jsx(fw,{editor:t,className:"p-4",initialMode:t.isActive("highlight")?"highlight":"text"})}),Nh=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(!1),[i,o]=C.useState(!1),[l,a]=C.useState(!1),{x:c,y:d,refs:u,strategy:h,update:f}=Xi({placement:"top",middleware:[Yi(6),La(),Da()],whileElementsMounted:Ms}),p=C.useCallback(()=>{if(!t||!t.isEditable)return!1;const{state:y}=t,{from:b,to:w}=y.selection,M=b!==w,S=y.selection instanceof q,A=t.isActive("codeBlock"),x=y.selection.empty&&(t.isActive("alert-widget")||t.isActive("cta-widget")),k=t.isActive("image");return M&&!S&&!A&&!x&&!k},[t]),g=C.useCallback(()=>{if(!(!t||!p()))try{const{from:y,to:b}=t.state.selection,w=t.view.coordsAtPos(y),M=t.view.coordsAtPos(b),S={getBoundingClientRect:()=>({x:w.left,y:w.top,top:w.top,left:w.left,bottom:M.bottom,right:M.right,width:M.right-w.left,height:M.bottom-w.top})};u.setReference(S),f(),requestAnimationFrame(()=>s(!0))}catch(y){console.warn("BubbleMenu positioning error:",y)}},[t,u,f,p]);return C.useEffect(()=>{if(!t)return;let y=0;const b=()=>{cancelAnimationFrame(y),y=requestAnimationFrame(()=>{p()?(n(!0),g()):!i&&!l&&n(!1)})},w=({event:M})=>{i||l||u.floating.current&&M.relatedTarget&&u.floating.current.contains(M.relatedTarget)||n(!1)};return b(),t.on("selectionUpdate",b),t.on("transaction",b),t.on("focus",b),t.on("blur",w),()=>{cancelAnimationFrame(y),t.off("selectionUpdate",b),t.off("transaction",b),t.off("focus",b),t.off("blur",w)}},[t,p,g,i,l,u.floating]),!t||!e?null:m.jsxs("div",{ref:u.setFloating,style:{position:h,top:d??0,left:c??0,zIndex:1e4,visibility:r?"visible":"hidden"},className:"flex gap-1 items-center bg-background border rounded-lg p-1 shadow-lg",onMouseDown:y=>y.preventDefault(),children:[m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleBold().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("bold")?"bg-accent":""}`,"aria-label":"Bold",title:"Bold",children:m.jsx(Gl,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleItalic().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("italic")?"bg-accent":""}`,"aria-label":"Italic",title:"Italic",children:m.jsx(kh,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleUnderline().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("underline")?"bg-accent":""}`,"aria-label":"Underline",title:"Underline",children:m.jsx(Ch,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleStrike().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("strike")?"bg-accent":""}`,"aria-label":"Strikethrough",title:"Strikethrough",children:m.jsx(Yx,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleCode().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("code")?"bg-accent":""}`,"aria-label":"Inline code",title:"Inline code",children:m.jsx(Rs,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("div",{className:"w-px bg-border h-5"}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleSubscript().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("subscript")?"bg-accent":""}`,"aria-label":"Subscript",title:"Subscript",children:m.jsx(Xx,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleSuperscript().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("superscript")?"bg-accent":""}`,"aria-label":"Superscript",title:"Superscript",children:m.jsx(Zx,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("div",{className:"w-px bg-border h-5"}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("left").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"left"})?"bg-accent":""}`,"aria-label":"Align left",title:"Align left",children:m.jsx(Ss,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("center").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"center"})?"bg-accent":""}`,"aria-label":"Align center",title:"Align center",children:m.jsx(Ki,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("right").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"right"})?"bg-accent":""}`,"aria-label":"Align right",title:"Align right",children:m.jsx(Gi,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("justify").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"justify"})?"bg-accent":""}`,"aria-label":"Justify",title:"Justify",children:m.jsx(Sh,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("div",{className:"w-px bg-border h-5"}),m.jsxs(gt.Popover,{open:l,onOpenChange:a,children:[m.jsx(gt.PopoverTrigger,{asChild:!0,children:m.jsx("button",{type:"button",className:"p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center","aria-label":"Font size",title:"Font size",onMouseDown:y=>y.preventDefault(),children:m.jsx(Wr,{className:"h-4 w-4 pointer-events-none"})})}),m.jsx(gt.PopoverContent,{onFocusOutside:y=>y.preventDefault(),onMouseDown:y=>y.stopPropagation(),className:"w-[360px] p-0",side:"top",align:"start",children:m.jsx(pw,{editor:t,className:"p-4"})})]}),m.jsxs(gt.Popover,{children:[m.jsx(gt.PopoverTrigger,{asChild:!0,children:m.jsx("button",{type:"button",className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("link")?"bg-accent":""}`,"aria-label":"Link",title:"Link",onMouseDown:y=>y.preventDefault(),children:m.jsx(Ta,{className:"h-4 w-4 pointer-events-none"})})}),m.jsx(gt.PopoverContent,{className:"w-auto p-0",side:"top",align:"start",children:m.jsx(tj,{editor:t})})]}),m.jsxs(gt.Popover,{open:i,onOpenChange:o,children:[m.jsx(gt.PopoverTrigger,{asChild:!0,children:m.jsx("button",{type:"button",onMouseDown:y=>y.preventDefault(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("textStyle")||t.isActive("highlight")?"bg-accent":""}`,"aria-label":"Color / highlight",title:"Color / highlight",children:m.jsx(vh,{className:"h-4 w-4 pointer-events-none"})})}),m.jsx(gt.PopoverContent,{onFocusOutside:y=>y.preventDefault(),onMouseDown:y=>y.stopPropagation(),className:"w-auto p-0",side:"top",align:"start",children:m.jsx(nj,{editor:t})})]}),m.jsx("div",{className:"w-px bg-border h-5"})]})};function Xm(t,e){t.storage.mediaPicker={open:e}}function ja(t){return t.storage?.mediaPicker?.open}const rj=[{title:"Heading 1",icon:m.jsx(vs,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:1}).run()},{title:"Heading 2",icon:m.jsx(Vi,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:2}).run()},{title:"Bullet List",icon:m.jsx(Os,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBulletList().run()},{title:"Ordered List",icon:m.jsx(Wi,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleOrderedList().run()},{title:"Blockquote",icon:m.jsx(Ji,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBlockquote().run()},{title:"Code Block",icon:m.jsx(Rs,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleCodeBlock().run()},{title:"Image",icon:m.jsx(zr,{className:"h-4 w-4"}),command:async t=>{const e=ja(t);if(e){const r=await e();r?.src&&t.chain().focus().setImage({src:r.src,alt:r.alt||void 0}).updateAttributes("image",{blurDataURL:r.blurDataURL||void 0}).run();return}const n=window.prompt("URL");n&&t.chain().focus().setImage({src:n}).run()}},{title:"Table",icon:m.jsx(qi,{className:"h-4 w-4"}),command:t=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{title:"Horizontal Rule",icon:m.jsx(_a,{className:"h-4 w-4"}),command:t=>t.chain().focus().setHorizontalRule().run()},{title:"Link",icon:m.jsx(Ta,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter URL:");e&&t.chain().focus().setLink({href:e}).run()}},{title:"CSS Block",icon:m.jsx(Nr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter CSS (without <style> tags):","/* your styles */");if(e!=null){const n=`<style>${e}</style>`;t.commands.insertContentAt({from:0,to:0},n)}}},{title:"Script Block",icon:m.jsx(Nr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter JavaScript (without <script> tags):","// your script");if(e!=null){const n=`<script>${e}<\/script>`,r=t.state.doc.content.size;t.commands.insertContentAt(r,n)}}},{title:"DIV Block",icon:m.jsx(Nr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Optional class for DIV:",""),n=window.prompt("Optional inline style for DIV:",""),r=window.prompt("Optional content for DIV:","New block"),s=`${e?` class="${e}"`:""}${n?` style="${n}"`:""}`,o=r?`<p>${(l=>l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"))(r)}</p>`:"<p><br /></p>";t.chain().focus().insertContent(`<div${s}>${o}</div>`).run()}},{title:"Alert Widget",icon:m.jsx(Oa,{className:"h-4 w-4"}),command:t=>{t.chain().focus().setAlertWidget().run()}},{title:"CTA Widget",icon:m.jsx(Na,{className:"h-4 w-4"}),command:t=>{t.chain().focus().setCtaWidget({text:"Learn more",url:"",style:"primary",size:"medium",textAlign:"center"}).run()}}],_h=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(null),[i,o]=C.useState(null),l=C.useRef(null),a=C.useRef(null),c=C.useRef(!1),d=C.useCallback(()=>{l.current&&l.current.setAttribute("aria-expanded","false"),a.current&&a.current.removeAttribute("data-menu-open"),l.current=null,a.current=null,s(null),n(!1)},[]),{x:u,y:h,refs:f,strategy:p}=Xi({placement:"right-start",open:e,middleware:[Yi(8),La(),Da()],whileElementsMounted:Ms});C.useEffect(()=>{c.current=e},[e]),C.useEffect(()=>{r?f.setReference(r):f.setReference(null)},[r,f]);const g=C.useCallback(()=>!(!t||!t.isEditable||t.isActive("image")),[t]);C.useEffect(()=>{if(!t)return;const b=t.view.dom.parentElement;if(!b)return;const w=M=>{const S=M,{handle:A,button:x}=S.detail;try{const v=t.state.selection?.$from;if(v){let T=v.depth;for(;T>0&&!v.node(T)?.isBlock;)T-=1;const N=typeof v.after=="function"?v.after(T):void 0;typeof N=="number"?o(N):typeof v.pos=="number"?o(v.pos):o(null)}else o(null)}catch{o(null)}if(l.current===x&&c.current){d();return}l.current&&l.current!==x&&l.current.setAttribute("aria-expanded","false"),a.current&&a.current!==A&&a.current.removeAttribute("data-menu-open"),l.current=x,a.current=A,x.setAttribute("aria-expanded","true"),A.setAttribute("data-menu-open","true"),s(x),n(!0)};return b.addEventListener("tiptap-gutter-toggle",w),()=>{b.removeEventListener("tiptap-gutter-toggle",w)}},[t,g,d]),C.useEffect(()=>{if(!t)return;const b=()=>{g()||d()};return t.on("selectionUpdate",b),t.on("transaction",b),t.on("blur",d),()=>{t.off("selectionUpdate",b),t.off("transaction",b),t.off("blur",d)}},[t,g,d]),C.useEffect(()=>{if(!e)return;const b=M=>{const S=M.target,A=f.floating.current;if(A&&!A.contains(S)){const x=l.current;(!x||!x.contains(S))&&d()}},w=M=>{M.key==="Escape"&&d()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",w)}},[e,d,f]);const y=b=>{i!=null?t.chain().focus().insertContentAt(i,{type:"paragraph"}).setTextSelection(i+1).run():t.chain().focus().run(),b(t),d()};return!r||!e?null:m.jsx("div",{ref:f.setFloating,style:{position:p,top:h??0,left:u??0,zIndex:10001},className:"w-48 rounded-md bg-white p-1 shadow-lg max-h-[400px] overflow-auto",onMouseDown:b=>b.preventDefault(),children:m.jsx("div",{className:"flex flex-col",children:rj.map(b=>m.jsxs(le.Button,{type:"button",variant:"ghost",className:"justify-start",onClick:()=>y(b.command),children:[b.icon,m.jsx("span",{className:"ml-2",children:b.title})]},b.title))})})},sj=[{title:"Text",description:"Start writing with plain text",icon:m.jsx(Wr,{className:"h-4 w-4"}),command:t=>t.chain().focus().clearNodes().run(),category:"basic",keywords:["text","paragraph","plain"]},{title:"Heading 1",description:"Large section heading",icon:m.jsx(vs,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:1}).run(),category:"headings",keywords:["heading","h1","title","large"]},{title:"Heading 2",description:"Medium section heading",icon:m.jsx(Vi,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:2}).run(),category:"headings",keywords:["heading","h2","subtitle","medium"]},{title:"Heading 3",description:"Small section heading",icon:m.jsx(Aa,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:3}).run(),category:"headings",keywords:["heading","h3","small"]},{title:"Bullet List",description:"Create a simple bulleted list",icon:m.jsx(Os,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBulletList().run(),category:"lists",keywords:["bullet","list","unordered","ul"]},{title:"Numbered List",description:"Create a list with numbering",icon:m.jsx(Wi,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleOrderedList().run(),category:"lists",keywords:["numbered","list","ordered","ol"]},{title:"Task List",description:"Create a list with checkboxes",icon:m.jsx(Ra,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleTaskList().run(),category:"lists",keywords:["task","todo","checkbox","checklist"]},{title:"Image",description:"Insert an image",icon:m.jsx(zr,{className:"h-4 w-4"}),command:async t=>{const e=ja(t);if(e){const r=await e();r?.src&&t.chain().focus().setImage({src:r.src,alt:r.alt||void 0}).updateAttributes("image",{blurDataURL:r.blurDataURL||void 0}).run();return}const n=window.prompt("Enter image URL:");n&&t.chain().focus().setImage({src:n}).run()},category:"media",keywords:["image","picture","photo","img"]},{title:"Video",description:"Embed a video from URL",icon:m.jsx(ew,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter video URL (YouTube, Vimeo, etc.):");e&&t.chain().focus().insertContent(`<p><a href="${e}" target="_blank">Video: ${e}</a></p>`).run()},category:"media",keywords:["video","youtube","vimeo","embed"]},{title:"Blockquote",description:"Create a quote or citation",icon:m.jsx(Ji,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBlockquote().run(),category:"advanced",keywords:["quote","blockquote","citation"]},{title:"Code Block",description:"Create a code block with syntax highlighting",icon:m.jsx(Rs,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleCodeBlock().run(),category:"advanced",keywords:["code","programming","syntax","block"]},{title:"Table",description:"Insert a table with rows and columns",icon:m.jsx(qi,{className:"h-4 w-4"}),command:t=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),category:"advanced",keywords:["table","grid","rows","columns"]},{title:"Horizontal Rule",description:"Insert a horizontal divider",icon:m.jsx(_a,{className:"h-4 w-4"}),command:t=>t.chain().focus().setHorizontalRule().run(),category:"advanced",keywords:["divider","separator","line","hr"]},{title:"Alert",description:"Insert an alert or notice",icon:m.jsx(Oa,{className:"h-4 w-4"}),command:t=>{t.can().setAlertWidget()?t.chain().focus().setAlertWidget().run():t.chain().focus().toggleBlockquote().run()},category:"advanced",keywords:["alert","notice","warning","info"]},{title:"Call to Action",description:"Insert a call to action button",icon:m.jsx(Na,{className:"h-4 w-4"}),command:t=>{t.can().setCtaWidget()?t.chain().focus().setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}).run():t.chain().focus().insertContent("Call to Action").run()},category:"advanced",keywords:["cta","button","action","link"]}],Zm={basic:m.jsx(Wr,{className:"h-3 w-3"}),headings:m.jsx(XL,{className:"h-3 w-3"}),lists:m.jsx(Os,{className:"h-3 w-3"}),media:m.jsx(zr,{className:"h-3 w-3"}),advanced:m.jsx(PI,{className:"h-3 w-3"})},Qm={basic:"Basic",headings:"Headings",lists:"Lists",media:"Media",advanced:"Advanced"},mw=({editor:t,wrapperRef:e})=>{const[n,r]=C.useState(!1),[s,i]=C.useState(!1),[o,l]=C.useState(!1),[a,c]=C.useState(""),[d,u]=C.useState("all"),[h,f]=C.useState({top:-9999,left:-9999,width:0}),{x:p,y:g,refs:y,strategy:b,update:w}=Xi({placement:"bottom-start",open:n,onOpenChange:r,middleware:[Yi(10),La({fallbackPlacements:["top-start","bottom-start","right-start"]}),Da({padding:8}),p2({apply({availableWidth:v,availableHeight:T,elements:N}){Object.assign(N.floating.style,{maxWidth:`${Math.min(400,v-16)}px`,maxHeight:`${Math.min(500,T-16)}px`})}})],whileElementsMounted:Ms}),M=C.useCallback(()=>{const{$from:v}=t.state.selection,T=v.parent;if(T.type.name==="paragraph"&&T.content.size===0||T.type.name==="heading"&&T.content.size===0)return!0;if(T.type.name==="listItem"&&T.content.size===1){const N=T.firstChild;if(N&&N.type.name==="paragraph"&&N.content.size===0)return!0}return t.isEditable},[t]),S=C.useCallback(()=>{if(!e?.current)return;const v=e.current.getBoundingClientRect(),T=t.view.dom.getBoundingClientRect(),H=t.view.coordsAtPos(t.state.selection.from).top-v.top,V=T.left-v.left,$=T.width;f({top:H,left:V,width:$}),w(),requestAnimationFrame(()=>l(!0))},[t,w,e]);C.useEffect(()=>{if(!t)return;let v=0;const T=()=>{cancelAnimationFrame(v),v=requestAnimationFrame(()=>{M()?(i(!0),l(!1),S()):(i(!1),r(!1),l(!1))})},N=()=>{i(!1),r(!1),l(!1)};return T(),t.on("selectionUpdate",T),t.on("transaction",T),t.on("focus",T),t.on("blur",N),()=>{cancelAnimationFrame(v),t.off("selectionUpdate",T),t.off("transaction",T),t.off("focus",T),t.off("blur",N)}},[t,M,S]);const A=v=>{v(t),r(!1),c(""),u("all")},x=sj.filter(v=>{const T=d==="all"||v.category===d,N=a===""||v.title.toLowerCase().includes(a.toLowerCase())||v.description.toLowerCase().includes(a.toLowerCase())||v.keywords.some(H=>H.toLowerCase().includes(a.toLowerCase()));return T&&N}),k=x.reduce((v,T)=>(v[T.category]||(v[T.category]=[]),v[T.category].push(T),v),{});return s?m.jsxs(m.Fragment,{children:[m.jsx("div",{style:{position:"absolute",top:h.top,left:h.left,width:h.width,visibility:o?"visible":"hidden",zIndex:1e4},className:"group",children:m.jsxs("div",{className:"relative py-4 w-[95%] mx-auto flex items-center","aria-label":"Insert block",children:[m.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-full h-0.5 bg-gradient-to-r from-transparent via-slate-300 to-transparent dark:via-slate-600 transform origin-center scale-x-0 opacity-0 group-hover:scale-x-100 group-hover:opacity-100 transition-all duration-300"}),m.jsxs("div",{ref:y.setReference,className:"relative z-10 cursor-pointer mx-auto",onClick:()=>r(v=>!v),children:[m.jsx("div",{className:"absolute -inset-3 rounded-full bg-primary/10 dark:bg-primary/20 scale-0 opacity-0 group-hover:scale-100 group-hover:opacity-100 transition-all duration-300 ease-out animate-pulse"}),m.jsx("div",{className:"relative bg-background border border-border p-1.5 rounded-full shadow-sm group-hover:shadow-md transition-all duration-200",children:m.jsx(LL,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors duration-200"})})]})]})}),n&&m.jsxs("div",{ref:y.setFloating,style:{position:b,top:g??0,left:p??0,zIndex:10001},className:"bg-background border border-border shadow-lg rounded-lg p-2 w-96 max-h-[500px] overflow-hidden",onMouseDown:v=>v.preventDefault(),children:[m.jsx("div",{className:"p-2 border-b border-border",children:m.jsx("input",{type:"text",placeholder:"Search blocks...",value:a,onChange:v=>c(v.target.value),className:"w-full px-3 py-2 text-sm bg-muted border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",autoFocus:!0})}),m.jsxs("div",{className:"flex gap-1 p-2 border-b border-border overflow-x-auto",children:[m.jsx(le.Button,{variant:d==="all"?"default":"ghost",size:"sm",onClick:()=>u("all"),className:"text-xs whitespace-nowrap",children:"All"}),Object.entries(Qm).map(([v,T])=>m.jsxs(le.Button,{variant:d===v?"default":"ghost",size:"sm",onClick:()=>u(v),className:"text-xs whitespace-nowrap flex items-center gap-1",children:[Zm[v],T]},v))]}),m.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[d==="all"?Object.entries(k).map(([v,T])=>m.jsxs("div",{className:"py-2",children:[m.jsxs("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-2",children:[Zm[v],Qm[v]]}),T.map(N=>m.jsx(le.Button,{variant:"ghost",className:"w-full justify-start p-3 h-auto text-left",onClick:()=>A(N.command),children:m.jsxs("div",{className:"flex items-center gap-3 w-full",children:[m.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-md border bg-muted",children:N.icon}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"font-medium text-sm",children:N.title}),m.jsx("p",{className:"text-xs text-muted-foreground truncate",children:N.description})]})]})},N.title))]},v)):x.map(v=>m.jsx(le.Button,{variant:"ghost",className:"w-full justify-start p-3 h-auto text-left",onClick:()=>A(v.command),children:m.jsxs("div",{className:"flex items-center gap-3 w-full",children:[m.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-md border bg-muted",children:v.icon}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"font-medium text-sm",children:v.title}),m.jsx("p",{className:"text-xs text-muted-foreground truncate",children:v.description})]})]})},v.title)),x.length===0&&m.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:['No blocks found for "',a,'"']})]})]})]}):null},ij=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),eg=new Set(["address","article","aside","blockquote","canvas","dd","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","li","main","nav","noscript","ol","p","pre","section","table","tfoot","ul","video","thead","tbody","tr","th","td","colgroup"]);function gw(t){const e=t.match(/^<\/?\s*([a-zA-Z0-9:-]+)/);return e?e[1].toLowerCase():null}function oj(t){return/^<\s*[^/!][^>]*>$/.test(t)}function tg(t){return/^<\s*\//.test(t)}function lj(t){if(/\/\s*>$/.test(t))return!0;const e=gw(t);return e?ij.has(e):!1}function aj(t){return/^<\s*!/.test(t)}function $c(t,e=2){if(!t)return"";const n=t.replace(/\r\n?/g,`
|
|
152
|
-
`).split(/(<[^>]+>)/g).filter(Boolean),r=" ".repeat(e);let s=0;const i=[];let o=null;for(let l=0;l<n.length;l++){const a=n[l];if(a.startsWith("<")){const c=gw(a);c&&(c==="pre"||c==="code"||c==="script"||c==="style")&&tg(a)&&(o=null),tg(a)&&s>0&&(s-=1);const d=c&&eg.has(c)||
|
|
153
|
-
`)?i[i.length-1]=h+a.trim():i.push(r.repeat(s)+a.trim())}c&&
|
|
151
|
+
`?o.insert.slice(0,-1):o.insert;(typeof l!="string"||l.length>0)&&Ic(r,this,s,l,o.attributes||{})}else o.retain!==void 0?Em(r,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&Mm(r,s,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??ft();const s=[],i=new Map,o=this.doc;let l="",a=this._start;function c(){if(l.length>0){const u={};let h=!1;i.forEach((p,g)=>{h=!0,u[g]=p});const f={insert:l};h&&(f.attributes=u),s.push(f),l=""}}const d=()=>{for(;a!==null;){if(br(a,e)||n!==void 0&&br(a,n))switch(a.content.constructor){case Xt:{const u=i.get("ychange");e!==void 0&&!br(a,e)?(u===void 0||u.user!==a.id.client||u.type!=="removed")&&(c(),i.set("ychange",r?r("removed",a.id):{type:"removed"})):n!==void 0&&!br(a,n)?(u===void 0||u.user!==a.id.client||u.type!=="added")&&(c(),i.set("ychange",r?r("added",a.id):{type:"added"})):u!==void 0&&(c(),i.delete("ychange")),l+=a.content.str;break}case en:case Vr:{c();const u={insert:a.content.getContent()[0]};if(i.size>0){const h={};u.attributes=h,i.forEach((f,p)=>{h[p]=f})}s.push(u);break}case Ge:br(a,e)&&(c(),_s(i,a.content));break}a=a.right}c()};return e||n?Ce(o,u=>{e&&jd(u,e),n&&jd(u,n),d()},"cleanup"):d(),s}insert(e,n,r){if(n.length<=0)return;const s=this.doc;s!==null?Ce(s,i=>{const o=To(i,this,e,!r);r||(r={},o.currentAttributes.forEach((l,a)=>{r[a]=l})),Ic(i,this,o,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const s=this.doc;s!==null?Ce(s,i=>{const o=To(i,this,e,!r);Ic(i,this,o,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;const r=this.doc;r!==null?Ce(r,s=>{Mm(s,To(s,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const s=this.doc;s!==null?Ce(s,i=>{const o=To(i,this,e,!1);o.right!==null&&Em(i,this,o,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?Ce(this.doc,n=>{zl(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?Ce(this.doc,r=>{mh(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return gh(this,e)}getAttributes(){return mx(this)}_write(e){e.writeTypeRef(UO)}}const CO=t=>new dr;class jc{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??ft()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===ht||n.constructor===$r)&&n._start!==null)e=n._start;else for(;e!==null;){const r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class $r extends tt{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new $r}clone(){const e=new $r;return e.insert(0,this.toArray().map(n=>n instanceof tt?n.clone():n)),e}get length(){return this.doc??ft(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new jc(this,e)}querySelector(e){e=e.toUpperCase();const r=new jc(this,s=>s.nodeName&&s.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),Br(new jc(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){Ca(this,e,new AO(this,n,e))}toString(){return dx(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const s=e.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),Ai(this,i=>{s.insertBefore(i.toDOM(e,n,r),null)}),s}insert(e,n){this.doc!==null?Ce(this.doc,r=>{fx(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)Ce(this.doc,r=>{const s=e&&e instanceof tt?e._item:e;Hl(r,this,s,n)});else{const r=this._prelimContent,s=e===null?0:r.findIndex(i=>i===e)+1;if(s===0&&e!==null)throw ar("Reference item not found");r.splice(s,0,...n)}}delete(e,n=1){this.doc!==null?Ce(this.doc,r=>{px(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return ax(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return ux(this,e)}slice(e=0,n=this.length){return lx(this,e,n)}forEach(e){Ai(this,e)}_write(e){e.writeTypeRef(WO)}}const EO=t=>new $r;class ht extends $r{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new ht(this.nodeName)}clone(){const e=new ht(this.nodeName),n=this.getAttributes();return lR(n,(r,s)=>{typeof r=="string"&&e.setAttribute(s,r)}),e.insert(0,this.toArray().map(r=>r instanceof tt?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const l in e)r.push(l);r.sort();const s=r.length;for(let l=0;l<s;l++){const a=r[l];n.push(a+'="'+e[a]+'"')}const i=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(e){this.doc!==null?Ce(this.doc,n=>{zl(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?Ce(this.doc,r=>{mh(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return gh(this,e)}hasAttribute(e){return gx(this,e)}getAttributes(e){return e?mO(this,e):mx(this)}toDOM(e=document,n={},r){const s=e.createElement(this.nodeName),i=this.getAttributes();for(const o in i){const l=i[o];typeof l=="string"&&s.setAttribute(o,l)}return Ai(this,o=>{s.appendChild(o.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef(VO),e.writeKey(this.nodeName)}}const MO=t=>new ht(t.readKey());class AO extends va{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}}class Fl extends ks{constructor(e){super(),this.hookName=e}_copy(){return new Fl(this.hookName)}clone(){const e=new Fl(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const s=n[this.hookName];let i;return s!==void 0?i=s.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(qO),e.writeKey(this.hookName)}}const TO=t=>new Fl(t.readKey());class Et extends dr{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new Et}clone(){const e=new Et;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const s=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(e=>{const n=[];for(const s in e.attributes){const i=[];for(const o in e.attributes[s])i.push({key:o,value:e.attributes[s][o]});i.sort((o,l)=>o.key<l.key?-1:1),n.push({nodeName:s,attrs:i})}n.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<n.length;s++){const i=n[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){const l=i.attrs[o];r+=` ${l.key}="${l.value}"`}r+=">"}r+=e.insert;for(let s=n.length-1;s>=0;s--)r+=`</${n[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(KO)}}const NO=t=>new Et;class yh{constructor(e,n){this.id=e,this.length=n}get deleted(){throw Gt()}mergeWith(e){return!1}write(e,n,r){throw Gt()}integrate(e,n){throw Gt()}}const _O=0;class Bt extends yh{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),ex(e.doc.store,this)}write(e,n){e.writeInfo(_O),e.writeLen(this.length-n)}getMissing(e,n){return null}}class Fi{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Fi(this.content)}splice(e){throw Gt()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const RO=t=>new Fi(t.readBuf());class Ti{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Ti(this.len)}splice(e){const n=new Ti(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){Si(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const OO=t=>new Ti(t.readLen()),kx=(t,e)=>new Ur({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Ui{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Ui(kx(this.doc.guid,this.opts))}splice(e){throw Gt()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const DO=t=>new Ui(kx(t.readString(),t.readAny()));class Vr{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Vr(this.embed)}splice(e){throw Gt()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const LO=t=>new Vr(t.readJSON());class Ge{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Ge(this.key,this.value)}splice(e){throw Gt()}mergeWith(e){return!1}integrate(e,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const IO=t=>new Ge(t.readKey(),t.readJSON());class Ul{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Ul(this.arr)}splice(e){const n=new Ul(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const i=this.arr[s];e.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}const jO=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const s=t.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new Ul(n)},PO=Pl("node_env")==="development";class Hr{constructor(e){this.arr=e,PO&&P0(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Hr(this.arr)}splice(e){const n=new Hr(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const i=this.arr[s];e.writeAny(i)}}getRef(){return 8}}const BO=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new Hr(n)};class Xt{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Xt(this.str)}splice(e){const n=new Xt(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const $O=t=>new Xt(t.readString()),HO=[yO,xO,CO,MO,EO,TO,NO],zO=0,FO=1,UO=2,VO=3,WO=4,qO=5,KO=6;class en{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new en(this.type._copy())}splice(e){throw Gt()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const GO=t=>new en(HO[t.readTypeRef()](t)),$d=(t,e)=>{let n=e,r=0,s;do r>0&&(n=ce(n.client,n.clock+r)),s=cs(t,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof ve);return{item:s,diff:r}},bh=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},Vl=(t,e,n)=>{const{client:r,clock:s}=e.id,i=new ve(ce(r,s+n),e,ce(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),e.redone!==null&&(i.redone=ce(e.redone.client,e.redone.clock+n)),e.right=i,i.right!==null&&(i.right.left=i),t._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),e.length=n,i},Am=(t,e)=>x_(t,n=>Ns(n.deletions,e)),vx=(t,e,n,r,s,i)=>{const o=t.doc,l=o.store,a=o.clientID,c=e.redone;if(c!==null)return vt(t,c);let d=e.parent._item,u=null,h;if(d!==null&&d.deleted===!0){if(d.redone===null&&(!n.has(d)||vx(t,d,n,r,s,i)===null))return null;for(;d.redone!==null;)d=vt(t,d.redone)}const f=d===null?e.parent:d.content.type;if(e.parentSub===null){for(u=e.left,h=e;u!==null;){let b=u;for(;b!==null&&b.parent._item!==d;)b=b.redone===null?null:vt(t,b.redone);if(b!==null&&b.parent._item===d){u=b;break}u=u.left}for(;h!==null;){let b=h;for(;b!==null&&b.parent._item!==d;)b=b.redone===null?null:vt(t,b.redone);if(b!==null&&b.parent._item===d){h=b;break}h=h.right}}else if(h=null,e.right&&!s){for(u=e;u!==null&&u.right!==null&&(u.right.redone||Ns(r,u.right.id)||Am(i.undoStack,u.right.id)||Am(i.redoStack,u.right.id));)for(u=u.right;u.redone;)u=vt(t,u.redone);if(u&&u.right!==null)return null}else u=f._map.get(e.parentSub)||null;const p=Ue(l,a),g=ce(a,p),y=new ve(g,u,u&&u.lastId,h,h&&h.id,f,e.parentSub,e.content.copy());return e.redone=g,bh(y,!0),y.integrate(t,0),y};class ve extends yh{constructor(e,n,r,s,i,o,l,a){super(e,a.getLength()),this.origin=r,this.left=n,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=l,this.redone=null,this.content=a,this.info=this.content.isCountable()?rm:0}set marker(e){(this.info&Nc)>0!==e&&(this.info^=Nc)}get marker(){return(this.info&Nc)>0}get keep(){return(this.info&nm)>0}set keep(e){this.keep!==e&&(this.info^=nm)}get countable(){return(this.info&rm)>0}get deleted(){return(this.info&Tc)>0}set deleted(e){this.deleted!==e&&(this.info^=Tc)}markDeleted(){this.info|=Tc}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Ue(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Ue(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===as&&this.id.client!==this.parent.client&&this.parent.clock>=Ue(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=ym(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=vt(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Bt||this.right&&this.right.constructor===Bt)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===ve?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===ve&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===as){const r=cs(n,this.parent);r.constructor===Bt?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=ym(e,e.doc.store,ce(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;const i=new Set,o=new Set;for(;s!==null&&s!==this.right;){if(o.add(s),i.add(s),Eo(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if(Eo(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(cs(e.doc.store,s.origin)))i.has(cs(e.doc.store,s.origin))||(r=s,i.clear());else break;s=s.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),ex(e.doc.store,this),this.content.integrate(e,this),xm(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Bt(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:ce(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Eo(e.origin,this.lastId)&&this.right===e&&Eo(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Si(e.deleteSet,this.id.client,this.id.clock,this.length),xm(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw Mt();this.content.gc(e),n?QR(e,this,new Bt(this.id,this.length)):this.content=new Ti(this.length)}write(e,n){const r=n>0?ce(this.id.client,this.id.clock+n-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&ya|(r===null?0:yt)|(s===null?0:Tn)|(i===null?0:wi);if(e.writeInfo(o),r!==null&&e.writeLeftID(r),s!==null&&e.writeRightID(s),r===null&&s===null){const l=this.parent;if(l._item!==void 0){const a=l._item;if(a===null){const c=Ci(l);e.writeParentInfo(!0),e.writeString(c)}else e.writeParentInfo(!1),e.writeLeftID(a.id)}else l.constructor===String?(e.writeParentInfo(!0),e.writeString(l)):l.constructor===as?(e.writeParentInfo(!1),e.writeLeftID(l)):Mt();i!==null&&e.writeString(i)}this.content.write(e,n)}}const Sx=(t,e)=>JO[e&ya](t),JO=[()=>{Mt()},OO,jO,RO,$O,LO,IO,GO,BO,DO,()=>{Mt()}],YO=10;class Vt extends yh{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){Mt()}write(e,n){e.writeInfo(YO),ge(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const Cx=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Ex="__ $YJS$ __";Cx[Ex]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Cx[Ex]=!0;const XO=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},ZO=/[\uD800-\uDBFF]/,QO=/[\uDC00-\uDFFF]/,eD=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&ZO.test(t[n-1])&&n--;r+n<t.length&&r+n<e.length&&t[t.length-r-1]===e[e.length-r-1];)r++;return r>0&&QO.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},tD=eD,an=(t,e)=>t>>>e|t<<32-e,nD=t=>an(t,2)^an(t,13)^an(t,22),rD=t=>an(t,6)^an(t,11)^an(t,25),sD=t=>an(t,7)^an(t,18)^t>>>3,iD=t=>an(t,17)^an(t,19)^t>>>10,oD=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),lD=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class aD{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(lD),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let u=16;u<64;u++)n[u]=iD(n[u-2])+n[u-7]+sD(n[u-15])+n[u-16];let r=e[0],s=e[1],i=e[2],o=e[3],l=e[4],a=e[5],c=e[6],d=e[7];for(let u=0,h,f;u<64;u++)h=d+rD(l)+(l&a^~l&c)+oD[u]+n[u]>>>0,f=nD(r)+(r&s^r&i^s&i)>>>0,d=c,c=a,a=l,l=o+h>>>0,o=i,i=s,s=r,r=h+f>>>0;e[0]+=r,e[1]+=s,e[2]+=i,e[3]+=o,e[4]+=l,e[5]+=a,e[6]+=c,e[7]+=d}digest(e){let n=0;for(;n+56<=e.length;){let o=0;for(;o<16&&n+3<e.length;o++)this._W[o]=e[n++]<<24|e[n++]<<16|e[n++]<<8|e[n++];if(n%64!==0){for(this._W.fill(0,o,16);n<e.length;)this._W[o]|=e[n]<<(3-n%4)*8,n++;this._W[o]|=yt<<(3-n%4)*8}this._updateHash()}const r=n%64!==0;this._W.fill(0,0,16);let s=0;for(;n<e.length;s++)for(let o=3;o>=0&&n<e.length;o--)this._W[s]|=e[n++]<<o*8;r||(this._W[s-(n%4===0?0:1)]|=yt<<(3-n%4)*8),this._W[14]=e.byteLength/w_,this._W[15]=e.byteLength*8,this._updateHash();const i=new Uint8Array(32);for(let o=0;o<this._H.length;o++)for(let l=0;l<4;l++)i[o*4+l]=this._H[o]>>>(3-l)*8;return i}}const cD=t=>new aD().digest(t),Ie=new ye("y-sync"),Nn=new ye("y-undo");new ye("yjs-cursor");const dD=t=>{for(let n=6;n<t.length;n++)t[n%6]=t[n%6]^t[n];return t.slice(0,6)},uD=t=>bR(dD(cD(xR(t)))),Wl=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!Ns(e.ds,t.id),hD=[{light:"#ecd44433",dark:"#ecd444"}],fD=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=Pr();t.forEach(s=>r.add(s)),e=e.filter(s=>!r.has(s))}t.set(n,Q_(e))}return t.get(n)},pD=(t,{colors:e=hD,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:s=()=>{},mapping:i}={})=>{let o=!1;const l=new gD(t,i),a=new me({props:{editable:c=>{const d=Ie.getState(c);return d.snapshot==null&&d.prevSnapshot==null}},key:Ie,state:{init:(c,d)=>({type:t,doc:t.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(c,d)=>{const u=c.getMeta(Ie);if(u!==void 0){d=Object.assign({},d);for(const h in u)d[h]=u[h]}return d.addToHistory=c.getMeta("addToHistory")!==!1,d.isChangeOrigin=u!==void 0&&!!u.isChangeOrigin,d.isUndoRedoOperation=u!==void 0&&!!u.isChangeOrigin&&!!u.isUndoRedoOperation,l.prosemirrorView!==null&&u!==void 0&&(u.snapshot!=null||u.prevSnapshot!=null)&&H0(0,()=>{l.prosemirrorView!=null&&(u.restore==null?l._renderSnapshot(u.snapshot,u.prevSnapshot,d):(l._renderSnapshot(u.snapshot,u.snapshot,d),delete d.restore,delete d.snapshot,delete d.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))}),d}},view:c=>(l.initView(c),i==null&&l._forceRerender(),s(),{update:()=>{const d=a.getState(c.state);if(d.snapshot==null&&d.prevSnapshot==null&&(o||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(o=!0,d.addToHistory===!1&&!d.isChangeOrigin){const u=Nn.getState(c.state),h=u&&u.undoManager;h&&h.stopCapturing()}l.mux(()=>{d.doc.transact(u=>{u.meta.set("addToHistory",d.addToHistory),l._prosemirrorChanged(c.state.doc)},Ie)})}},destroy:()=>{l.destroy()}})});return a},mD=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new St(t.doc));else if(e.type==="node"){const r=Vo(n.doc,n.type,e.anchor,n.mapping);t.setSelection(q.create(t.doc,r))}else{const r=Vo(n.doc,n.type,e.anchor,n.mapping),s=Vo(n.doc,n.type,e.head,n.mapping);r!==null&&s!==null&&t.setSelection(J.between(t.doc.resolve(r),t.doc.resolve(s)))}},Hd=(t,e)=>({type:e.selection.jsonID,anchor:Vd(e.selection.anchor,t.type,t.mapping),head:Vd(e.selection.head,t.type,t.mapping)});class gD{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=XO(),this.mapping=n,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=Hd(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(B0&&this._domSelectionInView===null&&(H0(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;const n=this.prosemirrorView._root.createRange();n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const s=n.getBoundingClientRect(),i=kR.documentElement;return s.bottom>=0&&s.right>=0&&s.left<=(window.innerWidth||i.clientWidth||0)&&s.top<=(window.innerHeight||i.clientHeight||0)}renderSnapshot(e,n){n||(n=Z0(G0(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Ie,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>Uo(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new P(O.from(e),0,0));n.setMeta(Ie,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(s=>Uo(s,this.prosemirrorView.state.schema,this)).filter(s=>s!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new P(O.from(n),0,0));if(e){const s=bs(lr(e.anchor,0),r.doc.content.size),i=bs(lr(e.head,0),r.doc.content.size);r.setSelection(J.create(r.doc,s,i))}this.prosemirrorView.dispatch(r.setMeta(Ie,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let s=this.doc,i=this.type;if(e||(e=Lc(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&Mt(),s=new Ur({gc:!1}),Id(s,n),n=Lc(s),Id(s,e),e=Lc(s),i._item===null){const o=Array.from(this.doc.share.keys()).find(l=>this.doc.share.get(l)===this.type);i=s.getXmlFragment(o)}else{const o=s.store.clients.get(i._item.id.client)??[],l=Yt(o,i._item.id.clock);i=o[l].content.type}this.mapping.clear(),this.mux(()=>{s.transact(o=>{const l=r.permanentUserData;l&&l.dss.forEach(u=>{cr(o,u,h=>{})});const a=(u,h)=>{const f=u==="added"?l.getUserByClientId(h.client):l.getUserByDeletedId(h);return{user:f,type:u,color:fD(r.colorMapping,r.colors,f)}},c=cx(i,new fh(n.ds,e.sv)).map(u=>!u._item.deleted||Wl(u._item,e)||Wl(u._item,n)?Uo(u,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,n,a):null).filter(u=>u!==null),d=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new P(O.from(c),0,0));this.prosemirrorView.dispatch(d.setMeta(Ie,{isChangeOrigin:!0}))},Ie)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=Ie.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const s=(l,a)=>this.mapping.delete(a);cr(n,n.deleteSet,l=>{if(l.constructor===ve){const a=l.content.type;a&&this.mapping.delete(a)}}),n.changed.forEach(s),n.changedParentTypes.forEach(s);const i=this.type.toArray().map(l=>Mx(l,this.prosemirrorView.state.schema,this)).filter(l=>l!==null);let o=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new P(O.from(i),0,0));mD(o,this.beforeTransactionSelection,this),o=o.setMeta(Ie,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof rx}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(e){this.doc.transact(()=>{Fd(this.doc,this.type,e,this),this.beforeTransactionSelection=Hd(this,this.prosemirrorView.state)},Ie)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const Mx=(t,e,n,r,s,i)=>{const o=n.mapping.get(t);if(o===void 0){if(t instanceof ht)return Uo(t,e,n,r,s,i);throw Gt()}return o},Uo=(t,e,n,r,s,i)=>{const o=[],l=a=>{if(a instanceof ht){const c=Mx(a,e,n,r,s,i);c!==null&&o.push(c)}else{const c=a._item.right?.content?.type;c instanceof dr&&!c._item.deleted&&c._item.id.client===c.doc.clientID&&(a.applyDelta([{retain:a.length},...c.toDelta()]),c.doc.transact(u=>{c._item.delete(u)}));const d=yD(a,e,n,r,s,i);d!==null&&d.forEach(u=>{u!==null&&o.push(u)})}};r===void 0||s===void 0?t.toArray().forEach(l):cx(t,new fh(s.ds,r.sv)).forEach(l);try{const a=t.getAttributes(r);r!==void 0&&(Wl(t._item,r)?Wl(t._item,s)||(a.ychange=i?i("added",t._item.id):{type:"added"}):a.ychange=i?i("removed",t._item.id):{type:"removed"});const c=e.node(t.nodeName,a,o);return n.mapping.set(t,c),c}catch{return t.doc.transact(c=>{t._item.delete(c)},Ie),n.mapping.delete(t),null}},yD=(t,e,n,r,s,i)=>{const o=[],l=t.toDelta(r,s,i);try{for(let a=0;a<l.length;a++){const c=l[a];o.push(e.text(c.insert,SD(c.attributes,e)))}}catch{return t.doc.transact(c=>{t._item.delete(c)},Ie),null}return o},bD=(t,e)=>{const n=new Et,r=t.map(s=>({insert:s.text,attributes:Tx(s.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},xD=(t,e)=>{const n=new ht(t.type.name);for(const r in t.attrs){const s=t.attrs[r];s!==null&&r!=="ychange"&&n.setAttribute(r,s)}return n.insert(0,Ea(t).map(r=>zd(r,e))),e.mapping.set(n,t),n},zd=(t,e)=>t instanceof Array?bD(t,e):xD(t,e),Tm=t=>typeof t=="object"&&t!==null,xh=(t,e)=>{const n=Object.keys(t).filter(s=>t[s]!==null);let r=n.length===Object.keys(e).filter(s=>e[s]!==null).length;for(let s=0;s<n.length&&r;s++){const i=n[s],o=t[i],l=e[i];r=i==="ychange"||o===l||Tm(o)&&Tm(l)&&xh(o,l)}return r},Ea=t=>{const e=t.content.content,n=[];for(let r=0;r<e.length;r++){const s=e[r];if(s.isText){const i=[];for(let o=e[r];r<e.length&&o.isText;o=e[++r])i.push(o);r--,n.push(i)}else n.push(s)}return n},Ax=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,s)=>r.insert===e[s].text&&I0(r.attributes||{}).length===e[s].marks.length&&j0(r.attributes,(i,o)=>{const l=wh(o),a=e[s].marks;return xh(i,a.find(c=>c.type.name===l)?.attrs)}))},Ni=(t,e)=>{if(t instanceof ht&&!(e instanceof Array)&&Ud(t,e)){const n=Ea(e);return t._length===n.length&&xh(t.getAttributes(),e.attrs)&&t.toArray().every((r,s)=>Ni(r,n[s]))}return t instanceof Et&&e instanceof Array&&Ax(t,e)},ql=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),Nm=(t,e,n)=>{const r=t.toArray(),s=Ea(e),i=s.length,o=r.length,l=bs(o,i);let a=0,c=0,d=!1;for(;a<l;a++){const u=r[a],h=s[a];if(ql(n.mapping.get(u),h))d=!0;else if(!Ni(u,h))break}for(;a+c<l;c++){const u=r[o-c-1],h=s[i-c-1];if(ql(n.mapping.get(u),h))d=!0;else if(!Ni(u,h))break}return{equalityFactor:a+c,foundMappedChild:d}},wD=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Xt?e+=n.content.str:n.content instanceof Ge&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},kD=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:s}=wD(t),i=e.map(c=>({insert:c.text,attributes:Object.assign({},r,Tx(c.marks,n))})),{insert:o,remove:l,index:a}=tD(s,i.map(c=>c.insert).join(""));t.delete(a,l),t.insert(a,o),t.applyDelta(i.map(c=>({retain:c.insert.length,attributes:c.attributes})))},vD=/(.*)(--[a-zA-Z0-9+/=]{8})$/,wh=t=>vD.exec(t)?.[1]??t,SD=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(wh(r),t[r]));return n},Tx=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const s=On(e.isOMark,r.type,()=>!r.type.excludes(r.type));n[s?`${r.type.name}--${uD(r.toJSON())}`:r.type.name]=r.attrs}}),n},Fd=(t,e,n,r)=>{if(e instanceof ht&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof ht){const u=e.getAttributes(),h=n.attrs;for(const f in h)h[f]!==null?u[f]!==h[f]&&f!=="ychange"&&e.setAttribute(f,h[f]):e.removeAttribute(f);for(const f in u)h[f]===void 0&&e.removeAttribute(f)}const s=Ea(n),i=s.length,o=e.toArray(),l=o.length,a=bs(i,l);let c=0,d=0;for(;c<a;c++){const u=o[c],h=s[c];if(!ql(r.mapping.get(u),h))if(Ni(u,h))r.mapping.set(u,h);else break}for(;d+c+1<a;d++){const u=o[l-d-1],h=s[i-d-1];if(!ql(r.mapping.get(u),h))if(Ni(u,h))r.mapping.set(u,h);else break}t.transact(()=>{for(;l-c-d>0&&i-c-d>0;){const h=o[c],f=s[c],p=o[l-d-1],g=s[i-d-1];if(h instanceof Et&&f instanceof Array)Ax(h,f)||kD(h,f,r),c+=1;else{let y=h instanceof ht&&Ud(h,f),b=p instanceof ht&&Ud(p,g);if(y&&b){const w=Nm(h,f,r),M=Nm(p,g,r);w.foundMappedChild&&!M.foundMappedChild?b=!1:!w.foundMappedChild&&M.foundMappedChild||w.equalityFactor<M.equalityFactor?y=!1:b=!1}y?(Fd(t,h,f,r),c+=1):b?(Fd(t,p,g,r),d+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[zd(f,r)]),c+=1)}}const u=l-c-d;if(l===1&&i===0&&o[0]instanceof Et?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):u>0&&(e.slice(c,c+u).forEach(h=>r.mapping.delete(h)),e.delete(c,u)),c+d<i){const h=[];for(let f=c;f<i-d;f++)h.push(zd(s[f],r));e.insert(c,h)}},Ie)},Ud=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name,Vd=(t,e,n)=>{if(t===0)return Dc(e,0,-1);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof Et){if(r._length>=t)return Dc(r,t,-1);if(t-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,t--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const s=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t<s)r=r._first.content.type,t--;else{if(t===1&&r._length===0&&s>1)return new $l(r._item===null?null:r._item.id,r._item===null?Ci(r):null,null);if(t-=s,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(t===0)return r=r._item===null?r:r._item.parent,new $l(r._item===null?null:r._item.id,r._item===null?Ci(r):null,null);do r=r._item.parent,t--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw Mt();if(t===0&&r.constructor!==Et&&r!==e)return CD(r._item.parent,r._item)}return Dc(e,e._length,-1)},CD=(t,e)=>{let n=null,r=null;return t._item===null?r=Ci(t):n=ce(t._item.id.client,t._item.id.clock),new $l(n,r,e.id)},Vo=(t,e,n,r)=>{const s=XR(n,t);if(s===null||s.type!==e&&!Ei(e,s.type._item))return null;let i=s.type,o=0;if(i.constructor===Et)o=s.index;else if(i._item===null||!i._item.deleted){let l=i._first,a=0;for(;a<i._length&&a<s.index&&l!==null;){if(!l.deleted){const c=l.content.type;a++,c instanceof Et?o+=c._length:o+=r.get(c).nodeSize}l=l.right}o+=1}for(;i!==e&&i._item!==null;){const l=i._item.parent;if(l._item===null||!l._item.deleted){o+=1;let a=l._first;for(;a!==null;){const c=a.content.type;if(c===i)break;a.deleted||(c instanceof Et?o+=c._length:o+=r.get(c).nodeSize),a=a.right}}i=l}return o-1};function ED(t){const e=t.toArray(),n=r=>{let s;if(r instanceof Et)s=r.toDelta().map(o=>{const l={type:"text",text:o.insert};return o.attributes&&(l.marks=Object.keys(o.attributes).map(a=>{const c=o.attributes[a],u={type:wh(a)};return Object.keys(c)&&(u.attrs=c),u})),l});else if(r instanceof ht){s={type:r.nodeName};const i=r.getAttributes();Object.keys(i).length&&(s.attrs=i);const o=r.toArray();o.length&&(s.content=o.map(n).flat())}else Mt();return s};return{type:"doc",content:e.map(n)}}const MD=t=>{const e=Nn.getState(t).undoManager;if(e!=null)return e.undo(),!0},AD=t=>{const e=Nn.getState(t).undoManager;if(e!=null)return e.redo(),!0},TD=new Set(["paragraph"]),ND=(t,e)=>!(t instanceof ve)||!(t.content instanceof en)||!(t.content.type instanceof dr||t.content.type instanceof ht&&e.has(t.content.type.nodeName))||t.content.type._length===0,_D=({protectedNodes:t=TD,trackedOrigins:e=[],undoManager:n=null}={})=>new me({key:Nn,state:{init:(r,s)=>{const i=Ie.getState(s),o=n||new rx(i.type,{trackedOrigins:new Set([Ie].concat(e)),deleteFilter:l=>ND(l,t),captureTransaction:l=>l.meta.get("addToHistory")!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(r,s,i,o)=>{const l=Ie.getState(o).binding,a=s.undoManager,c=a.undoStack.length>0,d=a.redoStack.length>0;return l?{undoManager:a,prevSel:Hd(l,i),hasUndoOps:c,hasRedoOps:d}:c!==s.hasUndoOps||d!==s.hasRedoOps?Object.assign({},s,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):s}},view:r=>{const s=Ie.getState(r.state),i=Nn.getState(r.state).undoManager;return i.on("stack-item-added",({stackItem:o})=>{const l=s.binding;l&&o.meta.set(l,Nn.getState(r.state).prevSel)}),i.on("stack-item-popped",({stackItem:o})=>{const l=s.binding;l&&(l.beforeTransactionSelection=o.meta.get(l)||l.beforeTransactionSelection)}),{destroy:()=>{i.destroy()}}}});de.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(t=>t.name==="undoRedo")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".')},addCommands(){return{undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Nn.getState(e).undoManager.undoStack.length===0?!1:n?MD(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Nn.getState(e).undoManager.redoStack.length===0?!1:n?AD(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){var t;const e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),n=_D(this.options.yUndoOptions),r=n.spec.view;n.spec.view=o=>{const{undoManager:l}=Nn.getState(o.state);l.restore&&(l.restore(),l.restore=()=>{});const a=r?r(o):void 0;return{destroy:()=>{const c=l.trackedOrigins.has(l),d=l._observers;l.restore=()=>{c&&l.trackedOrigins.add(l),l.doc.on("afterTransaction",l.afterTransactionHandler),l._observers=d},a?.destroy&&a.destroy()}}};const s={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender},i=pD(e,s);return this.editor.options.enableContentCheck&&((t=e.doc)==null||t.on("beforeTransaction",()=>{try{const o=ED(e);if(o.content.length===0)return;this.editor.schema.nodeFromJSON(o).check()}catch(o){return this.editor.emit("contentError",{error:o,editor:this.editor,disableCollaboration:()=>{var l;(l=e.doc)==null||l.destroy(),this.storage.isDisabled=!0}}),!1}})),[i,n,this.editor.options.enableContentCheck&&new me({key:new ye("filterInvalidContent"),filterTransaction:()=>{var o;return this.storage.isDisabled!==!1&&((o=e.doc)==null||o.destroy()),!0}})].filter(Boolean)}});function RD(t){return!!t.getMeta(Ie)}function _m(t){if(!t.length)return be.empty;const e=[],n=t[0].$from.node(0);return t.forEach(r=>{const s=r.$from.pos,i=r.$from.nodeAfter;i&&e.push(_e.node(s,s+i.nodeSize,{class:"ProseMirror-selectednoderange"}))}),be.create(n,e)}function Ma(t,e,n){const r=[],s=t.node(0);typeof n=="number"&&n>=0||(t.sameParent(e)?n=Math.max(0,t.sharedDepth(e.pos)-1):n=t.sharedDepth(e.pos));const i=new oi(t,e,n),o=i.depth===0?0:s.resolve(i.start).posAtIndex(0);return i.parent.forEach((l,a)=>{const c=o+a,d=c+l.nodeSize;if(c<i.start||c>=i.end)return;const u=new lu(s.resolve(c),s.resolve(d));r.push(u)}),r}var OD=class Nx{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Nx(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return new Xn(n,r)}},Xn=class Hn extends ee{constructor(e,n,r,s=1){const{doc:i}=e,o=e===n,l=e.pos===i.content.size&&n.pos===i.content.size,a=o&&!l?i.resolve(n.pos+(s>0?1:-1)):n,c=o&&l?i.resolve(e.pos-(s>0?1:-1)):e,d=Ma(c.min(a),c.max(a),r),u=a.pos>=e.pos?d[0].$from:d[d.length-1].$to,h=a.pos>=e.pos?d[d.length-1].$to:d[0].$from;super(u,h,d),this.depth=r}get $to(){return this.ranges[this.ranges.length-1].$to}eq(e){return e instanceof Hn&&e.$from.pos===this.$from.pos&&e.$to.pos===this.$to.pos}map(e,n){const r=e.resolve(n.map(this.anchor)),s=e.resolve(n.map(this.head));return new Hn(r,s)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:e}=this.$from;if(this.isForwards&&this.ranges.length>1){const s=this.ranges.slice(0,-1),i=s[0].$from,o=s[s.length-1].$to;return new Hn(i,o,this.depth)}const n=this.ranges[0],r=e.resolve(Math.max(0,n.$from.pos-1));return new Hn(this.$anchor,r,this.depth)}extendForwards(){const{doc:e}=this.$from;if(this.isBackwards&&this.ranges.length>1){const s=this.ranges.slice(1),i=s[0].$from,o=s[s.length-1].$to;return new Hn(o,i,this.depth)}const n=this.ranges[this.ranges.length-1],r=e.resolve(Math.min(e.content.size,n.$to.pos+1));return new Hn(this.$anchor,r,this.depth)}static fromJSON(e,n){return new Hn(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r,s,i=1){return new this(e.resolve(n),e.resolve(r),s,i)}getBookmark(){return new OD(this.anchor,this.head)}};Xn.prototype.visible=!1;function No(t){return t instanceof Xn}var DD=de.create({name:"nodeRange",addOptions(){return{depth:void 0,key:"Mod"}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,selection:i,tr:o}=r,{anchor:l,head:a}=i;if(!No(i)){const d=Xn.create(s,l,a,e,-1);return o.setSelection(d),n.dispatch(o),!0}const c=i.extendBackwards();return o.setSelection(c),n.dispatch(o),!0},"Shift-ArrowDown":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,selection:i,tr:o}=r,{anchor:l,head:a}=i;if(!No(i)){const d=Xn.create(s,l,a,e);return o.setSelection(d),n.dispatch(o),!0}const c=i.extendForwards();return o.setSelection(c),n.dispatch(o),!0},"Mod-a":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,tr:i}=r,o=Xn.create(s,0,s.content.size,e);return i.setSelection(o),n.dispatch(i),!0}}},onSelectionUpdate(){const{selection:t}=this.editor.state;No(t)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let t=!1,e=!1;return[new me({key:new ye("nodeRange"),props:{attributes:()=>t?{class:"ProseMirror-noderangeselection"}:{class:""},handleDOMEvents:{mousedown:(n,r)=>{const{key:s}=this.options,i=/Mac/.test(navigator.platform),o=!!r.shiftKey,l=!!r.ctrlKey,a=!!r.altKey,c=!!r.metaKey,d=i?c:l;return(s==null||s==="Shift"&&o||s==="Control"&&l||s==="Alt"&&a||s==="Meta"&&c||s==="Mod"&&d)&&(e=!0),e&&document.addEventListener("mouseup",()=>{e=!1;const{state:u}=n,{doc:h,selection:f,tr:p}=u,{$anchor:g,$head:y}=f;if(g.sameParent(y))return;const b=Xn.create(h,g.pos,y.pos,this.options.depth);p.setSelection(b),n.dispatch(p)},{once:!0}),!1}},decorations:n=>{const{selection:r}=n,s=No(r);if(t=!1,!e)return s?(t=!0,_m(r.ranges)):null;const{$from:i,$to:o}=r;if(!s&&i.sameParent(o))return null;const l=Ma(i,o,this.options.depth);return l.length?(t=!0,_m(l)):null}}})]}}),LD=DD;function ID(t){let e="";const n=getComputedStyle(t);for(let r=0;r<n.length;r+=1)e+=`${n[r]}:${n.getPropertyValue(n[r])};`;return e}function jD(t){const e=t.cloneNode(!0),n=[t,...Array.from(t.getElementsByTagName("*"))],r=[e,...Array.from(e.getElementsByTagName("*"))];return n.forEach((s,i)=>{r[i].style.cssText=ID(s)}),e}function PD(t,e){let n=t;for(;n?.parentElement&&n.parentElement!==e.dom;)n=n.parentElement;return n?.parentElement===e.dom?n:void 0}function BD(t,e,n,r=5){const s=t.dom,i=s.firstElementChild,o=s.lastElementChild;if(!i||!o)return{x:e,y:n};const l=i.getBoundingClientRect(),a=o.getBoundingClientRect(),c=Math.min(Math.max(l.top+r,n),a.bottom-r),d=.5,u=Math.abs(l.left-a.left)<d,h=Math.abs(l.right-a.right)<d;let f=l;return u&&h&&(f=l),{x:Math.min(Math.max(f.left+r,e),f.right-r),y:c}}var _x=t=>{const{x:e,y:n,editor:r}=t,{view:s,state:i}=r,{x:o,y:l}=BD(s,e,n,5),a=s.root.elementsFromPoint(o,l);let c;if(Array.prototype.some.call(a,h=>{if(!s.dom.contains(h))return!1;const f=PD(h,s);return f?(c=f,!0):!1}),!c)return{resultElement:null,resultNode:null,pos:null};let d;try{d=s.posAtDOM(c,0)}catch{return{resultElement:null,resultNode:null,pos:null}}const u=i.doc.nodeAt(d);return{resultElement:c,resultNode:u,pos:d}};function _o(t,e){return window.getComputedStyle(t)[e]}function $D(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function HD(t,e,n){const r=parseInt(_o(t.dom,"paddingLeft"),10),s=parseInt(_o(t.dom,"paddingRight"),10),i=parseInt(_o(t.dom,"borderLeftWidth"),10),o=parseInt(_o(t.dom,"borderLeftWidth"),10),l=t.dom.getBoundingClientRect();return{left:$D(e,l.left+r+i,l.right-s-o),top:n}}function Rx(t){var e;(e=t.parentNode)==null||e.removeChild(t)}function zD(t,e){const{doc:n}=e.view.state,r=_x({editor:e,x:t.clientX,y:t.clientY});if(!r.resultNode||r.pos===null)return[];const s=t.clientX,i=HD(e.view,s,t.clientY),o=e.view.posAtCoords(i);if(!o)return[];const{pos:l}=o;if(!n.resolve(l).parent)return[];const c=n.resolve(r.pos),d=n.resolve(r.pos+1);return Ma(c,d,0)}function FD(t,e){const{view:n}=e;if(!t.dataTransfer)return;const{empty:r,$from:s,$to:i}=n.state.selection,o=zD(t,e),l=Ma(s,i,0),a=l.some(y=>o.find(b=>b.$from===y.$from&&b.$to===y.$to)),c=r||!a?o:l;if(!c.length)return;const{tr:d}=n.state,u=document.createElement("div"),h=c[0].$from.pos,f=c[c.length-1].$to.pos,p=Xn.create(n.state.doc,h,f),g=p.content();c.forEach(y=>{const b=n.nodeDOM(y.$from.pos),w=jD(b);u.append(w)}),u.style.position="absolute",u.style.top="-10000px",document.body.append(u),t.dataTransfer.clearData(),t.dataTransfer.setDragImage(u,0,0),n.dragging={slice:g,move:!0},d.setSelection(p),n.dispatch(d),document.addEventListener("drop",()=>Rx(u),{once:!0})}var Rm=(t,e)=>{const n=t.resolve(e),{depth:r}=n;return r===0?e:n.pos-n.parentOffset-1},Om=(t,e)=>{const n=t.nodeAt(e),r=t.resolve(e);let{depth:s}=r,i=n;for(;s>0;){const o=r.node(s);s-=1,s===0&&(i=o)}return i},Pc=(t,e)=>{const n=Ie.getState(t);return n?Vd(e,n.type,n.binding.mapping):null},UD=(t,e)=>{const n=Ie.getState(t);return n?Vo(n.doc,n.type,e,n.binding.mapping)||0:-1},Dm=(t,e)=>{let n=e;for(;n?.parentNode&&n.parentNode!==t.dom;)n=n.parentNode;return n},Ox=new ye("dragHandle"),Dx=({pluginKey:t=Ox,element:e,editor:n,computePositionConfig:r,getReferencedVirtualElement:s,onNodeChange:i,onElementDragStart:o,onElementDragEnd:l})=>{const a=document.createElement("div");let c=!1,d=null,u=-1,h,f=null,p=null;function g(){e&&(e.style.visibility="hidden",e.style.pointerEvents="none")}function y(){if(e){if(!n.isEditable){g();return}e.style.visibility="",e.style.pointerEvents="auto"}}function b(S){const A=s?.()||{getBoundingClientRect:()=>S.getBoundingClientRect()};Fu(A,e,r).then(x=>{Object.assign(e.style,{position:x.strategy,left:`${x.x}px`,top:`${x.y}px`})})}function w(S){o?.(S),FD(S,n),setTimeout(()=>{e&&(e.style.pointerEvents="none")},0)}function M(S){l?.(S),g(),e&&(e.style.pointerEvents="auto")}return e.addEventListener("dragstart",w),e.addEventListener("dragend",M),a.appendChild(e),{unbind(){e.removeEventListener("dragstart",w),e.removeEventListener("dragend",M),f&&(cancelAnimationFrame(f),f=null,p=null)},plugin:new me({key:typeof t=="string"?new ye(t):t,state:{init(){return{locked:!1}},apply(S,A,x,k){const v=S.getMeta("lockDragHandle"),T=S.getMeta("hideDragHandle");if(v!==void 0&&(c=v),T)return g(),c=!1,d=null,u=-1,i?.({editor:n,node:null,pos:-1}),A;if(S.docChanged&&u!==-1&&e)if(RD(S)){const N=UD(k,h);N!==u&&(u=N)}else{const N=S.mapping.map(u);N!==u&&(u=N,h=Pc(k,u))}return A}},view:S=>{var A;return e.draggable=!0,e.style.pointerEvents="auto",(A=n.view.dom.parentElement)==null||A.appendChild(a),a.style.pointerEvents="none",a.style.position="absolute",a.style.top="0",a.style.left="0",{update(x,k){if(!e)return;if(!n.isEditable){g();return}if(c?e.draggable=!1:e.draggable=!0,S.state.doc.eq(k.doc)||u===-1)return;let v=S.nodeDOM(u);if(v=Dm(S,v),v===S.dom||v?.nodeType!==1)return;const T=S.posAtDOM(v,0),N=Om(n.state.doc,T),H=Rm(n.state.doc,T);d=N,u=H,h=Pc(S.state,u),i?.({editor:n,node:d,pos:u}),b(v)},destroy(){f&&(cancelAnimationFrame(f),f=null,p=null),e&&Rx(a)}}},props:{handleDOMEvents:{keydown(S){return!e||c||S.hasFocus()&&(g(),d=null,u=-1,i?.({editor:n,node:null,pos:-1})),!1},mouseleave(S,A){return c||A.target&&!a.contains(A.relatedTarget)&&(g(),d=null,u=-1,i?.({editor:n,node:null,pos:-1})),!1},mousemove(S,A){return!e||c||(p={x:A.clientX,y:A.clientY},f)||(f=requestAnimationFrame(()=>{if(f=null,!p)return;const{x,y:k}=p;p=null;const v=_x({x,y:k,editor:n});if(!v.resultElement)return;let T=v.resultElement;if(T=Dm(S,T),T===S.dom||T?.nodeType!==1)return;const N=S.posAtDOM(T,0),H=Om(n.state.doc,N);if(H!==d){const V=Rm(n.state.doc,N);d=H,u=V,h=Pc(S.state,u),i?.({editor:n,node:d,pos:u}),b(T),y()}})),!1}}}})}},Wd={placement:"left-start",strategy:"absolute"},VD=de.create({name:"dragHandle",addOptions(){return{render(){const t=document.createElement("div");return t.classList.add("drag-handle"),t},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0}},addCommands(){return{lockDragHandle:()=>({editor:t})=>(this.options.locked=!0,t.commands.setMeta("lockDragHandle",this.options.locked)),unlockDragHandle:()=>({editor:t})=>(this.options.locked=!1,t.commands.setMeta("lockDragHandle",this.options.locked)),toggleDragHandle:()=>({editor:t})=>(this.options.locked=!this.options.locked,t.commands.setMeta("lockDragHandle",this.options.locked))}},addProseMirrorPlugins(){const t=this.options.render();return[Dx({computePositionConfig:{...Wd,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:t,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd}).plugin]}}),WD=VD;function qD(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 s={className:"subst",begin:/\$\(/,end:/\)/,contains:[t.BACKSLASH_ESCAPE]},i=t.inherit(t.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},l={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,n,s]};s.contains.push(l);const a={match:/\\"/},c={className:"string",begin:/'/,end:/'/},d={match:/\\'/},u={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},t.NUMBER_MODE,n]},h=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],f=t.SHEBANG({binary:`(${h.join("|")})`,relevance:10}),p={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[t.inherit(t.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},g=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],y=["true","false"],b={match:/(\/[a-z._-]+)+/},w=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],M=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],S=["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"],A=["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","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:g,literal:y,built_in:[...w,...M,"set","shopt",...S,...A]},contains:[f,t.SHEBANG(),p,u,i,o,b,l,a,c,d,n]}}const KD=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_-]*/}}),GD=["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","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],JD=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],YD=[...GD,...JD],XD=["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"].sort().reverse(),ZD=["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"].sort().reverse(),QD=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),eL=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","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-end-end-radius","border-end-start-radius","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-start-end-radius","border-start-start-radius","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-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","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","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","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","margin-trim","marker","marker-end","marker-mid","marker-start","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","masonry-auto-flow","math-depth","math-shift","math-style","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","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-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","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","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","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function tL(t){const e=t.regex,n=KD(t),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},s="and or not only",i=/@-?\w[\w]*(-\w+)*/,o="[a-zA-Z-][a-zA-Z0-9_-]*",l=[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:":("+ZD.join("|")+")"},{begin:":(:)?("+QD.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+eL.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...l,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...l,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:e.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:XD.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...l,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+YD.join("|")+")\\b"}]}}const Lm="[A-Za-z$_][0-9A-Za-z$_]*",nL=["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","using"],rL=["true","false","null","undefined","NaN","Infinity"],Lx=["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"],Ix=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],jx=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],sL=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],iL=[].concat(jx,Lx,Ix);function oL(t){const e=t.regex,n=(F,{after:ue})=>{const xe="</"+F[0].slice(1);return F.input.indexOf(xe,ue)!==-1},r=Lm,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(F,ue)=>{const xe=F[0].length+F.index,_=F.input[xe];if(_==="<"||_===","){ue.ignoreMatch();return}_===">"&&(n(F,{after:xe})||ue.ignoreMatch());let Z;const fe=F.input.substring(xe);if(Z=fe.match(/^\s*=/)){ue.ignoreMatch();return}if((Z=fe.match(/^\s+extends\s+/))&&Z.index===0){ue.ignoreMatch();return}}},l={$pattern:Lm,keyword:nL,literal:rL,built_in:iL,"variable.language":sL},a="[0-9](_?[0-9])*",c=`\\.(${a})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",u={className:"number",variants:[{begin:`(\\b(${d})((${c})|\\.)?|(${c}))[eE][+-]?(${a})\\b`},{begin:`\\b(${d})\\b((${c})\\b|\\.)?|(${c})\\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},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},f={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},p={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"css"}},g={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,h]},w={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]},M=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,g,y,{match:/\$\d+/},u];h.contains=M.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(M)});const S=[].concat(w,h.contains),A=S.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(S)}]),x={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:A},k={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"}}]},v={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:{_:[...Lx,...Ix]}},T={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:[x],illegal:/%/},H={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function V(F){return e.concat("(?!",F.join("|"),")")}const $={match:e.concat(/\b/,V([...jx,"super","import"].map(F=>`${F}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},I={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},j={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},x]},Q="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",ie={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(Q)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[x]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:A,CLASS_REFERENCE:v},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),T,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,g,y,w,{match:/\$\d+/},u,v,{scope:"attr",match:r+e.lookahead(":"),relevance:0},ie,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[w,t.REGEXP_MODE,{className:"function",begin:Q,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:A}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{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:[x,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},I,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[x]},$,H,k,j,{match:/\$[(.]/}]}}function lL(t){const e={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],s={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[e,n,t.QUOTE_STRING_MODE,s,t.C_NUMBER_MODE,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function aL(t){const e=t.regex,n=new RegExp("[\\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"],l={$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"]},a={className:"meta",begin:/^(>>>|\.\.\.) /},c={className:"subst",begin:/\{/,end:/\}/,keywords:l,illegal:/#/},d={begin:/\{\{/,relevance:0},u={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,a,d,c]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,a,d,c]},{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,d,c]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,d,c]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},h="[0-9](_?[0-9])*",f=`(\\b(${h}))?\\.(${h})|\\b(${h})\\.`,p=`\\b|${r.join("|")}`,g={className:"number",relevance:0,variants:[{begin:`(\\b(${h})|(${f}))[eE][+-]?(${h})[jJ]?(?=${p})`},{begin:`(${f})[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(${h})[jJ](?=${p})`}]},y={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:l,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},b={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:["self",a,g,u,t.HASH_COMMENT_MODE]}]};return c.contains=[u,g,a],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:l,illegal:/(<\/|\?)|=>/,contains:[a,g,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},u,y,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[b]},{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:[g,b,u]}]}}function cL(t){const e=t.regex,n=t.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},s={begin:/"/,end:/"/,contains:[{match:/""/}]},i=["true","false","unknown"],o=["double precision","large object","with timezone","without timezone"],l=["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"],a=["add","asc","collation","desc","final","first","last","view"],c=["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"],d=["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"],u=["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"],h=["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"],f=d,p=[...c,...a].filter(A=>!d.includes(A)),g={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},y={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},b={match:e.concat(/\b/,e.either(...f),/\s*\(/),relevance:0,keywords:{built_in:f}};function w(A){return e.concat(/\b/,e.either(...A.map(x=>x.replace(/\s+/,"\\s+"))),/\b/)}const M={scope:"keyword",match:w(h),relevance:0};function S(A,{exceptions:x,when:k}={}){const v=k;return x=x||[],A.map(T=>T.match(/\|\d+$/)||x.includes(T)?T:v(T)?`${T}|0`:T)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:S(p,{when:A=>A.length<3}),literal:i,type:l,built_in:u},contains:[{scope:"type",match:w(o)},M,b,g,r,s,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,y]}}const Kl="[A-Za-z$_][0-9A-Za-z$_]*",Px=["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","using"],Bx=["true","false","null","undefined","NaN","Infinity"],$x=["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"],Hx=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],zx=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Fx=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Ux=[].concat(zx,$x,Hx);function dL(t){const e=t.regex,n=(F,{after:ue})=>{const xe="</"+F[0].slice(1);return F.input.indexOf(xe,ue)!==-1},r=Kl,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(F,ue)=>{const xe=F[0].length+F.index,_=F.input[xe];if(_==="<"||_===","){ue.ignoreMatch();return}_===">"&&(n(F,{after:xe})||ue.ignoreMatch());let Z;const fe=F.input.substring(xe);if(Z=fe.match(/^\s*=/)){ue.ignoreMatch();return}if((Z=fe.match(/^\s+extends\s+/))&&Z.index===0){ue.ignoreMatch();return}}},l={$pattern:Kl,keyword:Px,literal:Bx,built_in:Ux,"variable.language":Fx},a="[0-9](_?[0-9])*",c=`\\.(${a})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",u={className:"number",variants:[{begin:`(\\b(${d})((${c})|\\.)?|(${c}))[eE][+-]?(${a})\\b`},{begin:`\\b(${d})\\b((${c})\\b|\\.)?|(${c})\\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},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},f={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},p={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"css"}},g={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,h]},w={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]},M=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,g,y,{match:/\$\d+/},u];h.contains=M.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(M)});const S=[].concat(w,h.contains),A=S.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(S)}]),x={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:A},k={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"}}]},v={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:{_:[...$x,...Hx]}},T={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:[x],illegal:/%/},H={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function V(F){return e.concat("(?!",F.join("|"),")")}const $={match:e.concat(/\b/,V([...zx,"super","import"].map(F=>`${F}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},I={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},j={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},x]},Q="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",ie={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(Q)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[x]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:A,CLASS_REFERENCE:v},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),T,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,g,y,w,{match:/\$\d+/},u,v,{scope:"attr",match:r+e.lookahead(":"),relevance:0},ie,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[w,t.REGEXP_MODE,{className:"function",begin:Q,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:A}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{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:[x,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},I,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[x]},$,H,k,j,{match:/\$[(.]/}]}}function uL(t){const e=t.regex,n=dL(t),r=Kl,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},o={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},l={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},a=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],c={$pattern:Kl,keyword:Px.concat(a),literal:Bx,built_in:Ux.concat(s),"variable.language":Fx},d={className:"meta",begin:"@"+r},u=(g,y,b)=>{const w=g.contains.findIndex(M=>M.label===y);if(w===-1)throw new Error("can not find mode to replace");g.contains.splice(w,1,b)};Object.assign(n.keywords,c),n.exports.PARAMS_CONTAINS.push(d);const h=n.contains.find(g=>g.scope==="attr"),f=Object.assign({},h,{match:e.concat(r,e.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,h,f]),n.contains=n.contains.concat([d,i,o,f]),u(n,"shebang",t.SHEBANG()),u(n,"use_strict",l);const p=n.contains.find(g=>g.label==="func.def");return p.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function hL(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,s={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=t.inherit(i,{begin:/\(/,end:/\)/}),l=t.inherit(t.APOS_STRING_MODE,{className:"string"}),a=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),c={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[s]},{begin:/'/,end:/'/,contains:[s]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[i,a,l,o,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,o,a,l]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[a]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[c],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[c],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:e.concat(/</,e.lookahead(e.concat(n,e.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:c}]},{className:"tag",begin:e.concat(/<\//,e.lookahead(e.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}const Im={},fL="hljs-";function pL(t){const e=a0.newInstance();return t&&i(t),{highlight:n,highlightAuto:r,listLanguages:s,register:i,registerAlias:o,registered:l};function n(a,c,d){const u=d||Im,h=typeof u.prefix=="string"?u.prefix:fL;if(!e.getLanguage(a))throw new Error("Unknown language: `"+a+"` is not registered");e.configure({__emitter:mL,classPrefix:h});const f=e.highlight(c,{ignoreIllegals:!0,language:a});if(f.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:f.errorRaised});const p=f._emitter.root,g=p.data;return g.language=f.language,g.relevance=f.relevance,p}function r(a,c){const u=(c||Im).subset||s();let h=-1,f=0,p;for(;++h<u.length;){const g=u[h];if(!e.getLanguage(g))continue;const y=n(g,a,c);y.data&&y.data.relevance!==void 0&&y.data.relevance>f&&(f=y.data.relevance,p=y)}return p||{type:"root",children:[],data:{language:void 0,relevance:f}}}function s(){return e.listLanguages()}function i(a,c){if(typeof a=="string")e.registerLanguage(a,c);else{let d;for(d in a)Object.hasOwn(a,d)&&e.registerLanguage(d,a[d])}}function o(a,c){if(typeof a=="string")e.registerAliases(typeof c=="string"?c:[...c],{languageName:a});else{let d;for(d in a)if(Object.hasOwn(a,d)){const u=a[d];e.registerAliases(typeof u=="string"?u:[...u],{languageName:d})}}}function l(a){return!!e.getLanguage(a)}}class mL{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],s=e.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:s}):r.children.push(...s)}openNode(e){const n=this,r=e.split(".").map(function(o,l){return l?o+"_".repeat(l):n.options.classPrefix+o}),s=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:r},children:[]};s.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const Vx=de.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:[]}},addProseMirrorPlugins(){const t=new ye("trailingNode");return[new me({key:t,appendTransaction:(e,n,r)=>{if(!e.some(h=>h.docChanged))return null;const{doc:i,schema:o}=r,l=i.lastChild,a=this.options.node,c=o.nodes[a];if(!c||l?.type.name===a||l&&this.options.notAfter.includes(l.type.name))return null;const d=i.content.size;return r.tr.insert(d,c.create())}})]}});var gL=tT;const yL=t=>{const{editor:e,pos:n}=t,r=e.state.doc.resolve(Math.max(n,0));return r.depth>0?r.node(r.depth-1):null},bL=t=>{const e='Press "/" to insert or start typing...',{node:n}=t,r=n.type.name,s=yL(t);if(r==="heading"){const i=n.attrs.level??1;switch(i){case 1:return"Add a title...";case 2:return"Add a section heading...";case 3:return"Add a subheading...";default:return`Heading ${i}`}}if(r==="taskItem")return"Add a task...";if(r==="listItem"){const i=s?.type.name;return i==="bulletList"?"Add a bullet...":i==="orderedList"?"Add a numbered item...":"Add a list item..."}if(r==="codeBlock"){const i=n.attrs.language;return i?`Write ${i} code...`:"Write some code..."}if(r==="paragraph"){const i=s?.type.name;if(!i||i==="doc")return e}return r==="doc"?e:""},Wx=gL.extend({addOptions(){return{...this.parent?.(),emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",includeChildren:!0,showOnlyCurrent:!0,showOnlyWhenEditable:!0,placeholder:e=>bL(e)}},addProseMirrorPlugins(){const t=new Set(["table","tableCell","tableHeader","tableRow"]),e=n=>{const r=this.editor.state.doc.resolve(n);for(let s=r.depth;s>=0;s-=1){const i=r.node(s);if(t.has(i.type.name))return!0}return!1};return[new me({key:new ye("placeholder"),props:{decorations:({doc:n,selection:r})=>{if(!(this.editor.isEditable||!this.options.showOnlyWhenEditable))return null;const{anchor:i}=r,o=[],l=this.editor.isEmpty;return n.descendants((a,c)=>{if(e(c))return this.options.includeChildren;const d=i>=c&&i<=c+a.nodeSize,u=!a.isLeaf&&Li(a);if((d||!this.options.showOnlyCurrent)&&u){const h=[this.options.emptyNodeClass];l&&h.push(this.options.emptyEditorClass);const f=typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:c,hasAnchor:d}):this.options.placeholder,p=_e.node(c,c+a.nodeSize,{class:h.join(" "),"data-placeholder":f});o.push(p)}return this.options.includeChildren}),o.length?be.create(n,o):null}}})]}}),xL=({node:t,updateAttributes:e,editor:n})=>{const[r,s]=C.useState(!1),{type:i,title:o,message:l,align:a,size:c,textAlign:d}=t.attrs,u={info:"bg-blue-50 text-blue-900 border-2 border-blue-200 dark:bg-blue-900/20 dark:text-blue-100 dark:border-blue-800",warning:"bg-yellow-50 text-yellow-900 border-2 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-100 dark:border-yellow-800",error:"bg-red-50 text-red-900 border-2 border-red-200 dark:bg-red-900/20 dark:text-red-100 dark:border-red-800",success:"bg-green-50 text-green-900 border-2 border-green-200 dark:bg-green-900/20 dark:text-green-100 dark:border-green-800"},h={small:"text-sm p-2",medium:"text-base p-3",large:"text-lg p-4"},f={left:"text-left",center:"text-center",right:"text-right"},p={left:"text-left",center:"text-center",right:"text-right"};return m.jsxs(Iu,{children:[m.jsx("div",{className:`${f[a]||"text-left"} cursor-grab`,onClick:()=>s(!0),"data-drag-handle":!0,children:m.jsxs("div",{className:`inline-block rounded-lg border p-2 m-1 ${u[i]||u.info} ${h[c]||h["fit-content"]} ${p[d]||p.left}`,children:[m.jsx("strong",{className:"font-bold block",children:o}),m.jsx("span",{children:l})]})}),r&&m.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center",onClick:()=>s(!1),children:m.jsxs("div",{className:"bg-white p-6 rounded-lg shadow-xl w-full max-w-md",onClick:g=>g.stopPropagation(),children:[m.jsx("h3",{className:"text-xl font-semibold mb-4 text-gray-800",children:"Edit Alert"}),m.jsxs("div",{className:"space-y-4",children:[m.jsxs("div",{children:[m.jsx("label",{htmlFor:"title",className:"block text-sm font-medium text-gray-700 mb-1",children:"Title"}),m.jsx("input",{type:"text",id:"title",defaultValue:o,onBlur:g=>e({title:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"message",className:"block text-sm font-medium text-gray-700 mb-1",children:"Message"}),m.jsx("textarea",{id:"message",defaultValue:l,onBlur:g=>e({message:g.target.value}),rows:3,className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"type",className:"block text-sm font-medium text-gray-700 mb-1",children:"Type"}),m.jsxs("select",{id:"type",defaultValue:i,onChange:g=>e({type:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"info",children:"Info"}),m.jsx("option",{value:"warning",children:"Warning"}),m.jsx("option",{value:"error",children:"Error"}),m.jsx("option",{value:"success",children:"Success"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"align",className:"block text-sm font-medium text-gray-700 mb-1",children:"Alignment"}),m.jsxs("select",{id:"align",defaultValue:a,onChange:g=>e({align:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"left",children:"Left"}),m.jsx("option",{value:"center",children:"Center"}),m.jsx("option",{value:"right",children:"Right"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"size",className:"block text-sm font-medium text-gray-700 mb-1",children:"Size"}),m.jsxs("select",{id:"size",defaultValue:c,onChange:g=>e({size:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"small",children:"Small"}),m.jsx("option",{value:"medium",children:"Medium"}),m.jsx("option",{value:"large",children:"Large"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"textAlign",className:"block text-sm font-medium text-gray-700 mb-1",children:"Text Alignment"}),m.jsxs("select",{id:"textAlign",defaultValue:d,onChange:g=>e({textAlign:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"left",children:"Left"}),m.jsx("option",{value:"center",children:"Center"}),m.jsx("option",{value:"right",children:"Right"})]})]})]}),m.jsx("div",{className:"mt-6 flex justify-end",children:m.jsx("button",{onClick:()=>s(!1),className:"px-4 py-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500",children:"Done"})})]})})]})},qx=Oe.create({name:"alertWidget",group:"block",atom:!0,draggable:!0,defining:!0,addAttributes(){return{type:{default:"info",parseHTML:t=>t.getAttribute("data-type"),renderHTML:t=>({"data-type":t.type})},title:{default:"Alert",parseHTML:t=>t.getAttribute("data-title"),renderHTML:t=>({"data-title":t.title})},message:{default:"This is an alert message.",parseHTML:t=>t.getAttribute("data-message"),renderHTML:t=>({"data-message":t.message})},align:{default:"center",parseHTML:t=>t.getAttribute("data-align"),renderHTML:t=>({"data-align":t.align})},size:{default:"medium",parseHTML:t=>t.getAttribute("data-size"),renderHTML:t=>({"data-size":t.size})},textAlign:{default:"left",parseHTML:t=>t.getAttribute("data-text-align"),renderHTML:t=>({"data-text-align":t.textAlign})}}},parseHTML(){return[{tag:"div[data-alert-widget]",priority:52}]},renderHTML({HTMLAttributes:t}){return["div",pe(t,{"data-alert-widget":""})]},addNodeView(){return ju(xL)},addCommands(){return{setAlertWidget:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}}),wL=({node:t,updateAttributes:e,editor:n})=>{const[r,s]=C.useState(!1),{text:i,url:o,style:l,size:a,textAlign:c}=t.attrs,d={primary:"bg-primary text-primary-foreground hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80"},u={"fit-content":"w-auto","full-width":"w-full"},h={left:"text-left",center:"text-center",right:"text-right"};return m.jsxs(Iu,{children:[m.jsx("div",{className:`p-2 ${h[c]||h.left} cursor-grab`,"data-drag-handle":!0,onClick:()=>s(!0),children:m.jsx("div",{role:"button",tabIndex:0,className:`inline-block px-4 py-2 rounded-md ${d[l]} ${u[a]||u["fit-content"]}`,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),s(!0))},children:i})}),r&&m.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center",onClick:()=>s(!1),children:m.jsxs("div",{className:"bg-white p-6 rounded-lg shadow-xl w-full max-w-md",onClick:f=>f.stopPropagation(),children:[m.jsx("h3",{className:"text-xl font-semibold mb-4 text-gray-800",children:"Edit CTA Button"}),m.jsxs("div",{className:"space-y-4",children:[m.jsxs("div",{children:[m.jsx("label",{htmlFor:"text",className:"block text-sm font-medium text-gray-700 mb-1",children:"Button Text"}),m.jsx("input",{type:"text",id:"text",defaultValue:i,onBlur:f=>e({text:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"url",className:"block text-sm font-medium text-gray-700 mb-1",children:"URL"}),m.jsx("input",{type:"text",id:"url",defaultValue:o,onBlur:f=>e({url:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"style",className:"block text-sm font-medium text-gray-700 mb-1",children:"Style"}),m.jsxs("select",{id:"style",defaultValue:l,onChange:f=>e({style:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"primary",children:"Primary"}),m.jsx("option",{value:"secondary",children:"Secondary"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"size",className:"block text-sm font-medium text-gray-700 mb-1",children:"Size"}),m.jsxs("select",{id:"size",defaultValue:a,onChange:f=>e({size:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"fit-content",children:"Fit Content"}),m.jsx("option",{value:"full-width",children:"Full Width"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"textAlign",className:"block text-sm font-medium text-gray-700 mb-1",children:"Text Alignment"}),m.jsxs("select",{id:"textAlign",defaultValue:c,onChange:f=>e({textAlign:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"left",children:"Left"}),m.jsx("option",{value:"center",children:"Center"}),m.jsx("option",{value:"right",children:"Right"})]})]})]}),m.jsx("div",{className:"mt-6 flex justify-end",children:m.jsx("button",{onClick:()=>s(!1),className:"px-4 py-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500",children:"Done"})})]})})]})},Kx=Oe.create({name:"ctaWidget",group:"block",draggable:!0,atom:!0,defining:!0,addAttributes(){return{text:{default:"Click Here",parseHTML:t=>t.getAttribute("data-text"),renderHTML:t=>({"data-text":t.text})},url:{default:"#",parseHTML:t=>t.getAttribute("data-url"),renderHTML:t=>({"data-url":t.url})},style:{default:"primary",parseHTML:t=>t.getAttribute("data-style"),renderHTML:t=>({"data-style":t.style})},size:{default:"fit-content",parseHTML:t=>t.getAttribute("data-size"),renderHTML:t=>({"data-size":t.size})},textAlign:{default:"left",parseHTML:t=>t.getAttribute("data-text-align"),renderHTML:t=>({"data-text-align":t.textAlign})}}},parseHTML(){return[{tag:"div[data-cta-widget]",priority:52}]},renderHTML({HTMLAttributes:t}){return["div",pe(t,{"data-cta-widget":""})]},addNodeView(){return ju(wL)},addCommands(){return{setCtaWidget:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}});function kL(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:l}=t,a=r&&!s,c=iE(n),d=new RegExp(`\\s${c}$`),u=o?"^":"",h=s?"":c,f=a?new RegExp(`${u}${c}.*?(?=\\s${h}|$)`,"gm"):new RegExp(`${u}(?:^)?${c}[^\\s${h}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const g=l.pos-p.length,y=Array.from(p.matchAll(f)).pop();if(!y||y.input===void 0||y.index===void 0)return null;const b=y.input.slice(Math.max(0,y.index-1),y.index),w=new RegExp(`^[${i?.join("")}\0]?$`).test(b);if(i!==null&&!w)return null;const M=g+y.index;let S=M+y[0].length;return a&&d.test(p.slice(S-1,S+1))&&(y[0]+=" ",S+=1),M<l.pos&&S>=l.pos?{range:{from:M,to:S},query:y[0].slice(n.length),text:y[0]}:null}var vL=new ye("suggestion");function SL({pluginKey:t=vL,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:i=[" "],startOfLine:o=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:d="is-empty",command:u=()=>null,items:h=()=>[],render:f=()=>({}),allow:p=()=>!0,findSuggestionMatch:g=kL}){let y;const b=f?.(),w=()=>{const x=e.state.selection.$anchor.pos,k=e.view.coordsAtPos(x),{top:v,right:T,bottom:N,left:H}=k;try{return new DOMRect(H,v,T-H,N-v)}catch{return null}},M=(x,k)=>k?()=>{const v=t.getState(e.state),T=v?.decorationId,N=x.dom.querySelector(`[data-decoration-id="${T}"]`);return N?.getBoundingClientRect()||null}:w;function S(x,k){var v;try{const N=t.getState(x.state),H=N?.decorationId?x.dom.querySelector(`[data-decoration-id="${N.decorationId}"]`):null,V={editor:e,range:N?.range||{from:0,to:0},query:N?.query||null,text:N?.text||null,items:[],command:$=>u({editor:e,range:N?.range||{from:0,to:0},props:$}),decorationNode:H,clientRect:M(x,H)};(v=b?.onExit)==null||v.call(b,V)}catch{}const T=x.state.tr.setMeta(k,{exit:!0});x.dispatch(T)}const A=new me({key:t,view(){return{update:async(x,k)=>{var v,T,N,H,V,$,I;const j=(v=this.key)==null?void 0:v.getState(k),Q=(T=this.key)==null?void 0:T.getState(x.state),ie=j.active&&Q.active&&j.range.from!==Q.range.from,F=!j.active&&Q.active,ue=j.active&&!Q.active,xe=!F&&!ue&&j.query!==Q.query,_=F||ie&&xe,Z=xe||ie,fe=ue||ie&&xe;if(!_&&!Z&&!fe)return;const Se=fe&&!_?j:Q,pn=x.dom.querySelector(`[data-decoration-id="${Se.decorationId}"]`);y={editor:e,range:Se.range,query:Se.query,text:Se.text,items:[],command:fr=>u({editor:e,range:Se.range,props:fr}),decorationNode:pn,clientRect:M(x,pn)},_&&((N=b?.onBeforeStart)==null||N.call(b,y)),Z&&((H=b?.onBeforeUpdate)==null||H.call(b,y)),(Z||_)&&(y.items=await h({editor:e,query:Se.query})),fe&&((V=b?.onExit)==null||V.call(b,y)),Z&&(($=b?.onUpdate)==null||$.call(b,y)),_&&((I=b?.onStart)==null||I.call(b,y))},destroy:()=>{var x;y&&((x=b?.onExit)==null||x.call(b,y))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(x,k,v,T){const{isEditable:N}=e,{composing:H}=e.view,{selection:V}=x,{empty:$,from:I}=V,j={...k},Q=x.getMeta(t);if(Q&&Q.exit)return j.active=!1,j.decorationId=null,j.range={from:0,to:0},j.query=null,j.text=null,j;if(j.composing=H,N&&($||e.view.composing)){(I<k.range.from||I>k.range.to)&&!H&&!k.composing&&(j.active=!1);const ie=g({char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:V.$from}),F=`id_${Math.floor(Math.random()*4294967295)}`;ie&&p({editor:e,state:T,range:ie.range,isActive:k.active})?(j.active=!0,j.decorationId=k.decorationId?k.decorationId:F,j.range=ie.range,j.query=ie.query,j.text=ie.text):j.active=!1}else j.active=!1;return j.active||(j.decorationId=null,j.range={from:0,to:0},j.query=null,j.text=null),j}},props:{handleKeyDown(x,k){var v,T,N,H;const{active:V,range:$}=A.getState(x.state);if(!V)return!1;if(k.key==="Escape"||k.key==="Esc"){const j=A.getState(x.state),Q=(v=y?.decorationNode)!=null?v:null,ie=Q??(j?.decorationId?x.dom.querySelector(`[data-decoration-id="${j.decorationId}"]`):null);if(((T=b?.onKeyDown)==null?void 0:T.call(b,{view:x,event:k,range:j.range}))||!1)return!0;const ue={editor:e,range:j.range,query:j.query,text:j.text,items:[],command:xe=>u({editor:e,range:j.range,props:xe}),decorationNode:ie,clientRect:ie?()=>ie.getBoundingClientRect()||null:null};return(N=b?.onExit)==null||N.call(b,ue),S(x,t),!0}return((H=b?.onKeyDown)==null?void 0:H.call(b,{view:x,event:k,range:$}))||!1},decorations(x){const{active:k,range:v,decorationId:T,query:N}=A.getState(x);if(!k)return null;const H=!N?.length,V=[a];return H&&V.push(d),be.create(x.doc,[_e.inline(v.from,v.to,{nodeName:l,class:V.join(" "),"data-decoration-id":T,"data-decoration-content":c})])}}});return A}const CL=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),EL=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),jm=t=>{const e=EL(t);return e.charAt(0).toUpperCase()+e.slice(1)},Gx=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),ML=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var AL={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const TL=C.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:i,iconNode:o,...l},a)=>C.createElement("svg",{ref:a,...AL,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:Gx("lucide",s),...!i&&!ML(l)&&{"aria-hidden":"true"},...l},[...o.map(([c,d])=>C.createElement(c,d)),...Array.isArray(i)?i:[i]]));const X=(t,e)=>{const n=C.forwardRef(({className:r,...s},i)=>C.createElement(TL,{ref:i,iconNode:e,className:Gx(`lucide-${CL(jm(t))}`,`lucide-${t}`,r),...s}));return n.displayName=jm(t),n};const NL=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],Gl=X("bold",NL);const _L=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Pm=X("circle-alert",_L);const RL=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],OL=X("circle-check-big",RL);const DL=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],LL=X("circle-plus",DL);const IL=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],jL=X("circle-x",IL);const PL=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Nr=X("code-xml",PL);const BL=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],Rs=X("code",BL);const $L=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],HL=X("columns-2",$L);const zL=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],FL=X("columns-3",zL);const UL=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Jx=X("download",UL);const VL=[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]],WL=X("eraser",VL);const qL=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],KL=X("eye",qL);const GL=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],JL=X("file-code-2",GL);const YL=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],XL=X("hash",YL);const ZL=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],vs=X("heading-1",ZL);const QL=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],Vi=X("heading-2",QL);const eI=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],Aa=X("heading-3",eI);const tI=[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]],nI=X("heading-4",tI);const rI=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]],sI=X("heading-5",rI);const iI=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]],oI=X("heading-6",iI);const lI=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],zr=X("image",lI);const aI=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],kh=X("italic",aI);const cI=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Ta=X("link-2",cI);const dI=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],Wi=X("list-ordered",dI);const uI=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],Os=X("list",uI);const hI=[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]],Na=X("megaphone",hI);const fI=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],pI=X("menu",fI);const mI=[["path",{d:"M5 12h14",key:"1ays0h"}]],_a=X("minus",mI);const gI=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],vh=X("palette",gI);const yI=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],bI=X("play",yI);const xI=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],wI=X("redo-2",xI);const kI=[["path",{d:"M14 4a1 1 0 0 1 1-1",key:"dhj8ez"}],["path",{d:"M15 10a1 1 0 0 1-1-1",key:"1mnyi5"}],["path",{d:"M21 4a1 1 0 0 0-1-1",key:"sfs9ap"}],["path",{d:"M21 9a1 1 0 0 1-1 1",key:"mp6qeo"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a2 2 0 0 1 2-2h2",key:"15xut4"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}]],vI=X("replace",kI);const SI=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],CI=X("rotate-ccw",SI);const EI=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]],MI=X("rows-2",EI);const AI=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],TI=X("rows-3",AI);const NI=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],_I=X("search",NI);const RI=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ra=X("square-check-big",RI);const OI=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],Yx=X("strikethrough",OI);const DI=[["path",{d:"m4 5 8 8",key:"1eunvl"}],["path",{d:"m12 5-8 8",key:"1ah0jp"}],["path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07",key:"e8ta8j"}]],Xx=X("subscript",DI);const LI=[["path",{d:"m4 19 8-8",key:"hr47gm"}],["path",{d:"m12 19-8-8",key:"1dhhmo"}],["path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06",key:"1dfcux"}]],Zx=X("superscript",LI);const II=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],qi=X("table-2",II);const jI=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],PI=X("terminal",jI);const BI=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Ki=X("text-align-center",BI);const $I=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Gi=X("text-align-end",$I);const HI=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],Sh=X("text-align-justify",HI);const zI=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Ss=X("text-align-start",zI);const FI=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],Ji=X("text-quote",FI);const UI=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Qx=X("trash-2",UI);const VI=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Oa=X("triangle-alert",VI);const WI=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],Wr=X("type",WI);const qI=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Ch=X("underline",qI);const KI=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],GI=X("undo-2",KI);const JI=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],ew=X("video",JI);const YI=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],tw=X("x",YI),Eh=C.forwardRef(({items:t,command:e},n)=>{const[r,s]=C.useState(-1),i=C.useRef(null),o=a=>{const c=t[a];c&&e(c)};C.useEffect(()=>{if(t.length===0){s(-1);return}s(a=>{if(a===-1)return-1;const c=Math.min(Math.max(a,0),t.length-1);return Number.isFinite(c)?c:-1})},[t]),C.useEffect(()=>{if(!i.current||r===-1)return;const a=i.current.querySelector(`[data-index="${r}"]`);a&&a.scrollIntoView({block:"nearest"})},[r]),C.useImperativeHandle(n,()=>({onKeyDown:({event:a})=>t.length===0?!1:a.key==="ArrowUp"?(a.preventDefault(),s(c=>c===-1?t.length-1:(c-1+t.length)%t.length),!0):a.key==="ArrowDown"?(a.preventDefault(),s(c=>c===-1?0:(c+1)%t.length),!0):a.key==="Enter"?(a.preventDefault(),r!==-1&&o(r),!0):!1}));const l=a=>{a.stopPropagation()};return m.jsx("div",{ref:i,className:"z-50 max-h-72 w-72 overflow-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md",role:"listbox","aria-activedescendant":r!==-1?`cmd-opt-${r}`:void 0,tabIndex:-1,onWheel:l,style:{scrollbarWidth:"thin",scrollbarColor:"rgb(148 163 184) transparent"},children:t.length>0?t.map((a,c)=>{const d=r!==-1&&c===r;return m.jsxs("button",{id:`cmd-opt-${c}`,"data-index":c,role:"option","aria-selected":d,type:"button",onMouseDown:u=>u.preventDefault(),onClick:()=>o(c),className:De.cn("flex w-full items-center gap-2 rounded-sm p-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",d&&"bg-accent text-accent-foreground"),children:[m.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border bg-background",children:a.icon}),m.jsxs("div",{className:"min-w-0",children:[m.jsx("p",{className:"truncate font-medium",children:a.title}),a.description?m.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a.description}):null]})]},`${a.title}-${c}`)}):m.jsx("div",{className:"p-2 text-sm text-muted-foreground",children:"No results"})})});Eh.displayName="SlashCommandList";const XI=[{title:"Text",description:"Start writing with plain text.",icon:C.createElement(Wr,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).clearNodes().run()}},{title:"Heading 1",description:"Large section heading.",icon:C.createElement(vs,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:1}).run()}},{title:"Heading 2",description:"Medium section heading.",icon:C.createElement(Vi,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:2}).run()}},{title:"Heading 3",description:"Small section heading.",icon:C.createElement(Aa,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:3}).run()}},{title:"Heading 4",description:"Extra small section heading.",icon:C.createElement(nI,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:4}).run()}},{title:"Heading 5",description:"Tiny section heading.",icon:C.createElement(sI,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:5}).run()}},{title:"Heading 6",description:"Smallest section heading.",icon:C.createElement(oI,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:6}).run()}},{title:"Bullet List",description:"Create a simple bulleted list.",icon:C.createElement(Os,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBulletList().run()}},{title:"Numbered List",description:"Create a list with numbering.",icon:C.createElement(Wi,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleOrderedList().run()}},{title:"Task List",description:"Create a list with checkboxes.",icon:C.createElement(Ra,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleTaskList().run()}},{title:"Blockquote",description:"Create a quote or citation.",icon:C.createElement(Ji,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBlockquote().run()}},{title:"Code Block",description:"Create a code block with syntax highlighting.",icon:C.createElement(Rs,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleCodeBlock().run()}},{title:"Horizontal Rule",description:"Insert a horizontal divider.",icon:C.createElement(_a,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHorizontalRule().run()}},{title:"Image",description:"Insert an image from URL.",icon:C.createElement(zr,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{const n=window.prompt("Enter image URL:");n&&t.chain().focus().deleteRange(e).setImage({src:n}).run()}},{title:"Table",description:"Insert a table with rows and columns.",icon:C.createElement(qi,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{title:"Align Left",description:"Align text to the left.",icon:C.createElement(Ss,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("left").run()}},{title:"Align Center",description:"Center align text.",icon:C.createElement(Ki,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("center").run()}},{title:"Align Right",description:"Align text to the right.",icon:C.createElement(Gi,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("right").run()}},{title:"Justify",description:"Justify text alignment.",icon:C.createElement(Sh,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("justify").run()}},{title:"Video",description:"Embed a video from URL.",icon:C.createElement(ew,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{const n=window.prompt("Enter video URL (YouTube, Vimeo, etc.):");n&&t.chain().focus().deleteRange(e).insertContent(`<p><a href="${n}" target="_blank">Video: ${n}</a></p>`).run()}},{title:"Alert",description:"Insert an alert or notice.",icon:C.createElement(Oa,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.can().setAlertWidget()?t.chain().focus().deleteRange(e).setAlertWidget().run():t.chain().focus().deleteRange(e).toggleBlockquote().run()}},{title:"Call to Action",description:"Insert a call to action button.",icon:C.createElement(Na,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.can().setCtaWidget()?t.chain().focus().deleteRange(e).setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}).run():t.chain().focus().deleteRange(e).insertContent("Call to Action").run()}}],nw=de.create({name:"slashCommand",addOptions(){return{suggestion:{char:"/",allowSpaces:!1,allowedPrefixes:[" "],startOfLine:!1,decorationTag:"span",decorationClass:"slash-command"}}},addProseMirrorPlugins(){return[SL({char:"/",allowSpaces:!1,allowedPrefixes:[" "],startOfLine:!1,decorationTag:"span",decorationClass:"slash-command",editor:this.editor,items:({query:t})=>XI.filter(n=>n.title.toLowerCase().includes(t.toLowerCase())||n.description.toLowerCase().includes(t.toLowerCase())).slice(0,10),command:({editor:t,range:e,props:n})=>{n.command({editor:t,range:e})},render:()=>{let t=null,e=null,n=null;const r=i=>({getBoundingClientRect:()=>i()||new DOMRect(0,0,0,0)}),s=async i=>{if(!e)return;const o=r(i),{x:l,y:a}=await Fu(o,e,{placement:"bottom-start",middleware:[zu(6),Ab({fallbackPlacements:["top-start","bottom-start"]}),Mb({padding:8}),Tb({apply({availableWidth:c,availableHeight:d,elements:u}){Object.assign(u.floating.style,{maxWidth:`${Math.min(288,c-16)}px`,maxHeight:`${Math.min(288,d-16)}px`})}})],strategy:"fixed"});e.style.left=`${Math.round(l)}px`,e.style.top=`${Math.round(a)}px`};return{onStart:i=>{if(!i.clientRect)return;const o=i.clientRect;t=new pb(Eh,{props:i,editor:i.editor}),e=document.createElement("div"),e.style.position="fixed",e.style.zIndex="10000",e.style.top="0",e.style.left="0",e.style.pointerEvents="none",e.appendChild(t.element),t.element.style.pointerEvents="auto",t.element.addEventListener("wheel",a=>{a.stopPropagation()},{passive:!0}),document.body.appendChild(e);const l=r(o);n=Ms(l,e,()=>s(o)),s(o)},onUpdate:i=>{t?.updateProps(i),i.clientRect&&s(i.clientRect)},onKeyDown:({event:i})=>i.key==="Escape"?!0:t?.ref?.onKeyDown({event:i})??!1,onExit:()=>{n?.(),n=null,t?.destroy(),t=null,e?.remove(),e=null}}}})]}});var ZI=Zu,QI=eh;NA.extend({draggable:!0});zM.extend({draggable:!0});AM.extend({draggable:!0});ZI.extend({draggable:!0});QI.extend({draggable:!0});h0.extend({draggable:!0});f0.extend({draggable:!0});d0.extend({draggable:!0});u0.extend({draggable:!0});const rw=de.create({name:"draggableNodes",addGlobalAttributes(){return[{types:["paragraph","heading","blockquote","bulletList","orderedList","taskList","taskItem","codeBlock","image"],attributes:{draggable:{default:!0,parseHTML:()=>!0,renderHTML:()=>({"data-draggable":"true"})}}}]}}),e2=Oe.create({name:"styleTag",group:"block",atom:!0,isolating:!0,defining:!0,draggable:!1,addAttributes(){return{cssContent:{default:"",parseHTML:t=>t.innerHTML},type:{default:"text/css",parseHTML:t=>t.getAttribute("type"),renderHTML:t=>t.type?{type:t.type}:{}},media:{default:null,parseHTML:t=>t.getAttribute("media"),renderHTML:t=>t.media?{media:t.media}:{}}}},parseHTML(){return[{tag:"style",getAttrs:t=>{const e=t,n={cssContent:e.innerHTML,type:e.getAttribute("type")},r=e.getAttribute("media");return r!==null&&(n.media=r),n}}]},renderHTML({HTMLAttributes:t,node:e}){const n={...t};return delete n.cssContent,["style",n,e.attrs.cssContent||""]},addNodeView(){return({node:t,editor:e,getPos:n})=>{const r=document.createElement("div");return r.setAttribute("data-style-node-placeholder","true"),r.style.border="1px dashed #999",r.style.padding="8px",r.style.margin="1rem 0",r.style.fontFamily="monospace",r.style.fontSize="0.9em",r.style.color="#555",r.style.cursor="pointer",r.textContent="[Custom CSS Block - Edit in Source View]",r.contentEditable="false",r.title="Click to open Source View",r.addEventListener("click",()=>{try{e?.chain().focus()}catch{}try{window.dispatchEvent(new CustomEvent("editor:openSourceView"))}catch{}}),{dom:r}}}}),t2=Oe.create({name:"divBlock",group:"block",content:"block*",defining:!0,draggable:!0,addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}},id:{default:null,parseHTML:t=>t.getAttribute("id"),renderHTML:t=>t.id?{id:t.id}:{}}}},parseHTML(){return[{tag:"div",priority:51,getAttrs:t=>{const e=t,n={};for(let r=0;r<e.attributes.length;r++){const s=e.attributes[r];n[s.name]=s.value}return n}}]},renderHTML({node:t}){return["div",pe(this.options.HTMLAttributes,t.attrs),0]}}),n2=de.create({name:"preserveAllAttributesExtension",addGlobalAttributes(){return[{types:["paragraph","heading","listItem","blockquote","codeBlock","bulletList","orderedList","textStyle"],attributes:{style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}},class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},id:{default:null,parseHTML:t=>t.getAttribute("id"),renderHTML:t=>t.id?{id:t.id}:{}},dataAttributes:{default:null,parseHTML:t=>{const e={};for(let n=0;n<t.attributes.length;n++){const r=t.attributes[n];r.name.startsWith("data-")&&(e[r.name]=r.value)}return Object.keys(e).length>0?e:null},renderHTML:t=>t.dataAttributes||{}}}}]}}),r2=Oe.create({name:"scriptTag",group:"block",atom:!0,isolating:!0,defining:!0,draggable:!1,addAttributes(){return{jsContent:{default:"",parseHTML:t=>t.innerHTML},type:{default:"text/javascript",parseHTML:t=>t.getAttribute("type"),renderHTML:t=>t.type?{type:t.type}:{}},src:{default:null,parseHTML:t=>t.getAttribute("src"),renderHTML:t=>t.src?{src:t.src}:{}},async:{default:null,parseHTML:t=>t.getAttribute("async"),renderHTML:t=>t.async!=null?{async:""}:{}},defer:{default:null,parseHTML:t=>t.getAttribute("defer"),renderHTML:t=>t.defer!=null?{defer:""}:{}}}},parseHTML(){return[{tag:"script",getAttrs:t=>{const e=t,n={jsContent:e.innerHTML,type:e.getAttribute("type")},r=e.getAttribute("src");return r!==null&&(n.src=r),e.hasAttribute("async")&&(n.async=""),e.hasAttribute("defer")&&(n.defer=""),n}}]},renderHTML({HTMLAttributes:t,node:e}){const n={...t};return delete n.jsContent,["script",n,e.attrs.src?"":e.attrs.jsContent||""]},addNodeView(){return({editor:t})=>{const e=document.createElement("div");return e.setAttribute("data-script-node-placeholder","true"),e.style.border="1px dashed #999",e.style.padding="8px",e.style.margin="1rem 0",e.style.fontFamily="monospace",e.style.fontSize="0.9em",e.style.color="#555",e.style.cursor="pointer",e.textContent="[Custom JavaScript Block - Edit in Source View]",e.contentEditable="false",e.title="Click to open Source View",e.addEventListener("click",()=>{try{t?.chain().focus()}catch{}try{window.dispatchEvent(new CustomEvent("editor:openSourceView"))}catch{}}),{dom:e}}}}),s2=Oe.create({name:"svg",group:"inline",inline:!0,atom:!0,addOptions(){return{HTMLAttributes:{class:"inline-block align-middle"}}},addAttributes(){return{html:{default:""},viewBox:{default:"0 0 24 24"},width:{default:null},height:{default:null},fill:{default:"none"},stroke:{default:"currentColor"},class:{default:null},style:{default:null},xmlns:{default:"http://www.w3.org/2000/svg"}}},parseHTML(){return[{tag:"svg",priority:60,getAttrs:t=>{if(!(t instanceof Element))return!1;const e={html:t.innerHTML};return t.getAttribute("viewBox")&&(e.viewBox=t.getAttribute("viewBox")),t.getAttribute("width")&&(e.width=t.getAttribute("width")),t.getAttribute("height")&&(e.height=t.getAttribute("height")),t.getAttribute("fill")&&(e.fill=t.getAttribute("fill")),t.getAttribute("stroke")&&(e.stroke=t.getAttribute("stroke")),t.getAttribute("class")&&(e.class=t.getAttribute("class")),t.getAttribute("style")&&(e.style=t.getAttribute("style")),t.getAttribute("xmlns")&&(e.xmlns=t.getAttribute("xmlns")),e}}]},renderHTML({HTMLAttributes:t}){const e=document.createElementNS("http://www.w3.org/2000/svg","svg"),{html:n,...r}=t;return Object.entries(pe(this.options.HTMLAttributes,r)).forEach(([s,i])=>{i!=null&&e.setAttribute(s,String(i))}),n&&(e.innerHTML=n),{dom:e}},addNodeView(){return({node:t,HTMLAttributes:e})=>{const n=document.createElementNS("http://www.w3.org/2000/svg","svg"),{html:r,...s}=e;return Object.entries(s).forEach(([i,o])=>{i!=="html"&&o!==null&&o!==void 0&&n.setAttribute(i,String(o))}),t.attrs.html?n.innerHTML=t.attrs.html:r&&(n.innerHTML=r),n.classList.add("parsed-svg-node"),{dom:n}}}}),i2=Oe.create({name:"spanComponent",group:"inline",inline:!0,content:"inline*",addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}}}},parseHTML(){return[{tag:"span",priority:60,getAttrs:t=>t instanceof HTMLElement&&t.hasAttribute("class")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",pe(this.options.HTMLAttributes,t),0]}}),o2=pL({html:hL,css:tL,js:oL,ts:uL,python:aL,json:lL,bash:qD,sql:cL}),Bm="http://www.w3.org/2000/svg";function $m(t){const e=document.createElementNS(Bm,"svg");return e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor"),e.classList.add("tiptap-drag-handle__icon","tiptap-drag-handle__icon--filled"),t.forEach(n=>{const r=document.createElementNS(Bm,"path");r.setAttribute("d",n),e.appendChild(r)}),e}const Mh=[sT.configure({codeBlock:!1,link:!1,undoRedo:!1,bulletList:{HTMLAttributes:{class:"list-disc pl-4"},keepMarks:!0,keepAttributes:!1},orderedList:{HTMLAttributes:{class:"list-decimal pl-4"},keepMarks:!0,keepAttributes:!1},dropcursor:{color:"#60A5FA",width:2},gapcursor:!1}),bA.configure({openOnClick:!1,autolink:!0,defaultProtocol:"https",protocols:["http","https","ftp","mailto"],validate:t=>/^https?:\/\//.test(t),HTMLAttributes:{class:"text-primary underline underline-offset-2 hover:text-primary/80 cursor-pointer",rel:"noopener noreferrer",target:"_blank"}}),p_,LA,m_.configure({depth:100,newGroupDelay:500}),d0.configure({lowlight:o2,defaultLanguage:"plaintext",HTMLAttributes:{class:"relative rounded-md bg-muted p-4 font-mono text-sm"}}),t2,e2,r2,s2,i2,n2,pT.configure({inline:!0,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-md"}}),h0.configure({HTMLAttributes:{class:"list-none pl-0 space-y-1"}}),f0.configure({nested:!0,HTMLAttributes:{class:"flex items-start gap-2 my-1"}}),M0.configure({resizable:!0,cellMinWidth:100,HTMLAttributes:{class:"w-full border-collapse border border-gray-300 dark:border-gray-700 my-4"}}),kN.configure({HTMLAttributes:{class:"border-b border-gray-300 dark:border-gray-700"}}),vN.configure({HTMLAttributes:{class:"bg-gray-100 dark:bg-gray-800 font-bold p-3 text-left border border-gray-300 dark:border-gray-700"}}),SN.configure({HTMLAttributes:{class:"p-3 border border-gray-300 dark:border-gray-700 min-w-[100px]"}}),FN.configure({color:{types:["textStyle"]},fontFamily:{types:["textStyle"]},fontSize:{types:["textStyle"]}}),AN.configure({multicolor:!0,HTMLAttributes:{class:"rounded-sm px-1 py-0.5"}}),NN,RN,DN.extend({addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{if(t.style.textAlign)return t.style.textAlign;if(t.getAttribute("align"))return t.getAttribute("align");const e=t.getAttribute("class")||"";return/(?:^|\s)text-center(?:\s|$)/.test(e)?"center":/(?:^|\s)text-right(?:\s|$)/.test(e)?"right":/(?:^|\s)text-justify(?:\s|$)/.test(e)?"justify":/(?:^|\s)text-left(?:\s|$)/.test(e)?"left":null},renderHTML:t=>t.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${t.textAlign} !important`}}}}]}}).configure({types:["heading","paragraph","div"],alignments:["left","center","right","justify"],defaultAlignment:"left"}),f_,Wx,UN.configure({limit:5e4,mode:"textSize"}),Vx,qx,Kx,nw,rw,LD,WD.configure({computePositionConfig:{placement:"left-start",strategy:"absolute",middleware:[zu({mainAxis:5,crossAxis:0})]},onElementDragStart:()=>{typeof document<"u"&&document.body.classList.add("dragging")},onElementDragEnd:()=>{typeof document<"u"&&document.body.classList.remove("dragging")},onNodeChange:({editor:t})=>{},render(){const t=document.createElement("div");t.classList.add("drag-handle","tiptap-drag-handle"),typeof window<"u"&&(window.__dragHandleElement=t);const e=document.createElement("div");e.classList.add("tiptap-drag-handle__group"),e.setAttribute("role","group"),e.dataset.orientation="horizontal",t.appendChild(e);const n=document.createElement("button");n.type="button",n.classList.add("tiptap-drag-handle__button","tiptap-drag-handle__button--ghost","tiptap-drag-handle__plus"),n.setAttribute("aria-label","Insert block"),n.setAttribute("title","Insert block");const r=$m(["M13 5C13 4.44772 12.5523 4 12 4C11.4477 4 11 4.44772 11 5V11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H11V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V13H19C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11H13V5Z"]);n.appendChild(r),e.appendChild(n);const s=document.createElement("button");s.type="button",s.classList.add("tiptap-drag-handle__button","tiptap-drag-handle__button--ghost","tiptap-drag-handle__grip"),s.setAttribute("aria-label","Drag to reorder"),s.setAttribute("title","Drag to reorder"),s.setAttribute("tabindex","0"),s.setAttribute("aria-haspopup","menu"),s.setAttribute("aria-expanded","false");const i=$m(["M9 3C7.89543 3 7 3.89543 7 5C7 6.10457 7.89543 7 9 7C10.1046 7 11 6.10457 11 5C11 3.89543 10.1046 3 9 3Z","M9 10C7.89543 10 7 10.8954 7 12C7 13.1046 7.89543 14 9 14C10.1046 14 11 13.1046 11 12C11 10.8954 10.1046 10 9 10Z","M7 19C7 17.8954 7.89543 17 9 17C10.1046 17 11 17.8954 11 19C11 20.1046 10.1046 21 9 21C7.89543 21 7 20.1046 7 19Z","M15 10C13.8954 10 13 10.8954 13 12C13 13.1046 13.8954 14 15 14C16.1046 14 17 13.1046 17 12C17 10.8954 16.1046 10 15 10Z","M13 5C13 3.89543 13.8954 3 15 3C16.1046 3 17 3.89543 17 5C17 6.10457 16.1046 7 15 7C13.8954 7 13 6.10457 13 5Z","M15 17C13.8954 17 13 17.8954 13 19C13 20.1046 13.8954 21 15 21C16.1046 21 17 20.1046 17 19C17 17.8954 16.1046 17 15 17Z"]);s.appendChild(i),e.appendChild(s);const o=()=>{const l=new CustomEvent("tiptap-gutter-toggle",{bubbles:!0,detail:{handle:e,button:n}});e.dispatchEvent(l)};return n.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),o()}),n.addEventListener("keydown",l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),o())}),s.addEventListener("mousedown",()=>{s.setAttribute("aria-expanded","true")}),s.addEventListener("mouseup",()=>{s.setAttribute("aria-expanded","false")}),t}})];var l2=typeof document<"u",a2=function(){},qd=l2?C.useLayoutEffect:a2;const c2={...ne},d2=c2.useInsertionEffect,u2=d2||(t=>t());function h2(t){const e=ne.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return u2(()=>{e.current=t}),ne.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return e.current==null?void 0:e.current(...r)},[])}var f2=typeof document<"u",p2=function(){},Wo=f2?C.useLayoutEffect:p2;function Jl(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,s;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!Jl(t[r],e[r]))return!1;return!0}if(s=Object.keys(t),n=s.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,s[r]))return!1;for(r=n;r--!==0;){const i=s[r];if(!(i==="_owner"&&t.$$typeof)&&!Jl(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function sw(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Hm(t,e){const n=sw(t);return Math.round(e*n)/n}function Bc(t){const e=ne.useRef(t);return Wo(()=>{e.current=t}),e}function m2(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:o}={},transform:l=!0,whileElementsMounted:a,open:c}=t,[d,u]=ne.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[h,f]=ne.useState(r);Jl(h,r)||f(r);const[p,g]=ne.useState(null),[y,b]=ne.useState(null),w=ne.useCallback(F=>{F!==x.current&&(x.current=F,g(F))},[]),M=ne.useCallback(F=>{F!==k.current&&(k.current=F,b(F))},[]),S=i||p,A=o||y,x=ne.useRef(null),k=ne.useRef(null),v=ne.useRef(d),T=a!=null,N=Bc(a),H=Bc(s),V=Bc(c),$=ne.useCallback(()=>{if(!x.current||!k.current)return;const F={placement:e,strategy:n,middleware:h};H.current&&(F.platform=H.current),Fu(x.current,k.current,F).then(ue=>{const xe={...ue,isPositioned:V.current!==!1};I.current&&!Jl(v.current,xe)&&(v.current=xe,c1.flushSync(()=>{u(xe)}))})},[h,e,n,H,V]);Wo(()=>{c===!1&&v.current.isPositioned&&(v.current.isPositioned=!1,u(F=>({...F,isPositioned:!1})))},[c]);const I=ne.useRef(!1);Wo(()=>(I.current=!0,()=>{I.current=!1}),[]),Wo(()=>{if(S&&(x.current=S),A&&(k.current=A),S&&A){if(N.current)return N.current(S,A,$);$()}},[S,A,$,N,T]);const j=ne.useMemo(()=>({reference:x,floating:k,setReference:w,setFloating:M}),[w,M]),Q=ne.useMemo(()=>({reference:S,floating:A}),[S,A]),ie=ne.useMemo(()=>{const F={position:n,left:0,top:0};if(!Q.floating)return F;const ue=Hm(Q.floating,d.x),xe=Hm(Q.floating,d.y);return l?{...F,transform:"translate("+ue+"px, "+xe+"px)",...sw(Q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:ue,top:xe}},[n,l,Q.floating,d.x,d.y]);return ne.useMemo(()=>({...d,update:$,refs:j,elements:Q,floatingStyles:ie}),[d,$,j,Q,ie])}const Yi=(t,e)=>({...zu(t),options:[t,e]}),Da=(t,e)=>({...Mb(t),options:[t,e]}),La=(t,e)=>({...Ab(t),options:[t,e]}),g2=(t,e)=>({...Tb(t),options:[t,e]}),y2={...ne};let zm=!1,b2=0;const Fm=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+b2++;function x2(){const[t,e]=ne.useState(()=>zm?Fm():void 0);return qd(()=>{t==null&&e(Fm())},[]),ne.useEffect(()=>{zm=!0},[]),t}const w2=y2.useId,k2=w2||x2;let Kd;process.env.NODE_ENV!=="production"&&(Kd=new Set);function v2(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((t=Kd)!=null&&t.has(s))){var i;(i=Kd)==null||i.add(s),console.error(s)}}function S2(){const t=new Map;return{emit(e,n){var r;(r=t.get(e))==null||r.forEach(s=>s(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var r;(r=t.get(e))==null||r.delete(n)}}}const C2=ne.createContext(null),E2=ne.createContext(null),M2=()=>{var t;return((t=ne.useContext(C2))==null?void 0:t.id)||null},A2=()=>ne.useContext(E2);function T2(t){const{open:e=!1,onOpenChange:n,elements:r}=t,s=k2(),i=ne.useRef({}),[o]=ne.useState(()=>S2()),l=M2()!=null;if(process.env.NODE_ENV!=="production"){const f=r.reference;f&&!ut(f)&&v2("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[a,c]=ne.useState(r.reference),d=h2((f,p,g)=>{i.current.openEvent=f?p:void 0,o.emit("openchange",{open:f,event:p,reason:g,nested:l}),n?.(f,p,g)}),u=ne.useMemo(()=>({setPositionReference:c}),[]),h=ne.useMemo(()=>({reference:a||r.reference||null,floating:r.floating||null,domReference:r.reference}),[a,r.reference,r.floating]);return ne.useMemo(()=>({dataRef:i,open:e,onOpenChange:d,elements:h,events:o,floatingId:s,refs:u}),[e,d,h,o,s,u])}function Xi(t){t===void 0&&(t={});const{nodeId:e}=t,n=T2({...t,elements:{reference:null,floating:null,...t.elements}}),r=t.rootContext||n,s=r.elements,[i,o]=ne.useState(null),[l,a]=ne.useState(null),d=s?.domReference||i,u=ne.useRef(null),h=A2();qd(()=>{d&&(u.current=d)},[d]);const f=m2({...t,elements:{...s,...l&&{reference:l}}}),p=ne.useCallback(M=>{const S=ut(M)?{getBoundingClientRect:()=>M.getBoundingClientRect(),getClientRects:()=>M.getClientRects(),contextElement:M}:M;a(S),f.refs.setReference(S)},[f.refs]),g=ne.useCallback(M=>{(ut(M)||M===null)&&(u.current=M,o(M)),(ut(f.refs.reference.current)||f.refs.reference.current===null||M!==null&&!ut(M))&&f.refs.setReference(M)},[f.refs]),y=ne.useMemo(()=>({...f.refs,setReference:g,setPositionReference:p,domReference:u}),[f.refs,g,p]),b=ne.useMemo(()=>({...f.elements,domReference:d}),[f.elements,d]),w=ne.useMemo(()=>({...f,...r,refs:y,elements:b,nodeId:e}),[f,y,b,e,r]);return qd(()=>{r.dataRef.current.floatingContext=w;const M=h?.nodesRef.current.find(S=>S.id===e);M&&(M.context=w)}),ne.useMemo(()=>({...f,context:w,refs:y,elements:b}),[f,y,b,w])}const N2="_pickerRoot_1wq30_1",_2="_picker_1wq30_1",Um={pickerRoot:N2,picker:_2};function Ia(){return(Ia=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function iw(t,e){if(t==null)return{};var n,r,s={},i=Object.keys(t);for(r=0;r<i.length;r++)e.indexOf(n=i[r])>=0||(s[n]=t[n]);return s}function Gd(t){var e=C.useRef(t),n=C.useRef(function(r){e.current&&e.current(r)});return e.current=t,n.current}var _i=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t<e?e:t},ni=function(t){return"touches"in t},Jd=function(t){return t&&t.ownerDocument.defaultView||self},Vm=function(t,e,n){var r=t.getBoundingClientRect(),s=ni(e)?(function(i,o){for(var l=0;l<i.length;l++)if(i[l].identifier===o)return i[l];return i[0]})(e.touches,n):e;return{left:_i((s.pageX-(r.left+Jd(t).pageXOffset))/r.width),top:_i((s.pageY-(r.top+Jd(t).pageYOffset))/r.height)}},Wm=function(t){!ni(t)&&t.preventDefault()},ow=C.memo(function(t){var e=t.onMove,n=t.onKey,r=iw(t,["onMove","onKey"]),s=C.useRef(null),i=Gd(e),o=Gd(n),l=C.useRef(null),a=C.useRef(!1),c=C.useMemo(function(){var f=function(y){Wm(y),(ni(y)?y.touches.length>0:y.buttons>0)&&s.current?i(Vm(s.current,y,l.current)):g(!1)},p=function(){return g(!1)};function g(y){var b=a.current,w=Jd(s.current),M=y?w.addEventListener:w.removeEventListener;M(b?"touchmove":"mousemove",f),M(b?"touchend":"mouseup",p)}return[function(y){var b=y.nativeEvent,w=s.current;if(w&&(Wm(b),!(function(S,A){return A&&!ni(S)})(b,a.current)&&w)){if(ni(b)){a.current=!0;var M=b.changedTouches||[];M.length&&(l.current=M[0].identifier)}w.focus(),i(Vm(w,b,l.current)),g(!0)}},function(y){var b=y.which||y.keyCode;b<37||b>40||(y.preventDefault(),o({left:b===39?.05:b===37?-.05:0,top:b===40?.05:b===38?-.05:0}))},g]},[o,i]),d=c[0],u=c[1],h=c[2];return C.useEffect(function(){return h},[h]),C.createElement("div",Ia({},r,{onTouchStart:d,onMouseDown:d,className:"react-colorful__interactive",ref:s,onKeyDown:u,tabIndex:0,role:"slider"}))}),Ah=function(t){return t.filter(Boolean).join(" ")},lw=function(t){var e=t.color,n=t.left,r=t.top,s=r===void 0?.5:r,i=Ah(["react-colorful__pointer",t.className]);return C.createElement("div",{className:i,style:{top:100*s+"%",left:100*n+"%"}},C.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:e}}))},ot=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n},R2=function(t){return j2(Yd(t))},Yd=function(t){return t[0]==="#"&&(t=t.substring(1)),t.length<6?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?ot(parseInt(t[3]+t[3],16)/255,2):1}:{r:parseInt(t.substring(0,2),16),g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16),a:t.length===8?ot(parseInt(t.substring(6,8),16)/255,2):1}},O2=function(t){return I2(L2(t))},D2=function(t){var e=t.s,n=t.v,r=t.a,s=(200-e)*n/100;return{h:ot(t.h),s:ot(s>0&&s<200?e*n/100/(s<=100?s:200-s)*100:0),l:ot(s/2),a:ot(r,2)}},Xd=function(t){var e=D2(t);return"hsl("+e.h+", "+e.s+"%, "+e.l+"%)"},L2=function(t){var e=t.h,n=t.s,r=t.v,s=t.a;e=e/360*6,n/=100,r/=100;var i=Math.floor(e),o=r*(1-n),l=r*(1-(e-i)*n),a=r*(1-(1-e+i)*n),c=i%6;return{r:ot(255*[r,l,o,o,a,r][c]),g:ot(255*[a,r,r,l,o,o][c]),b:ot(255*[o,o,a,r,r,l][c]),a:ot(s,2)}},Ro=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},I2=function(t){var e=t.r,n=t.g,r=t.b,s=t.a,i=s<1?Ro(ot(255*s)):"";return"#"+Ro(e)+Ro(n)+Ro(r)+i},j2=function(t){var e=t.r,n=t.g,r=t.b,s=t.a,i=Math.max(e,n,r),o=i-Math.min(e,n,r),l=o?i===e?(n-r)/o:i===n?2+(r-e)/o:4+(e-n)/o:0;return{h:ot(60*(l<0?l+6:l)),s:ot(i?o/i*100:0),v:ot(i/255*100),a:s}},P2=C.memo(function(t){var e=t.hue,n=t.onChange,r=Ah(["react-colorful__hue",t.className]);return C.createElement("div",{className:r},C.createElement(ow,{onMove:function(s){n({h:360*s.left})},onKey:function(s){n({h:_i(e+360*s.left,0,360)})},"aria-label":"Hue","aria-valuenow":ot(e),"aria-valuemax":"360","aria-valuemin":"0"},C.createElement(lw,{className:"react-colorful__hue-pointer",left:e/360,color:Xd({h:e,s:100,v:100,a:1})})))}),B2=C.memo(function(t){var e=t.hsva,n=t.onChange,r={backgroundColor:Xd({h:e.h,s:100,v:100,a:1})};return C.createElement("div",{className:"react-colorful__saturation",style:r},C.createElement(ow,{onMove:function(s){n({s:100*s.left,v:100-100*s.top})},onKey:function(s){n({s:_i(e.s+100*s.left,0,100),v:_i(e.v-100*s.top,0,100)})},"aria-label":"Color","aria-valuetext":"Saturation "+ot(e.s)+"%, Brightness "+ot(e.v)+"%"},C.createElement(lw,{className:"react-colorful__saturation-pointer",top:1-e.v/100,left:e.s/100,color:Xd(e)})))}),aw=function(t,e){if(t===e)return!0;for(var n in t)if(t[n]!==e[n])return!1;return!0},$2=function(t,e){return t.toLowerCase()===e.toLowerCase()||aw(Yd(t),Yd(e))};function H2(t,e,n){var r=Gd(n),s=C.useState(function(){return t.toHsva(e)}),i=s[0],o=s[1],l=C.useRef({color:e,hsva:i});C.useEffect(function(){if(!t.equal(e,l.current.color)){var c=t.toHsva(e);l.current={hsva:c,color:e},o(c)}},[e,t]),C.useEffect(function(){var c;aw(i,l.current.hsva)||t.equal(c=t.fromHsva(i),l.current.color)||(l.current={hsva:i,color:c},r(c))},[i,t,r]);var a=C.useCallback(function(c){o(function(d){return Object.assign({},d,c)})},[]);return[i,a]}var z2=typeof window<"u"?C.useLayoutEffect:C.useEffect,F2=function(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0},qm=new Map,U2=function(t){z2(function(){var e=t.current?t.current.ownerDocument:document;if(e!==void 0&&!qm.has(e)){var n=e.createElement("style");n.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`,qm.set(e,n);var r=F2();r&&n.setAttribute("nonce",r),e.head.appendChild(n)}},[])},V2=function(t){var e=t.className,n=t.colorModel,r=t.color,s=r===void 0?n.defaultColor:r,i=t.onChange,o=iw(t,["className","colorModel","color","onChange"]),l=C.useRef(null);U2(l);var a=H2(n,s,i),c=a[0],d=a[1],u=Ah(["react-colorful",e]);return C.createElement("div",Ia({},o,{ref:l,className:u}),C.createElement(B2,{hsva:c,onChange:d}),C.createElement(P2,{hue:c.h,onChange:d,className:"react-colorful__last-control"}))},W2={defaultColor:"000",toHsva:R2,fromHsva:function(t){return O2({h:t.h,s:t.s,v:t.v,a:1})},equal:$2},q2=function(t){return C.createElement(V2,Ia({},t,{colorModel:W2}))};const Km="#1F2937",Gm="#FFF7D1",K2=["#FFF7D1","#FFEAE3","#DCFCE7","#DBEAFE"],G2=[{title:"Brand",colors:[{label:"Primary",value:"hsl(var(--primary))"},{label:"Secondary",value:"hsl(var(--secondary))"},{label:"Accent",value:"hsl(var(--accent))"},{label:"Ring",value:"hsl(var(--ring))"}]},{title:"Neutrals",colors:[{label:"Foreground",value:"hsl(var(--foreground))"},{label:"Muted",value:"hsl(var(--muted-foreground))"},{label:"Background",value:"hsl(var(--background))"},{label:"Card",value:"hsl(var(--card))"}]},{title:"States",colors:[{label:"Warning",value:"hsl(var(--warning))"},{label:"Destructive",value:"hsl(var(--destructive))"},{label:"Success",value:"hsl(var(--chart-2))"},{label:"Info",value:"hsl(var(--chart-5))"}]},{title:"Utility",colors:[{label:"Secondary FG",value:"hsl(var(--secondary-foreground))"},{label:"Accent FG",value:"hsl(var(--accent-foreground))"},{label:"Primary FG",value:"hsl(var(--primary-foreground))"},{label:"Border",value:"hsl(var(--border))"}]}],J2=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Y2=/^#[0-9a-f]{6}$/i,cw=/^rgba?\((\s*\d{1,3}\s*,){2}\s*\d{1,3}\s*(,\s*(0|1|0?\.\d+)\s*)?\)$/i,dw=/^hsla?\((\s*\d{1,3}\s*,)(\s*\d{1,3}%\s*,)\s*\d{1,3}%\s*(,\s*(0|1|0?\.\d+)\s*)?\)$/i;function Yl(t){const e=t.replace("#","").trim();return e.length===3||e.length===4?`#${e.split("").map(r=>r+r).join("").toUpperCase()}`:e.length===6||e.length===8?`#${e.toUpperCase()}`:t}function uw(t){const e=Yl(t).replace("#","");if(e.length!==6&&e.length!==8)return null;const n=parseInt(e.slice(0,2),16),r=parseInt(e.slice(2,4),16),s=parseInt(e.slice(4,6),16),i=e.length===8?parseInt(e.slice(6,8),16)/255:1;return{r:n,g:r,b:s,a:i}}function Zd(t,e,n){return`#${[t,e,n].map(r=>Math.max(0,Math.min(255,Math.round(r))).toString(16).padStart(2,"0")).join("").toUpperCase()}`}function ri(t,e=2){const n=10**e;return Math.round(t*n)/n}function si(t,e,n,r=1){const s=t/255,i=e/255,o=n/255,l=Math.max(s,i,o),a=Math.min(s,i,o);let c=0,d=0;const u=(l+a)/2;if(l!==a){const g=l-a;switch(d=u>.5?g/(2-l-a):g/(l+a),l){case s:c=(i-o)/g+(i<o?6:0);break;case i:c=(o-s)/g+2;break;case o:c=(s-i)/g+4;break}c/=6}const h=Math.round(c*360),f=Math.round(d*100),p=Math.round(u*100);return r!==1?`hsla(${h}, ${f}%, ${p}%, ${ri(r,2)})`:`hsl(${h}, ${f}%, ${p}%)`}function Jm(t){if(typeof window>"u"||typeof document>"u")return null;const e=document.createElement("span");if(e.style.color="",e.style.color=t,!e.style.color)return null;e.style.position="absolute",e.style.visibility="hidden",e.style.pointerEvents="none",document.body.appendChild(e);const n=getComputedStyle(e).color;document.body.removeChild(e);const r=n.match(/rgba?\(([^)]+)\)/i);if(!r)return null;const[s,i,o,l]=r[1].split(",").map(a=>a.trim()).map((a,c)=>c===3?parseFloat(a):parseInt(a,10));return[s,i,o].some(a=>Number.isNaN(a))?null:{r:s,g:i,b:o,a:typeof l=="number"&&!Number.isNaN(l)?l:1}}function Sn(t){if(!t)return null;const e=t.trim();if(J2.test(e)){const r=Yl(e),s=uw(r);if(!s)return null;const i=`#${r.replace("#","").slice(0,6)}`;return{source:r,hex:i,rgb:s.a===1?`rgb(${s.r}, ${s.g}, ${s.b})`:`rgba(${s.r}, ${s.g}, ${s.b}, ${ri(s.a,2)})`,hsl:si(s.r,s.g,s.b,s.a),alpha:s.a}}if(cw.test(e)||dw.test(e)){const r=Jm(e);return r?{source:e,hex:Zd(r.r,r.g,r.b),rgb:r.a===1?`rgb(${r.r}, ${r.g}, ${r.b})`:`rgba(${r.r}, ${r.g}, ${r.b}, ${ri(r.a,2)})`,hsl:si(r.r,r.g,r.b,r.a),alpha:r.a}:null}const n=Jm(e);return n?{source:e,hex:Zd(n.r,n.g,n.b),rgb:n.a===1?`rgb(${n.r}, ${n.g}, ${n.b})`:`rgba(${n.r}, ${n.g}, ${n.b}, ${ri(n.a,2)})`,hsl:si(n.r,n.g,n.b,n.a),alpha:n.a}:null}function hw(t){const e=uw(t);if(e)return{source:Yl(t),hex:Zd(e.r,e.g,e.b),rgb:e.a===1?`rgb(${e.r}, ${e.g}, ${e.b})`:`rgba(${e.r}, ${e.g}, ${e.b}, ${ri(e.a,2)})`,hsl:si(e.r,e.g,e.b,e.a),alpha:e.a};const n=Yl(t);return{source:n,hex:n.slice(0,7),rgb:"rgb(0, 0, 0)",hsl:si(0,0,0,1),alpha:1}}const $s=Sn(Km)??hw(Km),Ym=Sn(Gm)??hw(Gm);function fw({editor:t,className:e,initialMode:n="text"}){const r=C.useRef(null),[s,i]=C.useState(n),[o,l]=C.useState(null),[a,c]=C.useState($s),[d,u]=C.useState(Ym);C.useEffect(()=>{i(n)},[n]);const[h,f]=C.useState($s.hex),[p,g]=C.useState(!1),[y,b]=C.useState($s.rgb),[w,M]=C.useState(!1),[S,A]=C.useState($s.hsl),[x,k]=C.useState(!1),v=s==="text"?a:d;C.useEffect(()=>{const $=()=>{if(o)return;const I=t.getAttributes("textStyle").color,j=t.getAttributes("highlight").color,Q=Sn(I)??$s,ie=Sn(j)??Ym;c(Q),u(ie)};return $(),t.on("selectionUpdate",$),t.on("transaction",$),()=>{t.off("selectionUpdate",$),t.off("transaction",$)}},[t,o,s]),C.useEffect(()=>{o!=="hex"&&f(v.hex),o!=="rgb"&&b(v.rgb),o!=="hsl"&&A(v.hsl),o===null&&(g(!1),M(!1),k(!1))},[v,o]);const T=C.useCallback(($,I,j=!0)=>{const Q=t.chain();j&&Q.focus(),$==="text"?(c(I),Q.setColor(I.source).run()):(u(I),Q.setHighlight({color:I.source}).run())},[t,c,u]),N=C.useCallback(($,I)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{T($,I,!1)},300)},[T]),H=C.useCallback($=>{r.current&&clearTimeout(r.current);const I=Sn($);I&&(T(s,I,!1),g(!1))},[T,s,g]),V=C.useCallback($=>{r.current&&clearTimeout(r.current);const I=Sn($);I&&(T(s,I),g(!1))},[T,s,g]);return m.jsxs("div",{className:De.cn("flex w-full sm:w-auto flex-col gap-3 sm:gap-4",e),children:[m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsxs("div",{className:"inline-flex items-center gap-1 rounded-md bg-muted/60 p-1",children:[m.jsx(le.Button,{type:"button",variant:s==="text"?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs",onClick:()=>i("text"),children:"Text"}),m.jsx(le.Button,{type:"button",variant:s==="highlight"?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs",onClick:()=>i("highlight"),children:"Highlight"})]}),m.jsx("div",{className:"flex items-center",children:m.jsx(le.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>{s==="text"?t.chain().focus().unsetColor().run():t.chain().focus().unsetHighlight().run()},children:"Remove Color"})})]}),m.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:gap-4",children:[m.jsx("div",{className:Um.pickerRoot,children:m.jsx(q2,{color:v.hex,onChange:H,className:Um.picker})}),m.jsxs("div",{className:"flex w-full flex-col gap-2 text-[11px] sm:w-[150px]",children:[m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"HEX"}),m.jsx(ns.Input,{value:h,onFocus:()=>l("hex"),onChange:$=>{const I=$.target.value;if(f(I),Y2.test(I)){const j=Sn(I);j&&(N(s,j),g(!1))}else g(!0)},onBlur:()=>{l(null),p&&(f(v.hex),g(!1))},spellCheck:!1,className:De.cn("h-8 w-full text-xs",p&&"border-destructive focus-visible:ring-destructive")})]}),m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"RGB"}),m.jsx(ns.Input,{value:y,onFocus:()=>l("rgb"),onChange:$=>{const I=$.target.value;if(b(I),cw.test(I)){const j=Sn(I);j&&(N(s,j),M(!1))}else M(!0)},onBlur:()=>{l(null),w&&(b(v.rgb),M(!1))},spellCheck:!1,className:De.cn("h-8 w-full text-xs",w&&"border-destructive focus-visible:ring-destructive")})]}),m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"HSL"}),m.jsx(ns.Input,{value:S,onFocus:()=>l("hsl"),onChange:$=>{const I=$.target.value;if(A(I),dw.test(I)){const j=Sn(I);j&&(N(s,j),k(!1))}else k(!0)},onBlur:()=>{l(null),x&&(A(v.hsl),k(!1))},spellCheck:!1,className:De.cn("h-8 w-full text-xs",x&&"border-destructive focus-visible:ring-destructive")})]})]})]}),m.jsxs("div",{className:"space-y-1.5",children:[m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Theme colors"}),m.jsx("div",{className:"space-y-1",children:G2.map($=>m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground/80",children:$.title}),m.jsx("div",{className:"flex items-center gap-1.5",children:$.colors.map(I=>m.jsx("button",{type:"button",onClick:()=>V(I.value),className:"h-6 w-6 rounded border border-border bg-background shadow-sm transition hover:border-primary/40 hover:shadow-sm",style:{background:I.value},"aria-label":`${$.title} color ${I.label}`,title:`${$.title} color ${I.label}`},I.label))})]},$.title))})]}),s==="highlight"?m.jsxs("div",{className:"space-y-2",children:[m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Highlight presets"}),m.jsx("div",{className:"flex flex-wrap gap-1.5",children:K2.map($=>m.jsxs("button",{type:"button",onClick:()=>V($),className:"flex items-center gap-1 rounded-full border bg-background px-2 py-1 text-[11px] shadow-sm transition hover:border-primary/40 hover:shadow-sm",children:[m.jsx("span",{className:"h-3.5 w-3.5 rounded-full border",style:{background:$},"aria-hidden":!0}),$]},$))})]}):null]})}const X2=["px","pt","rem","em","%"];function qo(t){if(!t)return null;const n=String(t).trim().match(/^(-?\d*\.?\d+)(px|pt|rem|em|%)$/i);if(!n)return null;const r=parseFloat(n[1]),s=n[2].toLowerCase();return Number.isFinite(r)?{value:r,unit:s}:null}function Qd(t){if(!t)return null;const{value:e,unit:n}=t;return n==="%"?`${Math.max(1,Math.round(e))}%`:n==="px"||n==="pt"?`${Math.max(1,Math.round(e))}${n}`:`${Math.max(.01,Math.round(e*100)/100)}${n}`}function Z2(t){const e=qo(t);return e?Qd(e):null}function Q2(){if(typeof document>"u")return[];const t=[];try{const n=Array.from(document.styleSheets),r=[],s=[];for(const l of n){const a=l.href,c=l.ownerNode;`${a||""} ${c?.textContent||""}`.toLowerCase().includes("globals.css")?r.push(l):s.push(l)}const i=[...r,...s],o=new Set(["h1","h2","h3","h4","h5","h6"]);for(const l of i){let a=null;try{a=l.cssRules}catch{continue}if(a){for(const c of Array.from(a))if(c.style){const u=c.style.fontSize,h=c.selectorText;if(u&&h&&o.has(h)){const f=Z2(u)??u.trim();if(f){const p=parseInt(h.replace("h",""),10);t.push({level:p,value:f})}}}}}}catch{}const e=new Map;for(const n of t)e.has(n.level)||e.set(n.level,n.value);return Array.from(e.entries()).map(([n,r])=>({level:n,value:r}))}function ej(t){if(typeof document>"u")return 0;try{const e=document.createElement("span");e.style.position="absolute",e.style.visibility="hidden",e.style.fontSize=t,document.body.appendChild(e);const n=parseFloat(getComputedStyle(e).fontSize);return document.body.removeChild(e),Number.isFinite(n)?n:0}catch{return 0}}function Xl(){if(typeof document>"u")return 16;try{const t=parseFloat(getComputedStyle(document.documentElement).fontSize);return Number.isFinite(t)&&t>0?t:16}catch{return 16}}function Th(t){try{const e=t.state.selection.from,n=t.view.domAtPos(e),r=n&&n.node||t.view.dom,s=r.nodeType===1?r:t.view.dom,i=parseFloat(getComputedStyle(s).fontSize);return Number.isFinite(i)&&i>0?i:Xl()}catch{return Xl()}}function tj(t,e,n){const r=Xl(),s=Th(n);switch(e){case"px":return t;case"pt":return t*(96/72);case"rem":return t*r;case"em":return t*s;case"%":return t/100*s}}function nj(t,e,n){const r=Xl(),s=Th(n);switch(e){case"px":return t;case"pt":return t*(72/96);case"rem":return t/r;case"em":return t/s;case"%":return t/s*100}}function pw({editor:t,className:e}){const[n,r]=C.useState([]),[s,i]=C.useState(null),[o,l]=C.useState(""),[a,c]=C.useState("px"),[d,u]=C.useState(!1),h=C.useRef(null),f=C.useCallback(()=>{const S=t.getAttributes("textStyle").fontSize,A=qo(S);if(A)l(String(A.value)),c(A.unit),u(!1);else{if(S&&typeof S=="string"){const x=ej(S);if(x>0&&!s){l(String(Math.round(x))),c("px"),u(!1);return}}s||(l(""),c("px"),u(!1))}},[t,s]);C.useEffect(()=>{f();const S=()=>f();return t.on("selectionUpdate",S),t.on("transaction",S),()=>{t.off("selectionUpdate",S),t.off("transaction",S)}},[t,f]),C.useEffect(()=>{r(Q2())},[]);const p=C.useCallback((S,A=!0)=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{const x=t.chain();A&&x.focus(),x.setFontSize(S).run()},120)},[t]),g=C.useCallback(S=>{l(S);const A=`${S}${a}`,x=qo(A);if(x){u(!1);const k=Qd(x);k&&p(k,!1)}else u(S.trim().length>0)},[a,p]),y=C.useCallback(S=>{const A=a;c(S);let x=0;const k=parseFloat(o);Number.isFinite(k)?x=tj(k,A,t):x=Th(t);const v=nj(x,S,t);let T;S==="px"||S==="pt"||S==="%"?T=String(Math.round(v)):T=String(Math.max(.01,Math.round(v*100)/100)),l(T);const N=Qd(qo(`${T}${S}`));N&&p(N)},[a,o,t,p]),b=C.useCallback(()=>{h.current&&clearTimeout(h.current),t.chain().focus().unsetFontSize().run(),u(!1)},[t]),w=C.useMemo(()=>a==="px"||a==="pt"||a==="%"?1:.01,[a]),M=C.useMemo(()=>{switch(a){case"%":return"100";case"px":return"16";case"pt":return"12";case"rem":return"1";case"em":return"1";default:return""}},[a]);return m.jsxs("div",{className:De.cn("space-y-3",e),onMouseDown:S=>S.stopPropagation(),children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(Wr,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Font size"})]}),m.jsxs(le.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:b,title:"Erase font size","aria-label":"Erase font size",children:[m.jsx(WL,{className:"h-3.5 w-3.5 mr-1"}),"Erase"]})]}),m.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-2 items-end",children:[m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"Value"}),m.jsx(ns.Input,{type:"number",inputMode:"decimal",step:w,placeholder:M,value:o,onFocus:()=>i("value"),onChange:S=>g(S.target.value),onBlur:()=>i(null),className:De.cn("h-9",d&&"border-destructive focus-visible:ring-destructive"),spellCheck:!1})]}),m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"Unit"}),m.jsx("div",{className:"flex gap-1",children:m.jsx("select",{value:a,onChange:S=>y(S.target.value),onFocus:()=>i("unit"),onBlur:()=>i(null),className:"h-9 w-[84px] rounded-md border border-input bg-background px-2 text-sm shadow-sm outline-none focus-visible:ring-2 focus-visible:ring-ring",children:X2.map(S=>m.jsx("option",{value:S,children:S},S))})})]})]}),m.jsxs("div",{className:"space-y-2",children:[n.length>0?m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Headings"}),m.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:n.map(({level:S,value:A})=>m.jsx("button",{type:"button",onClick:()=>p(A),className:"h-8 w-full rounded-md border bg-background px-2 text-xs font-medium shadow-sm transition hover:border-primary/40 hover:shadow-sm",title:`Apply H${S} (${A})`,children:`H${S} (${A})`},`h${S}`))})]}):null,m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Keywords"}),m.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:["xx-small","x-small","small","medium","large","x-large"].map(S=>m.jsx("button",{type:"button",onClick:()=>p(S),className:"h-8 w-full rounded-md border bg-background px-2 text-xs font-medium shadow-sm transition hover:border-primary/40 hover:shadow-sm",title:`Apply ${S}`,children:S.replace(/\b\w/g,A=>A.toUpperCase())},S))})]})]})]})}const rj=({editor:t})=>{const[e,n]=C.useState(t.getAttributes("link")?.href??"");C.useEffect(()=>{const s=()=>{n(t.getAttributes("link")?.href??"")};return t.on("selectionUpdate",s),t.on("transaction",s),()=>{t.off("selectionUpdate",s),t.off("transaction",s)}},[t]);const r=()=>{const s=e.trim();s?t.chain().focus().extendMarkRange("link").setLink({href:s}).run():t.chain().focus().extendMarkRange("link").unsetLink().run()};return m.jsxs("div",{className:"p-2 flex items-center gap-2",onMouseDown:s=>s.preventDefault(),children:[m.jsx("input",{type:"url",value:e,onChange:s=>n(s.target.value),placeholder:"Enter URL",className:"bg-background p-1 rounded border border-input text-sm",onKeyDown:s=>s.key==="Enter"&&r()}),m.jsx(le.Button,{type:"button",size:"sm",onClick:r,children:"Set Link"})]})},sj=({editor:t})=>m.jsx("div",{className:"w-[380px]",children:m.jsx(fw,{editor:t,className:"p-4",initialMode:t.isActive("highlight")?"highlight":"text"})}),Nh=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(!1),[i,o]=C.useState(!1),[l,a]=C.useState(!1),{x:c,y:d,refs:u,strategy:h,update:f}=Xi({placement:"top",middleware:[Yi(6),La(),Da()],whileElementsMounted:Ms}),p=C.useCallback(()=>{if(!t||!t.isEditable)return!1;const{state:y}=t,{from:b,to:w}=y.selection,M=b!==w,S=y.selection instanceof q,A=t.isActive("codeBlock"),x=y.selection.empty&&(t.isActive("alert-widget")||t.isActive("cta-widget")),k=t.isActive("image");return M&&!S&&!A&&!x&&!k},[t]),g=C.useCallback(()=>{if(!(!t||!p()))try{const{from:y,to:b}=t.state.selection,w=t.view.coordsAtPos(y),M=t.view.coordsAtPos(b),S={getBoundingClientRect:()=>({x:w.left,y:w.top,top:w.top,left:w.left,bottom:M.bottom,right:M.right,width:M.right-w.left,height:M.bottom-w.top})};u.setReference(S),f(),requestAnimationFrame(()=>s(!0))}catch(y){console.warn("BubbleMenu positioning error:",y)}},[t,u,f,p]);return C.useEffect(()=>{if(!t)return;let y=0;const b=()=>{cancelAnimationFrame(y),y=requestAnimationFrame(()=>{p()?(n(!0),g()):!i&&!l&&n(!1)})},w=({event:M})=>{i||l||u.floating.current&&M.relatedTarget&&u.floating.current.contains(M.relatedTarget)||n(!1)};return b(),t.on("selectionUpdate",b),t.on("transaction",b),t.on("focus",b),t.on("blur",w),()=>{cancelAnimationFrame(y),t.off("selectionUpdate",b),t.off("transaction",b),t.off("focus",b),t.off("blur",w)}},[t,p,g,i,l,u.floating]),!t||!e?null:m.jsxs("div",{ref:u.setFloating,style:{position:h,top:d??0,left:c??0,zIndex:1e4,visibility:r?"visible":"hidden"},className:"flex gap-1 items-center bg-background border rounded-lg p-1 shadow-lg",onMouseDown:y=>y.preventDefault(),children:[m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleBold().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("bold")?"bg-accent":""}`,"aria-label":"Bold",title:"Bold",children:m.jsx(Gl,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleItalic().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("italic")?"bg-accent":""}`,"aria-label":"Italic",title:"Italic",children:m.jsx(kh,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleUnderline().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("underline")?"bg-accent":""}`,"aria-label":"Underline",title:"Underline",children:m.jsx(Ch,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleStrike().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("strike")?"bg-accent":""}`,"aria-label":"Strikethrough",title:"Strikethrough",children:m.jsx(Yx,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleCode().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("code")?"bg-accent":""}`,"aria-label":"Inline code",title:"Inline code",children:m.jsx(Rs,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("div",{className:"w-px bg-border h-5"}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleSubscript().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("subscript")?"bg-accent":""}`,"aria-label":"Subscript",title:"Subscript",children:m.jsx(Xx,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleSuperscript().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("superscript")?"bg-accent":""}`,"aria-label":"Superscript",title:"Superscript",children:m.jsx(Zx,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("div",{className:"w-px bg-border h-5"}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("left").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"left"})?"bg-accent":""}`,"aria-label":"Align left",title:"Align left",children:m.jsx(Ss,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("center").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"center"})?"bg-accent":""}`,"aria-label":"Align center",title:"Align center",children:m.jsx(Ki,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("right").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"right"})?"bg-accent":""}`,"aria-label":"Align right",title:"Align right",children:m.jsx(Gi,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("justify").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"justify"})?"bg-accent":""}`,"aria-label":"Justify",title:"Justify",children:m.jsx(Sh,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("div",{className:"w-px bg-border h-5"}),m.jsxs(gt.Popover,{open:l,onOpenChange:a,children:[m.jsx(gt.PopoverTrigger,{asChild:!0,children:m.jsx("button",{type:"button",className:"p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center","aria-label":"Font size",title:"Font size",onMouseDown:y=>y.preventDefault(),children:m.jsx(Wr,{className:"h-4 w-4 pointer-events-none"})})}),m.jsx(gt.PopoverContent,{onFocusOutside:y=>y.preventDefault(),onMouseDown:y=>y.stopPropagation(),className:"w-[360px] p-0",side:"top",align:"start",children:m.jsx(pw,{editor:t,className:"p-4"})})]}),m.jsxs(gt.Popover,{children:[m.jsx(gt.PopoverTrigger,{asChild:!0,children:m.jsx("button",{type:"button",className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("link")?"bg-accent":""}`,"aria-label":"Link",title:"Link",onMouseDown:y=>y.preventDefault(),children:m.jsx(Ta,{className:"h-4 w-4 pointer-events-none"})})}),m.jsx(gt.PopoverContent,{className:"w-auto p-0",side:"top",align:"start",children:m.jsx(rj,{editor:t})})]}),m.jsxs(gt.Popover,{open:i,onOpenChange:o,children:[m.jsx(gt.PopoverTrigger,{asChild:!0,children:m.jsx("button",{type:"button",onMouseDown:y=>y.preventDefault(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("textStyle")||t.isActive("highlight")?"bg-accent":""}`,"aria-label":"Color / highlight",title:"Color / highlight",children:m.jsx(vh,{className:"h-4 w-4 pointer-events-none"})})}),m.jsx(gt.PopoverContent,{onFocusOutside:y=>y.preventDefault(),onMouseDown:y=>y.stopPropagation(),className:"w-auto p-0",side:"top",align:"start",children:m.jsx(sj,{editor:t})})]}),m.jsx("div",{className:"w-px bg-border h-5"})]})};function Xm(t,e){t.storage.mediaPicker={open:e}}function ja(t){return t.storage?.mediaPicker?.open}const ij=[{title:"Heading 1",icon:m.jsx(vs,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:1}).run()},{title:"Heading 2",icon:m.jsx(Vi,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:2}).run()},{title:"Bullet List",icon:m.jsx(Os,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBulletList().run()},{title:"Ordered List",icon:m.jsx(Wi,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleOrderedList().run()},{title:"Blockquote",icon:m.jsx(Ji,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBlockquote().run()},{title:"Code Block",icon:m.jsx(Rs,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleCodeBlock().run()},{title:"Image",icon:m.jsx(zr,{className:"h-4 w-4"}),command:async t=>{const e=ja(t);if(e){const r=await e();r?.src&&t.chain().focus().setImage({src:r.src,alt:r.alt||void 0}).updateAttributes("image",{blurDataURL:r.blurDataURL||void 0}).run();return}const n=window.prompt("URL");n&&t.chain().focus().setImage({src:n}).run()}},{title:"Table",icon:m.jsx(qi,{className:"h-4 w-4"}),command:t=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{title:"Horizontal Rule",icon:m.jsx(_a,{className:"h-4 w-4"}),command:t=>t.chain().focus().setHorizontalRule().run()},{title:"Link",icon:m.jsx(Ta,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter URL:");e&&t.chain().focus().setLink({href:e}).run()}},{title:"CSS Block",icon:m.jsx(Nr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter CSS (without <style> tags):","/* your styles */");if(e!=null){const n=`<style>${e}</style>`;t.commands.insertContentAt({from:0,to:0},n)}}},{title:"Script Block",icon:m.jsx(Nr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter JavaScript (without <script> tags):","// your script");if(e!=null){const n=`<script>${e}<\/script>`,r=t.state.doc.content.size;t.commands.insertContentAt(r,n)}}},{title:"DIV Block",icon:m.jsx(Nr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Optional class for DIV:",""),n=window.prompt("Optional inline style for DIV:",""),r=window.prompt("Optional content for DIV:","New block"),s=`${e?` class="${e}"`:""}${n?` style="${n}"`:""}`,o=r?`<p>${(l=>l.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"))(r)}</p>`:"<p><br /></p>";t.chain().focus().insertContent(`<div${s}>${o}</div>`).run()}},{title:"Alert Widget",icon:m.jsx(Oa,{className:"h-4 w-4"}),command:t=>{t.chain().focus().setAlertWidget().run()}},{title:"CTA Widget",icon:m.jsx(Na,{className:"h-4 w-4"}),command:t=>{t.chain().focus().setCtaWidget({text:"Learn more",url:"",style:"primary",size:"medium",textAlign:"center"}).run()}}],_h=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(null),[i,o]=C.useState(null),l=C.useRef(null),a=C.useRef(null),c=C.useRef(!1),d=C.useCallback(()=>{l.current&&l.current.setAttribute("aria-expanded","false"),a.current&&a.current.removeAttribute("data-menu-open"),l.current=null,a.current=null,s(null),n(!1)},[]),{x:u,y:h,refs:f,strategy:p}=Xi({placement:"right-start",open:e,middleware:[Yi(8),La(),Da()],whileElementsMounted:Ms});C.useEffect(()=>{c.current=e},[e]),C.useEffect(()=>{r?f.setReference(r):f.setReference(null)},[r,f]);const g=C.useCallback(()=>!(!t||!t.isEditable||t.isActive("image")),[t]);C.useEffect(()=>{if(!t)return;const b=t.view.dom.parentElement;if(!b)return;const w=M=>{const S=M,{handle:A,button:x}=S.detail;try{const v=t.state.selection?.$from;if(v){let T=v.depth;for(;T>0&&!v.node(T)?.isBlock;)T-=1;const N=typeof v.after=="function"?v.after(T):void 0;typeof N=="number"?o(N):typeof v.pos=="number"?o(v.pos):o(null)}else o(null)}catch{o(null)}if(l.current===x&&c.current){d();return}l.current&&l.current!==x&&l.current.setAttribute("aria-expanded","false"),a.current&&a.current!==A&&a.current.removeAttribute("data-menu-open"),l.current=x,a.current=A,x.setAttribute("aria-expanded","true"),A.setAttribute("data-menu-open","true"),s(x),n(!0)};return b.addEventListener("tiptap-gutter-toggle",w),()=>{b.removeEventListener("tiptap-gutter-toggle",w)}},[t,g,d]),C.useEffect(()=>{if(!t)return;const b=()=>{g()||d()};return t.on("selectionUpdate",b),t.on("transaction",b),t.on("blur",d),()=>{t.off("selectionUpdate",b),t.off("transaction",b),t.off("blur",d)}},[t,g,d]),C.useEffect(()=>{if(!e)return;const b=M=>{const S=M.target,A=f.floating.current;if(A&&!A.contains(S)){const x=l.current;(!x||!x.contains(S))&&d()}},w=M=>{M.key==="Escape"&&d()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",w)}},[e,d,f]);const y=b=>{i!=null?t.chain().focus().insertContentAt(i,{type:"paragraph"}).setTextSelection(i+1).run():t.chain().focus().run(),b(t),d()};return!r||!e?null:m.jsx("div",{ref:f.setFloating,style:{position:p,top:h??0,left:u??0,zIndex:10001},className:"w-48 rounded-md bg-white p-1 shadow-lg max-h-[400px] overflow-auto",onMouseDown:b=>b.preventDefault(),children:m.jsx("div",{className:"flex flex-col",children:ij.map(b=>m.jsxs(le.Button,{type:"button",variant:"ghost",className:"justify-start",onClick:()=>y(b.command),children:[b.icon,m.jsx("span",{className:"ml-2",children:b.title})]},b.title))})})},oj=[{title:"Text",description:"Start writing with plain text",icon:m.jsx(Wr,{className:"h-4 w-4"}),command:t=>t.chain().focus().clearNodes().run(),category:"basic",keywords:["text","paragraph","plain"]},{title:"Heading 1",description:"Large section heading",icon:m.jsx(vs,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:1}).run(),category:"headings",keywords:["heading","h1","title","large"]},{title:"Heading 2",description:"Medium section heading",icon:m.jsx(Vi,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:2}).run(),category:"headings",keywords:["heading","h2","subtitle","medium"]},{title:"Heading 3",description:"Small section heading",icon:m.jsx(Aa,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:3}).run(),category:"headings",keywords:["heading","h3","small"]},{title:"Bullet List",description:"Create a simple bulleted list",icon:m.jsx(Os,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBulletList().run(),category:"lists",keywords:["bullet","list","unordered","ul"]},{title:"Numbered List",description:"Create a list with numbering",icon:m.jsx(Wi,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleOrderedList().run(),category:"lists",keywords:["numbered","list","ordered","ol"]},{title:"Task List",description:"Create a list with checkboxes",icon:m.jsx(Ra,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleTaskList().run(),category:"lists",keywords:["task","todo","checkbox","checklist"]},{title:"Image",description:"Insert an image",icon:m.jsx(zr,{className:"h-4 w-4"}),command:async t=>{const e=ja(t);if(e){const r=await e();r?.src&&t.chain().focus().setImage({src:r.src,alt:r.alt||void 0}).updateAttributes("image",{blurDataURL:r.blurDataURL||void 0}).run();return}const n=window.prompt("Enter image URL:");n&&t.chain().focus().setImage({src:n}).run()},category:"media",keywords:["image","picture","photo","img"]},{title:"Video",description:"Embed a video from URL",icon:m.jsx(ew,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter video URL (YouTube, Vimeo, etc.):");e&&t.chain().focus().insertContent(`<p><a href="${e}" target="_blank">Video: ${e}</a></p>`).run()},category:"media",keywords:["video","youtube","vimeo","embed"]},{title:"Blockquote",description:"Create a quote or citation",icon:m.jsx(Ji,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBlockquote().run(),category:"advanced",keywords:["quote","blockquote","citation"]},{title:"Code Block",description:"Create a code block with syntax highlighting",icon:m.jsx(Rs,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleCodeBlock().run(),category:"advanced",keywords:["code","programming","syntax","block"]},{title:"Table",description:"Insert a table with rows and columns",icon:m.jsx(qi,{className:"h-4 w-4"}),command:t=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),category:"advanced",keywords:["table","grid","rows","columns"]},{title:"Horizontal Rule",description:"Insert a horizontal divider",icon:m.jsx(_a,{className:"h-4 w-4"}),command:t=>t.chain().focus().setHorizontalRule().run(),category:"advanced",keywords:["divider","separator","line","hr"]},{title:"Alert",description:"Insert an alert or notice",icon:m.jsx(Oa,{className:"h-4 w-4"}),command:t=>{t.can().setAlertWidget()?t.chain().focus().setAlertWidget().run():t.chain().focus().toggleBlockquote().run()},category:"advanced",keywords:["alert","notice","warning","info"]},{title:"Call to Action",description:"Insert a call to action button",icon:m.jsx(Na,{className:"h-4 w-4"}),command:t=>{t.can().setCtaWidget()?t.chain().focus().setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}).run():t.chain().focus().insertContent("Call to Action").run()},category:"advanced",keywords:["cta","button","action","link"]}],Zm={basic:m.jsx(Wr,{className:"h-3 w-3"}),headings:m.jsx(XL,{className:"h-3 w-3"}),lists:m.jsx(Os,{className:"h-3 w-3"}),media:m.jsx(zr,{className:"h-3 w-3"}),advanced:m.jsx(PI,{className:"h-3 w-3"})},Qm={basic:"Basic",headings:"Headings",lists:"Lists",media:"Media",advanced:"Advanced"},mw=({editor:t,wrapperRef:e})=>{const[n,r]=C.useState(!1),[s,i]=C.useState(!1),[o,l]=C.useState(!1),[a,c]=C.useState(""),[d,u]=C.useState("all"),[h,f]=C.useState({top:-9999,left:-9999,width:0}),{x:p,y:g,refs:y,strategy:b,update:w}=Xi({placement:"bottom-start",open:n,onOpenChange:r,middleware:[Yi(10),La({fallbackPlacements:["top-start","bottom-start","right-start"]}),Da({padding:8}),g2({apply({availableWidth:v,availableHeight:T,elements:N}){Object.assign(N.floating.style,{maxWidth:`${Math.min(400,v-16)}px`,maxHeight:`${Math.min(500,T-16)}px`})}})],whileElementsMounted:Ms}),M=C.useCallback(()=>{const{$from:v}=t.state.selection,T=v.parent;if(T.type.name==="paragraph"&&T.content.size===0||T.type.name==="heading"&&T.content.size===0)return!0;if(T.type.name==="listItem"&&T.content.size===1){const N=T.firstChild;if(N&&N.type.name==="paragraph"&&N.content.size===0)return!0}return t.isEditable},[t]),S=C.useCallback(()=>{if(!e?.current)return;const v=e.current.getBoundingClientRect(),T=t.view.dom.getBoundingClientRect(),H=t.view.coordsAtPos(t.state.selection.from).top-v.top,V=T.left-v.left,$=T.width;f({top:H,left:V,width:$}),w(),requestAnimationFrame(()=>l(!0))},[t,w,e]);C.useEffect(()=>{if(!t)return;let v=0;const T=()=>{cancelAnimationFrame(v),v=requestAnimationFrame(()=>{M()?(i(!0),l(!1),S()):(i(!1),r(!1),l(!1))})},N=()=>{i(!1),r(!1),l(!1)};return T(),t.on("selectionUpdate",T),t.on("transaction",T),t.on("focus",T),t.on("blur",N),()=>{cancelAnimationFrame(v),t.off("selectionUpdate",T),t.off("transaction",T),t.off("focus",T),t.off("blur",N)}},[t,M,S]);const A=v=>{v(t),r(!1),c(""),u("all")},x=oj.filter(v=>{const T=d==="all"||v.category===d,N=a===""||v.title.toLowerCase().includes(a.toLowerCase())||v.description.toLowerCase().includes(a.toLowerCase())||v.keywords.some(H=>H.toLowerCase().includes(a.toLowerCase()));return T&&N}),k=x.reduce((v,T)=>(v[T.category]||(v[T.category]=[]),v[T.category].push(T),v),{});return s?m.jsxs(m.Fragment,{children:[m.jsx("div",{style:{position:"absolute",top:h.top,left:h.left,width:h.width,visibility:o?"visible":"hidden",zIndex:1e4},className:"group",children:m.jsxs("div",{className:"relative py-4 w-[95%] mx-auto flex items-center","aria-label":"Insert block",children:[m.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-full h-0.5 bg-gradient-to-r from-transparent via-slate-300 to-transparent dark:via-slate-600 transform origin-center scale-x-0 opacity-0 group-hover:scale-x-100 group-hover:opacity-100 transition-all duration-300"}),m.jsxs("div",{ref:y.setReference,className:"relative z-10 cursor-pointer mx-auto",onClick:()=>r(v=>!v),children:[m.jsx("div",{className:"absolute -inset-3 rounded-full bg-primary/10 dark:bg-primary/20 scale-0 opacity-0 group-hover:scale-100 group-hover:opacity-100 transition-all duration-300 ease-out animate-pulse"}),m.jsx("div",{className:"relative bg-background border border-border p-1.5 rounded-full shadow-sm group-hover:shadow-md transition-all duration-200",children:m.jsx(LL,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors duration-200"})})]})]})}),n&&m.jsxs("div",{ref:y.setFloating,style:{position:b,top:g??0,left:p??0,zIndex:10001},className:"bg-background border border-border shadow-lg rounded-lg p-2 w-96 max-h-[500px] overflow-hidden",onMouseDown:v=>v.preventDefault(),children:[m.jsx("div",{className:"p-2 border-b border-border",children:m.jsx("input",{type:"text",placeholder:"Search blocks...",value:a,onChange:v=>c(v.target.value),className:"w-full px-3 py-2 text-sm bg-muted border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",autoFocus:!0})}),m.jsxs("div",{className:"flex gap-1 p-2 border-b border-border overflow-x-auto",children:[m.jsx(le.Button,{variant:d==="all"?"default":"ghost",size:"sm",onClick:()=>u("all"),className:"text-xs whitespace-nowrap",children:"All"}),Object.entries(Qm).map(([v,T])=>m.jsxs(le.Button,{variant:d===v?"default":"ghost",size:"sm",onClick:()=>u(v),className:"text-xs whitespace-nowrap flex items-center gap-1",children:[Zm[v],T]},v))]}),m.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[d==="all"?Object.entries(k).map(([v,T])=>m.jsxs("div",{className:"py-2",children:[m.jsxs("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-2",children:[Zm[v],Qm[v]]}),T.map(N=>m.jsx(le.Button,{variant:"ghost",className:"w-full justify-start p-3 h-auto text-left",onClick:()=>A(N.command),children:m.jsxs("div",{className:"flex items-center gap-3 w-full",children:[m.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-md border bg-muted",children:N.icon}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"font-medium text-sm",children:N.title}),m.jsx("p",{className:"text-xs text-muted-foreground truncate",children:N.description})]})]})},N.title))]},v)):x.map(v=>m.jsx(le.Button,{variant:"ghost",className:"w-full justify-start p-3 h-auto text-left",onClick:()=>A(v.command),children:m.jsxs("div",{className:"flex items-center gap-3 w-full",children:[m.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-md border bg-muted",children:v.icon}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"font-medium text-sm",children:v.title}),m.jsx("p",{className:"text-xs text-muted-foreground truncate",children:v.description})]})]})},v.title)),x.length===0&&m.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:['No blocks found for "',a,'"']})]})]})]}):null},lj=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),eg=new Set(["address","article","aside","blockquote","canvas","dd","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","li","main","nav","noscript","ol","p","pre","section","table","tfoot","ul","video","thead","tbody","tr","th","td","colgroup"]);function gw(t){const e=t.match(/^<\/?\s*([a-zA-Z0-9:-]+)/);return e?e[1].toLowerCase():null}function aj(t){return/^<\s*[^/!][^>]*>$/.test(t)}function tg(t){return/^<\s*\//.test(t)}function cj(t){if(/\/\s*>$/.test(t))return!0;const e=gw(t);return e?lj.has(e):!1}function dj(t){return/^<\s*!/.test(t)}function $c(t,e=2){if(!t)return"";const n=t.replace(/\r\n?/g,`
|
|
152
|
+
`).split(/(<[^>]+>)/g).filter(Boolean),r=" ".repeat(e);let s=0;const i=[];let o=null;for(let l=0;l<n.length;l++){const a=n[l];if(a.startsWith("<")){const c=gw(a);c&&(c==="pre"||c==="code"||c==="script"||c==="style")&&tg(a)&&(o=null),tg(a)&&s>0&&(s-=1);const d=c&&eg.has(c)||dj(a),u=`${d?r.repeat(s):""}${a.trim()}`;if(d)i.push(u);else{const h=i.length?i[i.length-1]:"";h&&!h.endsWith(`
|
|
153
|
+
`)?i[i.length-1]=h+a.trim():i.push(r.repeat(s)+a.trim())}c&&aj(a)&&!cj(a)&&eg.has(c)&&(s+=1,(c==="pre"||c==="code"||c==="script"||c==="style")&&(o=c))}else if(o){const c=a.split(`
|
|
154
154
|
`);for(const d of c)i.push(d)}else{const c=a.replace(/\s+/g," ");if(c.length>0){const d=i.length?i[i.length-1]:"";if(d&&!d.endsWith(`
|
|
155
155
|
`))i[i.length-1]=d+c;else{const u=c.replace(/^ +/,"");u&&i.push(r.repeat(s)+u)}}}}return i.join(`
|
|
156
156
|
`).replace(/\n{3,}/g,`
|
|
157
157
|
|
|
158
|
-
`)}const Rh=t=>{const[e,n]=C.useState({canUndo:!1,canRedo:!1,historyDepth:0,isHistoryEmpty:!0}),r=C.useCallback(()=>{if(!t){n({canUndo:!1,canRedo:!1,historyDepth:0,isHistoryEmpty:!0});return}const a=t.can().undo(),c=t.can().redo();n({canUndo:a,canRedo:c,historyDepth:a?1:0,isHistoryEmpty:!a&&!c})},[t]);C.useEffect(()=>{if(t)return r(),t.on("transaction",r),t.on("update",r),t.on("selectionUpdate",r),t.on("focus",r),t.on("blur",r),()=>{t.off("transaction",r),t.off("update",r),t.off("selectionUpdate",r),t.off("focus",r),t.off("blur",r)}},[t,r]);const s=C.useCallback(()=>{if(!t||!e.canUndo)return!1;try{console.log("useEditorHistory - Attempting undo operation");const a=t.chain().focus().undo().run();return console.log("useEditorHistory - Undo result:",a),a}catch(a){return console.error("useEditorHistory - Undo operation failed:",a),!1}},[t,e.canUndo]),i=C.useCallback(()=>{if(!t||!e.canRedo)return!1;try{console.log("useEditorHistory - Attempting redo operation");const a=t.chain().focus().redo().run();return console.log("useEditorHistory - Redo result:",a),a}catch(a){return console.error("useEditorHistory - Redo operation failed:",a),!1}},[t,e.canRedo]),o=C.useCallback(()=>{if(t)try{t.commands.clearContent(),r()}catch(a){console.warn("Clear history operation failed:",a)}},[t,r]),l=C.useCallback(()=>({...e}),[e]);return{...e,undo:s,redo:i,clearHistory:o,getHistoryState:l}},yw=(t,e)=>t?e==="undo"?t.can().undo():t.can().redo():!1,cj=(t,e)=>{if(!t||!yw(t,e))return!1;try{return e==="undo"?t.chain().focus().undo().run():t.chain().focus().redo().run()}catch(n){return console.warn(`${e} operation failed:`,n),!1}},eu=t=>{const e=typeof navigator<"u"&&navigator.platform.includes("Mac"),n=e?"Cmd":"Ctrl";return t==="undo"?`${n}+Z`:e?`${n}+Shift+Z`:`${n}+Y`},Oh=({editor:t,className:e,showLabels:n=!1,size:r="sm"})=>{const{canUndo:s,canRedo:i,undo:o,redo:l}=Rh(t);C.useEffect(()=>{if(!t)return;const d=u=>{t.isFocused&&(u.ctrlKey||u.metaKey)&&(u.key==="z"&&!u.shiftKey?(u.preventDefault(),o()):(u.key==="z"&&u.shiftKey||u.key==="y")&&(u.preventDefault(),l()))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,o,l]);const a=r==="sm"?"sm":r==="lg"?"lg":"default",c=r==="sm"?"h-4 w-4":r==="lg"?"h-6 w-6":"h-5 w-5";return m.jsxs("div",{className:Oe.cn("flex items-center gap-1",e),children:[m.jsxs(le.Button,{variant:s?"outline":"ghost",size:a,onClick:o,disabled:!s,title:`Undo last action (${eu("undo")})`,"aria-label":"Undo last action",className:Oe.cn("transition-all duration-200 border-2",r==="sm"?"h-8 w-8 p-0":r==="lg"?"h-10 w-10 p-0":"h-9 w-9 p-0",s?"border-primary/20 hover:border-primary/40 hover:bg-primary/10 hover:text-primary hover:scale-105 active:scale-95 shadow-sm":"opacity-40 cursor-not-allowed border-transparent",s&&"bg-primary/5",n&&"w-auto px-3"),children:[m.jsx(GI,{className:Oe.cn(c,"transition-colors duration-200",s?s?"text-primary":"text-current":"text-muted-foreground")}),n&&m.jsx("span",{className:"ml-2",children:"Undo"})]}),m.jsxs(le.Button,{variant:i?"outline":"ghost",size:a,onClick:l,disabled:!i,title:`Redo last undone action (${eu("redo")})`,"aria-label":"Redo last undone action",className:Oe.cn("transition-all duration-200 border-2",r==="sm"?"h-8 w-8 p-0":r==="lg"?"h-10 w-10 p-0":"h-9 w-9 p-0",i?"border-primary/20 hover:border-primary/40 hover:bg-primary/10 hover:text-primary hover:scale-105 active:scale-95 shadow-sm":"opacity-40 cursor-not-allowed border-transparent",i&&"bg-primary/5",n&&"w-auto px-3"),children:[m.jsx(wI,{className:Oe.cn(c,"transition-colors duration-200",i?i?"text-primary":"text-current":"text-muted-foreground")}),n&&m.jsx("span",{className:"ml-2",children:"Redo"})]})]})},Fe=({onClick:t,isActive:e,disabled:n,children:r,title:s,ariaLabel:i,shortcut:o})=>{const l=o?`${s} (${o})`:s;return m.jsx(le.Button,{variant:e?"default":"ghost",size:"sm",onClick:t,disabled:n,title:l,"aria-label":i||s,className:`h-8 w-8 p-0 transition-all duration-200 ${n?"opacity-40 cursor-not-allowed":"hover:bg-accent hover:text-accent-foreground hover:scale-105"}`,children:r})},dj=({editor:t})=>m.jsxs(gt.Popover,{children:[m.jsx(gt.PopoverTrigger,{asChild:!0,children:m.jsxs(le.Button,{variant:"ghost",size:"sm",className:"h-8 px-2","aria-label":"Font size menu",title:"Font size menu",children:[m.jsx(Wr,{className:"h-4 w-4 mr-1"}),"Size"]})}),m.jsx(gt.PopoverContent,{onFocusOutside:e=>e.preventDefault(),className:"w-[360px] p-0",side:"bottom",align:"start",children:m.jsx(pw,{editor:t,className:"p-4"})})]}),uj=({editor:t})=>m.jsxs(gt.Popover,{children:[m.jsx(gt.PopoverTrigger,{asChild:!0,children:m.jsx(le.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0","aria-label":"Color menu",title:"Color menu",children:m.jsx(vh,{className:"h-4 w-4"})})}),m.jsx(gt.PopoverContent,{onFocusOutside:e=>e.preventDefault(),className:"w-[380px] p-0",side:"bottom",align:"start",children:m.jsx(fw,{editor:t,className:"p-4"})})]}),hj=({editor:t})=>{const e=async()=>{const s=ja(t);if(s){const o=await s();o?.src&&(t.chain().focus().setImage({src:o.src,alt:o.alt||void 0}).run(),o.blurDataURL&&t.chain().focus().updateAttributes("image",{blurDataURL:o.blurDataURL}).run());return}const i=window.prompt("Enter image URL:");i&&t.chain().focus().setImage({src:i}).run()},n=()=>{t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},r=()=>{const s=window.prompt("Enter URL:");s&&t.chain().focus().setLink({href:s}).run()};return m.jsxs(We.DropdownMenu,{children:[m.jsx(We.DropdownMenuTrigger,{asChild:!0,children:m.jsx(le.Button,{variant:"ghost",size:"sm",className:"h-8 px-2",children:"Insert"})}),m.jsxs(We.DropdownMenuContent,{children:[m.jsxs(We.DropdownMenuItem,{onClick:e,children:[m.jsx(zr,{className:"h-4 w-4 mr-2"}),"Image"]}),m.jsxs(We.DropdownMenuItem,{onClick:n,children:[m.jsx(qi,{className:"h-4 w-4 mr-2"}),"Table"]}),m.jsxs(We.DropdownMenuItem,{onClick:r,children:[m.jsx(Ta,{className:"h-4 w-4 mr-2"}),"Link"]}),m.jsxs(We.DropdownMenuItem,{onClick:()=>t.chain().focus().setHorizontalRule().run(),children:[m.jsx(_a,{className:"h-4 w-4 mr-2"}),"Horizontal Rule"]}),m.jsx(We.DropdownMenuSeparator,{}),m.jsxs(We.DropdownMenuItem,{onClick:()=>{const s=window.prompt("Enter CSS (without <style> tags):","/* your styles */");if(s!=null){const i=`<style>${s}</style>`;t.commands.insertContentAt({from:0,to:0},i)}},children:[m.jsx(Nr,{className:"h-4 w-4 mr-2"}),"CSS Block"]}),m.jsxs(We.DropdownMenuItem,{onClick:()=>{const s=window.prompt("Enter JavaScript (without <script> tags):","// your script");if(s!=null){const i=`<script>${s}<\/script>`,o=t.state.doc.content.size;t.commands.insertContentAt(o,i)}},children:[m.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Script Block"]}),m.jsxs(We.DropdownMenuItem,{onClick:()=>{const s=window.prompt("Optional class for DIV:",""),i=window.prompt("Optional inline style for DIV:",""),o=window.prompt("Optional content for DIV:","New block"),l=`${s?` class="${s}"`:""}${i?` style="${i}"`:""}`,c=o?`<p>${(d=>d.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"))(o)}</p>`:"<p><br /></p>";t.chain().focus().insertContent(`<div${l}>${c}</div>`).run()},children:[m.jsx(Nr,{className:"h-4 w-4 mr-2"}),"DIV Block"]}),m.jsx(We.DropdownMenuSeparator,{}),m.jsxs(We.DropdownMenuItem,{onClick:()=>t.chain().focus().setAlertWidget().run(),children:[m.jsx(Oa,{className:"h-4 w-4 mr-2"}),"Alert Widget"]}),m.jsxs(We.DropdownMenuItem,{onClick:()=>t.chain().focus().setCtaWidget({text:"Learn more",url:"",style:"primary",size:"medium",textAlign:"center"}).run(),children:[m.jsx(Na,{className:"h-4 w-4 mr-2"}),"CTA Widget"]})]})]})},fj=({editor:t})=>{const e=()=>{const s=t.getHTML(),i=new Blob([s],{type:"text/html"}),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.download="document.html",l.click(),URL.revokeObjectURL(o)},n=()=>{const s=JSON.stringify(t.getJSON(),null,2),i=new Blob([s],{type:"application/json"}),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.download="document.json",l.click(),URL.revokeObjectURL(o)},r=()=>{const s=t.getText(),i=new Blob([s],{type:"text/plain"}),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.download="document.txt",l.click(),URL.revokeObjectURL(o)};return m.jsxs(We.DropdownMenu,{children:[m.jsx(We.DropdownMenuTrigger,{asChild:!0,children:m.jsx(le.Button,{variant:"ghost",size:"sm",className:"h-8 px-2","aria-label":"Export menu",title:"Export menu",children:m.jsx(Jx,{className:"h-4 w-4 mr-1"})})}),m.jsxs(We.DropdownMenuContent,{children:[m.jsx(We.DropdownMenuItem,{onClick:e,children:"Export as HTML"}),m.jsx(We.DropdownMenuItem,{onClick:n,children:"Export as JSON"}),m.jsx(We.DropdownMenuItem,{onClick:r,children:"Export as Text"})]})]})},Dh=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(""),[i,o]=C.useState(!1),[l,a]=C.useState(null),c=C.useRef([]);if(C.useEffect(()=>{if(!t)return;const f=g=>{try{const y=t.getHTML();s($c(y)),n(!0)}catch{}},p="editor:openSourceView";return window.addEventListener(p,f),()=>window.removeEventListener(p,f)},[t]),!t)return null;const d=()=>{const f=t.getHTML();s($c(f)),n(!0)},u=()=>{t.chain().focus().setContent(r).run(),n(!1)},h=()=>{for(const x of c.current)try{URL.revokeObjectURL(x)}catch{}c.current=[];const f=t.getHTML(),y=new DOMParser().parseFromString(`<div id="__content__">${f}</div>`,"text/html").body.querySelector("#__content__");Array.from(y.querySelectorAll("script")).forEach(x=>{if(!x.getAttribute("src")){const k=x.textContent||"",v=new Blob([k],{type:"text/javascript"}),T=URL.createObjectURL(v);x.setAttribute("src",T),x.textContent="",c.current.push(T)}});const M=`<!doctype html><html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Preview</title></head><body>${y.innerHTML}</body></html>`,S=new Blob([M],{type:"text/html"}),A=URL.createObjectURL(S);c.current.push(A),l&&URL.revokeObjectURL(l),a(A),o(!0)};return m.jsxs("div",{className:"border-b bg-background p-2 relative",children:[m.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[m.jsx("div",{className:"flex items-center gap-1 mr-2 p-1 rounded-md bg-muted/30 border border-border/50",children:m.jsx(Oh,{editor:t,size:"sm",showLabels:!1})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),isActive:t.isActive("heading",{level:1}),title:"Heading 1",children:m.jsx(vs,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),isActive:t.isActive("heading",{level:2}),title:"Heading 2",children:m.jsx(Vi,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),isActive:t.isActive("heading",{level:3}),title:"Heading 3",children:m.jsx(Aa,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleBold().run(),isActive:t.isActive("bold"),title:"Bold",children:m.jsx(Gl,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleItalic().run(),isActive:t.isActive("italic"),title:"Italic",children:m.jsx(kh,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleUnderline().run(),isActive:t.isActive("underline"),title:"Underline",children:m.jsx(Ch,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleStrike().run(),isActive:t.isActive("strike"),title:"Strikethrough",children:m.jsx(Yx,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleCode().run(),isActive:t.isActive("code"),title:"Inline Code",children:m.jsx(Rs,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleSubscript().run(),isActive:t.isActive("subscript"),title:"Subscript",children:m.jsx(Xx,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleSuperscript().run(),isActive:t.isActive("superscript"),title:"Superscript",children:m.jsx(Zx,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:()=>t.chain().focus().setTextAlign("left").run(),isActive:t.isActive({textAlign:"left"}),title:"Align Left",children:m.jsx(Ss,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().setTextAlign("center").run(),isActive:t.isActive({textAlign:"center"}),title:"Align Center",children:m.jsx(Ki,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().setTextAlign("right").run(),isActive:t.isActive({textAlign:"right"}),title:"Align Right",children:m.jsx(Gi,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().setTextAlign("justify").run(),isActive:t.isActive({textAlign:"justify"}),title:"Justify",children:m.jsx(Sh,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleBulletList().run(),isActive:t.isActive("bulletList"),title:"Bullet List",children:m.jsx(Os,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleOrderedList().run(),isActive:t.isActive("orderedList"),title:"Numbered List",children:m.jsx(Wi,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleTaskList().run(),isActive:t.isActive("taskList"),title:"Task List",children:m.jsx(Ra,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleBlockquote().run(),isActive:t.isActive("blockquote"),title:"Blockquote",children:m.jsx(Ji,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleCodeBlock().run(),isActive:t.isActive("codeBlock"),title:"Code Block",children:m.jsx(Nr,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(dj,{editor:t}),m.jsx(uj,{editor:t}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(hj,{editor:t}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:d,title:"View Source (HTML)",children:m.jsx(JL,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:h,title:"Preview (executes scripts)",children:m.jsx(KL,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(fj,{editor:t})]}),e&&m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:m.jsxs("div",{className:"bg-background border rounded-md shadow-xl w-[90vw] max-w-4xl h-[70vh] flex flex-col",children:[m.jsx("div",{className:"p-3 border-b font-semibold",children:"Edit HTML Source"}),m.jsx("textarea",{className:"flex-1 p-3 font-mono text-sm outline-none resize-none bg-muted/30",value:r,onChange:f=>s(f.target.value),spellCheck:!1}),m.jsxs("div",{className:"p-3 border-t flex justify-end gap-2",children:[m.jsx(le.Button,{variant:"outline",size:"sm",onClick:()=>n(!1),children:"Cancel"}),m.jsx(le.Button,{variant:"secondary",size:"sm",onClick:()=>s($c(r)),children:"Format"}),m.jsx(le.Button,{size:"sm",onClick:u,children:"Apply"})]})]})}),i&&m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:m.jsxs("div",{className:"bg-background border rounded-md shadow-xl w-[95vw] max-w-5xl h-[80vh] flex flex-col",children:[m.jsxs("div",{className:"p-3 border-b flex items-center justify-between",children:[m.jsx("div",{className:"font-semibold",children:"Preview"}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx(le.Button,{variant:"outline",size:"sm",onClick:()=>{h()},children:"Refresh"}),m.jsx(le.Button,{size:"sm",onClick:()=>{for(const f of c.current)try{URL.revokeObjectURL(f)}catch{}c.current=[],l&&URL.revokeObjectURL(l),a(null),o(!1)},children:"Close"})]})]}),m.jsx("div",{className:"flex-1",children:m.jsx("iframe",{title:"Editor Preview",className:"w-full h-full",sandbox:"allow-scripts allow-same-origin allow-modals",src:l??void 0})})]})})]})},bw=({editor:t,className:e})=>{const[n,r]=C.useState(!1),[s,i]=C.useState("format"),[o,l]=C.useState(!1),a=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||window.innerWidth<=768;C.useEffect(()=>{const h=()=>{r(a())};return h(),window.addEventListener("resize",h),()=>window.removeEventListener("resize",h)},[]),C.useEffect(()=>{if(!t)return;const h=()=>{const{selection:f}=t.state;!f.empty&&a()?r(!0):o||r(!1)};return t.on("selectionUpdate",h),t.on("focus",h),t.on("blur",()=>{o||r(!1)}),()=>{t.off("selectionUpdate",h),t.off("focus",h),t.off("blur",()=>r(!1))}},[t,o]);const c=[{icon:m.jsx(Gl,{className:"h-4 w-4"}),label:"Bold",action:()=>t.chain().focus().toggleBold().run(),isActive:()=>t.isActive("bold"),section:"format"},{icon:m.jsx(kh,{className:"h-4 w-4"}),label:"Italic",action:()=>t.chain().focus().toggleItalic().run(),isActive:()=>t.isActive("italic"),section:"format"},{icon:m.jsx(Ch,{className:"h-4 w-4"}),label:"Underline",action:()=>t.chain().focus().toggleUnderline().run(),isActive:()=>t.isActive("underline"),section:"format"},{icon:m.jsx(Rs,{className:"h-4 w-4"}),label:"Code",action:()=>t.chain().focus().toggleCode().run(),isActive:()=>t.isActive("code"),section:"format"},{icon:m.jsx(vh,{className:"h-4 w-4"}),label:"Highlight",action:()=>t.chain().focus().toggleHighlight().run(),isActive:()=>t.isActive("highlight"),section:"format"},{icon:m.jsx(Wr,{className:"h-4 w-4"}),label:"Paragraph",action:()=>t.chain().focus().setParagraph().run(),isActive:()=>t.isActive("paragraph"),section:"blocks"},{icon:m.jsx(vs,{className:"h-4 w-4"}),label:"Heading 1",action:()=>t.chain().focus().toggleHeading({level:1}).run(),isActive:()=>t.isActive("heading",{level:1}),section:"blocks"},{icon:m.jsx(Vi,{className:"h-4 w-4"}),label:"Heading 2",action:()=>t.chain().focus().toggleHeading({level:2}).run(),isActive:()=>t.isActive("heading",{level:2}),section:"blocks"},{icon:m.jsx(Aa,{className:"h-4 w-4"}),label:"Heading 3",action:()=>t.chain().focus().toggleHeading({level:3}).run(),isActive:()=>t.isActive("heading",{level:3}),section:"blocks"},{icon:m.jsx(Os,{className:"h-4 w-4"}),label:"Bullet List",action:()=>t.chain().focus().toggleBulletList().run(),isActive:()=>t.isActive("bulletList"),section:"blocks"},{icon:m.jsx(Wi,{className:"h-4 w-4"}),label:"Numbered List",action:()=>t.chain().focus().toggleOrderedList().run(),isActive:()=>t.isActive("orderedList"),section:"blocks"},{icon:m.jsx(Ra,{className:"h-4 w-4"}),label:"Task List",action:()=>t.chain().focus().toggleTaskList().run(),isActive:()=>t.isActive("taskList"),section:"blocks"},{icon:m.jsx(Ji,{className:"h-4 w-4"}),label:"Quote",action:()=>t.chain().focus().toggleBlockquote().run(),isActive:()=>t.isActive("blockquote"),section:"blocks"},{icon:m.jsx(Ta,{className:"h-4 w-4"}),label:"Link",action:()=>{const h=window.prompt("Enter URL:");h&&t.chain().focus().setLink({href:h}).run()},isActive:()=>t.isActive("link"),section:"insert"},{icon:m.jsx(zr,{className:"h-4 w-4"}),label:"Image",action:async()=>{const h=ja(t);if(h){const p=await h();p?.src&&t.chain().focus().setImage({src:p.src,alt:p.alt||void 0}).run();return}const f=window.prompt("Enter image URL:");f&&t.chain().focus().setImage({src:f}).run()},section:"insert"},{icon:m.jsx(qi,{className:"h-4 w-4"}),label:"Table",action:()=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),section:"insert"},{icon:m.jsx(Ss,{className:"h-4 w-4"}),label:"Align Left",action:()=>t.chain().focus().setTextAlign("left").run(),isActive:()=>t.isActive({textAlign:"left"}),section:"align"},{icon:m.jsx(Ki,{className:"h-4 w-4"}),label:"Align Center",action:()=>t.chain().focus().setTextAlign("center").run(),isActive:()=>t.isActive({textAlign:"center"}),section:"align"},{icon:m.jsx(Gi,{className:"h-4 w-4"}),label:"Align Right",action:()=>t.chain().focus().setTextAlign("right").run(),isActive:()=>t.isActive({textAlign:"right"}),section:"align"}],d=[{key:"format",label:"Format",icon:m.jsx(Gl,{className:"h-3 w-3"})},{key:"blocks",label:"Blocks",icon:m.jsx(vs,{className:"h-3 w-3"})},{key:"insert",label:"Insert",icon:m.jsx(zr,{className:"h-3 w-3"})},{key:"align",label:"Align",icon:m.jsx(Ss,{className:"h-3 w-3"})}],u=c.filter(h=>h.section===s);return!n&&!o?null:m.jsxs("div",{className:Oe.cn("fixed bottom-0 left-0 right-0 z-50 bg-background border-t border-border shadow-lg","transform transition-transform duration-300 ease-in-out",n||o?"translate-y-0":"translate-y-full",e),children:[m.jsx("div",{className:"flex justify-center py-2 border-b border-border",children:m.jsxs(le.Button,{variant:"ghost",size:"sm",onClick:()=>l(!o),className:"flex items-center gap-2",children:[o?m.jsx(tw,{className:"h-4 w-4"}):m.jsx(pI,{className:"h-4 w-4"}),m.jsx("span",{className:"text-xs",children:o?"Close":"Tools"})]})}),(o||n)&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"flex border-b border-border bg-muted/50",children:d.map(h=>m.jsx(le.Button,{variant:s===h.key?"default":"ghost",size:"sm",onClick:()=>i(h.key),className:"flex-1 rounded-none text-xs py-2 h-auto",children:m.jsxs("div",{className:"flex flex-col items-center gap-1",children:[h.icon,m.jsx("span",{children:h.label})]})},h.key))}),m.jsx("div",{className:"p-2",children:m.jsx("div",{className:"flex flex-wrap gap-1 justify-center",children:u.map((h,f)=>m.jsxs(le.Button,{variant:h.isActive?.()?"default":"ghost",size:"sm",onClick:h.action,className:"flex flex-col items-center gap-1 h-auto py-2 px-3 min-w-[60px]",title:h.label,children:[h.icon,m.jsx("span",{className:"text-xs",children:h.label})]},f))})})]}),m.jsx("div",{className:"h-safe-area-inset-bottom"})]})},Pa=({content:t,onChange:e,placeholder:n,editable:r=!0,showToolbar:s=!0,showCharacterCount:i=!0,className:o,onFocus:l,onBlur:a,useEnhancedFloatingMenu:c=!0,showMobileToolbar:d=!0,enableAdvancedPlaceholders:u=!0,enableFocusMode:h=!1,showKeyboardShortcuts:f=!1})=>{const p=C.useRef(null),[g,y]=C.useState({isOpen:!1,searchTerm:"",replaceTerm:"",currentMatch:0,totalMatches:0,caseSensitive:!1,wholeWord:!1}),b=hb({extensions:Mh,content:t,editable:r,immediatelyRender:!1,onUpdate:({editor:k})=>{e(k.getHTML())},onFocus:()=>{l?.()},onBlur:()=>{a?.()},editorProps:{attributes:{class:Oe.cn("prose dark:prose-invert prose-sm sm:prose-base lg:prose-lg xl:prose-2xl","mx-auto focus:outline-none p-4 min-h-[500px] w-full","prose-headings:scroll-mt-[80px] prose-headings:font-semibold","prose-h1:text-4xl prose-h2:text-3xl prose-h3:text-2xl","prose-p:leading-7 prose-li:leading-7","prose-pre:bg-muted prose-pre:border prose-pre:rounded-lg","prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:rounded","prose-blockquote:border-l-4 prose-blockquote:border-primary prose-blockquote:pl-4","prose-table:border-collapse prose-table:border prose-table:border-border","prose-th:border prose-th:border-border prose-th:bg-muted prose-th:p-2","prose-td:border prose-td:border-border prose-td:p-2","prose-img:rounded-lg prose-img:shadow-sm",o)},handleKeyDown:(k,v)=>{if(v.ctrlKey||v.metaKey)switch(v.key){case"f":return v.preventDefault(),y(T=>({...T,isOpen:!T.isOpen})),!0;case"s":return v.preventDefault(),!0;default:return!1}return!1}}});C.useEffect(()=>{if(!b)return;const k=b.getHTML();if(t!==k){const{from:v,to:T}=b.state.selection;b.commands.setContent(t,{emitUpdate:!1}),b.commands.setTextSelection({from:v,to:T})}},[t,b]);const w=k=>{if(!b||!k){y($=>({...$,totalMatches:0,currentMatch:0}));return}const v=b.getText(),T=g.caseSensitive?"g":"gi",N=g.wholeWord?`\\b${k}\\b`:k,H=new RegExp(N,T),V=v.match(H);y($=>({...$,totalMatches:V?V.length:0,currentMatch:V?1:0}))},M=()=>{if(!b||!g.searchTerm)return;const k=b.getHTML(),v=g.caseSensitive?"g":"gi",T=g.wholeWord?`\\b${g.searchTerm}\\b`:g.searchTerm,N=new RegExp(T,v),H=k.replace(N,g.replaceTerm);b.commands.setContent(H),y(V=>({...V,totalMatches:0,currentMatch:0}))};if(!b)return null;const S=b.storage?.characterCount,A=S?.characters?.()??0,x=S?.words?.()??0;return m.jsxs("div",{ref:p,className:Oe.cn("relative w-full rounded-lg border bg-background shadow-sm","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",o),children:[s&&m.jsx(Dh,{editor:b}),g.isOpen&&m.jsxs("div",{className:"border-b bg-muted/50 p-3",children:[m.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[m.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[m.jsx(_I,{className:"h-4 w-4 text-muted-foreground"}),m.jsx(ns.Input,{placeholder:"Search...",value:g.searchTerm,onChange:k=>{const v=k.target.value;y(T=>({...T,searchTerm:v})),w(v)},className:"h-8"}),m.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:g.totalMatches>0?`${g.currentMatch}/${g.totalMatches}`:"No matches"})]}),m.jsx(le.Button,{variant:"ghost",size:"sm",onClick:()=>y(k=>({...k,isOpen:!1})),children:m.jsx(tw,{className:"h-4 w-4"})})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(vI,{className:"h-4 w-4 text-muted-foreground"}),m.jsx(ns.Input,{placeholder:"Replace with...",value:g.replaceTerm,onChange:k=>y(v=>({...v,replaceTerm:k.target.value})),className:"h-8 flex-1"}),m.jsx(le.Button,{variant:"outline",size:"sm",onClick:M,disabled:!g.searchTerm||g.totalMatches===0,children:"Replace All"})]})]}),m.jsx(Nh,{editor:b}),c?m.jsx(mw,{editor:b,wrapperRef:p}):m.jsx(_h,{editor:b}),m.jsx(db,{editor:b}),i&&S&&m.jsxs("div",{className:"absolute bottom-2 right-2 z-10 text-xs text-muted-foreground bg-background/80 backdrop-blur-sm rounded px-2 py-1 border",children:[A," characters / ",x," words"]}),f&&m.jsxs("div",{className:"absolute bottom-2 left-2 text-xs text-muted-foreground bg-background/80 backdrop-blur-sm rounded px-2 py-1 border opacity-0 hover:opacity-100 transition-opacity",children:[m.jsx("div",{children:"Ctrl+F: Search"}),m.jsx("div",{children:"Ctrl+S: Save"}),m.jsx("div",{children:"/: Commands"}),m.jsx("div",{children:"Ctrl+K: Insert Link"}),m.jsx("div",{children:"Ctrl+Shift+H: Highlight"}),m.jsx("div",{children:"Ctrl+Alt+1-6: Headings"})]}),d&&m.jsx(bw,{editor:b})]})},pj=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(!1),{x:i,y:o,refs:l,strategy:a,update:c}=Xi({placement:"top",strategy:"fixed",open:e,onOpenChange:n,middleware:[Yi(-12)],whileElementsMounted:Ms}),d=C.useCallback(()=>t.isActive("image"),[t]),u=t.getAttributes("image")||{},h=C.useCallback(()=>{const{state:y,view:b}=t,w=()=>{try{if(y.selection instanceof q){const k=b.nodeDOM(y.selection.from);if(k){const v=k.closest?.(".tiptap-image-wrapper")??k;return v.querySelector("img")??v}}const A=b.dom.querySelector(".tiptap-image-wrapper.ProseMirror-selectednode");if(A)return A.querySelector("img")??A;const x=b.dom.querySelector(".ProseMirror-selectednode");if(x){const k=x.closest?.(".tiptap-image-wrapper")??x;return k.querySelector("img")??k}}catch{}return null},M=h._lastEl,S=w()??M;if(S){h._lastEl=S;const A={getBoundingClientRect:()=>{const x=w()??h._lastEl;return x?x.getBoundingClientRect():new DOMRect(0,0,0,0)}};l.setReference(A)}else{const A=b.coordsAtPos(y.selection.from),x={getBoundingClientRect:()=>new DOMRect(A.left,A.top,0,0)};l.setReference(x)}requestAnimationFrame(()=>{c(),requestAnimationFrame(()=>s(!0))})},[t,l,c]);if(C.useEffect(()=>{const y=()=>{const b=d();n(b),s(!1),b&&h()};return y(),t.on("selectionUpdate",y),t.on("transaction",y),t.on("focus",y),t.on("blur",()=>n(!1)),()=>{t.off("selectionUpdate",y),t.off("transaction",y),t.off("focus",y)}},[t,d,h]),!e)return null;const f=y=>{t.chain().focus().updateAttributes("image",{align:y}).run(),requestAnimationFrame(()=>h())},p=()=>{t.chain().focus().deleteSelection().run()},g=()=>{const y=u?.src;if(y)try{const b=document.createElement("a");b.href=y;const w=(y.split("?")[0]||"").split("/").pop()||"image";b.download=w,document.body.appendChild(b),b.click(),b.remove()}catch{}};return m.jsxs("div",{ref:l.setFloating,style:{position:a,top:o??0,left:i??0,zIndex:10002,visibility:r?"visible":"hidden",pointerEvents:"auto"},className:"bg-background/95 backdrop-blur border rounded-full shadow-lg px-3 py-2 flex items-center gap-1",onMouseDown:y=>y.preventDefault(),children:[m.jsx(le.Button,{size:"icon",variant:u.align==="left"?"default":"ghost",title:"Align left",onClick:()=>f("left"),children:m.jsx(Ss,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:u.align==="center"?"default":"ghost",title:"Align center",onClick:()=>f("center"),children:m.jsx(Ki,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:u.align==="right"?"default":"ghost",title:"Align right",onClick:()=>f("right"),children:m.jsx(Gi,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:"ghost",title:"Download",onClick:g,children:m.jsx(Jx,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:"ghost",title:"Delete",onClick:p,children:m.jsx(Qx,{className:"h-4 w-4"})})]})},ng=t=>t.isActive("table")||t.isActive("tableCell")||t.isActive("tableHeader")||t.isActive("tableRow"),mj=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(!1),{refs:i,x:o,y:l,strategy:a,update:c}=Xi({placement:"bottom",strategy:"fixed",middleware:[Yi(12),La(),Da()],whileElementsMounted:Ms,open:e,onOpenChange:n}),d=C.useCallback(()=>{const{state:v,view:T}=t;try{const{from:N}=v.selection,{node:H}=T.domAtPos(N);let V=null;return H.nodeType===Node.ELEMENT_NODE?V=H:(H.nodeType===Node.TEXT_NODE||H?.parentElement)&&(V=H.parentElement),V?.closest?.("td, th")??null}catch{return null}},[t]),u=C.useCallback(()=>d()?.closest("table")??null,[d]),h=C.useCallback(()=>{if(!ng(t)){n(!1);return}const v=u();if(!v){n(!1);return}i.setReference(v),n(!0),s(!1),requestAnimationFrame(()=>{c(),requestAnimationFrame(()=>s(!0))})},[t,i,u,c]);if(C.useEffect(()=>{const v=()=>{ng(t)?h():n(!1)},T=()=>n(!1);return v(),t.on("selectionUpdate",v),t.on("transaction",v),t.on("focus",v),t.on("blur",T),()=>{t.off("selectionUpdate",v),t.off("transaction",v),t.off("focus",v),t.off("blur",T)}},[t,h]),!e)return null;const f=t.can(),p=typeof f.addRowAfter=="function"?f.addRowAfter():!1,g=typeof f.deleteRow=="function"?f.deleteRow():!1,y=typeof f.addColumnAfter=="function"?f.addColumnAfter():!1,b=typeof f.deleteColumn=="function"?f.deleteColumn():!1,w=typeof f.deleteTable=="function"?f.deleteTable():!1,M=()=>{t.chain().focus().addRowAfter().run(),h()},S=()=>{t.chain().focus().deleteRow().run(),h()},A=()=>{t.chain().focus().addColumnAfter().run(),h()},x=()=>{t.chain().focus().deleteColumn().run(),h()},k=()=>{t.chain().focus().deleteTable().run(),n(!1)};return m.jsxs("div",{ref:i.setFloating,style:{position:a,top:l??0,left:o??0,zIndex:10002,visibility:r?"visible":"hidden"},className:"flex items-center gap-1 rounded-full border bg-background/95 px-2 py-1 shadow-lg",onMouseDown:v=>v.preventDefault(),children:[m.jsx(le.Button,{size:"icon",variant:"ghost",onClick:M,disabled:!p,title:"Add row below","aria-label":"Add row below",children:m.jsx(TI,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:"ghost",onClick:S,disabled:!g,title:"Delete current row","aria-label":"Delete current row",children:m.jsx(MI,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:"ghost",onClick:A,disabled:!y,title:"Add column to the right","aria-label":"Add column to the right",children:m.jsx(FL,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:"ghost",onClick:x,disabled:!b,title:"Delete current column","aria-label":"Delete current column",children:m.jsx(HL,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:"ghost",onClick:k,disabled:!w,title:"Delete table","aria-label":"Delete table",children:m.jsx(Qx,{className:"h-4 w-4"})})]})},xw=({content:t,onChange:e,placeholder:n,editable:r=!0,showToolbar:s=!0,showCharacterCount:i=!0,className:o,onFocus:l,onBlur:a,openImagePicker:c})=>{const d=C.useRef(null),u=hb({extensions:Mh,content:t,editable:r,immediatelyRender:!1,onUpdate:({editor:g})=>e(g.getHTML()),onFocus:()=>{l?.()},onBlur:()=>{a?.()},editorProps:{attributes:{class:Oe.cn("prose dark:prose-invert prose-sm sm:prose-base lg:prose-lg xl:prose-2xl","mx-auto focus:outline-none min-h-[500px] w-full","pl-14 pr-4 py-4","prose-headings:scroll-mt-[80px] prose-headings:font-semibold","prose-h1:text-4xl prose-h2:text-3xl prose-h3:text-2xl","prose-p:leading-7 prose-li:leading-7","prose-pre:bg-muted prose-pre:border prose-pre:rounded-lg","prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:rounded","prose-blockquote:border-l-4 prose-blockquote:border-primary prose-blockquote:pl-4","prose-table:border-collapse prose-table:border prose-table:border-border","prose-th:border prose-th:border-border prose-th:bg-muted prose-th:p-2","prose-td:border prose-td:border-border prose-td:p-2","prose-img:rounded-lg prose-img:shadow-sm")}}});if(C.useEffect(()=>{if(u)return Xm(u,c),()=>Xm(u,void 0)},[u,c]),C.useEffect(()=>{if(!u)return;const g=u.getHTML();if(t!==g){const{from:y,to:b}=u.state.selection;u.commands.setContent(t,{emitUpdate:!1}),u.commands.setTextSelection({from:y,to:b})}},[t,u]),C.useEffect(()=>{if(!(!u||typeof window>"u"))return window.__nextblockEditor=u,()=>{window.__nextblockEditor===u&&delete window.__nextblockEditor}},[u]),C.useEffect(()=>{if(!u||typeof window>"u")return;const g=()=>{const w=window.__dragHandleElement;if(!w)return;const M=w.parentElement,S=u.view.dom.parentElement??u.view.dom;M&&S&&!M.isConnected&&S.appendChild(M)},y=()=>g();g(),u.on("selectionUpdate",y),u.on("transaction",y),u.on("focus",y);const b=window.setInterval(g,2e3);return()=>{u.off("selectionUpdate",y),u.off("transaction",y),u.off("focus",y),window.clearInterval(b)}},[u]),C.useEffect(()=>()=>{typeof document<"u"&&document.body.classList.remove("dragging")},[]),!u)return null;const h=u.storage?.characterCount,f=h?.characters?.()??0,p=h?.words?.()??0;return m.jsxs("div",{ref:d,className:Oe.cn("relative w-full rounded-lg border bg-background shadow-sm","flex flex-col h-full min-h-0","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",o),children:[s&&m.jsx(Dh,{editor:u}),m.jsx(Nh,{editor:u}),m.jsx(_h,{editor:u}),m.jsx(pj,{editor:u}),m.jsx(mj,{editor:u}),m.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:m.jsx(db,{editor:u})}),i&&h&&m.jsxs("div",{className:"absolute bottom-2 right-2 text-xs z-10 text-muted-foreground bg-background/80 backdrop-blur-sm rounded px-2 py-1 border",children:[f," characters / ",p," words"]})]})},ww=C.forwardRef(({className:t,...e},n)=>m.jsx("div",{ref:n,className:Oe.cn("flex items-center gap-1 rounded-md bg-background p-1",t),...e}));ww.displayName="Toolbar";const kw=C.forwardRef(({className:t,...e},n)=>m.jsx("div",{ref:n,className:Oe.cn("flex items-center gap-1",t),...e}));kw.displayName="ToolbarGroup";const vw=C.forwardRef(({className:t,isActive:e,...n},r)=>m.jsx("button",{ref:r,className:Oe.cn("inline-flex items-center justify-center rounded-md p-1.5 text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{"bg-accent text-accent-foreground":e},t),...n}));vw.displayName="ToolbarButton";const Sw=C.forwardRef(({className:t,...e},n)=>m.jsx("div",{ref:n,className:Oe.cn("mx-1 h-7 w-px bg-muted",t),...e}));Sw.displayName="ToolbarSeparator";var gj=t=>{const{className:e="drag-handle",children:n,editor:r,pluginKey:s=Ox,onNodeChange:i,onElementDragStart:o,onElementDragEnd:l,computePositionConfig:a=Wd}=t,[c,d]=C.useState(null),u=C.useRef(null);return C.useEffect(()=>{let h=null;return c?r.isDestroyed?()=>{u.current=null}:(u.current||(h=Dx({editor:r,element:c,pluginKey:s,computePositionConfig:{...Wd,...a},onElementDragStart:o,onElementDragEnd:l,onNodeChange:i}),u.current=h.plugin,r.registerPlugin(u.current)),()=>{r.unregisterPlugin(s),u.current=null,h&&(h.unbind(),h=null)}):()=>{u.current=null}},[c,r,i,s,a,o,l]),m.jsx("div",{className:e,style:{visibility:"hidden",position:"absolute"},ref:d,children:n})},yj=gj;const bj=({editor:t,className:e,onDragStart:n,onDragEnd:r,onNodeChange:s})=>{const i=C.useRef(null),o=C.useMemo(()=>a=>{a.preventDefault(),a.stopPropagation();const c=i.current;if(!c)return;const d=new CustomEvent("tiptap-gutter-toggle",{bubbles:!0,detail:{handle:c,button:a.currentTarget}});c.dispatchEvent(d)},[]),l=a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),o(a))};return t?m.jsx(yj,{editor:t,className:Oe.cn("tiptap-drag-handle",e),onElementDragStart:n,onElementDragEnd:r,onNodeChange:a=>s?.(a),children:m.jsxs("div",{ref:i,className:"tiptap-drag-handle__group",role:"group","data-orientation":"horizontal",children:[m.jsx("button",{type:"button","aria-label":"Insert block",title:"Insert block",className:"tiptap-drag-handle__button tiptap-drag-handle__button--ghost tiptap-drag-handle__plus",onClick:o,onKeyDown:l,children:m.jsx(xj,{})}),m.jsx("button",{type:"button",className:"tiptap-drag-handle__button tiptap-drag-handle__button--ghost tiptap-drag-handle__grip",role:"button","aria-label":"Drag to reorder",title:"Drag to reorder",tabIndex:0,children:m.jsx(wj,{})})]})}):null},xj=({className:t,...e})=>m.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:Oe.cn("tiptap-drag-handle__icon tiptap-drag-handle__icon--filled",t),...e,children:m.jsx("path",{d:"M13 5C13 4.44772 12.5523 4 12 4C11.4477 4 11 4.44772 11 5V11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H11V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V13H19C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11H13V5Z"})}),wj=({className:t,...e})=>m.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:Oe.cn("tiptap-drag-handle__icon tiptap-drag-handle__icon--filled",t),...e,children:[m.jsx("path",{d:"M9 3C7.89543 3 7 3.89543 7 5C7 6.10457 7.89543 7 9 7C10.1046 7 11 6.10457 11 5C11 3.89543 10.1046 3 9 3Z"}),m.jsx("path",{d:"M9 10C7.89543 10 7 10.8954 7 12C7 13.1046 7.89543 14 9 14C10.1046 14 11 13.1046 11 12C11 10.8954 10.1046 10 9 10Z"}),m.jsx("path",{d:"M7 19C7 17.8954 7.89543 17 9 17C10.1046 17 11 17.8954 11 19C11 20.1046 10.1046 21 9 21C7.89543 21 7 20.1046 7 19Z"}),m.jsx("path",{d:"M15 10C13.8954 10 13 10.8954 13 12C13 13.1046 13.8954 14 15 14C16.1046 14 17 13.1046 17 12C17 10.8954 16.1046 10 15 10Z"}),m.jsx("path",{d:"M13 5C13 3.89543 13.8954 3 15 3C16.1046 3 17 3.89543 17 5C17 6.10457 16.1046 7 15 7C13.8954 7 13 6.10457 13 5Z"}),m.jsx("path",{d:"M15 17C13.8954 17 13 17.8954 13 19C13 20.1046 13.8954 21 15 21C16.1046 21 17 20.1046 17 19C17 17.8954 16.1046 17 15 17Z"})]}),kj=({html:t,className:e})=>{const n=C.useRef(null);return C.useEffect(()=>{const r=n.current;if(!r)return;r.innerHTML=t;const s=[];return Array.from(r.querySelectorAll("script")).forEach(o=>{const l=document.createElement("script");for(const a of Array.from(o.attributes))l.setAttribute(a.name,a.value);if(o.src)l.src=o.src;else{const a=o.textContent||"",c=new Blob([a],{type:l.type||"text/javascript"}),d=URL.createObjectURL(c);l.src=d,l.async=!1,s.push(d)}o.parentNode?.insertBefore(l,o),o.remove()}),()=>{s.forEach(o=>{try{URL.revokeObjectURL(o)}catch(l){process.env.NODE_ENV!=="production"&&console.warn("Failed to revoke object URL",o,l)}})}},[t]),m.jsx("div",{ref:n,className:e})},vj=de.create({name:"enhancedFocus",addOptions(){return{className:"has-focus",mode:"all",showFocusRing:!0,highlightSelection:!0,dimUnfocused:!1,animateTransitions:!0}},addProseMirrorPlugins(){return[new pe({key:new ge("enhancedFocus"),props:{decorations:({doc:t,selection:e})=>{const{from:n,to:r}=e,s=[];if(t.nodesBetween(n,r,(i,o)=>{const l=_e.node(o,o+i.nodeSize,{class:this.options.className});s.push(l)}),this.options.highlightSelection&&n!==r){const i=_e.inline(n,r,{class:"selection-highlight"});s.push(i)}if(this.options.showFocusRing){const i=_e.widget(n,()=>{const o=document.createElement("div");return o.className="focus-ring",o});s.push(i)}return ye.create(t,s)}},view:()=>({update:(t,e)=>{const{state:n}=t,{selection:r}=n,s=e.selection;r.eq(s)||this.editor.emit("selectionUpdate",{editor:this.editor,transaction:n.tr})}})})]},addGlobalAttributes(){return[{types:["paragraph","heading","blockquote","codeBlock","listItem"],attributes:{"data-focused":{default:null,renderHTML:t=>t["data-focused"]?{"data-focused":t["data-focused"]}:{}}}}]},onCreate(){const t=this.editor.view.dom;this.options.animateTransitions&&t.classList.add("focus-transitions"),this.options.dimUnfocused&&t.classList.add("dim-unfocused")},onSelectionUpdate(){const{state:t}=this.editor,{selection:e}=t,{from:n,to:r}=e,s=t.tr;let i=!1;t.doc.descendants((o,l)=>{if(o.isText||o.isLeaf)return;const a=l,c=l+o.nodeSize,d=n>=a&&r<=c,u=o.attrs["data-focused"];d&&!u?(s.setNodeMarkup(l,void 0,{...o.attrs,"data-focused":"true"}),i=!0):!d&&u&&(s.setNodeMarkup(l,void 0,{...o.attrs,"data-focused":null}),i=!0)}),i&&this.editor.view.dispatch(s)},addStorage(){return{isFocused:!1}},onFocus(){this.editor.view.dom.classList.add("editor-focused"),this.storage.isFocused=!0},onBlur(){this.editor.view.dom.classList.remove("editor-focused"),this.storage.isFocused=!1}}),Sj=de.create({name:"keyboardShortcuts",addOptions(){return{enableAdvancedShortcuts:!0,enableCustomShortcuts:!0,showShortcutHints:!1}},addKeyboardShortcuts(){const t={};return this.options.enableAdvancedShortcuts&&(t["Mod-Shift-x"]=()=>this.editor.commands.toggleStrike(),t["Mod-Shift-h"]=()=>this.editor.commands.toggleHighlight(),t["Mod-Shift-c"]=()=>this.editor.commands.toggleCode(),t["Mod-Alt-1"]=()=>this.editor.commands.toggleHeading({level:1}),t["Mod-Alt-2"]=()=>this.editor.commands.toggleHeading({level:2}),t["Mod-Alt-3"]=()=>this.editor.commands.toggleHeading({level:3}),t["Mod-Alt-4"]=()=>this.editor.commands.toggleHeading({level:4}),t["Mod-Alt-5"]=()=>this.editor.commands.toggleHeading({level:5}),t["Mod-Alt-6"]=()=>this.editor.commands.toggleHeading({level:6}),t["Mod-Alt-0"]=()=>this.editor.commands.setParagraph(),t["Mod-Shift-8"]=()=>this.editor.commands.toggleBulletList(),t["Mod-Shift-7"]=()=>this.editor.commands.toggleOrderedList(),t["Mod-Shift-9"]=()=>this.editor.commands.toggleTaskList(),t["Mod-Shift-b"]=()=>this.editor.commands.toggleBlockquote(),t["Mod-Alt-c"]=()=>this.editor.commands.toggleCodeBlock(),t["Mod-Shift-minus"]=()=>this.editor.commands.setHorizontalRule(),t["Mod-Shift-l"]=()=>this.editor.commands.setTextAlign("left"),t["Mod-Shift-e"]=()=>this.editor.commands.setTextAlign("center"),t["Mod-Shift-r"]=()=>this.editor.commands.setTextAlign("right"),t["Mod-Shift-j"]=()=>this.editor.commands.setTextAlign("justify"),t["Mod-comma"]=()=>this.editor.commands.toggleSubscript(),t["Mod-period"]=()=>this.editor.commands.toggleSuperscript(),t["Mod-Alt-t"]=()=>this.editor.can().insertTable()?this.editor.commands.insertTable({rows:3,cols:3,withHeaderRow:!0}):!1,t["Mod-Home"]=()=>this.editor.commands.focus("start"),t["Mod-End"]=()=>this.editor.commands.focus("end"),t["Mod-a"]=()=>this.editor.commands.selectAll(),t["Mod-\\"]=()=>this.editor.commands.unsetAllMarks()&&this.editor.commands.clearNodes(),t["Mod-k"]=()=>{const e=window.prompt("Enter URL:");return e?this.editor.commands.setLink({href:e}):!1},t["Mod-Shift-i"]=()=>{const e=window.prompt("Enter image URL:");return e?this.editor.commands.setImage({src:e}):!1},t["Alt-ArrowUp"]=()=>{const{selection:e}=this.editor.state,{$from:n}=e,r=n.nodeBefore;if(r){const s=n.pos-r.nodeSize;return this.editor.commands.setTextSelection(s)}return!1},t["Alt-ArrowDown"]=()=>{const{selection:e}=this.editor.state,{$to:n}=e,r=n.nodeAfter;if(r){const s=n.pos+r.nodeSize;return this.editor.commands.setTextSelection(s)}return!1},t["Mod-Shift-d"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);return s?this.editor.commands.insertContentAt(r,`
|
|
159
|
-
${s}`):!1},t["Mod-Shift-k"]=()=>{const{selection:e}=this.editor.state,{$from:n,$to:r}=e,s=n.start(),i=r.end();return this.editor.commands.deleteRange({from:s,to:i})},t["Mod-Backspace"]=()=>{const{selection:e}=this.editor.state,{from:n}=e,r=this.editor.state.doc.resolve(n);let s=n;const i=r.parent.textContent,o=r.parentOffset;for(let l=o-1;l>=0;l--){if(/\s/.test(i[l])){s=n-(o-l-1);break}l===0&&(s=n-o)}return this.editor.commands.deleteRange({from:s,to:n})},t["Mod-Delete"]=()=>{const{selection:e}=this.editor.state,{to:n}=e,r=this.editor.state.doc.resolve(n);let s=n;const i=r.parent.textContent,o=r.parentOffset;for(let l=o;l<i.length;l++){if(/\s/.test(i[l])){s=n+(l-o);break}l===i.length-1&&(s=n+(i.length-o))}return this.editor.commands.deleteRange({from:n,to:s})}),this.options.enableCustomShortcuts&&(t["Mod-Shift-a"]=()=>this.editor.can().setAlertWidget()?this.editor.commands.setAlertWidget():!1,t["Mod-Shift-t"]=()=>this.editor.can().setCtaWidget()?this.editor.commands.setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}):!1,t["Mod-Shift-f"]=()=>(this.editor.view.dom.classList.toggle("focus-mode"),!0),t["Mod-Shift-w"]=()=>(this.editor.view.dom.classList.toggle("writing-mode"),!0),t["Mod-Shift-u"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);return s?this.editor.commands.insertContentAt({from:n,to:r},s.toUpperCase()):!1},t["Mod-Shift-l"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);return s?this.editor.commands.insertContentAt({from:n,to:r},s.toLowerCase()):!1},t["Mod-Shift-p"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);if(s){const i=s.replace(/\w\S*/g,o=>o.charAt(0).toUpperCase()+o.substr(1).toLowerCase());return this.editor.commands.insertContentAt({from:n,to:r},i)}return!1}),t},addStorage(){return{shortcuts:{},hints:[]}},onCreate(){this.options.showShortcutHints&&(this.storage.shortcuts={},this.storage.hints=[{category:"Text Formatting",shortcuts:[{keys:"Cmd/Ctrl + B",action:"Bold"},{keys:"Cmd/Ctrl + I",action:"Italic"},{keys:"Cmd/Ctrl + U",action:"Underline"},{keys:"Cmd/Ctrl + Shift + X",action:"Strikethrough"},{keys:"Cmd/Ctrl + Shift + H",action:"Highlight"},{keys:"Cmd/Ctrl + E",action:"Inline Code"}]},{category:"Headings",shortcuts:[{keys:"Cmd/Ctrl + Alt + 1-6",action:"Heading 1-6"},{keys:"Cmd/Ctrl + Alt + 0",action:"Paragraph"}]},{category:"Lists",shortcuts:[{keys:"Cmd/Ctrl + Shift + 8",action:"Bullet List"},{keys:"Cmd/Ctrl + Shift + 7",action:"Numbered List"},{keys:"Cmd/Ctrl + Shift + 9",action:"Task List"}]},{category:"Blocks",shortcuts:[{keys:"Cmd/Ctrl + Shift + B",action:"Blockquote"},{keys:"Cmd/Ctrl + Alt + C",action:"Code Block"},{keys:"Cmd/Ctrl + Alt + T",action:"Table"}]},{category:"Navigation",shortcuts:[{keys:"Cmd/Ctrl + A",action:"Select All"},{keys:"Cmd/Ctrl + Home",action:"Go to Start"},{keys:"Cmd/Ctrl + End",action:"Go to End"}]},{category:"Advanced",shortcuts:[{keys:"Cmd/Ctrl + K",action:"Insert Link"},{keys:"Cmd/Ctrl + Shift + I",action:"Insert Image"},{keys:"Cmd/Ctrl + \\",action:"Clear Formatting"}]}])}}),Cj=()=>{const[t,e]=C.useState("<p>Start testing...</p>"),[n,r]=C.useState([]),[s,i]=C.useState(!1),[o,l]=C.useState(""),a=x=>({name:x,tests:[],status:"pending"}),c=(x,k)=>{r(v=>v.map(T=>{if(T.name===x){const N=[...T.tests,k],H=N.some(I=>I.status==="fail"),V=N.some(I=>I.status==="warning"),$=N.every(I=>I.status!=="pending");return{...T,tests:N,status:H?"fail":V?"warning":$?"pass":"pending"}}return T}))},d=x=>new Promise(k=>setTimeout(k,x)),u=async()=>{const x="Drag and Drop";l(x);try{const k=document.querySelectorAll(".drag-handle, .drag-handle-button");c(x,{name:"Drag Handle Presence",status:k.length>0?"pass":"fail",message:k.length>0?"Drag handles found":"No drag handles detected",details:`Found ${k.length} drag handle elements`});const v=document.querySelector("style")?.textContent?.includes("drag-handle")||Array.from(document.styleSheets).some(N=>{try{return Array.from(N.cssRules).some(H=>H.cssText.includes("drag-handle"))}catch{return!1}});c(x,{name:"Drag Handle CSS",status:v?"pass":"warning",message:v?"Drag handle CSS loaded":"Drag handle CSS may not be loaded",details:"Check if drag-handle.css is properly imported"});const T=document.querySelectorAll('[data-draggable="true"]');c(x,{name:"Draggable Nodes",status:T.length>0?"pass":"warning",message:T.length>0?"Draggable nodes found":"No draggable nodes detected",details:`Found ${T.length} draggable nodes`})}catch(k){c(x,{name:"Drag and Drop Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},h=async()=>{const x="Undo/Redo System";l(x);try{const k=document.querySelectorAll('[aria-label*="Undo"], [title*="Undo"]'),v=document.querySelectorAll('[aria-label*="Redo"], [title*="Redo"]');c(x,{name:"Undo/Redo Buttons",status:k.length>0&&v.length>0?"pass":"fail",message:`Found ${k.length} undo and ${v.length} redo buttons`,details:"Undo/Redo buttons should be present in toolbar"}),e("<p>Test content for undo</p>"),await d(100),c(x,{name:"History State Change",status:"pass",message:"Content change detected",details:"History system should track this change"});const T=typeof document<"u"&&document.addEventListener!==void 0;c(x,{name:"Keyboard Shortcuts",status:T?"pass":"warning",message:"Keyboard event system available",details:"Ctrl+Z and Ctrl+Y shortcuts should work"})}catch(k){c(x,{name:"Undo/Redo Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},f=async()=>{const x="Enhanced Floating Menu";l(x);try{const k=document.querySelectorAll('[aria-label*="Insert"], .enhanced-floating-menu');c(x,{name:"Floating Menu Trigger",status:k.length>0?"pass":"warning",message:k.length>0?"Floating menu trigger found":"No floating menu trigger detected",details:"Should appear on empty paragraphs"});const v=document.querySelectorAll('input[placeholder*="Search"], .search-input');c(x,{name:"Search Functionality",status:v.length>0?"pass":"warning",message:v.length>0?"Search input found":"Search input not visible",details:"Search should be available when menu is open"});const T=document.querySelectorAll("[data-category], .category-button");c(x,{name:"Category Filters",status:T.length>0?"pass":"warning",message:T.length>0?"Category filters found":"Category filters not visible",details:"Should have Basic, Headings, Lists, Media, Advanced categories"})}catch(k){c(x,{name:"Enhanced Floating Menu Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},p=async()=>{const x="Advanced Placeholders";l(x);try{const k=Array.from(document.styleSheets).some(N=>{try{return Array.from(N.cssRules).some(H=>H.cssText.includes("is-empty")||H.cssText.includes("placeholder"))}catch{return!1}});c(x,{name:"Placeholder CSS",status:k?"pass":"warning",message:k?"Placeholder CSS loaded":"Placeholder CSS may not be loaded",details:"Check if advanced-features.css is properly imported"});const v=document.querySelectorAll(".is-empty, .is-editor-empty");c(x,{name:"Empty Node Detection",status:v.length>=0?"pass":"warning",message:`Found ${v.length} empty nodes`,details:"Empty nodes should have placeholder classes"}),e("<p></p>"),await d(100);const T=document.querySelectorAll("[data-placeholder]");c(x,{name:"Placeholder Content",status:T.length>0?"pass":"warning",message:T.length>0?"Placeholder content found":"No placeholder content detected",details:"Should show contextual placeholders for different node types"})}catch(k){c(x,{name:"Advanced Placeholders Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},g=async()=>{const x="Focus Management";l(x);try{const k=document.querySelectorAll(".has-focus, .editor-focused");c(x,{name:"Focus Classes",status:k.length>=0?"pass":"warning",message:`Found ${k.length} focus elements`,details:"Focus classes should be applied to active elements"});const v=document.querySelectorAll(".focus-ring");c(x,{name:"Focus Ring",status:v.length>=0?"pass":"warning",message:`Found ${v.length} focus rings`,details:"Focus rings provide visual feedback"}),c(x,{name:"Selection Highlighting",status:"pass",message:"Selection highlighting system available",details:"Enhanced selection visibility should work"})}catch(k){c(x,{name:"Focus Management Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},y=async()=>{const x="Mobile Experience";l(x);try{const k=document.querySelectorAll('.mobile-toolbar, [class*="mobile"]');c(x,{name:"Mobile Toolbar",status:k.length>0?"pass":"warning",message:k.length>0?"Mobile toolbar found":"Mobile toolbar not detected",details:"Should appear on mobile devices or small screens"});const v=Array.from(document.styleSheets).some(N=>{try{return Array.from(N.cssRules).some(H=>H.cssText.includes("@media")&&H.cssText.includes("768px"))}catch{return!1}});c(x,{name:"Responsive CSS",status:v?"pass":"warning",message:v?"Responsive CSS found":"Responsive CSS may not be loaded",details:"Should have mobile breakpoints"});const T=document.querySelectorAll('[class*="touch"], .toolbar-item');c(x,{name:"Touch-Friendly Elements",status:T.length>0?"pass":"warning",message:T.length>0?"Touch-friendly elements found":"No touch-friendly elements detected",details:"Should have larger touch targets for mobile"})}catch(k){c(x,{name:"Mobile Experience Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},b=async()=>{const x="Keyboard Shortcuts";l(x);try{c(x,{name:"Keyboard Shortcuts Available",status:"pass",message:`${["Ctrl+B","Ctrl+I","Ctrl+U","Ctrl+Shift+X","Ctrl+Shift+H","Ctrl+Alt+1","Ctrl+Alt+2","Ctrl+Alt+3","Ctrl+K","Ctrl+\\"].length} keyboard shortcuts configured`,details:"Text formatting, headings, lists, and advanced shortcuts"});const v=document.querySelectorAll('[title*="Ctrl"], [title*="Cmd"]');c(x,{name:"Shortcut Hints",status:v.length>0?"pass":"warning",message:v.length>0?"Shortcut hints found":"No shortcut hints detected",details:"Tooltips should show keyboard shortcuts"}),c(x,{name:"Conflict Prevention",status:"pass",message:"Keyboard shortcuts use standard patterns",details:"Should not conflict with browser shortcuts"})}catch(k){c(x,{name:"Keyboard Shortcuts Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},w=async()=>{i(!0),r([a("Drag and Drop"),a("Undo/Redo System"),a("Enhanced Floating Menu"),a("Advanced Placeholders"),a("Focus Management"),a("Mobile Experience"),a("Keyboard Shortcuts")]);try{await u(),await d(500),await h(),await d(500),await f(),await d(500),await p(),await d(500),await g(),await d(500),await y(),await d(500),await b()}catch(x){console.error("Test suite failed:",x)}finally{i(!1),l("")}},M=()=>{r([]),e("<p>Start testing...</p>"),l("")},S=x=>{switch(x){case"pass":return m.jsx(OL,{className:"h-4 w-4 text-green-500"});case"fail":return m.jsx(jL,{className:"h-4 w-4 text-red-500"});case"warning":return m.jsx(Pm,{className:"h-4 w-4 text-yellow-500"});default:return m.jsx(Pm,{className:"h-4 w-4 text-gray-400"})}},A=x=>{const k={pass:"bg-green-100 text-green-800",fail:"bg-red-100 text-red-800",warning:"bg-yellow-100 text-yellow-800",pending:"bg-gray-100 text-gray-800"};return m.jsx(a1.Badge,{className:k[x]||k.pending,children:x.toUpperCase()})};return m.jsxs("div",{className:"max-w-6xl mx-auto p-6 space-y-6",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("h1",{className:"text-3xl font-bold",children:"Tiptap v3 Feature Validation"}),m.jsxs("div",{className:"flex gap-2",children:[m.jsxs(le.Button,{onClick:M,variant:"outline",disabled:s,children:[m.jsx(CI,{className:"h-4 w-4 mr-2"}),"Reset"]}),m.jsxs(le.Button,{onClick:w,disabled:s,children:[m.jsx(bI,{className:"h-4 w-4 mr-2"}),s?"Running Tests...":"Run All Tests"]})]})]}),s&&o&&m.jsx(at.Card,{children:m.jsx(at.CardContent,{className:"pt-6",children:m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-primary"}),m.jsxs("span",{children:["Running: ",o]})]})})}),m.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[m.jsxs("div",{className:"space-y-4",children:[m.jsx("h2",{className:"text-xl font-semibold",children:"Test Results"}),n.map(x=>m.jsxs(at.Card,{children:[m.jsx(at.CardHeader,{className:"pb-3",children:m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx(at.CardTitle,{className:"text-lg",children:x.name}),A(x.status)]})}),m.jsxs(at.CardContent,{className:"space-y-2",children:[x.tests.map((k,v)=>m.jsxs("div",{className:"flex items-start gap-2 p-2 rounded border",children:[S(k.status),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:"font-medium text-sm",children:k.name}),m.jsx("div",{className:"text-xs text-muted-foreground",children:k.message}),k.details&&m.jsx("div",{className:"text-xs text-muted-foreground mt-1 opacity-75",children:k.details})]})]},v)),x.tests.length===0&&x.status==="pending"&&m.jsx("div",{className:"text-sm text-muted-foreground",children:"No tests run yet"})]})]},x.name))]}),m.jsxs("div",{className:"space-y-4",children:[m.jsx("h2",{className:"text-xl font-semibold",children:"Live Editor Test"}),m.jsx(at.Card,{children:m.jsx(at.CardContent,{className:"pt-6",children:m.jsx(Pa,{content:t,onChange:e,useEnhancedFloatingMenu:!0,showMobileToolbar:!0,enableAdvancedPlaceholders:!0,enableFocusMode:!1,showKeyboardShortcuts:!0,className:"min-h-[400px]"})})}),m.jsxs(at.Card,{children:[m.jsx(at.CardHeader,{children:m.jsx(at.CardTitle,{className:"text-lg",children:"Test Instructions"})}),m.jsxs(at.CardContent,{className:"text-sm space-y-2",children:[m.jsx("p",{children:"• Try typing in the editor to test placeholders"}),m.jsx("p",{children:"• Create empty paragraphs to test floating menu"}),m.jsx("p",{children:"• Use keyboard shortcuts (Ctrl+B, Ctrl+I, etc.)"}),m.jsx("p",{children:"• Test undo/redo with Ctrl+Z/Ctrl+Y"}),m.jsx("p",{children:"• Hover over elements to see drag handles"}),m.jsx("p",{children:"• Resize window to test mobile toolbar"})]})]})]})]})]})},Ej=()=>{const[t,e]=C.useState(`
|
|
158
|
+
`)}const Rh=t=>{const[e,n]=C.useState({canUndo:!1,canRedo:!1,historyDepth:0,isHistoryEmpty:!0}),r=C.useCallback(()=>{if(!t){n({canUndo:!1,canRedo:!1,historyDepth:0,isHistoryEmpty:!0});return}const a=t.can().undo(),c=t.can().redo();n({canUndo:a,canRedo:c,historyDepth:a?1:0,isHistoryEmpty:!a&&!c})},[t]);C.useEffect(()=>{if(t)return r(),t.on("transaction",r),t.on("update",r),t.on("selectionUpdate",r),t.on("focus",r),t.on("blur",r),()=>{t.off("transaction",r),t.off("update",r),t.off("selectionUpdate",r),t.off("focus",r),t.off("blur",r)}},[t,r]);const s=C.useCallback(()=>{if(!t||!e.canUndo)return!1;try{console.log("useEditorHistory - Attempting undo operation");const a=t.chain().focus().undo().run();return console.log("useEditorHistory - Undo result:",a),a}catch(a){return console.error("useEditorHistory - Undo operation failed:",a),!1}},[t,e.canUndo]),i=C.useCallback(()=>{if(!t||!e.canRedo)return!1;try{console.log("useEditorHistory - Attempting redo operation");const a=t.chain().focus().redo().run();return console.log("useEditorHistory - Redo result:",a),a}catch(a){return console.error("useEditorHistory - Redo operation failed:",a),!1}},[t,e.canRedo]),o=C.useCallback(()=>{if(t)try{t.commands.clearContent(),r()}catch(a){console.warn("Clear history operation failed:",a)}},[t,r]),l=C.useCallback(()=>({...e}),[e]);return{...e,undo:s,redo:i,clearHistory:o,getHistoryState:l}},yw=(t,e)=>t?e==="undo"?t.can().undo():t.can().redo():!1,uj=(t,e)=>{if(!t||!yw(t,e))return!1;try{return e==="undo"?t.chain().focus().undo().run():t.chain().focus().redo().run()}catch(n){return console.warn(`${e} operation failed:`,n),!1}},eu=t=>{const e=typeof navigator<"u"&&navigator.platform.includes("Mac"),n=e?"Cmd":"Ctrl";return t==="undo"?`${n}+Z`:e?`${n}+Shift+Z`:`${n}+Y`},Oh=({editor:t,className:e,showLabels:n=!1,size:r="sm"})=>{const{canUndo:s,canRedo:i,undo:o,redo:l}=Rh(t);C.useEffect(()=>{if(!t)return;const d=u=>{t.isFocused&&(u.ctrlKey||u.metaKey)&&(u.key==="z"&&!u.shiftKey?(u.preventDefault(),o()):(u.key==="z"&&u.shiftKey||u.key==="y")&&(u.preventDefault(),l()))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,o,l]);const a=r==="sm"?"sm":r==="lg"?"lg":"default",c=r==="sm"?"h-4 w-4":r==="lg"?"h-6 w-6":"h-5 w-5";return m.jsxs("div",{className:De.cn("flex items-center gap-1",e),children:[m.jsxs(le.Button,{variant:s?"outline":"ghost",size:a,onClick:o,disabled:!s,title:`Undo last action (${eu("undo")})`,"aria-label":"Undo last action",className:De.cn("transition-all duration-200 border-2",r==="sm"?"h-8 w-8 p-0":r==="lg"?"h-10 w-10 p-0":"h-9 w-9 p-0",s?"border-primary/20 hover:border-primary/40 hover:bg-primary/10 hover:text-primary hover:scale-105 active:scale-95 shadow-sm":"opacity-40 cursor-not-allowed border-transparent",s&&"bg-primary/5",n&&"w-auto px-3"),children:[m.jsx(GI,{className:De.cn(c,"transition-colors duration-200",s?s?"text-primary":"text-current":"text-muted-foreground")}),n&&m.jsx("span",{className:"ml-2",children:"Undo"})]}),m.jsxs(le.Button,{variant:i?"outline":"ghost",size:a,onClick:l,disabled:!i,title:`Redo last undone action (${eu("redo")})`,"aria-label":"Redo last undone action",className:De.cn("transition-all duration-200 border-2",r==="sm"?"h-8 w-8 p-0":r==="lg"?"h-10 w-10 p-0":"h-9 w-9 p-0",i?"border-primary/20 hover:border-primary/40 hover:bg-primary/10 hover:text-primary hover:scale-105 active:scale-95 shadow-sm":"opacity-40 cursor-not-allowed border-transparent",i&&"bg-primary/5",n&&"w-auto px-3"),children:[m.jsx(wI,{className:De.cn(c,"transition-colors duration-200",i?i?"text-primary":"text-current":"text-muted-foreground")}),n&&m.jsx("span",{className:"ml-2",children:"Redo"})]})]})},Fe=({onClick:t,isActive:e,disabled:n,children:r,title:s,ariaLabel:i,shortcut:o})=>{const l=o?`${s} (${o})`:s;return m.jsx(le.Button,{variant:e?"default":"ghost",size:"sm",onClick:t,disabled:n,title:l,"aria-label":i||s,className:`h-8 w-8 p-0 transition-all duration-200 ${n?"opacity-40 cursor-not-allowed":"hover:bg-accent hover:text-accent-foreground hover:scale-105"}`,children:r})},hj=({editor:t})=>m.jsxs(gt.Popover,{children:[m.jsx(gt.PopoverTrigger,{asChild:!0,children:m.jsxs(le.Button,{variant:"ghost",size:"sm",className:"h-8 px-2","aria-label":"Font size menu",title:"Font size menu",children:[m.jsx(Wr,{className:"h-4 w-4 mr-1"}),"Size"]})}),m.jsx(gt.PopoverContent,{onFocusOutside:e=>e.preventDefault(),className:"w-[360px] p-0",side:"bottom",align:"start",children:m.jsx(pw,{editor:t,className:"p-4"})})]}),fj=({editor:t})=>m.jsxs(gt.Popover,{children:[m.jsx(gt.PopoverTrigger,{asChild:!0,children:m.jsx(le.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0","aria-label":"Color menu",title:"Color menu",children:m.jsx(vh,{className:"h-4 w-4"})})}),m.jsx(gt.PopoverContent,{onFocusOutside:e=>e.preventDefault(),className:"w-[380px] p-0",side:"bottom",align:"start",children:m.jsx(fw,{editor:t,className:"p-4"})})]}),pj=({editor:t})=>{const e=async()=>{const s=ja(t);if(s){const o=await s();o?.src&&(t.chain().focus().setImage({src:o.src,alt:o.alt||void 0}).run(),o.blurDataURL&&t.chain().focus().updateAttributes("image",{blurDataURL:o.blurDataURL}).run());return}const i=window.prompt("Enter image URL:");i&&t.chain().focus().setImage({src:i}).run()},n=()=>{t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},r=()=>{const s=window.prompt("Enter URL:");s&&t.chain().focus().setLink({href:s}).run()};return m.jsxs(We.DropdownMenu,{children:[m.jsx(We.DropdownMenuTrigger,{asChild:!0,children:m.jsx(le.Button,{variant:"ghost",size:"sm",className:"h-8 px-2",children:"Insert"})}),m.jsxs(We.DropdownMenuContent,{children:[m.jsxs(We.DropdownMenuItem,{onClick:e,children:[m.jsx(zr,{className:"h-4 w-4 mr-2"}),"Image"]}),m.jsxs(We.DropdownMenuItem,{onClick:n,children:[m.jsx(qi,{className:"h-4 w-4 mr-2"}),"Table"]}),m.jsxs(We.DropdownMenuItem,{onClick:r,children:[m.jsx(Ta,{className:"h-4 w-4 mr-2"}),"Link"]}),m.jsxs(We.DropdownMenuItem,{onClick:()=>t.chain().focus().setHorizontalRule().run(),children:[m.jsx(_a,{className:"h-4 w-4 mr-2"}),"Horizontal Rule"]}),m.jsx(We.DropdownMenuSeparator,{}),m.jsxs(We.DropdownMenuItem,{onClick:()=>{const s=window.prompt("Enter CSS (without <style> tags):","/* your styles */");if(s!=null){const i=`<style>${s}</style>`;t.commands.insertContentAt({from:0,to:0},i)}},children:[m.jsx(Nr,{className:"h-4 w-4 mr-2"}),"CSS Block"]}),m.jsxs(We.DropdownMenuItem,{onClick:()=>{const s=window.prompt("Enter JavaScript (without <script> tags):","// your script");if(s!=null){const i=`<script>${s}<\/script>`,o=t.state.doc.content.size;t.commands.insertContentAt(o,i)}},children:[m.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Script Block"]}),m.jsxs(We.DropdownMenuItem,{onClick:()=>{const s=window.prompt("Optional class for DIV:",""),i=window.prompt("Optional inline style for DIV:",""),o=window.prompt("Optional content for DIV:","New block"),l=`${s?` class="${s}"`:""}${i?` style="${i}"`:""}`,c=o?`<p>${(d=>d.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"))(o)}</p>`:"<p><br /></p>";t.chain().focus().insertContent(`<div${l}>${c}</div>`).run()},children:[m.jsx(Nr,{className:"h-4 w-4 mr-2"}),"DIV Block"]}),m.jsx(We.DropdownMenuSeparator,{}),m.jsxs(We.DropdownMenuItem,{onClick:()=>t.chain().focus().setAlertWidget().run(),children:[m.jsx(Oa,{className:"h-4 w-4 mr-2"}),"Alert Widget"]}),m.jsxs(We.DropdownMenuItem,{onClick:()=>t.chain().focus().setCtaWidget({text:"Learn more",url:"",style:"primary",size:"medium",textAlign:"center"}).run(),children:[m.jsx(Na,{className:"h-4 w-4 mr-2"}),"CTA Widget"]})]})]})},mj=({editor:t})=>{const e=()=>{const s=t.getHTML(),i=new Blob([s],{type:"text/html"}),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.download="document.html",l.click(),URL.revokeObjectURL(o)},n=()=>{const s=JSON.stringify(t.getJSON(),null,2),i=new Blob([s],{type:"application/json"}),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.download="document.json",l.click(),URL.revokeObjectURL(o)},r=()=>{const s=t.getText(),i=new Blob([s],{type:"text/plain"}),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.download="document.txt",l.click(),URL.revokeObjectURL(o)};return m.jsxs(We.DropdownMenu,{children:[m.jsx(We.DropdownMenuTrigger,{asChild:!0,children:m.jsx(le.Button,{variant:"ghost",size:"sm",className:"h-8 px-2","aria-label":"Export menu",title:"Export menu",children:m.jsx(Jx,{className:"h-4 w-4 mr-1"})})}),m.jsxs(We.DropdownMenuContent,{children:[m.jsx(We.DropdownMenuItem,{onClick:e,children:"Export as HTML"}),m.jsx(We.DropdownMenuItem,{onClick:n,children:"Export as JSON"}),m.jsx(We.DropdownMenuItem,{onClick:r,children:"Export as Text"})]})]})},Dh=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(""),[i,o]=C.useState(!1),[l,a]=C.useState(null),c=C.useRef([]);if(C.useEffect(()=>{if(!t)return;const f=g=>{try{const y=t.getHTML();s($c(y)),n(!0)}catch{}},p="editor:openSourceView";return window.addEventListener(p,f),()=>window.removeEventListener(p,f)},[t]),!t)return null;const d=()=>{const f=t.getHTML();s($c(f)),n(!0)},u=()=>{t.chain().focus().setContent(r).run(),n(!1)},h=()=>{for(const x of c.current)try{URL.revokeObjectURL(x)}catch{}c.current=[];const f=t.getHTML(),y=new DOMParser().parseFromString(`<div id="__content__">${f}</div>`,"text/html").body.querySelector("#__content__");Array.from(y.querySelectorAll("script")).forEach(x=>{if(!x.getAttribute("src")){const k=x.textContent||"",v=new Blob([k],{type:"text/javascript"}),T=URL.createObjectURL(v);x.setAttribute("src",T),x.textContent="",c.current.push(T)}});const M=`<!doctype html><html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Preview</title></head><body>${y.innerHTML}</body></html>`,S=new Blob([M],{type:"text/html"}),A=URL.createObjectURL(S);c.current.push(A),l&&URL.revokeObjectURL(l),a(A),o(!0)};return m.jsxs("div",{className:"border-b bg-background p-2 relative",children:[m.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[m.jsx("div",{className:"flex items-center gap-1 mr-2 p-1 rounded-md bg-muted/30 border border-border/50",children:m.jsx(Oh,{editor:t,size:"sm",showLabels:!1})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),isActive:t.isActive("heading",{level:1}),title:"Heading 1",children:m.jsx(vs,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),isActive:t.isActive("heading",{level:2}),title:"Heading 2",children:m.jsx(Vi,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),isActive:t.isActive("heading",{level:3}),title:"Heading 3",children:m.jsx(Aa,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleBold().run(),isActive:t.isActive("bold"),title:"Bold",children:m.jsx(Gl,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleItalic().run(),isActive:t.isActive("italic"),title:"Italic",children:m.jsx(kh,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleUnderline().run(),isActive:t.isActive("underline"),title:"Underline",children:m.jsx(Ch,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleStrike().run(),isActive:t.isActive("strike"),title:"Strikethrough",children:m.jsx(Yx,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleCode().run(),isActive:t.isActive("code"),title:"Inline Code",children:m.jsx(Rs,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleSubscript().run(),isActive:t.isActive("subscript"),title:"Subscript",children:m.jsx(Xx,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleSuperscript().run(),isActive:t.isActive("superscript"),title:"Superscript",children:m.jsx(Zx,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:()=>t.chain().focus().setTextAlign("left").run(),isActive:t.isActive({textAlign:"left"}),title:"Align Left",children:m.jsx(Ss,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().setTextAlign("center").run(),isActive:t.isActive({textAlign:"center"}),title:"Align Center",children:m.jsx(Ki,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().setTextAlign("right").run(),isActive:t.isActive({textAlign:"right"}),title:"Align Right",children:m.jsx(Gi,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().setTextAlign("justify").run(),isActive:t.isActive({textAlign:"justify"}),title:"Justify",children:m.jsx(Sh,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleBulletList().run(),isActive:t.isActive("bulletList"),title:"Bullet List",children:m.jsx(Os,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleOrderedList().run(),isActive:t.isActive("orderedList"),title:"Numbered List",children:m.jsx(Wi,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleTaskList().run(),isActive:t.isActive("taskList"),title:"Task List",children:m.jsx(Ra,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleBlockquote().run(),isActive:t.isActive("blockquote"),title:"Blockquote",children:m.jsx(Ji,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleCodeBlock().run(),isActive:t.isActive("codeBlock"),title:"Code Block",children:m.jsx(Nr,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(hj,{editor:t}),m.jsx(fj,{editor:t}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(pj,{editor:t}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:d,title:"View Source (HTML)",children:m.jsx(JL,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:h,title:"Preview (executes scripts)",children:m.jsx(KL,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(mj,{editor:t})]}),e&&m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:m.jsxs("div",{className:"bg-background border rounded-md shadow-xl w-[90vw] max-w-4xl h-[70vh] flex flex-col",children:[m.jsx("div",{className:"p-3 border-b font-semibold",children:"Edit HTML Source"}),m.jsx("textarea",{className:"flex-1 p-3 font-mono text-sm outline-none resize-none bg-muted/30",value:r,onChange:f=>s(f.target.value),spellCheck:!1}),m.jsxs("div",{className:"p-3 border-t flex justify-end gap-2",children:[m.jsx(le.Button,{variant:"outline",size:"sm",onClick:()=>n(!1),children:"Cancel"}),m.jsx(le.Button,{variant:"secondary",size:"sm",onClick:()=>s($c(r)),children:"Format"}),m.jsx(le.Button,{size:"sm",onClick:u,children:"Apply"})]})]})}),i&&m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:m.jsxs("div",{className:"bg-background border rounded-md shadow-xl w-[95vw] max-w-5xl h-[80vh] flex flex-col",children:[m.jsxs("div",{className:"p-3 border-b flex items-center justify-between",children:[m.jsx("div",{className:"font-semibold",children:"Preview"}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx(le.Button,{variant:"outline",size:"sm",onClick:()=>{h()},children:"Refresh"}),m.jsx(le.Button,{size:"sm",onClick:()=>{for(const f of c.current)try{URL.revokeObjectURL(f)}catch{}c.current=[],l&&URL.revokeObjectURL(l),a(null),o(!1)},children:"Close"})]})]}),m.jsx("div",{className:"flex-1",children:m.jsx("iframe",{title:"Editor Preview",className:"w-full h-full",sandbox:"allow-scripts allow-same-origin allow-modals",src:l??void 0})})]})})]})},bw=({editor:t,className:e})=>{const[n,r]=C.useState(!1),[s,i]=C.useState("format"),[o,l]=C.useState(!1),a=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||window.innerWidth<=768;C.useEffect(()=>{const h=()=>{r(a())};return h(),window.addEventListener("resize",h),()=>window.removeEventListener("resize",h)},[]),C.useEffect(()=>{if(!t)return;const h=()=>{const{selection:f}=t.state;!f.empty&&a()?r(!0):o||r(!1)};return t.on("selectionUpdate",h),t.on("focus",h),t.on("blur",()=>{o||r(!1)}),()=>{t.off("selectionUpdate",h),t.off("focus",h),t.off("blur",()=>r(!1))}},[t,o]);const c=[{icon:m.jsx(Gl,{className:"h-4 w-4"}),label:"Bold",action:()=>t.chain().focus().toggleBold().run(),isActive:()=>t.isActive("bold"),section:"format"},{icon:m.jsx(kh,{className:"h-4 w-4"}),label:"Italic",action:()=>t.chain().focus().toggleItalic().run(),isActive:()=>t.isActive("italic"),section:"format"},{icon:m.jsx(Ch,{className:"h-4 w-4"}),label:"Underline",action:()=>t.chain().focus().toggleUnderline().run(),isActive:()=>t.isActive("underline"),section:"format"},{icon:m.jsx(Rs,{className:"h-4 w-4"}),label:"Code",action:()=>t.chain().focus().toggleCode().run(),isActive:()=>t.isActive("code"),section:"format"},{icon:m.jsx(vh,{className:"h-4 w-4"}),label:"Highlight",action:()=>t.chain().focus().toggleHighlight().run(),isActive:()=>t.isActive("highlight"),section:"format"},{icon:m.jsx(Wr,{className:"h-4 w-4"}),label:"Paragraph",action:()=>t.chain().focus().setParagraph().run(),isActive:()=>t.isActive("paragraph"),section:"blocks"},{icon:m.jsx(vs,{className:"h-4 w-4"}),label:"Heading 1",action:()=>t.chain().focus().toggleHeading({level:1}).run(),isActive:()=>t.isActive("heading",{level:1}),section:"blocks"},{icon:m.jsx(Vi,{className:"h-4 w-4"}),label:"Heading 2",action:()=>t.chain().focus().toggleHeading({level:2}).run(),isActive:()=>t.isActive("heading",{level:2}),section:"blocks"},{icon:m.jsx(Aa,{className:"h-4 w-4"}),label:"Heading 3",action:()=>t.chain().focus().toggleHeading({level:3}).run(),isActive:()=>t.isActive("heading",{level:3}),section:"blocks"},{icon:m.jsx(Os,{className:"h-4 w-4"}),label:"Bullet List",action:()=>t.chain().focus().toggleBulletList().run(),isActive:()=>t.isActive("bulletList"),section:"blocks"},{icon:m.jsx(Wi,{className:"h-4 w-4"}),label:"Numbered List",action:()=>t.chain().focus().toggleOrderedList().run(),isActive:()=>t.isActive("orderedList"),section:"blocks"},{icon:m.jsx(Ra,{className:"h-4 w-4"}),label:"Task List",action:()=>t.chain().focus().toggleTaskList().run(),isActive:()=>t.isActive("taskList"),section:"blocks"},{icon:m.jsx(Ji,{className:"h-4 w-4"}),label:"Quote",action:()=>t.chain().focus().toggleBlockquote().run(),isActive:()=>t.isActive("blockquote"),section:"blocks"},{icon:m.jsx(Ta,{className:"h-4 w-4"}),label:"Link",action:()=>{const h=window.prompt("Enter URL:");h&&t.chain().focus().setLink({href:h}).run()},isActive:()=>t.isActive("link"),section:"insert"},{icon:m.jsx(zr,{className:"h-4 w-4"}),label:"Image",action:async()=>{const h=ja(t);if(h){const p=await h();p?.src&&t.chain().focus().setImage({src:p.src,alt:p.alt||void 0}).run();return}const f=window.prompt("Enter image URL:");f&&t.chain().focus().setImage({src:f}).run()},section:"insert"},{icon:m.jsx(qi,{className:"h-4 w-4"}),label:"Table",action:()=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),section:"insert"},{icon:m.jsx(Ss,{className:"h-4 w-4"}),label:"Align Left",action:()=>t.chain().focus().setTextAlign("left").run(),isActive:()=>t.isActive({textAlign:"left"}),section:"align"},{icon:m.jsx(Ki,{className:"h-4 w-4"}),label:"Align Center",action:()=>t.chain().focus().setTextAlign("center").run(),isActive:()=>t.isActive({textAlign:"center"}),section:"align"},{icon:m.jsx(Gi,{className:"h-4 w-4"}),label:"Align Right",action:()=>t.chain().focus().setTextAlign("right").run(),isActive:()=>t.isActive({textAlign:"right"}),section:"align"}],d=[{key:"format",label:"Format",icon:m.jsx(Gl,{className:"h-3 w-3"})},{key:"blocks",label:"Blocks",icon:m.jsx(vs,{className:"h-3 w-3"})},{key:"insert",label:"Insert",icon:m.jsx(zr,{className:"h-3 w-3"})},{key:"align",label:"Align",icon:m.jsx(Ss,{className:"h-3 w-3"})}],u=c.filter(h=>h.section===s);return!n&&!o?null:m.jsxs("div",{className:De.cn("fixed bottom-0 left-0 right-0 z-50 bg-background border-t border-border shadow-lg","transform transition-transform duration-300 ease-in-out",n||o?"translate-y-0":"translate-y-full",e),children:[m.jsx("div",{className:"flex justify-center py-2 border-b border-border",children:m.jsxs(le.Button,{variant:"ghost",size:"sm",onClick:()=>l(!o),className:"flex items-center gap-2",children:[o?m.jsx(tw,{className:"h-4 w-4"}):m.jsx(pI,{className:"h-4 w-4"}),m.jsx("span",{className:"text-xs",children:o?"Close":"Tools"})]})}),(o||n)&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"flex border-b border-border bg-muted/50",children:d.map(h=>m.jsx(le.Button,{variant:s===h.key?"default":"ghost",size:"sm",onClick:()=>i(h.key),className:"flex-1 rounded-none text-xs py-2 h-auto",children:m.jsxs("div",{className:"flex flex-col items-center gap-1",children:[h.icon,m.jsx("span",{children:h.label})]})},h.key))}),m.jsx("div",{className:"p-2",children:m.jsx("div",{className:"flex flex-wrap gap-1 justify-center",children:u.map((h,f)=>m.jsxs(le.Button,{variant:h.isActive?.()?"default":"ghost",size:"sm",onClick:h.action,className:"flex flex-col items-center gap-1 h-auto py-2 px-3 min-w-[60px]",title:h.label,children:[h.icon,m.jsx("span",{className:"text-xs",children:h.label})]},f))})})]}),m.jsx("div",{className:"h-safe-area-inset-bottom"})]})},Pa=({content:t,onChange:e,placeholder:n,editable:r=!0,showToolbar:s=!0,showCharacterCount:i=!0,className:o,onFocus:l,onBlur:a,useEnhancedFloatingMenu:c=!0,showMobileToolbar:d=!0,enableAdvancedPlaceholders:u=!0,enableFocusMode:h=!1,showKeyboardShortcuts:f=!1})=>{const p=C.useRef(null),[g,y]=C.useState({isOpen:!1,searchTerm:"",replaceTerm:"",currentMatch:0,totalMatches:0,caseSensitive:!1,wholeWord:!1}),b=hb({extensions:Mh,content:t,editable:r,immediatelyRender:!1,onUpdate:({editor:k})=>{e(k.getHTML())},onFocus:()=>{l?.()},onBlur:()=>{a?.()},editorProps:{attributes:{class:De.cn("prose dark:prose-invert prose-sm sm:prose-base lg:prose-lg xl:prose-2xl","mx-auto focus:outline-none p-4 min-h-[500px] w-full","prose-headings:scroll-mt-[80px] prose-headings:font-semibold","prose-h1:text-4xl prose-h2:text-3xl prose-h3:text-2xl","prose-p:leading-7 prose-li:leading-7","prose-pre:bg-muted prose-pre:border prose-pre:rounded-lg","prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:rounded","prose-blockquote:border-l-4 prose-blockquote:border-primary prose-blockquote:pl-4","prose-table:border-collapse prose-table:border prose-table:border-border","prose-th:border prose-th:border-border prose-th:bg-muted prose-th:p-2","prose-td:border prose-td:border-border prose-td:p-2","prose-img:rounded-lg prose-img:shadow-sm",o)},handleKeyDown:(k,v)=>{if(v.ctrlKey||v.metaKey)switch(v.key){case"f":return v.preventDefault(),y(T=>({...T,isOpen:!T.isOpen})),!0;case"s":return v.preventDefault(),!0;default:return!1}return!1}}});C.useEffect(()=>{if(!b)return;const k=b.getHTML();if(t!==k){const{from:v,to:T}=b.state.selection;b.commands.setContent(t,{emitUpdate:!1}),b.commands.setTextSelection({from:v,to:T})}},[t,b]);const w=k=>{if(!b||!k){y($=>({...$,totalMatches:0,currentMatch:0}));return}const v=b.getText(),T=g.caseSensitive?"g":"gi",N=g.wholeWord?`\\b${k}\\b`:k,H=new RegExp(N,T),V=v.match(H);y($=>({...$,totalMatches:V?V.length:0,currentMatch:V?1:0}))},M=()=>{if(!b||!g.searchTerm)return;const k=b.getHTML(),v=g.caseSensitive?"g":"gi",T=g.wholeWord?`\\b${g.searchTerm}\\b`:g.searchTerm,N=new RegExp(T,v),H=k.replace(N,g.replaceTerm);b.commands.setContent(H),y(V=>({...V,totalMatches:0,currentMatch:0}))};if(!b)return null;const S=b.storage?.characterCount,A=S?.characters?.()??0,x=S?.words?.()??0;return m.jsxs("div",{ref:p,className:De.cn("relative w-full rounded-lg border shadow-sm","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2","bg-background",o),children:[s&&m.jsx(Dh,{editor:b}),g.isOpen&&m.jsxs("div",{className:"border-b bg-muted/50 p-3",children:[m.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[m.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[m.jsx(_I,{className:"h-4 w-4 text-muted-foreground"}),m.jsx(ns.Input,{placeholder:"Search...",value:g.searchTerm,onChange:k=>{const v=k.target.value;y(T=>({...T,searchTerm:v})),w(v)},className:"h-8"}),m.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:g.totalMatches>0?`${g.currentMatch}/${g.totalMatches}`:"No matches"})]}),m.jsx(le.Button,{variant:"ghost",size:"sm",onClick:()=>y(k=>({...k,isOpen:!1})),children:m.jsx(tw,{className:"h-4 w-4"})})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(vI,{className:"h-4 w-4 text-muted-foreground"}),m.jsx(ns.Input,{placeholder:"Replace with...",value:g.replaceTerm,onChange:k=>y(v=>({...v,replaceTerm:k.target.value})),className:"h-8 flex-1"}),m.jsx(le.Button,{variant:"outline",size:"sm",onClick:M,disabled:!g.searchTerm||g.totalMatches===0,children:"Replace All"})]})]}),m.jsx(Nh,{editor:b}),c?m.jsx(mw,{editor:b,wrapperRef:p}):m.jsx(_h,{editor:b}),m.jsx(db,{editor:b}),i&&S&&m.jsxs("div",{className:"absolute bottom-2 right-2 z-10 text-xs text-muted-foreground bg-background/80 backdrop-blur-sm rounded px-2 py-1 border",children:[A," characters / ",x," words"]}),f&&m.jsxs("div",{className:"absolute bottom-2 left-2 text-xs text-muted-foreground bg-background/80 backdrop-blur-sm rounded px-2 py-1 border opacity-0 hover:opacity-100 transition-opacity",children:[m.jsx("div",{children:"Ctrl+F: Search"}),m.jsx("div",{children:"Ctrl+S: Save"}),m.jsx("div",{children:"/: Commands"}),m.jsx("div",{children:"Ctrl+K: Insert Link"}),m.jsx("div",{children:"Ctrl+Shift+H: Highlight"}),m.jsx("div",{children:"Ctrl+Alt+1-6: Headings"})]}),d&&m.jsx(bw,{editor:b})]})},gj=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(!1),{x:i,y:o,refs:l,strategy:a,update:c}=Xi({placement:"top",strategy:"fixed",open:e,onOpenChange:n,middleware:[Yi(-12)],whileElementsMounted:Ms}),d=C.useCallback(()=>t.isActive("image"),[t]),u=t.getAttributes("image")||{},h=C.useCallback(()=>{const{state:y,view:b}=t,w=()=>{try{if(y.selection instanceof q){const k=b.nodeDOM(y.selection.from);if(k){const v=k.closest?.(".tiptap-image-wrapper")??k;return v.querySelector("img")??v}}const A=b.dom.querySelector(".tiptap-image-wrapper.ProseMirror-selectednode");if(A)return A.querySelector("img")??A;const x=b.dom.querySelector(".ProseMirror-selectednode");if(x){const k=x.closest?.(".tiptap-image-wrapper")??x;return k.querySelector("img")??k}}catch{}return null},M=h._lastEl,S=w()??M;if(S){h._lastEl=S;const A={getBoundingClientRect:()=>{const x=w()??h._lastEl;return x?x.getBoundingClientRect():new DOMRect(0,0,0,0)}};l.setReference(A)}else{const A=b.coordsAtPos(y.selection.from),x={getBoundingClientRect:()=>new DOMRect(A.left,A.top,0,0)};l.setReference(x)}requestAnimationFrame(()=>{c(),requestAnimationFrame(()=>s(!0))})},[t,l,c]);if(C.useEffect(()=>{const y=()=>{const b=d();n(b),s(!1),b&&h()};return y(),t.on("selectionUpdate",y),t.on("transaction",y),t.on("focus",y),t.on("blur",()=>n(!1)),()=>{t.off("selectionUpdate",y),t.off("transaction",y),t.off("focus",y)}},[t,d,h]),!e)return null;const f=y=>{t.chain().focus().updateAttributes("image",{align:y}).run(),requestAnimationFrame(()=>h())},p=()=>{t.chain().focus().deleteSelection().run()},g=()=>{const y=u?.src;if(y)try{const b=document.createElement("a");b.href=y;const w=(y.split("?")[0]||"").split("/").pop()||"image";b.download=w,document.body.appendChild(b),b.click(),b.remove()}catch{}};return m.jsxs("div",{ref:l.setFloating,style:{position:a,top:o??0,left:i??0,zIndex:10002,visibility:r?"visible":"hidden",pointerEvents:"auto"},className:"bg-background/95 backdrop-blur border rounded-full shadow-lg px-3 py-2 flex items-center gap-1",onMouseDown:y=>y.preventDefault(),children:[m.jsx(le.Button,{size:"icon",variant:u.align==="left"?"default":"ghost",title:"Align left",onClick:()=>f("left"),children:m.jsx(Ss,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:u.align==="center"?"default":"ghost",title:"Align center",onClick:()=>f("center"),children:m.jsx(Ki,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:u.align==="right"?"default":"ghost",title:"Align right",onClick:()=>f("right"),children:m.jsx(Gi,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:"ghost",title:"Download",onClick:g,children:m.jsx(Jx,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:"ghost",title:"Delete",onClick:p,children:m.jsx(Qx,{className:"h-4 w-4"})})]})},ng=t=>t.isActive("table")||t.isActive("tableCell")||t.isActive("tableHeader")||t.isActive("tableRow"),yj=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(!1),{refs:i,x:o,y:l,strategy:a,update:c}=Xi({placement:"bottom",strategy:"fixed",middleware:[Yi(12),La(),Da()],whileElementsMounted:Ms,open:e,onOpenChange:n}),d=C.useCallback(()=>{const{state:v,view:T}=t;try{const{from:N}=v.selection,{node:H}=T.domAtPos(N);let V=null;return H.nodeType===Node.ELEMENT_NODE?V=H:(H.nodeType===Node.TEXT_NODE||H?.parentElement)&&(V=H.parentElement),V?.closest?.("td, th")??null}catch{return null}},[t]),u=C.useCallback(()=>d()?.closest("table")??null,[d]),h=C.useCallback(()=>{if(!ng(t)){n(!1);return}const v=u();if(!v){n(!1);return}i.setReference(v),n(!0),s(!1),requestAnimationFrame(()=>{c(),requestAnimationFrame(()=>s(!0))})},[t,i,u,c]);if(C.useEffect(()=>{const v=()=>{ng(t)?h():n(!1)},T=()=>n(!1);return v(),t.on("selectionUpdate",v),t.on("transaction",v),t.on("focus",v),t.on("blur",T),()=>{t.off("selectionUpdate",v),t.off("transaction",v),t.off("focus",v),t.off("blur",T)}},[t,h]),!e)return null;const f=t.can(),p=typeof f.addRowAfter=="function"?f.addRowAfter():!1,g=typeof f.deleteRow=="function"?f.deleteRow():!1,y=typeof f.addColumnAfter=="function"?f.addColumnAfter():!1,b=typeof f.deleteColumn=="function"?f.deleteColumn():!1,w=typeof f.deleteTable=="function"?f.deleteTable():!1,M=()=>{t.chain().focus().addRowAfter().run(),h()},S=()=>{t.chain().focus().deleteRow().run(),h()},A=()=>{t.chain().focus().addColumnAfter().run(),h()},x=()=>{t.chain().focus().deleteColumn().run(),h()},k=()=>{t.chain().focus().deleteTable().run(),n(!1)};return m.jsxs("div",{ref:i.setFloating,style:{position:a,top:l??0,left:o??0,zIndex:10002,visibility:r?"visible":"hidden"},className:"flex items-center gap-1 rounded-full border bg-background/95 px-2 py-1 shadow-lg",onMouseDown:v=>v.preventDefault(),children:[m.jsx(le.Button,{size:"icon",variant:"ghost",onClick:M,disabled:!p,title:"Add row below","aria-label":"Add row below",children:m.jsx(TI,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:"ghost",onClick:S,disabled:!g,title:"Delete current row","aria-label":"Delete current row",children:m.jsx(MI,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:"ghost",onClick:A,disabled:!y,title:"Add column to the right","aria-label":"Add column to the right",children:m.jsx(FL,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:"ghost",onClick:x,disabled:!b,title:"Delete current column","aria-label":"Delete current column",children:m.jsx(HL,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:"ghost",onClick:k,disabled:!w,title:"Delete table","aria-label":"Delete table",children:m.jsx(Qx,{className:"h-4 w-4"})})]})},xw=({content:t,onChange:e,placeholder:n,editable:r=!0,showToolbar:s=!0,showCharacterCount:i=!0,className:o,onFocus:l,onBlur:a,openImagePicker:c})=>{const d=C.useRef(null),u=hb({extensions:Mh,content:t,editable:r,immediatelyRender:!1,onUpdate:({editor:g})=>e(g.getHTML()),onFocus:()=>{l?.()},onBlur:()=>{a?.()},editorProps:{attributes:{class:De.cn("prose dark:prose-invert prose-sm sm:prose-base lg:prose-lg xl:prose-2xl","mx-auto focus:outline-none min-h-[500px] w-full","pl-14 pr-4 py-4","prose-headings:scroll-mt-[80px] prose-headings:font-semibold","prose-h1:text-4xl prose-h2:text-3xl prose-h3:text-2xl","prose-p:leading-7 prose-li:leading-7","prose-pre:bg-muted prose-pre:border prose-pre:rounded-lg","prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:rounded","prose-blockquote:border-l-4 prose-blockquote:border-primary prose-blockquote:pl-4","prose-table:border-collapse prose-table:border prose-table:border-border","prose-th:border prose-th:border-border prose-th:bg-muted prose-th:p-2","prose-td:border prose-td:border-border prose-td:p-2","prose-img:rounded-lg prose-img:shadow-sm")}}});if(C.useEffect(()=>{if(u)return Xm(u,c),()=>Xm(u,void 0)},[u,c]),C.useEffect(()=>{if(!u)return;const g=u.getHTML();if(t!==g){const{from:y,to:b}=u.state.selection;u.commands.setContent(t,{emitUpdate:!1}),u.commands.setTextSelection({from:y,to:b})}},[t,u]),C.useEffect(()=>{if(!(!u||typeof window>"u"))return window.__nextblockEditor=u,()=>{window.__nextblockEditor===u&&delete window.__nextblockEditor}},[u]),C.useEffect(()=>{if(!u||typeof window>"u")return;const g=()=>{const w=window.__dragHandleElement;if(!w)return;const M=w.parentElement,S=u.view.dom.parentElement??u.view.dom;M&&S&&!M.isConnected&&S.appendChild(M)},y=()=>g();g(),u.on("selectionUpdate",y),u.on("transaction",y),u.on("focus",y);const b=window.setInterval(g,2e3);return()=>{u.off("selectionUpdate",y),u.off("transaction",y),u.off("focus",y),window.clearInterval(b)}},[u]),C.useEffect(()=>()=>{typeof document<"u"&&document.body.classList.remove("dragging")},[]),!u)return null;const h=u.storage?.characterCount,f=h?.characters?.()??0,p=h?.words?.()??0;return m.jsxs("div",{ref:d,className:De.cn("relative w-full rounded-lg border bg-background shadow-sm","flex flex-col h-full min-h-0","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",o),children:[s&&m.jsx(Dh,{editor:u}),m.jsx(Nh,{editor:u}),m.jsx(_h,{editor:u}),m.jsx(gj,{editor:u}),m.jsx(yj,{editor:u}),m.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:m.jsx(db,{editor:u})}),i&&h&&m.jsxs("div",{className:"absolute bottom-2 right-2 text-xs z-10 text-muted-foreground bg-background/80 backdrop-blur-sm rounded px-2 py-1 border",children:[f," characters / ",p," words"]})]})},ww=C.forwardRef(({className:t,...e},n)=>m.jsx("div",{ref:n,className:De.cn("flex items-center gap-1 rounded-md bg-background p-1",t),...e}));ww.displayName="Toolbar";const kw=C.forwardRef(({className:t,...e},n)=>m.jsx("div",{ref:n,className:De.cn("flex items-center gap-1",t),...e}));kw.displayName="ToolbarGroup";const vw=C.forwardRef(({className:t,isActive:e,...n},r)=>m.jsx("button",{ref:r,className:De.cn("inline-flex items-center justify-center rounded-md p-1.5 text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{"bg-accent text-accent-foreground":e},t),...n}));vw.displayName="ToolbarButton";const Sw=C.forwardRef(({className:t,...e},n)=>m.jsx("div",{ref:n,className:De.cn("mx-1 h-7 w-px bg-muted",t),...e}));Sw.displayName="ToolbarSeparator";var bj=t=>{const{className:e="drag-handle",children:n,editor:r,pluginKey:s=Ox,onNodeChange:i,onElementDragStart:o,onElementDragEnd:l,computePositionConfig:a=Wd}=t,[c,d]=C.useState(null),u=C.useRef(null);return C.useEffect(()=>{let h=null;return c?r.isDestroyed?()=>{u.current=null}:(u.current||(h=Dx({editor:r,element:c,pluginKey:s,computePositionConfig:{...Wd,...a},onElementDragStart:o,onElementDragEnd:l,onNodeChange:i}),u.current=h.plugin,r.registerPlugin(u.current)),()=>{r.unregisterPlugin(s),u.current=null,h&&(h.unbind(),h=null)}):()=>{u.current=null}},[c,r,i,s,a,o,l]),m.jsx("div",{className:e,style:{visibility:"hidden",position:"absolute"},ref:d,children:n})},xj=bj;const wj=({editor:t,className:e,onDragStart:n,onDragEnd:r,onNodeChange:s})=>{const i=C.useRef(null),o=C.useMemo(()=>a=>{a.preventDefault(),a.stopPropagation();const c=i.current;if(!c)return;const d=new CustomEvent("tiptap-gutter-toggle",{bubbles:!0,detail:{handle:c,button:a.currentTarget}});c.dispatchEvent(d)},[]),l=a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),o(a))};return t?m.jsx(xj,{editor:t,className:De.cn("tiptap-drag-handle",e),onElementDragStart:n,onElementDragEnd:r,onNodeChange:a=>s?.(a),children:m.jsxs("div",{ref:i,className:"tiptap-drag-handle__group",role:"group","data-orientation":"horizontal",children:[m.jsx("button",{type:"button","aria-label":"Insert block",title:"Insert block",className:"tiptap-drag-handle__button tiptap-drag-handle__button--ghost tiptap-drag-handle__plus",onClick:o,onKeyDown:l,children:m.jsx(kj,{})}),m.jsx("button",{type:"button",className:"tiptap-drag-handle__button tiptap-drag-handle__button--ghost tiptap-drag-handle__grip",role:"button","aria-label":"Drag to reorder",title:"Drag to reorder",tabIndex:0,children:m.jsx(vj,{})})]})}):null},kj=({className:t,...e})=>m.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:De.cn("tiptap-drag-handle__icon tiptap-drag-handle__icon--filled",t),...e,children:m.jsx("path",{d:"M13 5C13 4.44772 12.5523 4 12 4C11.4477 4 11 4.44772 11 5V11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H11V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V13H19C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11H13V5Z"})}),vj=({className:t,...e})=>m.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:De.cn("tiptap-drag-handle__icon tiptap-drag-handle__icon--filled",t),...e,children:[m.jsx("path",{d:"M9 3C7.89543 3 7 3.89543 7 5C7 6.10457 7.89543 7 9 7C10.1046 7 11 6.10457 11 5C11 3.89543 10.1046 3 9 3Z"}),m.jsx("path",{d:"M9 10C7.89543 10 7 10.8954 7 12C7 13.1046 7.89543 14 9 14C10.1046 14 11 13.1046 11 12C11 10.8954 10.1046 10 9 10Z"}),m.jsx("path",{d:"M7 19C7 17.8954 7.89543 17 9 17C10.1046 17 11 17.8954 11 19C11 20.1046 10.1046 21 9 21C7.89543 21 7 20.1046 7 19Z"}),m.jsx("path",{d:"M15 10C13.8954 10 13 10.8954 13 12C13 13.1046 13.8954 14 15 14C16.1046 14 17 13.1046 17 12C17 10.8954 16.1046 10 15 10Z"}),m.jsx("path",{d:"M13 5C13 3.89543 13.8954 3 15 3C16.1046 3 17 3.89543 17 5C17 6.10457 16.1046 7 15 7C13.8954 7 13 6.10457 13 5Z"}),m.jsx("path",{d:"M15 17C13.8954 17 13 17.8954 13 19C13 20.1046 13.8954 21 15 21C16.1046 21 17 20.1046 17 19C17 17.8954 16.1046 17 15 17Z"})]}),Sj=({html:t,className:e})=>{const n=C.useRef(null);return C.useEffect(()=>{const r=n.current;if(!r)return;r.innerHTML=t;const s=[];return Array.from(r.querySelectorAll("script")).forEach(o=>{const l=document.createElement("script");for(const a of Array.from(o.attributes))l.setAttribute(a.name,a.value);if(o.src)l.src=o.src;else{const a=o.textContent||"",c=new Blob([a],{type:l.type||"text/javascript"}),d=URL.createObjectURL(c);l.src=d,l.async=!1,s.push(d)}o.parentNode?.insertBefore(l,o),o.remove()}),()=>{s.forEach(o=>{try{URL.revokeObjectURL(o)}catch(l){process.env.NODE_ENV!=="production"&&console.warn("Failed to revoke object URL",o,l)}})}},[t]),m.jsx("div",{ref:n,className:e})},Cj=de.create({name:"enhancedFocus",addOptions(){return{className:"has-focus",mode:"all",showFocusRing:!0,highlightSelection:!0,dimUnfocused:!1,animateTransitions:!0}},addProseMirrorPlugins(){return[new me({key:new ye("enhancedFocus"),props:{decorations:({doc:t,selection:e})=>{const{from:n,to:r}=e,s=[];if(t.nodesBetween(n,r,(i,o)=>{const l=_e.node(o,o+i.nodeSize,{class:this.options.className});s.push(l)}),this.options.highlightSelection&&n!==r){const i=_e.inline(n,r,{class:"selection-highlight"});s.push(i)}if(this.options.showFocusRing){const i=_e.widget(n,()=>{const o=document.createElement("div");return o.className="focus-ring",o});s.push(i)}return be.create(t,s)}},view:()=>({update:(t,e)=>{const{state:n}=t,{selection:r}=n,s=e.selection;r.eq(s)||this.editor.emit("selectionUpdate",{editor:this.editor,transaction:n.tr})}})})]},addGlobalAttributes(){return[{types:["paragraph","heading","blockquote","codeBlock","listItem"],attributes:{"data-focused":{default:null,renderHTML:t=>t["data-focused"]?{"data-focused":t["data-focused"]}:{}}}}]},onCreate(){const t=this.editor.view.dom;this.options.animateTransitions&&t.classList.add("focus-transitions"),this.options.dimUnfocused&&t.classList.add("dim-unfocused")},onSelectionUpdate(){const{state:t}=this.editor,{selection:e}=t,{from:n,to:r}=e,s=t.tr;let i=!1;t.doc.descendants((o,l)=>{if(o.isText||o.isLeaf)return;const a=l,c=l+o.nodeSize,d=n>=a&&r<=c,u=o.attrs["data-focused"];d&&!u?(s.setNodeMarkup(l,void 0,{...o.attrs,"data-focused":"true"}),i=!0):!d&&u&&(s.setNodeMarkup(l,void 0,{...o.attrs,"data-focused":null}),i=!0)}),i&&this.editor.view.dispatch(s)},addStorage(){return{isFocused:!1}},onFocus(){this.editor.view.dom.classList.add("editor-focused"),this.storage.isFocused=!0},onBlur(){this.editor.view.dom.classList.remove("editor-focused"),this.storage.isFocused=!1}}),Ej=de.create({name:"keyboardShortcuts",addOptions(){return{enableAdvancedShortcuts:!0,enableCustomShortcuts:!0,showShortcutHints:!1}},addKeyboardShortcuts(){const t={};return this.options.enableAdvancedShortcuts&&(t["Mod-Shift-x"]=()=>this.editor.commands.toggleStrike(),t["Mod-Shift-h"]=()=>this.editor.commands.toggleHighlight(),t["Mod-Shift-c"]=()=>this.editor.commands.toggleCode(),t["Mod-Alt-1"]=()=>this.editor.commands.toggleHeading({level:1}),t["Mod-Alt-2"]=()=>this.editor.commands.toggleHeading({level:2}),t["Mod-Alt-3"]=()=>this.editor.commands.toggleHeading({level:3}),t["Mod-Alt-4"]=()=>this.editor.commands.toggleHeading({level:4}),t["Mod-Alt-5"]=()=>this.editor.commands.toggleHeading({level:5}),t["Mod-Alt-6"]=()=>this.editor.commands.toggleHeading({level:6}),t["Mod-Alt-0"]=()=>this.editor.commands.setParagraph(),t["Mod-Shift-8"]=()=>this.editor.commands.toggleBulletList(),t["Mod-Shift-7"]=()=>this.editor.commands.toggleOrderedList(),t["Mod-Shift-9"]=()=>this.editor.commands.toggleTaskList(),t["Mod-Shift-b"]=()=>this.editor.commands.toggleBlockquote(),t["Mod-Alt-c"]=()=>this.editor.commands.toggleCodeBlock(),t["Mod-Shift-minus"]=()=>this.editor.commands.setHorizontalRule(),t["Mod-Shift-l"]=()=>this.editor.commands.setTextAlign("left"),t["Mod-Shift-e"]=()=>this.editor.commands.setTextAlign("center"),t["Mod-Shift-r"]=()=>this.editor.commands.setTextAlign("right"),t["Mod-Shift-j"]=()=>this.editor.commands.setTextAlign("justify"),t["Mod-comma"]=()=>this.editor.commands.toggleSubscript(),t["Mod-period"]=()=>this.editor.commands.toggleSuperscript(),t["Mod-Alt-t"]=()=>this.editor.can().insertTable()?this.editor.commands.insertTable({rows:3,cols:3,withHeaderRow:!0}):!1,t["Mod-Home"]=()=>this.editor.commands.focus("start"),t["Mod-End"]=()=>this.editor.commands.focus("end"),t["Mod-a"]=()=>this.editor.commands.selectAll(),t["Mod-\\"]=()=>this.editor.commands.unsetAllMarks()&&this.editor.commands.clearNodes(),t["Mod-k"]=()=>{const e=window.prompt("Enter URL:");return e?this.editor.commands.setLink({href:e}):!1},t["Mod-Shift-i"]=()=>{const e=window.prompt("Enter image URL:");return e?this.editor.commands.setImage({src:e}):!1},t["Alt-ArrowUp"]=()=>{const{selection:e}=this.editor.state,{$from:n}=e,r=n.nodeBefore;if(r){const s=n.pos-r.nodeSize;return this.editor.commands.setTextSelection(s)}return!1},t["Alt-ArrowDown"]=()=>{const{selection:e}=this.editor.state,{$to:n}=e,r=n.nodeAfter;if(r){const s=n.pos+r.nodeSize;return this.editor.commands.setTextSelection(s)}return!1},t["Mod-Shift-d"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);return s?this.editor.commands.insertContentAt(r,`
|
|
159
|
+
${s}`):!1},t["Mod-Shift-k"]=()=>{const{selection:e}=this.editor.state,{$from:n,$to:r}=e,s=n.start(),i=r.end();return this.editor.commands.deleteRange({from:s,to:i})},t["Mod-Backspace"]=()=>{const{selection:e}=this.editor.state,{from:n}=e,r=this.editor.state.doc.resolve(n);let s=n;const i=r.parent.textContent,o=r.parentOffset;for(let l=o-1;l>=0;l--){if(/\s/.test(i[l])){s=n-(o-l-1);break}l===0&&(s=n-o)}return this.editor.commands.deleteRange({from:s,to:n})},t["Mod-Delete"]=()=>{const{selection:e}=this.editor.state,{to:n}=e,r=this.editor.state.doc.resolve(n);let s=n;const i=r.parent.textContent,o=r.parentOffset;for(let l=o;l<i.length;l++){if(/\s/.test(i[l])){s=n+(l-o);break}l===i.length-1&&(s=n+(i.length-o))}return this.editor.commands.deleteRange({from:n,to:s})}),this.options.enableCustomShortcuts&&(t["Mod-Shift-a"]=()=>this.editor.can().setAlertWidget()?this.editor.commands.setAlertWidget():!1,t["Mod-Shift-t"]=()=>this.editor.can().setCtaWidget()?this.editor.commands.setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}):!1,t["Mod-Shift-f"]=()=>(this.editor.view.dom.classList.toggle("focus-mode"),!0),t["Mod-Shift-w"]=()=>(this.editor.view.dom.classList.toggle("writing-mode"),!0),t["Mod-Shift-u"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);return s?this.editor.commands.insertContentAt({from:n,to:r},s.toUpperCase()):!1},t["Mod-Shift-l"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);return s?this.editor.commands.insertContentAt({from:n,to:r},s.toLowerCase()):!1},t["Mod-Shift-p"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);if(s){const i=s.replace(/\w\S*/g,o=>o.charAt(0).toUpperCase()+o.substr(1).toLowerCase());return this.editor.commands.insertContentAt({from:n,to:r},i)}return!1}),t},addStorage(){return{shortcuts:{},hints:[]}},onCreate(){this.options.showShortcutHints&&(this.storage.shortcuts={},this.storage.hints=[{category:"Text Formatting",shortcuts:[{keys:"Cmd/Ctrl + B",action:"Bold"},{keys:"Cmd/Ctrl + I",action:"Italic"},{keys:"Cmd/Ctrl + U",action:"Underline"},{keys:"Cmd/Ctrl + Shift + X",action:"Strikethrough"},{keys:"Cmd/Ctrl + Shift + H",action:"Highlight"},{keys:"Cmd/Ctrl + E",action:"Inline Code"}]},{category:"Headings",shortcuts:[{keys:"Cmd/Ctrl + Alt + 1-6",action:"Heading 1-6"},{keys:"Cmd/Ctrl + Alt + 0",action:"Paragraph"}]},{category:"Lists",shortcuts:[{keys:"Cmd/Ctrl + Shift + 8",action:"Bullet List"},{keys:"Cmd/Ctrl + Shift + 7",action:"Numbered List"},{keys:"Cmd/Ctrl + Shift + 9",action:"Task List"}]},{category:"Blocks",shortcuts:[{keys:"Cmd/Ctrl + Shift + B",action:"Blockquote"},{keys:"Cmd/Ctrl + Alt + C",action:"Code Block"},{keys:"Cmd/Ctrl + Alt + T",action:"Table"}]},{category:"Navigation",shortcuts:[{keys:"Cmd/Ctrl + A",action:"Select All"},{keys:"Cmd/Ctrl + Home",action:"Go to Start"},{keys:"Cmd/Ctrl + End",action:"Go to End"}]},{category:"Advanced",shortcuts:[{keys:"Cmd/Ctrl + K",action:"Insert Link"},{keys:"Cmd/Ctrl + Shift + I",action:"Insert Image"},{keys:"Cmd/Ctrl + \\",action:"Clear Formatting"}]}])}}),Mj=()=>{const[t,e]=C.useState("<p>Start testing...</p>"),[n,r]=C.useState([]),[s,i]=C.useState(!1),[o,l]=C.useState(""),a=x=>({name:x,tests:[],status:"pending"}),c=(x,k)=>{r(v=>v.map(T=>{if(T.name===x){const N=[...T.tests,k],H=N.some(I=>I.status==="fail"),V=N.some(I=>I.status==="warning"),$=N.every(I=>I.status!=="pending");return{...T,tests:N,status:H?"fail":V?"warning":$?"pass":"pending"}}return T}))},d=x=>new Promise(k=>setTimeout(k,x)),u=async()=>{const x="Drag and Drop";l(x);try{const k=document.querySelectorAll(".drag-handle, .drag-handle-button");c(x,{name:"Drag Handle Presence",status:k.length>0?"pass":"fail",message:k.length>0?"Drag handles found":"No drag handles detected",details:`Found ${k.length} drag handle elements`});const v=document.querySelector("style")?.textContent?.includes("drag-handle")||Array.from(document.styleSheets).some(N=>{try{return Array.from(N.cssRules).some(H=>H.cssText.includes("drag-handle"))}catch{return!1}});c(x,{name:"Drag Handle CSS",status:v?"pass":"warning",message:v?"Drag handle CSS loaded":"Drag handle CSS may not be loaded",details:"Check if drag-handle.css is properly imported"});const T=document.querySelectorAll('[data-draggable="true"]');c(x,{name:"Draggable Nodes",status:T.length>0?"pass":"warning",message:T.length>0?"Draggable nodes found":"No draggable nodes detected",details:`Found ${T.length} draggable nodes`})}catch(k){c(x,{name:"Drag and Drop Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},h=async()=>{const x="Undo/Redo System";l(x);try{const k=document.querySelectorAll('[aria-label*="Undo"], [title*="Undo"]'),v=document.querySelectorAll('[aria-label*="Redo"], [title*="Redo"]');c(x,{name:"Undo/Redo Buttons",status:k.length>0&&v.length>0?"pass":"fail",message:`Found ${k.length} undo and ${v.length} redo buttons`,details:"Undo/Redo buttons should be present in toolbar"}),e("<p>Test content for undo</p>"),await d(100),c(x,{name:"History State Change",status:"pass",message:"Content change detected",details:"History system should track this change"});const T=typeof document<"u"&&document.addEventListener!==void 0;c(x,{name:"Keyboard Shortcuts",status:T?"pass":"warning",message:"Keyboard event system available",details:"Ctrl+Z and Ctrl+Y shortcuts should work"})}catch(k){c(x,{name:"Undo/Redo Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},f=async()=>{const x="Enhanced Floating Menu";l(x);try{const k=document.querySelectorAll('[aria-label*="Insert"], .enhanced-floating-menu');c(x,{name:"Floating Menu Trigger",status:k.length>0?"pass":"warning",message:k.length>0?"Floating menu trigger found":"No floating menu trigger detected",details:"Should appear on empty paragraphs"});const v=document.querySelectorAll('input[placeholder*="Search"], .search-input');c(x,{name:"Search Functionality",status:v.length>0?"pass":"warning",message:v.length>0?"Search input found":"Search input not visible",details:"Search should be available when menu is open"});const T=document.querySelectorAll("[data-category], .category-button");c(x,{name:"Category Filters",status:T.length>0?"pass":"warning",message:T.length>0?"Category filters found":"Category filters not visible",details:"Should have Basic, Headings, Lists, Media, Advanced categories"})}catch(k){c(x,{name:"Enhanced Floating Menu Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},p=async()=>{const x="Advanced Placeholders";l(x);try{const k=Array.from(document.styleSheets).some(N=>{try{return Array.from(N.cssRules).some(H=>H.cssText.includes("is-empty")||H.cssText.includes("placeholder"))}catch{return!1}});c(x,{name:"Placeholder CSS",status:k?"pass":"warning",message:k?"Placeholder CSS loaded":"Placeholder CSS may not be loaded",details:"Check if advanced-features.css is properly imported"});const v=document.querySelectorAll(".is-empty, .is-editor-empty");c(x,{name:"Empty Node Detection",status:v.length>=0?"pass":"warning",message:`Found ${v.length} empty nodes`,details:"Empty nodes should have placeholder classes"}),e("<p></p>"),await d(100);const T=document.querySelectorAll("[data-placeholder]");c(x,{name:"Placeholder Content",status:T.length>0?"pass":"warning",message:T.length>0?"Placeholder content found":"No placeholder content detected",details:"Should show contextual placeholders for different node types"})}catch(k){c(x,{name:"Advanced Placeholders Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},g=async()=>{const x="Focus Management";l(x);try{const k=document.querySelectorAll(".has-focus, .editor-focused");c(x,{name:"Focus Classes",status:k.length>=0?"pass":"warning",message:`Found ${k.length} focus elements`,details:"Focus classes should be applied to active elements"});const v=document.querySelectorAll(".focus-ring");c(x,{name:"Focus Ring",status:v.length>=0?"pass":"warning",message:`Found ${v.length} focus rings`,details:"Focus rings provide visual feedback"}),c(x,{name:"Selection Highlighting",status:"pass",message:"Selection highlighting system available",details:"Enhanced selection visibility should work"})}catch(k){c(x,{name:"Focus Management Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},y=async()=>{const x="Mobile Experience";l(x);try{const k=document.querySelectorAll('.mobile-toolbar, [class*="mobile"]');c(x,{name:"Mobile Toolbar",status:k.length>0?"pass":"warning",message:k.length>0?"Mobile toolbar found":"Mobile toolbar not detected",details:"Should appear on mobile devices or small screens"});const v=Array.from(document.styleSheets).some(N=>{try{return Array.from(N.cssRules).some(H=>H.cssText.includes("@media")&&H.cssText.includes("768px"))}catch{return!1}});c(x,{name:"Responsive CSS",status:v?"pass":"warning",message:v?"Responsive CSS found":"Responsive CSS may not be loaded",details:"Should have mobile breakpoints"});const T=document.querySelectorAll('[class*="touch"], .toolbar-item');c(x,{name:"Touch-Friendly Elements",status:T.length>0?"pass":"warning",message:T.length>0?"Touch-friendly elements found":"No touch-friendly elements detected",details:"Should have larger touch targets for mobile"})}catch(k){c(x,{name:"Mobile Experience Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},b=async()=>{const x="Keyboard Shortcuts";l(x);try{c(x,{name:"Keyboard Shortcuts Available",status:"pass",message:`${["Ctrl+B","Ctrl+I","Ctrl+U","Ctrl+Shift+X","Ctrl+Shift+H","Ctrl+Alt+1","Ctrl+Alt+2","Ctrl+Alt+3","Ctrl+K","Ctrl+\\"].length} keyboard shortcuts configured`,details:"Text formatting, headings, lists, and advanced shortcuts"});const v=document.querySelectorAll('[title*="Ctrl"], [title*="Cmd"]');c(x,{name:"Shortcut Hints",status:v.length>0?"pass":"warning",message:v.length>0?"Shortcut hints found":"No shortcut hints detected",details:"Tooltips should show keyboard shortcuts"}),c(x,{name:"Conflict Prevention",status:"pass",message:"Keyboard shortcuts use standard patterns",details:"Should not conflict with browser shortcuts"})}catch(k){c(x,{name:"Keyboard Shortcuts Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},w=async()=>{i(!0),r([a("Drag and Drop"),a("Undo/Redo System"),a("Enhanced Floating Menu"),a("Advanced Placeholders"),a("Focus Management"),a("Mobile Experience"),a("Keyboard Shortcuts")]);try{await u(),await d(500),await h(),await d(500),await f(),await d(500),await p(),await d(500),await g(),await d(500),await y(),await d(500),await b()}catch(x){console.error("Test suite failed:",x)}finally{i(!1),l("")}},M=()=>{r([]),e("<p>Start testing...</p>"),l("")},S=x=>{switch(x){case"pass":return m.jsx(OL,{className:"h-4 w-4 text-green-500"});case"fail":return m.jsx(jL,{className:"h-4 w-4 text-red-500"});case"warning":return m.jsx(Pm,{className:"h-4 w-4 text-yellow-500"});default:return m.jsx(Pm,{className:"h-4 w-4 text-gray-400"})}},A=x=>{const k={pass:"bg-green-100 text-green-800",fail:"bg-red-100 text-red-800",warning:"bg-yellow-100 text-yellow-800",pending:"bg-gray-100 text-gray-800"};return m.jsx(a1.Badge,{className:k[x]||k.pending,children:x.toUpperCase()})};return m.jsxs("div",{className:"max-w-6xl mx-auto p-6 space-y-6",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("h1",{className:"text-3xl font-bold",children:"Tiptap v3 Feature Validation"}),m.jsxs("div",{className:"flex gap-2",children:[m.jsxs(le.Button,{onClick:M,variant:"outline",disabled:s,children:[m.jsx(CI,{className:"h-4 w-4 mr-2"}),"Reset"]}),m.jsxs(le.Button,{onClick:w,disabled:s,children:[m.jsx(bI,{className:"h-4 w-4 mr-2"}),s?"Running Tests...":"Run All Tests"]})]})]}),s&&o&&m.jsx(at.Card,{children:m.jsx(at.CardContent,{className:"pt-6",children:m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-primary"}),m.jsxs("span",{children:["Running: ",o]})]})})}),m.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[m.jsxs("div",{className:"space-y-4",children:[m.jsx("h2",{className:"text-xl font-semibold",children:"Test Results"}),n.map(x=>m.jsxs(at.Card,{children:[m.jsx(at.CardHeader,{className:"pb-3",children:m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx(at.CardTitle,{className:"text-lg",children:x.name}),A(x.status)]})}),m.jsxs(at.CardContent,{className:"space-y-2",children:[x.tests.map((k,v)=>m.jsxs("div",{className:"flex items-start gap-2 p-2 rounded border",children:[S(k.status),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:"font-medium text-sm",children:k.name}),m.jsx("div",{className:"text-xs text-muted-foreground",children:k.message}),k.details&&m.jsx("div",{className:"text-xs text-muted-foreground mt-1 opacity-75",children:k.details})]})]},v)),x.tests.length===0&&x.status==="pending"&&m.jsx("div",{className:"text-sm text-muted-foreground",children:"No tests run yet"})]})]},x.name))]}),m.jsxs("div",{className:"space-y-4",children:[m.jsx("h2",{className:"text-xl font-semibold",children:"Live Editor Test"}),m.jsx(at.Card,{children:m.jsx(at.CardContent,{className:"pt-6",children:m.jsx(Pa,{content:t,onChange:e,useEnhancedFloatingMenu:!0,showMobileToolbar:!0,enableAdvancedPlaceholders:!0,enableFocusMode:!1,showKeyboardShortcuts:!0,className:"min-h-[400px]"})})}),m.jsxs(at.Card,{children:[m.jsx(at.CardHeader,{children:m.jsx(at.CardTitle,{className:"text-lg",children:"Test Instructions"})}),m.jsxs(at.CardContent,{className:"text-sm space-y-2",children:[m.jsx("p",{children:"• Try typing in the editor to test placeholders"}),m.jsx("p",{children:"• Create empty paragraphs to test floating menu"}),m.jsx("p",{children:"• Use keyboard shortcuts (Ctrl+B, Ctrl+I, etc.)"}),m.jsx("p",{children:"• Test undo/redo with Ctrl+Z/Ctrl+Y"}),m.jsx("p",{children:"• Hover over elements to see drag handles"}),m.jsx("p",{children:"• Resize window to test mobile toolbar"})]})]})]})]})]})},Aj=()=>{const[t,e]=C.useState(`
|
|
160
160
|
<h1>Undo/Redo Test Document</h1>
|
|
161
161
|
<p>This document tests the enhanced undo/redo functionality with various content types.</p>
|
|
162
162
|
|
|
@@ -195,7 +195,7 @@ ${s}`):!1},t["Mod-Shift-k"]=()=>{const{selection:e}=this.editor.state,{$from:n,$
|
|
|
195
195
|
</table>
|
|
196
196
|
|
|
197
197
|
<p>Try editing any content above and use the undo/redo buttons or keyboard shortcuts!</p>
|
|
198
|
-
`),[n]=C.useState(null),r=Rh(n),s=[{name:"Add Bold Text",action:()=>{n&&n.chain().focus().insertContent("<p><strong>Bold text added!</strong></p>").run()}},{name:"Add Heading",action:()=>{n&&n.chain().focus().insertContent("<h3>New Heading Added</h3>").run()}},{name:"Add List Item",action:()=>{n&&n.chain().focus().insertContent("<ul><li>New list item</li></ul>").run()}},{name:"Add Table",action:()=>{n&&n.chain().focus().insertTable({rows:2,cols:2,withHeaderRow:!0}).run()}},{name:"Clear All Content",action:()=>{n&&n.chain().focus().clearContent().run()}}];return m.jsx("div",{className:"max-w-4xl mx-auto p-6 space-y-6",children:m.jsxs(at.Card,{children:[m.jsx(at.CardHeader,{children:m.jsx(at.CardTitle,{children:"Enhanced Undo/Redo Test"})}),m.jsxs(at.CardContent,{className:"space-y-4",children:[m.jsxs("div",{className:"flex items-center gap-4 p-4 bg-muted rounded-lg",children:[m.jsx("div",{className:"text-sm",children:m.jsx("strong",{children:"History State:"})}),m.jsxs("div",{className:"text-sm",children:["Can Undo: ",m.jsx("span",{className:r.canUndo?"text-green-600":"text-red-600",children:r.canUndo?"Yes":"No"})]}),m.jsxs("div",{className:"text-sm",children:["Can Redo: ",m.jsx("span",{className:r.canRedo?"text-green-600":"text-red-600",children:r.canRedo?"Yes":"No"})]}),m.jsxs("div",{className:"text-sm",children:["History Empty: ",m.jsx("span",{className:r.isHistoryEmpty?"text-orange-600":"text-blue-600",children:r.isHistoryEmpty?"Yes":"No"})]})]}),m.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg",children:[m.jsx("div",{className:"text-sm font-medium",children:"Enhanced Controls:"}),m.jsx(Oh,{editor:n,size:"md",showLabels:!0,className:"border rounded p-2"}),m.jsx("div",{className:"text-xs text-muted-foreground",children:"Keyboard: Ctrl+Z (Undo), Ctrl+Y (Redo)"})]}),m.jsxs("div",{className:"space-y-2",children:[m.jsx("div",{className:"text-sm font-medium",children:"Test Actions:"}),m.jsx("div",{className:"flex flex-wrap gap-2",children:s.map((i,o)=>m.jsx(le.Button,{variant:"outline",size:"sm",onClick:i.action,disabled:!n,children:i.name},o))})]}),m.jsx("div",{className:"border rounded-lg",children:m.jsx(Pa,{content:t,onChange:e,showToolbar:!0,showCharacterCount:!0,onFocus:()=>console.log("Editor focused"),onBlur:()=>console.log("Editor blurred")})}),m.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[m.jsx("p",{children:m.jsx("strong",{children:"Test Instructions:"})}),m.jsxs("ul",{className:"list-disc list-inside space-y-1",children:[m.jsx("li",{children:"Use the test actions above to add content"}),m.jsx("li",{children:"Try editing text directly in the editor"}),m.jsx("li",{children:"Use Ctrl+Z to undo changes"}),m.jsx("li",{children:"Use Ctrl+Y to redo changes"}),m.jsx("li",{children:"Try dragging content around (if drag handles are visible)"}),m.jsx("li",{children:"Watch the history state indicators update in real-time"}),m.jsx("li",{children:"Test with different content types: text, headings, lists, tables, etc."})]})]})]})]})})},
|
|
198
|
+
`),[n]=C.useState(null),r=Rh(n),s=[{name:"Add Bold Text",action:()=>{n&&n.chain().focus().insertContent("<p><strong>Bold text added!</strong></p>").run()}},{name:"Add Heading",action:()=>{n&&n.chain().focus().insertContent("<h3>New Heading Added</h3>").run()}},{name:"Add List Item",action:()=>{n&&n.chain().focus().insertContent("<ul><li>New list item</li></ul>").run()}},{name:"Add Table",action:()=>{n&&n.chain().focus().insertTable({rows:2,cols:2,withHeaderRow:!0}).run()}},{name:"Clear All Content",action:()=>{n&&n.chain().focus().clearContent().run()}}];return m.jsx("div",{className:"max-w-4xl mx-auto p-6 space-y-6",children:m.jsxs(at.Card,{children:[m.jsx(at.CardHeader,{children:m.jsx(at.CardTitle,{children:"Enhanced Undo/Redo Test"})}),m.jsxs(at.CardContent,{className:"space-y-4",children:[m.jsxs("div",{className:"flex items-center gap-4 p-4 bg-muted rounded-lg",children:[m.jsx("div",{className:"text-sm",children:m.jsx("strong",{children:"History State:"})}),m.jsxs("div",{className:"text-sm",children:["Can Undo: ",m.jsx("span",{className:r.canUndo?"text-green-600":"text-red-600",children:r.canUndo?"Yes":"No"})]}),m.jsxs("div",{className:"text-sm",children:["Can Redo: ",m.jsx("span",{className:r.canRedo?"text-green-600":"text-red-600",children:r.canRedo?"Yes":"No"})]}),m.jsxs("div",{className:"text-sm",children:["History Empty: ",m.jsx("span",{className:r.isHistoryEmpty?"text-orange-600":"text-blue-600",children:r.isHistoryEmpty?"Yes":"No"})]})]}),m.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg",children:[m.jsx("div",{className:"text-sm font-medium",children:"Enhanced Controls:"}),m.jsx(Oh,{editor:n,size:"md",showLabels:!0,className:"border rounded p-2"}),m.jsx("div",{className:"text-xs text-muted-foreground",children:"Keyboard: Ctrl+Z (Undo), Ctrl+Y (Redo)"})]}),m.jsxs("div",{className:"space-y-2",children:[m.jsx("div",{className:"text-sm font-medium",children:"Test Actions:"}),m.jsx("div",{className:"flex flex-wrap gap-2",children:s.map((i,o)=>m.jsx(le.Button,{variant:"outline",size:"sm",onClick:i.action,disabled:!n,children:i.name},o))})]}),m.jsx("div",{className:"border rounded-lg",children:m.jsx(Pa,{content:t,onChange:e,showToolbar:!0,showCharacterCount:!0,onFocus:()=>console.log("Editor focused"),onBlur:()=>console.log("Editor blurred")})}),m.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[m.jsx("p",{children:m.jsx("strong",{children:"Test Instructions:"})}),m.jsxs("ul",{className:"list-disc list-inside space-y-1",children:[m.jsx("li",{children:"Use the test actions above to add content"}),m.jsx("li",{children:"Try editing text directly in the editor"}),m.jsx("li",{children:"Use Ctrl+Z to undo changes"}),m.jsx("li",{children:"Use Ctrl+Y to redo changes"}),m.jsx("li",{children:"Try dragging content around (if drag handles are visible)"}),m.jsx("li",{children:"Watch the history state indicators update in real-time"}),m.jsx("li",{children:"Test with different content types: text, headings, lists, tables, etc."})]})]})]})]})})},Tj=()=>{const[t,e]=C.useState(`
|
|
199
199
|
<h1>Enhanced NotionEditor Test</h1>
|
|
200
200
|
<p>This is a test of the enhanced NotionEditor with undo/redo buttons and improved drag handles.</p>
|
|
201
201
|
<h2>Drag Handle UX Improvements:</h2>
|
|
@@ -216,4 +216,4 @@ ${s}`):!1},t["Mod-Shift-k"]=()=>{const{selection:e}=this.editor.state,{$from:n,$
|
|
|
216
216
|
<li>Second item - drag handle should be centered vertically</li>
|
|
217
217
|
</ol>
|
|
218
218
|
<p>Try typing some text and then using the undo/redo buttons in the toolbar.</p>
|
|
219
|
-
`);return m.jsxs("div",{className:"p-6 max-w-4xl mx-auto",children:[m.jsx("h1",{className:"text-2xl font-bold mb-4",children:"NotionEditor Enhanced Features Test"}),m.jsxs("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg",children:[m.jsx("h3",{className:"font-semibold text-blue-800 mb-2",children:"Drag Handle UX Test Instructions:"}),m.jsxs("ol",{className:"list-decimal list-inside text-blue-700 space-y-1",children:[m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"target",children:"🎯"})," ",m.jsx("strong",{children:"Expanded Hover Area:"})," Hover anywhere on a content block (not just the handle area) - drag handle should appear"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"pushpin",children:"📍"})," ",m.jsx("strong",{children:"Proper Centering:"})," Verify drag handles are vertically centered within each content section"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"refresh arrows",children:"🔄"})," ",m.jsx("strong",{children:"Content Types:"})," Test on paragraphs, headings, lists, and blockquotes"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"mobile phone",children:"📱"})," ",m.jsx("strong",{children:"Mobile Responsive:"})," Check that drag handles work properly on smaller screens"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"sparkles",children:"✨"})," ",m.jsx("strong",{children:"Visual Feedback:"})," Notice smooth transitions and enhanced styling"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"computer mouse",children:"🖱️"})," ",m.jsx("strong",{children:"Drag Functionality:"})," Try dragging blocks to reorder them"]})]})]}),m.jsx("div",{className:"border border-gray-200 rounded-lg",children:m.jsx(xw,{content:t,onChange:e,showToolbar:!0,showCharacterCount:!0,className:"min-h-[600px]"})}),m.jsxs("div",{className:"mt-4 p-4 bg-gray-50 border border-gray-200 rounded-lg",children:[m.jsx("h3",{className:"font-semibold mb-2",children:"Current Content (JSON):"}),m.jsx("pre",{className:"text-xs bg-white p-2 rounded border overflow-auto max-h-32",children:JSON.stringify(t,null,2)})]})]})};exports.AdvancedPlaceholder=Wx;exports.AlertWidget=qx;exports.CtaWidgetNode=Kx;exports.DragHandle=
|
|
219
|
+
`);return m.jsxs("div",{className:"p-6 max-w-4xl mx-auto",children:[m.jsx("h1",{className:"text-2xl font-bold mb-4",children:"NotionEditor Enhanced Features Test"}),m.jsxs("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg",children:[m.jsx("h3",{className:"font-semibold text-blue-800 mb-2",children:"Drag Handle UX Test Instructions:"}),m.jsxs("ol",{className:"list-decimal list-inside text-blue-700 space-y-1",children:[m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"target",children:"🎯"})," ",m.jsx("strong",{children:"Expanded Hover Area:"})," Hover anywhere on a content block (not just the handle area) - drag handle should appear"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"pushpin",children:"📍"})," ",m.jsx("strong",{children:"Proper Centering:"})," Verify drag handles are vertically centered within each content section"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"refresh arrows",children:"🔄"})," ",m.jsx("strong",{children:"Content Types:"})," Test on paragraphs, headings, lists, and blockquotes"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"mobile phone",children:"📱"})," ",m.jsx("strong",{children:"Mobile Responsive:"})," Check that drag handles work properly on smaller screens"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"sparkles",children:"✨"})," ",m.jsx("strong",{children:"Visual Feedback:"})," Notice smooth transitions and enhanced styling"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"computer mouse",children:"🖱️"})," ",m.jsx("strong",{children:"Drag Functionality:"})," Try dragging blocks to reorder them"]})]})]}),m.jsx("div",{className:"border border-gray-200 rounded-lg",children:m.jsx(xw,{content:t,onChange:e,showToolbar:!0,showCharacterCount:!0,className:"min-h-[600px]"})}),m.jsxs("div",{className:"mt-4 p-4 bg-gray-50 border border-gray-200 rounded-lg",children:[m.jsx("h3",{className:"font-semibold mb-2",children:"Current Content (JSON):"}),m.jsx("pre",{className:"text-xs bg-white p-2 rounded border overflow-auto max-h-32",children:JSON.stringify(t,null,2)})]})]})};exports.AdvancedPlaceholder=Wx;exports.AlertWidget=qx;exports.CtaWidgetNode=Kx;exports.DragHandle=wj;exports.DraggableNodes=rw;exports.Editor=Pa;exports.EditorBubbleMenu=Nh;exports.EditorFloatingMenu=_h;exports.EditorToolbar=Dh;exports.EnhancedFloatingMenu=mw;exports.EnhancedFocus=Cj;exports.FeatureValidationTest=Mj;exports.HtmlContent=Sj;exports.KeyboardShortcuts=Ej;exports.MobileToolbar=bw;exports.NotionEditor=xw;exports.NotionEditorEnhancedTest=Tj;exports.SlashCommand=nw;exports.SlashCommandList=Eh;exports.Toolbar=ww;exports.ToolbarButton=vw;exports.ToolbarGroup=kw;exports.ToolbarSeparator=Sw;exports.TrailingNode=Vx;exports.UndoRedoButtons=Oh;exports.UndoRedoTest=Aj;exports.canExecuteHistoryAction=yw;exports.default=Pa;exports.editorExtensions=Mh;exports.executeHistoryAction=uj;exports.getHistoryShortcut=eu;exports.useEditorHistory=Rh;
|