@novaprose/tinymce-compat 0.8.0 → 0.9.0

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.
Files changed (49) hide show
  1. package/README.md +1 -1
  2. package/dist/index.cjs +11 -1
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.js +11 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/novaprose.css +56 -6
  7. package/dist/tinymce-chunks/de-21549c7e.js +2 -0
  8. package/dist/tinymce-chunks/de-21549c7e.js.map +7 -0
  9. package/dist/tinymce-chunks/es-1de93a3f.js +2 -0
  10. package/dist/tinymce-chunks/es-1de93a3f.js.map +7 -0
  11. package/dist/tinymce-chunks/{exportpdf-0c6647bc.js → exportpdf-1dfcbddc.js} +2 -2
  12. package/dist/tinymce-chunks/{exportword-8a03f24d.js → exportword-ad95abb4.js} +2 -2
  13. package/dist/tinymce-chunks/fr-6fbcca9f.js +2 -0
  14. package/dist/tinymce-chunks/fr-6fbcca9f.js.map +7 -0
  15. package/dist/tinymce-chunks/{importword-ec0b2213.js → importword-d6c2636a.js} +2 -2
  16. package/dist/tinymce-chunks/{index-330c7726.js → index-a1feed69.js} +5 -5
  17. package/dist/tinymce-chunks/{index-330c7726.js.map → index-a1feed69.js.map} +4 -4
  18. package/dist/tinymce-chunks/it-ca70815f.js +2 -0
  19. package/dist/tinymce-chunks/it-ca70815f.js.map +7 -0
  20. package/dist/tinymce-chunks/paste-office-4e8e9cb7.js +3 -0
  21. package/dist/tinymce-chunks/paste-office-4e8e9cb7.js.map +7 -0
  22. package/dist/tinymce-chunks/pt-BR-f6958ec0.js +2 -0
  23. package/dist/tinymce-chunks/pt-BR-f6958ec0.js.map +7 -0
  24. package/dist/tinymce-chunks/ru-982f3476.js +2 -0
  25. package/dist/tinymce-chunks/ru-982f3476.js.map +7 -0
  26. package/dist/tinymce-chunks/{search-bar-3ea04183.js → search-bar-1c8ef2ee.js} +2 -2
  27. package/dist/tinymce-chunks/search-bar-1c8ef2ee.js.map +7 -0
  28. package/dist/tinymce.global.js +28 -28
  29. package/dist/tinymce.global.js.map +4 -4
  30. package/dist/tinymce.licenses.txt +1 -1
  31. package/package.json +2 -2
  32. package/dist/tinymce-chunks/de-eb649701.js +0 -2
  33. package/dist/tinymce-chunks/de-eb649701.js.map +0 -7
  34. package/dist/tinymce-chunks/es-b9c95169.js +0 -2
  35. package/dist/tinymce-chunks/es-b9c95169.js.map +0 -7
  36. package/dist/tinymce-chunks/fr-724ffe36.js +0 -2
  37. package/dist/tinymce-chunks/fr-724ffe36.js.map +0 -7
  38. package/dist/tinymce-chunks/it-f4816bbc.js +0 -2
  39. package/dist/tinymce-chunks/it-f4816bbc.js.map +0 -7
  40. package/dist/tinymce-chunks/paste-office-d6821891.js +0 -3
  41. package/dist/tinymce-chunks/paste-office-d6821891.js.map +0 -7
  42. package/dist/tinymce-chunks/pt-BR-abebbb34.js +0 -2
  43. package/dist/tinymce-chunks/pt-BR-abebbb34.js.map +0 -7
  44. package/dist/tinymce-chunks/ru-f1d19f4f.js +0 -2
  45. package/dist/tinymce-chunks/ru-f1d19f4f.js.map +0 -7
  46. package/dist/tinymce-chunks/search-bar-3ea04183.js.map +0 -7
  47. /package/dist/tinymce-chunks/{exportpdf-0c6647bc.js.map → exportpdf-1dfcbddc.js.map} +0 -0
  48. /package/dist/tinymce-chunks/{exportword-8a03f24d.js.map → exportword-ad95abb4.js.map} +0 -0
  49. /package/dist/tinymce-chunks/{importword-ec0b2213.js.map → importword-d6c2636a.js.map} +0 -0
@@ -1,27 +1,27 @@
1
- /*! NovaProse 0.8.0 | MIT | third-party licenses: tinymce.licenses.txt */
1
+ /*! NovaProse 0.9.0 | MIT | third-party licenses: tinymce.licenses.txt */
2
2
  var __novaChunkBase=typeof document!=="undefined"&&(document.currentScript&&document.currentScript.src||document.baseURI)||"";function __novaChunk(p){return new URL(p,__novaChunkBase).href}
3
- (()=>{var wy=Object.create;var So=Object.defineProperty;var Sy=Object.getOwnPropertyDescriptor;var My=Object.getOwnPropertyNames;var Ey=Object.getPrototypeOf,Cy=Object.prototype.hasOwnProperty;var Ay=(n,e,t)=>e in n?So(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var _=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var j=(n,e)=>{for(var t in e)So(n,t,{get:e[t],enumerable:!0})},Ty=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of My(e))!Cy.call(n,o)&&o!==t&&So(n,o,{get:()=>e[o],enumerable:!(r=Sy(e,o))||r.enumerable});return n};var I=(n,e,t)=>(t=n!=null?wy(Ey(n)):{},Ty(e||!n||!n.__esModule?So(t,"default",{value:n,enumerable:!0}):t,n));var S=(n,e,t)=>Ay(n,typeof e!="symbol"?e+"":e,t);var sm={};var Rs={};j(Rs,{definePlugin:()=>mu,isPluginRegistered:()=>Mo,loadPlugin:()=>Ps,orderPlugins:()=>On,pageHandlerOf:()=>yr,registerPlugin:()=>V,resolveEntries:()=>br});function yr(n,e){for(let t of n)if(t.page)try{return typeof t.page=="function"?t.page(e):t.page}catch(r){console.error(`[nova] Plugin "${t.name}" failed to set up its page`,r)}return null}function mu(n){return n}var Ls=new Map;function V(n,e){Ls.set(n,e)}function Mo(n){return Ls.has(n)}function hu(n){return typeof n=="function"}function br(n){let e=[],t=[],r=[];for(let o of n)if(typeof o=="string"){let i=Ls.get(o);i?hu(i)?t.push(i):e.push(i):r.push(`Plugin "${o}" is not registered`)}else hu(o)?t.push(o):e.push(o);return{plugins:e,loaders:t,errors:r}}function On(n,e=new Set){let t=new Map(n.map(l=>[l.name,l])),r=[],o=[],i=new Map,s=(l,a)=>{let c=i.get(l.name);if(c==="done")return!0;if(c==="failed")return!1;if(c==="visiting")return o.push(`Plugin dependency cycle: ${[...a,l.name].join(" \u2192 ")}`),!1;i.set(l.name,"visiting");for(let d of l.requires??[]){if(e.has(d))continue;let u=t.get(d);if(!u)return o.push(`Plugin "${l.name}" requires "${d}", which is not loaded`),i.set(l.name,"failed"),!1;if(!s(u,[...a,l.name]))return i.set(l.name,"failed"),!1}return i.set(l.name,"done"),r.push(l),!0};for(let l of n)s(l,[]);return{ordered:r,errors:o}}async function Ps(n){let e=await n();return"default"in e&&e.default?e.default:e}var dl={};j(dl,{LABELS:()=>il,default:()=>cl,detailsAround:()=>Mb,isOpen:()=>sl,setOpen:()=>Ep,summaryEnd:()=>ll});var Qs={};j(Qs,{AllSelection:()=>ue,EditorState:()=>cn,NodeSelection:()=>R,Plugin:()=>z,PluginKey:()=>Z,Selection:()=>K,SelectionRange:()=>an,TextSelection:()=>F,Transaction:()=>_o});var Vs={};j(Vs,{ContentMatch:()=>Ft,DOMParser:()=>St,DOMSerializer:()=>Ve,Fragment:()=>N,Mark:()=>Q,MarkType:()=>Pn,Node:()=>Te,NodeRange:()=>Bt,NodeType:()=>it,ReplaceError:()=>wt,ResolvedPos:()=>xr,Schema:()=>Rn,Slice:()=>D});function we(n){this.content=n}we.prototype={constructor:we,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,o=r.find(n),i=r.content.slice();return o==-1?i.push(t||n,e):(i[o+1]=e,t&&(i[o]=t)),new we(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new we(t)},addToStart:function(n,e){return new we([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new we(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),i=r.find(n);return o.splice(i==-1?o.length:i,0,e,t),new we(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=we.from(n),n.size?new we(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=we.from(n),n.size?new we(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=we.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};we.from=function(n){if(n instanceof we)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new we(e)};var Ds=we;function Au(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),i=e.child(r);if(o==i){t+=o.nodeSize;continue}if(!o.sameMarkup(i))return t;if(o.isText&&o.text!=i.text){let s=o.text,l=i.text,a=0;for(;s[a]==l[a];a++)t++;return a&&a<s.length&&a<l.length&&Ou(s.charCodeAt(a-1))&&Nu(s.charCodeAt(a))&&t--,t}if(o.content.size||i.content.size){let s=Au(o.content,i.content,t+1);if(s!=null)return s}t+=o.nodeSize}}function Tu(n,e,t,r){for(let o=n.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:t,b:r};let s=n.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=s.text,d=l.text,u=c.length,p=d.length;for(;u>0&&p>0&&c[u-1]==d[p-1];)u--,p--,t--,r--;return u&&p&&u<c.length&&Ou(c.charCodeAt(u-1))&&Nu(c.charCodeAt(u))&&(t++,r++),{a:t,b:r}}if(s.content.size||l.content.size){let c=Tu(s.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}function Nu(n){return n>=56320&&n<57344}function Ou(n){return n>=55296&&n<56320}var N=class n{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,i){for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,o+l,i||null,s)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),r,o+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let i="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new n(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;a>e&&((s<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),o+=l.nodeSize),s=a}return new n(r,o)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new n(o,i)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return Au(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Tu(this,e,t,r)}findIndex(e){if(e==0)return Eo(0,e);if(e==this.size)return Eo(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let o=this.child(t),i=r+o.nodeSize;if(i>=e)return i==e?Eo(t+1,i):Eo(t,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return n.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let o=0;o<e.length;o++){let i=e[o];r+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(t||(t=e.slice(0,o)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new n(t||e,r)}static from(e){if(!e)return n.empty;if(e instanceof n)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new n([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};N.empty=new N([],0);var _s={index:0,offset:0};function Eo(n,e){return _s.index=n,_s.offset=e,_s}function To(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!To(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!To(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}var Q=class n{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&To(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);return r.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return n.none;if(e instanceof n)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}};Q.none=[];var wt=class extends Error{},D=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Pu(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(Lu(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return n.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(N.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)o++;return new n(e,r,o)}};D.empty=new D(N.empty,0,0);function Lu(n,e,t){let{index:r,offset:o}=n.findIndex(e),i=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(o==e||i.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(Lu(i.content,e-o-1,t-o-1)))}function Pu(n,e,t,r,o,i){let{index:s,offset:l}=n.findIndex(e),a=n.maybeChild(s);if(l==e||a.isText)return i&&r<=0&&o<=0&&!i.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=Pu(a.content,e-l-1,t,s==0?r-1:0,s==n.childCount-1?o-1:0,a);return c&&n.replaceChild(s,a.copy(c))}function Ny(n,e,t){if(t.openStart>n.depth)throw new wt("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new wt("Inconsistent open depths");return Ru(n,e,t,0)}function Ru(n,e,t,r){let o=n.index(r),i=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let s=Ru(n,e,t,r+1);return i.copy(i.content.replaceChild(o,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let s=n.parent,l=s.content;return tn(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=Oy(t,n);return tn(i,_u(n,s,l,e,r))}else return tn(i,No(n,e,r))}function Du(n,e){if(!e.type.compatibleContent(n.type))throw new wt("Cannot join "+e.type.name+" onto "+n.type.name)}function Is(n,e,t){let r=n.node(t);return Du(r,e.node(t)),r}function en(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function kr(n,e,t,r){let o=(e||n).node(t),i=0,s=e?e.index(t):o.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(en(n.nodeAfter,r),i++));for(let l=i;l<s;l++)en(o.child(l),r);e&&e.depth==t&&e.textOffset&&en(e.nodeBefore,r)}function tn(n,e){if(!n.type.validContent(e))throw new wt("Invalid content for node "+n.type.name);return n.copy(e)}function _u(n,e,t,r,o){let i=n.depth>o&&Is(n,e,o+1),s=r.depth>o&&Is(t,r,o+1),l=[];return kr(null,n,o,l),i&&s&&e.index(o)==t.index(o)?(Du(i,s),en(tn(i,_u(n,e,t,r,o+1)),l)):(i&&en(tn(i,No(n,e,o+1)),l),kr(e,t,o,l),s&&en(tn(s,No(t,r,o+1)),l)),kr(r,null,o,l),new N(l)}function No(n,e,t){let r=[];if(kr(null,n,t,r),n.depth>t){let o=Is(n,e,t+1);en(tn(o,No(n,e,t+1)),r)}return kr(e,null,t,r),new N(r)}function Oy(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)o=e.node(i).copy(N.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}var xr=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)o+=r.child(i).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return Q.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let l=r;r=o,o=l}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Bt(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],o=0,i=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new n(t,r,i)}static resolveCached(e,t){let r=gu.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==t)return s}else gu.set(e,r=new Hs);let o=r.elts[r.i]=n.resolve(e,t);return r.i=(r.i+1)%Ly,o}},Hs=class{constructor(){this.elts=[],this.i=0}},Ly=12,gu=new WeakMap,Bt=class{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Py=Object.create(null),Te=class n{constructor(e,t,r,o=Q.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||N.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,o=0){this.content.nodesBetween(e,t,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,o){return this.content.textBetween(e,t,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&To(this.attrs,t||e.defaultAttrs||Py)&&Q.sameSet(this.marks,r||Q.none)}copy(e=null){return e==this.content?this:new n(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return D.empty;let o=this.resolve(e),i=this.resolve(t),s=r?0:o.sharedDepth(t),l=o.start(s),c=o.node(s).content.cut(o.pos-l,i.pos-l);return new D(c,o.depth-s,i.depth-s)}replace(e,t,r){return Ny(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return xr.resolveCached(this,e)}resolveNoCache(e){return xr.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Iu(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=N.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),bu(this.type.attrs,this.attrs,"node",this.type.name);let e=Q.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];bu(r.type.attrs,r.attrs,"mark",r.type.name),e=r.addToSet(e)}if(!Q.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let o=N.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,o,r)}};Te.prototype.text=void 0;var yu=(()=>{let{stack:n}=new Error("/");if(!n||!/\n\s*at\s/.test(n))return t=>t;let e=Object.create(null);return t=>(e[t],t)})(),Bs=class n extends Te{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Iu(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return yu(this.text.slice(e,t))}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(yu(this.text.slice(e,t)))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Iu(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}function bu(n,e,t,r){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${r}`);for(let o in n)n[o].validate&&n[o].validate(e[o])}var Ft=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Fs(e,t);if(r.next==null)return n.empty;let o=Hu(r);r.next&&r.err("Unexpected trailing text");let i=Fy(By(o));return zy(i,r),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let o=this;for(let i=t;o&&i<r;i++)o=o.matchType(e.child(i).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function i(s,l){let a=s.matchFragment(e,r);if(a&&(!t||a.validEnd))return N.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:d,next:u}=s.next[c];if(!(d.isText||d.hasRequiredAttrs())&&o.indexOf(u)==-1){o.push(u);let p=i(u,l.concat(d));if(p)return p}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(e)){let s=[];for(let l=o;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:l,next:a}=i.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
4
- `)}};Ft.empty=new Ft(!0);var Fs=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function Hu(n){let e=[];do e.push(Ry(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Ry(n){let e=[];do e.push(Dy(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Dy(n){let e=Hy(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=_y(n,e);else break;return e}function ku(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function _y(n,e){let t=ku(n),r=t;return n.eat(",")&&(n.next!="}"?r=ku(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Iy(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let i in t){let s=t[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function Hy(n){if(n.eat("(")){let e=Hu(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Iy(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function By(n){let e=[[]];return o(i(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let d=t();o(i(s.expr,a),d),a=d}if(s.max==-1)o(i(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let d=t();r(a,d),o(i(s.expr,a),d),a=d}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Bu(n,e){return e-n}function vu(n,e){let t=[];return r(e),t.sort(Bu);function r(o){let i=n[o];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(o);for(let s=0;s<i.length;s++){let{term:l,to:a}=i[s];!l&&t.indexOf(a)==-1&&r(a)}}}function Fy(n){let e=Object.create(null);return t(vu(n,0));function t(r){let o=[];r.forEach(s=>{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<o.length;d++)o[d][0]==l&&(c=o[d][1]);vu(n,a).forEach(d=>{c||o.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[r.join(",")]=new Ft(r.indexOf(n.length-1)>-1);for(let s=0;s<o.length;s++){let l=o[s][1].sort(Bu);i.next.push({type:o[s][0],next:e[l.join(",")]||t(l)})}return i}}function zy(n,e){for(let t=0,r=[n];t<r.length;t++){let o=r[t],i=!o.validEnd,s=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];s.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Fu(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function zu(n,e){let t=Object.create(null);for(let r in n){let o=n[r],i=e&&e[r];if(i===void 0)if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r);else o.validate&&o.validate(i);t[r]=i}return t}function $u(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new zs(n,r,e[r]);return t}var it=class n{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=$u(e,r.attrs),this.defaultAttrs=Fu(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==Ft.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:zu(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Te(this,this.computeAttrs(e),N.from(t),Q.setFrom(r))}createChecked(e=null,t,r){return t=N.from(t),this.checkContent(t),new Te(this,this.computeAttrs(e),t,Q.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=N.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(N.empty,!0);return i?new Te(this,e,t.append(i),Q.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:Q.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,s)=>r[i]=new n(i,t,s));let o=t.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function $y(n,e,t){let r=t.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}var zs=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?$y(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},Pn=class n{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=$u(e,o.attrs),this.excluded=null;let i=Fu(this.attrs);this.instance=i?new Q(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Q(this,zu(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new n(i,o++,t,s)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}},Rn=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=Ds.from(e.nodes),t.marks=Ds.from(e.marks||{}),this.nodes=it.compile(this.spec.nodes,this),this.marks=Pn.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=Ft.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?xu(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:xu(this,s.split(" "))}this.nodeFromJSON=o=>Te.fromJSON(this,o),this.markFromJSON=o=>Q.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof it){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,o)}text(e,t){let r=this.nodes.text;return new Bs(r,r.defaultAttrs,e,Q.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function xu(n,e){let t=[];for(let r=0;r<e.length;r++){let o=e[r],i=n.marks[o],s=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function Vy(n){return n.tag!=null}function qy(n){return n.style!=null}var St=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if(Vy(o))this.tags.push(o);else if(qy(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new Oo(this,t,!1);return r.addAll(e,Q.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Oo(this,t,!0);return r.addAll(e,Q.none,t.from,t.to),D.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(Ky(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(e);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(e,t,r,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let s=this.styles[i],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<i)break}t.splice(s,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Su(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Su(s)),s.node||s.ignore||s.mark||(s.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},Vu={address:!0,article:!0,aside:!0,blockquote:!0,body:!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},jy={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},qu={ol:!0,ul:!0},wr=1,$s=2,vr=4;function wu(n,e,t){return e!=null?(e?wr:0)|(e==="full"?$s:0):n&&n.whitespace=="pre"?wr|$s:t&~vr}var Ln=class{constructor(e,t,r,o,i,s){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=Q.none,this.match=i||(s&vr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(N.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&wr)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let t=N.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(N.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Vu.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Oo=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,i,s=wu(null,t.preserveWhitespace,0)|(r?vr:0);o?i=new Ln(o.type,o.attrs,Q.none,!0,t.topMatch||o.type.contentMatch,s):r?i=new Ln(null,null,Q.none,!0,null,s):i=new Ln(e.schema.topNodeType,null,Q.none,!0,null,s),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,o=this.top,i=o.options&$s?"full":this.localPreserveWS||(o.options&wr)>0,{schema:s}=this.parser;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
5
- `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(s.text(l[a]),t,!/\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=o.content[o.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(s.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let o=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;qu.hasOwnProperty(s)&&this.parser.normalizeLists&&Wy(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:jy.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,d=this.needsBlock;if(Vu.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(i),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
6
- `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],s=r.getPropertyValue(i);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(i,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,o){let i,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,t);this.findAtPoint(e,i)}findPlace(e,t,r){let o,i;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(i);for(let s=0;s<o.length;s++)t=this.enterInner(o[s],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let o=this.findPlace(e,t,r);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=Q.none;for(let l of o.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):Mu(l.type,e.type))&&(s=l.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,t,r,o){let i=this.findPlace(e.create(t),r,!1);return i&&(i=this.enterInner(e,t,r,!0,o)),i}enterInner(e,t,r,o=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=wu(e,i,s.options);s.options&vr&&s.content.length==0&&(l|=vr);let a=Q.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):Mu(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Ln(e,t,a,o,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=wr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let d=a>0||a==0&&o?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 s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}};function Wy(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&qu.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Ky(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Su(n){let e={};for(let t in n)e[t]=n[t];return e}function Mu(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let i=[],s=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||i.indexOf(d)<0&&s(d))return!0}};if(s(o.contentMatch))return!0}}var Ve=class n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Co(t).createDocumentFragment());let o=r,i=[];return e.forEach(s=>{if(i.length||s.marks.length){let l=0,a=0;for(;l<i.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)o=i.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],d=this.serializeMark(c,s.isInline,t);d&&(i.push([c,o]),o.appendChild(d.dom),o=d.contentDOM||d.dom)}}o.appendChild(this.serializeNodeInner(s,t))}),r}serializeNodeInner(e,t){if(e.isText)return Co(t).createTextNode(e.text);let{dom:r,contentDOM:o}=Ao(Co(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&Ao(Co(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return typeof t=="string"?{dom:e.createTextNode(t)}:Ao(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Eu(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Eu(e.marks)}};function Eu(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Co(n){return n.document||window.document}var Cu=new WeakMap;function Uy(n){let e=Cu.get(n);return e===void 0&&Cu.set(n,e=Jy(n)),e}function Jy(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function Ao(n,e,t,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let o=e[0],i;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Uy(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=o.indexOf(" ");s>0&&(t=o.slice(0,s),o=o.slice(s+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],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 p=u.indexOf(" ");p>0?a.setAttributeNS(u.slice(0,p),u.slice(p+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 p=e[u];if(p===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 if(typeof p=="string")a.appendChild(n.createTextNode(p));else{let{dom:f,contentDOM:h}=Ao(n,p,t,r);if(a.appendChild(f),h){if(l)throw new RangeError("Multiple content holes");l=h}}}return{dom:a,contentDOM:l}}var Gs={};j(Gs,{AddMarkStep:()=>Ue,AddNodeMarkStep:()=>In,AttrStep:()=>rn,DocAttrStep:()=>Cr,MapResult:()=>Dn,Mapping:()=>_n,RemoveMarkStep:()=>Je,RemoveNodeMarkStep:()=>nn,ReplaceAroundStep:()=>re,ReplaceStep:()=>le,Step:()=>oe,StepMap:()=>st,StepResult:()=>me,Transform:()=>Mt,TransformError:()=>on,canJoin:()=>at,canSplit:()=>Et,dropPoint:()=>Ar,findWrapping:()=>sn,insertPoint:()=>rp,joinPoint:()=>np,liftTarget:()=>lt,replaceStep:()=>Tr});var Ju=65535,Gu=Math.pow(2,16);function Gy(n,e){return n+e*Gu}function ju(n){return n&Ju}function Yy(n){return(n-(n&Ju))/Gu}var Yu=1,Xu=2,Lo=4,Zu=8,Dn=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Zu)>0}get deletedBefore(){return(this.delInfo&(Yu|Lo))>0}get deletedAfter(){return(this.delInfo&(Xu|Lo))>0}get deletedAcross(){return(this.delInfo&Lo)>0}},st=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=ju(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+Yy(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],d=this.ranges[l+s],u=a+c;if(e<=u){let p=c?e==a?-1:e==u?1:t:t,f=a+o+(p<0?0:d);if(r)return f;let h=e==(t<0?a:u)?null:Gy(l/3,e-a),m=0;return c&&(m|=e==a?Xu:e==u?Yu:Lo,(t<0?e!=a:e!=u)&&(m|=Zu)),new Dn(f,m,h)}o+=d-c}return r?e+o:new Dn(e+o,0,null)}touches(e,t){let r=0,o=ju(t),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let s=this.ranges[o],l=s-(this.inverted?i:0),a=s+(this.inverted?0:i),c=this.ranges[o+t],d=this.ranges[o+r];e(l,l+c,a,a+d),i+=d-c}}invert(){return new n(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?n.empty:new n(e<0?[0,-e,0]:[0,0,e])}};st.empty=new st([]);var _n=class n{constructor(e,t,r=0,o=e?e.length:0){this.mirror=t,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new n(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=e.from,r=this._maps.length;t<e.to;t++){let o=e.getMirror(t);o!=null&&(o=o<t&&o>=e.from?r+(o-e.from):void 0),this.appendMap(e._maps[t],o)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.to-1,r=this._maps.length+e._maps.length;t>=e.from;t--){let o=e.getMirror(t);o!=null&&(o=o>t&&o<e.to?r-(o-e.from)-1:void 0),this.appendMap(e._maps[t].invert(),o)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let i=this.from;i<this.to;i++){let s=this._maps[i],l=s.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new Dn(e,o,null)}},qs=Object.create(null),oe=class{getMap(){return st.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=qs[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in qs)throw new RangeError("Duplicate use of step JSON ID "+e);return qs[e]=t,t.prototype.jsonID=e,t}},me=class n{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new n(e,null)}static fail(e){return new n(null,e)}static fromReplace(e,t,r,o){try{return n.ok(e.replace(t,r,o))}catch(i){if(i instanceof wt)return n.fail(i.message);throw i}}};function Us(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let i=n.child(o);i.content.size&&(i=i.copy(Us(i.content,e,i))),i.isInline&&(i=e(i,t,o)),r.push(i)}return N.fromArray(r)}var Ue=class n extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new D(Us(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),t.openStart,t.openEnd);return me.fromReplace(e,this.from,this.to,i)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(r,o)=>{if(r.isInline&&r.isAtom){let i=this.mark.addToSet(r.marks);if(!Q.sameSet(i,r.marks)){let s=Math.max(this.from,o),l=Math.min(this.to,o+r.nodeSize);Po(Je,s,l,this.mark,t);for(let a of r.marks)a.isInSet(i)||Po(n,s,l,a,t)}}}),t.length==1?t[0]:new Er(t)}map(e){let t=e.map(this.from,1),r=e.map(this.to,-1);return t>=r?null:new n(t,r,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};oe.jsonID("addMark",Ue);var Je=class n extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new D(Us(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return me.fromReplace(e,this.from,this.to,r)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(r,o)=>{r.isInline&&r.isAtom&&this.mark.isInSet(r.marks)&&Po(Ue,Math.max(this.from,o),Math.min(this.to,o+r.nodeSize),this.mark,t)}),t.length==1?t[0]:new Er(t)}map(e){let t=e.map(this.from,1),r=e.map(this.to,-1);return t>=r?null:new n(t,r,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};oe.jsonID("removeMark",Je);function Po(n,e,t,r,o){let i=o.length?o[o.length-1]:null;i&&i instanceof n&&i.to==e&&i.mark.eq(r)?o[o.length-1]=new n(i.from,t,r):o.push(new n(e,t,r))}var Er=class n extends oe{constructor(e){super(),this.steps=e}apply(e){for(let t of this.steps){let r=t.apply(e);if(!r.doc)return r;e=r.doc}return new me(e,null)}invert(e){return new n(this.steps.map(t=>t.invert(e)))}map(e){let t=[];for(let r of this.steps){let o=r.map(e);o&&t.push(o)}return t.length?new n(t):null}toJSON(){return{stepType:"markSet",steps:this.steps.map(e=>e.toJSON())}}static fromJSON(e,t){if(!Array.isArray(t.steps)||!t.steps.every(r=>r.stepType=="addMark"||r.stepType=="removeMark"))throw new RangeError("Invalid JSON for MarkSetStep");return new n(t.steps.map(r=>oe.fromJSON(e,r)))}};oe.jsonID("markSet",Er);var In=class n extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return me.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return me.fromReplace(e,this.pos,this.pos+1,new D(N.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new n(this.pos,t.marks[o]);return new n(this.pos,this.mark)}}return new nn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};oe.jsonID("addNodeMark",In);var nn=class n extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return me.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return me.fromReplace(e,this.pos,this.pos+1,new D(N.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new In(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};oe.jsonID("removeNodeMark",nn);var le=class n extends oe{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&Ws(e,this.from,this.to)?me.fail("Structure replace would overwrite content"):me.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new st([this.from,this.to-this.from,this.slice.size])}invert(e){return new n(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&n.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new n(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof n)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?D.empty:new D(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new n(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?D.empty:new D(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new n(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new n(t.from,t.to,D.fromJSON(e,t.slice),!!t.structure)}};le.MAP_BIAS=1;oe.jsonID("replace",le);var re=class n extends oe{constructor(e,t,r,o,i,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=l}apply(e){if(this.structure&&(Ws(e,this.from,this.gapFrom)||Ws(e,this.gapTo,this.to)))return me.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return me.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?me.fromReplace(e,this.from,this.to,r):me.fail("Content does not fit in gap")}getMap(){return new st([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new n(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||i>r.pos||o>i?null:new n(t.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n(t.from,t.to,t.gapFrom,t.gapTo,D.fromJSON(e,t.slice),t.insert,!!t.structure)}};oe.jsonID("replaceAround",re);function Ws(n,e,t){let r=n.resolve(e),o=t-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function Xy(n,e,t,r){let o=[];n.doc.nodesBetween(e,t,(i,s,l)=>{if(!i.isInline)return;let a=i.marks;if(!r.isInSet(a)&&l.type.allowsMarkType(r.type)){let c=Math.max(s,e),d=Math.min(s+i.nodeSize,t);Po(Ue,c,d,r,o)}}),o.forEach(i=>n.step(i))}function Zy(n,e,t,r){let o=[],i=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline||!s.isAtom)return;i++;let a=null;if(r instanceof Pn){let c=s.marks,d;for(;d=r.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],p;for(let f=0;f<o.length;f++){let h=o[f];h.step==i-1&&u.eq(o[f].style)&&(p=h)}p?(p.to=c,p.step=i):o.push({style:u,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(s=>n.step(new Je(s.from,s.to,s.style)))}function Js(n,e,t,r=t.contentMatch,o=!0){let i=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),d=l+c.nodeSize,u=r.matchType(c.type);if(!u)s.push(new le(l,d,D.empty));else{r=u;for(let p=0;p<c.marks.length;p++)t.allowsMarkType(c.marks[p].type)||n.step(new Je(l,d,c.marks[p]));if(o&&c.isText&&t.whitespace!="pre"){let p,f=/\r?\n|\r/g,h;for(;p=f.exec(c.text);)h||(h=new D(N.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new le(l+p.index,l+p.index+p[0].length,h))}}l=d}if(!r.validEnd){let a=r.fillBefore(N.empty,!0);n.replace(l,l,new D(a,0,0))}for(let a=s.length-1;a>=0;a--)n.step(s[a])}function Qy(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function lt(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,o=0,i=0;;--r){let s=n.$from.node(r),l=n.$from.index(r)+o,a=n.$to.indexAfter(r)-i;if(r<n.depth&&s.canReplace(l,a,t))return r;if(r==0||s.type.spec.isolating||!Qy(s,l,a))break;l&&(o=1),a<s.childCount&&(i=1)}return null}function eb(n,e,t){let{$from:r,$to:o,depth:i}=e,s=r.before(i+1),l=o.after(i+1),a=s,c=l,d=N.empty,u=0;for(let h=i,m=!1;h>t;h--)m||r.index(h)>0?(m=!0,d=N.from(r.node(h).copy(d)),u++):a--;let p=N.empty,f=0;for(let h=i,m=!1;h>t;h--)m||o.after(h+1)<o.end(h)?(m=!0,p=N.from(o.node(h).copy(p)),f++):c++;n.step(new re(a,c,s,l,new D(d.append(p),u,f),d.size-u,!0))}function sn(n,e,t=null,r=n){let o=tb(n,e),i=o&&nb(r,e);return i?o.map(Wu).concat({type:e,attrs:t}).concat(i.map(Wu)):null}function Wu(n){return{type:n,attrs:null}}function tb(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return t.canReplaceWith(r,o,s)?i:null}function nb(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:s}function rb(n,e,t){let r=N.empty;for(let s=t.length-1;s>=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=N.from(t[s].type.create(t[s].attrs,r))}let o=e.start,i=e.end;n.step(new re(o,i,o,i,new D(r,0,0),t.length,!0))}function ob(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&ib(n.doc,n.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!h?c=!1:!f&&h&&(c=!0)}c===!1&&ep(n,s,l,i),Js(n,n.mapping.slice(i).map(l,1),r,void 0,c===null);let d=n.mapping.slice(i),u=d.map(l,1),p=d.map(l+s.nodeSize,1);return n.step(new re(u,p,u+1,p-1,new D(N.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Qu(n,s,l,i),!1}})}function Qu(n,e,t,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=n.mapping.slice(r).map(t+1+i+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function ep(n,e,t,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+i);n.replaceWith(s,s+1,e.type.schema.text(`
7
- `))}})}function ib(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function sb(n,e,t,r,o){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let s=t.create(r,null,o||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,s);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new re(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new D(N.from(s),0,0),1,!0))}function Et(n,e,t=1,r){let o=n.resolve(e),i=o.depth-t,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,d=t-2;c>i;c--,d--){let u=o.node(c),p=o.index(c);if(u.type.spec.isolating)return!1;let f=u.content.cutByIndex(p,u.childCount),h=r&&r[d+1];h&&(f=f.replaceChild(0,h.type.create(h.attrs)));let m=r&&r[d]||u;if(!u.canReplace(p+1,u.childCount)||!m.type.validContent(f))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function lb(n,e,t=1,r){let o=n.doc.resolve(e),i=N.empty,s=N.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){i=N.from(o.node(l).copy(i));let d=r&&r[c];s=N.from(d?d.type.create(d.attrs,s):o.node(l).copy(s))}n.step(new le(e,e,new D(i.append(s),t,t),!0))}function at(n,e){let t=n.resolve(e),r=t.index();return tp(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function ab(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),s=i.type==r?n.type.schema.nodes.text:i.type;if(t=t.matchType(s),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function tp(n,e){return!!(n&&e&&!n.isLeaf&&ab(n,e))}function np(n,e,t=-1){let r=n.resolve(e);for(let o=r.depth;;o--){let i,s,l=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):t>0?(i=r.node(o+1),l++,s=r.node(o).maybeChild(l)):(i=r.node(o).maybeChild(l-1),s=r.node(o+1)),i&&!i.isTextblock&&tp(i,s)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function cb(n,e,t){let r=null,{linebreakReplacement:o}=n.doc.type.schema,i=n.doc.resolve(e-t),s=i.node().type;if(o&&s.inlineContent){let d=s.whitespace=="pre",u=!!s.contentMatch.matchType(o);d&&!u?r=!1:!d&&u&&(r=!0)}let l=n.steps.length;if(r===!1){let d=n.doc.resolve(e+t);ep(n,d.node(),d.before(),l)}s.inlineContent&&Js(n,e+t-1,s,i.node().contentMatchAt(i.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new le(c,a.map(e+t,-1),D.empty,!0)),r===!0){let d=n.doc.resolve(c);Qu(n,d.node(),d.before(),n.steps.length)}return n}function rp(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,t))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,t))return r.after(o+1);if(i<r.node(o).childCount)return null}return null}function Ar(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let i=0;i<t.openStart;i++)o=o.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1;for(let a=0;a<2;a++){if(a){if(!l)break;l=-l}let c=r.index(s)+(l>0?1:0),d=r.node(s),u=!1;if(i==1)u=d.canReplace(c,c,o);else{let p=d.contentMatchAt(c).findWrapping(o.firstChild.type);u=p&&d.canReplaceWith(c,c,p[0])}if(u)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}}return null}function Tr(n,e,t=e,r=D.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),i=n.resolve(t);return op(o,i,r)?new le(e,t,r):new Ks(o,i,r).fit()}function op(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var Ks=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=N.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=N.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new D(i,s,l);return e>-1?new re(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new le(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let i=t.firstChild;if(t.childCount>1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=Ku(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(s?c.matchType(s.type)||(u=c.fillBefore(N.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:u};if(t==2&&s&&(d=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced;return Uu(e,-1)<=t?!1:(this.unplaced.size>1&&Uu(e,1)>r&&r++,this.unplaced=new D(e,t+1,r),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=Ku(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new D(Sr(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new D(Sr(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,d=[],{match:u,type:p}=this.frontier[t];if(o){for(let m=0;m<o.childCount;m++)d.push(o.child(m));u=u.matchFragment(o)}let f=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let m=l.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(u=g,d.push(ip(m.mark(p.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?f:-1)))}let h=c==l.childCount;h||(f=-1),this.placed=Mr(this.placed,t,N.from(d)),this.frontier[t].match=u,h&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=d[d.length-1];g&&m<f;m++)this.frontier.push({type:g.type,match:g.contentMatchAt(g.childCount)}),g=g.lastChild;this.unplaced=h?e==0?D.empty:new D(Sr(s.content,e-1,1),e-1,f<0?s.openEnd:e-1):new D(Sr(s.content,e,c),e,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!js(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=js(e,t,o,r,i);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=js(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:s,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Mr(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Mr(this.placed,this.depth,N.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(N.empty,!0);t.childCount&&(this.placed=Mr(this.placed,this.frontier.length,t))}};function Sr(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Sr(n.firstChild.content,e-1,t)))}function Mr(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Mr(n.lastChild.content,e-1,t)))}function Ku(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function ip(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,ip(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(N.empty,!0)))),n.copy(r)}function js(n,e,t,r,o){let i=n.node(e),s=o?n.indexAfter(e):n.index(e);if(s==i.childCount&&!t.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!db(t,i.content,s)?l:null}function db(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function ub(n){return n.spec.defining||n.spec.definingForContent}function Uu(n,e){for(let t=0;;t++){let r=e<0?n.firstChild:n.lastChild;if(!r||r.isAtom)return t;n=r.content}}function pb(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),i=n.doc.resolve(t);if(op(o,i,r))return n.step(new le(e,t,r));let s=lp(o,i);s[s.length-1]==0&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let p=o.depth,f=o.pos-1;p>0;p--,f--){let h=o.node(p).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(p)>-1?l=p:o.before(p)==f&&s.splice(1,0,-p)}let a=s.indexOf(l),c=[],d=r.openStart;for(let p=r.content,f=0;;f++){let h=p.firstChild;if(c.push(h),f==r.openStart)break;p=h.content}for(let p=d-1;p>=0;p--){let f=c[p],h=ub(f.type);if(h&&!f.sameMarkup(o.node(Math.abs(l)-1)))d=p;else if(h||!f.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let f=(p+d+1)%(r.openStart+1),h=c[f];if(h)for(let m=0;m<s.length;m++){let g=s[(m+a)%s.length],y=!0;g<0&&(y=!1,g=-g);let x=o.node(g-1),M=o.index(g-1);if(x.canReplaceWith(M,M,h.type,h.marks))return n.replace(o.before(g),y?i.after(g):t,new D(sp(r.content,0,r.openStart,f),f,r.openEnd))}}let u=n.steps.length;for(let p=s.length-1;p>=0&&(n.replace(e,t,r),!(n.steps.length>u));p--){let f=s[p];f<0||(e=o.before(f),t=i.after(f))}}function sp(n,e,t,r,o){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(sp(i.content,e+1,t,r,i)))}if(e>r){let i=o.contentMatchAt(0),s=i.fillBefore(n).append(n);n=s.append(i.matchFragment(s).fillBefore(N.empty,!0))}return n}function fb(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=rp(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new D(N.from(r),0,0))}function hb(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&r.parentOffset==0&&o.parentOffset==0){let s=r.sharedDepth(t),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=o.depth;a>s;a--)o.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=o.depth;a>0&&t==o.start(a);a--)t=o.before(a);r=n.doc.resolve(e),o=n.doc.resolve(t)}}let i=lp(r,o);for(let s=0;s<i.length;s++){let l=i[s],a=s==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return n.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&o.end(s)-t!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function lp(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;o>=0;o--){let i=n.start(o);if(i<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&t.push(o)}return t}var rn=class n extends oe{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return me.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return me.fromReplace(e,this.pos,this.pos+1,new D(N.from(o),0,t.isLeaf?0:1))}getMap(){return st.empty}invert(e){return new n(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new n(t.pos,t.attr,t.value)}};oe.jsonID("attr",rn);var Cr=class n extends oe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return me.ok(r)}getMap(){return st.empty}invert(e){return new n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(t.attr,t.value)}};oe.jsonID("docAttr",Cr);var on=class extends Error{};on=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};on.prototype=Object.create(Error.prototype);on.prototype.constructor=on;on.prototype.name="TransformError";var Mt=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new _n}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new on(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let o=this.mapping.maps[r];r&&(e=o.map(e,1),t=o.map(t,-1)),o.forEach((i,s,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=D.empty){let o=Tr(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new D(N.from(r),0,0))}delete(e,t){return this.replace(e,t,D.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return pb(this,e,t,r),this}replaceRangeWith(e,t,r){return fb(this,e,t,r),this}deleteRange(e,t){return hb(this,e,t),this}lift(e,t){return eb(this,e,t),this}join(e,t=1){return cb(this,e,t),this}wrap(e,t){return rb(this,e,t),this}setBlockType(e,t=e,r,o=null){return ob(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return sb(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new rn(e,t,r)),this}setDocAttribute(e,t){return this.step(new Cr(e,t)),this}addNodeMark(e,t){return this.step(new In(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof Q)t.isInSet(r.marks)&&this.step(new nn(e,t));else{let o=r.marks,i,s=[];for(;i=t.isInSet(o);)s.push(new nn(e,i)),o=i.removeFromSet(o);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,t=1,r){return lb(this,e,t,r),this}addMark(e,t,r){return Xy(this,e,t,r),this}removeMark(e,t,r){return Zy(this,e,t,r),this}clearIncompatible(e,t,r){return Js(this,e,t,r),this}};var Ys=Object.create(null),K=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new an(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=D.empty){let r=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=r,r=r.lastChild;let i=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(c.pos),l?D.empty:t),l==0&&dp(e,i,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:s,$to:l}=o[i],a=e.mapping.slice(r),c=a.map(s.pos),d=a.map(l.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),dp(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new F(e):Hn(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let i=e.depth-1;i>=0;i--){let s=t<0?Hn(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):Hn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ue(e.node(0))}static atStart(e){return Hn(e,e,0,0,1)||new ue(e)}static atEnd(e){return Hn(e,e,e.content.size,e.childCount,-1)||new ue(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Ys[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Ys)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ys[e]=t,t.prototype.jsonID=e,t}getBookmark(){return F.between(this.$anchor,this.$head).getBookmark()}};K.prototype.visible=!0;var an=class{constructor(e,t){this.$from=e,this.$to=t}},ap=!1;function cp(n){!ap&&!n.parent.inlineContent&&(ap=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var F=class n extends K{constructor(e,t=e){cp(e),cp(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return K.near(r);let o=e.resolve(t.map(this.anchor));return new n(o.parent.inlineContent?o:r,r)}replace(e,t=D.empty){if(super.replace(e,t),t==D.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Do(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let i=K.findFrom(t,r,!0)||K.findFrom(t,-r,!0);if(i)t=i.$head;else return K.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(K.findFrom(e,-r,!0)||K.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new n(e,t)}};K.jsonID("text",F);var Do=class n{constructor(e,t){this.anchor=e,this.head=t}map(e){return new n(e.map(this.anchor),e.map(this.head))}resolve(e){return F.between(e.resolve(this.anchor),e.resolve(this.head))}},R=class n extends K{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),i=e.resolve(o);return r?K.near(i):new n(i)}content(){return new D(N.from(this.node),0,0)}eq(e){return e instanceof n&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Zs(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new n(e.resolve(t.anchor))}static create(e,t){return new n(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};R.prototype.visible=!1;K.jsonID("node",R);var Zs=class n{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Do(r,r):new n(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&R.isSelectable(r)?new R(t):K.near(t)}},ue=class n extends K{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=D.empty){if(t==D.empty){e.delete(0,e.doc.content.size);let r=K.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new n(e)}map(e){return new n(e)}eq(e){return e instanceof n}getBookmark(){return mb}};K.jsonID("all",ue);var mb={map(){return this},resolve(n){return new ue(n)}};function Hn(n,e,t,r,o,i=!1){if(e.inlineContent)return F.create(n,t);for(let s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&R.isSelectable(l))return R.create(n,t-(o<0?l.nodeSize:0))}else{let a=Hn(n,l,t+o,o<0?l.childCount:0,o,i);if(a)return a}t+=l.nodeSize*o}return null}function dp(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof le||o instanceof re))return;let i=n.mapping.maps[r],s;i.forEach((l,a,c,d)=>{s==null&&(s=d)}),n.setSelection(K.near(n.doc.resolve(s),t))}var up=1,Ro=2,pp=4,_o=class extends Mt{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|up)&~Ro,this.storedMarks=null,this}get selectionSet(){return(this.updated&up)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Ro,this}ensureMarks(e){return Q.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Ro)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Ro,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Q.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(t);i=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(K.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=pp,this}get scrolledIntoView(){return(this.updated&pp)>0}};function fp(n,e){return!e||!n?n:n.bind(e)}var ln=class{constructor(e,t,r){this.name=e,this.init=fp(t.init,r),this.apply=fp(t.apply,r)}},gb=[new ln("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new ln("selection",{init(n,e){return n.selection||K.atStart(e.doc)},apply(n){return n.selection}}),new ln("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new ln("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],Nr=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=gb.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new ln(r.key,r.spec.state,r))})}},cn=class n{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),o=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=o?o[s].n:0,c=o?o[s].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(d&&r.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!o){o=[];for(let u=0;u<this.config.plugins.length;u++)o.push(u<s?{state:r,n:t.length}:{state:this,n:0})}t.push(d),r=r.applyInner(d),i=!0}o&&(o[s]={state:r,n:t.length})}}if(!i)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new n(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let i=r[o];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new _o(this)}static create(e){let t=new Nr(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new n(t);for(let o=0;o<t.fields.length;o++)r[t.fields[o].name]=t.fields[o].init(e,r);return r}reconfigure(e){let t=new Nr(this.schema,e.plugins),r=t.fields,o=new n(t);for(let i=0;i<r.length;i++){let s=r[i].name;o[s]=this.hasOwnProperty(s)?this[s]:r[i].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Nr(e.schema,e.plugins),i=new n(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=Te.fromJSON(e.schema,t.doc);else if(s.name=="selection")i.selection=K.fromJSON(i.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[s.name]=c.fromJSON.call(a,e,t[l],i);return}}i[s.name]=s.init(e,i)}}),i}};function hp(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=hp(o,e,{})),t[r]=o}return t}var z=class{constructor(e){this.spec=e,this.props={},e.props&&hp(e.props,this,this.props),this.key=e.key?e.key.key:mp("plugin")}getState(e){return e[this.key]}},Xs=Object.create(null);function mp(n){return n in Xs?n+"$"+ ++Xs[n]:(Xs[n]=0,n+"$")}var Z=class{constructor(e="key"){this.key=mp(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var tl={};j(tl,{FOCUSABLE:()=>zt,activeElement:()=>te,eventTarget:()=>el,formatShortcut:()=>Ct,h:()=>w,icon:()=>ee,isMac:()=>yp,isRtl:()=>Bn,listenDocument:()=>ct,logicalKey:()=>Ne,uniqueId:()=>qe});function w(n,e={},...t){let r=document.createElement(n);for(let[o,i]of Object.entries(e))i==null||i===!1||(typeof i=="function"?r.addEventListener(o.replace(/^on/,"").toLowerCase(),i):o==="className"?r.className=String(i):r.setAttribute(o,i===!0?"":String(i)));for(let o of t.flat())o==null||o===!1||r.append(o);return r}function ee(n){let e=document.createElement("span");return e.className="nova-icon",e.innerHTML=n,e}var gp=0;function qe(n="nova"){return gp+=1,`${n}-${gp}`}var yp=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),yb={ArrowUp:"\u2191",ArrowDown:"\u2193",ArrowLeft:"\u2190",ArrowRight:"\u2192"};function Ct(n){let e=n.split("-"),t=e.pop(),r=t.length===1?t.toUpperCase():yb[t]??t;if(yp){let i={Mod:"\u2318",Shift:"\u21E7",Alt:"\u2325",Ctrl:"\u2303"};return e.map(s=>i[s]??s).join("")+r}let o={Mod:"Ctrl",Shift:"Shift",Alt:"Alt",Ctrl:"Ctrl"};return[...e.map(i=>o[i]??i),r].join("+")}var zt='a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function te(n){let e=n.getRootNode(),t=("activeElement"in e?e.activeElement:null)??document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}function el(n){return n.composedPath?.()[0]??n.target}function ct(n,e,t){let r=n.getRootNode(),o=typeof ShadowRoot<"u"&&r instanceof ShadowRoot?r:null,i=l=>{o&&l.composedPath().includes(o.host)||t(l,el(l))},s=l=>t(l,el(l));return document.addEventListener(e,i,!0),o?.addEventListener(e,s,!0),()=>{document.removeEventListener(e,i,!0),o?.removeEventListener(e,s,!0)}}function Bn(n){return n.closest("[dir]")?.getAttribute("dir")?.toLowerCase()==="rtl"}function Ne(n,e){return n.key!=="ArrowLeft"&&n.key!=="ArrowRight"||!Bn(e)?n.key:n.key==="ArrowLeft"?"ArrowRight":"ArrowLeft"}var nl={};j(nl,{icons:()=>C});var T=n=>`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`,C={undo:T('<path d="M9 14 4 9l5-5" /><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" />'),redo:T('<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />'),bold:T('<path d="M6 12h9a4 4 0 010 8H7a1 1 0 01-1-1V5a1 1 0 011-1h7a4 4 0 010 8" />'),italic:T('<line x1="19" x2="10" y1="4" y2="4" /><line x1="14" x2="5" y1="20" y2="20" /><line x1="15" x2="9" y1="4" y2="20" />'),underline:T('<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />'),strike:T('<path d="M16 4H9a3 3 0 0 0-2.83 4" /><path d="M14 12a4 4 0 0 1 0 8H6" /><line x1="4" x2="20" y1="12" y2="12" />'),code:T('<path d="m16 18 6-6-6-6" /><path d="m8 6-6 6 6 6" />'),subscript:T('<path d="m4 5 8 8" /><path d="m12 5-8 8" /><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" />'),superscript:T('<path d="m4 19 8-8" /><path d="m12 19-8-8" /><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" />'),bulletList:T('<path d="M3 5h.01" /><path d="M3 12h.01" /><path d="M3 19h.01" /><path d="M8 5h13" /><path d="M8 12h13" /><path d="M8 19h13" />'),orderedList:T('<path d="M11 5h10" /><path d="M11 12h10" /><path d="M11 19h10" /><path d="M4 4h1v5" /><path d="M4 9h2" /><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" />'),indent:T('<path d="M21 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m3 8 4 4-4 4" />'),outdent:T('<path d="M21 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m7 8-4 4 4 4" />'),blockquote:T('<path d="M17 5H3" /><path d="M21 12H8" /><path d="M21 19H8" /><path d="M3 12v7" />'),codeBlock:T('<path d="m10 9-3 3 3 3" /><path d="m14 15 3-3-3-3" /><rect x="3" y="3" width="18" height="18" rx="2" />'),alignLeft:T('<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />'),alignCenter:T('<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />'),alignRight:T('<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />'),alignJustify:T('<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />'),horizontalRule:T('<path d="m16 16-4 4-4-4" /><path d="M3 12h18" /><path d="m8 8 4-4 4 4" />'),link:T('<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" /><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />'),unlink:T('<path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71" /><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71" /><line x1="8" x2="8" y1="2" y2="5" /><line x1="2" x2="5" y1="8" y2="8" /><line x1="16" x2="16" y1="19" y2="22" /><line x1="19" x2="22" y1="16" y2="16" />'),image:T('<rect width="18" height="18" x="3" y="3" rx="2" ry="2" /><circle cx="9" cy="9" r="2" /><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" />'),clearFormatting:T('<path d="M4 7V4h16v3" /><path d="M5 20h6" /><path d="M13 4 8 20" /><path d="m15 15 5 5" /><path d="m20 15-5 5" />'),formatMore:T('<path d="M12 4v16" /><path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" /><path d="M9 20h6" />'),imageLeft:T('<rect width="9" height="6" x="6" y="14" rx="2" /><rect width="16" height="6" x="6" y="4" rx="2" /><path d="M2 2v20" />'),imageCenter:T('<path d="M12 2v20" /><path d="M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4" /><path d="M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4" /><path d="M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1" /><path d="M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1" />'),imageRight:T('<rect width="16" height="6" x="2" y="4" rx="2" /><rect width="9" height="6" x="9" y="14" rx="2" /><path d="M22 22V2" />'),resize:T('<path d="M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" /><path d="M14 15H9v-5" /><path d="M16 3h5v5" /><path d="M21 3 9 15" />'),altText:T('<rect width="18" height="14" x="3" y="5" rx="2" ry="2" /><path d="M7 15h4M15 15h2M7 11h2M13 11h4" />'),imageCaption:T('<rect width="18" height="14" x="3" y="5" rx="2" ry="2" /><path d="M7 15h4M15 15h2M7 11h2M13 11h4" />'),trash:T('<path d="M10 11v6" /><path d="M14 11v6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M3 6h18" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />'),paragraph:T('<path d="M13 4v16" /><path d="M17 4v16" /><path d="M19 4H9.5a4.5 4.5 0 0 0 0 9H13" />'),h1:T('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="m17 12 3-2v8" />'),h2:T('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1" />'),h3:T('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2" /><path d="M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2" />'),pasteText:T('<rect width="8" height="4" x="8" y="2" rx="1" ry="1" /><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" /><path d="M9 12v-1h6v1" /><path d="M11 17h2" /><path d="M12 11v6" />'),table:T('<path d="M12 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" />'),rowBefore:T('<path d="M12 2v6" /><path d="M18.464 3H19a2 2 0 012 2v14a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h.535" /><path d="M21 12H3" /><path d="M9 5h6" />'),rowAfter:T('<path d="M12 22v-6" /><path d="M18.464 21H19a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h.535" /><path d="M21 12H3" /><path d="M9 19h6" />'),rowDelete:T('<path d="M16 5H3" /><path d="M11 12H3" /><path d="M16 19H3" /><path d="m15.5 9.5 5 5" /><path d="m20.5 9.5-5 5" />'),colBefore:T('<path d="M12 3v18" /><path d="M3 5.536V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-.535" /><path d="M5 15V9" /><path d="M8 12H2" />'),colAfter:T('<path d="M12 3v18" /><path d="M16 12h6" /><path d="M19 15V9" /><path d="M21 5.536V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-.535" />'),colDelete:T('<g transform="rotate(90 12 12)"><path d="M16 5H3" /><path d="M11 12H3" /><path d="M16 19H3" /><path d="m15.5 9.5 5 5" /><path d="m20.5 9.5-5 5" /></g>'),merge:T('<path d="M12 21v-6" /><path d="M12 9V3" /><path d="M3 15h18" /><path d="M3 9h18" /><rect width="18" height="18" x="3" y="3" rx="2" />'),split:T('<path d="M12 15V9" /><path d="M3 15h18" /><path d="M3 9h18" /><rect width="18" height="18" x="3" y="3" rx="2" />'),rowHeader:T('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" />'),colHeader:T('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M9 3v18" />'),sort:T('<path d="m3 16 4 4 4-4" /><path d="M7 20V4" /><path d="M11 4h10" /><path d="M11 8h7" /><path d="M11 12h4" />'),tableProps:T('<path d="M15 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M21 9H3" /><path d="M21 15H3" />'),cellProps:T('<path d="M10.6 21H5a2 2 0 01-2-2V5a2 2 0 012-2h14a2 2 0 012 2v5.6" /><path d="m14.305 19.53.923-.382" /><path d="M15 3v7.6" /><path d="m15.229 16.852-.924-.383" /><path d="m16.852 15.228-.383-.923" /><path d="m16.852 20.772-.383.924" /><path d="m19.148 15.228.383-.923" /><path d="m19.53 21.696-.382-.924" /><path d="m20.773 16.852.922-.383" /><path d="m20.773 19.148.922.383" /><path d="M9 3v18" /><circle cx="18" cy="18" r="3" />'),tableDelete:T('<path d="M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3" /><path d="m16.5 16.5 5 5" /><path d="m16.5 21.5 5-5" />'),chevronUp:T('<path d="m18 15-6-6-6 6" />'),search:T('<path d="m21 21-4.34-4.34" /><circle cx="11" cy="11" r="8" />'),fullscreen:T('<path d="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" />'),fullscreenExit:T('<path d="M8 3v3a2 2 0 0 1-2 2H3" /><path d="M21 8h-3a2 2 0 0 1-2-2V3" /><path d="M3 16h3a2 2 0 0 1 2 2v3" /><path d="M16 21v-3a2 2 0 0 1 2-2h3" />'),preview:T('<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" /><circle cx="12" cy="12" r="3" />'),sourceCode:T('<path d="m18 16 4-4-4-4" /><path d="m6 8-4 4 4 4" /><path d="m14.5 4-5 16" />'),help:T('<circle cx="12" cy="12" r="10" /><path d="M9 9.5a3 2.5 0 016 0c0 2-2 2-3 3.5" /><path d="M12 17h.01" />'),print:T('<path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2" /><path d="M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6" /><rect x="6" y="14" width="12" height="8" rx="1" />'),check:T('<path d="M20 6 9 17l-5-5" />'),close:T('<path d="M18 6 6 18" /><path d="m6 6 12 12" />'),chevronDown:T('<path d="m6 9 6 6 6-6" />'),more:T('<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />'),textColor:T('<path d="M4 20h16" /><path d="m6 16 6-12 6 12" /><path d="M8 12h8" />'),highlight:T('<path d="m9 11-6 6v3h9l3-3" /><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4" />'),lineHeight:T('<path d="M15 14H9" /><path d="M21 21H3" /><path d="M21 3H3" /><path d="m8 16 3.453-7.648a.6.6 0 011.094.001L16 16" />'),upload:T('<path d="M12 3v12" /><path d="m17 8-5-5-5 5" /><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />'),externalLink:T('<path d="M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6" /><path d="m21 3-9 9" /><path d="M15 3h6v6" />'),copy:T('<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />'),edit:T('<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" /><path d="m15 5 4 4" />'),resizeHandle:T('<circle cx="12" cy="9" r="1" /><circle cx="19" cy="9" r="1" /><circle cx="5" cy="9" r="1" /><circle cx="12" cy="15" r="1" /><circle cx="19" cy="15" r="1" /><circle cx="5" cy="15" r="1" />'),browse:T('<path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2" />'),mergeTags:T('<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1" /><path d="M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1" />'),resizeHandleBoth:T('<path d="M19 13v6h-6" /><path d="M5 11V5h6" /><path d="m5 5 14 14" />'),sidebar:T('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M15 3v18" />'),anchor:T('<path d="M12 6v16" /><path d="m19 13 2-1a9 9 0 0 1-18 0l2 1" /><path d="M9 11h6" /><circle cx="12" cy="4" r="2" />'),save:T('<path d="M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z" /><path d="M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7" /><path d="M7 3v4a1 1 0 0 0 1 1h7" />'),charmap:T('<path d="M3 20h4.5a.5.5 0 0 0 .5-.5v-.282a.52.52 0 0 0-.247-.437 8 8 0 1 1 8.494-.001.52.52 0 0 0-.247.438v.282a.5.5 0 0 0 .5.5H21" />'),commentAdd:T('<path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z" /><path d="M12 8v6" /><path d="M9 11h6" />'),comments:T('<path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z" /><path d="M7 11h10" /><path d="M7 15h6" /><path d="M7 7h8" />'),emoji:T('<path d="M15 10V9" /><path d="M16.472 15a6 6 0 01-8.943 0" /><path d="M9 10V9" /><circle cx="12" cy="12" r="10" />'),dateTime:T('<path d="M16 2v3" /><path d="M17 15.5v1.7l1 .625" /><path d="M21 8.936V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h3.935" /><path d="M3 9h9.873" /><path d="M8 2v3" /><circle cx="17" cy="17" r="5" />'),media:T('<rect x="3" y="3" width="18" height="18" rx="2" /><path d="M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z" />'),checklist:T('<path d="M13 5h8" /><path d="M13 12h8" /><path d="M13 19h8" /><path d="m3 17 2 2 4-4" /><rect x="3" y="4" width="6" height="6" rx="1" />'),codeSample:T('<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /><path d="M10 12.5 8 15l2 2.5" /><path d="m14 12.5 2 2.5-2 2.5" />'),dragHandle:T('<circle cx="9" cy="12" r="1" /><circle cx="9" cy="5" r="1" /><circle cx="9" cy="19" r="1" /><circle cx="15" cy="12" r="1" /><circle cx="15" cy="5" r="1" /><circle cx="15" cy="19" r="1" />'),accordion:T('<path d="M10 5h11" /><path d="M10 12h11" /><path d="M10 19h11" /><path d="m3 10 3-3-3-3" /><path d="m3 20 3-3-3-3" />'),tableOfContents:T('<path d="M16 5H3" /><path d="M16 12H3" /><path d="M16 19H3" /><path d="M21 5h.01" /><path d="M21 12h.01" /><path d="M21 19h.01" />'),math:T('<path d="M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2" />'),duplicate:T('<line x1="15" x2="15" y1="12" y2="18" /><line x1="12" x2="18" y1="15" y2="15" /><rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />'),nonBreaking:T('<path d="M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1" />'),pageBreak:T('<path d="M5.42 9.42 8 12" /><circle cx="4" cy="8" r="2" /><path d="m14 6-8.58 8.58" /><circle cx="4" cy="16" r="2" /><path d="M10.8 14.8 14 18" /><path d="M16 12h-2" /><path d="M22 12h-2" />'),history:T('<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /><path d="M12 7v5l4 2" />'),suggest:T('<path d="M13 21h8" /><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" />'),review:T('<path d="M13 5h8" /><path d="M13 12h8" /><path d="M13 19h8" /><path d="m3 17 2 2 4-4" /><path d="m3 7 2 2 4-4" />'),visualBlocks:T('<path d="M5 3a2 2 0 0 0-2 2" /><path d="M19 3a2 2 0 0 1 2 2" /><path d="M21 19a2 2 0 0 1-2 2" /><path d="M5 21a2 2 0 0 1-2-2" /><path d="M9 3h1" /><path d="M9 21h1" /><path d="M14 3h1" /><path d="M14 21h1" /><path d="M3 9v1" /><path d="M21 9v1" /><path d="M3 14v1" /><path d="M21 14v1" />'),ltr:T('<path d="M10 3v11" /><path d="M10 9H7a1 1 0 0 1 0-6h8" /><path d="M14 3v11" /><path d="m18 14 4 4H2" /><path d="m22 18-4 4" />'),rtl:T('<path d="M14 3v11" /><path d="M14 9h-3a3 3 0 0 1 0-6h9" /><path d="M18 3v11" /><path d="M22 18H2l4-4" /><path d="m6 22-4-4" />'),caseChange:T('<path d="m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16" /><path d="M22 9v7" /><path d="M3.304 13h6.392" /><circle cx="18.5" cy="12.5" r="3.5" />'),formatPainter:T('<path d="m14.622 17.897-10.68-2.913" /><path d="M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z" /><path d="M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15" />'),permanentPen:T('<path d="m9 11-6 6v3h9l3-3" /><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4" />'),visualChars:T('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M12 12H9.5a2.5 2.5 0 0 1 0-5H17" /><path d="M12 7v10" /><path d="M16 7v10" />'),cancelChanges:T('<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" />'),template:T('<rect width="18" height="7" x="3" y="3" rx="1" /><rect width="9" height="7" x="3" y="14" rx="1" /><rect width="5" height="7" x="16" y="14" rx="1" />'),footnote:T('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M12 8v8" /><path d="m8.5 14 7-4" /><path d="m8.5 10 7 4" />'),footnotesUpdate:T('<path d="M21 5H3" /><path d="M7 12H3" /><path d="M7 19H3" /><path d="M12 18a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L11 14" /><path d="M11 10v4h4" />')};var bp='.nova-details{position:relative;margin:0 0 .75em;padding-block:6px;padding-inline:34px 12px;border:1px solid var(--nova-border);border-radius:var(--nova-radius-sm)}.nova-details-toggle{position:absolute;top:7px;inset-inline-start:6px;display:flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:0;border-radius:4px;background:none;color:var(--nova-muted);cursor:pointer}.nova-details-toggle:hover{background:var(--nova-hover);color:var(--nova-fg)}.nova-details-toggle:focus-visible{outline:2px solid var(--nova-accent);outline-offset:1px}.nova-details-toggle svg{width:16px;height:16px;transition:transform .12s ease}.nova-details:not(.nova-details-open)>.nova-details-toggle svg{transform:rotate(-90deg)}[dir=rtl] .nova-details:not(.nova-details-open)>.nova-details-toggle svg{transform:rotate(90deg)}.nova-details-content>summary{position:relative;display:block;margin:0;font-weight:600;cursor:text;list-style:none}.nova-details-content>summary::-webkit-details-marker{display:none}.nova-details-content>summary:has(>br.ProseMirror-trailingBreak:only-child):before{content:var(--nova-summary-placeholder, "");position:absolute;color:var(--nova-muted);font-weight:400;pointer-events:none}.nova-details-open>.nova-details-content>summary{margin-bottom:.4em}.nova-details:not(.nova-details-open)>.nova-details-content>:not(summary){display:none}.nova-details-content>:last-child{margin-bottom:0}.nova-details.ProseMirror-selectednode{outline:2px solid var(--nova-accent);outline-offset:2px}@media(prefers-reduced-motion:reduce){.nova-details-toggle svg{transition:none}}';var ol={};j(ol,{insertText:()=>vb,openSymbolDialog:()=>wb,pickLabels:()=>Oe,symbolPanel:()=>xb});var dn={"toolbar.label":"Formatting","toolbar.options":"options","editor.label":"Rich text editor","editor.required":"Please fill in this field.",undo:"Undo",redo:"Redo",bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strikethrough",code:"Inline code",subscript:"Subscript",superscript:"Superscript",link:"Link",unlink:"Remove link",image:"Image",bulletList:"Bulleted list",orderedList:"Numbered list",indent:"Increase indent",outdent:"Decrease indent",align:"Alignment",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",alignJustify:"Justify",blockquote:"Quote",codeBlock:"Code block",moveBlockUp:"Move block up",moveBlockDown:"Move block down",horizontalRule:"Horizontal line",clearFormatting:"Clear formatting",more:"More",moreFormats:"More formatting",blocks:"Text style",styles:"Formats","styles.headings":"Headings","styles.inline":"Inline","styles.blocks":"Blocks","styles.align":"Align",paragraph:"Paragraph",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",fontFamily:"Font",fontSize:"Font size",lineHeight:"Line height",default:"Default",textColor:"Text color",backgroundColor:"Highlight color",removeColor:"Remove color",customColor:"Custom color","dialog.cancel":"Cancel","dialog.save":"Save","dialog.insert":"Insert","dialog.close":"Close","dialog.required":"This field is required","dialog.invalid":"Check the format","link.title":"Insert link","link.editTitle":"Edit link","link.url":"URL","link.text":"Text to display","link.tooltip":"Title (tooltip)","link.newTab":"Open in new tab","link.open":"Open link","link.edit":"Edit link","link.copy":"Copy link","link.copied":"Link copied","link.invalid":"This URL is not allowed","image.title":"Insert image","image.url":"Image URL","image.alt":"Alternative text","image.altHint":"Describe the image for people using screen readers","image.upload":"Upload","image.drop":"Drop an image here or click to choose","image.uploading":"Uploading image\u2026","image.uploadFailed":"Image upload failed","image.retry":"Retry","image.retrying":"Connection problem \u2014 retrying the upload\u2026","image.invalid":"This image URL is not allowed","image.or":"or","image.toolbar":"Image options","image.alignLeft":"Float left","image.alignCenter":"Center","image.alignRight":"Float right","image.editAlt":"Alternative text","image.size":"Size","image.sizeSmall":"Small (25%)","image.sizeMedium":"Medium (50%)","image.sizeLarge":"Large (75%)","image.sizeFull":"Full width","image.sizeOriginal":"Original size","image.delete":"Remove image","image.caption":"Caption","image.captionPlaceholder":"Add a caption\u2026","status.words":"{count} words","announce.on":"{name} on","announce.off":"{name} off","status.resize":"Resize editor","dialog.browse":"Browse","dialog.dropFiles":"Drop files here or","dialog.fileType":"This file type is not allowed","dialog.fileTooLarge":"The file is too large","dialog.removeFile":"Remove",pasteAsText:"Paste as text","menu.label":"Menu","menu.file":"File","menu.edit":"Edit","menu.view":"View","menu.insert":"Insert","menu.format":"Format","menu.table":"Table","menu.tools":"Tools","menu.help":"Help",selectAll:"Select all",print:"Print","table.rows":"Rows","table.cols":"Columns","table.invalidSize":"Enter a number from 1 to 50","quickbars.selection":"Quick formatting","quickbars.insert":"Quick insert","search.title":"Find and replace","search.find":"Find","search.replace":"Replace with","search.next":"Next match","search.prev":"Previous match","search.replaceOne":"Replace","search.replaceAll":"Replace all","search.matchCase":"Match case","search.wholeWord":"Whole words only","search.count":"{current} of {total}","search.none":"No results",fullscreen:"Fullscreen",preview:"Preview",sourceCode:"Source code",help:"Keyboard shortcuts","help.formatting":"Text formatting","help.blocks":"Paragraphs and lists","help.editing":"Editing","help.navigation":"Navigation","help.slash":"Insert block (slash commands)","help.toMenubar":"Move to the menu bar","help.toToolbar":"Move to the toolbar","help.toContextToolbar":"Move to the image/table toolbar","help.toEditor":"Back to the text","help.nextCell":"Next table cell",table:"Table","table.insert":"Insert table","table.size":"{rows} \xD7 {cols}","table.toolbar":"Table options","table.rowBefore":"Insert row above","table.rowAfter":"Insert row below","table.rowDelete":"Delete row","table.colBefore":"Insert column left","table.colAfter":"Insert column right","table.colDelete":"Delete column","table.merge":"Merge cells","table.split":"Split cell","table.rowHeader":"Header row","table.colHeader":"Header column","table.cellBackground":"Cell background","table.delete":"Delete table","table.sort":"Sort","table.sortAsc":"Sort A \u2192 Z, 1 \u2192 9","table.sortDesc":"Sort Z \u2192 A, 9 \u2192 1","table.props":"Table properties","table.style":"Style","table.styleDefault":"Default","table.width":"Width","table.widthHint":"For example 100% or 600px. Leave empty to fit the content.","table.invalidWidth":"Enter a width such as 100% or 600px","table.align":"Alignment on the page","table.alignDefault":"Default","table.alignCenter":"Center","table.alignRight":"Right","table.cellProps":"Cell properties","table.valign":"Vertical alignment","table.valignTop":"Top","table.valignMiddle":"Middle","table.valignBottom":"Bottom","table.cellType":"Cell type","table.cellData":"Data cell","table.cellHeader":"Header cell","table.colWidth":"Column width, px","table.colWidthHint":"Leave empty to fit the content.","table.invalidColWidth":"Enter a number from 24 to 4000","slash.label":"Commands","slash.empty":"No matching commands"};var Fn={},Or={en:dn},kp=new Set,Ho={};function kb(n){let e={};for(let[t,r]of Object.entries(n))typeof r=="string"?e[t]=r:r.forEach((o,i)=>e[`${t}.${i}`]=o);return e}var zn={},Io={};function xp(n,e,t=!1){Fn[n]=t?{...e,...Fn[n]}:{...Fn[n],...e},Or[n]={...dn,...Fn[n]}}function $t(n,e){let t=n.toLowerCase();typeof e=="function"?zn[t]=e:xp(t,e)}function wp(n){let e=n.toLowerCase();return e in Or||e.split("-")[0]in Or}function rl(n){let e=n.toLowerCase(),t=e.split("-")[0],r=e in zn?e:t in zn?t:null;return r?Io[r]??(Io[r]=zn[r]().then(o=>(xp(r,o.default??o,!0),!0),o=>{throw Io[r]=void 0,o})):Promise.resolve(wp(e))}function Sp(n,e){let t=Ho[n]??(Ho[n]={});for(let[r,o]of Object.entries(e))o&&(t[r]={...t[r],...kb(o)})}var vp=(n,e)=>e?n.replace(/\{(\w+)\}/g,(t,r)=>String(e[r]??`{${r}}`)):n;function Mp(n="en",e={}){let t=n.toLowerCase(),r=t.split("-")[0],o=Or[t]??Or[r]??dn;o===dn&&r!=="en"&&!kp.has(r)&&(kp.add(r),console.warn(t in zn||r in zn?`[nova] language "${n}" is not loaded yet, using English. Load it before creating the editor: await loadLanguage('${n}');`:`[nova] language "${n}" is not registered, using English. import pack from '@novaprose/core/i18n/${r}'; registerLanguage('${r}', pack);`));let i={...dn,...o,...e},s={...Fn[r],...Fn[t]},l=e;return(a,c)=>{let d=i[a];if(d!==void 0)return vp(d,c);let u=a.indexOf("."),p=u>0?Ho[a.slice(0,u)]:void 0,f=a.slice(u+1),h=l[a]??s[a]??p?.[t]?.[f]??p?.[r]?.[f]??p?.en?.[f]??a;return vp(h,c)}}function Oe(n,e,t){Sp(e,t);let r={};for(let[o,i]of Object.entries(t.en))r[o]=typeof i=="string"?n.ui.t(`${e}.${o}`):i.map((s,l)=>n.ui.t(`${e}.${o}.${l}`));return r}function vb(n,e){let{state:t,dispatch:r}=n.view;r(t.tr.insertText(e).scrollIntoView()),n.focus()}function xb(n){let e=w("input",{type:"search",className:"nova-input nova-symbols-search",placeholder:n.searchLabel,"aria-label":n.searchLabel}),t=w("div",{className:"nova-symbols-list"}),r=w("div",{className:`nova-symbols ${n.className}`},e,t),o=i=>{let s=i.trim().toLowerCase(),l=n.groups.map(a=>({title:a.title,items:s?a.items.filter(([c,d])=>d.includes(s)||c===s):a.items})).filter(a=>a.items.length);if(!l.length){t.replaceChildren(w("div",{className:"nova-symbols-empty"},n.emptyText));return}t.replaceChildren(...l.map(a=>w("div",{className:"nova-symbols-group",role:"group","aria-label":a.title},w("div",{className:"nova-symbols-title"},a.title),w("div",{className:"nova-symbols-grid"},...a.items.map(([c,d])=>w("button",{type:"button",className:"nova-symbols-cell",title:d,"aria-label":d,onclick:()=>n.onPick(c)},c))))))};return e.addEventListener("input",()=>o(e.value)),e.addEventListener("keydown",i=>{i.key==="ArrowDown"?(i.preventDefault(),t.querySelector(".nova-symbols-cell")?.focus()):i.key==="Enter"&&(i.preventDefault(),t.querySelector(".nova-symbols-cell")?.click())}),t.addEventListener("keydown",i=>{let s=[...t.querySelectorAll(".nova-symbols-cell")],l=s.indexOf(te(t));if(l<0)return;let a=Math.max(1,s.filter(p=>p.offsetTop===s[0].offsetTop).length),c={ArrowRight:1,ArrowLeft:-1,ArrowDown:a,ArrowUp:-a},d=Ne(i,t);if(!(d in c))return;i.preventDefault();let u=l+c[d];u<0?e.focus():s[Math.min(s.length-1,u)]?.focus()}),o(""),queueMicrotask(()=>e.focus()),r}function wb(n,e,t){let r=null,o=t(()=>r?.close());r=n.ui.openDialog({title:e,body:o,cancelLabel:n.ui.t("dialog.close")})}var il={en:{accordion:"Accordion",summary:"Summary",expand:"Expand",collapse:"Collapse"}};function Sb(n){let e=n.options.pluginOptions?.accordion??{},t=e.initialState??"inherited",r=e.serializedState??"inherited";return{details:{group:"block",content:"details_summary block+",defining:!0,attrs:{open:{default:!0}},parseDOM:[{tag:"details",getAttrs:o=>({open:t==="inherited"?o.hasAttribute("open"):t==="expanded"})}],toDOM:o=>["details",(r==="inherited"?o.attrs.open!==!1:r==="expanded")?{open:""}:{},0]},details_summary:{content:"inline*",defining:!0,isolating:!0,parseDOM:[{tag:"summary",context:"details/"}],toDOM:()=>["summary",0]}}}function Mb(n){for(let e=n.depth;e>0;e--){let t=n.node(e);if(t.type.name==="details")return{node:t,pos:n.before(e)}}return null}var sl=n=>n.attrs.open!==!1,ll=n=>n.pos+2+n.node.firstChild.content.size;function Ep(n,e,t){return n.setNodeAttribute(e.pos,"open",t).setMeta("addToHistory",!1)}var al=class{constructor(e,t,r,o){S(this,"node",e);S(this,"labels",o);S(this,"dom");S(this,"contentDOM");S(this,"toggle");this.toggle=w("button",{type:"button",className:"nova-details-toggle",contentEditable:"false",tabIndex:-1}),this.toggle.append(ee(C.chevronDown)),this.toggle.addEventListener("mousedown",i=>i.preventDefault()),this.toggle.addEventListener("click",()=>{let i=r();if(i===void 0)return;let s=t.state.doc.nodeAt(i);if(s?.type.name!=="details")return;let l={node:s,pos:i},a=sl(s),c=Ep(t.state.tr,l,!a),{from:d}=t.state.selection;a&&d>ll(l)&&d<i+s.nodeSize&&c.setSelection(F.create(c.doc,ll(l))),t.dispatch(c)}),this.contentDOM=w("div",{className:"nova-details-content"}),this.dom=w("div",{className:"nova-details"},this.toggle,this.contentDOM),this.sync()}sync(){let e=sl(this.node);this.dom.classList.toggle("nova-details-open",e),this.toggle.setAttribute("aria-expanded",String(e)),this.toggle.setAttribute("aria-label",e?this.labels.collapse:this.labels.expand)}update(e){return e.type!==this.node.type?!1:(this.node=e,this.sync(),!0)}stopEvent(e){return e.target instanceof Node&&this.toggle.contains(e.target)}ignoreMutation(e){return e.type!=="selection"&&!this.contentDOM.contains(e.target)}},cl={name:"accordion",nodes:Sb,prosemirrorPlugins:n=>{let e=Oe(n,"accordion",il);return[new z({key:new Z("nova-accordion"),props:{nodeViews:{details:(t,r,o)=>new al(t,r,o,e)}}})]},setup(n){n.ui.addStyles("nova-accordion",bp);let{summary:e}=Oe(n,"accordion",il);n.root.style.setProperty("--nova-summary-placeholder",JSON.stringify(e))},load:()=>import(__novaChunk("tinymce-chunks/accordion-ui-4272c63b.js") )};var ul={};j(ul,{ELEMENT_ID_RE:()=>Bo,elementId:()=>$n});var Bo=/^[A-Za-z][\w.-]{0,63}$/;function $n(n){return typeof n=="string"&&Bo.test(n)?n:null}var pl=Bo,Cp={name:"anchor",toolbar:"anchor",nodes:{anchor:{group:"inline",inline:!0,atom:!0,selectable:!0,attrs:{id:{}},parseDOM:[{tag:"a[id]:not([href])",getAttrs:n=>{let e=n.getAttribute("id")??"";return pl.test(e)?{id:e}:!1}},{tag:"a[name]:not([href])",getAttrs:n=>{let e=n.getAttribute("name")??"";return pl.test(e)?{id:e}:!1}}],toDOM:n=>["a",{id:pl.test(n.attrs.id)?n.attrs.id:null}]}},load:()=>import(__novaChunk("tinymce-chunks/anchor-ui-da0966bb.js") )};var hl={};j(hl,{LABELS:()=>Np,default:()=>fl,loadTemml:()=>Op,mathLatex:()=>Vn,renderMath:()=>Lp});var Ap='.nova-math{border-radius:4px;cursor:pointer}.nova-math-inline{display:inline-block;padding:0 2px}.nova-math-block{display:block;margin:0 0 .75em;padding:6px 8px;overflow-x:auto;text-align:center}.nova-math:hover{background:var(--nova-hover)}.nova-math.is-selected{outline:2px solid var(--nova-accent)}.nova-math:not(:has(math)){font-family:var(--nova-mono);font-size:.9em}.nova-math-error{color:var(--nova-danger);text-decoration:underline wavy;text-underline-offset:3px}.nova-math-empty:before{content:var(--nova-math-empty, "");color:var(--nova-muted);font-family:var(--nova-font)}.nova-math-preview{min-height:2.5em;padding:8px;overflow-x:auto;border:1px dashed var(--nova-border);border-radius:var(--nova-radius-sm);text-align:center}';var Np={en:{empty:"Formula"}};function Vn(n){return typeof n=="string"?n.slice(0,1e4):""}var Fo=null;function Op(){return Fo??(Fo=import(__novaChunk("tinymce-chunks/temml-d637f801.js") ).then(n=>n.default,n=>(Fo=null,console.warn("[nova] math: could not load the formula renderer",n),null))),Fo}function Lp(n,e,t,r){try{return n.render(e,t,{displayMode:r,throwOnError:!0,trust:!1,annotate:!0}),null}catch(o){return t.textContent=e,o instanceof Error?o.message.replace(/^ParseError:\s*/,""):String(o)}}function Tp(n){let e=n?"block-math":"inline-math",t=n?"div":"span";return{...n?{group:"block"}:{group:"inline",inline:!0},atom:!0,selectable:!0,draggable:!0,attrs:{latex:{default:""}},parseDOM:[{tag:`${t}[data-type="${e}"]`,getAttrs:r=>({latex:Vn(r.getAttribute("data-latex"))})}],toDOM:r=>{let o=Vn(r.attrs.latex);return[t,{"data-type":e,"data-latex":o},n?`\\[${o}\\]`:`\\(${o}\\)`]},leafText:r=>n?`$$${Vn(r.attrs.latex)}$$`:`$${Vn(r.attrs.latex)}$`}}var zo=class{constructor(e,t,r,o){S(this,"node",e);S(this,"view",t);S(this,"getPos",r);S(this,"editor",o);S(this,"dom");S(this,"latex","");let i=e.type.name==="math_block";this.dom=document.createElement(i?"div":"span"),this.dom.className=`nova-math ${i?"nova-math-block":"nova-math-inline"}`,this.dom.contentEditable="false",this.dom.addEventListener("click",()=>this.edit()),this.render()}render(){let e=Vn(this.node.attrs.latex);if(e===this.latex&&this.dom.childNodes.length)return;this.latex=e;let t=this.node.type.name==="math_block";this.dom.classList.toggle("nova-math-empty",!e.trim()),this.dom.textContent=e.trim()?e:"",e.trim()&&Op().then(r=>{if(!r||this.latex!==e)return;let o=Lp(r,e,this.dom,t);this.dom.classList.toggle("nova-math-error",!!o),o?this.dom.title=o:this.dom.removeAttribute("title")})}edit(){let e=this.getPos();if(e===void 0||!this.editor.isEditable())return;this.view.dispatch(this.view.state.tr.setSelection(R.create(this.view.state.doc,e)));let t=this.editor.ui.registry.get("math");t?.type==="button"&&t.onAction(this.editor)}update(e){return e.type!==this.node.type?!1:(this.node=e,this.render(),!0)}selectNode(){this.dom.classList.add("is-selected")}deselectNode(){this.dom.classList.remove("is-selected")}ignoreMutation(){return!0}},fl={name:"math",nodes:{math_inline:Tp(!1),math_block:Tp(!0)},prosemirrorPlugins:n=>[new z({key:new Z("nova-math"),props:{nodeViews:{math_inline:(e,t,r)=>new zo(e,t,r,n),math_block:(e,t,r)=>new zo(e,t,r,n)}}})],setup(n){n.ui.addStyles("nova-math",Ap);let{empty:e}=Oe(n,"math",Np);n.root.style.setProperty("--nova-math-empty",JSON.stringify(e))},load:()=>import(__novaChunk("tinymce-chunks/math-ui-1b57f7eb.js") )};var yl={};j(yl,{LABELS:()=>Rp,default:()=>gl,tocEntries:()=>ml,tocSettings:()=>Dp});var Pp='.nova-prosemirror nav[data-toc]{margin:0 0 .75em;padding:10px 14px;border-inline-start:3px solid var(--nova-accent);border-radius:var(--nova-radius-sm);background:var(--nova-code-bg)}.nova-prosemirror nav[data-toc]>:is(p,h1,h2,h3,h4,h5,h6):first-child{margin:0 0 6px;font-size:1em;font-weight:600}.nova-prosemirror nav[data-toc] :is(ul,ol){margin:0;padding-inline-start:1.2em}.nova-prosemirror nav[data-toc]>:is(ul,ol){padding-inline-start:0}.nova-prosemirror nav[data-toc] ul{list-style:none}.nova-prosemirror nav[data-toc] li{margin:2px 0}.nova-prosemirror nav[data-toc] a{color:var(--nova-accent);text-decoration:none;cursor:pointer}.nova-prosemirror nav[data-toc] a:hover{text-decoration:underline}.nova-prosemirror nav[data-toc]:not(:has(a)):after{content:var(--nova-toc-empty, "");color:var(--nova-muted)}.nova-prosemirror nav[data-toc].ProseMirror-selectednode{outline:2px solid var(--nova-accent);outline-offset:2px}';var Rp={en:{title:"Contents",insert:"Table of contents",update:"Update table of contents",empty:"Add headings \u2014 they will appear here"}},Ab=/^[A-Za-z_][\w-]{0,63}$/;function Dp(n){let e=n.options.pluginOptions?.tableofcontents??{},t=Number(e.depth);return{depth:Number.isInteger(t)&&t>=1&&t<=6?t:3,className:typeof e.className=="string"&&Ab.test(e.className)?e.className:"nova-toc",titleTag:typeof e.titleTag=="string"&&/^(p|h[1-6])$/i.test(e.titleTag)?e.titleTag.toLowerCase():"p",title:typeof e.title=="string"?e.title.slice(0,200):null,list:e.orderedList?"ol":"ul"}}function ml(n){if(!Array.isArray(n))return[];let e=[];for(let t of n.slice(0,1e3)){if(!t||typeof t!="object")continue;let{level:r,id:o,text:i}=t,s=Number(r),l=$n(o);!Number.isInteger(s)||s<1||s>6||!l||typeof i!="string"||e.push({level:s,id:l,text:i.slice(0,300)})}return e}function Tb(n,e){if(!n.length)return null;let t=[e],r=[{level:n[0].level,list:t,last:null}];for(let o of n){let i=r[r.length-1];if(o.level>i.level&&i.last){let l=[e];i.last.push(l),r.push({level:o.level,list:l,last:null})}else for(;r.length>1&&o.level<r[r.length-1].level;)r.pop();i=r[r.length-1];let s=["li",["a",{href:`#${o.id}`},o.text]];i.list.push(s),i.last=s}return t}function Nb(n){let e=[];for(let t of n.querySelectorAll('a[href^="#"]')){let r=0;for(let o=t;o&&o!==n;o=o.parentElement)(o.tagName==="UL"||o.tagName==="OL")&&r++;e.push({level:Math.min(Math.max(r,1),6),id:t.getAttribute("href").slice(1),text:(t.textContent??"").trim()})}return ml(e)}function Ob(n){let e=Dp(n);return{toc:{group:"block",atom:!0,selectable:!0,attrs:{entries:{default:[]},title:{default:null}},parseDOM:[...["nav[data-toc]","div.mce-toc",`.${e.className}`].map(t=>({tag:t,getAttrs:r=>{let o=r.querySelector(":scope > h1, :scope > h2, :scope > h3, :scope > h4, :scope > h5, :scope > h6, :scope > p");return{entries:Nb(r),title:o?.textContent?.trim()||null}}}))],toDOM:t=>{let r=typeof t.attrs.title=="string"?t.attrs.title.slice(0,200):"",o=Tb(ml(t.attrs.entries),e.list);return["nav",{class:e.className,"data-toc":""},...r?[[e.titleTag,r]]:[],...o?[o]:[]]}}}}var gl={name:"tableofcontents",nodes:Ob,setup(n){n.ui.addStyles("nova-tableofcontents",Pp);let{empty:e}=Oe(n,"tableofcontents",Rp);n.root.style.setProperty("--nova-toc-empty",JSON.stringify(e))},load:()=>import(__novaChunk("tinymce-chunks/tableofcontents-ui-01a9af06.js") )};var la={};j(la,{LABELS:()=>Qf,commentsKey:()=>pt,default:()=>sa,getComments:()=>li});var Kl={};j(Kl,{Decoration:()=>ge,DecorationSet:()=>ae,EditorView:()=>Xn,__endComposition:()=>nv,__parseFromClipboard:()=>tv});var Le=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e};function Kn(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e}var wl=null;function Tt(n,e,t){let r=wl||(wl=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r}function Lb(){wl=null}function $o(n,e,t,r){return t&&(Ip(n,e,t,r,-1)||Ip(n,e,t,r,1))}var _p=/^(img|br|input|textarea|hr)$/i;function Ip(n,e,t,r,o){for(var i;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Me(n))){let s=n.parentNode;if(!s||!W(s)||Vo(n)||_p.test(n.nodeName)||n.contentEditable=="false")return!1;e=Le(n)+(o<0?0:1),n=s}else if(W(n)){let s=n.childNodes[e+(o<0?-1:0)];if(W(s)&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=o;else return!1;else{if(Vo(s)||_p.test(s.nodeName))return!1;n=s,e=o<0?Me(n):0}}else return!1}}function Me(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function W(n){return n.nodeType==1}function ke(n){return n.nodeType==3}function Un(n,e){return e?n.contains(W(e)?e:e.parentNode):!1}function mf(n,e){for(;;){if(ke(n)&&e)return n;if(W(n)&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Me(n)}else if(n.parentNode&&!Vo(n,!0))e=Le(n),n=n.parentNode;else return null}}function gf(n,e){for(;;){if(ke(n)&&e<n.nodeValue.length)return n;if(W(n)&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Vo(n,!0))e=Le(n)+1,n=n.parentNode;else return null}}function Pb(n,e,t){for(let r=e==0,o=e==Me(n);r||o;){if(n==t)return!0;let i=Le(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,o=o&&i==Me(n)}}function Vo(n,e=!1){let t;for(let r=n;r&&!(t=r.pmViewDesc);r=r.parentNode);return t&&t.node&&(!e||t.node.isBlock)&&(t.dom==n||t.contentDOM==n)}function Xo(n){return n.focusNode&&$o(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)}function yf(n,e){n.collapse(e.anchorNode,e.anchorOffset),(e.focusNode!=e.anchorNode||e.focusOffset!=e.anchorOffset)&&n.extend(e.focusNode,e.focusOffset)}function Rb(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Db(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function _b(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Me(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Me(r.startContainer),r.startOffset)}}}var dt=typeof navigator<"u"?navigator:null,Hp=typeof document<"u"?document:null,Jn=dt&&dt.userAgent||"",Ge=/gecko\/(\d+)/i.test(Jn)&&!/edge?\//i.test(Jn);Ge&&+(/Firefox\/(\d+)/.exec(Jn)||[0,0])[1];var Sl=/Chrome\/(\d+)/.exec(Jn),Pe=!!Sl,bf=Sl?+Sl[1]:0,Re=!!dt&&/Apple Computer/.test(dt.vendor),Gn=Re&&(/Mobile\/\w+/.test(Jn)||!!dt&&dt.maxTouchPoints>2),je=Gn||(dt?/Mac/.test(dt.platform):!1),kf=dt?/Win/.test(dt.platform):!1,Nt=/Android \d/.test(Jn),Zo=!!Hp&&"webkitFontSmoothing"in Hp.documentElement.style,Ib=Zo?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Hb(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function At(n,e){return typeof n=="number"?n:n[e]}function Bb(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Bp(n,e,t){if(!Ml(e)&&e.left==0)return;let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(!W(s)){s=Kn(s);continue}let l=s==i.body,a=l?Hb(i):Bb(s),c=0,d=0;if(e.top<a.top+At(r,"top")?d=-(a.top-e.top+At(o,"top")):e.bottom>a.bottom-At(r,"bottom")&&(d=e.bottom-e.top>a.bottom-a.top?e.top+At(o,"top")-a.top:e.bottom-a.bottom+At(o,"bottom")),e.left<a.left+At(r,"left")?c=-(a.left-e.left+At(o,"left")):e.right>a.right-At(r,"right")&&(c=e.right-a.right+At(o,"right")),c||d)if(l)i.defaultView.scrollBy(c,d);else{let p=s.scrollLeft,f=s.scrollTop;d&&(s.scrollTop+=d),c&&(s.scrollLeft+=c);let h=s.scrollLeft-p,m=s.scrollTop-f;e={left:e.left-h,top:e.top-m,right:e.right-h,bottom:e.bottom-m}}let u=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(u))break;s=u=="absolute"?s.offsetParent:Kn(s)}}function Fb(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=n.root.elementFromPoint(i,s);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:vf(n.dom)}}function vf(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Kn(r));return e}function zb({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;xf(t,r==0?0:r-e)}function xf(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:o,left:i}=n[t];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}var qn=null;function wf(n){if(n.setActive)return n.setActive();if(qn)return n.focus(qn);let e=vf(n);n.focus(qn==null?{get preventScroll(){return qn={preventScroll:!0},!0}}:void 0),qn||(qn=!1,xf(e,0))}function Sf(n,e){let t,r=2e8,o,i=0,s=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let p;if(W(d))p=d.getClientRects();else if(ke(d))p=Tt(d).getClientRects();else continue;for(let f=0;f<p.length;f++){let h=p[f];if(h.top<=s&&h.bottom>=l){s=Math.max(h.bottom,s),l=Math.min(h.top,l);let m=h.left>e.left?h.left-e.left:h.right<e.left?e.left-h.right:0;if(m<r){t=d,r=m,o=m&&ke(t)?{left:h.right<e.left?h.right:h.left,top:e.top}:e,W(d)&&m&&(i=u+(e.left>=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=d,c={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!t&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(i=u+1)}}return!t&&a&&(t=a,o=c,r=0),t&&ke(t)?$b(t,o):!t||r?{node:n,offset:i}:Sf(t,o)}function $b(n,e){let t=n.nodeValue.length,r=document.createRange(),o;for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let s=Vt(r,1);if(s.top!=s.bottom&&Bl(e,s)){o={node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),o||{node:n,offset:0}}function Bl(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Vb(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function qb(n,e,t){let{node:r,offset:o}=Sf(e,t),i=-1;if(W(r)&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,o,i)}function jb(n,e,t,r){let o=-1;for(let i=e,s=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0),a;if(!l)return null;if(W(l.dom)&&(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)&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),s=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function Mf(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),i=o;;){let s=n.childNodes[i];if(W(s)){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Bl(e,c))return Mf(s,e,c)}}if((i=(i+1)%r)==o)break}return n}function Wb(n,e){let t=n.dom.ownerDocument,r,o=0,i=_b(t,e.left,e.top);i&&({node:r,offset:o}=i);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!s||!n.dom.contains(s)){let c=n.dom.getBoundingClientRect();if(!Bl(e,c)||(s=Mf(n.dom,e,c),!s))return null}if(Re)for(let c=s;r&&c;c=Kn(c))c.draggable&&(r=void 0);if(s=Vb(s,e),r){if(Ge&&W(r)&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let d=r.childNodes[o],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&o++}let c;Zo&&o&&W(r)&&W(c=r.childNodes[o-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&W(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||!W(r)||r.childNodes[o-1].nodeName!="BR")&&(l=jb(n,r,o,e))}l==null&&(l=qb(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ml(n){return n.top<n.bottom||n.left<n.right}function Vt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Ml(r))return r}return Array.prototype.find.call(t,Ml)||n.getBoundingClientRect()}var Kb=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ef(n,e,t){let{node:r,offset:o,atom:i}=n.docView.domFromPos(e,t<0?-1:1),s=Zo||Ge;if(ke(r))if(s&&(Kb.test(r.nodeValue)||(t<0?!o:o==r.nodeValue.length))){let a=Vt(Tt(r,o,o),t);if(Ge&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=Vt(Tt(r,o-1,o-1),-1);if(c.top==a.top){let d=Vt(Tt(r,o,o+1),-1);if(d.top!=a.top)return Lr(d,d.left<c.left)}}return a}else{let a=o,c=o,d=t<0?1:-1;return t<0&&!o?(c++,d=-1):t>=0&&o==r.nodeValue.length?(a--,d=1):t<0?a--:c++,Lr(Vt(Tt(r,a,c),d),d<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(t<0||o==Me(r))){let a=r.childNodes[o-1];if(W(a))return bl(a.getBoundingClientRect(),!1)}if(i==null&&o<Me(r)){let a=r.childNodes[o];if(W(a))return bl(a.getBoundingClientRect(),!0)}return bl(r.getBoundingClientRect(),t>=0)}if(i==null&&o&&(t<0||o==Me(r))){let a=r.childNodes[o-1],c=ke(a)?Tt(a,Me(a)-(s?0:1)):W(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Lr(Vt(c,1),!1)}if(i==null&&o<Me(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?ke(a)?Tt(a,0,s?0:1):W(a)?a:null:null;if(c)return Lr(Vt(c,-1),!0)}return Lr(Vt(ke(r)?Tt(r):r,-t),t>=0)}function Lr(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function bl(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Cf(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function Ub(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return Cf(n,e,()=>{let{node:i}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=Ef(n,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(W(l))a=l.getClientRects();else if(ke(l))a=Tt(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&&(t=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}var Jb=/[\u0590-\u08ac]/;function Gb(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=n.domSelection();return l?!Jb.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:s:Cf(n,e,()=>{let a=n.domSel.readRange(),c=l.caretBidiLevel;l.modify("move",t,"character");let d=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:u,focusOffset:p}=n.domSel.readRange(),f=u&&!Un(d,u)||a.focusNode==u&&a.focusOffset==p;return yf(l,a),c!=null&&(l.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var Fp=null,zp=null,$p=!1;function Yb(n,e,t){return Fp==e&&zp==t?$p:(Fp=e,zp=t,$p=t=="up"||t=="down"?Ub(n,e,t):Gb(n,e,t))}var mn=class{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.damage=0,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let o=this.children[t];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&Un(this.contentDOM,e))if(r<0){let i,s;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>Le(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let i=e.compareDocumentPosition(this.contentDOM);i&16?o=t>Array.from(e.childNodes).findIndex(s=>s.contains(this.contentDOM)):o=!(i&4)}else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!t||i.node))if(r&&(s=i.nodeDOM)&&!(W(s)?Un(s,e):s==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t],i=r+o.size;if(r==e&&i!=r){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let l=o.children[s];if(l.size){o=l;break}}return o}if(e<i)return o.descAt(e-r-o.border);r=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],l=i+s.size;if(l>e){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(;r>0;r--){let i=this.children[r-1];if(i.size||!(i instanceof jo||i instanceof qo&&i.side>=0))break}if(t<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&t&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?Le(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?Le(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(o==-1&&e<=c){let d=s+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=s;for(let u=l;u>0;u--){let p=this.children[u-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){o=Le(p.dom)+1;break}e-=p.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=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=Le(u.dom);break}t+=u.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(!W(t)||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDamage(e){e&&(this.damage|=e,this.markParentDamage())}markParentDamage(){for(let e=this;;){let{parent:t}=e;if(!t||t.damage&1)break;t.damage|=1,e=t}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},qo=class extends mn{constructor(e,t,r,o){let i,s=t.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let l=W(s)?s:document.createElement("span");l!=s&&(l.appendChild(s),s=l),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return!this.damage&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},El=class extends mn{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},pn=class n extends mn{constructor(e,t,r,o,i){super(e,[],r,o),this.mark=t,this.spec=i}static create(e,t,r,o){let i=o.nodeViews[t.type.name],s=i&&i(t,o,r);return(!s||!s.dom)&&(s=Ve.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.damage&4||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return!(this.damage&4)&&this.mark.eq(e)}markDamage(e){var t;this.damage|=e,(t=this.parent)===null||t===void 0||t.markDamage(2)}slice(e,t,r){let o=n.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;t<s&&(i=Al(i,t,s,r)),e>0&&(i=Al(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Kt=class n extends mn{constructor(e,t,r,o,i,s,l){super(e,[],i,s),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,t,r,o,i,s){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(!ke(d))throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Ve.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let p=d;return d=Tf(d,r,t),c?a=new Wo(e,t,r,o,d,u||null,p,c):t.isText?new _r(e,t,r,o,d,p):new n(e,t,r,o,d,u||null,p)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let o=this.children[r];if(this.dom.contains(o.dom.parentNode)){t.contentElement=o.dom.parentNode;break}}if(!t.contentElement){let r=e&&e.find(o=>W(o)&&e.indexOf(o.parentNode)<0&&this.dom.contains(o));r?t.contentElement=r:t.getContent=()=>N.empty}}return t}matchesNode(e,t,r){return!this.damage&&e.eq(this.node)&&Ko(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Cl(this,s&&s.node,e),c=this.node.inlineContent,d=c&&this.node.isBlock;ek(this.node,this.innerDeco,(u,p,f)=>{u.spec.marks?a.syncToMarks(u.spec.marks,r,e,p):u.type.side>=0&&!f&&a.syncToMarks(p==this.node.childCount?Q.none:this.node.child(p).marks,r,e,p),a.placeWidget(u,e,o)},(u,p,f,h)=>{a.syncToMarks(u.marks,r,e,h),d&&u.isAtom&&!u.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(u,p,f,h)||l&&e.state.selection.from>o&&e.state.selection.to<o+u.nodeSize&&(m=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(u,p,f,m,e,o)||a.updateNextNode(u,p,f,e,h,o)||a.addNode(u,p,f,e,o),o+=u.nodeSize,c&&(d=u.isAtom&&!u.isText)}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.damage&2)&&(s&&this.protectLocalComposition(e,s),Af(this.contentDOM,this.children,e),Gn&&tk(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof F)||r<t||o>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let s=i.nodeValue,l=nk(this.node.content,s,r-t,o-t);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:o}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new El(this,i,t,o);e.input.compositionNodes.push(s),this.children=Al(this.children,r,r+o.length,e,s)}update(e,t,r,o,i){return this.damage&4||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o,i),!0)}updateInner(e,t,r,o,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,i+1),this.damage=0}updateOuterDeco(e){if(Ko(e,this.outerDeco))return;let t=!W(this.nodeDOM),r=this.dom;this.dom=Fl(this.dom,this.nodeDOM,Ir(this.outerDeco,this.node,t),Ir(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){W(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){W(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function Vp(n,e,t,r,o,i){i?Fl(r,r,Ir(i,n,!1),Ir(e,n,!1)):Tf(r,e,n);let s=new Kt(void 0,n,e,t,r,r,r);return s.contentDOM&&s.updateChildren(o,0),s}var _r=class n extends Kt{constructor(e,t,r,o,i,s){super(e,t,r,o,i,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.damage&4||this.damage&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.damage&8||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.damage=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return!1}slice(e,t,r){let o=this.node.cut(e,t),i=document.createTextNode(o.text);return new n(this.parent,o,this.outerDeco,this.innerDeco,i,i)}get domAtom(){return!1}isText(e){return this.node.text==e}},jo=class extends mn{parseRule(){return{ignore:!0}}matchesHack(e){return!this.damage&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Wo=class extends Kt{constructor(e,t,r,o,i,s,l,a){super(e,t,r,o,i,s,l),this.spec=a}update(e,t,r,o,i){if(this.damage&4)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,o,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}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 Af(n,e,t){let r=n.firstChild,o=!1;for(let i=0;i<e.length;i++){let s=e[i],l=s.dom;if(l.parentNode==n){for(;l!=r;)r=qp(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(l,r);if(s instanceof pn){let a=r?r.previousSibling:n.lastChild;Af(s.contentDOM,s.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=qp(r),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}var Rr=function(n){n&&(this.nodeName=n)};Rr.prototype=Object.create(null);var un=[new Rr];function Ir(n,e,t){if(n.length==0)return un;let r=t?un[0]:new Rr,o=[r];for(let i=0;i<n.length;i++){let s=n[i].type.attrs;if(s){s.nodeName&&o.push(r=new Rr(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&o.length==1&&o.push(r=new Rr(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function Fl(n,e,t,r){if(t==un&&r==un)return e;let o=e;for(let i=0;i<r.length;i++){let s=r[i],l=t[i];if(i){let a;l&&l.nodeName==s.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=un[0]),o=a}Xb(o,l||un[0],s)}return o}function Xb(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&n.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.indexOf(o[i])==-1&&n.classList.add(o[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function Tf(n,e,t){return Fl(n,n,un,Ir(e,t,!W(n)))}function Ko(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function qp(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var Cl=class{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Zb(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,o){let i=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;i<l&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.damage=0,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;o<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let d=this.index;d<c;d++){let u=this.top.children[d];if(u.matchesMark(e[s])&&!this.isLocked(u.dom)){a=d;break}}if(a<0&&this.index<this.top.children.length){let d=this.top.children[this.index];d instanceof pn&&!(d.damage&4)&&d.mark.type==e[s].type&&d.spec.update&&!this.isLocked(d.dom)&&d.spec.update(e[s])&&(d.mark=e[s],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let d=pn.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,d),this.top=d,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,r,o,i,s){let l=this.top.children[o];return l.damage&4&&l.dom==l.contentDOM&&(l.damage=2),l.update(e,t,r,i,s)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=t}}updateNextNode(e,t,r,o,i,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Kt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let d=a.dom,u,p=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&!(a.damage&4)&&Ko(t,a.outerDeco));if(!p&&a.update(e,t,r,o,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!p&&(u=this.recreateWrapper(a,e,t,r,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.damage|=2,u.updateChildren(o,s+1),u.damage=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,o,i,s){if(e.damage&3||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Ko(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=Kt.create(this.top,t,r,o,i,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,o,i){let s=Kt.create(this.top,e,t,r,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new qo(this.top,e,t,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof pn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof _r)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Re||Pe)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new jo(this.top,[],r,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||W(e)&&e.contains(this.lock.parentNode))}};function Zb(n,e){let t=e,r=t.children.length,o=[],i=n.childCount,s=new Map,l=[];e:for(;i>0;){let a;for(;;)if(r){let d=t.children[r-1];if(d instanceof pn)o.push(r-1),t=d,r=d.children.length;else{a=d,r--;break}}else{if(t==e)break e;r=o.pop(),t=t.parent}let c=a.node;if(c){if(c!=n.child(i-1))break;--i,s.set(a,i),l.push(a)}}return{index:i,matched:s,matches:l.reverse()}}function Qb(n,e){return n.type.side-e.type.side}function ek(n,e,t,r){let o=e.locals(n),i=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);r(d,o,e.forChild(i,d),c),i+=d.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let d,u;for(;s<o.length&&o[s].to==i;){let g=o[s++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(Qb);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let p,f;if(a)f=-1,p=a,a=null;else if(c<n.childCount)f=c,p=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let h=i+p.nodeSize;if(p.isText){let g=h;s<o.length&&o[s].from<g&&(g=o[s].from);for(let y=0;y<l.length;y++)l[y].to<g&&(g=l[y].to);g<h&&(a=p.cut(g-i),p=p.cut(0,g-i),h=g,f=-1)}else for(;s<o.length&&o[s].to<h;)s++;let m=p.isInline&&!p.isLeaf?l.filter(g=>!g.inline):l.slice();r(p,m,e.forChild(i,p),f),i=h}}function tk(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function nk(n,e,t,r){for(let o=0,i=0;o<n.childCount&&i<=r;){let s=n.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<n.childCount;){let c=n.child(o++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Al(n,e,t,r,o){let i=[];for(let s=0,l=0;s<n.length;s++){let a=n[s],c=l,d=l+=a.size;c>=t||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),o&&(i.push(o),o=void 0),d>t&&i.push(a.slice(t-c,a.size,r)))}return i}function Tl(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),i=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return i&&K.findFrom(i,e)}function qt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function jp(n,e,t){let r=n.state.selection;if(r instanceof F)if(t.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=n.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return qt(n,new F(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Tl(n.state,e);return o&&o instanceof R?qt(n,o):!1}else if(!je||t.indexOf("m")<0){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?R.isSelectable(i)?qt(n,new R(e<0?n.state.doc.resolve(o.pos-i.nodeSize):o)):qt(n,new F(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1}}else return!1;else{if(r instanceof R&&r.node.isInline)return qt(n,new F(e>0?r.$to:r.$from));{let o=Tl(n.state,e);return o?qt(n,o):!1}}}function Dr(n,e){let t=n.pmViewDesc;return t?t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR"):W(n)&&n.contentEditable=="false"}function jn(n,e){return e<0?rk(n):ok(n)}function rk(n){let e=n.domSel.readRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,i,s=!1;for(Ge&&W(t)&&r<Me(t)&&Dr(t.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!W(t))break;let l=t.childNodes[r-1];if(Dr(l,-1))o=t,i=--r;else if(ke(l))t=l,r=t.nodeValue.length;else break}else{if(Nf(t))break;{let l=t.previousSibling;for(;l&&Dr(l,-1);)o=t.parentNode,i=Le(l),l=l.previousSibling;if(l)t=l,r=Me(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?Nl(n,t,r):o&&Nl(n,o,i)}function ok(n){let e=n.domSel.readRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=Me(t),i,s;for(;;)if(r<o){if(!W(t))break;let l=t.childNodes[r];if(Dr(l,1))i=t,s=++r;else break}else{if(Nf(t))break;{let l=t.nextSibling;for(;l&&Dr(l,1);)i=l.parentNode,s=Le(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=Me(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}i&&Nl(n,i,s)}function Nf(n){for(let e=n;e;e=e.parentNode){let t=e.pmViewDesc;if(t)return t.node?t.node.isBlock:!1}return!1}function Nl(n,e,t){if(!ke(e)){let s,l;(l=gf(e,t))?(e=l,t=0):(s=mf(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection(),o=n.domSel.readRange();if(!r)return;Xo(o)?r.collapse(e,t):r.extend&&(r.collapse(o.anchorNode,o.anchorOffset),r.extend(e,t)),n.domSel.ignore();let{state:i}=n;setTimeout(()=>{n.state==i&&n.domSel.sync()},50)}function Wp(n,e){let t=n.state.doc.resolve(e);if(!(Pe||kf)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}let r=n.dom;for(let i=t.depth;i>0;i--)if(t.node(i).isBlock){r=n.nodeDOM(t.before(i))||r;break}return getComputedStyle(r).direction=="rtl"?"rtl":"ltr"}function Kp(n,e,t){let r=n.state.selection;if(r instanceof F&&!r.empty||t.indexOf("s")>-1||je&&t.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Tl(n.state,e);if(s&&s instanceof R)return qt(n,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof ue?K.near(s,e):K.findFrom(s,e);return l?qt(n,l):!1}return!1}function Up(n,e){if(!(n.state.selection instanceof F))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let s=n.state.tr;return e<0?s.delete(t.pos-i.nodeSize,t.pos):s.delete(t.pos,t.pos+i.nodeSize),n.dispatch(s),!0}return!1}function Jp(n,e,t){n.domObserver.stopped(()=>e.contentEditable=t)}function ik(n){if(!Re||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSel.readRange();if(e&&W(e)&&t==0&&e.firstChild&&W(e.firstChild)&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Jp(n,r,"true"),setTimeout(()=>Jp(n,r,"false"),20)}return!1}function sk(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function lk(n,e){let t=e.keyCode,r=sk(e);if(t==8||je&&t==72&&r=="c")return Up(n,-1)||jn(n,-1);if(t==46&&!e.shiftKey||je&&t==68&&r=="c")return Up(n,1)||jn(n,1);if(t==13||t==27)return!0;if(t==37||je&&t==66&&r=="c"){let o=t==37?Wp(n,n.state.selection.from)=="ltr"?-1:1:-1;return jp(n,o,r)||jn(n,o)}else if(t==39||je&&t==70&&r=="c"){let o=t==39?Wp(n,n.state.selection.from)=="ltr"?1:-1:1;return jp(n,o,r)||jn(n,o)}else{if(t==38||je&&t==80&&r=="c")return Kp(n,-1,r)||jn(n,-1);if(t==40||je&&t==78&&r=="c")return ik(n)||Kp(n,1,r)||jn(n,1);if(r==(je?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function zl(n,e){n.someProp("transformCopied",f=>{e=f(e,n)});let t=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let f=r.firstChild;t.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let s=n.someProp("clipboardSerializer")||Ve.fromSchema(n.state.schema),l=Df(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&W(c)&&(d=Rf[c.nodeName.toLowerCase()]);){for(let f=d.length-1;f>=0;f--){let h=l.createElement(d[f]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),u++}c=a.firstChild}c&&W(c)&&c.setAttribute("data-pm-slice",`${o} ${i}${u?` -${u}`:""} ${JSON.stringify(t)}`);let p=n.someProp("clipboardTextSerializer",f=>f(e,n))||e.content.textBetween(0,e.content.size,`
3
+ (()=>{var Dy=Object.create;var Eo=Object.defineProperty;var _y=Object.getOwnPropertyDescriptor;var Iy=Object.getOwnPropertyNames;var Hy=Object.getPrototypeOf,By=Object.prototype.hasOwnProperty;var Fy=(n,e,t)=>e in n?Eo(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var I=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var q=(n,e)=>{for(var t in e)Eo(n,t,{get:e[t],enumerable:!0})},zy=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Iy(e))!By.call(n,o)&&o!==t&&Eo(n,o,{get:()=>e[o],enumerable:!(r=_y(e,o))||r.enumerable});return n};var H=(n,e,t)=>(t=n!=null?Dy(Hy(n)):{},zy(e||!n||!n.__esModule?Eo(t,"default",{value:n,enumerable:!0}):t,n));var S=(n,e,t)=>Fy(n,typeof e!="symbol"?e+"":e,t);var gm={};var Fs={};q(Fs,{definePlugin:()=>Md,isPluginRegistered:()=>Co,loadPlugin:()=>Bs,orderPlugins:()=>Ln,pageHandlerOf:()=>kr,registerPlugin:()=>j,resolveEntries:()=>vr});function kr(n,e){for(let t of n)if(t.page)try{return typeof t.page=="function"?t.page(e):t.page}catch(r){console.error(`[nova] Plugin "${t.name}" failed to set up its page`,r)}return null}function Md(n){return n}var Hs=new Map;function j(n,e){Hs.set(n,e)}function Co(n){return Hs.has(n)}function Sd(n){return typeof n=="function"}function vr(n){let e=[],t=[],r=[];for(let o of n)if(typeof o=="string"){let i=Hs.get(o);i?Sd(i)?t.push(i):e.push(i):r.push(`Plugin "${o}" is not registered`)}else Sd(o)?t.push(o):e.push(o);return{plugins:e,loaders:t,errors:r}}function Ln(n,e=new Set){let t=new Map(n.map(l=>[l.name,l])),r=[],o=[],i=new Map,s=(l,a)=>{let c=i.get(l.name);if(c==="done")return!0;if(c==="failed")return!1;if(c==="visiting")return o.push(`Plugin dependency cycle: ${[...a,l.name].join(" \u2192 ")}`),!1;i.set(l.name,"visiting");for(let u of l.requires??[]){if(e.has(u))continue;let d=t.get(u);if(!d)return o.push(`Plugin "${l.name}" requires "${u}", which is not loaded`),i.set(l.name,"failed"),!1;if(!s(d,[...a,l.name]))return i.set(l.name,"failed"),!1}return i.set(l.name,"done"),r.push(l),!0};for(let l of n)s(l,[]);return{ordered:r,errors:o}}async function Bs(n){let e=await n();return"default"in e&&e.default?e.default:e}var gl={};q(gl,{LABELS:()=>dl,default:()=>ml,detailsAround:()=>Ib,isOpen:()=>pl,setOpen:()=>Dp,summaryEnd:()=>fl});var il={};q(il,{AllSelection:()=>de,EditorState:()=>un,NodeSelection:()=>R,Plugin:()=>z,PluginKey:()=>X,Selection:()=>U,SelectionRange:()=>cn,TextSelection:()=>F,Transaction:()=>Ho});var Js={};q(Js,{ContentMatch:()=>zt,DOMParser:()=>Mt,DOMSerializer:()=>qe,Fragment:()=>T,Mark:()=>Q,MarkType:()=>Rn,Node:()=>Te,NodeRange:()=>Ft,NodeType:()=>st,ReplaceError:()=>St,ResolvedPos:()=>Sr,Schema:()=>Dn,Slice:()=>D});function we(n){this.content=n}we.prototype={constructor:we,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,o=r.find(n),i=r.content.slice();return o==-1?i.push(t||n,e):(i[o+1]=e,t&&(i[o]=t)),new we(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new we(t)},addToStart:function(n,e){return new we([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new we(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),i=r.find(n);return o.splice(i==-1?o.length:i,0,e,t),new we(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=we.from(n),n.size?new we(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=we.from(n),n.size?new we(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=we.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};we.from=function(n){if(n instanceof we)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new we(e)};var zs=we;function Id(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),i=e.child(r);if(o==i){t+=o.nodeSize;continue}if(!o.sameMarkup(i))return t;if(o.isText&&o.text!=i.text){let s=o.text,l=i.text,a=0;for(;s[a]==l[a];a++)t++;return a&&a<s.length&&a<l.length&&Fd(s.charCodeAt(a-1))&&Bd(s.charCodeAt(a))&&t--,t}if(o.content.size||i.content.size){let s=Id(o.content,i.content,t+1);if(s!=null)return s}t+=o.nodeSize}}function Hd(n,e,t,r){for(let o=n.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:t,b:r};let s=n.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=s.text,u=l.text,d=c.length,p=u.length;for(;d>0&&p>0&&c[d-1]==u[p-1];)d--,p--,t--,r--;return d&&p&&d<c.length&&Fd(c.charCodeAt(d-1))&&Bd(c.charCodeAt(d))&&(t++,r++),{a:t,b:r}}if(s.content.size||l.content.size){let c=Hd(s.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}function Bd(n){return n>=56320&&n<57344}function Fd(n){return n>=55296&&n<56320}var T=class n{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,i){for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,o+l,i||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let i="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new n(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;a>e&&((s<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),o+=l.nodeSize),s=a}return new n(r,o)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new n(o,i)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return Id(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Hd(this,e,t,r)}findIndex(e){if(e==0)return Ao(0,e);if(e==this.size)return Ao(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let o=this.child(t),i=r+o.nodeSize;if(i>=e)return i==e?Ao(t+1,i):Ao(t,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return n.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let o=0;o<e.length;o++){let i=e[o];r+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(t||(t=e.slice(0,o)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new n(t||e,r)}static from(e){if(!e)return n.empty;if(e instanceof n)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new n([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};T.empty=new T([],0);var $s={index:0,offset:0};function Ao(n,e){return $s.index=n,$s.offset=e,$s}function Oo(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Oo(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Oo(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}var Q=class n{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Oo(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);return r.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return n.none;if(e instanceof n)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}};Q.none=[];var St=class extends Error{},D=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=$d(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(zd(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return n.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(T.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)o++;return new n(e,r,o)}};D.empty=new D(T.empty,0,0);function zd(n,e,t){let{index:r,offset:o}=n.findIndex(e),i=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(o==e||i.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(zd(i.content,e-o-1,t-o-1)))}function $d(n,e,t,r,o,i){let{index:s,offset:l}=n.findIndex(e),a=n.maybeChild(s);if(l==e||a.isText)return i&&r<=0&&o<=0&&!i.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=$d(a.content,e-l-1,t,s==0?r-1:0,s==n.childCount-1?o-1:0,a);return c&&n.replaceChild(s,a.copy(c))}function $y(n,e,t){if(t.openStart>n.depth)throw new St("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new St("Inconsistent open depths");return Vd(n,e,t,0)}function Vd(n,e,t,r){let o=n.index(r),i=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let s=Vd(n,e,t,r+1);return i.copy(i.content.replaceChild(o,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let s=n.parent,l=s.content;return nn(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=Vy(t,n);return nn(i,jd(n,s,l,e,r))}else return nn(i,Lo(n,e,r))}function qd(n,e){if(!e.type.compatibleContent(n.type))throw new St("Cannot join "+e.type.name+" onto "+n.type.name)}function Vs(n,e,t){let r=n.node(t);return qd(r,e.node(t)),r}function tn(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function xr(n,e,t,r){let o=(e||n).node(t),i=0,s=e?e.index(t):o.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(tn(n.nodeAfter,r),i++));for(let l=i;l<s;l++)tn(o.child(l),r);e&&e.depth==t&&e.textOffset&&tn(e.nodeBefore,r)}function nn(n,e){if(!n.type.validContent(e))throw new St("Invalid content for node "+n.type.name);return n.copy(e)}function jd(n,e,t,r,o){let i=n.depth>o&&Vs(n,e,o+1),s=r.depth>o&&Vs(t,r,o+1),l=[];return xr(null,n,o,l),i&&s&&e.index(o)==t.index(o)?(qd(i,s),tn(nn(i,jd(n,e,t,r,o+1)),l)):(i&&tn(nn(i,Lo(n,e,o+1)),l),xr(e,t,o,l),s&&tn(nn(s,Lo(t,r,o+1)),l)),xr(r,null,o,l),new T(l)}function Lo(n,e,t){let r=[];if(xr(null,n,t,r),n.depth>t){let o=Vs(n,e,t+1);tn(nn(o,Lo(n,e,t+1)),r)}return xr(e,null,t,r),new T(r)}function Vy(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)o=e.node(i).copy(T.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}var Sr=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)o+=r.child(i).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return Q.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let l=r;r=o,o=l}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new Ft(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],o=0,i=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new n(t,r,i)}static resolveCached(e,t){let r=Ed.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==t)return s}else Ed.set(e,r=new qs);let o=r.elts[r.i]=n.resolve(e,t);return r.i=(r.i+1)%qy,o}},qs=class{constructor(){this.elts=[],this.i=0}},qy=12,Ed=new WeakMap,Ft=class{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},jy=Object.create(null),Te=class n{constructor(e,t,r,o=Q.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||T.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,o=0){this.content.nodesBetween(e,t,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,o){return this.content.textBetween(e,t,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Oo(this.attrs,t||e.defaultAttrs||jy)&&Q.sameSet(this.marks,r||Q.none)}copy(e=null){return e==this.content?this:new n(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return D.empty;let o=this.resolve(e),i=this.resolve(t),s=r?0:o.sharedDepth(t),l=o.start(s),c=o.node(s).content.cut(o.pos-l,i.pos-l);return new D(c,o.depth-s,i.depth-s)}replace(e,t,r){return $y(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return Sr.resolveCached(this,e)}resolveNoCache(e){return Sr.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Wd(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=T.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),Ad(this.type.attrs,this.attrs,"node",this.type.name);let e=Q.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];Ad(r.type.attrs,r.attrs,"mark",r.type.name),e=r.addToSet(e)}if(!Q.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let o=T.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,o,r)}};Te.prototype.text=void 0;var Cd=(()=>{let{stack:n}=new Error("/");if(!n||!/\n\s*at\s/.test(n))return t=>t;let e=Object.create(null);return t=>(e[t],t)})(),js=class n extends Te{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Wd(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return Cd(this.text.slice(e,t))}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(Cd(this.text.slice(e,t)))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Wd(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}function Ad(n,e,t,r){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${r}`);for(let o in n)n[o].validate&&n[o].validate(e[o])}var zt=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Ws(e,t);if(r.next==null)return n.empty;let o=Kd(r);r.next&&r.err("Unexpected trailing text");let i=Xy(Yy(o));return Zy(i,r),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let o=this;for(let i=t;o&&i<r;i++)o=o.matchType(e.child(i).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function i(s,l){let a=s.matchFragment(e,r);if(a&&(!t||a.validEnd))return T.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:d}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(d)==-1){o.push(d);let p=i(d,l.concat(u));if(p)return p}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(e)){let s=[];for(let l=o;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:l,next:a}=i.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
4
+ `)}};zt.empty=new zt(!0);var Ws=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function Kd(n){let e=[];do e.push(Wy(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Wy(n){let e=[];do e.push(Ky(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Ky(n){let e=Gy(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Uy(n,e);else break;return e}function Td(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Uy(n,e){let t=Td(n),r=t;return n.eat(",")&&(n.next!="}"?r=Td(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Jy(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let i in t){let s=t[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function Gy(n){if(n.eat("(")){let e=Kd(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Jy(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Yy(n){let e=[[]];return o(i(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let u=t();o(i(s.expr,a),u),a=u}if(s.max==-1)o(i(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let u=t();r(a,u),o(i(s.expr,a),u),a=u}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Ud(n,e){return e-n}function Nd(n,e){let t=[];return r(e),t.sort(Ud);function r(o){let i=n[o];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(o);for(let s=0;s<i.length;s++){let{term:l,to:a}=i[s];!l&&t.indexOf(a)==-1&&r(a)}}}function Xy(n){let e=Object.create(null);return t(Nd(n,0));function t(r){let o=[];r.forEach(s=>{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<o.length;u++)o[u][0]==l&&(c=o[u][1]);Nd(n,a).forEach(u=>{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new zt(r.indexOf(n.length-1)>-1);for(let s=0;s<o.length;s++){let l=o[s][1].sort(Ud);i.next.push({type:o[s][0],next:e[l.join(",")]||t(l)})}return i}}function Zy(n,e){for(let t=0,r=[n];t<r.length;t++){let o=r[t],i=!o.validEnd,s=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];s.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Jd(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Gd(n,e){let t=Object.create(null);for(let r in n){let o=n[r],i=e&&e[r];if(i===void 0)if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r);else o.validate&&o.validate(i);t[r]=i}return t}function Yd(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Ks(n,r,e[r]);return t}var st=class n{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Yd(e,r.attrs),this.defaultAttrs=Jd(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==zt.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:Gd(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Te(this,this.computeAttrs(e),T.from(t),Q.setFrom(r))}createChecked(e=null,t,r){return t=T.from(t),this.checkContent(t),new Te(this,this.computeAttrs(e),t,Q.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=T.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(T.empty,!0);return i?new Te(this,e,t.append(i),Q.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:Q.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,s)=>r[i]=new n(i,t,s));let o=t.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Qy(n,e,t){let r=t.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}var Ks=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Qy(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},Rn=class n{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=Yd(e,o.attrs),this.excluded=null;let i=Jd(this.attrs);this.instance=i?new Q(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Q(this,Gd(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new n(i,o++,t,s)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}},Dn=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=zs.from(e.nodes),t.marks=zs.from(e.marks||{}),this.nodes=st.compile(this.spec.nodes,this),this.marks=Rn.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=zt.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?Od(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:Od(this,s.split(" "))}this.nodeFromJSON=o=>Te.fromJSON(this,o),this.markFromJSON=o=>Q.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof st){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,o)}text(e,t){let r=this.nodes.text;return new js(r,r.defaultAttrs,e,Q.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function Od(n,e){let t=[];for(let r=0;r<e.length;r++){let o=e[r],i=n.marks[o],s=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function eb(n){return n.tag!=null}function tb(n){return n.style!=null}var Mt=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if(eb(o))this.tags.push(o);else if(tb(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new Po(this,t,!1);return r.addAll(e,Q.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Po(this,t,!0);return r.addAll(e,Q.none,t.from,t.to),D.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(ob(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(e);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(e,t,r,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let s=this.styles[i],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<i)break}t.splice(s,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Pd(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Pd(s)),s.node||s.ignore||s.mark||(s.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},Xd={address:!0,article:!0,aside:!0,blockquote:!0,body:!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},nb={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Zd={ol:!0,ul:!0},Mr=1,Us=2,wr=4;function Ld(n,e,t){return e!=null?(e?Mr:0)|(e==="full"?Us:0):n&&n.whitespace=="pre"?Mr|Us:t&~wr}var Pn=class{constructor(e,t,r,o,i,s){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=Q.none,this.match=i||(s&wr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(T.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Mr)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let t=T.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(T.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Xd.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Po=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,i,s=Ld(null,t.preserveWhitespace,0)|(r?wr:0);o?i=new Pn(o.type,o.attrs,Q.none,!0,t.topMatch||o.type.contentMatch,s):r?i=new Pn(null,null,Q.none,!0,null,s):i=new Pn(e.schema.topNodeType,null,Q.none,!0,null,s),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,o=this.top,i=o.options&Us?"full":this.localPreserveWS||(o.options&Mr)>0,{schema:s}=this.parser;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
5
+ `);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(s.text(l[a]),t,!/\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=o.content[o.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(s.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let o=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Zd.hasOwnProperty(s)&&this.parser.normalizeLists&&rb(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:nb.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Xd.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=a&&a.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
6
+ `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],s=r.getPropertyValue(i);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(i,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,o){let i,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,t);this.findAtPoint(e,i)}findPlace(e,t,r){let o,i;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(i);for(let s=0;s<o.length;s++)t=this.enterInner(o[s],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let o=this.findPlace(e,t,r);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=Q.none;for(let l of o.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):Rd(l.type,e.type))&&(s=l.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,t,r,o){let i=this.findPlace(e.create(t),r,!1);return i&&(i=this.enterInner(e,t,r,!0,o)),i}enterInner(e,t,r,o=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=Ld(e,i,s.options);s.options&wr&&s.content.length==0&&(l|=wr);let a=Q.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):Rd(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Pn(e,t,a,o,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Mr)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}};function rb(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Zd.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function ob(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Pd(n){let e={};for(let t in n)e[t]=n[t];return e}function Rd(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let i=[],s=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&s(u))return!0}};if(s(o.contentMatch))return!0}}var qe=class n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=To(t).createDocumentFragment());let o=r,i=[];return e.forEach(s=>{if(i.length||s.marks.length){let l=0,a=0;for(;l<i.length&&a<s.marks.length;){let c=s.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)o=i.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],u=this.serializeMark(c,s.isInline,t);u&&(i.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(s,t))}),r}serializeNodeInner(e,t){if(e.isText)return To(t).createTextNode(e.text);let{dom:r,contentDOM:o}=No(To(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&No(To(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return typeof t=="string"?{dom:e.createTextNode(t)}:No(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Dd(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Dd(e.marks)}};function Dd(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function To(n){return n.document||window.document}var _d=new WeakMap;function ib(n){let e=_d.get(n);return e===void 0&&_d.set(n,e=sb(n)),e}function sb(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function No(n,e,t,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let o=e[0],i;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=ib(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=o.indexOf(" ");s>0&&(t=o.slice(0,s),o=o.slice(s+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let p=d.indexOf(" ");p>0?a.setAttributeNS(d.slice(0,p),d.slice(p+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let p=e[d];if(p===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof p=="string")a.appendChild(n.createTextNode(p));else{let{dom:f,contentDOM:h}=No(n,p,t,r);if(a.appendChild(f),h){if(l)throw new RangeError("Multiple content holes");l=h}}}return{dom:a,contentDOM:l}}var tl={};q(tl,{AddMarkStep:()=>Je,AddNodeMarkStep:()=>Hn,AttrStep:()=>on,DocAttrStep:()=>Tr,MapResult:()=>_n,Mapping:()=>In,RemoveMarkStep:()=>Ge,RemoveNodeMarkStep:()=>rn,ReplaceAroundStep:()=>re,ReplaceStep:()=>le,Step:()=>oe,StepMap:()=>lt,StepResult:()=>me,Transform:()=>Et,TransformError:()=>sn,canJoin:()=>ct,canSplit:()=>Ct,dropPoint:()=>Nr,findWrapping:()=>ln,insertPoint:()=>pp,joinPoint:()=>dp,liftTarget:()=>at,replaceStep:()=>Or});var rp=65535,op=Math.pow(2,16);function lb(n,e){return n+e*op}function Qd(n){return n&rp}function ab(n){return(n-(n&rp))/op}var ip=1,sp=2,Ro=4,lp=8,_n=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&lp)>0}get deletedBefore(){return(this.delInfo&(ip|Ro))>0}get deletedAfter(){return(this.delInfo&(sp|Ro))>0}get deletedAcross(){return(this.delInfo&Ro)>0}},lt=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=Qd(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+ab(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+s],d=a+c;if(e<=d){let p=c?e==a?-1:e==d?1:t:t,f=a+o+(p<0?0:u);if(r)return f;let h=e==(t<0?a:d)?null:lb(l/3,e-a),m=0;return c&&(m|=e==a?sp:e==d?ip:Ro,(t<0?e!=a:e!=d)&&(m|=lp)),new _n(f,m,h)}o+=u-c}return r?e+o:new _n(e+o,0,null)}touches(e,t){let r=0,o=Qd(t),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let s=this.ranges[o],l=s-(this.inverted?i:0),a=s+(this.inverted?0:i),c=this.ranges[o+t],u=this.ranges[o+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new n(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?n.empty:new n(e<0?[0,-e,0]:[0,0,e])}};lt.empty=new lt([]);var In=class n{constructor(e,t,r=0,o=e?e.length:0){this.mirror=t,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new n(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=e.from,r=this._maps.length;t<e.to;t++){let o=e.getMirror(t);o!=null&&(o=o<t&&o>=e.from?r+(o-e.from):void 0),this.appendMap(e._maps[t],o)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.to-1,r=this._maps.length+e._maps.length;t>=e.from;t--){let o=e.getMirror(t);o!=null&&(o=o>t&&o<e.to?r-(o-e.from)-1:void 0),this.appendMap(e._maps[t].invert(),o)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let i=this.from;i<this.to;i++){let s=this._maps[i],l=s.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new _n(e,o,null)}},Gs=Object.create(null),oe=class{getMap(){return lt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Gs[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Gs)throw new RangeError("Duplicate use of step JSON ID "+e);return Gs[e]=t,t.prototype.jsonID=e,t}},me=class n{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new n(e,null)}static fail(e){return new n(null,e)}static fromReplace(e,t,r,o){try{return n.ok(e.replace(t,r,o))}catch(i){if(i instanceof St)return n.fail(i.message);throw i}}};function Qs(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let i=n.child(o);i.content.size&&(i=i.copy(Qs(i.content,e,i))),i.isInline&&(i=e(i,t,o)),r.push(i)}return T.fromArray(r)}var Je=class n extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new D(Qs(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),t.openStart,t.openEnd);return me.fromReplace(e,this.from,this.to,i)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(r,o)=>{if(r.isInline&&r.isAtom){let i=this.mark.addToSet(r.marks);if(!Q.sameSet(i,r.marks)){let s=Math.max(this.from,o),l=Math.min(this.to,o+r.nodeSize);Do(Ge,s,l,this.mark,t);for(let a of r.marks)a.isInSet(i)||Do(n,s,l,a,t)}}}),t.length==1?t[0]:new Ar(t)}map(e){let t=e.map(this.from,1),r=e.map(this.to,-1);return t>=r?null:new n(t,r,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};oe.jsonID("addMark",Je);var Ge=class n extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new D(Qs(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return me.fromReplace(e,this.from,this.to,r)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(r,o)=>{r.isInline&&r.isAtom&&this.mark.isInSet(r.marks)&&Do(Je,Math.max(this.from,o),Math.min(this.to,o+r.nodeSize),this.mark,t)}),t.length==1?t[0]:new Ar(t)}map(e){let t=e.map(this.from,1),r=e.map(this.to,-1);return t>=r?null:new n(t,r,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};oe.jsonID("removeMark",Ge);function Do(n,e,t,r,o){let i=o.length?o[o.length-1]:null;i&&i instanceof n&&i.to==e&&i.mark.eq(r)?o[o.length-1]=new n(i.from,t,r):o.push(new n(e,t,r))}var Ar=class n extends oe{constructor(e){super(),this.steps=e}apply(e){for(let t of this.steps){let r=t.apply(e);if(!r.doc)return r;e=r.doc}return new me(e,null)}invert(e){return new n(this.steps.map(t=>t.invert(e)))}map(e){let t=[];for(let r of this.steps){let o=r.map(e);o&&t.push(o)}return t.length?new n(t):null}toJSON(){return{stepType:"markSet",steps:this.steps.map(e=>e.toJSON())}}static fromJSON(e,t){if(!Array.isArray(t.steps)||!t.steps.every(r=>r.stepType=="addMark"||r.stepType=="removeMark"))throw new RangeError("Invalid JSON for MarkSetStep");return new n(t.steps.map(r=>oe.fromJSON(e,r)))}};oe.jsonID("markSet",Ar);var Hn=class n extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return me.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return me.fromReplace(e,this.pos,this.pos+1,new D(T.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new n(this.pos,t.marks[o]);return new n(this.pos,this.mark)}}return new rn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};oe.jsonID("addNodeMark",Hn);var rn=class n extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return me.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return me.fromReplace(e,this.pos,this.pos+1,new D(T.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Hn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new n(t.pos,e.markFromJSON(t.mark))}};oe.jsonID("removeNodeMark",rn);var le=class n extends oe{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&Xs(e,this.from,this.to)?me.fail("Structure replace would overwrite content"):me.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new lt([this.from,this.to-this.from,this.slice.size])}invert(e){return new n(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&n.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new n(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof n)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?D.empty:new D(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new n(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?D.empty:new D(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new n(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new n(t.from,t.to,D.fromJSON(e,t.slice),!!t.structure)}};le.MAP_BIAS=1;oe.jsonID("replace",le);var re=class n extends oe{constructor(e,t,r,o,i,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=l}apply(e){if(this.structure&&(Xs(e,this.from,this.gapFrom)||Xs(e,this.gapTo,this.to)))return me.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return me.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?me.fromReplace(e,this.from,this.to,r):me.fail("Content does not fit in gap")}getMap(){return new lt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new n(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||i>r.pos||o>i?null:new n(t.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n(t.from,t.to,t.gapFrom,t.gapTo,D.fromJSON(e,t.slice),t.insert,!!t.structure)}};oe.jsonID("replaceAround",re);function Xs(n,e,t){let r=n.resolve(e),o=t-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function cb(n,e,t,r){let o=[];n.doc.nodesBetween(e,t,(i,s,l)=>{if(!i.isInline)return;let a=i.marks;if(!r.isInSet(a)&&l.type.allowsMarkType(r.type)){let c=Math.max(s,e),u=Math.min(s+i.nodeSize,t);Do(Je,c,u,r,o)}}),o.forEach(i=>n.step(i))}function ub(n,e,t,r){let o=[],i=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline||!s.isAtom)return;i++;let a=null;if(r instanceof Rn){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],p;for(let f=0;f<o.length;f++){let h=o[f];h.step==i-1&&d.eq(o[f].style)&&(p=h)}p?(p.to=c,p.step=i):o.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(s=>n.step(new Ge(s.from,s.to,s.style)))}function el(n,e,t,r=t.contentMatch,o=!0){let i=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)s.push(new le(l,u,D.empty));else{r=d;for(let p=0;p<c.marks.length;p++)t.allowsMarkType(c.marks[p].type)||n.step(new Ge(l,u,c.marks[p]));if(o&&c.isText&&t.whitespace!="pre"){let p,f=/\r?\n|\r/g,h;for(;p=f.exec(c.text);)h||(h=new D(T.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new le(l+p.index,l+p.index+p[0].length,h))}}l=u}if(!r.validEnd){let a=r.fillBefore(T.empty,!0);n.replace(l,l,new D(a,0,0))}for(let a=s.length-1;a>=0;a--)n.step(s[a])}function db(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function at(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,o=0,i=0;;--r){let s=n.$from.node(r),l=n.$from.index(r)+o,a=n.$to.indexAfter(r)-i;if(r<n.depth&&s.canReplace(l,a,t))return r;if(r==0||s.type.spec.isolating||!db(s,l,a))break;l&&(o=1),a<s.childCount&&(i=1)}return null}function pb(n,e,t){let{$from:r,$to:o,depth:i}=e,s=r.before(i+1),l=o.after(i+1),a=s,c=l,u=T.empty,d=0;for(let h=i,m=!1;h>t;h--)m||r.index(h)>0?(m=!0,u=T.from(r.node(h).copy(u)),d++):a--;let p=T.empty,f=0;for(let h=i,m=!1;h>t;h--)m||o.after(h+1)<o.end(h)?(m=!0,p=T.from(o.node(h).copy(p)),f++):c++;n.step(new re(a,c,s,l,new D(u.append(p),d,f),u.size-d,!0))}function ln(n,e,t=null,r=n){let o=fb(n,e),i=o&&hb(r,e);return i?o.map(ep).concat({type:e,attrs:t}).concat(i.map(ep)):null}function ep(n){return{type:n,attrs:null}}function fb(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return t.canReplaceWith(r,o,s)?i:null}function hb(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:s}function mb(n,e,t){let r=T.empty;for(let s=t.length-1;s>=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=T.from(t[s].type.create(t[s].attrs,r))}let o=e.start,i=e.end;n.step(new re(o,i,o,i,new D(r,0,0),t.length,!0))}function gb(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&yb(n.doc,n.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!h?c=!1:!f&&h&&(c=!0)}c===!1&&cp(n,s,l,i),el(n,n.mapping.slice(i).map(l,1),r,void 0,c===null);let u=n.mapping.slice(i),d=u.map(l,1),p=u.map(l+s.nodeSize,1);return n.step(new re(d,p,d+1,p-1,new D(T.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&ap(n,s,l,i),!1}})}function ap(n,e,t,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=n.mapping.slice(r).map(t+1+i+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function cp(n,e,t,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+i);n.replaceWith(s,s+1,e.type.schema.text(`
7
+ `))}})}function yb(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function bb(n,e,t,r,o){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let s=t.create(r,null,o||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,s);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new re(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new D(T.from(s),0,0),1,!0))}function Ct(n,e,t=1,r){let o=n.resolve(e),i=o.depth-t,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=t-2;c>i;c--,u--){let d=o.node(c),p=o.index(c);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(p,d.childCount),h=r&&r[u+1];h&&(f=f.replaceChild(0,h.type.create(h.attrs)));let m=r&&r[u]||d;if(!d.canReplace(p+1,d.childCount)||!m.type.validContent(f))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function kb(n,e,t=1,r){let o=n.doc.resolve(e),i=T.empty,s=T.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){i=T.from(o.node(l).copy(i));let u=r&&r[c];s=T.from(u?u.type.create(u.attrs,s):o.node(l).copy(s))}n.step(new le(e,e,new D(i.append(s),t,t),!0))}function ct(n,e){let t=n.resolve(e),r=t.index();return up(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function vb(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),s=i.type==r?n.type.schema.nodes.text:i.type;if(t=t.matchType(s),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function up(n,e){return!!(n&&e&&!n.isLeaf&&vb(n,e))}function dp(n,e,t=-1){let r=n.resolve(e);for(let o=r.depth;;o--){let i,s,l=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):t>0?(i=r.node(o+1),l++,s=r.node(o).maybeChild(l)):(i=r.node(o).maybeChild(l-1),s=r.node(o+1)),i&&!i.isTextblock&&up(i,s)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function xb(n,e,t){let r=null,{linebreakReplacement:o}=n.doc.type.schema,i=n.doc.resolve(e-t),s=i.node().type;if(o&&s.inlineContent){let u=s.whitespace=="pre",d=!!s.contentMatch.matchType(o);u&&!d?r=!1:!u&&d&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);cp(n,u.node(),u.before(),l)}s.inlineContent&&el(n,e+t-1,s,i.node().contentMatchAt(i.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new le(c,a.map(e+t,-1),D.empty,!0)),r===!0){let u=n.doc.resolve(c);ap(n,u.node(),u.before(),n.steps.length)}return n}function pp(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,t))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,t))return r.after(o+1);if(i<r.node(o).childCount)return null}return null}function Nr(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let i=0;i<t.openStart;i++)o=o.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1;for(let a=0;a<2;a++){if(a){if(!l)break;l=-l}let c=r.index(s)+(l>0?1:0),u=r.node(s),d=!1;if(i==1)d=u.canReplace(c,c,o);else{let p=u.contentMatchAt(c).findWrapping(o.firstChild.type);d=p&&u.canReplaceWith(c,c,p[0])}if(d)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}}return null}function Or(n,e,t=e,r=D.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),i=n.resolve(t);return fp(o,i,r)?new le(e,t,r):new Zs(o,i,r).fit()}function fp(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var Zs=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=T.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=T.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new D(i,s,l);return e>-1?new re(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new le(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let i=t.firstChild;if(t.childCount>1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=tp(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(s?c.matchType(s.type)||(d=c.fillBefore(T.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(t==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced;return np(e,-1)<=t?!1:(this.unplaced.size>1&&np(e,1)>r&&r++,this.unplaced=new D(e,t+1,r),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=tp(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new D(Er(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new D(Er(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,u=[],{match:d,type:p}=this.frontier[t];if(o){for(let m=0;m<o.childCount;m++)u.push(o.child(m));d=d.matchFragment(o)}let f=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let m=l.child(c),g=d.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(d=g,u.push(hp(m.mark(p.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?f:-1)))}let h=c==l.childCount;h||(f=-1),this.placed=Cr(this.placed,t,T.from(u)),this.frontier[t].match=d,h&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=u[u.length-1];g&&m<f;m++)this.frontier.push({type:g.type,match:g.contentMatchAt(g.childCount)}),g=g.lastChild;this.unplaced=h?e==0?D.empty:new D(Er(s.content,e-1,1),e-1,f<0?s.openEnd:e-1):new D(Er(s.content,e,c),e,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Ys(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=Ys(e,t,o,r,i);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Ys(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:s,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Cr(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Cr(this.placed,this.depth,T.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(T.empty,!0);t.childCount&&(this.placed=Cr(this.placed,this.frontier.length,t))}};function Er(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Er(n.firstChild.content,e-1,t)))}function Cr(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Cr(n.lastChild.content,e-1,t)))}function tp(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function hp(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,hp(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(T.empty,!0)))),n.copy(r)}function Ys(n,e,t,r,o){let i=n.node(e),s=o?n.indexAfter(e):n.index(e);if(s==i.childCount&&!t.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!wb(t,i.content,s)?l:null}function wb(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Sb(n){return n.spec.defining||n.spec.definingForContent}function np(n,e){for(let t=0;;t++){let r=e<0?n.firstChild:n.lastChild;if(!r||r.isAtom)return t;n=r.content}}function Mb(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),i=n.doc.resolve(t);if(fp(o,i,r))return n.step(new le(e,t,r));let s=gp(o,i);s[s.length-1]==0&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let p=o.depth,f=o.pos-1;p>0;p--,f--){let h=o.node(p).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(p)>-1?l=p:o.before(p)==f&&s.splice(1,0,-p)}let a=s.indexOf(l),c=[],u=r.openStart;for(let p=r.content,f=0;;f++){let h=p.firstChild;if(c.push(h),f==r.openStart)break;p=h.content}for(let p=u-1;p>=0;p--){let f=c[p],h=Sb(f.type);if(h&&!f.sameMarkup(o.node(Math.abs(l)-1)))u=p;else if(h||!f.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let f=(p+u+1)%(r.openStart+1),h=c[f];if(h)for(let m=0;m<s.length;m++){let g=s[(m+a)%s.length],k=!0;g<0&&(k=!1,g=-g);let x=o.node(g-1),M=o.index(g-1);if(x.canReplaceWith(M,M,h.type,h.marks))return n.replace(o.before(g),k?i.after(g):t,new D(mp(r.content,0,r.openStart,f),f,r.openEnd))}}let d=n.steps.length;for(let p=s.length-1;p>=0&&(n.replace(e,t,r),!(n.steps.length>d));p--){let f=s[p];f<0||(e=o.before(f),t=i.after(f))}}function mp(n,e,t,r,o){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(mp(i.content,e+1,t,r,i)))}if(e>r){let i=o.contentMatchAt(0),s=i.fillBefore(n).append(n);n=s.append(i.matchFragment(s).fillBefore(T.empty,!0))}return n}function Eb(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=pp(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new D(T.from(r),0,0))}function Cb(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&r.parentOffset==0&&o.parentOffset==0){let s=r.sharedDepth(t),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=o.depth;a>s;a--)o.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=o.depth;a>0&&t==o.start(a);a--)t=o.before(a);r=n.doc.resolve(e),o=n.doc.resolve(t)}}let i=gp(r,o);for(let s=0;s<i.length;s++){let l=i[s],a=s==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return n.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&o.end(s)-t!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function gp(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;o>=0;o--){let i=n.start(o);if(i<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&t.push(o)}return t}var on=class n extends oe{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return me.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return me.fromReplace(e,this.pos,this.pos+1,new D(T.from(o),0,t.isLeaf?0:1))}getMap(){return lt.empty}invert(e){return new n(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new n(t.pos,t.attr,t.value)}};oe.jsonID("attr",on);var Tr=class n extends oe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return me.ok(r)}getMap(){return lt.empty}invert(e){return new n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(t.attr,t.value)}};oe.jsonID("docAttr",Tr);var sn=class extends Error{};sn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};sn.prototype=Object.create(Error.prototype);sn.prototype.constructor=sn;sn.prototype.name="TransformError";var Et=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new In}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new sn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let o=this.mapping.maps[r];r&&(e=o.map(e,1),t=o.map(t,-1)),o.forEach((i,s,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=D.empty){let o=Or(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new D(T.from(r),0,0))}delete(e,t){return this.replace(e,t,D.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Mb(this,e,t,r),this}replaceRangeWith(e,t,r){return Eb(this,e,t,r),this}deleteRange(e,t){return Cb(this,e,t),this}lift(e,t){return pb(this,e,t),this}join(e,t=1){return xb(this,e,t),this}wrap(e,t){return mb(this,e,t),this}setBlockType(e,t=e,r,o=null){return gb(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return bb(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new on(e,t,r)),this}setDocAttribute(e,t){return this.step(new Tr(e,t)),this}addNodeMark(e,t){return this.step(new Hn(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof Q)t.isInSet(r.marks)&&this.step(new rn(e,t));else{let o=r.marks,i,s=[];for(;i=t.isInSet(o);)s.push(new rn(e,i)),o=i.removeFromSet(o);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,t=1,r){return kb(this,e,t,r),this}addMark(e,t,r){return cb(this,e,t,r),this}removeMark(e,t,r){return ub(this,e,t,r),this}clearIncompatible(e,t,r){return el(this,e,t,r),this}};var nl=Object.create(null),U=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new cn(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=D.empty){let r=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=r,r=r.lastChild;let i=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?D.empty:t),l==0&&kp(e,i,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:s,$to:l}=o[i],a=e.mapping.slice(r),c=a.map(s.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),kp(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new F(e):Bn(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let i=e.depth-1;i>=0;i--){let s=t<0?Bn(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):Bn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new de(e.node(0))}static atStart(e){return Bn(e,e,0,0,1)||new de(e)}static atEnd(e){return Bn(e,e,e.content.size,e.childCount,-1)||new de(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=nl[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in nl)throw new RangeError("Duplicate use of selection JSON ID "+e);return nl[e]=t,t.prototype.jsonID=e,t}getBookmark(){return F.between(this.$anchor,this.$head).getBookmark()}};U.prototype.visible=!0;var cn=class{constructor(e,t){this.$from=e,this.$to=t}},yp=!1;function bp(n){!yp&&!n.parent.inlineContent&&(yp=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var F=class n extends U{constructor(e,t=e){bp(e),bp(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return U.near(r);let o=e.resolve(t.map(this.anchor));return new n(o.parent.inlineContent?o:r,r)}replace(e,t=D.empty){if(super.replace(e,t),t==D.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Io(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let i=U.findFrom(t,r,!0)||U.findFrom(t,-r,!0);if(i)t=i.$head;else return U.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(U.findFrom(e,-r,!0)||U.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new n(e,t)}};U.jsonID("text",F);var Io=class n{constructor(e,t){this.anchor=e,this.head=t}map(e){return new n(e.map(this.anchor),e.map(this.head))}resolve(e){return F.between(e.resolve(this.anchor),e.resolve(this.head))}},R=class n extends U{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),i=e.resolve(o);return r?U.near(i):new n(i)}content(){return new D(T.from(this.node),0,0)}eq(e){return e instanceof n&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ol(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new n(e.resolve(t.anchor))}static create(e,t){return new n(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};R.prototype.visible=!1;U.jsonID("node",R);var ol=class n{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Io(r,r):new n(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&R.isSelectable(r)?new R(t):U.near(t)}},de=class n extends U{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=D.empty){if(t==D.empty){e.delete(0,e.doc.content.size);let r=U.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new n(e)}map(e){return new n(e)}eq(e){return e instanceof n}getBookmark(){return Ab}};U.jsonID("all",de);var Ab={map(){return this},resolve(n){return new de(n)}};function Bn(n,e,t,r,o,i=!1){if(e.inlineContent)return F.create(n,t);for(let s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&R.isSelectable(l))return R.create(n,t-(o<0?l.nodeSize:0))}else{let a=Bn(n,l,t+o,o<0?l.childCount:0,o,i);if(a)return a}t+=l.nodeSize*o}return null}function kp(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof le||o instanceof re))return;let i=n.mapping.maps[r],s;i.forEach((l,a,c,u)=>{s==null&&(s=u)}),n.setSelection(U.near(n.doc.resolve(s),t))}var vp=1,_o=2,xp=4,Ho=class extends Et{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|vp)&~_o,this.storedMarks=null,this}get selectionSet(){return(this.updated&vp)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=_o,this}ensureMarks(e){return Q.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&_o)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~_o,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Q.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(t);i=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(U.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=xp,this}get scrolledIntoView(){return(this.updated&xp)>0}};function wp(n,e){return!e||!n?n:n.bind(e)}var an=class{constructor(e,t,r){this.name=e,this.init=wp(t.init,r),this.apply=wp(t.apply,r)}},Tb=[new an("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new an("selection",{init(n,e){return n.selection||U.atStart(e.doc)},apply(n){return n.selection}}),new an("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new an("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],Lr=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Tb.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new an(r.key,r.spec.state,r))})}},un=class n{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),o=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=o?o[s].n:0,c=o?o[s].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!o){o=[];for(let d=0;d<this.config.plugins.length;d++)o.push(d<s?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),i=!0}o&&(o[s]={state:r,n:t.length})}}if(!i)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new n(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let i=r[o];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new Ho(this)}static create(e){let t=new Lr(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new n(t);for(let o=0;o<t.fields.length;o++)r[t.fields[o].name]=t.fields[o].init(e,r);return r}reconfigure(e){let t=new Lr(this.schema,e.plugins),r=t.fields,o=new n(t);for(let i=0;i<r.length;i++){let s=r[i].name;o[s]=this.hasOwnProperty(s)?this[s]:r[i].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Lr(e.schema,e.plugins),i=new n(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=Te.fromJSON(e.schema,t.doc);else if(s.name=="selection")i.selection=U.fromJSON(i.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[s.name]=c.fromJSON.call(a,e,t[l],i);return}}i[s.name]=s.init(e,i)}}),i}};function Sp(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=Sp(o,e,{})),t[r]=o}return t}var z=class{constructor(e){this.spec=e,this.props={},e.props&&Sp(e.props,this,this.props),this.key=e.key?e.key.key:Mp("plugin")}getState(e){return e[this.key]}},rl=Object.create(null);function Mp(n){return n in rl?n+"$"+ ++rl[n]:(rl[n]=0,n+"$")}var X=class{constructor(e="key"){this.key=Mp(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var ll={};q(ll,{FOCUSABLE:()=>$t,activeElement:()=>te,eventTarget:()=>sl,formatShortcut:()=>At,h:()=>w,icon:()=>ee,isMac:()=>Cp,isRtl:()=>Fn,listenDocument:()=>ut,logicalKey:()=>Ne,uniqueId:()=>je});function w(n,e={},...t){let r=document.createElement(n);for(let[o,i]of Object.entries(e))i==null||i===!1||(typeof i=="function"?r.addEventListener(o.replace(/^on/,"").toLowerCase(),i):o==="className"?r.className=String(i):r.setAttribute(o,i===!0?"":String(i)));for(let o of t.flat())o==null||o===!1||r.append(o);return r}function ee(n){let e=document.createElement("span");return e.className="nova-icon",e.innerHTML=n,e}var Ep=0;function je(n="nova"){return Ep+=1,`${n}-${Ep}`}var Cp=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Nb={ArrowUp:"\u2191",ArrowDown:"\u2193",ArrowLeft:"\u2190",ArrowRight:"\u2192"};function At(n){let e=n.split("-"),t=e.pop(),r=t.length===1?t.toUpperCase():Nb[t]??t;if(Cp){let i={Mod:"\u2318",Shift:"\u21E7",Alt:"\u2325",Ctrl:"\u2303"};return e.map(s=>i[s]??s).join("")+r}let o={Mod:"Ctrl",Shift:"Shift",Alt:"Alt",Ctrl:"Ctrl"};return[...e.map(i=>o[i]??i),r].join("+")}var $t='a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function te(n){let e=n.getRootNode(),t=("activeElement"in e?e.activeElement:null)??document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}function sl(n){return n.composedPath?.()[0]??n.target}function ut(n,e,t){let r=n.getRootNode(),o=typeof ShadowRoot<"u"&&r instanceof ShadowRoot?r:null,i=l=>{o&&l.composedPath().includes(o.host)||t(l,sl(l))},s=l=>t(l,sl(l));return document.addEventListener(e,i,!0),o?.addEventListener(e,s,!0),()=>{document.removeEventListener(e,i,!0),o?.removeEventListener(e,s,!0)}}function Fn(n){return n.closest("[dir]")?.getAttribute("dir")?.toLowerCase()==="rtl"}function Ne(n,e){return n.key!=="ArrowLeft"&&n.key!=="ArrowRight"||!Fn(e)?n.key:n.key==="ArrowLeft"?"ArrowRight":"ArrowLeft"}var al={};q(al,{icons:()=>C});var A=n=>`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`,C={undo:A('<path d="M9 14 4 9l5-5" /><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" />'),redo:A('<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />'),bold:A('<path d="M6 12h9a4 4 0 010 8H7a1 1 0 01-1-1V5a1 1 0 011-1h7a4 4 0 010 8" />'),italic:A('<line x1="19" x2="10" y1="4" y2="4" /><line x1="14" x2="5" y1="20" y2="20" /><line x1="15" x2="9" y1="4" y2="20" />'),underline:A('<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />'),strike:A('<path d="M16 4H9a3 3 0 0 0-2.83 4" /><path d="M14 12a4 4 0 0 1 0 8H6" /><line x1="4" x2="20" y1="12" y2="12" />'),code:A('<path d="m16 18 6-6-6-6" /><path d="m8 6-6 6 6 6" />'),subscript:A('<path d="m4 5 8 8" /><path d="m12 5-8 8" /><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" />'),superscript:A('<path d="m4 19 8-8" /><path d="m12 19-8-8" /><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" />'),bulletList:A('<path d="M3 5h.01" /><path d="M3 12h.01" /><path d="M3 19h.01" /><path d="M8 5h13" /><path d="M8 12h13" /><path d="M8 19h13" />'),orderedList:A('<path d="M11 5h10" /><path d="M11 12h10" /><path d="M11 19h10" /><path d="M4 4h1v5" /><path d="M4 9h2" /><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" />'),indent:A('<path d="M21 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m3 8 4 4-4 4" />'),outdent:A('<path d="M21 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m7 8-4 4 4 4" />'),blockquote:A('<path d="M17 5H3" /><path d="M21 12H8" /><path d="M21 19H8" /><path d="M3 12v7" />'),codeBlock:A('<path d="m10 9-3 3 3 3" /><path d="m14 15 3-3-3-3" /><rect x="3" y="3" width="18" height="18" rx="2" />'),alignLeft:A('<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />'),alignCenter:A('<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />'),alignRight:A('<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />'),alignJustify:A('<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />'),horizontalRule:A('<path d="m16 16-4 4-4-4" /><path d="M3 12h18" /><path d="m8 8 4-4 4 4" />'),link:A('<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" /><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />'),unlink:A('<path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71" /><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71" /><line x1="8" x2="8" y1="2" y2="5" /><line x1="2" x2="5" y1="8" y2="8" /><line x1="16" x2="16" y1="19" y2="22" /><line x1="19" x2="22" y1="16" y2="16" />'),image:A('<rect width="18" height="18" x="3" y="3" rx="2" ry="2" /><circle cx="9" cy="9" r="2" /><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" />'),clearFormatting:A('<path d="M4 7V4h16v3" /><path d="M5 20h6" /><path d="M13 4 8 20" /><path d="m15 15 5 5" /><path d="m20 15-5 5" />'),formatMore:A('<path d="M12 4v16" /><path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" /><path d="M9 20h6" />'),imageLeft:A('<rect width="9" height="6" x="6" y="14" rx="2" /><rect width="16" height="6" x="6" y="4" rx="2" /><path d="M2 2v20" />'),imageCenter:A('<path d="M12 2v20" /><path d="M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4" /><path d="M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4" /><path d="M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1" /><path d="M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1" />'),imageRight:A('<rect width="16" height="6" x="2" y="4" rx="2" /><rect width="9" height="6" x="9" y="14" rx="2" /><path d="M22 22V2" />'),resize:A('<path d="M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" /><path d="M14 15H9v-5" /><path d="M16 3h5v5" /><path d="M21 3 9 15" />'),altText:A('<rect width="18" height="14" x="3" y="5" rx="2" ry="2" /><path d="M7 15h4M15 15h2M7 11h2M13 11h4" />'),imageCaption:A('<rect width="18" height="14" x="3" y="5" rx="2" ry="2" /><path d="M7 15h4M15 15h2M7 11h2M13 11h4" />'),trash:A('<path d="M10 11v6" /><path d="M14 11v6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M3 6h18" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />'),paragraph:A('<path d="M13 4v16" /><path d="M17 4v16" /><path d="M19 4H9.5a4.5 4.5 0 0 0 0 9H13" />'),h1:A('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="m17 12 3-2v8" />'),h2:A('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1" />'),h3:A('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2" /><path d="M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2" />'),pasteText:A('<rect width="8" height="4" x="8" y="2" rx="1" ry="1" /><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" /><path d="M9 12v-1h6v1" /><path d="M11 17h2" /><path d="M12 11v6" />'),table:A('<path d="M12 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" />'),rowBefore:A('<path d="M12 2v6" /><path d="M18.464 3H19a2 2 0 012 2v14a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h.535" /><path d="M21 12H3" /><path d="M9 5h6" />'),rowAfter:A('<path d="M12 22v-6" /><path d="M18.464 21H19a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h.535" /><path d="M21 12H3" /><path d="M9 19h6" />'),rowDelete:A('<path d="M16 5H3" /><path d="M11 12H3" /><path d="M16 19H3" /><path d="m15.5 9.5 5 5" /><path d="m20.5 9.5-5 5" />'),colBefore:A('<path d="M12 3v18" /><path d="M3 5.536V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-.535" /><path d="M5 15V9" /><path d="M8 12H2" />'),colAfter:A('<path d="M12 3v18" /><path d="M16 12h6" /><path d="M19 15V9" /><path d="M21 5.536V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-.535" />'),colDelete:A('<g transform="rotate(90 12 12)"><path d="M16 5H3" /><path d="M11 12H3" /><path d="M16 19H3" /><path d="m15.5 9.5 5 5" /><path d="m20.5 9.5-5 5" /></g>'),merge:A('<path d="M12 21v-6" /><path d="M12 9V3" /><path d="M3 15h18" /><path d="M3 9h18" /><rect width="18" height="18" x="3" y="3" rx="2" />'),split:A('<path d="M12 15V9" /><path d="M3 15h18" /><path d="M3 9h18" /><rect width="18" height="18" x="3" y="3" rx="2" />'),rowHeader:A('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" />'),colHeader:A('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M9 3v18" />'),sort:A('<path d="m3 16 4 4 4-4" /><path d="M7 20V4" /><path d="M11 4h10" /><path d="M11 8h7" /><path d="M11 12h4" />'),tableProps:A('<path d="M15 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M21 9H3" /><path d="M21 15H3" />'),cellProps:A('<path d="M10.6 21H5a2 2 0 01-2-2V5a2 2 0 012-2h14a2 2 0 012 2v5.6" /><path d="m14.305 19.53.923-.382" /><path d="M15 3v7.6" /><path d="m15.229 16.852-.924-.383" /><path d="m16.852 15.228-.383-.923" /><path d="m16.852 20.772-.383.924" /><path d="m19.148 15.228.383-.923" /><path d="m19.53 21.696-.382-.924" /><path d="m20.773 16.852.922-.383" /><path d="m20.773 19.148.922.383" /><path d="M9 3v18" /><circle cx="18" cy="18" r="3" />'),tableDelete:A('<path d="M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3" /><path d="m16.5 16.5 5 5" /><path d="m16.5 21.5 5-5" />'),chevronUp:A('<path d="m18 15-6-6-6 6" />'),search:A('<path d="m21 21-4.34-4.34" /><circle cx="11" cy="11" r="8" />'),fullscreen:A('<path d="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" />'),fullscreenExit:A('<path d="M8 3v3a2 2 0 0 1-2 2H3" /><path d="M21 8h-3a2 2 0 0 1-2-2V3" /><path d="M3 16h3a2 2 0 0 1 2 2v3" /><path d="M16 21v-3a2 2 0 0 1 2-2h3" />'),preview:A('<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" /><circle cx="12" cy="12" r="3" />'),sourceCode:A('<path d="m18 16 4-4-4-4" /><path d="m6 8-4 4 4 4" /><path d="m14.5 4-5 16" />'),help:A('<circle cx="12" cy="12" r="10" /><path d="M9 9.5a3 2.5 0 016 0c0 2-2 2-3 3.5" /><path d="M12 17h.01" />'),print:A('<path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2" /><path d="M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6" /><rect x="6" y="14" width="12" height="8" rx="1" />'),check:A('<path d="M20 6 9 17l-5-5" />'),close:A('<path d="M18 6 6 18" /><path d="m6 6 12 12" />'),chevronDown:A('<path d="m6 9 6 6 6-6" />'),more:A('<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />'),textColor:A('<path d="M4 20h16" /><path d="m6 16 6-12 6 12" /><path d="M8 12h8" />'),highlight:A('<path d="m9 11-6 6v3h9l3-3" /><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4" />'),lineHeight:A('<path d="M15 14H9" /><path d="M21 21H3" /><path d="M21 3H3" /><path d="m8 16 3.453-7.648a.6.6 0 011.094.001L16 16" />'),language:A('<path d="m5 8 6 6" /><path d="m4 14 6-6 2-3" /><path d="M2 5h12" /><path d="M7 2h1" /><path d="m22 22-5-10-5 10" /><path d="M14 18h6" />'),upload:A('<path d="M12 3v12" /><path d="m17 8-5-5-5 5" /><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />'),externalLink:A('<path d="M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6" /><path d="m21 3-9 9" /><path d="M15 3h6v6" />'),copy:A('<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />'),edit:A('<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" /><path d="m15 5 4 4" />'),resizeHandle:A('<circle cx="12" cy="9" r="1" /><circle cx="19" cy="9" r="1" /><circle cx="5" cy="9" r="1" /><circle cx="12" cy="15" r="1" /><circle cx="19" cy="15" r="1" /><circle cx="5" cy="15" r="1" />'),browse:A('<path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2" />'),mergeTags:A('<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1" /><path d="M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1" />'),resizeHandleBoth:A('<path d="M19 13v6h-6" /><path d="M5 11V5h6" /><path d="m5 5 14 14" />'),sidebar:A('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M15 3v18" />'),anchor:A('<path d="M12 6v16" /><path d="m19 13 2-1a9 9 0 0 1-18 0l2 1" /><path d="M9 11h6" /><circle cx="12" cy="4" r="2" />'),save:A('<path d="M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z" /><path d="M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7" /><path d="M7 3v4a1 1 0 0 0 1 1h7" />'),charmap:A('<path d="M3 20h4.5a.5.5 0 0 0 .5-.5v-.282a.52.52 0 0 0-.247-.437 8 8 0 1 1 8.494-.001.52.52 0 0 0-.247.438v.282a.5.5 0 0 0 .5.5H21" />'),commentAdd:A('<path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z" /><path d="M12 8v6" /><path d="M9 11h6" />'),comments:A('<path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z" /><path d="M7 11h10" /><path d="M7 15h6" /><path d="M7 7h8" />'),emoji:A('<path d="M15 10V9" /><path d="M16.472 15a6 6 0 01-8.943 0" /><path d="M9 10V9" /><circle cx="12" cy="12" r="10" />'),dateTime:A('<path d="M16 2v3" /><path d="M17 15.5v1.7l1 .625" /><path d="M21 8.936V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h3.935" /><path d="M3 9h9.873" /><path d="M8 2v3" /><circle cx="17" cy="17" r="5" />'),media:A('<rect x="3" y="3" width="18" height="18" rx="2" /><path d="M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z" />'),checklist:A('<path d="M13 5h8" /><path d="M13 12h8" /><path d="M13 19h8" /><path d="m3 17 2 2 4-4" /><rect x="3" y="4" width="6" height="6" rx="1" />'),codeSample:A('<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /><path d="M14 2v5a1 1 0 0 0 1 1h5" /><path d="M10 12.5 8 15l2 2.5" /><path d="m14 12.5 2 2.5-2 2.5" />'),dragHandle:A('<circle cx="9" cy="12" r="1" /><circle cx="9" cy="5" r="1" /><circle cx="9" cy="19" r="1" /><circle cx="15" cy="12" r="1" /><circle cx="15" cy="5" r="1" /><circle cx="15" cy="19" r="1" />'),accordion:A('<path d="M10 5h11" /><path d="M10 12h11" /><path d="M10 19h11" /><path d="m3 10 3-3-3-3" /><path d="m3 20 3-3-3-3" />'),tableOfContents:A('<path d="M16 5H3" /><path d="M16 12H3" /><path d="M16 19H3" /><path d="M21 5h.01" /><path d="M21 12h.01" /><path d="M21 19h.01" />'),math:A('<path d="M18 7V5a1 1 0 0 0-1-1H6.5a.5.5 0 0 0-.4.8l4.5 6a2 2 0 0 1 0 2.4l-4.5 6a.5.5 0 0 0 .4.8H17a1 1 0 0 0 1-1v-2" />'),duplicate:A('<line x1="15" x2="15" y1="12" y2="18" /><line x1="12" x2="18" y1="15" y2="15" /><rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />'),nonBreaking:A('<path d="M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1" />'),pageBreak:A('<path d="M5.42 9.42 8 12" /><circle cx="4" cy="8" r="2" /><path d="m14 6-8.58 8.58" /><circle cx="4" cy="16" r="2" /><path d="M10.8 14.8 14 18" /><path d="M16 12h-2" /><path d="M22 12h-2" />'),history:A('<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /><path d="M12 7v5l4 2" />'),suggest:A('<path d="M13 21h8" /><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" />'),review:A('<path d="M13 5h8" /><path d="M13 12h8" /><path d="M13 19h8" /><path d="m3 17 2 2 4-4" /><path d="m3 7 2 2 4-4" />'),visualBlocks:A('<path d="M5 3a2 2 0 0 0-2 2" /><path d="M19 3a2 2 0 0 1 2 2" /><path d="M21 19a2 2 0 0 1-2 2" /><path d="M5 21a2 2 0 0 1-2-2" /><path d="M9 3h1" /><path d="M9 21h1" /><path d="M14 3h1" /><path d="M14 21h1" /><path d="M3 9v1" /><path d="M21 9v1" /><path d="M3 14v1" /><path d="M21 14v1" />'),ltr:A('<path d="M10 3v11" /><path d="M10 9H7a1 1 0 0 1 0-6h8" /><path d="M14 3v11" /><path d="m18 14 4 4H2" /><path d="m22 18-4 4" />'),rtl:A('<path d="M14 3v11" /><path d="M14 9h-3a3 3 0 0 1 0-6h9" /><path d="M18 3v11" /><path d="M22 18H2l4-4" /><path d="m6 22-4-4" />'),caseChange:A('<path d="m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16" /><path d="M22 9v7" /><path d="M3.304 13h6.392" /><circle cx="18.5" cy="12.5" r="3.5" />'),formatPainter:A('<path d="m14.622 17.897-10.68-2.913" /><path d="M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z" /><path d="M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15" />'),permanentPen:A('<path d="m9 11-6 6v3h9l3-3" /><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4" />'),visualChars:A('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M12 12H9.5a2.5 2.5 0 0 1 0-5H17" /><path d="M12 7v10" /><path d="M16 7v10" />'),cancelChanges:A('<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" />'),template:A('<rect width="18" height="7" x="3" y="3" rx="1" /><rect width="9" height="7" x="3" y="14" rx="1" /><rect width="5" height="7" x="16" y="14" rx="1" />'),footnote:A('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M12 8v8" /><path d="m8.5 14 7-4" /><path d="m8.5 10 7 4" />'),footnotesUpdate:A('<path d="M21 5H3" /><path d="M7 12H3" /><path d="M7 19H3" /><path d="M12 18a5 5 0 0 0 9-3 4.5 4.5 0 0 0-4.5-4.5c-1.33 0-2.54.54-3.41 1.41L11 14" /><path d="M11 10v4h4" />')};var Ap='.nova-details{position:relative;margin:0 0 .75em;padding-block:6px;padding-inline:34px 12px;border:1px solid var(--nova-border);border-radius:var(--nova-radius-sm)}.nova-details-toggle{position:absolute;top:7px;inset-inline-start:6px;display:flex;align-items:center;justify-content:center;width:22px;height:22px;padding:0;border:0;border-radius:4px;background:none;color:var(--nova-muted);cursor:pointer}.nova-details-toggle:hover{background:var(--nova-hover);color:var(--nova-fg)}.nova-details-toggle:focus-visible{outline:2px solid var(--nova-accent);outline-offset:1px}.nova-details-toggle svg{width:16px;height:16px;transition:transform .12s ease}.nova-details:not(.nova-details-open)>.nova-details-toggle svg{transform:rotate(-90deg)}[dir=rtl] .nova-details:not(.nova-details-open)>.nova-details-toggle svg{transform:rotate(90deg)}.nova-details-content>summary{position:relative;display:block;margin:0;font-weight:600;cursor:text;list-style:none}.nova-details-content>summary::-webkit-details-marker{display:none}.nova-details-content>summary:has(>br.ProseMirror-trailingBreak:only-child):before{content:var(--nova-summary-placeholder, "");position:absolute;color:var(--nova-muted);font-weight:400;pointer-events:none}.nova-details-open>.nova-details-content>summary{margin-bottom:.4em}.nova-details:not(.nova-details-open)>.nova-details-content>:not(summary){display:none}.nova-details-content>:last-child{margin-bottom:0}.nova-details.ProseMirror-selectednode{outline:2px solid var(--nova-accent);outline-offset:2px}@media(prefers-reduced-motion:reduce){.nova-details-toggle svg{transition:none}}';var ul={};q(ul,{insertText:()=>Pb,openSymbolDialog:()=>Db,pickLabels:()=>Oe,symbolPanel:()=>Rb});var dn={"toolbar.label":"Formatting","toolbar.options":"options","editor.label":"Rich text editor","editor.required":"Please fill in this field.",undo:"Undo",redo:"Redo",bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strikethrough",code:"Inline code",subscript:"Subscript",superscript:"Superscript",link:"Link",unlink:"Remove link",image:"Image",bulletList:"Bulleted list",orderedList:"Numbered list",indent:"Increase indent",outdent:"Decrease indent",align:"Alignment",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",alignJustify:"Justify",blockquote:"Quote",codeBlock:"Code block",moveBlockUp:"Move block up",moveBlockDown:"Move block down",horizontalRule:"Horizontal line",clearFormatting:"Clear formatting",more:"More",moreFormats:"More formatting",blocks:"Text style",styles:"Formats","styles.headings":"Headings","styles.inline":"Inline","styles.blocks":"Blocks","styles.align":"Align",paragraph:"Paragraph",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",fontFamily:"Font",fontSize:"Font size",lineHeight:"Line height",language:"Language","language.default":"Default language","language.field":"Language of the selected text",default:"Default",textColor:"Text color",backgroundColor:"Highlight color",removeColor:"Remove color",customColor:"Custom color","dialog.cancel":"Cancel","dialog.save":"Save","dialog.insert":"Insert","dialog.close":"Close","dialog.required":"This field is required","dialog.invalid":"Check the format","link.title":"Insert link","link.editTitle":"Edit link","link.url":"URL","link.text":"Text to display","link.tooltip":"Title (tooltip)","link.newTab":"Open in new tab","link.open":"Open link","link.edit":"Edit link","link.copy":"Copy link","link.copied":"Link copied","link.invalid":"This URL is not allowed","image.title":"Insert image","image.url":"Image URL","image.alt":"Alternative text","image.altHint":"Describe the image for people using screen readers","image.upload":"Upload","image.drop":"Drop an image here or click to choose","image.uploading":"Uploading image\u2026","image.uploadFailed":"Image upload failed","image.retry":"Retry","image.retrying":"Connection problem \u2014 retrying the upload\u2026","image.invalid":"This image URL is not allowed","image.or":"or","image.toolbar":"Image options","image.alignLeft":"Float left","image.alignCenter":"Center","image.alignRight":"Float right","image.editAlt":"Alternative text","image.size":"Size","image.sizeSmall":"Small (25%)","image.sizeMedium":"Medium (50%)","image.sizeLarge":"Large (75%)","image.sizeFull":"Full width","image.sizeOriginal":"Original size","image.delete":"Remove image","image.caption":"Caption","image.captionPlaceholder":"Add a caption\u2026","status.words":"{count} words","announce.on":"{name} on","announce.off":"{name} off","status.resize":"Resize editor","dialog.browse":"Browse","dialog.dropFiles":"Drop files here or","dialog.fileType":"This file type is not allowed","dialog.fileTooLarge":"The file is too large","dialog.removeFile":"Remove",pasteAsText:"Paste as text","menu.label":"Menu","menu.file":"File","menu.edit":"Edit","menu.view":"View","menu.insert":"Insert","menu.format":"Format","menu.table":"Table","menu.tools":"Tools","menu.help":"Help",selectAll:"Select all",print:"Print","table.rows":"Rows","table.cols":"Columns","table.invalidSize":"Enter a number from 1 to 50","quickbars.selection":"Quick formatting","quickbars.insert":"Quick insert","search.title":"Find and replace","search.find":"Find","search.replace":"Replace with","search.next":"Next match","search.prev":"Previous match","search.replaceOne":"Replace","search.replaceAll":"Replace all","search.matchCase":"Match case","search.wholeWord":"Whole words only","search.count":"{current} of {total}","search.none":"No results",fullscreen:"Fullscreen",preview:"Preview",sourceCode:"Source code",help:"Keyboard shortcuts","help.formatting":"Text formatting","help.blocks":"Paragraphs and lists","help.editing":"Editing","help.navigation":"Navigation","help.slash":"Insert block (slash commands)","help.toMenubar":"Move to the menu bar","help.toToolbar":"Move to the toolbar","help.toContextToolbar":"Move to the image/table toolbar","help.toEditor":"Back to the text","help.nextCell":"Next table cell",table:"Table","table.insert":"Insert table","table.size":"{rows} \xD7 {cols}","table.toolbar":"Table options","table.rowBefore":"Insert row above","table.rowAfter":"Insert row below","table.rowDelete":"Delete row","table.colBefore":"Insert column left","table.colAfter":"Insert column right","table.colDelete":"Delete column","table.merge":"Merge cells","table.split":"Split cell","table.rowHeader":"Header row","table.colHeader":"Header column","table.cellBackground":"Cell background","table.delete":"Delete table","table.sort":"Sort","table.sortAsc":"Sort A \u2192 Z, 1 \u2192 9","table.sortDesc":"Sort Z \u2192 A, 9 \u2192 1","table.props":"Table properties","table.style":"Style","table.styleDefault":"Default","table.width":"Width","table.widthHint":"For example 100% or 600px. Leave empty to fit the content.","table.invalidWidth":"Enter a width such as 100% or 600px","table.align":"Alignment on the page","table.alignDefault":"Default","table.alignCenter":"Center","table.alignRight":"Right","table.cellProps":"Cell properties","table.valign":"Vertical alignment","table.valignTop":"Top","table.valignMiddle":"Middle","table.valignBottom":"Bottom","table.cellType":"Cell type","table.cellData":"Data cell","table.cellHeader":"Header cell","table.colWidth":"Column width, px","table.colWidthHint":"Leave empty to fit the content.","table.invalidColWidth":"Enter a number from 24 to 4000","slash.label":"Commands","slash.empty":"No matching commands"};var zn={},Pr={en:dn},Tp=new Set,Fo={};function Lb(n){let e={};for(let[t,r]of Object.entries(n))typeof r=="string"?e[t]=r:r.forEach((o,i)=>e[`${t}.${i}`]=o);return e}var $n={},Bo={};function Op(n,e,t=!1){zn[n]=t?{...e,...zn[n]}:{...zn[n],...e},Pr[n]={...dn,...zn[n]}}function Vt(n,e){let t=n.toLowerCase();typeof e=="function"?$n[t]=e:Op(t,e)}function Lp(n){let e=n.toLowerCase();return e in Pr||e.split("-")[0]in Pr}function cl(n){let e=n.toLowerCase(),t=e.split("-")[0],r=e in $n?e:t in $n?t:null;return r?Bo[r]??(Bo[r]=$n[r]().then(o=>(Op(r,o.default??o,!0),!0),o=>{throw Bo[r]=void 0,o})):Promise.resolve(Lp(e))}function Pp(n,e){let t=Fo[n]??(Fo[n]={});for(let[r,o]of Object.entries(e))o&&(t[r]={...t[r],...Lb(o)})}var Np=(n,e)=>e?n.replace(/\{(\w+)\}/g,(t,r)=>String(e[r]??`{${r}}`)):n;function Rp(n="en",e={}){let t=n.toLowerCase(),r=t.split("-")[0],o=Pr[t]??Pr[r]??dn;o===dn&&r!=="en"&&!Tp.has(r)&&(Tp.add(r),console.warn(t in $n||r in $n?`[nova] language "${n}" is not loaded yet, using English. Load it before creating the editor: await loadLanguage('${n}');`:`[nova] language "${n}" is not registered, using English. import pack from '@novaprose/core/i18n/${r}'; registerLanguage('${r}', pack);`));let i={...dn,...o,...e},s={...zn[r],...zn[t]},l=e;return(a,c)=>{let u=i[a];if(u!==void 0)return Np(u,c);let d=a.indexOf("."),p=d>0?Fo[a.slice(0,d)]:void 0,f=a.slice(d+1),h=l[a]??s[a]??p?.[t]?.[f]??p?.[r]?.[f]??p?.en?.[f]??a;return Np(h,c)}}function Oe(n,e,t){Pp(e,t);let r={};for(let[o,i]of Object.entries(t.en))r[o]=typeof i=="string"?n.ui.t(`${e}.${o}`):i.map((s,l)=>n.ui.t(`${e}.${o}.${l}`));return r}function Pb(n,e){let{state:t,dispatch:r}=n.view;r(t.tr.insertText(e).scrollIntoView()),n.focus()}function Rb(n){let e=w("input",{type:"search",className:"nova-input nova-symbols-search",placeholder:n.searchLabel,"aria-label":n.searchLabel}),t=w("div",{className:"nova-symbols-list"}),r=w("div",{className:`nova-symbols ${n.className}`},e,t),o=i=>{let s=i.trim().toLowerCase(),l=n.groups.map(a=>({title:a.title,items:s?a.items.filter(([c,u])=>u.includes(s)||c===s):a.items})).filter(a=>a.items.length);if(!l.length){t.replaceChildren(w("div",{className:"nova-symbols-empty"},n.emptyText));return}t.replaceChildren(...l.map(a=>w("div",{className:"nova-symbols-group",role:"group","aria-label":a.title},w("div",{className:"nova-symbols-title"},a.title),w("div",{className:"nova-symbols-grid"},...a.items.map(([c,u])=>w("button",{type:"button",className:"nova-symbols-cell",title:u,"aria-label":u,onclick:()=>n.onPick(c)},c))))))};return e.addEventListener("input",()=>o(e.value)),e.addEventListener("keydown",i=>{i.key==="ArrowDown"?(i.preventDefault(),t.querySelector(".nova-symbols-cell")?.focus()):i.key==="Enter"&&(i.preventDefault(),t.querySelector(".nova-symbols-cell")?.click())}),t.addEventListener("keydown",i=>{let s=[...t.querySelectorAll(".nova-symbols-cell")],l=s.indexOf(te(t));if(l<0)return;let a=Math.max(1,s.filter(p=>p.offsetTop===s[0].offsetTop).length),c={ArrowRight:1,ArrowLeft:-1,ArrowDown:a,ArrowUp:-a},u=Ne(i,t);if(!(u in c))return;i.preventDefault();let d=l+c[u];d<0?e.focus():s[Math.min(s.length-1,d)]?.focus()}),o(""),queueMicrotask(()=>e.focus()),r}function Db(n,e,t){let r=null,o=t(()=>r?.close());r=n.ui.openDialog({title:e,body:o,cancelLabel:n.ui.t("dialog.close")})}var dl={en:{accordion:"Accordion",summary:"Summary",expand:"Expand",collapse:"Collapse"}};function _b(n){let e=n.options.pluginOptions?.accordion??{},t=e.initialState??"inherited",r=e.serializedState??"inherited";return{details:{group:"block",content:"details_summary block+",defining:!0,attrs:{open:{default:!0}},parseDOM:[{tag:"details",getAttrs:o=>({open:t==="inherited"?o.hasAttribute("open"):t==="expanded"})}],toDOM:o=>["details",(r==="inherited"?o.attrs.open!==!1:r==="expanded")?{open:""}:{},0]},details_summary:{content:"inline*",defining:!0,isolating:!0,parseDOM:[{tag:"summary",context:"details/"}],toDOM:()=>["summary",0]}}}function Ib(n){for(let e=n.depth;e>0;e--){let t=n.node(e);if(t.type.name==="details")return{node:t,pos:n.before(e)}}return null}var pl=n=>n.attrs.open!==!1,fl=n=>n.pos+2+n.node.firstChild.content.size;function Dp(n,e,t){return n.setNodeAttribute(e.pos,"open",t).setMeta("addToHistory",!1)}var hl=class{constructor(e,t,r,o){S(this,"node",e);S(this,"labels",o);S(this,"dom");S(this,"contentDOM");S(this,"toggle");this.toggle=w("button",{type:"button",className:"nova-details-toggle",contentEditable:"false",tabIndex:-1}),this.toggle.append(ee(C.chevronDown)),this.toggle.addEventListener("mousedown",i=>i.preventDefault()),this.toggle.addEventListener("click",()=>{let i=r();if(i===void 0)return;let s=t.state.doc.nodeAt(i);if(s?.type.name!=="details")return;let l={node:s,pos:i},a=pl(s),c=Dp(t.state.tr,l,!a),{from:u}=t.state.selection;a&&u>fl(l)&&u<i+s.nodeSize&&c.setSelection(F.create(c.doc,fl(l))),t.dispatch(c)}),this.contentDOM=w("div",{className:"nova-details-content"}),this.dom=w("div",{className:"nova-details"},this.toggle,this.contentDOM),this.sync()}sync(){let e=pl(this.node);this.dom.classList.toggle("nova-details-open",e),this.toggle.setAttribute("aria-expanded",String(e)),this.toggle.setAttribute("aria-label",e?this.labels.collapse:this.labels.expand)}update(e){return e.type!==this.node.type?!1:(this.node=e,this.sync(),!0)}stopEvent(e){return e.target instanceof Node&&this.toggle.contains(e.target)}ignoreMutation(e){return e.type!=="selection"&&!this.contentDOM.contains(e.target)}},ml={name:"accordion",nodes:_b,prosemirrorPlugins:n=>{let e=Oe(n,"accordion",dl);return[new z({key:new X("nova-accordion"),props:{nodeViews:{details:(t,r,o)=>new hl(t,r,o,e)}}})]},setup(n){n.ui.addStyles("nova-accordion",Ap);let{summary:e}=Oe(n,"accordion",dl);n.root.style.setProperty("--nova-summary-placeholder",JSON.stringify(e))},load:()=>import(__novaChunk("tinymce-chunks/accordion-ui-4272c63b.js") )};var yl={};q(yl,{ELEMENT_ID_RE:()=>zo,elementId:()=>Vn});var zo=/^[A-Za-z][\w.-]{0,63}$/;function Vn(n){return typeof n=="string"&&zo.test(n)?n:null}var bl=zo,_p={name:"anchor",toolbar:"anchor",nodes:{anchor:{group:"inline",inline:!0,atom:!0,selectable:!0,attrs:{id:{}},parseDOM:[{tag:"a[id]:not([href])",getAttrs:n=>{let e=n.getAttribute("id")??"";return bl.test(e)?{id:e}:!1}},{tag:"a[name]:not([href])",getAttrs:n=>{let e=n.getAttribute("name")??"";return bl.test(e)?{id:e}:!1}}],toDOM:n=>["a",{id:bl.test(n.attrs.id)?n.attrs.id:null}]}},load:()=>import(__novaChunk("tinymce-chunks/anchor-ui-da0966bb.js") )};var vl={};q(vl,{LABELS:()=>Bp,default:()=>kl,loadTemml:()=>Fp,mathLatex:()=>qn,renderMath:()=>zp});var Ip='.nova-math{border-radius:4px;cursor:pointer}.nova-math-inline{display:inline-block;padding:0 2px}.nova-math-block{display:block;margin:0 0 .75em;padding:6px 8px;overflow-x:auto;text-align:center}.nova-math:hover{background:var(--nova-hover)}.nova-math.is-selected{outline:2px solid var(--nova-accent)}.nova-math:not(:has(math)){font-family:var(--nova-mono);font-size:.9em}.nova-math-error{color:var(--nova-danger);text-decoration:underline wavy;text-underline-offset:3px}.nova-math-empty:before{content:var(--nova-math-empty, "");color:var(--nova-muted);font-family:var(--nova-font)}.nova-math-preview{min-height:2.5em;padding:8px;overflow-x:auto;border:1px dashed var(--nova-border);border-radius:var(--nova-radius-sm);text-align:center}';var Bp={en:{empty:"Formula"}};function qn(n){return typeof n=="string"?n.slice(0,1e4):""}var $o=null;function Fp(){return $o??($o=import(__novaChunk("tinymce-chunks/temml-d637f801.js") ).then(n=>n.default,n=>($o=null,console.warn("[nova] math: could not load the formula renderer",n),null))),$o}function zp(n,e,t,r){try{return n.render(e,t,{displayMode:r,throwOnError:!0,trust:!1,annotate:!0}),null}catch(o){return t.textContent=e,o instanceof Error?o.message.replace(/^ParseError:\s*/,""):String(o)}}function Hp(n){let e=n?"block-math":"inline-math",t=n?"div":"span";return{...n?{group:"block"}:{group:"inline",inline:!0},atom:!0,selectable:!0,draggable:!0,attrs:{latex:{default:""}},parseDOM:[{tag:`${t}[data-type="${e}"]`,getAttrs:r=>({latex:qn(r.getAttribute("data-latex"))})}],toDOM:r=>{let o=qn(r.attrs.latex);return[t,{"data-type":e,"data-latex":o},n?`\\[${o}\\]`:`\\(${o}\\)`]},leafText:r=>n?`$$${qn(r.attrs.latex)}$$`:`$${qn(r.attrs.latex)}$`}}var Vo=class{constructor(e,t,r,o){S(this,"node",e);S(this,"view",t);S(this,"getPos",r);S(this,"editor",o);S(this,"dom");S(this,"latex","");let i=e.type.name==="math_block";this.dom=document.createElement(i?"div":"span"),this.dom.className=`nova-math ${i?"nova-math-block":"nova-math-inline"}`,this.dom.contentEditable="false",this.dom.addEventListener("click",()=>this.edit()),this.render()}render(){let e=qn(this.node.attrs.latex);if(e===this.latex&&this.dom.childNodes.length)return;this.latex=e;let t=this.node.type.name==="math_block";this.dom.classList.toggle("nova-math-empty",!e.trim()),this.dom.textContent=e.trim()?e:"",e.trim()&&Fp().then(r=>{if(!r||this.latex!==e)return;let o=zp(r,e,this.dom,t);this.dom.classList.toggle("nova-math-error",!!o),o?this.dom.title=o:this.dom.removeAttribute("title")})}edit(){let e=this.getPos();if(e===void 0||!this.editor.isEditable())return;this.view.dispatch(this.view.state.tr.setSelection(R.create(this.view.state.doc,e)));let t=this.editor.ui.registry.get("math");t?.type==="button"&&t.onAction(this.editor)}update(e){return e.type!==this.node.type?!1:(this.node=e,this.render(),!0)}selectNode(){this.dom.classList.add("is-selected")}deselectNode(){this.dom.classList.remove("is-selected")}ignoreMutation(){return!0}},kl={name:"math",nodes:{math_inline:Hp(!1),math_block:Hp(!0)},prosemirrorPlugins:n=>[new z({key:new X("nova-math"),props:{nodeViews:{math_inline:(e,t,r)=>new Vo(e,t,r,n),math_block:(e,t,r)=>new Vo(e,t,r,n)}}})],setup(n){n.ui.addStyles("nova-math",Ip);let{empty:e}=Oe(n,"math",Bp);n.root.style.setProperty("--nova-math-empty",JSON.stringify(e))},load:()=>import(__novaChunk("tinymce-chunks/math-ui-1b57f7eb.js") )};var Sl={};q(Sl,{LABELS:()=>Vp,default:()=>wl,tocEntries:()=>xl,tocSettings:()=>qp});var $p='.nova-prosemirror nav[data-toc]{margin:0 0 .75em;padding:10px 14px;border-inline-start:3px solid var(--nova-accent);border-radius:var(--nova-radius-sm);background:var(--nova-code-bg)}.nova-prosemirror nav[data-toc]>:is(p,h1,h2,h3,h4,h5,h6):first-child{margin:0 0 6px;font-size:1em;font-weight:600}.nova-prosemirror nav[data-toc] :is(ul,ol){margin:0;padding-inline-start:1.2em}.nova-prosemirror nav[data-toc]>:is(ul,ol){padding-inline-start:0}.nova-prosemirror nav[data-toc] ul{list-style:none}.nova-prosemirror nav[data-toc] li{margin:2px 0}.nova-prosemirror nav[data-toc] a{color:var(--nova-accent);text-decoration:none;cursor:pointer}.nova-prosemirror nav[data-toc] a:hover{text-decoration:underline}.nova-prosemirror nav[data-toc]:not(:has(a)):after{content:var(--nova-toc-empty, "");color:var(--nova-muted)}.nova-prosemirror nav[data-toc].ProseMirror-selectednode{outline:2px solid var(--nova-accent);outline-offset:2px}';var Vp={en:{title:"Contents",insert:"Table of contents",update:"Update table of contents",empty:"Add headings \u2014 they will appear here"}},Fb=/^[A-Za-z_][\w-]{0,63}$/;function qp(n){let e=n.options.pluginOptions?.tableofcontents??{},t=Number(e.depth);return{depth:Number.isInteger(t)&&t>=1&&t<=6?t:3,className:typeof e.className=="string"&&Fb.test(e.className)?e.className:"nova-toc",titleTag:typeof e.titleTag=="string"&&/^(p|h[1-6])$/i.test(e.titleTag)?e.titleTag.toLowerCase():"p",title:typeof e.title=="string"?e.title.slice(0,200):null,list:e.orderedList?"ol":"ul"}}function xl(n){if(!Array.isArray(n))return[];let e=[];for(let t of n.slice(0,1e3)){if(!t||typeof t!="object")continue;let{level:r,id:o,text:i}=t,s=Number(r),l=Vn(o);!Number.isInteger(s)||s<1||s>6||!l||typeof i!="string"||e.push({level:s,id:l,text:i.slice(0,300)})}return e}function zb(n,e){if(!n.length)return null;let t=[e],r=[{level:n[0].level,list:t,last:null}];for(let o of n){let i=r[r.length-1];if(o.level>i.level&&i.last){let l=[e];i.last.push(l),r.push({level:o.level,list:l,last:null})}else for(;r.length>1&&o.level<r[r.length-1].level;)r.pop();i=r[r.length-1];let s=["li",["a",{href:`#${o.id}`},o.text]];i.list.push(s),i.last=s}return t}function $b(n){let e=[];for(let t of n.querySelectorAll('a[href^="#"]')){let r=0;for(let o=t;o&&o!==n;o=o.parentElement)(o.tagName==="UL"||o.tagName==="OL")&&r++;e.push({level:Math.min(Math.max(r,1),6),id:t.getAttribute("href").slice(1),text:(t.textContent??"").trim()})}return xl(e)}function Vb(n){let e=qp(n);return{toc:{group:"block",atom:!0,selectable:!0,attrs:{entries:{default:[]},title:{default:null}},parseDOM:[...["nav[data-toc]","div.mce-toc",`.${e.className}`].map(t=>({tag:t,getAttrs:r=>{let o=r.querySelector(":scope > h1, :scope > h2, :scope > h3, :scope > h4, :scope > h5, :scope > h6, :scope > p");return{entries:$b(r),title:o?.textContent?.trim()||null}}}))],toDOM:t=>{let r=typeof t.attrs.title=="string"?t.attrs.title.slice(0,200):"",o=zb(xl(t.attrs.entries),e.list);return["nav",{class:e.className,"data-toc":""},...r?[[e.titleTag,r]]:[],...o?[o]:[]]}}}}var wl={name:"tableofcontents",nodes:Vb,setup(n){n.ui.addStyles("nova-tableofcontents",$p);let{empty:e}=Oe(n,"tableofcontents",Vp);n.root.style.setProperty("--nova-toc-empty",JSON.stringify(e))},load:()=>import(__novaChunk("tinymce-chunks/tableofcontents-ui-01a9af06.js") )};var fa={};q(fa,{LABELS:()=>ah,commentsKey:()=>ft,default:()=>pa,getComments:()=>ci});var Zl={};q(Zl,{Decoration:()=>ge,DecorationSet:()=>ae,EditorView:()=>Zn,__endComposition:()=>hv,__parseFromClipboard:()=>fv});var Le=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e};function Un(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e}var Tl=null;function Nt(n,e,t){let r=Tl||(Tl=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r}function qb(){Tl=null}function qo(n,e,t,r){return t&&(Wp(n,e,t,r,-1)||Wp(n,e,t,r,1))}var jp=/^(img|br|input|textarea|hr)$/i;function Wp(n,e,t,r,o){for(var i;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Me(n))){let s=n.parentNode;if(!s||!W(s)||jo(n)||jp.test(n.nodeName)||n.contentEditable=="false")return!1;e=Le(n)+(o<0?0:1),n=s}else if(W(n)){let s=n.childNodes[e+(o<0?-1:0)];if(W(s)&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=o;else return!1;else{if(jo(s)||jp.test(s.nodeName))return!1;n=s,e=o<0?Me(n):0}}else return!1}}function Me(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function W(n){return n.nodeType==1}function ke(n){return n.nodeType==3}function Jn(n,e){return e?n.contains(W(e)?e:e.parentNode):!1}function Mf(n,e){for(;;){if(ke(n)&&e)return n;if(W(n)&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Me(n)}else if(n.parentNode&&!jo(n,!0))e=Le(n),n=n.parentNode;else return null}}function Ef(n,e){for(;;){if(ke(n)&&e<n.nodeValue.length)return n;if(W(n)&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!jo(n,!0))e=Le(n)+1,n=n.parentNode;else return null}}function jb(n,e,t){for(let r=e==0,o=e==Me(n);r||o;){if(n==t)return!0;let i=Le(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,o=o&&i==Me(n)}}function jo(n,e=!1){let t;for(let r=n;r&&!(t=r.pmViewDesc);r=r.parentNode);return t&&t.node&&(!e||t.node.isBlock)&&(t.dom==n||t.contentDOM==n)}function Qo(n){return n.focusNode&&qo(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)}function Cf(n,e){n.collapse(e.anchorNode,e.anchorOffset),(e.focusNode!=e.anchorNode||e.focusOffset!=e.anchorOffset)&&n.extend(e.focusNode,e.focusOffset)}function Wb(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Kb(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Ub(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Me(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Me(r.startContainer),r.startOffset)}}}var dt=typeof navigator<"u"?navigator:null,Kp=typeof document<"u"?document:null,Gn=dt&&dt.userAgent||"",Ye=/gecko\/(\d+)/i.test(Gn)&&!/edge?\//i.test(Gn);Ye&&+(/Firefox\/(\d+)/.exec(Gn)||[0,0])[1];var Nl=/Chrome\/(\d+)/.exec(Gn),Pe=!!Nl,Af=Nl?+Nl[1]:0,Re=!!dt&&/Apple Computer/.test(dt.vendor),Yn=Re&&(/Mobile\/\w+/.test(Gn)||!!dt&&dt.maxTouchPoints>2),We=Yn||(dt?/Mac/.test(dt.platform):!1),Tf=dt?/Win/.test(dt.platform):!1,Ot=/Android \d/.test(Gn),ei=!!Kp&&"webkitFontSmoothing"in Kp.documentElement.style,Jb=ei?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Gb(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Tt(n,e){return typeof n=="number"?n:n[e]}function Yb(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Up(n,e,t){if(!Ol(e)&&e.left==0)return;let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(!W(s)){s=Un(s);continue}let l=s==i.body,a=l?Gb(i):Yb(s),c=0,u=0;if(e.top<a.top+Tt(r,"top")?u=-(a.top-e.top+Tt(o,"top")):e.bottom>a.bottom-Tt(r,"bottom")&&(u=e.bottom-e.top>a.bottom-a.top?e.top+Tt(o,"top")-a.top:e.bottom-a.bottom+Tt(o,"bottom")),e.left<a.left+Tt(r,"left")?c=-(a.left-e.left+Tt(o,"left")):e.right>a.right-Tt(r,"right")&&(c=e.right-a.right+Tt(o,"right")),c||u)if(l)i.defaultView.scrollBy(c,u);else{let p=s.scrollLeft,f=s.scrollTop;u&&(s.scrollTop+=u),c&&(s.scrollLeft+=c);let h=s.scrollLeft-p,m=s.scrollTop-f;e={left:e.left-h,top:e.top-m,right:e.right-h,bottom:e.bottom-m}}let d=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s=d=="absolute"?s.offsetParent:Un(s)}}function Xb(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=n.root.elementFromPoint(i,s);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:Nf(n.dom)}}function Nf(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Un(r));return e}function Zb({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Of(t,r==0?0:r-e)}function Of(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:o,left:i}=n[t];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}var jn=null;function Lf(n){if(n.setActive)return n.setActive();if(jn)return n.focus(jn);let e=Nf(n);n.focus(jn==null?{get preventScroll(){return jn={preventScroll:!0},!0}}:void 0),jn||(jn=!1,Of(e,0))}function Pf(n,e){let t,r=2e8,o,i=0,s=e.top,l=e.top,a,c;for(let u=n.firstChild,d=0;u;u=u.nextSibling,d++){let p;if(W(u))p=u.getClientRects();else if(ke(u))p=Nt(u).getClientRects();else continue;for(let f=0;f<p.length;f++){let h=p[f];if(h.top<=s&&h.bottom>=l){s=Math.max(h.bottom,s),l=Math.min(h.top,l);let m=h.left>e.left?h.left-e.left:h.right<e.left?e.left-h.right:0;if(m<r){t=u,r=m,o=m&&ke(t)?{left:h.right<e.left?h.right:h.left,top:e.top}:e,W(u)&&m&&(i=d+(e.left>=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=u,c={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!t&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(i=d+1)}}return!t&&a&&(t=a,o=c,r=0),t&&ke(t)?Qb(t,o):!t||r?{node:n,offset:i}:Pf(t,o)}function Qb(n,e){let t=n.nodeValue.length,r=document.createRange(),o;for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let s=qt(r,1);if(s.top!=s.bottom&&jl(e,s)){o={node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),o||{node:n,offset:0}}function jl(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function ek(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function tk(n,e,t){let{node:r,offset:o}=Pf(e,t),i=-1;if(W(r)&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,o,i)}function nk(n,e,t,r){let o=-1;for(let i=e,s=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0),a;if(!l)return null;if(W(l.dom)&&(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)&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),s=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function Rf(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),i=o;;){let s=n.childNodes[i];if(W(s)){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(jl(e,c))return Rf(s,e,c)}}if((i=(i+1)%r)==o)break}return n}function rk(n,e){let t=n.dom.ownerDocument,r,o=0,i=Ub(t,e.left,e.top);i&&({node:r,offset:o}=i);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!s||!n.dom.contains(s)){let c=n.dom.getBoundingClientRect();if(!jl(e,c)||(s=Rf(n.dom,e,c),!s))return null}if(Re)for(let c=s;r&&c;c=Un(c))c.draggable&&(r=void 0);if(s=ek(s,e),r){if(Ye&&W(r)&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let u=r.childNodes[o],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&o++}let c;ei&&o&&W(r)&&W(c=r.childNodes[o-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&W(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||!W(r)||r.childNodes[o-1].nodeName!="BR")&&(l=nk(n,r,o,e))}l==null&&(l=tk(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ol(n){return n.top<n.bottom||n.left<n.right}function qt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Ol(r))return r}return Array.prototype.find.call(t,Ol)||n.getBoundingClientRect()}var ok=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Df(n,e,t){let{node:r,offset:o,atom:i}=n.docView.domFromPos(e,t<0?-1:1),s=ei||Ye;if(ke(r))if(s&&(ok.test(r.nodeValue)||(t<0?!o:o==r.nodeValue.length))){let a=qt(Nt(r,o,o),t);if(Ye&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=qt(Nt(r,o-1,o-1),-1);if(c.top==a.top){let u=qt(Nt(r,o,o+1),-1);if(u.top!=a.top)return Rr(u,u.left<c.left)}}return a}else{let a=o,c=o,u=t<0?1:-1;return t<0&&!o?(c++,u=-1):t>=0&&o==r.nodeValue.length?(a--,u=1):t<0?a--:c++,Rr(qt(Nt(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(t<0||o==Me(r))){let a=r.childNodes[o-1];if(W(a))return Ml(a.getBoundingClientRect(),!1)}if(i==null&&o<Me(r)){let a=r.childNodes[o];if(W(a))return Ml(a.getBoundingClientRect(),!0)}return Ml(r.getBoundingClientRect(),t>=0)}if(i==null&&o&&(t<0||o==Me(r))){let a=r.childNodes[o-1],c=ke(a)?Nt(a,Me(a)-(s?0:1)):W(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Rr(qt(c,1),!1)}if(i==null&&o<Me(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?ke(a)?Nt(a,0,s?0:1):W(a)?a:null:null;if(c)return Rr(qt(c,-1),!0)}return Rr(qt(ke(r)?Nt(r):r,-t),t>=0)}function Rr(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Ml(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function _f(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function ik(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return _f(n,e,()=>{let{node:i}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=Df(n,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(W(l))a=l.getClientRects();else if(ke(l))a=Nt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}var sk=/[\u0590-\u08ac]/;function lk(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=n.domSelection();return l?!sk.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:s:_f(n,e,()=>{let a=n.domSel.readRange(),c=l.caretBidiLevel;l.modify("move",t,"character");let u=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:d,focusOffset:p}=n.domSel.readRange(),f=d&&!Jn(u,d)||a.focusNode==d&&a.focusOffset==p;return Cf(l,a),c!=null&&(l.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var Jp=null,Gp=null,Yp=!1;function ak(n,e,t){return Jp==e&&Gp==t?Yp:(Jp=e,Gp=t,Yp=t=="up"||t=="down"?ik(n,e,t):lk(n,e,t))}var gn=class{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.damage=0,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(e){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let o=this.children[t];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&Jn(this.contentDOM,e))if(r<0){let i,s;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>Le(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let i=e.compareDocumentPosition(this.contentDOM);i&16?o=t>Array.from(e.childNodes).findIndex(s=>s.contains(this.contentDOM)):o=!(i&4)}else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!t||i.node))if(r&&(s=i.nodeDOM)&&!(W(s)?Jn(s,e):s==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t],i=r+o.size;if(r==e&&i!=r){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let l=o.children[s];if(l.size){o=l;break}}return o}if(e<i)return o.descAt(e-r-o.border);r=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],l=i+s.size;if(l>e){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(;r>0;r--){let i=this.children[r-1];if(i.size||!(i instanceof Ko||i instanceof Wo&&i.side>=0))break}if(t<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&t&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?Le(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?Le(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(o==-1&&e<=c){let u=s+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=s;for(let d=l;d>0;d--){let p=this.children[d-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){o=Le(p.dom)+1;break}e-=p.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=Le(d.dom);break}t+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(!W(t)||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDamage(e){e&&(this.damage|=e,this.markParentDamage())}markParentDamage(){for(let e=this;;){let{parent:t}=e;if(!t||t.damage&1)break;t.damage|=1,e=t}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Wo=class extends gn{constructor(e,t,r,o){let i,s=t.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let l=W(s)?s:document.createElement("span");l!=s&&(l.appendChild(s),s=l),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return!this.damage&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},Ll=class extends gn{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},fn=class n extends gn{constructor(e,t,r,o,i){super(e,[],r,o),this.mark=t,this.spec=i}static create(e,t,r,o){let i=o.nodeViews[t.type.name],s=i&&i(t,o,r);return(!s||!s.dom)&&(s=qe.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.damage&4||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return!(this.damage&4)&&this.mark.eq(e)}markDamage(e){var t;this.damage|=e,(t=this.parent)===null||t===void 0||t.markDamage(2)}slice(e,t,r){let o=n.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;t<s&&(i=Rl(i,t,s,r)),e>0&&(i=Rl(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Ut=class n extends gn{constructor(e,t,r,o,i,s,l){super(e,[],i,s),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,t,r,o,i,s){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(!ke(u))throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=qe.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let p=u;return u=Hf(u,r,t),c?a=new Uo(e,t,r,o,u,d||null,p,c):t.isText?new Hr(e,t,r,o,u,p):new n(e,t,r,o,u,d||null,p)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let o=this.children[r];if(this.dom.contains(o.dom.parentNode)){t.contentElement=o.dom.parentNode;break}}if(!t.contentElement){let r=e&&e.find(o=>W(o)&&e.indexOf(o.parentNode)<0&&this.dom.contains(o));r?t.contentElement=r:t.getContent=()=>T.empty}}return t}matchesNode(e,t,r){return!this.damage&&e.eq(this.node)&&Jo(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Pl(this,s&&s.node,e),c=this.node.inlineContent,u=c&&this.node.isBlock;pk(this.node,this.innerDeco,(d,p,f)=>{d.spec.marks?a.syncToMarks(d.spec.marks,r,e,p):d.type.side>=0&&!f&&a.syncToMarks(p==this.node.childCount?Q.none:this.node.child(p).marks,r,e,p),a.placeWidget(d,e,o)},(d,p,f,h)=>{a.syncToMarks(d.marks,r,e,h),u&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(d,p,f,h)||l&&e.state.selection.from>o&&e.state.selection.to<o+d.nodeSize&&(m=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(d,p,f,m,e,o)||a.updateNextNode(d,p,f,e,h,o)||a.addNode(d,p,f,e,o),o+=d.nodeSize,c&&(u=d.isAtom&&!d.isText)}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.damage&2)&&(s&&this.protectLocalComposition(e,s),If(this.contentDOM,this.children,e),Yn&&fk(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof F)||r<t||o>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let s=i.nodeValue,l=hk(this.node.content,s,r-t,o-t);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:o}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new Ll(this,i,t,o);e.input.compositionNodes.push(s),this.children=Rl(this.children,r,r+o.length,e,s)}update(e,t,r,o,i){return this.damage&4||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o,i),!0)}updateInner(e,t,r,o,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,i+1),this.damage=0}updateOuterDeco(e){if(Jo(e,this.outerDeco))return;let t=!W(this.nodeDOM),r=this.dom;this.dom=Wl(this.dom,this.nodeDOM,Br(this.outerDeco,this.node,t),Br(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){W(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){W(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function Xp(n,e,t,r,o,i){i?Wl(r,r,Br(i,n,!1),Br(e,n,!1)):Hf(r,e,n);let s=new Ut(void 0,n,e,t,r,r,r);return s.contentDOM&&s.updateChildren(o,0),s}var Hr=class n extends Ut{constructor(e,t,r,o,i,s){super(e,t,r,o,i,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.damage&4||this.damage&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.damage&8||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.damage=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return!1}slice(e,t,r){let o=this.node.cut(e,t),i=document.createTextNode(o.text);return new n(this.parent,o,this.outerDeco,this.innerDeco,i,i)}get domAtom(){return!1}isText(e){return this.node.text==e}},Ko=class extends gn{parseRule(){return{ignore:!0}}matchesHack(e){return!this.damage&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Uo=class extends Ut{constructor(e,t,r,o,i,s,l,a){super(e,t,r,o,i,s,l),this.spec=a}update(e,t,r,o,i){if(this.damage&4)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,o,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}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 If(n,e,t){let r=n.firstChild,o=!1;for(let i=0;i<e.length;i++){let s=e[i],l=s.dom;if(l.parentNode==n){for(;l!=r;)r=Zp(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(l,r);if(s instanceof fn){let a=r?r.previousSibling:n.lastChild;If(s.contentDOM,s.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Zp(r),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}var _r=function(n){n&&(this.nodeName=n)};_r.prototype=Object.create(null);var pn=[new _r];function Br(n,e,t){if(n.length==0)return pn;let r=t?pn[0]:new _r,o=[r];for(let i=0;i<n.length;i++){let s=n[i].type.attrs;if(s){s.nodeName&&o.push(r=new _r(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&o.length==1&&o.push(r=new _r(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function Wl(n,e,t,r){if(t==pn&&r==pn)return e;let o=e;for(let i=0;i<r.length;i++){let s=r[i],l=t[i];if(i){let a;l&&l.nodeName==s.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=pn[0]),o=a}ck(o,l||pn[0],s)}return o}function ck(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&n.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.indexOf(o[i])==-1&&n.classList.add(o[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function Hf(n,e,t){return Wl(n,n,pn,Br(e,t,!W(n)))}function Jo(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Zp(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var Pl=class{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=uk(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,o){let i=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;i<l&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.damage=0,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;o<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[s])&&!this.isLocked(d.dom)){a=u;break}}if(a<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof fn&&!(u.damage&4)&&u.mark.type==e[s].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[s])&&(u.mark=e[s],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=fn.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,r,o,i,s){let l=this.top.children[o];return l.damage&4&&l.dom==l.contentDOM&&(l.damage=2),l.update(e,t,r,i,s)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=t}}updateNextNode(e,t,r,o,i,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Ut){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let u=a.dom,d,p=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&!(a.damage&4)&&Jo(t,a.outerDeco));if(!p&&a.update(e,t,r,o,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!p&&(d=this.recreateWrapper(a,e,t,r,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.damage|=2,d.updateChildren(o,s+1),d.damage=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,o,i,s){if(e.damage&3||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Jo(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=Ut.create(this.top,t,r,o,i,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,o,i){let s=Ut.create(this.top,e,t,r,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new Wo(this.top,e,t,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof fn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Hr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Re||Pe)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new Ko(this.top,[],r,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||W(e)&&e.contains(this.lock.parentNode))}};function uk(n,e){let t=e,r=t.children.length,o=[],i=n.childCount,s=new Map,l=[];e:for(;i>0;){let a;for(;;)if(r){let u=t.children[r-1];if(u instanceof fn)o.push(r-1),t=u,r=u.children.length;else{a=u,r--;break}}else{if(t==e)break e;r=o.pop(),t=t.parent}let c=a.node;if(c){if(c!=n.child(i-1))break;--i,s.set(a,i),l.push(a)}}return{index:i,matched:s,matches:l.reverse()}}function dk(n,e){return n.type.side-e.type.side}function pk(n,e,t,r){let o=e.locals(n),i=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,o,e.forChild(i,u),c),i+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,d;for(;s<o.length&&o[s].to==i;){let g=o[s++];g.widget&&(u?(d||(d=[u])).push(g):u=g)}if(u)if(d){d.sort(dk);for(let g=0;g<d.length;g++)t(d[g],c,!!a)}else t(u,c,!!a);let p,f;if(a)f=-1,p=a,a=null;else if(c<n.childCount)f=c,p=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let h=i+p.nodeSize;if(p.isText){let g=h;s<o.length&&o[s].from<g&&(g=o[s].from);for(let k=0;k<l.length;k++)l[k].to<g&&(g=l[k].to);g<h&&(a=p.cut(g-i),p=p.cut(0,g-i),h=g,f=-1)}else for(;s<o.length&&o[s].to<h;)s++;let m=p.isInline&&!p.isLeaf?l.filter(g=>!g.inline):l.slice();r(p,m,e.forChild(i,p),f),i=h}}function fk(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function hk(n,e,t,r){for(let o=0,i=0;o<n.childCount&&i<=r;){let s=n.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<n.childCount;){let c=n.child(o++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Rl(n,e,t,r,o){let i=[];for(let s=0,l=0;s<n.length;s++){let a=n[s],c=l,u=l+=a.size;c>=t||u<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),o&&(i.push(o),o=void 0),u>t&&i.push(a.slice(t-c,a.size,r)))}return i}function Dl(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),i=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return i&&U.findFrom(i,e)}function jt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Qp(n,e,t){let r=n.state.selection;if(r instanceof F)if(t.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=n.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return jt(n,new F(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Dl(n.state,e);return o&&o instanceof R?jt(n,o):!1}else if(!We||t.indexOf("m")<0){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?R.isSelectable(i)?jt(n,new R(e<0?n.state.doc.resolve(o.pos-i.nodeSize):o)):jt(n,new F(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1}}else return!1;else{if(r instanceof R&&r.node.isInline)return jt(n,new F(e>0?r.$to:r.$from));{let o=Dl(n.state,e);return o?jt(n,o):!1}}}function Ir(n,e){let t=n.pmViewDesc;return t?t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR"):W(n)&&n.contentEditable=="false"}function Wn(n,e){return e<0?mk(n):gk(n)}function mk(n){let e=n.domSel.readRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,i,s=!1;for(Ye&&W(t)&&r<Me(t)&&Ir(t.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!W(t))break;let l=t.childNodes[r-1];if(Ir(l,-1))o=t,i=--r;else if(ke(l))t=l,r=t.nodeValue.length;else break}else{if(Bf(t))break;{let l=t.previousSibling;for(;l&&Ir(l,-1);)o=t.parentNode,i=Le(l),l=l.previousSibling;if(l)t=l,r=Me(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?_l(n,t,r):o&&_l(n,o,i)}function gk(n){let e=n.domSel.readRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=Me(t),i,s;for(;;)if(r<o){if(!W(t))break;let l=t.childNodes[r];if(Ir(l,1))i=t,s=++r;else break}else{if(Bf(t))break;{let l=t.nextSibling;for(;l&&Ir(l,1);)i=l.parentNode,s=Le(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=Me(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}i&&_l(n,i,s)}function Bf(n){for(let e=n;e;e=e.parentNode){let t=e.pmViewDesc;if(t)return t.node?t.node.isBlock:!1}return!1}function _l(n,e,t){if(!ke(e)){let s,l;(l=Ef(e,t))?(e=l,t=0):(s=Mf(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection(),o=n.domSel.readRange();if(!r)return;Qo(o)?r.collapse(e,t):r.extend&&(r.collapse(o.anchorNode,o.anchorOffset),r.extend(e,t)),n.domSel.ignore();let{state:i}=n;setTimeout(()=>{n.state==i&&n.domSel.sync()},50)}function ef(n,e){let t=n.state.doc.resolve(e);if(!(Pe||Tf)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}let r=n.dom;for(let i=t.depth;i>0;i--)if(t.node(i).isBlock){r=n.nodeDOM(t.before(i))||r;break}return getComputedStyle(r).direction=="rtl"?"rtl":"ltr"}function tf(n,e,t){let r=n.state.selection;if(r instanceof F&&!r.empty||t.indexOf("s")>-1||We&&t.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Dl(n.state,e);if(s&&s instanceof R)return jt(n,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof de?U.near(s,e):U.findFrom(s,e);return l?jt(n,l):!1}return!1}function nf(n,e){if(!(n.state.selection instanceof F))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let s=n.state.tr;return e<0?s.delete(t.pos-i.nodeSize,t.pos):s.delete(t.pos,t.pos+i.nodeSize),n.dispatch(s),!0}return!1}function rf(n,e,t){n.domObserver.stopped(()=>e.contentEditable=t)}function yk(n){if(!Re||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSel.readRange();if(e&&W(e)&&t==0&&e.firstChild&&W(e.firstChild)&&e.firstChild.contentEditable=="false"){let r=e.firstChild;rf(n,r,"true"),setTimeout(()=>rf(n,r,"false"),20)}return!1}function bk(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function kk(n,e){let t=e.keyCode,r=bk(e);if(t==8||We&&t==72&&r=="c")return nf(n,-1)||Wn(n,-1);if(t==46&&!e.shiftKey||We&&t==68&&r=="c")return nf(n,1)||Wn(n,1);if(t==13||t==27)return!0;if(t==37||We&&t==66&&r=="c"){let o=t==37?ef(n,n.state.selection.from)=="ltr"?-1:1:-1;return Qp(n,o,r)||Wn(n,o)}else if(t==39||We&&t==70&&r=="c"){let o=t==39?ef(n,n.state.selection.from)=="ltr"?1:-1:1;return Qp(n,o,r)||Wn(n,o)}else{if(t==38||We&&t==80&&r=="c")return tf(n,-1,r)||Wn(n,-1);if(t==40||We&&t==78&&r=="c")return yk(n)||tf(n,1,r)||Wn(n,1);if(r==(We?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Kl(n,e){n.someProp("transformCopied",f=>{e=f(e,n)});let t=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let f=r.firstChild;t.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let s=n.someProp("clipboardSerializer")||qe.fromSchema(n.state.schema),l=qf(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&W(c)&&(u=Vf[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let h=l.createElement(u[f]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),d++}c=a.firstChild}c&&W(c)&&c.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(t)}`);let p=n.someProp("clipboardTextSerializer",f=>f(e,n))||e.content.textBetween(0,e.content.size,`
8
8
 
9
- `);return{dom:a,text:p,slice:e}}function $l(n,e,t,r,o){let i=o.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=!!e&&(r||i||!t);if(a){if(n.someProp("transformPastedText",p=>{e=p(e,i||r,n)}),i)return l=new D(N.from(n.state.schema.text(e.replace(/\r\n?/g,`
10
- `))),0,0),n.someProp("transformPasted",p=>{l=p(l,n,!0)}),l;let u=n.someProp("clipboardTextParser",p=>p(e,o,r,n));if(u)l=u;else{let p=o.marks(),{schema:f}=n.state,h=Ve.fromSchema(f);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(h.serializeNode(f.text(m,p)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),s=uk(t),Zo&&pk(s);let c=s&&s.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 p=s.firstChild;for(;p&&!W(p);)p=p.nextSibling;if(!p)break;s=p}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||St.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||d),context:o,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!ak.test(p.parentNode.nodeName)?{ignore:!0}:null}})),d)l=fk(Gp(l,+d[1],+d[2]),d[4]);else if(l=D.maxOpen(ck(l.content,o),!0),l.openStart||l.openEnd){let u=0,p=0;for(let f=l.content.firstChild;u<l.openStart&&!f.type.spec.isolating;u++,f=f.firstChild);for(let f=l.content.lastChild;p<l.openEnd&&!f.type.spec.isolating;p++,f=f.lastChild);l=Gp(l,u,p)}return n.someProp("transformPasted",u=>{l=u(l,n,r)}),l}var ak=/^(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 ck(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),i,s=[];if(n.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&Lf(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Pf(s[s.length-1],i.length));let d=Of(l,a);s.push(d),o=o.matchType(d.type),i=a}}),s)return N.from(s)}return n}function Of(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,N.from(n));return n}function Lf(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let i=Lf(n,e,t,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(N.from(Of(t,n,o+1))))}}function Pf(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Pf(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(N.empty,!0);return n.copy(t.append(r))}function Ol(n,e,t,r,o,i){let s=e<0?n.firstChild:n.lastChild,l=s.content;return n.childCount>1&&(i=0),o<r-1&&(l=Ol(l,e,t,r,o+1,i)),o>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(N.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function Gp(n,e,t){return e<n.openStart&&(n=new D(Ol(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new D(Ol(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var Rf={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function Df(){return document.implementation.createHTMLDocument("title")}var Pr=null;function dk(n){let e=window.trustedTypes;if(!e)return n;if(!Pr){if(Pr=e.defaultPolicy)try{return Pr.createHTML(n)}catch{}Pr=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return Pr.createHTML(n)}function uk(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Df(),r=t.body,o=/<([a-z][^>\s]+)/i.exec(n),i;if((i=o&&Rf[o[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=dk(n),i)for(let s=0;s<i.length;s++)r=r.querySelector(i[s])||r;for(let s=0;s<t.styleSheets.length;s++){let l=t.styleSheets[s];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let d=r.querySelectorAll(c.selectorText);for(let u=0;u<d.length;u++)d[u].style.cssText+=c.style.cssText}}}return r}function pk(n){let e=n.querySelectorAll(Pe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function fk(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:i,openEnd:s}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs()||!a.createAndFill(null,o))break;try{o=N.from(a.create(r[l+1],o))}catch{break}i++,s++}return new D(o,i,s)}var Be=class n{constructor(e,t,r,o){this.anchorNode=e,this.anchorOffset=t,this.focusNode=r,this.focusOffset=o}static from(e){return e instanceof n?e:new n(e.anchorNode,e.anchorOffset,e.focusNode,e.focusOffset)}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};Be.null=new Be(null,0,null,0);var Ll=class{constructor(e){this.view=e,this.range=Be.null,this.active=!1,this.synced=!1,this.suppress=!1,this.currentDocument=null,this.onSelectionChange=this.onSelectionChange.bind(this)}ensureListener(){let e=this.view.dom.ownerDocument;e!=this.currentDocument&&(this.currentDocument&&this.currentDocument.removeEventListener("selectionchange",this.onSelectionChange),this.currentDocument=e,e.addEventListener("selectionchange",this.onSelectionChange))}destroy(){this.currentDocument&&(this.currentDocument.removeEventListener("selectionchange",this.onSelectionChange),this.currentDocument=null),this.active=!1,this.range=Be.null}suppressChanges(){this.suppress=!0,setTimeout(()=>this.suppress=!1,50)}onSelectionChange(){if(this.suppress&&this.view.hasFocus())return this.sync();this.read()&&this.view.domObserver.flush(!1)}readRange(){let{view:e}=this,t=e.dom.isConnected!==!1&&e.domSelection();return t?Re&&e.root.nodeType===11&&Db(e.dom.ownerDocument)==e.dom?Be.from(hk(e,t)||t):Be.from(t):Be.null}read(){this.ensureListener();let e=Hf(this.view);if(!e){this.active=!1,this.range=Be.null;return}return this.active=!0,this.range.eq(e)?!1:(this.range=e,this.synced=!1,!0)}sync(e=!1){let{view:t}=this;t.docView&&(this.ensureListener(),t.domObserver.stopped(()=>{kk(t,t.state.selection);let r=t.state.selection;if(t.input.mouseDown||_f(t)){let{desc:o,start:i}=If(t.docView,r.from,r.to,0);t.cursorWrapper?bk(t):o instanceof Wo&&o.spec.setSelection?o.spec.setSelection(r.anchor-i,r.head-i,t.root):mk(t,e,o,i),this.synced=this.active=!0}r.visible==t.dom.classList.contains("ProseMirror-hideselection")&&(r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),yk(t))),this.range=this.readRange()}))}ignore(e=this.readRange()){this.range=Be.from(e),this.synced=!0}deactivate(){this.range=Be.null,this.active=this.synced=!1}};function hk(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return Yp(n,o)}let t;function r(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Yp(n,t):null}function Yp(n,e){let t=e.startContainer,r=e.startOffset,o=e.endContainer,i=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return $o(s.node,s.offset,o,i)&&([t,r,o,i]=[o,i,t,r]),new Be(t,r,o,i)}function Vl(n,e,t=null){let r=n.state.doc;if(!e.focusNode)return null;let o=n.docView.nearestDesc(e.focusNode),i=o&&o.size==0,s=n.docView.posFromDOM(e.focusNode,e.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(Xo(e)){for(a=s;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&R.isSelectable(o.node)&&o.parent&&!(o.node.isInline&&Pb(e.focusNode,e.focusOffset,o.dom))){let u=o.posBefore;c=new R(s==u?l:r.resolve(u))}else if(Ge&&t=="key"&&s>n.state.selection.to&&W(e.focusNode)&&e.focusOffset==e.focusNode.childNodes.length&&o&&o.posAtStart>n.state.selection.to)for(let u=e.focusNode;;u=u.parentNode){if(getComputedStyle(u).overflow!="visible"){c=K.findFrom(r.resolve(o.posAtStart),1);break}if(u==o.dom||u.nextSibling||!u.parentNode||!W(u.parentNode))break}}else{if(e instanceof n.dom.ownerDocument.defaultView.Selection&&e.rangeCount>1){let u=s,p=s;for(let f=0;f<e.rangeCount;f++){let h=e.getRangeAt(f);u=Math.min(u,n.docView.posFromDOM(h.startContainer,h.startOffset,1)),p=Math.max(p,n.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(u<0)return null;[a,s]=p==n.state.selection.anchor?[p,u]:[u,p],l=r.resolve(s)}else a=n.docView.posFromDOM(e.anchorNode,e.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!c){let u=t=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=Yn(n,d,l,u)}return c}function _f(n){return n.editable?n.hasFocus():Bf(n,n.domSel.readRange())&&(!document.activeElement||document.activeElement.contains(n.dom))}function mk(n,e,t,r){let o=n.state.selection,{anchor:i,head:s}=o,l,a;Xp&&!(o instanceof F)&&(o.$from.parent.inlineContent||(l=Zp(n,o.from)),!o.empty&&!o.$from.parent.inlineContent&&(a=Zp(n,o.to)));let c=t.domFromPos(i-r,i>r?-1:1),d=s==i?c:t.domFromPos(s-r,s>r?-1:1);gk(i,s,c,d,n,e),Xp&&(l&&Qp(l),a&&Qp(a))}function If(n,e,t,r=0){for(let o=0,i=r;o<n.children.length;o++){let s=n.children[o],l=i+s.size;if(e>i&&t<l)return If(s,e,t,i+s.border);i=l}return{desc:n,start:r}}function gk(n,e,t,r,o,i){let s=!1;if((Ge||Re)&&n==e){let{node:a,offset:c}=t;if(ke(a)){if(s=!!(c&&a.nodeValue[c-1]==`
11
- `),s&&c==a.nodeValue.length)for(let d=a,u;d;d=d.parentNode){if(u=d.nextSibling){u.nodeName=="BR"&&(t=r={node:u.parentNode,offset:Le(u)+1});break}let p=d.pmViewDesc;if(p&&p.node&&p.node.isBlock)break}}else{let d=a.childNodes[c-1];s=d&&(d.nodeName=="BR"||d.contentEditable=="false")}}let l=o.domSel.readRange();if(Ge&&l.focusNode&&l.focusNode!=r.node&&W(l.focusNode)){let a=l.focusNode.childNodes[l.focusOffset];a&&a.contentEditable=="false"&&(i=!0)}!(i||s&&Re)&&$o(t.node,t.offset,l.anchorNode,l.anchorOffset)&&$o(r.node,r.offset,l.focusNode,l.focusOffset)||yf(o.domSelection(),{focusNode:r.node,focusOffset:r.offset,anchorNode:t.node,anchorOffset:t.offset})}var Xp=Re||Pe&&bf<63;function Zp(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,i=r?t.childNodes[r-1]:null;if(Re&&o&&o.contentEditable=="false")return kl(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return kl(o);if(i)return kl(i)}}function kl(n){return n.contentEditable="true",Re&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Qp(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function yk(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSel.readRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!_f(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function bk(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom;t.nodeName=="IMG"?e.collapse(t.parentNode,Le(t)+1):e.collapse(t,0)}function kk(n,e){if(e instanceof R){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ef(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ef(n)}function ef(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Yn(n,e,t,r){let o=n.someProp("createSelectionBetween",i=>i(n,e,t))||F.between(e,t,r);return n.someProp("adjustSelectionFromDOM",i=>{o=i(n,o)}),o}function Hf(n){if(n.editable&&!n.hasFocus())return null;let e=n.domSel.readRange();return e&&Bf(n,e)?e:null}function Bf(n,e){if(!e.anchorNode)return!1;try{return Un(n.dom,e.anchorNode)&&(n.editable||Un(n.dom,e.focusNode))}catch{return!1}}var De={},_e={},vk={touchstart:!0,touchmove:!0},Pl=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function xk(n){for(let e in De){let t=De[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Sk(n,r)&&(n.input.composing&&(r.type=="keydown"||r.type=="beforeinput")&&r.isComposing===!1&&$f(n,!0),!ql(n,r)&&(n.editable||!(r.type in _e))&&t(n,r))},vk[e]?{passive:!0}:void 0)}Re&&n.dom.addEventListener("input",()=>null),Rl(n)}function Qo(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function wk(n){n.input.mouseDown&&n.input.mouseDown.done(),n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Rl(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>ql(n,r))})}function ql(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Sk(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Mk(n,e){!ql(n,e)&&De[e.type]&&(n.editable||!(e.type in _e))&&De[e.type](n,e)}function jt(n,e){let{input:t}=n;return t.lastKeyDispatched||n.composing?!1:(t.lastKeyDispatched=!0,typeof e=="string"&&(e=Rb(e=="Backspace"?8:13,e)),n.someProp("handleKeyDown",r=>r(n,e)))}_e.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),n.input.lastKeyDispatched=!1,!(Nt&&Pe&&t.keyCode==13)){if(Gn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(jt(n,"Enter"),n.input.lastIOSEnter=0)},200);return}t.keyCode!=229&&n.domObserver.forceFlush(!0),jt(n,t)||lk(n,t)?t.preventDefault():Qo(n,"key")}};_e.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};_e.keypress=(n,e)=>{let t=e;if(Pk(n)||!t.charCode||t.ctrlKey&&!t.altKey||je&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof F)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode),i=()=>n.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o,i))&&n.dispatch(i()),t.preventDefault()}};function Hr(n){return{left:n.clientX,top:n.clientY}}function Ek(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function jl(n,e,t,r,o){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(n.someProp(e,l=>s>i.depth?l(n,t,i.nodeAfter,i.before(s),o,!0):l(n,t,i.node(s),i.before(s),o,!1)))return!0;return!1}function Ff(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Ck(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&R.isSelectable(r)?(Ff(n,new R(t)),!0):!1}function Ak(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof R&&(r=t.node);let i=n.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(R.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?o=i.before(t.$from.depth):o=i.before(s);break}}return o!=null?(Ff(n,R.create(n.state.doc,o)),!0):!1}function Tk(n,e,t,r,o){return jl(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(o?Ak(n,t):Ck(n,t))}function Nk(n,e,t,r){return jl(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function Ok(n,e,t,r){return jl(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))}function tf(n,e,t){if(e==-1)return n.inlineContent?F.create(n,0,n.content.size):null;let r=n.resolve(e);for(let o=r.depth+1;o>0;o--){let i=o>r.depth?r.nodeAfter:r.node(o),s=r.before(o);if(i.inlineContent)return F.create(n,s+1,s+1+i.content.size);if(t&&R.isSelectable(i))return R.create(n,s)}return null}var Dl=/[\w_\u00a1-\uffff]+/g;try{Dl=new RegExp("[\\p{L}\\p{N}_]+","gu")}catch{}function nf(n,e){let t=n.resolve(e),r=t.node(),o="",i=e,s=e;for(let m=t.indexAfter(),g=!1;m>0;m--){let y=r.child(m-1);if(!y.text)break;let x=i==e?e-t.posAtIndex(m-1):y.text.length,M=x;for(;M>0;M--)if(/\S/.test(y.text[M-1]))g=!0;else if(g)break;if(o=y.text.slice(M,x)+o,i-=x-M,M||i<e-50)break}for(let m=t.index(),g=!1;m<r.childCount;m++){let y=r.child(m);if(!y.text)break;let x=s==e?e-t.posAtIndex(m):0,M=x;for(;M<y.text.length;M++)if(/\S/.test(y.text[M]))g=!0;else if(g)break;if(o+=y.text.slice(x,M),s+=M-x,M<y.text.length||s>e+50)break}let l=i,a=s;if(Intl.Segmenter){for(let m of new Intl.Segmenter(void 0,{granularity:"word"}).segment(o))if(m.isWordLike){let g=m.index+i,y=g+m.segment.length;if(y<e)l=y;else if(g>e){a=g;break}else return F.create(n,g,y)}}else{Dl.lastIndex=0;for(let m;m=Dl.exec(o);){let g=m.index+i,y=g+m[0].length;if(y<e)l=y;else if(g>e){a=g;break}else return F.create(n,g,y)}}let c=o.slice(l-i,e-i),d=o.slice(e-i,a-i),u=/\S*$/.exec(c)[0].length,p=/^\S*/.exec(d)[0].length;if(u||p)return F.create(n,e-u,e+p);let f=/\s*$/.exec(c)[0].length,h=/^\s*/.exec(d)[0].length;return F.create(n,e-f,e+h)}var zf=je?"metaKey":"ctrlKey";De.mousedown=(n,e)=>{let t=e,r=Date.now();if(n.input.shiftKey=t.shiftKey,n.input.lastTouch>r-500)return!1;Ut(n);let o="singleClick";r-n.input.lastClick.time<500&&Ek(t,n.input.lastClick)&&!t[zf]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:r,x:t.clientX,y:t.clientY,type:o,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let i=n.posAtCoords(Hr(t));if(i)if(t.button==0){if(!n.hasFocus()){wf(n.dom);let l=n.root.activeElement;l&&!l.contains(n.dom)&&l.blur()}(n.input.mouseDown=new _l(n,i,t,o)).mightDrag||t.preventDefault()}else Qo(n,"pointer")};var _l=class{constructor(e,t,r,o){var i;this.view=e,this.startPos=t,this.event=r,this.type=o,this.didMove=!1,this.lastPos=-1,this.anchorRange=null,this.startDoc=e.state.doc,this.selectNode=!!r[zf],this.extend=r.shiftKey,this.anchorDoc=this.startDoc;let s=rf(e);if(this.extend){let l=e.state.selection;this.anchorRange=l instanceof R?{from:l.from,to:l.to}:{from:l.anchor,to:l.anchor};let a=l instanceof R?e.nodeDOM(l.from).getBoundingClientRect():e.coordsAtPos(l.anchor);this.anchorOffset={x:(a.left+a.right)/2-s.x,y:(a.top+a.bottom)/2-s.y}}else this.anchorOffset={x:r.clientX-s.x,y:r.clientY-s.y};if(o=="singleClick"){let{selection:l}=e.state,a,c,d=!1;if(l instanceof R&&l.from<=t.pos&&l.to>=t.pos)c=l.from,a=l.node,d=!0;else if(t.inside>-1)a=e.state.doc.nodeAt(t.inside),c=t.inside;else{let u=e.state.doc.resolve(t.pos);a=u.parent,c=u.depth?u.before():-1}if(d||c>-1&&a.type.spec.draggable&&a.type.spec.selectable!==!1){let u=(i=e.docView.descAt(c))===null||i===void 0?void 0:i.nodeDOM;this.mightDrag={node:a,elt:u,pos:c,addAttr:!1},u&&!u.draggable&&(this.mightDrag.addAttr=!0,e.domObserver.stopped(()=>u.draggable=!0))}else this.mightDrag=Lk(e,r)}else this.mightDrag=!1;e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),this.mightDrag||this.select(this.startPos,!0)}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null),typeof this.mightDrag=="object"&&this.mightDrag.addAttr&&this.view.domObserver.stopped(()=>this.mightDrag.elt.removeAttribute("draggable"))}maybeRunHandler(e,t){return(this.type=="singleClick"?Tk:this.type=="doubleClick"?Nk:Ok)(this.view,e.pos,e.inside,t,this.selectNode)}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.startPos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Hr(e))),t&&(this.didMove||this.maybeRunHandler(t,e)||this.select(t,!0),e.preventDefault())}move(e){if(e.buttons==0){this.done();return}if(!this.didMove&&(Math.abs(this.event.x-e.clientX)>8||Math.abs(this.event.y-e.clientY)>8)&&(this.didMove=!0,this.mightDrag=!1),!this.mightDrag){let t=this.view.posAtCoords(Hr(e));t&&this.select(t,!1)}e.preventDefault()}select(e,t){if(e.pos==this.lastPos)return;this.lastPos=e.pos;let{view:r}=this,{doc:o}=r.state,i=this.type=="singleClick"?of(r,o,e):this.type=="doubleClick"?nf(o,e.pos):tf(o,e.inside,t);i&&(t&&!this.extend?this.anchorRange=i:(!t||this.extend)&&(o.eq(this.anchorDoc)||this.restoreAnchor(),this.anchorRange&&this.anchorRange.from<i.from?i=Yn(r,o.resolve(this.anchorRange.from),o.resolve(i.to)):this.anchorRange&&this.anchorRange.to>i.to&&(i=Yn(r,o.resolve(this.anchorRange.to),o.resolve(i.from)))),i.eq(r.state.selection)||r.dispatch(r.state.tr.setSelection(i).setMeta("pointer",!0).scrollIntoView()))}restoreAnchor(){let e=rf(this.view),t=this.view.posAtCoords({left:this.anchorOffset.x+e.x,top:this.anchorOffset.y+e.y});if(!t)this.anchorRange=null;else{let{doc:r}=this.view.state;this.anchorRange=this.type=="singleClick"?of(this.view,r,t):this.type=="doubleClick"?nf(r,t.pos):tf(r,t.inside,!1),this.anchorDoc=this.view.state.doc}}};function rf(n){let e=n.dom.getBoundingClientRect();return{x:e.left-n.dom.scrollLeft,y:e.top-n.dom.scrollTop}}function of(n,e,t){if(t.inside>-1){let o=e.nodeAt(t.inside);if(o.isAtom&&R.isSelectable(o))return R.create(e,t.inside)}let r=e.resolve(t.pos);return Yn(n,r,r)}function Lk(n,e){let{selection:t}=n.state;if(t.empty)return!1;let r=n.domSelection();if(!r||r.rangeCount==0)return!0;let o=r.getRangeAt(0).getClientRects();for(let i=0;i<o.length;i++){let s=o[i];if(s.left<=e.clientX&&s.right>=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}De.touchstart=n=>{n.input.lastTouch=Date.now(),Ut(n),Qo(n,"pointer")};De.touchmove=n=>{n.input.lastTouch=Date.now(),Qo(n,"pointer")};De.contextmenu=n=>Ut(n);function Pk(n,e){return n.composing?!0:Re&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var Rk=Nt?5e3:-1;_e.compositionstart=_e.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof F&&e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Pe&&kf&&Dk(n)))n.markCursor=n.state.storedMarks||t.marks(),Ut(n,!0),n.markCursor=null;else if(Ut(n,!e.selection.empty),Ge&&n.domSel.active&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length)for(let{focusNode:r,focusOffset:o}=n.domSel.range;r&&W(r)&&o!=0;){let i=o<0?r.lastChild:r.childNodes[o-1];if(!i)break;if(ke(i)){let s=n.domSelection();s&&s.collapse(i,i.nodeValue.length);break}else r=i,o=-1}n.input.composing=!0}Vf(n,Rk)};function Dk(n){let{focusNode:e,focusOffset:t}=n.domSel.range;if(!e||!W(e)||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return W(r)&&r.contentEditable=="false"}_e.compositionend=(n,e)=>{n.composing&&$f(n)};function $f(n,e=!1){n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,e?Ut(n):Vf(n,20)}function Vf(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Ut(n),e))}function qf(n){n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());for(let e;e=n.input.compositionNodes.pop();)e.markParentDamage()}function _k(n){let e=n.domSel.range;if(!n.domSel.active||!e.focusNode)return null;let t=mf(e.focusNode,e.focusOffset),r=gf(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function Ut(n,e=!1){if(!(Nt&&n.domObserver.flushingSoon>=0)&&(n.domObserver.forceFlush(),qf(n),e||n.docView&&n.docView.damage)){let t=Vl(n,n.domSel.readRange()),r=n.state.selection;t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state)}}function Ik(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var Br=Gn&&Ib<604;De.copy=_e.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let i=Br?null:t.clipboardData,s=r.content(),{dom:l,text:a}=zl(n,s);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):Ik(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Hk(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Bk(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Fr(n,r.value,null,o,e):Fr(n,r.textContent,r.innerHTML,o,e)},50)}function Fr(n,e,t,r,o){let i=$l(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,i||D.empty)))return!0;if(!i)return!1;let s=Hk(i),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function jf(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}_e.paste=(n,e)=>{let t=e;if(n.composing&&!Nt)return;let r=Br?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Fr(n,jf(r),r.getData("text/html"),o,t)?t.preventDefault():Bk(n,t)};var Uo=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Fk=je?"altKey":"ctrlKey";function Wf(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[Fk]}De.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,i=o.empty?null:n.posAtCoords(Hr(t)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof R?o.to-1:o.to))){if(r&&typeof r.mightDrag=="object")s=R.create(n.state.doc,r.mightDrag.pos);else if(t.target&&W(t.target)){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(s=R.create(n.state.doc,u.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:d}=zl(n,l);(!t.dataTransfer.files.length||!Pe||bf>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Br?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Br||t.dataTransfer.setData("text/plain",c),n.dragging=new Uo(d,Wf(n,t),s)};De.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};_e.dragover=_e.dragenter=(n,e)=>e.preventDefault();_e.drop=(n,e)=>{try{zk(n,e,n.dragging)}finally{n.dragging=null}};function zk(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(Hr(e));if(!r)return;let o=n.state.doc.resolve(r.pos),i=t&&t.slice;i?n.someProp("transformPasted",f=>{i=f(i,n,!1)}):i=$l(n,jf(e.dataTransfer),Br?null:e.dataTransfer.getData("text/html"),!1,o);let s=!!(t&&Wf(n,e));if(n.someProp("handleDrop",f=>f(n,e,i||D.empty,s))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?Ar(n.state.doc,o.pos,i):o.pos;l==null&&(l=o.pos);let a=n.state.tr;if(s){let{node:f}=t;f?f.replace(a):a.deleteSelection()}let c=a.mapping.map(l),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,u=a.doc;if(d?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(u))return;let p=a.doc.resolve(c);if(d&&R.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new R(p));else{let f=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((h,m,g,y)=>f=y),a.setSelection(Yn(n,p,a.doc.resolve(f)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}De.focus=n=>{if(n.input.lastFocus=Date.now(),!n.focused&&(n.domObserver.stopped(()=>n.dom.classList.add("ProseMirror-focused")),n.focused=!0,n.domSel.read(),!n.domSel.synced)){let e=n.domSel.range;setTimeout(()=>{let t=n.domSel.readRange();t&&e.eq(t)&&n.domSel.sync()},20)}};De.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stopped(()=>n.dom.classList.remove("ProseMirror-focused")),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domSel.deactivate(),n.focused=!1)};De.beforeinput=(n,e)=>{if(Nt&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||n.domObserver.pendingRecords().length||(n.dom.blur(),n.focus(),jt(n,"Backspace")))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in _e)De[n]=_e[n];function zr(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var $r=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let t=this.frag.child(this.index);if(this.off==e)return t;this.off+=t.nodeSize,this.index++}return null}},Jo=class n{constructor(e,t){this.toDOM=e,this.spec=t||hn,this.side=this.spec.side||0}map(e,t,r,o){let{pos:i,deleted:s}=e.mapResult(t.from+o,this.side<0?-1:1);return s?null:new ge(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&zr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},fn=class n{constructor(e,t){this.attrs=e,this.spec=t||hn}map(e,t,r,o){let i=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new ge(i,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&zr(this.attrs,e.attrs)&&zr(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},Il=class n{constructor(e,t){this.attrs=e,this.spec=t||hn}map(e,t,r,o){let i=e.mapResult(t.from+o,1);if(i.deleted)return null;let s=e.mapResult(t.to+o,-1);return s.deleted||s.pos<=i.pos?null:new ge(i.pos-r,s.pos-r,this)}valid(e,t,r){let o=r.nodeAt(t.from);return!!o&&!o.isText&&t.from+o.nodeSize==t.to}eq(e){return this==e||e instanceof n&&zr(this.attrs,e.attrs)&&zr(this.spec,e.spec)}destroy(){}},ge=class n{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new n(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new n(e,e,new Jo(t,r))}static inline(e,t,r,o){return new n(e,t,new fn(r,o))}static node(e,t,r,o){return new n(e,t,new Il(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof fn}get widget(){return this.type instanceof Jo}},Wn=[],hn={},ae=class n{constructor(e,t){this.local=e.length?e:Wn,this.children=t.length?t:Wn}static create(e,t){return t.length?Yo(t,e,0,hn):Se}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,i){for(let s=0;s<this.local.length;s++){let l=this.local[s];if(l.from>t)break;l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length&&!(this.children[s]>=t);s+=3)if(this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,o+l,i)}}map(e,t,r){return this==Se||e.maps.length==0?this:this.mapInner(e,t,0,0,r||hn)}mapInner(e,t,r,o,i){let s;if(this.local.length){let l=new $r(t.content);for(let a=0;a<this.local.length;a++){let c=this.local[a].map(e,r,o);c&&c.type.valid(t,c,l)?(s||(s=[])).push(c):i.onRemove&&i.onRemove(this.local[a].spec)}}return this.children.length?$k(this.children,s||[],e,t,r,o,i):s?new n(s.sort(Wt),Wn):Se}add(e,t){return t.length?this==Se?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,i=0;e.forEach((l,a)=>{let c=a+r,d;if(d=Uf(t,l,c)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,d,c+1):o.splice(i,0,a,a+l.nodeSize,Yo(d,l,c+1,hn)),i+=3}});let s=Kf(i?Jf(t):t,-r).sort(Wt);if(s.length){let l=new $r(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||s.splice(a--,1)}return new n(s.length?this.local.concat(s).sort(Wt):this.local,o||this.children)}remove(e){return e.length==0||this==Se?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let s,l=r[i]+t,a=r[i+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(s||(s=[])).push(u));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(s,l+1);c!=Se?r[i+2]=c:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,s;i<e.length;i++)if(s=e[i])for(let l=0;l<o.length;l++)o[l].eq(s,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new n(o,r):Se}forChild(e,t){if(this==Se)return this;if(t.isLeaf)return n.empty;let r,o,i=0,s=this.children.length/3;for(;i<s;){let c=i+s>>>1,d=c*3,u=this.children[d];if(u<e)i=c+1;else if(u>e)s=c;else{r=this.children[d+2];break}}let l=e+1,a=l+t.content.size;for(let c=0;c<this.local.length;c++){let d=this.local[c];if(d.from<a&&d.to>l&&d.type instanceof fn){let u=Math.max(l,d.from)-l,p=Math.min(a,d.to)-l;u<p&&(o||(o=[])).push(d.copy(u,p))}}if(o){let c=new n(o.sort(Wt),Wn);return r?new Go([c,r]):c}return r||Se}eq(e){if(this==e)return!0;if(!(e instanceof n)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Wl(this.localsInner(e))}localsInner(e){if(this==Se)return Wn;if(e.inlineContent||!this.local.some(fn.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof fn||t.push(this.local[r]);return t}forEachSet(e){e(this)}};ae.empty=new ae([],[]);ae.removeOverlap=Wl;var Se=ae.empty,Go=class n{constructor(e){this.members=e}map(e,t){let r=this.members.map(o=>o.map(e,t,hn));return n.from(r)}forChild(e,t){if(t.isLeaf)return ae.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,t);i!=Se&&(i instanceof n?r=r.concat(i.members):r.push(i))}return n.from(r)}eq(e){if(!(e instanceof n)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(e);if(i.length)if(!t)t=i;else{r&&(t=t.slice(),r=!1);for(let s=0;s<i.length;s++)t.push(i[s])}}return t?Wl(r?t:t.sort(Wt)):Wn}static from(e){switch(e.length){case 0:return Se;case 1:return e[0];default:return new n(e.every(t=>t instanceof ae)?e:e.reduce((t,r)=>t.concat(r instanceof ae?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function $k(n,e,t,r,o,i,s){let l=n.slice();for(let c=0,d=i;c<t.maps.length;c++){let u=0;t.maps[c].forEach((p,f,h,m)=>{let g=m-h-(f-p);for(let y=0;y<l.length;y+=3){let x=l[y+1];if(x<0||p>x+d-u)continue;let M=l[y]+d-u;f>=M?l[y+1]=p<=M?-2:-1:p>=d&&g&&(l[y]+=g,l[y+1]+=g)}u+=g}),d=t.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=t.map(n[c]+i),u=d-o;if(u<0||u>=r.content.size){a=!0;continue}let p=t.map(n[c+1]+i,-1),f=p-o,{index:h,offset:m}=r.content.findIndex(u),g=r.maybeChild(h);if(g&&m==u&&m+g.nodeSize==f){let y=l[c+2].mapInner(t,g,d+1,n[c]+i+1,s);y!=Se?(l[c]=u,l[c+1]=f,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Vk(l,n,e,t,o,i,s),d=Yo(c,r,0,s);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,p=0;u<d.children.length;u+=3){let f=d.children[u];for(;p<l.length&&l[p]<f;)p+=3;l.splice(p,0,d.children[u],d.children[u+1],d.children[u+2])}}return new ae(e.sort(Wt),l)}function Kf(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new ge(o.from+e,o.to+e,o.type))}return t}function Vk(n,e,t,r,o,i,s){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(r,o,c);u?t.push(u):s.onRemove&&s.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<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+i+1);return t}function Uf(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let i=0,s;i<n.length;i++)(s=n[i])&&s.from>t&&s.to<r&&((o||(o=[])).push(s),n[i]=null);return o}function Jf(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Yo(n,e,t,r){let o=[],i=!1;e.forEach((l,a)=>{let c=Uf(n,l,a+t);if(c){i=!0;let d=Yo(c,l,t+a+1,r);d!=Se&&o.push(a,a+l.nodeSize,d)}});let s=Kf(i?Jf(n):n,-t).sort(Wt);if(s.length){let l=new $r(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1))}return s.length||o.length?new ae(s,o):Se}function Wt(n,e){return n.from-e.from||n.to-e.to}function Wl(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let i=e[o];if(i.from==r.from){i.to!=r.to&&(e==n&&(e=n.slice()),e[o]=i.copy(i.from,r.to),sf(e,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,i.from),sf(e,o,r.copy(i.from,r.to)));break}}}return e}function sf(n,e,t){for(;e<n.length&&Wt(t,n[e])>0;)e++;n.splice(e,0,t)}function vl(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=Se&&e.push(r)}),n.cursorWrapper&&e.push(ae.create(n.state.doc,[n.cursorWrapper.deco])),Go.from(e)}function qk(n,e,t,r){let{node:o,fromOffset:i,toOffset:s,from:l,to:a}=n.docView.parseRange(e,t),c=n.domSel.range,d,u=c.anchorNode;if(u&&Un(n.dom,u)&&(d=[{node:u,offset:c.anchorOffset}],Xo(c)||d.push({node:c.focusNode,offset:c.focusOffset})),Pe&&n.input.lastKeyCode===8)for(let y=s;y>i;y--){let x=o.childNodes[y-1],M=x.pmViewDesc;if(x.nodeName=="BR"&&!M){s=y;break}if(!M||M.size)break}let p=n.state.doc,f=n.someProp("domParser")||St.fromSchema(n.state.schema),h=p.resolve(l),m=null,g=f.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:d,ruleFromNode:jk(r),context:h});if(d&&d[0].pos!=null){let y=d[0].pos,x=d[1]&&d[1].pos;x==null&&(x=y),m={anchor:y+l,head:x+l}}return{doc:g,sel:m,from:l,to:a}}var jk=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(Re&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||Re&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},Wk=/^(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 Kk(n,e,t,r,o,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let P=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,v=Vl(n,n.domSel.range,P);if(v&&!n.state.selection.eq(v)&&n.domSel.active){if(Pe&&Nt&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&jt(n,"Enter"))return;let k=n.state.tr.setSelection(v);P=="pointer"?k.setMeta("pointer",!0):P=="key"&&k.scrollIntoView(),s&&k.setMeta("composition",s),n.dispatch(k)}return}let l=n.state.doc.resolve(e),a=l.sharedDepth(t);e=l.before(a+1),t=n.state.doc.resolve(t).after(a+1);let c=n.state.selection,d=qk(n,e,t,i),u=n.state.doc,p=u.slice(d.from,d.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let m=Yk(p.content,d.doc.content,d.from,f,h);if(m&&n.input.domChangeCount++,(Gn&&n.input.lastIOSEnter>Date.now()-225||Nt)&&i.some(P=>W(P)&&!Wk.test(P.nodeName))&&(!m||m.endA>=m.endB)&&jt(n,"Enter")){n.input.lastIOSEnter=0;return}if(!m)if(o&&c instanceof F&&!c.empty&&c.$head.sameParent(c.$anchor)&&!n.composing&&!(d.sel&&d.sel.anchor!=d.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(d.sel){let P=lf(n,n.state.doc,d.sel);if(P&&!P.eq(n.state.selection)){let v=n.state.tr.setSelection(P);s&&v.setMeta("composition",s),n.dispatch(v)}}return}n.state.selection.from<n.state.selection.to&&m.start==m.endB&&n.state.selection instanceof F&&(m.start>n.state.selection.from&&m.start<=n.state.selection.from+2&&n.state.selection.from>=d.from?m.start=n.state.selection.from:m.endA<n.state.selection.to&&m.endA>=n.state.selection.to-2&&n.state.selection.to<=d.to&&(m.endB+=n.state.selection.to-m.endA,m.endA=n.state.selection.to));let g=d.doc.resolveNoCache(m.start-d.from),y=d.doc.resolveNoCache(m.endB-d.from),x=u.resolve(m.start),M=g.sameParent(y)&&g.parent.inlineContent&&x.end()>=m.endA;if((Gn&&n.input.lastIOSEnter>Date.now()-225&&(!M||i.some(P=>P.nodeName=="DIV"||P.nodeName=="P"))||!M&&Gk(d.doc,g.pos,y.pos))&&jt(n,"Enter")){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>m.start&&(M?m.endA>m.start&&m.endB==m.start:Jk(u,m.start,m.endA,g,y))&&jt(n,"Backspace")){Nt&&Pe&&n.domSel.suppressChanges();return}Pe&&m.endB==m.start&&(n.input.lastChromeDelete=Date.now()),Nt&&!M&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&d.sel&&d.sel.anchor==d.sel.head&&d.sel.head==m.endA&&(m.endB-=2,y=d.doc.resolveNoCache(m.endB-d.from),setTimeout(()=>jt(n,"Enter"),20));let L=m.start,O=m.endA,B=P=>{let v=P||n.state.tr.replace(L,O,d.doc.slice(m.start-d.from,m.endB-d.from));if(d.sel){let k=lf(n,v.doc,d.sel);k&&!(Pe&&n.composing&&k.empty&&(m.start!=m.endB||n.input.lastChromeDelete<Date.now()-100)&&(k.head==L||k.head==v.mapping.map(O)-1))&&v.setSelection(k)}return s&&v.setMeta("composition",s),v.scrollIntoView()},J;if(M)if(g.pos==y.pos){let P=B(n.state.tr.delete(L,O)),v=u.resolve(m.start).marksAcross(u.resolve(m.endA));v&&P.ensureMarks(v),n.dispatch(P)}else if(m.endA==m.endB&&(J=Uk(g.parent.content.cut(g.parentOffset,y.parentOffset),x.parent.content.cut(x.parentOffset,m.endA-x.start())))){let P=B(n.state.tr);J.type=="add"?P.addMark(L,O,J.mark):P.removeMark(L,O,J.mark),n.dispatch(P)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let P=g.parent.textBetween(g.parentOffset,y.parentOffset),v=()=>B(n.state.tr.insertText(P,L,O));n.someProp("handleTextInput",k=>k(n,L,O,P,v))||n.dispatch(v())}else n.dispatch(B());else n.dispatch(B())}function lf(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Yn(n,e.resolve(t.anchor),e.resolve(t.head))}function Uk(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,i=r,s,l,a;for(let d=0;d<r.length;d++)o=r[d].removeFromSet(o);for(let d=0;d<t.length;d++)i=t[d].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],s="add",a=d=>d.mark(l.addToSet(d.marks));else if(o.length==0&&i.length==1)l=i[0],s="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(N.from(c).eq(n))return{mark:l,type:s}}function Jk(n,e,t,r,o){if(t-e<=o.pos-r.pos||xl(r,!0,!1)<o.pos)return!1;let i=n.resolve(e);if(!r.parent.inlineContent){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=n.resolve(xl(i,!0,!0));return!s.parent.isTextblock||s.pos>t||xl(s,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function Gk(n,e,t){let r=0,o=0;return n.nodesBetween(e,t,(i,s)=>{i.isTextblock&&s>=e&&s<t?r++:(i.isText?/\S/.test(i.text.slice(Math.max(0,e-s),Math.min(i.nodeSize,t-s))):i.isLeaf)&&o++}),o==0&&r==1}function xl(n,e,t){let r=n.depth,o=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function Yk(n,e,t,r,o){let i=n.findDiffStart(e,t),s=t+n.size,l=t+e.size;if(i==null)return null;let{a,b:c}=n.findDiffEnd(e,s,l);if(o=="end"){let d=Math.max(0,i-Math.min(a,c));r-=a+d-i}if(a<i&&s<l){let d=r<=i&&r>=a?i-r:0;i-=d,c=i+(c-a),a=i}else if(c<i){let d=r<=i&&r>=c?i-r:0;i-=d,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}var Xk={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Hl=class{constructor(e){this.view=e,this.queue=[],this.flushingSoon=-1,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.started=!1,this.observer=new window.MutationObserver(t=>{for(let r=0;r<t.length;r++)this.queue.push(t[r]);Re&&e.composing&&t.some(r=>r.type=="childList"&&r.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()})}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(e=!1){this.flushingSoon>-1?(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush(!0)):e&&this.flush(!0)}start(){this.observer.takeRecords(),this.observer.observe(this.view.dom,Xk),this.started=!0}stop(){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect(),this.started=!1}stopped(e){if(!this.started)return e();this.stop();try{return e()}finally{this.start()}}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let i=e.focusNode;i;i=Kn(i))t.add(i);for(let i=e.anchorNode;i;i=Kn(i))if(t.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:ke(r)?r.parentNode:r}))return this.view.domSel.ignore(e),!0}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(e=!0){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let r=this.pendingRecords();r.length&&(this.queue=[]),e&&t.domSel.read();let o=!t.domSel.suppress&&!t.domSel.synced&&!!Hf(t)&&!this.ignoreSelectionChange(t.domSel.range),i=-1,s=-1,l=!1,a=[];if(t.editable)for(let d=0;d<r.length;d++){let u=this.registerMutation(r[d],a);u&&(i=i<0?u.from:Math.min(u.from,i),s=s<0?u.to:Math.max(u.to,s),u.typeOver&&(l=!0))}if(a.some(d=>d.nodeName=="BR")&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46||Pe&&(t.composing||t.input.compositionEndedAt>Date.now()-50)&&r.some(d=>d.type=="childList"&&d.removedNodes.length))){for(let d of a)if(d.nodeName=="BR"&&d.parentNode){let u=d.nextSibling;for(;u&&W(u);){if(u.contentEditable=="false"){d.parentNode.removeChild(d);break}u=u.firstChild}}}else if(Ge&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,p]=d;u.parentNode&&u.parentNode.parentNode==p.parentNode?p.remove():u.remove()}else{let{focusNode:u}=t.domSel.range;for(let p of d){let f=p.parentNode;f&&f.nodeName=="LI"&&(!u||Qk(t,u)!=f)&&p.remove()}}}let c=null;i<0&&o&&t.domSel.active&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Xo(t.domSel.range)&&(c=Vl(t,t.domSel.range))&&c.eq(K.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,t.domSel.sync(),t.scrollToSelection()):(i>-1||o)&&(i>-1&&Zk(t),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,ev(t,a)),Kk(this.view,i,s,o,l,a),t.docView&&t.docView.damage?t.updateState(t.state):o&&t.domSel.sync())}registerMutation(e,t){var r;if(t.indexOf(e.target)>-1)return null;let o;for(let i=e.target;i&&!(o=this.view.docView.getDesc(i));i=i.parentNode);if(e.type=="attributes"&&(o==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!o||o.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let p=e.addedNodes[u];t.push(p),ke(p)&&(this.lastChangedTextNode=p)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return o.markDamage(4),{from:o.posBefore,to:o.posAfter};let i=e.previousSibling,s=e.nextSibling,l=i&&i.parentNode==e.target?Le(i)+1:0,a=o.localPosFromDOM(e.target,l,-1),c=s&&s.parentNode==e.target?Le(s):e.target.childNodes.length,d=o.localPosFromDOM(e.target,c,1);return o.markDamage(!((r=o.contentDOM)===null||r===void 0)&&r.contains(e.target)?2:4),{from:a,to:d}}else return e.type=="attributes"?(o.markDamage(4),{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}):(this.lastChangedTextNode=e.target,o.markDamage(o instanceof _r&&e.target==o.nodeDOM?8:4),{from:o.posAtStart,to:o.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},af=new WeakMap,cf=!1;function Zk(n){if(!af.has(n)&&(af.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ge,cf)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."),cf=!0}}function Qk(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function ev(n,e){var t;let{focusNode:r,focusOffset:o}=n.domSel.range;for(let i of e)if(((t=i.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=i.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||!W(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&n.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}var tv=$l,nv=Ut,Xn=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Pl,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(hf),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=pf(this),uf(this),this.nodeViews=ff(this),this.docView=Vp(this.state.doc,df(this),vl(this),this.dom,this),this.domObserver=new Hl(this),this.domSel=new Ll(this),this.domObserver.start(),this.domSel.read(),xk(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Rl(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(hf),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(qf(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=ff(this);ov(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Rl(this),this.editable=pf(this),uf(this);let a=vl(this),c=df(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(o.selection))&&(s=!0);let p=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Fb(this);s&&this.domObserver.stopped(()=>{let f=u&&Pe&&!this.composing&&!o.selection.empty&&!e.selection.empty&&rv(o.selection,e.selection);if(u){let h=Pe?this.trackWrites=this.domSel.range.focusNode:null;if(this.composing&&(this.input.compositionNode=_k(this)),i||!this.docView.update(e.doc,c,a,this,-1)){let m=this.docView.outerDeco;this.docView.destroy(),this.docView=Vp(e.doc,c,a,this.dom,this,m)}h&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}this.domSel.sync(f)}),this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():p&&zb(p)}scrollToSelection(){let e=this.domSel.range.focusNode;if(!(!e||!this.domSel.active)){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof R){let t=this.docView.domAfterPos(this.state.selection.from);W(t)&&Bp(this,t.getBoundingClientRect(),e)}else Bp(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,o=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let i=r.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new Uo(e.slice,e.move,o<0?void 0:R.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(o=t?t(l):l))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let l=i[s].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){return this.root.activeElement==this.dom}focus(){this.editable&&wf(this.dom),this.domSel.sync()}get root(){let e=this.dom.isConnected!==!1;e||(this._root=null);let t=this._root;if(t==null&&e){for(let r=this.dom.parentNode;r;r=r.parentNode)if(r.nodeType==9||r.nodeType==11&&r.host)return r.getSelection||(Object.getPrototypeOf(r).getSelection=()=>r.ownerDocument.getSelection()),this._root=r}return t||document}updateRoot(){this._root=null}posAtCoords(e){return Wb(this,e)}coordsAtPos(e,t=1){return Ef(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return Yb(this,t||this.state,e)}pasteHTML(e,t){return Fr(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Fr(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return zl(this,e)}destroy(){this.docView&&(wk(this),this.domSel.destroy(),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],vl(this),this,-1),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Lb())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Mk(this,e)}domSelection(){return this.root.getSelection()}};Xn.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function df(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[ge.node(0,n.state.doc.content.size,e)]}function uf(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ge.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function pf(n){return!n.someProp("editable",e=>e(n.state)===!1)}function rv(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function ff(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function ov(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function hf(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Yl={};j(Yl,{keydownHandler:()=>ti,keymap:()=>We});var Jl={};j(Jl,{base:()=>ut,keyName:()=>Ul,shift:()=>Vr});var ut={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:"'"},Vr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},iv=typeof navigator<"u"&&/Mac/.test(navigator.platform),sv=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(pe=0;pe<10;pe++)ut[48+pe]=ut[96+pe]=String(pe);var pe;for(pe=1;pe<=24;pe++)ut[pe+111]="F"+pe;var pe;for(pe=65;pe<=90;pe++)ut[pe]=String.fromCharCode(pe+32),Vr[pe]=String.fromCharCode(pe);var pe;for(ei in ut)Vr.hasOwnProperty(ei)||(Vr[ei]=ut[ei]);var ei;function Ul(n){var e=iv&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||sv&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Vr:ut)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var lv=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),av=typeof navigator<"u"&&/Win/.test(navigator.platform);function cv(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,i,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))lv?s=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),s&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function dv(n){let e=Object.create(null);for(let t in n)e[cv(t)]=n[t];return e}function Gl(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function We(n){return new z({props:{handleKeyDown:ti(n)}})}function ti(n){let e=dv(n);return function(t,r){let o=Ul(r),i,s=e[Gl(o,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[Gl(o,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(av&&r.ctrlKey&&r.altKey)&&(i=ut[r.keyCode])&&i!=o){let l=e[Gl(i,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var ta={};j(ta,{COMMENT_ID_RE:()=>gn,COMMENT_MAX_LENGTH:()=>ni,COMMENT_NAME_MAX_LENGTH:()=>Ql,createCommentStore:()=>ea,newCommentId:()=>ri,sanitizeThread:()=>Xl});var gn=/^[A-Za-z0-9_-]{1,64}$/,ni=5e3,Ql=80;function ri(n="c"){let e=new Uint8Array(9);return globalThis.crypto.getRandomValues(e),n+Array.from(e,t=>(t%36).toString(36)).join("")}function Xl(n){if(!n||typeof n!="object")return null;let e=n;if(typeof e.id!="string"||!gn.test(e.id))return null;let t=Array.isArray(e.comments)?e.comments.map(Gf).filter(i=>i!==null):[],r=e.resolved,o={id:e.id,createdAt:Number(e.createdAt)||0,comments:t,resolved:r&&typeof r=="object"?{by:Zl(r.by),at:Number(r.at)||0}:null};return typeof e.suggestion=="string"&&gn.test(e.suggestion)&&(o.suggestion=e.suggestion),o}function Zl(n){let e=n&&typeof n=="object"?n:{};return{id:String(e.id??"").slice(0,128),name:String(e.name??"").slice(0,80)}}function Gf(n){if(!n||typeof n!="object")return null;let e=n;if(typeof e.id!="string"||!gn.test(e.id))return null;let t={id:e.id,author:Zl(e.author),text:String(e.text??"").slice(0,5e3),createdAt:Number(e.createdAt)||0};if(e.editedAt&&(t.editedAt=Number(e.editedAt)||0),Array.isArray(e.mentions)){let r=e.mentions.slice(0,20).map(Zl).filter(o=>/^[\w.@:+-]{1,128}$/.test(o.id)&&o.name);r.length&&(t.mentions=r)}return t}function ea(n=[],e){let t=n.map(Xl).filter(s=>s!==null),r=new Set,o=s=>{t=s,e?.(t),r.forEach(l=>l())},i=(s,l)=>o(t.map(a=>a.id===s?l(a):a));return{threads:()=>t,subscribe(s){return r.add(s),()=>r.delete(s)},createThread(s){let l=Xl(s);!l||t.some(a=>a.id===l.id)||o([...t,l])},reply(s,l){let a=Gf(l);a&&i(s,c=>({...c,comments:[...c.comments,a]}))},editComment(s,l,a){i(s,c=>({...c,comments:c.comments.map(d=>d.id===l?{...d,text:a.slice(0,5e3),editedAt:Date.now()}:d)}))},deleteComment(s,l){i(s,a=>({...a,comments:a.comments.filter(c=>c.id!==l)}))},setResolved(s,l){i(s,a=>({...a,resolved:l??null}))},deleteThread(s){o(t.filter(l=>l.id!==s))}}}var oa={};j(oa,{MENTION_ID_RE:()=>ii,default:()=>ra,findMentionUsers:()=>na,getMentions:()=>pv});var ii=/^[\w.@:+-]{1,128}$/,uv=80,oi=n=>n.replace(/^@/,"").trim().slice(0,uv);async function na(n,e,t=8){let r=await n(e);return Array.isArray(r)?r.filter(o=>o&&typeof o.id=="string"&&ii.test(o.id)&&o.name).slice(0,t).map(o=>({id:o.id,name:oi(String(o.name)),...o.description?{description:String(o.description).slice(0,120)}:{}})):[]}function pv(n){let e="view"in n?n.view.state.doc:n,t=new Map;return e.descendants(r=>{r.type.name==="mention"&&!t.has(r.attrs.id)&&t.set(r.attrs.id,{id:r.attrs.id,name:r.attrs.name})}),[...t.values()]}var ra={name:"mentions",nodes:{mention:{group:"inline",inline:!0,atom:!0,selectable:!1,attrs:{id:{},name:{default:""}},parseDOM:[{tag:"span[data-mention]",getAttrs:n=>{let e=n,t=e.getAttribute("data-mention")??"";return ii.test(t)?{id:t,name:oi(e.textContent??"")}:!1}}],toDOM:n=>["span",{"data-mention":ii.test(n.attrs.id)?n.attrs.id:null},`@${oi(String(n.attrs.name))}`],leafText:n=>`@${oi(String(n.attrs.name))}`}},load:()=>import(__novaChunk("tinymce-chunks/mentions-ui-b1bb2d15.js") )};var Qf={en:{add:"Add comment",show:"Comments",panel:"Comments",guest:"Guest",newComment:"New comment",placeholder:"Add a comment\u2026",replyPlaceholder:"Reply\u2026",comment:"Comment",reply:"Reply",cancel:"Cancel",save:"Save",edit:"Edit",remove:"Delete",resolve:"Resolve",reopen:"Reopen",deleteThread:"Delete thread",close:"Close comments",showResolved:"Show resolved",resolvedBy:"Resolved by {name}",orphan:"The commented text was deleted",empty:"No comments yet. Select text and press \u201CAdd comment\u201D ({shortcut}).",people:"People",noPeople:"No matches",edited:"edited",you:"you",count:"{count} comments"}},Yf=C.commentAdd,Xf=C.comments,si="Mod-Alt-m",pt=new Z("nova-comments"),ia=new WeakMap;function li(n){return ia.get(n)}function Zf(n){let e=new Map;return n.descendants((t,r)=>{if(t.isInline)for(let o of t.marks){if(o.type.name!=="comment")continue;let i=o.attrs.id,s=e.get(i)??[],l=s[s.length-1];l&&l.to===r?l.to=r+t.nodeSize:s.push({from:r,to:r+t.nodeSize}),e.set(i,s)}}),e}function fv(n){let{$from:e,empty:t}=n.selection;return(t?[...e.nodeBefore?.marks??[],...e.nodeAfter?.marks??[]]:e.nodeAfter?.marks??[]).filter(o=>o.type.name==="comment").map(o=>o.attrs.id)}var sa={name:"comments",toolbar:"addcomment showcomments",marks:{comment:{attrs:{id:{}},inclusive:!1,excludes:"",parseDOM:[{tag:"span[data-comment]",getAttrs:n=>{let e=n.getAttribute("data-comment")??"";return gn.test(e)?{id:e}:!1}}],toDOM:n=>["span",{"data-comment":gn.test(n.attrs.id)?n.attrs.id:null},0]}},prosemirrorPlugins:n=>{let e=null;return[We({[si]:()=>li(n)?.startComment()??!1}),new z({key:pt,state:{init:()=>({pending:null,active:null}),apply(t,r){let o=t.getMeta(pt),i=r;if(t.docChanged&&i.pending){let s=t.mapping.map(i.pending.from,1),l=t.mapping.map(i.pending.to,-1);i={...i,pending:s<l?{from:s,to:l}:null}}return o&&("pending"in o||"active"in o)&&(i={...i,...o}),i}},props:{decorations(t){let r=li(n),o=pt.getState(t),i=r?.store.threads();if(e&&e.doc===t.doc&&e.threads===i&&e.state===o)return e.set;let s=new Set((i??[]).filter(c=>!c.resolved).map(c=>c.id)),l=[];for(let[c,d]of Zf(t.doc)){if(!s.has(c))continue;let u=c===o.active?"nova-comment is-active":"nova-comment";for(let{from:p,to:f}of d)l.push(ge.inline(p,f,{class:u}))}if(o.pending){let{from:c,to:d}=o.pending;l.push(ge.inline(c,d,{class:"nova-comment is-active is-pending"}))}let a=ae.create(t.doc,l);return e={doc:t.doc,threads:i,state:o,set:a},a}},view:()=>({update(t,r){if(r.selection.eq(t.state.selection)||r.doc!==t.state.doc)return;let o=li(n);if(!o||pt.getState(t.state).pending)return;let i=new Set(o.store.threads().filter(l=>!l.resolved).map(l=>l.id)),s=fv(t.state).find(l=>i.has(l));s&&(s!==o.active()||!o.isPanelOpen())&&queueMicrotask(()=>{o.setActive(s),o.openPanel()})}})})]},setup(n){let e=Oe(n,"comments",Qf),t=n.options.pluginOptions?.comments??{},r=t.store??ea(t.threads??[],t.onChange),o={id:String(t.author?.id??"guest").slice(0,128),name:String(t.author?.name||e.guest).slice(0,80)},i=()=>n.schema.marks.comment,s=t.mentions??n.options.pluginOptions?.mentions?.fetch,l=(M,L=[])=>[...new Map(L.map(B=>[B.id,B])).values()].filter(B=>M.includes(`@${B.name}`)),a=(M,L)=>{let O=l(M,L);return{id:ri(),author:o,text:M,createdAt:Date.now(),...O.length?{mentions:O}:{}}},c=(M,L)=>{L.mentions?.length&&t.onMention?.({threadId:M,comment:L,users:L.mentions})},d=()=>pt.getState(n.view.state),u=M=>n.view.dispatch(n.view.state.tr.setMeta(pt,M)),p=null,f=!1;n.ui.registry.addSidebar("comments",{title:e.panel,button:!1,header:!1,render:async M=>{let{createCommentsPanel:L}=await import(__novaChunk("tinymce-chunks/comments-panel-152e9cbe.js") );return p=L(h),M.append(p.el),()=>p?.destroy()},onShow:()=>{f=!0,p&&(p.el.hidden=!1),n.root.classList.add("nova-comments-open"),p?.render()},onHide:()=>{f=!1,p&&(p.el.hidden=!0),n.root.classList.remove("nova-comments-open"),d().pending&&u({pending:null})}});let h={editor:n,store:r,author:o,labels:e,shortcut:si,pending:()=>d().pending,active:()=>d().active,setActive(M,L=!1){d().active!==M&&u({active:M}),p?.render();let O=M?h.ranges(M)[0]:void 0;if(L&&O){let{node:B}=n.view.domAtPos(O.from);(B instanceof Element?B:B.parentElement)?.scrollIntoView({block:"nearest"})}},startComment(){let{selection:M}=n.view.state;return M.empty||!n.isEditable()?!1:(u({pending:{from:M.from,to:M.to},active:null}),h.openPanel().then(()=>{p?.render(),p?.focusComposer()}),!0)},cancelPending(){u({pending:null}),p?.render(),n.focus()},findUsers:s?M=>na(s,M):null,submitPending(M,L){let O=d().pending,B=M.trim().slice(0,5e3);if(!O||!B)return null;let J=ri("t"),P=a(B,L);r.createThread({id:J,createdAt:P.createdAt,comments:[P],resolved:null});let{state:v}=n.view;return n.view.dispatch(v.tr.addMark(O.from,O.to,i().create({id:J})).setMeta(pt,{pending:null,active:J}).setMeta("addToHistory",!1)),p?.render(),c(J,P),J},reply(M,L,O){let B=L.trim().slice(0,5e3);if(!B)return;let J=a(B,O);r.reply(M,J),c(M,J)},ranges:M=>Zf(n.view.state.doc).get(M)??[],quote(M){let{doc:L}=n.view.state;return h.ranges(M).map(({from:O,to:B})=>L.textBetween(O,B," ")).join(" \u2026 ")},positionOf:M=>h.ranges(M)[0]?.from??Number.MAX_SAFE_INTEGER,deleteThread(M){let{state:L}=n.view,O=L.tr;for(let{from:B,to:J}of h.ranges(M))O.removeMark(B,J,i().create({id:M}));d().active===M&&O.setMeta(pt,{active:null}),(O.docChanged||O.getMeta(pt))&&n.view.dispatch(O.setMeta("addToHistory",!1)),r.deleteThread(M)},setResolved(M,L){r.setResolved(M,L?{by:o,at:Date.now()}:null),L&&d().active===M&&u({active:null})},canEdit:M=>t.canEdit?t.canEdit(M,o):M.author.id===o.id,isPanelOpen:()=>f,openPanel:()=>n.ui.sidebar.show("comments"),closePanel(){f&&(n.ui.sidebar.hide({restoreFocus:!1}),n.focus())}};ia.set(n,h);let m=r.subscribe(()=>{n.view.isDestroyed||(u({refresh:!0}),p?.render())}),g=()=>h.startComment(),y=()=>h.isPanelOpen()?h.closePanel():void h.openPanel(),x=M=>M.isEditable()&&!M.view.state.selection.empty;return n.ui.registry.addButton("addcomment",{icon:Yf,tooltip:e.add,shortcut:si,isEnabled:x,onAction:g}),n.ui.registry.addToggleButton("showcomments",{icon:Xf,tooltip:e.show,isActive:()=>f,onAction:y}),n.ui.registry.addMenuItem("addcomment",{text:e.add,icon:Yf,shortcut:si,isEnabled:x,onAction:g}),n.ui.registry.addMenuItem("showcomments",{text:e.show,icon:Xf,isActive:()=>f,onAction:y}),()=>{m(),ia.delete(n)}}};var da={};j(da,{LABELS:()=>th,default:()=>ca,flatList:()=>rh,isGroup:()=>nh,optionsOf:()=>ai});var th={en:{insert:"Insert variable",search:"Variables",empty:"No variables found",unknown:"Unknown variable"}},eh=/^[\w.:-]{1,100}$/,hv=/^data-[a-z0-9-]{1,40}$/;function ai(n){return n.options.pluginOptions?.mergetags??{}}function mv(n){let e=ai(n).attribute??"data-mergetag";return hv.test(e)?e:(console.warn(`[nova] mergetags: attribute "${e}" must look like data-name; using data-mergetag`),"data-mergetag")}var nh=n=>Array.isArray(n.items);function rh(n){return(ai(n).list??[]).flatMap(e=>nh(e)?e.items:[e])}function oh(n,e){return rh(n).find(t=>t.key===e)?.label}function gv(n){let e=mv(n);return{mergetag:{group:"inline",inline:!0,atom:!0,selectable:!0,draggable:!0,ignoreStyles:!0,attrs:{key:{},label:{default:""}},parseDOM:[{tag:`span[${e}]`,priority:60,getAttrs:t=>{let r=t,o=r.getAttribute(e)??"";return eh.test(o)?{key:o,label:oh(n,o)??r.textContent?.trim()??o}:!1}}],toDOM:t=>{let r=eh.test(t.attrs.key)?t.attrs.key:"",o=t.attrs.label==null||t.attrs.label===""?r:String(t.attrs.label);return["span",{[e]:r,contenteditable:"false"},o]}}}}var aa=class{constructor(e,t,r){S(this,"node",e);S(this,"editor",t);S(this,"unknownTitle",r);S(this,"dom");this.dom=document.createElement("span"),this.dom.className="nova-mergetag",this.dom.contentEditable="false",this.render()}render(){let e=this.node.attrs.key,t=oh(this.editor,e);this.dom.textContent=t??(this.node.attrs.label||e),this.dom.dataset.key=e;let o=!!ai(this.editor).list?.length&&t===void 0;this.dom.classList.toggle("is-unknown",o),this.dom.title=o?`${this.unknownTitle}: ${e}`:e}update(e){return e.type!==this.node.type?!1:(this.node=e,this.render(),!0)}selectNode(){this.dom.classList.add("is-selected")}deselectNode(){this.dom.classList.remove("is-selected")}stopEvent(){return!1}ignoreMutation(){return!0}},ca={name:"mergetags",toolbar:"mergetags",nodes:gv,prosemirrorPlugins:n=>{let e=Oe(n,"mergetags",th);return[new z({props:{nodeViews:{mergetag:(t,r)=>new aa(t,n,e.unknown)}}})]},load:()=>import(__novaChunk("tinymce-chunks/mergetags-ui-f5bdd1f9.js") )};var Ea={};j(Ea,{LABELS:()=>ga,OWN:()=>yi,RESOLVED:()=>yh,around:()=>gi,attrValue:()=>ka,blockSuggestion:()=>Ee,cleanFormat:()=>jr,default:()=>Ma,formatMarks:()=>bi,hasInline:()=>fi,isSuggesting:()=>xa,listSuggestions:()=>Sa,markup:()=>ba,resolveSuggestions:()=>Sh,setStructureTrackers:()=>Cv,setSuggesting:()=>Eh,suggestTransaction:()=>wh,suggestionColor:()=>bh,suggestionsKey:()=>Qn,suggestionsResult:()=>Fv});var fa={};j(fa,{addListNodes:()=>vv,bulletList:()=>sh,liftListItem:()=>yn,listItem:()=>lh,orderedList:()=>ih,sinkListItem:()=>di,splitListItem:()=>ci,splitListItemKeepMarks:()=>wv,wrapInList:()=>pa,wrapRangeInList:()=>ah});var yv=["ol",0],bv=["ul",0],kv=["li",0],ih={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs(n){return{order:n.hasAttribute("start")?+n.getAttribute("start"):1}}}],toDOM(n){return n.attrs.order==1?yv:["ol",{start:n.attrs.order},0]}},sh={parseDOM:[{tag:"ul"}],toDOM(){return bv}},lh={parseDOM:[{tag:"li"}],toDOM(){return kv},defining:!0};function ua(n,e){let t={};for(let r in n)t[r]=n[r];for(let r in e)t[r]=e[r];return t}function vv(n,e,t){return n.append({ordered_list:ua(ih,{content:"list_item+",group:t}),bullet_list:ua(sh,{content:"list_item+",group:t}),list_item:ua(lh,{content:e})})}function pa(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,s=o.blockRange(i);if(!s)return!1;let l=r?t.tr:null;return ah(l,s,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function ah(n,e,t,r=null){let o=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new Bt(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Bt(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=sn(i,t,r,e);return l?(n&&xv(n,e,l,o,t),!0):!1}function xv(n,e,t,r,o){let i=N.empty;for(let d=t.length-1;d>=0;d--)i=N.from(t[d].type.create(t[d].attrs,i));n.step(new re(e.start-(r?2:0),e.end,e.start,e.end,new D(i,0,0),t.length,!0));let s=0;for(let d=0;d<t.length;d++)t[d].type==o&&(s=d+1);let l=t.length-s,a=e.start+t.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,p=!0;d<u;d++,p=!1)!p&&l&&Et(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function Zn(n,e){return n instanceof it?e==n:n.indexOf(e)>-1}function ci(n,e){return function(t,r){let{$from:o,$to:i,node:s}=t.selection;if(s&&s.isBlock||o.depth<2||!o.sameParent(i))return!1;let l=o.node(-1);if(!Zn(n,l.type))return!1;if(o.parent.content.size==0&&o.node(-1).childCount==o.indexAfter(-1)){if(o.depth==3||!Zn(n,o.node(-3).type)||o.index(-2)!=o.node(-2).childCount-1)return!1;if(r){let u=N.empty,p=o.index(-1)?1:o.index(-2)?2:3;for(let y=o.depth-p;y>=o.depth-3;y--)u=N.from(o.node(y).copy(u));let f=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;u=u.append(N.from(o.node(-3).type.createAndFill()));let h=o.before(o.depth-(p-1)),m=t.tr.replace(h,o.after(-f),new D(u,4-p,0)),g=-1;m.doc.nodesBetween(h,m.doc.content.size,(y,x)=>{if(g>-1)return!1;y.isTextblock&&y.content.size==0&&(g=x+1)}),g>-1&&m.setSelection(K.near(m.doc.resolve(g))),r(m.scrollIntoView())}return!0}let a=i.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(o.pos,i.pos),d=a||e?[e?{type:l.type,attrs:e}:null,a?{type:a}:null]:void 0;return Et(c.doc,o.pos,2,d)?(r&&r(c.split(o.pos,2,d).scrollIntoView()),!0):!1}}function wv(n,e){let t=ci(n,e);return(r,o)=>t(r,o&&(i=>{let s=r.storedMarks||r.selection.$to.parentOffset&&r.selection.$from.marks();s&&i.ensureMarks(s),o(i)}))}function yn(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,s=>s.childCount>0&&Zn(n,s.firstChild.type));return i?t?Zn(n,r.node(i.depth-1).type)?Sv(e,t,i):Mv(e,t,i):!0:!1}}function Sv(n,e,t){let r=n.tr,o=t.end,i=t.$to.end(t.depth),s=t.parent.child(t.endIndex-1).type;o<i&&(r.step(new re(o-1,i,o,i,new D(N.from(s.create(null,t.parent.copy())),1,0),1,!0)),t=new Bt(r.doc.resolve(t.$from.pos),r.doc.resolve(i),t.depth));let l=lt(t);if(l==null)return!1;r.lift(t,l);let a=r.doc.resolve(r.mapping.map(o,-1)-1);return at(r.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&r.join(a.pos),e(r.scrollIntoView()),!0}function Mv(n,e,t){let r=n.tr,o=t.parent;for(let f=t.end,h=t.endIndex-1,m=t.startIndex;h>m;h--)f-=o.child(h).nodeSize,r.delete(f-1,f+1);let i=r.doc.resolve(t.start),s=i.nodeAfter;if(r.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,s.content.append(a?N.empty:N.from(o))))return!1;let u=i.pos,p=u+s.nodeSize;return r.step(new re(u-(l?1:0),p+(a?1:0),u+1,p-1,new D((l?N.empty:N.from(o.copy(N.empty))).append(a?N.empty:N.from(o.copy(N.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function di(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&Zn(n,c.firstChild.type));if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(!Zn(n,a.type))return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=N.from(c?a.lastChild.lastChild.type.create():null),u=new D(N.from(a.type.create(null,N.from(l.type.create(null,d)))),c?3:1,0),p=i.start,f=i.end;t(e.tr.step(new re(p-(c?3:1),f,p,f,u,1,!0)).scrollIntoView())}return!0}}var ui="nova:set-content";var qr=/^[A-Za-z0-9_-]{1,64}$/,tr=/^[\w.@:+-]{1,128}$/,ga={en:{toggle:"Suggest edits",review:"Review suggestions",accept:"Accept",reject:"Reject",acceptAll:"Accept all suggestions",rejectAll:"Reject all suggestions",next:"Next suggestion",previous:"Previous suggestion",inserted:"Inserted by {name}",deleted:"Deleted by {name}",formatted:"Formatted by {name}",toolbar:"Suggestion",guest:"Guest",none:"No suggestions",unsupported:"This change can\u2019t be a suggestion",unsupportedDirect:"This change can\u2019t be a suggestion. To make it, turn off Suggest edits."}},Qn=new Z("nova-suggestions"),yi="nova-suggestions-own",yh="nova-suggestions-resolved",ch=["#116329","#6639ba","#99286e","#0550ae","#953800","#0e5b5e"];function bh(n){let e=0;for(let t of String(n??""))e=e*31+t.charCodeAt(0)|0;return ch[Math.abs(e)%ch.length]}function pi(){let n=new Uint8Array(9);return globalThis.crypto.getRandomValues(n),"s"+Array.from(n,e=>(e%36).toString(36)).join("")}function dh(n){let e=n==="insert"?"ins":"del";return{attrs:{id:{},author:{default:""},name:{default:""},time:{default:0}},inclusive:!1,excludes:"",parseDOM:[{tag:`${e}[data-suggestion]`,priority:60,getAttrs:t=>{let r=t,o=r.getAttribute("data-suggestion")??"";if(!qr.test(o))return!1;let i=r.getAttribute("data-author")??"";return{id:o,author:tr.test(i)?i:"",name:(r.getAttribute("data-name")??"").slice(0,80),time:Number(r.getAttribute("data-time"))||0}}}],toDOM:t=>[e,{"data-suggestion":qr.test(t.attrs.id)?t.attrs.id:null,"data-author":tr.test(t.attrs.author)?t.attrs.author:null,"data-name":String(t.attrs.name??"").slice(0,80)||null,"data-time":Number(t.attrs.time)||null},0]}}function jr(n){let e;try{e=typeof n=="string"?JSON.parse(n):n}catch{return"[]"}if(!Array.isArray(e))return"[]";let t=[];for(let r of e.slice(0,16)){let o=r?.type;if(typeof o!="string"||!/^[a-z][a-z0-9_]{0,39}$/.test(o))continue;let i=kh(r.attrs,8);t.push(Object.keys(i).length?{type:o,attrs:i}:{type:o})}return JSON.stringify(t)}function kh(n,e){let t={};if(n&&typeof n=="object"&&!Array.isArray(n))for(let[r,o]of Object.entries(n).slice(0,e))!/^[A-Za-z][\w-]{0,39}$/.test(r)||r==="suggestion"||(typeof o=="string"?t[r]=o.slice(0,2e3):(typeof o=="number"||typeof o=="boolean"||o===null)&&(t[r]=o));return t}function Ee(n){if(!n||typeof n!="object")return null;let e=n;if(typeof e.id!="string"||!qr.test(e.id))return null;let t=String(e.author??""),r={id:e.id,author:tr.test(t)?t:"",name:String(e.name??"").slice(0,80),time:Number(e.time)||0};if(e.change==="split"||e.change==="join"){let i=e.change==="join"&&e.before!=null?uh(e.before):null;return{...r,change:e.change,depth:Math.min(4,Math.max(1,Math.trunc(Number(e.depth))||1)),...i?{before:i}:{}}}if(e.change==="insert"||e.change==="delete")return{...r,change:e.change};if(e.change==="wrap"||e.change==="unwrap")return{...r,change:e.change,depth:Math.min(9,Math.max(1,Math.trunc(Number(e.depth))||1))};let o=uh(e.before);return o?{...r,change:"block",before:o}:null}function uh(n){let e=n;try{typeof e=="string"&&(e=JSON.parse(e))}catch{return null}let t=e?.type;return typeof t!="string"||!/^[a-z][a-z0-9_]{0,39}$/.test(t)?null:{type:t,attrs:kh(e.attrs,12)}}var Ev={nodes:"all",default:null,parse:n=>n.hasAttribute("data-before")||n.hasAttribute("data-change")?Ee({id:n.getAttribute("data-suggestion"),author:n.getAttribute("data-author"),name:n.getAttribute("data-name"),time:n.getAttribute("data-time"),before:n.getAttribute("data-before"),change:n.getAttribute("data-change"),depth:n.getAttribute("data-depth")}):null,render(n){let e=Ee(n);if(!e)return{};let t={"data-suggestion":e.id};return e.change!=="block"&&(t["data-change"]=e.change),e.before&&(t["data-before"]=JSON.stringify(e.before)),(e.depth??1)>1&&(t["data-depth"]=String(e.depth)),e.author&&(t["data-author"]=e.author),e.name&&(t["data-name"]=e.name),e.time&&(t["data-time"]=String(e.time)),t}},hi=null;function Cv(n){hi=n}function Av(){return{attrs:{id:{},author:{default:""},name:{default:""},time:{default:0},before:{default:"[]"}},inclusive:!1,excludes:"",parseDOM:[{tag:"span[data-suggestion][data-format]",priority:60,getAttrs:n=>{let e=n,t=e.getAttribute("data-suggestion")??"";if(!qr.test(t))return!1;let r=e.getAttribute("data-author")??"";return{id:t,author:tr.test(r)?r:"",name:(e.getAttribute("data-name")??"").slice(0,80),time:Number(e.getAttribute("data-time"))||0,before:jr(e.getAttribute("data-format"))}}}],toDOM:n=>["span",{"data-suggestion":qr.test(n.attrs.id)?n.attrs.id:null,"data-format":jr(n.attrs.before),"data-author":tr.test(n.attrs.author)?n.attrs.author:null,"data-name":String(n.attrs.name??"").slice(0,80)||null,"data-time":Number(n.attrs.time)||null},0]}}var Wr=n=>({insert:n.marks.suggestion_insert,delete:n.marks.suggestion_delete,format:n.marks.suggestion_format}),wa=new Set(["suggestion_insert","suggestion_delete","suggestion_format","comment"]),mi=n=>n.filter(e=>!wa.has(e.type.name));function bi(n,e){let t=[];for(let r of JSON.parse(jr(e)))if(!(wa.has(r.type)||!n.marks[r.type]))try{let o=n.markFromJSON(r);o.isInSet(t)||t.push(o)}catch{}return t}var ya=(n,e)=>n.length===e.length&&n.every(t=>t.isInSet(e));function Tv(n){return!n.docChanged||n.getMeta(yi)||n.getMeta("addToHistory")===!1||n.getMeta(ui)||n.getMeta("history$")?!1:!n.getMeta("y-sync$")?.isChangeOrigin}var er=n=>!!n.type.spec.attrs&&"suggestion"in n.type.spec.attrs;function bn(n,e,t,r,o=1){return{id:e,author:t.id,name:t.name,time:r,change:n,...o>1?{depth:o}:{}}}function gi(n,e,t){let r=n.resolve(e),o={own:!1,deleted:!1};for(let i=r.depth;i>0;i--){let s=Ee(r.node(i).attrs.suggestion);s?.change==="insert"&&s.author===t&&(o.own=!0),s?.change==="delete"&&(o.deleted=!0)}return o}function fi(n){let e=!1;return n.descendants(t=>(t.isInline&&(e=!0),!e)),e}function ba(n){let e={};for(let[t,r]of Object.entries(n.attrs))t!=="suggestion"&&(r===null||["string","number","boolean"].includes(typeof r))&&(e[t]=r);return{type:n.type.name,attrs:e}}function ka(n,e,t){return e.attrs[t]??n.nodes[e.type]?.spec.attrs?.[t]?.default??null}function ph(n,e,t){return[...new Set([...Object.keys(e.attrs),...Object.keys(t.attrs)])].filter(r=>ka(n,e,r)!==ka(n,t,r))}function Nv(n,e){if(n instanceof rn)return e.nodeAt(n.pos)?n.pos:null;if(n instanceof re){let t=e.nodeAt(n.from),r=n.slice.content.firstChild;return!!t&&!!r&&!r.isLeaf&&n.slice.content.childCount===1&&n.slice.openStart===0&&n.slice.openEnd===0&&n.insert===1&&n.to===n.from+t.nodeSize&&n.gapFrom===n.from+1&&n.gapTo===n.to-1&&r.content.size===0?n.from:null}if(n instanceof le){let{from:t,to:r,slice:o}=n,i=e.nodeAt(t),s=o.content.firstChild;return i?.isLeaf&&!i.isText&&s?.isLeaf&&i.type===s.type&&r===t+i.nodeSize&&o.content.childCount===1&&o.openStart===0&&o.openEnd===0&&ya(i.marks,s.marks)&&!i.eq(s)?t:null}return null}var Ov=new Set(["colwidth"]);function Lv(n,e,t,r,o,i){let s=n.doc.nodeAt(e);if(!s||!er(s)||!er(t))return!1;let l=n.doc.type.schema,a=m=>n.setNodeMarkup(e,t.type,{...t.attrs,suggestion:m},t.marks),c=Ee(s.attrs.suggestion),d=ba(s),u=ba(t);if(s.marks.some(m=>m.type.name==="suggestion_insert"&&m.attrs.author===r.id)||(c?.change==="insert"||c?.change==="split")&&c.author===r.id||gi(n.doc,e,r.id).own||d.type===u.type&&ph(l,d,u).every(m=>Ov.has(m)))return a(s.attrs.suggestion),!0;if(c&&c.change!=="block")return!1;let f=c?.before??d,h=f.type===u.type&&ph(l,f,u).length===0;return a(h?null:{id:c?.id??o(),author:r.id,name:r.name,time:i,change:"block",before:f}),!0}function va(n,e){let t=n.doc.nodeAt(e);if(!t||t.isLeaf)return null;let r=n.steps.length,o=n.doc.type.schema.nodes.list_item;if(t.type===o&&o){let i=cn.create({doc:n.doc,selection:F.near(n.doc.resolve(e+1))}),s=!1;if(yn(o)(i,l=>{for(let a of l.steps)n.step(a);s=!0}),!s)return null}else{let i=n.doc.resolve(e+1).blockRange(n.doc.resolve(e+t.nodeSize-1)),s=i&&lt(i);if(s==null)return null;n.lift(i,s)}return n.mapping.slice(r).map(e+1,1)}function vh(n,e){let t=n.resolve(e);return t.depth>0&&e===t.start()?t.before():null}function fh(n,e){return[...e].sort((t,r)=>r-t).every(t=>va(n,t)!==null)}function Pv(n,e,t,r,o,i,s){let l=hi?.structure(t,n.doc);if(!l?.nodes.length)return null;let a=(h,...m)=>!!h&&h.author===o.id&&m.includes(h.change);if(l.change==="wrap"){let h=new Mt(n.doc);if(!fh(h,l.nodes)||!h.doc.eq(t))return null;for(let m of l.nodes){let g=Ee(n.doc.nodeAt(m).attrs.suggestion);if(!a(g,"insert")){if(g&&!a(g,"wrap"))return null;n.setNodeAttribute(m,"suggestion",bn("wrap",g?.id??i(),o,s,(g?.depth??0)+1))}}return n}let c=new Mt(t);if(!fh(c,l.nodes)||!c.doc.eq(n.doc))return null;let d=l.nodes.map(h=>({pos:h,node:t.nodeAt(h)})),u=({node:h})=>{let m=h.childCount===1?h.firstChild:null,g=Ee(h.attrs.suggestion)??Ee(m?.attrs.suggestion),y=!0;return m?.descendants(x=>(x.isInline&&!x.marks.some(M=>M.type.name==="suggestion_insert"&&M.attrs.author===o.id)&&(y=!1),y)),!!m?.isTextblock&&a(g,"split","insert")&&y},p=({node:h})=>a(Ee(h.attrs.suggestion),"wrap");if(d.every(h=>u(h)||p(h))){let h=n.mapping.slice(e);for(let m of d){let g=h.map(m.pos+1,1),y=vh(n.doc,g),x=y===null?null:n.doc.nodeAt(y);if(p(m)){let O=Ee(m.node.attrs.suggestion);x?.type===m.node.type&&n.setNodeAttribute(y,"suggestion",(O.depth??1)>1?bn("wrap",O.id,o,O.time,O.depth-1):null);continue}let M=n.doc.nodeAt(g),L=Ee(m.node.attrs.suggestion)??Ee(m.node.firstChild.attrs.suggestion);M?.isTextblock&&x?.type.name!=="list_item"&&n.setNodeAttribute(g,"suggestion",bn("insert",L.id,o,L.time))}return n}let f=r.tr;for(let h of n.steps.slice(0,e))f.step(h);if(!f.doc.eq(t))return null;for(let{pos:h,node:m}of d){let g=Ee(m.attrs.suggestion);if(g&&!a(g,"unwrap"))return null;f.setNodeAttribute(h,"suggestion",bn("unwrap",g?.id??i(),o,s,(g?.depth??0)+1))}return f}function Rv(n,e,t,r,o,i,s){let l=Wr(n.doc.type.schema),a=(u,p)=>r==="add"?n.addMark(u,p,o):n.removeMark(u,p,o);if(wa.has(o.type.name)||!l.format){a(e,t);return}let c=[];n.doc.nodesBetween(e,t,(u,p,f)=>{if(!u.isInline)return!0;let h=Math.max(p,e),m=Math.min(p+u.nodeSize,t);return h<m&&f?.type.allowsMarkType(o.type)&&c.push({from:h,to:m,node:u}),!1});let d=null;for(let{from:u,to:p,node:f}of c){let h=r==="add"?o.addToSet(f.marks):o.removeFromSet(f.marks);if(ya(h,f.marks)||(a(u,p),f.marks.some(x=>x.type===l.insert&&x.attrs.author===i.id)||l.delete.isInSet(f.marks)))continue;let g=f.marks.find(x=>x.type===l.format);if(g){let x=bi(n.doc.type.schema,g.attrs.before);ya(mi(h),x)&&n.removeMark(u,p,g);continue}d??(d=pi());let y=jr(mi(f.marks).map(x=>x.toJSON()));n.addMark(u,p,l.format.create({id:d,author:i.id,name:i.name,time:s,before:y}))}}function ha(n,e,t,r){let o=n.resolve(e);for(let i of[o.nodeBefore,o.nodeAfter]){let s=i?.marks.find(l=>l.type===t&&l.attrs.author===r);if(s)return s}return null}function xh(n,e,t,r,o,i){let s=[];return n.forEach((l,a,c)=>{if(l.isInline){s.push(t&&!t.allowsMarkType(e.type)?l:l.mark(e.addToSet(l.marks)));return}let d=c===0&&r>0,u=c===n.childCount-1&&o>0;if(!d&&!u&&er(l)){s.push(l.type.create({...l.attrs,suggestion:i()},l.content,l.marks));return}s.push(l.copy(xh(l.content,e,l.type,d?r-1:0,u?o-1:0,i)))}),N.from(s)}function hh(n,e,t){n.maybeStep(new le(e,e,t)).failed&&n.replace(e,e,t)}function ma(n,e,t){if(n instanceof R){let r=t(n.from),o=e.nodeAt(r);if(o&&R.isSelectable(o))return R.create(e,r)}return F.between(e.resolve(t(n.anchor)),e.resolve(t(n.head)))}function wh(n,e,t,r){if(!Tv(n))return n;let o=()=>(r?.(),e.tr),i=hi?.breaks(n,e,t);if(i)return i;let s=Wr(e.schema),l=e.tr,a=Date.now(),c=null,d=()=>c??(c=pi()),u=L=>L,p=null,f=null,h=null,m=!1,g=!1,y=!1,x=null,M=null;for(let L=0;L<n.steps.length;L++){let O=n.steps[L],B=n.docs[L];if(O instanceof Ue||O instanceof Je){if(x!==null)return o();let U=O instanceof Ue?"add":"remove";Rv(l,u(O.from),u(O.to),U,O.mark,t,a);continue}let J=Nv(O,B);if(J!==null){if(x!==null||g)return o();y=!0;let U=(n.docs[L+1]??n.doc).nodeAt(J);if(!U||!Lv(l,u(J),U,t,d,a))return o();continue}if(O instanceof re||x!==null){let U=O instanceof le&&(fi(B.slice(O.from,O.to).content)||fi(O.slice.content));if(!hi||U||!(O instanceof re||O instanceof le))return o();if(x===null){if(!l.doc.eq(B))return o();x=l.steps.length,M=l.doc}if(l.maybeStep(O).failed)return o();continue}if(!(O instanceof le))return o();m=!0;let P=O,v=l.steps.length,k=u,E=k(P.from),b=Math.max(E,k(P.to)),A=!1;if(b>E){let U=[],se=[],Ae=[];l.doc.nodesBetween(E,b,(de,he)=>{let be=Math.max(he,E),Os=Math.min(he+de.nodeSize,b);if(be>=Os)return!1;if(!de.isInline){if(he<E||he+de.nodeSize>b)return!0;let Qt=Ee(de.attrs.suggestion);return Qt?.change==="insert"&&Qt.author===t.id?(U.push({from:he,to:he+de.nodeSize}),!1):Qt?.change==="delete"?!1:!er(de)||Qt?!0:(Ae.push(he),!1)}let fu=gi(l.doc,he,t.id);return fu.deleted||(fu.own||de.marks.some(Qt=>Qt.type===s.insert&&Qt.attrs.author===t.id)?U.push({from:be,to:Os}):s.delete.isInSet(de.marks)||se.push({from:be,to:Os})),!1});let rt=null;if(se.length){let de=se[0],he=ha(l.doc,de.from,s.delete,t.id)??ha(l.doc,se[se.length-1].to,s.delete,t.id)??s.delete.create({id:pi(),author:t.id,name:t.name,time:a});for(let be of se)l.addMark(be.from,be.to,he);rt=he.attrs.id}for(let de of Ae)l.setNodeAttribute(de,"suggestion",bn("delete",rt??d(),t,a));let $e=l.doc.resolve(E),xt=l.doc.resolve(b),ot=xt.parent;if($e.parent!==ot&&$e.parent.isTextblock&&ot.isTextblock&&$e.depth===xt.depth&&xt.start()>E&&er(ot)&&!ot.attrs.suggestion&&!Ae.includes(xt.before())&&l.setNodeAttribute(xt.before(),"suggestion",{id:rt??d(),author:t.id,name:t.name,time:a,change:"join",depth:xt.depth-$e.sharedDepth(b)}),(se.length||Ae.length)&&(g=!0,y))return o();A=Ae.length>0;for(let de of U.sort((he,be)=>be.from-he.from))l.delete(de.from,de.to);let ye=l.mapping.slice(v);E=ye.map(E,1),b=ye.map(b,-1);let He=e.selection;n.steps.length===1&&P.slice.size===0&&(He.empty&&He.from===P.from&&n.selection.head===P.from&&(p=b),He instanceof R&&Ae.includes(k(He.from))&&(f=ye.map(k(He.to),1)))}let H=A&&P.slice.content.childCount===1&&!P.slice.openStart&&!!P.slice.content.firstChild.isTextblock&&!P.slice.content.firstChild.content.size;if(P.slice.size>0&&!H){let U=b;if(gi(l.doc,U,t.id).own){let ye=l.doc.resolve(U),He=ye.parent.isTextblock?Ee(ye.parent.attrs.suggestion):null;if(hh(l,U,P.slice),He?.change==="insert"&&P.slice.openEnd>0){let be=l.doc.resolve(U+P.slice.size);be.parent.isTextblock&&!be.parent.attrs.suggestion&&l.setNodeAttribute(be.before(),"suggestion",He)}n.steps.length===1&&(h={at:U,from:P.from,size:P.slice.size});let de=P.getMap().invert(),he=l.mapping.slice(v);u=be=>he.map(k(de.map(be,-1)),1);continue}if(!P.slice.openStart)for(let ye=l.doc.resolve(U).nodeAfter;ye&&s.delete.isInSet(ye.marks);)U+=ye.nodeSize,ye=l.doc.resolve(U).nodeAfter;let se=ha(l.doc,U,s.insert,t.id)??s.insert.create({id:pi(),author:t.id,name:t.name,time:a}),Ae=l.doc.resolve(U),rt=()=>bn("insert",fi(P.slice.content)?se.attrs.id:d(),t,a),$e=xh(P.slice.content,se,P.slice.openStart?null:Ae.parent.type,P.slice.openStart,P.slice.openEnd,rt);hh(l,U,new D($e,P.slice.openStart,P.slice.openEnd)),n.steps.length===1&&(h={at:U,from:P.from,size:P.slice.size});let{openStart:xt,openEnd:ot}=P.slice;if(xt>0&&xt===ot&&Ae.parent.isTextblock){let ye=l.doc.resolve(U+P.slice.size),He=ye.depth>=ot?ye.before(ye.depth-ot+1):-1,de=Ae.parentOffset===Ae.parent.content.size&&He>=0&&He+l.doc.nodeAt(He).nodeSize===U+P.slice.size+ot,he=de?He:ye.depth>0?ye.before():-1,be=he>=0?l.doc.nodeAt(he):null;ye.parent.isTextblock&&be&&er(be)&&l.setNodeAttribute(he,"suggestion",de?bn("insert",se.attrs.id,t,a):{id:se.attrs.id,author:t.id,name:t.name,time:a,change:"split",depth:ot})}}let $=P.getMap().invert(),G=l.mapping.slice(v);u=U=>G.map(k($.map(U,-1)),1)}if(x!==null){let L=Pv(l,x,M,e,t,d,a);if(!L)return o();L===l?l.setSelection(n.selection.map(l.doc,l.mapping.slice(l.steps.length))):(l=L,l.setSelection(e.selection.map(l.doc,l.mapping)))}else if(!m)l.setSelection(n.selection.map(l.doc,l.mapping.slice(l.steps.length)));else if(p!==null)l.setSelection(F.create(l.doc,p));else if(f!==null)l.setSelection(K.near(l.doc.resolve(f),1));else if(h){let{at:L,from:O,size:B}=h,{anchor:J,head:P,empty:v}=n.selection,k=E=>E>=O&&E<=O+B;if(v&&P===O+B)l.setSelection(F.create(l.doc,L+B));else if(k(J)&&k(P))l.setSelection(ma(n.selection,l.doc,E=>E-O+L));else if(v){let E=l.doc.resolve(L+B);l.setSelection(F.between(E,E))}else l.setSelection(ma(n.selection,l.doc,u))}else l.setSelection(ma(n.selection,l.doc,u));for(let L of["addToHistory","uiEvent","paste","scrollIntoView"]){let O=n.getMeta(L);O!==void 0&&l.setMeta(L,O)}return n.scrolledIntoView&&l.scrollIntoView(),l}function Dv(n,e){let t=bi(n.type.schema,e.attrs.before),r=mi(n.marks),o=r.filter(s=>!s.isInSet(t)).map(s=>s.type.name),i=t.filter(s=>!s.isInSet(r)&&!o.includes(s.type.name)).map(s=>s.type.name);return{added:o,removed:i}}var mh=(n,e)=>{for(let t of e)n.includes(t)||n.push(t)};function Sa(n){let e=Wr(n.type.schema),t=[];return n.descendants((r,o)=>{if(!r.isText){let i=Ee(r.attrs.suggestion);if(i&&t.push({id:i.id,kind:i.change,author:{id:i.author,name:i.name},time:i.time,from:o,to:o+r.nodeSize,text:r.isLeaf?r.type.spec.leafText?.(r)??"":r.textContent,node:r.type.name,...i.before?{before:i.before}:{},...i.depth?{depth:i.depth}:{}}),!r.isInline)return!0}for(let i of r.marks){let s=i.type===e.insert?"insert":i.type===e.delete?"delete":i.type===e.format?"format":null;if(!s)continue;let l=t[t.length-1],a=r.isText?r.text:r.type.spec.leafText?.(r)??"",c=s==="format"?Dv(r,i):null;l&&l.id===i.attrs.id&&l.kind===s&&l.to===o?(l.to=o+r.nodeSize,l.text+=a,c&&(mh(l.added,c.added),mh(l.removed,c.removed))):t.push({id:i.attrs.id,kind:s,author:{id:i.attrs.author,name:i.attrs.name},time:Number(i.attrs.time)||0,from:o,to:o+r.nodeSize,text:a,...c??{}})}return!1}),t}function _v(n,e,t){let r=Wr(n.doc.type.schema).format,o=[];n.doc.nodesBetween(e.from,e.to,(i,s)=>{if(!i.isInline)return!0;let l=i.marks.find(a=>a.type===r&&a.attrs.id===e.id);return l&&o.push({from:Math.max(s,e.from),to:Math.min(s+i.nodeSize,e.to),node:i,mark:l}),!1});for(let{from:i,to:s,node:l,mark:a}of o){if(t==="reject"){let c=bi(n.doc.type.schema,a.attrs.before);for(let d of mi(l.marks))d.isInSet(c)||n.removeMark(i,s,d);for(let d of c)d.isInSet(l.marks)||n.addMark(i,s,d)}n.removeMark(i,s,a)}}function Iv(n,e,t){let r=e.from,o=n.doc.nodeAt(r);if(!o)return;let i=t==="reject"?n.doc.type.schema.nodes[e.before.type]:void 0,s=n.doc.resolve(r);if(i?.spec.attrs&&"suggestion"in i.spec.attrs&&s.parent.canReplaceWith(s.index(),s.index()+1,i)&&(o.isLeaf?i.isLeaf:!i.isLeaf&&i.validContent(o.content))){let l=Object.fromEntries(Object.entries(e.before.attrs).filter(([a])=>a in i.spec.attrs));try{n.setNodeMarkup(r,i,{...o.attrs,...l,suggestion:null},o.marks);return}catch{}}n.setNodeAttribute(r,"suggestion",null)}function Hv(n,e){let t=n.doc.nodeAt(e);if(!t)return;let r=n.doc.resolve(e),o=e,i=e+t.nodeSize;for(let s=r.depth;;s--){let l=r.node(s),a=r.index(s);if(l.canReplace(a,a+1)){n.delete(o,i);return}if(s===0||l.childCount>1||l.type.spec.isolating){let c=l.type.contentMatch.defaultType?.createAndFill();c&&l.canReplace(a,a+1,N.from(c))&&n.replaceWith(o,i,c);return}o=r.before(s),i=r.after(s)}}function Sh(n,e,t){let r=Wr(n.schema),o=n.tr.setMeta(yi,!0),i=Sa(n.doc).filter(p=>!t||t.includes(p.id));o.setMeta(yh,{action:e,ids:[...new Set(i.map(p=>p.id))]});for(let p of i)p.kind==="format"&&_v(o,p,e);let s=[],l=[];for(let p of i){if(!p.node)continue;let f=e==="reject",h=p.kind==="block"?f&&"style":p.kind==="join"?f?!!p.before&&"style":"join":p.kind==="split"?f&&"join":p.kind==="insert"?f&&"remove":p.kind==="delete"?!f&&"remove":p.kind==="wrap"?f&&"lift":!f&&"lift";h?h==="remove"?s.push(p):l.push({s:p,op:h}):o.setNodeAttribute(p.from,"suggestion",null)}for(let p of[...i].sort((f,h)=>h.from-f.from))p.kind!=="insert"&&p.kind!=="delete"||p.node||(p.kind==="insert"==(e==="reject")?o.delete(p.from,p.to):o.removeMark(p.from,p.to,p.kind==="insert"?r.insert:r.delete));let a=p=>{let f=o.mapping.mapResult(p.from,1);return(f.deleted?null:o.doc.nodeAt(f.pos))?.type.name===p.node?f.pos:null};for(let p of s.sort((f,h)=>h.from-f.from)){let f=a(p);f!==null&&Hv(o,f)}let c=({s:p,op:f},h)=>{let m=a(p);if(m===null)return!0;if(f==="join"){let y=m-((p.depth??1)-1);if(!at(o.doc,y))return!1;try{o.join(y,p.depth??1)}catch{return!1}return!0}if(f==="style")return!h&&!Bv(o.doc,m,p)?!1:(Iv(o,{...p,from:m},"reject"),!0);if(va(new Mt(o.doc),m)===null)return!1;o.setNodeAttribute(m,"suggestion",null);let g=m;for(let y=0;y<(p.depth??1)&&g!==null;y++){let x=va(o,g);g=x===null?null:vh(o.doc,x)}return!0},d={join:0,style:1,lift:2},u=l.sort((p,f)=>d[p.op]-d[f.op]||f.s.from-p.s.from);for(let p=0;p>=0;)p=u.findIndex(f=>c(f,!1)),p>=0&&u.splice(p,1);for(let p of u)if(p.op==="style")c(p,!0);else{let f=a(p.s);f!==null&&o.setNodeAttribute(f,"suggestion",null)}return o}function Bv(n,e,t){let r=n.nodeAt(e),o=t.before?n.type.schema.nodes[t.before.type]:void 0;if(!r||!o)return!1;let i=n.resolve(e);return i.parent.canReplaceWith(i.index(),i.index()+1,o)&&(r.isLeaf?o.isLeaf:!o.isLeaf&&o.validContent(r.content))}function Fv(n,e){return Sh(n.view.state,e).doc}function Mh(n){let e=[];return n.forEach(t=>{let r=t.marks.filter(i=>!i.type.name.startsWith("suggestion_"));if(t.isText){e.push(t.mark(r));return}let o=t.attrs.suggestion!=null?{...t.attrs,suggestion:null}:t.attrs;e.push(t.type.create(o,Mh(t.content),r))}),N.from(e)}var gh=new WeakMap;function xa(n){return Qn.getState(n)?.enabled??!1}function Eh(n,e){let{state:t,dispatch:r}=n.view;r(t.tr.setMeta(Qn,{enabled:e}).setMeta(yi,!0)),n.updateUI()}var Ma={name:"suggestions",toolbar:"suggestions reviewsuggestions suggestionspanel",marks:{suggestion_insert:dh("insert"),suggestion_delete:dh("delete"),suggestion_format:Av()},nodeAttributes:{suggestion:Ev},prosemirrorPlugins:n=>{let e=n.options.pluginOptions?.suggestions??{},t=null;return[new z({key:Qn,state:{init:()=>({enabled:!!(e.enabled||e.force)}),apply(r,o){let i=r.getMeta(Qn);return i?{enabled:e.force?!0:i.enabled}:o}},props:{attributes:r=>Qn.getState(r)?.enabled?{class:"nova-suggesting"}:{},transformPasted:r=>new D(Mh(r.content),r.openStart,r.openEnd),decorations(r){if(t?.doc===r.doc)return t.set;let o=Oe(n,"suggestions",ga),i=new Intl.DateTimeFormat(n.options.language??"en",{dateStyle:"medium",timeStyle:"short"}),s=ae.create(r.doc,Sa(r.doc).map(l=>(l.node?ge.node:ge.inline)(l.from,l.to,{title:(l.kind==="insert"||l.kind==="split"?o.inserted:l.kind==="delete"||l.kind==="join"?o.deleted:o.formatted).replace("{name}",l.author.name||o.guest)+(l.time?` \xB7 ${i.format(l.time)}`:""),class:l.node&&(l.kind==="insert"||l.kind==="delete")?`nova-sugg-${l.kind} nova-sugg-node`:`nova-sugg-${l.kind}`,style:`--nova-suggestion: ${bh(l.author.id||l.author.name)}`})));return t={doc:r.doc,set:s},s}}}),We({"Mod-Alt-Shift-e":()=>e.force?!1:(Eh(n,!xa(n.view.state)),!0)})]},transformTransaction(n,e,t){if(!xa(e))return n;let r=t.options.pluginOptions?.suggestions??{},o=Oe(t,"suggestions",ga),i={id:tr.test(r.author?.id??"")?r.author.id:"guest",name:String(r.author?.name||o.guest).slice(0,80)};return wh(n,e,i,()=>{let s=Date.now();s-(gh.get(t)??0)<3e3||(gh.set(t,s),t.ui.notify(r.force?o.unsupported:o.unsupportedDirect))})},load:()=>import(__novaChunk("tinymce-chunks/suggestions-ui-c5f6bad4.js") )};var Ba={};j(Ba,{default:()=>Ha,embedResolvers:()=>ux,parseMediaUrl:()=>xi});var Ia={};j(Ia,{ALIGNMENTS:()=>Jr,BULLET_STYLES:()=>Ta,CELL_VALIGN:()=>La,IMAGE_ALIGN_STYLES:()=>Oa,INDENT_STEP:()=>Da,MAX_INDENT:()=>Dh,ORDERED_STYLES:()=>Na,classAttr:()=>Ye,createSchema:()=>vi,cssValue:()=>Y,imageSize:()=>ne,indentLevel:()=>nr,preText:()=>Hh,schema:()=>Ot,tableStyle:()=>_h});function zv(n,e){if(typeof n=="string")return{};let t=n.getAttribute("data-colwidth"),r=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(s=>Number(s)):null,o=Number(n.getAttribute("colspan")||1),i={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:r&&r.length===o?r:null};for(let[s,l]of Object.entries(e)){let a=l.getFromDOM?.(n);a!=null&&(i[s]=a)}return i}function $v(n,e){let t={};n.attrs.colspan!==1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!==1&&(t.rowspan=n.attrs.rowspan),Array.isArray(n.attrs.colwidth)&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(let[r,o]of Object.entries(e))o.setDOMAttr?.(n.attrs[r],t);return t}function Vv(n){if(n!==null&&(!Array.isArray(n)||n.some(e=>typeof e!="number")))throw new TypeError("colwidth must be null or an array of numbers")}function Ch(n){let e=n.cellAttributes,t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:Vv}};for(let[o,i]of Object.entries(e))t[o]={default:i.default};let r=(o,i)=>({content:n.cellContent,attrs:t,tableRole:i,isolating:!0,parseDOM:[{tag:o,getAttrs:s=>zv(s,e)}],toDOM:s=>[o,$v(s,e),0]});return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM:()=>["table",["tbody",0]]},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:()=>["tr",0]},table_cell:r("td","cell"),table_header:r("th","header_cell")}}function Jt(n){let{$head:e}=n.selection;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole==="row")return!0;return!1}var Ca={};j(Ca,{isSafeImageUrl:()=>fe,isSafeLinkUrl:()=>Ie});var qv=new Set(["http:","https:","mailto:","tel:"]),jv=new Set(["http:","https:","blob:"]),Wv=/^data:image\/(png|jpe?g|gif|webp|avif|bmp);base64,/i;function Ah(n){if(typeof n!="string")return null;let t=n.replace(/[\u0000- \u007f-\u009f]/g,"").match(/^([a-z][a-z0-9+.-]*):/i);return t?`${t[1].toLowerCase()}:`:null}function Ie(n){if(typeof n!="string")return!1;let e=Ah(n);return e===null||qv.has(e)}function fe(n){if(typeof n!="string")return!1;if(Wv.test(n.trim()))return!0;let e=Ah(n);return e===null||jv.has(e)}var Aa={};j(Aa,{codeLanguage:()=>kn});function kn(n){return typeof n=="string"&&/^[A-Za-z0-9_+#.-]{1,32}$/.test(n)?n:null}var Jr=["left","center","right","justify"],Kv=/^(#[0-9a-f]{3,8}|rgba?\(\s*[\d.]+%?\s*,\s*[\d.]+%?\s*,\s*[\d.]+%?\s*(,\s*[\d.]+%?\s*)?\)|[a-z]{3,20})$/i,Uv=/^\d{1,4}(\.\d{1,3})?(px|pt|em|rem|%)$/,Jv=/^\d{1,2}(\.\d{1,3})?(px|em|%)?$/,Gv=/^[\w\s,'"-]{1,200}$/;function Yv(n){let e=n.trim().toLowerCase(),t=e.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(1|1\.0+)\s*)?\)$/);if(t)return"#"+t.slice(1,4).map(o=>Math.min(255,Number(o)).toString(16).padStart(2,"0")).join("");let r=e.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);return r?`#${r[1]}${r[1]}${r[2]}${r[2]}${r[3]}${r[3]}`:e}var Y={color:n=>typeof n=="string"&&Kv.test(n.trim())&&!/^(inherit|initial|unset|currentcolor|transparent|windowtext|window|auto|none)$/i.test(n.trim())?Yv(n):null,length:n=>typeof n=="string"&&Uv.test(n.trim())?n.trim():null,lineHeight:n=>typeof n=="string"&&Jv.test(n.trim())&&n.trim()!=="normal"?n.trim():null,fontFamily:n=>typeof n=="string"&&Gv.test(n.trim())?n.trim():null},Da=40,Dh=10;function nr(n){let e=Math.trunc(Number(n));return Number.isFinite(e)?Math.min(Dh,Math.max(0,e)):0}var Xv=/^(\d+(?:\.\d+)?)(px|pt|em|rem)$/,Zv={px:1,pt:4/3,em:16,rem:16};function Qv(n,e){if(n.parentElement?.tagName==="LI")return 0;let t=n.style,r=e==="rtl"?t.marginRight||t.paddingRight:t.marginLeft||t.paddingLeft,o=Xv.exec(r?.trim()??"");return o?nr(Math.round(Number(o[1])*Zv[o[2]]/Da)):0}function ex(n){let e=n.getAttribute("dir")?.toLowerCase();return e==="rtl"||e==="ltr"?e:null}function Th(n,e=!1){let t=n.style.textAlign,r=ex(n);return{align:Jr.includes(t)?t:null,lineHeight:Y.lineHeight(n.style.lineHeight),dir:r,indent:Qv(n,r??(e?"rtl":null))}}function Nh(n,e=!1){let t={};(n.dir==="rtl"||n.dir==="ltr")&&(t.dir=n.dir);let r=n.dir==="rtl"||e&&n.dir!=="ltr",o=[],i=n.align;i&&Jr.includes(i)&&o.push(`text-align: ${i};`);let s=Y.lineHeight(n.lineHeight);s&&o.push(`line-height: ${s};`);let l=nr(n.indent);return l&&o.push(`margin-${r?"right":"left"}: ${l*Da}px;`),o.length&&(t.style=o.join(" ")),t}var Oh={align:{default:null},lineHeight:{default:null},dir:{default:null},indent:{default:0}},Ta=["disc","circle","square"],Na=["decimal","lower-alpha","upper-alpha","lower-roman","upper-roman","lower-greek"],tx={1:"decimal",a:"lower-alpha",A:"upper-alpha",i:"lower-roman",I:"upper-roman"};function Lh(n,e,t){let r=n.style.listStyleType.toLowerCase(),o=tx[n.getAttribute("type")??""]??"",i=e.includes(r)?r:e.includes(o)?o:null;return i===t?null:i}function Ph(n,e){return typeof n=="string"&&e.includes(n)?{style:`list-style-type: ${n};`}:{}}var Oa={left:"float: left; margin: 0 1em 1em 0;",right:"float: right; margin: 0 0 1em 1em;",center:"display: block; margin-left: auto; margin-right: auto;"};function Rh(n){let e=n.style.float||n.getAttribute("align");return e==="left"||e==="right"?e:n.style.display==="block"&&n.style.marginLeft==="auto"&&n.style.marginRight==="auto"?"center":null}function ne(n){if(n==null||n==="")return null;let e=String(n).trim().match(/^(\d{1,5})(px)?$/);if(!e)return null;let t=Number(e[1]);return t>=1&&t<=1e4?t:null}var La=["top","middle","bottom"];function _h(n){let e=[],t=Y.length(n.width);return t&&e.push(`width: ${t};`),n.align==="center"?e.push("margin-left: auto; margin-right: auto;"):n.align==="right"&&e.push("margin-left: auto;"),e.join(" ")}var nx=100;function rx(n){let e=Ch({tableGroup:"block",cellContent:"block+",cellAttributes:{class:{default:null,getFromDOM:t=>Gt(t,n),setDOMAttr:(t,r)=>{let o=Ye(t).class;o&&(r.class=o)}},background:{default:null,getFromDOM:t=>Y.color(t.getAttribute("data-nova-cell-bg")??t.style?.backgroundColor),setDOMAttr:(t,r)=>{let o=Y.color(t);o&&(r.style=`${r.style??""}background-color: ${o};`)}},valign:{default:null,getFromDOM:t=>{let r=t,o=(r.style.verticalAlign||r.getAttribute("valign")||"").toLowerCase();return La.includes(o)?o:null},setDOMAttr:(t,r)=>{La.includes(t)&&(r.style=`${r.style??""}vertical-align: ${t};`)}}}});e.table.attrs={width:{default:null},align:{default:null},class:{default:null}},e.table.parseDOM=[{tag:"table",getAttrs:t=>{let r=t,o=Y.length(r.style.width)??Y.length(`${r.getAttribute("width")??""}px`),i=l=>l==="auto",s=r.getAttribute("align")==="center"||i(r.style.marginLeft)&&i(r.style.marginRight)?"center":r.getAttribute("align")==="right"||i(r.style.marginLeft)?"right":null;return{width:o,align:s,class:Gt(r,n)}}}],e.table.toDOM=t=>{let r=_h(t.attrs);return["table",{...Ye(t.attrs.class),...r?{style:r}:{}},["tbody",0]]};for(let t of["table_cell","table_header"]){let r=e[t],o=r.parseDOM[0],i=o.getAttrs;o.getAttrs=l=>{let a=i(l);if(!a)return a;let c=d=>Math.min(nx,Math.max(1,Number.isFinite(d)?Math.floor(d):1));return{...a,colspan:c(a.colspan),rowspan:c(a.rowspan)}};let s=r.toDOM;r.toDOM=l=>{let a=s(l),c=l.attrs.colwidth;if(c?.every(d=>d>0)){let d=c.reduce((p,f)=>p+f,0),u=a[1].style?` ${a[1].style}`:"";a[1]={...a[1],style:`width: ${d}px;${u}`}}return a}}return e}var _a=()=>!1,Ih=/^-?[_a-zA-Z][\w-]*$/,ox=/(?:^|\s)lang(?:uage)?-(\S+)/;function ix(n){for(let e of[n.querySelector("code"),n]){if(!e)continue;let t=kn(ox.exec(e.getAttribute("class")??"")?.[1])??kn(e.getAttribute("data-language"));if(t)return t}return null}var sx=/^(?:P|DIV|H[1-6]|LI|UL|OL|DL|DT|DD|TABLE|TR|BLOCKQUOTE|PRE|SECTION|ARTICLE|HEADER|FOOTER)$/;function Hh(n){let e="",t=!1,r=i=>{i&&(t&&(e+=`
9
+ `);return{dom:a,text:p,slice:e}}function Ul(n,e,t,r,o){let i=o.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=!!e&&(r||i||!t);if(a){if(n.someProp("transformPastedText",p=>{e=p(e,i||r,n)}),i)return l=new D(T.from(n.state.schema.text(e.replace(/\r\n?/g,`
10
+ `))),0,0),n.someProp("transformPasted",p=>{l=p(l,n,!0)}),l;let d=n.someProp("clipboardTextParser",p=>p(e,o,r,n));if(d)l=d;else{let p=o.marks(),{schema:f}=n.state,h=qe.fromSchema(f);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(h.serializeNode(f.text(m,p)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),s=Sk(t),ei&&Mk(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let p=s.firstChild;for(;p&&!W(p);)p=p.nextSibling;if(!p)break;s=p}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Mt.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!vk.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Ek(of(l,+u[1],+u[2]),u[4]);else if(l=D.maxOpen(xk(l.content,o),!0),l.openStart||l.openEnd){let d=0,p=0;for(let f=l.content.firstChild;d<l.openStart&&!f.type.spec.isolating;d++,f=f.firstChild);for(let f=l.content.lastChild;p<l.openEnd&&!f.type.spec.isolating;p++,f=f.lastChild);l=of(l,d,p)}return n.someProp("transformPasted",d=>{l=d(l,n,r)}),l}var vk=/^(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 xk(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),i,s=[];if(n.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&zf(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=$f(s[s.length-1],i.length));let u=Ff(l,a);s.push(u),o=o.matchType(u.type),i=a}}),s)return T.from(s)}return n}function Ff(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,T.from(n));return n}function zf(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let i=zf(n,e,t,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(T.from(Ff(t,n,o+1))))}}function $f(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,$f(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(T.empty,!0);return n.copy(t.append(r))}function Il(n,e,t,r,o,i){let s=e<0?n.firstChild:n.lastChild,l=s.content;return n.childCount>1&&(i=0),o<r-1&&(l=Il(l,e,t,r,o+1,i)),o>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(T.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function of(n,e,t){return e<n.openStart&&(n=new D(Il(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new D(Il(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var Vf={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function qf(){return document.implementation.createHTMLDocument("title")}var Dr=null;function wk(n){let e=window.trustedTypes;if(!e)return n;if(!Dr){if(Dr=e.defaultPolicy)try{return Dr.createHTML(n)}catch{}Dr=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return Dr.createHTML(n)}function Sk(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=qf(),r=t.body,o=/<([a-z][^>\s]+)/i.exec(n),i;if((i=o&&Vf[o[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=wk(n),i)for(let s=0;s<i.length;s++)r=r.querySelector(i[s])||r;for(let s=0;s<t.styleSheets.length;s++){let l=t.styleSheets[s];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let u=r.querySelectorAll(c.selectorText);for(let d=0;d<u.length;d++)u[d].style.cssText+=c.style.cssText}}}return r}function Mk(n){let e=n.querySelectorAll(Pe?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Ek(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:i,openEnd:s}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs()||!a.createAndFill(null,o))break;try{o=T.from(a.create(r[l+1],o))}catch{break}i++,s++}return new D(o,i,s)}var Be=class n{constructor(e,t,r,o){this.anchorNode=e,this.anchorOffset=t,this.focusNode=r,this.focusOffset=o}static from(e){return e instanceof n?e:new n(e.anchorNode,e.anchorOffset,e.focusNode,e.focusOffset)}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};Be.null=new Be(null,0,null,0);var Hl=class{constructor(e){this.view=e,this.range=Be.null,this.active=!1,this.synced=!1,this.suppress=!1,this.currentDocument=null,this.onSelectionChange=this.onSelectionChange.bind(this)}ensureListener(){let e=this.view.dom.ownerDocument;e!=this.currentDocument&&(this.currentDocument&&this.currentDocument.removeEventListener("selectionchange",this.onSelectionChange),this.currentDocument=e,e.addEventListener("selectionchange",this.onSelectionChange))}destroy(){this.currentDocument&&(this.currentDocument.removeEventListener("selectionchange",this.onSelectionChange),this.currentDocument=null),this.active=!1,this.range=Be.null}suppressChanges(){this.suppress=!0,setTimeout(()=>this.suppress=!1,50)}onSelectionChange(){if(this.suppress&&this.view.hasFocus())return this.sync();this.read()&&this.view.domObserver.flush(!1)}readRange(){let{view:e}=this,t=e.dom.isConnected!==!1&&e.domSelection();return t?Re&&e.root.nodeType===11&&Kb(e.dom.ownerDocument)==e.dom?Be.from(Ck(e,t)||t):Be.from(t):Be.null}read(){this.ensureListener();let e=Kf(this.view);if(!e){this.active=!1,this.range=Be.null;return}return this.active=!0,this.range.eq(e)?!1:(this.range=e,this.synced=!1,!0)}sync(e=!1){let{view:t}=this;t.docView&&(this.ensureListener(),t.domObserver.stopped(()=>{Lk(t,t.state.selection);let r=t.state.selection;if(t.input.mouseDown||jf(t)){let{desc:o,start:i}=Wf(t.docView,r.from,r.to,0);t.cursorWrapper?Ok(t):o instanceof Uo&&o.spec.setSelection?o.spec.setSelection(r.anchor-i,r.head-i,t.root):Ak(t,e,o,i),this.synced=this.active=!0}r.visible==t.dom.classList.contains("ProseMirror-hideselection")&&(r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),Nk(t))),this.range=this.readRange()}))}ignore(e=this.readRange()){this.range=Be.from(e),this.synced=!0}deactivate(){this.range=Be.null,this.active=this.synced=!1}};function Ck(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return sf(n,o)}let t;function r(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?sf(n,t):null}function sf(n,e){let t=e.startContainer,r=e.startOffset,o=e.endContainer,i=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return qo(s.node,s.offset,o,i)&&([t,r,o,i]=[o,i,t,r]),new Be(t,r,o,i)}function Jl(n,e,t=null){let r=n.state.doc;if(!e.focusNode)return null;let o=n.docView.nearestDesc(e.focusNode),i=o&&o.size==0,s=n.docView.posFromDOM(e.focusNode,e.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(Qo(e)){for(a=s;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&R.isSelectable(o.node)&&o.parent&&!(o.node.isInline&&jb(e.focusNode,e.focusOffset,o.dom))){let d=o.posBefore;c=new R(s==d?l:r.resolve(d))}else if(Ye&&t=="key"&&s>n.state.selection.to&&W(e.focusNode)&&e.focusOffset==e.focusNode.childNodes.length&&o&&o.posAtStart>n.state.selection.to)for(let d=e.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!="visible"){c=U.findFrom(r.resolve(o.posAtStart),1);break}if(d==o.dom||d.nextSibling||!d.parentNode||!W(d.parentNode))break}}else{if(e instanceof n.dom.ownerDocument.defaultView.Selection&&e.rangeCount>1){let d=s,p=s;for(let f=0;f<e.rangeCount;f++){let h=e.getRangeAt(f);d=Math.min(d,n.docView.posFromDOM(h.startContainer,h.startOffset,1)),p=Math.max(p,n.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(d<0)return null;[a,s]=p==n.state.selection.anchor?[p,d]:[d,p],l=r.resolve(s)}else a=n.docView.posFromDOM(e.anchorNode,e.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=t=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=Xn(n,u,l,d)}return c}function jf(n){return n.editable?n.hasFocus():Uf(n,n.domSel.readRange())&&(!document.activeElement||document.activeElement.contains(n.dom))}function Ak(n,e,t,r){let o=n.state.selection,{anchor:i,head:s}=o,l,a;lf&&!(o instanceof F)&&(o.$from.parent.inlineContent||(l=af(n,o.from)),!o.empty&&!o.$from.parent.inlineContent&&(a=af(n,o.to)));let c=t.domFromPos(i-r,i>r?-1:1),u=s==i?c:t.domFromPos(s-r,s>r?-1:1);Tk(i,s,c,u,n,e),lf&&(l&&cf(l),a&&cf(a))}function Wf(n,e,t,r=0){for(let o=0,i=r;o<n.children.length;o++){let s=n.children[o],l=i+s.size;if(e>i&&t<l)return Wf(s,e,t,i+s.border);i=l}return{desc:n,start:r}}function Tk(n,e,t,r,o,i){let s=!1;if((Ye||Re)&&n==e){let{node:a,offset:c}=t;if(ke(a)){if(s=!!(c&&a.nodeValue[c-1]==`
11
+ `),s&&c==a.nodeValue.length)for(let u=a,d;u;u=u.parentNode){if(d=u.nextSibling){d.nodeName=="BR"&&(t=r={node:d.parentNode,offset:Le(d)+1});break}let p=u.pmViewDesc;if(p&&p.node&&p.node.isBlock)break}}else{let u=a.childNodes[c-1];s=u&&(u.nodeName=="BR"||u.contentEditable=="false")}}let l=o.domSel.readRange();if(Ye&&l.focusNode&&l.focusNode!=r.node&&W(l.focusNode)){let a=l.focusNode.childNodes[l.focusOffset];a&&a.contentEditable=="false"&&(i=!0)}!(i||s&&Re)&&qo(t.node,t.offset,l.anchorNode,l.anchorOffset)&&qo(r.node,r.offset,l.focusNode,l.focusOffset)||Cf(o.domSelection(),{focusNode:r.node,focusOffset:r.offset,anchorNode:t.node,anchorOffset:t.offset})}var lf=Re||Pe&&Af<63;function af(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,i=r?t.childNodes[r-1]:null;if(Re&&o&&o.contentEditable=="false")return El(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return El(o);if(i)return El(i)}}function El(n){return n.contentEditable="true",Re&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function cf(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Nk(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSel.readRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!jf(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ok(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom;t.nodeName=="IMG"?e.collapse(t.parentNode,Le(t)+1):e.collapse(t,0)}function Lk(n,e){if(e instanceof R){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(uf(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else uf(n)}function uf(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Xn(n,e,t,r){let o=n.someProp("createSelectionBetween",i=>i(n,e,t))||F.between(e,t,r);return n.someProp("adjustSelectionFromDOM",i=>{o=i(n,o)}),o}function Kf(n){if(n.editable&&!n.hasFocus())return null;let e=n.domSel.readRange();return e&&Uf(n,e)?e:null}function Uf(n,e){if(!e.anchorNode)return!1;try{return Jn(n.dom,e.anchorNode)&&(n.editable||Jn(n.dom,e.focusNode))}catch{return!1}}var De={},_e={},Pk={touchstart:!0,touchmove:!0},Bl=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function Rk(n){for(let e in De){let t=De[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{_k(n,r)&&(n.input.composing&&(r.type=="keydown"||r.type=="beforeinput")&&r.isComposing===!1&&Yf(n,!0),!Gl(n,r)&&(n.editable||!(r.type in _e))&&t(n,r))},Pk[e]?{passive:!0}:void 0)}Re&&n.dom.addEventListener("input",()=>null),Fl(n)}function ti(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Dk(n){n.input.mouseDown&&n.input.mouseDown.done(),n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Fl(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Gl(n,r))})}function Gl(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function _k(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Ik(n,e){!Gl(n,e)&&De[e.type]&&(n.editable||!(e.type in _e))&&De[e.type](n,e)}function Wt(n,e){let{input:t}=n;return t.lastKeyDispatched||n.composing?!1:(t.lastKeyDispatched=!0,typeof e=="string"&&(e=Wb(e=="Backspace"?8:13,e)),n.someProp("handleKeyDown",r=>r(n,e)))}_e.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),n.input.lastKeyDispatched=!1,!(Ot&&Pe&&t.keyCode==13)){if(Yn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(Wt(n,"Enter"),n.input.lastIOSEnter=0)},200);return}t.keyCode!=229&&n.domObserver.forceFlush(!0),Wt(n,t)||kk(n,t)?t.preventDefault():ti(n,"key")}};_e.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};_e.keypress=(n,e)=>{let t=e;if(jk(n)||!t.charCode||t.ctrlKey&&!t.altKey||We&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof F)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode),i=()=>n.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o,i))&&n.dispatch(i()),t.preventDefault()}};function Fr(n){return{left:n.clientX,top:n.clientY}}function Hk(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Yl(n,e,t,r,o){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(n.someProp(e,l=>s>i.depth?l(n,t,i.nodeAfter,i.before(s),o,!0):l(n,t,i.node(s),i.before(s),o,!1)))return!0;return!1}function Jf(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Bk(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&R.isSelectable(r)?(Jf(n,new R(t)),!0):!1}function Fk(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof R&&(r=t.node);let i=n.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(R.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?o=i.before(t.$from.depth):o=i.before(s);break}}return o!=null?(Jf(n,R.create(n.state.doc,o)),!0):!1}function zk(n,e,t,r,o){return Yl(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(o?Fk(n,t):Bk(n,t))}function $k(n,e,t,r){return Yl(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function Vk(n,e,t,r){return Yl(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))}function df(n,e,t){if(e==-1)return n.inlineContent?F.create(n,0,n.content.size):null;let r=n.resolve(e);for(let o=r.depth+1;o>0;o--){let i=o>r.depth?r.nodeAfter:r.node(o),s=r.before(o);if(i.inlineContent)return F.create(n,s+1,s+1+i.content.size);if(t&&R.isSelectable(i))return R.create(n,s)}return null}var zl=/[\w_\u00a1-\uffff]+/g;try{zl=new RegExp("[\\p{L}\\p{N}_]+","gu")}catch{}function pf(n,e){let t=n.resolve(e),r=t.node(),o="",i=e,s=e;for(let m=t.indexAfter(),g=!1;m>0;m--){let k=r.child(m-1);if(!k.text)break;let x=i==e?e-t.posAtIndex(m-1):k.text.length,M=x;for(;M>0;M--)if(/\S/.test(k.text[M-1]))g=!0;else if(g)break;if(o=k.text.slice(M,x)+o,i-=x-M,M||i<e-50)break}for(let m=t.index(),g=!1;m<r.childCount;m++){let k=r.child(m);if(!k.text)break;let x=s==e?e-t.posAtIndex(m):0,M=x;for(;M<k.text.length;M++)if(/\S/.test(k.text[M]))g=!0;else if(g)break;if(o+=k.text.slice(x,M),s+=M-x,M<k.text.length||s>e+50)break}let l=i,a=s;if(Intl.Segmenter){for(let m of new Intl.Segmenter(void 0,{granularity:"word"}).segment(o))if(m.isWordLike){let g=m.index+i,k=g+m.segment.length;if(k<e)l=k;else if(g>e){a=g;break}else return F.create(n,g,k)}}else{zl.lastIndex=0;for(let m;m=zl.exec(o);){let g=m.index+i,k=g+m[0].length;if(k<e)l=k;else if(g>e){a=g;break}else return F.create(n,g,k)}}let c=o.slice(l-i,e-i),u=o.slice(e-i,a-i),d=/\S*$/.exec(c)[0].length,p=/^\S*/.exec(u)[0].length;if(d||p)return F.create(n,e-d,e+p);let f=/\s*$/.exec(c)[0].length,h=/^\s*/.exec(u)[0].length;return F.create(n,e-f,e+h)}var Gf=We?"metaKey":"ctrlKey";De.mousedown=(n,e)=>{let t=e,r=Date.now();if(n.input.shiftKey=t.shiftKey,n.input.lastTouch>r-500)return!1;Jt(n);let o="singleClick";r-n.input.lastClick.time<500&&Hk(t,n.input.lastClick)&&!t[Gf]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:r,x:t.clientX,y:t.clientY,type:o,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let i=n.posAtCoords(Fr(t));if(i)if(t.button==0){if(!n.hasFocus()){Lf(n.dom);let l=n.root.activeElement;l&&!l.contains(n.dom)&&l.blur()}(n.input.mouseDown=new $l(n,i,t,o)).mightDrag||t.preventDefault()}else ti(n,"pointer")};var $l=class{constructor(e,t,r,o){var i;this.view=e,this.startPos=t,this.event=r,this.type=o,this.didMove=!1,this.lastPos=-1,this.anchorRange=null,this.startDoc=e.state.doc,this.selectNode=!!r[Gf],this.extend=r.shiftKey,this.anchorDoc=this.startDoc;let s=ff(e);if(this.extend){let l=e.state.selection;this.anchorRange=l instanceof R?{from:l.from,to:l.to}:{from:l.anchor,to:l.anchor};let a=l instanceof R?e.nodeDOM(l.from).getBoundingClientRect():e.coordsAtPos(l.anchor);this.anchorOffset={x:(a.left+a.right)/2-s.x,y:(a.top+a.bottom)/2-s.y}}else this.anchorOffset={x:r.clientX-s.x,y:r.clientY-s.y};if(o=="singleClick"){let{selection:l}=e.state,a,c,u=!1;if(l instanceof R&&l.from<=t.pos&&l.to>=t.pos)c=l.from,a=l.node,u=!0;else if(t.inside>-1)a=e.state.doc.nodeAt(t.inside),c=t.inside;else{let d=e.state.doc.resolve(t.pos);a=d.parent,c=d.depth?d.before():-1}if(u||c>-1&&a.type.spec.draggable&&a.type.spec.selectable!==!1){let d=(i=e.docView.descAt(c))===null||i===void 0?void 0:i.nodeDOM;this.mightDrag={node:a,elt:d,pos:c,addAttr:!1},d&&!d.draggable&&(this.mightDrag.addAttr=!0,e.domObserver.stopped(()=>d.draggable=!0))}else this.mightDrag=qk(e,r)}else this.mightDrag=!1;e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),this.mightDrag||this.select(this.startPos,!0)}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null),typeof this.mightDrag=="object"&&this.mightDrag.addAttr&&this.view.domObserver.stopped(()=>this.mightDrag.elt.removeAttribute("draggable"))}maybeRunHandler(e,t){return(this.type=="singleClick"?zk:this.type=="doubleClick"?$k:Vk)(this.view,e.pos,e.inside,t,this.selectNode)}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.startPos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Fr(e))),t&&(this.didMove||this.maybeRunHandler(t,e)||this.select(t,!0),e.preventDefault())}move(e){if(e.buttons==0){this.done();return}if(!this.didMove&&(Math.abs(this.event.x-e.clientX)>8||Math.abs(this.event.y-e.clientY)>8)&&(this.didMove=!0,this.mightDrag=!1),!this.mightDrag){let t=this.view.posAtCoords(Fr(e));t&&this.select(t,!1)}e.preventDefault()}select(e,t){if(e.pos==this.lastPos)return;this.lastPos=e.pos;let{view:r}=this,{doc:o}=r.state,i=this.type=="singleClick"?hf(r,o,e):this.type=="doubleClick"?pf(o,e.pos):df(o,e.inside,t);i&&(t&&!this.extend?this.anchorRange=i:(!t||this.extend)&&(o.eq(this.anchorDoc)||this.restoreAnchor(),this.anchorRange&&this.anchorRange.from<i.from?i=Xn(r,o.resolve(this.anchorRange.from),o.resolve(i.to)):this.anchorRange&&this.anchorRange.to>i.to&&(i=Xn(r,o.resolve(this.anchorRange.to),o.resolve(i.from)))),i.eq(r.state.selection)||r.dispatch(r.state.tr.setSelection(i).setMeta("pointer",!0).scrollIntoView()))}restoreAnchor(){let e=ff(this.view),t=this.view.posAtCoords({left:this.anchorOffset.x+e.x,top:this.anchorOffset.y+e.y});if(!t)this.anchorRange=null;else{let{doc:r}=this.view.state;this.anchorRange=this.type=="singleClick"?hf(this.view,r,t):this.type=="doubleClick"?pf(r,t.pos):df(r,t.inside,!1),this.anchorDoc=this.view.state.doc}}};function ff(n){let e=n.dom.getBoundingClientRect();return{x:e.left-n.dom.scrollLeft,y:e.top-n.dom.scrollTop}}function hf(n,e,t){if(t.inside>-1){let o=e.nodeAt(t.inside);if(o.isAtom&&R.isSelectable(o))return R.create(e,t.inside)}let r=e.resolve(t.pos);return Xn(n,r,r)}function qk(n,e){let{selection:t}=n.state;if(t.empty)return!1;let r=n.domSelection();if(!r||r.rangeCount==0)return!0;let o=r.getRangeAt(0).getClientRects();for(let i=0;i<o.length;i++){let s=o[i];if(s.left<=e.clientX&&s.right>=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}De.touchstart=n=>{n.input.lastTouch=Date.now(),Jt(n),ti(n,"pointer")};De.touchmove=n=>{n.input.lastTouch=Date.now(),ti(n,"pointer")};De.contextmenu=n=>Jt(n);function jk(n,e){return n.composing?!0:Re&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var Wk=Ot?5e3:-1;_e.compositionstart=_e.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof F&&e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Pe&&Tf&&Kk(n)))n.markCursor=n.state.storedMarks||t.marks(),Jt(n,!0),n.markCursor=null;else if(Jt(n,!e.selection.empty),Ye&&n.domSel.active&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length)for(let{focusNode:r,focusOffset:o}=n.domSel.range;r&&W(r)&&o!=0;){let i=o<0?r.lastChild:r.childNodes[o-1];if(!i)break;if(ke(i)){let s=n.domSelection();s&&s.collapse(i,i.nodeValue.length);break}else r=i,o=-1}n.input.composing=!0}Xf(n,Wk)};function Kk(n){let{focusNode:e,focusOffset:t}=n.domSel.range;if(!e||!W(e)||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return W(r)&&r.contentEditable=="false"}_e.compositionend=(n,e)=>{n.composing&&Yf(n)};function Yf(n,e=!1){n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,e?Jt(n):Xf(n,20)}function Xf(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Jt(n),e))}function Zf(n){n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());for(let e;e=n.input.compositionNodes.pop();)e.markParentDamage()}function Uk(n){let e=n.domSel.range;if(!n.domSel.active||!e.focusNode)return null;let t=Mf(e.focusNode,e.focusOffset),r=Ef(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function Jt(n,e=!1){if(!(Ot&&n.domObserver.flushingSoon>=0)&&(n.domObserver.forceFlush(),Zf(n),e||n.docView&&n.docView.damage)){let t=Jl(n,n.domSel.readRange()),r=n.state.selection;t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state)}}function Jk(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var zr=Yn&&Jb<604;De.copy=_e.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let i=zr?null:t.clipboardData,s=r.content(),{dom:l,text:a}=Kl(n,s);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):Jk(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Gk(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Yk(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?$r(n,r.value,null,o,e):$r(n,r.textContent,r.innerHTML,o,e)},50)}function $r(n,e,t,r,o){let i=Ul(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,i||D.empty)))return!0;if(!i)return!1;let s=Gk(i),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Qf(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}_e.paste=(n,e)=>{let t=e;if(n.composing&&!Ot)return;let r=zr?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&$r(n,Qf(r),r.getData("text/html"),o,t)?t.preventDefault():Yk(n,t)};var Go=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Xk=We?"altKey":"ctrlKey";function eh(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[Xk]}De.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,i=o.empty?null:n.posAtCoords(Fr(t)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof R?o.to-1:o.to))){if(r&&typeof r.mightDrag=="object")s=R.create(n.state.doc,r.mightDrag.pos);else if(t.target&&W(t.target)){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(s=R.create(n.state.doc,d.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:u}=Kl(n,l);(!t.dataTransfer.files.length||!Pe||Af>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(zr?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",zr||t.dataTransfer.setData("text/plain",c),n.dragging=new Go(u,eh(n,t),s)};De.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};_e.dragover=_e.dragenter=(n,e)=>e.preventDefault();_e.drop=(n,e)=>{try{Zk(n,e,n.dragging)}finally{n.dragging=null}};function Zk(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(Fr(e));if(!r)return;let o=n.state.doc.resolve(r.pos),i=t&&t.slice;i?n.someProp("transformPasted",f=>{i=f(i,n,!1)}):i=Ul(n,Qf(e.dataTransfer),zr?null:e.dataTransfer.getData("text/html"),!1,o);let s=!!(t&&eh(n,e));if(n.someProp("handleDrop",f=>f(n,e,i||D.empty,s))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?Nr(n.state.doc,o.pos,i):o.pos;l==null&&(l=o.pos);let a=n.state.tr;if(s){let{node:f}=t;f?f.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(d))return;let p=a.doc.resolve(c);if(u&&R.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new R(p));else{let f=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((h,m,g,k)=>f=k),a.setSelection(Xn(n,p,a.doc.resolve(f)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}De.focus=n=>{if(n.input.lastFocus=Date.now(),!n.focused&&(n.domObserver.stopped(()=>n.dom.classList.add("ProseMirror-focused")),n.focused=!0,n.domSel.read(),!n.domSel.synced)){let e=n.domSel.range;setTimeout(()=>{let t=n.domSel.readRange();t&&e.eq(t)&&n.domSel.sync()},20)}};De.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stopped(()=>n.dom.classList.remove("ProseMirror-focused")),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domSel.deactivate(),n.focused=!1)};De.beforeinput=(n,e)=>{if(Ot&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||n.domObserver.pendingRecords().length||(n.dom.blur(),n.focus(),Wt(n,"Backspace")))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in _e)De[n]=_e[n];function Vr(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var qr=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let t=this.frag.child(this.index);if(this.off==e)return t;this.off+=t.nodeSize,this.index++}return null}},Yo=class n{constructor(e,t){this.toDOM=e,this.spec=t||mn,this.side=this.spec.side||0}map(e,t,r,o){let{pos:i,deleted:s}=e.mapResult(t.from+o,this.side<0?-1:1);return s?null:new ge(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Vr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},hn=class n{constructor(e,t){this.attrs=e,this.spec=t||mn}map(e,t,r,o){let i=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new ge(i,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&Vr(this.attrs,e.attrs)&&Vr(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},Vl=class n{constructor(e,t){this.attrs=e,this.spec=t||mn}map(e,t,r,o){let i=e.mapResult(t.from+o,1);if(i.deleted)return null;let s=e.mapResult(t.to+o,-1);return s.deleted||s.pos<=i.pos?null:new ge(i.pos-r,s.pos-r,this)}valid(e,t,r){let o=r.nodeAt(t.from);return!!o&&!o.isText&&t.from+o.nodeSize==t.to}eq(e){return this==e||e instanceof n&&Vr(this.attrs,e.attrs)&&Vr(this.spec,e.spec)}destroy(){}},ge=class n{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new n(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new n(e,e,new Yo(t,r))}static inline(e,t,r,o){return new n(e,t,new hn(r,o))}static node(e,t,r,o){return new n(e,t,new Vl(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof hn}get widget(){return this.type instanceof Yo}},Kn=[],mn={},ae=class n{constructor(e,t){this.local=e.length?e:Kn,this.children=t.length?t:Kn}static create(e,t){return t.length?Zo(t,e,0,mn):Se}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,i){for(let s=0;s<this.local.length;s++){let l=this.local[s];if(l.from>t)break;l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length&&!(this.children[s]>=t);s+=3)if(this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,o+l,i)}}map(e,t,r){return this==Se||e.maps.length==0?this:this.mapInner(e,t,0,0,r||mn)}mapInner(e,t,r,o,i){let s;if(this.local.length){let l=new qr(t.content);for(let a=0;a<this.local.length;a++){let c=this.local[a].map(e,r,o);c&&c.type.valid(t,c,l)?(s||(s=[])).push(c):i.onRemove&&i.onRemove(this.local[a].spec)}}return this.children.length?Qk(this.children,s||[],e,t,r,o,i):s?new n(s.sort(Kt),Kn):Se}add(e,t){return t.length?this==Se?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=nh(t,l,c)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,u,c+1):o.splice(i,0,a,a+l.nodeSize,Zo(u,l,c+1,mn)),i+=3}});let s=th(i?rh(t):t,-r).sort(Kt);if(s.length){let l=new qr(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||s.splice(a--,1)}return new n(s.length?this.local.concat(s).sort(Kt):this.local,o||this.children)}remove(e){return e.length==0||this==Se?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let s,l=r[i]+t,a=r[i+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(s||(s=[])).push(d));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(s,l+1);c!=Se?r[i+2]=c:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,s;i<e.length;i++)if(s=e[i])for(let l=0;l<o.length;l++)o[l].eq(s,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new n(o,r):Se}forChild(e,t){if(this==Se)return this;if(t.isLeaf)return n.empty;let r,o,i=0,s=this.children.length/3;for(;i<s;){let c=i+s>>>1,u=c*3,d=this.children[u];if(d<e)i=c+1;else if(d>e)s=c;else{r=this.children[u+2];break}}let l=e+1,a=l+t.content.size;for(let c=0;c<this.local.length;c++){let u=this.local[c];if(u.from<a&&u.to>l&&u.type instanceof hn){let d=Math.max(l,u.from)-l,p=Math.min(a,u.to)-l;d<p&&(o||(o=[])).push(u.copy(d,p))}}if(o){let c=new n(o.sort(Kt),Kn);return r?new Xo([c,r]):c}return r||Se}eq(e){if(this==e)return!0;if(!(e instanceof n)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Xl(this.localsInner(e))}localsInner(e){if(this==Se)return Kn;if(e.inlineContent||!this.local.some(hn.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof hn||t.push(this.local[r]);return t}forEachSet(e){e(this)}};ae.empty=new ae([],[]);ae.removeOverlap=Xl;var Se=ae.empty,Xo=class n{constructor(e){this.members=e}map(e,t){let r=this.members.map(o=>o.map(e,t,mn));return n.from(r)}forChild(e,t){if(t.isLeaf)return ae.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,t);i!=Se&&(i instanceof n?r=r.concat(i.members):r.push(i))}return n.from(r)}eq(e){if(!(e instanceof n)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(e);if(i.length)if(!t)t=i;else{r&&(t=t.slice(),r=!1);for(let s=0;s<i.length;s++)t.push(i[s])}}return t?Xl(r?t:t.sort(Kt)):Kn}static from(e){switch(e.length){case 0:return Se;case 1:return e[0];default:return new n(e.every(t=>t instanceof ae)?e:e.reduce((t,r)=>t.concat(r instanceof ae?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function Qk(n,e,t,r,o,i,s){let l=n.slice();for(let c=0,u=i;c<t.maps.length;c++){let d=0;t.maps[c].forEach((p,f,h,m)=>{let g=m-h-(f-p);for(let k=0;k<l.length;k+=3){let x=l[k+1];if(x<0||p>x+u-d)continue;let M=l[k]+u-d;f>=M?l[k+1]=p<=M?-2:-1:p>=u&&g&&(l[k]+=g,l[k+1]+=g)}d+=g}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+i),d=u-o;if(d<0||d>=r.content.size){a=!0;continue}let p=t.map(n[c+1]+i,-1),f=p-o,{index:h,offset:m}=r.content.findIndex(d),g=r.maybeChild(h);if(g&&m==d&&m+g.nodeSize==f){let k=l[c+2].mapInner(t,g,u+1,n[c]+i+1,s);k!=Se?(l[c]=d,l[c+1]=f,l[c+2]=k):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=ev(l,n,e,t,o,i,s),u=Zo(c,r,0,s);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,p=0;d<u.children.length;d+=3){let f=u.children[d];for(;p<l.length&&l[p]<f;)p+=3;l.splice(p,0,u.children[d],u.children[d+1],u.children[d+2])}}return new ae(e.sort(Kt),l)}function th(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new ge(o.from+e,o.to+e,o.type))}return t}function ev(n,e,t,r,o,i,s){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,o,c);d?t.push(d):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+i+1);return t}function nh(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let i=0,s;i<n.length;i++)(s=n[i])&&s.from>t&&s.to<r&&((o||(o=[])).push(s),n[i]=null);return o}function rh(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Zo(n,e,t,r){let o=[],i=!1;e.forEach((l,a)=>{let c=nh(n,l,a+t);if(c){i=!0;let u=Zo(c,l,t+a+1,r);u!=Se&&o.push(a,a+l.nodeSize,u)}});let s=th(i?rh(n):n,-t).sort(Kt);if(s.length){let l=new qr(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1))}return s.length||o.length?new ae(s,o):Se}function Kt(n,e){return n.from-e.from||n.to-e.to}function Xl(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let i=e[o];if(i.from==r.from){i.to!=r.to&&(e==n&&(e=n.slice()),e[o]=i.copy(i.from,r.to),mf(e,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,i.from),mf(e,o,r.copy(i.from,r.to)));break}}}return e}function mf(n,e,t){for(;e<n.length&&Kt(t,n[e])>0;)e++;n.splice(e,0,t)}function Cl(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=Se&&e.push(r)}),n.cursorWrapper&&e.push(ae.create(n.state.doc,[n.cursorWrapper.deco])),Xo.from(e)}function tv(n,e,t,r){let{node:o,fromOffset:i,toOffset:s,from:l,to:a}=n.docView.parseRange(e,t),c=n.domSel.range,u,d=c.anchorNode;if(d&&Jn(n.dom,d)&&(u=[{node:d,offset:c.anchorOffset}],Qo(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Pe&&n.input.lastKeyCode===8)for(let k=s;k>i;k--){let x=o.childNodes[k-1],M=x.pmViewDesc;if(x.nodeName=="BR"&&!M){s=k;break}if(!M||M.size)break}let p=n.state.doc,f=n.someProp("domParser")||Mt.fromSchema(n.state.schema),h=p.resolve(l),m=null,g=f.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:nv(r),context:h});if(u&&u[0].pos!=null){let k=u[0].pos,x=u[1]&&u[1].pos;x==null&&(x=k),m={anchor:k+l,head:x+l}}return{doc:g,sel:m,from:l,to:a}}var nv=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(Re&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||Re&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},rv=/^(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 ov(n,e,t,r,o,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let P=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,G=Jl(n,n.domSel.range,P);if(G&&!n.state.selection.eq(G)&&n.domSel.active){if(Pe&&Ot&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&Wt(n,"Enter"))return;let y=n.state.tr.setSelection(G);P=="pointer"?y.setMeta("pointer",!0):P=="key"&&y.scrollIntoView(),s&&y.setMeta("composition",s),n.dispatch(y)}return}let l=n.state.doc.resolve(e),a=l.sharedDepth(t);e=l.before(a+1),t=n.state.doc.resolve(t).after(a+1);let c=n.state.selection,u=tv(n,e,t,i),d=n.state.doc,p=d.slice(u.from,u.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let m=av(p.content,u.doc.content,u.from,f,h);if(m&&n.input.domChangeCount++,(Yn&&n.input.lastIOSEnter>Date.now()-225||Ot)&&i.some(P=>W(P)&&!rv.test(P.nodeName))&&(!m||m.endA>=m.endB)&&Wt(n,"Enter")){n.input.lastIOSEnter=0;return}if(!m)if(o&&c instanceof F&&!c.empty&&c.$head.sameParent(c.$anchor)&&!n.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let P=gf(n,n.state.doc,u.sel);if(P&&!P.eq(n.state.selection)){let G=n.state.tr.setSelection(P);s&&G.setMeta("composition",s),n.dispatch(G)}}return}n.state.selection.from<n.state.selection.to&&m.start==m.endB&&n.state.selection instanceof F&&(m.start>n.state.selection.from&&m.start<=n.state.selection.from+2&&n.state.selection.from>=u.from?m.start=n.state.selection.from:m.endA<n.state.selection.to&&m.endA>=n.state.selection.to-2&&n.state.selection.to<=u.to&&(m.endB+=n.state.selection.to-m.endA,m.endA=n.state.selection.to));let g=u.doc.resolveNoCache(m.start-u.from),k=u.doc.resolveNoCache(m.endB-u.from),x=d.resolve(m.start),M=g.sameParent(k)&&g.parent.inlineContent&&x.end()>=m.endA;if((Yn&&n.input.lastIOSEnter>Date.now()-225&&(!M||i.some(P=>P.nodeName=="DIV"||P.nodeName=="P"))||!M&&lv(u.doc,g.pos,k.pos))&&Wt(n,"Enter")){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>m.start&&(M?m.endA>m.start&&m.endB==m.start:sv(d,m.start,m.endA,g,k))&&Wt(n,"Backspace")){Ot&&Pe&&n.domSel.suppressChanges();return}Pe&&m.endB==m.start&&(n.input.lastChromeDelete=Date.now()),Ot&&!M&&g.start()!=k.start()&&k.parentOffset==0&&g.depth==k.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==m.endA&&(m.endB-=2,k=u.doc.resolveNoCache(m.endB-u.from),setTimeout(()=>Wt(n,"Enter"),20));let L=m.start,O=m.endA,B=P=>{let G=P||n.state.tr.replace(L,O,u.doc.slice(m.start-u.from,m.endB-u.from));if(u.sel){let y=gf(n,G.doc,u.sel);y&&!(Pe&&n.composing&&y.empty&&(m.start!=m.endB||n.input.lastChromeDelete<Date.now()-100)&&(y.head==L||y.head==G.mapping.map(O)-1))&&G.setSelection(y)}return s&&G.setMeta("composition",s),G.scrollIntoView()},J;if(M)if(g.pos==k.pos){let P=B(n.state.tr.delete(L,O)),G=d.resolve(m.start).marksAcross(d.resolve(m.endA));G&&P.ensureMarks(G),n.dispatch(P)}else if(m.endA==m.endB&&(J=iv(g.parent.content.cut(g.parentOffset,k.parentOffset),x.parent.content.cut(x.parentOffset,m.endA-x.start())))){let P=B(n.state.tr);J.type=="add"?P.addMark(L,O,J.mark):P.removeMark(L,O,J.mark),n.dispatch(P)}else if(g.parent.child(g.index()).isText&&g.index()==k.index()-(k.textOffset?0:1)){let P=g.parent.textBetween(g.parentOffset,k.parentOffset),G=()=>B(n.state.tr.insertText(P,L,O));n.someProp("handleTextInput",y=>y(n,L,O,P,G))||n.dispatch(G())}else n.dispatch(B());else n.dispatch(B())}function gf(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Xn(n,e.resolve(t.anchor),e.resolve(t.head))}function iv(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,i=r,s,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<t.length;u++)i=t[u].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],s="add",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(T.from(c).eq(n))return{mark:l,type:s}}function sv(n,e,t,r,o){if(t-e<=o.pos-r.pos||Al(r,!0,!1)<o.pos)return!1;let i=n.resolve(e);if(!r.parent.inlineContent){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=n.resolve(Al(i,!0,!0));return!s.parent.isTextblock||s.pos>t||Al(s,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function lv(n,e,t){let r=0,o=0;return n.nodesBetween(e,t,(i,s)=>{i.isTextblock&&s>=e&&s<t?r++:(i.isText?/\S/.test(i.text.slice(Math.max(0,e-s),Math.min(i.nodeSize,t-s))):i.isLeaf)&&o++}),o==0&&r==1}function Al(n,e,t){let r=n.depth,o=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function av(n,e,t,r,o){let i=n.findDiffStart(e,t),s=t+n.size,l=t+e.size;if(i==null)return null;let{a,b:c}=n.findDiffEnd(e,s,l);if(o=="end"){let u=Math.max(0,i-Math.min(a,c));r-=a+u-i}if(a<i&&s<l){let u=r<=i&&r>=a?i-r:0;i-=u,c=i+(c-a),a=i}else if(c<i){let u=r<=i&&r>=c?i-r:0;i-=u,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}var cv={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ql=class{constructor(e){this.view=e,this.queue=[],this.flushingSoon=-1,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.started=!1,this.observer=new window.MutationObserver(t=>{for(let r=0;r<t.length;r++)this.queue.push(t[r]);Re&&e.composing&&t.some(r=>r.type=="childList"&&r.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()})}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(e=!1){this.flushingSoon>-1?(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush(!0)):e&&this.flush(!0)}start(){this.observer.takeRecords(),this.observer.observe(this.view.dom,cv),this.started=!0}stop(){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect(),this.started=!1}stopped(e){if(!this.started)return e();this.stop();try{return e()}finally{this.start()}}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let i=e.focusNode;i;i=Un(i))t.add(i);for(let i=e.anchorNode;i;i=Un(i))if(t.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:ke(r)?r.parentNode:r}))return this.view.domSel.ignore(e),!0}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(e=!0){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let r=this.pendingRecords();r.length&&(this.queue=[]),e&&t.domSel.read();let o=!t.domSel.suppress&&!t.domSel.synced&&!!Kf(t)&&!this.ignoreSelectionChange(t.domSel.range),i=-1,s=-1,l=!1,a=[];if(t.editable)for(let u=0;u<r.length;u++){let d=this.registerMutation(r[u],a);d&&(i=i<0?d.from:Math.min(d.from,i),s=s<0?d.to:Math.max(d.to,s),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46||Pe&&(t.composing||t.input.compositionEndedAt>Date.now()-50)&&r.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&W(d);){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(Ye&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,p]=u;d.parentNode&&d.parentNode.parentNode==p.parentNode?p.remove():d.remove()}else{let{focusNode:d}=t.domSel.range;for(let p of u){let f=p.parentNode;f&&f.nodeName=="LI"&&(!d||dv(t,d)!=f)&&p.remove()}}}let c=null;i<0&&o&&t.domSel.active&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Qo(t.domSel.range)&&(c=Jl(t,t.domSel.range))&&c.eq(U.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,t.domSel.sync(),t.scrollToSelection()):(i>-1||o)&&(i>-1&&uv(t),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,pv(t,a)),ov(this.view,i,s,o,l,a),t.docView&&t.docView.damage?t.updateState(t.state):o&&t.domSel.sync())}registerMutation(e,t){var r;if(t.indexOf(e.target)>-1)return null;let o;for(let i=e.target;i&&!(o=this.view.docView.getDesc(i));i=i.parentNode);if(e.type=="attributes"&&(o==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!o||o.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let p=e.addedNodes[d];t.push(p),ke(p)&&(this.lastChangedTextNode=p)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return o.markDamage(4),{from:o.posBefore,to:o.posAfter};let i=e.previousSibling,s=e.nextSibling,l=i&&i.parentNode==e.target?Le(i)+1:0,a=o.localPosFromDOM(e.target,l,-1),c=s&&s.parentNode==e.target?Le(s):e.target.childNodes.length,u=o.localPosFromDOM(e.target,c,1);return o.markDamage(!((r=o.contentDOM)===null||r===void 0)&&r.contains(e.target)?2:4),{from:a,to:u}}else return e.type=="attributes"?(o.markDamage(4),{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}):(this.lastChangedTextNode=e.target,o.markDamage(o instanceof Hr&&e.target==o.nodeDOM?8:4),{from:o.posAtStart,to:o.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},yf=new WeakMap,bf=!1;function uv(n){if(!yf.has(n)&&(yf.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ye,bf)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."),bf=!0}}function dv(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function pv(n,e){var t;let{focusNode:r,focusOffset:o}=n.domSel.range;for(let i of e)if(((t=i.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=i.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||!W(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&n.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}var fv=Ul,hv=Jt,Zn=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Bl,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Sf),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=xf(this),vf(this),this.nodeViews=wf(this),this.docView=Xp(this.state.doc,kf(this),Cl(this),this.dom,this),this.domObserver=new ql(this),this.domSel=new Hl(this),this.domObserver.start(),this.domSel.read(),Rk(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Fl(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Sf),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(Zf(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=wf(this);gv(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Fl(this),this.editable=xf(this),vf(this);let a=Cl(this),c=kf(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(o.selection))&&(s=!0);let p=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Xb(this);s&&this.domObserver.stopped(()=>{let f=d&&Pe&&!this.composing&&!o.selection.empty&&!e.selection.empty&&mv(o.selection,e.selection);if(d){let h=Pe?this.trackWrites=this.domSel.range.focusNode:null;if(this.composing&&(this.input.compositionNode=Uk(this)),i||!this.docView.update(e.doc,c,a,this,-1)){let m=this.docView.outerDeco;this.docView.destroy(),this.docView=Xp(e.doc,c,a,this.dom,this,m)}h&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}this.domSel.sync(f)}),this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():p&&Zb(p)}scrollToSelection(){let e=this.domSel.range.focusNode;if(!(!e||!this.domSel.active)){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof R){let t=this.docView.domAfterPos(this.state.selection.from);W(t)&&Up(this,t.getBoundingClientRect(),e)}else Up(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,o=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let i=r.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new Go(e.slice,e.move,o<0?void 0:R.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(o=t?t(l):l))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let l=i[s].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){return this.root.activeElement==this.dom}focus(){this.editable&&Lf(this.dom),this.domSel.sync()}get root(){let e=this.dom.isConnected!==!1;e||(this._root=null);let t=this._root;if(t==null&&e){for(let r=this.dom.parentNode;r;r=r.parentNode)if(r.nodeType==9||r.nodeType==11&&r.host)return r.getSelection||(Object.getPrototypeOf(r).getSelection=()=>r.ownerDocument.getSelection()),this._root=r}return t||document}updateRoot(){this._root=null}posAtCoords(e){return rk(this,e)}coordsAtPos(e,t=1){return Df(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return ak(this,t||this.state,e)}pasteHTML(e,t){return $r(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return $r(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Kl(this,e)}destroy(){this.docView&&(Dk(this),this.domSel.destroy(),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Cl(this),this,-1),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,qb())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Ik(this,e)}domSelection(){return this.root.getSelection()}};Zn.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function kf(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[ge.node(0,n.state.doc.content.size,e)]}function vf(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ge.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function xf(n){return!n.someProp("editable",e=>e(n.state)===!1)}function mv(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function wf(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function gv(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function Sf(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var na={};q(na,{keydownHandler:()=>ri,keymap:()=>Ke});var ea={};q(ea,{base:()=>pt,keyName:()=>Ql,shift:()=>jr});var pt={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:"'"},jr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},yv=typeof navigator<"u"&&/Mac/.test(navigator.platform),bv=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(pe=0;pe<10;pe++)pt[48+pe]=pt[96+pe]=String(pe);var pe;for(pe=1;pe<=24;pe++)pt[pe+111]="F"+pe;var pe;for(pe=65;pe<=90;pe++)pt[pe]=String.fromCharCode(pe+32),jr[pe]=String.fromCharCode(pe);var pe;for(ni in pt)jr.hasOwnProperty(ni)||(jr[ni]=pt[ni]);var ni;function Ql(n){var e=yv&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||bv&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?jr:pt)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var kv=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),vv=typeof navigator<"u"&&/Win/.test(navigator.platform);function xv(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,i,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))kv?s=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),s&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function wv(n){let e=Object.create(null);for(let t in n)e[xv(t)]=n[t];return e}function ta(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Ke(n){return new z({props:{handleKeyDown:ri(n)}})}function ri(n){let e=wv(n);return function(t,r){let o=Ql(r),i,s=e[ta(o,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[ta(o,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(vv&&r.ctrlKey&&r.altKey)&&(i=pt[r.keyCode])&&i!=o){let l=e[ta(i,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var la={};q(la,{COMMENT_ID_RE:()=>yn,COMMENT_MAX_LENGTH:()=>oi,COMMENT_NAME_MAX_LENGTH:()=>ia,createCommentStore:()=>sa,newCommentId:()=>ii,sanitizeThread:()=>ra});var yn=/^[A-Za-z0-9_-]{1,64}$/,oi=5e3,ia=80;function ii(n="c"){let e=new Uint8Array(9);return globalThis.crypto.getRandomValues(e),n+Array.from(e,t=>(t%36).toString(36)).join("")}function ra(n){if(!n||typeof n!="object")return null;let e=n;if(typeof e.id!="string"||!yn.test(e.id))return null;let t=Array.isArray(e.comments)?e.comments.map(oh).filter(i=>i!==null):[],r=e.resolved,o={id:e.id,createdAt:Number(e.createdAt)||0,comments:t,resolved:r&&typeof r=="object"?{by:oa(r.by),at:Number(r.at)||0}:null};return typeof e.suggestion=="string"&&yn.test(e.suggestion)&&(o.suggestion=e.suggestion),o}function oa(n){let e=n&&typeof n=="object"?n:{};return{id:String(e.id??"").slice(0,128),name:String(e.name??"").slice(0,80)}}function oh(n){if(!n||typeof n!="object")return null;let e=n;if(typeof e.id!="string"||!yn.test(e.id))return null;let t={id:e.id,author:oa(e.author),text:String(e.text??"").slice(0,5e3),createdAt:Number(e.createdAt)||0};if(e.editedAt&&(t.editedAt=Number(e.editedAt)||0),Array.isArray(e.mentions)){let r=e.mentions.slice(0,20).map(oa).filter(o=>/^[\w.@:+-]{1,128}$/.test(o.id)&&o.name);r.length&&(t.mentions=r)}return t}function sa(n=[],e){let t=n.map(ra).filter(s=>s!==null),r=new Set,o=s=>{t=s,e?.(t),r.forEach(l=>l())},i=(s,l)=>o(t.map(a=>a.id===s?l(a):a));return{threads:()=>t,subscribe(s){return r.add(s),()=>r.delete(s)},createThread(s){let l=ra(s);!l||t.some(a=>a.id===l.id)||o([...t,l])},reply(s,l){let a=oh(l);a&&i(s,c=>({...c,comments:[...c.comments,a]}))},editComment(s,l,a){i(s,c=>({...c,comments:c.comments.map(u=>u.id===l?{...u,text:a.slice(0,5e3),editedAt:Date.now()}:u)}))},deleteComment(s,l){i(s,a=>({...a,comments:a.comments.filter(c=>c.id!==l)}))},setResolved(s,l){i(s,a=>({...a,resolved:l??null}))},deleteThread(s){o(t.filter(l=>l.id!==s))}}}var ua={};q(ua,{MENTION_ID_RE:()=>li,default:()=>ca,findMentionUsers:()=>aa,getMentions:()=>Mv});var li=/^[\w.@:+-]{1,128}$/,Sv=80,si=n=>n.replace(/^@/,"").trim().slice(0,Sv);async function aa(n,e,t=8){let r=await n(e);return Array.isArray(r)?r.filter(o=>o&&typeof o.id=="string"&&li.test(o.id)&&o.name).slice(0,t).map(o=>({id:o.id,name:si(String(o.name)),...o.description?{description:String(o.description).slice(0,120)}:{}})):[]}function Mv(n){let e="view"in n?n.view.state.doc:n,t=new Map;return e.descendants(r=>{r.type.name==="mention"&&!t.has(r.attrs.id)&&t.set(r.attrs.id,{id:r.attrs.id,name:r.attrs.name})}),[...t.values()]}var ca={name:"mentions",nodes:{mention:{group:"inline",inline:!0,atom:!0,selectable:!1,attrs:{id:{},name:{default:""}},parseDOM:[{tag:"span[data-mention]",getAttrs:n=>{let e=n,t=e.getAttribute("data-mention")??"";return li.test(t)?{id:t,name:si(e.textContent??"")}:!1}}],toDOM:n=>["span",{"data-mention":li.test(n.attrs.id)?n.attrs.id:null},`@${si(String(n.attrs.name))}`],leafText:n=>`@${si(String(n.attrs.name))}`}},load:()=>import(__novaChunk("tinymce-chunks/mentions-ui-b1bb2d15.js") )};var ah={en:{add:"Add comment",show:"Comments",panel:"Comments",guest:"Guest",newComment:"New comment",placeholder:"Add a comment\u2026",replyPlaceholder:"Reply\u2026",comment:"Comment",reply:"Reply",cancel:"Cancel",save:"Save",edit:"Edit",remove:"Delete",resolve:"Resolve",reopen:"Reopen",deleteThread:"Delete thread",close:"Close comments",showResolved:"Show resolved",resolvedBy:"Resolved by {name}",orphan:"The commented text was deleted",empty:"No comments yet. Select text and press \u201CAdd comment\u201D ({shortcut}).",people:"People",noPeople:"No matches",edited:"edited",you:"you",count:"{count} comments"}},ih=C.commentAdd,sh=C.comments,ai="Mod-Alt-m",ft=new X("nova-comments"),da=new WeakMap;function ci(n){return da.get(n)}function lh(n){let e=new Map;return n.descendants((t,r)=>{if(t.isInline)for(let o of t.marks){if(o.type.name!=="comment")continue;let i=o.attrs.id,s=e.get(i)??[],l=s[s.length-1];l&&l.to===r?l.to=r+t.nodeSize:s.push({from:r,to:r+t.nodeSize}),e.set(i,s)}}),e}function Ev(n){let{$from:e,empty:t}=n.selection;return(t?[...e.nodeBefore?.marks??[],...e.nodeAfter?.marks??[]]:e.nodeAfter?.marks??[]).filter(o=>o.type.name==="comment").map(o=>o.attrs.id)}var pa={name:"comments",toolbar:"addcomment showcomments",marks:{comment:{attrs:{id:{}},inclusive:!1,excludes:"",parseDOM:[{tag:"span[data-comment]",getAttrs:n=>{let e=n.getAttribute("data-comment")??"";return yn.test(e)?{id:e}:!1}}],toDOM:n=>["span",{"data-comment":yn.test(n.attrs.id)?n.attrs.id:null},0]}},prosemirrorPlugins:n=>{let e=null;return[Ke({[ai]:()=>ci(n)?.startComment()??!1}),new z({key:ft,state:{init:()=>({pending:null,active:null}),apply(t,r){let o=t.getMeta(ft),i=r;if(t.docChanged&&i.pending){let s=t.mapping.map(i.pending.from,1),l=t.mapping.map(i.pending.to,-1);i={...i,pending:s<l?{from:s,to:l}:null}}return o&&("pending"in o||"active"in o)&&(i={...i,...o}),i}},props:{decorations(t){let r=ci(n),o=ft.getState(t),i=r?.store.threads();if(e&&e.doc===t.doc&&e.threads===i&&e.state===o)return e.set;let s=new Set((i??[]).filter(c=>!c.resolved).map(c=>c.id)),l=[];for(let[c,u]of lh(t.doc)){if(!s.has(c))continue;let d=c===o.active?"nova-comment is-active":"nova-comment";for(let{from:p,to:f}of u)l.push(ge.inline(p,f,{class:d}))}if(o.pending){let{from:c,to:u}=o.pending;l.push(ge.inline(c,u,{class:"nova-comment is-active is-pending"}))}let a=ae.create(t.doc,l);return e={doc:t.doc,threads:i,state:o,set:a},a}},view:()=>({update(t,r){if(r.selection.eq(t.state.selection)||r.doc!==t.state.doc)return;let o=ci(n);if(!o||ft.getState(t.state).pending)return;let i=new Set(o.store.threads().filter(l=>!l.resolved).map(l=>l.id)),s=Ev(t.state).find(l=>i.has(l));s&&(s!==o.active()||!o.isPanelOpen())&&queueMicrotask(()=>{o.setActive(s),o.openPanel()})}})})]},setup(n){let e=Oe(n,"comments",ah),t=n.options.pluginOptions?.comments??{},r=t.store??sa(t.threads??[],t.onChange),o={id:String(t.author?.id??"guest").slice(0,128),name:String(t.author?.name||e.guest).slice(0,80)},i=()=>n.schema.marks.comment,s=t.mentions??n.options.pluginOptions?.mentions?.fetch,l=(M,L=[])=>[...new Map(L.map(B=>[B.id,B])).values()].filter(B=>M.includes(`@${B.name}`)),a=(M,L)=>{let O=l(M,L);return{id:ii(),author:o,text:M,createdAt:Date.now(),...O.length?{mentions:O}:{}}},c=(M,L)=>{L.mentions?.length&&t.onMention?.({threadId:M,comment:L,users:L.mentions})},u=()=>ft.getState(n.view.state),d=M=>n.view.dispatch(n.view.state.tr.setMeta(ft,M)),p=null,f=!1;n.ui.registry.addSidebar("comments",{title:e.panel,button:!1,header:!1,render:async M=>{let{createCommentsPanel:L}=await import(__novaChunk("tinymce-chunks/comments-panel-152e9cbe.js") );return p=L(h),M.append(p.el),()=>p?.destroy()},onShow:()=>{f=!0,p&&(p.el.hidden=!1),n.root.classList.add("nova-comments-open"),p?.render()},onHide:()=>{f=!1,p&&(p.el.hidden=!0),n.root.classList.remove("nova-comments-open"),u().pending&&d({pending:null})}});let h={editor:n,store:r,author:o,labels:e,shortcut:ai,pending:()=>u().pending,active:()=>u().active,setActive(M,L=!1){u().active!==M&&d({active:M}),p?.render();let O=M?h.ranges(M)[0]:void 0;if(L&&O){let{node:B}=n.view.domAtPos(O.from);(B instanceof Element?B:B.parentElement)?.scrollIntoView({block:"nearest"})}},startComment(){let{selection:M}=n.view.state;return M.empty||!n.isEditable()?!1:(d({pending:{from:M.from,to:M.to},active:null}),h.openPanel().then(()=>{p?.render(),p?.focusComposer()}),!0)},cancelPending(){d({pending:null}),p?.render(),n.focus()},findUsers:s?M=>aa(s,M):null,submitPending(M,L){let O=u().pending,B=M.trim().slice(0,5e3);if(!O||!B)return null;let J=ii("t"),P=a(B,L);r.createThread({id:J,createdAt:P.createdAt,comments:[P],resolved:null});let{state:G}=n.view;return n.view.dispatch(G.tr.addMark(O.from,O.to,i().create({id:J})).setMeta(ft,{pending:null,active:J}).setMeta("addToHistory",!1)),p?.render(),c(J,P),J},reply(M,L,O){let B=L.trim().slice(0,5e3);if(!B)return;let J=a(B,O);r.reply(M,J),c(M,J)},ranges:M=>lh(n.view.state.doc).get(M)??[],quote(M){let{doc:L}=n.view.state;return h.ranges(M).map(({from:O,to:B})=>L.textBetween(O,B," ")).join(" \u2026 ")},positionOf:M=>h.ranges(M)[0]?.from??Number.MAX_SAFE_INTEGER,deleteThread(M){let{state:L}=n.view,O=L.tr;for(let{from:B,to:J}of h.ranges(M))O.removeMark(B,J,i().create({id:M}));u().active===M&&O.setMeta(ft,{active:null}),(O.docChanged||O.getMeta(ft))&&n.view.dispatch(O.setMeta("addToHistory",!1)),r.deleteThread(M)},setResolved(M,L){r.setResolved(M,L?{by:o,at:Date.now()}:null),L&&u().active===M&&d({active:null})},canEdit:M=>t.canEdit?t.canEdit(M,o):M.author.id===o.id,isPanelOpen:()=>f,openPanel:()=>n.ui.sidebar.show("comments"),closePanel(){f&&(n.ui.sidebar.hide({restoreFocus:!1}),n.focus())}};da.set(n,h);let m=r.subscribe(()=>{n.view.isDestroyed||(d({refresh:!0}),p?.render())}),g=()=>h.startComment(),k=()=>h.isPanelOpen()?h.closePanel():void h.openPanel(),x=M=>M.isEditable()&&!M.view.state.selection.empty;return n.ui.registry.addButton("addcomment",{icon:ih,tooltip:e.add,shortcut:ai,isEnabled:x,onAction:g}),n.ui.registry.addToggleButton("showcomments",{icon:sh,tooltip:e.show,isActive:()=>f,onAction:k}),n.ui.registry.addMenuItem("addcomment",{text:e.add,icon:ih,shortcut:ai,isEnabled:x,onAction:g}),n.ui.registry.addMenuItem("showcomments",{text:e.show,icon:sh,isActive:()=>f,onAction:k}),()=>{m(),da.delete(n)}}};var ga={};q(ga,{LABELS:()=>uh,default:()=>ma,flatList:()=>ph,isGroup:()=>dh,optionsOf:()=>ui});var uh={en:{insert:"Insert variable",search:"Variables",empty:"No variables found",unknown:"Unknown variable"}},ch=/^[\w.:-]{1,100}$/,Cv=/^data-[a-z0-9-]{1,40}$/;function ui(n){return n.options.pluginOptions?.mergetags??{}}function Av(n){let e=ui(n).attribute??"data-mergetag";return Cv.test(e)?e:(console.warn(`[nova] mergetags: attribute "${e}" must look like data-name; using data-mergetag`),"data-mergetag")}var dh=n=>Array.isArray(n.items);function ph(n){return(ui(n).list??[]).flatMap(e=>dh(e)?e.items:[e])}function fh(n,e){return ph(n).find(t=>t.key===e)?.label}function Tv(n){let e=Av(n);return{mergetag:{group:"inline",inline:!0,atom:!0,selectable:!0,draggable:!0,ignoreStyles:!0,attrs:{key:{},label:{default:""}},parseDOM:[{tag:`span[${e}]`,priority:60,getAttrs:t=>{let r=t,o=r.getAttribute(e)??"";return ch.test(o)?{key:o,label:fh(n,o)??r.textContent?.trim()??o}:!1}}],toDOM:t=>{let r=ch.test(t.attrs.key)?t.attrs.key:"",o=t.attrs.label==null||t.attrs.label===""?r:String(t.attrs.label);return["span",{[e]:r,contenteditable:"false"},o]}}}}var ha=class{constructor(e,t,r){S(this,"node",e);S(this,"editor",t);S(this,"unknownTitle",r);S(this,"dom");this.dom=document.createElement("span"),this.dom.className="nova-mergetag",this.dom.contentEditable="false",this.render()}render(){let e=this.node.attrs.key,t=fh(this.editor,e);this.dom.textContent=t??(this.node.attrs.label||e),this.dom.dataset.key=e;let o=!!ui(this.editor).list?.length&&t===void 0;this.dom.classList.toggle("is-unknown",o),this.dom.title=o?`${this.unknownTitle}: ${e}`:e}update(e){return e.type!==this.node.type?!1:(this.node=e,this.render(),!0)}selectNode(){this.dom.classList.add("is-selected")}deselectNode(){this.dom.classList.remove("is-selected")}stopEvent(){return!1}ignoreMutation(){return!0}},ma={name:"mergetags",toolbar:"mergetags",nodes:Tv,prosemirrorPlugins:n=>{let e=Oe(n,"mergetags",uh);return[new z({props:{nodeViews:{mergetag:(t,r)=>new ha(t,n,e.unknown)}}})]},load:()=>import(__novaChunk("tinymce-chunks/mergetags-ui-f5bdd1f9.js") )};var La={};q(La,{LABELS:()=>wa,OWN:()=>ki,RESOLVED:()=>Ch,around:()=>bi,attrValue:()=>Ea,blockSuggestion:()=>Ee,cleanFormat:()=>Kr,default:()=>Oa,formatMarks:()=>vi,hasInline:()=>mi,isSuggesting:()=>Aa,listSuggestions:()=>Na,markup:()=>Ma,resolveSuggestions:()=>Ph,setStructureTrackers:()=>Bv,setSuggesting:()=>Dh,suggestTransaction:()=>Lh,suggestionColor:()=>Ah,suggestionsKey:()=>er,suggestionsResult:()=>Xv});var ka={};q(ka,{addListNodes:()=>Pv,bulletList:()=>mh,liftListItem:()=>bn,listItem:()=>gh,orderedList:()=>hh,sinkListItem:()=>pi,splitListItem:()=>di,splitListItemKeepMarks:()=>Dv,wrapInList:()=>ba,wrapRangeInList:()=>yh});var Nv=["ol",0],Ov=["ul",0],Lv=["li",0],hh={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs(n){return{order:n.hasAttribute("start")?+n.getAttribute("start"):1}}}],toDOM(n){return n.attrs.order==1?Nv:["ol",{start:n.attrs.order},0]}},mh={parseDOM:[{tag:"ul"}],toDOM(){return Ov}},gh={parseDOM:[{tag:"li"}],toDOM(){return Lv},defining:!0};function ya(n,e){let t={};for(let r in n)t[r]=n[r];for(let r in e)t[r]=e[r];return t}function Pv(n,e,t){return n.append({ordered_list:ya(hh,{content:"list_item+",group:t}),bullet_list:ya(mh,{content:"list_item+",group:t}),list_item:ya(gh,{content:e})})}function ba(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,s=o.blockRange(i);if(!s)return!1;let l=r?t.tr:null;return yh(l,s,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function yh(n,e,t,r=null){let o=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new Ft(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new Ft(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=ln(i,t,r,e);return l?(n&&Rv(n,e,l,o,t),!0):!1}function Rv(n,e,t,r,o){let i=T.empty;for(let u=t.length-1;u>=0;u--)i=T.from(t[u].type.create(t[u].attrs,i));n.step(new re(e.start-(r?2:0),e.end,e.start,e.end,new D(i,0,0),t.length,!0));let s=0;for(let u=0;u<t.length;u++)t[u].type==o&&(s=u+1);let l=t.length-s,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,p=!0;u<d;u++,p=!1)!p&&l&&Ct(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function Qn(n,e){return n instanceof st?e==n:n.indexOf(e)>-1}function di(n,e){return function(t,r){let{$from:o,$to:i,node:s}=t.selection;if(s&&s.isBlock||o.depth<2||!o.sameParent(i))return!1;let l=o.node(-1);if(!Qn(n,l.type))return!1;if(o.parent.content.size==0&&o.node(-1).childCount==o.indexAfter(-1)){if(o.depth==3||!Qn(n,o.node(-3).type)||o.index(-2)!=o.node(-2).childCount-1)return!1;if(r){let d=T.empty,p=o.index(-1)?1:o.index(-2)?2:3;for(let k=o.depth-p;k>=o.depth-3;k--)d=T.from(o.node(k).copy(d));let f=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;d=d.append(T.from(o.node(-3).type.createAndFill()));let h=o.before(o.depth-(p-1)),m=t.tr.replace(h,o.after(-f),new D(d,4-p,0)),g=-1;m.doc.nodesBetween(h,m.doc.content.size,(k,x)=>{if(g>-1)return!1;k.isTextblock&&k.content.size==0&&(g=x+1)}),g>-1&&m.setSelection(U.near(m.doc.resolve(g))),r(m.scrollIntoView())}return!0}let a=i.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(o.pos,i.pos),u=a||e?[e?{type:l.type,attrs:e}:null,a?{type:a}:null]:void 0;return Ct(c.doc,o.pos,2,u)?(r&&r(c.split(o.pos,2,u).scrollIntoView()),!0):!1}}function Dv(n,e){let t=di(n,e);return(r,o)=>t(r,o&&(i=>{let s=r.storedMarks||r.selection.$to.parentOffset&&r.selection.$from.marks();s&&i.ensureMarks(s),o(i)}))}function bn(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,s=>s.childCount>0&&Qn(n,s.firstChild.type));return i?t?Qn(n,r.node(i.depth-1).type)?_v(e,t,i):Iv(e,t,i):!0:!1}}function _v(n,e,t){let r=n.tr,o=t.end,i=t.$to.end(t.depth),s=t.parent.child(t.endIndex-1).type;o<i&&(r.step(new re(o-1,i,o,i,new D(T.from(s.create(null,t.parent.copy())),1,0),1,!0)),t=new Ft(r.doc.resolve(t.$from.pos),r.doc.resolve(i),t.depth));let l=at(t);if(l==null)return!1;r.lift(t,l);let a=r.doc.resolve(r.mapping.map(o,-1)-1);return ct(r.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&r.join(a.pos),e(r.scrollIntoView()),!0}function Iv(n,e,t){let r=n.tr,o=t.parent;for(let f=t.end,h=t.endIndex-1,m=t.startIndex;h>m;h--)f-=o.child(h).nodeSize,r.delete(f-1,f+1);let i=r.doc.resolve(t.start),s=i.nodeAfter;if(r.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?T.empty:T.from(o))))return!1;let d=i.pos,p=d+s.nodeSize;return r.step(new re(d-(l?1:0),p+(a?1:0),d+1,p-1,new D((l?T.empty:T.from(o.copy(T.empty))).append(a?T.empty:T.from(o.copy(T.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function pi(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&Qn(n,c.firstChild.type));if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(!Qn(n,a.type))return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=T.from(c?a.lastChild.lastChild.type.create():null),d=new D(T.from(a.type.create(null,T.from(l.type.create(null,u)))),c?3:1,0),p=i.start,f=i.end;t(e.tr.step(new re(p-(c?3:1),f,p,f,d,1,!0)).scrollIntoView())}return!0}}var fi="nova:set-content";var Wr=/^[A-Za-z0-9_-]{1,64}$/,nr=/^[\w.@:+-]{1,128}$/,wa={en:{toggle:"Suggest edits",review:"Review suggestions",accept:"Accept",reject:"Reject",acceptAll:"Accept all suggestions",rejectAll:"Reject all suggestions",next:"Next suggestion",previous:"Previous suggestion",inserted:"Inserted by {name}",deleted:"Deleted by {name}",formatted:"Formatted by {name}",toolbar:"Suggestion",guest:"Guest",none:"No suggestions",unsupported:"This change can\u2019t be a suggestion",unsupportedDirect:"This change can\u2019t be a suggestion. To make it, turn off Suggest edits."}},er=new X("nova-suggestions"),ki="nova-suggestions-own",Ch="nova-suggestions-resolved",bh=["#116329","#6639ba","#99286e","#0550ae","#953800","#0e5b5e"];function Ah(n){let e=0;for(let t of String(n??""))e=e*31+t.charCodeAt(0)|0;return bh[Math.abs(e)%bh.length]}function hi(){let n=new Uint8Array(9);return globalThis.crypto.getRandomValues(n),"s"+Array.from(n,e=>(e%36).toString(36)).join("")}function kh(n){let e=n==="insert"?"ins":"del";return{attrs:{id:{},author:{default:""},name:{default:""},time:{default:0}},inclusive:!1,excludes:"",parseDOM:[{tag:`${e}[data-suggestion]`,priority:60,getAttrs:t=>{let r=t,o=r.getAttribute("data-suggestion")??"";if(!Wr.test(o))return!1;let i=r.getAttribute("data-author")??"";return{id:o,author:nr.test(i)?i:"",name:(r.getAttribute("data-name")??"").slice(0,80),time:Number(r.getAttribute("data-time"))||0}}}],toDOM:t=>[e,{"data-suggestion":Wr.test(t.attrs.id)?t.attrs.id:null,"data-author":nr.test(t.attrs.author)?t.attrs.author:null,"data-name":String(t.attrs.name??"").slice(0,80)||null,"data-time":Number(t.attrs.time)||null},0]}}function Kr(n){let e;try{e=typeof n=="string"?JSON.parse(n):n}catch{return"[]"}if(!Array.isArray(e))return"[]";let t=[];for(let r of e.slice(0,16)){let o=r?.type;if(typeof o!="string"||!/^[a-z][a-z0-9_]{0,39}$/.test(o))continue;let i=Th(r.attrs,8);t.push(Object.keys(i).length?{type:o,attrs:i}:{type:o})}return JSON.stringify(t)}function Th(n,e){let t={};if(n&&typeof n=="object"&&!Array.isArray(n))for(let[r,o]of Object.entries(n).slice(0,e))!/^[A-Za-z][\w-]{0,39}$/.test(r)||r==="suggestion"||(typeof o=="string"?t[r]=o.slice(0,2e3):(typeof o=="number"||typeof o=="boolean"||o===null)&&(t[r]=o));return t}function Ee(n){if(!n||typeof n!="object")return null;let e=n;if(typeof e.id!="string"||!Wr.test(e.id))return null;let t=String(e.author??""),r={id:e.id,author:nr.test(t)?t:"",name:String(e.name??"").slice(0,80),time:Number(e.time)||0};if(e.change==="split"||e.change==="join"){let i=e.change==="join"&&e.before!=null?vh(e.before):null;return{...r,change:e.change,depth:Math.min(4,Math.max(1,Math.trunc(Number(e.depth))||1)),...i?{before:i}:{}}}if(e.change==="insert"||e.change==="delete")return{...r,change:e.change};if(e.change==="wrap"||e.change==="unwrap")return{...r,change:e.change,depth:Math.min(9,Math.max(1,Math.trunc(Number(e.depth))||1))};let o=vh(e.before);return o?{...r,change:"block",before:o}:null}function vh(n){let e=n;try{typeof e=="string"&&(e=JSON.parse(e))}catch{return null}let t=e?.type;return typeof t!="string"||!/^[a-z][a-z0-9_]{0,39}$/.test(t)?null:{type:t,attrs:Th(e.attrs,12)}}var Hv={nodes:"all",default:null,parse:n=>n.hasAttribute("data-before")||n.hasAttribute("data-change")?Ee({id:n.getAttribute("data-suggestion"),author:n.getAttribute("data-author"),name:n.getAttribute("data-name"),time:n.getAttribute("data-time"),before:n.getAttribute("data-before"),change:n.getAttribute("data-change"),depth:n.getAttribute("data-depth")}):null,render(n){let e=Ee(n);if(!e)return{};let t={"data-suggestion":e.id};return e.change!=="block"&&(t["data-change"]=e.change),e.before&&(t["data-before"]=JSON.stringify(e.before)),(e.depth??1)>1&&(t["data-depth"]=String(e.depth)),e.author&&(t["data-author"]=e.author),e.name&&(t["data-name"]=e.name),e.time&&(t["data-time"]=String(e.time)),t}},gi=null;function Bv(n){gi=n}function Fv(){return{attrs:{id:{},author:{default:""},name:{default:""},time:{default:0},before:{default:"[]"}},inclusive:!1,excludes:"",parseDOM:[{tag:"span[data-suggestion][data-format]",priority:60,getAttrs:n=>{let e=n,t=e.getAttribute("data-suggestion")??"";if(!Wr.test(t))return!1;let r=e.getAttribute("data-author")??"";return{id:t,author:nr.test(r)?r:"",name:(e.getAttribute("data-name")??"").slice(0,80),time:Number(e.getAttribute("data-time"))||0,before:Kr(e.getAttribute("data-format"))}}}],toDOM:n=>["span",{"data-suggestion":Wr.test(n.attrs.id)?n.attrs.id:null,"data-format":Kr(n.attrs.before),"data-author":nr.test(n.attrs.author)?n.attrs.author:null,"data-name":String(n.attrs.name??"").slice(0,80)||null,"data-time":Number(n.attrs.time)||null},0]}}var Ur=n=>({insert:n.marks.suggestion_insert,delete:n.marks.suggestion_delete,format:n.marks.suggestion_format}),Ta=new Set(["suggestion_insert","suggestion_delete","suggestion_format","comment"]),yi=n=>n.filter(e=>!Ta.has(e.type.name));function vi(n,e){let t=[];for(let r of JSON.parse(Kr(e)))if(!(Ta.has(r.type)||!n.marks[r.type]))try{let o=n.markFromJSON(r);o.isInSet(t)||t.push(o)}catch{}return t}var Sa=(n,e)=>n.length===e.length&&n.every(t=>t.isInSet(e));function zv(n){return!n.docChanged||n.getMeta(ki)||n.getMeta("addToHistory")===!1||n.getMeta(fi)||n.getMeta("history$")?!1:!n.getMeta("y-sync$")?.isChangeOrigin}var tr=n=>!!n.type.spec.attrs&&"suggestion"in n.type.spec.attrs;function kn(n,e,t,r,o=1){return{id:e,author:t.id,name:t.name,time:r,change:n,...o>1?{depth:o}:{}}}function bi(n,e,t){let r=n.resolve(e),o={own:!1,deleted:!1};for(let i=r.depth;i>0;i--){let s=Ee(r.node(i).attrs.suggestion);s?.change==="insert"&&s.author===t&&(o.own=!0),s?.change==="delete"&&(o.deleted=!0)}return o}function mi(n){let e=!1;return n.descendants(t=>(t.isInline&&(e=!0),!e)),e}function Ma(n){let e={};for(let[t,r]of Object.entries(n.attrs))t!=="suggestion"&&(r===null||["string","number","boolean"].includes(typeof r))&&(e[t]=r);return{type:n.type.name,attrs:e}}function Ea(n,e,t){return e.attrs[t]??n.nodes[e.type]?.spec.attrs?.[t]?.default??null}function xh(n,e,t){return[...new Set([...Object.keys(e.attrs),...Object.keys(t.attrs)])].filter(r=>Ea(n,e,r)!==Ea(n,t,r))}function $v(n,e){if(n instanceof on)return e.nodeAt(n.pos)?n.pos:null;if(n instanceof re){let t=e.nodeAt(n.from),r=n.slice.content.firstChild;return!!t&&!!r&&!r.isLeaf&&n.slice.content.childCount===1&&n.slice.openStart===0&&n.slice.openEnd===0&&n.insert===1&&n.to===n.from+t.nodeSize&&n.gapFrom===n.from+1&&n.gapTo===n.to-1&&r.content.size===0?n.from:null}if(n instanceof le){let{from:t,to:r,slice:o}=n,i=e.nodeAt(t),s=o.content.firstChild;return i?.isLeaf&&!i.isText&&s?.isLeaf&&i.type===s.type&&r===t+i.nodeSize&&o.content.childCount===1&&o.openStart===0&&o.openEnd===0&&Sa(i.marks,s.marks)&&!i.eq(s)?t:null}return null}var Vv=new Set(["colwidth"]);function qv(n,e,t,r,o,i){let s=n.doc.nodeAt(e);if(!s||!tr(s)||!tr(t))return!1;let l=n.doc.type.schema,a=m=>n.setNodeMarkup(e,t.type,{...t.attrs,suggestion:m},t.marks),c=Ee(s.attrs.suggestion),u=Ma(s),d=Ma(t);if(s.marks.some(m=>m.type.name==="suggestion_insert"&&m.attrs.author===r.id)||(c?.change==="insert"||c?.change==="split")&&c.author===r.id||bi(n.doc,e,r.id).own||u.type===d.type&&xh(l,u,d).every(m=>Vv.has(m)))return a(s.attrs.suggestion),!0;if(c&&c.change!=="block")return!1;let f=c?.before??u,h=f.type===d.type&&xh(l,f,d).length===0;return a(h?null:{id:c?.id??o(),author:r.id,name:r.name,time:i,change:"block",before:f}),!0}function Ca(n,e){let t=n.doc.nodeAt(e);if(!t||t.isLeaf)return null;let r=n.steps.length,o=n.doc.type.schema.nodes.list_item;if(t.type===o&&o){let i=un.create({doc:n.doc,selection:F.near(n.doc.resolve(e+1))}),s=!1;if(bn(o)(i,l=>{for(let a of l.steps)n.step(a);s=!0}),!s)return null}else{let i=n.doc.resolve(e+1).blockRange(n.doc.resolve(e+t.nodeSize-1)),s=i&&at(i);if(s==null)return null;n.lift(i,s)}return n.mapping.slice(r).map(e+1,1)}function Nh(n,e){let t=n.resolve(e);return t.depth>0&&e===t.start()?t.before():null}function wh(n,e){return[...e].sort((t,r)=>r-t).every(t=>Ca(n,t)!==null)}function jv(n,e,t,r,o,i,s){let l=gi?.structure(t,n.doc);if(!l?.nodes.length)return null;let a=(h,...m)=>!!h&&h.author===o.id&&m.includes(h.change);if(l.change==="wrap"){let h=new Et(n.doc);if(!wh(h,l.nodes)||!h.doc.eq(t))return null;for(let m of l.nodes){let g=Ee(n.doc.nodeAt(m).attrs.suggestion);if(!a(g,"insert")){if(g&&!a(g,"wrap"))return null;n.setNodeAttribute(m,"suggestion",kn("wrap",g?.id??i(),o,s,(g?.depth??0)+1))}}return n}let c=new Et(t);if(!wh(c,l.nodes)||!c.doc.eq(n.doc))return null;let u=l.nodes.map(h=>({pos:h,node:t.nodeAt(h)})),d=({node:h})=>{let m=h.childCount===1?h.firstChild:null,g=Ee(h.attrs.suggestion)??Ee(m?.attrs.suggestion),k=!0;return m?.descendants(x=>(x.isInline&&!x.marks.some(M=>M.type.name==="suggestion_insert"&&M.attrs.author===o.id)&&(k=!1),k)),!!m?.isTextblock&&a(g,"split","insert")&&k},p=({node:h})=>a(Ee(h.attrs.suggestion),"wrap");if(u.every(h=>d(h)||p(h))){let h=n.mapping.slice(e);for(let m of u){let g=h.map(m.pos+1,1),k=Nh(n.doc,g),x=k===null?null:n.doc.nodeAt(k);if(p(m)){let O=Ee(m.node.attrs.suggestion);x?.type===m.node.type&&n.setNodeAttribute(k,"suggestion",(O.depth??1)>1?kn("wrap",O.id,o,O.time,O.depth-1):null);continue}let M=n.doc.nodeAt(g),L=Ee(m.node.attrs.suggestion)??Ee(m.node.firstChild.attrs.suggestion);M?.isTextblock&&x?.type.name!=="list_item"&&n.setNodeAttribute(g,"suggestion",kn("insert",L.id,o,L.time))}return n}let f=r.tr;for(let h of n.steps.slice(0,e))f.step(h);if(!f.doc.eq(t))return null;for(let{pos:h,node:m}of u){let g=Ee(m.attrs.suggestion);if(g&&!a(g,"unwrap"))return null;f.setNodeAttribute(h,"suggestion",kn("unwrap",g?.id??i(),o,s,(g?.depth??0)+1))}return f}function Wv(n,e,t,r,o,i,s){let l=Ur(n.doc.type.schema),a=(d,p)=>r==="add"?n.addMark(d,p,o):n.removeMark(d,p,o);if(Ta.has(o.type.name)||!l.format){a(e,t);return}let c=[];n.doc.nodesBetween(e,t,(d,p,f)=>{if(!d.isInline)return!0;let h=Math.max(p,e),m=Math.min(p+d.nodeSize,t);return h<m&&f?.type.allowsMarkType(o.type)&&c.push({from:h,to:m,node:d}),!1});let u=null;for(let{from:d,to:p,node:f}of c){let h=r==="add"?o.addToSet(f.marks):o.removeFromSet(f.marks);if(Sa(h,f.marks)||(a(d,p),f.marks.some(x=>x.type===l.insert&&x.attrs.author===i.id)||l.delete.isInSet(f.marks)))continue;let g=f.marks.find(x=>x.type===l.format);if(g){let x=vi(n.doc.type.schema,g.attrs.before);Sa(yi(h),x)&&n.removeMark(d,p,g);continue}u??(u=hi());let k=Kr(yi(f.marks).map(x=>x.toJSON()));n.addMark(d,p,l.format.create({id:u,author:i.id,name:i.name,time:s,before:k}))}}function va(n,e,t,r){let o=n.resolve(e);for(let i of[o.nodeBefore,o.nodeAfter]){let s=i?.marks.find(l=>l.type===t&&l.attrs.author===r);if(s)return s}return null}function Oh(n,e,t,r,o,i){let s=[];return n.forEach((l,a,c)=>{if(l.isInline){s.push(t&&!t.allowsMarkType(e.type)?l:l.mark(e.addToSet(l.marks)));return}let u=c===0&&r>0,d=c===n.childCount-1&&o>0;if(!u&&!d&&tr(l)){s.push(l.type.create({...l.attrs,suggestion:i()},l.content,l.marks));return}s.push(l.copy(Oh(l.content,e,l.type,u?r-1:0,d?o-1:0,i)))}),T.from(s)}function Sh(n,e,t){n.maybeStep(new le(e,e,t)).failed&&n.replace(e,e,t)}function xa(n,e,t){if(n instanceof R){let r=t(n.from),o=e.nodeAt(r);if(o&&R.isSelectable(o))return R.create(e,r)}return F.between(e.resolve(t(n.anchor)),e.resolve(t(n.head)))}function Lh(n,e,t,r){if(!zv(n))return n;let o=()=>(r?.(),e.tr),i=gi?.breaks(n,e,t);if(i)return i;let s=Ur(e.schema),l=e.tr,a=Date.now(),c=null,u=()=>c??(c=hi()),d=L=>L,p=null,f=null,h=null,m=!1,g=!1,k=!1,x=null,M=null;for(let L=0;L<n.steps.length;L++){let O=n.steps[L],B=n.docs[L];if(O instanceof Je||O instanceof Ge){if(x!==null)return o();let K=O instanceof Je?"add":"remove";Wv(l,d(O.from),d(O.to),K,O.mark,t,a);continue}let J=$v(O,B);if(J!==null){if(x!==null||g)return o();k=!0;let K=(n.docs[L+1]??n.doc).nodeAt(J);if(!K||!qv(l,d(J),K,t,u,a))return o();continue}if(O instanceof re||x!==null){let K=O instanceof le&&(mi(B.slice(O.from,O.to).content)||mi(O.slice.content));if(!gi||K||!(O instanceof re||O instanceof le))return o();if(x===null){if(!l.doc.eq(B))return o();x=l.steps.length,M=l.doc}if(l.maybeStep(O).failed)return o();continue}if(!(O instanceof le))return o();m=!0;let P=O,G=l.steps.length,y=d,v=y(P.from),b=Math.max(v,y(P.to)),E=!1;if(b>v){let K=[],se=[],Ae=[];l.doc.nodesBetween(v,b,(ue,he)=>{let be=Math.max(he,v),Is=Math.min(he+ue.nodeSize,b);if(be>=Is)return!1;if(!ue.isInline){if(he<v||he+ue.nodeSize>b)return!0;let en=Ee(ue.attrs.suggestion);return en?.change==="insert"&&en.author===t.id?(K.push({from:he,to:he+ue.nodeSize}),!1):en?.change==="delete"?!1:!tr(ue)||en?!0:(Ae.push(he),!1)}let wd=bi(l.doc,he,t.id);return wd.deleted||(wd.own||ue.marks.some(en=>en.type===s.insert&&en.attrs.author===t.id)?K.push({from:be,to:Is}):s.delete.isInSet(ue.marks)||se.push({from:be,to:Is})),!1});let ot=null;if(se.length){let ue=se[0],he=va(l.doc,ue.from,s.delete,t.id)??va(l.doc,se[se.length-1].to,s.delete,t.id)??s.delete.create({id:hi(),author:t.id,name:t.name,time:a});for(let be of se)l.addMark(be.from,be.to,he);ot=he.attrs.id}for(let ue of Ae)l.setNodeAttribute(ue,"suggestion",kn("delete",ot??u(),t,a));let Ve=l.doc.resolve(v),wt=l.doc.resolve(b),it=wt.parent;if(Ve.parent!==it&&Ve.parent.isTextblock&&it.isTextblock&&Ve.depth===wt.depth&&wt.start()>v&&tr(it)&&!it.attrs.suggestion&&!Ae.includes(wt.before())&&l.setNodeAttribute(wt.before(),"suggestion",{id:ot??u(),author:t.id,name:t.name,time:a,change:"join",depth:wt.depth-Ve.sharedDepth(b)}),(se.length||Ae.length)&&(g=!0,k))return o();E=Ae.length>0;for(let ue of K.sort((he,be)=>be.from-he.from))l.delete(ue.from,ue.to);let ye=l.mapping.slice(G);v=ye.map(v,1),b=ye.map(b,-1);let He=e.selection;n.steps.length===1&&P.slice.size===0&&(He.empty&&He.from===P.from&&n.selection.head===P.from&&(p=b),He instanceof R&&Ae.includes(y(He.from))&&(f=ye.map(y(He.to),1)))}let _=E&&P.slice.content.childCount===1&&!P.slice.openStart&&!!P.slice.content.firstChild.isTextblock&&!P.slice.content.firstChild.content.size;if(P.slice.size>0&&!_){let K=b;if(bi(l.doc,K,t.id).own){let ye=l.doc.resolve(K),He=ye.parent.isTextblock?Ee(ye.parent.attrs.suggestion):null;if(Sh(l,K,P.slice),He?.change==="insert"&&P.slice.openEnd>0){let be=l.doc.resolve(K+P.slice.size);be.parent.isTextblock&&!be.parent.attrs.suggestion&&l.setNodeAttribute(be.before(),"suggestion",He)}n.steps.length===1&&(h={at:K,from:P.from,size:P.slice.size});let ue=P.getMap().invert(),he=l.mapping.slice(G);d=be=>he.map(y(ue.map(be,-1)),1);continue}if(!P.slice.openStart)for(let ye=l.doc.resolve(K).nodeAfter;ye&&s.delete.isInSet(ye.marks);)K+=ye.nodeSize,ye=l.doc.resolve(K).nodeAfter;let se=va(l.doc,K,s.insert,t.id)??s.insert.create({id:hi(),author:t.id,name:t.name,time:a}),Ae=l.doc.resolve(K),ot=()=>kn("insert",mi(P.slice.content)?se.attrs.id:u(),t,a),Ve=Oh(P.slice.content,se,P.slice.openStart?null:Ae.parent.type,P.slice.openStart,P.slice.openEnd,ot);Sh(l,K,new D(Ve,P.slice.openStart,P.slice.openEnd)),n.steps.length===1&&(h={at:K,from:P.from,size:P.slice.size});let{openStart:wt,openEnd:it}=P.slice;if(wt>0&&wt===it&&Ae.parent.isTextblock){let ye=l.doc.resolve(K+P.slice.size),He=ye.depth>=it?ye.before(ye.depth-it+1):-1,ue=Ae.parentOffset===Ae.parent.content.size&&He>=0&&He+l.doc.nodeAt(He).nodeSize===K+P.slice.size+it,he=ue?He:ye.depth>0?ye.before():-1,be=he>=0?l.doc.nodeAt(he):null;ye.parent.isTextblock&&be&&tr(be)&&l.setNodeAttribute(he,"suggestion",ue?kn("insert",se.attrs.id,t,a):{id:se.attrs.id,author:t.id,name:t.name,time:a,change:"split",depth:it})}}let N=P.getMap().invert(),$=l.mapping.slice(G);d=K=>$.map(y(N.map(K,-1)),1)}if(x!==null){let L=jv(l,x,M,e,t,u,a);if(!L)return o();L===l?l.setSelection(n.selection.map(l.doc,l.mapping.slice(l.steps.length))):(l=L,l.setSelection(e.selection.map(l.doc,l.mapping)))}else if(!m)l.setSelection(n.selection.map(l.doc,l.mapping.slice(l.steps.length)));else if(p!==null)l.setSelection(F.create(l.doc,p));else if(f!==null)l.setSelection(U.near(l.doc.resolve(f),1));else if(h){let{at:L,from:O,size:B}=h,{anchor:J,head:P,empty:G}=n.selection,y=v=>v>=O&&v<=O+B;if(G&&P===O+B)l.setSelection(F.create(l.doc,L+B));else if(y(J)&&y(P))l.setSelection(xa(n.selection,l.doc,v=>v-O+L));else if(G){let v=l.doc.resolve(L+B);l.setSelection(F.between(v,v))}else l.setSelection(xa(n.selection,l.doc,d))}else l.setSelection(xa(n.selection,l.doc,d));for(let L of["addToHistory","uiEvent","paste","scrollIntoView"]){let O=n.getMeta(L);O!==void 0&&l.setMeta(L,O)}return n.scrolledIntoView&&l.scrollIntoView(),l}function Kv(n,e){let t=vi(n.type.schema,e.attrs.before),r=yi(n.marks),o=r.filter(s=>!s.isInSet(t)).map(s=>s.type.name),i=t.filter(s=>!s.isInSet(r)&&!o.includes(s.type.name)).map(s=>s.type.name);return{added:o,removed:i}}var Mh=(n,e)=>{for(let t of e)n.includes(t)||n.push(t)};function Na(n){let e=Ur(n.type.schema),t=[];return n.descendants((r,o)=>{if(!r.isText){let i=Ee(r.attrs.suggestion);if(i&&t.push({id:i.id,kind:i.change,author:{id:i.author,name:i.name},time:i.time,from:o,to:o+r.nodeSize,text:r.isLeaf?r.type.spec.leafText?.(r)??"":r.textContent,node:r.type.name,...i.before?{before:i.before}:{},...i.depth?{depth:i.depth}:{}}),!r.isInline)return!0}for(let i of r.marks){let s=i.type===e.insert?"insert":i.type===e.delete?"delete":i.type===e.format?"format":null;if(!s)continue;let l=t[t.length-1],a=r.isText?r.text:r.type.spec.leafText?.(r)??"",c=s==="format"?Kv(r,i):null;l&&l.id===i.attrs.id&&l.kind===s&&l.to===o?(l.to=o+r.nodeSize,l.text+=a,c&&(Mh(l.added,c.added),Mh(l.removed,c.removed))):t.push({id:i.attrs.id,kind:s,author:{id:i.attrs.author,name:i.attrs.name},time:Number(i.attrs.time)||0,from:o,to:o+r.nodeSize,text:a,...c??{}})}return!1}),t}function Uv(n,e,t){let r=Ur(n.doc.type.schema).format,o=[];n.doc.nodesBetween(e.from,e.to,(i,s)=>{if(!i.isInline)return!0;let l=i.marks.find(a=>a.type===r&&a.attrs.id===e.id);return l&&o.push({from:Math.max(s,e.from),to:Math.min(s+i.nodeSize,e.to),node:i,mark:l}),!1});for(let{from:i,to:s,node:l,mark:a}of o){if(t==="reject"){let c=vi(n.doc.type.schema,a.attrs.before);for(let u of yi(l.marks))u.isInSet(c)||n.removeMark(i,s,u);for(let u of c)u.isInSet(l.marks)||n.addMark(i,s,u)}n.removeMark(i,s,a)}}function Jv(n,e,t){let r=e.from,o=n.doc.nodeAt(r);if(!o)return;let i=t==="reject"?n.doc.type.schema.nodes[e.before.type]:void 0,s=n.doc.resolve(r);if(i?.spec.attrs&&"suggestion"in i.spec.attrs&&s.parent.canReplaceWith(s.index(),s.index()+1,i)&&(o.isLeaf?i.isLeaf:!i.isLeaf&&i.validContent(o.content))){let l=Object.fromEntries(Object.entries(e.before.attrs).filter(([a])=>a in i.spec.attrs));try{n.setNodeMarkup(r,i,{...o.attrs,...l,suggestion:null},o.marks);return}catch{}}n.setNodeAttribute(r,"suggestion",null)}function Gv(n,e){let t=n.doc.nodeAt(e);if(!t)return;let r=n.doc.resolve(e),o=e,i=e+t.nodeSize;for(let s=r.depth;;s--){let l=r.node(s),a=r.index(s);if(l.canReplace(a,a+1)){n.delete(o,i);return}if(s===0||l.childCount>1||l.type.spec.isolating){let c=l.type.contentMatch.defaultType?.createAndFill();c&&l.canReplace(a,a+1,T.from(c))&&n.replaceWith(o,i,c);return}o=r.before(s),i=r.after(s)}}function Ph(n,e,t){let r=Ur(n.schema),o=n.tr.setMeta(ki,!0),i=Na(n.doc).filter(p=>!t||t.includes(p.id));o.setMeta(Ch,{action:e,ids:[...new Set(i.map(p=>p.id))]});for(let p of i)p.kind==="format"&&Uv(o,p,e);let s=[],l=[];for(let p of i){if(!p.node)continue;let f=e==="reject",h=p.kind==="block"?f&&"style":p.kind==="join"?f?!!p.before&&"style":"join":p.kind==="split"?f&&"join":p.kind==="insert"?f&&"remove":p.kind==="delete"?!f&&"remove":p.kind==="wrap"?f&&"lift":!f&&"lift";h?h==="remove"?s.push(p):l.push({s:p,op:h}):o.setNodeAttribute(p.from,"suggestion",null)}for(let p of[...i].sort((f,h)=>h.from-f.from))p.kind!=="insert"&&p.kind!=="delete"||p.node||(p.kind==="insert"==(e==="reject")?o.delete(p.from,p.to):o.removeMark(p.from,p.to,p.kind==="insert"?r.insert:r.delete));let a=p=>{let f=o.mapping.mapResult(p.from,1);return(f.deleted?null:o.doc.nodeAt(f.pos))?.type.name===p.node?f.pos:null};for(let p of s.sort((f,h)=>h.from-f.from)){let f=a(p);f!==null&&Gv(o,f)}let c=({s:p,op:f},h)=>{let m=a(p);if(m===null)return!0;if(f==="join"){let k=m-((p.depth??1)-1);if(!ct(o.doc,k))return!1;try{o.join(k,p.depth??1)}catch{return!1}return!0}if(f==="style")return!h&&!Yv(o.doc,m,p)?!1:(Jv(o,{...p,from:m},"reject"),!0);if(Ca(new Et(o.doc),m)===null)return!1;o.setNodeAttribute(m,"suggestion",null);let g=m;for(let k=0;k<(p.depth??1)&&g!==null;k++){let x=Ca(o,g);g=x===null?null:Nh(o.doc,x)}return!0},u={join:0,style:1,lift:2},d=l.sort((p,f)=>u[p.op]-u[f.op]||f.s.from-p.s.from);for(let p=0;p>=0;)p=d.findIndex(f=>c(f,!1)),p>=0&&d.splice(p,1);for(let p of d)if(p.op==="style")c(p,!0);else{let f=a(p.s);f!==null&&o.setNodeAttribute(f,"suggestion",null)}return o}function Yv(n,e,t){let r=n.nodeAt(e),o=t.before?n.type.schema.nodes[t.before.type]:void 0;if(!r||!o)return!1;let i=n.resolve(e);return i.parent.canReplaceWith(i.index(),i.index()+1,o)&&(r.isLeaf?o.isLeaf:!o.isLeaf&&o.validContent(r.content))}function Xv(n,e){return Ph(n.view.state,e).doc}function Rh(n){let e=[];return n.forEach(t=>{let r=t.marks.filter(i=>!i.type.name.startsWith("suggestion_"));if(t.isText){e.push(t.mark(r));return}let o=t.attrs.suggestion!=null?{...t.attrs,suggestion:null}:t.attrs;e.push(t.type.create(o,Rh(t.content),r))}),T.from(e)}var Eh=new WeakMap;function Aa(n){return er.getState(n)?.enabled??!1}function Dh(n,e){let{state:t,dispatch:r}=n.view;r(t.tr.setMeta(er,{enabled:e}).setMeta(ki,!0)),n.updateUI()}var Oa={name:"suggestions",toolbar:"suggestions reviewsuggestions suggestionspanel",marks:{suggestion_insert:kh("insert"),suggestion_delete:kh("delete"),suggestion_format:Fv()},nodeAttributes:{suggestion:Hv},prosemirrorPlugins:n=>{let e=n.options.pluginOptions?.suggestions??{},t=null;return[new z({key:er,state:{init:()=>({enabled:!!(e.enabled||e.force)}),apply(r,o){let i=r.getMeta(er);return i?{enabled:e.force?!0:i.enabled}:o}},props:{attributes:r=>er.getState(r)?.enabled?{class:"nova-suggesting"}:{},transformPasted:r=>new D(Rh(r.content),r.openStart,r.openEnd),decorations(r){if(t?.doc===r.doc)return t.set;let o=Oe(n,"suggestions",wa),i=new Intl.DateTimeFormat(n.options.language??"en",{dateStyle:"medium",timeStyle:"short"}),s=ae.create(r.doc,Na(r.doc).map(l=>(l.node?ge.node:ge.inline)(l.from,l.to,{title:(l.kind==="insert"||l.kind==="split"?o.inserted:l.kind==="delete"||l.kind==="join"?o.deleted:o.formatted).replace("{name}",l.author.name||o.guest)+(l.time?` \xB7 ${i.format(l.time)}`:""),class:l.node&&(l.kind==="insert"||l.kind==="delete")?`nova-sugg-${l.kind} nova-sugg-node`:`nova-sugg-${l.kind}`,style:`--nova-suggestion: ${Ah(l.author.id||l.author.name)}`})));return t={doc:r.doc,set:s},s}}}),Ke({"Mod-Alt-Shift-e":()=>e.force?!1:(Dh(n,!Aa(n.view.state)),!0)})]},transformTransaction(n,e,t){if(!Aa(e))return n;let r=t.options.pluginOptions?.suggestions??{},o=Oe(t,"suggestions",wa),i={id:nr.test(r.author?.id??"")?r.author.id:"guest",name:String(r.author?.name||o.guest).slice(0,80)};return Lh(n,e,i,()=>{let s=Date.now();s-(Eh.get(t)??0)<3e3||(Eh.set(t,s),t.ui.notify(r.force?o.unsupported:o.unsupportedDirect))})},load:()=>import(__novaChunk("tinymce-chunks/suggestions-ui-c5f6bad4.js") )};var Wa={};q(Wa,{default:()=>ja,embedResolvers:()=>Mx,parseMediaUrl:()=>Ai});var qa={};q(qa,{ALIGNMENTS:()=>Yr,BULLET_STYLES:()=>_a,CELL_VALIGN:()=>Ba,IMAGE_ALIGN_STYLES:()=>Ha,INDENT_STEP:()=>$a,MAX_INDENT:()=>jh,ORDERED_STYLES:()=>Ia,classAttr:()=>Xe,createSchema:()=>Ci,cssValue:()=>Y,imageSize:()=>ne,indentLevel:()=>or,preText:()=>Uh,schema:()=>Lt,tableStyle:()=>Wh});function Zv(n,e){if(typeof n=="string")return{};let t=n.getAttribute("data-colwidth"),r=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(s=>Number(s)):null,o=Number(n.getAttribute("colspan")||1),i={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:r&&r.length===o?r:null};for(let[s,l]of Object.entries(e)){let a=l.getFromDOM?.(n);a!=null&&(i[s]=a)}return i}function Qv(n,e){let t={};n.attrs.colspan!==1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!==1&&(t.rowspan=n.attrs.rowspan),Array.isArray(n.attrs.colwidth)&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(let[r,o]of Object.entries(e))o.setDOMAttr?.(n.attrs[r],t);return t}function ex(n){if(n!==null&&(!Array.isArray(n)||n.some(e=>typeof e!="number")))throw new TypeError("colwidth must be null or an array of numbers")}function _h(n){let e=n.cellAttributes,t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:ex}};for(let[o,i]of Object.entries(e))t[o]={default:i.default};let r=(o,i)=>({content:n.cellContent,attrs:t,tableRole:i,isolating:!0,parseDOM:[{tag:o,getAttrs:s=>Zv(s,e)}],toDOM:s=>[o,Qv(s,e),0]});return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM:()=>["table",["tbody",0]]},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:()=>["tr",0]},table_cell:r("td","cell"),table_header:r("th","header_cell")}}function Gt(n){let{$head:e}=n.selection;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole==="row")return!0;return!1}var Pa={};q(Pa,{isSafeImageUrl:()=>fe,isSafeLinkUrl:()=>Ie});var tx=new Set(["http:","https:","mailto:","tel:"]),nx=new Set(["http:","https:","blob:"]),rx=/^data:image\/(png|jpe?g|gif|webp|avif|bmp);base64,/i;function Ih(n){if(typeof n!="string")return null;let t=n.replace(/[\u0000- \u007f-\u009f]/g,"").match(/^([a-z][a-z0-9+.-]*):/i);return t?`${t[1].toLowerCase()}:`:null}function Ie(n){if(typeof n!="string")return!1;let e=Ih(n);return e===null||tx.has(e)}function fe(n){if(typeof n!="string")return!1;if(rx.test(n.trim()))return!0;let e=Ih(n);return e===null||nx.has(e)}var Ra={};q(Ra,{codeLanguage:()=>vn});function vn(n){return typeof n=="string"&&/^[A-Za-z0-9_+#.-]{1,32}$/.test(n)?n:null}var Da={};q(Da,{DEFAULT_CONTENT_LANGS:()=>Hh,contentLanguages:()=>Si,getTextLanguage:()=>Mi,languageName:()=>wi,languageTag:()=>Fe,primaryLanguage:()=>xi,setTextLanguage:()=>rr});var Hh=["ar","de","el","en","es","fr","he","hi","it","ja","ko","la","nl","pl","pt","ru","sv","tr","uk","zh"],ox=/^[A-Za-z]{2,8}(?:-[A-Za-z0-9]{1,8})*$/;function Fe(n){if(typeof n!="string")return null;let e=n.trim();if(e.length>35||!ox.test(e))return null;try{return Intl.getCanonicalLocales(e)[0]??null}catch{return null}}var xi=n=>n.split("-")[0].toLowerCase();function wi(n,e="en"){try{return new Intl.DisplayNames([e,"en"],{type:"language"}).of(n)??n}catch{return n}}function Si(n,e="en"){let t=n??Hh.map(o=>({code:o})),r=[];for(let o of t){let i=Fe(o?.code);if(!i||r.some(l=>l.code===i))continue;let s=typeof o.title=="string"&&o.title.trim()?o.title.trim():wi(i,e);r.push({code:i,title:s})}return n||r.sort((o,i)=>o.title.localeCompare(i.title,e)),r}function Mi(n){let e=n.schema.marks.language;if(!e)return null;let{$from:t,empty:r}=n.selection,o=r?n.storedMarks??t.marks():t.nodeAfter?.marks??t.marks();return Fe(e.isInSet(o)?.attrs.lang)}function rr(n){return(e,t)=>{let r=e.schema.marks.language,o=n===null?null:Fe(n);if(!r||n!==null&&!o)return!1;let{selection:i}=e,s=!1;if(i.empty)s=i.$from.parent.type.allowsMarkType(r);else for(let{$from:a,$to:c}of i.ranges)e.doc.nodesBetween(a.pos,c.pos,(u,d,p)=>s?!1:(u.isInline&&p?.type.allowsMarkType(r)&&(s=!0),!0));if(!s)return!1;if(!t)return!0;let l=e.tr;if(i.empty)l.removeStoredMark(r),o&&l.addStoredMark(r.create({lang:o}));else for(let{$from:a,$to:c}of i.ranges)l.removeMark(a.pos,c.pos,r),o&&l.addMark(a.pos,c.pos,r.create({lang:o}));return t(l.scrollIntoView()),!0}}var Yr=["left","center","right","justify"],ix=/^(#[0-9a-f]{3,8}|rgba?\(\s*[\d.]+%?\s*,\s*[\d.]+%?\s*,\s*[\d.]+%?\s*(,\s*[\d.]+%?\s*)?\)|[a-z]{3,20})$/i,sx=/^\d{1,4}(\.\d{1,3})?(px|pt|em|rem|%)$/,lx=/^\d{1,2}(\.\d{1,3})?(px|em|%)?$/,ax=/^[\w\s,'"-]{1,200}$/;function cx(n){let e=n.trim().toLowerCase(),t=e.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(1|1\.0+)\s*)?\)$/);if(t)return"#"+t.slice(1,4).map(o=>Math.min(255,Number(o)).toString(16).padStart(2,"0")).join("");let r=e.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);return r?`#${r[1]}${r[1]}${r[2]}${r[2]}${r[3]}${r[3]}`:e}var Y={color:n=>typeof n=="string"&&ix.test(n.trim())&&!/^(inherit|initial|unset|currentcolor|transparent|windowtext|window|auto|none)$/i.test(n.trim())?cx(n):null,length:n=>typeof n=="string"&&sx.test(n.trim())?n.trim():null,lineHeight:n=>typeof n=="string"&&lx.test(n.trim())&&n.trim()!=="normal"?n.trim():null,fontFamily:n=>typeof n=="string"&&ax.test(n.trim())?n.trim():null},$a=40,jh=10;function or(n){let e=Math.trunc(Number(n));return Number.isFinite(e)?Math.min(jh,Math.max(0,e)):0}var ux=/^(\d+(?:\.\d+)?)(px|pt|em|rem)$/,dx={px:1,pt:4/3,em:16,rem:16};function px(n,e){if(n.parentElement?.tagName==="LI")return 0;let t=n.style,r=e==="rtl"?t.marginRight||t.paddingRight:t.marginLeft||t.paddingLeft,o=ux.exec(r?.trim()??"");return o?or(Math.round(Number(o[1])*dx[o[2]]/$a)):0}function fx(n){let e=n.getAttribute("dir")?.toLowerCase();return e==="rtl"||e==="ltr"?e:null}function Bh(n,e=!1){let t=n.style.textAlign,r=fx(n);return{align:Yr.includes(t)?t:null,lineHeight:Y.lineHeight(n.style.lineHeight),dir:r,indent:px(n,r??(e?"rtl":null))}}function Fh(n,e=!1){let t={};(n.dir==="rtl"||n.dir==="ltr")&&(t.dir=n.dir);let r=n.dir==="rtl"||e&&n.dir!=="ltr",o=[],i=n.align;i&&Yr.includes(i)&&o.push(`text-align: ${i};`);let s=Y.lineHeight(n.lineHeight);s&&o.push(`line-height: ${s};`);let l=or(n.indent);return l&&o.push(`margin-${r?"right":"left"}: ${l*$a}px;`),o.length&&(t.style=o.join(" ")),t}var zh={align:{default:null},lineHeight:{default:null},dir:{default:null},indent:{default:0}},_a=["disc","circle","square"],Ia=["decimal","lower-alpha","upper-alpha","lower-roman","upper-roman","lower-greek"],hx={1:"decimal",a:"lower-alpha",A:"upper-alpha",i:"lower-roman",I:"upper-roman"};function $h(n,e,t){let r=n.style.listStyleType.toLowerCase(),o=hx[n.getAttribute("type")??""]??"",i=e.includes(r)?r:e.includes(o)?o:null;return i===t?null:i}function Vh(n,e){return typeof n=="string"&&e.includes(n)?{style:`list-style-type: ${n};`}:{}}var Ha={left:"float: left; margin: 0 1em 1em 0;",right:"float: right; margin: 0 0 1em 1em;",center:"display: block; margin-left: auto; margin-right: auto;"};function qh(n){let e=n.style.float||n.getAttribute("align");return e==="left"||e==="right"?e:n.style.display==="block"&&n.style.marginLeft==="auto"&&n.style.marginRight==="auto"?"center":null}function ne(n){if(n==null||n==="")return null;let e=String(n).trim().match(/^(\d{1,5})(px)?$/);if(!e)return null;let t=Number(e[1]);return t>=1&&t<=1e4?t:null}var Ba=["top","middle","bottom"];function Wh(n){let e=[],t=Y.length(n.width);return t&&e.push(`width: ${t};`),n.align==="center"?e.push("margin-left: auto; margin-right: auto;"):n.align==="right"&&e.push("margin-left: auto;"),e.join(" ")}var mx=100;function gx(n){let e=_h({tableGroup:"block",cellContent:"block+",cellAttributes:{class:{default:null,getFromDOM:t=>Yt(t,n),setDOMAttr:(t,r)=>{let o=Xe(t).class;o&&(r.class=o)}},background:{default:null,getFromDOM:t=>Y.color(t.getAttribute("data-nova-cell-bg")??t.style?.backgroundColor),setDOMAttr:(t,r)=>{let o=Y.color(t);o&&(r.style=`${r.style??""}background-color: ${o};`)}},valign:{default:null,getFromDOM:t=>{let r=t,o=(r.style.verticalAlign||r.getAttribute("valign")||"").toLowerCase();return Ba.includes(o)?o:null},setDOMAttr:(t,r)=>{Ba.includes(t)&&(r.style=`${r.style??""}vertical-align: ${t};`)}}}});e.table.attrs={width:{default:null},align:{default:null},class:{default:null}},e.table.parseDOM=[{tag:"table",getAttrs:t=>{let r=t,o=Y.length(r.style.width)??Y.length(`${r.getAttribute("width")??""}px`),i=l=>l==="auto",s=r.getAttribute("align")==="center"||i(r.style.marginLeft)&&i(r.style.marginRight)?"center":r.getAttribute("align")==="right"||i(r.style.marginLeft)?"right":null;return{width:o,align:s,class:Yt(r,n)}}}],e.table.toDOM=t=>{let r=Wh(t.attrs);return["table",{...Xe(t.attrs.class),...r?{style:r}:{}},["tbody",0]]};for(let t of["table_cell","table_header"]){let r=e[t],o=r.parseDOM[0],i=o.getAttrs;o.getAttrs=l=>{let a=i(l);if(!a)return a;let c=u=>Math.min(mx,Math.max(1,Number.isFinite(u)?Math.floor(u):1));return{...a,colspan:c(a.colspan),rowspan:c(a.rowspan)}};let s=r.toDOM;r.toDOM=l=>{let a=s(l),c=l.attrs.colwidth;if(c?.every(u=>u>0)){let u=c.reduce((p,f)=>p+f,0),d=a[1].style?` ${a[1].style}`:"";a[1]={...a[1],style:`width: ${u}px;${d}`}}return a}}return e}var Va=()=>!1,Kh=/^-?[_a-zA-Z][\w-]*$/,yx=/(?:^|\s)lang(?:uage)?-(\S+)/;function bx(n){for(let e of[n.querySelector("code"),n]){if(!e)continue;let t=vn(yx.exec(e.getAttribute("class")??"")?.[1])??vn(e.getAttribute("data-language"));if(t)return t}return null}var kx=/^(?:P|DIV|H[1-6]|LI|UL|OL|DL|DT|DD|TABLE|TR|BLOCKQUOTE|PRE|SECTION|ARTICLE|HEADER|FOOTER)$/;function Uh(n){let e="",t=!1,r=i=>{i&&(t&&(e+=`
12
12
  `),t=!1,e+=i)},o=i=>{for(let s of i.childNodes)if(s.nodeType===3)r(s.data);else if(s.nodeType===1){let l=s.tagName;l==="BR"?(t=!1,e+=`
13
- `):sx.test(l)?(e&&(t||!e.endsWith(`
13
+ `):kx.test(l)?(e&&(t||!e.endsWith(`
14
14
  `))&&(e+=`
15
- `),t=!1,o(s),t=!0):o(s)}};return o(n),e}function Bh(n){return n.getAttribute("data-type")==="taskList"||n.classList.contains("tox-checklist")||n.classList.contains("contains-task-list")}function lx(n){let e=n.parentElement;if(!e||!Bh(e))return null;let t=n.getAttribute("data-checked");if(t==="true"||t==="false")return t==="true";if(n.classList.contains("tox-checklist--checked"))return!0;let r=[...n.querySelectorAll('input[type="checkbox"]')].find(o=>o.closest("li")===n);return r?r.hasAttribute("checked"):!1}function ax(n){let e=Math.trunc(Number(n));return e>=1&&e<=6?e:1}function Gt(n,e){let t=[...n.classList].filter(r=>Ih.test(r)&&e(r));return t.length?t.join(" "):null}function Ye(n){if(typeof n!="string")return{};let e=n.split(/\s+/).filter(t=>Ih.test(t));return e.length?{class:e.join(" ")}:{}}var Kr={class:{default:null}},Fh=(n,e=!1)=>({doc:{content:"block+"},paragraph:{group:"block",content:"inline*",attrs:{...Oh,...Kr},parseDOM:[{tag:"p",getAttrs:t=>({...Th(t,e),class:Gt(t,n)})}],toDOM:t=>["p",{...Ye(t.attrs.class),...Nh(t.attrs,e)},0]},heading:{group:"block",content:"inline*",defining:!0,attrs:{level:{default:1},id:{default:null},...Oh,...Kr},parseDOM:[1,2,3,4,5,6].map(t=>({tag:`h${t}`,getAttrs:r=>({level:t,id:$n(r.getAttribute("id")),...Th(r,e),class:Gt(r,n)})})),toDOM:t=>[`h${ax(t.attrs.level)}`,{...$n(t.attrs.id)?{id:t.attrs.id}:{},...Ye(t.attrs.class),...Nh(t.attrs,e)},0]},blockquote:{group:"block",content:"block+",defining:!0,attrs:{...Kr},parseDOM:[{tag:"blockquote",getAttrs:t=>({class:Gt(t,n)})}],toDOM:t=>["blockquote",Ye(t.attrs.class),0]},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>["hr"]},code_block:{group:"block",content:"text*",marks:"",code:!0,defining:!0,attrs:{language:{default:null}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:t=>({language:ix(t)}),getContent:(t,r)=>{let o=Hh(t);return o?N.from(r.text(o)):N.empty}}],toDOM:t=>{let r=kn(t.attrs.language);return["pre",["code",r?{class:`language-${r}`}:{},0]]}},bullet_list:{group:"block",content:"list_item+",attrs:{listStyle:{default:null},checklist:{default:!1}},parseDOM:[{tag:"ul",getAttrs:t=>{let r=Bh(t);return{listStyle:r?null:Lh(t,Ta,"disc"),checklist:r}}}],toDOM:t=>t.attrs.checklist===!0?["ul",{"data-type":"taskList"},0]:["ul",Ph(t.attrs.listStyle,Ta),0]},ordered_list:{group:"block",content:"list_item+",attrs:{start:{default:1},listStyle:{default:null}},parseDOM:[{tag:"ol",getAttrs:t=>{let r=t.getAttribute("start");return{start:r?Number(r):1,listStyle:Lh(t,Na,"decimal")}}}],toDOM:t=>["ol",{...t.attrs.start===1?{}:{start:t.attrs.start},...Ph(t.attrs.listStyle,Na)},0]},list_item:{content:"paragraph block*",defining:!0,attrs:{checked:{default:null}},parseDOM:[{tag:"li",getAttrs:t=>({checked:lx(t)})}],toDOM:t=>typeof t.attrs.checked=="boolean"?["li",{"data-type":"taskItem","data-checked":String(t.attrs.checked)},0]:["li",0]},text:{group:"inline"},figure:{group:"block",content:"figure_image figcaption",draggable:!0,isolating:!0,attrs:{align:{default:null},...Kr},parseDOM:[{tag:"figure",getAttrs:t=>{let r=t,o=r.querySelector("img");return!o||!fe(o.getAttribute("src")??"")?!1:{align:Rh(r),class:Gt(r,n)}}}],toDOM:t=>{let r=ne(t.firstChild?.attrs.width),o=Oa[t.attrs.align]??"",i=`${o}${r?`${o?" ":""}width: ${r}px;`:""}`;return["figure",{...Ye(t.attrs.class),...i?{style:i}:{}},0]}},figure_image:{atom:!0,selectable:!1,attrs:{src:{default:""},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}},parseDOM:[{tag:"img[src]",context:"figure/",priority:60,getAttrs:t=>{let r=t;return fe(r.getAttribute("src")??"")?{src:r.getAttribute("src"),alt:r.getAttribute("alt"),title:r.getAttribute("title"),width:ne(r.getAttribute("width")??r.style.width),height:ne(r.getAttribute("height")??r.style.height)}:!1}}],toDOM:t=>{let{alt:r,title:o}=t.attrs,i=fe(t.attrs.src)?t.attrs.src:"",s=ne(t.attrs.width),l=ne(t.attrs.height);return["img",{src:i,...r==null?{}:{alt:String(r)},...o?{title:o}:{},...s?{width:String(s)}:{},...l?{height:String(l)}:{}}]}},figcaption:{content:"inline*",parseDOM:[{tag:"figcaption",context:"figure/"}],toDOM:()=>["figcaption",0]},image:{group:"inline",inline:!0,draggable:!0,attrs:{src:{},alt:{default:null},title:{default:null},width:{default:null},height:{default:null},align:{default:null},...Kr},parseDOM:[{tag:"img[src]",getAttrs:t=>{let r=t;return fe(r.getAttribute("src")??"")?{src:r.getAttribute("src"),alt:r.getAttribute("alt"),title:r.getAttribute("title"),width:ne(r.getAttribute("width")??r.style.width),height:ne(r.getAttribute("height")??r.style.height),align:Rh(r),class:Gt(r,n)}:!1}}],toDOM:t=>{let{alt:r,title:o}=t.attrs,i=fe(t.attrs.src)?t.attrs.src:"",s=ne(t.attrs.width),l=ne(t.attrs.height),a=Oa[t.attrs.align];return["img",{src:i,...Ye(t.attrs.class),...r==null?{}:{alt:String(r)},...o?{title:o}:{},...s?{width:String(s)}:{},...l?{height:String(l)}:{},...a?{style:a}:{}}]}},hard_break:{group:"inline",inline:!0,selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>["br"]},...rx(n)}),Pa=Fh(_a),zh=n=>({link:{attrs:{href:{},title:{default:null},target:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:e=>{let t=e;return Ie(t.getAttribute("href")??"")?{href:t.getAttribute("href"),title:t.getAttribute("title"),target:t.getAttribute("target")}:!1}}],toDOM:e=>{let{title:t,target:r}=e.attrs;return["a",{href:Ie(e.attrs.href)?e.attrs.href:"#",...t?{title:t}:{},...r?{target:r,rel:"noopener noreferrer"}:{}},0]}},bold:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:e=>e.style?.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:()=>["strong",0]},italic:{parseDOM:[{tag:"em"},{tag:"i"},{style:"font-style=italic"}],toDOM:()=>["em",0]},underline:{parseDOM:[{tag:"u"},{style:"text-decoration=underline"}],toDOM:()=>["u",0]},strike:{parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration=line-through"}],toDOM:()=>["s",0]},code:{code:!0,parseDOM:[{tag:"code"}],toDOM:()=>["code",0]},subscript:{excludes:"superscript",parseDOM:[{tag:"sub"},{style:"vertical-align=sub"}],toDOM:()=>["sub",0]},superscript:{excludes:"subscript",parseDOM:[{tag:"sup"},{style:"vertical-align=super"}],toDOM:()=>["sup",0]},color:{attrs:{value:{}},parseDOM:[{style:"color",getAttrs:e=>Ur(Y.color(e))},{tag:"font[color]",getAttrs:e=>Ur(Y.color(e.getAttribute("color")))}],toDOM:e=>ki("color",Y.color(e.attrs.value))},background:{attrs:{value:{}},parseDOM:[{style:"background-color",getAttrs:e=>Ur(Y.color(e))},{tag:"mark",getAttrs:()=>({value:"yellow"})}],toDOM:e=>ki("background-color",Y.color(e.attrs.value))},font_family:{attrs:{value:{}},parseDOM:[{style:"font-family",getAttrs:e=>Ur(Y.fontFamily(e))}],toDOM:e=>ki("font-family",Y.fontFamily(e.attrs.value))},font_size:{attrs:{value:{}},parseDOM:[{style:"font-size",getAttrs:e=>Ur(Y.length(e))}],toDOM:e=>ki("font-size",Y.length(e.attrs.value))},span_class:{attrs:{class:{}},parseDOM:[{tag:"span[class]",consuming:!1,getAttrs:e=>{let t=Gt(e,n);return t?{class:t}:!1}}],toDOM:e=>["span",Ye(e.attrs.class),0]}}),Ra=zh(_a);function Ur(n){return n?{value:n}:!1}function ki(n,e){return e?["span",{style:`${n}: ${e};`},0]:["span",0]}var Ot=new Rn({nodes:Pa,marks:Ra});function cx(n,e,t){let r=t.toDOM;return{...t,attrs:{...t.attrs,[n]:{default:e.default}},parseDOM:t.parseDOM?.map(o=>{if(!o.tag)return o;let i=o.getAttrs;return{...o,getAttrs:s=>{let l=i?i(s):o.attrs??null;if(l===!1)return!1;let a=e.parse(s);return a==null?l:{...l,[n]:a}}}}),...r?{toDOM:o=>{let i=r(o),s=e.render(o.attrs[n]);if(!Array.isArray(i)||typeof i[0]!="string"||!Object.keys(s).length)return i;let l=i[1],a=!!l&&typeof l=="object"&&!Array.isArray(l)&&l.nodeType===void 0;return[i[0],{...a?l:{},...s},...i.slice(a?2:1)]}}:{}}}var dx=n=>/\b(inline|text)\b/.test(n.content??"");function vi(n={},e,t,r="ltr"){let o=r==="rtl",i=Object.entries(n.nodes??{}),s=Object.entries(n.marks??{}),l=Object.entries(n.attributes??{});if(!i.length&&!s.length&&!l.length&&!e&&!t&&!o)return Ot;let a=e||o?Fh(e??_a,o):Pa,c=e?zh(e):Ra,d={};t&&({nodes:a,marks:c}=t.apply({nodes:a,marks:c},d));for(let[f]of i)if(f in Pa)throw new Error(`[nova] node "${f}" already exists in the base schema`);for(let[f]of s)if(f in Ra)throw new Error(`[nova] mark "${f}" already exists in the base schema`);let u={...a,...Object.fromEntries(i)},p=(f,h,m)=>f.nodes==="all"?h!=="doc"&&h!=="text":f.nodes==="textblock"?dx(m):f.nodes.includes(h);for(let[f,h]of l)u=Object.fromEntries(Object.entries(u).map(([m,g])=>[m,p(h,m,g)&&!g.attrs?.[f]?cx(f,h,g):g]));return d.schema=new Rn({nodes:u,marks:{...c,...Object.fromEntries(s)}}),d.schema}var ux=new WeakMap,px=/^https?:\/\/(?:www\.|m\.)?(?:youtube(?:-nocookie)?\.com\/(?:watch\?(?:[^#]*&)?v=|embed\/|shorts\/|live\/)|youtu\.be\/)([\w-]{11})(?:[?&#]|$)/i,fx=/^https?:\/\/(?:www\.|player\.)?vimeo\.com\/(?:video\/)?(\d{1,12})(?:[/?#]|$)/i,hx=/^https:\/\/[^\s"'<>]+\.(?:mp4|webm|ogv|ogg)(?:\?[^\s"'<>#]*)?$/i;function xi(n){if(typeof n!="string")return null;let e=n.trim(),t=e.match(px);if(t)return{kind:"youtube",src:`https://www.youtube-nocookie.com/embed/${t[1]}`};let r=e.match(fx);return r?{kind:"vimeo",src:`https://player.vimeo.com/video/${r[1]}`}:hx.test(e)?{kind:"video",src:e}:null}function $h(n,e){let t=e?xi(e):null;return t?{...t,width:ne(n.getAttribute("width"))??560,height:ne(n.getAttribute("height"))??315,title:n.getAttribute("title")??""}:!1}function mx(n){let e=xi(n.attrs.src);if(!e)return null;let t=String(ne(n.attrs.width)??560),r=String(ne(n.attrs.height)??315);return e.kind==="video"?w("video",{src:e.src,controls:!0,width:t,height:r,preload:"metadata"}):w("iframe",{src:e.src,width:t,height:r,title:n.attrs.title||"Video",allow:"accelerometer; encrypted-media; gyroscope; picture-in-picture; fullscreen",allowfullscreen:!0,loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin"})}var Ha={name:"media",toolbar:"media",nodes:{media:{group:"block",atom:!0,selectable:!0,draggable:!0,attrs:{kind:{default:"youtube"},src:{},width:{default:560},height:{default:315},title:{default:""}},parseDOM:[{tag:"iframe[src]",getAttrs:n=>$h(n,n.getAttribute("src"))},{tag:"video",getAttrs:n=>{let e=n,t=e.getAttribute("src")??e.querySelector("source[src]")?.getAttribute("src")??null;return $h(e,t)}}],toDOM:n=>{let e=xi(n.attrs.src),t=String(ne(n.attrs.width)??560),r=String(ne(n.attrs.height)??315);return e?e.kind==="video"?["video",{src:e.src,controls:"",width:t,height:r}]:["iframe",{src:e.src,width:t,height:r,title:n.attrs.title||null,allow:"accelerometer; encrypted-media; gyroscope; picture-in-picture; fullscreen",allowfullscreen:"",loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin"}]:["p"]}}},prosemirrorPlugins:()=>[new z({props:{nodeViews:{media:n=>{let e=mx(n);return{dom:w("div",{className:"nova-media",contenteditable:"false"},e,w("div",{className:"nova-media-overlay","aria-hidden":"true"})),ignoreMutation:()=>!0,stopEvent:()=>!1}}}}})],load:()=>import(__novaChunk("tinymce-chunks/media-ui-de819f11.js") )};var $a={};j($a,{DEFAULT_SANDBOX:()=>qh,FIXED:()=>Lt,default:()=>za,embeddableUrl:()=>wi,pageEmbedOptions:()=>Fa,ratioOf:()=>Gr});var qh="allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation",gx=["21by9","16by9","4by3","1by1"].map(n=>({value:`nova-pageembed--${n}`})),Lt={width:350,height:260},Vh=/^[\w-]{1,60}$/,yx=/--(\d{1,3})by(\d{1,3})$/;function Fa(n){let e=n.options.pluginOptions?.pageembed??{},t=Array.isArray(e.sizes)?e.sizes.filter(o=>!!o&&typeof o.value=="string"&&Vh.test(o.value)):gx,r=e.sandbox===!1?!1:typeof e.sandbox=="string"?e.sandbox.split(/\s+/).filter(o=>/^allow-[a-z-]{1,40}$/.test(o)).join(" "):qh;return{sizes:t,inlineStyles:e.inlineStyles!==!1,className:typeof e.className=="string"&&Vh.test(e.className)?e.className:"nova-pageembed",sandbox:r,allowUrl:typeof e.allowUrl=="function"?e.allowUrl:void 0}}function Gr(n){let e=yx.exec(n);if(!e)return null;let t=Number(e[1]),r=Number(e[2]);return t>0&&r>0?[t,r]:null}function wi(n,e){if(typeof n!="string")return null;let t=n.trim();if(t.length>2e3||!/^https?:\/\/[^\s/?#]/i.test(t))return null;let r;try{r=new URL(t)}catch{return null}if(r.protocol!=="http:"&&r.protocol!=="https:"||r.username||r.password)return null;try{if(e&&!e(r.href))return null}catch{return null}return t}function jh(n,e){if(typeof n=="string"&&n.trim())return n.trim().slice(0,300);try{return new URL(e).hostname}catch{return e}}function Wh(n,e){return typeof n=="string"&&e.sizes.some(t=>t.value===n)?n:""}function bx(n,e){let t=n.find(r=>e.sizes.some(o=>o.value===r));if(t)return t;for(let r of n){let o=/^(?:nova|tiny)-pageembed--/.test(r)?Gr(r):null;if(!o)continue;let i=e.sizes.find(s=>{let l=Gr(s.value);return!!l&&l[0]*o[1]===l[1]*o[0]});if(i)return i.value}return""}function kx(n,e){return n.some(t=>t===e.className||/^(?:nova|tiny)-pageembed(?:--[\w-]+)?$/.test(t)||e.sizes.some(r=>r.value===t))}function Kh(n,e,t){return{src:e,title:jh(n.attrs.title,e),sandbox:t.sandbox===!1?null:t.sandbox,allow:"fullscreen",allowfullscreen:"",loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin",frameborder:n.attrs.border===!0?"1":"0",scrolling:n.attrs.scrolling===!1?"no":null}}function vx(n){let e=Fa(n);return{pageembed:{group:"block",atom:!0,selectable:!0,draggable:!0,attrs:{src:{default:""},size:{default:""},width:{default:Lt.width},height:{default:Lt.height},title:{default:""},border:{default:!1},scrolling:{default:!0}},parseDOM:[{tag:"div",priority:70,getAttrs:t=>{let r=t,o=[...r.classList];if(!kx(o,e))return!1;let i=r.querySelector("iframe"),s=wi(i?.getAttribute("src"),e.allowUrl);if(!i||!s)return!1;let l=i.getAttribute("frameborder");return{src:s,size:bx(o,e),width:ne(i.getAttribute("width"))??Lt.width,height:ne(i.getAttribute("height"))??Lt.height,title:(i.getAttribute("title")??"").trim().slice(0,300),border:l!==null&&l!=="0"&&l.toLowerCase()!=="no",scrolling:i.getAttribute("scrolling")?.toLowerCase()!=="no"}}}],toDOM:t=>{let r=wi(t.attrs.src,e.allowUrl);if(!r)return["div",{class:e.className}];let o=Kh(t,r,e),i=Wh(t.attrs.size,e);if(!i)return o.width=String(ne(t.attrs.width)??Lt.width),o.height=String(ne(t.attrs.height)??Lt.height),["div",{class:e.className},["iframe",o]];let s=e.inlineStyles?Gr(i):null;if(s){let l=Math.round(s[1]/s[0]*1e6)/1e4;return o.style=`position: absolute; top: 0; left: 0; width: 100%; height: 100%${t.attrs.border===!0?"":"; border: 0"}`,["div",{class:`${e.className} ${i}`,style:`position: relative; width: 100%; padding-top: ${l}%; overflow: hidden`},["iframe",o]]}return["div",{class:`${e.className} ${i}`},["iframe",o]]}}}}function xx(n,e){let t=w("div",{className:"nova-media nova-pageembed-view",contenteditable:"false"}),r=w("div",{className:"nova-media-overlay","aria-hidden":"true"}),o=null,i=null,s=l=>{let a=wi(l.attrs.src,e.allowUrl),c=Wh(l.attrs.size,e),d=c?Gr(c):null;if(t.classList.toggle("is-responsive",!!c),t.classList.toggle("has-border",l.attrs.border===!0),!a){o?.remove(),o=null,i=null,t.replaceChildren(w("div",{className:"nova-pageembed-missing"},typeof l.attrs.src=="string"?l.attrs.src:""),r);return}if(!o||i!==a){let u=Kh(l,a,e);o=w("iframe",{src:a,title:u.title,...u.sandbox===null?{}:{sandbox:u.sandbox},allow:"fullscreen",loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin",tabindex:"-1"}),i=a,t.replaceChildren(o,r)}o.title=jh(l.attrs.title,a),l.attrs.scrolling===!1?o.setAttribute("scrolling","no"):o.removeAttribute("scrolling"),c?(o.removeAttribute("width"),o.removeAttribute("height"),o.style.aspectRatio=d?`${d[0]} / ${d[1]}`:"16 / 9"):(o.style.aspectRatio="",o.setAttribute("width",String(ne(l.attrs.width)??Lt.width)),o.setAttribute("height",String(ne(l.attrs.height)??Lt.height)))};return s(n),{dom:t,update(l){return l.type!==n.type?!1:(n=l,s(l),!0)},ignoreMutation:()=>!0,stopEvent:()=>!1}}var za={name:"pageembed",toolbar:"pageembed",nodes:vx,prosemirrorPlugins:n=>{let e=Fa(n);return[new z({props:{nodeViews:{pageembed:t=>xx(t,e)}}})]},load:()=>import(__novaChunk("tinymce-chunks/pageembed-ui-da39f1ee.js") )};var ja={};j(ja,{default:()=>qa,seriesName:()=>Va});var wx=/^[a-z][\w-]{0,39}$/i;function Va(n){return typeof n=="string"&&wx.test(n)?n:null}var Sx={nodes:["table_cell","table_header"],default:null,parse:n=>Va(n.getAttribute("data-series")),render:n=>{let e=Va(n);return e?{"data-series":e}:{}}},qa={name:"advtable",nodeAttributes:{series:Sx},load:()=>import(__novaChunk("tinymce-chunks/advtable-ui-db2e667d.js") )};var Xa={};j(Xa,{cardFields:()=>Ga,cardHref:()=>Ua,cardImage:()=>Ja,cardText:()=>Pt,default:()=>Ya,hostOf:()=>Wa,mediaEmbedOptions:()=>Ka});var Mx=/^[\w-]{1,60}$/;function Ka(n){let e=n.options.pluginOptions?.mediaembed??{},t=Number(e.maxWidth);return{className:typeof e.className=="string"&&Mx.test(e.className)?e.className:"nova-card",inlineStyles:e.inlineStyles!==!1,maxWidth:Number.isFinite(t)&&t>=200?Math.min(2e3,Math.round(t)):650}}function Pt(n,e){return typeof n=="string"?n.replace(/\s+/g," ").trim().slice(0,e):""}function Ua(n){if(typeof n!="string")return null;let e=n.trim();return/^https?:\/\/[^\s/?#]/i.test(e)&&e.length<=2e3&&Ie(e)?e:null}function Ja(n){if(typeof n!="string")return null;let e=n.trim();return/^https?:\/\/[^\s/?#]/i.test(e)&&e.length<=2e3&&fe(e)?e:null}function Wa(n){try{return new URL(n).hostname.replace(/^www\./,"")}catch{return""}}function Ga(n){let e=Ua(n.href);return{href:e,title:Pt(n.title,300)||(e?Wa(e):""),description:Pt(n.description,500),image:Ja(n.image),site:Pt(n.site,100)||(e?Wa(e):""),author:Pt(n.author,100)}}function Ex(n){let e=Ka(n),t=[...new Set([e.className,"nova-card","ephox-summary-card"])],r=(o,i)=>o.querySelector(t.map(s=>`.${s}-${i}`).join(", "));return{link_card:{group:"block",atom:!0,selectable:!0,draggable:!0,attrs:{href:{default:""},title:{default:""},description:{default:""},image:{default:""},site:{default:""},author:{default:""}},parseDOM:[{tag:"a, div",priority:70,getAttrs:o=>{let i=o;if(!t.some(c=>i.classList.contains(c)))return!1;let s=Ua(i.getAttribute("href")??i.querySelector("a[href]")?.getAttribute("href"));if(!s)return!1;let l=r(i,"thumbnail"),a=l?.getAttribute("src")??l?.querySelector("img")?.getAttribute("src")??"";return{href:s,title:Pt(r(i,"title")?.textContent,300),description:Pt(r(i,"description")?.textContent,500),image:Ja(a)??"",site:Pt(r(i,"website")?.textContent,100),author:Pt(r(i,"author")?.textContent,100)}}}],toDOM:o=>Cx(o,e)}}}var vn=(n,e)=>n.inlineStyles?e:null;function Cx(n,e){let t=Ga(n.attrs),r=e.className;if(!t.href)return["div",{class:r},t.title];let o="display: block; opacity: 0.75; font-size: 0.875em",i=[["span",{class:`${r}-title`,style:vn(e,"display: block; font-weight: 600")},t.title]];return t.description&&i.push(["span",{class:`${r}-description`,style:vn(e,o)},t.description]),i.push(["span",{class:`${r}-website`,style:vn(e,o)},t.site]),t.author&&i.push(["span",{class:`${r}-author`,style:vn(e,o)},t.author]),["a",{class:r,href:t.href,rel:"noopener noreferrer",style:vn(e,`display: flex; flex-wrap: wrap; gap: 12px; max-width: ${e.maxWidth}px; margin: 0.5em 0; padding: 12px; border: 1px solid rgb(127 127 127 / 0.35); border-radius: 8px; color: inherit; text-decoration: none; overflow: hidden`)},...t.image?[["img",{class:`${r}-thumbnail`,src:t.image,alt:"",loading:"lazy",style:vn(e,"flex: none; width: 120px; height: 90px; object-fit: cover; border-radius: 4px")}]]:[],["span",{style:vn(e,"display: block; flex: 1 1 180px; min-width: 0")},...i]]}function Ax(n,e){let t=w("div",{className:"nova-card-view",contenteditable:"false"});t.style.maxWidth=`${e.maxWidth}px`;let r=o=>{let i=Ga(o.attrs);t.replaceChildren(...i.image?[w("img",{className:"nova-card-view-image",src:i.image,alt:""})]:[],w("div",{className:"nova-card-view-text"},w("div",{className:"nova-card-view-title"},i.title),i.description?w("div",{className:"nova-card-view-description"},i.description):null,w("div",{className:"nova-card-view-site"},[i.site,i.author].filter(Boolean).join(" \xB7 ")))),t.title=i.href??""};return r(n),{dom:t,update(o){return o.type!==n.type?!1:(n=o,r(o),!0)},ignoreMutation:()=>!0,stopEvent:()=>!1}}var Ya={name:"mediaembed",nodes:Ex,prosemirrorPlugins:n=>{let e=Ka(n);return[new z({props:{nodeViews:{link_card:t=>Ax(t,e)}}})]},load:()=>import(__novaChunk("tinymce-chunks/mediaembed-ui-7be11324.js") )};var oc={};j(oc,{bodyStyle:()=>tc,cleanPage:()=>nc,default:()=>rc,fullPageOptions:()=>Qh});var Qa={};j(Qa,{HTMLSerializer:()=>Xr,escapeAttr:()=>Zr,escapeText:()=>xn});var Tx=new Set(["href","xlink:href","action","formaction","cite"]),Nx=new Set(["src","poster","data","background"]),Ox=/url\s*\(|expression\s*\(|javascript:|@import|behavior\s*:|-moz-binding/i;function Yr(n,e){let t=n.toLowerCase();return t.startsWith("on")?null:Tx.has(t)?Ie(e)?e:null:Nx.has(t)?fe(e)?e:null:t==="srcset"?e.split(",").map(o=>o.trim().split(/\s+/)[0]??"").every(o=>fe(o))?e:null:t==="style"&&Ox.test(e)?null:e}var Lx=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Jh=new RegExp("\xA0","g");function xn(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(Jh,"&nbsp;")}var Px="\xA0";function Rx(n){let e=null,t=!0,r=n.childCount;for(let o=0;o<r;o++){let i=n.child(o);if(!i.isText){t=i.type.name==="hard_break"||!i.isInline;continue}let s=i.text??"";if(!s.includes(" ")){t=!1;continue}let l=o===r-1||!n.child(o+1).isInline,a="";for(let c=0;c<s.length;c++){let d=s[c];d!==" "?(a+=d,t=!1):t||l&&c===s.length-1?(a+=Px,t=!1):(a+=" ",t=!0)}a!==s&&(e??(e=new Map)).set(o,a)}return e}function Zr(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(Jh,"&nbsp;")}var Dx=/^[a-z][a-z0-9-]*$/i,_x=new Set(["script","style","base","link","meta","object","embed","applet","frame","frameset","template","noscript"]),Uh=new Set;function Ix(n){Uh.has(n)||(Uh.add(n),console.error(`[nova] toDOM produced <${n}>, which is not allowed in output; the tag was dropped`))}var Hx=/^[a-z_:][a-z0-9_.:-]*$/i;function Za(n){if(typeof n=="string")return{open:"",close:"",hole:!1,html:xn(n)};if(typeof n=="number"||typeof n=="boolean")return{open:"",close:"",hole:!1,html:xn(String(n))};if(n==null)return{open:"",close:"",hole:!1,html:""};if(!Array.isArray(n))throw new Error("[nova] serializer supports only array/string toDOM specs");let[e,...t]=n,r=e.includes(" ")?e.split(" ")[1]:e;if(!Dx.test(r))throw new Error(`[nova] invalid tag in toDOM: ${r}`);let o=_x.has(r.toLowerCase());o&&Ix(r.toLowerCase());let i="",s=t,l=t[0];if(l&&typeof l=="object"&&!Array.isArray(l)){for(let[f,h]of Object.entries(l)){if(h==null)continue;let m=f.includes(" ")?f.split(" ")[1]:f;if(!Hx.test(m))continue;let g=Yr(m,String(h));g!==null&&(i+=` ${m}="${Zr(g)}"`)}s=t.slice(1)}let a=o?"":`<${r}${i}>`;if(Lx.has(r.toLowerCase()))return{open:a,close:"",hole:!1,html:a};let c="",d="",u=!1;for(let f of s){if(f===0){if(u)throw new Error("[nova] toDOM spec has more than one content hole");u=!0;continue}let h=Za(f);if(u){if(h.hole)throw new Error("[nova] toDOM spec has more than one content hole");d+=h.html}else h.hole?(c+=h.open,d+=h.close,u=!0):c+=h.html}if(o)return{open:"",close:"",hole:u,html:""};let p=`</${r}>`;return{open:a+c,close:d+p,hole:u,html:a+c+d+p}}var Xr=class{constructor(){S(this,"cache",new WeakMap)}serializeFragment(e,{pre:t=!1}={}){let r=t?null:Rx(e),o="",i=[],s=[],l=a=>{for(;i.length>a;)o+=s.pop(),i.pop()};return e.forEach((a,c,d)=>{if(!a.isInline){l(0),o+=this.serializeNode(a);return}let u=0;for(;u<i.length&&u<a.marks.length&&i[u].eq(a.marks[u]);)u++;l(u);for(let p=u;p<a.marks.length;p++){let f=a.marks[p],h=this.renderMark(f,a.isText);o+=h.open,s.push(h.close),i.push(f)}o+=a.isText?xn(r?.get(d)??a.text??""):this.serializeNode(a)}),l(0),i=[],s=[],o}serializeNode(e){let t=e.type.spec.toDOM;if(!t)throw new Error(`[nova] node "${e.type.name}" has no toDOM`);let r=Za(t(e));if(!r.hole)return r.html;let o=!!e.type.spec.code||e.type.spec.whitespace==="pre";return r.open+this.serializeFragment(e.content,{pre:o})+r.close}renderMark(e,t){let r=e.type.spec.toDOM;if(!r)throw new Error(`[nova] mark "${e.type.name}" has no toDOM`);let o=this.cache.get(e.type);o||this.cache.set(e.type,o=new Map);let i=JSON.stringify(e.attrs),s=o.get(i);return s||(s=Za(r(e,t)),o.size>500&&o.clear(),o.set(i,s)),s}};var Bx=/^[a-z]{1,8}(?:-[a-z0-9]{1,8}){0,4}$/i,Gh=/^[\w.:-]{1,100}$/,Yh=/^<!doctype html(?:\s+(?:public|system)(?:\s+(?:"[^"<>]{0,300}"|'[^'<>]{0,300}')){1,2})?\s*>$/i,Fx=new Set(["content-type","content-language","x-ua-compatible","default-style"]),zx=new Set(["stylesheet","icon","shortcut","apple-touch-icon","canonical","alternate","author","license","next","prev"]),$x="<!DOCTYPE html>";function wn(n,e){return typeof n!="string"||n.length>e||/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/.test(n)?null:n.replace(/\r\n?/g,`
16
- `)}var Si=n=>Bx.test(n)?n:null,Xh=n=>["ltr","rtl","auto"].includes(n.toLowerCase())?n.toLowerCase():null,ec=n=>wn(n,300),Vx=n=>{let e=n.split(/\s+/).filter(Boolean);return e.length&&e.length<=20&&e.every(t=>/^[\w-]{1,60}$/.test(t))?e.join(" "):null},qx=n=>{let e=n.trim(),t=/^([a-z][a-z0-9+.-]*):/i.exec(e.replace(/[\u0000- ]/g,""))?.[1];return e&&e.length<=2e3&&(!t||/^https?$/i.test(t))?e:null},ft=n=>{let e=n.trim().split(/\s+/);return e.length<=4&&e.every(t=>t==="0"||t==="auto"||Y.length(t))?e.join(" "):null},jx={"background-color":Y.color,color:Y.color,"font-family":Y.fontFamily,"font-size":Y.length,"line-height":Y.lineHeight,"text-align":n=>["left","center","right","justify"].includes(n)?n:null,"max-width":Y.length,margin:ft,"margin-top":ft,"margin-right":ft,"margin-bottom":ft,"margin-left":ft,padding:ft,"padding-top":ft,"padding-right":ft,"padding-bottom":ft,"padding-left":ft};function tc(n){if(typeof n!="string")return"";let e=new Map;for(let t of n.slice(0,2e3).split(";")){let r=t.indexOf(":");if(r<0)continue;let o=t.slice(0,r).trim().toLowerCase();o==="background"&&(o="background-color");let i=jx[o]?.(t.slice(r+1).trim());i&&(e.delete(o),e.set(o,i))}return[...e].map(([t,r])=>`${t}: ${r}`).join("; ")}var Wx={lang:Si,dir:Xh,xmlns:n=>n==="http://www.w3.org/1999/xhtml"?n:null,"xml:lang":Si},Kx={style:n=>tc(n)||null,class:Vx,dir:Xh,lang:Si},Zh={charset:n=>/^[\w.:-]{1,40}$/.test(n)?n:null,name:n=>Gh.test(n)?n:null,property:n=>Gh.test(n)?n:null,"http-equiv":n=>Fx.has(n.toLowerCase())?n:null,content:n=>wn(n,2e3)},Ux={rel:n=>{let e=n.toLowerCase().split(/\s+/).filter(Boolean);return e.length&&e.every(t=>zx.has(t))?e.join(" "):null},href:qx,type:n=>/^[\w.+-]{1,60}\/[\w.+-]{1,60}$/.test(n)?n:null,media:ec,sizes:n=>/^(?:any|\d{1,4}x\d{1,4}(?:\s+\d{1,4}x\d{1,4}){0,9})$/i.test(n)?n:null,hreflang:Si,title:ec},Jx={media:ec,type:n=>n.toLowerCase()==="text/css"?"text/css":null};function Qr(n,e){if(!n||typeof n!="object"||Array.isArray(n))return null;let t=n,r={};for(let[o,i]of Object.entries(e)){let s=typeof t[o]=="string"?i(t[o]):null;s!==null&&(r[o]=s)}return Object.keys(r).length?r:null}function Gx(n){if(!n||typeof n!="object")return null;let{tag:e,attrs:t,text:r}=n;if(e==="title"){let o=wn(r,1e3);return o===null?null:{tag:e,text:o.replace(/\s+/g," ").trim()}}if(e==="meta"){let o=Qr(t,Zh),i=o&&(o.name??o.property??o["http-equiv"])&&o.content!==void 0;return o&&(o.charset||i)?{tag:e,attrs:o}:null}if(e==="link"){let o=Qr(t,Ux);return o?.rel&&o.href?{tag:e,attrs:o}:null}if(e==="style"){let o=wn(r,2e5);return o===null?null:{tag:e,attrs:Qr(t,Jx)??{},text:o}}return null}function nc(n){if(!n||typeof n!="object"||Array.isArray(n))return{};let e=n,t={},r=wn(e.doctype,700)?.trim();r&&Yh.test(r)&&(t.doctype=r);let o=Qr(e.html,Wx);o&&(t.html=o);let i=Array.isArray(e.head)?e.head.slice(0,300).map(Gx).filter(c=>c!==null):[],s=i.findIndex(c=>c.tag==="title"),l=i.filter((c,d)=>c.tag!=="title"||d===s);l.length&&(t.head=l);let a=Qr(e.body,Kx);return a&&(t.body=a),t}var Mi=(n={})=>Object.entries(n).map(([e,t])=>` ${e}="${Zr(t)}"`).join("");function Yx(n){return n.tag==="title"?`<title>${xn(n.text)}</title>`:n.tag==="style"?`<style${Mi(n.attrs)}>${n.text.replace(/<\/(style)/gi,"<\\/$1")}</style>`:`<${n.tag}${Mi(n.attrs)}>`}function Xx(n){let e=l=>l?Object.fromEntries([...l.attributes].map(a=>[a.name.toLowerCase(),a.value])):{},t=n.doctype,r=t?`<!DOCTYPE ${t.name}${t.publicId?` PUBLIC "${t.publicId}"`:""}${t.systemId?`${t.publicId?"":" SYSTEM"} "${t.systemId}"`:""}>`:void 0,o=[...n.head.children].map(l=>{let a=l.tagName.toLowerCase();return a==="title"||a==="style"?{tag:a,attrs:e(l),text:l.textContent??""}:{tag:a,attrs:e(l)}}),i=e(n.body),s=[i.bgcolor&&`background-color: ${i.bgcolor}`,i.text&&`color: ${i.text}`,i.style].filter(Boolean);return s.length&&(i.style=s.join("; ")),nc({doctype:r,html:e(n.documentElement),head:o,body:i})}var Zx=/<!doctype\b|<(?:html|head|body)[\s>/]/i;function Qh(n){let e=n.options.pluginOptions?.fullpagehtml??{},t=wn(e.doctype,700)?.trim();return{doctype:t&&Yh.test(t)?t:$x,title:wn(e.title,1e3)?.replace(/\s+/g," ").trim()??"",encoding:typeof e.encoding=="string"?Zh.charset(e.encoding)??"":"",bodyStyle:tc(e.bodyStyle),hideInSourceView:e.hideInSourceView===!0}}function Qx(n,e){let t=nc(n),r=(t.head??[]).map(Yx);e.encoding&&!t.head?.some(i=>i.tag==="meta"&&i.attrs.charset)&&r.unshift(`<meta charset="${Zr(e.encoding)}">`),e.title&&!t.head?.some(i=>i.tag==="title")&&r.push(`<title>${xn(e.title)}</title>`);let o={...t.body};return!o.style&&e.bodyStyle&&(o.style=e.bodyStyle),[t.doctype??e.doctype,`<html${Mi(t.html)}>`,"<head>",...r,"</head>",`<body${Mi(o)}>`].join(`
17
- `)}function e1(n){let e=Qh(n);return{inSource:!e.hideInSourceView,read(t){if(!Zx.test(t))return null;let r=new DOMParser().parseFromString(t,"text/html");return{content:r.body.innerHTML,attrs:{page:Xx(r)}}},write:(t,r)=>`${Qx(r.page,e)}
15
+ `),t=!1,o(s),t=!0):o(s)}};return o(n),e}function Jh(n){return n.getAttribute("data-type")==="taskList"||n.classList.contains("tox-checklist")||n.classList.contains("contains-task-list")}function vx(n){let e=n.parentElement;if(!e||!Jh(e))return null;let t=n.getAttribute("data-checked");if(t==="true"||t==="false")return t==="true";if(n.classList.contains("tox-checklist--checked"))return!0;let r=[...n.querySelectorAll('input[type="checkbox"]')].find(o=>o.closest("li")===n);return r?r.hasAttribute("checked"):!1}function xx(n){let e=Math.trunc(Number(n));return e>=1&&e<=6?e:1}function Yt(n,e){let t=[...n.classList].filter(r=>Kh.test(r)&&e(r));return t.length?t.join(" "):null}function Xe(n){if(typeof n!="string")return{};let e=n.split(/\s+/).filter(t=>Kh.test(t));return e.length?{class:e.join(" ")}:{}}var Jr={class:{default:null}},Gh=(n,e=!1)=>({doc:{content:"block+"},paragraph:{group:"block",content:"inline*",attrs:{...zh,...Jr},parseDOM:[{tag:"p",getAttrs:t=>({...Bh(t,e),class:Yt(t,n)})}],toDOM:t=>["p",{...Xe(t.attrs.class),...Fh(t.attrs,e)},0]},heading:{group:"block",content:"inline*",defining:!0,attrs:{level:{default:1},id:{default:null},...zh,...Jr},parseDOM:[1,2,3,4,5,6].map(t=>({tag:`h${t}`,getAttrs:r=>({level:t,id:Vn(r.getAttribute("id")),...Bh(r,e),class:Yt(r,n)})})),toDOM:t=>[`h${xx(t.attrs.level)}`,{...Vn(t.attrs.id)?{id:t.attrs.id}:{},...Xe(t.attrs.class),...Fh(t.attrs,e)},0]},blockquote:{group:"block",content:"block+",defining:!0,attrs:{...Jr},parseDOM:[{tag:"blockquote",getAttrs:t=>({class:Yt(t,n)})}],toDOM:t=>["blockquote",Xe(t.attrs.class),0]},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>["hr"]},code_block:{group:"block",content:"text*",marks:"",code:!0,defining:!0,attrs:{language:{default:null}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:t=>({language:bx(t)}),getContent:(t,r)=>{let o=Uh(t);return o?T.from(r.text(o)):T.empty}}],toDOM:t=>{let r=vn(t.attrs.language);return["pre",["code",r?{class:`language-${r}`}:{},0]]}},bullet_list:{group:"block",content:"list_item+",attrs:{listStyle:{default:null},checklist:{default:!1}},parseDOM:[{tag:"ul",getAttrs:t=>{let r=Jh(t);return{listStyle:r?null:$h(t,_a,"disc"),checklist:r}}}],toDOM:t=>t.attrs.checklist===!0?["ul",{"data-type":"taskList"},0]:["ul",Vh(t.attrs.listStyle,_a),0]},ordered_list:{group:"block",content:"list_item+",attrs:{start:{default:1},listStyle:{default:null}},parseDOM:[{tag:"ol",getAttrs:t=>{let r=t.getAttribute("start");return{start:r?Number(r):1,listStyle:$h(t,Ia,"decimal")}}}],toDOM:t=>["ol",{...t.attrs.start===1?{}:{start:t.attrs.start},...Vh(t.attrs.listStyle,Ia)},0]},list_item:{content:"paragraph block*",defining:!0,attrs:{checked:{default:null}},parseDOM:[{tag:"li",getAttrs:t=>({checked:vx(t)})}],toDOM:t=>typeof t.attrs.checked=="boolean"?["li",{"data-type":"taskItem","data-checked":String(t.attrs.checked)},0]:["li",0]},text:{group:"inline"},figure:{group:"block",content:"figure_image figcaption",draggable:!0,isolating:!0,attrs:{align:{default:null},...Jr},parseDOM:[{tag:"figure",getAttrs:t=>{let r=t,o=r.querySelector("img");return!o||!fe(o.getAttribute("src")??"")?!1:{align:qh(r),class:Yt(r,n)}}}],toDOM:t=>{let r=ne(t.firstChild?.attrs.width),o=Ha[t.attrs.align]??"",i=`${o}${r?`${o?" ":""}width: ${r}px;`:""}`;return["figure",{...Xe(t.attrs.class),...i?{style:i}:{}},0]}},figure_image:{atom:!0,selectable:!1,attrs:{src:{default:""},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}},parseDOM:[{tag:"img[src]",context:"figure/",priority:60,getAttrs:t=>{let r=t;return fe(r.getAttribute("src")??"")?{src:r.getAttribute("src"),alt:r.getAttribute("alt"),title:r.getAttribute("title"),width:ne(r.getAttribute("width")??r.style.width),height:ne(r.getAttribute("height")??r.style.height)}:!1}}],toDOM:t=>{let{alt:r,title:o}=t.attrs,i=fe(t.attrs.src)?t.attrs.src:"",s=ne(t.attrs.width),l=ne(t.attrs.height);return["img",{src:i,...r==null?{}:{alt:String(r)},...o?{title:o}:{},...s?{width:String(s)}:{},...l?{height:String(l)}:{}}]}},figcaption:{content:"inline*",parseDOM:[{tag:"figcaption",context:"figure/"}],toDOM:()=>["figcaption",0]},image:{group:"inline",inline:!0,draggable:!0,attrs:{src:{},alt:{default:null},title:{default:null},width:{default:null},height:{default:null},align:{default:null},...Jr},parseDOM:[{tag:"img[src]",getAttrs:t=>{let r=t;return fe(r.getAttribute("src")??"")?{src:r.getAttribute("src"),alt:r.getAttribute("alt"),title:r.getAttribute("title"),width:ne(r.getAttribute("width")??r.style.width),height:ne(r.getAttribute("height")??r.style.height),align:qh(r),class:Yt(r,n)}:!1}}],toDOM:t=>{let{alt:r,title:o}=t.attrs,i=fe(t.attrs.src)?t.attrs.src:"",s=ne(t.attrs.width),l=ne(t.attrs.height),a=Ha[t.attrs.align];return["img",{src:i,...Xe(t.attrs.class),...r==null?{}:{alt:String(r)},...o?{title:o}:{},...s?{width:String(s)}:{},...l?{height:String(l)}:{},...a?{style:a}:{}}]}},hard_break:{group:"inline",inline:!0,selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>["br"]},...gx(n)}),Fa=Gh(Va),Yh=n=>({language:{attrs:{lang:{default:null}},parseDOM:[{tag:"[lang]",priority:60,consuming:!1,getAttrs:e=>{let t=Fe(e.getAttribute("lang"));return t?{lang:t}:!1}}],toDOM:e=>{let t=Fe(e.attrs.lang);return t?["span",{lang:t},0]:["span",0]}},link:{attrs:{href:{},title:{default:null},target:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:e=>{let t=e;return Ie(t.getAttribute("href")??"")?{href:t.getAttribute("href"),title:t.getAttribute("title"),target:t.getAttribute("target")}:!1}}],toDOM:e=>{let{title:t,target:r}=e.attrs;return["a",{href:Ie(e.attrs.href)?e.attrs.href:"#",...t?{title:t}:{},...r?{target:r,rel:"noopener noreferrer"}:{}},0]}},bold:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:e=>e.style?.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:()=>["strong",0]},italic:{parseDOM:[{tag:"em"},{tag:"i"},{style:"font-style=italic"}],toDOM:()=>["em",0]},underline:{parseDOM:[{tag:"u"},{style:"text-decoration=underline"}],toDOM:()=>["u",0]},strike:{parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration=line-through"}],toDOM:()=>["s",0]},code:{code:!0,parseDOM:[{tag:"code"}],toDOM:()=>["code",0]},subscript:{excludes:"superscript",parseDOM:[{tag:"sub"},{style:"vertical-align=sub"}],toDOM:()=>["sub",0]},superscript:{excludes:"subscript",parseDOM:[{tag:"sup"},{style:"vertical-align=super"}],toDOM:()=>["sup",0]},color:{attrs:{value:{}},parseDOM:[{style:"color",getAttrs:e=>Gr(Y.color(e))},{tag:"font[color]",getAttrs:e=>Gr(Y.color(e.getAttribute("color")))}],toDOM:e=>Ei("color",Y.color(e.attrs.value))},background:{attrs:{value:{}},parseDOM:[{style:"background-color",getAttrs:e=>Gr(Y.color(e))},{tag:"mark",getAttrs:()=>({value:"yellow"})}],toDOM:e=>Ei("background-color",Y.color(e.attrs.value))},font_family:{attrs:{value:{}},parseDOM:[{style:"font-family",getAttrs:e=>Gr(Y.fontFamily(e))}],toDOM:e=>Ei("font-family",Y.fontFamily(e.attrs.value))},font_size:{attrs:{value:{}},parseDOM:[{style:"font-size",getAttrs:e=>Gr(Y.length(e))}],toDOM:e=>Ei("font-size",Y.length(e.attrs.value))},span_class:{attrs:{class:{}},parseDOM:[{tag:"span[class]",consuming:!1,getAttrs:e=>{let t=Yt(e,n);return t?{class:t}:!1}}],toDOM:e=>["span",Xe(e.attrs.class),0]}}),za=Yh(Va);function Gr(n){return n?{value:n}:!1}function Ei(n,e){return e?["span",{style:`${n}: ${e};`},0]:["span",0]}var Lt=new Dn({nodes:Fa,marks:za});function wx(n,e,t){let r=t.toDOM;return{...t,attrs:{...t.attrs,[n]:{default:e.default}},parseDOM:t.parseDOM?.map(o=>{if(!o.tag)return o;let i=o.getAttrs;return{...o,getAttrs:s=>{let l=i?i(s):o.attrs??null;if(l===!1)return!1;let a=e.parse(s);return a==null?l:{...l,[n]:a}}}}),...r?{toDOM:o=>{let i=r(o),s=e.render(o.attrs[n]);if(!Array.isArray(i)||typeof i[0]!="string"||!Object.keys(s).length)return i;let l=i[1],a=!!l&&typeof l=="object"&&!Array.isArray(l)&&l.nodeType===void 0;return[i[0],{...a?l:{},...s},...i.slice(a?2:1)]}}:{}}}var Sx=n=>/\b(inline|text)\b/.test(n.content??"");function Ci(n={},e,t,r="ltr"){let o=r==="rtl",i=Object.entries(n.nodes??{}),s=Object.entries(n.marks??{}),l=Object.entries(n.attributes??{});if(!i.length&&!s.length&&!l.length&&!e&&!t&&!o)return Lt;let a=e||o?Gh(e??Va,o):Fa,c=e?Yh(e):za,u={};t&&({nodes:a,marks:c}=t.apply({nodes:a,marks:c},u));for(let[f]of i)if(f in Fa)throw new Error(`[nova] node "${f}" already exists in the base schema`);for(let[f]of s)if(f in za)throw new Error(`[nova] mark "${f}" already exists in the base schema`);let d={...a,...Object.fromEntries(i)},p=(f,h,m)=>f.nodes==="all"?h!=="doc"&&h!=="text":f.nodes==="textblock"?Sx(m):f.nodes.includes(h);for(let[f,h]of l)d=Object.fromEntries(Object.entries(d).map(([m,g])=>[m,p(h,m,g)&&!g.attrs?.[f]?wx(f,h,g):g]));return u.schema=new Dn({nodes:d,marks:{...c,...Object.fromEntries(s)}}),u.schema}var Mx=new WeakMap,Ex=/^https?:\/\/(?:www\.|m\.)?(?:youtube(?:-nocookie)?\.com\/(?:watch\?(?:[^#]*&)?v=|embed\/|shorts\/|live\/)|youtu\.be\/)([\w-]{11})(?:[?&#]|$)/i,Cx=/^https?:\/\/(?:www\.|player\.)?vimeo\.com\/(?:video\/)?(\d{1,12})(?:[/?#]|$)/i,Ax=/^https:\/\/[^\s"'<>]+\.(?:mp4|webm|ogv|ogg)(?:\?[^\s"'<>#]*)?$/i;function Ai(n){if(typeof n!="string")return null;let e=n.trim(),t=e.match(Ex);if(t)return{kind:"youtube",src:`https://www.youtube-nocookie.com/embed/${t[1]}`};let r=e.match(Cx);return r?{kind:"vimeo",src:`https://player.vimeo.com/video/${r[1]}`}:Ax.test(e)?{kind:"video",src:e}:null}function Xh(n,e){let t=e?Ai(e):null;return t?{...t,width:ne(n.getAttribute("width"))??560,height:ne(n.getAttribute("height"))??315,title:n.getAttribute("title")??""}:!1}function Tx(n){let e=Ai(n.attrs.src);if(!e)return null;let t=String(ne(n.attrs.width)??560),r=String(ne(n.attrs.height)??315);return e.kind==="video"?w("video",{src:e.src,controls:!0,width:t,height:r,preload:"metadata"}):w("iframe",{src:e.src,width:t,height:r,title:n.attrs.title||"Video",allow:"accelerometer; encrypted-media; gyroscope; picture-in-picture; fullscreen",allowfullscreen:!0,loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin"})}var ja={name:"media",toolbar:"media",nodes:{media:{group:"block",atom:!0,selectable:!0,draggable:!0,attrs:{kind:{default:"youtube"},src:{},width:{default:560},height:{default:315},title:{default:""}},parseDOM:[{tag:"iframe[src]",getAttrs:n=>Xh(n,n.getAttribute("src"))},{tag:"video",getAttrs:n=>{let e=n,t=e.getAttribute("src")??e.querySelector("source[src]")?.getAttribute("src")??null;return Xh(e,t)}}],toDOM:n=>{let e=Ai(n.attrs.src),t=String(ne(n.attrs.width)??560),r=String(ne(n.attrs.height)??315);return e?e.kind==="video"?["video",{src:e.src,controls:"",width:t,height:r}]:["iframe",{src:e.src,width:t,height:r,title:n.attrs.title||null,allow:"accelerometer; encrypted-media; gyroscope; picture-in-picture; fullscreen",allowfullscreen:"",loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin"}]:["p"]}}},prosemirrorPlugins:()=>[new z({props:{nodeViews:{media:n=>{let e=Tx(n);return{dom:w("div",{className:"nova-media",contenteditable:"false"},e,w("div",{className:"nova-media-overlay","aria-hidden":"true"})),ignoreMutation:()=>!0,stopEvent:()=>!1}}}}})],load:()=>import(__novaChunk("tinymce-chunks/media-ui-de819f11.js") )};var Ja={};q(Ja,{DEFAULT_SANDBOX:()=>Qh,FIXED:()=>Pt,default:()=>Ua,embeddableUrl:()=>Ti,pageEmbedOptions:()=>Ka,ratioOf:()=>Xr});var Qh="allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation",Nx=["21by9","16by9","4by3","1by1"].map(n=>({value:`nova-pageembed--${n}`})),Pt={width:350,height:260},Zh=/^[\w-]{1,60}$/,Ox=/--(\d{1,3})by(\d{1,3})$/;function Ka(n){let e=n.options.pluginOptions?.pageembed??{},t=Array.isArray(e.sizes)?e.sizes.filter(o=>!!o&&typeof o.value=="string"&&Zh.test(o.value)):Nx,r=e.sandbox===!1?!1:typeof e.sandbox=="string"?e.sandbox.split(/\s+/).filter(o=>/^allow-[a-z-]{1,40}$/.test(o)).join(" "):Qh;return{sizes:t,inlineStyles:e.inlineStyles!==!1,className:typeof e.className=="string"&&Zh.test(e.className)?e.className:"nova-pageembed",sandbox:r,allowUrl:typeof e.allowUrl=="function"?e.allowUrl:void 0}}function Xr(n){let e=Ox.exec(n);if(!e)return null;let t=Number(e[1]),r=Number(e[2]);return t>0&&r>0?[t,r]:null}function Ti(n,e){if(typeof n!="string")return null;let t=n.trim();if(t.length>2e3||!/^https?:\/\/[^\s/?#]/i.test(t))return null;let r;try{r=new URL(t)}catch{return null}if(r.protocol!=="http:"&&r.protocol!=="https:"||r.username||r.password)return null;try{if(e&&!e(r.href))return null}catch{return null}return t}function em(n,e){if(typeof n=="string"&&n.trim())return n.trim().slice(0,300);try{return new URL(e).hostname}catch{return e}}function tm(n,e){return typeof n=="string"&&e.sizes.some(t=>t.value===n)?n:""}function Lx(n,e){let t=n.find(r=>e.sizes.some(o=>o.value===r));if(t)return t;for(let r of n){let o=/^(?:nova|tiny)-pageembed--/.test(r)?Xr(r):null;if(!o)continue;let i=e.sizes.find(s=>{let l=Xr(s.value);return!!l&&l[0]*o[1]===l[1]*o[0]});if(i)return i.value}return""}function Px(n,e){return n.some(t=>t===e.className||/^(?:nova|tiny)-pageembed(?:--[\w-]+)?$/.test(t)||e.sizes.some(r=>r.value===t))}function nm(n,e,t){return{src:e,title:em(n.attrs.title,e),sandbox:t.sandbox===!1?null:t.sandbox,allow:"fullscreen",allowfullscreen:"",loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin",frameborder:n.attrs.border===!0?"1":"0",scrolling:n.attrs.scrolling===!1?"no":null}}function Rx(n){let e=Ka(n);return{pageembed:{group:"block",atom:!0,selectable:!0,draggable:!0,attrs:{src:{default:""},size:{default:""},width:{default:Pt.width},height:{default:Pt.height},title:{default:""},border:{default:!1},scrolling:{default:!0}},parseDOM:[{tag:"div",priority:70,getAttrs:t=>{let r=t,o=[...r.classList];if(!Px(o,e))return!1;let i=r.querySelector("iframe"),s=Ti(i?.getAttribute("src"),e.allowUrl);if(!i||!s)return!1;let l=i.getAttribute("frameborder");return{src:s,size:Lx(o,e),width:ne(i.getAttribute("width"))??Pt.width,height:ne(i.getAttribute("height"))??Pt.height,title:(i.getAttribute("title")??"").trim().slice(0,300),border:l!==null&&l!=="0"&&l.toLowerCase()!=="no",scrolling:i.getAttribute("scrolling")?.toLowerCase()!=="no"}}}],toDOM:t=>{let r=Ti(t.attrs.src,e.allowUrl);if(!r)return["div",{class:e.className}];let o=nm(t,r,e),i=tm(t.attrs.size,e);if(!i)return o.width=String(ne(t.attrs.width)??Pt.width),o.height=String(ne(t.attrs.height)??Pt.height),["div",{class:e.className},["iframe",o]];let s=e.inlineStyles?Xr(i):null;if(s){let l=Math.round(s[1]/s[0]*1e6)/1e4;return o.style=`position: absolute; top: 0; left: 0; width: 100%; height: 100%${t.attrs.border===!0?"":"; border: 0"}`,["div",{class:`${e.className} ${i}`,style:`position: relative; width: 100%; padding-top: ${l}%; overflow: hidden`},["iframe",o]]}return["div",{class:`${e.className} ${i}`},["iframe",o]]}}}}function Dx(n,e){let t=w("div",{className:"nova-media nova-pageembed-view",contenteditable:"false"}),r=w("div",{className:"nova-media-overlay","aria-hidden":"true"}),o=null,i=null,s=l=>{let a=Ti(l.attrs.src,e.allowUrl),c=tm(l.attrs.size,e),u=c?Xr(c):null;if(t.classList.toggle("is-responsive",!!c),t.classList.toggle("has-border",l.attrs.border===!0),!a){o?.remove(),o=null,i=null,t.replaceChildren(w("div",{className:"nova-pageembed-missing"},typeof l.attrs.src=="string"?l.attrs.src:""),r);return}if(!o||i!==a){let d=nm(l,a,e);o=w("iframe",{src:a,title:d.title,...d.sandbox===null?{}:{sandbox:d.sandbox},allow:"fullscreen",loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin",tabindex:"-1"}),i=a,t.replaceChildren(o,r)}o.title=em(l.attrs.title,a),l.attrs.scrolling===!1?o.setAttribute("scrolling","no"):o.removeAttribute("scrolling"),c?(o.removeAttribute("width"),o.removeAttribute("height"),o.style.aspectRatio=u?`${u[0]} / ${u[1]}`:"16 / 9"):(o.style.aspectRatio="",o.setAttribute("width",String(ne(l.attrs.width)??Pt.width)),o.setAttribute("height",String(ne(l.attrs.height)??Pt.height)))};return s(n),{dom:t,update(l){return l.type!==n.type?!1:(n=l,s(l),!0)},ignoreMutation:()=>!0,stopEvent:()=>!1}}var Ua={name:"pageembed",toolbar:"pageembed",nodes:Rx,prosemirrorPlugins:n=>{let e=Ka(n);return[new z({props:{nodeViews:{pageembed:t=>Dx(t,e)}}})]},load:()=>import(__novaChunk("tinymce-chunks/pageembed-ui-da39f1ee.js") )};var Xa={};q(Xa,{default:()=>Ya,seriesName:()=>Ga});var _x=/^[a-z][\w-]{0,39}$/i;function Ga(n){return typeof n=="string"&&_x.test(n)?n:null}var Ix={nodes:["table_cell","table_header"],default:null,parse:n=>Ga(n.getAttribute("data-series")),render:n=>{let e=Ga(n);return e?{"data-series":e}:{}}},Ya={name:"advtable",nodeAttributes:{series:Ix},load:()=>import(__novaChunk("tinymce-chunks/advtable-ui-db2e667d.js") )};var oc={};q(oc,{cardFields:()=>nc,cardHref:()=>ec,cardImage:()=>tc,cardText:()=>Rt,default:()=>rc,hostOf:()=>Za,mediaEmbedOptions:()=>Qa});var Hx=/^[\w-]{1,60}$/;function Qa(n){let e=n.options.pluginOptions?.mediaembed??{},t=Number(e.maxWidth);return{className:typeof e.className=="string"&&Hx.test(e.className)?e.className:"nova-card",inlineStyles:e.inlineStyles!==!1,maxWidth:Number.isFinite(t)&&t>=200?Math.min(2e3,Math.round(t)):650}}function Rt(n,e){return typeof n=="string"?n.replace(/\s+/g," ").trim().slice(0,e):""}function ec(n){if(typeof n!="string")return null;let e=n.trim();return/^https?:\/\/[^\s/?#]/i.test(e)&&e.length<=2e3&&Ie(e)?e:null}function tc(n){if(typeof n!="string")return null;let e=n.trim();return/^https?:\/\/[^\s/?#]/i.test(e)&&e.length<=2e3&&fe(e)?e:null}function Za(n){try{return new URL(n).hostname.replace(/^www\./,"")}catch{return""}}function nc(n){let e=ec(n.href);return{href:e,title:Rt(n.title,300)||(e?Za(e):""),description:Rt(n.description,500),image:tc(n.image),site:Rt(n.site,100)||(e?Za(e):""),author:Rt(n.author,100)}}function Bx(n){let e=Qa(n),t=[...new Set([e.className,"nova-card","ephox-summary-card"])],r=(o,i)=>o.querySelector(t.map(s=>`.${s}-${i}`).join(", "));return{link_card:{group:"block",atom:!0,selectable:!0,draggable:!0,attrs:{href:{default:""},title:{default:""},description:{default:""},image:{default:""},site:{default:""},author:{default:""}},parseDOM:[{tag:"a, div",priority:70,getAttrs:o=>{let i=o;if(!t.some(c=>i.classList.contains(c)))return!1;let s=ec(i.getAttribute("href")??i.querySelector("a[href]")?.getAttribute("href"));if(!s)return!1;let l=r(i,"thumbnail"),a=l?.getAttribute("src")??l?.querySelector("img")?.getAttribute("src")??"";return{href:s,title:Rt(r(i,"title")?.textContent,300),description:Rt(r(i,"description")?.textContent,500),image:tc(a)??"",site:Rt(r(i,"website")?.textContent,100),author:Rt(r(i,"author")?.textContent,100)}}}],toDOM:o=>Fx(o,e)}}}var xn=(n,e)=>n.inlineStyles?e:null;function Fx(n,e){let t=nc(n.attrs),r=e.className;if(!t.href)return["div",{class:r},t.title];let o="display: block; opacity: 0.75; font-size: 0.875em",i=[["span",{class:`${r}-title`,style:xn(e,"display: block; font-weight: 600")},t.title]];return t.description&&i.push(["span",{class:`${r}-description`,style:xn(e,o)},t.description]),i.push(["span",{class:`${r}-website`,style:xn(e,o)},t.site]),t.author&&i.push(["span",{class:`${r}-author`,style:xn(e,o)},t.author]),["a",{class:r,href:t.href,rel:"noopener noreferrer",style:xn(e,`display: flex; flex-wrap: wrap; gap: 12px; max-width: ${e.maxWidth}px; margin: 0.5em 0; padding: 12px; border: 1px solid rgb(127 127 127 / 0.35); border-radius: 8px; color: inherit; text-decoration: none; overflow: hidden`)},...t.image?[["img",{class:`${r}-thumbnail`,src:t.image,alt:"",loading:"lazy",style:xn(e,"flex: none; width: 120px; height: 90px; object-fit: cover; border-radius: 4px")}]]:[],["span",{style:xn(e,"display: block; flex: 1 1 180px; min-width: 0")},...i]]}function zx(n,e){let t=w("div",{className:"nova-card-view",contenteditable:"false"});t.style.maxWidth=`${e.maxWidth}px`;let r=o=>{let i=nc(o.attrs);t.replaceChildren(...i.image?[w("img",{className:"nova-card-view-image",src:i.image,alt:""})]:[],w("div",{className:"nova-card-view-text"},w("div",{className:"nova-card-view-title"},i.title),i.description?w("div",{className:"nova-card-view-description"},i.description):null,w("div",{className:"nova-card-view-site"},[i.site,i.author].filter(Boolean).join(" \xB7 ")))),t.title=i.href??""};return r(n),{dom:t,update(o){return o.type!==n.type?!1:(n=o,r(o),!0)},ignoreMutation:()=>!0,stopEvent:()=>!1}}var rc={name:"mediaembed",nodes:Bx,prosemirrorPlugins:n=>{let e=Qa(n);return[new z({props:{nodeViews:{link_card:t=>zx(t,e)}}})]},load:()=>import(__novaChunk("tinymce-chunks/mediaembed-ui-7be11324.js") )};var dc={};q(dc,{bodyStyle:()=>ac,cleanPage:()=>cc,default:()=>uc,fullPageOptions:()=>cm});var sc={};q(sc,{HTMLSerializer:()=>Qr,escapeAttr:()=>eo,escapeText:()=>wn});var $x=new Set(["href","xlink:href","action","formaction","cite"]),Vx=new Set(["src","poster","data","background"]),qx=/url\s*\(|expression\s*\(|javascript:|@import|behavior\s*:|-moz-binding/i;function Zr(n,e){let t=n.toLowerCase();return t.startsWith("on")?null:$x.has(t)?Ie(e)?e:null:Vx.has(t)?fe(e)?e:null:t==="srcset"?e.split(",").map(o=>o.trim().split(/\s+/)[0]??"").every(o=>fe(o))?e:null:t==="style"&&qx.test(e)?null:e}var jx=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),om=new RegExp("\xA0","g");function wn(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(om,"&nbsp;")}var Wx="\xA0";function Kx(n){let e=null,t=!0,r=n.childCount;for(let o=0;o<r;o++){let i=n.child(o);if(!i.isText){t=i.type.name==="hard_break"||!i.isInline;continue}let s=i.text??"";if(!s.includes(" ")){t=!1;continue}let l=o===r-1||!n.child(o+1).isInline,a="";for(let c=0;c<s.length;c++){let u=s[c];u!==" "?(a+=u,t=!1):t||l&&c===s.length-1?(a+=Wx,t=!1):(a+=" ",t=!0)}a!==s&&(e??(e=new Map)).set(o,a)}return e}function eo(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(om,"&nbsp;")}var Ux=/^[a-z][a-z0-9-]*$/i,Jx=new Set(["script","style","base","link","meta","object","embed","applet","frame","frameset","template","noscript"]),rm=new Set;function Gx(n){rm.has(n)||(rm.add(n),console.error(`[nova] toDOM produced <${n}>, which is not allowed in output; the tag was dropped`))}var Yx=/^[a-z_:][a-z0-9_.:-]*$/i;function ic(n){if(typeof n=="string")return{open:"",close:"",hole:!1,html:wn(n)};if(typeof n=="number"||typeof n=="boolean")return{open:"",close:"",hole:!1,html:wn(String(n))};if(n==null)return{open:"",close:"",hole:!1,html:""};if(!Array.isArray(n))throw new Error("[nova] serializer supports only array/string toDOM specs");let[e,...t]=n,r=e.includes(" ")?e.split(" ")[1]:e;if(!Ux.test(r))throw new Error(`[nova] invalid tag in toDOM: ${r}`);let o=Jx.has(r.toLowerCase());o&&Gx(r.toLowerCase());let i="",s=t,l=t[0];if(l&&typeof l=="object"&&!Array.isArray(l)){for(let[f,h]of Object.entries(l)){if(h==null)continue;let m=f.includes(" ")?f.split(" ")[1]:f;if(!Yx.test(m))continue;let g=Zr(m,String(h));g!==null&&(i+=` ${m}="${eo(g)}"`)}s=t.slice(1)}let a=o?"":`<${r}${i}>`;if(jx.has(r.toLowerCase()))return{open:a,close:"",hole:!1,html:a};let c="",u="",d=!1;for(let f of s){if(f===0){if(d)throw new Error("[nova] toDOM spec has more than one content hole");d=!0;continue}let h=ic(f);if(d){if(h.hole)throw new Error("[nova] toDOM spec has more than one content hole");u+=h.html}else h.hole?(c+=h.open,u+=h.close,d=!0):c+=h.html}if(o)return{open:"",close:"",hole:d,html:""};let p=`</${r}>`;return{open:a+c,close:u+p,hole:d,html:a+c+u+p}}var Qr=class{constructor(){S(this,"cache",new WeakMap)}serializeFragment(e,{pre:t=!1}={}){let r=t?null:Kx(e),o="",i=[],s=[],l=a=>{for(;i.length>a;)o+=s.pop(),i.pop()};return e.forEach((a,c,u)=>{if(!a.isInline){l(0),o+=this.serializeNode(a);return}let d=0;for(;d<i.length&&d<a.marks.length&&i[d].eq(a.marks[d]);)d++;l(d);for(let p=d;p<a.marks.length;p++){let f=a.marks[p],h=this.renderMark(f,a.isText);o+=h.open,s.push(h.close),i.push(f)}o+=a.isText?wn(r?.get(u)??a.text??""):this.serializeNode(a)}),l(0),i=[],s=[],o}serializeNode(e){let t=e.type.spec.toDOM;if(!t)throw new Error(`[nova] node "${e.type.name}" has no toDOM`);let r=ic(t(e));if(!r.hole)return r.html;let o=!!e.type.spec.code||e.type.spec.whitespace==="pre";return r.open+this.serializeFragment(e.content,{pre:o})+r.close}renderMark(e,t){let r=e.type.spec.toDOM;if(!r)throw new Error(`[nova] mark "${e.type.name}" has no toDOM`);let o=this.cache.get(e.type);o||this.cache.set(e.type,o=new Map);let i=JSON.stringify(e.attrs),s=o.get(i);return s||(s=ic(r(e,t)),o.size>500&&o.clear(),o.set(i,s)),s}};var Xx=/^[a-z]{1,8}(?:-[a-z0-9]{1,8}){0,4}$/i,im=/^[\w.:-]{1,100}$/,sm=/^<!doctype html(?:\s+(?:public|system)(?:\s+(?:"[^"<>]{0,300}"|'[^'<>]{0,300}')){1,2})?\s*>$/i,Zx=new Set(["content-type","content-language","x-ua-compatible","default-style"]),Qx=new Set(["stylesheet","icon","shortcut","apple-touch-icon","canonical","alternate","author","license","next","prev"]),e1="<!DOCTYPE html>";function Sn(n,e){return typeof n!="string"||n.length>e||/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/.test(n)?null:n.replace(/\r\n?/g,`
16
+ `)}var Ni=n=>Xx.test(n)?n:null,lm=n=>["ltr","rtl","auto"].includes(n.toLowerCase())?n.toLowerCase():null,lc=n=>Sn(n,300),t1=n=>{let e=n.split(/\s+/).filter(Boolean);return e.length&&e.length<=20&&e.every(t=>/^[\w-]{1,60}$/.test(t))?e.join(" "):null},n1=n=>{let e=n.trim(),t=/^([a-z][a-z0-9+.-]*):/i.exec(e.replace(/[\u0000- ]/g,""))?.[1];return e&&e.length<=2e3&&(!t||/^https?$/i.test(t))?e:null},ht=n=>{let e=n.trim().split(/\s+/);return e.length<=4&&e.every(t=>t==="0"||t==="auto"||Y.length(t))?e.join(" "):null},r1={"background-color":Y.color,color:Y.color,"font-family":Y.fontFamily,"font-size":Y.length,"line-height":Y.lineHeight,"text-align":n=>["left","center","right","justify"].includes(n)?n:null,"max-width":Y.length,margin:ht,"margin-top":ht,"margin-right":ht,"margin-bottom":ht,"margin-left":ht,padding:ht,"padding-top":ht,"padding-right":ht,"padding-bottom":ht,"padding-left":ht};function ac(n){if(typeof n!="string")return"";let e=new Map;for(let t of n.slice(0,2e3).split(";")){let r=t.indexOf(":");if(r<0)continue;let o=t.slice(0,r).trim().toLowerCase();o==="background"&&(o="background-color");let i=r1[o]?.(t.slice(r+1).trim());i&&(e.delete(o),e.set(o,i))}return[...e].map(([t,r])=>`${t}: ${r}`).join("; ")}var o1={lang:Ni,dir:lm,xmlns:n=>n==="http://www.w3.org/1999/xhtml"?n:null,"xml:lang":Ni},i1={style:n=>ac(n)||null,class:t1,dir:lm,lang:Ni},am={charset:n=>/^[\w.:-]{1,40}$/.test(n)?n:null,name:n=>im.test(n)?n:null,property:n=>im.test(n)?n:null,"http-equiv":n=>Zx.has(n.toLowerCase())?n:null,content:n=>Sn(n,2e3)},s1={rel:n=>{let e=n.toLowerCase().split(/\s+/).filter(Boolean);return e.length&&e.every(t=>Qx.has(t))?e.join(" "):null},href:n1,type:n=>/^[\w.+-]{1,60}\/[\w.+-]{1,60}$/.test(n)?n:null,media:lc,sizes:n=>/^(?:any|\d{1,4}x\d{1,4}(?:\s+\d{1,4}x\d{1,4}){0,9})$/i.test(n)?n:null,hreflang:Ni,title:lc},l1={media:lc,type:n=>n.toLowerCase()==="text/css"?"text/css":null};function to(n,e){if(!n||typeof n!="object"||Array.isArray(n))return null;let t=n,r={};for(let[o,i]of Object.entries(e)){let s=typeof t[o]=="string"?i(t[o]):null;s!==null&&(r[o]=s)}return Object.keys(r).length?r:null}function a1(n){if(!n||typeof n!="object")return null;let{tag:e,attrs:t,text:r}=n;if(e==="title"){let o=Sn(r,1e3);return o===null?null:{tag:e,text:o.replace(/\s+/g," ").trim()}}if(e==="meta"){let o=to(t,am),i=o&&(o.name??o.property??o["http-equiv"])&&o.content!==void 0;return o&&(o.charset||i)?{tag:e,attrs:o}:null}if(e==="link"){let o=to(t,s1);return o?.rel&&o.href?{tag:e,attrs:o}:null}if(e==="style"){let o=Sn(r,2e5);return o===null?null:{tag:e,attrs:to(t,l1)??{},text:o}}return null}function cc(n){if(!n||typeof n!="object"||Array.isArray(n))return{};let e=n,t={},r=Sn(e.doctype,700)?.trim();r&&sm.test(r)&&(t.doctype=r);let o=to(e.html,o1);o&&(t.html=o);let i=Array.isArray(e.head)?e.head.slice(0,300).map(a1).filter(c=>c!==null):[],s=i.findIndex(c=>c.tag==="title"),l=i.filter((c,u)=>c.tag!=="title"||u===s);l.length&&(t.head=l);let a=to(e.body,i1);return a&&(t.body=a),t}var Oi=(n={})=>Object.entries(n).map(([e,t])=>` ${e}="${eo(t)}"`).join("");function c1(n){return n.tag==="title"?`<title>${wn(n.text)}</title>`:n.tag==="style"?`<style${Oi(n.attrs)}>${n.text.replace(/<\/(style)/gi,"<\\/$1")}</style>`:`<${n.tag}${Oi(n.attrs)}>`}function u1(n){let e=l=>l?Object.fromEntries([...l.attributes].map(a=>[a.name.toLowerCase(),a.value])):{},t=n.doctype,r=t?`<!DOCTYPE ${t.name}${t.publicId?` PUBLIC "${t.publicId}"`:""}${t.systemId?`${t.publicId?"":" SYSTEM"} "${t.systemId}"`:""}>`:void 0,o=[...n.head.children].map(l=>{let a=l.tagName.toLowerCase();return a==="title"||a==="style"?{tag:a,attrs:e(l),text:l.textContent??""}:{tag:a,attrs:e(l)}}),i=e(n.body),s=[i.bgcolor&&`background-color: ${i.bgcolor}`,i.text&&`color: ${i.text}`,i.style].filter(Boolean);return s.length&&(i.style=s.join("; ")),cc({doctype:r,html:e(n.documentElement),head:o,body:i})}var d1=/<!doctype\b|<(?:html|head|body)[\s>/]/i;function cm(n){let e=n.options.pluginOptions?.fullpagehtml??{},t=Sn(e.doctype,700)?.trim();return{doctype:t&&sm.test(t)?t:e1,title:Sn(e.title,1e3)?.replace(/\s+/g," ").trim()??"",encoding:typeof e.encoding=="string"?am.charset(e.encoding)??"":"",bodyStyle:ac(e.bodyStyle),hideInSourceView:e.hideInSourceView===!0}}function p1(n,e){let t=cc(n),r=(t.head??[]).map(c1);e.encoding&&!t.head?.some(i=>i.tag==="meta"&&i.attrs.charset)&&r.unshift(`<meta charset="${eo(e.encoding)}">`),e.title&&!t.head?.some(i=>i.tag==="title")&&r.push(`<title>${wn(e.title)}</title>`);let o={...t.body};return!o.style&&e.bodyStyle&&(o.style=e.bodyStyle),[t.doctype??e.doctype,`<html${Oi(t.html)}>`,"<head>",...r,"</head>",`<body${Oi(o)}>`].join(`
17
+ `)}function f1(n){let e=cm(n);return{inSource:!e.hideInSourceView,read(t){if(!d1.test(t))return null;let r=new DOMParser().parseFromString(t,"text/html");return{content:r.body.innerHTML,attrs:{page:u1(r)}}},write:(t,r)=>`${p1(r.page,e)}
18
18
  ${t}
19
19
  </body>
20
- </html>`}}var rc={name:"fullpagehtml",toolbar:"fullpagehtml",nodeAttributes:{page:{nodes:["doc"],default:null,parse:()=>null,render:()=>({})}},page:e1,load:()=>import(__novaChunk("tinymce-chunks/fullpagehtml-ui-9dd804af.js") )};var em={name:"pagebreak",toolbar:"pagebreak",nodes:{pagebreak:{group:"block",atom:!0,selectable:!0,parseDOM:[{tag:"div.nova-pagebreak"},{tag:"div",getAttrs:n=>{let e=n;return(e.style.breakAfter==="page"||e.style.pageBreakAfter==="always")&&!e.textContent?.trim()?null:!1}}],toDOM:()=>["div",{class:"nova-pagebreak",style:"break-after: page;"}]}},load:()=>import(__novaChunk("tinymce-chunks/pagebreak-ui-7476f5c2.js") )};var dc={};j(dc,{PAGE_SIZES:()=>sc,default:()=>cc,fillBand:()=>r1,pageLayout:()=>o1,resolveBand:()=>lc,resolvePageLayout:()=>ac,setPageCount:()=>i1});var tm=".nova-pages{--nova-desk: #e6e9ed}[data-theme=dark] .nova-pages{--nova-desk: #010409}@media(prefers-color-scheme:dark){.nova-pages:not([data-theme=light] *){--nova-desk: #010409}}.nova-pages .nova-content{position:relative;padding:24px 12px 32px;background:var(--nova-desk)}.nova-pages .nova-prosemirror{box-sizing:border-box;width:var(--nova-page-width);max-width:100%;min-height:max(var(--nova-page-height),var(--nova-pages-height, 0px));margin:0 auto;padding:var(--nova-page-margins);background:var(--nova-bg);color:var(--nova-fg);box-shadow:0 1px 3px #0000002e,0 8px 24px #00000014}@media(max-width:600px){.nova-pages .nova-content{padding:0}.nova-pages .nova-prosemirror{padding:16px;box-shadow:none}}";var sc={A3:[297,420],A4:[210,297],A5:[148,210],A6:[105,148],Letter:[215.9,279.4],Legal:[215.9,355.6]},n1=20;function ic(n,e,t,r){let o=typeof n=="number"?n:typeof n=="string"?Number(n):NaN;return Number.isFinite(o)?Math.min(t,Math.max(e,Math.round(o*10)/10)):r}function Ei(n){return typeof n=="string"?n.replace(/\s+/g," ").trim().slice(0,200):""}function lc(n){let e=null;if(typeof n=="string")e={left:"",center:Ei(n),right:""};else if(typeof n=="object"&&n!==null){let t=n;e={left:Ei(t.left),center:Ei(t.center),right:Ei(t.right)}}return e&&(e.left||e.center||e.right)?e:null}function r1(n,e,t){return n.replace(/\{page\}/g,String(e)).replace(/\{pages\}/g,String(t))}function ac(n={}){let e=typeof n.size=="object"&&n.size!==null,t=!e&&typeof n.size=="string"&&n.size in sc?n.size:"A4",r=n.size,[o,i]=e?[ic(r?.width,30,2e3,210),ic(r?.height,30,2e3,297)]:sc[t];if(n.orientation==="landscape"||n.orientation==="portrait"){let c=n.orientation==="landscape",d=o>i;c!==d&&([o,i]=[i,o])}let s=Math.min(o,i)/3,l=n.margins,a=c=>ic(typeof l=="object"&&l!==null?l[c]:l,0,s,Math.min(n1,s));return{size:e?"custom":t,orientation:o>i?"landscape":"portrait",width:o,height:i,margins:{top:a("top"),right:a("right"),bottom:a("bottom"),left:a("left")},header:lc(n.header),footer:lc(n.footer),differentFirstPage:n.differentFirstPage===!0}}var Ci=new WeakMap;function nm(n){for(let e of[...n.listeners])try{e()}catch(t){console.error("[nova] pagelayout: listener failed",t)}}function rm(n,e){let{style:t}=n.root,{top:r,right:o,bottom:i,left:s}=e.margins;t.setProperty("--nova-page-width",`${e.width}mm`),t.setProperty("--nova-page-height",`${e.height}mm`),t.setProperty("--nova-page-margins",`${r}mm ${o}mm ${i}mm ${s}mm`)}function o1(n){let e=Ci.get(n);if(e)return{get layout(){return e.layout},get pages(){return e.pages},set(t){e.options={...e.options,...t},e.layout=ac(e.options),rm(n,e.layout),nm(e)},onChange(t){return e.listeners.add(t),()=>e.listeners.delete(t)}}}function i1(n,e){let t=Ci.get(n);!t||t.pages===e||(t.pages=e,nm(t))}var cc={name:"pagelayout",setup(n){let e=n.options.pluginOptions?.pagelayout??{},t=ac(e);return Ci.set(n,{options:e,layout:t,pages:null,listeners:new Set}),n.ui.addStyles("nova-pagelayout",tm),n.root.classList.add("nova-pages"),rm(n,t),()=>{Ci.delete(n),n.root.classList.remove("nova-pages")}},load:()=>import(__novaChunk("tinymce-chunks/pagelayout-ui-01757669.js") )};var mc={};j(mc,{default:()=>hc,footnoteId:()=>eo,footnoteNodes:()=>im,footnoteNumber:()=>Ai});var om=".nova-prosemirror sup.mce-footnote a{text-decoration:none}.nova-prosemirror .mce-footnotes{margin-top:2em;font-size:.9em}.nova-prosemirror .mce-footnotes hr{width:30%;margin:0 0 .5em;border:0;border-top:1px solid var(--nova-border)}.nova-prosemirror .mce-footnotes-backlink{margin-inline-end:.35em;text-decoration:none;cursor:pointer;user-select:none}@media print{.nova-prosemirror .mce-footnotes{break-inside:avoid}.nova-prosemirror .mce-footnotes-backlink{display:none}}";function eo(n){let e=typeof n=="string"||typeof n=="number"?String(n):"";return/^[\w-]{1,64}$/.test(e)?e:""}function Ai(n){let e=Math.trunc(Number(n));return Number.isFinite(e)&&e>0?e:1}var uc=(n,e)=>n?.startsWith(e)?eo(n.slice(e.length)):"",im={footnote_ref:{inline:!0,group:"inline",atom:!0,selectable:!0,draggable:!0,attrs:{id:{default:""},number:{default:1}},parseDOM:[{tag:"sup.mce-footnote",priority:60,getAttrs:n=>{let e=n.querySelector("a");return{id:uc(e?.getAttribute("href"),"#footnote-")||uc(e?.getAttribute("id"),"footnote-ref-"),number:Ai((e??n).textContent)}}}],toDOM:n=>{let e=eo(n.attrs.id);return["sup",{class:"mce-footnote"},["a",{href:`#footnote-${e}`,id:`footnote-ref-${e}`,role:"doc-noteref"},String(Ai(n.attrs.number))]]},leafText:n=>`[${Ai(n.attrs.number)}]`},footnotes:{group:"block",content:"footnote+",isolating:!0,selectable:!1,parseDOM:[{tag:"div.mce-footnotes",priority:60,contentElement:n=>n.querySelector("ol, ul")??n}],toDOM:()=>["div",{class:"mce-footnotes",role:"doc-endnotes"},["hr"],["ol",0]]},footnote:{content:"inline*",defining:!0,attrs:{id:{default:""}},parseDOM:[{tag:"a.mce-footnotes-backlink",priority:60,ignore:!0},{tag:"li",context:"footnotes/",priority:60,getAttrs:n=>({id:uc(n.getAttribute("id"),"footnote-")})}],toDOM:n=>{let e=eo(n.attrs.id);return["li",{id:`footnote-${e}`},["a",{class:"mce-footnotes-backlink",href:`#footnote-ref-${e}`,role:"doc-backlink"},"^"],["span",{class:"mce-footnote-text"},0]]}}},pc=class{constructor(){S(this,"dom");S(this,"contentDOM");this.dom=document.createElement("div"),this.dom.className="mce-footnotes",this.dom.setAttribute("role","doc-endnotes");let e=document.createElement("hr");e.contentEditable="false",this.contentDOM=document.createElement("ol"),this.dom.append(e,this.contentDOM)}},fc=class{constructor(e){S(this,"dom");S(this,"contentDOM");let t=eo(e.attrs.id);this.dom=document.createElement("li"),this.dom.id=`footnote-${t}`;let r=document.createElement("a");r.className="mce-footnotes-backlink",r.href=`#footnote-ref-${t}`,r.setAttribute("role","doc-backlink"),r.contentEditable="false",r.textContent="^",this.contentDOM=document.createElement("span"),this.contentDOM.className="mce-footnote-text",this.dom.append(r,this.contentDOM)}},hc={name:"footnotes",nodes:im,prosemirrorPlugins:()=>[new z({key:new Z("nova-footnotes-view"),props:{nodeViews:{footnotes:()=>new pc,footnote:n=>new fc(n)}}})],setup(n){n.ui.addStyles("nova-footnotes",om)},load:()=>import(__novaChunk("tinymce-chunks/footnotes-ui-3f167c2c.js") )};V("insertdatetime",()=>import(__novaChunk("tinymce-chunks/insertdatetime-a48ee6e0.js") ));V("casechange",()=>import(__novaChunk("tinymce-chunks/casechange-8ad6a2c3.js") ));V("formatpainter",()=>import(__novaChunk("tinymce-chunks/formatpainter-cbeeffa7.js") ));V("permanentpen",()=>import(__novaChunk("tinymce-chunks/permanentpen-fc96f445.js") ));V("visualchars",()=>import(__novaChunk("tinymce-chunks/visualchars-7cda4c00.js") ));V("save",()=>import(__novaChunk("tinymce-chunks/save-a65e56cd.js") ));V("markdown",()=>import(__novaChunk("tinymce-chunks/markdown-5698ebec.js") ));V("importcss",()=>import(__novaChunk("tinymce-chunks/importcss-28610ab5.js") ));V("template",()=>import(__novaChunk("tinymce-chunks/template-b522c8ed.js") ));V("spellchecker",()=>import(__novaChunk("tinymce-chunks/spellchecker-91509fc1.js") ));V("autocorrect",()=>import(__novaChunk("tinymce-chunks/autocorrect-907e1296.js") ));V("typography",()=>import(__novaChunk("tinymce-chunks/typography-469ce11a.js") ));V("a11ychecker",()=>import(__novaChunk("tinymce-chunks/a11ychecker-fe78c552.js") ));V("linkchecker",()=>import(__novaChunk("tinymce-chunks/linkchecker-820845fd.js") ));V("advcode",()=>import(__novaChunk("tinymce-chunks/advcode-840793ca.js") ));V("editimage",()=>import(__novaChunk("tinymce-chunks/editimage-36199bc6.js") ));V("email",()=>import(__novaChunk("tinymce-chunks/email2-e9c49586.js") ));V("quickbars",()=>import(__novaChunk("tinymce-chunks/quickbars-35c87c0e.js") ));V("charmap",()=>import(__novaChunk("tinymce-chunks/charmap-5deb524c.js") ));V("emoticons",()=>import(__novaChunk("tinymce-chunks/emoticons-a5ab437d.js") ));V("nonbreaking",()=>import(__novaChunk("tinymce-chunks/nonbreaking-f15226ad.js") ));V("checklist",()=>import(__novaChunk("tinymce-chunks/checklist-5a0c95d3.js") ));V("codesample",()=>import(__novaChunk("tinymce-chunks/codesample-b91dcd91.js") ));V("draghandle",()=>import(__novaChunk("tinymce-chunks/draghandle-a1d99987.js") ));V("autolink",()=>import(__novaChunk("tinymce-chunks/autolink-897e8650.js") ));V("autosave",()=>import(__novaChunk("tinymce-chunks/autosave-60381295.js") ));V("autoresize",()=>import(__novaChunk("tinymce-chunks/autoresize-f8a4a52a.js") ));V("visualblocks",()=>import(__novaChunk("tinymce-chunks/visualblocks-8b7cba25.js") ));V("exportword",()=>import(__novaChunk("tinymce-chunks/exportword-8a03f24d.js") ));V("exportpdf",()=>import(__novaChunk("tinymce-chunks/exportpdf-0c6647bc.js") ));V("importword",()=>import(__novaChunk("tinymce-chunks/importword-ec0b2213.js") ));V("ai",()=>import(__novaChunk("tinymce-chunks/ai2-ddf912a7.js") ));V("anchor",Cp);V("accordion",cl);V("tableofcontents",gl);V("math",fl);V("pagebreak",em);V("pagelayout",cc);V("footnotes",hc);V("media",Ha);V("pageembed",za);V("advtable",qa);V("mediaembed",Ya);V("fullpagehtml",rc);V("comments",sa);V("mentions",ra);V("mergetags",ca);V("suggestions",Ma);V("directionality",()=>import(__novaChunk("tinymce-chunks/directionality-185b3810.js") ));V("advlist",()=>import(__novaChunk("tinymce-chunks/advlist-67b98670.js") ));V("revisionhistory",()=>import(__novaChunk("tinymce-chunks/revisionhistory-741dfb24.js") ));var nu={};j(nu,{API_CHANGE_META:()=>xs,Editor:()=>bo,REMOTE_CHANGE_META:()=>tu,createEditor:()=>ws,parseContent:()=>eu});var am=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function l1(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var a1=(n,e,t)=>{let r=l1(n,t);if(!r)return!1;let o=cm(r);if(!o){let s=r.blockRange(),l=s&&lt(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(um(n,o,e,-1))return!0;if(r.parent.content.size==0&&(rr(i,"end")||R.isSelectable(i)))for(let s=r.depth;;s--){let l=Tr(n.doc,r.before(s),r.after(s),D.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(rr(i,"end")?K.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):R.create(a.doc,o.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1};function rr(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}var c1=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=cm(r)}let s=i&&i.nodeBefore;return!s||!R.isSelectable(s)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function cm(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function d1(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}var u1=(n,e,t)=>{let r=d1(n,t);if(!r)return!1;let o=dm(r);if(!o)return!1;let i=o.nodeAfter;if(um(n,o,e,1))return!0;if(r.parent.content.size==0&&(rr(i,"start")||R.isSelectable(i))){let s=Tr(n.doc,r.before(),r.after(),D.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=n.tr.step(s);l.setSelection(rr(i,"start")?K.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):R.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},p1=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;i=dm(r)}let s=i&&i.nodeAfter;return!s||!R.isSelectable(s)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,i.pos)).scrollIntoView()),!0)};function dm(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}var Ti=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),i=o&&lt(o);return i==null?!1:(e&&e(n.tr.lift(o,i).scrollIntoView()),!0)},f1=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
21
- `).scrollIntoView()),!0)};function yc(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var bc=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),i=t.indexAfter(-1),s=yc(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(K.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},h1=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof ue||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=yc(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=n.tr.insert(s,i.createAndFill());l.setSelection(F.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},m1=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(Et(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),o=r&&lt(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)};function g1(n){return(e,t)=>{if(e.selection instanceof R&&e.selection.node.isBlock){let{$from:f}=e.selection;return!f.parentOffset||!Et(e.doc,f.pos)?!1:(t&&t(e.tr.split(f.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof F||e.selection instanceof ue)&&r.deleteSelection();let{$from:o}=r.selection,i=r.steps.length,s=[],l,a,c=!1,d=!1;for(let f=o.depth;;f--)if(o.node(f).isBlock){c=o.end(f)==o.pos+(o.depth-f),d=o.start(f)==o.pos-(o.depth-f),a=yc(o.node(f-1).contentMatchAt(o.indexAfter(f-1)));let m=n&&n(o.parent,c,o);s.unshift(m||(c&&a?{type:a}:null)),l=f;break}else{if(f==1)return!1;s.unshift(null)}let u=o.pos,p=Et(r.doc,u,s.length,s);if(p||(s[0]=a?{type:a}:null,p=Et(r.doc,u,s.length,s)),!p)return!1;if(r.split(u,s.length,s),!c&&d&&o.node(l).type!=a){let f=r.mapping.slice(i),h=f.map(o.before(l)),m=r.doc.resolve(h);a&&o.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&r.setNodeMarkup(f.map(o.before(l)),a)}return t&&t(r.scrollIntoView()),!0}}var y1=g1();var b1=(n,e)=>(e&&e(n.tr.setSelection(new ue(n.doc))),!0);function k1(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||at(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function um(n,e,t,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&k1(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(t){let f=e.pos+i.nodeSize,h=N.empty;for(let y=s.length-1;y>=0;y--)h=N.from(s[y].create(null,h));h=N.from(o.copy(h));let m=n.tr.step(new re(e.pos-1,f,e.pos,f,new D(h,1,0),s.length,!0)),g=m.doc.resolve(f+2*s.length);g.nodeAfter&&g.nodeAfter.type==o.type&&at(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=i.type.spec.isolating||r>0&&a?null:K.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),p=u&&lt(u);if(p!=null&&p>=e.depth)return t&&t(n.tr.lift(u,p).scrollIntoView()),!0;if(c&&rr(i,"start",!0)&&rr(o,"end")){let f=o,h=[];for(;h.push(f),!f.isTextblock;)f=f.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(f.canReplace(f.childCount,f.childCount,m.content)){if(t){let y=N.empty;for(let M=h.length-1;M>=0;M--)y=N.from(h[M].copy(y));let x=n.tr.step(new re(e.pos-h.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new D(y,h.length,0),0,!0));t(x.scrollIntoView())}return!0}}return!1}function pm(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(t&&t(e.tr.setSelection(F.create(e.doc,n<0?o.start(i):o.end(i)))),!0):!1}}var v1=pm(-1),x1=pm(1);function Ni(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,s=o.blockRange(i),l=s&&sn(s,n,e);return l?(r&&r(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function kc(n,e=null){return function(t,r){let o=!1;for(let i=0;i<t.selection.ranges.length&&!o;i++){let{$from:{pos:s},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(s,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let d=t.doc.resolve(c),u=d.index();o=d.parent.canReplaceWith(u,u+1,n)}})}if(!o)return!1;if(r){let i=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[s];i.setBlockType(l,a,n,e)}r(i.scrollIntoView())}return!0}}function w1(n,e,t,r){for(let o=0;o<e.length;o++){let{$from:i,$to:s}=e[o],l=i.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(i.pos,s.pos,(a,c)=>{if(l||!r&&a.isAtom&&a.isInline&&c>=i.pos&&c+a.nodeSize<=s.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function S1(n){let e=[];for(let t=0;t<n.length;t++){let{$from:r,$to:o}=n[t];r.doc.nodesBetween(r.pos,o.pos,(i,s)=>{if(i.isAtom&&i.content.size&&i.isInline&&s>=r.pos&&s+i.nodeSize<=o.pos)return s+1>r.pos&&e.push(new an(r,r.doc.resolve(s+1))),r=r.doc.resolve(s+1+i.content.size),!1}),r.pos<o.pos&&e.push(new an(r,o))}return e}function Yt(n,e=null,t){let r=(t&&t.removeWhenPresent)!==!1,o=(t&&t.enterInlineAtoms)!==!1,i=!(t&&t.includeWhitespace);return function(s,l){let{empty:a,$cursor:c,ranges:d}=s.selection;if(a&&!c||!w1(s.doc,d,n,o))return!1;if(l)if(c)n.isInSet(s.storedMarks||c.marks())?l(s.tr.removeStoredMark(n)):l(s.tr.addStoredMark(n.create(e)));else{let u,p=s.tr;o||(d=S1(d)),r?u=!d.some(f=>s.doc.rangeHasMark(f.$from.pos,f.$to.pos,n)):u=!d.every(f=>{let h=!1;return p.doc.nodesBetween(f.$from.pos,f.$to.pos,(m,g,y)=>{if(h)return!1;h=!n.isInSet(m.marks)&&!!y&&y.type.allowsMarkType(n)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,f.$from.pos-g),Math.min(m.nodeSize,f.$to.pos-g))))}),!h});for(let f=0;f<d.length;f++){let{$from:h,$to:m}=d[f];if(!u)p.removeMark(h.pos,m.pos,n);else{let g=h.pos,y=m.pos,x=h.nodeAfter,M=m.nodeBefore,L=i&&x&&x.isText?/^\s*/.exec(x.text)[0].length:0,O=i&&M&&M.isText?/\s*$/.exec(M.text)[0].length:0;g+L<y&&(g+=L,y-=O),p.addMark(g,y,n.create(e))}}l(p.scrollIntoView())}return!0}}function or(...n){return function(e,t,r){for(let o=0;o<n.length;o++)if(n[o](e,t,r))return!0;return!1}}var gc=or(am,a1,c1),lm=or(am,u1,p1),Rt={Enter:or(f1,h1,m1,y1),"Mod-Enter":bc,Backspace:gc,"Mod-Backspace":gc,"Shift-Backspace":gc,Delete:lm,"Mod-Delete":lm,"Mod-a":b1},fm={"Ctrl-h":Rt.Backspace,"Alt-Backspace":Rt["Mod-Backspace"],"Ctrl-d":Rt.Delete,"Ctrl-Alt-Backspace":Rt["Mod-Delete"],"Alt-Delete":Rt["Mod-Delete"],"Alt-d":Rt["Mod-Delete"],"Ctrl-a":v1,"Ctrl-e":x1};for(let n in Rt)fm[n]=Rt[n];var M1=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,hm=M1?fm:Rt;var Lc={};j(Lc,{commands:()=>Ke,convertList:()=>Sm,findParentList:()=>wm,getActiveAlign:()=>Xt,getLinkAt:()=>En,insertImage:()=>Oc,isCommandActive:()=>lr,isMarkActive:()=>sr,isNodeActive:()=>Xe,listIndent:()=>Tc,listOutdent:()=>Nc,markRange:()=>Cn,marksOf:()=>ce,nodesOf:()=>X,replaceSelectionWithBlock:()=>Hi,setLink:()=>U1});var Mc={};j(Mc,{closeHistory:()=>R1,history:()=>Sc,isHistoryTransaction:()=>B1,redo:()=>Di,redoDepth:()=>H1,redoNoScroll:()=>_1,undo:()=>Ri,undoDepth:()=>I1,undoNoScroll:()=>D1});var Oi=200,ve=function(){};ve.prototype.append=function(e){return e.length?(e=ve.from(e),!this.length&&e||e.length<Oi&&this.leafAppend(e)||this.length<Oi&&e.leafPrepend(this)||this.appendInner(e)):this};ve.prototype.prepend=function(e){return e.length?ve.from(e).append(this):this};ve.prototype.appendInner=function(e){return new E1(this,e)};ve.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?ve.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};ve.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ve.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};ve.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},t,r),o};ve.from=function(e){return e instanceof ve?e:e&&e.length?new mm(e):ve.empty};var mm=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,s,l){for(var a=i;a<s;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,s,l){for(var a=i-1;a>=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Oi)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Oi)return new e(o.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(ve);ve.empty=new mm([]);var E1=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.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,o,i,s){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(i,l),s)===!1||i>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(o,l),i,s)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(r,o):r>=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,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})(ve),vc=ve;var C1=500,Sn=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;t&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=e.tr,l,a,c=[],d=[];return this.items.forEach((u,p)=>{if(!u.step){o||(o=this.remapping(r,p+1),i=o.maps.length),i--,d.push(u);return}if(o){d.push(new ht(u.map));let f=u.step.map(o.slice(i)),h;f&&s.maybeStep(f).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],c.push(new ht(h,void 0,void 0,c.length+d.length))),i--,h&&o.appendMap(h,i)}else s.maybeStep(u.step);if(u.selection)return l=o?u.selection.map(o.slice(i)):u.selection,a=new n(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&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]),p=new ht(e.mapping.maps[d],u,t),f;(f=a&&a.merge(p))&&(p=f,d?i.pop():l=l.slice(0,l.length-1)),i.push(p),t&&(s++,t=void 0),o||(a=p)}let c=s-r.depth;return c>T1&&(l=A1(l,c),s-=c),new n(l.append(i),s)}remapping(e,t){let r=new _n;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new ht(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;t=Math.min(this.items.length,t);let r=[],o=this.items.length-t,i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},o);let a=t;this.items.forEach(p=>{let f=i.getMirror(--a);if(f==null)return;s=Math.min(s,f);let h=i.maps[f];if(p.step){let m=e.steps[f].invert(e.docs[f]),g=p.selection&&p.selection.map(i.slice(a+1,f));g&&l++,r.push(new ht(h,m,g))}else r.push(new ht(h))},o);let c=[];for(let p=t;p<s;p++)c.push(new ht(i.maps[p]));let d=this.items.slice(0,o).append(c).append(r),u=new n(d,l);return u.emptyItemCount()>C1&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let d=s.selection&&s.selection.map(t.slice(r));d&&i++;let u=new ht(c.invert(),a,d),p,f=o.length-1;(p=o.length&&o[f].merge(u))?o[f]=p:o.push(u)}}else s.map&&r--},this.items.length,0),new n(vc.from(o.reverse()),i)}};Sn.empty=new Sn(vc.empty,0);function A1(n,e){let t;return n.forEach((r,o)=>{if(r.selection&&e--==0)return t=o,!1}),n.slice(t)}var ht=class n{constructor(e,t,r,o){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},mt=class{constructor(e,t,r,o,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},T1=20;function N1(n,e,t,r){let o=t.getMeta(gt),i;if(o)return o.historyState;t.getMeta(bm)&&(n=new mt(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(gt))return s.getMeta(gt).redo?new mt(n.done.addTransform(t,void 0,r,Li(e)),n.undone,gm(t.mapping.maps),n.prevTime,n.prevComposition):new mt(n.done,n.undone.addTransform(t,void 0,r,Li(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!O1(t,n.prevRanges)),c=s?xc(n.prevRanges,t.mapping):gm(t.mapping.maps);return new mt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Li(e)),Sn.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new mt(n.done.rebased(t,i),n.undone.rebased(t,i),xc(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new mt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),xc(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function O1(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,o)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&o>=e[i]&&(t=!0)}),t}function gm(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,o,i,s)=>e.push(i,s));return e}function xc(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let o=e.map(n[r],1),i=e.map(n[r+1],-1);o<=i&&t.push(o,i)}return t}function L1(n,e){for(let t=0;t<e.steps.length;t++){let r=e.mapping.maps[t],o=-1;if(r.forEach((i,s)=>o=s),o<0){let i=e.steps[t];(i instanceof Ue||i instanceof Je)&&(o=i.to)}if(o>-1)return K.near(n.doc.resolve(o))}return n.selection}function P1(n,e,t){let r=Li(e),o=gt.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,L1(e,i.transform).getBookmark(),o,r),a=new mt(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(gt,{redo:t,historyState:a})}var wc=!1,ym=null;function Li(n){let e=n.plugins;if(ym!=e){wc=!1,ym=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){wc=!0;break}}return wc}function R1(n){return n.setMeta(bm,!0)}var gt=new Z("history"),bm=new Z("closeHistory");function Sc(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new z({key:gt,state:{init(){return new mt(Sn.empty,Sn.empty,null,0,-1)},apply(e,t,r){return N1(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,o=r=="historyUndo"?Ri:r=="historyRedo"?Di:null;return!o||!e.editable?!1:(t.preventDefault(),o(e.state,e.dispatch))}}}})}function Pi(n,e){return(t,r)=>{let o=gt.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(r){let i=P1(o,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}var Ri=Pi(!1,!0),Di=Pi(!0,!0),D1=Pi(!1,!1),_1=Pi(!0,!1);function I1(n){let e=gt.getState(n);return e?e.done.eventCount:0}function H1(n){let e=gt.getState(n);return e?e.undone.eventCount:0}function B1(n){return n.getMeta(gt)!=null}var Ac={};j(Ac,{blockUnitAt:()=>Ec,duplicateBlock:()=>$1,moveBlock:()=>_i,selectedBlockUnit:()=>Cc});function Ec(n){for(let e=n.depth;e>0;e--){let t=n.node(e);if(t.type.name==="list_item")return{node:t,pos:n.before(e),depth:e}}if(n.depth===0){let e=n.nodeAfter;return e?{node:e,pos:n.pos,depth:1}:null}return{node:n.node(1),pos:n.before(1),depth:1}}function Cc(n){let{selection:e}=n;return e instanceof R?{node:e.node,pos:e.from,depth:e.$from.depth+1}:e instanceof F?Ec(e.$from):null}function F1(n){let e=Cc(n);if(!e)return null;let{selection:t}=n;if(!(t instanceof R)&&e.node.type.spec.tableRole==="table")return null;let r=n.doc.resolve(e.pos),o=r.parent,i=r.index(),s=i;if(!t.empty&&!(t instanceof R)){let a=Ec(t.$to);if(a&&a.depth===e.depth){let c=n.doc.resolve(a.pos);c.start()===r.start()&&(s=Math.max(i,c.index()))}}let l=e.pos;for(let a=i;a<=s;a++)l+=o.child(a).nodeSize;return{parent:o,startIndex:i,endIndex:s,from:e.pos,to:l}}function z1(n,e,t){let{selection:r}=e;n.setSelection(r instanceof R?R.create(n.doc,r.from+t):F.create(n.doc,r.anchor+t,r.head+t))}function _i(n){return(e,t)=>{let r=F1(e);if(!r)return!1;let{parent:o,startIndex:i,endIndex:s,from:l,to:a}=r,c=n<0?i-1:s+1;if(c<0||c>=o.childCount)return!1;let d=o.child(c),u=[];for(let g=i;g<=s;g++)u.push(o.child(g));let p=N.fromArray(u),f=n<0?p.append(N.from(d)):N.from(d).append(p),h=Math.min(i,c),m=Math.max(s,c);if(!o.canReplace(h,m+1,f))return!1;if(t){let g=n<0?e.tr.replaceWith(l-d.nodeSize,a,f):e.tr.replaceWith(l,a+d.nodeSize,f);z1(g,e,n*d.nodeSize),t(g.scrollIntoView())}return!0}}var $1=(n,e)=>{let t=Cc(n);if(!t||t.node.type.spec.tableRole==="table"&&!(n.selection instanceof R))return!1;let r=t.pos+t.node.nodeSize,o=n.doc.resolve(r);if(!o.parent.canReplaceWith(o.index(),o.index(),t.node.type))return!1;if(e){let i=n.tr.insert(r,t.node);i.setSelection(R.create(i.doc,r)),e(i.scrollIntoView())}return!0};var X=n=>n.schema.nodes,ce=n=>n.schema.marks,to=(n,e)=>(t,r,o)=>e(X(t)[n])(t,r,o),Mn=(n,e)=>(t,r,o)=>e(ce(t)[n])(t,r,o);function Ii(n){return(e,t)=>{let{from:r,to:o}=e.selection,i=e.tr,s=!1;return e.doc.nodesBetween(r,o,(l,a)=>{let c=X(e);(l.type===c.paragraph||l.type===c.heading)&&(s=!0,i=i.setNodeMarkup(a,void 0,{...l.attrs,align:n}))}),s?(t?.(i),!0):!1}}function Hi(n,e){let{$from:t}=n.selection;if(e.isBlock)for(let r=t.depth-1;r>0;r--){let o=t.node(r);if(!o.type.spec.isolating)continue;let i=!1;for(let l=0;l<=o.childCount&&!i;l++)i=o.canReplaceWith(l,l,e.type);if(i)break;let s=t.after(r);return n.insert(s,e),n.setSelection(K.near(n.doc.resolve(s+e.nodeSize)))}return n.replaceSelectionWith(e)}var V1=(n,e)=>(e?.(Hi(n.tr,X(n).horizontal_rule.create()).scrollIntoView()),!0),q1=(n,e)=>{let{from:t,to:r,empty:o,$from:i}=n.selection,s=ce(n);if(o){let l=Cn(n,s.link,i.pos);return l?(e?.(n.tr.removeMark(l.from,l.to,s.link)),!0):!1}return n.doc.rangeHasMark(t,r,s.link)?(e?.(n.tr.removeMark(t,r,s.link)),!0):!1},j1=(n,e)=>{let{from:t,to:r,empty:o}=n.selection;if(o)return!1;if(e){let i=ce(n),s=n.tr;for(let l of Object.values(i))l!==i.link&&(s=s.removeMark(t,r,l));e(s)}return!0};function vm(n){return(e,t)=>{let r=X(e),o=[],{from:i,to:s}=e.selection;if(e.doc.nodesBetween(i,s,(l,a,c)=>{if(l.type!==r.paragraph&&l.type!==r.heading)return!0;if(c?.type!==r.list_item){let d=nr(l.attrs.indent),u=nr(d+n);u!==d&&o.push({pos:a,attrs:{...l.attrs,indent:u}})}return!1}),!o.length)return!1;if(t){let l=e.tr;for(let{pos:a,attrs:c}of o)l.setNodeMarkup(a,void 0,c);t(l.scrollIntoView())}return!0}}var W1=(n,e,t)=>di(X(n).list_item)(n,e,t)||vm(1)(n,e,t),K1=(n,e,t)=>yn(X(n).list_item)(n,e,t)||vm(-1)(n,e,t),Tc=(n,e,t)=>di(X(n).list_item)(n,e,t),Nc=(n,e,t)=>yn(X(n).list_item)(n,e,t);function xm(n,e={}){let t=kc(n,e);return(r,o)=>{if(!t(r))return!1;if(o){let i=r.tr;for(let s of r.selection.ranges)i.setBlockType(s.$from.pos,s.$to.pos,n,l=>({...e,..."align"in n.spec.attrs&&l.attrs.align?{align:l.attrs.align}:{},..."lineHeight"in n.spec.attrs&&l.attrs.lineHeight?{lineHeight:l.attrs.lineHeight}:{},..."dir"in n.spec.attrs&&l.attrs.dir?{dir:l.attrs.dir}:{},..."indent"in n.spec.attrs&&l.attrs.indent?{indent:l.attrs.indent}:{},..."id"in n.spec.attrs&&l.attrs.id?{id:l.attrs.id}:{}}));o(i.scrollIntoView())}return!0}}function ir(n){return to("heading",e=>xm(e,{level:n}))}var Ke={bold:Mn("bold",Yt),italic:Mn("italic",Yt),underline:Mn("underline",Yt),strike:Mn("strike",Yt),code:Mn("code",Yt),subscript:Mn("subscript",Yt),superscript:Mn("superscript",Yt),paragraph:to("paragraph",n=>xm(n)),h1:ir(1),h2:ir(2),h3:ir(3),h4:ir(4),h5:ir(5),h6:ir(6),blockquote:(n,e)=>Xe(n,X(n).blockquote)?Ti(n,e):Ni(X(n).blockquote)(n,e),codeBlock:to("code_block",n=>kc(n)),bulletList:to("bullet_list",km),orderedList:to("ordered_list",km),indent:W1,outdent:K1,alignLeft:Ii(null),alignCenter:Ii("center"),alignRight:Ii("right"),alignJustify:Ii("justify"),horizontalRule:V1,unlink:q1,clearFormatting:j1,undo:Ri,redo:Di,moveBlockUp:_i(-1),moveBlockDown:_i(1)};function wm(n){let e=X(n),{$from:t}=n.selection;for(let r=t.depth;r>0;r--){let o=t.node(r);if(o.type===e.bullet_list||o.type===e.ordered_list)return{node:o,pos:t.before(r)}}return null}function Sm(n,e,t,r=!1){let o=n.doc.type.schema.nodes,i=t===o.bullet_list&&r;return n.setNodeMarkup(e.pos,t,t===o.bullet_list?{listStyle:null,checklist:i}:{start:1}),e.node.forEach((s,l)=>{let a=s.attrs.checked,c=i?typeof a=="boolean"?a:!1:null;c!==a&&n.setNodeMarkup(e.pos+1+l,void 0,{...s.attrs,checked:c})}),n}function km(n){return(e,t)=>{let r=X(e),o=n===r.bullet_list?{checklist:!1}:void 0;if(Xe(e,n,o))return yn(r.list_item)(e,t);let i=wm(e);return i?(t&&t(Sm(e.tr,i,n).scrollIntoView()),!0):pa(n)(e,t)}}function U1(n,e={}){return(t,r)=>{if(!Ie(n))return!1;let{from:o,to:i,empty:s,$from:l}=t.selection,a=ce(t),c=a.link.create({href:n,title:e.title??null,target:e.target??null});if(s){let d=Cn(t,a.link,l.pos);return d?(r?.(t.tr.removeMark(d.from,d.to,a.link).addMark(d.from,d.to,c)),!0):(r?.(t.tr.insert(o,t.schema.text(n,[c]))),!0)}return r?.(t.tr.removeMark(o,i,a.link).addMark(o,i,c)),!0}}function Oc(n,e){return(t,r)=>fe(n)?(r?.(t.tr.replaceSelectionWith(X(t).image.create({src:n,alt:e??null})).scrollIntoView()),!0):!1}function sr(n,e){let{from:t,$from:r,to:o,empty:i}=n.selection;return i?!!e.isInSet(n.storedMarks??r.marks()):n.doc.rangeHasMark(t,o,e)}function Xe(n,e,t){let{$from:r,to:o}=n.selection;for(let i=r.depth;i>0;i--){let s=r.node(i);if(s.type===e&&(!t||Object.entries(t).every(([l,a])=>s.attrs[l]===a)))return o<=r.end(i)}return!1}function Xt(n){return n.selection.$from.parent.attrs.align??"left"}function lr(n,e){let t=n.selection.$from.parent,r=X(n),o=ce(n);switch(e){case"bold":case"italic":case"underline":case"strike":case"code":case"subscript":case"superscript":return sr(n,o[e]);case"paragraph":return t.type===r.paragraph;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return t.type===r.heading&&t.attrs.level===Number(e[1]);case"codeBlock":return t.type===r.code_block;case"blockquote":return Xe(n,r.blockquote);case"bulletList":return Xe(n,r.bullet_list,{checklist:!1});case"orderedList":return Xe(n,r.ordered_list);case"alignLeft":return Xt(n)==="left";case"alignCenter":return Xt(n)==="center";case"alignRight":return Xt(n)==="right";case"alignJustify":return Xt(n)==="justify";default:return!1}}function En(n){let{$from:e}=n.selection,t=ce(n),r=t.link.isInSet(e.marks())??t.link.isInSet(e.nodeAfter?.marks??[]);return r?r.attrs:null}function Cn(n,e,t){let r=n.doc.resolve(t),o=r.start(),i=[];return r.parent.forEach((s,l)=>{if(!e.isInSet(s.marks))return;let a=o+l,c=a+s.nodeSize,d=i[i.length-1];d&&d.to===a?d.to=c:i.push({from:a,to:c})}),i.find(s=>s.from<=t&&t<=s.to)??null}var J1={strong:"bold",b:"bold",em:"italic",i:"italic",u:"underline",s:"strike",strike:"strike",del:"strike",code:"code",sub:"subscript",sup:"superscript"},G1={color:{mark:"color",read:Y.color},"background-color":{mark:"background",read:Y.color},"font-family":{mark:"font_family",read:Y.fontFamily},"font-size":{mark:"font_size",read:Y.length}},qi={p:n=>n.type.name==="paragraph",h1:n=>n.type.name==="heading"&&n.attrs.level===1,h2:n=>n.type.name==="heading"&&n.attrs.level===2,h3:n=>n.type.name==="heading"&&n.attrs.level===3,h4:n=>n.type.name==="heading"&&n.attrs.level===4,h5:n=>n.type.name==="heading"&&n.attrs.level===5,h6:n=>n.type.name==="heading"&&n.attrs.level===6,blockquote:n=>n.type.name==="blockquote",pre:n=>n.type.name==="code_block",img:n=>n.type.name==="image"},Mm=new Set;function ji(n){Mm.has(n)||(Mm.add(n),console.warn(`[nova] formats: ${n}`))}function Ze(n){return Array.isArray(n)?n.flatMap(Ze):typeof n=="string"?n.split(/\s+/).filter(Boolean):[]}function no(n){let e=[];for(let t of n)e.push(...Ze(t.classes)),"items"in t&&t.items&&e.push(...no(t.items));return e}var zi=(n,e)=>{let t=Ze(n);return e.every(r=>t.includes(r))},Bi=(n,e)=>{let t=[...new Set([...Ze(n),...e])];return t.length?t.join(" "):null},Fi=(n,e)=>{let t=Ze(n).filter(r=>!e.includes(r));return t.length?t.join(" "):null};function $i(n){let e={};for(let[t,r]of Object.entries(n.styles??{}))t==="text-align"&&Jr.includes(r)?e.align=r:t==="line-height"&&Y.lineHeight(r)?e.lineHeight=Y.lineHeight(r):ji(`style "${t}" is not supported on blocks`);return e}function Dc(n,e){let t=ce(n),r=[];if(e.inline&&e.inline!=="span"){let i=t[J1[e.inline]];i&&r.push(i.create())}let o=Ze(e.classes);o.length&&t.span_class&&r.push(t.span_class.create({class:o.join(" ")}));for(let[i,s]of Object.entries(e.styles??{})){let l=G1[i],a=l?.read(s),c=l?t[l.mark]:void 0;c&&a?r.push(c.create({value:a})):ji(`style "${i}: ${s}" is not supported on text`)}return r}var Wi=n=>(n.selector??"").split(",").map(e=>e.trim().toLowerCase()).filter(e=>qi[e]?!0:(ji(`selector "${e}" is not supported`),!1));function Ki(n,e){let t=[],r=a=>e.some(c=>qi[c](a)),{selection:o}=n;if(o instanceof R&&r(o.node))return[{node:o.node,pos:o.from}];let{$from:i,from:s,to:l}=o;for(let a=i.depth;a>0;a--){let c=i.node(a);r(c)&&t.push({node:c,pos:i.before(a)})}return n.doc.nodesBetween(s,l,(a,c)=>{r(a)&&!t.some(d=>d.pos===c)&&t.push({node:a,pos:c})}),t}function Pc(n){let e=[],{from:t,to:r}=n.selection;return n.doc.nodesBetween(t,r,(o,i)=>o.isTextblock?(e.push({node:o,pos:i}),!1):!0),e}function _c(n){let{$from:e}=n.selection;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.name==="blockquote")return{node:r,pos:e.before(t)}}return null}function Am(n){return{align:n.align??null,lineHeight:n.lineHeight??null,dir:n.dir??null}}var Vi=class{constructor(e,t){S(this,"editor",e);S(this,"allowedClasses",t);S(this,"registry",new Map)}register(e,t){let r=Array.isArray(t)?t:[t];this.registry.set(e,r),no(r).forEach(o=>this.allowedClasses.add(o))}unregister(e){this.registry.delete(e)}has(e){return this.registry.has(e)}get(e){return this.registry.get(e)}resolve(e){if(typeof e!="string")return[e];let t=this.registry.get(e);return t||ji(`unknown format "${e}"`),t??[]}canApply(e){if(!this.editor.isEditable())return!1;let t=this.editor.view.state;return this.resolve(e).some(r=>Em(t,r))}match(e){let t=this.editor.view.state;return this.resolve(e).some(r=>Y1(t,r))}apply(e){if(!this.editor.isEditable())return!1;let t=this.resolve(e);if(!t.length)return!1;let r=t.find(o=>Em(this.editor.view.state,o))??t[0];return this.run((o,i)=>X1(o,i,r))}remove(e){if(!this.editor.isEditable())return!1;let t=this.resolve(e);return t.length?this.run((r,o)=>t.forEach(i=>Z1(r,o,i))):!1}toggle(e){return this.match(e)?this.remove(e):this.apply(e)}run(e){let{view:t}=this.editor,r=t.state.tr;return e(t.state,r)===!1?!1:((r.docChanged||r.storedMarksSet)&&t.dispatch(r.scrollIntoView()),t.focus(),!0)}};function Em(n,e){return e.selector?Ki(n,Wi(e)).length>0:!0}function Cm(n,e){return n.type.name==="image"?!0:Object.entries($i(e)).every(([t,r])=>n.attrs[t]===r)}function Y1(n,e){let t=Ze(e.classes);if(e.block){if(e.block==="blockquote"){let o=_c(n);return!!o&&zi(o.node.attrs.class,t)}let r=n.selection.$from.parent;return qi[e.block](r)&&zi(r.attrs.class,t)&&Cm(r,e)}if(e.selector){let r=Ki(n,Wi(e));return r.length>0&&r.some(({node:o})=>zi(o.attrs.class,t)&&Cm(o,e))}if(e.inline){let r=Dc(n,e);if(!r.length)return!1;let{$from:o,empty:i,from:s,to:l}=n.selection;if(i){let d=n.storedMarks??o.marks();return r.every(u=>d.some(p=>Rc(p,u)))}let a=!1,c=!0;return n.doc.nodesBetween(s,l,d=>{d.isText&&(a=!0,r.every(u=>d.marks.some(p=>Rc(p,u)))||(c=!1))}),a&&c}return!1}function Rc(n,e){return n.type!==e.type?!1:e.type.name==="span_class"?zi(n.attrs.class,Ze(e.attrs.class)):e.attrs.value===void 0||n.attrs.value===e.attrs.value}function X1(n,e,t){let r=Ze(t.classes),o=X(n);if(t.block==="blockquote"){let i=_c(n);return i?(e.setNodeMarkup(i.pos,void 0,{...i.node.attrs,class:Bi(i.node.attrs.class,r)}),!0):Ni(o.blockquote,{class:Bi(null,r)})(n,s=>s.steps.forEach(l=>e.step(l)))}if(t.block==="pre"){for(let{node:i,pos:s}of Pc(n))i.type!==o.code_block&&e.setNodeMarkup(s,o.code_block,{language:null});return!0}if(t.block){let i=t.block==="p"?0:Number(t.block.slice(1)),s=i?o.heading:o.paragraph,l=$i(t);for(let{node:a,pos:c}of Pc(n)){if(a.type===o.code_block&&a.textContent.includes(`
22
- `))continue;let d=a.type===s&&(!i||a.attrs.level===i);e.setNodeMarkup(c,s,{...Am(a.attrs),...i?{level:i}:{},...l,class:Bi(d?a.attrs.class:null,r)})}return!0}if(t.selector){let i=$i(t),s=Ki(n,Wi(t));if(!s.length)return!1;for(let{node:l,pos:a}of s){let c=l.type.name==="image"?{}:i;e.setNodeMarkup(a,void 0,{...l.attrs,...c,class:Bi(l.attrs.class,r)})}return n.selection instanceof R&&e.setSelection(R.create(e.doc,n.selection.from)),!0}if(t.inline){let i=Dc(n,t);if(!i.length)return!1;let{empty:s,ranges:l}=n.selection;if(s){let a=n.storedMarks??n.selection.$from.marks();for(let c of i)a=c.addToSet(a);return e.setStoredMarks(a),!0}for(let{$from:a,$to:c}of l)for(let d of i)e.addMark(a.pos,c.pos,d);return!0}return!1}function Z1(n,e,t){let r=Ze(t.classes),o=X(n);if(t.block==="blockquote"){let i=_c(n);if(!i)return;let s=Fi(i.node.attrs.class,r);if(r.length&&s!==null){e.setNodeMarkup(i.pos,void 0,{...i.node.attrs,class:s});return}Ti(n,l=>l.steps.forEach(a=>e.step(a)));return}if(t.block){for(let{node:i,pos:s}of Pc(n))qi[t.block](i)&&e.setNodeMarkup(s,o.paragraph,{...Am(i.attrs),class:t.block==="p"?Fi(i.attrs.class,r):null});return}if(t.selector){let i=$i(t);for(let{node:s,pos:l}of Ki(n,Wi(t))){let a={};s.type.name!=="image"&&("align"in i&&s.attrs.align===i.align&&(a.align=null),"lineHeight"in i&&s.attrs.lineHeight===i.lineHeight&&(a.lineHeight=null)),e.setNodeMarkup(l,void 0,{...s.attrs,...a,class:Fi(s.attrs.class,r)})}n.selection instanceof R&&e.setSelection(R.create(e.doc,n.selection.from));return}if(t.inline){let i=Dc(n,t),{empty:s,from:l,to:a,$from:c}=n.selection;if(s){let d=(n.storedMarks??c.marks()).filter(u=>!i.some(p=>Rc(u,p)));e.setStoredMarks(d);return}for(let d of i){if(d.type.name!=="span_class"){e.removeMark(l,a,d.type);continue}n.doc.nodesBetween(l,a,(u,p)=>{if(!u.isText)return;let f=u.marks.find(y=>y.type===d.type);if(!f)return;let h=Math.max(p,l),m=Math.min(p+u.nodeSize,a);e.removeMark(h,m,d.type);let g=Fi(f.attrs.class,Ze(d.attrs.class));g&&e.addMark(h,m,d.type.create({class:g}))})}}}var Hc={};j(Hc,{absolutizeUrls:()=>Pm,attachCss:()=>Ic,loadCss:()=>Ji,scopeCss:()=>Ui,scopeSelector:()=>Lm,splitSelectors:()=>Om,splitTopLevel:()=>Nm});var Q1=/^@(font-face|(-webkit-)?keyframes|property|counter-style|page|font-feature-values|font-palette-values)\b/i,e0=/^@(media|supports|container|layer|document|scope)\b/i;function Nm(n){let e=[],t=0,r=0,o=0,i="";for(;t<n.length;){let s=n[t];if(s==="/"&&n[t+1]==="*"){let l=n.indexOf("*/",t+2),a=l===-1?n.length:l+2;if(o===0){n=n.slice(0,t)+n.slice(a);continue}t=a;continue}if(s==='"'||s==="'"){for(t++;t<n.length&&n[t]!==s;)t+=n[t]==="\\"?2:1;t++;continue}if(s==="{")o===0&&(i=n.slice(r,t).trim(),r=t+1),o++;else if(s==="}")o--,o===0&&(e.push({prelude:i,body:n.slice(r,t)}),r=t+1),o<0&&(o=0);else if(s===";"&&o===0){let l=n.slice(r,t).trim();l&&e.push({prelude:l,body:null}),r=t+1}t++}return e}function Om(n){let e=[],t=0,r="",o=0;for(let i=0;i<n.length;i++){let s=n[i];r?s==="\\"?i++:s===r&&(r=""):s==='"'||s==="'"?r=s:s==="("||s==="["?t++:s===")"||s==="]"?t--:s===","&&t===0&&(e.push(n.slice(o,i)),o=i+1)}return e.push(n.slice(o)),e.map(i=>i.trim()).filter(Boolean)}function Lm(n,e){let t=n,r=!1;for(;;){let o=t.match(/^(html|body|:root)(?![\w-])\s*/i);if(!o)break;r=!0,t=t.slice(o[0].length)}if(!r)return`${e} ${n}`;if(/^[.#[:]/.test(t)){let o=t.search(/[\s>+~]/);return o===-1?`${e}${t}`:`${e}${t.slice(0,o)} ${t.slice(o).trim()}`}return t?`${e} ${t}`:e}function Ui(n,e){let t=[];for(let{prelude:r,body:o}of Nm(n)){if(o===null){/^@layer\b/i.test(r)&&t.push(`${r};`);continue}if(Q1.test(r))t.push(`${r}{${o}}`);else if(e0.test(r))t.push(`${r}{${Ui(o,e)}}`);else{if(r.startsWith("@"))continue;{let i=Om(r).map(s=>Lm(s,e));i.length&&t.push(`${i.join(", ")}{${o}}`)}}}return t.join(`
23
- `)}function Pm(n,e){return n.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi,(t,r,o)=>{if(/^(data:|https?:|\/\/|#)/i.test(o))return t;try{return`url(${r}${new URL(o,e).href}${r})`}catch{return t}})}var Tm=/@import\s+(?:url\(\s*)?(['"]?)([^'")\s;]+)\1\s*\)?([^;]*);/gi;async function Ji(n,e=0){let t=new URL(n,document.baseURI).href,r=await fetch(t);if(!r.ok)throw new Error(`HTTP ${r.status}`);let o=Pm(await r.text(),t);if(e>=3)return o.replace(Tm,"");let i=[...o.matchAll(Tm)];for(let s of i){let l=s[3].trim(),a="";try{a=await Ji(new URL(s[2],t).href,e+1)}catch(c){console.warn(`[nova] contentCss: could not load ${s[2]}`,c)}o=o.replace(s[0],l?`@media ${l}{${a}}`:a)}return o}function Ic(n,e){let t=n.getRootNode();if("adoptedStyleSheets"in t&&typeof CSSStyleSheet<"u"&&"replaceSync"in CSSStyleSheet.prototype)try{let i=new CSSStyleSheet;return i.replaceSync(e),t.adoptedStyleSheets=[...t.adoptedStyleSheets,i],()=>{t.adoptedStyleSheets=t.adoptedStyleSheets.filter(s=>s!==i)}}catch{}let o=document.createElement("style");return o.setAttribute("data-nova-content-css",""),o.textContent=e,n.prepend(o),()=>o.remove()}function Rm(n={}){return new z({view(e){return new Bc(e,n)}})}var Bc=class{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else 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),t=!e.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(t){let u=e.nodeBefore,p=e.nodeAfter;if(u||p){let f=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(f){let h=f.getBoundingClientRect(),m=u?h.bottom:h.top;u&&p&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:h.left,right:h.right,top:m-g,bottom:m+g}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*s;r={left:u.left-p,right:u.left+p,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",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),p=u.width/a.offsetWidth,f=u.height/a.offsetHeight;c=u.left-a.scrollLeft*p,d=u.top-a.scrollTop*f}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,t,e):o;if(!t||i)return null;let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Ar(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}return s}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var Ce=class n extends K{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):K.near(r)}content(){return D.empty}eq(e){return e instanceof n&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(e.resolve(t.pos))}getBookmark(){return new Fc(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!t0(e)||!n0(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&n.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)<l.childCount:e.index(s)>0){i=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=t;let a=e.doc.resolve(o);if(n.valid(a))return a}for(;;){let s=t>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!R.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*t),r=!1;continue e}break}i=s,o+=t;let l=e.doc.resolve(o);if(n.valid(l))return l}return null}}};Ce.prototype.visible=!1;Ce.findFrom=Ce.findGapCursorFrom;K.jsonID("gapcursor",Ce);var Fc=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Ce.valid(t)?new Ce(t):K.near(t)}};function Dm(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function t0(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||Dm(o.type))return!0;if(o.inlineContent)return!1}}return!0}function n0(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||Dm(o.type))return!0;if(o.inlineContent)return!1}}return!0}function _m(){return new z({props:{decorations:s0,createSelectionBetween(n,e,t){return e.pos==t.pos&&Ce.valid(t)?new Ce(t):null},handleClick:o0,handleKeyDown:r0,handleDOMEvents:{beforeinput:i0}}})}var r0=ti({ArrowLeft:Gi("horiz",-1),ArrowRight:Gi("horiz",1),ArrowUp:Gi("vert",-1),ArrowDown:Gi("vert",1)});function Gi(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof F){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=Ce.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new Ce(c))),!0):!1}}function o0(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Ce.valid(r))return!1;let o=n.posAtCoords({left:t.clientX,top:t.clientY});return o&&o.inside>-1&&R.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Ce(r))),!0)}function i0(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Ce))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=N.empty;for(let s=r.length-1;s>=0;s--)o=N.from(r[s].createAndFill(null,o));let i=n.state.tr.replace(t.pos,t.pos,new D(o,0,0));return i.setSelection(F.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function s0(n){if(!(n.selection instanceof Ce))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ae.create(n.doc,[ge.widget(n.selection.head,e,{key:"gapcursor"})])}var ed={};j(ed,{UPLOAD_RETRY_DELAYS:()=>Bm,dataUrlToFile:()=>zm,embeddedImageUploadPlugin:()=>Uc,exitImageCaption:()=>Xc,getSelectedImage:()=>Qe,hasImageCaption:()=>Gc,imageDropPastePlugin:()=>Jc,isSupportedImage:()=>oo,openImageAltDialog:()=>Qc,openImageDialog:()=>io,setImageAttrs:()=>ar,setImageWidthFraction:()=>Zc,toggleImageCaption:()=>Yc,uploadEmbeddedImage:()=>Kc,uploadImages:()=>Yi});var zc={};j(zc,{attachFilePicker:()=>ro});function ro(n,e,t,r){let{filePicker:o,filePickerTypes:i}=n.options;if(!o||i&&!i.includes(t))return;let{input:s}=e,l=w("button",{type:"button",className:"nova-btn nova-input-action","aria-label":n.ui.t("dialog.browse"),title:n.ui.t("dialog.browse")},ee(C.browse)),a=w("div",{className:"nova-input-group"});s.replaceWith(a),a.append(s,l),l.addEventListener("click",async()=>{l.disabled=!0;try{let c=await o({type:t,value:s.value});if(!c?.url)return;s.value=c.url,s.removeAttribute("aria-invalid"),r?.(c)}catch(c){console.error("[nova] filePicker failed:",c)}finally{l.disabled=!1,s.isConnected&&s.focus()}})}var qc={};j(qc,{checkboxField:()=>Vc,openDialog:()=>$c,selectField:()=>l0,textField:()=>Fe});function $c(n){let e=qe("nova-dialog-title"),t=w("p",{className:"nova-dialog-error",role:"alert",hidden:!0}),r=w("button",{type:"submit",className:"nova-button nova-button-primary",hidden:!n.submitLabel},n.submitLabel??""),o=w("button",{type:"button",className:"nova-button"},n.cancelLabel),i=w("button",{type:"button",className:"nova-btn nova-dialog-close","aria-label":n.closeLabel},ee(C.close)),s=w("form",{className:n.size==="large"?"nova-dialog nova-dialog-large":"nova-dialog",role:"dialog","aria-modal":"true","aria-labelledby":e,novalidate:!0},w("header",{className:"nova-dialog-header"},w("h2",{id:e},n.title),i),w("div",{className:"nova-dialog-body"},n.body,t),w("footer",{className:"nova-dialog-footer"},o,r)),l=w("div",{className:"nova-dialog-backdrop"},s);n.host.append(l);let a=!1,c=()=>{a||(a=!0,l.remove(),p(),n.onClose?.(),n.returnFocus?.())},d=h=>{t.hidden=!h,t.textContent=h??""},u=h=>{r.disabled=h,s.setAttribute("aria-busy",String(h))};s.addEventListener("submit",async h=>{h.preventDefault(),d(null),u(!0);try{let m=n.onSubmit?await n.onSubmit():!0;typeof m=="string"?d(m):m!==!1&&c()}finally{a||u(!1)}}),o.addEventListener("click",c),i.addEventListener("click",c),l.addEventListener("mousedown",h=>{h.target===l&&c()}),s.addEventListener("keydown",h=>{if(h.key==="Escape"&&!h.defaultPrevented)h.preventDefault(),h.stopPropagation(),c();else if(h.key==="Tab"){let m=[...s.querySelectorAll(zt)].filter(x=>!x.hidden),g=m[0],y=m[m.length-1];if(!g||!y)return;h.shiftKey&&te(s)===g?(h.preventDefault(),y.focus()):!h.shiftKey&&te(s)===y&&(h.preventDefault(),g.focus())}}),s.tabIndex=-1,s.addEventListener("click",()=>{!a&&!s.contains(te(s))&&s.focus({preventScroll:!0})});let p=ct(s,"focusin",(h,m)=>{let g=m instanceof Element&&m.closest(".nova-dialog")!==null;!s.contains(m)&&!g&&(s.querySelector(zt)??s).focus()});return(n.initialFocus??s.querySelector(".nova-dialog-body input, .nova-dialog-body textarea")??(n.submitLabel?r:o)).focus(),{el:s,close:c,setError:d,setBusy:u}}function Fe(n){let e=qe("nova-field"),t=n.hint?`${e}-hint`:void 0,r=w("input",{id:e,type:n.type??"text",className:"nova-input",value:n.value??"",placeholder:n.placeholder,required:n.required??!1,autocomplete:n.autocomplete??"off",spellcheck:"false","aria-describedby":t});return r.value=n.value??"",{el:w("div",{className:"nova-field"},w("label",{for:e,className:"nova-label"},n.label),r,n.hint?w("p",{id:t,className:"nova-hint"},n.hint):null),input:r}}function Vc(n,e=!1){let t=qe("nova-check"),r=w("input",{id:t,type:"checkbox",className:"nova-checkbox"});return r.checked=e,{el:w("div",{className:"nova-field nova-field-inline"},r,w("label",{for:t},n)),input:r}}function l0(n){let e=qe("nova-field"),t=w("select",{id:e,className:"nova-input nova-select"},...n.options.map(o=>w("option",{value:o.value},o.label)));return t.value=n.value,{el:w("div",{className:"nova-field"},w("label",{for:e,className:"nova-label"},n.label),t),select:t}}var a0=/^image\/(png|jpe?g|gif|webp|avif|bmp)$/;function oo(n){return a0.test(n.type)}function c0(n){return new Promise((e,t)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>t(r.error??new Error("FileReader failed")),r.readAsDataURL(n)})}function jc(n,e){let t=null;return n.state.doc.descendants((r,o)=>t!==null?!1:(r.type===X(n.state).image&&r.attrs.src===e&&(t=o),!0)),t}function Yi(n,e,t){let r=e.filter(oo),o=n.view;for(let i of r){let s=URL.createObjectURL(i),l=X(o.state).image.create({src:s,alt:null}),a=o.state.tr;t!==void 0?a.insert(Math.min(t,a.doc.content.size),l):a.replaceSelectionWith(l),o.dispatch(a.scrollIntoView()),Wc(n,i,s,0)}}var Bm=[1e3,3e3],Xi=class extends Error{};function Wc(n,e,t,r){let o=n.view,{t:i}=n.ui,s=n.options.uploadImage,l=s?n.ui.notify({text:i("image.uploading"),timeout:0}):null,a=s?s(e,u=>l?.setText(`${i("image.uploading")} ${Math.round(u)}%`)):c0(e),c=()=>URL.revokeObjectURL(t),d=()=>{let u=o.isDestroyed?null:jc(o,t);u!==null&&o.dispatch(o.state.tr.delete(u,u+1).setMeta("addToHistory",!1)),c()};a.then(u=>{if(!fe(u))throw new Xi(`Unsafe image URL returned: ${u}`);let p=o.isDestroyed?null:jc(o,t);if(p!==null){let f=o.state.doc.nodeAt(p);o.dispatch(o.state.tr.setNodeMarkup(p,void 0,{...f.attrs,src:u}).setMeta("addToHistory",!1))}c()}).catch(u=>{if(o.isDestroyed||jc(o,t)===null)return c();let p=Bm[r];if(s&&p!==void 0&&!(u instanceof Xi)){let f=n.ui.notify({text:i("image.retrying"),timeout:0});setTimeout(()=>{if(f.close(),o.isDestroyed)return c();Wc(n,e,t,r+1)},p);return}console.error("[nova] image upload failed",u),n.ui.notify({text:i("image.uploadFailed"),type:"error",actions:[{label:i("image.retry"),onAction:()=>Wc(n,e,t,0)},{label:i("image.delete"),onAction:d}],onClose:d})}).finally(()=>l?.close())}var Fm=/^data:(image\/(?:png|jpe?g|gif|webp|avif|bmp));base64,(.+)$/i;function zm(n,e="pasted-image"){let t=n.match(Fm);if(!t)return null;let r=t[1].toLowerCase();try{let o=atob(t[2]),i=new Uint8Array(o.length);for(let l=0;l<o.length;l++)i[l]=o.charCodeAt(l);let s=r.split("/")[1].replace("jpeg","jpg");return new File([i],`${e}.${s}`,{type:r})}catch{return null}}function d0(n,e,t){let r=n.state.tr;n.state.doc.descendants((o,i)=>{o.type===X(n.state).image&&o.attrs.src===e&&r.setNodeMarkup(i,void 0,{...o.attrs,src:t})}),r.docChanged&&n.dispatch(r.setMeta("addToHistory",!1))}async function Kc(n,e){let t=n.options.uploadImage,r=t?zm(e):null;if(!t||!r)return;let o=n.ui.notify({text:n.ui.t("image.uploading"),timeout:0});try{let i=await t(r,s=>o.setText(`${n.ui.t("image.uploading")} ${Math.round(s)}%`));if(!fe(i))throw new Error(`Unsafe image URL returned: ${i}`);d0(n.view,e,i)}catch(i){console.error("[nova] embedded image upload failed",i),n.ui.notify({text:n.ui.t("image.uploadFailed"),type:"error",actions:[{label:n.ui.t("image.retry"),onAction:()=>{Kc(n,e)}}]})}finally{o.close()}}function Im(n,e){let t=new Set;return n.descendants(r=>{r.type===e&&Fm.test(r.attrs.src)&&t.add(r.attrs.src)}),t}function Uc(n){return new z({key:new Z("nova-embedded-image-upload"),appendTransaction(e,t,r){if(!n.options.uploadImage||!e.some(a=>["paste","drop"].includes(a.getMeta("uiEvent")))||!e.some(a=>a.docChanged))return null;let i=X(r).image,s=Im(t.doc,i),l=[...Im(r.doc,i)].filter(a=>!s.has(a));return l.length&&queueMicrotask(()=>l.forEach(a=>{Kc(n,a)})),null}})}function Jc(n){return new z({key:new Z("nova-image-drop-paste"),props:{handlePaste(e,t){if(!n.isAllowed("image"))return!1;let r=t.clipboardData;if(!r||r.getData("text/html"))return!1;let o=[...r.files].filter(oo);return o.length?(Yi(n,o),!0):!1},handleDrop(e,t){if(!n.isAllowed("image"))return!1;let r=[...t.dataTransfer?.files??[]].filter(oo);if(!r.length)return!1;t.preventDefault();let o=e.posAtCoords({left:t.clientX,top:t.clientY});return Yi(n,r,o?.pos),!0}}})}function io(n){let{t:e}=n.ui,t=w("input",{type:"file",accept:"image/png,image/jpeg,image/gif,image/webp,image/avif",className:"nova-visually-hidden",tabindex:"-1","aria-label":e("image.drop"),"aria-hidden":"true"}),r=w("button",{type:"button",className:"nova-dropzone"},ee(C.upload),w("span",{},e("image.drop"))),o=Fe({label:e("image.url"),type:"url",placeholder:"https://"}),i=Fe({label:e("image.alt"),hint:e("image.altHint")});ro(n,o,"image",c=>{c.alt&&(i.input.value=c.alt)});let s=w("div",{className:"nova-form"},r,t,w("div",{className:"nova-divider"},w("span",{},e("image.or"))),o.el,i.el),l=n.ui.openDialog({title:e("image.title"),body:s,submitLabel:e("dialog.insert"),initialFocus:o.input,onSubmit:()=>{let c=o.input.value.trim();return!c||!fe(c)?(o.input.setAttribute("aria-invalid","true"),o.input.focus(),e("image.invalid")):(n.exec(Oc(c,i.input.value.trim()||void 0)),!0)}}),a=c=>{let d=c.filter(oo);d.length&&(l.close(),Yi(n,d))};r.addEventListener("click",()=>t.click()),t.addEventListener("change",()=>a([...t.files??[]])),r.addEventListener("dragover",c=>{c.preventDefault(),r.classList.add("is-dragover")}),r.addEventListener("dragleave",()=>r.classList.remove("is-dragover")),r.addEventListener("drop",c=>{c.preventDefault(),r.classList.remove("is-dragover"),a([...c.dataTransfer?.files??[]])})}function Qe(n){let{selection:e}=n,t=X(n),r=(i,s)=>i.type===t.figure?{node:i,pos:s,attrs:{...i.firstChild?.attrs,align:i.attrs.align}}:{node:i,pos:s,attrs:i.attrs};if(e instanceof R&&(e.node.type===t.image||e.node.type===t.figure))return r(e.node,e.from);let{$from:o}=e;for(let i=o.depth;i>0;i--)if(o.node(i).type===t.figure)return r(o.node(i),o.before(i));return null}function Gc(n){return Qe(n)?.node.type===X(n).figure}var u0=["src","alt","title","width","height"],Hm=n=>Object.fromEntries(u0.map(e=>[e,n[e]??null])),Yc=(n,e)=>{let t=Qe(n);if(!t)return!1;let r=X(n),{pos:o,node:i,attrs:s}=t;if(!e)return!0;let l=n.tr;if(i.type===r.figure){let f=r.image.create({...Hm(s),align:s.align??null}),h=[r.paragraph.create(null,f)],m=i.child(1);return m.content.size&&h.push(r.paragraph.create(null,m.content)),l.replaceWith(o,o+i.nodeSize,h),l.setSelection(R.create(l.doc,o+1)),e(l.scrollIntoView()),!0}let a=n.doc.resolve(o),c=a.before(a.depth),d=a.after(a.depth),u=r.figure.create({align:s.align??null},[r.figure_image.create(Hm(s)),r.figcaption.create()]),p=3;return a.parent.childCount===1?(l.replaceWith(c,d,u),l.setSelection(F.create(l.doc,c+p))):(l.insert(d,u),l.delete(o,o+i.nodeSize),l.setSelection(F.create(l.doc,l.mapping.map(d,-1)+p))),e(l.scrollIntoView()),!0},Xc=(n,e)=>{let{$from:t}=n.selection;if(t.parent.type!==X(n).figcaption)return!1;if(e){let r=t.after(t.depth-1),o=n.tr.insert(r,X(n).paragraph.create());o.setSelection(F.create(o.doc,r+1)),e(o.scrollIntoView())}return!0};function ar(n){return(e,t)=>{let r=Qe(e);if(!r)return!1;if(t){let o=e.tr;if(r.node.type===X(e).figure){let{align:i,...s}=n;if(i!==void 0&&o.setNodeMarkup(r.pos,void 0,{...r.node.attrs,align:i}),Object.keys(s).length){let l=r.node.firstChild;o.setNodeMarkup(r.pos+1,void 0,{...l.attrs,...s})}}else o.setNodeMarkup(r.pos,void 0,{...r.node.attrs,...n}),o.setSelection(R.create(o.doc,r.pos));t(o)}return!0}}function Zc(n,e){let t=Qe(n.view.state);if(!t)return!1;if(e===null)return n.exec(ar({width:null,height:null}));let o=n.view.nodeDOM(t.pos)?.querySelector("img")??null,i=getComputedStyle(n.view.dom),s=n.view.dom.clientWidth-parseFloat(i.paddingLeft||"0")-parseFloat(i.paddingRight||"0"),l=Math.max(24,Math.round(s*e)),a=o&&o.naturalWidth?o.naturalHeight/o.naturalWidth:null;return n.exec(ar({width:l,height:a?Math.round(l*a):null}))}function Qc(n){let e=Qe(n.view.state);if(!e)return;let{t}=n.ui,r=Fe({label:t("image.alt"),value:String(e.attrs.alt??""),hint:t("image.altHint")}),o=Fe({label:t("link.tooltip"),value:String(e.attrs.title??"")});n.ui.openDialog({title:t("image.editAlt"),body:w("div",{className:"nova-form"},r.el,o.el),submitLabel:t("dialog.save"),initialFocus:r.input,onSubmit:()=>(n.exec(ar({alt:r.input.value.trim()||null,title:o.input.value.trim()||null})),!0)})}function p0(n){let e=n.dom.ownerDocument.getSelection(),t=e?.focusNode;if(!e||!t||!n.dom.contains(t))return null;try{return n.posAtDOM(t,e.focusOffset)}catch{return null}}function $m(){let n=!0;return new z({props:{handleDOMEvents:{mousedown(e){return n=e.hasFocus(),!1}},handleClick(e,t,r){if(n||r.button!==0||r.shiftKey||r.detail>1)return!1;let{doc:o}=e.state,i=e.posAtCoords({left:r.clientX,top:r.clientY}),s=i&&i.inside>=0?o.nodeAt(i.inside):null;if(s&&!s.isTextblock)return!1;let l=o.resolve(t),a=p0(e);if(a!==null&&o.resolve(a).parent===l.parent)return!1;let c=K.near(l);return e.state.selection.eq(c)||e.dispatch(e.state.tr.setSelection(c).setMeta("pointer",!0)),e.focus(),!0}}})}var so=new Z("nova-announce");function ie(n){return(e,t,r)=>Ke[n](e,t&&(o=>t(o.setMeta(so,n))),r)}var f0=new Set(["bold","italic","underline","strike","code","subscript","superscript","bulletList","orderedList"]),h0=new Set(["paragraph","h1","h2","h3","h4","h5","h6"]),Vm=["alignLeft","alignCenter","alignRight","alignJustify"];function td(n){let{$from:e}=n.selection,t=[];for(let r=1;r<=e.depth;r++){let o=e.node(r),i=o.type.name;i==="bullet_list"?t.push("bulletList"):i==="ordered_list"?t.push("orderedList"):i==="blockquote"?t.push("blockquote"):i==="code_block"?t.push("codeBlock"):i==="heading"&&t.push(`h${Math.min(6,Math.max(1,Number(o.attrs.level)||1))}`)}return t}function m0(n,e,t){if(f0.has(e))return t(lr(n,e)?"announce.on":"announce.off",{name:t(e)});if(h0.has(e)){let r=td(n).filter(o=>/^h[1-6]$/.test(o)).pop();return t(r??"paragraph")}return Vm.includes(e)?t(Vm.find(r=>lr(n,r))??"alignLeft"):t(e)}function g0(n,e,t){let r=td(n),o=td(e),i=o.findIndex((s,l)=>s!==r[l]);return i<0?null:t(o[i])}function qm(n,e){return new z({key:so,state:{init:()=>null,apply(t,r,o,i){let s=t.getMeta(so);return s?{command:s}:i.plugins.some(l=>l.spec.isInputRules&&t.getMeta(l))?{typed:!0}:null}},view:()=>({update(t,r){let o=so.getState(t.state);if(!o||o===so.getState(r))return;let i="command"in o?m0(t.state,o.command,n):g0(r,t.state,n);i&&e(i)}})})}var Wm={options:{},commands:{},events:{}},Km={options:"the option",commands:"the command",events:"the event"},jm=new Set;function Um(n,e){jm.has(n)||(jm.add(n),console.warn(`[nova] ${n} is deprecated: use ${e}. Old names keep working for at least one minor version (https://novaprose.com/project/versioning/).`))}var y0=(n,e)=>Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0;function lo(n,e,t=Wm){let r=y0(t[n],e);return r===void 0?e:(Um(`${Km[n]} "${e}"`,`"${r}"`),r)}function Jm(n,e=Wm){let t=n;for(let[r,o]of Object.entries(e.options))Object.prototype.hasOwnProperty.call(n,r)&&(Um(`${Km.options} "${r}"`,`"${o}"`),t===n&&(t={...t}),Object.prototype.hasOwnProperty.call(t,o)||(t[o]=t[r]),delete t[r]);return t}var id={};j(id,{InputRule:()=>et,closeDoubleQuote:()=>Xm,closeSingleQuote:()=>Qm,ellipsis:()=>od,emDash:()=>rd,inputRules:()=>nd,openDoubleQuote:()=>Ym,openSingleQuote:()=>Zm,smartQuotes:()=>x0,textblockTypeInputRule:()=>Zi,undoInputRule:()=>v0,wrappingInputRule:()=>ao});var et=class{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?b0(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}};function b0(n){return function(e,t,r,o){let i=n;if(t[1]){let s=t[0].lastIndexOf(t[1]);i+=t[0].slice(s+t[1].length),r+=s;let l=r-o;l>0&&(i=t[0].slice(s-l,s)+i,r=o)}return e.tr.insertText(i,r,o)}}var k0=500;function nd({rules:n}){let e=new z({state:{init(){return null},apply(t,r){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,o,i){return Gm(t,r,o,i,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&Gm(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function Gm(n,e,t,r,o,i){if(n.composing)return!1;let s=n.state,l=s.doc.resolve(e),a=n.state.selection,c=l.parent.textBetween(Math.max(0,l.parentOffset-k0),l.parentOffset,null,"\uFFFC")+r,d=e==a.from&&t==a.to&&n.state.storedMarks||(e==t?l.marks():l.marksAcross(s.doc.resolve(t))||[]);for(let u=0;u<o.length;u++){let p=o[u];if(!p.inCodeMark&&d.some(g=>g.type.spec.code))continue;if(l.parent.type.spec.code){if(!p.inCode)continue}else if(p.inCode==="only")continue;let f=p.match.exec(c);if(!f||f[0].length<r.length)continue;let h=e-(f[0].length-r.length);if(!p.inCodeMark){let g=!1;if(s.doc.nodesBetween(h,l.pos,y=>{y.isInline&&y.marks.some(x=>x.type.spec.code)&&(g=!0)}),g)continue}let m=p.handler(s,f,h,t,r);if(m)return p.undoable&&m.setMeta(i,{transform:m,from:e,to:t,text:r}),n.dispatch(m),!0}return!1}var v0=(n,e)=>{let t=n.plugins;for(let r=0;r<t.length;r++){let o=t[r],i;if(o.spec.isInputRules&&(i=o.getState(n))){if(e){let s=n.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a--)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,n.schema.text(i.text,a))}else s.delete(i.from,i.to);e(s)}return!0}}return!1},rd=new et(/--$/,"\u2014",{inCodeMark:!1}),od=new et(/\.\.\.$/,"\u2026",{inCodeMark:!1}),Ym=new et(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),Xm=new et(/"$/,"\u201D",{inCodeMark:!1}),Zm=new et(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),Qm=new et(/'$/,"\u2019",{inCodeMark:!1}),x0=[Ym,Xm,Zm,Qm];function ao(n,e,t,r){let o,i;return e instanceof it?i=e:(o=e,i=e.nodeType,t=e.getAttrs,r=e.joinPredicate),new et(n,(s,l,a,c)=>{let d=t instanceof Function?t(l):t,u=s.tr.delete(a,c),p=u.doc.resolve(a),f=p.blockRange(),h=f&&sn(f,i,d);if(!h)return null;u.wrap(f,h);let m=u.doc.resolve(a-1).nodeBefore;return m&&m.type==i&&at(u.doc,a-1)&&(!r||r(l,m))&&u.join(a-1),u},o)}function Zi(n,e,t){let r,o;return e instanceof it?o=e:(r=e,o=e.nodeType,t=e.getAttrs),new et(n,(i,s,l,a)=>{let c=i.doc.resolve(l),d=t instanceof Function?t(s):t;return c.node(-1).canReplaceWith(c.index(-1),c.indexAfter(-1),o)?i.tr.delete(l,a).setBlockType(l,l,o,d):null},r)}var eg="([A-Za-z0-9_+#.-]{0,32})";function tg(n=()=>!0,e=Ot){let{nodes:t}=e,r=[od,rd];n("blockquote")&&r.push(ao(/^\s*>\s$/,t.blockquote)),n("numlist")&&r.push(ao(/^(\d+)\.\s$/,t.ordered_list,o=>({start:Number(o[1])}),(o,i)=>i.childCount+i.attrs.start===Number(o[1]))),n("bullist")&&r.push(ao(/^\s*([-+*])\s$/,t.bullet_list)),n("codeblock")&&r.push(Zi(new RegExp(`^\`\`\`${eg}\\s$`),t.code_block,o=>({language:o[1]||null})));for(let o=1;o<=6;o++)n(`h${o}`)&&r.push(Zi(new RegExp(`^(#{${o}})\\s$`),t.heading,{level:o}));return nd({rules:r})}function ng(n=()=>!0,e=Ot){let t=new RegExp(`^\`\`\`${eg}$`);return We({Enter:(o,i)=>{let{$from:s,empty:l}=o.selection,a=s.parent;if(!l||a.type!==e.nodes.paragraph||!n("codeblock")||s.parentOffset!==a.content.size||a.childCount!==1)return!1;let c=a.firstChild.isText?t.exec(a.textContent):null;if(!c)return!1;let d=s.index(-1);if(!s.node(-1).canReplaceWith(d,d+1,e.nodes.code_block))return!1;if(i){let u=s.start(),p=o.tr.delete(u,s.pos).setBlockType(u,u,e.nodes.code_block,{language:c[1]||null});i(p.scrollIntoView())}return!0}})}var rg={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike",strike:"strike",code:"code",subscript:"subscript",superscript:"superscript",p:"paragraph",paragraph:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",blockquote:"blockquote",pre:"codeBlock"};function og(n){let e=[];for(let t of n){let r=t;if(!(!r||typeof r.start!="string"||!r.start||r.start.length>40))if(typeof r.replacement=="string")e.push({start:r.start,replacement:r.replacement});else{if(typeof r.format!="string"&&!r.command)continue;typeof r.end=="string"&&r.end,e.push(r)}}return e.sort((t,r)=>r.start.length-t.start.length)}function w0(n){let{$from:e,empty:t}=n.selection;return!t||!e.parent.isTextblock||e.parent.type.spec.code||e.marks().some(r=>r.type.spec.code)?null:e.parent.textBetween(0,e.parentOffset,void 0,"\uFFFC")}function ig(n,e){let{format:t,command:r,value:o}=e;typeof r=="function"?r(n,o):typeof r=="string"?n.exec(r):t&&n.formatter.has(t)?n.formatter.apply(t):t&&rg[t]&&n.exec(rg[t])}function sg(n,e,t){let r=og(e),o=(s,l)=>{if(!t)return r;let{$from:a}=s.state.selection,c=s.nodeDOM(a.before()),d=[];try{d=t({text:l,block:c instanceof HTMLElement?c:null})}catch(u){console.error("[nova] textPatternsLookup failed:",u)}return Array.isArray(d)?og([...r,...d]):r},i=(s,l)=>{let a=w0(s.state);if(a===null||!n.isEditable())return null;let{$from:c}=s.state.selection,d=c.start();for(let u of o(s,a)){if("replacement"in u){if(!a.endsWith(u.start))continue;let f=c.pos-u.start.length;return/<[a-z]/i.test(u.replacement)?(s.dispatch(s.state.tr.delete(f,c.pos)),n.insertContent(u.replacement),s.dispatch(s.state.tr.setStoredMarks([]))):s.dispatch(s.state.tr.insertText(u.replacement,f,c.pos)),"replacement"}if("end"in u){if(!a.endsWith(u.end))continue;let f=a.lastIndexOf(u.start,a.length-u.end.length-1),h=f+u.start.length,m=a.length-u.end.length;if(f<0||m<=h||/^\s|\s$/.test(a.slice(h,m)))continue;let g=s.state.tr.delete(d+m,d+a.length).delete(d+f,d+h),y=d+f,x=y+(m-h);s.dispatch(g.setSelection(F.create(g.doc,y,x))),ig(n,u);let{state:M}=s;return s.dispatch(M.tr.setSelection(F.create(M.doc,M.selection.to))),s.dispatch(s.state.tr.setStoredMarks([])),"inline"}if(!((u.trigger??"space")!==l||!(l==="space"?a===u.start:c.parent.textContent.startsWith(u.start)&&c.parentOffset===c.parent.content.size)))return s.dispatch(s.state.tr.delete(d,d+u.start.length)),ig(n,u),"block"}return null};return new z({props:{handleTextInput(s,l,a,c){if(c!==" "||l!==a)return!1;let d=i(s,"space");return d?(d!=="block"&&s.dispatch(s.state.tr.insertText(" ")),!0):!1},handleKeyDown(s,l){return l.key!=="Enter"||l.shiftKey||l.ctrlKey||l.metaKey||i(s,"enter"),!1}}})}var S0=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),M0=or(bc,(n,e)=>(e?.(n.tr.replaceSelectionWith(X(n).hard_break.create()).scrollIntoView()),!0)),sd=(n,e)=>(t,r,o)=>n(e)(t,r,o);function lg(n=e=>Ke[e]){let e={"Mod-z":sd(n,"undo"),"Shift-Mod-z":sd(n,"redo"),"Mod-b":ie("bold"),"Mod-i":ie("italic"),"Mod-u":ie("underline"),"Mod-Shift-x":ie("strike"),"Mod-e":ie("code"),"Mod-,":ie("subscript"),"Mod-.":ie("superscript"),"Mod-Alt-0":ie("paragraph"),"Mod-Alt-1":ie("h1"),"Mod-Alt-2":ie("h2"),"Mod-Alt-3":ie("h3"),"Mod-Alt-4":ie("h4"),"Mod-Alt-5":ie("h5"),"Mod-Alt-6":ie("h6"),"Mod-Shift-7":ie("orderedList"),"Mod-Shift-8":ie("bulletList"),"Mod-Shift-l":ie("alignLeft"),"Mod-Shift-e":ie("alignCenter"),"Mod-Shift-r":ie("alignRight"),"Mod-Shift-j":ie("alignJustify"),"Mod-\\":ie("clearFormatting"),"Shift-Enter":M0,Enter:or(Xc,(t,r)=>{let i=typeof E0(t)?.attrs.checked=="boolean"?{checked:!1}:void 0;return ci(X(t).list_item,i)(t,r)}),Tab:Tc,"Shift-Tab":Nc,"Mod-]":Ke.indent,"Mod-[":Ke.outdent,"Alt-Shift-ArrowUp":Ke.moveBlockUp,"Alt-Shift-ArrowDown":Ke.moveBlockDown};return S0||(e["Mod-y"]=sd(n,"redo")),[We(e),We(hm)]}function E0(n){let{$from:e}=n.selection;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type===X(n).list_item)return r}return null}var cd={};j(cd,{applyLink:()=>ag,normalizeUrl:()=>ld,openLinkDialog:()=>Dt,removeLink:()=>cr});function ld(n){let e=n.trim();return e?/^[a-z][a-z0-9+.-]*:/i.test(e)||/^[/#?.]/.test(e)?e:/^[^\s@/]+@[^\s@/]+\.[^\s@/]+$/.test(e)?`mailto:${e}`:/^(www\.)?[^\s/]+\.[a-z]{2,}([/:?#].*)?$/i.test(e)?`https://${e}`:e:""}function ad(n){let{from:e,to:t,empty:r,$from:o}=n.selection;return r?Cn(n,ce(n).link,o.pos)??{from:e,to:t}:{from:e,to:t}}function ag(n){return(e,t)=>{let r=ld(n.href);if(!r||!Ie(r))return!1;if(!t)return!0;let{from:o,to:i}=ad(e),s=ce(e).link.create({href:r,title:n.title||null,target:n.target||null}),l=e.doc.textBetween(o,i),a=n.text?.trim()?n.text:null,c=e.tr;if(o===i||a!==null&&a!==l){let d=ce(e).link.removeFromSet(e.doc.resolve(o).marks()),u=e.schema.text(a??(l||r),s.addToSet(d));c.replaceWith(o,i,u)}else c.removeMark(o,i,ce(e).link).addMark(o,i,s);return t(c.scrollIntoView()),!0}}function cr(){return(n,e)=>{let{from:t,to:r}=ad(n);return t===r||!n.doc.rangeHasMark(t,r,ce(n).link)?!1:(e?.(n.tr.removeMark(t,r,ce(n).link)),!0)}}function Dt(n){let{t:e}=n.ui,t=n.view.state,r=En(t),o=ad(t),i=t.doc.textBetween(o.from,o.to),s=!i.includes(`
24
- `)&&t.selection.$from.sameParent(t.doc.resolve(o.to)),l=Fe({label:e("link.url"),type:"url",value:r?.href??"",placeholder:"https://",required:!0}),a=Fe({label:e("link.text"),value:i}),c=Fe({label:e("link.tooltip"),value:r?.title??""}),d=Vc(e("link.newTab"),r?.target==="_blank");ro(n,l,"file",p=>{p.text&&!a.input.value.trim()&&(a.input.value=p.text),p.title&&(c.input.value=p.title)});let u=w("div",{className:"nova-form"},l.el,s?a.el:null,c.el,d.el);n.ui.openDialog({title:e(r?"link.editTitle":"link.title"),body:u,submitLabel:e(r?"dialog.save":"dialog.insert"),initialFocus:l.input,onSubmit:()=>{let p=ld(l.input.value);return!p||!Ie(p)?(l.input.setAttribute("aria-invalid","true"),l.input.focus(),e("link.invalid")):(n.exec(ag({href:p,...s?{text:a.input.value}:{},title:c.input.value.trim()||null,target:d.input.checked?"_blank":null})),!0)}})}function cg(n){return/<img[^>]+src=["']?file:/i.test(n)}var yt=null,Qi=null;function dd(){return Qi??(Qi=import(__novaChunk("tinymce-chunks/paste-office-d6821891.js") ).then(n=>yt=n,()=>(Qi=null,null))),Qi}var C0=new Z("nova-paste");function A0(n){let e=document.createElement("template");e.innerHTML=n;let t=/^(P|DIV|H[1-6]|LI|BLOCKQUOTE|PRE|TR|SECTION|ARTICLE|HEADER|FOOTER)$/,r="",o=i=>{if(i.nodeType===Node.TEXT_NODE){r+=(i.textContent??"").replace(/\s+/g," ");return}if(!(i instanceof Element)){i.childNodes.forEach(o);return}if(/^(SCRIPT|STYLE|META|TITLE|HEAD)$/.test(i.tagName))return;if(i.tagName==="BR"){r+=`
20
+ </html>`}}var uc={name:"fullpagehtml",toolbar:"fullpagehtml",nodeAttributes:{page:{nodes:["doc"],default:null,parse:()=>null,render:()=>({})}},page:f1,load:()=>import(__novaChunk("tinymce-chunks/fullpagehtml-ui-9dd804af.js") )};var um={name:"pagebreak",toolbar:"pagebreak",nodes:{pagebreak:{group:"block",atom:!0,selectable:!0,parseDOM:[{tag:"div.nova-pagebreak"},{tag:"div",getAttrs:n=>{let e=n;return(e.style.breakAfter==="page"||e.style.pageBreakAfter==="always")&&!e.textContent?.trim()?null:!1}}],toDOM:()=>["div",{class:"nova-pagebreak",style:"break-after: page;"}]}},load:()=>import(__novaChunk("tinymce-chunks/pagebreak-ui-7476f5c2.js") )};var yc={};q(yc,{PAGE_SIZES:()=>fc,default:()=>gc,fillBand:()=>g1,pageLayout:()=>y1,resolveBand:()=>hc,resolvePageLayout:()=>mc,setPageCount:()=>b1});var dm=".nova-pages{--nova-desk: #e6e9ed}[data-theme=dark] .nova-pages{--nova-desk: #010409}@media(prefers-color-scheme:dark){.nova-pages:not([data-theme=light] *){--nova-desk: #010409}}.nova-pages .nova-content{position:relative;padding:24px 12px 32px;background:var(--nova-desk)}.nova-pages .nova-prosemirror{box-sizing:border-box;width:var(--nova-page-width);max-width:100%;min-height:max(var(--nova-page-height),var(--nova-pages-height, 0px));margin:0 auto;padding:var(--nova-page-margins);background:var(--nova-bg);color:var(--nova-fg);box-shadow:0 1px 3px #0000002e,0 8px 24px #00000014}@media(max-width:600px){.nova-pages .nova-content{padding:0}.nova-pages .nova-prosemirror{padding:16px;box-shadow:none}}";var fc={A3:[297,420],A4:[210,297],A5:[148,210],A6:[105,148],Letter:[215.9,279.4],Legal:[215.9,355.6]},m1=20;function pc(n,e,t,r){let o=typeof n=="number"?n:typeof n=="string"?Number(n):NaN;return Number.isFinite(o)?Math.min(t,Math.max(e,Math.round(o*10)/10)):r}function Li(n){return typeof n=="string"?n.replace(/\s+/g," ").trim().slice(0,200):""}function hc(n){let e=null;if(typeof n=="string")e={left:"",center:Li(n),right:""};else if(typeof n=="object"&&n!==null){let t=n;e={left:Li(t.left),center:Li(t.center),right:Li(t.right)}}return e&&(e.left||e.center||e.right)?e:null}function g1(n,e,t){return n.replace(/\{page\}/g,String(e)).replace(/\{pages\}/g,String(t))}function mc(n={}){let e=typeof n.size=="object"&&n.size!==null,t=!e&&typeof n.size=="string"&&n.size in fc?n.size:"A4",r=n.size,[o,i]=e?[pc(r?.width,30,2e3,210),pc(r?.height,30,2e3,297)]:fc[t];if(n.orientation==="landscape"||n.orientation==="portrait"){let c=n.orientation==="landscape",u=o>i;c!==u&&([o,i]=[i,o])}let s=Math.min(o,i)/3,l=n.margins,a=c=>pc(typeof l=="object"&&l!==null?l[c]:l,0,s,Math.min(m1,s));return{size:e?"custom":t,orientation:o>i?"landscape":"portrait",width:o,height:i,margins:{top:a("top"),right:a("right"),bottom:a("bottom"),left:a("left")},header:hc(n.header),footer:hc(n.footer),differentFirstPage:n.differentFirstPage===!0}}var Pi=new WeakMap;function pm(n){for(let e of[...n.listeners])try{e()}catch(t){console.error("[nova] pagelayout: listener failed",t)}}function fm(n,e){let{style:t}=n.root,{top:r,right:o,bottom:i,left:s}=e.margins;t.setProperty("--nova-page-width",`${e.width}mm`),t.setProperty("--nova-page-height",`${e.height}mm`),t.setProperty("--nova-page-margins",`${r}mm ${o}mm ${i}mm ${s}mm`)}function y1(n){let e=Pi.get(n);if(e)return{get layout(){return e.layout},get pages(){return e.pages},set(t){e.options={...e.options,...t},e.layout=mc(e.options),fm(n,e.layout),pm(e)},onChange(t){return e.listeners.add(t),()=>e.listeners.delete(t)}}}function b1(n,e){let t=Pi.get(n);!t||t.pages===e||(t.pages=e,pm(t))}var gc={name:"pagelayout",setup(n){let e=n.options.pluginOptions?.pagelayout??{},t=mc(e);return Pi.set(n,{options:e,layout:t,pages:null,listeners:new Set}),n.ui.addStyles("nova-pagelayout",dm),n.root.classList.add("nova-pages"),fm(n,t),()=>{Pi.delete(n),n.root.classList.remove("nova-pages")}},load:()=>import(__novaChunk("tinymce-chunks/pagelayout-ui-01757669.js") )};var wc={};q(wc,{default:()=>xc,footnoteId:()=>no,footnoteNodes:()=>mm,footnoteNumber:()=>Ri});var hm=".nova-prosemirror sup.mce-footnote a{text-decoration:none}.nova-prosemirror .mce-footnotes{margin-top:2em;font-size:.9em}.nova-prosemirror .mce-footnotes hr{width:30%;margin:0 0 .5em;border:0;border-top:1px solid var(--nova-border)}.nova-prosemirror .mce-footnotes-backlink{margin-inline-end:.35em;text-decoration:none;cursor:pointer;user-select:none}@media print{.nova-prosemirror .mce-footnotes{break-inside:avoid}.nova-prosemirror .mce-footnotes-backlink{display:none}}";function no(n){let e=typeof n=="string"||typeof n=="number"?String(n):"";return/^[\w-]{1,64}$/.test(e)?e:""}function Ri(n){let e=Math.trunc(Number(n));return Number.isFinite(e)&&e>0?e:1}var bc=(n,e)=>n?.startsWith(e)?no(n.slice(e.length)):"",mm={footnote_ref:{inline:!0,group:"inline",atom:!0,selectable:!0,draggable:!0,attrs:{id:{default:""},number:{default:1}},parseDOM:[{tag:"sup.mce-footnote",priority:60,getAttrs:n=>{let e=n.querySelector("a");return{id:bc(e?.getAttribute("href"),"#footnote-")||bc(e?.getAttribute("id"),"footnote-ref-"),number:Ri((e??n).textContent)}}}],toDOM:n=>{let e=no(n.attrs.id);return["sup",{class:"mce-footnote"},["a",{href:`#footnote-${e}`,id:`footnote-ref-${e}`,role:"doc-noteref"},String(Ri(n.attrs.number))]]},leafText:n=>`[${Ri(n.attrs.number)}]`},footnotes:{group:"block",content:"footnote+",isolating:!0,selectable:!1,parseDOM:[{tag:"div.mce-footnotes",priority:60,contentElement:n=>n.querySelector("ol, ul")??n}],toDOM:()=>["div",{class:"mce-footnotes",role:"doc-endnotes"},["hr"],["ol",0]]},footnote:{content:"inline*",defining:!0,attrs:{id:{default:""}},parseDOM:[{tag:"a.mce-footnotes-backlink",priority:60,ignore:!0},{tag:"li",context:"footnotes/",priority:60,getAttrs:n=>({id:bc(n.getAttribute("id"),"footnote-")})}],toDOM:n=>{let e=no(n.attrs.id);return["li",{id:`footnote-${e}`},["a",{class:"mce-footnotes-backlink",href:`#footnote-ref-${e}`,role:"doc-backlink"},"^"],["span",{class:"mce-footnote-text"},0]]}}},kc=class{constructor(){S(this,"dom");S(this,"contentDOM");this.dom=document.createElement("div"),this.dom.className="mce-footnotes",this.dom.setAttribute("role","doc-endnotes");let e=document.createElement("hr");e.contentEditable="false",this.contentDOM=document.createElement("ol"),this.dom.append(e,this.contentDOM)}},vc=class{constructor(e){S(this,"dom");S(this,"contentDOM");let t=no(e.attrs.id);this.dom=document.createElement("li"),this.dom.id=`footnote-${t}`;let r=document.createElement("a");r.className="mce-footnotes-backlink",r.href=`#footnote-ref-${t}`,r.setAttribute("role","doc-backlink"),r.contentEditable="false",r.textContent="^",this.contentDOM=document.createElement("span"),this.contentDOM.className="mce-footnote-text",this.dom.append(r,this.contentDOM)}},xc={name:"footnotes",nodes:mm,prosemirrorPlugins:()=>[new z({key:new X("nova-footnotes-view"),props:{nodeViews:{footnotes:()=>new kc,footnote:n=>new vc(n)}}})],setup(n){n.ui.addStyles("nova-footnotes",hm)},load:()=>import(__novaChunk("tinymce-chunks/footnotes-ui-3f167c2c.js") )};j("insertdatetime",()=>import(__novaChunk("tinymce-chunks/insertdatetime-a48ee6e0.js") ));j("casechange",()=>import(__novaChunk("tinymce-chunks/casechange-8ad6a2c3.js") ));j("formatpainter",()=>import(__novaChunk("tinymce-chunks/formatpainter-cbeeffa7.js") ));j("permanentpen",()=>import(__novaChunk("tinymce-chunks/permanentpen-fc96f445.js") ));j("visualchars",()=>import(__novaChunk("tinymce-chunks/visualchars-7cda4c00.js") ));j("save",()=>import(__novaChunk("tinymce-chunks/save-a65e56cd.js") ));j("markdown",()=>import(__novaChunk("tinymce-chunks/markdown-5698ebec.js") ));j("importcss",()=>import(__novaChunk("tinymce-chunks/importcss-28610ab5.js") ));j("template",()=>import(__novaChunk("tinymce-chunks/template-b522c8ed.js") ));j("spellchecker",()=>import(__novaChunk("tinymce-chunks/spellchecker-91509fc1.js") ));j("autocorrect",()=>import(__novaChunk("tinymce-chunks/autocorrect-907e1296.js") ));j("typography",()=>import(__novaChunk("tinymce-chunks/typography-469ce11a.js") ));j("a11ychecker",()=>import(__novaChunk("tinymce-chunks/a11ychecker-fe78c552.js") ));j("linkchecker",()=>import(__novaChunk("tinymce-chunks/linkchecker-820845fd.js") ));j("advcode",()=>import(__novaChunk("tinymce-chunks/advcode-840793ca.js") ));j("editimage",()=>import(__novaChunk("tinymce-chunks/editimage-36199bc6.js") ));j("email",()=>import(__novaChunk("tinymce-chunks/email2-e9c49586.js") ));j("quickbars",()=>import(__novaChunk("tinymce-chunks/quickbars-35c87c0e.js") ));j("charmap",()=>import(__novaChunk("tinymce-chunks/charmap-5deb524c.js") ));j("emoticons",()=>import(__novaChunk("tinymce-chunks/emoticons-a5ab437d.js") ));j("nonbreaking",()=>import(__novaChunk("tinymce-chunks/nonbreaking-f15226ad.js") ));j("checklist",()=>import(__novaChunk("tinymce-chunks/checklist-5a0c95d3.js") ));j("codesample",()=>import(__novaChunk("tinymce-chunks/codesample-b91dcd91.js") ));j("draghandle",()=>import(__novaChunk("tinymce-chunks/draghandle-a1d99987.js") ));j("autolink",()=>import(__novaChunk("tinymce-chunks/autolink-897e8650.js") ));j("autosave",()=>import(__novaChunk("tinymce-chunks/autosave-60381295.js") ));j("autoresize",()=>import(__novaChunk("tinymce-chunks/autoresize-f8a4a52a.js") ));j("visualblocks",()=>import(__novaChunk("tinymce-chunks/visualblocks-8b7cba25.js") ));j("exportword",()=>import(__novaChunk("tinymce-chunks/exportword-ad95abb4.js") ));j("exportpdf",()=>import(__novaChunk("tinymce-chunks/exportpdf-1dfcbddc.js") ));j("importword",()=>import(__novaChunk("tinymce-chunks/importword-d6c2636a.js") ));j("ai",()=>import(__novaChunk("tinymce-chunks/ai2-ddf912a7.js") ));j("anchor",_p);j("accordion",ml);j("tableofcontents",wl);j("math",kl);j("pagebreak",um);j("pagelayout",gc);j("footnotes",xc);j("media",ja);j("pageembed",Ua);j("advtable",Ya);j("mediaembed",rc);j("fullpagehtml",uc);j("comments",pa);j("mentions",ca);j("mergetags",ma);j("suggestions",Oa);j("directionality",()=>import(__novaChunk("tinymce-chunks/directionality-185b3810.js") ));j("advlist",()=>import(__novaChunk("tinymce-chunks/advlist-67b98670.js") ));j("revisionhistory",()=>import(__novaChunk("tinymce-chunks/revisionhistory-741dfb24.js") ));var dd={};q(dd,{API_CHANGE_META:()=>As,Editor:()=>vo,REMOTE_CHANGE_META:()=>ud,createEditor:()=>Ts,parseContent:()=>cd});function bm(n,e){let t=null,r=()=>{if(t!==null||(t=0,queueMicrotask(()=>t=null),e.scrollHeight>e.clientHeight+1))return t;let l=getComputedStyle(n);return l.position==="sticky"&&l.display!=="none"&&(t=n.offsetHeight+(parseFloat(l.top)||0)),t},o=l=>{if(!r()||!l.hasFocus())return;let a=n.getBoundingClientRect(),c;try{c=l.coordsAtPos(l.state.selection.head)}catch{return}c.bottom<=a.top||c.top>=a.bottom||ym(n).scrollBy(0,c.top-a.bottom-5)},i=l=>{if(!l.dom.getClientRects().length)return;let a;try{a=l.coordsAtPos(l.state.selection.head)}catch{return}if(e.scrollHeight>e.clientHeight+1){let f=e.getBoundingClientRect();a.top<f.top+5?e.scrollTop-=f.top+5-a.top:a.bottom>f.bottom-5&&(e.scrollTop+=a.bottom-f.bottom+5),a=l.coordsAtPos(l.state.selection.head)}let c=ym(e),u=c instanceof HTMLElement?c.getBoundingClientRect():{top:0,bottom:c.innerHeight},d=u.top+r()+5,p=u.bottom-5;a.top<d?c.scrollBy(0,a.top-d):a.bottom>p&&c.scrollBy(0,a.bottom-p)};return{plugin:new z({key:Sc,state:{init:()=>0,apply:(l,a)=>l.scrolledIntoView?a+1:a},view:()=>{let l=0;return{update(a,c){Sc.getState(a.state)!==Sc.getState(c)&&!a.hasFocus()&&i(a),!a.state.selection.eq(c.selection)&&(cancelAnimationFrame(l),l=requestAnimationFrame(()=>o(a)))},destroy:()=>cancelAnimationFrame(l)}}}),props:{scrollThreshold:{left:0,right:0,bottom:0,get top(){return r()}},scrollMargin:{left:5,right:5,bottom:5,get top(){return r()+5}}}}}var Sc=new X("nova-scroll-requests");function ym(n){for(let e=n.parentElement;e;e=e.parentElement){let{overflowY:t}=getComputedStyle(e);if(/auto|scroll|overlay/.test(t)&&e.scrollHeight>e.clientHeight+1)return e}return n.ownerDocument.defaultView??window}var vm=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function v1(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var x1=(n,e,t)=>{let r=v1(n,t);if(!r)return!1;let o=xm(r);if(!o){let s=r.blockRange(),l=s&&at(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(Sm(n,o,e,-1))return!0;if(r.parent.content.size==0&&(ir(i,"end")||R.isSelectable(i)))for(let s=r.depth;;s--){let l=Or(n.doc,r.before(s),r.after(s),D.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(ir(i,"end")?U.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):R.create(a.doc,o.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1};function ir(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}var w1=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=xm(r)}let s=i&&i.nodeBefore;return!s||!R.isSelectable(s)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function xm(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function S1(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}var M1=(n,e,t)=>{let r=S1(n,t);if(!r)return!1;let o=wm(r);if(!o)return!1;let i=o.nodeAfter;if(Sm(n,o,e,1))return!0;if(r.parent.content.size==0&&(ir(i,"start")||R.isSelectable(i))){let s=Or(n.doc,r.before(),r.after(),D.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=n.tr.step(s);l.setSelection(ir(i,"start")?U.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):R.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},E1=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;i=wm(r)}let s=i&&i.nodeAfter;return!s||!R.isSelectable(s)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,i.pos)).scrollIntoView()),!0)};function wm(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}var Di=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),i=o&&at(o);return i==null?!1:(e&&e(n.tr.lift(o,i).scrollIntoView()),!0)},C1=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
21
+ `).scrollIntoView()),!0)};function Ec(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var Cc=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),i=t.indexAfter(-1),s=Ec(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(U.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},A1=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof de||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=Ec(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=n.tr.insert(s,i.createAndFill());l.setSelection(F.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},T1=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(Ct(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),o=r&&at(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)};function N1(n){return(e,t)=>{if(e.selection instanceof R&&e.selection.node.isBlock){let{$from:f}=e.selection;return!f.parentOffset||!Ct(e.doc,f.pos)?!1:(t&&t(e.tr.split(f.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof F||e.selection instanceof de)&&r.deleteSelection();let{$from:o}=r.selection,i=r.steps.length,s=[],l,a,c=!1,u=!1;for(let f=o.depth;;f--)if(o.node(f).isBlock){c=o.end(f)==o.pos+(o.depth-f),u=o.start(f)==o.pos-(o.depth-f),a=Ec(o.node(f-1).contentMatchAt(o.indexAfter(f-1)));let m=n&&n(o.parent,c,o);s.unshift(m||(c&&a?{type:a}:null)),l=f;break}else{if(f==1)return!1;s.unshift(null)}let d=o.pos,p=Ct(r.doc,d,s.length,s);if(p||(s[0]=a?{type:a}:null,p=Ct(r.doc,d,s.length,s)),!p)return!1;if(r.split(d,s.length,s),!c&&u&&o.node(l).type!=a){let f=r.mapping.slice(i),h=f.map(o.before(l)),m=r.doc.resolve(h);a&&o.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&r.setNodeMarkup(f.map(o.before(l)),a)}return t&&t(r.scrollIntoView()),!0}}var O1=N1();var L1=(n,e)=>(e&&e(n.tr.setSelection(new de(n.doc))),!0);function P1(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||ct(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Sm(n,e,t,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&P1(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(t){let f=e.pos+i.nodeSize,h=T.empty;for(let k=s.length-1;k>=0;k--)h=T.from(s[k].create(null,h));h=T.from(o.copy(h));let m=n.tr.step(new re(e.pos-1,f,e.pos,f,new D(h,1,0),s.length,!0)),g=m.doc.resolve(f+2*s.length);g.nodeAfter&&g.nodeAfter.type==o.type&&ct(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&a?null:U.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),p=d&&at(d);if(p!=null&&p>=e.depth)return t&&t(n.tr.lift(d,p).scrollIntoView()),!0;if(c&&ir(i,"start",!0)&&ir(o,"end")){let f=o,h=[];for(;h.push(f),!f.isTextblock;)f=f.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(f.canReplace(f.childCount,f.childCount,m.content)){if(t){let k=T.empty;for(let M=h.length-1;M>=0;M--)k=T.from(h[M].copy(k));let x=n.tr.step(new re(e.pos-h.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new D(k,h.length,0),0,!0));t(x.scrollIntoView())}return!0}}return!1}function Mm(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(t&&t(e.tr.setSelection(F.create(e.doc,n<0?o.start(i):o.end(i)))),!0):!1}}var R1=Mm(-1),D1=Mm(1);function _i(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,s=o.blockRange(i),l=s&&ln(s,n,e);return l?(r&&r(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Ac(n,e=null){return function(t,r){let o=!1;for(let i=0;i<t.selection.ranges.length&&!o;i++){let{$from:{pos:s},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(s,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let u=t.doc.resolve(c),d=u.index();o=u.parent.canReplaceWith(d,d+1,n)}})}if(!o)return!1;if(r){let i=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[s];i.setBlockType(l,a,n,e)}r(i.scrollIntoView())}return!0}}function _1(n,e,t,r){for(let o=0;o<e.length;o++){let{$from:i,$to:s}=e[o],l=i.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(i.pos,s.pos,(a,c)=>{if(l||!r&&a.isAtom&&a.isInline&&c>=i.pos&&c+a.nodeSize<=s.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function I1(n){let e=[];for(let t=0;t<n.length;t++){let{$from:r,$to:o}=n[t];r.doc.nodesBetween(r.pos,o.pos,(i,s)=>{if(i.isAtom&&i.content.size&&i.isInline&&s>=r.pos&&s+i.nodeSize<=o.pos)return s+1>r.pos&&e.push(new cn(r,r.doc.resolve(s+1))),r=r.doc.resolve(s+1+i.content.size),!1}),r.pos<o.pos&&e.push(new cn(r,o))}return e}function Xt(n,e=null,t){let r=(t&&t.removeWhenPresent)!==!1,o=(t&&t.enterInlineAtoms)!==!1,i=!(t&&t.includeWhitespace);return function(s,l){let{empty:a,$cursor:c,ranges:u}=s.selection;if(a&&!c||!_1(s.doc,u,n,o))return!1;if(l)if(c)n.isInSet(s.storedMarks||c.marks())?l(s.tr.removeStoredMark(n)):l(s.tr.addStoredMark(n.create(e)));else{let d,p=s.tr;o||(u=I1(u)),r?d=!u.some(f=>s.doc.rangeHasMark(f.$from.pos,f.$to.pos,n)):d=!u.every(f=>{let h=!1;return p.doc.nodesBetween(f.$from.pos,f.$to.pos,(m,g,k)=>{if(h)return!1;h=!n.isInSet(m.marks)&&!!k&&k.type.allowsMarkType(n)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,f.$from.pos-g),Math.min(m.nodeSize,f.$to.pos-g))))}),!h});for(let f=0;f<u.length;f++){let{$from:h,$to:m}=u[f];if(!d)p.removeMark(h.pos,m.pos,n);else{let g=h.pos,k=m.pos,x=h.nodeAfter,M=m.nodeBefore,L=i&&x&&x.isText?/^\s*/.exec(x.text)[0].length:0,O=i&&M&&M.isText?/\s*$/.exec(M.text)[0].length:0;g+L<k&&(g+=L,k-=O),p.addMark(g,k,n.create(e))}}l(p.scrollIntoView())}return!0}}function sr(...n){return function(e,t,r){for(let o=0;o<n.length;o++)if(n[o](e,t,r))return!0;return!1}}var Mc=sr(vm,x1,w1),km=sr(vm,M1,E1),Dt={Enter:sr(C1,A1,T1,O1),"Mod-Enter":Cc,Backspace:Mc,"Mod-Backspace":Mc,"Shift-Backspace":Mc,Delete:km,"Mod-Delete":km,"Mod-a":L1},Em={"Ctrl-h":Dt.Backspace,"Alt-Backspace":Dt["Mod-Backspace"],"Ctrl-d":Dt.Delete,"Ctrl-Alt-Backspace":Dt["Mod-Delete"],"Alt-Delete":Dt["Mod-Delete"],"Alt-d":Dt["Mod-Delete"],"Ctrl-a":R1,"Ctrl-e":D1};for(let n in Dt)Em[n]=Dt[n];var H1=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Cm=H1?Em:Dt;var Fc={};q(Fc,{commands:()=>Ue,convertList:()=>_m,findParentList:()=>Dm,getActiveAlign:()=>Zt,getLinkAt:()=>Cn,insertImage:()=>Bc,isCommandActive:()=>cr,isMarkActive:()=>ar,isNodeActive:()=>Ze,listIndent:()=>Ic,listOutdent:()=>Hc,markRange:()=>An,marksOf:()=>ce,nodesOf:()=>Z,replaceSelectionWithBlock:()=>qi,setLink:()=>s0});var Pc={};q(Pc,{closeHistory:()=>K1,history:()=>Lc,isHistoryTransaction:()=>X1,redo:()=>zi,redoDepth:()=>Y1,redoNoScroll:()=>J1,undo:()=>Fi,undoDepth:()=>G1,undoNoScroll:()=>U1});var Ii=200,ve=function(){};ve.prototype.append=function(e){return e.length?(e=ve.from(e),!this.length&&e||e.length<Ii&&this.leafAppend(e)||this.length<Ii&&e.leafPrepend(this)||this.appendInner(e)):this};ve.prototype.prepend=function(e){return e.length?ve.from(e).append(this):this};ve.prototype.appendInner=function(e){return new B1(this,e)};ve.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?ve.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};ve.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};ve.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};ve.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},t,r),o};ve.from=function(e){return e instanceof ve?e:e&&e.length?new Am(e):ve.empty};var Am=(function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,s,l){for(var a=i;a<s;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,s,l){for(var a=i-1;a>=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Ii)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Ii)return new e(o.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(ve);ve.empty=new Am([]);var B1=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.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,o,i,s){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(i,l),s)===!1||i>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(o,l),i,s)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(r,o):r>=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,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})(ve),Tc=ve;var F1=500,Mn=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;t&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((d,p)=>{if(!d.step){o||(o=this.remapping(r,p+1),i=o.maps.length),i--,u.push(d);return}if(o){u.push(new mt(d.map));let f=d.step.map(o.slice(i)),h;f&&s.maybeStep(f).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],c.push(new mt(h,void 0,void 0,c.length+u.length))),i--,h&&o.appendMap(h,i)}else s.maybeStep(d.step);if(d.selection)return l=o?d.selection.map(o.slice(i)):d.selection,a=new n(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),p=new mt(e.mapping.maps[u],d,t),f;(f=a&&a.merge(p))&&(p=f,u?i.pop():l=l.slice(0,l.length-1)),i.push(p),t&&(s++,t=void 0),o||(a=p)}let c=s-r.depth;return c>$1&&(l=z1(l,c),s-=c),new n(l.append(i),s)}remapping(e,t){let r=new In;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new mt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;t=Math.min(this.items.length,t);let r=[],o=this.items.length-t,i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},o);let a=t;this.items.forEach(p=>{let f=i.getMirror(--a);if(f==null)return;s=Math.min(s,f);let h=i.maps[f];if(p.step){let m=e.steps[f].invert(e.docs[f]),g=p.selection&&p.selection.map(i.slice(a+1,f));g&&l++,r.push(new mt(h,m,g))}else r.push(new mt(h))},o);let c=[];for(let p=t;p<s;p++)c.push(new mt(i.maps[p]));let u=this.items.slice(0,o).append(c).append(r),d=new n(u,l);return d.emptyItemCount()>F1&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=s.selection&&s.selection.map(t.slice(r));u&&i++;let d=new mt(c.invert(),a,u),p,f=o.length-1;(p=o.length&&o[f].merge(d))?o[f]=p:o.push(d)}}else s.map&&r--},this.items.length,0),new n(Tc.from(o.reverse()),i)}};Mn.empty=new Mn(Tc.empty,0);function z1(n,e){let t;return n.forEach((r,o)=>{if(r.selection&&e--==0)return t=o,!1}),n.slice(t)}var mt=class n{constructor(e,t,r,o){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},gt=class{constructor(e,t,r,o,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},$1=20;function V1(n,e,t,r){let o=t.getMeta(yt),i;if(o)return o.historyState;t.getMeta(Om)&&(n=new gt(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(yt))return s.getMeta(yt).redo?new gt(n.done.addTransform(t,void 0,r,Hi(e)),n.undone,Tm(t.mapping.maps),n.prevTime,n.prevComposition):new gt(n.done,n.undone.addTransform(t,void 0,r,Hi(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!q1(t,n.prevRanges)),c=s?Nc(n.prevRanges,t.mapping):Tm(t.mapping.maps);return new gt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Hi(e)),Mn.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new gt(n.done.rebased(t,i),n.undone.rebased(t,i),Nc(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new gt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Nc(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function q1(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,o)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&o>=e[i]&&(t=!0)}),t}function Tm(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,o,i,s)=>e.push(i,s));return e}function Nc(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let o=e.map(n[r],1),i=e.map(n[r+1],-1);o<=i&&t.push(o,i)}return t}function j1(n,e){for(let t=0;t<e.steps.length;t++){let r=e.mapping.maps[t],o=-1;if(r.forEach((i,s)=>o=s),o<0){let i=e.steps[t];(i instanceof Je||i instanceof Ge)&&(o=i.to)}if(o>-1)return U.near(n.doc.resolve(o))}return n.selection}function W1(n,e,t){let r=Hi(e),o=yt.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,j1(e,i.transform).getBookmark(),o,r),a=new gt(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(yt,{redo:t,historyState:a})}var Oc=!1,Nm=null;function Hi(n){let e=n.plugins;if(Nm!=e){Oc=!1,Nm=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Oc=!0;break}}return Oc}function K1(n){return n.setMeta(Om,!0)}var yt=new X("history"),Om=new X("closeHistory");function Lc(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new z({key:yt,state:{init(){return new gt(Mn.empty,Mn.empty,null,0,-1)},apply(e,t,r){return V1(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,o=r=="historyUndo"?Fi:r=="historyRedo"?zi:null;return!o||!e.editable?!1:(t.preventDefault(),o(e.state,e.dispatch))}}}})}function Bi(n,e){return(t,r)=>{let o=yt.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(r){let i=W1(o,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}var Fi=Bi(!1,!0),zi=Bi(!0,!0),U1=Bi(!1,!1),J1=Bi(!0,!1);function G1(n){let e=yt.getState(n);return e?e.done.eventCount:0}function Y1(n){let e=yt.getState(n);return e?e.undone.eventCount:0}function X1(n){return n.getMeta(yt)!=null}var _c={};q(_c,{blockUnitAt:()=>Rc,duplicateBlock:()=>e0,moveBlock:()=>$i,selectedBlockUnit:()=>Dc});function Rc(n){for(let e=n.depth;e>0;e--){let t=n.node(e);if(t.type.name==="list_item")return{node:t,pos:n.before(e),depth:e}}if(n.depth===0){let e=n.nodeAfter;return e?{node:e,pos:n.pos,depth:1}:null}return{node:n.node(1),pos:n.before(1),depth:1}}function Dc(n){let{selection:e}=n;return e instanceof R?{node:e.node,pos:e.from,depth:e.$from.depth+1}:e instanceof F?Rc(e.$from):null}function Z1(n){let e=Dc(n);if(!e)return null;let{selection:t}=n;if(!(t instanceof R)&&e.node.type.spec.tableRole==="table")return null;let r=n.doc.resolve(e.pos),o=r.parent,i=r.index(),s=i;if(!t.empty&&!(t instanceof R)){let a=Rc(t.$to);if(a&&a.depth===e.depth){let c=n.doc.resolve(a.pos);c.start()===r.start()&&(s=Math.max(i,c.index()))}}let l=e.pos;for(let a=i;a<=s;a++)l+=o.child(a).nodeSize;return{parent:o,startIndex:i,endIndex:s,from:e.pos,to:l}}function Q1(n,e,t){let{selection:r}=e;n.setSelection(r instanceof R?R.create(n.doc,r.from+t):F.create(n.doc,r.anchor+t,r.head+t))}function $i(n){return(e,t)=>{let r=Z1(e);if(!r)return!1;let{parent:o,startIndex:i,endIndex:s,from:l,to:a}=r,c=n<0?i-1:s+1;if(c<0||c>=o.childCount)return!1;let u=o.child(c),d=[];for(let g=i;g<=s;g++)d.push(o.child(g));let p=T.fromArray(d),f=n<0?p.append(T.from(u)):T.from(u).append(p),h=Math.min(i,c),m=Math.max(s,c);if(!o.canReplace(h,m+1,f))return!1;if(t){let g=n<0?e.tr.replaceWith(l-u.nodeSize,a,f):e.tr.replaceWith(l,a+u.nodeSize,f);Q1(g,e,n*u.nodeSize),t(g.scrollIntoView())}return!0}}var e0=(n,e)=>{let t=Dc(n);if(!t||t.node.type.spec.tableRole==="table"&&!(n.selection instanceof R))return!1;let r=t.pos+t.node.nodeSize,o=n.doc.resolve(r);if(!o.parent.canReplaceWith(o.index(),o.index(),t.node.type))return!1;if(e){let i=n.tr.insert(r,t.node);i.setSelection(R.create(i.doc,r)),e(i.scrollIntoView())}return!0};var Z=n=>n.schema.nodes,ce=n=>n.schema.marks,ro=(n,e)=>(t,r,o)=>e(Z(t)[n])(t,r,o),En=(n,e)=>(t,r,o)=>e(ce(t)[n])(t,r,o);function Vi(n){return(e,t)=>{let{from:r,to:o}=e.selection,i=e.tr,s=!1;return e.doc.nodesBetween(r,o,(l,a)=>{let c=Z(e);(l.type===c.paragraph||l.type===c.heading)&&(s=!0,i=i.setNodeMarkup(a,void 0,{...l.attrs,align:n}))}),s?(t?.(i),!0):!1}}function qi(n,e){let{$from:t}=n.selection;if(e.isBlock)for(let r=t.depth-1;r>0;r--){let o=t.node(r);if(!o.type.spec.isolating)continue;let i=!1;for(let l=0;l<=o.childCount&&!i;l++)i=o.canReplaceWith(l,l,e.type);if(i)break;let s=t.after(r);return n.insert(s,e),n.setSelection(U.near(n.doc.resolve(s+e.nodeSize)))}return n.replaceSelectionWith(e)}var t0=(n,e)=>(e?.(qi(n.tr,Z(n).horizontal_rule.create()).scrollIntoView()),!0),n0=(n,e)=>{let{from:t,to:r,empty:o,$from:i}=n.selection,s=ce(n);if(o){let l=An(n,s.link,i.pos);return l?(e?.(n.tr.removeMark(l.from,l.to,s.link)),!0):!1}return n.doc.rangeHasMark(t,r,s.link)?(e?.(n.tr.removeMark(t,r,s.link)),!0):!1},r0=(n,e)=>{let{from:t,to:r,empty:o}=n.selection;if(o)return!1;if(e){let i=ce(n),s=n.tr;for(let l of Object.values(i))l!==i.link&&(s=s.removeMark(t,r,l));e(s)}return!0};function Pm(n){return(e,t)=>{let r=Z(e),o=[],{from:i,to:s}=e.selection;if(e.doc.nodesBetween(i,s,(l,a,c)=>{if(l.type!==r.paragraph&&l.type!==r.heading)return!0;if(c?.type!==r.list_item){let u=or(l.attrs.indent),d=or(u+n);d!==u&&o.push({pos:a,attrs:{...l.attrs,indent:d}})}return!1}),!o.length)return!1;if(t){let l=e.tr;for(let{pos:a,attrs:c}of o)l.setNodeMarkup(a,void 0,c);t(l.scrollIntoView())}return!0}}var o0=(n,e,t)=>pi(Z(n).list_item)(n,e,t)||Pm(1)(n,e,t),i0=(n,e,t)=>bn(Z(n).list_item)(n,e,t)||Pm(-1)(n,e,t),Ic=(n,e,t)=>pi(Z(n).list_item)(n,e,t),Hc=(n,e,t)=>bn(Z(n).list_item)(n,e,t);function Rm(n,e={}){let t=Ac(n,e);return(r,o)=>{if(!t(r))return!1;if(o){let i=r.tr;for(let s of r.selection.ranges)i.setBlockType(s.$from.pos,s.$to.pos,n,l=>({...e,..."align"in n.spec.attrs&&l.attrs.align?{align:l.attrs.align}:{},..."lineHeight"in n.spec.attrs&&l.attrs.lineHeight?{lineHeight:l.attrs.lineHeight}:{},..."dir"in n.spec.attrs&&l.attrs.dir?{dir:l.attrs.dir}:{},..."indent"in n.spec.attrs&&l.attrs.indent?{indent:l.attrs.indent}:{},..."id"in n.spec.attrs&&l.attrs.id?{id:l.attrs.id}:{}}));o(i.scrollIntoView())}return!0}}function lr(n){return ro("heading",e=>Rm(e,{level:n}))}var Ue={bold:En("bold",Xt),italic:En("italic",Xt),underline:En("underline",Xt),strike:En("strike",Xt),code:En("code",Xt),subscript:En("subscript",Xt),superscript:En("superscript",Xt),paragraph:ro("paragraph",n=>Rm(n)),h1:lr(1),h2:lr(2),h3:lr(3),h4:lr(4),h5:lr(5),h6:lr(6),blockquote:(n,e)=>Ze(n,Z(n).blockquote)?Di(n,e):_i(Z(n).blockquote)(n,e),codeBlock:ro("code_block",n=>Ac(n)),bulletList:ro("bullet_list",Lm),orderedList:ro("ordered_list",Lm),indent:o0,outdent:i0,alignLeft:Vi(null),alignCenter:Vi("center"),alignRight:Vi("right"),alignJustify:Vi("justify"),horizontalRule:t0,unlink:n0,clearFormatting:r0,undo:Fi,redo:zi,moveBlockUp:$i(-1),moveBlockDown:$i(1)};function Dm(n){let e=Z(n),{$from:t}=n.selection;for(let r=t.depth;r>0;r--){let o=t.node(r);if(o.type===e.bullet_list||o.type===e.ordered_list)return{node:o,pos:t.before(r)}}return null}function _m(n,e,t,r=!1){let o=n.doc.type.schema.nodes,i=t===o.bullet_list&&r;return n.setNodeMarkup(e.pos,t,t===o.bullet_list?{listStyle:null,checklist:i}:{start:1}),e.node.forEach((s,l)=>{let a=s.attrs.checked,c=i?typeof a=="boolean"?a:!1:null;c!==a&&n.setNodeMarkup(e.pos+1+l,void 0,{...s.attrs,checked:c})}),n}function Lm(n){return(e,t)=>{let r=Z(e),o=n===r.bullet_list?{checklist:!1}:void 0;if(Ze(e,n,o))return bn(r.list_item)(e,t);let i=Dm(e);return i?(t&&t(_m(e.tr,i,n).scrollIntoView()),!0):ba(n)(e,t)}}function s0(n,e={}){return(t,r)=>{if(!Ie(n))return!1;let{from:o,to:i,empty:s,$from:l}=t.selection,a=ce(t),c=a.link.create({href:n,title:e.title??null,target:e.target??null});if(s){let u=An(t,a.link,l.pos);return u?(r?.(t.tr.removeMark(u.from,u.to,a.link).addMark(u.from,u.to,c)),!0):(r?.(t.tr.insert(o,t.schema.text(n,[c]))),!0)}return r?.(t.tr.removeMark(o,i,a.link).addMark(o,i,c)),!0}}function Bc(n,e){return(t,r)=>fe(n)?(r?.(t.tr.replaceSelectionWith(Z(t).image.create({src:n,alt:e??null})).scrollIntoView()),!0):!1}function ar(n,e){let{from:t,$from:r,to:o,empty:i}=n.selection;return i?!!e.isInSet(n.storedMarks??r.marks()):n.doc.rangeHasMark(t,o,e)}function Ze(n,e,t){let{$from:r,to:o}=n.selection;for(let i=r.depth;i>0;i--){let s=r.node(i);if(s.type===e&&(!t||Object.entries(t).every(([l,a])=>s.attrs[l]===a)))return o<=r.end(i)}return!1}function Zt(n){return n.selection.$from.parent.attrs.align??"left"}function cr(n,e){let t=n.selection.$from.parent,r=Z(n),o=ce(n);switch(e){case"bold":case"italic":case"underline":case"strike":case"code":case"subscript":case"superscript":return ar(n,o[e]);case"paragraph":return t.type===r.paragraph;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return t.type===r.heading&&t.attrs.level===Number(e[1]);case"codeBlock":return t.type===r.code_block;case"blockquote":return Ze(n,r.blockquote);case"bulletList":return Ze(n,r.bullet_list,{checklist:!1});case"orderedList":return Ze(n,r.ordered_list);case"alignLeft":return Zt(n)==="left";case"alignCenter":return Zt(n)==="center";case"alignRight":return Zt(n)==="right";case"alignJustify":return Zt(n)==="justify";default:return!1}}function Cn(n){let{$from:e}=n.selection,t=ce(n),r=t.link.isInSet(e.marks())??t.link.isInSet(e.nodeAfter?.marks??[]);return r?r.attrs:null}function An(n,e,t){let r=n.doc.resolve(t),o=r.start(),i=[];return r.parent.forEach((s,l)=>{if(!e.isInSet(s.marks))return;let a=o+l,c=a+s.nodeSize,u=i[i.length-1];u&&u.to===a?u.to=c:i.push({from:a,to:c})}),i.find(s=>s.from<=t&&t<=s.to)??null}var l0={strong:"bold",b:"bold",em:"italic",i:"italic",u:"underline",s:"strike",strike:"strike",del:"strike",code:"code",sub:"subscript",sup:"superscript"},a0={color:{mark:"color",read:Y.color},"background-color":{mark:"background",read:Y.color},"font-family":{mark:"font_family",read:Y.fontFamily},"font-size":{mark:"font_size",read:Y.length}},Gi={p:n=>n.type.name==="paragraph",h1:n=>n.type.name==="heading"&&n.attrs.level===1,h2:n=>n.type.name==="heading"&&n.attrs.level===2,h3:n=>n.type.name==="heading"&&n.attrs.level===3,h4:n=>n.type.name==="heading"&&n.attrs.level===4,h5:n=>n.type.name==="heading"&&n.attrs.level===5,h6:n=>n.type.name==="heading"&&n.attrs.level===6,blockquote:n=>n.type.name==="blockquote",pre:n=>n.type.name==="code_block",img:n=>n.type.name==="image"},Im=new Set;function Yi(n){Im.has(n)||(Im.add(n),console.warn(`[nova] formats: ${n}`))}function Qe(n){return Array.isArray(n)?n.flatMap(Qe):typeof n=="string"?n.split(/\s+/).filter(Boolean):[]}function oo(n){let e=[];for(let t of n)e.push(...Qe(t.classes)),"items"in t&&t.items&&e.push(...oo(t.items));return e}var Ki=(n,e)=>{let t=Qe(n);return e.every(r=>t.includes(r))},ji=(n,e)=>{let t=[...new Set([...Qe(n),...e])];return t.length?t.join(" "):null},Wi=(n,e)=>{let t=Qe(n).filter(r=>!e.includes(r));return t.length?t.join(" "):null};function Ui(n){let e={};for(let[t,r]of Object.entries(n.styles??{}))t==="text-align"&&Yr.includes(r)?e.align=r:t==="line-height"&&Y.lineHeight(r)?e.lineHeight=Y.lineHeight(r):Yi(`style "${t}" is not supported on blocks`);return e}function Vc(n,e){let t=ce(n),r=[];if(e.inline&&e.inline!=="span"){let i=t[l0[e.inline]];i&&r.push(i.create())}let o=Qe(e.classes);o.length&&t.span_class&&r.push(t.span_class.create({class:o.join(" ")}));for(let[i,s]of Object.entries(e.styles??{})){let l=a0[i],a=l?.read(s),c=l?t[l.mark]:void 0;c&&a?r.push(c.create({value:a})):Yi(`style "${i}: ${s}" is not supported on text`)}return r}var Xi=n=>(n.selector??"").split(",").map(e=>e.trim().toLowerCase()).filter(e=>Gi[e]?!0:(Yi(`selector "${e}" is not supported`),!1));function Zi(n,e){let t=[],r=a=>e.some(c=>Gi[c](a)),{selection:o}=n;if(o instanceof R&&r(o.node))return[{node:o.node,pos:o.from}];let{$from:i,from:s,to:l}=o;for(let a=i.depth;a>0;a--){let c=i.node(a);r(c)&&t.push({node:c,pos:i.before(a)})}return n.doc.nodesBetween(s,l,(a,c)=>{r(a)&&!t.some(u=>u.pos===c)&&t.push({node:a,pos:c})}),t}function zc(n){let e=[],{from:t,to:r}=n.selection;return n.doc.nodesBetween(t,r,(o,i)=>o.isTextblock?(e.push({node:o,pos:i}),!1):!0),e}function qc(n){let{$from:e}=n.selection;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.name==="blockquote")return{node:r,pos:e.before(t)}}return null}function Fm(n){return{align:n.align??null,lineHeight:n.lineHeight??null,dir:n.dir??null}}var Ji=class{constructor(e,t){S(this,"editor",e);S(this,"allowedClasses",t);S(this,"registry",new Map)}register(e,t){let r=Array.isArray(t)?t:[t];this.registry.set(e,r),oo(r).forEach(o=>this.allowedClasses.add(o))}unregister(e){this.registry.delete(e)}has(e){return this.registry.has(e)}get(e){return this.registry.get(e)}resolve(e){if(typeof e!="string")return[e];let t=this.registry.get(e);return t||Yi(`unknown format "${e}"`),t??[]}canApply(e){if(!this.editor.isEditable())return!1;let t=this.editor.view.state;return this.resolve(e).some(r=>Hm(t,r))}match(e){let t=this.editor.view.state;return this.resolve(e).some(r=>c0(t,r))}apply(e){if(!this.editor.isEditable())return!1;let t=this.resolve(e);if(!t.length)return!1;let r=t.find(o=>Hm(this.editor.view.state,o))??t[0];return this.run((o,i)=>u0(o,i,r))}remove(e){if(!this.editor.isEditable())return!1;let t=this.resolve(e);return t.length?this.run((r,o)=>t.forEach(i=>d0(r,o,i))):!1}toggle(e){return this.match(e)?this.remove(e):this.apply(e)}run(e){let{view:t}=this.editor,r=t.state.tr;return e(t.state,r)===!1?!1:((r.docChanged||r.storedMarksSet)&&t.dispatch(r.scrollIntoView()),t.focus(),!0)}};function Hm(n,e){return e.selector?Zi(n,Xi(e)).length>0:!0}function Bm(n,e){return n.type.name==="image"?!0:Object.entries(Ui(e)).every(([t,r])=>n.attrs[t]===r)}function c0(n,e){let t=Qe(e.classes);if(e.block){if(e.block==="blockquote"){let o=qc(n);return!!o&&Ki(o.node.attrs.class,t)}let r=n.selection.$from.parent;return Gi[e.block](r)&&Ki(r.attrs.class,t)&&Bm(r,e)}if(e.selector){let r=Zi(n,Xi(e));return r.length>0&&r.some(({node:o})=>Ki(o.attrs.class,t)&&Bm(o,e))}if(e.inline){let r=Vc(n,e);if(!r.length)return!1;let{$from:o,empty:i,from:s,to:l}=n.selection;if(i){let u=n.storedMarks??o.marks();return r.every(d=>u.some(p=>$c(p,d)))}let a=!1,c=!0;return n.doc.nodesBetween(s,l,u=>{u.isText&&(a=!0,r.every(d=>u.marks.some(p=>$c(p,d)))||(c=!1))}),a&&c}return!1}function $c(n,e){return n.type!==e.type?!1:e.type.name==="span_class"?Ki(n.attrs.class,Qe(e.attrs.class)):e.attrs.value===void 0||n.attrs.value===e.attrs.value}function u0(n,e,t){let r=Qe(t.classes),o=Z(n);if(t.block==="blockquote"){let i=qc(n);return i?(e.setNodeMarkup(i.pos,void 0,{...i.node.attrs,class:ji(i.node.attrs.class,r)}),!0):_i(o.blockquote,{class:ji(null,r)})(n,s=>s.steps.forEach(l=>e.step(l)))}if(t.block==="pre"){for(let{node:i,pos:s}of zc(n))i.type!==o.code_block&&e.setNodeMarkup(s,o.code_block,{language:null});return!0}if(t.block){let i=t.block==="p"?0:Number(t.block.slice(1)),s=i?o.heading:o.paragraph,l=Ui(t);for(let{node:a,pos:c}of zc(n)){if(a.type===o.code_block&&a.textContent.includes(`
22
+ `))continue;let u=a.type===s&&(!i||a.attrs.level===i);e.setNodeMarkup(c,s,{...Fm(a.attrs),...i?{level:i}:{},...l,class:ji(u?a.attrs.class:null,r)})}return!0}if(t.selector){let i=Ui(t),s=Zi(n,Xi(t));if(!s.length)return!1;for(let{node:l,pos:a}of s){let c=l.type.name==="image"?{}:i;e.setNodeMarkup(a,void 0,{...l.attrs,...c,class:ji(l.attrs.class,r)})}return n.selection instanceof R&&e.setSelection(R.create(e.doc,n.selection.from)),!0}if(t.inline){let i=Vc(n,t);if(!i.length)return!1;let{empty:s,ranges:l}=n.selection;if(s){let a=n.storedMarks??n.selection.$from.marks();for(let c of i)a=c.addToSet(a);return e.setStoredMarks(a),!0}for(let{$from:a,$to:c}of l)for(let u of i)e.addMark(a.pos,c.pos,u);return!0}return!1}function d0(n,e,t){let r=Qe(t.classes),o=Z(n);if(t.block==="blockquote"){let i=qc(n);if(!i)return;let s=Wi(i.node.attrs.class,r);if(r.length&&s!==null){e.setNodeMarkup(i.pos,void 0,{...i.node.attrs,class:s});return}Di(n,l=>l.steps.forEach(a=>e.step(a)));return}if(t.block){for(let{node:i,pos:s}of zc(n))Gi[t.block](i)&&e.setNodeMarkup(s,o.paragraph,{...Fm(i.attrs),class:t.block==="p"?Wi(i.attrs.class,r):null});return}if(t.selector){let i=Ui(t);for(let{node:s,pos:l}of Zi(n,Xi(t))){let a={};s.type.name!=="image"&&("align"in i&&s.attrs.align===i.align&&(a.align=null),"lineHeight"in i&&s.attrs.lineHeight===i.lineHeight&&(a.lineHeight=null)),e.setNodeMarkup(l,void 0,{...s.attrs,...a,class:Wi(s.attrs.class,r)})}n.selection instanceof R&&e.setSelection(R.create(e.doc,n.selection.from));return}if(t.inline){let i=Vc(n,t),{empty:s,from:l,to:a,$from:c}=n.selection;if(s){let u=(n.storedMarks??c.marks()).filter(d=>!i.some(p=>$c(d,p)));e.setStoredMarks(u);return}for(let u of i){if(u.type.name!=="span_class"){e.removeMark(l,a,u.type);continue}n.doc.nodesBetween(l,a,(d,p)=>{if(!d.isText)return;let f=d.marks.find(k=>k.type===u.type);if(!f)return;let h=Math.max(p,l),m=Math.min(p+d.nodeSize,a);e.removeMark(h,m,u.type);let g=Wi(f.attrs.class,Qe(u.attrs.class));g&&e.addMark(h,m,u.type.create({class:g}))})}}}var Wc={};q(Wc,{absolutizeUrls:()=>jm,attachCss:()=>jc,loadCss:()=>es,scopeCss:()=>Qi,scopeSelector:()=>qm,splitSelectors:()=>Vm,splitTopLevel:()=>$m});var p0=/^@(font-face|(-webkit-)?keyframes|property|counter-style|page|font-feature-values|font-palette-values)\b/i,f0=/^@(media|supports|container|layer|document|scope)\b/i;function $m(n){let e=[],t=0,r=0,o=0,i="";for(;t<n.length;){let s=n[t];if(s==="/"&&n[t+1]==="*"){let l=n.indexOf("*/",t+2),a=l===-1?n.length:l+2;if(o===0){n=n.slice(0,t)+n.slice(a);continue}t=a;continue}if(s==='"'||s==="'"){for(t++;t<n.length&&n[t]!==s;)t+=n[t]==="\\"?2:1;t++;continue}if(s==="{")o===0&&(i=n.slice(r,t).trim(),r=t+1),o++;else if(s==="}")o--,o===0&&(e.push({prelude:i,body:n.slice(r,t)}),r=t+1),o<0&&(o=0);else if(s===";"&&o===0){let l=n.slice(r,t).trim();l&&e.push({prelude:l,body:null}),r=t+1}t++}return e}function Vm(n){let e=[],t=0,r="",o=0;for(let i=0;i<n.length;i++){let s=n[i];r?s==="\\"?i++:s===r&&(r=""):s==='"'||s==="'"?r=s:s==="("||s==="["?t++:s===")"||s==="]"?t--:s===","&&t===0&&(e.push(n.slice(o,i)),o=i+1)}return e.push(n.slice(o)),e.map(i=>i.trim()).filter(Boolean)}function qm(n,e){let t=n,r=!1;for(;;){let o=t.match(/^(html|body|:root)(?![\w-])\s*/i);if(!o)break;r=!0,t=t.slice(o[0].length)}if(!r)return`${e} ${n}`;if(/^[.#[:]/.test(t)){let o=t.search(/[\s>+~]/);return o===-1?`${e}${t}`:`${e}${t.slice(0,o)} ${t.slice(o).trim()}`}return t?`${e} ${t}`:e}function Qi(n,e){let t=[];for(let{prelude:r,body:o}of $m(n)){if(o===null){/^@layer\b/i.test(r)&&t.push(`${r};`);continue}if(p0.test(r))t.push(`${r}{${o}}`);else if(f0.test(r))t.push(`${r}{${Qi(o,e)}}`);else{if(r.startsWith("@"))continue;{let i=Vm(r).map(s=>qm(s,e));i.length&&t.push(`${i.join(", ")}{${o}}`)}}}return t.join(`
23
+ `)}function jm(n,e){return n.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi,(t,r,o)=>{if(/^(data:|https?:|\/\/|#)/i.test(o))return t;try{return`url(${r}${new URL(o,e).href}${r})`}catch{return t}})}var zm=/@import\s+(?:url\(\s*)?(['"]?)([^'")\s;]+)\1\s*\)?([^;]*);/gi;async function es(n,e=0){let t=new URL(n,document.baseURI).href,r=await fetch(t);if(!r.ok)throw new Error(`HTTP ${r.status}`);let o=jm(await r.text(),t);if(e>=3)return o.replace(zm,"");let i=[...o.matchAll(zm)];for(let s of i){let l=s[3].trim(),a="";try{a=await es(new URL(s[2],t).href,e+1)}catch(c){console.warn(`[nova] contentCss: could not load ${s[2]}`,c)}o=o.replace(s[0],l?`@media ${l}{${a}}`:a)}return o}function jc(n,e){let t=n.getRootNode();if("adoptedStyleSheets"in t&&typeof CSSStyleSheet<"u"&&"replaceSync"in CSSStyleSheet.prototype)try{let i=new CSSStyleSheet;return i.replaceSync(e),t.adoptedStyleSheets=[...t.adoptedStyleSheets,i],()=>{t.adoptedStyleSheets=t.adoptedStyleSheets.filter(s=>s!==i)}}catch{}let o=document.createElement("style");return o.setAttribute("data-nova-content-css",""),o.textContent=e,n.prepend(o),()=>o.remove()}function Wm(n={}){return new z({view(e){return new Kc(e,n)}})}var Kc=class{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else 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),t=!e.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(t){let d=e.nodeBefore,p=e.nodeAfter;if(d||p){let f=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(f){let h=f.getBoundingClientRect(),m=d?h.bottom:h.top;d&&p&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:h.left,right:h.right,top:m-g,bottom:m+g}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*s;r={left:d.left-p,right:d.left+p,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),p=d.width/a.offsetWidth,f=d.height/a.offsetHeight;c=d.left-a.scrollLeft*p,u=d.top-a.scrollTop*f}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,t,e):o;if(!t||i)return null;let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Nr(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}return s}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var Ce=class n extends U{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):U.near(r)}content(){return D.empty}eq(e){return e instanceof n&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(e.resolve(t.pos))}getBookmark(){return new Uc(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!h0(e)||!m0(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&n.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)<l.childCount:e.index(s)>0){i=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=t;let a=e.doc.resolve(o);if(n.valid(a))return a}for(;;){let s=t>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!R.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*t),r=!1;continue e}break}i=s,o+=t;let l=e.doc.resolve(o);if(n.valid(l))return l}return null}}};Ce.prototype.visible=!1;Ce.findFrom=Ce.findGapCursorFrom;U.jsonID("gapcursor",Ce);var Uc=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Ce.valid(t)?new Ce(t):U.near(t)}};function Km(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function h0(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||Km(o.type))return!0;if(o.inlineContent)return!1}}return!0}function m0(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||Km(o.type))return!0;if(o.inlineContent)return!1}}return!0}function Um(){return new z({props:{decorations:k0,createSelectionBetween(n,e,t){return e.pos==t.pos&&Ce.valid(t)?new Ce(t):null},handleClick:y0,handleKeyDown:g0,handleDOMEvents:{beforeinput:b0}}})}var g0=ri({ArrowLeft:ts("horiz",-1),ArrowRight:ts("horiz",1),ArrowUp:ts("vert",-1),ArrowDown:ts("vert",1)});function ts(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof F){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=Ce.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new Ce(c))),!0):!1}}function y0(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Ce.valid(r))return!1;let o=n.posAtCoords({left:t.clientX,top:t.clientY});return o&&o.inside>-1&&R.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Ce(r))),!0)}function b0(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Ce))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=T.empty;for(let s=r.length-1;s>=0;s--)o=T.from(r[s].createAndFill(null,o));let i=n.state.tr.replace(t.pos,t.pos,new D(o,0,0));return i.setSelection(F.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function k0(n){if(!(n.selection instanceof Ce))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",ae.create(n.doc,[ge.widget(n.selection.head,e,{key:"gapcursor"})])}var au={};q(au,{UPLOAD_RETRY_DELAYS:()=>Ym,dataUrlToFile:()=>Zm,embeddedImageUploadPlugin:()=>tu,exitImageCaption:()=>iu,getSelectedImage:()=>et,hasImageCaption:()=>ru,imageDropPastePlugin:()=>nu,isSupportedImage:()=>so,openImageAltDialog:()=>lu,openImageDialog:()=>lo,setImageAttrs:()=>ur,setImageWidthFraction:()=>su,toggleImageCaption:()=>ou,uploadEmbeddedImage:()=>eu,uploadImages:()=>ns});var Jc={};q(Jc,{attachFilePicker:()=>io});function io(n,e,t,r){let{filePicker:o,filePickerTypes:i}=n.options;if(!o||i&&!i.includes(t))return;let{input:s}=e,l=w("button",{type:"button",className:"nova-btn nova-input-action","aria-label":n.ui.t("dialog.browse"),title:n.ui.t("dialog.browse")},ee(C.browse)),a=w("div",{className:"nova-input-group"});s.replaceWith(a),a.append(s,l),l.addEventListener("click",async()=>{l.disabled=!0;try{let c=await o({type:t,value:s.value});if(!c?.url)return;s.value=c.url,s.removeAttribute("aria-invalid"),r?.(c)}catch(c){console.error("[nova] filePicker failed:",c)}finally{l.disabled=!1,s.isConnected&&s.focus()}})}var Xc={};q(Xc,{checkboxField:()=>Yc,openDialog:()=>Gc,selectField:()=>v0,textField:()=>ze});function Gc(n){let e=je("nova-dialog-title"),t=w("p",{className:"nova-dialog-error",role:"alert",hidden:!0}),r=w("button",{type:"submit",className:"nova-button nova-button-primary",hidden:!n.submitLabel},n.submitLabel??""),o=w("button",{type:"button",className:"nova-button"},n.cancelLabel),i=w("button",{type:"button",className:"nova-btn nova-dialog-close","aria-label":n.closeLabel},ee(C.close)),s=w("form",{className:n.size==="large"?"nova-dialog nova-dialog-large":"nova-dialog",role:"dialog","aria-modal":"true","aria-labelledby":e,novalidate:!0},w("header",{className:"nova-dialog-header"},w("h2",{id:e},n.title),i),w("div",{className:"nova-dialog-body"},n.body,t),w("footer",{className:"nova-dialog-footer"},o,r)),l=w("div",{className:"nova-dialog-backdrop"},s);n.host.append(l);let a=!1,c=()=>{a||(a=!0,l.remove(),p(),n.onClose?.(),n.returnFocus?.())},u=h=>{t.hidden=!h,t.textContent=h??""},d=h=>{r.disabled=h,s.setAttribute("aria-busy",String(h))};s.addEventListener("submit",async h=>{h.preventDefault(),u(null),d(!0);try{let m=n.onSubmit?await n.onSubmit():!0;typeof m=="string"?u(m):m!==!1&&c()}finally{a||d(!1)}}),o.addEventListener("click",c),i.addEventListener("click",c),l.addEventListener("mousedown",h=>{h.target===l&&c()}),s.addEventListener("keydown",h=>{if(h.key==="Escape"&&!h.defaultPrevented)h.preventDefault(),h.stopPropagation(),c();else if(h.key==="Tab"){let m=[...s.querySelectorAll($t)].filter(x=>!x.hidden),g=m[0],k=m[m.length-1];if(!g||!k)return;h.shiftKey&&te(s)===g?(h.preventDefault(),k.focus()):!h.shiftKey&&te(s)===k&&(h.preventDefault(),g.focus())}}),s.tabIndex=-1,s.addEventListener("click",()=>{!a&&!s.contains(te(s))&&s.focus({preventScroll:!0})});let p=ut(s,"focusin",(h,m)=>{let g=m instanceof Element&&m.closest(".nova-dialog")!==null;!s.contains(m)&&!g&&(s.querySelector($t)??s).focus()});return(n.initialFocus??s.querySelector(".nova-dialog-body input, .nova-dialog-body textarea")??(n.submitLabel?r:o)).focus(),{el:s,close:c,setError:u,setBusy:d}}function ze(n){let e=je("nova-field"),t=n.hint?`${e}-hint`:void 0,r=w("input",{id:e,type:n.type??"text",className:"nova-input",value:n.value??"",placeholder:n.placeholder,...n.required?{"aria-required":"true"}:{},autocomplete:n.autocomplete??"off",spellcheck:"false","aria-describedby":t});return r.value=n.value??"",{el:w("div",{className:"nova-field"},w("label",{for:e,className:"nova-label"},n.label),r,n.hint?w("p",{id:t,className:"nova-hint"},n.hint):null),input:r}}function Yc(n,e=!1){let t=je("nova-check"),r=w("input",{id:t,type:"checkbox",className:"nova-checkbox"});return r.checked=e,{el:w("div",{className:"nova-field nova-field-inline"},r,w("label",{for:t},n)),input:r}}function v0(n){let e=je("nova-field"),t=w("select",{id:e,className:"nova-input nova-select"},...n.options.map(o=>w("option",{value:o.value},o.label)));return t.value=n.value,{el:w("div",{className:"nova-field"},w("label",{for:e,className:"nova-label"},n.label),t),select:t}}var x0=/^image\/(png|jpe?g|gif|webp|avif|bmp)$/;function so(n){return x0.test(n.type)}function w0(n){return new Promise((e,t)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>t(r.error??new Error("FileReader failed")),r.readAsDataURL(n)})}function Zc(n,e){let t=null;return n.state.doc.descendants((r,o)=>t!==null?!1:(r.type===Z(n.state).image&&r.attrs.src===e&&(t=o),!0)),t}function ns(n,e,t){let r=e.filter(so),o=n.view;for(let i of r){let s=URL.createObjectURL(i),l=Z(o.state).image.create({src:s,alt:null}),a=o.state.tr;t!==void 0?a.insert(Math.min(t,a.doc.content.size),l):a.replaceSelectionWith(l),o.dispatch(a.scrollIntoView()),Qc(n,i,s,0)}}var Ym=[1e3,3e3],rs=class extends Error{};function Qc(n,e,t,r){let o=n.view,{t:i}=n.ui,s=n.options.uploadImage,l=s?n.ui.notify({text:i("image.uploading"),timeout:0}):null,a=s?s(e,d=>l?.setText(`${i("image.uploading")} ${Math.round(d)}%`)):w0(e),c=()=>URL.revokeObjectURL(t),u=()=>{let d=o.isDestroyed?null:Zc(o,t);d!==null&&o.dispatch(o.state.tr.delete(d,d+1).setMeta("addToHistory",!1)),c()};a.then(d=>{if(!fe(d))throw new rs(`Unsafe image URL returned: ${d}`);let p=o.isDestroyed?null:Zc(o,t);if(p!==null){let f=o.state.doc.nodeAt(p);o.dispatch(o.state.tr.setNodeMarkup(p,void 0,{...f.attrs,src:d}).setMeta("addToHistory",!1))}c()}).catch(d=>{if(o.isDestroyed||Zc(o,t)===null)return c();let p=Ym[r];if(s&&p!==void 0&&!(d instanceof rs)){let f=n.ui.notify({text:i("image.retrying"),timeout:0});setTimeout(()=>{if(f.close(),o.isDestroyed)return c();Qc(n,e,t,r+1)},p);return}console.error("[nova] image upload failed",d),n.ui.notify({text:i("image.uploadFailed"),type:"error",actions:[{label:i("image.retry"),onAction:()=>Qc(n,e,t,0)},{label:i("image.delete"),onAction:u}],onClose:u})}).finally(()=>l?.close())}var Xm=/^data:(image\/(?:png|jpe?g|gif|webp|avif|bmp));base64,(.+)$/i;function Zm(n,e="pasted-image"){let t=n.match(Xm);if(!t)return null;let r=t[1].toLowerCase();try{let o=atob(t[2]),i=new Uint8Array(o.length);for(let l=0;l<o.length;l++)i[l]=o.charCodeAt(l);let s=r.split("/")[1].replace("jpeg","jpg");return new File([i],`${e}.${s}`,{type:r})}catch{return null}}function S0(n,e,t){let r=n.state.tr;n.state.doc.descendants((o,i)=>{o.type===Z(n.state).image&&o.attrs.src===e&&r.setNodeMarkup(i,void 0,{...o.attrs,src:t})}),r.docChanged&&n.dispatch(r.setMeta("addToHistory",!1))}async function eu(n,e){let t=n.options.uploadImage,r=t?Zm(e):null;if(!t||!r)return;let o=n.ui.notify({text:n.ui.t("image.uploading"),timeout:0});try{let i=await t(r,s=>o.setText(`${n.ui.t("image.uploading")} ${Math.round(s)}%`));if(!fe(i))throw new Error(`Unsafe image URL returned: ${i}`);S0(n.view,e,i)}catch(i){console.error("[nova] embedded image upload failed",i),n.ui.notify({text:n.ui.t("image.uploadFailed"),type:"error",actions:[{label:n.ui.t("image.retry"),onAction:()=>{eu(n,e)}}]})}finally{o.close()}}function Jm(n,e){let t=new Set;return n.descendants(r=>{r.type===e&&Xm.test(r.attrs.src)&&t.add(r.attrs.src)}),t}function tu(n){return new z({key:new X("nova-embedded-image-upload"),appendTransaction(e,t,r){if(!n.options.uploadImage||!e.some(a=>["paste","drop"].includes(a.getMeta("uiEvent")))||!e.some(a=>a.docChanged))return null;let i=Z(r).image,s=Jm(t.doc,i),l=[...Jm(r.doc,i)].filter(a=>!s.has(a));return l.length&&queueMicrotask(()=>l.forEach(a=>{eu(n,a)})),null}})}function nu(n){return new z({key:new X("nova-image-drop-paste"),props:{handlePaste(e,t){if(!n.isAllowed("image"))return!1;let r=t.clipboardData;if(!r||r.getData("text/html"))return!1;let o=[...r.files].filter(so);return o.length?(ns(n,o),!0):!1},handleDrop(e,t){if(!n.isAllowed("image"))return!1;let r=[...t.dataTransfer?.files??[]].filter(so);if(!r.length)return!1;t.preventDefault();let o=e.posAtCoords({left:t.clientX,top:t.clientY});return ns(n,r,o?.pos),!0}}})}function lo(n){let{t:e}=n.ui,t=w("input",{type:"file",accept:"image/png,image/jpeg,image/gif,image/webp,image/avif",className:"nova-visually-hidden",tabindex:"-1","aria-label":e("image.drop"),"aria-hidden":"true"}),r=w("button",{type:"button",className:"nova-dropzone"},ee(C.upload),w("span",{},e("image.drop"))),o=ze({label:e("image.url"),type:"url",placeholder:"https://"}),i=ze({label:e("image.alt"),hint:e("image.altHint")});io(n,o,"image",c=>{c.alt&&(i.input.value=c.alt)});let s=w("div",{className:"nova-form"},r,t,w("div",{className:"nova-divider"},w("span",{},e("image.or"))),o.el,i.el),l=n.ui.openDialog({title:e("image.title"),body:s,submitLabel:e("dialog.insert"),initialFocus:o.input,onSubmit:()=>{let c=o.input.value.trim();return!c||!fe(c)?(o.input.setAttribute("aria-invalid","true"),o.input.focus(),e("image.invalid")):(n.exec(Bc(c,i.input.value.trim()||void 0)),!0)}}),a=c=>{let u=c.filter(so);u.length&&(l.close(),ns(n,u))};r.addEventListener("click",()=>t.click()),t.addEventListener("change",()=>a([...t.files??[]])),r.addEventListener("dragover",c=>{c.preventDefault(),r.classList.add("is-dragover")}),r.addEventListener("dragleave",()=>r.classList.remove("is-dragover")),r.addEventListener("drop",c=>{c.preventDefault(),r.classList.remove("is-dragover"),a([...c.dataTransfer?.files??[]])})}function et(n){let{selection:e}=n,t=Z(n),r=(i,s)=>i.type===t.figure?{node:i,pos:s,attrs:{...i.firstChild?.attrs,align:i.attrs.align}}:{node:i,pos:s,attrs:i.attrs};if(e instanceof R&&(e.node.type===t.image||e.node.type===t.figure))return r(e.node,e.from);let{$from:o}=e;for(let i=o.depth;i>0;i--)if(o.node(i).type===t.figure)return r(o.node(i),o.before(i));return null}function ru(n){return et(n)?.node.type===Z(n).figure}var M0=["src","alt","title","width","height"],Gm=n=>Object.fromEntries(M0.map(e=>[e,n[e]??null])),ou=(n,e)=>{let t=et(n);if(!t)return!1;let r=Z(n),{pos:o,node:i,attrs:s}=t;if(!e)return!0;let l=n.tr;if(i.type===r.figure){let f=r.image.create({...Gm(s),align:s.align??null}),h=[r.paragraph.create(null,f)],m=i.child(1);return m.content.size&&h.push(r.paragraph.create(null,m.content)),l.replaceWith(o,o+i.nodeSize,h),l.setSelection(R.create(l.doc,o+1)),e(l.scrollIntoView()),!0}let a=n.doc.resolve(o),c=a.before(a.depth),u=a.after(a.depth),d=r.figure.create({align:s.align??null},[r.figure_image.create(Gm(s)),r.figcaption.create()]),p=3;return a.parent.childCount===1?(l.replaceWith(c,u,d),l.setSelection(F.create(l.doc,c+p))):(l.insert(u,d),l.delete(o,o+i.nodeSize),l.setSelection(F.create(l.doc,l.mapping.map(u,-1)+p))),e(l.scrollIntoView()),!0},iu=(n,e)=>{let{$from:t}=n.selection;if(t.parent.type!==Z(n).figcaption)return!1;if(e){let r=t.after(t.depth-1),o=n.tr.insert(r,Z(n).paragraph.create());o.setSelection(F.create(o.doc,r+1)),e(o.scrollIntoView())}return!0};function ur(n){return(e,t)=>{let r=et(e);if(!r)return!1;if(t){let o=e.tr;if(r.node.type===Z(e).figure){let{align:i,...s}=n;if(i!==void 0&&o.setNodeMarkup(r.pos,void 0,{...r.node.attrs,align:i}),Object.keys(s).length){let l=r.node.firstChild;o.setNodeMarkup(r.pos+1,void 0,{...l.attrs,...s})}}else o.setNodeMarkup(r.pos,void 0,{...r.node.attrs,...n}),o.setSelection(R.create(o.doc,r.pos));t(o)}return!0}}function su(n,e){let t=et(n.view.state);if(!t)return!1;if(e===null)return n.exec(ur({width:null,height:null}));let o=n.view.nodeDOM(t.pos)?.querySelector("img")??null,i=getComputedStyle(n.view.dom),s=n.view.dom.clientWidth-parseFloat(i.paddingLeft||"0")-parseFloat(i.paddingRight||"0"),l=Math.max(24,Math.round(s*e)),a=o&&o.naturalWidth?o.naturalHeight/o.naturalWidth:null;return n.exec(ur({width:l,height:a?Math.round(l*a):null}))}function lu(n){let e=et(n.view.state);if(!e)return;let{t}=n.ui,r=ze({label:t("image.alt"),value:String(e.attrs.alt??""),hint:t("image.altHint")}),o=ze({label:t("link.tooltip"),value:String(e.attrs.title??"")});n.ui.openDialog({title:t("image.editAlt"),body:w("div",{className:"nova-form"},r.el,o.el),submitLabel:t("dialog.save"),initialFocus:r.input,onSubmit:()=>(n.exec(ur({alt:r.input.value.trim()||null,title:o.input.value.trim()||null})),!0)})}function E0(n){let e=n.dom.ownerDocument.getSelection(),t=e?.focusNode;if(!e||!t||!n.dom.contains(t))return null;try{return n.posAtDOM(t,e.focusOffset)}catch{return null}}function Qm(){let n=!0;return new z({props:{handleDOMEvents:{mousedown(e){return n=e.hasFocus(),!1}},handleClick(e,t,r){if(n||r.button!==0||r.shiftKey||r.detail>1)return!1;let{doc:o}=e.state,i=e.posAtCoords({left:r.clientX,top:r.clientY}),s=i&&i.inside>=0?o.nodeAt(i.inside):null;if(s&&!s.isTextblock)return!1;let l=o.resolve(t),a=E0(e);if(a!==null&&o.resolve(a).parent===l.parent)return!1;let c=U.near(l);return e.state.selection.eq(c)||e.dispatch(e.state.tr.setSelection(c).setMeta("pointer",!0)),e.focus(),!0}}})}var ao=new X("nova-announce");function ie(n){return(e,t,r)=>Ue[n](e,t&&(o=>t(o.setMeta(ao,n))),r)}var C0=new Set(["bold","italic","underline","strike","code","subscript","superscript","bulletList","orderedList"]),A0=new Set(["paragraph","h1","h2","h3","h4","h5","h6"]),eg=["alignLeft","alignCenter","alignRight","alignJustify"];function cu(n){let{$from:e}=n.selection,t=[];for(let r=1;r<=e.depth;r++){let o=e.node(r),i=o.type.name;i==="bullet_list"?t.push("bulletList"):i==="ordered_list"?t.push("orderedList"):i==="blockquote"?t.push("blockquote"):i==="code_block"?t.push("codeBlock"):i==="heading"&&t.push(`h${Math.min(6,Math.max(1,Number(o.attrs.level)||1))}`)}return t}function T0(n,e,t){if(C0.has(e))return t(cr(n,e)?"announce.on":"announce.off",{name:t(e)});if(A0.has(e)){let r=cu(n).filter(o=>/^h[1-6]$/.test(o)).pop();return t(r??"paragraph")}return eg.includes(e)?t(eg.find(r=>cr(n,r))??"alignLeft"):t(e)}function N0(n,e,t){let r=cu(n),o=cu(e),i=o.findIndex((s,l)=>s!==r[l]);return i<0?null:t(o[i])}function tg(n,e){return new z({key:ao,state:{init:()=>null,apply(t,r,o,i){let s=t.getMeta(ao);return s?{command:s}:i.plugins.some(l=>l.spec.isInputRules&&t.getMeta(l))?{typed:!0}:null}},view:()=>({update(t,r){let o=ao.getState(t.state);if(!o||o===ao.getState(r))return;let i="command"in o?T0(t.state,o.command,n):N0(r,t.state,n);i&&e(i)}})})}var rg={options:{},commands:{},events:{}},og={options:"the option",commands:"the command",events:"the event"},ng=new Set;function ig(n,e){ng.has(n)||(ng.add(n),console.warn(`[nova] ${n} is deprecated: use ${e}. Old names keep working for at least one minor version (https://novaprose.com/project/versioning/).`))}var O0=(n,e)=>Object.prototype.hasOwnProperty.call(n,e)?n[e]:void 0;function co(n,e,t=rg){let r=O0(t[n],e);return r===void 0?e:(ig(`${og[n]} "${e}"`,`"${r}"`),r)}function sg(n,e=rg){let t=n;for(let[r,o]of Object.entries(e.options))Object.prototype.hasOwnProperty.call(n,r)&&(ig(`${og.options} "${r}"`,`"${o}"`),t===n&&(t={...t}),Object.prototype.hasOwnProperty.call(t,o)||(t[o]=t[r]),delete t[r]);return t}var fu={};q(fu,{InputRule:()=>tt,closeDoubleQuote:()=>cg,closeSingleQuote:()=>dg,ellipsis:()=>pu,emDash:()=>du,inputRules:()=>uu,openDoubleQuote:()=>ag,openSingleQuote:()=>ug,smartQuotes:()=>D0,textblockTypeInputRule:()=>is,undoInputRule:()=>R0,wrappingInputRule:()=>uo});var tt=class{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?L0(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}};function L0(n){return function(e,t,r,o){let i=n;if(t[1]){let s=t[0].lastIndexOf(t[1]);i+=t[0].slice(s+t[1].length),r+=s;let l=r-o;l>0&&(i=t[0].slice(s-l,s)+i,r=o)}return e.tr.insertText(i,r,o)}}var P0=500;function uu({rules:n}){let e=new z({state:{init(){return null},apply(t,r){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,o,i){return lg(t,r,o,i,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&lg(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function lg(n,e,t,r,o,i){if(n.composing)return!1;let s=n.state,l=s.doc.resolve(e),a=n.state.selection,c=l.parent.textBetween(Math.max(0,l.parentOffset-P0),l.parentOffset,null,"\uFFFC")+r,u=e==a.from&&t==a.to&&n.state.storedMarks||(e==t?l.marks():l.marksAcross(s.doc.resolve(t))||[]);for(let d=0;d<o.length;d++){let p=o[d];if(!p.inCodeMark&&u.some(g=>g.type.spec.code))continue;if(l.parent.type.spec.code){if(!p.inCode)continue}else if(p.inCode==="only")continue;let f=p.match.exec(c);if(!f||f[0].length<r.length)continue;let h=e-(f[0].length-r.length);if(!p.inCodeMark){let g=!1;if(s.doc.nodesBetween(h,l.pos,k=>{k.isInline&&k.marks.some(x=>x.type.spec.code)&&(g=!0)}),g)continue}let m=p.handler(s,f,h,t,r);if(m)return p.undoable&&m.setMeta(i,{transform:m,from:e,to:t,text:r}),n.dispatch(m),!0}return!1}var R0=(n,e)=>{let t=n.plugins;for(let r=0;r<t.length;r++){let o=t[r],i;if(o.spec.isInputRules&&(i=o.getState(n))){if(e){let s=n.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a--)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,n.schema.text(i.text,a))}else s.delete(i.from,i.to);e(s)}return!0}}return!1},du=new tt(/--$/,"\u2014",{inCodeMark:!1}),pu=new tt(/\.\.\.$/,"\u2026",{inCodeMark:!1}),ag=new tt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),cg=new tt(/"$/,"\u201D",{inCodeMark:!1}),ug=new tt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),dg=new tt(/'$/,"\u2019",{inCodeMark:!1}),D0=[ag,cg,ug,dg];function uo(n,e,t,r){let o,i;return e instanceof st?i=e:(o=e,i=e.nodeType,t=e.getAttrs,r=e.joinPredicate),new tt(n,(s,l,a,c)=>{let u=t instanceof Function?t(l):t,d=s.tr.delete(a,c),p=d.doc.resolve(a),f=p.blockRange(),h=f&&ln(f,i,u);if(!h)return null;d.wrap(f,h);let m=d.doc.resolve(a-1).nodeBefore;return m&&m.type==i&&ct(d.doc,a-1)&&(!r||r(l,m))&&d.join(a-1),d},o)}function is(n,e,t){let r,o;return e instanceof st?o=e:(r=e,o=e.nodeType,t=e.getAttrs),new tt(n,(i,s,l,a)=>{let c=i.doc.resolve(l),u=t instanceof Function?t(s):t;return c.node(-1).canReplaceWith(c.index(-1),c.indexAfter(-1),o)?i.tr.delete(l,a).setBlockType(l,l,o,u):null},r)}var pg="([A-Za-z0-9_+#.-]{0,32})";function fg(n=()=>!0,e=Lt){let{nodes:t}=e,r=[pu,du];n("blockquote")&&r.push(uo(/^\s*>\s$/,t.blockquote)),n("numlist")&&r.push(uo(/^(\d+)\.\s$/,t.ordered_list,o=>({start:Number(o[1])}),(o,i)=>i.childCount+i.attrs.start===Number(o[1]))),n("bullist")&&r.push(uo(/^\s*([-+*])\s$/,t.bullet_list)),n("codeblock")&&r.push(is(new RegExp(`^\`\`\`${pg}\\s$`),t.code_block,o=>({language:o[1]||null})));for(let o=1;o<=6;o++)n(`h${o}`)&&r.push(is(new RegExp(`^(#{${o}})\\s$`),t.heading,{level:o}));return uu({rules:r})}function hg(n=()=>!0,e=Lt){let t=new RegExp(`^\`\`\`${pg}$`);return Ke({Enter:(o,i)=>{let{$from:s,empty:l}=o.selection,a=s.parent;if(!l||a.type!==e.nodes.paragraph||!n("codeblock")||s.parentOffset!==a.content.size||a.childCount!==1)return!1;let c=a.firstChild.isText?t.exec(a.textContent):null;if(!c)return!1;let u=s.index(-1);if(!s.node(-1).canReplaceWith(u,u+1,e.nodes.code_block))return!1;if(i){let d=s.start(),p=o.tr.delete(d,s.pos).setBlockType(d,d,e.nodes.code_block,{language:c[1]||null});i(p.scrollIntoView())}return!0}})}var mg={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike",strike:"strike",code:"code",subscript:"subscript",superscript:"superscript",p:"paragraph",paragraph:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",blockquote:"blockquote",pre:"codeBlock"};function gg(n){let e=[];for(let t of n){let r=t;if(!(!r||typeof r.start!="string"||!r.start||r.start.length>40))if(typeof r.replacement=="string")e.push({start:r.start,replacement:r.replacement});else{if(typeof r.format!="string"&&!r.command)continue;typeof r.end=="string"&&r.end,e.push(r)}}return e.sort((t,r)=>r.start.length-t.start.length)}function _0(n){let{$from:e,empty:t}=n.selection;return!t||!e.parent.isTextblock||e.parent.type.spec.code||e.marks().some(r=>r.type.spec.code)?null:e.parent.textBetween(0,e.parentOffset,void 0,"\uFFFC")}function yg(n,e){let{format:t,command:r,value:o}=e;typeof r=="function"?r(n,o):typeof r=="string"?n.exec(r):t&&n.formatter.has(t)?n.formatter.apply(t):t&&mg[t]&&n.exec(mg[t])}function bg(n,e,t){let r=gg(e),o=(s,l)=>{if(!t)return r;let{$from:a}=s.state.selection,c=s.nodeDOM(a.before()),u=[];try{u=t({text:l,block:c instanceof HTMLElement?c:null})}catch(d){console.error("[nova] textPatternsLookup failed:",d)}return Array.isArray(u)?gg([...r,...u]):r},i=(s,l)=>{let a=_0(s.state);if(a===null||!n.isEditable())return null;let{$from:c}=s.state.selection,u=c.start();for(let d of o(s,a)){if("replacement"in d){if(!a.endsWith(d.start))continue;let f=c.pos-d.start.length;return/<[a-z]/i.test(d.replacement)?(s.dispatch(s.state.tr.delete(f,c.pos)),n.insertContent(d.replacement),s.dispatch(s.state.tr.setStoredMarks([]))):s.dispatch(s.state.tr.insertText(d.replacement,f,c.pos)),"replacement"}if("end"in d){if(!a.endsWith(d.end))continue;let f=a.lastIndexOf(d.start,a.length-d.end.length-1),h=f+d.start.length,m=a.length-d.end.length;if(f<0||m<=h||/^\s|\s$/.test(a.slice(h,m)))continue;let g=s.state.tr.delete(u+m,u+a.length).delete(u+f,u+h),k=u+f,x=k+(m-h);s.dispatch(g.setSelection(F.create(g.doc,k,x))),yg(n,d);let{state:M}=s;return s.dispatch(M.tr.setSelection(F.create(M.doc,M.selection.to))),s.dispatch(s.state.tr.setStoredMarks([])),"inline"}if(!((d.trigger??"space")!==l||!(l==="space"?a===d.start:c.parent.textContent.startsWith(d.start)&&c.parentOffset===c.parent.content.size)))return s.dispatch(s.state.tr.delete(u,u+d.start.length)),yg(n,d),"block"}return null};return new z({props:{handleTextInput(s,l,a,c){if(c!==" "||l!==a)return!1;let u=i(s,"space");return u?(u!=="block"&&s.dispatch(s.state.tr.insertText(" ")),!0):!1},handleKeyDown(s,l){return l.key!=="Enter"||l.shiftKey||l.ctrlKey||l.metaKey||i(s,"enter"),!1}}})}var I0=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),H0=sr(Cc,(n,e)=>(e?.(n.tr.replaceSelectionWith(Z(n).hard_break.create()).scrollIntoView()),!0)),hu=(n,e)=>(t,r,o)=>n(e)(t,r,o);function kg(n=e=>Ue[e]){let e={"Mod-z":hu(n,"undo"),"Shift-Mod-z":hu(n,"redo"),"Mod-b":ie("bold"),"Mod-i":ie("italic"),"Mod-u":ie("underline"),"Mod-Shift-x":ie("strike"),"Mod-e":ie("code"),"Mod-,":ie("subscript"),"Mod-.":ie("superscript"),"Mod-Alt-0":ie("paragraph"),"Mod-Alt-1":ie("h1"),"Mod-Alt-2":ie("h2"),"Mod-Alt-3":ie("h3"),"Mod-Alt-4":ie("h4"),"Mod-Alt-5":ie("h5"),"Mod-Alt-6":ie("h6"),"Mod-Shift-7":ie("orderedList"),"Mod-Shift-8":ie("bulletList"),"Mod-Shift-l":ie("alignLeft"),"Mod-Shift-e":ie("alignCenter"),"Mod-Shift-r":ie("alignRight"),"Mod-Shift-j":ie("alignJustify"),"Mod-\\":ie("clearFormatting"),"Shift-Enter":H0,Enter:sr(iu,(t,r)=>{let i=typeof B0(t)?.attrs.checked=="boolean"?{checked:!1}:void 0;return di(Z(t).list_item,i)(t,r)}),Tab:Ic,"Shift-Tab":Hc,"Mod-]":Ue.indent,"Mod-[":Ue.outdent,"Alt-Shift-ArrowUp":Ue.moveBlockUp,"Alt-Shift-ArrowDown":Ue.moveBlockDown};return I0||(e["Mod-y"]=hu(n,"redo")),[Ke(e),Ke(Cm)]}function B0(n){let{$from:e}=n.selection;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type===Z(n).list_item)return r}return null}var yu={};q(yu,{applyLink:()=>vg,normalizeUrl:()=>mu,openLinkDialog:()=>_t,removeLink:()=>dr});function mu(n){let e=n.trim();return e?/^[a-z][a-z0-9+.-]*:/i.test(e)||/^[/#?.]/.test(e)?e:/^[^\s@/]+@[^\s@/]+\.[^\s@/]+$/.test(e)?`mailto:${e}`:/^(www\.)?[^\s/]+\.[a-z]{2,}([/:?#].*)?$/i.test(e)?`https://${e}`:e:""}function gu(n){let{from:e,to:t,empty:r,$from:o}=n.selection;return r?An(n,ce(n).link,o.pos)??{from:e,to:t}:{from:e,to:t}}function vg(n){return(e,t)=>{let r=mu(n.href);if(!r||!Ie(r))return!1;if(!t)return!0;let{from:o,to:i}=gu(e),s=ce(e).link.create({href:r,title:n.title||null,target:n.target||null}),l=e.doc.textBetween(o,i),a=n.text?.trim()?n.text:null,c=e.tr;if(o===i||a!==null&&a!==l){let u=ce(e).link.removeFromSet(e.doc.resolve(o).marks()),d=e.schema.text(a??(l||r),s.addToSet(u));c.replaceWith(o,i,d)}else c.removeMark(o,i,ce(e).link).addMark(o,i,s);return t(c.scrollIntoView()),!0}}function dr(){return(n,e)=>{let{from:t,to:r}=gu(n);return t===r||!n.doc.rangeHasMark(t,r,ce(n).link)?!1:(e?.(n.tr.removeMark(t,r,ce(n).link)),!0)}}function _t(n){let{t:e}=n.ui,t=n.view.state,r=Cn(t),o=gu(t),i=t.doc.textBetween(o.from,o.to),s=!i.includes(`
24
+ `)&&t.selection.$from.sameParent(t.doc.resolve(o.to)),l=ze({label:e("link.url"),type:"url",value:r?.href??"",placeholder:"https://",required:!0}),a=ze({label:e("link.text"),value:i}),c=ze({label:e("link.tooltip"),value:r?.title??""}),u=Yc(e("link.newTab"),r?.target==="_blank");io(n,l,"file",p=>{p.text&&!a.input.value.trim()&&(a.input.value=p.text),p.title&&(c.input.value=p.title)});let d=w("div",{className:"nova-form"},l.el,s?a.el:null,c.el,u.el);n.ui.openDialog({title:e(r?"link.editTitle":"link.title"),body:d,submitLabel:e(r?"dialog.save":"dialog.insert"),initialFocus:l.input,onSubmit:()=>{let p=mu(l.input.value);return!p||!Ie(p)?(l.input.setAttribute("aria-invalid","true"),l.input.focus(),l.input.value.trim()?e("link.invalid"):e("dialog.required")):(n.exec(vg({href:p,...s?{text:a.input.value}:{},title:c.input.value.trim()||null,target:u.input.checked?"_blank":null})),!0)}})}function xg(n){return/<img[^>]+src=["']?file:/i.test(n)}var bt=null,ss=null;function bu(){return ss??(ss=import(__novaChunk("tinymce-chunks/paste-office-4e8e9cb7.js") ).then(n=>bt=n,()=>(ss=null,null))),ss}var F0=new X("nova-paste");function z0(n){let e=document.createElement("template");e.innerHTML=n;let t=/^(P|DIV|H[1-6]|LI|BLOCKQUOTE|PRE|TR|SECTION|ARTICLE|HEADER|FOOTER)$/,r="",o=i=>{if(i.nodeType===Node.TEXT_NODE){r+=(i.textContent??"").replace(/\s+/g," ");return}if(!(i instanceof Element)){i.childNodes.forEach(o);return}if(/^(SCRIPT|STYLE|META|TITLE|HEAD)$/.test(i.tagName))return;if(i.tagName==="BR"){r+=`
25
25
  `;return}let s=t.test(i.tagName);s&&r&&!r.endsWith(`
26
26
  `)&&(r+=`
27
27
  `),i.childNodes.forEach(o),s&&(r+=`
@@ -29,20 +29,20 @@ ${t}
29
29
  `).map(i=>i.trim()).join(`
30
30
  `).replace(/\n{3,}/g,`
31
31
 
32
- `).trim()}function ug(n){let e=!1;return new z({key:C0,props:{transformPasted(t,r){let{selection:o}=r.state,i=o.$from.parent;return t.openStart>0&&o.empty&&i.isTextblock&&i.content.size===0&&t.content.firstChild?.isBlock?new D(t.content,0,t.openEnd):t},transformPastedHTML(t){let{pastePreprocess:r,pastePostprocess:o,pasteStyles:i}=n.options,s=r?r(t,n):t;if(yt&&(s=yt.cleanPastedHTML(s,i??"clean")),o){let l=document.createElement("template");l.innerHTML=s;let a=document.createElement("div");a.append(l.content),o(a,n),s=a.innerHTML}return s},handleDOMEvents:{paste(t,r){if(yt||e||n.isPasteAsText())return!1;let o=r.clipboardData;if(o?.getData(pg))return!1;let i=o?.getData("text/html");if(!i)return!1;let s=cg(i)?o?.getData("text/rtf")??"":"";return r.preventDefault(),dd().then(()=>{if(t.isDestroyed)return;let l=s&&yt&&n.isAllowed("image")?yt.replaceLocalImages(i,yt.extractRtfImages(s)):i;e=!0;try{t.pasteHTML(l)}finally{e=!1}}),!0}},handlePaste(t,r,o){if(e)return!1;let i=a=>{e=!0;try{t.pasteText(a)}finally{e=!1}};if(T0(t,r,n,i))return!0;let s=r.clipboardData?.getData("text/html");if(!n.isPasteAsText()){let a=s&&cg(s)?r.clipboardData?.getData("text/rtf"):"";if(!s||!a||!yt||!n.isAllowed("image"))return!1;let c=yt.replaceLocalImages(s,yt.extractRtfImages(a));if(c===s)return!1;e=!0;try{t.pasteHTML(c,r)}finally{e=!1}return!0}let l=s?A0(s):r.clipboardData?.getData("text/plain")||o.content.textBetween(0,o.content.size,`
32
+ `).trim()}function $0(n){return Fe(n.options.contentLanguage)??Fe(n.root.parentElement?.closest("[lang]")?.getAttribute("lang"))}function V0(n,e){if(!e||!/\slang\s*=/i.test(n))return n;let t=document.createElement("template");t.innerHTML=n;let r=!1;for(let i of t.content.querySelectorAll("[lang]")){let s=Fe(i.getAttribute("lang"));s&&xi(s)===xi(e)&&(i.removeAttribute("lang"),r=!0)}if(!r)return n;let o=document.createElement("div");return o.append(t.content),o.innerHTML}function Sg(n){let e=!1;return new z({key:F0,props:{transformPasted(t,r){let{selection:o}=r.state,i=o.$from.parent;return t.openStart>0&&o.empty&&i.isTextblock&&i.content.size===0&&t.content.firstChild?.isBlock?new D(t.content,0,t.openEnd):t},transformPastedHTML(t){let{pastePreprocess:r,pastePostprocess:o,pasteStyles:i}=n.options,s=r?r(t,n):t;if(bt&&(s=bt.cleanPastedHTML(s,i??"clean")),s=V0(s,$0(n)),o){let l=document.createElement("template");l.innerHTML=s;let a=document.createElement("div");a.append(l.content),o(a,n),s=a.innerHTML}return s},handleDOMEvents:{paste(t,r){if(bt||e||n.isPasteAsText())return!1;let o=r.clipboardData;if(o?.getData(Mg))return!1;let i=o?.getData("text/html");if(!i)return!1;let s=xg(i)?o?.getData("text/rtf")??"":"";return r.preventDefault(),bu().then(()=>{if(t.isDestroyed)return;let l=s&&bt&&n.isAllowed("image")?bt.replaceLocalImages(i,bt.extractRtfImages(s)):i;e=!0;try{t.pasteHTML(l)}finally{e=!1}}),!0}},handlePaste(t,r,o){if(e)return!1;let i=a=>{e=!0;try{t.pasteText(a)}finally{e=!1}};if(q0(t,r,n,i))return!0;let s=r.clipboardData?.getData("text/html");if(!n.isPasteAsText()){let a=s&&xg(s)?r.clipboardData?.getData("text/rtf"):"";if(!s||!a||!bt||!n.isAllowed("image"))return!1;let c=bt.replaceLocalImages(s,bt.extractRtfImages(a));if(c===s)return!1;e=!0;try{t.pasteHTML(c,r)}finally{e=!1}return!0}let l=s?z0(s):r.clipboardData?.getData("text/plain")||o.content.textBetween(0,o.content.size,`
33
33
 
34
- `);return l?(i(l),!0):!1}}})}var pg="vscode-editor-data",dg={shellscript:"bash",typescriptreact:"tsx",javascriptreact:"jsx",jsonc:"json"};function T0(n,e,t,r){let o=e.clipboardData,i=o?.getData(pg),s=o?.getData("text/plain");if(!i||!s||n.state.selection.$from.parent.type.spec.code)return!1;let l;try{l=JSON.parse(i).mode}catch{}if(l==="markdown"&&t.hasPlugin("markdown")&&!t.isPasteAsText())return!1;let a=s.replace(/\r\n?/g,`
34
+ `);return l?(i(l),!0):!1}}})}var Mg="vscode-editor-data",wg={shellscript:"bash",typescriptreact:"tsx",javascriptreact:"jsx",jsonc:"json"};function q0(n,e,t,r){let o=e.clipboardData,i=o?.getData(Mg),s=o?.getData("text/plain");if(!i||!s||n.state.selection.$from.parent.type.spec.code)return!1;let l;try{l=JSON.parse(i).mode}catch{}if(l==="markdown"&&t.hasPlugin("markdown")&&!t.isPasteAsText())return!1;let a=s.replace(/\r\n?/g,`
35
35
  `).replace(/\n$/,""),c=n.state.schema.nodes.code_block;if(!a.includes(`
36
- `)||l==="markdown"||l==="plaintext"||t.isPasteAsText()||!c||!t.isAllowed("codeblock"))return r(a),!0;let d=typeof l=="string"?Object.hasOwn(dg,l)?dg[l]:kn(l):null,u=c.create({language:d},n.state.schema.text(a));return n.dispatch(n.state.tr.replaceSelection(new D(N.from(u),0,0)).setMeta("uiEvent","paste").scrollIntoView()),!0}var yd={};j(yd,{MAX_GRID:()=>dr,createTable:()=>fg,createTableGridPanel:()=>gd,getCellProps:()=>R0,getTableProps:()=>L0,hasHeaderColumn:()=>hd,hasHeaderRow:()=>fd,insertTable:()=>_t,isCellSelection:()=>O0,isInTable:()=>Jt,loadTables:()=>ud,loadedTables:()=>N0,setCellBackground:()=>pd,setCellProps:()=>D0,setTableProps:()=>P0,sortTable:()=>ts,tableCommands:()=>ze,tableRect:()=>md});var xe=null,es=null;function ud(){return es??(es=import(__novaChunk("tinymce-chunks/table-4d43f60d.js") ).then(n=>xe=n,n=>(console.warn("[nova] failed to load table editing",n),es=null,null))),es}function N0(){return xe}var tt=n=>(e,t,r)=>xe?xe.tableCommands[n](e,t,r):!1,ze={addRowBefore:tt("addRowBefore"),addRowAfter:tt("addRowAfter"),deleteRow:tt("deleteRow"),addColumnBefore:tt("addColumnBefore"),addColumnAfter:tt("addColumnAfter"),deleteColumn:tt("deleteColumn"),mergeCells:tt("mergeCells"),splitCell:tt("splitCell"),toggleHeaderRow:tt("toggleHeaderRow"),toggleHeaderColumn:tt("toggleHeaderColumn"),deleteTable:tt("deleteTable")};function pd(n){return(e,t,r)=>xe?xe.setCellBackground(n)(e,t,r):!1}function fd(n){return xe?.hasHeaderRow(n)??!1}function hd(n){return xe?.hasHeaderColumn(n)??!1}function O0(n){return xe?.isCellSelection(n)??!1}function L0(n){return xe?.getTableProps(n)??null}function P0(n){return(e,t,r)=>xe?xe.setTableProps(n)(e,t,r):!1}function R0(n){return xe?.getCellProps(n)??null}function D0(n){return(e,t,r)=>xe?xe.setCellProps(n)(e,t,r):!1}function ts(n,e){return(t,r,o)=>xe?xe.sortTable(n,e)(t,r,o):!1}var dr=10;function md(n){let{$from:e}=n.view.state.selection;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole==="table")return n.view.nodeDOM(e.before(t))?.getBoundingClientRect()??null;return null}function fg(n,e,t=!0,r=Ot){let{table:o,table_row:i,table_cell:s,table_header:l,paragraph:a}=r.nodes,c=[];for(let d=0;d<n;d++){let u=t&&d===0?l:s,p=[];for(let f=0;f<e;f++)p.push(u.create(null,a.create()));c.push(i.create(null,p))}return o.create(null,c)}function _t(n,e,t=!0){return(r,o)=>{if(n<1||e<1||n>100||e>50||Jt(r))return!1;if(o){let i=fg(n,e,t,r.schema),s=Hi(r.tr,i),l=-1;s.doc.descendants((a,c)=>(a===i&&(l=c),l<0)),l>=0&&s.setSelection(F.near(s.doc.resolve(l+3))),o(s.scrollIntoView())}return!0}}function gd(n,e,t){let r=1,o=1,i=[],s=w("div",{className:"nova-grid-caption","aria-live":"polite"}),l=w("div",{className:"nova-grid",role:"grid","aria-label":t}),a=()=>{for(let c of i){let d=Number(c.dataset.row),u=Number(c.dataset.col);c.classList.toggle("is-on",d<=r&&u<=o),c.tabIndex=d===r&&u===o?0:-1}s.textContent=e(r,o)};for(let c=1;c<=dr;c++)for(let d=1;d<=dr;d++){let u=w("button",{type:"button",className:"nova-grid-cell",role:"gridcell","aria-label":e(c,d),"data-row":String(c),"data-col":String(d)});u.addEventListener("mouseenter",()=>{r=c,o=d,a()}),u.addEventListener("click",()=>n(c,d)),i.push(u),l.append(u)}return l.addEventListener("keydown",c=>{let u={ArrowRight:[0,1],ArrowLeft:[0,-1],ArrowDown:[1,0],ArrowUp:[-1,0]}[c.key];u&&(c.preventDefault(),r=Math.min(dr,Math.max(1,r+u[0])),o=Math.min(dr,Math.max(1,o+u[1])),a(),i[(r-1)*dr+(o-1)].focus())}),a(),w("div",{className:"nova-grid-panel"},l,s)}var wd={};j(wd,{createRenderer:()=>kg,htmlSerializer:()=>fr,isRtlLanguage:()=>rs,renderHTML:()=>q0,sanitizeJSON:()=>co,schemaFromOptions:()=>is});var hg={b:"strong",i:"em",strike:"s",del:"s",tbody:"table",thead:"table",tfoot:"table",caption:"table",colgroup:"table",col:"table",figcaption:"figure"},_0=["p","h1","h2","h3","h4","h5","h6","blockquote","pre","hr","ul","ol","li","img","figure","br","table","tr","td","th","strong","em","u","s","code","a","sub","sup","span"];var I0={bold:["strong"],italic:["em"],underline:["u"],strikethrough:["s"],strike:["s"],inlinecode:["code"],code:["code"],subscript:["sub"],superscript:["sup"],link:["a"],unlink:["a"],quicklink:["a"],image:["img"],quickimage:["img"],table:["table"],quicktable:["table"],inserttable:["table"],tableinsertrowbefore:["table"],tableinsertrowafter:["table"],tabledeleterow:["table"],tableinsertcolbefore:["table"],tableinsertcolafter:["table"],tabledeletecol:["table"],tablemergecells:["table"],tablesplitcells:["table"],tabledelete:["table"],tablerowheader:["th"],tablecolheader:["th"],tablecellbackground:["style:background-color"],bullist:["ul"],checklist:["ul"],accordion:["details"],bulletlist:["ul"],numlist:["ol"],orderedlist:["ol"],blockquote:["blockquote"],codeblock:["pre"],hr:["hr"],horizontalrule:["hr"],h1:["h1"],h2:["h2"],h3:["h3"],h4:["h4"],h5:["h5"],h6:["h6"],forecolor:["span","style:color"],backcolor:["span","style:background-color"],fontfamily:["span","style:font-family"],fontsize:["span","style:font-size"],lineheight:["style:line-height"],align:["style:text-align"],alignleft:["style:text-align"],aligncenter:["style:text-align"],alignright:["style:text-align"],alignjustify:["style:text-align"],imagealignleft:["style:float"],imagealigncenter:["style:float"],imagealignright:["style:float"]};function bd(n){if(n===void 0)return null;let e=new Set;for(let t of n.split(",")){let r=t.trim().replace(/^[-#+!]+/,"").replace(/\[.*$/,"").toLowerCase();for(let o of r.split("/")){let i=o.trim();i&&e.add(hg[i]??i)}}return e}function H0(n){if(n===void 0)return null;let e=typeof n=="string"?n:Object.values(n).join(",");return new Set(e.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean))}var ur=class{constructor(e){S(this,"tags");S(this,"styles");let t=bd(e.validElements),r=bd(e.invalidElements)??new Set,o=new Set(t??_0);if(t)for(let i of bd(e.extendedValidElements)??[])o.add(i);(o.has("ul")||o.has("ol"))&&o.add("li"),o.has("table")&&(o.add("tr"),o.add("td"));for(let i of r)o.delete(i);o.add("p"),this.tags=o,this.styles=H0(e.validStyles)}isTagAllowed(e){let t=e.toLowerCase();return this.tags.has(hg[t]??t)}isStyleAllowed(e){return!this.styles||this.styles.has(e.toLowerCase())}isAllowed(e){let t=I0[e.toLowerCase()];return t?t.every(r=>r.startsWith("style:")?this.isStyleAllowed(r.slice(6)):this.isTagAllowed(r)):!0}markAllowed(e){switch(e.type.name){case"bold":return this.isTagAllowed("strong");case"italic":return this.isTagAllowed("em");case"underline":return this.isTagAllowed("u");case"strike":return this.isTagAllowed("s");case"code":return this.isTagAllowed("code");case"link":return this.isTagAllowed("a");case"subscript":return this.isTagAllowed("sub");case"superscript":return this.isTagAllowed("sup");case"color":return this.isTagAllowed("span")&&this.isStyleAllowed("color");case"background":return this.isTagAllowed("span")&&this.isStyleAllowed("background-color");case"font_family":return this.isTagAllowed("span")&&this.isStyleAllowed("font-family");case"font_size":return this.isTagAllowed("span")&&this.isStyleAllowed("font-size");default:return!0}}blockAttrs(e){return{...e,...this.isStyleAllowed("text-align")?{}:{align:null},...this.isStyleAllowed("line-height")?{}:{lineHeight:null},...this.isStyleAllowed("margin-left")?{}:{indent:0}}}normalize(e){let t=e.type.schema,{nodes:r}=t;if(e.isText){let l=e.marks.filter(a=>this.markAllowed(a));return[l.length===e.marks.length?e:e.mark(l)]}let o=e.marks.filter(l=>this.markAllowed(l));switch(e.type){case r.image:return this.isTagAllowed("img")?[r.image.create({...e.attrs,...this.isStyleAllowed("float")?{}:{align:null}},null,o)]:[];case r.figure:{let l=e.childCount>1?e.child(1).content:null,a=l?.size?[r.paragraph.create(null,this.normalizeChildren(l))]:[],c=e.firstChild;if(!this.isTagAllowed("img")||!c)return a;let d=this.isStyleAllowed("float")?e.attrs.align:null;if(!this.isTagAllowed("figure")){let u=r.image.create({...c.attrs,align:d});return[r.paragraph.create(null,u),...a]}return[r.figure.create({...e.attrs,align:d},e.content)]}case r.hard_break:return this.isTagAllowed("br")?[e.mark(o)]:[t.text(" ",o)];case r.horizontal_rule:return this.isTagAllowed("hr")?[e]:[]}let i=this.normalizeChildren(e.content),s=(l=e.type,a=e.attrs)=>{try{return[l.createChecked(a,i,e.marks)]}catch{let c=l.createAndFill(a,i,e.marks);return c?[c]:i.content.length?kd(i):[]}};if(e.type.name==="details"&&!this.isTagAllowed("details")){let l=[];return i.forEach(a=>{a.type.name!=="details_summary"?l.push(a):a.content.size&&l.push(r.paragraph.create(null,a.content))}),l}switch(e.type){case r.paragraph:return s(r.paragraph,this.blockAttrs(e.attrs));case r.heading:return this.isTagAllowed(`h${e.attrs.level}`)?s(r.heading,this.blockAttrs(e.attrs)):s(r.paragraph,this.blockAttrs({align:e.attrs.align,lineHeight:e.attrs.lineHeight}));case r.blockquote:return this.isTagAllowed("blockquote")?s():kd(i);case r.code_block:return this.isTagAllowed("pre")?s():e.textContent.split(`
37
- `).map(l=>r.paragraph.create(null,l?t.text(l):null));case r.bullet_list:case r.ordered_list:return this.isTagAllowed(e.type===r.bullet_list?"ul":"ol")?s(e.type,{...e.attrs,...this.isStyleAllowed("list-style-type")?{}:{listStyle:null}}):B0(i);case r.table:return this.isTagAllowed("table")?s():F0(i);case r.table_header:return this.isTagAllowed("th")?s():s(r.table_cell,e.attrs);case r.table_cell:return s(r.table_cell,{...e.attrs,...this.isStyleAllowed("background-color")?{}:{background:null}});default:return s()}}normalizeChildren(e){let t=[];return e.forEach(r=>t.push(...this.normalize(r))),N.from(t)}normalizeDoc(e){let t=this.normalizeChildren(e.content),r=e.type.schema;return e.type.createAndFill(e.attrs,t.size?t:r.nodes.paragraph.create())}};function kd(n){let e=[],t=[],r=()=>{t.length&&e.push(t[0].type.schema.nodes.paragraph.create(null,t)),t=[]};return n.forEach(o=>{o.isInline?t.push(o):(r(),e.push(o))}),r(),e}function B0(n){let e=[];return n.forEach(t=>{t.type===t.type.schema.nodes.list_item?t.content.forEach(r=>e.push(r)):e.push(...kd(N.from(t)))}),e}function F0(n){let e=[];return n.forEach(t=>t.forEach(r=>r.forEach(o=>e.push(o)))),e}var z0=new Z("nova-content-rules");function mg(n){return new z({key:z0,appendTransaction(e,t,r){if(!e.some(c=>c.docChanged))return null;let o=t.doc.content.findDiffStart(r.doc.content);if(o===null)return null;let i=t.doc.content.findDiffEnd(r.doc.content)?.b??r.doc.content.size,s=r.doc,l=[];if(s.forEach((c,d)=>{let u=d,p=d+c.nodeSize;if(p<o||u>Math.max(o,i))return;let f=n.normalize(c);f.length===1&&f[0].eq(c)||l.push({from:u,to:p,nodes:f})}),!l.length)return null;let a=r.tr;for(let{from:c,to:d,nodes:u}of l.reverse())u.length?a.replaceWith(c,d,u):a.doc.childCount>1?a.delete(c,d):a.replaceWith(c,d,r.schema.nodes.paragraph.create());return a.setMeta("addToHistory",e.every(c=>c.getMeta("addToHistory")!==!1))}})}var ns="data-nova-own-style",vd=null;function xd(n){vd=n}var gg=!1;function yg(n){return!!n.extendedValidElements||!!n.customElements||/\[/.test(n.validElements??"")?vd?vd.create(n):(gg||(gg=!0,console.warn("[nova] attribute lists, extendedValidElements and customElements need: import { htmlRules } from '@novaprose/core/html-rules'; registerHtmlRules(htmlRules);")),null):null}var fr=new Xr,$0=new Set(["ar","he","iw","fa","ur","ps","sd","ug","yi","dv","ckb"]);function rs(n){return!!n&&$0.has(n.toLowerCase().split(/[-_]/)[0])}function pr(n,e){console.error(`[nova] ${n}`,...e===void 0?[]:[e])}function is(n,e,t,r){let o=new Set([...no(Object.values(n.formats??{}).flat()),...no(n.styleFormats??[]),...Array.isArray(n.validClasses)?n.validClasses:[],...[...n.tableClassList??[],...n.tableCellClassList??[]].flatMap(u=>u.value.split(/\s+/).filter(Boolean))]),i=yg(n),l=n.validClasses===!0||n.validClasses===void 0&&!!i?.classOnBuiltIn?()=>!0:u=>o.has(u),a={},c={},d={};for(let u of e){Object.assign(d,u.nodeAttributes);let p;try{p=typeof u.nodes=="function"?u.nodes(r):u.nodes}catch(f){pr(`Plugin "${u.name}" failed to define its nodes`,f)}for(let[f,h]of Object.entries(p??{}))f in a?pr(`Node "${f}" is defined by several plugins`):a[f]=h;for(let[f,h]of Object.entries(u.marks??{}))f in c?pr(`Mark "${f}" is defined by several plugins`):c[f]=h}try{return{schema:vi({nodes:a,marks:c,attributes:d},l,i,t),allowedClasses:o}}catch(u){return pr("Failed to build the document schema from plugins",u),{schema:vi({},l,i,t),allowedClasses:o}}}function V0(n,e){let t=n?.validate;if(!t)return!0;if(typeof t=="function")try{return t(e),!0}catch{return!1}let r=e===null?"null":typeof e;return t.split("|").includes(r)}function bg(n,e){return!e||typeof e!="object"||!n?e:Object.fromEntries(Object.entries(e).filter(([t,r])=>V0(n[t],r)))}function co(n,e){let t=n.nodes[e.type],r={...e};return t&&(r.attrs=bg(t.spec.attrs,e.attrs)),Array.isArray(e.marks)&&(r.marks=e.marks.map(o=>{let i=o&&n.marks[o.type];return i?{...o,attrs:bg(i.spec.attrs,o.attrs)}:o})),Array.isArray(e.content)&&(r.content=e.content.map(o=>o&&typeof o=="object"?co(n,o):o)),r}function kg(n={}){let e=br(n.plugins??[]);e.errors.forEach(d=>pr(d));let{ordered:t,errors:r}=On(e.plugins);r.forEach(d=>pr(d));let o=n.direction??(rs(n.language)?"rtl":"ltr"),{schema:i}=is(n,t,o,{options:n}),l=n.validElements!==void 0||n.invalidElements!==void 0||n.validStyles!==void 0?new ur(n):null,a=d=>{let u=Te.fromJSON(i,co(i,d));return l?l.normalizeDoc(u):u},c=yr(t,{options:n});return{schema:i,doc:a,html:(d,{fullPage:u=!0}={})=>{let p=a(d),f=fr.serializeFragment(p.content);return c&&u?c.write(f,p.attrs):f},text:d=>{let u=a(d);return u.textBetween(0,u.content.size,`
36
+ `)||l==="markdown"||l==="plaintext"||t.isPasteAsText()||!c||!t.isAllowed("codeblock"))return r(a),!0;let u=typeof l=="string"?Object.hasOwn(wg,l)?wg[l]:vn(l):null,d=c.create({language:u},n.state.schema.text(a));return n.dispatch(n.state.tr.replaceSelection(new D(T.from(d),0,0)).setMeta("uiEvent","paste").scrollIntoView()),!0}var Eu={};q(Eu,{MAX_GRID:()=>pr,createTable:()=>Eg,createTableGridPanel:()=>Mu,getCellProps:()=>J0,getTableProps:()=>K0,hasHeaderColumn:()=>wu,hasHeaderRow:()=>xu,insertTable:()=>It,isCellSelection:()=>W0,isInTable:()=>Gt,loadTables:()=>ku,loadedTables:()=>j0,setCellBackground:()=>vu,setCellProps:()=>G0,setTableProps:()=>U0,sortTable:()=>as,tableCommands:()=>$e,tableRect:()=>Su});var xe=null,ls=null;function ku(){return ls??(ls=import(__novaChunk("tinymce-chunks/table-4d43f60d.js") ).then(n=>xe=n,n=>(console.warn("[nova] failed to load table editing",n),ls=null,null))),ls}function j0(){return xe}var nt=n=>(e,t,r)=>xe?xe.tableCommands[n](e,t,r):!1,$e={addRowBefore:nt("addRowBefore"),addRowAfter:nt("addRowAfter"),deleteRow:nt("deleteRow"),addColumnBefore:nt("addColumnBefore"),addColumnAfter:nt("addColumnAfter"),deleteColumn:nt("deleteColumn"),mergeCells:nt("mergeCells"),splitCell:nt("splitCell"),toggleHeaderRow:nt("toggleHeaderRow"),toggleHeaderColumn:nt("toggleHeaderColumn"),deleteTable:nt("deleteTable")};function vu(n){return(e,t,r)=>xe?xe.setCellBackground(n)(e,t,r):!1}function xu(n){return xe?.hasHeaderRow(n)??!1}function wu(n){return xe?.hasHeaderColumn(n)??!1}function W0(n){return xe?.isCellSelection(n)??!1}function K0(n){return xe?.getTableProps(n)??null}function U0(n){return(e,t,r)=>xe?xe.setTableProps(n)(e,t,r):!1}function J0(n){return xe?.getCellProps(n)??null}function G0(n){return(e,t,r)=>xe?xe.setCellProps(n)(e,t,r):!1}function as(n,e){return(t,r,o)=>xe?xe.sortTable(n,e)(t,r,o):!1}var pr=10;function Su(n){let{$from:e}=n.view.state.selection;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole==="table")return n.view.nodeDOM(e.before(t))?.getBoundingClientRect()??null;return null}function Eg(n,e,t=!0,r=Lt){let{table:o,table_row:i,table_cell:s,table_header:l,paragraph:a}=r.nodes,c=[];for(let u=0;u<n;u++){let d=t&&u===0?l:s,p=[];for(let f=0;f<e;f++)p.push(d.create(null,a.create()));c.push(i.create(null,p))}return o.create(null,c)}function It(n,e,t=!0){return(r,o)=>{if(n<1||e<1||n>100||e>50||Gt(r))return!1;if(o){let i=Eg(n,e,t,r.schema),s=qi(r.tr,i),l=-1;s.doc.descendants((a,c)=>(a===i&&(l=c),l<0)),l>=0&&s.setSelection(F.near(s.doc.resolve(l+3))),o(s.scrollIntoView())}return!0}}function Mu(n,e,t){let r=1,o=1,i=[],s=w("div",{className:"nova-grid-caption","aria-live":"polite"}),l=w("div",{className:"nova-grid",role:"grid","aria-label":t}),a=()=>{for(let c of i){let u=Number(c.dataset.row),d=Number(c.dataset.col);c.classList.toggle("is-on",u<=r&&d<=o),c.tabIndex=u===r&&d===o?0:-1}s.textContent=e(r,o)};for(let c=1;c<=pr;c++)for(let u=1;u<=pr;u++){let d=w("button",{type:"button",className:"nova-grid-cell",role:"gridcell","aria-label":e(c,u),"data-row":String(c),"data-col":String(u)});d.addEventListener("mouseenter",()=>{r=c,o=u,a()}),d.addEventListener("click",()=>n(c,u)),i.push(d),l.append(d)}return l.addEventListener("keydown",c=>{let d={ArrowRight:[0,1],ArrowLeft:[0,-1],ArrowDown:[1,0],ArrowUp:[-1,0]}[c.key];d&&(c.preventDefault(),r=Math.min(pr,Math.max(1,r+d[0])),o=Math.min(pr,Math.max(1,o+d[1])),a(),i[(r-1)*pr+(o-1)].focus())}),a(),w("div",{className:"nova-grid-panel"},l,s)}var Ou={};q(Ou,{createRenderer:()=>Lg,htmlSerializer:()=>mr,isRtlLanguage:()=>us,renderHTML:()=>ow,sanitizeJSON:()=>po,schemaFromOptions:()=>ds});var Cg={b:"strong",i:"em",strike:"s",del:"s",tbody:"table",thead:"table",tfoot:"table",caption:"table",colgroup:"table",col:"table",figcaption:"figure"},Y0=["p","h1","h2","h3","h4","h5","h6","blockquote","pre","hr","ul","ol","li","img","figure","br","table","tr","td","th","strong","em","u","s","code","a","sub","sup","span"];var X0={bold:["strong"],italic:["em"],underline:["u"],strikethrough:["s"],strike:["s"],inlinecode:["code"],code:["code"],subscript:["sub"],superscript:["sup"],language:["span"],link:["a"],unlink:["a"],quicklink:["a"],image:["img"],quickimage:["img"],table:["table"],quicktable:["table"],inserttable:["table"],tableinsertrowbefore:["table"],tableinsertrowafter:["table"],tabledeleterow:["table"],tableinsertcolbefore:["table"],tableinsertcolafter:["table"],tabledeletecol:["table"],tablemergecells:["table"],tablesplitcells:["table"],tabledelete:["table"],tablerowheader:["th"],tablecolheader:["th"],tablecellbackground:["style:background-color"],bullist:["ul"],checklist:["ul"],accordion:["details"],bulletlist:["ul"],numlist:["ol"],orderedlist:["ol"],blockquote:["blockquote"],codeblock:["pre"],hr:["hr"],horizontalrule:["hr"],h1:["h1"],h2:["h2"],h3:["h3"],h4:["h4"],h5:["h5"],h6:["h6"],forecolor:["span","style:color"],backcolor:["span","style:background-color"],fontfamily:["span","style:font-family"],fontsize:["span","style:font-size"],lineheight:["style:line-height"],align:["style:text-align"],alignleft:["style:text-align"],aligncenter:["style:text-align"],alignright:["style:text-align"],alignjustify:["style:text-align"],imagealignleft:["style:float"],imagealigncenter:["style:float"],imagealignright:["style:float"]};function Cu(n){if(n===void 0)return null;let e=new Set;for(let t of n.split(",")){let r=t.trim().replace(/^[-#+!]+/,"").replace(/\[.*$/,"").toLowerCase();for(let o of r.split("/")){let i=o.trim();i&&e.add(Cg[i]??i)}}return e}function Z0(n){if(n===void 0)return null;let e=typeof n=="string"?n:Object.values(n).join(",");return new Set(e.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean))}var fr=class{constructor(e){S(this,"tags");S(this,"styles");let t=Cu(e.validElements),r=Cu(e.invalidElements)??new Set,o=new Set(t??Y0);if(t)for(let i of Cu(e.extendedValidElements)??[])o.add(i);(o.has("ul")||o.has("ol"))&&o.add("li"),o.has("table")&&(o.add("tr"),o.add("td"));for(let i of r)o.delete(i);o.add("p"),this.tags=o,this.styles=Z0(e.validStyles)}isTagAllowed(e){let t=e.toLowerCase();return this.tags.has(Cg[t]??t)}isStyleAllowed(e){return!this.styles||this.styles.has(e.toLowerCase())}isAllowed(e){let t=X0[e.toLowerCase()];return t?t.every(r=>r.startsWith("style:")?this.isStyleAllowed(r.slice(6)):this.isTagAllowed(r)):!0}markAllowed(e){switch(e.type.name){case"bold":return this.isTagAllowed("strong");case"italic":return this.isTagAllowed("em");case"underline":return this.isTagAllowed("u");case"strike":return this.isTagAllowed("s");case"code":return this.isTagAllowed("code");case"link":return this.isTagAllowed("a");case"subscript":return this.isTagAllowed("sub");case"superscript":return this.isTagAllowed("sup");case"color":return this.isTagAllowed("span")&&this.isStyleAllowed("color");case"background":return this.isTagAllowed("span")&&this.isStyleAllowed("background-color");case"font_family":return this.isTagAllowed("span")&&this.isStyleAllowed("font-family");case"font_size":return this.isTagAllowed("span")&&this.isStyleAllowed("font-size");case"language":return this.isTagAllowed("span");default:return!0}}blockAttrs(e){return{...e,...this.isStyleAllowed("text-align")?{}:{align:null},...this.isStyleAllowed("line-height")?{}:{lineHeight:null},...this.isStyleAllowed("margin-left")?{}:{indent:0}}}normalize(e){let t=e.type.schema,{nodes:r}=t;if(e.isText){let l=e.marks.filter(a=>this.markAllowed(a));return[l.length===e.marks.length?e:e.mark(l)]}let o=e.marks.filter(l=>this.markAllowed(l));switch(e.type){case r.image:return this.isTagAllowed("img")?[r.image.create({...e.attrs,...this.isStyleAllowed("float")?{}:{align:null}},null,o)]:[];case r.figure:{let l=e.childCount>1?e.child(1).content:null,a=l?.size?[r.paragraph.create(null,this.normalizeChildren(l))]:[],c=e.firstChild;if(!this.isTagAllowed("img")||!c)return a;let u=this.isStyleAllowed("float")?e.attrs.align:null;if(!this.isTagAllowed("figure")){let d=r.image.create({...c.attrs,align:u});return[r.paragraph.create(null,d),...a]}return[r.figure.create({...e.attrs,align:u},e.content)]}case r.hard_break:return this.isTagAllowed("br")?[e.mark(o)]:[t.text(" ",o)];case r.horizontal_rule:return this.isTagAllowed("hr")?[e]:[]}let i=this.normalizeChildren(e.content),s=(l=e.type,a=e.attrs)=>{try{return[l.createChecked(a,i,e.marks)]}catch{let c=l.createAndFill(a,i,e.marks);return c?[c]:i.content.length?Au(i):[]}};if(e.type.name==="details"&&!this.isTagAllowed("details")){let l=[];return i.forEach(a=>{a.type.name!=="details_summary"?l.push(a):a.content.size&&l.push(r.paragraph.create(null,a.content))}),l}switch(e.type){case r.paragraph:return s(r.paragraph,this.blockAttrs(e.attrs));case r.heading:return this.isTagAllowed(`h${e.attrs.level}`)?s(r.heading,this.blockAttrs(e.attrs)):s(r.paragraph,this.blockAttrs({align:e.attrs.align,lineHeight:e.attrs.lineHeight}));case r.blockquote:return this.isTagAllowed("blockquote")?s():Au(i);case r.code_block:return this.isTagAllowed("pre")?s():e.textContent.split(`
37
+ `).map(l=>r.paragraph.create(null,l?t.text(l):null));case r.bullet_list:case r.ordered_list:return this.isTagAllowed(e.type===r.bullet_list?"ul":"ol")?s(e.type,{...e.attrs,...this.isStyleAllowed("list-style-type")?{}:{listStyle:null}}):Q0(i);case r.table:return this.isTagAllowed("table")?s():ew(i);case r.table_header:return this.isTagAllowed("th")?s():s(r.table_cell,e.attrs);case r.table_cell:return s(r.table_cell,{...e.attrs,...this.isStyleAllowed("background-color")?{}:{background:null}});default:return s()}}normalizeChildren(e){let t=[];return e.forEach(r=>t.push(...this.normalize(r))),T.from(t)}normalizeDoc(e){let t=this.normalizeChildren(e.content),r=e.type.schema;return e.type.createAndFill(e.attrs,t.size?t:r.nodes.paragraph.create())}};function Au(n){let e=[],t=[],r=()=>{t.length&&e.push(t[0].type.schema.nodes.paragraph.create(null,t)),t=[]};return n.forEach(o=>{o.isInline?t.push(o):(r(),e.push(o))}),r(),e}function Q0(n){let e=[];return n.forEach(t=>{t.type===t.type.schema.nodes.list_item?t.content.forEach(r=>e.push(r)):e.push(...Au(T.from(t)))}),e}function ew(n){let e=[];return n.forEach(t=>t.forEach(r=>r.forEach(o=>e.push(o)))),e}var tw=new X("nova-content-rules");function Ag(n){return new z({key:tw,appendTransaction(e,t,r){if(!e.some(c=>c.docChanged))return null;let o=t.doc.content.findDiffStart(r.doc.content);if(o===null)return null;let i=t.doc.content.findDiffEnd(r.doc.content)?.b??r.doc.content.size,s=r.doc,l=[];if(s.forEach((c,u)=>{let d=u,p=u+c.nodeSize;if(p<o||d>Math.max(o,i))return;let f=n.normalize(c);f.length===1&&f[0].eq(c)||l.push({from:d,to:p,nodes:f})}),!l.length)return null;let a=r.tr;for(let{from:c,to:u,nodes:d}of l.reverse())d.length?a.replaceWith(c,u,d):a.doc.childCount>1?a.delete(c,u):a.replaceWith(c,u,r.schema.nodes.paragraph.create());return a.setMeta("addToHistory",e.every(c=>c.getMeta("addToHistory")!==!1))}})}var cs="data-nova-own-style",Tu=null;function Nu(n){Tu=n}var Tg=!1;function Ng(n){return!!n.extendedValidElements||!!n.customElements||/\[/.test(n.validElements??"")?Tu?Tu.create(n):(Tg||(Tg=!0,console.warn("[nova] attribute lists, extendedValidElements and customElements need: import { htmlRules } from '@novaprose/core/html-rules'; registerHtmlRules(htmlRules);")),null):null}var mr=new Qr,nw=new Set(["ar","he","iw","fa","ur","ps","sd","ug","yi","dv","ckb"]);function us(n){return!!n&&nw.has(n.toLowerCase().split(/[-_]/)[0])}function hr(n,e){console.error(`[nova] ${n}`,...e===void 0?[]:[e])}function ds(n,e,t,r){let o=new Set([...oo(Object.values(n.formats??{}).flat()),...oo(n.styleFormats??[]),...Array.isArray(n.validClasses)?n.validClasses:[],...[...n.tableClassList??[],...n.tableCellClassList??[]].flatMap(d=>d.value.split(/\s+/).filter(Boolean))]),i=Ng(n),l=n.validClasses===!0||n.validClasses===void 0&&!!i?.classOnBuiltIn?()=>!0:d=>o.has(d),a={},c={},u={};for(let d of e){Object.assign(u,d.nodeAttributes);let p;try{p=typeof d.nodes=="function"?d.nodes(r):d.nodes}catch(f){hr(`Plugin "${d.name}" failed to define its nodes`,f)}for(let[f,h]of Object.entries(p??{}))f in a?hr(`Node "${f}" is defined by several plugins`):a[f]=h;for(let[f,h]of Object.entries(d.marks??{}))f in c?hr(`Mark "${f}" is defined by several plugins`):c[f]=h}try{return{schema:Ci({nodes:a,marks:c,attributes:u},l,i,t),allowedClasses:o}}catch(d){return hr("Failed to build the document schema from plugins",d),{schema:Ci({},l,i,t),allowedClasses:o}}}function rw(n,e){let t=n?.validate;if(!t)return!0;if(typeof t=="function")try{return t(e),!0}catch{return!1}let r=e===null?"null":typeof e;return t.split("|").includes(r)}function Og(n,e){return!e||typeof e!="object"||!n?e:Object.fromEntries(Object.entries(e).filter(([t,r])=>rw(n[t],r)))}function po(n,e){let t=n.nodes[e.type],r={...e};return t&&(r.attrs=Og(t.spec.attrs,e.attrs)),Array.isArray(e.marks)&&(r.marks=e.marks.map(o=>{let i=o&&n.marks[o.type];return i?{...o,attrs:Og(i.spec.attrs,o.attrs)}:o})),Array.isArray(e.content)&&(r.content=e.content.map(o=>o&&typeof o=="object"?po(n,o):o)),r}function Lg(n={}){let e=vr(n.plugins??[]);e.errors.forEach(u=>hr(u));let{ordered:t,errors:r}=Ln(e.plugins);r.forEach(u=>hr(u));let o=n.direction??(us(n.language)?"rtl":"ltr"),{schema:i}=ds(n,t,o,{options:n}),l=n.validElements!==void 0||n.invalidElements!==void 0||n.validStyles!==void 0?new fr(n):null,a=u=>{let d=Te.fromJSON(i,po(i,u));return l?l.normalizeDoc(d):d},c=kr(t,{options:n});return{schema:i,doc:a,html:(u,{fullPage:d=!0}={})=>{let p=a(u),f=mr.serializeFragment(p.content);return c&&d?c.write(f,p.attrs):f},text:u=>{let d=a(u);return d.textBetween(0,d.content.size,`
38
38
 
39
- `)}}}function q0(n,e={}){return kg(e).html(n)}var Sd=new WeakSet,Md=new WeakMap,vg=new WeakSet;function Ed(n){for(let e of n){let t=e.spec,r=t.view;!r||vg.has(e)||(vg.add(e),t.view=o=>{let i=Md.get(o);i||Md.set(o,i=new Map);let s=i.get(e);s||i.set(e,s=r(o));let l=s;return{update:(a,c)=>l.update?.(a,c),destroy:()=>{Sd.has(o)||(i.delete(e),l.destroy?.())}}})}}function Cd(n,e){Ed(e),Sd.add(n);try{n.updateState(n.state.reconfigure({plugins:e}))}finally{Sd.delete(n)}let t=Md.get(n);if(t)for(let[r,o]of t)e.includes(r)||(t.delete(r),o.destroy?.())}var Nd={};j(Nd,{CELL_BG_ATTR:()=>wg,novaParser:()=>K0,parserFor:()=>hr,preprocessDOM:()=>Sg});var wg="data-nova-cell-bg",Ad="http://www.w3.org/1999/xhtml",j0="http://www.w3.org/1998/Math/MathML";function W0(n){let e=[...n.querySelectorAll("*")].filter(t=>t.namespaceURI!==Ad&&(t.parentElement?.namespaceURI??Ad)===Ad);for(let t of e){let r=t.namespaceURI===j0?t.textContent??"":"";t.replaceWith(t.ownerDocument.createTextNode(r))}}function Sg(n){W0(n),n.querySelectorAll("td, th").forEach(e=>{if(!e.style)return;let t=e.style.backgroundColor;t&&(e.setAttribute(wg,t),e.style.removeProperty("background-color"),e.getAttribute("style")||e.removeAttribute("style"))})}var Td=class extends St{constructor(){super(...arguments);S(this,"atomSelector");S(this,"ownStyleSelector")}prepare(t){Sg(t),this.ownStyleSelector??(this.ownStyleSelector=Object.values(this.schema.nodes).flatMap(r=>r.spec.ownStyleTags??[]).join(", ")),this.ownStyleSelector&&"querySelectorAll"in t&&t.querySelectorAll(this.ownStyleSelector).forEach(r=>{let o=r.getAttribute("style");o!==null&&(r.setAttribute(ns,o),r.removeAttribute("style"))}),this.atomSelector??(this.atomSelector=Object.values(this.schema.nodes).filter(r=>r.spec.ignoreStyles).flatMap(r=>(r.spec.parseDOM??[]).map(o=>o.tag)).filter(r=>!!r).join(", ")),!(!this.atomSelector||!("querySelectorAll"in t))&&t.querySelectorAll(this.atomSelector).forEach(r=>{r.removeAttribute("style")})}parse(t,r){return this.prepare(t),super.parse(t,r)}parseSlice(t,r){return this.prepare(t),super.parseSlice(t,r)}},xg=new WeakMap;function hr(n){let e=xg.get(n);return e||(e=new Td(n,St.fromSchema(n).rules),xg.set(n,e)),e}var K0=hr(Ot);var Od={};j(Od,{createMenu:()=>uo,focusMenu:()=>po});function uo(n,e,t){let r=[],o=w("div",{className:"nova-menu",role:"menu","aria-label":t}),i=n.some(a=>(a.type===void 0||a.type==="item")&&a.active!==void 0);for(let a of n){if(a.type==="separator"){o.append(w("div",{className:"nova-menu-sep",role:"separator"}));continue}if(a.type==="heading"){o.append(w("div",{className:"nova-menu-heading",role:"presentation"},a.label));continue}let c=w("span",{className:"nova-menu-label"},a.label);a.labelStyle&&c.setAttribute("style",a.labelStyle);let d=w("button",{type:"button",className:"nova-menu-item",role:a.active===void 0?"menuitem":a.checkbox?"menuitemcheckbox":"menuitemradio",tabindex:"-1","data-id":a.id,disabled:a.disabled??!1,...a.active!==void 0?{"aria-checked":String(a.active)}:{}},i?w("span",{className:"nova-menu-check"},a.active?ee(C.check):null):null,a.icon?ee(a.icon):null,c,a.shortcut?w("kbd",{className:"nova-menu-shortcut"},Ct(a.shortcut)):null);d.addEventListener("click",()=>{e(),a.onSelect()}),r.push(d),o.append(d)}let s=()=>r.filter(a=>!a.disabled),l=a=>{let c=s();c.length&&c[(a+c.length)%c.length].focus()};return o.addEventListener("keydown",a=>{let c=s(),d=c.indexOf(te(o));switch(a.key){case"ArrowDown":a.preventDefault(),l(d+1);break;case"ArrowUp":a.preventDefault(),l(d-1);break;case"Home":a.preventDefault(),l(0);break;case"End":a.preventDefault(),l(c.length-1);break;case"Tab":a.preventDefault();break;default:if(a.key.length===1&&/\S/.test(a.key)){let u=a.key.toLowerCase(),p=d+1;[...c.slice(p),...c.slice(0,p)].find(h=>h.textContent?.trim().toLowerCase().startsWith(u))?.focus()}}}),o}function po(n){(n.querySelector('[aria-checked="true"]:not(:disabled)')??n.querySelector(".nova-menu-item:not(:disabled)"))?.focus()}var Mg={file:{title:"menu.file",items:"save cancel | fullpagehtml | importword exportword exportpdf | preview | print"},edit:{title:"menu.edit",items:"undo redo | selectall | searchreplace pastetext"},view:{title:"menu.view",items:"code preview | fullscreen | visualblocks visualchars"},insert:{title:"menu.insert",items:"image link media pageembed inserttable hr | insertdatetime template footnotes"},format:{title:"menu.format",items:"bold italic underline strikethrough superscript subscript inlinecode | paragraph h1 h2 h3 blockquote codeblock | alignleft aligncenter alignright alignjustify | lowercase uppercase titlecase | formatpainter permanentpen configurepermanentpen | removeformat"},table:{title:"menu.table",items:"inserttable | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells | advtablesort advtablerownumbering | tabledelete"},tools:{title:"menu.tools",items:"spellchecker spellcheckdialog | autocorrect capitalization typography | linkchecker a11ycheck"},help:{title:"menu.help",items:"help"}},Eg="file edit view insert format table help";function Cg(n,e,t,r){let{t:o}=n.ui;e.className="nova-menubar",e.setAttribute("role","menubar"),e.setAttribute("aria-label",o("menu.label"));let i=new AbortController,{signal:s}=i,l=f=>f.title.startsWith("menu.")?o(f.title):f.title,a=f=>{let h=[];for(let m of f.items.split(/\s+/)){if(!m)continue;if(m==="|"){h.length&&h[h.length-1].type!=="separator"&&h.push({type:"separator"});continue}if(!n.isAllowed(m))continue;let g=n.ui.registry.getMenuItem(m);g&&h.push({id:m,label:g.text,...g.icon?{icon:g.icon}:{},...g.shortcut?{shortcut:g.shortcut}:{},...g.isActive?{active:g.isActive(n),checkbox:!0}:{},disabled:!n.isEditable()||(g.isEnabled?!g.isEnabled(n):!1),onSelect:()=>g.onAction(n)})}for(;h.length&&h[h.length-1].type==="separator";)h.pop();return h},c=[],d=null,u=()=>{d?.popover.close(),d=null},p=(f,h)=>{u();let m=c[f],g=r[m.dataset.menu],y=a(g);if(!y.length)return;let x=uo(y,()=>n.ui.closePopover(),l(g));x.addEventListener("keydown",L=>{let O=Ne(L,x);if(O!=="ArrowLeft"&&O!=="ArrowRight")return;L.preventDefault();let B=(f+(O==="ArrowRight"?1:-1)+c.length)%c.length;p(B,!0)}),m.setAttribute("aria-expanded","true");let M=n.ui.openPopover({anchor:m,content:x,ignore:[e],className:"nova-popover-menu",onClose:L=>{m.setAttribute("aria-expanded","false"),d?.popover===M&&(d=null),L==="escape"&&m.focus()}});d={index:f,popover:M},h&&po(x)};for(let f of t.split(/\s+/).filter(Boolean)){let h=r[f];if(!h)continue;let m=w("button",{type:"button",className:"nova-menubar-item",role:"menuitem","aria-haspopup":"menu","aria-expanded":"false","data-menu":f,tabindex:c.length===0?"0":"-1"},l(h)),g=c.length;m.addEventListener("click",y=>{if(d?.index===g)return u();p(g,y.detail===0)}),m.addEventListener("mouseenter",()=>{d&&d.index!==g&&p(g,!1)}),c.push(m),e.append(m)}return e.addEventListener("keydown",f=>{let h=c.indexOf(te(e));if(h<0)return;let m=y=>{f.preventDefault();let x=(y+c.length)%c.length;c.forEach((M,L)=>M.tabIndex=L===x?0:-1),c[x].focus()},g=Ne(f,e);g==="ArrowRight"?m(h+1):g==="ArrowLeft"?m(h-1):f.key==="Home"?m(0):f.key==="End"?m(c.length-1):f.key==="ArrowDown"?(f.preventDefault(),p(h,!0)):f.key==="Escape"&&(f.preventDefault(),n.focus())},{signal:s}),e.addEventListener("mousedown",f=>{f.target.closest("button")&&f.preventDefault()},{signal:s}),{focus:()=>(c.find(f=>f.tabIndex===0)??c[0])?.focus(),destroy:()=>{u(),i.abort(),e.replaceChildren()}}}function U0(n){import(__novaChunk("tinymce-chunks/print-86762549.js") ).then(e=>e.print(n),e=>console.error("[nova] print: could not load the print module",e))}function J0(n){let{t:e}=n.ui,t=Fe({label:e("table.rows"),value:"3"}),r=Fe({label:e("table.cols"),value:"3"});for(let o of[t,r])o.input.type="number",o.input.min="1",o.input.max="50",o.input.inputMode="numeric";n.ui.openDialog({title:e("table.insert"),body:w("div",{className:"nova-form nova-form-row"},t.el,r.el),submitLabel:e("dialog.insert"),initialFocus:t.input,onSubmit:()=>{let o=Number(t.input.value),i=Number(r.input.value);return!Number.isInteger(o)||!Number.isInteger(i)||o<1||i<1||o>50||i>50?e("table.invalidSize"):(n.exec(_t(o,i)),!0)}})}function Ag(n){let{registry:e,t}=n.ui;e.addToggleMenuItem("paragraph",{text:t("paragraph"),icon:C.paragraph,shortcut:"Mod-Alt-0",isActive:r=>r.view.state.selection.$from.parent.type.name==="paragraph",onAction:r=>r.exec("paragraph")}),e.addMenuItem("selectall",{text:t("selectAll"),shortcut:"Mod-a",onAction:r=>{r.view.dispatch(r.view.state.tr.setSelection(new ue(r.view.state.doc))),r.focus()}}),e.addMenuItem("print",{text:t("print"),icon:C.print,shortcut:"Mod-p",onAction:r=>U0(r)}),e.addMenuItem("inserttable",{text:t("table.insert"),icon:C.table,isEnabled:r=>r.can(_t(1,1)),onAction:r=>J0(r)})}function G0(n,e){let{selection:t,doc:r,storedMarks:o}=e;return Object.create(n,{doc:{get:()=>r},selection:{get:()=>t},storedMarks:{get:()=>o},tr:{get:()=>({selection:t,doc:r,storedMarks:o}=e,e)}})}function Tg(n){console.warn(`[nova] chain: ${n}`)}function Ng(n){let e=[],t=o=>{let i=n.view();if(!i)return!1;let{state:s}=i,l=s.tr;for(let a of e){let c=!1,d=u=>{u!==l&&(c=!0)};if(!a(G0(s,l),d,i))return!1;if(c)return Tg("a command dispatched its own transaction; build it from state.tr"),!1}return o&&(i.dispatch(l),i.focus()),!0},r={exec(o){return o==="undo"||o==="redo"?(Tg(`"${o}" runs on its own \u2014 use editor.exec()`),e.push(()=>!1)):e.push(typeof o=="string"?n.resolve(o):o),r},insertContent(o){return e.push(n.insertContent(o)),r},run:()=>t(!0),can:()=>t(!1)};return r}var Rd={};j(Rd,{pages:()=>An,setSourceHTML:()=>Pd,sourceHTML:()=>Ld});var An=new WeakMap;function Ld(n){return n.getHTML({fullPage:An.get(n)?.inSource!==!1})}function Pd(n,e){n.setContent(e,{fullPage:An.get(n)?.inSource!==!1})}var Y0=200,fo=new Z("nova-bookmarks");function Og(){return new z({key:fo,state:{init:()=>new Map,apply(n,e){let t=n.getMeta(fo);if(t)return t;if(!n.docChanged||!e.size)return e;let r=new Map;for(let[o,i]of e){let s=n.mapping.mapResult(i.from,1),l=n.mapping.mapResult(i.to,-1);r.set(o,{from:s.pos,to:Math.max(s.pos,l.pos),gone:i.gone||i.from!==i.to&&s.pos>=l.pos})}return r}}})}var X0=1;function Lg(n){let e=()=>n.view,t=i=>{let s=e().state.doc.content.size,l=typeof i=="number"&&Number.isFinite(i)?Math.round(i):0;return Math.max(0,Math.min(l,s))},r=i=>i instanceof Node&&i!==e().dom&&e().dom.contains(i),o={getRange(){let{from:i,to:s}=e().state.selection;return{from:i,to:s}},setRange(i,s=i){let{state:l,dispatch:a}=e(),c=F.between(l.doc.resolve(t(i)),l.doc.resolve(t(s)));a(l.tr.setSelection(c))},isCollapsed:()=>e().state.selection.empty,collapse(i=!1){let{from:s,to:l}=e().state.selection;o.setRange(i?s:l)},selectAll(){let{state:i,dispatch:s}=e();s(i.tr.setSelection(new ue(i.doc)))},getHTML(){let{selection:i}=e().state;return i.empty?"":fr.serializeFragment(i.content().content)},getText(){let{state:i}=e();return i.doc.textBetween(i.selection.from,i.selection.to,`
40
- `)},setHTML:i=>n.insertContent(i),getNode(){let i=e(),{selection:s}=i.state;if(s instanceof R){let c=i.nodeDOM(s.from);if(c instanceof HTMLElement)return c}let l=(c,d)=>{let{node:u}=i.domAtPos(c,d);return u instanceof HTMLElement?u:u.parentElement},a=l(s.from,s.empty?0:1);if(!s.empty){let c=l(s.to,-1);for(;a&&c&&!a.contains(c);)a=a.parentElement}return a&&i.dom.contains(a)?a:null},select(i,s=!1){if(!r(i))return;let l=e(),{doc:a}=l.state,c=l.posAtDOM(i,0);for(let d of[c-1,c]){if(d<0||d>=a.content.size)continue;let u=a.nodeAt(d);if(!u||u.isText)continue;let p=l.nodeDOM(d);if(!(p!==i&&!(u.isLeaf&&p instanceof Node&&p.contains(i)))){u.isLeaf||!s&&R.isSelectable(u)?l.dispatch(l.state.tr.setSelection(R.create(a,d))):o.setRange(d+1,d+u.nodeSize-1);return}}o.setRange(c,l.posAtDOM(i,i.childNodes.length))},setCursorLocation(i,s=0){if(!r(i))return;let l=i.nodeType===3?i.length:i.childNodes.length;o.setRange(e().posAtDOM(i,Math.max(0,Math.min(s,l))))},getDOMRange(){let i=e();if(!i.dom.isConnected)return null;let{from:s,to:l}=i.state.selection;try{let a=i.domAtPos(s),c=i.domAtPos(l),d=document.createRange();return d.setStart(a.node,a.offset),d.setEnd(c.node,c.offset),d}catch{return null}},getRect(){let i=e();if(!i.dom.isConnected)return null;let{from:s,to:l,empty:a}=i.state.selection;try{if(!a){let f=o.getDOMRange()?.getBoundingClientRect?.();if(f&&(f.width||f.height))return f}let c=i.coordsAtPos(s),d=a?c:i.coordsAtPos(l),u=Math.min(c.left,d.left),p=Math.min(c.top,d.top);return new DOMRect(u,p,Math.max(c.right,d.right)-u,Math.max(c.bottom,d.bottom)-p)}catch{return null}},getBookmark(){let i=e(),s=X0++;if(i.isDestroyed)return{id:s};let l=new Map(fo.getState(i.state));for(;l.size>=Y0;)l.delete(l.keys().next().value);let{from:a,to:c}=i.state.selection;return l.set(s,{from:a,to:c,gone:!1}),i.dispatch(i.state.tr.setMeta(fo,l).setMeta("addToHistory",!1)),{id:s}},moveToBookmark(i){let s=e(),l=i?.id,a=typeof l=="number"?fo.getState(s.state)?.get(l):void 0;return!a||a.gone?!1:(o.setRange(a.from,a.to),!0)},scrollIntoView(){let{state:i,dispatch:s}=e();s(i.tr.scrollIntoView())}};return o}var Bd={};j(Bd,{MAX_MATCHES:()=>Dd,clearSearch:()=>tw,findMatches:()=>Id,findNext:()=>rw,getSearchState:()=>ss,replaceAll:()=>iw,replaceCurrent:()=>ow,searchKey:()=>Zt,searchPlugin:()=>Hd,setSearch:()=>ew});var Dd=1e4,Z0="\uFFFC",Zt=new Z("nova-search"),_d={query:"",caseSensitive:!1,wholeWord:!1,matches:[],current:-1};function Q0({query:n,caseSensitive:e,wholeWord:t}){if(!n)return null;let r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=t?`(?<![\\p{L}\\p{N}_])${r}(?![\\p{L}\\p{N}_])`:r;return new RegExp(o,e?"gu":"giu")}function Id(n,e){let t=Q0(e);if(!t)return[];let r=[];return n.descendants((o,i)=>{if(r.length>=Dd)return!1;if(!o.isTextblock)return!0;let s=o.textBetween(0,o.content.size,void 0,Z0);t.lastIndex=0;let l;for(;(l=t.exec(s))&&r.length<Dd;){if(l[0].length===0){t.lastIndex+=1;continue}r.push({from:i+1+l.index,to:i+1+l.index+l[0].length})}return!1}),r}function Pg(n,e){if(!n.length)return-1;let t=n.findIndex(r=>r.from>=e);return t<0?0:t}function Hd(){return new z({key:Zt,state:{init:()=>_d,apply(n,e,t,r){let o=n.getMeta(Zt);if(o?.type==="clear")return _d;if(o?.type==="set"){let i=Id(r.doc,o.options);return{...o.options,matches:i,current:Pg(i,r.selection.from)}}if(o?.type==="goto")return{...e,current:o.index};if(n.docChanged&&e.query){let i=Id(r.doc,e),s=e.matches[e.current]?.from,l=s===void 0?-1:Pg(i,n.mapping.map(s));return{...e,matches:i,current:l}}return e}},props:{decorations(n){let e=Zt.getState(n);return e?.matches.length?ae.create(n.doc,e.matches.map((t,r)=>ge.inline(t.from,t.to,{class:r===e.current?"nova-search-match nova-search-current":"nova-search-match"}))):null}}})}function ss(n){return Zt.getState(n)??_d}function ew(n){return(e,t)=>(t?.(e.tr.setMeta(Zt,{type:"set",options:n})),!0)}var tw=(n,e)=>(e?.(n.tr.setMeta(Zt,{type:"clear"})),!0);function nw(n,e,t){return n.setMeta(Zt,{type:"goto",index:t}).setSelection(F.create(n.doc,e.from,e.to)).scrollIntoView()}function rw(n=1){return(e,t)=>{let{matches:r,current:o}=ss(e);if(!r.length)return!1;let s=o>=0&&e.selection.from===r[o].from&&e.selection.to===r[o].to||o<0?(Math.max(o,0)+n+r.length)%r.length:o;return t&&t(nw(e.tr,r[s],s)),!0}}function ow(n){return(e,t)=>{let{matches:r,current:o}=ss(e),i=r[o];if(!i)return!1;if(t){let s=e.tr,l=e.doc.resolve(i.from).marksAcross(e.doc.resolve(i.to))??[];n?s.replaceWith(i.from,i.to,e.schema.text(n,l)):s.delete(i.from,i.to);let a=s.mapping.map(i.to);t(s.setSelection(F.create(s.doc,a)).scrollIntoView())}return!0}}function iw(n){return(e,t)=>{let{matches:r}=ss(e);if(!r.length)return!1;if(t){let o=e.tr;for(let i=r.length-1;i>=0;i--){let{from:s,to:l}=r[i],a=e.doc.resolve(s).marksAcross(e.doc.resolve(l))??[];n?o.replaceWith(s,l,e.schema.text(n,a)):o.delete(s,l)}t(o.scrollIntoView())}return!0}}var $d={};j($d,{formatHTML:()=>Rg,isFullscreen:()=>ls,openHelp:()=>ho,openPreview:()=>Fd,openSourceCode:()=>zd,toggleFullscreen:()=>mr});function ls(n){return n.root.classList.contains("nova-fullscreen")}function mr(n,e=!ls(n)){n.root.classList.toggle("nova-fullscreen",e),document.documentElement.classList.toggle("nova-fullscreen-lock",e),n.ui.closePopover(),n.updateUI(),n.focus()}function Fd(n,{doc:e=n.view.state.doc,title:t}={}){let{t:r}=n.ui,o=w("div",{className:"nova-prosemirror nova-preview"});o.append(Ve.fromSchema(n.schema).serializeFragment(e.content)),o.querySelectorAll("a[href]").forEach(i=>{i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer")}),n.ui.openDialog({title:t??r("preview"),body:o,size:"large",cancelLabel:r("dialog.close")})}function Rg(n){return n.replace(/(<\/(p|h[1-6]|ul|ol|li|blockquote|pre|table|tbody|tr)>|<hr>)/g,`$1
39
+ `)}}}function ow(n,e={}){return Lg(e).html(n)}var Lu=new WeakSet,Pu=new WeakMap,Pg=new WeakSet;function Ru(n){for(let e of n){let t=e.spec,r=t.view;!r||Pg.has(e)||(Pg.add(e),t.view=o=>{let i=Pu.get(o);i||Pu.set(o,i=new Map);let s=i.get(e);s||i.set(e,s=r(o));let l=s;return{update:(a,c)=>l.update?.(a,c),destroy:()=>{Lu.has(o)||(i.delete(e),l.destroy?.())}}})}}function Du(n,e){Ru(e),Lu.add(n);try{n.updateState(n.state.reconfigure({plugins:e}))}finally{Lu.delete(n)}let t=Pu.get(n);if(t)for(let[r,o]of t)e.includes(r)||(t.delete(r),o.destroy?.())}var Hu={};q(Hu,{CELL_BG_ATTR:()=>Dg,novaParser:()=>lw,parserFor:()=>gr,preprocessDOM:()=>_g});var Dg="data-nova-cell-bg",_u="http://www.w3.org/1999/xhtml",iw="http://www.w3.org/1998/Math/MathML";function sw(n){let e=[...n.querySelectorAll("*")].filter(t=>t.namespaceURI!==_u&&(t.parentElement?.namespaceURI??_u)===_u);for(let t of e){let r=t.namespaceURI===iw?t.textContent??"":"";t.replaceWith(t.ownerDocument.createTextNode(r))}}function _g(n){sw(n),n.querySelectorAll("td, th").forEach(e=>{if(!e.style)return;let t=e.style.backgroundColor;t&&(e.setAttribute(Dg,t),e.style.removeProperty("background-color"),e.getAttribute("style")||e.removeAttribute("style"))})}var Iu=class extends Mt{constructor(){super(...arguments);S(this,"atomSelector");S(this,"ownStyleSelector")}prepare(t){_g(t),this.ownStyleSelector??(this.ownStyleSelector=Object.values(this.schema.nodes).flatMap(r=>r.spec.ownStyleTags??[]).join(", ")),this.ownStyleSelector&&"querySelectorAll"in t&&t.querySelectorAll(this.ownStyleSelector).forEach(r=>{let o=r.getAttribute("style");o!==null&&(r.setAttribute(cs,o),r.removeAttribute("style"))}),this.atomSelector??(this.atomSelector=Object.values(this.schema.nodes).filter(r=>r.spec.ignoreStyles).flatMap(r=>(r.spec.parseDOM??[]).map(o=>o.tag)).filter(r=>!!r).join(", ")),!(!this.atomSelector||!("querySelectorAll"in t))&&t.querySelectorAll(this.atomSelector).forEach(r=>{r.removeAttribute("style")})}parse(t,r){return this.prepare(t),super.parse(t,r)}parseSlice(t,r){return this.prepare(t),super.parseSlice(t,r)}},Rg=new WeakMap;function gr(n){let e=Rg.get(n);return e||(e=new Iu(n,Mt.fromSchema(n).rules),Rg.set(n,e)),e}var lw=gr(Lt);var Bu={};q(Bu,{createMenu:()=>fo,focusMenu:()=>ho});function fo(n,e,t){let r=[],o=w("div",{className:"nova-menu",role:"menu","aria-label":t}),i=n.some(a=>(a.type===void 0||a.type==="item")&&a.active!==void 0);for(let a of n){if(a.type==="separator"){o.append(w("div",{className:"nova-menu-sep",role:"separator"}));continue}if(a.type==="heading"){o.append(w("div",{className:"nova-menu-heading",role:"presentation"},a.label));continue}let c=w("span",{className:"nova-menu-label"},a.label);a.labelStyle&&c.setAttribute("style",a.labelStyle);let u=w("button",{type:"button",className:"nova-menu-item",role:a.active===void 0?"menuitem":a.checkbox?"menuitemcheckbox":"menuitemradio",tabindex:"-1","data-id":a.id,disabled:a.disabled??!1,...a.active!==void 0?{"aria-checked":String(a.active)}:{}},i?w("span",{className:"nova-menu-check"},a.active?ee(C.check):null):null,a.icon?ee(a.icon):null,c,a.shortcut?w("kbd",{className:"nova-menu-shortcut"},At(a.shortcut)):null);u.addEventListener("click",()=>{e(),a.onSelect()}),r.push(u),o.append(u)}let s=()=>r.filter(a=>!a.disabled),l=a=>{let c=s();c.length&&c[(a+c.length)%c.length].focus()};return o.addEventListener("keydown",a=>{let c=s(),u=c.indexOf(te(o));switch(a.key){case"ArrowDown":a.preventDefault(),l(u+1);break;case"ArrowUp":a.preventDefault(),l(u-1);break;case"Home":a.preventDefault(),l(0);break;case"End":a.preventDefault(),l(c.length-1);break;case"Tab":a.preventDefault();break;default:if(a.key.length===1&&/\S/.test(a.key)){let d=a.key.toLowerCase(),p=u+1;[...c.slice(p),...c.slice(0,p)].find(h=>h.textContent?.trim().toLowerCase().startsWith(d))?.focus()}}}),o}function ho(n){(n.querySelector('[aria-checked="true"]:not(:disabled)')??n.querySelector(".nova-menu-item:not(:disabled)"))?.focus()}var Ig={file:{title:"menu.file",items:"save cancel | fullpagehtml | importword exportword exportpdf | preview | print"},edit:{title:"menu.edit",items:"undo redo | selectall | searchreplace pastetext"},view:{title:"menu.view",items:"code preview | fullscreen | visualblocks visualchars"},insert:{title:"menu.insert",items:"image link media pageembed inserttable hr | insertdatetime template footnotes"},format:{title:"menu.format",items:"bold italic underline strikethrough superscript subscript inlinecode | paragraph h1 h2 h3 blockquote codeblock | alignleft aligncenter alignright alignjustify | lowercase uppercase titlecase | formatpainter permanentpen configurepermanentpen | language | removeformat"},table:{title:"menu.table",items:"inserttable | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells | advtablesort advtablerownumbering | tabledelete"},tools:{title:"menu.tools",items:"spellchecker spellcheckdialog | autocorrect capitalization typography | linkchecker a11ycheck"},help:{title:"menu.help",items:"help"}},Hg="file edit view insert format table help";function Bg(n,e,t,r){let{t:o}=n.ui;e.className="nova-menubar",e.setAttribute("role","menubar"),e.setAttribute("aria-label",o("menu.label"));let i=new AbortController,{signal:s}=i,l=f=>f.title.startsWith("menu.")?o(f.title):f.title,a=f=>{let h=[];for(let m of f.items.split(/\s+/)){if(!m)continue;if(m==="|"){h.length&&h[h.length-1].type!=="separator"&&h.push({type:"separator"});continue}if(!n.isAllowed(m))continue;let g=n.ui.registry.getMenuItem(m);g&&h.push({id:m,label:g.text,...g.icon?{icon:g.icon}:{},...g.shortcut?{shortcut:g.shortcut}:{},...g.isActive?{active:g.isActive(n),checkbox:!0}:{},disabled:!n.isEditable()||(g.isEnabled?!g.isEnabled(n):!1),onSelect:()=>g.onAction(n)})}for(;h.length&&h[h.length-1].type==="separator";)h.pop();return h},c=[],u=null,d=()=>{u?.popover.close(),u=null},p=(f,h)=>{d();let m=c[f],g=r[m.dataset.menu],k=a(g);if(!k.length)return;let x=fo(k,()=>n.ui.closePopover(),l(g));x.addEventListener("keydown",L=>{let O=Ne(L,x);if(O!=="ArrowLeft"&&O!=="ArrowRight")return;L.preventDefault();let B=(f+(O==="ArrowRight"?1:-1)+c.length)%c.length;p(B,!0)}),m.setAttribute("aria-expanded","true");let M=n.ui.openPopover({anchor:m,content:x,ignore:[e],className:"nova-popover-menu",onClose:L=>{m.setAttribute("aria-expanded","false"),u?.popover===M&&(u=null),L==="escape"&&m.focus()}});u={index:f,popover:M},h&&ho(x)};for(let f of t.split(/\s+/).filter(Boolean)){let h=r[f];if(!h)continue;let m=w("button",{type:"button",className:"nova-menubar-item",role:"menuitem","aria-haspopup":"menu","aria-expanded":"false","data-menu":f,tabindex:c.length===0?"0":"-1"},l(h)),g=c.length;m.addEventListener("click",k=>{if(u?.index===g)return d();p(g,k.detail===0)}),m.addEventListener("mouseenter",()=>{u&&u.index!==g&&p(g,!1)}),c.push(m),e.append(m)}return e.addEventListener("keydown",f=>{let h=c.indexOf(te(e));if(h<0)return;let m=k=>{f.preventDefault();let x=(k+c.length)%c.length;c.forEach((M,L)=>M.tabIndex=L===x?0:-1),c[x].focus()},g=Ne(f,e);g==="ArrowRight"?m(h+1):g==="ArrowLeft"?m(h-1):f.key==="Home"?m(0):f.key==="End"?m(c.length-1):f.key==="ArrowDown"?(f.preventDefault(),p(h,!0)):f.key==="Escape"&&(f.preventDefault(),n.focus())},{signal:s}),e.addEventListener("mousedown",f=>{f.target.closest("button")&&f.preventDefault()},{signal:s}),{focus:()=>(c.find(f=>f.tabIndex===0)??c[0])?.focus(),destroy:()=>{d(),i.abort(),e.replaceChildren()}}}function aw(n){import(__novaChunk("tinymce-chunks/print-86762549.js") ).then(e=>e.print(n),e=>console.error("[nova] print: could not load the print module",e))}function cw(n){let{t:e}=n.ui,t=ze({label:e("table.rows"),value:"3"}),r=ze({label:e("table.cols"),value:"3"});for(let o of[t,r])o.input.type="number",o.input.min="1",o.input.max="50",o.input.inputMode="numeric";n.ui.openDialog({title:e("table.insert"),body:w("div",{className:"nova-form nova-form-row"},t.el,r.el),submitLabel:e("dialog.insert"),initialFocus:t.input,onSubmit:()=>{let o=Number(t.input.value),i=Number(r.input.value);return!Number.isInteger(o)||!Number.isInteger(i)||o<1||i<1||o>50||i>50?e("table.invalidSize"):(n.exec(It(o,i)),!0)}})}function Fg(n){let{registry:e,t}=n.ui;e.addToggleMenuItem("paragraph",{text:t("paragraph"),icon:C.paragraph,shortcut:"Mod-Alt-0",isActive:r=>r.view.state.selection.$from.parent.type.name==="paragraph",onAction:r=>r.exec("paragraph")}),e.addMenuItem("selectall",{text:t("selectAll"),shortcut:"Mod-a",onAction:r=>{r.view.dispatch(r.view.state.tr.setSelection(new de(r.view.state.doc))),r.focus()}}),e.addMenuItem("print",{text:t("print"),icon:C.print,shortcut:"Mod-p",onAction:r=>aw(r)}),e.addMenuItem("inserttable",{text:t("table.insert"),icon:C.table,isEnabled:r=>r.can(It(1,1)),onAction:r=>cw(r)})}function uw(n,e){let{selection:t,doc:r,storedMarks:o}=e;return Object.create(n,{doc:{get:()=>r},selection:{get:()=>t},storedMarks:{get:()=>o},tr:{get:()=>({selection:t,doc:r,storedMarks:o}=e,e)}})}function zg(n){console.warn(`[nova] chain: ${n}`)}function $g(n){let e=[],t=o=>{let i=n.view();if(!i)return!1;let{state:s}=i,l=s.tr;for(let a of e){let c=!1,u=d=>{d!==l&&(c=!0)};if(!a(uw(s,l),u,i))return!1;if(c)return zg("a command dispatched its own transaction; build it from state.tr"),!1}return o&&(i.dispatch(l),i.focus()),!0},r={exec(o){return o==="undo"||o==="redo"?(zg(`"${o}" runs on its own \u2014 use editor.exec()`),e.push(()=>!1)):e.push(typeof o=="string"?n.resolve(o):o),r},insertContent(o){return e.push(n.insertContent(o)),r},run:()=>t(!0),can:()=>t(!1)};return r}var $u={};q($u,{pages:()=>Tn,setSourceHTML:()=>zu,sourceHTML:()=>Fu});var Tn=new WeakMap;function Fu(n){return n.getHTML({fullPage:Tn.get(n)?.inSource!==!1})}function zu(n,e){n.setContent(e,{fullPage:Tn.get(n)?.inSource!==!1})}var dw=200,mo=new X("nova-bookmarks");function Vg(){return new z({key:mo,state:{init:()=>new Map,apply(n,e){let t=n.getMeta(mo);if(t)return t;if(!n.docChanged||!e.size)return e;let r=new Map;for(let[o,i]of e){let s=n.mapping.mapResult(i.from,1),l=n.mapping.mapResult(i.to,-1);r.set(o,{from:s.pos,to:Math.max(s.pos,l.pos),gone:i.gone||i.from!==i.to&&s.pos>=l.pos})}return r}}})}var pw=1;function qg(n){let e=()=>n.view,t=i=>{let s=e().state.doc.content.size,l=typeof i=="number"&&Number.isFinite(i)?Math.round(i):0;return Math.max(0,Math.min(l,s))},r=i=>i instanceof Node&&i!==e().dom&&e().dom.contains(i),o={getRange(){let{from:i,to:s}=e().state.selection;return{from:i,to:s}},setRange(i,s=i){let{state:l,dispatch:a}=e(),c=F.between(l.doc.resolve(t(i)),l.doc.resolve(t(s)));a(l.tr.setSelection(c))},isCollapsed:()=>e().state.selection.empty,collapse(i=!1){let{from:s,to:l}=e().state.selection;o.setRange(i?s:l)},selectAll(){let{state:i,dispatch:s}=e();s(i.tr.setSelection(new de(i.doc)))},getHTML(){let{selection:i}=e().state;return i.empty?"":mr.serializeFragment(i.content().content)},getText(){let{state:i}=e();return i.doc.textBetween(i.selection.from,i.selection.to,`
40
+ `)},setHTML:i=>n.insertContent(i),getNode(){let i=e(),{selection:s}=i.state;if(s instanceof R){let c=i.nodeDOM(s.from);if(c instanceof HTMLElement)return c}let l=(c,u)=>{let{node:d}=i.domAtPos(c,u);return d instanceof HTMLElement?d:d.parentElement},a=l(s.from,s.empty?0:1);if(!s.empty){let c=l(s.to,-1);for(;a&&c&&!a.contains(c);)a=a.parentElement}return a&&i.dom.contains(a)?a:null},select(i,s=!1){if(!r(i))return;let l=e(),{doc:a}=l.state,c=l.posAtDOM(i,0);for(let u of[c-1,c]){if(u<0||u>=a.content.size)continue;let d=a.nodeAt(u);if(!d||d.isText)continue;let p=l.nodeDOM(u);if(!(p!==i&&!(d.isLeaf&&p instanceof Node&&p.contains(i)))){d.isLeaf||!s&&R.isSelectable(d)?l.dispatch(l.state.tr.setSelection(R.create(a,u))):o.setRange(u+1,u+d.nodeSize-1);return}}o.setRange(c,l.posAtDOM(i,i.childNodes.length))},setCursorLocation(i,s=0){if(!r(i))return;let l=i.nodeType===3?i.length:i.childNodes.length;o.setRange(e().posAtDOM(i,Math.max(0,Math.min(s,l))))},getDOMRange(){let i=e();if(!i.dom.isConnected)return null;let{from:s,to:l}=i.state.selection;try{let a=i.domAtPos(s),c=i.domAtPos(l),u=document.createRange();return u.setStart(a.node,a.offset),u.setEnd(c.node,c.offset),u}catch{return null}},getRect(){let i=e();if(!i.dom.isConnected)return null;let{from:s,to:l,empty:a}=i.state.selection;try{if(!a){let f=o.getDOMRange()?.getBoundingClientRect?.();if(f&&(f.width||f.height))return f}let c=i.coordsAtPos(s),u=a?c:i.coordsAtPos(l),d=Math.min(c.left,u.left),p=Math.min(c.top,u.top);return new DOMRect(d,p,Math.max(c.right,u.right)-d,Math.max(c.bottom,u.bottom)-p)}catch{return null}},getBookmark(){let i=e(),s=pw++;if(i.isDestroyed)return{id:s};let l=new Map(mo.getState(i.state));for(;l.size>=dw;)l.delete(l.keys().next().value);let{from:a,to:c}=i.state.selection;return l.set(s,{from:a,to:c,gone:!1}),i.dispatch(i.state.tr.setMeta(mo,l).setMeta("addToHistory",!1)),{id:s}},moveToBookmark(i){let s=e(),l=i?.id,a=typeof l=="number"?mo.getState(s.state)?.get(l):void 0;return!a||a.gone?!1:(o.setRange(a.from,a.to),!0)},scrollIntoView(){let{state:i,dispatch:s}=e();s(i.tr.scrollIntoView())}};return o}var Ku={};q(Ku,{MAX_MATCHES:()=>Vu,clearSearch:()=>gw,findMatches:()=>ju,findNext:()=>bw,getSearchState:()=>ps,replaceAll:()=>vw,replaceCurrent:()=>kw,searchKey:()=>Qt,searchPlugin:()=>Wu,setSearch:()=>mw});var Vu=1e4,fw="\uFFFC",Qt=new X("nova-search"),qu={query:"",caseSensitive:!1,wholeWord:!1,matches:[],current:-1};function hw({query:n,caseSensitive:e,wholeWord:t}){if(!n)return null;let r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=t?`(?<![\\p{L}\\p{N}_])${r}(?![\\p{L}\\p{N}_])`:r;return new RegExp(o,e?"gu":"giu")}function ju(n,e){let t=hw(e);if(!t)return[];let r=[];return n.descendants((o,i)=>{if(r.length>=Vu)return!1;if(!o.isTextblock)return!0;let s=o.textBetween(0,o.content.size,void 0,fw);t.lastIndex=0;let l;for(;(l=t.exec(s))&&r.length<Vu;){if(l[0].length===0){t.lastIndex+=1;continue}r.push({from:i+1+l.index,to:i+1+l.index+l[0].length})}return!1}),r}function jg(n,e){if(!n.length)return-1;let t=n.findIndex(r=>r.from>=e);return t<0?0:t}function Wu(){return new z({key:Qt,state:{init:()=>qu,apply(n,e,t,r){let o=n.getMeta(Qt);if(o?.type==="clear")return qu;if(o?.type==="set"){let i=ju(r.doc,o.options);return{...o.options,matches:i,current:jg(i,r.selection.from)}}if(o?.type==="goto")return{...e,current:o.index};if(n.docChanged&&e.query){let i=ju(r.doc,e),s=e.matches[e.current]?.from,l=s===void 0?-1:jg(i,n.mapping.map(s));return{...e,matches:i,current:l}}return e}},props:{decorations(n){let e=Qt.getState(n);return e?.matches.length?ae.create(n.doc,e.matches.map((t,r)=>ge.inline(t.from,t.to,{class:r===e.current?"nova-search-match nova-search-current":"nova-search-match"}))):null}}})}function ps(n){return Qt.getState(n)??qu}function mw(n){return(e,t)=>(t?.(e.tr.setMeta(Qt,{type:"set",options:n})),!0)}var gw=(n,e)=>(e?.(n.tr.setMeta(Qt,{type:"clear"})),!0);function yw(n,e,t){return n.setMeta(Qt,{type:"goto",index:t}).setSelection(F.create(n.doc,e.from,e.to)).scrollIntoView()}function bw(n=1){return(e,t)=>{let{matches:r,current:o}=ps(e);if(!r.length)return!1;let s=o>=0&&e.selection.from===r[o].from&&e.selection.to===r[o].to||o<0?(Math.max(o,0)+n+r.length)%r.length:o;return t&&t(yw(e.tr,r[s],s)),!0}}function kw(n){return(e,t)=>{let{matches:r,current:o}=ps(e),i=r[o];if(!i)return!1;if(t){let s=e.tr,l=e.doc.resolve(i.from).marksAcross(e.doc.resolve(i.to))??[];n?s.replaceWith(i.from,i.to,e.schema.text(n,l)):s.delete(i.from,i.to);let a=s.mapping.map(i.to);t(s.setSelection(F.create(s.doc,a)).scrollIntoView())}return!0}}function vw(n){return(e,t)=>{let{matches:r}=ps(e);if(!r.length)return!1;if(t){let o=e.tr;for(let i=r.length-1;i>=0;i--){let{from:s,to:l}=r[i],a=e.doc.resolve(s).marksAcross(e.doc.resolve(l))??[];n?o.replaceWith(s,l,e.schema.text(n,a)):o.delete(s,l)}t(o.scrollIntoView())}return!0}}var Gu={};q(Gu,{formatHTML:()=>Wg,isFullscreen:()=>fs,openHelp:()=>go,openPreview:()=>Uu,openSourceCode:()=>Ju,toggleFullscreen:()=>yr});function fs(n){return n.root.classList.contains("nova-fullscreen")}function yr(n,e=!fs(n)){n.root.classList.toggle("nova-fullscreen",e),document.documentElement.classList.toggle("nova-fullscreen-lock",e),n.ui.closePopover(),n.updateUI(),n.focus()}function Uu(n,{doc:e=n.view.state.doc,title:t}={}){let{t:r}=n.ui,o=w("div",{className:"nova-prosemirror nova-preview"});o.append(qe.fromSchema(n.schema).serializeFragment(e.content)),o.querySelectorAll("a[href]").forEach(i=>{i.setAttribute("target","_blank"),i.setAttribute("rel","noopener noreferrer")}),n.ui.openDialog({title:t??r("preview"),body:o,size:"large",cancelLabel:r("dialog.close")})}function Wg(n){return n.replace(/(<\/(p|h[1-6]|ul|ol|li|blockquote|pre|table|tbody|tr)>|<hr>)/g,`$1
41
41
  `).replace(/(<(ul|ol|table|tbody|tr|blockquote)( [^>]*)?>)/g,`$1
42
42
  `).replace(/\n{2,}/g,`
43
- `).trim()}function zd(n){let{t:e}=n.ui,t=Rg(Ld(n)),r=w("textarea",{className:"nova-input nova-source",spellcheck:"false","aria-label":e("sourceCode"),autocomplete:"off",rows:"18"});r.value=t,n.ui.openDialog({title:e("sourceCode"),body:r,size:"large",submitLabel:e("dialog.save"),initialFocus:r,onSubmit:()=>(r.value!==t&&Pd(n,r.value),!0)})}var sw=[{group:"help.formatting",rows:[{label:"bold",keys:"Mod-b"},{label:"italic",keys:"Mod-i"},{label:"underline",keys:"Mod-u"},{label:"strike",keys:"Mod-Shift-x"},{label:"code",keys:"Mod-e"},{label:"superscript",keys:"Mod-."},{label:"subscript",keys:"Mod-,"},{label:"link",keys:"Mod-k"},{label:"clearFormatting",keys:"Mod-\\"}]},{group:"help.blocks",rows:[{label:"paragraph",keys:"Mod-Alt-0"},{label:"h1",keys:"Mod-Alt-1"},{label:"h2",keys:"Mod-Alt-2"},{label:"h3",keys:"Mod-Alt-3"},{label:"bulletList",keys:"Mod-Shift-8"},{label:"orderedList",keys:"Mod-Shift-7"},{label:"alignCenter",keys:"Mod-Shift-e"},{label:"indent",keys:"Mod-]"},{label:"outdent",keys:"Mod-["}]},{group:"help.editing",rows:[{label:"undo",keys:"Mod-z"},{label:"redo",keys:"Mod-Shift-z"},{label:"search.title",keys:"Mod-f"},{label:"pasteAsText",keys:"Mod-Shift-v"},{label:"fullscreen",keys:"Mod-Shift-f"},{label:"help.slash",keys:"/"},{label:"moveBlockUp",keys:"Alt-Shift-ArrowUp"},{label:"moveBlockDown",keys:"Alt-Shift-ArrowDown"}]},{group:"help.navigation",rows:[{label:"help.toMenubar",keys:"Alt-F9"},{label:"help.toToolbar",keys:"Alt-F10"},{label:"help.toContextToolbar",keys:"Ctrl-F9"},{label:"help.toEditor",keys:"Escape"},{label:"help.nextCell",keys:"Tab"},{label:"help",keys:"Alt-0"}]}];function ho(n){let{t:e}=n.ui,t=w("div",{className:"nova-help"});for(let{group:r,rows:o}of sw)t.append(w("section",{},w("h3",{},e(r)),w("ul",{className:"nova-help-list"},o.map(({label:i,keys:s})=>w("li",{},w("span",{},e(i))," ",w("kbd",{},s.length===1?s:Ct(s)))))));n.ui.openDialog({title:e("help"),body:t,size:"large",cancelLabel:e("dialog.close")})}var jd={};j(jd,{defaultFontFamilies:()=>Bg,defaultFontSizes:()=>Fg,defaultLineHeights:()=>zg,registerBuiltins:()=>qd});var lw={color:Y.color,background:Y.color,font_family:Y.fontFamily,font_size:Y.length};function It(n,e){return(t,r)=>{let o=ce(t)[n],i=e===null?null:lw[n](e);if(e!==null&&!i)return!1;let{empty:s}=t.selection;if(!r)return!0;let l=t.tr;if(s)l.removeStoredMark(o),i&&l.addStoredMark(o.create({value:i}));else for(let a of t.selection.ranges)l.removeMark(a.$from.pos,a.$to.pos,o),i&&l.addMark(a.$from.pos,a.$to.pos,o.create({value:i}));return r(l.scrollIntoView()),!0}}function bt(n,e){let t=ce(n)[e],{$from:r,empty:o}=n.selection,i=o?n.storedMarks??r.marks():r.nodeAfter?.marks??r.marks(),s=t.isInSet(i);return s?s.attrs.value:null}function mo(n){return(e,t)=>{let r=n===null?null:Y.lineHeight(n);if(n!==null&&!r)return!1;let{from:o,to:i}=e.selection,s=e.tr,l=!1;return e.doc.nodesBetween(o,i,(a,c)=>{(a.type===X(e).paragraph||a.type===X(e).heading)&&(l=!0,s.setNodeMarkup(c,void 0,{...a.attrs,lineHeight:r}))}),l?(t?.(s),!0):!1}}function Vd(n){return n.selection.$from.parent.attrs.lineHeight??null}var as=["#000000","#434343","#666666","#999999","#b7b7b7","#d9d9d9","#efefef","#ffffff","#b91c1c","#c2410c","#a16207","#15803d","#0e7490","#1d4ed8","#6d28d9","#be185d","#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#fecaca","#fed7aa","#fef08a","#bbf7d0","#a5f3fc","#bfdbfe","#ddd6fe","#fbcfe8"];function cs(n){let t=[],r=n.current?.toLowerCase()??null,o=w("div",{className:"nova-swatches",role:"grid","aria-label":n.label}),i=null;for(let a of n.colors){let c=r===a.toLowerCase(),d=w("button",{type:"button",className:"nova-swatch",role:"gridcell","aria-label":a,"aria-selected":String(c),title:a,tabindex:"-1"},c?ee(C.check):null);d.style.setProperty("--swatch",a),d.addEventListener("click",()=>n.onPick(a)),t.push(d),(!i||i.childElementCount===8)&&(i=w("div",{className:"nova-swatch-row",role:"row"}),o.append(i)),i.append(d)}(t.find(a=>a.getAttribute("aria-selected")==="true")??t[0])?.setAttribute("tabindex","0"),o.addEventListener("keydown",a=>{let c=t.indexOf(te(o));if(c<0)return;let u={ArrowRight:1,ArrowLeft:-1,ArrowDown:8,ArrowUp:-8}[Ne(a,o)];if(u===void 0)return;a.preventDefault();let p=t[Math.min(t.length-1,Math.max(0,c+u))];t[c].tabIndex=-1,p.tabIndex=0,p.focus()});let s=w("button",{type:"button",className:"nova-panel-action"},ee(C.clearFormatting),n.removeLabel);s.addEventListener("click",()=>n.onPick(null));let l=w("input",{type:"color",className:"nova-color-input","aria-label":n.customLabel,value:/^#[0-9a-f]{6}$/i.test(r??"")?r:"#000000"});return l.addEventListener("change",()=>n.onPick(l.value)),w("div",{className:"nova-color-panel"},o,w("div",{className:"nova-panel-footer"},s,w("label",{className:"nova-panel-action"},l,n.customLabel)))}function Dg(n){let{registry:e,t}=n.ui,r=(i,s)=>t("table.size",{rows:i,cols:s});e.addPanelButton("table",{icon:C.table,tooltip:t("table.insert"),isEnabled:i=>i.can(_t(1,1)),render:(i,s)=>gd((l,a)=>{s(),i.exec(_t(l,a))},r,t("table.insert"))});let o=(i,s,l,a,c)=>e.addButton(i,{icon:l,tooltip:t(s),onAction:d=>d.exec(a),isEnabled:d=>d.can(a),...c?{isActive:c}:{}});o("tableinsertrowbefore","table.rowBefore",C.rowBefore,ze.addRowBefore),o("tableinsertrowafter","table.rowAfter",C.rowAfter,ze.addRowAfter),o("tabledeleterow","table.rowDelete",C.rowDelete,ze.deleteRow),o("tableinsertcolbefore","table.colBefore",C.colBefore,ze.addColumnBefore),o("tableinsertcolafter","table.colAfter",C.colAfter,ze.addColumnAfter),o("tabledeletecol","table.colDelete",C.colDelete,ze.deleteColumn),o("tablemergecells","table.merge",C.merge,ze.mergeCells),o("tablesplitcells","table.split",C.split,ze.splitCell),o("tablerowheader","table.rowHeader",C.rowHeader,ze.toggleHeaderRow,i=>fd(i.view.state)),o("tablecolheader","table.colHeader",C.colHeader,ze.toggleHeaderColumn,i=>hd(i.view.state)),o("tabledelete","table.delete",C.tableDelete,ze.deleteTable),e.addPanelButton("tablecellbackground",{icon:C.highlight,tooltip:t("table.cellBackground"),isEnabled:i=>Jt(i.view.state),render:(i,s)=>cs({colors:i.options.colors??as,current:null,label:t("table.cellBackground"),removeLabel:t("removeColor"),customLabel:t("customColor"),onPick:l=>{s(),i.exec(pd(l))}})}),e.addMenuButton("advtablesort",{icon:C.sort,tooltip:t("table.sort"),isEnabled:i=>i.can(ts("asc")),items:i=>{let s=["asc","desc"].map(a=>({id:a,label:t(a==="asc"?"table.sortAsc":"table.sortDesc"),onSelect:()=>i.exec(ts(a,i.options.language))})),l=i.ui.registry.getMenuItem("advtablesort");return l?[...s,{id:"advanced",label:l.text,onSelect:()=>l.onAction(i)}]:s}}),e.addButton("tableprops",{icon:C.tableProps,tooltip:t("table.props"),isEnabled:i=>Jt(i.view.state),onAction:i=>{import(__novaChunk("tinymce-chunks/table-dialogs-0445847c.js") ).then(s=>s.openTableProps(i))}}),e.addButton("tablecellprops",{icon:C.cellProps,tooltip:t("table.cellProps"),isEnabled:i=>Jt(i.view.state),onAction:i=>{import(__novaChunk("tinymce-chunks/table-dialogs-0445847c.js") ).then(s=>s.openCellProps(i))}}),e.addContextToolbar("table",{label:t("table.toolbar"),predicate:i=>Jt(i.view.state),anchor:i=>md(i),placement:"bottom-start",items:"tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells | tablerowheader tablecolheader tablecellbackground | advtablesort advtablerownumbering tablecellprops tableprops | tabledelete"})}var Bg=[{label:"Sans Serif",value:'system-ui, -apple-system, "Segoe UI", Roboto, sans-serif'},{label:"Serif",value:'Georgia, "Times New Roman", serif'},{label:"Monospace",value:"ui-monospace, Menlo, Consolas, monospace"},{label:"Arial",value:"Arial, Helvetica, sans-serif"},{label:"Georgia",value:"Georgia, serif"},{label:"Times New Roman",value:'"Times New Roman", Times, serif'},{label:"Verdana",value:"Verdana, Geneva, sans-serif"},{label:"Courier New",value:'"Courier New", Courier, monospace'}],Fg=["8pt","10pt","12pt","14pt","16pt","18pt","24pt","36pt","48pt"],zg=["1","1.15","1.5","2","2.5","3"],nt={undo:"Mod-z",redo:"Mod-Shift-z",bold:"Mod-b",italic:"Mod-i",underline:"Mod-u",strike:"Mod-Shift-x",code:"Mod-e",subscript:"Mod-,",superscript:"Mod-.",bulletList:"Mod-Shift-8",orderedList:"Mod-Shift-7",alignLeft:"Mod-Shift-l",alignCenter:"Mod-Shift-e",alignRight:"Mod-Shift-r",alignJustify:"Mod-Shift-j",indent:"Mod-]",outdent:"Mod-[",clearFormatting:"Mod-\\",paragraph:"Mod-Alt-0",h1:"Mod-Alt-1",h2:"Mod-Alt-2",h3:"Mod-Alt-3",h4:"Mod-Alt-4",h5:"Mod-Alt-5",h6:"Mod-Alt-6"};function _g(n){try{let{node:e}=n.view.domAtPos(n.view.state.selection.from),t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;return t?getComputedStyle(t):null}catch{return null}}var aw={"system-ui":"Sans Serif","-apple-system":"Sans Serif","sans-serif":"Sans Serif",serif:"Serif",monospace:"Monospace","ui-monospace":"Monospace"};function Ig(n){let e=String(n).split(",")[0].trim().replace(/["']/g,"");return aw[e.toLowerCase()]??e}function cw(n){let e=parseFloat(n);return!Number.isFinite(e)||e<=0?null:`${Math.round(e*.75*2)/2}pt`}var Hg=(n,e)=>typeof n=="string"&&n.replace(/["'\s]/g,"").toLowerCase()===e.replace(/["'\s]/g,"").toLowerCase();function qd(n){let{registry:e,t}=n.ui,r=()=>n.view.state,o=(v,k,E,b)=>e.addButton(v,{icon:E,tooltip:t(k),...nt[k]?{shortcut:nt[k]}:{},onAction:A=>A.exec(k),isEnabled:A=>A.can(k),...b?{isActive:b}:{}}),i=(v,k,E,b)=>o(v,k,b,()=>sr(r(),n.schema.marks[E]));o("undo","undo",C.undo),o("redo","redo",C.redo),i("bold","bold","bold",C.bold),i("italic","italic","italic",C.italic),i("underline","underline","underline",C.underline),i("strikethrough","strike","strike",C.strike),i("inlinecode","code","code",C.code),i("subscript","subscript","subscript",C.subscript),i("superscript","superscript","superscript",C.superscript),o("bullist","bulletList",C.bulletList,()=>Xe(r(),n.schema.nodes.bullet_list)),o("numlist","orderedList",C.orderedList,()=>Xe(r(),n.schema.nodes.ordered_list)),o("indent","indent",C.indent),o("outdent","outdent",C.outdent),o("blockquote","blockquote",C.blockquote,()=>Xe(r(),n.schema.nodes.blockquote)),o("codeblock","codeBlock",C.codeBlock,()=>Xe(r(),n.schema.nodes.code_block)),o("hr","horizontalRule",C.horizontalRule),o("removeformat","clearFormatting",C.clearFormatting);let s=[["alignLeft","left",C.alignLeft],["alignCenter","center",C.alignCenter],["alignRight","right",C.alignRight],["alignJustify","justify",C.alignJustify]];for(let[v,k,E]of s)o(v.toLowerCase(),v,E,()=>Xt(r())===k);e.addMenuButton("align",{icon:C.alignLeft,tooltip:t("align"),isEnabled:v=>v.can("alignLeft"),items:v=>s.map(([k,E,b])=>({id:k,label:t(k),icon:b,...nt[k]?{shortcut:nt[k]}:{},active:Xt(v.view.state)===E,onSelect:()=>v.exec(k)}))});let l=[{command:"paragraph",style:""},{command:"h1",style:"font-size: 1.6em; font-weight: 700"},{command:"h2",style:"font-size: 1.35em; font-weight: 700"},{command:"h3",style:"font-size: 1.15em; font-weight: 700"},{command:"h4",style:"font-size: 1em; font-weight: 700"},{command:"h5",style:"font-size: 0.9em; font-weight: 700"},{command:"h6",style:"font-size: 0.85em; font-weight: 700"},{command:"codeBlock",style:"font-family: ui-monospace, monospace"}],a=()=>{let v=r().selection.$from.parent;return v.type===n.schema.nodes.heading?`h${v.attrs.level}`:v.type===n.schema.nodes.code_block?"codeBlock":"paragraph"};for(let v=1;v<=6;v++){let k=`h${v}`;e.addToggleButton(k,{...v<=3?{icon:C[`h${v}`]}:{text:`H${v}`},tooltip:t(k),...nt[k]?{shortcut:nt[k]}:{},isActive:()=>a()===k,isEnabled:E=>E.can(k)||a()===k,onAction:E=>E.exec(a()===k?"paragraph":k)})}let c={p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",pre:"codeBlock"},d=()=>{let v=n.options.blockFormats;return v?.length?v.flatMap(({label:k,block:E})=>{let b=c[E],A=l.find(H=>H.command===b);return A?[{...A,label:k}]:[]}):l};e.addMenuButton("blocks",{tooltip:t("blocks"),label:()=>d().find(v=>v.command===a())?.label??t(a()),minChars:11,isEnabled:v=>d().some(({command:k})=>v.can(k)),items:v=>d().filter(({command:k})=>v.isAllowed(k)).map(({command:k,style:E,label:b})=>({id:k,label:b??t(k),labelStyle:E,...nt[k]?{shortcut:nt[k]}:{},active:a()===k,onSelect:()=>v.exec(k)}))});let u="p,h1,h2,h3,h4,h5,h6",p=()=>[{title:t("styles.headings"),items:[1,2,3,4,5,6].map(v=>({title:t(`h${v}`),block:`h${v}`}))},{title:t("styles.inline"),items:[{title:t("bold"),inline:"strong"},{title:t("italic"),inline:"em"},{title:t("underline"),inline:"u"},{title:t("strike"),inline:"s"},{title:t("superscript"),inline:"sup"},{title:t("subscript"),inline:"sub"},{title:t("code"),inline:"code"}]},{title:t("styles.blocks"),items:[{title:t("paragraph"),block:"p"},{title:t("blockquote"),block:"blockquote"},{title:t("codeBlock"),block:"pre"}]},{title:t("styles.align"),items:["left","center","right","justify"].map(v=>({title:t(`align${v==="justify"?"Justify":v[0].toUpperCase()+v.slice(1)}`),selector:u,styles:{"text-align":v}}))}],f=v=>v.format??v,h=v=>{let k=v.format?n.formatter.get(v.format)?.[0]:v,E=[],b=k?.block;b&&/^h[1-6]$/.test(b)&&E.push("font-weight: 700"),(k?.inline==="strong"||k?.inline==="b")&&E.push("font-weight: 700"),(k?.inline==="em"||k?.inline==="i")&&E.push("font-style: italic"),k?.inline==="u"&&E.push("text-decoration: underline"),(k?.inline==="s"||k?.inline==="strike"||k?.inline==="del")&&E.push("text-decoration: line-through"),(k?.inline==="code"||b==="pre")&&E.push("font-family: ui-monospace, monospace");for(let A of["color","background-color","font-family"]){let H=k?.styles?.[A];H&&/^[#\w\s,'"().%-]+$/.test(H)&&E.push(`${A}: ${H}`)}return E.join("; ")},m=v=>v.flatMap(k=>k.items?m(k.items):[k]),g=()=>{let v=n.options.styleFormats,k=v?n.options.styleFormatsMerge?[...p(),...v]:v:p(),E=e.getStyleFormats();return E.items.length?E.replace?[...E.items]:[...k,...E.items]:k};e.addMenuButton("styles",{tooltip:t("styles"),minChars:10,label:v=>m(g()).find(k=>v.formatter.match(f(k)))?.title??t("styles"),items:v=>{let k=[],E=(b,A)=>{b.forEach((H,$)=>{if(H.items){k.length&&k.push({type:"separator"}),k.push({type:"heading",label:H.title}),E(H.items,`${A}${$}-`);return}k.push({id:`style-${A}${$}`,label:H.title,labelStyle:h(H),active:v.formatter.match(f(H)),disabled:!v.formatter.canApply(f(H)),onSelect:()=>v.formatter.toggle(f(H))})})};return E(g(),""),k}});let y=n.options.fontFamilies??Bg;e.addMenuButton("fontfamily",{tooltip:t("fontFamily"),minChars:9,label:v=>{let k=bt(r(),"font_family");if(k)return y.find(b=>Hg(k,b.value))?.label??Ig(k);let E=_g(v)?.fontFamily;return E?Ig(E):t("fontFamily")},items:v=>{let k=bt(v.view.state,"font_family");return[{id:"default",label:t("default"),active:k===null,onSelect:()=>v.exec(It("font_family",null))},{type:"separator"},...y.map(E=>({id:E.label,label:E.label,labelStyle:`font-family: ${E.value}`,active:Hg(k,E.value),onSelect:()=>v.exec(It("font_family",E.value))}))]}});let x=n.options.fontSizes??Fg;e.addMenuButton("fontsize",{tooltip:t("fontSize"),minChars:4,label:v=>bt(r(),"font_size")??cw(_g(v)?.fontSize??"")??"\u2014",items:v=>{let k=bt(v.view.state,"font_size");return[{id:"default",label:t("default"),active:k===null,onSelect:()=>v.exec(It("font_size",null))},{type:"separator"},...x.map(E=>({id:E,label:E,active:k===E,onSelect:()=>v.exec(It("font_size",E))}))]}});let M=n.options.lineHeights??zg;e.addMenuButton("lineheight",{icon:C.lineHeight,tooltip:t("lineHeight"),isEnabled:v=>v.can(mo(null)),items:v=>{let k=Vd(v.view.state);return[{id:"default",label:t("default"),active:k===null,onSelect:()=>v.exec(mo(null))},...M.map(E=>({id:E,label:E,active:k===E,onSelect:()=>v.exec(mo(E))}))]}});let L=(v,k,E,b)=>e.addPanelButton(v,{icon:E,tooltip:t(b),indicator:()=>bt(r(),k),render:(A,H)=>cs({colors:A.options.colors??as,current:bt(A.view.state,k),label:t(b),removeLabel:t("removeColor"),customLabel:t("customColor"),onPick:$=>{H(),A.exec(It(k,$))}})});L("forecolor","color",C.textColor,"textColor"),L("backcolor","background",C.highlight,"backgroundColor");let O=[["superscript","superscript",C.superscript],["subscript","subscript",C.subscript],["code","code",C.code]];e.addMenuButton("moreformats",{icon:C.formatMore,tooltip:t("moreFormats"),isActive:v=>O.some(([,k])=>sr(v.view.state,n.schema.marks[k])),items:v=>[...O.filter(([k])=>v.isAllowed(k)).map(([k,E,b])=>({id:k,label:t(k),icon:b,checkbox:!0,active:sr(v.view.state,n.schema.marks[E]),disabled:!v.can(k),...nt[k]?{shortcut:nt[k]}:{},onSelect:()=>v.exec(k)})),{type:"separator"},{id:"clearFormatting",label:t("clearFormatting"),icon:C.clearFormatting,disabled:!v.can("clearFormatting"),shortcut:nt.clearFormatting,onSelect:()=>v.exec("clearFormatting")},{id:"pasteAsText",label:t("pasteAsText"),icon:C.pasteText,checkbox:!0,active:v.isPasteAsText(),onSelect:()=>{v.setPasteAsText(!v.isPasteAsText()),v.focus()}}]}),e.addToggleButton("pastetext",{icon:C.pasteText,tooltip:t("pasteAsText"),isActive:v=>v.isPasteAsText(),onAction:v=>{v.setPasteAsText(!v.isPasteAsText()),v.focus()}}),e.addButton("link",{icon:C.link,tooltip:t("link"),shortcut:"Mod-k",onAction:v=>Dt(v),isActive:()=>!!En(r())}),e.addButton("unlink",{icon:C.unlink,tooltip:t("unlink"),onAction:v=>v.exec(cr()),isEnabled:v=>v.can(cr())}),e.addButton("image",{icon:C.image,tooltip:t("image"),onAction:v=>io(v)});let B=()=>Qe(r())?.attrs.align??null,J=(v,k,E,b)=>e.addToggleButton(v,{icon:E,tooltip:t(b),isActive:()=>B()===k,onAction:A=>A.exec(ar({align:B()===k?null:k}))});J("imagealignleft","left",C.imageLeft,"image.alignLeft"),J("imagealigncenter","center",C.imageCenter,"image.alignCenter"),J("imagealignright","right",C.imageRight,"image.alignRight");let P=[["image.sizeSmall",.25],["image.sizeMedium",.5],["image.sizeLarge",.75],["image.sizeFull",1],["image.sizeOriginal",null]];e.addMenuButton("imagesize",{icon:C.resize,tooltip:t("image.size"),items:v=>P.map(([k,E])=>({id:k,label:t(k),onSelect:()=>Zc(v,E)}))}),e.addButton("imagealt",{icon:C.altText,tooltip:t("image.editAlt"),onAction:v=>Qc(v)}),e.addToggleButton("imagecaption",{icon:C.imageCaption,tooltip:t("image.caption"),isActive:v=>Gc(v.view.state),onAction:v=>v.exec(Yc)}),e.addButton("imagedelete",{icon:C.trash,tooltip:t("image.delete"),onAction:v=>v.exec((k,E)=>{let b=Qe(k);return b?(E?.(k.tr.delete(b.pos,b.pos+b.node.nodeSize).scrollIntoView()),!0):!1})}),Dg(n),e.addButton("searchreplace",{icon:C.search,tooltip:t("search.title"),shortcut:"Mod-f",onAction:v=>v.openSearch()}),e.addToggleButton("fullscreen",{icon:C.fullscreen,tooltip:t("fullscreen"),shortcut:"Mod-Shift-f",isActive:v=>ls(v),onAction:v=>mr(v)}),e.addButton("preview",{icon:C.preview,tooltip:t("preview"),onAction:v=>Fd(v)}),e.addButton("code",{icon:C.sourceCode,tooltip:t("sourceCode"),onAction:v=>zd(v)}),e.addButton("help",{icon:C.help,tooltip:t("help"),shortcut:"Alt-0",onAction:v=>ho(v)}),e.addContextToolbar("image",{label:t("image.toolbar"),predicate:v=>!!Qe(v.view.state),items:"imagealignleft imagealigncenter imagealignright | imagesize imagealt imagecaption | imagedelete",anchor:v=>{let k=Qe(v.view.state);return(k?v.view.nodeDOM(k.pos):null)?.getBoundingClientRect()??null}})}var Jd={};j(Jd,{addLinkNote:()=>dw,linkBubblePlugin:()=>Ud});var Wd={};j(Wd,{Popover:()=>Tn,positionFloating:()=>kt,visibleArea:()=>ps});var ds=6,us=8;function ps(){let n=window.visualViewport;return n?{left:n.offsetLeft,top:n.offsetTop,right:n.offsetLeft+n.width,bottom:n.offsetTop+n.height}:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight}}function kt(n,e,t){let r=ps(),o=n.offsetWidth,i=n.offsetHeight,s=r.bottom-e.bottom,l=e.top-r.top,c=t==="top-start"||t==="top-end"?l>=i+ds||l>s:s<i+ds&&l>s,d=c?e.top-i-ds:e.bottom+ds,u=Bn(n),f=t==="bottom"?e.left+e.width/2-o/2:(t==="bottom-end"||t==="top-end")!==u?e.right-o:e.left;f=Math.max(r.left+us,Math.min(f,r.right-o-us)),d=Math.max(r.top+us,Math.min(d,r.bottom-i-us)),n.style.left=`${Math.round(f)}px`,n.style.top=`${Math.round(d)}px`,n.dataset.side=c?"top":"bottom"}var go=[],Tn=class{constructor(e){S(this,"el");S(this,"options");S(this,"closed",!1);S(this,"unlisten",[]);S(this,"reposition",()=>{if(this.closed)return;let{anchor:e,placement:t="bottom-start"}=this.options,r=typeof e=="function"?e():e.getBoundingClientRect();kt(this.el,r,t)});S(this,"focusWasInside",!1);S(this,"onKeyDown",(e,t)=>{e.key!=="Escape"||e.defaultPrevented||go[go.length-1]===this&&(t?.closest?.(".nova-dialog")||(e.preventDefault(),e.stopPropagation(),this.focusWasInside=this.el.contains(te(this.el)),this.close("escape")))});S(this,"onPointerDown",(e,t)=>{this.options.dismissOnOutside!==!1&&(this.el.contains(t)||this.options.ignore?.some(r=>r.contains(t))||this.close("outside"))});this.options=e,this.el=document.createElement("div"),this.el.className=`nova-popover ${e.className??""}`.trim(),this.el.append(e.content),e.host.append(this.el),this.reposition(),this.unlisten=[ct(this.el,"keydown",this.onKeyDown),ct(this.el,"pointerdown",this.onPointerDown)],go.push(this),window.addEventListener("resize",this.reposition),window.addEventListener("scroll",this.reposition,!0)}get isOpen(){return!this.closed}close(e="api"){this.closed||(this.closed=!0,go.splice(go.indexOf(this),1),this.unlisten.forEach(t=>t()),window.removeEventListener("resize",this.reposition),window.removeEventListener("scroll",this.reposition,!0),this.el.remove(),this.options.onClose?.(e))}};var Kd=new WeakMap;function dw(n,e){let t=Kd.get(n)??new Set;return Kd.set(n,t),t.add(e),()=>t.delete(e)}function Ud(n){return new z({key:new Z("nova-link-bubble"),view(e){let{t}=n.ui,r=w("a",{className:"nova-bubble-link",target:"_blank",rel:"noopener noreferrer"}),o=(h,m,g)=>{let y=w("button",{type:"button",className:"nova-btn","aria-label":m,"data-tooltip":m},ee(h));return y.addEventListener("click",g),n.ui.tooltip.attach(y),y},i=w("div",{className:"nova-bubble-row"},ee(C.externalLink),r,w("span",{className:"nova-bubble-sep"}),o(C.edit,t("link.edit"),()=>Dt(n)),o(C.copy,t("link.copy"),()=>{navigator.clipboard?.writeText(r.href).then(()=>n.ui.notify({text:t("link.copied"),type:"success",timeout:2e3}))}),o(C.unlink,t("unlink"),()=>n.exec(cr()))),s=w("span",{className:"nova-bubble-note-text"}),l=w("button",{type:"button",className:"nova-button nova-bubble-note-action"}),a=w("div",{className:"nova-bubble-note",hidden:!0},s,l),c=w("div",{className:"nova-bubble nova-link-bubble",role:"toolbar","aria-label":t("link"),hidden:!0},i,a),d=null;l.addEventListener("click",()=>d?.()),c.addEventListener("mousedown",h=>{h.target.closest("button")&&h.preventDefault()}),n.ui.overlayHost.append(c);let u=()=>{c.hidden=!0},p=()=>{let h=e.state,m=En(h),g=e.hasFocus()||c.contains(te(c));if(!m||!g||!n.isEditable()||n.ui.activeDialog||!h.selection.empty){u();return}let y=Cn(h,ce(h).link,h.selection.from);if(!y)return u();r.textContent=m.href,r.title=m.href;let x=null;for(let B of Kd.get(n)??[])if(x=B(m.href),x)break;a.hidden=!x,s.textContent=x?.text??"",l.hidden=!x?.action,l.textContent=x?.action?.label??"",d=x?.action?.run??null,Ie(m.href)?r.setAttribute("href",m.href):r.removeAttribute("href"),c.hidden=!1;let M=e.coordsAtPos(y.from),L=e.coordsAtPos(y.to),O=new DOMRect(M.left,M.top,Math.max(1,L.right-M.left),L.bottom-M.top);kt(c,O,"bottom-start")},f=h=>{c.contains(h.relatedTarget)||u()};return e.dom.addEventListener("blur",f),c.addEventListener("focusout",h=>{!c.contains(h.relatedTarget)&&!e.hasFocus()&&u()}),{update:p,destroy(){e.dom.removeEventListener("blur",f),c.remove()}}}})}var Gd="undo redo | blocks | bold italic underline strikethrough moreformats | forecolor backcolor | link image table | bullist numlist | align lineheight outdent indent | fontfamily fontsize | blockquote codeblock hr | removeformat | searchreplace preview code fullscreen help";function Yd(n){let e=Array.isArray(n)?n:n.split(/\s+/),t=[[]];for(let r of e){let o=r.trim();o&&(o==="|"?t.push([]):t[t.length-1].push(o))}return t.filter(r=>r.length>0)}function Xd(n,e,t,r,{warnUnknown:o=!0}={}){let{ui:i}=n,s=i.t,l=new AbortController,{signal:a}=l;e.className=`nova-toolbar nova-toolbar-${r}`,e.setAttribute("role","toolbar"),e.setAttribute("aria-label",s("toolbar.label"));let c=[],d=[];for(let k of Yd(t)){let E=w("div",{className:"nova-tb-group",role:"group"});for(let b of k){if(!n.isAllowed(b))continue;let A=i.registry.get(b);if(!A){o&&console.warn(`[nova] Unknown toolbar item "${b}"`);continue}let H=yo(n,b,A);c.push(H),E.append(H.el)}E.childElementCount&&(d.push(E),e.append(E))}let u=r==="floating"||r==="sliding",p=r==="sliding",f=w("div",{className:p?"nova-toolbar nova-tb-strip":"nova-toolbar nova-tb-overflow",role:"group",id:qe("nova-tb-more"),"aria-label":s("more"),hidden:p}),h=w("button",{type:"button",className:"nova-btn nova-tb-more","aria-label":s("more"),"aria-expanded":"false","data-tooltip":s("more"),hidden:!0,...p?{"aria-controls":f.id}:{"aria-haspopup":"true"}},ee(C.more));i.tooltip.attach(h);let m=null,g=()=>{m?.close(),m=null,p&&!f.hidden&&(f.hidden=!0,h.setAttribute("aria-expanded","false"))},y=i.onDialogOpen(()=>{p||g()});h.addEventListener("click",k=>{if(p){let b=f.hidden;f.hidden=!b,h.setAttribute("aria-expanded",String(b)),b&&k.detail===0&&f.querySelector("button:not(:disabled)")?.focus();return}if(m)return g();h.setAttribute("aria-expanded","true");let E=new Tn({host:i.overlayHost,anchor:h,placement:"bottom-end",content:f,className:"nova-tb-overflow-popover",ignore:[i.overlayHost,h],onClose:b=>{m=null,h.setAttribute("aria-expanded","false"),b==="escape"&&E.focusWasInside&&h.focus()}});m=E,k.detail===0&&f.querySelector("button:not(:disabled)")?.focus()}),u&&e.append(h),p&&e.after(f),r==="scrolling"&&e.addEventListener("focusin",k=>k.target.scrollIntoView?.({block:"nearest",inline:"nearest"}),{signal:a});let x=()=>{if(!u)return;for(let E of d)e.insertBefore(E,h);if(h.hidden=!0,e.scrollWidth<=e.clientWidth+1){g();return}h.hidden=!1;let k=d.length;for(;k>1&&e.scrollWidth>e.clientWidth+1;)k-=1,f.prepend(d[k]);f.childElementCount||(h.hidden=!0,g()),m?.reposition(),J()},M=-1,L=typeof ResizeObserver<"u"&&u?new ResizeObserver(()=>{e.clientWidth!==M&&(M=e.clientWidth,x())}):null;L?.observe(e);let O=()=>[...e.querySelectorAll("button")].filter(k=>!k.disabled&&!k.hidden),B=null,J=()=>{let k=O();(!B||!k.includes(B))&&(B=k[0]??null);for(let E of e.querySelectorAll("button"))E.tabIndex=E===B?0:-1};e.addEventListener("focusin",k=>{let E=k.target;E instanceof HTMLButtonElement&&e.contains(E)&&(B=E,J())},{signal:a}),e.addEventListener("keydown",k=>{let E=O(),b=E.indexOf(te(e));if(b<0)return;let A=null,H=Ne(k,e);if(H==="ArrowRight")A=b+1;else if(H==="ArrowLeft")A=b-1;else if(k.key==="Home")A=0;else if(k.key==="End")A=E.length-1;else if(k.key==="Escape"){k.preventDefault(),n.focus();return}A!==null&&(k.preventDefault(),E[(A+E.length)%E.length].focus())},{signal:a});let P=k=>{k.target.closest("button")&&k.preventDefault()};e.addEventListener("mousedown",P,{signal:a}),f.addEventListener("mousedown",P),f.addEventListener("keydown",k=>{if(k.key==="Escape"){p&&(k.preventDefault(),g(),h.focus());return}let E=[...f.querySelectorAll("button")].filter(H=>!H.disabled),b=E.indexOf(te(f));if(b<0)return;let A=Ne(k,f);A==="ArrowRight"||A==="ArrowDown"?(k.preventDefault(),E[(b+1)%E.length].focus()):(A==="ArrowLeft"||A==="ArrowUp")&&(k.preventDefault(),E[(b-1+E.length)%E.length].focus())});let v=()=>{for(let k of c)k.update();J()};return v(),x(),{update:v,focus:()=>{J(),B?.focus()},destroy:()=>{L?.disconnect(),y(),g(),l.abort(),e.replaceChildren(),p&&f.remove()}}}function yo(n,e,t){if(t.type==="split")return uw(n,e,t);let{ui:r}=n,o=w("button",{type:"button",className:`nova-btn nova-tb-${t.type}`,"aria-label":t.tooltip,"data-tooltip":t.tooltip,"data-control":e,...t.shortcut?{"data-shortcut":t.shortcut}:{}});r.tooltip.attach(o),t.icon&&o.append(ee(t.icon));let i=t.type==="menu"&&(t.label||t.text)?w("span",{className:"nova-tb-label"}):null;i?(t.type==="menu"&&t.minChars&&(i.style.minWidth=`${t.minChars}ch`),o.append(i),o.classList.add("nova-tb-has-label")):!t.icon&&t.text&&o.append(t.text);let s=null;return t.type==="panel"&&t.indicator&&(s=w("span",{className:"nova-color-bar"}),o.append(s)),t.type!=="button"&&(o.setAttribute("aria-haspopup",t.type==="menu"?"menu":"dialog"),o.setAttribute("aria-expanded","false"),o.append(ee(C.chevronDown)),o.lastElementChild?.classList.add("nova-chevron")),o.addEventListener("click",a=>{if(t.type==="button"){t.onAction(n);return}if(o.getAttribute("aria-expanded")==="true"){r.closePopover();return}let c=a.detail===0,d=()=>r.closePopover(),u=t.type==="menu"?uo(t.items(n),d,t.tooltip):t.render(n,d);o.setAttribute("aria-expanded","true");let p=r.openPopover({anchor:o,content:u,ignore:[o],className:t.type==="menu"?"nova-popover-menu":"nova-popover-panel",onClose:f=>{o.setAttribute("aria-expanded","false"),f==="escape"&&p.focusWasInside&&o.focus()}});t.type==="menu"?po(u):c&&u.querySelector("button, input")?.focus()}),t.type!=="button"&&o.addEventListener("keydown",a=>{a.key==="ArrowDown"&&o.getAttribute("aria-expanded")!=="true"&&(a.preventDefault(),o.click())}),{el:o,update:()=>{let a=n.isEditable();if(o.disabled=!a||(t.isEnabled?!t.isEnabled(n):!1),t.isActive){let c=t.isActive(n);o.classList.toggle("is-active",c),t.type==="button"&&o.setAttribute("aria-pressed",String(c))}if(i&&t.type==="menu"){let c=t.label?.(n)??t.text??"";i.textContent=c,o.setAttribute("aria-label",c&&c!==t.tooltip?`${c}, ${t.tooltip}`:t.tooltip??c)}if(s&&t.type==="panel"&&t.indicator){let c=t.indicator(n);s.style.background=c??"",s.classList.toggle("is-empty",!c)}}}}function uw(n,e,t){let r=yo(n,e,{type:"button",tooltip:t.tooltip,onAction:t.onAction,...t.icon?{icon:t.icon}:{},...t.text?{text:t.text}:{},...t.shortcut?{shortcut:t.shortcut}:{},...t.isActive?{isActive:t.isActive}:{},...t.isEnabled?{isEnabled:t.isEnabled}:{}}),o=yo(n,`${e}-options`,{type:"menu",tooltip:`${t.tooltip}: ${n.ui.t("toolbar.options")}`,items:t.items,...t.isEnabled?{isEnabled:t.isEnabled}:{}});return o.el.classList.add("nova-tb-split-more"),{el:w("span",{className:"nova-tb-split"},r.el,o.el),update:()=>{r.update(),o.update()}}}function $g(n){return new z({key:new Z("nova-context-toolbar"),view(e){let t=w("div",{className:"nova-bubble nova-context-toolbar",role:"toolbar",hidden:!0});n.ui.overlayHost.append(t);let r=new Map,o=null,i=(y,x)=>{let M=r.get(y);if(M)return M;let L=w("div",{className:"nova-context-items"}),O=[];return Yd(x.items).forEach((B,J)=>{J>0&&L.append(w("span",{className:"nova-bubble-sep",role:"separator"}));for(let P of B){if(!n.isAllowed(P))continue;let v=n.ui.registry.get(P);if(!v)continue;let k=yo(n,P,v);O.push(k),L.append(k.el)}}),M={el:L,controls:O},r.set(y,M),M},s=()=>{t.hidden=!0,o=null},l=y=>{let{selection:x}=e.state;if((y.position??"node")==="node"&&x instanceof R)return e.nodeDOM(x.from)?.getBoundingClientRect()??null;let M=e.coordsAtPos(x.from),L=e.coordsAtPos(x.to);return new DOMRect(M.left,M.top,Math.max(1,L.right-M.left),L.bottom-M.top)},a=!1,c=y=>{y.pointerType==="mouse"&&y.button===0&&(a=!0)},d=()=>{a&&(a=!1,setTimeout(()=>h(e),0))};e.dom.addEventListener("pointerdown",c);let u=ct(t,"pointerup",d),p=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,f=()=>{let y=ps();t.style.left=`${Math.round(y.left)}px`,t.style.width=`${Math.round(y.right-y.left)}px`,t.style.top=`${Math.round(y.bottom-t.offsetHeight)}px`,t.dataset.side="docked"},h=y=>{if(!(y.hasFocus()||t.contains(te(t)))||!n.isEditable()||n.ui.activeDialog||a)return s();let M=n.ui.registry.getContextToolbars().find(([,k])=>k.predicate(n));if(!M)return s();let[L,O]=M,B=i(L,O);o!==L&&(t.replaceChildren(B.el),t.setAttribute("aria-label",O.label),o=L);for(let k of B.controls)k.update();let J=O.anchor?O.anchor(n):l(O);if(!J)return s();t.hidden=!1;let P=p&&O.position==="selection";if(t.classList.toggle("nova-context-toolbar-docked",P),P)return f();t.style.width="";let v=(typeof O.placement=="function"?O.placement(n):O.placement)??(O.position==="selection"?"bottom-start":"top-start");kt(t,J,v)};t.addEventListener("mousedown",y=>{y.target.closest("button")&&y.preventDefault()}),t.addEventListener("keydown",y=>{let x=[...t.querySelectorAll("button:not(:disabled)")],M=x.indexOf(te(t));if(y.key==="Escape")y.preventDefault(),n.focus();else if(M>=0&&(y.key==="ArrowRight"||y.key==="ArrowLeft")){y.preventDefault();let L=Ne(y,t)==="ArrowRight"?1:-1;x[(M+L+x.length)%x.length].focus()}});let m=y=>{let x=y.relatedTarget;!t.contains(x)&&!n.ui.overlayHost.contains(x)&&s()};e.dom.addEventListener("blur",m),t.addEventListener("focusout",y=>{let x=y.relatedTarget;!t.contains(x)&&!e.hasFocus()&&!n.ui.overlayHost.contains(x)&&s()});let g=()=>{t.hidden||h(e)};return window.addEventListener("scroll",g,!0),window.addEventListener("resize",g),e.dom.addEventListener("load",g,!0),window.visualViewport?.addEventListener("resize",g),window.visualViewport?.addEventListener("scroll",g),{update:h,destroy(){e.dom.removeEventListener("blur",m),e.dom.removeEventListener("pointerdown",c),u(),window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g),e.dom.removeEventListener("load",g,!0),window.visualViewport?.removeEventListener("resize",g),window.visualViewport?.removeEventListener("scroll",g),t.remove()}}}})}function Vg(n){let e=n.ui.overlayHost.querySelector(".nova-context-toolbar:not([hidden]) button:not(:disabled)");return e?.focus(),!!e}var qg=24,fs=class{constructor(e,t,r,o){S(this,"view",t);S(this,"getPos",r);S(this,"editor",o);S(this,"dom");S(this,"img");S(this,"node");S(this,"resizing",!1);this.node=e,this.dom=document.createElement("span"),this.dom.className="nova-image",this.img=document.createElement("img"),this.img.draggable=!1,this.dom.append(this.img);for(let i of["nw","ne","sw","se"]){let s=document.createElement("span");s.className=`nova-image-handle nova-image-handle-${i}`,s.dataset.corner=i,s.addEventListener("pointerdown",l=>this.startResize(l,i)),this.dom.append(s)}this.render()}render(){let{src:e,alt:t,title:r,width:o,height:i,align:s}=this.node.attrs,l=fe(e)?e:"";this.img.getAttribute("src")!==l&&this.img.setAttribute("src",l),this.setAttr("alt",t),this.setAttr("title",r),this.setAttr("class",Ye(this.node.attrs.class).class??null);let a=ne(o),c=ne(i);this.img.style.width=a?`${a}px`:"",this.img.style.aspectRatio=a&&c?`${a} / ${c}`:"",this.dom.dataset.align=s??""}setAttr(e,t){t?this.img.setAttribute(e,t):this.img.removeAttribute(e)}update(e){return e.type!==this.node.type?!1:(this.node=e,this.resizing||this.render(),!0)}selectNode(){this.dom.classList.add("is-selected")}deselectNode(){this.dom.classList.remove("is-selected")}stopEvent(e){return e.target.classList?.contains("nova-image-handle")??!1}ignoreMutation(){return!0}startResize(e,t){if(!this.editor.isEditable())return;e.preventDefault(),e.stopPropagation();let r=e.currentTarget;r.setPointerCapture(e.pointerId);let o=this.img.getBoundingClientRect(),i=e.clientX,s=o.width,l=o.width>0?o.height/o.width:this.img.naturalHeight/(this.img.naturalWidth||1),a=Math.max(qg,this.view.dom.clientWidth-40),c=t==="ne"||t==="se"?1:-1,d=s;this.resizing=!0,this.dom.classList.add("is-resizing");let u=f=>{d=Math.round(Math.min(a,Math.max(qg,s+c*(f.clientX-i)))),this.img.style.width=`${d}px`,this.dom.dataset.size=`${d} \xD7 ${Math.round(d*l)}`},p=()=>{r.removeEventListener("pointermove",u),r.removeEventListener("pointerup",p),r.removeEventListener("pointercancel",p),this.resizing=!1,this.dom.classList.remove("is-resizing"),delete this.dom.dataset.size;let f=this.getPos();if(f===void 0||Math.abs(d-s)<1)return this.render();let h=this.view.state.tr.setNodeMarkup(f,void 0,{...this.node.attrs,width:d,height:Math.round(d*l)});h.setSelection(R.create(h.doc,f)),this.view.dispatch(h)};r.addEventListener("pointermove",u),r.addEventListener("pointerup",p),r.addEventListener("pointercancel",p)}};var Qd={};j(Qd,{FLAT_MARK_SELECTOR:()=>fw,flatMarkViews:()=>Zd});var pw=["bold","italic","strike","code","subscript","superscript"],fw="strong, em, s, code, sub, sup";function Zd(n){let e={};for(let t of pw){let r=n.marks[t]?.spec.toDOM;r&&(e[t]=(o,i,s)=>{let{dom:l,contentDOM:a}=Ve.renderSpec(i.dom.ownerDocument,r(o,s));return l.setAttribute("role","none"),{dom:l,contentDOM:a??void 0}})}return e}var hw=30;function mw(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function gw(n,e){let{selection:t}=n.state;if(!t.empty)return null;let r=t.$from;if(!r.parent.isTextblock||r.parent.type.spec.code)return null;let o=r.parent.textBetween(Math.max(0,r.parentOffset-hw-1),r.parentOffset,"\0","\0");for(let[i,s]of e.ui.registry.getAutocompleters()){let l=new RegExp(`(?:^|\\s)${mw(s.trigger)}([\\p{L}\\p{N}_-]*)$`,"u"),a=o.match(l);if(!a)continue;let c=a[1]??"";if(c.length<(s.minChars??0))continue;let d=r.parentOffset-c.length-s.trigger.length,u=d>0?r.parent.textBetween(d-1,d,"\0","\0"):"";if(!(u&&!/\s/.test(u)))return{name:i,spec:s,from:r.pos-c.length-s.trigger.length,to:r.pos,query:c}}return null}function jg(n){let e,t=[],r=0,o=null,i=null,s=0,l=qe("nova-ac"),a=()=>!e.hidden,c=h=>{e.hidden=!0,o=null,t=[],h.dom.removeAttribute("aria-activedescendant"),h.dom.removeAttribute("aria-controls"),h.dom.removeAttribute("aria-expanded")},d=(h,m)=>{let g=t[m];if(!g||!o)return;let{spec:y,from:x,to:M}=o;c(h),y.onSelect(g,{from:x,to:M},n)},u=h=>{if(!o)return;let{spec:m}=o;if(e.replaceChildren(),e.setAttribute("aria-label",m.label),!t.length){if(!m.emptyText)return c(h);e.append(w("div",{className:"nova-ac-empty"},m.emptyText))}t.forEach((y,x)=>{let M=w("div",{id:`${l}-${x}`,className:"nova-menu-item nova-ac-item",role:"option","aria-selected":String(x===r)},y.icon?ee(y.icon):null,w("span",{className:"nova-menu-label"},y.label),y.shortcut?w("kbd",{className:"nova-menu-shortcut"},Ct(y.shortcut)):y.detail?w("span",{className:"nova-menu-shortcut"},y.detail):null);M.addEventListener("mousedown",L=>{L.preventDefault(),d(h,x)}),M.addEventListener("mousemove",()=>{r!==x&&p(h,x)}),e.append(M)}),e.hidden=!1,h.dom.setAttribute("aria-controls",l),p(h,Math.min(r,Math.max(0,t.length-1)));let g=h.coordsAtPos(o.from);kt(e,new DOMRect(g.left,g.top,1,g.bottom-g.top),"bottom-start")},p=(h,m)=>{r=m,e.querySelectorAll('[role="option"]').forEach((y,x)=>y.setAttribute("aria-selected",String(x===m)));let g=e.querySelector(`#${l}-${m}`);g&&(h.dom.setAttribute("aria-activedescendant",g.id),g.scrollIntoView?.({block:"nearest"}))},f=h=>{let m=n.isEditable()&&h.hasFocus()?gw(h,n):null;if(!m||m.from===i){m||(i=null),(a()||o)&&c(h);return}let g=!o||o.query!==m.query||o.from!==m.from;if(o=m,!g&&a())return u(h);let y=++s;Promise.resolve(m.spec.fetch(m.query,n)).then(x=>{y!==s||!o||(t=x.slice(0,m.spec.maxResults??10),r=0,u(h))})};return new z({key:new Z("nova-autocompleter"),view(h){e=w("div",{className:"nova-popover nova-ac",id:l,role:"listbox",hidden:!0}),n.ui.overlayHost.append(e),h.dom.setAttribute("aria-autocomplete","list");let m=()=>c(h);return h.dom.addEventListener("blur",m),{update:g=>f(g),destroy(){h.dom.removeEventListener("blur",m),e.remove()}}},props:{handleKeyDown(h,m){if(!a()||!o)return!1;let g=t.length;switch(m.key){case"ArrowDown":return g&&p(h,(r+1)%g),!0;case"ArrowUp":return g&&p(h,(r-1+g)%g),!0;case"Enter":case"Tab":return g?(d(h,r),!0):!1;case"Escape":return i=o.from,c(h),!0;default:return!1}}}})}var Ht=n=>e=>e.exec(n),yw=[{name:"paragraph",label:"paragraph",icon:C.paragraph,keywords:["text","p","paragraph"],run:Ht("paragraph")},{name:"h1",label:"h1",icon:C.h1,keywords:["h1","heading","title"],shortcut:"Mod-Alt-1",run:Ht("h1")},{name:"h2",label:"h2",icon:C.h2,keywords:["h2","heading","subtitle"],shortcut:"Mod-Alt-2",run:Ht("h2")},{name:"h3",label:"h3",icon:C.h3,keywords:["h3","heading"],shortcut:"Mod-Alt-3",run:Ht("h3")},{name:"bullist",label:"bulletList",icon:C.bulletList,keywords:["ul","list","bullet"],shortcut:"Mod-Shift-8",run:Ht("bulletList")},{name:"numlist",label:"orderedList",icon:C.orderedList,keywords:["ol","list","numbered"],shortcut:"Mod-Shift-7",run:Ht("orderedList")},{name:"blockquote",label:"blockquote",icon:C.blockquote,keywords:["quote","blockquote","citation"],run:Ht("blockquote")},{name:"codeblock",label:"codeBlock",icon:C.codeBlock,keywords:["code","pre","snippet"],run:Ht("codeBlock")},{name:"hr",label:"horizontalRule",icon:C.horizontalRule,keywords:["hr","divider","line","separator"],run:Ht("horizontalRule")},{name:"table",label:"table",icon:C.table,keywords:["table","grid"],run:n=>n.exec(_t(3,3))},{name:"image",label:"image",icon:C.image,keywords:["image","picture","photo","img"],run:n=>io(n)},{name:"link",label:"link",icon:C.link,keywords:["link","url","href"],shortcut:"Mod-k",run:n=>Dt(n)}];function bw(n,e,t){let r=e.toLowerCase();if(!r)return n;let o=[];return n.forEach((i,s)=>{let l=t(i.label).toLowerCase(),a=[l,...l.split(/\s+/),...i.keywords],c=-1;l.startsWith(r)?c=3:a.some(d=>d.startsWith(r))?c=2:a.some(d=>d.includes(r))&&(c=1),c>0&&o.push([c,s,i])}),o.sort((i,s)=>s[0]-i[0]||i[1]-s[1]).map(([,,i])=>i)}function Wg(n,e=[]){let{t}=n.ui,r=[...yw,...e].filter(o=>n.isAllowed(o.name));n.ui.registry.addAutocompleter("slashcommands",{trigger:"/",label:t("slash.label"),emptyText:t("slash.empty"),fetch:o=>bw(r,o,t).map(i=>({value:i.name,label:t(i.label),icon:i.icon,...i.shortcut?{shortcut:i.shortcut}:{}})),onSelect:(o,i,s)=>{let l=r.find(a=>a.name===o.value);l&&(s.view.dispatch(s.view.state.tr.delete(i.from,i.to)),l.run(s))}})}var hs=class{constructor(e,t){S(this,"region");S(this,"closeLabel");this.closeLabel=t,this.region=w("div",{className:"nova-notifications","aria-live":"polite"}),e.append(this.region)}open(e){let t=e.type??"info",r=e.timeout??(t==="error"?0:4e3),o=w("span",{className:"nova-notification-text"},e.text),i=w("button",{type:"button",className:"nova-btn","aria-label":this.closeLabel},ee(C.close)),s=(e.actions??[]).map(p=>w("button",{type:"button",className:"nova-btn nova-notification-action"},p.label)),l=w("div",{className:`nova-notification nova-notification-${t}`,role:t==="error"?"alert":"status"},o,...s,i);this.region.append(l);let a=null,c=!1,d=()=>{c||(c=!0,a&&clearTimeout(a),l.remove())},u=()=>{c||(d(),e.onClose?.())};return s.forEach((p,f)=>p.addEventListener("click",()=>{d(),e.actions[f].onAction()})),i.addEventListener("click",u),r>0&&(a=setTimeout(u,r)),s[0]?.focus({preventScroll:!0}),{close:d,setText:p=>o.textContent=p}}destroy(){this.region.remove()}};var kw=C.sidebar,ms=class{constructor(){S(this,"controls",new Map);S(this,"menuItems",new Map);S(this,"styleFormats",{items:[],replace:!1});S(this,"contextToolbars",new Map);S(this,"autocompleters",new Map);S(this,"sidebars",new Map);S(this,"views",new Map)}addButton(e,t){this.controls.set(e.toLowerCase(),{type:"button",...t})}addToggleButton(e,t){this.addButton(e,t)}addMenuButton(e,t){this.controls.set(e.toLowerCase(),{type:"menu",...t})}addPanelButton(e,t){this.controls.set(e.toLowerCase(),{type:"panel",...t})}addSplitButton(e,t){this.controls.set(e.toLowerCase(),{type:"split",...t})}addStyleFormats(e,{replace:t=!1}={}){this.styleFormats={items:[...this.styleFormats.items,...e],replace:this.styleFormats.replace||t}}getStyleFormats(){return this.styleFormats}addMenuItem(e,t){this.menuItems.set(e.toLowerCase(),t)}addToggleMenuItem(e,t){this.addMenuItem(e,t)}getMenuItem(e){let t=this.menuItems.get(e.toLowerCase());if(t)return t;let r=this.get(e);if(!(r?.type!=="button"&&r?.type!=="split"))return{text:r.tooltip,...r.icon?{icon:r.icon}:{},...r.shortcut?{shortcut:r.shortcut}:{},onAction:r.onAction,...r.isActive?{isActive:r.isActive}:{},...r.isEnabled?{isEnabled:r.isEnabled}:{}}}addSidebar(e,t){this.sidebars.set(e,t),!(t.button===!1||this.has(e))&&this.addToggleButton(e,{tooltip:t.tooltip??t.title,icon:t.icon??kw,isActive:r=>r.ui.sidebar.isOpen(e),onAction:r=>{r.ui.sidebar.toggle(e)}})}getSidebar(e){return this.sidebars.get(e)}addView(e,t){this.views.set(e,t)}getView(e){return this.views.get(e)}addAutocompleter(e,t){this.autocompleters.set(e.toLowerCase(),t)}getAutocompleters(){return[...this.autocompleters]}addContextToolbar(e,t){this.contextToolbars.set(e.toLowerCase(),t)}getContextToolbars(){return[...this.contextToolbars].sort((e,t)=>(t[1].priority??0)-(e[1].priority??0))}get(e){return this.controls.get(e.toLowerCase())}has(e){return this.controls.has(e.toLowerCase())}names(){return[...this.controls.keys()]}};var gs=class{constructor(e){S(this,"editor",e);S(this,"current",null);S(this,"mounted",new Map);S(this,"column",null);S(this,"opening",Promise.resolve());S(this,"destroyed",!1)}get active(){return this.current}isOpen(e){return this.current===e}async show(e,t={}){let r=this.editor.ui.registry.getSidebar(e);if(!r){console.warn(`[nova] sidebar "${e}" is not registered`);return}if(this.current!==e){this.hide({restoreFocus:!1}),this.editor.ui.closeOverlays(),this.current=e;let o=this.mount(e,r);this.opening=o.ready.then(i=>{if(!i||this.current!==e||this.destroyed){this.current===e&&(this.current=null);return}o.el.hidden=!1,this.editor.root.classList.add("nova-sidebar-open"),r.onShow?.(this.editor),this.editor.updateUI()})}if(await this.opening,t.focus&&this.current===e){let o=this.mounted.get(e).el;(o.querySelector(zt)??o).focus()}}hide(e={}){let t=this.current;if(!t)return;this.current=null;let r=this.mounted.get(t);if(!r)return;let o=r.el.contains(te(r.el));r.el.hidden=!0,this.editor.root.classList.remove("nova-sidebar-open"),this.editor.ui.registry.getSidebar(t)?.onHide?.(this.editor),this.editor.updateUI(),o&&e.restoreFocus!==!1&&this.editor.focus()}toggle(e,t={}){return this.current===e?(this.hide(),Promise.resolve()):this.show(e,t)}destroy(){this.destroyed=!0,this.mounted.forEach(e=>e.cleanup?.()),this.mounted.clear()}host(){if(this.column)return this.column;let e=this.editor.view.dom.parentElement,t=w("div",{className:"nova-body"});return e.before(t),t.append(e),this.column=t,t}mount(e,t){let r=this.mounted.get(e);if(r)return r;let o=qe("nova-sidebar-title"),i=w("div",{className:"nova-sidebar-body"}),s=w("button",{type:"button",className:"nova-btn nova-sidebar-close","aria-label":this.editor.ui.t("dialog.close"),onClick:()=>this.hide()},ee(C.close)),l=t.header===!1?null:w("div",{className:"nova-sidebar-head"},w("h2",{id:o,className:"nova-sidebar-title"},t.title),s),a=w("div",{className:`nova-sidebar${l?"":" nova-sidebar-bare"}`,hidden:!0,"data-sidebar":e,...this.editor.options.language?{lang:this.editor.options.language}:{},...l?{role:"complementary","aria-labelledby":o}:{},onKeydown:(d=>{d.key!=="Escape"||d.defaultPrevented||(d.preventDefault(),this.hide())})},l,i);this.host().append(a);let c={el:a,ready:Promise.resolve(!1)};return c.ready=(async()=>{try{let d=await t.render(i,this.editor);return typeof d=="function"&&(c.cleanup=d),!0}catch(d){return console.error(`[nova] sidebar "${e}" failed to render`,d),a.remove(),this.mounted.delete(e),!1}})(),this.mounted.set(e,c),c}};var Kg=".nova-editor.nova-view-open>:not(.nova-view):not(.nova-overlays){display:none}.nova-view{display:flex;flex:1 1 auto;flex-direction:column;min-height:240px;background:var(--nova-surface);color:var(--nova-fg)}.nova-view[hidden]{display:none}.nova-view:focus{outline:none}.nova-view-head{display:flex;align-items:center;gap:8px;padding:8px 12px;border-bottom:1px solid var(--nova-border);background:var(--nova-toolbar-bg)}.nova-view-title{margin:0;font-size:15px;font-weight:600}.nova-view-buttons{display:flex;gap:8px;margin-inline-start:auto}.nova-view-body{flex:1;min-height:0;padding:12px;overflow:auto}";var ys=class{constructor(e){S(this,"editor",e);S(this,"current",null);S(this,"mounted",new Map)}get active(){return this.current}isOpen(e){return this.current===e}show(e){let t=this.editor.ui.registry.getView(e);if(!t){console.warn(`[nova] view "${e}" is not registered`);return}if(this.current===e)return;this.hide({restoreFocus:!1}),this.editor.ui.closeOverlays(),this.editor.ui.addStyles("nova-editor-views",Kg);let r=this.mount(e,t);this.current=e,r.el.hidden=!1,this.editor.root.classList.add("nova-view-open");try{t.onShow?.(r.api)}catch(o){console.error(`[nova] view "${e}" failed to show`,o)}(r.el.querySelector(zt)??r.el).focus(),this.editor.updateUI()}hide(e={}){let t=this.current;if(!t)return;this.current=null;let r=this.mounted.get(t);if(!r)return;let o=r.el.contains(te(r.el));r.el.hidden=!0,this.editor.root.classList.remove("nova-view-open");try{this.editor.ui.registry.getView(t)?.onHide?.(r.api)}catch(i){console.error(`[nova] view "${t}" failed to hide`,i)}this.editor.updateUI(),o&&e.restoreFocus!==!1&&this.editor.focus()}toggle(e){this.current===e?this.hide():this.show(e)}destroy(){this.mounted.forEach(({el:e})=>e.remove()),this.mounted.clear(),this.current=null}mount(e,t){let r=this.mounted.get(e);if(r)return r;let o=w("div",{className:"nova-view-body"}),i=(t.buttons??[]).map(a=>w("button",{type:"button",className:a.buttonType==="primary"?"nova-button nova-button-primary":"nova-button",onClick:()=>{try{a.onAction(this.editor)}catch(c){console.error(`[nova] a button of view "${e}" failed`,c)}}},a.text)),s=w("section",{className:"nova-view",hidden:!0,tabindex:"-1","data-view":e,"aria-label":t.title??e,...this.editor.options.language?{lang:this.editor.options.language}:{},onKeydown:(a=>{a.key!=="Escape"||a.defaultPrevented||(a.preventDefault(),this.hide())})},w("div",{className:"nova-view-head"},t.title?w("h2",{className:"nova-view-title"},t.title):null,w("div",{className:"nova-view-buttons"},...i)),o);this.editor.root.append(s);let l={el:s,api:{getContainer:()=>o}};return this.mounted.set(e,l),l}};var xw=450,ww=150,bs=class{constructor(e){S(this,"el");S(this,"timer",null);S(this,"target",null);S(this,"offEscape",null);this.el=w("div",{className:"nova-tooltip",role:"tooltip",hidden:!0}),this.el.addEventListener("pointerenter",()=>this.clearTimer()),this.el.addEventListener("pointerleave",()=>this.hide()),this.el.addEventListener("pointerdown",()=>this.hide()),e.append(this.el)}attach(e){e.addEventListener("pointerenter",t=>{t.pointerType==="mouse"&&this.schedule(e)}),e.addEventListener("pointerleave",()=>{this.clearTimer(),this.el.hidden||(this.timer=setTimeout(()=>this.hide(),ww))}),e.addEventListener("focus",()=>{e.matches(":focus-visible")&&this.show(e)}),e.addEventListener("blur",()=>this.hide()),e.addEventListener("pointerdown",()=>this.hide())}schedule(e){this.clearTimer(),this.timer=setTimeout(()=>this.show(e),xw)}show(e){this.clearTimer();let t=e.dataset.tooltip;if(!t||e.getAttribute("aria-expanded")==="true")return;this.target=e;let r=e.dataset.shortcut;this.el.replaceChildren(w("span",{},t)),r&&this.el.append(w("kbd",{},Ct(r))),this.el.hidden=!1,kt(this.el,e.getBoundingClientRect(),"bottom"),this.offEscape??(this.offEscape=ct(this.el,"keydown",o=>{o.key!=="Escape"||this.el.hidden||(o.preventDefault(),o.stopPropagation(),this.hide())}))}hide(){this.clearTimer(),this.el.hidden=!0,this.target=null,this.offEscape?.(),this.offEscape=null}get current(){return this.target}destroy(){this.hide(),this.el.remove()}clearTimer(){this.timer&&clearTimeout(this.timer),this.timer=null}};var Ug=new WeakMap,ks=class{constructor(e,t,r,o){S(this,"focusEditor",r);S(this,"registry",new ms);S(this,"t");S(this,"overlayHost");S(this,"tooltip");S(this,"sidebar");S(this,"view");S(this,"notifications");S(this,"popover",null);S(this,"currentDialog",null);S(this,"liveRegion");S(this,"announceTimer");S(this,"rootEl");S(this,"dialogListeners",new Set);this.t=t,this.rootEl=e,this.overlayHost=w("div",{className:"nova-overlays"}),e.append(this.overlayHost),this.tooltip=new bs(this.overlayHost),this.notifications=new hs(e,t("dialog.close")),this.sidebar=new gs(o),this.view=new ys(o),this.liveRegion=w("div",{className:"nova-visually-hidden nova-announcer",role:"status","aria-live":"polite","aria-atomic":"true"}),e.append(this.liveRegion)}announce(e){let t=this.liveRegion;t.textContent="",clearTimeout(this.announceTimer),this.announceTimer=setTimeout(()=>{t.textContent=e},50)}addStyles(e,t){let r=this.rootEl.getRootNode(),o=Ug.get(r);if(o||Ug.set(r,o=new Set),o.has(e))return;if(o.add(e),"adoptedStyleSheets"in r&&typeof CSSStyleSheet<"u")try{let s=new CSSStyleSheet;s.replaceSync(t),r.adoptedStyleSheets=[...r.adoptedStyleSheets,s];return}catch{}let i=document.createElement("style");i.dataset.novaStyles=e,i.textContent=t,(r.head??r).append(i)}async dialog(e){let{openFormDialog:t,formDialogCss:r}=await import(__novaChunk("tinymce-chunks/form-dialog-9eb62199.js") );return this.addStyles("nova-form-dialog",r),t(e,this.t,o=>this.openDialog(o))}openPopover(e){this.closePopover(),this.tooltip.hide();let t=new Tn({...e,host:this.overlayHost,onClose:r=>{this.popover===t&&(this.popover=null),e.onClose?.(r)}});return this.popover=t,t}closePopover(){this.popover?.close("api"),this.popover=null}get activePopover(){return this.popover}onDialogOpen(e){return this.dialogListeners.add(e),()=>this.dialogListeners.delete(e)}closeOverlays(){this.closePopover(),this.dialogListeners.forEach(e=>e())}openDialog(e){this.closePopover(),this.dialogListeners.forEach(r=>r()),this.currentDialog?.close();let t=$c({cancelLabel:this.t("dialog.cancel"),closeLabel:this.t("dialog.close"),...e,host:this.overlayHost,returnFocus:this.focusEditor,onClose:()=>{this.currentDialog===t&&(this.currentDialog=null),e.onClose?.()}});return this.currentDialog=t,t}get activeDialog(){return this.currentDialog}notify(e){return this.notifications.open(typeof e=="string"?{text:e}:e)}destroy(){this.sidebar.destroy(),this.view.destroy(),this.closePopover(),this.currentDialog?.close(),this.tooltip.destroy(),this.notifications.destroy(),this.overlayHost.remove(),clearTimeout(this.announceTimer),this.liveRegion.remove()}};var Sw={paragraph:()=>"p",heading:n=>`h${n.attrs.level}`,blockquote:()=>"blockquote",code_block:()=>"pre",bullet_list:()=>"ul",ordered_list:()=>"ol",list_item:()=>"li",table:()=>"table",table_row:()=>"tr",table_cell:()=>"td",table_header:()=>"th"},Mw={bold:"strong",italic:"em",underline:"u",strike:"s",code:"code",link:"a",subscript:"sub",superscript:"sup"},Gg=String.raw`\p{sc=Han}\p{sc=Hiragana}\p{sc=Katakana}`,Jg=String.raw`(?:(?![${Gg}])[\p{L}\p{N}])`,Ew=new RegExp(`[${Gg}]|${Jg}+(?:['\u2019-]${Jg}+)*`,"gu");function Cw(n){return n.match(Ew)?.length??0}function Yg(n,e){e.className="nova-statusbar";let t=w("div",{className:"nova-path","aria-hidden":"true"}),r=w("div",{className:"nova-wordcount","aria-live":"off"});e.append(t,r);let o=n.options.resize,i=o?Nw(n,e,o==="both"):null,s=null,l=()=>{let c=n.view.state.doc;r.textContent=n.ui.t("status.words",{count:Cw(c.textBetween(0,c.content.size," "," "))})},a=c=>{let{$from:d}=n.view.state.selection,u=[];for(let f=1;f<=d.depth;f++){let h=d.node(f),m=Sw[h.type.name]?.(h);m&&u.push(m)}n.view.state.selection.node?.type.name==="image"&&u.push("img");for(let f of d.marks()){let h=Mw[f.type.name];h&&u.push(h)}t.replaceChildren(...u.flatMap((f,h)=>[...h?[" \u203A "]:[],w("span",{className:"nova-path-item"},f)])),c&&(s&&clearTimeout(s),s=setTimeout(l,250))};return l(),a(!1),{update:a,destroy:()=>{s&&clearTimeout(s),i?.(),e.replaceChildren()}}}var Aw=100,Tw=200,vs=20;function Nw(n,e,t){let r=n.root,o=w("div",{className:"nova-resize-handle",role:"separator",tabIndex:0,"aria-orientation":"horizontal","aria-label":n.ui.t("status.resize")});o.append(ee(t?C.resizeHandleBoth:C.resizeHandle)),r.dataset.resize=t?"both":"vertical",e.append(o);let i=(u,p)=>{if(r.style.boxSizing="border-box",r.style.height=`${Math.max(Aw,Math.round(u))}px`,t&&p!==void 0){let f=r.parentElement?.clientWidth||1/0;r.style.width=`${Math.min(f,Math.max(Tw,Math.round(p)))}px`}o.setAttribute("aria-valuenow",String(r.offsetHeight))},s=null,l=u=>{n.isDisabled()||(u.preventDefault(),o.setPointerCapture(u.pointerId),s={x:u.clientX,y:u.clientY,height:r.offsetHeight,width:r.offsetWidth})},a=u=>{if(!s)return;let p=(u.clientX-s.x)*(Bn(r)?-1:1);i(s.height+u.clientY-s.y,s.width+p)},c=u=>{s&&(s=null,o.hasPointerCapture(u.pointerId)&&o.releasePointerCapture(u.pointerId))},d=u=>{let p=u.key==="ArrowDown"?vs:u.key==="ArrowUp"?-vs:0,f=Ne(u,r),h=t?f==="ArrowRight"?vs:f==="ArrowLeft"?-vs:0:0;!h&&!p||(u.preventDefault(),i(r.offsetHeight+p,r.offsetWidth+h))};return o.addEventListener("pointerdown",l),o.addEventListener("pointermove",a),o.addEventListener("pointerup",c),o.addEventListener("pointercancel",c),o.addEventListener("keydown",d),()=>{o.remove(),delete r.dataset.resize}}var tu="nova:remote",xs="nova:api",Ow=new Set("P H1 H2 H3 H4 H5 H6 UL OL TABLE BLOCKQUOTE PRE HR DIV FIGURE".split(" "));function Xg(n){return(e,t)=>{if(!t)return!0;let r=document.createElement("template");r.innerHTML=n;let o=document.createElement("div");o.append(r.content);let i=hr(e.schema),l=[...o.children].some(p=>Ow.has(p.tagName))?new D(i.parse(o).content,0,0):i.parseSlice(o),a=!1;l.content.descendants(p=>(p.type.spec.tableRole==="table"&&(a=!0),!a));let{$from:c}=e.selection,d=0;for(let p=1;p<=c.depth;p++)if(c.node(p).type.spec.tableRole==="table"){d=p;break}let u=a&&d?e.tr.insert(c.after(d),l.content):e.tr.replaceSelection(l);return t(u.setMeta(xs,!0).scrollIntoView()),!0}}var Lw=0,Zg=new Set,bo=class{constructor(e){S(this,"view");S(this,"root");S(this,"ui");S(this,"options");S(this,"listeners",new Map);S(this,"ready");S(this,"toolbar");S(this,"toolbarHost");S(this,"menubar");S(this,"mode");S(this,"direction");S(this,"pluginsByName",new Map);S(this,"commandOverrides",new Map);S(this,"transactionTransforms",[]);S(this,"cleanups",[]);S(this,"contentRules");S(this,"schema");S(this,"formatter");S(this,"selection");S(this,"statusbar");S(this,"searchBar",null);S(this,"searchBarLoad",null);S(this,"contentHost");S(this,"destroyed",!1);S(this,"editable");S(this,"disabled");S(this,"pasteAsText");e=Jm(e),this.options=e,this.root=document.createElement("div"),this.root.className="nova-editor";let t=e.direction??(rs(e.language)?"rtl":void 0);t&&(this.root.dir=t),this.direction=t??(e.element.closest("[dir]")?.getAttribute("dir")==="rtl"?"rtl":"ltr"),e.element.appendChild(this.root);let r=document.createElement("div"),o=document.createElement("div"),i=document.createElement("div");o.className="nova-content";let s=document.createElement("div");s.className="nova-header";let l=document.createElement("div");s.append(l,r),this.root.append(s,o,i),this.toolbarHost=r,this.mode=e.mode??"classic",this.root.classList.add(`nova-mode-${this.mode}`);let a=this.mode==="distraction-free";if(this.mode!=="classic"&&(this.root.addEventListener("focusin",()=>this.root.classList.add("is-focused")),this.root.addEventListener("focusout",()=>{setTimeout(()=>{this.root.contains(te(this.root))||this.root.classList.remove("is-focused")},0)})),this.ui=new ks(this.root,Mp(e.language,e.translations),()=>this.focus(),this),e.language)for(let b of[s,i,this.ui.overlayHost])b.lang=e.language;this.root.style.setProperty("--nova-caption-placeholder",JSON.stringify(this.ui.t("image.captionPlaceholder")));let c=We({"Mod-k":()=>(Dt(this),!0),"Alt-F9":()=>this.menubar?(this.menubar.focus(),!0):!1,"Alt-F10":()=>this.toolbar?(this.toolbar.focus(),!0):!1,"Ctrl-F9":()=>Vg(this),"Mod-f":()=>(this.openSearch(),!0),"Mod-Shift-f":()=>(mr(this),!0),"Alt-0":()=>(ho(this),!0),Escape:()=>this.searchBar?.isOpen()?(this.searchBar.close(),!0):!1}),d=[...e.plugins??[]];a&&!d.includes("quickbars")&&d.push("quickbars");let u=br(d);u.errors.forEach(b=>vt(b));let{ordered:p,errors:f}=On(u.plugins);f.forEach(b=>vt(b));for(let b of p)b.load&&u.loaders.push(b.load);let h=p.flatMap(b=>this.collectPmPlugins(b)),m=e.validElements!==void 0||e.invalidElements!==void 0||e.validStyles!==void 0;this.contentRules=m?new ur(e):null;let{schema:g,allowedClasses:y}=is(e,p,this.direction,this);this.schema=g,this.formatter=new Vi(this,y),this.selection=Lg(this);for(let[b,A]of Object.entries(e.formats??{}))this.formatter.register(b,A);p.forEach(b=>this.registerCommands(b));let x=yr(p,this);x&&An.set(this,x);let M=eu(this.schema,e.content??"",x),L=Hd(),O=[jg(this),...e.textPatterns===!1?[]:Array.isArray(e.textPatterns)||e.textPatternsLookup?[sg(this,Array.isArray(e.textPatterns)?e.textPatterns:[],e.textPatternsLookup)]:[tg(b=>this.isAllowed(b),this.schema),ng(b=>this.isAllowed(b),this.schema)],c,L,...lg(b=>this.resolveCommand(b)),qm(this.ui.t,b=>this.ui.announce(b)),...p.some(b=>b.replaceHistory)?[]:[Sc()],Rm({color:"var(--nova-accent)",width:2}),_m(),Jc(this),Uc(this),ug(this),Ud(this),$g(this),...this.contentRules?[mg(this.contentRules)]:[],$m(),Og(),...h,...e.prosemirrorPlugins??[]];Ed(O);let B=cn.create({doc:this.contentRules?this.contentRules.normalizeDoc(M):M,plugins:O});this.editable=e.editable??!0,this.disabled=e.disabled??!1,this.pasteAsText=e.pasteAsText??!1;let J=this.handleTransaction.bind(this);this.view=new Xn(o,{state:B,editable:()=>this.isEditable(),attributes:{class:"nova-prosemirror",role:"textbox","aria-multiline":"true","aria-label":this.ui.t("editor.label"),...e.placeholder?{"data-placeholder":e.placeholder,"aria-placeholder":e.placeholder}:{}},dispatchTransaction:function(b){J(b,this)},clipboardParser:hr(this.schema),nodeViews:{image:(b,A,H)=>new fs(b,A,H,this)},markViews:Zd(this.schema),handleDOMEvents:{focus:(b,A)=>(this.emit("focus",{event:A}),!1),blur:(b,A)=>(this.emit("blur",{event:A}),!1)},handleKeyDown:(b,A)=>(this.emit("keydown",{event:A}),A.defaultPrevented)}),this.root.classList.toggle("nova-readonly",!this.editable),this.applyDisabled(),qd(this),Ag(this),e.slashCommands!==!1&&Wg(this,e.slashCommands??[]),p.forEach(b=>this.setupPlugin(b)),e.setup?.(this);let P=e.menubar===!0?Eg:typeof e.menubar=="string"?e.menubar:null;this.menubar=P?Cg(this,l,P,{...Mg,...e.menu}):null,this.menubar||l.remove(),this.toolbar=e.toolbar===!1||a&&e.toolbar===void 0?null:Xd(this,r,this.toolbarConfig(),e.toolbarMode??"floating",{warnUnknown:u.loaders.length===0}),this.toolbar||r.remove(),!this.toolbar&&!this.menubar&&s.remove(),this.contentHost=o;let v=this.loadSearchBar(),k=e.statusbar??this.mode==="classic";this.statusbar=k?Yg(this,i):null,this.statusbar||i.remove(),e.onChange&&this.on("change",e.onChange),this.updatePlaceholder();let E=this.applyContentStyles();this.ready=Promise.all([u.loaders.length?this.loadLazyPlugins(u.loaders):void 0,E,dd(),this.installTables(L),v]).then(()=>{this.destroyed||this.emit("init")})}async installTables(e){let t=await ud();if(!t||this.destroyed)return;let{state:r}=this.view,o=r.plugins.indexOf(e),i=[...r.plugins];i.splice(o<0?i.length:o,0,...t.tablePlugins()),Cd(this.view,i),this.updateUI()}applyContentStyles(){let{contentStyle:e,contentCss:t}=this.options,r=t===void 0?[]:Array.isArray(t)?t:[t];if(!e&&!r.length)return;let o=`nova-cs-${++Lw}`;this.root.classList.add(o);let i=`.nova-editor.${o} .nova-prosemirror`,s=r.map(()=>""),l=null,a=()=>{this.destroyed||(l?.(),l=Ic(this.root,Ui([...s,e??""].join(`
44
- `),i)))};if(this.cleanups.push(()=>l?.()),a(),!!r.length)return Promise.all(r.map((c,d)=>Ji(c).then(u=>{s[d]=u},u=>console.warn(`[nova] contentCss: could not load ${c}`,u)))).then(a)}isAllowed(e){return this.contentRules?.isAllowed(e)??!0}hasPlugin(e){return this.pluginsByName.has(e)}collectPmPlugins(e){try{let t=e.prosemirrorPlugins?.(this)??[];if(e.nodeViews){let r=Object.fromEntries(Object.entries(e.nodeViews).map(([o,i])=>[o,i(this)]));t.push(new z({props:{nodeViews:r}}))}return t}catch(t){return vt(`Plugin "${e.name}" failed to create ProseMirror plugins`,t),[]}}setupPlugin(e){try{let t=e.setup?.(this);typeof t=="function"&&this.cleanups.push(t),this.pluginsByName.set(e.name,e)}catch(t){vt(`Plugin "${e.name}" failed during setup`,t)}}async loadLazyPlugins(e){let t=await Promise.all(e.map(l=>Ps(l).catch(a=>(vt("Failed to load plugin",a),null))));if(this.destroyed)return;let r=t.filter(l=>l?l.nodes||l.marks?(vt(`Plugin "${l.name}" defines nodes or marks and cannot be loaded lazily; pass the plugin object instead`),!1):!0:!1),{ordered:o,errors:i}=On(r,new Set(this.pluginsByName.keys()));i.forEach(l=>vt(l));let s=o.flatMap(l=>this.collectPmPlugins(l));s.length&&Cd(this.view,[...this.view.state.plugins,...s]),o.forEach(l=>{this.registerCommands(l),this.setupPlugin(l)}),this.rebuildToolbar()}updateUI(){this.destroyed||this.toolbar?.update()}rebuildToolbar(){!this.toolbar||this.destroyed||(this.toolbar.destroy(),this.toolbar=Xd(this,this.toolbarHost,this.toolbarConfig(),this.options.toolbarMode??"floating"))}toolbarConfig(){if(this.options.toolbar)return this.options.toolbar;let e=[...this.pluginsByName.values()].map(t=>t.toolbar).filter(Boolean);return e.length?`${Gd} | ${e.join(" ")}`:Gd}handleTransaction(e,t=this.view){if(!t.isDestroyed){for(let r of this.transactionTransforms)e=r(e,t.state,this);t.updateState(t.state.apply(e)),this.view&&(this.toolbar?.update(),this.statusbar?.update(e.docChanged),this.searchBar?.update(),this.updatePlaceholder(),e.docChanged&&(this.emit("change",{transaction:e}),!(e.getMeta(xs)||e.getMeta(tu))&&e.getMeta("addToHistory")!==!1&&this.emit("input",{transaction:e})),(e.selectionSet||e.docChanged)&&this.emit("selectionChange",{transaction:e}))}}updatePlaceholder(){let e=this.view.state.doc,t=e.childCount===1&&e.firstChild?.type===this.schema.nodes.paragraph&&e.firstChild.content.size===0;this.view.dom.classList.toggle("nova-empty",t)}getHTML({fullPage:e=!0}={}){let t=this.view.state.doc,r=fr.serializeFragment(t.content),o=e?An.get(this):void 0;return o?o.write(r,t.attrs):r}getJSON(){return this.view.state.doc.toJSON()}getText(){return this.view.state.doc.textBetween(0,this.view.state.doc.content.size,`
43
+ `).trim()}function Ju(n){let{t:e}=n.ui,t=Wg(Fu(n)),r=w("textarea",{className:"nova-input nova-source",spellcheck:"false","aria-label":e("sourceCode"),autocomplete:"off",rows:"18"});r.value=t,n.ui.openDialog({title:e("sourceCode"),body:r,size:"large",submitLabel:e("dialog.save"),initialFocus:r,onSubmit:()=>(r.value!==t&&zu(n,r.value),!0)})}var xw=[{group:"help.formatting",rows:[{label:"bold",keys:"Mod-b"},{label:"italic",keys:"Mod-i"},{label:"underline",keys:"Mod-u"},{label:"strike",keys:"Mod-Shift-x"},{label:"code",keys:"Mod-e"},{label:"superscript",keys:"Mod-."},{label:"subscript",keys:"Mod-,"},{label:"link",keys:"Mod-k"},{label:"clearFormatting",keys:"Mod-\\"}]},{group:"help.blocks",rows:[{label:"paragraph",keys:"Mod-Alt-0"},{label:"h1",keys:"Mod-Alt-1"},{label:"h2",keys:"Mod-Alt-2"},{label:"h3",keys:"Mod-Alt-3"},{label:"bulletList",keys:"Mod-Shift-8"},{label:"orderedList",keys:"Mod-Shift-7"},{label:"alignCenter",keys:"Mod-Shift-e"},{label:"indent",keys:"Mod-]"},{label:"outdent",keys:"Mod-["}]},{group:"help.editing",rows:[{label:"undo",keys:"Mod-z"},{label:"redo",keys:"Mod-Shift-z"},{label:"search.title",keys:"Mod-f"},{label:"pasteAsText",keys:"Mod-Shift-v"},{label:"fullscreen",keys:"Mod-Shift-f"},{label:"help.slash",keys:"/"},{label:"moveBlockUp",keys:"Alt-Shift-ArrowUp"},{label:"moveBlockDown",keys:"Alt-Shift-ArrowDown"}]},{group:"help.navigation",rows:[{label:"help.toMenubar",keys:"Alt-F9"},{label:"help.toToolbar",keys:"Alt-F10"},{label:"help.toContextToolbar",keys:"Ctrl-F9"},{label:"help.toEditor",keys:"Escape"},{label:"help.nextCell",keys:"Tab"},{label:"help",keys:"Alt-0"}]}];function go(n){let{t:e}=n.ui,t=w("div",{className:"nova-help"});for(let{group:r,rows:o}of xw)t.append(w("section",{},w("h3",{},e(r)),w("ul",{className:"nova-help-list"},o.map(({label:i,keys:s})=>w("li",{},w("span",{},e(i))," ",w("kbd",{},s.length===1?s:At(s)))))));n.ui.openDialog({title:e("help"),body:t,size:"large",cancelLabel:e("dialog.close")})}var Zu={};q(Zu,{defaultFontFamilies:()=>Yg,defaultFontSizes:()=>Xg,defaultLineHeights:()=>Zg,registerBuiltins:()=>Xu});var ww={color:Y.color,background:Y.color,font_family:Y.fontFamily,font_size:Y.length};function Ht(n,e){return(t,r)=>{let o=ce(t)[n],i=e===null?null:ww[n](e);if(e!==null&&!i)return!1;let{empty:s}=t.selection;if(!r)return!0;let l=t.tr;if(s)l.removeStoredMark(o),i&&l.addStoredMark(o.create({value:i}));else for(let a of t.selection.ranges)l.removeMark(a.$from.pos,a.$to.pos,o),i&&l.addMark(a.$from.pos,a.$to.pos,o.create({value:i}));return r(l.scrollIntoView()),!0}}function kt(n,e){let t=ce(n)[e],{$from:r,empty:o}=n.selection,i=o?n.storedMarks??r.marks():r.nodeAfter?.marks??r.marks(),s=t.isInSet(i);return s?s.attrs.value:null}function yo(n){return(e,t)=>{let r=n===null?null:Y.lineHeight(n);if(n!==null&&!r)return!1;let{from:o,to:i}=e.selection,s=e.tr,l=!1;return e.doc.nodesBetween(o,i,(a,c)=>{(a.type===Z(e).paragraph||a.type===Z(e).heading)&&(l=!0,s.setNodeMarkup(c,void 0,{...a.attrs,lineHeight:r}))}),l?(t?.(s),!0):!1}}function Yu(n){return n.selection.$from.parent.attrs.lineHeight??null}var hs=["#000000","#434343","#666666","#999999","#b7b7b7","#d9d9d9","#efefef","#ffffff","#b91c1c","#c2410c","#a16207","#15803d","#0e7490","#1d4ed8","#6d28d9","#be185d","#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#fecaca","#fed7aa","#fef08a","#bbf7d0","#a5f3fc","#bfdbfe","#ddd6fe","#fbcfe8"];function ms(n){let t=[],r=n.current?.toLowerCase()??null,o=w("div",{className:"nova-swatches",role:"grid","aria-label":n.label}),i=null;for(let a of n.colors){let c=r===a.toLowerCase(),u=w("button",{type:"button",className:"nova-swatch",role:"gridcell","aria-label":a,"aria-selected":String(c),title:a,tabindex:"-1"},c?ee(C.check):null);u.style.setProperty("--swatch",a),u.addEventListener("click",()=>n.onPick(a)),t.push(u),(!i||i.childElementCount===8)&&(i=w("div",{className:"nova-swatch-row",role:"row"}),o.append(i)),i.append(u)}(t.find(a=>a.getAttribute("aria-selected")==="true")??t[0])?.setAttribute("tabindex","0"),o.addEventListener("keydown",a=>{let c=t.indexOf(te(o));if(c<0)return;let d={ArrowRight:1,ArrowLeft:-1,ArrowDown:8,ArrowUp:-8}[Ne(a,o)];if(d===void 0)return;a.preventDefault();let p=t[Math.min(t.length-1,Math.max(0,c+d))];t[c].tabIndex=-1,p.tabIndex=0,p.focus()});let s=w("button",{type:"button",className:"nova-panel-action"},ee(C.clearFormatting),n.removeLabel);s.addEventListener("click",()=>n.onPick(null));let l=w("input",{type:"color",className:"nova-color-input","aria-label":n.customLabel,value:/^#[0-9a-f]{6}$/i.test(r??"")?r:"#000000"});return l.addEventListener("change",()=>n.onPick(l.value)),w("div",{className:"nova-color-panel"},o,w("div",{className:"nova-panel-footer"},s,w("label",{className:"nova-panel-action"},l,n.customLabel)))}function Kg(n){let{registry:e,t}=n.ui,r=(i,s)=>t("table.size",{rows:i,cols:s});e.addPanelButton("table",{icon:C.table,tooltip:t("table.insert"),isEnabled:i=>i.can(It(1,1)),render:(i,s)=>Mu((l,a)=>{s(),i.exec(It(l,a))},r,t("table.insert"))});let o=(i,s,l,a,c)=>e.addButton(i,{icon:l,tooltip:t(s),onAction:u=>u.exec(a),isEnabled:u=>u.can(a),...c?{isActive:c}:{}});o("tableinsertrowbefore","table.rowBefore",C.rowBefore,$e.addRowBefore),o("tableinsertrowafter","table.rowAfter",C.rowAfter,$e.addRowAfter),o("tabledeleterow","table.rowDelete",C.rowDelete,$e.deleteRow),o("tableinsertcolbefore","table.colBefore",C.colBefore,$e.addColumnBefore),o("tableinsertcolafter","table.colAfter",C.colAfter,$e.addColumnAfter),o("tabledeletecol","table.colDelete",C.colDelete,$e.deleteColumn),o("tablemergecells","table.merge",C.merge,$e.mergeCells),o("tablesplitcells","table.split",C.split,$e.splitCell),o("tablerowheader","table.rowHeader",C.rowHeader,$e.toggleHeaderRow,i=>xu(i.view.state)),o("tablecolheader","table.colHeader",C.colHeader,$e.toggleHeaderColumn,i=>wu(i.view.state)),o("tabledelete","table.delete",C.tableDelete,$e.deleteTable),e.addPanelButton("tablecellbackground",{icon:C.highlight,tooltip:t("table.cellBackground"),isEnabled:i=>Gt(i.view.state),render:(i,s)=>ms({colors:i.options.colors??hs,current:null,label:t("table.cellBackground"),removeLabel:t("removeColor"),customLabel:t("customColor"),onPick:l=>{s(),i.exec(vu(l))}})}),e.addMenuButton("advtablesort",{icon:C.sort,tooltip:t("table.sort"),isEnabled:i=>i.can(as("asc")),items:i=>{let s=["asc","desc"].map(a=>({id:a,label:t(a==="asc"?"table.sortAsc":"table.sortDesc"),onSelect:()=>i.exec(as(a,i.options.language))})),l=i.ui.registry.getMenuItem("advtablesort");return l?[...s,{id:"advanced",label:l.text,onSelect:()=>l.onAction(i)}]:s}}),e.addButton("tableprops",{icon:C.tableProps,tooltip:t("table.props"),isEnabled:i=>Gt(i.view.state),onAction:i=>{import(__novaChunk("tinymce-chunks/table-dialogs-0445847c.js") ).then(s=>s.openTableProps(i))}}),e.addButton("tablecellprops",{icon:C.cellProps,tooltip:t("table.cellProps"),isEnabled:i=>Gt(i.view.state),onAction:i=>{import(__novaChunk("tinymce-chunks/table-dialogs-0445847c.js") ).then(s=>s.openCellProps(i))}}),e.addContextToolbar("table",{label:t("table.toolbar"),predicate:i=>Gt(i.view.state),anchor:i=>Su(i),placement:"bottom-start",items:"tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells | tablerowheader tablecolheader tablecellbackground | advtablesort advtablerownumbering tablecellprops tableprops | tabledelete"})}var Yg=[{label:"Sans Serif",value:'system-ui, -apple-system, "Segoe UI", Roboto, sans-serif'},{label:"Serif",value:'Georgia, "Times New Roman", serif'},{label:"Monospace",value:"ui-monospace, Menlo, Consolas, monospace"},{label:"Arial",value:"Arial, Helvetica, sans-serif"},{label:"Georgia",value:"Georgia, serif"},{label:"Times New Roman",value:'"Times New Roman", Times, serif'},{label:"Verdana",value:"Verdana, Geneva, sans-serif"},{label:"Courier New",value:'"Courier New", Courier, monospace'}],Xg=["8pt","10pt","12pt","14pt","16pt","18pt","24pt","36pt","48pt"],Zg=["1","1.15","1.5","2","2.5","3"],rt={undo:"Mod-z",redo:"Mod-Shift-z",bold:"Mod-b",italic:"Mod-i",underline:"Mod-u",strike:"Mod-Shift-x",code:"Mod-e",subscript:"Mod-,",superscript:"Mod-.",bulletList:"Mod-Shift-8",orderedList:"Mod-Shift-7",alignLeft:"Mod-Shift-l",alignCenter:"Mod-Shift-e",alignRight:"Mod-Shift-r",alignJustify:"Mod-Shift-j",indent:"Mod-]",outdent:"Mod-[",clearFormatting:"Mod-\\",paragraph:"Mod-Alt-0",h1:"Mod-Alt-1",h2:"Mod-Alt-2",h3:"Mod-Alt-3",h4:"Mod-Alt-4",h5:"Mod-Alt-5",h6:"Mod-Alt-6"};function Ug(n){try{let{node:e}=n.view.domAtPos(n.view.state.selection.from),t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;return t?getComputedStyle(t):null}catch{return null}}var Sw={"system-ui":"Sans Serif","-apple-system":"Sans Serif","sans-serif":"Sans Serif",serif:"Serif",monospace:"Monospace","ui-monospace":"Monospace"};function Jg(n){let e=String(n).split(",")[0].trim().replace(/["']/g,"");return Sw[e.toLowerCase()]??e}function Mw(n){let e=parseFloat(n);return!Number.isFinite(e)||e<=0?null:`${Math.round(e*.75*2)/2}pt`}var Gg=(n,e)=>typeof n=="string"&&n.replace(/["'\s]/g,"").toLowerCase()===e.replace(/["'\s]/g,"").toLowerCase();function Xu(n){let{registry:e,t}=n.ui,r=()=>n.view.state,o=(y,v,b,E)=>e.addButton(y,{icon:b,tooltip:t(v),...rt[v]?{shortcut:rt[v]}:{},onAction:_=>_.exec(v),isEnabled:_=>_.can(v),...E?{isActive:E}:{}}),i=(y,v,b,E)=>o(y,v,E,()=>ar(r(),n.schema.marks[b]));o("undo","undo",C.undo),o("redo","redo",C.redo),i("bold","bold","bold",C.bold),i("italic","italic","italic",C.italic),i("underline","underline","underline",C.underline),i("strikethrough","strike","strike",C.strike),i("inlinecode","code","code",C.code),i("subscript","subscript","subscript",C.subscript),i("superscript","superscript","superscript",C.superscript),o("bullist","bulletList",C.bulletList,()=>Ze(r(),n.schema.nodes.bullet_list)),o("numlist","orderedList",C.orderedList,()=>Ze(r(),n.schema.nodes.ordered_list)),o("indent","indent",C.indent),o("outdent","outdent",C.outdent),o("blockquote","blockquote",C.blockquote,()=>Ze(r(),n.schema.nodes.blockquote)),o("codeblock","codeBlock",C.codeBlock,()=>Ze(r(),n.schema.nodes.code_block)),o("hr","horizontalRule",C.horizontalRule),o("removeformat","clearFormatting",C.clearFormatting);let s=[["alignLeft","left",C.alignLeft],["alignCenter","center",C.alignCenter],["alignRight","right",C.alignRight],["alignJustify","justify",C.alignJustify]];for(let[y,v,b]of s)o(y.toLowerCase(),y,b,()=>Zt(r())===v);e.addMenuButton("align",{icon:C.alignLeft,tooltip:t("align"),isEnabled:y=>y.can("alignLeft"),items:y=>s.map(([v,b,E])=>({id:v,label:t(v),icon:E,...rt[v]?{shortcut:rt[v]}:{},active:Zt(y.view.state)===b,onSelect:()=>y.exec(v)}))});let l=[{command:"paragraph",style:""},{command:"h1",style:"font-size: 1.6em; font-weight: 700"},{command:"h2",style:"font-size: 1.35em; font-weight: 700"},{command:"h3",style:"font-size: 1.15em; font-weight: 700"},{command:"h4",style:"font-size: 1em; font-weight: 700"},{command:"h5",style:"font-size: 0.9em; font-weight: 700"},{command:"h6",style:"font-size: 0.85em; font-weight: 700"},{command:"codeBlock",style:"font-family: ui-monospace, monospace"}],a=()=>{let y=r().selection.$from.parent;return y.type===n.schema.nodes.heading?`h${y.attrs.level}`:y.type===n.schema.nodes.code_block?"codeBlock":"paragraph"};for(let y=1;y<=6;y++){let v=`h${y}`;e.addToggleButton(v,{...y<=3?{icon:C[`h${y}`]}:{text:`H${y}`},tooltip:t(v),...rt[v]?{shortcut:rt[v]}:{},isActive:()=>a()===v,isEnabled:b=>b.can(v)||a()===v,onAction:b=>b.exec(a()===v?"paragraph":v)})}let c={p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",pre:"codeBlock"},u=()=>{let y=n.options.blockFormats;return y?.length?y.flatMap(({label:v,block:b})=>{let E=c[b],_=l.find(N=>N.command===E);return _?[{..._,label:v}]:[]}):l};e.addMenuButton("blocks",{tooltip:t("blocks"),label:()=>u().find(y=>y.command===a())?.label??t(a()),minChars:11,isEnabled:y=>u().some(({command:v})=>y.can(v)),items:y=>u().filter(({command:v})=>y.isAllowed(v)).map(({command:v,style:b,label:E})=>({id:v,label:E??t(v),labelStyle:b,...rt[v]?{shortcut:rt[v]}:{},active:a()===v,onSelect:()=>y.exec(v)}))});let d="p,h1,h2,h3,h4,h5,h6",p=()=>[{title:t("styles.headings"),items:[1,2,3,4,5,6].map(y=>({title:t(`h${y}`),block:`h${y}`}))},{title:t("styles.inline"),items:[{title:t("bold"),inline:"strong"},{title:t("italic"),inline:"em"},{title:t("underline"),inline:"u"},{title:t("strike"),inline:"s"},{title:t("superscript"),inline:"sup"},{title:t("subscript"),inline:"sub"},{title:t("code"),inline:"code"}]},{title:t("styles.blocks"),items:[{title:t("paragraph"),block:"p"},{title:t("blockquote"),block:"blockquote"},{title:t("codeBlock"),block:"pre"}]},{title:t("styles.align"),items:["left","center","right","justify"].map(y=>({title:t(`align${y==="justify"?"Justify":y[0].toUpperCase()+y.slice(1)}`),selector:d,styles:{"text-align":y}}))}],f=y=>y.format??y,h=y=>{let v=y.format?n.formatter.get(y.format)?.[0]:y,b=[],E=v?.block;E&&/^h[1-6]$/.test(E)&&b.push("font-weight: 700"),(v?.inline==="strong"||v?.inline==="b")&&b.push("font-weight: 700"),(v?.inline==="em"||v?.inline==="i")&&b.push("font-style: italic"),v?.inline==="u"&&b.push("text-decoration: underline"),(v?.inline==="s"||v?.inline==="strike"||v?.inline==="del")&&b.push("text-decoration: line-through"),(v?.inline==="code"||E==="pre")&&b.push("font-family: ui-monospace, monospace");for(let _ of["color","background-color","font-family"]){let N=v?.styles?.[_];N&&/^[#\w\s,'"().%-]+$/.test(N)&&b.push(`${_}: ${N}`)}return b.join("; ")},m=y=>y.flatMap(v=>v.items?m(v.items):[v]),g=()=>{let y=n.options.styleFormats,v=y?n.options.styleFormatsMerge?[...p(),...y]:y:p(),b=e.getStyleFormats();return b.items.length?b.replace?[...b.items]:[...v,...b.items]:v};e.addMenuButton("styles",{tooltip:t("styles"),minChars:10,label:y=>m(g()).find(v=>y.formatter.match(f(v)))?.title??t("styles"),items:y=>{let v=[],b=(E,_)=>{E.forEach((N,$)=>{if(N.items){v.length&&v.push({type:"separator"}),v.push({type:"heading",label:N.title}),b(N.items,`${_}${$}-`);return}v.push({id:`style-${_}${$}`,label:N.title,labelStyle:h(N),active:y.formatter.match(f(N)),disabled:!y.formatter.canApply(f(N)),onSelect:()=>y.formatter.toggle(f(N))})})};return b(g(),""),v}});let k=n.options.fontFamilies??Yg;e.addMenuButton("fontfamily",{tooltip:t("fontFamily"),minChars:9,label:y=>{let v=kt(r(),"font_family");if(v)return k.find(E=>Gg(v,E.value))?.label??Jg(v);let b=Ug(y)?.fontFamily;return b?Jg(b):t("fontFamily")},items:y=>{let v=kt(y.view.state,"font_family");return[{id:"default",label:t("default"),active:v===null,onSelect:()=>y.exec(Ht("font_family",null))},{type:"separator"},...k.map(b=>({id:b.label,label:b.label,labelStyle:`font-family: ${b.value}`,active:Gg(v,b.value),onSelect:()=>y.exec(Ht("font_family",b.value))}))]}});let x=n.options.fontSizes??Xg;e.addMenuButton("fontsize",{tooltip:t("fontSize"),minChars:4,label:y=>kt(r(),"font_size")??Mw(Ug(y)?.fontSize??"")??"\u2014",items:y=>{let v=kt(y.view.state,"font_size");return[{id:"default",label:t("default"),active:v===null,onSelect:()=>y.exec(Ht("font_size",null))},{type:"separator"},...x.map(b=>({id:b,label:b,active:v===b,onSelect:()=>y.exec(Ht("font_size",b))}))]}});let M=n.options.lineHeights??Zg;e.addMenuButton("lineheight",{icon:C.lineHeight,tooltip:t("lineHeight"),isEnabled:y=>y.can(yo(null)),items:y=>{let v=Yu(y.view.state);return[{id:"default",label:t("default"),active:v===null,onSelect:()=>y.exec(yo(null))},...M.map(b=>({id:b,label:b,active:v===b,onSelect:()=>y.exec(yo(b))}))]}});let L=()=>Si(n.options.contentLangs,n.options.language);if(L().length){let y=v=>v.can(rr("en"));e.addMenuButton("language",{icon:C.language,tooltip:t("language"),isEnabled:y,items:v=>{let b=Mi(v.view.state);return[{id:"default",label:t("language.default"),active:b===null,onSelect:()=>v.exec(rr(null))},{type:"separator"},...L().map(({code:E,title:_})=>({id:E,label:_,active:b===E,onSelect:()=>v.exec(rr(E))}))]}}),e.addMenuItem("language",{text:`${t("language")}\u2026`,icon:C.language,isEnabled:y,onAction:v=>{Ew(v)}})}let O=(y,v,b,E)=>e.addPanelButton(y,{icon:b,tooltip:t(E),indicator:()=>kt(r(),v),render:(_,N)=>ms({colors:_.options.colors??hs,current:kt(_.view.state,v),label:t(E),removeLabel:t("removeColor"),customLabel:t("customColor"),onPick:$=>{N(),_.exec(Ht(v,$))}})});O("forecolor","color",C.textColor,"textColor"),O("backcolor","background",C.highlight,"backgroundColor");let B=[["superscript","superscript",C.superscript],["subscript","subscript",C.subscript],["code","code",C.code]];e.addMenuButton("moreformats",{icon:C.formatMore,tooltip:t("moreFormats"),isActive:y=>B.some(([,v])=>ar(y.view.state,n.schema.marks[v])),items:y=>[...B.filter(([v])=>y.isAllowed(v)).map(([v,b,E])=>({id:v,label:t(v),icon:E,checkbox:!0,active:ar(y.view.state,n.schema.marks[b]),disabled:!y.can(v),...rt[v]?{shortcut:rt[v]}:{},onSelect:()=>y.exec(v)})),{type:"separator"},{id:"clearFormatting",label:t("clearFormatting"),icon:C.clearFormatting,disabled:!y.can("clearFormatting"),shortcut:rt.clearFormatting,onSelect:()=>y.exec("clearFormatting")},{id:"pasteAsText",label:t("pasteAsText"),icon:C.pasteText,checkbox:!0,active:y.isPasteAsText(),onSelect:()=>{y.setPasteAsText(!y.isPasteAsText()),y.focus()}}]}),e.addToggleButton("pastetext",{icon:C.pasteText,tooltip:t("pasteAsText"),isActive:y=>y.isPasteAsText(),onAction:y=>{y.setPasteAsText(!y.isPasteAsText()),y.focus()}}),e.addButton("link",{icon:C.link,tooltip:t("link"),shortcut:"Mod-k",onAction:y=>_t(y),isActive:()=>!!Cn(r())}),e.addButton("unlink",{icon:C.unlink,tooltip:t("unlink"),onAction:y=>y.exec(dr()),isEnabled:y=>y.can(dr())}),e.addButton("image",{icon:C.image,tooltip:t("image"),onAction:y=>lo(y)});let J=()=>et(r())?.attrs.align??null,P=(y,v,b,E)=>e.addToggleButton(y,{icon:b,tooltip:t(E),isActive:()=>J()===v,onAction:_=>_.exec(ur({align:J()===v?null:v}))});P("imagealignleft","left",C.imageLeft,"image.alignLeft"),P("imagealigncenter","center",C.imageCenter,"image.alignCenter"),P("imagealignright","right",C.imageRight,"image.alignRight");let G=[["image.sizeSmall",.25],["image.sizeMedium",.5],["image.sizeLarge",.75],["image.sizeFull",1],["image.sizeOriginal",null]];e.addMenuButton("imagesize",{icon:C.resize,tooltip:t("image.size"),items:y=>G.map(([v,b])=>({id:v,label:t(v),onSelect:()=>su(y,b)}))}),e.addButton("imagealt",{icon:C.altText,tooltip:t("image.editAlt"),onAction:y=>lu(y)}),e.addToggleButton("imagecaption",{icon:C.imageCaption,tooltip:t("image.caption"),isActive:y=>ru(y.view.state),onAction:y=>y.exec(ou)}),e.addButton("imagedelete",{icon:C.trash,tooltip:t("image.delete"),onAction:y=>y.exec((v,b)=>{let E=et(v);return E?(b?.(v.tr.delete(E.pos,E.pos+E.node.nodeSize).scrollIntoView()),!0):!1})}),Kg(n),e.addButton("searchreplace",{icon:C.search,tooltip:t("search.title"),shortcut:"Mod-f",onAction:y=>y.openSearch()}),e.addToggleButton("fullscreen",{icon:C.fullscreen,tooltip:t("fullscreen"),shortcut:"Mod-Shift-f",isActive:y=>fs(y),onAction:y=>yr(y)}),e.addButton("preview",{icon:C.preview,tooltip:t("preview"),onAction:y=>Uu(y)}),e.addButton("code",{icon:C.sourceCode,tooltip:t("sourceCode"),onAction:y=>Ju(y)}),e.addButton("help",{icon:C.help,tooltip:t("help"),shortcut:"Alt-0",onAction:y=>go(y)}),e.addContextToolbar("image",{label:t("image.toolbar"),predicate:y=>!!et(y.view.state),items:"imagealignleft imagealigncenter imagealignright | imagesize imagealt imagecaption | imagedelete",anchor:y=>{let v=et(y.view.state);return(v?y.view.nodeDOM(v.pos):null)?.getBoundingClientRect()??null}})}async function Ew(n){let e=n.ui.t,t=Mi(n.view.state),r=Si(n.options.contentLangs,n.options.language);t&&!r.some(i=>i.code===t)&&r.unshift({code:t,title:wi(t,n.options.language)});let o=await n.ui.dialog({title:e("language"),submitLabel:e("dialog.save"),initialData:{lang:t??""},fields:[{type:"select",name:"lang",label:e("language.field"),options:[{value:"",label:e("language.default")},...r.map(({code:i,title:s})=>({value:i,label:s}))]}]});o&&n.exec(rr(String(o.lang??"")||null))}var nd={};q(nd,{addLinkNote:()=>Cw,linkBubblePlugin:()=>td});var Qu={};q(Qu,{Popover:()=>Nn,positionFloating:()=>vt,visibleArea:()=>bs});var gs=6,ys=8;function bs(){let n=window.visualViewport;return n?{left:n.offsetLeft,top:n.offsetTop,right:n.offsetLeft+n.width,bottom:n.offsetTop+n.height}:{left:0,top:0,right:window.innerWidth,bottom:window.innerHeight}}function vt(n,e,t){let r=bs(),o=n.offsetWidth,i=n.offsetHeight,s=r.bottom-e.bottom,l=e.top-r.top,c=t==="top-start"||t==="top-end"?l>=i+gs||l>s:s<i+gs&&l>s,u=c?e.top-i-gs:e.bottom+gs,d=Fn(n),f=t==="bottom"?e.left+e.width/2-o/2:(t==="bottom-end"||t==="top-end")!==d?e.right-o:e.left;f=Math.max(r.left+ys,Math.min(f,r.right-o-ys)),u=Math.max(r.top+ys,Math.min(u,r.bottom-i-ys)),n.style.left=`${Math.round(f)}px`,n.style.top=`${Math.round(u)}px`,n.dataset.side=c?"top":"bottom"}var bo=[],Nn=class{constructor(e){S(this,"el");S(this,"options");S(this,"closed",!1);S(this,"unlisten",[]);S(this,"reposition",()=>{if(this.closed)return;let{anchor:e,placement:t="bottom-start"}=this.options,r=typeof e=="function"?e():e.getBoundingClientRect();vt(this.el,r,t)});S(this,"focusWasInside",!1);S(this,"onKeyDown",(e,t)=>{e.key!=="Escape"||e.defaultPrevented||bo[bo.length-1]===this&&(t?.closest?.(".nova-dialog")||(e.preventDefault(),e.stopPropagation(),this.focusWasInside=this.el.contains(te(this.el)),this.close("escape")))});S(this,"onPointerDown",(e,t)=>{this.options.dismissOnOutside!==!1&&(this.el.contains(t)||this.options.ignore?.some(r=>r.contains(t))||this.close("outside"))});this.options=e,this.el=document.createElement("div"),this.el.className=`nova-popover ${e.className??""}`.trim(),this.el.append(e.content),e.host.append(this.el),this.reposition(),this.unlisten=[ut(this.el,"keydown",this.onKeyDown),ut(this.el,"pointerdown",this.onPointerDown)],bo.push(this),window.addEventListener("resize",this.reposition),window.addEventListener("scroll",this.reposition,!0)}get isOpen(){return!this.closed}close(e="api"){this.closed||(this.closed=!0,bo.splice(bo.indexOf(this),1),this.unlisten.forEach(t=>t()),window.removeEventListener("resize",this.reposition),window.removeEventListener("scroll",this.reposition,!0),this.el.remove(),this.options.onClose?.(e))}};var ed=new WeakMap;function Cw(n,e){let t=ed.get(n)??new Set;return ed.set(n,t),t.add(e),()=>t.delete(e)}function td(n){return new z({key:new X("nova-link-bubble"),view(e){let{t}=n.ui,r=w("a",{className:"nova-bubble-link",target:"_blank",rel:"noopener noreferrer"}),o=(h,m,g)=>{let k=w("button",{type:"button",className:"nova-btn","aria-label":m,"data-tooltip":m},ee(h));return k.addEventListener("click",g),n.ui.tooltip.attach(k),k},i=w("div",{className:"nova-bubble-row"},ee(C.externalLink),r,w("span",{className:"nova-bubble-sep"}),o(C.edit,t("link.edit"),()=>_t(n)),o(C.copy,t("link.copy"),()=>{navigator.clipboard?.writeText(r.href).then(()=>n.ui.notify({text:t("link.copied"),type:"success",timeout:2e3}))}),o(C.unlink,t("unlink"),()=>n.exec(dr()))),s=w("span",{className:"nova-bubble-note-text"}),l=w("button",{type:"button",className:"nova-button nova-bubble-note-action"}),a=w("div",{className:"nova-bubble-note",hidden:!0},s,l),c=w("div",{className:"nova-bubble nova-link-bubble",role:"toolbar","aria-label":t("link"),hidden:!0},i,a),u=null;l.addEventListener("click",()=>u?.()),c.addEventListener("mousedown",h=>{h.target.closest("button")&&h.preventDefault()}),n.ui.overlayHost.append(c);let d=()=>{c.hidden=!0},p=()=>{let h=e.state,m=Cn(h),g=e.hasFocus()||c.contains(te(c));if(!m||!g||!n.isEditable()||n.ui.activeDialog||!h.selection.empty){d();return}let k=An(h,ce(h).link,h.selection.from);if(!k)return d();r.textContent=m.href,r.title=m.href;let x=null;for(let B of ed.get(n)??[])if(x=B(m.href),x)break;a.hidden=!x,s.textContent=x?.text??"",l.hidden=!x?.action,l.textContent=x?.action?.label??"",u=x?.action?.run??null,Ie(m.href)?r.setAttribute("href",m.href):r.removeAttribute("href"),c.hidden=!1;let M=e.coordsAtPos(k.from),L=e.coordsAtPos(k.to),O=new DOMRect(M.left,M.top,Math.max(1,L.right-M.left),L.bottom-M.top);vt(c,O,"bottom-start")},f=h=>{c.contains(h.relatedTarget)||d()};return e.dom.addEventListener("blur",f),c.addEventListener("focusout",h=>{!c.contains(h.relatedTarget)&&!e.hasFocus()&&d()}),{update:p,destroy(){e.dom.removeEventListener("blur",f),c.remove()}}}})}var rd="undo redo | blocks | bold italic underline strikethrough moreformats | forecolor backcolor | link image table | bullist numlist | align lineheight outdent indent | fontfamily fontsize | blockquote codeblock hr | removeformat | searchreplace preview code fullscreen help";function od(n){let e=Array.isArray(n)?n:n.split(/\s+/),t=[[]];for(let r of e){let o=r.trim();o&&(o==="|"?t.push([]):t[t.length-1].push(o))}return t.filter(r=>r.length>0)}function id(n,e,t,r,{warnUnknown:o=!0}={}){let{ui:i}=n,s=i.t,l=new AbortController,{signal:a}=l;e.className=`nova-toolbar nova-toolbar-${r}`,e.setAttribute("role","toolbar"),e.setAttribute("aria-label",s("toolbar.label"));let c=[],u=[];for(let y of od(t)){let v=w("div",{className:"nova-tb-group",role:"group"});for(let b of y){if(!n.isAllowed(b))continue;let E=i.registry.get(b);if(!E){o&&console.warn(`[nova] Unknown toolbar item "${b}"`);continue}let _=ko(n,b,E);c.push(_),v.append(_.el)}v.childElementCount&&(u.push(v),e.append(v))}let d=r==="floating"||r==="sliding",p=r==="sliding",f=w("div",{className:p?"nova-toolbar nova-tb-strip":"nova-toolbar nova-tb-overflow",role:"group",id:je("nova-tb-more"),"aria-label":s("more"),hidden:p}),h=w("button",{type:"button",className:"nova-btn nova-tb-more","aria-label":s("more"),"aria-expanded":"false","data-tooltip":s("more"),hidden:!0,...p?{"aria-controls":f.id}:{"aria-haspopup":"true"}},ee(C.more));i.tooltip.attach(h);let m=null,g=()=>{m?.close(),m=null,p&&!f.hidden&&(f.hidden=!0,h.setAttribute("aria-expanded","false"))},k=i.onDialogOpen(()=>{p||g()});h.addEventListener("click",y=>{if(p){let b=f.hidden;f.hidden=!b,h.setAttribute("aria-expanded",String(b)),b&&y.detail===0&&f.querySelector("button:not(:disabled)")?.focus();return}if(m)return g();h.setAttribute("aria-expanded","true");let v=new Nn({host:i.overlayHost,anchor:h,placement:"bottom-end",content:f,className:"nova-tb-overflow-popover",ignore:[i.overlayHost,h],onClose:b=>{m=null,h.setAttribute("aria-expanded","false"),b==="escape"&&v.focusWasInside&&h.focus()}});m=v,y.detail===0&&f.querySelector("button:not(:disabled)")?.focus()}),d&&e.append(h),p&&e.after(f),r==="scrolling"&&e.addEventListener("focusin",y=>y.target.scrollIntoView?.({block:"nearest",inline:"nearest"}),{signal:a});let x=()=>{if(!d)return;for(let v of u)e.insertBefore(v,h);if(h.hidden=!0,e.scrollWidth<=e.clientWidth+1){g();return}h.hidden=!1;let y=u.length;for(;y>1&&e.scrollWidth>e.clientWidth+1;)y-=1,f.prepend(u[y]);f.childElementCount||(h.hidden=!0,g()),m?.reposition(),J()},M=-1,L=typeof ResizeObserver<"u"&&d?new ResizeObserver(()=>{e.clientWidth!==M&&(M=e.clientWidth,x())}):null;L?.observe(e);let O=()=>[...e.querySelectorAll("button")].filter(y=>!y.disabled&&!y.hidden),B=null,J=()=>{let y=O();(!B||!y.includes(B))&&(B=y[0]??null);for(let v of e.querySelectorAll("button"))v.tabIndex=v===B?0:-1};e.addEventListener("focusin",y=>{let v=y.target;v instanceof HTMLButtonElement&&e.contains(v)&&(B=v,J())},{signal:a}),e.addEventListener("keydown",y=>{let v=O(),b=v.indexOf(te(e));if(b<0)return;let E=null,_=Ne(y,e);if(_==="ArrowRight")E=b+1;else if(_==="ArrowLeft")E=b-1;else if(y.key==="Home")E=0;else if(y.key==="End")E=v.length-1;else if(y.key==="Escape"){y.preventDefault(),n.focus();return}E!==null&&(y.preventDefault(),v[(E+v.length)%v.length].focus())},{signal:a});let P=y=>{y.target.closest("button")&&y.preventDefault()};e.addEventListener("mousedown",P,{signal:a}),f.addEventListener("mousedown",P),f.addEventListener("keydown",y=>{if(y.key==="Escape"){p&&(y.preventDefault(),g(),h.focus());return}let v=[...f.querySelectorAll("button")].filter(_=>!_.disabled),b=v.indexOf(te(f));if(b<0)return;let E=Ne(y,f);E==="ArrowRight"||E==="ArrowDown"?(y.preventDefault(),v[(b+1)%v.length].focus()):(E==="ArrowLeft"||E==="ArrowUp")&&(y.preventDefault(),v[(b-1+v.length)%v.length].focus())});let G=()=>{for(let y of c)y.update();J()};return G(),x(),{update:G,focus:()=>{J(),B?.focus()},destroy:()=>{L?.disconnect(),k(),g(),l.abort(),e.replaceChildren(),p&&f.remove()}}}function ko(n,e,t){if(t.type==="split")return Aw(n,e,t);let{ui:r}=n,o=w("button",{type:"button",className:`nova-btn nova-tb-${t.type}`,"aria-label":t.tooltip,"data-tooltip":t.tooltip,"data-control":e,...t.shortcut?{"data-shortcut":t.shortcut}:{}});r.tooltip.attach(o),t.icon&&o.append(ee(t.icon));let i=t.type==="menu"&&(t.label||t.text)?w("span",{className:"nova-tb-label"}):null;i?(t.type==="menu"&&t.minChars&&(i.style.minWidth=`${t.minChars}ch`),o.append(i),o.classList.add("nova-tb-has-label")):!t.icon&&t.text&&o.append(t.text);let s=null;return t.type==="panel"&&t.indicator&&(s=w("span",{className:"nova-color-bar"}),o.append(s)),t.type!=="button"&&(o.setAttribute("aria-haspopup",t.type==="menu"?"menu":"dialog"),o.setAttribute("aria-expanded","false"),o.append(ee(C.chevronDown)),o.lastElementChild?.classList.add("nova-chevron")),o.addEventListener("click",a=>{if(t.type==="button"){t.onAction(n);return}if(o.getAttribute("aria-expanded")==="true"){r.closePopover();return}let c=a.detail===0,u=()=>r.closePopover(),d=t.type==="menu"?fo(t.items(n),u,t.tooltip):t.render(n,u);o.setAttribute("aria-expanded","true");let p=r.openPopover({anchor:o,content:d,ignore:[o],className:t.type==="menu"?"nova-popover-menu":"nova-popover-panel",onClose:f=>{o.setAttribute("aria-expanded","false"),f==="escape"&&p.focusWasInside&&o.focus()}});t.type==="menu"?ho(d):c&&d.querySelector("button, input")?.focus()}),t.type!=="button"&&o.addEventListener("keydown",a=>{a.key==="ArrowDown"&&o.getAttribute("aria-expanded")!=="true"&&(a.preventDefault(),o.click())}),{el:o,update:()=>{let a=n.isEditable();if(o.disabled=!a||(t.isEnabled?!t.isEnabled(n):!1),t.isActive){let c=t.isActive(n);o.classList.toggle("is-active",c),t.type==="button"&&o.setAttribute("aria-pressed",String(c))}if(i&&t.type==="menu"){let c=t.label?.(n)??t.text??"";i.textContent=c,o.setAttribute("aria-label",c&&c!==t.tooltip?`${c}, ${t.tooltip}`:t.tooltip??c)}if(s&&t.type==="panel"&&t.indicator){let c=t.indicator(n);s.style.background=c??"",s.classList.toggle("is-empty",!c)}}}}function Aw(n,e,t){let r=ko(n,e,{type:"button",tooltip:t.tooltip,onAction:t.onAction,...t.icon?{icon:t.icon}:{},...t.text?{text:t.text}:{},...t.shortcut?{shortcut:t.shortcut}:{},...t.isActive?{isActive:t.isActive}:{},...t.isEnabled?{isEnabled:t.isEnabled}:{}}),o=ko(n,`${e}-options`,{type:"menu",tooltip:`${t.tooltip}: ${n.ui.t("toolbar.options")}`,items:t.items,...t.isEnabled?{isEnabled:t.isEnabled}:{}});return o.el.classList.add("nova-tb-split-more"),{el:w("span",{className:"nova-tb-split"},r.el,o.el),update:()=>{r.update(),o.update()}}}function Qg(n){return new z({key:new X("nova-context-toolbar"),view(e){let t=w("div",{className:"nova-bubble nova-context-toolbar",role:"toolbar",hidden:!0});n.ui.overlayHost.append(t);let r=new Map,o=null,i=(k,x)=>{let M=r.get(k);if(M)return M;let L=w("div",{className:"nova-context-items"}),O=[];return od(x.items).forEach((B,J)=>{J>0&&L.append(w("span",{className:"nova-bubble-sep",role:"separator"}));for(let P of B){if(!n.isAllowed(P))continue;let G=n.ui.registry.get(P);if(!G)continue;let y=ko(n,P,G);O.push(y),L.append(y.el)}}),M={el:L,controls:O},r.set(k,M),M},s=()=>{t.hidden=!0,o=null},l=k=>{let{selection:x}=e.state;if((k.position??"node")==="node"&&x instanceof R)return e.nodeDOM(x.from)?.getBoundingClientRect()??null;let M=e.coordsAtPos(x.from),L=e.coordsAtPos(x.to);return new DOMRect(M.left,M.top,Math.max(1,L.right-M.left),L.bottom-M.top)},a=!1,c=k=>{k.pointerType==="mouse"&&k.button===0&&(a=!0)},u=()=>{a&&(a=!1,setTimeout(()=>h(e),0))};e.dom.addEventListener("pointerdown",c);let d=ut(t,"pointerup",u),p=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,f=()=>{let k=bs();t.style.left=`${Math.round(k.left)}px`,t.style.width=`${Math.round(k.right-k.left)}px`,t.style.top=`${Math.round(k.bottom-t.offsetHeight)}px`,t.dataset.side="docked"},h=k=>{if(!(k.hasFocus()||t.contains(te(t)))||!n.isEditable()||n.ui.activeDialog||a)return s();let M=n.ui.registry.getContextToolbars().find(([,y])=>y.predicate(n));if(!M)return s();let[L,O]=M,B=i(L,O);o!==L&&(t.replaceChildren(B.el),t.setAttribute("aria-label",O.label),o=L);for(let y of B.controls)y.update();let J=O.anchor?O.anchor(n):l(O);if(!J)return s();t.hidden=!1;let P=p&&O.position==="selection";if(t.classList.toggle("nova-context-toolbar-docked",P),P)return f();t.style.width="";let G=(typeof O.placement=="function"?O.placement(n):O.placement)??(O.position==="selection"?"bottom-start":"top-start");vt(t,J,G)};t.addEventListener("mousedown",k=>{k.target.closest("button")&&k.preventDefault()}),t.addEventListener("keydown",k=>{let x=[...t.querySelectorAll("button:not(:disabled)")],M=x.indexOf(te(t));if(k.key==="Escape")k.preventDefault(),n.focus();else if(M>=0&&(k.key==="ArrowRight"||k.key==="ArrowLeft")){k.preventDefault();let L=Ne(k,t)==="ArrowRight"?1:-1;x[(M+L+x.length)%x.length].focus()}});let m=k=>{let x=k.relatedTarget;!t.contains(x)&&!n.ui.overlayHost.contains(x)&&s()};e.dom.addEventListener("blur",m),t.addEventListener("focusout",k=>{let x=k.relatedTarget;!t.contains(x)&&!e.hasFocus()&&!n.ui.overlayHost.contains(x)&&s()});let g=()=>{t.hidden||h(e)};return window.addEventListener("scroll",g,!0),window.addEventListener("resize",g),e.dom.addEventListener("load",g,!0),window.visualViewport?.addEventListener("resize",g),window.visualViewport?.addEventListener("scroll",g),{update:h,destroy(){e.dom.removeEventListener("blur",m),e.dom.removeEventListener("pointerdown",c),d(),window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g),e.dom.removeEventListener("load",g,!0),window.visualViewport?.removeEventListener("resize",g),window.visualViewport?.removeEventListener("scroll",g),t.remove()}}}})}function ey(n){let e=n.ui.overlayHost.querySelector(".nova-context-toolbar:not([hidden]) button:not(:disabled)");return e?.focus(),!!e}var ty=24,ks=class{constructor(e,t,r,o){S(this,"view",t);S(this,"getPos",r);S(this,"editor",o);S(this,"dom");S(this,"img");S(this,"node");S(this,"resizing",!1);this.node=e,this.dom=document.createElement("span"),this.dom.className="nova-image",this.img=document.createElement("img"),this.img.draggable=!1,this.dom.append(this.img);for(let i of["nw","ne","sw","se"]){let s=document.createElement("span");s.className=`nova-image-handle nova-image-handle-${i}`,s.dataset.corner=i,s.addEventListener("pointerdown",l=>this.startResize(l,i)),this.dom.append(s)}this.render()}render(){let{src:e,alt:t,title:r,width:o,height:i,align:s}=this.node.attrs,l=fe(e)?e:"";this.img.getAttribute("src")!==l&&this.img.setAttribute("src",l),this.setAttr("alt",t),this.setAttr("title",r),this.setAttr("class",Xe(this.node.attrs.class).class??null);let a=ne(o),c=ne(i);this.img.style.width=a?`${a}px`:"",this.img.style.aspectRatio=a&&c?`${a} / ${c}`:"",this.dom.dataset.align=s??""}setAttr(e,t){t?this.img.setAttribute(e,t):this.img.removeAttribute(e)}update(e){return e.type!==this.node.type?!1:(this.node=e,this.resizing||this.render(),!0)}selectNode(){this.dom.classList.add("is-selected")}deselectNode(){this.dom.classList.remove("is-selected")}stopEvent(e){return e.target.classList?.contains("nova-image-handle")??!1}ignoreMutation(){return!0}startResize(e,t){if(!this.editor.isEditable())return;e.preventDefault(),e.stopPropagation();let r=e.currentTarget;r.setPointerCapture(e.pointerId);let o=this.img.getBoundingClientRect(),i=e.clientX,s=o.width,l=o.width>0?o.height/o.width:this.img.naturalHeight/(this.img.naturalWidth||1),a=Math.max(ty,this.view.dom.clientWidth-40),c=t==="ne"||t==="se"?1:-1,u=s;this.resizing=!0,this.dom.classList.add("is-resizing");let d=f=>{u=Math.round(Math.min(a,Math.max(ty,s+c*(f.clientX-i)))),this.img.style.width=`${u}px`,this.dom.dataset.size=`${u} \xD7 ${Math.round(u*l)}`},p=()=>{r.removeEventListener("pointermove",d),r.removeEventListener("pointerup",p),r.removeEventListener("pointercancel",p),this.resizing=!1,this.dom.classList.remove("is-resizing"),delete this.dom.dataset.size;let f=this.getPos();if(f===void 0||Math.abs(u-s)<1)return this.render();let h=this.view.state.tr.setNodeMarkup(f,void 0,{...this.node.attrs,width:u,height:Math.round(u*l)});h.setSelection(R.create(h.doc,f)),this.view.dispatch(h)};r.addEventListener("pointermove",d),r.addEventListener("pointerup",p),r.addEventListener("pointercancel",p)}};var ld={};q(ld,{FLAT_MARK_SELECTOR:()=>Nw,flatMarkViews:()=>sd});var Tw=["bold","italic","strike","code","subscript","superscript"],Nw="strong, em, s, code, sub, sup";function sd(n){let e={};for(let t of Tw){let r=n.marks[t]?.spec.toDOM;r&&(e[t]=(o,i,s)=>{let{dom:l,contentDOM:a}=qe.renderSpec(i.dom.ownerDocument,r(o,s));return l.setAttribute("role","none"),{dom:l,contentDOM:a??void 0}})}return e}var Ow=30;function Lw(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pw(n,e){let{selection:t}=n.state;if(!t.empty)return null;let r=t.$from;if(!r.parent.isTextblock||r.parent.type.spec.code)return null;let o=r.parent.textBetween(Math.max(0,r.parentOffset-Ow-1),r.parentOffset,"\0","\0");for(let[i,s]of e.ui.registry.getAutocompleters()){let l=new RegExp(`(?:^|\\s)${Lw(s.trigger)}([\\p{L}\\p{N}_-]*)$`,"u"),a=o.match(l);if(!a)continue;let c=a[1]??"";if(c.length<(s.minChars??0))continue;let u=r.parentOffset-c.length-s.trigger.length,d=u>0?r.parent.textBetween(u-1,u,"\0","\0"):"";if(!(d&&!/\s/.test(d)))return{name:i,spec:s,from:r.pos-c.length-s.trigger.length,to:r.pos,query:c}}return null}function ny(n){let e,t=[],r=0,o=null,i=null,s=0,l=je("nova-ac"),a=()=>!e.hidden,c=h=>{e.hidden=!0,o=null,t=[],h.dom.removeAttribute("aria-activedescendant"),h.dom.removeAttribute("aria-controls"),h.dom.removeAttribute("aria-expanded")},u=(h,m)=>{let g=t[m];if(!g||!o)return;let{spec:k,from:x,to:M}=o;c(h),k.onSelect(g,{from:x,to:M},n)},d=h=>{if(!o)return;let{spec:m}=o;if(e.replaceChildren(),e.setAttribute("aria-label",m.label),!t.length){if(!m.emptyText)return c(h);e.append(w("div",{className:"nova-ac-empty"},m.emptyText))}t.forEach((k,x)=>{let M=w("div",{id:`${l}-${x}`,className:"nova-menu-item nova-ac-item",role:"option","aria-selected":String(x===r)},k.icon?ee(k.icon):null,w("span",{className:"nova-menu-label"},k.label),k.shortcut?w("kbd",{className:"nova-menu-shortcut"},At(k.shortcut)):k.detail?w("span",{className:"nova-menu-shortcut"},k.detail):null);M.addEventListener("mousedown",L=>{L.preventDefault(),u(h,x)}),M.addEventListener("mousemove",()=>{r!==x&&p(h,x)}),e.append(M)}),e.hidden=!1,h.dom.setAttribute("aria-controls",l),p(h,Math.min(r,Math.max(0,t.length-1)));let g=h.coordsAtPos(o.from);vt(e,new DOMRect(g.left,g.top,1,g.bottom-g.top),"bottom-start")},p=(h,m)=>{r=m,e.querySelectorAll('[role="option"]').forEach((k,x)=>k.setAttribute("aria-selected",String(x===m)));let g=e.querySelector(`#${l}-${m}`);g&&(h.dom.setAttribute("aria-activedescendant",g.id),g.scrollIntoView?.({block:"nearest"}))},f=h=>{let m=n.isEditable()&&h.hasFocus()?Pw(h,n):null;if(!m||m.from===i){m||(i=null),(a()||o)&&c(h);return}let g=!o||o.query!==m.query||o.from!==m.from;if(o=m,!g&&a())return d(h);let k=++s;Promise.resolve(m.spec.fetch(m.query,n)).then(x=>{k!==s||!o||(t=x.slice(0,m.spec.maxResults??10),r=0,d(h))})};return new z({key:new X("nova-autocompleter"),view(h){e=w("div",{className:"nova-popover nova-ac",id:l,role:"listbox",hidden:!0}),n.ui.overlayHost.append(e),h.dom.setAttribute("aria-autocomplete","list");let m=()=>c(h);return h.dom.addEventListener("blur",m),{update:g=>f(g),destroy(){h.dom.removeEventListener("blur",m),e.remove()}}},props:{handleKeyDown(h,m){if(!a()||!o)return!1;let g=t.length;switch(m.key){case"ArrowDown":return g&&p(h,(r+1)%g),!0;case"ArrowUp":return g&&p(h,(r-1+g)%g),!0;case"Enter":case"Tab":return g?(u(h,r),!0):!1;case"Escape":return i=o.from,c(h),!0;default:return!1}}}})}var Bt=n=>e=>e.exec(n),Rw=[{name:"paragraph",label:"paragraph",icon:C.paragraph,keywords:["text","p","paragraph"],run:Bt("paragraph")},{name:"h1",label:"h1",icon:C.h1,keywords:["h1","heading","title"],shortcut:"Mod-Alt-1",run:Bt("h1")},{name:"h2",label:"h2",icon:C.h2,keywords:["h2","heading","subtitle"],shortcut:"Mod-Alt-2",run:Bt("h2")},{name:"h3",label:"h3",icon:C.h3,keywords:["h3","heading"],shortcut:"Mod-Alt-3",run:Bt("h3")},{name:"bullist",label:"bulletList",icon:C.bulletList,keywords:["ul","list","bullet"],shortcut:"Mod-Shift-8",run:Bt("bulletList")},{name:"numlist",label:"orderedList",icon:C.orderedList,keywords:["ol","list","numbered"],shortcut:"Mod-Shift-7",run:Bt("orderedList")},{name:"blockquote",label:"blockquote",icon:C.blockquote,keywords:["quote","blockquote","citation"],run:Bt("blockquote")},{name:"codeblock",label:"codeBlock",icon:C.codeBlock,keywords:["code","pre","snippet"],run:Bt("codeBlock")},{name:"hr",label:"horizontalRule",icon:C.horizontalRule,keywords:["hr","divider","line","separator"],run:Bt("horizontalRule")},{name:"table",label:"table",icon:C.table,keywords:["table","grid"],run:n=>n.exec(It(3,3))},{name:"image",label:"image",icon:C.image,keywords:["image","picture","photo","img"],run:n=>lo(n)},{name:"link",label:"link",icon:C.link,keywords:["link","url","href"],shortcut:"Mod-k",run:n=>_t(n)}];function Dw(n,e,t){let r=e.toLowerCase();if(!r)return n;let o=[];return n.forEach((i,s)=>{let l=t(i.label).toLowerCase(),a=[l,...l.split(/\s+/),...i.keywords],c=-1;l.startsWith(r)?c=3:a.some(u=>u.startsWith(r))?c=2:a.some(u=>u.includes(r))&&(c=1),c>0&&o.push([c,s,i])}),o.sort((i,s)=>s[0]-i[0]||i[1]-s[1]).map(([,,i])=>i)}function ry(n,e=[]){let{t}=n.ui,r=[...Rw,...e].filter(o=>n.isAllowed(o.name));n.ui.registry.addAutocompleter("slashcommands",{trigger:"/",label:t("slash.label"),emptyText:t("slash.empty"),fetch:o=>Dw(r,o,t).map(i=>({value:i.name,label:t(i.label),icon:i.icon,...i.shortcut?{shortcut:i.shortcut}:{}})),onSelect:(o,i,s)=>{let l=r.find(a=>a.name===o.value);l&&(s.view.dispatch(s.view.state.tr.delete(i.from,i.to)),l.run(s))}})}var vs=class{constructor(e,t){S(this,"region");S(this,"closeLabel");this.closeLabel=t,this.region=w("div",{className:"nova-notifications","aria-live":"polite"}),e.append(this.region)}open(e){let t=e.type??"info",r=e.timeout??(t==="error"?0:4e3),o=w("span",{className:"nova-notification-text"},e.text),i=w("button",{type:"button",className:"nova-btn","aria-label":this.closeLabel},ee(C.close)),s=(e.actions??[]).map(p=>w("button",{type:"button",className:"nova-btn nova-notification-action"},p.label)),l=w("div",{className:`nova-notification nova-notification-${t}`,role:t==="error"?"alert":"status"},o,...s,i);this.region.append(l);let a=null,c=!1,u=()=>{c||(c=!0,a&&clearTimeout(a),l.remove())},d=()=>{c||(u(),e.onClose?.())};return s.forEach((p,f)=>p.addEventListener("click",()=>{u(),e.actions[f].onAction()})),i.addEventListener("click",d),r>0&&(a=setTimeout(d,r)),s[0]?.focus({preventScroll:!0}),{close:u,setText:p=>o.textContent=p}}destroy(){this.region.remove()}};var _w=C.sidebar,xs=class{constructor(){S(this,"controls",new Map);S(this,"menuItems",new Map);S(this,"styleFormats",{items:[],replace:!1});S(this,"contextToolbars",new Map);S(this,"autocompleters",new Map);S(this,"sidebars",new Map);S(this,"views",new Map)}addButton(e,t){this.controls.set(e.toLowerCase(),{type:"button",...t})}addToggleButton(e,t){this.addButton(e,t)}addMenuButton(e,t){this.controls.set(e.toLowerCase(),{type:"menu",...t})}addPanelButton(e,t){this.controls.set(e.toLowerCase(),{type:"panel",...t})}addSplitButton(e,t){this.controls.set(e.toLowerCase(),{type:"split",...t})}addStyleFormats(e,{replace:t=!1}={}){this.styleFormats={items:[...this.styleFormats.items,...e],replace:this.styleFormats.replace||t}}getStyleFormats(){return this.styleFormats}addMenuItem(e,t){this.menuItems.set(e.toLowerCase(),t)}addToggleMenuItem(e,t){this.addMenuItem(e,t)}getMenuItem(e){let t=this.menuItems.get(e.toLowerCase());if(t)return t;let r=this.get(e);if(!(r?.type!=="button"&&r?.type!=="split"))return{text:r.tooltip,...r.icon?{icon:r.icon}:{},...r.shortcut?{shortcut:r.shortcut}:{},onAction:r.onAction,...r.isActive?{isActive:r.isActive}:{},...r.isEnabled?{isEnabled:r.isEnabled}:{}}}addSidebar(e,t){this.sidebars.set(e,t),!(t.button===!1||this.has(e))&&this.addToggleButton(e,{tooltip:t.tooltip??t.title,icon:t.icon??_w,isActive:r=>r.ui.sidebar.isOpen(e),onAction:r=>{r.ui.sidebar.toggle(e)}})}getSidebar(e){return this.sidebars.get(e)}addView(e,t){this.views.set(e,t)}getView(e){return this.views.get(e)}addAutocompleter(e,t){this.autocompleters.set(e.toLowerCase(),t)}getAutocompleters(){return[...this.autocompleters]}addContextToolbar(e,t){this.contextToolbars.set(e.toLowerCase(),t)}getContextToolbars(){return[...this.contextToolbars].sort((e,t)=>(t[1].priority??0)-(e[1].priority??0))}get(e){return this.controls.get(e.toLowerCase())}has(e){return this.controls.has(e.toLowerCase())}names(){return[...this.controls.keys()]}};var ws=class{constructor(e){S(this,"editor",e);S(this,"current",null);S(this,"mounted",new Map);S(this,"column",null);S(this,"opening",Promise.resolve());S(this,"destroyed",!1)}get active(){return this.current}isOpen(e){return this.current===e}async show(e,t={}){let r=this.editor.ui.registry.getSidebar(e);if(!r){console.warn(`[nova] sidebar "${e}" is not registered`);return}if(this.current!==e){this.hide({restoreFocus:!1}),this.editor.ui.closeOverlays(),this.current=e;let o=this.mount(e,r);this.opening=o.ready.then(i=>{if(!i||this.current!==e||this.destroyed){this.current===e&&(this.current=null);return}o.el.hidden=!1,this.editor.root.classList.add("nova-sidebar-open"),r.onShow?.(this.editor),this.editor.updateUI()})}if(await this.opening,t.focus&&this.current===e){let o=this.mounted.get(e).el;(o.querySelector($t)??o).focus()}}hide(e={}){let t=this.current;if(!t)return;this.current=null;let r=this.mounted.get(t);if(!r)return;let o=r.el.contains(te(r.el));r.el.hidden=!0,this.editor.root.classList.remove("nova-sidebar-open"),this.editor.ui.registry.getSidebar(t)?.onHide?.(this.editor),this.editor.updateUI(),o&&e.restoreFocus!==!1&&this.editor.focus()}toggle(e,t={}){return this.current===e?(this.hide(),Promise.resolve()):this.show(e,t)}destroy(){this.destroyed=!0,this.mounted.forEach(e=>e.cleanup?.()),this.mounted.clear()}host(){if(this.column)return this.column;let e=this.editor.view.dom.parentElement,t=w("div",{className:"nova-body"});return e.before(t),t.append(e),this.column=t,t}mount(e,t){let r=this.mounted.get(e);if(r)return r;let o=je("nova-sidebar-title"),i=w("div",{className:"nova-sidebar-body"}),s=w("button",{type:"button",className:"nova-btn nova-sidebar-close","aria-label":this.editor.ui.t("dialog.close"),onClick:()=>this.hide()},ee(C.close)),l=t.header===!1?null:w("div",{className:"nova-sidebar-head"},w("h2",{id:o,className:"nova-sidebar-title"},t.title),s),a=w("div",{className:`nova-sidebar${l?"":" nova-sidebar-bare"}`,hidden:!0,"data-sidebar":e,...this.editor.options.language?{lang:this.editor.options.language}:{},...l?{role:"complementary","aria-labelledby":o}:{},onKeydown:(u=>{u.key!=="Escape"||u.defaultPrevented||(u.preventDefault(),this.hide())})},l,i);this.host().append(a);let c={el:a,ready:Promise.resolve(!1)};return c.ready=(async()=>{try{let u=await t.render(i,this.editor);return typeof u=="function"&&(c.cleanup=u),!0}catch(u){return console.error(`[nova] sidebar "${e}" failed to render`,u),a.remove(),this.mounted.delete(e),!1}})(),this.mounted.set(e,c),c}};var oy=".nova-editor.nova-view-open>:not(.nova-view):not(.nova-overlays){display:none}.nova-view{display:flex;flex:1 1 auto;flex-direction:column;min-height:240px;background:var(--nova-surface);color:var(--nova-fg)}.nova-view[hidden]{display:none}.nova-view:focus{outline:none}.nova-view-head{display:flex;align-items:center;gap:8px;padding:8px 12px;border-bottom:1px solid var(--nova-border);background:var(--nova-toolbar-bg)}.nova-view-title{margin:0;font-size:15px;font-weight:600}.nova-view-buttons{display:flex;gap:8px;margin-inline-start:auto}.nova-view-body{flex:1;min-height:0;padding:12px;overflow:auto}";var Ss=class{constructor(e){S(this,"editor",e);S(this,"current",null);S(this,"mounted",new Map)}get active(){return this.current}isOpen(e){return this.current===e}show(e){let t=this.editor.ui.registry.getView(e);if(!t){console.warn(`[nova] view "${e}" is not registered`);return}if(this.current===e)return;this.hide({restoreFocus:!1}),this.editor.ui.closeOverlays(),this.editor.ui.addStyles("nova-editor-views",oy);let r=this.mount(e,t);this.current=e,r.el.hidden=!1,this.editor.root.classList.add("nova-view-open");try{t.onShow?.(r.api)}catch(o){console.error(`[nova] view "${e}" failed to show`,o)}(r.el.querySelector($t)??r.el).focus(),this.editor.updateUI()}hide(e={}){let t=this.current;if(!t)return;this.current=null;let r=this.mounted.get(t);if(!r)return;let o=r.el.contains(te(r.el));r.el.hidden=!0,this.editor.root.classList.remove("nova-view-open");try{this.editor.ui.registry.getView(t)?.onHide?.(r.api)}catch(i){console.error(`[nova] view "${t}" failed to hide`,i)}this.editor.updateUI(),o&&e.restoreFocus!==!1&&this.editor.focus()}toggle(e){this.current===e?this.hide():this.show(e)}destroy(){this.mounted.forEach(({el:e})=>e.remove()),this.mounted.clear(),this.current=null}mount(e,t){let r=this.mounted.get(e);if(r)return r;let o=w("div",{className:"nova-view-body"}),i=(t.buttons??[]).map(a=>w("button",{type:"button",className:a.buttonType==="primary"?"nova-button nova-button-primary":"nova-button",onClick:()=>{try{a.onAction(this.editor)}catch(c){console.error(`[nova] a button of view "${e}" failed`,c)}}},a.text)),s=w("section",{className:"nova-view",hidden:!0,tabindex:"-1","data-view":e,"aria-label":t.title??e,...this.editor.options.language?{lang:this.editor.options.language}:{},onKeydown:(a=>{a.key!=="Escape"||a.defaultPrevented||(a.preventDefault(),this.hide())})},w("div",{className:"nova-view-head"},t.title?w("h2",{className:"nova-view-title"},t.title):null,w("div",{className:"nova-view-buttons"},...i)),o);this.editor.root.append(s);let l={el:s,api:{getContainer:()=>o}};return this.mounted.set(e,l),l}};var Hw=450,Bw=150,Ms=class{constructor(e){S(this,"el");S(this,"timer",null);S(this,"target",null);S(this,"offEscape",null);this.el=w("div",{className:"nova-tooltip",role:"tooltip",hidden:!0}),this.el.addEventListener("pointerenter",()=>this.clearTimer()),this.el.addEventListener("pointerleave",()=>this.hide()),this.el.addEventListener("pointerdown",()=>this.hide()),e.append(this.el)}attach(e){e.addEventListener("pointerenter",t=>{t.pointerType==="mouse"&&this.schedule(e)}),e.addEventListener("pointerleave",()=>{this.clearTimer(),this.el.hidden||(this.timer=setTimeout(()=>this.hide(),Bw))}),e.addEventListener("focus",()=>{e.matches(":focus-visible")&&this.show(e)}),e.addEventListener("blur",()=>this.hide()),e.addEventListener("pointerdown",()=>this.hide())}schedule(e){this.clearTimer(),this.timer=setTimeout(()=>this.show(e),Hw)}show(e){this.clearTimer();let t=e.dataset.tooltip;if(!t||e.getAttribute("aria-expanded")==="true")return;this.target=e;let r=e.dataset.shortcut;this.el.replaceChildren(w("span",{},t)),r&&this.el.append(w("kbd",{},At(r))),this.el.hidden=!1,vt(this.el,e.getBoundingClientRect(),"bottom"),this.offEscape??(this.offEscape=ut(this.el,"keydown",o=>{o.key!=="Escape"||this.el.hidden||(o.preventDefault(),o.stopPropagation(),this.hide())}))}hide(){this.clearTimer(),this.el.hidden=!0,this.target=null,this.offEscape?.(),this.offEscape=null}get current(){return this.target}destroy(){this.hide(),this.el.remove()}clearTimer(){this.timer&&clearTimeout(this.timer),this.timer=null}};var iy=new WeakMap,Es=class{constructor(e,t,r,o){S(this,"focusEditor",r);S(this,"registry",new xs);S(this,"t");S(this,"overlayHost");S(this,"tooltip");S(this,"sidebar");S(this,"view");S(this,"notifications");S(this,"popover",null);S(this,"currentDialog",null);S(this,"liveRegion");S(this,"announceTimer");S(this,"rootEl");S(this,"dialogListeners",new Set);this.t=t,this.rootEl=e,this.overlayHost=w("div",{className:"nova-overlays"}),e.append(this.overlayHost),this.tooltip=new Ms(this.overlayHost),this.notifications=new vs(e,t("dialog.close")),this.sidebar=new ws(o),this.view=new Ss(o),this.liveRegion=w("div",{className:"nova-visually-hidden nova-announcer",role:"status","aria-live":"polite","aria-atomic":"true"}),e.append(this.liveRegion)}announce(e){let t=this.liveRegion;t.textContent="",clearTimeout(this.announceTimer),this.announceTimer=setTimeout(()=>{t.textContent=e},50)}addStyles(e,t){let r=this.rootEl.getRootNode(),o=iy.get(r);if(o||iy.set(r,o=new Set),o.has(e))return;if(o.add(e),"adoptedStyleSheets"in r&&typeof CSSStyleSheet<"u")try{let s=new CSSStyleSheet;s.replaceSync(t),r.adoptedStyleSheets=[...r.adoptedStyleSheets,s];return}catch{}let i=document.createElement("style");i.dataset.novaStyles=e,i.textContent=t,(r.head??r).append(i)}async dialog(e){let{openFormDialog:t,formDialogCss:r}=await import(__novaChunk("tinymce-chunks/form-dialog-9eb62199.js") );return this.addStyles("nova-form-dialog",r),t(e,this.t,o=>this.openDialog(o))}openPopover(e){this.closePopover(),this.tooltip.hide();let t=new Nn({...e,host:this.overlayHost,onClose:r=>{this.popover===t&&(this.popover=null),e.onClose?.(r)}});return this.popover=t,t}closePopover(){this.popover?.close("api"),this.popover=null}get activePopover(){return this.popover}onDialogOpen(e){return this.dialogListeners.add(e),()=>this.dialogListeners.delete(e)}closeOverlays(){this.closePopover(),this.dialogListeners.forEach(e=>e())}openDialog(e){this.closePopover(),this.dialogListeners.forEach(r=>r()),this.currentDialog?.close();let t=Gc({cancelLabel:this.t("dialog.cancel"),closeLabel:this.t("dialog.close"),...e,host:this.overlayHost,returnFocus:this.focusEditor,onClose:()=>{this.currentDialog===t&&(this.currentDialog=null),e.onClose?.()}});return this.currentDialog=t,t}get activeDialog(){return this.currentDialog}notify(e){return this.notifications.open(typeof e=="string"?{text:e}:e)}destroy(){this.sidebar.destroy(),this.view.destroy(),this.closePopover(),this.currentDialog?.close(),this.tooltip.destroy(),this.notifications.destroy(),this.overlayHost.remove(),clearTimeout(this.announceTimer),this.liveRegion.remove()}};var Fw={paragraph:()=>"p",heading:n=>`h${n.attrs.level}`,blockquote:()=>"blockquote",code_block:()=>"pre",bullet_list:()=>"ul",ordered_list:()=>"ol",list_item:()=>"li",table:()=>"table",table_row:()=>"tr",table_cell:()=>"td",table_header:()=>"th"},zw={bold:"strong",italic:"em",underline:"u",strike:"s",code:"code",link:"a",subscript:"sub",superscript:"sup"},ly=String.raw`\p{sc=Han}\p{sc=Hiragana}\p{sc=Katakana}`,sy=String.raw`(?:(?![${ly}])[\p{L}\p{N}])`,$w=new RegExp(`[${ly}]|${sy}+(?:['\u2019-]${sy}+)*`,"gu");function Vw(n){return n.match($w)?.length??0}function ay(n,e){e.className="nova-statusbar";let t=w("div",{className:"nova-path","aria-hidden":"true"}),r=w("div",{className:"nova-wordcount","aria-live":"off"});e.append(t,r);let o=n.options.resize,i=o?Ww(n,e,o==="both"):null,s=null,l=()=>{let c=n.view.state.doc;r.textContent=n.ui.t("status.words",{count:Vw(c.textBetween(0,c.content.size," "," "))})},a=c=>{let{$from:u}=n.view.state.selection,d=[];for(let f=1;f<=u.depth;f++){let h=u.node(f),m=Fw[h.type.name]?.(h);m&&d.push(m)}n.view.state.selection.node?.type.name==="image"&&d.push("img");for(let f of u.marks()){let h=zw[f.type.name];h&&d.push(h)}t.replaceChildren(...d.flatMap((f,h)=>[...h?[" \u203A "]:[],w("span",{className:"nova-path-item"},f)])),c&&(s&&clearTimeout(s),s=setTimeout(l,250))};return l(),a(!1),{update:a,destroy:()=>{s&&clearTimeout(s),i?.(),e.replaceChildren()}}}var ad=100,qw=200,Cs=20,jw=4e3;function Ww(n,e,t){let r=n.root,o=w("div",{className:"nova-resize-handle",role:"separator",tabIndex:0,"aria-orientation":"horizontal","aria-label":n.ui.t("status.resize"),"aria-valuemin":String(ad)});o.append(ee(t?C.resizeHandleBoth:C.resizeHandle)),r.dataset.resize=t?"both":"vertical",e.append(o);let i=()=>{let p=Math.max(ad,r.offsetHeight);o.setAttribute("aria-valuenow",String(p)),o.setAttribute("aria-valuemax",String(Math.max(jw,p)))};i(),o.addEventListener("focus",i);let s=(p,f)=>{if(r.style.boxSizing="border-box",r.style.height=`${Math.max(ad,Math.round(p))}px`,t&&f!==void 0){let h=r.parentElement?.clientWidth||1/0;r.style.width=`${Math.min(h,Math.max(qw,Math.round(f)))}px`}i()},l=null,a=p=>{n.isDisabled()||(p.preventDefault(),o.setPointerCapture(p.pointerId),l={x:p.clientX,y:p.clientY,height:r.offsetHeight,width:r.offsetWidth})},c=p=>{if(!l)return;let f=(p.clientX-l.x)*(Fn(r)?-1:1);s(l.height+p.clientY-l.y,l.width+f)},u=p=>{l&&(l=null,o.hasPointerCapture(p.pointerId)&&o.releasePointerCapture(p.pointerId))},d=p=>{let f=p.key==="ArrowDown"?Cs:p.key==="ArrowUp"?-Cs:0,h=Ne(p,r),m=t?h==="ArrowRight"?Cs:h==="ArrowLeft"?-Cs:0:0;!m&&!f||(p.preventDefault(),s(r.offsetHeight+f,r.offsetWidth+m))};return o.addEventListener("pointerdown",a),o.addEventListener("pointermove",c),o.addEventListener("pointerup",u),o.addEventListener("pointercancel",u),o.addEventListener("keydown",d),()=>{o.remove(),delete r.dataset.resize}}var ud="nova:remote",As="nova:api",Kw=new Set("P H1 H2 H3 H4 H5 H6 UL OL TABLE BLOCKQUOTE PRE HR DIV FIGURE".split(" "));function cy(n){return(e,t)=>{if(!t)return!0;let r=document.createElement("template");r.innerHTML=n;let o=document.createElement("div");o.append(r.content);let i=gr(e.schema),l=[...o.children].some(p=>Kw.has(p.tagName))?new D(i.parse(o).content,0,0):i.parseSlice(o),a=!1;l.content.descendants(p=>(p.type.spec.tableRole==="table"&&(a=!0),!a));let{$from:c}=e.selection,u=0;for(let p=1;p<=c.depth;p++)if(c.node(p).type.spec.tableRole==="table"){u=p;break}let d=a&&u?e.tr.insert(c.after(u),l.content):e.tr.replaceSelection(l);return t(d.setMeta(As,!0).scrollIntoView()),!0}}var Uw=0,uy=new Set,vo=class{constructor(e){S(this,"view");S(this,"root");S(this,"ui");S(this,"options");S(this,"listeners",new Map);S(this,"ready");S(this,"toolbar");S(this,"toolbarHost");S(this,"menubar");S(this,"mode");S(this,"direction");S(this,"pluginsByName",new Map);S(this,"commandOverrides",new Map);S(this,"transactionTransforms",[]);S(this,"cleanups",[]);S(this,"contentRules");S(this,"schema");S(this,"formatter");S(this,"selection");S(this,"statusbar");S(this,"searchBar",null);S(this,"searchBarLoad",null);S(this,"contentHost");S(this,"destroyed",!1);S(this,"editable");S(this,"disabled");S(this,"pasteAsText");e=sg(e),this.options=e,this.root=document.createElement("div"),this.root.className="nova-editor";let t=e.direction??(us(e.language)?"rtl":void 0);t&&(this.root.dir=t),this.direction=t??(e.element.closest("[dir]")?.getAttribute("dir")==="rtl"?"rtl":"ltr"),e.element.appendChild(this.root);let r=document.createElement("div"),o=document.createElement("div"),i=document.createElement("div");o.className="nova-content";let s=document.createElement("div");s.className="nova-header";let l=document.createElement("div");s.append(l,r),this.root.append(s,o,i),this.toolbarHost=r;let a=Number(e.toolbarStickyOffset);Number.isFinite(a)&&a>0&&this.root.style.setProperty("--nova-sticky-offset",`${Math.min(a,1e3)}px`),this.mode=e.mode??"classic",this.root.classList.add(`nova-mode-${this.mode}`);let c=this.mode==="distraction-free";if(this.mode!=="classic"&&(this.root.addEventListener("focusin",()=>this.root.classList.add("is-focused")),this.root.addEventListener("focusout",()=>{setTimeout(()=>{this.root.contains(te(this.root))||this.root.classList.remove("is-focused")},0)})),this.ui=new Es(this.root,Rp(e.language,e.translations),()=>this.focus(),this),e.language)for(let N of[s,i,this.ui.overlayHost])N.lang=e.language;this.root.style.setProperty("--nova-caption-placeholder",JSON.stringify(this.ui.t("image.captionPlaceholder")));let u=Ke({"Mod-k":()=>(_t(this),!0),"Alt-F9":()=>this.menubar?(this.menubar.focus(),!0):!1,"Alt-F10":()=>this.toolbar?(this.toolbar.focus(),!0):!1,"Ctrl-F9":()=>ey(this),"Mod-f":()=>(this.openSearch(),!0),"Mod-Shift-f":()=>(yr(this),!0),"Alt-0":()=>(go(this),!0),Escape:()=>this.searchBar?.isOpen()?(this.searchBar.close(),!0):!1}),d=[...e.plugins??[]];c&&!d.includes("quickbars")&&d.push("quickbars");let p=vr(d);p.errors.forEach(N=>xt(N));let{ordered:f,errors:h}=Ln(p.plugins);h.forEach(N=>xt(N));for(let N of f)N.load&&p.loaders.push(N.load);let m=f.flatMap(N=>this.collectPmPlugins(N)),g=e.validElements!==void 0||e.invalidElements!==void 0||e.validStyles!==void 0;this.contentRules=g?new fr(e):null;let{schema:k,allowedClasses:x}=ds(e,f,this.direction,this);this.schema=k,this.formatter=new Ji(this,x),this.selection=qg(this);for(let[N,$]of Object.entries(e.formats??{}))this.formatter.register(N,$);f.forEach(N=>this.registerCommands(N));let M=kr(f,this);M&&Tn.set(this,M);let L=cd(this.schema,e.content??"",M),O=Wu(),B=bm(s,o),J=[ny(this),...e.textPatterns===!1?[]:Array.isArray(e.textPatterns)||e.textPatternsLookup?[bg(this,Array.isArray(e.textPatterns)?e.textPatterns:[],e.textPatternsLookup)]:[fg(N=>this.isAllowed(N),this.schema),hg(N=>this.isAllowed(N),this.schema)],u,O,...kg(N=>this.resolveCommand(N)),tg(this.ui.t,N=>this.ui.announce(N)),...f.some(N=>N.replaceHistory)?[]:[Lc()],Wm({color:"var(--nova-accent)",width:2}),Um(),nu(this),tu(this),Sg(this),td(this),Qg(this),...this.contentRules?[Ag(this.contentRules)]:[],Qm(),Vg(),B.plugin,...m,...e.prosemirrorPlugins??[]];Ru(J);let P=un.create({doc:this.contentRules?this.contentRules.normalizeDoc(L):L,plugins:J});this.editable=e.editable??!0,this.disabled=e.disabled??!1,this.pasteAsText=e.pasteAsText??!1;let G=this.handleTransaction.bind(this),y=Fe(e.contentLanguage);this.view=new Zn(o,{state:P,editable:()=>this.isEditable(),...B.props,attributes:{class:"nova-prosemirror",role:"textbox","aria-multiline":"true","aria-label":this.ui.t("editor.label"),...y?{lang:y}:{},...e.placeholder?{"data-placeholder":e.placeholder,"aria-placeholder":e.placeholder}:{}},dispatchTransaction:function(N){G(N,this)},clipboardParser:gr(this.schema),nodeViews:{image:(N,$,K)=>new ks(N,$,K,this)},markViews:sd(this.schema),handleDOMEvents:{focus:(N,$)=>(this.emit("focus",{event:$}),!1),blur:(N,$)=>(this.emit("blur",{event:$}),!1)},handleKeyDown:(N,$)=>(this.emit("keydown",{event:$}),$.defaultPrevented)}),this.root.classList.toggle("nova-readonly",!this.editable),this.applyDisabled(),Xu(this),Fg(this),e.slashCommands!==!1&&ry(this,e.slashCommands??[]),f.forEach(N=>this.setupPlugin(N)),e.setup?.(this);let v=e.menubar===!0?Hg:typeof e.menubar=="string"?e.menubar:null;this.menubar=v?Bg(this,l,v,{...Ig,...e.menu}):null,this.menubar||l.remove(),this.toolbar=e.toolbar===!1||c&&e.toolbar===void 0?null:id(this,r,this.toolbarConfig(),e.toolbarMode??"floating",{warnUnknown:p.loaders.length===0}),this.toolbar||r.remove(),!this.toolbar&&!this.menubar&&s.remove(),this.contentHost=o;let b=this.loadSearchBar(),E=e.statusbar??this.mode==="classic";this.statusbar=E?ay(this,i):null,this.statusbar||i.remove(),e.onChange&&this.on("change",e.onChange),this.updatePlaceholder();let _=this.applyContentStyles();this.ready=Promise.all([p.loaders.length?this.loadLazyPlugins(p.loaders):void 0,_,bu(),this.installTables(O),b]).then(()=>{this.destroyed||this.emit("init")})}async installTables(e){let t=await ku();if(!t||this.destroyed)return;let{state:r}=this.view,o=r.plugins.indexOf(e),i=[...r.plugins];i.splice(o<0?i.length:o,0,...t.tablePlugins()),Du(this.view,i),this.updateUI()}applyContentStyles(){let{contentStyle:e,contentCss:t}=this.options,r=t===void 0?[]:Array.isArray(t)?t:[t];if(!e&&!r.length)return;let o=`nova-cs-${++Uw}`;this.root.classList.add(o);let i=`.nova-editor.${o} .nova-prosemirror`,s=r.map(()=>""),l=null,a=()=>{this.destroyed||(l?.(),l=jc(this.root,Qi([...s,e??""].join(`
44
+ `),i)))};if(this.cleanups.push(()=>l?.()),a(),!!r.length)return Promise.all(r.map((c,u)=>es(c).then(d=>{s[u]=d},d=>console.warn(`[nova] contentCss: could not load ${c}`,d)))).then(a)}isAllowed(e){return this.contentRules?.isAllowed(e)??!0}hasPlugin(e){return this.pluginsByName.has(e)}collectPmPlugins(e){try{let t=e.prosemirrorPlugins?.(this)??[];if(e.nodeViews){let r=Object.fromEntries(Object.entries(e.nodeViews).map(([o,i])=>[o,i(this)]));t.push(new z({props:{nodeViews:r}}))}return t}catch(t){return xt(`Plugin "${e.name}" failed to create ProseMirror plugins`,t),[]}}setupPlugin(e){try{let t=e.setup?.(this);typeof t=="function"&&this.cleanups.push(t),this.pluginsByName.set(e.name,e)}catch(t){xt(`Plugin "${e.name}" failed during setup`,t)}}async loadLazyPlugins(e){let t=await Promise.all(e.map(l=>Bs(l).catch(a=>(xt("Failed to load plugin",a),null))));if(this.destroyed)return;let r=t.filter(l=>l?l.nodes||l.marks?(xt(`Plugin "${l.name}" defines nodes or marks and cannot be loaded lazily; pass the plugin object instead`),!1):!0:!1),{ordered:o,errors:i}=Ln(r,new Set(this.pluginsByName.keys()));i.forEach(l=>xt(l));let s=o.flatMap(l=>this.collectPmPlugins(l));s.length&&Du(this.view,[...this.view.state.plugins,...s]),o.forEach(l=>{this.registerCommands(l),this.setupPlugin(l)}),this.rebuildToolbar()}updateUI(){this.destroyed||this.toolbar?.update()}rebuildToolbar(){!this.toolbar||this.destroyed||(this.toolbar.destroy(),this.toolbar=id(this,this.toolbarHost,this.toolbarConfig(),this.options.toolbarMode??"floating"))}toolbarConfig(){if(this.options.toolbar)return this.options.toolbar;let e=[...this.pluginsByName.values()].map(t=>t.toolbar).filter(Boolean);return e.length?`${rd} | ${e.join(" ")}`:rd}handleTransaction(e,t=this.view){if(!t.isDestroyed){for(let r of this.transactionTransforms)e=r(e,t.state,this);t.updateState(t.state.apply(e)),this.view&&(this.toolbar?.update(),this.statusbar?.update(e.docChanged),this.searchBar?.update(),this.updatePlaceholder(),e.docChanged&&(this.emit("change",{transaction:e}),!(e.getMeta(As)||e.getMeta(ud))&&e.getMeta("addToHistory")!==!1&&this.emit("input",{transaction:e})),(e.selectionSet||e.docChanged)&&this.emit("selectionChange",{transaction:e}))}}updatePlaceholder(){let e=this.view.state.doc,t=e.childCount===1&&e.firstChild?.type===this.schema.nodes.paragraph&&e.firstChild.content.size===0;this.view.dom.classList.toggle("nova-empty",t)}getHTML({fullPage:e=!0}={}){let t=this.view.state.doc,r=mr.serializeFragment(t.content),o=e?Tn.get(this):void 0;return o?o.write(r,t.attrs):r}getJSON(){return this.view.state.doc.toJSON()}getText(){return this.view.state.doc.textBetween(0,this.view.state.doc.content.size,`
45
45
 
46
- `)}setContent(e,{addToHistory:t=!0,fullPage:r=!0}={}){let o={content:e};this.emit("beforeSetContent",o);let i=r?An.get(this):void 0,s=eu(this.schema,o.content,i),l=this.view.state.tr.replaceWith(0,this.view.state.doc.content.size,s.content);if(i&&(typeof o.content!="string"||Qg.has(s)))for(let[a,c]of Object.entries(s.attrs))c!==this.view.state.doc.attrs[a]&&l.setDocAttribute(a,c);l.setMeta(xs,!0).setMeta(ui,!0),t||l.setMeta("addToHistory",!1),this.view.dispatch(l),this.emit("setContent",{content:o.content})}insertContent(e){return this.isEditable()?Xg(e)(this.view.state,this.view.dispatch):!1}isEmpty(){return this.view.dom.classList.contains("nova-empty")}resolveCommand(e){e=lo("commands",e);let t=this.commandOverrides.get(e)??(Object.prototype.hasOwnProperty.call(Ke,e)?Ke[e]:void 0);return t||(Zg.has(e)||(Zg.add(e),console.warn(`[nova] unknown command "${String(e)}": editor.exec() returns false`)),()=>!1)}registerCommands(e){for(let[t,r]of Object.entries(e.commands??{}))r&&this.commandOverrides.set(t,r);e.transformTransaction&&this.transactionTransforms.push(e.transformTransaction)}exec(e){let r=(typeof e=="string"?this.resolveCommand(e):e)(this.view.state,this.view.dispatch,this.view);return r&&this.view.focus(),r}chain(){return Ng({view:()=>this.destroyed?null:this.view,resolve:e=>this.resolveCommand(e),insertContent:e=>(t,r,o)=>this.isEditable()&&Xg(e)(t,r,o)})}can(e){let t=typeof e=="string"?this.resolveCommand(e):e;try{return t(this.view.state,void 0,this.view)}catch{return!1}}isActive(e){return lr(this.view.state,lo("commands",e))}getCommandState(e){return{active:this.isActive(e),enabled:this.isEditable()&&this.can(e)}}focus(){this.destroyed||this.view.focus()}isPasteAsText(){return this.pasteAsText}setPasteAsText(e){this.pasteAsText=e,this.toolbar?.update()}loadSearchBar(){return this.searchBarLoad??(this.searchBarLoad=import(__novaChunk("tinymce-chunks/search-bar-3ea04183.js") ).then(({createSearchBar:e})=>this.destroyed?null:(this.searchBar=e(this,this.contentHost),this.searchBar),e=>(vt("The find and replace bar failed to load",e),null))),this.searchBarLoad}openSearch(){return this.loadSearchBar().then(e=>e?.open())}closeSearch(){this.searchBar?.close()}isEditable(){return this.editable&&!this.disabled}isDisabled(){return this.disabled}setDisabled(e){this.disabled!==e&&(this.disabled=e,this.view.setProps({}),this.applyDisabled(),e&&(this.ui.closePopover(),this.view.dom.blur()),this.toolbar?.update(),this.emit("editableChange"))}applyDisabled(){this.root.classList.toggle("nova-disabled",this.disabled),this.disabled?this.root.setAttribute("aria-disabled","true"):this.root.removeAttribute("aria-disabled"),this.disabled?this.view.dom.setAttribute("tabindex","-1"):this.view.dom.removeAttribute("tabindex")}setEditable(e){this.editable!==e&&(this.editable=e,this.view.setProps({}),this.root.classList.toggle("nova-readonly",!e),e||this.ui.closePopover(),this.toolbar?.update(),this.emit("editableChange"))}on(e,t){e=lo("events",e);let r=this.listeners.get(e);return r||this.listeners.set(e,r=new Set),r.add(t),()=>this.off(e,t)}off(e,t){e=lo("events",e),this.listeners.get(e)?.delete(t)}emit(e,...[t]){for(let r of this.listeners.get(e)??[])try{r(this,t)}catch(o){vt(`Listener for "${e}" failed`,o)}}destroy(){if(!this.destroyed){this.emit("destroy"),this.destroyed=!0,this.menubar?.destroy(),this.ui.destroy(),this.toolbar?.destroy(),this.statusbar?.destroy();for(let e of this.cleanups.splice(0))try{e()}catch(t){vt("Plugin cleanup failed",t)}this.searchBar?.destroy(),this.root.classList.contains("nova-fullscreen")&&mr(this,!1),this.view.destroy(),this.root.remove(),this.listeners.clear()}}};function vt(n,e){console.error(`[nova] ${n}`,...e===void 0?[]:[e])}var Qg=new WeakSet;function eu(n,e,t){if(typeof e!="string")return Te.fromJSON(n,co(n,e));let r=t?t.read(e):null,o=document.createElement("div"),i=document.createElement("template");i.innerHTML=r?r.content:e,o.appendChild(i.content);let s=hr(n).parse(o);if(!r)return s;let l=s.type.create(r.attrs,s.content);return Qg.add(l),l}function ws(n){return new bo(n)}var ou={};j(ou,{prettyHTML:()=>Ss});var ey=new Set(["address","article","aside","blockquote","caption","col","colgroup","dd","details","div","dl","dt","figcaption","figure","footer","h1","h2","h3","h4","h5","h6","header","hr","li","main","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul"]),Pw=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Rw=/<!--[\s\S]*?-->|<\/?[a-zA-Z][^>]*>|[^<]+|</g;function ru(n){let e=/^<(\/?)([a-zA-Z][\w-]*)/.exec(n);return e?{name:e[2].toLowerCase(),closing:e[1]==="/"}:null}function Ss(n,e=" "){let t=n.match(Rw)??[],r="",o=0,i=[],s=()=>(r?`
47
- `:"")+e.repeat(o);for(let l=0;l<t.length;l++){let a=t[l],c=ru(a);if(c&&!c.closing&&c.name==="pre"){let f=l,h=0;for(;f<t.length;f++){let m=ru(t[f]);if(m?.name==="pre"&&(h+=m.closing?-1:1),h===0)break}r+=s()+t.slice(l,f+1).join(""),l=f;continue}if(!c||!ey.has(c.name)){r+=a;continue}if(c.closing){i.pop()?.spread&&(o=Math.max(0,o-1),r+=s()),r+=a;continue}let d=i[i.length-1];if((!d||d.spread)&&(r+=s()),r+=a,Pw.has(c.name)||a.endsWith("/>"))continue;let u=ru(t[l+1]??""),p=!!u&&!u.closing&&ey.has(u.name);i.push({name:c.name,spread:p}),p&&o++}return r}var ty=new Set("script,style,iframe,frame,frameset,object,embed,applet,base,link,meta,title,head,html,body,template,slot,noscript,form,input,button,select,option,optgroup,textarea,fieldset,legend,datalist,output,progress,meter,svg,math,canvas,audio,video,source,track,picture,map,area,portal,dialog,param,xmp,plaintext,listing,noembed,noframes,image".split(",")),Dw=/^(on|xmlns)|^(srcdoc|formaction|action|contenteditable|autofocus|is|slot|nonce)$/,_w=/^[a-z_:][a-z0-9_.:-]*$/,ny=/^[a-z][a-z0-9._-]*$/,gr=new Set("p,h1,h2,h3,h4,h5,h6,blockquote,pre,hr,ul,ol,li,img,figure,figcaption,br,table,tr,td,th,strong,em,u,s,code,a,sub,sup".split(",")),ko=new Set(["span","i","b","del","strike","mark"]),Iw=new Set("abbr,acronym,bdi,bdo,big,cite,data,dfn,ins,kbd,q,samp,small,time,tt,var,label,ruby,rt,rp,wbr".split(",")),ay=new Set("div,section,article,aside,header,footer,nav,main,address,details,summary,dl,dt,dd,center,hgroup,search".split(",")),Hw=new Set([...ay,..."p,h1,h2,h3,h4,h5,h6,blockquote,pre,hr,ul,ol,li,table,figure".split(",")]),Bw={a:["href"],ul:["data-type"],li:["data-type","data-checked"],img:["src"],td:["colspan","rowspan"],th:["colspan","rowspan"]};function ry(n){let e=[],t=0,r="";for(let o of n)o==="["?t++:o==="]"&&(t=Math.max(0,t-1)),o===","&&!t?(e.push(r),r=""):r+=o;return e.push(r),e.map(o=>o.trim()).filter(Boolean)}function Fw(n){let e=n.trim(),t=e.startsWith("!");t&&(e=e.slice(1));let r=/^([^=:<]+)(?:([=:<])(.*))?$/s.exec(e);if(!r)return null;let o=r[1].trim().toLowerCase();if(!o)return null;let i={name:o,required:t},s=r[3]??"";return r[2]==="="?i.def=s:r[2]===":"?i.forced=s:r[2]==="<"&&(i.values=s.split("?")),i}function iu(n,e){return n==="*"?!0:n.endsWith("*")?e.startsWith(n.slice(0,-1)):n===e}var oy=new Set;function su(n,e){oy.has(n)||(oy.add(n),console.warn(`[nova] <${n}> in content rules is ignored: ${e}`))}var lu=class{constructor(e){S(this,"elements",new Map);S(this,"globals",[]);S(this,"blockTags",new Map);S(this,"inlineTags",new Map);let t=new Set((e.invalidElements??"").split(",").map(s=>s.trim().toLowerCase()).filter(Boolean)),r=new Set,o=new Set;for(let s of(e.customElements??"").split(",")){let l=s.trim().toLowerCase(),a=l.replace(/^~/,"");if(ny.test(a)){if(ty.has(a)||gr.has(a)){su(a,"it cannot be a custom element");continue}o.add(a),l.startsWith("~")&&r.add(a)}}let i=(s,l)=>{let[a,...c]=s;if(a){if(a==="@"||a==="*"){this.globals.push(...l??[]);return}for(let d of s){if(!ny.test(d)||t.has(d))continue;if(ty.has(d)){su(d,"not allowed for security reasons (iframes and video: use the media plugin)");continue}this.elements.set(d,l);let u=gr.has(d)||ko.has(d)?d:a;if(gr.has(d))continue;if(ko.has(d)){d===a&&l?.length&&this.inlineTags.set(d,d);continue}let p=o.has(d)||o.has(a)||d.includes("-");Iw.has(a)||r.has(a)?this.inlineTags.set(d,u):ay.has(a)||p?this.blockTags.set(d,u):(!c.includes(d)||d===a)&&su(d,"unknown element")}}};for(let s of ry(e.validElements??"")){let{names:l,attrs:a}=iy(s);a?i(l,a):l.every(c=>gr.has(c)||ko.has(c))||i(l,null)}for(let s of ry(e.extendedValidElements??"")){let{names:l,attrs:a}=iy(s);i(l,a)}for(let s of o)t.has(s)||(this.elements.has(s)||this.elements.set(s,[{name:"*",required:!1}]),r.has(s)?this.inlineTags.set(s,s):this.inlineTags.has(s)||this.blockTags.set(s,s))}apply(e,t){return jw(e.nodes,e.marks,this,t)}get active(){return this.elements.size>0||this.globals.length>0}touches(e){return this.globals.length>0||this.elements.has(e)}rulesFor(e){return[...this.elements.get(e)??[],...this.globals]}allows(e,t){return Dw.test(t)||!_w.test(t)?!1:this.rulesFor(e).some(r=>iu(r.name,t))}extends(e){return this.rulesFor(e).some(t=>t.name!=="class"&&t.name!=="style")}get classOnBuiltIn(){if(this.globals.some(e=>iu(e.name,"class")))return!0;for(let[e,t]of this.elements)if(gr.has(e)&&t?.some(r=>iu(r.name,"class")))return!0;return!1}hasRequired(e,t){return this.rulesFor(e).every(r=>!r.required||t.hasAttribute(r.name))}readAttrs(e,t,r){let o=null;for(let i of Array.from(t.attributes)){let s=i.name.toLowerCase();if(s===ns&&(s="style"),r.includes(s)||!this.allows(e,s))continue;let l=Yr(s,i.value);l!==null&&((o??(o={}))[s]=l)}return o}outputAttrs(e,t,r){let o={...t};if(r&&typeof r=="object"&&!Array.isArray(r))for(let[s,l]of Object.entries(r)){let a=s.toLowerCase();if(o[a]!=null||!this.allows(e,a)||!["string","number","boolean"].includes(typeof l))continue;let c=Yr(a,String(l));c!==null&&(o[a]=c)}if(this.elements.get(e))for(let s of Object.keys(o))this.allows(e,s)||Bw[e]?.includes(s)||s.startsWith("data-nova-")||delete o[s];for(let s of this.rulesFor(e)){if(s.name.includes("*"))continue;s.forced!==void 0?o[s.name]=s.forced:s.def!==void 0&&o[s.name]==null&&(o[s.name]=s.def);let l=o[s.name];s.values&&l!=null&&!s.values.includes(String(l))&&delete o[s.name]}return e==="a"&&o.target!=null&&o.rel==null&&(o.rel="noopener noreferrer"),o}decorate(e,t){if(!Array.isArray(e)||typeof e[0]!="string")return e;let r=e[0],o=(r.includes(" ")?r.split(" ")[1]:r).toLowerCase();if(!this.touches(o))return e;let i=e[1],s=!!i&&typeof i=="object"&&!Array.isArray(i)&&i.nodeType===void 0,l=this.outputAttrs(o,s?i:{},t);return[r,l,...e.slice(s?2:1)]}};function iy(n){let e=/^([^[]*)(?:\[(.*)\])?$/s.exec(n.trim()),t=(e?.[1]??"").trim().replace(/^[-#+!]+/,"").split("/").map(i=>i.trim().toLowerCase()).filter(Boolean),r=e?.[2],o=r===void 0?null:r.split("|").map(Fw).filter(i=>i!==null);return{names:t,attrs:o}}function zw(n){if(!n.validElements&&!n.extendedValidElements&&!n.customElements)return null;let e=new lu(n);return e.active?e:null}var sy=n=>(/^[a-z][a-z0-9-]*/i.exec(n)?.[0]??"").toLowerCase();function $w(n,e,t,r,o){try{let i=n.schema,s=e==="node"?o(i.nodes[t].create(r)):o(i.marks[t].create(r),!0),l=Array.isArray(s)?s[1]:null;return l&&typeof l=="object"&&!Array.isArray(l)?Object.keys(l):[]}catch{return[]}}function Vw(n,e,t,r,o){let i=(e.parseDOM??[]).map(a=>a.tag?sy(a.tag):"").filter(a=>gr.has(a)&&r.touches(a));if(!i.length||!e.toDOM)return e;let s=i.some(a=>r.extends(a)),l=e.toDOM;return{...e,...s?{attrs:{...e.attrs,htmlAttrs:{default:null}}}:{},parseDOM:e.parseDOM.map(a=>{let c=a.tag?sy(a.tag):"";if(!i.includes(c))return a;let d=a.getAttrs;return{...a,getAttrs:u=>{let p=d?d(u):a.attrs??null;if(p===!1||!r.hasRequired(c,u))return!1;if(!s)return p;let f=r.readAttrs(c,u,["class","style"]);if(!f)return p;for(let h of $w(o,t,n,{...p},l))delete f[h];return Object.keys(f).length?{...p,htmlAttrs:f}:p}}}),toDOM:((a,c)=>r.decorate(l(a,c),a.attrs.htmlAttrs))}}function ly(n,e){return Array.from(n.children).some(t=>{let r=t.localName;return Hw.has(r)||e.blockTags.has(r)})}function qw(n){let e={},t={},r=(a,c,d)=>{if(!n.hasRequired(a,c))return!1;let u=ko.has(a),p=u?d&&a==="span"?["class","style"]:["style"]:[],f=n.readAttrs(a,c,p);return u&&!f?!1:{tag:a,htmlAttrs:f}},o=a=>[...a].filter(([,c])=>!ko.has(c)).map(([c])=>c),i=(a,c,d)=>{let u=typeof d.tag=="string"&&a.has(d.tag)?d.tag:c;return{tag:u,attrs:n.outputAttrs(u,{},d.htmlAttrs)}},s=[...n.blockTags];if(s.length){let a=new Set(n.blockTags.values()),c=a.has("div")?"div":[...a][0],d={tag:{default:c},htmlAttrs:{default:null}};e.html_block={ownStyleTags:o(n.blockTags),group:"block",content:"block+",defining:!0,attrs:d,parseDOM:s.map(([u,p])=>({tag:u,getAttrs:f=>ly(f,n)?r(p,f,!1):!1})),toDOM:u=>{let{tag:p,attrs:f}=i(a,c,u.attrs);return[p,f,0]}},e.html_textblock={group:"block",content:"inline*",attrs:d,parseDOM:s.map(([u,p])=>({tag:u,getAttrs:f=>ly(f,n)?!1:r(p,f,!1)})),toDOM:u=>{let{tag:p,attrs:f}=i(a,c,u.attrs);return[p,f,0]}}}let l=[...n.inlineTags];if(l.length){let a=new Set(n.inlineTags.values()),c=a.has("span")?"span":[...a][0],d={tag:{default:c},htmlAttrs:{default:null}};e.html_inline_atom={ownStyleTags:o(n.inlineTags),group:"inline",inline:!0,atom:!0,attrs:d,parseDOM:l.map(([u,p])=>({tag:u,priority:65,getAttrs:f=>f.firstChild?!1:r(p,f,!1)})),toDOM:u=>{let{tag:p,attrs:f}=i(a,c,u.attrs);return[p,f]}},t.html_inline={attrs:d,excludes:"",parseDOM:l.map(([u,p])=>({tag:u,priority:p==="span"?40:60,getAttrs:f=>f.firstChild?r(p,f,!0):!1})),toDOM:u=>{let{tag:p,attrs:f}=i(a,c,u.attrs);return[p,f,0]}}}return{nodes:e,marks:t}}function jw(n,e,t,r){let o=(s,l)=>Object.fromEntries(Object.entries(s).map(([a,c])=>[a,Vw(a,c,l,t,r)])),i=qw(t);return{nodes:{...o(n,"node"),...i.nodes},marks:{...o(e,"mark"),...i.marks}}}var cy={create:zw};var dy=new Set(["lists","link","image","table","code","preview","searchreplace","fullscreen","help","wordcount","paste","hr","print","textcolor","colorpicker","contextmenu","tabfocus","textpattern","imagetools","powerpaste"]),uy={tinycomments:"comments",tinymcespellchecker:"spellchecker",inlinecss:"email"},Ww=new Set(["selector","target","license_key","api_key","branding","promotion","skin","skin_url","content_css","icons","icons_url","theme","theme_url","base_url","suffix","referrer_policy","convert_urls","relative_urls","remove_script_host","document_base_url","entity_encoding","height","min_height","max_height","width","resize","content_style","setup","init_instance_callback","inline","plugins","toolbar","menubar","statusbar","placeholder","readonly","disabled","block_formats","file_picker_callback","formats","style_formats","style_formats_merge","valid_classes","table_class_list","table_cell_class_list","file_picker_types","language","images_upload_handler","paste_as_text","paste_preprocess","paste_postprocess","invalid_elements","valid_elements","directionality","extended_valid_elements","custom_elements","valid_styles","toolbar_mode","toolbar_sticky","font_family_formats","font_size_formats","line_height_formats","color_map","autosave_interval","autosave_retention","autosave_prefix","quickbars_selection_toolbar","quickbars_insert_toolbar","mentions_fetch","tinycomments_author","tinycomments_author_name","codesample_languages","details_initial_state","details_serialized_state","tableofcontents_class","tableofcontents_depth","tableofcontents_header","tableofcontents_orderedlist","tableofcontents_includeheader","codesample_global_prismjs","casechange_title_case_minors","permanentpen_properties","visualchars_default_state","save_enablewhendirty","save_onsavecallback","save_oncancelcallback","importcss_append","importcss_file_filter","importcss_selector_filter","importcss_groups","importcss_exclusive","importcss_selector_converter","templates","spellchecker_active","spellchecker_language","spellchecker_languages","spellchecker_ignore_list","spellchecker_dialog","content_language","spellchecker_languagetool_url","spellchecker_check","a11ychecker_level","a11ychecker_ignored_rules","a11ychecker_allow_decorative_images","a11y_advanced_options","a11ychecker_alt_text_max_length","a11ychecker_filter_issue","a11ychecker_html_version","a11ychecker_issue_url_callback","ai_request","ai_shortcuts","inlinecss_selector_filter","inlinecss_file_filter","linkchecker_service_url","linkchecker_preprocess","linkchecker_content_css","tiny_pageembed_classes","tiny_pageembed_inline_styles","fullpagehtml_default_doctype","fullpagehtml_default_title","fullpagehtml_default_encoding","fullpagehtml_default_body_style","fullpagehtml_hide_in_source_view","mediaembed_service_url","mediaembed_max_width","mediaembed_inline_styles","advtable_value_series","advcode_prettify_editor","advcode_prettify_getcontent","advcode_inline","view_show","sidebar_show","editimage_toolbar","editimage_credentials_hosts","editimage_fetch_image","editimage_cors_hosts","editimage_proxy","editimage_proxy_service_url","editimage_upload_timeout","autocorrect_autocorrect","autocorrect_capitalize","autocorrect_service_url","typography_default_lang","typography_langs","typography_rules","typography_ignore","text_patterns","text_patterns_lookup","template_replace_values","template_preview_replace_values","template_selected_content_classes","template_cdate_classes","template_mdate_classes","template_cdate_format","template_mdate_format"]),Nn=n=>(Array.isArray(n)?n.join(" "):String(n??"")).split(/[\s,]+/).filter(Boolean);function py(n,e){return Nn(n.plugins).filter(t=>dy.has(t)||e(uy[t]??t))}function Kw(n){return/\/dash\//.test(n)?"dashes":/^common\/punctuation\/(quote|apostrophe)$/.test(n)?"quotes":n==="common/punctuation/hellip"?"ellipsis":n==="common/punctuation/delDoublePunctuation"||n.startsWith("common/space/")?"spaces":n==="common/symbols/arrow"?"arrows":n.startsWith("common/symbols/")?"symbols":n==="common/number/fraction"?"fractions":n.startsWith("common/number/")?"math":n.startsWith("common/nbsp/")?"nbsp":null}var Uw={code:["code","code_block"],pre:["code_block"],a:["link"],strong:["bold"],b:["bold"],em:["italic"],i:["italic"],blockquote:["blockquote"]};function Jw(n){let e={},t=n.typography_default_lang,r=Array.isArray(t)?t[0]:t;typeof r=="string"&&r&&(e.language=r.replace(/_/g,"-"));let o=n.typography_langs,s=(Array.isArray(o)?o:o&&typeof o=="object"?Object.keys(o):[]).filter(l=>typeof l=="string").map(l=>l.replace(/_/g,"-"));if(s.length&&(e.languages=s),Array.isArray(n.typography_rules)){let l=new Set(n.typography_rules.map(a=>typeof a=="string"?Kw(a):null));e.rules=Object.fromEntries(["quotes","dashes","ellipsis","symbols","arrows","math","fractions","spaces","nbsp"].map(a=>[a,l.has(a)]))}if(Array.isArray(n.typography_ignore)){let l=n.typography_ignore.flatMap(a=>typeof a=="string"?Uw[a.toLowerCase().replace(/\[.*$/,"")]??[]:[]);l.length&&(e.ignore=[...new Set(l)])}return e}function Ms(n){if(typeof n=="string")return n.split(";").map(e=>e.trim()).filter(Boolean).map(e=>{let[t,r]=e.includes("=")?e.split("="):[e,e];return{label:t.trim(),value:(r??t).trim()}})}function Gw(n){let e="",t=new Promise(o=>{let i=new FileReader;i.onload=()=>{e=String(i.result).replace(/^data:[^,]*,/,""),o()},i.onerror=()=>o(),i.readAsDataURL(n)}),r="";return{ready:t,info:{id:()=>n.name.replace(/\.[^.]+$/,"")||"image",name:()=>n.name.replace(/\.[^.]+$/,"")||"image",filename:()=>n.name||"image",blob:()=>n,base64:()=>e,blobUri:()=>r||(r=URL.createObjectURL(n)),uri:()=>{}}}}var Yw=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre"]),Xw=new Set(["span","strong","b","em","i","u","s","strike","del","code","sub","sup"]);function Es(n){let e=Array.isArray(n)?n:[n],t=[];for(let r of e){if(!r||typeof r!="object")continue;let o=r,i={};typeof o.block=="string"&&Yw.has(o.block.toLowerCase())&&(i.block=o.block.toLowerCase()),typeof o.inline=="string"&&Xw.has(o.inline.toLowerCase())&&(i.inline=o.inline.toLowerCase()),typeof o.selector=="string"&&(i.selector=o.selector),(typeof o.classes=="string"||Array.isArray(o.classes))&&(i.classes=o.classes),o.styles&&typeof o.styles=="object"&&(i.styles=Object.fromEntries(Object.entries(o.styles).filter(([,s])=>typeof s=="string"&&!s.includes("%")).map(([s,l])=>[s.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`),l]))),(i.block||i.inline||i.selector)&&t.push(i)}return t}function fy(n){return Array.isArray(n)?n.flatMap(e=>{if(!e||typeof e!="object")return[];let t=e,r=String(t.title??"");if(!r)return[];if(Array.isArray(t.items))return[{title:r,items:fy(t.items)}];if(typeof t.format=="string")return[{title:r,format:t.format}];let[o]=Es(t);return o?[{title:r,...o}]:[]}):[]}function hy(n){return n.flatMap(e=>{if(!e||typeof e!="object")return[];let t=e,r=typeof t.title=="string"?t.title:"";return r?Array.isArray(t.subprompts)?[{title:r,items:hy(t.subprompts)}]:typeof t.prompt!="string"?[]:[{title:r,prompt:t.prompt,...typeof t.selection=="boolean"?{selection:t.selection}:{}}]:[]})}function my(n){let e=Object.keys(n).filter(b=>!Ww.has(b)),t=[],r=[];for(let b of Nn(n.plugins)){let A=uy[b]??b;dy.has(b)||(Mo(A)?t.push(A):r.push(b))}t.includes("ai")&&!t.includes("suggestions")&&t.splice(t.indexOf("ai"),0,"suggestions"),t.includes("mediaembed")&&!t.includes("media")&&t.splice(t.indexOf("mediaembed"),0,"media");let o={plugins:t};n.toolbar===!1?o.toolbar=!1:Array.isArray(n.toolbar)?o.toolbar=n.toolbar.join(" | "):typeof n.toolbar=="string"&&(o.toolbar=n.toolbar),n.menubar!==void 0&&(o.menubar=n.menubar),n.text_patterns===!1&&(o.textPatterns=!1),typeof n.statusbar=="boolean"&&(o.statusbar=n.statusbar),typeof n.placeholder=="string"&&(o.placeholder=n.placeholder),n.readonly===!0&&(o.editable=!1),typeof n.content_style=="string"&&(o.contentStyle=n.content_style);let i=b=>Array.isArray(b)?b.filter(A=>!!A&&typeof A.title=="string"&&typeof A.value=="string").map(({title:A,value:H})=>({title:A,value:H})):void 0,s=i(n.table_class_list);s&&(o.tableClassList=s);let l=i(n.table_cell_class_list);if(l&&(o.tableCellClassList=l),n.formats&&typeof n.formats=="object"&&(o.formats=Object.fromEntries(Object.entries(n.formats).map(([b,A])=>[b,Es(A)]).filter(([,b])=>b.length))),Array.isArray(n.style_formats)&&(o.styleFormats=fy(n.style_formats),n.style_formats_merge===!0&&(o.styleFormatsMerge=!0)),typeof n.valid_classes=="string"?o.validClasses=Nn(n.valid_classes):n.valid_classes&&typeof n.valid_classes=="object"?o.validClasses=Object.values(n.valid_classes).flatMap(b=>Nn(b)):o.validClasses=!0,n.content_css!==void 0&&n.content_css!==!1){let b=new Set(["default","dark","document","writer","tinymce-5","tinymce-5-dark"]),A=(Array.isArray(n.content_css)?n.content_css:String(n.content_css).split(",")).map(H=>String(H).trim()).filter(H=>H&&!b.has(H));A.length&&(o.contentCss=A)}n.disabled===!0&&(o.disabled=!0),n.resize!==!1&&(o.resize=n.resize==="both"?"both":!0);let a=Ms(n.block_formats);if(a){let b=["p","h1","h2","h3","h4","h5","h6","pre"];o.blockFormats=a.map(({label:A,value:H})=>({label:A,block:H.toLowerCase()})).filter(A=>b.includes(A.block))}if(typeof n.language=="string"&&(o.language=n.language.replace("_","-")),(n.toolbar_mode==="floating"||n.toolbar_mode==="sliding"||n.toolbar_mode==="scrolling"||n.toolbar_mode==="wrap")&&(o.toolbarMode=n.toolbar_mode),n.inline===!0&&(o.mode="inline"),n.paste_as_text===!0&&(o.pasteAsText=!0),typeof n.paste_preprocess=="function"){let b=n.paste_preprocess;o.pastePreprocess=(A,H)=>{let $={content:A};return b(H,$),$.content}}typeof n.invalid_elements=="string"&&(o.invalidElements=n.invalid_elements),typeof n.valid_elements=="string"&&(o.validElements=n.valid_elements),typeof n.extended_valid_elements=="string"&&(o.extendedValidElements=n.extended_valid_elements),typeof n.custom_elements=="string"&&(o.customElements=n.custom_elements),(n.directionality==="rtl"||n.directionality==="ltr")&&(o.direction=n.directionality),n.valid_styles&&(o.validStyles=n.valid_styles);let c=Ms(n.font_family_formats);c&&(o.fontFamilies=c);let d=Ms(n.font_size_formats);d&&(o.fontSizes=d.map(b=>b.value));let u=Ms(n.line_height_formats);if(u&&(o.lineHeights=u.map(b=>b.value)),Array.isArray(n.color_map)&&(o.colors=n.color_map.filter((b,A)=>A%2===0).map(b=>b.startsWith("#")?b:`#${b}`)),typeof n.images_upload_handler=="function"){let b=n.images_upload_handler,A=async(H,$)=>{let{ready:G,info:U}=Gw(H);return await G,b(U,$)};o.uploadImage=A}if(typeof n.file_picker_callback=="function"){let b=n.file_picker_callback;typeof n.file_picker_types=="string"&&(o.filePickerTypes=Nn(n.file_picker_types).filter(A=>A==="file"||A==="image"||A==="media")),o.filePicker=({type:A,value:H})=>new Promise($=>b((G,U={})=>$({url:G,...U}),H,{filetype:A,fieldname:"src"}))}let p={};if(n.autosave_interval||n.autosave_retention||n.autosave_prefix){let b=A=>parseInt(String(A),10);p.autosave={...n.autosave_interval?{delay:b(n.autosave_interval)*1e3}:{},...n.autosave_retention?{retention:b(n.autosave_retention)}:{},...n.autosave_prefix?{key:String(n.autosave_prefix)}:{}}}if((n.quickbars_selection_toolbar!==void 0||n.quickbars_insert_toolbar!==void 0)&&(p.quickbars={...n.quickbars_selection_toolbar!==void 0?{selection:n.quickbars_selection_toolbar}:{},...n.quickbars_insert_toolbar!==void 0?{insert:n.quickbars_insert_toolbar}:{}}),typeof n.mentions_fetch=="function"){let b=n.mentions_fetch;p.mentions={fetch:A=>new Promise(H=>b({term:A},H))}}if(n.tinycomments_author&&(p.comments={author:{id:String(n.tinycomments_author),name:String(n.tinycomments_author_name??n.tinycomments_author)}}),Array.isArray(n.codesample_languages)){let b=n.codesample_languages.flatMap(A=>{let{text:H,value:$}=A??{};return typeof $=="string"&&$?[{value:$,label:typeof H=="string"&&H?H:$}]:[]});p.codesample={languages:b}}let f=b=>b==="inherited"||b==="collapsed"||b==="expanded"?b:void 0;(n.details_initial_state||n.details_serialized_state)&&(p.accordion={...f(n.details_initial_state)?{initialState:f(n.details_initial_state)}:{},...f(n.details_serialized_state)?{serializedState:f(n.details_serialized_state)}:{}}),Nn(n.plugins).includes("tableofcontents")&&(p.tableofcontents={className:typeof n.tableofcontents_class=="string"?n.tableofcontents_class:"mce-toc",titleTag:typeof n.tableofcontents_header=="string"?n.tableofcontents_header:"h2",...n.tableofcontents_depth!==void 0?{depth:Number(n.tableofcontents_depth)}:{},...n.tableofcontents_orderedlist?{orderedList:!0}:{},...n.tableofcontents_includeheader===!1?{title:""}:{}}),Array.isArray(n.casechange_title_case_minors)&&(p.casechange={titleCaseMinors:n.casechange_title_case_minors.map(String)}),n.permanentpen_properties&&typeof n.permanentpen_properties=="object"&&(p.permanentpen={properties:{...n.permanentpen_properties}}),n.visualchars_default_state===!0&&(p.visualchars={default:!0});let h=Object.fromEntries([["append",n.importcss_append],["fileFilter",n.importcss_file_filter],["selectorFilter",n.importcss_selector_filter],["groups",n.importcss_groups],["exclusive",n.importcss_exclusive],["converter",n.importcss_selector_converter]].filter(([,b])=>b!==void 0));Object.keys(h).length&&(p.importcss=h);let m=n.templates,g=Object.fromEntries([["templates",typeof m=="function"?()=>new Promise(b=>m(b)):m],["values",n.template_replace_values],["previewValues",n.template_preview_replace_values],["selectedContentClasses",n.template_selected_content_classes],["creationDateClasses",n.template_cdate_classes],["modifiedDateClasses",n.template_mdate_classes],["creationDateFormat",n.template_cdate_format],["modifiedDateFormat",n.template_mdate_format]].filter(([,b])=>b!==void 0));Object.keys(g).length&&(p.template=g);let y={};typeof n.spellchecker_active=="boolean"&&(y.active=n.spellchecker_active);let x=n.content_language??n.spellchecker_language;typeof x=="string"&&x&&(y.language=x.replace(/_/g,"-")),typeof n.spellchecker_languages=="string"&&(y.languages=n.spellchecker_languages.split(",").map(b=>b.split("=")).filter(b=>b.length===2&&!!b[0].trim()&&!!b[1].trim()).map(([b,A])=>({name:b.trim(),code:A.trim().replace(/_/g,"-")})));let M=n.spellchecker_ignore_list,L=Array.isArray(M)?M:M&&typeof M=="object"?Object.values(M).flatMap(b=>Array.isArray(b)?b:[]):[];if(L.length&&(y.ignore=L.filter(b=>typeof b=="string")),typeof n.spellchecker_check=="function"&&(y.check=n.spellchecker_check),typeof n.spellchecker_languagetool_url=="string"&&(y.languageTool={url:n.spellchecker_languagetool_url}),Object.keys(y).length&&(p.spellchecker=y),Nn(n.plugins).includes("a11ychecker")){let b={allowDecorativeImages:(n.a11ychecker_allow_decorative_images??n.a11y_advanced_options)===!0};typeof n.a11ychecker_level=="string"&&(b.level=n.a11ychecker_level.toLowerCase()),typeof n.a11ychecker_ignored_rules=="string"&&(b.ignoredRules=n.a11ychecker_ignored_rules.split(",").map(H=>H.trim()).filter(Boolean)),typeof n.a11ychecker_alt_text_max_length=="number"&&(b.altTextMaxLength=n.a11ychecker_alt_text_max_length);let A=n.a11ychecker_filter_issue;typeof A=="function"&&(b.filterIssue=H=>A({...H,id:H.rule,contentID:H.text})!==!1),p.a11ychecker=b}let O=n.ai_shortcuts;O===!1||Array.isArray(O)&&!O.length?p.ai={shortcuts:!1}:Array.isArray(O)&&(p.ai={shortcuts:hy(O)});let B={};(["string","function"].includes(typeof n.inlinecss_selector_filter)||n.inlinecss_selector_filter instanceof RegExp)&&(B.selectorFilter=n.inlinecss_selector_filter),(["string","function"].includes(typeof n.inlinecss_file_filter)||n.inlinecss_file_filter instanceof RegExp)&&(B.fileFilter=n.inlinecss_file_filter),Object.keys(B).length&&(p.email=B);let J={};typeof n.autocorrect_autocorrect=="boolean"&&(J.autocorrect=n.autocorrect_autocorrect),typeof n.autocorrect_capitalize=="boolean"&&(J.capitalize=n.autocorrect_capitalize),Object.keys(J).length&&(p.autocorrect=J);let P={};typeof n.linkchecker_service_url=="string"&&(P.serviceUrl=n.linkchecker_service_url);let v=n.linkchecker_preprocess;if(typeof v=="function"&&(P.preprocess=b=>{let A=v({url:b});return typeof A?.url=="string"?A.url:b}),Object.keys(P).length&&(p.linkchecker=P),t.includes("pageembed")){let b=n.tiny_pageembed_classes;p.pageembed={className:"tiny-pageembed",sizes:Array.isArray(b)?b.filter(A=>!!A&&typeof A.value=="string").map(A=>({value:A.value,...typeof A.text=="string"?{text:A.text}:{}})):["21by9","16by9","4by3","1by1"].map(A=>({value:`tiny-pageembed--${A}`})),inlineStyles:n.tiny_pageembed_inline_styles===!0}}if(t.includes("fullpagehtml")){let b={},A=(H,$)=>{typeof n[H]=="string"&&(b[$]=n[H])};A("fullpagehtml_default_doctype","doctype"),A("fullpagehtml_default_title","title"),A("fullpagehtml_default_encoding","encoding"),A("fullpagehtml_default_body_style","bodyStyle"),n.fullpagehtml_hide_in_source_view===!0&&(b.hideInSourceView=!0),Object.keys(b).length&&(p.fullpagehtml=b)}if(t.includes("mediaembed")){let b={className:"ephox-summary-card",inlineStyles:n.mediaembed_inline_styles===!0};typeof n.mediaembed_service_url=="string"&&n.mediaembed_service_url&&(b.serviceUrl=n.mediaembed_service_url);let A=Number(n.mediaembed_max_width);n.mediaembed_max_width!==void 0&&Number.isFinite(A)&&(b.maxWidth=A),p.mediaembed=b}let k=n.advtable_value_series;if(t.includes("advtable")&&k&&typeof k=="object"){let b={};for(let[A,H]of Object.entries(k)){let{title:$,generator:G}=H??{};if(typeof $!="string"||typeof G!="function")continue;let U;b[A]={title:$,value:se=>{se===0&&(U=void 0);let rt=G({sectionType:"tbody",cellType:"td",getRowType:()=>"body",classes:[],direction:"column",prev:U},se,0);U=rt;let $e=rt?.value;return typeof $e=="string"||typeof $e=="number"?String($e):void 0}}}Object.keys(b).length&&(p.advtable={series:b})}if(t.includes("editimage")){let b={};typeof n.editimage_toolbar=="string"&&(b.toolbar=n.editimage_toolbar),Array.isArray(n.editimage_credentials_hosts)&&(b.credentialsHosts=n.editimage_credentials_hosts.filter(H=>typeof H=="string"));let A=n.editimage_fetch_image;typeof A=="function"&&(b.fetchImage=H=>{let $=document.createElement("img");return $.src=H,A($)}),Object.keys(b).length&&(p.editimage=b)}t.includes("advcode")&&typeof n.advcode_prettify_editor=="boolean"&&(p.advcode={prettify:n.advcode_prettify_editor});let E=Jw(n);return Object.keys(E).length&&(p.typography=E),Object.keys(p).length&&(o.pluginOptions=p),{options:o,unknown:e,missingPlugins:r}}var uu=null,au=null;function by(){return au??(au=import(__novaChunk("tinymce-chunks/dialog-126a0355.js") ).then(n=>uu=n)),au}function Zw(n,e,t){if(uu)return uu.openSpecDialog(n,e,t);let r=null,o={...e.initialData??{}},i=[];by().then(l=>{r=l.openSpecDialog(n,{...e,initialData:o},t);for(let a of i.splice(0))a(r)},l=>console.error("[nova] windowManager: could not load dialogs",l));let s=l=>(...a)=>{let c=d=>d[l](...a);r?c(r):i.push(c)};return{getData:()=>r?r.getData():{...o},setData:l=>{r?r.setData(l):o={...o,...l}},close:s("close"),block:s("block"),unblock:s("unblock"),focus:s("focus"),disable:s("disable"),enable:s("enable"),showTab:s("showTab"),redial:s("redial")}}var Cs={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike",superscript:"superscript",subscript:"subscript",justifyleft:"alignLeft",justifycenter:"alignCenter",justifyright:"alignRight",justifyfull:"alignJustify",insertunorderedlist:"bulletList",insertorderedlist:"orderedList",indent:"indent",outdent:"outdent",undo:"undo",redo:"redo",removeformat:"clearFormatting",unlink:"unlink",inserthorizontalrule:"horizontalRule",mceblockquote:"blockquote"},vo={mcelowercase:"lowercase",mceuppercase:"uppercase",mcetitlecase:"titlecase",mcetoggleformatpainter:"formatpainter",mcetogglepermanentpen:"permanentpen",mceconfigurepermanentpen:"configurepermanentpen",mcevisualchars:"visualchars",mcesave:"save",mcecancel:"cancel",mcetemplate:"template",mceinsertfootnote:"footnotes",mceupdatefootnotes:"footnotesupdate",mcespellcheckdialog:"spellcheckdialog",mcetypography:"typography",mcecodeeditor:"code",mceimagerotateleft:"rotateleft",mceimagerotateright:"rotateright",mceimageflipvertical:"flipv",mceimagefliphorizontal:"fliph",mceeditimage:"editimage",mcefullpagehtmlproperties:"fullpagehtml"},gy=new Set(["mcespellcheckenable","mcespellcheckdisable","mcespellcheckupdate","mcespellcheckdialogclose"]),yy={mceadvancedtablesort:()=>({command:"dialog"}),mcesorttablebycolumnasc:()=>({command:"sort",value:{by:"column",direction:"asc"}}),mcesorttablebycolumndesc:()=>({command:"sort",value:{by:"column",direction:"desc"}}),mcesorttablebyrowasc:()=>({command:"sort",value:{by:"row",direction:"asc"}}),mcesorttablebyrowdesc:()=>({command:"sort",value:{by:"row",direction:"desc"}}),mcesorttableadvanced:n=>{let e=n&&typeof n=="object"?n:{},t=Number(e.roworcol);return{command:"sort",value:{by:e.sortby==="row"?"row":"column",...Number.isInteger(t)&&t>=0?{index:t}:{},direction:e.order==="descending"?"desc":"asc",scope:e.sort==="selection"?"selection":"table"}}},mcetabletoggleseries:n=>({command:"series",value:n?.name})},Qw=new Set(["insertaccordion","removeaccordion","toggleaccordion","toggleallaccordions"]),eS={p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",blockquote:"blockquote",pre:"codeBlock"},tS={bold:"bold",italic:"italic",underline:"underline","strike-through":"strike",link:"link",unlink:"unlink",image:"image",table:"table",undo:"undo",redo:"redo","align-left":"alignLeft","align-center":"alignCenter","align-right":"alignRight","align-justify":"alignJustify","unordered-list":"bulletList","ordered-list":"orderedList",indent:"indent",outdent:"outdent",quote:"blockquote","code-sample":"codeBlock","horizontal-rule":"horizontalRule","remove-formatting":"clearFormatting",fullscreen:"fullscreen",preview:"preview",sourcecode:"sourceCode",help:"help",print:"print",search:"search",copy:"copy","edit-block":"edit",checkmark:"check",close:"close",upload:"upload",subscript:"subscript",superscript:"superscript","paste-text":"pasteText","text-color":"textColor","highlight-bg-color":"highlight","line-height":"lineHeight"},cu={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike",superscript:"superscript",subscript:"subscript",code:"code",p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",blockquote:"blockquote",pre:"codeBlock",alignleft:"alignLeft",aligncenter:"alignCenter",alignright:"alignRight",alignjustify:"alignJustify"},nS=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre"]),rS=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre","alignleft","aligncenter","alignright","alignjustify"]),du={forecolor:"color",hilitecolor:"background",fontname:"font_family",fontsize:"font_size"};function xo(n){console.warn(`[nova] tinymce-compat: editor.dom.${n} changes the editor DOM directly, which NovaProse redraws from its document model. Use setContent, insertContent or editor.formatter instead.`)}var Ts=new Map;function As(n){if(typeof n!="string"||!n)return;if(Ts.has(n))return Ts.get(n);let e=tS[n]??(n in C?n:void 0);return e?C[e]:void 0}function oS(n){let e=!1,t=!0;return{state:{get active(){return e},get enabled(){return t}},api:{isActive:()=>e,setActive:r=>{e=r,n.core.updateUI()},isEnabled:()=>t,setEnabled:r=>{t=r,n.core.updateUI()},isDisabled:()=>!t,setDisabled:r=>{t=!r,n.core.updateUI()}}}}var wo=class{constructor(e,t,r,o){S(this,"id");S(this,"core");S(this,"targetElm");S(this,"settings");S(this,"plugins",{});S(this,"initialized",!1);S(this,"removed",!1);S(this,"handlers",new Map);S(this,"dirty",!1);S(this,"teardowns",[]);S(this,"commands",new Map);S(this,"options",{get:e=>this.settings[e],set:(e,t)=>(this.settings[e]=t,e==="disabled"&&this.core.setDisabled(t===!0),!0),isSet:e=>e in this.settings,isRegistered:()=>!0,register:()=>{}});S(this,"mode",{get:()=>this.core.isEditable()?"design":"readonly",set:e=>this.core.setEditable(e!=="readonly"),isReadOnly:()=>!this.core.isEditable()});S(this,"undoManager",{undo:()=>this.core.exec("undo"),redo:()=>this.core.exec("redo"),hasUndo:()=>this.core.can("undo"),hasRedo:()=>this.core.can("redo"),add:()=>null,clear:()=>{},transact:e=>(e(),null),ignore:e=>e()});S(this,"selection",{getContent:(e={})=>e.format==="text"?this.core.selection.getText():this.core.selection.getHTML(),setContent:e=>this.insertContent(e),getNode:()=>this.core.selection.getNode()??this.core.view.dom,getStart:()=>this.selection.getNode(),getEnd:()=>this.selection.getNode(),isCollapsed:()=>this.core.selection.isCollapsed(),collapse:(e=!1)=>this.core.selection.collapse(e),setCursorLocation:(e,t=0)=>{e&&this.core.selection.setCursorLocation(e,t)},select:(e,t=!1)=>this.core.selection.select(e,t),getRng:()=>this.core.selection.getDOMRange(),setRng:e=>{let{view:t}=this.core;if(!e||!t.dom.contains(e.startContainer))return;let r=t.posAtDOM(e.startContainer,e.startOffset),o=t.dom.contains(e.endContainer)?t.posAtDOM(e.endContainer,e.endOffset):r;this.core.selection.setRange(r,o)},getBookmark:()=>this.core.selection.getBookmark(),moveToBookmark:e=>this.core.selection.moveToBookmark(e),scrollIntoView:()=>this.core.selection.scrollIntoView()});S(this,"notificationManager",{open:e=>this.core.ui.notify({text:e.text,...e.type?{type:e.type}:{},...e.timeout!==void 0?{timeout:e.timeout}:{}}),close:()=>{}});S(this,"windowManager",{alert:(e,t)=>{let r=document.createElement("p");r.textContent=e,this.core.ui.openDialog({title:"",body:r,onSubmit:()=>!0,...t?{onClose:t}:{}})},confirm:(e,t)=>{let r=document.createElement("p");r.textContent=e;let o=!1;this.core.ui.openDialog({title:"",body:r,submitLabel:"OK",onSubmit:()=>(o=!0,!0),onClose:()=>t?.(o)})},open:e=>Zw(this.core,e,t=>this.windowManager.open(t))});S(this,"ui",{registry:{addIcon:(e,t)=>{Ts.set(e,t)},addButton:(e,t)=>this.addButton(e,t,!1),addToggleButton:(e,t)=>this.addButton(e,t,!0),addMenuButton:(e,t)=>{let r=[];t.fetch(i=>r=i);let o=As(t.icon);this.core.ui.registry.addMenuButton(e,{tooltip:t.tooltip??t.text??e,...o?{icon:o}:{text:t.text??e},items:()=>(t.fetch(i=>r=i),r.map((i,s)=>i.type==="separator"?{type:"separator"}:{id:`${e}-${s}`,label:i.text??"",onSelect:()=>i.onAction?.({})}))})},addMenuItem:(e,t)=>{let r=As(t.icon);this.core.ui.registry.addMenuItem(e,{text:t.text??e,...r?{icon:r}:{},onAction:()=>t.onAction?.({})})},addContextToolbar:(e,t)=>{this.core.ui.registry.addContextToolbar(e,{label:t.label??e,items:t.items,position:t.position==="node"?"node":"selection",predicate:()=>{let r=this.selection.getNode();return!!r&&this.getBody().contains(r)&&t.predicate(r)}})},addSidebar:(e,t)=>{let r=null,o={element:()=>r},i=As(t.icon);this.core.ui.registry.addSidebar(e,{title:t.tooltip??e,...i?{icon:i}:{},render:s=>{r=s;let l=t.onSetup?.(o);return typeof l=="function"?l:void 0},onShow:()=>t.onShow?.(o),onHide:()=>t.onHide?.(o)})},addView:(e,t)=>{this.core.ui.registry.addView(e,{buttons:(Array.isArray(t.buttons)?t.buttons:[]).filter(r=>typeof r?.text=="string").map(r=>({text:r.text,buttonType:r.buttonType==="primary"?"primary":"secondary",onAction:()=>r.onAction?.()})),...t.onShow?{onShow:t.onShow}:{},...t.onHide?{onHide:t.onHide}:{}})},addContextForm:()=>{console.warn("[nova] tinymce-compat: addContextForm is not supported yet")},getAll:()=>({})}});S(this,"dom",{select:(e,t)=>[...(t??this.getBody()).querySelectorAll(e)],get:e=>typeof e=="string"?this.getBody().querySelector(`#${CSS.escape(e)}`):e,getParent:(e,t)=>{let r=e instanceof Element?e:e?.parentElement??null;for(;r&&r!==this.getBody();){if(typeof t=="string"?r.matches(t):t(r))return r;r=r.parentElement}return null},getParents:(e,t)=>{let r=[],o=e instanceof Element?e:e?.parentElement??null;for(;o&&o!==this.getBody();)(!t||o.matches(t))&&r.push(o),o=o.parentElement;return r},is:(e,t)=>!!e?.matches(t),getAttrib:(e,t,r="")=>e?.getAttribute(t)??r,hasClass:(e,t)=>!!e?.classList.contains(t),getStyle:(e,t)=>e instanceof HTMLElement?e.style.getPropertyValue(t):"",getRoot:()=>this.getBody(),encode:e=>e.replace(/[&<>"']/g,t=>`&#${t.charCodeAt(0)};`),decode:e=>{let t=document.createElement("textarea");return t.innerHTML=e,t.value},create:(e,t={},r)=>{let o=document.createElement(e);for(let[i,s]of Object.entries(t))i.startsWith("on")||o.setAttribute(i,s);return r!==void 0&&(o.textContent=r),o},uniqueId:(e="mce_")=>`${e}${Math.random().toString(36).slice(2,10)}`,setAttrib:()=>xo("setAttrib"),addClass:()=>xo("addClass"),removeClass:()=>xo("removeClass"),setStyle:()=>xo("setStyle"),remove:()=>xo("remove")});S(this,"formatter",{apply:(e,t={})=>this.applyFormat(e,t,"apply"),remove:e=>this.applyFormat(e,{},"remove"),toggle:(e,t={})=>this.applyFormat(e,t,this.formatter.match(e)?"remove":"apply"),match:e=>{if(this.core.formatter.has(e))return this.core.formatter.match(e);let t=e.toLowerCase();if(nS.has(t))return this.blockMatches(t);let r=cu[t];if(r)return this.core.isActive(r);let o=du[t];if(!o)return!1;let{state:i}=this.core.view,{from:s,to:l,empty:a}=i.selection,c=i.schema.marks[o];return a||!c?bt(i,o)!==null:i.doc.rangeHasMark(s,l,c)},canApply:e=>this.core.formatter.has(e)||e.toLowerCase()in cu||e.toLowerCase()in du,register:(e,t)=>{let r=typeof e=="string"?[[e,t]]:Object.entries(e);for(let[o,i]of r){let s=Es(i);s.length?this.core.formatter.register(o,s):console.warn(`[nova] tinymce-compat: format "${o}" is not supported yet`)}},unregister:e=>this.core.formatter.unregister(e),get:e=>this.core.formatter.get(e)});this.core=e,this.targetElm=t,this.id=r,this.settings=o,setTimeout(()=>{by().catch(()=>{})},0)}getContent(e={}){let t={format:e.format??"html",content:""};return t.content=t.format==="text"?this.core.getText():this.core.getHTML({fullPage:e.fullpagehtml!==!1}),(e.prettify===!0||this.settings.advcode_prettify_getcontent===!0&&this.core.hasPlugin("advcode"))&&t.format!=="text"&&(t.content=Ss(t.content)),this.fire("GetContent",t),t.content}setContent(e,t={}){let r={content:e,...t};return this.fire("BeforeSetContent",r),this.core.setContent(r.content,{fullPage:t.fullpagehtml!==!1}),this.fire("SetContent",r),r.content}insertContent(e){this.core.insertContent(e)}resetContent(e){this.core.setContent(e??this.settings.__initialContent??"",{addToHistory:!1}),this.setDirty(!1)}getBody(){return this.core.view.dom}getElement(){return this.targetElm}getContainer(){return this.core.root}getContentAreaContainer(){return this.core.view.dom.parentElement??this.core.root}getDoc(){return this.core.root.ownerDocument}getWin(){return this.core.root.ownerDocument.defaultView}queryCommandValue(e){return e.toLowerCase()==="togglesidebar"?this.core.ui.sidebar.active??"":e.toLowerCase()==="toggleview"?this.core.ui.view.active??"":""}execCommand(e,t,r){let o=e.toLowerCase(),i=!1;if(Cs[o])i=this.core.exec(Cs[o]);else if(o==="formatblock"||o==="mcetoggleformat"){let s=eS[String(r??"").toLowerCase()];i=s?this.core.exec(s):!1}else if(o==="mceinsertcontent"||o==="inserthtml")this.insertContent(String(r??"")),i=!0;else if(o==="toggleview")this.core.ui.view.toggle(String(r??"")),i=!0;else if(o==="togglesidebar")this.core.ui.sidebar.toggle(String(r??"")),i=!0;else if((o==="mceaidialog"||o==="mceaidialogclose")&&this.core.hasPlugin("ai")){let s=r&&typeof r=="object"?r:{},l={...typeof s.prompt=="string"?{prompt:s.prompt}:{},...s.generate===!0?{generate:!0}:{},...s.display===!1?{display:!1}:{}};this.core.root.dispatchEvent(o==="mceaidialog"?new CustomEvent("nova-ai-dialog",{detail:l}):new CustomEvent("nova-ai-dialog-close")),i=!0}else if(o==="mcesetcontent")this.setContent(String(r??"")),i=!0;else if(o==="mceinserttoc"||o==="mceupdatetoc"){let s=this.core.ui.registry.get(o==="mceinserttoc"?"tableofcontents":"tableofcontentsupdate");s?.type==="button"&&(s.onAction(this.core),i=!0)}else if(yy[o]&&this.core.hasPlugin("advtable"))this.core.root.dispatchEvent(new CustomEvent("nova-advtable",{detail:yy[o](r)})),i=!0;else if(Qw.has(o))i=this.accordionCommand(o,r);else if(o==="mceinserttemplate"&&this.core.hasPlugin("template"))this.core.root.dispatchEvent(new CustomEvent("nova-insert-template",{detail:String(r??"")})),i=!0;else if(gy.has(o)&&this.core.hasPlugin("spellchecker"))i=this.spellcheckCommand(o);else if(vo[o]||o==="mcetogglestickyformatpainter")i=this.pluginCommand(o);else if(o==="codesample"){let s=this.core.ui.registry.get("codesample");s?.type==="button"&&(s.onAction(this.core),i=!0)}else if(o==="selectall"){let{state:s,dispatch:l}=this.core.view;l(s.tr.setSelection(new ue(s.doc))),i=!0}else if(o==="mcecleanup")i=!0;else{let s=this.commands.get(o);s&&(s(t,r),i=!0)}return i&&this.fire("ExecCommand",{command:e,ui:t,value:r}),i}spellcheckCommand(e){if(e==="mcespellcheckdialogclose")return this.core.ui.closeOverlays(),!0;if(e==="mcespellcheckupdate")return!0;let t=this.core.ui.registry.get("spellchecker");if(!t)return!1;let r=!!t.isActive?.(this.core);return e==="mcespellcheckenable"!==r&&t.onAction(this.core),!0}accordionCommand(e,t){let{view:r}=this.core,{state:o}=r,i=o.selection.$from,s=null;for(let d=i.depth;d>0&&!s;d--){let u=i.node(d);u.type.name==="details"&&(s={pos:i.before(d),open:u.attrs.open!==!1})}if(e==="insertaccordion"||e==="removeaccordion"){if(e==="removeaccordion"!=!!s)return!1;let d=this.core.ui.registry.get("accordion");return d?.type!=="button"?!1:(d.onAction(this.core),!0)}let l=[];if(e==="toggleaccordion"?s&&l.push(s):o.doc.descendants((d,u)=>(d.type.name==="details"&&l.push({pos:u,open:d.attrs.open!==!1}),!d.isTextblock)),!l.length)return!1;let a=typeof t=="boolean"?t:!l.every(d=>d.open),c=o.tr;for(let d of l)c.setNodeAttribute(d.pos,"open",a);return r.dispatch(c.setMeta("addToHistory",!1)),!0}pluginCommand(e){let{registry:t}=this.core.ui;if(e==="mcetogglestickyformatpainter"){let o=t.get("formatpainter"),i=t.getMenuItem("formatpainter");return o?.type!=="button"||!i?!1:(i.isActive?.(this.core)?i.onAction(this.core):(o.onAction(this.core),o.onAction(this.core)),!0)}let r=t.getMenuItem(vo[e]);return!r||e!=="mcesave"&&r.isEnabled?.(this.core)===!1?!1:(r.onAction(this.core),!0)}queryCommandState(e){let t=e.toLowerCase(),r=Cs[t];return r?this.core.isActive(r):t==="mcetoggleformatpainter"||t==="mcetogglepermanentpen"?!!this.core.ui.registry.getMenuItem(vo[t])?.isActive?.(this.core):!1}queryCommandSupported(e){let t=e.toLowerCase();return t in Cs||["formatblock","mceinsertcontent","mcesetcontent"].includes(t)||t in vo&&!!this.core.ui.registry.getMenuItem(vo[t])||t==="mcetogglestickyformatpainter"&&this.core.ui.registry.has("formatpainter")||gy.has(t)&&this.core.hasPlugin("spellchecker")||(t==="mceaidialog"||t==="mceaidialogclose")&&this.core.hasPlugin("ai")||this.commands.has(t)}addCommand(e,t){this.commands.set(e.toLowerCase(),t)}on(e,t,r=!1){for(let o of e.toLowerCase().split(/\s+/).filter(Boolean)){let i=this.handlers.get(o)??new Set;r?this.handlers.set(o,new Set([t,...i])):this.handlers.set(o,i.add(t))}return this}off(e,t){if(!e)return this.handlers.clear(),this;for(let r of e.toLowerCase().split(/\s+/).filter(Boolean))t?this.handlers.get(r)?.delete(t):this.handlers.delete(r);return this}once(e,t){let r=o=>(this.off(e,r),t(o));return this.on(e,r)}fire(e,t={}){let r=Object.assign(t,{type:e.toLowerCase(),target:this});for(let o of[...this.handlers.get(e.toLowerCase())??[]])try{o(r)}catch(i){console.error(`[nova] tinymce-compat: "${e}" handler failed`,i)}return r}fireNative(e,t){for(let r of[...this.handlers.get(e)??[]])try{r(t)}catch(o){console.error(`[nova] tinymce-compat: "${e}" handler failed`,o)}}static registerIcon(e,t){Ts.set(e,t)}dispatch(e,t){return this.fire(e,t)}hasEventListeners(e){return(this.handlers.get(e.toLowerCase())?.size??0)>0}isDirty(){return this.dirty}setDirty(e){let t=this.dirty!==e;this.dirty=e,t&&e&&this.fire("Dirty")}save(){let e=this.getContent(),t=this.fire("SaveContent",{content:e});return this.targetElm instanceof HTMLTextAreaElement&&(this.targetElm.value=String(t.content)),this.setDirty(!1),String(t.content)}focus(){this.core.focus()}hasFocus(){return this.core.view.hasFocus()}hide(){this.core.root.hidden=!0,this.targetElm instanceof HTMLTextAreaElement&&(this.targetElm.hidden=!1)}show(){this.core.root.hidden=!1,this.targetElm instanceof HTMLTextAreaElement&&(this.targetElm.hidden=!0)}isHidden(){return this.core.root.hidden===!0}getParam(e,t){return e in this.settings?this.settings[e]:t}addButton(e,t,r){let{api:o,state:i}=oS(this);t.enabled===!1&&o.setEnabled(!1),t.active&&o.setActive(!0);let s=As(t.icon);if(this.core.ui.registry.addButton(e,{tooltip:t.tooltip??t.text??e,...s?{icon:s}:{text:t.text??e},isEnabled:()=>i.enabled,...r?{isActive:()=>i.active}:{},onAction:()=>t.onAction?.(o)}),t.onSetup){let l=()=>{let a=t.onSetup(o);typeof a=="function"&&this.teardowns.push(a)};this.initialized?l():this.once("init",l)}}blockMatches(e){let{$from:t}=this.core.view.state.selection;for(let o=t.depth;o>0;o-=1){let i=t.node(o),s=i.type.name;if(e==="blockquote"&&s==="blockquote")return!0;if(o===t.depth){if(e==="p")return s==="paragraph";if(e==="pre")return s==="code_block";if(/^h[1-6]$/.test(e))return s==="heading"&&i.attrs.level===Number(e[1])}}let r=null;if(this.core.view.state.doc.descendants(o=>r||!o.isTextblock?!r:(r={name:o.type.name,level:o.attrs.level},!1)),!t.depth&&r){let o=r;if(e==="p")return o.name==="paragraph";if(e==="pre")return o.name==="code_block";if(/^h[1-6]$/.test(e))return o.name==="heading"&&o.level===Number(e[1])}return!1}applyFormat(e,t,r){if(this.core.formatter.has(e)){r==="apply"?this.core.formatter.apply(e):this.core.formatter.remove(e);return}let o=e.toLowerCase(),i=cu[o];if(i){let l=this.formatter.match(o);rS.has(o)?r==="apply"?this.core.exec(i):l&&this.core.exec("paragraph"):r==="apply"!==l&&this.core.exec(i);return}let s=du[o];if(s){this.core.exec(It(s,r==="apply"?t.value??null:null));return}console.warn(`[nova] tinymce-compat: format "${e}" is not supported yet`)}remove(){if(this.removed)return;this.fire("remove"),this.save(),this.teardowns.splice(0).forEach(t=>t()),this.removed=!0,this.core.destroy(),this.core.root.remove(),this.settings.__wrapper?.remove(),this.targetElm.hidden=!1,this.off()}destroy(){this.remove()}};var ky=new Set;function pu(n){ky.has(n)||(ky.add(n),console.warn(`[nova] tinymce-compat: ${n}`))}var iS=0,Ns=n=>typeof n=="number"?`${n}px`:String(n);function sS(){xd(cy);let n=[],e=new Map,t=null;async function r(i,s){var H;let l=n.find($=>$.targetElm===i&&!$.removed);if(l)return l;let{options:a,unknown:c,missingPlugins:d}=my(s);c.length&&pu(`options not supported yet: ${c.join(", ")}`);let u=String(Array.isArray(s.plugins)?s.plugins.join(" "):s.plugins??"").split(/[\s,]+/).filter($=>e.has($)),p=d.filter($=>!e.has($));p.length&&pu(`plugins not available: ${p.join(", ")}`);let f=i.id||`mce_${++iS}`;i.id||(i.id=f);let h=i instanceof HTMLTextAreaElement,m=h?i.value:i.innerHTML,g={...s,__initialContent:m},y;s.inline===!0&&!h?(i.replaceChildren(),y=i):(y=document.createElement("div"),y.className="nova-compat",i.after(y),i.hidden=!0,g.__wrapper=y);let x,M=$=>{let G=$;if(!G||typeof G.start!="string")return null;if(typeof G.replacement=="string")return{start:G.start,replacement:G.replacement};let U=(Array.isArray(G.format)?G.format:[G.format]).filter(Ae=>typeof Ae=="string"),se=typeof G.cmd=="string"?G.cmd:null;return!se&&!U.length?null:{start:G.start,...typeof G.end=="string"&&G.end?{end:G.end}:{},...G.trigger==="enter"?{trigger:"enter"}:{},value:G.value,command:(Ae,rt)=>{if(se)x.execCommand(se,!1,rt);else for(let $e of U)x.formatter.apply($e)}}};Array.isArray(s.text_patterns)&&(a.textPatterns=s.text_patterns.map(M));let L=s.text_patterns_lookup;typeof L=="function"&&(a.textPatternsLookup=$=>{let G=L($);return Array.isArray(G)?G.map(M):[]},a.textPatterns||(a.textPatterns=[]));let O=s.save_onsavecallback,B=s.save_oncancelcallback,J={...s.save_enablewhendirty!==void 0?{enableWhenDirty:s.save_enablewhendirty!==!1}:{},...typeof O=="function"?{onSave:()=>(x.save(),O(x))}:{},...typeof B=="function"?{onCancel:()=>B(x)}:{}},P=s.ai_request,v=typeof P=="function"?{...a.pluginOptions?.ai,async*request($){let{tinyAiRequest:G}=await import(__novaChunk("tinymce-chunks/ai-e0658729.js") );yield*G(P,(U,se)=>x?.fire(U,se))($)}}:null,k={...a.pluginOptions,...Object.keys(J).length?{save:J}:{},...v?{ai:v}:{}},E=ws({...a,...Object.keys(k).length?{pluginOptions:k}:{},element:y,content:m,setup:$=>{x=new wo($,i,f,g);for(let G of u)try{let U=e.get(G)(x,"");x.plugins[G]=U&&typeof U=="object"?U:{}}catch(U){console.error(`[nova] tinymce-compat: plugin "${G}" failed`,U)}s.setup?.(x)}});s.height!==void 0&&(E.root.style.height=Ns(s.height)),s.min_height!==void 0&&(E.root.style.minHeight=Ns(s.min_height)),s.max_height!==void 0&&(E.root.style.maxHeight=Ns(s.max_height)),s.width!==void 0&&(E.root.style.width=Ns(s.width));let b=!1;E.on("change",()=>{x.setDirty(!0),b=!0,x.fire("input")}),E.on("selectionChange",()=>{x.fire("NodeChange",{element:x.selection.getNode(),selectionChange:!0})}),E.on("focus",()=>{t=x,b=!1,x.fire("focus")}),E.on("blur",()=>{b&&x.fire("change",{level:{content:x.getContent()}}),b=!1,x.fire("blur")});for(let $ of["keydown","keyup","keypress","click","dblclick","mousedown","mouseup","paste","copy","cut","drop"])E.view.dom.addEventListener($,G=>x.fireNative($,G));if(E.root.addEventListener("nova-ai-dialogopen",()=>x.fire("AIDialogOpen")),E.root.addEventListener("nova-ai-dialogclose",()=>x.fire("AIDialogClose")),E.root.addEventListener("nova-autocorrect-toggle",$=>{let{feature:G,on:U}=$.detail;x.fire((G==="capitalize"?"Capitalize":"Autocorrect")+(U?"Start":"End"))}),(h?i.form:i.closest("form"))?.addEventListener("submit",()=>x.save()),x.on("remove",()=>{let $=n.indexOf(x);$>=0&&n.splice($,1),t===x&&(t=n[0]??null)}),n.push(x),t??(t=x),await E.ready,x.removed)return x;for(let $ of py(s,G=>E.hasPlugin(G)))(H=x.plugins)[$]??(H[$]={});return x.plugins.inlinecss&&(x.plugins.inlinecss.getContent=async()=>{x.fire("InlineCSS");let{emailHTML:$}=await import(__novaChunk("tinymce-chunks/email-1926dd8a.js") );return{html:await $(E,{document:!1})}}),x.initialized=!0,x.fire("init"),s.init_instance_callback?.(x),typeof s.view_show=="string"&&s.view_show?E.ui.view.show(s.view_show):typeof s.sidebar_show=="string"&&s.sidebar_show&&E.ui.sidebar.show(s.sidebar_show),x}return{majorVersion:"7",minorVersion:"0.0",novaprose:!0,get activeEditor(){return t},get editors(){return[...n]},async init(i){document.readyState==="loading"&&await new Promise(a=>document.addEventListener("DOMContentLoaded",a,{once:!0})),typeof i.language=="string"&&await rl(i.language.replace("_","-")).catch(a=>(console.warn("[nova] tinymce-compat: language pack failed to load",a),!1));let s=i.target?[i.target]:i.selector?[...document.querySelectorAll(i.selector)]:[];s.length||pu(`no elements match "${i.selector??""}"`);let l=[];for(let a of s)l.push(await r(a,i));return l},get:(i=>i===void 0?[...n]:typeof i=="number"?n[i]??null:n.find(s=>s.id===i)??null),remove(i){(i===void 0?[...n]:typeof i=="string"?n.filter(l=>l.id===i.replace(/^#/,"")||l.targetElm.matches(i)):[i]).forEach(l=>l.remove())},triggerSave(){n.forEach(i=>i.save())},execCommand(i,s,l){return t?.execCommand(i,s,l)??!1},PluginManager:{add:(i,s)=>{e.set(i,s)},get:i=>e.get(i),requireLangPack:()=>{},urls:{}},IconManager:{add:(i,s)=>{for(let[l,a]of Object.entries(s.icons??{}))wo.registerIcon(l,a)}},util:{I18n:{translate:i=>i}}}}var vy=sS();$t("ru",()=>import(__novaChunk("tinymce-chunks/ru-f1d19f4f.js") ));$t("de",()=>import(__novaChunk("tinymce-chunks/de-eb649701.js") ));$t("es",()=>import(__novaChunk("tinymce-chunks/es-b9c95169.js") ));$t("fr",()=>import(__novaChunk("tinymce-chunks/fr-724ffe36.js") ));$t("it",()=>import(__novaChunk("tinymce-chunks/it-f4816bbc.js") ));$t("pt-BR",()=>import(__novaChunk("tinymce-chunks/pt-BR-abebbb34.js") ));var xy=document.currentScript;if(xy?.src&&!document.querySelector("link[data-novaprose-css]")){let n=document.createElement("link");n.rel="stylesheet",n.href=xy.src.replace(/[^/]*$/,"novaprose.css"),n.setAttribute("data-novaprose-css",""),document.head.append(n)}window.tinymce=vy;var q=globalThis.__novaprose_tinymce={};q["node_modules/.pnpm/prosemirror-history@1.5.2/node_modules/prosemirror-history/dist/index.js"]=Mc;q["node_modules/.pnpm/prosemirror-inputrules@1.7.0/node_modules/prosemirror-inputrules/dist/index.js"]=id;q["node_modules/.pnpm/prosemirror-keymap@1.2.3/node_modules/prosemirror-keymap/dist/index.js"]=Yl;q["node_modules/.pnpm/prosemirror-model@1.25.13/node_modules/prosemirror-model/dist/index.js"]=Vs;q["node_modules/.pnpm/prosemirror-schema-list@1.6.1/node_modules/prosemirror-schema-list/dist/index.js"]=fa;q["node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.js"]=Qs;q["node_modules/.pnpm/prosemirror-transform@1.12.7/node_modules/prosemirror-transform/dist/index.js"]=Gs;q["node_modules/.pnpm/prosemirror-view@1.43.1/node_modules/prosemirror-view/dist/index.js"]=Kl;q["node_modules/.pnpm/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.js"]=Jl;q["packages/core/src/blocks.ts"]=Ac;q["packages/core/src/code-language.ts"]=Aa;q["packages/core/src/commands.ts"]=Lc;q["packages/core/src/comments.ts"]=ta;q["packages/core/src/content-css.ts"]=Hc;q["packages/core/src/document.ts"]=wd;q["packages/core/src/editor.ts"]=nu;q["packages/core/src/element-id.ts"]=ul;q["packages/core/src/image.ts"]=ed;q["packages/core/src/link.ts"]=cd;q["packages/core/src/mark-views.ts"]=Qd;q["packages/core/src/page.ts"]=Rd;q["packages/core/src/parser.ts"]=Nd;q["packages/core/src/plugins.ts"]=Rs;q["packages/core/src/plugins/accordion.ts"]=dl;q["packages/core/src/plugins/advtable.ts"]=ja;q["packages/core/src/plugins/comments.ts"]=la;q["packages/core/src/plugins/footnotes.ts"]=mc;q["packages/core/src/plugins/fullpagehtml.ts"]=oc;q["packages/core/src/plugins/index.ts"]=sm;q["packages/core/src/plugins/math.ts"]=hl;q["packages/core/src/plugins/media.ts"]=Ba;q["packages/core/src/plugins/mediaembed.ts"]=Xa;q["packages/core/src/plugins/mentions.ts"]=oa;q["packages/core/src/plugins/mergetags.ts"]=da;q["packages/core/src/plugins/pageembed.ts"]=$a;q["packages/core/src/plugins/pagelayout.ts"]=dc;q["packages/core/src/plugins/shared.ts"]=ol;q["packages/core/src/plugins/suggestions.ts"]=Ea;q["packages/core/src/plugins/tableofcontents.ts"]=yl;q["packages/core/src/pretty-html.ts"]=ou;q["packages/core/src/schema.ts"]=Ia;q["packages/core/src/search.ts"]=Bd;q["packages/core/src/serializer.ts"]=Qa;q["packages/core/src/tables.ts"]=yd;q["packages/core/src/ui/builtins.ts"]=jd;q["packages/core/src/ui/dialog.ts"]=qc;q["packages/core/src/ui/dom.ts"]=tl;q["packages/core/src/ui/file-picker.ts"]=zc;q["packages/core/src/ui/icons.ts"]=nl;q["packages/core/src/ui/link-bubble.ts"]=Jd;q["packages/core/src/ui/menu.ts"]=Od;q["packages/core/src/ui/popover.ts"]=Wd;q["packages/core/src/ui/views.ts"]=$d;q["packages/core/src/url.ts"]=Ca;})();
46
+ `)}setContent(e,{addToHistory:t=!0,fullPage:r=!0}={}){let o={content:e};this.emit("beforeSetContent",o);let i=r?Tn.get(this):void 0,s=cd(this.schema,o.content,i),l=this.view.state.tr.replaceWith(0,this.view.state.doc.content.size,s.content);if(i&&(typeof o.content!="string"||dy.has(s)))for(let[a,c]of Object.entries(s.attrs))c!==this.view.state.doc.attrs[a]&&l.setDocAttribute(a,c);l.setMeta(As,!0).setMeta(fi,!0),t||l.setMeta("addToHistory",!1),this.view.dispatch(l),this.emit("setContent",{content:o.content})}insertContent(e){return this.isEditable()?cy(e)(this.view.state,this.view.dispatch):!1}isEmpty(){return this.view.dom.classList.contains("nova-empty")}resolveCommand(e){e=co("commands",e);let t=this.commandOverrides.get(e)??(Object.prototype.hasOwnProperty.call(Ue,e)?Ue[e]:void 0);return t||(uy.has(e)||(uy.add(e),console.warn(`[nova] unknown command "${String(e)}": editor.exec() returns false`)),()=>!1)}registerCommands(e){for(let[t,r]of Object.entries(e.commands??{}))r&&this.commandOverrides.set(t,r);e.transformTransaction&&this.transactionTransforms.push(e.transformTransaction)}exec(e){let r=(typeof e=="string"?this.resolveCommand(e):e)(this.view.state,this.view.dispatch,this.view);return r&&this.view.focus(),r}chain(){return $g({view:()=>this.destroyed?null:this.view,resolve:e=>this.resolveCommand(e),insertContent:e=>(t,r,o)=>this.isEditable()&&cy(e)(t,r,o)})}can(e){let t=typeof e=="string"?this.resolveCommand(e):e;try{return t(this.view.state,void 0,this.view)}catch{return!1}}isActive(e){return cr(this.view.state,co("commands",e))}getCommandState(e){return{active:this.isActive(e),enabled:this.isEditable()&&this.can(e)}}focus(){this.destroyed||this.view.focus()}isPasteAsText(){return this.pasteAsText}setPasteAsText(e){this.pasteAsText=e,this.toolbar?.update()}loadSearchBar(){return this.searchBarLoad??(this.searchBarLoad=import(__novaChunk("tinymce-chunks/search-bar-1c8ef2ee.js") ).then(({createSearchBar:e})=>{if(this.destroyed)return null;let t=this.toolbarHost.parentElement;return this.searchBar=e(this,r=>t?t.append(r):this.contentHost.before(r)),this.searchBar},e=>(xt("The find and replace bar failed to load",e),null))),this.searchBarLoad}openSearch(){return this.loadSearchBar().then(e=>e?.open())}closeSearch(){this.searchBar?.close()}isEditable(){return this.editable&&!this.disabled}isDisabled(){return this.disabled}setDisabled(e){this.disabled!==e&&(this.disabled=e,this.view.setProps({}),this.applyDisabled(),e&&(this.ui.closePopover(),this.view.dom.blur()),this.toolbar?.update(),this.emit("editableChange"))}applyDisabled(){this.root.classList.toggle("nova-disabled",this.disabled),this.disabled?this.root.setAttribute("aria-disabled","true"):this.root.removeAttribute("aria-disabled"),this.disabled?this.view.dom.setAttribute("tabindex","-1"):this.view.dom.removeAttribute("tabindex")}setEditable(e){this.editable!==e&&(this.editable=e,this.view.setProps({}),this.root.classList.toggle("nova-readonly",!e),e||this.ui.closePopover(),this.toolbar?.update(),this.emit("editableChange"))}on(e,t){e=co("events",e);let r=this.listeners.get(e);return r||this.listeners.set(e,r=new Set),r.add(t),()=>this.off(e,t)}off(e,t){e=co("events",e),this.listeners.get(e)?.delete(t)}emit(e,...[t]){for(let r of this.listeners.get(e)??[])try{r(this,t)}catch(o){xt(`Listener for "${e}" failed`,o)}}destroy(){if(!this.destroyed){this.emit("destroy"),this.destroyed=!0,this.menubar?.destroy(),this.ui.destroy(),this.toolbar?.destroy(),this.statusbar?.destroy();for(let e of this.cleanups.splice(0))try{e()}catch(t){xt("Plugin cleanup failed",t)}this.searchBar?.destroy(),this.root.classList.contains("nova-fullscreen")&&yr(this,!1),this.view.destroy(),this.root.remove(),this.listeners.clear()}}};function xt(n,e){console.error(`[nova] ${n}`,...e===void 0?[]:[e])}var dy=new WeakSet;function cd(n,e,t){if(typeof e!="string")return Te.fromJSON(n,po(n,e));let r=t?t.read(e):null,o=document.createElement("div"),i=document.createElement("template");i.innerHTML=r?r.content:e,o.appendChild(i.content);let s=gr(n).parse(o);if(!r)return s;let l=s.type.create(r.attrs,s.content);return dy.add(l),l}function Ts(n){return new vo(n)}var fd={};q(fd,{prettyHTML:()=>Ns});var py=new Set(["address","article","aside","blockquote","caption","col","colgroup","dd","details","div","dl","dt","figcaption","figure","footer","h1","h2","h3","h4","h5","h6","header","hr","li","main","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul"]),Jw=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Gw=/<!--[\s\S]*?-->|<\/?[a-zA-Z][^>]*>|[^<]+|</g;function pd(n){let e=/^<(\/?)([a-zA-Z][\w-]*)/.exec(n);return e?{name:e[2].toLowerCase(),closing:e[1]==="/"}:null}function Ns(n,e=" "){let t=n.match(Gw)??[],r="",o=0,i=[],s=()=>(r?`
47
+ `:"")+e.repeat(o);for(let l=0;l<t.length;l++){let a=t[l],c=pd(a);if(c&&!c.closing&&c.name==="pre"){let f=l,h=0;for(;f<t.length;f++){let m=pd(t[f]);if(m?.name==="pre"&&(h+=m.closing?-1:1),h===0)break}r+=s()+t.slice(l,f+1).join(""),l=f;continue}if(!c||!py.has(c.name)){r+=a;continue}if(c.closing){i.pop()?.spread&&(o=Math.max(0,o-1),r+=s()),r+=a;continue}let u=i[i.length-1];if((!u||u.spread)&&(r+=s()),r+=a,Jw.has(c.name)||a.endsWith("/>"))continue;let d=pd(t[l+1]??""),p=!!d&&!d.closing&&py.has(d.name);i.push({name:c.name,spread:p}),p&&o++}return r}var fy=new Set("script,style,iframe,frame,frameset,object,embed,applet,base,link,meta,title,head,html,body,template,slot,noscript,form,input,button,select,option,optgroup,textarea,fieldset,legend,datalist,output,progress,meter,svg,math,canvas,audio,video,source,track,picture,map,area,portal,dialog,param,xmp,plaintext,listing,noembed,noframes,image".split(",")),Yw=/^(on|xmlns)|^(srcdoc|formaction|action|contenteditable|autofocus|is|slot|nonce)$/,Xw=/^[a-z_:][a-z0-9_.:-]*$/,hy=/^[a-z][a-z0-9._-]*$/,br=new Set("p,h1,h2,h3,h4,h5,h6,blockquote,pre,hr,ul,ol,li,img,figure,figcaption,br,table,tr,td,th,strong,em,u,s,code,a,sub,sup".split(",")),xo=new Set(["span","i","b","del","strike","mark"]),Zw=new Set("abbr,acronym,bdi,bdo,big,cite,data,dfn,ins,kbd,q,samp,small,time,tt,var,label,ruby,rt,rp,wbr".split(",")),vy=new Set("div,section,article,aside,header,footer,nav,main,address,details,summary,dl,dt,dd,center,hgroup,search".split(",")),Qw=new Set([...vy,..."p,h1,h2,h3,h4,h5,h6,blockquote,pre,hr,ul,ol,li,table,figure".split(",")]),eS={a:["href"],ul:["data-type"],li:["data-type","data-checked"],img:["src"],td:["colspan","rowspan"],th:["colspan","rowspan"]};function my(n){let e=[],t=0,r="";for(let o of n)o==="["?t++:o==="]"&&(t=Math.max(0,t-1)),o===","&&!t?(e.push(r),r=""):r+=o;return e.push(r),e.map(o=>o.trim()).filter(Boolean)}function tS(n){let e=n.trim(),t=e.startsWith("!");t&&(e=e.slice(1));let r=/^([^=:<]+)(?:([=:<])(.*))?$/s.exec(e);if(!r)return null;let o=r[1].trim().toLowerCase();if(!o)return null;let i={name:o,required:t},s=r[3]??"";return r[2]==="="?i.def=s:r[2]===":"?i.forced=s:r[2]==="<"&&(i.values=s.split("?")),i}function hd(n,e){return n==="*"?!0:n.endsWith("*")?e.startsWith(n.slice(0,-1)):n===e}var gy=new Set;function md(n,e){gy.has(n)||(gy.add(n),console.warn(`[nova] <${n}> in content rules is ignored: ${e}`))}var gd=class{constructor(e){S(this,"elements",new Map);S(this,"globals",[]);S(this,"blockTags",new Map);S(this,"inlineTags",new Map);let t=new Set((e.invalidElements??"").split(",").map(s=>s.trim().toLowerCase()).filter(Boolean)),r=new Set,o=new Set;for(let s of(e.customElements??"").split(",")){let l=s.trim().toLowerCase(),a=l.replace(/^~/,"");if(hy.test(a)){if(fy.has(a)||br.has(a)){md(a,"it cannot be a custom element");continue}o.add(a),l.startsWith("~")&&r.add(a)}}let i=(s,l)=>{let[a,...c]=s;if(a){if(a==="@"||a==="*"){this.globals.push(...l??[]);return}for(let u of s){if(!hy.test(u)||t.has(u))continue;if(fy.has(u)){md(u,"not allowed for security reasons (iframes and video: use the media plugin)");continue}this.elements.set(u,l);let d=br.has(u)||xo.has(u)?u:a;if(br.has(u))continue;if(xo.has(u)){u===a&&l?.length&&this.inlineTags.set(u,u);continue}let p=o.has(u)||o.has(a)||u.includes("-");Zw.has(a)||r.has(a)?this.inlineTags.set(u,d):vy.has(a)||p?this.blockTags.set(u,d):(!c.includes(u)||u===a)&&md(u,"unknown element")}}};for(let s of my(e.validElements??"")){let{names:l,attrs:a}=yy(s);a?i(l,a):l.every(c=>br.has(c)||xo.has(c))||i(l,null)}for(let s of my(e.extendedValidElements??"")){let{names:l,attrs:a}=yy(s);i(l,a)}for(let s of o)t.has(s)||(this.elements.has(s)||this.elements.set(s,[{name:"*",required:!1}]),r.has(s)?this.inlineTags.set(s,s):this.inlineTags.has(s)||this.blockTags.set(s,s))}apply(e,t){return sS(e.nodes,e.marks,this,t)}get active(){return this.elements.size>0||this.globals.length>0}touches(e){return this.globals.length>0||this.elements.has(e)}rulesFor(e){return[...this.elements.get(e)??[],...this.globals]}allows(e,t){return Yw.test(t)||!Xw.test(t)?!1:this.rulesFor(e).some(r=>hd(r.name,t))}extends(e){return this.rulesFor(e).some(t=>t.name!=="class"&&t.name!=="style")}get classOnBuiltIn(){if(this.globals.some(e=>hd(e.name,"class")))return!0;for(let[e,t]of this.elements)if(br.has(e)&&t?.some(r=>hd(r.name,"class")))return!0;return!1}hasRequired(e,t){return this.rulesFor(e).every(r=>!r.required||t.hasAttribute(r.name))}readAttrs(e,t,r){let o=null;for(let i of Array.from(t.attributes)){let s=i.name.toLowerCase();if(s===cs&&(s="style"),s==="lang"||r.includes(s)||!this.allows(e,s))continue;let l=Zr(s,i.value);l!==null&&((o??(o={}))[s]=l)}return o}outputAttrs(e,t,r){let o={...t};if(r&&typeof r=="object"&&!Array.isArray(r))for(let[s,l]of Object.entries(r)){let a=s.toLowerCase();if(o[a]!=null||a==="lang"||!this.allows(e,a)||!["string","number","boolean"].includes(typeof l))continue;let c=Zr(a,String(l));c!==null&&(o[a]=c)}if(this.elements.get(e))for(let s of Object.keys(o))this.allows(e,s)||eS[e]?.includes(s)||s.startsWith("data-nova-")||delete o[s];for(let s of this.rulesFor(e)){if(s.name.includes("*"))continue;s.forced!==void 0?o[s.name]=s.forced:s.def!==void 0&&o[s.name]==null&&(o[s.name]=s.def);let l=o[s.name];s.values&&l!=null&&!s.values.includes(String(l))&&delete o[s.name]}return e==="a"&&o.target!=null&&o.rel==null&&(o.rel="noopener noreferrer"),o}decorate(e,t){if(!Array.isArray(e)||typeof e[0]!="string")return e;let r=e[0],o=(r.includes(" ")?r.split(" ")[1]:r).toLowerCase();if(!this.touches(o))return e;let i=e[1],s=!!i&&typeof i=="object"&&!Array.isArray(i)&&i.nodeType===void 0,l=this.outputAttrs(o,s?i:{},t);return[r,l,...e.slice(s?2:1)]}};function yy(n){let e=/^([^[]*)(?:\[(.*)\])?$/s.exec(n.trim()),t=(e?.[1]??"").trim().replace(/^[-#+!]+/,"").split("/").map(i=>i.trim().toLowerCase()).filter(Boolean),r=e?.[2],o=r===void 0?null:r.split("|").map(tS).filter(i=>i!==null);return{names:t,attrs:o}}function nS(n){if(!n.validElements&&!n.extendedValidElements&&!n.customElements)return null;let e=new gd(n);return e.active?e:null}var by=n=>(/^[a-z][a-z0-9-]*/i.exec(n)?.[0]??"").toLowerCase();function rS(n,e,t,r,o){try{let i=n.schema,s=e==="node"?o(i.nodes[t].create(r)):o(i.marks[t].create(r),!0),l=Array.isArray(s)?s[1]:null;return l&&typeof l=="object"&&!Array.isArray(l)?Object.keys(l):[]}catch{return[]}}function oS(n,e,t,r,o){let i=(e.parseDOM??[]).map(a=>a.tag?by(a.tag):"").filter(a=>br.has(a)&&r.touches(a));if(!i.length||!e.toDOM)return e;let s=i.some(a=>r.extends(a)),l=e.toDOM;return{...e,...s?{attrs:{...e.attrs,htmlAttrs:{default:null}}}:{},parseDOM:e.parseDOM.map(a=>{let c=a.tag?by(a.tag):"";if(!i.includes(c))return a;let u=a.getAttrs;return{...a,getAttrs:d=>{let p=u?u(d):a.attrs??null;if(p===!1||!r.hasRequired(c,d))return!1;if(!s)return p;let f=r.readAttrs(c,d,["class","style"]);if(!f)return p;for(let h of rS(o,t,n,{...p},l))delete f[h];return Object.keys(f).length?{...p,htmlAttrs:f}:p}}}),toDOM:((a,c)=>r.decorate(l(a,c),a.attrs.htmlAttrs))}}function ky(n,e){return Array.from(n.children).some(t=>{let r=t.localName;return Qw.has(r)||e.blockTags.has(r)})}function iS(n){let e={},t={},r=(a,c,u)=>{if(!n.hasRequired(a,c))return!1;let d=xo.has(a),p=d?u&&a==="span"?["class","style"]:["style"]:[],f=n.readAttrs(a,c,p);return d&&!f?!1:{tag:a,htmlAttrs:f}},o=a=>[...a].filter(([,c])=>!xo.has(c)).map(([c])=>c),i=(a,c,u)=>{let d=typeof u.tag=="string"&&a.has(u.tag)?u.tag:c;return{tag:d,attrs:n.outputAttrs(d,{},u.htmlAttrs)}},s=[...n.blockTags];if(s.length){let a=new Set(n.blockTags.values()),c=a.has("div")?"div":[...a][0],u={tag:{default:c},htmlAttrs:{default:null}};e.html_block={ownStyleTags:o(n.blockTags),group:"block",content:"block+",defining:!0,attrs:u,parseDOM:s.map(([d,p])=>({tag:d,getAttrs:f=>ky(f,n)?r(p,f,!1):!1})),toDOM:d=>{let{tag:p,attrs:f}=i(a,c,d.attrs);return[p,f,0]}},e.html_textblock={group:"block",content:"inline*",attrs:u,parseDOM:s.map(([d,p])=>({tag:d,getAttrs:f=>ky(f,n)?!1:r(p,f,!1)})),toDOM:d=>{let{tag:p,attrs:f}=i(a,c,d.attrs);return[p,f,0]}}}let l=[...n.inlineTags];if(l.length){let a=new Set(n.inlineTags.values()),c=a.has("span")?"span":[...a][0],u={tag:{default:c},htmlAttrs:{default:null}};e.html_inline_atom={ownStyleTags:o(n.inlineTags),group:"inline",inline:!0,atom:!0,attrs:u,parseDOM:l.map(([d,p])=>({tag:d,priority:65,getAttrs:f=>f.firstChild?!1:r(p,f,!1)})),toDOM:d=>{let{tag:p,attrs:f}=i(a,c,d.attrs);return[p,f]}},t.html_inline={attrs:u,excludes:"",parseDOM:l.map(([d,p])=>({tag:d,priority:p==="span"?40:60,getAttrs:f=>f.firstChild?r(p,f,!0):!1})),toDOM:d=>{let{tag:p,attrs:f}=i(a,c,d.attrs);return[p,f,0]}}}return{nodes:e,marks:t}}function sS(n,e,t,r){let o=(s,l)=>Object.fromEntries(Object.entries(s).map(([a,c])=>[a,oS(a,c,l,t,r)])),i=iS(t);return{nodes:{...o(n,"node"),...i.nodes},marks:{...o(e,"mark"),...i.marks}}}var xy={create:nS};var wy=new Set(["lists","link","image","table","code","preview","searchreplace","fullscreen","help","wordcount","paste","hr","print","textcolor","colorpicker","contextmenu","tabfocus","textpattern","imagetools","powerpaste"]),Sy={tinycomments:"comments",tinymcespellchecker:"spellchecker",inlinecss:"email"},lS=new Set(["selector","target","license_key","api_key","branding","promotion","skin","skin_url","content_css","icons","icons_url","theme","theme_url","base_url","suffix","referrer_policy","convert_urls","relative_urls","remove_script_host","document_base_url","entity_encoding","height","min_height","max_height","width","resize","content_style","setup","init_instance_callback","inline","plugins","toolbar","menubar","statusbar","placeholder","readonly","disabled","block_formats","file_picker_callback","formats","style_formats","style_formats_merge","valid_classes","table_class_list","table_cell_class_list","file_picker_types","language","images_upload_handler","paste_as_text","paste_preprocess","paste_postprocess","invalid_elements","valid_elements","directionality","extended_valid_elements","custom_elements","valid_styles","toolbar_mode","toolbar_sticky","toolbar_sticky_offset","content_language","content_langs","font_family_formats","font_size_formats","line_height_formats","color_map","autosave_interval","autosave_retention","autosave_prefix","quickbars_selection_toolbar","quickbars_insert_toolbar","mentions_fetch","tinycomments_author","tinycomments_author_name","codesample_languages","details_initial_state","details_serialized_state","tableofcontents_class","tableofcontents_depth","tableofcontents_header","tableofcontents_orderedlist","tableofcontents_includeheader","codesample_global_prismjs","casechange_title_case_minors","permanentpen_properties","visualchars_default_state","save_enablewhendirty","save_onsavecallback","save_oncancelcallback","importcss_append","importcss_file_filter","importcss_selector_filter","importcss_groups","importcss_exclusive","importcss_selector_converter","templates","spellchecker_active","spellchecker_language","spellchecker_languages","spellchecker_ignore_list","spellchecker_dialog","spellchecker_languagetool_url","spellchecker_check","a11ychecker_level","a11ychecker_ignored_rules","a11ychecker_allow_decorative_images","a11y_advanced_options","a11ychecker_alt_text_max_length","a11ychecker_filter_issue","a11ychecker_html_version","a11ychecker_issue_url_callback","ai_request","ai_shortcuts","inlinecss_selector_filter","inlinecss_file_filter","linkchecker_service_url","linkchecker_preprocess","linkchecker_content_css","tiny_pageembed_classes","tiny_pageembed_inline_styles","fullpagehtml_default_doctype","fullpagehtml_default_title","fullpagehtml_default_encoding","fullpagehtml_default_body_style","fullpagehtml_hide_in_source_view","mediaembed_service_url","mediaembed_max_width","mediaembed_inline_styles","advtable_value_series","advcode_prettify_editor","advcode_prettify_getcontent","advcode_inline","view_show","sidebar_show","editimage_toolbar","editimage_credentials_hosts","editimage_fetch_image","editimage_cors_hosts","editimage_proxy","editimage_proxy_service_url","editimage_upload_timeout","autocorrect_autocorrect","autocorrect_capitalize","autocorrect_service_url","typography_default_lang","typography_langs","typography_rules","typography_ignore","text_patterns","text_patterns_lookup","template_replace_values","template_preview_replace_values","template_selected_content_classes","template_cdate_classes","template_mdate_classes","template_cdate_format","template_mdate_format"]),On=n=>(Array.isArray(n)?n.join(" "):String(n??"")).split(/[\s,]+/).filter(Boolean);function My(n,e){return On(n.plugins).filter(t=>wy.has(t)||e(Sy[t]??t))}function aS(n){return/\/dash\//.test(n)?"dashes":/^common\/punctuation\/(quote|apostrophe)$/.test(n)?"quotes":n==="common/punctuation/hellip"?"ellipsis":n==="common/punctuation/delDoublePunctuation"||n.startsWith("common/space/")?"spaces":n==="common/symbols/arrow"?"arrows":n.startsWith("common/symbols/")?"symbols":n==="common/number/fraction"?"fractions":n.startsWith("common/number/")?"math":n.startsWith("common/nbsp/")?"nbsp":null}var cS={code:["code","code_block"],pre:["code_block"],a:["link"],strong:["bold"],b:["bold"],em:["italic"],i:["italic"],blockquote:["blockquote"]};function uS(n){let e={},t=n.typography_default_lang,r=Array.isArray(t)?t[0]:t;typeof r=="string"&&r&&(e.language=r.replace(/_/g,"-"));let o=n.typography_langs,s=(Array.isArray(o)?o:o&&typeof o=="object"?Object.keys(o):[]).filter(l=>typeof l=="string").map(l=>l.replace(/_/g,"-"));if(s.length&&(e.languages=s),Array.isArray(n.typography_rules)){let l=new Set(n.typography_rules.map(a=>typeof a=="string"?aS(a):null));e.rules=Object.fromEntries(["quotes","dashes","ellipsis","symbols","arrows","math","fractions","spaces","nbsp"].map(a=>[a,l.has(a)]))}if(Array.isArray(n.typography_ignore)){let l=n.typography_ignore.flatMap(a=>typeof a=="string"?cS[a.toLowerCase().replace(/\[.*$/,"")]??[]:[]);l.length&&(e.ignore=[...new Set(l)])}return e}function Os(n){if(typeof n=="string")return n.split(";").map(e=>e.trim()).filter(Boolean).map(e=>{let[t,r]=e.includes("=")?e.split("="):[e,e];return{label:t.trim(),value:(r??t).trim()}})}function dS(n){let e="",t=new Promise(o=>{let i=new FileReader;i.onload=()=>{e=String(i.result).replace(/^data:[^,]*,/,""),o()},i.onerror=()=>o(),i.readAsDataURL(n)}),r="";return{ready:t,info:{id:()=>n.name.replace(/\.[^.]+$/,"")||"image",name:()=>n.name.replace(/\.[^.]+$/,"")||"image",filename:()=>n.name||"image",blob:()=>n,base64:()=>e,blobUri:()=>r||(r=URL.createObjectURL(n)),uri:()=>{}}}}var pS=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre"]),fS=new Set(["span","strong","b","em","i","u","s","strike","del","code","sub","sup"]);function Ls(n){let e=Array.isArray(n)?n:[n],t=[];for(let r of e){if(!r||typeof r!="object")continue;let o=r,i={};typeof o.block=="string"&&pS.has(o.block.toLowerCase())&&(i.block=o.block.toLowerCase()),typeof o.inline=="string"&&fS.has(o.inline.toLowerCase())&&(i.inline=o.inline.toLowerCase()),typeof o.selector=="string"&&(i.selector=o.selector),(typeof o.classes=="string"||Array.isArray(o.classes))&&(i.classes=o.classes),o.styles&&typeof o.styles=="object"&&(i.styles=Object.fromEntries(Object.entries(o.styles).filter(([,s])=>typeof s=="string"&&!s.includes("%")).map(([s,l])=>[s.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`),l]))),(i.block||i.inline||i.selector)&&t.push(i)}return t}function Ey(n){return Array.isArray(n)?n.flatMap(e=>{if(!e||typeof e!="object")return[];let t=e,r=String(t.title??"");if(!r)return[];if(Array.isArray(t.items))return[{title:r,items:Ey(t.items)}];if(typeof t.format=="string")return[{title:r,format:t.format}];let[o]=Ls(t);return o?[{title:r,...o}]:[]}):[]}function Cy(n){return n.flatMap(e=>{if(!e||typeof e!="object")return[];let t=e,r=typeof t.title=="string"?t.title:"";return r?Array.isArray(t.subprompts)?[{title:r,items:Cy(t.subprompts)}]:typeof t.prompt!="string"?[]:[{title:r,prompt:t.prompt,...typeof t.selection=="boolean"?{selection:t.selection}:{}}]:[]})}function Ay(n){let e=Object.keys(n).filter(b=>!lS.has(b)),t=[],r=[];for(let b of On(n.plugins)){let E=Sy[b]??b;wy.has(b)||(Co(E)?t.push(E):r.push(b))}t.includes("ai")&&!t.includes("suggestions")&&t.splice(t.indexOf("ai"),0,"suggestions"),t.includes("mediaembed")&&!t.includes("media")&&t.splice(t.indexOf("mediaembed"),0,"media");let o={plugins:t};n.toolbar===!1?o.toolbar=!1:Array.isArray(n.toolbar)?o.toolbar=n.toolbar.join(" | "):typeof n.toolbar=="string"&&(o.toolbar=n.toolbar),n.menubar!==void 0&&(o.menubar=n.menubar),n.text_patterns===!1&&(o.textPatterns=!1),typeof n.statusbar=="boolean"&&(o.statusbar=n.statusbar),typeof n.placeholder=="string"&&(o.placeholder=n.placeholder),n.readonly===!0&&(o.editable=!1),typeof n.content_style=="string"&&(o.contentStyle=n.content_style);let i=b=>Array.isArray(b)?b.filter(E=>!!E&&typeof E.title=="string"&&typeof E.value=="string").map(({title:E,value:_})=>({title:E,value:_})):void 0,s=i(n.table_class_list);s&&(o.tableClassList=s);let l=i(n.table_cell_class_list);if(l&&(o.tableCellClassList=l),n.formats&&typeof n.formats=="object"&&(o.formats=Object.fromEntries(Object.entries(n.formats).map(([b,E])=>[b,Ls(E)]).filter(([,b])=>b.length))),Array.isArray(n.style_formats)&&(o.styleFormats=Ey(n.style_formats),n.style_formats_merge===!0&&(o.styleFormatsMerge=!0)),typeof n.valid_classes=="string"?o.validClasses=On(n.valid_classes):n.valid_classes&&typeof n.valid_classes=="object"?o.validClasses=Object.values(n.valid_classes).flatMap(b=>On(b)):o.validClasses=!0,n.content_css!==void 0&&n.content_css!==!1){let b=new Set(["default","dark","document","writer","tinymce-5","tinymce-5-dark"]),E=(Array.isArray(n.content_css)?n.content_css:String(n.content_css).split(",")).map(_=>String(_).trim()).filter(_=>_&&!b.has(_));E.length&&(o.contentCss=E)}n.disabled===!0&&(o.disabled=!0),n.resize!==!1&&(o.resize=n.resize==="both"?"both":!0);let a=Os(n.block_formats);if(a){let b=["p","h1","h2","h3","h4","h5","h6","pre"];o.blockFormats=a.map(({label:E,value:_})=>({label:E,block:_.toLowerCase()})).filter(E=>b.includes(E.block))}if(typeof n.language=="string"&&(o.language=n.language.replace("_","-")),typeof n.content_language=="string"&&n.content_language&&(o.contentLanguage=n.content_language.replace(/_/g,"-")),o.contentLangs=Array.isArray(n.content_langs)?n.content_langs.flatMap(b=>{let{code:E,title:_}=b??{};return typeof E=="string"?[{code:E,...typeof _=="string"?{title:_}:{}}]:[]}):[],typeof n.toolbar_sticky_offset=="number"&&(o.toolbarStickyOffset=n.toolbar_sticky_offset),(n.toolbar_mode==="floating"||n.toolbar_mode==="sliding"||n.toolbar_mode==="scrolling"||n.toolbar_mode==="wrap")&&(o.toolbarMode=n.toolbar_mode),n.inline===!0&&(o.mode="inline"),n.paste_as_text===!0&&(o.pasteAsText=!0),typeof n.paste_preprocess=="function"){let b=n.paste_preprocess;o.pastePreprocess=(E,_)=>{let N={content:E};return b(_,N),N.content}}typeof n.invalid_elements=="string"&&(o.invalidElements=n.invalid_elements),typeof n.valid_elements=="string"&&(o.validElements=n.valid_elements),typeof n.extended_valid_elements=="string"&&(o.extendedValidElements=n.extended_valid_elements),typeof n.custom_elements=="string"&&(o.customElements=n.custom_elements),(n.directionality==="rtl"||n.directionality==="ltr")&&(o.direction=n.directionality),n.valid_styles&&(o.validStyles=n.valid_styles);let c=Os(n.font_family_formats);c&&(o.fontFamilies=c);let u=Os(n.font_size_formats);u&&(o.fontSizes=u.map(b=>b.value));let d=Os(n.line_height_formats);if(d&&(o.lineHeights=d.map(b=>b.value)),Array.isArray(n.color_map)&&(o.colors=n.color_map.filter((b,E)=>E%2===0).map(b=>b.startsWith("#")?b:`#${b}`)),typeof n.images_upload_handler=="function"){let b=n.images_upload_handler,E=async(_,N)=>{let{ready:$,info:K}=dS(_);return await $,b(K,N)};o.uploadImage=E}if(typeof n.file_picker_callback=="function"){let b=n.file_picker_callback;typeof n.file_picker_types=="string"&&(o.filePickerTypes=On(n.file_picker_types).filter(E=>E==="file"||E==="image"||E==="media")),o.filePicker=({type:E,value:_})=>new Promise(N=>b(($,K={})=>N({url:$,...K}),_,{filetype:E,fieldname:"src"}))}let p={};if(n.autosave_interval||n.autosave_retention||n.autosave_prefix){let b=E=>parseInt(String(E),10);p.autosave={...n.autosave_interval?{delay:b(n.autosave_interval)*1e3}:{},...n.autosave_retention?{retention:b(n.autosave_retention)}:{},...n.autosave_prefix?{key:String(n.autosave_prefix)}:{}}}if((n.quickbars_selection_toolbar!==void 0||n.quickbars_insert_toolbar!==void 0)&&(p.quickbars={...n.quickbars_selection_toolbar!==void 0?{selection:n.quickbars_selection_toolbar}:{},...n.quickbars_insert_toolbar!==void 0?{insert:n.quickbars_insert_toolbar}:{}}),typeof n.mentions_fetch=="function"){let b=n.mentions_fetch;p.mentions={fetch:E=>new Promise(_=>b({term:E},_))}}if(n.tinycomments_author&&(p.comments={author:{id:String(n.tinycomments_author),name:String(n.tinycomments_author_name??n.tinycomments_author)}}),Array.isArray(n.codesample_languages)){let b=n.codesample_languages.flatMap(E=>{let{text:_,value:N}=E??{};return typeof N=="string"&&N?[{value:N,label:typeof _=="string"&&_?_:N}]:[]});p.codesample={languages:b}}let f=b=>b==="inherited"||b==="collapsed"||b==="expanded"?b:void 0;(n.details_initial_state||n.details_serialized_state)&&(p.accordion={...f(n.details_initial_state)?{initialState:f(n.details_initial_state)}:{},...f(n.details_serialized_state)?{serializedState:f(n.details_serialized_state)}:{}}),On(n.plugins).includes("tableofcontents")&&(p.tableofcontents={className:typeof n.tableofcontents_class=="string"?n.tableofcontents_class:"mce-toc",titleTag:typeof n.tableofcontents_header=="string"?n.tableofcontents_header:"h2",...n.tableofcontents_depth!==void 0?{depth:Number(n.tableofcontents_depth)}:{},...n.tableofcontents_orderedlist?{orderedList:!0}:{},...n.tableofcontents_includeheader===!1?{title:""}:{}}),Array.isArray(n.casechange_title_case_minors)&&(p.casechange={titleCaseMinors:n.casechange_title_case_minors.map(String)}),n.permanentpen_properties&&typeof n.permanentpen_properties=="object"&&(p.permanentpen={properties:{...n.permanentpen_properties}}),n.visualchars_default_state===!0&&(p.visualchars={default:!0});let h=Object.fromEntries([["append",n.importcss_append],["fileFilter",n.importcss_file_filter],["selectorFilter",n.importcss_selector_filter],["groups",n.importcss_groups],["exclusive",n.importcss_exclusive],["converter",n.importcss_selector_converter]].filter(([,b])=>b!==void 0));Object.keys(h).length&&(p.importcss=h);let m=n.templates,g=Object.fromEntries([["templates",typeof m=="function"?()=>new Promise(b=>m(b)):m],["values",n.template_replace_values],["previewValues",n.template_preview_replace_values],["selectedContentClasses",n.template_selected_content_classes],["creationDateClasses",n.template_cdate_classes],["modifiedDateClasses",n.template_mdate_classes],["creationDateFormat",n.template_cdate_format],["modifiedDateFormat",n.template_mdate_format]].filter(([,b])=>b!==void 0));Object.keys(g).length&&(p.template=g);let k={};typeof n.spellchecker_active=="boolean"&&(k.active=n.spellchecker_active);let x=n.content_language??n.spellchecker_language;typeof x=="string"&&x&&(k.language=x.replace(/_/g,"-")),typeof n.spellchecker_languages=="string"&&(k.languages=n.spellchecker_languages.split(",").map(b=>b.split("=")).filter(b=>b.length===2&&!!b[0].trim()&&!!b[1].trim()).map(([b,E])=>({name:b.trim(),code:E.trim().replace(/_/g,"-")})));let M=n.spellchecker_ignore_list,L=Array.isArray(M)?M:M&&typeof M=="object"?Object.values(M).flatMap(b=>Array.isArray(b)?b:[]):[];if(L.length&&(k.ignore=L.filter(b=>typeof b=="string")),typeof n.spellchecker_check=="function"&&(k.check=n.spellchecker_check),typeof n.spellchecker_languagetool_url=="string"&&(k.languageTool={url:n.spellchecker_languagetool_url}),Object.keys(k).length&&(p.spellchecker=k),On(n.plugins).includes("a11ychecker")){let b={allowDecorativeImages:(n.a11ychecker_allow_decorative_images??n.a11y_advanced_options)===!0};typeof n.a11ychecker_level=="string"&&(b.level=n.a11ychecker_level.toLowerCase()),typeof n.a11ychecker_ignored_rules=="string"&&(b.ignoredRules=n.a11ychecker_ignored_rules.split(",").map(_=>_.trim()).filter(Boolean)),typeof n.a11ychecker_alt_text_max_length=="number"&&(b.altTextMaxLength=n.a11ychecker_alt_text_max_length);let E=n.a11ychecker_filter_issue;typeof E=="function"&&(b.filterIssue=_=>E({..._,id:_.rule,contentID:_.text})!==!1),p.a11ychecker=b}let O=n.ai_shortcuts;O===!1||Array.isArray(O)&&!O.length?p.ai={shortcuts:!1}:Array.isArray(O)&&(p.ai={shortcuts:Cy(O)});let B={};(["string","function"].includes(typeof n.inlinecss_selector_filter)||n.inlinecss_selector_filter instanceof RegExp)&&(B.selectorFilter=n.inlinecss_selector_filter),(["string","function"].includes(typeof n.inlinecss_file_filter)||n.inlinecss_file_filter instanceof RegExp)&&(B.fileFilter=n.inlinecss_file_filter),Object.keys(B).length&&(p.email=B);let J={};typeof n.autocorrect_autocorrect=="boolean"&&(J.autocorrect=n.autocorrect_autocorrect),typeof n.autocorrect_capitalize=="boolean"&&(J.capitalize=n.autocorrect_capitalize),Object.keys(J).length&&(p.autocorrect=J);let P={};typeof n.linkchecker_service_url=="string"&&(P.serviceUrl=n.linkchecker_service_url);let G=n.linkchecker_preprocess;if(typeof G=="function"&&(P.preprocess=b=>{let E=G({url:b});return typeof E?.url=="string"?E.url:b}),Object.keys(P).length&&(p.linkchecker=P),t.includes("pageembed")){let b=n.tiny_pageembed_classes;p.pageembed={className:"tiny-pageembed",sizes:Array.isArray(b)?b.filter(E=>!!E&&typeof E.value=="string").map(E=>({value:E.value,...typeof E.text=="string"?{text:E.text}:{}})):["21by9","16by9","4by3","1by1"].map(E=>({value:`tiny-pageembed--${E}`})),inlineStyles:n.tiny_pageembed_inline_styles===!0}}if(t.includes("fullpagehtml")){let b={},E=(_,N)=>{typeof n[_]=="string"&&(b[N]=n[_])};E("fullpagehtml_default_doctype","doctype"),E("fullpagehtml_default_title","title"),E("fullpagehtml_default_encoding","encoding"),E("fullpagehtml_default_body_style","bodyStyle"),n.fullpagehtml_hide_in_source_view===!0&&(b.hideInSourceView=!0),Object.keys(b).length&&(p.fullpagehtml=b)}if(t.includes("mediaembed")){let b={className:"ephox-summary-card",inlineStyles:n.mediaembed_inline_styles===!0};typeof n.mediaembed_service_url=="string"&&n.mediaembed_service_url&&(b.serviceUrl=n.mediaembed_service_url);let E=Number(n.mediaembed_max_width);n.mediaembed_max_width!==void 0&&Number.isFinite(E)&&(b.maxWidth=E),p.mediaembed=b}let y=n.advtable_value_series;if(t.includes("advtable")&&y&&typeof y=="object"){let b={};for(let[E,_]of Object.entries(y)){let{title:N,generator:$}=_??{};if(typeof N!="string"||typeof $!="function")continue;let K;b[E]={title:N,value:se=>{se===0&&(K=void 0);let ot=$({sectionType:"tbody",cellType:"td",getRowType:()=>"body",classes:[],direction:"column",prev:K},se,0);K=ot;let Ve=ot?.value;return typeof Ve=="string"||typeof Ve=="number"?String(Ve):void 0}}}Object.keys(b).length&&(p.advtable={series:b})}if(t.includes("editimage")){let b={};typeof n.editimage_toolbar=="string"&&(b.toolbar=n.editimage_toolbar),Array.isArray(n.editimage_credentials_hosts)&&(b.credentialsHosts=n.editimage_credentials_hosts.filter(_=>typeof _=="string"));let E=n.editimage_fetch_image;typeof E=="function"&&(b.fetchImage=_=>{let N=document.createElement("img");return N.src=_,E(N)}),Object.keys(b).length&&(p.editimage=b)}t.includes("advcode")&&typeof n.advcode_prettify_editor=="boolean"&&(p.advcode={prettify:n.advcode_prettify_editor});let v=uS(n);return Object.keys(v).length&&(p.typography=v),Object.keys(p).length&&(o.pluginOptions=p),{options:o,unknown:e,missingPlugins:r}}var vd=null,yd=null;function Oy(){return yd??(yd=import(__novaChunk("tinymce-chunks/dialog-126a0355.js") ).then(n=>vd=n)),yd}function hS(n,e,t){if(vd)return vd.openSpecDialog(n,e,t);let r=null,o={...e.initialData??{}},i=[];Oy().then(l=>{r=l.openSpecDialog(n,{...e,initialData:o},t);for(let a of i.splice(0))a(r)},l=>console.error("[nova] windowManager: could not load dialogs",l));let s=l=>(...a)=>{let c=u=>u[l](...a);r?c(r):i.push(c)};return{getData:()=>r?r.getData():{...o},setData:l=>{r?r.setData(l):o={...o,...l}},close:s("close"),block:s("block"),unblock:s("unblock"),focus:s("focus"),disable:s("disable"),enable:s("enable"),showTab:s("showTab"),redial:s("redial")}}var Ps={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike",superscript:"superscript",subscript:"subscript",justifyleft:"alignLeft",justifycenter:"alignCenter",justifyright:"alignRight",justifyfull:"alignJustify",insertunorderedlist:"bulletList",insertorderedlist:"orderedList",indent:"indent",outdent:"outdent",undo:"undo",redo:"redo",removeformat:"clearFormatting",unlink:"unlink",inserthorizontalrule:"horizontalRule",mceblockquote:"blockquote"},wo={mcelowercase:"lowercase",mceuppercase:"uppercase",mcetitlecase:"titlecase",mcetoggleformatpainter:"formatpainter",mcetogglepermanentpen:"permanentpen",mceconfigurepermanentpen:"configurepermanentpen",mcevisualchars:"visualchars",mcesave:"save",mcecancel:"cancel",mcetemplate:"template",mceinsertfootnote:"footnotes",mceupdatefootnotes:"footnotesupdate",mcespellcheckdialog:"spellcheckdialog",mcetypography:"typography",mcecodeeditor:"code",mceimagerotateleft:"rotateleft",mceimagerotateright:"rotateright",mceimageflipvertical:"flipv",mceimagefliphorizontal:"fliph",mceeditimage:"editimage",mcefullpagehtmlproperties:"fullpagehtml"},Ty=new Set(["mcespellcheckenable","mcespellcheckdisable","mcespellcheckupdate","mcespellcheckdialogclose"]),Ny={mceadvancedtablesort:()=>({command:"dialog"}),mcesorttablebycolumnasc:()=>({command:"sort",value:{by:"column",direction:"asc"}}),mcesorttablebycolumndesc:()=>({command:"sort",value:{by:"column",direction:"desc"}}),mcesorttablebyrowasc:()=>({command:"sort",value:{by:"row",direction:"asc"}}),mcesorttablebyrowdesc:()=>({command:"sort",value:{by:"row",direction:"desc"}}),mcesorttableadvanced:n=>{let e=n&&typeof n=="object"?n:{},t=Number(e.roworcol);return{command:"sort",value:{by:e.sortby==="row"?"row":"column",...Number.isInteger(t)&&t>=0?{index:t}:{},direction:e.order==="descending"?"desc":"asc",scope:e.sort==="selection"?"selection":"table"}}},mcetabletoggleseries:n=>({command:"series",value:n?.name})},mS=new Set(["insertaccordion","removeaccordion","toggleaccordion","toggleallaccordions"]),gS={p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",blockquote:"blockquote",pre:"codeBlock"},yS={bold:"bold",italic:"italic",underline:"underline","strike-through":"strike",link:"link",unlink:"unlink",image:"image",table:"table",undo:"undo",redo:"redo","align-left":"alignLeft","align-center":"alignCenter","align-right":"alignRight","align-justify":"alignJustify","unordered-list":"bulletList","ordered-list":"orderedList",indent:"indent",outdent:"outdent",quote:"blockquote","code-sample":"codeBlock","horizontal-rule":"horizontalRule","remove-formatting":"clearFormatting",fullscreen:"fullscreen",preview:"preview",sourcecode:"sourceCode",help:"help",print:"print",search:"search",copy:"copy","edit-block":"edit",checkmark:"check",close:"close",upload:"upload",subscript:"subscript",superscript:"superscript","paste-text":"pasteText","text-color":"textColor","highlight-bg-color":"highlight","line-height":"lineHeight"},bd={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike",superscript:"superscript",subscript:"subscript",code:"code",p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",blockquote:"blockquote",pre:"codeBlock",alignleft:"alignLeft",aligncenter:"alignCenter",alignright:"alignRight",alignjustify:"alignJustify"},bS=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre"]),kS=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre","alignleft","aligncenter","alignright","alignjustify"]),kd={forecolor:"color",hilitecolor:"background",fontname:"font_family",fontsize:"font_size"};function So(n){console.warn(`[nova] tinymce-compat: editor.dom.${n} changes the editor DOM directly, which NovaProse redraws from its document model. Use setContent, insertContent or editor.formatter instead.`)}var Ds=new Map;function Rs(n){if(typeof n!="string"||!n)return;if(Ds.has(n))return Ds.get(n);let e=yS[n]??(n in C?n:void 0);return e?C[e]:void 0}function vS(n){let e=!1,t=!0;return{state:{get active(){return e},get enabled(){return t}},api:{isActive:()=>e,setActive:r=>{e=r,n.core.updateUI()},isEnabled:()=>t,setEnabled:r=>{t=r,n.core.updateUI()},isDisabled:()=>!t,setDisabled:r=>{t=!r,n.core.updateUI()}}}}var Mo=class{constructor(e,t,r,o){S(this,"id");S(this,"core");S(this,"targetElm");S(this,"settings");S(this,"plugins",{});S(this,"initialized",!1);S(this,"removed",!1);S(this,"handlers",new Map);S(this,"dirty",!1);S(this,"teardowns",[]);S(this,"commands",new Map);S(this,"options",{get:e=>this.settings[e],set:(e,t)=>(this.settings[e]=t,e==="disabled"&&this.core.setDisabled(t===!0),!0),isSet:e=>e in this.settings,isRegistered:()=>!0,register:()=>{}});S(this,"mode",{get:()=>this.core.isEditable()?"design":"readonly",set:e=>this.core.setEditable(e!=="readonly"),isReadOnly:()=>!this.core.isEditable()});S(this,"undoManager",{undo:()=>this.core.exec("undo"),redo:()=>this.core.exec("redo"),hasUndo:()=>this.core.can("undo"),hasRedo:()=>this.core.can("redo"),add:()=>null,clear:()=>{},transact:e=>(e(),null),ignore:e=>e()});S(this,"selection",{getContent:(e={})=>e.format==="text"?this.core.selection.getText():this.core.selection.getHTML(),setContent:e=>this.insertContent(e),getNode:()=>this.core.selection.getNode()??this.core.view.dom,getStart:()=>this.selection.getNode(),getEnd:()=>this.selection.getNode(),isCollapsed:()=>this.core.selection.isCollapsed(),collapse:(e=!1)=>this.core.selection.collapse(e),setCursorLocation:(e,t=0)=>{e&&this.core.selection.setCursorLocation(e,t)},select:(e,t=!1)=>this.core.selection.select(e,t),getRng:()=>this.core.selection.getDOMRange(),setRng:e=>{let{view:t}=this.core;if(!e||!t.dom.contains(e.startContainer))return;let r=t.posAtDOM(e.startContainer,e.startOffset),o=t.dom.contains(e.endContainer)?t.posAtDOM(e.endContainer,e.endOffset):r;this.core.selection.setRange(r,o)},getBookmark:()=>this.core.selection.getBookmark(),moveToBookmark:e=>this.core.selection.moveToBookmark(e),scrollIntoView:()=>this.core.selection.scrollIntoView()});S(this,"notificationManager",{open:e=>this.core.ui.notify({text:e.text,...e.type?{type:e.type}:{},...e.timeout!==void 0?{timeout:e.timeout}:{}}),close:()=>{}});S(this,"windowManager",{alert:(e,t)=>{let r=document.createElement("p");r.textContent=e,this.core.ui.openDialog({title:"",body:r,onSubmit:()=>!0,...t?{onClose:t}:{}})},confirm:(e,t)=>{let r=document.createElement("p");r.textContent=e;let o=!1;this.core.ui.openDialog({title:"",body:r,submitLabel:"OK",onSubmit:()=>(o=!0,!0),onClose:()=>t?.(o)})},open:e=>hS(this.core,e,t=>this.windowManager.open(t))});S(this,"ui",{registry:{addIcon:(e,t)=>{Ds.set(e,t)},addButton:(e,t)=>this.addButton(e,t,!1),addToggleButton:(e,t)=>this.addButton(e,t,!0),addMenuButton:(e,t)=>{let r=[];t.fetch(i=>r=i);let o=Rs(t.icon);this.core.ui.registry.addMenuButton(e,{tooltip:t.tooltip??t.text??e,...o?{icon:o}:{text:t.text??e},items:()=>(t.fetch(i=>r=i),r.map((i,s)=>i.type==="separator"?{type:"separator"}:{id:`${e}-${s}`,label:i.text??"",onSelect:()=>i.onAction?.({})}))})},addMenuItem:(e,t)=>{let r=Rs(t.icon);this.core.ui.registry.addMenuItem(e,{text:t.text??e,...r?{icon:r}:{},onAction:()=>t.onAction?.({})})},addContextToolbar:(e,t)=>{this.core.ui.registry.addContextToolbar(e,{label:t.label??e,items:t.items,position:t.position==="node"?"node":"selection",predicate:()=>{let r=this.selection.getNode();return!!r&&this.getBody().contains(r)&&t.predicate(r)}})},addSidebar:(e,t)=>{let r=null,o={element:()=>r},i=Rs(t.icon);this.core.ui.registry.addSidebar(e,{title:t.tooltip??e,...i?{icon:i}:{},render:s=>{r=s;let l=t.onSetup?.(o);return typeof l=="function"?l:void 0},onShow:()=>t.onShow?.(o),onHide:()=>t.onHide?.(o)})},addView:(e,t)=>{this.core.ui.registry.addView(e,{buttons:(Array.isArray(t.buttons)?t.buttons:[]).filter(r=>typeof r?.text=="string").map(r=>({text:r.text,buttonType:r.buttonType==="primary"?"primary":"secondary",onAction:()=>r.onAction?.()})),...t.onShow?{onShow:t.onShow}:{},...t.onHide?{onHide:t.onHide}:{}})},addContextForm:()=>{console.warn("[nova] tinymce-compat: addContextForm is not supported yet")},getAll:()=>({})}});S(this,"dom",{select:(e,t)=>[...(t??this.getBody()).querySelectorAll(e)],get:e=>typeof e=="string"?this.getBody().querySelector(`#${CSS.escape(e)}`):e,getParent:(e,t)=>{let r=e instanceof Element?e:e?.parentElement??null;for(;r&&r!==this.getBody();){if(typeof t=="string"?r.matches(t):t(r))return r;r=r.parentElement}return null},getParents:(e,t)=>{let r=[],o=e instanceof Element?e:e?.parentElement??null;for(;o&&o!==this.getBody();)(!t||o.matches(t))&&r.push(o),o=o.parentElement;return r},is:(e,t)=>!!e?.matches(t),getAttrib:(e,t,r="")=>e?.getAttribute(t)??r,hasClass:(e,t)=>!!e?.classList.contains(t),getStyle:(e,t)=>e instanceof HTMLElement?e.style.getPropertyValue(t):"",getRoot:()=>this.getBody(),encode:e=>e.replace(/[&<>"']/g,t=>`&#${t.charCodeAt(0)};`),decode:e=>{let t=document.createElement("textarea");return t.innerHTML=e,t.value},create:(e,t={},r)=>{let o=document.createElement(e);for(let[i,s]of Object.entries(t))i.startsWith("on")||o.setAttribute(i,s);return r!==void 0&&(o.textContent=r),o},uniqueId:(e="mce_")=>`${e}${Math.random().toString(36).slice(2,10)}`,setAttrib:()=>So("setAttrib"),addClass:()=>So("addClass"),removeClass:()=>So("removeClass"),setStyle:()=>So("setStyle"),remove:()=>So("remove")});S(this,"formatter",{apply:(e,t={})=>this.applyFormat(e,t,"apply"),remove:e=>this.applyFormat(e,{},"remove"),toggle:(e,t={})=>this.applyFormat(e,t,this.formatter.match(e)?"remove":"apply"),match:e=>{if(this.core.formatter.has(e))return this.core.formatter.match(e);let t=e.toLowerCase();if(bS.has(t))return this.blockMatches(t);let r=bd[t];if(r)return this.core.isActive(r);let o=kd[t];if(!o)return!1;let{state:i}=this.core.view,{from:s,to:l,empty:a}=i.selection,c=i.schema.marks[o];return a||!c?kt(i,o)!==null:i.doc.rangeHasMark(s,l,c)},canApply:e=>this.core.formatter.has(e)||e.toLowerCase()in bd||e.toLowerCase()in kd,register:(e,t)=>{let r=typeof e=="string"?[[e,t]]:Object.entries(e);for(let[o,i]of r){let s=Ls(i);s.length?this.core.formatter.register(o,s):console.warn(`[nova] tinymce-compat: format "${o}" is not supported yet`)}},unregister:e=>this.core.formatter.unregister(e),get:e=>this.core.formatter.get(e)});this.core=e,this.targetElm=t,this.id=r,this.settings=o,setTimeout(()=>{Oy().catch(()=>{})},0)}getContent(e={}){let t={format:e.format??"html",content:""};return t.content=t.format==="text"?this.core.getText():this.core.getHTML({fullPage:e.fullpagehtml!==!1}),(e.prettify===!0||this.settings.advcode_prettify_getcontent===!0&&this.core.hasPlugin("advcode"))&&t.format!=="text"&&(t.content=Ns(t.content)),this.fire("GetContent",t),t.content}setContent(e,t={}){let r={content:e,...t};return this.fire("BeforeSetContent",r),this.core.setContent(r.content,{fullPage:t.fullpagehtml!==!1}),this.fire("SetContent",r),r.content}insertContent(e){this.core.insertContent(e)}resetContent(e){this.core.setContent(e??this.settings.__initialContent??"",{addToHistory:!1}),this.setDirty(!1)}getBody(){return this.core.view.dom}getElement(){return this.targetElm}getContainer(){return this.core.root}getContentAreaContainer(){return this.core.view.dom.parentElement??this.core.root}getDoc(){return this.core.root.ownerDocument}getWin(){return this.core.root.ownerDocument.defaultView}queryCommandValue(e){return e.toLowerCase()==="togglesidebar"?this.core.ui.sidebar.active??"":e.toLowerCase()==="toggleview"?this.core.ui.view.active??"":""}execCommand(e,t,r){let o=e.toLowerCase(),i=!1;if(Ps[o])i=this.core.exec(Ps[o]);else if(o==="formatblock"||o==="mcetoggleformat"){let s=gS[String(r??"").toLowerCase()];i=s?this.core.exec(s):!1}else if(o==="mceinsertcontent"||o==="inserthtml")this.insertContent(String(r??"")),i=!0;else if(o==="toggleview")this.core.ui.view.toggle(String(r??"")),i=!0;else if(o==="togglesidebar")this.core.ui.sidebar.toggle(String(r??"")),i=!0;else if((o==="mceaidialog"||o==="mceaidialogclose")&&this.core.hasPlugin("ai")){let s=r&&typeof r=="object"?r:{},l={...typeof s.prompt=="string"?{prompt:s.prompt}:{},...s.generate===!0?{generate:!0}:{},...s.display===!1?{display:!1}:{}};this.core.root.dispatchEvent(o==="mceaidialog"?new CustomEvent("nova-ai-dialog",{detail:l}):new CustomEvent("nova-ai-dialog-close")),i=!0}else if(o==="mcesetcontent")this.setContent(String(r??"")),i=!0;else if(o==="mceinserttoc"||o==="mceupdatetoc"){let s=this.core.ui.registry.get(o==="mceinserttoc"?"tableofcontents":"tableofcontentsupdate");s?.type==="button"&&(s.onAction(this.core),i=!0)}else if(Ny[o]&&this.core.hasPlugin("advtable"))this.core.root.dispatchEvent(new CustomEvent("nova-advtable",{detail:Ny[o](r)})),i=!0;else if(mS.has(o))i=this.accordionCommand(o,r);else if(o==="mceinserttemplate"&&this.core.hasPlugin("template"))this.core.root.dispatchEvent(new CustomEvent("nova-insert-template",{detail:String(r??"")})),i=!0;else if(Ty.has(o)&&this.core.hasPlugin("spellchecker"))i=this.spellcheckCommand(o);else if(wo[o]||o==="mcetogglestickyformatpainter")i=this.pluginCommand(o);else if(o==="codesample"){let s=this.core.ui.registry.get("codesample");s?.type==="button"&&(s.onAction(this.core),i=!0)}else if(o==="selectall"){let{state:s,dispatch:l}=this.core.view;l(s.tr.setSelection(new de(s.doc))),i=!0}else if(o==="mcecleanup")i=!0;else{let s=this.commands.get(o);s&&(s(t,r),i=!0)}return i&&this.fire("ExecCommand",{command:e,ui:t,value:r}),i}spellcheckCommand(e){if(e==="mcespellcheckdialogclose")return this.core.ui.closeOverlays(),!0;if(e==="mcespellcheckupdate")return!0;let t=this.core.ui.registry.get("spellchecker");if(!t)return!1;let r=!!t.isActive?.(this.core);return e==="mcespellcheckenable"!==r&&t.onAction(this.core),!0}accordionCommand(e,t){let{view:r}=this.core,{state:o}=r,i=o.selection.$from,s=null;for(let u=i.depth;u>0&&!s;u--){let d=i.node(u);d.type.name==="details"&&(s={pos:i.before(u),open:d.attrs.open!==!1})}if(e==="insertaccordion"||e==="removeaccordion"){if(e==="removeaccordion"!=!!s)return!1;let u=this.core.ui.registry.get("accordion");return u?.type!=="button"?!1:(u.onAction(this.core),!0)}let l=[];if(e==="toggleaccordion"?s&&l.push(s):o.doc.descendants((u,d)=>(u.type.name==="details"&&l.push({pos:d,open:u.attrs.open!==!1}),!u.isTextblock)),!l.length)return!1;let a=typeof t=="boolean"?t:!l.every(u=>u.open),c=o.tr;for(let u of l)c.setNodeAttribute(u.pos,"open",a);return r.dispatch(c.setMeta("addToHistory",!1)),!0}pluginCommand(e){let{registry:t}=this.core.ui;if(e==="mcetogglestickyformatpainter"){let o=t.get("formatpainter"),i=t.getMenuItem("formatpainter");return o?.type!=="button"||!i?!1:(i.isActive?.(this.core)?i.onAction(this.core):(o.onAction(this.core),o.onAction(this.core)),!0)}let r=t.getMenuItem(wo[e]);return!r||e!=="mcesave"&&r.isEnabled?.(this.core)===!1?!1:(r.onAction(this.core),!0)}queryCommandState(e){let t=e.toLowerCase(),r=Ps[t];return r?this.core.isActive(r):t==="mcetoggleformatpainter"||t==="mcetogglepermanentpen"?!!this.core.ui.registry.getMenuItem(wo[t])?.isActive?.(this.core):!1}queryCommandSupported(e){let t=e.toLowerCase();return t in Ps||["formatblock","mceinsertcontent","mcesetcontent"].includes(t)||t in wo&&!!this.core.ui.registry.getMenuItem(wo[t])||t==="mcetogglestickyformatpainter"&&this.core.ui.registry.has("formatpainter")||Ty.has(t)&&this.core.hasPlugin("spellchecker")||(t==="mceaidialog"||t==="mceaidialogclose")&&this.core.hasPlugin("ai")||this.commands.has(t)}addCommand(e,t){this.commands.set(e.toLowerCase(),t)}on(e,t,r=!1){for(let o of e.toLowerCase().split(/\s+/).filter(Boolean)){let i=this.handlers.get(o)??new Set;r?this.handlers.set(o,new Set([t,...i])):this.handlers.set(o,i.add(t))}return this}off(e,t){if(!e)return this.handlers.clear(),this;for(let r of e.toLowerCase().split(/\s+/).filter(Boolean))t?this.handlers.get(r)?.delete(t):this.handlers.delete(r);return this}once(e,t){let r=o=>(this.off(e,r),t(o));return this.on(e,r)}fire(e,t={}){let r=Object.assign(t,{type:e.toLowerCase(),target:this});for(let o of[...this.handlers.get(e.toLowerCase())??[]])try{o(r)}catch(i){console.error(`[nova] tinymce-compat: "${e}" handler failed`,i)}return r}fireNative(e,t){for(let r of[...this.handlers.get(e)??[]])try{r(t)}catch(o){console.error(`[nova] tinymce-compat: "${e}" handler failed`,o)}}static registerIcon(e,t){Ds.set(e,t)}dispatch(e,t){return this.fire(e,t)}hasEventListeners(e){return(this.handlers.get(e.toLowerCase())?.size??0)>0}isDirty(){return this.dirty}setDirty(e){let t=this.dirty!==e;this.dirty=e,t&&e&&this.fire("Dirty")}save(){let e=this.getContent(),t=this.fire("SaveContent",{content:e});return this.targetElm instanceof HTMLTextAreaElement&&(this.targetElm.value=String(t.content)),this.setDirty(!1),String(t.content)}focus(){this.core.focus()}hasFocus(){return this.core.view.hasFocus()}hide(){this.core.root.hidden=!0,this.targetElm instanceof HTMLTextAreaElement&&(this.targetElm.hidden=!1)}show(){this.core.root.hidden=!1,this.targetElm instanceof HTMLTextAreaElement&&(this.targetElm.hidden=!0)}isHidden(){return this.core.root.hidden===!0}getParam(e,t){return e in this.settings?this.settings[e]:t}addButton(e,t,r){let{api:o,state:i}=vS(this);t.enabled===!1&&o.setEnabled(!1),t.active&&o.setActive(!0);let s=Rs(t.icon);if(this.core.ui.registry.addButton(e,{tooltip:t.tooltip??t.text??e,...s?{icon:s}:{text:t.text??e},isEnabled:()=>i.enabled,...r?{isActive:()=>i.active}:{},onAction:()=>t.onAction?.(o)}),t.onSetup){let l=()=>{let a=t.onSetup(o);typeof a=="function"&&this.teardowns.push(a)};this.initialized?l():this.once("init",l)}}blockMatches(e){let{$from:t}=this.core.view.state.selection;for(let o=t.depth;o>0;o-=1){let i=t.node(o),s=i.type.name;if(e==="blockquote"&&s==="blockquote")return!0;if(o===t.depth){if(e==="p")return s==="paragraph";if(e==="pre")return s==="code_block";if(/^h[1-6]$/.test(e))return s==="heading"&&i.attrs.level===Number(e[1])}}let r=null;if(this.core.view.state.doc.descendants(o=>r||!o.isTextblock?!r:(r={name:o.type.name,level:o.attrs.level},!1)),!t.depth&&r){let o=r;if(e==="p")return o.name==="paragraph";if(e==="pre")return o.name==="code_block";if(/^h[1-6]$/.test(e))return o.name==="heading"&&o.level===Number(e[1])}return!1}applyFormat(e,t,r){if(this.core.formatter.has(e)){r==="apply"?this.core.formatter.apply(e):this.core.formatter.remove(e);return}let o=e.toLowerCase(),i=bd[o];if(i){let l=this.formatter.match(o);kS.has(o)?r==="apply"?this.core.exec(i):l&&this.core.exec("paragraph"):r==="apply"!==l&&this.core.exec(i);return}let s=kd[o];if(s){this.core.exec(Ht(s,r==="apply"?t.value??null:null));return}console.warn(`[nova] tinymce-compat: format "${e}" is not supported yet`)}remove(){if(this.removed)return;this.fire("remove"),this.save(),this.teardowns.splice(0).forEach(t=>t()),this.removed=!0,this.core.destroy(),this.core.root.remove(),this.settings.__wrapper?.remove(),this.targetElm.hidden=!1,this.off()}destroy(){this.remove()}};var Ly=new Set;function xd(n){Ly.has(n)||(Ly.add(n),console.warn(`[nova] tinymce-compat: ${n}`))}var xS=0,_s=n=>typeof n=="number"?`${n}px`:String(n);function wS(){Nu(xy);let n=[],e=new Map,t=null;async function r(i,s){var _;let l=n.find(N=>N.targetElm===i&&!N.removed);if(l)return l;let{options:a,unknown:c,missingPlugins:u}=Ay(s);c.length&&xd(`options not supported yet: ${c.join(", ")}`);let d=String(Array.isArray(s.plugins)?s.plugins.join(" "):s.plugins??"").split(/[\s,]+/).filter(N=>e.has(N)),p=u.filter(N=>!e.has(N));p.length&&xd(`plugins not available: ${p.join(", ")}`);let f=i.id||`mce_${++xS}`;i.id||(i.id=f);let h=i instanceof HTMLTextAreaElement,m=h?i.value:i.innerHTML,g={...s,__initialContent:m},k;s.inline===!0&&!h?(i.replaceChildren(),k=i):(k=document.createElement("div"),k.className="nova-compat",i.after(k),i.hidden=!0,g.__wrapper=k);let x,M=N=>{let $=N;if(!$||typeof $.start!="string")return null;if(typeof $.replacement=="string")return{start:$.start,replacement:$.replacement};let K=(Array.isArray($.format)?$.format:[$.format]).filter(Ae=>typeof Ae=="string"),se=typeof $.cmd=="string"?$.cmd:null;return!se&&!K.length?null:{start:$.start,...typeof $.end=="string"&&$.end?{end:$.end}:{},...$.trigger==="enter"?{trigger:"enter"}:{},value:$.value,command:(Ae,ot)=>{if(se)x.execCommand(se,!1,ot);else for(let Ve of K)x.formatter.apply(Ve)}}};Array.isArray(s.text_patterns)&&(a.textPatterns=s.text_patterns.map(M));let L=s.text_patterns_lookup;typeof L=="function"&&(a.textPatternsLookup=N=>{let $=L(N);return Array.isArray($)?$.map(M):[]},a.textPatterns||(a.textPatterns=[]));let O=s.save_onsavecallback,B=s.save_oncancelcallback,J={...s.save_enablewhendirty!==void 0?{enableWhenDirty:s.save_enablewhendirty!==!1}:{},...typeof O=="function"?{onSave:()=>(x.save(),O(x))}:{},...typeof B=="function"?{onCancel:()=>B(x)}:{}},P=s.ai_request,G=typeof P=="function"?{...a.pluginOptions?.ai,async*request(N){let{tinyAiRequest:$}=await import(__novaChunk("tinymce-chunks/ai-e0658729.js") );yield*$(P,(K,se)=>x?.fire(K,se))(N)}}:null,y={...a.pluginOptions,...Object.keys(J).length?{save:J}:{},...G?{ai:G}:{}},v=Ts({...a,...Object.keys(y).length?{pluginOptions:y}:{},element:k,content:m,setup:N=>{x=new Mo(N,i,f,g);for(let $ of d)try{let K=e.get($)(x,"");x.plugins[$]=K&&typeof K=="object"?K:{}}catch(K){console.error(`[nova] tinymce-compat: plugin "${$}" failed`,K)}s.setup?.(x)}});s.height!==void 0&&(v.root.style.height=_s(s.height)),s.min_height!==void 0&&(v.root.style.minHeight=_s(s.min_height)),s.max_height!==void 0&&(v.root.style.maxHeight=_s(s.max_height)),s.width!==void 0&&(v.root.style.width=_s(s.width));let b=!1;v.on("change",()=>{x.setDirty(!0),b=!0,x.fire("input")}),v.on("selectionChange",()=>{x.fire("NodeChange",{element:x.selection.getNode(),selectionChange:!0})}),v.on("focus",()=>{t=x,b=!1,x.fire("focus")}),v.on("blur",()=>{b&&x.fire("change",{level:{content:x.getContent()}}),b=!1,x.fire("blur")});for(let N of["keydown","keyup","keypress","click","dblclick","mousedown","mouseup","paste","copy","cut","drop"])v.view.dom.addEventListener(N,$=>x.fireNative(N,$));if(v.root.addEventListener("nova-ai-dialogopen",()=>x.fire("AIDialogOpen")),v.root.addEventListener("nova-ai-dialogclose",()=>x.fire("AIDialogClose")),v.root.addEventListener("nova-autocorrect-toggle",N=>{let{feature:$,on:K}=N.detail;x.fire(($==="capitalize"?"Capitalize":"Autocorrect")+(K?"Start":"End"))}),(h?i.form:i.closest("form"))?.addEventListener("submit",()=>x.save()),x.on("remove",()=>{let N=n.indexOf(x);N>=0&&n.splice(N,1),t===x&&(t=n[0]??null)}),n.push(x),t??(t=x),await v.ready,x.removed)return x;for(let N of My(s,$=>v.hasPlugin($)))(_=x.plugins)[N]??(_[N]={});return x.plugins.inlinecss&&(x.plugins.inlinecss.getContent=async()=>{x.fire("InlineCSS");let{emailHTML:N}=await import(__novaChunk("tinymce-chunks/email-1926dd8a.js") );return{html:await N(v,{document:!1})}}),x.initialized=!0,x.fire("init"),s.init_instance_callback?.(x),typeof s.view_show=="string"&&s.view_show?v.ui.view.show(s.view_show):typeof s.sidebar_show=="string"&&s.sidebar_show&&v.ui.sidebar.show(s.sidebar_show),x}return{majorVersion:"7",minorVersion:"0.0",novaprose:!0,get activeEditor(){return t},get editors(){return[...n]},async init(i){document.readyState==="loading"&&await new Promise(a=>document.addEventListener("DOMContentLoaded",a,{once:!0})),typeof i.language=="string"&&await cl(i.language.replace("_","-")).catch(a=>(console.warn("[nova] tinymce-compat: language pack failed to load",a),!1));let s=i.target?[i.target]:i.selector?[...document.querySelectorAll(i.selector)]:[];s.length||xd(`no elements match "${i.selector??""}"`);let l=[];for(let a of s)l.push(await r(a,i));return l},get:(i=>i===void 0?[...n]:typeof i=="number"?n[i]??null:n.find(s=>s.id===i)??null),remove(i){(i===void 0?[...n]:typeof i=="string"?n.filter(l=>l.id===i.replace(/^#/,"")||l.targetElm.matches(i)):[i]).forEach(l=>l.remove())},triggerSave(){n.forEach(i=>i.save())},execCommand(i,s,l){return t?.execCommand(i,s,l)??!1},PluginManager:{add:(i,s)=>{e.set(i,s)},get:i=>e.get(i),requireLangPack:()=>{},urls:{}},IconManager:{add:(i,s)=>{for(let[l,a]of Object.entries(s.icons??{}))Mo.registerIcon(l,a)}},util:{I18n:{translate:i=>i}}}}var Py=wS();Vt("ru",()=>import(__novaChunk("tinymce-chunks/ru-982f3476.js") ));Vt("de",()=>import(__novaChunk("tinymce-chunks/de-21549c7e.js") ));Vt("es",()=>import(__novaChunk("tinymce-chunks/es-1de93a3f.js") ));Vt("fr",()=>import(__novaChunk("tinymce-chunks/fr-6fbcca9f.js") ));Vt("it",()=>import(__novaChunk("tinymce-chunks/it-ca70815f.js") ));Vt("pt-BR",()=>import(__novaChunk("tinymce-chunks/pt-BR-f6958ec0.js") ));var Ry=document.currentScript;if(Ry?.src&&!document.querySelector("link[data-novaprose-css]")){let n=document.createElement("link");n.rel="stylesheet",n.href=Ry.src.replace(/[^/]*$/,"novaprose.css"),n.setAttribute("data-novaprose-css",""),document.head.append(n)}window.tinymce=Py;var V=globalThis.__novaprose_tinymce={};V["node_modules/.pnpm/prosemirror-history@1.5.2/node_modules/prosemirror-history/dist/index.js"]=Pc;V["node_modules/.pnpm/prosemirror-inputrules@1.7.0/node_modules/prosemirror-inputrules/dist/index.js"]=fu;V["node_modules/.pnpm/prosemirror-keymap@1.2.3/node_modules/prosemirror-keymap/dist/index.js"]=na;V["node_modules/.pnpm/prosemirror-model@1.25.13/node_modules/prosemirror-model/dist/index.js"]=Js;V["node_modules/.pnpm/prosemirror-schema-list@1.6.1/node_modules/prosemirror-schema-list/dist/index.js"]=ka;V["node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.js"]=il;V["node_modules/.pnpm/prosemirror-transform@1.12.7/node_modules/prosemirror-transform/dist/index.js"]=tl;V["node_modules/.pnpm/prosemirror-view@1.43.1/node_modules/prosemirror-view/dist/index.js"]=Zl;V["node_modules/.pnpm/w3c-keyname@2.2.8/node_modules/w3c-keyname/index.js"]=ea;V["packages/core/src/blocks.ts"]=_c;V["packages/core/src/code-language.ts"]=Ra;V["packages/core/src/commands.ts"]=Fc;V["packages/core/src/comments.ts"]=la;V["packages/core/src/content-css.ts"]=Wc;V["packages/core/src/document.ts"]=Ou;V["packages/core/src/editor.ts"]=dd;V["packages/core/src/element-id.ts"]=yl;V["packages/core/src/image.ts"]=au;V["packages/core/src/language.ts"]=Da;V["packages/core/src/link.ts"]=yu;V["packages/core/src/mark-views.ts"]=ld;V["packages/core/src/page.ts"]=$u;V["packages/core/src/parser.ts"]=Hu;V["packages/core/src/plugins.ts"]=Fs;V["packages/core/src/plugins/accordion.ts"]=gl;V["packages/core/src/plugins/advtable.ts"]=Xa;V["packages/core/src/plugins/comments.ts"]=fa;V["packages/core/src/plugins/footnotes.ts"]=wc;V["packages/core/src/plugins/fullpagehtml.ts"]=dc;V["packages/core/src/plugins/index.ts"]=gm;V["packages/core/src/plugins/math.ts"]=vl;V["packages/core/src/plugins/media.ts"]=Wa;V["packages/core/src/plugins/mediaembed.ts"]=oc;V["packages/core/src/plugins/mentions.ts"]=ua;V["packages/core/src/plugins/mergetags.ts"]=ga;V["packages/core/src/plugins/pageembed.ts"]=Ja;V["packages/core/src/plugins/pagelayout.ts"]=yc;V["packages/core/src/plugins/shared.ts"]=ul;V["packages/core/src/plugins/suggestions.ts"]=La;V["packages/core/src/plugins/tableofcontents.ts"]=Sl;V["packages/core/src/pretty-html.ts"]=fd;V["packages/core/src/schema.ts"]=qa;V["packages/core/src/search.ts"]=Ku;V["packages/core/src/serializer.ts"]=sc;V["packages/core/src/tables.ts"]=Eu;V["packages/core/src/ui/builtins.ts"]=Zu;V["packages/core/src/ui/dialog.ts"]=Xc;V["packages/core/src/ui/dom.ts"]=ll;V["packages/core/src/ui/file-picker.ts"]=Jc;V["packages/core/src/ui/icons.ts"]=al;V["packages/core/src/ui/link-bubble.ts"]=nd;V["packages/core/src/ui/menu.ts"]=Bu;V["packages/core/src/ui/popover.ts"]=Qu;V["packages/core/src/ui/views.ts"]=Gu;V["packages/core/src/url.ts"]=Pa;})();
48
48
  //# sourceMappingURL=tinymce.global.js.map