@nextblock-cms/editor 0.2.24 → 0.8.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.
package/index.js CHANGED
@@ -1,21 +1,23 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C=require("react"),tu=require("react-dom"),De=require("@nextblock-cms/utils"),gt=require("@nextblock-cms/ui/popover"),le=require("@nextblock-cms/ui/button"),ns=require("@nextblock-cms/ui/input"),Ft=require("@nextblock-cms/ui/separator"),We=require("@nextblock-cms/ui/dropdown-menu"),at=require("@nextblock-cms/ui/card"),a1=require("@nextblock-cms/ui/badge");function rg(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const ne=rg(C),c1=rg(tu);function sg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var io={exports:{}},Ls={};var Yh;function d1(){if(Yh)return Ls;Yh=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,i){var o=null;if(i!==void 0&&(o=""+i),s.key!==void 0&&(o=""+s.key),"key"in s){i={};for(var l in s)l!=="key"&&(i[l]=s[l])}else i=s;return s=i.ref,{$$typeof:t,type:r,key:o,ref:s!==void 0?s:null,props:i}}return Ls.Fragment=e,Ls.jsx=n,Ls.jsxs=n,Ls}var Is={};var Xh;function u1(){return Xh||(Xh=1,process.env.NODE_ENV!=="production"&&(function(){function t(_){if(_==null)return null;if(typeof _=="function")return _.$$typeof===H?null:_.displayName||_.name||null;if(typeof _=="string")return _;switch(_){case y:return"Fragment";case w:return"Profiler";case b:return"StrictMode";case x:return"Suspense";case k:return"SuspenseList";case N:return"Activity"}if(typeof _=="object")switch(typeof _.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),_.$$typeof){case g:return"Portal";case S:return _.displayName||"Context";case A:return(_._context.displayName||"Context")+".Consumer";case M:var Z=_.render;return _=_.displayName,_||(_=Z.displayName||Z.name||"",_=_!==""?"ForwardRef("+_+")":"ForwardRef"),_;case v:return Z=_.displayName||null,Z!==null?Z:t(_.type)||"Memo";case T:Z=_._payload,_=_._init;try{return t(_(Z))}catch{}}return null}function e(_){return""+_}function n(_){try{e(_);var Z=!1}catch{Z=!0}if(Z){Z=console;var fe=Z.error,Se=typeof Symbol=="function"&&Symbol.toStringTag&&_[Symbol.toStringTag]||_.constructor.name||"Object";return fe.call(Z,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",Se),e(_)}}function r(_){if(_===y)return"<>";if(typeof _=="object"&&_!==null&&_.$$typeof===T)return"<...>";try{var Z=t(_);return Z?"<"+Z+">":"<...>"}catch{return"<...>"}}function s(){var _=V.A;return _===null?null:_.getOwner()}function i(){return Error("react-stack-top-frame")}function o(_){if($.call(_,"key")){var Z=Object.getOwnPropertyDescriptor(_,"key").get;if(Z&&Z.isReactWarning)return!1}return _.key!==void 0}function l(_,Z){function fe(){Q||(Q=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",Z))}fe.isReactWarning=!0,Object.defineProperty(_,"key",{get:fe,configurable:!0})}function a(){var _=t(this.type);return ie[_]||(ie[_]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),_=this.props.ref,_!==void 0?_:null}function c(_,Z,fe,Se,pn,fr){var $e=fe.ref;return _={$$typeof:p,type:_,key:Z,props:fe,_owner:Se},($e!==void 0?$e:null)!==null?Object.defineProperty(_,"ref",{enumerable:!1,get:a}):Object.defineProperty(_,"ref",{enumerable:!1,value:null}),_._store={},Object.defineProperty(_._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(_,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(_,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:pn}),Object.defineProperty(_,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:fr}),Object.freeze&&(Object.freeze(_.props),Object.freeze(_)),_}function d(_,Z,fe,Se,pn,fr){var $e=Z.children;if($e!==void 0)if(Se)if(I($e)){for(Se=0;Se<$e.length;Se++)u($e[Se]);Object.freeze&&Object.freeze($e)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else u($e);if($.call(Z,"key")){$e=t(_);var Ln=Object.keys(Z).filter(function(qr){return qr!=="key"});Se=0<Ln.length?"{key: someKey, "+Ln.join(": ..., ")+": ...}":"{key: someKey}",xe[$e+Se]||(Ln=0<Ln.length?"{"+Ln.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const E=require("react"),pc=require("react-dom"),Ie=require("@nextblock-cms/utils"),St=require("@nextblock-cms/ui/popover"),ae=require("@nextblock-cms/ui/button"),Ss=require("@nextblock-cms/ui/input"),tn=require("@nextblock-cms/ui/separator"),We=require("@nextblock-cms/ui/dropdown-menu"),ht=require("@nextblock-cms/ui/card"),fS=require("@nextblock-cms/ui/badge");function mb(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const se=mb(E),pS=mb(pc);function mS(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var tl={exports:{}},ui={};var Up;function gS(){if(Up)return ui;Up=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,i){var o=null;if(i!==void 0&&(o=""+i),s.key!==void 0&&(o=""+s.key),"key"in s){i={};for(var l in s)l!=="key"&&(i[l]=s[l])}else i=s;return s=i.ref,{$$typeof:t,type:r,key:o,ref:s!==void 0?s:null,props:i}}return ui.Fragment=e,ui.jsx=n,ui.jsxs=n,ui}var di={};var Vp;function yS(){return Vp||(Vp=1,process.env.NODE_ENV!=="production"&&(function(){function t(R){if(R==null)return null;if(typeof R=="function")return R.$$typeof===D?null:R.displayName||R.name||null;if(typeof R=="string")return R;switch(R){case y:return"Fragment";case x:return"Profiler";case b:return"StrictMode";case S:return"Suspense";case v:return"SuspenseList";case N:return"Activity"}if(typeof R=="object")switch(typeof R.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),R.$$typeof){case m:return"Portal";case k:return R.displayName||"Context";case w:return(R._context.displayName||"Context")+".Consumer";case T:var q=R.render;return R=R.displayName,R||(R=q.displayName||q.name||"",R=R!==""?"ForwardRef("+R+")":"ForwardRef"),R;case A:return q=R.displayName||null,q!==null?q:t(R.type)||"Memo";case C:q=R._payload,R=R._init;try{return t(R(q))}catch{}}return null}function e(R){return""+R}function n(R){try{e(R);var q=!1}catch{q=!0}if(q){q=console;var le=q.error,Se=typeof Symbol=="function"&&Symbol.toStringTag&&R[Symbol.toStringTag]||R.constructor.name||"Object";return le.call(q,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",Se),e(R)}}function r(R){if(R===y)return"<>";if(typeof R=="object"&&R!==null&&R.$$typeof===C)return"<...>";try{var q=t(R);return q?"<"+q+">":"<...>"}catch{return"<...>"}}function s(){var R=z.A;return R===null?null:R.getOwner()}function i(){return Error("react-stack-top-frame")}function o(R){if(L.call(R,"key")){var q=Object.getOwnPropertyDescriptor(R,"key").get;if(q&&q.isReactWarning)return!1}return R.key!==void 0}function l(R,q){function le(){ee||(ee=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",q))}le.isReactWarning=!0,Object.defineProperty(R,"key",{get:le,configurable:!0})}function a(){var R=t(this.type);return be[R]||(be[R]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),R=this.props.ref,R!==void 0?R:null}function c(R,q,le,Se,Ot,Ye){var Ce=le.ref;return R={$$typeof:p,type:R,key:q,props:le,_owner:Se},(Ce!==void 0?Ce:null)!==null?Object.defineProperty(R,"ref",{enumerable:!1,get:a}):Object.defineProperty(R,"ref",{enumerable:!1,value:null}),R._store={},Object.defineProperty(R._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(R,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(R,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Ot}),Object.defineProperty(R,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Ye}),Object.freeze&&(Object.freeze(R.props),Object.freeze(R)),R}function u(R,q,le,Se,Ot,Ye){var Ce=q.children;if(Ce!==void 0)if(Se)if(_(Ce)){for(Se=0;Se<Ce.length;Se++)d(Ce[Se]);Object.freeze&&Object.freeze(Ce)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else d(Ce);if(L.call(q,"key")){Ce=t(R);var Ze=Object.keys(q).filter(function(Dt){return Dt!=="key"});Se=0<Ze.length?"{key: someKey, "+Ze.join(": ..., ")+": ...}":"{key: someKey}",ne[Ce+Se]||(Ze=0<Ze.length?"{"+Ze.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
2
  let props = %s;
3
3
  <%s {...props} />
4
4
  React keys must be passed directly to JSX without using spread:
5
5
  let props = %s;
6
- <%s key={someKey} {...props} />`,Se,$e,Ln,$e),xe[$e+Se]=!0)}if($e=null,fe!==void 0&&(n(fe),$e=""+fe),o(Z)&&(n(Z.key),$e=""+Z.key),"key"in Z){fe={};for(var Zi in Z)Zi!=="key"&&(fe[Zi]=Z[Zi])}else fe=Z;return $e&&l(fe,typeof _=="function"?_.displayName||_.name||"Unknown":_),c(_,$e,fe,s(),pn,fr)}function u(_){h(_)?_._store&&(_._store.validated=1):typeof _=="object"&&_!==null&&_.$$typeof===T&&(_._payload.status==="fulfilled"?h(_._payload.value)&&_._payload.value._store&&(_._payload.value._store.validated=1):_._store&&(_._store.validated=1))}function h(_){return typeof _=="object"&&_!==null&&_.$$typeof===p}var f=C,p=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),S=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),x=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),H=Symbol.for("react.client.reference"),V=f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=Object.prototype.hasOwnProperty,I=Array.isArray,j=console.createTask?console.createTask:function(){return null};f={react_stack_bottom_frame:function(_){return _()}};var Q,ie={},F=f.react_stack_bottom_frame.bind(f,i)(),ue=j(r(i)),xe={};Is.Fragment=y,Is.jsx=function(_,Z,fe){var Se=1e4>V.recentlyCreatedOwnerStacks++;return d(_,Z,fe,!1,Se?Error("react-stack-top-frame"):F,Se?j(r(_)):ue)},Is.jsxs=function(_,Z,fe){var Se=1e4>V.recentlyCreatedOwnerStacks++;return d(_,Z,fe,!0,Se?Error("react-stack-top-frame"):F,Se?j(r(_)):ue)}})()),Is}var Zh;function h1(){return Zh||(Zh=1,process.env.NODE_ENV==="production"?io.exports=d1():io.exports=u1()),io.exports}var m=h1(),oo={exports:{}},Wa={};var Qh;function f1(){if(Qh)return Wa;Qh=1;var t=C;function e(u,h){return u===h&&(u!==0||1/u===1/h)||u!==u&&h!==h}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,s=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function l(u,h){var f=h(),p=r({inst:{value:f,getSnapshot:h}}),g=p[0].inst,y=p[1];return i(function(){g.value=f,g.getSnapshot=h,a(g)&&y({inst:g})},[u,f,h]),s(function(){return a(g)&&y({inst:g}),u(function(){a(g)&&y({inst:g})})},[u]),o(f),f}function a(u){var h=u.getSnapshot;u=u.value;try{var f=h();return!n(u,f)}catch{return!0}}function c(u,h){return h()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:l;return Wa.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,Wa}var qa={};var ef;function p1(){return ef||(ef=1,process.env.NODE_ENV!=="production"&&(function(){function t(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}function e(f,p){d||s.startTransition===void 0||(d=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var g=p();if(!u){var y=p();i(g,y)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}y=o({inst:{value:g,getSnapshot:p}});var b=y[0].inst,w=y[1];return a(function(){b.value=g,b.getSnapshot=p,n(b)&&w({inst:b})},[f,g,p]),l(function(){return n(b)&&w({inst:b}),f(function(){n(b)&&w({inst:b})})},[f]),c(g),g}function n(f){var p=f.getSnapshot;f=f.value;try{var g=p();return!i(f,g)}catch{return!0}}function r(f,p){return p()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=C,i=typeof Object.is=="function"?Object.is:t,o=s.useState,l=s.useEffect,a=s.useLayoutEffect,c=s.useDebugValue,d=!1,u=!1,h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:e;qa.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:h,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),qa}var tf;function nu(){return tf||(tf=1,process.env.NODE_ENV==="production"?oo.exports=f1():oo.exports=p1()),oo.exports}var ig=nu();function rt(t){this.content=t}rt.prototype={constructor:rt,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),i=r.content.slice();return s==-1?i.push(n||t,e):(i[s+1]=e,n&&(i[s]=n)),new rt(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new rt(n)},addToStart:function(t,e){return new rt([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new rt(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),i=r.find(t);return s.splice(i==-1?s.length:i,0,e,n),new rt(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=rt.from(t),t.size?new rt(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=rt.from(t),t.size?new rt(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=rt.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};rt.from=function(t){if(t instanceof rt)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new rt(e)};function og(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)n++;return n}if(s.content.size||i.content.size){let o=og(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function lg(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){n-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let c=0,d=Math.min(o.text.length,l.text.length);for(;c<d&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let c=lg(o.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}class O{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,l=0;l<n;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,n-d),r,s+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new O(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),s+=l.nodeSize),o=a}return new O(r,s)}cutByIndex(e,n){return e==n?O.empty:e==0&&n==this.content.length?this:new O(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new O(s,i)}addToStart(e){return new O([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new O(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return og(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return lg(this,e,n,r)}findIndex(e){if(e==0)return lo(0,e);if(e==this.size)return lo(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?lo(n+1,i):lo(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return O.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new O(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return O.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new O(n||e,r)}static from(e){if(!e)return O.empty;if(e instanceof O)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new O([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}O.empty=new O([],0);const Ka={index:0,offset:0};function lo(t,e){return Ka.index=t,Ka.offset=e,Ka}function Ko(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!Ko(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Ko(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Ee=class Hc{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Ko(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Hc.none;if(e instanceof Hc)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};Ee.none=[];class Go extends Error{}class P{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=cg(this.content,e+this.openStart,n);return r&&new P(r,this.openStart,this.openEnd)}removeBetween(e,n){return new P(ag(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return P.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new P(O.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new P(e,r,s)}}P.empty=new P(O.empty,0,0);function ag(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(ag(i.content,e-s-1,n-s-1)))}function cg(t,e,n,r){let{index:s,offset:i}=t.findIndex(e),o=t.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=cg(o.content,e-i-1,n,o);return l&&t.replaceChild(s,o.copy(l))}function m1(t,e,n){if(n.openStart>t.depth)throw new Go("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Go("Inconsistent open depths");return dg(t,e,n,0)}function dg(t,e,n,r){let s=t.index(r),i=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let o=dg(t,e,n,r+1);return i.copy(i.content.replaceChild(s,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return Cr(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=g1(n,t);return Cr(i,hg(t,o,l,e,r))}else return Cr(i,Jo(t,e,r))}function ug(t,e){if(!e.type.compatibleContent(t.type))throw new Go("Cannot join "+e.type.name+" onto "+t.type.name)}function zc(t,e,n){let r=t.node(n);return ug(r,e.node(n)),r}function Sr(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Vs(t,e,n,r){let s=(e||t).node(n),i=0,o=e?e.index(n):s.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Sr(t.nodeAfter,r),i++));for(let l=i;l<o;l++)Sr(s.child(l),r);e&&e.depth==n&&e.textOffset&&Sr(e.nodeBefore,r)}function Cr(t,e){return t.type.checkContent(e),t.copy(e)}function hg(t,e,n,r,s){let i=t.depth>s&&zc(t,e,s+1),o=r.depth>s&&zc(n,r,s+1),l=[];return Vs(null,t,s,l),i&&o&&e.index(s)==n.index(s)?(ug(i,o),Sr(Cr(i,hg(t,e,n,r,s+1)),l)):(i&&Sr(Cr(i,Jo(t,e,s+1)),l),Vs(e,n,s,l),o&&Sr(Cr(o,Jo(n,r,s+1)),l)),Vs(r,null,s,l),new O(l)}function Jo(t,e,n){let r=[];if(Vs(null,t,n,r),t.depth>n){let s=zc(t,e,n+1);Sr(Cr(s,Jo(t,e,n+1)),r)}return Vs(e,null,n,r),new O(r)}function g1(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)s=e.node(i).copy(O.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class ii{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Ee.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let l=r;r=s,s=l}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new oi(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,i=n;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(i),c=i-a;if(r.push(o,l,s+a),!c||(o=o.child(l),o.isText))break;i=c-1,s+=a+1}return new ii(n,r,i)}static resolveCached(e,n){let r=nf.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==n)return o}else nf.set(e,r=new y1);let s=r.elts[r.i]=ii.resolve(e,n);return r.i=(r.i+1)%b1,s}}class y1{constructor(){this.elts=[],this.i=0}}const b1=12,nf=new WeakMap;class oi{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const x1=Object.create(null);let Zn=class Fc{constructor(e,n,r,s=Ee.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||O.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,s=0){this.content.nodesBetween(e,n,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,s){return this.content.textBetween(e,n,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&Ko(this.attrs,n||e.defaultAttrs||x1)&&Ee.sameSet(this.marks,r||Ee.none)}copy(e=null){return e==this.content?this:new Fc(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Fc(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return P.empty;let s=this.resolve(e),i=this.resolve(n),o=r?0:s.sharedDepth(n),l=s.start(o),c=s.node(o).content.cut(s.pos-l,i.pos-l);return new P(c,s.depth-o,i.depth-o)}replace(e,n,r){return m1(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return ii.resolveCached(this,e)}resolveNoCache(e){return ii.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),fg(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=O.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=s;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Ee.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Ee.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=O.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,s,r);return i.type.checkAttrs(i.attrs),i}};Zn.prototype.text=void 0;class Yo extends Zn{constructor(e,n,r,s){if(super(e,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):fg(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Yo(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Yo(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function fg(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class _r{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new w1(e,n);if(r.next==null)return _r.empty;let s=pg(r);r.next&&r.err("Unexpected trailing text");let i=A1(M1(s));return T1(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let i=n;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function i(o,l){let a=o.matchFragment(e,r);if(a&&(!n||a.validEnd))return O.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:d,next:u}=o.next[c];if(!(d.isText||d.hasRequiredAttrs())&&s.indexOf(u)==-1){s.push(u);let h=i(u,l.concat(d));if(h)return h}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:a}=i.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
7
- `)}}_r.empty=new _r(!0);class w1{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function pg(t){let e=[];do e.push(k1(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function k1(t){let e=[];do e.push(v1(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function v1(t){let e=E1(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=S1(t,e);else break;return e}function rf(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function S1(t,e){let n=rf(t),r=n;return t.eat(",")&&(t.next!="}"?r=rf(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function C1(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let i in n){let o=n[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function E1(t){if(t.eat("(")){let e=pg(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=C1(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function M1(t){let e=[[]];return s(i(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function s(o,l){o.forEach(a=>a.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=i(o.exprs[a],l);if(a==o.exprs.length-1)return c;s(c,l=n())}else if(o.type=="star"){let a=n();return r(l,a),s(i(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=n();return s(i(o.expr,l),a),s(i(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let d=n();s(i(o.expr,a),d),a=d}if(o.max==-1)s(i(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let d=n();r(a,d),s(i(o.expr,a),d),a=d}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function mg(t,e){return e-t}function sf(t,e){let n=[];return r(e),n.sort(mg);function r(s){let i=t[s];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(s);for(let o=0;o<i.length;o++){let{term:l,to:a}=i[o];!l&&n.indexOf(a)==-1&&r(a)}}}function A1(t){let e=Object.create(null);return n(sf(t,0));function n(r){let s=[];r.forEach(o=>{t[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<s.length;d++)s[d][0]==l&&(c=s[d][1]);sf(t,a).forEach(d=>{c||s.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[r.join(",")]=new _r(r.indexOf(t.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(mg);i.next.push({type:s[o][0],next:e[l.join(",")]||n(l)})}return i}}function T1(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],i=!s.validEnd,o=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];o.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function gg(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function yg(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let i=t[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function bg(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${s}`);for(let s in t){let i=t[s];i.validate&&i.validate(e[s])}}function xg(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new _1(t,r,e[r]);return n}let of=class wg{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=xg(e,r.attrs),this.defaultAttrs=gg(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==_r.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:yg(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Zn(this,this.computeAttrs(e),O.from(n),Ee.setFrom(r))}createChecked(e=null,n,r){return n=O.from(n),this.checkContent(n),new Zn(this,this.computeAttrs(e),n,Ee.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=O.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let s=this.contentMatch.matchFragment(n),i=s&&s.fillBefore(O.empty,!0);return i?new Zn(this,e,n.append(i),Ee.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){bg(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:Ee.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,o)=>r[i]=new wg(i,n,o));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function N1(t,e,n){let r=n.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class _1{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?N1(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Zl{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=xg(e,s.attrs),this.excluded=null;let i=gg(this.attrs);this.instance=i?new Ee(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Ee(this,yg(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new Zl(i,s++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){bg(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class kg{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=rt.from(e.nodes),n.marks=rt.from(e.marks||{}),this.nodes=of.compile(this.spec.nodes,this),this.marks=Zl.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=_r.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?lf(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:lf(this,o.split(" "))}this.nodeFromJSON=s=>Zn.fromJSON(this,s),this.markFromJSON=s=>Ee.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof of){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,s)}text(e,n){let r=this.nodes.text;return new Yo(r,r.defaultAttrs,e,Ee.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function lf(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],i=t.marks[s],o=i;if(i)n.push(i);else for(let l in t.marks){let a=t.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function R1(t){return t.tag!=null}function O1(t){return t.style!=null}let Ws=class Uc{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(R1(s))this.tags.push(s);else if(O1(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new cf(this,n,!1);return r.addAll(e,Ee.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new cf(this,n,!0);return r.addAll(e,Ee.none,n.from,n.to),P.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(I1(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let a=o.getAttrs(n);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=df(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=df(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Uc(e,Uc.schemaRules(e)))}};const vg={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},D1={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Sg={ol:!0,ul:!0},li=1,Vc=2,qs=4;function af(t,e,n){return e!=null?(e?li:0)|(e==="full"?Vc:0):t&&t.whitespace=="pre"?li|Vc:n&~qs}class ao{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=Ee.none,this.match=i||(o&qs?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(O.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&li)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=O.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(O.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!vg.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class cf{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=af(null,n.preserveWhitespace,0)|(r?qs:0);s?i=new ao(s.type,s.attrs,Ee.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new ao(null,null,Ee.none,!0,null,o):i=new ao(e.schema.topNodeType,null,Ee.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&Vc?"full":this.localPreserveWS||(s.options&li)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
8
- `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(o.text(l[a]),n,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Sg.hasOwnProperty(o)&&this.parser.normalizeLists&&L1(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:D1.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,d=this.needsBlock;if(vg.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let u=a&&a.skip?n:this.readStyles(e,n);u&&this.addAll(e,u),c&&this.sync(i),this.needsBlock=d}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
9
- `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(i,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,s){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=Ee.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):uf(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=af(e,i,o.options);o.options&qs&&o.content.length==0&&(l|=qs);let a=Ee.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):uf(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new ao(e,n,a,s,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=li)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let d=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function L1(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Sg.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function I1(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function df(t){let e={};for(let n in t)e[n]=t[n];return e}function uf(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||i.indexOf(d)<0&&o(d))return!0}};if(o(s.contentMatch))return!0}}class Fr{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Ga(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],d=this.serializeMark(c,o.isInline,n);d&&(i.push([c,s]),s.appendChild(d.dom),s=d.contentDOM||d.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=Oo(Ga(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&Oo(Ga(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return Oo(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Fr(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=hf(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return hf(e.marks)}}function hf(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Ga(t){return t.document||window.document}const ff=new WeakMap;function j1(t){let e=ff.get(t);return e===void 0&&ff.set(t,e=P1(t)),e}function P1(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function Oo(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=j1(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let l,a=n?t.createElementNS(n,s):t.createElement(s),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let h=u.indexOf(" ");h>0?a.setAttributeNS(u.slice(0,h),u.slice(h+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let h=e[u];if(h===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:p}=Oo(t,h,n,r);if(a.appendChild(f),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Cg=65535,Eg=Math.pow(2,16);function B1(t,e){return t+e*Eg}function pf(t){return t&Cg}function $1(t){return(t-(t&Cg))/Eg}const Mg=1,Ag=2,Do=4,Tg=8;class Wc{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Tg)>0}get deletedBefore(){return(this.delInfo&(Mg|Do))>0}get deletedAfter(){return(this.delInfo&(Ag|Do))>0}get deletedAcross(){return(this.delInfo&Do)>0}}class _t{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&_t.empty)return _t.empty}recover(e){let n=0,r=pf(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+$1(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],d=this.ranges[l+o],u=a+c;if(e<=u){let h=c?e==a?-1:e==u?1:n:n,f=a+s+(h<0?0:d);if(r)return f;let p=e==(n<0?a:u)?null:B1(l/3,e-a),g=e==a?Ag:e==u?Mg:Do;return(n<0?e!=a:e!=u)&&(g|=Tg),new Wc(f,g,p)}s+=d-c}return r?e+s:new Wc(e+s,0,null)}touches(e,n){let r=0,s=pf(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+n],d=this.ranges[s+r];e(l,l+c,a,a+d),i+=d-c}}invert(){return new _t(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?_t.empty:new _t(e<0?[0,-e,0]:[0,0,e])}}_t.empty=new _t([]);class ai{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new ai(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new ai;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new Wc(e,s,null)}}const Ja=Object.create(null);class mt{getMap(){return _t.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Ja[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Ja)throw new RangeError("Duplicate use of step JSON ID "+e);return Ja[e]=n,n.prototype.jsonID=e,n}}class qe{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new qe(e,null)}static fail(e){return new qe(null,e)}static fromReplace(e,n,r,s){try{return qe.ok(e.replace(n,r,s))}catch(i){if(i instanceof Go)return qe.fail(i.message);throw i}}}function ru(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(ru(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return O.fromArray(r)}class Kn extends mt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new P(ru(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return qe.fromReplace(e,this.from,this.to,i)}invert(){return new Wt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Kn(n.pos,r.pos,this.mark)}merge(e){return e instanceof Kn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Kn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Kn(n.from,n.to,e.markFromJSON(n.mark))}}mt.jsonID("addMark",Kn);class Wt extends mt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new P(ru(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return qe.fromReplace(e,this.from,this.to,r)}invert(){return new Kn(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Wt(n.pos,r.pos,this.mark)}merge(e){return e instanceof Wt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Wt(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Wt(n.from,n.to,e.markFromJSON(n.mark))}}mt.jsonID("removeMark",Wt);class Gn extends mt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return qe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return qe.fromReplace(e,this.pos,this.pos+1,new P(O.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new Gn(this.pos,n.marks[s]);return new Gn(this.pos,this.mark)}}return new Rr(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Gn(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Gn(n.pos,e.markFromJSON(n.mark))}}mt.jsonID("addNodeMark",Gn);class Rr extends mt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return qe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return qe.fromReplace(e,this.pos,this.pos+1,new P(O.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Gn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Rr(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Rr(n.pos,e.markFromJSON(n.mark))}}mt.jsonID("removeNodeMark",Rr);class Ze extends mt{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&qc(e,this.from,this.to)?qe.fail("Structure replace would overwrite content"):qe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new _t([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ze(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new Ze(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ze)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?P.empty:new P(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ze(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?P.empty:new P(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ze(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ze(n.from,n.to,P.fromJSON(e,n.slice),!!n.structure)}}mt.jsonID("replace",Ze);class Qe extends mt{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(qc(e,this.from,this.gapFrom)||qc(e,this.gapTo,this.to)))return qe.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return qe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?qe.fromReplace(e,this.from,this.to,r):qe.fail("Content does not fit in gap")}getMap(){return new _t([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Qe(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new Qe(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Qe(n.from,n.to,n.gapFrom,n.gapTo,P.fromJSON(e,n.slice),n.insert,!!n.structure)}}mt.jsonID("replaceAround",Qe);function qc(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function H1(t,e,n,r){let s=[],i=[],o,l;t.doc.nodesBetween(e,n,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let h=Math.max(c,e),f=Math.min(c+a.nodeSize,n),p=r.addToSet(u);for(let g=0;g<u.length;g++)u[g].isInSet(p)||(o&&o.to==h&&o.mark.eq(u[g])?o.to=f:s.push(o=new Wt(h,f,u[g])));l&&l.to==h?l.to=f:i.push(l=new Kn(h,f,r))}}),s.forEach(a=>t.step(a)),i.forEach(a=>t.step(a))}function z1(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;i++;let a=null;if(r instanceof Zl){let c=o.marks,d;for(;d=r.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,n);for(let d=0;d<a.length;d++){let u=a[d],h;for(let f=0;f<s.length;f++){let p=s[f];p.step==i-1&&u.eq(s[f].style)&&(h=p)}h?(h.to=c,h.step=i):s.push({style:u,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(o=>t.step(new Wt(o.from,o.to,o.style)))}function su(t,e,n,r=n.contentMatch,s=!0){let i=t.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),d=l+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Ze(l,d,P.empty));else{r=u;for(let h=0;h<c.marks.length;h++)n.allowsMarkType(c.marks[h].type)||t.step(new Wt(l,d,c.marks[h]));if(s&&c.isText&&n.whitespace!="pre"){let h,f=/\r?\n|\r/g,p;for(;h=f.exec(c.text);)p||(p=new P(O.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),o.push(new Ze(l+h.index,l+h.index+h[0].length,p))}}l=d}if(!r.validEnd){let a=r.fillBefore(O.empty,!0);t.replace(l,l,new P(a,0,0))}for(let a=o.length-1;a>=0;a--)t.step(o[a])}function F1(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Cs(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let s=t.$from.node(r),i=t.$from.index(r),o=t.$to.indexAfter(r);if(r<t.depth&&s.canReplace(i,o,n))return r;if(r==0||s.type.spec.isolating||!F1(s,i,o))break}return null}function U1(t,e,n){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),l=s.after(i+1),a=o,c=l,d=O.empty,u=0;for(let p=i,g=!1;p>n;p--)g||r.index(p)>0?(g=!0,d=O.from(r.node(p).copy(d)),u++):a--;let h=O.empty,f=0;for(let p=i,g=!1;p>n;p--)g||s.after(p+1)<s.end(p)?(g=!0,h=O.from(s.node(p).copy(h)),f++):c++;t.step(new Qe(a,c,o,l,new P(d.append(h),u,f),d.size-u,!0))}function iu(t,e,n=null,r=t){let s=V1(t,e),i=s&&W1(r,e);return i?s.map(mf).concat({type:e,attrs:n}).concat(i.map(mf)):null}function mf(t){return{type:t,attrs:null}}function V1(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return n.canReplaceWith(r,s,o)?i:null}function W1(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:o}function q1(t,e,n){let r=O.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=O.from(n[o].type.create(n[o].attrs,r))}let s=e.start,i=e.end;t.step(new Qe(s,i,s,i,new P(r,0,0),n.length,!0))}function K1(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let a=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,a)&&G1(t.doc,t.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&_g(t,o,l,i),su(t,t.mapping.slice(i).map(l,1),r,void 0,c===null);let d=t.mapping.slice(i),u=d.map(l,1),h=d.map(l+o.nodeSize,1);return t.step(new Qe(u,h,u+1,h-1,new P(O.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&Ng(t,o,l,i),!1}})}function Ng(t,e,n,r){e.forEach((s,i)=>{if(s.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(s.text);){let a=t.mapping.slice(r).map(n+1+i+o.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function _g(t,e,n,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(`
10
- `))}})}function G1(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function J1(t,e,n,r,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Qe(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new P(O.from(o),0,0),1,!0))}function Mn(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,d=n-2;c>i;c--,d--){let u=s.node(c),h=s.index(c);if(u.type.spec.isolating)return!1;let f=u.content.cutByIndex(h,u.childCount),p=r&&r[d+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[d]||u;if(!u.canReplace(h+1,u.childCount)||!g.type.validContent(f))return!1}let l=s.indexAfter(i),a=r&&r[0];return s.node(i).canReplaceWith(l,l,a?a.type:s.node(i+1).type)}function Y1(t,e,n=1,r){let s=t.doc.resolve(e),i=O.empty,o=O.empty;for(let l=s.depth,a=s.depth-n,c=n-1;l>a;l--,c--){i=O.from(s.node(l).copy(i));let d=r&&r[c];o=O.from(d?d.type.create(d.attrs,o):s.node(l).copy(o))}t.step(new Ze(e,e,new P(i.append(o),n,n),!0))}function ur(t,e){let n=t.resolve(e),r=n.index();return Rg(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function X1(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function Rg(t,e){return!!(t&&e&&!t.isLeaf&&X1(t,e))}function Ql(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let i,o,l=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):n>0?(i=r.node(s+1),l++,o=r.node(s).maybeChild(l)):(i=r.node(s).maybeChild(l-1),o=r.node(s+1)),i&&!i.isTextblock&&Rg(i,o)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function Z1(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(s&&o.inlineContent){let d=o.whitespace=="pre",u=!!o.contentMatch.matchType(s);d&&!u?r=!1:!d&&u&&(r=!0)}let l=t.steps.length;if(r===!1){let d=t.doc.resolve(e+n);_g(t,d.node(),d.before(),l)}o.inlineContent&&su(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new Ze(c,a.map(e+n,-1),P.empty,!0)),r===!0){let d=t.doc.resolve(c);Ng(t,d.node(),d.before(),t.steps.length)}return t}function Q1(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,n))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,n))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function Og(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),d=!1;if(i==1)d=c.canReplace(a,a,s);else{let u=c.contentMatchAt(a).findWrapping(s.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function ea(t,e,n=e,r=P.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return Dg(s,i,r)?new Ze(e,n,r):new ek(s,i,r).fit()}function Dg(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class ek{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=O.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=O.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let a=new P(i,o,l);return e>-1?new Qe(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new Ze(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=Ya(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(n==1&&(o?c.matchType(o.type)||(u=c.fillBefore(O.from(o),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:u};if(n==2&&o&&(d=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Ya(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new P(e,n+1,Math.max(r,s.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Ya(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new P(Hs(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new P(Hs(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let g=0;g<i.length;g++)this.openFrontierNode(i[g]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,d=[],{match:u,type:h}=this.frontier[n];if(s){for(let g=0;g<s.childCount;g++)d.push(s.child(g));u=u.matchFragment(s)}let f=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let g=l.child(c),y=u.matchType(g.type);if(!y)break;c++,(c>1||a==0||g.content.size)&&(u=y,d.push(Lg(g.mark(h.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?f:-1)))}let p=c==l.childCount;p||(f=-1),this.placed=zs(this.placed,n,O.from(d)),this.frontier[n].match=u,p&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=l;g<f;g++){let b=y.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),y=b.content}this.unplaced=p?e==0?P.empty:new P(Hs(o.content,e-1,1),e-1,f<0?o.openEnd:e-1):new P(Hs(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Xa(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=Xa(e,n,s,r,i);if(o){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Xa(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=zs(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=zs(this.placed,this.depth,O.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(O.empty,!0);n.childCount&&(this.placed=zs(this.placed,this.frontier.length,n))}}function Hs(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Hs(t.firstChild.content,e-1,n)))}function zs(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(zs(t.lastChild.content,e-1,n)))}function Ya(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Lg(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Lg(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(O.empty,!0)))),t.copy(r)}function Xa(t,e,n,r,s){let i=t.node(e),o=s?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!tk(n,i.content,o)?l:null}function tk(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function nk(t){return t.spec.defining||t.spec.definingForContent}function rk(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(Dg(s,i,r))return t.step(new Ze(e,n,r));let o=jg(s,t.doc.resolve(n));o[o.length-1]==0&&o.pop();let l=-(s.depth+1);o.unshift(l);for(let h=s.depth,f=s.pos-1;h>0;h--,f--){let p=s.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(h)>-1?l=h:s.before(h)==f&&o.splice(1,0,-h)}let a=o.indexOf(l),c=[],d=r.openStart;for(let h=r.content,f=0;;f++){let p=h.firstChild;if(c.push(p),f==r.openStart)break;h=p.content}for(let h=d-1;h>=0;h--){let f=c[h],p=nk(f.type);if(p&&!f.sameMarkup(s.node(Math.abs(l)-1)))d=h;else if(p||!f.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let f=(h+d+1)%(r.openStart+1),p=c[f];if(p)for(let g=0;g<o.length;g++){let y=o[(g+a)%o.length],b=!0;y<0&&(b=!1,y=-y);let w=s.node(y-1),A=s.index(y-1);if(w.canReplaceWith(A,A,p.type,p.marks))return t.replace(s.before(y),b?i.after(y):n,new P(Ig(r.content,0,r.openStart,f),f,r.openEnd))}}let u=t.steps.length;for(let h=o.length-1;h>=0&&(t.replace(e,n,r),!(t.steps.length>u));h--){let f=o[h];f<0||(e=s.before(f),n=i.after(f))}}function Ig(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(Ig(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(O.empty,!0))}return t}function sk(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=Q1(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new P(O.from(r),0,0))}function ik(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n),i=jg(r,s);for(let o=0;o<i.length;o++){let l=i[o],a=o==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return t.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function jg(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}class rs extends mt{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return qe.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return qe.fromReplace(e,this.pos,this.pos+1,new P(O.from(s),0,n.isLeaf?0:1))}getMap(){return _t.empty}invert(e){return new rs(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new rs(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new rs(n.pos,n.attr,n.value)}}mt.jsonID("attr",rs);class ci extends mt{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return qe.ok(r)}getMap(){return _t.empty}invert(e){return new ci(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new ci(n.attr,n.value)}}mt.jsonID("docAttr",ci);let us=class extends Error{};us=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};us.prototype=Object.create(Error.prototype);us.prototype.constructor=us;us.prototype.name="TransformError";class ou{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ai}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new us(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=P.empty){let s=ea(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new P(O.from(r),0,0))}delete(e,n){return this.replace(e,n,P.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return rk(this,e,n,r),this}replaceRangeWith(e,n,r){return sk(this,e,n,r),this}deleteRange(e,n){return ik(this,e,n),this}lift(e,n){return U1(this,e,n),this}join(e,n=1){return Z1(this,e,n),this}wrap(e,n){return q1(this,e,n),this}setBlockType(e,n=e,r,s=null){return K1(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return J1(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new rs(e,n,r)),this}setDocAttribute(e,n){return this.step(new ci(e,n)),this}addNodeMark(e,n){return this.step(new Gn(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof Ee)n.isInSet(r.marks)&&this.step(new Rr(e,n));else{let s=r.marks,i,o=[];for(;i=n.isInSet(s);)o.push(new Rr(e,i)),s=i.removeFromSet(s);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return Y1(this,e,n,r),this}addMark(e,n,r){return H1(this,e,n,r),this}removeMark(e,n,r){return z1(this,e,n,r),this}clearIncompatible(e,n,r){return su(this,e,n,r),this}}const Za=Object.create(null);class ee{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new lu(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=P.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(c.pos),l?P.empty:n),l==0&&bf(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],a=e.mapping.slice(r),c=a.map(o.pos),d=a.map(l.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,n),bf(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new J(e):Xr(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?Xr(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Xr(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new St(e.node(0))}static atStart(e){return Xr(e,e,0,0,1)||new St(e)}static atEnd(e){return Xr(e,e,e.content.size,e.childCount,-1)||new St(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Za[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Za)throw new RangeError("Duplicate use of selection JSON ID "+e);return Za[e]=n,n.prototype.jsonID=e,n}getBookmark(){return J.between(this.$anchor,this.$head).getBookmark()}}ee.prototype.visible=!0;class lu{constructor(e,n){this.$from=e,this.$to=n}}let gf=!1;function yf(t){!gf&&!t.parent.inlineContent&&(gf=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class J extends ee{constructor(e,n=e){yf(e),yf(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return ee.near(r);let s=e.resolve(n.map(this.anchor));return new J(s.parent.inlineContent?s:r,r)}replace(e,n=P.empty){if(super.replace(e,n),n==P.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof J&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ta(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new J(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=ee.findFrom(n,r,!0)||ee.findFrom(n,-r,!0);if(i)n=i.$head;else return ee.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(ee.findFrom(e,-r,!0)||ee.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new J(e,n)}}ee.jsonID("text",J);class ta{constructor(e,n){this.anchor=e,this.head=n}map(e){return new ta(e.map(this.anchor),e.map(this.head))}resolve(e){return J.between(e.resolve(this.anchor),e.resolve(this.head))}}class q extends ee{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?ee.near(i):new q(i)}content(){return new P(O.from(this.node),0,0)}eq(e){return e instanceof q&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new au(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new q(e.resolve(n.anchor))}static create(e,n){return new q(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}q.prototype.visible=!1;ee.jsonID("node",q);class au{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new ta(r,r):new au(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&q.isSelectable(r)?new q(n):ee.near(n)}}class St extends ee{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=P.empty){if(n==P.empty){e.delete(0,e.doc.content.size);let r=ee.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new St(e)}map(e){return new St(e)}eq(e){return e instanceof St}getBookmark(){return ok}}ee.jsonID("all",St);const ok={map(){return this},resolve(t){return new St(t)}};function Xr(t,e,n,r,s,i=!1){if(e.inlineContent)return J.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&q.isSelectable(l))return q.create(t,n-(s<0?l.nodeSize:0))}else{let a=Xr(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function bf(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Ze||s instanceof Qe))return;let i=t.mapping.maps[r],o;i.forEach((l,a,c,d)=>{o==null&&(o=d)}),t.setSelection(ee.near(t.doc.resolve(o),n))}const xf=1,co=2,wf=4;let lk=class extends ou{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|xf)&~co,this.storedMarks=null,this}get selectionSet(){return(this.updated&xf)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=co,this}ensureMarks(e){return Ee.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&co)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~co,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Ee.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(ee.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=wf,this}get scrolledIntoView(){return(this.updated&wf)>0}};function kf(t,e){return!e||!t?t:t.bind(e)}class Fs{constructor(e,n,r){this.name=e,this.init=kf(n.init,r),this.apply=kf(n.apply,r)}}const ak=[new Fs("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Fs("selection",{init(t,e){return t.selection||ee.atStart(e.doc)},apply(t){return t.selection}}),new Fs("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Fs("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Qa{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ak.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Fs(r.key,r.spec.state,r))})}}class ts{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=s?s[o].n:0,c=s?s[o].state:this,d=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(d&&r.filterTransaction(d,o)){if(d.setMeta("appendedTransaction",e),!s){s=[];for(let u=0;u<this.config.plugins.length;u++)s.push(u<o?{state:r,n:n.length}:{state:this,n:0})}n.push(d),r=r.applyInner(d),i=!0}s&&(s[o]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new ts(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new lk(this)}static create(e){let n=new Qa(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new ts(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new Qa(this.schema,e.plugins),r=n.fields,s=new ts(n);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new Qa(e.schema,e.plugins),i=new ts(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=Zn.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=ee.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[o.name]=c.fromJSON.call(a,e,n[l],i);return}}i[o.name]=o.init(e,i)}}),i}}function Pg(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Pg(s,e,{})),n[r]=s}return n}class me{constructor(e){this.spec=e,this.props={},e.props&&Pg(e.props,this,this.props),this.key=e.key?e.key.key:Bg("plugin")}getState(e){return e[this.key]}}const ec=Object.create(null);function Bg(t){return t in ec?t+"$"+ ++ec[t]:(ec[t]=0,t+"$")}class ye{constructor(e="key"){this.key=Bg(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const cu=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function $g(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Hg=(t,e,n)=>{let r=$g(t,n);if(!r)return!1;let s=du(r);if(!s){let o=r.blockRange(),l=o&&Cs(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(Jg(t,s,e,-1))return!0;if(r.parent.content.size==0&&(hs(i,"end")||q.isSelectable(i)))for(let o=r.depth;;o--){let l=ea(t.doc,r.before(o),r.after(o),P.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(hs(i,"end")?ee.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):q.create(a.doc,s.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},ck=(t,e,n)=>{let r=$g(t,n);if(!r)return!1;let s=du(r);return s?zg(t,s,e):!1},dk=(t,e,n)=>{let r=Ug(t,n);if(!r)return!1;let s=uu(r);return s?zg(t,s,e):!1};function zg(t,e,n){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let d=s.lastChild;if(!d)return!1;s=d}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=ea(t.doc,i,a,P.empty);if(!c||c.from!=i||c instanceof Ze&&c.slice.size>=a-i)return!1;if(n){let d=t.tr.step(c);d.setSelection(J.create(d.doc,i)),n(d.scrollIntoView())}return!0}function hs(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const Fg=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=du(r)}let o=i&&i.nodeBefore;return!o||!q.isSelectable(o)?!1:(e&&e(t.tr.setSelection(q.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function du(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Ug(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Vg=(t,e,n)=>{let r=Ug(t,n);if(!r)return!1;let s=uu(r);if(!s)return!1;let i=s.nodeAfter;if(Jg(t,s,e,1))return!0;if(r.parent.content.size==0&&(hs(i,"start")||q.isSelectable(i))){let o=ea(t.doc,r.before(),r.after(),P.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(hs(i,"start")?ee.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):q.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},Wg=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=uu(r)}let o=i&&i.nodeAfter;return!o||!q.isSelectable(o)?!1:(e&&e(t.tr.setSelection(q.create(t.doc,i.pos)).scrollIntoView()),!0)};function uu(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const uk=(t,e)=>{let n=t.selection,r=n instanceof q,s;if(r){if(n.node.isTextblock||!ur(t.doc,n.from))return!1;s=n.from}else if(s=Ql(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(q.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},hk=(t,e)=>{let n=t.selection,r;if(n instanceof q){if(n.node.isTextblock||!ur(t.doc,n.to))return!1;r=n.to}else if(r=Ql(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},fk=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&Cs(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},qg=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
11
- `).scrollIntoView()),!0)};function hu(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const pk=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),i=n.indexAfter(-1),o=hu(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,o.createAndFill());a.setSelection(ee.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Kg=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof St||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=hu(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=t.tr.insert(o,i.createAndFill());l.setSelection(J.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Gg=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if(Mn(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Cs(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function mk(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof q&&e.selection.node.isBlock)return!r.parentOffset||!Mn(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,l,a=!1,c=!1;for(let f=r.depth;;f--)if(r.node(f).isBlock){a=r.end(f)==r.pos+(r.depth-f),c=r.start(f)==r.pos-(r.depth-f),l=hu(r.node(f-1).contentMatchAt(r.indexAfter(f-1))),i.unshift(a&&l?{type:l}:null),o=f;break}else{if(f==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof J||e.selection instanceof St)&&d.deleteSelection();let u=d.mapping.map(r.pos),h=Mn(d.doc,u,i.length,i);if(h||(i[0]=l?{type:l}:null,h=Mn(d.doc,u,i.length,i)),!h)return!1;if(d.split(u,i.length,i),!a&&c&&r.node(o).type!=l){let f=d.mapping.map(r.before(o)),p=d.doc.resolve(f);l&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(o)),l)}return n&&n(d.scrollIntoView()),!0}}const gk=mk(),yk=(t,e)=>{let{$from:n,to:r}=t.selection,s,i=n.sharedDepth(r);return i==0?!1:(s=n.before(i),e&&e(t.tr.setSelection(q.create(t.doc,s))),!0)};function bk(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||ur(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Jg(t,e,n,r){let s=e.nodeBefore,i=e.nodeAfter,o,l,a=s.type.spec.isolating||i.type.spec.isolating;if(!a&&bk(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(o[0]||i.type).validEnd){if(n){let f=e.pos+i.nodeSize,p=O.empty;for(let b=o.length-1;b>=0;b--)p=O.from(o[b].create(null,p));p=O.from(s.copy(p));let g=t.tr.step(new Qe(e.pos-1,f,e.pos,f,new P(p,1,0),o.length,!0)),y=g.doc.resolve(f+2*o.length);y.nodeAfter&&y.nodeAfter.type==s.type&&ur(g.doc,y.pos)&&g.join(y.pos),n(g.scrollIntoView())}return!0}let d=i.type.spec.isolating||r>0&&a?null:ee.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),h=u&&Cs(u);if(h!=null&&h>=e.depth)return n&&n(t.tr.lift(u,h).scrollIntoView()),!0;if(c&&hs(i,"start",!0)&&hs(s,"end")){let f=s,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let g=i,y=1;for(;!g.isTextblock;g=g.firstChild)y++;if(f.canReplace(f.childCount,f.childCount,g.content)){if(n){let b=O.empty;for(let A=p.length-1;A>=0;A--)b=O.from(p[A].copy(b));let w=t.tr.step(new Qe(e.pos-p.length,e.pos+i.nodeSize,e.pos+y,e.pos+i.nodeSize-y,new P(b,p.length,0),0,!0));n(w.scrollIntoView())}return!0}}return!1}function Yg(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(n&&n(e.tr.setSelection(J.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const xk=Yg(-1),wk=Yg(1);function kk(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i),l=o&&iu(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function vf(t,e=null){return function(n,r){let s=!1;for(let i=0;i<n.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(o,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)s=!0;else{let d=n.doc.resolve(c),u=d.index();s=d.parent.canReplaceWith(u,u+1,t)}})}if(!s)return!1;if(r){let i=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[o];i.setBlockType(l,a,t,e)}r(i.scrollIntoView())}return!0}}function fu(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}fu(cu,Hg,Fg);fu(cu,Vg,Wg);fu(qg,Kg,Gg,gk);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function vk(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i);if(!o)return!1;let l=r?n.tr:null;return Sk(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Sk(t,e,n,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);i=new oi(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new oi(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=iu(i,n,r,e);return l?(t&&Ck(t,e,l,s,n),!0):!1}function Ck(t,e,n,r,s){let i=O.empty;for(let d=n.length-1;d>=0;d--)i=O.from(n[d].type.create(n[d].attrs,i));t.step(new Qe(e.start-(r?2:0),e.end,e.start,e.end,new P(i,0,0),n.length,!0));let o=0;for(let d=0;d<n.length;d++)n[d].type==s&&(o=d+1);let l=n.length-o,a=e.start+n.length-(r?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,h=!0;d<u;d++,h=!1)!h&&Mn(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return t}function Ek(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?Mk(e,n,t,i):Ak(e,n,i):!0:!1}}function Mk(t,e,n,r){let s=t.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new Qe(i-1,o,i,o,new P(O.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new oi(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const l=Cs(r);if(l==null)return!1;s.lift(r,l);let a=s.doc.resolve(s.mapping.map(i,-1)-1);return ur(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function Ak(t,e,n){let r=t.tr,s=n.parent;for(let f=n.end,p=n.endIndex-1,g=n.startIndex;p>g;p--)f-=s.child(p).nodeSize,r.delete(f-1,f+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==s.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,o.content.append(a?O.empty:O.from(s))))return!1;let u=i.pos,h=u+o.nodeSize;return r.step(new Qe(u-(l?1:0),h+(a?1:0),u+1,h-1,new P((l?O.empty:O.from(s.copy(O.empty))).append(a?O.empty:O.from(s.copy(O.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Tk(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==t);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let l=i.parent,a=l.child(o-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,d=O.from(c?t.create():null),u=new P(O.from(t.create(null,O.from(l.type.create(null,d)))),c?3:1,0),h=i.start,f=i.end;n(e.tr.step(new Qe(h-(c?3:1),f,h,f,u,1,!0)).scrollIntoView())}return!0}}const st=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},fs=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Kc=null;const vn=function(t,e,n){let r=Kc||(Kc=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Nk=function(){Kc=null},Or=function(t,e,n,r){return n&&(Sf(t,e,n,r,-1)||Sf(t,e,n,r,1))},_k=/^(img|br|input|textarea|hr)$/i;function Sf(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:Pt(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Ri(t)||_k.test(t.nodeName)||t.contentEditable=="false")return!1;e=st(t)+(s<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=o,e=s<0?Pt(t):0}else return!1}}function Pt(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Rk(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Pt(t)}else if(t.parentNode&&!Ri(t))e=st(t),t=t.parentNode;else return null}}function Ok(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Ri(t))e=st(t)+1,t=t.parentNode;else return null}}function Dk(t,e,n){for(let r=e==0,s=e==Pt(t);r||s;){if(t==n)return!0;let i=st(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==Pt(t)}}function Ri(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const na=function(t){return t.focusNode&&Or(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function yr(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function Lk(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Ik(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Pt(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Pt(r.startContainer),r.startOffset)}}}const cn=typeof navigator<"u"?navigator:null,Cf=typeof document<"u"?document:null,hr=cn&&cn.userAgent||"",Gc=/Edge\/(\d+)/.exec(hr),Xg=/MSIE \d/.exec(hr),Jc=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(hr),Ct=!!(Xg||Jc||Gc),Qn=Xg?document.documentMode:Jc?+Jc[1]:Gc?+Gc[1]:0,$t=!Ct&&/gecko\/(\d+)/i.test(hr);$t&&+(/Firefox\/(\d+)/.exec(hr)||[0,0])[1];const Yc=!Ct&&/Chrome\/(\d+)/.exec(hr),dt=!!Yc,Zg=Yc?+Yc[1]:0,bt=!Ct&&!!cn&&/Apple Computer/.test(cn.vendor),ps=bt&&(/Mobile\/\w+/.test(hr)||!!cn&&cn.maxTouchPoints>2),jt=ps||(cn?/Mac/.test(cn.platform):!1),jk=cn?/Win/.test(cn.platform):!1,Cn=/Android \d/.test(hr),Oi=!!Cf&&"webkitFontSmoothing"in Cf.documentElement.style,Pk=Oi?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Bk(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function gn(t,e){return typeof t=="number"?t:t[e]}function $k(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Ef(t,e,n){let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=fs(o);continue}let l=o,a=l==i.body,c=a?Bk(i):$k(l),d=0,u=0;if(e.top<c.top+gn(r,"top")?u=-(c.top-e.top+gn(s,"top")):e.bottom>c.bottom-gn(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+gn(s,"top")-c.top:e.bottom-c.bottom+gn(s,"bottom")),e.left<c.left+gn(r,"left")?d=-(c.left-e.left+gn(s,"left")):e.right>c.right-gn(r,"right")&&(d=e.right-c.right+gn(s,"right")),d||u)if(a)i.defaultView.scrollBy(d,u);else{let f=l.scrollLeft,p=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let g=l.scrollLeft-f,y=l.scrollTop-p;e={left:e.left-g,top:e.top-y,right:e.right-g,bottom:e.bottom-y}}let h=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(h))break;o=h=="absolute"?o.offsetParent:fs(o)}}function Hk(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(i,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:Qg(t.dom)}}function Qg(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=fs(r));return e}function zk({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;ey(n,r==0?0:r-e)}function ey(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:i}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let Jr=null;function Fk(t){if(t.setActive)return t.setActive();if(Jr)return t.focus(Jr);let e=Qg(t);t.focus(Jr==null?{get preventScroll(){return Jr={preventScroll:!0},!0}}:void 0),Jr||(Jr=!1,ey(e,0))}function ty(t,e){let n,r=2e8,s,i=0,o=e.top,l=e.top,a,c;for(let d=t.firstChild,u=0;d;d=d.nextSibling,u++){let h;if(d.nodeType==1)h=d.getClientRects();else if(d.nodeType==3)h=vn(d).getClientRects();else continue;for(let f=0;f<h.length;f++){let p=h[f];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let g=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(g<r){n=d,r=g,s=g&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&g&&(i=u+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=u+1)}}return!n&&a&&(n=a,s=c,r=0),n&&n.nodeType==3?Uk(n,s):!n||r&&n.nodeType==1?{node:t,offset:i}:ty(n,s)}function Uk(t,e){let n=t.nodeValue.length,r=document.createRange();for(let s=0;s<n;s++){r.setEnd(t,s+1),r.setStart(t,s);let i=$n(r,1);if(i.top!=i.bottom&&pu(e,i))return{node:t,offset:s+(e.left>=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}function pu(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Vk(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function Wk(t,e,n){let{node:r,offset:s}=ty(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,s,i)}function qk(t,e,n,r){let s=-1;for(let i=e,o=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&a.left>r.left||a.top>r.top?s=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(s=l.posAfter),o=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function ny(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=s;;){let o=t.childNodes[i];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(pu(e,c))return ny(o,e,c)}}if((i=(i+1)%r)==s)break}return t}function Kk(t,e){let n=t.dom.ownerDocument,r,s=0,i=Ik(n,e.left,e.top);i&&({node:r,offset:s}=i);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=t.dom.getBoundingClientRect();if(!pu(e,c)||(o=ny(t.dom,e,c),!o))return null}if(bt)for(let c=o;r&&c;c=fs(c))c.draggable&&(r=void 0);if(o=Vk(o,e),r){if($t&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let d=r.childNodes[s],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&s++}let c;Oi&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=qk(t,r,s,e))}l==null&&(l=Wk(t,o,e));let a=t.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Mf(t){return t.top<t.bottom||t.left<t.right}function $n(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Mf(r))return r}return Array.prototype.find.call(n,Mf)||t.getBoundingClientRect()}const Gk=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ry(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),o=Oi||$t;if(r.nodeType==3)if(o&&(Gk.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let a=$n(vn(r,s,s),n);if($t&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=$n(vn(r,s-1,s-1),-1);if(c.top==a.top){let d=$n(vn(r,s,s+1),-1);if(d.top!=a.top)return js(d,d.left<c.left)}}return a}else{let a=s,c=s,d=n<0?1:-1;return n<0&&!s?(c++,d=-1):n>=0&&s==r.nodeValue.length?(a--,d=1):n<0?a--:c++,js($n(vn(r,a,c),d),d<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==Pt(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return tc(a.getBoundingClientRect(),!1)}if(i==null&&s<Pt(r)){let a=r.childNodes[s];if(a.nodeType==1)return tc(a.getBoundingClientRect(),!0)}return tc(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==Pt(r))){let a=r.childNodes[s-1],c=a.nodeType==3?vn(a,Pt(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return js($n(c,1),!1)}if(i==null&&s<Pt(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?vn(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return js($n(c,-1),!0)}return js($n(r.nodeType==3?vn(r):r,-n),n>=0)}function js(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function tc(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function sy(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function Jk(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return sy(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let o=ry(t,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=vn(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(n=="up"?o.top-d.top>(d.bottom-o.top)*2:d.bottom-o.bottom>(o.bottom-d.top)*2))return!1}}return!0})}const Yk=/[\u0590-\u08ac]/;function Xk(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,l=t.domSelection();return l?!Yk.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:o:sy(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=t.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",n,"character");let f=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:g}=t.domSelectionRange(),y=p&&!f.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==g;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return h!=null&&(l.caretBidiLevel=h),y}):r.pos==r.start()||r.pos==r.end()}let Af=null,Tf=null,Nf=!1;function Zk(t,e,n){return Af==e&&Tf==n?Nf:(Af=e,Tf=n,Nf=n=="up"||n=="down"?Jk(t,e,n):Xk(t,e,n))}const Ht=0,_f=1,xr=2,dn=3;class Di{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=Ht,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let s=this.children[n];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>st(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!n||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let l=s.children[o];if(l.size){s=l;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],l=i+o.size;if(l>e||o instanceof oy){s=e-i;break}i=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof iy&&i.side>=0;r--);if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?st(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?st(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(s==-1&&e<=c){let d=o+a.border;if(e>=d&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,d);e=o;for(let u=l;u>0;u--){let h=this.children[u-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){s=st(h.dom)+1;break}e-=h.size}s==-1&&(s=0)}if(s>-1&&(c>n||l==this.children.length-1)){n=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){i=st(u.dom);break}n+=u.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let i=Math.min(e,n),o=Math.max(e,n);for(let f=0,p=0;f<this.children.length;f++){let g=this.children[f],y=p+g.size;if(i>p&&o<y)return g.setSelection(e-p-g.border,n-p-g.border,r,s);p=y}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),d=r.domSelectionRange(),u=!1;if(($t||bt)&&e==n){let{node:f,offset:p}=l;if(f.nodeType==3){if(u=!!(p&&f.nodeValue[p-1]==`
12
- `),u&&p==f.nodeValue.length)for(let g=f,y;g;g=g.parentNode){if(y=g.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:st(y)+1});break}let b=g.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let g=f.childNodes[p-1];u=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if($t&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let f=d.focusNode.childNodes[d.focusOffset];f&&f.contentEditable=="false"&&(s=!0)}if(!(s||u&&bt)&&Or(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Or(a.node,a.offset,d.focusNode,d.focusOffset))return;let h=!1;if((c.extend||e==n)&&!(u&&$t)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),h=!0}catch{}}if(!h){if(e>n){let p=l;l=a,a=p}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+i.border,a=o-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==o?xr:_f,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=dn:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?xr:dn}r=o}this.dirty=xr}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?xr:_f;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class iy extends Di{constructor(e,n,r,s){let i,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==Ht&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Qk extends Di{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Dr extends Di{constructor(e,n,r,s,i){super(e,[],r,s),this.mark=n,this.spec=i}static create(e,n,r,s){let i=s.nodeViews[n.type.name],o=i&&i(n,s,r);return(!o||!o.dom)&&(o=Fr.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Dr(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&dn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=dn&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Ht){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ht}}slice(e,n,r){let s=Dr.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;n<o&&(i=Zc(i,n,o,r)),e>0&&(i=Zc(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class er extends Di{constructor(e,n,r,s,i,o,l,a,c){super(e,[],i,o),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,n,r,s,i,o){let l=i.nodeViews[n.type.name],a,c=l&&l(n,i,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,s),d=c&&c.dom,u=c&&c.contentDOM;if(n.isText){if(!d)d=document.createTextNode(n.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Fr.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!u&&!n.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),n.type.spec.draggable&&(d.draggable=!0));let h=d;return d=cy(d,r,n),c?a=new ev(e,n,r,s,d,u||null,h,c,i,o+1):n.isText?new ra(e,n,r,s,d,h,i):new er(e,n,r,s,d,u||null,h,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>O.empty)}return e}matchesNode(e,n,r){return this.dirty==Ht&&e.eq(this.node)&&Xo(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new nv(this,o&&o.node,e);iv(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?Ee.none:this.node.child(d).marks,r,e),a.placeWidget(c,e,s)},(c,d,u,h)=>{a.syncToMarks(c.marks,r,e);let f;a.findNodeMatch(c,d,u,h)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(f=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,d,u,f,e)||a.updateNextNode(c,d,u,e,h,s)||a.addNode(c,d,u,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==xr)&&(o&&this.protectLocalComposition(e,o),ly(this.contentDOM,this.children,e),ps&&ov(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof J)||r<n||s>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,l=lv(this.node.content,o,r-n,s-n);return l<0?null:{node:i,pos:l,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new Qk(this,i,n,s);e.input.compositionNodes.push(o),this.children=Zc(this.children,r,r+s.length,e,o)}update(e,n,r,s){return this.dirty==dn||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=Ht}updateOuterDeco(e){if(Xo(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=ay(this.dom,this.nodeDOM,Xc(this.outerDeco,this.node,n),Xc(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Rf(t,e,n,r,s){cy(r,e,t);let i=new er(void 0,t,e,n,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class ra extends er{constructor(e,n,r,s,i,o,l){super(e,n,r,s,i,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,s){return this.dirty==dn||this.dirty!=Ht&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Ht||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=Ht,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),i=document.createTextNode(s.text);return new ra(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=dn)}get domAtom(){return!1}isText(e){return this.node.text==e}}class oy extends Di{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ht&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class ev extends er{constructor(e,n,r,s,i,o,l,a,c,d){super(e,n,r,s,i,o,l,c,d),this.spec=a}update(e,n,r,s){if(this.dirty==dn)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function ly(t,e,n){let r=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=Of(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(l,r);if(o instanceof Dr){let a=r?r.previousSibling:t.lastChild;ly(o.contentDOM,o.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=Of(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const Ks=function(t){t&&(this.nodeName=t)};Ks.prototype=Object.create(null);const wr=[new Ks];function Xc(t,e,n){if(t.length==0)return wr;let r=n?wr[0]:new Ks,s=[r];for(let i=0;i<t.length;i++){let o=t[i].type.attrs;if(o){o.nodeName&&s.push(r=new Ks(o.nodeName));for(let l in o){let a=o[l];a!=null&&(n&&s.length==1&&s.push(r=new Ks(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return s}function ay(t,e,n,r){if(n==wr&&r==wr)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],l=n[i];if(i){let a;l&&l.nodeName==o.nodeName&&s!=t&&(a=s.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=wr[0]),s=a}tv(s,l||wr[0],o)}return s}function tv(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&t.classList.add(s[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function cy(t,e,n){return ay(t,t,wr,Xc(e,n,t.nodeType!=1))}function Xo(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Of(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class nv{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=rv(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let s=0,i=this.stack.length>>1,o=Math.min(i,e.length);for(;s<o&&(s==i-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<i;)this.destroyRest(),this.top.dirty=Ht,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[i])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Dr.create(this.top,e[i],n,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,n,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))i=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,s,i){let o=this.top.children[s];return o.dirty==dn&&o.dom==o.contentDOM&&(o.dirty=xr),o.update(e,n,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,i,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof er){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let d=a.dom,u,h=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=dn&&Xo(n,a.outerDeco));if(!h&&a.update(e,n,r,s))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(u=this.recreateWrapper(a,e,n,r,s,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=xr,u.updateChildren(s,o+1),u.dirty=Ht),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,i,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Xo(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=er.create(this.top,n,r,s,i,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,s,i){let o=er.create(this.top,e,n,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new iy(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Dr;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof ra)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((bt||dt)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new oy(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function rv(t,e){let n=e,r=n.children.length,s=t.childCount,i=new Map,o=[];e:for(;s>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof Dr)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(s-1))break;--s,i.set(l,s),o.push(l)}}return{index:s,matched:i,matches:o.reverse()}}function sv(t,e){return t.type.side-e.type.side}function iv(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let c=0;c<t.childCount;c++){let d=t.child(c);r(d,s,e.forChild(i,d),c),i+=d.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let d,u;for(;o<s.length&&s[o].to==i;){let y=s[o++];y.widget&&(d?(u||(u=[d])).push(y):d=y)}if(d)if(u){u.sort(sv);for(let y=0;y<u.length;y++)n(u[y],c,!!a)}else n(d,c,!!a);let h,f;if(a)f=-1,h=a,a=null;else if(c<t.childCount)f=c,h=t.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=i&&l.splice(y--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)l.push(s[o++]);let p=i+h.nodeSize;if(h.isText){let y=p;o<s.length&&s[o].from<y&&(y=s[o].from);for(let b=0;b<l.length;b++)l[b].to<y&&(y=l[b].to);y<p&&(a=h.cut(y-i),h=h.cut(0,y-i),p=y,f=-1)}else for(;o<s.length&&s[o].to<p;)o++;let g=h.isInline&&!h.isLeaf?l.filter(y=>!y.inline):l.slice();r(h,g,e.forChild(i,h),f),i=p}}function ov(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function lv(t,e,n,r){for(let s=0,i=0;s<t.childCount&&i<=r;){let o=t.child(s++),l=i;if(i+=o.nodeSize,!o.isText)continue;let a=o.text;for(;s<t.childCount;){let c=t.child(s++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Zc(t,e,n,r,s){let i=[];for(let o=0,l=0;o<t.length;o++){let a=t[o],c=l,d=l+=a.size;c>=n||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),s&&(i.push(s),s=void 0),d>n&&i.push(a.slice(n-c,a.size,r)))}return i}function mu(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(na(n)){for(a=o;s&&!s.node;)s=s.parent;let u=s.node;if(s&&u.isAtom&&q.isSelectable(u)&&s.parent&&!(u.isInline&&Dk(n.focusNode,n.focusOffset,s.dom))){let h=s.posBefore;c=new q(o==h?l:r.resolve(h))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let u=o,h=o;for(let f=0;f<n.rangeCount;f++){let p=n.getRangeAt(f);u=Math.min(u,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),h=Math.max(h,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,o]=h==t.state.selection.anchor?[h,u]:[u,h],l=r.resolve(o)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let d=r.resolve(a);if(!c){let u=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;c=gu(t,d,l,u)}return c}function dy(t){return t.editable?t.hasFocus():hy(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function An(t,e=!1){let n=t.state.selection;if(uy(t,n),!!dy(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&dt){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Or(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)cv(t);else{let{anchor:r,head:s}=n,i,o;Df&&!(n instanceof J)&&(n.$from.parent.inlineContent||(i=Lf(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=Lf(t,n.to))),t.docView.setSelection(r,s,t,e),Df&&(i&&If(i),o&&If(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&av(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Df=bt||dt&&Zg<63;function Lf(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(bt&&s&&s.contentEditable=="false")return nc(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return nc(s);if(i)return nc(i)}}function nc(t){return t.contentEditable="true",bt&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function If(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function av(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!dy(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function cv(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,st(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Ct&&Qn<=11&&(n.disabled=!0,n.disabled=!1)}function uy(t,e){if(e instanceof q){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(jf(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else jf(t)}function jf(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function gu(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||J.between(e,n,r)}function Pf(t){return t.editable&&!t.hasFocus()?!1:hy(t)}function hy(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function dv(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Or(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Qc(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&ee.findFrom(i,e)}function zn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Bf(t,e,n){let r=t.state.selection;if(r instanceof J)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return zn(t,new J(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Qc(t.state,e);return s&&s instanceof q?zn(t,s):!1}else if(!(jt&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?q.isSelectable(i)?zn(t,new q(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):Oi?zn(t,new J(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof q&&r.node.isInline)return zn(t,new J(e>0?r.$to:r.$from));{let s=Qc(t.state,e);return s?zn(t,s):!1}}}function Zo(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Gs(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Yr(t,e){return e<0?uv(t):hv(t)}function uv(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for($t&&n.nodeType==1&&r<Zo(n)&&Gs(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Gs(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(fy(n))break;{let l=n.previousSibling;for(;l&&Gs(l,-1);)s=n.parentNode,i=st(l),l=l.previousSibling;if(l)n=l,r=Zo(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?ed(t,n,r):s&&ed(t,s,i)}function hv(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=Zo(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Gs(l,1))i=n,o=++r;else break}else{if(fy(n))break;{let l=n.nextSibling;for(;l&&Gs(l,1);)i=l.parentNode,o=st(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=Zo(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&ed(t,i,o)}function fy(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function fv(t,e){for(;t&&e==t.childNodes.length&&!Ri(t);)e=st(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function pv(t,e){for(;t&&!e&&!Ri(t);)e=st(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function ed(t,e,n){if(e.nodeType!=3){let i,o;(o=fv(e,n))?(e=o,n=0):(i=pv(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(na(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&An(t)},50)}function $f(t,e){let n=t.state.doc.resolve(e);if(!(dt||jk)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Hf(t,e,n){let r=t.state.selection;if(r instanceof J&&!r.empty||n.indexOf("s")>-1||jt&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Qc(t.state,e);if(o&&o instanceof q)return zn(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof St?ee.near(o,e):ee.findFrom(o,e);return l?zn(t,l):!1}return!1}function zf(t,e){if(!(t.state.selection instanceof J))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function Ff(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function mv(t){if(!bt||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Ff(t,r,"true"),setTimeout(()=>Ff(t,r,"false"),20)}return!1}function gv(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function yv(t,e){let n=e.keyCode,r=gv(e);if(n==8||jt&&n==72&&r=="c")return zf(t,-1)||Yr(t,-1);if(n==46&&!e.shiftKey||jt&&n==68&&r=="c")return zf(t,1)||Yr(t,1);if(n==13||n==27)return!0;if(n==37||jt&&n==66&&r=="c"){let s=n==37?$f(t,t.state.selection.from)=="ltr"?-1:1:-1;return Bf(t,s,r)||Yr(t,s)}else if(n==39||jt&&n==70&&r=="c"){let s=n==39?$f(t,t.state.selection.from)=="ltr"?1:-1:1;return Bf(t,s,r)||Yr(t,s)}else{if(n==38||jt&&n==80&&r=="c")return Hf(t,-1,r)||Yr(t,-1);if(n==40||jt&&n==78&&r=="c")return mv(t)||Hf(t,1,r)||Yr(t,1);if(r==(jt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function yu(t,e){t.someProp("transformCopied",f=>{e=f(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let f=r.firstChild;n.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let o=t.someProp("clipboardSerializer")||Fr.fromSchema(t.state.schema),l=xy(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=by[c.nodeName.toLowerCase()]);){for(let f=d.length-1;f>=0;f--){let p=l.createElement(d[f]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${u?` -${u}`:""} ${JSON.stringify(n)}`);let h=t.someProp("clipboardTextSerializer",f=>f(e,t))||e.content.textBetween(0,e.content.size,`
13
-
14
- `);return{dom:a,text:h,slice:e}}function py(t,e,n,r,s){let i=s.parent.type.spec.code,o,l;if(!n&&!e)return null;let a=!!e&&(r||i||!n);if(a){if(t.someProp("transformPastedText",h=>{e=h(e,i||r,t)}),i)return l=new P(O.from(t.state.schema.text(e.replace(/\r\n?/g,`
15
- `))),0,0),t.someProp("transformPasted",h=>{l=h(l,t,!0)}),l;let u=t.someProp("clipboardTextParser",h=>h(e,s,r,t));if(u)l=u;else{let h=s.marks(),{schema:f}=t.state,p=Fr.fromSchema(f);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=o.appendChild(document.createElement("p"));g&&y.appendChild(p.serializeNode(f.text(g,h)))})}}else t.someProp("transformPastedHTML",u=>{n=u(n,t)}),o=kv(n),Oi&&vv(o);let c=o&&o.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let h=o.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;o=h}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Ws.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||d),context:s,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!bv.test(h.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Sv(Uf(l,+d[1],+d[2]),d[4]);else if(l=P.maxOpen(xv(l.content,s),!0),l.openStart||l.openEnd){let u=0,h=0;for(let f=l.content.firstChild;u<l.openStart&&!f.type.spec.isolating;u++,f=f.firstChild);for(let f=l.content.lastChild;h<l.openEnd&&!f.type.spec.isolating;h++,f=f.lastChild);l=Uf(l,u,h)}return t.someProp("transformPasted",u=>{l=u(l,t,a)}),l}const bv=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function xv(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&i.length&&gy(a,i,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=yy(o[o.length-1],i.length));let d=my(l,a);o.push(d),s=s.matchType(d.type),i=a}}),o)return O.from(o)}return t}function my(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,O.from(t));return t}function gy(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=gy(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(O.from(my(n,t,s+1))))}}function yy(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,yy(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(O.empty,!0);return t.copy(n.append(r))}function td(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(i=0),s<r-1&&(l=td(l,e,n,r,s+1,i)),s>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(O.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function Uf(t,e,n){return e<t.openStart&&(t=new P(td(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new P(td(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const by={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Vf=null;function xy(){return Vf||(Vf=document.implementation.createHTMLDocument("title"))}let rc=null;function wv(t){let e=window.trustedTypes;return e?(rc||(rc=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),rc.createHTML(t)):t}function kv(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=xy().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&by[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=wv(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function vv(t){let e=t.querySelectorAll(dt?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function Sv(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=O.from(a.create(r[l+1],s)),i++,o++}return new P(s,i,o)}const xt={},wt={},Cv={touchstart:!0,touchmove:!0};class Ev{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Mv(t){for(let e in xt){let n=xt[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Tv(t,r)&&!bu(t,r)&&(t.editable||!(r.type in wt))&&n(t,r)},Cv[e]?{passive:!0}:void 0)}bt&&t.dom.addEventListener("input",()=>null),nd(t)}function Jn(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Av(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function nd(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>bu(t,r))})}function bu(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Tv(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function Nv(t,e){!bu(t,e)&&xt[e.type]&&(t.editable||!(e.type in wt))&&xt[e.type](t,e)}wt.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!ky(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Cn&&dt&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),ps&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,yr(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||yv(t,n)?n.preventDefault():Jn(t,"key")};wt.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};wt.keypress=(t,e)=>{let n=e;if(ky(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||jt&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof J)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function sa(t){return{left:t.clientX,top:t.clientY}}function _v(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function xu(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,l=>o>i.depth?l(t,n,i.nodeAfter,i.before(o),s,!0):l(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function ss(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function Rv(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&q.isSelectable(r)?(ss(t,new q(n)),!0):!1}function Ov(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof q&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(q.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(ss(t,q.create(t.state.doc,s)),!0):!1}function Dv(t,e,n,r,s){return xu(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?Ov(t,n):Rv(t,n))}function Lv(t,e,n,r){return xu(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function Iv(t,e,n,r){return xu(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||jv(t,n,r)}function jv(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(ss(t,J.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)ss(t,J.create(r,l+1,l+1+o.content.size));else if(q.isSelectable(o))ss(t,q.create(r,l));else continue;return!0}}function wu(t){return Qo(t)}const wy=jt?"metaKey":"ctrlKey";xt.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=wu(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&_v(n,t.input.lastClick)&&!n[wy]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=t.posAtCoords(sa(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new Pv(t,o,n,!!r)):(i=="doubleClick"?Lv:Iv)(t,o.pos,o.inside,n)?n.preventDefault():Jn(t,"pointer"))};class Pv{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[wy],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let d=e.state.doc.resolve(n.pos);i=d.parent,o=d.depth?d.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof q&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&$t&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Jn(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>An(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(sa(e))),this.updateAllowDefault(e),this.allowDefault||!n?Jn(this.view,"pointer"):Dv(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||bt&&this.mightDrag&&!this.mightDrag.node.isAtom||dt&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(ss(this.view,ee.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Jn(this.view,"pointer")}move(e){this.updateAllowDefault(e),Jn(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}xt.touchstart=t=>{t.input.lastTouch=Date.now(),wu(t),Jn(t,"pointer")};xt.touchmove=t=>{t.input.lastTouch=Date.now(),Jn(t,"pointer")};xt.contextmenu=t=>wu(t);function ky(t,e){return t.composing?!0:bt&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const Bv=Cn?5e3:-1;wt.compositionstart=wt.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof J&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),Qo(t,!0),t.markCursor=null;else if(Qo(t,!e.selection.empty),$t&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}vy(t,Bv)};wt.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,vy(t,20))};function vy(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Qo(t),e))}function Sy(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Hv());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function $v(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Rk(e.focusNode,e.focusOffset),r=Ok(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function Hv(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Qo(t,e=!1){if(!(Cn&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Sy(t),e||t.docView&&t.docView.dirty){let n=mu(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function zv(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const di=Ct&&Qn<15||ps&&Pk<604;xt.copy=wt.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=di?null:n.clipboardData,o=r.content(),{dom:l,text:a}=yu(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):zv(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Fv(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Uv(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?ui(t,r.value,null,s,e):ui(t,r.textContent,r.innerHTML,s,e)},50)}function ui(t,e,n,r,s){let i=py(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,s,i||P.empty)))return!0;if(!i)return!1;let o=Fv(i),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Cy(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}wt.paste=(t,e)=>{let n=e;if(t.composing&&!Cn)return;let r=di?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&ui(t,Cy(r),r.getData("text/html"),s,n)?n.preventDefault():Uv(t,n)};class Ey{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const Vv=jt?"altKey":"ctrlKey";function My(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[Vv]}xt.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(sa(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof q?s.to-1:s.to))){if(r&&r.mightDrag)o=q.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let u=t.docView.nearestDesc(n.target,!0);u&&u.node.type.spec.draggable&&u!=t.docView&&(o=q.create(t.state.doc,u.posBefore))}}let l=(o||t.state.selection).content(),{dom:a,text:c,slice:d}=yu(t,l);(!n.dataTransfer.files.length||!dt||Zg>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(di?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",di||n.dataTransfer.setData("text/plain",c),t.dragging=new Ey(d,My(t,n),o)};xt.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};wt.dragover=wt.dragenter=(t,e)=>e.preventDefault();wt.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let s=t.posAtCoords(sa(n));if(!s)return;let i=t.state.doc.resolve(s.pos),o=r&&r.slice;o?t.someProp("transformPasted",p=>{o=p(o,t,!1)}):o=py(t,Cy(n.dataTransfer),di?null:n.dataTransfer.getData("text/html"),!1,i);let l=!!(r&&My(t,n));if(t.someProp("handleDrop",p=>p(t,n,o||P.empty,l))){n.preventDefault();return}if(!o)return;n.preventDefault();let a=o?Og(t.state.doc,i.pos,o):i.pos;a==null&&(a=i.pos);let c=t.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,h=c.doc;if(u?c.replaceRangeWith(d,d,o.content.firstChild):c.replaceRange(d,d,o),c.doc.eq(h))return;let f=c.doc.resolve(d);if(u&&q.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new q(f));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((g,y,b,w)=>p=w),c.setSelection(gu(t,f,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))};xt.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&An(t)},20))};xt.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};xt.beforeinput=(t,e)=>{if(dt&&Cn&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,yr(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in wt)xt[t]=wt[t];function hi(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class el{constructor(e,n){this.toDOM=e,this.spec=n||Er,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new _e(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof el&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&hi(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class tr{constructor(e,n){this.attrs=e,this.spec=n||Er}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new _e(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof tr&&hi(this.attrs,e.attrs)&&hi(this.spec,e.spec)}static is(e){return e.type instanceof tr}destroy(){}}class ku{constructor(e,n){this.attrs=e,this.spec=n||Er}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new _e(i.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof ku&&hi(this.attrs,e.attrs)&&hi(this.spec,e.spec)}destroy(){}}class _e{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new _e(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new _e(e,e,new el(n,r))}static inline(e,n,r,s){return new _e(e,n,new tr(r,s))}static node(e,n,r,s){return new _e(e,n,new ku(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof tr}get widget(){return this.type instanceof el}}const Zr=[],Er={};class be{constructor(e,n){this.local=e.length?e:Zr,this.children=n.length?n:Zr}static create(e,n){return n.length?tl(n,e,0,Er):ct}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,s+l,i)}}map(e,n,r){return this==ct||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Er)}mapInner(e,n,r,s,i){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(n,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?Wv(this.children,o||[],e,n,r,s,i):o?new be(o.sort(Mr),Zr):ct}add(e,n){return n.length?this==ct?be.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((l,a)=>{let c=a+r,d;if(d=Ty(n,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,d,c+1):s.splice(i,0,a,a+l.nodeSize,tl(d,l,c+1,Er)),i+=3}});let o=Ay(i?Ny(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new be(o.length?this.local.concat(o).sort(Mr):this.local,s||this.children)}remove(e){return e.length==0||this==ct?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+n,a=r[i+1]+n;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(o||(o=[])).push(u));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(o,l+1);c!=ct?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new be(s,r):ct}forChild(e,n){if(this==ct)return this;if(n.isLeaf)return be.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>i&&a.type instanceof tr){let c=Math.max(i,a.from)-i,d=Math.min(o,a.to)-i;c<d&&(s||(s=[])).push(a.copy(c,d))}}if(s){let l=new be(s.sort(Mr),Zr);return r?new Vn([l,r]):l}return r||ct}eq(e){if(this==e)return!0;if(!(e instanceof be)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return vu(this.localsInner(e))}localsInner(e){if(this==ct)return Zr;if(e.inlineContent||!this.local.some(tr.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof tr||n.push(this.local[r]);return n}forEachSet(e){e(this)}}be.empty=new be([],[]);be.removeOverlap=vu;const ct=be.empty;class Vn{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,Er));return Vn.from(r)}forChild(e,n){if(n.isLeaf)return be.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=ct&&(i instanceof Vn?r=r.concat(i.members):r.push(i))}return Vn.from(r)}eq(e){if(!(e instanceof Vn)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?vu(r?n:n.sort(Mr)):Zr}static from(e){switch(e.length){case 0:return ct;case 1:return e[0];default:return new Vn(e.every(n=>n instanceof be)?e:e.reduce((n,r)=>n.concat(r instanceof be?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function Wv(t,e,n,r,s,i,o){let l=t.slice();for(let c=0,d=i;c<n.maps.length;c++){let u=0;n.maps[c].forEach((h,f,p,g)=>{let y=g-p-(f-h);for(let b=0;b<l.length;b+=3){let w=l[b+1];if(w<0||h>w+d-u)continue;let A=l[b]+d-u;f>=A?l[b+1]=h<=A?-2:-1:h>=d&&y&&(l[b]+=y,l[b+1]+=y)}u+=y}),d=n.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=n.map(t[c]+i),u=d-s;if(u<0||u>=r.content.size){a=!0;continue}let h=n.map(t[c+1]+i,-1),f=h-s,{index:p,offset:g}=r.content.findIndex(u),y=r.maybeChild(p);if(y&&g==u&&g+y.nodeSize==f){let b=l[c+2].mapInner(n,y,d+1,t[c]+i+1,o);b!=ct?(l[c]=u,l[c+1]=f,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=qv(l,t,e,n,s,i,o),d=tl(c,r,0,o);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,h=0;u<d.children.length;u+=3){let f=d.children[u];for(;h<l.length&&l[h]<f;)h+=3;l.splice(h,0,d.children[u],d.children[u+1],d.children[u+2])}}return new be(e.sort(Mr),l)}function Ay(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new _e(s.from+e,s.to+e,s.type))}return n}function qv(t,e,n,r,s,i,o){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(r,s,c);u?n.push(u):o.onRemove&&o.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function Ty(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function Ny(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function tl(t,e,n,r){let s=[],i=!1;e.forEach((l,a)=>{let c=Ty(t,l,a+n);if(c){i=!0;let d=tl(c,l,n+a+1,r);d!=ct&&s.push(a,a+l.nodeSize,d)}});let o=Ay(i?Ny(t):t,-n).sort(Mr);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new be(o,s):ct}function Mr(t,e){return t.from-e.from||t.to-e.to}function vu(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),Wf(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),Wf(e,s,r.copy(i.from,r.to)));break}}}return e}function Wf(t,e,n){for(;e<t.length&&Mr(n,t[e])>0;)e++;t.splice(e,0,n)}function sc(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ct&&e.push(r)}),t.cursorWrapper&&e.push(be.create(t.state.doc,[t.cursorWrapper.deco])),Vn.from(e)}const Kv={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Gv=Ct&&Qn<=11;class Jv{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Yv{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Jv,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);Ct&&Qn<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),Gv&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Kv)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Pf(this.view)){if(this.suppressingSelectionUpdates)return An(this.view);if(Ct&&Qn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Or(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=fs(i))n.add(i);for(let i=e.anchorNode;i;i=fs(i))if(n.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Pf(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,l=!1,a=[];if(e.editable)for(let d=0;d<n.length;d++){let u=this.registerMutation(n[d],a);u&&(i=i<0?u.from:Math.min(u.from,i),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(l=!0))}if($t&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,h]=d;u.parentNode&&u.parentNode.parentNode==h.parentNode?h.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let h of d){let f=h.parentNode;f&&f.nodeName=="LI"&&(!u||Qv(e,u)!=f)&&h.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&na(r)&&(c=mu(e))&&c.eq(ee.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,An(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),Xv(e)),this.handleDOMChange(i,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||An(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];n.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(Ct&&Qn<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:h}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(s=u),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h)}let o=s&&s.parentNode==e.target?st(s)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=i&&i.parentNode==e.target?st(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let qf=new WeakMap,Kf=!1;function Xv(t){if(!qf.has(t)&&(qf.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=$t,Kf)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Kf=!0}}function Gf(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Or(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function Zv(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return Gf(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Gf(t,n):null}function Qv(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function eS(t,e,n){let{node:r,fromOffset:s,toOffset:i,from:o,to:l}=t.docView.parseRange(e,n),a=t.domSelectionRange(),c,d=a.anchorNode;if(d&&t.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],na(a)||c.push({node:a.focusNode,offset:a.focusOffset})),dt&&t.input.lastKeyCode===8)for(let y=i;y>s;y--){let b=r.childNodes[y-1],w=b.pmViewDesc;if(b.nodeName=="BR"&&!w){i=y;break}if(!w||w.size)break}let u=t.state.doc,h=t.someProp("domParser")||Ws.fromSchema(t.state.schema),f=u.resolve(o),p=null,g=h.parse(r,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:s,to:i,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:tS,context:f});if(c&&c[0].pos!=null){let y=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=y),p={anchor:y+o,head:b+o}}return{doc:g,sel:p,from:o,to:l}}function tS(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(bt&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||bt&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const nS=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function rS(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let k=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,v=mu(t,k);if(v&&!t.state.selection.eq(v)){if(dt&&Cn&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",N=>N(t,yr(13,"Enter"))))return;let T=t.state.tr.setSelection(v);k=="pointer"?T.setMeta("pointer",!0):k=="key"&&T.scrollIntoView(),i&&T.setMeta("composition",i),t.dispatch(T)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=eS(t,e,n),d=t.state.doc,u=d.slice(c.from,c.to),h,f;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(h=t.state.selection.to,f="end"):(h=t.state.selection.from,f="start"),t.input.lastKeyCode=null;let p=oS(u.content,c.doc.content,c.from,h,f);if(p&&t.input.domChangeCount++,(ps&&t.input.lastIOSEnter>Date.now()-225||Cn)&&s.some(k=>k.nodeType==1&&!nS.test(k.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",k=>k(t,yr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof J&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let k=Jf(t,t.state.doc,c.sel);if(k&&!k.eq(t.state.selection)){let v=t.state.tr.setSelection(k);i&&v.setMeta("composition",i),t.dispatch(v)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof J&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),Ct&&Qn<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let g=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),b=d.resolve(p.start),w=g.sameParent(y)&&g.parent.inlineContent&&b.end()>=p.endA;if((ps&&t.input.lastIOSEnter>Date.now()-225&&(!w||s.some(k=>k.nodeName=="DIV"||k.nodeName=="P"))||!w&&g.pos<c.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(c.doc.textBetween(g.pos,y.pos,"","")))&&t.someProp("handleKeyDown",k=>k(t,yr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&iS(d,p.start,p.endA,g,y)&&t.someProp("handleKeyDown",k=>k(t,yr(8,"Backspace")))){Cn&&dt&&t.domObserver.suppressSelectionUpdates();return}dt&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),Cn&&!w&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(k){return k(t,yr(13,"Enter"))})},20));let A=p.start,S=p.endA,M=k=>{let v=k||t.state.tr.replace(A,S,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let T=Jf(t,v.doc,c.sel);T&&!(dt&&t.composing&&T.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(T.head==A||T.head==v.mapping.map(S)-1)||Ct&&T.empty&&T.head==A)&&v.setSelection(T)}return i&&v.setMeta("composition",i),v.scrollIntoView()},x;if(w)if(g.pos==y.pos){Ct&&Qn<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>An(t),20));let k=M(t.state.tr.delete(A,S)),v=d.resolve(p.start).marksAcross(d.resolve(p.endA));v&&k.ensureMarks(v),t.dispatch(k)}else if(p.endA==p.endB&&(x=sS(g.parent.content.cut(g.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start())))){let k=M(t.state.tr);x.type=="add"?k.addMark(A,S,x.mark):k.removeMark(A,S,x.mark),t.dispatch(k)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let k=g.parent.textBetween(g.parentOffset,y.parentOffset),v=()=>M(t.state.tr.insertText(k,A,S));t.someProp("handleTextInput",T=>T(t,A,S,k,v))||t.dispatch(v())}else t.dispatch(M());else t.dispatch(M())}function Jf(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:gu(t,e.resolve(n.anchor),e.resolve(n.head))}function sS(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,o,l,a;for(let d=0;d<r.length;d++)s=r[d].removeFromSet(s);for(let d=0;d<n.length;d++)i=n[d].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],o="add",a=d=>d.mark(l.addToSet(d.marks));else if(s.length==0&&i.length==1)l=i[0],o="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(O.from(c).eq(t))return{mark:l,type:o}}function iS(t,e,n,r,s){if(n-e<=s.pos-r.pos||ic(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=t.resolve(ic(i,!0,!0));return!o.parent.isTextblock||o.pos>n||ic(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function ic(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function oS(t,e,n,r,s){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(s=="end"){let a=Math.max(0,i-Math.min(o,l));r-=o+a-i}if(o<i&&t.size<e.size){let a=r<=i&&r>=o?i-r:0;i-=a,i&&i<e.size&&Yf(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-o),o=i}else if(l<i){let a=r<=i&&r>=l?i-r:0;i-=a,i&&i<t.size&&Yf(t.textBetween(i-1,i+1))&&(i+=a?1:-1),o=i+(o-l),l=i}return{start:i,endA:o,endB:l}}function Yf(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class _y{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Ev,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(tp),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Qf(this),Zf(this),this.nodeViews=ep(this),this.docView=Rf(this.state.doc,Xf(this),sc(this),this.dom,this),this.domObserver=new Yv(this,(r,s,i,o)=>rS(this,r,s,i,o)),this.domObserver.start(),Mv(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&nd(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(tp),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(Sy(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let f=ep(this);aS(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&nd(this),this.editable=Qf(this),Zf(this);let a=sc(this),c=Xf(this),d=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(s.selection))&&(o=!0);let h=d=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Hk(this);if(o){this.domObserver.stop();let f=u&&(Ct||dt)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&lS(s.selection,e.selection);if(u){let p=dt?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=$v(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Rf(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&dv(this))?An(this,f):(uy(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():h&&zk(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof q){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Ef(this,n.getBoundingClientRect(),e)}else Ef(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new Ey(e.slice,e.move,s<0?void 0:q.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(s=n?n(l):l))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let l=i[o].props[e];if(l!=null&&(s=n?n(l):l))return s}}hasFocus(){if(Ct){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Fk(this.dom),An(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Kk(this,e)}coordsAtPos(e,n=1){return ry(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return Zk(this,n||this.state,e)}pasteHTML(e,n){return ui(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return ui(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return yu(this,e)}destroy(){this.docView&&(Av(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],sc(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Nk())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Nv(this,e)}domSelectionRange(){let e=this.domSelection();return e?bt&&this.root.nodeType===11&&Lk(this.dom.ownerDocument)==this.dom&&Zv(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}_y.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Xf(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[_e.node(0,t.state.doc.content.size,e)]}function Zf(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:_e.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Qf(t){return!t.someProp("editable",e=>e(t.state)===!1)}function lS(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function ep(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function aS(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function tp(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var nr={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},nl={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},cS=typeof navigator<"u"&&/Mac/.test(navigator.platform),dS=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var it=0;it<10;it++)nr[48+it]=nr[96+it]=String(it);for(var it=1;it<=24;it++)nr[it+111]="F"+it;for(var it=65;it<=90;it++)nr[it]=String.fromCharCode(it+32),nl[it]=String.fromCharCode(it);for(var oc in nr)nl.hasOwnProperty(oc)||(nl[oc]=nr[oc]);function uS(t){var e=cS&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||dS&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?nl:nr)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const hS=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),fS=typeof navigator<"u"&&/Win/.test(navigator.platform);function pS(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))hS?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function mS(t){let e=Object.create(null);for(let n in t)e[pS(n)]=t[n];return e}function lc(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function gS(t){return new me({props:{handleKeyDown:Su(t)}})}function Su(t){let e=mS(t);return function(n,r){let s=uS(r),i,o=e[lc(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[lc(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(fS&&r.ctrlKey&&r.altKey)&&(i=nr[r.keyCode])&&i!=s){let l=e[lc(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var yS=Object.defineProperty,Cu=(t,e)=>{for(var n in e)yS(t,n,{get:e[n],enumerable:!0})};function ia(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}var oa=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:s}=n,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...c)=>{const d=l(...c)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o=[],l=!!t,a=t||s.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(a),o.every(u=>u===!0)),d={...Object.fromEntries(Object.entries(n).map(([u,h])=>[u,(...p)=>{const g=this.buildProps(a,e),y=h(...p)(g);return o.push(y),d}])),run:c};return d}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.tr,i=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o={tr:t,editor:r,view:i,state:ia({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)(o)]))}};return o}},Ry={};Cu(Ry,{blur:()=>bS,clearContent:()=>xS,clearNodes:()=>wS,command:()=>kS,createParagraphNear:()=>vS,cut:()=>SS,deleteCurrentNode:()=>CS,deleteNode:()=>ES,deleteRange:()=>MS,deleteSelection:()=>AS,enter:()=>TS,exitCode:()=>NS,extendMarkRange:()=>_S,first:()=>RS,focus:()=>OS,forEach:()=>DS,insertContent:()=>LS,insertContentAt:()=>PS,joinBackward:()=>HS,joinDown:()=>$S,joinForward:()=>zS,joinItemBackward:()=>FS,joinItemForward:()=>US,joinTextblockBackward:()=>VS,joinTextblockForward:()=>WS,joinUp:()=>BS,keyboardShortcut:()=>KS,lift:()=>GS,liftEmptyBlock:()=>JS,liftListItem:()=>YS,newlineInCode:()=>XS,resetAttributes:()=>ZS,scrollIntoView:()=>QS,selectAll:()=>eC,selectNodeBackward:()=>tC,selectNodeForward:()=>nC,selectParentNode:()=>rC,selectTextblockEnd:()=>sC,selectTextblockStart:()=>iC,setContent:()=>oC,setMark:()=>SC,setMeta:()=>CC,setNode:()=>EC,setNodeSelection:()=>MC,setTextSelection:()=>AC,sinkListItem:()=>TC,splitBlock:()=>NC,splitListItem:()=>_C,toggleList:()=>RC,toggleMark:()=>OC,toggleNode:()=>DC,toggleWrap:()=>LC,undoInputRule:()=>IC,unsetAllMarks:()=>jC,unsetMark:()=>PC,updateAttributes:()=>BC,wrapIn:()=>$C,wrapInList:()=>HC});var bS=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),xS=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),wS=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:i,$to:o})=>{t.doc.nodesBetween(i.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:d}=e,u=c.resolve(d.map(a)),h=c.resolve(d.map(a+l.nodeSize)),f=u.blockRange(h);if(!f)return;const p=Cs(f);if(l.type.isTextblock){const{defaultType:g}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(f.start,g)}(p||p===0)&&e.lift(f,p)})}),!0},kS=t=>e=>t(e),vS=()=>({state:t,dispatch:e})=>Kg(t,e),SS=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,i=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new J(r.doc.resolve(Math.max(o-1,0)))),!0},CS=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const l=s.before(i),a=s.after(i);t.delete(l,a).scrollIntoView()}return!0}return!1};function Ke(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var ES=t=>({tr:e,state:n,dispatch:r})=>{const s=Ke(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const a=i.before(o),c=i.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},MS=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},AS=()=>({state:t,dispatch:e})=>cu(t,e),TS=()=>({commands:t})=>t.keyboardShortcut("Enter"),NS=()=>({state:t,dispatch:e})=>pk(t,e);function Eu(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function rl(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:Eu(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function Oy(t,e,n={}){return t.find(r=>r.type===e&&rl(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function np(t,e,n={}){return!!Oy(t,e,n)}function Mu(t,e,n){var r;if(!t||!e)return;let s=t.parent.childAfter(t.parentOffset);if((!s.node||!s.node.marks.some(d=>d.type===e))&&(s=t.parent.childBefore(t.parentOffset)),!s.node||!s.node.marks.some(d=>d.type===e)||(n=n||((r=s.node.marks[0])==null?void 0:r.attrs),!Oy([...s.node.marks],e,n)))return;let o=s.index,l=t.start()+s.offset,a=o+1,c=l+s.node.nodeSize;for(;o>0&&np([...t.parent.child(o-1).marks],e,n);)o-=1,l-=t.parent.child(o).nodeSize;for(;a<t.parent.childCount&&np([...t.parent.child(a).marks],e,n);)c+=t.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function Rn(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var _S=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const i=Rn(t,r.schema),{doc:o,selection:l}=n,{$from:a,from:c,to:d}=l;if(s){const u=Mu(a,i,e);if(u&&u.from<=c&&u.to>=d){const h=J.create(o,u.from,u.to);n.setSelection(h)}}return!0},RS=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function Dy(t){return t instanceof J}function kr(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Ly(t,e=null){if(!e)return null;const n=ee.atStart(t),r=ee.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,i=r.to;return e==="all"?J.create(t,kr(0,s,i),kr(t.content.size,s,i)):J.create(t,kr(e,s,i),kr(e,s,i))}function Iy(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function la(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var OS=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(la()||Iy())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(i&&t===null&&!Dy(n.state.selection))return o(),!0;const l=Ly(s.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},DS=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),LS=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),jy=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&jy(r)}return t};function uo(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return jy(n)}function fi(t,e,n){if(t instanceof Zn||t instanceof O)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return O.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),fi("",e,n)}if(s){if(n.errorOnInvalidContent){let o=!1,l="";const a=new kg({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?Ws.fromSchema(a).parseSlice(uo(t),n.parseOptions):Ws.fromSchema(a).parse(uo(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=Ws.fromSchema(e);return n.slice?i.parseSlice(uo(t),n.parseOptions).content:i.parse(uo(t),n.parseOptions)}return fi("",e,n)}function IS(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof Ze||s instanceof Qe))return;const i=t.mapping.maps[r];let o=0;i.forEach((l,a,c,d)=>{o===0&&(o=d)}),t.setSelection(ee.near(t.doc.resolve(o),n))}var jS=t=>!("type"in t),PS=(t,e,n)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const a=y=>{i.emit("contentError",{editor:i,error:y,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{fi(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(y){a(y)}try{l=fi(e,i.schema,{parseOptions:c,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(y){return a(y),!1}let{from:d,to:u}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},h=!0,f=!0;if((jS(l)?l:[l]).forEach(y=>{y.check(),h=h?y.isText&&y.marks.length===0:!1,f=f?y.isBlock:!1}),d===u&&f){const{parent:y}=r.doc.resolve(d);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(d-=1,u+=1)}let g;if(h){if(Array.isArray(e))g=e.map(y=>y.text||"").join("");else if(e instanceof O){let y="";e.forEach(b=>{b.text&&(y+=b.text)}),g=y}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,d,u)}else{g=l;const y=r.doc.resolve(d),b=y.node(),w=y.parentOffset===0,A=b.isText||b.isTextblock,S=b.content.size>0;w&&A&&S&&(d=Math.max(0,d-1)),r.replaceWith(d,u,g)}n.updateSelection&&IS(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:d,text:g}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:d,text:g})}return!0},BS=()=>({state:t,dispatch:e})=>uk(t,e),$S=()=>({state:t,dispatch:e})=>hk(t,e),HS=()=>({state:t,dispatch:e})=>Hg(t,e),zS=()=>({state:t,dispatch:e})=>Vg(t,e),FS=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Ql(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},US=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Ql(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},VS=()=>({state:t,dispatch:e})=>ck(t,e),WS=()=>({state:t,dispatch:e})=>dk(t,e);function Py(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function qS(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))la()||Py()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var KS=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const i=qS(t).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a?.steps.forEach(c=>{const d=c.map(r.mapping);d&&s&&r.maybeStep(d)}),!0};function rr(t,e,n={}){const{from:r,to:s,empty:i}=t.selection,o=e?Ke(e,t.schema):null,l=[];t.doc.nodesBetween(r,s,(u,h)=>{if(u.isText)return;const f=Math.max(r,h),p=Math.min(s,h+u.nodeSize);l.push({node:u,from:f,to:p})});const a=s-r,c=l.filter(u=>o?o.name===u.node.type.name:!0).filter(u=>rl(u.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((u,h)=>u+h.to-h.from,0)>=a}var GS=(t,e={})=>({state:n,dispatch:r})=>{const s=Ke(t,n.schema);return rr(n,s,e)?fk(n,r):!1},JS=()=>({state:t,dispatch:e})=>Gg(t,e),YS=t=>({state:e,dispatch:n})=>{const r=Ke(t,e.schema);return Ek(r)(e,n)},XS=()=>({state:t,dispatch:e})=>qg(t,e);function aa(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function rp(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var ZS=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=aa(typeof t=="string"?t:t.name,r.schema);return l?(l==="node"&&(i=Ke(t,r.schema)),l==="mark"&&(o=Rn(t,r.schema)),s&&n.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,d)=>{i&&i===c.type&&n.setNodeMarkup(d,void 0,rp(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(u=>{o===u.type&&n.addMark(d,d+c.nodeSize,o.create(rp(u.attrs,e)))})})}),!0):!1},QS=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),eC=()=>({tr:t,dispatch:e})=>{if(e){const n=new St(t.doc);t.setSelection(n)}return!0},tC=()=>({state:t,dispatch:e})=>Fg(t,e),nC=()=>({state:t,dispatch:e})=>Wg(t,e),rC=()=>({state:t,dispatch:e})=>yk(t,e),sC=()=>({state:t,dispatch:e})=>wk(t,e),iC=()=>({state:t,dispatch:e})=>xk(t,e);function rd(t,e,n={},r={}){return fi(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var oC=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:l})=>{const{doc:a}=i;if(r.preserveWhitespace!=="full"){const c=rd(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return o&&i.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function By(t,e){const n=Rn(e,t.schema),{from:r,to:s,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function $y(t,e){const n=new ou(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function lC(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function sd(t,e){const n=[];return t.descendants((r,s)=>{e(r)&&n.push({node:r,pos:s})}),n}function aC(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function Hy(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function ca(t){return e=>Hy(e.$from,t)}function G(t,e,n){return t.config[e]===void 0&&t.parent?G(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?G(t.parent,e,n):null}):t.config[e]}function Au(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=G(e,"addExtensions",n);return r?[e,...Au(r())]:e}).flat(10)}function Tu(t,e){const n=Fr.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function zy(t){return typeof t=="function"}function we(t,e=void 0,...n){return zy(t)?e?t.bind(e)(...n):t(...n):t}function cC(t={}){return Object.keys(t).length===0&&t.constructor===Object}function pi(t){const e=t.filter(s=>s.type==="extension"),n=t.filter(s=>s.type==="node"),r=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Fy(t){const e=[],{nodeExtensions:n,markExtensions:r}=pi(t),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage,extensions:s},a=G(o,"addGlobalAttributes",l);if(!a)return;a().forEach(d=>{d.types.forEach(u=>{Object.entries(d.attributes).forEach(([h,f])=>{e.push({type:u,name:h,attribute:{...i,...f}})})})})}),s.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=G(o,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([d,u])=>{const h={...i,...u};typeof h?.default=="function"&&(h.default=h.default()),h?.isRequired&&h?.default===void 0&&delete h.default,e.push({type:o.name,name:d,attribute:h})})}),e}function pe(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const l=i?String(i).split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(d=>!a.includes(d));r[s]=[...a,...c].join(" ")}else if(s==="style"){const l=i?i.split(";").map(d=>d.trim()).filter(Boolean):[],a=r[s]?r[s].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;a.forEach(d=>{const[u,h]=d.split(":").map(f=>f.trim());c.set(u,h)}),l.forEach(d=>{const[u,h]=d.split(":").map(f=>f.trim());c.set(u,h)}),r[s]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else r[s]=i}),r},{})}function mi(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>pe(n,r),{})}function dC(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function sp(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):dC(n.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function ip(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&cC(n)?!1:n!=null))}function uC(t,e){var n;const r=Fy(t),{nodeExtensions:s,markExtensions:i}=pi(t),o=(n=s.find(c=>G(c,"topNode")))==null?void 0:n.name,l=Object.fromEntries(s.map(c=>{const d=r.filter(b=>b.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((b,w)=>{const A=G(w,"extendNodeSchema",u);return{...b,...A?A(c):{}}},{}),f=ip({...h,content:we(G(c,"content",u)),marks:we(G(c,"marks",u)),group:we(G(c,"group",u)),inline:we(G(c,"inline",u)),atom:we(G(c,"atom",u)),selectable:we(G(c,"selectable",u)),draggable:we(G(c,"draggable",u)),code:we(G(c,"code",u)),whitespace:we(G(c,"whitespace",u)),linebreakReplacement:we(G(c,"linebreakReplacement",u)),defining:we(G(c,"defining",u)),isolating:we(G(c,"isolating",u)),attrs:Object.fromEntries(d.map(b=>{var w,A;return[b.name,{default:(w=b?.attribute)==null?void 0:w.default,validate:(A=b?.attribute)==null?void 0:A.validate}]}))}),p=we(G(c,"parseHTML",u));p&&(f.parseDOM=p.map(b=>sp(b,d)));const g=G(c,"renderHTML",u);g&&(f.toDOM=b=>g({node:b,HTMLAttributes:mi(b,d)}));const y=G(c,"renderText",u);return y&&(f.toText=y),[c.name,f]})),a=Object.fromEntries(i.map(c=>{const d=r.filter(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((y,b)=>{const w=G(b,"extendMarkSchema",u);return{...y,...w?w(c):{}}},{}),f=ip({...h,inclusive:we(G(c,"inclusive",u)),excludes:we(G(c,"excludes",u)),group:we(G(c,"group",u)),spanning:we(G(c,"spanning",u)),code:we(G(c,"code",u)),attrs:Object.fromEntries(d.map(y=>{var b,w;return[y.name,{default:(b=y?.attribute)==null?void 0:b.default,validate:(w=y?.attribute)==null?void 0:w.validate}]}))}),p=we(G(c,"parseHTML",u));p&&(f.parseDOM=p.map(y=>sp(y,d)));const g=G(c,"renderHTML",u);return g&&(f.toDOM=y=>g({mark:y,HTMLAttributes:mi(y,d)})),[c.name,f]}));return new kg({topNode:o,nodes:l,marks:a})}function hC(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function Nu(t){return t.sort((n,r)=>{const s=G(n,"priority")||100,i=G(r,"priority")||100;return s>i?-1:s<i?1:0})}function Uy(t){const e=Nu(Au(t)),n=hC(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Vy(t,e,n){const{from:r,to:s}=e,{blockSeparator:i=`
16
-
17
- `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,s,(a,c,d,u)=>{var h;a.isBlock&&c>r&&(l+=i);const f=o?.[a.type.name];if(f)return d&&(l+=f({node:a,pos:c,parent:d,index:u,range:e})),!1;a.isText&&(l+=(h=a?.text)==null?void 0:h.slice(Math.max(r,c)-c,s-c))}),l}function fC(t,e){const n={from:0,to:t.content.size};return Vy(t,n,e)}function Wy(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function pC(t,e){const n=Ke(e,t.schema),{from:r,to:s}=t.selection,i=[];t.doc.nodesBetween(r,s,l=>{i.push(l)});const o=i.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function qy(t,e){const n=aa(typeof e=="string"?e:e.name,t.schema);return n==="node"?pC(t,e):n==="mark"?By(t,e):{}}function mC(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function gC(t){const e=mC(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,o)=>o!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function Ky(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=n[i];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(i).map(l,-1),d=e.slice(i).map(a),u=e.invert().map(c,-1),h=e.invert().map(d);r.push({oldRange:{from:u,to:h},newRange:{from:c,to:d}})})}),gC(r)}function _u(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const i=n.resolve(t),o=Mu(i,s.type);o&&r.push({mark:s,...o})}):n.nodesBetween(t,e,(s,i)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}var yC=(t,e,n,r=20)=>{const s=t.doc.resolve(n);let i=r,o=null;for(;i>0&&o===null;){const l=s.node(i);l?.type.name===e?o=l:i-=1}return[o,i]};function ac(t,e){return e.nodes[t]||e.marks[t]||null}function Lo(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}var bC=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,l)=>{var a,c;const d=((c=(a=s.type.spec).toText)==null?void 0:c.call(a,{node:s,pos:i,parent:o,index:l}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?d:d.slice(0,Math.max(0,r-i))}),n};function id(t,e,n={}){const{empty:r,ranges:s}=t.selection,i=e?Rn(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>rl(u.attrs,n,{strict:!1}));let o=0;const l=[];if(s.forEach(({$from:u,$to:h})=>{const f=u.pos,p=h.pos;t.doc.nodesBetween(f,p,(g,y)=>{if(!g.isText&&!g.marks.length)return;const b=Math.max(f,y),w=Math.min(p,y+g.nodeSize),A=w-b;o+=A,l.push(...g.marks.map(S=>({mark:S,from:b,to:w})))})}),o===0)return!1;const a=l.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>rl(u.mark.attrs,n,{strict:!1})).reduce((u,h)=>u+h.to-h.from,0),c=l.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,h)=>u+h.to-h.from,0);return(a>0?a+c:a)>=o}function xC(t,e,n={}){if(!e)return rr(t,null,n)||id(t,null,n);const r=aa(e,t.schema);return r==="node"?rr(t,e,n):r==="mark"?id(t,e,n):!1}var wC=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const i=ca(l=>l.type.name===e)(t.selection);if(!i)return!1;const o=t.doc.resolve(i.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},kC=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function op(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function lp(t,e){const{nodeExtensions:n}=pi(e),r=n.find(o=>o.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=we(G(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function Li(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(i=>{s!==!1&&(Li(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function Gy(t){return t instanceof q}function vC(t,e,n){var r;const{selection:s}=e;let i=null;if(Dy(s)&&(i=s.$cursor),i){const l=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(c=>c.type.excludes(n)))}const{ranges:o}=s;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(d,u,h)=>{if(c)return!1;if(d.isInline){const f=!h||h.type.allowsMarkType(n),p=!!n.isInSet(d.marks)||!d.marks.some(g=>g.type.excludes(n));c=f&&p}return!c}),c})}var SC=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:o,ranges:l}=i,a=Rn(t,r.schema);if(s)if(o){const c=By(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(h,f)=>{const p=Math.max(f,d),g=Math.min(f+h.nodeSize,u);h.marks.find(b=>b.type===a)?h.marks.forEach(b=>{a===b.type&&n.addMark(p,g,a.create({...b.attrs,...e}))}):n.addMark(p,g,a.create(e))})});return vC(r,n,a)},CC=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),EC=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const i=Ke(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:l})=>vf(i,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>vf(i,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},MC=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=kr(t,0,r.content.size),i=q.create(r,s);e.setSelection(i)}return!0},AC=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,o=J.atStart(r).from,l=J.atEnd(r).to,a=kr(s,o,l),c=kr(i,o,l),d=J.create(r,a,c);e.setSelection(d)}return!0},TC=t=>({state:e,dispatch:n})=>{const r=Ke(t,e.schema);return Tk(r)(e,n)};function ap(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e?.includes(s.type.name));t.tr.ensureMarks(r)}}var NC=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:l,$to:a}=i,c=s.extensionManager.attributes,d=Lo(c,l.node().type.name,l.node().attrs);if(i instanceof q&&i.node.isBlock)return!l.parentOffset||!Mn(o,l.pos)?!1:(r&&(t&&ap(n,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const u=a.parentOffset===a.parent.content.size,h=l.depth===0?void 0:lC(l.node(-1).contentMatchAt(l.indexAfter(-1)));let f=u&&h?[{type:h,attrs:d}]:void 0,p=Mn(e.doc,e.mapping.map(l.pos),1,f);if(!f&&!p&&Mn(e.doc,e.mapping.map(l.pos),1,h?[{type:h}]:void 0)&&(p=!0,f=h?[{type:h,attrs:d}]:void 0),r){if(p&&(i instanceof J&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,f),h&&!u&&!l.parentOffset&&l.parent.type!==h)){const g=e.mapping.map(l.before()),y=e.doc.resolve(g);l.node(-1).canReplaceWith(y.index(),y.index()+1,h)&&e.setNodeMarkup(e.mapping.map(l.before()),h)}t&&ap(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return p},_C=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var o;const l=Ke(t,r.schema),{$from:a,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||a.depth<2||!a.sameParent(c))return!1;const u=a.node(-1);if(u.type!==l)return!1;const h=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(s){let b=O.empty;const w=a.index(-1)?1:a.index(-2)?2:3;for(let v=a.depth-w;v>=a.depth-3;v-=1)b=O.from(a.node(v).copy(b));const A=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,S={...Lo(h,a.node().type.name,a.node().attrs),...e},M=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(S))||void 0;b=b.append(O.from(l.createAndFill(null,M)||void 0));const x=a.before(a.depth-(w-1));n.replace(x,a.after(-A),new P(b,4-w,0));let k=-1;n.doc.nodesBetween(x,n.doc.content.size,(v,T)=>{if(k>-1)return!1;v.isTextblock&&v.content.size===0&&(k=T+1)}),k>-1&&n.setSelection(J.near(n.doc.resolve(k))),n.scrollIntoView()}return!0}const f=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,p={...Lo(h,u.type.name,u.attrs),...e},g={...Lo(h,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);const y=f?[{type:l,attrs:p},{type:f,attrs:g}]:[{type:l,attrs:p}];if(!Mn(n.doc,a.pos,2))return!1;if(s){const{selection:b,storedMarks:w}=r,{splittableMarks:A}=i.extensionManager,S=w||b.$to.parentOffset&&b.$from.marks();if(n.split(a.pos,2,y).scrollIntoView(),!S||!s)return!0;const M=S.filter(x=>A.includes(x.type.name));n.ensureMarks(M)}return!0},cc=(t,e)=>{const n=ca(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===s?.type&&ur(t.doc,n.pos)&&t.join(n.pos),!0},dc=(t,e)=>{const n=ca(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===s?.type&&ur(t.doc,r)&&t.join(r),!0},RC=(t,e,n,r={})=>({editor:s,tr:i,state:o,dispatch:l,chain:a,commands:c,can:d})=>{const{extensions:u,splittableMarks:h}=s.extensionManager,f=Ke(t,o.schema),p=Ke(e,o.schema),{selection:g,storedMarks:y}=o,{$from:b,$to:w}=g,A=b.blockRange(w),S=y||g.$to.parentOffset&&g.$from.marks();if(!A)return!1;const M=ca(x=>lp(x.type.name,u))(g);if(A.depth>=1&&M&&A.depth-M.depth<=1){if(M.node.type===f)return c.liftListItem(p);if(lp(M.node.type.name,u)&&f.validContent(M.node.content)&&l)return a().command(()=>(i.setNodeMarkup(M.pos,f),!0)).command(()=>cc(i,f)).command(()=>dc(i,f)).run()}return!n||!S||!l?a().command(()=>d().wrapInList(f,r)?!0:c.clearNodes()).wrapInList(f,r).command(()=>cc(i,f)).command(()=>dc(i,f)).run():a().command(()=>{const x=d().wrapInList(f,r),k=S.filter(v=>h.includes(v.type.name));return i.ensureMarks(k),x?!0:c.clearNodes()}).wrapInList(f,r).command(()=>cc(i,f)).command(()=>dc(i,f)).run()},OC=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,o=Rn(t,r.schema);return id(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},DC=(t,e,n={})=>({state:r,commands:s})=>{const i=Ke(t,r.schema),o=Ke(e,r.schema),l=rr(r,i,n);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(o,a):s.setNode(i,{...a,...n})},LC=(t,e={})=>({state:n,commands:r})=>{const s=Ke(t,n.schema);return rr(n,s,e)?r.lift(s):r.wrapIn(s,e)},IC=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let i;if(s.spec.isInputRules&&(i=s.getState(t))){if(e){const o=t.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(i.text){const a=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else o.delete(i.from,i.to)}return!0}}return!1},jC=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:s}=n;return r||e&&s.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},PC=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,a=Rn(t,r.schema),{$from:c,empty:d,ranges:u}=l;if(!s)return!0;if(d&&o){let{from:h,to:f}=l;const p=(i=c.marks().find(y=>y.type===a))==null?void 0:i.attrs,g=Mu(c,a,p);g&&(h=g.from,f=g.to),n.removeMark(h,f,a)}else u.forEach(h=>{n.removeMark(h.$from.pos,h.$to.pos,a)});return n.removeStoredMark(a),!0},BC=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=aa(typeof t=="string"?t:t.name,r.schema);return l?(l==="node"&&(i=Ke(t,r.schema)),l==="mark"&&(o=Rn(t,r.schema)),s&&n.selection.ranges.forEach(a=>{const c=a.$from.pos,d=a.$to.pos;let u,h,f,p;n.selection.empty?r.doc.nodesBetween(c,d,(g,y)=>{i&&i===g.type&&(f=Math.max(y,c),p=Math.min(y+g.nodeSize,d),u=y,h=g)}):r.doc.nodesBetween(c,d,(g,y)=>{y<c&&i&&i===g.type&&(f=Math.max(y,c),p=Math.min(y+g.nodeSize,d),u=y,h=g),y>=c&&y<=d&&(i&&i===g.type&&n.setNodeMarkup(y,void 0,{...g.attrs,...e}),o&&g.marks.length&&g.marks.forEach(b=>{if(o===b.type){const w=Math.max(y,c),A=Math.min(y+g.nodeSize,d);n.addMark(w,A,o.create({...b.attrs,...e}))}}))}),h&&(u!==void 0&&n.setNodeMarkup(u,void 0,{...h.attrs,...e}),o&&h.marks.length&&h.marks.forEach(g=>{o===g.type&&n.addMark(f,p,o.create({...g.attrs,...e}))}))}),!0):!1},$C=(t,e={})=>({state:n,dispatch:r})=>{const s=Ke(t,n.schema);return kk(s,e)(n,r)},HC=(t,e={})=>({state:n,dispatch:r})=>{const s=Ke(t,n.schema);return vk(s,e)(n,r)},zC=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Ii=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},FC=(t,e)=>{if(Eu(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function ho(t){var e;const{editor:n,from:r,to:s,text:i,rules:o,plugin:l}=t,{view:a}=n;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(h=>h.type.spec.code))return!1;let d=!1;const u=bC(c)+i;return o.forEach(h=>{if(d)return;const f=FC(u,h.find);if(!f)return;const p=a.state.tr,g=ia({state:a.state,transaction:p}),y={from:r-(f[0].length-i.length),to:s},{commands:b,chain:w,can:A}=new oa({editor:n,state:g});h.handler({state:g,range:y,match:f,commands:b,chain:w,can:A})===null||!p.steps.length||(h.undoable&&p.setMeta(l,{transform:p,from:r,to:s,text:i}),a.dispatch(p),d=!0)}),d}function UC(t){const{editor:e,rules:n}=t,r=new me({state:{init(){return null},apply(s,i,o){const l=s.getMeta(r);if(l)return l;const a=s.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:d}=a;typeof d=="string"?d=d:d=Tu(O.from(d),o.schema);const{from:u}=a,h=u+d.length;ho({editor:e,from:u,to:h,text:d,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,l){return ho({editor:e,from:i,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&ho({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?ho({editor:e,from:o.pos,to:o.pos,text:`
18
- `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function VC(t){return Object.prototype.toString.call(t).slice(8,-1)}function fo(t){return VC(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Jy(t,e){const n={...t};return fo(t)&&fo(e)&&Object.keys(e).forEach(r=>{fo(e[r])&&fo(t[r])?n[r]=Jy(t[r],e[r]):n[r]=e[r]}),n}var Ru=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...we(G(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...we(G(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Jy(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},Zt=class Yy extends Ru{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Yy(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(c=>c?.type.name===n.name))return!1;const a=o.find(c=>c?.type.name===n.name);return a&&r.removeStoredMark(a),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function WC(t){return typeof t=="number"}var qC=class{constructor(t){this.find=t.find,this.handler=t.handler}},KC=(t,e,n)=>{if(Eu(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=t,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function GC(t){const{editor:e,state:n,from:r,to:s,rule:i,pasteEvent:o,dropEvent:l}=t,{commands:a,chain:c,can:d}=new oa({editor:e,state:n}),u=[];return n.doc.nodesBetween(r,s,(f,p)=>{var g,y,b,w,A;if((y=(g=f.type)==null?void 0:g.spec)!=null&&y.code||!(f.isText||f.isTextblock||f.isInline))return;const S=(A=(w=(b=f.content)==null?void 0:b.size)!=null?w:f.nodeSize)!=null?A:0,M=Math.max(r,p),x=Math.min(s,p+S);if(M>=x)return;const k=f.isText?f.text||"":f.textBetween(M-p,x-p,void 0,"");KC(k,i.find,o).forEach(T=>{if(T.index===void 0)return;const N=M+T.index+1,H=N+T[0].length,V={from:n.tr.mapping.map(N),to:n.tr.mapping.map(H)},$=i.handler({state:n,range:V,match:T,commands:a,chain:c,can:d,pasteEvent:o,dropEvent:l});u.push($)})}),u.every(f=>f!==null)}var po=null,JC=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function YC(t){const{editor:e,rules:n}=t;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:d,from:u,to:h,rule:f,pasteEvt:p})=>{const g=d.tr,y=ia({state:d,transaction:g});if(!(!GC({editor:e,state:y,from:Math.max(u-1,0),to:h.b-1,rule:f,pasteEvent:p,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return n.map(d=>new me({view(u){const h=p=>{var g;r=(g=u.dom.parentElement)!=null&&g.contains(p.target)?u.dom.parentElement:null,r&&(po=e)},f=()=>{po&&(po=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(u,h)=>{if(i=r===u.dom.parentElement,l=h,!i){const f=po;f?.isEditable&&setTimeout(()=>{const p=f.state.selection;p&&f.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(u,h)=>{var f;const p=(f=h.clipboardData)==null?void 0:f.getData("text/html");return o=h,s=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(u,h,f)=>{const p=u[0],g=p.getMeta("uiEvent")==="paste"&&!s,y=p.getMeta("uiEvent")==="drop"&&!i,b=p.getMeta("applyPasteRules"),w=!!b;if(!g&&!y&&!w)return;if(w){let{text:M}=b;typeof M=="string"?M=M:M=Tu(O.from(M),f.schema);const{from:x}=b,k=x+M.length,v=JC(M);return a({rule:d,state:f,from:x,to:{b:k},pasteEvt:v})}const A=h.doc.content.findDiffStart(f.doc.content),S=h.doc.content.findDiffEnd(f.doc.content);if(!(!WC(A)||!S||A===S.b))return a({rule:d,state:f,from:A,to:S,pasteEvt:o})}}))}var da=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=Uy(t),this.schema=uC(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ac(e.name,this.schema)},r=G(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return Nu([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:ac(r.name,this.schema)},i=[],o=G(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&G(r,"exitable",s)&&(l.ArrowRight=()=>Zt.handleExit({editor:t,mark:r})),o){const h=Object.fromEntries(Object.entries(o()).map(([f,p])=>[f,()=>p({editor:t})]));l={...l,...h}}const a=gS(l);i.push(a);const c=G(r,"addInputRules",s);if(op(r,t.options.enableInputRules)&&c){const h=c();if(h&&h.length){const f=UC({editor:t,rules:h}),p=Array.isArray(f)?f:[f];i.push(...p)}}const d=G(r,"addPasteRules",s);if(op(r,t.options.enablePasteRules)&&d){const h=d();if(h&&h.length){const f=YC({editor:t,rules:h});i.push(...f)}}const u=G(r,"addProseMirrorPlugins",s);if(u){const h=u();i.push(...h)}return i})}get attributes(){return Fy(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=pi(this.extensions);return Object.fromEntries(e.filter(n=>!!G(n,"addNodeView")).map(n=>{const r=this.attributes.filter(a=>a.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ke(n.name,this.schema)},i=G(n,"addNodeView",s);if(!i)return[];const o=i();if(!o)return[];const l=(a,c,d,u,h)=>{const f=mi(a,r);return o({node:a,view:c,getPos:d,decorations:u,innerDecorations:h,editor:t,extension:n,HTMLAttributes:f})};return[n.name,l]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=pi(this.extensions);return Object.fromEntries(e.filter(n=>!!G(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Rn(n.name,this.schema)},i=G(n,"addMarkView",s);if(!i)return[];const o=(l,a,c)=>{const d=mi(l,r);return i()({mark:l,view:a,inline:c,editor:t,extension:n,HTMLAttributes:d,updateAttributes:u=>{hE(l,t,u)}})};return[n.name,o]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:ac(e.name,this.schema)};e.type==="mark"&&((n=we(G(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const s=G(e,"onBeforeCreate",r),i=G(e,"onCreate",r),o=G(e,"onUpdate",r),l=G(e,"onSelectionUpdate",r),a=G(e,"onTransaction",r),c=G(e,"onFocus",r),d=G(e,"onBlur",r),u=G(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}};da.resolve=Uy;da.sort=Nu;da.flatten=Au;var XC={};Cu(XC,{ClipboardTextSerializer:()=>Zy,Commands:()=>Qy,Delete:()=>eb,Drop:()=>tb,Editable:()=>nb,FocusEvents:()=>sb,Keymap:()=>ib,Paste:()=>ob,Tabindex:()=>lb,focusEventsPluginKey:()=>rb});var de=class Xy extends Ru{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Xy(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Zy=de.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new me({key:new ye("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,{ranges:i}=s,o=Math.min(...i.map(d=>d.$from.pos)),l=Math.max(...i.map(d=>d.$to.pos)),a=Wy(n);return Vy(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Qy=de.create({name:"commands",addCommands(){return{...Ry}}}),eb=de.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,s;const i=()=>{var o,l,a,c;if((c=(a=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,t))!=null?c:t.getMeta("y-sync$"))return;const d=$y(t.before,[t,...e]);Ky(d).forEach(f=>{d.mapping.mapResult(f.oldRange.from).deletedAfter&&d.mapping.mapResult(f.oldRange.to).deletedBefore&&d.before.nodesBetween(f.oldRange.from,f.oldRange.to,(p,g)=>{const y=g+p.nodeSize-2,b=f.oldRange.from<=g&&y<=f.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:g,to:y,newFrom:d.mapping.map(g),newTo:d.mapping.map(y),deletedRange:f.oldRange,newRange:f.newRange,partial:!b,editor:this.editor,transaction:t,combinedTransform:d})})});const h=d.mapping;d.steps.forEach((f,p)=>{var g,y;if(f instanceof Wt){const b=h.slice(p).map(f.from,-1),w=h.slice(p).map(f.to),A=h.invert().map(b,-1),S=h.invert().map(w),M=(g=d.doc.nodeAt(b-1))==null?void 0:g.marks.some(k=>k.eq(f.mark)),x=(y=d.doc.nodeAt(w))==null?void 0:y.marks.some(k=>k.eq(f.mark));this.editor.emit("delete",{type:"mark",mark:f.mark,from:f.from,to:f.to,deletedRange:{from:A,to:S},newRange:{from:b,to:w},partial:!!(x||M),editor:this.editor,transaction:t,combinedTransform:d})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(i,0):i()}}),tb=de.create({name:"drop",addProseMirrorPlugins(){return[new me({key:new ye("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),nb=de.create({name:"editable",addProseMirrorPlugins(){return[new me({key:new ye("editable"),props:{editable:()=>this.editor.options.editable}})]}}),rb=new ye("focusEvents"),sb=de.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new me({key:rb,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),ib=de.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:h,parent:f}=u,p=u.parent.isTextblock&&h>0?l.doc.resolve(h-1):u,g=p.parent.type.spec.isolating,y=u.pos-u.parentOffset,b=g&&p.parent.childCount===1?y===u.pos:ee.atStart(c).from===h;return!d||!f.type.isTextblock||f.textContent.length||!b||b&&u.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return la()||Py()?i:s},addProseMirrorPlugins(){return[new me({key:new ye("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(g=>g.getMeta("composition")))return;const r=t.some(g=>g.docChanged)&&!e.doc.eq(n.doc),s=t.some(g=>g.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:l}=e.selection,a=ee.atStart(e.doc).from,c=ee.atEnd(e.doc).to;if(i||!(o===a&&l===c)||!Li(n.doc))return;const h=n.tr,f=ia({state:n,transaction:h}),{commands:p}=new oa({editor:this.editor,state:f});if(p.clearNodes(),!!h.steps.length)return h}})]}}),ob=de.create({name:"paste",addProseMirrorPlugins(){return[new me({key:new ye("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),lb=de.create({name:"tabindex",addProseMirrorPlugins(){return[new me({key:new ye("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),ZC=class Qr{constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Qr(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Qr(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Qr(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=this.pos+r+(i?0:1);if(o<0||o>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(o);if(!s&&l.depth<=this.depth)return;const a=new Qr(l,this.editor,s,s?n:null);s&&(a.actualDepth=this.depth+1),e.push(new Qr(l,this.editor,s,s?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){const i=s.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const a=o[l];if(i[a]!==n[a])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(n);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(a=>n[a]===o.node.attrs[a])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,n,r))))}),s}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},QC=`.ProseMirror {
6
+ <%s key={someKey} {...props} />`,Se,Ce,Ze,Ce),ne[Ce+Se]=!0)}if(Ce=null,le!==void 0&&(n(le),Ce=""+le),o(q)&&(n(q.key),Ce=""+q.key),"key"in q){le={};for(var wt in q)wt!=="key"&&(le[wt]=q[wt])}else le=q;return Ce&&l(le,typeof R=="function"?R.displayName||R.name||"Unknown":R),c(R,Ce,le,s(),Ot,Ye)}function d(R){h(R)?R._store&&(R._store.validated=1):typeof R=="object"&&R!==null&&R.$$typeof===C&&(R._payload.status==="fulfilled"?h(R._payload.value)&&R._payload.value._store&&(R._payload.value._store.validated=1):R._store&&(R._store.validated=1))}function h(R){return typeof R=="object"&&R!==null&&R.$$typeof===p}var f=E,p=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),k=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),v=Symbol.for("react.suspense_list"),A=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),D=Symbol.for("react.client.reference"),z=f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=Object.prototype.hasOwnProperty,_=Array.isArray,V=console.createTask?console.createTask:function(){return null};f={react_stack_bottom_frame:function(R){return R()}};var ee,be={},I=f.react_stack_bottom_frame.bind(f,i)(),P=V(r(i)),ne={};di.Fragment=y,di.jsx=function(R,q,le){var Se=1e4>z.recentlyCreatedOwnerStacks++;return u(R,q,le,!1,Se?Error("react-stack-top-frame"):I,Se?V(r(R)):P)},di.jsxs=function(R,q,le){var Se=1e4>z.recentlyCreatedOwnerStacks++;return u(R,q,le,!0,Se?Error("react-stack-top-frame"):I,Se?V(r(R)):P)}})()),di}var Wp;function bS(){return Wp||(Wp=1,process.env.NODE_ENV==="production"?tl.exports=gS():tl.exports=yS()),tl.exports}var g=bS(),nl={exports:{}},pu={};var qp;function xS(){if(qp)return pu;qp=1;var t=E;function e(d,h){return d===h&&(d!==0||1/d===1/h)||d!==d&&h!==h}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,s=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function l(d,h){var f=h(),p=r({inst:{value:f,getSnapshot:h}}),m=p[0].inst,y=p[1];return i(function(){m.value=f,m.getSnapshot=h,a(m)&&y({inst:m})},[d,f,h]),s(function(){return a(m)&&y({inst:m}),d(function(){a(m)&&y({inst:m})})},[d]),o(f),f}function a(d){var h=d.getSnapshot;d=d.value;try{var f=h();return!n(d,f)}catch{return!0}}function c(d,h){return h()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:l;return pu.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,pu}var mu={};var Kp;function wS(){return Kp||(Kp=1,process.env.NODE_ENV!=="production"&&(function(){function t(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}function e(f,p){u||s.startTransition===void 0||(u=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var m=p();if(!d){var y=p();i(m,y)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}y=o({inst:{value:m,getSnapshot:p}});var b=y[0].inst,x=y[1];return a(function(){b.value=m,b.getSnapshot=p,n(b)&&x({inst:b})},[f,m,p]),l(function(){return n(b)&&x({inst:b}),f(function(){n(b)&&x({inst:b})})},[f]),c(m),m}function n(f){var p=f.getSnapshot;f=f.value;try{var m=p();return!i(f,m)}catch{return!0}}function r(f,p){return p()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=E,i=typeof Object.is=="function"?Object.is:t,o=s.useState,l=s.useEffect,a=s.useLayoutEffect,c=s.useDebugValue,u=!1,d=!1,h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:e;mu.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:h,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),mu}var Jp;function $h(){return Jp||(Jp=1,process.env.NODE_ENV==="production"?nl.exports=xS():nl.exports=wS()),nl.exports}var gb=$h();function ot(t){this.content=t}ot.prototype={constructor:ot,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),i=r.content.slice();return s==-1?i.push(n||t,e):(i[s+1]=e,n&&(i[s]=n)),new ot(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new ot(n)},addToStart:function(t,e){return new ot([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new ot(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),i=r.find(t);return s.splice(i==-1?s.length:i,0,e,n),new ot(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=ot.from(t),t.size?new ot(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=ot.from(t),t.size?new ot(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=ot.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};ot.from=function(t){if(t instanceof ot)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new ot(e)};function yb(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)n++;return n}if(s.content.size||i.content.size){let o=yb(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function bb(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){n-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let c=bb(o.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}let j=class kt{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,l=0;l<n;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new kt(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),s+=l.nodeSize),o=a}return new kt(r,s)}cutByIndex(e,n){return e==n?kt.empty:e==0&&n==this.content.length?this:new kt(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new kt(s,i)}addToStart(e){return new kt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new kt(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return yb(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return bb(this,e,n,r)}findIndex(e){if(e==0)return rl(0,e);if(e==this.size)return rl(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?rl(n+1,i):rl(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return kt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return kt.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return kt.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new kt(n||e,r)}static from(e){if(!e)return kt.empty;if(e instanceof kt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new kt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};j.empty=new j([],0);const gu={index:0,offset:0};function rl(t,e){return gu.index=t,gu.offset=e,gu}function ea(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!ea(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!ea(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Ae=class wd{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ea(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return wd.none;if(e instanceof wd)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};Ae.none=[];let ta=class extends Error{},F=class ps{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=wb(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new ps(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ps(xb(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ps.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ps(j.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new ps(e,r,s)}};F.empty=new F(j.empty,0,0);function xb(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(xb(i.content,e-s-1,n-s-1)))}function wb(t,e,n,r,s,i){let{index:o,offset:l}=t.findIndex(e),a=t.maybeChild(o);if(l==e||a.isText)return i&&r<=0&&s<=0&&!i.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=wb(a.content,e-l-1,n,o==0?r-1:0,o==t.childCount-1?s-1:0,a);return c&&t.replaceChild(o,a.copy(c))}function kS(t,e,n){if(n.openStart>t.depth)throw new ta("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new ta("Inconsistent open depths");return kb(t,e,n,0)}function kb(t,e,n,r){let s=t.index(r),i=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let o=kb(t,e,n,r+1);return i.copy(i.content.replaceChild(s,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return Pr(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=vS(n,t);return Pr(i,Sb(t,o,l,e,r))}else return Pr(i,na(t,e,r))}function vb(t,e){if(!e.type.compatibleContent(t.type))throw new ta("Cannot join "+e.type.name+" onto "+t.type.name)}function kd(t,e,n){let r=t.node(n);return vb(r,e.node(n)),r}function Ir(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Ii(t,e,n,r){let s=(e||t).node(n),i=0,o=e?e.index(n):s.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Ir(t.nodeAfter,r),i++));for(let l=i;l<o;l++)Ir(s.child(l),r);e&&e.depth==n&&e.textOffset&&Ir(e.nodeBefore,r)}function Pr(t,e){return t.type.checkContent(e),t.copy(e)}function Sb(t,e,n,r,s){let i=t.depth>s&&kd(t,e,s+1),o=r.depth>s&&kd(n,r,s+1),l=[];return Ii(null,t,s,l),i&&o&&e.index(s)==n.index(s)?(vb(i,o),Ir(Pr(i,Sb(t,e,n,r,s+1)),l)):(i&&Ir(Pr(i,na(t,e,s+1)),l),Ii(e,n,s,l),o&&Ir(Pr(o,na(n,r,s+1)),l)),Ii(r,null,s,l),new j(l)}function na(t,e,n){let r=[];if(Ii(null,t,n,r),t.depth>n){let s=kd(t,e,n+1);Ir(Pr(s,na(t,e,n+1)),r)}return Ii(e,null,n,r),new j(r)}function vS(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)s=e.node(i).copy(j.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class eo{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Ae.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let l=r;r=s,s=l}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new to(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,i=n;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(i),c=i-a;if(r.push(o,l,s+a),!c||(o=o.child(l),o.isText))break;i=c-1,s+=a+1}return new eo(n,r,i)}static resolveCached(e,n){let r=Gp.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==n)return o}else Gp.set(e,r=new SS);let s=r.elts[r.i]=eo.resolve(e,n);return r.i=(r.i+1)%CS,s}}class SS{constructor(){this.elts=[],this.i=0}}const CS=12,Gp=new WeakMap;class to{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const ES=Object.create(null);let cr=class vd{constructor(e,n,r,s=Ae.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||j.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,s=0){this.content.nodesBetween(e,n,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,s){return this.content.textBetween(e,n,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&ea(this.attrs,n||e.defaultAttrs||ES)&&Ae.sameSet(this.marks,r||Ae.none)}copy(e=null){return e==this.content?this:new vd(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new vd(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return F.empty;let s=this.resolve(e),i=this.resolve(n),o=r?0:s.sharedDepth(n),l=s.start(o),c=s.node(o).content.cut(s.pos-l,i.pos-l);return new F(c,s.depth-o,i.depth-o)}replace(e,n,r){return kS(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return eo.resolveCached(this,e)}resolveNoCache(e){return eo.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Cb(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=j.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=s;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Ae.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Ae.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=j.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,s,r);return i.type.checkAttrs(i.attrs),i}};cr.prototype.text=void 0;class ra extends cr{constructor(e,n,r,s){if(super(e,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Cb(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new ra(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new ra(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Cb(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Fr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new AS(e,n);if(r.next==null)return Fr.empty;let s=Eb(r);r.next&&r.err("Unexpected trailing text");let i=DS(OS(s));return LS(i,r),i}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let i=n;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function i(o,l){let a=o.matchFragment(e,r);if(a&&(!n||a.validEnd))return j.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let h=i(d,l.concat(u));if(h)return h}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:a}=i.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
7
+ `)}}Fr.empty=new Fr(!0);class AS{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Eb(t){let e=[];do e.push(MS(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function MS(t){let e=[];do e.push(TS(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function TS(t){let e=_S(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=NS(t,e);else break;return e}function Yp(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function NS(t,e){let n=Yp(t),r=n;return t.eat(",")&&(t.next!="}"?r=Yp(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function RS(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let i in n){let o=n[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function _S(t){if(t.eat("(")){let e=Eb(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=RS(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function OS(t){let e=[[]];return s(i(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function s(o,l){o.forEach(a=>a.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=i(o.exprs[a],l);if(a==o.exprs.length-1)return c;s(c,l=n())}else if(o.type=="star"){let a=n();return r(l,a),s(i(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=n();return s(i(o.expr,l),a),s(i(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=n();s(i(o.expr,a),u),a=u}if(o.max==-1)s(i(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=n();r(a,u),s(i(o.expr,a),u),a=u}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Ab(t,e){return e-t}function Xp(t,e){let n=[];return r(e),n.sort(Ab);function r(s){let i=t[s];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(s);for(let o=0;o<i.length;o++){let{term:l,to:a}=i[o];!l&&n.indexOf(a)==-1&&r(a)}}}function DS(t){let e=Object.create(null);return n(Xp(t,0));function n(r){let s=[];r.forEach(o=>{t[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<s.length;u++)s[u][0]==l&&(c=s[u][1]);Xp(t,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new Fr(r.indexOf(t.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(Ab);i.next.push({type:s[o][0],next:e[l.join(",")]||n(l)})}return i}}function LS(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],i=!s.validEnd,o=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];o.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Mb(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Tb(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let i=t[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function Nb(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${s}`);for(let s in t){let i=t[s];i.validate&&i.validate(e[s])}}function Rb(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new PS(t,r,e[r]);return n}let Zp=class _b{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Rb(e,r.attrs),this.defaultAttrs=Mb(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==Fr.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:Tb(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new cr(this,this.computeAttrs(e),j.from(n),Ae.setFrom(r))}createChecked(e=null,n,r){return n=j.from(n),this.checkContent(n),new cr(this,this.computeAttrs(e),n,Ae.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=j.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let s=this.contentMatch.matchFragment(n),i=s&&s.fillBefore(j.empty,!0);return i?new cr(this,e,n.append(i),Ae.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Nb(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:Ae.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,o)=>r[i]=new _b(i,n,o));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function IS(t,e,n){let r=n.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class PS{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?IS(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class mc{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=Rb(e,s.attrs),this.excluded=null;let i=Mb(this.attrs);this.instance=i?new Ae(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Ae(this,Tb(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new mc(i,s++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){Nb(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}let Ob=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=ot.from(e.nodes),n.marks=ot.from(e.marks||{}),this.nodes=Zp.compile(this.spec.nodes,this),this.marks=mc.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=Fr.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?Qp(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:Qp(this,o.split(" "))}this.nodeFromJSON=s=>cr.fromJSON(this,s),this.markFromJSON=s=>Ae.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Zp){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,s)}text(e,n){let r=this.nodes.text;return new ra(r,r.defaultAttrs,e,Ae.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function Qp(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],i=t.marks[s],o=i;if(i)n.push(i);else for(let l in t.marks){let a=t.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&n.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function jS(t){return t.tag!=null}function $S(t){return t.style!=null}let Pi=class Sd{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(jS(s))this.tags.push(s);else if($S(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new tm(this,n,!1);return r.addAll(e,Ae.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new tm(this,n,!0);return r.addAll(e,Ae.none,n.from,n.to),F.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(HS(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let a=o.getAttrs(n);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<i)break}n.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=nm(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=nm(o)),o.node||o.ignore||o.mark||(o.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Sd(e,Sd.schemaRules(e)))}};const Db={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},BS={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Lb={ol:!0,ul:!0},no=1,Cd=2,ji=4;function em(t,e,n){return e!=null?(e?no:0)|(e==="full"?Cd:0):t&&t.whitespace=="pre"?no|Cd:n&~ji}class sl{constructor(e,n,r,s,i,o){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=Ae.none,this.match=i||(o&ji?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(j.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&no)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=j.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(j.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Db.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class tm{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,o=em(null,n.preserveWhitespace,0)|(r?ji:0);s?i=new sl(s.type,s.attrs,Ae.none,!0,n.topMatch||s.type.contentMatch,o):r?i=new sl(null,null,Ae.none,!0,null,o):i=new sl(e.schema.topNodeType,null,Ae.none,!0,null,o),this.nodes=[i],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,i=s.options&Cd?"full":this.localPreserveWS||(s.options&no)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
8
+ `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[a]&&this.insertNode(o.text(l[a]),n,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Lb.hasOwnProperty(o)&&this.parser.normalizeLists&&zS(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:BS.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Db.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=a&&a.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
9
+ `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(i,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,s){let i,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,n.attrs||null,r,n.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)n=this.enterInner(s[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=Ae.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):rm(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=em(e,i,o.options);o.options&ji&&o.content.length==0&&(l|=ji);let a=Ae.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):rm(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new sl(e,n,a,s,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=no)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function zS(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Lb.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function HS(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function nm(t){let e={};for(let n in t)e[n]=t[n];return e}function rm(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&o(u))return!0}};if(o(s.contentMatch))return!0}}class ns{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=il(n).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,n);u&&(i.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){if(e.isText)return il(n).createTextNode(e.text);let{dom:r,contentDOM:s}=_l(il(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&_l(il(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return typeof n=="string"?{dom:e.createTextNode(n)}:_l(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ns(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=sm(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return sm(e.marks)}}function sm(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function il(t){return t.document||window.document}const im=new WeakMap;function FS(t){let e=im.get(t);return e===void 0&&im.set(t,e=US(t)),e}function US(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function _l(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=FS(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(n=s.slice(0,o),s=s.slice(o+1));let l,a=n?t.createElementNS(n,s):t.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let h=d.indexOf(" ");h>0?a.setAttributeNS(d.slice(0,h),d.slice(h+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let h=e[d];if(h===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof h=="string")a.appendChild(t.createTextNode(h));else{let{dom:f,contentDOM:p}=_l(t,h,n,r);if(a.appendChild(f),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Ib=65535,Pb=Math.pow(2,16);function VS(t,e){return t+e*Pb}function om(t){return t&Ib}function WS(t){return(t-(t&Ib))/Pb}const jb=1,$b=2,Ol=4,Bb=8;let Ed=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Bb)>0}get deletedBefore(){return(this.delInfo&(jb|Ol))>0}get deletedAfter(){return(this.delInfo&($b|Ol))>0}get deletedAcross(){return(this.delInfo&Ol)>0}},Ur=class ms{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&ms.empty)return ms.empty}recover(e){let n=0,r=om(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+WS(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+o],d=a+c;if(e<=d){let h=c?e==a?-1:e==d?1:n:n,f=a+s+(h<0?0:u);if(r)return f;let p=e==(n<0?a:d)?null:VS(l/3,e-a),m=e==a?$b:e==d?jb:Ol;return(n<0?e!=a:e!=d)&&(m|=Bb),new Ed(f,m,p)}s+=u-c}return r?e+s:new Ed(e+s,0,null)}touches(e,n){let r=0,s=om(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+n],u=this.ranges[s+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new ms(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ms.empty:new ms(e<0?[0,-e,0]:[0,0,e])}};Ur.empty=new Ur([]);class ro{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new ro(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new ro;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new Ed(e,s,null)}}const yu=Object.create(null);let bt=class{getMap(){return Ur.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=yu[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in yu)throw new RangeError("Duplicate use of step JSON ID "+e);return yu[e]=n,n.prototype.jsonID=e,n}},Ct=class bi{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new bi(e,null)}static fail(e){return new bi(null,e)}static fromReplace(e,n,r,s){try{return bi.ok(e.replace(n,r,s))}catch(i){if(i instanceof ta)return bi.fail(i.message);throw i}}};function Bh(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(Bh(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return j.fromArray(r)}let zh=class xi extends bt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new F(Bh(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return Ct.fromReplace(e,this.from,this.to,i)}invert(){return new Xs(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new xi(n.pos,r.pos,this.mark)}merge(e){return e instanceof xi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new xi(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new xi(n.from,n.to,e.markFromJSON(n.mark))}};bt.jsonID("addMark",zh);let Xs=class wi extends bt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new F(Bh(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return Ct.fromReplace(e,this.from,this.to,r)}invert(){return new zh(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new wi(n.pos,r.pos,this.mark)}merge(e){return e instanceof wi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new wi(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new wi(n.from,n.to,e.markFromJSON(n.mark))}};bt.jsonID("removeMark",Xs);let Hh=class ki extends bt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ct.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Ct.fromReplace(e,this.pos,this.pos+1,new F(j.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new ki(this.pos,n.marks[s]);return new ki(this.pos,this.mark)}}return new sa(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ki(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new ki(n.pos,e.markFromJSON(n.mark))}};bt.jsonID("addNodeMark",Hh);let sa=class Ad extends bt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ct.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Ct.fromReplace(e,this.pos,this.pos+1,new F(j.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Hh(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ad(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ad(n.pos,e.markFromJSON(n.mark))}};bt.jsonID("removeNodeMark",sa);let Qt=class Xn extends bt{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Md(e,this.from,this.to)?Ct.fail("Structure replace would overwrite content"):Ct.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ur([this.from,this.to-this.from,this.slice.size])}invert(e){return new Xn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&Xn.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new Xn(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Xn)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?F.empty:new F(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Xn(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?F.empty:new F(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Xn(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Xn(n.from,n.to,F.fromJSON(e,n.slice),!!n.structure)}};Qt.MAP_BIAS=1;bt.jsonID("replace",Qt);let jt=class Dl extends bt{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Md(e,this.from,this.gapFrom)||Md(e,this.gapTo,this.to)))return Ct.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Ct.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Ct.fromReplace(e,this.from,this.to,r):Ct.fail("Content does not fit in gap")}getMap(){return new Ur([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Dl(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new Dl(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Dl(n.from,n.to,n.gapFrom,n.gapTo,F.fromJSON(e,n.slice),n.insert,!!n.structure)}};bt.jsonID("replaceAround",jt);function Md(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function qS(t,e,n,r){let s=[],i=[],o,l;t.doc.nodesBetween(e,n,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let h=Math.max(c,e),f=Math.min(c+a.nodeSize,n),p=r.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(p)||(o&&o.to==h&&o.mark.eq(d[m])?o.to=f:s.push(o=new Xs(h,f,d[m])));l&&l.to==h?l.to=f:i.push(l=new zh(h,f,r))}}),s.forEach(a=>t.step(a)),i.forEach(a=>t.step(a))}function KS(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;i++;let a=null;if(r instanceof mc){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,n);for(let u=0;u<a.length;u++){let d=a[u],h;for(let f=0;f<s.length;f++){let p=s[f];p.step==i-1&&d.eq(s[f].style)&&(h=p)}h?(h.to=c,h.step=i):s.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(o=>t.step(new Xs(o.from,o.to,o.style)))}function Fh(t,e,n,r=n.contentMatch,s=!0){let i=t.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new Qt(l,u,F.empty));else{r=d;for(let h=0;h<c.marks.length;h++)n.allowsMarkType(c.marks[h].type)||t.step(new Xs(l,u,c.marks[h]));if(s&&c.isText&&n.whitespace!="pre"){let h,f=/\r?\n|\r/g,p;for(;h=f.exec(c.text);)p||(p=new F(j.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),o.push(new Qt(l+h.index,l+h.index+h[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(j.empty,!0);t.replace(l,l,new F(a,0,0))}for(let a=o.length-1;a>=0;a--)t.step(o[a])}function JS(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Zs(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,i=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+s,a=t.$to.indexAfter(r)-i;if(r<t.depth&&o.canReplace(l,a,n))return r;if(r==0||o.type.spec.isolating||!JS(o,l,a))break;l&&(s=1),a<o.childCount&&(i=1)}return null}function GS(t,e,n){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),l=s.after(i+1),a=o,c=l,u=j.empty,d=0;for(let p=i,m=!1;p>n;p--)m||r.index(p)>0?(m=!0,u=j.from(r.node(p).copy(u)),d++):a--;let h=j.empty,f=0;for(let p=i,m=!1;p>n;p--)m||s.after(p+1)<s.end(p)?(m=!0,h=j.from(s.node(p).copy(h)),f++):c++;t.step(new jt(a,c,o,l,new F(u.append(h),d,f),u.size-d,!0))}function Uh(t,e,n=null,r=t){let s=YS(t,e),i=s&&XS(r,e);return i?s.map(lm).concat({type:e,attrs:n}).concat(i.map(lm)):null}function lm(t){return{type:t,attrs:null}}function YS(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return n.canReplaceWith(r,s,o)?i:null}function XS(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:o}function ZS(t,e,n){let r=j.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=j.from(n[o].type.create(n[o].attrs,r))}let s=e.start,i=e.end;t.step(new jt(s,i,s,i,new F(r,0,0),n.length,!0))}function QS(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let a=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,a)&&eC(t.doc,t.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&Hb(t,o,l,i),Fh(t,t.mapping.slice(i).map(l,1),r,void 0,c===null);let u=t.mapping.slice(i),d=u.map(l,1),h=u.map(l+o.nodeSize,1);return t.step(new jt(d,h,d+1,h-1,new F(j.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&zb(t,o,l,i),!1}})}function zb(t,e,n,r){e.forEach((s,i)=>{if(s.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(s.text);){let a=t.mapping.slice(r).map(n+1+i+o.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Hb(t,e,n,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text(`
10
+ `))}})}function eC(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function tC(t,e,n,r,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let o=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,o);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new jt(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new F(j.from(o),0,0),1,!0))}function $n(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,o=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!o.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,u=n-2;c>i;c--,u--){let d=s.node(c),h=s.index(c);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(h,d.childCount),p=r&&r[u+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(h+1,d.childCount)||!m.type.validContent(f))return!1}let l=s.indexAfter(i),a=r&&r[0];return s.node(i).canReplaceWith(l,l,a?a.type:s.node(i+1).type)}function nC(t,e,n=1,r){let s=t.doc.resolve(e),i=j.empty,o=j.empty;for(let l=s.depth,a=s.depth-n,c=n-1;l>a;l--,c--){i=j.from(s.node(l).copy(i));let u=r&&r[c];o=j.from(u?u.type.create(u.attrs,o):s.node(l).copy(o))}t.step(new Qt(e,e,new F(i.append(o),n,n),!0))}function kr(t,e){let n=t.resolve(e),r=n.index();return Fb(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function rC(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let i=e.child(s),o=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function Fb(t,e){return!!(t&&e&&!t.isLeaf&&rC(t,e))}function gc(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let i,o,l=r.index(s);if(s==r.depth?(i=r.nodeBefore,o=r.nodeAfter):n>0?(i=r.node(s+1),l++,o=r.node(s).maybeChild(l)):(i=r.node(s).maybeChild(l-1),o=r.node(s+1)),i&&!i.isTextblock&&Fb(i,o)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function sC(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),o=i.node().type;if(s&&o.inlineContent){let u=o.whitespace=="pre",d=!!o.contentMatch.matchType(s);u&&!d?r=!1:!u&&d&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);Hb(t,u.node(),u.before(),l)}o.inlineContent&&Fh(t,e+n-1,o,i.node().contentMatchAt(i.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new Qt(c,a.map(e+n,-1),F.empty,!0)),r===!0){let u=t.doc.resolve(c);zb(t,u.node(),u.before(),t.steps.length)}return t}function iC(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let i=r.index(s);if(r.node(s).canReplaceWith(i,i,n))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,n))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function Ub(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,a=r.index(o)+(l>0?1:0),c=r.node(o),u=!1;if(i==1)u=c.canReplace(a,a,s);else{let d=c.contentMatchAt(a).findWrapping(s.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function yc(t,e,n=e,r=F.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return Vb(s,i,r)?new Qt(e,n,r):new oC(s,i,r).fit()}function Vb(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class oC{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=j.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=j.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let i=this.placed,o=r.depth,l=s.depth;for(;o&&l&&i.childCount==1;)i=i.firstChild.content,o--,l--;let a=new F(i,o,l);return e>-1?new jt(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new Qt(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=bu(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let o=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(n==1&&(o?c.matchType(o.type)||(d=c.fillBefore(j.from(o),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(n==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=bu(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new F(e,n+1,Math.max(r,s.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=bu(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new F(vi(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new F(vi(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,u=[],{match:d,type:h}=this.frontier[n];if(s){for(let m=0;m<s.childCount;m++)u.push(s.child(m));d=d.matchFragment(s)}let f=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let m=l.child(c),y=d.matchType(m.type);if(!y)break;c++,(c>1||a==0||m.content.size)&&(d=y,u.push(Wb(m.mark(h.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?f:-1)))}let p=c==l.childCount;p||(f=-1),this.placed=Si(this.placed,n,j.from(u)),this.frontier[n].match=d,p&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,y=l;m<f;m++){let b=y.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),y=b.content}this.unplaced=p?e==0?F.empty:new F(vi(o.content,e-1,1),e-1,f<0?o.openEnd:e-1):new F(vi(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!xu(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=xu(e,n,s,r,i);if(o){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=xu(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:o,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Si(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=Si(this.placed,this.depth,j.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(j.empty,!0);n.childCount&&(this.placed=Si(this.placed,this.frontier.length,n))}}function vi(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(vi(t.firstChild.content,e-1,n)))}function Si(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Si(t.lastChild.content,e-1,n)))}function bu(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Wb(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Wb(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(j.empty,!0)))),t.copy(r)}function xu(t,e,n,r,s){let i=t.node(e),o=s?t.indexAfter(e):t.index(e);if(o==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,o);return l&&!lC(n,i.content,o)?l:null}function lC(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function aC(t){return t.spec.defining||t.spec.definingForContent}function cC(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(Vb(s,i,r))return t.step(new Qt(e,n,r));let o=Kb(s,i);o[o.length-1]==0&&o.pop();let l=-(s.depth+1);o.unshift(l);for(let h=s.depth,f=s.pos-1;h>0;h--,f--){let p=s.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(h)>-1?l=h:s.before(h)==f&&o.splice(1,0,-h)}let a=o.indexOf(l),c=[],u=r.openStart;for(let h=r.content,f=0;;f++){let p=h.firstChild;if(c.push(p),f==r.openStart)break;h=p.content}for(let h=u-1;h>=0;h--){let f=c[h],p=aC(f.type);if(p&&!f.sameMarkup(s.node(Math.abs(l)-1)))u=h;else if(p||!f.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let f=(h+u+1)%(r.openStart+1),p=c[f];if(p)for(let m=0;m<o.length;m++){let y=o[(m+a)%o.length],b=!0;y<0&&(b=!1,y=-y);let x=s.node(y-1),w=s.index(y-1);if(x.canReplaceWith(w,w,p.type,p.marks))return t.replace(s.before(y),b?i.after(y):n,new F(qb(r.content,0,r.openStart,f),f,r.openEnd))}}let d=t.steps.length;for(let h=o.length-1;h>=0&&(t.replace(e,n,r),!(t.steps.length>d));h--){let f=o[h];f<0||(e=s.before(f),n=i.after(f))}}function qb(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(qb(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),o=i.fillBefore(t).append(t);t=o.append(i.matchFragment(o).fillBefore(j.empty,!0))}return t}function uC(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=iC(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new F(j.from(r),0,0))}function dC(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n);if(r.parent.isTextblock&&s.parent.isTextblock&&r.start()!=s.start()&&r.parentOffset==0&&s.parentOffset==0){let o=r.sharedDepth(n),l=!1;for(let a=r.depth;a>o;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=s.depth;a>o;a--)s.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=s.depth;a>0&&n==s.start(a);a--)n=s.before(a);r=t.doc.resolve(e),s=t.doc.resolve(n)}}let i=Kb(r,s);for(let o=0;o<i.length;o++){let l=i[o],a=o==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return t.delete(r.before(l),s.after(l))}for(let o=1;o<=r.depth&&o<=s.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&s.end(o)-n!=s.depth-o&&r.start(o-1)==s.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),s.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function Kb(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}let Jb=class Ll extends bt{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ct.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return Ct.fromReplace(e,this.pos,this.pos+1,new F(j.from(s),0,n.isLeaf?0:1))}getMap(){return Ur.empty}invert(e){return new Ll(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ll(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ll(n.pos,n.attr,n.value)}};bt.jsonID("attr",Jb);let Gb=class Td extends bt{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Ct.ok(r)}getMap(){return Ur.empty}invert(e){return new Td(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Td(n.attr,n.value)}};bt.jsonID("docAttr",Gb);let _s=class extends Error{};_s=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};_s.prototype=Object.create(Error.prototype);_s.prototype.constructor=_s;_s.prototype.name="TransformError";class Vh{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ro}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new _s(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(e=s.map(e,1),n=s.map(n,-1)),s.forEach((i,o,l,a)=>{e=Math.min(e,l),n=Math.max(n,a)})}return e==1e9?null:{from:e,to:n}}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=F.empty){let s=yc(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new F(j.from(r),0,0))}delete(e,n){return this.replace(e,n,F.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return cC(this,e,n,r),this}replaceRangeWith(e,n,r){return uC(this,e,n,r),this}deleteRange(e,n){return dC(this,e,n),this}lift(e,n){return GS(this,e,n),this}join(e,n=1){return sC(this,e,n),this}wrap(e,n){return ZS(this,e,n),this}setBlockType(e,n=e,r,s=null){return QS(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return tC(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new Jb(e,n,r)),this}setDocAttribute(e,n){return this.step(new Gb(e,n)),this}addNodeMark(e,n){return this.step(new Hh(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof Ae)n.isInSet(r.marks)&&this.step(new sa(e,n));else{let s=r.marks,i,o=[];for(;i=n.isInSet(s);)o.push(new sa(e,i)),s=i.removeFromSet(s);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return nC(this,e,n,r),this}addMark(e,n,r){return qS(this,e,n,r),this}removeMark(e,n,r){return KS(this,e,n,r),this}clearIncompatible(e,n,r){return Fh(this,e,n,r),this}}const wu=Object.create(null);let te=class{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Wh(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=F.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.openEnd;l++)s=r,r=r.lastChild;let i=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?F.empty:n),l==0&&um(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:o,$to:l}=s[i],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),um(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new Q(e):gs(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let o=n<0?gs(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):gs(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new xn(e.node(0))}static atStart(e){return gs(e,e,0,0,1)||new xn(e)}static atEnd(e){return gs(e,e,e.content.size,e.childCount,-1)||new xn(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=wu[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in wu)throw new RangeError("Duplicate use of selection JSON ID "+e);return wu[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Q.between(this.$anchor,this.$head).getBookmark()}};te.prototype.visible=!0;let Wh=class{constructor(e,n){this.$from=e,this.$to=n}},am=!1;function cm(t){!am&&!t.parent.inlineContent&&(am=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}let Q=class Ci extends te{constructor(e,n=e){cm(e),cm(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return te.near(r);let s=e.resolve(n.map(this.anchor));return new Ci(s.parent.inlineContent?s:r,r)}replace(e,n=F.empty){if(super.replace(e,n),n==F.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Ci&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Yb(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Ci(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=te.findFrom(n,r,!0)||te.findFrom(n,-r,!0);if(i)n=i.$head;else return te.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(te.findFrom(e,-r,!0)||te.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new Ci(e,n)}};te.jsonID("text",Q);let Yb=class Xb{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Xb(e.map(this.anchor),e.map(this.head))}resolve(e){return Q.between(e.resolve(this.anchor),e.resolve(this.head))}},Y=class Ei extends te{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?te.near(i):new Ei(i)}content(){return new F(j.from(this.node),0,0)}eq(e){return e instanceof Ei&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new hC(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ei(e.resolve(n.anchor))}static create(e,n){return new Ei(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};Y.prototype.visible=!1;te.jsonID("node",Y);let hC=class Zb{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Yb(r,r):new Zb(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Y.isSelectable(r)?new Y(n):te.near(n)}},xn=class Il extends te{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=F.empty){if(n==F.empty){e.delete(0,e.doc.content.size);let r=te.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Il(e)}map(e){return new Il(e)}eq(e){return e instanceof Il}getBookmark(){return fC}};te.jsonID("all",xn);const fC={map(){return this},resolve(t){return new xn(t)}};function gs(t,e,n,r,s,i=!1){if(e.inlineContent)return Q.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&Y.isSelectable(l))return Y.create(t,n-(s<0?l.nodeSize:0))}else{let a=gs(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function um(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Qt||s instanceof jt))return;let i=t.mapping.maps[r],o;i.forEach((l,a,c,u)=>{o==null&&(o=u)}),t.setSelection(te.near(t.doc.resolve(o),n))}const dm=1,ol=2,hm=4;let pC=class extends Vh{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|dm)&~ol,this.storedMarks=null,this}get selectionSet(){return(this.updated&dm)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ol,this}ensureMarks(e){return Ae.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&ol)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~ol,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Ae.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let o=this.doc.resolve(n);i=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(te.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=hm,this}get scrolledIntoView(){return(this.updated&hm)>0}};function fm(t,e){return!e||!t?t:t.bind(e)}let Ai=class{constructor(e,n,r){this.name=e,this.init=fm(n.init,r),this.apply=fm(n.apply,r)}};const mC=[new Ai("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Ai("selection",{init(t,e){return t.selection||te.atStart(e.doc)},apply(t){return t.selection}}),new Ai("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Ai("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class ku{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=mC.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Ai(r.key,r.spec.state,r))})}}class vs{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let i=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=s?s[o].n:0,c=s?s[o].state:this,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,o)){if(u.setMeta("appendedTransaction",e),!s){s=[];for(let d=0;d<this.config.plugins.length;d++)s.push(d<o?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),i=!0}s&&(s[o]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new vs(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new pC(this)}static create(e){let n=new ku(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new vs(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new ku(this.schema,e.plugins),r=n.fields,s=new vs(n);for(let i=0;i<r.length;i++){let o=r[i].name;s[o]=this.hasOwnProperty(o)?this[o]:r[i].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],i=s.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new ku(e.schema,e.plugins),i=new vs(s);return s.fields.forEach(o=>{if(o.name=="doc")i.doc=cr.fromJSON(e.schema,n.doc);else if(o.name=="selection")i.selection=te.fromJSON(i.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[o.name]=c.fromJSON.call(a,e,n[l],i);return}}i[o.name]=o.init(e,i)}}),i}}function Qb(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Qb(s,e,{})),n[r]=s}return n}class me{constructor(e){this.spec=e,this.props={},e.props&&Qb(e.props,this,this.props),this.key=e.key?e.key.key:e0("plugin")}getState(e){return e[this.key]}}const vu=Object.create(null);function e0(t){return t in vu?t+"$"+ ++vu[t]:(vu[t]=0,t+"$")}class ge{constructor(e="key"){this.key=e0(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const t0=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function n0(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const r0=(t,e,n)=>{let r=n0(t,n);if(!r)return!1;let s=qh(r);if(!s){let o=r.blockRange(),l=o&&Zs(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let i=s.nodeBefore;if(h0(t,s,e,-1))return!0;if(r.parent.content.size==0&&(Os(i,"end")||Y.isSelectable(i)))for(let o=r.depth;;o--){let l=yc(t.doc,r.before(o),r.after(o),F.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(Os(i,"end")?te.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):Y.create(a.doc,s.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},gC=(t,e,n)=>{let r=n0(t,n);if(!r)return!1;let s=qh(r);return s?s0(t,s,e):!1},yC=(t,e,n)=>{let r=o0(t,n);if(!r)return!1;let s=Kh(r);return s?s0(t,s,e):!1};function s0(t,e,n){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let u=s.lastChild;if(!u)return!1;s=u}let o=e.nodeAfter,l=o,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=yc(t.doc,i,a,F.empty);if(!c||c.from!=i||c instanceof Qt&&c.slice.size>=a-i)return!1;if(n){let u=t.tr.step(c);u.setSelection(Q.create(u.doc,i)),n(u.scrollIntoView())}return!0}function Os(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const i0=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=qh(r)}let o=i&&i.nodeBefore;return!o||!Y.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Y.create(t.doc,i.pos-o.nodeSize)).scrollIntoView()),!0)};function qh(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function o0(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const l0=(t,e,n)=>{let r=o0(t,n);if(!r)return!1;let s=Kh(r);if(!s)return!1;let i=s.nodeAfter;if(h0(t,s,e,1))return!0;if(r.parent.content.size==0&&(Os(i,"start")||Y.isSelectable(i))){let o=yc(t.doc,r.before(),r.after(),F.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(Os(i,"start")?te.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):Y.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},a0=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=Kh(r)}let o=i&&i.nodeAfter;return!o||!Y.isSelectable(o)?!1:(e&&e(t.tr.setSelection(Y.create(t.doc,i.pos)).scrollIntoView()),!0)};function Kh(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const bC=(t,e)=>{let n=t.selection,r=n instanceof Y,s;if(r){if(n.node.isTextblock||!kr(t.doc,n.from))return!1;s=n.from}else if(s=gc(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(Y.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},xC=(t,e)=>{let n=t.selection,r;if(n instanceof Y){if(n.node.isTextblock||!kr(t.doc,n.to))return!1;r=n.to}else if(r=gc(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},wC=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&Zs(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},c0=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
11
+ `).scrollIntoView()),!0)};function Jh(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const kC=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),i=n.indexAfter(-1),o=Jh(s.contentMatchAt(i));if(!o||!s.canReplaceWith(i,i,o))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,o.createAndFill());a.setSelection(te.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},u0=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof xn||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=Jh(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let o=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=t.tr.insert(o,i.createAndFill());l.setSelection(Q.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},d0=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let i=n.before();if($n(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Zs(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function vC(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof Y&&e.selection.node.isBlock)return!r.parentOffset||!$n(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],o,l,a=!1,c=!1;for(let f=r.depth;;f--)if(r.node(f).isBlock){a=r.end(f)==r.pos+(r.depth-f),c=r.start(f)==r.pos-(r.depth-f),l=Jh(r.node(f-1).contentMatchAt(r.indexAfter(f-1))),i.unshift(a&&l?{type:l}:null),o=f;break}else{if(f==1)return!1;i.unshift(null)}let u=e.tr;(e.selection instanceof Q||e.selection instanceof xn)&&u.deleteSelection();let d=u.mapping.map(r.pos),h=$n(u.doc,d,i.length,i);if(h||(i[0]=l?{type:l}:null,h=$n(u.doc,d,i.length,i)),!h)return!1;if(u.split(d,i.length,i),!a&&c&&r.node(o).type!=l){let f=u.mapping.map(r.before(o)),p=u.doc.resolve(f);l&&r.node(o-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(o)),l)}return n&&n(u.scrollIntoView()),!0}}const SC=vC(),CC=(t,e)=>{let{$from:n,to:r}=t.selection,s,i=n.sharedDepth(r);return i==0?!1:(s=n.before(i),e&&e(t.tr.setSelection(Y.create(t.doc,s))),!0)};function EC(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||kr(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function h0(t,e,n,r){let s=e.nodeBefore,i=e.nodeAfter,o,l,a=s.type.spec.isolating||i.type.spec.isolating;if(!a&&EC(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&l.matchType(o[0]||i.type).validEnd){if(n){let f=e.pos+i.nodeSize,p=j.empty;for(let b=o.length-1;b>=0;b--)p=j.from(o[b].create(null,p));p=j.from(s.copy(p));let m=t.tr.step(new jt(e.pos-1,f,e.pos,f,new F(p,1,0),o.length,!0)),y=m.doc.resolve(f+2*o.length);y.nodeAfter&&y.nodeAfter.type==s.type&&kr(m.doc,y.pos)&&m.join(y.pos),n(m.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&a?null:te.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),h=d&&Zs(d);if(h!=null&&h>=e.depth)return n&&n(t.tr.lift(d,h).scrollIntoView()),!0;if(c&&Os(i,"start",!0)&&Os(s,"end")){let f=s,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let m=i,y=1;for(;!m.isTextblock;m=m.firstChild)y++;if(f.canReplace(f.childCount,f.childCount,m.content)){if(n){let b=j.empty;for(let w=p.length-1;w>=0;w--)b=j.from(p[w].copy(b));let x=t.tr.step(new jt(e.pos-p.length,e.pos+i.nodeSize,e.pos+y,e.pos+i.nodeSize-y,new F(b,p.length,0),0,!0));n(x.scrollIntoView())}return!0}}return!1}function f0(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(n&&n(e.tr.setSelection(Q.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const AC=f0(-1),MC=f0(1);function TC(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i),l=o&&Uh(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function pm(t,e=null){return function(n,r){let s=!1;for(let i=0;i<n.selection.ranges.length&&!s;i++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[i];n.doc.nodesBetween(o,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)s=!0;else{let u=n.doc.resolve(c),d=u.index();s=u.parent.canReplaceWith(d,d+1,t)}})}if(!s)return!1;if(r){let i=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[o];i.setBlockType(l,a,t,e)}r(i.scrollIntoView())}return!0}}function Gh(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}Gh(t0,r0,i0);Gh(t0,l0,a0);Gh(c0,u0,d0,SC);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function NC(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,o=s.blockRange(i);if(!o)return!1;let l=r?n.tr:null;return RC(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function RC(t,e,n,r=null){let s=!1,i=e,o=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=o.resolve(e.start-2);i=new to(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new to(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=Uh(i,n,r,e);return l?(t&&_C(t,e,l,s,n),!0):!1}function _C(t,e,n,r,s){let i=j.empty;for(let u=n.length-1;u>=0;u--)i=j.from(n[u].type.create(n[u].attrs,i));t.step(new jt(e.start-(r?2:0),e.end,e.start,e.end,new F(i,0,0),n.length,!0));let o=0;for(let u=0;u<n.length;u++)n[u].type==s&&(o=u+1);let l=n.length-o,a=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,h=!0;u<d;u++,h=!1)!h&&$n(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function OC(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,o=>o.childCount>0&&o.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?DC(e,n,t,i):LC(e,n,i):!0:!1}}function DC(t,e,n,r){let s=t.tr,i=r.end,o=r.$to.end(r.depth);i<o&&(s.step(new jt(i-1,o,i,o,new F(j.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new to(s.doc.resolve(r.$from.pos),s.doc.resolve(o),r.depth));const l=Zs(r);if(l==null)return!1;s.lift(r,l);let a=s.doc.resolve(s.mapping.map(i,-1)-1);return kr(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function LC(t,e,n){let r=t.tr,s=n.parent;for(let f=n.end,p=n.endIndex-1,m=n.startIndex;p>m;p--)f-=s.child(p).nodeSize,r.delete(f-1,f+1);let i=r.doc.resolve(n.start),o=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==s.childCount,c=i.node(-1),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?j.empty:j.from(s))))return!1;let d=i.pos,h=d+o.nodeSize;return r.step(new jt(d-(l?1:0),h+(a?1:0),d+1,h-1,new F((l?j.empty:j.from(s.copy(j.empty))).append(a?j.empty:j.from(s.copy(j.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function IC(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==t);if(!i)return!1;let o=i.startIndex;if(o==0)return!1;let l=i.parent,a=l.child(o-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=j.from(c?t.create():null),d=new F(j.from(t.create(null,j.from(l.type.create(null,u)))),c?3:1,0),h=i.start,f=i.end;n(e.tr.step(new jt(h-(c?3:1),f,h,f,d,1,!0)).scrollIntoView())}return!0}}const lt=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Ds=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Nd=null;const Ln=function(t,e,n){let r=Nd||(Nd=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},PC=function(){Nd=null},Vr=function(t,e,n,r){return n&&(mm(t,e,n,r,-1)||mm(t,e,n,r,1))},jC=/^(img|br|input|textarea|hr)$/i;function mm(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:Jt(t))){let o=t.parentNode;if(!o||o.nodeType!=1||No(t)||jC.test(t.nodeName)||t.contentEditable=="false")return!1;e=lt(t)+(s<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(s<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((i=o.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=o,e=s<0?Jt(t):0}else return!1}}function Jt(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function $C(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Jt(t)}else if(t.parentNode&&!No(t))e=lt(t),t=t.parentNode;else return null}}function BC(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!No(t))e=lt(t)+1,t=t.parentNode;else return null}}function zC(t,e,n){for(let r=e==0,s=e==Jt(t);r||s;){if(t==n)return!0;let i=lt(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==Jt(t)}}function No(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const bc=function(t){return t.focusNode&&Vr(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Tr(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function HC(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function FC(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Jt(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Jt(r.startContainer),r.startOffset)}}}const vn=typeof navigator<"u"?navigator:null,gm=typeof document<"u"?document:null,vr=vn&&vn.userAgent||"",Rd=/Edge\/(\d+)/.exec(vr),p0=/MSIE \d/.exec(vr),_d=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(vr),Pt=!!(p0||_d||Rd),ur=p0?document.documentMode:_d?+_d[1]:Rd?+Rd[1]:0,Yt=!Pt&&/gecko\/(\d+)/i.test(vr);Yt&&+(/Firefox\/(\d+)/.exec(vr)||[0,0])[1];const Od=!Pt&&/Chrome\/(\d+)/.exec(vr),ct=!!Od,m0=Od?+Od[1]:0,gt=!Pt&&!!vn&&/Apple Computer/.test(vn.vendor),Ls=gt&&(/Mobile\/\w+/.test(vr)||!!vn&&vn.maxTouchPoints>2),Kt=Ls||(vn?/Mac/.test(vn.platform):!1),g0=vn?/Win/.test(vn.platform):!1,Pn=/Android \d/.test(vr),Ro=!!gm&&"webkitFontSmoothing"in gm.documentElement.style,UC=Ro?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function VC(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Tn(t,e){return typeof t=="number"?t:t[e]}function WC(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function ym(t,e,n){let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=Ds(o);continue}let l=o,a=l==i.body,c=a?VC(i):WC(l),u=0,d=0;if(e.top<c.top+Tn(r,"top")?d=-(c.top-e.top+Tn(s,"top")):e.bottom>c.bottom-Tn(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+Tn(s,"top")-c.top:e.bottom-c.bottom+Tn(s,"bottom")),e.left<c.left+Tn(r,"left")?u=-(c.left-e.left+Tn(s,"left")):e.right>c.right-Tn(r,"right")&&(u=e.right-c.right+Tn(s,"right")),u||d)if(a)i.defaultView.scrollBy(u,d);else{let f=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let m=l.scrollLeft-f,y=l.scrollTop-p;e={left:e.left-m,top:e.top-y,right:e.right-m,bottom:e.bottom-y}}let h=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(h))break;o=h=="absolute"?o.offsetParent:Ds(o)}}function qC(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(i,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:y0(t.dom)}}function y0(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Ds(r));return e}function KC({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;b0(n,r==0?0:r-e)}function b0(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:i}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let ds=null;function JC(t){if(t.setActive)return t.setActive();if(ds)return t.focus(ds);let e=y0(t);t.focus(ds==null?{get preventScroll(){return ds={preventScroll:!0},!0}}:void 0),ds||(ds=!1,b0(e,0))}function x0(t,e){let n,r=2e8,s,i=0,o=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let h;if(u.nodeType==1)h=u.getClientRects();else if(u.nodeType==3)h=Ln(u).getClientRects();else continue;for(let f=0;f<h.length;f++){let p=h[f];if(p.top<=o&&p.bottom>=l){o=Math.max(p.bottom,o),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<r){n=u,r=m,s=m&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&m&&(i=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=d+1)}}return!n&&a&&(n=a,s=c,r=0),n&&n.nodeType==3?GC(n,s):!n||r&&n.nodeType==1?{node:t,offset:i}:x0(n,s)}function GC(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let o=Zn(r,1);if(o.top!=o.bottom&&Yh(e,o)){s={node:t,offset:i+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function Yh(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function YC(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function XC(t,e,n){let{node:r,offset:s}=x0(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();i=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,s,i)}function ZC(t,e,n,r){let s=-1;for(let i=e,o=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&a.left>r.left||a.top>r.top?s=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(s=l.posAfter),o=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function w0(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=s;;){let o=t.childNodes[i];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Yh(e,c))return w0(o,e,c)}}if((i=(i+1)%r)==s)break}return t}function QC(t,e){let n=t.dom.ownerDocument,r,s=0,i=FC(n,e.left,e.top);i&&({node:r,offset:s}=i);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=t.dom.getBoundingClientRect();if(!Yh(e,c)||(o=w0(t.dom,e,c),!o))return null}if(gt)for(let c=o;r&&c;c=Ds(c))c.draggable&&(r=void 0);if(o=YC(o,e),r){if(Yt&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let u=r.childNodes[s],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&s++}let c;Ro&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=ZC(t,r,s,e))}l==null&&(l=XC(t,o,e));let a=t.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function bm(t){return t.top<t.bottom||t.left<t.right}function Zn(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(bm(r))return r}return Array.prototype.find.call(n,bm)||t.getBoundingClientRect()}const eE=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function k0(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),o=Ro||Yt;if(r.nodeType==3)if(o&&(eE.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let a=Zn(Ln(r,s,s),n);if(Yt&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=Zn(Ln(r,s-1,s-1),-1);if(c.top==a.top){let u=Zn(Ln(r,s,s+1),-1);if(u.top!=a.top)return hi(u,u.left<c.left)}}return a}else{let a=s,c=s,u=n<0?1:-1;return n<0&&!s?(c++,u=-1):n>=0&&s==r.nodeValue.length?(a--,u=1):n<0?a--:c++,hi(Zn(Ln(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==Jt(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return Su(a.getBoundingClientRect(),!1)}if(i==null&&s<Jt(r)){let a=r.childNodes[s];if(a.nodeType==1)return Su(a.getBoundingClientRect(),!0)}return Su(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==Jt(r))){let a=r.childNodes[s-1],c=a.nodeType==3?Ln(a,Jt(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return hi(Zn(c,1),!1)}if(i==null&&s<Jt(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Ln(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return hi(Zn(c,-1),!0)}return hi(Zn(r.nodeType==3?Ln(r):r,-n),n>=0)}function hi(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Su(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function v0(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function tE(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return v0(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let o=k0(t,s.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ln(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const nE=/[\u0590-\u08ac]/;function rE(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,o=s==r.parent.content.size,l=t.domSelection();return l?!nE.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:o:v0(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",n,"character");let f=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:m}=t.domSelectionRange(),y=p&&!f.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return h!=null&&(l.caretBidiLevel=h),y}):r.pos==r.start()||r.pos==r.end()}let xm=null,wm=null,km=!1;function sE(t,e,n){return xm==e&&wm==n?km:(xm=e,wm=n,km=n=="up"||n=="down"?tE(t,e,n):rE(t,e,n))}const Xt=0,vm=1,Rr=2,Sn=3;class _o{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=Xt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,r=this.posAtStart;;n++){let s=this.children[n];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let i,o;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(o)+o.size:this.posAtStart}else{let i,o;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((o=i.pmViewDesc)&&o.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(o):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>lt(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let i=this.getDesc(s),o;if(i&&(!n||i.node))if(r&&(o=i.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let i=this.getDesc(s);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let o=0;o<s.children.length;o++){let l=s.children[o];if(l.size){s=l;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let o=this.children[r],l=i+o.size;if(l>e||o instanceof C0){s=e-i;break}i=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof S0&&i.side>=0;r--);if(n<=0){let i,o=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,o=!1);return i&&n&&o&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?lt(i.dom)+1:0}}else{let i,o=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,o=!1);return i&&o&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?lt(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,i=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(s==-1&&e<=c){let u=o+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=o;for(let d=l;d>0;d--){let h=this.children[d-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){s=lt(h.dom)+1;break}e-=h.size}s==-1&&(s=0)}if(s>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=lt(d.dom);break}n+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let i=Math.min(e,n),o=Math.max(e,n);for(let f=0,p=0;f<this.children.length;f++){let m=this.children[f],y=p+m.size;if(i>p&&o<y)return m.setSelection(e-p-m.border,n-p-m.border,r,s);p=y}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((Yt||gt)&&e==n){let{node:f,offset:p}=l;if(f.nodeType==3){if(d=!!(p&&f.nodeValue[p-1]==`
12
+ `),d&&p==f.nodeValue.length)for(let m=f,y;m;m=m.parentNode){if(y=m.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:lt(y)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=f.childNodes[p-1];d=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Yt&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let f=u.focusNode.childNodes[u.focusOffset];f&&f.contentEditable=="false"&&(s=!0)}if(!(s||d&&gt)&&Vr(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Vr(a.node,a.offset,u.focusNode,u.focusOffset))return;let h=!1;if((c.extend||e==n)&&!(d&&Yt)){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),h=!0}catch{}}if(!h){if(e>n){let p=l;l=a,a=p}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,s=0;s<this.children.length;s++){let i=this.children[s],o=r+i.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+i.border,a=o-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==o?Rr:vm,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Sn:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Rr:Sn}r=o}this.dirty=Rr}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Rr:vm;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class S0 extends _o{constructor(e,n,r,s){let i,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==Xt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class iE extends _o{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Wr extends _o{constructor(e,n,r,s,i){super(e,[],r,s),this.mark=n,this.spec=i}static create(e,n,r,s){let i=s.nodeViews[n.type.name],o=i&&i(n,s,r);return(!o||!o.dom)&&(o=ns.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Wr(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Sn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Sn&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Xt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Xt}}slice(e,n,r){let s=Wr.create(this.parent,this.mark,!0,r),i=this.children,o=this.size;n<o&&(i=Ld(i,n,o,r)),e>0&&(i=Ld(i,0,e,r));for(let l=0;l<i.length;l++)i[l].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class dr extends _o{constructor(e,n,r,s,i,o,l,a,c){super(e,[],i,o),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,n,r,s,i,o){let l=i.nodeViews[n.type.name],a,c=l&&l(n,i,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,s),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=ns.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let h=u;return u=M0(u,r,n),c?a=new oE(e,n,r,s,u,d||null,h,c,i,o+1):n.isText?new xc(e,n,r,s,u,h,i):new dr(e,n,r,s,u,d||null,h,i,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>j.empty)}return e}matchesNode(e,n,r){return this.dirty==Xt&&e.eq(this.node)&&ia(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,i=e.composing?this.localCompositionInfo(e,n):null,o=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new aE(this,o&&o.node,e);dE(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e,u):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?Ae.none:this.node.child(u).marks,r,e,u),a.placeWidget(c,e,s)},(c,u,d,h)=>{a.syncToMarks(c.marks,r,e,h);let f;a.findNodeMatch(c,u,d,h)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(f=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,u,d,f,e)||a.updateNextNode(c,u,d,e,h,s)||a.addNode(c,u,d,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Rr)&&(o&&this.protectLocalComposition(e,o),E0(this.contentDOM,this.children,e),Ls&&hE(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof Q)||r<n||s>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let o=i.nodeValue,l=fE(this.node.content,o,r-n,s-n);return l<0?null:{node:i,pos:l,text:o}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let o=new iE(this,i,n,s);e.input.compositionNodes.push(o),this.children=Ld(this.children,r,r+s.length,e,o)}update(e,n,r,s){return this.dirty==Sn||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=Xt}updateOuterDeco(e){if(ia(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=A0(this.dom,this.nodeDOM,Dd(this.outerDeco,this.node,n),Dd(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Sm(t,e,n,r,s){M0(r,e,t);let i=new dr(void 0,t,e,n,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class xc extends dr{constructor(e,n,r,s,i,o,l){super(e,n,r,s,i,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,s){return this.dirty==Sn||this.dirty!=Xt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Xt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=Xt,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),i=document.createTextNode(s.text);return new xc(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Sn)}get domAtom(){return!1}isText(e){return this.node.text==e}}class C0 extends _o{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Xt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class oE extends dr{constructor(e,n,r,s,i,o,l,a,c,u){super(e,n,r,s,i,o,l,c,u),this.spec=a}update(e,n,r,s){if(this.dirty==Sn)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,s),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function E0(t,e,n){let r=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let o=e[i],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=Cm(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(l,r);if(o instanceof Wr){let a=r?r.previousSibling:t.lastChild;E0(o.contentDOM,o.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=Cm(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const $i=function(t){t&&(this.nodeName=t)};$i.prototype=Object.create(null);const _r=[new $i];function Dd(t,e,n){if(t.length==0)return _r;let r=n?_r[0]:new $i,s=[r];for(let i=0;i<t.length;i++){let o=t[i].type.attrs;if(o){o.nodeName&&s.push(r=new $i(o.nodeName));for(let l in o){let a=o[l];a!=null&&(n&&s.length==1&&s.push(r=new $i(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return s}function A0(t,e,n,r){if(n==_r&&r==_r)return e;let s=e;for(let i=0;i<r.length;i++){let o=r[i],l=n[i];if(i){let a;l&&l.nodeName==o.nodeName&&s!=t&&(a=s.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=_r[0]),s=a}lE(s,l||_r[0],o)}return s}function lE(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)s.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&t.classList.add(s[i]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function M0(t,e,n){return A0(t,t,_r,Dd(e,n,t.nodeType!=1))}function ia(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Cm(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class aE{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=cE(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r,s){let i=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;i<l&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=Xt,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;s<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[o])&&!this.isLocked(d.dom)){a=u;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=Wr.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,s){let i=-1,o;if(s>=this.preMatch.index&&(o=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))i=this.top.children.indexOf(o,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,n,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,s,i){let o=this.top.children[s];return o.dirty==Sn&&o.dom==o.contentDOM&&(o.dirty=Rr),o.update(e,n,r,i)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,i,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof dr){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let u=a.dom,d,h=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Sn&&ia(n,a.outerDeco));if(!h&&a.update(e,n,r,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!h&&(d=this.recreateWrapper(a,e,n,r,s,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=Rr,d.updateChildren(s,o+1),d.dirty=Xt),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,i,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!ia(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=dr.create(this.top,n,r,s,i,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,s,i){let o=dr.create(this.top,e,n,r,s,i);o.contentDOM&&o.updateChildren(s,i+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let i=new S0(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Wr;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof xc)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((gt||ct)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new C0(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function cE(t,e){let n=e,r=n.children.length,s=t.childCount,i=new Map,o=[];e:for(;s>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof Wr)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(s-1))break;--s,i.set(l,s),o.push(l)}}return{index:s,matched:i,matches:o.reverse()}}function uE(t,e){return t.type.side-e.type.side}function dE(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,s,e.forChild(i,u),c),i+=u.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let u,d;for(;o<s.length&&s[o].to==i;){let y=s[o++];y.widget&&(u?(d||(d=[u])).push(y):u=y)}if(u)if(d){d.sort(uE);for(let y=0;y<d.length;y++)n(d[y],c,!!a)}else n(u,c,!!a);let h,f;if(a)f=-1,h=a,a=null;else if(c<t.childCount)f=c,h=t.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=i&&l.splice(y--,1);for(;o<s.length&&s[o].from<=i&&s[o].to>i;)l.push(s[o++]);let p=i+h.nodeSize;if(h.isText){let y=p;o<s.length&&s[o].from<y&&(y=s[o].from);for(let b=0;b<l.length;b++)l[b].to<y&&(y=l[b].to);y<p&&(a=h.cut(y-i),h=h.cut(0,y-i),p=y,f=-1)}else for(;o<s.length&&s[o].to<p;)o++;let m=h.isInline&&!h.isLeaf?l.filter(y=>!y.inline):l.slice();r(h,m,e.forChild(i,h),f),i=p}}function hE(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function fE(t,e,n,r){for(let s=0,i=0;s<t.childCount&&i<=r;){let o=t.child(s++),l=i;if(i+=o.nodeSize,!o.isText)continue;let a=o.text;for(;s<t.childCount;){let c=t.child(s++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Ld(t,e,n,r,s){let i=[];for(let o=0,l=0;o<t.length;o++){let a=t[o],c=l,u=l+=a.size;c>=n||u<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),s&&(i.push(s),s=void 0),u>n&&i.push(a.slice(n-c,a.size,r)))}return i}function Xh(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(bc(n)){for(a=o;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&Y.isSelectable(d)&&s.parent&&!(d.isInline&&zC(n.focusNode,n.focusOffset,s.dom))){let h=s.posBefore;c=new Y(o==h?l:r.resolve(h))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=o,h=o;for(let f=0;f<n.rangeCount;f++){let p=n.getRangeAt(f);d=Math.min(d,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),h=Math.max(h,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,o]=h==t.state.selection.anchor?[h,d]:[d,h],l=r.resolve(o)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||t.state.selection.head<l.pos&&!i?1:-1;c=Zh(t,u,l,d)}return c}function T0(t){return t.editable?t.hasFocus():R0(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Bn(t,e=!1){let n=t.state.selection;if(N0(t,n),!!T0(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ct){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Vr(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)mE(t);else{let{anchor:r,head:s}=n,i,o;Em&&!(n instanceof Q)&&(n.$from.parent.inlineContent||(i=Am(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=Am(t,n.to))),t.docView.setSelection(r,s,t,e),Em&&(i&&Mm(i),o&&Mm(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&pE(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Em=gt||ct&&m0<63;function Am(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(gt&&s&&s.contentEditable=="false")return Cu(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Cu(s);if(i)return Cu(i)}}function Cu(t){return t.contentEditable="true",gt&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Mm(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function pE(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!T0(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function mE(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,lt(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Pt&&ur<=11&&(n.disabled=!0,n.disabled=!1)}function N0(t,e){if(e instanceof Y){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Tm(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Tm(t)}function Tm(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Zh(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||Q.between(e,n,r)}function Nm(t){return t.editable&&!t.hasFocus()?!1:R0(t)}function R0(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function gE(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Vr(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Id(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&te.findFrom(i,e)}function tr(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Rm(t,e,n){let r=t.state.selection;if(r instanceof Q)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let o=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return tr(t,new Q(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Id(t.state,e);return s&&s instanceof Y?tr(t,s):!1}else if(!(Kt&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,o;if(!i||i.isText)return!1;let l=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?Y.isSelectable(i)?tr(t,new Y(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):Ro?tr(t,new Q(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Y&&r.node.isInline)return tr(t,new Q(e>0?r.$to:r.$from));{let s=Id(t.state,e);return s?tr(t,s):!1}}}function oa(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Bi(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function hs(t,e){return e<0?yE(t):bE(t)}function yE(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,o=!1;for(Yt&&n.nodeType==1&&r<oa(n)&&Bi(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Bi(l,-1))s=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(_0(n))break;{let l=n.previousSibling;for(;l&&Bi(l,-1);)s=n.parentNode,i=lt(l),l=l.previousSibling;if(l)n=l,r=oa(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?Pd(t,n,r):s&&Pd(t,s,i)}function bE(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=oa(n),i,o;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(Bi(l,1))i=n,o=++r;else break}else{if(_0(n))break;{let l=n.nextSibling;for(;l&&Bi(l,1);)i=l.parentNode,o=lt(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=oa(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&Pd(t,i,o)}function _0(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function xE(t,e){for(;t&&e==t.childNodes.length&&!No(t);)e=lt(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function wE(t,e){for(;t&&!e&&!No(t);)e=lt(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Pd(t,e,n){if(e.nodeType!=3){let i,o;(o=xE(e,n))?(e=o,n=0):(i=wE(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(bc(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&Bn(t)},50)}function _m(t,e){let n=t.state.doc.resolve(e);if(!(ct||g0)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),o=(i.top+i.bottom)/2;if(o>s.top&&o<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Om(t,e,n){let r=t.state.selection;if(r instanceof Q&&!r.empty||n.indexOf("s")>-1||Kt&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=Id(t.state,e);if(o&&o instanceof Y)return tr(t,o)}if(!s.parent.inlineContent){let o=e<0?s:i,l=r instanceof xn?te.near(o,e):te.findFrom(o,e);return l?tr(t,l):!1}return!1}function Dm(t,e){if(!(t.state.selection instanceof Q))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=t.state.tr;return e<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),t.dispatch(o),!0}return!1}function Lm(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function kE(t){if(!gt||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Lm(t,r,"true"),setTimeout(()=>Lm(t,r,"false"),20)}return!1}function vE(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function SE(t,e){let n=e.keyCode,r=vE(e);if(n==8||Kt&&n==72&&r=="c")return Dm(t,-1)||hs(t,-1);if(n==46&&!e.shiftKey||Kt&&n==68&&r=="c")return Dm(t,1)||hs(t,1);if(n==13||n==27)return!0;if(n==37||Kt&&n==66&&r=="c"){let s=n==37?_m(t,t.state.selection.from)=="ltr"?-1:1:-1;return Rm(t,s,r)||hs(t,s)}else if(n==39||Kt&&n==70&&r=="c"){let s=n==39?_m(t,t.state.selection.from)=="ltr"?1:-1:1;return Rm(t,s,r)||hs(t,s)}else{if(n==38||Kt&&n==80&&r=="c")return Om(t,-1,r)||hs(t,-1);if(n==40||Kt&&n==78&&r=="c")return kE(t)||Om(t,1,r)||hs(t,1);if(r==(Kt?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Qh(t,e){t.someProp("transformCopied",f=>{e=f(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let f=r.firstChild;n.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let o=t.someProp("clipboardSerializer")||ns.fromSchema(t.state.schema),l=j0(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=P0[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let p=l.createElement(u[f]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`);let h=t.someProp("clipboardTextSerializer",f=>f(e,t))||e.content.textBetween(0,e.content.size,`
13
+
14
+ `);return{dom:a,text:h,slice:e}}function O0(t,e,n,r,s){let i=s.parent.type.spec.code,o,l;if(!n&&!e)return null;let a=!!e&&(r||i||!n);if(a){if(t.someProp("transformPastedText",h=>{e=h(e,i||r,t)}),i)return l=new F(j.from(t.state.schema.text(e.replace(/\r\n?/g,`
15
+ `))),0,0),t.someProp("transformPasted",h=>{l=h(l,t,!0)}),l;let d=t.someProp("clipboardTextParser",h=>h(e,s,r,t));if(d)l=d;else{let h=s.marks(),{schema:f}=t.state,p=ns.fromSchema(f);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let y=o.appendChild(document.createElement("p"));m&&y.appendChild(p.serializeNode(f.text(m,h)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),o=ME(n),Ro&&TE(o);let c=o&&o.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let h=o.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;o=h}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Pi.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!CE.test(h.parentNode.nodeName)?{ignore:!0}:null}})),u)l=NE(Im(l,+u[1],+u[2]),u[4]);else if(l=F.maxOpen(EE(l.content,s),!0),l.openStart||l.openEnd){let d=0,h=0;for(let f=l.content.firstChild;d<l.openStart&&!f.type.spec.isolating;d++,f=f.firstChild);for(let f=l.content.lastChild;h<l.openEnd&&!f.type.spec.isolating;h++,f=f.lastChild);l=Im(l,d,h)}return t.someProp("transformPasted",d=>{l=d(l,t,a)}),l}const CE=/^(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 EE(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),i,o=[];if(t.forEach(l=>{if(!o)return;let a=s.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&i.length&&L0(a,i,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=I0(o[o.length-1],i.length));let u=D0(l,a);o.push(u),s=s.matchType(u.type),i=a}}),o)return j.from(o)}return t}function D0(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,j.from(t));return t}function L0(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=L0(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(j.from(D0(n,t,s+1))))}}function I0(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,I0(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(j.empty,!0);return t.copy(n.append(r))}function jd(t,e,n,r,s,i){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(i=0),s<r-1&&(l=jd(l,e,n,r,s+1,i)),s>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,i<=s).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(j.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function Im(t,e,n){return e<t.openStart&&(t=new F(jd(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new F(jd(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const P0={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Pm=null;function j0(){return Pm||(Pm=document.implementation.createHTMLDocument("title"))}let Eu=null;function AE(t){let e=window.trustedTypes;return e?(Eu||(Eu=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Eu.createHTML(t)):t}function ME(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=j0().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&P0[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=AE(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function TE(t){let e=t.querySelectorAll(ct?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function NE(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:i,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=j.from(a.create(r[l+1],s)),i++,o++}return new F(s,i,o)}const Tt={},Nt={},RE={touchstart:!0,touchmove:!0};class _E{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function OE(t){for(let e in Tt){let n=Tt[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{LE(t,r)&&!ef(t,r)&&(t.editable||!(r.type in Nt))&&n(t,r)},RE[e]?{passive:!0}:void 0)}gt&&t.dom.addEventListener("input",()=>null),$d(t)}function or(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function DE(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function $d(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>ef(t,r))})}function ef(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function LE(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function IE(t,e){!ef(t,e)&&Tt[e.type]&&(t.editable||!(e.type in Nt))&&Tt[e.type](t,e)}Nt.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!B0(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Pn&&ct&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Ls&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,Tr(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||SE(t,n)?n.preventDefault():or(t,"key")};Nt.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Nt.keypress=(t,e)=>{let n=e;if(B0(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Kt&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Q)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function wc(t){return{left:t.clientX,top:t.clientY}}function PE(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function tf(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let o=i.depth+1;o>0;o--)if(t.someProp(e,l=>o>i.depth?l(t,n,i.nodeAfter,i.before(o),s,!0):l(t,n,i.node(o),i.before(o),s,!1)))return!0;return!1}function Cs(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function jE(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&Y.isSelectable(r)?(Cs(t,new Y(n)),!0):!1}function $E(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof Y&&(r=n.node);let i=t.state.doc.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o);if(Y.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(o);break}}return s!=null?(Cs(t,Y.create(t.state.doc,s)),!0):!1}function BE(t,e,n,r,s){return tf(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?$E(t,n):jE(t,n))}function zE(t,e,n,r){return tf(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function HE(t,e,n,r){return tf(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||FE(t,n,r)}function FE(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Cs(t,Q.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let o=i>s.depth?s.nodeAfter:s.node(i),l=s.before(i);if(o.inlineContent)Cs(t,Q.create(r,l+1,l+1+o.content.size));else if(Y.isSelectable(o))Cs(t,Y.create(r,l));else continue;return!0}}function nf(t){return la(t)}const $0=Kt?"metaKey":"ctrlKey";Tt.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=nf(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&PE(n,t.input.lastClick)&&!n[$0]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let o=t.posAtCoords(wc(n));o&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new UE(t,o,n,!!r)):(i=="doubleClick"?zE:HE)(t,o.pos,o.inside,n)?n.preventDefault():or(t,"pointer"))};class UE{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[$0],this.allowDefault=r.shiftKey;let i,o;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),o=n.inside;else{let u=e.state.doc.resolve(n.pos);i=u.parent,o=u.depth?u.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;r.button==0&&(i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof Y&&c.from<=o&&c.to>o)&&(this.mightDrag={node:i,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Yt&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),or(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Bn(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(wc(e))),this.updateAllowDefault(e),this.allowDefault||!n?or(this.view,"pointer"):BE(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||gt&&this.mightDrag&&!this.mightDrag.node.isAtom||ct&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Cs(this.view,te.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):or(this.view,"pointer")}move(e){this.updateAllowDefault(e),or(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Tt.touchstart=t=>{t.input.lastTouch=Date.now(),nf(t),or(t,"pointer")};Tt.touchmove=t=>{t.input.lastTouch=Date.now(),or(t,"pointer")};Tt.contextmenu=t=>nf(t);function B0(t,e){return t.composing?!0:gt&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const VE=Pn?5e3:-1;Nt.compositionstart=Nt.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Q&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||ct&&g0&&WE(t)))t.markCursor=t.state.storedMarks||n.marks(),la(t,!0),t.markCursor=null;else if(la(t,!e.selection.empty),Yt&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let o=i<0?s.lastChild:s.childNodes[i-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else s=o,i=-1}}t.input.composing=!0}z0(t,VE)};function WE(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Nt.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,z0(t,20))};function z0(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>la(t),e))}function H0(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=KE());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function qE(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=$C(e.focusNode,e.focusOffset),r=BC(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function KE(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function la(t,e=!1){if(!(Pn&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),H0(t),e||t.docView&&t.docView.dirty){let n=Xh(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function JE(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const so=Pt&&ur<15||Ls&&UC<604;Tt.copy=Nt.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=so?null:n.clipboardData,o=r.content(),{dom:l,text:a}=Qh(t,o);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):JE(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function GE(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function YE(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?io(t,r.value,null,s,e):io(t,r.textContent,r.innerHTML,s,e)},50)}function io(t,e,n,r,s){let i=O0(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,s,i||F.empty)))return!0;if(!i)return!1;let o=GE(i),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(i);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function F0(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Nt.paste=(t,e)=>{let n=e;if(t.composing&&!Pn)return;let r=so?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&io(t,F0(r),r.getData("text/html"),s,n)?n.preventDefault():YE(t,n)};class U0{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const XE=Kt?"altKey":"ctrlKey";function V0(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[XE]}Tt.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(wc(n)),o;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof Y?s.to-1:s.to))){if(r&&r.mightDrag)o=Y.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(o=Y.create(t.state.doc,d.posBefore))}}let l=(o||t.state.selection).content(),{dom:a,text:c,slice:u}=Qh(t,l);(!n.dataTransfer.files.length||!ct||m0>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(so?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",so||n.dataTransfer.setData("text/plain",c),t.dragging=new U0(u,V0(t,n),o)};Tt.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Nt.dragover=Nt.dragenter=(t,e)=>e.preventDefault();Nt.drop=(t,e)=>{try{ZE(t,e,t.dragging)}finally{t.dragging=null}};function ZE(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(wc(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",f=>{i=f(i,t,!1)}):i=O0(t,F0(e.dataTransfer),so?null:e.dataTransfer.getData("text/html"),!1,s);let o=!!(n&&V0(t,e));if(t.someProp("handleDrop",f=>f(t,e,i||F.empty,o))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?Ub(t.state.doc,s.pos,i):s.pos;l==null&&(l=s.pos);let a=t.state.tr;if(o){let{node:f}=n;f?f.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(d))return;let h=a.doc.resolve(c);if(u&&Y.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new Y(h));else{let f=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,m,y,b)=>f=b),a.setSelection(Zh(t,h,a.doc.resolve(f)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))}Tt.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Bn(t)},20))};Tt.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Tt.beforeinput=(t,e)=>{if(ct&&Pn&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",i=>i(t,Tr(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in Nt)Tt[t]=Nt[t];function oo(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class aa{constructor(e,n){this.toDOM=e,this.spec=n||jr,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:o}=e.mapResult(n.from+s,this.side<0?-1:1);return o?null:new _e(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof aa&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&oo(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class hr{constructor(e,n){this.attrs=e,this.spec=n||jr}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=o?null:new _e(i,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof hr&&oo(this.attrs,e.attrs)&&oo(this.spec,e.spec)}static is(e){return e.type instanceof hr}destroy(){}}class rf{constructor(e,n){this.attrs=e,this.spec=n||jr}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let o=e.mapResult(n.to+s,-1);return o.deleted||o.pos<=i.pos?null:new _e(i.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof rf&&oo(this.attrs,e.attrs)&&oo(this.spec,e.spec)}destroy(){}}class _e{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new _e(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new _e(e,e,new aa(n,r))}static inline(e,n,r,s){return new _e(e,n,new hr(r,s))}static node(e,n,r,s){return new _e(e,n,new rf(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof hr}get widget(){return this.type instanceof aa}}const ys=[],jr={};class xe{constructor(e,n){this.local=e.length?e:ys,this.children=n.length?n:ys}static create(e,n){return n.length?ca(n,e,0,jr):ft}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,s+l,i)}}map(e,n,r){return this==ft||e.maps.length==0?this:this.mapInner(e,n,0,0,r||jr)}mapInner(e,n,r,s,i){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(n,a)?(o||(o=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?QE(this.children,o||[],e,n,r,s,i):o?new xe(o.sort($r),ys):ft}add(e,n){return n.length?this==ft?xe.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=q0(n,l,c)){for(s||(s=this.children.slice());i<s.length&&s[i]<a;)i+=3;s[i]==a?s[i+2]=s[i+2].addInner(l,u,c+1):s.splice(i,0,a,a+l.nodeSize,ca(u,l,c+1,jr)),i+=3}});let o=W0(i?K0(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new xe(o.length?this.local.concat(o).sort($r):this.local,s||this.children)}remove(e){return e.length==0||this==ft?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let o,l=r[i]+n,a=r[i+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(o||(o=[])).push(d));if(!o)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(o,l+1);c!=ft?r[i+2]=c:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,o;i<e.length;i++)if(o=e[i])for(let l=0;l<s.length;l++)s[l].eq(o,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new xe(s,r):ft}forChild(e,n){if(this==ft)return this;if(n.isLeaf)return xe.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,o=i+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>i&&a.type instanceof hr){let c=Math.max(i,a.from)-i,u=Math.min(o,a.to)-i;c<u&&(s||(s=[])).push(a.copy(c,u))}}if(s){let l=new xe(s.sort($r),ys);return r?new sr([l,r]):l}return r||ft}eq(e){if(this==e)return!0;if(!(e instanceof xe)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return sf(this.localsInner(e))}localsInner(e){if(this==ft)return ys;if(e.inlineContent||!this.local.some(hr.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof hr||n.push(this.local[r]);return n}forEachSet(e){e(this)}}xe.empty=new xe([],[]);xe.removeOverlap=sf;const ft=xe.empty;class sr{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,jr));return sr.from(r)}forChild(e,n){if(n.isLeaf)return xe.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=ft&&(i instanceof sr?r=r.concat(i.members):r.push(i))}return sr.from(r)}eq(e){if(!(e instanceof sr)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let o=0;o<i.length;o++)n.push(i[o])}}return n?sf(r?n:n.sort($r)):ys}static from(e){switch(e.length){case 0:return ft;case 1:return e[0];default:return new sr(e.every(n=>n instanceof xe)?e:e.reduce((n,r)=>n.concat(r instanceof xe?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function QE(t,e,n,r,s,i,o){let l=t.slice();for(let c=0,u=i;c<n.maps.length;c++){let d=0;n.maps[c].forEach((h,f,p,m)=>{let y=m-p-(f-h);for(let b=0;b<l.length;b+=3){let x=l[b+1];if(x<0||h>x+u-d)continue;let w=l[b]+u-d;f>=w?l[b+1]=h<=w?-2:-1:h>=u&&y&&(l[b]+=y,l[b+1]+=y)}d+=y}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(t[c]+i),d=u-s;if(d<0||d>=r.content.size){a=!0;continue}let h=n.map(t[c+1]+i,-1),f=h-s,{index:p,offset:m}=r.content.findIndex(d),y=r.maybeChild(p);if(y&&m==d&&m+y.nodeSize==f){let b=l[c+2].mapInner(n,y,u+1,t[c]+i+1,o);b!=ft?(l[c]=d,l[c+1]=f,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=eA(l,t,e,n,s,i,o),u=ca(c,r,0,o);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,h=0;d<u.children.length;d+=3){let f=u.children[d];for(;h<l.length&&l[h]<f;)h+=3;l.splice(h,0,u.children[d],u.children[d+1],u.children[d+2])}}return new xe(e.sort($r),l)}function W0(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new _e(s.from+e,s.to+e,s.type))}return n}function eA(t,e,n,r,s,i,o){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,s,c);d?n.push(d):o.onRemove&&o.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+i+1);return n}function q0(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,o;i<t.length;i++)(o=t[i])&&o.from>n&&o.to<r&&((s||(s=[])).push(o),t[i]=null);return s}function K0(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function ca(t,e,n,r){let s=[],i=!1;e.forEach((l,a)=>{let c=q0(t,l,a+n);if(c){i=!0;let u=ca(c,l,n+a+1,r);u!=ft&&s.push(a,a+l.nodeSize,u)}});let o=W0(i?K0(t):t,-n).sort($r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||s.length?new xe(o,s):ft}function $r(t,e){return t.from-e.from||t.to-e.to}function sf(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),jm(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),jm(e,s,r.copy(i.from,r.to)));break}}}return e}function jm(t,e,n){for(;e<t.length&&$r(n,t[e])>0;)e++;t.splice(e,0,n)}function Au(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=ft&&e.push(r)}),t.cursorWrapper&&e.push(xe.create(t.state.doc,[t.cursorWrapper.deco])),sr.from(e)}const tA={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},nA=Pt&&ur<=11;class rA{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class sA{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new rA,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);Pt&&ur<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():gt&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),nA&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,tA)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;n<e.length;n++)this.queue.push(e[n]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Nm(this.view)){if(this.suppressingSelectionUpdates)return Bn(this.view);if(Pt&&ur<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Vr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let i=e.focusNode;i;i=Ds(i))n.add(i);for(let i=e.anchorNode;i;i=Ds(i))if(n.has(i)){r=i;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Nm(e)&&!this.ignoreSelectionChange(r),i=-1,o=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[u],a);d&&(i=i<0?d.from:Math.min(d.from,i),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&d.nodeType==1;){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(Yt&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,h]=u;d.parentNode&&d.parentNode.parentNode==h.parentNode?h.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let h of u){let f=h.parentNode;f&&f.nodeName=="LI"&&(!d||lA(e,d)!=f)&&h.remove()}}}let c=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&bc(r)&&(c=Xh(e))&&c.eq(te.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Bn(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,o),iA(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,aA(e,a)),this.handleDOMChange(i,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Bn(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(Pt&&ur<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:h}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h)}let o=s&&s.parentNode==e.target?lt(s)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=i&&i.parentNode==e.target?lt(i):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let $m=new WeakMap,Bm=!1;function iA(t){if(!$m.has(t)&&($m.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Yt,Bm)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."),Bm=!0}}function zm(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Vr(o.node,o.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function oA(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return zm(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?zm(t,n):null}function lA(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function aA(t,e){var n;let{focusNode:r,focusOffset:s}=t.domSelectionRange();for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=i.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&t.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function cA(t,e,n){let{node:r,fromOffset:s,toOffset:i,from:o,to:l}=t.docView.parseRange(e,n),a=t.domSelectionRange(),c,u=a.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],bc(a)||c.push({node:a.focusNode,offset:a.focusOffset})),ct&&t.input.lastKeyCode===8)for(let y=i;y>s;y--){let b=r.childNodes[y-1],x=b.pmViewDesc;if(b.nodeName=="BR"&&!x){i=y;break}if(!x||x.size)break}let d=t.state.doc,h=t.someProp("domParser")||Pi.fromSchema(t.state.schema),f=d.resolve(o),p=null,m=h.parse(r,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:s,to:i,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:uA,context:f});if(c&&c[0].pos!=null){let y=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=y),p={anchor:y+o,head:b+o}}return{doc:m,sel:p,from:o,to:l}}function uA(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(gt&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||gt&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const dA=/^(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 hA(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let v=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,A=Xh(t,v);if(A&&!t.state.selection.eq(A)){if(ct&&Pn&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",N=>N(t,Tr(13,"Enter"))))return;let C=t.state.tr.setSelection(A);v=="pointer"?C.setMeta("pointer",!0):v=="key"&&C.scrollIntoView(),i&&C.setMeta("composition",i),t.dispatch(C)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=cA(t,e,n),u=t.state.doc,d=u.slice(c.from,c.to),h,f;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(h=t.state.selection.to,f="end"):(h=t.state.selection.from,f="start"),t.input.lastKeyCode=null;let p=mA(d.content,c.doc.content,c.from,h,f);if(p&&t.input.domChangeCount++,(Ls&&t.input.lastIOSEnter>Date.now()-225||Pn)&&s.some(v=>v.nodeType==1&&!dA.test(v.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",v=>v(t,Tr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof Q&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let v=Hm(t,t.state.doc,c.sel);if(v&&!v.eq(t.state.selection)){let A=t.state.tr.setSelection(v);i&&A.setMeta("composition",i),t.dispatch(A)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof Q&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),Pt&&ur<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),b=u.resolve(p.start),x=m.sameParent(y)&&m.parent.inlineContent&&b.end()>=p.endA;if((Ls&&t.input.lastIOSEnter>Date.now()-225&&(!x||s.some(v=>v.nodeName=="DIV"||v.nodeName=="P"))||!x&&m.pos<c.doc.content.size&&(!m.sameParent(y)||!m.parent.inlineContent)&&m.pos<y.pos&&!/\S/.test(c.doc.textBetween(m.pos,y.pos,"","")))&&t.someProp("handleKeyDown",v=>v(t,Tr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&pA(u,p.start,p.endA,m,y)&&t.someProp("handleKeyDown",v=>v(t,Tr(8,"Backspace")))){Pn&&ct&&t.domObserver.suppressSelectionUpdates();return}ct&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),Pn&&!x&&m.start()!=y.start()&&y.parentOffset==0&&m.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(v){return v(t,Tr(13,"Enter"))})},20));let w=p.start,k=p.endA,T=v=>{let A=v||t.state.tr.replace(w,k,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let C=Hm(t,A.doc,c.sel);C&&!(ct&&t.composing&&C.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(C.head==w||C.head==A.mapping.map(k)-1)||Pt&&C.empty&&C.head==w)&&A.setSelection(C)}return i&&A.setMeta("composition",i),A.scrollIntoView()},S;if(x)if(m.pos==y.pos){Pt&&ur<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Bn(t),20));let v=T(t.state.tr.delete(w,k)),A=u.resolve(p.start).marksAcross(u.resolve(p.endA));A&&v.ensureMarks(A),t.dispatch(v)}else if(p.endA==p.endB&&(S=fA(m.parent.content.cut(m.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start())))){let v=T(t.state.tr);S.type=="add"?v.addMark(w,k,S.mark):v.removeMark(w,k,S.mark),t.dispatch(v)}else if(m.parent.child(m.index()).isText&&m.index()==y.index()-(y.textOffset?0:1)){let v=m.parent.textBetween(m.parentOffset,y.parentOffset),A=()=>T(t.state.tr.insertText(v,w,k));t.someProp("handleTextInput",C=>C(t,w,k,v,A))||t.dispatch(A())}else t.dispatch(T());else t.dispatch(T())}function Hm(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Zh(t,e.resolve(n.anchor),e.resolve(n.head))}function fA(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,o,l,a;for(let u=0;u<r.length;u++)s=r[u].removeFromSet(s);for(let u=0;u<n.length;u++)i=n[u].removeFromSet(i);if(s.length==1&&i.length==0)l=s[0],o="add",a=u=>u.mark(l.addToSet(u.marks));else if(s.length==0&&i.length==1)l=i[0],o="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(j.from(c).eq(t))return{mark:l,type:o}}function pA(t,e,n,r,s){if(n-e<=s.pos-r.pos||Mu(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let l=i.nodeAfter;return l!=null&&n==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let o=t.resolve(Mu(i,!0,!0));return!o.parent.isTextblock||o.pos>n||Mu(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Mu(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function mA(t,e,n,r,s){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(s=="end"){let a=Math.max(0,i-Math.min(o,l));r-=o+a-i}if(o<i&&t.size<e.size){let a=r<=i&&r>=o?i-r:0;i-=a,i&&i<e.size&&Fm(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-o),o=i}else if(l<i){let a=r<=i&&r>=l?i-r:0;i-=a,i&&i<t.size&&Fm(t.textBetween(i-1,i+1))&&(i+=a?1:-1),o=i+(o-l),l=i}return{start:i,endA:o,endB:l}}function Fm(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class J0{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new _E,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Km),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=Wm(this),Vm(this),this.nodeViews=qm(this),this.docView=Sm(this.state.doc,Um(this),Au(this),this.dom,this),this.domObserver=new sA(this,(r,s,i,o)=>hA(this,r,s,i,o)),this.domObserver.start(),OE(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&$d(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Km),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(H0(this),o=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let f=qm(this);yA(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&$d(this),this.editable=Wm(this),Vm(this);let a=Au(this),c=Um(this),u=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(s.selection))&&(o=!0);let h=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&qC(this);if(o){this.domObserver.stop();let f=d&&(Pt||ct)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&gA(s.selection,e.selection);if(d){let p=ct?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=qE(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Sm(e.doc,c,a,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&gE(this))?Bn(this,f):(N0(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():h&&KC(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof Y){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&ym(this,n.getBoundingClientRect(),e)}else ym(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new U0(e.slice,e.move,s<0?void 0:Y.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(s=n?n(l):l))return s}let i=this.state.plugins;if(i)for(let o=0;o<i.length;o++){let l=i[o].props[e];if(l!=null&&(s=n?n(l):l))return s}}hasFocus(){if(Pt){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&JC(this.dom),Bn(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return QC(this,e)}coordsAtPos(e,n=1){return k0(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return sE(this,n||this.state,e)}pasteHTML(e,n){return io(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return io(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Qh(this,e)}destroy(){this.docView&&(DE(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Au(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,PC())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return IE(this,e)}domSelectionRange(){let e=this.domSelection();return e?gt&&this.root.nodeType===11&&HC(this.dom.ownerDocument)==this.dom&&oA(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}J0.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Um(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[_e.node(0,t.state.doc.content.size,e)]}function Vm(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:_e.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Wm(t){return!t.someProp("editable",e=>e(t.state)===!1)}function gA(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function qm(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function yA(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function Km(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var fr={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:"'"},ua={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},bA=typeof navigator<"u"&&/Mac/.test(navigator.platform),xA=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var at=0;at<10;at++)fr[48+at]=fr[96+at]=String(at);for(var at=1;at<=24;at++)fr[at+111]="F"+at;for(var at=65;at<=90;at++)fr[at]=String.fromCharCode(at+32),ua[at]=String.fromCharCode(at);for(var Tu in fr)ua.hasOwnProperty(Tu)||(ua[Tu]=fr[Tu]);function wA(t){var e=bA&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||xA&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?ua:fr)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const kA=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),vA=typeof navigator<"u"&&/Win/.test(navigator.platform);function SA(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))kA?o=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),o&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function CA(t){let e=Object.create(null);for(let n in t)e[SA(n)]=t[n];return e}function Nu(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function EA(t){return new me({props:{handleKeyDown:of(t)}})}function of(t){let e=CA(t);return function(n,r){let s=wA(r),i,o=e[Nu(s,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Nu(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(vA&&r.ctrlKey&&r.altKey)&&(i=fr[r.keyCode])&&i!=s){let l=e[Nu(i,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var AA=Object.defineProperty,lf=(t,e)=>{for(var n in e)AA(t,n,{get:e[n],enumerable:!0})};function kc(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}var vc=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:s}=n,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...c)=>{const u=l(...c)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o=[],l=!!t,a=t||s.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(a),o.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(n).map(([d,h])=>[d,(...p)=>{const m=this.buildProps(a,e),y=h(...p)(m);return o.push(y),u}])),run:c};return u}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.tr,i=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,o={tr:t,editor:r,view:i,state:kc({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)(o)]))}};return o}},G0={};lf(G0,{blur:()=>MA,clearContent:()=>TA,clearNodes:()=>NA,command:()=>RA,createParagraphNear:()=>_A,cut:()=>OA,deleteCurrentNode:()=>DA,deleteNode:()=>LA,deleteRange:()=>IA,deleteSelection:()=>$A,enter:()=>BA,exitCode:()=>zA,extendMarkRange:()=>HA,first:()=>FA,focus:()=>VA,forEach:()=>WA,insertContent:()=>qA,insertContentAt:()=>GA,joinBackward:()=>ZA,joinDown:()=>XA,joinForward:()=>QA,joinItemBackward:()=>eM,joinItemForward:()=>tM,joinTextblockBackward:()=>nM,joinTextblockForward:()=>rM,joinUp:()=>YA,keyboardShortcut:()=>iM,lift:()=>oM,liftEmptyBlock:()=>lM,liftListItem:()=>aM,newlineInCode:()=>cM,resetAttributes:()=>uM,scrollIntoView:()=>dM,selectAll:()=>hM,selectNodeBackward:()=>fM,selectNodeForward:()=>pM,selectParentNode:()=>mM,selectTextblockEnd:()=>gM,selectTextblockStart:()=>yM,setContent:()=>bM,setMark:()=>$M,setMeta:()=>BM,setNode:()=>zM,setNodeSelection:()=>HM,setTextDirection:()=>FM,setTextSelection:()=>UM,sinkListItem:()=>VM,splitBlock:()=>WM,splitListItem:()=>qM,toggleList:()=>JM,toggleMark:()=>GM,toggleNode:()=>YM,toggleWrap:()=>XM,undoInputRule:()=>ZM,unsetAllMarks:()=>QM,unsetMark:()=>eT,unsetTextDirection:()=>tT,updateAttributes:()=>nT,wrapIn:()=>rT,wrapInList:()=>sT});var MA=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),TA=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),NA=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:i,$to:o})=>{t.doc.nodesBetween(i.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),h=c.resolve(u.map(a+l.nodeSize)),f=d.blockRange(h);if(!f)return;const p=Zs(f);if(l.type.isTextblock){const{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(f.start,m)}(p||p===0)&&e.lift(f,p)})}),!0},RA=t=>e=>t(e),_A=()=>({state:t,dispatch:e})=>u0(t,e),OA=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,i=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,i.content),r.setSelection(new Q(r.doc.resolve(Math.max(o-1,0)))),!0},DA=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const l=s.before(i),a=s.after(i);t.delete(l,a).scrollIntoView()}return!0}return!1};function Ke(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}var LA=t=>({tr:e,state:n,dispatch:r})=>{const s=Ke(t,n.schema),i=e.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===s){if(r){const a=i.before(o),c=i.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},IA=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},PA=t=>t.content?/^text(\*|\+)/.test(t.content):!1,Jm=(t,e,n)=>{if(!t.parent.isInline||n==="left"&&t.pos>t.start()||n==="right"&&t.pos<t.end())return t.pos;const r=e.nodes[t.parent.type.name].spec;return PA(r)?n==="left"?t.start()-1:t.end()+1:t.pos},jA=(t,e,n)=>{const r=Jm(t,n,"left"),s=Jm(e,n,"right");return{from:r,to:s}},$A=()=>({state:t,dispatch:e})=>{const{$from:n,$to:r}=t.selection;if(t.selection.empty)return!1;const{from:s,to:i}=jA(n,r,t.schema);return e&&(t.tr.deleteRange(s,i).scrollIntoView(),e(t.tr)),!0},BA=()=>({commands:t})=>t.keyboardShortcut("Enter"),zA=()=>({state:t,dispatch:e})=>kC(t,e);function af(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function da(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:af(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function Y0(t,e,n={}){return t.find(r=>r.type===e&&da(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function Gm(t,e,n={}){return!!Y0(t,e,n)}function cf(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(c=>c.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(c=>c.type===e))return;if(!n){const c=r.node.marks.find(u=>u.type===e);c&&(n=c.attrs)}if(!Y0([...r.node.marks],e,n))return;let i=r.index,o=t.start()+r.offset,l=i+1,a=o+r.node.nodeSize;for(;i>0&&Gm([...t.parent.child(i-1).marks],e,n);)i-=1,o-=t.parent.child(i).nodeSize;for(;l<t.parent.childCount&&Gm([...t.parent.child(l).marks],e,n);)a+=t.parent.child(l).nodeSize,l+=1;return{from:o,to:a}}function Un(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}var HA=(t,e)=>({tr:n,state:r,dispatch:s})=>{const i=Un(t,r.schema),{doc:o,selection:l}=n,{$from:a,from:c,to:u}=l;if(s){const d=cf(a,i,e);if(d&&d.from<=c&&d.to>=u){const h=Q.create(o,d.from,d.to);n.setSelection(h)}}return!0},FA=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function uf(t){return t instanceof Q}function Or(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function X0(t,e=null){if(!e)return null;const n=te.atStart(t),r=te.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,i=r.to;return e==="all"?Q.create(t,Or(0,s,i),Or(t.content.size,s,i)):Q.create(t,Or(e,s,i),Or(e,s,i))}function Bd(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function lo(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function UA(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var VA=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const o=()=>{(lo()||Bd())&&r.dom.focus(),UA()&&!lo()&&!Bd()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!uf(n.state.selection))return o(),!0;const l=X0(s.doc,t)||n.state.selection,a=n.state.selection.eq(l);return i&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),o()),!0},WA=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),qA=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),Z0=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Z0(r)}return t};function ll(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return Z0(n)}function ao(t,e,n){if(t instanceof cr||t instanceof j)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return j.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),ao("",e,n)}if(s){if(n.errorOnInvalidContent){let o=!1,l="";const a=new Ob({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(o=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?Pi.fromSchema(a).parseSlice(ll(t),n.parseOptions):Pi.fromSchema(a).parse(ll(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const i=Pi.fromSchema(e);return n.slice?i.parseSlice(ll(t),n.parseOptions).content:i.parse(ll(t),n.parseOptions)}return ao("",e,n)}function KA(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof Qt||s instanceof jt))return;const i=t.mapping.maps[r];let o=0;i.forEach((l,a,c,u)=>{o===0&&(o=u)}),t.setSelection(te.near(t.doc.resolve(o),n))}var JA=t=>!("type"in t),GA=(t,e,n)=>({tr:r,dispatch:s,editor:i})=>{var o;if(s){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const a=y=>{i.emit("contentError",{editor:i,error:y,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{ao(e,i.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(y){a(y)}try{l=ao(e,i.schema,{parseOptions:c,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:i.options.enableContentCheck})}catch(y){return a(y),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},h=!0,f=!0;if((JA(l)?l:[l]).forEach(y=>{y.check(),h=h?y.isText&&y.marks.length===0:!1,f=f?y.isBlock:!1}),u===d&&f){const{parent:y}=r.doc.resolve(u);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(u-=1,d+=1)}let m;if(h){if(Array.isArray(e))m=e.map(y=>y.text||"").join("");else if(e instanceof j){let y="";e.forEach(b=>{b.text&&(y+=b.text)}),m=y}else typeof e=="object"&&e&&e.text?m=e.text:m=e;r.insertText(m,u,d)}else{m=l;const y=r.doc.resolve(u),b=y.node(),x=y.parentOffset===0,w=b.isText||b.isTextblock,k=b.content.size>0;x&&w&&k&&f&&(u=Math.max(0,u-1)),r.replaceWith(u,d,m)}n.updateSelection&&KA(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:m}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:m})}return!0},YA=()=>({state:t,dispatch:e})=>bC(t,e),XA=()=>({state:t,dispatch:e})=>xC(t,e),ZA=()=>({state:t,dispatch:e})=>r0(t,e),QA=()=>({state:t,dispatch:e})=>l0(t,e),eM=()=>({state:t,dispatch:e,tr:n})=>{try{const r=gc(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},tM=()=>({state:t,dispatch:e,tr:n})=>{try{const r=gc(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},nM=()=>({state:t,dispatch:e})=>gC(t,e),rM=()=>({state:t,dispatch:e})=>yC(t,e);function Q0(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function sM(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,s,i,o;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))lo()||Q0()?o=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var iM=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const i=sM(t).split(/-(?!$)/),o=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a?.steps.forEach(c=>{const u=c.map(r.mapping);u&&s&&r.maybeStep(u)}),!0};function pr(t,e,n={}){const{from:r,to:s,empty:i}=t.selection,o=e?Ke(e,t.schema):null,l=[];t.doc.nodesBetween(r,s,(d,h)=>{if(d.isText)return;const f=Math.max(r,h),p=Math.min(s,h+d.nodeSize);l.push({node:d,from:f,to:p})});const a=s-r,c=l.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>da(d.node.attrs,n,{strict:!1}));return i?!!c.length:c.reduce((d,h)=>d+h.to-h.from,0)>=a}var oM=(t,e={})=>({state:n,dispatch:r})=>{const s=Ke(t,n.schema);return pr(n,s,e)?wC(n,r):!1},lM=()=>({state:t,dispatch:e})=>d0(t,e),aM=t=>({state:e,dispatch:n})=>{const r=Ke(t,e.schema);return OC(r)(e,n)},cM=()=>({state:t,dispatch:e})=>c0(t,e);function Sc(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Ym(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var uM=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=Sc(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=Ke(t,r.schema)),l==="mark"&&(o=Un(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{r.doc.nodesBetween(c.$from.pos,c.$to.pos,(u,d)=>{i&&i===u.type&&(a=!0,s&&n.setNodeMarkup(d,void 0,Ym(u.attrs,e))),o&&u.marks.length&&u.marks.forEach(h=>{o===h.type&&(a=!0,s&&n.addMark(d,d+u.nodeSize,o.create(Ym(h.attrs,e))))})})}),a},dM=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),hM=()=>({tr:t,dispatch:e})=>{if(e){const n=new xn(t.doc);t.setSelection(n)}return!0},fM=()=>({state:t,dispatch:e})=>i0(t,e),pM=()=>({state:t,dispatch:e})=>a0(t,e),mM=()=>({state:t,dispatch:e})=>CC(t,e),gM=()=>({state:t,dispatch:e})=>MC(t,e),yM=()=>({state:t,dispatch:e})=>AC(t,e);function zd(t,e,n={},r={}){return ao(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var bM=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:o,commands:l})=>{const{doc:a}=i;if(r.preserveWhitespace!=="full"){const c=zd(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return o&&i.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n),!0}return o&&i.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function ex(t,e){const n=Un(e,t.schema),{from:r,to:s,empty:i}=t.selection,o=[];i?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function tx(t,e){const n=new Vh(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function xM(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Hd(t,e){const n=[];return t.descendants((r,s)=>{e(r)&&n.push({node:r,pos:s})}),n}function wM(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function nx(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function Cc(t){return e=>nx(e.$from,t)}function J(t,e,n){return t.config[e]===void 0&&t.parent?J(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?J(t.parent,e,n):null}):t.config[e]}function df(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=J(e,"addExtensions",n);return r?[e,...df(r())]:e}).flat(10)}function hf(t,e){const n=ns.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function rx(t){return typeof t=="function"}function we(t,e=void 0,...n){return rx(t)?e?t.bind(e)(...n):t(...n):t}function kM(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Is(t){const e=t.filter(s=>s.type==="extension"),n=t.filter(s=>s.type==="node"),r=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function sx(t){const e=[],{nodeExtensions:n,markExtensions:r}=Is(t),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(c=>c.name!=="text").map(c=>c.name),l=r.map(c=>c.name),a=[...o,...l];return t.forEach(c=>{const u={name:c.name,options:c.options,storage:c.storage,extensions:s},d=J(c,"addGlobalAttributes",u);if(!d)return;d().forEach(f=>{let p;Array.isArray(f.types)?p=f.types:f.types==="*"?p=a:f.types==="nodes"?p=o:f.types==="marks"?p=l:p=[],p.forEach(m=>{Object.entries(f.attributes).forEach(([y,b])=>{e.push({type:m,name:y,attribute:{...i,...b}})})})})}),s.forEach(c=>{const u={name:c.name,options:c.options,storage:c.storage},d=J(c,"addAttributes",u);if(!d)return;const h=d();Object.entries(h).forEach(([f,p])=>{const m={...i,...p};typeof m?.default=="function"&&(m.default=m.default()),m?.isRequired&&m?.default===void 0&&delete m.default,e.push({type:c.name,name:f,attribute:m})})}),e}function vM(t){const e=[];let n="",r=!1,s=!1,i=0;const o=t.length;for(let l=0;l<o;l+=1){const a=t[l];if(a==="'"&&!s){r=!r,n+=a;continue}if(a==='"'&&!r){s=!s,n+=a;continue}if(!r&&!s){if(a==="("){i+=1,n+=a;continue}if(a===")"&&i>0){i-=1,n+=a;continue}if(a===";"&&i===0){e.push(n),n="";continue}}n+=a}return n&&e.push(n),e}function Xm(t){const e=[],n=vM(t||""),r=n.length;for(let s=0;s<r;s+=1){const i=n[s],o=i.indexOf(":");if(o===-1)continue;const l=i.slice(0,o).trim(),a=i.slice(o+1).trim();l&&a&&e.push([l,a])}return e}function fe(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const l=i?String(i).split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(u=>!a.includes(u));r[s]=[...a,...c].join(" ")}else if(s==="style"){const l=new Map([...Xm(r[s]),...Xm(i)]);r[s]=Array.from(l.entries()).map(([a,c])=>`${a}: ${c}`).join("; ")}else r[s]=i}),r},{})}function Ps(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>fe(n,r),{})}function SM(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Zm(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((i,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):SM(n.getAttribute(o.name));return l==null?i:{...i,[o.name]:l}},{});return{...r,...s}}}}function Qm(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&kM(n)?!1:n!=null))}function eg(t){var e,n;const r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function CM(t,e){var n;const r=sx(t),{nodeExtensions:s,markExtensions:i}=Is(t),o=(n=s.find(c=>J(c,"topNode")))==null?void 0:n.name,l=Object.fromEntries(s.map(c=>{const u=r.filter(b=>b.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((b,x)=>{const w=J(x,"extendNodeSchema",d);return{...b,...w?w(c):{}}},{}),f=Qm({...h,content:we(J(c,"content",d)),marks:we(J(c,"marks",d)),group:we(J(c,"group",d)),inline:we(J(c,"inline",d)),atom:we(J(c,"atom",d)),selectable:we(J(c,"selectable",d)),draggable:we(J(c,"draggable",d)),code:we(J(c,"code",d)),whitespace:we(J(c,"whitespace",d)),linebreakReplacement:we(J(c,"linebreakReplacement",d)),defining:we(J(c,"defining",d)),isolating:we(J(c,"isolating",d)),attrs:Object.fromEntries(u.map(eg))}),p=we(J(c,"parseHTML",d));p&&(f.parseDOM=p.map(b=>Zm(b,u)));const m=J(c,"renderHTML",d);m&&(f.toDOM=b=>m({node:b,HTMLAttributes:Ps(b,u)}));const y=J(c,"renderText",d);return y&&(f.toText=y),[c.name,f]})),a=Object.fromEntries(i.map(c=>{const u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((y,b)=>{const x=J(b,"extendMarkSchema",d);return{...y,...x?x(c):{}}},{}),f=Qm({...h,inclusive:we(J(c,"inclusive",d)),excludes:we(J(c,"excludes",d)),group:we(J(c,"group",d)),spanning:we(J(c,"spanning",d)),code:we(J(c,"code",d)),attrs:Object.fromEntries(u.map(eg))}),p=we(J(c,"parseHTML",d));p&&(f.parseDOM=p.map(y=>Zm(y,u)));const m=J(c,"renderHTML",d);return m&&(f.toDOM=y=>m({mark:y,HTMLAttributes:Ps(y,u)})),[c.name,f]}));return new Ob({topNode:o,nodes:l,marks:a})}function EM(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function zi(t){return t.sort((n,r)=>{const s=J(n,"priority")||100,i=J(r,"priority")||100;return s>i?-1:s<i?1:0})}function ix(t){const e=zi(df(t)),n=EM(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function ox(t,e,n){const{from:r,to:s}=e,{blockSeparator:i=`
16
+
17
+ `,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,s,(a,c,u,d)=>{var h;a.isBlock&&c>r&&(l+=i);const f=o?.[a.type.name];if(f)return u&&(l+=f({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(h=a?.text)==null?void 0:h.slice(Math.max(r,c)-c,s-c))}),l}function AM(t,e){const n={from:0,to:t.content.size};return ox(t,n,e)}function lx(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function MM(t,e){const n=Ke(e,t.schema),{from:r,to:s}=t.selection,i=[];t.doc.nodesBetween(r,s,l=>{i.push(l)});const o=i.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function ax(t,e){const n=Sc(typeof e=="string"?e:e.name,t.schema);return n==="node"?MM(t,e):n==="mark"?ex(t,e):{}}function TM(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function NM(t){const e=TM(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,o)=>o!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function cx(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,i)=>{const o=[];if(s.ranges.length)s.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=n[i];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(i).map(l,-1),u=e.slice(i).map(a),d=e.invert().map(c,-1),h=e.invert().map(u);r.push({oldRange:{from:d,to:h},newRange:{from:c,to:u}})})}),NM(r)}function ff(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const i=n.resolve(t),o=cf(i,s.type);o&&r.push({mark:s,...o})}):n.nodesBetween(t,e,(s,i)=>{!s||s?.nodeSize===void 0||r.push(...s.marks.map(o=>({from:i,to:i+s.nodeSize,mark:o})))}),r}var RM=(t,e,n,r=20)=>{const s=t.doc.resolve(n);let i=r,o=null;for(;i>0&&o===null;){const l=s.node(i);l?.type.name===e?o=l:i-=1}return[o,i]};function fi(t,e){return e.nodes[t]||e.marks[t]||null}function Pl(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}var _M=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,i,o,l)=>{var a,c;const u=((c=(a=s.type.spec).toText)==null?void 0:c.call(a,{node:s,pos:i,parent:o,index:l}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-i))}),n};function Fd(t,e,n={}){const{empty:r,ranges:s}=t.selection,i=e?Un(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>i?i.name===d.type.name:!0).find(d=>da(d.attrs,n,{strict:!1}));let o=0;const l=[];if(s.forEach(({$from:d,$to:h})=>{const f=d.pos,p=h.pos;t.doc.nodesBetween(f,p,(m,y)=>{if(i&&m.inlineContent&&!m.type.allowsMarkType(i))return!1;if(!m.isText&&!m.marks.length)return;const b=Math.max(f,y),x=Math.min(p,y+m.nodeSize),w=x-b;o+=w,l.push(...m.marks.map(k=>({mark:k,from:b,to:x})))})}),o===0)return!1;const a=l.filter(d=>i?i.name===d.mark.type.name:!0).filter(d=>da(d.mark.attrs,n,{strict:!1})).reduce((d,h)=>d+h.to-h.from,0),c=l.filter(d=>i?d.mark.type!==i&&d.mark.type.excludes(i):!0).reduce((d,h)=>d+h.to-h.from,0);return(a>0?a+c:a)>=o}function OM(t,e,n={}){if(!e)return pr(t,null,n)||Fd(t,null,n);const r=Sc(e,t.schema);return r==="node"?pr(t,e,n):r==="mark"?Fd(t,e,n):!1}var DM=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const i=Cc(l=>l.type.name===e)(t.selection);if(!i)return!1;const o=t.doc.resolve(i.pos+1);return s.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},LM=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function tg(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Ru(t,e){const{nodeExtensions:n}=Is(e),r=n.find(o=>o.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=we(J(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function js(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return!/\S/.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(i=>{s!==!1&&(js(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function ux(t){return t instanceof Y}function IM({selection:t,pos:e,nodeSize:n,selectedOnTextSelection:r=!1}){const{from:s,to:i}=t;return!!(s<=e&&i>=e+n||r&&uf(t)&&s>e&&i<e+n)}var pf=class dx{constructor(e){this.position=e}static fromJSON(e){return new dx(e.position)}toJSON(){return{position:this.position}}};function hx(t,e){const n=e.mapping.mapResult(t.position);return{position:new pf(n.pos),mapResult:n}}function PM(t){return new pf(t)}function jM(t,e,n){var r;const{selection:s}=e;let i=null;if(uf(s)&&(i=s.$cursor),i){const l=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(c=>c.type.excludes(n)))}const{ranges:o}=s;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(u,d,h)=>{if(c)return!1;if(u.isInline){const f=!h||h.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(n));c=f&&p}return!c}),c})}var $M=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:o,ranges:l}=i,a=Un(t,r.schema);if(s)if(o){const c=ex(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(h,f)=>{const p=Math.max(f,u),m=Math.min(f+h.nodeSize,d);h.marks.find(b=>b.type===a)?h.marks.forEach(b=>{a===b.type&&n.addMark(p,m,a.create({...b.attrs,...e}))}):n.addMark(p,m,a.create(e))})});return jM(r,n,a)},BM=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),zM=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const i=Ke(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:l})=>pm(i,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>pm(i,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},HM=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=Or(t,0,r.content.size),i=Y.create(r,s);e.setSelection(i)}return!0},FM=(t,e)=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=r;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=i.from,l=i.to),s&&n.doc.nodesBetween(o,l,(a,c)=>{a.isText||n.setNodeMarkup(c,void 0,{...a.attrs,dir:t})}),!0},UM=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,o=Q.atStart(r).from,l=Q.atEnd(r).to,a=Or(s,o,l),c=Or(i,o,l),u=Q.create(r,a,c);e.setSelection(u)}return!0},VM=t=>({state:e,dispatch:n})=>{const r=Ke(t,e.schema);return IC(r)(e,n)};function ng(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e?.includes(s.type.name));t.tr.ensureMarks(r)}}var WM=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:o}=e,{$from:l,$to:a}=i,c=s.extensionManager.attributes,u=Pl(c,l.node().type.name,l.node().attrs);if(i instanceof Y&&i.node.isBlock)return!l.parentOffset||!$n(o,l.pos)?!1:(r&&(t&&ng(n,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,h=l.depth===0?void 0:xM(l.node(-1).contentMatchAt(l.indexAfter(-1)));let f=d&&h?[{type:h,attrs:u}]:void 0,p=$n(e.doc,e.mapping.map(l.pos),1,f);if(!f&&!p&&$n(e.doc,e.mapping.map(l.pos),1,h?[{type:h}]:void 0)&&(p=!0,f=h?[{type:h,attrs:u}]:void 0),r){if(p&&(i instanceof Q&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,f),h&&!d&&!l.parentOffset&&l.parent.type!==h)){const m=e.mapping.map(l.before()),y=e.doc.resolve(m);l.node(-1).canReplaceWith(y.index(),y.index()+1,h)&&e.setNodeMarkup(e.mapping.map(l.before()),h)}t&&ng(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return p},qM=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var o;const l=Ke(t,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;const d=a.node(-1);if(d.type!==l)return!1;const h=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(s){let b=j.empty;const x=a.index(-1)?1:a.index(-2)?2:3;for(let A=a.depth-x;A>=a.depth-3;A-=1)b=j.from(a.node(A).copy(b));const w=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,k={...Pl(h,a.node().type.name,a.node().attrs),...e},T=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(k))||void 0;b=b.append(j.from(l.createAndFill(null,T)||void 0));const S=a.before(a.depth-(x-1));n.replace(S,a.after(-w),new F(b,4-x,0));let v=-1;n.doc.nodesBetween(S,n.doc.content.size,(A,C)=>{if(v>-1)return!1;A.isTextblock&&A.content.size===0&&(v=C+1)}),v>-1&&n.setSelection(Q.near(n.doc.resolve(v))),n.scrollIntoView()}return!0}const f=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,p={...Pl(h,d.type.name,d.attrs),...e},m={...Pl(h,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);const y=f?[{type:l,attrs:p},{type:f,attrs:m}]:[{type:l,attrs:p}];if(!$n(n.doc,a.pos,2))return!1;if(s){const{selection:b,storedMarks:x}=r,{splittableMarks:w}=i.extensionManager,k=x||b.$to.parentOffset&&b.$from.marks();if(n.split(a.pos,2,y).scrollIntoView(),!k||!s)return!0;const T=k.filter(S=>w.includes(S.type.name));n.ensureMarks(T)}return!0},_u=(t,e)=>{const n=Cc(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===s?.type&&kr(t.doc,n.pos)&&t.join(n.pos),!0},Ou=(t,e)=>{const n=Cc(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===s?.type&&kr(t.doc,r)&&t.join(r),!0};function KM(t){const e=t.doc,n=e.firstChild;if(!n)return null;const r=e.resolve(1),s=e.resolve(n.nodeSize-1);return Q.between(r,s)}var JM=(t,e,n,r={})=>({editor:s,tr:i,state:o,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:h}=s.extensionManager,f=Ke(t,o.schema),p=Ke(e,o.schema),{selection:m,storedMarks:y}=o,{$from:b,$to:x}=m,w=b.blockRange(x),k=y||m.$to.parentOffset&&m.$from.marks();if(!w)return!1;const T=Cc(L=>Ru(L.type.name,d))(m),S=m.from===0&&m.to===o.doc.content.size,v=o.doc.content.content,A=v.length===1?v[0]:null,C=S&&A&&Ru(A.type.name,d)?{node:A,pos:0}:null,N=T??C,D=!!T&&w.depth>=1&&w.depth-T.depth<=1,z=!!C;if((D||z)&&N){if(N.node.type===f)return S&&z?a().command(({tr:L,dispatch:_})=>{const V=KM(L);return V?(L.setSelection(V),_&&_(L),!0):!1}).liftListItem(p).run():c.liftListItem(p);if(Ru(N.node.type.name,d)&&f.validContent(N.node.content))return a().command(()=>(i.setNodeMarkup(N.pos,f),!0)).command(()=>_u(i,f)).command(()=>Ou(i,f)).run()}return!n||!k||!l?a().command(()=>u().wrapInList(f,r)?!0:c.clearNodes()).wrapInList(f,r).command(()=>_u(i,f)).command(()=>Ou(i,f)).run():a().command(()=>{const L=u().wrapInList(f,r),_=k.filter(V=>h.includes(V.type.name));return i.ensureMarks(_),L?!0:c.clearNodes()}).wrapInList(f,r).command(()=>_u(i,f)).command(()=>Ou(i,f)).run()},GM=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,o=Un(t,r.schema);return Fd(r,o,e)?s.unsetMark(o,{extendEmptyMarkRange:i}):s.setMark(o,e)},YM=(t,e,n={})=>({state:r,commands:s})=>{const i=Ke(t,r.schema),o=Ke(e,r.schema),l=pr(r,i,n);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(o,a):s.setNode(i,{...a,...n})},XM=(t,e={})=>({state:n,commands:r})=>{const s=Ke(t,n.schema);return pr(n,s,e)?r.lift(s):r.wrapIn(s,e)},ZM=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let i;if(s.spec.isInputRules&&(i=s.getState(t))){if(e){const o=t.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(i.text){const a=o.doc.resolve(i.from).marks();o.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else o.delete(i.from,i.to)}return!0}}return!1},QM=(t={})=>({tr:e,dispatch:n,editor:r})=>{const{ignoreClearable:s=!1}=t,{selection:i}=e,{empty:o,ranges:l}=i;if(o)return!0;const{nonClearableMarks:a}=r.extensionManager;if(n){const c=Object.values(r.schema.marks).filter(u=>s||!a.includes(u.name));l.forEach(u=>{for(const d of c)e.removeMark(u.$from.pos,u.$to.pos,d)})}return!0},eT=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,a=Un(t,r.schema),{$from:c,empty:u,ranges:d}=l;if(!s)return!0;if(u&&o){let{from:h,to:f}=l;const p=(i=c.marks().find(y=>y.type===a))==null?void 0:i.attrs,m=cf(c,a,p);m&&(h=m.from,f=m.to),n.removeMark(h,f,a)}else d.forEach(h=>{n.removeMark(h.$from.pos,h.$to.pos,a)});return n.removeStoredMark(a),!0},tT=t=>({tr:e,state:n,dispatch:r})=>{const{selection:s}=n;let i,o;return typeof t=="number"?(i=t,o=t):t&&"from"in t&&"to"in t?(i=t.from,o=t.to):(i=s.from,o=s.to),r&&e.doc.nodesBetween(i,o,(l,a)=>{if(l.isText)return;const c={...l.attrs};delete c.dir,e.setNodeMarkup(a,void 0,c)}),!0},nT=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,o=null;const l=Sc(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(i=Ke(t,r.schema)),l==="mark"&&(o=Un(t,r.schema));let a=!1;return n.selection.ranges.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;let h,f,p,m;n.selection.empty?r.doc.nodesBetween(u,d,(y,b)=>{i&&i===y.type&&(a=!0,p=Math.max(b,u),m=Math.min(b+y.nodeSize,d),h=b,f=y)}):r.doc.nodesBetween(u,d,(y,b)=>{b<u&&i&&i===y.type&&(a=!0,p=Math.max(b,u),m=Math.min(b+y.nodeSize,d),h=b,f=y),b>=u&&b<=d&&(i&&i===y.type&&(a=!0,s&&n.setNodeMarkup(b,void 0,{...y.attrs,...e})),o&&y.marks.length&&y.marks.forEach(x=>{if(o===x.type&&(a=!0,s)){const w=Math.max(b,u),k=Math.min(b+y.nodeSize,d);n.addMark(w,k,o.create({...x.attrs,...e}))}}))}),f&&(h!==void 0&&s&&n.setNodeMarkup(h,void 0,{...f.attrs,...e}),o&&f.marks.length&&f.marks.forEach(y=>{o===y.type&&s&&n.addMark(p,m,o.create({...y.attrs,...e}))}))}),a},rT=(t,e={})=>({state:n,dispatch:r})=>{const s=Ke(t,n.schema);return TC(s,e)(n,r)},sT=(t,e={})=>({state:n,dispatch:r})=>{const s=Ke(t,n.schema);return NC(s,e)(n,r)},iT=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}},Oo=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},oT=(t,e)=>{if(af(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function al(t){var e;const{editor:n,from:r,to:s,text:i,rules:o,plugin:l}=t,{view:a}=n;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(h=>h.type.spec.code))return!1;let u=!1;const d=_M(c)+i;return o.forEach(h=>{if(u)return;const f=oT(d,h.find);if(!f)return;const p=a.state.tr,m=kc({state:a.state,transaction:p}),y={from:r-(f[0].length-i.length),to:s},{commands:b,chain:x,can:w}=new vc({editor:n,state:m});h.handler({state:m,range:y,match:f,commands:b,chain:x,can:w})===null||!p.steps.length||(h.undoable&&p.setMeta(l,{transform:p,from:r,to:s,text:i}),a.dispatch(p),u=!0)}),u}function lT(t){const{editor:e,rules:n}=t,r=new me({state:{init(){return null},apply(s,i,o){const l=s.getMeta(r);if(l)return l;const a=s.getMeta("applyInputRules");return a&&setTimeout(()=>{let{text:u}=a;typeof u=="string"?u=u:u=hf(j.from(u),o.schema);const{from:d}=a,h=d+u.length;al({editor:e,from:d,to:h,text:u,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,o,l){return al({editor:e,from:i,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&al({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:o}=s.state.selection;return o?al({editor:e,from:o.pos,to:o.pos,text:`
18
+ `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function aT(t){return Object.prototype.toString.call(t).slice(8,-1)}function cl(t){return aT(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function fx(t,e){const n={...t};return cl(t)&&cl(e)&&Object.keys(e).forEach(r=>{cl(e[r])&&cl(t[r])?n[r]=fx(t[r],e[r]):n[r]=e[r]}),n}var mf=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...we(J(this,"addOptions",{name:this.name}))}}get storage(){return{...we(J(this,"addStorage",{name:this.name,options:this.options}))}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>fx(this.options,t)});return e.name=this.name,e.parent=this.parent,this.child=null,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},dn=class px extends mf{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new px(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const o=s.marks();if(!!!o.find(c=>c?.type.name===n.name))return!1;const a=o.find(c=>c?.type.name===n.name);return a&&r.removeStoredMark(a),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function cT(t){return typeof t=="number"}var uT=class{constructor(t){this.find=t.find,this.handler=t.handler}},dT=(t,e,n)=>{if(af(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=t,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function hT(t){const{editor:e,state:n,from:r,to:s,rule:i,pasteEvent:o,dropEvent:l}=t,{commands:a,chain:c,can:u}=new vc({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,s,(f,p)=>{var m,y,b,x,w;if((y=(m=f.type)==null?void 0:m.spec)!=null&&y.code||!(f.isText||f.isTextblock||f.isInline))return;const k=(w=(x=(b=f.content)==null?void 0:b.size)!=null?x:f.nodeSize)!=null?w:0,T=Math.max(r,p),S=Math.min(s,p+k);if(T>=S)return;const v=f.isText?f.text||"":f.textBetween(T-p,S-p,void 0,"");dT(v,i.find,o).forEach(C=>{if(C.index===void 0)return;const N=T+C.index+1,D=N+C[0].length,z={from:n.tr.mapping.map(N),to:n.tr.mapping.map(D)},L=i.handler({state:n,range:z,match:C,commands:a,chain:c,can:u,pasteEvent:o,dropEvent:l});d.push(L)})}),d.every(f=>f!==null)}var ul=null,fT=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function pT(t){const{editor:e,rules:n}=t;let r=null,s=!1,i=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:u,from:d,to:h,rule:f,pasteEvt:p})=>{const m=u.tr,y=kc({state:u,transaction:m});if(!(!hT({editor:e,state:y,from:Math.max(d-1,0),to:h.b-1,rule:f,pasteEvent:p,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,m}};return n.map(u=>new me({view(d){const h=p=>{var m;r=(m=d.dom.parentElement)!=null&&m.contains(p.target)?d.dom.parentElement:null,r&&(ul=e)},f=()=>{ul&&(ul=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(d,h)=>{if(i=r===d.dom.parentElement,l=h,!i){const f=ul;f?.isEditable&&setTimeout(()=>{const p=f.state.selection;p&&f.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,h)=>{var f;const p=(f=h.clipboardData)==null?void 0:f.getData("text/html");return o=h,s=!!p?.includes("data-pm-slice"),!1}}},appendTransaction:(d,h,f)=>{const p=d[0],m=p.getMeta("uiEvent")==="paste"&&!s,y=p.getMeta("uiEvent")==="drop"&&!i,b=p.getMeta("applyPasteRules"),x=!!b;if(!m&&!y&&!x)return;if(x){let{text:T}=b;typeof T=="string"?T=T:T=hf(j.from(T),f.schema);const{from:S}=b,v=S+T.length,A=fT(T);return a({rule:u,state:f,from:S,to:{b:v},pasteEvt:A})}const w=h.doc.content.findDiffStart(f.doc.content),k=h.doc.content.findDiffEnd(f.doc.content);if(!(!cT(w)||!k||w===k.b))return a({rule:u,state:f,from:w,to:k,pasteEvt:o})}}))}var Ec=class{constructor(t,e){this.splittableMarks=[],this.nonClearableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=ix(t),this.schema=CM(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:fi(e.name,this.schema)},r=J(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return zi([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:fi(r.name,this.schema)},i=[],o=J(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&J(r,"exitable",s)&&(l.ArrowRight=()=>dn.handleExit({editor:t,mark:r})),o){const h=Object.fromEntries(Object.entries(o()).map(([f,p])=>[f,()=>p({editor:t})]));l={...l,...h}}const a=EA(l);i.push(a);const c=J(r,"addInputRules",s);if(tg(r,t.options.enableInputRules)&&c){const h=c();if(h&&h.length){const f=lT({editor:t,rules:h}),p=Array.isArray(f)?f:[f];i.push(...p)}}const u=J(r,"addPasteRules",s);if(tg(r,t.options.enablePasteRules)&&u){const h=u();if(h&&h.length){const f=pT({editor:t,rules:h});i.push(...f)}}const d=J(r,"addProseMirrorPlugins",s);if(d){const h=d();i.push(...h)}return i})}get attributes(){return sx(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Is(this.extensions);return Object.fromEntries(e.filter(n=>!!J(n,"addNodeView")).map(n=>{const r=this.attributes.filter(a=>a.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Ke(n.name,this.schema)},i=J(n,"addNodeView",s);if(!i)return[];const o=i();if(!o)return[];const l=(a,c,u,d,h)=>{const f=Ps(a,r);return o({node:a,view:c,getPos:u,decorations:d,innerDecorations:h,editor:t,extension:n,HTMLAttributes:f})};return[n.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return zi([...this.extensions].reverse()).reduceRight((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:fi(s.name,this.schema)},o=J(s,"dispatchTransaction",i);return o?l=>{o.call(i,{transaction:l,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return zi([...this.extensions]).reduce((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:fi(s.name,this.schema)},o=J(s,"transformPastedHTML",i);return o?(l,a)=>{const c=r(l,a);return o.call(i,c)}:r},t||(r=>r))}get markViews(){const{editor:t}=this,{markExtensions:e}=Is(this.extensions);return Object.fromEntries(e.filter(n=>!!J(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Un(n.name,this.schema)},i=J(n,"addMarkView",s);if(!i)return[];const o=(l,a,c)=>{const u=Ps(l,r);return i()({mark:l,view:a,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:d=>{RT(l,t,d)}})};return[n.name,o]}))}destroy(){this.extensions.forEach(t=>{let e=t;for(;e.parent;){const n=e.parent;n.child===e&&(n.child=null),e=n}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n,r;const s={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:fi(e.name,this.schema)};e.type==="mark"&&(((n=we(J(e,"keepOnSplit",s)))==null||n)&&this.splittableMarks.push(e.name),(r=we(J(e,"clearable",s)))==null||r||this.nonClearableMarks.push(e.name));const i=J(e,"onBeforeCreate",s),o=J(e,"onCreate",s),l=J(e,"onUpdate",s),a=J(e,"onSelectionUpdate",s),c=J(e,"onTransaction",s),u=J(e,"onFocus",s),d=J(e,"onBlur",s),h=J(e,"onDestroy",s);i&&this.editor.on("beforeCreate",i),o&&this.editor.on("create",o),l&&this.editor.on("update",l),a&&this.editor.on("selectionUpdate",a),c&&this.editor.on("transaction",c),u&&this.editor.on("focus",u),d&&this.editor.on("blur",d),h&&this.editor.on("destroy",h)})}};Ec.resolve=ix;Ec.sort=zi;Ec.flatten=df;var mT={};lf(mT,{ClipboardTextSerializer:()=>gx,Commands:()=>yx,Delete:()=>bx,Drop:()=>xx,Editable:()=>wx,FocusEvents:()=>vx,Keymap:()=>Sx,Paste:()=>Cx,Tabindex:()=>Ex,TextDirection:()=>Ax,focusEventsPluginKey:()=>kx});var ce=class mx extends mf{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new mx(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},gx=ce.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new me({key:new ge("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,i=lx(n),{blockSeparator:o}=this.options,l={...o!==void 0?{blockSeparator:o}:{},textSerializers:i};return[...s.ranges].sort((c,u)=>c.$from.pos-u.$from.pos).map(({$from:c,$to:u})=>ox(r,{from:c.pos,to:u.pos},l)).join(o??`
19
+
20
+ `)}}})]}}),yx=ce.create({name:"commands",addCommands(){return{...G0}}}),bx=ce.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,s;const i=()=>{var o,l,a,c;if((c=(a=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,t))!=null?c:t.getMeta("y-sync$"))return;const u=tx(t.before,[t,...e]);cx(u).forEach(f=>{u.mapping.mapResult(f.oldRange.from).deletedAfter&&u.mapping.mapResult(f.oldRange.to).deletedBefore&&u.before.nodesBetween(f.oldRange.from,f.oldRange.to,(p,m)=>{const y=m+p.nodeSize-2,b=f.oldRange.from<=m&&y<=f.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:m,to:y,newFrom:u.mapping.map(m),newTo:u.mapping.map(y),deletedRange:f.oldRange,newRange:f.newRange,partial:!b,editor:this.editor,transaction:t,combinedTransform:u})})});const h=u.mapping;u.steps.forEach((f,p)=>{var m,y;if(f instanceof Xs){const b=h.slice(p).map(f.from,-1),x=h.slice(p).map(f.to),w=h.invert().map(b,-1),k=h.invert().map(x),T=b>0?(m=u.doc.nodeAt(b-1))==null?void 0:m.marks.some(v=>v.eq(f.mark)):!1,S=(y=u.doc.nodeAt(x))==null?void 0:y.marks.some(v=>v.eq(f.mark));this.editor.emit("delete",{type:"mark",mark:f.mark,from:f.from,to:f.to,deletedRange:{from:w,to:k},newRange:{from:b,to:x},partial:!!(S||T),editor:this.editor,transaction:t,combinedTransform:u})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(i,0):i()}}),xx=ce.create({name:"drop",addProseMirrorPlugins(){return[new me({key:new ge("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),wx=ce.create({name:"editable",addProseMirrorPlugins(){return[new me({key:new ge("editable"),props:{editable:()=>this.editor.options.editable}})]}}),kx=new ge("focusEvents"),vx=ce.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new me({key:kx,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Sx=ce.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:h,parent:f}=d,p=d.parent.isTextblock&&h>0?l.doc.resolve(h-1):d,m=p.parent.type.spec.isolating,y=d.pos-d.parentOffset,b=m&&p.parent.childCount===1?y===d.pos:te.atStart(c).from===h;return!u||!f.type.isTextblock||f.textContent.length||!b||b&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},i={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return lo()||Q0()?i:s},addProseMirrorPlugins(){return[new me({key:new ge("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(m=>m.getMeta("composition")))return;const r=t.some(m=>m.docChanged)&&!e.doc.eq(n.doc),s=t.some(m=>m.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:o,to:l}=e.selection,a=te.atStart(e.doc).from,c=te.atEnd(e.doc).to;if(i||!(o===a&&l===c)||!js(n.doc))return;const h=n.tr,f=kc({state:n,transaction:h}),{commands:p}=new vc({editor:this.editor,state:f});if(p.clearNodes(),!!h.steps.length)return h}})]}}),Cx=ce.create({name:"paste",addProseMirrorPlugins(){return[new me({key:new ge("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Ex=ce.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new me({key:new ge("tabindex"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!=null?t:"0"}}}})]}}),Ax=ce.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=Is(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new me({key:new ge("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),gT=class Mi{constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new Mi(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new Mi(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new Mi(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,o=n.isInline,l=this.pos+r+(i?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const a=this.resolvedPos.doc.resolve(l);if(!s&&!o&&a.depth<=this.depth)return;const c=new Mi(a,this.editor,s,s||o?n:null);s&&(c.actualDepth=this.depth+1),e.push(c)}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){const i=s.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const a=o[l];if(i[a]!==n[a])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const i=Object.keys(n);return this.children.forEach(o=>{r&&s.length>0||(o.node.type.name===e&&i.every(a=>n[a]===o.node.attrs[a])&&s.push(o),!(r&&s.length>0)&&(s=s.concat(o.querySelectorAll(e,n,r))))}),s}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},yT=`.ProseMirror {
19
21
  position: relative;
20
22
  }
21
23
 
@@ -85,78 +87,94 @@ img.ProseMirror-separator {
85
87
 
86
88
  .ProseMirror-focused .ProseMirror-gapcursor {
87
89
  display: block;
88
- }`;function eE(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}var tE=class extends zC{constructor(e={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:s})=>{throw s},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:s,slice:i,moved:o})=>this.options.onDrop(s,i,o)),this.on("paste",({event:s,slice:i})=>this.options.onPaste(s,i)),this.on("delete",this.options.onDelete);const n=this.createDoc(),r=Ly(n,this.options.autofocus);this.editorState=ts.create({doc:n,schema:this.schema,selection:r||void 0}),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(e),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn("Failed to remove CSS element:",e)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=eE(QC,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,n=!0){this.setOptions({editable:e}),n&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,n)=>{if(this.editorView)return this.editorView[n];if(n==="state")return this.editorState;if(n in e)return Reflect.get(e,n);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${n}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,n){const r=zy(n)?n(e,[...this.state.plugins]):[...this.state.plugins,e],s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}unregisterPlugin(e){if(this.isDestroyed)return;const n=this.state.plugins;let r=n;if([].concat(e).forEach(i=>{const o=typeof i=="string"?`${i}$`:i.key;r=r.filter(l=>!l.key.startsWith(o))}),n.length===r.length)return;const s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}createExtensionManager(){var e,n;const s=[...this.options.enableCoreExtensions?[nb,Zy.configure({blockSeparator:(n=(e=this.options.coreExtensionOptions)==null?void 0:e.clipboardTextSerializer)==null?void 0:n.blockSeparator}),Qy,sb,ib,lb,tb,ob,eb].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i?.type));this.extensionManager=new da(s,this)}createCommandManager(){this.commandManager=new oa({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=rd(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(n){if(!(n instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(n.message))throw n;this.emit("contentError",{editor:this,error:n,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(r=>r.name!=="collaboration"),this.createExtensionManager()}}),e=rd(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){var n;this.editorView=new _y(e,{...this.options.editorProps,attributes:{role:"textbox",...(n=this.options.editorProps)==null?void 0:n.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const r=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(r),this.prependClass(),this.injectCSS();const s=this.view.dom;s.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const n=this.capturedTransaction;return this.capturedTransaction=null,n}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(d=>{var u;return(u=this.capturedTransaction)==null?void 0:u.step(d)});return}const{state:n,transactions:r}=this.state.applyTransaction(e),s=!this.state.selection.eq(n.selection),i=r.includes(e),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:n}),!i)return;this.view.updateState(n),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:r.slice(1)}),s&&this.emit("selectionUpdate",{editor:this,transaction:e});const l=r.findLast(d=>d.getMeta("focus")||d.getMeta("blur")),a=l?.getMeta("focus"),c=l?.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:l}),c&&this.emit("blur",{editor:this,event:c.event,transaction:l}),!(e.getMeta("preventUpdate")||!r.some(d=>d.docChanged)||o.doc.eq(n.doc))&&this.emit("update",{editor:this,transaction:e,appendedTransactions:r.slice(1)})}getAttributes(e){return qy(this.state,e)}isActive(e,n){const r=typeof e=="string"?e:null,s=typeof e=="string"?n:e;return xC(this.state,r,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Tu(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:n=`
90
+ }`;function Mx(t,e,n){const r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute(`data-tiptap-style${n?`-${n}`:""}`,""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}var bT=class extends iT{constructor(e={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,textDirection:void 0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:s})=>{throw s},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:hx,createMappablePosition:PM},this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:s,slice:i,moved:o})=>this.options.onDrop(s,i,o)),this.on("paste",({event:s,slice:i})=>this.options.onPaste(s,i)),this.on("delete",this.options.onDelete);const n=this.createDoc(),r=X0(n,this.options.autofocus);this.editorState=vs.create({doc:n,schema:this.schema,selection:r||void 0}),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(e),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const e=this.editorView.dom;e?.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn("Failed to remove CSS element:",e)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=Mx(yT,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,n=!0){this.setOptions({editable:e}),n&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,n)=>{if(this.editorView)return this.editorView[n];if(n==="state")return this.editorState;if(n in e)return Reflect.get(e,n);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${n}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,n){const r=rx(n)?n(e,[...this.state.plugins]):[...this.state.plugins,e],s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}unregisterPlugin(e){if(this.isDestroyed)return;const n=this.state.plugins;let r=n;if([].concat(e).forEach(i=>{const o=typeof i=="string"?`${i}$`:i.key;r=r.filter(l=>!l.key.startsWith(o))}),n.length===r.length)return;const s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}createExtensionManager(){var e,n,r,s;const o=[...this.options.enableCoreExtensions?[wx,gx.configure({blockSeparator:(n=(e=this.options.coreExtensionOptions)==null?void 0:e.clipboardTextSerializer)==null?void 0:n.blockSeparator}),yx,vx,Sx,Ex.configure({value:(s=(r=this.options.coreExtensionOptions)==null?void 0:r.tabindex)==null?void 0:s.value}),xx,Cx,bx,Ax.configure({direction:this.options.textDirection})].filter(l=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[l.name]!==!1:!0):[],...this.options.extensions].filter(l=>["extension","node","mark"].includes(l?.type));this.extensionManager=new Ec(o,this)}createCommandManager(){this.commandManager=new vc({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=zd(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(n){if(!(n instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(n.message))throw n;this.emit("contentError",{editor:this,error:n,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(r=>r.name!=="collaboration"),this.createExtensionManager()}}),e=zd(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){const{editorProps:n,enableExtensionDispatchTransaction:r}=this.options,s=n.dispatchTransaction||this.dispatchTransaction.bind(this),i=r?this.extensionManager.dispatchTransaction(s):s,o=n.transformPastedHTML,l=this.extensionManager.transformPastedHTML(o);this.editorView=new J0(e,{...n,attributes:{role:"textbox",...n?.attributes},dispatchTransaction:i,transformPastedHTML:l,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const a=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(a),this.prependClass(),this.injectCSS();const c=this.view.dom;c.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const n=this.capturedTransaction;return this.capturedTransaction=null,n}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(u=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(u)});return}const{state:n,transactions:r}=this.state.applyTransaction(e),s=!this.state.selection.eq(n.selection),i=r.includes(e),o=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:n}),!i)return;this.view.updateState(n),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:r.slice(1)}),s&&this.emit("selectionUpdate",{editor:this,transaction:e});const l=r.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),a=l?.getMeta("focus"),c=l?.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:l}),c&&this.emit("blur",{editor:this,event:c.event,transaction:l}),!(e.getMeta("preventUpdate")||!r.some(u=>u.docChanged)||o.doc.eq(n.doc))&&this.emit("update",{editor:this,transaction:e,appendedTransactions:r.slice(1)})}getAttributes(e){return ax(this.state,e)}isActive(e,n){const r=typeof e=="string"?e:null,s=typeof e=="string"?n:e;return OM(this.state,r,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return hf(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:n=`
89
91
 
90
- `,textSerializers:r={}}=e||{};return fC(this.state.doc,{blockSeparator:n,textSerializers:{...Wy(this.schema),...r}})}get isEmpty(){return Li(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var e,n;return(n=(e=this.editorView)==null?void 0:e.isDestroyed)!=null?n:!0}$node(e,n){var r;return((r=this.$doc)==null?void 0:r.querySelector(e,n))||null}$nodes(e,n){var r;return((r=this.$doc)==null?void 0:r.querySelectorAll(e,n))||null}$pos(e){const n=this.state.doc.resolve(e);return new ZC(n,this)}get $doc(){return this.$pos(0)}};function Lr(t){return new Ii({find:t.find,handler:({state:e,range:n,match:r})=>{const s=we(t.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=n.from+l.indexOf(o),d=c+o.length;if(_u(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(g=>g===t.type&&g!==f.mark.type)).filter(f=>f.to>c).length)return null;d<n.to&&i.delete(d,n.to),c>n.from&&i.delete(n.from+a,c);const h=n.from+a+o.length;i.addMark(n.from+a,h,t.type.create(s||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function ab(t){return new Ii({find:t.find,handler:({state:e,range:n,match:r})=>{const s=we(t.getAttributes,void 0,r)||{},{tr:i}=e,o=n.from;let l=n.to;const a=t.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let d=o+c;d>l?d=l:l=d+r[1].length;const u=r[0][r[0].length-1];i.insertText(u,o+r[0].length-1),i.replaceWith(d,l,a)}else if(r[0]){const c=t.type.isInline?o:o-1;i.insert(c,t.type.create(s)).delete(i.mapping.map(o),i.mapping.map(l))}i.scrollIntoView()},undoable:t.undoable})}function od(t){return new Ii({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),i=we(t.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function Be(t){return new Ii({find:t.find,handler:({state:e,range:n,match:r})=>{let s=t.replace,i=n.from;const o=n.to;if(r[1]){const l=r[0].lastIndexOf(r[1]);s+=r[0].slice(l+r[1].length),i+=l;const a=i-o;a>0&&(s=r[0].slice(l-a,l)+s,i=o)}e.tr.insertText(s,i,o)},undoable:t.undoable})}function ms(t){return new Ii({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const i=we(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),a=o.doc.resolve(n.from).blockRange(),c=a&&iu(a,t.type,i);if(!c)return null;if(o.wrap(a,c),t.keepMarks&&t.editor){const{selection:u,storedMarks:h}=e,{splittableMarks:f}=t.editor.extensionManager,p=h||u.$to.parentOffset&&u.$from.marks();if(p){const g=p.filter(y=>f.includes(y.type.name));o.ensureMarks(g)}}if(t.keepAttributes){const u=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(u,i).run()}const d=o.doc.resolve(n.from-1).nodeBefore;d&&d.type===t.type&&ur(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,d))&&o.join(n.from-1)},undoable:t.undoable})}var nE=t=>"touches"in t,rE=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.handleMouseMove=o=>{if(!this.isResizing||!this.activeHandle)return;const l=o.clientX-this.startX,a=o.clientY-this.startY;this.handleResize(l,a)},this.handleTouchMove=o=>{if(!this.isResizing||!this.activeHandle)return;const l=o.touches[0];if(!l)return;const a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleMouseUp=()=>{if(!this.isResizing)return;const o=this.element.offsetWidth,l=this.element.offsetHeight;this.onCommit(o,l),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=o=>{o.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=o=>{o.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,s,i;this.node=t.node,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(s=t.options)!=null&&s.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(i=t.options)!=null&&i.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles()}get dom(){return this.container}get contentDOM(){return this.contentElement}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",t.style.justifyContent="flex-start",t.style.alignItems="flex-start",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),s=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),s&&(t.style.left="0"),i&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{const e=this.createHandle(t);this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.wrapper.appendChild(e)})}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,nE(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:s}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(r,s,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,s=this.startHeight;const i=t.includes("right"),o=t.includes("left"),l=t.includes("bottom"),a=t.includes("top");return i?r=this.startWidth+e:o&&(r=this.startWidth-e),l?s=this.startHeight+n:a&&(s=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(s=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,s,t):{width:r,height:s}}applyConstraints(t,e,n){var r,s,i,o;if(!n){let c=Math.max(this.minSize.width,t),d=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(c=Math.min(this.maxSize.width,c)),(s=this.maxSize)!=null&&s.height&&(d=Math.min(this.maxSize.height,d)),{width:c,height:d}}let l=t,a=e;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),(i=this.maxSize)!=null&&i.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",s=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:s?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function sE(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof q){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let s=r.depth;for(;s>=0;){const i=r.index(s);if(r.node(s).contentMatchAt(i).matchType(e))return!0;s-=1}return!1}function iE(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var oE={};Cu(oE,{createAtomBlockMarkdownSpec:()=>lE,createBlockMarkdownSpec:()=>aE,createInlineMarkdownSpec:()=>uE,parseAttributes:()=>Ou,parseIndentedBlocks:()=>ld,renderNestedMarkdownContent:()=>Lu,serializeAttributes:()=>Du});function Ou(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const c=s.map(d=>d.trim().slice(1));e.class=c.join(" ")}const i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,c,d])=>{var u;const h=parseInt(((u=d.match(/__QUOTED_(\d+)__/))==null?void 0:u[1])||"0",10),f=n[h];f&&(e[c]=f.slice(1,-1))});const a=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(d=>{d.match(/^[a-zA-Z][\w-]*$/)&&(e[d]=!0)}),e}function Du(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function lE(t){const{nodeName:e,name:n,parseAttributes:r=Ou,serializeAttributes:s=Du,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:l}=t,a=n||e,c=d=>{if(!l)return d;const u={};return l.forEach(h=>{h in d&&(u[h]=d[h])}),u};return{parseMarkdown:(d,u)=>{const h={...i,...d.attributes};return u.createNode(e,h,[])},markdownTokenizer:{name:e,level:"block",start(d){var u;const h=new RegExp(`^:::${a}(?:\\s|$)`,"m"),f=(u=d.match(h))==null?void 0:u.index;return f!==void 0?f:-1},tokenize(d,u,h){const f=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=d.match(f);if(!p)return;const g=p[1]||"",y=r(g);if(!o.find(w=>!(w in y)))return{type:e,raw:p[0],attributes:y}}},renderMarkdown:d=>{const u=c(d.attrs||{}),h=s(u),f=h?` {${h}}`:"";return`:::${a}${f} :::`}}}function aE(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=Ou,serializeAttributes:i=Du,defaultAttributes:o={},content:l="block",allowedAttributes:a}=t,c=n||e,d=u=>{if(!a)return u;const h={};return a.forEach(f=>{f in u&&(h[f]=u[f])}),h};return{parseMarkdown:(u,h)=>{let f;if(r){const g=r(u);f=typeof g=="string"?[{type:"text",text:g}]:g}else l==="block"?f=h.parseChildren(u.tokens||[]):f=h.parseInline(u.tokens||[]);const p={...o,...u.attributes};return h.createNode(e,p,f)},markdownTokenizer:{name:e,level:"block",start(u){var h;const f=new RegExp(`^:::${c}`,"m"),p=(h=u.match(f))==null?void 0:h.index;return p!==void 0?p:-1},tokenize(u,h,f){var p;const g=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),y=u.match(g);if(!y)return;const[b,w=""]=y,A=s(w);let S=1;const M=b.length;let x="";const k=/^:::([\w-]*)(\s.*)?/gm,v=u.slice(M);for(k.lastIndex=0;;){const T=k.exec(v);if(T===null)break;const N=T.index,H=T[1];if(!((p=T[2])!=null&&p.endsWith(":::"))){if(H)S+=1;else if(S-=1,S===0){const V=v.slice(0,N);x=V.trim();const $=u.slice(0,M+N+T[0].length);let I=[];if(x)if(l==="block")for(I=f.blockTokens(V),I.forEach(j=>{j.text&&(!j.tokens||j.tokens.length===0)&&(j.tokens=f.inlineTokens(j.text))});I.length>0;){const j=I[I.length-1];if(j.type==="paragraph"&&(!j.text||j.text.trim()===""))I.pop();else break}else I=f.inlineTokens(x);return{type:e,raw:$,attributes:A,content:x,tokens:I}}}}}},renderMarkdown:(u,h)=>{const f=d(u.attrs||{}),p=i(f),g=p?` {${p}}`:"",y=h.renderChildren(u.content||[],`
92
+ `,textSerializers:r={}}=e||{};return AM(this.state.doc,{blockSeparator:n,textSerializers:{...lx(this.schema),...r}})}get isEmpty(){return js(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}get isDestroyed(){var e,n;return(n=(e=this.editorView)==null?void 0:e.isDestroyed)!=null?n:!0}$node(e,n){var r;return((r=this.$doc)==null?void 0:r.querySelector(e,n))||null}$nodes(e,n){var r;return((r=this.$doc)==null?void 0:r.querySelectorAll(e,n))||null}$pos(e){const n=this.state.doc.resolve(e),r=e>0&&n.nodeAfter&&!n.nodeAfter.isText?n.nodeAfter:null;return new gT(n,this,!1,r)}get $doc(){return this.$pos(0)}};function qr(t){return new Oo({find:t.find,handler:({state:e,range:n,match:r})=>{const s=we(t.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,o=r[r.length-1],l=r[0];if(o){const a=l.search(/\S/),c=n.from+l.indexOf(o),u=c+o.length;if(ff(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(m=>m===t.type&&m!==f.mark.type)).filter(f=>f.to>c).length)return null;u<n.to&&i.delete(u,n.to),c>n.from&&i.delete(n.from+a,c);const h=n.from+a+o.length;i.addMark(n.from+a,h,t.type.create(s||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function Tx(t){return new Oo({find:t.find,handler:({state:e,range:n,match:r})=>{const s=we(t.getAttributes,void 0,r)||{},{tr:i}=e,o=n.from;let l=n.to;const a=t.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=o+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];i.insertText(d,o+r[0].length-1),i.replaceWith(u,l,a)}else if(r[0]){const c=t.type.isInline?o:o-1;i.insert(c,t.type.create(s)).delete(i.mapping.map(o),i.mapping.map(l))}i.scrollIntoView()},undoable:t.undoable})}function Ud(t){return new Oo({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),i=we(t.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)},undoable:t.undoable})}function Be(t){return new Oo({find:t.find,handler:({state:e,range:n,match:r})=>{let s=t.replace,i=n.from;const o=n.to;if(r[1]){const l=r[0].lastIndexOf(r[1]);s+=r[0].slice(l+r[1].length),i+=l;const a=i-o;a>0&&(s=r[0].slice(l-a,l)+s,i=o)}e.tr.insertText(s,i,o)},undoable:t.undoable})}function $s(t){return new Oo({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const i=we(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),a=o.doc.resolve(n.from).blockRange(),c=a&&Uh(a,t.type,i);if(!c)return null;if(o.wrap(a,c),t.keepMarks&&t.editor){const{selection:d,storedMarks:h}=e,{splittableMarks:f}=t.editor.extensionManager,p=h||d.$to.parentOffset&&d.$from.marks();if(p){const m=p.filter(y=>f.includes(y.type.name));o.ensureMarks(m)}}if(t.keepAttributes){const d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,i).run()}const u=o.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&kr(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&o.join(n.from-1)},undoable:t.undoable})}var xT=t=>"touches"in t,wT=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=l=>{if(!this.isResizing||!this.activeHandle)return;const a=l.clientX-this.startX,c=l.clientY-this.startY;this.handleResize(a,c)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;const a=l.touches[0];if(!a)return;const c=a.clientX-this.startX,u=a.clientY-this.startY;this.handleResize(c,u)},this.handleMouseUp=()=>{if(!this.isResizing)return;const l=this.element.offsetWidth,a=this.element.offsetHeight;this.onCommit(l,a),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,s,i,o;this.node=t.node,this.editor=t.editor,this.element=t.element,this.element.draggable=!1,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t?.options)!=null&&r.directions&&(this.directions=t.options.directions),(s=t.options)!=null&&s.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(i=t.options)!=null&&i.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(o=t.options)!=null&&o.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!=null?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display=this.node.type.isInline?"inline-flex":"flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),s=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),s&&(t.style.left="0"),i&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,xT(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:s}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(r,s,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,s=this.startHeight;const i=t.includes("right"),o=t.includes("left"),l=t.includes("bottom"),a=t.includes("top");return i?r=this.startWidth+e:o&&(r=this.startWidth-e),l?s=this.startHeight+n:a&&(s=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(s=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,s,t):{width:r,height:s}}applyConstraints(t,e,n){var r,s,i,o;if(!n){let c=Math.max(this.minSize.width,t),u=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(c=Math.min(this.maxSize.width,c)),(s=this.maxSize)!=null&&s.height&&(u=Math.min(this.maxSize.height,u)),{width:c,height:u}}let l=t,a=e;return l<this.minSize.width&&(l=this.minSize.width,a=l/this.aspectRatio),a<this.minSize.height&&(a=this.minSize.height,l=a*this.aspectRatio),(i=this.maxSize)!=null&&i.width&&l>this.maxSize.width&&(l=this.maxSize.width,a=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&a>this.maxSize.height&&(a=this.maxSize.height,l=a*this.aspectRatio),{width:l,height:a}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",s=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:s?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function kT(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof Y){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let s=r.depth;for(;s>=0;){const i=r.index(s);if(r.node(s).contentMatchAt(i).matchType(e))return!0;s-=1}return!1}function vT(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function Qs(t,e){const n=t.getAttribute("style");if(!n)return null;const r=n.split(";").map(i=>i.trim()).filter(Boolean),s=e.toLowerCase();for(let i=r.length-1;i>=0;i-=1){const o=r[i],l=o.indexOf(":");if(l===-1)continue;if(o.slice(0,l).trim().toLowerCase()===s)return o.slice(l+1).trim()}return null}function ST(){return typeof navigator<"u"?/Firefox/.test(navigator.userAgent):!1}var CT={};lf(CT,{createAtomBlockMarkdownSpec:()=>ET,createBlockMarkdownSpec:()=>AT,createInlineMarkdownSpec:()=>NT,parseAttributes:()=>gf,parseIndentedBlocks:()=>Vd,renderNestedMarkdownContent:()=>bf,serializeAttributes:()=>yf});function gf(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,c=>(n.push(c),`__QUOTED_${n.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const c=s.map(u=>u.trim().slice(1));e.class=c.join(" ")}const i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,c,u])=>{var d;const h=parseInt(((d=u.match(/__QUOTED_(\d+)__/))==null?void 0:d[1])||"0",10),f=n[h];f&&(e[c]=f.slice(1,-1))});const a=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return a&&a.split(/\s+/).filter(Boolean).forEach(u=>{u.match(/^[a-zA-Z][\w-]*$/)&&(e[u]=!0)}),e}function yf(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function ET(t){const{nodeName:e,name:n,parseAttributes:r=gf,serializeAttributes:s=yf,defaultAttributes:i={},requiredAttributes:o=[],allowedAttributes:l}=t,a=n||e,c=u=>{if(!l)return u;const d={};return l.forEach(h=>{h in u&&(d[h]=u[h])}),d};return{parseMarkdown:(u,d)=>{const h={...i,...u.attributes};return d.createNode(e,h,[])},markdownTokenizer:{name:e,level:"block",start(u){var d;const h=new RegExp(`^:::${a}(?:\\s|$)`,"m"),f=(d=u.match(h))==null?void 0:d.index;return f!==void 0?f:-1},tokenize(u,d,h){const f=new RegExp(`^:::${a}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),p=u.match(f);if(!p)return;const m=p[1]||"",y=r(m);if(!o.find(x=>!(x in y)))return{type:e,raw:p[0],attributes:y}}},renderMarkdown:u=>{const d=c(u.attrs||{}),h=s(d),f=h?` {${h}}`:"";return`:::${a}${f} :::`}}}function AT(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=gf,serializeAttributes:i=yf,defaultAttributes:o={},content:l="block",allowedAttributes:a}=t,c=n||e,u=d=>{if(!a)return d;const h={};return a.forEach(f=>{f in d&&(h[f]=d[f])}),h};return{parseMarkdown:(d,h)=>{let f;if(r){const m=r(d);f=typeof m=="string"?[{type:"text",text:m}]:m}else l==="block"?f=h.parseChildren(d.tokens||[]):f=h.parseInline(d.tokens||[]);const p={...o,...d.attributes};return h.createNode(e,p,f)},markdownTokenizer:{name:e,level:"block",start(d){var h;const f=new RegExp(`^:::${c}`,"m"),p=(h=d.match(f))==null?void 0:h.index;return p!==void 0?p:-1},tokenize(d,h,f){var p;const m=new RegExp(`^:::${c}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),y=d.match(m);if(!y)return;const[b,x=""]=y,w=s(x);let k=1;const T=b.length;let S="";const v=/^:::([\w-]*)(\s.*)?/gm,A=d.slice(T);for(v.lastIndex=0;;){const C=v.exec(A);if(C===null)break;const N=C.index,D=C[1];if(!((p=C[2])!=null&&p.endsWith(":::"))){if(D)k+=1;else if(k-=1,k===0){const z=A.slice(0,N);S=z.trim();const L=d.slice(0,T+N+C[0].length);let _=[];if(S)if(l==="block")for(_=f.blockTokens(z),_.forEach(V=>{V.text&&(!V.tokens||V.tokens.length===0)&&(V.tokens=f.inlineTokens(V.text))});_.length>0;){const V=_[_.length-1];if(V.type==="paragraph"&&(!V.text||V.text.trim()===""))_.pop();else break}else _=f.inlineTokens(S);return{type:e,raw:L,attributes:w,content:S,tokens:_}}}}}},renderMarkdown:(d,h)=>{const f=u(d.attrs||{}),p=i(f),m=p?` {${p}}`:"",y=h.renderChildren(d.content||[],`
91
93
 
92
- `);return`:::${c}${g}
94
+ `);return`:::${c}${m}
93
95
 
94
96
  ${y}
95
97
 
96
- :::`}}}function cE(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,i,o]=r;e[s]=i||o,r=n.exec(t)}return e}function dE(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function uE(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=cE,serializeAttributes:i=dE,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:a}=t,c=n||e,d=h=>{if(!a)return h;const f={};return a.forEach(p=>{p in h&&(f[p]=h[p])}),f},u=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(h,f)=>{const p={...o,...h.attributes};if(l)return f.createNode(e,p);const g=r?r(h):h.content||"";return g?f.createNode(e,p,[f.createTextNode(g)]):f.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(h){const f=l?new RegExp(`\\[${u}\\s*[^\\]]*\\]`):new RegExp(`\\[${u}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${u}\\]`),p=h.match(f),g=p?.index;return g!==void 0?g:-1},tokenize(h,f,p){const g=l?new RegExp(`^\\[${u}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${u}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${u}\\]`),y=h.match(g);if(!y)return;let b="",w="";if(l){const[,S]=y;w=S}else{const[,S,M]=y;w=S,b=M||""}const A=s(w.trim());return{type:e,raw:y[0],content:b.trim(),attributes:A}}},renderMarkdown:h=>{let f="";r?f=r(h):h.content&&h.content.length>0&&(f=h.content.filter(b=>b.type==="text").map(b=>b.text).join(""));const p=d(h.attrs||{}),g=i(p),y=g?` ${g}`:"";return l?`[${c}${y}]`:`[${c}${y}]${f}[/${c}]`}}}function ld(t,e,n){var r,s,i,o;const l=t.split(`
97
- `),a=[];let c="",d=0;const u=e.baseIndentSize||2;for(;d<l.length;){const h=l[d],f=h.match(e.itemPattern);if(!f){if(a.length>0)break;if(h.trim()===""){d+=1;continue}else return}const p=e.extractItemData(f),{indentLevel:g,mainContent:y}=p;c=`${c}${h}
98
- `;const b=[y];for(d+=1;d<l.length;){const M=l[d];if(M.trim()===""){const k=l.slice(d+1).findIndex(N=>N.trim()!=="");if(k===-1)break;if((((s=(r=l[d+1+k].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>g){b.push(M),c=`${c}${M}
99
- `,d+=1;continue}else break}if((((o=(i=M.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:o.length)||0)>g)b.push(M),c=`${c}${M}
100
- `,d+=1;else break}let w;const A=b.slice(1);if(A.length>0){const M=A.map(x=>x.slice(g+u)).join(`
101
- `);M.trim()&&(e.customNestedParser?w=e.customNestedParser(M):w=n.blockTokens(M))}const S=e.createToken(p,w);a.push(S)}if(a.length!==0)return{items:a,raw:c.trim()}}function Lu(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[i,...o]=t.content,l=e.renderChildren([i]),a=[`${s}${l}`];return o&&o.length>0&&o.forEach(c=>{const d=e.renderChildren([c]);if(d){const u=d.split(`
102
- `).map(h=>h?e.indent(h):"").join(`
103
- `);a.push(u)}}),a.join(`
104
- `)}function hE(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,o=t;s.descendants((l,a)=>{const c=i.mapping.map(a),d=i.mapping.map(a)+l.nodeSize;let u=null;if(l.marks.forEach(f=>{if(f!==o)return!1;u=f}),!u)return;let h=!1;if(Object.keys(n).forEach(f=>{n[f]!==u.attrs[f]&&(h=!0)}),h){const f=t.type.create({...t.attrs,...n});i.removeMark(c,d,t.type),i.addMark(c,d,f)}}),i.docChanged&&e.view.dispatch(i)}var Oe=class cb extends Ru{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new cb(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},fE=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,s,i,o,l;const{view:a}=this.editor,c=t.target,d=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(c)||!d)return;let u=0,h=0;if(this.dom!==d){const w=this.dom.getBoundingClientRect(),A=d.getBoundingClientRect(),S=(s=t.offsetX)!=null?s:(r=t.nativeEvent)==null?void 0:r.offsetX,M=(o=t.offsetY)!=null?o:(i=t.nativeEvent)==null?void 0:i.offsetY;u=A.x-w.x+S,h=A.y-w.y+M}const f=this.dom.cloneNode(!0);try{const w=this.dom.getBoundingClientRect();f.style.width=`${Math.round(w.width)}px`,f.style.height=`${Math.round(w.height)}px`,f.style.boxSizing="border-box",f.style.pointerEvents="none"}catch{}let p=null;try{p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(f),document.body.appendChild(p),(l=t.dataTransfer)==null||l.setDragImage(f,u,h)}finally{p&&setTimeout(()=>{try{p?.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const y=q.create(a.state.doc,g),b=a.state.tr.setSelection(y);a.dispatch(b)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const s=t.type.startsWith("drag"),i=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!i&&!s)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,d=q.isSelectable(this.node),u=t.type==="copy",h=t.type==="paste",f=t.type==="cut",p=t.type==="mousedown";if(!c&&d&&s&&t.target===this.dom&&t.preventDefault(),c&&s&&!a&&t.target===this.dom)return t.preventDefault(),!1;if(c&&l&&!a&&p){const g=n.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(a||i||u||h||f||p&&d)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(la()||Iy())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function sr(t){return new qC({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const i=we(t.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=n.to;if(l){const d=a.search(/\S/),u=n.from+a.indexOf(l),h=u+l.length;if(_u(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(y=>y===t.type&&y!==p.mark.type)).filter(p=>p.to>u).length)return null;h<n.to&&o.delete(h,n.to),u>n.from&&o.delete(n.from+d,u),c=n.from+d+l.length,o.addMark(n.from+d,c,t.type.create(i||{})),o.removeStoredMark(t.type)}}})}var uc,cp;function pE(){return cp||(cp=1,uc=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,s,i;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(s=r;s--!==0;)if(!t(e[s],n[s]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(s of e.entries())if(!n.has(s[0]))return!1;for(s of e.entries())if(!t(s[1],n.get(s[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(s of e.entries())if(!n.has(s[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(s=r;s--!==0;)if(e[s]!==n[s])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(n).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[s]))return!1;for(s=r;s--!==0;){var o=i[s];if(!(o==="_owner"&&e.$$typeof)&&!t(e[o],n[o]))return!1}return!0}return e!==e&&n!==n}),uc}var mE=pE();const gE=sg(mE);var mo={exports:{}},hc={};var dp;function yE(){if(dp)return hc;dp=1;var t=C,e=nu();function n(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,i=t.useRef,o=t.useEffect,l=t.useMemo,a=t.useDebugValue;return hc.useSyncExternalStoreWithSelector=function(c,d,u,h,f){var p=i(null);if(p.current===null){var g={hasValue:!1,value:null};p.current=g}else g=p.current;p=l(function(){function b(x){if(!w){if(w=!0,A=x,x=h(x),f!==void 0&&g.hasValue){var k=g.value;if(f(k,x))return S=k}return S=x}if(k=S,r(A,x))return k;var v=h(x);return f!==void 0&&f(k,v)?(A=x,k):(A=x,S=v)}var w=!1,A,S,M=u===void 0?null:u;return[function(){return b(d())},M===null?void 0:function(){return b(M())}]},[d,u,h,f]);var y=s(c,p[0],p[1]);return o(function(){g.hasValue=!0,g.value=y},[y]),a(y),y},hc}var fc={};var up;function bE(){return up||(up=1,process.env.NODE_ENV!=="production"&&(function(){function t(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var e=C,n=nu(),r=typeof Object.is=="function"?Object.is:t,s=n.useSyncExternalStore,i=e.useRef,o=e.useEffect,l=e.useMemo,a=e.useDebugValue;fc.useSyncExternalStoreWithSelector=function(c,d,u,h,f){var p=i(null);if(p.current===null){var g={hasValue:!1,value:null};p.current=g}else g=p.current;p=l(function(){function b(x){if(!w){if(w=!0,A=x,x=h(x),f!==void 0&&g.hasValue){var k=g.value;if(f(k,x))return S=k}return S=x}if(k=S,r(A,x))return k;var v=h(x);return f!==void 0&&f(k,v)?(A=x,k):(A=x,S=v)}var w=!1,A,S,M=u===void 0?null:u;return[function(){return b(d())},M===null?void 0:function(){return b(M())}]},[d,u,h,f]);var y=s(c,p[0],p[1]);return o(function(){g.hasValue=!0,g.value=y},[y]),a(y),y},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),fc}var hp;function xE(){return hp||(hp=1,process.env.NODE_ENV==="production"?mo.exports=yE():mo.exports=bE()),mo.exports}var wE=xE(),kE=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},vE=({contentComponent:t})=>{const e=ig.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return m.jsx(m.Fragment,{children:Object.values(e)})};function SE(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:tu.createPortal(r.reactElement,r.element,n)},t.forEach(s=>s())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(s=>s())}}}var CE=class extends C.Component{constructor(t){var e;super(t),this.editorContentRef=C.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(t.view.dom),t.setOptions({element:e}),t.contentComponent=SE(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(e){this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.firstChild))return;const n=document.createElement("div");n.append(e.view.dom),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return m.jsxs(m.Fragment,{children:[m.jsx("div",{ref:kE(e,this.editorContentRef),...n}),t?.contentComponent&&m.jsx(vE,{contentComponent:t.contentComponent})]})}},EE=C.forwardRef((t,e)=>{const n=C.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return C.createElement(CE,{key:n,innerRef:e,...t})}),db=C.memo(EE),ME=typeof window<"u"?C.useLayoutEffect:C.useEffect,AE=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function TE(t){var e;const[n]=C.useState(()=>new AE(t.editor)),r=wE.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:gE);return ME(()=>n.watch(t.editor),[t.editor,n]),C.useDebugValue(r),r}var fp=process.env.NODE_ENV!=="production",ad=typeof window>"u",NE=ad||!!(typeof window<"u"&&window.next),_E=class ub{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0){if(ad||NE){if(fp)throw new Error("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches.");return null}return this.createEditor()}if(this.options.current.immediatelyRender&&ad&&fp)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)==null?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)==null?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)==null?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)==null?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)==null?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)==null?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)==null?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)==null?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)==null?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)==null?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)==null?void 0:i.call(s,...r)},onDelete:(...r)=>{var s,i;return(i=(s=this.options.current).onDelete)==null?void 0:i.call(s,...r)}};return new tE(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((s,i)=>{var o;return s===((o=n.extensions)==null?void 0:o[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?ub.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function hb(t={},e=[]){const n=C.useRef(t);n.current=t;const[r]=C.useState(()=>new _E(n)),s=ig.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return C.useDebugValue(s),C.useEffect(r.onRender(e)),TE({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var RE=C.createContext({editor:null});RE.Consumer;var fb=C.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),OE=()=>C.useContext(fb),Iu=C.forwardRef((t,e)=>{const{onDragStart:n}=OE(),r=t.as||"div";return m.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function pp(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function mp(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function DE(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function LE(t){if(pp(t)||mp(t))return!0;if(DE(t)){const e=t.type;if(e)return pp(e)||mp(e)}return!1}function IE(){try{if(C.version)return parseInt(C.version.split(".")[0],10)>=19}catch{}return!1}var pb=class{constructor(t,{editor:e,props:n={},as:r="div",className:s=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?tu.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var t;const e=this.component,n=this.props,r=this.editor,s=IE(),i=LE(e),o={...n};o.ref&&!(s||i)&&delete o.ref,!o.ref&&(s||i)&&(o.ref=l=>{this.ref=l}),this.reactElement=m.jsx(e,{...o}),(t=r?.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){this.props={...this.props,...t},this.render()}destroy(){var t;const e=this.editor;(t=e?.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};C.createContext({markViewContentRef:()=>{}});var jE=class extends fE{constructor(t,e,n){if(super(t,e,n),!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}mount(){const t={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:C.createRef()};if(!this.component.displayName){const a=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=a(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement&&(a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper"),a.appendChild(this.contentDOMElement))}},s=this.component,i=C.memo(a=>m.jsx(fb.Provider,{value:r,children:C.createElement(s,a)}));i.displayName="ReactNodeView";let o=this.node.isInline?"span":"div";this.options.as&&(o=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new pb(i,{editor:this.editor,props:t,as:o,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:t,to:e}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(t<=n&&e>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(t,e,n){const r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const s=this.node,i=this.decorations,o=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.options.update({oldNode:s,oldDecorations:i,newNode:t,newDecorations:e,oldInnerDecorations:o,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n})})}return t===this.node&&this.decorations===e&&this.innerDecorations===n||(this.node=t,this.decorations=e,this.innerDecorations=n,r({node:t,decorations:e,innerDecorations:n})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=mi(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function ju(t,e){return n=>n.editor.contentComponent?new jE(t,n,e):{}}const gs=Math.min,Nt=Math.max,sl=Math.round,go=Math.floor,ln=t=>({x:t,y:t}),PE={left:"right",right:"left",bottom:"top",top:"bottom"},BE={start:"end",end:"start"};function gp(t,e,n){return Nt(t,gs(e,n))}function ji(t,e){return typeof t=="function"?t(e):t}function ir(t){return t.split("-")[0]}function Pi(t){return t.split("-")[1]}function mb(t){return t==="x"?"y":"x"}function gb(t){return t==="y"?"height":"width"}const $E=new Set(["top","bottom"]);function En(t){return $E.has(ir(t))?"y":"x"}function yb(t){return mb(En(t))}function HE(t,e,n){n===void 0&&(n=!1);const r=Pi(t),s=yb(t),i=gb(s);let o=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=il(o)),[o,il(o)]}function zE(t){const e=il(t);return[cd(t),e,cd(e)]}function cd(t){return t.replace(/start|end/g,e=>BE[e])}const yp=["left","right"],bp=["right","left"],FE=["top","bottom"],UE=["bottom","top"];function VE(t,e,n){switch(t){case"top":case"bottom":return n?e?bp:yp:e?yp:bp;case"left":case"right":return e?FE:UE;default:return[]}}function WE(t,e,n,r){const s=Pi(t);let i=VE(ir(t),n==="start",r);return s&&(i=i.map(o=>o+"-"+s),e&&(i=i.concat(i.map(cd)))),i}function il(t){return t.replace(/left|right|bottom|top/g,e=>PE[e])}function qE(t){return{top:0,right:0,bottom:0,left:0,...t}}function KE(t){return typeof t!="number"?qE(t):{top:t,right:t,bottom:t,left:t}}function ol(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function xp(t,e,n){let{reference:r,floating:s}=t;const i=En(e),o=yb(e),l=gb(o),a=ir(e),c=i==="y",d=r.x+r.width/2-s.width/2,u=r.y+r.height/2-s.height/2,h=r[l]/2-s[l]/2;let f;switch(a){case"top":f={x:d,y:r.y-s.height};break;case"bottom":f={x:d,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:u};break;case"left":f={x:r.x-s.width,y:u};break;default:f={x:r.x,y:r.y}}switch(Pi(e)){case"start":f[o]-=h*(n&&c?-1:1);break;case"end":f[o]+=h*(n&&c?-1:1);break}return f}const GE=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:o}=n,l=i.filter(Boolean),a=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:s}),{x:d,y:u}=xp(c,r,a),h=r,f={},p=0;for(let g=0;g<l.length;g++){const{name:y,fn:b}=l[g],{x:w,y:A,data:S,reset:M}=await b({x:d,y:u,initialPlacement:r,placement:h,strategy:s,middlewareData:f,rects:c,platform:o,elements:{reference:t,floating:e}});d=w??d,u=A??u,f={...f,[y]:{...f[y],...S}},M&&p<=50&&(p++,typeof M=="object"&&(M.placement&&(h=M.placement),M.rects&&(c=M.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:s}):M.rects),{x:d,y:u}=xp(c,h,a)),g=-1)}return{x:d,y:u,placement:h,strategy:s,middlewareData:f}};async function Pu(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:i,rects:o,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:d="viewport",elementContext:u="floating",altBoundary:h=!1,padding:f=0}=ji(e,t),p=KE(f),y=l[h?u==="floating"?"reference":"floating":u],b=ol(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(y)))==null||n?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:c,rootBoundary:d,strategy:a})),w=u==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,A=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),S=await(i.isElement==null?void 0:i.isElement(A))?await(i.getScale==null?void 0:i.getScale(A))||{x:1,y:1}:{x:1,y:1},M=ol(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:w,offsetParent:A,strategy:a}):w);return{top:(b.top-M.top+p.top)/S.y,bottom:(M.bottom-b.bottom+p.bottom)/S.y,left:(b.left-M.left+p.left)/S.x,right:(M.right-b.right+p.right)/S.x}}const JE=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:i,rects:o,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:d=!0,crossAxis:u=!0,fallbackPlacements:h,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...y}=ji(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const b=ir(s),w=En(l),A=ir(l)===l,S=await(a.isRTL==null?void 0:a.isRTL(c.floating)),M=h||(A||!g?[il(l)]:zE(l)),x=p!=="none";!h&&x&&M.push(...WE(l,g,p,S));const k=[l,...M],v=await Pu(e,y),T=[];let N=((r=i.flip)==null?void 0:r.overflows)||[];if(d&&T.push(v[b]),u){const I=HE(s,o,S);T.push(v[I[0]],v[I[1]])}if(N=[...N,{placement:s,overflows:T}],!T.every(I=>I<=0)){var H,V;const I=(((H=i.flip)==null?void 0:H.index)||0)+1,j=k[I];if(j&&(!(u==="alignment"?w!==En(j):!1)||N.every(F=>En(F.placement)===w?F.overflows[0]>0:!0)))return{data:{index:I,overflows:N},reset:{placement:j}};let Q=(V=N.filter(ie=>ie.overflows[0]<=0).sort((ie,F)=>ie.overflows[1]-F.overflows[1])[0])==null?void 0:V.placement;if(!Q)switch(f){case"bestFit":{var $;const ie=($=N.filter(F=>{if(x){const ue=En(F.placement);return ue===w||ue==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(ue=>ue>0).reduce((ue,xe)=>ue+xe,0)]).sort((F,ue)=>F[1]-ue[1])[0])==null?void 0:$[0];ie&&(Q=ie);break}case"initialPlacement":Q=l;break}if(s!==Q)return{reset:{placement:Q}}}return{}}}},YE=new Set(["left","top"]);async function XE(t,e){const{placement:n,platform:r,elements:s}=t,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=ir(n),l=Pi(n),a=En(n)==="y",c=YE.has(o)?-1:1,d=i&&a?-1:1,u=ji(e,t);let{mainAxis:h,crossAxis:f,alignmentAxis:p}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return l&&typeof p=="number"&&(f=l==="end"?p*-1:p),a?{x:f*d,y:h*c}:{x:h*c,y:f*d}}const ZE=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:i,placement:o,middlewareData:l}=e,a=await XE(e,t);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+a.x,y:i+a.y,data:{...a,placement:o}}}}},QE=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s}=e,{mainAxis:i=!0,crossAxis:o=!1,limiter:l={fn:y=>{let{x:b,y:w}=y;return{x:b,y:w}}},...a}=ji(t,e),c={x:n,y:r},d=await Pu(e,a),u=En(ir(s)),h=mb(u);let f=c[h],p=c[u];if(i){const y=h==="y"?"top":"left",b=h==="y"?"bottom":"right",w=f+d[y],A=f-d[b];f=gp(w,f,A)}if(o){const y=u==="y"?"top":"left",b=u==="y"?"bottom":"right",w=p+d[y],A=p-d[b];p=gp(w,p,A)}const g=l.fn({...e,[h]:f,[u]:p});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[h]:i,[u]:o}}}}}},eM=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:s,rects:i,platform:o,elements:l}=e,{apply:a=()=>{},...c}=ji(t,e),d=await Pu(e,c),u=ir(s),h=Pi(s),f=En(s)==="y",{width:p,height:g}=i.floating;let y,b;u==="top"||u==="bottom"?(y=u,b=h===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(b=u,y=h==="end"?"top":"bottom");const w=g-d.top-d.bottom,A=p-d.left-d.right,S=gs(g-d[y],w),M=gs(p-d[b],A),x=!e.middlewareData.shift;let k=S,v=M;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(v=A),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(k=w),x&&!h){const N=Nt(d.left,0),H=Nt(d.right,0),V=Nt(d.top,0),$=Nt(d.bottom,0);f?v=p-2*(N!==0||H!==0?N+H:Nt(d.left,d.right)):k=g-2*(V!==0||$!==0?V+$:Nt(d.top,d.bottom))}await a({...e,availableWidth:v,availableHeight:k});const T=await o.getDimensions(l.floating);return p!==T.width||g!==T.height?{reset:{rects:!0}}:{}}}};function ua(){return typeof window<"u"}function Es(t){return bb(t)?(t.nodeName||"").toLowerCase():"#document"}function Ot(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function hn(t){var e;return(e=(bb(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function bb(t){return ua()?t instanceof Node||t instanceof Ot(t).Node:!1}function ut(t){return ua()?t instanceof Element||t instanceof Ot(t).Element:!1}function un(t){return ua()?t instanceof HTMLElement||t instanceof Ot(t).HTMLElement:!1}function wp(t){return!ua()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Ot(t).ShadowRoot}const tM=new Set(["inline","contents"]);function Bi(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=Jt(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!tM.has(s)}const nM=new Set(["table","td","th"]);function rM(t){return nM.has(Es(t))}const sM=[":popover-open",":modal"];function ha(t){return sM.some(e=>{try{return t.matches(e)}catch{return!1}})}const iM=["transform","translate","scale","rotate","perspective"],oM=["transform","translate","scale","rotate","perspective","filter"],lM=["paint","layout","strict","content"];function Bu(t){const e=$u(),n=ut(t)?Jt(t):t;return iM.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||oM.some(r=>(n.willChange||"").includes(r))||lM.some(r=>(n.contain||"").includes(r))}function aM(t){let e=or(t);for(;un(e)&&!ys(e);){if(Bu(e))return e;if(ha(e))return null;e=or(e)}return null}function $u(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const cM=new Set(["html","body","#document"]);function ys(t){return cM.has(Es(t))}function Jt(t){return Ot(t).getComputedStyle(t)}function fa(t){return ut(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function or(t){if(Es(t)==="html")return t;const e=t.assignedSlot||t.parentNode||wp(t)&&t.host||hn(t);return wp(e)?e.host:e}function xb(t){const e=or(t);return ys(e)?t.ownerDocument?t.ownerDocument.body:t.body:un(e)&&Bi(e)?e:xb(e)}function gi(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const s=xb(t),i=s===((r=t.ownerDocument)==null?void 0:r.body),o=Ot(s);if(i){const l=dd(o);return e.concat(o,o.visualViewport||[],Bi(s)?s:[],l&&n?gi(l):[])}return e.concat(s,gi(s,[],n))}function dd(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function wb(t){const e=Jt(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=un(t),i=s?t.offsetWidth:n,o=s?t.offsetHeight:r,l=sl(n)!==i||sl(r)!==o;return l&&(n=i,r=o),{width:n,height:r,$:l}}function Hu(t){return ut(t)?t:t.contextElement}function is(t){const e=Hu(t);if(!un(e))return ln(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:i}=wb(e);let o=(i?sl(n.width):n.width)/r,l=(i?sl(n.height):n.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const dM=ln(0);function kb(t){const e=Ot(t);return!$u()||!e.visualViewport?dM:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function uM(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Ot(t)?!1:e}function Ir(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),i=Hu(t);let o=ln(1);e&&(r?ut(r)&&(o=is(r)):o=is(t));const l=uM(i,n,r)?kb(i):ln(0);let a=(s.left+l.x)/o.x,c=(s.top+l.y)/o.y,d=s.width/o.x,u=s.height/o.y;if(i){const h=Ot(i),f=r&&ut(r)?Ot(r):r;let p=h,g=dd(p);for(;g&&r&&f!==p;){const y=is(g),b=g.getBoundingClientRect(),w=Jt(g),A=b.left+(g.clientLeft+parseFloat(w.paddingLeft))*y.x,S=b.top+(g.clientTop+parseFloat(w.paddingTop))*y.y;a*=y.x,c*=y.y,d*=y.x,u*=y.y,a+=A,c+=S,p=Ot(g),g=dd(p)}}return ol({width:d,height:u,x:a,y:c})}function pa(t,e){const n=fa(t).scrollLeft;return e?e.left+n:Ir(hn(t)).left+n}function vb(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-pa(t,n),s=n.top+e.scrollTop;return{x:r,y:s}}function hM(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const i=s==="fixed",o=hn(r),l=e?ha(e.floating):!1;if(r===o||l&&i)return n;let a={scrollLeft:0,scrollTop:0},c=ln(1);const d=ln(0),u=un(r);if((u||!u&&!i)&&((Es(r)!=="body"||Bi(o))&&(a=fa(r)),un(r))){const f=Ir(r);c=is(r),d.x=f.x+r.clientLeft,d.y=f.y+r.clientTop}const h=o&&!u&&!i?vb(o,a):ln(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+d.x+h.x,y:n.y*c.y-a.scrollTop*c.y+d.y+h.y}}function fM(t){return Array.from(t.getClientRects())}function pM(t){const e=hn(t),n=fa(t),r=t.ownerDocument.body,s=Nt(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=Nt(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+pa(t);const l=-n.scrollTop;return Jt(r).direction==="rtl"&&(o+=Nt(e.clientWidth,r.clientWidth)-s),{width:s,height:i,x:o,y:l}}const kp=25;function mM(t,e){const n=Ot(t),r=hn(t),s=n.visualViewport;let i=r.clientWidth,o=r.clientHeight,l=0,a=0;if(s){i=s.width,o=s.height;const d=$u();(!d||d&&e==="fixed")&&(l=s.offsetLeft,a=s.offsetTop)}const c=pa(r);if(c<=0){const d=r.ownerDocument,u=d.body,h=getComputedStyle(u),f=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,p=Math.abs(r.clientWidth-u.clientWidth-f);p<=kp&&(i-=p)}else c<=kp&&(i+=c);return{width:i,height:o,x:l,y:a}}const gM=new Set(["absolute","fixed"]);function yM(t,e){const n=Ir(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,i=un(t)?is(t):ln(1),o=t.clientWidth*i.x,l=t.clientHeight*i.y,a=s*i.x,c=r*i.y;return{width:o,height:l,x:a,y:c}}function vp(t,e,n){let r;if(e==="viewport")r=mM(t,n);else if(e==="document")r=pM(hn(t));else if(ut(e))r=yM(e,n);else{const s=kb(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return ol(r)}function Sb(t,e){const n=or(t);return n===e||!ut(n)||ys(n)?!1:Jt(n).position==="fixed"||Sb(n,e)}function bM(t,e){const n=e.get(t);if(n)return n;let r=gi(t,[],!1).filter(l=>ut(l)&&Es(l)!=="body"),s=null;const i=Jt(t).position==="fixed";let o=i?or(t):t;for(;ut(o)&&!ys(o);){const l=Jt(o),a=Bu(o);!a&&l.position==="fixed"&&(s=null),(i?!a&&!s:!a&&l.position==="static"&&!!s&&gM.has(s.position)||Bi(o)&&!a&&Sb(t,o))?r=r.filter(d=>d!==o):s=l,o=or(o)}return e.set(t,r),r}function xM(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const o=[...n==="clippingAncestors"?ha(e)?[]:bM(e,this._c):[].concat(n),r],l=o[0],a=o.reduce((c,d)=>{const u=vp(e,d,s);return c.top=Nt(u.top,c.top),c.right=gs(u.right,c.right),c.bottom=gs(u.bottom,c.bottom),c.left=Nt(u.left,c.left),c},vp(e,l,s));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function wM(t){const{width:e,height:n}=wb(t);return{width:e,height:n}}function kM(t,e,n){const r=un(e),s=hn(e),i=n==="fixed",o=Ir(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const a=ln(0);function c(){a.x=pa(s)}if(r||!r&&!i)if((Es(e)!=="body"||Bi(s))&&(l=fa(e)),r){const f=Ir(e,!0,i,e);a.x=f.x+e.clientLeft,a.y=f.y+e.clientTop}else s&&c();i&&!r&&s&&c();const d=s&&!r&&!i?vb(s,l):ln(0),u=o.left+l.scrollLeft-a.x-d.x,h=o.top+l.scrollTop-a.y-d.y;return{x:u,y:h,width:o.width,height:o.height}}function pc(t){return Jt(t).position==="static"}function Sp(t,e){if(!un(t)||Jt(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return hn(t)===n&&(n=n.ownerDocument.body),n}function Cb(t,e){const n=Ot(t);if(ha(t))return n;if(!un(t)){let s=or(t);for(;s&&!ys(s);){if(ut(s)&&!pc(s))return s;s=or(s)}return n}let r=Sp(t,e);for(;r&&rM(r)&&pc(r);)r=Sp(r,e);return r&&ys(r)&&pc(r)&&!Bu(r)?n:r||aM(t)||n}const vM=async function(t){const e=this.getOffsetParent||Cb,n=this.getDimensions,r=await n(t.floating);return{reference:kM(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function SM(t){return Jt(t).direction==="rtl"}const CM={convertOffsetParentRelativeRectToViewportRelativeRect:hM,getDocumentElement:hn,getClippingRect:xM,getOffsetParent:Cb,getElementRects:vM,getClientRects:fM,getDimensions:wM,getScale:is,isElement:ut,isRTL:SM};function Eb(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function EM(t,e){let n=null,r;const s=hn(t);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function o(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),i();const c=t.getBoundingClientRect(),{left:d,top:u,width:h,height:f}=c;if(l||e(),!h||!f)return;const p=go(u),g=go(s.clientWidth-(d+h)),y=go(s.clientHeight-(u+f)),b=go(d),A={rootMargin:-p+"px "+-g+"px "+-y+"px "+-b+"px",threshold:Nt(0,gs(1,a))||1};let S=!0;function M(x){const k=x[0].intersectionRatio;if(k!==a){if(!S)return o();k?o(!1,k):r=setTimeout(()=>{o(!1,1e-7)},1e3)}k===1&&!Eb(c,t.getBoundingClientRect())&&o(),S=!1}try{n=new IntersectionObserver(M,{...A,root:s.ownerDocument})}catch{n=new IntersectionObserver(M,A)}n.observe(t)}return o(!0),i}function Ms(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,c=Hu(t),d=s||i?[...c?gi(c):[],...gi(e)]:[];d.forEach(b=>{s&&b.addEventListener("scroll",n,{passive:!0}),i&&b.addEventListener("resize",n)});const u=c&&l?EM(c,n):null;let h=-1,f=null;o&&(f=new ResizeObserver(b=>{let[w]=b;w&&w.target===c&&f&&(f.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var A;(A=f)==null||A.observe(e)})),n()}),c&&!a&&f.observe(c),f.observe(e));let p,g=a?Ir(t):null;a&&y();function y(){const b=Ir(t);g&&!Eb(g,b)&&n(),g=b,p=requestAnimationFrame(y)}return n(),()=>{var b;d.forEach(w=>{s&&w.removeEventListener("scroll",n),i&&w.removeEventListener("resize",n)}),u?.(),(b=f)==null||b.disconnect(),f=null,a&&cancelAnimationFrame(p)}}const zu=ZE,Mb=QE,Ab=JE,Tb=eM,Fu=(t,e,n)=>{const r=new Map,s={platform:CM,...n},i={...s.platform,_c:r};return GE(t,e,{...s,platform:i})};var ll=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},MM=/^\s*>\s$/,Nb=Oe.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return ll("blockquote",{...pe(this.options.HTMLAttributes,t),children:ll("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=[];return t.content.forEach(s=>{const o=e.renderChildren(s).split(`
105
- `).map(l=>`> ${l}`).join(`
106
- `);n.push(o)}),n.flatMap(s=>[s,"> "]).slice(0,-1).join(`
107
- `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[ms({find:MM,type:this.type})]}}),AM=Nb,TM=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,NM=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,_M=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,RM=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,OM=Zt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return ll("strong",{...pe(this.options.HTMLAttributes,t),children:ll("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Lr({find:TM,type:this.type}),Lr({find:_M,type:this.type})]},addPasteRules(){return[sr({find:NM,type:this.type}),sr({find:RM,type:this.type})]}}),DM=/(^|[^`])`([^`]+)`(?!`)$/,LM=/(^|[^`])`([^`]+)`(?!`)/g,IM=Zt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",pe(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Lr({find:DM,type:this.type})]},addPasteRules(){return[sr({find:LM,type:this.type})]}}),mc=4,jM=/^```([a-z]+)?[\s\n]$/,PM=/^~~~([a-z]+)?[\s\n]$/,_b=Oe.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:mc,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",pe(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const s=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${s}`,e.renderChildren(t.content),"```"].join(`
98
+ :::`}}}function MT(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,i,o]=r;e[s]=i||o,r=n.exec(t)}return e}function TT(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function NT(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=MT,serializeAttributes:i=TT,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:a}=t,c=n||e,u=h=>{if(!a)return h;const f={};return a.forEach(p=>{const m=typeof p=="string"?p:p.name,y=typeof p=="string"?void 0:p.skipIfDefault;if(m in h){const b=h[m];if(y!==void 0&&b===y)return;f[m]=b}}),f},d=c.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(h,f)=>{const p={...o,...h.attributes};if(l)return f.createNode(e,p);const m=r?r(h):h.content||"";return m?f.createNode(e,p,[f.createTextNode(m)]):f.createNode(e,p,[])},markdownTokenizer:{name:e,level:"inline",start(h){const f=l?new RegExp(`\\[${d}\\s*[^\\]]*\\]`):new RegExp(`\\[${d}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${d}\\]`),p=h.match(f),m=p?.index;return m!==void 0?m:-1},tokenize(h,f,p){const m=l?new RegExp(`^\\[${d}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${d}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${d}\\]`),y=h.match(m);if(!y)return;let b="",x="";if(l){const[,k]=y;x=k}else{const[,k,T]=y;x=k,b=T||""}const w=s(x.trim());return{type:e,raw:y[0],content:b.trim(),attributes:w}}},renderMarkdown:h=>{let f="";r?f=r(h):h.content&&h.content.length>0&&(f=h.content.filter(b=>b.type==="text").map(b=>b.text).join(""));const p=u(h.attrs||{}),m=i(p),y=m?` ${m}`:"";return l?`[${c}${y}]`:`[${c}${y}]${f}[/${c}]`}}}function Vd(t,e,n){var r,s,i,o;const l=t.split(`
99
+ `),a=[];let c="",u=0;const d=e.baseIndentSize||2;for(;u<l.length;){const h=l[u],f=h.match(e.itemPattern);if(!f){if(a.length>0)break;if(h.trim()===""){u+=1,c=`${c}${h}
100
+ `;continue}else return}const p=e.extractItemData(f),{indentLevel:m,mainContent:y}=p;c=`${c}${h}
101
+ `;const b=[y];for(u+=1;u<l.length;){const T=l[u];if(T.trim()===""){const v=l.slice(u+1).findIndex(N=>N.trim()!=="");if(v===-1)break;if((((s=(r=l[u+1+v].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>m){b.push(T),c=`${c}${T}
102
+ `,u+=1;continue}else break}if((((o=(i=T.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:o.length)||0)>m)b.push(T),c=`${c}${T}
103
+ `,u+=1;else break}let x;const w=b.slice(1);if(w.length>0){const T=w.map(S=>S.slice(m+d)).join(`
104
+ `);T.trim()&&(e.customNestedParser?x=e.customNestedParser(T):x=n.blockTokens(T))}const k=e.createToken(p,x);a.push(k)}if(a.length!==0)return{items:a,raw:c}}function bf(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[i,...o]=t.content,l=e.renderChildren([i]);let a=`${s}${l}`;return o&&o.length>0&&o.forEach((c,u)=>{var d,h;const f=(h=(d=e.renderChild)==null?void 0:d.call(e,c,u+1))!=null?h:e.renderChildren([c]);if(f!=null){const p=f.split(`
105
+ `).map(m=>m?e.indent(m):e.indent("")).join(`
106
+ `);a+=c.type==="paragraph"?`
107
+
108
+ ${p}`:`
109
+ ${p}`}}),a}function RT(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,o=t;s.descendants((l,a)=>{const c=i.mapping.map(a),u=i.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(f=>{if(f!==o)return!1;d=f}),!d)return;let h=!1;if(Object.keys(n).forEach(f=>{n[f]!==d.attrs[f]&&(h=!0)}),h){const f=t.type.create({...t.attrs,...n});i.removeMark(c,u,t.type),i.addMark(c,u,f)}}),i.docChanged&&e.view.dispatch(i)}var De=class Nx extends mf{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new Nx(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},_T=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,s,i,o,l;const{view:a}=this.editor,c=t.target,u=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(c)||!u)return;let d=0,h=0;if(this.dom!==u){const x=this.dom.getBoundingClientRect(),w=u.getBoundingClientRect(),k=(s=t.offsetX)!=null?s:(r=t.nativeEvent)==null?void 0:r.offsetX,T=(o=t.offsetY)!=null?o:(i=t.nativeEvent)==null?void 0:i.offsetY;d=w.x-x.x+k,h=w.y-x.y+T}const f=this.dom.cloneNode(!0);try{const x=this.dom.getBoundingClientRect();f.style.width=`${Math.round(x.width)}px`,f.style.height=`${Math.round(x.height)}px`,f.style.boxSizing="border-box",f.style.pointerEvents="none"}catch{}let p=null;try{p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(f),document.body.appendChild(p),(l=t.dataTransfer)==null||l.setDragImage(f,d,h)}finally{p&&setTimeout(()=>{try{p?.remove()}catch{}},0)}const m=this.getPos();if(typeof m!="number")return;const y=Y.create(a.state.doc,m),b=a.state.tr.setSelection(y);a.dispatch(b)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const s=t.type.startsWith("drag"),i=t.type==="dragover"||t.type==="dragenter",o=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!o&&!s)return!0;const{isEditable:a}=this.editor,{isDragging:c}=this,u=!!this.node.type.spec.draggable,d=Y.isSelectable(this.node),h=t.type==="copy",f=t.type==="paste",p=t.type==="cut",m=t.type==="mousedown";if(!u&&d&&s&&t.target===this.dom&&t.preventDefault(),u&&s&&!c&&t.target===this.dom)return t.preventDefault(),!1;if(u&&a&&!c&&m){const y=n.closest("[data-drag-handle]");y&&(this.dom===y||this.dom.contains(y))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(c||i||o||h||f||p||m&&d)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(lo()||Bd())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function mr(t){return new uT({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const i=we(t.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:o}=e,l=r[r.length-1],a=r[0];let c=n.to;if(l){const u=a.search(/\S/),d=n.from+a.indexOf(l),h=d+l.length;if(ff(n.from,n.to,e.doc).filter(m=>m.mark.type.excluded.find(b=>b===t.type&&b!==m.mark.type)).filter(m=>m.to>d).length)return null;h<n.to&&o.delete(h,n.to),d>n.from&&o.delete(n.from+u,d),c=n.from+u+l.length,o.addMark(n.from+u,c,t.type.create(i||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:OT,getOwnPropertySymbols:DT}=Object,{hasOwnProperty:LT}=Object.prototype;function Du(t,e){return function(r,s,i){return t(r,s,i)&&e(r,s,i)}}function dl(t){return function(n,r,s){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,s);const{cache:i}=s,o=i.get(n),l=i.get(r);if(o&&l)return o===r&&l===n;i.set(n,r),i.set(r,n);const a=t(n,r,s);return i.delete(n),i.delete(r),a}}function IT(t){return t?.[Symbol.toStringTag]}function rg(t){return OT(t).concat(DT(t))}const PT=Object.hasOwn||((t,e)=>LT.call(t,e));function rs(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const jT="__v",$T="__o",BT="_owner",{getOwnPropertyDescriptor:sg,keys:ig}=Object;function zT(t,e){return t.byteLength===e.byteLength&&ha(new Uint8Array(t),new Uint8Array(e))}function HT(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function FT(t,e){return t.byteLength===e.byteLength&&ha(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function UT(t,e){return rs(t.getTime(),e.getTime())}function VT(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function WT(t,e){return t===e}function og(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.entries();let o,l,a=0;for(;(o=i.next())&&!o.done;){const c=e.entries();let u=!1,d=0;for(;(l=c.next())&&!l.done;){if(s[d]){d++;continue}const h=o.value,f=l.value;if(n.equals(h[0],f[0],a,d,t,e,n)&&n.equals(h[1],f[1],h[0],f[0],t,e,n)){u=s[d]=!0;break}d++}if(!u)return!1;a++}return!0}const qT=rs;function KT(t,e,n){const r=ig(t);let s=r.length;if(ig(e).length!==s)return!1;for(;s-- >0;)if(!Rx(t,e,n,r[s]))return!1;return!0}function pi(t,e,n){const r=rg(t);let s=r.length;if(rg(e).length!==s)return!1;let i,o,l;for(;s-- >0;)if(i=r[s],!Rx(t,e,n,i)||(o=sg(t,i),l=sg(e,i),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function JT(t,e){return rs(t.valueOf(),e.valueOf())}function GT(t,e){return t.source===e.source&&t.flags===e.flags}function lg(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.values();let o,l;for(;(o=i.next())&&!o.done;){const a=e.values();let c=!1,u=0;for(;(l=a.next())&&!l.done;){if(!s[u]&&n.equals(o.value,l.value,o.value,l.value,t,e,n)){c=s[u]=!0;break}u++}if(!c)return!1}return!0}function ha(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function YT(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function Rx(t,e,n,r){return(r===BT||r===$T||r===jT)&&(t.$$typeof||e.$$typeof)?!0:PT(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const XT="[object ArrayBuffer]",ZT="[object Arguments]",QT="[object Boolean]",eN="[object DataView]",tN="[object Date]",nN="[object Error]",rN="[object Map]",sN="[object Number]",iN="[object Object]",oN="[object RegExp]",lN="[object Set]",aN="[object String]",cN={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},uN="[object URL]",dN=Object.prototype.toString;function hN({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:i,areMapsEqual:o,areNumbersEqual:l,areObjectsEqual:a,arePrimitiveWrappersEqual:c,areRegExpsEqual:u,areSetsEqual:d,areTypedArraysEqual:h,areUrlsEqual:f,unknownTagComparators:p}){return function(y,b,x){if(y===b)return!0;if(y==null||b==null)return!1;const w=typeof y;if(w!==typeof b)return!1;if(w!=="object")return w==="number"?l(y,b,x):w==="function"?i(y,b,x):!1;const k=y.constructor;if(k!==b.constructor)return!1;if(k===Object)return a(y,b,x);if(Array.isArray(y))return e(y,b,x);if(k===Date)return r(y,b,x);if(k===RegExp)return u(y,b,x);if(k===Map)return o(y,b,x);if(k===Set)return d(y,b,x);const T=dN.call(y);if(T===tN)return r(y,b,x);if(T===oN)return u(y,b,x);if(T===rN)return o(y,b,x);if(T===lN)return d(y,b,x);if(T===iN)return typeof y.then!="function"&&typeof b.then!="function"&&a(y,b,x);if(T===uN)return f(y,b,x);if(T===nN)return s(y,b,x);if(T===ZT)return a(y,b,x);if(cN[T])return h(y,b,x);if(T===XT)return t(y,b,x);if(T===eN)return n(y,b,x);if(T===QT||T===sN||T===aN)return c(y,b,x);if(p){let S=p[T];if(!S){const v=IT(y);v&&(S=p[v])}if(S)return S(y,b,x)}return!1}}function fN({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:zT,areArraysEqual:n?pi:HT,areDataViewsEqual:FT,areDatesEqual:UT,areErrorsEqual:VT,areFunctionsEqual:WT,areMapsEqual:n?Du(og,pi):og,areNumbersEqual:qT,areObjectsEqual:n?pi:KT,arePrimitiveWrappersEqual:JT,areRegExpsEqual:GT,areSetsEqual:n?Du(lg,pi):lg,areTypedArraysEqual:n?Du(ha,pi):ha,areUrlsEqual:YT,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const s=dl(r.areArraysEqual),i=dl(r.areMapsEqual),o=dl(r.areObjectsEqual),l=dl(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:i,areObjectsEqual:o,areSetsEqual:l})}return r}function pN(t){return function(e,n,r,s,i,o,l){return t(e,n,l)}}function mN({circular:t,comparator:e,createState:n,equals:r,strict:s}){if(n)return function(l,a){const{cache:c=t?new WeakMap:void 0,meta:u}=n();return e(l,a,{cache:c,equals:r,meta:u,strict:s})};if(t)return function(l,a){return e(l,a,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const i={cache:void 0,equals:r,meta:void 0,strict:s};return function(l,a){return e(l,a,i)}}const gN=Sr();Sr({strict:!0});Sr({circular:!0});Sr({circular:!0,strict:!0});Sr({createInternalComparator:()=>rs});Sr({strict:!0,createInternalComparator:()=>rs});Sr({circular:!0,createInternalComparator:()=>rs});Sr({circular:!0,createInternalComparator:()=>rs,strict:!0});function Sr(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:s=!1}=t,i=fN(t),o=hN(i),l=n?n(o):pN(o);return mN({circular:e,comparator:o,createState:r,equals:l,strict:s})}var hl={exports:{}},Lu={};var ag;function yN(){if(ag)return Lu;ag=1;var t=E,e=$h();function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,i=t.useRef,o=t.useEffect,l=t.useMemo,a=t.useDebugValue;return Lu.useSyncExternalStoreWithSelector=function(c,u,d,h,f){var p=i(null);if(p.current===null){var m={hasValue:!1,value:null};p.current=m}else m=p.current;p=l(function(){function b(S){if(!x){if(x=!0,w=S,S=h(S),f!==void 0&&m.hasValue){var v=m.value;if(f(v,S))return k=v}return k=S}if(v=k,r(w,S))return v;var A=h(S);return f!==void 0&&f(v,A)?(w=S,v):(w=S,k=A)}var x=!1,w,k,T=d===void 0?null:d;return[function(){return b(u())},T===null?void 0:function(){return b(T())}]},[u,d,h,f]);var y=s(c,p[0],p[1]);return o(function(){m.hasValue=!0,m.value=y},[y]),a(y),y},Lu}var Iu={};var cg;function bN(){return cg||(cg=1,process.env.NODE_ENV!=="production"&&(function(){function t(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var e=E,n=$h(),r=typeof Object.is=="function"?Object.is:t,s=n.useSyncExternalStore,i=e.useRef,o=e.useEffect,l=e.useMemo,a=e.useDebugValue;Iu.useSyncExternalStoreWithSelector=function(c,u,d,h,f){var p=i(null);if(p.current===null){var m={hasValue:!1,value:null};p.current=m}else m=p.current;p=l(function(){function b(S){if(!x){if(x=!0,w=S,S=h(S),f!==void 0&&m.hasValue){var v=m.value;if(f(v,S))return k=v}return k=S}if(v=k,r(w,S))return v;var A=h(S);return f!==void 0&&f(v,A)?(w=S,v):(w=S,k=A)}var x=!1,w,k,T=d===void 0?null:d;return[function(){return b(u())},T===null?void 0:function(){return b(T())}]},[u,d,h,f]);var y=s(c,p[0],p[1]);return o(function(){m.hasValue=!0,m.value=y},[y]),a(y),y},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Iu}var ug;function xN(){return ug||(ug=1,process.env.NODE_ENV==="production"?hl.exports=yN():hl.exports=bN()),hl.exports}var wN=xN(),kN=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},vN=({contentComponent:t})=>{const e=gb.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return g.jsx(g.Fragment,{children:Object.values(e)})};function SN(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:pc.createPortal(r.reactElement,r.element,n)},t.forEach(s=>s())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(s=>s())}}}var CN=class extends E.Component{constructor(t){super(t),this.editorContentRef=E.createRef()}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=SN(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){var t;const e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return g.jsxs(g.Fragment,{children:[g.jsx("div",{ref:kN(e,this.editorContentRef),...n}),t?.contentComponent&&g.jsx(vN,{contentComponent:t.contentComponent})]})}},EN=E.forwardRef((t,e)=>{const n=E.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return E.createElement(CN,{key:n,innerRef:e,...t})}),xf=E.memo(EN),AN=typeof window<"u"?E.useLayoutEffect:E.useEffect,MN=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function TN(t){var e;const[n]=E.useState(()=>new MN(t.editor)),r=wN.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:gN);return AN(()=>n.watch(t.editor),[t.editor,n]),E.useDebugValue(r),r}var dg=process.env.NODE_ENV!=="production",_x=typeof window>"u",NN=_x||!!(typeof window<"u"&&window.next),RN=class Ox{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){const e=this.options.current.immediatelyRender;let n=e??!0;return _x?(n&&dg&&console.warn("SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches"),n=!1):NN&&e===void 0&&(n=!1,dg&&console.warn("Next.js detected. `immediatelyRender` defaults to false to avoid hydration mismatches. Pass `immediatelyRender: true` explicitly if you are rendering the editor only on the client.")),n?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)==null?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)==null?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)==null?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)==null?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)==null?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)==null?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)==null?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)==null?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)==null?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)==null?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)==null?void 0:i.call(s,...r)},onDelete:(...r)=>{var s,i;return(i=(s=this.options.current).onDelete)==null?void 0:i.call(s,...r)}};return new bT(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((s,i)=>{var o;return s===((o=n.extensions)==null?void 0:o[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?Ox.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function Dx(t={},e=[]){const n=E.useRef(t);n.current=t;const[r]=E.useState(()=>new RN(n)),s=gb.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(s),E.useEffect(r.onRender(e)),TN({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var Lx=E.createContext({editor:null});Lx.Consumer;var Ix=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),_N=()=>E.useContext(Ix),wf=E.forwardRef((t,e)=>{const{onDragStart:n}=_N(),r=t.as||"div";return g.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function hg(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function fg(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function ON(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function DN(t){if(hg(t)||fg(t))return!0;if(ON(t)){const e=t.type;if(e)return hg(e)||fg(e)}return!1}function LN(){try{if(E.version)return parseInt(E.version.split(".")[0],10)>=19}catch{}return!1}var Px=class{constructor(t,{editor:e,props:n={},as:r="div",className:s=""}){this.ref=null,this.destroyed=!1,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isEditorContentInitialized?pc.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.destroyed||this.render()})}render(){var t;if(this.destroyed)return;const e=this.component,n=this.props,r=this.editor,s=LN(),i=DN(e),o={...n};o.ref&&!(s||i)&&delete o.ref,!o.ref&&(s||i)&&(o.ref=l=>{this.ref=l}),this.reactElement=g.jsx(e,{...o}),(t=r?.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){if(this.destroyed)return;let e=!1;const n=Object.keys(t);for(let r=0;r<n.length;r+=1){const s=n[r];if(t[s]!==this.props[s]){e=!0;break}}e&&(this.props={...this.props,...t},this.render())}destroy(){var t;this.destroyed=!0;const e=this.editor;(t=e?.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};E.createContext({markViewContentRef:()=>{}});var IN=class extends _T{constructor(t,e,n){if(super(t,e,n),this.selectionRafId=null,this.handlePositionUpdate=()=>{const r=this.getPos();typeof r!="number"||r===this.currentPos||(this.currentPos=r,this.renderer.updateProps({getPos:()=>this.getPos()}),typeof this.options.attrs=="function"&&this.updateElementAttributes())},this.cachedExtensionWithSyncedStorage=null,!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}this.options.trackNodeViewPosition&&this.editor.on("update",this.handlePositionUpdate)}get extensionWithSyncedStorage(){if(!this.cachedExtensionWithSyncedStorage){const t=this.editor,e=this.extension;this.cachedExtensionWithSyncedStorage=new Proxy(e,{get(n,r,s){var i;return r==="storage"?(i=t.storage[e.name])!=null?i:{}:Reflect.get(n,r,s)}})}return this.cachedExtensionWithSyncedStorage}mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extensionWithSyncedStorage,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(c={})=>this.updateAttributes(c),deleteNode:()=>this.deleteNode(),ref:E.createRef()};if(!this.component.displayName){const c=u=>u.charAt(0).toUpperCase()+u.substring(1);this.component.displayName=c(this.extension.name)}const s={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:c=>{c&&this.contentDOMElement&&c.firstChild!==this.contentDOMElement&&(c.hasAttribute("data-node-view-wrapper")&&c.removeAttribute("data-node-view-wrapper"),c.appendChild(this.contentDOMElement))}},i=this.component,o=E.memo(c=>g.jsx(Ix.Provider,{value:s,children:E.createElement(i,c)}));o.displayName="ReactNodeView";let l=this.node.isInline?"span":"div";this.options.as&&(l=this.options.as);const{className:a=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new Px(o,{editor:this.editor,props:e,as:l,className:`node-${this.node.type.name} ${a}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes(),this.currentPos=this.getPos()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null),this.selectionRafId=requestAnimationFrame(()=>{this.selectionRafId=null;const t=this.currentPos;if(typeof t!="number")return;if(IM({selection:this.editor.state.selection,pos:t,nodeSize:this.node.nodeSize,selectedOnTextSelection:this.options.selectedOnTextSelection})){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}})}update(t,e,n){const r=l=>{this.renderer.updateProps(l),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const l=this.node,a=this.decorations,c=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.currentPos=this.getPos(),this.options.update({oldNode:l,oldDecorations:a,newNode:t,newDecorations:e,oldInnerDecorations:c,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage})})}if(!(t!==this.node))return this.node=t,this.decorations=e,this.innerDecorations=n,!0;const i=this.getPos();this.node=t,this.decorations=e,this.innerDecorations=n,this.currentPos=i;const o={node:t,decorations:e,innerDecorations:n,extension:this.extensionWithSyncedStorage};return this.options.trackNodeViewPosition&&(o.getPos=()=>this.getPos()),r(o),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.options.trackNodeViewPosition&&this.editor.off("update",this.handlePositionUpdate),this.contentDOMElement=null,this.selectionRafId&&(cancelAnimationFrame(this.selectionRafId),this.selectionRafId=null)}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=Ps(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function kf(t,e){return n=>n.editor.contentComponent?new IN(t,n,e):{}}var vf=E.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});vf.displayName="TiptapContext";var PN=()=>E.useContext(vf);function jx({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const s=E.useMemo(()=>({editor:r}),[r]),i=E.useMemo(()=>({editor:r}),[r]);return g.jsx(Lx.Provider,{value:i,children:g.jsx(vf.Provider,{value:s,children:n})})}jx.displayName="Tiptap";function $x({...t}){const{editor:e}=PN();return g.jsx(xf,{editor:e,...t})}$x.displayName="Tiptap.Content";Object.assign(jx,{Content:$x});const Bs=Math.min,zt=Math.max,fa=Math.round,fl=Math.floor,wn=t=>({x:t,y:t}),jN={left:"right",right:"left",bottom:"top",top:"bottom"};function pg(t,e,n){return zt(t,Bs(e,n))}function Do(t,e){return typeof t=="function"?t(e):t}function gr(t){return t.split("-")[0]}function Lo(t){return t.split("-")[1]}function Bx(t){return t==="x"?"y":"x"}function zx(t){return t==="y"?"height":"width"}function jn(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function Hx(t){return Bx(jn(t))}function $N(t,e,n){n===void 0&&(n=!1);const r=Lo(t),s=Hx(t),i=zx(s);let o=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(o=pa(o)),[o,pa(o)]}function BN(t){const e=pa(t);return[Wd(t),e,Wd(e)]}function Wd(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const mg=["left","right"],gg=["right","left"],zN=["top","bottom"],HN=["bottom","top"];function FN(t,e,n){switch(t){case"top":case"bottom":return n?e?gg:mg:e?mg:gg;case"left":case"right":return e?zN:HN;default:return[]}}function UN(t,e,n,r){const s=Lo(t);let i=FN(gr(t),n==="start",r);return s&&(i=i.map(o=>o+"-"+s),e&&(i=i.concat(i.map(Wd)))),i}function pa(t){const e=gr(t);return jN[e]+t.slice(e.length)}function VN(t){return{top:0,right:0,bottom:0,left:0,...t}}function WN(t){return typeof t!="number"?VN(t):{top:t,right:t,bottom:t,left:t}}function ma(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function yg(t,e,n){let{reference:r,floating:s}=t;const i=jn(e),o=Hx(e),l=zx(o),a=gr(e),c=i==="y",u=r.x+r.width/2-s.width/2,d=r.y+r.height/2-s.height/2,h=r[l]/2-s[l]/2;let f;switch(a){case"top":f={x:u,y:r.y-s.height};break;case"bottom":f={x:u,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:d};break;case"left":f={x:r.x-s.width,y:d};break;default:f={x:r.x,y:r.y}}switch(Lo(e)){case"start":f[o]-=h*(n&&c?-1:1);break;case"end":f[o]+=h*(n&&c?-1:1);break}return f}async function qN(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:i,rects:o,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:f=0}=Do(e,t),p=WN(f),y=l[h?d==="floating"?"reference":"floating":d],b=ma(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(y)))==null||n?y:y.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:a})),x=d==="floating"?{x:r,y:s,width:o.floating.width,height:o.floating.height}:o.reference,w=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),k=await(i.isElement==null?void 0:i.isElement(w))?await(i.getScale==null?void 0:i.getScale(w))||{x:1,y:1}:{x:1,y:1},T=ma(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:x,offsetParent:w,strategy:a}):x);return{top:(b.top-T.top+p.top)/k.y,bottom:(T.bottom-b.bottom+p.bottom)/k.y,left:(b.left-T.left+p.left)/k.x,right:(T.right-b.right+p.right)/k.x}}const KN=50,JN=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:qN},a=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:s}),{x:u,y:d}=yg(c,r,a),h=r,f=0;const p={};for(let m=0;m<i.length;m++){const y=i[m];if(!y)continue;const{name:b,fn:x}=y,{x:w,y:k,data:T,reset:S}=await x({x:u,y:d,initialPlacement:r,placement:h,strategy:s,middlewareData:p,rects:c,platform:l,elements:{reference:t,floating:e}});u=w??u,d=k??d,p[b]={...p[b],...T},S&&f<KN&&(f++,typeof S=="object"&&(S.placement&&(h=S.placement),S.rects&&(c=S.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:s}):S.rects),{x:u,y:d}=yg(c,h,a)),m=-1)}return{x:u,y:d,placement:h,strategy:s,middlewareData:p}},GN=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:i,rects:o,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:m=!0,...y}=Do(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const b=gr(s),x=jn(l),w=gr(l)===l,k=await(a.isRTL==null?void 0:a.isRTL(c.floating)),T=h||(w||!m?[pa(l)]:BN(l)),S=p!=="none";!h&&S&&T.push(...UN(l,m,p,k));const v=[l,...T],A=await a.detectOverflow(e,y),C=[];let N=((r=i.flip)==null?void 0:r.overflows)||[];if(u&&C.push(A[b]),d){const _=$N(s,o,k);C.push(A[_[0]],A[_[1]])}if(N=[...N,{placement:s,overflows:C}],!C.every(_=>_<=0)){var D,z;const _=(((D=i.flip)==null?void 0:D.index)||0)+1,V=v[_];if(V&&(!(d==="alignment"?x!==jn(V):!1)||N.every(I=>jn(I.placement)===x?I.overflows[0]>0:!0)))return{data:{index:_,overflows:N},reset:{placement:V}};let ee=(z=N.filter(be=>be.overflows[0]<=0).sort((be,I)=>be.overflows[1]-I.overflows[1])[0])==null?void 0:z.placement;if(!ee)switch(f){case"bestFit":{var L;const be=(L=N.filter(I=>{if(S){const P=jn(I.placement);return P===x||P==="y"}return!0}).map(I=>[I.placement,I.overflows.filter(P=>P>0).reduce((P,ne)=>P+ne,0)]).sort((I,P)=>I[1]-P[1])[0])==null?void 0:L[0];be&&(ee=be);break}case"initialPlacement":ee=l;break}if(s!==ee)return{reset:{placement:ee}}}return{}}}},YN=new Set(["left","top"]);async function XN(t,e){const{placement:n,platform:r,elements:s}=t,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),o=gr(n),l=Lo(n),a=jn(n)==="y",c=YN.has(o)?-1:1,u=i&&a?-1:1,d=Do(e,t);let{mainAxis:h,crossAxis:f,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&typeof p=="number"&&(f=l==="end"?p*-1:p),a?{x:f*u,y:h*c}:{x:h*c,y:f*u}}const ZN=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:i,placement:o,middlewareData:l}=e,a=await XN(e,t);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+a.x,y:i+a.y,data:{...a,placement:o}}}}},QN=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s,platform:i}=e,{mainAxis:o=!0,crossAxis:l=!1,limiter:a={fn:b=>{let{x,y:w}=b;return{x,y:w}}},...c}=Do(t,e),u={x:n,y:r},d=await i.detectOverflow(e,c),h=jn(gr(s)),f=Bx(h);let p=u[f],m=u[h];if(o){const b=f==="y"?"top":"left",x=f==="y"?"bottom":"right",w=p+d[b],k=p-d[x];p=pg(w,p,k)}if(l){const b=h==="y"?"top":"left",x=h==="y"?"bottom":"right",w=m+d[b],k=m-d[x];m=pg(w,m,k)}const y=a.fn({...e,[f]:p,[h]:m});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[f]:o,[h]:l}}}}}},eR=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:s,rects:i,platform:o,elements:l}=e,{apply:a=()=>{},...c}=Do(t,e),u=await o.detectOverflow(e,c),d=gr(s),h=Lo(s),f=jn(s)==="y",{width:p,height:m}=i.floating;let y,b;d==="top"||d==="bottom"?(y=d,b=h===(await(o.isRTL==null?void 0:o.isRTL(l.floating))?"start":"end")?"left":"right"):(b=d,y=h==="end"?"top":"bottom");const x=m-u.top-u.bottom,w=p-u.left-u.right,k=Bs(m-u[y],x),T=Bs(p-u[b],w),S=!e.middlewareData.shift;let v=k,A=T;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(A=w),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(v=x),S&&!h){const N=zt(u.left,0),D=zt(u.right,0),z=zt(u.top,0),L=zt(u.bottom,0);f?A=p-2*(N!==0||D!==0?N+D:zt(u.left,u.right)):v=m-2*(z!==0||L!==0?z+L:zt(u.top,u.bottom))}await a({...e,availableWidth:A,availableHeight:v});const C=await o.getDimensions(l.floating);return p!==C.width||m!==C.height?{reset:{rects:!0}}:{}}}};function Ac(){return typeof window<"u"}function ei(t){return Fx(t)?(t.nodeName||"").toLowerCase():"#document"}function Ft(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function En(t){var e;return(e=(Fx(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Fx(t){return Ac()?t instanceof Node||t instanceof Ft(t).Node:!1}function pt(t){return Ac()?t instanceof Element||t instanceof Ft(t).Element:!1}function Vn(t){return Ac()?t instanceof HTMLElement||t instanceof Ft(t).HTMLElement:!1}function bg(t){return!Ac()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Ft(t).ShadowRoot}function Io(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=ln(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&s!=="inline"&&s!=="contents"}function tR(t){return/^(table|td|th)$/.test(ei(t))}function Mc(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const nR=/transform|translate|scale|rotate|perspective|filter/,rR=/paint|layout|strict|content/,Ar=t=>!!t&&t!=="none";let Pu;function Sf(t){const e=pt(t)?ln(t):t;return Ar(e.transform)||Ar(e.translate)||Ar(e.scale)||Ar(e.rotate)||Ar(e.perspective)||!Cf()&&(Ar(e.backdropFilter)||Ar(e.filter))||nR.test(e.willChange||"")||rR.test(e.contain||"")}function sR(t){let e=yr(t);for(;Vn(e)&&!zs(e);){if(Sf(e))return e;if(Mc(e))return null;e=yr(e)}return null}function Cf(){return Pu==null&&(Pu=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Pu}function zs(t){return/^(html|body|#document)$/.test(ei(t))}function ln(t){return Ft(t).getComputedStyle(t)}function Tc(t){return pt(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function yr(t){if(ei(t)==="html")return t;const e=t.assignedSlot||t.parentNode||bg(t)&&t.host||En(t);return bg(e)?e.host:e}function Ux(t){const e=yr(t);return zs(e)?t.ownerDocument?t.ownerDocument.body:t.body:Vn(e)&&Io(e)?e:Ux(e)}function co(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const s=Ux(t),i=s===((r=t.ownerDocument)==null?void 0:r.body),o=Ft(s);if(i){const l=qd(o);return e.concat(o,o.visualViewport||[],Io(s)?s:[],l&&n?co(l):[])}else return e.concat(s,co(s,[],n))}function qd(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Vx(t){const e=ln(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=Vn(t),i=s?t.offsetWidth:n,o=s?t.offsetHeight:r,l=fa(n)!==i||fa(r)!==o;return l&&(n=i,r=o),{width:n,height:r,$:l}}function Ef(t){return pt(t)?t:t.contextElement}function Es(t){const e=Ef(t);if(!Vn(e))return wn(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:i}=Vx(e);let o=(i?fa(n.width):n.width)/r,l=(i?fa(n.height):n.height)/s;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const iR=wn(0);function Wx(t){const e=Ft(t);return!Cf()||!e.visualViewport?iR:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function oR(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Ft(t)?!1:e}function Kr(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),i=Ef(t);let o=wn(1);e&&(r?pt(r)&&(o=Es(r)):o=Es(t));const l=oR(i,n,r)?Wx(i):wn(0);let a=(s.left+l.x)/o.x,c=(s.top+l.y)/o.y,u=s.width/o.x,d=s.height/o.y;if(i){const h=Ft(i),f=r&&pt(r)?Ft(r):r;let p=h,m=qd(p);for(;m&&r&&f!==p;){const y=Es(m),b=m.getBoundingClientRect(),x=ln(m),w=b.left+(m.clientLeft+parseFloat(x.paddingLeft))*y.x,k=b.top+(m.clientTop+parseFloat(x.paddingTop))*y.y;a*=y.x,c*=y.y,u*=y.x,d*=y.y,a+=w,c+=k,p=Ft(m),m=qd(p)}}return ma({width:u,height:d,x:a,y:c})}function Nc(t,e){const n=Tc(t).scrollLeft;return e?e.left+n:Kr(En(t)).left+n}function qx(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-Nc(t,n),s=n.top+e.scrollTop;return{x:r,y:s}}function lR(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const i=s==="fixed",o=En(r),l=e?Mc(e.floating):!1;if(r===o||l&&i)return n;let a={scrollLeft:0,scrollTop:0},c=wn(1);const u=wn(0),d=Vn(r);if((d||!d&&!i)&&((ei(r)!=="body"||Io(o))&&(a=Tc(r)),d)){const f=Kr(r);c=Es(r),u.x=f.x+r.clientLeft,u.y=f.y+r.clientTop}const h=o&&!d&&!i?qx(o,a):wn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-a.scrollTop*c.y+u.y+h.y}}function aR(t){return Array.from(t.getClientRects())}function cR(t){const e=En(t),n=Tc(t),r=t.ownerDocument.body,s=zt(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),i=zt(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+Nc(t);const l=-n.scrollTop;return ln(r).direction==="rtl"&&(o+=zt(e.clientWidth,r.clientWidth)-s),{width:s,height:i,x:o,y:l}}const xg=25;function uR(t,e){const n=Ft(t),r=En(t),s=n.visualViewport;let i=r.clientWidth,o=r.clientHeight,l=0,a=0;if(s){i=s.width,o=s.height;const u=Cf();(!u||u&&e==="fixed")&&(l=s.offsetLeft,a=s.offsetTop)}const c=Nc(r);if(c<=0){const u=r.ownerDocument,d=u.body,h=getComputedStyle(d),f=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,p=Math.abs(r.clientWidth-d.clientWidth-f);p<=xg&&(i-=p)}else c<=xg&&(i+=c);return{width:i,height:o,x:l,y:a}}function dR(t,e){const n=Kr(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,i=Vn(t)?Es(t):wn(1),o=t.clientWidth*i.x,l=t.clientHeight*i.y,a=s*i.x,c=r*i.y;return{width:o,height:l,x:a,y:c}}function wg(t,e,n){let r;if(e==="viewport")r=uR(t,n);else if(e==="document")r=cR(En(t));else if(pt(e))r=dR(e,n);else{const s=Wx(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return ma(r)}function Kx(t,e){const n=yr(t);return n===e||!pt(n)||zs(n)?!1:ln(n).position==="fixed"||Kx(n,e)}function hR(t,e){const n=e.get(t);if(n)return n;let r=co(t,[],!1).filter(l=>pt(l)&&ei(l)!=="body"),s=null;const i=ln(t).position==="fixed";let o=i?yr(t):t;for(;pt(o)&&!zs(o);){const l=ln(o),a=Sf(o);!a&&l.position==="fixed"&&(s=null),(i?!a&&!s:!a&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||Io(o)&&!a&&Kx(t,o))?r=r.filter(u=>u!==o):s=l,o=yr(o)}return e.set(t,r),r}function fR(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const o=[...n==="clippingAncestors"?Mc(e)?[]:hR(e,this._c):[].concat(n),r],l=wg(e,o[0],s);let a=l.top,c=l.right,u=l.bottom,d=l.left;for(let h=1;h<o.length;h++){const f=wg(e,o[h],s);a=zt(f.top,a),c=Bs(f.right,c),u=Bs(f.bottom,u),d=zt(f.left,d)}return{width:c-d,height:u-a,x:d,y:a}}function pR(t){const{width:e,height:n}=Vx(t);return{width:e,height:n}}function mR(t,e,n){const r=Vn(e),s=En(e),i=n==="fixed",o=Kr(t,!0,i,e);let l={scrollLeft:0,scrollTop:0};const a=wn(0);function c(){a.x=Nc(s)}if(r||!r&&!i)if((ei(e)!=="body"||Io(s))&&(l=Tc(e)),r){const f=Kr(e,!0,i,e);a.x=f.x+e.clientLeft,a.y=f.y+e.clientTop}else s&&c();i&&!r&&s&&c();const u=s&&!r&&!i?qx(s,l):wn(0),d=o.left+l.scrollLeft-a.x-u.x,h=o.top+l.scrollTop-a.y-u.y;return{x:d,y:h,width:o.width,height:o.height}}function ju(t){return ln(t).position==="static"}function kg(t,e){if(!Vn(t)||ln(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return En(t)===n&&(n=n.ownerDocument.body),n}function Jx(t,e){const n=Ft(t);if(Mc(t))return n;if(!Vn(t)){let s=yr(t);for(;s&&!zs(s);){if(pt(s)&&!ju(s))return s;s=yr(s)}return n}let r=kg(t,e);for(;r&&tR(r)&&ju(r);)r=kg(r,e);return r&&zs(r)&&ju(r)&&!Sf(r)?n:r||sR(t)||n}const gR=async function(t){const e=this.getOffsetParent||Jx,n=this.getDimensions,r=await n(t.floating);return{reference:mR(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function yR(t){return ln(t).direction==="rtl"}const bR={convertOffsetParentRelativeRectToViewportRelativeRect:lR,getDocumentElement:En,getClippingRect:fR,getOffsetParent:Jx,getElementRects:gR,getClientRects:aR,getDimensions:pR,getScale:Es,isElement:pt,isRTL:yR};function Gx(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function xR(t,e){let n=null,r;const s=En(t);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function o(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),i();const c=t.getBoundingClientRect(),{left:u,top:d,width:h,height:f}=c;if(l||e(),!h||!f)return;const p=fl(d),m=fl(s.clientWidth-(u+h)),y=fl(s.clientHeight-(d+f)),b=fl(u),w={rootMargin:-p+"px "+-m+"px "+-y+"px "+-b+"px",threshold:zt(0,Bs(1,a))||1};let k=!0;function T(S){const v=S[0].intersectionRatio;if(v!==a){if(!k)return o();v?o(!1,v):r=setTimeout(()=>{o(!1,1e-7)},1e3)}v===1&&!Gx(c,t.getBoundingClientRect())&&o(),k=!1}try{n=new IntersectionObserver(T,{...w,root:s.ownerDocument})}catch{n=new IntersectionObserver(T,w)}n.observe(t)}return o(!0),i}function ti(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,c=Ef(t),u=s||i?[...c?co(c):[],...e?co(e):[]]:[];u.forEach(b=>{s&&b.addEventListener("scroll",n,{passive:!0}),i&&b.addEventListener("resize",n)});const d=c&&l?xR(c,n):null;let h=-1,f=null;o&&(f=new ResizeObserver(b=>{let[x]=b;x&&x.target===c&&f&&e&&(f.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var w;(w=f)==null||w.observe(e)})),n()}),c&&!a&&f.observe(c),e&&f.observe(e));let p,m=a?Kr(t):null;a&&y();function y(){const b=Kr(t);m&&!Gx(m,b)&&n(),m=b,p=requestAnimationFrame(y)}return n(),()=>{var b;u.forEach(x=>{s&&x.removeEventListener("scroll",n),i&&x.removeEventListener("resize",n)}),d?.(),(b=f)==null||b.disconnect(),f=null,a&&cancelAnimationFrame(p)}}const Af=ZN,Yx=QN,Xx=GN,Zx=eR,Mf=(t,e,n)=>{const r=new Map,s={platform:bR,...n},i={...s.platform,_c:r};return JN(t,e,{...s,platform:i})};var ga=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]};function Qx(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)n++;return n}if(s.content.size||i.content.size){let o=Qx(s.content,i.content,n+1);if(o!=null)return o}n+=s.nodeSize}}function ew(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let o=t.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){n-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(o.content.size||l.content.size){let c=ew(o.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}var Fn=class vt{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,i){for(let o=0,l=0;l<n;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",o=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new vt(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let i=0,o=0;o<n;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),s+=l.nodeSize),o=a}return new vt(r,s)}cutByIndex(e,n){return e==n?vt.empty:e==0&&n==this.content.length?this:new vt(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new vt(s,i)}addToStart(e){return new vt([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new vt(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return Qx(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return ew(this,e,n,r)}findIndex(e){if(e==0)return pl(0,e);if(e==this.size)return pl(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),i=r+s.nodeSize;if(i>=e)return i==e?pl(n+1,i):pl(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return vt.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return vt.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return vt.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new vt(n||e,r)}static from(e){if(!e)return vt.empty;if(e instanceof vt)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new vt([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};Fn.empty=new Fn([],0);var $u={index:0,offset:0};function pl(t,e){return $u.index=t,$u.offset=e,$u}var wR=class extends Error{},qe=class bs{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=nw(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new bs(r,this.openStart,this.openEnd)}removeBetween(e,n){return new bs(tw(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return bs.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new bs(Fn.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new bs(e,r,s)}};qe.empty=new qe(Fn.empty,0,0);function tw(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(s==e||i.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(tw(i.content,e-s-1,n-s-1)))}function nw(t,e,n,r,s,i){let{index:o,offset:l}=t.findIndex(e),a=t.maybeChild(o);if(l==e||a.isText)return i&&r<=0&&s<=0&&!i.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=nw(a.content,e-l-1,n,o==0?r-1:0,o==t.childCount-1?s-1:0,a);return c&&t.replaceChild(o,a.copy(c))}var rw=65535,sw=Math.pow(2,16);function kR(t,e){return t+e*sw}function vg(t){return t&rw}function vR(t){return(t-(t&rw))/sw}var iw=1,ow=2,jl=4,lw=8,Sg=class{constructor(t,e,n){this.pos=t,this.delInfo=e,this.recover=n}get deleted(){return(this.delInfo&lw)>0}get deletedBefore(){return(this.delInfo&(iw|jl))>0}get deletedAfter(){return(this.delInfo&(ow|jl))>0}get deletedAcross(){return(this.delInfo&jl)>0}},Jr=class xs{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&xs.empty)return xs.empty}recover(e){let n=0,r=vg(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+vR(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+o],d=a+c;if(e<=d){let h=c?e==a?-1:e==d?1:n:n,f=a+s+(h<0?0:u);if(r)return f;let p=e==(n<0?a:d)?null:kR(l/3,e-a),m=e==a?ow:e==d?iw:jl;return(n<0?e!=a:e!=d)&&(m|=lw),new Sg(f,m,p)}s+=u-c}return r?e+s:new Sg(e+s,0,null)}touches(e,n){let r=0,s=vg(n),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+n],u=this.ranges[s+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new xs(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?xs.empty:new xs(e<0?[0,-e,0]:[0,0,e])}};Jr.empty=new Jr([]);var Bu=Object.create(null),xt=class{getMap(){return Jr.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Bu[e.stepType];if(!n)throw new RangeError(`No step type ${e.stepType} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Bu)throw new RangeError("Duplicate use of step JSON ID "+t);return Bu[t]=e,e.prototype.jsonID=t,e}},Et=class Ti{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Ti(e,null)}static fail(e){return new Ti(null,e)}static fromReplace(e,n,r,s){try{return Ti.ok(e.replace(n,r,s))}catch(i){if(i instanceof wR)return Ti.fail(i.message);throw i}}};function Tf(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(Tf(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return Fn.fromArray(r)}var aw=class Ni extends xt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new qe(Tf(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),n.openStart,n.openEnd);return Et.fromReplace(e,this.from,this.to,i)}invert(){return new cw(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Ni(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ni&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ni(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Ni(n.from,n.to,e.markFromJSON(n.mark))}};xt.jsonID("addMark",aw);var cw=class Ri extends xt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new qe(Tf(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return Et.fromReplace(e,this.from,this.to,r)}invert(){return new aw(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Ri(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ri&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ri(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ri(n.from,n.to,e.markFromJSON(n.mark))}};xt.jsonID("removeMark",cw);var uw=class _i extends xt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Et.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Et.fromReplace(e,this.pos,this.pos+1,new qe(Fn.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new _i(this.pos,n.marks[s]);return new _i(this.pos,this.mark)}}return new dw(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new _i(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new _i(n.pos,e.markFromJSON(n.mark))}};xt.jsonID("addNodeMark",uw);var dw=class Kd extends xt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Et.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Et.fromReplace(e,this.pos,this.pos+1,new qe(Fn.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new uw(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Kd(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Kd(n.pos,e.markFromJSON(n.mark))}};xt.jsonID("removeNodeMark",dw);var Nf=class Qn extends xt{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Jd(e,this.from,this.to)?Et.fail("Structure replace would overwrite content"):Et.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Jr([this.from,this.to-this.from,this.slice.size])}invert(e){return new Qn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&Qn.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new Qn(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Qn)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?qe.empty:new qe(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Qn(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?qe.empty:new qe(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Qn(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Qn(n.from,n.to,qe.fromJSON(e,n.slice),!!n.structure)}};Nf.MAP_BIAS=1;xt.jsonID("replace",Nf);var hw=class $l extends xt{constructor(e,n,r,s,i,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Jd(e,this.from,this.gapFrom)||Jd(e,this.gapTo,this.to)))return Et.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Et.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Et.fromReplace(e,this.from,this.to,r):Et.fail("Content does not fit in gap")}getMap(){return new Jr([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new $l(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new $l(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new $l(n.from,n.to,n.gapFrom,n.gapTo,qe.fromJSON(e,n.slice),n.insert,!!n.structure)}};xt.jsonID("replaceAround",hw);function Jd(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}var SR=class Bl extends xt{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Et.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return Et.fromReplace(e,this.pos,this.pos+1,new qe(Fn.from(s),0,n.isLeaf?0:1))}getMap(){return Jr.empty}invert(e){return new Bl(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Bl(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Bl(n.pos,n.attr,n.value)}};xt.jsonID("attr",SR);var CR=class Gd extends xt{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Et.ok(r)}getMap(){return Jr.empty}invert(e){return new Gd(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Gd(n.attr,n.value)}};xt.jsonID("docAttr",CR);var uo=class extends Error{};uo=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};uo.prototype=Object.create(Error.prototype);uo.prototype.constructor=uo;uo.prototype.name="TransformError";var zu=Object.create(null),tt=class{constructor(t,e,n){this.$anchor=t,this.$head=e,this.ranges=n||[new ER(t.min(e),t.max(e))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=qe.empty){let n=e.content.lastChild,r=null;for(let o=0;o<e.openEnd;o++)r=n,n=n.lastChild;let s=t.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:l,$to:a}=i[o],c=t.mapping.slice(s);t.replaceRange(c.map(l.pos),c.map(a.pos),o?qe.empty:e),o==0&&Ag(t,s,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(t,e){let n=t.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:i,$to:o}=r[s],l=t.mapping.slice(n),a=l.map(i.pos),c=l.map(o.pos);s?t.deleteRange(a,c):(t.replaceRangeWith(a,c,e),Ag(t,n,e.isInline?-1:1))}}static findFrom(t,e,n=!1){let r=t.parent.inlineContent?new Hs(t):ws(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(let s=t.depth-1;s>=0;s--){let i=e<0?ws(t.node(0),t.node(s),t.before(s+1),t.index(s),e,n):ws(t.node(0),t.node(s),t.after(s+1),t.index(s)+1,e,n);if(i)return i}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new Hi(t.node(0))}static atStart(t){return ws(t,t,0,0,1)||new Hi(t)}static atEnd(t){return ws(t,t,t.content.size,t.childCount,-1)||new Hi(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=zu[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in zu)throw new RangeError("Duplicate use of selection JSON ID "+t);return zu[t]=e,e.prototype.jsonID=t,e}getBookmark(){return Hs.between(this.$anchor,this.$head).getBookmark()}};tt.prototype.visible=!0;var ER=class{constructor(t,e){this.$from=t,this.$to=e}},Cg=!1;function Eg(t){!Cg&&!t.parent.inlineContent&&(Cg=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}var Hs=class Oi extends tt{constructor(e,n=e){Eg(e),Eg(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return tt.near(r);let s=e.resolve(n.map(this.anchor));return new Oi(s.parent.inlineContent?s:r,r)}replace(e,n=qe.empty){if(super.replace(e,n),n==qe.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Oi&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new fw(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Oi(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let i=tt.findFrom(n,r,!0)||tt.findFrom(n,-r,!0);if(i)n=i.$head;else return tt.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(tt.findFrom(e,-r,!0)||tt.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new Oi(e,n)}};tt.jsonID("text",Hs);var fw=class pw{constructor(e,n){this.anchor=e,this.head=n}map(e){return new pw(e.map(this.anchor),e.map(this.head))}resolve(e){return Hs.between(e.resolve(this.anchor),e.resolve(this.head))}},Fs=class Di extends tt{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),i=e.resolve(s);return r?tt.near(i):new Di(i)}content(){return new qe(Fn.from(this.node),0,0)}eq(e){return e instanceof Di&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new AR(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Di(e.resolve(n.anchor))}static create(e,n){return new Di(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};Fs.prototype.visible=!1;tt.jsonID("node",Fs);var AR=class mw{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new fw(r,r):new mw(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Fs.isSelectable(r)?new Fs(n):tt.near(n)}},Hi=class zl extends tt{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=qe.empty){if(n==qe.empty){e.delete(0,e.doc.content.size);let r=tt.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new zl(e)}map(e){return new zl(e)}eq(e){return e instanceof zl}getBookmark(){return MR}};tt.jsonID("all",Hi);var MR={map(){return this},resolve(t){return new Hi(t)}};function ws(t,e,n,r,s,i=!1){if(e.inlineContent)return Hs.create(t,n);for(let o=r-(s>0?0:1);s>0?o<e.childCount:o>=0;o+=s){let l=e.child(o);if(l.isAtom){if(!i&&Fs.isSelectable(l))return Fs.create(t,n-(s<0?l.nodeSize:0))}else{let a=ws(t,l,n+s,s<0?l.childCount:0,s,i);if(a)return a}n+=l.nodeSize*s}return null}function Ag(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof Nf||s instanceof hw))return;let i=t.mapping.maps[r],o;i.forEach((l,a,c,u)=>{o==null&&(o=u)}),t.setSelection(tt.near(t.doc.resolve(o),n))}function Mg(t,e){return!e||!t?t:t.bind(e)}var ml=class{constructor(t,e,n){this.name=t,this.init=Mg(e.init,n),this.apply=Mg(e.apply,n)}};new ml("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new ml("selection",{init(t,e){return t.selection||tt.atStart(e.doc)},apply(t){return t.selection}}),new ml("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new ml("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});var TR=(t,e)=>{var n;const{state:r,view:s}=t,{selection:i}=r;if(!i.empty)return!1;const{$from:o}=i;if(o.parentOffset!==0)return!1;const l=o.depth-1,a=o.node(l),c=o.index(l);if(c===0)return!1;if(a.type===e)return t.commands.lift(e.name);const u=a.child(c-1);if(u.type!==e||!((n=u.lastChild)!=null&&n.isTextblock))return!1;const d=o.before(),f=d-1-1,{tr:p}=r;return p.delete(d,o.after()).insert(f,o.parent.content),p.setSelection(Hs.create(p.doc,f)),s.dispatch(p.scrollIntoView()),!0},NR=/^\s*>\s$/,gw=De.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return ga("blockquote",{...fe(this.options.HTMLAttributes,t),children:ga("slot",{})})},parseMarkdown:(t,e)=>{var n;const r=(n=e.parseBlockChildren)!=null?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach((s,i)=>{var o,l;const u=((l=(o=e.renderChild)==null?void 0:o.call(e,s,i))!=null?l:e.renderChildren([s])).split(`
110
+ `).map(d=>d.trim()===""?n:`${n} ${d}`);r.push(u.join(`
111
+ `))}),r.join(`
112
+ ${n}
113
+ `)},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote(),Backspace:()=>TR(this.editor,this.type)}},addInputRules(){return[$s({find:NR,type:this.type})]}}),RR=gw,_R=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,OR=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,DR=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,LR=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,IR=dn.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return ga("strong",{...fe(this.options.HTMLAttributes,t),children:ga("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[qr({find:_R,type:this.type}),qr({find:DR,type:this.type})]},addPasteRules(){return[mr({find:OR,type:this.type}),mr({find:LR,type:this.type})]}}),PR=t=>{const e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},jR=t=>{const e=/`([^`]+)`(?!`)/g,n=[];let r;for(;(r=e.exec(t))!==null;)r.index>0&&t[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n},$R=dn.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",fe(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[qr({find:PR,type:this.type})]},addPasteRules(){return[mr({find:jR,type:this.type})]}}),Hu=4,BR=/^```([a-z]+)?[\s\n]$/,zR=/^~~~([a-z]+)?[\s\n]$/,yw=De.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Hu,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options;if(!n)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",fe(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&((r=t.raw)==null?void 0:r.startsWith("~~~"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const s=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${s}`,e.renderChildren(t.content),"```"].join(`
108
114
  `):r=`\`\`\`${s}
109
115
 
110
- \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:mc,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;if(i.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:a})=>{const{from:c,to:d}=s,f=r.doc.textBetween(c,d,`
116
+ \`\`\``,r},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Hu,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;if(i.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:a})=>{const{from:c,to:u}=s,f=r.doc.textBetween(c,u,`
111
117
  `,`
112
118
  `).split(`
113
119
  `).map(p=>l+p).join(`
114
- `);return a.replaceWith(c,d,r.schema.text(f)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:mc,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;return i.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var a;const{pos:c}=i,d=i.start(),u=i.end(),f=r.doc.textBetween(d,u,`
120
+ `);return a.replaceWith(c,u,r.schema.text(f)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:Hu,{state:r}=t,{selection:s}=r,{$from:i,empty:o}=s;return i.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var a;const{pos:c}=i,u=i.start(),d=i.end(),f=r.doc.textBetween(u,d,`
115
121
  `,`
116
122
  `).split(`
117
- `);let p=0,g=0;const y=c-d;for(let x=0;x<f.length;x+=1){if(g+f[x].length>=y){p=x;break}g+=f[x].length+1}const w=((a=f[p].match(/^ */))==null?void 0:a[0])||"",A=Math.min(w.length,n);if(A===0)return!0;let S=d;for(let x=0;x<p;x+=1)S+=f[x].length+1;return l.delete(S,S+A),c-S<=A&&l.setSelection(J.create(l.doc,S)),!0}):t.commands.command(({tr:l})=>{const{from:a,to:c}=s,h=r.doc.textBetween(a,c,`
123
+ `);let p=0,m=0;const y=c-u;for(let S=0;S<f.length;S+=1){if(m+f[S].length>=y){p=S;break}m+=f[S].length+1}const x=((a=f[p].match(/^ */))==null?void 0:a[0])||"",w=Math.min(x.length,n);if(w===0)return!0;let k=u;for(let S=0;S<p;S+=1)k+=f[S].length+1;return l.delete(k,k+w),c-k<=w&&l.setSelection(Q.create(l.doc,k)),!0}):t.commands.command(({tr:l})=>{const{from:a,to:c}=s,h=r.doc.textBetween(a,c,`
118
124
  `,`
119
125
  `).split(`
120
- `).map(f=>{var p;const g=((p=f.match(/^ */))==null?void 0:p[0])||"",y=Math.min(g.length,n);return f.slice(y)}).join(`
126
+ `).map(f=>{var p;const m=((p=f.match(/^ */))==null?void 0:p[0])||"",y=Math.min(m.length,n);return f.slice(y)}).join(`
121
127
  `);return l.replaceWith(a,c,r.schema.text(h)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
122
128
 
123
- `);return!i||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:c})=>(c.setSelection(ee.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[od({find:jM,type:this.type,getAttributes:t=>({language:t[1]})}),od({find:PM,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new me({key:new ye("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!n||!i)return!1;const{tr:o,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,`
124
- `));return o.replaceSelectionWith(this.type.create({language:i},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(J.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),BM=_b,$M=Oe.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
129
+ `);return!i||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:c})=>(c.setSelection(te.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[Ud({find:BR,type:this.type,getAttributes:t=>({language:t[1]})}),Ud({find:zR,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new me({key:new ge("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,i=s?.mode;if(!n||!i)return!1;const{tr:o,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,`
130
+ `));return o.replaceSelectionWith(this.type.create({language:i},a)),o.selection.$from.parent.type!==this.type&&o.setSelection(Q.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),HR=De.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
125
131
 
126
- `):""}),HM=Oe.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",pe(this.options.HTMLAttributes,t)]},renderText(){return`
127
- `},renderMarkdown:(t,e)=>e.indent(`
128
- `),parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&o){const u=a.filter(h=>l.includes(h.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Rb=Oe.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,pe(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>od({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),zM=Rb,FM=Oe.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",pe(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!sE(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return Gy(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:o,dispatch:l})=>{if(l){const{$to:a}=o.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?o.setSelection(J.create(o.doc,a.pos+1)):a.nodeAfter.isBlock?o.setSelection(q.create(o.doc,a.pos)):o.setSelection(J.create(o.doc,a.pos));else{const d=i.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,u=d?.create();u&&(o.insert(c,u),o.setSelection(J.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[ab({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),UM=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,VM=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,WM=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,qM=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,KM=Zt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",pe(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Lr({find:UM,type:this.type}),Lr({find:WM,type:this.type})]},addPasteRules(){return[sr({find:VM,type:this.type}),sr({find:qM,type:this.type})]}});const GM="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",JM="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",ud="numeric",hd="ascii",fd="alpha",Js="asciinumeric",Us="alphanumeric",pd="domain",Ob="emoji",YM="scheme",XM="slashscheme",gc="whitespace";function ZM(t,e){return t in e||(e[t]=[]),e[t]}function vr(t,e,n){e[ud]&&(e[Js]=!0,e[Us]=!0),e[hd]&&(e[Js]=!0,e[fd]=!0),e[Js]&&(e[Us]=!0),e[fd]&&(e[Us]=!0),e[Us]&&(e[pd]=!0),e[Ob]&&(e[pd]=!0);for(const r in e){const s=ZM(r,n);s.indexOf(t)<0&&s.push(t)}}function QM(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function kt(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}kt.groups={};kt.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||kt.groups;let s;return e&&e.j?s=e:(s=new kt(e),n&&r&&vr(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const i=t.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(t[o]);return s.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||kt.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const i=e;let o,l=s.go(t);if(l?(o=new kt,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new kt,i){if(r)if(o.t&&typeof o.t=="string"){const a=Object.assign(QM(o.t,r),n);vr(i,a,r)}else n&&vr(i,n,r);o.t=i}return s.j[t]=o,o}};const oe=(t,e,n,r,s)=>t.ta(e,n,r,s),Le=(t,e,n,r,s)=>t.tr(e,n,r,s),Cp=(t,e,n,r,s)=>t.ts(e,n,r,s),D=(t,e,n,r,s)=>t.tt(e,n,r,s),wn="WORD",md="UWORD",Db="ASCIINUMERICAL",Lb="ALPHANUMERICAL",yi="LOCALHOST",gd="TLD",yd="UTLD",Io="SCHEME",es="SLASH_SCHEME",Uu="NUM",bd="WS",Vu="NL",Ys="OPENBRACE",Xs="CLOSEBRACE",al="OPENBRACKET",cl="CLOSEBRACKET",dl="OPENPAREN",ul="CLOSEPAREN",hl="OPENANGLEBRACKET",fl="CLOSEANGLEBRACKET",pl="FULLWIDTHLEFTPAREN",ml="FULLWIDTHRIGHTPAREN",gl="LEFTCORNERBRACKET",yl="RIGHTCORNERBRACKET",bl="LEFTWHITECORNERBRACKET",xl="RIGHTWHITECORNERBRACKET",wl="FULLWIDTHLESSTHAN",kl="FULLWIDTHGREATERTHAN",vl="AMPERSAND",Sl="APOSTROPHE",Cl="ASTERISK",Fn="AT",El="BACKSLASH",Ml="BACKTICK",Al="CARET",Wn="COLON",Wu="COMMA",Tl="DOLLAR",sn="DOT",Nl="EQUALS",qu="EXCLAMATION",Lt="HYPHEN",Zs="PERCENT",_l="PIPE",Rl="PLUS",Ol="POUND",Qs="QUERY",Ku="QUOTE",Ib="FULLWIDTHMIDDLEDOT",Gu="SEMI",on="SLASH",ei="TILDE",Dl="UNDERSCORE",jb="EMOJI",Ll="SYM";var Pb=Object.freeze({__proto__:null,ALPHANUMERICAL:Lb,AMPERSAND:vl,APOSTROPHE:Sl,ASCIINUMERICAL:Db,ASTERISK:Cl,AT:Fn,BACKSLASH:El,BACKTICK:Ml,CARET:Al,CLOSEANGLEBRACKET:fl,CLOSEBRACE:Xs,CLOSEBRACKET:cl,CLOSEPAREN:ul,COLON:Wn,COMMA:Wu,DOLLAR:Tl,DOT:sn,EMOJI:jb,EQUALS:Nl,EXCLAMATION:qu,FULLWIDTHGREATERTHAN:kl,FULLWIDTHLEFTPAREN:pl,FULLWIDTHLESSTHAN:wl,FULLWIDTHMIDDLEDOT:Ib,FULLWIDTHRIGHTPAREN:ml,HYPHEN:Lt,LEFTCORNERBRACKET:gl,LEFTWHITECORNERBRACKET:bl,LOCALHOST:yi,NL:Vu,NUM:Uu,OPENANGLEBRACKET:hl,OPENBRACE:Ys,OPENBRACKET:al,OPENPAREN:dl,PERCENT:Zs,PIPE:_l,PLUS:Rl,POUND:Ol,QUERY:Qs,QUOTE:Ku,RIGHTCORNERBRACKET:yl,RIGHTWHITECORNERBRACKET:xl,SCHEME:Io,SEMI:Gu,SLASH:on,SLASH_SCHEME:es,SYM:Ll,TILDE:ei,TLD:gd,UNDERSCORE:Dl,UTLD:yd,UWORD:md,WORD:wn,WS:bd});const yn=/[a-z]/,Ps=new RegExp("\\p{L}","u"),yc=new RegExp("\\p{Emoji}","u"),bn=/\d/,bc=/\s/,Ep="\r",xc=`
129
- `,eA="️",tA="‍",wc="";let yo=null,bo=null;function nA(t=[]){const e={};kt.groups=e;const n=new kt;yo==null&&(yo=Mp(GM)),bo==null&&(bo=Mp(JM)),D(n,"'",Sl),D(n,"{",Ys),D(n,"}",Xs),D(n,"[",al),D(n,"]",cl),D(n,"(",dl),D(n,")",ul),D(n,"<",hl),D(n,">",fl),D(n,"(",pl),D(n,")",ml),D(n,"「",gl),D(n,"」",yl),D(n,"『",bl),D(n,"』",xl),D(n,"<",wl),D(n,">",kl),D(n,"&",vl),D(n,"*",Cl),D(n,"@",Fn),D(n,"`",Ml),D(n,"^",Al),D(n,":",Wn),D(n,",",Wu),D(n,"$",Tl),D(n,".",sn),D(n,"=",Nl),D(n,"!",qu),D(n,"-",Lt),D(n,"%",Zs),D(n,"|",_l),D(n,"+",Rl),D(n,"#",Ol),D(n,"?",Qs),D(n,'"',Ku),D(n,"/",on),D(n,";",Gu),D(n,"~",ei),D(n,"_",Dl),D(n,"\\",El),D(n,"・",Ib);const r=Le(n,bn,Uu,{[ud]:!0});Le(r,bn,r);const s=Le(r,yn,Db,{[Js]:!0}),i=Le(r,Ps,Lb,{[Us]:!0}),o=Le(n,yn,wn,{[hd]:!0});Le(o,bn,s),Le(o,yn,o),Le(s,bn,s),Le(s,yn,s);const l=Le(n,Ps,md,{[fd]:!0});Le(l,yn),Le(l,bn,i),Le(l,Ps,l),Le(i,bn,i),Le(i,yn),Le(i,Ps,i);const a=D(n,xc,Vu,{[gc]:!0}),c=D(n,Ep,bd,{[gc]:!0}),d=Le(n,bc,bd,{[gc]:!0});D(n,wc,d),D(c,xc,a),D(c,wc,d),Le(c,bc,d),D(d,Ep),D(d,xc),Le(d,bc,d),D(d,wc,d);const u=Le(n,yc,jb,{[Ob]:!0});D(u,"#"),Le(u,yc,u),D(u,eA,u);const h=D(u,tA);D(h,"#"),Le(h,yc,u);const f=[[yn,o],[bn,s]],p=[[yn,null],[Ps,l],[bn,i]];for(let g=0;g<yo.length;g++)Pn(n,yo[g],gd,wn,f);for(let g=0;g<bo.length;g++)Pn(n,bo[g],yd,md,p);vr(gd,{tld:!0,ascii:!0},e),vr(yd,{utld:!0,alpha:!0},e),Pn(n,"file",Io,wn,f),Pn(n,"mailto",Io,wn,f),Pn(n,"http",es,wn,f),Pn(n,"https",es,wn,f),Pn(n,"ftp",es,wn,f),Pn(n,"ftps",es,wn,f),vr(Io,{scheme:!0,ascii:!0},e),vr(es,{slashscheme:!0,ascii:!0},e),t=t.sort((g,y)=>g[0]>y[0]?1:-1);for(let g=0;g<t.length;g++){const y=t[g][0],w=t[g][1]?{[YM]:!0}:{[XM]:!0};y.indexOf("-")>=0?w[pd]=!0:yn.test(y)?bn.test(y)?w[Js]=!0:w[hd]=!0:w[ud]=!0,Cp(n,y,y,w)}return Cp(n,"localhost",yi,{ascii:!0}),n.jd=new kt(Ll),{start:n,tokens:Object.assign({groups:e},Pb)}}function Bb(t,e){const n=rA(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,s=[];let i=0,o=0;for(;o<r;){let l=t,a=null,c=0,d=null,u=-1,h=-1;for(;o<r&&(a=l.go(n[o]));)l=a,l.accepts()?(u=0,h=0,d=l):u>=0&&(u+=n[o].length,h++),c+=n[o].length,i+=n[o].length,o++;i-=u,o-=h,c-=u,s.push({t:d.t,v:e.slice(i-c,i),s:i-c,e:i})}return s}function rA(t){const e=[],n=t.length;let r=0;for(;r<n;){let s=t.charCodeAt(r),i,o=s<55296||s>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Pn(t,e,n,r,s){let i;const o=e.length;for(let l=0;l<o-1;l++){const a=e[l];t.j[a]?i=t.j[a]:(i=new kt(r),i.jr=s.slice(),t.j[a]=i),t=i}return i=new kt(n),i.jr=s.slice(),t.j[e[o-1]]=i,i}function Mp(t){const e=[],n=[];let r=0,s="0123456789";for(;r<t.length;){let i=0;for(;s.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+i),10);o>0;o--)n.pop();r+=i}else n.push(t[r]),r++}return e}const bi={defaultProtocol:"http",events:null,format:Ap,formatHref:Ap,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Ju(t,e=null){let n=Object.assign({},bi);t&&(n=Object.assign(n,t instanceof Ju?t.o:t));const r=n.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=s}Ju.prototype={o:bi,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let s=this.o[t];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:bi[t],typeof s=="function"&&r&&(s=s(e,n))):typeof s=="function"&&r&&(s=s(e,n.t,n)),s)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Ap(t){return t}function $b(t,e){this.t="token",this.v=t,this.tk=e}$b.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=bi.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),s=t.get("tagName",n,e),i=this.toFormattedString(t),o={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),d=t.getObj("attributes",n,e),u=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),d&&Object.assign(o,d),{tagName:s,attributes:o,content:i,eventListeners:u}}};function ma(t,e){class n extends $b{constructor(s,i){super(s,i),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const Tp=ma("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Np=ma("text"),sA=ma("nl"),xo=ma("url",{isLink:!0,toHref(t=bi.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==yi&&t[1].t===Wn}}),Dt=t=>new kt(t);function iA({groups:t}){const e=t.domain.concat([vl,Cl,Fn,El,Ml,Al,Tl,Nl,Lt,Uu,Zs,_l,Rl,Ol,on,Ll,ei,Dl]),n=[Sl,Wn,Wu,sn,qu,Zs,Qs,Ku,Gu,hl,fl,Ys,Xs,cl,al,dl,ul,pl,ml,gl,yl,bl,xl,wl,kl],r=[vl,Sl,Cl,El,Ml,Al,Tl,Nl,Lt,Ys,Xs,Zs,_l,Rl,Ol,Qs,on,Ll,ei,Dl],s=Dt(),i=D(s,ei);oe(i,r,i),oe(i,t.domain,i);const o=Dt(),l=Dt(),a=Dt();oe(s,t.domain,o),oe(s,t.scheme,l),oe(s,t.slashscheme,a),oe(o,r,i),oe(o,t.domain,o);const c=D(o,Fn);D(i,Fn,c),D(l,Fn,c),D(a,Fn,c);const d=D(i,sn);oe(d,r,i),oe(d,t.domain,i);const u=Dt();oe(c,t.domain,u),oe(u,t.domain,u);const h=D(u,sn);oe(h,t.domain,u);const f=Dt(Tp);oe(h,t.tld,f),oe(h,t.utld,f),D(c,yi,f);const p=D(u,Lt);D(p,Lt,p),oe(p,t.domain,u),oe(f,t.domain,u),D(f,sn,h),D(f,Lt,p);const g=D(f,Wn);oe(g,t.numeric,Tp);const y=D(o,Lt),b=D(o,sn);D(y,Lt,y),oe(y,t.domain,o),oe(b,r,i),oe(b,t.domain,o);const w=Dt(xo);oe(b,t.tld,w),oe(b,t.utld,w),oe(w,t.domain,o),oe(w,r,i),D(w,sn,b),D(w,Lt,y),D(w,Fn,c);const A=D(w,Wn),S=Dt(xo);oe(A,t.numeric,S);const M=Dt(xo),x=Dt();oe(M,e,M),oe(M,n,x),oe(x,e,M),oe(x,n,x),D(w,on,M),D(S,on,M);const k=D(l,Wn),v=D(a,Wn),T=D(v,on),N=D(T,on);oe(l,t.domain,o),D(l,sn,b),D(l,Lt,y),oe(a,t.domain,o),D(a,sn,b),D(a,Lt,y),oe(k,t.domain,M),D(k,on,M),D(k,Qs,M),oe(N,t.domain,M),oe(N,e,M),D(N,on,M);const H=[[Ys,Xs],[al,cl],[dl,ul],[hl,fl],[pl,ml],[gl,yl],[bl,xl],[wl,kl]];for(let V=0;V<H.length;V++){const[$,I]=H[V],j=D(M,$);D(x,$,j),D(j,I,M);const Q=Dt(xo);oe(j,e,Q);const ie=Dt();oe(j,n),oe(Q,e,Q),oe(Q,n,ie),oe(ie,e,Q),oe(ie,n,ie),D(Q,I,M),D(ie,I,M)}return D(s,yi,w),D(s,Vu,sA),{start:s,tokens:Pb}}function oA(t,e,n){let r=n.length,s=0,i=[],o=[];for(;s<r;){let l=t,a=null,c=null,d=0,u=null,h=-1;for(;s<r&&!(a=l.go(n[s].t));)o.push(n[s++]);for(;s<r&&(c=a||l.go(n[s].t));)a=null,l=c,l.accepts()?(h=0,u=l):h>=0&&h++,s++,d++;if(h<0)s-=d,s<r&&(o.push(n[s]),s++);else{o.length>0&&(i.push(kc(Np,e,o)),o=[]),s-=h,d-=h;const f=u.t,p=n.slice(s-d,s);i.push(kc(f,e,p))}}return o.length>0&&i.push(kc(Np,e,o)),i}function kc(t,e,n){const r=n[0].s,s=n[n.length-1].e,i=e.slice(r,s);return new t(i,n)}const lA=typeof console<"u"&&console&&console.warn||(()=>{}),aA="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Ne={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function cA(){return kt.groups={},Ne.scanner=null,Ne.parser=null,Ne.tokenQueue=[],Ne.pluginQueue=[],Ne.customSchemes=[],Ne.initialized=!1,Ne}function _p(t,e=!1){if(Ne.initialized&&lA(`linkifyjs: already initialized - will not register custom scheme "${t}" ${aA}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
132
+ `):""}),FR=De.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",fe(this.options.HTMLAttributes,t)]},renderText(){return`
133
+ `},renderMarkdown:()=>`
134
+ `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&o){const d=a.filter(h=>l.includes(h.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),bw=De.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,fe(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Ud({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),UR=bw,VR=De.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",fe(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!kT(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return ux(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:o,dispatch:l})=>{if(l){const{$to:a}=o.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?o.setSelection(Q.create(o.doc,a.pos+1)):a.nodeAfter.isBlock?o.setSelection(Y.create(o.doc,a.pos)):o.setSelection(Q.create(o.doc,a.pos));else{const u=i.schema.nodes[this.options.nextNodeType]||a.parent.type.contentMatch.defaultType,d=u?.create();d&&(o.insert(c,d),o.setSelection(Q.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Tx({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),WR=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,qR=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,KR=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,JR=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,GR=dn.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",fe(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[qr({find:WR,type:this.type}),qr({find:KR,type:this.type})]},addPasteRules(){return[mr({find:qR,type:this.type}),mr({find:JR,type:this.type})]}});const YR="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",XR="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Yd="numeric",Xd="ascii",Zd="alpha",Fi="asciinumeric",Li="alphanumeric",Qd="domain",xw="emoji",ZR="scheme",QR="slashscheme",Fu="whitespace";function e_(t,e){return t in e||(e[t]=[]),e[t]}function Dr(t,e,n){e[Yd]&&(e[Fi]=!0,e[Li]=!0),e[Xd]&&(e[Fi]=!0,e[Zd]=!0),e[Fi]&&(e[Li]=!0),e[Zd]&&(e[Li]=!0),e[Li]&&(e[Qd]=!0),e[xw]&&(e[Qd]=!0);for(const r in e){const s=e_(r,n);s.indexOf(t)<0&&s.push(t)}}function t_(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Lt(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Lt.groups={};Lt.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],i=e.jr[r][1];if(i&&s.test(t))return i}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||Lt.groups;let s;return e&&e.j?s=e:(s=new Lt(e),n&&r&&Dr(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const i=t.length;if(!i)return s;for(let o=0;o<i-1;o++)s=s.tt(t[o]);return s.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||Lt.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const i=e;let o,l=s.go(t);if(l?(o=new Lt,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new Lt,i){if(r)if(o.t&&typeof o.t=="string"){const a=Object.assign(t_(o.t,r),n);Dr(i,a,r)}else n&&Dr(i,n,r);o.t=i}return s.j[t]=o,o}};const de=(t,e,n,r,s)=>t.ta(e,n,r,s),Pe=(t,e,n,r,s)=>t.tr(e,n,r,s),Tg=(t,e,n,r,s)=>t.ts(e,n,r,s),$=(t,e,n,r,s)=>t.tt(e,n,r,s),On="WORD",eh="UWORD",ww="ASCIINUMERICAL",kw="ALPHANUMERICAL",ho="LOCALHOST",th="TLD",nh="UTLD",Hl="SCHEME",ks="SLASH_SCHEME",Rf="NUM",rh="WS",_f="NL",Ui="OPENBRACE",Vi="CLOSEBRACE",ya="OPENBRACKET",ba="CLOSEBRACKET",xa="OPENPAREN",wa="CLOSEPAREN",ka="OPENANGLEBRACKET",va="CLOSEANGLEBRACKET",Sa="FULLWIDTHLEFTPAREN",Ca="FULLWIDTHRIGHTPAREN",Ea="LEFTCORNERBRACKET",Aa="RIGHTCORNERBRACKET",Ma="LEFTWHITECORNERBRACKET",Ta="RIGHTWHITECORNERBRACKET",Na="FULLWIDTHLESSTHAN",Ra="FULLWIDTHGREATERTHAN",_a="AMPERSAND",Oa="APOSTROPHE",Da="ASTERISK",nr="AT",La="BACKSLASH",Ia="BACKTICK",Pa="CARET",Lr="COLON",Of="COMMA",ja="DOLLAR",yn="DOT",$a="EQUALS",Df="EXCLAMATION",Wt="HYPHEN",Wi="PERCENT",Ba="PIPE",za="PLUS",Ha="POUND",qi="QUERY",Lf="QUOTE",vw="FULLWIDTHMIDDLEDOT",If="SEMI",bn="SLASH",Ki="TILDE",Fa="UNDERSCORE",Sw="EMOJI",Ua="SYM";var Cw=Object.freeze({__proto__:null,ALPHANUMERICAL:kw,AMPERSAND:_a,APOSTROPHE:Oa,ASCIINUMERICAL:ww,ASTERISK:Da,AT:nr,BACKSLASH:La,BACKTICK:Ia,CARET:Pa,CLOSEANGLEBRACKET:va,CLOSEBRACE:Vi,CLOSEBRACKET:ba,CLOSEPAREN:wa,COLON:Lr,COMMA:Of,DOLLAR:ja,DOT:yn,EMOJI:Sw,EQUALS:$a,EXCLAMATION:Df,FULLWIDTHGREATERTHAN:Ra,FULLWIDTHLEFTPAREN:Sa,FULLWIDTHLESSTHAN:Na,FULLWIDTHMIDDLEDOT:vw,FULLWIDTHRIGHTPAREN:Ca,HYPHEN:Wt,LEFTCORNERBRACKET:Ea,LEFTWHITECORNERBRACKET:Ma,LOCALHOST:ho,NL:_f,NUM:Rf,OPENANGLEBRACKET:ka,OPENBRACE:Ui,OPENBRACKET:ya,OPENPAREN:xa,PERCENT:Wi,PIPE:Ba,PLUS:za,POUND:Ha,QUERY:qi,QUOTE:Lf,RIGHTCORNERBRACKET:Aa,RIGHTWHITECORNERBRACKET:Ta,SCHEME:Hl,SEMI:If,SLASH:bn,SLASH_SCHEME:ks,SYM:Ua,TILDE:Ki,TLD:th,UNDERSCORE:Fa,UTLD:nh,UWORD:eh,WORD:On,WS:rh});const Nn=/[a-z]/,mi=new RegExp("\\p{L}","u"),Uu=new RegExp("\\p{Emoji}","u"),Rn=/\d/,Vu=/\s/,Ng="\r",Wu=`
135
+ `,n_="️",r_="‍",qu="";let gl=null,yl=null;function s_(t=[]){const e={};Lt.groups=e;const n=new Lt;gl==null&&(gl=Rg(YR)),yl==null&&(yl=Rg(XR)),$(n,"'",Oa),$(n,"{",Ui),$(n,"}",Vi),$(n,"[",ya),$(n,"]",ba),$(n,"(",xa),$(n,")",wa),$(n,"<",ka),$(n,">",va),$(n,"(",Sa),$(n,")",Ca),$(n,"「",Ea),$(n,"」",Aa),$(n,"『",Ma),$(n,"』",Ta),$(n,"<",Na),$(n,">",Ra),$(n,"&",_a),$(n,"*",Da),$(n,"@",nr),$(n,"`",Ia),$(n,"^",Pa),$(n,":",Lr),$(n,",",Of),$(n,"$",ja),$(n,".",yn),$(n,"=",$a),$(n,"!",Df),$(n,"-",Wt),$(n,"%",Wi),$(n,"|",Ba),$(n,"+",za),$(n,"#",Ha),$(n,"?",qi),$(n,'"',Lf),$(n,"/",bn),$(n,";",If),$(n,"~",Ki),$(n,"_",Fa),$(n,"\\",La),$(n,"・",vw);const r=Pe(n,Rn,Rf,{[Yd]:!0});Pe(r,Rn,r);const s=Pe(r,Nn,ww,{[Fi]:!0}),i=Pe(r,mi,kw,{[Li]:!0}),o=Pe(n,Nn,On,{[Xd]:!0});Pe(o,Rn,s),Pe(o,Nn,o),Pe(s,Rn,s),Pe(s,Nn,s);const l=Pe(n,mi,eh,{[Zd]:!0});Pe(l,Nn),Pe(l,Rn,i),Pe(l,mi,l),Pe(i,Rn,i),Pe(i,Nn),Pe(i,mi,i);const a=$(n,Wu,_f,{[Fu]:!0}),c=$(n,Ng,rh,{[Fu]:!0}),u=Pe(n,Vu,rh,{[Fu]:!0});$(n,qu,u),$(c,Wu,a),$(c,qu,u),Pe(c,Vu,u),$(u,Ng),$(u,Wu),Pe(u,Vu,u),$(u,qu,u);const d=Pe(n,Uu,Sw,{[xw]:!0});$(d,"#"),Pe(d,Uu,d),$(d,n_,d);const h=$(d,r_);$(h,"#"),Pe(h,Uu,d);const f=[[Nn,o],[Rn,s]],p=[[Nn,null],[mi,l],[Rn,i]];for(let m=0;m<gl.length;m++)Gn(n,gl[m],th,On,f);for(let m=0;m<yl.length;m++)Gn(n,yl[m],nh,eh,p);Dr(th,{tld:!0,ascii:!0},e),Dr(nh,{utld:!0,alpha:!0},e),Gn(n,"file",Hl,On,f),Gn(n,"mailto",Hl,On,f),Gn(n,"http",ks,On,f),Gn(n,"https",ks,On,f),Gn(n,"ftp",ks,On,f),Gn(n,"ftps",ks,On,f),Dr(Hl,{scheme:!0,ascii:!0},e),Dr(ks,{slashscheme:!0,ascii:!0},e),t=t.sort((m,y)=>m[0]>y[0]?1:-1);for(let m=0;m<t.length;m++){const y=t[m][0],x=t[m][1]?{[ZR]:!0}:{[QR]:!0};y.indexOf("-")>=0?x[Qd]=!0:Nn.test(y)?Rn.test(y)?x[Fi]=!0:x[Xd]=!0:x[Yd]=!0,Tg(n,y,y,x)}return Tg(n,"localhost",ho,{ascii:!0}),n.jd=new Lt(Ua),{start:n,tokens:Object.assign({groups:e},Cw)}}function Ew(t,e){const n=i_(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,s=[];let i=0,o=0;for(;o<r;){let l=t,a=null,c=0,u=null,d=-1,h=-1;for(;o<r&&(a=l.go(n[o]));)l=a,l.accepts()?(d=0,h=0,u=l):d>=0&&(d+=n[o].length,h++),c+=n[o].length,i+=n[o].length,o++;i-=d,o-=h,c-=d,s.push({t:u.t,v:e.slice(i-c,i),s:i-c,e:i})}return s}function i_(t){const e=[],n=t.length;let r=0;for(;r<n;){let s=t.charCodeAt(r),i,o=s<55296||s>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Gn(t,e,n,r,s){let i;const o=e.length;for(let l=0;l<o-1;l++){const a=e[l];t.j[a]?i=t.j[a]:(i=new Lt(r),i.jr=s.slice(),t.j[a]=i),t=i}return i=new Lt(n),i.jr=s.slice(),t.j[e[o-1]]=i,i}function Rg(t){const e=[],n=[];let r=0,s="0123456789";for(;r<t.length;){let i=0;for(;s.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+i),10);o>0;o--)n.pop();r+=i}else n.push(t[r]),r++}return e}const fo={defaultProtocol:"http",events:null,format:_g,formatHref:_g,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Pf(t,e=null){let n=Object.assign({},fo);t&&(n=Object.assign(n,t instanceof Pf?t.o:t));const r=n.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=s}Pf.prototype={o:fo,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let s=this.o[t];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:fo[t],typeof s=="function"&&r&&(s=s(e,n))):typeof s=="function"&&r&&(s=s(e,n.t,n)),s)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function _g(t){return t}function Aw(t,e){this.t="token",this.v=t,this.tk=e}Aw.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=fo.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),s=t.get("tagName",n,e),i=this.toFormattedString(t),o={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),u&&Object.assign(o,u),{tagName:s,attributes:o,content:i,eventListeners:d}}};function Rc(t,e){class n extends Aw{constructor(s,i){super(s,i),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const o_=Rc("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Og=Rc("text"),l_=Rc("nl"),bl=Rc("url",{isLink:!0,toHref(t=fo.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==ho&&t[1].t===Lr}}),Vt=t=>new Lt(t);function a_({groups:t}){const e=t.domain.concat([_a,Da,nr,La,Ia,Pa,ja,$a,Wt,Rf,Wi,Ba,za,Ha,bn,Ua,Ki,Fa]),n=[Oa,Lr,Of,yn,Df,Wi,qi,Lf,If,ka,va,Ui,Vi,ba,ya,xa,wa,Sa,Ca,Ea,Aa,Ma,Ta,Na,Ra],r=[_a,Oa,Da,La,Ia,Pa,ja,$a,Wt,Ui,Vi,Wi,Ba,za,Ha,qi,bn,Ua,Ki,Fa],s=Vt(),i=$(s,Ki);de(i,r,i),de(i,t.domain,i);const o=Vt(),l=Vt(),a=Vt();de(s,t.domain,o),de(s,t.scheme,l),de(s,t.slashscheme,a),de(o,r,i),de(o,t.domain,o);const c=$(o,nr);$(i,nr,c),$(l,nr,c),$(a,nr,c);const u=$(i,yn);de(u,r,i),de(u,t.domain,i);const d=Vt();de(c,t.domain,d),de(d,t.domain,d);const h=$(d,yn);de(h,t.domain,d);const f=Vt(o_);de(h,t.tld,f),de(h,t.utld,f),$(c,ho,f);const p=$(d,Wt);$(p,Wt,p),de(p,t.domain,d),de(f,t.domain,d),$(f,yn,h),$(f,Wt,p);const m=$(o,Wt),y=$(o,yn);$(m,Wt,m),de(m,t.domain,o),de(y,r,i),de(y,t.domain,o);const b=Vt(bl);de(y,t.tld,b),de(y,t.utld,b),de(b,t.domain,o),de(b,r,i),$(b,yn,y),$(b,Wt,m),$(b,nr,c);const x=$(b,Lr),w=Vt(bl);de(x,t.numeric,w);const k=Vt(bl),T=Vt();de(k,e,k),de(k,n,T),de(T,e,k),de(T,n,T),$(b,bn,k),$(w,bn,k);const S=$(l,Lr),v=$(a,Lr),A=$(v,bn),C=$(A,bn);de(l,t.domain,o),$(l,yn,y),$(l,Wt,m),de(a,t.domain,o),$(a,yn,y),$(a,Wt,m),de(S,t.domain,k),$(S,bn,k),$(S,qi,k),de(C,t.domain,k),de(C,e,k),$(C,bn,k);const N=[[Ui,Vi],[ya,ba],[xa,wa],[ka,va],[Sa,Ca],[Ea,Aa],[Ma,Ta],[Na,Ra]];for(let D=0;D<N.length;D++){const[z,L]=N[D],_=$(k,z);$(T,z,_);const V=Vt(bl);de(_,e,V);const ee=Vt();de(_,n,ee),$(_,L,k),de(V,e,V),de(V,n,ee),de(ee,e,V),de(ee,n,ee),$(V,L,k),$(ee,L,k)}return $(s,ho,b),$(s,_f,l_),{start:s,tokens:Cw}}function c_(t,e,n){let r=n.length,s=0,i=[],o=[];for(;s<r;){let l=t,a=null,c=null,u=0,d=null,h=-1;for(;s<r&&!(a=l.go(n[s].t));)o.push(n[s++]);for(;s<r&&(c=a||l.go(n[s].t));)a=null,l=c,l.accepts()?(h=0,d=l):h>=0&&h++,s++,u++;if(h<0)s-=u,s<r&&(o.push(n[s]),s++);else{o.length>0&&(i.push(Ku(Og,e,o)),o=[]),s-=h,u-=h;const f=d.t,p=n.slice(s-u,s);i.push(Ku(f,e,p))}}return o.length>0&&i.push(Ku(Og,e,o)),i}function Ku(t,e,n){const r=n[0].s,s=n[n.length-1].e,i=e.slice(r,s);return new t(i,n)}const u_=typeof console<"u"&&console&&console.warn||(()=>{}),d_="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Re={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function h_(){return Lt.groups={},Re.scanner=null,Re.parser=null,Re.tokenQueue=[],Re.pluginQueue=[],Re.customSchemes=[],Re.initialized=!1,Re}function Dg(t,e=!1){if(Re.initialized&&u_(`linkifyjs: already initialized - will not register custom scheme "${t}" ${d_}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
130
136
  1. Must only contain digits, lowercase ASCII letters or "-"
131
137
  2. Cannot start or end with "-"
132
- 3. "-" cannot repeat`);Ne.customSchemes.push([t,e])}function dA(){Ne.scanner=nA(Ne.customSchemes);for(let t=0;t<Ne.tokenQueue.length;t++)Ne.tokenQueue[t][1]({scanner:Ne.scanner});Ne.parser=iA(Ne.scanner.tokens);for(let t=0;t<Ne.pluginQueue.length;t++)Ne.pluginQueue[t][1]({scanner:Ne.scanner,parser:Ne.parser});return Ne.initialized=!0,Ne}function Yu(t){return Ne.initialized||dA(),oA(Ne.parser.start,t,Bb(Ne.scanner.start,t))}Yu.scan=Bb;function Hb(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new Ju(n),s=Yu(t),i=[];for(let o=0;o<s.length;o++){const l=s[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var Xu="[\0-   ᠎ -\u2029  ]",uA=new RegExp(Xu),hA=new RegExp(`${Xu}$`),fA=new RegExp(Xu,"g");function pA(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function mA(t){return new me({key:new ye("autolink"),appendTransaction:(e,n,r)=>{const s=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,l=$y(n.doc,[...e]);if(Ky(l).forEach(({newRange:c})=>{const d=aC(r.doc,c,f=>f.isTextblock);let u,h;if(d.length>1)u=d[0],h=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ");else if(d.length){const f=r.doc.textBetween(c.from,c.to," "," ");if(!hA.test(f))return;u=d[0],h=r.doc.textBetween(u.pos,c.to,void 0," ")}if(u&&h){const f=h.split(uA).filter(Boolean);if(f.length<=0)return!1;const p=f[f.length-1],g=u.pos+h.lastIndexOf(p);if(!p)return!1;const y=Yu(p).map(b=>b.toObject(t.defaultProtocol));if(!pA(y))return!1;y.filter(b=>b.isLink).map(b=>({...b,from:g+b.start+1,to:g+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{_u(b.from,b.to,r.doc).some(w=>w.mark.type===t.type)||o.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!o.steps.length)return o}})}function gA(t){return new me({key:new ye("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,i;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{let d=r.target;const u=[];for(;d.nodeName!=="DIV";)u.push(d),d=d.parentNode;o=u.find(h=>h.nodeName==="A")}if(!o)return!1;const l=qy(e.state,t.type.name),a=(s=o?.href)!=null?s:l.href,c=(i=o?.target)!=null?i:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),o&&a?(window.open(a,c),!0):!1}}})}function yA(t){return new me({key:new ye("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:i}=e,{selection:o}=i,{empty:l}=o;if(l)return!1;let a="";r.content.forEach(d=>{a+=d.textContent});const c=Hb(a,{defaultProtocol:t.defaultProtocol}).find(d=>d.isLink&&d.value===a);return!a||!c||s!==void 0&&!s(c.href)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function gr(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace(fA,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var zb=Zt.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){_p(t);return}_p(t.scheme,t.optionalSlashes)})},onDestroy(){cA()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!gr(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!gr(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!gr(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",pe(this.options.HTMLAttributes,t),0]:["a",pe(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n;const r=((n=t.attrs)==null?void 0:n.href)||"";return`[${e.renderChildren(t)}](${r})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!gr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!gr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[sr({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,s=Hb(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!gr(o,n),protocols:n,defaultProtocol:r}));s.length&&s.forEach(i=>{this.options.shouldAutoLink(i.value)&&e.push({text:i.value,data:{href:i.href},index:i.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(mA({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!gr(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(gA({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(yA({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),bA=zb,xA=Object.defineProperty,wA=(t,e)=>{for(var n in e)xA(t,n,{get:e[n],enumerable:!0})},kA="listItem",Rp="textStyle",Op=/^\s*([-+*])\s$/,Zu=Oe.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",pe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
133
- `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(kA,this.editor.getAttributes(Rp)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=ms({find:Op,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ms({find:Op,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Rp),editor:this.editor})),[t]}}),Fb=Oe.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",pe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(s=>s.type==="paragraph"))n=e.parseChildren(t.tokens);else{const s=t.tokens[0];if(s&&s.type==="text"&&s.tokens&&s.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(s.tokens)}],t.tokens.length>1){const o=t.tokens.slice(1),l=e.parseChildren(o);n.push(...l)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>Lu(t,e,r=>r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${r.index+1}. `:"- ",n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),vA={};wA(vA,{findListItemPos:()=>$i,getNextListDepth:()=>Qu,handleBackspace:()=>xd,handleDelete:()=>wd,hasListBefore:()=>Ub,hasListItemAfter:()=>SA,hasListItemBefore:()=>Vb,listItemHasSubList:()=>Wb,nextListIsDeeper:()=>qb,nextListIsHigher:()=>Kb});var $i=(t,e)=>{const{$from:n}=e.selection,r=Ke(t,e.schema);let s=null,i=n.depth,o=n.pos,l=null;for(;i>0&&l===null;)s=n.node(i),s.type===r?l=i:(i-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},Qu=(t,e)=>{const n=$i(t,e);if(!n)return!1;const[,r]=yC(e,t,n.$pos.pos+4);return r},Ub=(t,e,n)=>{const{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),i=t.doc.resolve(s).node();return!(!i||!n.includes(i.type.name))},Vb=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((n=s.nodeBefore)==null?void 0:n.type.name)!==t)},Wb=(t,e,n)=>{if(!n)return!1;const r=Ke(t,e.schema);let s=!1;return n.descendants(i=>{i.type===r&&(s=!0)}),s},xd=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!rr(t.state,e)&&Ub(t.state,e,n)){const{$anchor:l}=t.state.selection,a=t.state.doc.resolve(l.before()-1),c=[];a.node().descendants((h,f)=>{h.type.name===e&&c.push({node:h,pos:f})});const d=c.at(-1);if(!d)return!1;const u=t.state.doc.resolve(a.start()+d.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},u.end()).joinForward().run()}if(!rr(t.state,e)||!kC(t.state))return!1;const r=$i(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),o=Wb(e,t.state,i);return Vb(e,t.state)&&!o?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},qb=(t,e)=>{const n=Qu(t,e),r=$i(t,e);return!r||!n?!1:n>r.depth},Kb=(t,e)=>{const n=Qu(t,e),r=$i(t,e);return!r||!n?!1:n<r.depth},wd=(t,e)=>{if(!rr(t.state,e)||!wC(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:qb(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Kb(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},SA=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((n=s.nodeAfter)==null?void 0:n.type.name)!==t)},Gb=de.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&wd(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&wd(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&xd(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&xd(t,n,r)&&(e=!0)}),e}}}}),Dp=/^(\s*)(\d+)\.\s+(.*)$/,CA=/^\s/;function EA(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],i=s.match(Dp);if(!i)break;const[,o,l,a]=i,c=o.length;let d=a,u=n+1;const h=[s];for(;u<t.length;){const f=t[u];if(f.match(Dp))break;if(f.trim()==="")h.push(f),d+=`
134
- `,u+=1;else if(f.match(CA))h.push(f),d+=`
135
- ${f.slice(c+2)}`,u+=1;else break}e.push({indent:c,number:parseInt(l,10),content:d.trim(),raw:h.join(`
136
- `)}),r=u,n=u}return[e,r]}function Jb(t,e,n){var r;const s=[];let i=0;for(;i<t.length;){const o=t[i];if(o.indent===e){const l=o.content.split(`
137
- `),a=((r=l[0])==null?void 0:r.trim())||"",c=[];a&&c.push({type:"paragraph",raw:a,tokens:n.inlineTokens(a)});const d=l.slice(1).join(`
138
- `).trim();if(d){const f=n.blockTokens(d);c.push(...f)}let u=i+1;const h=[];for(;u<t.length&&t[u].indent>e;)h.push(t[u]),u+=1;if(h.length>0){const f=Math.min(...h.map(g=>g.indent)),p=Jb(h,f,n);c.push({type:"list",ordered:!0,start:h[0].number,items:p,raw:h.map(g=>g.raw).join(`
139
- `)})}s.push({type:"list_item",raw:o.raw,tokens:c}),i=u}else i+=1}return s}function MA(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const i=e.parseChildren([s]);r.push({type:"paragraph",content:i})}else{const i=e.parseChildren([s]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var AA="listItem",Lp="textStyle",Ip=/^(\d+)\.\s$/,eh=Oe.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",pe(this.options.HTMLAttributes,n),0]:["ol",pe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?MA(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
138
+ 3. "-" cannot repeat`);Re.customSchemes.push([t,e])}function f_(){Re.scanner=s_(Re.customSchemes);for(let t=0;t<Re.tokenQueue.length;t++)Re.tokenQueue[t][1]({scanner:Re.scanner});Re.parser=a_(Re.scanner.tokens);for(let t=0;t<Re.pluginQueue.length;t++)Re.pluginQueue[t][1]({scanner:Re.scanner,parser:Re.parser});return Re.initialized=!0,Re}function jf(t){return Re.initialized||f_(),c_(Re.parser.start,t,Ew(Re.scanner.start,t))}jf.scan=Ew;function Mw(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new Pf(n),s=jf(t),i=[];for(let o=0;o<s.length;o++){const l=s[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&i.push(l.toFormattedObject(r))}return i}var $f="[\0-   ᠎ -\u2029  ]",p_=new RegExp($f),m_=new RegExp(`${$f}$`),g_=new RegExp($f,"g");function y_(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function b_(t){return new me({key:new ge("autolink"),appendTransaction:(e,n,r)=>{const s=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!s||i)return;const{tr:o}=r,l=tx(n.doc,[...e]);if(cx(l).forEach(({newRange:c})=>{const u=wM(r.doc,c,f=>f.isTextblock);let d,h;if(u.length>1)d=u[0],h=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){const f=r.doc.textBetween(c.from,c.to," "," ");if(!m_.test(f))return;d=u[0],h=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&h){const f=h.split(p_).filter(Boolean);if(f.length<=0)return!1;const p=f[f.length-1],m=d.pos+h.lastIndexOf(p);if(!p)return!1;const y=jf(p).map(b=>b.toObject(t.defaultProtocol));if(!y_(y))return!1;y.filter(b=>b.isLink).map(b=>({...b,from:m+b.start+1,to:m+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{ff(b.from,b.to,r.doc).some(x=>x.mark.type===t.type)||o.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!o.steps.length)return o}})}function x_(t){return new me({key:new ge("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,i;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{const a=r.target;if(!a)return!1;const c=t.editor.view.dom;o=a.closest("a"),o&&!c.contains(o)&&(o=null)}if(!o)return!1;let l=!1;if(t.enableClickSelection&&(l=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const a=ax(e.state,t.type.name),c=(s=o.href)!=null?s:a.href,u=(i=o.target)!=null?i:a.target;c&&(window.open(c,u),l=!0)}return l}}})}function w_(t){return new me({key:new ge("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:i}=e,{selection:o}=i,{empty:l}=o;if(l)return!1;let a="";r.content.forEach(u=>{a+=u.textContent});const c=Mw(a,{defaultProtocol:t.defaultProtocol}).find(u=>u.isLink&&u.value===a);return!a||!c||s!==void 0&&!s(c.value)?!1:t.editor.commands.setMark(t.type,{href:c.href})}}})}function Mr(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace(g_,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Tw=dn.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){Dg(t);return}Dg(t.scheme,t.optionalSlashes)})},onDestroy(){h_()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Mr(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const s=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Mr(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Mr(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",fe(this.options.HTMLAttributes,t),0]:["a",fe(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,s,i;const o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",l=(i=(s=t.attrs)==null?void 0:s.title)!=null?i:"",a=e.renderChildren(t);return l?`[${a}](${o} "${l}")`:`[${a}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Mr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Mr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[mr({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,s=Mw(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:o=>!!Mr(o,n),protocols:n,defaultProtocol:r}));s.length&&s.forEach(i=>{this.options.shouldAutoLink(i.value)&&e.push({text:i.value,data:{href:i.href},index:i.start})})}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(b_({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!Mr(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(x_({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(w_({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),k_=Tw,v_=Object.defineProperty,S_=(t,e)=>{for(var n in e)v_(t,n,{get:e[n],enumerable:!0})},C_="listItem",Lg="textStyle",Ig=/^\s*([-+*])\s$/,Bf=De.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",fe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
139
+ `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(C_,this.editor.getAttributes(Lg)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=$s({find:Ig,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=$s({find:Ig,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Lg),editor:this.editor})),[t]}}),E_=(t,e,n)=>{const{selection:r}=t;if(!r.empty)return null;const{$from:s}=r;if(!s.parent.isTextblock||s.parentOffset!==s.parent.content.size)return null;let i=-1;for(let f=s.depth;f>0;f-=1)if(s.node(f).type.name===e){i=f;break}if(i<0)return null;const o=s.node(i),l=s.index(i);if(l+1>=o.childCount)return null;const a=o.child(l+1);if(!n.includes(a.type.name))return null;const c=t.schema.nodes[e];let u=!1;if(a.forEach(f=>{f.type===c&&f.childCount>1&&(u=!0)}),!u)return null;const d=t.doc.resolve(s.after()).nodeAfter;if(!d||!n.includes(d.type.name))return null;const h=[];return d.forEach(f=>{h.push(f)}),h.length===0?null:{listItemDepth:i,nestedList:d,nestedListPos:s.after(),insertPos:s.after(i),items:h}},A_=(t,e,n,r)=>{const s=E_(t,n,r);if(!s)return!1;const{selection:i}=t,{nestedList:o,nestedListPos:l,insertPos:a,items:c}=s,u=t.tr;u.delete(l,l+o.nodeSize);const d=u.mapping.map(a);return u.insert(d,j.from(c)),u.setSelection(i.map(u.doc,u.mapping)),e&&e(u),!0},M_=(t,e,n)=>A_(t.state,t.view.dispatch,e,n),Nw=(t,e)=>ce.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const n=()=>M_(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}});function T_(t){var e,n;const r=(e=t.tokens)==null?void 0:e[0];return!!(t.text&&((n=t.tokens)==null?void 0:n.length)===1&&r?.type==="list"&&r.ordered&&r.raw===t.text)}function N_(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}var Rw=De.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",fe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];const r=(n=e.parseBlockChildren)!=null?n:e.parseChildren;let s=[];if(t.tokens&&t.tokens.length>0){if(T_(t))return{type:"listItem",content:[{type:"paragraph",content:N_(t.text||"",e)}]};if(t.tokens.some(o=>o.type==="paragraph"))s=r(t.tokens);else{const o=t.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(s=[{type:"paragraph",content:e.parseInline(o.tokens)}],t.tokens.length>1){const a=t.tokens.slice(1),c=r(a);s.push(...c)}}else s=r(t.tokens)}}return s.length===0&&(s=[{type:"paragraph",content:[]}]),{type:"listItem",content:s}},renderMarkdown:(t,e,n)=>bf(t,e,r=>{var s,i;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((i=(s=r.meta)==null?void 0:s.parentAttrs)==null?void 0:i.start)||1)+r.index}. `:"- "},n),addExtensions(){return[Nw(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),R_={};S_(R_,{findListItemPos:()=>_c,getNextListDepth:()=>zf,handleBackspace:()=>sh,handleDelete:()=>ih,hasListBefore:()=>_w,hasListItemAfter:()=>__,hasListItemBefore:()=>O_,listItemHasSubList:()=>D_,nextListIsDeeper:()=>Ow,nextListIsHigher:()=>Dw});var _c=(t,e)=>{const{$from:n}=e.selection,r=Ke(t,e.schema);let s=null,i=n.depth,o=n.pos,l=null;for(;i>0&&l===null;)s=n.node(i),s.type===r?l=i:(i-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},zf=(t,e)=>{const n=_c(t,e);if(!n)return!1;const[,r]=RM(e,t,n.$pos.pos+4);return r},_w=(t,e,n)=>{const{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),i=t.doc.resolve(s).node();return!(!i||!n.includes(i.type.name))},sh=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!pr(t.state,e)&&_w(t.state,e,n)){const{$anchor:r}=t.state.selection,s=t.state.doc.resolve(r.before()-1),i=[];s.node().descendants((a,c)=>{a.type.name===e&&i.push({node:a,pos:c})});const o=i.at(-1);if(!o)return!1;const l=t.state.doc.resolve(s.start()+o.pos+1);return t.chain().cut({from:r.start()-1,to:r.end()+1},l.end()).joinForward().run()}return!pr(t.state,e)||!LM(t.state)?!1:t.chain().liftListItem(e).run()},Ow=(t,e)=>{const n=zf(t,e),r=_c(t,e);return!r||!n?!1:n>r.depth},Dw=(t,e)=>{const n=zf(t,e),r=_c(t,e);return!r||!n?!1:n<r.depth},ih=(t,e)=>{if(!pr(t.state,e)||!DM(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:Ow(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Dw(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},__=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((n=s.nodeAfter)==null?void 0:n.type.name)!==t)},O_=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((n=s.nodeBefore)==null?void 0:n.type.name)!==t)},D_=(t,e,n)=>{if(!n)return!1;const r=Ke(t,e.schema);let s=!1;return n.descendants(i=>{i.type===r&&(s=!0)}),s},Lw=ce.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&ih(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&ih(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&sh(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&sh(t,n,r)&&(e=!0)}),e}}}}),Pg=/^(\s*)(\d+)\.\s+(.*)$/,L_=/^\s/;function I_(t){const e=t.trimStart();return/^[-+*]\s+/.test(e)||/^\d+\.\s+/.test(e)||/^>\s?/.test(e)||/^```/.test(e)||/^~~~/.test(e)}function P_(t){const e=[],n=[];let r=!1;return t.forEach(s=>{if(r){n.push(s);return}if(s.trim()===""){r=!0,n.push(s);return}if(e.length>0&&I_(s)){r=!0,n.push(s);return}e.push(s)}),{paragraphLines:e,blockLines:n}}function j_(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],i=s.match(Pg);if(!i)break;const[,o,l,a]=i,c=o.length,u=[a];let d=n+1;const h=[s];let f=!1;for(;d<t.length;){const p=t[d];if(p.match(Pg))break;if(p.trim()==="")h.push(p),u.push(""),f=!0,d+=1;else if(p.match(L_))h.push(p),u.push(p.slice(c+2)),d+=1;else{if(f)break;h.push(p),u.push(p),d+=1}}e.push({indent:c,number:parseInt(l,10),content:u.join(`
140
+ `).trim(),contentLines:u,raw:h.join(`
141
+ `)}),r=d,n=d}return[e,r]}function Iw(t,e,n){const r=[];let s=0;for(;s<t.length;){const i=t[s];if(i.indent===e){const{paragraphLines:o,blockLines:l}=P_(i.contentLines),a=o.join(`
142
+ `).trim(),c=[];a&&c.push({type:"paragraph",raw:a,tokens:n.inlineTokens(a)});const u=l.join(`
143
+ `).trim();if(u){const f=n.blockTokens(u);c.push(...f)}let d=s+1;const h=[];for(;d<t.length&&t[d].indent>e;)h.push(t[d]),d+=1;if(h.length>0){const f=Math.min(...h.map(m=>m.indent)),p=Iw(h,f,n);c.push({type:"list",ordered:!0,start:h[0].number,items:p,raw:h.map(m=>m.raw).join(`
144
+ `)})}r.push({type:"list_item",raw:i.raw,tokens:c}),s=d}else s+=1}return r}function $_(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const i=e.parseChildren([s]);r.push({type:"paragraph",content:i})}else{const i=e.parseChildren([s]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var B_="listItem",jg="textStyle",$g=/^(\d+)\.\s$/,Hf=De.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",fe(this.options.HTMLAttributes,n),0]:["ol",fe(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?$_(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
140
145
  `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e?.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const s=t.split(`
141
- `),[i,o]=EA(s);if(i.length===0)return;const l=Jb(i,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=i[0])==null?void 0:r.number)||1,items:l,raw:s.slice(0,o).join(`
142
- `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(AA,this.editor.getAttributes(Lp)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=ms({find:Ip,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ms({find:Ip,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Lp)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),TA=/^\s*(\[([( |x])?\])\s$/,Yb=Oe.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",pe(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const s=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Lu(t,e,s)},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=d=>{var u,h;l.ariaLabel=((h=(u=this.options.a11y)==null?void 0:u.checkboxLabel)==null?void 0:h.call(u,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};return c(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:u}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const f=n();if(typeof f!="number")return!1;const p=h.doc.nodeAt(f);return h.setNodeMarkup(f,void 0,{...p?.attrs,checked:u}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,u)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,u])=>{s.setAttribute(d,u)}),s.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,o),s.append(i,a),Object.entries(e).forEach(([d,u])=>{s.setAttribute(d,u)}),{dom:s,contentDOM:a,update:d=>d.type!==this.type?!1:(s.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d),!0)}}},addInputRules(){return[ms({find:TA,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Xb=Oe.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",pe(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
143
- `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=i=>{const o=ld(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(i)},s=ld(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});de.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Zu.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Fb.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Gb.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(eh.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Yb.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Xb.configure(this.options.taskList)),t}});var Zb=Oe.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",pe(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];return n.length===1&&n[0].type==="image"?e.parseChildren([n[0]]):e.createNode("paragraph",void 0,e.parseInline(n))},renderMarkdown:(t,e)=>!t||!Array.isArray(t.content)?"":e.renderChildren(t.content),addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),NA=Zb,_A=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,RA=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,OA=Zt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",pe(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Lr({find:_A,type:this.type})]},addPasteRules(){return[sr({find:RA,type:this.type})]}}),DA=Oe.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),Qb=Zt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",pe(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!s)return;const i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),LA=Qb;function IA(t={}){return new me({view(e){return new jA(e,t)}})}class jA{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let u=e.nodeBefore,h=e.nodeAfter;if(u||h){let f=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(f){let p=f.getBoundingClientRect(),g=u?p.bottom:p.top;u&&h&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:p.left,right:p.right,top:g-y,bottom:g+y}}}}if(!r){let u=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*o;r={left:u.left-h,right:u.left+h,top:u.top,bottom:u.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),h=u.width/a.offsetWidth,f=u.height/a.offsetHeight;c=u.left-a.scrollLeft*h,d=u.top-a.scrollTop*f}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-d)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Og(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class je extends ee{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return je.valid(r)?new je(r):ee.near(r)}content(){return P.empty}eq(e){return e instanceof je&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new je(e.resolve(n.pos))}getBookmark(){return new th(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!PA(e)||!BA(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&je.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let a=e.doc.resolve(s);if(je.valid(a))return a}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!q.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let l=e.doc.resolve(s);if(je.valid(l))return l}return null}}}je.prototype.visible=!1;je.findFrom=je.findGapCursorFrom;ee.jsonID("gapcursor",je);class th{constructor(e){this.pos=e}map(e){return new th(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return je.valid(n)?new je(n):ee.near(n)}}function e0(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function PA(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||e0(s.type))return!0;if(s.inlineContent)return!1}}return!0}function BA(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||e0(s.type))return!0;if(s.inlineContent)return!1}}return!0}function $A(){return new me({props:{decorations:UA,createSelectionBetween(t,e,n){return e.pos==n.pos&&je.valid(n)?new je(n):null},handleClick:zA,handleKeyDown:HA,handleDOMEvents:{beforeinput:FA}}})}const HA=Su({ArrowLeft:wo("horiz",-1),ArrowRight:wo("horiz",1),ArrowUp:wo("vert",-1),ArrowDown:wo("vert",1)});function wo(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof J){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=je.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new je(c))),!0):!1}}function zA(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!je.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&q.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new je(r))),!0)}function FA(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof je))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=O.empty;for(let o=r.length-1;o>=0;o--)s=O.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new P(s,0,0));return i.setSelection(J.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function UA(t){if(!(t.selection instanceof je))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",be.create(t.doc,[_e.widget(t.selection.head,e,{key:"gapcursor"})])}var Il=200,et=function(){};et.prototype.append=function(e){return e.length?(e=et.from(e),!this.length&&e||e.length<Il&&this.leafAppend(e)||this.length<Il&&e.leafPrepend(this)||this.appendInner(e)):this};et.prototype.prepend=function(e){return e.length?et.from(e).append(this):this};et.prototype.appendInner=function(e){return new VA(this,e)};et.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?et.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};et.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};et.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};et.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},n,r),s};et.from=function(e){return e instanceof et?e:e&&e.length?new t0(e):et.empty};var t0=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Il)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Il)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(et);et.empty=new t0([]);var VA=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(et);const WA=500;class Ut{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],d=[];return this.items.forEach((u,h)=>{if(!u.step){s||(s=this.remapping(r,h+1),i=s.maps.length),i--,d.push(u);return}if(s){d.push(new Bn(u.map));let f=u.step.map(s.slice(i)),p;f&&o.maybeStep(f).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Bn(p,void 0,void 0,c.length+d.length))),i--,p&&s.appendMap(p,i)}else o.maybeStep(u.step);if(u.selection)return l=s?u.selection.map(s.slice(i)):u.selection,a=new Ut(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,n,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),h=new Bn(e.mapping.maps[d],u,n),f;(f=a&&a.merge(h))&&(h=f,d?i.pop():l=l.slice(0,l.length-1)),i.push(h),n&&(o++,n=void 0),s||(a=h)}let c=o-r.depth;return c>KA&&(l=qA(l,c),o-=c),new Ut(l.append(i),o)}remapping(e,n){let r=new ai;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new Ut(this.items.append(e.map(n=>new Bn(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},s);let a=n;this.items.forEach(h=>{let f=i.getMirror(--a);if(f==null)return;o=Math.min(o,f);let p=i.maps[f];if(h.step){let g=e.steps[f].invert(e.docs[f]),y=h.selection&&h.selection.map(i.slice(a+1,f));y&&l++,r.push(new Bn(p,g,y))}else r.push(new Bn(p))},s);let c=[];for(let h=n;h<o;h++)c.push(new Bn(i.maps[h]));let d=this.items.slice(0,s).append(c).append(r),u=new Ut(d,l);return u.emptyItemCount()>WA&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let d=o.selection&&o.selection.map(n.slice(r));d&&i++;let u=new Bn(c.invert(),a,d),h,f=s.length-1;(h=s.length&&s[f].merge(u))?s[f]=h:s.push(u)}}else o.map&&r--},this.items.length,0),new Ut(et.from(s.reverse()),i)}}Ut.empty=new Ut(et.empty,0);function qA(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}let Bn=class n0{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new n0(n.getMap().invert(),n,this.selection)}}};class Un{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const KA=20;function GA(t,e,n,r){let s=n.getMeta(Ar),i;if(s)return s.historyState;n.getMeta(XA)&&(t=new Un(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Ar))return o.getMeta(Ar).redo?new Un(t.done.addTransform(n,void 0,r,jo(e)),t.undone,jp(n.mapping.maps),t.prevTime,t.prevComposition):new Un(t.done,t.undone.addTransform(n,void 0,r,jo(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!JA(n,t.prevRanges)),c=o?vc(t.prevRanges,n.mapping):jp(n.mapping.maps);return new Un(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,jo(e)),Ut.empty,c,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Un(t.done.rebased(n,i),t.undone.rebased(n,i),vc(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Un(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),vc(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function JA(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function jp(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function vc(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function YA(t,e,n){let r=jo(e),s=Ar.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new Un(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(Ar,{redo:n,historyState:a})}let Sc=!1,Pp=null;function jo(t){let e=t.plugins;if(Pp!=e){Sc=!1,Pp=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Sc=!0;break}}return Sc}const Ar=new ye("history"),XA=new ye("closeHistory");function ZA(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new me({key:Ar,state:{init(){return new Un(Ut.empty,Ut.empty,null,0,-1)},apply(e,n,r){return GA(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?s0:r=="historyRedo"?i0:null;return s?(n.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function r0(t,e){return(n,r)=>{let s=Ar.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=YA(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const s0=r0(!1,!0),i0=r0(!0,!0);var QA=de.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new me({key:new ye("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit;if(s==null||s===0){t=!0;return}const i=this.storage.characters({node:r.doc});if(i>s){const o=i-s,l=0,a=o;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return t=!0,c}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=i-r,c=l-a,d=l;return e.deleteRange(c,d),!(this.storage.characters({node:e.doc})>r)}})]}}),eT=de.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[IA(this.options)]}});de.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new me({key:new ye("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return be.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(_e.node(c,c+a.nodeSize,{class:this.options.className}))}),be.create(t,i)}}})]}});var o0=de.create({name:"gapCursor",addProseMirrorPlugins(){return[$A()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=we(G(t,"allowGapCursor",n)))!=null?e:null}}}),tT=de.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new me({key:new ye("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(!n)return null;const i=this.editor.isEmpty;return t.descendants((o,l)=>{const a=r>=l&&r<=l+o.nodeSize,c=!o.isLeaf&&Li(o);if((a||!this.options.showOnlyCurrent)&&c){const d=[this.options.emptyNodeClass];i&&d.push(this.options.emptyEditorClass);const u=_e.node(l,l+o.nodeSize,{class:d.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:o,pos:l,hasAnchor:a}):this.options.placeholder});s.push(u)}return this.options.includeChildren}),be.create(t,s)}}})]}});de.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new me({key:new ye("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Gy(n.selection)||t.view.dragging?null:be.create(n.doc,[_e.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function Bp({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var nT=de.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ye(this.name),n=((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||this.options.node||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new me({key:e,appendTransaction:(s,i,o)=>{const{doc:l,tr:a,schema:c}=o,d=e.getState(o),u=l.content.size,h=c.nodes[n];if(d)return a.insert(u,h.create())},state:{init:(s,i)=>{const o=i.tr.doc.lastChild;return!Bp({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged)return i;const o=s.doc.lastChild;return!Bp({node:o,types:r})}}})]}}),l0=de.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>s0(t,e),redo:()=>({state:t,dispatch:e})=>i0(t,e)}},addProseMirrorPlugins(){return[ZA(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),rT=de.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(OM.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(Nb.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(Zu.configure(this.options.bulletList)),this.options.code!==!1&&s.push(IM.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(_b.configure(this.options.codeBlock)),this.options.document!==!1&&s.push($M.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(eT.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(o0.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(HM.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(Rb.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(l0.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(FM.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(KM.configure(this.options.italic)),this.options.listItem!==!1&&s.push(Fb.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(Gb.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(zb.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(eh.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(Zb.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(OA.configure(this.options.strike)),this.options.text!==!1&&s.push(DA.configure(this.options.text)),this.options.underline!==!1&&s.push(Qb.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(nT.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),sT=rT,Cc,$p;function iT(){if($p)return Cc;$p=1;function t(E){return E instanceof Map?E.clear=E.delete=E.set=function(){throw new Error("map is read-only")}:E instanceof Set&&(E.add=E.clear=E.delete=function(){throw new Error("set is read-only")}),Object.freeze(E),Object.getOwnPropertyNames(E).forEach(R=>{const B=E[R],re=typeof B;(re==="object"||re==="function")&&!Object.isFrozen(B)&&t(B)}),E}class e{constructor(R){R.data===void 0&&(R.data={}),this.data=R.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(E){return E.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(E,...R){const B=Object.create(null);for(const re in E)B[re]=E[re];return R.forEach(function(re){for(const He in re)B[He]=re[He]}),B}const s="</span>",i=E=>!!E.scope,o=(E,{prefix:R})=>{if(E.startsWith("language:"))return E.replace("language:","language-");if(E.includes(".")){const B=E.split(".");return[`${R}${B.shift()}`,...B.map((re,He)=>`${re}${"_".repeat(He+1)}`)].join(" ")}return`${R}${E}`};class l{constructor(R,B){this.buffer="",this.classPrefix=B.classPrefix,R.walk(this)}addText(R){this.buffer+=n(R)}openNode(R){if(!i(R))return;const B=o(R.scope,{prefix:this.classPrefix});this.span(B)}closeNode(R){i(R)&&(this.buffer+=s)}value(){return this.buffer}span(R){this.buffer+=`<span class="${R}">`}}const a=(E={})=>{const R={children:[]};return Object.assign(R,E),R};class c{constructor(){this.rootNode=a(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(R){this.top.children.push(R)}openNode(R){const B=a({scope:R});this.add(B),this.stack.push(B)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(R){return this.constructor._walk(R,this.rootNode)}static _walk(R,B){return typeof B=="string"?R.addText(B):B.children&&(R.openNode(B),B.children.forEach(re=>this._walk(R,re)),R.closeNode(B)),R}static _collapse(R){typeof R!="string"&&R.children&&(R.children.every(B=>typeof B=="string")?R.children=[R.children.join("")]:R.children.forEach(B=>{c._collapse(B)}))}}class d extends c{constructor(R){super(),this.options=R}addText(R){R!==""&&this.add(R)}startScope(R){this.openNode(R)}endScope(){this.closeNode()}__addSublanguage(R,B){const re=R.root;B&&(re.scope=`language:${B}`),this.add(re)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function u(E){return E?typeof E=="string"?E:E.source:null}function h(E){return g("(?=",E,")")}function f(E){return g("(?:",E,")*")}function p(E){return g("(?:",E,")?")}function g(...E){return E.map(B=>u(B)).join("")}function y(E){const R=E[E.length-1];return typeof R=="object"&&R.constructor===Object?(E.splice(E.length-1,1),R):{}}function b(...E){return"("+(y(E).capture?"":"?:")+E.map(re=>u(re)).join("|")+")"}function w(E){return new RegExp(E.toString()+"|").exec("").length-1}function A(E,R){const B=E&&E.exec(R);return B&&B.index===0}const S=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function M(E,{joinWith:R}){let B=0;return E.map(re=>{B+=1;const He=B;let ze=u(re),W="";for(;ze.length>0;){const U=S.exec(ze);if(!U){W+=ze;break}W+=ze.substring(0,U.index),ze=ze.substring(U.index+U[0].length),U[0][0]==="\\"&&U[1]?W+="\\"+String(Number(U[1])+He):(W+=U[0],U[0]==="("&&B++)}return W}).map(re=>`(${re})`).join(R)}const x=/\b\B/,k="[a-zA-Z]\\w*",v="[a-zA-Z_]\\w*",T="\\b\\d+(\\.\\d+)?",N="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",H="\\b(0b[01]+)",V="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",$=(E={})=>{const R=/^#![ ]*\//;return E.binary&&(E.begin=g(R,/.*\b/,E.binary,/\b.*/)),r({scope:"meta",begin:R,end:/$/,relevance:0,"on:begin":(B,re)=>{B.index!==0&&re.ignoreMatch()}},E)},I={begin:"\\\\[\\s\\S]",relevance:0},j={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[I]},Q={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[I]},ie={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},F=function(E,R,B={}){const re=r({scope:"comment",begin:E,end:R,contains:[]},B);re.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const He=b("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return re.contains.push({begin:g(/[ ]+/,"(",He,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),re},ue=F("//","$"),xe=F("/\\*","\\*/"),_=F("#","$"),Z={scope:"number",begin:T,relevance:0},fe={scope:"number",begin:N,relevance:0},Se={scope:"number",begin:H,relevance:0},pn={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[I,{begin:/\[/,end:/\]/,relevance:0,contains:[I]}]},fr={scope:"title",begin:k,relevance:0},$e={scope:"title",begin:v,relevance:0},Ln={begin:"\\.\\s*"+v,relevance:0};var qr=Object.freeze({__proto__:null,APOS_STRING_MODE:j,BACKSLASH_ESCAPE:I,BINARY_NUMBER_MODE:Se,BINARY_NUMBER_RE:H,COMMENT:F,C_BLOCK_COMMENT_MODE:xe,C_LINE_COMMENT_MODE:ue,C_NUMBER_MODE:fe,C_NUMBER_RE:N,END_SAME_AS_BEGIN:function(E){return Object.assign(E,{"on:begin":(R,B)=>{B.data._beginMatch=R[1]},"on:end":(R,B)=>{B.data._beginMatch!==R[1]&&B.ignoreMatch()}})},HASH_COMMENT_MODE:_,IDENT_RE:k,MATCH_NOTHING_RE:x,METHOD_GUARD:Ln,NUMBER_MODE:Z,NUMBER_RE:T,PHRASAL_WORDS_MODE:ie,QUOTE_STRING_MODE:Q,REGEXP_MODE:pn,RE_STARTERS_RE:V,SHEBANG:$,TITLE_MODE:fr,UNDERSCORE_IDENT_RE:v,UNDERSCORE_TITLE_MODE:$e});function Cw(E,R){E.input[E.index-1]==="."&&R.ignoreMatch()}function Ew(E,R){E.className!==void 0&&(E.scope=E.className,delete E.className)}function Mw(E,R){R&&E.beginKeywords&&(E.begin="\\b("+E.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",E.__beforeBegin=Cw,E.keywords=E.keywords||E.beginKeywords,delete E.beginKeywords,E.relevance===void 0&&(E.relevance=0))}function Aw(E,R){Array.isArray(E.illegal)&&(E.illegal=b(...E.illegal))}function Tw(E,R){if(E.match){if(E.begin||E.end)throw new Error("begin & end are not supported with match");E.begin=E.match,delete E.match}}function Nw(E,R){E.relevance===void 0&&(E.relevance=1)}const _w=(E,R)=>{if(!E.beforeMatch)return;if(E.starts)throw new Error("beforeMatch cannot be used with starts");const B=Object.assign({},E);Object.keys(E).forEach(re=>{delete E[re]}),E.keywords=B.keywords,E.begin=g(B.beforeMatch,h(B.begin)),E.starts={relevance:0,contains:[Object.assign(B,{endsParent:!0})]},E.relevance=0,delete B.beforeMatch},Rw=["of","and","for","in","not","or","if","then","parent","list","value"],Ow="keyword";function Lh(E,R,B=Ow){const re=Object.create(null);return typeof E=="string"?He(B,E.split(" ")):Array.isArray(E)?He(B,E):Object.keys(E).forEach(function(ze){Object.assign(re,Lh(E[ze],R,ze))}),re;function He(ze,W){R&&(W=W.map(U=>U.toLowerCase())),W.forEach(function(U){const te=U.split("|");re[te[0]]=[ze,Dw(te[0],te[1])]})}}function Dw(E,R){return R?Number(R):Lw(E)?0:1}function Lw(E){return Rw.includes(E.toLowerCase())}const Ih={},pr=E=>{console.error(E)},jh=(E,...R)=>{console.log(`WARN: ${E}`,...R)},Kr=(E,R)=>{Ih[`${E}/${R}`]||(console.log(`Deprecated as of ${E}. ${R}`),Ih[`${E}/${R}`]=!0)},Qi=new Error;function Ph(E,R,{key:B}){let re=0;const He=E[B],ze={},W={};for(let U=1;U<=R.length;U++)W[U+re]=He[U],ze[U+re]=!0,re+=w(R[U-1]);E[B]=W,E[B]._emit=ze,E[B]._multi=!0}function Iw(E){if(Array.isArray(E.begin)){if(E.skip||E.excludeBegin||E.returnBegin)throw pr("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Qi;if(typeof E.beginScope!="object"||E.beginScope===null)throw pr("beginScope must be object"),Qi;Ph(E,E.begin,{key:"beginScope"}),E.begin=M(E.begin,{joinWith:""})}}function jw(E){if(Array.isArray(E.end)){if(E.skip||E.excludeEnd||E.returnEnd)throw pr("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Qi;if(typeof E.endScope!="object"||E.endScope===null)throw pr("endScope must be object"),Qi;Ph(E,E.end,{key:"endScope"}),E.end=M(E.end,{joinWith:""})}}function Pw(E){E.scope&&typeof E.scope=="object"&&E.scope!==null&&(E.beginScope=E.scope,delete E.scope)}function Bw(E){Pw(E),typeof E.beginScope=="string"&&(E.beginScope={_wrap:E.beginScope}),typeof E.endScope=="string"&&(E.endScope={_wrap:E.endScope}),Iw(E),jw(E)}function $w(E){function R(W,U){return new RegExp(u(W),"m"+(E.case_insensitive?"i":"")+(E.unicodeRegex?"u":"")+(U?"g":""))}class B{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(U,te){te.position=this.position++,this.matchIndexes[this.matchAt]=te,this.regexes.push([te,U]),this.matchAt+=w(U)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const U=this.regexes.map(te=>te[1]);this.matcherRe=R(M(U,{joinWith:"|"}),!0),this.lastIndex=0}exec(U){this.matcherRe.lastIndex=this.lastIndex;const te=this.matcherRe.exec(U);if(!te)return null;const Ye=te.findIndex((Ds,$a)=>$a>0&&Ds!==void 0),Ve=this.matchIndexes[Ye];return te.splice(0,Ye),Object.assign(te,Ve)}}class re{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(U){if(this.multiRegexes[U])return this.multiRegexes[U];const te=new B;return this.rules.slice(U).forEach(([Ye,Ve])=>te.addRule(Ye,Ve)),te.compile(),this.multiRegexes[U]=te,te}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(U,te){this.rules.push([U,te]),te.type==="begin"&&this.count++}exec(U){const te=this.getMatcher(this.regexIndex);te.lastIndex=this.lastIndex;let Ye=te.exec(U);if(this.resumingScanAtSamePosition()&&!(Ye&&Ye.index===this.lastIndex)){const Ve=this.getMatcher(0);Ve.lastIndex=this.lastIndex+1,Ye=Ve.exec(U)}return Ye&&(this.regexIndex+=Ye.position+1,this.regexIndex===this.count&&this.considerAll()),Ye}}function He(W){const U=new re;return W.contains.forEach(te=>U.addRule(te.begin,{rule:te,type:"begin"})),W.terminatorEnd&&U.addRule(W.terminatorEnd,{type:"end"}),W.illegal&&U.addRule(W.illegal,{type:"illegal"}),U}function ze(W,U){const te=W;if(W.isCompiled)return te;[Ew,Tw,Bw,_w].forEach(Ve=>Ve(W,U)),E.compilerExtensions.forEach(Ve=>Ve(W,U)),W.__beforeBegin=null,[Mw,Aw,Nw].forEach(Ve=>Ve(W,U)),W.isCompiled=!0;let Ye=null;return typeof W.keywords=="object"&&W.keywords.$pattern&&(W.keywords=Object.assign({},W.keywords),Ye=W.keywords.$pattern,delete W.keywords.$pattern),Ye=Ye||/\w+/,W.keywords&&(W.keywords=Lh(W.keywords,E.case_insensitive)),te.keywordPatternRe=R(Ye,!0),U&&(W.begin||(W.begin=/\B|\b/),te.beginRe=R(te.begin),!W.end&&!W.endsWithParent&&(W.end=/\B|\b/),W.end&&(te.endRe=R(te.end)),te.terminatorEnd=u(te.end)||"",W.endsWithParent&&U.terminatorEnd&&(te.terminatorEnd+=(W.end?"|":"")+U.terminatorEnd)),W.illegal&&(te.illegalRe=R(W.illegal)),W.contains||(W.contains=[]),W.contains=[].concat(...W.contains.map(function(Ve){return Hw(Ve==="self"?W:Ve)})),W.contains.forEach(function(Ve){ze(Ve,te)}),W.starts&&ze(W.starts,U),te.matcher=He(te),te}if(E.compilerExtensions||(E.compilerExtensions=[]),E.contains&&E.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return E.classNameAliases=r(E.classNameAliases||{}),ze(E)}function Bh(E){return E?E.endsWithParent||Bh(E.starts):!1}function Hw(E){return E.variants&&!E.cachedVariants&&(E.cachedVariants=E.variants.map(function(R){return r(E,{variants:null},R)})),E.cachedVariants?E.cachedVariants:Bh(E)?r(E,{starts:E.starts?r(E.starts):null}):Object.isFrozen(E)?r(E):E}var zw="11.11.1";class Fw extends Error{constructor(R,B){super(R),this.name="HTMLInjectionError",this.html=B}}const Ba=n,$h=r,Hh=Symbol("nomatch"),Uw=7,zh=function(E){const R=Object.create(null),B=Object.create(null),re=[];let He=!0;const ze="Could not find the language '{}', did you forget to load/include a language module?",W={disableAutodetect:!0,name:"Plain text",contains:[]};let U={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:d};function te(L){return U.noHighlightRe.test(L)}function Ye(L){let Y=L.className+" ";Y+=L.parentNode?L.parentNode.className:"";const he=U.languageDetectRe.exec(Y);if(he){const Me=In(he[1]);return Me||(jh(ze.replace("{}",he[1])),jh("Falling back to no-highlight mode for this block.",L)),Me?he[1]:"no-highlight"}return Y.split(/\s+/).find(Me=>te(Me)||In(Me))}function Ve(L,Y,he){let Me="",Je="";typeof Y=="object"?(Me=L,he=Y.ignoreIllegals,Je=Y.language):(Kr("10.7.0","highlight(lang, code, ...args) has been deprecated."),Kr("10.7.0",`Please use highlight(code, options) instead.
144
- https://github.com/highlightjs/highlight.js/issues/2277`),Je=L,Me=Y),he===void 0&&(he=!0);const zt={code:Me,language:Je};to("before:highlight",zt);const jn=zt.result?zt.result:Ds(zt.language,zt.code,he);return jn.code=zt.code,to("after:highlight",jn),jn}function Ds(L,Y,he,Me){const Je=Object.create(null);function zt(z,K){return z.keywords[K]}function jn(){if(!se.keywords){nt.addText(Ae);return}let z=0;se.keywordPatternRe.lastIndex=0;let K=se.keywordPatternRe.exec(Ae),ae="";for(;K;){ae+=Ae.substring(z,K.index);const ke=nn.case_insensitive?K[0].toLowerCase():K[0],lt=zt(se,ke);if(lt){const[mn,o1]=lt;if(nt.addText(ae),ae="",Je[ke]=(Je[ke]||0)+1,Je[ke]<=Uw&&(so+=o1),mn.startsWith("_"))ae+=K[0];else{const l1=nn.classNameAliases[mn]||mn;tn(K[0],l1)}}else ae+=K[0];z=se.keywordPatternRe.lastIndex,K=se.keywordPatternRe.exec(Ae)}ae+=Ae.substring(z),nt.addText(ae)}function no(){if(Ae==="")return;let z=null;if(typeof se.subLanguage=="string"){if(!R[se.subLanguage]){nt.addText(Ae);return}z=Ds(se.subLanguage,Ae,!0,Jh[se.subLanguage]),Jh[se.subLanguage]=z._top}else z=Ha(Ae,se.subLanguage.length?se.subLanguage:null);se.relevance>0&&(so+=z.relevance),nt.__addSublanguage(z._emitter,z.language)}function At(){se.subLanguage!=null?no():jn(),Ae=""}function tn(z,K){z!==""&&(nt.startScope(K),nt.addText(z),nt.endScope())}function Wh(z,K){let ae=1;const ke=K.length-1;for(;ae<=ke;){if(!z._emit[ae]){ae++;continue}const lt=nn.classNameAliases[z[ae]]||z[ae],mn=K[ae];lt?tn(mn,lt):(Ae=mn,jn(),Ae=""),ae++}}function qh(z,K){return z.scope&&typeof z.scope=="string"&&nt.openNode(nn.classNameAliases[z.scope]||z.scope),z.beginScope&&(z.beginScope._wrap?(tn(Ae,nn.classNameAliases[z.beginScope._wrap]||z.beginScope._wrap),Ae=""):z.beginScope._multi&&(Wh(z.beginScope,K),Ae="")),se=Object.create(z,{parent:{value:se}}),se}function Kh(z,K,ae){let ke=A(z.endRe,ae);if(ke){if(z["on:end"]){const lt=new e(z);z["on:end"](K,lt),lt.isMatchIgnored&&(ke=!1)}if(ke){for(;z.endsParent&&z.parent;)z=z.parent;return z}}if(z.endsWithParent)return Kh(z.parent,K,ae)}function t1(z){return se.matcher.regexIndex===0?(Ae+=z[0],1):(Va=!0,0)}function n1(z){const K=z[0],ae=z.rule,ke=new e(ae),lt=[ae.__beforeBegin,ae["on:begin"]];for(const mn of lt)if(mn&&(mn(z,ke),ke.isMatchIgnored))return t1(K);return ae.skip?Ae+=K:(ae.excludeBegin&&(Ae+=K),At(),!ae.returnBegin&&!ae.excludeBegin&&(Ae=K)),qh(ae,z),ae.returnBegin?0:K.length}function r1(z){const K=z[0],ae=Y.substring(z.index),ke=Kh(se,z,ae);if(!ke)return Hh;const lt=se;se.endScope&&se.endScope._wrap?(At(),tn(K,se.endScope._wrap)):se.endScope&&se.endScope._multi?(At(),Wh(se.endScope,z)):lt.skip?Ae+=K:(lt.returnEnd||lt.excludeEnd||(Ae+=K),At(),lt.excludeEnd&&(Ae=K));do se.scope&&nt.closeNode(),!se.skip&&!se.subLanguage&&(so+=se.relevance),se=se.parent;while(se!==ke.parent);return ke.starts&&qh(ke.starts,z),lt.returnEnd?0:K.length}function s1(){const z=[];for(let K=se;K!==nn;K=K.parent)K.scope&&z.unshift(K.scope);z.forEach(K=>nt.openNode(K))}let ro={};function Gh(z,K){const ae=K&&K[0];if(Ae+=z,ae==null)return At(),0;if(ro.type==="begin"&&K.type==="end"&&ro.index===K.index&&ae===""){if(Ae+=Y.slice(K.index,K.index+1),!He){const ke=new Error(`0 width match regex (${L})`);throw ke.languageName=L,ke.badRule=ro.rule,ke}return 1}if(ro=K,K.type==="begin")return n1(K);if(K.type==="illegal"&&!he){const ke=new Error('Illegal lexeme "'+ae+'" for mode "'+(se.scope||"<unnamed>")+'"');throw ke.mode=se,ke}else if(K.type==="end"){const ke=r1(K);if(ke!==Hh)return ke}if(K.type==="illegal"&&ae==="")return Ae+=`
145
- `,1;if(Ua>1e5&&Ua>K.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Ae+=ae,ae.length}const nn=In(L);if(!nn)throw pr(ze.replace("{}",L)),new Error('Unknown language: "'+L+'"');const i1=$w(nn);let Fa="",se=Me||i1;const Jh={},nt=new U.__emitter(U);s1();let Ae="",so=0,mr=0,Ua=0,Va=!1;try{if(nn.__emitTokens)nn.__emitTokens(Y,nt);else{for(se.matcher.considerAll();;){Ua++,Va?Va=!1:se.matcher.considerAll(),se.matcher.lastIndex=mr;const z=se.matcher.exec(Y);if(!z)break;const K=Y.substring(mr,z.index),ae=Gh(K,z);mr=z.index+ae}Gh(Y.substring(mr))}return nt.finalize(),Fa=nt.toHTML(),{language:L,value:Fa,relevance:so,illegal:!1,_emitter:nt,_top:se}}catch(z){if(z.message&&z.message.includes("Illegal"))return{language:L,value:Ba(Y),illegal:!0,relevance:0,_illegalBy:{message:z.message,index:mr,context:Y.slice(mr-100,mr+100),mode:z.mode,resultSoFar:Fa},_emitter:nt};if(He)return{language:L,value:Ba(Y),illegal:!1,relevance:0,errorRaised:z,_emitter:nt,_top:se};throw z}}function $a(L){const Y={value:Ba(L),illegal:!1,relevance:0,_top:W,_emitter:new U.__emitter(U)};return Y._emitter.addText(L),Y}function Ha(L,Y){Y=Y||U.languages||Object.keys(R);const he=$a(L),Me=Y.filter(In).filter(Vh).map(At=>Ds(At,L,!1));Me.unshift(he);const Je=Me.sort((At,tn)=>{if(At.relevance!==tn.relevance)return tn.relevance-At.relevance;if(At.language&&tn.language){if(In(At.language).supersetOf===tn.language)return 1;if(In(tn.language).supersetOf===At.language)return-1}return 0}),[zt,jn]=Je,no=zt;return no.secondBest=jn,no}function Vw(L,Y,he){const Me=Y&&B[Y]||he;L.classList.add("hljs"),L.classList.add(`language-${Me}`)}function za(L){let Y=null;const he=Ye(L);if(te(he))return;if(to("before:highlightElement",{el:L,language:he}),L.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",L);return}if(L.children.length>0&&(U.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(L)),U.throwUnescapedHTML))throw new Fw("One of your code blocks includes unescaped HTML.",L.innerHTML);Y=L;const Me=Y.textContent,Je=he?Ve(Me,{language:he,ignoreIllegals:!0}):Ha(Me);L.innerHTML=Je.value,L.dataset.highlighted="yes",Vw(L,he,Je.language),L.result={language:Je.language,re:Je.relevance,relevance:Je.relevance},Je.secondBest&&(L.secondBest={language:Je.secondBest.language,relevance:Je.secondBest.relevance}),to("after:highlightElement",{el:L,result:Je,text:Me})}function Ww(L){U=$h(U,L)}const qw=()=>{eo(),Kr("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Kw(){eo(),Kr("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Fh=!1;function eo(){function L(){eo()}if(document.readyState==="loading"){Fh||window.addEventListener("DOMContentLoaded",L,!1),Fh=!0;return}document.querySelectorAll(U.cssSelector).forEach(za)}function Gw(L,Y){let he=null;try{he=Y(E)}catch(Me){if(pr("Language definition for '{}' could not be registered.".replace("{}",L)),He)pr(Me);else throw Me;he=W}he.name||(he.name=L),R[L]=he,he.rawDefinition=Y.bind(null,E),he.aliases&&Uh(he.aliases,{languageName:L})}function Jw(L){delete R[L];for(const Y of Object.keys(B))B[Y]===L&&delete B[Y]}function Yw(){return Object.keys(R)}function In(L){return L=(L||"").toLowerCase(),R[L]||R[B[L]]}function Uh(L,{languageName:Y}){typeof L=="string"&&(L=[L]),L.forEach(he=>{B[he.toLowerCase()]=Y})}function Vh(L){const Y=In(L);return Y&&!Y.disableAutodetect}function Xw(L){L["before:highlightBlock"]&&!L["before:highlightElement"]&&(L["before:highlightElement"]=Y=>{L["before:highlightBlock"](Object.assign({block:Y.el},Y))}),L["after:highlightBlock"]&&!L["after:highlightElement"]&&(L["after:highlightElement"]=Y=>{L["after:highlightBlock"](Object.assign({block:Y.el},Y))})}function Zw(L){Xw(L),re.push(L)}function Qw(L){const Y=re.indexOf(L);Y!==-1&&re.splice(Y,1)}function to(L,Y){const he=L;re.forEach(function(Me){Me[he]&&Me[he](Y)})}function e1(L){return Kr("10.7.0","highlightBlock will be removed entirely in v12.0"),Kr("10.7.0","Please use highlightElement now."),za(L)}Object.assign(E,{highlight:Ve,highlightAuto:Ha,highlightAll:eo,highlightElement:za,highlightBlock:e1,configure:Ww,initHighlighting:qw,initHighlightingOnLoad:Kw,registerLanguage:Gw,unregisterLanguage:Jw,listLanguages:Yw,getLanguage:In,registerAliases:Uh,autoDetection:Vh,inherit:$h,addPlugin:Zw,removePlugin:Qw}),E.debugMode=function(){He=!1},E.safeMode=function(){He=!0},E.versionString=zw,E.regex={concat:g,lookahead:h,either:b,optional:p,anyNumberOfTimes:f};for(const L in qr)typeof qr[L]=="object"&&t(qr[L]);return Object.assign(E,qr),E},Gr=zh({});return Gr.newInstance=()=>zh({}),Cc=Gr,Gr.HighlightJS=Gr,Gr.default=Gr,Cc}var oT=iT();const a0=sg(oT);function c0(t,e=[]){return t.flatMap(n=>{const r=[...e,...n.properties?n.properties.className:[]];return n.children?c0(n.children,r):{text:n.value,classes:r}})}function Hp(t){return t.value||t.children||[]}function lT(t){return!!a0.getLanguage(t)}function zp({doc:t,name:e,lowlight:n,defaultLanguage:r}){const s=[];return sd(t,i=>i.type.name===e).forEach(i=>{var o;let l=i.pos+1;const a=i.node.attrs.language||r,c=n.listLanguages(),d=a&&(c.includes(a)||lT(a)||(o=n.registered)!=null&&o.call(n,a))?Hp(n.highlight(a,i.node.textContent)):Hp(n.highlightAuto(i.node.textContent));c0(d).forEach(u=>{const h=l+u.text.length;if(u.classes.length){const f=_e.inline(l,h,{class:u.classes.join(" ")});s.push(f)}l=h})}),be.create(t,s)}function aT(t){return typeof t=="function"}function cT({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(s=>aT(e[s])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new me({key:new ye("lowlight"),state:{init:(s,{doc:i})=>zp({doc:i,name:t,lowlight:e,defaultLanguage:n}),apply:(s,i,o,l)=>{const a=o.selection.$head.parent.type.name,c=l.selection.$head.parent.type.name,d=sd(o.doc,h=>h.type.name===t),u=sd(l.doc,h=>h.type.name===t);return s.docChanged&&([a,c].includes(t)||u.length!==d.length||s.steps.some(h=>h.from!==void 0&&h.to!==void 0&&d.some(f=>f.pos>=h.from&&f.pos+f.node.nodeSize<=h.to)))?zp({doc:s.doc,name:t,lowlight:e,defaultLanguage:n}):i.map(s.mapping,s.doc)}},props:{decorations(s){return r.getState(s)}}});return r}var dT=BM.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],cT({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),d0=dT,uT=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,hT=Oe.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",pe(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,s,i,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",a=(s=(r=t.attrs)==null?void 0:r.alt)!=null?s:"",c=(o=(i=t.attrs)==null?void 0:i.title)!=null?o:"";return c?`![${a}](${l} "${c}")`:`![${a}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u"||!this.editor.isEditable)return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:s,getPos:i,HTMLAttributes:o})=>{const l=document.createElement("img");Object.entries(o).forEach(([d,u])=>{if(u!=null)switch(d){case"width":case"height":break;default:l.setAttribute(d,u);break}}),l.src=o.src;const a=new rE({element:l,node:s,getPos:i,onResize:(d,u)=>{l.style.width=`${d}px`,l.style.height=`${u}px`},onCommit:(d,u)=>{const h=i();h!==void 0&&this.editor.chain().setNodeSelection(h).updateAttributes(this.name,{width:d,height:u}).run()},onUpdate:(d,u,h)=>d.type===s.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),c=a.dom;return c.style.visibility="hidden",c.style.pointerEvents="none",l.onload=()=>{c.style.visibility="",c.style.pointerEvents=""},a}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[ab({find:uT,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),u0=hT;const Ec=(t,e,n)=>Math.max(e,Math.min(n,t));function fT(t){const e=ne.useRef(null),[n,r]=ne.useState(!1),[s,i]=ne.useState(null),o=t.node.attrs,l=ne.useMemo(()=>{const h=o.width;return typeof h=="string"&&h.trim().endsWith("%")?Ec(parseFloat(h)||100,1,100):100},[o.width]),a=s??l,c=h=>f=>{f.preventDefault(),f.stopPropagation();const p=f.clientX,g=a,b=(e.current?.closest(".ProseMirror")||void 0)?.getBoundingClientRect().width||e.current?.parentElement?.getBoundingClientRect().width||e.current?.getBoundingClientRect().width||window.innerWidth;let w=g;const A=M=>{const k=(M.clientX-p)/b*100,v=h==="east"?g+k:g-k,T=Ec(v,1,100);w=T,i(T)},S=()=>{r(!1),window.removeEventListener("pointermove",A),window.removeEventListener("pointerup",S);const M=Ec(w,1,100);t.updateAttributes({width:`${M.toFixed(2)}%`}),i(null)};r(!0),window.addEventListener("pointermove",A),window.addEventListener("pointerup",S,{once:!0})},d=(()=>{const h={width:`${a}%`,maxWidth:"100%",display:"block"};return o.height?(typeof o.height=="number"||typeof o.height=="string")&&(h.height=o.height):h.height="auto",o.align==="left"&&(h.marginLeft=0,h.marginRight="auto"),o.align==="right"&&(h.marginLeft="auto",h.marginRight=0),o.align==="center"&&(h.margin="0 auto"),h})(),u=t.selected||n;return m.jsxs(Iu,{ref:e,className:"tiptap-image-wrapper relative block","data-dragging":n?"true":"false",contentEditable:!1,style:d,onClick:h=>h.stopPropagation(),children:[m.jsx("img",{src:o.src,alt:o.alt||"",style:{display:"block",width:"100%",height:"100%",objectFit:"cover",objectPosition:`${o.focalX??50}% ${o.focalY??50}%`,borderRadius:6},draggable:!1,onClick:h=>{if(o.focusMode){const f=h.target.getBoundingClientRect(),p=Math.round((h.clientX-f.left)/f.width*100),g=Math.round((h.clientY-f.top)/f.height*100);t.updateAttributes({focalX:p,focalY:g,focusMode:!1})}}}),u&&m.jsxs(m.Fragment,{children:[m.jsx("div",{role:"slider","aria-label":"Resize image","aria-valuemin":1,"aria-valuemax":100,"aria-valuenow":a,onPointerDown:c("west"),className:"absolute left-0 top-1/2 -translate-y-1/2 h-16 w-2 rounded-sm bg-primary cursor-ew-resize shadow border border-primary/40"}),m.jsx("div",{role:"slider","aria-label":"Resize image","aria-valuemin":1,"aria-valuemax":100,"aria-valuenow":a,onPointerDown:c("east"),className:"absolute right-0 top-1/2 -translate-y-1/2 h-16 w-2 rounded-sm bg-primary cursor-ew-resize shadow border border-primary/40"})]}),u&&m.jsx("div",{className:"pointer-events-none absolute inset-0 rounded-md ring-2 ring-primary/60"}),n&&m.jsxs("div",{className:"pointer-events-none absolute -top-6 right-0 text-xs bg-primary text-primary-foreground px-2 py-0.5 rounded",children:[Number(a.toFixed(1)),"%"]})]})}const pT=u0.extend({name:"image",addAttributes(){return{...this.parent?.()||{},width:{default:null,parseHTML:t=>t.getAttribute("width")||t.style.width||null,renderHTML:t=>{const e={};return typeof t.width=="number"?e.width=t.width:typeof t.width=="string"&&t.width.trim().length>0&&(e.style=`width: ${t.width};`),e}},height:{default:null,parseHTML:t=>t.getAttribute("height")||t.style.height||null,renderHTML:t=>{const e={};if(typeof t.height=="number")e.height=t.height;else if(typeof t.height=="string"&&t.height.trim().length>0){const n=`height: ${t.height};`;e.style=e.style?`${e.style} ${n}`:n}return e}},blurDataURL:{default:null,parseHTML:t=>t.getAttribute("data-blur")||null,renderHTML:t=>t.blurDataURL?{"data-blur":t.blurDataURL}:{}},lockAspect:{default:!0,parseHTML:t=>t.getAttribute("data-lock-aspect")!=="false",renderHTML:t=>({"data-lock-aspect":String(t.lockAspect)})},align:{default:null,parseHTML:t=>t.getAttribute("data-align"),renderHTML:t=>t.align?{"data-align":t.align}:{}},caption:{default:null,parseHTML:t=>t.getAttribute("data-caption"),renderHTML:t=>t.caption?{"data-caption":t.caption}:{}},focalX:{default:null,parseHTML:t=>t.getAttribute("data-focal-x"),renderHTML:t=>t.focalX!=null?{"data-focal-x":String(t.focalX)}:{}},focalY:{default:null,parseHTML:t=>t.getAttribute("data-focal-y"),renderHTML:t=>t.focalY!=null?{"data-focal-y":String(t.focalY)}:{}},focusMode:{default:!1,parseHTML:t=>t.getAttribute("data-focus-mode")==="true",renderHTML:t=>t.focusMode?{"data-focus-mode":"true"}:{}}}},addKeyboardShortcuts(){const e=n=>()=>{const s=(this.editor.getAttributes("image")||{}).width;let i=100;typeof s=="string"&&s.endsWith("%")&&(i=parseFloat(s)||100);const o=Math.max(1,Math.min(100,i+n));return this.editor.chain().focus().updateAttributes("image",{width:`${o}%`}).run()};return{"Alt-=":e(5),"Alt-+":e(5),"Alt--":e(-5),"Alt-_":e(-5)}},addNodeView(){return ju(fT)}});var h0=Xb,f0=Yb,kd,vd;if(typeof WeakMap<"u"){let t=new WeakMap;kd=e=>t.get(e),vd=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;kd=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},vd=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var Pe=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,s=e/this.width|0;let i=r+1,o=s+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;o<this.height&&this.map[e+this.width*l]==n;l++)o++;return{left:r,top:s,right:i,bottom:o}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:s,top:i,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[i*this.width+(n<0?r-1:s)]:(n<0?i==0:o==this.height)?null:this.map[r+this.width*(n<0?i-1:o)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(s,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const i=r*this.width+s,o=this.map[i];n[o]||(n[o]=!0,!(s==t.left&&s&&this.map[i-1]==o||r==t.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const i=s+n.child(r).nodeSize;if(r==t){let o=e+t*this.width;const l=(t+1)*this.width;for(;o<l&&this.map[o]<s;)o++;return o==l?i-1:this.map[o]}s=i}}static get(t){return kd(t)||vd(t,mT(t))}};function mT(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=gT(t),n=t.childCount,r=[];let s=0,i=null;const o=[];for(let c=0,d=e*n;c<d;c++)r[c]=0;for(let c=0,d=0;c<n;c++){const u=t.child(c);d++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==u.childCount)break;const g=u.child(p),{colspan:y,rowspan:b,colwidth:w}=g.attrs;for(let A=0;A<b;A++){if(A+c>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:b-A});break}const S=s+A*e;for(let M=0;M<y;M++){r[S+M]==0?r[S+M]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:y-M});const x=w&&w[M];if(x){const k=(S+M)%e*2,v=o[k];v==null||v!=x&&o[k+1]==1?(o[k]=x,o[k+1]=1):v==x&&o[k+1]++}}}s+=y,d+=g.nodeSize}const h=(c+1)*e;let f=0;for(;s<h;)r[s++]==0&&f++;f&&(i||(i=[])).push({type:"missing",row:c,n:f}),d++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new Pe(e,n,r,i);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<n&&(a=!0);return a&&yT(l,o,t),l}function gT(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let i=0;if(n)for(let o=0;o<r;o++){const l=t.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const l=s.child(o);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function yT(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const i=t.map[s];if(r[i])continue;r[i]=!0;const o=n.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const d=(s+c)%t.width,u=e[d*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=bT(a)))[c]=u)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function bT(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function pt(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}var qn=new ye("selectingCells");function As(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function xT(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function Qt(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function ga(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=As(e.$head)||wT(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function wT(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Sd(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function kT(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function nh(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function p0(t,e,n){const r=t.node(-1),s=Pe.get(r),i=t.start(-1),o=s.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function jr(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function m0(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<n;s++)r.colwidth.splice(e,0,0)}return r}function vT(t,e,n){const r=pt(e.type.schema).header_cell;for(let s=0;s<t.height;s++)if(e.nodeAt(t.map[n+s*t.width]).type!=r)return!1;return!0}var Te=class kn extends ee{constructor(e,n=e){const r=e.node(-1),s=Pe.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,n.pos-i),l=e.node(0),a=s.cellsInRect(o).filter(d=>d!=n.pos-i);a.unshift(n.pos-i);const c=a.map(d=>{const u=r.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);const h=i+d+1;return new lu(l.resolve(h),l.resolve(h+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(Sd(r)&&Sd(s)&&nh(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?kn.rowSelection(r,s):i&&this.isColSelection()?kn.colSelection(r,s):new kn(r,s)}return J.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=Pe.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let d=a*n.width+s.left,u=s.left;u<s.right;u++,d++){const h=n.map[d];if(i[h])continue;i[h]=!0;const f=n.findCell(h);let p=e.nodeAt(h);if(!p)throw RangeError(`No cell with offset ${h} found`);const g=s.left-f.left,y=f.right-s.right;if(g>0||y>0){let b=p.attrs;if(g>0&&(b=jr(b,0,g)),y>0&&(b=jr(b,b.colspan-y,y)),f.left<s.left){if(p=p.type.createAndFill(b),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else p=p.type.create(b,p.content)}if(f.top<s.top||f.bottom>s.bottom){const b={...p.attrs,rowspan:Math.min(f.bottom,s.bottom)-Math.max(f.top,s.top)};f.top<s.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}o.push(e.child(a).copy(O.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new P(O.from(l),1,1)}replace(e,n=P.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:l,$to:a}=s[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?P.empty:n)}const i=ee.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new P(O.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=Pe.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(n.nodeAt(i[o]),s+i[o])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),s=Pe.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(i+s.map[o.left])),l.bottom<s.height&&(n=a.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+s.map[l.left])),o.bottom<s.height&&(e=a.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new kn(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=Pe.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==n.width}eq(e){return e instanceof kn&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=Pe.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(i+s.map[o.top*s.width])),l.right<s.width&&(n=a.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+s.map[l.top*s.width])),o.right<s.width&&(e=a.resolve(i+s.map[s.width*(o.top+1)-1]))),new kn(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new kn(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new kn(e.resolve(n),e.resolve(r))}getBookmark(){return new ST(this.$anchorCell.pos,this.$headCell.pos)}};Te.prototype.visible=!1;ee.jsonID("cell",Te);var ST=class g0{constructor(e,n){this.anchor=e,this.head=n}map(e){return new g0(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&nh(n,r)?new Te(n,r):ee.near(r,1)}};function CT(t){if(!(t.selection instanceof Te))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(_e.node(r,r+n.nodeSize,{class:"selectedCell"}))}),be.create(t.doc,e)}function ET({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,s=t.depth;for(;s>=0&&!(t.after(s+1)<t.end(s));s--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(s).type.spec.tableRole)}function MT({$from:t,$to:e}){let n,r;for(let s=t.depth;s>0;s--){const i=t.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function AT(t,e,n){const r=(e||t).selection,s=(e||t).doc;let i,o;if(r instanceof q&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=Te.create(s,r.from);else if(o=="row"){const l=s.resolve(r.from+1);i=Te.rowSelection(l,l)}else if(!n){const l=Pe.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=Te.create(s,a+1,c)}}else r instanceof J&&ET(r)?i=J.create(s,r.from):r instanceof J&&MT(r)&&(i=J.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}var TT=new ye("fix-tables");function y0(t,e,n,r){const s=t.childCount,i=e.childCount;e:for(let o=0,l=0;o<i;o++){const a=e.child(o);for(let c=l,d=Math.min(s,o+3);c<d;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<s&&t.child(l).sameMarkup(a)?y0(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function b0(t,e){let n;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=NT(t,s,i,n))};return e?e.doc!=t.doc&&y0(e.doc,t.doc,0,r):t.doc.descendants(r),n}function NT(t,e,n,r){const s=Pe.get(e);if(!s.problems)return r;r||(r=t.tr);const i=[];for(let a=0;a<s.height;a++)i.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let h=0;h<u.rowspan;h++)i[c.row+h]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,jr(u,u.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const d=r.mapping.map(n);r.delete(d,d+e.nodeSize)}}let o,l;for(let a=0;a<i.length;a++)i[a]&&(o==null&&(o=a),l=a);for(let a=0,c=n+1;a<s.height;a++){const d=e.child(a),u=c+d.nodeSize,h=i[a];if(h>0){let f="cell";d.firstChild&&(f=d.firstChild.type.spec.tableRole);const p=[];for(let y=0;y<h;y++){const b=pt(t.schema)[f].createAndFill();b&&p.push(b)}const g=(a==0||o==a-1)&&l==a?c+1:u-1;r.insert(r.mapping.map(g),p)}c=u}return r.setMeta(TT,{fixTables:!0})}function fn(t){const e=t.selection,n=ga(t),r=n.node(-1),s=n.start(-1),i=Pe.get(r);return{...e instanceof Te?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function x0(t,{map:e,tableStart:n,table:r},s){let i=s>0?-1:0;vT(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){const l=o*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,m0(c.attrs,s-e.colCount(a))),o+=c.attrs.rowspan-1}else{const a=i==null?pt(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(o,s,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function _T(t,e){if(!Qt(t))return!1;if(e){const n=fn(t);e(x0(t.tr,n,n.left))}return!0}function RT(t,e){if(!Qt(t))return!1;if(e){const n=fn(t);e(x0(t.tr,n,n.right))}return!0}function OT(t,{map:e,table:n,tableStart:r},s){const i=t.mapping.maps.length;for(let o=0;o<e.height;){const l=o*e.width+s,a=e.map[l],c=n.nodeAt(a),d=c.attrs;if(s>0&&e.map[l-1]==a||s<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(i).map(r+a),null,jr(d,s-e.colCount(a)));else{const u=t.mapping.slice(i).map(r+a);t.delete(u,u+c.nodeSize)}o+=d.rowspan}}function DT(t,e){if(!Qt(t))return!1;if(e){const n=fn(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;OT(r,n,s),s!=n.left;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw RangeError("No table found");n.table=i,n.map=Pe.get(i)}e(r)}return!0}function LT(t,e,n){var r;const s=pt(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))==null?void 0:r.type)!=s)return!1;return!0}function w0(t,{map:e,tableStart:n,table:r},s){var i;let o=n;for(let c=0;c<s;c++)o+=r.child(c).nodeSize;const l=[];let a=s>0?-1:0;LT(e,r,s+a)&&(a=s==0||s==e.height?null:0);for(let c=0,d=e.width*s;c<e.width;c++,d++)if(s>0&&s<e.height&&e.map[d]==e.map[d-e.width]){const u=e.map[d],h=r.nodeAt(u).attrs;t.setNodeMarkup(n+u,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{const u=a==null?pt(r.type.schema).cell:(i=r.nodeAt(e.map[d+a*e.width]))==null?void 0:i.type,h=u?.createAndFill();h&&l.push(h)}return t.insert(o,pt(r.type.schema).row.create(null,l)),t}function IT(t,e){if(!Qt(t))return!1;if(e){const n=fn(t);e(w0(t.tr,n,n.top))}return!0}function jT(t,e){if(!Qt(t))return!1;if(e){const n=fn(t);e(w0(t.tr,n,n.bottom))}return!0}function PT(t,{map:e,table:n,tableStart:r},s){let i=0;for(let c=0;c<s;c++)i+=n.child(c).nodeSize;const o=i+n.child(s).nodeSize,l=t.mapping.maps.length;t.delete(i+r,o+r);const a=new Set;for(let c=0,d=s*e.width;c<e.width;c++,d++){const u=e.map[d];if(!a.has(u)){if(a.add(u),s>0&&u==e.map[d-e.width]){const h=n.nodeAt(u).attrs;t.setNodeMarkup(t.mapping.slice(l).map(u+r),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(s<e.height&&u==e.map[d+e.width]){const h=n.nodeAt(u),f=h.attrs,p=h.type.create({...f,rowspan:h.attrs.rowspan-1},h.content),g=e.positionAt(s+1,c,n);t.insert(t.mapping.slice(l).map(r+g),p),c+=f.colspan-1}}}}function BT(t,e){if(!Qt(t))return!1;if(e){const n=fn(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;PT(r,n,s),s!=n.top;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw RangeError("No table found");n.table=i,n.map=Pe.get(n.table)}e(r)}return!0}function Fp(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function $T({width:t,height:e,map:n},r){let s=r.top*t+r.left,i=s,o=(r.bottom-1)*t+r.left,l=s+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[o]==n[o+t])return!0;s++,o++}return!1}function Up(t,e){const n=t.selection;if(!(n instanceof Te)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=fn(t),{map:s}=r;if($T(s,r))return!1;if(e){const i=t.tr,o={};let l=O.empty,a,c;for(let d=r.top;d<r.bottom;d++)for(let u=r.left;u<r.right;u++){const h=s.map[d*s.width+u],f=r.table.nodeAt(h);if(!(o[h]||!f))if(o[h]=!0,a==null)a=h,c=f;else{Fp(f)||(l=l.append(f.content));const p=i.mapping.map(h+r.tableStart);i.delete(p,p+f.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...m0(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size){const d=a+1+c.content.size,u=Fp(c)?a+1:d;i.replaceWith(u+r.tableStart,d+r.tableStart,l)}i.setSelection(new Te(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function Vp(t,e){const n=pt(t.schema);return HT(({node:r})=>n[r.type.spec.tableRole])(t,e)}function HT(t){return(e,n)=>{var r;const s=e.selection;let i,o;if(s instanceof Te){if(s.$anchorCell.pos!=s.$headCell.pos)return!1;i=s.$anchorCell.nodeAfter,o=s.$anchorCell.pos}else{if(i=xT(s.$from),!i)return!1;o=(r=As(s.$from))==null?void 0:r.pos}if(i==null||o==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let l=i.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const d=fn(e),u=e.tr;for(let f=0;f<d.right-d.left;f++)a.push(c?{...l,colwidth:c&&c[f]?[c[f]]:null}:l);let h;for(let f=d.top;f<d.bottom;f++){let p=d.map.positionAt(f,d.left,d.table);f==d.top&&(p+=i.nodeSize);for(let g=d.left,y=0;g<d.right;g++,y++)g==d.left&&f==d.top||u.insert(h=u.mapping.map(p+d.tableStart,1),t({node:i,row:f,col:g}).createAndFill(a[y]))}u.setNodeMarkup(o,t({node:i,row:d.top,col:d.left}),a[0]),s instanceof Te&&u.setSelection(new Te(u.doc.resolve(s.$anchorCell.pos),h?u.doc.resolve(h):void 0)),n(u)}return!0}}function zT(t,e){return function(n,r){if(!Qt(n))return!1;const s=ga(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof Te?n.selection.forEachCell((o,l)=>{o.attrs[t]!==e&&i.setNodeMarkup(l,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function FT(t){return function(e,n){if(!Qt(e))return!1;if(n){const r=pt(e.schema),s=fn(e),i=e.tr,o=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=o.map(a=>s.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[a],r.cell,l[a].attrs);if(i.steps.length==0)for(let a=0;a<o.length;a++)i.setNodeMarkup(s.tableStart+o[a],r.header_cell,l[a].attrs);n(i)}return!0}}function Wp(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function xi(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?FT(t):function(n,r){if(!Qt(n))return!1;if(r){const s=pt(n.schema),i=fn(n),o=n.tr,l=Wp("row",i,s),a=Wp("column",i,s),d=(t==="column"?l:t==="row"?a:!1)?1:0,u=t=="column"?{left:0,top:d,right:1,bottom:i.map.height}:t=="row"?{left:d,top:0,right:i.map.width,bottom:1}:i,h=t=="column"?a?s.cell:s.header_cell:t=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(u).forEach(f=>{const p=f+i.tableStart,g=o.doc.nodeAt(p);g&&o.setNodeMarkup(p,h,g.attrs)}),r(o)}return!0}}xi("row",{useDeprecatedLogic:!0});xi("column",{useDeprecatedLogic:!0});var UT=xi("cell",{useDeprecatedLogic:!0});function VT(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,s=t.before();r>=0;r--){const i=t.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),s=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function qp(t){return function(e,n){if(!Qt(e))return!1;const r=VT(ga(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection(J.between(s,kT(s))).scrollIntoView())}return!0}}function WT(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function ko(t,e){const n=t.selection;if(!(n instanceof Te))return!1;if(e){const r=t.tr,s=pt(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new P(s,0,0))}),r.docChanged&&e(r)}return!0}function qT(t){if(!t.size)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,n-1),u=a<e.childCount-1?0:Math.max(0,r-1);(d||u)&&(c=Cd(pt(o).row,new P(c,d,u)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(n||r?Cd(pt(o).row,new P(e,n,r)).content:e);else return null;return KT(o,l)}function KT(t,e){const n=[];for(let s=0;s<e.length;s++){const i=e[s];for(let o=i.childCount-1;o>=0;o--){const{rowspan:l,colspan:a}=i.child(o).attrs;for(let c=s;c<s+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,n[s]);for(let s=0;s<n.length;s++)if(s>=e.length&&e.push(O.empty),n[s]<r){const i=pt(t).cell.createAndFill(),o=[];for(let l=n[s];l<r;l++)o.push(i);e[s]=e[s].append(O.from(o))}return{height:e.length,width:r,rows:e}}function Cd(t,e){const n=t.createAndFill();return new ou(n).replace(0,n.content.size,e).doc}function GT({width:t,height:e,rows:n},r,s){if(t!=r){const i=[],o=[];for(let l=0;l<n.length;l++){const a=n[l],c=[];for(let d=i[l]||0,u=0;d<r;u++){let h=a.child(u%a.childCount);d+h.attrs.colspan>r&&(h=h.type.createChecked(jr(h.attrs,h.attrs.colspan,d+h.attrs.colspan-r),h.content)),c.push(h),d+=h.attrs.colspan;for(let f=1;f<h.attrs.rowspan;f++)i[l+f]=(i[l+f]||0)+h.attrs.colspan}o.push(O.from(c))}n=o,t=r}if(e!=s){const i=[];for(let o=0,l=0;o<s;o++,l++){const a=[],c=n[l%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);o+u.attrs.rowspan>s&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,s-u.attrs.rowspan)},u.content)),a.push(u)}i.push(O.from(a))}n=i,e=s}return{width:t,height:e,rows:n}}function JT(t,e,n,r,s,i,o){const l=t.doc.type.schema,a=pt(l);let c,d;if(s>e.width)for(let u=0,h=0;u<e.height;u++){const f=n.child(u);h+=f.nodeSize;const p=[];let g;f.lastChild==null||f.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=d||(d=a.header_cell.createAndFill());for(let y=e.width;y<s;y++)p.push(g);t.insert(t.mapping.slice(o).map(h-1+r),p)}if(i>e.height){const u=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,s);p++){const y=p>=e.width?!1:n.nodeAt(e.map[g+p]).type==a.header_cell;u.push(y?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const h=a.row.create(null,O.from(u)),f=[];for(let p=e.height;p<i;p++)f.push(h);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(c||d)}function Kp(t,e,n,r,s,i,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=s;c<i;c++){const d=o*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;const h=n.nodeAt(u),{top:f,left:p}=e.findCell(u);t.setNodeMarkup(t.mapping.slice(l).map(u+r),null,{...h.attrs,rowspan:o-f}),t.insert(t.mapping.slice(l).map(e.positionAt(o,p,n)),h.type.createAndFill({...h.attrs,rowspan:f+h.attrs.rowspan-o})),c+=h.attrs.colspan-1}}return a}function Gp(t,e,n,r,s,i,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=s;c<i;c++){const d=c*e.width+o,u=e.map[d];if(e.map[d-1]==u){a=!0;const h=n.nodeAt(u),f=e.colCount(u),p=t.mapping.slice(l).map(u+r);t.setNodeMarkup(p,null,jr(h.attrs,o-f,h.attrs.colspan-(o-f))),t.insert(p+h.nodeSize,h.type.createAndFill(jr(h.attrs,0,o-f))),c+=h.attrs.rowspan-1}}return a}function Jp(t,e,n,r,s){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let o=Pe.get(i);const{top:l,left:a}=r,c=a+s.width,d=l+s.height,u=t.tr;let h=0;function f(){if(i=n?u.doc.nodeAt(n-1):u.doc,!i)throw new Error("No table found");o=Pe.get(i),h=u.mapping.maps.length}JT(u,o,i,n,c,d,h)&&f(),Kp(u,o,i,n,a,c,l,h)&&f(),Kp(u,o,i,n,a,c,d,h)&&f(),Gp(u,o,i,n,l,d,a,h)&&f(),Gp(u,o,i,n,l,d,c,h)&&f();for(let p=l;p<d;p++){const g=o.positionAt(p,a,i),y=o.positionAt(p,c,i);u.replace(u.mapping.slice(h).map(g+n),u.mapping.slice(h).map(y+n),new P(s.rows[p-l],0,0))}f(),u.setSelection(new Te(u.doc.resolve(n+o.positionAt(l,a,i)),u.doc.resolve(n+o.positionAt(d-1,c-1,i)))),e(u)}var YT=Su({ArrowLeft:vo("horiz",-1),ArrowRight:vo("horiz",1),ArrowUp:vo("vert",-1),ArrowDown:vo("vert",1),"Shift-ArrowLeft":So("horiz",-1),"Shift-ArrowRight":So("horiz",1),"Shift-ArrowUp":So("vert",-1),"Shift-ArrowDown":So("vert",1),Backspace:ko,"Mod-Backspace":ko,Delete:ko,"Mod-Delete":ko});function Po(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function vo(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof Te)return Po(n,r,ee.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=k0(s,t,e);if(o==null)return!1;if(t=="horiz")return Po(n,r,ee.near(n.doc.resolve(i.head+e),e));{const l=n.doc.resolve(o),a=p0(l,t,e);let c;return a?c=ee.near(a,1):e<0?c=ee.near(n.doc.resolve(l.before(-1)),-1):c=ee.near(n.doc.resolve(l.after(-1)),1),Po(n,r,c)}}}function So(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let o;if(i instanceof Te)o=i;else{const a=k0(s,t,e);if(a==null)return!1;o=new Te(n.doc.resolve(a))}const l=p0(o.$headCell,t,e);return l?Po(n,r,new Te(o.$anchorCell,l)):!1}}function XT(t,e){const n=t.state.doc,r=As(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Te(r))),!0):!1}function ZT(t,e,n){if(!Qt(t.state))return!1;let r=qT(n);const s=t.state.selection;if(s instanceof Te){r||(r={width:1,height:1,rows:[O.from(Cd(pt(t.state.schema).cell,n))]});const i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),l=Pe.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=GT(r,l.right-l.left,l.bottom-l.top),Jp(t.state,t.dispatch,o,l,r),!0}else if(r){const i=ga(t.state),o=i.start(-1);return Jp(t.state,t.dispatch,o,Pe.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function QT(t,e){var n;if(e.ctrlKey||e.metaKey)return;const r=Yp(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof Te)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=As(t.state.selection.$anchor))!=null&&((n=Mc(t,e))==null?void 0:n.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(a,c){let d=Mc(t,c);const u=qn.getState(t.state)==null;if(!d||!nh(a,d))if(u)d=a;else return;const h=new Te(a,d);if(u||!t.state.selection.eq(h)){const f=t.state.tr.setSelection(h);u&&f.setMeta(qn,a.pos),t.dispatch(f)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),qn.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(qn,-1))}function l(a){const c=a,d=qn.getState(t.state);let u;if(d!=null)u=t.state.doc.resolve(d);else if(Yp(t,c.target)!=r&&(u=Mc(t,e),!u))return o();u&&i(u,c)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",l)}function k0(t,e,n){if(!(t.state.selection instanceof J))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=r.before(s),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?l:null}}return null}function Yp(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Mc(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?As(t.state.doc.resolve(n.pos)):null}var eN=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Ed(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Ed(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Ed(t,e,n,r,s,i){var o;let l=0,a=!0,c=e.firstChild;const d=t.firstChild;if(d){for(let u=0,h=0;u<d.childCount;u++){const{colspan:f,colwidth:p}=d.child(u).attrs;for(let g=0;g<f;g++,h++){const y=s==h?i:p&&p[g],b=y?y+"px":"";if(l+=y||r,y||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const w=document.createElement("col");w.style.width=b,e.appendChild(w)}}}for(;c;){const u=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=u}a?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}var Rt=new ye("tableColumnResizing");function tN({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=eN,lastColumnResizable:s=!0}={}){const i=new me({key:Rt,state:{init(o,l){var a,c;const d=(c=(a=i.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,u=pt(l.schema).table.name;return r&&d&&(d[u]=(h,f)=>new r(h,n,f)),new nN(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=Rt.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{rN(o,l,t,s)},mouseleave:o=>{sN(o)},mousedown:(o,l)=>{iN(o,l,e,n)}},decorations:o=>{const l=Rt.getState(o);if(l&&l.activeHandle>-1)return dN(o,l.activeHandle)},nodeViews:{}}});return i}var nN=class Bo{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Rt);if(r&&r.setHandle!=null)return new Bo(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Bo(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return Sd(e.doc.resolve(s))||(s=-1),new Bo(s,n.dragging)}return n}};function rN(t,e,n,r){if(!t.editable)return;const s=Rt.getState(t.state);if(s&&!s.dragging){const i=lN(e.target);let o=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=n?o=Xp(t,e,"left",n):a-e.clientX<=n&&(o=Xp(t,e,"right",n))}if(o!=s.activeHandle){if(!r&&o!==-1){const l=t.state.doc.resolve(o),a=l.node(-1),c=Pe.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}v0(t,o)}}}function sN(t){if(!t.editable)return;const e=Rt.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&v0(t,-1)}function iN(t,e,n,r){var s;if(!t.editable)return!1;const i=(s=t.dom.ownerDocument.defaultView)!=null?s:window,o=Rt.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=t.state.doc.nodeAt(o.activeHandle),a=oN(t,o.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Rt,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const h=Rt.getState(t.state);h?.dragging&&(aN(t,h.activeHandle,Zp(h.dragging,u,n)),t.dispatch(t.state.tr.setMeta(Rt,{setDragging:null})))}function d(u){if(!u.which)return c(u);const h=Rt.getState(t.state);if(h&&h.dragging){const f=Zp(h.dragging,u,n);Qp(t,h.activeHandle,f,r)}}return Qp(t,o.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function oN(t,e,{colspan:n,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=t.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,a=n;if(r)for(let c=0;c<n;c++)r[c]&&(l-=r[c],a--);return l/a}function lN(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Xp(t,e,n,r){const s=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:o}=i,l=As(t.state.doc.resolve(o));if(!l)return-1;if(n=="right")return l.pos;const a=Pe.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function Zp(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function v0(t,e){t.dispatch(t.state.tr.setMeta(Rt,{setHandle:e}))}function aN(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),i=Pe.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<i.height;c++){const d=c*i.width+l;if(c&&i.map[d]==i.map[d-i.width])continue;const u=i.map[d],h=s.nodeAt(u).attrs,f=h.colspan==1?0:l-i.colCount(u);if(h.colwidth&&h.colwidth[f]==n)continue;const p=h.colwidth?h.colwidth.slice():cN(h.colspan);p[f]=n,a.setNodeMarkup(o+u,null,{...h,colwidth:p})}a.docChanged&&t.dispatch(a)}function Qp(t,e,n,r){const s=t.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),l=Pe.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;let a=t.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Ed(i,a.firstChild,a,r,l,n)}function cN(t){return Array(t).fill(0)}function dN(t,e){var n;const r=[],s=t.doc.resolve(e),i=s.node(-1);if(!i)return be.empty;const o=Pe.get(i),l=s.start(-1),a=o.colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;for(let c=0;c<o.height;c++){const d=a+c*o.width;if((a==o.width-1||o.map[d]!=o.map[d+1])&&(c==0||o.map[d]!=o.map[d-o.width])){const u=o.map[d],h=l+u+i.nodeAt(u).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",(n=Rt.getState(t))!=null&&n.dragging&&r.push(_e.node(l+u,l+u+i.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),r.push(_e.widget(h,f))}}return be.create(t.doc,r)}function uN({allowTableNodeSelection:t=!1}={}){return new me({key:qn,state:{init(){return null},apply(e,n){const r=e.getMeta(qn);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:s,pos:i}=e.mapping.mapResult(n);return s?null:i}},props:{decorations:CT,handleDOMEvents:{mousedown:QT},createSelectionBetween(e){return qn.getState(e.state)!=null?e.state.selection:null},handleTripleClick:XT,handleKeyDown:YT,handlePaste:ZT},appendTransaction(e,n,r){return AT(r,b0(r,n),t)}})}var S0=Oe.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const r=t.getAttribute("colwidth"),s=r?r.split(",").map(i=>parseInt(i,10)):null;if(!s){const i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),o=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(o&&o>-1&&i&&i[o]){const l=i[o].getAttribute("width");return l?[parseInt(l,10)]:null}}return s}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",pe(this.options.HTMLAttributes,t),0]}}),C0=Oe.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",pe(this.options.HTMLAttributes,t),0]}}),E0=Oe.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",pe(this.options.HTMLAttributes,t),0]}});function Md(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function em(t,e,n,r,s,i){var o;let l=0,a=!0,c=e.firstChild;const d=t.firstChild;if(d!==null)for(let u=0,h=0;u<d.childCount;u+=1){const{colspan:f,colwidth:p}=d.child(u).attrs;for(let g=0;g<f;g+=1,h+=1){const y=s===h?i:p&&p[g],b=y?`${y}px`:"";if(l+=y||r,y||(a=!1),c){if(c.style.width!==b){const[w,A]=Md(r,y);c.style.setProperty(w,A)}c=c.nextSibling}else{const w=document.createElement("col"),[A,S]=Md(r,y);w.style.setProperty(A,S),e.appendChild(w)}}}for(;c;){const u=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=u}a?(n.style.width=`${l}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${l}px`)}var hN=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),em(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,em(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function fN(t,e,n,r){let s=0,i=!0;const o=[],l=t.firstChild;if(!l)return{};for(let u=0,h=0;u<l.childCount;u+=1){const{colspan:f,colwidth:p}=l.child(u).attrs;for(let g=0;g<f;g+=1,h+=1){const y=n===h?r:p&&p[g];s+=y||e,y||(i=!1);const[b,w]=Md(e,y);o.push(["col",{style:`${b}: ${w}`}])}}const a=i?`${s}px`:"",c=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:a,tableMinWidth:c}}function tm(t,e){return t.createAndFill()}function pN(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function mN(t,e,n,r,s){const i=pN(t),o=[],l=[];for(let c=0;c<n;c+=1){const d=tm(i.cell);if(d&&l.push(d),r){const u=tm(i.header_cell);u&&o.push(u)}}const a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?o:l));return i.table.createChecked(null,a)}function gN(t){return t instanceof Te}var Co=({editor:t})=>{const{selection:e}=t.state;if(!gN(e))return!1;let n=0;const r=Hy(e.ranges[0].$from,i=>i.type.name==="table");return r?.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},yN="";function bN(t){return(t||"").replace(/\s+/g," ").trim()}function xN(t,e,n={}){var r;const s=(r=n.cellLineSeparator)!=null?r:yN;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(p=>{const g=[];p.content&&p.content.forEach(y=>{let b="";y.content&&Array.isArray(y.content)&&y.content.length>1?b=y.content.map(M=>e.renderChildren(M)).join(s):b=y.content?e.renderChildren(y.content):"";const w=bN(b),A=y.type==="tableHeader";g.push({text:w,isHeader:A})}),i.push(g)});const o=i.reduce((p,g)=>Math.max(p,g.length),0);if(o===0)return"";const l=new Array(o).fill(0);i.forEach(p=>{var g;for(let y=0;y<o;y+=1){const w=(((g=p[y])==null?void 0:g.text)||"").length;w>l[y]&&(l[y]=w),l[y]<3&&(l[y]=3)}});const a=(p,g)=>p+" ".repeat(Math.max(0,g-p.length)),c=i[0],d=c.some(p=>p.isHeader);let u=`
146
- `;const h=new Array(o).fill(0).map((p,g)=>d&&c[g]&&c[g].text||"");return u+=`| ${h.map((p,g)=>a(p,l[g])).join(" | ")} |
147
- `,u+=`| ${l.map(p=>"-".repeat(Math.max(3,p))).join(" | ")} |
148
- `,(d?i.slice(1):i).forEach(p=>{u+=`| ${new Array(o).fill(0).map((g,y)=>a(p[y]&&p[y].text||"",l[y])).join(" | ")} |
149
- `}),u}var wN=xN,M0=Oe.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:hN,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:s}=fN(t,this.options.cellMinWidth),i=["table",pe(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${s}`}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},i]:i},parseMarkdown:(t,e)=>{const n=[];if(t.header){const r=[];t.header.forEach(s=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(r=>{const s=[];r.forEach(i=>{s.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>wN(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const o=mN(i.schema,t,e,n);if(s){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(J.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>_T(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>RT(t,e),deleteColumn:()=>({state:t,dispatch:e})=>DT(t,e),addRowBefore:()=>({state:t,dispatch:e})=>IT(t,e),addRowAfter:()=>({state:t,dispatch:e})=>jT(t,e),deleteRow:()=>({state:t,dispatch:e})=>BT(t,e),deleteTable:()=>({state:t,dispatch:e})=>WT(t,e),mergeCells:()=>({state:t,dispatch:e})=>Up(t,e),splitCell:()=>({state:t,dispatch:e})=>Vp(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>xi("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>xi("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>UT(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Up(t,e)?!0:Vp(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>zT(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>qp(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>qp(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&b0(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Te.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Co,"Mod-Backspace":Co,Delete:Co,"Mod-Delete":Co}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[tN({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],uN({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:we(G(t,"tableRole",e))}}});de.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(M0.configure(this.options.table)),this.options.tableCell!==!1&&t.push(S0.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(C0.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(E0.configure(this.options.tableRow)),t}});var kN=E0,vN=C0,SN=S0,CN=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,EN=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,MN=Zt.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",pe(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){const s=/^(==)([^=]+)(==)/.exec(t);if(s){const i=s[2].trim(),o=n.inlineTokens(i);return{type:"highlight",raw:s[0],text:i,tokens:o}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Lr({find:CN,type:this.type})]},addPasteRules(){return[sr({find:EN,type:this.type})]}}),AN=MN,TN=Zt.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",pe(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),NN=TN,_N=Zt.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",pe(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),RN=_N,ON=de.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).every(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),DN=ON,LN=20,A0=(t,e=0)=>{const n=[];return!t.children.length||e>LN||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...A0(r,e+1))}),n},IN=t=>{if(!t.children.length)return;const e=A0(t);e&&e.forEach(n=>{var r,s;const i=n.getAttribute("style"),o=(s=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:s.getAttribute("style");n.setAttribute("style",`${o};${i}`)})},jN=Zt.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&IN(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",pe(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),PN=de.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(s=>s.trim()).filter(Boolean);for(let s=r.length-1;s>=0;s-=1){const i=r[s].split(":");if(i.length>=2){const o=i[0].trim().toLowerCase(),l=i.slice(1).join(":").trim();if(o==="background-color")return l.replace(/['"]+/g,"")}}}return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),BN=de.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(s=>s.trim()).filter(Boolean);for(let s=r.length-1;s>=0;s-=1){const i=r[s].split(":");if(i.length>=2){const o=i[0].trim().toLowerCase(),l=i.slice(1).join(":").trim();if(o==="color")return l.replace(/['"]+/g,"")}}}return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),$N=de.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),HN=de.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),zN=de.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}}),FN=de.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(PN.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(BN.configure(this.options.color)),this.options.fontFamily!==!1&&t.push($N.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(HN.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(zN.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(jN.configure(this.options.textStyle)),t}}),UN=QA,VN=t=>Be({find:/--$/,replace:t??"—"}),WN=t=>Be({find:/\.\.\.$/,replace:t??"…"}),qN=t=>Be({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"“"}),KN=t=>Be({find:/"$/,replace:t??"”"}),GN=t=>Be({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"‘"}),JN=t=>Be({find:/'$/,replace:t??"’"}),YN=t=>Be({find:/<-$/,replace:t??"←"}),XN=t=>Be({find:/->$/,replace:t??"→"}),ZN=t=>Be({find:/\(c\)$/,replace:t??"©"}),QN=t=>Be({find:/\(tm\)$/,replace:t??"™"}),e_=t=>Be({find:/\(sm\)$/,replace:t??"℠"}),t_=t=>Be({find:/\(r\)$/,replace:t??"®"}),n_=t=>Be({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),r_=t=>Be({find:/\+\/-$/,replace:t??"±"}),s_=t=>Be({find:/!=$/,replace:t??"≠"}),i_=t=>Be({find:/<<$/,replace:t??"«"}),o_=t=>Be({find:/>>$/,replace:t??"»"}),l_=t=>Be({find:/\d+\s?([*x])\s?\d+$/,replace:t??"×"}),a_=t=>Be({find:/\^2$/,replace:t??"²"}),c_=t=>Be({find:/\^3$/,replace:t??"³"}),d_=t=>Be({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),u_=t=>Be({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),h_=de.create({name:"typography",addOptions(){return{closeDoubleQuote:"”",closeSingleQuote:"’",copyright:"©",ellipsis:"…",emDash:"—",laquo:"«",leftArrow:"←",multiplication:"×",notEqual:"≠",oneHalf:"½",oneQuarter:"¼",openDoubleQuote:"“",openSingleQuote:"‘",plusMinus:"±",raquo:"»",registeredTrademark:"®",rightArrow:"→",servicemark:"℠",superscriptThree:"³",superscriptTwo:"²",threeQuarters:"¾",trademark:"™"}},addInputRules(){const t=[];return this.options.emDash!==!1&&t.push(VN(this.options.emDash)),this.options.ellipsis!==!1&&t.push(WN(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&t.push(qN(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&t.push(KN(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&t.push(GN(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&t.push(JN(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&t.push(YN(this.options.leftArrow)),this.options.rightArrow!==!1&&t.push(XN(this.options.rightArrow)),this.options.copyright!==!1&&t.push(ZN(this.options.copyright)),this.options.trademark!==!1&&t.push(QN(this.options.trademark)),this.options.servicemark!==!1&&t.push(e_(this.options.servicemark)),this.options.registeredTrademark!==!1&&t.push(t_(this.options.registeredTrademark)),this.options.oneHalf!==!1&&t.push(n_(this.options.oneHalf)),this.options.plusMinus!==!1&&t.push(r_(this.options.plusMinus)),this.options.notEqual!==!1&&t.push(s_(this.options.notEqual)),this.options.laquo!==!1&&t.push(i_(this.options.laquo)),this.options.raquo!==!1&&t.push(o_(this.options.raquo)),this.options.multiplication!==!1&&t.push(l_(this.options.multiplication)),this.options.superscriptTwo!==!1&&t.push(a_(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&t.push(c_(this.options.superscriptThree)),this.options.oneQuarter!==!1&&t.push(d_(this.options.oneQuarter)),this.options.threeQuarters!==!1&&t.push(u_(this.options.threeQuarters)),t}}),f_=h_,p_=o0,m_=l0;const Kt=()=>new Map,Ad=t=>{const e=Kt();return t.forEach((n,r)=>{e.set(r,n)}),e},On=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},g_=(t,e)=>{const n=[];for(const[r,s]of t)n.push(e(s,r));return n},y_=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},Pr=()=>new Set,Ac=t=>t[t.length-1],b_=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},Br=Array.from,x_=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},Td=Array.isArray;class T0{constructor(){this._observers=Kt()}on(e,n){return On(this._observers,e,Pr).add(n),n}once(e,n){const r=(...s)=>{this.off(e,r),n(...s)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return Br((this._observers.get(e)||Kt()).values()).forEach(r=>r(...n))}destroy(){this._observers=Kt()}}const _n=Math.floor,$o=Math.abs,bs=(t,e)=>t<e?t:e,lr=(t,e)=>t>e?t:e,N0=t=>t!==0?t<0:1/t<0,nm=1,rm=2,Tc=4,Nc=8,wi=32,Tn=64,yt=128,w_=1<<29,ya=31,Nd=63,Tr=127,k_=2147483647,_0=Number.MAX_SAFE_INTEGER,v_=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&_n(t)===t),S_=String.fromCharCode,C_=t=>t.toLowerCase(),E_=/^\s*/g,M_=t=>t.replace(E_,""),A_=/([A-Z])/g,sm=(t,e)=>M_(t.replace(A_,n=>`${e}${C_(n)}`)),T_=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},ki=typeof TextEncoder<"u"?new TextEncoder:null,N_=t=>ki.encode(t),__=ki?N_:T_;let ti=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});ti&&ti.decode(new Uint8Array).length===1&&(ti=null);class Hi{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const zi=()=>new Hi,R_=t=>{const e=zi();return t(e),qt(e)},O_=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},qt=t=>{const e=new Uint8Array(O_(t));let n=0;for(let r=0;r<t.bufs.length;r++){const s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},D_=(t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(lr(n,e)*2),t.cpos=0)},Xe=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},_d=Xe,ge=(t,e)=>{for(;e>Tr;)Xe(t,yt|Tr&e),e=_n(e/128);Xe(t,Tr&e)},rh=(t,e)=>{const n=N0(e);for(n&&(e=-e),Xe(t,(e>Nd?yt:0)|(n?Tn:0)|Nd&e),e=_n(e/64);e>0;)Xe(t,(e>Tr?yt:0)|Tr&e),e=_n(e/128)},Rd=new Uint8Array(3e4),L_=Rd.length/3,I_=(t,e)=>{if(e.length<L_){const n=ki.encodeInto(e,Rd).written||0;ge(t,n);for(let r=0;r<n;r++)Xe(t,Rd[r])}else Tt(t,__(e))},j_=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;ge(t,r);for(let s=0;s<r;s++)Xe(t,n.codePointAt(s))},ls=ki&&ki.encodeInto?I_:j_,ba=(t,e)=>{const n=t.cbuf.length,r=t.cpos,s=bs(n-r,e.length),i=e.length-s;t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,i>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(lr(n*2,i)),t.cbuf.set(e.subarray(s)),t.cpos=i)},Tt=(t,e)=>{ge(t,e.byteLength),ba(t,e)},sh=(t,e)=>{D_(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},P_=(t,e)=>sh(t,4).setFloat32(0,e,!1),B_=(t,e)=>sh(t,8).setFloat64(0,e,!1),$_=(t,e)=>sh(t,8).setBigInt64(0,e,!1),im=new DataView(new ArrayBuffer(4)),H_=t=>(im.setFloat32(0,t),im.getFloat32(0)===t),xs=(t,e)=>{switch(typeof e){case"string":Xe(t,119),ls(t,e);break;case"number":v_(e)&&$o(e)<=k_?(Xe(t,125),rh(t,e)):H_(e)?(Xe(t,124),P_(t,e)):(Xe(t,123),B_(t,e));break;case"bigint":Xe(t,122),$_(t,e);break;case"object":if(e===null)Xe(t,126);else if(Td(e)){Xe(t,117),ge(t,e.length);for(let n=0;n<e.length;n++)xs(t,e[n])}else if(e instanceof Uint8Array)Xe(t,116),Tt(t,e);else{Xe(t,118);const n=Object.keys(e);ge(t,n.length);for(let r=0;r<n.length;r++){const s=n[r];ls(t,s),xs(t,e[s])}}break;case"boolean":Xe(t,e?120:121);break;default:Xe(t,127)}};class om extends Hi{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&ge(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const lm=t=>{t.count>0&&(rh(t.encoder,t.count===1?t.s:-t.s),t.count>1&&ge(t.encoder,t.count-2))};class Ho{constructor(){this.encoder=new Hi,this.s=0,this.count=0}write(e){this.s===e?this.count++:(lm(this),this.count=1,this.s=e)}toUint8Array(){return lm(this),qt(this.encoder)}}const am=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);rh(t.encoder,e),t.count>1&&ge(t.encoder,t.count-2)}};class _c{constructor(){this.encoder=new Hi,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(am(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return am(this),qt(this.encoder)}}class z_{constructor(){this.sarr=[],this.s="",this.lensE=new Ho}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Hi;return this.sarr.push(this.s),this.s="",ls(e,this.sarr.join("")),ba(e,this.lensE.toUint8Array()),qt(e)}}const ar=t=>new Error(t),Gt=()=>{throw ar("Method unimplemented")},Mt=()=>{throw ar("Unexpected case")},R0=ar("Unexpected end of array"),O0=ar("Integer out of Range");class xa{constructor(e){this.arr=e,this.pos=0}}const ih=t=>new xa(t),F_=t=>t.pos!==t.arr.length,U_=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},It=t=>U_(t,Re(t)),vi=t=>t.arr[t.pos++],Re=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const s=t.arr[t.pos++];if(e=e+(s&Tr)*n,n*=128,s<yt)return e;if(e>_0)throw O0}throw R0},oh=t=>{let e=t.arr[t.pos++],n=e&Nd,r=64;const s=(e&Tn)>0?-1:1;if((e&yt)===0)return s*n;const i=t.arr.length;for(;t.pos<i;){if(e=t.arr[t.pos++],n=n+(e&Tr)*r,r*=128,e<yt)return s*n;if(n>_0)throw O0}throw R0},V_=t=>{let e=Re(t);if(e===0)return"";{let n=String.fromCodePoint(vi(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(vi(t));else for(;e>0;){const r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},W_=t=>ti.decode(It(t)),Od=ti?W_:V_,lh=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},q_=t=>lh(t,4).getFloat32(0,!1),K_=t=>lh(t,8).getFloat64(0,!1),G_=t=>lh(t,8).getBigInt64(0,!1),J_=[t=>{},t=>null,oh,q_,K_,G_,t=>!1,t=>!0,Od,t=>{const e=Re(t),n={};for(let r=0;r<e;r++){const s=Od(t);n[s]=jl(t)}return n},t=>{const e=Re(t),n=[];for(let r=0;r<e;r++)n.push(jl(t));return n},It],jl=t=>J_[127-vi(t)](t);class cm extends xa{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),F_(this)?this.count=Re(this)+1:this.count=-1),this.count--,this.s}}class zo extends xa{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=oh(this);const e=N0(this.s);this.count=1,e&&(this.s=-this.s,this.count=Re(this)+2)}return this.count--,this.s}}class Rc extends xa{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=oh(this),n=e&1;this.diff=_n(e/2),this.count=1,n&&(this.count=Re(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Y_{constructor(e){this.decoder=new zo(e),this.str=Od(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const X_=crypto.getRandomValues.bind(crypto),Z_=Math.random,D0=()=>X_(new Uint32Array(1))[0],Q_=t=>t[_n(Z_()*t.length)],eR="10000000-1000-4000-8000"+-1e11,tR=()=>eR.replace(/[018]/g,t=>(t^D0()&15>>t/4).toString(16)),nR=Date.now,dm=t=>new Promise(t);Promise.all.bind(Promise);const um=t=>t===void 0?null:t;class rR{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let L0=new rR,sR=!0;try{typeof localStorage<"u"&&localStorage&&(L0=localStorage,sR=!1)}catch{}const iR=L0,oR=Object.assign,I0=Object.keys,lR=(t,e)=>{for(const n in t)e(t[n],n)},hm=t=>I0(t).length,aR=t=>{for(const e in t)return!1;return!0},j0=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},cR=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),dR=(t,e)=>t===e||hm(t)===hm(e)&&j0(t,(n,r)=>(n!==void 0||cR(e,r))&&e[r]===n),uR=Object.freeze,P0=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&P0(t[e])}return uR(t)},ah=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&ah(t,e,n+1)}},hR=(t,e)=>e.includes(t),ws=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",B0=typeof window<"u"&&typeof document<"u"&&!ws;let rn;const fR=()=>{if(rn===void 0)if(ws){rn=Kt();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&rn.set(e,""),e=r):e!==null&&(rn.set(e,r),e=null)}e!==null&&rn.set(e,"")}else typeof location=="object"?(rn=Kt(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");rn.set(`--${sm(e,"-")}`,n),rn.set(`-${sm(e,"-")}`,n)}})):rn=Kt();return rn},Dd=t=>fR().has(t),Pl=t=>um(ws?process.env[t.toUpperCase().replaceAll("-","_")]:iR.getItem(t)),$0=t=>Dd("--"+t)||Pl(t)!==null;$0("production");const pR=ws&&hR(process.env.FORCE_COLOR,["true","1","2"]),mR=pR||!Dd("--no-colors")&&!$0("no-color")&&(!ws||process.stdout.isTTY)&&(!ws||Dd("--color")||Pl("COLORTERM")!==null||(Pl("TERM")||"").includes("color")),gR=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=S_(t[n]);return btoa(e)},yR=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),bR=B0?gR:yR,xR=t=>R_(e=>xs(e,t));class wR{constructor(e,n){this.left=e,this.right=n}}const xn=(t,e)=>new wR(t,e),kR=typeof document<"u"?document:{};typeof DOMParser<"u"&&new DOMParser;const vR=t=>g_(t,(e,n)=>`${n}:${e};`).join(""),SR=t=>class{constructor(n){this._=n}destroy(){t(this._)}},CR=SR(clearTimeout),H0=(t,e)=>new CR(setTimeout(e,t)),Dn=Symbol,z0=Dn(),F0=Dn(),ER=Dn(),MR=Dn(),AR=Dn(),U0=Dn(),TR=Dn(),ch=Dn(),NR=Dn(),_R=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r<t.length;r++){const s=t[r];if(s===void 0)break;if(s.constructor===String||s.constructor===Number)e.push(s);else if(s.constructor===Object)break}for(r>0&&n.push(e.join(""));r<t.length;r++){const s=t[r];s instanceof Symbol||n.push(s)}return n},RR={[z0]:xn("font-weight","bold"),[F0]:xn("font-weight","normal"),[ER]:xn("color","blue"),[AR]:xn("color","green"),[MR]:xn("color","grey"),[U0]:xn("color","red"),[TR]:xn("color","purple"),[ch]:xn("color","orange"),[NR]:xn("color","black")},OR=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[],r=Kt();let s=[],i=0;for(;i<t.length;i++){const o=t[i],l=RR[o];if(l!==void 0)r.set(l.left,l.right);else{if(o===void 0)break;if(o.constructor===String||o.constructor===Number){const a=vR(r);i>0||a.length>0?(e.push("%c"+o),n.push(a)):e.push(o)}else break}}for(i>0&&(s=n,s.unshift(e.join("")));i<t.length;i++){const o=t[i];o instanceof Symbol||s.push(o)}return s},V0=mR?OR:_R,DR=(...t)=>{console.log(...V0(t)),q0.forEach(e=>e.print(t))},W0=(...t)=>{console.warn(...V0(t)),t.unshift(ch),q0.forEach(e=>e.print(t))},q0=Pr(),K0=t=>({[Symbol.iterator](){return this},next:t}),LR=(t,e)=>K0(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Oc=(t,e)=>K0(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class dh{constructor(e,n){this.clock=e,this.len=n}}class Ts{constructor(){this.clients=new Map}}const cr=(t,e,n)=>e.clients.forEach((r,s)=>{const i=t.doc.store.clients.get(s);if(i!=null){const o=i[i.length-1],l=o.id.clock+o.length;for(let a=0,c=r[a];a<r.length&&c.clock<l;c=r[++a])tx(t,i,c.clock,c.len,n)}}),IR=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const s=_n((n+r)/2),i=t[s],o=i.clock;if(o<=e){if(e<o+i.len)return s;n=s+1}else r=s-1}return null},Ns=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&IR(n,e.clock)!==null},uh=t=>{t.clients.forEach(e=>{e.sort((s,i)=>s.clock-i.clock);let n,r;for(n=1,r=1;n<e.length;n++){const s=e[r-1],i=e[n];s.clock+s.len>=i.clock?s.len=lr(s.len,i.clock+i.len-s.clock):(r<n&&(e[r]=i),r++)}e.length=r})},Ld=t=>{const e=new Ts;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){const i=r.slice();for(let o=n+1;o<t.length;o++)b_(i,t[o].clients.get(s)||[]);e.clients.set(s,i)}});return uh(e),e},Si=(t,e,n,r)=>{On(t.clients,e,()=>[]).push(new dh(n,r))},G0=()=>new Ts,jR=t=>{const e=G0();return t.clients.forEach((n,r)=>{const s=[];for(let i=0;i<n.length;i++){const o=n[i];if(o.deleted){const l=o.id.clock;let a=o.length;if(i+1<n.length)for(let c=n[i+1];i+1<n.length&&c.deleted;c=n[++i+1])a+=c.length;s.push(new dh(l,a))}}s.length>0&&e.clients.set(r,s)}),e},hh=(t,e)=>{ge(t.restEncoder,e.clients.size),Br(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),ge(t.restEncoder,n);const s=r.length;ge(t.restEncoder,s);for(let i=0;i<s;i++){const o=r[i];t.writeDsClock(o.clock),t.writeDsLen(o.len)}})},PR=t=>{const e=new Ts,n=Re(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const s=Re(t.restDecoder),i=Re(t.restDecoder);if(i>0){const o=On(e.clients,s,()=>[]);for(let l=0;l<i;l++)o.push(new dh(t.readDsClock(),t.readDsLen()))}}return e},fm=(t,e,n)=>{const r=new Ts,s=Re(t.restDecoder);for(let i=0;i<s;i++){t.resetDsCurVal();const o=Re(t.restDecoder),l=Re(t.restDecoder),a=n.clients.get(o)||[],c=Ue(n,o);for(let d=0;d<l;d++){const u=t.readDsClock(),h=u+t.readDsLen();if(u<c){c<h&&Si(r,o,c,h-c);let f=Yt(a,u),p=a[f];for(!p.deleted&&p.id.clock<u&&(a.splice(f+1,0,Vl(e,p,u-p.id.clock)),f++);f<a.length&&(p=a[f++],p.id.clock<h);)p.deleted||(h<p.id.clock+p.length&&a.splice(f,0,Vl(e,p,h-p.id.clock)),p.delete(e))}else Si(r,o,u,h-u)}}if(r.clients.size>0){const i=new wa;return ge(i.restEncoder,0),hh(i,r),i.toUint8Array()}return null},J0=D0;class Ur extends T0{constructor({guid:e=tR(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:l=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=J0(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new Q0,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=dm(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const a=()=>dm(c=>{const d=u=>{(u===void 0||u===!0)&&(this.off("sync",d),c())};this.on("sync",d)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=a()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=a()}load(){const e=this._item;e!==null&&!this.shouldLoad&&Ce(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Br(this.subdocs).map(e=>e.guid))}transact(e,n=null){return Ce(this,e,n)}get(e,n=tt){const r=On(this.share,e,()=>{const i=new n;return i._integrate(this,null),i}),s=r.constructor;if(n!==tt&&s!==n)if(s===tt){const i=new n;i._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(e,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,ds)}getText(e=""){return this.get(e,dr)}getMap(e=""){return this.get(e,ks)}getXmlElement(e=""){return this.get(e,ht)}getXmlFragment(e=""){return this.get(e,$r)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,Br(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new Ur({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,Ce(e.parent.doc,r=>{const s=n.doc;e.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class BR{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Re(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Re(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Bl extends BR{constructor(e){super(e),this.keys=[],Re(e),this.keyClockDecoder=new Rc(It(e)),this.clientDecoder=new zo(It(e)),this.leftClockDecoder=new Rc(It(e)),this.rightClockDecoder=new Rc(It(e)),this.infoDecoder=new cm(It(e),vi),this.stringDecoder=new Y_(It(e)),this.parentInfoDecoder=new cm(It(e),vi),this.typeRefDecoder=new zo(It(e)),this.lenDecoder=new zo(It(e))}readLeftID(){return new as(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new as(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return jl(this.restDecoder)}readBuf(){return It(this.restDecoder)}readJSON(){return jl(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class $R{constructor(){this.restEncoder=zi()}toUint8Array(){return qt(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){ge(this.restEncoder,e)}writeDsLen(e){ge(this.restEncoder,e)}}class HR extends $R{writeLeftID(e){ge(this.restEncoder,e.client),ge(this.restEncoder,e.clock)}writeRightID(e){ge(this.restEncoder,e.client),ge(this.restEncoder,e.clock)}writeClient(e){ge(this.restEncoder,e)}writeInfo(e){_d(this.restEncoder,e)}writeString(e){ls(this.restEncoder,e)}writeParentInfo(e){ge(this.restEncoder,e?1:0)}writeTypeRef(e){ge(this.restEncoder,e)}writeLen(e){ge(this.restEncoder,e)}writeAny(e){xs(this.restEncoder,e)}writeBuf(e){Tt(this.restEncoder,e)}writeJSON(e){ls(this.restEncoder,JSON.stringify(e))}writeKey(e){ls(this.restEncoder,e)}}class zR{constructor(){this.restEncoder=zi(),this.dsCurrVal=0}toUint8Array(){return qt(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,ge(this.restEncoder,n)}writeDsLen(e){e===0&&Mt(),ge(this.restEncoder,e-1),this.dsCurrVal+=e}}class wa extends zR{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new _c,this.clientEncoder=new Ho,this.leftClockEncoder=new _c,this.rightClockEncoder=new _c,this.infoEncoder=new om(_d),this.stringEncoder=new z_,this.parentInfoEncoder=new om(_d),this.typeRefEncoder=new Ho,this.lenEncoder=new Ho}toUint8Array(){const e=zi();return ge(e,0),Tt(e,this.keyClockEncoder.toUint8Array()),Tt(e,this.clientEncoder.toUint8Array()),Tt(e,this.leftClockEncoder.toUint8Array()),Tt(e,this.rightClockEncoder.toUint8Array()),Tt(e,qt(this.infoEncoder)),Tt(e,this.stringEncoder.toUint8Array()),Tt(e,qt(this.parentInfoEncoder)),Tt(e,this.typeRefEncoder.toUint8Array()),Tt(e,this.lenEncoder.toUint8Array()),ba(e,qt(this.restEncoder)),qt(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){xs(this.restEncoder,e)}writeBuf(e){Tt(this.restEncoder,e)}writeJSON(e){xs(this.restEncoder,e)}writeKey(e){const n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}}const FR=(t,e,n,r)=>{r=lr(r,e[0].id.clock);const s=Yt(e,r);ge(t.restEncoder,e.length-s),t.writeClient(n),ge(t.restEncoder,r);const i=e[s];i.write(t,r-i.id.clock);for(let o=s+1;o<e.length;o++)e[o].write(t,0)},Y0=(t,e,n)=>{const r=new Map;n.forEach((s,i)=>{Ue(e,i)>s&&r.set(i,s)}),ka(e).forEach((s,i)=>{n.has(i)||r.set(i,0)}),ge(t.restEncoder,r.size),Br(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{FR(t,e.clients.get(s),s,i)})},UR=(t,e)=>{const n=Kt(),r=Re(t.restDecoder);for(let s=0;s<r;s++){const i=Re(t.restDecoder),o=new Array(i),l=t.readClient();let a=Re(t.restDecoder);n.set(l,{i:0,refs:o});for(let c=0;c<i;c++){const d=t.readInfo();switch(ya&d){case 0:{const u=t.readLen();o[c]=new Bt(ce(l,a),u),a+=u;break}case 10:{const u=Re(t.restDecoder);o[c]=new Vt(ce(l,a),u),a+=u;break}default:{const u=(d&(Tn|yt))===0,h=new ve(ce(l,a),null,(d&yt)===yt?t.readLeftID():null,null,(d&Tn)===Tn?t.readRightID():null,u?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,u&&(d&wi)===wi?t.readString():null,Sx(t,d));o[c]=h,a+=h.length}}}}return n},VR=(t,e,n)=>{const r=[];let s=Br(n.keys()).sort((f,p)=>f-p);if(s.length===0)return null;const i=()=>{if(s.length===0)return null;let f=n.get(s[s.length-1]);for(;f.refs.length===f.i;)if(s.pop(),s.length>0)f=n.get(s[s.length-1]);else return null;return f};let o=i();if(o===null)return null;const l=new Q0,a=new Map,c=(f,p)=>{const g=a.get(f);(g==null||g>p)&&a.set(f,p)};let d=o.refs[o.i++];const u=new Map,h=()=>{for(const f of r){const p=f.id.client,g=n.get(p);g?(g.i--,l.clients.set(p,g.refs.slice(g.i)),n.delete(p),g.i=0,g.refs=[]):l.clients.set(p,[f]),s=s.filter(y=>y!==p)}r.length=0};for(;;){if(d.constructor!==Vt){const p=On(u,d.id.client,()=>Ue(e,d.id.client))-d.id.clock;if(p<0)r.push(d),c(d.id.client,d.id.clock-1),h();else{const g=d.getMissing(t,e);if(g!==null){r.push(d);const y=n.get(g)||{refs:[],i:0};if(y.refs.length===y.i)c(g,Ue(e,g)),h();else{d=y.refs[y.i++];continue}}else(p===0||p<d.length)&&(d.integrate(t,p),u.set(d.id.client,d.id.clock+d.length))}}if(r.length>0)d=r.pop();else if(o!==null&&o.i<o.refs.length)d=o.refs[o.i++];else{if(o=i(),o===null)break;d=o.refs[o.i++]}}if(l.clients.size>0){const f=new wa;return Y0(f,l,new Map),ge(f.restEncoder,0),{missing:a,update:f.toUint8Array()}}return null},WR=(t,e)=>Y0(t,e.doc.store,e.beforeState),qR=(t,e,n,r=new Bl(t))=>Ce(e,s=>{s.local=!1;let i=!1;const o=s.doc,l=o.store,a=UR(r,o),c=VR(s,l,a),d=l.pendingStructs;if(d){for(const[h,f]of d.missing)if(f<Ue(l,h)){i=!0;break}if(c){for(const[h,f]of c.missing){const p=d.missing.get(h);(p==null||p>f)&&d.missing.set(h,f)}d.update=vm([d.update,c.update])}}else l.pendingStructs=c;const u=fm(r,s,l);if(l.pendingDs){const h=new Bl(ih(l.pendingDs));Re(h.restDecoder);const f=fm(h,s,l);u&&f?l.pendingDs=vm([u,f]):l.pendingDs=u||f}else l.pendingDs=u;if(i){const h=l.pendingStructs.update;l.pendingStructs=null,Id(s.doc,h)}},n,!1),Id=(t,e,n,r=Bl)=>{const s=ih(e);qR(s,t,n,new r(s))};class KR{constructor(){this.l=[]}}const pm=()=>new KR,mm=(t,e)=>t.l.push(e),gm=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(s=>e!==s),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},X0=(t,e,n)=>ah(t.l,[e,n]);class as{constructor(e,n){this.client=e,this.clock=n}}const Eo=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,ce=(t,e)=>new as(t,e),Ci=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Mt()},Ei=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class $l{constructor(e,n,r,s=0){this.type=e,this.tname=n,this.item=r,this.assoc=s}}class GR{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const JR=(t,e,n=0)=>new GR(t,e,n),Mo=(t,e,n)=>{let r=null,s=null;return t._item===null?s=Ci(t):r=ce(t._item.id.client,t._item.id.clock),new $l(r,s,e,n)},Dc=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Mo(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Mo(t,ce(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Mo(t,r.lastId,n);r=r.right}return Mo(t,null,n)},YR=(t,e)=>{const n=cs(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},XR=(t,e,n=!0)=>{const r=e.store,s=t.item,i=t.type,o=t.tname,l=t.assoc;let a=null,c=0;if(s!==null){if(Ue(r,s.client)<=s.clock)return null;const d=n?$d(r,s):YR(r,s),u=d.item;if(!(u instanceof ve))return null;if(a=u.parent,a._item===null||!a._item.deleted){c=u.deleted||!u.countable?0:d.diff+(l>=0?0:1);let h=u.left;for(;h!==null;)!h.deleted&&h.countable&&(c+=h.length),h=h.left}}else{if(o!==null)a=e.get(o);else if(i!==null){if(Ue(r,i.client)<=i.clock)return null;const{item:d}=n?$d(r,i):{item:cs(r,i)};if(d instanceof ve&&d.content instanceof en)a=d.content.type;else return null}else throw Mt();l>=0?c=a._length:c=0}return JR(a,c,t.assoc)};class fh{constructor(e,n){this.ds=e,this.sv=n}}const Z0=(t,e)=>new fh(t,e),Lc=t=>Z0(jR(t.store),ka(t.store)),br=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!Ns(e.ds,t.id),jd=(t,e)=>{const n=On(t.meta,jd,Pr),r=t.doc.store;n.has(e)||(e.sv.forEach((s,i)=>{s<Ue(r,i)&&vt(t,ce(i,s))}),cr(t,e.ds,s=>{}),n.add(e))};class Q0{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const ka=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},Ue=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},ex=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw Mt()}n.push(e)},Yt=(t,e)=>{let n=0,r=t.length-1,s=t[r],i=s.id.clock;if(i===e)return r;let o=_n(e/(i+s.length-1)*r);for(;n<=r;){if(s=t[o],i=s.id.clock,i<=e){if(e<i+s.length)return o;n=o+1}else r=o-1;o=_n((n+r)/2)}throw Mt()},ZR=(t,e)=>{const n=t.clients.get(e.client);return n[Yt(n,e.clock)]},cs=ZR,Pd=(t,e,n)=>{const r=Yt(e,n),s=e[r];return s.id.clock<n&&s instanceof ve?(e.splice(r+1,0,Vl(t,s,n-s.id.clock)),r+1):r},vt=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[Pd(t,n,e.clock)]},ym=(t,e,n)=>{const r=e.clients.get(n.client),s=Yt(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==Bt&&r.splice(s+1,0,Vl(t,i,n.clock-i.id.clock+1)),i},QR=(t,e,n)=>{const r=t.clients.get(e.id.client);r[Yt(r,e.id.clock)]=n},tx=(t,e,n,r,s)=>{if(r===0)return;const i=n+r;let o=Pd(t,e,n),l;do l=e[o++],i<l.id.clock+l.length&&Pd(t,e,i),s(l);while(o<e.length&&e[o].id.clock<i)};class eO{constructor(e,n,r){this.doc=e,this.deleteSet=new Ts,this.beforeState=ka(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const bm=(t,e)=>e.deleteSet.clients.size===0&&!y_(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(uh(e.deleteSet),WR(t,e),hh(t,e.deleteSet),!0),xm=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&On(t.changed,e,Pr).add(n)},Fo=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof ve&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const i=e-s;return i&&t.splice(e+1-i,i),i},tO=(t,e,n)=>{for(const[r,s]of t.clients.entries()){const i=e.clients.get(r);for(let o=s.length-1;o>=0;o--){const l=s[o],a=l.clock+l.len;for(let c=Yt(i,l.clock),d=i[c];c<i.length&&d.id.clock<a;d=i[++c]){const u=i[c];if(l.clock+l.len<=u.id.clock)break;u instanceof ve&&u.deleted&&!u.keep&&n(u)&&u.gc(e,!1)}}}},nO=(t,e)=>{t.clients.forEach((n,r)=>{const s=e.clients.get(r);for(let i=n.length-1;i>=0;i--){const o=n[i],l=bs(s.length-1,1+Yt(s,o.clock+o.len-1));for(let a=l,c=s[a];a>0&&c.id.clock>=o.clock;c=s[a])a-=1+Fo(s,a)}})},nx=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{uh(i),n.afterState=ka(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const l=[];n.changed.forEach((a,c)=>l.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(n,a)})),l.push(()=>{n.changedParentTypes.forEach((a,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(a=a.filter(d=>d.target._item===null||!d.target._item.deleted),a.forEach(d=>{d.currentTarget=c,d._path=null}),a.sort((d,u)=>d.path.length-u.path.length),X0(c._dEH,a,n))})}),l.push(()=>r.emit("afterTransaction",[n,r])),ah(l,[]),n._needFormattingCleanup&&vO(n)}finally{r.gc&&tO(i,s,r.gcFilter),nO(i,s),n.afterState.forEach((d,u)=>{const h=n.beforeState.get(u)||0;if(h!==d){const f=s.clients.get(u),p=lr(Yt(f,h),1);for(let g=f.length-1;g>=p;)g-=1+Fo(f,g)}});for(let d=o.length-1;d>=0;d--){const{client:u,clock:h}=o[d].id,f=s.clients.get(u),p=Yt(f,h);p+1<f.length&&Fo(f,p+1)>1||p>0&&Fo(f,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(DR(ch,z0,"[yjs] ",F0,U0,"Changed the client-id because another client seems to be using it."),r.clientID=J0()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const d=new HR;bm(d,n)&&r.emit("update",[d.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const d=new wa;bm(d,n)&&r.emit("updateV2",[d.toUint8Array(),n.origin,r,n])}const{subdocsAdded:l,subdocsLoaded:a,subdocsRemoved:c}=n;(l.size>0||c.size>0||a.size>0)&&(l.forEach(d=>{d.clientID=r.clientID,d.collectionid==null&&(d.collectionid=r.collectionid),r.subdocs.add(d)}),c.forEach(d=>r.subdocs.delete(d)),r.emit("subdocs",[{loaded:a,added:l,removed:c},r,n]),c.forEach(d=>d.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):nx(t,e+1)}}},Ce=(t,e,n=null,r=!0)=>{const s=t._transactionCleanups;let i=!1,o=null;t._transaction===null&&(i=!0,t._transaction=new eO(t,n,r),s.push(t._transaction),s.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(i){const l=t._transaction===s[0];t._transaction=null,l&&nx(s,0)}}return o};class rO{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const wm=(t,e,n)=>{cr(t,n.deletions,r=>{r instanceof ve&&e.scope.some(s=>s===t.doc||Ei(s,r))&&bh(r,!1)})},km=(t,e,n)=>{let r=null;const s=t.doc,i=t.scope;Ce(s,l=>{for(;e.length>0&&t.currStackItem===null;){const a=s.store,c=e.pop(),d=new Set,u=[];let h=!1;cr(l,c.insertions,f=>{if(f instanceof ve){if(f.redone!==null){let{item:p,diff:g}=$d(a,f.id);g>0&&(p=vt(l,ce(p.id.client,p.id.clock+g))),f=p}!f.deleted&&i.some(p=>p===l.doc||Ei(p,f))&&u.push(f)}}),cr(l,c.deletions,f=>{f instanceof ve&&i.some(p=>p===l.doc||Ei(p,f))&&!Ns(c.insertions,f.id)&&d.add(f)}),d.forEach(f=>{h=vx(l,f,d,c.insertions,t.ignoreRemoteMapChanges,t)!==null||h});for(let f=u.length-1;f>=0;f--){const p=u[f];t.deleteFilter(p)&&(p.delete(l),h=!0)}t.currStackItem=h?c:null}l.changed.forEach((a,c)=>{a.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=l},t);const o=t.currStackItem;if(o!=null){const l=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return o};class rx extends T0{constructor(e,{captureTimeout:n=500,captureTransaction:r=a=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:l=Td(e)?e[0].doc:e instanceof Ur?e:e.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(e),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=a=>{if(!this.captureTransaction(a)||!this.scope.some(y=>a.changedParentTypes.has(y)||y===this.doc)||!this.trackedOrigins.has(a.origin)&&(!a.origin||!this.trackedOrigins.has(a.origin.constructor)))return;const c=this.undoing,d=this.redoing,u=c?this.redoStack:this.undoStack;c?this.stopCapturing():d||this.clear(!1,!0);const h=new Ts;a.afterState.forEach((y,b)=>{const w=a.beforeState.get(b)||0,A=y-w;A>0&&Si(h,b,w,A)});const f=nR();let p=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&u.length>0&&!c&&!d){const y=u[u.length-1];y.deletions=Ld([y.deletions,a.deleteSet]),y.insertions=Ld([y.insertions,h])}else u.push(new rO(a.deleteSet,h)),p=!0;!c&&!d&&(this.lastChange=f),cr(a,a.deleteSet,y=>{y instanceof ve&&this.scope.some(b=>b===a.doc||Ei(b,y))&&bh(y,!0)});const g=[{stackItem:u[u.length-1],origin:a.origin,type:c?"redo":"undo",changedParentTypes:a.changedParentTypes},this];p?this.emit("stack-item-added",g):this.emit("stack-item-updated",g)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const n=new Set(this.scope);e=Td(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof tt?r.doc!==this.doc:r!==this.doc)&&W0("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(s=>wm(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>wm(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=km(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=km(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*sO(t){const e=Re(t.restDecoder);for(let n=0;n<e;n++){const r=Re(t.restDecoder),s=t.readClient();let i=Re(t.restDecoder);for(let o=0;o<r;o++){const l=t.readInfo();if(l===10){const a=Re(t.restDecoder);yield new Vt(ce(s,i),a),i+=a}else if((ya&l)!==0){const a=(l&(Tn|yt))===0,c=new ve(ce(s,i),null,(l&yt)===yt?t.readLeftID():null,null,(l&Tn)===Tn?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(l&wi)===wi?t.readString():null,Sx(t,l));yield c,i+=c.length}else{const a=t.readLen();yield new Bt(ce(s,i),a),i+=a}}}}class iO{constructor(e,n){this.gen=sO(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Vt);return this.curr}}class oO{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const lO=(t,e)=>{if(t.constructor===Bt){const{client:n,clock:r}=t.id;return new Bt(ce(n,r+e),t.length-e)}else if(t.constructor===Vt){const{client:n,clock:r}=t.id;return new Vt(ce(n,r+e),t.length-e)}else{const n=t,{client:r,clock:s}=n.id;return new ve(ce(r,s+e),null,ce(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},vm=(t,e=Bl,n=wa)=>{if(t.length===1)return t[0];const r=t.map(d=>new e(ih(d)));let s=r.map(d=>new iO(d,!0)),i=null;const o=new n,l=new oO(o);for(;s=s.filter(h=>h.curr!==null),s.sort((h,f)=>{if(h.curr.id.client===f.curr.id.client){const p=h.curr.id.clock-f.curr.id.clock;return p===0?h.curr.constructor===f.curr.constructor?0:h.curr.constructor===Vt?1:-1:p}else return f.curr.id.client-h.curr.id.client}),s.length!==0;){const d=s[0],u=d.curr.id.client;if(i!==null){let h=d.curr,f=!1;for(;h!==null&&h.id.clock+h.length<=i.struct.id.clock+i.struct.length&&h.id.client>=i.struct.id.client;)h=d.next(),f=!0;if(h===null||h.id.client!==u||f&&h.id.clock>i.struct.id.clock+i.struct.length)continue;if(u!==i.struct.id.client)Bs(l,i.struct,i.offset),i={struct:h,offset:0},d.next();else if(i.struct.id.clock+i.struct.length<h.id.clock)if(i.struct.constructor===Vt)i.struct.length=h.id.clock+h.length-i.struct.id.clock;else{Bs(l,i.struct,i.offset);const p=h.id.clock-i.struct.id.clock-i.struct.length;i={struct:new Vt(ce(u,i.struct.id.clock+i.struct.length),p),offset:0}}else{const p=i.struct.id.clock+i.struct.length-h.id.clock;p>0&&(i.struct.constructor===Vt?i.struct.length-=p:h=lO(h,p)),i.struct.mergeWith(h)||(Bs(l,i.struct,i.offset),i={struct:h,offset:0},d.next())}}else i={struct:d.curr,offset:0},d.next();for(let h=d.curr;h!==null&&h.id.client===u&&h.id.clock===i.struct.id.clock+i.struct.length&&h.constructor!==Vt;h=d.next())Bs(l,i.struct,i.offset),i={struct:h,offset:0}}i!==null&&(Bs(l,i.struct,i.offset),i=null),aO(l);const a=r.map(d=>PR(d)),c=Ld(a);return hh(o,c),o.toUint8Array()},sx=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:qt(t.encoder.restEncoder)}),t.encoder.restEncoder=zi(),t.written=0)},Bs=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&sx(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),ge(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},aO=t=>{sx(t);const e=t.encoder.restEncoder;ge(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];ge(e,r.written),ba(e,r.restEncoder)}},Sm="You must not compute changes after the event-handler fired.";class va{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=cO(this.currentTarget,this.target))}deletes(e){return Ns(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw ar(Sm);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){const i=n._map.get(s);let o,l;if(this.adds(i)){let a=i.left;for(;a!==null&&this.adds(a);)a=a.left;if(this.deletes(i))if(a!==null&&this.deletes(a))o="delete",l=Ac(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",l=Ac(a.content.getContent())):(o="add",l=void 0)}else if(this.deletes(i))o="delete",l=Ac(i.content.getContent());else return;e.set(s,{action:o,oldValue:l})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw ar(Sm);const n=this.target,r=Pr(),s=Pr(),i=[];if(e={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let l=null;const a=()=>{l&&i.push(l)};for(let c=n._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((l===null||l.delete===void 0)&&(a(),l={delete:0}),l.delete+=c.length,s.add(c)):this.adds(c)?((l===null||l.insert===void 0)&&(a(),l={insert:[]}),l.insert=l.insert.concat(c.content.getContent()),r.add(c)):((l===null||l.retain===void 0)&&(a(),l={retain:0}),l.retain+=c.length);l!==null&&l.retain===void 0&&a()}this._changes=e}return e}}const cO=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;n.unshift(r)}e=e._item.parent}return n},ft=()=>{W0("Invalid access: Add Yjs type to a document before reading data.")},ix=80;let ph=0;class dO{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=ph++}}const uO=t=>{t.timestamp=ph++},ox=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=ph++},hO=(t,e,n)=>{if(t.length>=ix){const r=t.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return ox(r,e,n),r}else{const r=new dO(e,n);return t.push(r),r}},Sa=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((i,o)=>$o(e-i.index)<$o(e-o.index)?i:o);let r=t._start,s=0;for(n!==null&&(r=n.p,s=n.index,uO(n));r.right!==null&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return n!==null&&$o(n.index-s)<r.parent.length/ix?(ox(n,r,s),n):hO(t._searchMarker,r,s)},Mi=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const s=t[r];if(n>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){t.splice(r,1);continue}s.p=i,i.marker=!0}(e<s.index||n>0&&e===s.index)&&(s.index=lr(e,s.index+n))}},Ca=(t,e,n)=>{const r=t,s=e.changedParentTypes;for(;On(s,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;X0(r._eH,n,e)};class tt{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=pm(),this._dEH=pm(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw Gt()}clone(){throw Gt()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){mm(this._eH,e)}observeDeep(e){mm(this._dEH,e)}unobserve(e){gm(this._eH,e)}unobserveDeep(e){gm(this._dEH,e)}toJSON(){}}const lx=(t,e,n)=>{t.doc??ft(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const s=[];let i=t._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){const o=i.content.getContent();if(o.length<=e)e-=o.length;else{for(let l=e;l<o.length&&r>0;l++)s.push(o[l]),r--;e=0}}i=i.right}return s},ax=t=>{t.doc??ft();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e},cx=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&br(r,e)){const s=r.content.getContent();for(let i=0;i<s.length;i++)n.push(s[i])}r=r.right}return n},Ai=(t,e)=>{let n=0,r=t._start;for(t.doc??ft();r!==null;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let i=0;i<s.length;i++)e(s[i],n++,t)}r=r.right}},dx=(t,e)=>{const n=[];return Ai(t,(r,s)=>{n.push(e(r,s,t))}),n},fO=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},ux=(t,e)=>{t.doc??ft();const n=Sa(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Hl=(t,e,n,r)=>{let s=n;const i=t.doc,o=i.clientID,l=i.store,a=n===null?e._start:n.right;let c=[];const d=()=>{c.length>0&&(s=new ve(ce(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Hr(c)),s.integrate(t,0),c=[])};r.forEach(u=>{if(u===null)c.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(u);break;default:switch(d(),u.constructor){case Uint8Array:case ArrayBuffer:s=new ve(ce(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Fi(new Uint8Array(u))),s.integrate(t,0);break;case Ur:s=new ve(ce(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Ui(u)),s.integrate(t,0);break;default:if(u instanceof tt)s=new ve(ce(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new en(u)),s.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),d()},hx=()=>ar("Length exceeded!"),fx=(t,e,n,r)=>{if(n>e._length)throw hx();if(n===0)return e._searchMarker&&Mi(e._searchMarker,n,r.length),Hl(t,e,null,r);const s=n,i=Sa(e,n);let o=e._start;for(i!==null&&(o=i.p,n-=i.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&vt(t,ce(o.id.client,o.id.clock+n));break}n-=o.length}return e._searchMarker&&Mi(e._searchMarker,s,r.length),Hl(t,e,o,r)},pO=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:e._start}).p;if(s)for(;s.right;)s=s.right;return Hl(t,e,s,n)},px=(t,e,n,r)=>{if(r===0)return;const s=n,i=r,o=Sa(e,n);let l=e._start;for(o!==null&&(l=o.p,n-=o.index);l!==null&&n>0;l=l.right)!l.deleted&&l.countable&&(n<l.length&&vt(t,ce(l.id.client,l.id.clock+n)),n-=l.length);for(;r>0&&l!==null;)l.deleted||(r<l.length&&vt(t,ce(l.id.client,l.id.clock+r)),l.delete(t),r-=l.length),l=l.right;if(r>0)throw hx();e._searchMarker&&Mi(e._searchMarker,s,-i+r)},zl=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},mh=(t,e,n,r)=>{const s=e._map.get(n)||null,i=t.doc,o=i.clientID;let l;if(r==null)l=new Hr([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new Hr([r]);break;case Uint8Array:l=new Fi(r);break;case Ur:l=new Ui(r);break;default:if(r instanceof tt)l=new en(r);else throw new Error("Unexpected content type")}new ve(ce(o,Ue(i.store,o)),s,s&&s.lastId,null,null,e,n,l).integrate(t,0)},gh=(t,e)=>{t.doc??ft();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},mx=t=>{const e={};return t.doc??ft(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},gx=(t,e)=>{t.doc??ft();const n=t._map.get(e);return n!==void 0&&!n.deleted},mO=(t,e)=>{const n={};return t._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&&br(i,e)&&(n[s]=i.content.getContent()[i.length-1])}),n},Ao=t=>(t.doc??ft(),LR(t._map.entries(),e=>!e[1].deleted));class gO extends va{}class ds extends tt{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new ds;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ds}clone(){const e=new ds;return e.insert(0,this.toArray().map(n=>n instanceof tt?n.clone():n)),e}get length(){return this.doc??ft(),this._length}_callObserver(e,n){super._callObserver(e,n),Ca(this,e,new gO(this,e))}insert(e,n){this.doc!==null?Ce(this.doc,r=>{fx(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?Ce(this.doc,n=>{pO(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?Ce(this.doc,r=>{px(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return ux(this,e)}toArray(){return ax(this)}slice(e=0,n=this.length){return lx(this,e,n)}toJSON(){return this.map(e=>e instanceof tt?e.toJSON():e)}map(e){return dx(this,e)}forEach(e){Ai(this,e)}[Symbol.iterator](){return fO(this)}_write(e){e.writeTypeRef(zO)}}const yO=t=>new ds;class bO extends va{constructor(e,n,r){super(e,n),this.keysChanged=r}}class ks extends tt{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new ks}clone(){const e=new ks;return this.forEach((n,r)=>{e.set(r,n instanceof tt?n.clone():n)}),e}_callObserver(e,n){Ca(this,e,new bO(this,e,n))}toJSON(){this.doc??ft();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const s=n.content.getContent()[n.length-1];e[r]=s instanceof tt?s.toJSON():s}}),e}get size(){return[...Ao(this)].length}keys(){return Oc(Ao(this),e=>e[0])}values(){return Oc(Ao(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Oc(Ao(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??ft(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?Ce(this.doc,n=>{zl(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?Ce(this.doc,r=>{mh(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return gh(this,e)}has(e){return gx(this,e)}clear(){this.doc!==null?Ce(this.doc,e=>{this.forEach(function(n,r,s){zl(e,s,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(FO)}}const xO=t=>new ks,Yn=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&dR(t,e);class Bd{constructor(e,n,r,s){this.left=e,this.right=n,this.index=r,this.currentAttributes=s}forward(){switch(this.right===null&&Mt(),this.right.content.constructor){case Ge:this.right.deleted||_s(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const Cm=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case Ge:e.right.deleted||_s(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n<e.right.length&&vt(t,ce(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},To=(t,e,n,r)=>{const s=new Map,i=r?Sa(e,n):null;if(i){const o=new Bd(i.p.left,i.p,i.index,s);return Cm(t,o,n-i.index)}else{const o=new Bd(null,e._start,0,s);return Cm(t,o,n)}},yx=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Ge&&Yn(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const s=t.doc,i=s.clientID;r.forEach((o,l)=>{const a=n.left,c=n.right,d=new ve(ce(i,Ue(s.store,i)),a,a&&a.lastId,c,c&&c.id,e,null,new Ge(l,o));d.integrate(t,0),n.right=d,n.forward()})},_s=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},bx=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Ge&&Yn(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},xx=(t,e,n,r)=>{const s=t.doc,i=s.clientID,o=new Map;for(const l in r){const a=r[l],c=n.currentAttributes.get(l)??null;if(!Yn(c,a)){o.set(l,c);const{left:d,right:u}=n;n.right=new ve(ce(i,Ue(s.store,i)),d,d&&d.lastId,u,u&&u.id,e,null,new Ge(l,a)),n.right.integrate(t,0),n.forward()}}return o},Ic=(t,e,n,r,s)=>{n.currentAttributes.forEach((h,f)=>{s[f]===void 0&&(s[f]=null)});const i=t.doc,o=i.clientID;bx(n,s);const l=xx(t,e,n,s),a=r.constructor===String?new Xt(r):r instanceof tt?new en(r):new Vr(r);let{left:c,right:d,index:u}=n;e._searchMarker&&Mi(e._searchMarker,n.index,a.getLength()),d=new ve(ce(o,Ue(i.store,o)),c,c&&c.lastId,d,d&&d.id,e,null,a),d.integrate(t,0),n.right=d,n.index=u,n.forward(),yx(t,e,n,l)},Em=(t,e,n,r,s)=>{const i=t.doc,o=i.clientID;bx(n,s);const l=xx(t,e,n,s);e:for(;n.right!==null&&(r>0||l.size>0&&(n.right.deleted||n.right.content.constructor===Ge));){if(!n.right.deleted)switch(n.right.content.constructor){case Ge:{const{key:a,value:c}=n.right.content,d=s[a];if(d!==void 0){if(Yn(d,c))l.delete(a);else{if(r===0)break e;l.set(a,c)}n.right.delete(t)}else n.currentAttributes.set(a,c);break}default:r<n.right.length&&vt(t,ce(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
150
- `;n.right=new ve(ce(o,Ue(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new Xt(a)),n.right.integrate(t,0),n.forward()}yx(t,e,n,l)},wx=(t,e,n,r,s)=>{let i=e;const o=Kt();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===Ge){const c=i.content;o.set(c.key,c)}i=i.right}let l=0,a=!1;for(;e!==i;){if(n===e&&(a=!0),!e.deleted){const c=e.content;switch(c.constructor){case Ge:{const{key:d,value:u}=c,h=r.get(d)??null;(o.get(d)!==c||h===u)&&(e.delete(t),l++,!a&&(s.get(d)??null)===u&&h!==u&&(h===null?s.delete(d):s.set(d,h))),!a&&!e.deleted&&_s(s,c);break}}}e=e.right}return l},wO=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Ge){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},kO=t=>{let e=0;return Ce(t.doc,n=>{let r=t._start,s=t._start,i=Kt();const o=Ad(i);for(;s;){if(s.deleted===!1)switch(s.content.constructor){case Ge:_s(o,s.content);break;default:e+=wx(n,r,s,i,o),i=Ad(o),r=s;break}s=s.right}}),e},vO=t=>{const e=new Set,n=t.doc;for(const[r,s]of t.afterState.entries()){const i=t.beforeState.get(r)||0;s!==i&&tx(t,n.store.clients.get(r),i,s,o=>{!o.deleted&&o.content.constructor===Ge&&o.constructor!==Bt&&e.add(o.parent)})}Ce(n,r=>{cr(t,t.deleteSet,s=>{if(s instanceof Bt||!s.parent._hasFormatting||e.has(s.parent))return;const i=s.parent;s.content.constructor===Ge?e.add(i):wO(r,s)});for(const s of e)kO(s)})},Mm=(t,e,n)=>{const r=n,s=Ad(e.currentAttributes),i=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case en:case Vr:case Xt:n<e.right.length&&vt(t,ce(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}i&&wx(t,i,e.right,s,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&Mi(o._searchMarker,e.index,-r+n),e};class SO extends va{constructor(e,n,r){super(e,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(s=>{s===null?this.childListChanged=!0:this.keysChanged.add(s)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,n=[];Ce(e,r=>{const s=new Map,i=new Map;let o=this.target._start,l=null;const a={};let c="",d=0,u=0;const h=()=>{if(l!==null){let f=null;switch(l){case"delete":u>0&&(f={delete:u}),u=0;break;case"insert":(typeof c=="object"||c.length>0)&&(f={insert:c},s.size>0&&(f.attributes={},s.forEach((p,g)=>{p!==null&&(f.attributes[g]=p)}))),c="";break;case"retain":d>0&&(f={retain:d},aR(a)||(f.attributes=oR({},a))),d=0;break}f&&n.push(f),l=null}};for(;o!==null;){switch(o.content.constructor){case en:case Vr:this.adds(o)?this.deletes(o)||(h(),l="insert",c=o.content.getContent()[0],h()):this.deletes(o)?(l!=="delete"&&(h(),l="delete"),u+=1):o.deleted||(l!=="retain"&&(h(),l="retain"),d+=1);break;case Xt:this.adds(o)?this.deletes(o)||(l!=="insert"&&(h(),l="insert"),c+=o.content.str):this.deletes(o)?(l!=="delete"&&(h(),l="delete"),u+=o.length):o.deleted||(l!=="retain"&&(h(),l="retain"),d+=o.length);break;case Ge:{const{key:f,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){const g=s.get(f)??null;Yn(g,p)?p!==null&&o.delete(r):(l==="retain"&&h(),Yn(p,i.get(f)??null)?delete a[f]:a[f]=p)}}else if(this.deletes(o)){i.set(f,p);const g=s.get(f)??null;Yn(g,p)||(l==="retain"&&h(),a[f]=g)}else if(!o.deleted){i.set(f,p);const g=a[f];g!==void 0&&(Yn(g,p)?g!==null&&o.delete(r):(l==="retain"&&h(),p===null?delete a[f]:a[f]=p))}o.deleted||(l==="insert"&&h(),_s(s,o.content));break}}o=o.right}for(h();n.length>0;){const f=n[n.length-1];if(f.retain!==void 0&&f.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class dr extends tt{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??ft(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new dr}clone(){const e=new dr;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new SO(this,e,n);Ca(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??ft();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Xt&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?Ce(this.doc,r=>{const s=new Bd(null,this._start,0,new Map);for(let i=0;i<e.length;i++){const o=e[i];if(o.insert!==void 0){const l=!n&&typeof o.insert=="string"&&i===e.length-1&&s.right===null&&o.insert.slice(-1)===`
151
- `?o.insert.slice(0,-1):o.insert;(typeof l!="string"||l.length>0)&&Ic(r,this,s,l,o.attributes||{})}else o.retain!==void 0?Em(r,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&Mm(r,s,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??ft();const s=[],i=new Map,o=this.doc;let l="",a=this._start;function c(){if(l.length>0){const u={};let h=!1;i.forEach((p,g)=>{h=!0,u[g]=p});const f={insert:l};h&&(f.attributes=u),s.push(f),l=""}}const d=()=>{for(;a!==null;){if(br(a,e)||n!==void 0&&br(a,n))switch(a.content.constructor){case Xt:{const u=i.get("ychange");e!==void 0&&!br(a,e)?(u===void 0||u.user!==a.id.client||u.type!=="removed")&&(c(),i.set("ychange",r?r("removed",a.id):{type:"removed"})):n!==void 0&&!br(a,n)?(u===void 0||u.user!==a.id.client||u.type!=="added")&&(c(),i.set("ychange",r?r("added",a.id):{type:"added"})):u!==void 0&&(c(),i.delete("ychange")),l+=a.content.str;break}case en:case Vr:{c();const u={insert:a.content.getContent()[0]};if(i.size>0){const h={};u.attributes=h,i.forEach((f,p)=>{h[p]=f})}s.push(u);break}case Ge:br(a,e)&&(c(),_s(i,a.content));break}a=a.right}c()};return e||n?Ce(o,u=>{e&&jd(u,e),n&&jd(u,n),d()},"cleanup"):d(),s}insert(e,n,r){if(n.length<=0)return;const s=this.doc;s!==null?Ce(s,i=>{const o=To(i,this,e,!r);r||(r={},o.currentAttributes.forEach((l,a)=>{r[a]=l})),Ic(i,this,o,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const s=this.doc;s!==null?Ce(s,i=>{const o=To(i,this,e,!r);Ic(i,this,o,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;const r=this.doc;r!==null?Ce(r,s=>{Mm(s,To(s,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const s=this.doc;s!==null?Ce(s,i=>{const o=To(i,this,e,!1);o.right!==null&&Em(i,this,o,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?Ce(this.doc,n=>{zl(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?Ce(this.doc,r=>{mh(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return gh(this,e)}getAttributes(){return mx(this)}_write(e){e.writeTypeRef(UO)}}const CO=t=>new dr;class jc{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??ft()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===ht||n.constructor===$r)&&n._start!==null)e=n._start;else for(;e!==null;){const r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class $r extends tt{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new $r}clone(){const e=new $r;return e.insert(0,this.toArray().map(n=>n instanceof tt?n.clone():n)),e}get length(){return this.doc??ft(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new jc(this,e)}querySelector(e){e=e.toUpperCase();const r=new jc(this,s=>s.nodeName&&s.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),Br(new jc(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){Ca(this,e,new AO(this,n,e))}toString(){return dx(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const s=e.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),Ai(this,i=>{s.insertBefore(i.toDOM(e,n,r),null)}),s}insert(e,n){this.doc!==null?Ce(this.doc,r=>{fx(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)Ce(this.doc,r=>{const s=e&&e instanceof tt?e._item:e;Hl(r,this,s,n)});else{const r=this._prelimContent,s=e===null?0:r.findIndex(i=>i===e)+1;if(s===0&&e!==null)throw ar("Reference item not found");r.splice(s,0,...n)}}delete(e,n=1){this.doc!==null?Ce(this.doc,r=>{px(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return ax(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return ux(this,e)}slice(e=0,n=this.length){return lx(this,e,n)}forEach(e){Ai(this,e)}_write(e){e.writeTypeRef(WO)}}const EO=t=>new $r;class ht extends $r{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new ht(this.nodeName)}clone(){const e=new ht(this.nodeName),n=this.getAttributes();return lR(n,(r,s)=>{typeof r=="string"&&e.setAttribute(s,r)}),e.insert(0,this.toArray().map(r=>r instanceof tt?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const l in e)r.push(l);r.sort();const s=r.length;for(let l=0;l<s;l++){const a=r[l];n.push(a+'="'+e[a]+'"')}const i=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(e){this.doc!==null?Ce(this.doc,n=>{zl(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?Ce(this.doc,r=>{mh(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return gh(this,e)}hasAttribute(e){return gx(this,e)}getAttributes(e){return e?mO(this,e):mx(this)}toDOM(e=document,n={},r){const s=e.createElement(this.nodeName),i=this.getAttributes();for(const o in i){const l=i[o];typeof l=="string"&&s.setAttribute(o,l)}return Ai(this,o=>{s.appendChild(o.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef(VO),e.writeKey(this.nodeName)}}const MO=t=>new ht(t.readKey());class AO extends va{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}}class Fl extends ks{constructor(e){super(),this.hookName=e}_copy(){return new Fl(this.hookName)}clone(){const e=new Fl(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const s=n[this.hookName];let i;return s!==void 0?i=s.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(qO),e.writeKey(this.hookName)}}const TO=t=>new Fl(t.readKey());class Et extends dr{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new Et}clone(){const e=new Et;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const s=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(e=>{const n=[];for(const s in e.attributes){const i=[];for(const o in e.attributes[s])i.push({key:o,value:e.attributes[s][o]});i.sort((o,l)=>o.key<l.key?-1:1),n.push({nodeName:s,attrs:i})}n.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<n.length;s++){const i=n[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){const l=i.attrs[o];r+=` ${l.key}="${l.value}"`}r+=">"}r+=e.insert;for(let s=n.length-1;s>=0;s--)r+=`</${n[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(KO)}}const NO=t=>new Et;class yh{constructor(e,n){this.id=e,this.length=n}get deleted(){throw Gt()}mergeWith(e){return!1}write(e,n,r){throw Gt()}integrate(e,n){throw Gt()}}const _O=0;class Bt extends yh{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),ex(e.doc.store,this)}write(e,n){e.writeInfo(_O),e.writeLen(this.length-n)}getMissing(e,n){return null}}class Fi{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Fi(this.content)}splice(e){throw Gt()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const RO=t=>new Fi(t.readBuf());class Ti{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Ti(this.len)}splice(e){const n=new Ti(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){Si(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const OO=t=>new Ti(t.readLen()),kx=(t,e)=>new Ur({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Ui{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Ui(kx(this.doc.guid,this.opts))}splice(e){throw Gt()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const DO=t=>new Ui(kx(t.readString(),t.readAny()));class Vr{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Vr(this.embed)}splice(e){throw Gt()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const LO=t=>new Vr(t.readJSON());class Ge{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Ge(this.key,this.value)}splice(e){throw Gt()}mergeWith(e){return!1}integrate(e,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const IO=t=>new Ge(t.readKey(),t.readJSON());class Ul{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Ul(this.arr)}splice(e){const n=new Ul(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const i=this.arr[s];e.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}const jO=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const s=t.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new Ul(n)},PO=Pl("node_env")==="development";class Hr{constructor(e){this.arr=e,PO&&P0(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Hr(this.arr)}splice(e){const n=new Hr(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const i=this.arr[s];e.writeAny(i)}}getRef(){return 8}}const BO=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new Hr(n)};class Xt{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Xt(this.str)}splice(e){const n=new Xt(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const $O=t=>new Xt(t.readString()),HO=[yO,xO,CO,MO,EO,TO,NO],zO=0,FO=1,UO=2,VO=3,WO=4,qO=5,KO=6;class en{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new en(this.type._copy())}splice(e){throw Gt()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const GO=t=>new en(HO[t.readTypeRef()](t)),$d=(t,e)=>{let n=e,r=0,s;do r>0&&(n=ce(n.client,n.clock+r)),s=cs(t,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof ve);return{item:s,diff:r}},bh=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},Vl=(t,e,n)=>{const{client:r,clock:s}=e.id,i=new ve(ce(r,s+n),e,ce(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),e.redone!==null&&(i.redone=ce(e.redone.client,e.redone.clock+n)),e.right=i,i.right!==null&&(i.right.left=i),t._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),e.length=n,i},Am=(t,e)=>x_(t,n=>Ns(n.deletions,e)),vx=(t,e,n,r,s,i)=>{const o=t.doc,l=o.store,a=o.clientID,c=e.redone;if(c!==null)return vt(t,c);let d=e.parent._item,u=null,h;if(d!==null&&d.deleted===!0){if(d.redone===null&&(!n.has(d)||vx(t,d,n,r,s,i)===null))return null;for(;d.redone!==null;)d=vt(t,d.redone)}const f=d===null?e.parent:d.content.type;if(e.parentSub===null){for(u=e.left,h=e;u!==null;){let b=u;for(;b!==null&&b.parent._item!==d;)b=b.redone===null?null:vt(t,b.redone);if(b!==null&&b.parent._item===d){u=b;break}u=u.left}for(;h!==null;){let b=h;for(;b!==null&&b.parent._item!==d;)b=b.redone===null?null:vt(t,b.redone);if(b!==null&&b.parent._item===d){h=b;break}h=h.right}}else if(h=null,e.right&&!s){for(u=e;u!==null&&u.right!==null&&(u.right.redone||Ns(r,u.right.id)||Am(i.undoStack,u.right.id)||Am(i.redoStack,u.right.id));)for(u=u.right;u.redone;)u=vt(t,u.redone);if(u&&u.right!==null)return null}else u=f._map.get(e.parentSub)||null;const p=Ue(l,a),g=ce(a,p),y=new ve(g,u,u&&u.lastId,h,h&&h.id,f,e.parentSub,e.content.copy());return e.redone=g,bh(y,!0),y.integrate(t,0),y};class ve extends yh{constructor(e,n,r,s,i,o,l,a){super(e,a.getLength()),this.origin=r,this.left=n,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=l,this.redone=null,this.content=a,this.info=this.content.isCountable()?rm:0}set marker(e){(this.info&Nc)>0!==e&&(this.info^=Nc)}get marker(){return(this.info&Nc)>0}get keep(){return(this.info&nm)>0}set keep(e){this.keep!==e&&(this.info^=nm)}get countable(){return(this.info&rm)>0}get deleted(){return(this.info&Tc)>0}set deleted(e){this.deleted!==e&&(this.info^=Tc)}markDeleted(){this.info|=Tc}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Ue(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Ue(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===as&&this.id.client!==this.parent.client&&this.parent.clock>=Ue(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=ym(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=vt(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Bt||this.right&&this.right.constructor===Bt)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===ve?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===ve&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===as){const r=cs(n,this.parent);r.constructor===Bt?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=ym(e,e.doc.store,ce(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;const i=new Set,o=new Set;for(;s!==null&&s!==this.right;){if(o.add(s),i.add(s),Eo(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if(Eo(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(cs(e.doc.store,s.origin)))i.has(cs(e.doc.store,s.origin))||(r=s,i.clear());else break;s=s.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),ex(e.doc.store,this),this.content.integrate(e,this),xm(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Bt(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:ce(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Eo(e.origin,this.lastId)&&this.right===e&&Eo(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Si(e.deleteSet,this.id.client,this.id.clock,this.length),xm(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw Mt();this.content.gc(e),n?QR(e,this,new Bt(this.id,this.length)):this.content=new Ti(this.length)}write(e,n){const r=n>0?ce(this.id.client,this.id.clock+n-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&ya|(r===null?0:yt)|(s===null?0:Tn)|(i===null?0:wi);if(e.writeInfo(o),r!==null&&e.writeLeftID(r),s!==null&&e.writeRightID(s),r===null&&s===null){const l=this.parent;if(l._item!==void 0){const a=l._item;if(a===null){const c=Ci(l);e.writeParentInfo(!0),e.writeString(c)}else e.writeParentInfo(!1),e.writeLeftID(a.id)}else l.constructor===String?(e.writeParentInfo(!0),e.writeString(l)):l.constructor===as?(e.writeParentInfo(!1),e.writeLeftID(l)):Mt();i!==null&&e.writeString(i)}this.content.write(e,n)}}const Sx=(t,e)=>JO[e&ya](t),JO=[()=>{Mt()},OO,jO,RO,$O,LO,IO,GO,BO,DO,()=>{Mt()}],YO=10;class Vt extends yh{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){Mt()}write(e,n){e.writeInfo(YO),ge(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const Cx=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Ex="__ $YJS$ __";Cx[Ex]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Cx[Ex]=!0;const XO=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},ZO=/[\uD800-\uDBFF]/,QO=/[\uDC00-\uDFFF]/,eD=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&ZO.test(t[n-1])&&n--;r+n<t.length&&r+n<e.length&&t[t.length-r-1]===e[e.length-r-1];)r++;return r>0&&QO.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},tD=eD,an=(t,e)=>t>>>e|t<<32-e,nD=t=>an(t,2)^an(t,13)^an(t,22),rD=t=>an(t,6)^an(t,11)^an(t,25),sD=t=>an(t,7)^an(t,18)^t>>>3,iD=t=>an(t,17)^an(t,19)^t>>>10,oD=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),lD=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class aD{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(lD),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let u=16;u<64;u++)n[u]=iD(n[u-2])+n[u-7]+sD(n[u-15])+n[u-16];let r=e[0],s=e[1],i=e[2],o=e[3],l=e[4],a=e[5],c=e[6],d=e[7];for(let u=0,h,f;u<64;u++)h=d+rD(l)+(l&a^~l&c)+oD[u]+n[u]>>>0,f=nD(r)+(r&s^r&i^s&i)>>>0,d=c,c=a,a=l,l=o+h>>>0,o=i,i=s,s=r,r=h+f>>>0;e[0]+=r,e[1]+=s,e[2]+=i,e[3]+=o,e[4]+=l,e[5]+=a,e[6]+=c,e[7]+=d}digest(e){let n=0;for(;n+56<=e.length;){let o=0;for(;o<16&&n+3<e.length;o++)this._W[o]=e[n++]<<24|e[n++]<<16|e[n++]<<8|e[n++];if(n%64!==0){for(this._W.fill(0,o,16);n<e.length;)this._W[o]|=e[n]<<(3-n%4)*8,n++;this._W[o]|=yt<<(3-n%4)*8}this._updateHash()}const r=n%64!==0;this._W.fill(0,0,16);let s=0;for(;n<e.length;s++)for(let o=3;o>=0&&n<e.length;o--)this._W[s]|=e[n++]<<o*8;r||(this._W[s-(n%4===0?0:1)]|=yt<<(3-n%4)*8),this._W[14]=e.byteLength/w_,this._W[15]=e.byteLength*8,this._updateHash();const i=new Uint8Array(32);for(let o=0;o<this._H.length;o++)for(let l=0;l<4;l++)i[o*4+l]=this._H[o]>>>(3-l)*8;return i}}const cD=t=>new aD().digest(t),Ie=new ye("y-sync"),Nn=new ye("y-undo");new ye("yjs-cursor");const dD=t=>{for(let n=6;n<t.length;n++)t[n%6]=t[n%6]^t[n];return t.slice(0,6)},uD=t=>bR(dD(cD(xR(t)))),Wl=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!Ns(e.ds,t.id),hD=[{light:"#ecd44433",dark:"#ecd444"}],fD=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=Pr();t.forEach(s=>r.add(s)),e=e.filter(s=>!r.has(s))}t.set(n,Q_(e))}return t.get(n)},pD=(t,{colors:e=hD,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:s=()=>{},mapping:i}={})=>{let o=!1;const l=new gD(t,i),a=new me({props:{editable:c=>{const d=Ie.getState(c);return d.snapshot==null&&d.prevSnapshot==null}},key:Ie,state:{init:(c,d)=>({type:t,doc:t.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(c,d)=>{const u=c.getMeta(Ie);if(u!==void 0){d=Object.assign({},d);for(const h in u)d[h]=u[h]}return d.addToHistory=c.getMeta("addToHistory")!==!1,d.isChangeOrigin=u!==void 0&&!!u.isChangeOrigin,d.isUndoRedoOperation=u!==void 0&&!!u.isChangeOrigin&&!!u.isUndoRedoOperation,l.prosemirrorView!==null&&u!==void 0&&(u.snapshot!=null||u.prevSnapshot!=null)&&H0(0,()=>{l.prosemirrorView!=null&&(u.restore==null?l._renderSnapshot(u.snapshot,u.prevSnapshot,d):(l._renderSnapshot(u.snapshot,u.snapshot,d),delete d.restore,delete d.snapshot,delete d.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))}),d}},view:c=>(l.initView(c),i==null&&l._forceRerender(),s(),{update:()=>{const d=a.getState(c.state);if(d.snapshot==null&&d.prevSnapshot==null&&(o||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(o=!0,d.addToHistory===!1&&!d.isChangeOrigin){const u=Nn.getState(c.state),h=u&&u.undoManager;h&&h.stopCapturing()}l.mux(()=>{d.doc.transact(u=>{u.meta.set("addToHistory",d.addToHistory),l._prosemirrorChanged(c.state.doc)},Ie)})}},destroy:()=>{l.destroy()}})});return a},mD=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new St(t.doc));else if(e.type==="node"){const r=Vo(n.doc,n.type,e.anchor,n.mapping);t.setSelection(q.create(t.doc,r))}else{const r=Vo(n.doc,n.type,e.anchor,n.mapping),s=Vo(n.doc,n.type,e.head,n.mapping);r!==null&&s!==null&&t.setSelection(J.between(t.doc.resolve(r),t.doc.resolve(s)))}},Hd=(t,e)=>({type:e.selection.jsonID,anchor:Vd(e.selection.anchor,t.type,t.mapping),head:Vd(e.selection.head,t.type,t.mapping)});class gD{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=XO(),this.mapping=n,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=Hd(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(B0&&this._domSelectionInView===null&&(H0(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;const n=this.prosemirrorView._root.createRange();n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const s=n.getBoundingClientRect(),i=kR.documentElement;return s.bottom>=0&&s.right>=0&&s.left<=(window.innerWidth||i.clientWidth||0)&&s.top<=(window.innerHeight||i.clientHeight||0)}renderSnapshot(e,n){n||(n=Z0(G0(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Ie,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>Uo(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new P(O.from(e),0,0));n.setMeta(Ie,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(s=>Uo(s,this.prosemirrorView.state.schema,this)).filter(s=>s!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new P(O.from(n),0,0));if(e){const s=bs(lr(e.anchor,0),r.doc.content.size),i=bs(lr(e.head,0),r.doc.content.size);r.setSelection(J.create(r.doc,s,i))}this.prosemirrorView.dispatch(r.setMeta(Ie,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let s=this.doc,i=this.type;if(e||(e=Lc(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&Mt(),s=new Ur({gc:!1}),Id(s,n),n=Lc(s),Id(s,e),e=Lc(s),i._item===null){const o=Array.from(this.doc.share.keys()).find(l=>this.doc.share.get(l)===this.type);i=s.getXmlFragment(o)}else{const o=s.store.clients.get(i._item.id.client)??[],l=Yt(o,i._item.id.clock);i=o[l].content.type}this.mapping.clear(),this.mux(()=>{s.transact(o=>{const l=r.permanentUserData;l&&l.dss.forEach(u=>{cr(o,u,h=>{})});const a=(u,h)=>{const f=u==="added"?l.getUserByClientId(h.client):l.getUserByDeletedId(h);return{user:f,type:u,color:fD(r.colorMapping,r.colors,f)}},c=cx(i,new fh(n.ds,e.sv)).map(u=>!u._item.deleted||Wl(u._item,e)||Wl(u._item,n)?Uo(u,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,n,a):null).filter(u=>u!==null),d=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new P(O.from(c),0,0));this.prosemirrorView.dispatch(d.setMeta(Ie,{isChangeOrigin:!0}))},Ie)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=Ie.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const s=(l,a)=>this.mapping.delete(a);cr(n,n.deleteSet,l=>{if(l.constructor===ve){const a=l.content.type;a&&this.mapping.delete(a)}}),n.changed.forEach(s),n.changedParentTypes.forEach(s);const i=this.type.toArray().map(l=>Mx(l,this.prosemirrorView.state.schema,this)).filter(l=>l!==null);let o=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new P(O.from(i),0,0));mD(o,this.beforeTransactionSelection,this),o=o.setMeta(Ie,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof rx}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(e){this.doc.transact(()=>{Fd(this.doc,this.type,e,this),this.beforeTransactionSelection=Hd(this,this.prosemirrorView.state)},Ie)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const Mx=(t,e,n,r,s,i)=>{const o=n.mapping.get(t);if(o===void 0){if(t instanceof ht)return Uo(t,e,n,r,s,i);throw Gt()}return o},Uo=(t,e,n,r,s,i)=>{const o=[],l=a=>{if(a instanceof ht){const c=Mx(a,e,n,r,s,i);c!==null&&o.push(c)}else{const c=a._item.right?.content?.type;c instanceof dr&&!c._item.deleted&&c._item.id.client===c.doc.clientID&&(a.applyDelta([{retain:a.length},...c.toDelta()]),c.doc.transact(u=>{c._item.delete(u)}));const d=yD(a,e,n,r,s,i);d!==null&&d.forEach(u=>{u!==null&&o.push(u)})}};r===void 0||s===void 0?t.toArray().forEach(l):cx(t,new fh(s.ds,r.sv)).forEach(l);try{const a=t.getAttributes(r);r!==void 0&&(Wl(t._item,r)?Wl(t._item,s)||(a.ychange=i?i("added",t._item.id):{type:"added"}):a.ychange=i?i("removed",t._item.id):{type:"removed"});const c=e.node(t.nodeName,a,o);return n.mapping.set(t,c),c}catch{return t.doc.transact(c=>{t._item.delete(c)},Ie),n.mapping.delete(t),null}},yD=(t,e,n,r,s,i)=>{const o=[],l=t.toDelta(r,s,i);try{for(let a=0;a<l.length;a++){const c=l[a];o.push(e.text(c.insert,SD(c.attributes,e)))}}catch{return t.doc.transact(c=>{t._item.delete(c)},Ie),null}return o},bD=(t,e)=>{const n=new Et,r=t.map(s=>({insert:s.text,attributes:Tx(s.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},xD=(t,e)=>{const n=new ht(t.type.name);for(const r in t.attrs){const s=t.attrs[r];s!==null&&r!=="ychange"&&n.setAttribute(r,s)}return n.insert(0,Ea(t).map(r=>zd(r,e))),e.mapping.set(n,t),n},zd=(t,e)=>t instanceof Array?bD(t,e):xD(t,e),Tm=t=>typeof t=="object"&&t!==null,xh=(t,e)=>{const n=Object.keys(t).filter(s=>t[s]!==null);let r=n.length===Object.keys(e).filter(s=>e[s]!==null).length;for(let s=0;s<n.length&&r;s++){const i=n[s],o=t[i],l=e[i];r=i==="ychange"||o===l||Tm(o)&&Tm(l)&&xh(o,l)}return r},Ea=t=>{const e=t.content.content,n=[];for(let r=0;r<e.length;r++){const s=e[r];if(s.isText){const i=[];for(let o=e[r];r<e.length&&o.isText;o=e[++r])i.push(o);r--,n.push(i)}else n.push(s)}return n},Ax=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,s)=>r.insert===e[s].text&&I0(r.attributes||{}).length===e[s].marks.length&&j0(r.attributes,(i,o)=>{const l=wh(o),a=e[s].marks;return xh(i,a.find(c=>c.type.name===l)?.attrs)}))},Ni=(t,e)=>{if(t instanceof ht&&!(e instanceof Array)&&Ud(t,e)){const n=Ea(e);return t._length===n.length&&xh(t.getAttributes(),e.attrs)&&t.toArray().every((r,s)=>Ni(r,n[s]))}return t instanceof Et&&e instanceof Array&&Ax(t,e)},ql=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),Nm=(t,e,n)=>{const r=t.toArray(),s=Ea(e),i=s.length,o=r.length,l=bs(o,i);let a=0,c=0,d=!1;for(;a<l;a++){const u=r[a],h=s[a];if(ql(n.mapping.get(u),h))d=!0;else if(!Ni(u,h))break}for(;a+c<l;c++){const u=r[o-c-1],h=s[i-c-1];if(ql(n.mapping.get(u),h))d=!0;else if(!Ni(u,h))break}return{equalityFactor:a+c,foundMappedChild:d}},wD=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Xt?e+=n.content.str:n.content instanceof Ge&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},kD=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:s}=wD(t),i=e.map(c=>({insert:c.text,attributes:Object.assign({},r,Tx(c.marks,n))})),{insert:o,remove:l,index:a}=tD(s,i.map(c=>c.insert).join(""));t.delete(a,l),t.insert(a,o),t.applyDelta(i.map(c=>({retain:c.insert.length,attributes:c.attributes})))},vD=/(.*)(--[a-zA-Z0-9+/=]{8})$/,wh=t=>vD.exec(t)?.[1]??t,SD=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(wh(r),t[r]));return n},Tx=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const s=On(e.isOMark,r.type,()=>!r.type.excludes(r.type));n[s?`${r.type.name}--${uD(r.toJSON())}`:r.type.name]=r.attrs}}),n},Fd=(t,e,n,r)=>{if(e instanceof ht&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof ht){const u=e.getAttributes(),h=n.attrs;for(const f in h)h[f]!==null?u[f]!==h[f]&&f!=="ychange"&&e.setAttribute(f,h[f]):e.removeAttribute(f);for(const f in u)h[f]===void 0&&e.removeAttribute(f)}const s=Ea(n),i=s.length,o=e.toArray(),l=o.length,a=bs(i,l);let c=0,d=0;for(;c<a;c++){const u=o[c],h=s[c];if(!ql(r.mapping.get(u),h))if(Ni(u,h))r.mapping.set(u,h);else break}for(;d+c+1<a;d++){const u=o[l-d-1],h=s[i-d-1];if(!ql(r.mapping.get(u),h))if(Ni(u,h))r.mapping.set(u,h);else break}t.transact(()=>{for(;l-c-d>0&&i-c-d>0;){const h=o[c],f=s[c],p=o[l-d-1],g=s[i-d-1];if(h instanceof Et&&f instanceof Array)Ax(h,f)||kD(h,f,r),c+=1;else{let y=h instanceof ht&&Ud(h,f),b=p instanceof ht&&Ud(p,g);if(y&&b){const w=Nm(h,f,r),A=Nm(p,g,r);w.foundMappedChild&&!A.foundMappedChild?b=!1:!w.foundMappedChild&&A.foundMappedChild||w.equalityFactor<A.equalityFactor?y=!1:b=!1}y?(Fd(t,h,f,r),c+=1):b?(Fd(t,p,g,r),d+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[zd(f,r)]),c+=1)}}const u=l-c-d;if(l===1&&i===0&&o[0]instanceof Et?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):u>0&&(e.slice(c,c+u).forEach(h=>r.mapping.delete(h)),e.delete(c,u)),c+d<i){const h=[];for(let f=c;f<i-d;f++)h.push(zd(s[f],r));e.insert(c,h)}},Ie)},Ud=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name,Vd=(t,e,n)=>{if(t===0)return Dc(e,0,-1);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof Et){if(r._length>=t)return Dc(r,t,-1);if(t-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,t--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const s=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t<s)r=r._first.content.type,t--;else{if(t===1&&r._length===0&&s>1)return new $l(r._item===null?null:r._item.id,r._item===null?Ci(r):null,null);if(t-=s,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(t===0)return r=r._item===null?r:r._item.parent,new $l(r._item===null?null:r._item.id,r._item===null?Ci(r):null,null);do r=r._item.parent,t--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw Mt();if(t===0&&r.constructor!==Et&&r!==e)return CD(r._item.parent,r._item)}return Dc(e,e._length,-1)},CD=(t,e)=>{let n=null,r=null;return t._item===null?r=Ci(t):n=ce(t._item.id.client,t._item.id.clock),new $l(n,r,e.id)},Vo=(t,e,n,r)=>{const s=XR(n,t);if(s===null||s.type!==e&&!Ei(e,s.type._item))return null;let i=s.type,o=0;if(i.constructor===Et)o=s.index;else if(i._item===null||!i._item.deleted){let l=i._first,a=0;for(;a<i._length&&a<s.index&&l!==null;){if(!l.deleted){const c=l.content.type;a++,c instanceof Et?o+=c._length:o+=r.get(c).nodeSize}l=l.right}o+=1}for(;i!==e&&i._item!==null;){const l=i._item.parent;if(l._item===null||!l._item.deleted){o+=1;let a=l._first;for(;a!==null;){const c=a.content.type;if(c===i)break;a.deleted||(c instanceof Et?o+=c._length:o+=r.get(c).nodeSize),a=a.right}}i=l}return o-1};function ED(t){const e=t.toArray(),n=r=>{let s;if(r instanceof Et)s=r.toDelta().map(o=>{const l={type:"text",text:o.insert};return o.attributes&&(l.marks=Object.keys(o.attributes).map(a=>{const c=o.attributes[a],u={type:wh(a)};return Object.keys(c)&&(u.attrs=c),u})),l});else if(r instanceof ht){s={type:r.nodeName};const i=r.getAttributes();Object.keys(i).length&&(s.attrs=i);const o=r.toArray();o.length&&(s.content=o.map(n).flat())}else Mt();return s};return{type:"doc",content:e.map(n)}}const MD=t=>{const e=Nn.getState(t).undoManager;if(e!=null)return e.undo(),!0},AD=t=>{const e=Nn.getState(t).undoManager;if(e!=null)return e.redo(),!0},TD=new Set(["paragraph"]),ND=(t,e)=>!(t instanceof ve)||!(t.content instanceof en)||!(t.content.type instanceof dr||t.content.type instanceof ht&&e.has(t.content.type.nodeName))||t.content.type._length===0,_D=({protectedNodes:t=TD,trackedOrigins:e=[],undoManager:n=null}={})=>new me({key:Nn,state:{init:(r,s)=>{const i=Ie.getState(s),o=n||new rx(i.type,{trackedOrigins:new Set([Ie].concat(e)),deleteFilter:l=>ND(l,t),captureTransaction:l=>l.meta.get("addToHistory")!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(r,s,i,o)=>{const l=Ie.getState(o).binding,a=s.undoManager,c=a.undoStack.length>0,d=a.redoStack.length>0;return l?{undoManager:a,prevSel:Hd(l,i),hasUndoOps:c,hasRedoOps:d}:c!==s.hasUndoOps||d!==s.hasRedoOps?Object.assign({},s,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):s}},view:r=>{const s=Ie.getState(r.state),i=Nn.getState(r.state).undoManager;return i.on("stack-item-added",({stackItem:o})=>{const l=s.binding;l&&o.meta.set(l,Nn.getState(r.state).prevSel)}),i.on("stack-item-popped",({stackItem:o})=>{const l=s.binding;l&&(l.beforeTransactionSelection=o.meta.get(l)||l.beforeTransactionSelection)}),{destroy:()=>{i.destroy()}}}});de.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(t=>t.name==="undoRedo")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".')},addCommands(){return{undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Nn.getState(e).undoManager.undoStack.length===0?!1:n?MD(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Nn.getState(e).undoManager.redoStack.length===0?!1:n?AD(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){var t;const e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),n=_D(this.options.yUndoOptions),r=n.spec.view;n.spec.view=o=>{const{undoManager:l}=Nn.getState(o.state);l.restore&&(l.restore(),l.restore=()=>{});const a=r?r(o):void 0;return{destroy:()=>{const c=l.trackedOrigins.has(l),d=l._observers;l.restore=()=>{c&&l.trackedOrigins.add(l),l.doc.on("afterTransaction",l.afterTransactionHandler),l._observers=d},a?.destroy&&a.destroy()}}};const s={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender},i=pD(e,s);return this.editor.options.enableContentCheck&&((t=e.doc)==null||t.on("beforeTransaction",()=>{try{const o=ED(e);if(o.content.length===0)return;this.editor.schema.nodeFromJSON(o).check()}catch(o){return this.editor.emit("contentError",{error:o,editor:this.editor,disableCollaboration:()=>{var l;(l=e.doc)==null||l.destroy(),this.storage.isDisabled=!0}}),!1}})),[i,n,this.editor.options.enableContentCheck&&new me({key:new ye("filterInvalidContent"),filterTransaction:()=>{var o;return this.storage.isDisabled!==!1&&((o=e.doc)==null||o.destroy()),!0}})].filter(Boolean)}});function RD(t){return!!t.getMeta(Ie)}function _m(t){if(!t.length)return be.empty;const e=[],n=t[0].$from.node(0);return t.forEach(r=>{const s=r.$from.pos,i=r.$from.nodeAfter;i&&e.push(_e.node(s,s+i.nodeSize,{class:"ProseMirror-selectednoderange"}))}),be.create(n,e)}function Ma(t,e,n){const r=[],s=t.node(0);typeof n=="number"&&n>=0||(t.sameParent(e)?n=Math.max(0,t.sharedDepth(e.pos)-1):n=t.sharedDepth(e.pos));const i=new oi(t,e,n),o=i.depth===0?0:s.resolve(i.start).posAtIndex(0);return i.parent.forEach((l,a)=>{const c=o+a,d=c+l.nodeSize;if(c<i.start||c>=i.end)return;const u=new lu(s.resolve(c),s.resolve(d));r.push(u)}),r}var OD=class Nx{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Nx(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return new Xn(n,r)}},Xn=class Hn extends ee{constructor(e,n,r,s=1){const{doc:i}=e,o=e===n,l=e.pos===i.content.size&&n.pos===i.content.size,a=o&&!l?i.resolve(n.pos+(s>0?1:-1)):n,c=o&&l?i.resolve(e.pos-(s>0?1:-1)):e,d=Ma(c.min(a),c.max(a),r),u=a.pos>=e.pos?d[0].$from:d[d.length-1].$to,h=a.pos>=e.pos?d[d.length-1].$to:d[0].$from;super(u,h,d),this.depth=r}get $to(){return this.ranges[this.ranges.length-1].$to}eq(e){return e instanceof Hn&&e.$from.pos===this.$from.pos&&e.$to.pos===this.$to.pos}map(e,n){const r=e.resolve(n.map(this.anchor)),s=e.resolve(n.map(this.head));return new Hn(r,s)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:e}=this.$from;if(this.isForwards&&this.ranges.length>1){const s=this.ranges.slice(0,-1),i=s[0].$from,o=s[s.length-1].$to;return new Hn(i,o,this.depth)}const n=this.ranges[0],r=e.resolve(Math.max(0,n.$from.pos-1));return new Hn(this.$anchor,r,this.depth)}extendForwards(){const{doc:e}=this.$from;if(this.isBackwards&&this.ranges.length>1){const s=this.ranges.slice(1),i=s[0].$from,o=s[s.length-1].$to;return new Hn(o,i,this.depth)}const n=this.ranges[this.ranges.length-1],r=e.resolve(Math.min(e.content.size,n.$to.pos+1));return new Hn(this.$anchor,r,this.depth)}static fromJSON(e,n){return new Hn(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r,s,i=1){return new this(e.resolve(n),e.resolve(r),s,i)}getBookmark(){return new OD(this.anchor,this.head)}};Xn.prototype.visible=!1;function No(t){return t instanceof Xn}var DD=de.create({name:"nodeRange",addOptions(){return{depth:void 0,key:"Mod"}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,selection:i,tr:o}=r,{anchor:l,head:a}=i;if(!No(i)){const d=Xn.create(s,l,a,e,-1);return o.setSelection(d),n.dispatch(o),!0}const c=i.extendBackwards();return o.setSelection(c),n.dispatch(o),!0},"Shift-ArrowDown":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,selection:i,tr:o}=r,{anchor:l,head:a}=i;if(!No(i)){const d=Xn.create(s,l,a,e);return o.setSelection(d),n.dispatch(o),!0}const c=i.extendForwards();return o.setSelection(c),n.dispatch(o),!0},"Mod-a":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,tr:i}=r,o=Xn.create(s,0,s.content.size,e);return i.setSelection(o),n.dispatch(i),!0}}},onSelectionUpdate(){const{selection:t}=this.editor.state;No(t)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let t=!1,e=!1;return[new me({key:new ye("nodeRange"),props:{attributes:()=>t?{class:"ProseMirror-noderangeselection"}:{class:""},handleDOMEvents:{mousedown:(n,r)=>{const{key:s}=this.options,i=/Mac/.test(navigator.platform),o=!!r.shiftKey,l=!!r.ctrlKey,a=!!r.altKey,c=!!r.metaKey,d=i?c:l;return(s==null||s==="Shift"&&o||s==="Control"&&l||s==="Alt"&&a||s==="Meta"&&c||s==="Mod"&&d)&&(e=!0),e&&document.addEventListener("mouseup",()=>{e=!1;const{state:u}=n,{doc:h,selection:f,tr:p}=u,{$anchor:g,$head:y}=f;if(g.sameParent(y))return;const b=Xn.create(h,g.pos,y.pos,this.options.depth);p.setSelection(b),n.dispatch(p)},{once:!0}),!1}},decorations:n=>{const{selection:r}=n,s=No(r);if(t=!1,!e)return s?(t=!0,_m(r.ranges)):null;const{$from:i,$to:o}=r;if(!s&&i.sameParent(o))return null;const l=Ma(i,o,this.options.depth);return l.length?(t=!0,_m(l)):null}}})]}}),LD=DD;function ID(t){let e="";const n=getComputedStyle(t);for(let r=0;r<n.length;r+=1)e+=`${n[r]}:${n.getPropertyValue(n[r])};`;return e}function jD(t){const e=t.cloneNode(!0),n=[t,...Array.from(t.getElementsByTagName("*"))],r=[e,...Array.from(e.getElementsByTagName("*"))];return n.forEach((s,i)=>{r[i].style.cssText=ID(s)}),e}function PD(t,e){let n=t;for(;n?.parentElement&&n.parentElement!==e.dom;)n=n.parentElement;return n?.parentElement===e.dom?n:void 0}function BD(t,e,n,r=5){const s=t.dom,i=s.firstElementChild,o=s.lastElementChild;if(!i||!o)return{x:e,y:n};const l=i.getBoundingClientRect(),a=o.getBoundingClientRect(),c=Math.min(Math.max(l.top+r,n),a.bottom-r),d=.5,u=Math.abs(l.left-a.left)<d,h=Math.abs(l.right-a.right)<d;let f=l;return u&&h&&(f=l),{x:Math.min(Math.max(f.left+r,e),f.right-r),y:c}}var _x=t=>{const{x:e,y:n,editor:r}=t,{view:s,state:i}=r,{x:o,y:l}=BD(s,e,n,5),a=s.root.elementsFromPoint(o,l);let c;if(Array.prototype.some.call(a,h=>{if(!s.dom.contains(h))return!1;const f=PD(h,s);return f?(c=f,!0):!1}),!c)return{resultElement:null,resultNode:null,pos:null};let d;try{d=s.posAtDOM(c,0)}catch{return{resultElement:null,resultNode:null,pos:null}}const u=i.doc.nodeAt(d);return{resultElement:c,resultNode:u,pos:d}};function _o(t,e){return window.getComputedStyle(t)[e]}function $D(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function HD(t,e,n){const r=parseInt(_o(t.dom,"paddingLeft"),10),s=parseInt(_o(t.dom,"paddingRight"),10),i=parseInt(_o(t.dom,"borderLeftWidth"),10),o=parseInt(_o(t.dom,"borderLeftWidth"),10),l=t.dom.getBoundingClientRect();return{left:$D(e,l.left+r+i,l.right-s-o),top:n}}function Rx(t){var e;(e=t.parentNode)==null||e.removeChild(t)}function zD(t,e){const{doc:n}=e.view.state,r=_x({editor:e,x:t.clientX,y:t.clientY});if(!r.resultNode||r.pos===null)return[];const s=t.clientX,i=HD(e.view,s,t.clientY),o=e.view.posAtCoords(i);if(!o)return[];const{pos:l}=o;if(!n.resolve(l).parent)return[];const c=n.resolve(r.pos),d=n.resolve(r.pos+1);return Ma(c,d,0)}function FD(t,e){const{view:n}=e;if(!t.dataTransfer)return;const{empty:r,$from:s,$to:i}=n.state.selection,o=zD(t,e),l=Ma(s,i,0),a=l.some(y=>o.find(b=>b.$from===y.$from&&b.$to===y.$to)),c=r||!a?o:l;if(!c.length)return;const{tr:d}=n.state,u=document.createElement("div"),h=c[0].$from.pos,f=c[c.length-1].$to.pos,p=Xn.create(n.state.doc,h,f),g=p.content();c.forEach(y=>{const b=n.nodeDOM(y.$from.pos),w=jD(b);u.append(w)}),u.style.position="absolute",u.style.top="-10000px",document.body.append(u),t.dataTransfer.clearData(),t.dataTransfer.setDragImage(u,0,0),n.dragging={slice:g,move:!0},d.setSelection(p),n.dispatch(d),document.addEventListener("drop",()=>Rx(u),{once:!0})}var Rm=(t,e)=>{const n=t.resolve(e),{depth:r}=n;return r===0?e:n.pos-n.parentOffset-1},Om=(t,e)=>{const n=t.nodeAt(e),r=t.resolve(e);let{depth:s}=r,i=n;for(;s>0;){const o=r.node(s);s-=1,s===0&&(i=o)}return i},Pc=(t,e)=>{const n=Ie.getState(t);return n?Vd(e,n.type,n.binding.mapping):null},UD=(t,e)=>{const n=Ie.getState(t);return n?Vo(n.doc,n.type,e,n.binding.mapping)||0:-1},Dm=(t,e)=>{let n=e;for(;n?.parentNode&&n.parentNode!==t.dom;)n=n.parentNode;return n},Ox=new ye("dragHandle"),Dx=({pluginKey:t=Ox,element:e,editor:n,computePositionConfig:r,getReferencedVirtualElement:s,onNodeChange:i,onElementDragStart:o,onElementDragEnd:l})=>{const a=document.createElement("div");let c=!1,d=null,u=-1,h,f=null,p=null;function g(){e&&(e.style.visibility="hidden",e.style.pointerEvents="none")}function y(){if(e){if(!n.isEditable){g();return}e.style.visibility="",e.style.pointerEvents="auto"}}function b(S){const M=s?.()||{getBoundingClientRect:()=>S.getBoundingClientRect()};Fu(M,e,r).then(x=>{Object.assign(e.style,{position:x.strategy,left:`${x.x}px`,top:`${x.y}px`})})}function w(S){o?.(S),FD(S,n),setTimeout(()=>{e&&(e.style.pointerEvents="none")},0)}function A(S){l?.(S),g(),e&&(e.style.pointerEvents="auto")}return e.addEventListener("dragstart",w),e.addEventListener("dragend",A),a.appendChild(e),{unbind(){e.removeEventListener("dragstart",w),e.removeEventListener("dragend",A),f&&(cancelAnimationFrame(f),f=null,p=null)},plugin:new me({key:typeof t=="string"?new ye(t):t,state:{init(){return{locked:!1}},apply(S,M,x,k){const v=S.getMeta("lockDragHandle"),T=S.getMeta("hideDragHandle");if(v!==void 0&&(c=v),T)return g(),c=!1,d=null,u=-1,i?.({editor:n,node:null,pos:-1}),M;if(S.docChanged&&u!==-1&&e)if(RD(S)){const N=UD(k,h);N!==u&&(u=N)}else{const N=S.mapping.map(u);N!==u&&(u=N,h=Pc(k,u))}return M}},view:S=>{var M;return e.draggable=!0,e.style.pointerEvents="auto",(M=n.view.dom.parentElement)==null||M.appendChild(a),a.style.pointerEvents="none",a.style.position="absolute",a.style.top="0",a.style.left="0",{update(x,k){if(!e)return;if(!n.isEditable){g();return}if(c?e.draggable=!1:e.draggable=!0,S.state.doc.eq(k.doc)||u===-1)return;let v=S.nodeDOM(u);if(v=Dm(S,v),v===S.dom||v?.nodeType!==1)return;const T=S.posAtDOM(v,0),N=Om(n.state.doc,T),H=Rm(n.state.doc,T);d=N,u=H,h=Pc(S.state,u),i?.({editor:n,node:d,pos:u}),b(v)},destroy(){f&&(cancelAnimationFrame(f),f=null,p=null),e&&Rx(a)}}},props:{handleDOMEvents:{keydown(S){return!e||c||S.hasFocus()&&(g(),d=null,u=-1,i?.({editor:n,node:null,pos:-1})),!1},mouseleave(S,M){return c||M.target&&!a.contains(M.relatedTarget)&&(g(),d=null,u=-1,i?.({editor:n,node:null,pos:-1})),!1},mousemove(S,M){return!e||c||(p={x:M.clientX,y:M.clientY},f)||(f=requestAnimationFrame(()=>{if(f=null,!p)return;const{x,y:k}=p;p=null;const v=_x({x,y:k,editor:n});if(!v.resultElement)return;let T=v.resultElement;if(T=Dm(S,T),T===S.dom||T?.nodeType!==1)return;const N=S.posAtDOM(T,0),H=Om(n.state.doc,N);if(H!==d){const V=Rm(n.state.doc,N);d=H,u=V,h=Pc(S.state,u),i?.({editor:n,node:d,pos:u}),b(T),y()}})),!1}}}})}},Wd={placement:"left-start",strategy:"absolute"},VD=de.create({name:"dragHandle",addOptions(){return{render(){const t=document.createElement("div");return t.classList.add("drag-handle"),t},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0}},addCommands(){return{lockDragHandle:()=>({editor:t})=>(this.options.locked=!0,t.commands.setMeta("lockDragHandle",this.options.locked)),unlockDragHandle:()=>({editor:t})=>(this.options.locked=!1,t.commands.setMeta("lockDragHandle",this.options.locked)),toggleDragHandle:()=>({editor:t})=>(this.options.locked=!this.options.locked,t.commands.setMeta("lockDragHandle",this.options.locked))}},addProseMirrorPlugins(){const t=this.options.render();return[Dx({computePositionConfig:{...Wd,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:t,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd}).plugin]}}),WD=VD;function qD(t){const e=t.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:e.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const s={className:"subst",begin:/\$\(/,end:/\)/,contains:[t.BACKSLASH_ESCAPE]},i=t.inherit(t.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},l={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,n,s]};s.contains.push(l);const a={match:/\\"/},c={className:"string",begin:/'/,end:/'/},d={match:/\\'/},u={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},t.NUMBER_MODE,n]},h=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],f=t.SHEBANG({binary:`(${h.join("|")})`,relevance:10}),p={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[t.inherit(t.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},g=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],y=["true","false"],b={match:/(\/[a-z._-]+)+/},w=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],A=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],S=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],M=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:g,literal:y,built_in:[...w,...A,"set","shopt",...S,...M]},contains:[f,t.SHEBANG(),p,u,i,o,b,l,a,c,d,n]}}const KD=t=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:t.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:t.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),GD=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],JD=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],YD=[...GD,...JD],XD=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),ZD=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),QD=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),eL=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function tL(t){const e=t.regex,n=KD(t),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},s="and or not only",i=/@-?\w[\w]*(-\w+)*/,o="[a-zA-Z-][a-zA-Z0-9_-]*",l=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+o,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+ZD.join("|")+")"},{begin:":(:)?("+QD.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+eL.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...l,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...l,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:e.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:XD.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...l,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+YD.join("|")+")\\b"}]}}const Lm="[A-Za-z$_][0-9A-Za-z$_]*",nL=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],rL=["true","false","null","undefined","NaN","Infinity"],Lx=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Ix=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],jx=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],sL=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],iL=[].concat(jx,Lx,Ix);function oL(t){const e=t.regex,n=(F,{after:ue})=>{const xe="</"+F[0].slice(1);return F.input.indexOf(xe,ue)!==-1},r=Lm,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(F,ue)=>{const xe=F[0].length+F.index,_=F.input[xe];if(_==="<"||_===","){ue.ignoreMatch();return}_===">"&&(n(F,{after:xe})||ue.ignoreMatch());let Z;const fe=F.input.substring(xe);if(Z=fe.match(/^\s*=/)){ue.ignoreMatch();return}if((Z=fe.match(/^\s+extends\s+/))&&Z.index===0){ue.ignoreMatch();return}}},l={$pattern:Lm,keyword:nL,literal:rL,built_in:iL,"variable.language":sL},a="[0-9](_?[0-9])*",c=`\\.(${a})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",u={className:"number",variants:[{begin:`(\\b(${d})((${c})|\\.)?|(${c}))[eE][+-]?(${a})\\b`},{begin:`\\b(${d})\\b((${c})\\b|\\.)?|(${c})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},f={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},p={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"css"}},g={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,h]},w={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},A=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,g,y,{match:/\$\d+/},u];h.contains=A.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(A)});const S=[].concat(w,h.contains),M=S.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(S)}]),x={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:M},k={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},v={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Lx,...Ix]}},T={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},N={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[x],illegal:/%/},H={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function V(F){return e.concat("(?!",F.join("|"),")")}const $={match:e.concat(/\b/,V([...jx,"super","import"].map(F=>`${F}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},I={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},j={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},x]},Q="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",ie={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(Q)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[x]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:M,CLASS_REFERENCE:v},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),T,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,g,y,w,{match:/\$\d+/},u,v,{scope:"attr",match:r+e.lookahead(":"),relevance:0},ie,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[w,t.REGEXP_MODE,{className:"function",begin:Q,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:M}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},N,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[x,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},I,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[x]},$,H,k,j,{match:/\$[(.]/}]}}function lL(t){const e={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],s={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[e,n,t.QUOTE_STRING_MODE,s,t.C_NUMBER_MODE,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function aL(t){const e=t.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],l={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},a={className:"meta",begin:/^(>>>|\.\.\.) /},c={className:"subst",begin:/\{/,end:/\}/,keywords:l,illegal:/#/},d={begin:/\{\{/,relevance:0},u={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,a,d,c]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,a,d,c]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[t.BACKSLASH_ESCAPE,d,c]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,d,c]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},h="[0-9](_?[0-9])*",f=`(\\b(${h}))?\\.(${h})|\\b(${h})\\.`,p=`\\b|${r.join("|")}`,g={className:"number",relevance:0,variants:[{begin:`(\\b(${h})|(${f}))[eE][+-]?(${h})[jJ]?(?=${p})`},{begin:`(${f})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${p})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${p})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${p})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${p})`},{begin:`\\b(${h})[jJ](?=${p})`}]},y={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:l,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},b={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:["self",a,g,u,t.HASH_COMMENT_MODE]}]};return c.contains=[u,g,a],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:l,illegal:/(<\/|\?)|=>/,contains:[a,g,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},u,y,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[b]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[g,b,u]}]}}function cL(t){const e=t.regex,n=t.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},s={begin:/"/,end:/"/,contains:[{match:/""/}]},i=["true","false","unknown"],o=["double precision","large object","with timezone","without timezone"],l=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],a=["add","asc","collation","desc","final","first","last","view"],c=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],d=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],u=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],h=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],f=d,p=[...c,...a].filter(M=>!d.includes(M)),g={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},y={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},b={match:e.concat(/\b/,e.either(...f),/\s*\(/),relevance:0,keywords:{built_in:f}};function w(M){return e.concat(/\b/,e.either(...M.map(x=>x.replace(/\s+/,"\\s+"))),/\b/)}const A={scope:"keyword",match:w(h),relevance:0};function S(M,{exceptions:x,when:k}={}){const v=k;return x=x||[],M.map(T=>T.match(/\|\d+$/)||x.includes(T)?T:v(T)?`${T}|0`:T)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:S(p,{when:M=>M.length<3}),literal:i,type:l,built_in:u},contains:[{scope:"type",match:w(o)},A,b,g,r,s,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,y]}}const Kl="[A-Za-z$_][0-9A-Za-z$_]*",Px=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],Bx=["true","false","null","undefined","NaN","Infinity"],$x=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Hx=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],zx=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Fx=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Ux=[].concat(zx,$x,Hx);function dL(t){const e=t.regex,n=(F,{after:ue})=>{const xe="</"+F[0].slice(1);return F.input.indexOf(xe,ue)!==-1},r=Kl,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(F,ue)=>{const xe=F[0].length+F.index,_=F.input[xe];if(_==="<"||_===","){ue.ignoreMatch();return}_===">"&&(n(F,{after:xe})||ue.ignoreMatch());let Z;const fe=F.input.substring(xe);if(Z=fe.match(/^\s*=/)){ue.ignoreMatch();return}if((Z=fe.match(/^\s+extends\s+/))&&Z.index===0){ue.ignoreMatch();return}}},l={$pattern:Kl,keyword:Px,literal:Bx,built_in:Ux,"variable.language":Fx},a="[0-9](_?[0-9])*",c=`\\.(${a})`,d="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",u={className:"number",variants:[{begin:`(\\b(${d})((${c})|\\.)?|(${c}))[eE][+-]?(${a})\\b`},{begin:`\\b(${d})\\b((${c})\\b|\\.)?|(${c})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},f={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},p={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"css"}},g={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,h]},w={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},A=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,g,y,{match:/\$\d+/},u];h.contains=A.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(A)});const S=[].concat(w,h.contains),M=S.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(S)}]),x={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:M},k={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},v={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...$x,...Hx]}},T={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},N={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[x],illegal:/%/},H={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function V(F){return e.concat("(?!",F.join("|"),")")}const $={match:e.concat(/\b/,V([...zx,"super","import"].map(F=>`${F}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},I={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},j={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},x]},Q="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",ie={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(Q)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[x]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:M,CLASS_REFERENCE:v},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),T,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,g,y,w,{match:/\$\d+/},u,v,{scope:"attr",match:r+e.lookahead(":"),relevance:0},ie,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[w,t.REGEXP_MODE,{className:"function",begin:Q,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:M}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},N,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[x,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},I,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[x]},$,H,k,j,{match:/\$[(.]/}]}}function uL(t){const e=t.regex,n=dL(t),r=Kl,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},o={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},l={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},a=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],c={$pattern:Kl,keyword:Px.concat(a),literal:Bx,built_in:Ux.concat(s),"variable.language":Fx},d={className:"meta",begin:"@"+r},u=(g,y,b)=>{const w=g.contains.findIndex(A=>A.label===y);if(w===-1)throw new Error("can not find mode to replace");g.contains.splice(w,1,b)};Object.assign(n.keywords,c),n.exports.PARAMS_CONTAINS.push(d);const h=n.contains.find(g=>g.scope==="attr"),f=Object.assign({},h,{match:e.concat(r,e.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,h,f]),n.contains=n.contains.concat([d,i,o,f]),u(n,"shebang",t.SHEBANG()),u(n,"use_strict",l);const p=n.contains.find(g=>g.label==="func.def");return p.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function hL(t){const e=t.regex,n=e.concat(/[\p{L}_]/u,e.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,s={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=t.inherit(i,{begin:/\(/,end:/\)/}),l=t.inherit(t.APOS_STRING_MODE,{className:"string"}),a=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),c={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[s]},{begin:/'/,end:/'/,contains:[s]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[i,a,l,o,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,o,a,l]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[a]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[c],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[c],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:e.concat(/</,e.lookahead(e.concat(n,e.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:c}]},{className:"tag",begin:e.concat(/<\//,e.lookahead(e.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}const Im={},fL="hljs-";function pL(t){const e=a0.newInstance();return t&&i(t),{highlight:n,highlightAuto:r,listLanguages:s,register:i,registerAlias:o,registered:l};function n(a,c,d){const u=d||Im,h=typeof u.prefix=="string"?u.prefix:fL;if(!e.getLanguage(a))throw new Error("Unknown language: `"+a+"` is not registered");e.configure({__emitter:mL,classPrefix:h});const f=e.highlight(c,{ignoreIllegals:!0,language:a});if(f.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:f.errorRaised});const p=f._emitter.root,g=p.data;return g.language=f.language,g.relevance=f.relevance,p}function r(a,c){const u=(c||Im).subset||s();let h=-1,f=0,p;for(;++h<u.length;){const g=u[h];if(!e.getLanguage(g))continue;const y=n(g,a,c);y.data&&y.data.relevance!==void 0&&y.data.relevance>f&&(f=y.data.relevance,p=y)}return p||{type:"root",children:[],data:{language:void 0,relevance:f}}}function s(){return e.listLanguages()}function i(a,c){if(typeof a=="string")e.registerLanguage(a,c);else{let d;for(d in a)Object.hasOwn(a,d)&&e.registerLanguage(d,a[d])}}function o(a,c){if(typeof a=="string")e.registerAliases(typeof c=="string"?c:[...c],{languageName:a});else{let d;for(d in a)if(Object.hasOwn(a,d)){const u=a[d];e.registerAliases(typeof u=="string"?u:[...u],{languageName:d})}}}function l(a){return!!e.getLanguage(a)}}class mL{constructor(e){this.options=e,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(e){if(e==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=e:n.children.push({type:"text",value:e})}startScope(e){this.openNode(String(e))}endScope(){this.closeNode()}__addSublanguage(e,n){const r=this.stack[this.stack.length-1],s=e.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:s}):r.children.push(...s)}openNode(e){const n=this,r=e.split(".").map(function(o,l){return l?o+"_".repeat(l):n.options.classPrefix+o}),s=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:r},children:[]};s.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const Vx=de.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:[]}},addProseMirrorPlugins(){const t=new ye("trailingNode");return[new me({key:t,appendTransaction:(e,n,r)=>{if(!e.some(h=>h.docChanged))return null;const{doc:i,schema:o}=r,l=i.lastChild,a=this.options.node,c=o.nodes[a];if(!c||l?.type.name===a||l&&this.options.notAfter.includes(l.type.name))return null;const d=i.content.size;return r.tr.insert(d,c.create())}})]}});var gL=tT;const yL=t=>{const{editor:e,pos:n}=t,r=e.state.doc.resolve(Math.max(n,0));return r.depth>0?r.node(r.depth-1):null},bL=t=>{const e='Press "/" to insert or start typing...',{node:n}=t,r=n.type.name,s=yL(t);if(r==="heading"){const i=n.attrs.level??1;switch(i){case 1:return"Add a title...";case 2:return"Add a section heading...";case 3:return"Add a subheading...";default:return`Heading ${i}`}}if(r==="taskItem")return"Add a task...";if(r==="listItem"){const i=s?.type.name;return i==="bulletList"?"Add a bullet...":i==="orderedList"?"Add a numbered item...":"Add a list item..."}if(r==="codeBlock"){const i=n.attrs.language;return i?`Write ${i} code...`:"Write some code..."}if(r==="paragraph"){const i=s?.type.name;if(!i||i==="doc")return e}return r==="doc"?e:""},Wx=gL.extend({addOptions(){return{...this.parent?.(),emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",includeChildren:!0,showOnlyCurrent:!0,showOnlyWhenEditable:!0,placeholder:e=>bL(e)}},addProseMirrorPlugins(){const t=new Set(["table","tableCell","tableHeader","tableRow"]),e=n=>{const r=this.editor.state.doc.resolve(n);for(let s=r.depth;s>=0;s-=1){const i=r.node(s);if(t.has(i.type.name))return!0}return!1};return[new me({key:new ye("placeholder"),props:{decorations:({doc:n,selection:r})=>{if(!(this.editor.isEditable||!this.options.showOnlyWhenEditable))return null;const{anchor:i}=r,o=[],l=this.editor.isEmpty;return n.descendants((a,c)=>{if(e(c))return this.options.includeChildren;const d=i>=c&&i<=c+a.nodeSize,u=!a.isLeaf&&Li(a);if((d||!this.options.showOnlyCurrent)&&u){const h=[this.options.emptyNodeClass];l&&h.push(this.options.emptyEditorClass);const f=typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:c,hasAnchor:d}):this.options.placeholder,p=_e.node(c,c+a.nodeSize,{class:h.join(" "),"data-placeholder":f});o.push(p)}return this.options.includeChildren}),o.length?be.create(n,o):null}}})]}}),xL=({node:t,updateAttributes:e,editor:n})=>{const[r,s]=C.useState(!1),{type:i,title:o,message:l,align:a,size:c,textAlign:d}=t.attrs,u={info:"bg-blue-50 text-blue-900 border-2 border-blue-200 dark:bg-blue-900/20 dark:text-blue-100 dark:border-blue-800",warning:"bg-yellow-50 text-yellow-900 border-2 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-100 dark:border-yellow-800",error:"bg-red-50 text-red-900 border-2 border-red-200 dark:bg-red-900/20 dark:text-red-100 dark:border-red-800",success:"bg-green-50 text-green-900 border-2 border-green-200 dark:bg-green-900/20 dark:text-green-100 dark:border-green-800"},h={small:"text-sm p-2",medium:"text-base p-3",large:"text-lg p-4"},f={left:"text-left",center:"text-center",right:"text-right"},p={left:"text-left",center:"text-center",right:"text-right"};return m.jsxs(Iu,{children:[m.jsx("div",{className:`${f[a]||"text-left"} cursor-grab`,onClick:()=>s(!0),"data-drag-handle":!0,children:m.jsxs("div",{className:`inline-block rounded-lg border p-2 m-1 ${u[i]||u.info} ${h[c]||h["fit-content"]} ${p[d]||p.left}`,children:[m.jsx("strong",{className:"font-bold block",children:o}),m.jsx("span",{children:l})]})}),r&&m.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center",onClick:()=>s(!1),children:m.jsxs("div",{className:"bg-white p-6 rounded-lg shadow-xl w-full max-w-md",onClick:g=>g.stopPropagation(),children:[m.jsx("h3",{className:"text-xl font-semibold mb-4 text-gray-800",children:"Edit Alert"}),m.jsxs("div",{className:"space-y-4",children:[m.jsxs("div",{children:[m.jsx("label",{htmlFor:"title",className:"block text-sm font-medium text-gray-700 mb-1",children:"Title"}),m.jsx("input",{type:"text",id:"title",defaultValue:o,onBlur:g=>e({title:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"message",className:"block text-sm font-medium text-gray-700 mb-1",children:"Message"}),m.jsx("textarea",{id:"message",defaultValue:l,onBlur:g=>e({message:g.target.value}),rows:3,className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"type",className:"block text-sm font-medium text-gray-700 mb-1",children:"Type"}),m.jsxs("select",{id:"type",defaultValue:i,onChange:g=>e({type:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"info",children:"Info"}),m.jsx("option",{value:"warning",children:"Warning"}),m.jsx("option",{value:"error",children:"Error"}),m.jsx("option",{value:"success",children:"Success"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"align",className:"block text-sm font-medium text-gray-700 mb-1",children:"Alignment"}),m.jsxs("select",{id:"align",defaultValue:a,onChange:g=>e({align:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"left",children:"Left"}),m.jsx("option",{value:"center",children:"Center"}),m.jsx("option",{value:"right",children:"Right"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"size",className:"block text-sm font-medium text-gray-700 mb-1",children:"Size"}),m.jsxs("select",{id:"size",defaultValue:c,onChange:g=>e({size:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"small",children:"Small"}),m.jsx("option",{value:"medium",children:"Medium"}),m.jsx("option",{value:"large",children:"Large"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"textAlign",className:"block text-sm font-medium text-gray-700 mb-1",children:"Text Alignment"}),m.jsxs("select",{id:"textAlign",defaultValue:d,onChange:g=>e({textAlign:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"left",children:"Left"}),m.jsx("option",{value:"center",children:"Center"}),m.jsx("option",{value:"right",children:"Right"})]})]})]}),m.jsx("div",{className:"mt-6 flex justify-end",children:m.jsx("button",{onClick:()=>s(!1),className:"px-4 py-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500",children:"Done"})})]})})]})},qx=Oe.create({name:"alertWidget",group:"block",atom:!0,draggable:!0,defining:!0,addAttributes(){return{type:{default:"info",parseHTML:t=>t.getAttribute("data-type"),renderHTML:t=>({"data-type":t.type})},title:{default:"Alert",parseHTML:t=>t.getAttribute("data-title"),renderHTML:t=>({"data-title":t.title})},message:{default:"This is an alert message.",parseHTML:t=>t.getAttribute("data-message"),renderHTML:t=>({"data-message":t.message})},align:{default:"center",parseHTML:t=>t.getAttribute("data-align"),renderHTML:t=>({"data-align":t.align})},size:{default:"medium",parseHTML:t=>t.getAttribute("data-size"),renderHTML:t=>({"data-size":t.size})},textAlign:{default:"left",parseHTML:t=>t.getAttribute("data-text-align"),renderHTML:t=>({"data-text-align":t.textAlign})}}},parseHTML(){return[{tag:"div[data-alert-widget]",priority:52}]},renderHTML({HTMLAttributes:t}){return["div",pe(t,{"data-alert-widget":""})]},addNodeView(){return ju(xL)},addCommands(){return{setAlertWidget:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}}),wL=({node:t,updateAttributes:e,editor:n})=>{const[r,s]=C.useState(!1),{text:i,url:o,style:l,size:a,textAlign:c}=t.attrs,d={primary:"bg-primary text-primary-foreground hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80"},u={"fit-content":"w-auto","full-width":"w-full"},h={left:"text-left",center:"text-center",right:"text-right"};return m.jsxs(Iu,{children:[m.jsx("div",{className:`p-2 ${h[c]||h.left} cursor-grab`,"data-drag-handle":!0,onClick:()=>s(!0),children:m.jsx("div",{role:"button",tabIndex:0,className:`inline-block px-4 py-2 rounded-md ${d[l]} ${u[a]||u["fit-content"]}`,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),s(!0))},children:i})}),r&&m.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center",onClick:()=>s(!1),children:m.jsxs("div",{className:"bg-white p-6 rounded-lg shadow-xl w-full max-w-md",onClick:f=>f.stopPropagation(),children:[m.jsx("h3",{className:"text-xl font-semibold mb-4 text-gray-800",children:"Edit CTA Button"}),m.jsxs("div",{className:"space-y-4",children:[m.jsxs("div",{children:[m.jsx("label",{htmlFor:"text",className:"block text-sm font-medium text-gray-700 mb-1",children:"Button Text"}),m.jsx("input",{type:"text",id:"text",defaultValue:i,onBlur:f=>e({text:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"url",className:"block text-sm font-medium text-gray-700 mb-1",children:"URL"}),m.jsx("input",{type:"text",id:"url",defaultValue:o,onBlur:f=>e({url:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"style",className:"block text-sm font-medium text-gray-700 mb-1",children:"Style"}),m.jsxs("select",{id:"style",defaultValue:l,onChange:f=>e({style:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"primary",children:"Primary"}),m.jsx("option",{value:"secondary",children:"Secondary"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"size",className:"block text-sm font-medium text-gray-700 mb-1",children:"Size"}),m.jsxs("select",{id:"size",defaultValue:a,onChange:f=>e({size:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"fit-content",children:"Fit Content"}),m.jsx("option",{value:"full-width",children:"Full Width"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"textAlign",className:"block text-sm font-medium text-gray-700 mb-1",children:"Text Alignment"}),m.jsxs("select",{id:"textAlign",defaultValue:c,onChange:f=>e({textAlign:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"left",children:"Left"}),m.jsx("option",{value:"center",children:"Center"}),m.jsx("option",{value:"right",children:"Right"})]})]})]}),m.jsx("div",{className:"mt-6 flex justify-end",children:m.jsx("button",{onClick:()=>s(!1),className:"px-4 py-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500",children:"Done"})})]})})]})},Kx=Oe.create({name:"ctaWidget",group:"block",draggable:!0,atom:!0,defining:!0,addAttributes(){return{text:{default:"Click Here",parseHTML:t=>t.getAttribute("data-text"),renderHTML:t=>({"data-text":t.text})},url:{default:"#",parseHTML:t=>t.getAttribute("data-url"),renderHTML:t=>({"data-url":t.url})},style:{default:"primary",parseHTML:t=>t.getAttribute("data-style"),renderHTML:t=>({"data-style":t.style})},size:{default:"fit-content",parseHTML:t=>t.getAttribute("data-size"),renderHTML:t=>({"data-size":t.size})},textAlign:{default:"left",parseHTML:t=>t.getAttribute("data-text-align"),renderHTML:t=>({"data-text-align":t.textAlign})}}},parseHTML(){return[{tag:"div[data-cta-widget]",priority:52}]},renderHTML({HTMLAttributes:t}){return["div",pe(t,{"data-cta-widget":""})]},addNodeView(){return ju(wL)},addCommands(){return{setCtaWidget:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}});function kL(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:l}=t,a=r&&!s,c=iE(n),d=new RegExp(`\\s${c}$`),u=o?"^":"",h=s?"":c,f=a?new RegExp(`${u}${c}.*?(?=\\s${h}|$)`,"gm"):new RegExp(`${u}(?:^)?${c}[^\\s${h}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const g=l.pos-p.length,y=Array.from(p.matchAll(f)).pop();if(!y||y.input===void 0||y.index===void 0)return null;const b=y.input.slice(Math.max(0,y.index-1),y.index),w=new RegExp(`^[${i?.join("")}\0]?$`).test(b);if(i!==null&&!w)return null;const A=g+y.index;let S=A+y[0].length;return a&&d.test(p.slice(S-1,S+1))&&(y[0]+=" ",S+=1),A<l.pos&&S>=l.pos?{range:{from:A,to:S},query:y[0].slice(n.length),text:y[0]}:null}var vL=new ye("suggestion");function SL({pluginKey:t=vL,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:i=[" "],startOfLine:o=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:d="is-empty",command:u=()=>null,items:h=()=>[],render:f=()=>({}),allow:p=()=>!0,findSuggestionMatch:g=kL}){let y;const b=f?.(),w=()=>{const x=e.state.selection.$anchor.pos,k=e.view.coordsAtPos(x),{top:v,right:T,bottom:N,left:H}=k;try{return new DOMRect(H,v,T-H,N-v)}catch{return null}},A=(x,k)=>k?()=>{const v=t.getState(e.state),T=v?.decorationId,N=x.dom.querySelector(`[data-decoration-id="${T}"]`);return N?.getBoundingClientRect()||null}:w;function S(x,k){var v;try{const N=t.getState(x.state),H=N?.decorationId?x.dom.querySelector(`[data-decoration-id="${N.decorationId}"]`):null,V={editor:e,range:N?.range||{from:0,to:0},query:N?.query||null,text:N?.text||null,items:[],command:$=>u({editor:e,range:N?.range||{from:0,to:0},props:$}),decorationNode:H,clientRect:A(x,H)};(v=b?.onExit)==null||v.call(b,V)}catch{}const T=x.state.tr.setMeta(k,{exit:!0});x.dispatch(T)}const M=new me({key:t,view(){return{update:async(x,k)=>{var v,T,N,H,V,$,I;const j=(v=this.key)==null?void 0:v.getState(k),Q=(T=this.key)==null?void 0:T.getState(x.state),ie=j.active&&Q.active&&j.range.from!==Q.range.from,F=!j.active&&Q.active,ue=j.active&&!Q.active,xe=!F&&!ue&&j.query!==Q.query,_=F||ie&&xe,Z=xe||ie,fe=ue||ie&&xe;if(!_&&!Z&&!fe)return;const Se=fe&&!_?j:Q,pn=x.dom.querySelector(`[data-decoration-id="${Se.decorationId}"]`);y={editor:e,range:Se.range,query:Se.query,text:Se.text,items:[],command:fr=>u({editor:e,range:Se.range,props:fr}),decorationNode:pn,clientRect:A(x,pn)},_&&((N=b?.onBeforeStart)==null||N.call(b,y)),Z&&((H=b?.onBeforeUpdate)==null||H.call(b,y)),(Z||_)&&(y.items=await h({editor:e,query:Se.query})),fe&&((V=b?.onExit)==null||V.call(b,y)),Z&&(($=b?.onUpdate)==null||$.call(b,y)),_&&((I=b?.onStart)==null||I.call(b,y))},destroy:()=>{var x;y&&((x=b?.onExit)==null||x.call(b,y))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(x,k,v,T){const{isEditable:N}=e,{composing:H}=e.view,{selection:V}=x,{empty:$,from:I}=V,j={...k},Q=x.getMeta(t);if(Q&&Q.exit)return j.active=!1,j.decorationId=null,j.range={from:0,to:0},j.query=null,j.text=null,j;if(j.composing=H,N&&($||e.view.composing)){(I<k.range.from||I>k.range.to)&&!H&&!k.composing&&(j.active=!1);const ie=g({char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:V.$from}),F=`id_${Math.floor(Math.random()*4294967295)}`;ie&&p({editor:e,state:T,range:ie.range,isActive:k.active})?(j.active=!0,j.decorationId=k.decorationId?k.decorationId:F,j.range=ie.range,j.query=ie.query,j.text=ie.text):j.active=!1}else j.active=!1;return j.active||(j.decorationId=null,j.range={from:0,to:0},j.query=null,j.text=null),j}},props:{handleKeyDown(x,k){var v,T,N,H;const{active:V,range:$}=M.getState(x.state);if(!V)return!1;if(k.key==="Escape"||k.key==="Esc"){const j=M.getState(x.state),Q=(v=y?.decorationNode)!=null?v:null,ie=Q??(j?.decorationId?x.dom.querySelector(`[data-decoration-id="${j.decorationId}"]`):null);if(((T=b?.onKeyDown)==null?void 0:T.call(b,{view:x,event:k,range:j.range}))||!1)return!0;const ue={editor:e,range:j.range,query:j.query,text:j.text,items:[],command:xe=>u({editor:e,range:j.range,props:xe}),decorationNode:ie,clientRect:ie?()=>ie.getBoundingClientRect()||null:null};return(N=b?.onExit)==null||N.call(b,ue),S(x,t),!0}return((H=b?.onKeyDown)==null?void 0:H.call(b,{view:x,event:k,range:$}))||!1},decorations(x){const{active:k,range:v,decorationId:T,query:N}=M.getState(x);if(!k)return null;const H=!N?.length,V=[a];return H&&V.push(d),be.create(x.doc,[_e.inline(v.from,v.to,{nodeName:l,class:V.join(" "),"data-decoration-id":T,"data-decoration-content":c})])}}});return M}const CL=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),EL=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),jm=t=>{const e=EL(t);return e.charAt(0).toUpperCase()+e.slice(1)},Gx=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),ML=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var AL={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const TL=C.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:i,iconNode:o,...l},a)=>C.createElement("svg",{ref:a,...AL,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:Gx("lucide",s),...!i&&!ML(l)&&{"aria-hidden":"true"},...l},[...o.map(([c,d])=>C.createElement(c,d)),...Array.isArray(i)?i:[i]]));const X=(t,e)=>{const n=C.forwardRef(({className:r,...s},i)=>C.createElement(TL,{ref:i,iconNode:e,className:Gx(`lucide-${CL(jm(t))}`,`lucide-${t}`,r),...s}));return n.displayName=jm(t),n};const NL=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],Gl=X("bold",NL);const _L=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Pm=X("circle-alert",_L);const RL=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],OL=X("circle-check-big",RL);const DL=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],LL=X("circle-plus",DL);const IL=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],jL=X("circle-x",IL);const PL=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Nr=X("code-xml",PL);const BL=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],Rs=X("code",BL);const $L=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],HL=X("columns-2",$L);const zL=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],FL=X("columns-3",zL);const UL=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Jx=X("download",UL);const VL=[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]],WL=X("eraser",VL);const qL=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],KL=X("eye",qL);const GL=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],JL=X("file-code-2",GL);const YL=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],XL=X("hash",YL);const ZL=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],vs=X("heading-1",ZL);const QL=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],Vi=X("heading-2",QL);const eI=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],Aa=X("heading-3",eI);const tI=[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]],nI=X("heading-4",tI);const rI=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]],sI=X("heading-5",rI);const iI=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]],oI=X("heading-6",iI);const lI=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],zr=X("image",lI);const aI=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],kh=X("italic",aI);const cI=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Ta=X("link-2",cI);const dI=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],Wi=X("list-ordered",dI);const uI=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],Os=X("list",uI);const hI=[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]],Na=X("megaphone",hI);const fI=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],pI=X("menu",fI);const mI=[["path",{d:"M5 12h14",key:"1ays0h"}]],_a=X("minus",mI);const gI=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],vh=X("palette",gI);const yI=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],bI=X("play",yI);const xI=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],wI=X("redo-2",xI);const kI=[["path",{d:"M14 4a1 1 0 0 1 1-1",key:"dhj8ez"}],["path",{d:"M15 10a1 1 0 0 1-1-1",key:"1mnyi5"}],["path",{d:"M21 4a1 1 0 0 0-1-1",key:"sfs9ap"}],["path",{d:"M21 9a1 1 0 0 1-1 1",key:"mp6qeo"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a2 2 0 0 1 2-2h2",key:"15xut4"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}]],vI=X("replace",kI);const SI=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],CI=X("rotate-ccw",SI);const EI=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]],MI=X("rows-2",EI);const AI=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],TI=X("rows-3",AI);const NI=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],_I=X("search",NI);const RI=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ra=X("square-check-big",RI);const OI=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],Yx=X("strikethrough",OI);const DI=[["path",{d:"m4 5 8 8",key:"1eunvl"}],["path",{d:"m12 5-8 8",key:"1ah0jp"}],["path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07",key:"e8ta8j"}]],Xx=X("subscript",DI);const LI=[["path",{d:"m4 19 8-8",key:"hr47gm"}],["path",{d:"m12 19-8-8",key:"1dhhmo"}],["path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06",key:"1dfcux"}]],Zx=X("superscript",LI);const II=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],qi=X("table-2",II);const jI=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],PI=X("terminal",jI);const BI=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Ki=X("text-align-center",BI);const $I=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Gi=X("text-align-end",$I);const HI=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],Sh=X("text-align-justify",HI);const zI=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Ss=X("text-align-start",zI);const FI=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],Ji=X("text-quote",FI);const UI=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],Qx=X("trash-2",UI);const VI=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Oa=X("triangle-alert",VI);const WI=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],Wr=X("type",WI);const qI=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],Ch=X("underline",qI);const KI=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],GI=X("undo-2",KI);const JI=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],ew=X("video",JI);const YI=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],tw=X("x",YI),Eh=C.forwardRef(({items:t,command:e},n)=>{const[r,s]=C.useState(-1),i=C.useRef(null),o=a=>{const c=t[a];c&&e(c)};C.useEffect(()=>{if(t.length===0){s(-1);return}s(a=>{if(a===-1)return-1;const c=Math.min(Math.max(a,0),t.length-1);return Number.isFinite(c)?c:-1})},[t]),C.useEffect(()=>{if(!i.current||r===-1)return;const a=i.current.querySelector(`[data-index="${r}"]`);a&&a.scrollIntoView({block:"nearest"})},[r]),C.useImperativeHandle(n,()=>({onKeyDown:({event:a})=>t.length===0?!1:a.key==="ArrowUp"?(a.preventDefault(),s(c=>c===-1?t.length-1:(c-1+t.length)%t.length),!0):a.key==="ArrowDown"?(a.preventDefault(),s(c=>c===-1?0:(c+1)%t.length),!0):a.key==="Enter"?(a.preventDefault(),r!==-1&&o(r),!0):!1}));const l=a=>{a.stopPropagation()};return m.jsx("div",{ref:i,className:"z-50 max-h-72 w-72 overflow-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md",role:"listbox","aria-activedescendant":r!==-1?`cmd-opt-${r}`:void 0,tabIndex:-1,onWheel:l,style:{scrollbarWidth:"thin",scrollbarColor:"rgb(148 163 184) transparent"},children:t.length>0?t.map((a,c)=>{const d=r!==-1&&c===r;return m.jsxs("button",{id:`cmd-opt-${c}`,"data-index":c,role:"option","aria-selected":d,type:"button",onMouseDown:u=>u.preventDefault(),onClick:()=>o(c),className:De.cn("flex w-full items-center gap-2 rounded-sm p-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",d&&"bg-accent text-accent-foreground"),children:[m.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border bg-background",children:a.icon}),m.jsxs("div",{className:"min-w-0",children:[m.jsx("p",{className:"truncate font-medium",children:a.title}),a.description?m.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a.description}):null]})]},`${a.title}-${c}`)}):m.jsx("div",{className:"p-2 text-sm text-muted-foreground",children:"No results"})})});Eh.displayName="SlashCommandList";const XI=[{title:"Text",description:"Start writing with plain text.",icon:C.createElement(Wr,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).clearNodes().run()}},{title:"Heading 1",description:"Large section heading.",icon:C.createElement(vs,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:1}).run()}},{title:"Heading 2",description:"Medium section heading.",icon:C.createElement(Vi,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:2}).run()}},{title:"Heading 3",description:"Small section heading.",icon:C.createElement(Aa,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:3}).run()}},{title:"Heading 4",description:"Extra small section heading.",icon:C.createElement(nI,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:4}).run()}},{title:"Heading 5",description:"Tiny section heading.",icon:C.createElement(sI,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:5}).run()}},{title:"Heading 6",description:"Smallest section heading.",icon:C.createElement(oI,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:6}).run()}},{title:"Bullet List",description:"Create a simple bulleted list.",icon:C.createElement(Os,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBulletList().run()}},{title:"Numbered List",description:"Create a list with numbering.",icon:C.createElement(Wi,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleOrderedList().run()}},{title:"Task List",description:"Create a list with checkboxes.",icon:C.createElement(Ra,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleTaskList().run()}},{title:"Blockquote",description:"Create a quote or citation.",icon:C.createElement(Ji,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBlockquote().run()}},{title:"Code Block",description:"Create a code block with syntax highlighting.",icon:C.createElement(Rs,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleCodeBlock().run()}},{title:"Horizontal Rule",description:"Insert a horizontal divider.",icon:C.createElement(_a,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHorizontalRule().run()}},{title:"Image",description:"Insert an image from URL.",icon:C.createElement(zr,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{const n=window.prompt("Enter image URL:");n&&t.chain().focus().deleteRange(e).setImage({src:n}).run()}},{title:"Table",description:"Insert a table with rows and columns.",icon:C.createElement(qi,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{title:"Align Left",description:"Align text to the left.",icon:C.createElement(Ss,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("left").run()}},{title:"Align Center",description:"Center align text.",icon:C.createElement(Ki,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("center").run()}},{title:"Align Right",description:"Align text to the right.",icon:C.createElement(Gi,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("right").run()}},{title:"Justify",description:"Justify text alignment.",icon:C.createElement(Sh,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("justify").run()}},{title:"Video",description:"Embed a video from URL.",icon:C.createElement(ew,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{const n=window.prompt("Enter video URL (YouTube, Vimeo, etc.):");n&&t.chain().focus().deleteRange(e).insertContent(`<p><a href="${n}" target="_blank">Video: ${n}</a></p>`).run()}},{title:"Alert",description:"Insert an alert or notice.",icon:C.createElement(Oa,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.can().setAlertWidget()?t.chain().focus().deleteRange(e).setAlertWidget().run():t.chain().focus().deleteRange(e).toggleBlockquote().run()}},{title:"Call to Action",description:"Insert a call to action button.",icon:C.createElement(Na,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.can().setCtaWidget()?t.chain().focus().deleteRange(e).setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}).run():t.chain().focus().deleteRange(e).insertContent("Call to Action").run()}}],nw=de.create({name:"slashCommand",addOptions(){return{suggestion:{char:"/",allowSpaces:!1,allowedPrefixes:[" "],startOfLine:!1,decorationTag:"span",decorationClass:"slash-command"}}},addProseMirrorPlugins(){return[SL({char:"/",allowSpaces:!1,allowedPrefixes:[" "],startOfLine:!1,decorationTag:"span",decorationClass:"slash-command",editor:this.editor,items:({query:t})=>XI.filter(n=>n.title.toLowerCase().includes(t.toLowerCase())||n.description.toLowerCase().includes(t.toLowerCase())).slice(0,10),command:({editor:t,range:e,props:n})=>{n.command({editor:t,range:e})},render:()=>{let t=null,e=null,n=null;const r=i=>({getBoundingClientRect:()=>i()||new DOMRect(0,0,0,0)}),s=async i=>{if(!e)return;const o=r(i),{x:l,y:a}=await Fu(o,e,{placement:"bottom-start",middleware:[zu(6),Ab({fallbackPlacements:["top-start","bottom-start"]}),Mb({padding:8}),Tb({apply({availableWidth:c,availableHeight:d,elements:u}){Object.assign(u.floating.style,{maxWidth:`${Math.min(288,c-16)}px`,maxHeight:`${Math.min(288,d-16)}px`})}})],strategy:"fixed"});e.style.left=`${Math.round(l)}px`,e.style.top=`${Math.round(a)}px`};return{onStart:i=>{if(!i.clientRect)return;const o=i.clientRect;t=new pb(Eh,{props:i,editor:i.editor}),e=document.createElement("div"),e.style.position="fixed",e.style.zIndex="10000",e.style.top="0",e.style.left="0",e.style.pointerEvents="none",e.appendChild(t.element),t.element.style.pointerEvents="auto",t.element.addEventListener("wheel",a=>{a.stopPropagation()},{passive:!0}),document.body.appendChild(e);const l=r(o);n=Ms(l,e,()=>s(o)),s(o)},onUpdate:i=>{t?.updateProps(i),i.clientRect&&s(i.clientRect)},onKeyDown:({event:i})=>i.key==="Escape"?!0:t?.ref?.onKeyDown({event:i})??!1,onExit:()=>{n?.(),n=null,t?.destroy(),t=null,e?.remove(),e=null}}}})]}});var ZI=Zu,QI=eh;NA.extend({draggable:!0});zM.extend({draggable:!0});AM.extend({draggable:!0});ZI.extend({draggable:!0});QI.extend({draggable:!0});h0.extend({draggable:!0});f0.extend({draggable:!0});d0.extend({draggable:!0});u0.extend({draggable:!0});const rw=de.create({name:"draggableNodes",addGlobalAttributes(){return[{types:["paragraph","heading","blockquote","bulletList","orderedList","taskList","taskItem","codeBlock","image"],attributes:{draggable:{default:!0,parseHTML:()=>!0,renderHTML:()=>({"data-draggable":"true"})}}}]}}),e2=Oe.create({name:"styleTag",group:"block",atom:!0,isolating:!0,defining:!0,draggable:!1,addAttributes(){return{cssContent:{default:"",parseHTML:t=>t.innerHTML},type:{default:"text/css",parseHTML:t=>t.getAttribute("type"),renderHTML:t=>t.type?{type:t.type}:{}},media:{default:null,parseHTML:t=>t.getAttribute("media"),renderHTML:t=>t.media?{media:t.media}:{}}}},parseHTML(){return[{tag:"style",getAttrs:t=>{const e=t,n={cssContent:e.innerHTML,type:e.getAttribute("type")},r=e.getAttribute("media");return r!==null&&(n.media=r),n}}]},renderHTML({HTMLAttributes:t,node:e}){const n={...t};return delete n.cssContent,["style",n,e.attrs.cssContent||""]},addNodeView(){return({node:t,editor:e,getPos:n})=>{const r=document.createElement("div");return r.setAttribute("data-style-node-placeholder","true"),r.style.border="1px dashed #999",r.style.padding="8px",r.style.margin="1rem 0",r.style.fontFamily="monospace",r.style.fontSize="0.9em",r.style.color="#555",r.style.cursor="pointer",r.textContent="[Custom CSS Block - Edit in Source View]",r.contentEditable="false",r.title="Click to open Source View",r.addEventListener("click",()=>{try{e?.chain().focus()}catch{}try{window.dispatchEvent(new CustomEvent("editor:openSourceView"))}catch{}}),{dom:r}}}}),t2=Oe.create({name:"divBlock",group:"block",content:"block*",defining:!0,draggable:!0,addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}},id:{default:null,parseHTML:t=>t.getAttribute("id"),renderHTML:t=>t.id?{id:t.id}:{}}}},parseHTML(){return[{tag:"div",priority:51,getAttrs:t=>{const e=t,n={};for(let r=0;r<e.attributes.length;r++){const s=e.attributes[r];n[s.name]=s.value}return n}}]},renderHTML({node:t}){return["div",pe(this.options.HTMLAttributes,t.attrs),0]}}),n2=de.create({name:"preserveAllAttributesExtension",addGlobalAttributes(){return[{types:["paragraph","heading","listItem","blockquote","codeBlock","bulletList","orderedList","textStyle"],attributes:{style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}},class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},id:{default:null,parseHTML:t=>t.getAttribute("id"),renderHTML:t=>t.id?{id:t.id}:{}},dataAttributes:{default:null,parseHTML:t=>{const e={};for(let n=0;n<t.attributes.length;n++){const r=t.attributes[n];r.name.startsWith("data-")&&(e[r.name]=r.value)}return Object.keys(e).length>0?e:null},renderHTML:t=>t.dataAttributes||{}}}}]}}),r2=Oe.create({name:"scriptTag",group:"block",atom:!0,isolating:!0,defining:!0,draggable:!1,addAttributes(){return{jsContent:{default:"",parseHTML:t=>t.innerHTML},type:{default:"text/javascript",parseHTML:t=>t.getAttribute("type"),renderHTML:t=>t.type?{type:t.type}:{}},src:{default:null,parseHTML:t=>t.getAttribute("src"),renderHTML:t=>t.src?{src:t.src}:{}},async:{default:null,parseHTML:t=>t.getAttribute("async"),renderHTML:t=>t.async!=null?{async:""}:{}},defer:{default:null,parseHTML:t=>t.getAttribute("defer"),renderHTML:t=>t.defer!=null?{defer:""}:{}}}},parseHTML(){return[{tag:"script",getAttrs:t=>{const e=t,n={jsContent:e.innerHTML,type:e.getAttribute("type")},r=e.getAttribute("src");return r!==null&&(n.src=r),e.hasAttribute("async")&&(n.async=""),e.hasAttribute("defer")&&(n.defer=""),n}}]},renderHTML({HTMLAttributes:t,node:e}){const n={...t};return delete n.jsContent,["script",n,e.attrs.src?"":e.attrs.jsContent||""]},addNodeView(){return({editor:t})=>{const e=document.createElement("div");return e.setAttribute("data-script-node-placeholder","true"),e.style.border="1px dashed #999",e.style.padding="8px",e.style.margin="1rem 0",e.style.fontFamily="monospace",e.style.fontSize="0.9em",e.style.color="#555",e.style.cursor="pointer",e.textContent="[Custom JavaScript Block - Edit in Source View]",e.contentEditable="false",e.title="Click to open Source View",e.addEventListener("click",()=>{try{t?.chain().focus()}catch{}try{window.dispatchEvent(new CustomEvent("editor:openSourceView"))}catch{}}),{dom:e}}}}),s2=Oe.create({name:"svg",group:"inline",inline:!0,atom:!0,addOptions(){return{HTMLAttributes:{class:"inline-block align-middle"}}},addAttributes(){return{html:{default:""},viewBox:{default:"0 0 24 24"},width:{default:null},height:{default:null},fill:{default:"none"},stroke:{default:"currentColor"},class:{default:null},style:{default:null},xmlns:{default:"http://www.w3.org/2000/svg"}}},parseHTML(){return[{tag:"svg",priority:60,getAttrs:t=>{if(!(t instanceof Element))return!1;const e={html:t.innerHTML};return t.getAttribute("viewBox")&&(e.viewBox=t.getAttribute("viewBox")),t.getAttribute("width")&&(e.width=t.getAttribute("width")),t.getAttribute("height")&&(e.height=t.getAttribute("height")),t.getAttribute("fill")&&(e.fill=t.getAttribute("fill")),t.getAttribute("stroke")&&(e.stroke=t.getAttribute("stroke")),t.getAttribute("class")&&(e.class=t.getAttribute("class")),t.getAttribute("style")&&(e.style=t.getAttribute("style")),t.getAttribute("xmlns")&&(e.xmlns=t.getAttribute("xmlns")),e}}]},renderHTML({HTMLAttributes:t}){const e=document.createElementNS("http://www.w3.org/2000/svg","svg"),{html:n,...r}=t;return Object.entries(pe(this.options.HTMLAttributes,r)).forEach(([s,i])=>{i!=null&&e.setAttribute(s,String(i))}),n&&(e.innerHTML=n),{dom:e}},addNodeView(){return({node:t,HTMLAttributes:e})=>{const n=document.createElementNS("http://www.w3.org/2000/svg","svg"),{html:r,...s}=e;return Object.entries(s).forEach(([i,o])=>{i!=="html"&&o!==null&&o!==void 0&&n.setAttribute(i,String(o))}),t.attrs.html?n.innerHTML=t.attrs.html:r&&(n.innerHTML=r),n.classList.add("parsed-svg-node"),{dom:n}}}}),i2=Oe.create({name:"spanComponent",group:"inline",inline:!0,content:"inline*",addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}}}},parseHTML(){return[{tag:"span",priority:60,getAttrs:t=>t instanceof HTMLElement&&t.hasAttribute("class")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",pe(this.options.HTMLAttributes,t),0]}}),o2=pL({html:hL,css:tL,js:oL,ts:uL,python:aL,json:lL,bash:qD,sql:cL}),Bm="http://www.w3.org/2000/svg";function $m(t){const e=document.createElementNS(Bm,"svg");return e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor"),e.classList.add("tiptap-drag-handle__icon","tiptap-drag-handle__icon--filled"),t.forEach(n=>{const r=document.createElementNS(Bm,"path");r.setAttribute("d",n),e.appendChild(r)}),e}const Mh=[sT.configure({codeBlock:!1,link:!1,undoRedo:!1,bulletList:{HTMLAttributes:{class:"list-disc pl-4"},keepMarks:!0,keepAttributes:!1},orderedList:{HTMLAttributes:{class:"list-decimal pl-4"},keepMarks:!0,keepAttributes:!1},dropcursor:{color:"#60A5FA",width:2},gapcursor:!1}),bA.configure({openOnClick:!1,autolink:!0,defaultProtocol:"https",protocols:["http","https","ftp","mailto"],validate:t=>/^https?:\/\//.test(t),HTMLAttributes:{class:"text-primary underline underline-offset-2 hover:text-primary/80 cursor-pointer",rel:"noopener noreferrer",target:"_blank"}}),p_,LA,m_.configure({depth:100,newGroupDelay:500}),d0.configure({lowlight:o2,defaultLanguage:"plaintext",HTMLAttributes:{class:"relative rounded-md bg-muted p-4 font-mono text-sm"}}),t2,e2,r2,s2,i2,n2,pT.configure({inline:!0,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-md"}}),h0.configure({HTMLAttributes:{class:"list-none pl-0 space-y-1"}}),f0.configure({nested:!0,HTMLAttributes:{class:"flex items-start gap-2 my-1"}}),M0.configure({resizable:!0,cellMinWidth:100,HTMLAttributes:{class:"w-full border-collapse border border-gray-300 dark:border-gray-700 my-4"}}),kN.configure({HTMLAttributes:{class:"border-b border-gray-300 dark:border-gray-700"}}),vN.configure({HTMLAttributes:{class:"bg-gray-100 dark:bg-gray-800 font-bold p-3 text-left border border-gray-300 dark:border-gray-700"}}),SN.configure({HTMLAttributes:{class:"p-3 border border-gray-300 dark:border-gray-700 min-w-[100px]"}}),FN.configure({color:{types:["textStyle"]},fontFamily:{types:["textStyle"]},fontSize:{types:["textStyle"]}}),AN.configure({multicolor:!0,HTMLAttributes:{class:"rounded-sm px-1 py-0.5"}}),NN,RN,DN.extend({addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{if(t.style.textAlign)return t.style.textAlign;if(t.getAttribute("align"))return t.getAttribute("align");const e=t.getAttribute("class")||"";return/(?:^|\s)text-center(?:\s|$)/.test(e)?"center":/(?:^|\s)text-right(?:\s|$)/.test(e)?"right":/(?:^|\s)text-justify(?:\s|$)/.test(e)?"justify":/(?:^|\s)text-left(?:\s|$)/.test(e)?"left":null},renderHTML:t=>t.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${t.textAlign} !important`}}}}]}}).configure({types:["heading","paragraph","div"],alignments:["left","center","right","justify"],defaultAlignment:"left"}),f_,Wx,UN.configure({limit:5e4,mode:"textSize"}),Vx,qx,Kx,nw,rw,LD,WD.configure({computePositionConfig:{placement:"left-start",strategy:"absolute",middleware:[zu({mainAxis:5,crossAxis:0})]},onElementDragStart:()=>{typeof document<"u"&&document.body.classList.add("dragging")},onElementDragEnd:()=>{typeof document<"u"&&document.body.classList.remove("dragging")},onNodeChange:({editor:t})=>{},render(){const t=document.createElement("div");t.classList.add("drag-handle","tiptap-drag-handle"),typeof window<"u"&&(window.__dragHandleElement=t);const e=document.createElement("div");e.classList.add("tiptap-drag-handle__group"),e.setAttribute("role","group"),e.dataset.orientation="horizontal",t.appendChild(e);const n=document.createElement("button");n.type="button",n.classList.add("tiptap-drag-handle__button","tiptap-drag-handle__button--ghost","tiptap-drag-handle__plus"),n.setAttribute("aria-label","Insert block"),n.setAttribute("title","Insert block");const r=$m(["M13 5C13 4.44772 12.5523 4 12 4C11.4477 4 11 4.44772 11 5V11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H11V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V13H19C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11H13V5Z"]);n.appendChild(r),e.appendChild(n);const s=document.createElement("button");s.type="button",s.classList.add("tiptap-drag-handle__button","tiptap-drag-handle__button--ghost","tiptap-drag-handle__grip"),s.setAttribute("aria-label","Drag to reorder"),s.setAttribute("title","Drag to reorder"),s.setAttribute("tabindex","0"),s.setAttribute("aria-haspopup","menu"),s.setAttribute("aria-expanded","false");const i=$m(["M9 3C7.89543 3 7 3.89543 7 5C7 6.10457 7.89543 7 9 7C10.1046 7 11 6.10457 11 5C11 3.89543 10.1046 3 9 3Z","M9 10C7.89543 10 7 10.8954 7 12C7 13.1046 7.89543 14 9 14C10.1046 14 11 13.1046 11 12C11 10.8954 10.1046 10 9 10Z","M7 19C7 17.8954 7.89543 17 9 17C10.1046 17 11 17.8954 11 19C11 20.1046 10.1046 21 9 21C7.89543 21 7 20.1046 7 19Z","M15 10C13.8954 10 13 10.8954 13 12C13 13.1046 13.8954 14 15 14C16.1046 14 17 13.1046 17 12C17 10.8954 16.1046 10 15 10Z","M13 5C13 3.89543 13.8954 3 15 3C16.1046 3 17 3.89543 17 5C17 6.10457 16.1046 7 15 7C13.8954 7 13 6.10457 13 5Z","M15 17C13.8954 17 13 17.8954 13 19C13 20.1046 13.8954 21 15 21C16.1046 21 17 20.1046 17 19C17 17.8954 16.1046 17 15 17Z"]);s.appendChild(i),e.appendChild(s);const o=()=>{const l=new CustomEvent("tiptap-gutter-toggle",{bubbles:!0,detail:{handle:e,button:n}});e.dispatchEvent(l)};return n.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),o()}),n.addEventListener("keydown",l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),o())}),s.addEventListener("mousedown",()=>{s.setAttribute("aria-expanded","true")}),s.addEventListener("mouseup",()=>{s.setAttribute("aria-expanded","false")}),t}})];var l2=typeof document<"u",a2=function(){},qd=l2?C.useLayoutEffect:a2;const c2={...ne},d2=c2.useInsertionEffect,u2=d2||(t=>t());function h2(t){const e=ne.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return u2(()=>{e.current=t}),ne.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return e.current==null?void 0:e.current(...r)},[])}var f2=typeof document<"u",p2=function(){},Wo=f2?C.useLayoutEffect:p2;function Jl(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,s;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!Jl(t[r],e[r]))return!1;return!0}if(s=Object.keys(t),n=s.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,s[r]))return!1;for(r=n;r--!==0;){const i=s[r];if(!(i==="_owner"&&t.$$typeof)&&!Jl(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function sw(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Hm(t,e){const n=sw(t);return Math.round(e*n)/n}function Bc(t){const e=ne.useRef(t);return Wo(()=>{e.current=t}),e}function m2(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:o}={},transform:l=!0,whileElementsMounted:a,open:c}=t,[d,u]=ne.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[h,f]=ne.useState(r);Jl(h,r)||f(r);const[p,g]=ne.useState(null),[y,b]=ne.useState(null),w=ne.useCallback(F=>{F!==x.current&&(x.current=F,g(F))},[]),A=ne.useCallback(F=>{F!==k.current&&(k.current=F,b(F))},[]),S=i||p,M=o||y,x=ne.useRef(null),k=ne.useRef(null),v=ne.useRef(d),T=a!=null,N=Bc(a),H=Bc(s),V=Bc(c),$=ne.useCallback(()=>{if(!x.current||!k.current)return;const F={placement:e,strategy:n,middleware:h};H.current&&(F.platform=H.current),Fu(x.current,k.current,F).then(ue=>{const xe={...ue,isPositioned:V.current!==!1};I.current&&!Jl(v.current,xe)&&(v.current=xe,c1.flushSync(()=>{u(xe)}))})},[h,e,n,H,V]);Wo(()=>{c===!1&&v.current.isPositioned&&(v.current.isPositioned=!1,u(F=>({...F,isPositioned:!1})))},[c]);const I=ne.useRef(!1);Wo(()=>(I.current=!0,()=>{I.current=!1}),[]),Wo(()=>{if(S&&(x.current=S),M&&(k.current=M),S&&M){if(N.current)return N.current(S,M,$);$()}},[S,M,$,N,T]);const j=ne.useMemo(()=>({reference:x,floating:k,setReference:w,setFloating:A}),[w,A]),Q=ne.useMemo(()=>({reference:S,floating:M}),[S,M]),ie=ne.useMemo(()=>{const F={position:n,left:0,top:0};if(!Q.floating)return F;const ue=Hm(Q.floating,d.x),xe=Hm(Q.floating,d.y);return l?{...F,transform:"translate("+ue+"px, "+xe+"px)",...sw(Q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:ue,top:xe}},[n,l,Q.floating,d.x,d.y]);return ne.useMemo(()=>({...d,update:$,refs:j,elements:Q,floatingStyles:ie}),[d,$,j,Q,ie])}const Yi=(t,e)=>({...zu(t),options:[t,e]}),Da=(t,e)=>({...Mb(t),options:[t,e]}),La=(t,e)=>({...Ab(t),options:[t,e]}),g2=(t,e)=>({...Tb(t),options:[t,e]}),y2={...ne};let zm=!1,b2=0;const Fm=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+b2++;function x2(){const[t,e]=ne.useState(()=>zm?Fm():void 0);return qd(()=>{t==null&&e(Fm())},[]),ne.useEffect(()=>{zm=!0},[]),t}const w2=y2.useId,k2=w2||x2;let Kd;process.env.NODE_ENV!=="production"&&(Kd=new Set);function v2(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((t=Kd)!=null&&t.has(s))){var i;(i=Kd)==null||i.add(s),console.error(s)}}function S2(){const t=new Map;return{emit(e,n){var r;(r=t.get(e))==null||r.forEach(s=>s(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var r;(r=t.get(e))==null||r.delete(n)}}}const C2=ne.createContext(null),E2=ne.createContext(null),M2=()=>{var t;return((t=ne.useContext(C2))==null?void 0:t.id)||null},A2=()=>ne.useContext(E2);function T2(t){const{open:e=!1,onOpenChange:n,elements:r}=t,s=k2(),i=ne.useRef({}),[o]=ne.useState(()=>S2()),l=M2()!=null;if(process.env.NODE_ENV!=="production"){const f=r.reference;f&&!ut(f)&&v2("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[a,c]=ne.useState(r.reference),d=h2((f,p,g)=>{i.current.openEvent=f?p:void 0,o.emit("openchange",{open:f,event:p,reason:g,nested:l}),n?.(f,p,g)}),u=ne.useMemo(()=>({setPositionReference:c}),[]),h=ne.useMemo(()=>({reference:a||r.reference||null,floating:r.floating||null,domReference:r.reference}),[a,r.reference,r.floating]);return ne.useMemo(()=>({dataRef:i,open:e,onOpenChange:d,elements:h,events:o,floatingId:s,refs:u}),[e,d,h,o,s,u])}function Xi(t){t===void 0&&(t={});const{nodeId:e}=t,n=T2({...t,elements:{reference:null,floating:null,...t.elements}}),r=t.rootContext||n,s=r.elements,[i,o]=ne.useState(null),[l,a]=ne.useState(null),d=s?.domReference||i,u=ne.useRef(null),h=A2();qd(()=>{d&&(u.current=d)},[d]);const f=m2({...t,elements:{...s,...l&&{reference:l}}}),p=ne.useCallback(A=>{const S=ut(A)?{getBoundingClientRect:()=>A.getBoundingClientRect(),getClientRects:()=>A.getClientRects(),contextElement:A}:A;a(S),f.refs.setReference(S)},[f.refs]),g=ne.useCallback(A=>{(ut(A)||A===null)&&(u.current=A,o(A)),(ut(f.refs.reference.current)||f.refs.reference.current===null||A!==null&&!ut(A))&&f.refs.setReference(A)},[f.refs]),y=ne.useMemo(()=>({...f.refs,setReference:g,setPositionReference:p,domReference:u}),[f.refs,g,p]),b=ne.useMemo(()=>({...f.elements,domReference:d}),[f.elements,d]),w=ne.useMemo(()=>({...f,...r,refs:y,elements:b,nodeId:e}),[f,y,b,e,r]);return qd(()=>{r.dataRef.current.floatingContext=w;const A=h?.nodesRef.current.find(S=>S.id===e);A&&(A.context=w)}),ne.useMemo(()=>({...f,context:w,refs:y,elements:b}),[f,y,b,w])}const N2="_pickerRoot_1wq30_1",_2="_picker_1wq30_1",Um={pickerRoot:N2,picker:_2};function Ia(){return(Ia=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function iw(t,e){if(t==null)return{};var n,r,s={},i=Object.keys(t);for(r=0;r<i.length;r++)e.indexOf(n=i[r])>=0||(s[n]=t[n]);return s}function Gd(t){var e=C.useRef(t),n=C.useRef(function(r){e.current&&e.current(r)});return e.current=t,n.current}var _i=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t<e?e:t},ni=function(t){return"touches"in t},Jd=function(t){return t&&t.ownerDocument.defaultView||self},Vm=function(t,e,n){var r=t.getBoundingClientRect(),s=ni(e)?(function(i,o){for(var l=0;l<i.length;l++)if(i[l].identifier===o)return i[l];return i[0]})(e.touches,n):e;return{left:_i((s.pageX-(r.left+Jd(t).pageXOffset))/r.width),top:_i((s.pageY-(r.top+Jd(t).pageYOffset))/r.height)}},Wm=function(t){!ni(t)&&t.preventDefault()},ow=C.memo(function(t){var e=t.onMove,n=t.onKey,r=iw(t,["onMove","onKey"]),s=C.useRef(null),i=Gd(e),o=Gd(n),l=C.useRef(null),a=C.useRef(!1),c=C.useMemo(function(){var f=function(y){Wm(y),(ni(y)?y.touches.length>0:y.buttons>0)&&s.current?i(Vm(s.current,y,l.current)):g(!1)},p=function(){return g(!1)};function g(y){var b=a.current,w=Jd(s.current),A=y?w.addEventListener:w.removeEventListener;A(b?"touchmove":"mousemove",f),A(b?"touchend":"mouseup",p)}return[function(y){var b=y.nativeEvent,w=s.current;if(w&&(Wm(b),!(function(S,M){return M&&!ni(S)})(b,a.current)&&w)){if(ni(b)){a.current=!0;var A=b.changedTouches||[];A.length&&(l.current=A[0].identifier)}w.focus(),i(Vm(w,b,l.current)),g(!0)}},function(y){var b=y.which||y.keyCode;b<37||b>40||(y.preventDefault(),o({left:b===39?.05:b===37?-.05:0,top:b===40?.05:b===38?-.05:0}))},g]},[o,i]),d=c[0],u=c[1],h=c[2];return C.useEffect(function(){return h},[h]),C.createElement("div",Ia({},r,{onTouchStart:d,onMouseDown:d,className:"react-colorful__interactive",ref:s,onKeyDown:u,tabIndex:0,role:"slider"}))}),Ah=function(t){return t.filter(Boolean).join(" ")},lw=function(t){var e=t.color,n=t.left,r=t.top,s=r===void 0?.5:r,i=Ah(["react-colorful__pointer",t.className]);return C.createElement("div",{className:i,style:{top:100*s+"%",left:100*n+"%"}},C.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:e}}))},ot=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n},R2=function(t){return j2(Yd(t))},Yd=function(t){return t[0]==="#"&&(t=t.substring(1)),t.length<6?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?ot(parseInt(t[3]+t[3],16)/255,2):1}:{r:parseInt(t.substring(0,2),16),g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16),a:t.length===8?ot(parseInt(t.substring(6,8),16)/255,2):1}},O2=function(t){return I2(L2(t))},D2=function(t){var e=t.s,n=t.v,r=t.a,s=(200-e)*n/100;return{h:ot(t.h),s:ot(s>0&&s<200?e*n/100/(s<=100?s:200-s)*100:0),l:ot(s/2),a:ot(r,2)}},Xd=function(t){var e=D2(t);return"hsl("+e.h+", "+e.s+"%, "+e.l+"%)"},L2=function(t){var e=t.h,n=t.s,r=t.v,s=t.a;e=e/360*6,n/=100,r/=100;var i=Math.floor(e),o=r*(1-n),l=r*(1-(e-i)*n),a=r*(1-(1-e+i)*n),c=i%6;return{r:ot(255*[r,l,o,o,a,r][c]),g:ot(255*[a,r,r,l,o,o][c]),b:ot(255*[o,o,a,r,r,l][c]),a:ot(s,2)}},Ro=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},I2=function(t){var e=t.r,n=t.g,r=t.b,s=t.a,i=s<1?Ro(ot(255*s)):"";return"#"+Ro(e)+Ro(n)+Ro(r)+i},j2=function(t){var e=t.r,n=t.g,r=t.b,s=t.a,i=Math.max(e,n,r),o=i-Math.min(e,n,r),l=o?i===e?(n-r)/o:i===n?2+(r-e)/o:4+(e-n)/o:0;return{h:ot(60*(l<0?l+6:l)),s:ot(i?o/i*100:0),v:ot(i/255*100),a:s}},P2=C.memo(function(t){var e=t.hue,n=t.onChange,r=Ah(["react-colorful__hue",t.className]);return C.createElement("div",{className:r},C.createElement(ow,{onMove:function(s){n({h:360*s.left})},onKey:function(s){n({h:_i(e+360*s.left,0,360)})},"aria-label":"Hue","aria-valuenow":ot(e),"aria-valuemax":"360","aria-valuemin":"0"},C.createElement(lw,{className:"react-colorful__hue-pointer",left:e/360,color:Xd({h:e,s:100,v:100,a:1})})))}),B2=C.memo(function(t){var e=t.hsva,n=t.onChange,r={backgroundColor:Xd({h:e.h,s:100,v:100,a:1})};return C.createElement("div",{className:"react-colorful__saturation",style:r},C.createElement(ow,{onMove:function(s){n({s:100*s.left,v:100-100*s.top})},onKey:function(s){n({s:_i(e.s+100*s.left,0,100),v:_i(e.v-100*s.top,0,100)})},"aria-label":"Color","aria-valuetext":"Saturation "+ot(e.s)+"%, Brightness "+ot(e.v)+"%"},C.createElement(lw,{className:"react-colorful__saturation-pointer",top:1-e.v/100,left:e.s/100,color:Xd(e)})))}),aw=function(t,e){if(t===e)return!0;for(var n in t)if(t[n]!==e[n])return!1;return!0},$2=function(t,e){return t.toLowerCase()===e.toLowerCase()||aw(Yd(t),Yd(e))};function H2(t,e,n){var r=Gd(n),s=C.useState(function(){return t.toHsva(e)}),i=s[0],o=s[1],l=C.useRef({color:e,hsva:i});C.useEffect(function(){if(!t.equal(e,l.current.color)){var c=t.toHsva(e);l.current={hsva:c,color:e},o(c)}},[e,t]),C.useEffect(function(){var c;aw(i,l.current.hsva)||t.equal(c=t.fromHsva(i),l.current.color)||(l.current={hsva:i,color:c},r(c))},[i,t,r]);var a=C.useCallback(function(c){o(function(d){return Object.assign({},d,c)})},[]);return[i,a]}var z2=typeof window<"u"?C.useLayoutEffect:C.useEffect,F2=function(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0},qm=new Map,U2=function(t){z2(function(){var e=t.current?t.current.ownerDocument:document;if(e!==void 0&&!qm.has(e)){var n=e.createElement("style");n.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`,qm.set(e,n);var r=F2();r&&n.setAttribute("nonce",r),e.head.appendChild(n)}},[])},V2=function(t){var e=t.className,n=t.colorModel,r=t.color,s=r===void 0?n.defaultColor:r,i=t.onChange,o=iw(t,["className","colorModel","color","onChange"]),l=C.useRef(null);U2(l);var a=H2(n,s,i),c=a[0],d=a[1],u=Ah(["react-colorful",e]);return C.createElement("div",Ia({},o,{ref:l,className:u}),C.createElement(B2,{hsva:c,onChange:d}),C.createElement(P2,{hue:c.h,onChange:d,className:"react-colorful__last-control"}))},W2={defaultColor:"000",toHsva:R2,fromHsva:function(t){return O2({h:t.h,s:t.s,v:t.v,a:1})},equal:$2},q2=function(t){return C.createElement(V2,Ia({},t,{colorModel:W2}))};const Km="#1F2937",Gm="#FFF7D1",K2=["#FFF7D1","#FFEAE3","#DCFCE7","#DBEAFE"],G2=[{title:"Brand",colors:[{label:"Primary",value:"hsl(var(--primary))"},{label:"Secondary",value:"hsl(var(--secondary))"},{label:"Accent",value:"hsl(var(--accent))"},{label:"Ring",value:"hsl(var(--ring))"}]},{title:"Neutrals",colors:[{label:"Foreground",value:"hsl(var(--foreground))"},{label:"Muted",value:"hsl(var(--muted-foreground))"},{label:"Background",value:"hsl(var(--background))"},{label:"Card",value:"hsl(var(--card))"}]},{title:"States",colors:[{label:"Warning",value:"hsl(var(--warning))"},{label:"Destructive",value:"hsl(var(--destructive))"},{label:"Success",value:"hsl(var(--chart-2))"},{label:"Info",value:"hsl(var(--chart-5))"}]},{title:"Utility",colors:[{label:"Secondary FG",value:"hsl(var(--secondary-foreground))"},{label:"Accent FG",value:"hsl(var(--accent-foreground))"},{label:"Primary FG",value:"hsl(var(--primary-foreground))"},{label:"Border",value:"hsl(var(--border))"}]}],J2=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Y2=/^#[0-9a-f]{6}$/i,cw=/^rgba?\((\s*\d{1,3}\s*,){2}\s*\d{1,3}\s*(,\s*(0|1|0?\.\d+)\s*)?\)$/i,dw=/^hsla?\((\s*\d{1,3}\s*,)(\s*\d{1,3}%\s*,)\s*\d{1,3}%\s*(,\s*(0|1|0?\.\d+)\s*)?\)$/i;function Yl(t){const e=t.replace("#","").trim();return e.length===3||e.length===4?`#${e.split("").map(r=>r+r).join("").toUpperCase()}`:e.length===6||e.length===8?`#${e.toUpperCase()}`:t}function uw(t){const e=Yl(t).replace("#","");if(e.length!==6&&e.length!==8)return null;const n=parseInt(e.slice(0,2),16),r=parseInt(e.slice(2,4),16),s=parseInt(e.slice(4,6),16),i=e.length===8?parseInt(e.slice(6,8),16)/255:1;return{r:n,g:r,b:s,a:i}}function Zd(t,e,n){return`#${[t,e,n].map(r=>Math.max(0,Math.min(255,Math.round(r))).toString(16).padStart(2,"0")).join("").toUpperCase()}`}function ri(t,e=2){const n=10**e;return Math.round(t*n)/n}function si(t,e,n,r=1){const s=t/255,i=e/255,o=n/255,l=Math.max(s,i,o),a=Math.min(s,i,o);let c=0,d=0;const u=(l+a)/2;if(l!==a){const g=l-a;switch(d=u>.5?g/(2-l-a):g/(l+a),l){case s:c=(i-o)/g+(i<o?6:0);break;case i:c=(o-s)/g+2;break;case o:c=(s-i)/g+4;break}c/=6}const h=Math.round(c*360),f=Math.round(d*100),p=Math.round(u*100);return r!==1?`hsla(${h}, ${f}%, ${p}%, ${ri(r,2)})`:`hsl(${h}, ${f}%, ${p}%)`}function Jm(t){if(typeof window>"u"||typeof document>"u")return null;const e=document.createElement("span");if(e.style.color="",e.style.color=t,!e.style.color)return null;e.style.position="absolute",e.style.visibility="hidden",e.style.pointerEvents="none",document.body.appendChild(e);const n=getComputedStyle(e).color;document.body.removeChild(e);const r=n.match(/rgba?\(([^)]+)\)/i);if(!r)return null;const[s,i,o,l]=r[1].split(",").map(a=>a.trim()).map((a,c)=>c===3?parseFloat(a):parseInt(a,10));return[s,i,o].some(a=>Number.isNaN(a))?null:{r:s,g:i,b:o,a:typeof l=="number"&&!Number.isNaN(l)?l:1}}function Sn(t){if(!t)return null;const e=t.trim();if(J2.test(e)){const r=Yl(e),s=uw(r);if(!s)return null;const i=`#${r.replace("#","").slice(0,6)}`;return{source:r,hex:i,rgb:s.a===1?`rgb(${s.r}, ${s.g}, ${s.b})`:`rgba(${s.r}, ${s.g}, ${s.b}, ${ri(s.a,2)})`,hsl:si(s.r,s.g,s.b,s.a),alpha:s.a}}if(cw.test(e)||dw.test(e)){const r=Jm(e);return r?{source:e,hex:Zd(r.r,r.g,r.b),rgb:r.a===1?`rgb(${r.r}, ${r.g}, ${r.b})`:`rgba(${r.r}, ${r.g}, ${r.b}, ${ri(r.a,2)})`,hsl:si(r.r,r.g,r.b,r.a),alpha:r.a}:null}const n=Jm(e);return n?{source:e,hex:Zd(n.r,n.g,n.b),rgb:n.a===1?`rgb(${n.r}, ${n.g}, ${n.b})`:`rgba(${n.r}, ${n.g}, ${n.b}, ${ri(n.a,2)})`,hsl:si(n.r,n.g,n.b,n.a),alpha:n.a}:null}function hw(t){const e=uw(t);if(e)return{source:Yl(t),hex:Zd(e.r,e.g,e.b),rgb:e.a===1?`rgb(${e.r}, ${e.g}, ${e.b})`:`rgba(${e.r}, ${e.g}, ${e.b}, ${ri(e.a,2)})`,hsl:si(e.r,e.g,e.b,e.a),alpha:e.a};const n=Yl(t);return{source:n,hex:n.slice(0,7),rgb:"rgb(0, 0, 0)",hsl:si(0,0,0,1),alpha:1}}const $s=Sn(Km)??hw(Km),Ym=Sn(Gm)??hw(Gm);function fw({editor:t,className:e,initialMode:n="text"}){const r=C.useRef(null),[s,i]=C.useState(n),[o,l]=C.useState(null),[a,c]=C.useState($s),[d,u]=C.useState(Ym);C.useEffect(()=>{i(n)},[n]);const[h,f]=C.useState($s.hex),[p,g]=C.useState(!1),[y,b]=C.useState($s.rgb),[w,A]=C.useState(!1),[S,M]=C.useState($s.hsl),[x,k]=C.useState(!1),v=s==="text"?a:d;C.useEffect(()=>{const $=()=>{if(o)return;const I=t.getAttributes("textStyle").color,j=t.getAttributes("highlight").color,Q=Sn(I)??$s,ie=Sn(j)??Ym;c(Q),u(ie)};return $(),t.on("selectionUpdate",$),t.on("transaction",$),()=>{t.off("selectionUpdate",$),t.off("transaction",$)}},[t,o,s]),C.useEffect(()=>{o!=="hex"&&f(v.hex),o!=="rgb"&&b(v.rgb),o!=="hsl"&&M(v.hsl),o===null&&(g(!1),A(!1),k(!1))},[v,o]);const T=C.useCallback(($,I,j=!0)=>{const Q=t.chain();j&&Q.focus(),$==="text"?(c(I),Q.setColor(I.source).run()):(u(I),Q.setHighlight({color:I.source}).run())},[t,c,u]),N=C.useCallback(($,I)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{T($,I,!1)},300)},[T]),H=C.useCallback($=>{r.current&&clearTimeout(r.current);const I=Sn($);I&&(T(s,I,!1),g(!1))},[T,s,g]),V=C.useCallback($=>{r.current&&clearTimeout(r.current);const I=Sn($);I&&(T(s,I),g(!1))},[T,s,g]);return m.jsxs("div",{className:De.cn("flex w-full sm:w-auto flex-col gap-3 sm:gap-4",e),children:[m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsxs("div",{className:"inline-flex items-center gap-1 rounded-md bg-muted/60 p-1",children:[m.jsx(le.Button,{type:"button",variant:s==="text"?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs",onClick:()=>i("text"),children:"Text"}),m.jsx(le.Button,{type:"button",variant:s==="highlight"?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs",onClick:()=>i("highlight"),children:"Highlight"})]}),m.jsx("div",{className:"flex items-center",children:m.jsx(le.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>{s==="text"?t.chain().focus().unsetColor().run():t.chain().focus().unsetHighlight().run()},children:"Remove Color"})})]}),m.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:gap-4",children:[m.jsx("div",{className:Um.pickerRoot,children:m.jsx(q2,{color:v.hex,onChange:H,className:Um.picker})}),m.jsxs("div",{className:"flex w-full flex-col gap-2 text-[11px] sm:w-[150px]",children:[m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"HEX"}),m.jsx(ns.Input,{value:h,onFocus:()=>l("hex"),onChange:$=>{const I=$.target.value;if(f(I),Y2.test(I)){const j=Sn(I);j&&(N(s,j),g(!1))}else g(!0)},onBlur:()=>{l(null),p&&(f(v.hex),g(!1))},spellCheck:!1,className:De.cn("h-8 w-full text-xs",p&&"border-destructive focus-visible:ring-destructive")})]}),m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"RGB"}),m.jsx(ns.Input,{value:y,onFocus:()=>l("rgb"),onChange:$=>{const I=$.target.value;if(b(I),cw.test(I)){const j=Sn(I);j&&(N(s,j),A(!1))}else A(!0)},onBlur:()=>{l(null),w&&(b(v.rgb),A(!1))},spellCheck:!1,className:De.cn("h-8 w-full text-xs",w&&"border-destructive focus-visible:ring-destructive")})]}),m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"HSL"}),m.jsx(ns.Input,{value:S,onFocus:()=>l("hsl"),onChange:$=>{const I=$.target.value;if(M(I),dw.test(I)){const j=Sn(I);j&&(N(s,j),k(!1))}else k(!0)},onBlur:()=>{l(null),x&&(M(v.hsl),k(!1))},spellCheck:!1,className:De.cn("h-8 w-full text-xs",x&&"border-destructive focus-visible:ring-destructive")})]})]})]}),m.jsxs("div",{className:"space-y-1.5",children:[m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Theme colors"}),m.jsx("div",{className:"space-y-1",children:G2.map($=>m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground/80",children:$.title}),m.jsx("div",{className:"flex items-center gap-1.5",children:$.colors.map(I=>m.jsx("button",{type:"button",onClick:()=>V(I.value),className:"h-6 w-6 rounded border border-border bg-background shadow-sm transition hover:border-primary/40 hover:shadow-sm",style:{background:I.value},"aria-label":`${$.title} color ${I.label}`,title:`${$.title} color ${I.label}`},I.label))})]},$.title))})]}),s==="highlight"?m.jsxs("div",{className:"space-y-2",children:[m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Highlight presets"}),m.jsx("div",{className:"flex flex-wrap gap-1.5",children:K2.map($=>m.jsxs("button",{type:"button",onClick:()=>V($),className:"flex items-center gap-1 rounded-full border bg-background px-2 py-1 text-[11px] shadow-sm transition hover:border-primary/40 hover:shadow-sm",children:[m.jsx("span",{className:"h-3.5 w-3.5 rounded-full border",style:{background:$},"aria-hidden":!0}),$]},$))})]}):null]})}const X2=["px","pt","rem","em","%"];function qo(t){if(!t)return null;const n=String(t).trim().match(/^(-?\d*\.?\d+)(px|pt|rem|em|%)$/i);if(!n)return null;const r=parseFloat(n[1]),s=n[2].toLowerCase();return Number.isFinite(r)?{value:r,unit:s}:null}function Qd(t){if(!t)return null;const{value:e,unit:n}=t;return n==="%"?`${Math.max(1,Math.round(e))}%`:n==="px"||n==="pt"?`${Math.max(1,Math.round(e))}${n}`:`${Math.max(.01,Math.round(e*100)/100)}${n}`}function Z2(t){const e=qo(t);return e?Qd(e):null}function Q2(){if(typeof document>"u")return[];const t=[];try{const n=Array.from(document.styleSheets),r=[],s=[];for(const l of n){const a=l.href,c=l.ownerNode;`${a||""} ${c?.textContent||""}`.toLowerCase().includes("globals.css")?r.push(l):s.push(l)}const i=[...r,...s],o=new Set(["h1","h2","h3","h4","h5","h6"]);for(const l of i){let a=null;try{a=l.cssRules}catch{continue}if(a){for(const c of Array.from(a))if(c.style){const u=c.style.fontSize,h=c.selectorText;if(u&&h&&o.has(h)){const f=Z2(u)??u.trim();if(f){const p=parseInt(h.replace("h",""),10);t.push({level:p,value:f})}}}}}}catch{}const e=new Map;for(const n of t)e.has(n.level)||e.set(n.level,n.value);return Array.from(e.entries()).map(([n,r])=>({level:n,value:r}))}function ej(t){if(typeof document>"u")return 0;try{const e=document.createElement("span");e.style.position="absolute",e.style.visibility="hidden",e.style.fontSize=t,document.body.appendChild(e);const n=parseFloat(getComputedStyle(e).fontSize);return document.body.removeChild(e),Number.isFinite(n)?n:0}catch{return 0}}function Xl(){if(typeof document>"u")return 16;try{const t=parseFloat(getComputedStyle(document.documentElement).fontSize);return Number.isFinite(t)&&t>0?t:16}catch{return 16}}function Th(t){try{const e=t.state.selection.from,n=t.view.domAtPos(e),r=n&&n.node||t.view.dom,s=r.nodeType===1?r:t.view.dom,i=parseFloat(getComputedStyle(s).fontSize);return Number.isFinite(i)&&i>0?i:Xl()}catch{return Xl()}}function tj(t,e,n){const r=Xl(),s=Th(n);switch(e){case"px":return t;case"pt":return t*(96/72);case"rem":return t*r;case"em":return t*s;case"%":return t/100*s}}function nj(t,e,n){const r=Xl(),s=Th(n);switch(e){case"px":return t;case"pt":return t*(72/96);case"rem":return t/r;case"em":return t/s;case"%":return t/s*100}}function pw({editor:t,className:e}){const[n,r]=C.useState([]),[s,i]=C.useState(null),[o,l]=C.useState(""),[a,c]=C.useState("px"),[d,u]=C.useState(!1),h=C.useRef(null),f=C.useCallback(()=>{const S=t.getAttributes("textStyle").fontSize,M=qo(S);if(M)l(String(M.value)),c(M.unit),u(!1);else{if(S&&typeof S=="string"){const x=ej(S);if(x>0&&!s){l(String(Math.round(x))),c("px"),u(!1);return}}s||(l(""),c("px"),u(!1))}},[t,s]);C.useEffect(()=>{f();const S=()=>f();return t.on("selectionUpdate",S),t.on("transaction",S),()=>{t.off("selectionUpdate",S),t.off("transaction",S)}},[t,f]),C.useEffect(()=>{r(Q2())},[]);const p=C.useCallback((S,M=!0)=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{const x=t.chain();M&&x.focus(),x.setFontSize(S).run()},120)},[t]),g=C.useCallback(S=>{l(S);const M=`${S}${a}`,x=qo(M);if(x){u(!1);const k=Qd(x);k&&p(k,!1)}else u(S.trim().length>0)},[a,p]),y=C.useCallback(S=>{const M=a;c(S);let x=0;const k=parseFloat(o);Number.isFinite(k)?x=tj(k,M,t):x=Th(t);const v=nj(x,S,t);let T;S==="px"||S==="pt"||S==="%"?T=String(Math.round(v)):T=String(Math.max(.01,Math.round(v*100)/100)),l(T);const N=Qd(qo(`${T}${S}`));N&&p(N)},[a,o,t,p]),b=C.useCallback(()=>{h.current&&clearTimeout(h.current),t.chain().focus().unsetFontSize().run(),u(!1)},[t]),w=C.useMemo(()=>a==="px"||a==="pt"||a==="%"?1:.01,[a]),A=C.useMemo(()=>{switch(a){case"%":return"100";case"px":return"16";case"pt":return"12";case"rem":return"1";case"em":return"1";default:return""}},[a]);return m.jsxs("div",{className:De.cn("space-y-3",e),onMouseDown:S=>S.stopPropagation(),children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(Wr,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Font size"})]}),m.jsxs(le.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:b,title:"Erase font size","aria-label":"Erase font size",children:[m.jsx(WL,{className:"h-3.5 w-3.5 mr-1"}),"Erase"]})]}),m.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-2 items-end",children:[m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"Value"}),m.jsx(ns.Input,{type:"number",inputMode:"decimal",step:w,placeholder:A,value:o,onFocus:()=>i("value"),onChange:S=>g(S.target.value),onBlur:()=>i(null),className:De.cn("h-9",d&&"border-destructive focus-visible:ring-destructive"),spellCheck:!1})]}),m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"Unit"}),m.jsx("div",{className:"flex gap-1",children:m.jsx("select",{value:a,onChange:S=>y(S.target.value),onFocus:()=>i("unit"),onBlur:()=>i(null),className:"h-9 w-[84px] rounded-md border border-input bg-background px-2 text-sm shadow-sm outline-none focus-visible:ring-2 focus-visible:ring-ring",children:X2.map(S=>m.jsx("option",{value:S,children:S},S))})})]})]}),m.jsxs("div",{className:"space-y-2",children:[n.length>0?m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Headings"}),m.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:n.map(({level:S,value:M})=>m.jsx("button",{type:"button",onClick:()=>p(M),className:"h-8 w-full rounded-md border bg-background px-2 text-xs font-medium shadow-sm transition hover:border-primary/40 hover:shadow-sm",title:`Apply H${S} (${M})`,children:`H${S} (${M})`},`h${S}`))})]}):null,m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Keywords"}),m.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:["xx-small","x-small","small","medium","large","x-large"].map(S=>m.jsx("button",{type:"button",onClick:()=>p(S),className:"h-8 w-full rounded-md border bg-background px-2 text-xs font-medium shadow-sm transition hover:border-primary/40 hover:shadow-sm",title:`Apply ${S}`,children:S.replace(/\b\w/g,M=>M.toUpperCase())},S))})]})]})]})}const rj=({editor:t})=>{const[e,n]=C.useState(t.getAttributes("link")?.href??"");C.useEffect(()=>{const s=()=>{n(t.getAttributes("link")?.href??"")};return t.on("selectionUpdate",s),t.on("transaction",s),()=>{t.off("selectionUpdate",s),t.off("transaction",s)}},[t]);const r=()=>{const s=e.trim();s?t.chain().focus().extendMarkRange("link").setLink({href:s}).run():t.chain().focus().extendMarkRange("link").unsetLink().run()};return m.jsxs("div",{className:"p-2 flex items-center gap-2",onMouseDown:s=>s.preventDefault(),children:[m.jsx("input",{type:"url",value:e,onChange:s=>n(s.target.value),placeholder:"Enter URL",className:"bg-background p-1 rounded border border-input text-sm",onKeyDown:s=>s.key==="Enter"&&r()}),m.jsx(le.Button,{type:"button",size:"sm",onClick:r,children:"Set Link"})]})},sj=({editor:t})=>m.jsx("div",{className:"w-[380px]",children:m.jsx(fw,{editor:t,className:"p-4",initialMode:t.isActive("highlight")?"highlight":"text"})}),Nh=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(!1),[i,o]=C.useState(!1),[l,a]=C.useState(!1),{x:c,y:d,refs:u,strategy:h,update:f}=Xi({placement:"top",middleware:[Yi(6),La(),Da()],whileElementsMounted:Ms}),p=C.useCallback(()=>{if(!t||!t.isEditable)return!1;const{state:y}=t,{from:b,to:w}=y.selection,A=b!==w,S=y.selection instanceof q,M=t.isActive("codeBlock"),x=y.selection.empty&&(t.isActive("alert-widget")||t.isActive("cta-widget")),k=t.isActive("image");return A&&!S&&!M&&!x&&!k},[t]),g=C.useCallback(()=>{if(!(!t||!p()))try{const{from:y,to:b}=t.state.selection,w=t.view.coordsAtPos(y),A=t.view.coordsAtPos(b),S={getBoundingClientRect:()=>({x:w.left,y:w.top,top:w.top,left:w.left,bottom:A.bottom,right:A.right,width:A.right-w.left,height:A.bottom-w.top})};u.setReference(S),f(),requestAnimationFrame(()=>s(!0))}catch(y){console.warn("BubbleMenu positioning error:",y)}},[t,u,f,p]);return C.useEffect(()=>{if(!t)return;let y=0;const b=()=>{cancelAnimationFrame(y),y=requestAnimationFrame(()=>{p()?(n(!0),g()):!i&&!l&&n(!1)})},w=({event:A})=>{i||l||u.floating.current&&A.relatedTarget&&u.floating.current.contains(A.relatedTarget)||n(!1)};return b(),t.on("selectionUpdate",b),t.on("transaction",b),t.on("focus",b),t.on("blur",w),()=>{cancelAnimationFrame(y),t.off("selectionUpdate",b),t.off("transaction",b),t.off("focus",b),t.off("blur",w)}},[t,p,g,i,l,u.floating]),!t||!e?null:m.jsxs("div",{ref:u.setFloating,style:{position:h,top:d??0,left:c??0,zIndex:1e4,visibility:r?"visible":"hidden"},className:"flex gap-1 items-center bg-background border rounded-lg p-1 shadow-lg",onMouseDown:y=>y.preventDefault(),children:[m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleBold().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("bold")?"bg-accent":""}`,"aria-label":"Bold",title:"Bold",children:m.jsx(Gl,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleItalic().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("italic")?"bg-accent":""}`,"aria-label":"Italic",title:"Italic",children:m.jsx(kh,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleUnderline().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("underline")?"bg-accent":""}`,"aria-label":"Underline",title:"Underline",children:m.jsx(Ch,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleStrike().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("strike")?"bg-accent":""}`,"aria-label":"Strikethrough",title:"Strikethrough",children:m.jsx(Yx,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleCode().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("code")?"bg-accent":""}`,"aria-label":"Inline code",title:"Inline code",children:m.jsx(Rs,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("div",{className:"w-px bg-border h-5"}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleSubscript().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("subscript")?"bg-accent":""}`,"aria-label":"Subscript",title:"Subscript",children:m.jsx(Xx,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleSuperscript().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("superscript")?"bg-accent":""}`,"aria-label":"Superscript",title:"Superscript",children:m.jsx(Zx,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("div",{className:"w-px bg-border h-5"}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("left").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"left"})?"bg-accent":""}`,"aria-label":"Align left",title:"Align left",children:m.jsx(Ss,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("center").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"center"})?"bg-accent":""}`,"aria-label":"Align center",title:"Align center",children:m.jsx(Ki,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("right").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"right"})?"bg-accent":""}`,"aria-label":"Align right",title:"Align right",children:m.jsx(Gi,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("justify").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"justify"})?"bg-accent":""}`,"aria-label":"Justify",title:"Justify",children:m.jsx(Sh,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("div",{className:"w-px bg-border h-5"}),m.jsxs(gt.Popover,{open:l,onOpenChange:a,children:[m.jsx(gt.PopoverTrigger,{asChild:!0,children:m.jsx("button",{type:"button",className:"p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center","aria-label":"Font size",title:"Font size",onMouseDown:y=>y.preventDefault(),children:m.jsx(Wr,{className:"h-4 w-4 pointer-events-none"})})}),m.jsx(gt.PopoverContent,{onFocusOutside:y=>y.preventDefault(),onMouseDown:y=>y.stopPropagation(),className:"w-[360px] p-0",side:"top",align:"start",children:m.jsx(pw,{editor:t,className:"p-4"})})]}),m.jsxs(gt.Popover,{children:[m.jsx(gt.PopoverTrigger,{asChild:!0,children:m.jsx("button",{type:"button",className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("link")?"bg-accent":""}`,"aria-label":"Link",title:"Link",onMouseDown:y=>y.preventDefault(),children:m.jsx(Ta,{className:"h-4 w-4 pointer-events-none"})})}),m.jsx(gt.PopoverContent,{className:"w-auto p-0",side:"top",align:"start",children:m.jsx(rj,{editor:t})})]}),m.jsxs(gt.Popover,{open:i,onOpenChange:o,children:[m.jsx(gt.PopoverTrigger,{asChild:!0,children:m.jsx("button",{type:"button",onMouseDown:y=>y.preventDefault(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("textStyle")||t.isActive("highlight")?"bg-accent":""}`,"aria-label":"Color / highlight",title:"Color / highlight",children:m.jsx(vh,{className:"h-4 w-4 pointer-events-none"})})}),m.jsx(gt.PopoverContent,{onFocusOutside:y=>y.preventDefault(),onMouseDown:y=>y.stopPropagation(),className:"w-auto p-0",side:"top",align:"start",children:m.jsx(sj,{editor:t})})]}),m.jsx("div",{className:"w-px bg-border h-5"})]})};function Xm(t,e){t.storage.mediaPicker={open:e}}function ja(t){return t.storage?.mediaPicker?.open}const ij=[{title:"Heading 1",icon:m.jsx(vs,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:1}).run()},{title:"Heading 2",icon:m.jsx(Vi,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:2}).run()},{title:"Bullet List",icon:m.jsx(Os,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBulletList().run()},{title:"Ordered List",icon:m.jsx(Wi,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleOrderedList().run()},{title:"Blockquote",icon:m.jsx(Ji,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBlockquote().run()},{title:"Code Block",icon:m.jsx(Rs,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleCodeBlock().run()},{title:"Image",icon:m.jsx(zr,{className:"h-4 w-4"}),command:async t=>{const e=ja(t);if(e){const r=await e();r?.src&&t.chain().focus().setImage({src:r.src,alt:r.alt||void 0}).updateAttributes("image",{blurDataURL:r.blurDataURL||void 0}).run();return}const n=window.prompt("URL");n&&t.chain().focus().setImage({src:n}).run()}},{title:"Table",icon:m.jsx(qi,{className:"h-4 w-4"}),command:t=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{title:"Horizontal Rule",icon:m.jsx(_a,{className:"h-4 w-4"}),command:t=>t.chain().focus().setHorizontalRule().run()},{title:"Link",icon:m.jsx(Ta,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter URL:");e&&t.chain().focus().setLink({href:e}).run()}},{title:"CSS Block",icon:m.jsx(Nr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter CSS (without <style> tags):","/* your styles */");if(e!=null){const n=`<style>${e}</style>`;t.commands.insertContentAt({from:0,to:0},n)}}},{title:"Script Block",icon:m.jsx(Nr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter JavaScript (without <script> tags):","// your script");if(e!=null){const n=`<script>${e}<\/script>`,r=t.state.doc.content.size;t.commands.insertContentAt(r,n)}}},{title:"DIV Block",icon:m.jsx(Nr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Optional class for DIV:",""),n=window.prompt("Optional inline style for DIV:",""),r=window.prompt("Optional content for DIV:","New block"),s=`${e?` class="${e}"`:""}${n?` style="${n}"`:""}`,o=r?`<p>${(l=>l.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"))(r)}</p>`:"<p><br /></p>";t.chain().focus().insertContent(`<div${s}>${o}</div>`).run()}},{title:"Alert Widget",icon:m.jsx(Oa,{className:"h-4 w-4"}),command:t=>{t.chain().focus().setAlertWidget().run()}},{title:"CTA Widget",icon:m.jsx(Na,{className:"h-4 w-4"}),command:t=>{t.chain().focus().setCtaWidget({text:"Learn more",url:"",style:"primary",size:"medium",textAlign:"center"}).run()}}],_h=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(null),[i,o]=C.useState(null),l=C.useRef(null),a=C.useRef(null),c=C.useRef(!1),d=C.useCallback(()=>{l.current&&l.current.setAttribute("aria-expanded","false"),a.current&&a.current.removeAttribute("data-menu-open"),l.current=null,a.current=null,s(null),n(!1)},[]),{x:u,y:h,refs:f,strategy:p}=Xi({placement:"right-start",open:e,middleware:[Yi(8),La(),Da()],whileElementsMounted:Ms});C.useEffect(()=>{c.current=e},[e]),C.useEffect(()=>{r?f.setReference(r):f.setReference(null)},[r,f]);const g=C.useCallback(()=>!(!t||!t.isEditable||t.isActive("image")),[t]);C.useEffect(()=>{if(!t)return;const b=t.view.dom.parentElement;if(!b)return;const w=A=>{const S=A,{handle:M,button:x}=S.detail;try{const v=t.state.selection?.$from;if(v){let T=v.depth;for(;T>0&&!v.node(T)?.isBlock;)T-=1;const N=typeof v.after=="function"?v.after(T):void 0;typeof N=="number"?o(N):typeof v.pos=="number"?o(v.pos):o(null)}else o(null)}catch{o(null)}if(l.current===x&&c.current){d();return}l.current&&l.current!==x&&l.current.setAttribute("aria-expanded","false"),a.current&&a.current!==M&&a.current.removeAttribute("data-menu-open"),l.current=x,a.current=M,x.setAttribute("aria-expanded","true"),M.setAttribute("data-menu-open","true"),s(x),n(!0)};return b.addEventListener("tiptap-gutter-toggle",w),()=>{b.removeEventListener("tiptap-gutter-toggle",w)}},[t,g,d]),C.useEffect(()=>{if(!t)return;const b=()=>{g()||d()};return t.on("selectionUpdate",b),t.on("transaction",b),t.on("blur",d),()=>{t.off("selectionUpdate",b),t.off("transaction",b),t.off("blur",d)}},[t,g,d]),C.useEffect(()=>{if(!e)return;const b=A=>{const S=A.target,M=f.floating.current;if(M&&!M.contains(S)){const x=l.current;(!x||!x.contains(S))&&d()}},w=A=>{A.key==="Escape"&&d()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",w)}},[e,d,f]);const y=b=>{i!=null?t.chain().focus().insertContentAt(i,{type:"paragraph"}).setTextSelection(i+1).run():t.chain().focus().run(),b(t),d()};return!r||!e?null:m.jsx("div",{ref:f.setFloating,style:{position:p,top:h??0,left:u??0,zIndex:10001},className:"w-48 rounded-md bg-white p-1 shadow-lg max-h-[400px] overflow-auto",onMouseDown:b=>b.preventDefault(),children:m.jsx("div",{className:"flex flex-col",children:ij.map(b=>m.jsxs(le.Button,{type:"button",variant:"ghost",className:"justify-start",onClick:()=>y(b.command),children:[b.icon,m.jsx("span",{className:"ml-2",children:b.title})]},b.title))})})},oj=[{title:"Text",description:"Start writing with plain text",icon:m.jsx(Wr,{className:"h-4 w-4"}),command:t=>t.chain().focus().clearNodes().run(),category:"basic",keywords:["text","paragraph","plain"]},{title:"Heading 1",description:"Large section heading",icon:m.jsx(vs,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:1}).run(),category:"headings",keywords:["heading","h1","title","large"]},{title:"Heading 2",description:"Medium section heading",icon:m.jsx(Vi,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:2}).run(),category:"headings",keywords:["heading","h2","subtitle","medium"]},{title:"Heading 3",description:"Small section heading",icon:m.jsx(Aa,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:3}).run(),category:"headings",keywords:["heading","h3","small"]},{title:"Bullet List",description:"Create a simple bulleted list",icon:m.jsx(Os,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBulletList().run(),category:"lists",keywords:["bullet","list","unordered","ul"]},{title:"Numbered List",description:"Create a list with numbering",icon:m.jsx(Wi,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleOrderedList().run(),category:"lists",keywords:["numbered","list","ordered","ol"]},{title:"Task List",description:"Create a list with checkboxes",icon:m.jsx(Ra,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleTaskList().run(),category:"lists",keywords:["task","todo","checkbox","checklist"]},{title:"Image",description:"Insert an image",icon:m.jsx(zr,{className:"h-4 w-4"}),command:async t=>{const e=ja(t);if(e){const r=await e();r?.src&&t.chain().focus().setImage({src:r.src,alt:r.alt||void 0}).updateAttributes("image",{blurDataURL:r.blurDataURL||void 0}).run();return}const n=window.prompt("Enter image URL:");n&&t.chain().focus().setImage({src:n}).run()},category:"media",keywords:["image","picture","photo","img"]},{title:"Video",description:"Embed a video from URL",icon:m.jsx(ew,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter video URL (YouTube, Vimeo, etc.):");e&&t.chain().focus().insertContent(`<p><a href="${e}" target="_blank">Video: ${e}</a></p>`).run()},category:"media",keywords:["video","youtube","vimeo","embed"]},{title:"Blockquote",description:"Create a quote or citation",icon:m.jsx(Ji,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBlockquote().run(),category:"advanced",keywords:["quote","blockquote","citation"]},{title:"Code Block",description:"Create a code block with syntax highlighting",icon:m.jsx(Rs,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleCodeBlock().run(),category:"advanced",keywords:["code","programming","syntax","block"]},{title:"Table",description:"Insert a table with rows and columns",icon:m.jsx(qi,{className:"h-4 w-4"}),command:t=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),category:"advanced",keywords:["table","grid","rows","columns"]},{title:"Horizontal Rule",description:"Insert a horizontal divider",icon:m.jsx(_a,{className:"h-4 w-4"}),command:t=>t.chain().focus().setHorizontalRule().run(),category:"advanced",keywords:["divider","separator","line","hr"]},{title:"Alert",description:"Insert an alert or notice",icon:m.jsx(Oa,{className:"h-4 w-4"}),command:t=>{t.can().setAlertWidget()?t.chain().focus().setAlertWidget().run():t.chain().focus().toggleBlockquote().run()},category:"advanced",keywords:["alert","notice","warning","info"]},{title:"Call to Action",description:"Insert a call to action button",icon:m.jsx(Na,{className:"h-4 w-4"}),command:t=>{t.can().setCtaWidget()?t.chain().focus().setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}).run():t.chain().focus().insertContent("Call to Action").run()},category:"advanced",keywords:["cta","button","action","link"]}],Zm={basic:m.jsx(Wr,{className:"h-3 w-3"}),headings:m.jsx(XL,{className:"h-3 w-3"}),lists:m.jsx(Os,{className:"h-3 w-3"}),media:m.jsx(zr,{className:"h-3 w-3"}),advanced:m.jsx(PI,{className:"h-3 w-3"})},Qm={basic:"Basic",headings:"Headings",lists:"Lists",media:"Media",advanced:"Advanced"},mw=({editor:t,wrapperRef:e})=>{const[n,r]=C.useState(!1),[s,i]=C.useState(!1),[o,l]=C.useState(!1),[a,c]=C.useState(""),[d,u]=C.useState("all"),[h,f]=C.useState({top:-9999,left:-9999,width:0}),{x:p,y:g,refs:y,strategy:b,update:w}=Xi({placement:"bottom-start",open:n,onOpenChange:r,middleware:[Yi(10),La({fallbackPlacements:["top-start","bottom-start","right-start"]}),Da({padding:8}),g2({apply({availableWidth:v,availableHeight:T,elements:N}){Object.assign(N.floating.style,{maxWidth:`${Math.min(400,v-16)}px`,maxHeight:`${Math.min(500,T-16)}px`})}})],whileElementsMounted:Ms}),A=C.useCallback(()=>{const{$from:v}=t.state.selection,T=v.parent;if(T.type.name==="paragraph"&&T.content.size===0||T.type.name==="heading"&&T.content.size===0)return!0;if(T.type.name==="listItem"&&T.content.size===1){const N=T.firstChild;if(N&&N.type.name==="paragraph"&&N.content.size===0)return!0}return t.isEditable},[t]),S=C.useCallback(()=>{if(!e?.current)return;const v=e.current.getBoundingClientRect(),T=t.view.dom.getBoundingClientRect(),H=t.view.coordsAtPos(t.state.selection.from).top-v.top,V=T.left-v.left,$=T.width;f({top:H,left:V,width:$}),w(),requestAnimationFrame(()=>l(!0))},[t,w,e]);C.useEffect(()=>{if(!t)return;let v=0;const T=()=>{cancelAnimationFrame(v),v=requestAnimationFrame(()=>{A()?(i(!0),l(!1),S()):(i(!1),r(!1),l(!1))})},N=()=>{i(!1),r(!1),l(!1)};return T(),t.on("selectionUpdate",T),t.on("transaction",T),t.on("focus",T),t.on("blur",N),()=>{cancelAnimationFrame(v),t.off("selectionUpdate",T),t.off("transaction",T),t.off("focus",T),t.off("blur",N)}},[t,A,S]);const M=v=>{v(t),r(!1),c(""),u("all")},x=oj.filter(v=>{const T=d==="all"||v.category===d,N=a===""||v.title.toLowerCase().includes(a.toLowerCase())||v.description.toLowerCase().includes(a.toLowerCase())||v.keywords.some(H=>H.toLowerCase().includes(a.toLowerCase()));return T&&N}),k=x.reduce((v,T)=>(v[T.category]||(v[T.category]=[]),v[T.category].push(T),v),{});return s?m.jsxs(m.Fragment,{children:[m.jsx("div",{style:{position:"absolute",top:h.top,left:h.left,width:h.width,visibility:o?"visible":"hidden",zIndex:1e4},className:"group",children:m.jsxs("div",{className:"relative py-4 w-[95%] mx-auto flex items-center","aria-label":"Insert block",children:[m.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-full h-0.5 bg-gradient-to-r from-transparent via-slate-300 to-transparent dark:via-slate-600 transform origin-center scale-x-0 opacity-0 group-hover:scale-x-100 group-hover:opacity-100 transition-all duration-300"}),m.jsxs("div",{ref:y.setReference,className:"relative z-10 cursor-pointer mx-auto",onClick:()=>r(v=>!v),children:[m.jsx("div",{className:"absolute -inset-3 rounded-full bg-primary/10 dark:bg-primary/20 scale-0 opacity-0 group-hover:scale-100 group-hover:opacity-100 transition-all duration-300 ease-out animate-pulse"}),m.jsx("div",{className:"relative bg-background border border-border p-1.5 rounded-full shadow-sm group-hover:shadow-md transition-all duration-200",children:m.jsx(LL,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors duration-200"})})]})]})}),n&&m.jsxs("div",{ref:y.setFloating,style:{position:b,top:g??0,left:p??0,zIndex:10001},className:"bg-background border border-border shadow-lg rounded-lg p-2 w-96 max-h-[500px] overflow-hidden",onMouseDown:v=>v.preventDefault(),children:[m.jsx("div",{className:"p-2 border-b border-border",children:m.jsx("input",{type:"text",placeholder:"Search blocks...",value:a,onChange:v=>c(v.target.value),className:"w-full px-3 py-2 text-sm bg-muted border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",autoFocus:!0})}),m.jsxs("div",{className:"flex gap-1 p-2 border-b border-border overflow-x-auto",children:[m.jsx(le.Button,{variant:d==="all"?"default":"ghost",size:"sm",onClick:()=>u("all"),className:"text-xs whitespace-nowrap",children:"All"}),Object.entries(Qm).map(([v,T])=>m.jsxs(le.Button,{variant:d===v?"default":"ghost",size:"sm",onClick:()=>u(v),className:"text-xs whitespace-nowrap flex items-center gap-1",children:[Zm[v],T]},v))]}),m.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[d==="all"?Object.entries(k).map(([v,T])=>m.jsxs("div",{className:"py-2",children:[m.jsxs("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-2",children:[Zm[v],Qm[v]]}),T.map(N=>m.jsx(le.Button,{variant:"ghost",className:"w-full justify-start p-3 h-auto text-left",onClick:()=>M(N.command),children:m.jsxs("div",{className:"flex items-center gap-3 w-full",children:[m.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-md border bg-muted",children:N.icon}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"font-medium text-sm",children:N.title}),m.jsx("p",{className:"text-xs text-muted-foreground truncate",children:N.description})]})]})},N.title))]},v)):x.map(v=>m.jsx(le.Button,{variant:"ghost",className:"w-full justify-start p-3 h-auto text-left",onClick:()=>M(v.command),children:m.jsxs("div",{className:"flex items-center gap-3 w-full",children:[m.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-md border bg-muted",children:v.icon}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"font-medium text-sm",children:v.title}),m.jsx("p",{className:"text-xs text-muted-foreground truncate",children:v.description})]})]})},v.title)),x.length===0&&m.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:['No blocks found for "',a,'"']})]})]})]}):null},lj=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),eg=new Set(["address","article","aside","blockquote","canvas","dd","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","li","main","nav","noscript","ol","p","pre","section","table","tfoot","ul","video","thead","tbody","tr","th","td","colgroup"]);function gw(t){const e=t.match(/^<\/?\s*([a-zA-Z0-9:-]+)/);return e?e[1].toLowerCase():null}function aj(t){return/^<\s*[^/!][^>]*>$/.test(t)}function tg(t){return/^<\s*\//.test(t)}function cj(t){if(/\/\s*>$/.test(t))return!0;const e=gw(t);return e?lj.has(e):!1}function dj(t){return/^<\s*!/.test(t)}function $c(t,e=2){if(!t)return"";const n=t.replace(/\r\n?/g,`
152
- `).split(/(<[^>]+>)/g).filter(Boolean),r=" ".repeat(e);let s=0;const i=[];let o=null;for(let l=0;l<n.length;l++){const a=n[l];if(a.startsWith("<")){const c=gw(a);c&&(c==="pre"||c==="code"||c==="script"||c==="style")&&tg(a)&&(o=null),tg(a)&&s>0&&(s-=1);const d=c&&eg.has(c)||dj(a),u=`${d?r.repeat(s):""}${a.trim()}`;if(d)i.push(u);else{const h=i.length?i[i.length-1]:"";h&&!h.endsWith(`
153
- `)?i[i.length-1]=h+a.trim():i.push(r.repeat(s)+a.trim())}c&&aj(a)&&!cj(a)&&eg.has(c)&&(s+=1,(c==="pre"||c==="code"||c==="script"||c==="style")&&(o=c))}else if(o){const c=a.split(`
154
- `);for(const d of c)i.push(d)}else{const c=a.replace(/\s+/g," ");if(c.length>0){const d=i.length?i[i.length-1]:"";if(d&&!d.endsWith(`
155
- `))i[i.length-1]=d+c;else{const u=c.replace(/^ +/,"");u&&i.push(r.repeat(s)+u)}}}}return i.join(`
146
+ `),[i,o]=j_(s);if(i.length===0)return;const l=Iw(i,0,n);return l.length===0?void 0:{type:"list",ordered:!0,start:((r=i[0])==null?void 0:r.number)||1,items:l,raw:s.slice(0,o).join(`
147
+ `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(B_,this.editor.getAttributes(jg)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=$s({find:$g,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=$s({find:$g,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(jg)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),z_=/^\s*(\[([( |x])?\])\s$/,Pw=De.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",fe(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const s=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return bf(t,e,s)},addExtensions(){return this.options.nested?[Nw(this.name,[this.options.taskListTypeName])]:[]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const s=document.createElement("li"),i=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=d=>{var h,f;l.ariaLabel=((f=(h=this.options.a11y)==null?void 0:h.checkboxLabel)==null?void 0:f.call(h,d,l.checked))||`Task item checkbox for ${d.textContent||"empty task item"}`};c(t),i.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",d=>d.preventDefault()),l.addEventListener("change",d=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:h}=d.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:f})=>{const p=n();if(typeof p!="number")return!1;const m=f.doc.nodeAt(p);return f.setNodeMarkup(p,void 0,{...m?.attrs,checked:h}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,h)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([d,h])=>{s.setAttribute(d,h)}),s.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,i.append(l,o),s.append(i,a),Object.entries(e).forEach(([d,h])=>{s.setAttribute(d,h)});let u=new Set(Object.keys(e));return{dom:s,contentDOM:a,update:d=>{if(d.type!==this.type)return!1;s.dataset.checked=d.attrs.checked,l.checked=d.attrs.checked,c(d);const h=r.extensionManager.attributes,f=Ps(d,h),p=new Set(Object.keys(f)),m=this.options.HTMLAttributes;return u.forEach(y=>{p.has(y)||(y in m?s.setAttribute(y,m[y]):s.removeAttribute(y))}),Object.entries(f).forEach(([y,b])=>{b==null?y in m?s.setAttribute(y,m[y]):s.removeAttribute(y):s.setAttribute(y,b)}),u=p,!0}}}},addInputRules(){return[$s({find:z_,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),jw=De.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",fe(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
148
+ `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=i=>{const o=Vd(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,a)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:a}),customNestedParser:r},n);return o?[{type:"taskList",raw:o.raw,items:o.items}]:n.blockTokens(i)},s=Vd(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,o)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:o}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});ce.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Bf.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Rw.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Lw.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Hf.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Pw.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(jw.configure(this.options.taskList)),t}});var xl="&nbsp;",Ju=" ",$w=De.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",fe(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return n.length===1&&n[0].type==="text"&&(n[0].raw===xl||n[0].text===xl||n[0].raw===Ju||n[0].text===Ju)&&r.length===1&&r[0].type==="text"&&(r[0].text===xl||r[0].text===Ju)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{var r,s;if(!t)return"";const i=Array.isArray(t.content)?t.content:[];if(i.length===0){const o=Array.isArray((r=n?.previousNode)==null?void 0:r.content)?n.previousNode.content:[];return((s=n?.previousNode)==null?void 0:s.type)==="paragraph"&&o.length===0?xl:""}return e.renderChildren(i)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),H_=$w,F_=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,U_=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,V_=dn.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",fe(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[qr({find:F_,type:this.type})]},addPasteRules(){return[mr({find:U_,type:this.type})]}}),W_=De.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),q_=dn.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",fe(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!s)return;const i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:n.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function K_(t={}){return new me({view(e){return new J_(e,t)}})}class J_{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let i=o=>{this[s](o)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,s=this.editorView.dom,i=s.getBoundingClientRect(),o=i.width/s.offsetWidth,l=i.height/s.offsetHeight;if(n){let d=e.nodeBefore,h=e.nodeAfter;if(d||h){let f=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(f){let p=f.getBoundingClientRect(),m=d?p.bottom:p.top;d&&h&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:p.left,right:p.right,top:m-y,bottom:m+y}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*o;r={left:d.left-h,right:d.left+h,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),h=d.width/a.offsetWidth,f=d.height/a.offsetHeight;c=d.left-a.scrollLeft*h,u=d.top-a.scrollTop*f}this.element.style.left=(r.left-c)/o+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,i=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!i){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Ub(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class je extends te{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return je.valid(r)?new je(r):te.near(r)}content(){return F.empty}eq(e){return e instanceof je&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new je(e.resolve(n.pos))}getBookmark(){return new Ff(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!G_(e)||!Y_(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&je.valid(e))return e;let s=e.pos,i=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){i=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;s+=n;let a=e.doc.resolve(s);if(je.valid(a))return a}for(;;){let o=n>0?i.firstChild:i.lastChild;if(!o){if(i.isAtom&&!i.isText&&!Y.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=o,s+=n;let l=e.doc.resolve(s);if(je.valid(l))return l}return null}}}je.prototype.visible=!1;je.findFrom=je.findGapCursorFrom;te.jsonID("gapcursor",je);class Ff{constructor(e){this.pos=e}map(e){return new Ff(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return je.valid(n)?new je(n):te.near(n)}}function Bw(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function G_(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||Bw(s.type))return!0;if(s.inlineContent)return!1}}return!0}function Y_(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||Bw(s.type))return!0;if(s.inlineContent)return!1}}return!0}function X_(){return new me({props:{decorations:tO,createSelectionBetween(t,e,n){return e.pos==n.pos&&je.valid(n)?new je(n):null},handleClick:Q_,handleKeyDown:Z_,handleDOMEvents:{beforeinput:eO}}})}const Z_=of({ArrowLeft:wl("horiz",-1),ArrowRight:wl("horiz",1),ArrowUp:wl("vert",-1),ArrowDown:wl("vert",1)});function wl(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof Q){if(!i.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=je.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new je(c))),!0):!1}}function Q_(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!je.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&Y.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new je(r))),!0)}function eO(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof je))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=j.empty;for(let o=r.length-1;o>=0;o--)s=j.from(r[o].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new F(s,0,0));return i.setSelection(Q.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function tO(t){if(!(t.selection instanceof je))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",xe.create(t.doc,[_e.widget(t.selection.head,e,{key:"gapcursor"})])}var Va=200,nt=function(){};nt.prototype.append=function(e){return e.length?(e=nt.from(e),!this.length&&e||e.length<Va&&this.leafAppend(e)||this.length<Va&&e.leafPrepend(this)||this.appendInner(e)):this};nt.prototype.prepend=function(e){return e.length?nt.from(e).append(this):this};nt.prototype.appendInner=function(e){return new nO(this,e)};nt.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?nt.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};nt.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};nt.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};nt.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,o){return s.push(e(i,o))},n,r),s};nt.from=function(e){return e instanceof nt?e:e&&e.length?new zw(e):nt.empty};var zw=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,o,l){for(var a=i;a<o;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,o,l){for(var a=i-1;a>=o;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Va)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Va)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(nt);nt.empty=new zw([]);var nO=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,i,o){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(i,l),o)===!1||i>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,i)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,o){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(i,l)-l,o+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(s,l),i,o)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(nt);const rO=500;class nn{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,h)=>{if(!d.step){s||(s=this.remapping(r,h+1),i=s.maps.length),i--,u.push(d);return}if(s){u.push(new Yn(d.map));let f=d.step.map(s.slice(i)),p;f&&o.maybeStep(f).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Yn(p,void 0,void 0,c.length+u.length))),i--,p&&s.appendMap(p,i)}else o.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(i)):d.selection,a=new nn(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,n,r,s){let i=[],o=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),h=new Yn(e.mapping.maps[u],d,n),f;(f=a&&a.merge(h))&&(h=f,u?i.pop():l=l.slice(0,l.length-1)),i.push(h),n&&(o++,n=void 0),s||(a=h)}let c=o-r.depth;return c>iO&&(l=sO(l,c),o-=c),new nn(l.append(i),o)}remapping(e,n){let r=new ro;return this.items.forEach((s,i)=>{let o=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new nn(this.items.append(e.map(n=>new Yn(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},s);let a=n;this.items.forEach(h=>{let f=i.getMirror(--a);if(f==null)return;o=Math.min(o,f);let p=i.maps[f];if(h.step){let m=e.steps[f].invert(e.docs[f]),y=h.selection&&h.selection.map(i.slice(a+1,f));y&&l++,r.push(new Yn(p,m,y))}else r.push(new Yn(p))},s);let c=[];for(let h=n;h<o;h++)c.push(new Yn(i.maps[h]));let u=this.items.slice(0,s).append(c).append(r),d=new nn(u,l);return d.emptyItemCount()>rO&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],i=0;return this.items.forEach((o,l)=>{if(l>=e)s.push(o),o.selection&&i++;else if(o.step){let a=o.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=o.selection&&o.selection.map(n.slice(r));u&&i++;let d=new Yn(c.invert(),a,u),h,f=s.length-1;(h=s.length&&s[f].merge(d))?s[f]=h:s.push(d)}}else o.map&&r--},this.items.length,0),new nn(nt.from(s.reverse()),i)}}nn.empty=new nn(nt.empty,0);function sO(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}let Yn=class Hw{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Hw(n.getMap().invert(),n,this.selection)}}};class rr{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const iO=20;function oO(t,e,n,r){let s=n.getMeta(Br),i;if(s)return s.historyState;n.getMeta(cO)&&(t=new rr(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Br))return o.getMeta(Br).redo?new rr(t.done.addTransform(n,void 0,r,Fl(e)),t.undone,Bg(n.mapping.maps),t.prevTime,t.prevComposition):new rr(t.done,t.undone.addTransform(n,void 0,r,Fl(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!lO(n,t.prevRanges)),c=o?Gu(t.prevRanges,n.mapping):Bg(n.mapping.maps);return new rr(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,Fl(e)),nn.empty,c,n.time,l??t.prevComposition)}else return(i=n.getMeta("rebased"))?new rr(t.done.rebased(n,i),t.undone.rebased(n,i),Gu(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new rr(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Gu(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function lO(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function Bg(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,o)=>e.push(i,o));return e}function Gu(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function aO(t,e,n){let r=Fl(e),s=Br.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let o=i.selection.resolve(i.transform.doc),l=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),a=new rr(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(o).setMeta(Br,{redo:n,historyState:a})}let Yu=!1,zg=null;function Fl(t){let e=t.plugins;if(zg!=e){Yu=!1,zg=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Yu=!0;break}}return Yu}const Br=new ge("history"),cO=new ge("closeHistory");function uO(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new me({key:Br,state:{init(){return new rr(nn.empty,nn.empty,null,0,-1)},apply(e,n,r){return oO(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?Uw:r=="historyRedo"?Vw:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function Fw(t,e){return(n,r)=>{let s=Br.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=aO(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const Uw=Fw(!1,!0),Vw=Fw(!0,!0);var dO=ce.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=t?.node||this.editor.state.doc;if((t?.mode||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=t?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new me({key:new ge("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit,i=this.options.autoTrim;if(s==null||s===0||i===!1){t=!0;return}const o=this.storage.characters({node:r.doc});if(o>s){const l=o-s,a=0,c=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const u=r.tr.deleteRange(a,c);return t=!0,u}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:n.doc}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=i-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}}),hO=ce.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[K_(this.options)]}});ce.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new me({key:new ge("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return xe.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";i.push(_e.node(c,c+a.nodeSize,{class:this.options.className}))}),xe.create(t,i)}}})]}});var Ww=ce.create({name:"gapCursor",addProseMirrorPlugins(){return[X_()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=we(J(t,"allowGapCursor",n)))!=null?e:null}}}),qw="placeholder",po=new ge("tiptap__placeholder"),Hg=200;function Fg(t){const{editor:e,placeholder:n,dataAttribute:r,pos:s,node:i,isEmptyDoc:o,hasAnchor:l,classes:{emptyNode:a,emptyEditor:c}}=t,u=[a];return o&&u.push(c),_e.node(s,s+i.nodeSize,{class:u.join(" "),[r]:typeof n=="function"?n({editor:e,node:i,pos:s,hasAnchor:l}):n})}function Ug(t,e){return typeof t=="function"?t(e):t}function fO({editor:t,options:e,dataAttribute:n,doc:r,selection:s}){var i,o;if(!(t.isEditable||!e.showOnlyWhenEditable))return null;const{anchor:a}=s,c=[],u=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){const h=r.resolve(a),f=h.depth>0?h.node(1):h.nodeAfter,p=h.depth>0?h.before(1):a;if(f&&f.type.isTextblock&&js(f)){const m=a>=p&&a<=p+f.nodeSize;c.push(Fg({editor:t,isEmptyDoc:u,dataAttribute:n,hasAnchor:m,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Ug(e.emptyNodeClass,{editor:t,node:f,pos:p,hasAnchor:m})},node:f,pos:p}))}}else{const h=po.getState(t.state),f=(i=h?.topPos)!=null?i:0,p=(o=h?.bottomPos)!=null?o:r.content.size;r.nodesBetween(f,p,(m,y)=>{const b=a>=y&&a<=y+m.nodeSize,x=!m.isLeaf&&js(m);return m.type.isTextblock&&(b||!e.showOnlyCurrent)&&x&&c.push(Fg({editor:t,isEmptyDoc:u,dataAttribute:n,hasAnchor:b,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Ug(e.emptyNodeClass,{editor:t,node:m,pos:y,hasAnchor:b})},node:m,pos:y})),e.includeChildren})}return xe.create(r,c)}function pO(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function mO(t){const e=getComputedStyle(t),n=`${e.overflow} ${e.overflowY} ${e.overflowX}`;return/auto|scroll|overlay/.test(n)}function gO(t){let e=t;for(;e;){if(mO(e))return e;const n=e.parentElement;if(!n){const r=e.getRootNode();if(r instanceof ShadowRoot){e=r.host;continue}return window}e=n}return window}function yO(t){return t===window?{top:0,bottom:window.innerHeight}:t.getBoundingClientRect()}function bO({doc:t,view:e,scrollContainer:n}){const r=e.dom.getBoundingClientRect(),s=n?yO(n):{top:0,bottom:window.innerHeight},i=Math.max(r.top,s.top)-Hg,o=Math.min(r.bottom,s.bottom)+Hg;if(i>=o)return{top:0,bottom:t.content.size};const a=getComputedStyle(e.dom).direction==="rtl"?Math.max(r.right-2,r.left+2):r.left+2,c=e.posAtCoords({left:a,top:i+2}),u=e.posAtCoords({left:a,top:o-2});return{top:c?c.pos:0,bottom:u?u.pos:t.content.size}}var xO={init(){return{topPos:null,bottomPos:null}},apply(t,e){const n=t.getMeta(po);return n?.positions?{topPos:n.positions.top,bottomPos:n.positions.bottom}:t.docChanged?{topPos:e.topPos!==null?t.mapping.map(e.topPos):null,bottomPos:e.bottomPos!==null?t.mapping.map(e.bottomPos):null}:e}};function wO(t){const e=gO(t.dom),n=()=>{const l=bO({view:t,doc:t.state.doc,scrollContainer:e}),a=po.getState(t.state);if(a?.topPos===l.top&&a?.bottomPos===l.bottom)return;const c=t.state.tr.setMeta(po,{positions:l});t.dispatch(c)};let r=null,s=0;const i=150,o=()=>{r===null&&(r=requestAnimationFrame(()=>{r=null;const l=performance.now();l-s>=i?(s=l,n()):o()}))};return e.addEventListener("scroll",o,{passive:!0}),n(),{update(l,a){t.state.doc.content.size!==a.doc.content.size&&o()},destroy:()=>{r!==null&&cancelAnimationFrame(r),e.removeEventListener("scroll",o)}}}function kO({editor:t,options:e}){const n=e.dataAttribute?`data-${pO(e.dataAttribute)}`:`data-${qw}`;return new me({key:po,state:xO,view:wO,props:{decorations:({doc:r,selection:s})=>fO({editor:t,options:e,dataAttribute:n,doc:r,selection:s})}})}var vO=ce.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:qw,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[kO({editor:this.editor,options:this.options})]}}),SO=`.ProseMirror:not(.ProseMirror-focused) *::selection {
149
+ background: transparent;
150
+ }
151
+
152
+ .ProseMirror:not(.ProseMirror-focused) *::-moz-selection {
153
+ background: transparent;
154
+ }`;ce.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return t.options.injectCSS&&typeof document<"u"&&Mx(SO,t.options.injectNonce,"selection"),[new me({key:new ge("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||ux(n.selection)||t.view.dragging?null:xe.create(n.doc,[_e.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});var CO="skipTrailingNode";function Vg({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var EO=ce.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new ge(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new me({key:e,appendTransaction:(s,i,o)=>{const{doc:l,tr:a,schema:c}=o,u=e.getState(o),d=l.content.size,h=c.nodes[n];if(!s.some(f=>f.getMeta(CO))&&u)return a.insert(d,h.create())},state:{init:(s,i)=>{const o=i.tr.doc.lastChild;return!Vg({node:o,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const o=s.doc.lastChild;return!Vg({node:o,types:r})}}})]}}),Kw=ce.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Uw(t,e),redo:()=>({state:t,dispatch:e})=>Vw(t,e)}},addProseMirrorPlugins(){return[uO(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),AO=ce.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(IR.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(gw.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(Bf.configure(this.options.bulletList)),this.options.code!==!1&&s.push($R.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(yw.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(HR.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(hO.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(Ww.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(FR.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(bw.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(Kw.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(VR.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(GR.configure(this.options.italic)),this.options.listItem!==!1&&s.push(Rw.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(Lw.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(Tw.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(Hf.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push($w.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(V_.configure(this.options.strike)),this.options.text!==!1&&s.push(W_.configure(this.options.text)),this.options.underline!==!1&&s.push(q_.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(EO.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),MO=AO,Xu,Wg;function TO(){if(Wg)return Xu;Wg=1;function t(M){return M instanceof Map?M.clear=M.delete=M.set=function(){throw new Error("map is read-only")}:M instanceof Set&&(M.add=M.clear=M.delete=function(){throw new Error("set is read-only")}),Object.freeze(M),Object.getOwnPropertyNames(M).forEach(O=>{const H=M[O],ie=typeof H;(ie==="object"||ie==="function")&&!Object.isFrozen(H)&&t(H)}),M}class e{constructor(O){O.data===void 0&&(O.data={}),this.data=O.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(M){return M.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(M,...O){const H=Object.create(null);for(const ie in M)H[ie]=M[ie];return O.forEach(function(ie){for(const ze in ie)H[ze]=ie[ze]}),H}const s="</span>",i=M=>!!M.scope,o=(M,{prefix:O})=>{if(M.startsWith("language:"))return M.replace("language:","language-");if(M.includes(".")){const H=M.split(".");return[`${O}${H.shift()}`,...H.map((ie,ze)=>`${ie}${"_".repeat(ze+1)}`)].join(" ")}return`${O}${M}`};class l{constructor(O,H){this.buffer="",this.classPrefix=H.classPrefix,O.walk(this)}addText(O){this.buffer+=n(O)}openNode(O){if(!i(O))return;const H=o(O.scope,{prefix:this.classPrefix});this.span(H)}closeNode(O){i(O)&&(this.buffer+=s)}value(){return this.buffer}span(O){this.buffer+=`<span class="${O}">`}}const a=(M={})=>{const O={children:[]};return Object.assign(O,M),O};class c{constructor(){this.rootNode=a(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(O){this.top.children.push(O)}openNode(O){const H=a({scope:O});this.add(H),this.stack.push(H)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(O){return this.constructor._walk(O,this.rootNode)}static _walk(O,H){return typeof H=="string"?O.addText(H):H.children&&(O.openNode(H),H.children.forEach(ie=>this._walk(O,ie)),O.closeNode(H)),O}static _collapse(O){typeof O!="string"&&O.children&&(O.children.every(H=>typeof H=="string")?O.children=[O.children.join("")]:O.children.forEach(H=>{c._collapse(H)}))}}class u extends c{constructor(O){super(),this.options=O}addText(O){O!==""&&this.add(O)}startScope(O){this.openNode(O)}endScope(){this.closeNode()}__addSublanguage(O,H){const ie=O.root;H&&(ie.scope=`language:${H}`),this.add(ie)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function d(M){return M?typeof M=="string"?M:M.source:null}function h(M){return m("(?=",M,")")}function f(M){return m("(?:",M,")*")}function p(M){return m("(?:",M,")?")}function m(...M){return M.map(H=>d(H)).join("")}function y(M){const O=M[M.length-1];return typeof O=="object"&&O.constructor===Object?(M.splice(M.length-1,1),O):{}}function b(...M){return"("+(y(M).capture?"":"?:")+M.map(ie=>d(ie)).join("|")+")"}function x(M){return new RegExp(M.toString()+"|").exec("").length-1}function w(M,O){const H=M&&M.exec(O);return H&&H.index===0}const k=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function T(M,{joinWith:O}){let H=0;return M.map(ie=>{H+=1;const ze=H;let He=d(ie),K="";for(;He.length>0;){const W=k.exec(He);if(!W){K+=He;break}K+=He.substring(0,W.index),He=He.substring(W.index+W[0].length),W[0][0]==="\\"&&W[1]?K+="\\"+String(Number(W[1])+ze):(K+=W[0],W[0]==="("&&H++)}return K}).map(ie=>`(${ie})`).join(O)}const S=/\b\B/,v="[a-zA-Z]\\w*",A="[a-zA-Z_]\\w*",C="\\b\\d+(\\.\\d+)?",N="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",D="\\b(0b[01]+)",z="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",L=(M={})=>{const O=/^#![ ]*\//;return M.binary&&(M.begin=m(O,/.*\b/,M.binary,/\b.*/)),r({scope:"meta",begin:O,end:/$/,relevance:0,"on:begin":(H,ie)=>{H.index!==0&&ie.ignoreMatch()}},M)},_={begin:"\\\\[\\s\\S]",relevance:0},V={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[_]},ee={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[_]},be={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},I=function(M,O,H={}){const ie=r({scope:"comment",begin:M,end:O,contains:[]},H);ie.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const ze=b("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return ie.contains.push({begin:m(/[ ]+/,"(",ze,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),ie},P=I("//","$"),ne=I("/\\*","\\*/"),R=I("#","$"),q={scope:"number",begin:C,relevance:0},le={scope:"number",begin:N,relevance:0},Se={scope:"number",begin:D,relevance:0},Ot={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[_,{begin:/\[/,end:/\]/,relevance:0,contains:[_]}]},Ye={scope:"title",begin:v,relevance:0},Ce={scope:"title",begin:A,relevance:0},Ze={begin:"\\.\\s*"+A,relevance:0};var Dt=Object.freeze({__proto__:null,APOS_STRING_MODE:V,BACKSLASH_ESCAPE:_,BINARY_NUMBER_MODE:Se,BINARY_NUMBER_RE:D,COMMENT:I,C_BLOCK_COMMENT_MODE:ne,C_LINE_COMMENT_MODE:P,C_NUMBER_MODE:le,C_NUMBER_RE:N,END_SAME_AS_BEGIN:function(M){return Object.assign(M,{"on:begin":(O,H)=>{H.data._beginMatch=O[1]},"on:end":(O,H)=>{H.data._beginMatch!==O[1]&&H.ignoreMatch()}})},HASH_COMMENT_MODE:R,IDENT_RE:v,MATCH_NOTHING_RE:S,METHOD_GUARD:Ze,NUMBER_MODE:q,NUMBER_RE:C,PHRASAL_WORDS_MODE:be,QUOTE_STRING_MODE:ee,REGEXP_MODE:Ot,RE_STARTERS_RE:z,SHEBANG:L,TITLE_MODE:Ye,UNDERSCORE_IDENT_RE:A,UNDERSCORE_TITLE_MODE:Ce});function as(M,O){M.input[M.index-1]==="."&&O.ignoreMatch()}function ou(M,O){M.className!==void 0&&(M.scope=M.className,delete M.className)}function _v(M,O){O&&M.beginKeywords&&(M.begin="\\b("+M.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",M.__beforeBegin=as,M.keywords=M.keywords||M.beginKeywords,delete M.beginKeywords,M.relevance===void 0&&(M.relevance=0))}function Ov(M,O){Array.isArray(M.illegal)&&(M.illegal=b(...M.illegal))}function Dv(M,O){if(M.match){if(M.begin||M.end)throw new Error("begin & end are not supported with match");M.begin=M.match,delete M.match}}function Lv(M,O){M.relevance===void 0&&(M.relevance=1)}const Iv=(M,O)=>{if(!M.beforeMatch)return;if(M.starts)throw new Error("beforeMatch cannot be used with starts");const H=Object.assign({},M);Object.keys(M).forEach(ie=>{delete M[ie]}),M.keywords=H.keywords,M.begin=m(H.beforeMatch,h(H.begin)),M.starts={relevance:0,contains:[Object.assign(H,{endsParent:!0})]},M.relevance=0,delete H.beforeMatch},Pv=["of","and","for","in","not","or","if","then","parent","list","value"],jv="keyword";function Mp(M,O,H=jv){const ie=Object.create(null);return typeof M=="string"?ze(H,M.split(" ")):Array.isArray(M)?ze(H,M):Object.keys(M).forEach(function(He){Object.assign(ie,Mp(M[He],O,He))}),ie;function ze(He,K){O&&(K=K.map(W=>W.toLowerCase())),K.forEach(function(W){const re=W.split("|");ie[re[0]]=[He,$v(re[0],re[1])]})}}function $v(M,O){return O?Number(O):Bv(M)?0:1}function Bv(M){return Pv.includes(M.toLowerCase())}const Tp={},Cr=M=>{console.error(M)},Np=(M,...O)=>{console.log(`WARN: ${M}`,...O)},cs=(M,O)=>{Tp[`${M}/${O}`]||(console.log(`Deprecated as of ${M}. ${O}`),Tp[`${M}/${O}`]=!0)},Go=new Error;function Rp(M,O,{key:H}){let ie=0;const ze=M[H],He={},K={};for(let W=1;W<=O.length;W++)K[W+ie]=ze[W],He[W+ie]=!0,ie+=x(O[W-1]);M[H]=K,M[H]._emit=He,M[H]._multi=!0}function zv(M){if(Array.isArray(M.begin)){if(M.skip||M.excludeBegin||M.returnBegin)throw Cr("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Go;if(typeof M.beginScope!="object"||M.beginScope===null)throw Cr("beginScope must be object"),Go;Rp(M,M.begin,{key:"beginScope"}),M.begin=T(M.begin,{joinWith:""})}}function Hv(M){if(Array.isArray(M.end)){if(M.skip||M.excludeEnd||M.returnEnd)throw Cr("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Go;if(typeof M.endScope!="object"||M.endScope===null)throw Cr("endScope must be object"),Go;Rp(M,M.end,{key:"endScope"}),M.end=T(M.end,{joinWith:""})}}function Fv(M){M.scope&&typeof M.scope=="object"&&M.scope!==null&&(M.beginScope=M.scope,delete M.scope)}function Uv(M){Fv(M),typeof M.beginScope=="string"&&(M.beginScope={_wrap:M.beginScope}),typeof M.endScope=="string"&&(M.endScope={_wrap:M.endScope}),zv(M),Hv(M)}function Vv(M){function O(K,W){return new RegExp(d(K),"m"+(M.case_insensitive?"i":"")+(M.unicodeRegex?"u":"")+(W?"g":""))}class H{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(W,re){re.position=this.position++,this.matchIndexes[this.matchAt]=re,this.regexes.push([re,W]),this.matchAt+=x(W)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const W=this.regexes.map(re=>re[1]);this.matcherRe=O(T(W,{joinWith:"|"}),!0),this.lastIndex=0}exec(W){this.matcherRe.lastIndex=this.lastIndex;const re=this.matcherRe.exec(W);if(!re)return null;const Qe=re.findIndex((ci,au)=>au>0&&ci!==void 0),Ve=this.matchIndexes[Qe];return re.splice(0,Qe),Object.assign(re,Ve)}}class ie{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(W){if(this.multiRegexes[W])return this.multiRegexes[W];const re=new H;return this.rules.slice(W).forEach(([Qe,Ve])=>re.addRule(Qe,Ve)),re.compile(),this.multiRegexes[W]=re,re}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(W,re){this.rules.push([W,re]),re.type==="begin"&&this.count++}exec(W){const re=this.getMatcher(this.regexIndex);re.lastIndex=this.lastIndex;let Qe=re.exec(W);if(this.resumingScanAtSamePosition()&&!(Qe&&Qe.index===this.lastIndex)){const Ve=this.getMatcher(0);Ve.lastIndex=this.lastIndex+1,Qe=Ve.exec(W)}return Qe&&(this.regexIndex+=Qe.position+1,this.regexIndex===this.count&&this.considerAll()),Qe}}function ze(K){const W=new ie;return K.contains.forEach(re=>W.addRule(re.begin,{rule:re,type:"begin"})),K.terminatorEnd&&W.addRule(K.terminatorEnd,{type:"end"}),K.illegal&&W.addRule(K.illegal,{type:"illegal"}),W}function He(K,W){const re=K;if(K.isCompiled)return re;[ou,Dv,Uv,Iv].forEach(Ve=>Ve(K,W)),M.compilerExtensions.forEach(Ve=>Ve(K,W)),K.__beforeBegin=null,[_v,Ov,Lv].forEach(Ve=>Ve(K,W)),K.isCompiled=!0;let Qe=null;return typeof K.keywords=="object"&&K.keywords.$pattern&&(K.keywords=Object.assign({},K.keywords),Qe=K.keywords.$pattern,delete K.keywords.$pattern),Qe=Qe||/\w+/,K.keywords&&(K.keywords=Mp(K.keywords,M.case_insensitive)),re.keywordPatternRe=O(Qe,!0),W&&(K.begin||(K.begin=/\B|\b/),re.beginRe=O(re.begin),!K.end&&!K.endsWithParent&&(K.end=/\B|\b/),K.end&&(re.endRe=O(re.end)),re.terminatorEnd=d(re.end)||"",K.endsWithParent&&W.terminatorEnd&&(re.terminatorEnd+=(K.end?"|":"")+W.terminatorEnd)),K.illegal&&(re.illegalRe=O(K.illegal)),K.contains||(K.contains=[]),K.contains=[].concat(...K.contains.map(function(Ve){return Wv(Ve==="self"?K:Ve)})),K.contains.forEach(function(Ve){He(Ve,re)}),K.starts&&He(K.starts,W),re.matcher=ze(re),re}if(M.compilerExtensions||(M.compilerExtensions=[]),M.contains&&M.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return M.classNameAliases=r(M.classNameAliases||{}),He(M)}function _p(M){return M?M.endsWithParent||_p(M.starts):!1}function Wv(M){return M.variants&&!M.cachedVariants&&(M.cachedVariants=M.variants.map(function(O){return r(M,{variants:null},O)})),M.cachedVariants?M.cachedVariants:_p(M)?r(M,{starts:M.starts?r(M.starts):null}):Object.isFrozen(M)?r(M):M}var qv="11.11.1";class Kv extends Error{constructor(O,H){super(O),this.name="HTMLInjectionError",this.html=H}}const lu=n,Op=r,Dp=Symbol("nomatch"),Jv=7,Lp=function(M){const O=Object.create(null),H=Object.create(null),ie=[];let ze=!0;const He="Could not find the language '{}', did you forget to load/include a language module?",K={disableAutodetect:!0,name:"Plain text",contains:[]};let W={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:u};function re(B){return W.noHighlightRe.test(B)}function Qe(B){let Z=B.className+" ";Z+=B.parentNode?B.parentNode.className:"";const pe=W.languageDetectRe.exec(Z);if(pe){const Me=Kn(pe[1]);return Me||(Np(He.replace("{}",pe[1])),Np("Falling back to no-highlight mode for this block.",B)),Me?pe[1]:"no-highlight"}return Z.split(/\s+/).find(Me=>re(Me)||Kn(Me))}function Ve(B,Z,pe){let Me="",Xe="";typeof Z=="object"?(Me=B,pe=Z.ignoreIllegals,Xe=Z.language):(cs("10.7.0","highlight(lang, code, ...args) has been deprecated."),cs("10.7.0",`Please use highlight(code, options) instead.
155
+ https://github.com/highlightjs/highlight.js/issues/2277`),Xe=B,Me=Z),pe===void 0&&(pe=!0);const en={code:Me,language:Xe};Xo("before:highlight",en);const Jn=en.result?en.result:ci(en.language,en.code,pe);return Jn.code=en.code,Xo("after:highlight",Jn),Jn}function ci(B,Z,pe,Me){const Xe=Object.create(null);function en(U,G){return U.keywords[G]}function Jn(){if(!oe.keywords){it.addText(Te);return}let U=0;oe.keywordPatternRe.lastIndex=0;let G=oe.keywordPatternRe.exec(Te),ue="";for(;G;){ue+=Te.substring(U,G.index);const ke=mn.case_insensitive?G[0].toLowerCase():G[0],dt=en(oe,ke);if(dt){const[Mn,dS]=dt;if(it.addText(ue),ue="",Xe[ke]=(Xe[ke]||0)+1,Xe[ke]<=Jv&&(el+=dS),Mn.startsWith("_"))ue+=G[0];else{const hS=mn.classNameAliases[Mn]||Mn;pn(G[0],hS)}}else ue+=G[0];U=oe.keywordPatternRe.lastIndex,G=oe.keywordPatternRe.exec(Te)}ue+=Te.substring(U),it.addText(ue)}function Zo(){if(Te==="")return;let U=null;if(typeof oe.subLanguage=="string"){if(!O[oe.subLanguage]){it.addText(Te);return}U=ci(oe.subLanguage,Te,!0,Fp[oe.subLanguage]),Fp[oe.subLanguage]=U._top}else U=cu(Te,oe.subLanguage.length?oe.subLanguage:null);oe.relevance>0&&(el+=U.relevance),it.__addSublanguage(U._emitter,U.language)}function $t(){oe.subLanguage!=null?Zo():Jn(),Te=""}function pn(U,G){U!==""&&(it.startScope(G),it.addText(U),it.endScope())}function $p(U,G){let ue=1;const ke=G.length-1;for(;ue<=ke;){if(!U._emit[ue]){ue++;continue}const dt=mn.classNameAliases[U[ue]]||U[ue],Mn=G[ue];dt?pn(Mn,dt):(Te=Mn,Jn(),Te=""),ue++}}function Bp(U,G){return U.scope&&typeof U.scope=="string"&&it.openNode(mn.classNameAliases[U.scope]||U.scope),U.beginScope&&(U.beginScope._wrap?(pn(Te,mn.classNameAliases[U.beginScope._wrap]||U.beginScope._wrap),Te=""):U.beginScope._multi&&($p(U.beginScope,G),Te="")),oe=Object.create(U,{parent:{value:oe}}),oe}function zp(U,G,ue){let ke=w(U.endRe,ue);if(ke){if(U["on:end"]){const dt=new e(U);U["on:end"](G,dt),dt.isMatchIgnored&&(ke=!1)}if(ke){for(;U.endsParent&&U.parent;)U=U.parent;return U}}if(U.endsWithParent)return zp(U.parent,G,ue)}function oS(U){return oe.matcher.regexIndex===0?(Te+=U[0],1):(fu=!0,0)}function lS(U){const G=U[0],ue=U.rule,ke=new e(ue),dt=[ue.__beforeBegin,ue["on:begin"]];for(const Mn of dt)if(Mn&&(Mn(U,ke),ke.isMatchIgnored))return oS(G);return ue.skip?Te+=G:(ue.excludeBegin&&(Te+=G),$t(),!ue.returnBegin&&!ue.excludeBegin&&(Te=G)),Bp(ue,U),ue.returnBegin?0:G.length}function aS(U){const G=U[0],ue=Z.substring(U.index),ke=zp(oe,U,ue);if(!ke)return Dp;const dt=oe;oe.endScope&&oe.endScope._wrap?($t(),pn(G,oe.endScope._wrap)):oe.endScope&&oe.endScope._multi?($t(),$p(oe.endScope,U)):dt.skip?Te+=G:(dt.returnEnd||dt.excludeEnd||(Te+=G),$t(),dt.excludeEnd&&(Te=G));do oe.scope&&it.closeNode(),!oe.skip&&!oe.subLanguage&&(el+=oe.relevance),oe=oe.parent;while(oe!==ke.parent);return ke.starts&&Bp(ke.starts,U),dt.returnEnd?0:G.length}function cS(){const U=[];for(let G=oe;G!==mn;G=G.parent)G.scope&&U.unshift(G.scope);U.forEach(G=>it.openNode(G))}let Qo={};function Hp(U,G){const ue=G&&G[0];if(Te+=U,ue==null)return $t(),0;if(Qo.type==="begin"&&G.type==="end"&&Qo.index===G.index&&ue===""){if(Te+=Z.slice(G.index,G.index+1),!ze){const ke=new Error(`0 width match regex (${B})`);throw ke.languageName=B,ke.badRule=Qo.rule,ke}return 1}if(Qo=G,G.type==="begin")return lS(G);if(G.type==="illegal"&&!pe){const ke=new Error('Illegal lexeme "'+ue+'" for mode "'+(oe.scope||"<unnamed>")+'"');throw ke.mode=oe,ke}else if(G.type==="end"){const ke=aS(G);if(ke!==Dp)return ke}if(G.type==="illegal"&&ue==="")return Te+=`
156
+ `,1;if(hu>1e5&&hu>G.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Te+=ue,ue.length}const mn=Kn(B);if(!mn)throw Cr(He.replace("{}",B)),new Error('Unknown language: "'+B+'"');const uS=Vv(mn);let du="",oe=Me||uS;const Fp={},it=new W.__emitter(W);cS();let Te="",el=0,Er=0,hu=0,fu=!1;try{if(mn.__emitTokens)mn.__emitTokens(Z,it);else{for(oe.matcher.considerAll();;){hu++,fu?fu=!1:oe.matcher.considerAll(),oe.matcher.lastIndex=Er;const U=oe.matcher.exec(Z);if(!U)break;const G=Z.substring(Er,U.index),ue=Hp(G,U);Er=U.index+ue}Hp(Z.substring(Er))}return it.finalize(),du=it.toHTML(),{language:B,value:du,relevance:el,illegal:!1,_emitter:it,_top:oe}}catch(U){if(U.message&&U.message.includes("Illegal"))return{language:B,value:lu(Z),illegal:!0,relevance:0,_illegalBy:{message:U.message,index:Er,context:Z.slice(Er-100,Er+100),mode:U.mode,resultSoFar:du},_emitter:it};if(ze)return{language:B,value:lu(Z),illegal:!1,relevance:0,errorRaised:U,_emitter:it,_top:oe};throw U}}function au(B){const Z={value:lu(B),illegal:!1,relevance:0,_top:K,_emitter:new W.__emitter(W)};return Z._emitter.addText(B),Z}function cu(B,Z){Z=Z||W.languages||Object.keys(O);const pe=au(B),Me=Z.filter(Kn).filter(jp).map($t=>ci($t,B,!1));Me.unshift(pe);const Xe=Me.sort(($t,pn)=>{if($t.relevance!==pn.relevance)return pn.relevance-$t.relevance;if($t.language&&pn.language){if(Kn($t.language).supersetOf===pn.language)return 1;if(Kn(pn.language).supersetOf===$t.language)return-1}return 0}),[en,Jn]=Xe,Zo=en;return Zo.secondBest=Jn,Zo}function Gv(B,Z,pe){const Me=Z&&H[Z]||pe;B.classList.add("hljs"),B.classList.add(`language-${Me}`)}function uu(B){let Z=null;const pe=Qe(B);if(re(pe))return;if(Xo("before:highlightElement",{el:B,language:pe}),B.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",B);return}if(B.children.length>0&&(W.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(B)),W.throwUnescapedHTML))throw new Kv("One of your code blocks includes unescaped HTML.",B.innerHTML);Z=B;const Me=Z.textContent,Xe=pe?Ve(Me,{language:pe,ignoreIllegals:!0}):cu(Me);B.innerHTML=Xe.value,B.dataset.highlighted="yes",Gv(B,pe,Xe.language),B.result={language:Xe.language,re:Xe.relevance,relevance:Xe.relevance},Xe.secondBest&&(B.secondBest={language:Xe.secondBest.language,relevance:Xe.secondBest.relevance}),Xo("after:highlightElement",{el:B,result:Xe,text:Me})}function Yv(B){W=Op(W,B)}const Xv=()=>{Yo(),cs("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Zv(){Yo(),cs("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Ip=!1;function Yo(){function B(){Yo()}if(document.readyState==="loading"){Ip||window.addEventListener("DOMContentLoaded",B,!1),Ip=!0;return}document.querySelectorAll(W.cssSelector).forEach(uu)}function Qv(B,Z){let pe=null;try{pe=Z(M)}catch(Me){if(Cr("Language definition for '{}' could not be registered.".replace("{}",B)),ze)Cr(Me);else throw Me;pe=K}pe.name||(pe.name=B),O[B]=pe,pe.rawDefinition=Z.bind(null,M),pe.aliases&&Pp(pe.aliases,{languageName:B})}function eS(B){delete O[B];for(const Z of Object.keys(H))H[Z]===B&&delete H[Z]}function tS(){return Object.keys(O)}function Kn(B){return B=(B||"").toLowerCase(),O[B]||O[H[B]]}function Pp(B,{languageName:Z}){typeof B=="string"&&(B=[B]),B.forEach(pe=>{H[pe.toLowerCase()]=Z})}function jp(B){const Z=Kn(B);return Z&&!Z.disableAutodetect}function nS(B){B["before:highlightBlock"]&&!B["before:highlightElement"]&&(B["before:highlightElement"]=Z=>{B["before:highlightBlock"](Object.assign({block:Z.el},Z))}),B["after:highlightBlock"]&&!B["after:highlightElement"]&&(B["after:highlightElement"]=Z=>{B["after:highlightBlock"](Object.assign({block:Z.el},Z))})}function rS(B){nS(B),ie.push(B)}function sS(B){const Z=ie.indexOf(B);Z!==-1&&ie.splice(Z,1)}function Xo(B,Z){const pe=B;ie.forEach(function(Me){Me[pe]&&Me[pe](Z)})}function iS(B){return cs("10.7.0","highlightBlock will be removed entirely in v12.0"),cs("10.7.0","Please use highlightElement now."),uu(B)}Object.assign(M,{highlight:Ve,highlightAuto:cu,highlightAll:Yo,highlightElement:uu,highlightBlock:iS,configure:Yv,initHighlighting:Xv,initHighlightingOnLoad:Zv,registerLanguage:Qv,unregisterLanguage:eS,listLanguages:tS,getLanguage:Kn,registerAliases:Pp,autoDetection:jp,inherit:Op,addPlugin:rS,removePlugin:sS}),M.debugMode=function(){ze=!1},M.safeMode=function(){ze=!0},M.versionString=qv,M.regex={concat:m,lookahead:h,either:b,optional:p,anyNumberOfTimes:f};for(const B in Dt)typeof Dt[B]=="object"&&t(Dt[B]);return Object.assign(M,Dt),M},us=Lp({});return us.newInstance=()=>Lp({}),Xu=us,us.HighlightJS=us,us.default=us,Xu}var NO=TO();const Jw=mS(NO);function Gw(t,e=[]){return t.flatMap(n=>{const r=[...e,...n.properties?n.properties.className:[]];return n.children?Gw(n.children,r):{text:n.value,classes:r}})}function qg(t){return t.value||t.children||[]}function RO(t){return!!Jw.getLanguage(t)}function Kg({doc:t,name:e,lowlight:n,defaultLanguage:r}){const s=[];return Hd(t,i=>i.type.name===e).forEach(i=>{var o;let l=i.pos+1;const a=i.node.attrs.language||r,c=n.listLanguages(),u=a&&(c.includes(a)||RO(a)||(o=n.registered)!=null&&o.call(n,a))?qg(n.highlight(a,i.node.textContent)):qg(n.highlightAuto(i.node.textContent));Gw(u).forEach(d=>{const h=l+d.text.length;if(d.classes.length){const f=_e.inline(l,h,{class:d.classes.join(" ")});s.push(f)}l=h})}),xe.create(t,s)}function _O(t){return typeof t=="function"}function OO({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(s=>_O(e[s])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new me({key:new ge("lowlight"),state:{init:(s,{doc:i})=>Kg({doc:i,name:t,lowlight:e,defaultLanguage:n}),apply:(s,i,o,l)=>{const a=o.selection.$head.parent.type.name,c=l.selection.$head.parent.type.name,u=Hd(o.doc,h=>h.type.name===t),d=Hd(l.doc,h=>h.type.name===t);return s.docChanged&&([a,c].includes(t)||d.length!==u.length||s.steps.some(h=>h.from!==void 0&&h.to!==void 0&&u.some(f=>f.pos>=h.from&&f.pos+f.node.nodeSize<=h.to)))?Kg({doc:s.doc,name:t,lowlight:e,defaultLanguage:n}):i.map(s.mapping,s.doc)}},props:{decorations(s){return r.getState(s)}}});return r}var DO=yw.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],OO({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),Yw=DO,LO=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,IO=De.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",fe(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,s,i,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",a=(s=(r=t.attrs)==null?void 0:r.alt)!=null?s:"",c=(o=(i=t.attrs)==null?void 0:i.title)!=null?o:"";return c?`![${a}](${l} "${c}")`:`![${a}](${l})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:s,getPos:i,HTMLAttributes:o,editor:l})=>{const a=document.createElement("img");a.draggable=!1;const c=fe(this.options.HTMLAttributes,o);Object.entries(c).forEach(([h,f])=>{if(f!=null)switch(h){case"width":case"height":break;default:a.setAttribute(h,f);break}}),c.src!==null&&(a.src=c.src);const u=new wT({element:a,editor:l,node:s,getPos:i,onResize:(h,f)=>{a.style.width=`${h}px`,a.style.height=`${f}px`},onCommit:(h,f)=>{const p=i();p!==void 0&&this.editor.chain().setNodeSelection(p).updateAttributes(this.name,{width:h,height:f}).run()},onUpdate:(h,f,p)=>h.type===s.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),d=u.dom;return d.style.visibility="hidden",d.style.pointerEvents="none",a.onload=()=>{d.style.visibility="",d.style.pointerEvents=""},u}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[Tx({find:LO,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Xw=IO;const Zu=(t,e,n)=>Math.max(e,Math.min(n,t));function PO(t){const e=se.useRef(null),[n,r]=se.useState(!1),[s,i]=se.useState(null),o=t.node.attrs,l=se.useMemo(()=>{const h=o.width;return typeof h=="string"&&h.trim().endsWith("%")?Zu(parseFloat(h)||100,1,100):100},[o.width]),a=s??l,c=h=>f=>{f.preventDefault(),f.stopPropagation();const p=f.clientX,m=a,b=(e.current?.closest(".ProseMirror")||void 0)?.getBoundingClientRect().width||e.current?.parentElement?.getBoundingClientRect().width||e.current?.getBoundingClientRect().width||window.innerWidth;let x=m;const w=T=>{const v=(T.clientX-p)/b*100,A=h==="east"?m+v:m-v,C=Zu(A,1,100);x=C,i(C)},k=()=>{r(!1),window.removeEventListener("pointermove",w),window.removeEventListener("pointerup",k);const T=Zu(x,1,100);t.updateAttributes({width:`${T.toFixed(2)}%`}),i(null)};r(!0),window.addEventListener("pointermove",w),window.addEventListener("pointerup",k,{once:!0})},u=(()=>{const h={width:`${a}%`,maxWidth:"100%",display:"block"};return o.height?(typeof o.height=="number"||typeof o.height=="string")&&(h.height=o.height):h.height="auto",o.align==="left"&&(h.marginLeft=0,h.marginRight="auto"),o.align==="right"&&(h.marginLeft="auto",h.marginRight=0),o.align==="center"&&(h.margin="0 auto"),h})(),d=t.selected||n;return g.jsxs(wf,{ref:e,className:"tiptap-image-wrapper relative block","data-dragging":n?"true":"false",contentEditable:!1,style:u,onClick:h=>h.stopPropagation(),children:[g.jsx("img",{src:o.src,alt:o.alt||"",style:{display:"block",width:"100%",height:"100%",objectFit:"cover",objectPosition:`${o.focalX??50}% ${o.focalY??50}%`,borderRadius:6},draggable:!1,onClick:h=>{if(o.focusMode){const f=h.target.getBoundingClientRect(),p=Math.round((h.clientX-f.left)/f.width*100),m=Math.round((h.clientY-f.top)/f.height*100);t.updateAttributes({focalX:p,focalY:m,focusMode:!1})}}}),d&&g.jsxs(g.Fragment,{children:[g.jsx("div",{role:"slider","aria-label":"Resize image","aria-valuemin":1,"aria-valuemax":100,"aria-valuenow":a,onPointerDown:c("west"),className:"absolute left-0 top-1/2 -translate-y-1/2 h-16 w-2 rounded-sm bg-primary cursor-ew-resize shadow border border-primary/40"}),g.jsx("div",{role:"slider","aria-label":"Resize image","aria-valuemin":1,"aria-valuemax":100,"aria-valuenow":a,onPointerDown:c("east"),className:"absolute right-0 top-1/2 -translate-y-1/2 h-16 w-2 rounded-sm bg-primary cursor-ew-resize shadow border border-primary/40"})]}),d&&g.jsx("div",{className:"pointer-events-none absolute inset-0 rounded-md ring-2 ring-primary/60"}),n&&g.jsxs("div",{className:"pointer-events-none absolute -top-6 right-0 text-xs bg-primary text-primary-foreground px-2 py-0.5 rounded",children:[Number(a.toFixed(1)),"%"]})]})}const jO=Xw.extend({name:"image",addAttributes(){return{...this.parent?.()||{},width:{default:null,parseHTML:t=>t.getAttribute("width")||t.style.width||null,renderHTML:t=>{const e={};return typeof t.width=="number"?e.width=t.width:typeof t.width=="string"&&t.width.trim().length>0&&(e.style=`width: ${t.width};`),e}},height:{default:null,parseHTML:t=>t.getAttribute("height")||t.style.height||null,renderHTML:t=>{const e={};if(typeof t.height=="number")e.height=t.height;else if(typeof t.height=="string"&&t.height.trim().length>0){const n=`height: ${t.height};`;e.style=e.style?`${e.style} ${n}`:n}return e}},blurDataURL:{default:null,parseHTML:t=>t.getAttribute("data-blur")||null,renderHTML:t=>t.blurDataURL?{"data-blur":t.blurDataURL}:{}},lockAspect:{default:!0,parseHTML:t=>t.getAttribute("data-lock-aspect")!=="false",renderHTML:t=>({"data-lock-aspect":String(t.lockAspect)})},align:{default:null,parseHTML:t=>t.getAttribute("data-align"),renderHTML:t=>t.align?{"data-align":t.align}:{}},caption:{default:null,parseHTML:t=>t.getAttribute("data-caption"),renderHTML:t=>t.caption?{"data-caption":t.caption}:{}},focalX:{default:null,parseHTML:t=>t.getAttribute("data-focal-x"),renderHTML:t=>t.focalX!=null?{"data-focal-x":String(t.focalX)}:{}},focalY:{default:null,parseHTML:t=>t.getAttribute("data-focal-y"),renderHTML:t=>t.focalY!=null?{"data-focal-y":String(t.focalY)}:{}},focusMode:{default:!1,parseHTML:t=>t.getAttribute("data-focus-mode")==="true",renderHTML:t=>t.focusMode?{"data-focus-mode":"true"}:{}}}},addKeyboardShortcuts(){const e=n=>()=>{const s=(this.editor.getAttributes("image")||{}).width;let i=100;typeof s=="string"&&s.endsWith("%")&&(i=parseFloat(s)||100);const o=Math.max(1,Math.min(100,i+n));return this.editor.chain().focus().updateAttributes("image",{width:`${o}%`}).run()};return{"Alt-=":e(5),"Alt-+":e(5),"Alt--":e(-5),"Alt-_":e(-5)}},addNodeView(){return kf(PO)}});var Zw=jw,Qw=Pw;let oh,lh;if(typeof WeakMap<"u"){let t=new WeakMap;oh=e=>t.get(e),lh=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;oh=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},lh=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var $e=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,s=e/this.width|0;let i=r+1,o=s+1;for(let l=1;i<this.width&&this.map[e+l]==n;l++)i++;for(let l=1;o<this.height&&this.map[e+this.width*l]==n;l++)o++;return{left:r,top:s,right:i,bottom:o}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:s,top:i,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[i*this.width+(n<0?r-1:s)]:(n<0?i==0:o==this.height)?null:this.map[r+this.width*(n<0?i-1:o)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:o,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(s,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const i=r*this.width+s,o=this.map[i];n[o]||(n[o]=!0,!(s==t.left&&s&&this.map[i-1]==o||r==t.top&&r&&this.map[i-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const i=s+n.child(r).nodeSize;if(r==t){let o=e+t*this.width;const l=(t+1)*this.width;for(;o<l&&this.map[o]<s;)o++;return o==l?i-1:this.map[o]}s=i}}static get(t){return oh(t)||lh(t,$O(t))}};function $O(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=BO(t),n=t.childCount,r=[];let s=0,i=null;const o=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){const d=t.child(c);u++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==d.childCount)break;const m=d.child(p),{colspan:y,rowspan:b,colwidth:x}=m.attrs;for(let w=0;w<b;w++){if(w+c>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:b-w});break}const k=s+w*e;for(let T=0;T<y;T++){r[k+T]==0?r[k+T]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:y-T});const S=x&&x[T];if(S){const v=(k+T)%e*2,A=o[v];A==null||A!=S&&o[v+1]==1?(o[v]=S,o[v+1]=1):A==S&&o[v+1]++}}}s+=y,u+=m.nodeSize}const h=(c+1)*e;let f=0;for(;s<h;)r[s++]==0&&f++;f&&(i||(i=[])).push({type:"missing",row:c,n:f}),u++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const l=new $e(e,n,r,i);let a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<n&&(a=!0);return a&&zO(l,o,t),l}function BO(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let i=0;if(n)for(let o=0;o<r;o++){const l=t.child(o);for(let a=0;a<l.childCount;a++){const c=l.child(a);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){const l=s.child(o);i+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function zO(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const i=t.map[s];if(r[i])continue;r[i]=!0;const o=n.nodeAt(i);if(!o)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=o.attrs;for(let c=0;c<a.colspan;c++){const u=e[(s+c)%t.width*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=HO(a)))[c]=u)}l&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function HO(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function yt(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}const ir=new ge("selectingCells");function Gr(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function FO(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function hn(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function Oc(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=Gr(e.$head)||UO(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function UO(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function ah(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function VO(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function Uf(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function e1(t,e,n){const r=t.node(-1),s=$e.get(r),i=t.start(-1),o=s.nextCell(t.pos-i,e,n);return o==null?null:t.node(0).resolve(i+o)}function Yr(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function t1(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<n;s++)r.colwidth.splice(e,0,0)}return r}function WO(t,e,n){const r=yt(e.type.schema).header_cell;for(let s=0;s<t.height;s++)if(e.nodeAt(t.map[n+s*t.width]).type!=r)return!1;return!0}var Ne=class Dn extends te{constructor(e,n=e){const r=e.node(-1),s=$e.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,n.pos-i),l=e.node(0),a=s.cellsInRect(o).filter(u=>u!=n.pos-i);a.unshift(n.pos-i);const c=a.map(u=>{const d=r.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);const h=i+u+1;return new Wh(l.resolve(h),l.resolve(h+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(ah(r)&&ah(s)&&Uf(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Dn.rowSelection(r,s):i&&this.isColSelection()?Dn.colSelection(r,s):new Dn(r,s)}return Q.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=$e.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let u=a*n.width+s.left,d=s.left;d<s.right;d++,u++){const h=n.map[u];if(i[h])continue;i[h]=!0;const f=n.findCell(h);let p=e.nodeAt(h);if(!p)throw new RangeError(`No cell with offset ${h} found`);const m=s.left-f.left,y=f.right-s.right;if(m>0||y>0){let b=p.attrs;if(m>0&&(b=Yr(b,0,m)),y>0&&(b=Yr(b,b.colspan-y,y)),f.left<s.left){if(p=p.type.createAndFill(b),!p)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else p=p.type.create(b,p.content)}if(f.top<s.top||f.bottom>s.bottom){const b={...p.attrs,rowspan:Math.min(f.bottom,s.bottom)-Math.max(f.top,s.top)};f.top<s.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}o.push(e.child(a).copy(j.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new F(j.from(l),1,1)}replace(e,n=F.empty){const r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){const{$from:l,$to:a}=s[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?F.empty:n)}const i=te.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new F(j.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=$e.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(n.nodeAt(i[o]),s+i[o])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),s=$e.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),a=e.node(0);return o.top<=l.top?(o.top>0&&(e=a.resolve(i+s.map[o.left])),l.bottom<s.height&&(n=a.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+s.map[l.left])),o.bottom<s.height&&(e=a.resolve(i+s.map[s.width*(s.height-1)+o.right-1]))),new Dn(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=$e.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const o=s+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==n.width}eq(e){return e instanceof Dn&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=$e.get(r),i=e.start(-1),o=s.findCell(e.pos-i),l=s.findCell(n.pos-i),a=e.node(0);return o.left<=l.left?(o.left>0&&(e=a.resolve(i+s.map[o.top*s.width])),l.right<s.width&&(n=a.resolve(i+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+s.map[l.top*s.width])),o.right<s.width&&(e=a.resolve(i+s.map[s.width*(o.top+1)-1]))),new Dn(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Dn(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Dn(e.resolve(n),e.resolve(r))}getBookmark(){return new qO(this.$anchorCell.pos,this.$headCell.pos)}};Ne.prototype.visible=!1;te.jsonID("cell",Ne);var qO=class n1{constructor(e,n){this.anchor=e,this.head=n}map(e){return new n1(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&Uf(n,r)?new Ne(n,r):te.near(r,1)}};function KO(t){if(!(t.selection instanceof Ne))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(_e.node(r,r+n.nodeSize,{class:"selectedCell"}))}),xe.create(t.doc,e)}function JO({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,s=t.depth;for(;s>=0&&!(t.after(s+1)<t.end(s));s--,n++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(s).type.spec.tableRole)}function GO({$from:t,$to:e}){let n,r;for(let s=t.depth;s>0;s--){const i=t.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function YO(t,e,n){const r=(e||t).selection,s=(e||t).doc;let i,o;if(r instanceof Y&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=Ne.create(s,r.from);else if(o=="row"){const l=s.resolve(r.from+1);i=Ne.rowSelection(l,l)}else if(!n){const l=$e.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=Ne.create(s,a+1,c)}}else r instanceof Q&&JO(r)?i=Q.create(s,r.from):r instanceof Q&&GO(r)&&(i=Q.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const XO=new ge("fix-tables");function r1(t,e,n,r){const s=t.childCount,i=e.childCount;e:for(let o=0,l=0;o<i;o++){const a=e.child(o);for(let c=l,u=Math.min(s,o+3);c<u;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<s&&t.child(l).sameMarkup(a)?r1(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function s1(t,e){let n;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=ZO(t,s,i,n))};return e?e.doc!=t.doc&&r1(e.doc,t.doc,0,r):t.doc.descendants(r),n}function ZO(t,e,n,r){const s=$e.get(e);if(!s.problems)return r;r||(r=t.tr);const i=[];for(let a=0;a<s.height;a++)i.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let h=0;h<d.rowspan;h++)i[c.row+h]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Yr(d,d.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(n);r.delete(u,u+e.nodeSize)}}let o,l;for(let a=0;a<i.length;a++)i[a]&&(o==null&&(o=a),l=a);for(let a=0,c=n+1;a<s.height;a++){const u=e.child(a),d=c+u.nodeSize,h=i[a];if(h>0){let f="cell";u.firstChild&&(f=u.firstChild.type.spec.tableRole);const p=[];for(let y=0;y<h;y++){const b=yt(t.schema)[f].createAndFill();b&&p.push(b)}const m=(a==0||o==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(m),p)}c=d}return r.setMeta(XO,{fixTables:!0})}function An(t){const e=t.selection,n=Oc(t),r=n.node(-1),s=n.start(-1),i=$e.get(r);return{...e instanceof Ne?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function i1(t,{map:e,tableStart:n,table:r},s){let i=s>0?-1:0;WO(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){const l=o*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,t1(c.attrs,s-e.colCount(a))),o+=c.attrs.rowspan-1}else{const a=i==null?yt(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(o,s,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function QO(t,e){if(!hn(t))return!1;if(e){const n=An(t);e(i1(t.tr,n,n.left))}return!0}function eD(t,e){if(!hn(t))return!1;if(e){const n=An(t);e(i1(t.tr,n,n.right))}return!0}function tD(t,{map:e,table:n,tableStart:r},s){const i=t.mapping.maps.length;for(let o=0;o<e.height;){const l=o*e.width+s,a=e.map[l],c=n.nodeAt(a),u=c.attrs;if(s>0&&e.map[l-1]==a||s<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(i).map(r+a),null,Yr(u,s-e.colCount(a)));else{const d=t.mapping.slice(i).map(r+a);t.delete(d,d+c.nodeSize)}o+=u.rowspan}}function nD(t,e){if(!hn(t))return!1;if(e){const n=An(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;tD(r,n,s),s!=n.left;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=$e.get(i)}e(r)}return!0}function rD(t,e,n){var r;const s=yt(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=s)return!1;return!0}function o1(t,{map:e,tableStart:n,table:r},s){let i=n;for(let c=0;c<s;c++)i+=r.child(c).nodeSize;const o=[];let l=s>0?-1:0;rD(e,r,s+l)&&(l=s==0||s==e.height?null:0);for(let c=0,u=e.width*s;c<e.width;c++,u++)if(s>0&&s<e.height&&e.map[u]==e.map[u-e.width]){const d=e.map[u],h=r.nodeAt(d).attrs;t.setNodeMarkup(n+d,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{var a;const d=l==null?yt(r.type.schema).cell:(a=r.nodeAt(e.map[u+l*e.width]))===null||a===void 0?void 0:a.type,h=d?.createAndFill();h&&o.push(h)}return t.insert(i,yt(r.type.schema).row.create(null,o)),t}function sD(t,e){if(!hn(t))return!1;if(e){const n=An(t);e(o1(t.tr,n,n.top))}return!0}function iD(t,e){if(!hn(t))return!1;if(e){const n=An(t);e(o1(t.tr,n,n.bottom))}return!0}function oD(t,{map:e,table:n,tableStart:r},s){let i=0;for(let c=0;c<s;c++)i+=n.child(c).nodeSize;const o=i+n.child(s).nodeSize,l=t.mapping.maps.length;t.delete(i+r,o+r);const a=new Set;for(let c=0,u=s*e.width;c<e.width;c++,u++){const d=e.map[u];if(!a.has(d)){if(a.add(d),s>0&&d==e.map[u-e.width]){const h=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(s<e.height&&d==e.map[u+e.width]){const h=n.nodeAt(d),f=h.attrs,p=h.type.create({...f,rowspan:h.attrs.rowspan-1},h.content),m=e.positionAt(s+1,c,n);t.insert(t.mapping.slice(l).map(r+m),p),c+=f.colspan-1}}}}function lD(t,e){if(!hn(t))return!1;if(e){const n=An(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;oD(r,n,s),s!=n.top;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=$e.get(n.table)}e(r)}return!0}function Jg(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function aD({width:t,height:e,map:n},r){let s=r.top*t+r.left,i=s,o=(r.bottom-1)*t+r.left,l=s+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[l]==n[l+1])return!0;i+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[o]==n[o+t])return!0;s++,o++}return!1}function Gg(t,e){const n=t.selection;if(!(n instanceof Ne)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=An(t),{map:s}=r;if(aD(s,r))return!1;if(e){const i=t.tr,o={};let l=j.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){const h=s.map[u*s.width+d],f=r.table.nodeAt(h);if(!(o[h]||!f))if(o[h]=!0,a==null)a=h,c=f;else{Jg(f)||(l=l.append(f.content));const p=i.mapping.map(h+r.tableStart);i.delete(p,p+f.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...t1(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){const u=a+1+c.content.size,d=Jg(c)?a+1:u;i.replaceWith(d+r.tableStart,u+r.tableStart,l)}i.setSelection(new Ne(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function Yg(t,e){const n=yt(t.schema);return cD(({node:r})=>n[r.type.spec.tableRole])(t,e)}function cD(t){return(e,n)=>{const r=e.selection;let s,i;if(r instanceof Ne){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var o;if(s=FO(r.$from),!s)return!1;i=(o=Gr(r.$from))===null||o===void 0?void 0:o.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let l=s.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const u=An(e),d=e.tr;for(let f=0;f<u.right-u.left;f++)a.push(c?{...l,colwidth:c&&c[f]?[c[f]]:null}:l);let h;for(let f=u.top;f<u.bottom;f++){let p=u.map.positionAt(f,u.left,u.table);f==u.top&&(p+=s.nodeSize);for(let m=u.left,y=0;m<u.right;m++,y++)m==u.left&&f==u.top||d.insert(h=d.mapping.map(p+u.tableStart,1),t({node:s,row:f,col:m}).createAndFill(a[y]))}d.setNodeMarkup(i,t({node:s,row:u.top,col:u.left}),a[0]),r instanceof Ne&&d.setSelection(new Ne(d.doc.resolve(r.$anchorCell.pos),h?d.doc.resolve(h):void 0)),n(d)}return!0}}function uD(t,e){return function(n,r){if(!hn(n))return!1;const s=Oc(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof Ne?n.selection.forEachCell((o,l)=>{o.attrs[t]!==e&&i.setNodeMarkup(l,null,{...o.attrs,[t]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function dD(t){return function(e,n){if(!hn(e))return!1;if(n){const r=yt(e.schema),s=An(e),i=e.tr,o=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=o.map(a=>s.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[a],r.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<o.length;a++)i.setNodeMarkup(s.tableStart+o[a],r.header_cell,l[a].attrs);n(i)}return!0}}function Xg(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function mo(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?dD(t):function(n,r){if(!hn(n))return!1;if(r){const s=yt(n.schema),i=An(n),o=n.tr,l=Xg("row",i,s),a=Xg("column",i,s),c=(t==="column"?l:t==="row"&&a)?1:0,u=t=="column"?{left:0,top:c,right:1,bottom:i.map.height}:t=="row"?{left:c,top:0,right:i.map.width,bottom:1}:i,d=t=="column"?a?s.cell:s.header_cell:t=="row"?l?s.cell:s.header_cell:s.cell;i.map.cellsInRect(u).forEach(h=>{const f=h+i.tableStart,p=o.doc.nodeAt(f);p&&o.setNodeMarkup(f,d,p.attrs)}),r(o)}return!0}}mo("row",{useDeprecatedLogic:!0});mo("column",{useDeprecatedLogic:!0});const hD=mo("cell",{useDeprecatedLogic:!0});function fD(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,s=t.before();r>=0;r--){const i=t.node(-1).child(r),o=i.lastChild;if(o)return s-1-o.nodeSize;s-=i.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),s=t.after();r<n.childCount;r++){const i=n.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function Zg(t){return function(e,n){if(!hn(e))return!1;const r=fD(Oc(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection(Q.between(s,VO(s))).scrollIntoView())}return!0}}function pD(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function kl(t,e){const n=t.selection;if(!(n instanceof Ne))return!1;if(e){const r=t.tr,s=yt(t.schema).cell.createAndFill().content;n.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new F(s,0,0))}),r.docChanged&&e(r)}return!0}function mD(t){if(t.size===0)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const s=e.child(0),i=s.type.spec.tableRole,o=s.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,n-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=ch(yt(o).row,new F(c,u,d)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(n||r?ch(yt(o).row,new F(e,n,r)).content:e);else return null;return gD(o,l)}function gD(t,e){const n=[];for(let s=0;s<e.length;s++){const i=e[s];for(let o=i.childCount-1;o>=0;o--){const{rowspan:l,colspan:a}=i.child(o).attrs;for(let c=s;c<s+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,n[s]);for(let s=0;s<n.length;s++)if(s>=e.length&&e.push(j.empty),n[s]<r){const i=yt(t).cell.createAndFill(),o=[];for(let l=n[s];l<r;l++)o.push(i);e[s]=e[s].append(j.from(o))}return{height:e.length,width:r,rows:e}}function ch(t,e){const n=t.createAndFill();return new Vh(n).replace(0,n.content.size,e).doc}function yD({width:t,height:e,rows:n},r,s){if(t!=r){const i=[],o=[];for(let l=0;l<n.length;l++){const a=n[l],c=[];for(let u=i[l]||0,d=0;u<r;d++){let h=a.child(d%a.childCount);u+h.attrs.colspan>r&&(h=h.type.createChecked(Yr(h.attrs,h.attrs.colspan,u+h.attrs.colspan-r),h.content)),c.push(h),u+=h.attrs.colspan;for(let f=1;f<h.attrs.rowspan;f++)i[l+f]=(i[l+f]||0)+h.attrs.colspan}o.push(j.from(c))}n=o,t=r}if(e!=s){const i=[];for(let o=0,l=0;o<s;o++,l++){const a=[],c=n[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);o+d.attrs.rowspan>s&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,s-d.attrs.rowspan)},d.content)),a.push(d)}i.push(j.from(a))}n=i,e=s}return{width:t,height:e,rows:n}}function bD(t,e,n,r,s,i,o){const l=t.doc.type.schema,a=yt(l);let c,u;if(s>e.width)for(let d=0,h=0;d<e.height;d++){const f=n.child(d);h+=f.nodeSize;const p=[];let m;f.lastChild==null||f.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=u||(u=a.header_cell.createAndFill());for(let y=e.width;y<s;y++)p.push(m);t.insert(t.mapping.slice(o).map(h-1+r),p)}if(i>e.height){const d=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,s);p++){const y=p>=e.width?!1:n.nodeAt(e.map[m+p]).type==a.header_cell;d.push(y?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const h=a.row.create(null,j.from(d)),f=[];for(let p=e.height;p<i;p++)f.push(h);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),f)}return!!(c||u)}function Qg(t,e,n,r,s,i,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=s;c<i;c++){const u=o*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;const h=n.nodeAt(d),{top:f,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...h.attrs,rowspan:o-f}),t.insert(t.mapping.slice(l).map(e.positionAt(o,p,n)),h.type.createAndFill({...h.attrs,rowspan:f+h.attrs.rowspan-o})),c+=h.attrs.colspan-1}}return a}function ey(t,e,n,r,s,i,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=s;c<i;c++){const u=c*e.width+o,d=e.map[u];if(e.map[u-1]==d){a=!0;const h=n.nodeAt(d),f=e.colCount(d),p=t.mapping.slice(l).map(d+r);t.setNodeMarkup(p,null,Yr(h.attrs,o-f,h.attrs.colspan-(o-f))),t.insert(p+h.nodeSize,h.type.createAndFill(Yr(h.attrs,0,o-f))),c+=h.attrs.rowspan-1}}return a}function ty(t,e,n,r,s){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let o=$e.get(i);const{top:l,left:a}=r,c=a+s.width,u=l+s.height,d=t.tr;let h=0;function f(){if(i=n?d.doc.nodeAt(n-1):d.doc,!i)throw new Error("No table found");o=$e.get(i),h=d.mapping.maps.length}bD(d,o,i,n,c,u,h)&&f(),Qg(d,o,i,n,a,c,l,h)&&f(),Qg(d,o,i,n,a,c,u,h)&&f(),ey(d,o,i,n,l,u,a,h)&&f(),ey(d,o,i,n,l,u,c,h)&&f();for(let p=l;p<u;p++){const m=o.positionAt(p,a,i),y=o.positionAt(p,c,i);d.replace(d.mapping.slice(h).map(m+n),d.mapping.slice(h).map(y+n),new F(s.rows[p-l],0,0))}f(),d.setSelection(new Ne(d.doc.resolve(n+o.positionAt(l,a,i)),d.doc.resolve(n+o.positionAt(u-1,c-1,i)))),e(d)}const xD=of({ArrowLeft:vl("horiz",-1),ArrowRight:vl("horiz",1),ArrowUp:vl("vert",-1),ArrowDown:vl("vert",1),"Shift-ArrowLeft":Sl("horiz",-1),"Shift-ArrowRight":Sl("horiz",1),"Shift-ArrowUp":Sl("vert",-1),"Shift-ArrowDown":Sl("vert",1),Backspace:kl,"Mod-Backspace":kl,Delete:kl,"Mod-Delete":kl});function Ul(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function vl(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof Ne)return Ul(n,r,te.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const o=l1(s,t,e);if(o==null)return!1;if(t=="horiz")return Ul(n,r,te.near(n.doc.resolve(i.head+e),e));{const l=n.doc.resolve(o),a=e1(l,t,e);let c;return a?c=te.near(a,1):e<0?c=te.near(n.doc.resolve(l.before(-1)),-1):c=te.near(n.doc.resolve(l.after(-1)),1),Ul(n,r,c)}}}function Sl(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let o;if(i instanceof Ne)o=i;else{const a=l1(s,t,e);if(a==null)return!1;o=new Ne(n.doc.resolve(a))}const l=e1(o.$headCell,t,e);return l?Ul(n,r,new Ne(o.$anchorCell,l)):!1}}function wD(t,e){const n=t.state.doc,r=Gr(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Ne(r))),!0):!1}function kD(t,e,n){if(!hn(t.state))return!1;let r=mD(n);const s=t.state.selection;if(s instanceof Ne){r||(r={width:1,height:1,rows:[j.from(ch(yt(t.state.schema).cell,n))]});const i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),l=$e.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=yD(r,l.right-l.left,l.bottom-l.top),ty(t.state,t.dispatch,o,l,r),!0}else if(r){const i=Oc(t.state),o=i.start(-1);return ty(t.state,t.dispatch,o,$e.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function vD(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=ny(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof Ne)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=Gr(t.state.selection.$anchor))!=null&&((n=Qu(t,e))===null||n===void 0?void 0:n.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(a,c){let u=Qu(t,c);const d=ir.getState(t.state)==null;if(!u||!Uf(a,u))if(d)u=a;else return;const h=new Ne(a,u);if(d||!t.state.selection.eq(h)){const f=t.state.tr.setSelection(h);d&&f.setMeta(ir,a.pos),t.dispatch(f)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),ir.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(ir,-1))}function l(a){const c=a,u=ir.getState(t.state);let d;if(u!=null)d=t.state.doc.resolve(u);else if(ny(t,c.target)!=r&&(d=Qu(t,e),!d))return o();d&&i(d,c)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",l)}function l1(t,e,n){if(!(t.state.selection instanceof Q))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const o=r.before(s),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?o:null}}return null}function ny(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Qu(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:s}=n;return r>=0&&Gr(t.state.doc.resolve(r))||Gr(t.state.doc.resolve(s))}var SD=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),uh(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,uh(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function uh(t,e,n,r,s,i){let o=0,l=!0,a=e.firstChild;const c=t.firstChild;if(c){for(let d=0,h=0;d<c.childCount;d++){const{colspan:f,colwidth:p}=c.child(d).attrs;for(let m=0;m<f;m++,h++){const y=s==h?i:p&&p[m],b=y?y+"px":"";if(o+=y||r,y||(l=!1),a)a.style.width!=b&&(a.style.width=b),a=a.nextSibling;else{const x=document.createElement("col");x.style.width=b,e.appendChild(x)}}}for(;a;){var u;const d=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=d}l?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}const Ht=new ge("tableColumnResizing");function CD({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=SD,lastColumnResizable:s=!0}={}){const i=new me({key:Ht,state:{init(o,l){var a;const c=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,u=yt(l.schema).table.name;return r&&c&&(c[u]=(d,h)=>new r(d,n,h)),new ED(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=Ht.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{AD(o,l,t,s)},mouseleave:o=>{MD(o)},mousedown:(o,l)=>{TD(o,l,e,n)}},decorations:o=>{const l=Ht.getState(o);if(l&&l.activeHandle>-1)return DD(o,l.activeHandle)},nodeViews:{}}});return i}var ED=class Vl{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Ht);if(r&&r.setHandle!=null)return new Vl(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Vl(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return ah(e.doc.resolve(s))||(s=-1),new Vl(s,n.dragging)}return n}};function AD(t,e,n,r){if(!t.editable)return;const s=Ht.getState(t.state);if(s&&!s.dragging){const i=RD(e.target);let o=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=n?o=ry(t,e,"left",n):a-e.clientX<=n&&(o=ry(t,e,"right",n))}if(o!=s.activeHandle){if(!r&&o!==-1){const l=t.state.doc.resolve(o),a=l.node(-1),c=$e.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}a1(t,o)}}}function MD(t){if(!t.editable)return;const e=Ht.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&a1(t,-1)}function TD(t,e,n,r){var s;if(!t.editable)return!1;const i=(s=t.dom.ownerDocument.defaultView)!==null&&s!==void 0?s:window,o=Ht.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=t.state.doc.nodeAt(o.activeHandle),a=ND(t,o.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Ht,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",u);const h=Ht.getState(t.state);h?.dragging&&(_D(t,h.activeHandle,sy(h.dragging,d,n)),t.dispatch(t.state.tr.setMeta(Ht,{setDragging:null})))}function u(d){if(!d.which)return c(d);const h=Ht.getState(t.state);if(h&&h.dragging){const f=sy(h.dragging,d,n);iy(t,h.activeHandle,f,r)}}return iy(t,o.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",u),e.preventDefault(),!0}function ND(t,e,{colspan:n,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=t.domAtPos(e);let o=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let a=0;a<n;a++)r[a]&&(o-=r[a],l--);return o/l}function RD(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function ry(t,e,n,r){const s=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:o}=i,l=Gr(t.state.doc.resolve(o));if(!l)return-1;if(n=="right")return l.pos;const a=$e.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function sy(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function a1(t,e){t.dispatch(t.state.tr.setMeta(Ht,{setHandle:e}))}function _D(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),i=$e.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<i.height;c++){const u=c*i.width+l;if(c&&i.map[u]==i.map[u-i.width])continue;const d=i.map[u],h=s.nodeAt(d).attrs,f=h.colspan==1?0:l-i.colCount(d);if(h.colwidth&&h.colwidth[f]==n)continue;const p=h.colwidth?h.colwidth.slice():OD(h.colspan);p[f]=n,a.setNodeMarkup(o+d,null,{...h,colwidth:p})}a.docChanged&&t.dispatch(a)}function iy(t,e,n,r){const s=t.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),l=$e.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1;let a=t.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&uh(i,a.firstChild,a,r,l,n)}function OD(t){return Array(t).fill(0)}function DD(t,e){const n=[],r=t.doc.resolve(e),s=r.node(-1);if(!s)return xe.empty;const i=$e.get(s),o=r.start(-1),l=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){const u=l+c*i.width;if((l==i.width-1||i.map[u]!=i.map[u+1])&&(c==0||i.map[u]!=i.map[u-i.width])){var a;const d=i.map[u],h=o+d+s.nodeAt(d).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",!((a=Ht.getState(t))===null||a===void 0)&&a.dragging&&n.push(_e.node(o+d,o+d+s.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),n.push(_e.widget(h,f))}}return xe.create(t.doc,n)}function LD({allowTableNodeSelection:t=!1}={}){return new me({key:ir,state:{init(){return null},apply(e,n){const r=e.getMeta(ir);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:s,pos:i}=e.mapping.mapResult(n);return s?null:i}},props:{decorations:KO,handleDOMEvents:{mousedown:vD},createSelectionBetween(e){return ir.getState(e.state)!=null?e.state.selection:null},handleTripleClick:wD,handleKeyDown:xD,handlePaste:kD},appendTransaction(e,n,r){return YO(r,s1(r,n),t)}})}function Wa(t){return t==="left"||t==="right"||t==="center"?t:null}function ID(t){const e=(t.style.textAlign||"").trim().toLowerCase(),n=(t.getAttribute("align")||"").trim().toLowerCase();return Wa(e||n)}function PD(t){return Wa(t?.align)}function c1(){return{default:null,parseHTML:t=>ID(t),renderHTML:t=>t.align?{style:`text-align: ${t.align}`}:{}}}var u1=De.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const r=t.getAttribute("colwidth"),s=r?r.split(",").map(i=>parseInt(i,10)):null;if(!s){const i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),o=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(o&&o>-1&&i&&i[o]){const l=i[o].getAttribute("width");return l?[parseInt(l,10)]:null}}return s}},align:c1()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",fe(this.options.HTMLAttributes,t),0]}}),d1=De.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}},align:c1()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",fe(this.options.HTMLAttributes,t),0]}}),h1=De.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",fe(this.options.HTMLAttributes,t),0]}});function dh(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function oy(t,e,n,r,s,i){var o;let l=0,a=!0,c=e.firstChild;const u=t.firstChild;if(u!==null)for(let h=0,f=0;h<u.childCount;h+=1){const{colspan:p,colwidth:m}=u.child(h).attrs;for(let y=0;y<p;y+=1,f+=1){const b=s===f?i:m&&m[y],x=b?`${b}px`:"";if(l+=b||r,b||(a=!1),c){if(c.style.width!==x){const[w,k]=dh(r,b);c.style.setProperty(w,k)}c=c.nextSibling}else{const w=document.createElement("col"),[k,T]=dh(r,b);w.style.setProperty(k,T),e.appendChild(w)}}}for(;c;){const h=c.nextSibling;(o=c.parentNode)==null||o.removeChild(c),c=h}const d=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);a&&!d?(n.style.width=`${l}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${l}px`)}var jD=class{constructor(t,e,n,r={}){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(const[s,i]of Object.entries(r))i!=null&&(s==="style"?this.table.style.cssText=String(i):this.table.setAttribute(s,String(i)));t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),oy(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,oy(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function $D(t,e,n,r){let s=0,i=!0;const o=[],l=t.firstChild;if(!l)return{};for(let d=0,h=0;d<l.childCount;d+=1){const{colspan:f,colwidth:p}=l.child(d).attrs;for(let m=0;m<f;m+=1,h+=1){const y=n===h?r:p&&p[m];s+=y||e,y||(i=!1);const[b,x]=dh(e,y);o.push(["col",{style:`${b}: ${x}`}])}}const a=i?`${s}px`:"",c=i?"":`${s}px`;return{colgroup:["colgroup",{},...o],tableWidth:a,tableMinWidth:c}}function ly(t,e){return t.createAndFill()}function BD(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function zD(t,e,n,r,s){const i=BD(t),o=[],l=[];for(let c=0;c<n;c+=1){const u=ly(i.cell);if(u&&l.push(u),r){const d=ly(i.header_cell);d&&o.push(d)}}const a=[];for(let c=0;c<e;c+=1)a.push(i.row.createChecked(null,r&&c===0?o:l));return i.table.createChecked(null,a)}function HD(t){return t instanceof Ne}var Cl=({editor:t})=>{const{selection:e}=t.state;if(!HD(e))return!1;let n=0;const r=nx(e.ranges[0].$from,i=>i.type.name==="table");return r?.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},FD="";function UD(t){return(t||"").replace(/\s+/g," ").trim()}function VD(t,e,n={}){var r;const s=(r=n.cellLineSeparator)!=null?r:FD;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(m=>{const y=[];m.content&&m.content.forEach(b=>{let x="";b.content&&Array.isArray(b.content)&&b.content.length>1?x=b.content.map(v=>e.renderChildren(v)).join(s):x=b.content?e.renderChildren(b.content):"";const w=UD(x),k=b.type==="tableHeader",T=PD(b.attrs);y.push({text:w,isHeader:k,align:T})}),i.push(y)});const o=i.reduce((m,y)=>Math.max(m,y.length),0);if(o===0)return"";const l=Array.from({length:o}).fill(0);i.forEach(m=>{var y;for(let b=0;b<o;b+=1){const w=(((y=m[b])==null?void 0:y.text)||"").length;w>l[b]&&(l[b]=w),l[b]<3&&(l[b]=3)}});const a=(m,y)=>m+" ".repeat(Math.max(0,y-m.length)),c=i[0],u=c.some(m=>m.isHeader),d=Array.from({length:o}).fill(null);i.forEach(m=>{var y;for(let b=0;b<o;b+=1)!d[b]&&((y=m[b])!=null&&y.align)&&(d[b]=m[b].align)});let h=`
157
+ `;const f=Array.from({length:o}).map((m,y)=>u&&c[y]&&c[y].text||"");return h+=`| ${f.map((m,y)=>a(m,l[y])).join(" | ")} |
158
+ `,h+=`| ${l.map((m,y)=>{const b=Math.max(3,m),x=d[y];return x==="left"?`:${"-".repeat(b)}`:x==="right"?`${"-".repeat(b)}:`:x==="center"?`:${"-".repeat(b)}:`:"-".repeat(b)}).join(" | ")} |
159
+ `,(u?i.slice(1):i).forEach(m=>{h+=`| ${Array.from({length:o}).fill(0).map((y,b)=>a(m[b]&&m[b].text||"",l[b])).join(" | ")} |
160
+ `}),h}var WD=VD,f1=De.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:jD,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:s}=$D(t,this.options.cellMinWidth),i=e.style;function o(){return i||(r?`width: ${r}`:`min-width: ${s}`)}const l=["table",fe(this.options.HTMLAttributes,e,{style:o()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(t,e)=>{const n=[],r=Array.isArray(t.align)?t.align:[];if(t.header){const s=[];t.header.forEach((i,o)=>{var l;const a=Wa((l=r[o])!=null?l:i.align),c=a?{align:a}:{};s.push(e.createNode("tableHeader",c,[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}return t.rows&&t.rows.forEach(s=>{const i=[];s.forEach((o,l)=>{var a;const c=Wa((a=r[l])!=null?a:o.align),u=c?{align:c}:{};i.push(e.createNode("tableCell",u,[{type:"paragraph",content:e.parseInline(o.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>WD(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const o=zD(i.schema,t,e,n);if(s){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(Q.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>QO(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>eD(t,e),deleteColumn:()=>({state:t,dispatch:e})=>nD(t,e),addRowBefore:()=>({state:t,dispatch:e})=>sD(t,e),addRowAfter:()=>({state:t,dispatch:e})=>iD(t,e),deleteRow:()=>({state:t,dispatch:e})=>lD(t,e),deleteTable:()=>({state:t,dispatch:e})=>pD(t,e),mergeCells:()=>({state:t,dispatch:e})=>Gg(t,e),splitCell:()=>({state:t,dispatch:e})=>Yg(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>mo("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>mo("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>hD(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Gg(t,e)?!0:Yg(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>uD(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Zg(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Zg(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&s1(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Ne.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Cl,"Mod-Backspace":Cl,Delete:Cl,"Mod-Delete":Cl}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[CD({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],LD({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){const t=this.options.resizable&&this.editor.isEditable,e=this.options.View;return t||!e?null:({node:n,view:r,HTMLAttributes:s})=>{const i=fe(this.options.HTMLAttributes,s);return new e(n,this.options.cellMinWidth,r,i)}},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:we(J(t,"tableRole",e))}}});ce.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(f1.configure(this.options.table)),this.options.tableCell!==!1&&t.push(u1.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(d1.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(h1.configure(this.options.tableRow)),t}});var qD=h1,KD=d1,JD=u1,GD=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,YD=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,XD=dn.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||Qs(t,"background-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",fe(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){const s=/^(==)([^=]+)(==)/.exec(t);if(s){const i=s[2].trim(),o=n.inlineTokens(i);return{type:"highlight",raw:s[0],text:i,tokens:o}}}},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[qr({find:GD,type:this.type})]},addPasteRules(){return[mr({find:YD,type:this.type})]}}),ZD=XD,QD=dn.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",fe(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),eL=QD,tL=dn.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",fe(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),nL=tL,rL=ce.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).some(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).some(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),sL=rL,iL=20,p1=(t,e=0)=>{const n=[];return!t.children.length||e>iL||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...p1(r,e+1))}),n},oL=t=>{if(!t.children.length)return;const e=p1(t);e&&e.forEach(n=>{var r,s;const i=n.getAttribute("style"),o=(s=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:s.getAttribute("style");n.setAttribute("style",`${o};${i}`)})},lL=dn.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&oL(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",fe(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(i=>!!i))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),aL=ce.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=(e=Qs(t,"background-color"))!=null?e:t.style.backgroundColor;return n?.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),cL=ce.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=(e=Qs(t,"color"))!=null?e:t.style.color;return n?.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),uL=ce.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>{var e;return(e=Qs(t,"font-family"))!=null?e:t.style.fontFamily},renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),dL=ce.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>{var e;return(e=Qs(t,"font-size"))!=null?e:t.style.fontSize},renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),hL=ce.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>{var e;return(e=Qs(t,"line-height"))!=null?e:t.style.lineHeight},renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}}),fL=ce.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(aL.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(cL.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(uL.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(dL.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(hL.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(lL.configure(this.options.textStyle)),t}}),pL=dO,mL=t=>Be({find:/--$/,replace:t??"—"}),gL=t=>Be({find:/\.\.\.$/,replace:t??"…"}),ed=t=>Be({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"“"}),td=t=>Be({find:/"$/,replace:t??"”"}),nd=t=>Be({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"‘"}),rd=t=>Be({find:/'$/,replace:t??"’"}),yL=t=>Be({find:/<-$/,replace:t??"←"}),bL=t=>Be({find:/->$/,replace:t??"→"}),xL=t=>Be({find:/\(c\)$/,replace:t??"©"}),wL=t=>Be({find:/\(tm\)$/,replace:t??"™"}),kL=t=>Be({find:/\(sm\)$/,replace:t??"℠"}),vL=t=>Be({find:/\(r\)$/,replace:t??"®"}),SL=t=>Be({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),CL=t=>Be({find:/\+\/-$/,replace:t??"±"}),EL=t=>Be({find:/!=$/,replace:t??"≠"}),AL=t=>Be({find:/<<$/,replace:t??"«"}),ML=t=>Be({find:/>>$/,replace:t??"»"}),TL=t=>Be({find:/\d+\s?([*x])\s?\d+$/,replace:t??"×"}),NL=t=>Be({find:/\^2$/,replace:t??"²"}),RL=t=>Be({find:/\^3$/,replace:t??"³"}),_L=t=>Be({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),OL=t=>Be({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),DL=ce.create({name:"typography",addOptions(){return{closeDoubleQuote:"”",closeSingleQuote:"’",copyright:"©",ellipsis:"…",emDash:"—",laquo:"«",leftArrow:"←",multiplication:"×",notEqual:"≠",oneHalf:"½",oneQuarter:"¼",openDoubleQuote:"“",openSingleQuote:"‘",plusMinus:"±",raquo:"»",registeredTrademark:"®",rightArrow:"→",servicemark:"℠",superscriptThree:"³",superscriptTwo:"²",threeQuarters:"¾",trademark:"™"}},addInputRules(){var t,e;const n=[];this.options.emDash!==!1&&n.push(mL(this.options.emDash)),this.options.ellipsis!==!1&&n.push(gL(this.options.ellipsis));const r=this.editor.options.textDirection==="rtl";if((t=this.options.doubleQuotes)!=null&&t.rtl){const{open:s,close:i}=this.options.doubleQuotes.rtl;n.push(ed(s)),n.push(td(i))}else r?(n.push(ed("”")),n.push(td("“"))):(this.options.openDoubleQuote!==!1&&n.push(ed(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&n.push(td(this.options.closeDoubleQuote)));if((e=this.options.singleQuotes)!=null&&e.rtl){const{open:s,close:i}=this.options.singleQuotes.rtl;n.push(nd(s)),n.push(rd(i))}else r?(n.push(nd("’")),n.push(rd("‘"))):(this.options.openSingleQuote!==!1&&n.push(nd(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&n.push(rd(this.options.closeSingleQuote)));return this.options.leftArrow!==!1&&n.push(yL(this.options.leftArrow)),this.options.rightArrow!==!1&&n.push(bL(this.options.rightArrow)),this.options.copyright!==!1&&n.push(xL(this.options.copyright)),this.options.trademark!==!1&&n.push(wL(this.options.trademark)),this.options.servicemark!==!1&&n.push(kL(this.options.servicemark)),this.options.registeredTrademark!==!1&&n.push(vL(this.options.registeredTrademark)),this.options.oneHalf!==!1&&n.push(SL(this.options.oneHalf)),this.options.plusMinus!==!1&&n.push(CL(this.options.plusMinus)),this.options.notEqual!==!1&&n.push(EL(this.options.notEqual)),this.options.laquo!==!1&&n.push(AL(this.options.laquo)),this.options.raquo!==!1&&n.push(ML(this.options.raquo)),this.options.multiplication!==!1&&n.push(TL(this.options.multiplication)),this.options.superscriptTwo!==!1&&n.push(NL(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&n.push(RL(this.options.superscriptThree)),this.options.oneQuarter!==!1&&n.push(_L(this.options.oneQuarter)),this.options.threeQuarters!==!1&&n.push(OL(this.options.threeQuarters)),n}}),LL=DL,IL=Ww,PL=Kw;const on=()=>new Map,hh=t=>{const e=on();return t.forEach((n,r)=>{e.set(r,n)}),e},Wn=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},jL=(t,e)=>{const n=[];for(const[r,s]of t)n.push(e(s,r));return n},$L=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},Xr=()=>new Set,sd=t=>t[t.length-1],BL=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},Zr=Array.from,Vf=(t,e)=>{for(let n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},Wf=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},zL=(t,e)=>{const n=new Array(t);for(let r=0;r<t;r++)n[r]=e(r,n);return n},Us=Array.isArray;class m1{constructor(){this._observers=on()}on(e,n){return Wn(this._observers,e,Xr).add(n),n}once(e,n){const r=(...s)=>{this.off(e,r),n(...s)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return Zr((this._observers.get(e)||on()).values()).forEach(r=>r(...n))}destroy(){this._observers=on()}}const an=Math.floor,Wl=Math.abs,Vs=(t,e)=>t<e?t:e,br=(t,e)=>t>e?t:e,g1=t=>t!==0?t<0:1/t<0,ay=1,cy=2,id=4,od=8,go=32,zn=64,Mt=128,HL=1<<29,Dc=31,fh=63,zr=127,FL=2147483647,qa=Number.MAX_SAFE_INTEGER,uy=Number.MIN_SAFE_INTEGER,UL=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&an(t)===t),y1=String.fromCharCode,VL=t=>t.toLowerCase(),WL=/^\s*/g,qL=t=>t.replace(WL,""),KL=/([A-Z])/g,dy=(t,e)=>qL(t.replace(KL,n=>`${e}${VL(n)}`)),JL=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},yo=typeof TextEncoder<"u"?new TextEncoder:null,GL=t=>yo.encode(t),YL=yo?GL:JL;let Ji=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Ji&&Ji.decode(new Uint8Array).length===1&&(Ji=null);const XL=(t,e)=>zL(e,()=>t).join("");class Po{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const jo=()=>new Po,ZL=t=>{const e=jo();return t(e),sn(e)},QL=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},sn=t=>{const e=new Uint8Array(QL(t));let n=0;for(let r=0;r<t.bufs.length;r++){const s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},eI=(t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(br(n,e)*2),t.cpos=0)},et=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},ph=et,ye=(t,e)=>{for(;e>zr;)et(t,Mt|zr&e),e=an(e/128);et(t,zr&e)},qf=(t,e)=>{const n=g1(e);for(n&&(e=-e),et(t,(e>fh?Mt:0)|(n?zn:0)|fh&e),e=an(e/64);e>0;)et(t,(e>zr?Mt:0)|zr&e),e=an(e/128)},mh=new Uint8Array(3e4),tI=mh.length/3,nI=(t,e)=>{if(e.length<tI){const n=yo.encodeInto(e,mh).written||0;ye(t,n);for(let r=0;r<n;r++)et(t,mh[r])}else Bt(t,YL(e))},rI=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;ye(t,r);for(let s=0;s<r;s++)et(t,n.codePointAt(s))},As=yo&&yo.encodeInto?nI:rI,Lc=(t,e)=>{const n=t.cbuf.length,r=t.cpos,s=Vs(n-r,e.length),i=e.length-s;t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,i>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(br(n*2,i)),t.cbuf.set(e.subarray(s)),t.cpos=i)},Bt=(t,e)=>{ye(t,e.byteLength),Lc(t,e)},Kf=(t,e)=>{eI(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},sI=(t,e)=>Kf(t,4).setFloat32(0,e,!1),iI=(t,e)=>Kf(t,8).setFloat64(0,e,!1),oI=(t,e)=>Kf(t,8).setBigInt64(0,e,!1),hy=new DataView(new ArrayBuffer(4)),lI=t=>(hy.setFloat32(0,t),hy.getFloat32(0)===t),Ws=(t,e)=>{switch(typeof e){case"string":et(t,119),As(t,e);break;case"number":UL(e)&&Wl(e)<=FL?(et(t,125),qf(t,e)):lI(e)?(et(t,124),sI(t,e)):(et(t,123),iI(t,e));break;case"bigint":et(t,122),oI(t,e);break;case"object":if(e===null)et(t,126);else if(Us(e)){et(t,117),ye(t,e.length);for(let n=0;n<e.length;n++)Ws(t,e[n])}else if(e instanceof Uint8Array)et(t,116),Bt(t,e);else{et(t,118);const n=Object.keys(e);ye(t,n.length);for(let r=0;r<n.length;r++){const s=n[r];As(t,s),Ws(t,e[s])}}break;case"boolean":et(t,e?120:121);break;default:et(t,127)}};class fy extends Po{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&ye(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const py=t=>{t.count>0&&(qf(t.encoder,t.count===1?t.s:-t.s),t.count>1&&ye(t.encoder,t.count-2))};class ql{constructor(){this.encoder=new Po,this.s=0,this.count=0}write(e){this.s===e?this.count++:(py(this),this.count=1,this.s=e)}toUint8Array(){return py(this),sn(this.encoder)}}const my=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);qf(t.encoder,e),t.count>1&&ye(t.encoder,t.count-2)}};class ld{constructor(){this.encoder=new Po,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(my(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return my(this),sn(this.encoder)}}class aI{constructor(){this.sarr=[],this.s="",this.lensE=new ql}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new Po;return this.sarr.push(this.s),this.s="",As(e,this.sarr.join("")),Lc(e,this.lensE.toUint8Array()),sn(e)}}const Cn=t=>new Error(t),Zt=()=>{throw Cn("Method unimplemented")},Rt=()=>{throw Cn("Unexpected case")},b1=Cn("Unexpected end of array"),x1=Cn("Integer out of Range");class Ic{constructor(e){this.arr=e,this.pos=0}}const Jf=t=>new Ic(t),cI=t=>t.pos!==t.arr.length,uI=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},qt=t=>uI(t,Oe(t)),bo=t=>t.arr[t.pos++],Oe=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const s=t.arr[t.pos++];if(e=e+(s&zr)*n,n*=128,s<Mt)return e;if(e>qa)throw x1}throw b1},Gf=t=>{let e=t.arr[t.pos++],n=e&fh,r=64;const s=(e&zn)>0?-1:1;if((e&Mt)===0)return s*n;const i=t.arr.length;for(;t.pos<i;){if(e=t.arr[t.pos++],n=n+(e&zr)*r,r*=128,e<Mt)return s*n;if(n>qa)throw x1}throw b1},dI=t=>{let e=Oe(t);if(e===0)return"";{let n=String.fromCodePoint(bo(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(bo(t));else for(;e>0;){const r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},hI=t=>Ji.decode(qt(t)),gh=Ji?hI:dI,Yf=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},fI=t=>Yf(t,4).getFloat32(0,!1),pI=t=>Yf(t,8).getFloat64(0,!1),mI=t=>Yf(t,8).getBigInt64(0,!1),gI=[t=>{},t=>null,Gf,fI,pI,mI,t=>!1,t=>!0,gh,t=>{const e=Oe(t),n={};for(let r=0;r<e;r++){const s=gh(t);n[s]=Ka(t)}return n},t=>{const e=Oe(t),n=[];for(let r=0;r<e;r++)n.push(Ka(t));return n},qt],Ka=t=>gI[127-bo(t)](t);class gy extends Ic{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),cI(this)?this.count=Oe(this)+1:this.count=-1),this.count--,this.s}}class Kl extends Ic{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Gf(this);const e=g1(this.s);this.count=1,e&&(this.s=-this.s,this.count=Oe(this)+2)}return this.count--,this.s}}class ad extends Ic{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=Gf(this),n=e&1;this.diff=an(e/2),this.count=1,n&&(this.count=Oe(this)+2)}return this.s+=this.diff,this.count--,this.s}}class yI{constructor(e){this.decoder=new Kl(e),this.str=gh(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const bI=crypto.getRandomValues.bind(crypto),xI=Math.random,w1=()=>bI(new Uint32Array(1))[0],wI=t=>t[an(xI()*t.length)],kI="10000000-1000-4000-8000"+-1e11,vI=()=>kI.replace(/[018]/g,t=>(t^w1()&15>>t/4).toString(16)),SI=Date.now,yy=t=>new Promise(t);Promise.all.bind(Promise);const by=t=>t===void 0?null:t;class CI{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let k1=new CI,EI=!0;try{typeof localStorage<"u"&&localStorage&&(k1=localStorage,EI=!1)}catch{}const AI=k1,xo=Symbol("Equality"),v1=(t,e)=>t===e||!!t?.[xo]?.(e)||!1,MI=t=>typeof t=="object",TI=Object.assign,S1=Object.keys,NI=(t,e)=>{for(const n in t)e(t[n],n)},Ja=t=>S1(t).length,RI=t=>{for(const e in t)return!1;return!0},ni=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},Xf=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),_I=(t,e)=>t===e||Ja(t)===Ja(e)&&ni(t,(n,r)=>(n!==void 0||Xf(e,r))&&v1(e[r],n)),OI=Object.freeze,C1=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&C1(t[e])}return OI(t)},Zf=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&Zf(t,e,n+1)}},Jl=(t,e)=>{if(t===e)return!0;if(t==null||e==null||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(t[xo]!=null)return t[xo](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:{if(t.byteLength!==e.byteLength)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break}case Set:{if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;break}case Map:{if(t.size!==e.size)return!1;for(const n of t.keys())if(!e.has(n)||!Jl(t.get(n),e.get(n)))return!1;break}case void 0:case Object:if(Ja(t)!==Ja(e))return!1;for(const n in t)if(!Xf(t,n)||!Jl(t[n],e[n]))return!1;break;case Array:if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(!Jl(t[n],e[n]))return!1;break;default:return!1}return!0},DI=(t,e)=>e.includes(t),qs=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",E1=typeof window<"u"&&typeof document<"u"&&!qs;let gn;const LI=()=>{if(gn===void 0)if(qs){gn=on();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&gn.set(e,""),e=r):e!==null&&(gn.set(e,r),e=null)}e!==null&&gn.set(e,"")}else typeof location=="object"?(gn=on(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");gn.set(`--${dy(e,"-")}`,n),gn.set(`-${dy(e,"-")}`,n)}})):gn=on();return gn},yh=t=>LI().has(t),Ga=t=>by(qs?process.env[t.toUpperCase().replaceAll("-","_")]:AI.getItem(t)),A1=t=>yh("--"+t)||Ga(t)!==null,II=A1("production"),PI=qs&&DI(process.env.FORCE_COLOR,["true","1","2"]),jI=PI||!yh("--no-colors")&&!A1("no-color")&&(!qs||process.stdout.isTTY)&&(!qs||yh("--color")||Ga("COLORTERM")!==null||(Ga("TERM")||"").includes("color")),$I=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=y1(t[n]);return btoa(e)},BI=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),zI=E1?$I:BI,HI=t=>ZL(e=>Ws(e,t));class FI{constructor(e,n){this.left=e,this.right=n}}const _n=(t,e)=>new FI(t,e),xy=t=>t.next()>=.5,cd=(t,e,n)=>an(t.next()*(n+1-e)+e),M1=(t,e,n)=>an(t.next()*(n+1-e)+e),Qf=(t,e,n)=>M1(t,e,n),UI=t=>y1(Qf(t,97,122)),VI=(t,e=0,n=20)=>{const r=Qf(t,e,n);let s="";for(let i=0;i<r;i++)s+=UI(t);return s},ud=(t,e)=>e[Qf(t,0,e.length-1)],WI=Symbol("0schema");class qI{constructor(){this._rerrs=[]}extend(e,n,r,s=null){this._rerrs.push({path:e,expected:n,has:r,message:s})}toString(){const e=[];for(let n=this._rerrs.length-1;n>0;n--){const r=this._rerrs[n];e.push(XL(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return e.join(`
161
+ `)}}const bh=(t,e)=>t===e?!0:t==null||e==null||t.constructor!==e.constructor?!1:t[xo]?v1(t,e):Us(t)?Vf(t,n=>Wf(e,r=>bh(n,r))):MI(t)?ni(t,(n,r)=>bh(n,e[r])):!1;class _t{static _dilutes=!1;extends(e){let[n,r]=[this.shape,e.shape];return this.constructor._dilutes&&([r,n]=[n,r]),bh(n,r)}equals(e){return this.constructor===e.constructor&&Jl(this.shape,e.shape)}[WI](){return!0}[xo](e){return this.equals(e)}validate(e){return this.check(e)}check(e,n){Zt()}get nullable(){return ri(this,zc)}get optional(){return new R1(this)}cast(e){return wy(e,this),e}expect(e){return wy(e,this),e}}class ep extends _t{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n=void 0){const r=e?.constructor===this.shape&&(this._c==null||this._c(e));return!r&&n?.extend(null,this.shape.name,e?.constructor.name,e?.constructor!==this.shape?"Constructor match failed":"Check failed"),r}}const Ge=(t,e=null)=>new ep(t,e);Ge(ep);class tp extends _t{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape(e);return!r&&n?.extend(null,"custom prop",e?.constructor.name,"failed to check custom prop"),r}}const st=t=>new tp(t);Ge(tp);class Pc extends _t{constructor(e){super(),this.shape=e}check(e,n){const r=this.shape.some(s=>s===e);return!r&&n?.extend(null,this.shape.join(" | "),e.toString()),r}}const jc=(...t)=>new Pc(t),T1=Ge(Pc),KI=RegExp.escape||(t=>t.replace(/[().|&,$^[\]]/g,e=>"\\"+e)),N1=t=>{if(Ks.check(t))return[KI(t)];if(T1.check(t))return t.shape.map(e=>e+"");if(B1.check(t))return["[+-]?\\d+.?\\d*"];if(z1.check(t))return[".*"];if(Ya.check(t))return t.shape.map(N1).flat(1);Rt()};class JI extends _t{constructor(e){super(),this.shape=e,this._r=new RegExp("^"+e.map(N1).map(n=>`(${n.join("|")})`).join("")+"$")}check(e,n){const r=this._r.exec(e)!=null;return!r&&n?.extend(null,this._r.toString(),e.toString(),"String doesn't match string template."),r}}Ge(JI);const GI=Symbol("optional");class R1 extends _t{constructor(e){super(),this.shape=e}check(e,n){const r=e===void 0||this.shape.check(e);return!r&&n?.extend(null,"undefined (optional)","()"),r}get[GI](){return!0}}const YI=Ge(R1);class XI extends _t{check(e,n){return n?.extend(null,"never",typeof e),!1}}Ge(XI);class $c extends _t{constructor(e,n=!1){super(),this.shape=e,this._isPartial=n}static _dilutes=!0;get partial(){return new $c(this.shape,!0)}check(e,n){return e==null?(n?.extend(null,"object","null"),!1):ni(this.shape,(r,s)=>{const i=this._isPartial&&!Xf(e,s)||r.check(e[s],n);return!i&&n?.extend(s.toString(),r.toString(),typeof e[s],"Object property does not match"),i})}}const ZI=t=>new $c(t),QI=Ge($c),e2=st(t=>t!=null&&(t.constructor===Object||t.constructor==null));class _1 extends _t{constructor(e,n){super(),this.shape={keys:e,values:n}}check(e,n){return e!=null&&ni(e,(r,s)=>{const i=this.shape.keys.check(s,n);return!i&&n?.extend(s+"","Record",typeof e,i?"Key doesn't match schema":"Value doesn't match value"),i&&this.shape.values.check(r,n)})}}const O1=(t,e)=>new _1(t,e),t2=Ge(_1);class D1 extends _t{constructor(e){super(),this.shape=e}check(e,n){return e!=null&&ni(this.shape,(r,s)=>{const i=r.check(e[s],n);return!i&&n?.extend(s.toString(),"Tuple",typeof r),i})}}const n2=(...t)=>new D1(t);Ge(D1);class L1 extends _t{constructor(e){super(),this.shape=e.length===1?e[0]:new np(e)}check(e,n){const r=Us(e)&&Vf(e,s=>this.shape.check(s));return!r&&n?.extend(null,"Array",""),r}}const I1=(...t)=>new L1(t),r2=Ge(L1),s2=st(t=>Us(t));class P1 extends _t{constructor(e,n){super(),this.shape=e,this._c=n}check(e,n){const r=e instanceof this.shape&&(this._c==null||this._c(e));return!r&&n?.extend(null,this.shape.name,e?.constructor.name),r}}const i2=(t,e=null)=>new P1(t,e);Ge(P1);const o2=i2(_t);class l2 extends _t{constructor(e){super(),this.len=e.length-1,this.args=n2(...e.slice(-1)),this.res=e[this.len]}check(e,n){const r=e.constructor===Function&&e.length<=this.len;return!r&&n?.extend(null,"function",typeof e),r}}const a2=Ge(l2),c2=st(t=>typeof t=="function");class u2 extends _t{constructor(e){super(),this.shape=e}check(e,n){const r=Vf(this.shape,s=>s.check(e,n));return!r&&n?.extend(null,"Intersectinon",typeof e),r}}Ge(u2,t=>t.shape.length>0);class np extends _t{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,n){const r=Wf(this.shape,s=>s.check(e,n));return n?.extend(null,"Union",typeof e),r}}const ri=(...t)=>t.findIndex(e=>Ya.check(e))>=0?ri(...t.map(e=>wo(e)).map(e=>Ya.check(e)?e.shape:[e]).flat(1)):t.length===1?t[0]:new np(t),Ya=Ge(np),j1=()=>!0,Xa=st(j1),d2=Ge(tp,t=>t.shape===j1),rp=st(t=>typeof t=="bigint"),h2=st(t=>t===rp),$1=st(t=>typeof t=="symbol");st(t=>t===$1);const Ms=st(t=>typeof t=="number"),B1=st(t=>t===Ms),Ks=st(t=>typeof t=="string"),z1=st(t=>t===Ks),Bc=st(t=>typeof t=="boolean"),f2=st(t=>t===Bc),H1=jc(void 0);Ge(Pc,t=>t.shape.length===1&&t.shape[0]===void 0);jc(void 0);const zc=jc(null),p2=Ge(Pc,t=>t.shape.length===1&&t.shape[0]===null);Ge(Uint8Array);Ge(ep,t=>t.shape===Uint8Array);const m2=ri(Ms,Ks,zc,H1,rp,Bc,$1);(()=>{const t=I1(Xa),e=O1(Ks,Xa),n=ri(Ms,Ks,zc,Bc,t,e);return t.shape=n,e.shape.values=n,n})();const wo=t=>{if(o2.check(t))return t;if(e2.check(t)){const e={};for(const n in t)e[n]=wo(t[n]);return ZI(e)}else{if(s2.check(t))return ri(...t.map(wo));if(m2.check(t))return jc(t);if(c2.check(t))return Ge(t)}Rt()},wy=II?()=>{}:(t,e)=>{const n=new qI;if(!e.check(t,n))throw Cn(`Expected value to be of type ${e.constructor.name}.
162
+ ${n.toString()}`)};class g2{constructor(e){this.patterns=[],this.$state=e}if(e,n){return this.patterns.push({if:wo(e),h:n}),this}else(e){return this.if(Xa,e)}done(){return(e,n)=>{for(let r=0;r<this.patterns.length;r++){const s=this.patterns[r];if(s.if.check(e))return s.h(e,n)}throw Cn("Unhandled pattern")}}}const y2=t=>new g2(t),F1=y2(Xa).if(B1,(t,e)=>cd(e,uy,qa)).if(z1,(t,e)=>VI(e)).if(f2,(t,e)=>xy(e)).if(h2,(t,e)=>BigInt(cd(e,uy,qa))).if(Ya,(t,e)=>fs(e,ud(e,t.shape))).if(QI,(t,e)=>{const n={};for(const r in t.shape){let s=t.shape[r];if(YI.check(s)){if(xy(e))continue;s=s.shape}n[r]=F1(s,e)}return n}).if(r2,(t,e)=>{const n=[],r=M1(e,0,42);for(let s=0;s<r;s++)n.push(fs(e,t.shape));return n}).if(T1,(t,e)=>ud(e,t.shape)).if(p2,(t,e)=>null).if(a2,(t,e)=>{const n=fs(e,t.res);return()=>n}).if(d2,(t,e)=>fs(e,ud(e,[Ms,Ks,zc,H1,rp,Bc,I1(Ms),O1(ri("a","b","c"),Ms)]))).if(t2,(t,e)=>{const n={},r=cd(e,0,3);for(let s=0;s<r;s++){const i=fs(e,t.shape.keys),o=fs(e,t.shape.values);n[i]=o}return n}).done(),fs=(t,e)=>F1(wo(e),t),$o=typeof document<"u"?document:{};st(t=>t.nodeType===v2);typeof DOMParser<"u"&&new DOMParser;st(t=>t.nodeType===x2);st(t=>t.nodeType===w2);const b2=t=>jL(t,(e,n)=>`${n}:${e};`).join(""),x2=$o.ELEMENT_NODE,w2=$o.TEXT_NODE,k2=$o.DOCUMENT_NODE,v2=$o.DOCUMENT_FRAGMENT_NODE;st(t=>t.nodeType===k2);const S2=t=>class{constructor(n){this._=n}destroy(){t(this._)}},C2=S2(clearTimeout),U1=(t,e)=>new C2(setTimeout(e,t)),qn=Symbol,V1=qn(),W1=qn(),E2=qn(),A2=qn(),M2=qn(),q1=qn(),T2=qn(),sp=qn(),N2=qn(),R2=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r<t.length;r++){const s=t[r];if(s===void 0)break;if(s.constructor===String||s.constructor===Number)e.push(s);else if(s.constructor===Object)break}for(r>0&&n.push(e.join(""));r<t.length;r++){const s=t[r];s instanceof Symbol||n.push(s)}return n},_2={[V1]:_n("font-weight","bold"),[W1]:_n("font-weight","normal"),[E2]:_n("color","blue"),[M2]:_n("color","green"),[A2]:_n("color","grey"),[q1]:_n("color","red"),[T2]:_n("color","purple"),[sp]:_n("color","orange"),[N2]:_n("color","black")},O2=t=>{t.length===1&&t[0]?.constructor===Function&&(t=t[0]());const e=[],n=[],r=on();let s=[],i=0;for(;i<t.length;i++){const o=t[i],l=_2[o];if(l!==void 0)r.set(l.left,l.right);else{if(o===void 0)break;if(o.constructor===String||o.constructor===Number){const a=b2(r);i>0||a.length>0?(e.push("%c"+o),n.push(a)):e.push(o)}else break}}for(i>0&&(s=n,s.unshift(e.join("")));i<t.length;i++){const o=t[i];o instanceof Symbol||s.push(o)}return s},K1=jI?O2:R2,D2=(...t)=>{console.log(...K1(t)),G1.forEach(e=>e.print(t))},J1=(...t)=>{console.warn(...K1(t)),t.unshift(sp),G1.forEach(e=>e.print(t))},G1=Xr(),Y1=t=>({[Symbol.iterator](){return this},next:t}),L2=(t,e)=>Y1(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),dd=(t,e)=>Y1(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class Hc{constructor(e,n){this.clock=e,this.len=n}}class si{constructor(){this.clients=new Map}}const xr=(t,e,n)=>e.clients.forEach((r,s)=>{const i=t.doc.store.clients.get(s);if(i!=null){const o=i[i.length-1],l=o.id.clock+o.length;for(let a=0,c=r[a];a<r.length&&c.clock<l;c=r[++a])sk(t,i,c.clock,c.len,n)}}),I2=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const s=an((n+r)/2),i=t[s],o=i.clock;if(o<=e){if(e<o+i.len)return s;n=s+1}else r=s-1}return null},ii=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&I2(n,e.clock)!==null},ip=t=>{t.clients.forEach(e=>{e.sort((s,i)=>s.clock-i.clock);let n,r;for(n=1,r=1;n<e.length;n++){const s=e[r-1],i=e[n];s.clock+s.len>=i.clock?e[r-1]=new Hc(s.clock,br(s.len,i.clock+i.len-s.clock)):(r<n&&(e[r]=i),r++)}e.length=r})},xh=t=>{const e=new si;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){const i=r.slice();for(let o=n+1;o<t.length;o++)BL(i,t[o].clients.get(s)||[]);e.clients.set(s,i)}});return ip(e),e},ko=(t,e,n,r)=>{Wn(t.clients,e,()=>[]).push(new Hc(n,r))},X1=()=>new si,P2=t=>{const e=X1();return t.clients.forEach((n,r)=>{const s=[];for(let i=0;i<n.length;i++){const o=n[i];if(o.deleted){const l=o.id.clock;let a=o.length;if(i+1<n.length)for(let c=n[i+1];i+1<n.length&&c.deleted;c=n[++i+1])a+=c.length;s.push(new Hc(l,a))}}s.length>0&&e.clients.set(r,s)}),e},op=(t,e)=>{ye(t.restEncoder,e.clients.size),Zr(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),ye(t.restEncoder,n);const s=r.length;ye(t.restEncoder,s);for(let i=0;i<s;i++){const o=r[i];t.writeDsClock(o.clock),t.writeDsLen(o.len)}})},j2=t=>{const e=new si,n=Oe(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const s=Oe(t.restDecoder),i=Oe(t.restDecoder);if(i>0){const o=Wn(e.clients,s,()=>[]);for(let l=0;l<i;l++)o.push(new Hc(t.readDsClock(),t.readDsLen()))}}return e},ky=(t,e,n)=>{const r=new si,s=Oe(t.restDecoder);for(let i=0;i<s;i++){t.resetDsCurVal();const o=Oe(t.restDecoder),l=Oe(t.restDecoder),a=n.clients.get(o)||[],c=Ue(n,o);for(let u=0;u<l;u++){const d=t.readDsClock(),h=d+t.readDsLen();if(d<c){c<h&&ko(r,o,c,h-c);let f=cn(a,d),p=a[f];for(!p.deleted&&p.id.clock<d&&(a.splice(f+1,0,sc(e,p,d-p.id.clock)),f++);f<a.length&&(p=a[f++],p.id.clock<h);)p.deleted||(h<p.id.clock+p.length&&a.splice(f,0,sc(e,p,h-p.id.clock)),p.delete(e))}else ko(r,o,d,h-d)}}if(r.clients.size>0){const i=new Fc;return ye(i.restEncoder,0),op(i,r),i.toUint8Array()}return null},Z1=w1;class ss extends m1{constructor({guid:e=vI(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:l=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=Z1(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new nk,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=yy(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const a=()=>yy(c=>{const u=d=>{(d===void 0||d===!0)&&(this.off("sync",u),c())};this.on("sync",u)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=a()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=a()}load(){const e=this._item;e!==null&&!this.shouldLoad&&Ee(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Zr(this.subdocs).map(e=>e.guid))}transact(e,n=null){return Ee(this,e,n)}get(e,n=rt){const r=Wn(this.share,e,()=>{const i=new n;return i._integrate(this,null),i}),s=r.constructor;if(n!==rt&&s!==n)if(s===rt){const i=new n;i._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(e,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,Rs)}getText(e=""){return this.get(e,wr)}getMap(e=""){return this.get(e,Js)}getXmlElement(e=""){return this.get(e,At)}getXmlFragment(e=""){return this.get(e,Qr)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,Zr(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new ss({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,Ee(e.parent.doc,r=>{const s=n.doc;e.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class $2{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Oe(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Oe(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Za extends $2{constructor(e){super(e),this.keys=[],Oe(e),this.keyClockDecoder=new ad(qt(e)),this.clientDecoder=new Kl(qt(e)),this.leftClockDecoder=new ad(qt(e)),this.rightClockDecoder=new ad(qt(e)),this.infoDecoder=new gy(qt(e),bo),this.stringDecoder=new yI(qt(e)),this.parentInfoDecoder=new gy(qt(e),bo),this.typeRefDecoder=new Kl(qt(e)),this.lenDecoder=new Kl(qt(e))}readLeftID(){return new Ts(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Ts(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Ka(this.restDecoder)}readBuf(){return qt(this.restDecoder)}readJSON(){return Ka(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class B2{constructor(){this.restEncoder=jo()}toUint8Array(){return sn(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){ye(this.restEncoder,e)}writeDsLen(e){ye(this.restEncoder,e)}}class z2 extends B2{writeLeftID(e){ye(this.restEncoder,e.client),ye(this.restEncoder,e.clock)}writeRightID(e){ye(this.restEncoder,e.client),ye(this.restEncoder,e.clock)}writeClient(e){ye(this.restEncoder,e)}writeInfo(e){ph(this.restEncoder,e)}writeString(e){As(this.restEncoder,e)}writeParentInfo(e){ye(this.restEncoder,e?1:0)}writeTypeRef(e){ye(this.restEncoder,e)}writeLen(e){ye(this.restEncoder,e)}writeAny(e){Ws(this.restEncoder,e)}writeBuf(e){Bt(this.restEncoder,e)}writeJSON(e){As(this.restEncoder,JSON.stringify(e))}writeKey(e){As(this.restEncoder,e)}}class H2{constructor(){this.restEncoder=jo(),this.dsCurrVal=0}toUint8Array(){return sn(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,ye(this.restEncoder,n)}writeDsLen(e){e===0&&Rt(),ye(this.restEncoder,e-1),this.dsCurrVal+=e}}class Fc extends H2{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new ld,this.clientEncoder=new ql,this.leftClockEncoder=new ld,this.rightClockEncoder=new ld,this.infoEncoder=new fy(ph),this.stringEncoder=new aI,this.parentInfoEncoder=new fy(ph),this.typeRefEncoder=new ql,this.lenEncoder=new ql}toUint8Array(){const e=jo();return ye(e,0),Bt(e,this.keyClockEncoder.toUint8Array()),Bt(e,this.clientEncoder.toUint8Array()),Bt(e,this.leftClockEncoder.toUint8Array()),Bt(e,this.rightClockEncoder.toUint8Array()),Bt(e,sn(this.infoEncoder)),Bt(e,this.stringEncoder.toUint8Array()),Bt(e,sn(this.parentInfoEncoder)),Bt(e,this.typeRefEncoder.toUint8Array()),Bt(e,this.lenEncoder.toUint8Array()),Lc(e,sn(this.restEncoder)),sn(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Ws(this.restEncoder,e)}writeBuf(e){Bt(this.restEncoder,e)}writeJSON(e){Ws(this.restEncoder,e)}writeKey(e){const n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}}const F2=(t,e,n,r)=>{r=br(r,e[0].id.clock);const s=cn(e,r);ye(t.restEncoder,e.length-s),t.writeClient(n),ye(t.restEncoder,r);const i=e[s];i.write(t,r-i.id.clock);for(let o=s+1;o<e.length;o++)e[o].write(t,0)},Q1=(t,e,n)=>{const r=new Map;n.forEach((s,i)=>{Ue(e,i)>s&&r.set(i,s)}),Uc(e).forEach((s,i)=>{n.has(i)||r.set(i,0)}),ye(t.restEncoder,r.size),Zr(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{F2(t,e.clients.get(s),s,i)})},U2=(t,e)=>{const n=on(),r=Oe(t.restDecoder);for(let s=0;s<r;s++){const i=Oe(t.restDecoder),o=new Array(i),l=t.readClient();let a=Oe(t.restDecoder);n.set(l,{i:0,refs:o});for(let c=0;c<i;c++){const u=t.readInfo();switch(Dc&u){case 0:{const d=t.readLen();o[c]=new Gt(he(l,a),d),a+=d;break}case 10:{const d=Oe(t.restDecoder);o[c]=new rn(he(l,a),d),a+=d;break}default:{const d=(u&(zn|Mt))===0,h=new ve(he(l,a),null,(u&Mt)===Mt?t.readLeftID():null,null,(u&zn)===zn?t.readRightID():null,d?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,d&&(u&go)===go?t.readString():null,Ak(t,u));o[c]=h,a+=h.length}}}}return n},V2=(t,e,n)=>{const r=[];let s=Zr(n.keys()).sort((f,p)=>f-p);if(s.length===0)return null;const i=()=>{if(s.length===0)return null;let f=n.get(s[s.length-1]);for(;f.refs.length===f.i;)if(s.pop(),s.length>0)f=n.get(s[s.length-1]);else return null;return f};let o=i();if(o===null)return null;const l=new nk,a=new Map,c=(f,p)=>{const m=a.get(f);(m==null||m>p)&&a.set(f,p)};let u=o.refs[o.i++];const d=new Map,h=()=>{for(const f of r){const p=f.id.client,m=n.get(p);m?(m.i--,l.clients.set(p,m.refs.slice(m.i)),n.delete(p),m.i=0,m.refs=[]):l.clients.set(p,[f]),s=s.filter(y=>y!==p)}r.length=0};for(;;){if(u.constructor!==rn){const p=Wn(d,u.id.client,()=>Ue(e,u.id.client))-u.id.clock;if(p<0)r.push(u),c(u.id.client,u.id.clock-1),h();else{const m=u.getMissing(t,e);if(m!==null){r.push(u);const y=n.get(m)||{refs:[],i:0};if(y.refs.length===y.i)c(m,Ue(e,m)),h();else{u=y.refs[y.i++];continue}}else(p===0||p<u.length)&&(u.integrate(t,p),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=i(),o===null)break;u=o.refs[o.i++]}}if(l.clients.size>0){const f=new Fc;return Q1(f,l,new Map),ye(f.restEncoder,0),{missing:a,update:f.toUint8Array()}}return null},W2=(t,e)=>Q1(t,e.doc.store,e.beforeState),q2=(t,e,n,r=new Za(t))=>Ee(e,s=>{s.local=!1;let i=!1;const o=s.doc,l=o.store,a=U2(r,o),c=V2(s,l,a),u=l.pendingStructs;if(u){for(const[h,f]of u.missing)if(f<Ue(l,h)){i=!0;break}if(c){for(const[h,f]of c.missing){const p=u.missing.get(h);(p==null||p>f)&&u.missing.set(h,f)}u.update=Ry([u.update,c.update])}}else l.pendingStructs=c;const d=ky(r,s,l);if(l.pendingDs){const h=new Za(Jf(l.pendingDs));Oe(h.restDecoder);const f=ky(h,s,l);d&&f?l.pendingDs=Ry([d,f]):l.pendingDs=d||f}else l.pendingDs=d;if(i){const h=l.pendingStructs.update;l.pendingStructs=null,wh(s.doc,h)}},n,!1),wh=(t,e,n,r=Za)=>{const s=Jf(e);q2(s,t,n,new r(s))};class K2{constructor(){this.l=[]}}const vy=()=>new K2,Sy=(t,e)=>t.l.push(e),Cy=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(s=>e!==s),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},ek=(t,e,n)=>Zf(t.l,[e,n]);class Ts{constructor(e,n){this.client=e,this.clock=n}}const El=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,he=(t,e)=>new Ts(t,e),vo=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Rt()},So=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class Qa{constructor(e,n,r,s=0){this.type=e,this.tname=n,this.item=r,this.assoc=s}}class J2{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const G2=(t,e,n=0)=>new J2(t,e,n),Al=(t,e,n)=>{let r=null,s=null;return t._item===null?s=vo(t):r=he(t._item.id.client,t._item.id.clock),new Qa(r,s,e,n)},hd=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Al(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Al(t,he(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Al(t,r.lastId,n);r=r.right}return Al(t,null,n)},Y2=(t,e)=>{const n=Ns(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},X2=(t,e,n=!0)=>{const r=e.store,s=t.item,i=t.type,o=t.tname,l=t.assoc;let a=null,c=0;if(s!==null){if(Ue(r,s.client)<=s.clock)return null;const u=n?Ch(r,s):Y2(r,s),d=u.item;if(!(d instanceof ve))return null;if(a=d.parent,a._item===null||!a._item.deleted){c=d.deleted||!d.countable?0:u.diff+(l>=0?0:1);let h=d.left;for(;h!==null;)!h.deleted&&h.countable&&(c+=h.length),h=h.left}}else{if(o!==null)a=e.get(o);else if(i!==null){if(Ue(r,i.client)<=i.clock)return null;const{item:u}=n?Ch(r,i):{item:Ns(r,i)};if(u instanceof ve&&u.content instanceof fn)a=u.content.type;else return null}else throw Rt();l>=0?c=a._length:c=0}return G2(a,c,t.assoc)};class lp{constructor(e,n){this.ds=e,this.sv=n}}const tk=(t,e)=>new lp(t,e),fd=t=>tk(P2(t.store),Uc(t.store)),Nr=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!ii(e.ds,t.id),kh=(t,e)=>{const n=Wn(t.meta,kh,Xr),r=t.doc.store;n.has(e)||(e.sv.forEach((s,i)=>{s<Ue(r,i)&&It(t,he(i,s))}),xr(t,e.ds,s=>{}),n.add(e))};class nk{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Uc=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},Ue=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},rk=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw Rt()}n.push(e)},cn=(t,e)=>{let n=0,r=t.length-1,s=t[r],i=s.id.clock;if(i===e)return r;let o=an(e/(i+s.length-1)*r);for(;n<=r;){if(s=t[o],i=s.id.clock,i<=e){if(e<i+s.length)return o;n=o+1}else r=o-1;o=an((n+r)/2)}throw Rt()},Z2=(t,e)=>{const n=t.clients.get(e.client);return n[cn(n,e.clock)]},Ns=Z2,vh=(t,e,n)=>{const r=cn(e,n),s=e[r];return s.id.clock<n&&s instanceof ve?(e.splice(r+1,0,sc(t,s,n-s.id.clock)),r+1):r},It=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[vh(t,n,e.clock)]},Ey=(t,e,n)=>{const r=e.clients.get(n.client),s=cn(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==Gt&&r.splice(s+1,0,sc(t,i,n.clock-i.id.clock+1)),i},Q2=(t,e,n)=>{const r=t.clients.get(e.id.client);r[cn(r,e.id.clock)]=n},sk=(t,e,n,r,s)=>{if(r===0)return;const i=n+r;let o=vh(t,e,n),l;do l=e[o++],i<l.id.clock+l.length&&vh(t,e,i),s(l);while(o<e.length&&e[o].id.clock<i)};class eP{constructor(e,n,r){this.doc=e,this.deleteSet=new si,this.beforeState=Uc(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const Ay=(t,e)=>e.deleteSet.clients.size===0&&!$L(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(ip(e.deleteSet),W2(t,e),op(t,e.deleteSet),!0),My=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&Wn(t.changed,e,Xr).add(n)},Gl=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof ve&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const i=e-s;return i&&t.splice(e+1-i,i),i},tP=(t,e,n)=>{for(const[r,s]of t.clients.entries()){const i=e.clients.get(r);for(let o=s.length-1;o>=0;o--){const l=s[o],a=l.clock+l.len;for(let c=cn(i,l.clock),u=i[c];c<i.length&&u.id.clock<a;u=i[++c]){const d=i[c];if(l.clock+l.len<=d.id.clock)break;d instanceof ve&&d.deleted&&!d.keep&&n(d)&&d.gc(e,!1)}}}},nP=(t,e)=>{t.clients.forEach((n,r)=>{const s=e.clients.get(r);for(let i=n.length-1;i>=0;i--){const o=n[i],l=Vs(s.length-1,1+cn(s,o.clock+o.len-1));for(let a=l,c=s[a];a>0&&c.id.clock>=o.clock;c=s[a])a-=1+Gl(s,a)}})},ik=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{ip(i),n.afterState=Uc(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const l=[];n.changed.forEach((a,c)=>l.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(n,a)})),l.push(()=>{n.changedParentTypes.forEach((a,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(a=a.filter(u=>u.target._item===null||!u.target._item.deleted),a.forEach(u=>{u.currentTarget=c,u._path=null}),a.sort((u,d)=>u.path.length-d.path.length),l.push(()=>{ek(c._dEH,a,n)}))}),l.push(()=>r.emit("afterTransaction",[n,r])),l.push(()=>{n._needFormattingCleanup&&vP(n)})}),Zf(l,[])}finally{r.gc&&tP(i,s,r.gcFilter),nP(i,s),n.afterState.forEach((u,d)=>{const h=n.beforeState.get(d)||0;if(h!==u){const f=s.clients.get(d),p=br(cn(f,h),1);for(let m=f.length-1;m>=p;)m-=1+Gl(f,m)}});for(let u=o.length-1;u>=0;u--){const{client:d,clock:h}=o[u].id,f=s.clients.get(d),p=cn(f,h);p+1<f.length&&Gl(f,p+1)>1||p>0&&Gl(f,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(D2(sp,V1,"[yjs] ",W1,q1,"Changed the client-id because another client seems to be using it."),r.clientID=Z1()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const u=new z2;Ay(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const u=new Fc;Ay(u,n)&&r.emit("updateV2",[u.toUint8Array(),n.origin,r,n])}const{subdocsAdded:l,subdocsLoaded:a,subdocsRemoved:c}=n;(l.size>0||c.size>0||a.size>0)&&(l.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),c.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:a,added:l,removed:c},r,n]),c.forEach(u=>u.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):ik(t,e+1)}}},Ee=(t,e,n=null,r=!0)=>{const s=t._transactionCleanups;let i=!1,o=null;t._transaction===null&&(i=!0,t._transaction=new eP(t,n,r),s.push(t._transaction),s.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(i){const l=t._transaction===s[0];t._transaction=null,l&&ik(s,0)}}return o};class rP{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const Ty=(t,e,n)=>{xr(t,n.deletions,r=>{r instanceof ve&&e.scope.some(s=>s===t.doc||So(s,r))&&hp(r,!1)})},Ny=(t,e,n)=>{let r=null;const s=t.doc,i=t.scope;Ee(s,l=>{for(;e.length>0&&t.currStackItem===null;){const a=s.store,c=e.pop(),u=new Set,d=[];let h=!1;xr(l,c.insertions,f=>{if(f instanceof ve){if(f.redone!==null){let{item:p,diff:m}=Ch(a,f.id);m>0&&(p=It(l,he(p.id.client,p.id.clock+m))),f=p}!f.deleted&&i.some(p=>p===l.doc||So(p,f))&&d.push(f)}}),xr(l,c.deletions,f=>{f instanceof ve&&i.some(p=>p===l.doc||So(p,f))&&!ii(c.insertions,f.id)&&u.add(f)}),u.forEach(f=>{h=Ek(l,f,u,c.insertions,t.ignoreRemoteMapChanges,t)!==null||h});for(let f=d.length-1;f>=0;f--){const p=d[f];t.deleteFilter(p)&&(p.delete(l),h=!0)}t.currStackItem=h?c:null}l.changed.forEach((a,c)=>{a.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=l},t);const o=t.currStackItem;if(o!=null){const l=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return o};class ok extends m1{constructor(e,{captureTimeout:n=500,captureTransaction:r=a=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:l=Us(e)?e[0].doc:e instanceof ss?e:e.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(e),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=a=>{if(!this.captureTransaction(a)||!this.scope.some(y=>a.changedParentTypes.has(y)||y===this.doc)||!this.trackedOrigins.has(a.origin)&&(!a.origin||!this.trackedOrigins.has(a.origin.constructor)))return;const c=this.undoing,u=this.redoing,d=c?this.redoStack:this.undoStack;c?this.stopCapturing():u||this.clear(!1,!0);const h=new si;a.afterState.forEach((y,b)=>{const x=a.beforeState.get(b)||0,w=y-x;w>0&&ko(h,b,x,w)});const f=SI();let p=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&d.length>0&&!c&&!u){const y=d[d.length-1];y.deletions=xh([y.deletions,a.deleteSet]),y.insertions=xh([y.insertions,h])}else d.push(new rP(a.deleteSet,h)),p=!0;!c&&!u&&(this.lastChange=f),xr(a,a.deleteSet,y=>{y instanceof ve&&this.scope.some(b=>b===a.doc||So(b,y))&&hp(y,!0)});const m=[{stackItem:d[d.length-1],origin:a.origin,type:c?"redo":"undo",changedParentTypes:a.changedParentTypes},this];p?this.emit("stack-item-added",m):this.emit("stack-item-updated",m)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const n=new Set(this.scope);e=Us(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof rt?r.doc!==this.doc:r!==this.doc)&&J1("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(s=>Ty(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>Ty(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Ny(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Ny(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*sP(t){const e=Oe(t.restDecoder);for(let n=0;n<e;n++){const r=Oe(t.restDecoder),s=t.readClient();let i=Oe(t.restDecoder);for(let o=0;o<r;o++){const l=t.readInfo();if(l===10){const a=Oe(t.restDecoder);yield new rn(he(s,i),a),i+=a}else if((Dc&l)!==0){const a=(l&(zn|Mt))===0,c=new ve(he(s,i),null,(l&Mt)===Mt?t.readLeftID():null,null,(l&zn)===zn?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(l&go)===go?t.readString():null,Ak(t,l));yield c,i+=c.length}else{const a=t.readLen();yield new Gt(he(s,i),a),i+=a}}}}class iP{constructor(e,n){this.gen=sP(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===rn);return this.curr}}class oP{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const lP=(t,e)=>{if(t.constructor===Gt){const{client:n,clock:r}=t.id;return new Gt(he(n,r+e),t.length-e)}else if(t.constructor===rn){const{client:n,clock:r}=t.id;return new rn(he(n,r+e),t.length-e)}else{const n=t,{client:r,clock:s}=n.id;return new ve(he(r,s+e),null,he(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},Ry=(t,e=Za,n=Fc)=>{if(t.length===1)return t[0];const r=t.map(u=>new e(Jf(u)));let s=r.map(u=>new iP(u,!0)),i=null;const o=new n,l=new oP(o);for(;s=s.filter(h=>h.curr!==null),s.sort((h,f)=>{if(h.curr.id.client===f.curr.id.client){const p=h.curr.id.clock-f.curr.id.clock;return p===0?h.curr.constructor===f.curr.constructor?0:h.curr.constructor===rn?1:-1:p}else return f.curr.id.client-h.curr.id.client}),s.length!==0;){const u=s[0],d=u.curr.id.client;if(i!==null){let h=u.curr,f=!1;for(;h!==null&&h.id.clock+h.length<=i.struct.id.clock+i.struct.length&&h.id.client>=i.struct.id.client;)h=u.next(),f=!0;if(h===null||h.id.client!==d||f&&h.id.clock>i.struct.id.clock+i.struct.length)continue;if(d!==i.struct.id.client)gi(l,i.struct,i.offset),i={struct:h,offset:0},u.next();else if(i.struct.id.clock+i.struct.length<h.id.clock)if(i.struct.constructor===rn)i.struct.length=h.id.clock+h.length-i.struct.id.clock;else{gi(l,i.struct,i.offset);const p=h.id.clock-i.struct.id.clock-i.struct.length;i={struct:new rn(he(d,i.struct.id.clock+i.struct.length),p),offset:0}}else{const p=i.struct.id.clock+i.struct.length-h.id.clock;p>0&&(i.struct.constructor===rn?i.struct.length-=p:h=lP(h,p)),i.struct.mergeWith(h)||(gi(l,i.struct,i.offset),i={struct:h,offset:0},u.next())}}else i={struct:u.curr,offset:0},u.next();for(let h=u.curr;h!==null&&h.id.client===d&&h.id.clock===i.struct.id.clock+i.struct.length&&h.constructor!==rn;h=u.next())gi(l,i.struct,i.offset),i={struct:h,offset:0}}i!==null&&(gi(l,i.struct,i.offset),i=null),aP(l);const a=r.map(u=>j2(u)),c=xh(a);return op(o,c),o.toUint8Array()},lk=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:sn(t.encoder.restEncoder)}),t.encoder.restEncoder=jo(),t.written=0)},gi=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&lk(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),ye(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},aP=t=>{lk(t);const e=t.encoder.restEncoder;ye(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];ye(e,r.written),Lc(e,r.restEncoder)}},_y="You must not compute changes after the event-handler fired.";class Vc{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=cP(this.currentTarget,this.target))}deletes(e){return ii(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Cn(_y);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){const i=n._map.get(s);let o,l;if(this.adds(i)){let a=i.left;for(;a!==null&&this.adds(a);)a=a.left;if(this.deletes(i))if(a!==null&&this.deletes(a))o="delete",l=sd(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",l=sd(a.content.getContent())):(o="add",l=void 0)}else if(this.deletes(i))o="delete",l=sd(i.content.getContent());else return;e.set(s,{action:o,oldValue:l})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Cn(_y);const n=this.target,r=Xr(),s=Xr(),i=[];if(e={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let l=null;const a=()=>{l&&i.push(l)};for(let c=n._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((l===null||l.delete===void 0)&&(a(),l={delete:0}),l.delete+=c.length,s.add(c)):this.adds(c)?((l===null||l.insert===void 0)&&(a(),l={insert:[]}),l.insert=l.insert.concat(c.content.getContent()),r.add(c)):((l===null||l.retain===void 0)&&(a(),l={retain:0}),l.retain+=c.length);l!==null&&l.retain===void 0&&a()}this._changes=e}return e}}const cP=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;n.unshift(r)}e=e._item.parent}return n},mt=()=>{J1("Invalid access: Add Yjs type to a document before reading data.")},ak=80;let ap=0;class uP{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=ap++}}const dP=t=>{t.timestamp=ap++},ck=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=ap++},hP=(t,e,n)=>{if(t.length>=ak){const r=t.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return ck(r,e,n),r}else{const r=new uP(e,n);return t.push(r),r}},Wc=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((i,o)=>Wl(e-i.index)<Wl(e-o.index)?i:o);let r=t._start,s=0;for(n!==null&&(r=n.p,s=n.index,dP(n));r.right!==null&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return n!==null&&Wl(n.index-s)<r.parent.length/ak?(ck(n,r,s),n):hP(t._searchMarker,r,s)},Co=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const s=t[r];if(n>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){t.splice(r,1);continue}s.p=i,i.marker=!0}(e<s.index||n>0&&e===s.index)&&(s.index=br(e,s.index+n))}},qc=(t,e,n)=>{const r=t,s=e.changedParentTypes;for(;Wn(s,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;ek(r._eH,n,e)};class rt{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=vy(),this._dEH=vy(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw Zt()}clone(){throw Zt()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){Sy(this._eH,e)}observeDeep(e){Sy(this._dEH,e)}unobserve(e){Cy(this._eH,e)}unobserveDeep(e){Cy(this._dEH,e)}toJSON(){}}const uk=(t,e,n)=>{t.doc??mt(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const s=[];let i=t._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){const o=i.content.getContent();if(o.length<=e)e-=o.length;else{for(let l=e;l<o.length&&r>0;l++)s.push(o[l]),r--;e=0}}i=i.right}return s},dk=t=>{t.doc??mt();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e},hk=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&Nr(r,e)){const s=r.content.getContent();for(let i=0;i<s.length;i++)n.push(s[i])}r=r.right}return n},Eo=(t,e)=>{let n=0,r=t._start;for(t.doc??mt();r!==null;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let i=0;i<s.length;i++)e(s[i],n++,t)}r=r.right}},fk=(t,e)=>{const n=[];return Eo(t,(r,s)=>{n.push(e(r,s,t))}),n},fP=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},pk=(t,e)=>{t.doc??mt();const n=Wc(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},ec=(t,e,n,r)=>{let s=n;const i=t.doc,o=i.clientID,l=i.store,a=n===null?e._start:n.right;let c=[];const u=()=>{c.length>0&&(s=new ve(he(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new es(c)),s.integrate(t,0),c=[])};r.forEach(d=>{if(d===null)c.push(d);else switch(d.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(d);break;default:switch(u(),d.constructor){case Uint8Array:case ArrayBuffer:s=new ve(he(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new Bo(new Uint8Array(d))),s.integrate(t,0);break;case ss:s=new ve(he(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new zo(d)),s.integrate(t,0);break;default:if(d instanceof rt)s=new ve(he(o,Ue(l,o)),s,s&&s.lastId,a,a&&a.id,e,null,new fn(d)),s.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},mk=()=>Cn("Length exceeded!"),gk=(t,e,n,r)=>{if(n>e._length)throw mk();if(n===0)return e._searchMarker&&Co(e._searchMarker,n,r.length),ec(t,e,null,r);const s=n,i=Wc(e,n);let o=e._start;for(i!==null&&(o=i.p,n-=i.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&It(t,he(o.id.client,o.id.clock+n));break}n-=o.length}return e._searchMarker&&Co(e._searchMarker,s,r.length),ec(t,e,o,r)},pP=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:e._start}).p;if(s)for(;s.right;)s=s.right;return ec(t,e,s,n)},yk=(t,e,n,r)=>{if(r===0)return;const s=n,i=r,o=Wc(e,n);let l=e._start;for(o!==null&&(l=o.p,n-=o.index);l!==null&&n>0;l=l.right)!l.deleted&&l.countable&&(n<l.length&&It(t,he(l.id.client,l.id.clock+n)),n-=l.length);for(;r>0&&l!==null;)l.deleted||(r<l.length&&It(t,he(l.id.client,l.id.clock+r)),l.delete(t),r-=l.length),l=l.right;if(r>0)throw mk();e._searchMarker&&Co(e._searchMarker,s,-i+r)},tc=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},cp=(t,e,n,r)=>{const s=e._map.get(n)||null,i=t.doc,o=i.clientID;let l;if(r==null)l=new es([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new es([r]);break;case Uint8Array:l=new Bo(r);break;case ss:l=new zo(r);break;default:if(r instanceof rt)l=new fn(r);else throw new Error("Unexpected content type")}new ve(he(o,Ue(i.store,o)),s,s&&s.lastId,null,null,e,n,l).integrate(t,0)},up=(t,e)=>{t.doc??mt();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},bk=t=>{const e={};return t.doc??mt(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},xk=(t,e)=>{t.doc??mt();const n=t._map.get(e);return n!==void 0&&!n.deleted},mP=(t,e)=>{const n={};return t._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&&Nr(i,e)&&(n[s]=i.content.getContent()[i.length-1])}),n},Ml=t=>(t.doc??mt(),L2(t._map.entries(),e=>!e[1].deleted));class gP extends Vc{}class Rs extends rt{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new Rs;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Rs}clone(){const e=new Rs;return e.insert(0,this.toArray().map(n=>n instanceof rt?n.clone():n)),e}get length(){return this.doc??mt(),this._length}_callObserver(e,n){super._callObserver(e,n),qc(this,e,new gP(this,e))}insert(e,n){this.doc!==null?Ee(this.doc,r=>{gk(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?Ee(this.doc,n=>{pP(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?Ee(this.doc,r=>{yk(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return pk(this,e)}toArray(){return dk(this)}slice(e=0,n=this.length){return uk(this,e,n)}toJSON(){return this.map(e=>e instanceof rt?e.toJSON():e)}map(e){return fk(this,e)}forEach(e){Eo(this,e)}[Symbol.iterator](){return fP(this)}_write(e){e.writeTypeRef(HP)}}const yP=t=>new Rs;class bP extends Vc{constructor(e,n,r){super(e,n),this.keysChanged=r}}class Js extends rt{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new Js}clone(){const e=new Js;return this.forEach((n,r)=>{e.set(r,n instanceof rt?n.clone():n)}),e}_callObserver(e,n){qc(this,e,new bP(this,e,n))}toJSON(){this.doc??mt();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const s=n.content.getContent()[n.length-1];e[r]=s instanceof rt?s.toJSON():s}}),e}get size(){return[...Ml(this)].length}keys(){return dd(Ml(this),e=>e[0])}values(){return dd(Ml(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return dd(Ml(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??mt(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?Ee(this.doc,n=>{tc(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?Ee(this.doc,r=>{cp(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return up(this,e)}has(e){return xk(this,e)}clear(){this.doc!==null?Ee(this.doc,e=>{this.forEach(function(n,r,s){tc(e,s,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(FP)}}const xP=t=>new Js,lr=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&_I(t,e);class Sh{constructor(e,n,r,s){this.left=e,this.right=n,this.index=r,this.currentAttributes=s}forward(){this.right===null&&Rt(),this.right.content.constructor===Je?this.right.deleted||oi(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const Oy=(t,e,n)=>{for(;e.right!==null&&n>0;)e.right.content.constructor===Je?e.right.deleted||oi(e.currentAttributes,e.right.content):e.right.deleted||(n<e.right.length&&It(t,he(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length),e.left=e.right,e.right=e.right.right;return e},Tl=(t,e,n,r)=>{const s=new Map,i=r?Wc(e,n):null;if(i){const o=new Sh(i.p.left,i.p,i.index,s);return Oy(t,o,n-i.index)}else{const o=new Sh(null,e._start,0,s);return Oy(t,o,n)}},wk=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Je&&lr(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const s=t.doc,i=s.clientID;r.forEach((o,l)=>{const a=n.left,c=n.right,u=new ve(he(i,Ue(s.store,i)),a,a&&a.lastId,c,c&&c.id,e,null,new Je(l,o));u.integrate(t,0),n.right=u,n.forward()})},oi=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},kk=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Je&&lr(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},vk=(t,e,n,r)=>{const s=t.doc,i=s.clientID,o=new Map;for(const l in r){const a=r[l],c=n.currentAttributes.get(l)??null;if(!lr(c,a)){o.set(l,c);const{left:u,right:d}=n;n.right=new ve(he(i,Ue(s.store,i)),u,u&&u.lastId,d,d&&d.id,e,null,new Je(l,a)),n.right.integrate(t,0),n.forward()}}return o},pd=(t,e,n,r,s)=>{n.currentAttributes.forEach((h,f)=>{s[f]===void 0&&(s[f]=null)});const i=t.doc,o=i.clientID;kk(n,s);const l=vk(t,e,n,s),a=r.constructor===String?new un(r):r instanceof rt?new fn(r):new is(r);let{left:c,right:u,index:d}=n;e._searchMarker&&Co(e._searchMarker,n.index,a.getLength()),u=new ve(he(o,Ue(i.store,o)),c,c&&c.lastId,u,u&&u.id,e,null,a),u.integrate(t,0),n.right=u,n.index=d,n.forward(),wk(t,e,n,l)},Dy=(t,e,n,r,s)=>{const i=t.doc,o=i.clientID;kk(n,s);const l=vk(t,e,n,s);e:for(;n.right!==null&&(r>0||l.size>0&&(n.right.deleted||n.right.content.constructor===Je));){if(!n.right.deleted)switch(n.right.content.constructor){case Je:{const{key:a,value:c}=n.right.content,u=s[a];if(u!==void 0){if(lr(u,c))l.delete(a);else{if(r===0)break e;l.set(a,c)}n.right.delete(t)}else n.currentAttributes.set(a,c);break}default:r<n.right.length&&It(t,he(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
163
+ `;n.right=new ve(he(o,Ue(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new un(a)),n.right.integrate(t,0),n.forward()}wk(t,e,n,l)},Sk=(t,e,n,r,s)=>{let i=e;const o=on();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===Je){const c=i.content;o.set(c.key,c)}i=i.right}let l=0,a=!1;for(;e!==i;){if(n===e&&(a=!0),!e.deleted){const c=e.content;if(c.constructor===Je){const{key:u,value:d}=c,h=r.get(u)??null;(o.get(u)!==c||h===d)&&(e.delete(t),l++,!a&&(s.get(u)??null)===d&&h!==d&&(h===null?s.delete(u):s.set(u,h))),!a&&!e.deleted&&oi(s,c)}}e=e.right}return l},wP=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Je){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},kP=t=>{let e=0;return Ee(t.doc,n=>{let r=t._start,s=t._start,i=on();const o=hh(i);for(;s;)s.deleted===!1&&(s.content.constructor===Je?oi(o,s.content):(e+=Sk(n,r,s,i,o),i=hh(o),r=s)),s=s.right}),e},vP=t=>{const e=new Set,n=t.doc;for(const[r,s]of t.afterState.entries()){const i=t.beforeState.get(r)||0;s!==i&&sk(t,n.store.clients.get(r),i,s,o=>{!o.deleted&&o.content.constructor===Je&&o.constructor!==Gt&&e.add(o.parent)})}Ee(n,r=>{xr(t,t.deleteSet,s=>{if(s instanceof Gt||!s.parent._hasFormatting||e.has(s.parent))return;const i=s.parent;s.content.constructor===Je?e.add(i):wP(r,s)});for(const s of e)kP(s)})},Ly=(t,e,n)=>{const r=n,s=hh(e.currentAttributes),i=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case fn:case is:case un:n<e.right.length&&It(t,he(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}i&&Sk(t,i,e.right,s,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&Co(o._searchMarker,e.index,-r+n),e};class SP extends Vc{constructor(e,n,r){super(e,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(s=>{s===null?this.childListChanged=!0:this.keysChanged.add(s)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,n=[];Ee(e,r=>{const s=new Map,i=new Map;let o=this.target._start,l=null;const a={};let c="",u=0,d=0;const h=()=>{if(l!==null){let f=null;switch(l){case"delete":d>0&&(f={delete:d}),d=0;break;case"insert":(typeof c=="object"||c.length>0)&&(f={insert:c},s.size>0&&(f.attributes={},s.forEach((p,m)=>{p!==null&&(f.attributes[m]=p)}))),c="";break;case"retain":u>0&&(f={retain:u},RI(a)||(f.attributes=TI({},a))),u=0;break}f&&n.push(f),l=null}};for(;o!==null;){switch(o.content.constructor){case fn:case is:this.adds(o)?this.deletes(o)||(h(),l="insert",c=o.content.getContent()[0],h()):this.deletes(o)?(l!=="delete"&&(h(),l="delete"),d+=1):o.deleted||(l!=="retain"&&(h(),l="retain"),u+=1);break;case un:this.adds(o)?this.deletes(o)||(l!=="insert"&&(h(),l="insert"),c+=o.content.str):this.deletes(o)?(l!=="delete"&&(h(),l="delete"),d+=o.length):o.deleted||(l!=="retain"&&(h(),l="retain"),u+=o.length);break;case Je:{const{key:f,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){const m=s.get(f)??null;lr(m,p)?p!==null&&o.delete(r):(l==="retain"&&h(),lr(p,i.get(f)??null)?delete a[f]:a[f]=p)}}else if(this.deletes(o)){i.set(f,p);const m=s.get(f)??null;lr(m,p)||(l==="retain"&&h(),a[f]=m)}else if(!o.deleted){i.set(f,p);const m=a[f];m!==void 0&&(lr(m,p)?m!==null&&o.delete(r):(l==="retain"&&h(),p===null?delete a[f]:a[f]=p))}o.deleted||(l==="insert"&&h(),oi(s,o.content));break}}o=o.right}for(h();n.length>0;){const f=n[n.length-1];if(f.retain!==void 0&&f.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class wr extends rt{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??mt(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new wr}clone(){const e=new wr;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new SP(this,e,n);qc(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??mt();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===un&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?Ee(this.doc,r=>{const s=new Sh(null,this._start,0,new Map);for(let i=0;i<e.length;i++){const o=e[i];if(o.insert!==void 0){const l=!n&&typeof o.insert=="string"&&i===e.length-1&&s.right===null&&o.insert.slice(-1)===`
164
+ `?o.insert.slice(0,-1):o.insert;(typeof l!="string"||l.length>0)&&pd(r,this,s,l,o.attributes||{})}else o.retain!==void 0?Dy(r,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&Ly(r,s,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??mt();const s=[],i=new Map,o=this.doc;let l="",a=this._start;function c(){if(l.length>0){const d={};let h=!1;i.forEach((p,m)=>{h=!0,d[m]=p});const f={insert:l};h&&(f.attributes=d),s.push(f),l=""}}const u=()=>{for(;a!==null;){if(Nr(a,e)||n!==void 0&&Nr(a,n))switch(a.content.constructor){case un:{const d=i.get("ychange");e!==void 0&&!Nr(a,e)?(d===void 0||d.user!==a.id.client||d.type!=="removed")&&(c(),i.set("ychange",r?r("removed",a.id):{type:"removed"})):n!==void 0&&!Nr(a,n)?(d===void 0||d.user!==a.id.client||d.type!=="added")&&(c(),i.set("ychange",r?r("added",a.id):{type:"added"})):d!==void 0&&(c(),i.delete("ychange")),l+=a.content.str;break}case fn:case is:{c();const d={insert:a.content.getContent()[0]};if(i.size>0){const h={};d.attributes=h,i.forEach((f,p)=>{h[p]=f})}s.push(d);break}case Je:Nr(a,e)&&(c(),oi(i,a.content));break}a=a.right}c()};return e||n?Ee(o,d=>{e&&kh(d,e),n&&kh(d,n),u()},"cleanup"):u(),s}insert(e,n,r){if(n.length<=0)return;const s=this.doc;s!==null?Ee(s,i=>{const o=Tl(i,this,e,!r);r||(r={},o.currentAttributes.forEach((l,a)=>{r[a]=l})),pd(i,this,o,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const s=this.doc;s!==null?Ee(s,i=>{const o=Tl(i,this,e,!r);pd(i,this,o,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;const r=this.doc;r!==null?Ee(r,s=>{Ly(s,Tl(s,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const s=this.doc;s!==null?Ee(s,i=>{const o=Tl(i,this,e,!1);o.right!==null&&Dy(i,this,o,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?Ee(this.doc,n=>{tc(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?Ee(this.doc,r=>{cp(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return up(this,e)}getAttributes(){return bk(this)}_write(e){e.writeTypeRef(UP)}}const CP=t=>new wr;class md{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??mt()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===At||n.constructor===Qr)&&n._start!==null)e=n._start;else for(;e!==null;){const r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class Qr extends rt{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Qr}clone(){const e=new Qr;return e.insert(0,this.toArray().map(n=>n instanceof rt?n.clone():n)),e}get length(){return this.doc??mt(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new md(this,e)}querySelector(e){e=e.toUpperCase();const r=new md(this,s=>s.nodeName&&s.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),Zr(new md(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){qc(this,e,new MP(this,n,e))}toString(){return fk(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const s=e.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),Eo(this,i=>{s.insertBefore(i.toDOM(e,n,r),null)}),s}insert(e,n){this.doc!==null?Ee(this.doc,r=>{gk(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)Ee(this.doc,r=>{const s=e&&e instanceof rt?e._item:e;ec(r,this,s,n)});else{const r=this._prelimContent,s=e===null?0:r.findIndex(i=>i===e)+1;if(s===0&&e!==null)throw Cn("Reference item not found");r.splice(s,0,...n)}}delete(e,n=1){this.doc!==null?Ee(this.doc,r=>{yk(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return dk(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return pk(this,e)}slice(e=0,n=this.length){return uk(this,e,n)}forEach(e){Eo(this,e)}_write(e){e.writeTypeRef(WP)}}const EP=t=>new Qr;class At extends Qr{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new At(this.nodeName)}clone(){const e=new At(this.nodeName),n=this.getAttributes();return NI(n,(r,s)=>{e.setAttribute(s,r)}),e.insert(0,this.toArray().map(r=>r instanceof rt?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const l in e)r.push(l);r.sort();const s=r.length;for(let l=0;l<s;l++){const a=r[l];n.push(a+'="'+e[a]+'"')}const i=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(e){this.doc!==null?Ee(this.doc,n=>{tc(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?Ee(this.doc,r=>{cp(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return up(this,e)}hasAttribute(e){return xk(this,e)}getAttributes(e){return e?mP(this,e):bk(this)}toDOM(e=document,n={},r){const s=e.createElement(this.nodeName),i=this.getAttributes();for(const o in i){const l=i[o];typeof l=="string"&&s.setAttribute(o,l)}return Eo(this,o=>{s.appendChild(o.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef(VP),e.writeKey(this.nodeName)}}const AP=t=>new At(t.readKey());class MP extends Vc{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}}class nc extends Js{constructor(e){super(),this.hookName=e}_copy(){return new nc(this.hookName)}clone(){const e=new nc(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const s=n[this.hookName];let i;return s!==void 0?i=s.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(qP),e.writeKey(this.hookName)}}const TP=t=>new nc(t.readKey());class Ut extends wr{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new Ut}clone(){const e=new Ut;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const s=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(e=>{const n=[];for(const s in e.attributes){const i=[];for(const o in e.attributes[s])i.push({key:o,value:e.attributes[s][o]});i.sort((o,l)=>o.key<l.key?-1:1),n.push({nodeName:s,attrs:i})}n.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<n.length;s++){const i=n[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){const l=i.attrs[o];r+=` ${l.key}="${l.value}"`}r+=">"}r+=e.insert;for(let s=n.length-1;s>=0;s--)r+=`</${n[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(KP)}}const NP=t=>new Ut;class dp{constructor(e,n){this.id=e,this.length=n}get deleted(){throw Zt()}mergeWith(e){return!1}write(e,n,r){throw Zt()}integrate(e,n){throw Zt()}}const RP=0;class Gt extends dp{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),rk(e.doc.store,this)}write(e,n){e.writeInfo(RP),e.writeLen(this.length-n)}getMissing(e,n){return null}}class Bo{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Bo(this.content)}splice(e){throw Zt()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const _P=t=>new Bo(t.readBuf());class Ao{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Ao(this.len)}splice(e){const n=new Ao(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){ko(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const OP=t=>new Ao(t.readLen()),Ck=(t,e)=>new ss({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class zo{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new zo(Ck(this.doc.guid,this.opts))}splice(e){throw Zt()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const DP=t=>new zo(Ck(t.readString(),t.readAny()));class is{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new is(this.embed)}splice(e){throw Zt()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const LP=t=>new is(t.readJSON());class Je{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Je(this.key,this.value)}splice(e){throw Zt()}mergeWith(e){return!1}integrate(e,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const IP=t=>new Je(t.readKey(),t.readJSON());class rc{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new rc(this.arr)}splice(e){const n=new rc(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const i=this.arr[s];e.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}const PP=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const s=t.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new rc(n)},jP=Ga("node_env")==="development";class es{constructor(e){this.arr=e,jP&&C1(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new es(this.arr)}splice(e){const n=new es(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const i=this.arr[s];e.writeAny(i)}}getRef(){return 8}}const $P=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new es(n)};class un{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new un(this.str)}splice(e){const n=new un(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const BP=t=>new un(t.readString()),zP=[yP,xP,CP,AP,EP,TP,NP],HP=0,FP=1,UP=2,VP=3,WP=4,qP=5,KP=6;class fn{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new fn(this.type._copy())}splice(e){throw Zt()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const JP=t=>new fn(zP[t.readTypeRef()](t)),Ch=(t,e)=>{let n=e,r=0,s;do r>0&&(n=he(n.client,n.clock+r)),s=Ns(t,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof ve);return{item:s,diff:r}},hp=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},sc=(t,e,n)=>{const{client:r,clock:s}=e.id,i=new ve(he(r,s+n),e,he(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),e.redone!==null&&(i.redone=he(e.redone.client,e.redone.clock+n)),e.right=i,i.right!==null&&(i.right.left=i),t._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),e.length=n,i},Iy=(t,e)=>Wf(t,n=>ii(n.deletions,e)),Ek=(t,e,n,r,s,i)=>{const o=t.doc,l=o.store,a=o.clientID,c=e.redone;if(c!==null)return It(t,c);let u=e.parent._item,d=null,h;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Ek(t,u,n,r,s,i)===null))return null;for(;u.redone!==null;)u=It(t,u.redone)}const f=u===null?e.parent:u.content.type;if(e.parentSub===null){for(d=e.left,h=e;d!==null;){let b=d;for(;b!==null&&b.parent._item!==u;)b=b.redone===null?null:It(t,b.redone);if(b!==null&&b.parent._item===u){d=b;break}d=d.left}for(;h!==null;){let b=h;for(;b!==null&&b.parent._item!==u;)b=b.redone===null?null:It(t,b.redone);if(b!==null&&b.parent._item===u){h=b;break}h=h.right}}else{if(h=null,e.right&&!s){for(d=e;d!==null&&d.right!==null&&(d.right.redone||ii(r,d.right.id)||Iy(i.undoStack,d.right.id)||Iy(i.redoStack,d.right.id));)for(d=d.right;d.redone;)d=It(t,d.redone);if(d&&d.right!==null)return null}else d=f._map.get(e.parentSub)||null;d!==null&&d.parent._item!==u&&(d=f._map.get(e.parentSub)||null)}const p=Ue(l,a),m=he(a,p),y=new ve(m,d,d&&d.lastId,h,h&&h.id,f,e.parentSub,e.content.copy());return e.redone=m,hp(y,!0),y.integrate(t,0),y};class ve extends dp{constructor(e,n,r,s,i,o,l,a){super(e,a.getLength()),this.origin=r,this.left=n,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=l,this.redone=null,this.content=a,this.info=this.content.isCountable()?cy:0}set marker(e){(this.info&od)>0!==e&&(this.info^=od)}get marker(){return(this.info&od)>0}get keep(){return(this.info&ay)>0}set keep(e){this.keep!==e&&(this.info^=ay)}get countable(){return(this.info&cy)>0}get deleted(){return(this.info&id)>0}set deleted(e){this.deleted!==e&&(this.info^=id)}markDeleted(){this.info|=id}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Ue(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Ue(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Ts&&this.id.client!==this.parent.client&&this.parent.clock>=Ue(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Ey(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=It(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Gt||this.right&&this.right.constructor===Gt)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===ve?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===ve&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Ts){const r=Ns(n,this.parent);r.constructor===Gt?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=Ey(e,e.doc.store,he(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;const i=new Set,o=new Set;for(;s!==null&&s!==this.right;){if(o.add(s),i.add(s),El(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if(El(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(Ns(e.doc.store,s.origin)))i.has(Ns(e.doc.store,s.origin))||(r=s,i.clear());else break;s=s.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),rk(e.doc.store,this),this.content.integrate(e,this),My(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Gt(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:he(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&El(e.origin,this.lastId)&&this.right===e&&El(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),ko(e.deleteSet,this.id.client,this.id.clock,this.length),My(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw Rt();this.content.gc(e),n?Q2(e,this,new Gt(this.id,this.length)):this.content=new Ao(this.length)}write(e,n){const r=n>0?he(this.id.client,this.id.clock+n-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&Dc|(r===null?0:Mt)|(s===null?0:zn)|(i===null?0:go);if(e.writeInfo(o),r!==null&&e.writeLeftID(r),s!==null&&e.writeRightID(s),r===null&&s===null){const l=this.parent;if(l._item!==void 0){const a=l._item;if(a===null){const c=vo(l);e.writeParentInfo(!0),e.writeString(c)}else e.writeParentInfo(!1),e.writeLeftID(a.id)}else l.constructor===String?(e.writeParentInfo(!0),e.writeString(l)):l.constructor===Ts?(e.writeParentInfo(!1),e.writeLeftID(l)):Rt();i!==null&&e.writeString(i)}this.content.write(e,n)}}const Ak=(t,e)=>GP[e&Dc](t),GP=[()=>{Rt()},OP,PP,_P,BP,LP,IP,JP,$P,DP,()=>{Rt()}],YP=10;class rn extends dp{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){Rt()}write(e,n){e.writeInfo(YP),ye(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const Mk=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Tk="__ $YJS$ __";Mk[Tk]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Mk[Tk]=!0;const XP=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},ZP=/[\uD800-\uDBFF]/,QP=/[\uDC00-\uDFFF]/,ej=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&ZP.test(t[n-1])&&n--;r+n<t.length&&r+n<e.length&&t[t.length-r-1]===e[e.length-r-1];)r++;return r>0&&QP.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},tj=ej,kn=(t,e)=>t>>>e|t<<32-e,nj=t=>kn(t,2)^kn(t,13)^kn(t,22),rj=t=>kn(t,6)^kn(t,11)^kn(t,25),sj=t=>kn(t,7)^kn(t,18)^t>>>3,ij=t=>kn(t,17)^kn(t,19)^t>>>10,oj=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),lj=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class aj{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(lj),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let d=16;d<64;d++)n[d]=ij(n[d-2])+n[d-7]+sj(n[d-15])+n[d-16];let r=e[0],s=e[1],i=e[2],o=e[3],l=e[4],a=e[5],c=e[6],u=e[7];for(let d=0,h,f;d<64;d++)h=u+rj(l)+(l&a^~l&c)+oj[d]+n[d]>>>0,f=nj(r)+(r&s^r&i^s&i)>>>0,u=c,c=a,a=l,l=o+h>>>0,o=i,i=s,s=r,r=h+f>>>0;e[0]+=r,e[1]+=s,e[2]+=i,e[3]+=o,e[4]+=l,e[5]+=a,e[6]+=c,e[7]+=u}digest(e){let n=0;for(;n+56<=e.length;){let o=0;for(;o<16&&n+3<e.length;o++)this._W[o]=e[n++]<<24|e[n++]<<16|e[n++]<<8|e[n++];if(n%64!==0){for(this._W.fill(0,o,16);n<e.length;)this._W[o]|=e[n]<<(3-n%4)*8,n++;this._W[o]|=Mt<<(3-n%4)*8}this._updateHash()}const r=n%64!==0;this._W.fill(0,0,16);let s=0;for(;n<e.length;s++)for(let o=3;o>=0&&n<e.length;o--)this._W[s]|=e[n++]<<o*8;r||(this._W[s-(n%4===0?0:1)]|=Mt<<(3-n%4)*8),this._W[14]=e.byteLength/HL,this._W[15]=e.byteLength*8,this._updateHash();const i=new Uint8Array(32);for(let o=0;o<this._H.length;o++)for(let l=0;l<4;l++)i[o*4+l]=this._H[o]>>>(3-l)*8;return i}}const cj=t=>new aj().digest(t),Le=new ge("y-sync"),Hn=new ge("y-undo");new ge("yjs-cursor");const uj=t=>{for(let n=6;n<t.length;n++)t[n%6]=t[n%6]^t[n];return t.slice(0,6)},dj=t=>zI(uj(cj(HI(t)))),ic=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!ii(e.ds,t.id),hj=[{light:"#ecd44433",dark:"#ecd444"}],fj=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=Xr();t.forEach(s=>r.add(s)),e=e.filter(s=>!r.has(s))}t.set(n,wI(e))}return t.get(n)},pj=(t,{colors:e=hj,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:s=()=>{},mapping:i}={})=>{let o=!1;const l=new yj(t,i),a=new me({props:{editable:c=>{const u=Le.getState(c);return u.snapshot==null&&u.prevSnapshot==null}},key:Le,state:{init:(c,u)=>({type:t,doc:t.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(c,u)=>{const d=c.getMeta(Le);if(d!==void 0){u=Object.assign({},u);for(const h in d)u[h]=d[h]}return u.addToHistory=c.getMeta("addToHistory")!==!1,u.isChangeOrigin=d!==void 0&&!!d.isChangeOrigin,u.isUndoRedoOperation=d!==void 0&&!!d.isChangeOrigin&&!!d.isUndoRedoOperation,l.prosemirrorView!==null&&d!==void 0&&(d.snapshot!=null||d.prevSnapshot!=null)&&U1(0,()=>{l.prosemirrorView!=null&&(d.restore==null?l._renderSnapshot(d.snapshot,d.prevSnapshot,u):(l._renderSnapshot(d.snapshot,d.snapshot,u),delete u.restore,delete u.snapshot,delete u.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))}),u}},view:c=>(l.initView(c),i==null&&l._forceRerender(),s(),{update:()=>{const u=a.getState(c.state);if(u.snapshot==null&&u.prevSnapshot==null&&(o||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(o=!0,u.addToHistory===!1&&!u.isChangeOrigin){const d=Hn.getState(c.state),h=d&&d.undoManager;h&&h.stopCapturing()}l.mux(()=>{u.doc.transact(d=>{d.meta.set("addToHistory",u.addToHistory),l._prosemirrorChanged(c.state.doc)},Le)})}},destroy:()=>{l.destroy()}})});return a},mj=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new xn(t.doc));else if(e.type==="node"){const r=Gi(n.doc,n.type,e.anchor,n.mapping);t.setSelection(gj(t,r))}else{const r=Gi(n.doc,n.type,e.anchor,n.mapping),s=Gi(n.doc,n.type,e.head,n.mapping);r!==null&&s!==null&&t.setSelection(Q.between(t.doc.resolve(r),t.doc.resolve(s)))}},gj=(t,e)=>{const n=t.doc.resolve(e);return n.nodeAfter?Y.create(t.doc,e):Q.near(n)},Eh=(t,e)=>({type:e.selection.jsonID,anchor:lc(e.selection.anchor,t.type,t.mapping),head:lc(e.selection.head,t.type,t.mapping)});class yj{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=XP(),this.mapping=n,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=Eh(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(E1&&this._domSelectionInView===null&&(U1(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;const n=this.prosemirrorView._root.createRange();n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const s=n.getBoundingClientRect(),i=$o.documentElement;return s.bottom>=0&&s.right>=0&&s.left<=(window.innerWidth||i.clientWidth||0)&&s.top<=(window.innerHeight||i.clientHeight||0)}renderSnapshot(e,n){n||(n=tk(X1(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Le,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>Yl(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new F(j.from(e),0,0));n.setMeta(Le,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(s=>Yl(s,this.prosemirrorView.state.schema,this)).filter(s=>s!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new F(j.from(n),0,0));if(e){const s=Vs(br(e.anchor,0),r.doc.content.size),i=Vs(br(e.head,0),r.doc.content.size);r.setSelection(Q.create(r.doc,s,i))}this.prosemirrorView.dispatch(r.setMeta(Le,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let s=this.doc,i=this.type;if(e||(e=fd(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&Rt(),s=new ss({gc:!1}),wh(s,n),n=fd(s),wh(s,e),e=fd(s),i._item===null){const o=Array.from(this.doc.share.keys()).find(l=>this.doc.share.get(l)===this.type);i=s.getXmlFragment(o)}else{const o=s.store.clients.get(i._item.id.client)??[],l=cn(o,i._item.id.clock);i=o[l].content.type}this.mapping.clear(),this.mux(()=>{s.transact(o=>{const l=r.permanentUserData;l&&l.dss.forEach(d=>{xr(o,d,h=>{})});const a=(d,h)=>{const f=d==="added"?l.getUserByClientId(h.client):l.getUserByDeletedId(h);return{user:f,type:d,color:fj(r.colorMapping,r.colors,f)}},c=hk(i,new lp(n.ds,e.sv)).map(d=>!d._item.deleted||ic(d._item,e)||ic(d._item,n)?Yl(d,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,n,a):null).filter(d=>d!==null),u=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new F(j.from(c),0,0));this.prosemirrorView.dispatch(u.setMeta(Le,{isChangeOrigin:!0}))},Le)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=Le.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const s=(l,a)=>this.mapping.delete(a);xr(n,n.deleteSet,l=>{if(l.constructor===ve){const a=l.content.type;a&&this.mapping.delete(a)}}),n.changed.forEach(s),n.changedParentTypes.forEach(s);const i=this.type.toArray().map(l=>Nk(l,this.prosemirrorView.state.schema,this)).filter(l=>l!==null);let o=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new F(j.from(i),0,0));mj(o,this.beforeTransactionSelection,this),o=o.setMeta(Le,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof ok}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(e){this.doc.transact(()=>{Mh(this.doc,this.type,e,this),this.beforeTransactionSelection=Eh(this,this.prosemirrorView.state)},Le)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const Nk=(t,e,n,r,s,i)=>{const o=n.mapping.get(t);if(o===void 0){if(t instanceof At)return Yl(t,e,n,r,s,i);throw Zt()}return o},Yl=(t,e,n,r,s,i)=>{const o=[],l=a=>{if(a instanceof At){const c=Nk(a,e,n,r,s,i);c!==null&&o.push(c)}else{const c=a._item.right?.content?.type;c instanceof wr&&!c._item.deleted&&c._item.id.client===c.doc.clientID&&(a.applyDelta([{retain:a.length},...c.toDelta()]),c.doc.transact(d=>{c._item.delete(d)}));const u=bj(a,e,n,r,s,i);u!==null&&u.forEach(d=>{d!==null&&o.push(d)})}};r===void 0||s===void 0?t.toArray().forEach(l):hk(t,new lp(s.ds,r.sv)).forEach(l);try{const a=t.getAttributes(r);r!==void 0&&(ic(t._item,r)?ic(t._item,s)||(a.ychange=i?i("added",t._item.id):{type:"added"}):a.ychange=i?i("removed",t._item.id):{type:"removed"});const c=e.node(t.nodeName,a,o);return n.mapping.set(t,c),c}catch{return t.doc.transact(c=>{t._item.delete(c)},Le),n.mapping.delete(t),null}},bj=(t,e,n,r,s,i)=>{const o=[],l=t.toDelta(r,s,i);try{for(let a=0;a<l.length;a++){const c=l[a];o.push(e.text(c.insert,Cj(c.attributes,e)))}}catch{return t.doc.transact(c=>{t._item.delete(c)},Le),null}return o},xj=(t,e)=>{const n=new Ut,r=t.map(s=>({insert:s.text,attributes:Ok(s.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},wj=(t,e)=>{const n=new At(t.type.name);for(const r in t.attrs){const s=t.attrs[r];s!==null&&r!=="ychange"&&n.setAttribute(r,s)}return n.insert(0,Kc(t).map(r=>Ah(r,e))),e.mapping.set(n,t),n},Ah=(t,e)=>t instanceof Array?xj(t,e):wj(t,e),Py=t=>typeof t=="object"&&t!==null,fp=(t,e)=>{const n=Object.keys(t).filter(s=>t[s]!==null);let r=n.length===Object.keys(e).filter(s=>e[s]!==null).length;for(let s=0;s<n.length&&r;s++){const i=n[s],o=t[i],l=e[i];r=i==="ychange"||o===l||Py(o)&&Py(l)&&fp(o,l)}return r},Kc=t=>{const e=t.content.content,n=[];for(let r=0;r<e.length;r++){const s=e[r];if(s.isText){const i=[];for(let o=e[r];r<e.length&&o.isText;o=e[++r])i.push(o);r--,n.push(i)}else n.push(s)}return n},Rk=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,s)=>r.insert===e[s].text&&S1(r.attributes||{}).length===e[s].marks.length&&ni(r.attributes,(i,o)=>{const l=_k(o),a=e[s].marks;return a.find(u=>u.type.name===l)?fp(i,a.find(u=>u.type.name===l)?.attrs):!1}))},Mo=(t,e)=>{if(t instanceof At&&!(e instanceof Array)&&Th(t,e)){const n=Kc(e);return t._length===n.length&&fp(t.getAttributes(),e.attrs)&&t.toArray().every((r,s)=>Mo(r,n[s]))}return t instanceof Ut&&e instanceof Array&&Rk(t,e)},oc=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),jy=(t,e,n)=>{const r=t.toArray(),s=Kc(e),i=s.length,o=r.length,l=Vs(o,i);let a=0,c=0,u=!1;for(;a<l;a++){const d=r[a],h=s[a];if(oc(n.mapping.get(d),h))u=!0;else if(!Mo(d,h))break}for(;a+c<l;c++){const d=r[o-c-1],h=s[i-c-1];if(oc(n.mapping.get(d),h))u=!0;else if(!Mo(d,h))break}return{equalityFactor:a+c,foundMappedChild:u}},kj=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof un?e+=n.content.str:n.content instanceof Je&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},vj=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:s}=kj(t),i=e.map(c=>({insert:c.text,attributes:Object.assign({},r,Ok(c.marks,n))})),{insert:o,remove:l,index:a}=tj(s,i.map(c=>c.insert).join(""));t.delete(a,l),t.insert(a,o),t.applyDelta(i.map(c=>({retain:c.insert.length,attributes:c.attributes})))},Sj=/(.*)(--[a-zA-Z0-9+/=]{8})$/,_k=t=>Sj.exec(t)?.[1]??t,Cj=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(_k(r),t[r]));return n},Ok=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const s=Wn(e.isOMark,r.type,()=>!r.type.excludes(r.type));n[s?`${r.type.name}--${dj(r.toJSON())}`:r.type.name]=r.attrs}}),n},Mh=(t,e,n,r)=>{if(e instanceof At&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof At){const d=e.getAttributes(),h=n.attrs;for(const f in h)h[f]!==null?d[f]!==h[f]&&f!=="ychange"&&e.setAttribute(f,h[f]):e.removeAttribute(f);for(const f in d)h[f]===void 0&&e.removeAttribute(f)}const s=Kc(n),i=s.length,o=e.toArray(),l=o.length,a=Vs(i,l);let c=0,u=0;for(;c<a;c++){const d=o[c],h=s[c];if(!oc(r.mapping.get(d),h))if(Mo(d,h))r.mapping.set(d,h);else break}for(;u+c+1<a;u++){const d=o[l-u-1],h=s[i-u-1];if(!oc(r.mapping.get(d),h))if(Mo(d,h))r.mapping.set(d,h);else break}t.transact(()=>{for(;l-c-u>0&&i-c-u>0;){const h=o[c],f=s[c],p=o[l-u-1],m=s[i-u-1];if(h instanceof Ut&&f instanceof Array)Rk(h,f)||vj(h,f,r),c+=1;else{let y=h instanceof At&&Th(h,f),b=p instanceof At&&Th(p,m);if(y&&b){const x=jy(h,f,r),w=jy(p,m,r);x.foundMappedChild&&!w.foundMappedChild?b=!1:!x.foundMappedChild&&w.foundMappedChild||x.equalityFactor<w.equalityFactor?y=!1:b=!1}y?(Mh(t,h,f,r),c+=1):b?(Mh(t,p,m,r),u+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[Ah(f,r)]),c+=1)}}const d=l-c-u;if(l===1&&i===0&&o[0]instanceof Ut?(r.mapping.delete(o[0]),o[0].delete(0,o[0].length)):d>0&&(e.slice(c,c+d).forEach(h=>r.mapping.delete(h)),e.delete(c,d)),c+u<i){const h=[];for(let f=c;f<i-u;f++)h.push(Ah(s[f],r));e.insert(c,h)}},Le)},Th=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name,lc=(t,e,n)=>{if(t===0)return hd(e,0,-1);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof Ut){if(r._length>=t)return hd(r,t,-1);if(t-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,t--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const s=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t<s)r=r._first.content.type,t--;else{if(t===1&&r._length===0&&s>1)return new Qa(r._item===null?null:r._item.id,r._item===null?vo(r):null,null);if(t-=s,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(t===0)return r=r._item===null?r:r._item.parent,new Qa(r._item===null?null:r._item.id,r._item===null?vo(r):null,null);do r=r._item.parent,t--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw Rt();if(t===0&&r.constructor!==Ut&&r!==e)return Ej(r._item.parent,r._item)}return hd(e,e._length,-1)},Ej=(t,e)=>{let n=null,r=null;return t._item===null?r=vo(t):n=he(t._item.id.client,t._item.id.clock),new Qa(n,r,e.id)},Gi=(t,e,n,r)=>{const s=X2(n,t);if(s===null||s.type!==e&&!So(e,s.type._item))return null;let i=s.type,o=0;if(i.constructor===Ut)o=s.index;else if(i._item===null||!i._item.deleted){let l=i._first,a=0;for(;a<i._length&&a<s.index&&l!==null;){if(!l.deleted){const c=l.content.type;a++,c instanceof Ut?o+=c._length:o+=r.get(c).nodeSize}l=l.right}o+=1}for(;i!==e&&i._item!==null;){const l=i._item.parent;if(l._item===null||!l._item.deleted){o+=1;let a=l._first;for(;a!==null;){const c=a.content.type;if(c===i)break;a.deleted||(c instanceof Ut?o+=c._length:o+=r.get(c).nodeSize),a=a.right}}i=l}return o-1},Aj=t=>{const e=Hn.getState(t).undoManager;if(e!=null)return e.undo(),!0},Mj=t=>{const e=Hn.getState(t).undoManager;if(e!=null)return e.redo(),!0},Tj=new Set(["paragraph"]),Nj=(t,e)=>!(t instanceof ve)||!(t.content instanceof fn)||!(t.content.type instanceof wr||t.content.type instanceof At&&e.has(t.content.type.nodeName))||t.content.type._length===0,Rj=({protectedNodes:t=Tj,trackedOrigins:e=[],undoManager:n=null}={})=>new me({key:Hn,state:{init:(r,s)=>{const i=Le.getState(s);let o=n;if(!o){const l=i.doc,a=new Set(l?l._observers.get("destroy"):[]);o=new ok(i.type,{trackedOrigins:new Set([Le].concat(e)),deleteFilter:u=>Nj(u,t),captureTransaction:u=>u.meta.get("addToHistory")!==!1});const c=l?l._observers.get("destroy"):new Set;o._yTiptapDocDestroyListeners=Array.from(c||[]).filter(u=>!a.has(u))}return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(r,s,i,o)=>{const l=Le.getState(o).binding,a=s.undoManager,c=a.undoStack.length>0,u=a.redoStack.length>0;return l?{undoManager:a,prevSel:Eh(l,i),hasUndoOps:c,hasRedoOps:u}:c!==s.hasUndoOps||u!==s.hasRedoOps?Object.assign({},s,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):s}},view:r=>{const s=Le.getState(r.state),i=Hn.getState(r.state).undoManager;return i.on("stack-item-added",({stackItem:o})=>{const l=s.binding;l&&o.meta.set(l,Hn.getState(r.state).prevSel)}),i.on("stack-item-popped",({stackItem:o})=>{const l=s.binding;l&&(l.beforeTransactionSelection=o.meta.get(l)||l.beforeTransactionSelection)}),{destroy:()=>{i.destroy();const o=i._yTiptapDocDestroyListeners;o&&i.doc&&(o.forEach(l=>i.doc.off("destroy",l)),i._yTiptapDocDestroyListeners=null)}}}});function pp(t){return!!t.getMeta(Le)}function _j(t,e){const n=Le.getState(t);return Gi(n.doc,n.type,e,n.binding.mapping)||0}function Dk(t,e){const n=Le.getState(t);return lc(e,n.type,n.binding.mapping)}var Xl=class Lk extends pf{constructor(e,n){super(e),this.yRelativePosition=n}static fromJSON(e){return new Lk(e.position,e.yRelativePosition)}toJSON(){return{position:this.position,yRelativePosition:this.yRelativePosition}}};function Oj(t,e){const n=Dk(e,t);return new Xl(t,n)}function Dj(t,e,n){const r=t instanceof Xl?t.yRelativePosition:null;if(pp(e)&&r){const o=_j(n,r);return{position:new Xl(o,r),mapResult:null}}const s=hx(t,e),i=s.position.position;return{position:new Xl(i,r??Dk(n,i)),mapResult:s.mapResult}}ce.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(t=>t.name==="undoRedo")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".')},onBeforeCreate(){this.editor.utils.getUpdatedPosition=(t,e)=>Dj(t,e,this.editor.state),this.editor.utils.createMappablePosition=t=>Oj(t,this.editor.state)},addCommands(){return{undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Hn.getState(e).undoManager.undoStack.length===0?!1:n?Aj(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),Hn.getState(e).undoManager.redoStack.length===0?!1:n?Mj(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){const t=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),e=Rj(this.options.yUndoOptions),n=e.spec.view;e.spec.view=i=>{const{undoManager:o}=Hn.getState(i.state);o.restore&&(o.restore(),o.restore=()=>{});const l=n?n(i):void 0;return{destroy:()=>{const a=o.trackedOrigins.has(o),c=o._observers;o.restore=()=>{a&&o.trackedOrigins.add(o),o.doc.on("afterTransaction",o.afterTransactionHandler),o._observers=c},l?.destroy&&l.destroy()}}};const r={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender};return[pj(t,r),e,this.editor.options.enableContentCheck&&new me({key:new ge("filterInvalidContent"),filterTransaction:i=>{if(!pp(i))return!0;if(this.storage.isDisabled)return!1;if(!i.docChanged)return!0;try{return i.doc.check(),!0}catch(o){return this.storage.isDisabled=!0,this.editor.emit("contentError",{error:o,editor:this.editor,disableCollaboration:()=>{var l;(l=t.doc)==null||l.destroy()}}),!0}}})].filter(Boolean)}});function $y(t){if(!t.length)return xe.empty;const e=[],n=t[0].$from.node(0);return t.forEach(r=>{const s=r.$from.pos,i=r.$from.nodeAfter;i&&e.push(_e.node(s,s+i.nodeSize,{class:"ProseMirror-selectednoderange"}))}),xe.create(n,e)}function Lj(t,e,n){const r=n.isText||n.isAtom?0:1;return{start:t+r,end:t+e-r}}function Jc(t,e,n,r={}){const s=[],i=t.node(0),{extendOnBoundaryOverlap:o=!0}=r;typeof n=="number"&&n>=0||(t.sameParent(e)?n=Math.max(0,t.sharedDepth(e.pos)-1):n=t.sharedDepth(e.pos));const l=new to(t,e,n),a=l.depth===0?0:i.resolve(l.start).posAtIndex(0);return l.parent.forEach((c,u)=>{const d=a+u,h=d+c.nodeSize,f=Lj(d,c.nodeSize,c),p=o?e.pos>=f.start&&t.pos<=f.end:e.pos>f.start&&t.pos<f.end;if(d<l.start||d>=l.end||!p)return;const m=new Wh(i.resolve(d),i.resolve(h));s.push(m)}),s}var Ij=class Ik{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Ik(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return new ar(n,r)}},ar=class er extends te{constructor(e,n,r,s=1){const{doc:i}=e,o=e===n,l=e.pos===i.content.size&&n.pos===i.content.size,a=o&&!l?i.resolve(n.pos+(s>0?1:-1)):n,c=o&&l?i.resolve(e.pos-(s>0?1:-1)):e,u=Jc(c.min(a),c.max(a),r),d=a.pos>=e.pos?u[0].$from:u[u.length-1].$to,h=a.pos>=e.pos?u[u.length-1].$to:u[0].$from;super(d,h,u),this.depth=r}get $to(){return this.ranges[this.ranges.length-1].$to}eq(e){return e instanceof er&&e.$from.pos===this.$from.pos&&e.$to.pos===this.$to.pos}map(e,n){const r=e.resolve(n.map(this.anchor)),s=e.resolve(n.map(this.head));return new er(r,s)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:e}=this.$from;if(this.isForwards&&this.ranges.length>1){const s=this.ranges.slice(0,-1),i=s[0].$from,o=s[s.length-1].$to;return new er(i,o,this.depth)}const n=this.ranges[0],r=e.resolve(Math.max(0,n.$from.pos-1));return new er(this.$anchor,r,this.depth)}extendForwards(){const{doc:e}=this.$from;if(this.isBackwards&&this.ranges.length>1){const s=this.ranges.slice(1),i=s[0].$from,o=s[s.length-1].$to;return new er(o,i,this.depth)}const n=this.ranges[this.ranges.length-1],r=e.resolve(Math.min(e.content.size,n.$to.pos+1));return new er(this.$anchor,r,this.depth)}static fromJSON(e,n){return new er(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r,s,i=1){return new this(e.resolve(n),e.resolve(r),s,i)}getBookmark(){return new Ij(this.anchor,this.head)}};ar.prototype.visible=!1;function Nl(t){return t instanceof ar}var Pj=ce.create({name:"nodeRange",addOptions(){return{depth:void 0,key:"Mod"}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,selection:i,tr:o}=r,{anchor:l,head:a}=i;if(!Nl(i)){const u=ar.create(s,l,a,e,-1);return o.setSelection(u),n.dispatch(o),!0}const c=i.extendBackwards();return o.setSelection(c),n.dispatch(o),!0},"Shift-ArrowDown":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,selection:i,tr:o}=r,{anchor:l,head:a}=i;if(!Nl(i)){const u=ar.create(s,l,a,e);return o.setSelection(u),n.dispatch(o),!0}const c=i.extendForwards();return o.setSelection(c),n.dispatch(o),!0},"Mod-a":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,tr:i}=r,o=ar.create(s,0,s.content.size,e);return i.setSelection(o),n.dispatch(i),!0}}},onSelectionUpdate(){const{selection:t}=this.editor.state;Nl(t)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let t=!1,e=!1;return[new me({key:new ge("nodeRange"),props:{attributes:()=>t?{class:"ProseMirror-noderangeselection"}:{class:""},handleDOMEvents:{mousedown:(n,r)=>{const{key:s}=this.options,i=/Mac/.test(navigator.platform),o=!!r.shiftKey,l=!!r.ctrlKey,a=!!r.altKey,c=!!r.metaKey,u=i?c:l;return(s==null||s==="Shift"&&o||s==="Control"&&l||s==="Alt"&&a||s==="Meta"&&c||s==="Mod"&&u)&&(e=!0),e&&document.addEventListener("mouseup",()=>{e=!1;const{state:d}=n,{doc:h,selection:f,tr:p}=d,{$anchor:m,$head:y}=f;if(m.sameParent(y))return;const b=ar.create(h,m.pos,y.pos,this.options.depth);p.setSelection(b),n.dispatch(p)},{once:!0}),!1}},decorations:n=>{const{selection:r}=n,s=Nl(r);if(t=!1,!e)return s?(t=!0,$y(r.ranges)):null;const{$from:i,$to:o}=r;if(!s&&i.sameParent(o))return null;const l=Jc(i,o,this.options.depth);return l.length?(t=!0,$y(l)):null}}})]}}),jj=Pj;function $j(t,e){const n=getComputedStyle(t);if(e)return e.filter(s=>s.trim().length>0).map(s=>`${s}:${n.getPropertyValue(s)};`).join("");let r="";for(let s=0;s<n.length;s+=1)r+=`${n[s]}:${n.getPropertyValue(n[s])};`;return r}function Bj(t,e){const n=t.cloneNode(!0),r=[t,...Array.from(t.getElementsByTagName("*"))],s=[n,...Array.from(n.getElementsByTagName("*"))];return r.forEach((i,o)=>{s[o].style.cssText=$j(i,e)}),n}var zj={id:"listItemFirstChild",evaluate:({parent:t,isFirst:e})=>e&&t&&["listItem","taskItem"].includes(t.type.name)?1e3:0},Hj={id:"listWrapperDeprioritize",evaluate:({node:t})=>{const e=["listItem","taskItem"],n=t.firstChild;return n&&e.includes(n.type.name)?1e3:0}},Fj={id:"tableStructure",evaluate:({node:t,parent:e})=>["tableRow","tableCell","tableHeader"].includes(t.type.name)||e&&e.type.name==="tableHeader"?1e3:0},Uj={id:"inlineContent",evaluate:({node:t})=>t.isInline||t.isText?1e3:0},Vj=[zj,Hj,Fj,Uj],By={edges:["left","top"],threshold:12,strength:500};function gd(t){return t===void 0||t==="left"?{...By}:t==="right"?{edges:["right","top"],threshold:12,strength:500}:t==="both"?{edges:["left","right","top"],threshold:12,strength:500}:t==="none"?{edges:[],threshold:0,strength:0}:{...By,...t}}function Wj(t,e,n){if(n.edges.length===0)return!1;const r=e.getBoundingClientRect(),{threshold:s,edges:i}=n;return i.some(o=>o==="left"?t.x-r.left<s:o==="right"?r.right-t.x<s:o==="top"?t.y-r.top<s:o==="bottom"?r.bottom-t.y<s:!1)}function qj(t,e,n,r){return!e||n.edges.length===0?0:Wj(t,e,n)?n.strength*r:0}var Kj=1e3;function zy(t,e,n,r){let s=Kj,i=!1;if(e.every(l=>{const a=l.evaluate(t);return s-=a,s<=0?(i=!0,!1):!0}),i)return-1;const o=t.view.nodeDOM(t.pos);return s-=qj(r,o,n,t.depth),s<=0?-1:s}function Hy(t,e,n){return Array.from({length:e},(s,i)=>e-1-i).some(s=>n.includes(t.node(s).type.name))}function Jj(t,e,n){if(!Number.isFinite(e.x)||!Number.isFinite(e.y))return null;const r=t.posAtCoords({left:e.x,top:e.y});if(!r)return null;const{doc:s}=t.state,i=s.resolve(r.pos),o=[];n.defaultRules&&o.push(...Vj),o.push(...n.rules);const a=Array.from({length:i.depth},(d,h)=>i.depth-h).map(d=>{const h=i.node(d),f=i.before(d);if(n.allowedContainers&&d>0&&!Hy(i,d,n.allowedContainers))return null;const p=d>0?i.node(d-1):null,m=d>0?i.index(d-1):0,y=p?p.childCount:1,b={node:h,pos:f,depth:d,parent:p,index:m,isFirst:m===0,isLast:m===y-1,$pos:i,view:t},x=zy(b,o,n.edgeDetection,e);if(x<0)return null;const w=t.nodeDOM(f);return{node:h,pos:f,depth:d,score:x,dom:w}}).filter(d=>d!==null),c=i.nodeAfter;if(c&&c.isAtom&&!c.isInline){const d=r.pos,h=i.depth+1,f=i.parent,p=i.index(),m=f.childCount;let y=!0;if(n.allowedContainers&&(y=Hy(i,h,n.allowedContainers)),y){const b={node:c,pos:d,depth:h,parent:f,index:p,isFirst:p===0,isLast:p===m-1,$pos:i,view:t},x=zy(b,o,n.edgeDetection,e);if(x>=0){const w=t.nodeDOM(d);w&&a.push({node:c,pos:d,depth:h,score:x,dom:w})}}}if(a.length===0)return null;a.sort((d,h)=>h.score!==d.score?h.score-d.score:h.depth-d.depth);const u=a[0];return u.dom?{node:u.node,pos:u.pos,dom:u.dom}:null}function Gj(t,e){let n=t;for(;n?.parentElement&&n.parentElement!==e.dom;)n=n.parentElement;return n?.parentElement===e.dom?n:void 0}function Fy(t){return Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)&&t.width>0&&t.height>0}function Yj(t,e,n,r=5){if(!Number.isFinite(e)||!Number.isFinite(n))return null;const s=t.dom,i=s.firstElementChild,o=s.lastElementChild;if(!i||!o)return null;const l=i.getBoundingClientRect(),a=o.getBoundingClientRect();if(!Fy(l)||!Fy(a))return null;const c=Math.min(Math.max(l.top+r,n),a.bottom-r),u=.5,d=Math.abs(l.left-a.left)<u,h=Math.abs(l.right-a.right)<u;let f=l;d&&h&&(f=l);const p=Math.min(Math.max(f.left+r,e),f.right-r);return!Number.isFinite(p)||!Number.isFinite(c)?null:{x:p,y:c}}var Pk=t=>{const{x:e,y:n,editor:r,nestedOptions:s}=t,{view:i,state:o}=r,l=Yj(i,e,n,5);if(!l)return{resultElement:null,resultNode:null,pos:null};const{x:a,y:c}=l;if(s?.enabled){const p=Jj(i,{x:a,y:c},s);return p?{resultElement:p.dom,resultNode:p.node,pos:p.pos}:{resultElement:null,resultNode:null,pos:null}}const u=i.root.elementsFromPoint(a,c);let d;if(Array.prototype.some.call(u,p=>{if(!i.dom.contains(p))return!1;const m=Gj(p,i);return m?(d=m,!0):!1}),!d){const p=i.posAtCoords({left:a,top:c});if(p){const m=o.doc.resolve(p.pos),y=Math.min(m.depth,1),b=y>0?m.before(y):m.pos,x=o.doc.nodeAt(b);if(x){const w=i.nodeDOM(b);return{resultElement:w instanceof HTMLElement?w:null,resultNode:x,pos:b}}}return{resultElement:null,resultNode:null,pos:null}}let h;try{h=i.posAtDOM(d,0)}catch{return{resultElement:null,resultNode:null,pos:null}}const f=o.doc.nodeAt(h);if(!f){const p=o.doc.resolve(h),m=p.parent;return{resultElement:d,resultNode:m,pos:p.start()}}return{resultElement:d,resultNode:f,pos:h}};function jk(t,e){const n=t.nodeDOM(e);if(n instanceof Element&&n!==t.dom)return n;const{node:r,offset:s}=t.domAtPos(e),i=r.childNodes[s];return i instanceof Element?i:r instanceof Element?r:r.nodeType===Node.TEXT_NODE&&r.parentElement?r.parentElement:null}function Xj(t,e){const n=jk(t,e);return(n?getComputedStyle(n).direction:getComputedStyle(t.dom).direction)||"ltr"}function $k(t){var e;(e=t.parentNode)==null||e.removeChild(t)}function Zj(t,e){return t==="rtl"?e:0}function Qj(t,e,n,r){const{doc:s}=e.view.state;if(n?.enabled&&r?.node&&r.pos>=0){const c=r.pos,u=r.pos+r.node.nodeSize;return[{$from:s.resolve(c),$to:s.resolve(u)}]}const i=Pk({editor:e,x:t.clientX,y:t.clientY,nestedOptions:n});if(!i.resultNode||i.pos===null)return[];const o=i.resultNode.isText||i.resultNode.isAtom?0:-1,l=s.resolve(i.pos),a=s.resolve(i.pos+i.resultNode.nodeSize+o);return Jc(l,a,0,{extendOnBoundaryOverlap:!1})}function e$(t,e,n,r,s){const{view:i}=e;if(!t.dataTransfer)return;const{empty:o,$from:l,$to:a}=i.state.selection,c=Qj(t,e,n,r),u=Jc(l,a,0,{extendOnBoundaryOverlap:!1}),d=u.some(N=>c.find(D=>D.$from===N.$from&&D.$to===N.$to)),h=o||!d?c:u;if(!h.length)return;const{tr:f}=i.state,p=document.createElement("div"),m=h[0].$from.pos,y=h[h.length-1].$to.pos,b=Xj(i,m);p.setAttribute("dir",b);const x=n?.enabled&&r?.node;let w,k;x?(w=i.state.doc.slice(m,y),k=Y.create(i.state.doc,m)):(k=ar.create(i.state.doc,m,y),w=k.content()),h.forEach(N=>{const D=jk(i,N.$from.pos);if(!D)return;const z=Bj(D,s);z.style.margin="0",p.append(z)}),p.style.position="absolute",p.style.top="-10000px",document.body.append(p),t.dataTransfer.clearData();const T=p.getBoundingClientRect(),S=Zj(b,T.width);t.dataTransfer.setDragImage(p,S,0);let v=!1;const A=()=>{v||(v=!0,$k(p),document.removeEventListener("drop",A),document.removeEventListener("dragend",A))},C=k instanceof Y?k:void 0;i.dragging={slice:w,move:!0,node:C},f.setSelection(k),i.dispatch(f),document.addEventListener("drop",A),document.addEventListener("dragend",A)}var Uy=(t,e)=>{const n=t.resolve(e),{depth:r}=n;return r===0?e:n.pos-n.parentOffset-1},Vy=(t,e)=>{const n=t.nodeAt(e),r=t.resolve(e);let{depth:s}=r,i=n;for(;s>0;){const o=r.node(s);s-=1,s===0&&(i=o)}return i},yd=(t,e)=>{const n=Le.getState(t);return n?lc(e,n.type,n.binding.mapping):null},t$=(t,e)=>{const n=Le.getState(t);return n?Gi(n.doc,n.type,e,n.binding.mapping)||0:-1},Wy=(t,e)=>{let n=e;for(;n?.parentNode&&n.parentNode!==t.dom;)n=n.parentNode;return n},Bk=new ge("dragHandle"),zk=({pluginKey:t=Bk,element:e,editor:n,computePositionConfig:r,getReferencedVirtualElement:s,onNodeChange:i,onElementDragStart:o,onElementDragEnd:l,nestedOptions:a,dragImageProperties:c})=>{const u=document.createElement("div");let d=!1,h=null,f=-1,p,m=null,y=null;function b(){e&&(e.style.visibility="hidden",e.style.pointerEvents="none")}function x(){if(e){if(!n.isEditable){b();return}e.style.visibility="",e.style.pointerEvents="auto"}}function w(v){const A=s?.()||{getBoundingClientRect:()=>v.getBoundingClientRect()};Mf(A,e,r).then(C=>{Object.assign(e.style,{position:C.strategy,left:`${C.x}px`,top:`${C.y}px`})})}function k(v){o?.(v),e$(v,n,a,{node:h,pos:f},c),e&&(e.dataset.dragging="true"),setTimeout(()=>{e&&(e.style.pointerEvents="none")},0)}function T(v){l?.(v),b(),e&&(e.style.pointerEvents="auto",e.dataset.dragging="false")}function S(){if(ST()){const v=n.view.dom;requestAnimationFrame(()=>{v.isContentEditable&&(v.contentEditable="false",v.contentEditable="true")})}}return u.appendChild(e),{unbind(){e.removeEventListener("dragstart",k),e.removeEventListener("dragend",T),document.removeEventListener("drop",S),m&&(cancelAnimationFrame(m),m=null,y=null)},plugin:new me({key:typeof t=="string"?new ge(t):t,state:{init(){return{locked:!1}},apply(v,A,C,N){const D=v.getMeta("lockDragHandle"),z=v.getMeta("hideDragHandle");if(D!==void 0&&(d=D),z)return b(),d=!1,h=null,f=-1,i?.({editor:n,node:null,pos:-1}),A;if(v.docChanged&&f!==-1&&e)if(pp(v)){const L=t$(N,p);L!==f&&(f=L)}else{const L=v.mapping.map(f);L!==f&&(f=L,p=yd(N,f))}return A}},view:v=>{var A;return e.draggable=!0,e.style.pointerEvents="auto",e.dataset.dragging="false",(A=n.view.dom.parentElement)==null||A.appendChild(u),u.style.pointerEvents="none",u.style.position="absolute",u.style.top="0",u.style.left="0",e.addEventListener("dragstart",k),e.addEventListener("dragend",T),document.addEventListener("drop",S),{update(C,N){if(!e)return;if(!n.isEditable){b();return}if(d?e.draggable=!1:e.draggable=!0,v.state.doc.eq(N.doc)||f===-1)return;let D=v.nodeDOM(f);if(D=Wy(v,D),D===v.dom||D?.nodeType!==1)return;const z=v.posAtDOM(D,0),L=Vy(n.state.doc,z),_=Uy(n.state.doc,z);h=L,f=_,p=yd(v.state,f),i?.({editor:n,node:h,pos:f}),w(D)},destroy(){e.removeEventListener("dragstart",k),e.removeEventListener("dragend",T),document.removeEventListener("drop",S),m&&(cancelAnimationFrame(m),m=null,y=null),e&&$k(u)}}},props:{handleDOMEvents:{keydown(v){return!e||d||v.hasFocus()&&(b(),h=null,f=-1,i?.({editor:n,node:null,pos:-1})),!1},mouseleave(v,A){return d||A.target&&!u.contains(A.relatedTarget)&&(b(),h=null,f=-1,i?.({editor:n,node:null,pos:-1})),!1},mousemove(v,A){return!e||d||(y={x:A.clientX,y:A.clientY},m)||(m=requestAnimationFrame(()=>{if(m=null,!y)return;const{x:C,y:N}=y;y=null;const D=Pk({x:C,y:N,editor:n,nestedOptions:a});if(!D.resultElement)return;let z=D.resultElement,L=D.resultNode,_=D.pos;if(!a?.enabled){if(z=Wy(v,z),z===v.dom||z?.nodeType!==1)return;const V=v.posAtDOM(z,0);L=Vy(n.state.doc,V),_=Uy(n.state.doc,V)}L!==h&&(h=L,f=_??-1,p=yd(v.state,f),i?.({editor:n,node:h,pos:f}),w(z),x())})),!1}}}})}};function Hk(t){var e,n;return t===!1||t===void 0?{enabled:!1,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:gd("none")}:t===!0?{enabled:!0,rules:[],defaultRules:!0,allowedContainers:void 0,edgeDetection:gd("left")}:{enabled:!0,rules:(e=t.rules)!=null?e:[],defaultRules:(n=t.defaultRules)!=null?n:!0,allowedContainers:t.allowedContainers,edgeDetection:gd(t.edgeDetection)}}var Nh={placement:"left-start",strategy:"absolute"},n$=ce.create({name:"dragHandle",addOptions(){return{render(){const t=document.createElement("div");return t.classList.add("drag-handle"),t},computePositionConfig:{},locked:!1,onNodeChange:()=>null,onElementDragStart:void 0,onElementDragEnd:void 0,nested:!1,dragImageProperties:void 0}},addCommands(){return{lockDragHandle:()=>({editor:t})=>(this.options.locked=!0,t.commands.setMeta("lockDragHandle",this.options.locked)),unlockDragHandle:()=>({editor:t})=>(this.options.locked=!1,t.commands.setMeta("lockDragHandle",this.options.locked)),toggleDragHandle:()=>({editor:t})=>(this.options.locked=!this.options.locked,t.commands.setMeta("lockDragHandle",this.options.locked))}},addProseMirrorPlugins(){const t=this.options.render(),e=Hk(this.options.nested);return[zk({computePositionConfig:{...Nh,...this.options.computePositionConfig},getReferencedVirtualElement:this.options.getReferencedVirtualElement,element:t,editor:this.editor,onNodeChange:this.options.onNodeChange,onElementDragStart:this.options.onElementDragStart,onElementDragEnd:this.options.onElementDragEnd,nestedOptions:e,dragImageProperties:this.options.dragImageProperties}).plugin]}}),r$=n$;function s$(t){const e=t.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:e.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const s={className:"subst",begin:/\$\(/,end:/\)/,contains:[t.BACKSLASH_ESCAPE]},i=t.inherit(t.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),o={begin:/<<-?\s*(?=\w+)/,starts:{contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},l={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,n,s]};s.contains.push(l);const a={match:/\\"/},c={className:"string",begin:/'/,end:/'/},u={match:/\\'/},d={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},t.NUMBER_MODE,n]},h=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],f=t.SHEBANG({binary:`(${h.join("|")})`,relevance:10}),p={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[t.inherit(t.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},m=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],y=["true","false"],b={match:/(\/[a-z._-]+)+/},x=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],w=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],k=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],T=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:m,literal:y,built_in:[...x,...w,"set","shopt",...k,...T]},contains:[f,t.SHEBANG(),p,d,i,o,b,l,a,c,u,n]}}const i$=t=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:t.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:t.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),o$=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],l$=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],a$=[...o$,...l$],c$=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),u$=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),d$=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),h$=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function f$(t){const e=t.regex,n=i$(t),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},s="and or not only",i=/@-?\w[\w]*(-\w+)*/,o="[a-zA-Z-][a-zA-Z0-9_-]*",l=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+o,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+u$.join("|")+")"},{begin:":(:)?("+d$.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+h$.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...l,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...l,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:e.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:c$.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...l,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+a$.join("|")+")\\b"}]}}const qy="[A-Za-z$_][0-9A-Za-z$_]*",p$=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],m$=["true","false","null","undefined","NaN","Infinity"],Fk=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Uk=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Vk=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],g$=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],y$=[].concat(Vk,Fk,Uk);function b$(t){const e=t.regex,n=(I,{after:P})=>{const ne="</"+I[0].slice(1);return I.input.indexOf(ne,P)!==-1},r=qy,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(I,P)=>{const ne=I[0].length+I.index,R=I.input[ne];if(R==="<"||R===","){P.ignoreMatch();return}R===">"&&(n(I,{after:ne})||P.ignoreMatch());let q;const le=I.input.substring(ne);if(q=le.match(/^\s*=/)){P.ignoreMatch();return}if((q=le.match(/^\s+extends\s+/))&&q.index===0){P.ignoreMatch();return}}},l={$pattern:qy,keyword:p$,literal:m$,built_in:y$,"variable.language":g$},a="[0-9](_?[0-9])*",c=`\\.(${a})`,u="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",d={className:"number",variants:[{begin:`(\\b(${u})((${c})|\\.)?|(${c}))[eE][+-]?(${a})\\b`},{begin:`\\b(${u})\\b((${c})\\b|\\.)?|(${c})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},f={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},p={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"css"}},m={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,h]},x={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},w=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,m,y,{match:/\$\d+/},d];h.contains=w.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(w)});const k=[].concat(x,h.contains),T=k.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(k)}]),S={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:T},v={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},A={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Fk,...Uk]}},C={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},N={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[S],illegal:/%/},D={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function z(I){return e.concat("(?!",I.join("|"),")")}const L={match:e.concat(/\b/,z([...Vk,"super","import"].map(I=>`${I}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},_={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},V={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},S]},ee="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",be={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(ee)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[S]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:T,CLASS_REFERENCE:A},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),C,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,m,y,x,{match:/\$\d+/},d,A,{scope:"attr",match:r+e.lookahead(":"),relevance:0},be,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[x,t.REGEXP_MODE,{className:"function",begin:ee,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:T}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},N,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[S,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},_,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[S]},L,D,v,V,{match:/\$[(.]/}]}}function x$(t){const e={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],s={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[e,n,t.QUOTE_STRING_MODE,s,t.C_NUMBER_MODE,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function w$(t){const e=t.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],l={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},a={className:"meta",begin:/^(>>>|\.\.\.) /},c={className:"subst",begin:/\{/,end:/\}/,keywords:l,illegal:/#/},u={begin:/\{\{/,relevance:0},d={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,a,u,c]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,a,u,c]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[t.BACKSLASH_ESCAPE,u,c]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,u,c]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},h="[0-9](_?[0-9])*",f=`(\\b(${h}))?\\.(${h})|\\b(${h})\\.`,p=`\\b|${r.join("|")}`,m={className:"number",relevance:0,variants:[{begin:`(\\b(${h})|(${f}))[eE][+-]?(${h})[jJ]?(?=${p})`},{begin:`(${f})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${p})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${p})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${p})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${p})`},{begin:`\\b(${h})[jJ](?=${p})`}]},y={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:l,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},b={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:["self",a,m,d,t.HASH_COMMENT_MODE]}]};return c.contains=[d,m,a],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:l,illegal:/(<\/|\?)|=>/,contains:[a,m,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},d,y,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[b]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[m,b,d]}]}}function k$(t){const e=t.regex,n=t.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},s={begin:/"/,end:/"/,contains:[{match:/""/}]},i=["true","false","unknown"],o=["double precision","large object","with timezone","without timezone"],l=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],a=["add","asc","collation","desc","final","first","last","view"],c=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],u=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],d=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],h=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],f=u,p=[...c,...a].filter(T=>!u.includes(T)),m={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},y={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},b={match:e.concat(/\b/,e.either(...f),/\s*\(/),relevance:0,keywords:{built_in:f}};function x(T){return e.concat(/\b/,e.either(...T.map(S=>S.replace(/\s+/,"\\s+"))),/\b/)}const w={scope:"keyword",match:x(h),relevance:0};function k(T,{exceptions:S,when:v}={}){const A=v;return S=S||[],T.map(C=>C.match(/\|\d+$/)||S.includes(C)?C:A(C)?`${C}|0`:C)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:k(p,{when:T=>T.length<3}),literal:i,type:l,built_in:d},contains:[{scope:"type",match:x(o)},w,b,m,r,s,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,y]}}const ac="[A-Za-z$_][0-9A-Za-z$_]*",Wk=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],qk=["true","false","null","undefined","NaN","Infinity"],Kk=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Jk=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Gk=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Yk=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],Xk=[].concat(Gk,Kk,Jk);function v$(t){const e=t.regex,n=(I,{after:P})=>{const ne="</"+I[0].slice(1);return I.input.indexOf(ne,P)!==-1},r=ac,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,o={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(I,P)=>{const ne=I[0].length+I.index,R=I.input[ne];if(R==="<"||R===","){P.ignoreMatch();return}R===">"&&(n(I,{after:ne})||P.ignoreMatch());let q;const le=I.input.substring(ne);if(q=le.match(/^\s*=/)){P.ignoreMatch();return}if((q=le.match(/^\s+extends\s+/))&&q.index===0){P.ignoreMatch();return}}},l={$pattern:ac,keyword:Wk,literal:qk,built_in:Xk,"variable.language":Yk},a="[0-9](_?[0-9])*",c=`\\.(${a})`,u="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",d={className:"number",variants:[{begin:`(\\b(${u})((${c})|\\.)?|(${c}))[eE][+-]?(${a})\\b`},{begin:`\\b(${u})\\b((${c})\\b|\\.)?|(${c})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},f={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},p={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"css"}},m={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,h]},x={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},w=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,m,y,{match:/\$\d+/},d];h.contains=w.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(w)});const k=[].concat(x,h.contains),T=k.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(k)}]),S={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:T},v={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},A={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Kk,...Jk]}},C={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},N={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[S],illegal:/%/},D={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function z(I){return e.concat("(?!",I.join("|"),")")}const L={match:e.concat(/\b/,z([...Gk,"super","import"].map(I=>`${I}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},_={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},V={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},S]},ee="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",be={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(ee)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[S]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:T,CLASS_REFERENCE:A},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),C,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,m,y,x,{match:/\$\d+/},d,A,{scope:"attr",match:r+e.lookahead(":"),relevance:0},be,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[x,t.REGEXP_MODE,{className:"function",begin:ee,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:T}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:o.begin,"on:begin":o.isTrulyOpeningTag,end:o.end}],subLanguage:"xml",contains:[{begin:o.begin,end:o.end,skip:!0,contains:["self"]}]}]},N,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[S,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},_,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[S]},L,D,v,V,{match:/\$[(.]/}]}}function S$(t){const e=t.regex,n=v$(t),r=ac,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},o={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},l={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},a=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],c={$pattern:ac,keyword:Wk.concat(a),literal:qk,built_in:Xk.concat(s),"variable.language":Yk},u={className:"meta",begin:"@"+r},d=(m,y,b)=>{const x=m.contains.findIndex(w=>w.label===y);if(x===-1)throw new Error("can not find mode to replace");m.contains.splice(x,1,b)};Object.assign(n.keywords,c),n.exports.PARAMS_CONTAINS.push(u);const h=n.contains.find(m=>m.scope==="attr"),f=Object.assign({},h,{match:e.concat(r,e.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,h,f]),n.contains=n.contains.concat([u,i,o,f]),d(n,"shebang",t.SHEBANG()),d(n,"use_strict",l);const p=n.contains.find(m=>m.label==="func.def");return p.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function C$(t){const e=t.regex,n=e.concat(/[\p{L}_]/u,e.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,s={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},o=t.inherit(i,{begin:/\(/,end:/\)/}),l=t.inherit(t.APOS_STRING_MODE,{className:"string"}),a=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),c={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[s]},{begin:/'/,end:/'/,contains:[s]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[i,a,l,o,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,o,a,l]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[a]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[c],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[c],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:e.concat(/</,e.lookahead(e.concat(n,e.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:c}]},{className:"tag",begin:e.concat(/<\//,e.lookahead(e.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}const Ky={},E$="hljs-";function A$(t){const e=Jw.newInstance();return t&&i(t),{highlight:n,highlightAuto:r,listLanguages:s,register:i,registerAlias:o,registered:l};function n(a,c,u){const d=u||Ky,h=typeof d.prefix=="string"?d.prefix:E$;if(!e.getLanguage(a))throw new Error("Unknown language: `"+a+"` is not registered");e.configure({__emitter:M$,classPrefix:h});const f=e.highlight(c,{ignoreIllegals:!0,language:a});if(f.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:f.errorRaised});const p=f._emitter.root,m=p.data;return m.language=f.language,m.relevance=f.relevance,p}function r(a,c){const d=(c||Ky).subset||s();let h=-1,f=0,p;for(;++h<d.length;){const m=d[h];if(!e.getLanguage(m))continue;const y=n(m,a,c);y.data&&y.data.relevance!==void 0&&y.data.relevance>f&&(f=y.data.relevance,p=y)}return p||{type:"root",children:[],data:{language:void 0,relevance:f}}}function s(){return e.listLanguages()}function i(a,c){if(typeof a=="string")e.registerLanguage(a,c);else{let u;for(u in a)Object.hasOwn(a,u)&&e.registerLanguage(u,a[u])}}function o(a,c){if(typeof a=="string")e.registerAliases(typeof c=="string"?c:[...c],{languageName:a});else{let u;for(u in a)if(Object.hasOwn(a,u)){const d=a[u];e.registerAliases(typeof d=="string"?d:[...d],{languageName:u})}}}function l(a){return!!e.getLanguage(a)}}class M${constructor(e){this.options=e,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(e){if(e==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=e:n.children.push({type:"text",value:e})}startScope(e){this.openNode(String(e))}endScope(){this.closeNode()}__addSublanguage(e,n){const r=this.stack[this.stack.length-1],s=e.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:s}):r.children.push(...s)}openNode(e){const n=this,r=e.split(".").map(function(o,l){return l?o+"_".repeat(l):n.options.classPrefix+o}),s=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:r},children:[]};s.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}var T$=vO;const N$=t=>{const{editor:e,pos:n}=t,r=e.state.doc.resolve(Math.max(n,0));return r.depth>0?r.node(r.depth-1):null},R$=t=>{const e='Press "/" to insert or start typing...',{node:n}=t,r=n.type.name,s=N$(t);if(r==="heading"){const i=n.attrs.level??1;switch(i){case 1:return"Add a title...";case 2:return"Add a section heading...";case 3:return"Add a subheading...";default:return`Heading ${i}`}}if(r==="taskItem")return"Add a task...";if(r==="listItem"){const i=s?.type.name;return i==="bulletList"?"Add a bullet...":i==="orderedList"?"Add a numbered item...":"Add a list item..."}if(r==="codeBlock"){const i=n.attrs.language;return i?`Write ${i} code...`:"Write some code..."}if(r==="paragraph"){const i=s?.type.name;if(!i||i==="doc")return e}return r==="doc"?e:""},Zk=T$.extend({addOptions(){return{...this.parent?.(),emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",includeChildren:!0,showOnlyCurrent:!0,showOnlyWhenEditable:!0,dataAttribute:"data-placeholder",placeholder:e=>R$(e)}},addProseMirrorPlugins(){const t=new Set(["table","tableCell","tableHeader","tableRow"]),e=n=>{const r=this.editor.state.doc.resolve(n);for(let s=r.depth;s>=0;s-=1){const i=r.node(s);if(t.has(i.type.name))return!0}return!1};return[new me({key:new ge("placeholder"),props:{decorations:({doc:n,selection:r})=>{if(!(this.editor.isEditable||!this.options.showOnlyWhenEditable))return null;const{anchor:i}=r,o=[],l=this.editor.isEmpty;return n.descendants((a,c)=>{if(e(c))return this.options.includeChildren;const u=i>=c&&i<=c+a.nodeSize,d=!a.isLeaf&&js(a);if((u||!this.options.showOnlyCurrent)&&d){const h=[this.options.emptyNodeClass];l&&h.push(this.options.emptyEditorClass);const f=typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:c,hasAnchor:u}):this.options.placeholder,p=_e.node(c,c+a.nodeSize,{class:h.join(" "),"data-placeholder":f});o.push(p)}return this.options.includeChildren}),o.length?xe.create(n,o):null}}})]}}),_$=({node:t,updateAttributes:e,editor:n})=>{const[r,s]=E.useState(!1),{type:i,title:o,message:l,align:a,size:c,textAlign:u}=t.attrs,d={info:"bg-blue-50 text-blue-900 border-2 border-blue-200 dark:bg-blue-900/20 dark:text-blue-100 dark:border-blue-800",warning:"bg-yellow-50 text-yellow-900 border-2 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-100 dark:border-yellow-800",error:"bg-red-50 text-red-900 border-2 border-red-200 dark:bg-red-900/20 dark:text-red-100 dark:border-red-800",success:"bg-green-50 text-green-900 border-2 border-green-200 dark:bg-green-900/20 dark:text-green-100 dark:border-green-800"},h={small:"text-sm p-2",medium:"text-base p-3",large:"text-lg p-4"},f={left:"text-left",center:"text-center",right:"text-right"},p={left:"text-left",center:"text-center",right:"text-right"};return g.jsxs(wf,{children:[g.jsx("div",{className:`${f[a]||"text-left"} cursor-grab`,onClick:()=>s(!0),"data-drag-handle":!0,children:g.jsxs("div",{className:`inline-block rounded-lg border p-2 m-1 ${d[i]||d.info} ${h[c]||h["fit-content"]} ${p[u]||p.left}`,children:[g.jsx("strong",{className:"font-bold block",children:o}),g.jsx("span",{children:l})]})}),r&&g.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center",onClick:()=>s(!1),children:g.jsxs("div",{className:"bg-white p-6 rounded-lg shadow-xl w-full max-w-md",onClick:m=>m.stopPropagation(),children:[g.jsx("h3",{className:"text-xl font-semibold mb-4 text-gray-800",children:"Edit Alert"}),g.jsxs("div",{className:"space-y-4",children:[g.jsxs("div",{children:[g.jsx("label",{htmlFor:"title",className:"block text-sm font-medium text-gray-700 mb-1",children:"Title"}),g.jsx("input",{type:"text",id:"title",defaultValue:o,onBlur:m=>e({title:m.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),g.jsxs("div",{children:[g.jsx("label",{htmlFor:"message",className:"block text-sm font-medium text-gray-700 mb-1",children:"Message"}),g.jsx("textarea",{id:"message",defaultValue:l,onBlur:m=>e({message:m.target.value}),rows:3,className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),g.jsxs("div",{children:[g.jsx("label",{htmlFor:"type",className:"block text-sm font-medium text-gray-700 mb-1",children:"Type"}),g.jsxs("select",{id:"type",defaultValue:i,onChange:m=>e({type:m.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[g.jsx("option",{value:"info",children:"Info"}),g.jsx("option",{value:"warning",children:"Warning"}),g.jsx("option",{value:"error",children:"Error"}),g.jsx("option",{value:"success",children:"Success"})]})]}),g.jsxs("div",{children:[g.jsx("label",{htmlFor:"align",className:"block text-sm font-medium text-gray-700 mb-1",children:"Alignment"}),g.jsxs("select",{id:"align",defaultValue:a,onChange:m=>e({align:m.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[g.jsx("option",{value:"left",children:"Left"}),g.jsx("option",{value:"center",children:"Center"}),g.jsx("option",{value:"right",children:"Right"})]})]}),g.jsxs("div",{children:[g.jsx("label",{htmlFor:"size",className:"block text-sm font-medium text-gray-700 mb-1",children:"Size"}),g.jsxs("select",{id:"size",defaultValue:c,onChange:m=>e({size:m.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[g.jsx("option",{value:"small",children:"Small"}),g.jsx("option",{value:"medium",children:"Medium"}),g.jsx("option",{value:"large",children:"Large"})]})]}),g.jsxs("div",{children:[g.jsx("label",{htmlFor:"textAlign",className:"block text-sm font-medium text-gray-700 mb-1",children:"Text Alignment"}),g.jsxs("select",{id:"textAlign",defaultValue:u,onChange:m=>e({textAlign:m.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[g.jsx("option",{value:"left",children:"Left"}),g.jsx("option",{value:"center",children:"Center"}),g.jsx("option",{value:"right",children:"Right"})]})]})]}),g.jsx("div",{className:"mt-6 flex justify-end",children:g.jsx("button",{onClick:()=>s(!1),className:"px-4 py-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500",children:"Done"})})]})})]})},Qk=De.create({name:"alertWidget",group:"block",atom:!0,draggable:!0,defining:!0,addAttributes(){return{type:{default:"info",parseHTML:t=>t.getAttribute("data-type"),renderHTML:t=>({"data-type":t.type})},title:{default:"Alert",parseHTML:t=>t.getAttribute("data-title"),renderHTML:t=>({"data-title":t.title})},message:{default:"This is an alert message.",parseHTML:t=>t.getAttribute("data-message"),renderHTML:t=>({"data-message":t.message})},align:{default:"center",parseHTML:t=>t.getAttribute("data-align"),renderHTML:t=>({"data-align":t.align})},size:{default:"medium",parseHTML:t=>t.getAttribute("data-size"),renderHTML:t=>({"data-size":t.size})},textAlign:{default:"left",parseHTML:t=>t.getAttribute("data-text-align"),renderHTML:t=>({"data-text-align":t.textAlign})}}},parseHTML(){return[{tag:"div[data-alert-widget]",priority:52}]},renderHTML({HTMLAttributes:t}){return["div",fe(t,{"data-alert-widget":""})]},addNodeView(){return kf(_$)},addCommands(){return{setAlertWidget:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}}),O$=({node:t,updateAttributes:e,editor:n})=>{const[r,s]=E.useState(!1),{text:i,url:o,style:l,size:a,textAlign:c}=t.attrs,u={primary:"bg-primary text-primary-foreground hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80"},d={"fit-content":"w-auto","full-width":"w-full"},h={left:"text-left",center:"text-center",right:"text-right"};return g.jsxs(wf,{children:[g.jsx("div",{className:`p-2 ${h[c]||h.left} cursor-grab`,"data-drag-handle":!0,onClick:()=>s(!0),children:g.jsx("div",{role:"button",tabIndex:0,className:`inline-block px-4 py-2 rounded-md ${u[l]} ${d[a]||d["fit-content"]}`,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),s(!0))},children:i})}),r&&g.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center",onClick:()=>s(!1),children:g.jsxs("div",{className:"bg-white p-6 rounded-lg shadow-xl w-full max-w-md",onClick:f=>f.stopPropagation(),children:[g.jsx("h3",{className:"text-xl font-semibold mb-4 text-gray-800",children:"Edit CTA Button"}),g.jsxs("div",{className:"space-y-4",children:[g.jsxs("div",{children:[g.jsx("label",{htmlFor:"text",className:"block text-sm font-medium text-gray-700 mb-1",children:"Button Text"}),g.jsx("input",{type:"text",id:"text",defaultValue:i,onBlur:f=>e({text:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),g.jsxs("div",{children:[g.jsx("label",{htmlFor:"url",className:"block text-sm font-medium text-gray-700 mb-1",children:"URL"}),g.jsx("input",{type:"text",id:"url",defaultValue:o,onBlur:f=>e({url:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),g.jsxs("div",{children:[g.jsx("label",{htmlFor:"style",className:"block text-sm font-medium text-gray-700 mb-1",children:"Style"}),g.jsxs("select",{id:"style",defaultValue:l,onChange:f=>e({style:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[g.jsx("option",{value:"primary",children:"Primary"}),g.jsx("option",{value:"secondary",children:"Secondary"})]})]}),g.jsxs("div",{children:[g.jsx("label",{htmlFor:"size",className:"block text-sm font-medium text-gray-700 mb-1",children:"Size"}),g.jsxs("select",{id:"size",defaultValue:a,onChange:f=>e({size:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[g.jsx("option",{value:"fit-content",children:"Fit Content"}),g.jsx("option",{value:"full-width",children:"Full Width"})]})]}),g.jsxs("div",{children:[g.jsx("label",{htmlFor:"textAlign",className:"block text-sm font-medium text-gray-700 mb-1",children:"Text Alignment"}),g.jsxs("select",{id:"textAlign",defaultValue:c,onChange:f=>e({textAlign:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[g.jsx("option",{value:"left",children:"Left"}),g.jsx("option",{value:"center",children:"Center"}),g.jsx("option",{value:"right",children:"Right"})]})]})]}),g.jsx("div",{className:"mt-6 flex justify-end",children:g.jsx("button",{onClick:()=>s(!1),className:"px-4 py-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500",children:"Done"})})]})})]})},ev=De.create({name:"ctaWidget",group:"block",draggable:!0,atom:!0,defining:!0,addAttributes(){return{text:{default:"Click Here",parseHTML:t=>t.getAttribute("data-text"),renderHTML:t=>({"data-text":t.text})},url:{default:"#",parseHTML:t=>t.getAttribute("data-url"),renderHTML:t=>({"data-url":t.url})},style:{default:"primary",parseHTML:t=>t.getAttribute("data-style"),renderHTML:t=>({"data-style":t.style})},size:{default:"fit-content",parseHTML:t=>t.getAttribute("data-size"),renderHTML:t=>({"data-size":t.size})},textAlign:{default:"left",parseHTML:t=>t.getAttribute("data-text-align"),renderHTML:t=>({"data-text-align":t.textAlign})}}},parseHTML(){return[{tag:"div[data-cta-widget]",priority:52}]},renderHTML({HTMLAttributes:t}){return["div",fe(t,{"data-cta-widget":""})]},addNodeView(){return kf(O$)},addCommands(){return{setCtaWidget:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}});function D$(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:l}=t,a=r&&!s,c=vT(n),u=new RegExp(`\\s${c}$`),d=o?"^":"",h=s?"":c,f=a?new RegExp(`${d}${c}.*?(?=\\s${h}|$)`,"gm"):new RegExp(`${d}(?:^)?${c}[^\\s${h}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const m=l.pos-p.length,y=Array.from(p.matchAll(f)).pop();if(!y||y.input===void 0||y.index===void 0)return null;const b=y.input.slice(Math.max(0,y.index-1),y.index),x=new RegExp(`^[${i?.join("")}\0]?$`).test(b);if(i!==null&&!x)return null;const w=m+y.index;let k=w+y[0].length;return a&&u.test(p.slice(k-1,k+1))&&(y[0]+=" ",k+=1),w<l.pos&&k>=l.pos?{range:{from:w,to:k},query:y[0].slice(n.length),text:y[0]}:null}function L$(t){return t.docChanged?t.steps.some(e=>{const n=e.slice;if(!n?.content)return!1;const r=n.content.textBetween(0,n.content.size,`
165
+ `);return/\s/.test(r)}):!1}var I$=new ge("suggestion");function P$({pluginKey:t=I$,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:i=[" "],startOfLine:o=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:u="is-empty",command:d=()=>null,items:h=()=>[],render:f=()=>({}),allow:p=()=>!0,findSuggestionMatch:m=D$,shouldShow:y,shouldResetDismissed:b}){let x;const w=f?.(),k=r&&!s,T=()=>{const N=e.state.selection.$anchor.pos,D=e.view.coordsAtPos(N),{top:z,right:L,bottom:_,left:V}=D;try{return new DOMRect(V,z,L-V,_-z)}catch{return null}},S=(N,D)=>D?()=>{const z=t.getState(e.state),L=z?.decorationId,_=N.dom.querySelector(`[data-decoration-id="${L}"]`);return _?.getBoundingClientRect()||null}:T,v=({match:N,dismissedRange:D,state:z,transaction:L})=>b?.({editor:e,state:z,range:D,match:N,transaction:L,allowSpaces:k})?!1:k?N.range.from===D.from:N.range.from===D.from&&!L$(L);function A(N,D){var z;try{const _=t.getState(N.state),V=_?.decorationId?N.dom.querySelector(`[data-decoration-id="${_.decorationId}"]`):null,ee={editor:e,range:_?.range||{from:0,to:0},query:_?.query||null,text:_?.text||null,items:[],command:be=>d({editor:e,range:_?.range||{from:0,to:0},props:be}),decorationNode:V,clientRect:S(N,V)};(z=w?.onExit)==null||z.call(w,ee)}catch{}const L=N.state.tr.setMeta(D,{exit:!0});N.dispatch(L)}const C=new me({key:t,view(){return{update:async(N,D)=>{var z,L,_,V,ee,be,I;const P=(z=this.key)==null?void 0:z.getState(D),ne=(L=this.key)==null?void 0:L.getState(N.state),R=P.active&&ne.active&&P.range.from!==ne.range.from,q=!P.active&&ne.active,le=P.active&&!ne.active,Se=!q&&!le&&P.query!==ne.query,Ot=q||R&&Se,Ye=Se||R,Ce=le||R&&Se;if(!Ot&&!Ye&&!Ce)return;const Ze=Ce&&!Ot?P:ne,wt=N.dom.querySelector(`[data-decoration-id="${Ze.decorationId}"]`);x={editor:e,range:Ze.range,query:Ze.query,text:Ze.text,items:[],command:Dt=>d({editor:e,range:Ze.range,props:Dt}),decorationNode:wt,clientRect:S(N,wt)},Ot&&((_=w?.onBeforeStart)==null||_.call(w,x)),Ye&&((V=w?.onBeforeUpdate)==null||V.call(w,x)),(Ye||Ot)&&(x.items=await h({editor:e,query:Ze.query})),Ce&&((ee=w?.onExit)==null||ee.call(w,x)),Ye&&((be=w?.onUpdate)==null||be.call(w,x)),Ot&&((I=w?.onStart)==null||I.call(w,x))},destroy:()=>{var N;x&&((N=w?.onExit)==null||N.call(w,x))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1,dismissedRange:null}},apply(N,D,z,L){const{isEditable:_}=e,{composing:V}=e.view,{selection:ee}=N,{empty:be,from:I}=ee,P={...D},ne=N.getMeta(t);if(ne&&ne.exit)return P.active=!1,P.decorationId=null,P.range={from:0,to:0},P.query=null,P.text=null,P.dismissedRange=D.active?{...D.range}:D.dismissedRange,P;if(P.composing=V,N.docChanged&&P.dismissedRange!==null&&(P.dismissedRange={from:N.mapping.map(P.dismissedRange.from),to:N.mapping.map(P.dismissedRange.to)}),_&&(be||e.view.composing)){(I<D.range.from||I>D.range.to)&&!V&&!D.composing&&(P.active=!1);const R=m({char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:i,startOfLine:o,$position:ee.$from}),q=`id_${Math.floor(Math.random()*4294967295)}`;R&&p({editor:e,state:L,range:R.range,isActive:D.active})&&(!y||y({editor:e,range:R.range,query:R.query,text:R.text,transaction:N}))?(P.dismissedRange!==null&&!v({match:R,dismissedRange:P.dismissedRange,state:L,transaction:N})&&(P.dismissedRange=null),P.dismissedRange===null?(P.active=!0,P.decorationId=D.decorationId?D.decorationId:q,P.range=R.range,P.query=R.query,P.text=R.text):P.active=!1):(R||(P.dismissedRange=null),P.active=!1)}else P.active=!1;return P.active||(P.decorationId=null,P.range={from:0,to:0},P.query=null,P.text=null),P}},props:{handleKeyDown(N,D){var z,L;const{active:_,range:V}=C.getState(N.state);if(!_)return!1;if(D.key==="Escape"||D.key==="Esc"){const be=C.getState(N.state);return(z=w?.onKeyDown)==null||z.call(w,{view:N,event:D,range:be.range}),A(N,t),!0}return((L=w?.onKeyDown)==null?void 0:L.call(w,{view:N,event:D,range:V}))||!1},decorations(N){const{active:D,range:z,decorationId:L,query:_}=C.getState(N);if(!D)return null;const V=!_?.length,ee=[a];return V&&ee.push(u),xe.create(N.doc,[_e.inline(z.from,z.to,{nodeName:l,class:ee.join(" "),"data-decoration-id":L,"data-decoration-content":c})])}}});return C}const tv=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim();const j$=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const $$=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase());const Jy=t=>{const e=$$(t);return e.charAt(0).toUpperCase()+e.slice(1)};var B$={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const z$=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0;return!1};const H$=E.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:i,iconNode:o,...l},a)=>E.createElement("svg",{ref:a,...B$,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:tv("lucide",s),...!i&&!z$(l)&&{"aria-hidden":"true"},...l},[...o.map(([c,u])=>E.createElement(c,u)),...Array.isArray(i)?i:[i]]));const X=(t,e)=>{const n=E.forwardRef(({className:r,...s},i)=>E.createElement(H$,{ref:i,iconNode:e,className:tv(`lucide-${j$(Jy(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Jy(t),n};const F$=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],cc=X("bold",F$);const U$=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Gy=X("circle-alert",U$);const V$=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],W$=X("circle-check-big",V$);const q$=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],K$=X("circle-plus",q$);const J$=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],G$=X("circle-x",J$);const Y$=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Hr=X("code-xml",Y$);const X$=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],li=X("code",X$);const Z$=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Q$=X("columns-2",Z$);const eB=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],tB=X("columns-3",eB);const nB=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],nv=X("download",nB);const rB=[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]],sB=X("eraser",rB);const iB=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],oB=X("eye",iB);const lB=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],aB=X("file-code-corner",lB);const cB=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],uB=X("hash",cB);const dB=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],Gs=X("heading-1",dB);const hB=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],Ho=X("heading-2",hB);const fB=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],Gc=X("heading-3",fB);const pB=[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]],mB=X("heading-4",pB);const gB=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]],yB=X("heading-5",gB);const bB=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]],xB=X("heading-6",bB);const wB=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],ts=X("image",wB);const kB=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],mp=X("italic",kB);const vB=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Yc=X("link-2",vB);const SB=[["path",{d:"M11 5h10",key:"1cz7ny"}],["path",{d:"M11 12h10",key:"1438ji"}],["path",{d:"M11 19h10",key:"11t30w"}],["path",{d:"M4 4h1v5",key:"10yrso"}],["path",{d:"M4 9h2",key:"r1h2o0"}],["path",{d:"M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02",key:"xtkcd5"}]],Fo=X("list-ordered",SB);const CB=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],ai=X("list",CB);const EB=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],AB=X("loader-circle",EB);const MB=[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]],Xc=X("megaphone",MB);const TB=[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]],NB=X("menu",TB);const RB=[["path",{d:"M5 12h14",key:"1ays0h"}]],Zc=X("minus",RB);const _B=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],gp=X("palette",_B);const OB=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],DB=X("play",OB);const LB=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],IB=X("redo-2",LB);const PB=[["path",{d:"M14 4a1 1 0 0 1 1-1",key:"dhj8ez"}],["path",{d:"M15 10a1 1 0 0 1-1-1",key:"1mnyi5"}],["path",{d:"M21 4a1 1 0 0 0-1-1",key:"sfs9ap"}],["path",{d:"M21 9a1 1 0 0 1-1 1",key:"mp6qeo"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a2 2 0 0 1 2-2h2",key:"15xut4"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}]],jB=X("replace",PB);const $B=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],BB=X("rotate-ccw",$B);const zB=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]],HB=X("rows-2",zB);const FB=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],UB=X("rows-3",FB);const VB=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],WB=X("search",VB);const qB=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],KB=X("sparkles",qB);const JB=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Qc=X("square-check-big",JB);const GB=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],rv=X("strikethrough",GB);const YB=[["path",{d:"m4 5 8 8",key:"1eunvl"}],["path",{d:"m12 5-8 8",key:"1ah0jp"}],["path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07",key:"e8ta8j"}]],sv=X("subscript",YB);const XB=[["path",{d:"m4 19 8-8",key:"hr47gm"}],["path",{d:"m12 19-8-8",key:"1dhhmo"}],["path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06",key:"1dfcux"}]],iv=X("superscript",XB);const ZB=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],Uo=X("table-2",ZB);const QB=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],ez=X("terminal",QB);const tz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 19H5",key:"vjpgq2"}]],Vo=X("text-align-center",tz);const nz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 19H7",key:"4cu937"}]],Wo=X("text-align-end",nz);const rz=[["path",{d:"M3 5h18",key:"1u36vt"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 19h18",key:"awlh7x"}]],yp=X("text-align-justify",rz);const sz=[["path",{d:"M21 5H3",key:"1fi0y6"}],["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 19H3",key:"z6ezky"}]],Ys=X("text-align-start",sz);const iz=[["path",{d:"M17 5H3",key:"1cn7zz"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 19H8",key:"13qgcb"}],["path",{d:"M3 12v7",key:"1ri8j3"}]],qo=X("text-quote",iz);const oz=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],ov=X("trash-2",oz);const lz=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],eu=X("triangle-alert",lz);const az=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],ls=X("type",az);const cz=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],bp=X("underline",cz);const uz=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],dz=X("undo-2",uz);const hz=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],lv=X("video",hz);const fz=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],av=X("x",fz),xp=E.forwardRef(({items:t,command:e},n)=>{const[r,s]=E.useState(-1),i=E.useRef(null),o=a=>{const c=t[a];c&&e(c)};E.useEffect(()=>{if(t.length===0){s(-1);return}s(a=>{if(a===-1)return-1;const c=Math.min(Math.max(a,0),t.length-1);return Number.isFinite(c)?c:-1})},[t]),E.useEffect(()=>{if(!i.current||r===-1)return;const a=i.current.querySelector(`[data-index="${r}"]`);a&&a.scrollIntoView({block:"nearest"})},[r]),E.useImperativeHandle(n,()=>({onKeyDown:({event:a})=>t.length===0?!1:a.key==="ArrowUp"?(a.preventDefault(),s(c=>c===-1?t.length-1:(c-1+t.length)%t.length),!0):a.key==="ArrowDown"?(a.preventDefault(),s(c=>c===-1?0:(c+1)%t.length),!0):a.key==="Enter"?(a.preventDefault(),r!==-1&&o(r),!0):!1}));const l=a=>{a.stopPropagation()};return g.jsx("div",{ref:i,className:"z-50 max-h-72 w-72 overflow-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md",role:"listbox","aria-activedescendant":r!==-1?`cmd-opt-${r}`:void 0,tabIndex:-1,onWheel:l,style:{scrollbarWidth:"thin",scrollbarColor:"rgb(148 163 184) transparent"},children:t.length>0?t.map((a,c)=>{const u=r!==-1&&c===r;return g.jsxs("button",{id:`cmd-opt-${c}`,"data-index":c,role:"option","aria-selected":u,type:"button",onMouseDown:d=>d.preventDefault(),onClick:()=>o(c),className:Ie.cn("flex w-full items-center gap-2 rounded-sm p-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",u&&"bg-accent text-accent-foreground"),children:[g.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border bg-background",children:a.icon}),g.jsxs("div",{className:"min-w-0",children:[g.jsx("p",{className:"truncate font-medium",children:a.title}),a.description?g.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a.description}):null]})]},`${a.title}-${c}`)}):g.jsx("div",{className:"p-2 text-sm text-muted-foreground",children:"No results"})})});xp.displayName="SlashCommandList";const pz=[{title:"Text",description:"Start writing with plain text.",icon:E.createElement(ls,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).clearNodes().run()}},{title:"Heading 1",description:"Large section heading.",icon:E.createElement(Gs,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:1}).run()}},{title:"Heading 2",description:"Medium section heading.",icon:E.createElement(Ho,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:2}).run()}},{title:"Heading 3",description:"Small section heading.",icon:E.createElement(Gc,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:3}).run()}},{title:"Heading 4",description:"Extra small section heading.",icon:E.createElement(mB,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:4}).run()}},{title:"Heading 5",description:"Tiny section heading.",icon:E.createElement(yB,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:5}).run()}},{title:"Heading 6",description:"Smallest section heading.",icon:E.createElement(xB,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:6}).run()}},{title:"Bullet List",description:"Create a simple bulleted list.",icon:E.createElement(ai,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBulletList().run()}},{title:"Numbered List",description:"Create a list with numbering.",icon:E.createElement(Fo,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleOrderedList().run()}},{title:"Task List",description:"Create a list with checkboxes.",icon:E.createElement(Qc,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleTaskList().run()}},{title:"Blockquote",description:"Create a quote or citation.",icon:E.createElement(qo,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBlockquote().run()}},{title:"Code Block",description:"Create a code block with syntax highlighting.",icon:E.createElement(li,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleCodeBlock().run()}},{title:"Horizontal Rule",description:"Insert a horizontal divider.",icon:E.createElement(Zc,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHorizontalRule().run()}},{title:"Image",description:"Insert an image from URL.",icon:E.createElement(ts,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{const n=window.prompt("Enter image URL:");n&&t.chain().focus().deleteRange(e).setImage({src:n}).run()}},{title:"Table",description:"Insert a table with rows and columns.",icon:E.createElement(Uo,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{title:"Align Left",description:"Align text to the left.",icon:E.createElement(Ys,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("left").run()}},{title:"Align Center",description:"Center align text.",icon:E.createElement(Vo,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("center").run()}},{title:"Align Right",description:"Align text to the right.",icon:E.createElement(Wo,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("right").run()}},{title:"Justify",description:"Justify text alignment.",icon:E.createElement(yp,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("justify").run()}},{title:"Video",description:"Embed a video from URL.",icon:E.createElement(lv,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{const n=window.prompt("Enter video URL (YouTube, Vimeo, etc.):");n&&t.chain().focus().deleteRange(e).insertContent(`<p><a href="${n}" target="_blank">Video: ${n}</a></p>`).run()}},{title:"Alert",description:"Insert an alert or notice.",icon:E.createElement(eu,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.can().setAlertWidget()?t.chain().focus().deleteRange(e).setAlertWidget().run():t.chain().focus().deleteRange(e).toggleBlockquote().run()}},{title:"Call to Action",description:"Insert a call to action button.",icon:E.createElement(Xc,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.can().setCtaWidget()?t.chain().focus().deleteRange(e).setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}).run():t.chain().focus().deleteRange(e).insertContent("Call to Action").run()}}],cv=ce.create({name:"slashCommand",addOptions(){return{suggestion:{char:"/",allowSpaces:!1,allowedPrefixes:[" "],startOfLine:!1,decorationTag:"span",decorationClass:"slash-command"}}},addProseMirrorPlugins(){return[P$({char:"/",allowSpaces:!1,allowedPrefixes:[" "],startOfLine:!1,decorationTag:"span",decorationClass:"slash-command",editor:this.editor,items:({query:t})=>pz.filter(n=>n.title.toLowerCase().includes(t.toLowerCase())||n.description.toLowerCase().includes(t.toLowerCase())).slice(0,10),command:({editor:t,range:e,props:n})=>{n.command({editor:t,range:e})},render:()=>{let t=null,e=null,n=null;const r=i=>({getBoundingClientRect:()=>i()||new DOMRect(0,0,0,0)}),s=async i=>{if(!e)return;const o=r(i),{x:l,y:a}=await Mf(o,e,{placement:"bottom-start",middleware:[Af(6),Xx({fallbackPlacements:["top-start","bottom-start"]}),Yx({padding:8}),Zx({apply({availableWidth:c,availableHeight:u,elements:d}){Object.assign(d.floating.style,{maxWidth:`${Math.min(288,c-16)}px`,maxHeight:`${Math.min(288,u-16)}px`})}})],strategy:"fixed"});e.style.left=`${Math.round(l)}px`,e.style.top=`${Math.round(a)}px`};return{onStart:i=>{if(!i.clientRect)return;const o=i.clientRect;t=new Px(xp,{props:i,editor:i.editor}),e=document.createElement("div"),e.style.position="fixed",e.style.zIndex="10000",e.style.top="0",e.style.left="0",e.style.pointerEvents="none",e.appendChild(t.element),t.element.style.pointerEvents="auto",t.element.addEventListener("wheel",a=>{a.stopPropagation()},{passive:!0}),document.body.appendChild(e);const l=r(o);n=ti(l,e,()=>s(o)),s(o)},onUpdate:i=>{t?.updateProps(i),i.clientRect&&s(i.clientRect)},onKeyDown:({event:i})=>i.key==="Escape"?!0:t?.ref?.onKeyDown({event:i})??!1,onExit:()=>{n?.(),n=null,t?.destroy(),t=null,e?.remove(),e=null}}}})]}});var mz=Bf,gz=Hf;H_.extend({draggable:!0});UR.extend({draggable:!0});RR.extend({draggable:!0});mz.extend({draggable:!0});gz.extend({draggable:!0});Zw.extend({draggable:!0});Qw.extend({draggable:!0});Yw.extend({draggable:!0});Xw.extend({draggable:!0});const uv=ce.create({name:"draggableNodes",addGlobalAttributes(){return[{types:["paragraph","heading","blockquote","bulletList","orderedList","taskList","taskItem","codeBlock","image"],attributes:{draggable:{default:!0,parseHTML:()=>!0,renderHTML:()=>({"data-draggable":"true"})}}}]}}),yz=De.create({name:"styleTag",group:"block",atom:!0,isolating:!0,defining:!0,draggable:!1,addAttributes(){return{cssContent:{default:"",parseHTML:t=>t.innerHTML},type:{default:"text/css",parseHTML:t=>t.getAttribute("type"),renderHTML:t=>t.type?{type:t.type}:{}},media:{default:null,parseHTML:t=>t.getAttribute("media"),renderHTML:t=>t.media?{media:t.media}:{}}}},parseHTML(){return[{tag:"style",getAttrs:t=>{const e=t,n={cssContent:e.innerHTML,type:e.getAttribute("type")},r=e.getAttribute("media");return r!==null&&(n.media=r),n}}]},renderHTML({HTMLAttributes:t,node:e}){const n={...t};return delete n.cssContent,["style",n,e.attrs.cssContent||""]},addNodeView(){return({node:t,editor:e,getPos:n})=>{const r=document.createElement("div");return r.setAttribute("data-style-node-placeholder","true"),r.style.border="1px dashed #999",r.style.padding="8px",r.style.margin="1rem 0",r.style.fontFamily="monospace",r.style.fontSize="0.9em",r.style.color="#555",r.style.cursor="pointer",r.textContent="[Custom CSS Block - Edit in Source View]",r.contentEditable="false",r.title="Click to open Source View",r.addEventListener("click",()=>{try{e?.chain().focus()}catch{}try{window.dispatchEvent(new CustomEvent("editor:openSourceView"))}catch{}}),{dom:r}}}}),bz=De.create({name:"divBlock",group:"block",content:"block*",defining:!0,draggable:!0,addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}},id:{default:null,parseHTML:t=>t.getAttribute("id"),renderHTML:t=>t.id?{id:t.id}:{}}}},parseHTML(){return[{tag:"div",priority:51,getAttrs:t=>{const e=t,n={};for(let r=0;r<e.attributes.length;r++){const s=e.attributes[r];n[s.name]=s.value}return n}}]},renderHTML({node:t}){return["div",fe(this.options.HTMLAttributes,t.attrs),0]}}),xz=ce.create({name:"preserveAllAttributesExtension",addGlobalAttributes(){return[{types:["paragraph","heading","listItem","blockquote","codeBlock","bulletList","orderedList","textStyle"],attributes:{style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}},class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},id:{default:null,parseHTML:t=>t.getAttribute("id"),renderHTML:t=>t.id?{id:t.id}:{}},dataAttributes:{default:null,parseHTML:t=>{const e={};for(let n=0;n<t.attributes.length;n++){const r=t.attributes[n];r.name.startsWith("data-")&&(e[r.name]=r.value)}return Object.keys(e).length>0?e:null},renderHTML:t=>t.dataAttributes||{}}}}]}}),wz=De.create({name:"scriptTag",group:"block",atom:!0,isolating:!0,defining:!0,draggable:!1,addAttributes(){return{jsContent:{default:"",parseHTML:t=>t.innerHTML},type:{default:"text/javascript",parseHTML:t=>t.getAttribute("type"),renderHTML:t=>t.type?{type:t.type}:{}},src:{default:null,parseHTML:t=>t.getAttribute("src"),renderHTML:t=>t.src?{src:t.src}:{}},async:{default:null,parseHTML:t=>t.getAttribute("async"),renderHTML:t=>t.async!=null?{async:""}:{}},defer:{default:null,parseHTML:t=>t.getAttribute("defer"),renderHTML:t=>t.defer!=null?{defer:""}:{}}}},parseHTML(){return[{tag:"script",getAttrs:t=>{const e=t,n={jsContent:e.innerHTML,type:e.getAttribute("type")},r=e.getAttribute("src");return r!==null&&(n.src=r),e.hasAttribute("async")&&(n.async=""),e.hasAttribute("defer")&&(n.defer=""),n}}]},renderHTML({HTMLAttributes:t,node:e}){const n={...t};return delete n.jsContent,["script",n,e.attrs.src?"":e.attrs.jsContent||""]},addNodeView(){return({editor:t})=>{const e=document.createElement("div");return e.setAttribute("data-script-node-placeholder","true"),e.style.border="1px dashed #999",e.style.padding="8px",e.style.margin="1rem 0",e.style.fontFamily="monospace",e.style.fontSize="0.9em",e.style.color="#555",e.style.cursor="pointer",e.textContent="[Custom JavaScript Block - Edit in Source View]",e.contentEditable="false",e.title="Click to open Source View",e.addEventListener("click",()=>{try{t?.chain().focus()}catch{}try{window.dispatchEvent(new CustomEvent("editor:openSourceView"))}catch{}}),{dom:e}}}}),kz=De.create({name:"svg",group:"inline",inline:!0,atom:!0,addOptions(){return{HTMLAttributes:{class:"inline-block align-middle"}}},addAttributes(){return{html:{default:""},viewBox:{default:"0 0 24 24"},width:{default:null},height:{default:null},fill:{default:"none"},stroke:{default:"currentColor"},class:{default:null},style:{default:null},xmlns:{default:"http://www.w3.org/2000/svg"}}},parseHTML(){return[{tag:"svg",priority:60,getAttrs:t=>{if(!(t instanceof Element))return!1;const e={html:t.innerHTML};return t.getAttribute("viewBox")&&(e.viewBox=t.getAttribute("viewBox")),t.getAttribute("width")&&(e.width=t.getAttribute("width")),t.getAttribute("height")&&(e.height=t.getAttribute("height")),t.getAttribute("fill")&&(e.fill=t.getAttribute("fill")),t.getAttribute("stroke")&&(e.stroke=t.getAttribute("stroke")),t.getAttribute("class")&&(e.class=t.getAttribute("class")),t.getAttribute("style")&&(e.style=t.getAttribute("style")),t.getAttribute("xmlns")&&(e.xmlns=t.getAttribute("xmlns")),e}}]},renderHTML({HTMLAttributes:t}){const e=document.createElementNS("http://www.w3.org/2000/svg","svg"),{html:n,...r}=t;return Object.entries(fe(this.options.HTMLAttributes,r)).forEach(([s,i])=>{i!=null&&e.setAttribute(s,String(i))}),n&&(e.innerHTML=n),{dom:e}},addNodeView(){return({node:t,HTMLAttributes:e})=>{const n=document.createElementNS("http://www.w3.org/2000/svg","svg"),{html:r,...s}=e;return Object.entries(s).forEach(([i,o])=>{i!=="html"&&o!==null&&o!==void 0&&n.setAttribute(i,String(o))}),t.attrs.html?n.innerHTML=t.attrs.html:r&&(n.innerHTML=r),n.classList.add("parsed-svg-node"),{dom:n}}}}),vz=De.create({name:"spanComponent",group:"inline",inline:!0,content:"inline*",addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}}}},parseHTML(){return[{tag:"span",priority:60,getAttrs:t=>t instanceof HTMLElement&&t.hasAttribute("class")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",fe(this.options.HTMLAttributes,t),0]}}),Sz=A$({html:C$,css:f$,js:b$,ts:S$,python:w$,json:x$,bash:s$,sql:k$}),Yy="http://www.w3.org/2000/svg";function Xy(t){const e=document.createElementNS(Yy,"svg");return e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","currentColor"),e.classList.add("tiptap-drag-handle__icon","tiptap-drag-handle__icon--filled"),t.forEach(n=>{const r=document.createElementNS(Yy,"path");r.setAttribute("d",n),e.appendChild(r)}),e}const uc=[MO.configure({codeBlock:!1,link:!1,undoRedo:!1,bulletList:{HTMLAttributes:{class:"list-disc pl-4"},keepMarks:!0,keepAttributes:!1},orderedList:{HTMLAttributes:{class:"list-decimal pl-4"},keepMarks:!0,keepAttributes:!1},dropcursor:{color:"#60A5FA",width:2},gapcursor:!1}),k_.configure({openOnClick:!1,autolink:!0,defaultProtocol:"https",protocols:["http","https","ftp","mailto"],validate:t=>/^https?:\/\//.test(t),HTMLAttributes:{class:"text-primary underline underline-offset-2 hover:text-primary/80 cursor-pointer",rel:"noopener noreferrer",target:"_blank"}}),IL,PL.configure({depth:100,newGroupDelay:500}),Yw.configure({lowlight:Sz,defaultLanguage:"plaintext",HTMLAttributes:{class:"relative rounded-md bg-muted p-4 font-mono text-sm"}}),bz,yz,wz,kz,vz,xz,jO.configure({inline:!0,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-md"}}),Zw.configure({HTMLAttributes:{class:"list-none pl-0 space-y-1"}}),Qw.configure({nested:!0,HTMLAttributes:{class:"flex items-start gap-2 my-1"}}),f1.configure({resizable:!0,cellMinWidth:100,HTMLAttributes:{class:"w-full border-collapse border border-gray-300 dark:border-gray-700 my-4"}}),qD.configure({HTMLAttributes:{class:"border-b border-gray-300 dark:border-gray-700"}}),KD.configure({HTMLAttributes:{class:"bg-gray-100 dark:bg-gray-800 font-bold p-3 text-left border border-gray-300 dark:border-gray-700"}}),JD.configure({HTMLAttributes:{class:"p-3 border border-gray-300 dark:border-gray-700 min-w-[100px]"}}),fL.configure({color:{types:["textStyle"]},fontFamily:{types:["textStyle"]},fontSize:{types:["textStyle"]}}),ZD.configure({multicolor:!0,HTMLAttributes:{class:"rounded-sm px-1 py-0.5"}}),eL,nL,sL.extend({addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{if(t.style.textAlign)return t.style.textAlign;if(t.getAttribute("align"))return t.getAttribute("align");const e=t.getAttribute("class")||"";return/(?:^|\s)text-center(?:\s|$)/.test(e)?"center":/(?:^|\s)text-right(?:\s|$)/.test(e)?"right":/(?:^|\s)text-justify(?:\s|$)/.test(e)?"justify":/(?:^|\s)text-left(?:\s|$)/.test(e)?"left":null},renderHTML:t=>t.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${t.textAlign} !important`}}}}]}}).configure({types:["heading","paragraph","div"],alignments:["left","center","right","justify"],defaultAlignment:"left"}),LL,Zk,pL.configure({limit:5e4,mode:"textSize"}),Qk,ev,cv,uv,jj,r$.configure({computePositionConfig:{placement:"left-start",strategy:"absolute",middleware:[Af({mainAxis:5,crossAxis:0})]},onElementDragStart:()=>{typeof document<"u"&&document.body.classList.add("dragging")},onElementDragEnd:()=>{typeof document<"u"&&document.body.classList.remove("dragging")},onNodeChange:({editor:t})=>{},render(){const t=document.createElement("div");t.classList.add("drag-handle","tiptap-drag-handle"),typeof window<"u"&&(window.__dragHandleElement=t);const e=document.createElement("div");e.classList.add("tiptap-drag-handle__group"),e.setAttribute("role","group"),e.dataset.orientation="horizontal",t.appendChild(e);const n=document.createElement("button");n.type="button",n.classList.add("tiptap-drag-handle__button","tiptap-drag-handle__button--ghost","tiptap-drag-handle__plus"),n.setAttribute("aria-label","Insert block"),n.setAttribute("title","Insert block");const r=Xy(["M13 5C13 4.44772 12.5523 4 12 4C11.4477 4 11 4.44772 11 5V11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H11V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V13H19C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11H13V5Z"]);n.appendChild(r),e.appendChild(n);const s=document.createElement("button");s.type="button",s.classList.add("tiptap-drag-handle__button","tiptap-drag-handle__button--ghost","tiptap-drag-handle__grip"),s.setAttribute("aria-label","Drag to reorder"),s.setAttribute("title","Drag to reorder"),s.setAttribute("tabindex","0"),s.setAttribute("aria-haspopup","menu"),s.setAttribute("aria-expanded","false");const i=Xy(["M9 3C7.89543 3 7 3.89543 7 5C7 6.10457 7.89543 7 9 7C10.1046 7 11 6.10457 11 5C11 3.89543 10.1046 3 9 3Z","M9 10C7.89543 10 7 10.8954 7 12C7 13.1046 7.89543 14 9 14C10.1046 14 11 13.1046 11 12C11 10.8954 10.1046 10 9 10Z","M7 19C7 17.8954 7.89543 17 9 17C10.1046 17 11 17.8954 11 19C11 20.1046 10.1046 21 9 21C7.89543 21 7 20.1046 7 19Z","M15 10C13.8954 10 13 10.8954 13 12C13 13.1046 13.8954 14 15 14C16.1046 14 17 13.1046 17 12C17 10.8954 16.1046 10 15 10Z","M13 5C13 3.89543 13.8954 3 15 3C16.1046 3 17 3.89543 17 5C17 6.10457 16.1046 7 15 7C13.8954 7 13 6.10457 13 5Z","M15 17C13.8954 17 13 17.8954 13 19C13 20.1046 13.8954 21 15 21C16.1046 21 17 20.1046 17 19C17 17.8954 16.1046 17 15 17Z"]);s.appendChild(i),e.appendChild(s);const o=()=>{const l=new CustomEvent("tiptap-gutter-toggle",{bubbles:!0,detail:{handle:e,button:n}});e.dispatchEvent(l)};return n.addEventListener("click",l=>{l.preventDefault(),l.stopPropagation(),o()}),n.addEventListener("keydown",l=>{(l.key==="Enter"||l.key===" ")&&(l.preventDefault(),o())}),s.addEventListener("mousedown",()=>{s.setAttribute("aria-expanded","true")}),s.addEventListener("mouseup",()=>{s.setAttribute("aria-expanded","false")}),t}})];var Cz=typeof document<"u",Ez=function(){},Rh=Cz?E.useLayoutEffect:Ez;const Az={...se},Mz=Az.useInsertionEffect,Tz=Mz||(t=>t());function Nz(t){const e=se.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return Tz(()=>{e.current=t}),se.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return e.current==null?void 0:e.current(...r)},[])}var Rz=typeof document<"u",_z=function(){},Zl=Rz?E.useLayoutEffect:_z;function dc(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,s;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!dc(t[r],e[r]))return!1;return!0}if(s=Object.keys(t),n=s.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,s[r]))return!1;for(r=n;r--!==0;){const i=s[r];if(!(i==="_owner"&&t.$$typeof)&&!dc(t[i],e[i]))return!1}return!0}return t!==t&&e!==e}function dv(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Zy(t,e){const n=dv(t);return Math.round(e*n)/n}function bd(t){const e=se.useRef(t);return Zl(()=>{e.current=t}),e}function Oz(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:o}={},transform:l=!0,whileElementsMounted:a,open:c}=t,[u,d]=se.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[h,f]=se.useState(r);dc(h,r)||f(r);const[p,m]=se.useState(null),[y,b]=se.useState(null),x=se.useCallback(I=>{I!==S.current&&(S.current=I,m(I))},[]),w=se.useCallback(I=>{I!==v.current&&(v.current=I,b(I))},[]),k=i||p,T=o||y,S=se.useRef(null),v=se.useRef(null),A=se.useRef(u),C=a!=null,N=bd(a),D=bd(s),z=bd(c),L=se.useCallback(()=>{if(!S.current||!v.current)return;const I={placement:e,strategy:n,middleware:h};D.current&&(I.platform=D.current),Mf(S.current,v.current,I).then(P=>{const ne={...P,isPositioned:z.current!==!1};_.current&&!dc(A.current,ne)&&(A.current=ne,pS.flushSync(()=>{d(ne)}))})},[h,e,n,D,z]);Zl(()=>{c===!1&&A.current.isPositioned&&(A.current.isPositioned=!1,d(I=>({...I,isPositioned:!1})))},[c]);const _=se.useRef(!1);Zl(()=>(_.current=!0,()=>{_.current=!1}),[]),Zl(()=>{if(k&&(S.current=k),T&&(v.current=T),k&&T){if(N.current)return N.current(k,T,L);L()}},[k,T,L,N,C]);const V=se.useMemo(()=>({reference:S,floating:v,setReference:x,setFloating:w}),[x,w]),ee=se.useMemo(()=>({reference:k,floating:T}),[k,T]),be=se.useMemo(()=>{const I={position:n,left:0,top:0};if(!ee.floating)return I;const P=Zy(ee.floating,u.x),ne=Zy(ee.floating,u.y);return l?{...I,transform:"translate("+P+"px, "+ne+"px)",...dv(ee.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:P,top:ne}},[n,l,ee.floating,u.x,u.y]);return se.useMemo(()=>({...u,update:L,refs:V,elements:ee,floatingStyles:be}),[u,L,V,ee,be])}const Ko=(t,e)=>{const n=Af(t);return{name:n.name,fn:n.fn,options:[t,e]}},tu=(t,e)=>{const n=Yx(t);return{name:n.name,fn:n.fn,options:[t,e]}},nu=(t,e)=>{const n=Xx(t);return{name:n.name,fn:n.fn,options:[t,e]}},Dz=(t,e)=>{const n=Zx(t);return{name:n.name,fn:n.fn,options:[t,e]}},Lz={...se};let Qy=!1,Iz=0;const eb=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+Iz++;function Pz(){const[t,e]=se.useState(()=>Qy?eb():void 0);return Rh(()=>{t==null&&e(eb())},[]),se.useEffect(()=>{Qy=!0},[]),t}const jz=Lz.useId,$z=jz||Pz;let _h;process.env.NODE_ENV!=="production"&&(_h=new Set);function Bz(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((t=_h)!=null&&t.has(s))){var i;(i=_h)==null||i.add(s),console.error(s)}}function zz(){const t=new Map;return{emit(e,n){var r;(r=t.get(e))==null||r.forEach(s=>s(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var r;(r=t.get(e))==null||r.delete(n)}}}const Hz=se.createContext(null),Fz=se.createContext(null),Uz=()=>{var t;return((t=se.useContext(Hz))==null?void 0:t.id)||null},Vz=()=>se.useContext(Fz);function Wz(t){const{open:e=!1,onOpenChange:n,elements:r}=t,s=$z(),i=se.useRef({}),[o]=se.useState(()=>zz()),l=Uz()!=null;if(process.env.NODE_ENV!=="production"){const f=r.reference;f&&!pt(f)&&Bz("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[a,c]=se.useState(r.reference),u=Nz((f,p,m)=>{i.current.openEvent=f?p:void 0,o.emit("openchange",{open:f,event:p,reason:m,nested:l}),n?.(f,p,m)}),d=se.useMemo(()=>({setPositionReference:c}),[]),h=se.useMemo(()=>({reference:a||r.reference||null,floating:r.floating||null,domReference:r.reference}),[a,r.reference,r.floating]);return se.useMemo(()=>({dataRef:i,open:e,onOpenChange:u,elements:h,events:o,floatingId:s,refs:d}),[e,u,h,o,s,d])}function Jo(t){t===void 0&&(t={});const{nodeId:e}=t,n=Wz({...t,elements:{reference:null,floating:null,...t.elements}}),r=t.rootContext||n,s=r.elements,[i,o]=se.useState(null),[l,a]=se.useState(null),u=s?.domReference||i,d=se.useRef(null),h=Vz();Rh(()=>{u&&(d.current=u)},[u]);const f=Oz({...t,elements:{...s,...l&&{reference:l}}}),p=se.useCallback(w=>{const k=pt(w)?{getBoundingClientRect:()=>w.getBoundingClientRect(),getClientRects:()=>w.getClientRects(),contextElement:w}:w;a(k),f.refs.setReference(k)},[f.refs]),m=se.useCallback(w=>{(pt(w)||w===null)&&(d.current=w,o(w)),(pt(f.refs.reference.current)||f.refs.reference.current===null||w!==null&&!pt(w))&&f.refs.setReference(w)},[f.refs]),y=se.useMemo(()=>({...f.refs,setReference:m,setPositionReference:p,domReference:d}),[f.refs,m,p]),b=se.useMemo(()=>({...f.elements,domReference:u}),[f.elements,u]),x=se.useMemo(()=>({...f,...r,refs:y,elements:b,nodeId:e}),[f,y,b,e,r]);return Rh(()=>{r.dataRef.current.floatingContext=x;const w=h?.nodesRef.current.find(k=>k.id===e);w&&(w.context=x)}),se.useMemo(()=>({...f,context:x,refs:y,elements:b}),[f,y,b,x])}const qz="_pickerRoot_1wq30_1",Kz="_picker_1wq30_1",tb={pickerRoot:qz,picker:Kz};function ru(){return(ru=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function hv(t,e){if(t==null)return{};var n,r,s={},i=Object.keys(t);for(r=0;r<i.length;r++)e.indexOf(n=i[r])>=0||(s[n]=t[n]);return s}function Yi(t){var e=E.useRef(t),n=E.useRef(function(r){e.current&&e.current(r)});return e.current=t,n.current}var To=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t<e?e:t},Xi=function(t){return"touches"in t},Oh=function(t){return t&&t.ownerDocument.defaultView||self},nb=function(t,e,n){var r=t.getBoundingClientRect(),s=Xi(e)?(function(i,o){for(var l=0;l<i.length;l++)if(i[l].identifier===o)return i[l];return i[0]})(e.touches,n):e;return{left:To((s.pageX-(r.left+Oh(t).pageXOffset))/r.width),top:To((s.pageY-(r.top+Oh(t).pageYOffset))/r.height)}},rb=function(t){!Xi(t)&&t.preventDefault()},fv=E.memo(function(t){var e=t.onMove,n=t.onKey,r=t.onEnd,s=hv(t,["onMove","onKey","onEnd"]),i=E.useRef(null),o=Yi(e),l=Yi(n),a=Yi(r),c=E.useRef(null),u=E.useRef(!1),d=E.useMemo(function(){var y=function(w){rb(w),(Xi(w)?w.touches.length>0:w.buttons>0)&&i.current?o(nb(i.current,w,c.current)):(x(!1),a())},b=function(){x(!1),a()};function x(w){var k=u.current,T=Oh(i.current),S=w?T.addEventListener:T.removeEventListener;S(k?"touchmove":"mousemove",y),S(k?"touchend":"mouseup",b)}return[function(w){var k=w.nativeEvent,T=i.current;if(T&&(rb(k),!(function(v,A){return A&&!Xi(v)})(k,u.current)&&T)){if(Xi(k)){u.current=!0;var S=k.changedTouches||[];S.length&&(c.current=S[0].identifier)}T.focus(),o(nb(T,k,c.current)),x(!0)}},function(w){var k=w.which||w.keyCode;k<37||k>40||(w.preventDefault(),l({left:k===39?.05:k===37?-.05:0,top:k===40?.05:k===38?-.05:0}))},function(w){var k=w.which||w.keyCode;k>=37&&k<=40&&a()},x]},[l,o,a]),h=d[0],f=d[1],p=d[2],m=d[3];return E.useEffect(function(){return m},[m]),E.createElement("div",ru({},s,{onTouchStart:h,onMouseDown:h,className:"react-colorful__interactive",ref:i,onKeyDown:f,onKeyUp:p,tabIndex:0,role:"slider"}))}),wp=function(t){return t.filter(Boolean).join(" ")},pv=function(t){var e=t.color,n=t.left,r=t.top,s=r===void 0?.5:r,i=wp(["react-colorful__pointer",t.className]);return E.createElement("div",{className:i,style:{top:100*s+"%",left:100*n+"%"}},E.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:e}}))},ut=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n},Jz=function(t){return Qz(Dh(t))},Dh=function(t){return t[0]==="#"&&(t=t.substring(1)),t.length<6?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?ut(parseInt(t[3]+t[3],16)/255,2):1}:{r:parseInt(t.substring(0,2),16),g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16),a:t.length===8?ut(parseInt(t.substring(6,8),16)/255,2):1}},Gz=function(t){return Zz(Xz(t))},Yz=function(t){var e=t.s,n=t.v,r=t.a,s=(200-e)*n/100;return{h:ut(t.h),s:ut(s>0&&s<200?e*n/100/(s<=100?s:200-s)*100:0),l:ut(s/2),a:ut(r,2)}},Lh=function(t){var e=Yz(t);return"hsl("+e.h+", "+e.s+"%, "+e.l+"%)"},Xz=function(t){var e=t.h,n=t.s,r=t.v,s=t.a;e=e/360*6,n/=100,r/=100;var i=Math.floor(e),o=r*(1-n),l=r*(1-(e-i)*n),a=r*(1-(1-e+i)*n),c=i%6;return{r:ut(255*[r,l,o,o,a,r][c]),g:ut(255*[a,r,r,l,o,o][c]),b:ut(255*[o,o,a,r,r,l][c]),a:ut(s,2)}},Rl=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},Zz=function(t){var e=t.r,n=t.g,r=t.b,s=t.a,i=s<1?Rl(ut(255*s)):"";return"#"+Rl(e)+Rl(n)+Rl(r)+i},Qz=function(t){var e=t.r,n=t.g,r=t.b,s=t.a,i=Math.max(e,n,r),o=i-Math.min(e,n,r),l=o?i===e?(n-r)/o:i===n?2+(r-e)/o:4+(e-n)/o:0;return{h:ut(60*(l<0?l+6:l)),s:ut(i?o/i*100:0),v:ut(i/255*100),a:s}},eH=E.memo(function(t){var e=t.hue,n=t.onChange,r=t.onChangeEnd,s=wp(["react-colorful__hue",t.className]);return E.createElement("div",{className:s},E.createElement(fv,{onMove:function(i){n({h:360*i.left})},onKey:function(i){n({h:To(e+360*i.left,0,360)})},onEnd:r,"aria-label":"Hue","aria-valuenow":ut(e),"aria-valuemax":"360","aria-valuemin":"0"},E.createElement(pv,{className:"react-colorful__hue-pointer",left:e/360,color:Lh({h:e,s:100,v:100,a:1})})))}),tH=E.memo(function(t){var e=t.hsva,n=t.onChange,r=t.onChangeEnd,s={backgroundColor:Lh({h:e.h,s:100,v:100,a:1})};return E.createElement("div",{className:"react-colorful__saturation",style:s},E.createElement(fv,{onMove:function(i){n({s:100*i.left,v:100-100*i.top})},onKey:function(i){n({s:To(e.s+100*i.left,0,100),v:To(e.v-100*i.top,0,100)})},onEnd:r,"aria-label":"Color","aria-valuetext":"Saturation "+ut(e.s)+"%, Brightness "+ut(e.v)+"%"},E.createElement(pv,{className:"react-colorful__saturation-pointer",top:1-e.v/100,left:e.s/100,color:Lh(e)})))}),mv=function(t,e){if(t===e)return!0;for(var n in t)if(t[n]!==e[n])return!1;return!0},nH=function(t,e){return t.toLowerCase()===e.toLowerCase()||mv(Dh(t),Dh(e))};function rH(t,e,n,r){var s=Yi(n),i=Yi(r),o=E.useState(function(){return t.toHsva(e)}),l=o[0],a=o[1],c=E.useRef({color:e,hsva:l}),u=E.useRef(!1);E.useEffect(function(){if(!t.equal(e,c.current.color)){var f=t.toHsva(e);c.current={hsva:f,color:e},a(f),u.current=!1}},[e,t]),E.useEffect(function(){var f;mv(l,c.current.hsva)||t.equal(f=t.fromHsva(l),c.current.color)||(c.current={hsva:l,color:f},s(f),u.current=!0)},[l,t,s]);var d=E.useCallback(function(f){a(function(p){return Object.assign({},p,f)})},[]),h=E.useCallback(function(){u.current&&(u.current=!1,i(c.current.color))},[i]);return[l,d,h]}var sH=typeof window<"u"?E.useLayoutEffect:E.useEffect,iH=function(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0},sb=new Map,oH=function(t){sH(function(){var e=t.current?t.current.ownerDocument:document;if(e!==void 0&&!sb.has(e)){var n=e.createElement("style");n.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`,sb.set(e,n);var r=iH();r&&n.setAttribute("nonce",r),e.head.appendChild(n)}},[])},lH=function(t){var e=t.className,n=t.colorModel,r=t.color,s=r===void 0?n.defaultColor:r,i=t.onChange,o=t.onChangeEnd,l=hv(t,["className","colorModel","color","onChange","onChangeEnd"]),a=E.useRef(null);oH(a);var c=rH(n,s,i,o),u=c[0],d=c[1],h=c[2],f=wp(["react-colorful",e]);return E.createElement("div",ru({},l,{ref:a,className:f}),E.createElement(tH,{hsva:u,onChange:d,onChangeEnd:h}),E.createElement(eH,{hue:u.h,onChange:d,onChangeEnd:h,className:"react-colorful__last-control"}))},aH={defaultColor:"000",toHsva:Jz,fromHsva:function(t){return Gz({h:t.h,s:t.s,v:t.v,a:1})},equal:nH},cH=function(t){return E.createElement(lH,ru({},t,{colorModel:aH}))};const ib="#1F2937",ob="#FFF7D1",uH=["#FFF7D1","#FFEAE3","#DCFCE7","#DBEAFE"],dH=[{title:"Brand",colors:[{label:"Primary",value:"hsl(var(--primary))"},{label:"Secondary",value:"hsl(var(--secondary))"},{label:"Accent",value:"hsl(var(--accent))"},{label:"Ring",value:"hsl(var(--ring))"}]},{title:"Neutrals",colors:[{label:"Foreground",value:"hsl(var(--foreground))"},{label:"Muted",value:"hsl(var(--muted-foreground))"},{label:"Background",value:"hsl(var(--background))"},{label:"Card",value:"hsl(var(--card))"}]},{title:"States",colors:[{label:"Warning",value:"hsl(var(--warning))"},{label:"Destructive",value:"hsl(var(--destructive))"},{label:"Success",value:"hsl(var(--chart-2))"},{label:"Info",value:"hsl(var(--chart-5))"}]},{title:"Utility",colors:[{label:"Secondary FG",value:"hsl(var(--secondary-foreground))"},{label:"Accent FG",value:"hsl(var(--accent-foreground))"},{label:"Primary FG",value:"hsl(var(--primary-foreground))"},{label:"Border",value:"hsl(var(--border))"}]}],hH=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,fH=/^#[0-9a-f]{6}$/i,gv=/^rgba?\((\s*\d{1,3}\s*,){2}\s*\d{1,3}\s*(,\s*(0|1|0?\.\d+)\s*)?\)$/i,yv=/^hsla?\((\s*\d{1,3}\s*,)(\s*\d{1,3}%\s*,)\s*\d{1,3}%\s*(,\s*(0|1|0?\.\d+)\s*)?\)$/i;function hc(t){const e=t.replace("#","").trim();return e.length===3||e.length===4?`#${e.split("").map(r=>r+r).join("").toUpperCase()}`:e.length===6||e.length===8?`#${e.toUpperCase()}`:t}function bv(t){const e=hc(t).replace("#","");if(e.length!==6&&e.length!==8)return null;const n=parseInt(e.slice(0,2),16),r=parseInt(e.slice(2,4),16),s=parseInt(e.slice(4,6),16),i=e.length===8?parseInt(e.slice(6,8),16)/255:1;return{r:n,g:r,b:s,a:i}}function Ih(t,e,n){return`#${[t,e,n].map(r=>Math.max(0,Math.min(255,Math.round(r))).toString(16).padStart(2,"0")).join("").toUpperCase()}`}function Zi(t,e=2){const n=10**e;return Math.round(t*n)/n}function Qi(t,e,n,r=1){const s=t/255,i=e/255,o=n/255,l=Math.max(s,i,o),a=Math.min(s,i,o);let c=0,u=0;const d=(l+a)/2;if(l!==a){const m=l-a;switch(u=d>.5?m/(2-l-a):m/(l+a),l){case s:c=(i-o)/m+(i<o?6:0);break;case i:c=(o-s)/m+2;break;case o:c=(s-i)/m+4;break}c/=6}const h=Math.round(c*360),f=Math.round(u*100),p=Math.round(d*100);return r!==1?`hsla(${h}, ${f}%, ${p}%, ${Zi(r,2)})`:`hsl(${h}, ${f}%, ${p}%)`}function lb(t){if(typeof window>"u"||typeof document>"u")return null;const e=document.createElement("span");if(e.style.color="",e.style.color=t,!e.style.color)return null;e.style.position="absolute",e.style.visibility="hidden",e.style.pointerEvents="none",document.body.appendChild(e);const n=getComputedStyle(e).color;document.body.removeChild(e);const r=n.match(/rgba?\(([^)]+)\)/i);if(!r)return null;const[s,i,o,l]=r[1].split(",").map(a=>a.trim()).map((a,c)=>c===3?parseFloat(a):parseInt(a,10));return[s,i,o].some(a=>Number.isNaN(a))?null:{r:s,g:i,b:o,a:typeof l=="number"&&!Number.isNaN(l)?l:1}}function In(t){if(!t)return null;const e=t.trim();if(hH.test(e)){const r=hc(e),s=bv(r);if(!s)return null;const i=`#${r.replace("#","").slice(0,6)}`;return{source:r,hex:i,rgb:s.a===1?`rgb(${s.r}, ${s.g}, ${s.b})`:`rgba(${s.r}, ${s.g}, ${s.b}, ${Zi(s.a,2)})`,hsl:Qi(s.r,s.g,s.b,s.a),alpha:s.a}}if(gv.test(e)||yv.test(e)){const r=lb(e);return r?{source:e,hex:Ih(r.r,r.g,r.b),rgb:r.a===1?`rgb(${r.r}, ${r.g}, ${r.b})`:`rgba(${r.r}, ${r.g}, ${r.b}, ${Zi(r.a,2)})`,hsl:Qi(r.r,r.g,r.b,r.a),alpha:r.a}:null}const n=lb(e);return n?{source:e,hex:Ih(n.r,n.g,n.b),rgb:n.a===1?`rgb(${n.r}, ${n.g}, ${n.b})`:`rgba(${n.r}, ${n.g}, ${n.b}, ${Zi(n.a,2)})`,hsl:Qi(n.r,n.g,n.b,n.a),alpha:n.a}:null}function xv(t){const e=bv(t);if(e)return{source:hc(t),hex:Ih(e.r,e.g,e.b),rgb:e.a===1?`rgb(${e.r}, ${e.g}, ${e.b})`:`rgba(${e.r}, ${e.g}, ${e.b}, ${Zi(e.a,2)})`,hsl:Qi(e.r,e.g,e.b,e.a),alpha:e.a};const n=hc(t);return{source:n,hex:n.slice(0,7),rgb:"rgb(0, 0, 0)",hsl:Qi(0,0,0,1),alpha:1}}const yi=In(ib)??xv(ib),ab=In(ob)??xv(ob);function wv({editor:t,className:e,initialMode:n="text"}){const r=E.useRef(null),[s,i]=E.useState(n),[o,l]=E.useState(null),[a,c]=E.useState(yi),[u,d]=E.useState(ab);E.useEffect(()=>{i(n)},[n]);const[h,f]=E.useState(yi.hex),[p,m]=E.useState(!1),[y,b]=E.useState(yi.rgb),[x,w]=E.useState(!1),[k,T]=E.useState(yi.hsl),[S,v]=E.useState(!1),A=s==="text"?a:u;E.useEffect(()=>{const L=()=>{if(o)return;const _=t.getAttributes("textStyle").color,V=t.getAttributes("highlight").color,ee=In(_)??yi,be=In(V)??ab;c(ee),d(be)};return L(),t.on("selectionUpdate",L),t.on("transaction",L),()=>{t.off("selectionUpdate",L),t.off("transaction",L)}},[t,o,s]),E.useEffect(()=>{o!=="hex"&&f(A.hex),o!=="rgb"&&b(A.rgb),o!=="hsl"&&T(A.hsl),o===null&&(m(!1),w(!1),v(!1))},[A,o]);const C=E.useCallback((L,_,V=!0)=>{const ee=t.chain();V&&ee.focus(),L==="text"?(c(_),ee.setColor(_.source).run()):(d(_),ee.setHighlight({color:_.source}).run())},[t,c,d]),N=E.useCallback((L,_)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{C(L,_,!1)},300)},[C]),D=E.useCallback(L=>{r.current&&clearTimeout(r.current);const _=In(L);_&&(C(s,_,!1),m(!1))},[C,s,m]),z=E.useCallback(L=>{r.current&&clearTimeout(r.current);const _=In(L);_&&(C(s,_),m(!1))},[C,s,m]);return g.jsxs("div",{className:Ie.cn("flex w-full sm:w-auto flex-col gap-3 sm:gap-4",e),children:[g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsxs("div",{className:"inline-flex items-center gap-1 rounded-md bg-muted/60 p-1",children:[g.jsx(ae.Button,{type:"button",variant:s==="text"?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs",onClick:()=>i("text"),children:"Text"}),g.jsx(ae.Button,{type:"button",variant:s==="highlight"?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs",onClick:()=>i("highlight"),children:"Highlight"})]}),g.jsx("div",{className:"flex items-center",children:g.jsx(ae.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>{s==="text"?t.chain().focus().unsetColor().run():t.chain().focus().unsetHighlight().run()},children:"Remove Color"})})]}),g.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:gap-4",children:[g.jsx("div",{className:tb.pickerRoot,children:g.jsx(cH,{color:A.hex,onChange:D,className:tb.picker})}),g.jsxs("div",{className:"flex w-full flex-col gap-2 text-[11px] sm:w-[150px]",children:[g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"font-medium text-muted-foreground",children:"HEX"}),g.jsx(Ss.Input,{value:h,onFocus:()=>l("hex"),onChange:L=>{const _=L.target.value;if(f(_),fH.test(_)){const V=In(_);V&&(N(s,V),m(!1))}else m(!0)},onBlur:()=>{l(null),p&&(f(A.hex),m(!1))},spellCheck:!1,className:Ie.cn("h-8 w-full text-xs",p&&"border-destructive focus-visible:ring-destructive")})]}),g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"font-medium text-muted-foreground",children:"RGB"}),g.jsx(Ss.Input,{value:y,onFocus:()=>l("rgb"),onChange:L=>{const _=L.target.value;if(b(_),gv.test(_)){const V=In(_);V&&(N(s,V),w(!1))}else w(!0)},onBlur:()=>{l(null),x&&(b(A.rgb),w(!1))},spellCheck:!1,className:Ie.cn("h-8 w-full text-xs",x&&"border-destructive focus-visible:ring-destructive")})]}),g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"font-medium text-muted-foreground",children:"HSL"}),g.jsx(Ss.Input,{value:k,onFocus:()=>l("hsl"),onChange:L=>{const _=L.target.value;if(T(_),yv.test(_)){const V=In(_);V&&(N(s,V),v(!1))}else v(!0)},onBlur:()=>{l(null),S&&(T(A.hsl),v(!1))},spellCheck:!1,className:Ie.cn("h-8 w-full text-xs",S&&"border-destructive focus-visible:ring-destructive")})]})]})]}),g.jsxs("div",{className:"space-y-1.5",children:[g.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Theme colors"}),g.jsx("div",{className:"space-y-1",children:dH.map(L=>g.jsxs("div",{className:"flex items-center justify-between gap-2",children:[g.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground/80",children:L.title}),g.jsx("div",{className:"flex items-center gap-1.5",children:L.colors.map(_=>g.jsx("button",{type:"button",onClick:()=>z(_.value),className:"h-6 w-6 rounded border border-border bg-background shadow-sm transition hover:border-primary/40 hover:shadow-sm",style:{background:_.value},"aria-label":`${L.title} color ${_.label}`,title:`${L.title} color ${_.label}`},_.label))})]},L.title))})]}),s==="highlight"?g.jsxs("div",{className:"space-y-2",children:[g.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Highlight presets"}),g.jsx("div",{className:"flex flex-wrap gap-1.5",children:uH.map(L=>g.jsxs("button",{type:"button",onClick:()=>z(L),className:"flex items-center gap-1 rounded-full border bg-background px-2 py-1 text-[11px] shadow-sm transition hover:border-primary/40 hover:shadow-sm",children:[g.jsx("span",{className:"h-3.5 w-3.5 rounded-full border",style:{background:L},"aria-hidden":!0}),L]},L))})]}):null]})}const pH=["px","pt","rem","em","%"];function Ql(t){if(!t)return null;const n=String(t).trim().match(/^(-?\d*\.?\d+)(px|pt|rem|em|%)$/i);if(!n)return null;const r=parseFloat(n[1]),s=n[2].toLowerCase();return Number.isFinite(r)?{value:r,unit:s}:null}function Ph(t){if(!t)return null;const{value:e,unit:n}=t;return n==="%"?`${Math.max(1,Math.round(e))}%`:n==="px"||n==="pt"?`${Math.max(1,Math.round(e))}${n}`:`${Math.max(.01,Math.round(e*100)/100)}${n}`}function mH(t){const e=Ql(t);return e?Ph(e):null}function gH(){if(typeof document>"u")return[];const t=[];try{const n=Array.from(document.styleSheets),r=[],s=[];for(const l of n){const a=l.href,c=l.ownerNode;`${a||""} ${c?.textContent||""}`.toLowerCase().includes("globals.css")?r.push(l):s.push(l)}const i=[...r,...s],o=new Set(["h1","h2","h3","h4","h5","h6"]);for(const l of i){let a=null;try{a=l.cssRules}catch{continue}if(a){for(const c of Array.from(a))if(c.style){const d=c.style.fontSize,h=c.selectorText;if(d&&h&&o.has(h)){const f=mH(d)??d.trim();if(f){const p=parseInt(h.replace("h",""),10);t.push({level:p,value:f})}}}}}}catch{}const e=new Map;for(const n of t)e.has(n.level)||e.set(n.level,n.value);return Array.from(e.entries()).map(([n,r])=>({level:n,value:r}))}function yH(t){if(typeof document>"u")return 0;try{const e=document.createElement("span");e.style.position="absolute",e.style.visibility="hidden",e.style.fontSize=t,document.body.appendChild(e);const n=parseFloat(getComputedStyle(e).fontSize);return document.body.removeChild(e),Number.isFinite(n)?n:0}catch{return 0}}function fc(){if(typeof document>"u")return 16;try{const t=parseFloat(getComputedStyle(document.documentElement).fontSize);return Number.isFinite(t)&&t>0?t:16}catch{return 16}}function kp(t){try{const e=t.state.selection.from,n=t.view.domAtPos(e),r=n&&n.node||t.view.dom,s=r.nodeType===1?r:t.view.dom,i=parseFloat(getComputedStyle(s).fontSize);return Number.isFinite(i)&&i>0?i:fc()}catch{return fc()}}function bH(t,e,n){const r=fc(),s=kp(n);switch(e){case"px":return t;case"pt":return t*(96/72);case"rem":return t*r;case"em":return t*s;case"%":return t/100*s}}function xH(t,e,n){const r=fc(),s=kp(n);switch(e){case"px":return t;case"pt":return t*(72/96);case"rem":return t/r;case"em":return t/s;case"%":return t/s*100}}function kv({editor:t,className:e}){const[n,r]=E.useState([]),[s,i]=E.useState(null),[o,l]=E.useState(""),[a,c]=E.useState("px"),[u,d]=E.useState(!1),h=E.useRef(null),f=E.useCallback(()=>{const k=t.getAttributes("textStyle").fontSize,T=Ql(k);if(T)l(String(T.value)),c(T.unit),d(!1);else{if(k&&typeof k=="string"){const S=yH(k);if(S>0&&!s){l(String(Math.round(S))),c("px"),d(!1);return}}s||(l(""),c("px"),d(!1))}},[t,s]);E.useEffect(()=>{f();const k=()=>f();return t.on("selectionUpdate",k),t.on("transaction",k),()=>{t.off("selectionUpdate",k),t.off("transaction",k)}},[t,f]),E.useEffect(()=>{r(gH())},[]);const p=E.useCallback((k,T=!0)=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{const S=t.chain();T&&S.focus(),S.setFontSize(k).run()},120)},[t]),m=E.useCallback(k=>{l(k);const T=`${k}${a}`,S=Ql(T);if(S){d(!1);const v=Ph(S);v&&p(v,!1)}else d(k.trim().length>0)},[a,p]),y=E.useCallback(k=>{const T=a;c(k);let S=0;const v=parseFloat(o);Number.isFinite(v)?S=bH(v,T,t):S=kp(t);const A=xH(S,k,t);let C;k==="px"||k==="pt"||k==="%"?C=String(Math.round(A)):C=String(Math.max(.01,Math.round(A*100)/100)),l(C);const N=Ph(Ql(`${C}${k}`));N&&p(N)},[a,o,t,p]),b=E.useCallback(()=>{h.current&&clearTimeout(h.current),t.chain().focus().unsetFontSize().run(),d(!1)},[t]),x=E.useMemo(()=>a==="px"||a==="pt"||a==="%"?1:.01,[a]),w=E.useMemo(()=>{switch(a){case"%":return"100";case"px":return"16";case"pt":return"12";case"rem":return"1";case"em":return"1";default:return""}},[a]);return g.jsxs("div",{className:Ie.cn("space-y-3",e),onMouseDown:k=>k.stopPropagation(),children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(ls,{className:"h-4 w-4 text-muted-foreground"}),g.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Font size"})]}),g.jsxs(ae.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:b,title:"Erase font size","aria-label":"Erase font size",children:[g.jsx(sB,{className:"h-3.5 w-3.5 mr-1"}),"Erase"]})]}),g.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-2 items-end",children:[g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"font-medium text-muted-foreground",children:"Value"}),g.jsx(Ss.Input,{type:"number",inputMode:"decimal",step:x,placeholder:w,value:o,onFocus:()=>i("value"),onChange:k=>m(k.target.value),onBlur:()=>i(null),className:Ie.cn("h-9",u&&"border-destructive focus-visible:ring-destructive"),spellCheck:!1})]}),g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"font-medium text-muted-foreground",children:"Unit"}),g.jsx("div",{className:"flex gap-1",children:g.jsx("select",{value:a,onChange:k=>y(k.target.value),onFocus:()=>i("unit"),onBlur:()=>i(null),className:"h-9 w-[84px] rounded-md border border-input bg-background px-2 text-sm shadow-sm outline-none focus-visible:ring-2 focus-visible:ring-ring",children:pH.map(k=>g.jsx("option",{value:k,children:k},k))})})]})]}),g.jsxs("div",{className:"space-y-2",children:[n.length>0?g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Headings"}),g.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:n.map(({level:k,value:T})=>g.jsx("button",{type:"button",onClick:()=>p(T),className:"h-8 w-full rounded-md border bg-background px-2 text-xs font-medium shadow-sm transition hover:border-primary/40 hover:shadow-sm",title:`Apply H${k} (${T})`,children:`H${k} (${T})`},`h${k}`))})]}):null,g.jsxs("div",{className:"space-y-1",children:[g.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Keywords"}),g.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:["xx-small","x-small","small","medium","large","x-large"].map(k=>g.jsx("button",{type:"button",onClick:()=>p(k),className:"h-8 w-full rounded-md border bg-background px-2 text-xs font-medium shadow-sm transition hover:border-primary/40 hover:shadow-sm",title:`Apply ${k}`,children:k.replace(/\b\w/g,T=>T.toUpperCase())},k))})]})]})]})}const wH=({editor:t})=>{const[e,n]=E.useState(t.getAttributes("link")?.href??"");E.useEffect(()=>{const s=()=>{n(t.getAttributes("link")?.href??"")};return t.on("selectionUpdate",s),t.on("transaction",s),()=>{t.off("selectionUpdate",s),t.off("transaction",s)}},[t]);const r=()=>{const s=e.trim();s?t.chain().focus().extendMarkRange("link").setLink({href:s}).run():t.chain().focus().extendMarkRange("link").unsetLink().run()};return g.jsxs("div",{className:"p-2 flex items-center gap-2",onMouseDown:s=>s.preventDefault(),children:[g.jsx("input",{type:"url",value:e,onChange:s=>n(s.target.value),placeholder:"Enter URL",className:"bg-background p-1 rounded border border-input text-sm",onKeyDown:s=>s.key==="Enter"&&r()}),g.jsx(ae.Button,{type:"button",size:"sm",onClick:r,children:"Set Link"})]})},kH=({editor:t})=>g.jsx("div",{className:"w-[380px]",children:g.jsx(wv,{editor:t,className:"p-4",initialMode:t.isActive("highlight")?"highlight":"text"})}),vp=({editor:t})=>{const[e,n]=E.useState(!1),[r,s]=E.useState(!1),[i,o]=E.useState(!1),[l,a]=E.useState(!1),{x:c,y:u,refs:d,strategy:h,update:f}=Jo({placement:"top",middleware:[Ko(6),nu(),tu()],whileElementsMounted:ti}),p=E.useCallback(()=>{if(!t||!t.isEditable)return!1;const{state:y}=t,{from:b,to:x}=y.selection,w=b!==x,k=y.selection instanceof Y,T=t.isActive("codeBlock"),S=y.selection.empty&&(t.isActive("alert-widget")||t.isActive("cta-widget")),v=t.isActive("image");return w&&!k&&!T&&!S&&!v},[t]),m=E.useCallback(()=>{if(!(!t||!p()))try{const{from:y,to:b}=t.state.selection,x=t.view.coordsAtPos(y),w=t.view.coordsAtPos(b),k={getBoundingClientRect:()=>({x:x.left,y:x.top,top:x.top,left:x.left,bottom:w.bottom,right:w.right,width:w.right-x.left,height:w.bottom-x.top})};d.setReference(k),f(),requestAnimationFrame(()=>s(!0))}catch(y){console.warn("BubbleMenu positioning error:",y)}},[t,d,f,p]);return E.useEffect(()=>{if(!t)return;let y=0;const b=()=>{cancelAnimationFrame(y),y=requestAnimationFrame(()=>{p()?(n(!0),m()):!i&&!l&&n(!1)})},x=({event:w})=>{i||l||d.floating.current&&w.relatedTarget&&d.floating.current.contains(w.relatedTarget)||n(!1)};return b(),t.on("selectionUpdate",b),t.on("transaction",b),t.on("focus",b),t.on("blur",x),()=>{cancelAnimationFrame(y),t.off("selectionUpdate",b),t.off("transaction",b),t.off("focus",b),t.off("blur",x)}},[t,p,m,i,l,d.floating]),!t||!e?null:g.jsxs("div",{ref:d.setFloating,style:{position:h,top:u??0,left:c??0,zIndex:1e4,visibility:r?"visible":"hidden"},className:"flex gap-1 items-center bg-background border rounded-lg p-1 shadow-lg",onMouseDown:y=>y.preventDefault(),children:[g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleBold().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("bold")?"bg-accent":""}`,"aria-label":"Bold",title:"Bold",children:g.jsx(cc,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleItalic().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("italic")?"bg-accent":""}`,"aria-label":"Italic",title:"Italic",children:g.jsx(mp,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleUnderline().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("underline")?"bg-accent":""}`,"aria-label":"Underline",title:"Underline",children:g.jsx(bp,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleStrike().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("strike")?"bg-accent":""}`,"aria-label":"Strikethrough",title:"Strikethrough",children:g.jsx(rv,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleCode().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("code")?"bg-accent":""}`,"aria-label":"Inline code",title:"Inline code",children:g.jsx(li,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("div",{className:"w-px bg-border h-5"}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleSubscript().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("subscript")?"bg-accent":""}`,"aria-label":"Subscript",title:"Subscript",children:g.jsx(sv,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleSuperscript().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("superscript")?"bg-accent":""}`,"aria-label":"Superscript",title:"Superscript",children:g.jsx(iv,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("div",{className:"w-px bg-border h-5"}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("left").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"left"})?"bg-accent":""}`,"aria-label":"Align left",title:"Align left",children:g.jsx(Ys,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("center").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"center"})?"bg-accent":""}`,"aria-label":"Align center",title:"Align center",children:g.jsx(Vo,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("right").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"right"})?"bg-accent":""}`,"aria-label":"Align right",title:"Align right",children:g.jsx(Wo,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("justify").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"justify"})?"bg-accent":""}`,"aria-label":"Justify",title:"Justify",children:g.jsx(yp,{className:"h-4 w-4 pointer-events-none"})}),g.jsx("div",{className:"w-px bg-border h-5"}),g.jsxs(St.Popover,{open:l,onOpenChange:a,children:[g.jsx(St.PopoverTrigger,{asChild:!0,children:g.jsx("button",{type:"button",className:"p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center","aria-label":"Font size",title:"Font size",onMouseDown:y=>y.preventDefault(),children:g.jsx(ls,{className:"h-4 w-4 pointer-events-none"})})}),g.jsx(St.PopoverContent,{onFocusOutside:y=>y.preventDefault(),onMouseDown:y=>y.stopPropagation(),className:"w-[360px] p-0",side:"top",align:"start",children:g.jsx(kv,{editor:t,className:"p-4"})})]}),g.jsxs(St.Popover,{children:[g.jsx(St.PopoverTrigger,{asChild:!0,children:g.jsx("button",{type:"button",className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("link")?"bg-accent":""}`,"aria-label":"Link",title:"Link",onMouseDown:y=>y.preventDefault(),children:g.jsx(Yc,{className:"h-4 w-4 pointer-events-none"})})}),g.jsx(St.PopoverContent,{className:"w-auto p-0",side:"top",align:"start",children:g.jsx(wH,{editor:t})})]}),g.jsxs(St.Popover,{open:i,onOpenChange:o,children:[g.jsx(St.PopoverTrigger,{asChild:!0,children:g.jsx("button",{type:"button",onMouseDown:y=>y.preventDefault(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("textStyle")||t.isActive("highlight")?"bg-accent":""}`,"aria-label":"Color / highlight",title:"Color / highlight",children:g.jsx(gp,{className:"h-4 w-4 pointer-events-none"})})}),g.jsx(St.PopoverContent,{onFocusOutside:y=>y.preventDefault(),onMouseDown:y=>y.stopPropagation(),className:"w-auto p-0",side:"top",align:"start",children:g.jsx(kH,{editor:t})})]}),g.jsx("div",{className:"w-px bg-border h-5"})]})};function cb(t,e){t.storage.mediaPicker={open:e}}function su(t){return t.storage?.mediaPicker?.open}const vH=[{title:"Heading 1",icon:g.jsx(Gs,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:1}).run()},{title:"Heading 2",icon:g.jsx(Ho,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:2}).run()},{title:"Bullet List",icon:g.jsx(ai,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBulletList().run()},{title:"Ordered List",icon:g.jsx(Fo,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleOrderedList().run()},{title:"Blockquote",icon:g.jsx(qo,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBlockquote().run()},{title:"Code Block",icon:g.jsx(li,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleCodeBlock().run()},{title:"Image",icon:g.jsx(ts,{className:"h-4 w-4"}),command:async t=>{const e=su(t);if(e){const r=await e();r?.src&&t.chain().focus().setImage({src:r.src,alt:r.alt||void 0}).updateAttributes("image",{blurDataURL:r.blurDataURL||void 0}).run();return}const n=window.prompt("URL");n&&t.chain().focus().setImage({src:n}).run()}},{title:"Table",icon:g.jsx(Uo,{className:"h-4 w-4"}),command:t=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{title:"Horizontal Rule",icon:g.jsx(Zc,{className:"h-4 w-4"}),command:t=>t.chain().focus().setHorizontalRule().run()},{title:"Link",icon:g.jsx(Yc,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter URL:");e&&t.chain().focus().setLink({href:e}).run()}},{title:"CSS Block",icon:g.jsx(Hr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter CSS (without <style> tags):","/* your styles */");if(e!=null){const n=`<style>${e}</style>`;t.commands.insertContentAt({from:0,to:0},n)}}},{title:"Script Block",icon:g.jsx(Hr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter JavaScript (without <script> tags):","// your script");if(e!=null){const n=`<script>${e}<\/script>`,r=t.state.doc.content.size;t.commands.insertContentAt(r,n)}}},{title:"DIV Block",icon:g.jsx(Hr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Optional class for DIV:",""),n=window.prompt("Optional inline style for DIV:",""),r=window.prompt("Optional content for DIV:","New block"),s=`${e?` class="${e}"`:""}${n?` style="${n}"`:""}`,o=r?`<p>${(l=>l.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"))(r)}</p>`:"<p><br /></p>";t.chain().focus().insertContent(`<div${s}>${o}</div>`).run()}},{title:"Alert Widget",icon:g.jsx(eu,{className:"h-4 w-4"}),command:t=>{t.chain().focus().setAlertWidget().run()}},{title:"CTA Widget",icon:g.jsx(Xc,{className:"h-4 w-4"}),command:t=>{t.chain().focus().setCtaWidget({text:"Learn more",url:"",style:"primary",size:"medium",textAlign:"center"}).run()}}],Sp=({editor:t})=>{const[e,n]=E.useState(!1),[r,s]=E.useState(null),[i,o]=E.useState(null),l=E.useRef(null),a=E.useRef(null),c=E.useRef(!1),u=E.useCallback(()=>{l.current&&l.current.setAttribute("aria-expanded","false"),a.current&&a.current.removeAttribute("data-menu-open"),l.current=null,a.current=null,s(null),n(!1)},[]),{x:d,y:h,refs:f,strategy:p}=Jo({placement:"right-start",open:e,middleware:[Ko(8),nu(),tu()],whileElementsMounted:ti});E.useEffect(()=>{c.current=e},[e]),E.useEffect(()=>{r?f.setReference(r):f.setReference(null)},[r,f]);const m=E.useCallback(()=>!(!t||!t.isEditable||t.isActive("image")),[t]);E.useEffect(()=>{if(!t)return;const b=t.view.dom.parentElement;if(!b)return;const x=w=>{const k=w,{handle:T,button:S}=k.detail;try{const A=t.state.selection?.$from;if(A){let C=A.depth;for(;C>0&&!A.node(C)?.isBlock;)C-=1;const N=typeof A.after=="function"?A.after(C):void 0;typeof N=="number"?o(N):typeof A.pos=="number"?o(A.pos):o(null)}else o(null)}catch{o(null)}if(l.current===S&&c.current){u();return}l.current&&l.current!==S&&l.current.setAttribute("aria-expanded","false"),a.current&&a.current!==T&&a.current.removeAttribute("data-menu-open"),l.current=S,a.current=T,S.setAttribute("aria-expanded","true"),T.setAttribute("data-menu-open","true"),s(S),n(!0)};return b.addEventListener("tiptap-gutter-toggle",x),()=>{b.removeEventListener("tiptap-gutter-toggle",x)}},[t,m,u]),E.useEffect(()=>{if(!t)return;const b=()=>{m()||u()};return t.on("selectionUpdate",b),t.on("transaction",b),t.on("blur",u),()=>{t.off("selectionUpdate",b),t.off("transaction",b),t.off("blur",u)}},[t,m,u]),E.useEffect(()=>{if(!e)return;const b=w=>{const k=w.target,T=f.floating.current;if(T&&!T.contains(k)){const S=l.current;(!S||!S.contains(k))&&u()}},x=w=>{w.key==="Escape"&&u()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",x)}},[e,u,f]);const y=b=>{i!=null?t.chain().focus().insertContentAt(i,{type:"paragraph"}).setTextSelection(i+1).run():t.chain().focus().run(),b(t),u()};return!r||!e?null:g.jsx("div",{ref:f.setFloating,style:{position:p,top:h??0,left:d??0,zIndex:10001},className:"w-48 rounded-md bg-white p-1 shadow-lg max-h-[400px] overflow-auto",onMouseDown:b=>b.preventDefault(),children:g.jsx("div",{className:"flex flex-col",children:vH.map(b=>g.jsxs(ae.Button,{type:"button",variant:"ghost",className:"justify-start",onClick:()=>y(b.command),children:[b.icon,g.jsx("span",{className:"ml-2",children:b.title})]},b.title))})})},SH=[{title:"Text",description:"Start writing with plain text",icon:g.jsx(ls,{className:"h-4 w-4"}),command:t=>t.chain().focus().clearNodes().run(),category:"basic",keywords:["text","paragraph","plain"]},{title:"Heading 1",description:"Large section heading",icon:g.jsx(Gs,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:1}).run(),category:"headings",keywords:["heading","h1","title","large"]},{title:"Heading 2",description:"Medium section heading",icon:g.jsx(Ho,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:2}).run(),category:"headings",keywords:["heading","h2","subtitle","medium"]},{title:"Heading 3",description:"Small section heading",icon:g.jsx(Gc,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:3}).run(),category:"headings",keywords:["heading","h3","small"]},{title:"Bullet List",description:"Create a simple bulleted list",icon:g.jsx(ai,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBulletList().run(),category:"lists",keywords:["bullet","list","unordered","ul"]},{title:"Numbered List",description:"Create a list with numbering",icon:g.jsx(Fo,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleOrderedList().run(),category:"lists",keywords:["numbered","list","ordered","ol"]},{title:"Task List",description:"Create a list with checkboxes",icon:g.jsx(Qc,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleTaskList().run(),category:"lists",keywords:["task","todo","checkbox","checklist"]},{title:"Image",description:"Insert an image",icon:g.jsx(ts,{className:"h-4 w-4"}),command:async t=>{const e=su(t);if(e){const r=await e();r?.src&&t.chain().focus().setImage({src:r.src,alt:r.alt||void 0}).updateAttributes("image",{blurDataURL:r.blurDataURL||void 0}).run();return}const n=window.prompt("Enter image URL:");n&&t.chain().focus().setImage({src:n}).run()},category:"media",keywords:["image","picture","photo","img"]},{title:"Video",description:"Embed a video from URL",icon:g.jsx(lv,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter video URL (YouTube, Vimeo, etc.):");e&&t.chain().focus().insertContent(`<p><a href="${e}" target="_blank">Video: ${e}</a></p>`).run()},category:"media",keywords:["video","youtube","vimeo","embed"]},{title:"Blockquote",description:"Create a quote or citation",icon:g.jsx(qo,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBlockquote().run(),category:"advanced",keywords:["quote","blockquote","citation"]},{title:"Code Block",description:"Create a code block with syntax highlighting",icon:g.jsx(li,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleCodeBlock().run(),category:"advanced",keywords:["code","programming","syntax","block"]},{title:"Table",description:"Insert a table with rows and columns",icon:g.jsx(Uo,{className:"h-4 w-4"}),command:t=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),category:"advanced",keywords:["table","grid","rows","columns"]},{title:"Horizontal Rule",description:"Insert a horizontal divider",icon:g.jsx(Zc,{className:"h-4 w-4"}),command:t=>t.chain().focus().setHorizontalRule().run(),category:"advanced",keywords:["divider","separator","line","hr"]},{title:"Alert",description:"Insert an alert or notice",icon:g.jsx(eu,{className:"h-4 w-4"}),command:t=>{t.can().setAlertWidget()?t.chain().focus().setAlertWidget().run():t.chain().focus().toggleBlockquote().run()},category:"advanced",keywords:["alert","notice","warning","info"]},{title:"Call to Action",description:"Insert a call to action button",icon:g.jsx(Xc,{className:"h-4 w-4"}),command:t=>{t.can().setCtaWidget()?t.chain().focus().setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}).run():t.chain().focus().insertContent("Call to Action").run()},category:"advanced",keywords:["cta","button","action","link"]}],ub={basic:g.jsx(ls,{className:"h-3 w-3"}),headings:g.jsx(uB,{className:"h-3 w-3"}),lists:g.jsx(ai,{className:"h-3 w-3"}),media:g.jsx(ts,{className:"h-3 w-3"}),advanced:g.jsx(ez,{className:"h-3 w-3"})},db={basic:"Basic",headings:"Headings",lists:"Lists",media:"Media",advanced:"Advanced"},vv=({editor:t,wrapperRef:e})=>{const[n,r]=E.useState(!1),[s,i]=E.useState(!1),[o,l]=E.useState(!1),[a,c]=E.useState(""),[u,d]=E.useState("all"),[h,f]=E.useState({top:-9999,left:-9999,width:0}),{x:p,y:m,refs:y,strategy:b,update:x}=Jo({placement:"bottom-start",open:n,onOpenChange:r,middleware:[Ko(10),nu({fallbackPlacements:["top-start","bottom-start","right-start"]}),tu({padding:8}),Dz({apply({availableWidth:A,availableHeight:C,elements:N}){Object.assign(N.floating.style,{maxWidth:`${Math.min(400,A-16)}px`,maxHeight:`${Math.min(500,C-16)}px`})}})],whileElementsMounted:ti}),w=E.useCallback(()=>{const{$from:A}=t.state.selection,C=A.parent;if(C.type.name==="paragraph"&&C.content.size===0||C.type.name==="heading"&&C.content.size===0)return!0;if(C.type.name==="listItem"&&C.content.size===1){const N=C.firstChild;if(N&&N.type.name==="paragraph"&&N.content.size===0)return!0}return t.isEditable},[t]),k=E.useCallback(()=>{if(!e?.current)return;const A=e.current.getBoundingClientRect(),C=t.view.dom.getBoundingClientRect(),D=t.view.coordsAtPos(t.state.selection.from).top-A.top,z=C.left-A.left,L=C.width;f({top:D,left:z,width:L}),x(),requestAnimationFrame(()=>l(!0))},[t,x,e]);E.useEffect(()=>{if(!t)return;let A=0;const C=()=>{cancelAnimationFrame(A),A=requestAnimationFrame(()=>{w()?(i(!0),l(!1),k()):(i(!1),r(!1),l(!1))})},N=()=>{i(!1),r(!1),l(!1)};return C(),t.on("selectionUpdate",C),t.on("transaction",C),t.on("focus",C),t.on("blur",N),()=>{cancelAnimationFrame(A),t.off("selectionUpdate",C),t.off("transaction",C),t.off("focus",C),t.off("blur",N)}},[t,w,k]);const T=A=>{A(t),r(!1),c(""),d("all")},S=SH.filter(A=>{const C=u==="all"||A.category===u,N=a===""||A.title.toLowerCase().includes(a.toLowerCase())||A.description.toLowerCase().includes(a.toLowerCase())||A.keywords.some(D=>D.toLowerCase().includes(a.toLowerCase()));return C&&N}),v=S.reduce((A,C)=>(A[C.category]||(A[C.category]=[]),A[C.category].push(C),A),{});return s?g.jsxs(g.Fragment,{children:[g.jsx("div",{style:{position:"absolute",top:h.top,left:h.left,width:h.width,visibility:o?"visible":"hidden",zIndex:1e4},className:"group",children:g.jsxs("div",{className:"relative py-4 w-[95%] mx-auto flex items-center","aria-label":"Insert block",children:[g.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-full h-0.5 bg-gradient-to-r from-transparent via-slate-300 to-transparent dark:via-slate-600 transform origin-center scale-x-0 opacity-0 group-hover:scale-x-100 group-hover:opacity-100 transition-all duration-300"}),g.jsxs("div",{ref:y.setReference,className:"relative z-10 cursor-pointer mx-auto",onClick:()=>r(A=>!A),children:[g.jsx("div",{className:"absolute -inset-3 rounded-full bg-primary/10 dark:bg-primary/20 scale-0 opacity-0 group-hover:scale-100 group-hover:opacity-100 transition-all duration-300 ease-out animate-pulse"}),g.jsx("div",{className:"relative bg-background border border-border p-1.5 rounded-full shadow-sm group-hover:shadow-md transition-all duration-200",children:g.jsx(K$,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors duration-200"})})]})]})}),n&&g.jsxs("div",{ref:y.setFloating,style:{position:b,top:m??0,left:p??0,zIndex:10001},className:"bg-background border border-border shadow-lg rounded-lg p-2 w-96 max-h-[500px] overflow-hidden",onMouseDown:A=>A.preventDefault(),children:[g.jsx("div",{className:"p-2 border-b border-border",children:g.jsx("input",{type:"text",placeholder:"Search blocks...",value:a,onChange:A=>c(A.target.value),className:"w-full px-3 py-2 text-sm bg-muted border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",autoFocus:!0})}),g.jsxs("div",{className:"flex gap-1 p-2 border-b border-border overflow-x-auto",children:[g.jsx(ae.Button,{variant:u==="all"?"default":"ghost",size:"sm",onClick:()=>d("all"),className:"text-xs whitespace-nowrap",children:"All"}),Object.entries(db).map(([A,C])=>g.jsxs(ae.Button,{variant:u===A?"default":"ghost",size:"sm",onClick:()=>d(A),className:"text-xs whitespace-nowrap flex items-center gap-1",children:[ub[A],C]},A))]}),g.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[u==="all"?Object.entries(v).map(([A,C])=>g.jsxs("div",{className:"py-2",children:[g.jsxs("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-2",children:[ub[A],db[A]]}),C.map(N=>g.jsx(ae.Button,{variant:"ghost",className:"w-full justify-start p-3 h-auto text-left",onClick:()=>T(N.command),children:g.jsxs("div",{className:"flex items-center gap-3 w-full",children:[g.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-md border bg-muted",children:N.icon}),g.jsxs("div",{className:"flex-1 min-w-0",children:[g.jsx("p",{className:"font-medium text-sm",children:N.title}),g.jsx("p",{className:"text-xs text-muted-foreground truncate",children:N.description})]})]})},N.title))]},A)):S.map(A=>g.jsx(ae.Button,{variant:"ghost",className:"w-full justify-start p-3 h-auto text-left",onClick:()=>T(A.command),children:g.jsxs("div",{className:"flex items-center gap-3 w-full",children:[g.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-md border bg-muted",children:A.icon}),g.jsxs("div",{className:"flex-1 min-w-0",children:[g.jsx("p",{className:"font-medium text-sm",children:A.title}),g.jsx("p",{className:"text-xs text-muted-foreground truncate",children:A.description})]})]})},A.title)),S.length===0&&g.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:['No blocks found for "',a,'"']})]})]})]}):null},CH=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),hb=new Set(["address","article","aside","blockquote","canvas","dd","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","li","main","nav","noscript","ol","p","pre","section","table","tfoot","ul","video","thead","tbody","tr","th","td","colgroup"]);function Sv(t){const e=t.match(/^<\/?\s*([a-zA-Z0-9:-]+)/);return e?e[1].toLowerCase():null}function EH(t){return/^<\s*[^/!][^>]*>$/.test(t)}function fb(t){return/^<\s*\//.test(t)}function AH(t){if(/\/\s*>$/.test(t))return!0;const e=Sv(t);return e?CH.has(e):!1}function MH(t){return/^<\s*!/.test(t)}function xd(t,e=2){if(!t)return"";const n=t.replace(/\r\n?/g,`
166
+ `).split(/(<[^>]+>)/g).filter(Boolean),r=" ".repeat(e);let s=0;const i=[];let o=null;for(let l=0;l<n.length;l++){const a=n[l];if(a.startsWith("<")){const c=Sv(a);c&&(c==="pre"||c==="code"||c==="script"||c==="style")&&fb(a)&&(o=null),fb(a)&&s>0&&(s-=1);const u=c&&hb.has(c)||MH(a),d=`${u?r.repeat(s):""}${a.trim()}`;if(u)i.push(d);else{const h=i.length?i[i.length-1]:"";h&&!h.endsWith(`
167
+ `)?i[i.length-1]=h+a.trim():i.push(r.repeat(s)+a.trim())}c&&EH(a)&&!AH(a)&&hb.has(c)&&(s+=1,(c==="pre"||c==="code"||c==="script"||c==="style")&&(o=c))}else if(o){const c=a.split(`
168
+ `);for(const u of c)i.push(u)}else{const c=a.replace(/\s+/g," ");if(c.length>0){const u=i.length?i[i.length-1]:"";if(u&&!u.endsWith(`
169
+ `))i[i.length-1]=u+c;else{const d=c.replace(/^ +/,"");d&&i.push(r.repeat(s)+d)}}}}return i.join(`
156
170
  `).replace(/\n{3,}/g,`
157
171
 
158
- `)}const Rh=t=>{const[e,n]=C.useState({canUndo:!1,canRedo:!1,historyDepth:0,isHistoryEmpty:!0}),r=C.useCallback(()=>{if(!t){n({canUndo:!1,canRedo:!1,historyDepth:0,isHistoryEmpty:!0});return}const a=t.can().undo(),c=t.can().redo();n({canUndo:a,canRedo:c,historyDepth:a?1:0,isHistoryEmpty:!a&&!c})},[t]);C.useEffect(()=>{if(t)return r(),t.on("transaction",r),t.on("update",r),t.on("selectionUpdate",r),t.on("focus",r),t.on("blur",r),()=>{t.off("transaction",r),t.off("update",r),t.off("selectionUpdate",r),t.off("focus",r),t.off("blur",r)}},[t,r]);const s=C.useCallback(()=>{if(!t||!e.canUndo)return!1;try{console.log("useEditorHistory - Attempting undo operation");const a=t.chain().focus().undo().run();return console.log("useEditorHistory - Undo result:",a),a}catch(a){return console.error("useEditorHistory - Undo operation failed:",a),!1}},[t,e.canUndo]),i=C.useCallback(()=>{if(!t||!e.canRedo)return!1;try{console.log("useEditorHistory - Attempting redo operation");const a=t.chain().focus().redo().run();return console.log("useEditorHistory - Redo result:",a),a}catch(a){return console.error("useEditorHistory - Redo operation failed:",a),!1}},[t,e.canRedo]),o=C.useCallback(()=>{if(t)try{t.commands.clearContent(),r()}catch(a){console.warn("Clear history operation failed:",a)}},[t,r]),l=C.useCallback(()=>({...e}),[e]);return{...e,undo:s,redo:i,clearHistory:o,getHistoryState:l}},yw=(t,e)=>t?e==="undo"?t.can().undo():t.can().redo():!1,uj=(t,e)=>{if(!t||!yw(t,e))return!1;try{return e==="undo"?t.chain().focus().undo().run():t.chain().focus().redo().run()}catch(n){return console.warn(`${e} operation failed:`,n),!1}},eu=t=>{const e=typeof navigator<"u"&&navigator.platform.includes("Mac"),n=e?"Cmd":"Ctrl";return t==="undo"?`${n}+Z`:e?`${n}+Shift+Z`:`${n}+Y`},Oh=({editor:t,className:e,showLabels:n=!1,size:r="sm"})=>{const{canUndo:s,canRedo:i,undo:o,redo:l}=Rh(t);C.useEffect(()=>{if(!t)return;const d=u=>{t.isFocused&&(u.ctrlKey||u.metaKey)&&(u.key==="z"&&!u.shiftKey?(u.preventDefault(),o()):(u.key==="z"&&u.shiftKey||u.key==="y")&&(u.preventDefault(),l()))};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,o,l]);const a=r==="sm"?"sm":r==="lg"?"lg":"default",c=r==="sm"?"h-4 w-4":r==="lg"?"h-6 w-6":"h-5 w-5";return m.jsxs("div",{className:De.cn("flex items-center gap-1",e),children:[m.jsxs(le.Button,{variant:s?"outline":"ghost",size:a,onClick:o,disabled:!s,title:`Undo last action (${eu("undo")})`,"aria-label":"Undo last action",className:De.cn("transition-all duration-200 border-2",r==="sm"?"h-8 w-8 p-0":r==="lg"?"h-10 w-10 p-0":"h-9 w-9 p-0",s?"border-primary/20 hover:border-primary/40 hover:bg-primary/10 hover:text-primary hover:scale-105 active:scale-95 shadow-sm":"opacity-40 cursor-not-allowed border-transparent",s&&"bg-primary/5",n&&"w-auto px-3"),children:[m.jsx(GI,{className:De.cn(c,"transition-colors duration-200",s?s?"text-primary":"text-current":"text-muted-foreground")}),n&&m.jsx("span",{className:"ml-2",children:"Undo"})]}),m.jsxs(le.Button,{variant:i?"outline":"ghost",size:a,onClick:l,disabled:!i,title:`Redo last undone action (${eu("redo")})`,"aria-label":"Redo last undone action",className:De.cn("transition-all duration-200 border-2",r==="sm"?"h-8 w-8 p-0":r==="lg"?"h-10 w-10 p-0":"h-9 w-9 p-0",i?"border-primary/20 hover:border-primary/40 hover:bg-primary/10 hover:text-primary hover:scale-105 active:scale-95 shadow-sm":"opacity-40 cursor-not-allowed border-transparent",i&&"bg-primary/5",n&&"w-auto px-3"),children:[m.jsx(wI,{className:De.cn(c,"transition-colors duration-200",i?i?"text-primary":"text-current":"text-muted-foreground")}),n&&m.jsx("span",{className:"ml-2",children:"Redo"})]})]})},Fe=({onClick:t,isActive:e,disabled:n,children:r,title:s,ariaLabel:i,shortcut:o})=>{const l=o?`${s} (${o})`:s;return m.jsx(le.Button,{variant:e?"default":"ghost",size:"sm",onClick:t,disabled:n,title:l,"aria-label":i||s,className:`h-8 w-8 p-0 transition-all duration-200 ${n?"opacity-40 cursor-not-allowed":"hover:bg-accent hover:text-accent-foreground hover:scale-105"}`,children:r})},hj=({editor:t})=>m.jsxs(gt.Popover,{children:[m.jsx(gt.PopoverTrigger,{asChild:!0,children:m.jsxs(le.Button,{variant:"ghost",size:"sm",className:"h-8 px-2","aria-label":"Font size menu",title:"Font size menu",children:[m.jsx(Wr,{className:"h-4 w-4 mr-1"}),"Size"]})}),m.jsx(gt.PopoverContent,{onFocusOutside:e=>e.preventDefault(),className:"w-[360px] p-0",side:"bottom",align:"start",children:m.jsx(pw,{editor:t,className:"p-4"})})]}),fj=({editor:t})=>m.jsxs(gt.Popover,{children:[m.jsx(gt.PopoverTrigger,{asChild:!0,children:m.jsx(le.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0","aria-label":"Color menu",title:"Color menu",children:m.jsx(vh,{className:"h-4 w-4"})})}),m.jsx(gt.PopoverContent,{onFocusOutside:e=>e.preventDefault(),className:"w-[380px] p-0",side:"bottom",align:"start",children:m.jsx(fw,{editor:t,className:"p-4"})})]}),pj=({editor:t})=>{const e=async()=>{const s=ja(t);if(s){const o=await s();o?.src&&(t.chain().focus().setImage({src:o.src,alt:o.alt||void 0}).run(),o.blurDataURL&&t.chain().focus().updateAttributes("image",{blurDataURL:o.blurDataURL}).run());return}const i=window.prompt("Enter image URL:");i&&t.chain().focus().setImage({src:i}).run()},n=()=>{t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},r=()=>{const s=window.prompt("Enter URL:");s&&t.chain().focus().setLink({href:s}).run()};return m.jsxs(We.DropdownMenu,{children:[m.jsx(We.DropdownMenuTrigger,{asChild:!0,children:m.jsx(le.Button,{variant:"ghost",size:"sm",className:"h-8 px-2",children:"Insert"})}),m.jsxs(We.DropdownMenuContent,{children:[m.jsxs(We.DropdownMenuItem,{onClick:e,children:[m.jsx(zr,{className:"h-4 w-4 mr-2"}),"Image"]}),m.jsxs(We.DropdownMenuItem,{onClick:n,children:[m.jsx(qi,{className:"h-4 w-4 mr-2"}),"Table"]}),m.jsxs(We.DropdownMenuItem,{onClick:r,children:[m.jsx(Ta,{className:"h-4 w-4 mr-2"}),"Link"]}),m.jsxs(We.DropdownMenuItem,{onClick:()=>t.chain().focus().setHorizontalRule().run(),children:[m.jsx(_a,{className:"h-4 w-4 mr-2"}),"Horizontal Rule"]}),m.jsx(We.DropdownMenuSeparator,{}),m.jsxs(We.DropdownMenuItem,{onClick:()=>{const s=window.prompt("Enter CSS (without <style> tags):","/* your styles */");if(s!=null){const i=`<style>${s}</style>`;t.commands.insertContentAt({from:0,to:0},i)}},children:[m.jsx(Nr,{className:"h-4 w-4 mr-2"}),"CSS Block"]}),m.jsxs(We.DropdownMenuItem,{onClick:()=>{const s=window.prompt("Enter JavaScript (without <script> tags):","// your script");if(s!=null){const i=`<script>${s}<\/script>`,o=t.state.doc.content.size;t.commands.insertContentAt(o,i)}},children:[m.jsx(Nr,{className:"h-4 w-4 mr-2"}),"Script Block"]}),m.jsxs(We.DropdownMenuItem,{onClick:()=>{const s=window.prompt("Optional class for DIV:",""),i=window.prompt("Optional inline style for DIV:",""),o=window.prompt("Optional content for DIV:","New block"),l=`${s?` class="${s}"`:""}${i?` style="${i}"`:""}`,c=o?`<p>${(d=>d.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"))(o)}</p>`:"<p><br /></p>";t.chain().focus().insertContent(`<div${l}>${c}</div>`).run()},children:[m.jsx(Nr,{className:"h-4 w-4 mr-2"}),"DIV Block"]}),m.jsx(We.DropdownMenuSeparator,{}),m.jsxs(We.DropdownMenuItem,{onClick:()=>t.chain().focus().setAlertWidget().run(),children:[m.jsx(Oa,{className:"h-4 w-4 mr-2"}),"Alert Widget"]}),m.jsxs(We.DropdownMenuItem,{onClick:()=>t.chain().focus().setCtaWidget({text:"Learn more",url:"",style:"primary",size:"medium",textAlign:"center"}).run(),children:[m.jsx(Na,{className:"h-4 w-4 mr-2"}),"CTA Widget"]})]})]})},mj=({editor:t})=>{const e=()=>{const s=t.getHTML(),i=new Blob([s],{type:"text/html"}),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.download="document.html",l.click(),URL.revokeObjectURL(o)},n=()=>{const s=JSON.stringify(t.getJSON(),null,2),i=new Blob([s],{type:"application/json"}),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.download="document.json",l.click(),URL.revokeObjectURL(o)},r=()=>{const s=t.getText(),i=new Blob([s],{type:"text/plain"}),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.download="document.txt",l.click(),URL.revokeObjectURL(o)};return m.jsxs(We.DropdownMenu,{children:[m.jsx(We.DropdownMenuTrigger,{asChild:!0,children:m.jsx(le.Button,{variant:"ghost",size:"sm",className:"h-8 px-2","aria-label":"Export menu",title:"Export menu",children:m.jsx(Jx,{className:"h-4 w-4 mr-1"})})}),m.jsxs(We.DropdownMenuContent,{children:[m.jsx(We.DropdownMenuItem,{onClick:e,children:"Export as HTML"}),m.jsx(We.DropdownMenuItem,{onClick:n,children:"Export as JSON"}),m.jsx(We.DropdownMenuItem,{onClick:r,children:"Export as Text"})]})]})},Dh=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(""),[i,o]=C.useState(!1),[l,a]=C.useState(null),c=C.useRef([]);if(C.useEffect(()=>{if(!t)return;const f=g=>{try{const y=t.getHTML();s($c(y)),n(!0)}catch{}},p="editor:openSourceView";return window.addEventListener(p,f),()=>window.removeEventListener(p,f)},[t]),!t)return null;const d=()=>{const f=t.getHTML();s($c(f)),n(!0)},u=()=>{t.chain().focus().setContent(r).run(),n(!1)},h=()=>{for(const x of c.current)try{URL.revokeObjectURL(x)}catch{}c.current=[];const f=t.getHTML(),y=new DOMParser().parseFromString(`<div id="__content__">${f}</div>`,"text/html").body.querySelector("#__content__");Array.from(y.querySelectorAll("script")).forEach(x=>{if(!x.getAttribute("src")){const k=x.textContent||"",v=new Blob([k],{type:"text/javascript"}),T=URL.createObjectURL(v);x.setAttribute("src",T),x.textContent="",c.current.push(T)}});const A=`<!doctype html><html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Preview</title></head><body>${y.innerHTML}</body></html>`,S=new Blob([A],{type:"text/html"}),M=URL.createObjectURL(S);c.current.push(M),l&&URL.revokeObjectURL(l),a(M),o(!0)};return m.jsxs("div",{className:"border-b bg-background p-2 relative",children:[m.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[m.jsx("div",{className:"flex items-center gap-1 mr-2 p-1 rounded-md bg-muted/30 border border-border/50",children:m.jsx(Oh,{editor:t,size:"sm",showLabels:!1})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),isActive:t.isActive("heading",{level:1}),title:"Heading 1",children:m.jsx(vs,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),isActive:t.isActive("heading",{level:2}),title:"Heading 2",children:m.jsx(Vi,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),isActive:t.isActive("heading",{level:3}),title:"Heading 3",children:m.jsx(Aa,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleBold().run(),isActive:t.isActive("bold"),title:"Bold",children:m.jsx(Gl,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleItalic().run(),isActive:t.isActive("italic"),title:"Italic",children:m.jsx(kh,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleUnderline().run(),isActive:t.isActive("underline"),title:"Underline",children:m.jsx(Ch,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleStrike().run(),isActive:t.isActive("strike"),title:"Strikethrough",children:m.jsx(Yx,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleCode().run(),isActive:t.isActive("code"),title:"Inline Code",children:m.jsx(Rs,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleSubscript().run(),isActive:t.isActive("subscript"),title:"Subscript",children:m.jsx(Xx,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleSuperscript().run(),isActive:t.isActive("superscript"),title:"Superscript",children:m.jsx(Zx,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:()=>t.chain().focus().setTextAlign("left").run(),isActive:t.isActive({textAlign:"left"}),title:"Align Left",children:m.jsx(Ss,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().setTextAlign("center").run(),isActive:t.isActive({textAlign:"center"}),title:"Align Center",children:m.jsx(Ki,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().setTextAlign("right").run(),isActive:t.isActive({textAlign:"right"}),title:"Align Right",children:m.jsx(Gi,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().setTextAlign("justify").run(),isActive:t.isActive({textAlign:"justify"}),title:"Justify",children:m.jsx(Sh,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleBulletList().run(),isActive:t.isActive("bulletList"),title:"Bullet List",children:m.jsx(Os,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleOrderedList().run(),isActive:t.isActive("orderedList"),title:"Numbered List",children:m.jsx(Wi,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleTaskList().run(),isActive:t.isActive("taskList"),title:"Task List",children:m.jsx(Ra,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleBlockquote().run(),isActive:t.isActive("blockquote"),title:"Blockquote",children:m.jsx(Ji,{className:"h-4 w-4"})}),m.jsx(Fe,{onClick:()=>t.chain().focus().toggleCodeBlock().run(),isActive:t.isActive("codeBlock"),title:"Code Block",children:m.jsx(Nr,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(hj,{editor:t}),m.jsx(fj,{editor:t}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(pj,{editor:t}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:d,title:"View Source (HTML)",children:m.jsx(JL,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Fe,{onClick:h,title:"Preview (executes scripts)",children:m.jsx(KL,{className:"h-4 w-4"})}),m.jsx(Ft.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(mj,{editor:t})]}),e&&m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:m.jsxs("div",{className:"bg-background border rounded-md shadow-xl w-[90vw] max-w-4xl h-[70vh] flex flex-col",children:[m.jsx("div",{className:"p-3 border-b font-semibold",children:"Edit HTML Source"}),m.jsx("textarea",{className:"flex-1 p-3 font-mono text-sm outline-none resize-none bg-muted/30",value:r,onChange:f=>s(f.target.value),spellCheck:!1}),m.jsxs("div",{className:"p-3 border-t flex justify-end gap-2",children:[m.jsx(le.Button,{variant:"outline",size:"sm",onClick:()=>n(!1),children:"Cancel"}),m.jsx(le.Button,{variant:"secondary",size:"sm",onClick:()=>s($c(r)),children:"Format"}),m.jsx(le.Button,{size:"sm",onClick:u,children:"Apply"})]})]})}),i&&m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:m.jsxs("div",{className:"bg-background border rounded-md shadow-xl w-[95vw] max-w-5xl h-[80vh] flex flex-col",children:[m.jsxs("div",{className:"p-3 border-b flex items-center justify-between",children:[m.jsx("div",{className:"font-semibold",children:"Preview"}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx(le.Button,{variant:"outline",size:"sm",onClick:()=>{h()},children:"Refresh"}),m.jsx(le.Button,{size:"sm",onClick:()=>{for(const f of c.current)try{URL.revokeObjectURL(f)}catch{}c.current=[],l&&URL.revokeObjectURL(l),a(null),o(!1)},children:"Close"})]})]}),m.jsx("div",{className:"flex-1",children:m.jsx("iframe",{title:"Editor Preview",className:"w-full h-full",sandbox:"allow-scripts allow-same-origin allow-modals",src:l??void 0})})]})})]})},bw=({editor:t,className:e})=>{const[n,r]=C.useState(!1),[s,i]=C.useState("format"),[o,l]=C.useState(!1),a=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||window.innerWidth<=768;C.useEffect(()=>{const h=()=>{r(a())};return h(),window.addEventListener("resize",h),()=>window.removeEventListener("resize",h)},[]),C.useEffect(()=>{if(!t)return;const h=()=>{const{selection:f}=t.state;!f.empty&&a()?r(!0):o||r(!1)};return t.on("selectionUpdate",h),t.on("focus",h),t.on("blur",()=>{o||r(!1)}),()=>{t.off("selectionUpdate",h),t.off("focus",h),t.off("blur",()=>r(!1))}},[t,o]);const c=[{icon:m.jsx(Gl,{className:"h-4 w-4"}),label:"Bold",action:()=>t.chain().focus().toggleBold().run(),isActive:()=>t.isActive("bold"),section:"format"},{icon:m.jsx(kh,{className:"h-4 w-4"}),label:"Italic",action:()=>t.chain().focus().toggleItalic().run(),isActive:()=>t.isActive("italic"),section:"format"},{icon:m.jsx(Ch,{className:"h-4 w-4"}),label:"Underline",action:()=>t.chain().focus().toggleUnderline().run(),isActive:()=>t.isActive("underline"),section:"format"},{icon:m.jsx(Rs,{className:"h-4 w-4"}),label:"Code",action:()=>t.chain().focus().toggleCode().run(),isActive:()=>t.isActive("code"),section:"format"},{icon:m.jsx(vh,{className:"h-4 w-4"}),label:"Highlight",action:()=>t.chain().focus().toggleHighlight().run(),isActive:()=>t.isActive("highlight"),section:"format"},{icon:m.jsx(Wr,{className:"h-4 w-4"}),label:"Paragraph",action:()=>t.chain().focus().setParagraph().run(),isActive:()=>t.isActive("paragraph"),section:"blocks"},{icon:m.jsx(vs,{className:"h-4 w-4"}),label:"Heading 1",action:()=>t.chain().focus().toggleHeading({level:1}).run(),isActive:()=>t.isActive("heading",{level:1}),section:"blocks"},{icon:m.jsx(Vi,{className:"h-4 w-4"}),label:"Heading 2",action:()=>t.chain().focus().toggleHeading({level:2}).run(),isActive:()=>t.isActive("heading",{level:2}),section:"blocks"},{icon:m.jsx(Aa,{className:"h-4 w-4"}),label:"Heading 3",action:()=>t.chain().focus().toggleHeading({level:3}).run(),isActive:()=>t.isActive("heading",{level:3}),section:"blocks"},{icon:m.jsx(Os,{className:"h-4 w-4"}),label:"Bullet List",action:()=>t.chain().focus().toggleBulletList().run(),isActive:()=>t.isActive("bulletList"),section:"blocks"},{icon:m.jsx(Wi,{className:"h-4 w-4"}),label:"Numbered List",action:()=>t.chain().focus().toggleOrderedList().run(),isActive:()=>t.isActive("orderedList"),section:"blocks"},{icon:m.jsx(Ra,{className:"h-4 w-4"}),label:"Task List",action:()=>t.chain().focus().toggleTaskList().run(),isActive:()=>t.isActive("taskList"),section:"blocks"},{icon:m.jsx(Ji,{className:"h-4 w-4"}),label:"Quote",action:()=>t.chain().focus().toggleBlockquote().run(),isActive:()=>t.isActive("blockquote"),section:"blocks"},{icon:m.jsx(Ta,{className:"h-4 w-4"}),label:"Link",action:()=>{const h=window.prompt("Enter URL:");h&&t.chain().focus().setLink({href:h}).run()},isActive:()=>t.isActive("link"),section:"insert"},{icon:m.jsx(zr,{className:"h-4 w-4"}),label:"Image",action:async()=>{const h=ja(t);if(h){const p=await h();p?.src&&t.chain().focus().setImage({src:p.src,alt:p.alt||void 0}).run();return}const f=window.prompt("Enter image URL:");f&&t.chain().focus().setImage({src:f}).run()},section:"insert"},{icon:m.jsx(qi,{className:"h-4 w-4"}),label:"Table",action:()=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),section:"insert"},{icon:m.jsx(Ss,{className:"h-4 w-4"}),label:"Align Left",action:()=>t.chain().focus().setTextAlign("left").run(),isActive:()=>t.isActive({textAlign:"left"}),section:"align"},{icon:m.jsx(Ki,{className:"h-4 w-4"}),label:"Align Center",action:()=>t.chain().focus().setTextAlign("center").run(),isActive:()=>t.isActive({textAlign:"center"}),section:"align"},{icon:m.jsx(Gi,{className:"h-4 w-4"}),label:"Align Right",action:()=>t.chain().focus().setTextAlign("right").run(),isActive:()=>t.isActive({textAlign:"right"}),section:"align"}],d=[{key:"format",label:"Format",icon:m.jsx(Gl,{className:"h-3 w-3"})},{key:"blocks",label:"Blocks",icon:m.jsx(vs,{className:"h-3 w-3"})},{key:"insert",label:"Insert",icon:m.jsx(zr,{className:"h-3 w-3"})},{key:"align",label:"Align",icon:m.jsx(Ss,{className:"h-3 w-3"})}],u=c.filter(h=>h.section===s);return!n&&!o?null:m.jsxs("div",{className:De.cn("fixed bottom-0 left-0 right-0 z-50 bg-background border-t border-border shadow-lg","transform transition-transform duration-300 ease-in-out",n||o?"translate-y-0":"translate-y-full",e),children:[m.jsx("div",{className:"flex justify-center py-2 border-b border-border",children:m.jsxs(le.Button,{variant:"ghost",size:"sm",onClick:()=>l(!o),className:"flex items-center gap-2",children:[o?m.jsx(tw,{className:"h-4 w-4"}):m.jsx(pI,{className:"h-4 w-4"}),m.jsx("span",{className:"text-xs",children:o?"Close":"Tools"})]})}),(o||n)&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"flex border-b border-border bg-muted/50",children:d.map(h=>m.jsx(le.Button,{variant:s===h.key?"default":"ghost",size:"sm",onClick:()=>i(h.key),className:"flex-1 rounded-none text-xs py-2 h-auto",children:m.jsxs("div",{className:"flex flex-col items-center gap-1",children:[h.icon,m.jsx("span",{children:h.label})]})},h.key))}),m.jsx("div",{className:"p-2",children:m.jsx("div",{className:"flex flex-wrap gap-1 justify-center",children:u.map((h,f)=>m.jsxs(le.Button,{variant:h.isActive?.()?"default":"ghost",size:"sm",onClick:h.action,className:"flex flex-col items-center gap-1 h-auto py-2 px-3 min-w-[60px]",title:h.label,children:[h.icon,m.jsx("span",{className:"text-xs",children:h.label})]},f))})})]}),m.jsx("div",{className:"h-safe-area-inset-bottom"})]})},Pa=({content:t,onChange:e,placeholder:n,editable:r=!0,showToolbar:s=!0,showCharacterCount:i=!0,className:o,onFocus:l,onBlur:a,useEnhancedFloatingMenu:c=!0,showMobileToolbar:d=!0,enableAdvancedPlaceholders:u=!0,enableFocusMode:h=!1,showKeyboardShortcuts:f=!1})=>{const p=C.useRef(null),[g,y]=C.useState({isOpen:!1,searchTerm:"",replaceTerm:"",currentMatch:0,totalMatches:0,caseSensitive:!1,wholeWord:!1}),b=hb({extensions:Mh,content:t,editable:r,immediatelyRender:!1,onUpdate:({editor:k})=>{e(k.getHTML())},onFocus:()=>{l?.()},onBlur:()=>{a?.()},editorProps:{attributes:{class:De.cn("prose dark:prose-invert prose-sm sm:prose-base lg:prose-lg xl:prose-2xl","mx-auto focus:outline-none p-4 min-h-[500px] w-full","prose-headings:scroll-mt-[80px] prose-headings:font-semibold","prose-h1:text-4xl prose-h2:text-3xl prose-h3:text-2xl","prose-p:leading-7 prose-li:leading-7","prose-pre:bg-muted prose-pre:border prose-pre:rounded-lg","prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:rounded","prose-blockquote:border-l-4 prose-blockquote:border-primary prose-blockquote:pl-4","prose-table:border-collapse prose-table:border prose-table:border-border","prose-th:border prose-th:border-border prose-th:bg-muted prose-th:p-2","prose-td:border prose-td:border-border prose-td:p-2","prose-img:rounded-lg prose-img:shadow-sm",o)},handleKeyDown:(k,v)=>{if(v.ctrlKey||v.metaKey)switch(v.key){case"f":return v.preventDefault(),y(T=>({...T,isOpen:!T.isOpen})),!0;case"s":return v.preventDefault(),!0;default:return!1}return!1}}});C.useEffect(()=>{if(!b)return;const k=b.getHTML();if(t!==k){const{from:v,to:T}=b.state.selection;b.commands.setContent(t,{emitUpdate:!1}),b.commands.setTextSelection({from:v,to:T})}},[t,b]);const w=k=>{if(!b||!k){y($=>({...$,totalMatches:0,currentMatch:0}));return}const v=b.getText(),T=g.caseSensitive?"g":"gi",N=g.wholeWord?`\\b${k}\\b`:k,H=new RegExp(N,T),V=v.match(H);y($=>({...$,totalMatches:V?V.length:0,currentMatch:V?1:0}))},A=()=>{if(!b||!g.searchTerm)return;const k=b.getHTML(),v=g.caseSensitive?"g":"gi",T=g.wholeWord?`\\b${g.searchTerm}\\b`:g.searchTerm,N=new RegExp(T,v),H=k.replace(N,g.replaceTerm);b.commands.setContent(H),y(V=>({...V,totalMatches:0,currentMatch:0}))};if(!b)return null;const S=b.storage?.characterCount,M=S?.characters?.()??0,x=S?.words?.()??0;return m.jsxs("div",{ref:p,className:De.cn("relative w-full rounded-lg border shadow-sm","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2","bg-background",o),children:[s&&m.jsx(Dh,{editor:b}),g.isOpen&&m.jsxs("div",{className:"border-b bg-muted/50 p-3",children:[m.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[m.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[m.jsx(_I,{className:"h-4 w-4 text-muted-foreground"}),m.jsx(ns.Input,{placeholder:"Search...",value:g.searchTerm,onChange:k=>{const v=k.target.value;y(T=>({...T,searchTerm:v})),w(v)},className:"h-8"}),m.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:g.totalMatches>0?`${g.currentMatch}/${g.totalMatches}`:"No matches"})]}),m.jsx(le.Button,{variant:"ghost",size:"sm",onClick:()=>y(k=>({...k,isOpen:!1})),children:m.jsx(tw,{className:"h-4 w-4"})})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(vI,{className:"h-4 w-4 text-muted-foreground"}),m.jsx(ns.Input,{placeholder:"Replace with...",value:g.replaceTerm,onChange:k=>y(v=>({...v,replaceTerm:k.target.value})),className:"h-8 flex-1"}),m.jsx(le.Button,{variant:"outline",size:"sm",onClick:A,disabled:!g.searchTerm||g.totalMatches===0,children:"Replace All"})]})]}),m.jsx(Nh,{editor:b}),c?m.jsx(mw,{editor:b,wrapperRef:p}):m.jsx(_h,{editor:b}),m.jsx(db,{editor:b}),i&&S&&m.jsxs("div",{className:"absolute bottom-2 right-2 z-10 text-xs text-muted-foreground bg-background/80 backdrop-blur-sm rounded px-2 py-1 border",children:[M," characters / ",x," words"]}),f&&m.jsxs("div",{className:"absolute bottom-2 left-2 text-xs text-muted-foreground bg-background/80 backdrop-blur-sm rounded px-2 py-1 border opacity-0 hover:opacity-100 transition-opacity",children:[m.jsx("div",{children:"Ctrl+F: Search"}),m.jsx("div",{children:"Ctrl+S: Save"}),m.jsx("div",{children:"/: Commands"}),m.jsx("div",{children:"Ctrl+K: Insert Link"}),m.jsx("div",{children:"Ctrl+Shift+H: Highlight"}),m.jsx("div",{children:"Ctrl+Alt+1-6: Headings"})]}),d&&m.jsx(bw,{editor:b})]})},gj=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(!1),{x:i,y:o,refs:l,strategy:a,update:c}=Xi({placement:"top",strategy:"fixed",open:e,onOpenChange:n,middleware:[Yi(-12)],whileElementsMounted:Ms}),d=C.useCallback(()=>t.isActive("image"),[t]),u=t.getAttributes("image")||{},h=C.useCallback(()=>{const{state:y,view:b}=t,w=()=>{try{if(y.selection instanceof q){const k=b.nodeDOM(y.selection.from);if(k){const v=k.closest?.(".tiptap-image-wrapper")??k;return v.querySelector("img")??v}}const M=b.dom.querySelector(".tiptap-image-wrapper.ProseMirror-selectednode");if(M)return M.querySelector("img")??M;const x=b.dom.querySelector(".ProseMirror-selectednode");if(x){const k=x.closest?.(".tiptap-image-wrapper")??x;return k.querySelector("img")??k}}catch{}return null},A=h._lastEl,S=w()??A;if(S){h._lastEl=S;const M={getBoundingClientRect:()=>{const x=w()??h._lastEl;return x?x.getBoundingClientRect():new DOMRect(0,0,0,0)}};l.setReference(M)}else{const M=b.coordsAtPos(y.selection.from),x={getBoundingClientRect:()=>new DOMRect(M.left,M.top,0,0)};l.setReference(x)}requestAnimationFrame(()=>{c(),requestAnimationFrame(()=>s(!0))})},[t,l,c]);if(C.useEffect(()=>{const y=()=>{const b=d();n(b),s(!1),b&&h()};return y(),t.on("selectionUpdate",y),t.on("transaction",y),t.on("focus",y),t.on("blur",()=>n(!1)),()=>{t.off("selectionUpdate",y),t.off("transaction",y),t.off("focus",y)}},[t,d,h]),!e)return null;const f=y=>{t.chain().focus().updateAttributes("image",{align:y}).run(),requestAnimationFrame(()=>h())},p=()=>{t.chain().focus().deleteSelection().run()},g=()=>{const y=u?.src;if(y)try{const b=document.createElement("a");b.href=y;const w=(y.split("?")[0]||"").split("/").pop()||"image";b.download=w,document.body.appendChild(b),b.click(),b.remove()}catch{}};return m.jsxs("div",{ref:l.setFloating,style:{position:a,top:o??0,left:i??0,zIndex:10002,visibility:r?"visible":"hidden",pointerEvents:"auto"},className:"bg-background/95 backdrop-blur border rounded-full shadow-lg px-3 py-2 flex items-center gap-1",onMouseDown:y=>y.preventDefault(),children:[m.jsx(le.Button,{size:"icon",variant:u.align==="left"?"default":"ghost",title:"Align left",onClick:()=>f("left"),children:m.jsx(Ss,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:u.align==="center"?"default":"ghost",title:"Align center",onClick:()=>f("center"),children:m.jsx(Ki,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:u.align==="right"?"default":"ghost",title:"Align right",onClick:()=>f("right"),children:m.jsx(Gi,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:"ghost",title:"Download",onClick:g,children:m.jsx(Jx,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:"ghost",title:"Delete",onClick:p,children:m.jsx(Qx,{className:"h-4 w-4"})})]})},ng=t=>t.isActive("table")||t.isActive("tableCell")||t.isActive("tableHeader")||t.isActive("tableRow"),yj=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(!1),{refs:i,x:o,y:l,strategy:a,update:c}=Xi({placement:"bottom",strategy:"fixed",middleware:[Yi(12),La(),Da()],whileElementsMounted:Ms,open:e,onOpenChange:n}),d=C.useCallback(()=>{const{state:v,view:T}=t;try{const{from:N}=v.selection,{node:H}=T.domAtPos(N);let V=null;return H.nodeType===Node.ELEMENT_NODE?V=H:(H.nodeType===Node.TEXT_NODE||H?.parentElement)&&(V=H.parentElement),V?.closest?.("td, th")??null}catch{return null}},[t]),u=C.useCallback(()=>d()?.closest("table")??null,[d]),h=C.useCallback(()=>{if(!ng(t)){n(!1);return}const v=u();if(!v){n(!1);return}i.setReference(v),n(!0),s(!1),requestAnimationFrame(()=>{c(),requestAnimationFrame(()=>s(!0))})},[t,i,u,c]);if(C.useEffect(()=>{const v=()=>{ng(t)?h():n(!1)},T=()=>n(!1);return v(),t.on("selectionUpdate",v),t.on("transaction",v),t.on("focus",v),t.on("blur",T),()=>{t.off("selectionUpdate",v),t.off("transaction",v),t.off("focus",v),t.off("blur",T)}},[t,h]),!e)return null;const f=t.can(),p=typeof f.addRowAfter=="function"?f.addRowAfter():!1,g=typeof f.deleteRow=="function"?f.deleteRow():!1,y=typeof f.addColumnAfter=="function"?f.addColumnAfter():!1,b=typeof f.deleteColumn=="function"?f.deleteColumn():!1,w=typeof f.deleteTable=="function"?f.deleteTable():!1,A=()=>{t.chain().focus().addRowAfter().run(),h()},S=()=>{t.chain().focus().deleteRow().run(),h()},M=()=>{t.chain().focus().addColumnAfter().run(),h()},x=()=>{t.chain().focus().deleteColumn().run(),h()},k=()=>{t.chain().focus().deleteTable().run(),n(!1)};return m.jsxs("div",{ref:i.setFloating,style:{position:a,top:l??0,left:o??0,zIndex:10002,visibility:r?"visible":"hidden"},className:"flex items-center gap-1 rounded-full border bg-background/95 px-2 py-1 shadow-lg",onMouseDown:v=>v.preventDefault(),children:[m.jsx(le.Button,{size:"icon",variant:"ghost",onClick:A,disabled:!p,title:"Add row below","aria-label":"Add row below",children:m.jsx(TI,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:"ghost",onClick:S,disabled:!g,title:"Delete current row","aria-label":"Delete current row",children:m.jsx(MI,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:"ghost",onClick:M,disabled:!y,title:"Add column to the right","aria-label":"Add column to the right",children:m.jsx(FL,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:"ghost",onClick:x,disabled:!b,title:"Delete current column","aria-label":"Delete current column",children:m.jsx(HL,{className:"h-4 w-4"})}),m.jsx(le.Button,{size:"icon",variant:"ghost",onClick:k,disabled:!w,title:"Delete table","aria-label":"Delete table",children:m.jsx(Qx,{className:"h-4 w-4"})})]})},xw=({content:t,onChange:e,placeholder:n,editable:r=!0,showToolbar:s=!0,showCharacterCount:i=!0,className:o,onFocus:l,onBlur:a,openImagePicker:c})=>{const d=C.useRef(null),u=hb({extensions:Mh,content:t,editable:r,immediatelyRender:!1,editorProps:{attributes:{class:De.cn("prose dark:prose-invert prose-sm sm:prose-base lg:prose-lg xl:prose-2xl","mx-auto focus:outline-none min-h-[500px] w-full","pl-14 pr-4 py-4","prose-headings:scroll-mt-[80px] prose-headings:font-semibold","prose-h1:text-4xl prose-h2:text-3xl prose-h3:text-2xl","prose-p:leading-7 prose-li:leading-7","prose-pre:bg-muted prose-pre:border prose-pre:rounded-lg","prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:rounded","prose-blockquote:border-l-4 prose-blockquote:border-primary prose-blockquote:pl-4","prose-table:border-collapse prose-table:border prose-table:border-border","prose-th:border prose-th:border-border prose-th:bg-muted prose-th:p-2","prose-td:border prose-td:border-border prose-td:p-2","prose-img:rounded-lg prose-img:shadow-sm")}}},[]);C.useEffect(()=>{if(!u)return;const y=()=>{e(u.getHTML())},b=()=>{l?.()},w=()=>{a?.()};return u.on("update",y),u.on("focus",b),u.on("blur",w),()=>{u.off("update",y),u.off("focus",b),u.off("blur",w)}},[u,e,l,a]),C.useEffect(()=>{if(u)return Xm(u,c),()=>Xm(u,void 0)},[u,c]),C.useEffect(()=>{u&&u.isEditable!==r&&u.setEditable(r)},[u,r]);const h=C.useRef(t);if(C.useEffect(()=>{if(!u)return;const y=()=>{h.current=u.getHTML()};return u.on("update",y),()=>{u.off("update",y)}},[u]),C.useEffect(()=>{if(!u||t===h.current)return;const y=u.getHTML();if(u.isEmpty&&(t===""||t==="<p></p>")){h.current=t;return}if(t!==y){const{from:b,to:w}=u.state.selection;u.commands.setContent(t,{emitUpdate:!1}),u.commands.setTextSelection({from:b,to:w}),h.current=t}},[t,u]),C.useEffect(()=>{if(!(!u||typeof window>"u"))return window.__nextblockEditor=u,()=>{window.__nextblockEditor===u&&delete window.__nextblockEditor}},[u]),C.useEffect(()=>{if(!u||typeof window>"u")return;const y=()=>{const A=window.__dragHandleElement;if(!A)return;const S=A.parentElement,M=u.view.dom.parentElement??u.view.dom;S&&M&&!S.isConnected&&M.appendChild(S)},b=()=>y();y(),u.on("selectionUpdate",b),u.on("transaction",b),u.on("focus",b);const w=window.setInterval(y,2e3);return()=>{u.off("selectionUpdate",b),u.off("transaction",b),u.off("focus",b),window.clearInterval(w)}},[u]),C.useEffect(()=>()=>{typeof document<"u"&&document.body.classList.remove("dragging")},[]),!u)return null;const f=u.storage?.characterCount,p=f?.characters?.()??0,g=f?.words?.()??0;return m.jsxs("div",{ref:d,className:De.cn("relative w-full rounded-lg border bg-background shadow-sm","flex flex-col h-full min-h-0","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",o),children:[s&&m.jsx(Dh,{editor:u}),m.jsx(Nh,{editor:u}),m.jsx(_h,{editor:u}),m.jsx(gj,{editor:u}),m.jsx(yj,{editor:u}),m.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:m.jsx(db,{editor:u})}),i&&f&&m.jsxs("div",{className:"absolute bottom-2 right-2 text-xs z-10 text-muted-foreground bg-background/80 backdrop-blur-sm rounded px-2 py-1 border",children:[p," characters / ",g," words"]})]})},ww=C.forwardRef(({className:t,...e},n)=>m.jsx("div",{ref:n,className:De.cn("flex items-center gap-1 rounded-md bg-background p-1",t),...e}));ww.displayName="Toolbar";const kw=C.forwardRef(({className:t,...e},n)=>m.jsx("div",{ref:n,className:De.cn("flex items-center gap-1",t),...e}));kw.displayName="ToolbarGroup";const vw=C.forwardRef(({className:t,isActive:e,...n},r)=>m.jsx("button",{ref:r,className:De.cn("inline-flex items-center justify-center rounded-md p-1.5 text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{"bg-accent text-accent-foreground":e},t),...n}));vw.displayName="ToolbarButton";const Sw=C.forwardRef(({className:t,...e},n)=>m.jsx("div",{ref:n,className:De.cn("mx-1 h-7 w-px bg-muted",t),...e}));Sw.displayName="ToolbarSeparator";var bj=t=>{const{className:e="drag-handle",children:n,editor:r,pluginKey:s=Ox,onNodeChange:i,onElementDragStart:o,onElementDragEnd:l,computePositionConfig:a=Wd}=t,[c,d]=C.useState(null),u=C.useRef(null);return C.useEffect(()=>{let h=null;return c?r.isDestroyed?()=>{u.current=null}:(u.current||(h=Dx({editor:r,element:c,pluginKey:s,computePositionConfig:{...Wd,...a},onElementDragStart:o,onElementDragEnd:l,onNodeChange:i}),u.current=h.plugin,r.registerPlugin(u.current)),()=>{r.unregisterPlugin(s),u.current=null,h&&(h.unbind(),h=null)}):()=>{u.current=null}},[c,r,i,s,a,o,l]),m.jsx("div",{className:e,style:{visibility:"hidden",position:"absolute"},ref:d,children:n})},xj=bj;const wj=({editor:t,className:e,onDragStart:n,onDragEnd:r,onNodeChange:s})=>{const i=C.useRef(null),o=C.useMemo(()=>a=>{a.preventDefault(),a.stopPropagation();const c=i.current;if(!c)return;const d=new CustomEvent("tiptap-gutter-toggle",{bubbles:!0,detail:{handle:c,button:a.currentTarget}});c.dispatchEvent(d)},[]),l=a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),o(a))};return t?m.jsx(xj,{editor:t,className:De.cn("tiptap-drag-handle",e),onElementDragStart:n,onElementDragEnd:r,onNodeChange:a=>s?.(a),children:m.jsxs("div",{ref:i,className:"tiptap-drag-handle__group",role:"group","data-orientation":"horizontal",children:[m.jsx("button",{type:"button","aria-label":"Insert block",title:"Insert block",className:"tiptap-drag-handle__button tiptap-drag-handle__button--ghost tiptap-drag-handle__plus",onClick:o,onKeyDown:l,children:m.jsx(kj,{})}),m.jsx("button",{type:"button",className:"tiptap-drag-handle__button tiptap-drag-handle__button--ghost tiptap-drag-handle__grip",role:"button","aria-label":"Drag to reorder",title:"Drag to reorder",tabIndex:0,children:m.jsx(vj,{})})]})}):null},kj=({className:t,...e})=>m.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:De.cn("tiptap-drag-handle__icon tiptap-drag-handle__icon--filled",t),...e,children:m.jsx("path",{d:"M13 5C13 4.44772 12.5523 4 12 4C11.4477 4 11 4.44772 11 5V11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H11V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V13H19C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11H13V5Z"})}),vj=({className:t,...e})=>m.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:De.cn("tiptap-drag-handle__icon tiptap-drag-handle__icon--filled",t),...e,children:[m.jsx("path",{d:"M9 3C7.89543 3 7 3.89543 7 5C7 6.10457 7.89543 7 9 7C10.1046 7 11 6.10457 11 5C11 3.89543 10.1046 3 9 3Z"}),m.jsx("path",{d:"M9 10C7.89543 10 7 10.8954 7 12C7 13.1046 7.89543 14 9 14C10.1046 14 11 13.1046 11 12C11 10.8954 10.1046 10 9 10Z"}),m.jsx("path",{d:"M7 19C7 17.8954 7.89543 17 9 17C10.1046 17 11 17.8954 11 19C11 20.1046 10.1046 21 9 21C7.89543 21 7 20.1046 7 19Z"}),m.jsx("path",{d:"M15 10C13.8954 10 13 10.8954 13 12C13 13.1046 13.8954 14 15 14C16.1046 14 17 13.1046 17 12C17 10.8954 16.1046 10 15 10Z"}),m.jsx("path",{d:"M13 5C13 3.89543 13.8954 3 15 3C16.1046 3 17 3.89543 17 5C17 6.10457 16.1046 7 15 7C13.8954 7 13 6.10457 13 5Z"}),m.jsx("path",{d:"M15 17C13.8954 17 13 17.8954 13 19C13 20.1046 13.8954 21 15 21C16.1046 21 17 20.1046 17 19C17 17.8954 16.1046 17 15 17Z"})]}),Sj=({html:t,className:e})=>{const n=C.useRef(null);return C.useEffect(()=>{const r=n.current;if(!r)return;r.innerHTML=t;const s=[];return Array.from(r.querySelectorAll("script")).forEach(o=>{const l=document.createElement("script");for(const a of Array.from(o.attributes))l.setAttribute(a.name,a.value);if(o.src)l.src=o.src;else{const a=o.textContent||"",c=new Blob([a],{type:l.type||"text/javascript"}),d=URL.createObjectURL(c);l.src=d,l.async=!1,s.push(d)}o.parentNode?.insertBefore(l,o),o.remove()}),()=>{s.forEach(o=>{try{URL.revokeObjectURL(o)}catch(l){process.env.NODE_ENV!=="production"&&console.warn("Failed to revoke object URL",o,l)}})}},[t]),m.jsx("div",{ref:n,className:e})},Cj=de.create({name:"enhancedFocus",addOptions(){return{className:"has-focus",mode:"all",showFocusRing:!0,highlightSelection:!0,dimUnfocused:!1,animateTransitions:!0}},addProseMirrorPlugins(){return[new me({key:new ye("enhancedFocus"),props:{decorations:({doc:t,selection:e})=>{const{from:n,to:r}=e,s=[];if(t.nodesBetween(n,r,(i,o)=>{const l=_e.node(o,o+i.nodeSize,{class:this.options.className});s.push(l)}),this.options.highlightSelection&&n!==r){const i=_e.inline(n,r,{class:"selection-highlight"});s.push(i)}if(this.options.showFocusRing){const i=_e.widget(n,()=>{const o=document.createElement("div");return o.className="focus-ring",o});s.push(i)}return be.create(t,s)}},view:()=>({update:(t,e)=>{const{state:n}=t,{selection:r}=n,s=e.selection;r.eq(s)||this.editor.emit("selectionUpdate",{editor:this.editor,transaction:n.tr})}})})]},addGlobalAttributes(){return[{types:["paragraph","heading","blockquote","codeBlock","listItem"],attributes:{"data-focused":{default:null,renderHTML:t=>t["data-focused"]?{"data-focused":t["data-focused"]}:{}}}}]},onCreate(){const t=this.editor.view.dom;this.options.animateTransitions&&t.classList.add("focus-transitions"),this.options.dimUnfocused&&t.classList.add("dim-unfocused")},onSelectionUpdate(){const{state:t}=this.editor,{selection:e}=t,{from:n,to:r}=e,s=t.tr;let i=!1;t.doc.descendants((o,l)=>{if(o.isText||o.isLeaf)return;const a=l,c=l+o.nodeSize,d=n>=a&&r<=c,u=o.attrs["data-focused"];d&&!u?(s.setNodeMarkup(l,void 0,{...o.attrs,"data-focused":"true"}),i=!0):!d&&u&&(s.setNodeMarkup(l,void 0,{...o.attrs,"data-focused":null}),i=!0)}),i&&this.editor.view.dispatch(s)},addStorage(){return{isFocused:!1}},onFocus(){this.editor.view.dom.classList.add("editor-focused"),this.storage.isFocused=!0},onBlur(){this.editor.view.dom.classList.remove("editor-focused"),this.storage.isFocused=!1}}),Ej=de.create({name:"keyboardShortcuts",addOptions(){return{enableAdvancedShortcuts:!0,enableCustomShortcuts:!0,showShortcutHints:!1}},addKeyboardShortcuts(){const t={};return this.options.enableAdvancedShortcuts&&(t["Mod-Shift-x"]=()=>this.editor.commands.toggleStrike(),t["Mod-Shift-h"]=()=>this.editor.commands.toggleHighlight(),t["Mod-Shift-c"]=()=>this.editor.commands.toggleCode(),t["Mod-Alt-1"]=()=>this.editor.commands.toggleHeading({level:1}),t["Mod-Alt-2"]=()=>this.editor.commands.toggleHeading({level:2}),t["Mod-Alt-3"]=()=>this.editor.commands.toggleHeading({level:3}),t["Mod-Alt-4"]=()=>this.editor.commands.toggleHeading({level:4}),t["Mod-Alt-5"]=()=>this.editor.commands.toggleHeading({level:5}),t["Mod-Alt-6"]=()=>this.editor.commands.toggleHeading({level:6}),t["Mod-Alt-0"]=()=>this.editor.commands.setParagraph(),t["Mod-Shift-8"]=()=>this.editor.commands.toggleBulletList(),t["Mod-Shift-7"]=()=>this.editor.commands.toggleOrderedList(),t["Mod-Shift-9"]=()=>this.editor.commands.toggleTaskList(),t["Mod-Shift-b"]=()=>this.editor.commands.toggleBlockquote(),t["Mod-Alt-c"]=()=>this.editor.commands.toggleCodeBlock(),t["Mod-Shift-minus"]=()=>this.editor.commands.setHorizontalRule(),t["Mod-Shift-l"]=()=>this.editor.commands.setTextAlign("left"),t["Mod-Shift-e"]=()=>this.editor.commands.setTextAlign("center"),t["Mod-Shift-r"]=()=>this.editor.commands.setTextAlign("right"),t["Mod-Shift-j"]=()=>this.editor.commands.setTextAlign("justify"),t["Mod-comma"]=()=>this.editor.commands.toggleSubscript(),t["Mod-period"]=()=>this.editor.commands.toggleSuperscript(),t["Mod-Alt-t"]=()=>this.editor.can().insertTable()?this.editor.commands.insertTable({rows:3,cols:3,withHeaderRow:!0}):!1,t["Mod-Home"]=()=>this.editor.commands.focus("start"),t["Mod-End"]=()=>this.editor.commands.focus("end"),t["Mod-a"]=()=>this.editor.commands.selectAll(),t["Mod-\\"]=()=>this.editor.commands.unsetAllMarks()&&this.editor.commands.clearNodes(),t["Mod-k"]=()=>{const e=window.prompt("Enter URL:");return e?this.editor.commands.setLink({href:e}):!1},t["Mod-Shift-i"]=()=>{const e=window.prompt("Enter image URL:");return e?this.editor.commands.setImage({src:e}):!1},t["Alt-ArrowUp"]=()=>{const{selection:e}=this.editor.state,{$from:n}=e,r=n.nodeBefore;if(r){const s=n.pos-r.nodeSize;return this.editor.commands.setTextSelection(s)}return!1},t["Alt-ArrowDown"]=()=>{const{selection:e}=this.editor.state,{$to:n}=e,r=n.nodeAfter;if(r){const s=n.pos+r.nodeSize;return this.editor.commands.setTextSelection(s)}return!1},t["Mod-Shift-d"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);return s?this.editor.commands.insertContentAt(r,`
159
- ${s}`):!1},t["Mod-Shift-k"]=()=>{const{selection:e}=this.editor.state,{$from:n,$to:r}=e,s=n.start(),i=r.end();return this.editor.commands.deleteRange({from:s,to:i})},t["Mod-Backspace"]=()=>{const{selection:e}=this.editor.state,{from:n}=e,r=this.editor.state.doc.resolve(n);let s=n;const i=r.parent.textContent,o=r.parentOffset;for(let l=o-1;l>=0;l--){if(/\s/.test(i[l])){s=n-(o-l-1);break}l===0&&(s=n-o)}return this.editor.commands.deleteRange({from:s,to:n})},t["Mod-Delete"]=()=>{const{selection:e}=this.editor.state,{to:n}=e,r=this.editor.state.doc.resolve(n);let s=n;const i=r.parent.textContent,o=r.parentOffset;for(let l=o;l<i.length;l++){if(/\s/.test(i[l])){s=n+(l-o);break}l===i.length-1&&(s=n+(i.length-o))}return this.editor.commands.deleteRange({from:n,to:s})}),this.options.enableCustomShortcuts&&(t["Mod-Shift-a"]=()=>this.editor.can().setAlertWidget()?this.editor.commands.setAlertWidget():!1,t["Mod-Shift-t"]=()=>this.editor.can().setCtaWidget()?this.editor.commands.setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}):!1,t["Mod-Shift-f"]=()=>(this.editor.view.dom.classList.toggle("focus-mode"),!0),t["Mod-Shift-w"]=()=>(this.editor.view.dom.classList.toggle("writing-mode"),!0),t["Mod-Shift-u"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);return s?this.editor.commands.insertContentAt({from:n,to:r},s.toUpperCase()):!1},t["Mod-Shift-l"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);return s?this.editor.commands.insertContentAt({from:n,to:r},s.toLowerCase()):!1},t["Mod-Shift-p"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);if(s){const i=s.replace(/\w\S*/g,o=>o.charAt(0).toUpperCase()+o.substr(1).toLowerCase());return this.editor.commands.insertContentAt({from:n,to:r},i)}return!1}),t},addStorage(){return{shortcuts:{},hints:[]}},onCreate(){this.options.showShortcutHints&&(this.storage.shortcuts={},this.storage.hints=[{category:"Text Formatting",shortcuts:[{keys:"Cmd/Ctrl + B",action:"Bold"},{keys:"Cmd/Ctrl + I",action:"Italic"},{keys:"Cmd/Ctrl + U",action:"Underline"},{keys:"Cmd/Ctrl + Shift + X",action:"Strikethrough"},{keys:"Cmd/Ctrl + Shift + H",action:"Highlight"},{keys:"Cmd/Ctrl + E",action:"Inline Code"}]},{category:"Headings",shortcuts:[{keys:"Cmd/Ctrl + Alt + 1-6",action:"Heading 1-6"},{keys:"Cmd/Ctrl + Alt + 0",action:"Paragraph"}]},{category:"Lists",shortcuts:[{keys:"Cmd/Ctrl + Shift + 8",action:"Bullet List"},{keys:"Cmd/Ctrl + Shift + 7",action:"Numbered List"},{keys:"Cmd/Ctrl + Shift + 9",action:"Task List"}]},{category:"Blocks",shortcuts:[{keys:"Cmd/Ctrl + Shift + B",action:"Blockquote"},{keys:"Cmd/Ctrl + Alt + C",action:"Code Block"},{keys:"Cmd/Ctrl + Alt + T",action:"Table"}]},{category:"Navigation",shortcuts:[{keys:"Cmd/Ctrl + A",action:"Select All"},{keys:"Cmd/Ctrl + Home",action:"Go to Start"},{keys:"Cmd/Ctrl + End",action:"Go to End"}]},{category:"Advanced",shortcuts:[{keys:"Cmd/Ctrl + K",action:"Insert Link"},{keys:"Cmd/Ctrl + Shift + I",action:"Insert Image"},{keys:"Cmd/Ctrl + \\",action:"Clear Formatting"}]}])}}),Mj=()=>{const[t,e]=C.useState("<p>Start testing...</p>"),[n,r]=C.useState([]),[s,i]=C.useState(!1),[o,l]=C.useState(""),a=x=>({name:x,tests:[],status:"pending"}),c=(x,k)=>{r(v=>v.map(T=>{if(T.name===x){const N=[...T.tests,k],H=N.some(I=>I.status==="fail"),V=N.some(I=>I.status==="warning"),$=N.every(I=>I.status!=="pending");return{...T,tests:N,status:H?"fail":V?"warning":$?"pass":"pending"}}return T}))},d=x=>new Promise(k=>setTimeout(k,x)),u=async()=>{const x="Drag and Drop";l(x);try{const k=document.querySelectorAll(".drag-handle, .drag-handle-button");c(x,{name:"Drag Handle Presence",status:k.length>0?"pass":"fail",message:k.length>0?"Drag handles found":"No drag handles detected",details:`Found ${k.length} drag handle elements`});const v=document.querySelector("style")?.textContent?.includes("drag-handle")||Array.from(document.styleSheets).some(N=>{try{return Array.from(N.cssRules).some(H=>H.cssText.includes("drag-handle"))}catch{return!1}});c(x,{name:"Drag Handle CSS",status:v?"pass":"warning",message:v?"Drag handle CSS loaded":"Drag handle CSS may not be loaded",details:"Check if drag-handle.css is properly imported"});const T=document.querySelectorAll('[data-draggable="true"]');c(x,{name:"Draggable Nodes",status:T.length>0?"pass":"warning",message:T.length>0?"Draggable nodes found":"No draggable nodes detected",details:`Found ${T.length} draggable nodes`})}catch(k){c(x,{name:"Drag and Drop Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},h=async()=>{const x="Undo/Redo System";l(x);try{const k=document.querySelectorAll('[aria-label*="Undo"], [title*="Undo"]'),v=document.querySelectorAll('[aria-label*="Redo"], [title*="Redo"]');c(x,{name:"Undo/Redo Buttons",status:k.length>0&&v.length>0?"pass":"fail",message:`Found ${k.length} undo and ${v.length} redo buttons`,details:"Undo/Redo buttons should be present in toolbar"}),e("<p>Test content for undo</p>"),await d(100),c(x,{name:"History State Change",status:"pass",message:"Content change detected",details:"History system should track this change"});const T=typeof document<"u"&&document.addEventListener!==void 0;c(x,{name:"Keyboard Shortcuts",status:T?"pass":"warning",message:"Keyboard event system available",details:"Ctrl+Z and Ctrl+Y shortcuts should work"})}catch(k){c(x,{name:"Undo/Redo Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},f=async()=>{const x="Enhanced Floating Menu";l(x);try{const k=document.querySelectorAll('[aria-label*="Insert"], .enhanced-floating-menu');c(x,{name:"Floating Menu Trigger",status:k.length>0?"pass":"warning",message:k.length>0?"Floating menu trigger found":"No floating menu trigger detected",details:"Should appear on empty paragraphs"});const v=document.querySelectorAll('input[placeholder*="Search"], .search-input');c(x,{name:"Search Functionality",status:v.length>0?"pass":"warning",message:v.length>0?"Search input found":"Search input not visible",details:"Search should be available when menu is open"});const T=document.querySelectorAll("[data-category], .category-button");c(x,{name:"Category Filters",status:T.length>0?"pass":"warning",message:T.length>0?"Category filters found":"Category filters not visible",details:"Should have Basic, Headings, Lists, Media, Advanced categories"})}catch(k){c(x,{name:"Enhanced Floating Menu Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},p=async()=>{const x="Advanced Placeholders";l(x);try{const k=Array.from(document.styleSheets).some(N=>{try{return Array.from(N.cssRules).some(H=>H.cssText.includes("is-empty")||H.cssText.includes("placeholder"))}catch{return!1}});c(x,{name:"Placeholder CSS",status:k?"pass":"warning",message:k?"Placeholder CSS loaded":"Placeholder CSS may not be loaded",details:"Check if advanced-features.css is properly imported"});const v=document.querySelectorAll(".is-empty, .is-editor-empty");c(x,{name:"Empty Node Detection",status:v.length>=0?"pass":"warning",message:`Found ${v.length} empty nodes`,details:"Empty nodes should have placeholder classes"}),e("<p></p>"),await d(100);const T=document.querySelectorAll("[data-placeholder]");c(x,{name:"Placeholder Content",status:T.length>0?"pass":"warning",message:T.length>0?"Placeholder content found":"No placeholder content detected",details:"Should show contextual placeholders for different node types"})}catch(k){c(x,{name:"Advanced Placeholders Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},g=async()=>{const x="Focus Management";l(x);try{const k=document.querySelectorAll(".has-focus, .editor-focused");c(x,{name:"Focus Classes",status:k.length>=0?"pass":"warning",message:`Found ${k.length} focus elements`,details:"Focus classes should be applied to active elements"});const v=document.querySelectorAll(".focus-ring");c(x,{name:"Focus Ring",status:v.length>=0?"pass":"warning",message:`Found ${v.length} focus rings`,details:"Focus rings provide visual feedback"}),c(x,{name:"Selection Highlighting",status:"pass",message:"Selection highlighting system available",details:"Enhanced selection visibility should work"})}catch(k){c(x,{name:"Focus Management Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},y=async()=>{const x="Mobile Experience";l(x);try{const k=document.querySelectorAll('.mobile-toolbar, [class*="mobile"]');c(x,{name:"Mobile Toolbar",status:k.length>0?"pass":"warning",message:k.length>0?"Mobile toolbar found":"Mobile toolbar not detected",details:"Should appear on mobile devices or small screens"});const v=Array.from(document.styleSheets).some(N=>{try{return Array.from(N.cssRules).some(H=>H.cssText.includes("@media")&&H.cssText.includes("768px"))}catch{return!1}});c(x,{name:"Responsive CSS",status:v?"pass":"warning",message:v?"Responsive CSS found":"Responsive CSS may not be loaded",details:"Should have mobile breakpoints"});const T=document.querySelectorAll('[class*="touch"], .toolbar-item');c(x,{name:"Touch-Friendly Elements",status:T.length>0?"pass":"warning",message:T.length>0?"Touch-friendly elements found":"No touch-friendly elements detected",details:"Should have larger touch targets for mobile"})}catch(k){c(x,{name:"Mobile Experience Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},b=async()=>{const x="Keyboard Shortcuts";l(x);try{c(x,{name:"Keyboard Shortcuts Available",status:"pass",message:`${["Ctrl+B","Ctrl+I","Ctrl+U","Ctrl+Shift+X","Ctrl+Shift+H","Ctrl+Alt+1","Ctrl+Alt+2","Ctrl+Alt+3","Ctrl+K","Ctrl+\\"].length} keyboard shortcuts configured`,details:"Text formatting, headings, lists, and advanced shortcuts"});const v=document.querySelectorAll('[title*="Ctrl"], [title*="Cmd"]');c(x,{name:"Shortcut Hints",status:v.length>0?"pass":"warning",message:v.length>0?"Shortcut hints found":"No shortcut hints detected",details:"Tooltips should show keyboard shortcuts"}),c(x,{name:"Conflict Prevention",status:"pass",message:"Keyboard shortcuts use standard patterns",details:"Should not conflict with browser shortcuts"})}catch(k){c(x,{name:"Keyboard Shortcuts Test",status:"fail",message:"Test failed with error",details:k instanceof Error?k.message:"Unknown error"})}},w=async()=>{i(!0),r([a("Drag and Drop"),a("Undo/Redo System"),a("Enhanced Floating Menu"),a("Advanced Placeholders"),a("Focus Management"),a("Mobile Experience"),a("Keyboard Shortcuts")]);try{await u(),await d(500),await h(),await d(500),await f(),await d(500),await p(),await d(500),await g(),await d(500),await y(),await d(500),await b()}catch(x){console.error("Test suite failed:",x)}finally{i(!1),l("")}},A=()=>{r([]),e("<p>Start testing...</p>"),l("")},S=x=>{switch(x){case"pass":return m.jsx(OL,{className:"h-4 w-4 text-green-500"});case"fail":return m.jsx(jL,{className:"h-4 w-4 text-red-500"});case"warning":return m.jsx(Pm,{className:"h-4 w-4 text-yellow-500"});default:return m.jsx(Pm,{className:"h-4 w-4 text-gray-400"})}},M=x=>{const k={pass:"bg-green-100 text-green-800",fail:"bg-red-100 text-red-800",warning:"bg-yellow-100 text-yellow-800",pending:"bg-gray-100 text-gray-800"};return m.jsx(a1.Badge,{className:k[x]||k.pending,children:x.toUpperCase()})};return m.jsxs("div",{className:"max-w-6xl mx-auto p-6 space-y-6",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("h1",{className:"text-3xl font-bold",children:"Tiptap v3 Feature Validation"}),m.jsxs("div",{className:"flex gap-2",children:[m.jsxs(le.Button,{onClick:A,variant:"outline",disabled:s,children:[m.jsx(CI,{className:"h-4 w-4 mr-2"}),"Reset"]}),m.jsxs(le.Button,{onClick:w,disabled:s,children:[m.jsx(bI,{className:"h-4 w-4 mr-2"}),s?"Running Tests...":"Run All Tests"]})]})]}),s&&o&&m.jsx(at.Card,{children:m.jsx(at.CardContent,{className:"pt-6",children:m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-primary"}),m.jsxs("span",{children:["Running: ",o]})]})})}),m.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[m.jsxs("div",{className:"space-y-4",children:[m.jsx("h2",{className:"text-xl font-semibold",children:"Test Results"}),n.map(x=>m.jsxs(at.Card,{children:[m.jsx(at.CardHeader,{className:"pb-3",children:m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx(at.CardTitle,{className:"text-lg",children:x.name}),M(x.status)]})}),m.jsxs(at.CardContent,{className:"space-y-2",children:[x.tests.map((k,v)=>m.jsxs("div",{className:"flex items-start gap-2 p-2 rounded border",children:[S(k.status),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:"font-medium text-sm",children:k.name}),m.jsx("div",{className:"text-xs text-muted-foreground",children:k.message}),k.details&&m.jsx("div",{className:"text-xs text-muted-foreground mt-1 opacity-75",children:k.details})]})]},v)),x.tests.length===0&&x.status==="pending"&&m.jsx("div",{className:"text-sm text-muted-foreground",children:"No tests run yet"})]})]},x.name))]}),m.jsxs("div",{className:"space-y-4",children:[m.jsx("h2",{className:"text-xl font-semibold",children:"Live Editor Test"}),m.jsx(at.Card,{children:m.jsx(at.CardContent,{className:"pt-6",children:m.jsx(Pa,{content:t,onChange:e,useEnhancedFloatingMenu:!0,showMobileToolbar:!0,enableAdvancedPlaceholders:!0,enableFocusMode:!1,showKeyboardShortcuts:!0,className:"min-h-[400px]"})})}),m.jsxs(at.Card,{children:[m.jsx(at.CardHeader,{children:m.jsx(at.CardTitle,{className:"text-lg",children:"Test Instructions"})}),m.jsxs(at.CardContent,{className:"text-sm space-y-2",children:[m.jsx("p",{children:"• Try typing in the editor to test placeholders"}),m.jsx("p",{children:"• Create empty paragraphs to test floating menu"}),m.jsx("p",{children:"• Use keyboard shortcuts (Ctrl+B, Ctrl+I, etc.)"}),m.jsx("p",{children:"• Test undo/redo with Ctrl+Z/Ctrl+Y"}),m.jsx("p",{children:"• Hover over elements to see drag handles"}),m.jsx("p",{children:"• Resize window to test mobile toolbar"})]})]})]})]})]})},Aj=()=>{const[t,e]=C.useState(`
172
+ `)}const Cp=t=>{const[e,n]=E.useState({canUndo:!1,canRedo:!1,historyDepth:0,isHistoryEmpty:!0}),r=E.useCallback(()=>{if(!t){n({canUndo:!1,canRedo:!1,historyDepth:0,isHistoryEmpty:!0});return}const a=t.can().undo(),c=t.can().redo();n({canUndo:a,canRedo:c,historyDepth:a?1:0,isHistoryEmpty:!a&&!c})},[t]);E.useEffect(()=>{if(t)return r(),t.on("transaction",r),t.on("update",r),t.on("selectionUpdate",r),t.on("focus",r),t.on("blur",r),()=>{t.off("transaction",r),t.off("update",r),t.off("selectionUpdate",r),t.off("focus",r),t.off("blur",r)}},[t,r]);const s=E.useCallback(()=>{if(!t||!e.canUndo)return!1;try{return t.chain().focus().undo().run()}catch(a){return console.error("useEditorHistory - Undo operation failed:",a),!1}},[t,e.canUndo]),i=E.useCallback(()=>{if(!t||!e.canRedo)return!1;try{return t.chain().focus().redo().run()}catch(a){return console.error("useEditorHistory - Redo operation failed:",a),!1}},[t,e.canRedo]),o=E.useCallback(()=>{if(t)try{t.commands.clearContent(),r()}catch(a){console.warn("Clear history operation failed:",a)}},[t,r]),l=E.useCallback(()=>({...e}),[e]);return{...e,undo:s,redo:i,clearHistory:o,getHistoryState:l}},Cv=(t,e)=>t?e==="undo"?t.can().undo():t.can().redo():!1,TH=(t,e)=>{if(!t||!Cv(t,e))return!1;try{return e==="undo"?t.chain().focus().undo().run():t.chain().focus().redo().run()}catch(n){return console.warn(`${e} operation failed:`,n),!1}},jh=t=>{const e=typeof navigator<"u"&&navigator.platform.includes("Mac"),n=e?"Cmd":"Ctrl";return t==="undo"?`${n}+Z`:e?`${n}+Shift+Z`:`${n}+Y`},Ep=({editor:t,className:e,showLabels:n=!1,size:r="sm"})=>{const{canUndo:s,canRedo:i,undo:o,redo:l}=Cp(t);E.useEffect(()=>{if(!t)return;const u=d=>{t.isFocused&&(d.ctrlKey||d.metaKey)&&(d.key==="z"&&!d.shiftKey?(d.preventDefault(),o()):(d.key==="z"&&d.shiftKey||d.key==="y")&&(d.preventDefault(),l()))};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[t,o,l]);const a=r==="sm"?"sm":r==="lg"?"lg":"default",c=r==="sm"?"h-4 w-4":r==="lg"?"h-6 w-6":"h-5 w-5";return g.jsxs("div",{className:Ie.cn("flex items-center gap-1",e),children:[g.jsxs(ae.Button,{type:"button",variant:s?"outline":"ghost",size:a,onClick:o,disabled:!s,title:`Undo last action (${jh("undo")})`,"aria-label":"Undo last action",className:Ie.cn("transition-all duration-200 border-2",r==="sm"?"h-8 w-8 p-0":r==="lg"?"h-10 w-10 p-0":"h-9 w-9 p-0",s?"border-primary/20 hover:border-primary/40 hover:bg-primary/10 hover:text-primary hover:scale-105 active:scale-95 shadow-sm":"opacity-40 cursor-not-allowed border-transparent",s&&"bg-primary/5",n&&"w-auto px-3"),children:[g.jsx(dz,{className:Ie.cn(c,"transition-colors duration-200",s?s?"text-primary":"text-current":"text-muted-foreground")}),n&&g.jsx("span",{className:"ml-2",children:"Undo"})]}),g.jsxs(ae.Button,{type:"button",variant:i?"outline":"ghost",size:a,onClick:l,disabled:!i,title:`Redo last undone action (${jh("redo")})`,"aria-label":"Redo last undone action",className:Ie.cn("transition-all duration-200 border-2",r==="sm"?"h-8 w-8 p-0":r==="lg"?"h-10 w-10 p-0":"h-9 w-9 p-0",i?"border-primary/20 hover:border-primary/40 hover:bg-primary/10 hover:text-primary hover:scale-105 active:scale-95 shadow-sm":"opacity-40 cursor-not-allowed border-transparent",i&&"bg-primary/5",n&&"w-auto px-3"),children:[g.jsx(IB,{className:Ie.cn(c,"transition-colors duration-200",i?i?"text-primary":"text-current":"text-muted-foreground")}),n&&g.jsx("span",{className:"ml-2",children:"Redo"})]})]})},Fe=({onClick:t,isActive:e,disabled:n,children:r,title:s,ariaLabel:i,shortcut:o})=>{const l=o?`${s} (${o})`:s;return g.jsx(ae.Button,{type:"button",variant:e?"default":"ghost",size:"sm",onClick:t,disabled:n,title:l,"aria-label":i||s,className:`h-8 w-8 p-0 transition-all duration-200 ${n?"opacity-40 cursor-not-allowed":"hover:bg-accent hover:text-accent-foreground hover:scale-105"}`,children:r})},NH=({editor:t})=>g.jsxs(St.Popover,{children:[g.jsx(St.PopoverTrigger,{asChild:!0,children:g.jsxs(ae.Button,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2","aria-label":"Font size menu",title:"Font size menu",children:[g.jsx(ls,{className:"h-4 w-4 mr-1"}),"Size"]})}),g.jsx(St.PopoverContent,{onFocusOutside:e=>e.preventDefault(),className:"w-[360px] p-0",side:"bottom",align:"start",children:g.jsx(kv,{editor:t,className:"p-4"})})]}),RH=({editor:t})=>g.jsxs(St.Popover,{children:[g.jsx(St.PopoverTrigger,{asChild:!0,children:g.jsx(ae.Button,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0","aria-label":"Color menu",title:"Color menu",children:g.jsx(gp,{className:"h-4 w-4"})})}),g.jsx(St.PopoverContent,{onFocusOutside:e=>e.preventDefault(),className:"w-[380px] p-0",side:"bottom",align:"start",children:g.jsx(wv,{editor:t,className:"p-4"})})]}),_H=({editor:t})=>{const e=async()=>{const s=su(t);if(s){const o=await s();o?.src&&(t.chain().focus().setImage({src:o.src,alt:o.alt||void 0}).run(),o.blurDataURL&&t.chain().focus().updateAttributes("image",{blurDataURL:o.blurDataURL}).run());return}const i=window.prompt("Enter image URL:");i&&t.chain().focus().setImage({src:i}).run()},n=()=>{t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},r=()=>{const s=window.prompt("Enter URL:");s&&t.chain().focus().setLink({href:s}).run()};return g.jsxs(We.DropdownMenu,{children:[g.jsx(We.DropdownMenuTrigger,{asChild:!0,children:g.jsx(ae.Button,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2",children:"Insert"})}),g.jsxs(We.DropdownMenuContent,{children:[g.jsxs(We.DropdownMenuItem,{onClick:e,children:[g.jsx(ts,{className:"h-4 w-4 mr-2"}),"Image"]}),g.jsxs(We.DropdownMenuItem,{onClick:n,children:[g.jsx(Uo,{className:"h-4 w-4 mr-2"}),"Table"]}),g.jsxs(We.DropdownMenuItem,{onClick:r,children:[g.jsx(Yc,{className:"h-4 w-4 mr-2"}),"Link"]}),g.jsxs(We.DropdownMenuItem,{onClick:()=>t.chain().focus().setHorizontalRule().run(),children:[g.jsx(Zc,{className:"h-4 w-4 mr-2"}),"Horizontal Rule"]}),g.jsx(We.DropdownMenuSeparator,{}),g.jsxs(We.DropdownMenuItem,{onClick:()=>{const s=window.prompt("Enter CSS (without <style> tags):","/* your styles */");if(s!=null){const i=`<style>${s}</style>`;t.commands.insertContentAt({from:0,to:0},i)}},children:[g.jsx(Hr,{className:"h-4 w-4 mr-2"}),"CSS Block"]}),g.jsxs(We.DropdownMenuItem,{onClick:()=>{const s=window.prompt("Enter JavaScript (without <script> tags):","// your script");if(s!=null){const i=`<script>${s}<\/script>`,o=t.state.doc.content.size;t.commands.insertContentAt(o,i)}},children:[g.jsx(Hr,{className:"h-4 w-4 mr-2"}),"Script Block"]}),g.jsxs(We.DropdownMenuItem,{onClick:()=>{const s=window.prompt("Optional class for DIV:",""),i=window.prompt("Optional inline style for DIV:",""),o=window.prompt("Optional content for DIV:","New block"),l=`${s?` class="${s}"`:""}${i?` style="${i}"`:""}`,c=o?`<p>${(u=>u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"))(o)}</p>`:"<p><br /></p>";t.chain().focus().insertContent(`<div${l}>${c}</div>`).run()},children:[g.jsx(Hr,{className:"h-4 w-4 mr-2"}),"DIV Block"]}),g.jsx(We.DropdownMenuSeparator,{}),g.jsxs(We.DropdownMenuItem,{onClick:()=>t.chain().focus().setAlertWidget().run(),children:[g.jsx(eu,{className:"h-4 w-4 mr-2"}),"Alert Widget"]}),g.jsxs(We.DropdownMenuItem,{onClick:()=>t.chain().focus().setCtaWidget({text:"Learn more",url:"",style:"primary",size:"medium",textAlign:"center"}).run(),children:[g.jsx(Xc,{className:"h-4 w-4 mr-2"}),"CTA Widget"]})]})]})},OH=({editor:t})=>{const e=()=>{const s=t.getHTML(),i=new Blob([s],{type:"text/html"}),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.download="document.html",l.click(),URL.revokeObjectURL(o)},n=()=>{const s=JSON.stringify(t.getJSON(),null,2),i=new Blob([s],{type:"application/json"}),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.download="document.json",l.click(),URL.revokeObjectURL(o)},r=()=>{const s=t.getText(),i=new Blob([s],{type:"text/plain"}),o=URL.createObjectURL(i),l=document.createElement("a");l.href=o,l.download="document.txt",l.click(),URL.revokeObjectURL(o)};return g.jsxs(We.DropdownMenu,{children:[g.jsx(We.DropdownMenuTrigger,{asChild:!0,children:g.jsx(ae.Button,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2","aria-label":"Export menu",title:"Export menu",children:g.jsx(nv,{className:"h-4 w-4 mr-1"})})}),g.jsxs(We.DropdownMenuContent,{children:[g.jsx(We.DropdownMenuItem,{onClick:e,children:"Export as HTML"}),g.jsx(We.DropdownMenuItem,{onClick:n,children:"Export as JSON"}),g.jsx(We.DropdownMenuItem,{onClick:r,children:"Export as Text"})]})]})},Ap=({editor:t})=>{const[e,n]=E.useState(!1),[r,s]=E.useState(""),[i,o]=E.useState(!1),[l,a]=E.useState(null),c=E.useRef([]);if(E.useEffect(()=>{if(!t)return;const f=m=>{try{const y=t.getHTML();s(xd(y)),n(!0)}catch{}},p="editor:openSourceView";return window.addEventListener(p,f),()=>window.removeEventListener(p,f)},[t]),!t)return null;const u=()=>{const f=t.getHTML();s(xd(f)),n(!0)},d=()=>{t.chain().focus().setContent(r).run(),n(!1)},h=()=>{for(const S of c.current)try{URL.revokeObjectURL(S)}catch{}c.current=[];const f=t.getHTML(),y=new DOMParser().parseFromString(`<div id="__content__">${f}</div>`,"text/html").body.querySelector("#__content__");Array.from(y.querySelectorAll("script")).forEach(S=>{if(!S.getAttribute("src")){const v=S.textContent||"",A=new Blob([v],{type:"text/javascript"}),C=URL.createObjectURL(A);S.setAttribute("src",C),S.textContent="",c.current.push(C)}});const w=`<!doctype html><html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Preview</title></head><body>${y.innerHTML}</body></html>`,k=new Blob([w],{type:"text/html"}),T=URL.createObjectURL(k);c.current.push(T),l&&URL.revokeObjectURL(l),a(T),o(!0)};return g.jsxs("div",{className:"border-b bg-background p-2 relative",children:[g.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[g.jsx("div",{className:"flex items-center gap-1 mr-2 p-1 rounded-md bg-muted/30 border border-border/50",children:g.jsx(Ep,{editor:t,size:"sm",showLabels:!1})}),g.jsx(tn.Separator,{orientation:"vertical",className:"h-6 mx-1"}),g.jsx(Fe,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),isActive:t.isActive("heading",{level:1}),title:"Heading 1",children:g.jsx(Gs,{className:"h-4 w-4"})}),g.jsx(Fe,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),isActive:t.isActive("heading",{level:2}),title:"Heading 2",children:g.jsx(Ho,{className:"h-4 w-4"})}),g.jsx(Fe,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),isActive:t.isActive("heading",{level:3}),title:"Heading 3",children:g.jsx(Gc,{className:"h-4 w-4"})}),g.jsx(tn.Separator,{orientation:"vertical",className:"h-6 mx-1"}),g.jsx(Fe,{onClick:()=>t.chain().focus().toggleBold().run(),isActive:t.isActive("bold"),title:"Bold",children:g.jsx(cc,{className:"h-4 w-4"})}),g.jsx(Fe,{onClick:()=>t.chain().focus().toggleItalic().run(),isActive:t.isActive("italic"),title:"Italic",children:g.jsx(mp,{className:"h-4 w-4"})}),g.jsx(Fe,{onClick:()=>t.chain().focus().toggleUnderline().run(),isActive:t.isActive("underline"),title:"Underline",children:g.jsx(bp,{className:"h-4 w-4"})}),g.jsx(Fe,{onClick:()=>t.chain().focus().toggleStrike().run(),isActive:t.isActive("strike"),title:"Strikethrough",children:g.jsx(rv,{className:"h-4 w-4"})}),g.jsx(Fe,{onClick:()=>t.chain().focus().toggleCode().run(),isActive:t.isActive("code"),title:"Inline Code",children:g.jsx(li,{className:"h-4 w-4"})}),g.jsx(tn.Separator,{orientation:"vertical",className:"h-6 mx-1"}),g.jsx(Fe,{onClick:()=>t.chain().focus().toggleSubscript().run(),isActive:t.isActive("subscript"),title:"Subscript",children:g.jsx(sv,{className:"h-4 w-4"})}),g.jsx(Fe,{onClick:()=>t.chain().focus().toggleSuperscript().run(),isActive:t.isActive("superscript"),title:"Superscript",children:g.jsx(iv,{className:"h-4 w-4"})}),g.jsx(tn.Separator,{orientation:"vertical",className:"h-6 mx-1"}),g.jsx(Fe,{onClick:()=>t.chain().focus().setTextAlign("left").run(),isActive:t.isActive({textAlign:"left"}),title:"Align Left",children:g.jsx(Ys,{className:"h-4 w-4"})}),g.jsx(Fe,{onClick:()=>t.chain().focus().setTextAlign("center").run(),isActive:t.isActive({textAlign:"center"}),title:"Align Center",children:g.jsx(Vo,{className:"h-4 w-4"})}),g.jsx(Fe,{onClick:()=>t.chain().focus().setTextAlign("right").run(),isActive:t.isActive({textAlign:"right"}),title:"Align Right",children:g.jsx(Wo,{className:"h-4 w-4"})}),g.jsx(Fe,{onClick:()=>t.chain().focus().setTextAlign("justify").run(),isActive:t.isActive({textAlign:"justify"}),title:"Justify",children:g.jsx(yp,{className:"h-4 w-4"})}),g.jsx(tn.Separator,{orientation:"vertical",className:"h-6 mx-1"}),g.jsx(Fe,{onClick:()=>t.chain().focus().toggleBulletList().run(),isActive:t.isActive("bulletList"),title:"Bullet List",children:g.jsx(ai,{className:"h-4 w-4"})}),g.jsx(Fe,{onClick:()=>t.chain().focus().toggleOrderedList().run(),isActive:t.isActive("orderedList"),title:"Numbered List",children:g.jsx(Fo,{className:"h-4 w-4"})}),g.jsx(Fe,{onClick:()=>t.chain().focus().toggleTaskList().run(),isActive:t.isActive("taskList"),title:"Task List",children:g.jsx(Qc,{className:"h-4 w-4"})}),g.jsx(tn.Separator,{orientation:"vertical",className:"h-6 mx-1"}),g.jsx(Fe,{onClick:()=>t.chain().focus().toggleBlockquote().run(),isActive:t.isActive("blockquote"),title:"Blockquote",children:g.jsx(qo,{className:"h-4 w-4"})}),g.jsx(Fe,{onClick:()=>t.chain().focus().toggleCodeBlock().run(),isActive:t.isActive("codeBlock"),title:"Code Block",children:g.jsx(Hr,{className:"h-4 w-4"})}),g.jsx(tn.Separator,{orientation:"vertical",className:"h-6 mx-1"}),g.jsx(NH,{editor:t}),g.jsx(RH,{editor:t}),g.jsx(tn.Separator,{orientation:"vertical",className:"h-6 mx-1"}),g.jsx(_H,{editor:t}),g.jsx(tn.Separator,{orientation:"vertical",className:"h-6 mx-1"}),g.jsx(Fe,{onClick:u,title:"View Source (HTML)",children:g.jsx(aB,{className:"h-4 w-4"})}),g.jsx(tn.Separator,{orientation:"vertical",className:"h-6 mx-1"}),g.jsx(Fe,{onClick:h,title:"Preview (executes scripts)",children:g.jsx(oB,{className:"h-4 w-4"})}),g.jsx(tn.Separator,{orientation:"vertical",className:"h-6 mx-1"}),g.jsx(OH,{editor:t})]}),e&&g.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:g.jsxs("div",{className:"bg-background border rounded-md shadow-xl w-[90vw] max-w-4xl h-[70vh] flex flex-col",children:[g.jsx("div",{className:"p-3 border-b font-semibold",children:"Edit HTML Source"}),g.jsx("textarea",{className:"flex-1 p-3 font-mono text-sm outline-none resize-none bg-muted/30",value:r,onChange:f=>s(f.target.value),spellCheck:!1}),g.jsxs("div",{className:"p-3 border-t flex justify-end gap-2",children:[g.jsx(ae.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>n(!1),children:"Cancel"}),g.jsx(ae.Button,{type:"button",variant:"secondary",size:"sm",onClick:()=>s(xd(r)),children:"Format"}),g.jsx(ae.Button,{type:"button",size:"sm",onClick:d,children:"Apply"})]})]})}),i&&g.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:g.jsxs("div",{className:"bg-background border rounded-md shadow-xl w-[95vw] max-w-5xl h-[80vh] flex flex-col",children:[g.jsxs("div",{className:"p-3 border-b flex items-center justify-between",children:[g.jsx("div",{className:"font-semibold",children:"Preview"}),g.jsxs("div",{className:"flex gap-2",children:[g.jsx(ae.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>{h()},children:"Refresh"}),g.jsx(ae.Button,{type:"button",size:"sm",onClick:()=>{for(const f of c.current)try{URL.revokeObjectURL(f)}catch{}c.current=[],l&&URL.revokeObjectURL(l),a(null),o(!1)},children:"Close"})]})]}),g.jsx("div",{className:"flex-1",children:g.jsx("iframe",{title:"Editor Preview",className:"w-full h-full",sandbox:"allow-scripts allow-same-origin allow-modals",src:l??void 0})})]})})]})},Ev=({editor:t,className:e})=>{const[n,r]=E.useState(!1),[s,i]=E.useState("format"),[o,l]=E.useState(!1),a=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||window.innerWidth<=768;E.useEffect(()=>{const h=()=>{r(a())};return h(),window.addEventListener("resize",h),()=>window.removeEventListener("resize",h)},[]),E.useEffect(()=>{if(!t)return;const h=()=>{const{selection:f}=t.state;!f.empty&&a()?r(!0):o||r(!1)};return t.on("selectionUpdate",h),t.on("focus",h),t.on("blur",()=>{o||r(!1)}),()=>{t.off("selectionUpdate",h),t.off("focus",h),t.off("blur",()=>r(!1))}},[t,o]);const c=[{icon:g.jsx(cc,{className:"h-4 w-4"}),label:"Bold",action:()=>t.chain().focus().toggleBold().run(),isActive:()=>t.isActive("bold"),section:"format"},{icon:g.jsx(mp,{className:"h-4 w-4"}),label:"Italic",action:()=>t.chain().focus().toggleItalic().run(),isActive:()=>t.isActive("italic"),section:"format"},{icon:g.jsx(bp,{className:"h-4 w-4"}),label:"Underline",action:()=>t.chain().focus().toggleUnderline().run(),isActive:()=>t.isActive("underline"),section:"format"},{icon:g.jsx(li,{className:"h-4 w-4"}),label:"Code",action:()=>t.chain().focus().toggleCode().run(),isActive:()=>t.isActive("code"),section:"format"},{icon:g.jsx(gp,{className:"h-4 w-4"}),label:"Highlight",action:()=>t.chain().focus().toggleHighlight().run(),isActive:()=>t.isActive("highlight"),section:"format"},{icon:g.jsx(ls,{className:"h-4 w-4"}),label:"Paragraph",action:()=>t.chain().focus().setParagraph().run(),isActive:()=>t.isActive("paragraph"),section:"blocks"},{icon:g.jsx(Gs,{className:"h-4 w-4"}),label:"Heading 1",action:()=>t.chain().focus().toggleHeading({level:1}).run(),isActive:()=>t.isActive("heading",{level:1}),section:"blocks"},{icon:g.jsx(Ho,{className:"h-4 w-4"}),label:"Heading 2",action:()=>t.chain().focus().toggleHeading({level:2}).run(),isActive:()=>t.isActive("heading",{level:2}),section:"blocks"},{icon:g.jsx(Gc,{className:"h-4 w-4"}),label:"Heading 3",action:()=>t.chain().focus().toggleHeading({level:3}).run(),isActive:()=>t.isActive("heading",{level:3}),section:"blocks"},{icon:g.jsx(ai,{className:"h-4 w-4"}),label:"Bullet List",action:()=>t.chain().focus().toggleBulletList().run(),isActive:()=>t.isActive("bulletList"),section:"blocks"},{icon:g.jsx(Fo,{className:"h-4 w-4"}),label:"Numbered List",action:()=>t.chain().focus().toggleOrderedList().run(),isActive:()=>t.isActive("orderedList"),section:"blocks"},{icon:g.jsx(Qc,{className:"h-4 w-4"}),label:"Task List",action:()=>t.chain().focus().toggleTaskList().run(),isActive:()=>t.isActive("taskList"),section:"blocks"},{icon:g.jsx(qo,{className:"h-4 w-4"}),label:"Quote",action:()=>t.chain().focus().toggleBlockquote().run(),isActive:()=>t.isActive("blockquote"),section:"blocks"},{icon:g.jsx(Yc,{className:"h-4 w-4"}),label:"Link",action:()=>{const h=window.prompt("Enter URL:");h&&t.chain().focus().setLink({href:h}).run()},isActive:()=>t.isActive("link"),section:"insert"},{icon:g.jsx(ts,{className:"h-4 w-4"}),label:"Image",action:async()=>{const h=su(t);if(h){const p=await h();p?.src&&t.chain().focus().setImage({src:p.src,alt:p.alt||void 0}).run();return}const f=window.prompt("Enter image URL:");f&&t.chain().focus().setImage({src:f}).run()},section:"insert"},{icon:g.jsx(Uo,{className:"h-4 w-4"}),label:"Table",action:()=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),section:"insert"},{icon:g.jsx(Ys,{className:"h-4 w-4"}),label:"Align Left",action:()=>t.chain().focus().setTextAlign("left").run(),isActive:()=>t.isActive({textAlign:"left"}),section:"align"},{icon:g.jsx(Vo,{className:"h-4 w-4"}),label:"Align Center",action:()=>t.chain().focus().setTextAlign("center").run(),isActive:()=>t.isActive({textAlign:"center"}),section:"align"},{icon:g.jsx(Wo,{className:"h-4 w-4"}),label:"Align Right",action:()=>t.chain().focus().setTextAlign("right").run(),isActive:()=>t.isActive({textAlign:"right"}),section:"align"}],u=[{key:"format",label:"Format",icon:g.jsx(cc,{className:"h-3 w-3"})},{key:"blocks",label:"Blocks",icon:g.jsx(Gs,{className:"h-3 w-3"})},{key:"insert",label:"Insert",icon:g.jsx(ts,{className:"h-3 w-3"})},{key:"align",label:"Align",icon:g.jsx(Ys,{className:"h-3 w-3"})}],d=c.filter(h=>h.section===s);return!n&&!o?null:g.jsxs("div",{className:Ie.cn("fixed bottom-0 left-0 right-0 z-50 bg-background border-t border-border shadow-lg","transform transition-transform duration-300 ease-in-out",n||o?"translate-y-0":"translate-y-full",e),children:[g.jsx("div",{className:"flex justify-center py-2 border-b border-border",children:g.jsxs(ae.Button,{variant:"ghost",size:"sm",onClick:()=>l(!o),className:"flex items-center gap-2",children:[o?g.jsx(av,{className:"h-4 w-4"}):g.jsx(NB,{className:"h-4 w-4"}),g.jsx("span",{className:"text-xs",children:o?"Close":"Tools"})]})}),(o||n)&&g.jsxs(g.Fragment,{children:[g.jsx("div",{className:"flex border-b border-border bg-muted/50",children:u.map(h=>g.jsx(ae.Button,{variant:s===h.key?"default":"ghost",size:"sm",onClick:()=>i(h.key),className:"flex-1 rounded-none text-xs py-2 h-auto",children:g.jsxs("div",{className:"flex flex-col items-center gap-1",children:[h.icon,g.jsx("span",{children:h.label})]})},h.key))}),g.jsx("div",{className:"p-2",children:g.jsx("div",{className:"flex flex-wrap gap-1 justify-center",children:d.map((h,f)=>g.jsxs(ae.Button,{variant:h.isActive?.()?"default":"ghost",size:"sm",onClick:h.action,className:"flex flex-col items-center gap-1 h-auto py-2 px-3 min-w-[60px]",title:h.label,children:[h.icon,g.jsx("span",{className:"text-xs",children:h.label})]},f))})})]}),g.jsx("div",{className:"h-safe-area-inset-bottom"})]})},iu=({content:t,onChange:e,placeholder:n,editable:r=!0,showToolbar:s=!0,showCharacterCount:i=!0,className:o,onFocus:l,onBlur:a,useEnhancedFloatingMenu:c=!0,showMobileToolbar:u=!0,enableAdvancedPlaceholders:d=!0,enableFocusMode:h=!1,showKeyboardShortcuts:f=!1})=>{const p=E.useRef(null),[m,y]=E.useState({isOpen:!1,searchTerm:"",replaceTerm:"",currentMatch:0,totalMatches:0,caseSensitive:!1,wholeWord:!1}),b=Dx({extensions:uc,content:t,editable:r,immediatelyRender:!1,onUpdate:({editor:v})=>{e(v.getHTML())},onFocus:()=>{l?.()},onBlur:()=>{a?.()},editorProps:{attributes:{class:Ie.cn("prose dark:prose-invert prose-sm sm:prose-base lg:prose-lg xl:prose-2xl","mx-auto focus:outline-none p-4 min-h-[500px] w-full","prose-headings:scroll-mt-[80px] prose-headings:font-semibold","prose-h1:text-4xl prose-h2:text-3xl prose-h3:text-2xl","prose-p:leading-7 prose-li:leading-7","prose-pre:bg-muted prose-pre:border prose-pre:rounded-lg","prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:rounded","prose-blockquote:border-l-4 prose-blockquote:border-primary prose-blockquote:pl-4","prose-table:border-collapse prose-table:border prose-table:border-border","prose-th:border prose-th:border-border prose-th:bg-muted prose-th:p-2","prose-td:border prose-td:border-border prose-td:p-2","prose-img:rounded-lg prose-img:shadow-sm",o)},handleKeyDown:(v,A)=>{if(A.ctrlKey||A.metaKey)switch(A.key){case"f":return A.preventDefault(),y(C=>({...C,isOpen:!C.isOpen})),!0;case"s":return A.preventDefault(),!0;default:return!1}return!1}}});E.useEffect(()=>{if(!b)return;const v=b.getHTML();if(t!==v){const{from:A,to:C}=b.state.selection;b.commands.setContent(t,{emitUpdate:!1}),b.commands.setTextSelection({from:A,to:C})}},[t,b]);const x=v=>{if(!b||!v){y(L=>({...L,totalMatches:0,currentMatch:0}));return}const A=b.getText(),C=m.caseSensitive?"g":"gi",N=m.wholeWord?`\\b${v}\\b`:v,D=new RegExp(N,C),z=A.match(D);y(L=>({...L,totalMatches:z?z.length:0,currentMatch:z?1:0}))},w=()=>{if(!b||!m.searchTerm)return;const v=b.getHTML(),A=m.caseSensitive?"g":"gi",C=m.wholeWord?`\\b${m.searchTerm}\\b`:m.searchTerm,N=new RegExp(C,A),D=v.replace(N,m.replaceTerm);b.commands.setContent(D),y(z=>({...z,totalMatches:0,currentMatch:0}))};if(!b)return null;const k=b.storage?.characterCount,T=k?.characters?.()??0,S=k?.words?.()??0;return g.jsxs("div",{ref:p,className:Ie.cn("relative w-full rounded-lg border shadow-sm","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2","bg-background",o),children:[s&&g.jsx(Ap,{editor:b}),m.isOpen&&g.jsxs("div",{className:"border-b bg-muted/50 p-3",children:[g.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[g.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[g.jsx(WB,{className:"h-4 w-4 text-muted-foreground"}),g.jsx(Ss.Input,{placeholder:"Search...",value:m.searchTerm,onChange:v=>{const A=v.target.value;y(C=>({...C,searchTerm:A})),x(A)},className:"h-8"}),g.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:m.totalMatches>0?`${m.currentMatch}/${m.totalMatches}`:"No matches"})]}),g.jsx(ae.Button,{variant:"ghost",size:"sm",onClick:()=>y(v=>({...v,isOpen:!1})),children:g.jsx(av,{className:"h-4 w-4"})})]}),g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(jB,{className:"h-4 w-4 text-muted-foreground"}),g.jsx(Ss.Input,{placeholder:"Replace with...",value:m.replaceTerm,onChange:v=>y(A=>({...A,replaceTerm:v.target.value})),className:"h-8 flex-1"}),g.jsx(ae.Button,{variant:"outline",size:"sm",onClick:w,disabled:!m.searchTerm||m.totalMatches===0,children:"Replace All"})]})]}),g.jsx(vp,{editor:b}),c?g.jsx(vv,{editor:b,wrapperRef:p}):g.jsx(Sp,{editor:b}),g.jsx(xf,{editor:b}),i&&k&&g.jsxs("div",{className:"absolute bottom-2 right-2 z-10 text-xs text-muted-foreground bg-background/80 backdrop-blur-sm rounded px-2 py-1 border",children:[T," characters / ",S," words"]}),f&&g.jsxs("div",{className:"absolute bottom-2 left-2 text-xs text-muted-foreground bg-background/80 backdrop-blur-sm rounded px-2 py-1 border opacity-0 hover:opacity-100 transition-opacity",children:[g.jsx("div",{children:"Ctrl+F: Search"}),g.jsx("div",{children:"Ctrl+S: Save"}),g.jsx("div",{children:"/: Commands"}),g.jsx("div",{children:"Ctrl+K: Insert Link"}),g.jsx("div",{children:"Ctrl+Shift+H: Highlight"}),g.jsx("div",{children:"Ctrl+Alt+1-6: Headings"})]}),u&&g.jsx(Ev,{editor:b})]})},DH=({editor:t})=>{const[e,n]=E.useState(!1),[r,s]=E.useState(!1),{x:i,y:o,refs:l,strategy:a,update:c}=Jo({placement:"top",strategy:"fixed",open:e,onOpenChange:n,middleware:[Ko(-12)],whileElementsMounted:ti}),u=E.useCallback(()=>t.isActive("image"),[t]),d=t.getAttributes("image")||{},h=E.useCallback(()=>{const{state:y,view:b}=t,x=()=>{try{if(y.selection instanceof Y){const v=b.nodeDOM(y.selection.from);if(v){const A=v.closest?.(".tiptap-image-wrapper")??v;return A.querySelector("img")??A}}const T=b.dom.querySelector(".tiptap-image-wrapper.ProseMirror-selectednode");if(T)return T.querySelector("img")??T;const S=b.dom.querySelector(".ProseMirror-selectednode");if(S){const v=S.closest?.(".tiptap-image-wrapper")??S;return v.querySelector("img")??v}}catch{}return null},w=h._lastEl,k=x()??w;if(k){h._lastEl=k;const T={getBoundingClientRect:()=>{const S=x()??h._lastEl;return S?S.getBoundingClientRect():new DOMRect(0,0,0,0)}};l.setReference(T)}else{const T=b.coordsAtPos(y.selection.from),S={getBoundingClientRect:()=>new DOMRect(T.left,T.top,0,0)};l.setReference(S)}requestAnimationFrame(()=>{c(),requestAnimationFrame(()=>s(!0))})},[t,l,c]);if(E.useEffect(()=>{const y=()=>{const b=u();n(b),s(!1),b&&h()};return y(),t.on("selectionUpdate",y),t.on("transaction",y),t.on("focus",y),t.on("blur",()=>n(!1)),()=>{t.off("selectionUpdate",y),t.off("transaction",y),t.off("focus",y)}},[t,u,h]),!e)return null;const f=y=>{t.chain().focus().updateAttributes("image",{align:y}).run(),requestAnimationFrame(()=>h())},p=()=>{t.chain().focus().deleteSelection().run()},m=()=>{const y=d?.src;if(y)try{const b=document.createElement("a");b.href=y;const x=(y.split("?")[0]||"").split("/").pop()||"image";b.download=x,document.body.appendChild(b),b.click(),b.remove()}catch{}};return g.jsxs("div",{ref:l.setFloating,style:{position:a,top:o??0,left:i??0,zIndex:10002,visibility:r?"visible":"hidden",pointerEvents:"auto"},className:"bg-background/95 backdrop-blur border rounded-full shadow-lg px-3 py-2 flex items-center gap-1",onMouseDown:y=>y.preventDefault(),children:[g.jsx(ae.Button,{size:"icon",variant:d.align==="left"?"default":"ghost",title:"Align left",onClick:()=>f("left"),children:g.jsx(Ys,{className:"h-4 w-4"})}),g.jsx(ae.Button,{size:"icon",variant:d.align==="center"?"default":"ghost",title:"Align center",onClick:()=>f("center"),children:g.jsx(Vo,{className:"h-4 w-4"})}),g.jsx(ae.Button,{size:"icon",variant:d.align==="right"?"default":"ghost",title:"Align right",onClick:()=>f("right"),children:g.jsx(Wo,{className:"h-4 w-4"})}),g.jsx(ae.Button,{size:"icon",variant:"ghost",title:"Download",onClick:m,children:g.jsx(nv,{className:"h-4 w-4"})}),g.jsx(ae.Button,{size:"icon",variant:"ghost",title:"Delete",onClick:p,children:g.jsx(ov,{className:"h-4 w-4"})})]})},pb=t=>t.isActive("table")||t.isActive("tableCell")||t.isActive("tableHeader")||t.isActive("tableRow"),LH=({editor:t})=>{const[e,n]=E.useState(!1),[r,s]=E.useState(!1),{refs:i,x:o,y:l,strategy:a,update:c}=Jo({placement:"bottom",strategy:"fixed",middleware:[Ko(12),nu(),tu()],whileElementsMounted:ti,open:e,onOpenChange:n}),u=E.useCallback(()=>{const{state:A,view:C}=t;try{const{from:N}=A.selection,{node:D}=C.domAtPos(N);let z=null;return D.nodeType===Node.ELEMENT_NODE?z=D:(D.nodeType===Node.TEXT_NODE||D?.parentElement)&&(z=D.parentElement),z?.closest?.("td, th")??null}catch{return null}},[t]),d=E.useCallback(()=>u()?.closest("table")??null,[u]),h=E.useCallback(()=>{if(!pb(t)){n(!1);return}const A=d();if(!A){n(!1);return}i.setReference(A),n(!0),s(!1),requestAnimationFrame(()=>{c(),requestAnimationFrame(()=>s(!0))})},[t,i,d,c]);if(E.useEffect(()=>{const A=()=>{pb(t)?h():n(!1)},C=()=>n(!1);return A(),t.on("selectionUpdate",A),t.on("transaction",A),t.on("focus",A),t.on("blur",C),()=>{t.off("selectionUpdate",A),t.off("transaction",A),t.off("focus",A),t.off("blur",C)}},[t,h]),!e)return null;const f=t.can(),p=typeof f.addRowAfter=="function"?f.addRowAfter():!1,m=typeof f.deleteRow=="function"?f.deleteRow():!1,y=typeof f.addColumnAfter=="function"?f.addColumnAfter():!1,b=typeof f.deleteColumn=="function"?f.deleteColumn():!1,x=typeof f.deleteTable=="function"?f.deleteTable():!1,w=()=>{t.chain().focus().addRowAfter().run(),h()},k=()=>{t.chain().focus().deleteRow().run(),h()},T=()=>{t.chain().focus().addColumnAfter().run(),h()},S=()=>{t.chain().focus().deleteColumn().run(),h()},v=()=>{t.chain().focus().deleteTable().run(),n(!1)};return g.jsxs("div",{ref:i.setFloating,style:{position:a,top:l??0,left:o??0,zIndex:10002,visibility:r?"visible":"hidden"},className:"flex items-center gap-1 rounded-full border bg-background/95 px-2 py-1 shadow-lg",onMouseDown:A=>A.preventDefault(),children:[g.jsx(ae.Button,{size:"icon",variant:"ghost",onClick:w,disabled:!p,title:"Add row below","aria-label":"Add row below",children:g.jsx(UB,{className:"h-4 w-4"})}),g.jsx(ae.Button,{size:"icon",variant:"ghost",onClick:k,disabled:!m,title:"Delete current row","aria-label":"Delete current row",children:g.jsx(HB,{className:"h-4 w-4"})}),g.jsx(ae.Button,{size:"icon",variant:"ghost",onClick:T,disabled:!y,title:"Add column to the right","aria-label":"Add column to the right",children:g.jsx(tB,{className:"h-4 w-4"})}),g.jsx(ae.Button,{size:"icon",variant:"ghost",onClick:S,disabled:!b,title:"Delete current column","aria-label":"Delete current column",children:g.jsx(Q$,{className:"h-4 w-4"})}),g.jsx(ae.Button,{size:"icon",variant:"ghost",onClick:v,disabled:!x,title:"Delete table","aria-label":"Delete table",children:g.jsx(ov,{className:"h-4 w-4"})})]})},Av=({content:t,initialContent:e,onChange:n,onUpdate:r,placeholder:s,editable:i=!0,showToolbar:o=!0,showAiPrompt:l=!0,showCharacterCount:a=!0,className:c,onFocus:u,onBlur:d,openImagePicker:h,extensions:f,dynamicExtensions:p})=>{const m=E.useRef(null),[y,b]=E.useState(""),[x,w]=E.useState(null),[k,T]=E.useState(!1),S=I=>{if(typeof I=="string"){const P=I.trim();if(P.startsWith("{")||P.startsWith("["))try{return JSON.parse(P)}catch{}}return I},v=S(t||e),A=E.useMemo(()=>f??(p&&p.length>0?[...uc,...p]:uc),[p,f]),C=Dx({extensions:A,content:v,editable:i,immediatelyRender:!1,editorProps:{attributes:{class:Ie.cn("prose dark:prose-invert prose-sm sm:prose-base lg:prose-lg xl:prose-2xl","mx-auto focus:outline-none min-h-[500px] w-full","pl-14 pr-4 py-4","prose-headings:scroll-mt-[80px] prose-headings:font-semibold","prose-h1:text-4xl prose-h2:text-3xl prose-h3:text-2xl","prose-p:leading-7 prose-li:leading-7","prose-pre:bg-muted prose-pre:border prose-pre:rounded-lg","prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:rounded","prose-blockquote:border-l-4 prose-blockquote:border-primary prose-blockquote:pl-4","prose-table:border-collapse prose-table:border prose-table:border-border","prose-th:border prose-th:border-border prose-th:bg-muted prose-th:p-2","prose-td:border prose-td:border-border prose-td:p-2","prose-img:rounded-lg prose-img:shadow-sm")}}});E.useEffect(()=>{if(!C)return;const I=()=>{n?.(C.getHTML()),r?.(C.getJSON())},P=()=>{u?.()},ne=()=>{d?.()};return C.on("update",I),C.on("focus",P),C.on("blur",ne),()=>{C.off("update",I),C.off("focus",P),C.off("blur",ne)}},[C,n,u,d,r]),E.useEffect(()=>{if(C)return cb(C,h),()=>cb(C,void 0)},[C,h]),E.useEffect(()=>{C&&C.isEditable!==i&&C.setEditable(i)},[C,i]);const N=E.useRef(t);if(E.useEffect(()=>{if(!C)return;const I=()=>{N.current=C.getHTML()};return C.on("update",I),()=>{C.off("update",I)}},[C]),E.useEffect(()=>{if(!C||t===void 0||t===N.current)return;const I=C.getHTML(),P=S(t);if(P!==void 0)if(typeof P=="string"){if(P===I)return;if(C.isEmpty&&(P===""||P==="<p></p>")){N.current=t;return}const{from:ne,to:R}=C.state.selection;C.commands.setContent(P,{emitUpdate:!1}),C.commands.setTextSelection({from:ne,to:R}),N.current=t}else{const{from:ne,to:R}=C.state.selection;C.commands.setContent(P,{emitUpdate:!1}),C.commands.setTextSelection({from:ne,to:R}),N.current=t}},[t,C]),E.useEffect(()=>{if(!(!C||typeof window>"u"))return window.__nextblockEditor=C,()=>{window.__nextblockEditor===C&&delete window.__nextblockEditor}},[C]),E.useEffect(()=>{if(!C||typeof window>"u")return;const I=()=>{const R=window.__dragHandleElement;if(!R)return;const q=R.parentElement,le=C.view.dom.parentElement??C.view.dom;q&&le&&!q.isConnected&&le.appendChild(q)},P=()=>I();I(),C.on("selectionUpdate",P),C.on("transaction",P),C.on("focus",P);const ne=window.setInterval(I,2e3);return()=>{C.off("selectionUpdate",P),C.off("transaction",P),C.off("focus",P),window.clearInterval(ne)}},[C]),E.useEffect(()=>()=>{typeof document<"u"&&document.body.classList.remove("dragging")},[]),!C)return null;const D=C.storage?.characterCount,z=D?.characters?.()??0,L=D?.words?.()??0,_=()=>{window.requestAnimationFrame(()=>{const I=m.current?.querySelector('[data-editor-scroll-area="true"]');I?.scrollTo({behavior:"smooth",top:I.scrollHeight})})},V=I=>{if(I.insertionMode==="replace-empty-document")return"Insertion target: empty editor. Create the initial content for this document.";const P=C.getText().trim();return[`Insertion target: ${I.insertionMode}.`,I.insertionMode==="append-to-end"?"Continue after the existing content. Do not repeat existing headings, paragraphs, or lists unless the user explicitly asks for a rewrite.":"Replace only the selected content. Keep surrounding editor content in mind for continuity.",I.selectedText?`Selected text:
173
+ ${I.selectedText.slice(0,600)}`:null,P?`Existing editor text:
174
+ ${P.slice(-1400)}`:null].filter(Boolean).join(`
175
+
176
+ `).slice(0,2e3)},ee=async()=>{const I=y.trim();if(!I||k)return;w(null),T(!0);const P=new AbortController,ne=window.setTimeout(()=>P.abort(),15e4),R=C.isEmpty,q=C.state.selection,le=!q.empty,Se=le?C.state.doc.textBetween(q.from,q.to," ").trim():"",Ot=R?"replace-empty-document":le?"replace-selection":"append-to-end";try{const Ye={"content-type":"application/json"};if(process.env.NEXT_PUBLIC_IS_SANDBOX==="true"){const Dt=window.localStorage.getItem("cortex_ai_sandbox_openrouter_api_key"),as=window.localStorage.getItem("cortex_ai_sandbox_openrouter_model_selection");Dt&&(Ye["x-sandbox-openrouter-key"]=Dt),as&&(Ye["x-sandbox-openrouter-model"]=as)}const Ce=V({insertionMode:Ot,selectedText:Se}),Ze=await fetch("/api/ai/generate-blocks",{body:JSON.stringify({context:Ce,prompt:I}),headers:Ye,method:"POST",signal:P.signal}),wt=await Ze.json();if(!Ze.ok)throw new Error(wt?.error||"Cortex AI could not generate content.");if(!wt||typeof wt.html!="string"||!wt.html.trim())throw new Error("Cortex AI returned an invalid HTML fragment.");if(R||C.isEmpty)C.commands.setContent(wt.html);else if(le){const Dt=C.state.doc.content.size,as=Math.min(q.from,Dt),ou=Math.min(q.to,Dt);C.chain().focus().insertContentAt({from:as,to:ou},wt.html).run()}else C.chain().focus().insertContentAt(C.state.doc.content.size,wt.html).run(),_();b("")}catch(Ye){w(Ye instanceof DOMException&&Ye.name==="AbortError"?"Cortex AI took too long to generate content. Please try again with a shorter prompt.":Ye instanceof Error?Ye.message:"Cortex AI could not generate content.")}finally{window.clearTimeout(ne),T(!1)}},be=I=>{I.key==="Enter"&&(I.preventDefault(),ee())};return g.jsxs("div",{ref:m,className:Ie.cn("relative w-full rounded-lg border bg-background shadow-sm","flex flex-col h-full min-h-0","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",c),children:[o&&g.jsx(Ap,{editor:C}),l&&i&&g.jsxs("div",{role:"group","aria-label":"Cortex AI content generation",className:"flex items-center gap-2 border-b bg-muted/30 px-3 py-2",children:[g.jsx("label",{htmlFor:"cortex-ai-editor-prompt",className:"sr-only",children:"Cortex AI prompt"}),g.jsx("input",{id:"cortex-ai-editor-prompt",value:y,onChange:I=>b(I.target.value),onKeyDown:be,disabled:k,placeholder:"Ask Cortex AI",className:"min-w-0 flex-1 rounded-md border bg-background px-3 py-2 text-sm outline-none transition focus:ring-2 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-60"}),g.jsx("button",{type:"button",onClick:()=>{ee()},disabled:!y.trim()||k,title:"Generate rich text",className:"inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-md border bg-background text-foreground transition hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50",children:k?g.jsx(AB,{className:"h-4 w-4 animate-spin"}):g.jsx(KB,{className:"h-4 w-4"})})]}),x&&g.jsx("div",{className:"border-b bg-destructive/10 px-3 py-2 text-sm text-destructive",children:x}),g.jsx(vp,{editor:C}),g.jsx(Sp,{editor:C}),g.jsx(DH,{editor:C}),g.jsx(LH,{editor:C}),g.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto","data-editor-scroll-area":"true",children:g.jsx(xf,{editor:C})}),a&&D&&g.jsxs("div",{className:"absolute bottom-2 right-2 text-xs z-10 text-muted-foreground bg-background/80 backdrop-blur-sm rounded px-2 py-1 border",children:[z," characters / ",L," words"]})]})},Mv=E.forwardRef(({className:t,...e},n)=>g.jsx("div",{ref:n,className:Ie.cn("flex items-center gap-1 rounded-md bg-background p-1",t),...e}));Mv.displayName="Toolbar";const Tv=E.forwardRef(({className:t,...e},n)=>g.jsx("div",{ref:n,className:Ie.cn("flex items-center gap-1",t),...e}));Tv.displayName="ToolbarGroup";const Nv=E.forwardRef(({className:t,isActive:e,...n},r)=>g.jsx("button",{ref:r,className:Ie.cn("inline-flex items-center justify-center rounded-md p-1.5 text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{"bg-accent text-accent-foreground":e},t),...n}));Nv.displayName="ToolbarButton";const Rv=E.forwardRef(({className:t,...e},n)=>g.jsx("div",{ref:n,className:Ie.cn("mx-1 h-7 w-px bg-muted",t),...e}));Rv.displayName="ToolbarSeparator";var IH=t=>{const{className:e="drag-handle",children:n,editor:r,pluginKey:s=Bk,onNodeChange:i,onElementDragStart:o,onElementDragEnd:l,getReferencedVirtualElement:a,computePositionConfig:c=Nh,nested:u=!1}=t,[d]=E.useState(()=>typeof document>"u"?null:document.createElement("div")),h=E.useMemo(()=>Hk(u),[JSON.stringify(u)]);return E.useEffect(()=>{d&&(d.className=e,d.style.visibility="hidden",d.style.position="absolute",d.dataset.dragging="false")},[e,d]),E.useEffect(()=>{if(!d||r.isDestroyed)return;const{plugin:f,unbind:p}=zk({editor:r,element:d,pluginKey:s,computePositionConfig:{...Nh,...c},onElementDragStart:o,onElementDragEnd:l,onNodeChange:i,getReferencedVirtualElement:a,nestedOptions:h});return r.registerPlugin(f),()=>{r.isDestroyed||r.unregisterPlugin(s),p()}},[d,r,i,a,s,c,o,l,h]),d?pc.createPortal(n,d):null},PH=IH;const jH=({editor:t,className:e,onDragStart:n,onDragEnd:r,onNodeChange:s})=>{const i=E.useRef(null),o=E.useMemo(()=>a=>{a.preventDefault(),a.stopPropagation();const c=i.current;if(!c)return;const u=new CustomEvent("tiptap-gutter-toggle",{bubbles:!0,detail:{handle:c,button:a.currentTarget}});c.dispatchEvent(u)},[]),l=a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),o(a))};return t?g.jsx(PH,{editor:t,className:Ie.cn("tiptap-drag-handle",e),onElementDragStart:n,onElementDragEnd:r,onNodeChange:a=>s?.(a),children:g.jsxs("div",{ref:i,className:"tiptap-drag-handle__group",role:"group","data-orientation":"horizontal",children:[g.jsx("button",{type:"button","aria-label":"Insert block",title:"Insert block",className:"tiptap-drag-handle__button tiptap-drag-handle__button--ghost tiptap-drag-handle__plus",onClick:o,onKeyDown:l,children:g.jsx($H,{})}),g.jsx("button",{type:"button",className:"tiptap-drag-handle__button tiptap-drag-handle__button--ghost tiptap-drag-handle__grip","aria-label":"Drag to reorder",title:"Drag to reorder",tabIndex:0,children:g.jsx(BH,{})})]})}):null},$H=({className:t,...e})=>g.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:Ie.cn("tiptap-drag-handle__icon tiptap-drag-handle__icon--filled",t),...e,children:g.jsx("path",{d:"M13 5C13 4.44772 12.5523 4 12 4C11.4477 4 11 4.44772 11 5V11H5C4.44772 11 4 11.4477 4 12C4 12.5523 4.44772 13 5 13H11V19C11 19.5523 11.4477 20 12 20C12.5523 20 13 19.5523 13 19V13H19C19.5523 13 20 12.5523 20 12C20 11.4477 19.5523 11 19 11H13V5Z"})}),BH=({className:t,...e})=>g.jsxs("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:Ie.cn("tiptap-drag-handle__icon tiptap-drag-handle__icon--filled",t),...e,children:[g.jsx("path",{d:"M9 3C7.89543 3 7 3.89543 7 5C7 6.10457 7.89543 7 9 7C10.1046 7 11 6.10457 11 5C11 3.89543 10.1046 3 9 3Z"}),g.jsx("path",{d:"M9 10C7.89543 10 7 10.8954 7 12C7 13.1046 7.89543 14 9 14C10.1046 14 11 13.1046 11 12C11 10.8954 10.1046 10 9 10Z"}),g.jsx("path",{d:"M7 19C7 17.8954 7.89543 17 9 17C10.1046 17 11 17.8954 11 19C11 20.1046 10.1046 21 9 21C7.89543 21 7 20.1046 7 19Z"}),g.jsx("path",{d:"M15 10C13.8954 10 13 10.8954 13 12C13 13.1046 13.8954 14 15 14C16.1046 14 17 13.1046 17 12C17 10.8954 16.1046 10 15 10Z"}),g.jsx("path",{d:"M13 5C13 3.89543 13.8954 3 15 3C16.1046 3 17 3.89543 17 5C17 6.10457 16.1046 7 15 7C13.8954 7 13 6.10457 13 5Z"}),g.jsx("path",{d:"M15 17C13.8954 17 13 17.8954 13 19C13 20.1046 13.8954 21 15 21C16.1046 21 17 20.1046 17 19C17 17.8954 16.1046 17 15 17Z"})]}),zH=({html:t,className:e})=>{const n=E.useRef(null);return E.useEffect(()=>{const r=n.current;if(!r)return;r.innerHTML=t;const s=[];return Array.from(r.querySelectorAll("script")).forEach(o=>{const l=document.createElement("script");for(const a of Array.from(o.attributes))l.setAttribute(a.name,a.value);if(o.src)l.src=o.src;else{const a=o.textContent||"",c=new Blob([a],{type:l.type||"text/javascript"}),u=URL.createObjectURL(c);l.src=u,l.async=!1,s.push(u)}o.parentNode?.insertBefore(l,o),o.remove()}),()=>{s.forEach(o=>{try{URL.revokeObjectURL(o)}catch(l){process.env.NODE_ENV!=="production"&&console.warn("Failed to revoke object URL",o,l)}})}},[t]),g.jsx("div",{ref:n,className:e})},HH=ce.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:[]}},addProseMirrorPlugins(){const t=new ge("trailingNode");return[new me({key:t,appendTransaction:(e,n,r)=>{if(!e.some(h=>h.docChanged))return null;const{doc:i,schema:o}=r,l=i.lastChild,a=this.options.node,c=o.nodes[a];if(!c||l?.type.name===a||l&&this.options.notAfter.includes(l.type.name))return null;const u=i.content.size;return r.tr.insert(u,c.create())}})]}}),FH=ce.create({name:"enhancedFocus",addOptions(){return{className:"has-focus",mode:"all",showFocusRing:!0,highlightSelection:!0,dimUnfocused:!1,animateTransitions:!0}},addProseMirrorPlugins(){return[new me({key:new ge("enhancedFocus"),props:{decorations:({doc:t,selection:e})=>{const{from:n,to:r}=e,s=[];if(t.nodesBetween(n,r,(i,o)=>{const l=_e.node(o,o+i.nodeSize,{class:this.options.className});s.push(l)}),this.options.highlightSelection&&n!==r){const i=_e.inline(n,r,{class:"selection-highlight"});s.push(i)}if(this.options.showFocusRing){const i=_e.widget(n,()=>{const o=document.createElement("div");return o.className="focus-ring",o});s.push(i)}return xe.create(t,s)}},view:()=>({update:(t,e)=>{const{state:n}=t,{selection:r}=n,s=e.selection;r.eq(s)||this.editor.emit("selectionUpdate",{editor:this.editor,transaction:n.tr})}})})]},addGlobalAttributes(){return[{types:["paragraph","heading","blockquote","codeBlock","listItem"],attributes:{"data-focused":{default:null,renderHTML:t=>t["data-focused"]?{"data-focused":t["data-focused"]}:{}}}}]},onCreate(){const t=this.editor.view.dom;this.options.animateTransitions&&t.classList.add("focus-transitions"),this.options.dimUnfocused&&t.classList.add("dim-unfocused")},onSelectionUpdate(){const{state:t}=this.editor,{selection:e}=t,{from:n,to:r}=e,s=t.tr;let i=!1;t.doc.descendants((o,l)=>{if(o.isText||o.isLeaf)return;const a=l,c=l+o.nodeSize,u=n>=a&&r<=c,d=o.attrs["data-focused"];u&&!d?(s.setNodeMarkup(l,void 0,{...o.attrs,"data-focused":"true"}),i=!0):!u&&d&&(s.setNodeMarkup(l,void 0,{...o.attrs,"data-focused":null}),i=!0)}),i&&this.editor.view.dispatch(s)},addStorage(){return{isFocused:!1}},onFocus(){this.editor.view.dom.classList.add("editor-focused"),this.storage.isFocused=!0},onBlur(){this.editor.view.dom.classList.remove("editor-focused"),this.storage.isFocused=!1}}),UH=ce.create({name:"keyboardShortcuts",addOptions(){return{enableAdvancedShortcuts:!0,enableCustomShortcuts:!0,showShortcutHints:!1}},addKeyboardShortcuts(){const t={};return this.options.enableAdvancedShortcuts&&(t["Mod-Shift-x"]=()=>this.editor.commands.toggleStrike(),t["Mod-Shift-h"]=()=>this.editor.commands.toggleHighlight(),t["Mod-Shift-c"]=()=>this.editor.commands.toggleCode(),t["Mod-Alt-1"]=()=>this.editor.commands.toggleHeading({level:1}),t["Mod-Alt-2"]=()=>this.editor.commands.toggleHeading({level:2}),t["Mod-Alt-3"]=()=>this.editor.commands.toggleHeading({level:3}),t["Mod-Alt-4"]=()=>this.editor.commands.toggleHeading({level:4}),t["Mod-Alt-5"]=()=>this.editor.commands.toggleHeading({level:5}),t["Mod-Alt-6"]=()=>this.editor.commands.toggleHeading({level:6}),t["Mod-Alt-0"]=()=>this.editor.commands.setParagraph(),t["Mod-Shift-8"]=()=>this.editor.commands.toggleBulletList(),t["Mod-Shift-7"]=()=>this.editor.commands.toggleOrderedList(),t["Mod-Shift-9"]=()=>this.editor.commands.toggleTaskList(),t["Mod-Shift-b"]=()=>this.editor.commands.toggleBlockquote(),t["Mod-Alt-c"]=()=>this.editor.commands.toggleCodeBlock(),t["Mod-Shift-minus"]=()=>this.editor.commands.setHorizontalRule(),t["Mod-Shift-l"]=()=>this.editor.commands.setTextAlign("left"),t["Mod-Shift-e"]=()=>this.editor.commands.setTextAlign("center"),t["Mod-Shift-r"]=()=>this.editor.commands.setTextAlign("right"),t["Mod-Shift-j"]=()=>this.editor.commands.setTextAlign("justify"),t["Mod-comma"]=()=>this.editor.commands.toggleSubscript(),t["Mod-period"]=()=>this.editor.commands.toggleSuperscript(),t["Mod-Alt-t"]=()=>this.editor.can().insertTable()?this.editor.commands.insertTable({rows:3,cols:3,withHeaderRow:!0}):!1,t["Mod-Home"]=()=>this.editor.commands.focus("start"),t["Mod-End"]=()=>this.editor.commands.focus("end"),t["Mod-a"]=()=>this.editor.commands.selectAll(),t["Mod-\\"]=()=>this.editor.commands.unsetAllMarks()&&this.editor.commands.clearNodes(),t["Mod-k"]=()=>{const e=window.prompt("Enter URL:");return e?this.editor.commands.setLink({href:e}):!1},t["Mod-Shift-i"]=()=>{const e=window.prompt("Enter image URL:");return e?this.editor.commands.setImage({src:e}):!1},t["Alt-ArrowUp"]=()=>{const{selection:e}=this.editor.state,{$from:n}=e,r=n.nodeBefore;if(r){const s=n.pos-r.nodeSize;return this.editor.commands.setTextSelection(s)}return!1},t["Alt-ArrowDown"]=()=>{const{selection:e}=this.editor.state,{$to:n}=e,r=n.nodeAfter;if(r){const s=n.pos+r.nodeSize;return this.editor.commands.setTextSelection(s)}return!1},t["Mod-Shift-d"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);return s?this.editor.commands.insertContentAt(r,`
177
+ ${s}`):!1},t["Mod-Shift-k"]=()=>{const{selection:e}=this.editor.state,{$from:n,$to:r}=e,s=n.start(),i=r.end();return this.editor.commands.deleteRange({from:s,to:i})},t["Mod-Backspace"]=()=>{const{selection:e}=this.editor.state,{from:n}=e,r=this.editor.state.doc.resolve(n);let s=n;const i=r.parent.textContent,o=r.parentOffset;for(let l=o-1;l>=0;l--){if(/\s/.test(i[l])){s=n-(o-l-1);break}l===0&&(s=n-o)}return this.editor.commands.deleteRange({from:s,to:n})},t["Mod-Delete"]=()=>{const{selection:e}=this.editor.state,{to:n}=e,r=this.editor.state.doc.resolve(n);let s=n;const i=r.parent.textContent,o=r.parentOffset;for(let l=o;l<i.length;l++){if(/\s/.test(i[l])){s=n+(l-o);break}l===i.length-1&&(s=n+(i.length-o))}return this.editor.commands.deleteRange({from:n,to:s})}),this.options.enableCustomShortcuts&&(t["Mod-Shift-a"]=()=>this.editor.can().setAlertWidget()?this.editor.commands.setAlertWidget():!1,t["Mod-Shift-t"]=()=>this.editor.can().setCtaWidget()?this.editor.commands.setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}):!1,t["Mod-Shift-f"]=()=>(this.editor.view.dom.classList.toggle("focus-mode"),!0),t["Mod-Shift-w"]=()=>(this.editor.view.dom.classList.toggle("writing-mode"),!0),t["Mod-Shift-u"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);return s?this.editor.commands.insertContentAt({from:n,to:r},s.toUpperCase()):!1},t["Mod-Shift-l"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);return s?this.editor.commands.insertContentAt({from:n,to:r},s.toLowerCase()):!1},t["Mod-Shift-p"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);if(s){const i=s.replace(/\w\S*/g,o=>o.charAt(0).toUpperCase()+o.substr(1).toLowerCase());return this.editor.commands.insertContentAt({from:n,to:r},i)}return!1}),t},addStorage(){return{shortcuts:{},hints:[]}},onCreate(){this.options.showShortcutHints&&(this.storage.shortcuts={},this.storage.hints=[{category:"Text Formatting",shortcuts:[{keys:"Cmd/Ctrl + B",action:"Bold"},{keys:"Cmd/Ctrl + I",action:"Italic"},{keys:"Cmd/Ctrl + U",action:"Underline"},{keys:"Cmd/Ctrl + Shift + X",action:"Strikethrough"},{keys:"Cmd/Ctrl + Shift + H",action:"Highlight"},{keys:"Cmd/Ctrl + E",action:"Inline Code"}]},{category:"Headings",shortcuts:[{keys:"Cmd/Ctrl + Alt + 1-6",action:"Heading 1-6"},{keys:"Cmd/Ctrl + Alt + 0",action:"Paragraph"}]},{category:"Lists",shortcuts:[{keys:"Cmd/Ctrl + Shift + 8",action:"Bullet List"},{keys:"Cmd/Ctrl + Shift + 7",action:"Numbered List"},{keys:"Cmd/Ctrl + Shift + 9",action:"Task List"}]},{category:"Blocks",shortcuts:[{keys:"Cmd/Ctrl + Shift + B",action:"Blockquote"},{keys:"Cmd/Ctrl + Alt + C",action:"Code Block"},{keys:"Cmd/Ctrl + Alt + T",action:"Table"}]},{category:"Navigation",shortcuts:[{keys:"Cmd/Ctrl + A",action:"Select All"},{keys:"Cmd/Ctrl + Home",action:"Go to Start"},{keys:"Cmd/Ctrl + End",action:"Go to End"}]},{category:"Advanced",shortcuts:[{keys:"Cmd/Ctrl + K",action:"Insert Link"},{keys:"Cmd/Ctrl + Shift + I",action:"Insert Image"},{keys:"Cmd/Ctrl + \\",action:"Clear Formatting"}]}])}}),VH=()=>{const[t,e]=E.useState("<p>Start testing...</p>"),[n,r]=E.useState([]),[s,i]=E.useState(!1),[o,l]=E.useState(""),a=S=>({name:S,tests:[],status:"pending"}),c=(S,v)=>{r(A=>A.map(C=>{if(C.name===S){const N=[...C.tests,v],D=N.some(_=>_.status==="fail"),z=N.some(_=>_.status==="warning"),L=N.every(_=>_.status!=="pending");return{...C,tests:N,status:D?"fail":z?"warning":L?"pass":"pending"}}return C}))},u=S=>new Promise(v=>setTimeout(v,S)),d=async()=>{const S="Drag and Drop";l(S);try{const v=document.querySelectorAll(".drag-handle, .drag-handle-button");c(S,{name:"Drag Handle Presence",status:v.length>0?"pass":"fail",message:v.length>0?"Drag handles found":"No drag handles detected",details:`Found ${v.length} drag handle elements`});const A=document.querySelector("style")?.textContent?.includes("drag-handle")||Array.from(document.styleSheets).some(N=>{try{return Array.from(N.cssRules).some(D=>D.cssText.includes("drag-handle"))}catch{return!1}});c(S,{name:"Drag Handle CSS",status:A?"pass":"warning",message:A?"Drag handle CSS loaded":"Drag handle CSS may not be loaded",details:"Check if drag-handle.css is properly imported"});const C=document.querySelectorAll('[data-draggable="true"]');c(S,{name:"Draggable Nodes",status:C.length>0?"pass":"warning",message:C.length>0?"Draggable nodes found":"No draggable nodes detected",details:`Found ${C.length} draggable nodes`})}catch(v){c(S,{name:"Drag and Drop Test",status:"fail",message:"Test failed with error",details:v instanceof Error?v.message:"Unknown error"})}},h=async()=>{const S="Undo/Redo System";l(S);try{const v=document.querySelectorAll('[aria-label*="Undo"], [title*="Undo"]'),A=document.querySelectorAll('[aria-label*="Redo"], [title*="Redo"]');c(S,{name:"Undo/Redo Buttons",status:v.length>0&&A.length>0?"pass":"fail",message:`Found ${v.length} undo and ${A.length} redo buttons`,details:"Undo/Redo buttons should be present in toolbar"}),e("<p>Test content for undo</p>"),await u(100),c(S,{name:"History State Change",status:"pass",message:"Content change detected",details:"History system should track this change"});const C=typeof document<"u"&&document.addEventListener!==void 0;c(S,{name:"Keyboard Shortcuts",status:C?"pass":"warning",message:"Keyboard event system available",details:"Ctrl+Z and Ctrl+Y shortcuts should work"})}catch(v){c(S,{name:"Undo/Redo Test",status:"fail",message:"Test failed with error",details:v instanceof Error?v.message:"Unknown error"})}},f=async()=>{const S="Enhanced Floating Menu";l(S);try{const v=document.querySelectorAll('[aria-label*="Insert"], .enhanced-floating-menu');c(S,{name:"Floating Menu Trigger",status:v.length>0?"pass":"warning",message:v.length>0?"Floating menu trigger found":"No floating menu trigger detected",details:"Should appear on empty paragraphs"});const A=document.querySelectorAll('input[placeholder*="Search"], .search-input');c(S,{name:"Search Functionality",status:A.length>0?"pass":"warning",message:A.length>0?"Search input found":"Search input not visible",details:"Search should be available when menu is open"});const C=document.querySelectorAll("[data-category], .category-button");c(S,{name:"Category Filters",status:C.length>0?"pass":"warning",message:C.length>0?"Category filters found":"Category filters not visible",details:"Should have Basic, Headings, Lists, Media, Advanced categories"})}catch(v){c(S,{name:"Enhanced Floating Menu Test",status:"fail",message:"Test failed with error",details:v instanceof Error?v.message:"Unknown error"})}},p=async()=>{const S="Advanced Placeholders";l(S);try{const v=Array.from(document.styleSheets).some(N=>{try{return Array.from(N.cssRules).some(D=>D.cssText.includes("is-empty")||D.cssText.includes("placeholder"))}catch{return!1}});c(S,{name:"Placeholder CSS",status:v?"pass":"warning",message:v?"Placeholder CSS loaded":"Placeholder CSS may not be loaded",details:"Check if advanced-features.css is properly imported"});const A=document.querySelectorAll(".is-empty, .is-editor-empty");c(S,{name:"Empty Node Detection",status:A.length>=0?"pass":"warning",message:`Found ${A.length} empty nodes`,details:"Empty nodes should have placeholder classes"}),e("<p></p>"),await u(100);const C=document.querySelectorAll("[data-placeholder]");c(S,{name:"Placeholder Content",status:C.length>0?"pass":"warning",message:C.length>0?"Placeholder content found":"No placeholder content detected",details:"Should show contextual placeholders for different node types"})}catch(v){c(S,{name:"Advanced Placeholders Test",status:"fail",message:"Test failed with error",details:v instanceof Error?v.message:"Unknown error"})}},m=async()=>{const S="Focus Management";l(S);try{const v=document.querySelectorAll(".has-focus, .editor-focused");c(S,{name:"Focus Classes",status:v.length>=0?"pass":"warning",message:`Found ${v.length} focus elements`,details:"Focus classes should be applied to active elements"});const A=document.querySelectorAll(".focus-ring");c(S,{name:"Focus Ring",status:A.length>=0?"pass":"warning",message:`Found ${A.length} focus rings`,details:"Focus rings provide visual feedback"}),c(S,{name:"Selection Highlighting",status:"pass",message:"Selection highlighting system available",details:"Enhanced selection visibility should work"})}catch(v){c(S,{name:"Focus Management Test",status:"fail",message:"Test failed with error",details:v instanceof Error?v.message:"Unknown error"})}},y=async()=>{const S="Mobile Experience";l(S);try{const v=document.querySelectorAll('.mobile-toolbar, [class*="mobile"]');c(S,{name:"Mobile Toolbar",status:v.length>0?"pass":"warning",message:v.length>0?"Mobile toolbar found":"Mobile toolbar not detected",details:"Should appear on mobile devices or small screens"});const A=Array.from(document.styleSheets).some(N=>{try{return Array.from(N.cssRules).some(D=>D.cssText.includes("@media")&&D.cssText.includes("768px"))}catch{return!1}});c(S,{name:"Responsive CSS",status:A?"pass":"warning",message:A?"Responsive CSS found":"Responsive CSS may not be loaded",details:"Should have mobile breakpoints"});const C=document.querySelectorAll('[class*="touch"], .toolbar-item');c(S,{name:"Touch-Friendly Elements",status:C.length>0?"pass":"warning",message:C.length>0?"Touch-friendly elements found":"No touch-friendly elements detected",details:"Should have larger touch targets for mobile"})}catch(v){c(S,{name:"Mobile Experience Test",status:"fail",message:"Test failed with error",details:v instanceof Error?v.message:"Unknown error"})}},b=async()=>{const S="Keyboard Shortcuts";l(S);try{c(S,{name:"Keyboard Shortcuts Available",status:"pass",message:`${["Ctrl+B","Ctrl+I","Ctrl+U","Ctrl+Shift+X","Ctrl+Shift+H","Ctrl+Alt+1","Ctrl+Alt+2","Ctrl+Alt+3","Ctrl+K","Ctrl+\\"].length} keyboard shortcuts configured`,details:"Text formatting, headings, lists, and advanced shortcuts"});const A=document.querySelectorAll('[title*="Ctrl"], [title*="Cmd"]');c(S,{name:"Shortcut Hints",status:A.length>0?"pass":"warning",message:A.length>0?"Shortcut hints found":"No shortcut hints detected",details:"Tooltips should show keyboard shortcuts"}),c(S,{name:"Conflict Prevention",status:"pass",message:"Keyboard shortcuts use standard patterns",details:"Should not conflict with browser shortcuts"})}catch(v){c(S,{name:"Keyboard Shortcuts Test",status:"fail",message:"Test failed with error",details:v instanceof Error?v.message:"Unknown error"})}},x=async()=>{i(!0),r([a("Drag and Drop"),a("Undo/Redo System"),a("Enhanced Floating Menu"),a("Advanced Placeholders"),a("Focus Management"),a("Mobile Experience"),a("Keyboard Shortcuts")]);try{await d(),await u(500),await h(),await u(500),await f(),await u(500),await p(),await u(500),await m(),await u(500),await y(),await u(500),await b()}catch(S){console.error("Test suite failed:",S)}finally{i(!1),l("")}},w=()=>{r([]),e("<p>Start testing...</p>"),l("")},k=S=>{switch(S){case"pass":return g.jsx(W$,{className:"h-4 w-4 text-green-500"});case"fail":return g.jsx(G$,{className:"h-4 w-4 text-red-500"});case"warning":return g.jsx(Gy,{className:"h-4 w-4 text-yellow-500"});default:return g.jsx(Gy,{className:"h-4 w-4 text-gray-400"})}},T=S=>{const v={pass:"bg-green-100 text-green-800",fail:"bg-red-100 text-red-800",warning:"bg-yellow-100 text-yellow-800",pending:"bg-gray-100 text-gray-800"};return g.jsx(fS.Badge,{className:v[S]||v.pending,children:S.toUpperCase()})};return g.jsxs("div",{className:"max-w-6xl mx-auto p-6 space-y-6",children:[g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx("h1",{className:"text-3xl font-bold",children:"Tiptap v3 Feature Validation"}),g.jsxs("div",{className:"flex gap-2",children:[g.jsxs(ae.Button,{onClick:w,variant:"outline",disabled:s,children:[g.jsx(BB,{className:"h-4 w-4 mr-2"}),"Reset"]}),g.jsxs(ae.Button,{onClick:x,disabled:s,children:[g.jsx(DB,{className:"h-4 w-4 mr-2"}),s?"Running Tests...":"Run All Tests"]})]})]}),s&&o&&g.jsx(ht.Card,{children:g.jsx(ht.CardContent,{className:"pt-6",children:g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-primary"}),g.jsxs("span",{children:["Running: ",o]})]})})}),g.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[g.jsxs("div",{className:"space-y-4",children:[g.jsx("h2",{className:"text-xl font-semibold",children:"Test Results"}),n.map(S=>g.jsxs(ht.Card,{children:[g.jsx(ht.CardHeader,{className:"pb-3",children:g.jsxs("div",{className:"flex items-center justify-between",children:[g.jsx(ht.CardTitle,{className:"text-lg",children:S.name}),T(S.status)]})}),g.jsxs(ht.CardContent,{className:"space-y-2",children:[S.tests.map((v,A)=>g.jsxs("div",{className:"flex items-start gap-2 p-2 rounded border",children:[k(v.status),g.jsxs("div",{className:"flex-1 min-w-0",children:[g.jsx("div",{className:"font-medium text-sm",children:v.name}),g.jsx("div",{className:"text-xs text-muted-foreground",children:v.message}),v.details&&g.jsx("div",{className:"text-xs text-muted-foreground mt-1 opacity-75",children:v.details})]})]},A)),S.tests.length===0&&S.status==="pending"&&g.jsx("div",{className:"text-sm text-muted-foreground",children:"No tests run yet"})]})]},S.name))]}),g.jsxs("div",{className:"space-y-4",children:[g.jsx("h2",{className:"text-xl font-semibold",children:"Live Editor Test"}),g.jsx(ht.Card,{children:g.jsx(ht.CardContent,{className:"pt-6",children:g.jsx(iu,{content:t,onChange:e,useEnhancedFloatingMenu:!0,showMobileToolbar:!0,enableAdvancedPlaceholders:!0,enableFocusMode:!1,showKeyboardShortcuts:!0,className:"min-h-[400px]"})})}),g.jsxs(ht.Card,{children:[g.jsx(ht.CardHeader,{children:g.jsx(ht.CardTitle,{className:"text-lg",children:"Test Instructions"})}),g.jsxs(ht.CardContent,{className:"text-sm space-y-2",children:[g.jsx("p",{children:"• Try typing in the editor to test placeholders"}),g.jsx("p",{children:"• Create empty paragraphs to test floating menu"}),g.jsx("p",{children:"• Use keyboard shortcuts (Ctrl+B, Ctrl+I, etc.)"}),g.jsx("p",{children:"• Test undo/redo with Ctrl+Z/Ctrl+Y"}),g.jsx("p",{children:"• Hover over elements to see drag handles"}),g.jsx("p",{children:"• Resize window to test mobile toolbar"})]})]})]})]})]})},WH=()=>{const[t,e]=E.useState(`
160
178
  <h1>Undo/Redo Test Document</h1>
161
179
  <p>This document tests the enhanced undo/redo functionality with various content types.</p>
162
180
 
@@ -195,7 +213,7 @@ ${s}`):!1},t["Mod-Shift-k"]=()=>{const{selection:e}=this.editor.state,{$from:n,$
195
213
  </table>
196
214
 
197
215
  <p>Try editing any content above and use the undo/redo buttons or keyboard shortcuts!</p>
198
- `),[n]=C.useState(null),r=Rh(n),s=[{name:"Add Bold Text",action:()=>{n&&n.chain().focus().insertContent("<p><strong>Bold text added!</strong></p>").run()}},{name:"Add Heading",action:()=>{n&&n.chain().focus().insertContent("<h3>New Heading Added</h3>").run()}},{name:"Add List Item",action:()=>{n&&n.chain().focus().insertContent("<ul><li>New list item</li></ul>").run()}},{name:"Add Table",action:()=>{n&&n.chain().focus().insertTable({rows:2,cols:2,withHeaderRow:!0}).run()}},{name:"Clear All Content",action:()=>{n&&n.chain().focus().clearContent().run()}}];return m.jsx("div",{className:"max-w-4xl mx-auto p-6 space-y-6",children:m.jsxs(at.Card,{children:[m.jsx(at.CardHeader,{children:m.jsx(at.CardTitle,{children:"Enhanced Undo/Redo Test"})}),m.jsxs(at.CardContent,{className:"space-y-4",children:[m.jsxs("div",{className:"flex items-center gap-4 p-4 bg-muted rounded-lg",children:[m.jsx("div",{className:"text-sm",children:m.jsx("strong",{children:"History State:"})}),m.jsxs("div",{className:"text-sm",children:["Can Undo: ",m.jsx("span",{className:r.canUndo?"text-green-600":"text-red-600",children:r.canUndo?"Yes":"No"})]}),m.jsxs("div",{className:"text-sm",children:["Can Redo: ",m.jsx("span",{className:r.canRedo?"text-green-600":"text-red-600",children:r.canRedo?"Yes":"No"})]}),m.jsxs("div",{className:"text-sm",children:["History Empty: ",m.jsx("span",{className:r.isHistoryEmpty?"text-orange-600":"text-blue-600",children:r.isHistoryEmpty?"Yes":"No"})]})]}),m.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg",children:[m.jsx("div",{className:"text-sm font-medium",children:"Enhanced Controls:"}),m.jsx(Oh,{editor:n,size:"md",showLabels:!0,className:"border rounded p-2"}),m.jsx("div",{className:"text-xs text-muted-foreground",children:"Keyboard: Ctrl+Z (Undo), Ctrl+Y (Redo)"})]}),m.jsxs("div",{className:"space-y-2",children:[m.jsx("div",{className:"text-sm font-medium",children:"Test Actions:"}),m.jsx("div",{className:"flex flex-wrap gap-2",children:s.map((i,o)=>m.jsx(le.Button,{variant:"outline",size:"sm",onClick:i.action,disabled:!n,children:i.name},o))})]}),m.jsx("div",{className:"border rounded-lg",children:m.jsx(Pa,{content:t,onChange:e,showToolbar:!0,showCharacterCount:!0,onFocus:()=>console.log("Editor focused"),onBlur:()=>console.log("Editor blurred")})}),m.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[m.jsx("p",{children:m.jsx("strong",{children:"Test Instructions:"})}),m.jsxs("ul",{className:"list-disc list-inside space-y-1",children:[m.jsx("li",{children:"Use the test actions above to add content"}),m.jsx("li",{children:"Try editing text directly in the editor"}),m.jsx("li",{children:"Use Ctrl+Z to undo changes"}),m.jsx("li",{children:"Use Ctrl+Y to redo changes"}),m.jsx("li",{children:"Try dragging content around (if drag handles are visible)"}),m.jsx("li",{children:"Watch the history state indicators update in real-time"}),m.jsx("li",{children:"Test with different content types: text, headings, lists, tables, etc."})]})]})]})]})})},Tj=()=>{const[t,e]=C.useState(`
216
+ `),[n]=E.useState(null),r=Cp(n),s=[{name:"Add Bold Text",action:()=>{n&&n.chain().focus().insertContent("<p><strong>Bold text added!</strong></p>").run()}},{name:"Add Heading",action:()=>{n&&n.chain().focus().insertContent("<h3>New Heading Added</h3>").run()}},{name:"Add List Item",action:()=>{n&&n.chain().focus().insertContent("<ul><li>New list item</li></ul>").run()}},{name:"Add Table",action:()=>{n&&n.chain().focus().insertTable({rows:2,cols:2,withHeaderRow:!0}).run()}},{name:"Clear All Content",action:()=>{n&&n.chain().focus().clearContent().run()}}];return g.jsx("div",{className:"max-w-4xl mx-auto p-6 space-y-6",children:g.jsxs(ht.Card,{children:[g.jsx(ht.CardHeader,{children:g.jsx(ht.CardTitle,{children:"Enhanced Undo/Redo Test"})}),g.jsxs(ht.CardContent,{className:"space-y-4",children:[g.jsxs("div",{className:"flex items-center gap-4 p-4 bg-muted rounded-lg",children:[g.jsx("div",{className:"text-sm",children:g.jsx("strong",{children:"History State:"})}),g.jsxs("div",{className:"text-sm",children:["Can Undo: ",g.jsx("span",{className:r.canUndo?"text-green-600":"text-red-600",children:r.canUndo?"Yes":"No"})]}),g.jsxs("div",{className:"text-sm",children:["Can Redo: ",g.jsx("span",{className:r.canRedo?"text-green-600":"text-red-600",children:r.canRedo?"Yes":"No"})]}),g.jsxs("div",{className:"text-sm",children:["History Empty: ",g.jsx("span",{className:r.isHistoryEmpty?"text-orange-600":"text-blue-600",children:r.isHistoryEmpty?"Yes":"No"})]})]}),g.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg",children:[g.jsx("div",{className:"text-sm font-medium",children:"Enhanced Controls:"}),g.jsx(Ep,{editor:n,size:"md",showLabels:!0,className:"border rounded p-2"}),g.jsx("div",{className:"text-xs text-muted-foreground",children:"Keyboard: Ctrl+Z (Undo), Ctrl+Y (Redo)"})]}),g.jsxs("div",{className:"space-y-2",children:[g.jsx("div",{className:"text-sm font-medium",children:"Test Actions:"}),g.jsx("div",{className:"flex flex-wrap gap-2",children:s.map((i,o)=>g.jsx(ae.Button,{variant:"outline",size:"sm",onClick:i.action,disabled:!n,children:i.name},o))})]}),g.jsx("div",{className:"border rounded-lg",children:g.jsx(iu,{content:t,onChange:e,showToolbar:!0,showCharacterCount:!0,onFocus:()=>console.log("Editor focused"),onBlur:()=>console.log("Editor blurred")})}),g.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[g.jsx("p",{children:g.jsx("strong",{children:"Test Instructions:"})}),g.jsxs("ul",{className:"list-disc list-inside space-y-1",children:[g.jsx("li",{children:"Use the test actions above to add content"}),g.jsx("li",{children:"Try editing text directly in the editor"}),g.jsx("li",{children:"Use Ctrl+Z to undo changes"}),g.jsx("li",{children:"Use Ctrl+Y to redo changes"}),g.jsx("li",{children:"Try dragging content around (if drag handles are visible)"}),g.jsx("li",{children:"Watch the history state indicators update in real-time"}),g.jsx("li",{children:"Test with different content types: text, headings, lists, tables, etc."})]})]})]})]})})},qH=()=>{const[t,e]=E.useState(`
199
217
  <h1>Enhanced NotionEditor Test</h1>
200
218
  <p>This is a test of the enhanced NotionEditor with undo/redo buttons and improved drag handles.</p>
201
219
  <h2>Drag Handle UX Improvements:</h2>
@@ -216,4 +234,4 @@ ${s}`):!1},t["Mod-Shift-k"]=()=>{const{selection:e}=this.editor.state,{$from:n,$
216
234
  <li>Second item - drag handle should be centered vertically</li>
217
235
  </ol>
218
236
  <p>Try typing some text and then using the undo/redo buttons in the toolbar.</p>
219
- `);return m.jsxs("div",{className:"p-6 max-w-4xl mx-auto",children:[m.jsx("h1",{className:"text-2xl font-bold mb-4",children:"NotionEditor Enhanced Features Test"}),m.jsxs("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg",children:[m.jsx("h3",{className:"font-semibold text-blue-800 mb-2",children:"Drag Handle UX Test Instructions:"}),m.jsxs("ol",{className:"list-decimal list-inside text-blue-700 space-y-1",children:[m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"target",children:"🎯"})," ",m.jsx("strong",{children:"Expanded Hover Area:"})," Hover anywhere on a content block (not just the handle area) - drag handle should appear"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"pushpin",children:"📍"})," ",m.jsx("strong",{children:"Proper Centering:"})," Verify drag handles are vertically centered within each content section"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"refresh arrows",children:"🔄"})," ",m.jsx("strong",{children:"Content Types:"})," Test on paragraphs, headings, lists, and blockquotes"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"mobile phone",children:"📱"})," ",m.jsx("strong",{children:"Mobile Responsive:"})," Check that drag handles work properly on smaller screens"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"sparkles",children:"✨"})," ",m.jsx("strong",{children:"Visual Feedback:"})," Notice smooth transitions and enhanced styling"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"computer mouse",children:"🖱️"})," ",m.jsx("strong",{children:"Drag Functionality:"})," Try dragging blocks to reorder them"]})]})]}),m.jsx("div",{className:"border border-gray-200 rounded-lg",children:m.jsx(xw,{content:t,onChange:e,showToolbar:!0,showCharacterCount:!0,className:"min-h-[600px]"})}),m.jsxs("div",{className:"mt-4 p-4 bg-gray-50 border border-gray-200 rounded-lg",children:[m.jsx("h3",{className:"font-semibold mb-2",children:"Current Content (JSON):"}),m.jsx("pre",{className:"text-xs bg-white p-2 rounded border overflow-auto max-h-32",children:JSON.stringify(t,null,2)})]})]})};exports.AdvancedPlaceholder=Wx;exports.AlertWidget=qx;exports.CtaWidgetNode=Kx;exports.DragHandle=wj;exports.DraggableNodes=rw;exports.Editor=Pa;exports.EditorBubbleMenu=Nh;exports.EditorFloatingMenu=_h;exports.EditorToolbar=Dh;exports.EnhancedFloatingMenu=mw;exports.EnhancedFocus=Cj;exports.FeatureValidationTest=Mj;exports.HtmlContent=Sj;exports.KeyboardShortcuts=Ej;exports.MobileToolbar=bw;exports.NotionEditor=xw;exports.NotionEditorEnhancedTest=Tj;exports.SlashCommand=nw;exports.SlashCommandList=Eh;exports.Toolbar=ww;exports.ToolbarButton=vw;exports.ToolbarGroup=kw;exports.ToolbarSeparator=Sw;exports.TrailingNode=Vx;exports.UndoRedoButtons=Oh;exports.UndoRedoTest=Aj;exports.canExecuteHistoryAction=yw;exports.default=Pa;exports.editorExtensions=Mh;exports.executeHistoryAction=uj;exports.getHistoryShortcut=eu;exports.useEditorHistory=Rh;
237
+ `);return g.jsxs("div",{className:"p-6 max-w-4xl mx-auto",children:[g.jsx("h1",{className:"text-2xl font-bold mb-4",children:"NotionEditor Enhanced Features Test"}),g.jsxs("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg",children:[g.jsx("h3",{className:"font-semibold text-blue-800 mb-2",children:"Drag Handle UX Test Instructions:"}),g.jsxs("ol",{className:"list-decimal list-inside text-blue-700 space-y-1",children:[g.jsxs("li",{children:[g.jsx("span",{role:"img","aria-label":"target",children:"🎯"})," ",g.jsx("strong",{children:"Expanded Hover Area:"})," Hover anywhere on a content block (not just the handle area) - drag handle should appear"]}),g.jsxs("li",{children:[g.jsx("span",{role:"img","aria-label":"pushpin",children:"📍"})," ",g.jsx("strong",{children:"Proper Centering:"})," Verify drag handles are vertically centered within each content section"]}),g.jsxs("li",{children:[g.jsx("span",{role:"img","aria-label":"refresh arrows",children:"🔄"})," ",g.jsx("strong",{children:"Content Types:"})," Test on paragraphs, headings, lists, and blockquotes"]}),g.jsxs("li",{children:[g.jsx("span",{role:"img","aria-label":"mobile phone",children:"📱"})," ",g.jsx("strong",{children:"Mobile Responsive:"})," Check that drag handles work properly on smaller screens"]}),g.jsxs("li",{children:[g.jsx("span",{role:"img","aria-label":"sparkles",children:"✨"})," ",g.jsx("strong",{children:"Visual Feedback:"})," Notice smooth transitions and enhanced styling"]}),g.jsxs("li",{children:[g.jsx("span",{role:"img","aria-label":"computer mouse",children:"🖱️"})," ",g.jsx("strong",{children:"Drag Functionality:"})," Try dragging blocks to reorder them"]})]})]}),g.jsx("div",{className:"border border-gray-200 rounded-lg",children:g.jsx(Av,{content:t,onChange:e,showToolbar:!0,showCharacterCount:!0,className:"min-h-[600px]"})}),g.jsxs("div",{className:"mt-4 p-4 bg-gray-50 border border-gray-200 rounded-lg",children:[g.jsx("h3",{className:"font-semibold mb-2",children:"Current Content (JSON):"}),g.jsx("pre",{className:"text-xs bg-white p-2 rounded border overflow-auto max-h-32",children:JSON.stringify(t,null,2)})]})]})};exports.AdvancedPlaceholder=Zk;exports.AlertWidget=Qk;exports.CtaWidgetNode=ev;exports.DragHandle=jH;exports.DraggableNodes=uv;exports.Editor=iu;exports.EditorBubbleMenu=vp;exports.EditorFloatingMenu=Sp;exports.EditorToolbar=Ap;exports.EnhancedFloatingMenu=vv;exports.EnhancedFocus=FH;exports.FeatureValidationTest=VH;exports.HtmlContent=zH;exports.KeyboardShortcuts=UH;exports.MobileToolbar=Ev;exports.NotionEditor=Av;exports.NotionEditorEnhancedTest=qH;exports.SlashCommand=cv;exports.SlashCommandList=xp;exports.Toolbar=Mv;exports.ToolbarButton=Nv;exports.ToolbarGroup=Tv;exports.ToolbarSeparator=Rv;exports.TrailingNode=HH;exports.UndoRedoButtons=Ep;exports.UndoRedoTest=WH;exports.canExecuteHistoryAction=Cv;exports.default=iu;exports.editorExtensions=uc;exports.executeHistoryAction=TH;exports.getHistoryShortcut=jh;exports.useEditorHistory=Cp;