@fileverse-dev/ddoc 1.2.3 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +21 -23
- package/dist/index.es.js +2742 -2806
- package/dist/index.umd.js +86 -101
- package/dist/packages/ddoc/ddoc-editor.d.ts +1 -1
- package/dist/packages/ddoc/types.d.ts +5 -2
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
(function($t,
|
1
|
+
(function($t,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],O):($t=typeof globalThis<"u"?globalThis:$t||self,O($t.ddoc={},$t.React,$t.ReactDOM))})(this,function($t,O,nn){"use strict";var KP=Object.defineProperty;var JP=($t,O,nn)=>O in $t?KP($t,O,{enumerable:!0,configurable:!0,writable:!0,value:nn}):$t[O]=nn;var vr=($t,O,nn)=>(JP($t,typeof O!="symbol"?O+"":O,nn),nn);function Fh(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 le=Fh(O),m1=Fh(nn);var _n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Pc(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Fc={exports:{}},Hs={};/**
|
2
2
|
* @license React
|
3
3
|
* react-jsx-runtime.production.min.js
|
4
4
|
*
|
@@ -6,7 +6,7 @@
|
|
6
6
|
*
|
7
7
|
* This source code is licensed under the MIT license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
|
-
*/var
|
9
|
+
*/var $h;function g1(){if($h)return Hs;$h=1;var t=O,e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function o(l,a,c){var u,d={},f=null,h=null;c!==void 0&&(f=""+c),a.key!==void 0&&(f=""+a.key),a.ref!==void 0&&(h=a.ref);for(u in a)r.call(a,u)&&!s.hasOwnProperty(u)&&(d[u]=a[u]);if(l&&l.defaultProps)for(u in a=l.defaultProps,a)d[u]===void 0&&(d[u]=a[u]);return{$$typeof:e,type:l,key:f,ref:h,props:d,_owner:i.current}}return Hs.Fragment=n,Hs.jsx=o,Hs.jsxs=o,Hs}var zs={};/**
|
10
10
|
* @license React
|
11
11
|
* react-jsx-runtime.development.js
|
12
12
|
*
|
@@ -14,32 +14,32 @@
|
|
14
14
|
*
|
15
15
|
* This source code is licensed under the MIT license found in the
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
17
|
-
*/var
|
17
|
+
*/var Bh;function y1(){return Bh||(Bh=1,process.env.NODE_ENV!=="production"&&function(){var t=O,e=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),h=Symbol.for("react.offscreen"),p=Symbol.iterator,g="@@iterator";function v(L){if(L===null||typeof L!="object")return null;var K=p&&L[p]||L[g];return typeof K=="function"?K:null}var w=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function S(L){{for(var K=arguments.length,Q=new Array(K>1?K-1:0),fe=1;fe<K;fe++)Q[fe-1]=arguments[fe];x("error",L,Q)}}function x(L,K,Q){{var fe=w.ReactDebugCurrentFrame,Re=fe.getStackAddendum();Re!==""&&(K+="%s",Q=Q.concat([Re]));var Be=Q.map(function(Oe){return String(Oe)});Be.unshift("Warning: "+K),Function.prototype.apply.call(console[L],console,Be)}}var y=!1,C=!1,E=!1,T=!1,D=!1,N;N=Symbol.for("react.module.reference");function A(L){return!!(typeof L=="string"||typeof L=="function"||L===r||L===s||D||L===i||L===c||L===u||T||L===h||y||C||E||typeof L=="object"&&L!==null&&(L.$$typeof===f||L.$$typeof===d||L.$$typeof===o||L.$$typeof===l||L.$$typeof===a||L.$$typeof===N||L.getModuleId!==void 0))}function R(L,K,Q){var fe=L.displayName;if(fe)return fe;var Re=K.displayName||K.name||"";return Re!==""?Q+"("+Re+")":Q}function P(L){return L.displayName||"Context"}function B(L){if(L==null)return null;if(typeof L.tag=="number"&&S("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof L=="function")return L.displayName||L.name||null;if(typeof L=="string")return L;switch(L){case r:return"Fragment";case n:return"Portal";case s:return"Profiler";case i:return"StrictMode";case c:return"Suspense";case u:return"SuspenseList"}if(typeof L=="object")switch(L.$$typeof){case l:var K=L;return P(K)+".Consumer";case o:var Q=L;return P(Q._context)+".Provider";case a:return R(L,L.render,"ForwardRef");case d:var fe=L.displayName||null;return fe!==null?fe:B(L.type)||"Memo";case f:{var Re=L,Be=Re._payload,Oe=Re._init;try{return B(Oe(Be))}catch{return null}}}return null}var z=Object.assign,U=0,J,G,ie,Z,ke,Le,$e;function Ee(){}Ee.__reactDisabledLog=!0;function ve(){{if(U===0){J=console.log,G=console.info,ie=console.warn,Z=console.error,ke=console.group,Le=console.groupCollapsed,$e=console.groupEnd;var L={configurable:!0,enumerable:!0,value:Ee,writable:!0};Object.defineProperties(console,{info:L,log:L,warn:L,error:L,group:L,groupCollapsed:L,groupEnd:L})}U++}}function De(){{if(U--,U===0){var L={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:z({},L,{value:J}),info:z({},L,{value:G}),warn:z({},L,{value:ie}),error:z({},L,{value:Z}),group:z({},L,{value:ke}),groupCollapsed:z({},L,{value:Le}),groupEnd:z({},L,{value:$e})})}U<0&&S("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Ie=w.ReactCurrentDispatcher,tt;function nt(L,K,Q){{if(tt===void 0)try{throw Error()}catch(Re){var fe=Re.stack.trim().match(/\n( *(at )?)/);tt=fe&&fe[1]||""}return`
|
18
18
|
`+tt+L}}var Ge=!1,Ye;{var Ot=typeof WeakMap=="function"?WeakMap:Map;Ye=new Ot}function xt(L,K){if(!L||Ge)return"";{var Q=Ye.get(L);if(Q!==void 0)return Q}var fe;Ge=!0;var Re=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Be;Be=Ie.current,Ie.current=null,ve();try{if(K){var Oe=function(){throw Error()};if(Object.defineProperty(Oe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Oe,[])}catch(qt){fe=qt}Reflect.construct(L,[],Oe)}else{try{Oe.call()}catch(qt){fe=qt}L.call(Oe.prototype)}}else{try{throw Error()}catch(qt){fe=qt}L()}}catch(qt){if(qt&&fe&&typeof qt.stack=="string"){for(var Te=qt.stack.split(`
|
19
19
|
`),Ft=fe.stack.split(`
|
20
20
|
`),st=Te.length-1,ct=Ft.length-1;st>=1&&ct>=0&&Te[st]!==Ft[ct];)ct--;for(;st>=1&&ct>=0;st--,ct--)if(Te[st]!==Ft[ct]){if(st!==1||ct!==1)do if(st--,ct--,ct<0||Te[st]!==Ft[ct]){var gn=`
|
21
21
|
`+Te[st].replace(" at new "," at ");return L.displayName&&gn.includes("<anonymous>")&&(gn=gn.replace("<anonymous>",L.displayName)),typeof L=="function"&&Ye.set(L,gn),gn}while(st>=1&&ct>=0);break}}}finally{Ge=!1,Ie.current=Be,De(),Error.prepareStackTrace=Re}var js=L?L.displayName||L.name:"",Ri=js?nt(js):"";return typeof L=="function"&&Ye.set(L,Ri),Ri}function it(L,K,Q){return xt(L,!1)}function at(L){var K=L.prototype;return!!(K&&K.isReactComponent)}function $(L,K,Q){if(L==null)return"";if(typeof L=="function")return xt(L,at(L));if(typeof L=="string")return nt(L);switch(L){case c:return nt("Suspense");case u:return nt("SuspenseList")}if(typeof L=="object")switch(L.$$typeof){case a:return it(L.render);case d:return $(L.type,K,Q);case f:{var fe=L,Re=fe._payload,Be=fe._init;try{return $(Be(Re),K,Q)}catch{}}}return""}var j=Object.prototype.hasOwnProperty,q={},te=w.ReactDebugCurrentFrame;function M(L){if(L){var K=L._owner,Q=$(L.type,L._source,K?K.type:null);te.setExtraStackFrame(Q)}else te.setExtraStackFrame(null)}function m(L,K,Q,fe,Re){{var Be=Function.call.bind(j);for(var Oe in L)if(Be(L,Oe)){var Te=void 0;try{if(typeof L[Oe]!="function"){var Ft=Error((fe||"React class")+": "+Q+" type `"+Oe+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof L[Oe]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ft.name="Invariant Violation",Ft}Te=L[Oe](K,Oe,fe,Q,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(st){Te=st}Te&&!(Te instanceof Error)&&(M(Re),S("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",fe||"React class",Q,Oe,typeof Te),M(null)),Te instanceof Error&&!(Te.message in q)&&(q[Te.message]=!0,M(Re),S("Failed %s type: %s",Q,Te.message),M(null))}}}var b=Array.isArray;function k(L){return b(L)}function I(L){{var K=typeof Symbol=="function"&&Symbol.toStringTag,Q=K&&L[Symbol.toStringTag]||L.constructor.name||"Object";return Q}}function F(L){try{return H(L),!1}catch{return!0}}function H(L){return""+L}function ne(L){if(F(L))return S("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",I(L)),H(L)}var de=w.ReactCurrentOwner,_e={key:!0,ref:!0,__self:!0,__source:!0},we,ye,Xe;Xe={};function Mn(L){if(j.call(L,"ref")){var K=Object.getOwnPropertyDescriptor(L,"ref").get;if(K&&K.isReactWarning)return!1}return L.ref!==void 0}function Qn(L){if(j.call(L,"key")){var K=Object.getOwnPropertyDescriptor(L,"key").get;if(K&&K.isReactWarning)return!1}return L.key!==void 0}function V(L,K){if(typeof L.ref=="string"&&de.current&&K&&de.current.stateNode!==K){var Q=B(de.current.type);Xe[Q]||(S('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',B(de.current.type),L.ref),Xe[Q]=!0)}}function ee(L,K){{var Q=function(){we||(we=!0,S("%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://reactjs.org/link/special-props)",K))};Q.isReactWarning=!0,Object.defineProperty(L,"key",{get:Q,configurable:!0})}}function oe(L,K){{var Q=function(){ye||(ye=!0,S("%s: `ref` 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://reactjs.org/link/special-props)",K))};Q.isReactWarning=!0,Object.defineProperty(L,"ref",{get:Q,configurable:!0})}}var Ne=function(L,K,Q,fe,Re,Be,Oe){var Te={$$typeof:e,type:L,key:K,ref:Q,props:Oe,_owner:Be};return Te._store={},Object.defineProperty(Te._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Te,"_self",{configurable:!1,enumerable:!1,writable:!1,value:fe}),Object.defineProperty(Te,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Re}),Object.freeze&&(Object.freeze(Te.props),Object.freeze(Te)),Te};function Me(L,K,Q,fe,Re){{var Be,Oe={},Te=null,Ft=null;Q!==void 0&&(ne(Q),Te=""+Q),Qn(K)&&(ne(K.key),Te=""+K.key),Mn(K)&&(Ft=K.ref,V(K,Re));for(Be in K)j.call(K,Be)&&!_e.hasOwnProperty(Be)&&(Oe[Be]=K[Be]);if(L&&L.defaultProps){var st=L.defaultProps;for(Be in st)Oe[Be]===void 0&&(Oe[Be]=st[Be])}if(Te||Ft){var ct=typeof L=="function"?L.displayName||L.name||"Unknown":L;Te&&ee(Oe,ct),Ft&&oe(Oe,ct)}return Ne(L,Te,Ft,Re,fe,de.current,Oe)}}var ft=w.ReactCurrentOwner,Pt=w.ReactDebugCurrentFrame;function tn(L){if(L){var K=L._owner,Q=$(L.type,L._source,K?K.type:null);Pt.setExtraStackFrame(Q)}else Pt.setExtraStackFrame(null)}var Ps;Ps=!1;function On(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function Fs(){{if(ft.current){var L=B(ft.current.type);if(L)return`
|
22
22
|
|
23
|
-
Check the render method of \``+L+"`."}return""}}function $s(L){return""}var br={};function
|
23
|
+
Check the render method of \``+L+"`."}return""}}function $s(L){return""}var br={};function _h(L){{var K=Fs();if(!K){var Q=typeof L=="string"?L:L.displayName||L.name;Q&&(K=`
|
24
24
|
|
25
|
-
Check the top-level render call using <`+Q+">.")}return K}}function Bs(L,K){{if(!L._store||L._store.validated||L.key!=null)return;L._store.validated=!0;var Q=
|
25
|
+
Check the top-level render call using <`+Q+">.")}return K}}function Bs(L,K){{if(!L._store||L._store.validated||L.key!=null)return;L._store.validated=!0;var Q=_h(K);if(br[Q])return;br[Q]=!0;var fe="";L&&L._owner&&L._owner!==ft.current&&(fe=" It was passed a child from "+B(L._owner.type)+"."),tn(L),S('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',Q,fe),tn(null)}}function Di(L,K){{if(typeof L!="object")return;if(k(L))for(var Q=0;Q<L.length;Q++){var fe=L[Q];On(fe)&&Bs(fe,K)}else if(On(L))L._store&&(L._store.validated=!0);else if(L){var Re=v(L);if(typeof Re=="function"&&Re!==L.entries)for(var Be=Re.call(L),Oe;!(Oe=Be.next()).done;)On(Oe.value)&&Bs(Oe.value,K)}}}function BP(L){{var K=L.type;if(K==null||typeof K=="string")return;var Q;if(typeof K=="function")Q=K.propTypes;else if(typeof K=="object"&&(K.$$typeof===a||K.$$typeof===d))Q=K.propTypes;else return;if(Q){var fe=B(K);m(Q,L.props,"prop",fe,L)}else if(K.PropTypes!==void 0&&!Ps){Ps=!0;var Re=B(K);S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Re||"Unknown")}typeof K.getDefaultProps=="function"&&!K.getDefaultProps.isReactClassApproved&&S("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function jP(L){{for(var K=Object.keys(L.props),Q=0;Q<K.length;Q++){var fe=K[Q];if(fe!=="children"&&fe!=="key"){tn(L),S("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",fe),tn(null);break}}L.ref!==null&&(tn(L),S("Invalid attribute `ref` supplied to `React.Fragment`."),tn(null))}}var f1={};function h1(L,K,Q,fe,Re,Be){{var Oe=A(L);if(!Oe){var Te="";(L===void 0||typeof L=="object"&&L!==null&&Object.keys(L).length===0)&&(Te+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Ft=$s();Ft?Te+=Ft:Te+=Fs();var st;L===null?st="null":k(L)?st="array":L!==void 0&&L.$$typeof===e?(st="<"+(B(L.type)||"Unknown")+" />",Te=" Did you accidentally export a JSX literal instead of a component?"):st=typeof L,S("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",st,Te)}var ct=Me(L,K,Q,Re,Be);if(ct==null)return ct;if(Oe){var gn=K.children;if(gn!==void 0)if(fe)if(k(gn)){for(var js=0;js<gn.length;js++)Di(gn[js],L);Object.freeze&&Object.freeze(gn)}else S("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 Di(gn,L)}if(j.call(K,"key")){var Ri=B(L),qt=Object.keys(K).filter(function(qP){return qP!=="key"}),Nh=qt.length>0?"{key: someKey, "+qt.join(": ..., ")+": ...}":"{key: someKey}";if(!f1[Ri+Nh]){var WP=qt.length>0?"{"+qt.join(": ..., ")+": ...}":"{}";S(`A props object containing a "key" prop is being spread into JSX:
|
26
26
|
let props = %s;
|
27
27
|
<%s {...props} />
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
29
29
|
let props = %s;
|
30
|
-
<%s key={someKey} {...props} />`,Dh,Ri,JP,Ri),f1[Ri+Dh]=!0}}return L===r?VP(ct):zP(ct),ct}}function UP(L,K,Q){return h1(L,K,Q,!0)}function WP(L,K,Q){return h1(L,K,Q,!1)}var qP=WP,KP=UP;zs.Fragment=r,zs.jsx=qP,zs.jsxs=KP}()),zs}process.env.NODE_ENV==="production"?$c.exports=g1():$c.exports=y1();var O=$c.exports;const b1=({metaData:t,setMetaData:e,isPreviewMode:n})=>O.jsx("div",{className:"flex items-center gap-4",children:O.jsx("input",{className:"custom-input mx-2 focus:outline-none bg-[#f8f9fa]",disabled:n,type:"text",placeholder:"Untitled",value:t.plugin.title||"",onChange:r=>e({...t,plugin:{...t.plugin,title:r.target.value}})})});function kt(t){this.content=t}kt.prototype={constructor:kt,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,i=r.find(t),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new kt(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new kt(n)},addToStart:function(t,e){return new kt([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new kt(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new kt(i)},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=kt.from(t),t.size?new kt(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=kt.from(t),t.size?new kt(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=kt.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}},kt.from=function(t){if(t instanceof kt)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new kt(e)};function Hh(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)n++;return n}if(i.content.size||s.content.size){let o=Hh(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function zh(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let o=t.child(--i),l=e.child(--s),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=zh(o.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}class W{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,i=0,s){for(let o=0,l=0;l<n;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||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,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",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?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new W(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let s=0,o=0;o<n;s++){let l=this.content[s],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),i+=l.nodeSize),o=a}return new W(r,i)}cutByIndex(e,n){return e==n?W.empty:e==0&&n==this.content.length?this:new W(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new W(i,s)}addToStart(e){return new W([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new W(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 i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return Hh(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return zh(this,e,n,r)}findIndex(e,n=-1){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 r=0,i=0;;r++){let s=this.child(r),o=i+s.nodeSize;if(o>=e)return o==e||n>0?rl(r+1,o):rl(r,i);i=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return W.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new W(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return W.empty;let n,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(n||(n=e.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new W(n||e,r)}static from(e){if(!e)return W.empty;if(e instanceof W)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new W([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}W.empty=new W([],0);const Bc={index:0,offset:0};function rl(t,e){return Bc.index=t,Bc.offset=e,Bc}function il(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(!il(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!il(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Pe=class Rh{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;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&&il(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`);return r.create(n.attrs)}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 Rh.none;if(e instanceof Rh)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Pe.none=[];class sl extends Error{}class Y{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=Uh(this.content,e+this.openStart,n);return r&&new Y(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Y(Vh(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 Y.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Y(W.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new Y(e,r,i)}}Y.empty=new Y(W.empty,0,0);function Vh(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||s.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,s.copy(Vh(s.content,e-i-1,n-i-1)))}function Uh(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText)return t.cut(0,e).append(n).append(t.cut(e));let l=Uh(o.content,e-s-1,n);return l&&t.replaceChild(i,o.copy(l))}function v1(t,e,n){if(n.openStart>t.depth)throw new sl("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new sl("Inconsistent open depths");return Wh(t,e,n,0)}function Wh(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=Wh(t,e,n,r+1);return s.copy(s.content.replaceChild(i,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 Xr(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=w1(n,t);return Xr(s,Kh(t,o,l,e,r))}else return Xr(s,ol(t,e,r))}function qh(t,e){if(!e.type.compatibleContent(t.type))throw new sl("Cannot join "+e.type.name+" onto "+t.type.name)}function jc(t,e,n){let r=t.node(n);return qh(r,e.node(n)),r}function Yr(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 i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(Yr(t.nodeAfter,r),s++));for(let l=s;l<o;l++)Yr(i.child(l),r);e&&e.depth==n&&e.textOffset&&Yr(e.nodeBefore,r)}function Xr(t,e){return t.type.checkContent(e),t.copy(e)}function Kh(t,e,n,r,i){let s=t.depth>i&&jc(t,e,i+1),o=r.depth>i&&jc(n,r,i+1),l=[];return Vs(null,t,i,l),s&&o&&e.index(i)==n.index(i)?(qh(s,o),Yr(Xr(s,Kh(t,e,n,r,i+1)),l)):(s&&Yr(Xr(s,ol(t,e,i+1)),l),Vs(e,n,i,l),o&&Yr(Xr(o,ol(n,r,i+1)),l)),Vs(r,null,i,l),new W(l)}function ol(t,e,n){let r=[];if(Vs(null,t,n,r),t.depth>n){let i=jc(t,e,n+1);Yr(Xr(i,ol(t,e,n+1)),r)}return Vs(e,null,n,r),new W(r)}function w1(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(W.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class Us{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Pe.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].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 ll(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=[],i=0,s=n;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(r.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new Us(n,r,s)}static resolveCached(e,n){for(let i=0;i<Hc.length;i++){let s=Hc[i];if(s.pos==n&&s.doc==e)return s}let r=Hc[zc]=Us.resolve(e,n);return zc=(zc+1)%x1,r}}let Hc=[],zc=0,x1=12;class ll{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 k1=Object.create(null);let Zr=class Lh{constructor(e,n,r,i=Pe.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||W.empty}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,i=0){this.content.nodesBetween(e,n,r,i,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,i){return this.content.textBetween(e,n,r,i)}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&&il(this.attrs,n||e.defaultAttrs||k1)&&Pe.sameSet(this.marks,r||Pe.none)}copy(e=null){return e==this.content?this:new Lh(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Lh(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 Y.empty;let i=this.resolve(e),s=this.resolve(n),o=r?0:i.sharedDepth(n),l=i.start(o),c=i.node(o).content.cut(i.pos-l,s.pos-l);return new Y(c,i.depth-o,s.depth-o)}replace(e,n,r){return v1(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+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 i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return Us.resolveCached(this,e)}resolveNoCache(e){return Us.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Jh(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=W.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.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);let e=Pe.none;for(let n=0;n<this.marks.length;n++)e=this.marks[n].addToSet(e);if(!Pe.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=null;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=W.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,i,r)}};Zr.prototype.text=void 0;class al extends Zr{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Jh(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 al(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new al(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 Jh(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Qr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new C1(e,n);if(r.next==null)return Qr.empty;let i=Gh(r);r.next&&r.err("Unexpected trailing text");let s=_1(O1(i));return N1(s,r),s}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 i=this;for(let s=n;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}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 i=[this];function s(o,l){let a=o.matchFragment(e,r);if(a&&(!n||a.validEnd))return W.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())&&i.indexOf(d)==-1){i.push(d);let f=s(d,l.concat(u));if(f)return f}}return null}return s(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 i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),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 i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
|
31
|
-
`)}}Qr.empty=new Qr(!0);class C1{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 Gh(t){let e=[];do e.push(S1(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function S1(t){let e=[];do e.push(E1(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function E1(t){let e=M1(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=T1(t,e);else break;return e}function Yh(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function T1(t,e){let n=Yh(t),r=n;return t.eat(",")&&(t.next!="}"?r=Yh(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function A1(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let o=n[s];o.groups.indexOf(e)>-1&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function M1(t){if(t.eat("(")){let e=Gh(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=A1(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 O1(t){let e=[[]];return i(s(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 i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=n())}else if(o.type=="star"){let a=n();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=n();return i(s(o.expr,l),a),i(s(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=n();i(s(o.expr,a),u),a=u}if(o.max==-1)i(s(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=n();r(a,u),i(s(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 Xh(t,e){return e-t}function Zh(t,e){let n=[];return r(e),n.sort(Xh);function r(i){let s=t[i];if(s.length==1&&!s[0].term)return r(s[0].to);n.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&n.indexOf(a)==-1&&r(a)}}}function _1(t){let e=Object.create(null);return n(Zh(t,0));function n(r){let i=[];r.forEach(o=>{t[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<i.length;u++)i[u][0]==l&&(c=i[u][1]);Zh(t,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new Qr(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Xh);s.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return s}}function N1(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Qh(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 ep(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let s=t[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function tp(t){let e=Object.create(null);if(t)for(let n in t)e[n]=new D1(t[n]);return e}let np=class p1{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=tp(r.attrs),this.defaultAttrs=Qh(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==Qr.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}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:ep(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Zr(this,this.computeAttrs(e),W.from(n),Pe.setFrom(r))}createChecked(e=null,n,r){return n=W.from(n),this.checkContent(n),new Zr(this,this.computeAttrs(e),n,Pe.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=W.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(W.empty,!0);return s?new Zr(this,e,n.append(s),Pe.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)}`)}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:Pe.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,o)=>r[s]=new p1(s,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class D1{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class cl{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=tp(i.attrs),this.excluded=null;let s=Qh(this.attrs);this.instance=s?new Pe(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Pe(this,ep(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new cl(s,i++,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]}excludes(e){return this.excluded.indexOf(e)>-1}}class R1{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=kt.from(e.nodes),n.marks=kt.from(e.marks||{}),this.nodes=np.compile(this.spec.nodes,this),this.marks=cl.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=Qr.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?rp(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:rp(this,o.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof np){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new al(r,r.defaultAttrs,e,Pe.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeFromJSON(e){return Zr.fromJSON(this,e)}markFromJSON(e){return Pe.fromJSON(this,e)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function rp(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],o=s;if(s)n.push(s);else for(let l in t.marks){let a=t.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function L1(t){return t.tag!=null}function I1(t){return t.style!=null}let Vc=class Ih{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[],n.forEach(r=>{L1(r)?this.tags.push(r):I1(r)&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let i=e.nodes[r.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new lp(this,n,!1);return r.addAll(e,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new lp(this,n,!0);return r.addAll(e,n.from,n.to),Y.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if($1(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,n,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],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(i){let s=i.priority==null?50:i.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<s)break}n.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=ap(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=ap(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ih(e,Ih.schemaRules(e)))}};const ip={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},P1={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},sp={ol:!0,ul:!0},ul=1,dl=2,Ws=4;function op(t,e,n){return e!=null?(e?ul:0)|(e==="full"?dl:0):t&&t.whitespace=="pre"?ul|dl:n&~Ws}class fl{constructor(e,n,r,i,s,o,l){this.type=e,this.attrs=n,this.marks=r,this.pendingMarks=i,this.solid=s,this.options=l,this.content=[],this.activeMarks=Pe.none,this.stashMarks=[],this.match=o||(l&Ws?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(W.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ul)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let n=W.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(W.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}popFromStashMark(e){for(let n=this.stashMarks.length-1;n>=0;n--)if(e.eq(this.stashMarks[n]))return this.stashMarks.splice(n,1)[0]}applyPending(e){for(let n=0,r=this.pendingMarks;n<r.length;n++){let i=r[n];(this.type?this.type.allowsMarkType(i.type):B1(i.type,e))&&!i.isInSet(this.activeMarks)&&(this.activeMarks=i.addToSet(this.activeMarks),this.pendingMarks=i.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!ip.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class lp{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0;let i=n.topNode,s,o=op(null,n.preserveWhitespace,0)|(r?Ws:0);i?s=new fl(i.type,i.attrs,Pe.none,Pe.none,!0,n.topMatch||i.type.contentMatch,o):r?s=new fl(null,null,Pe.none,Pe.none,!0,null,o):s=new fl(e.schema.topNodeType,null,Pe.none,Pe.none,!0,null,o),this.nodes=[s],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){e.nodeType==3?this.addTextNode(e):e.nodeType==1&&this.addElement(e)}withStyleRules(e,n){let r=e.style;if(!r||!r.length)return n();let i=this.readStyles(e.style);if(!i)return;let[s,o]=i,l=this.top;for(let a=0;a<o.length;a++)this.removePendingMark(o[a],l);for(let a=0;a<s.length;a++)this.addPendingMark(s[a]);n();for(let a=0;a<s.length;a++)this.removePendingMark(s[a],l);for(let a=0;a<o.length;a++)this.addPendingMark(o[a])}addTextNode(e){let n=e.nodeValue,r=this.top;if(r.options&dl||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(r.options&ul)r.options&dl?n=n.replace(/\r\n?/g,`
|
32
|
-
`):n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let i=r.content[r.content.length-1],s=e.previousSibling;(!i||s&&s.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n)),this.findInText(e)}else this.findInside(e)}addElement(e,n){let r=e.nodeName.toLowerCase(),i;
|
33
|
-
`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let n=Pe.none,r=Pe.none;for(let i=0,s=e.length;i<s;i++){let o=e.item(i);for(let l=void 0;;){let a=this.parser.matchStyle(o,e.getPropertyValue(o),this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?this.top.pendingMarks.concat(this.top.activeMarks).forEach(c=>{a.clearMark(c)&&(r=c.addToSet(r))}):n=this.parser.schema.marks[a.mark].create(a.attrs).addToSet(n),a.consuming===!1)l=a;else break}}return[n,r]}addElementByRule(e,n,r){let i,s,o;n.node?(s=this.parser.schema.nodes[n.node],s.isLeaf?this.insertNode(s.create(n.attrs))||this.leafFallback(e):i=this.enter(s,n.attrs||null,n.preserveWhitespace)):(o=this.parser.schema.marks[n.mark].create(n.attrs),this.addPendingMark(o));let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));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)}i&&this.sync(l)&&this.open--,o&&this.removePendingMark(o,l)}addAll(e,n,r){let i=n||0;for(let s=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];s!=o;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s);this.findAtPoint(e,i)}findPlace(e){let n,r;for(let i=this.open;i>=0;i--){let s=this.nodes[i],o=s.findWrapping(e);if(o&&(!n||n.length>o.length)&&(n=o,r=s,!o.length)||s.solid)break}if(!n)return!1;this.sync(r);for(let i=0;i<n.length;i++)this.enterInner(n[i],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let n=this.textblockFromContext();n&&this.enterInner(n)}if(this.findPlace(e)){this.closeExtra();let n=this.top;n.applyPending(e.type),n.match&&(n.match=n.match.matchType(e.type));let r=n.activeMarks;for(let i=0;i<e.marks.length;i++)(!n.type||n.type.allowsMarkType(e.marks[i].type))&&(r=e.marks[i].addToSet(r));return n.content.push(e.mark(r)),!0}return!1}enter(e,n,r){let i=this.findPlace(e.create(n));return i&&this.enterInner(e,n,!0,r),i}enterInner(e,n=null,r=!1,i){this.closeExtra();let s=this.top;s.applyPending(e),s.match=s.match&&s.match.matchType(e);let o=op(e,i,s.options);s.options&Ws&&s.content.length==0&&(o|=Ws),this.nodes.push(new fl(e,n,s.activeMarks,s.pendingMarks,r,null,o)),this.open++}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;return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<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 i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].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,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?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>=s;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&u.groups.indexOf(c)==-1)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}}addPendingMark(e){let n=j1(e,this.top.pendingMarks);n&&this.top.stashMarks.push(n),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,n){for(let r=this.open;r>=0;r--){let i=this.nodes[r];if(i.pendingMarks.lastIndexOf(e)>-1)i.pendingMarks=e.removeFromSet(i.pendingMarks);else{i.activeMarks=e.removeFromSet(i.activeMarks);let o=i.popFromStashMark(e);o&&i.type&&i.type.allowsMarkType(o.type)&&(i.activeMarks=o.addToSet(i.activeMarks))}if(i==n)break}}}function F1(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&sp.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function $1(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function ap(t){let e={};for(let n in t)e[n]=t[n];return e}function B1(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&o(u))return!0}};if(o(i.contentMatch))return!0}}function j1(t,e){for(let n=0;n<e.length;n++)if(t.eq(e[n]))return e[n]}class Nn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Uc(n).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,n);u&&(s.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=Nn.renderSpec(Uc(n),this.nodes[e.type.name](e));if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Nn.renderSpec(Uc(r),i(e,n))}static renderSpec(e,n,r=null){if(typeof n=="string")return{dom:e.createTextNode(n)};if(n.nodeType!=null)return{dom:n};if(n.dom&&n.dom.nodeType!=null)return n;let i=n[0],s=i.indexOf(" ");s>0&&(r=i.slice(0,s),i=i.slice(s+1));let o,l=r?e.createElementNS(r,i):e.createElement(i),a=n[1],c=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){c=2;for(let u in a)if(a[u]!=null){let d=u.indexOf(" ");d>0?l.setAttributeNS(u.slice(0,d),u.slice(d+1),a[u]):l.setAttribute(u,a[u])}}for(let u=c;u<n.length;u++){let d=n[u];if(d===0){if(u<n.length-1||u>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:f,contentDOM:h}=Nn.renderSpec(e,d,r);if(l.appendChild(f),h){if(o)throw new RangeError("Multiple content holes");o=h}}}return{dom:l,contentDOM:o}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Nn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=cp(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return cp(e.marks)}}function cp(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Uc(t){return t.document||window.document}const up=65535,dp=Math.pow(2,16);function H1(t,e){return t+e*dp}function fp(t){return t&up}function z1(t){return(t-(t&up))/dp}const hp=1,pp=2,hl=4,mp=8;class Wc{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&mp)>0}get deletedBefore(){return(this.delInfo&(hp|hl))>0}get deletedAfter(){return(this.delInfo&(pp|hl))>0}get deletedAcross(){return(this.delInfo&hl)>0}}class Kt{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Kt.empty)return Kt.empty}recover(e){let n=0,r=fp(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+z1(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 i=0,s=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?i:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+o],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:n:n,h=a+i+(f<0?0:u);if(r)return h;let p=e==(n<0?a:d)?null:H1(l/3,e-a),g=e==a?pp:e==d?hp:hl;return(n<0?e!=a:e!=d)&&(g|=mp),new Wc(h,g,p)}i+=u-c}return r?e+i:new Wc(e+i,0,null)}touches(e,n){let r=0,i=fp(n),s=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+s],u=a+c;if(e<=u&&l==i*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 i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+n],u=this.ranges[i+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new Kt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Kt.empty:new Kt(e<0?[0,-e,0]:[0,0,e])}}Kt.empty=new Kt([]);class Li{constructor(e=[],n,r=0,i=e.length){this.maps=e,this.mirror=n,this.from=r,this.to=i}slice(e=0,n=this.maps.length){return new Li(this.maps,this.mirror,e,n)}copy(){return new Li(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,n){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 i=e.getMirror(n);this.appendMap(e.maps[n],i!=null&&i<n?r+i: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 i=e.getMirror(n);this.appendMap(e.maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new Li;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 i=0;for(let s=this.from;s<this.to;s++){let o=this.maps[s],l=o.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this.maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new Wc(e,i,null)}}const qc=Object.create(null);class Tt{getMap(){return Kt.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=qc[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 qc)throw new RangeError("Duplicate use of step JSON ID "+e);return qc[e]=n,n.prototype.jsonID=e,n}}class ot{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ot(e,null)}static fail(e){return new ot(null,e)}static fromReplace(e,n,r,i){try{return ot.ok(e.replace(n,r,i))}catch(s){if(s instanceof sl)return ot.fail(s.message);throw s}}}function Kc(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(Kc(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return W.fromArray(r)}class wr extends Tt{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),i=r.node(r.sharedDepth(this.to)),s=new Y(Kc(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return ot.fromReplace(e,this.from,this.to,s)}invert(){return new Dn(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 wr(n.pos,r.pos,this.mark)}merge(e){return e instanceof wr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new wr(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 wr(n.from,n.to,e.markFromJSON(n.mark))}}Tt.jsonID("addMark",wr);class Dn extends Tt{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 Y(Kc(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return ot.fromReplace(e,this.from,this.to,r)}invert(){return new wr(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 Dn(n.pos,r.pos,this.mark)}merge(e){return e instanceof Dn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Dn(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 Dn(n.from,n.to,e.markFromJSON(n.mark))}}Tt.jsonID("removeMark",Dn);class xr extends Tt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ot.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ot.fromReplace(e,this.pos,this.pos+1,new Y(W.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new xr(this.pos,n.marks[i]);return new xr(this.pos,this.mark)}}return new Ii(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new xr(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 xr(n.pos,e.markFromJSON(n.mark))}}Tt.jsonID("addNodeMark",xr);class Ii extends Tt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ot.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ot.fromReplace(e,this.pos,this.pos+1,new Y(W.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new xr(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ii(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 Ii(n.pos,e.markFromJSON(n.mark))}}Tt.jsonID("removeNodeMark",Ii);class ht extends Tt{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&Jc(e,this.from,this.to)?ot.fail("Structure replace would overwrite content"):ot.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Kt([this.from,this.to-this.from,this.slice.size])}invert(e){return new ht(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 ht(n.pos,Math.max(n.pos,r.pos),this.slice)}merge(e){if(!(e instanceof ht)||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?Y.empty:new Y(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ht(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?Y.empty:new Y(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ht(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 ht(n.from,n.to,Y.fromJSON(e,n.slice),!!n.structure)}}Tt.jsonID("replace",ht);class pt extends Tt{constructor(e,n,r,i,s,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Jc(e,this.from,this.gapFrom)||Jc(e,this.gapTo,this.to)))return ot.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ot.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ot.fromReplace(e,this.from,this.to,r):ot.fail("Content does not fit in gap")}getMap(){return new Kt([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 pt(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),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||s>r.pos?null:new pt(n.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new pt(n.from,n.to,n.gapFrom,n.gapTo,Y.fromJSON(e,n.slice),n.insert,!!n.structure)}}Tt.jsonID("replaceAround",pt);function Jc(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function V1(t,e,n,r){let i=[],s=[],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 f=Math.max(c,e),h=Math.min(c+a.nodeSize,n),p=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(p)||(o&&o.to==f&&o.mark.eq(d[g])?o.to=h:i.push(o=new Dn(f,h,d[g])));l&&l.to==f?l.to=h:s.push(l=new wr(f,h,r))}}),i.forEach(a=>t.step(a)),s.forEach(a=>t.step(a))}function U1(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof cl){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],f;for(let h=0;h<i.length;h++){let p=i[h];p.step==s-1&&d.eq(i[h].style)&&(f=p)}f?(f.to=c,f.step=s):i.push({style:d,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>t.step(new Dn(o.from,o.to,o.style)))}function gp(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new ht(l,u,Y.empty));else{r=d;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new Dn(l,u,c.marks[f]));if(i&&c.isText&&n.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new Y(W.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),o.push(new ht(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(W.empty,!0);t.replace(l,l,new Y(a,0,0))}for(let a=o.length-1;a>=0;a--)t.step(o[a])}function W1(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Pi(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let i=t.$from.node(r),s=t.$from.index(r),o=t.$to.indexAfter(r);if(r<t.depth&&i.canReplace(s,o,n))return r;if(r==0||i.type.spec.isolating||!W1(i,s,o))break}return null}function q1(t,e,n){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),a=o,c=l,u=W.empty,d=0;for(let p=s,g=!1;p>n;p--)g||r.index(p)>0?(g=!0,u=W.from(r.node(p).copy(u)),d++):a--;let f=W.empty,h=0;for(let p=s,g=!1;p>n;p--)g||i.after(p+1)<i.end(p)?(g=!0,f=W.from(i.node(p).copy(f)),h++):c++;t.step(new pt(a,c,o,l,new Y(u.append(f),d,h),u.size-d,!0))}function Gc(t,e,n=null,r=t){let i=K1(t,e),s=i&&J1(r,e);return s?i.map(yp).concat({type:e,attrs:n}).concat(s.map(yp)):null}function yp(t){return{type:t,attrs:null}}function K1(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return n.canReplaceWith(r,i,o)?s:null}function J1(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:o}function G1(t,e,n){let r=W.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=W.from(n[o].type.create(n[o].attrs,r))}let i=e.start,s=e.end;t.step(new pt(i,s,i,s,new Y(r,0,0),n.length,!0))}function Y1(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{if(o.isTextblock&&!o.hasMarkup(r,i)&&Q1(t.doc,t.mapping.slice(s).map(l),r)){let a=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!h?a=!1:!f&&h&&(a=!0)}a===!1&&Z1(t,o,l,s),gp(t,t.mapping.slice(s).map(l,1),r,void 0,a===null);let c=t.mapping.slice(s),u=c.map(l,1),d=c.map(l+o.nodeSize,1);return t.step(new pt(u,d,u+1,d-1,new Y(W.from(r.create(i,null,o.marks)),0,0),1,!0)),a===!0&&X1(t,o,l,s),!1}})}function X1(t,e,n,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=t.mapping.slice(r).map(n+1+s+o.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Z1(t,e,n,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+s);t.replaceWith(o,o+1,e.type.schema.text(`
|
34
|
-
`))}})}function Q1(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function ex(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new pt(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new Y(W.from(o),0,0),1,!0))}function Fi(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=n-2;c>s;c--,u--){let d=i.node(c),f=i.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!g.type.validContent(h))return!1}let l=i.indexAfter(s),a=r&&r[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function tx(t,e,n=1,r){let i=t.doc.resolve(e),s=W.empty,o=W.empty;for(let l=i.depth,a=i.depth-n,c=n-1;l>a;l--,c--){s=W.from(i.node(l).copy(s));let u=r&&r[c];o=W.from(u?u.type.create(u.attrs,o):i.node(l).copy(o))}t.step(new ht(e,e,new Y(s.append(o),n,n),!0))}function kr(t,e){let n=t.resolve(e),r=n.index();return bp(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function bp(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}function pl(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let s,o,l=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):n>0?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&bp(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function nx(t,e,n){let r=new ht(e-n,e+n,Y.empty,!0);t.step(r)}function rx(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,n))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,n))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function vp(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let s=0;s<n.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)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(s==1)u=c.canReplace(a,a,i);else{let d=c.contentMatchAt(a).findWrapping(i.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 ml(t,e,n=e,r=Y.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return wp(i,s,r)?new ht(e,n,r):new ix(i,s,r).fit()}function wp(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class ix{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=W.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=W.from(e.node(i).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,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new Y(s,o,l);return e>-1?new pt(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new ht(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=n.firstChild;if(n.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Yc(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.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(W.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:d};if(n==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Yc(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Y(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Yc(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new Y(qs(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new Y(qs(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let g=0;g<s.length;g++)this.openFrontierNode(s[g]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[n];if(i){for(let g=0;g<i.childCount;g++)u.push(i.child(g));d=d.matchFragment(i)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let g=l.child(c),v=d.matchType(g.type);if(!v)break;c++,(c>1||a==0||g.content.size)&&(d=v,u.push(xp(g.mark(f.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=Ks(this.placed,n,W.from(u)),this.frontier[n].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,v=l;g<h;g++){let w=v.lastChild;this.frontier.push({type:w.type,match:w.contentMatchAt(w.childCount)}),v=w.content}this.unplaced=p?e==0?Y.empty:new Y(qs(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new Y(qs(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||!Xc(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,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],s=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=Xc(e,n,i,r,s);if(o){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Xc(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:o,move:s?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Ks(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Ks(this.placed,this.depth,W.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(W.empty,!0);n.childCount&&(this.placed=Ks(this.placed,this.frontier.length,n))}}function qs(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(qs(t.firstChild.content,e-1,n)))}function Ks(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Ks(t.lastChild.content,e-1,n)))}function Yc(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function xp(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,xp(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(W.empty,!0)))),t.copy(r)}function Xc(t,e,n,r,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!sx(n,s.content,o)?l:null}function sx(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function ox(t){return t.spec.defining||t.spec.definingForContent}function lx(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(wp(i,s,r))return t.step(new ht(e,n,r));let o=Cp(i,t.doc.resolve(n));o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let f=i.depth,h=i.pos-1;f>0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:i.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=ox(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let g=0;g<o.length;g++){let v=o[(g+a)%o.length],w=!0;v<0&&(w=!1,v=-v);let S=i.node(v-1),x=i.index(v-1);if(S.canReplaceWith(x,x,p.type,p.marks))return t.replace(i.before(v),w?s.after(v):n,new Y(kp(r.content,0,r.openStart,h),h,r.openEnd))}}let d=t.steps.length;for(let f=o.length-1;f>=0&&(t.replace(e,n,r),!(t.steps.length>d));f--){let h=o[f];h<0||(e=i.before(h),n=s.after(h))}}function kp(t,e,n,r,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(kp(s.content,e+1,n,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(t).append(t);t=o.append(s.matchFragment(o).fillBefore(W.empty,!0))}return t}function ax(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=rx(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Y(W.from(r),0,0))}function cx(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=Cp(r,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),i.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o)return t.delete(r.before(o),n);t.delete(e,n)}function Cp(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let s=t.start(i);if(s<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&n.push(i)}return n}class $i extends Tt{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 ot.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return ot.fromReplace(e,this.pos,this.pos+1,new Y(W.from(i),0,n.isLeaf?0:1))}getMap(){return Kt.empty}invert(e){return new $i(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 $i(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 $i(n.pos,n.attr,n.value)}}Tt.jsonID("attr",$i);class Js extends Tt{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return ot.ok(r)}getMap(){return Kt.empty}invert(e){return new Js(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 Js(n.attr,n.value)}}Tt.jsonID("docAttr",Js);let Bi=class extends Error{};Bi=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},Bi.prototype=Object.create(Error.prototype),Bi.prototype.constructor=Bi,Bi.prototype.name="TransformError";class Zc{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Li}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Bi(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=Y.empty){let i=ml(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Y(W.from(r),0,0))}delete(e,n){return this.replace(e,n,Y.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return lx(this,e,n,r),this}replaceRangeWith(e,n,r){return ax(this,e,n,r),this}deleteRange(e,n){return cx(this,e,n),this}lift(e,n){return q1(this,e,n),this}join(e,n=1){return nx(this,e,n),this}wrap(e,n){return G1(this,e,n),this}setBlockType(e,n=e,r,i=null){return Y1(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return ex(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new $i(e,n,r)),this}setDocAttribute(e,n){return this.step(new Js(e,n)),this}addNodeMark(e,n){return this.step(new xr(e,n)),this}removeNodeMark(e,n){if(!(n instanceof Pe)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n=n.isInSet(r.marks),!n)return this}return this.step(new Ii(e,n)),this}split(e,n=1,r){return tx(this,e,n,r),this}addMark(e,n,r){return V1(this,e,n,r),this}removeMark(e,n,r){return U1(this,e,n,r),this}clearIncompatible(e,n,r){return gp(this,e,n,r),this}}const Qc=Object.create(null);class ue{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new eu(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=Y.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let s=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(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?Y.empty:n),l==0&&Tp(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),Tp(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new ce(e):ji(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=n<0?ji(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):ji(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new yn(e.node(0))}static atStart(e){return ji(e,e,0,0,1)||new yn(e)}static atEnd(e){return ji(e,e,e.content.size,e.childCount,-1)||new yn(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Qc[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 Qc)throw new RangeError("Duplicate use of selection JSON ID "+e);return Qc[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ce.between(this.$anchor,this.$head).getBookmark()}}ue.prototype.visible=!0;class eu{constructor(e,n){this.$from=e,this.$to=n}}let Sp=!1;function Ep(t){!Sp&&!t.parent.inlineContent&&(Sp=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ce extends ue{constructor(e,n=e){Ep(e),Ep(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 ue.near(r);let i=e.resolve(n.map(this.anchor));return new ce(i.parent.inlineContent?i:r,r)}replace(e,n=Y.empty){if(super.replace(e,n),n==Y.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof ce&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new gl(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 ce(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let s=ue.findFrom(n,r,!0)||ue.findFrom(n,-r,!0);if(s)n=s.$head;else return ue.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(ue.findFrom(e,-r,!0)||ue.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new ce(e,n)}}ue.jsonID("text",ce);class gl{constructor(e,n){this.anchor=e,this.head=n}map(e){return new gl(e.map(this.anchor),e.map(this.head))}resolve(e){return ce.between(e.resolve(this.anchor),e.resolve(this.head))}}class se extends ue{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:i}=n.mapResult(this.anchor),s=e.resolve(i);return r?ue.near(s):new se(s)}content(){return new Y(W.from(this.node),0,0)}eq(e){return e instanceof se&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new tu(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new se(e.resolve(n.anchor))}static create(e,n){return new se(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}se.prototype.visible=!1,ue.jsonID("node",se);class tu{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new gl(r,r):new tu(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&se.isSelectable(r)?new se(n):ue.near(n)}}class yn extends ue{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Y.empty){if(n==Y.empty){e.delete(0,e.doc.content.size);let r=ue.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new yn(e)}map(e){return new yn(e)}eq(e){return e instanceof yn}getBookmark(){return ux}}ue.jsonID("all",yn);const ux={map(){return this},resolve(t){return new yn(t)}};function ji(t,e,n,r,i,s=!1){if(e.inlineContent)return ce.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&se.isSelectable(l))return se.create(t,n-(i<0?l.nodeSize:0))}else{let a=ji(t,l,n+i,i<0?l.childCount:0,i,s);if(a)return a}n+=l.nodeSize*i}return null}function Tp(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof ht||i instanceof pt))return;let s=t.mapping.maps[r],o;s.forEach((l,a,c,u)=>{o==null&&(o=u)}),t.setSelection(ue.near(t.doc.resolve(o),n))}const Ap=1,yl=2,Mp=4;let dx=class extends Zc{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|Ap)&~yl,this.storedMarks=null,this}get selectionSet(){return(this.updated&Ap)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=yl,this}ensureMarks(e){return Pe.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&yl)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~yl,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)||Pe.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),r=r??n,!e)return this.deleteRange(n,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(n);s=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,s)),this.selection.empty||this.setSelection(ue.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|=Mp,this}get scrolledIntoView(){return(this.updated&Mp)>0}};function Op(t,e){return!e||!t?t:t.bind(e)}class Gs{constructor(e,n,r){this.name=e,this.init=Op(n.init,r),this.apply=Op(n.apply,r)}}const fx=[new Gs("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Gs("selection",{init(t,e){return t.selection||ue.atStart(e.doc)},apply(t){return t.selection}}),new Gs("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Gs("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class nu{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=fx.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 Gs(r.key,r.spec.state,r))})}}class Hi{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 i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=i?i[o].n:0,c=i?i[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),!i){i=[];for(let d=0;d<this.config.plugins.length;d++)i.push(d<o?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),s=!0}i&&(i[o]={state:r,n:n.length})}}if(!s)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Hi(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];n[s.name]=s.apply(e,this[s.name],this,n)}return n}get tr(){return new dx(this)}static create(e){let n=new nu(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Hi(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new nu(this.schema,e.plugins),r=n.fields,i=new Hi(n);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]:r[s].init(e,i)}return i}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 i=e[r],s=i.spec.state;s&&s.toJSON&&(n[r]=s.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new nu(e.schema,e.plugins),s=new Hi(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Zr.fromJSON(e.schema,n.doc);else if(o.name=="selection")s.selection=ue.fromJSON(s.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let 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)){s[o.name]=c.fromJSON.call(a,e,n[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function _p(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=_p(i,e,{})),n[r]=i}return n}class je{constructor(e){this.spec=e,this.props={},e.props&&_p(e.props,this,this.props),this.key=e.key?e.key.key:Np("plugin")}getState(e){return e[this.key]}}const ru=Object.create(null);function Np(t){return t in ru?t+"$"+ ++ru[t]:(ru[t]=0,t+"$")}class We{constructor(e="key"){this.key=Np(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ct=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Ys=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let iu=null;const er=function(t,e,n){let r=iu||(iu=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},hx=function(){iu=null},ei=function(t,e,n,r){return n&&(Dp(t,e,n,r,-1)||Dp(t,e,n,r,1))},px=/^(img|br|input|textarea|hr)$/i;function Dp(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Rn(t))){let s=t.parentNode;if(!s||s.nodeType!=1||Xs(t)||px.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ct(t)+(i<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.contentEditable=="false")return!1;e=i<0?Rn(t):0}else return!1}}function Rn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function mx(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=Rn(t)}else if(t.parentNode&&!Xs(t))e=Ct(t),t=t.parentNode;else return null}}function gx(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&&!Xs(t))e=Ct(t)+1,t=t.parentNode;else return null}}function yx(t,e,n){for(let r=e==0,i=e==Rn(t);r||i;){if(t==n)return!0;let s=Ct(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,i=i&&s==Rn(t)}}function Xs(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 bl=function(t){return t.focusNode&&ei(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function ti(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function bx(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function vx(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:r.offset}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:r.startOffset}}}const Ln=typeof navigator<"u"?navigator:null,Rp=typeof document<"u"?document:null,Cr=Ln&&Ln.userAgent||"",su=/Edge\/(\d+)/.exec(Cr),Lp=/MSIE \d/.exec(Cr),ou=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Cr),Bt=!!(Lp||ou||su),Sr=Lp?document.documentMode:ou?+ou[1]:su?+su[1]:0,bn=!Bt&&/gecko\/(\d+)/i.test(Cr);bn&&+(/Firefox\/(\d+)/.exec(Cr)||[0,0])[1];const lu=!Bt&&/Chrome\/(\d+)/.exec(Cr),_t=!!lu,wx=lu?+lu[1]:0,Nt=!Bt&&!!Ln&&/Apple Computer/.test(Ln.vendor),zi=Nt&&(/Mobile\/\w+/.test(Cr)||!!Ln&&Ln.maxTouchPoints>2),rn=zi||(Ln?/Mac/.test(Ln.platform):!1),xx=Ln?/Win/.test(Ln.platform):!1,vn=/Android \d/.test(Cr),Zs=!!Rp&&"webkitFontSmoothing"in Rp.documentElement.style,kx=Zs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Cx(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 tr(t,e){return typeof t=="number"?t:t[e]}function Sx(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 Ip(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=n||t.dom;o;o=Ys(o)){if(o.nodeType!=1)continue;let l=o,a=l==s.body,c=a?Cx(s):Sx(l),u=0,d=0;if(e.top<c.top+tr(r,"top")?d=-(c.top-e.top+tr(i,"top")):e.bottom>c.bottom-tr(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+tr(i,"top")-c.top:e.bottom-c.bottom+tr(i,"bottom")),e.left<c.left+tr(r,"left")?u=-(c.left-e.left+tr(i,"left")):e.right>c.right-tr(r,"right")&&(u=e.right-c.right+tr(i,"right")),u||d)if(a)s.defaultView.scrollBy(u,d);else{let f=l.scrollLeft,h=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let p=l.scrollLeft-f,g=l.scrollTop-h;e={left:e.left-p,top:e.top-g,right:e.right-p,bottom:e.bottom-g}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(o).position))break}}function Ex(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(s,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:Pp(t.dom)}}function Pp(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Ys(r));return e}function Tx({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Fp(n,r==0?0:r-e)}function Fp(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:s}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let Vi=null;function Ax(t){if(t.setActive)return t.setActive();if(Vi)return t.focus(Vi);let e=Pp(t);t.focus(Vi==null?{get preventScroll(){return Vi={preventScroll:!0},!0}}:void 0),Vi||(Vi=!1,Fp(e,0))}function $p(t,e){let n,r=2e8,i,s=0,o=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=er(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];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=u,r=g,i=g&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&g&&(s=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)&&(s=d+1)}}return!n&&a&&(n=a,i=c,r=0),n&&n.nodeType==3?Mx(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:$p(n,i)}function Mx(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let s=Er(r,1);if(s.top!=s.bottom&&au(e,s))return{node:t,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:t,offset:0}}function au(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Ox(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function _x(t,e,n){let{node:r,offset:i}=$p(e,n),s=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}function Nx(t,e,n,r){let i=-1;for(let s=e,o=!1;s!=t.dom;){let l=t.docView.nearestDesc(s,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!o&&a.left>r.left||a.top>r.top?i=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<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}s=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function Bp(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let o=t.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(au(e,c))return Bp(o,e,c)}}if((s=(s+1)%r)==i)break}return t}function Dx(t,e){let n=t.dom.ownerDocument,r,i=0,s=vx(n,e.left,e.top);s&&({node:r,offset:i}=s);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(!au(e,c)||(o=Bp(t.dom,e,c),!o))return null}if(Nt)for(let c=o;r&&c;c=Ys(c))c.draggable&&(r=void 0);if(o=Ox(o,e),r){if(bn&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&i++}let c;Zs&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=Nx(t,r,i,e))}l==null&&(l=_x(t,o,e));let a=t.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function jp(t){return t.top<t.bottom||t.left<t.right}function Er(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(jp(r))return r}return Array.prototype.find.call(n,jp)||t.getBoundingClientRect()}const Rx=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Hp(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),o=Zs||bn;if(r.nodeType==3)if(o&&(Rx.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let a=Er(er(r,i,i),n);if(bn&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=Er(er(r,i-1,i-1),-1);if(c.top==a.top){let u=Er(er(r,i,i+1),-1);if(u.top!=a.top)return Qs(u,u.left<c.left)}}return a}else{let a=i,c=i,u=n<0?1:-1;return n<0&&!i?(c++,u=-1):n>=0&&i==r.nodeValue.length?(a--,u=1):n<0?a--:c++,Qs(Er(er(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==Rn(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return cu(a.getBoundingClientRect(),!1)}if(s==null&&i<Rn(r)){let a=r.childNodes[i];if(a.nodeType==1)return cu(a.getBoundingClientRect(),!0)}return cu(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==Rn(r))){let a=r.childNodes[i-1],c=a.nodeType==3?er(a,Rn(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Qs(Er(c,1),!1)}if(s==null&&i<Rn(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?er(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return Qs(Er(c,-1),!0)}return Qs(Er(r.nodeType==3?er(r):r,-n),n>=0)}function Qs(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 cu(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 zp(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function Lx(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return zp(t,e,()=>{let{node:s}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Hp(t,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=er(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 Ix=/[\u0590-\u08ac]/;function Px(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=t.domSelection();return!Ix.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?s:o:zp(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:g}=t.domSelectionRange(),v=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==g;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),v})}let Vp=null,Up=null,Wp=!1;function Fx(t,e,n){return Vp==e&&Up==n?Wp:(Vp=e,Up=n,Wp=n=="up"||n=="down"?Lx(t,e,n):Px(t,e,n))}const sn=0,qp=1,ni=2,In=3;class eo{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=sn,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 i=this.children[n];if(i==e)return r;r+=i.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 s,o;if(e==this.contentDOM)s=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>Ct(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!n||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)i=i.children[0];return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.size;if(l>e||o instanceof Gp){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Kp&&s.side>=0;r--);if(n<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&n&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?Ct(s.dom)+1:0}}else{let s,o=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,n):{node:this.contentDOM,offset:s?Ct(s.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 i=-1,s=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(i==-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 f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=Ct(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-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)){s=Ct(d.dom);break}n+=d.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:s}}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,i=!1){let s=Math.min(e,n),o=Math.max(e,n);for(let f=0,h=0;f<this.children.length;f++){let p=this.children[f],g=h+p.size;if(s>h&&o<g)return p.setSelection(e-h-p.border,n-h-p.border,r,i);h=g}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.getSelection(),u=!1;if((bn||Nt)&&e==n){let{node:f,offset:h}=l;if(f.nodeType==3){if(u=!!(h&&f.nodeValue[h-1]==`
|
35
|
-
`),u&&h==f.nodeValue.length)for(let p=f,g;p;p=p.parentNode){if(g=p.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:Ct(g)+1});break}let v=p.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let p=f.childNodes[h-1];u=p&&(p.nodeName=="BR"||p.contentEditable=="false")}}if(bn&&c.focusNode&&c.focusNode!=a.node&&c.focusNode.nodeType==1){let f=c.focusNode.childNodes[c.focusOffset];f&&f.contentEditable=="false"&&(i=!0)}if(!(i||u&&Nt)&&ei(l.node,l.offset,c.anchorNode,c.anchorOffset)&&ei(a.node,a.offset,c.focusNode,c.focusOffset))return;let d=!1;if((c.extend||e==n)&&!u){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>n){let h=l;l=a,a=h}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,i=0;i<this.children.length;i++){let s=this.children[i],o=r+s.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+s.border,a=o-s.border;if(e>=l&&n<=a){this.dirty=e==r||n==o?ni:qp,e==l&&n==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=In:s.markDirty(e-l,n-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?ni:In}r=o}this.dirty=ni}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?ni:qp;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class Kp extends eo{constructor(e,n,r,i){let s,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!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,s=this}matchesWidget(e){return this.dirty==sn&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class $x extends eo{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class ri extends eo{constructor(e,n,r,i){super(e,[],r,i),this.mark=n}static create(e,n,r,i){let s=i.nodeViews[n.type.name],o=s&&s(n,i,r);return(!o||!o.dom)&&(o=Nn.renderSpec(document,n.type.spec.toDOM(n,r))),new ri(e,n,o.dom,o.contentDOM||o.dom)}parseRule(){return this.dirty&In||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=In&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=sn){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=sn}}slice(e,n,r){let i=ri.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;n<o&&(s=fu(s,n,o,r)),e>0&&(s=fu(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}}class Tr extends eo{constructor(e,n,r,i,s,o,l,a,c){super(e,[],s,o),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,s,o){let l=s.nodeViews[n.type.name],a,c=l&&l(n,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,i),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}=Nn.renderSpec(document,n.type.spec.toDOM(n)));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Zp(u,r,n),c?a=new Bx(e,n,r,i,u,d||null,f,c,s,o+1):n.isText?new vl(e,n,r,i,u,f,s):new Tr(e,n,r,i,u,d||null,f,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>W.empty)}return e}matchesNode(e,n,r){return this.dirty==sn&&e.eq(this.node)&&du(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,s=e.composing?this.localCompositionInfo(e,n):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Hx(this,o&&o.node,e);Ux(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?Pe.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,i)},(c,u,d,f)=>{a.syncToMarks(c.marks,r,e);let h;a.findNodeMatch(c,u,d,f)||l&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(h=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,u,d,h,e)||a.updateNextNode(c,u,d,e,f,i)||a.addNode(c,u,d,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==ni)&&(o&&this.protectLocalComposition(e,o),Yp(this.contentDOM,this.children,e),zi&&Wx(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof ce)||r<n||i>n+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=qx(this.node.content,o,r-n,i-n);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new $x(this,s,n,i);e.input.compositionNodes.push(o),this.children=fu(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==In||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=sn}updateOuterDeco(e){if(du(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Xp(this.dom,this.nodeDOM,uu(this.outerDeco,this.node,n),uu(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Jp(t,e,n,r,i){Zp(r,e,t);let s=new Tr(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class vl extends Tr{constructor(e,n,r,i,s,o,l){super(e,n,r,i,s,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,i){return this.dirty==In||this.dirty!=sn&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=sn||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=sn,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),s=document.createTextNode(i.text);return new vl(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=In)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Gp extends eo{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==sn&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Bx extends Tr{constructor(e,n,r,i,s,o,l,a,c,u){super(e,n,r,i,s,o,l,c,u),this.spec=a}update(e,n,r,i){if(this.dirty==In)return!1;if(this.spec.update){let s=this.spec.update(e,n,r);return s&&this.updateInner(e,n,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Yp(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=Qp(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof ri){let a=r?r.previousSibling:t.lastChild;Yp(o.contentDOM,o.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=Qp(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const to=function(t){t&&(this.nodeName=t)};to.prototype=Object.create(null);const ii=[new to];function uu(t,e,n){if(t.length==0)return ii;let r=n?ii[0]:new to,i=[r];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&i.push(r=new to(o.nodeName));for(let l in o){let a=o[l];a!=null&&(n&&i.length==1&&i.push(r=new to(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 i}function Xp(t,e,n,r){if(n==ii&&r==ii)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],l=n[s];if(s){let a;l&&l.nodeName==o.nodeName&&i!=t&&(a=i.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=ii[0]),i=a}jx(i,l||ii[0],o)}return i}function jx(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):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&t.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&t.classList.add(i[s]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function Zp(t,e,n){return Xp(t,t,ii,uu(e,n,t.nodeType!=1))}function du(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 Qp(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Hx{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=zx(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 i=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;i<o&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=sn,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<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[s])&&!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=ri.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))s=this.top.children.indexOf(o,this.index);else for(let 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)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,n,r,i,s){let o=this.top.children[i];return o.dirty==In&&o.dom==o.contentDOM&&(o.dirty=ni),o.update(e,n,r,s)?(this.destroyBetween(this.index,i),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 i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Tr){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=In&&du(n,a.outerDeco));if(!f&&a.update(e,n,r,i))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,n,r,i,o)))return this.top.children[this.index]=d,d.contentDOM&&(d.dirty=ni,d.updateChildren(i,o+1),d.dirty=sn),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,s,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content))return null;let l=Tr.create(this.top,n,r,i,s,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,i,s){let o=Tr.create(this.top,e,n,r,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new Kp(this.top,e,n,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof ri;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof vl)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Nt||_t)&&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 i=new Gp(this.top,[],r,null);n!=this.top?n.children.push(i):n.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function zx(t,e){let n=e,r=n.children.length,i=t.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof ri)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(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function Vx(t,e){return t.type.side-e.type.side}function Ux(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,i,e.forChild(s,u),c),s+=u.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let u,d;for(;o<i.length&&i[o].to==s;){let v=i[o++];v.widget&&(u?(d||(d=[u])).push(v):u=v)}if(u)if(d){d.sort(Vx);for(let v=0;v<d.length;v++)n(d[v],c,!!a)}else n(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<t.childCount)h=c,f=t.child(c++);else break;for(let v=0;v<l.length;v++)l[v].to<=s&&l.splice(v--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let p=s+f.nodeSize;if(f.isText){let v=p;o<i.length&&i[o].from<v&&(v=i[o].from);for(let w=0;w<l.length;w++)l[w].to<v&&(v=l[w].to);v<p&&(a=f.cut(v-s),f=f.cut(0,v-s),p=v,h=-1)}else for(;o<i.length&&i[o].to<p;)o++;let g=f.isInline&&!f.isLeaf?l.filter(v=>!v.inline):l.slice();r(f,g,e.forChild(s,f),h),s=p}}function Wx(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 qx(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let o=t.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;i<t.childCount;){let c=t.child(i++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=n){if(s>=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 fu(t,e,n,r,i){let s=[];for(let o=0,l=0;o<t.length;o++){let a=t[o],c=l,u=l+=a.size;c>=n||u<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,r)),i&&(s.push(i),i=void 0),u>n&&s.push(a.slice(n-c,a.size,r)))}return s}function hu(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(bl(n)){for(a=l;i&&!i.node;)i=i.parent;let u=i.node;if(i&&u.isAtom&&se.isSelectable(u)&&i.parent&&!(u.isInline&&yx(n.focusNode,n.focusOffset,i.dom))){let d=i.posBefore;c=new se(o==d?l:r.resolve(d))}}else{let u=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(u<0)return null;a=r.resolve(u)}if(!c){let u=e=="pointer"||t.state.selection.head<l.pos&&!s?1:-1;c=mu(t,a,l,u)}return c}function em(t){return t.editable?t.hasFocus():lm(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function nr(t,e=!1){let n=t.state.selection;if(im(t,n),!!em(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&_t){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&ei(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Jx(t);else{let{anchor:r,head:i}=n,s,o;tm&&!(n instanceof ce)&&(n.$from.parent.inlineContent||(s=nm(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=nm(t,n.to))),t.docView.setSelection(r,i,t.root,e),tm&&(s&&rm(s),o&&rm(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Kx(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const tm=Nt||_t&&wx<63;function nm(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(Nt&&i&&i.contentEditable=="false")return pu(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return pu(i);if(s)return pu(s)}}function pu(t){return t.contentEditable="true",Nt&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function rm(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Kx(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!em(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Jx(t){let e=t.domSelection(),n=document.createRange(),r=t.cursorWrapper.dom,i=r.nodeName=="IMG";i?n.setEnd(r.parentNode,Ct(r)+1):n.setEnd(r,0),n.collapse(!1),e.removeAllRanges(),e.addRange(n),!i&&!t.state.selection.visible&&Bt&&Sr<=11&&(r.disabled=!0,r.disabled=!1)}function im(t,e){if(e instanceof se){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(sm(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else sm(t)}function sm(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function mu(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||ce.between(e,n,r)}function om(t){return t.editable&&!t.hasFocus()?!1:lm(t)}function lm(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 Gx(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return ei(e.node,e.offset,n.anchorNode,n.anchorOffset)}function gu(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&ue.findFrom(s,e)}function Ar(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function am(t,e,n){let r=t.state.selection;if(r instanceof ce)if(n.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Ar(t,new ce(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=gu(t.state,e);return i&&i instanceof se?Ar(t,i):!1}else if(!(rn&&n.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?se.isSelectable(s)?Ar(t,new se(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):Zs?Ar(t,new ce(t.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof se&&r.node.isInline)return Ar(t,new ce(e>0?r.$to:r.$from));{let i=gu(t.state,e);return i?Ar(t,i):!1}}}function wl(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function no(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Ui(t,e){return e<0?Yx(t):Xx(t)}function Yx(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(bn&&n.nodeType==1&&r<wl(n)&&no(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(no(l,-1))i=n,s=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(cm(n))break;{let l=n.previousSibling;for(;l&&no(l,-1);)i=n.parentNode,s=Ct(l),l=l.previousSibling;if(l)n=l,r=wl(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?yu(t,n,r):i&&yu(t,i,s)}function Xx(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=wl(n),s,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(no(l,1))s=n,o=++r;else break}else{if(cm(n))break;{let l=n.nextSibling;for(;l&&no(l,1);)s=l.parentNode,o=Ct(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=wl(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&yu(t,s,o)}function cm(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Zx(t,e){for(;t&&e==t.childNodes.length&&!Xs(t);)e=Ct(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 Qx(t,e){for(;t&&!e&&!Xs(t);)e=Ct(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 yu(t,e,n){if(e.nodeType!=3){let s,o;(o=Zx(e,n))?(e=o,n=0):(s=Qx(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(bl(r)){let s=document.createRange();s.setEnd(e,n),s.setStart(e,n),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&nr(t)},50)}function um(t,e){let n=t.state.doc.resolve(e);if(!(_t||xx)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let s=t.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<n.end()){let s=t.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function dm(t,e,n){let r=t.state.selection;if(r instanceof ce&&!r.empty||n.indexOf("s")>-1||rn&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=gu(t.state,e);if(o&&o instanceof se)return Ar(t,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof yn?ue.near(o,e):ue.findFrom(o,e);return l?Ar(t,l):!1}return!1}function fm(t,e){if(!(t.state.selection instanceof ce))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let o=t.state.tr;return e<0?o.delete(n.pos-s.nodeSize,n.pos):o.delete(n.pos,n.pos+s.nodeSize),t.dispatch(o),!0}return!1}function hm(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function ek(t){if(!Nt||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;hm(t,r,"true"),setTimeout(()=>hm(t,r,"false"),20)}return!1}function tk(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function nk(t,e){let n=e.keyCode,r=tk(e);if(n==8||rn&&n==72&&r=="c")return fm(t,-1)||Ui(t,-1);if(n==46&&!e.shiftKey||rn&&n==68&&r=="c")return fm(t,1)||Ui(t,1);if(n==13||n==27)return!0;if(n==37||rn&&n==66&&r=="c"){let i=n==37?um(t,t.state.selection.from)=="ltr"?-1:1:-1;return am(t,i,r)||Ui(t,i)}else if(n==39||rn&&n==70&&r=="c"){let i=n==39?um(t,t.state.selection.from)=="ltr"?1:-1:1;return am(t,i,r)||Ui(t,i)}else{if(n==38||rn&&n==80&&r=="c")return dm(t,-1,r)||Ui(t,-1);if(n==40||rn&&n==78&&r=="c")return ek(t)||dm(t,1,r)||Ui(t,1);if(r==(rn?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function pm(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=t.someProp("clipboardSerializer")||Nn.fromSchema(t.state.schema),l=km(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=wm[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
|
30
|
+
<%s key={someKey} {...props} />`,Nh,Ri,WP,Ri),f1[Ri+Nh]=!0}}return L===r?jP(ct):BP(ct),ct}}function HP(L,K,Q){return h1(L,K,Q,!0)}function zP(L,K,Q){return h1(L,K,Q,!1)}var VP=zP,UP=HP;zs.Fragment=r,zs.jsx=VP,zs.jsxs=UP}()),zs}process.env.NODE_ENV==="production"?Fc.exports=g1():Fc.exports=y1();var _=Fc.exports;const b1=({metaData:t,setMetaData:e,isPreviewMode:n})=>_.jsx("div",{className:"flex items-center gap-4",children:_.jsx("input",{className:"custom-input mx-2 focus:outline-none bg-[#f8f9fa]",disabled:n,type:"text",placeholder:"Untitled",value:t.plugin.title||"",onChange:r=>e({...t,plugin:{...t.plugin,title:r.target.value}})})});function kt(t){this.content=t}kt.prototype={constructor:kt,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,i=r.find(t),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new kt(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new kt(n)},addToStart:function(t,e){return new kt([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new kt(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new kt(i)},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=kt.from(t),t.size?new kt(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=kt.from(t),t.size?new kt(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=kt.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}},kt.from=function(t){if(t instanceof kt)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new kt(e)};function jh(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)n++;return n}if(i.content.size||s.content.size){let o=jh(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function Hh(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let o=t.child(--i),l=e.child(--s),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=Hh(o.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}class W{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,i=0,s){for(let o=0,l=0;l<n;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,i+l,s||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,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",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?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new W(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let s=0,o=0;o<n;s++){let l=this.content[s],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),i+=l.nodeSize),o=a}return new W(r,i)}cutByIndex(e,n){return e==n?W.empty:e==0&&n==this.content.length?this:new W(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new W(i,s)}addToStart(e){return new W([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new W(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 i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return jh(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Hh(this,e,n,r)}findIndex(e,n=-1){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 r=0,i=0;;r++){let s=this.child(r),o=i+s.nodeSize;if(o>=e)return o==e||n>0?rl(r+1,o):rl(r,i);i=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return W.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new W(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return W.empty;let n,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(n||(n=e.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new W(n||e,r)}static from(e){if(!e)return W.empty;if(e instanceof W)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new W([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}W.empty=new W([],0);const $c={index:0,offset:0};function rl(t,e){return $c.index=t,$c.offset=e,$c}function il(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(!il(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!il(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Pe=class Dh{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;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&&il(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`);return r.create(n.attrs)}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 Dh.none;if(e instanceof Dh)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Pe.none=[];class sl extends Error{}class Y{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=Vh(this.content,e+this.openStart,n);return r&&new Y(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Y(zh(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 Y.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Y(W.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new Y(e,r,i)}}Y.empty=new Y(W.empty,0,0);function zh(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||s.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,s.copy(zh(s.content,e-i-1,n-i-1)))}function Vh(t,e,n,r){let{index:i,offset:s}=t.findIndex(e),o=t.maybeChild(i);if(s==e||o.isText)return t.cut(0,e).append(n).append(t.cut(e));let l=Vh(o.content,e-s-1,n);return l&&t.replaceChild(i,o.copy(l))}function v1(t,e,n){if(n.openStart>t.depth)throw new sl("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new sl("Inconsistent open depths");return Uh(t,e,n,0)}function Uh(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=Uh(t,e,n,r+1);return s.copy(s.content.replaceChild(i,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 Xr(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=w1(n,t);return Xr(s,qh(t,o,l,e,r))}else return Xr(s,ol(t,e,r))}function Wh(t,e){if(!e.type.compatibleContent(t.type))throw new sl("Cannot join "+e.type.name+" onto "+t.type.name)}function Bc(t,e,n){let r=t.node(n);return Wh(r,e.node(n)),r}function Yr(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 i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(Yr(t.nodeAfter,r),s++));for(let l=s;l<o;l++)Yr(i.child(l),r);e&&e.depth==n&&e.textOffset&&Yr(e.nodeBefore,r)}function Xr(t,e){return t.type.checkContent(e),t.copy(e)}function qh(t,e,n,r,i){let s=t.depth>i&&Bc(t,e,i+1),o=r.depth>i&&Bc(n,r,i+1),l=[];return Vs(null,t,i,l),s&&o&&e.index(i)==n.index(i)?(Wh(s,o),Yr(Xr(s,qh(t,e,n,r,i+1)),l)):(s&&Yr(Xr(s,ol(t,e,i+1)),l),Vs(e,n,i,l),o&&Yr(Xr(o,ol(n,r,i+1)),l)),Vs(r,null,i,l),new W(l)}function ol(t,e,n){let r=[];if(Vs(null,t,n,r),t.depth>n){let i=Bc(t,e,n+1);Yr(Xr(i,ol(t,e,n+1)),r)}return Vs(e,null,n,r),new W(r)}function w1(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(W.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class Us{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Pe.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].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 ll(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=[],i=0,s=n;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(r.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new Us(n,r,s)}static resolveCached(e,n){for(let i=0;i<jc.length;i++){let s=jc[i];if(s.pos==n&&s.doc==e)return s}let r=jc[Hc]=Us.resolve(e,n);return Hc=(Hc+1)%x1,r}}let jc=[],Hc=0,x1=12;class ll{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 k1=Object.create(null);let Zr=class Rh{constructor(e,n,r,i=Pe.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||W.empty}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,i=0){this.content.nodesBetween(e,n,r,i,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,i){return this.content.textBetween(e,n,r,i)}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&&il(this.attrs,n||e.defaultAttrs||k1)&&Pe.sameSet(this.marks,r||Pe.none)}copy(e=null){return e==this.content?this:new Rh(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Rh(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 Y.empty;let i=this.resolve(e),s=this.resolve(n),o=r?0:i.sharedDepth(n),l=i.start(o),c=i.node(o).content.cut(i.pos-l,s.pos-l);return new Y(c,i.depth-o,s.depth-o)}replace(e,n,r){return v1(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+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 i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return Us.resolveCached(this,e)}resolveNoCache(e){return Us.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Kh(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=W.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.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);let e=Pe.none;for(let n=0;n<this.marks.length;n++)e=this.marks[n].addToSet(e);if(!Pe.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=null;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=W.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,i,r)}};Zr.prototype.text=void 0;class al extends Zr{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Kh(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 al(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new al(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 Kh(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Qr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new C1(e,n);if(r.next==null)return Qr.empty;let i=Jh(r);r.next&&r.err("Unexpected trailing text");let s=_1(O1(i));return N1(s,r),s}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 i=this;for(let s=n;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}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 i=[this];function s(o,l){let a=o.matchFragment(e,r);if(a&&(!n||a.validEnd))return W.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())&&i.indexOf(d)==-1){i.push(d);let f=s(d,l.concat(u));if(f)return f}}return null}return s(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 i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),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 i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
|
31
|
+
`)}}Qr.empty=new Qr(!0);class C1{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 Jh(t){let e=[];do e.push(S1(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function S1(t){let e=[];do e.push(E1(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function E1(t){let e=M1(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=T1(t,e);else break;return e}function Gh(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function T1(t,e){let n=Gh(t),r=n;return t.eat(",")&&(t.next!="}"?r=Gh(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function A1(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let o=n[s];o.groups.indexOf(e)>-1&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function M1(t){if(t.eat("(")){let e=Jh(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=A1(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 O1(t){let e=[[]];return i(s(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 i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=n())}else if(o.type=="star"){let a=n();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=n();return i(s(o.expr,l),a),i(s(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=n();i(s(o.expr,a),u),a=u}if(o.max==-1)i(s(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=n();r(a,u),i(s(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 Yh(t,e){return e-t}function Xh(t,e){let n=[];return r(e),n.sort(Yh);function r(i){let s=t[i];if(s.length==1&&!s[0].term)return r(s[0].to);n.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&n.indexOf(a)==-1&&r(a)}}}function _1(t){let e=Object.create(null);return n(Xh(t,0));function n(r){let i=[];r.forEach(o=>{t[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<i.length;u++)i[u][0]==l&&(c=i[u][1]);Xh(t,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new Qr(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Yh);s.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return s}}function N1(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Zh(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 Qh(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let s=t[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function ep(t){let e=Object.create(null);if(t)for(let n in t)e[n]=new D1(t[n]);return e}let tp=class p1{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=ep(r.attrs),this.defaultAttrs=Zh(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==Qr.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}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:Qh(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Zr(this,this.computeAttrs(e),W.from(n),Pe.setFrom(r))}createChecked(e=null,n,r){return n=W.from(n),this.checkContent(n),new Zr(this,this.computeAttrs(e),n,Pe.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=W.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(W.empty,!0);return s?new Zr(this,e,n.append(s),Pe.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)}`)}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:Pe.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,o)=>r[s]=new p1(s,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class D1{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class cl{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=ep(i.attrs),this.excluded=null;let s=Zh(this.attrs);this.instance=s?new Pe(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Pe(this,Qh(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new cl(s,i++,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]}excludes(e){return this.excluded.indexOf(e)>-1}}class R1{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=kt.from(e.nodes),n.marks=kt.from(e.marks||{}),this.nodes=tp.compile(this.spec.nodes,this),this.marks=cl.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=Qr.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?np(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:np(this,o.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof tp){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new al(r,r.defaultAttrs,e,Pe.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeFromJSON(e){return Zr.fromJSON(this,e)}markFromJSON(e){return Pe.fromJSON(this,e)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function np(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],o=s;if(s)n.push(s);else for(let l in t.marks){let a=t.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function L1(t){return t.tag!=null}function I1(t){return t.style!=null}let zc=class Lh{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[],n.forEach(r=>{L1(r)?this.tags.push(r):I1(r)&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let i=e.nodes[r.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new op(this,n,!1);return r.addAll(e,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new op(this,n,!0);return r.addAll(e,n.from,n.to),Y.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if($1(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,n,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],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(i){let s=i.priority==null?50:i.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<s)break}n.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=lp(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=lp(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Lh(e,Lh.schemaRules(e)))}};const rp={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},P1={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ip={ol:!0,ul:!0},ul=1,dl=2,Ws=4;function sp(t,e,n){return e!=null?(e?ul:0)|(e==="full"?dl:0):t&&t.whitespace=="pre"?ul|dl:n&~Ws}class fl{constructor(e,n,r,i,s,o,l){this.type=e,this.attrs=n,this.marks=r,this.pendingMarks=i,this.solid=s,this.options=l,this.content=[],this.activeMarks=Pe.none,this.stashMarks=[],this.match=o||(l&Ws?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(W.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ul)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let n=W.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(W.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}popFromStashMark(e){for(let n=this.stashMarks.length-1;n>=0;n--)if(e.eq(this.stashMarks[n]))return this.stashMarks.splice(n,1)[0]}applyPending(e){for(let n=0,r=this.pendingMarks;n<r.length;n++){let i=r[n];(this.type?this.type.allowsMarkType(i.type):B1(i.type,e))&&!i.isInSet(this.activeMarks)&&(this.activeMarks=i.addToSet(this.activeMarks),this.pendingMarks=i.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!rp.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class op{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0;let i=n.topNode,s,o=sp(null,n.preserveWhitespace,0)|(r?Ws:0);i?s=new fl(i.type,i.attrs,Pe.none,Pe.none,!0,n.topMatch||i.type.contentMatch,o):r?s=new fl(null,null,Pe.none,Pe.none,!0,null,o):s=new fl(e.schema.topNodeType,null,Pe.none,Pe.none,!0,null,o),this.nodes=[s],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){e.nodeType==3?this.addTextNode(e):e.nodeType==1&&this.addElement(e)}withStyleRules(e,n){let r=e.style;if(!r||!r.length)return n();let i=this.readStyles(e.style);if(!i)return;let[s,o]=i,l=this.top;for(let a=0;a<o.length;a++)this.removePendingMark(o[a],l);for(let a=0;a<s.length;a++)this.addPendingMark(s[a]);n();for(let a=0;a<s.length;a++)this.removePendingMark(s[a],l);for(let a=0;a<o.length;a++)this.addPendingMark(o[a])}addTextNode(e){let n=e.nodeValue,r=this.top;if(r.options&dl||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(r.options&ul)r.options&dl?n=n.replace(/\r\n?/g,`
|
32
|
+
`):n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let i=r.content[r.content.length-1],s=e.previousSibling;(!i||s&&s.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n)),this.findInText(e)}else this.findInside(e)}addElement(e,n){let r=e.nodeName.toLowerCase(),i;ip.hasOwnProperty(r)&&this.parser.normalizeLists&&F1(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,n));if(s?s.ignore:P1.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let o,l=this.top,a=this.needsBlock;if(rp.hasOwnProperty(r))l.content.length&&l.content[0].isInline&&this.open&&(this.open--,l=this.top),o=!0,l.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e);return}s&&s.skip?this.addAll(e):this.withStyleRules(e,()=>this.addAll(e)),o&&this.sync(l),this.needsBlock=a}else this.withStyleRules(e,()=>{this.addElementByRule(e,s,s.consuming===!1?i:void 0)})}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
33
|
+
`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let n=Pe.none,r=Pe.none;for(let i=0,s=e.length;i<s;i++){let o=e.item(i);for(let l=void 0;;){let a=this.parser.matchStyle(o,e.getPropertyValue(o),this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?this.top.pendingMarks.concat(this.top.activeMarks).forEach(c=>{a.clearMark(c)&&(r=c.addToSet(r))}):n=this.parser.schema.marks[a.mark].create(a.attrs).addToSet(n),a.consuming===!1)l=a;else break}}return[n,r]}addElementByRule(e,n,r){let i,s,o;n.node?(s=this.parser.schema.nodes[n.node],s.isLeaf?this.insertNode(s.create(n.attrs))||this.leafFallback(e):i=this.enter(s,n.attrs||null,n.preserveWhitespace)):(o=this.parser.schema.marks[n.mark].create(n.attrs),this.addPendingMark(o));let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));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)}i&&this.sync(l)&&this.open--,o&&this.removePendingMark(o,l)}addAll(e,n,r){let i=n||0;for(let s=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];s!=o;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s);this.findAtPoint(e,i)}findPlace(e){let n,r;for(let i=this.open;i>=0;i--){let s=this.nodes[i],o=s.findWrapping(e);if(o&&(!n||n.length>o.length)&&(n=o,r=s,!o.length)||s.solid)break}if(!n)return!1;this.sync(r);for(let i=0;i<n.length;i++)this.enterInner(n[i],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let n=this.textblockFromContext();n&&this.enterInner(n)}if(this.findPlace(e)){this.closeExtra();let n=this.top;n.applyPending(e.type),n.match&&(n.match=n.match.matchType(e.type));let r=n.activeMarks;for(let i=0;i<e.marks.length;i++)(!n.type||n.type.allowsMarkType(e.marks[i].type))&&(r=e.marks[i].addToSet(r));return n.content.push(e.mark(r)),!0}return!1}enter(e,n,r){let i=this.findPlace(e.create(n));return i&&this.enterInner(e,n,!0,r),i}enterInner(e,n=null,r=!1,i){this.closeExtra();let s=this.top;s.applyPending(e),s.match=s.match&&s.match.matchType(e);let o=sp(e,i,s.options);s.options&Ws&&s.content.length==0&&(o|=Ws),this.nodes.push(new fl(e,n,s.activeMarks,s.pendingMarks,r,null,o)),this.open++}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;return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<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 i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].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,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?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>=s;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&i?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&u.groups.indexOf(c)==-1)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}}addPendingMark(e){let n=j1(e,this.top.pendingMarks);n&&this.top.stashMarks.push(n),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,n){for(let r=this.open;r>=0;r--){let i=this.nodes[r];if(i.pendingMarks.lastIndexOf(e)>-1)i.pendingMarks=e.removeFromSet(i.pendingMarks);else{i.activeMarks=e.removeFromSet(i.activeMarks);let o=i.popFromStashMark(e);o&&i.type&&i.type.allowsMarkType(o.type)&&(i.activeMarks=o.addToSet(i.activeMarks))}if(i==n)break}}}function F1(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&ip.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function $1(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function lp(t){let e={};for(let n in t)e[n]=t[n];return e}function B1(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&o(u))return!0}};if(o(i.contentMatch))return!0}}function j1(t,e){for(let n=0;n<e.length;n++)if(t.eq(e[n]))return e[n]}class Nn{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Vc(n).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,n);u&&(s.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:i}=Nn.renderSpec(Vc(n),this.nodes[e.type.name](e));if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Nn.renderSpec(Vc(r),i(e,n))}static renderSpec(e,n,r=null){if(typeof n=="string")return{dom:e.createTextNode(n)};if(n.nodeType!=null)return{dom:n};if(n.dom&&n.dom.nodeType!=null)return n;let i=n[0],s=i.indexOf(" ");s>0&&(r=i.slice(0,s),i=i.slice(s+1));let o,l=r?e.createElementNS(r,i):e.createElement(i),a=n[1],c=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){c=2;for(let u in a)if(a[u]!=null){let d=u.indexOf(" ");d>0?l.setAttributeNS(u.slice(0,d),u.slice(d+1),a[u]):l.setAttribute(u,a[u])}}for(let u=c;u<n.length;u++){let d=n[u];if(d===0){if(u<n.length-1||u>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:f,contentDOM:h}=Nn.renderSpec(e,d,r);if(l.appendChild(f),h){if(o)throw new RangeError("Multiple content holes");o=h}}}return{dom:l,contentDOM:o}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Nn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=ap(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return ap(e.marks)}}function ap(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Vc(t){return t.document||window.document}const cp=65535,up=Math.pow(2,16);function H1(t,e){return t+e*up}function dp(t){return t&cp}function z1(t){return(t-(t&cp))/up}const fp=1,hp=2,hl=4,pp=8;class Uc{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&pp)>0}get deletedBefore(){return(this.delInfo&(fp|hl))>0}get deletedAfter(){return(this.delInfo&(hp|hl))>0}get deletedAcross(){return(this.delInfo&hl)>0}}class Kt{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Kt.empty)return Kt.empty}recover(e){let n=0,r=dp(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+z1(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 i=0,s=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?i:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+o],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:n:n,h=a+i+(f<0?0:u);if(r)return h;let p=e==(n<0?a:d)?null:H1(l/3,e-a),g=e==a?hp:e==d?fp:hl;return(n<0?e!=a:e!=d)&&(g|=pp),new Uc(h,g,p)}i+=u-c}return r?e+i:new Uc(e+i,0,null)}touches(e,n){let r=0,i=dp(n),s=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+s],u=a+c;if(e<=u&&l==i*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 i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+n],u=this.ranges[i+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new Kt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Kt.empty:new Kt(e<0?[0,-e,0]:[0,0,e])}}Kt.empty=new Kt([]);class Li{constructor(e=[],n,r=0,i=e.length){this.maps=e,this.mirror=n,this.from=r,this.to=i}slice(e=0,n=this.maps.length){return new Li(this.maps,this.mirror,e,n)}copy(){return new Li(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,n){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 i=e.getMirror(n);this.appendMap(e.maps[n],i!=null&&i<n?r+i: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 i=e.getMirror(n);this.appendMap(e.maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new Li;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 i=0;for(let s=this.from;s<this.to;s++){let o=this.maps[s],l=o.mapResult(e,n);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this.maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new Uc(e,i,null)}}const Wc=Object.create(null);class Tt{getMap(){return Kt.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Wc[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 Wc)throw new RangeError("Duplicate use of step JSON ID "+e);return Wc[e]=n,n.prototype.jsonID=e,n}}class ot{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ot(e,null)}static fail(e){return new ot(null,e)}static fromReplace(e,n,r,i){try{return ot.ok(e.replace(n,r,i))}catch(s){if(s instanceof sl)return ot.fail(s.message);throw s}}}function qc(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(qc(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return W.fromArray(r)}class wr extends Tt{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),i=r.node(r.sharedDepth(this.to)),s=new Y(qc(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return ot.fromReplace(e,this.from,this.to,s)}invert(){return new Dn(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 wr(n.pos,r.pos,this.mark)}merge(e){return e instanceof wr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new wr(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 wr(n.from,n.to,e.markFromJSON(n.mark))}}Tt.jsonID("addMark",wr);class Dn extends Tt{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 Y(qc(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return ot.fromReplace(e,this.from,this.to,r)}invert(){return new wr(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 Dn(n.pos,r.pos,this.mark)}merge(e){return e instanceof Dn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Dn(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 Dn(n.from,n.to,e.markFromJSON(n.mark))}}Tt.jsonID("removeMark",Dn);class xr extends Tt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ot.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ot.fromReplace(e,this.pos,this.pos+1,new Y(W.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new xr(this.pos,n.marks[i]);return new xr(this.pos,this.mark)}}return new Ii(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new xr(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 xr(n.pos,e.markFromJSON(n.mark))}}Tt.jsonID("addNodeMark",xr);class Ii extends Tt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ot.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ot.fromReplace(e,this.pos,this.pos+1,new Y(W.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new xr(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ii(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 Ii(n.pos,e.markFromJSON(n.mark))}}Tt.jsonID("removeNodeMark",Ii);class ht extends Tt{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&Kc(e,this.from,this.to)?ot.fail("Structure replace would overwrite content"):ot.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Kt([this.from,this.to-this.from,this.slice.size])}invert(e){return new ht(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 ht(n.pos,Math.max(n.pos,r.pos),this.slice)}merge(e){if(!(e instanceof ht)||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?Y.empty:new Y(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ht(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?Y.empty:new Y(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ht(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 ht(n.from,n.to,Y.fromJSON(e,n.slice),!!n.structure)}}Tt.jsonID("replace",ht);class pt extends Tt{constructor(e,n,r,i,s,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Kc(e,this.from,this.gapFrom)||Kc(e,this.gapTo,this.to)))return ot.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ot.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?ot.fromReplace(e,this.from,this.to,r):ot.fail("Content does not fit in gap")}getMap(){return new Kt([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 pt(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),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||s>r.pos?null:new pt(n.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new pt(n.from,n.to,n.gapFrom,n.gapTo,Y.fromJSON(e,n.slice),n.insert,!!n.structure)}}Tt.jsonID("replaceAround",pt);function Kc(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function V1(t,e,n,r){let i=[],s=[],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 f=Math.max(c,e),h=Math.min(c+a.nodeSize,n),p=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(p)||(o&&o.to==f&&o.mark.eq(d[g])?o.to=h:i.push(o=new Dn(f,h,d[g])));l&&l.to==f?l.to=h:s.push(l=new wr(f,h,r))}}),i.forEach(a=>t.step(a)),s.forEach(a=>t.step(a))}function U1(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof cl){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],f;for(let h=0;h<i.length;h++){let p=i[h];p.step==s-1&&d.eq(i[h].style)&&(f=p)}f?(f.to=c,f.step=s):i.push({style:d,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>t.step(new Dn(o.from,o.to,o.style)))}function mp(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new ht(l,u,Y.empty));else{r=d;for(let f=0;f<c.marks.length;f++)n.allowsMarkType(c.marks[f].type)||t.step(new Dn(l,u,c.marks[f]));if(i&&c.isText&&n.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new Y(W.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),o.push(new ht(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(W.empty,!0);t.replace(l,l,new Y(a,0,0))}for(let a=o.length-1;a>=0;a--)t.step(o[a])}function W1(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Pi(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let i=t.$from.node(r),s=t.$from.index(r),o=t.$to.indexAfter(r);if(r<t.depth&&i.canReplace(s,o,n))return r;if(r==0||i.type.spec.isolating||!W1(i,s,o))break}return null}function q1(t,e,n){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),a=o,c=l,u=W.empty,d=0;for(let p=s,g=!1;p>n;p--)g||r.index(p)>0?(g=!0,u=W.from(r.node(p).copy(u)),d++):a--;let f=W.empty,h=0;for(let p=s,g=!1;p>n;p--)g||i.after(p+1)<i.end(p)?(g=!0,f=W.from(i.node(p).copy(f)),h++):c++;t.step(new pt(a,c,o,l,new Y(u.append(f),d,h),u.size-d,!0))}function Jc(t,e,n=null,r=t){let i=K1(t,e),s=i&&J1(r,e);return s?i.map(gp).concat({type:e,attrs:n}).concat(s.map(gp)):null}function gp(t){return{type:t,attrs:null}}function K1(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return n.canReplaceWith(r,i,o)?s:null}function J1(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<i;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:o}function G1(t,e,n){let r=W.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=W.from(n[o].type.create(n[o].attrs,r))}let i=e.start,s=e.end;t.step(new pt(i,s,i,s,new Y(r,0,0),n.length,!0))}function Y1(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{if(o.isTextblock&&!o.hasMarkup(r,i)&&Q1(t.doc,t.mapping.slice(s).map(l),r)){let a=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!h?a=!1:!f&&h&&(a=!0)}a===!1&&Z1(t,o,l,s),mp(t,t.mapping.slice(s).map(l,1),r,void 0,a===null);let c=t.mapping.slice(s),u=c.map(l,1),d=c.map(l+o.nodeSize,1);return t.step(new pt(u,d,u+1,d-1,new Y(W.from(r.create(i,null,o.marks)),0,0),1,!0)),a===!0&&X1(t,o,l,s),!1}})}function X1(t,e,n,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=t.mapping.slice(r).map(n+1+s+o.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Z1(t,e,n,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+s);t.replaceWith(o,o+1,e.type.schema.text(`
|
34
|
+
`))}})}function Q1(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function ex(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new pt(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new Y(W.from(o),0,0),1,!0))}function Fi(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=n-2;c>s;c--,u--){let d=i.node(c),f=i.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!g.type.validContent(h))return!1}let l=i.indexAfter(s),a=r&&r[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function tx(t,e,n=1,r){let i=t.doc.resolve(e),s=W.empty,o=W.empty;for(let l=i.depth,a=i.depth-n,c=n-1;l>a;l--,c--){s=W.from(i.node(l).copy(s));let u=r&&r[c];o=W.from(u?u.type.create(u.attrs,o):i.node(l).copy(o))}t.step(new ht(e,e,new Y(s.append(o),n,n),!0))}function kr(t,e){let n=t.resolve(e),r=n.index();return yp(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function yp(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}function pl(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let s,o,l=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):n>0?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&yp(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function nx(t,e,n){let r=new ht(e-n,e+n,Y.empty,!0);t.step(r)}function rx(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,n))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,n))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function bp(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let s=0;s<n.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)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(s==1)u=c.canReplace(a,a,i);else{let d=c.contentMatchAt(a).findWrapping(i.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 ml(t,e,n=e,r=Y.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return vp(i,s,r)?new ht(e,n,r):new ix(i,s,r).fit()}function vp(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class ix{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=W.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=W.from(e.node(i).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,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new Y(s,o,l);return e>-1?new pt(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new ht(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=n.firstChild;if(n.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Gc(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.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(W.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:d};if(n==2&&o&&(u=c.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Gc(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Y(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Gc(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new Y(qs(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new Y(qs(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let g=0;g<s.length;g++)this.openFrontierNode(s[g]);let o=this.unplaced,l=r?r.content:o.content,a=o.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[n];if(i){for(let g=0;g<i.childCount;g++)u.push(i.child(g));d=d.matchFragment(i)}let h=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let g=l.child(c),v=d.matchType(g.type);if(!v)break;c++,(c>1||a==0||g.content.size)&&(d=v,u.push(wp(g.mark(f.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=Ks(this.placed,n,W.from(u)),this.frontier[n].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,v=l;g<h;g++){let w=v.lastChild;this.frontier.push({type:w.type,match:w.contentMatchAt(w.childCount)}),v=w.content}this.unplaced=p?e==0?Y.empty:new Y(qs(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new Y(qs(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||!Yc(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,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],s=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=Yc(e,n,i,r,s);if(o){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Yc(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:o,move:s?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Ks(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Ks(this.placed,this.depth,W.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(W.empty,!0);n.childCount&&(this.placed=Ks(this.placed,this.frontier.length,n))}}function qs(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(qs(t.firstChild.content,e-1,n)))}function Ks(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Ks(t.lastChild.content,e-1,n)))}function Gc(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function wp(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,wp(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(W.empty,!0)))),t.copy(r)}function Yc(t,e,n,r,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!sx(n,s.content,o)?l:null}function sx(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function ox(t){return t.spec.defining||t.spec.definingForContent}function lx(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(vp(i,s,r))return t.step(new ht(e,n,r));let o=kp(i,t.doc.resolve(n));o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let f=i.depth,h=i.pos-1;f>0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;o.indexOf(f)>-1?l=f:i.before(f)==h&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=ox(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let g=0;g<o.length;g++){let v=o[(g+a)%o.length],w=!0;v<0&&(w=!1,v=-v);let S=i.node(v-1),x=i.index(v-1);if(S.canReplaceWith(x,x,p.type,p.marks))return t.replace(i.before(v),w?s.after(v):n,new Y(xp(r.content,0,r.openStart,h),h,r.openEnd))}}let d=t.steps.length;for(let f=o.length-1;f>=0&&(t.replace(e,n,r),!(t.steps.length>d));f--){let h=o[f];h<0||(e=i.before(h),n=s.after(h))}}function xp(t,e,n,r,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(xp(s.content,e+1,n,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(t).append(t);t=o.append(s.matchFragment(o).fillBefore(W.empty,!0))}return t}function ax(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=rx(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Y(W.from(r),0,0))}function cx(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),s=kp(r,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),i.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o)return t.delete(r.before(o),n);t.delete(e,n)}function kp(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let s=t.start(i);if(s<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&n.push(i)}return n}class $i extends Tt{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 ot.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return ot.fromReplace(e,this.pos,this.pos+1,new Y(W.from(i),0,n.isLeaf?0:1))}getMap(){return Kt.empty}invert(e){return new $i(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 $i(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 $i(n.pos,n.attr,n.value)}}Tt.jsonID("attr",$i);class Js extends Tt{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return ot.ok(r)}getMap(){return Kt.empty}invert(e){return new Js(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 Js(n.attr,n.value)}}Tt.jsonID("docAttr",Js);let Bi=class extends Error{};Bi=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},Bi.prototype=Object.create(Error.prototype),Bi.prototype.constructor=Bi,Bi.prototype.name="TransformError";class Xc{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Li}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Bi(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=Y.empty){let i=ml(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Y(W.from(r),0,0))}delete(e,n){return this.replace(e,n,Y.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return lx(this,e,n,r),this}replaceRangeWith(e,n,r){return ax(this,e,n,r),this}deleteRange(e,n){return cx(this,e,n),this}lift(e,n){return q1(this,e,n),this}join(e,n=1){return nx(this,e,n),this}wrap(e,n){return G1(this,e,n),this}setBlockType(e,n=e,r,i=null){return Y1(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return ex(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new $i(e,n,r)),this}setDocAttribute(e,n){return this.step(new Js(e,n)),this}addNodeMark(e,n){return this.step(new xr(e,n)),this}removeNodeMark(e,n){if(!(n instanceof Pe)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n=n.isInSet(r.marks),!n)return this}return this.step(new Ii(e,n)),this}split(e,n=1,r){return tx(this,e,n,r),this}addMark(e,n,r){return V1(this,e,n,r),this}removeMark(e,n,r){return U1(this,e,n,r),this}clearIncompatible(e,n,r){return mp(this,e,n,r),this}}const Zc=Object.create(null);class ue{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Qc(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=Y.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let s=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(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?Y.empty:n),l==0&&Ep(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(r),c=a.map(o.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),Ep(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new ce(e):ji(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=n<0?ji(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):ji(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new yn(e.node(0))}static atStart(e){return ji(e,e,0,0,1)||new yn(e)}static atEnd(e){return ji(e,e,e.content.size,e.childCount,-1)||new yn(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Zc[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 Zc)throw new RangeError("Duplicate use of selection JSON ID "+e);return Zc[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ce.between(this.$anchor,this.$head).getBookmark()}}ue.prototype.visible=!0;class Qc{constructor(e,n){this.$from=e,this.$to=n}}let Cp=!1;function Sp(t){!Cp&&!t.parent.inlineContent&&(Cp=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ce extends ue{constructor(e,n=e){Sp(e),Sp(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 ue.near(r);let i=e.resolve(n.map(this.anchor));return new ce(i.parent.inlineContent?i:r,r)}replace(e,n=Y.empty){if(super.replace(e,n),n==Y.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof ce&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new gl(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 ce(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let s=ue.findFrom(n,r,!0)||ue.findFrom(n,-r,!0);if(s)n=s.$head;else return ue.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(ue.findFrom(e,-r,!0)||ue.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new ce(e,n)}}ue.jsonID("text",ce);class gl{constructor(e,n){this.anchor=e,this.head=n}map(e){return new gl(e.map(this.anchor),e.map(this.head))}resolve(e){return ce.between(e.resolve(this.anchor),e.resolve(this.head))}}class se extends ue{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:i}=n.mapResult(this.anchor),s=e.resolve(i);return r?ue.near(s):new se(s)}content(){return new Y(W.from(this.node),0,0)}eq(e){return e instanceof se&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new eu(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new se(e.resolve(n.anchor))}static create(e,n){return new se(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}se.prototype.visible=!1,ue.jsonID("node",se);class eu{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new gl(r,r):new eu(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&se.isSelectable(r)?new se(n):ue.near(n)}}class yn extends ue{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Y.empty){if(n==Y.empty){e.delete(0,e.doc.content.size);let r=ue.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new yn(e)}map(e){return new yn(e)}eq(e){return e instanceof yn}getBookmark(){return ux}}ue.jsonID("all",yn);const ux={map(){return this},resolve(t){return new yn(t)}};function ji(t,e,n,r,i,s=!1){if(e.inlineContent)return ce.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&se.isSelectable(l))return se.create(t,n-(i<0?l.nodeSize:0))}else{let a=ji(t,l,n+i,i<0?l.childCount:0,i,s);if(a)return a}n+=l.nodeSize*i}return null}function Ep(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof ht||i instanceof pt))return;let s=t.mapping.maps[r],o;s.forEach((l,a,c,u)=>{o==null&&(o=u)}),t.setSelection(ue.near(t.doc.resolve(o),n))}const Tp=1,yl=2,Ap=4;let dx=class extends Xc{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|Tp)&~yl,this.storedMarks=null,this}get selectionSet(){return(this.updated&Tp)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=yl,this}ensureMarks(e){return Pe.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&yl)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~yl,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)||Pe.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),r=r??n,!e)return this.deleteRange(n,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(n);s=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,s)),this.selection.empty||this.setSelection(ue.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|=Ap,this}get scrolledIntoView(){return(this.updated&Ap)>0}};function Mp(t,e){return!e||!t?t:t.bind(e)}class Gs{constructor(e,n,r){this.name=e,this.init=Mp(n.init,r),this.apply=Mp(n.apply,r)}}const fx=[new Gs("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Gs("selection",{init(t,e){return t.selection||ue.atStart(e.doc)},apply(t){return t.selection}}),new Gs("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Gs("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class tu{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=fx.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 Gs(r.key,r.spec.state,r))})}}class Hi{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 i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=i?i[o].n:0,c=i?i[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),!i){i=[];for(let d=0;d<this.config.plugins.length;d++)i.push(d<o?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),s=!0}i&&(i[o]={state:r,n:n.length})}}if(!s)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Hi(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];n[s.name]=s.apply(e,this[s.name],this,n)}return n}get tr(){return new dx(this)}static create(e){let n=new tu(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Hi(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new tu(this.schema,e.plugins),r=n.fields,i=new Hi(n);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]:r[s].init(e,i)}return i}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 i=e[r],s=i.spec.state;s&&s.toJSON&&(n[r]=s.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new tu(e.schema,e.plugins),s=new Hi(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Zr.fromJSON(e.schema,n.doc);else if(o.name=="selection")s.selection=ue.fromJSON(s.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let 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)){s[o.name]=c.fromJSON.call(a,e,n[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function Op(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Op(i,e,{})),n[r]=i}return n}class je{constructor(e){this.spec=e,this.props={},e.props&&Op(e.props,this,this.props),this.key=e.key?e.key.key:_p("plugin")}getState(e){return e[this.key]}}const nu=Object.create(null);function _p(t){return t in nu?t+"$"+ ++nu[t]:(nu[t]=0,t+"$")}class We{constructor(e="key"){this.key=_p(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Ct=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Ys=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let ru=null;const er=function(t,e,n){let r=ru||(ru=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},hx=function(){ru=null},ei=function(t,e,n,r){return n&&(Np(t,e,n,r,-1)||Np(t,e,n,r,1))},px=/^(img|br|input|textarea|hr)$/i;function Np(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Rn(t))){let s=t.parentNode;if(!s||s.nodeType!=1||Xs(t)||px.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ct(t)+(i<0?0:1),t=s}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.contentEditable=="false")return!1;e=i<0?Rn(t):0}else return!1}}function Rn(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function mx(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=Rn(t)}else if(t.parentNode&&!Xs(t))e=Ct(t),t=t.parentNode;else return null}}function gx(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&&!Xs(t))e=Ct(t)+1,t=t.parentNode;else return null}}function yx(t,e,n){for(let r=e==0,i=e==Rn(t);r||i;){if(t==n)return!0;let s=Ct(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,i=i&&s==Rn(t)}}function Xs(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 bl=function(t){return t.focusNode&&ei(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function ti(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function bx(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function vx(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:r.offset}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:r.startOffset}}}const Ln=typeof navigator<"u"?navigator:null,Dp=typeof document<"u"?document:null,Cr=Ln&&Ln.userAgent||"",iu=/Edge\/(\d+)/.exec(Cr),Rp=/MSIE \d/.exec(Cr),su=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Cr),Bt=!!(Rp||su||iu),Sr=Rp?document.documentMode:su?+su[1]:iu?+iu[1]:0,bn=!Bt&&/gecko\/(\d+)/i.test(Cr);bn&&+(/Firefox\/(\d+)/.exec(Cr)||[0,0])[1];const ou=!Bt&&/Chrome\/(\d+)/.exec(Cr),_t=!!ou,wx=ou?+ou[1]:0,Nt=!Bt&&!!Ln&&/Apple Computer/.test(Ln.vendor),zi=Nt&&(/Mobile\/\w+/.test(Cr)||!!Ln&&Ln.maxTouchPoints>2),rn=zi||(Ln?/Mac/.test(Ln.platform):!1),xx=Ln?/Win/.test(Ln.platform):!1,vn=/Android \d/.test(Cr),Zs=!!Dp&&"webkitFontSmoothing"in Dp.documentElement.style,kx=Zs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Cx(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 tr(t,e){return typeof t=="number"?t:t[e]}function Sx(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 Lp(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=n||t.dom;o;o=Ys(o)){if(o.nodeType!=1)continue;let l=o,a=l==s.body,c=a?Cx(s):Sx(l),u=0,d=0;if(e.top<c.top+tr(r,"top")?d=-(c.top-e.top+tr(i,"top")):e.bottom>c.bottom-tr(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+tr(i,"top")-c.top:e.bottom-c.bottom+tr(i,"bottom")),e.left<c.left+tr(r,"left")?u=-(c.left-e.left+tr(i,"left")):e.right>c.right-tr(r,"right")&&(u=e.right-c.right+tr(i,"right")),u||d)if(a)s.defaultView.scrollBy(u,d);else{let f=l.scrollLeft,h=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let p=l.scrollLeft-f,g=l.scrollTop-h;e={left:e.left-p,top:e.top-g,right:e.right-p,bottom:e.bottom-g}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(o).position))break}}function Ex(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(s,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:Ip(t.dom)}}function Ip(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Ys(r));return e}function Tx({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Pp(n,r==0?0:r-e)}function Pp(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:s}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let Vi=null;function Ax(t){if(t.setActive)return t.setActive();if(Vi)return t.focus(Vi);let e=Ip(t);t.focus(Vi==null?{get preventScroll(){return Vi={preventScroll:!0},!0}}:void 0),Vi||(Vi=!1,Pp(e,0))}function Fp(t,e){let n,r=2e8,i,s=0,o=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=er(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];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=u,r=g,i=g&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&g&&(s=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)&&(s=d+1)}}return!n&&a&&(n=a,i=c,r=0),n&&n.nodeType==3?Mx(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:Fp(n,i)}function Mx(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let s=Er(r,1);if(s.top!=s.bottom&&lu(e,s))return{node:t,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:t,offset:0}}function lu(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function Ox(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function _x(t,e,n){let{node:r,offset:i}=Fp(e,n),s=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}function Nx(t,e,n,r){let i=-1;for(let s=e,o=!1;s!=t.dom;){let l=t.docView.nearestDesc(s,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!o&&a.left>r.left||a.top>r.top?i=l.posBefore:(!o&&a.right<r.left||a.bottom<r.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<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}s=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function $p(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let o=t.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(lu(e,c))return $p(o,e,c)}}if((s=(s+1)%r)==i)break}return t}function Dx(t,e){let n=t.dom.ownerDocument,r,i=0,s=vx(n,e.left,e.top);s&&({node:r,offset:i}=s);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(!lu(e,c)||(o=$p(t.dom,e,c),!o))return null}if(Nt)for(let c=o;r&&c;c=Ys(c))c.draggable&&(r=void 0);if(o=Ox(o,e),r){if(bn&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let u=r.childNodes[i],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&i++}let c;Zs&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=Nx(t,r,i,e))}l==null&&(l=_x(t,o,e));let a=t.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Bp(t){return t.top<t.bottom||t.left<t.right}function Er(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(Bp(r))return r}return Array.prototype.find.call(n,Bp)||t.getBoundingClientRect()}const Rx=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function jp(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),o=Zs||bn;if(r.nodeType==3)if(o&&(Rx.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let a=Er(er(r,i,i),n);if(bn&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let c=Er(er(r,i-1,i-1),-1);if(c.top==a.top){let u=Er(er(r,i,i+1),-1);if(u.top!=a.top)return Qs(u,u.left<c.left)}}return a}else{let a=i,c=i,u=n<0?1:-1;return n<0&&!i?(c++,u=-1):n>=0&&i==r.nodeValue.length?(a--,u=1):n<0?a--:c++,Qs(Er(er(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==Rn(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return au(a.getBoundingClientRect(),!1)}if(s==null&&i<Rn(r)){let a=r.childNodes[i];if(a.nodeType==1)return au(a.getBoundingClientRect(),!0)}return au(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==Rn(r))){let a=r.childNodes[i-1],c=a.nodeType==3?er(a,Rn(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Qs(Er(c,1),!1)}if(s==null&&i<Rn(r)){let a=r.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?er(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return Qs(Er(c,-1),!0)}return Qs(Er(r.nodeType==3?er(r):r,-n),n>=0)}function Qs(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 au(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 Hp(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function Lx(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Hp(t,e,()=>{let{node:s}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=jp(t,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=er(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 Ix=/[\u0590-\u08ac]/;function Px(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=t.domSelection();return!Ix.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?s:o:Hp(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",n,"character");let h=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:g}=t.domSelectionRange(),v=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==g;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),v})}let zp=null,Vp=null,Up=!1;function Fx(t,e,n){return zp==e&&Vp==n?Up:(zp=e,Vp=n,Up=n=="up"||n=="down"?Lx(t,e,n):Px(t,e,n))}const sn=0,Wp=1,ni=2,In=3;class eo{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=sn,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 i=this.children[n];if(i==e)return r;r+=i.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 s,o;if(e==this.contentDOM)s=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>Ct(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!n||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)i=i.children[0];return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.size;if(l>e||o instanceof Jp){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof qp&&s.side>=0;r--);if(n<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&n&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?Ct(s.dom)+1:0}}else{let s,o=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,n):{node:this.contentDOM,offset:s?Ct(s.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 i=-1,s=-1;for(let o=r,l=0;;l++){let a=this.children[l],c=o+a.size;if(i==-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 f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=Ct(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-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)){s=Ct(d.dom);break}n+=d.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:s}}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,i=!1){let s=Math.min(e,n),o=Math.max(e,n);for(let f=0,h=0;f<this.children.length;f++){let p=this.children[f],g=h+p.size;if(s>h&&o<g)return p.setSelection(e-h-p.border,n-h-p.border,r,i);h=g}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.getSelection(),u=!1;if((bn||Nt)&&e==n){let{node:f,offset:h}=l;if(f.nodeType==3){if(u=!!(h&&f.nodeValue[h-1]==`
|
35
|
+
`),u&&h==f.nodeValue.length)for(let p=f,g;p;p=p.parentNode){if(g=p.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:Ct(g)+1});break}let v=p.pmViewDesc;if(v&&v.node&&v.node.isBlock)break}}else{let p=f.childNodes[h-1];u=p&&(p.nodeName=="BR"||p.contentEditable=="false")}}if(bn&&c.focusNode&&c.focusNode!=a.node&&c.focusNode.nodeType==1){let f=c.focusNode.childNodes[c.focusOffset];f&&f.contentEditable=="false"&&(i=!0)}if(!(i||u&&Nt)&&ei(l.node,l.offset,c.anchorNode,c.anchorOffset)&&ei(a.node,a.offset,c.focusNode,c.focusOffset))return;let d=!1;if((c.extend||e==n)&&!u){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>n){let h=l;l=a,a=h}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,i=0;i<this.children.length;i++){let s=this.children[i],o=r+s.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+s.border,a=o-s.border;if(e>=l&&n<=a){this.dirty=e==r||n==o?ni:Wp,e==l&&n==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=In:s.markDirty(e-l,n-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?ni:In}r=o}this.dirty=ni}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?ni:Wp;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class qp extends eo{constructor(e,n,r,i){let s,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!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,s=this}matchesWidget(e){return this.dirty==sn&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class $x extends eo{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class ri extends eo{constructor(e,n,r,i){super(e,[],r,i),this.mark=n}static create(e,n,r,i){let s=i.nodeViews[n.type.name],o=s&&s(n,i,r);return(!o||!o.dom)&&(o=Nn.renderSpec(document,n.type.spec.toDOM(n,r))),new ri(e,n,o.dom,o.contentDOM||o.dom)}parseRule(){return this.dirty&In||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=In&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=sn){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=sn}}slice(e,n,r){let i=ri.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;n<o&&(s=du(s,n,o,r)),e>0&&(s=du(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}}class Tr extends eo{constructor(e,n,r,i,s,o,l,a,c){super(e,[],s,o),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,s,o){let l=s.nodeViews[n.type.name],a,c=l&&l(n,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,i),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}=Nn.renderSpec(document,n.type.spec.toDOM(n)));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Xp(u,r,n),c?a=new Bx(e,n,r,i,u,d||null,f,c,s,o+1):n.isText?new vl(e,n,r,i,u,f,s):new Tr(e,n,r,i,u,d||null,f,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>W.empty)}return e}matchesNode(e,n,r){return this.dirty==sn&&e.eq(this.node)&&uu(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,s=e.composing?this.localCompositionInfo(e,n):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Hx(this,o&&o.node,e);Ux(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?Pe.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,i)},(c,u,d,f)=>{a.syncToMarks(c.marks,r,e);let h;a.findNodeMatch(c,u,d,f)||l&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(h=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,u,d,h,e)||a.updateNextNode(c,u,d,e,f,i)||a.addNode(c,u,d,e,i),i+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==ni)&&(o&&this.protectLocalComposition(e,o),Gp(this.contentDOM,this.children,e),zi&&Wx(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof ce)||r<n||i>n+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=qx(this.node.content,o,r-n,i-n);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new $x(this,s,n,i);e.input.compositionNodes.push(o),this.children=du(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==In||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=sn}updateOuterDeco(e){if(uu(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Yp(this.dom,this.nodeDOM,cu(this.outerDeco,this.node,n),cu(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Kp(t,e,n,r,i){Xp(r,e,t);let s=new Tr(void 0,t,e,n,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class vl extends Tr{constructor(e,n,r,i,s,o,l){super(e,n,r,i,s,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,i){return this.dirty==In||this.dirty!=sn&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=sn||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=sn,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),s=document.createTextNode(i.text);return new vl(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=In)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Jp extends eo{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==sn&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Bx extends Tr{constructor(e,n,r,i,s,o,l,a,c,u){super(e,n,r,i,s,o,l,c,u),this.spec=a}update(e,n,r,i){if(this.dirty==In)return!1;if(this.spec.update){let s=this.spec.update(e,n,r);return s&&this.updateInner(e,n,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Gp(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=Zp(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof ri){let a=r?r.previousSibling:t.lastChild;Gp(o.contentDOM,o.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=Zp(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const to=function(t){t&&(this.nodeName=t)};to.prototype=Object.create(null);const ii=[new to];function cu(t,e,n){if(t.length==0)return ii;let r=n?ii[0]:new to,i=[r];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&i.push(r=new to(o.nodeName));for(let l in o){let a=o[l];a!=null&&(n&&i.length==1&&i.push(r=new to(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 i}function Yp(t,e,n,r){if(n==ii&&r==ii)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],l=n[s];if(s){let a;l&&l.nodeName==o.nodeName&&i!=t&&(a=i.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=ii[0]),i=a}jx(i,l||ii[0],o)}return i}function jx(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):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&t.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&t.classList.add(i[s]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function Xp(t,e,n){return Yp(t,t,ii,cu(e,n,t.nodeType!=1))}function uu(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 Zp(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Hx{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=zx(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 i=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;i<o&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.dirty=sn,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<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[s])&&!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=ri.create(this.top,e[s],n,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,n,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))s=this.top.children.indexOf(o,this.index);else for(let 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)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,n,r,i,s){let o=this.top.children[i];return o.dirty==In&&o.dom==o.contentDOM&&(o.dirty=ni),o.update(e,n,r,s)?(this.destroyBetween(this.index,i),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 i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Tr){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=In&&uu(n,a.outerDeco));if(!f&&a.update(e,n,r,i))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,n,r,i,o)))return this.top.children[this.index]=d,d.contentDOM&&(d.dirty=ni,d.updateChildren(i,o+1),d.dirty=sn),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,s,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content))return null;let l=Tr.create(this.top,n,r,i,s,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,i,s){let o=Tr.create(this.top,e,n,r,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new qp(this.top,e,n,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof ri;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof vl)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Nt||_t)&&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 i=new Jp(this.top,[],r,null);n!=this.top?n.children.push(i):n.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function zx(t,e){let n=e,r=n.children.length,i=t.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof ri)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(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function Vx(t,e){return t.type.side-e.type.side}function Ux(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,i,e.forChild(s,u),c),s+=u.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let u,d;for(;o<i.length&&i[o].to==s;){let v=i[o++];v.widget&&(u?(d||(d=[u])).push(v):u=v)}if(u)if(d){d.sort(Vx);for(let v=0;v<d.length;v++)n(d[v],c,!!a)}else n(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<t.childCount)h=c,f=t.child(c++);else break;for(let v=0;v<l.length;v++)l[v].to<=s&&l.splice(v--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let p=s+f.nodeSize;if(f.isText){let v=p;o<i.length&&i[o].from<v&&(v=i[o].from);for(let w=0;w<l.length;w++)l[w].to<v&&(v=l[w].to);v<p&&(a=f.cut(v-s),f=f.cut(0,v-s),p=v,h=-1)}else for(;o<i.length&&i[o].to<p;)o++;let g=f.isInline&&!f.isLeaf?l.filter(v=>!v.inline):l.slice();r(f,g,e.forChild(s,f),h),s=p}}function Wx(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 qx(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let o=t.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;i<t.childCount;){let c=t.child(i++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=n){if(s>=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 du(t,e,n,r,i){let s=[];for(let o=0,l=0;o<t.length;o++){let a=t[o],c=l,u=l+=a.size;c>=n||u<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,r)),i&&(s.push(i),i=void 0),u>n&&s.push(a.slice(n-c,a.size,r)))}return s}function fu(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(bl(n)){for(a=l;i&&!i.node;)i=i.parent;let u=i.node;if(i&&u.isAtom&&se.isSelectable(u)&&i.parent&&!(u.isInline&&yx(n.focusNode,n.focusOffset,i.dom))){let d=i.posBefore;c=new se(o==d?l:r.resolve(d))}}else{let u=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(u<0)return null;a=r.resolve(u)}if(!c){let u=e=="pointer"||t.state.selection.head<l.pos&&!s?1:-1;c=pu(t,a,l,u)}return c}function Qp(t){return t.editable?t.hasFocus():om(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function nr(t,e=!1){let n=t.state.selection;if(rm(t,n),!!Qp(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&_t){let r=t.domSelectionRange(),i=t.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&ei(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Jx(t);else{let{anchor:r,head:i}=n,s,o;em&&!(n instanceof ce)&&(n.$from.parent.inlineContent||(s=tm(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=tm(t,n.to))),t.docView.setSelection(r,i,t.root,e),em&&(s&&nm(s),o&&nm(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Kx(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const em=Nt||_t&&wx<63;function tm(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(Nt&&i&&i.contentEditable=="false")return hu(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return hu(i);if(s)return hu(s)}}function hu(t){return t.contentEditable="true",Nt&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function nm(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Kx(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Qp(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Jx(t){let e=t.domSelection(),n=document.createRange(),r=t.cursorWrapper.dom,i=r.nodeName=="IMG";i?n.setEnd(r.parentNode,Ct(r)+1):n.setEnd(r,0),n.collapse(!1),e.removeAllRanges(),e.addRange(n),!i&&!t.state.selection.visible&&Bt&&Sr<=11&&(r.disabled=!0,r.disabled=!1)}function rm(t,e){if(e instanceof se){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(im(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else im(t)}function im(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function pu(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||ce.between(e,n,r)}function sm(t){return t.editable&&!t.hasFocus()?!1:om(t)}function om(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 Gx(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return ei(e.node,e.offset,n.anchorNode,n.anchorOffset)}function mu(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&ue.findFrom(s,e)}function Ar(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function lm(t,e,n){let r=t.state.selection;if(r instanceof ce)if(n.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Ar(t,new ce(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=mu(t.state,e);return i&&i instanceof se?Ar(t,i):!1}else if(!(rn&&n.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?se.isSelectable(s)?Ar(t,new se(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):Zs?Ar(t,new ce(t.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof se&&r.node.isInline)return Ar(t,new ce(e>0?r.$to:r.$from));{let i=mu(t.state,e);return i?Ar(t,i):!1}}}function wl(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function no(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Ui(t,e){return e<0?Yx(t):Xx(t)}function Yx(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(bn&&n.nodeType==1&&r<wl(n)&&no(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(no(l,-1))i=n,s=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(am(n))break;{let l=n.previousSibling;for(;l&&no(l,-1);)i=n.parentNode,s=Ct(l),l=l.previousSibling;if(l)n=l,r=wl(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?gu(t,n,r):i&&gu(t,i,s)}function Xx(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=wl(n),s,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(no(l,1))s=n,o=++r;else break}else{if(am(n))break;{let l=n.nextSibling;for(;l&&no(l,1);)s=l.parentNode,o=Ct(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=wl(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&gu(t,s,o)}function am(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Zx(t,e){for(;t&&e==t.childNodes.length&&!Xs(t);)e=Ct(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 Qx(t,e){for(;t&&!e&&!Xs(t);)e=Ct(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 gu(t,e,n){if(e.nodeType!=3){let s,o;(o=Zx(e,n))?(e=o,n=0):(s=Qx(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(bl(r)){let s=document.createRange();s.setEnd(e,n),s.setStart(e,n),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&nr(t)},50)}function cm(t,e){let n=t.state.doc.resolve(e);if(!(_t||xx)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let s=t.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<n.end()){let s=t.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function um(t,e,n){let r=t.state.selection;if(r instanceof ce&&!r.empty||n.indexOf("s")>-1||rn&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=mu(t.state,e);if(o&&o instanceof se)return Ar(t,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof yn?ue.near(o,e):ue.findFrom(o,e);return l?Ar(t,l):!1}return!1}function dm(t,e){if(!(t.state.selection instanceof ce))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let o=t.state.tr;return e<0?o.delete(n.pos-s.nodeSize,n.pos):o.delete(n.pos,n.pos+s.nodeSize),t.dispatch(o),!0}return!1}function fm(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function ek(t){if(!Nt||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;fm(t,r,"true"),setTimeout(()=>fm(t,r,"false"),20)}return!1}function tk(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function nk(t,e){let n=e.keyCode,r=tk(e);if(n==8||rn&&n==72&&r=="c")return dm(t,-1)||Ui(t,-1);if(n==46&&!e.shiftKey||rn&&n==68&&r=="c")return dm(t,1)||Ui(t,1);if(n==13||n==27)return!0;if(n==37||rn&&n==66&&r=="c"){let i=n==37?cm(t,t.state.selection.from)=="ltr"?-1:1:-1;return lm(t,i,r)||Ui(t,i)}else if(n==39||rn&&n==70&&r=="c"){let i=n==39?cm(t,t.state.selection.from)=="ltr"?1:-1:1;return lm(t,i,r)||Ui(t,i)}else{if(n==38||rn&&n==80&&r=="c")return um(t,-1,r)||Ui(t,-1);if(n==40||rn&&n==78&&r=="c")return ek(t)||um(t,1,r)||Ui(t,1);if(r==(rn?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function hm(t,e){t.someProp("transformCopied",h=>{e=h(e,t)});let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let h=r.firstChild;n.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=t.someProp("clipboardSerializer")||Nn.fromSchema(t.state.schema),l=xm(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=vm[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${d?` -${d}`:""} ${JSON.stringify(n)}`);let f=t.someProp("clipboardTextSerializer",h=>h(e,t))||e.content.textBetween(0,e.content.size,`
|
36
36
|
|
37
|
-
`);return{dom:a,text:f,slice:e}}function
|
38
|
-
`))),0,0):Y.empty;let d=t.someProp("clipboardTextParser",f=>f(e,i,r,t));if(d)l=d;else{let f=i.marks(),{schema:h}=t.state,p=Nn.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let v=o.appendChild(document.createElement("p"));g&&v.appendChild(p.serializeNode(h.text(g,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),o=sk(n),Zs&&ok(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 f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Vc.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!rk.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=lk(vm(l,+u[1],+u[2]),u[4]);else if(l=Y.maxOpen(ik(l.content,i),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=vm(l,d,f)}return t.someProp("transformPasted",d=>{l=d(l,t)}),l}const rk=/^(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 ik(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),s,o=[];if(t.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&ym(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=bm(o[o.length-1],s.length));let u=gm(l,a);o.push(u),i=i.matchType(u.type),s=a}}),o)return W.from(o)}return t}function gm(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,W.from(t));return t}function ym(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=ym(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(W.from(gm(n,t,i+1))))}}function bm(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,bm(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(W.empty,!0);return t.copy(n.append(r))}function bu(t,e,n,r,i,s){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(s=0),i<r-1&&(l=bu(l,e,n,r,i+1,s)),i>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(W.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function vm(t,e,n){return e<t.openStart&&(t=new Y(bu(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Y(bu(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const wm={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 xm=null;function km(){return xm||(xm=document.implementation.createHTMLDocument("title"))}function sk(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=km().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&wm[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=t,i)for(let s=0;s<i.length;s++)n=n.querySelector(i[s])||n;return n}function ok(t){let e=t.querySelectorAll(_t?"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 lk(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:i,openStart:s,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=W.from(a.create(r[l+1],i)),s++,o++}return new Y(i,s,o)}const Dt={},Rt={},ak={touchstart:!0,touchmove:!0};class ck{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function uk(t){for(let e in Dt){let n=Dt[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{fk(t,r)&&!wu(t,r)&&(t.editable||!(r.type in Rt))&&n(t,r)},ak[e]?{passive:!0}:void 0)}Nt&&t.dom.addEventListener("input",()=>null),vu(t)}function Mr(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function dk(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 vu(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>wu(t,r))})}function wu(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function fk(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 hk(t,e){!wu(t,e)&&Dt[e.type]&&(t.editable||!(e.type in Rt))&&Dt[e.type](t,e)}Rt.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Sm(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(vn&&_t&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),zi&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,ti(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||nk(t,n)?n.preventDefault():Mr(t,"key")},Rt.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)},Rt.keypress=(t,e)=>{let n=e;if(Sm(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||rn&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof ce)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode);!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,i))&&t.dispatch(t.state.tr.insertText(i).scrollIntoView()),n.preventDefault()}};function xl(t){return{left:t.clientX,top:t.clientY}}function pk(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,i){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(t.someProp(e,l=>o>s.depth?l(t,n,s.nodeAfter,s.before(o),i,!0):l(t,n,s.node(o),s.before(o),i,!1)))return!0;return!1}function Wi(t,e,n){t.focused||t.focus();let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function mk(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&se.isSelectable(r)?(Wi(t,new se(n)),!0):!1}function gk(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof se&&(r=n.node);let s=t.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(se.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(o);break}}return i!=null?(Wi(t,se.create(t.state.doc,i)),!0):!1}function yk(t,e,n,r,i){return xu(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?gk(t,n):mk(t,n))}function bk(t,e,n,r){return xu(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function vk(t,e,n,r){return xu(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||wk(t,n,r)}function wk(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Wi(t,ce.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)Wi(t,ce.create(r,l+1,l+1+o.content.size));else if(se.isSelectable(o))Wi(t,se.create(r,l));else continue;return!0}}function ku(t){return kl(t)}const Cm=rn?"metaKey":"ctrlKey";Dt.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=ku(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&pk(n,t.input.lastClick)&&!n[Cm]&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s};let o=t.posAtCoords(xl(n));o&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new xk(t,o,n,!!r)):(s=="doubleClick"?bk:vk)(t,o.pos,o.inside,n)?n.preventDefault():Mr(t,"pointer"))};class xk{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Cm],this.allowDefault=r.shiftKey;let s,o;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),o=n.inside;else{let u=e.state.doc.resolve(n.pos);s=u.parent,o=u.depth?u.before():0}const l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof se&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&bn&&!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)),Mr(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(()=>nr(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(xl(e))),this.updateAllowDefault(e),this.allowDefault||!n?Mr(this.view,"pointer"):yk(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Nt&&this.mightDrag&&!this.mightDrag.node.isAtom||_t&&!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)?(Wi(this.view,ue.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Mr(this.view,"pointer")}move(e){this.updateAllowDefault(e),Mr(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)}}Dt.touchstart=t=>{t.input.lastTouch=Date.now(),ku(t),Mr(t,"pointer")},Dt.touchmove=t=>{t.input.lastTouch=Date.now(),Mr(t,"pointer")},Dt.contextmenu=t=>ku(t);function Sm(t,e){return t.composing?!0:Nt&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const kk=vn?5e3:-1;Rt.compositionstart=Rt.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),kl(t,!0),t.markCursor=null;else if(kl(t),bn&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){t.domSelection().collapse(o,o.nodeValue.length);break}else i=o,s=-1}}t.input.composing=!0}Em(t,kk)},Rt.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++,Em(t,20))};function Em(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>kl(t),e))}function Tm(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Sk());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Ck(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=mx(e.focusNode,e.focusOffset),r=gx(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function Sk(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function kl(t,e=!1){if(!(vn&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Tm(t),e||t.docView&&t.docView.dirty){let n=hu(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}}function Ek(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const ro=Bt&&Sr<15||zi&&kx<604;Dt.copy=Rt.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=ro?null:n.clipboardData,o=r.content(),{dom:l,text:a}=pm(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Ek(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Tk(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Ak(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?io(t,r.value,null,i,e):io(t,r.textContent,r.innerHTML,i,e)},50)}function io(t,e,n,r,i){let s=mm(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,i,s||Y.empty)))return!0;if(!s)return!1;let o=Tk(s),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(s);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Am(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," "):""}Rt.paste=(t,e)=>{let n=e;if(t.composing&&!vn)return;let r=ro?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&io(t,Am(r),r.getData("text/html"),i,n)?n.preventDefault():Ak(t,n)};class Mm{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const Om=rn?"altKey":"ctrlKey";Dt.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(xl(n)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof se?i.to-1:i.to))){if(r&&r.mightDrag)o=se.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=se.create(t.state.doc,d.posBefore))}}let l=(o||t.state.selection).content(),{dom:a,text:c,slice:u}=pm(t,l);n.dataTransfer.clearData(),n.dataTransfer.setData(ro?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",ro||n.dataTransfer.setData("text/plain",c),t.dragging=new Mm(u,!n[Om],o)},Dt.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)},Rt.dragover=Rt.dragenter=(t,e)=>e.preventDefault(),Rt.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(xl(n));if(!i)return;let s=t.state.doc.resolve(i.pos),o=r&&r.slice;o?t.someProp("transformPasted",p=>{o=p(o,t)}):o=mm(t,Am(n.dataTransfer),ro?null:n.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!n[Om]);if(t.someProp("handleDrop",p=>p(t,n,o||Y.empty,l))){n.preventDefault();return}if(!o)return;n.preventDefault();let a=o?vp(t.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let c=t.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(u,u,o.content.firstChild):c.replaceRange(u,u,o),c.doc.eq(f))return;let h=c.doc.resolve(u);if(d&&se.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new se(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((g,v,w,S)=>p=S),c.setSelection(mu(t,h,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))},Dt.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())&&nr(t)},20))},Dt.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)},Dt.beforeinput=(t,e)=>{if(_t&&vn&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",s=>s(t,ti(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in Rt)Dt[t]=Rt[t];function so(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 Cl{constructor(e,n){this.toDOM=e,this.spec=n||si,this.side=this.spec.side||0}map(e,n,r,i){let{pos:s,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new ut(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Cl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&so(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Or{constructor(e,n){this.attrs=e,this.spec=n||si}map(e,n,r,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new ut(s,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Or&&so(this.attrs,e.attrs)&&so(this.spec,e.spec)}static is(e){return e.type instanceof Or}destroy(){}}class Cu{constructor(e,n){this.attrs=e,this.spec=n||si}map(e,n,r,i){let s=e.mapResult(n.from+i,1);if(s.deleted)return null;let o=e.mapResult(n.to+i,-1);return o.deleted||o.pos<=s.pos?null:new ut(s.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),s;return i==n.from&&!(s=e.child(r)).isText&&i+s.nodeSize==n.to}eq(e){return this==e||e instanceof Cu&&so(this.attrs,e.attrs)&&so(this.spec,e.spec)}destroy(){}}class ut{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new ut(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 ut(e,e,new Cl(n,r))}static inline(e,n,r,i){return new ut(e,n,new Or(r,i))}static node(e,n,r,i){return new ut(e,n,new Cu(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Or}get widget(){return this.type instanceof Cl}}const qi=[],si={};class He{constructor(e,n){this.local=e.length?e:qi,this.children=n.length?n:qi}static create(e,n){return n.length?Sl(n,e,0,si):At}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}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,i+l,s)}}map(e,n,r){return this==At||e.maps.length==0?this:this.mapInner(e,n,0,0,r||si)}mapInner(e,n,r,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(n,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?Mk(this.children,o||[],e,n,r,i,s):o?new He(o.sort(oi),qi):At}add(e,n){return n.length?this==At?He.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Nm(n,l,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,u,c+1):i.splice(s,0,a,a+l.nodeSize,Sl(u,l,c+1,si)),s+=3}});let o=_m(s?Dm(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new He(o.length?this.local.concat(o).sort(oi):this.local,i||this.children)}remove(e){return e.length==0||this==At?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+n,a=r[s+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[s+2].removeInner(o,l+1);c!=At?r[s+2]=c:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new He(i,r):At}forChild(e,n){if(this==At)return this;if(n.isLeaf)return He.empty;let r,i;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 s=e+1,o=s+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof Or){let c=Math.max(s,a.from)-s,u=Math.min(o,a.to)-s;c<u&&(i||(i=[])).push(a.copy(c,u))}}if(i){let l=new He(i.sort(oi),qi);return r?new _r([l,r]):l}return r||At}eq(e){if(this==e)return!0;if(!(e instanceof He)||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 Su(this.localsInner(e))}localsInner(e){if(this==At)return qi;if(e.inlineContent||!this.local.some(Or.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Or||n.push(this.local[r]);return n}}He.empty=new He([],[]),He.removeOverlap=Su;const At=He.empty;class _r{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,si));return _r.from(r)}forChild(e,n){if(n.isLeaf)return He.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=At&&(s instanceof _r?r=r.concat(s.members):r.push(s))}return _r.from(r)}eq(e){if(!(e instanceof _r)||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 i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!n)n=s;else{r&&(n=n.slice(),r=!1);for(let o=0;o<s.length;o++)n.push(s[o])}}return n?Su(r?n:n.sort(oi)):qi}static from(e){switch(e.length){case 0:return At;case 1:return e[0];default:return new _r(e.every(n=>n instanceof He)?e:e.reduce((n,r)=>n.concat(r instanceof He?r:r.members),[]))}}}function Mk(t,e,n,r,i,s,o){let l=t.slice();for(let c=0,u=s;c<n.maps.length;c++){let d=0;n.maps[c].forEach((f,h,p,g)=>{let v=g-p-(h-f);for(let w=0;w<l.length;w+=3){let S=l[w+1];if(S<0||f>S+u-d)continue;let x=l[w]+u-d;h>=x?l[w+1]=f<=x?-2:-1:f>=u&&v&&(l[w]+=v,l[w+1]+=v)}d+=v}),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]+s),d=u-i;if(d<0||d>=r.content.size){a=!0;continue}let f=n.map(t[c+1]+s,-1),h=f-i,{index:p,offset:g}=r.content.findIndex(d),v=r.maybeChild(p);if(v&&g==d&&g+v.nodeSize==h){let w=l[c+2].mapInner(n,v,u+1,t[c]+s+1,o);w!=At?(l[c]=d,l[c+1]=h,l[c+2]=w):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Ok(l,t,e,n,i,s,o),u=Sl(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,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new He(e.sort(oi),l)}function _m(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new ut(i.from+e,i.to+e,i.type))}return n}function Ok(t,e,n,r,i,s,o){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,i,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]+s+1);return n}function Nm(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let s=0,o;s<t.length;s++)(o=t[s])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),t[s]=null);return i}function Dm(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Sl(t,e,n,r){let i=[],s=!1;e.forEach((l,a)=>{let c=Nm(t,l,a+n);if(c){s=!0;let u=Sl(c,l,n+a+1,r);u!=At&&i.push(a,a+l.nodeSize,u)}});let o=_m(s?Dm(t):t,-n).sort(oi);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||i.length?new He(o,i):At}function oi(t,e){return t.from-e.from||t.to-e.to}function Su(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,r.to),Rm(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),Rm(e,i,r.copy(s.from,r.to)));break}}}return e}function Rm(t,e,n){for(;e<t.length&&oi(n,t[e])>0;)e++;t.splice(e,0,n)}function Eu(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=At&&e.push(r)}),t.cursorWrapper&&e.push(He.create(t.state.doc,[t.cursorWrapper.deco])),_r.from(e)}const _k={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Nk=Bt&&Sr<=11;class Dk{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 Rk{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Dk,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);Bt&&Sr<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Nk&&(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,_k)),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(om(this.view)){if(this.suppressingSelectionUpdates)return nr(this.view);if(Bt&&Sr<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ei(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let s=e.focusNode;s;s=Ys(s))n.add(s);for(let s=e.anchorNode;s;s=Ys(s))if(n.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&om(e)&&!this.ignoreSelectionChange(r),s=-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&&(s=s<0?d.from:Math.min(d.from,s),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(l=!0))}if(bn&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||Pk(e,d)!=h)&&f.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&bl(r)&&(c=hu(e))&&c.eq(ue.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,nr(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Lk(e)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||nr(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++)n.push(e.addedNodes[u]);if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(Bt&&Sr<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(i=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(s=f)}let o=i&&i.parentNode==e.target?Ct(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?Ct(s):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}:{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}}let Lm=new WeakMap,Im=!1;function Lk(t){if(!Lm.has(t)&&(Lm.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=bn,Im)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."),Im=!0}}function Pm(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return ei(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function Ik(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Pm(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Pm(t,n):null}function Pk(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 Fk(t,e,n){let{node:r,fromOffset:i,toOffset:s,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}],bl(a)||c.push({node:a.focusNode,offset:a.focusOffset})),_t&&t.input.lastKeyCode===8)for(let v=s;v>i;v--){let w=r.childNodes[v-1],S=w.pmViewDesc;if(w.nodeName=="BR"&&!S){s=v;break}if(!S||S.size)break}let d=t.state.doc,f=t.someProp("domParser")||Vc.fromSchema(t.state.schema),h=d.resolve(o),p=null,g=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:$k,context:h});if(c&&c[0].pos!=null){let v=c[0].pos,w=c[1]&&c[1].pos;w==null&&(w=v),p={anchor:v+o,head:w+o}}return{doc:g,sel:p,from:o,to:l}}function $k(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Nt&&/^(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||Nt&&/^(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 Bk=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function jk(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let N=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,A=hu(t,N);if(A&&!t.state.selection.eq(A)){if(_t&&vn&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",P=>P(t,ti(13,"Enter"))))return;let R=t.state.tr.setSelection(A);N=="pointer"?R.setMeta("pointer",!0):N=="key"&&R.scrollIntoView(),s&&R.setMeta("composition",s),t.dispatch(R)}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=Fk(t,e,n),u=t.state.doc,d=u.slice(c.from,c.to),f,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(f=t.state.selection.to,h="end"):(f=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let p=Vk(d.content,c.doc.content,c.from,f,h);if((zi&&t.input.lastIOSEnter>Date.now()-225||vn)&&i.some(N=>N.nodeType==1&&!Bk.test(N.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",N=>N(t,ti(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof ce&&!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 N=Fm(t,t.state.doc,c.sel);if(N&&!N.eq(t.state.selection)){let A=t.state.tr.setSelection(N);s&&A.setMeta("composition",s),t.dispatch(A)}}return}t.input.domChangeCount++,t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof ce&&(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)),Bt&&Sr<=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),v=c.doc.resolveNoCache(p.endB-c.from),w=u.resolve(p.start),S=g.sameParent(v)&&g.parent.inlineContent&&w.end()>=p.endA,x;if((zi&&t.input.lastIOSEnter>Date.now()-225&&(!S||i.some(N=>N.nodeName=="DIV"||N.nodeName=="P"))||!S&&g.pos<c.doc.content.size&&!g.sameParent(v)&&(x=ue.findFrom(c.doc.resolve(g.pos+1),1,!0))&&x.head==v.pos)&&t.someProp("handleKeyDown",N=>N(t,ti(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&zk(u,p.start,p.endA,g,v)&&t.someProp("handleKeyDown",N=>N(t,ti(8,"Backspace")))){vn&&_t&&t.domObserver.suppressSelectionUpdates();return}_t&&vn&&p.endB==p.start&&(t.input.lastAndroidDelete=Date.now()),vn&&!S&&g.start()!=v.start()&&v.parentOffset==0&&g.depth==v.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,v=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(N){return N(t,ti(13,"Enter"))})},20));let y=p.start,C=p.endA,E,T,D;if(S){if(g.pos==v.pos)Bt&&Sr<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>nr(t),20)),E=t.state.tr.delete(y,C),T=u.resolve(p.start).marksAcross(u.resolve(p.endA));else if(p.endA==p.endB&&(D=Hk(g.parent.content.cut(g.parentOffset,v.parentOffset),w.parent.content.cut(w.parentOffset,p.endA-w.start()))))E=t.state.tr,D.type=="add"?E.addMark(y,C,D.mark):E.removeMark(y,C,D.mark);else if(g.parent.child(g.index()).isText&&g.index()==v.index()-(v.textOffset?0:1)){let N=g.parent.textBetween(g.parentOffset,v.parentOffset);if(t.someProp("handleTextInput",A=>A(t,y,C,N)))return;E=t.state.tr.insertText(N,y,C)}}if(E||(E=t.state.tr.replace(y,C,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let N=Fm(t,E.doc,c.sel);N&&!(_t&&vn&&t.composing&&N.empty&&(p.start!=p.endB||t.input.lastAndroidDelete<Date.now()-100)&&(N.head==y||N.head==E.mapping.map(C)-1)||Bt&&N.empty&&N.head==y)&&E.setSelection(N)}T&&E.ensureMarks(T),s&&E.setMeta("composition",s),t.dispatch(E.scrollIntoView())}function Fm(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:mu(t,e.resolve(n.anchor),e.resolve(n.head))}function Hk(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,o,l,a;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<n.length;u++)s=n[u].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=u=>u.mark(l.addToSet(u.marks));else if(i.length==0&&s.length==1)l=s[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(W.from(c).eq(t))return{mark:l,type:o}}function zk(t,e,n,r,i){if(n-e<=i.pos-r.pos||Tu(r,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&n==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=t.resolve(Tu(s,!0,!0));return!o.parent.isTextblock||o.pos>n||Tu(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Tu(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let s=t.node(r).maybeChild(t.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function Vk(t,e,n,r,i){let s=t.findDiffStart(e,n);if(s==null)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let a=Math.max(0,s-Math.min(o,l));r-=o+a-s}if(o<s&&t.size<e.size){let a=r<=s&&r>=o?s-r:0;s-=a,s&&s<e.size&&$m(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-o),o=s}else if(l<s){let a=r<=s&&r>=l?s-r:0;s-=a,s&&s<t.size&&$m(t.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function $m(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 Uk{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 ck,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Vm),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=Hm(this),jm(this),this.nodeViews=zm(this),this.docView=Jp(this.state.doc,Bm(this),Eu(this),this.dom,this),this.domObserver=new Rk(this,(r,i,s,o)=>jk(this,r,i,s,o)),this.domObserver.start(),uk(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&&vu(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Vm),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(Tm(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=zm(this);qk(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&vu(this),this.editable=Hm(this),jm(this);let a=Eu(this),c=Bm(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=s||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(i.selection))&&(o=!0);let f=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Ex(this);if(o){this.domObserver.stop();let h=d&&(Bt||_t)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Wk(i.selection,e.selection);if(d){let p=_t?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Ck(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Jp(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Gx(this))?nr(this,h):(im(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&Tx(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof se){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Ip(this,n.getBoundingClientRect(),e)}else Ip(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,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-n.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new Mm(e.slice,e.move,i<0?void 0:se.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=n?n(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(Bt){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&&Ax(this.dom),nr(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 Dx(this,e)}coordsAtPos(e,n=1){return Hp(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return Fx(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"))}destroy(){this.docView&&(dk(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Eu(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,hx())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return hk(this,e)}dispatch(e){let n=this._props.dispatchTransaction;n?n.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return Nt&&this.root.nodeType===11&&bx(this.dom.ownerDocument)==this.dom&&Ik(this,e)||e}domSelection(){return this.root.getSelection()}}function Bm(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"),[ut.node(0,t.state.doc.content.size,e)]}function jm(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:ut.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Hm(t){return!t.someProp("editable",e=>e(t.state)===!1)}function Wk(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 zm(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function qk(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function Vm(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")}for(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:"'"},El={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Kk=typeof navigator<"u"&&/Mac/.test(navigator.platform),Jk=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),St=0;St<10;St++)Nr[48+St]=Nr[96+St]=String(St);for(var St=1;St<=24;St++)Nr[St+111]="F"+St;for(var St=65;St<=90;St++)Nr[St]=String.fromCharCode(St+32),El[St]=String.fromCharCode(St);for(var Au in Nr)El.hasOwnProperty(Au)||(El[Au]=Nr[Au]);function Gk(t){var e=Kk&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Jk&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?El: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 Yk=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Xk(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,s,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))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Yk?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),o&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function Zk(t){let e=Object.create(null);for(let n in t)e[Xk(n)]=t[n];return e}function Mu(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 Qk(t){return new je({props:{handleKeyDown:Ou(t)}})}function Ou(t){let e=Zk(t);return function(n,r){let i=Gk(r),s,o=e[Mu(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Mu(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.shiftKey||r.altKey||r.metaKey||i.charCodeAt(0)>127)&&(s=Nr[r.keyCode])&&s!=i){let l=e[Mu(s,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}const eC=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Um(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const tC=(t,e,n)=>{let r=Um(t,n);if(!r)return!1;let i=_u(r);if(!i){let o=r.blockRange(),l=o&&Pi(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(!s.type.spec.isolating&&Jm(t,i,e))return!0;if(r.parent.content.size==0&&(Ki(s,"end")||se.isSelectable(s))){let o=ml(t.doc,r.before(),r.after(),Y.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(Ki(s,"end")?ue.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):se.create(l.doc,i.pos-s.nodeSize)),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},nC=(t,e,n)=>{let r=Um(t,n);if(!r)return!1;let i=_u(r);return i?Wm(t,i,e):!1},rC=(t,e,n)=>{let r=qm(t,n);if(!r)return!1;let i=Nu(r);return i?Wm(t,i,e):!1};function Wm(t,e,n){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=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=ml(t.doc,s,a,Y.empty);if(!c||c.from!=s||c instanceof ht&&c.slice.size>=a-s)return!1;if(n){let u=t.tr.step(c);u.setSelection(ce.create(u.doc,s)),n(u.scrollIntoView())}return!0}function Ki(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 iC=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=_u(r)}let o=s&&s.nodeBefore;return!o||!se.isSelectable(o)?!1:(e&&e(t.tr.setSelection(se.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function _u(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 qm(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const sC=(t,e,n)=>{let r=qm(t,n);if(!r)return!1;let i=Nu(r);if(!i)return!1;let s=i.nodeAfter;if(Jm(t,i,e))return!0;if(r.parent.content.size==0&&(Ki(s,"start")||se.isSelectable(s))){let o=ml(t.doc,r.before(),r.after(),Y.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(Ki(s,"start")?ue.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):se.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},oC=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=Nu(r)}let o=s&&s.nodeAfter;return!o||!se.isSelectable(o)?!1:(e&&e(t.tr.setSelection(se.create(t.doc,s.pos)).scrollIntoView()),!0)};function Nu(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 lC=(t,e)=>{let n=t.selection,r=n instanceof se,i;if(r){if(n.node.isTextblock||!kr(t.doc,n.from))return!1;i=n.from}else if(i=pl(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(se.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},aC=(t,e)=>{let n=t.selection,r;if(n instanceof se){if(n.node.isTextblock||!kr(t.doc,n.to))return!1;r=n.to}else if(r=pl(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},cC=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&Pi(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},uC=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
|
39
|
-
`).scrollIntoView()),!0)};function Km(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 dC=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=Km(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,o.createAndFill());a.setSelection(ue.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},fC=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof yn||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=Km(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(o,s.createAndFill());l.setSelection(ce.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},hC=(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 s=n.before();if(Fi(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Pi(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)},pC=(t,e)=>{let{$from:n,to:r}=t.selection,i,s=n.sharedDepth(r);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(se.create(t.doc,i))),!0)};function mC(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||kr(t.doc,e.pos))?!1:(n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function Jm(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s,o;if(r.type.spec.isolating||i.type.spec.isolating)return!1;if(mC(t,e,n))return!0;let l=e.parent.canReplace(e.index(),e.index()+1);if(l&&(s=(o=r.contentMatchAt(r.childCount)).findWrapping(i.type))&&o.matchType(s[0]||i.type).validEnd){if(n){let d=e.pos+i.nodeSize,f=W.empty;for(let g=s.length-1;g>=0;g--)f=W.from(s[g].create(null,f));f=W.from(r.copy(f));let h=t.tr.step(new pt(e.pos-1,d,e.pos,d,new Y(f,1,0),s.length,!0)),p=d+2*s.length;kr(h.doc,p)&&h.join(p),n(h.scrollIntoView())}return!0}let a=ue.findFrom(e,1),c=a&&a.$from.blockRange(a.$to),u=c&&Pi(c);if(u!=null&&u>=e.depth)return n&&n(t.tr.lift(c,u).scrollIntoView()),!0;if(l&&Ki(i,"start",!0)&&Ki(r,"end")){let d=r,f=[];for(;f.push(d),!d.isTextblock;)d=d.lastChild;let h=i,p=1;for(;!h.isTextblock;h=h.firstChild)p++;if(d.canReplace(d.childCount,d.childCount,h.content)){if(n){let g=W.empty;for(let w=f.length-1;w>=0;w--)g=W.from(f[w].copy(g));let v=t.tr.step(new pt(e.pos-f.length,e.pos+i.nodeSize,e.pos+p,e.pos+i.nodeSize-p,new Y(g,f.length,0),0,!0));n(v.scrollIntoView())}return!0}}return!1}function Gm(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(e.tr.setSelection(ce.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const gC=Gm(-1),yC=Gm(1);function bC(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),l=o&&Gc(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Ym(t,e=null){return function(n,r){let i=!1;for(let s=0;s<n.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[s];n.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)i=!0;else{let u=n.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,t)}})}if(!i)return!1;if(r){let s=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[o];s.setBlockType(l,a,t,e)}r(s.scrollIntoView())}return!0}}typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function vC(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),l=!1,a=o;if(!o)return!1;if(o.depth>=2&&i.node(o.depth-1).type.compatibleContent(t)&&o.startIndex==0){if(i.index(o.depth-1)==0)return!1;let u=n.doc.resolve(o.start-2);a=new ll(u,u,o.depth),o.endIndex<o.parent.childCount&&(o=new ll(i,n.doc.resolve(s.end(o.depth)),o.depth)),l=!0}let c=Gc(a,t,e,o);return c?(r&&r(wC(n.tr,o,c,l,t).scrollIntoView()),!0):!1}}function wC(t,e,n,r,i){let s=W.empty;for(let u=n.length-1;u>=0;u--)s=W.from(n[u].type.create(n[u].attrs,s));t.step(new pt(e.start-(r?2:0),e.end,e.start,e.end,new Y(s,0,0),n.length,!0));let o=0;for(let u=0;u<n.length;u++)n[u].type==i&&(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,f=!0;u<d;u++,f=!1)!f&&Fi(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function xC(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==t);return s?n?r.node(s.depth-1).type==t?kC(e,n,t,s):CC(e,n,s):!0:!1}}function kC(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new pt(s-1,o,s,o,new Y(W.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new ll(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=Pi(r);if(l==null)return!1;i.lift(r,l);let a=i.mapping.map(s,-1)-1;return kr(i.doc,a)&&i.join(a),e(i.scrollIntoView()),!0}function CC(t,e,n){let r=t.tr,i=n.parent;for(let h=n.end,p=n.endIndex-1,g=n.startIndex;p>g;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==i.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?W.empty:W.from(i))))return!1;let d=s.pos,f=d+o.nodeSize;return r.step(new pt(d-(l?1:0),f+(a?1:0),d+1,f-1,new Y((l?W.empty:W.from(i.copy(W.empty))).append(a?W.empty:W.from(i.copy(W.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function SC(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==t);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=W.from(c?t.create():null),d=new Y(W.from(t.create(null,W.from(l.type.create(null,u)))),c?3:1,0),f=s.start,h=s.end;n(e.tr.step(new pt(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}function Tl(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}class Al{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:n,state:r}=this,{view:i}=n,{tr:s}=r,o=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...u)=>{const d=a(...u)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){const{rawCommands:r,editor:i,state:s}=this,{view:o}=i,l=[],a=!!e,c=e||s.tr,u=()=>(!a&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),l.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...g)=>{const v=this.buildProps(c,n),w=h(...g)(v);return l.push(w),d}])),run:u};return d}createCan(e){const{rawCommands:n,state:r}=this,i=!1,s=e||r.tr,o=this.buildProps(s,i);return{...Object.fromEntries(Object.entries(n).map(([a,c])=>[a,(...u)=>c(...u)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,i)}}buildProps(e,n=!0){const{rawCommands:r,editor:i,state:s}=this,{view:o}=i,l={tr:e,editor:i,view:o,state:Tl({state:s,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}}class EC{constructor(){this.callbacks={}}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),this}emit(e,...n){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,n)),this}off(e,n){const r=this.callbacks[e];return r&&(n?this.callbacks[e]=r.filter(i=>i!==n):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}}function re(t,e,n){return t.config[e]===void 0&&t.parent?re(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?re(t.parent,e,n):null}):t.config[e]}function Ml(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Xm(t){const e=[],{nodeExtensions:n,markExtensions:r}=Ml(t),i=[...n,...r],s={default:null,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},a=re(o,"addGlobalAttributes",l);if(!a)return;a().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([f,h])=>{e.push({type:d,name:f,attribute:{...s,...h}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=re(o,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([u,d])=>{const f={...s,...d};typeof(f==null?void 0:f.default)=="function"&&(f.default=f.default()),f!=null&&f.isRequired&&(f==null?void 0:f.default)===void 0&&delete f.default,e.push({type:o.name,name:u,attribute:f})})}),e}function mt(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function Ce(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const l=s?s.split(" "):[],a=r[i]?r[i].split(" "):[],c=l.filter(u=>!a.includes(u));r[i]=[...a,...c].join(" ")}else i==="style"?r[i]=[r[i],s].join("; "):r[i]=s}),r},{})}function Du(t,e){return e.filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>Ce(n,r),{})}function Zm(t){return typeof t=="function"}function be(t,e=void 0,...n){return Zm(t)?e?t.bind(e)(...n):t(...n):t}function TC(t={}){return Object.keys(t).length===0&&t.constructor===Object}function AC(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Qm(t,e){return t.style?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((s,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):AC(n.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...r,...i}}}}function eg(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&TC(n)?!1:n!=null))}function MC(t,e){var n;const r=Xm(t),{nodeExtensions:i,markExtensions:s}=Ml(t),o=(n=i.find(c=>re(c,"topNode")))===null||n===void 0?void 0:n.name,l=Object.fromEntries(i.map(c=>{const u=r.filter(w=>w.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((w,S)=>{const x=re(S,"extendNodeSchema",d);return{...w,...x?x(c):{}}},{}),h=eg({...f,content:be(re(c,"content",d)),marks:be(re(c,"marks",d)),group:be(re(c,"group",d)),inline:be(re(c,"inline",d)),atom:be(re(c,"atom",d)),selectable:be(re(c,"selectable",d)),draggable:be(re(c,"draggable",d)),code:be(re(c,"code",d)),defining:be(re(c,"defining",d)),isolating:be(re(c,"isolating",d)),attrs:Object.fromEntries(u.map(w=>{var S;return[w.name,{default:(S=w==null?void 0:w.attribute)===null||S===void 0?void 0:S.default}]}))}),p=be(re(c,"parseHTML",d));p&&(h.parseDOM=p.map(w=>Qm(w,u)));const g=re(c,"renderHTML",d);g&&(h.toDOM=w=>g({node:w,HTMLAttributes:Du(w,u)}));const v=re(c,"renderText",d);return v&&(h.toText=v),[c.name,h]})),a=Object.fromEntries(s.map(c=>{const u=r.filter(v=>v.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((v,w)=>{const S=re(w,"extendMarkSchema",d);return{...v,...S?S(c):{}}},{}),h=eg({...f,inclusive:be(re(c,"inclusive",d)),excludes:be(re(c,"excludes",d)),group:be(re(c,"group",d)),spanning:be(re(c,"spanning",d)),code:be(re(c,"code",d)),attrs:Object.fromEntries(u.map(v=>{var w;return[v.name,{default:(w=v==null?void 0:v.attribute)===null||w===void 0?void 0:w.default}]}))}),p=be(re(c,"parseHTML",d));p&&(h.parseDOM=p.map(v=>Qm(v,u)));const g=re(c,"renderHTML",d);return g&&(h.toDOM=v=>g({mark:v,HTMLAttributes:Du(v,u)})),[c.name,h]}));return new R1({topNode:o,nodes:l,marks:a})}function Ru(t,e){return e.nodes[t]||e.marks[t]||null}function tg(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}const OC=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,l)=>{var a,c;const u=((c=(a=i.type.spec).toText)===null||c===void 0?void 0:c.call(a,{node:i,pos:s,parent:o,index:l}))||i.textContent||"%leaf%";n+=u.slice(0,Math.max(0,r-s))}),n};function Lu(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class oo{constructor(e){this.find=e.find,this.handler=e.handler}}const _C=(t,e)=>{if(Lu(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 Ol(t){var e;const{editor:n,from:r,to:i,text:s,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===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let u=!1;const d=OC(c)+s;return o.forEach(f=>{if(u)return;const h=_C(d,f.find);if(!h)return;const p=a.state.tr,g=Tl({state:a.state,transaction:p}),v={from:r-(h[0].length-s.length),to:i},{commands:w,chain:S,can:x}=new Al({editor:n,state:g});f.handler({state:g,range:v,match:h,commands:w,chain:S,can:x})===null||!p.steps.length||(p.setMeta(l,{transform:p,from:r,to:i,text:s}),a.dispatch(p),u=!0)}),u}function NC(t){const{editor:e,rules:n}=t,r=new je({state:{init(){return null},apply(i,s){const o=i.getMeta(r);if(o)return o;const l=i.getMeta("applyInputRules");return!!l&&setTimeout(()=>{const{from:c,text:u}=l,d=c+u.length;Ol({editor:e,from:c,to:d,text:u,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return Ol({editor:e,from:s,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&Ol({editor:e,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?Ol({editor:e,from:o.pos,to:o.pos,text:`
|
40
|
-
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function DC(t){return typeof t=="number"}class RC{constructor(e){this.find=e.find,this.handler=e.handler}}const LC=(t,e,n)=>{if(
|
37
|
+
`);return{dom:a,text:f,slice:e}}function pm(t,e,n,r,i){let s=i.parent.type.spec.code,o,l;if(!n&&!e)return null;let a=e&&(r||s||!n);if(a){if(t.someProp("transformPastedText",f=>{e=f(e,s||r,t)}),s)return e?new Y(W.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
38
|
+
`))),0,0):Y.empty;let d=t.someProp("clipboardTextParser",f=>f(e,i,r,t));if(d)l=d;else{let f=i.marks(),{schema:h}=t.state,p=Nn.fromSchema(h);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let v=o.appendChild(document.createElement("p"));g&&v.appendChild(p.serializeNode(h.text(g,f)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),o=sk(n),Zs&&ok(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 f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||zc.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!rk.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=lk(bm(l,+u[1],+u[2]),u[4]);else if(l=Y.maxOpen(ik(l.content,i),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=bm(l,d,f)}return t.someProp("transformPasted",d=>{l=d(l,t)}),l}const rk=/^(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 ik(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),s,o=[];if(t.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&gm(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=ym(o[o.length-1],s.length));let u=mm(l,a);o.push(u),i=i.matchType(u.type),s=a}}),o)return W.from(o)}return t}function mm(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,W.from(t));return t}function gm(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=gm(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(W.from(mm(n,t,i+1))))}}function ym(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,ym(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(W.empty,!0);return t.copy(n.append(r))}function yu(t,e,n,r,i,s){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(s=0),i<r-1&&(l=yu(l,e,n,r,i+1,s)),i>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(W.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function bm(t,e,n){return e<t.openStart&&(t=new Y(yu(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Y(yu(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const vm={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 wm=null;function xm(){return wm||(wm=document.implementation.createHTMLDocument("title"))}function sk(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=xm().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&vm[r[1].toLowerCase()])&&(t=i.map(s=>"<"+s+">").join("")+t+i.map(s=>"</"+s+">").reverse().join("")),n.innerHTML=t,i)for(let s=0;s<i.length;s++)n=n.querySelector(i[s])||n;return n}function ok(t){let e=t.querySelectorAll(_t?"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 lk(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:i,openStart:s,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=W.from(a.create(r[l+1],i)),s++,o++}return new Y(i,s,o)}const Dt={},Rt={},ak={touchstart:!0,touchmove:!0};class ck{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function uk(t){for(let e in Dt){let n=Dt[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{fk(t,r)&&!vu(t,r)&&(t.editable||!(r.type in Rt))&&n(t,r)},ak[e]?{passive:!0}:void 0)}Nt&&t.dom.addEventListener("input",()=>null),bu(t)}function Mr(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function dk(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 bu(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>vu(t,r))})}function vu(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function fk(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 hk(t,e){!vu(t,e)&&Dt[e.type]&&(t.editable||!(e.type in Rt))&&Dt[e.type](t,e)}Rt.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Cm(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(vn&&_t&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),zi&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,ti(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||nk(t,n)?n.preventDefault():Mr(t,"key")},Rt.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)},Rt.keypress=(t,e)=>{let n=e;if(Cm(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||rn&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof ce)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode);!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",s=>s(t,r.$from.pos,r.$to.pos,i))&&t.dispatch(t.state.tr.insertText(i).scrollIntoView()),n.preventDefault()}};function xl(t){return{left:t.clientX,top:t.clientY}}function pk(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function wu(t,e,n,r,i){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(t.someProp(e,l=>o>s.depth?l(t,n,s.nodeAfter,s.before(o),i,!0):l(t,n,s.node(o),s.before(o),i,!1)))return!0;return!1}function Wi(t,e,n){t.focused||t.focus();let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function mk(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&se.isSelectable(r)?(Wi(t,new se(n)),!0):!1}function gk(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof se&&(r=n.node);let s=t.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(se.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(o);break}}return i!=null?(Wi(t,se.create(t.state.doc,i)),!0):!1}function yk(t,e,n,r,i){return wu(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?gk(t,n):mk(t,n))}function bk(t,e,n,r){return wu(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function vk(t,e,n,r){return wu(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||wk(t,n,r)}function wk(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Wi(t,ce.create(r,0,r.content.size)),!0):!1;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)Wi(t,ce.create(r,l+1,l+1+o.content.size));else if(se.isSelectable(o))Wi(t,se.create(r,l));else continue;return!0}}function xu(t){return kl(t)}const km=rn?"metaKey":"ctrlKey";Dt.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=xu(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&pk(n,t.input.lastClick)&&!n[km]&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s};let o=t.posAtCoords(xl(n));o&&(s=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new xk(t,o,n,!!r)):(s=="doubleClick"?bk:vk)(t,o.pos,o.inside,n)?n.preventDefault():Mr(t,"pointer"))};class xk{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[km],this.allowDefault=r.shiftKey;let s,o;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),o=n.inside;else{let u=e.state.doc.resolve(n.pos);s=u.parent,o=u.depth?u.before():0}const l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof se&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&bn&&!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)),Mr(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(()=>nr(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(xl(e))),this.updateAllowDefault(e),this.allowDefault||!n?Mr(this.view,"pointer"):yk(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Nt&&this.mightDrag&&!this.mightDrag.node.isAtom||_t&&!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)?(Wi(this.view,ue.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Mr(this.view,"pointer")}move(e){this.updateAllowDefault(e),Mr(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)}}Dt.touchstart=t=>{t.input.lastTouch=Date.now(),xu(t),Mr(t,"pointer")},Dt.touchmove=t=>{t.input.lastTouch=Date.now(),Mr(t,"pointer")},Dt.contextmenu=t=>xu(t);function Cm(t,e){return t.composing?!0:Nt&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const kk=vn?5e3:-1;Rt.compositionstart=Rt.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),kl(t,!0),t.markCursor=null;else if(kl(t),bn&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){t.domSelection().collapse(o,o.nodeValue.length);break}else i=o,s=-1}}t.input.composing=!0}Sm(t,kk)},Rt.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++,Sm(t,20))};function Sm(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>kl(t),e))}function Em(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Sk());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function Ck(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=mx(e.focusNode,e.focusOffset),r=gx(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let s=n.pmViewDesc;if(!(!s||!s.isText(n.nodeValue)))return r}}return n||r}function Sk(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function kl(t,e=!1){if(!(vn&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),Em(t),e||t.docView&&t.docView.dirty){let n=fu(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}}function Ek(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const ro=Bt&&Sr<15||zi&&kx<604;Dt.copy=Rt.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=ro?null:n.clipboardData,o=r.content(),{dom:l,text:a}=hm(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Ek(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Tk(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function Ak(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?io(t,r.value,null,i,e):io(t,r.textContent,r.innerHTML,i,e)},50)}function io(t,e,n,r,i){let s=pm(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,i,s||Y.empty)))return!0;if(!s)return!1;let o=Tk(s),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(s);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Tm(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," "):""}Rt.paste=(t,e)=>{let n=e;if(t.composing&&!vn)return;let r=ro?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&io(t,Tm(r),r.getData("text/html"),i,n)?n.preventDefault():Ak(t,n)};class Am{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const Mm=rn?"altKey":"ctrlKey";Dt.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(xl(n)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof se?i.to-1:i.to))){if(r&&r.mightDrag)o=se.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=se.create(t.state.doc,d.posBefore))}}let l=(o||t.state.selection).content(),{dom:a,text:c,slice:u}=hm(t,l);n.dataTransfer.clearData(),n.dataTransfer.setData(ro?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",ro||n.dataTransfer.setData("text/plain",c),t.dragging=new Am(u,!n[Mm],o)},Dt.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)},Rt.dragover=Rt.dragenter=(t,e)=>e.preventDefault(),Rt.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(xl(n));if(!i)return;let s=t.state.doc.resolve(i.pos),o=r&&r.slice;o?t.someProp("transformPasted",p=>{o=p(o,t)}):o=pm(t,Tm(n.dataTransfer),ro?null:n.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!n[Mm]);if(t.someProp("handleDrop",p=>p(t,n,o||Y.empty,l))){n.preventDefault();return}if(!o)return;n.preventDefault();let a=o?bp(t.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let c=t.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),d=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(u,u,o.content.firstChild):c.replaceRange(u,u,o),c.doc.eq(f))return;let h=c.doc.resolve(u);if(d&&se.isSelectable(o.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new se(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((g,v,w,S)=>p=S),c.setSelection(pu(t,h,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))},Dt.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())&&nr(t)},20))},Dt.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)},Dt.beforeinput=(t,e)=>{if(_t&&vn&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",s=>s(t,ti(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in Rt)Dt[t]=Rt[t];function so(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 Cl{constructor(e,n){this.toDOM=e,this.spec=n||si,this.side=this.spec.side||0}map(e,n,r,i){let{pos:s,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new ut(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Cl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&so(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Or{constructor(e,n){this.attrs=e,this.spec=n||si}map(e,n,r,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new ut(s,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Or&&so(this.attrs,e.attrs)&&so(this.spec,e.spec)}static is(e){return e.type instanceof Or}destroy(){}}class ku{constructor(e,n){this.attrs=e,this.spec=n||si}map(e,n,r,i){let s=e.mapResult(n.from+i,1);if(s.deleted)return null;let o=e.mapResult(n.to+i,-1);return o.deleted||o.pos<=s.pos?null:new ut(s.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),s;return i==n.from&&!(s=e.child(r)).isText&&i+s.nodeSize==n.to}eq(e){return this==e||e instanceof ku&&so(this.attrs,e.attrs)&&so(this.spec,e.spec)}destroy(){}}class ut{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new ut(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 ut(e,e,new Cl(n,r))}static inline(e,n,r,i){return new ut(e,n,new Or(r,i))}static node(e,n,r,i){return new ut(e,n,new ku(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Or}get widget(){return this.type instanceof Cl}}const qi=[],si={};class He{constructor(e,n){this.local=e.length?e:qi,this.children=n.length?n:qi}static create(e,n){return n.length?Sl(n,e,0,si):At}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}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,i+l,s)}}map(e,n,r){return this==At||e.maps.length==0?this:this.mapInner(e,n,0,0,r||si)}mapInner(e,n,r,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,i);a&&a.type.valid(n,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?Mk(this.children,o||[],e,n,r,i,s):o?new He(o.sort(oi),qi):At}add(e,n){return n.length?this==At?He.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=_m(n,l,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,u,c+1):i.splice(s,0,a,a+l.nodeSize,Sl(u,l,c+1,si)),s+=3}});let o=Om(s?Nm(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new He(o.length?this.local.concat(o).sort(oi):this.local,i||this.children)}remove(e){return e.length==0||this==At?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+n,a=r[s+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[s+2].removeInner(o,l+1);c!=At?r[s+2]=c:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new He(i,r):At}forChild(e,n){if(this==At)return this;if(n.isLeaf)return He.empty;let r,i;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 s=e+1,o=s+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof Or){let c=Math.max(s,a.from)-s,u=Math.min(o,a.to)-s;c<u&&(i||(i=[])).push(a.copy(c,u))}}if(i){let l=new He(i.sort(oi),qi);return r?new _r([l,r]):l}return r||At}eq(e){if(this==e)return!0;if(!(e instanceof He)||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 Cu(this.localsInner(e))}localsInner(e){if(this==At)return qi;if(e.inlineContent||!this.local.some(Or.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Or||n.push(this.local[r]);return n}}He.empty=new He([],[]),He.removeOverlap=Cu;const At=He.empty;class _r{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,si));return _r.from(r)}forChild(e,n){if(n.isLeaf)return He.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=At&&(s instanceof _r?r=r.concat(s.members):r.push(s))}return _r.from(r)}eq(e){if(!(e instanceof _r)||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 i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!n)n=s;else{r&&(n=n.slice(),r=!1);for(let o=0;o<s.length;o++)n.push(s[o])}}return n?Cu(r?n:n.sort(oi)):qi}static from(e){switch(e.length){case 0:return At;case 1:return e[0];default:return new _r(e.every(n=>n instanceof He)?e:e.reduce((n,r)=>n.concat(r instanceof He?r:r.members),[]))}}}function Mk(t,e,n,r,i,s,o){let l=t.slice();for(let c=0,u=s;c<n.maps.length;c++){let d=0;n.maps[c].forEach((f,h,p,g)=>{let v=g-p-(h-f);for(let w=0;w<l.length;w+=3){let S=l[w+1];if(S<0||f>S+u-d)continue;let x=l[w]+u-d;h>=x?l[w+1]=f<=x?-2:-1:f>=u&&v&&(l[w]+=v,l[w+1]+=v)}d+=v}),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]+s),d=u-i;if(d<0||d>=r.content.size){a=!0;continue}let f=n.map(t[c+1]+s,-1),h=f-i,{index:p,offset:g}=r.content.findIndex(d),v=r.maybeChild(p);if(v&&g==d&&g+v.nodeSize==h){let w=l[c+2].mapInner(n,v,u+1,t[c]+s+1,o);w!=At?(l[c]=d,l[c+1]=h,l[c+2]=w):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Ok(l,t,e,n,i,s,o),u=Sl(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,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new He(e.sort(oi),l)}function Om(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new ut(i.from+e,i.to+e,i.type))}return n}function Ok(t,e,n,r,i,s,o){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,i,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]+s+1);return n}function _m(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let s=0,o;s<t.length;s++)(o=t[s])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),t[s]=null);return i}function Nm(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Sl(t,e,n,r){let i=[],s=!1;e.forEach((l,a)=>{let c=_m(t,l,a+n);if(c){s=!0;let u=Sl(c,l,n+a+1,r);u!=At&&i.push(a,a+l.nodeSize,u)}});let o=Om(s?Nm(t):t,-n).sort(oi);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||i.length?new He(o,i):At}function oi(t,e){return t.from-e.from||t.to-e.to}function Cu(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,r.to),Dm(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),Dm(e,i,r.copy(s.from,r.to)));break}}}return e}function Dm(t,e,n){for(;e<t.length&&oi(n,t[e])>0;)e++;t.splice(e,0,n)}function Su(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=At&&e.push(r)}),t.cursorWrapper&&e.push(He.create(t.state.doc,[t.cursorWrapper.deco])),_r.from(e)}const _k={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Nk=Bt&&Sr<=11;class Dk{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 Rk{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Dk,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);Bt&&Sr<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Nk&&(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,_k)),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(sm(this.view)){if(this.suppressingSelectionUpdates)return nr(this.view);if(Bt&&Sr<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ei(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let s=e.focusNode;s;s=Ys(s))n.add(s);for(let s=e.anchorNode;s;s=Ys(s))if(n.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&sm(e)&&!this.ignoreSelectionChange(r),s=-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&&(s=s<0?d.from:Math.min(d.from,s),o=o<0?d.to:Math.max(d.to,o),d.typeOver&&(l=!0))}if(bn&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||Pk(e,d)!=h)&&f.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&bl(r)&&(c=fu(e))&&c.eq(ue.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,nr(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),Lk(e)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||nr(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++)n.push(e.addedNodes[u]);if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling;if(Bt&&Sr<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(i=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(s=f)}let o=i&&i.parentNode==e.target?Ct(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?Ct(s):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}:{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}}let Rm=new WeakMap,Lm=!1;function Lk(t){if(!Rm.has(t)&&(Rm.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=bn,Lm)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."),Lm=!0}}function Im(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return ei(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function Ik(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return Im(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Im(t,n):null}function Pk(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 Fk(t,e,n){let{node:r,fromOffset:i,toOffset:s,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}],bl(a)||c.push({node:a.focusNode,offset:a.focusOffset})),_t&&t.input.lastKeyCode===8)for(let v=s;v>i;v--){let w=r.childNodes[v-1],S=w.pmViewDesc;if(w.nodeName=="BR"&&!S){s=v;break}if(!S||S.size)break}let d=t.state.doc,f=t.someProp("domParser")||zc.fromSchema(t.state.schema),h=d.resolve(o),p=null,g=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:$k,context:h});if(c&&c[0].pos!=null){let v=c[0].pos,w=c[1]&&c[1].pos;w==null&&(w=v),p={anchor:v+o,head:w+o}}return{doc:g,sel:p,from:o,to:l}}function $k(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Nt&&/^(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||Nt&&/^(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 Bk=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function jk(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let N=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,A=fu(t,N);if(A&&!t.state.selection.eq(A)){if(_t&&vn&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",P=>P(t,ti(13,"Enter"))))return;let R=t.state.tr.setSelection(A);N=="pointer"?R.setMeta("pointer",!0):N=="key"&&R.scrollIntoView(),s&&R.setMeta("composition",s),t.dispatch(R)}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=Fk(t,e,n),u=t.state.doc,d=u.slice(c.from,c.to),f,h;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(f=t.state.selection.to,h="end"):(f=t.state.selection.from,h="start"),t.input.lastKeyCode=null;let p=Vk(d.content,c.doc.content,c.from,f,h);if((zi&&t.input.lastIOSEnter>Date.now()-225||vn)&&i.some(N=>N.nodeType==1&&!Bk.test(N.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",N=>N(t,ti(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof ce&&!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 N=Pm(t,t.state.doc,c.sel);if(N&&!N.eq(t.state.selection)){let A=t.state.tr.setSelection(N);s&&A.setMeta("composition",s),t.dispatch(A)}}return}t.input.domChangeCount++,t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof ce&&(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)),Bt&&Sr<=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),v=c.doc.resolveNoCache(p.endB-c.from),w=u.resolve(p.start),S=g.sameParent(v)&&g.parent.inlineContent&&w.end()>=p.endA,x;if((zi&&t.input.lastIOSEnter>Date.now()-225&&(!S||i.some(N=>N.nodeName=="DIV"||N.nodeName=="P"))||!S&&g.pos<c.doc.content.size&&!g.sameParent(v)&&(x=ue.findFrom(c.doc.resolve(g.pos+1),1,!0))&&x.head==v.pos)&&t.someProp("handleKeyDown",N=>N(t,ti(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&zk(u,p.start,p.endA,g,v)&&t.someProp("handleKeyDown",N=>N(t,ti(8,"Backspace")))){vn&&_t&&t.domObserver.suppressSelectionUpdates();return}_t&&vn&&p.endB==p.start&&(t.input.lastAndroidDelete=Date.now()),vn&&!S&&g.start()!=v.start()&&v.parentOffset==0&&g.depth==v.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,v=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{t.someProp("handleKeyDown",function(N){return N(t,ti(13,"Enter"))})},20));let y=p.start,C=p.endA,E,T,D;if(S){if(g.pos==v.pos)Bt&&Sr<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>nr(t),20)),E=t.state.tr.delete(y,C),T=u.resolve(p.start).marksAcross(u.resolve(p.endA));else if(p.endA==p.endB&&(D=Hk(g.parent.content.cut(g.parentOffset,v.parentOffset),w.parent.content.cut(w.parentOffset,p.endA-w.start()))))E=t.state.tr,D.type=="add"?E.addMark(y,C,D.mark):E.removeMark(y,C,D.mark);else if(g.parent.child(g.index()).isText&&g.index()==v.index()-(v.textOffset?0:1)){let N=g.parent.textBetween(g.parentOffset,v.parentOffset);if(t.someProp("handleTextInput",A=>A(t,y,C,N)))return;E=t.state.tr.insertText(N,y,C)}}if(E||(E=t.state.tr.replace(y,C,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let N=Pm(t,E.doc,c.sel);N&&!(_t&&vn&&t.composing&&N.empty&&(p.start!=p.endB||t.input.lastAndroidDelete<Date.now()-100)&&(N.head==y||N.head==E.mapping.map(C)-1)||Bt&&N.empty&&N.head==y)&&E.setSelection(N)}T&&E.ensureMarks(T),s&&E.setMeta("composition",s),t.dispatch(E.scrollIntoView())}function Pm(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:pu(t,e.resolve(n.anchor),e.resolve(n.head))}function Hk(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,o,l,a;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<n.length;u++)s=n[u].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=u=>u.mark(l.addToSet(u.marks));else if(i.length==0&&s.length==1)l=s[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(W.from(c).eq(t))return{mark:l,type:o}}function zk(t,e,n,r,i){if(n-e<=i.pos-r.pos||Eu(r,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&n==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=t.resolve(Eu(s,!0,!0));return!o.parent.isTextblock||o.pos>n||Eu(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Eu(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let s=t.node(r).maybeChild(t.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function Vk(t,e,n,r,i){let s=t.findDiffStart(e,n);if(s==null)return null;let{a:o,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let a=Math.max(0,s-Math.min(o,l));r-=o+a-s}if(o<s&&t.size<e.size){let a=r<=s&&r>=o?s-r:0;s-=a,s&&s<e.size&&Fm(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-o),o=s}else if(l<s){let a=r<=s&&r>=l?s-r:0;s-=a,s&&s<t.size&&Fm(t.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,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 Uk{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 ck,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(zm),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=jm(this),Bm(this),this.nodeViews=Hm(this),this.docView=Kp(this.state.doc,$m(this),Su(this),this.dom,this),this.domObserver=new Rk(this,(r,i,s,o)=>jk(this,r,i,s,o)),this.domObserver.start(),uk(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&&bu(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(zm),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(Em(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let h=Hm(this);qk(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&bu(this),this.editable=jm(this),Bm(this);let a=Su(this),c=$m(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=s||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(i.selection))&&(o=!0);let f=u=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Ex(this);if(o){this.domObserver.stop();let h=d&&(Bt||_t)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Wk(i.selection,e.selection);if(d){let p=_t?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Ck(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Kp(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Gx(this))?nr(this,h):(rm(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&Tx(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof se){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Lp(this,n.getBoundingClientRect(),e)}else Lp(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,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-n.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new Am(e.slice,e.move,i<0?void 0:se.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=n?n(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(Bt){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&&Ax(this.dom),nr(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 Dx(this,e)}coordsAtPos(e,n=1){return jp(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return Fx(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"))}destroy(){this.docView&&(dk(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Su(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,hx())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return hk(this,e)}dispatch(e){let n=this._props.dispatchTransaction;n?n.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return Nt&&this.root.nodeType===11&&bx(this.dom.ownerDocument)==this.dom&&Ik(this,e)||e}domSelection(){return this.root.getSelection()}}function $m(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"),[ut.node(0,t.state.doc.content.size,e)]}function Bm(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:ut.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function jm(t){return!t.someProp("editable",e=>e(t.state)===!1)}function Wk(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 Hm(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function qk(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function zm(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")}for(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:"'"},El={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Kk=typeof navigator<"u"&&/Mac/.test(navigator.platform),Jk=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),St=0;St<10;St++)Nr[48+St]=Nr[96+St]=String(St);for(var St=1;St<=24;St++)Nr[St+111]="F"+St;for(var St=65;St<=90;St++)Nr[St]=String.fromCharCode(St+32),El[St]=String.fromCharCode(St);for(var Tu in Nr)El.hasOwnProperty(Tu)||(El[Tu]=Nr[Tu]);function Gk(t){var e=Kk&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||Jk&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?El: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 Yk=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Xk(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,s,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))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Yk?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),o&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function Zk(t){let e=Object.create(null);for(let n in t)e[Xk(n)]=t[n];return e}function Au(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 Qk(t){return new je({props:{handleKeyDown:Mu(t)}})}function Mu(t){let e=Zk(t);return function(n,r){let i=Gk(r),s,o=e[Au(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Au(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.shiftKey||r.altKey||r.metaKey||i.charCodeAt(0)>127)&&(s=Nr[r.keyCode])&&s!=i){let l=e[Au(s,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}const eC=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Vm(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const tC=(t,e,n)=>{let r=Vm(t,n);if(!r)return!1;let i=Ou(r);if(!i){let o=r.blockRange(),l=o&&Pi(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(!s.type.spec.isolating&&Km(t,i,e))return!0;if(r.parent.content.size==0&&(Ki(s,"end")||se.isSelectable(s))){let o=ml(t.doc,r.before(),r.after(),Y.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(Ki(s,"end")?ue.findFrom(l.doc.resolve(l.mapping.map(i.pos,-1)),-1):se.create(l.doc,i.pos-s.nodeSize)),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},nC=(t,e,n)=>{let r=Vm(t,n);if(!r)return!1;let i=Ou(r);return i?Um(t,i,e):!1},rC=(t,e,n)=>{let r=Wm(t,n);if(!r)return!1;let i=_u(r);return i?Um(t,i,e):!1};function Um(t,e,n){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let u=i.lastChild;if(!u)return!1;i=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=ml(t.doc,s,a,Y.empty);if(!c||c.from!=s||c instanceof ht&&c.slice.size>=a-s)return!1;if(n){let u=t.tr.step(c);u.setSelection(ce.create(u.doc,s)),n(u.scrollIntoView())}return!0}function Ki(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 iC=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=Ou(r)}let o=s&&s.nodeBefore;return!o||!se.isSelectable(o)?!1:(e&&e(t.tr.setSelection(se.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function Ou(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 Wm(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const sC=(t,e,n)=>{let r=Wm(t,n);if(!r)return!1;let i=_u(r);if(!i)return!1;let s=i.nodeAfter;if(Km(t,i,e))return!0;if(r.parent.content.size==0&&(Ki(s,"start")||se.isSelectable(s))){let o=ml(t.doc,r.before(),r.after(),Y.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(Ki(s,"start")?ue.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):se.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},oC=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=_u(r)}let o=s&&s.nodeAfter;return!o||!se.isSelectable(o)?!1:(e&&e(t.tr.setSelection(se.create(t.doc,s.pos)).scrollIntoView()),!0)};function _u(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 lC=(t,e)=>{let n=t.selection,r=n instanceof se,i;if(r){if(n.node.isTextblock||!kr(t.doc,n.from))return!1;i=n.from}else if(i=pl(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(se.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},aC=(t,e)=>{let n=t.selection,r;if(n instanceof se){if(n.node.isTextblock||!kr(t.doc,n.to))return!1;r=n.to}else if(r=pl(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},cC=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&Pi(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},uC=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
|
39
|
+
`).scrollIntoView()),!0)};function qm(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 dC=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=qm(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,o.createAndFill());a.setSelection(ue.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},fC=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof yn||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=qm(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(o,s.createAndFill());l.setSelection(ce.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},hC=(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 s=n.before();if(Fi(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Pi(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)},pC=(t,e)=>{let{$from:n,to:r}=t.selection,i,s=n.sharedDepth(r);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(se.create(t.doc,i))),!0)};function mC(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||kr(t.doc,e.pos))?!1:(n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function Km(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s,o;if(r.type.spec.isolating||i.type.spec.isolating)return!1;if(mC(t,e,n))return!0;let l=e.parent.canReplace(e.index(),e.index()+1);if(l&&(s=(o=r.contentMatchAt(r.childCount)).findWrapping(i.type))&&o.matchType(s[0]||i.type).validEnd){if(n){let d=e.pos+i.nodeSize,f=W.empty;for(let g=s.length-1;g>=0;g--)f=W.from(s[g].create(null,f));f=W.from(r.copy(f));let h=t.tr.step(new pt(e.pos-1,d,e.pos,d,new Y(f,1,0),s.length,!0)),p=d+2*s.length;kr(h.doc,p)&&h.join(p),n(h.scrollIntoView())}return!0}let a=ue.findFrom(e,1),c=a&&a.$from.blockRange(a.$to),u=c&&Pi(c);if(u!=null&&u>=e.depth)return n&&n(t.tr.lift(c,u).scrollIntoView()),!0;if(l&&Ki(i,"start",!0)&&Ki(r,"end")){let d=r,f=[];for(;f.push(d),!d.isTextblock;)d=d.lastChild;let h=i,p=1;for(;!h.isTextblock;h=h.firstChild)p++;if(d.canReplace(d.childCount,d.childCount,h.content)){if(n){let g=W.empty;for(let w=f.length-1;w>=0;w--)g=W.from(f[w].copy(g));let v=t.tr.step(new pt(e.pos-f.length,e.pos+i.nodeSize,e.pos+p,e.pos+i.nodeSize-p,new Y(g,f.length,0),0,!0));n(v.scrollIntoView())}return!0}}return!1}function Jm(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(e.tr.setSelection(ce.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const gC=Jm(-1),yC=Jm(1);function bC(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),l=o&&Jc(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Gm(t,e=null){return function(n,r){let i=!1;for(let s=0;s<n.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[s];n.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)i=!0;else{let u=n.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,t)}})}if(!i)return!1;if(r){let s=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[o];s.setBlockType(l,a,t,e)}r(s.scrollIntoView())}return!0}}typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function vC(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),l=!1,a=o;if(!o)return!1;if(o.depth>=2&&i.node(o.depth-1).type.compatibleContent(t)&&o.startIndex==0){if(i.index(o.depth-1)==0)return!1;let u=n.doc.resolve(o.start-2);a=new ll(u,u,o.depth),o.endIndex<o.parent.childCount&&(o=new ll(i,n.doc.resolve(s.end(o.depth)),o.depth)),l=!0}let c=Jc(a,t,e,o);return c?(r&&r(wC(n.tr,o,c,l,t).scrollIntoView()),!0):!1}}function wC(t,e,n,r,i){let s=W.empty;for(let u=n.length-1;u>=0;u--)s=W.from(n[u].type.create(n[u].attrs,s));t.step(new pt(e.start-(r?2:0),e.end,e.start,e.end,new Y(s,0,0),n.length,!0));let o=0;for(let u=0;u<n.length;u++)n[u].type==i&&(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,f=!0;u<d;u++,f=!1)!f&&Fi(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function xC(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==t);return s?n?r.node(s.depth-1).type==t?kC(e,n,t,s):CC(e,n,s):!0:!1}}function kC(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new pt(s-1,o,s,o,new Y(W.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new ll(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=Pi(r);if(l==null)return!1;i.lift(r,l);let a=i.mapping.map(s,-1)-1;return kr(i.doc,a)&&i.join(a),e(i.scrollIntoView()),!0}function CC(t,e,n){let r=t.tr,i=n.parent;for(let h=n.end,p=n.endIndex-1,g=n.startIndex;p>g;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==i.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,o.content.append(a?W.empty:W.from(i))))return!1;let d=s.pos,f=d+o.nodeSize;return r.step(new pt(d-(l?1:0),f+(a?1:0),d+1,f-1,new Y((l?W.empty:W.from(i.copy(W.empty))).append(a?W.empty:W.from(i.copy(W.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function SC(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==t);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,a=l.child(o-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=W.from(c?t.create():null),d=new Y(W.from(t.create(null,W.from(l.type.create(null,u)))),c?3:1,0),f=s.start,h=s.end;n(e.tr.step(new pt(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}function Tl(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}class Al{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:n,state:r}=this,{view:i}=n,{tr:s}=r,o=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...u)=>{const d=a(...u)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){const{rawCommands:r,editor:i,state:s}=this,{view:o}=i,l=[],a=!!e,c=e||s.tr,u=()=>(!a&&n&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(c),l.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...g)=>{const v=this.buildProps(c,n),w=h(...g)(v);return l.push(w),d}])),run:u};return d}createCan(e){const{rawCommands:n,state:r}=this,i=!1,s=e||r.tr,o=this.buildProps(s,i);return{...Object.fromEntries(Object.entries(n).map(([a,c])=>[a,(...u)=>c(...u)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,i)}}buildProps(e,n=!0){const{rawCommands:r,editor:i,state:s}=this,{view:o}=i,l={tr:e,editor:i,view:o,state:Tl({state:s,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e,n),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}}class EC{constructor(){this.callbacks={}}on(e,n){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(n),this}emit(e,...n){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,n)),this}off(e,n){const r=this.callbacks[e];return r&&(n?this.callbacks[e]=r.filter(i=>i!==n):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}}function re(t,e,n){return t.config[e]===void 0&&t.parent?re(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?re(t.parent,e,n):null}):t.config[e]}function Ml(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Ym(t){const e=[],{nodeExtensions:n,markExtensions:r}=Ml(t),i=[...n,...r],s={default:null,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},a=re(o,"addGlobalAttributes",l);if(!a)return;a().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([f,h])=>{e.push({type:d,name:f,attribute:{...s,...h}})})})})}),i.forEach(o=>{const l={name:o.name,options:o.options,storage:o.storage},a=re(o,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([u,d])=>{const f={...s,...d};typeof(f==null?void 0:f.default)=="function"&&(f.default=f.default()),f!=null&&f.isRequired&&(f==null?void 0:f.default)===void 0&&delete f.default,e.push({type:o.name,name:u,attribute:f})})}),e}function mt(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function Ce(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const l=s?s.split(" "):[],a=r[i]?r[i].split(" "):[],c=l.filter(u=>!a.includes(u));r[i]=[...a,...c].join(" ")}else i==="style"?r[i]=[r[i],s].join("; "):r[i]=s}),r},{})}function Nu(t,e){return e.filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>Ce(n,r),{})}function Xm(t){return typeof t=="function"}function be(t,e=void 0,...n){return Xm(t)?e?t.bind(e)(...n):t(...n):t}function TC(t={}){return Object.keys(t).length===0&&t.constructor===Object}function AC(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Zm(t,e){return t.style?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const i=e.reduce((s,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):AC(n.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...r,...i}}}}function Qm(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&TC(n)?!1:n!=null))}function MC(t,e){var n;const r=Ym(t),{nodeExtensions:i,markExtensions:s}=Ml(t),o=(n=i.find(c=>re(c,"topNode")))===null||n===void 0?void 0:n.name,l=Object.fromEntries(i.map(c=>{const u=r.filter(w=>w.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((w,S)=>{const x=re(S,"extendNodeSchema",d);return{...w,...x?x(c):{}}},{}),h=Qm({...f,content:be(re(c,"content",d)),marks:be(re(c,"marks",d)),group:be(re(c,"group",d)),inline:be(re(c,"inline",d)),atom:be(re(c,"atom",d)),selectable:be(re(c,"selectable",d)),draggable:be(re(c,"draggable",d)),code:be(re(c,"code",d)),defining:be(re(c,"defining",d)),isolating:be(re(c,"isolating",d)),attrs:Object.fromEntries(u.map(w=>{var S;return[w.name,{default:(S=w==null?void 0:w.attribute)===null||S===void 0?void 0:S.default}]}))}),p=be(re(c,"parseHTML",d));p&&(h.parseDOM=p.map(w=>Zm(w,u)));const g=re(c,"renderHTML",d);g&&(h.toDOM=w=>g({node:w,HTMLAttributes:Nu(w,u)}));const v=re(c,"renderText",d);return v&&(h.toText=v),[c.name,h]})),a=Object.fromEntries(s.map(c=>{const u=r.filter(v=>v.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},f=t.reduce((v,w)=>{const S=re(w,"extendMarkSchema",d);return{...v,...S?S(c):{}}},{}),h=Qm({...f,inclusive:be(re(c,"inclusive",d)),excludes:be(re(c,"excludes",d)),group:be(re(c,"group",d)),spanning:be(re(c,"spanning",d)),code:be(re(c,"code",d)),attrs:Object.fromEntries(u.map(v=>{var w;return[v.name,{default:(w=v==null?void 0:v.attribute)===null||w===void 0?void 0:w.default}]}))}),p=be(re(c,"parseHTML",d));p&&(h.parseDOM=p.map(v=>Zm(v,u)));const g=re(c,"renderHTML",d);return g&&(h.toDOM=v=>g({mark:v,HTMLAttributes:Nu(v,u)})),[c.name,h]}));return new R1({topNode:o,nodes:l,marks:a})}function Du(t,e){return e.nodes[t]||e.marks[t]||null}function eg(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}const OC=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,l)=>{var a,c;const u=((c=(a=i.type.spec).toText)===null||c===void 0?void 0:c.call(a,{node:i,pos:s,parent:o,index:l}))||i.textContent||"%leaf%";n+=u.slice(0,Math.max(0,r-s))}),n};function Ru(t){return Object.prototype.toString.call(t)==="[object RegExp]"}class oo{constructor(e){this.find=e.find,this.handler=e.handler}}const _C=(t,e)=>{if(Ru(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 Ol(t){var e;const{editor:n,from:r,to:i,text:s,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===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let u=!1;const d=OC(c)+s;return o.forEach(f=>{if(u)return;const h=_C(d,f.find);if(!h)return;const p=a.state.tr,g=Tl({state:a.state,transaction:p}),v={from:r-(h[0].length-s.length),to:i},{commands:w,chain:S,can:x}=new Al({editor:n,state:g});f.handler({state:g,range:v,match:h,commands:w,chain:S,can:x})===null||!p.steps.length||(p.setMeta(l,{transform:p,from:r,to:i,text:s}),a.dispatch(p),u=!0)}),u}function NC(t){const{editor:e,rules:n}=t,r=new je({state:{init(){return null},apply(i,s){const o=i.getMeta(r);if(o)return o;const l=i.getMeta("applyInputRules");return!!l&&setTimeout(()=>{const{from:c,text:u}=l,d=c+u.length;Ol({editor:e,from:c,to:d,text:u,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return Ol({editor:e,from:s,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&Ol({editor:e,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?Ol({editor:e,from:o.pos,to:o.pos,text:`
|
40
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function DC(t){return typeof t=="number"}class RC{constructor(e){this.find=e.find,this.handler=e.handler}}const LC=(t,e,n)=>{if(Ru(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=t,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function IC(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=t,{commands:a,chain:c,can:u}=new Al({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,i,(h,p)=>{if(!h.isTextblock||h.type.spec.code)return;const g=Math.max(r,p),v=Math.min(i,p+h.content.size),w=h.textBetween(g-p,v-p,void 0,"");LC(w,s.find,o).forEach(x=>{if(x.index===void 0)return;const y=g+x.index+1,C=y+x[0].length,E={from:n.tr.mapping.map(y),to:n.tr.mapping.map(C)},T=s.handler({state:n,range:E,match:x,commands:a,chain:c,can:u,pasteEvent:o,dropEvent:l});d.push(T)})}),d.every(h=>h!==null)}const PC=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)===null||e===void 0||e.setData("text/html",t),n};function FC(t){const{editor:e,rules:n}=t;let r=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l=typeof DragEvent<"u"?new DragEvent("drop"):null;const a=({state:u,from:d,to:f,rule:h,pasteEvt:p})=>{const g=u.tr,v=Tl({state:u,transaction:g});if(!(!IC({editor:e,state:v,from:Math.max(d-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:l})||!g.steps.length))return l=typeof DragEvent<"u"?new DragEvent("drop"):null,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g};return n.map(u=>new je({view(d){const f=h=>{var p;r=!((p=d.dom.parentElement)===null||p===void 0)&&p.contains(h.target)?d.dom.parentElement:null};return window.addEventListener("dragstart",f),{destroy(){window.removeEventListener("dragstart",f)}}},props:{handleDOMEvents:{drop:(d,f)=>(s=r===d.dom.parentElement,l=f,!1),paste:(d,f)=>{var h;const p=(h=f.clipboardData)===null||h===void 0?void 0:h.getData("text/html");return o=f,i=!!(p!=null&&p.includes("data-pm-slice")),!1}}},appendTransaction:(d,f,h)=>{const p=d[0],g=p.getMeta("uiEvent")==="paste"&&!i,v=p.getMeta("uiEvent")==="drop"&&!s,w=p.getMeta("applyPasteRules"),S=!!w;if(!g&&!v&&!S)return;if(S){const{from:C,text:E}=w,T=C+E.length,D=PC(E);return a({rule:u,state:h,from:C,to:{b:T},pasteEvt:D})}const x=f.doc.content.findDiffStart(h.doc.content),y=f.doc.content.findDiffEnd(h.doc.content);if(!(!DC(x)||!y||x===y.b))return a({rule:u,state:h,from:x,to:y,pasteEvt:o})}}))}function $C(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return[...new Set(e)]}class Ji{constructor(e,n){this.splittableMarks=[],this.editor=n,this.extensions=Ji.resolve(e),this.schema=MC(this.extensions,n),this.setupExtensions()}static resolve(e){const n=Ji.sort(Ji.flatten(e)),r=$C(n.map(i=>i.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(i=>`'${i}'`).join(", ")}]. This can lead to issues.`),n}static flatten(e){return e.map(n=>{const r={name:n.name,options:n.options,storage:n.storage},i=re(n,"addExtensions",r);return i?[n,...this.flatten(i())]:n}).flat(10)}static sort(e){return e.sort((r,i)=>{const s=re(r,"priority")||100,o=re(i,"priority")||100;return s>o?-1:s<o?1:0})}get commands(){return this.extensions.reduce((e,n)=>{const r={name:n.name,options:n.options,storage:n.storage,editor:this.editor,type:Du(n.name,this.schema)},i=re(n,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,n=Ji.sort([...this.extensions].reverse()),r=[],i=[],s=n.map(o=>{const l={name:o.name,options:o.options,storage:o.storage,editor:e,type:Du(o.name,this.schema)},a=[],c=re(o,"addKeyboardShortcuts",l);let u={};if(o.type==="mark"&&o.config.exitable&&(u.ArrowRight=()=>jt.handleExit({editor:e,mark:o})),c){const g=Object.fromEntries(Object.entries(c()).map(([v,w])=>[v,()=>w({editor:e})]));u={...u,...g}}const d=Qk(u);a.push(d);const f=re(o,"addInputRules",l);eg(o,e.options.enableInputRules)&&f&&r.push(...f());const h=re(o,"addPasteRules",l);eg(o,e.options.enablePasteRules)&&h&&i.push(...h());const p=re(o,"addProseMirrorPlugins",l);if(p){const g=p();a.push(...g)}return a}).flat();return[NC({editor:e,rules:r}),...FC({editor:e,rules:i}),...s]}get attributes(){return Ym(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:n}=Ml(this.extensions);return Object.fromEntries(n.filter(r=>!!re(r,"addNodeView")).map(r=>{const i=this.attributes.filter(a=>a.type===r.name),s={name:r.name,options:r.options,storage:r.storage,editor:e,type:mt(r.name,this.schema)},o=re(r,"addNodeView",s);if(!o)return[];const l=(a,c,u,d)=>{const f=Nu(a,i);return o()({editor:e,node:a,getPos:u,decorations:d,HTMLAttributes:f,extension:r})};return[r.name,l]}))}setupExtensions(){this.extensions.forEach(e=>{var n;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Du(e.name,this.schema)};e.type==="mark"&&(!((n=be(re(e,"keepOnSplit",r)))!==null&&n!==void 0)||n)&&this.splittableMarks.push(e.name);const i=re(e,"onBeforeCreate",r),s=re(e,"onCreate",r),o=re(e,"onUpdate",r),l=re(e,"onSelectionUpdate",r),a=re(e,"onTransaction",r),c=re(e,"onFocus",r),u=re(e,"onBlur",r),d=re(e,"onDestroy",r);i&&this.editor.on("beforeCreate",i),s&&this.editor.on("create",s),o&&this.editor.on("update",o),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}}function BC(t){return Object.prototype.toString.call(t).slice(8,-1)}function Lu(t){return BC(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function _l(t,e){const n={...t};return Lu(t)&&Lu(e)&&Object.keys(e).forEach(r=>{Lu(e[r])?r in t?n[r]=_l(t[r],e[r]):Object.assign(n,{[r]:e[r]}):Object.assign(n,{[r]:e[r]})}),n}class Ue{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=be(re(this,"addOptions",{name:this.name}))),this.storage=be(re(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Ue(e)}configure(e={}){const n=this.extend();return n.parent=this.parent,n.options=_l(this.options,e),n.storage=be(re(n,"addStorage",{name:n.name,options:n.options})),n}extend(e={}){const n=new Ue({...this.config,...e});return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=be(re(n,"addOptions",{name:n.name})),n.storage=be(re(n,"addStorage",{name:n.name,options:n.options})),n}}function tg(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=`
|
41
41
|
|
42
|
-
`,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(a,c,u,d)=>{var f;a.isBlock&&c>r&&(l+=s);const h=o==null?void 0:o[a.type.name];if(h)return u&&(l+=h({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(f=a==null?void 0:a.text)===null||f===void 0?void 0:f.slice(Math.max(r,c)-c,i-c))}),l}function rg(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}const jC=Ue.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new je({key:new We("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(u=>u.$from.pos)),l=Math.max(...s.map(u=>u.$to.pos)),a=rg(n);return ng(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),HC=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),zC=(t=!1)=>({commands:e})=>e.setContent("",t),VC=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:s,$to:o})=>{t.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),f=c.resolve(u.map(a+l.nodeSize)),h=d.blockRange(f);if(!h)return;const p=Pi(h);if(l.type.isTextblock){const{defaultType:g}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,g)}(p||p===0)&&e.lift(h,p)})}),!0},UC=t=>e=>t(e),WC=()=>({state:t,dispatch:e})=>fC(t,e),qC=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new ce(r.doc.resolve(o-1))),!0},KC=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const l=i.before(s),a=i.after(s);t.delete(l,a).scrollIntoView()}return!0}return!1},JC=t=>({tr:e,state:n,dispatch:r})=>{const i=mt(t,n.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const a=s.before(o),c=s.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},GC=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},YC=()=>({state:t,dispatch:e})=>eC(t,e),XC=()=>({commands:t})=>t.keyboardShortcut("Enter"),ZC=()=>({state:t,dispatch:e})=>dC(t,e);function Nl(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:Lu(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Pu(t,e,n={}){return t.find(r=>r.type===e&&Nl(r.attrs,n))}function QC(t,e,n={}){return!!Pu(t,e,n)}function Fu(t,e,n={}){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if(t.parentOffset===r.offset&&r.offset!==0&&(r=t.parent.childBefore(t.parentOffset)),!r.node)return;const i=Pu([...r.node.marks],e,n);if(!i)return;let s=r.index,o=t.start()+r.offset,l=s+1,a=o+r.node.nodeSize;for(Pu([...r.node.marks],e,n);s>0&&i.isInSet(t.parent.child(s-1).marks);)s-=1,o-=t.parent.child(s).nodeSize;for(;l<t.parent.childCount&&QC([...t.parent.child(l).marks],e,n);)a+=t.parent.child(l).nodeSize,l+=1;return{from:o,to:a}}function Dr(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}const eS=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=Dr(t,r.schema),{doc:o,selection:l}=n,{$from:a,from:c,to:u}=l;if(i){const d=Fu(a,s,e);if(d&&d.from<=c&&d.to>=u){const f=ce.create(o,d.from,d.to);n.setSelection(f)}}return!0},tS=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 $u(t){return t instanceof ce}function rr(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function ig(t,e=null){if(!e)return null;const n=ue.atStart(t),r=ue.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,s=r.to;return e==="all"?ce.create(t,rr(0,i,s),rr(t.content.size,i,s)):ce.create(t,rr(e,i,s),rr(e,i,s))}function Dl(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const nS=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{Dl()&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(s&&t===null&&!$u(n.state.selection))return o(),!0;const l=ig(i.doc,t)||n.state.selection,a=n.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},rS=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),iS=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),sg=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&&sg(r)}return t};function og(t){const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return sg(n)}function Rl(t,e,n){n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{return Array.isArray(t)&&t.length>0?W.fromArray(t.map(o=>e.nodeFromJSON(o))):e.nodeFromJSON(t)}catch(s){return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",s),Rl("",e,n)}if(i){const s=Vc.fromSchema(e);return n.slice?s.parseSlice(og(t),n.parseOptions).content:s.parse(og(t),n.parseOptions)}return Rl("",e,n)}function sS(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof ht||i instanceof pt))return;const s=t.mapping.maps[r];let o=0;s.forEach((l,a,c,u)=>{o===0&&(o=u)}),t.setSelection(ue.near(t.doc.resolve(o),n))}const oS=t=>t.toString().startsWith("<"),lS=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{if(i){n={parseOptions:{},updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};const o=Rl(e,s.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if(o.toString()==="<>")return!0;let{from:l,to:a}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},c=!0,u=!0;if((oS(o)?o:[o]).forEach(h=>{h.check(),c=c?h.isText&&h.marks.length===0:!1,u=u?h.isBlock:!1}),l===a&&u){const{parent:h}=r.doc.resolve(l);h.isTextblock&&!h.type.spec.code&&!h.childCount&&(l-=1,a+=1)}let f;c?(Array.isArray(e)?f=e.map(h=>h.text||"").join(""):typeof e=="object"&&e&&e.text?f=e.text:f=e,r.insertText(f,l,a)):(f=o,r.replaceWith(l,a,f)),n.updateSelection&&sS(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:l,text:f}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:l,text:f})}return!0},aS=()=>({state:t,dispatch:e})=>lC(t,e),cS=()=>({state:t,dispatch:e})=>aC(t,e),uS=()=>({state:t,dispatch:e})=>tC(t,e),dS=()=>({state:t,dispatch:e})=>sC(t,e),fS=()=>({tr:t,state:e,dispatch:n})=>{try{const r=pl(e.doc,e.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),n&&n(t),!0)}catch{return!1}},hS=()=>({state:t,dispatch:e,tr:n})=>{try{const r=pl(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},pS=()=>({state:t,dispatch:e})=>nC(t,e),mS=()=>({state:t,dispatch:e})=>rC(t,e);function lg(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function gS(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,s,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))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Dl()||lg()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}const yS=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=gS(t).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a==null||a.steps.forEach(c=>{const u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function lo(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,o=e?mt(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(d,f)=>{if(d.isText)return;const h=Math.max(r,f),p=Math.min(i,f+d.nodeSize);l.push({node:d,from:h,to:p})});const a=i-r,c=l.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>Nl(d.node.attrs,n,{strict:!1}));return s?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=a}const bS=(t,e={})=>({state:n,dispatch:r})=>{const i=mt(t,n.schema);return lo(n,i,e)?cC(n,r):!1},vS=()=>({state:t,dispatch:e})=>hC(t,e),wS=t=>({state:e,dispatch:n})=>{const r=mt(t,e.schema);return xC(r)(e,n)},xS=()=>({state:t,dispatch:e})=>uC(t,e);function Ll(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function ag(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}const kS=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=Ll(typeof t=="string"?t:t.name,r.schema);return l?(l==="node"&&(s=mt(t,r.schema)),l==="mark"&&(o=Dr(t,r.schema)),i&&n.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,u)=>{s&&s===c.type&&n.setNodeMarkup(u,void 0,ag(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(d=>{o===d.type&&n.addMark(u,u+c.nodeSize,o.create(ag(d.attrs,e)))})})}),!0):!1},CS=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),SS=()=>({tr:t,commands:e})=>e.setTextSelection({from:0,to:t.doc.content.size}),ES=()=>({state:t,dispatch:e})=>iC(t,e),TS=()=>({state:t,dispatch:e})=>oC(t,e),AS=()=>({state:t,dispatch:e})=>pC(t,e),MS=()=>({state:t,dispatch:e})=>yC(t,e),OS=()=>({state:t,dispatch:e})=>gC(t,e);function cg(t,e,n={}){return Rl(t,e,{slice:!1,parseOptions:n})}const _S=(t,e=!1,n={})=>({tr:r,editor:i,dispatch:s})=>{const{doc:o}=r,l=cg(t,i.schema,n);return s&&r.replaceWith(0,o.content.size,l).setMeta("preventUpdate",!e),!0};function ao(t,e){const n=Dr(e,t.schema),{from:r,to:i,empty:s}=t.selection,o=[];s?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function NS(t,e){const n=new Zc(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function DS(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 RS(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function Bu(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 ju(t){return e=>Bu(e.$from,t)}function LS(t,e){const n=Nn.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function IS(t,e){const n={from:0,to:t.content.size};return ng(t,n,e)}function PS(t,e){const n=mt(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function ug(t,e){const n=Ll(typeof e=="string"?e:e.name,t.schema);return n==="node"?PS(t,e):n==="mark"?ao(t,e):{}}function FS(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function $S(t){const e=FS(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,o)=>o!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function BS(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=n[s];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(s).map(l,-1),u=e.slice(s).map(a),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),$S(r)}function Hu(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t-1),o=Fu(s,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}function Il(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}function zu(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?Dr(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>Nl(d.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:d,$to:f})=>{const h=d.pos,p=f.pos;t.doc.nodesBetween(h,p,(g,v)=>{if(!g.isText&&!g.marks.length)return;const w=Math.max(h,v),S=Math.min(p,v+g.nodeSize),x=S-w;o+=x,l.push(...g.marks.map(y=>({mark:y,from:w,to:S})))})}),o===0)return!1;const a=l.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>Nl(d.mark.attrs,n,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=l.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,f)=>d+f.to-f.from,0);return(a>0?a+c:a)>=o}function jS(t,e,n={}){if(!e)return lo(t,null,n)||zu(t,null,n);const r=Ll(e,t.schema);return r==="node"?lo(t,e,n):r==="mark"?zu(t,e,n):!1}function dg(t,e){const{nodeExtensions:n}=Ml(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=be(re(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function HS(t){var e;const n=(e=t.type.createAndFill())===null||e===void 0?void 0:e.toJSON(),r=t.toJSON();return JSON.stringify(n)===JSON.stringify(r)}function fg(t){return t instanceof se}function zS(t,e,n){const i=t.state.doc.content.size,s=rr(e,0,i),o=rr(n,0,i),l=t.coordsAtPos(s),a=t.coordsAtPos(o,-1),c=Math.min(l.top,a.top),u=Math.max(l.bottom,a.bottom),d=Math.min(l.left,a.left),f=Math.max(l.right,a.right),h=f-d,p=u-c,w={top:c,bottom:u,left:d,right:f,width:h,height:p,x:d,y:c};return{...w,toJSON:()=>w}}function VS(t,e,n){var r;const{selection:i}=e;let s=null;if($u(i)&&(s=i.$cursor),s){const l=(r=t.storedMarks)!==null&&r!==void 0?r:s.marks();return!!n.isInSet(l)||!l.some(a=>a.type.excludes(n))}const{ranges:o}=i;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,f)=>{if(c)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(n));c=h&&p}return!c}),c})}const US=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:l}=s,a=Dr(t,r.schema);if(i)if(o){const c=ao(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,(f,h)=>{const p=Math.max(h,u),g=Math.min(h+f.nodeSize,d);f.marks.find(w=>w.type===a)?f.marks.forEach(w=>{a===w.type&&n.addMark(p,g,a.create({...w.attrs,...e}))}):n.addMark(p,g,a.create(e))})});return VS(r,n,a)},WS=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),qS=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=mt(t,n.schema);return s.isTextblock?i().command(({commands:o})=>Ym(s,e)(n)?!0:o.clearNodes()).command(({state:o})=>Ym(s,e)(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},KS=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=rr(t,0,r.content.size),s=se.create(r,i);e.setSelection(s)}return!0},JS=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,o=ce.atStart(r).from,l=ce.atEnd(r).to,a=rr(i,o,l),c=rr(s,o,l),u=ce.create(r,a,c);e.setSelection(u)}return!0},GS=t=>({state:e,dispatch:n})=>{const r=mt(t,e.schema);return SC(r)(e,n)};function hg(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e==null?void 0:e.includes(i.type.name));t.tr.ensureMarks(r)}}const YS=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,u=Il(c,l.node().type.name,l.node().attrs);if(s instanceof se&&s.node.isBlock)return!l.parentOffset||!Fi(o,l.pos)?!1:(r&&(t&&hg(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;if(r){const d=a.parentOffset===a.parent.content.size;s instanceof ce&&e.deleteSelection();const f=l.depth===0?void 0:DS(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,p=Fi(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&Fi(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:u}]:void 0),p&&(e.split(e.mapping.map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f)){const g=e.mapping.map(l.before()),v=e.doc.resolve(g);l.node(-1).canReplaceWith(v.index(),v.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}t&&hg(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return!0},XS=t=>({tr:e,state:n,dispatch:r,editor:i})=>{var s;const o=mt(t,n.schema),{$from:l,$to:a}=n.selection,c=n.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;const u=l.node(-1);if(u.type!==o)return!1;const d=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(r){let v=W.empty;const w=l.index(-1)?1:l.index(-2)?2:3;for(let T=l.depth-w;T>=l.depth-3;T-=1)v=W.from(l.node(T).copy(v));const S=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,x=Il(d,l.node().type.name,l.node().attrs),y=((s=o.contentMatch.defaultType)===null||s===void 0?void 0:s.createAndFill(x))||void 0;v=v.append(W.from(o.createAndFill(null,y)||void 0));const C=l.before(l.depth-(w-1));e.replace(C,l.after(-S),new Y(v,4-w,0));let E=-1;e.doc.nodesBetween(C,e.doc.content.size,(T,D)=>{if(E>-1)return!1;T.isTextblock&&T.content.size===0&&(E=D+1)}),E>-1&&e.setSelection(ce.near(e.doc.resolve(E))),e.scrollIntoView()}return!0}const f=a.pos===l.end()?u.contentMatchAt(0).defaultType:null,h=Il(d,u.type.name,u.attrs),p=Il(d,l.node().type.name,l.node().attrs);e.delete(l.pos,a.pos);const g=f?[{type:o,attrs:h},{type:f,attrs:p}]:[{type:o,attrs:h}];if(!Fi(e.doc,l.pos,2))return!1;if(r){const{selection:v,storedMarks:w}=n,{splittableMarks:S}=i.extensionManager,x=w||v.$to.parentOffset&&v.$from.marks();if(e.split(l.pos,2,g).scrollIntoView(),!x||!r)return!0;const y=x.filter(C=>S.includes(C.type.name));e.ensureMarks(y)}return!0},Vu=(t,e)=>{const n=ju(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&kr(t.doc,n.pos)&&t.join(n.pos),!0},Uu=(t,e)=>{const n=ju(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&kr(t.doc,r)&&t.join(r),!0};var ZS=Object.freeze({__proto__:null,blur:HC,clearContent:zC,clearNodes:VC,command:UC,createParagraphNear:WC,cut:qC,deleteCurrentNode:KC,deleteNode:JC,deleteRange:GC,deleteSelection:YC,enter:XC,exitCode:ZC,extendMarkRange:eS,first:tS,focus:nS,forEach:rS,insertContent:iS,insertContentAt:lS,joinUp:aS,joinDown:cS,joinBackward:uS,joinForward:dS,joinItemBackward:fS,joinItemForward:hS,joinTextblockBackward:pS,joinTextblockForward:mS,keyboardShortcut:yS,lift:bS,liftEmptyBlock:vS,liftListItem:wS,newlineInCode:xS,resetAttributes:kS,scrollIntoView:CS,selectAll:SS,selectNodeBackward:ES,selectNodeForward:TS,selectParentNode:AS,selectTextblockEnd:MS,selectTextblockStart:OS,setContent:_S,setMark:US,setMeta:WS,setNode:qS,setNodeSelection:KS,setTextSelection:JS,sinkListItem:GS,splitBlock:YS,splitListItem:XS,toggleList:(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:f}=i.extensionManager,h=mt(t,o.schema),p=mt(e,o.schema),{selection:g,storedMarks:v}=o,{$from:w,$to:S}=g,x=w.blockRange(S),y=v||g.$to.parentOffset&&g.$from.marks();if(!x)return!1;const C=ju(E=>dg(E.type.name,d))(g);if(x.depth>=1&&C&&x.depth-C.depth<=1){if(C.node.type===h)return c.liftListItem(p);if(dg(C.node.type.name,d)&&h.validContent(C.node.content)&&l)return a().command(()=>(s.setNodeMarkup(C.pos,h),!0)).command(()=>Vu(s,h)).command(()=>Uu(s,h)).run()}return!n||!y||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Vu(s,h)).command(()=>Uu(s,h)).run():a().command(()=>{const E=u().wrapInList(h,r),T=y.filter(D=>f.includes(D.type.name));return s.ensureMarks(T),E?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Vu(s,h)).command(()=>Uu(s,h)).run()},toggleMark:(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=Dr(t,r.schema);return zu(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},toggleNode:(t,e,n={})=>({state:r,commands:i})=>{const s=mt(t,r.schema),o=mt(e,r.schema);return lo(r,s,n)?i.setNode(o):i.setNode(s,n)},toggleWrap:(t,e={})=>({state:n,commands:r})=>{const i=mt(t,n.schema);return lo(n,i,e)?r.lift(i):r.wrapIn(i,e)},undoInputRule:()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const o=t.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(s.text){const a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,t.schema.text(s.text,a))}else o.delete(s.from,s.to)}return!0}}return!1},unsetAllMarks:()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(s=>{t.removeMark(s.$from.pos,s.$to.pos)}),!0},unsetMark:(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,a=Dr(t,r.schema),{$from:c,empty:u,ranges:d}=l;if(!i)return!0;if(u&&o){let{from:f,to:h}=l;const p=(s=c.marks().find(v=>v.type===a))===null||s===void 0?void 0:s.attrs,g=Fu(c,a,p);g&&(f=g.from,h=g.to),n.removeMark(f,h,a)}else d.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,a)});return n.removeStoredMark(a),!0},updateAttributes:(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=Ll(typeof t=="string"?t:t.name,r.schema);return l?(l==="node"&&(s=mt(t,r.schema)),l==="mark"&&(o=Dr(t,r.schema)),i&&n.selection.ranges.forEach(a=>{const c=a.$from.pos,u=a.$to.pos;r.doc.nodesBetween(c,u,(d,f)=>{s&&s===d.type&&n.setNodeMarkup(f,void 0,{...d.attrs,...e}),o&&d.marks.length&&d.marks.forEach(h=>{if(o===h.type){const p=Math.max(f,c),g=Math.min(f+d.nodeSize,u);n.addMark(p,g,o.create({...h.attrs,...e}))}})})}),!0):!1},wrapIn:(t,e={})=>({state:n,dispatch:r})=>{const i=mt(t,n.schema);return bC(i,e)(n,r)},wrapInList:(t,e={})=>({state:n,dispatch:r})=>{const i=mt(t,n.schema);return vC(i,e)(n,r)}});const QS=Ue.create({name:"commands",addCommands(){return{...ZS}}}),eE=Ue.create({name:"editable",addProseMirrorPlugins(){return[new je({key:new We("editable"),props:{editable:()=>this.editor.options.editable}})]}}),tE=Ue.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new je({key:new We("focusEvents"),props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),nE=Ue.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:f,parent:h}=d,p=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,g=p.parent.type.spec.isolating,v=d.pos-d.parentOffset,w=g&&p.parent.childCount===1?v===d.pos:ue.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!w||w&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Dl()||lg()?s:i},addProseMirrorPlugins(){return[new je({key:new We("clearDocument"),appendTransaction:(t,e,n)=>{if(!(t.some(p=>p.docChanged)&&!e.doc.eq(n.doc)))return;const{empty:i,from:s,to:o}=e.selection,l=ue.atStart(e.doc).from,a=ue.atEnd(e.doc).to;if(i||!(s===l&&o===a)||!(n.doc.textBetween(0,n.doc.content.size," "," ").length===0))return;const d=n.tr,f=Tl({state:n,transaction:d}),{commands:h}=new Al({editor:this.editor,state:f});if(h.clearNodes(),!!d.steps.length)return d}})]}}),rE=Ue.create({name:"tabindex",addProseMirrorPlugins(){return[new je({key:new We("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});class li{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new li(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 li(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 li(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,s=this.pos+r+1,o=this.resolvedPos.doc.resolve(s);if(!i&&o.depth<=this.depth)return;const l=new li(o,this.editor,i,i?n:null);i&&(l.actualDepth=this.depth+1),e.push(new li(o,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const s=i.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const a=o[l];if(s[a]!==n[a])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(n);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&s.every(a=>n[a]===o.node.attrs[a])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){const n=this.editor.state.selection;this.editor.chain().setTextSelection(this.from).updateAttributes(this.node.type.name,e).setTextSelection(n.from).run()}}const iE=`.ProseMirror {
|
42
|
+
`,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(a,c,u,d)=>{var f;a.isBlock&&c>r&&(l+=s);const h=o==null?void 0:o[a.type.name];if(h)return u&&(l+=h({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(f=a==null?void 0:a.text)===null||f===void 0?void 0:f.slice(Math.max(r,c)-c,i-c))}),l}function ng(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}const jC=Ue.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new je({key:new We("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:s}=i,o=Math.min(...s.map(u=>u.$from.pos)),l=Math.max(...s.map(u=>u.$to.pos)),a=ng(n);return tg(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),HC=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),zC=(t=!1)=>({commands:e})=>e.setContent("",t),VC=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:s,$to:o})=>{t.doc.nodesBetween(s.pos,o.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),f=c.resolve(u.map(a+l.nodeSize)),h=d.blockRange(f);if(!h)return;const p=Pi(h);if(l.type.isTextblock){const{defaultType:g}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,g)}(p||p===0)&&e.lift(h,p)})}),!0},UC=t=>e=>t(e),WC=()=>({state:t,dispatch:e})=>fC(t,e),qC=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new ce(r.doc.resolve(o-1))),!0},KC=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const l=i.before(s),a=i.after(s);t.delete(l,a).scrollIntoView()}return!0}return!1},JC=t=>({tr:e,state:n,dispatch:r})=>{const i=mt(t,n.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const a=s.before(o),c=s.after(o);e.delete(a,c).scrollIntoView()}return!0}return!1},GC=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},YC=()=>({state:t,dispatch:e})=>eC(t,e),XC=()=>({commands:t})=>t.keyboardShortcut("Enter"),ZC=()=>({state:t,dispatch:e})=>dC(t,e);function Nl(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:Ru(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function Iu(t,e,n={}){return t.find(r=>r.type===e&&Nl(r.attrs,n))}function QC(t,e,n={}){return!!Iu(t,e,n)}function Pu(t,e,n={}){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if(t.parentOffset===r.offset&&r.offset!==0&&(r=t.parent.childBefore(t.parentOffset)),!r.node)return;const i=Iu([...r.node.marks],e,n);if(!i)return;let s=r.index,o=t.start()+r.offset,l=s+1,a=o+r.node.nodeSize;for(Iu([...r.node.marks],e,n);s>0&&i.isInSet(t.parent.child(s-1).marks);)s-=1,o-=t.parent.child(s).nodeSize;for(;l<t.parent.childCount&&QC([...t.parent.child(l).marks],e,n);)a+=t.parent.child(l).nodeSize,l+=1;return{from:o,to:a}}function Dr(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}const eS=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const s=Dr(t,r.schema),{doc:o,selection:l}=n,{$from:a,from:c,to:u}=l;if(i){const d=Pu(a,s,e);if(d&&d.from<=c&&d.to>=u){const f=ce.create(o,d.from,d.to);n.setSelection(f)}}return!0},tS=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 Fu(t){return t instanceof ce}function rr(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function rg(t,e=null){if(!e)return null;const n=ue.atStart(t),r=ue.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,s=r.to;return e==="all"?ce.create(t,rr(0,i,s),rr(t.content.size,i,s)):ce.create(t,rr(e,i,s),rr(e,i,s))}function Dl(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const nS=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{Dl()&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(s&&t===null&&!Fu(n.state.selection))return o(),!0;const l=rg(i.doc,t)||n.state.selection,a=n.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},rS=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),iS=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),ig=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&&ig(r)}return t};function sg(t){const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return ig(n)}function Rl(t,e,n){n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{return Array.isArray(t)&&t.length>0?W.fromArray(t.map(o=>e.nodeFromJSON(o))):e.nodeFromJSON(t)}catch(s){return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",s),Rl("",e,n)}if(i){const s=zc.fromSchema(e);return n.slice?s.parseSlice(sg(t),n.parseOptions).content:s.parse(sg(t),n.parseOptions)}return Rl("",e,n)}function sS(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof ht||i instanceof pt))return;const s=t.mapping.maps[r];let o=0;s.forEach((l,a,c,u)=>{o===0&&(o=u)}),t.setSelection(ue.near(t.doc.resolve(o),n))}const oS=t=>t.toString().startsWith("<"),lS=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{if(i){n={parseOptions:{},updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};const o=Rl(e,s.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if(o.toString()==="<>")return!0;let{from:l,to:a}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},c=!0,u=!0;if((oS(o)?o:[o]).forEach(h=>{h.check(),c=c?h.isText&&h.marks.length===0:!1,u=u?h.isBlock:!1}),l===a&&u){const{parent:h}=r.doc.resolve(l);h.isTextblock&&!h.type.spec.code&&!h.childCount&&(l-=1,a+=1)}let f;c?(Array.isArray(e)?f=e.map(h=>h.text||"").join(""):typeof e=="object"&&e&&e.text?f=e.text:f=e,r.insertText(f,l,a)):(f=o,r.replaceWith(l,a,f)),n.updateSelection&&sS(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:l,text:f}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:l,text:f})}return!0},aS=()=>({state:t,dispatch:e})=>lC(t,e),cS=()=>({state:t,dispatch:e})=>aC(t,e),uS=()=>({state:t,dispatch:e})=>tC(t,e),dS=()=>({state:t,dispatch:e})=>sC(t,e),fS=()=>({tr:t,state:e,dispatch:n})=>{try{const r=pl(e.doc,e.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),n&&n(t),!0)}catch{return!1}},hS=()=>({state:t,dispatch:e,tr:n})=>{try{const r=pl(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},pS=()=>({state:t,dispatch:e})=>nC(t,e),mS=()=>({state:t,dispatch:e})=>rC(t,e);function og(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function gS(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,s,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))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Dl()||og()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}const yS=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=gS(t).split(/-(?!$)/),o=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a==null||a.steps.forEach(c=>{const u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function lo(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,o=e?mt(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(d,f)=>{if(d.isText)return;const h=Math.max(r,f),p=Math.min(i,f+d.nodeSize);l.push({node:d,from:h,to:p})});const a=i-r,c=l.filter(d=>o?o.name===d.node.type.name:!0).filter(d=>Nl(d.node.attrs,n,{strict:!1}));return s?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=a}const bS=(t,e={})=>({state:n,dispatch:r})=>{const i=mt(t,n.schema);return lo(n,i,e)?cC(n,r):!1},vS=()=>({state:t,dispatch:e})=>hC(t,e),wS=t=>({state:e,dispatch:n})=>{const r=mt(t,e.schema);return xC(r)(e,n)},xS=()=>({state:t,dispatch:e})=>uC(t,e);function Ll(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function lg(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}const kS=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=Ll(typeof t=="string"?t:t.name,r.schema);return l?(l==="node"&&(s=mt(t,r.schema)),l==="mark"&&(o=Dr(t,r.schema)),i&&n.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,u)=>{s&&s===c.type&&n.setNodeMarkup(u,void 0,lg(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(d=>{o===d.type&&n.addMark(u,u+c.nodeSize,o.create(lg(d.attrs,e)))})})}),!0):!1},CS=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),SS=()=>({tr:t,commands:e})=>e.setTextSelection({from:0,to:t.doc.content.size}),ES=()=>({state:t,dispatch:e})=>iC(t,e),TS=()=>({state:t,dispatch:e})=>oC(t,e),AS=()=>({state:t,dispatch:e})=>pC(t,e),MS=()=>({state:t,dispatch:e})=>yC(t,e),OS=()=>({state:t,dispatch:e})=>gC(t,e);function ag(t,e,n={}){return Rl(t,e,{slice:!1,parseOptions:n})}const _S=(t,e=!1,n={})=>({tr:r,editor:i,dispatch:s})=>{const{doc:o}=r,l=ag(t,i.schema,n);return s&&r.replaceWith(0,o.content.size,l).setMeta("preventUpdate",!e),!0};function ao(t,e){const n=Dr(e,t.schema),{from:r,to:i,empty:s}=t.selection,o=[];s?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function NS(t,e){const n=new Xc(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function DS(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 RS(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function $u(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 Bu(t){return e=>$u(e.$from,t)}function LS(t,e){const n=Nn.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function IS(t,e){const n={from:0,to:t.content.size};return tg(t,n,e)}function PS(t,e){const n=mt(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function cg(t,e){const n=Ll(typeof e=="string"?e:e.name,t.schema);return n==="node"?PS(t,e):n==="mark"?ao(t,e):{}}function FS(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function $S(t){const e=FS(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,o)=>o!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function BS(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,a)=>{o.push({from:l,to:a})});else{const{from:l,to:a}=n[s];if(l===void 0||a===void 0)return;o.push({from:l,to:a})}o.forEach(({from:l,to:a})=>{const c=e.slice(s).map(l,-1),u=e.slice(s).map(a),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),$S(r)}function ju(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t-1),o=Pu(s,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,s)=>{!i||(i==null?void 0:i.nodeSize)===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}function Il(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}function Hu(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?Dr(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>Nl(d.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:d,$to:f})=>{const h=d.pos,p=f.pos;t.doc.nodesBetween(h,p,(g,v)=>{if(!g.isText&&!g.marks.length)return;const w=Math.max(h,v),S=Math.min(p,v+g.nodeSize),x=S-w;o+=x,l.push(...g.marks.map(y=>({mark:y,from:w,to:S})))})}),o===0)return!1;const a=l.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>Nl(d.mark.attrs,n,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=l.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,f)=>d+f.to-f.from,0);return(a>0?a+c:a)>=o}function jS(t,e,n={}){if(!e)return lo(t,null,n)||Hu(t,null,n);const r=Ll(e,t.schema);return r==="node"?lo(t,e,n):r==="mark"?Hu(t,e,n):!1}function ug(t,e){const{nodeExtensions:n}=Ml(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=be(re(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function HS(t){var e;const n=(e=t.type.createAndFill())===null||e===void 0?void 0:e.toJSON(),r=t.toJSON();return JSON.stringify(n)===JSON.stringify(r)}function dg(t){return t instanceof se}function zS(t,e,n){const i=t.state.doc.content.size,s=rr(e,0,i),o=rr(n,0,i),l=t.coordsAtPos(s),a=t.coordsAtPos(o,-1),c=Math.min(l.top,a.top),u=Math.max(l.bottom,a.bottom),d=Math.min(l.left,a.left),f=Math.max(l.right,a.right),h=f-d,p=u-c,w={top:c,bottom:u,left:d,right:f,width:h,height:p,x:d,y:c};return{...w,toJSON:()=>w}}function VS(t,e,n){var r;const{selection:i}=e;let s=null;if(Fu(i)&&(s=i.$cursor),s){const l=(r=t.storedMarks)!==null&&r!==void 0?r:s.marks();return!!n.isInSet(l)||!l.some(a=>a.type.excludes(n))}const{ranges:o}=i;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,f)=>{if(c)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(n));c=h&&p}return!c}),c})}const US=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:l}=s,a=Dr(t,r.schema);if(i)if(o){const c=ao(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,(f,h)=>{const p=Math.max(h,u),g=Math.min(h+f.nodeSize,d);f.marks.find(w=>w.type===a)?f.marks.forEach(w=>{a===w.type&&n.addMark(p,g,a.create({...w.attrs,...e}))}):n.addMark(p,g,a.create(e))})});return VS(r,n,a)},WS=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),qS=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=mt(t,n.schema);return s.isTextblock?i().command(({commands:o})=>Gm(s,e)(n)?!0:o.clearNodes()).command(({state:o})=>Gm(s,e)(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},KS=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=rr(t,0,r.content.size),s=se.create(r,i);e.setSelection(s)}return!0},JS=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,o=ce.atStart(r).from,l=ce.atEnd(r).to,a=rr(i,o,l),c=rr(s,o,l),u=ce.create(r,a,c);e.setSelection(u)}return!0},GS=t=>({state:e,dispatch:n})=>{const r=mt(t,e.schema);return SC(r)(e,n)};function fg(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e==null?void 0:e.includes(i.type.name));t.tr.ensureMarks(r)}}const YS=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,u=Il(c,l.node().type.name,l.node().attrs);if(s instanceof se&&s.node.isBlock)return!l.parentOffset||!Fi(o,l.pos)?!1:(r&&(t&&fg(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;if(r){const d=a.parentOffset===a.parent.content.size;s instanceof ce&&e.deleteSelection();const f=l.depth===0?void 0:DS(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,p=Fi(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&Fi(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:u}]:void 0),p&&(e.split(e.mapping.map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f)){const g=e.mapping.map(l.before()),v=e.doc.resolve(g);l.node(-1).canReplaceWith(v.index(),v.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}t&&fg(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return!0},XS=t=>({tr:e,state:n,dispatch:r,editor:i})=>{var s;const o=mt(t,n.schema),{$from:l,$to:a}=n.selection,c=n.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;const u=l.node(-1);if(u.type!==o)return!1;const d=i.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==o||l.index(-2)!==l.node(-2).childCount-1)return!1;if(r){let v=W.empty;const w=l.index(-1)?1:l.index(-2)?2:3;for(let T=l.depth-w;T>=l.depth-3;T-=1)v=W.from(l.node(T).copy(v));const S=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,x=Il(d,l.node().type.name,l.node().attrs),y=((s=o.contentMatch.defaultType)===null||s===void 0?void 0:s.createAndFill(x))||void 0;v=v.append(W.from(o.createAndFill(null,y)||void 0));const C=l.before(l.depth-(w-1));e.replace(C,l.after(-S),new Y(v,4-w,0));let E=-1;e.doc.nodesBetween(C,e.doc.content.size,(T,D)=>{if(E>-1)return!1;T.isTextblock&&T.content.size===0&&(E=D+1)}),E>-1&&e.setSelection(ce.near(e.doc.resolve(E))),e.scrollIntoView()}return!0}const f=a.pos===l.end()?u.contentMatchAt(0).defaultType:null,h=Il(d,u.type.name,u.attrs),p=Il(d,l.node().type.name,l.node().attrs);e.delete(l.pos,a.pos);const g=f?[{type:o,attrs:h},{type:f,attrs:p}]:[{type:o,attrs:h}];if(!Fi(e.doc,l.pos,2))return!1;if(r){const{selection:v,storedMarks:w}=n,{splittableMarks:S}=i.extensionManager,x=w||v.$to.parentOffset&&v.$from.marks();if(e.split(l.pos,2,g).scrollIntoView(),!x||!r)return!0;const y=x.filter(C=>S.includes(C.type.name));e.ensureMarks(y)}return!0},zu=(t,e)=>{const n=Bu(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&kr(t.doc,n.pos)&&t.join(n.pos),!0},Vu=(t,e)=>{const n=Bu(o=>o.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&kr(t.doc,r)&&t.join(r),!0};var ZS=Object.freeze({__proto__:null,blur:HC,clearContent:zC,clearNodes:VC,command:UC,createParagraphNear:WC,cut:qC,deleteCurrentNode:KC,deleteNode:JC,deleteRange:GC,deleteSelection:YC,enter:XC,exitCode:ZC,extendMarkRange:eS,first:tS,focus:nS,forEach:rS,insertContent:iS,insertContentAt:lS,joinUp:aS,joinDown:cS,joinBackward:uS,joinForward:dS,joinItemBackward:fS,joinItemForward:hS,joinTextblockBackward:pS,joinTextblockForward:mS,keyboardShortcut:yS,lift:bS,liftEmptyBlock:vS,liftListItem:wS,newlineInCode:xS,resetAttributes:kS,scrollIntoView:CS,selectAll:SS,selectNodeBackward:ES,selectNodeForward:TS,selectParentNode:AS,selectTextblockEnd:MS,selectTextblockStart:OS,setContent:_S,setMark:US,setMeta:WS,setNode:qS,setNodeSelection:KS,setTextSelection:JS,sinkListItem:GS,splitBlock:YS,splitListItem:XS,toggleList:(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:f}=i.extensionManager,h=mt(t,o.schema),p=mt(e,o.schema),{selection:g,storedMarks:v}=o,{$from:w,$to:S}=g,x=w.blockRange(S),y=v||g.$to.parentOffset&&g.$from.marks();if(!x)return!1;const C=Bu(E=>ug(E.type.name,d))(g);if(x.depth>=1&&C&&x.depth-C.depth<=1){if(C.node.type===h)return c.liftListItem(p);if(ug(C.node.type.name,d)&&h.validContent(C.node.content)&&l)return a().command(()=>(s.setNodeMarkup(C.pos,h),!0)).command(()=>zu(s,h)).command(()=>Vu(s,h)).run()}return!n||!y||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>zu(s,h)).command(()=>Vu(s,h)).run():a().command(()=>{const E=u().wrapInList(h,r),T=y.filter(D=>f.includes(D.type.name));return s.ensureMarks(T),E?!0:c.clearNodes()}).wrapInList(h,r).command(()=>zu(s,h)).command(()=>Vu(s,h)).run()},toggleMark:(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=Dr(t,r.schema);return Hu(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},toggleNode:(t,e,n={})=>({state:r,commands:i})=>{const s=mt(t,r.schema),o=mt(e,r.schema);return lo(r,s,n)?i.setNode(o):i.setNode(s,n)},toggleWrap:(t,e={})=>({state:n,commands:r})=>{const i=mt(t,n.schema);return lo(n,i,e)?r.lift(i):r.wrapIn(i,e)},undoInputRule:()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const o=t.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a-=1)o.step(l.steps[a].invert(l.docs[a]));if(s.text){const a=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,t.schema.text(s.text,a))}else o.delete(s.from,s.to)}return!0}}return!1},unsetAllMarks:()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(s=>{t.removeMark(s.$from.pos,s.$to.pos)}),!0},unsetMark:(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,a=Dr(t,r.schema),{$from:c,empty:u,ranges:d}=l;if(!i)return!0;if(u&&o){let{from:f,to:h}=l;const p=(s=c.marks().find(v=>v.type===a))===null||s===void 0?void 0:s.attrs,g=Pu(c,a,p);g&&(f=g.from,h=g.to),n.removeMark(f,h,a)}else d.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,a)});return n.removeStoredMark(a),!0},updateAttributes:(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=Ll(typeof t=="string"?t:t.name,r.schema);return l?(l==="node"&&(s=mt(t,r.schema)),l==="mark"&&(o=Dr(t,r.schema)),i&&n.selection.ranges.forEach(a=>{const c=a.$from.pos,u=a.$to.pos;r.doc.nodesBetween(c,u,(d,f)=>{s&&s===d.type&&n.setNodeMarkup(f,void 0,{...d.attrs,...e}),o&&d.marks.length&&d.marks.forEach(h=>{if(o===h.type){const p=Math.max(f,c),g=Math.min(f+d.nodeSize,u);n.addMark(p,g,o.create({...h.attrs,...e}))}})})}),!0):!1},wrapIn:(t,e={})=>({state:n,dispatch:r})=>{const i=mt(t,n.schema);return bC(i,e)(n,r)},wrapInList:(t,e={})=>({state:n,dispatch:r})=>{const i=mt(t,n.schema);return vC(i,e)(n,r)}});const QS=Ue.create({name:"commands",addCommands(){return{...ZS}}}),eE=Ue.create({name:"editable",addProseMirrorPlugins(){return[new je({key:new We("editable"),props:{editable:()=>this.editor.options.editable}})]}}),tE=Ue.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new je({key:new We("focusEvents"),props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),nE=Ue.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:f,parent:h}=d,p=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,g=p.parent.type.spec.isolating,v=d.pos-d.parentOffset,w=g&&p.parent.childCount===1?v===d.pos:ue.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!w||w&&d.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Dl()||og()?s:i},addProseMirrorPlugins(){return[new je({key:new We("clearDocument"),appendTransaction:(t,e,n)=>{if(!(t.some(p=>p.docChanged)&&!e.doc.eq(n.doc)))return;const{empty:i,from:s,to:o}=e.selection,l=ue.atStart(e.doc).from,a=ue.atEnd(e.doc).to;if(i||!(s===l&&o===a)||!(n.doc.textBetween(0,n.doc.content.size," "," ").length===0))return;const d=n.tr,f=Tl({state:n,transaction:d}),{commands:h}=new Al({editor:this.editor,state:f});if(h.clearNodes(),!!d.steps.length)return d}})]}}),rE=Ue.create({name:"tabindex",addProseMirrorPlugins(){return[new je({key:new We("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});class li{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new li(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 li(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 li(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,s=this.pos+r+1,o=this.resolvedPos.doc.resolve(s);if(!i&&o.depth<=this.depth)return;const l=new li(o,this.editor,i,i?n:null);i&&(l.actualDepth=this.depth+1),e.push(new li(o,this.editor,i,i?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const s=i.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const a=o[l];if(s[a]!==n[a])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(n);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&s.every(a=>n[a]===o.node.attrs[a])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){const n=this.editor.state.selection;this.editor.chain().setTextSelection(this.from).updateAttributes(this.node.type.name,e).setTextSelection(n.from).run()}}const iE=`.ProseMirror {
|
43
43
|
position: relative;
|
44
44
|
}
|
45
45
|
|
@@ -113,38 +113,38 @@ img.ProseMirror-separator {
|
|
113
113
|
|
114
114
|
.tippy-box[data-animation=fade][data-state=hidden] {
|
115
115
|
opacity: 0
|
116
|
-
}`;function sE(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}let oE=class extends EC{constructor(e={}){super(),this.isFocused=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}))},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=sE(iE,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,n=!0){this.setOptions({editable:e}),n&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,n){const r=
|
116
|
+
}`;function sE(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}let oE=class extends EC{constructor(e={}){super(),this.isFocused=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}))},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=sE(iE,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,n=!0){this.setOptions({editable:e}),n&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,n){const r=Xm(n)?n(e,[...this.state.plugins]):[...this.state.plugins,e],i=this.state.reconfigure({plugins:r});this.view.updateState(i)}unregisterPlugin(e){if(this.isDestroyed)return;const n=typeof e=="string"?`${e}$`:e.key,r=this.state.reconfigure({plugins:this.state.plugins.filter(i=>!i.key.startsWith(n))});this.view.updateState(r)}createExtensionManager(){var e,n;const i=[...this.options.enableCoreExtensions?[eE,jC.configure({blockSeparator:(n=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||n===void 0?void 0:n.blockSeparator}),QS,tE,nE,rE]:[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new Ji(i,this)}createCommandManager(){this.commandManager=new Al({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const e=ag(this.options.content,this.schema,this.options.parseOptions),n=rg(e,this.options.autofocus);this.view=new Uk(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:Hi.create({doc:e,selection:n||void 0})});const r=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(r),this.createNodeViews(),this.prependClass();const i=this.view.dom;i.editor=this}createNodeViews(){this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const n=this.capturedTransaction;return this.capturedTransaction=null,n}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(o=>{var l;return(l=this.capturedTransaction)===null||l===void 0?void 0:l.step(o)});return}const n=this.state.apply(e),r=!this.state.selection.eq(n.selection);this.view.updateState(n),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});const i=e.getMeta("focus"),s=e.getMeta("blur");i&&this.emit("focus",{editor:this,event:i.event,transaction:e}),s&&this.emit("blur",{editor:this,event:s.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return cg(this.state,e)}isActive(e,n){const r=typeof e=="string"?e:null,i=typeof e=="string"?n:e;return jS(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return LS(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:n=`
|
117
117
|
|
118
|
-
`,textSerializers:r={}}=e||{};return IS(this.state.doc,{blockSeparator:n,textSerializers:{...rg(this.schema),...r}})}get isEmpty(){return HS(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,n))||null}$nodes(e,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,n))||null}$pos(e){const n=this.state.doc.resolve(e);return new li(n,this)}get $doc(){return this.$pos(0)}};function ai(t){return new oo({find:t.find,handler:({state:e,range:n,match:r})=>{const i=be(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=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(Hu(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===t.type&&g!==h.mark.type)).filter(h=>h.to>c).length)return null;u<n.to&&s.delete(u,n.to),c>n.from&&s.delete(n.from+a,c);const f=n.from+a+o.length;s.addMark(n.from+a,f,t.type.create(i||{})),s.removeStoredMark(t.type)}}})}function Wu(t){return new oo({find:t.find,handler:({state:e,range:n,match:r})=>{const i=be(t.getAttributes,void 0,r)||{},{tr:s}=e,o=n.from;let l=n.to;const a=t.type.create(i);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];s.insertText(d,o+r[0].length-1),s.replaceWith(u,l,a)}else r[0]&&s.insert(o-1,t.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l));s.scrollIntoView()}})}function qu(t){return new oo({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=be(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)}})}function Gi(t){return new oo({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=be(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),a=o.doc.resolve(n.from).blockRange(),c=a&&Gc(a,t.type,s);if(!c)return null;if(o.wrap(a,c),t.keepMarks&&t.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=t.editor.extensionManager,p=f||d.$to.parentOffset&&d.$from.marks();if(p){const g=p.filter(v=>h.includes(v.type.name));o.ensureMarks(g)}}if(t.keepAttributes){const d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(d,s).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)}})}class jt{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=be(re(this,"addOptions",{name:this.name}))),this.storage=be(re(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new jt(e)}configure(e={}){const n=this.extend();return n.options=_l(this.options,e),n.storage=be(re(n,"addStorage",{name:n.name,options:n.options})),n}extend(e={}){const n=new jt({...this.config,...e});return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=be(re(n,"addOptions",{name:n.name})),n.storage=be(re(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===n.name))return!1;const a=o.find(c=>(c==null?void 0:c.type.name)===n.name);return a&&r.removeStoredMark(a),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}}let ze=class Ph{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=be(re(this,"addOptions",{name:this.name}))),this.storage=be(re(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Ph(e)}configure(e={}){const n=this.extend();return n.options=_l(this.options,e),n.storage=be(re(n,"addStorage",{name:n.name,options:n.options})),n}extend(e={}){const n=new Ph({...this.config,...e});return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=be(re(n,"addOptions",{name:n.name})),n.storage=be(re(n,"addStorage",{name:n.name,options:n.options})),n}};function lE(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}class aE{constructor(e,n,r){this.isDragging=!1,this.component=e,this.editor=n.editor,this.options={stopEvent:null,ignoreMutation:null,...r},this.extension=n.extension,this.node=n.node,this.decorations=n.decorations,this.getPos=n.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var n,r,i,s,o,l,a;const{view:c}=this.editor,u=e.target,d=u.nodeType===3?(n=u.parentElement)===null||n===void 0?void 0:n.closest("[data-drag-handle]"):u.closest("[data-drag-handle]");if(!this.dom||!((r=this.contentDOM)===null||r===void 0)&&r.contains(u)||!d)return;let f=0,h=0;if(this.dom!==d){const v=this.dom.getBoundingClientRect(),w=d.getBoundingClientRect(),S=(i=e.offsetX)!==null&&i!==void 0?i:(s=e.nativeEvent)===null||s===void 0?void 0:s.offsetX,x=(o=e.offsetY)!==null&&o!==void 0?o:(l=e.nativeEvent)===null||l===void 0?void 0:l.offsetY;f=w.x-v.x+S,h=w.y-v.y+x}(a=e.dataTransfer)===null||a===void 0||a.setDragImage(this.dom,f,h);const p=se.create(c.state.doc,this.getPos()),g=c.state.tr.setSelection(p);c.dispatch(g)}stopEvent(e){var n;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:e});const r=e.target;if(!(this.dom.contains(r)&&!(!((n=this.contentDOM)===null||n===void 0)&&n.contains(r))))return!1;const s=e.type.startsWith("drag"),o=e.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(r.tagName)||r.isContentEditable)&&!o&&!s)return!0;const{isEditable:a}=this.editor,{isDragging:c}=this,u=!!this.node.type.spec.draggable,d=se.isSelectable(this.node),f=e.type==="copy",h=e.type==="paste",p=e.type==="cut",g=e.type==="mousedown";if(!u&&d&&s&&e.preventDefault(),u&&s&&!c)return e.preventDefault(),!1;if(u&&a&&!c&&g){const v=r.closest("[data-drag-handle]");v&&(this.dom===v||this.dom.contains(v))&&(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||o||f||h||p||g&&d)}ignoreMutation(e){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:e}):this.node.isLeaf||this.node.isAtom?!0:e.type==="selection"||this.dom.contains(e.target)&&e.type==="childList"&&(Dl()||lE())&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(r=>r.isContentEditable)?!1:this.contentDOM===e.target&&e.type==="attributes"?!0:!this.contentDOM.contains(e.target)}updateAttributes(e){this.editor.commands.command(({tr:n})=>{const r=this.getPos();return n.setNodeMarkup(r,void 0,{...this.node.attrs,...e}),!0})}deleteNode(){const e=this.getPos(),n=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:n})}}function Rr(t){return new RC({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=be(t.getAttributes,void 0,r,i);if(s===!1||s===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),f=d+l.length;if(Hu(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(v=>v===t.type&&v!==p.mark.type)).filter(p=>p.to>d).length)return null;f<n.to&&o.delete(f,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(s||{})),o.removeStoredMark(t.type)}}})}function cE(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var Ht="top",on="bottom",ln="right",zt="left",Ku="auto",co=[Ht,on,ln,zt],Yi="start",uo="end",uE="clippingParents",pg="viewport",fo="popper",dE="reference",mg=co.reduce(function(t,e){return t.concat([e+"-"+Yi,e+"-"+uo])},[]),gg=[].concat(co,[Ku]).reduce(function(t,e){return t.concat([e,e+"-"+Yi,e+"-"+uo])},[]),fE="beforeRead",hE="read",pE="afterRead",mE="beforeMain",gE="main",yE="afterMain",bE="beforeWrite",vE="write",wE="afterWrite",xE=[fE,hE,pE,mE,gE,yE,bE,vE,wE];function Pn(t){return t?(t.nodeName||"").toLowerCase():null}function Jt(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function ci(t){var e=Jt(t).Element;return t instanceof e||t instanceof Element}function an(t){var e=Jt(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function Ju(t){if(typeof ShadowRoot>"u")return!1;var e=Jt(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function kE(t){var e=t.state;Object.keys(e.elements).forEach(function(n){var r=e.styles[n]||{},i=e.attributes[n]||{},s=e.elements[n];!an(s)||!Pn(s)||(Object.assign(s.style,r),Object.keys(i).forEach(function(o){var l=i[o];l===!1?s.removeAttribute(o):s.setAttribute(o,l===!0?"":l)}))})}function CE(t){var e=t.state,n={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,n.popper),e.styles=n,e.elements.arrow&&Object.assign(e.elements.arrow.style,n.arrow),function(){Object.keys(e.elements).forEach(function(r){var i=e.elements[r],s=e.attributes[r]||{},o=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:n[r]),l=o.reduce(function(a,c){return a[c]="",a},{});!an(i)||!Pn(i)||(Object.assign(i.style,l),Object.keys(s).forEach(function(a){i.removeAttribute(a)}))})}}const yg={name:"applyStyles",enabled:!0,phase:"write",fn:kE,effect:CE,requires:["computeStyles"]};function Fn(t){return t.split("-")[0]}var ui=Math.max,Pl=Math.min,Xi=Math.round;function Gu(){var t=navigator.userAgentData;return t!=null&&t.brands&&Array.isArray(t.brands)?t.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function bg(){return!/^((?!chrome|android).)*safari/i.test(Gu())}function Zi(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),i=1,s=1;e&&an(t)&&(i=t.offsetWidth>0&&Xi(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&Xi(r.height)/t.offsetHeight||1);var o=ci(t)?Jt(t):window,l=o.visualViewport,a=!bg()&&n,c=(r.left+(a&&l?l.offsetLeft:0))/i,u=(r.top+(a&&l?l.offsetTop:0))/s,d=r.width/i,f=r.height/s;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c,x:c,y:u}}function Yu(t){var e=Zi(t),n=t.offsetWidth,r=t.offsetHeight;return Math.abs(e.width-n)<=1&&(n=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:t.offsetLeft,y:t.offsetTop,width:n,height:r}}function vg(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&Ju(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function ir(t){return Jt(t).getComputedStyle(t)}function SE(t){return["table","td","th"].indexOf(Pn(t))>=0}function Lr(t){return((ci(t)?t.ownerDocument:t.document)||window.document).documentElement}function Fl(t){return Pn(t)==="html"?t:t.assignedSlot||t.parentNode||(Ju(t)?t.host:null)||Lr(t)}function wg(t){return!an(t)||ir(t).position==="fixed"?null:t.offsetParent}function EE(t){var e=/firefox/i.test(Gu()),n=/Trident/i.test(Gu());if(n&&an(t)){var r=ir(t);if(r.position==="fixed")return null}var i=Fl(t);for(Ju(i)&&(i=i.host);an(i)&&["html","body"].indexOf(Pn(i))<0;){var s=ir(i);if(s.transform!=="none"||s.perspective!=="none"||s.contain==="paint"||["transform","perspective"].indexOf(s.willChange)!==-1||e&&s.willChange==="filter"||e&&s.filter&&s.filter!=="none")return i;i=i.parentNode}return null}function ho(t){for(var e=Jt(t),n=wg(t);n&&SE(n)&&ir(n).position==="static";)n=wg(n);return n&&(Pn(n)==="html"||Pn(n)==="body"&&ir(n).position==="static")?e:n||EE(t)||e}function Xu(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function po(t,e,n){return ui(t,Pl(e,n))}function TE(t,e,n){var r=po(t,e,n);return r>n?n:r}function xg(){return{top:0,right:0,bottom:0,left:0}}function kg(t){return Object.assign({},xg(),t)}function Cg(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var AE=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,kg(typeof e!="number"?e:Cg(e,co))};function ME(t){var e,n=t.state,r=t.name,i=t.options,s=n.elements.arrow,o=n.modifiersData.popperOffsets,l=Fn(n.placement),a=Xu(l),c=[zt,ln].indexOf(l)>=0,u=c?"height":"width";if(!(!s||!o)){var d=AE(i.padding,n),f=Yu(s),h=a==="y"?Ht:zt,p=a==="y"?on:ln,g=n.rects.reference[u]+n.rects.reference[a]-o[a]-n.rects.popper[u],v=o[a]-n.rects.reference[a],w=ho(s),S=w?a==="y"?w.clientHeight||0:w.clientWidth||0:0,x=g/2-v/2,y=d[h],C=S-f[u]-d[p],E=S/2-f[u]/2+x,T=po(y,E,C),D=a;n.modifiersData[r]=(e={},e[D]=T,e.centerOffset=T-E,e)}}function OE(t){var e=t.state,n=t.options,r=n.element,i=r===void 0?"[data-popper-arrow]":r;i!=null&&(typeof i=="string"&&(i=e.elements.popper.querySelector(i),!i)||vg(e.elements.popper,i)&&(e.elements.arrow=i))}const _E={name:"arrow",enabled:!0,phase:"main",fn:ME,effect:OE,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Qi(t){return t.split("-")[1]}var NE={top:"auto",right:"auto",bottom:"auto",left:"auto"};function DE(t,e){var n=t.x,r=t.y,i=e.devicePixelRatio||1;return{x:Xi(n*i)/i||0,y:Xi(r*i)/i||0}}function Sg(t){var e,n=t.popper,r=t.popperRect,i=t.placement,s=t.variation,o=t.offsets,l=t.position,a=t.gpuAcceleration,c=t.adaptive,u=t.roundOffsets,d=t.isFixed,f=o.x,h=f===void 0?0:f,p=o.y,g=p===void 0?0:p,v=typeof u=="function"?u({x:h,y:g}):{x:h,y:g};h=v.x,g=v.y;var w=o.hasOwnProperty("x"),S=o.hasOwnProperty("y"),x=zt,y=Ht,C=window;if(c){var E=ho(n),T="clientHeight",D="clientWidth";if(E===Jt(n)&&(E=Lr(n),ir(E).position!=="static"&&l==="absolute"&&(T="scrollHeight",D="scrollWidth")),E=E,i===Ht||(i===zt||i===ln)&&s===uo){y=on;var N=d&&E===C&&C.visualViewport?C.visualViewport.height:E[T];g-=N-r.height,g*=a?1:-1}if(i===zt||(i===Ht||i===on)&&s===uo){x=ln;var A=d&&E===C&&C.visualViewport?C.visualViewport.width:E[D];h-=A-r.width,h*=a?1:-1}}var R=Object.assign({position:l},c&&NE),P=u===!0?DE({x:h,y:g},Jt(n)):{x:h,y:g};if(h=P.x,g=P.y,a){var B;return Object.assign({},R,(B={},B[y]=S?"0":"",B[x]=w?"0":"",B.transform=(C.devicePixelRatio||1)<=1?"translate("+h+"px, "+g+"px)":"translate3d("+h+"px, "+g+"px, 0)",B))}return Object.assign({},R,(e={},e[y]=S?g+"px":"",e[x]=w?h+"px":"",e.transform="",e))}function RE(t){var e=t.state,n=t.options,r=n.gpuAcceleration,i=r===void 0?!0:r,s=n.adaptive,o=s===void 0?!0:s,l=n.roundOffsets,a=l===void 0?!0:l,c={placement:Fn(e.placement),variation:Qi(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:i,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,Sg(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:o,roundOffsets:a})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,Sg(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:a})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const LE={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:RE,data:{}};var $l={passive:!0};function IE(t){var e=t.state,n=t.instance,r=t.options,i=r.scroll,s=i===void 0?!0:i,o=r.resize,l=o===void 0?!0:o,a=Jt(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&c.forEach(function(u){u.addEventListener("scroll",n.update,$l)}),l&&a.addEventListener("resize",n.update,$l),function(){s&&c.forEach(function(u){u.removeEventListener("scroll",n.update,$l)}),l&&a.removeEventListener("resize",n.update,$l)}}const PE={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:IE,data:{}};var FE={left:"right",right:"left",bottom:"top",top:"bottom"};function Bl(t){return t.replace(/left|right|bottom|top/g,function(e){return FE[e]})}var $E={start:"end",end:"start"};function Eg(t){return t.replace(/start|end/g,function(e){return $E[e]})}function Zu(t){var e=Jt(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function Qu(t){return Zi(Lr(t)).left+Zu(t).scrollLeft}function BE(t,e){var n=Jt(t),r=Lr(t),i=n.visualViewport,s=r.clientWidth,o=r.clientHeight,l=0,a=0;if(i){s=i.width,o=i.height;var c=bg();(c||!c&&e==="fixed")&&(l=i.offsetLeft,a=i.offsetTop)}return{width:s,height:o,x:l+Qu(t),y:a}}function jE(t){var e,n=Lr(t),r=Zu(t),i=(e=t.ownerDocument)==null?void 0:e.body,s=ui(n.scrollWidth,n.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),o=ui(n.scrollHeight,n.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),l=-r.scrollLeft+Qu(t),a=-r.scrollTop;return ir(i||n).direction==="rtl"&&(l+=ui(n.clientWidth,i?i.clientWidth:0)-s),{width:s,height:o,x:l,y:a}}function ed(t){var e=ir(t),n=e.overflow,r=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function Tg(t){return["html","body","#document"].indexOf(Pn(t))>=0?t.ownerDocument.body:an(t)&&ed(t)?t:Tg(Fl(t))}function mo(t,e){var n;e===void 0&&(e=[]);var r=Tg(t),i=r===((n=t.ownerDocument)==null?void 0:n.body),s=Jt(r),o=i?[s].concat(s.visualViewport||[],ed(r)?r:[]):r,l=e.concat(o);return i?l:l.concat(mo(Fl(o)))}function td(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function HE(t,e){var n=Zi(t,!1,e==="fixed");return n.top=n.top+t.clientTop,n.left=n.left+t.clientLeft,n.bottom=n.top+t.clientHeight,n.right=n.left+t.clientWidth,n.width=t.clientWidth,n.height=t.clientHeight,n.x=n.left,n.y=n.top,n}function Ag(t,e,n){return e===pg?td(BE(t,n)):ci(e)?HE(e,n):td(jE(Lr(t)))}function zE(t){var e=mo(Fl(t)),n=["absolute","fixed"].indexOf(ir(t).position)>=0,r=n&&an(t)?ho(t):t;return ci(r)?e.filter(function(i){return ci(i)&&vg(i,r)&&Pn(i)!=="body"}):[]}function VE(t,e,n,r){var i=e==="clippingParents"?zE(t):[].concat(e),s=[].concat(i,[n]),o=s[0],l=s.reduce(function(a,c){var u=Ag(t,c,r);return a.top=ui(u.top,a.top),a.right=Pl(u.right,a.right),a.bottom=Pl(u.bottom,a.bottom),a.left=ui(u.left,a.left),a},Ag(t,o,r));return l.width=l.right-l.left,l.height=l.bottom-l.top,l.x=l.left,l.y=l.top,l}function Mg(t){var e=t.reference,n=t.element,r=t.placement,i=r?Fn(r):null,s=r?Qi(r):null,o=e.x+e.width/2-n.width/2,l=e.y+e.height/2-n.height/2,a;switch(i){case Ht:a={x:o,y:e.y-n.height};break;case on:a={x:o,y:e.y+e.height};break;case ln:a={x:e.x+e.width,y:l};break;case zt:a={x:e.x-n.width,y:l};break;default:a={x:e.x,y:e.y}}var c=i?Xu(i):null;if(c!=null){var u=c==="y"?"height":"width";switch(s){case Yi:a[c]=a[c]-(e[u]/2-n[u]/2);break;case uo:a[c]=a[c]+(e[u]/2-n[u]/2);break}}return a}function go(t,e){e===void 0&&(e={});var n=e,r=n.placement,i=r===void 0?t.placement:r,s=n.strategy,o=s===void 0?t.strategy:s,l=n.boundary,a=l===void 0?uE:l,c=n.rootBoundary,u=c===void 0?pg:c,d=n.elementContext,f=d===void 0?fo:d,h=n.altBoundary,p=h===void 0?!1:h,g=n.padding,v=g===void 0?0:g,w=kg(typeof v!="number"?v:Cg(v,co)),S=f===fo?dE:fo,x=t.rects.popper,y=t.elements[p?S:f],C=VE(ci(y)?y:y.contextElement||Lr(t.elements.popper),a,u,o),E=Zi(t.elements.reference),T=Mg({reference:E,element:x,strategy:"absolute",placement:i}),D=td(Object.assign({},x,T)),N=f===fo?D:E,A={top:C.top-N.top+w.top,bottom:N.bottom-C.bottom+w.bottom,left:C.left-N.left+w.left,right:N.right-C.right+w.right},R=t.modifiersData.offset;if(f===fo&&R){var P=R[i];Object.keys(A).forEach(function(B){var z=[ln,on].indexOf(B)>=0?1:-1,U=[Ht,on].indexOf(B)>=0?"y":"x";A[B]+=P[U]*z})}return A}function UE(t,e){e===void 0&&(e={});var n=e,r=n.placement,i=n.boundary,s=n.rootBoundary,o=n.padding,l=n.flipVariations,a=n.allowedAutoPlacements,c=a===void 0?gg:a,u=Qi(r),d=u?l?mg:mg.filter(function(p){return Qi(p)===u}):co,f=d.filter(function(p){return c.indexOf(p)>=0});f.length===0&&(f=d);var h=f.reduce(function(p,g){return p[g]=go(t,{placement:g,boundary:i,rootBoundary:s,padding:o})[Fn(g)],p},{});return Object.keys(h).sort(function(p,g){return h[p]-h[g]})}function WE(t){if(Fn(t)===Ku)return[];var e=Bl(t);return[Eg(t),e,Eg(e)]}function qE(t){var e=t.state,n=t.options,r=t.name;if(!e.modifiersData[r]._skip){for(var i=n.mainAxis,s=i===void 0?!0:i,o=n.altAxis,l=o===void 0?!0:o,a=n.fallbackPlacements,c=n.padding,u=n.boundary,d=n.rootBoundary,f=n.altBoundary,h=n.flipVariations,p=h===void 0?!0:h,g=n.allowedAutoPlacements,v=e.options.placement,w=Fn(v),S=w===v,x=a||(S||!p?[Bl(v)]:WE(v)),y=[v].concat(x).reduce(function(ve,De){return ve.concat(Fn(De)===Ku?UE(e,{placement:De,boundary:u,rootBoundary:d,padding:c,flipVariations:p,allowedAutoPlacements:g}):De)},[]),C=e.rects.reference,E=e.rects.popper,T=new Map,D=!0,N=y[0],A=0;A<y.length;A++){var R=y[A],P=Fn(R),B=Qi(R)===Yi,z=[Ht,on].indexOf(P)>=0,U=z?"width":"height",J=go(e,{placement:R,boundary:u,rootBoundary:d,altBoundary:f,padding:c}),G=z?B?ln:zt:B?on:Ht;C[U]>E[U]&&(G=Bl(G));var ie=Bl(G),Z=[];if(s&&Z.push(J[P]<=0),l&&Z.push(J[G]<=0,J[ie]<=0),Z.every(function(ve){return ve})){N=R,D=!1;break}T.set(R,Z)}if(D)for(var ke=p?3:1,Le=function(De){var Ie=y.find(function(tt){var nt=T.get(tt);if(nt)return nt.slice(0,De).every(function(Ge){return Ge})});if(Ie)return N=Ie,"break"},$e=ke;$e>0;$e--){var Ee=Le($e);if(Ee==="break")break}e.placement!==N&&(e.modifiersData[r]._skip=!0,e.placement=N,e.reset=!0)}}const KE={name:"flip",enabled:!0,phase:"main",fn:qE,requiresIfExists:["offset"],data:{_skip:!1}};function Og(t,e,n){return n===void 0&&(n={x:0,y:0}),{top:t.top-e.height-n.y,right:t.right-e.width+n.x,bottom:t.bottom-e.height+n.y,left:t.left-e.width-n.x}}function _g(t){return[Ht,ln,on,zt].some(function(e){return t[e]>=0})}function JE(t){var e=t.state,n=t.name,r=e.rects.reference,i=e.rects.popper,s=e.modifiersData.preventOverflow,o=go(e,{elementContext:"reference"}),l=go(e,{altBoundary:!0}),a=Og(o,r),c=Og(l,i,s),u=_g(a),d=_g(c);e.modifiersData[n]={referenceClippingOffsets:a,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}const GE={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:JE};function YE(t,e,n){var r=Fn(t),i=[zt,Ht].indexOf(r)>=0?-1:1,s=typeof n=="function"?n(Object.assign({},e,{placement:t})):n,o=s[0],l=s[1];return o=o||0,l=(l||0)*i,[zt,ln].indexOf(r)>=0?{x:l,y:o}:{x:o,y:l}}function XE(t){var e=t.state,n=t.options,r=t.name,i=n.offset,s=i===void 0?[0,0]:i,o=gg.reduce(function(u,d){return u[d]=YE(d,e.rects,s),u},{}),l=o[e.placement],a=l.x,c=l.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=a,e.modifiersData.popperOffsets.y+=c),e.modifiersData[r]=o}const ZE={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:XE};function QE(t){var e=t.state,n=t.name;e.modifiersData[n]=Mg({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const eT={name:"popperOffsets",enabled:!0,phase:"read",fn:QE,data:{}};function tT(t){return t==="x"?"y":"x"}function nT(t){var e=t.state,n=t.options,r=t.name,i=n.mainAxis,s=i===void 0?!0:i,o=n.altAxis,l=o===void 0?!1:o,a=n.boundary,c=n.rootBoundary,u=n.altBoundary,d=n.padding,f=n.tether,h=f===void 0?!0:f,p=n.tetherOffset,g=p===void 0?0:p,v=go(e,{boundary:a,rootBoundary:c,padding:d,altBoundary:u}),w=Fn(e.placement),S=Qi(e.placement),x=!S,y=Xu(w),C=tT(y),E=e.modifiersData.popperOffsets,T=e.rects.reference,D=e.rects.popper,N=typeof g=="function"?g(Object.assign({},e.rects,{placement:e.placement})):g,A=typeof N=="number"?{mainAxis:N,altAxis:N}:Object.assign({mainAxis:0,altAxis:0},N),R=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,P={x:0,y:0};if(E){if(s){var B,z=y==="y"?Ht:zt,U=y==="y"?on:ln,J=y==="y"?"height":"width",G=E[y],ie=G+v[z],Z=G-v[U],ke=h?-D[J]/2:0,Le=S===Yi?T[J]:D[J],$e=S===Yi?-D[J]:-T[J],Ee=e.elements.arrow,ve=h&&Ee?Yu(Ee):{width:0,height:0},De=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:xg(),Ie=De[z],tt=De[U],nt=po(0,T[J],ve[J]),Ge=x?T[J]/2-ke-nt-Ie-A.mainAxis:Le-nt-Ie-A.mainAxis,Ye=x?-T[J]/2+ke+nt+tt+A.mainAxis:$e+nt+tt+A.mainAxis,Ot=e.elements.arrow&&ho(e.elements.arrow),xt=Ot?y==="y"?Ot.clientTop||0:Ot.clientLeft||0:0,it=(B=R==null?void 0:R[y])!=null?B:0,at=G+Ge-it-xt,$=G+Ye-it,j=po(h?Pl(ie,at):ie,G,h?ui(Z,$):Z);E[y]=j,P[y]=j-G}if(l){var q,te=y==="x"?Ht:zt,M=y==="x"?on:ln,m=E[C],b=C==="y"?"height":"width",k=m+v[te],I=m-v[M],F=[Ht,zt].indexOf(w)!==-1,H=(q=R==null?void 0:R[C])!=null?q:0,ne=F?k:m-T[b]-D[b]-H+A.altAxis,de=F?m+T[b]+D[b]-H-A.altAxis:I,_e=h&&F?TE(ne,m,de):po(h?ne:k,m,h?de:I);E[C]=_e,P[C]=_e-m}e.modifiersData[r]=P}}const rT={name:"preventOverflow",enabled:!0,phase:"main",fn:nT,requiresIfExists:["offset"]};function iT(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function sT(t){return t===Jt(t)||!an(t)?Zu(t):iT(t)}function oT(t){var e=t.getBoundingClientRect(),n=Xi(e.width)/t.offsetWidth||1,r=Xi(e.height)/t.offsetHeight||1;return n!==1||r!==1}function lT(t,e,n){n===void 0&&(n=!1);var r=an(e),i=an(e)&&oT(e),s=Lr(e),o=Zi(t,i,n),l={scrollLeft:0,scrollTop:0},a={x:0,y:0};return(r||!r&&!n)&&((Pn(e)!=="body"||ed(s))&&(l=sT(e)),an(e)?(a=Zi(e,!0),a.x+=e.clientLeft,a.y+=e.clientTop):s&&(a.x=Qu(s))),{x:o.left+l.scrollLeft-a.x,y:o.top+l.scrollTop-a.y,width:o.width,height:o.height}}function aT(t){var e=new Map,n=new Set,r=[];t.forEach(function(s){e.set(s.name,s)});function i(s){n.add(s.name);var o=[].concat(s.requires||[],s.requiresIfExists||[]);o.forEach(function(l){if(!n.has(l)){var a=e.get(l);a&&i(a)}}),r.push(s)}return t.forEach(function(s){n.has(s.name)||i(s)}),r}function cT(t){var e=aT(t);return xE.reduce(function(n,r){return n.concat(e.filter(function(i){return i.phase===r}))},[])}function uT(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function dT(t){var e=t.reduce(function(n,r){var i=n[r.name];return n[r.name]=i?Object.assign({},i,r,{options:Object.assign({},i.options,r.options),data:Object.assign({},i.data,r.data)}):r,n},{});return Object.keys(e).map(function(n){return e[n]})}var Ng={placement:"bottom",modifiers:[],strategy:"absolute"};function Dg(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return!e.some(function(r){return!(r&&typeof r.getBoundingClientRect=="function")})}function fT(t){t===void 0&&(t={});var e=t,n=e.defaultModifiers,r=n===void 0?[]:n,i=e.defaultOptions,s=i===void 0?Ng:i;return function(l,a,c){c===void 0&&(c=s);var u={placement:"bottom",orderedModifiers:[],options:Object.assign({},Ng,s),modifiersData:{},elements:{reference:l,popper:a},attributes:{},styles:{}},d=[],f=!1,h={state:u,setOptions:function(w){var S=typeof w=="function"?w(u.options):w;g(),u.options=Object.assign({},s,u.options,S),u.scrollParents={reference:ci(l)?mo(l):l.contextElement?mo(l.contextElement):[],popper:mo(a)};var x=cT(dT([].concat(r,u.options.modifiers)));return u.orderedModifiers=x.filter(function(y){return y.enabled}),p(),h.update()},forceUpdate:function(){if(!f){var w=u.elements,S=w.reference,x=w.popper;if(Dg(S,x)){u.rects={reference:lT(S,ho(x),u.options.strategy==="fixed"),popper:Yu(x)},u.reset=!1,u.placement=u.options.placement,u.orderedModifiers.forEach(function(A){return u.modifiersData[A.name]=Object.assign({},A.data)});for(var y=0;y<u.orderedModifiers.length;y++){if(u.reset===!0){u.reset=!1,y=-1;continue}var C=u.orderedModifiers[y],E=C.fn,T=C.options,D=T===void 0?{}:T,N=C.name;typeof E=="function"&&(u=E({state:u,options:D,name:N,instance:h})||u)}}}},update:uT(function(){return new Promise(function(v){h.forceUpdate(),v(u)})}),destroy:function(){g(),f=!0}};if(!Dg(l,a))return h;h.setOptions(c).then(function(v){!f&&c.onFirstUpdate&&c.onFirstUpdate(v)});function p(){u.orderedModifiers.forEach(function(v){var w=v.name,S=v.options,x=S===void 0?{}:S,y=v.effect;if(typeof y=="function"){var C=y({state:u,name:w,instance:h,options:x}),E=function(){};d.push(C||E)}})}function g(){d.forEach(function(v){return v()}),d=[]}return h}}var hT=[PE,eT,LE,yg,ZE,KE,rT,_E,GE],pT=fT({defaultModifiers:hT}),mT="tippy-box",Rg="tippy-content",gT="tippy-backdrop",Lg="tippy-arrow",Ig="tippy-svg-arrow",di={passive:!0,capture:!0},Pg=function(){return document.body};function yT(t,e){return{}.hasOwnProperty.call(t,e)}function nd(t,e,n){if(Array.isArray(t)){var r=t[e];return r??(Array.isArray(n)?n[e]:n)}return t}function rd(t,e){var n={}.toString.call(t);return n.indexOf("[object")===0&&n.indexOf(e+"]")>-1}function Fg(t,e){return typeof t=="function"?t.apply(void 0,e):t}function $g(t,e){if(e===0)return t;var n;return function(r){clearTimeout(n),n=setTimeout(function(){t(r)},e)}}function bT(t,e){var n=Object.assign({},t);return e.forEach(function(r){delete n[r]}),n}function vT(t){return t.split(/\s+/).filter(Boolean)}function es(t){return[].concat(t)}function Bg(t,e){t.indexOf(e)===-1&&t.push(e)}function wT(t){return t.filter(function(e,n){return t.indexOf(e)===n})}function xT(t){return t.split("-")[0]}function jl(t){return[].slice.call(t)}function jg(t){return Object.keys(t).reduce(function(e,n){return t[n]!==void 0&&(e[n]=t[n]),e},{})}function yo(){return document.createElement("div")}function bo(t){return["Element","Fragment"].some(function(e){return rd(t,e)})}function kT(t){return rd(t,"NodeList")}function CT(t){return rd(t,"MouseEvent")}function ST(t){return!!(t&&t._tippy&&t._tippy.reference===t)}function ET(t){return bo(t)?[t]:kT(t)?jl(t):Array.isArray(t)?t:jl(document.querySelectorAll(t))}function id(t,e){t.forEach(function(n){n&&(n.style.transitionDuration=e+"ms")})}function Hg(t,e){t.forEach(function(n){n&&n.setAttribute("data-state",e)})}function TT(t){var e,n=es(t),r=n[0];return r!=null&&(e=r.ownerDocument)!=null&&e.body?r.ownerDocument:document}function AT(t,e){var n=e.clientX,r=e.clientY;return t.every(function(i){var s=i.popperRect,o=i.popperState,l=i.props,a=l.interactiveBorder,c=xT(o.placement),u=o.modifiersData.offset;if(!u)return!0;var d=c==="bottom"?u.top.y:0,f=c==="top"?u.bottom.y:0,h=c==="right"?u.left.x:0,p=c==="left"?u.right.x:0,g=s.top-r+d>a,v=r-s.bottom-f>a,w=s.left-n+h>a,S=n-s.right-p>a;return g||v||w||S})}function sd(t,e,n){var r=e+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(i){t[r](i,n)})}function zg(t,e){for(var n=e;n;){var r;if(t.contains(n))return!0;n=n.getRootNode==null||(r=n.getRootNode())==null?void 0:r.host}return!1}var $n={isTouch:!1},Vg=0;function MT(){$n.isTouch||($n.isTouch=!0,window.performance&&document.addEventListener("mousemove",Ug))}function Ug(){var t=performance.now();t-Vg<20&&($n.isTouch=!1,document.removeEventListener("mousemove",Ug)),Vg=t}function OT(){var t=document.activeElement;if(ST(t)){var e=t._tippy;t.blur&&!e.state.isVisible&&t.blur()}}function _T(){document.addEventListener("touchstart",MT,di),window.addEventListener("blur",OT)}var NT=typeof window<"u"&&typeof document<"u",DT=NT?!!window.msCrypto:!1;function ts(t){var e=t==="destroy"?"n already-":" ";return[t+"() was called on a"+e+"destroyed instance. This is a no-op but","indicates a potential memory leak."].join(" ")}function Wg(t){var e=/[ \t]{2,}/g,n=/^[ \t]*/gm;return t.replace(e," ").replace(n,"").trim()}function RT(t){return Wg(`
|
118
|
+
`,textSerializers:r={}}=e||{};return IS(this.state.doc,{blockSeparator:n,textSerializers:{...ng(this.schema),...r}})}get isEmpty(){return HS(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){this.emit("destroy"),this.view&&this.view.destroy(),this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,n))||null}$nodes(e,n){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,n))||null}$pos(e){const n=this.state.doc.resolve(e);return new li(n,this)}get $doc(){return this.$pos(0)}};function ai(t){return new oo({find:t.find,handler:({state:e,range:n,match:r})=>{const i=be(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=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(ju(n.from,n.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===t.type&&g!==h.mark.type)).filter(h=>h.to>c).length)return null;u<n.to&&s.delete(u,n.to),c>n.from&&s.delete(n.from+a,c);const f=n.from+a+o.length;s.addMark(n.from+a,f,t.type.create(i||{})),s.removeStoredMark(t.type)}}})}function Uu(t){return new oo({find:t.find,handler:({state:e,range:n,match:r})=>{const i=be(t.getAttributes,void 0,r)||{},{tr:s}=e,o=n.from;let l=n.to;const a=t.type.create(i);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];s.insertText(d,o+r[0].length-1),s.replaceWith(u,l,a)}else r[0]&&s.insert(o-1,t.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l));s.scrollIntoView()}})}function Wu(t){return new oo({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=be(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)}})}function Gi(t){return new oo({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=be(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),a=o.doc.resolve(n.from).blockRange(),c=a&&Jc(a,t.type,s);if(!c)return null;if(o.wrap(a,c),t.keepMarks&&t.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=t.editor.extensionManager,p=f||d.$to.parentOffset&&d.$from.marks();if(p){const g=p.filter(v=>h.includes(v.type.name));o.ensureMarks(g)}}if(t.keepAttributes){const d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(d,s).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)}})}class jt{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=be(re(this,"addOptions",{name:this.name}))),this.storage=be(re(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new jt(e)}configure(e={}){const n=this.extend();return n.options=_l(this.options,e),n.storage=be(re(n,"addStorage",{name:n.name,options:n.options})),n}extend(e={}){const n=new jt({...this.config,...e});return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=be(re(n,"addOptions",{name:n.name})),n.storage=be(re(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(c=>(c==null?void 0:c.type.name)===n.name))return!1;const a=o.find(c=>(c==null?void 0:c.type.name)===n.name);return a&&r.removeStoredMark(a),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}}let ze=class Ih{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=be(re(this,"addOptions",{name:this.name}))),this.storage=be(re(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Ih(e)}configure(e={}){const n=this.extend();return n.options=_l(this.options,e),n.storage=be(re(n,"addStorage",{name:n.name,options:n.options})),n}extend(e={}){const n=new Ih({...this.config,...e});return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=be(re(n,"addOptions",{name:n.name})),n.storage=be(re(n,"addStorage",{name:n.name,options:n.options})),n}};function lE(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}class aE{constructor(e,n,r){this.isDragging=!1,this.component=e,this.editor=n.editor,this.options={stopEvent:null,ignoreMutation:null,...r},this.extension=n.extension,this.node=n.node,this.decorations=n.decorations,this.getPos=n.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var n,r,i,s,o,l,a;const{view:c}=this.editor,u=e.target,d=u.nodeType===3?(n=u.parentElement)===null||n===void 0?void 0:n.closest("[data-drag-handle]"):u.closest("[data-drag-handle]");if(!this.dom||!((r=this.contentDOM)===null||r===void 0)&&r.contains(u)||!d)return;let f=0,h=0;if(this.dom!==d){const v=this.dom.getBoundingClientRect(),w=d.getBoundingClientRect(),S=(i=e.offsetX)!==null&&i!==void 0?i:(s=e.nativeEvent)===null||s===void 0?void 0:s.offsetX,x=(o=e.offsetY)!==null&&o!==void 0?o:(l=e.nativeEvent)===null||l===void 0?void 0:l.offsetY;f=w.x-v.x+S,h=w.y-v.y+x}(a=e.dataTransfer)===null||a===void 0||a.setDragImage(this.dom,f,h);const p=se.create(c.state.doc,this.getPos()),g=c.state.tr.setSelection(p);c.dispatch(g)}stopEvent(e){var n;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:e});const r=e.target;if(!(this.dom.contains(r)&&!(!((n=this.contentDOM)===null||n===void 0)&&n.contains(r))))return!1;const s=e.type.startsWith("drag"),o=e.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(r.tagName)||r.isContentEditable)&&!o&&!s)return!0;const{isEditable:a}=this.editor,{isDragging:c}=this,u=!!this.node.type.spec.draggable,d=se.isSelectable(this.node),f=e.type==="copy",h=e.type==="paste",p=e.type==="cut",g=e.type==="mousedown";if(!u&&d&&s&&e.preventDefault(),u&&s&&!c)return e.preventDefault(),!1;if(u&&a&&!c&&g){const v=r.closest("[data-drag-handle]");v&&(this.dom===v||this.dom.contains(v))&&(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||o||f||h||p||g&&d)}ignoreMutation(e){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:e}):this.node.isLeaf||this.node.isAtom?!0:e.type==="selection"||this.dom.contains(e.target)&&e.type==="childList"&&(Dl()||lE())&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(r=>r.isContentEditable)?!1:this.contentDOM===e.target&&e.type==="attributes"?!0:!this.contentDOM.contains(e.target)}updateAttributes(e){this.editor.commands.command(({tr:n})=>{const r=this.getPos();return n.setNodeMarkup(r,void 0,{...this.node.attrs,...e}),!0})}deleteNode(){const e=this.getPos(),n=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:n})}}function Rr(t){return new RC({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=be(t.getAttributes,void 0,r,i);if(s===!1||s===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),f=d+l.length;if(ju(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(v=>v===t.type&&v!==p.mark.type)).filter(p=>p.to>d).length)return null;f<n.to&&o.delete(f,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(s||{})),o.removeStoredMark(t.type)}}})}function cE(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var Ht="top",on="bottom",ln="right",zt="left",qu="auto",co=[Ht,on,ln,zt],Yi="start",uo="end",uE="clippingParents",hg="viewport",fo="popper",dE="reference",pg=co.reduce(function(t,e){return t.concat([e+"-"+Yi,e+"-"+uo])},[]),mg=[].concat(co,[qu]).reduce(function(t,e){return t.concat([e,e+"-"+Yi,e+"-"+uo])},[]),fE="beforeRead",hE="read",pE="afterRead",mE="beforeMain",gE="main",yE="afterMain",bE="beforeWrite",vE="write",wE="afterWrite",xE=[fE,hE,pE,mE,gE,yE,bE,vE,wE];function Pn(t){return t?(t.nodeName||"").toLowerCase():null}function Jt(t){if(t==null)return window;if(t.toString()!=="[object Window]"){var e=t.ownerDocument;return e&&e.defaultView||window}return t}function ci(t){var e=Jt(t).Element;return t instanceof e||t instanceof Element}function an(t){var e=Jt(t).HTMLElement;return t instanceof e||t instanceof HTMLElement}function Ku(t){if(typeof ShadowRoot>"u")return!1;var e=Jt(t).ShadowRoot;return t instanceof e||t instanceof ShadowRoot}function kE(t){var e=t.state;Object.keys(e.elements).forEach(function(n){var r=e.styles[n]||{},i=e.attributes[n]||{},s=e.elements[n];!an(s)||!Pn(s)||(Object.assign(s.style,r),Object.keys(i).forEach(function(o){var l=i[o];l===!1?s.removeAttribute(o):s.setAttribute(o,l===!0?"":l)}))})}function CE(t){var e=t.state,n={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,n.popper),e.styles=n,e.elements.arrow&&Object.assign(e.elements.arrow.style,n.arrow),function(){Object.keys(e.elements).forEach(function(r){var i=e.elements[r],s=e.attributes[r]||{},o=Object.keys(e.styles.hasOwnProperty(r)?e.styles[r]:n[r]),l=o.reduce(function(a,c){return a[c]="",a},{});!an(i)||!Pn(i)||(Object.assign(i.style,l),Object.keys(s).forEach(function(a){i.removeAttribute(a)}))})}}const gg={name:"applyStyles",enabled:!0,phase:"write",fn:kE,effect:CE,requires:["computeStyles"]};function Fn(t){return t.split("-")[0]}var ui=Math.max,Pl=Math.min,Xi=Math.round;function Ju(){var t=navigator.userAgentData;return t!=null&&t.brands&&Array.isArray(t.brands)?t.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function yg(){return!/^((?!chrome|android).)*safari/i.test(Ju())}function Zi(t,e,n){e===void 0&&(e=!1),n===void 0&&(n=!1);var r=t.getBoundingClientRect(),i=1,s=1;e&&an(t)&&(i=t.offsetWidth>0&&Xi(r.width)/t.offsetWidth||1,s=t.offsetHeight>0&&Xi(r.height)/t.offsetHeight||1);var o=ci(t)?Jt(t):window,l=o.visualViewport,a=!yg()&&n,c=(r.left+(a&&l?l.offsetLeft:0))/i,u=(r.top+(a&&l?l.offsetTop:0))/s,d=r.width/i,f=r.height/s;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c,x:c,y:u}}function Gu(t){var e=Zi(t),n=t.offsetWidth,r=t.offsetHeight;return Math.abs(e.width-n)<=1&&(n=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:t.offsetLeft,y:t.offsetTop,width:n,height:r}}function bg(t,e){var n=e.getRootNode&&e.getRootNode();if(t.contains(e))return!0;if(n&&Ku(n)){var r=e;do{if(r&&t.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function ir(t){return Jt(t).getComputedStyle(t)}function SE(t){return["table","td","th"].indexOf(Pn(t))>=0}function Lr(t){return((ci(t)?t.ownerDocument:t.document)||window.document).documentElement}function Fl(t){return Pn(t)==="html"?t:t.assignedSlot||t.parentNode||(Ku(t)?t.host:null)||Lr(t)}function vg(t){return!an(t)||ir(t).position==="fixed"?null:t.offsetParent}function EE(t){var e=/firefox/i.test(Ju()),n=/Trident/i.test(Ju());if(n&&an(t)){var r=ir(t);if(r.position==="fixed")return null}var i=Fl(t);for(Ku(i)&&(i=i.host);an(i)&&["html","body"].indexOf(Pn(i))<0;){var s=ir(i);if(s.transform!=="none"||s.perspective!=="none"||s.contain==="paint"||["transform","perspective"].indexOf(s.willChange)!==-1||e&&s.willChange==="filter"||e&&s.filter&&s.filter!=="none")return i;i=i.parentNode}return null}function ho(t){for(var e=Jt(t),n=vg(t);n&&SE(n)&&ir(n).position==="static";)n=vg(n);return n&&(Pn(n)==="html"||Pn(n)==="body"&&ir(n).position==="static")?e:n||EE(t)||e}function Yu(t){return["top","bottom"].indexOf(t)>=0?"x":"y"}function po(t,e,n){return ui(t,Pl(e,n))}function TE(t,e,n){var r=po(t,e,n);return r>n?n:r}function wg(){return{top:0,right:0,bottom:0,left:0}}function xg(t){return Object.assign({},wg(),t)}function kg(t,e){return e.reduce(function(n,r){return n[r]=t,n},{})}var AE=function(e,n){return e=typeof e=="function"?e(Object.assign({},n.rects,{placement:n.placement})):e,xg(typeof e!="number"?e:kg(e,co))};function ME(t){var e,n=t.state,r=t.name,i=t.options,s=n.elements.arrow,o=n.modifiersData.popperOffsets,l=Fn(n.placement),a=Yu(l),c=[zt,ln].indexOf(l)>=0,u=c?"height":"width";if(!(!s||!o)){var d=AE(i.padding,n),f=Gu(s),h=a==="y"?Ht:zt,p=a==="y"?on:ln,g=n.rects.reference[u]+n.rects.reference[a]-o[a]-n.rects.popper[u],v=o[a]-n.rects.reference[a],w=ho(s),S=w?a==="y"?w.clientHeight||0:w.clientWidth||0:0,x=g/2-v/2,y=d[h],C=S-f[u]-d[p],E=S/2-f[u]/2+x,T=po(y,E,C),D=a;n.modifiersData[r]=(e={},e[D]=T,e.centerOffset=T-E,e)}}function OE(t){var e=t.state,n=t.options,r=n.element,i=r===void 0?"[data-popper-arrow]":r;i!=null&&(typeof i=="string"&&(i=e.elements.popper.querySelector(i),!i)||bg(e.elements.popper,i)&&(e.elements.arrow=i))}const _E={name:"arrow",enabled:!0,phase:"main",fn:ME,effect:OE,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Qi(t){return t.split("-")[1]}var NE={top:"auto",right:"auto",bottom:"auto",left:"auto"};function DE(t,e){var n=t.x,r=t.y,i=e.devicePixelRatio||1;return{x:Xi(n*i)/i||0,y:Xi(r*i)/i||0}}function Cg(t){var e,n=t.popper,r=t.popperRect,i=t.placement,s=t.variation,o=t.offsets,l=t.position,a=t.gpuAcceleration,c=t.adaptive,u=t.roundOffsets,d=t.isFixed,f=o.x,h=f===void 0?0:f,p=o.y,g=p===void 0?0:p,v=typeof u=="function"?u({x:h,y:g}):{x:h,y:g};h=v.x,g=v.y;var w=o.hasOwnProperty("x"),S=o.hasOwnProperty("y"),x=zt,y=Ht,C=window;if(c){var E=ho(n),T="clientHeight",D="clientWidth";if(E===Jt(n)&&(E=Lr(n),ir(E).position!=="static"&&l==="absolute"&&(T="scrollHeight",D="scrollWidth")),E=E,i===Ht||(i===zt||i===ln)&&s===uo){y=on;var N=d&&E===C&&C.visualViewport?C.visualViewport.height:E[T];g-=N-r.height,g*=a?1:-1}if(i===zt||(i===Ht||i===on)&&s===uo){x=ln;var A=d&&E===C&&C.visualViewport?C.visualViewport.width:E[D];h-=A-r.width,h*=a?1:-1}}var R=Object.assign({position:l},c&&NE),P=u===!0?DE({x:h,y:g},Jt(n)):{x:h,y:g};if(h=P.x,g=P.y,a){var B;return Object.assign({},R,(B={},B[y]=S?"0":"",B[x]=w?"0":"",B.transform=(C.devicePixelRatio||1)<=1?"translate("+h+"px, "+g+"px)":"translate3d("+h+"px, "+g+"px, 0)",B))}return Object.assign({},R,(e={},e[y]=S?g+"px":"",e[x]=w?h+"px":"",e.transform="",e))}function RE(t){var e=t.state,n=t.options,r=n.gpuAcceleration,i=r===void 0?!0:r,s=n.adaptive,o=s===void 0?!0:s,l=n.roundOffsets,a=l===void 0?!0:l,c={placement:Fn(e.placement),variation:Qi(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:i,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,Cg(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:o,roundOffsets:a})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,Cg(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:a})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}const LE={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:RE,data:{}};var $l={passive:!0};function IE(t){var e=t.state,n=t.instance,r=t.options,i=r.scroll,s=i===void 0?!0:i,o=r.resize,l=o===void 0?!0:o,a=Jt(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return s&&c.forEach(function(u){u.addEventListener("scroll",n.update,$l)}),l&&a.addEventListener("resize",n.update,$l),function(){s&&c.forEach(function(u){u.removeEventListener("scroll",n.update,$l)}),l&&a.removeEventListener("resize",n.update,$l)}}const PE={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:IE,data:{}};var FE={left:"right",right:"left",bottom:"top",top:"bottom"};function Bl(t){return t.replace(/left|right|bottom|top/g,function(e){return FE[e]})}var $E={start:"end",end:"start"};function Sg(t){return t.replace(/start|end/g,function(e){return $E[e]})}function Xu(t){var e=Jt(t),n=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:n,scrollTop:r}}function Zu(t){return Zi(Lr(t)).left+Xu(t).scrollLeft}function BE(t,e){var n=Jt(t),r=Lr(t),i=n.visualViewport,s=r.clientWidth,o=r.clientHeight,l=0,a=0;if(i){s=i.width,o=i.height;var c=yg();(c||!c&&e==="fixed")&&(l=i.offsetLeft,a=i.offsetTop)}return{width:s,height:o,x:l+Zu(t),y:a}}function jE(t){var e,n=Lr(t),r=Xu(t),i=(e=t.ownerDocument)==null?void 0:e.body,s=ui(n.scrollWidth,n.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),o=ui(n.scrollHeight,n.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),l=-r.scrollLeft+Zu(t),a=-r.scrollTop;return ir(i||n).direction==="rtl"&&(l+=ui(n.clientWidth,i?i.clientWidth:0)-s),{width:s,height:o,x:l,y:a}}function Qu(t){var e=ir(t),n=e.overflow,r=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function Eg(t){return["html","body","#document"].indexOf(Pn(t))>=0?t.ownerDocument.body:an(t)&&Qu(t)?t:Eg(Fl(t))}function mo(t,e){var n;e===void 0&&(e=[]);var r=Eg(t),i=r===((n=t.ownerDocument)==null?void 0:n.body),s=Jt(r),o=i?[s].concat(s.visualViewport||[],Qu(r)?r:[]):r,l=e.concat(o);return i?l:l.concat(mo(Fl(o)))}function ed(t){return Object.assign({},t,{left:t.x,top:t.y,right:t.x+t.width,bottom:t.y+t.height})}function HE(t,e){var n=Zi(t,!1,e==="fixed");return n.top=n.top+t.clientTop,n.left=n.left+t.clientLeft,n.bottom=n.top+t.clientHeight,n.right=n.left+t.clientWidth,n.width=t.clientWidth,n.height=t.clientHeight,n.x=n.left,n.y=n.top,n}function Tg(t,e,n){return e===hg?ed(BE(t,n)):ci(e)?HE(e,n):ed(jE(Lr(t)))}function zE(t){var e=mo(Fl(t)),n=["absolute","fixed"].indexOf(ir(t).position)>=0,r=n&&an(t)?ho(t):t;return ci(r)?e.filter(function(i){return ci(i)&&bg(i,r)&&Pn(i)!=="body"}):[]}function VE(t,e,n,r){var i=e==="clippingParents"?zE(t):[].concat(e),s=[].concat(i,[n]),o=s[0],l=s.reduce(function(a,c){var u=Tg(t,c,r);return a.top=ui(u.top,a.top),a.right=Pl(u.right,a.right),a.bottom=Pl(u.bottom,a.bottom),a.left=ui(u.left,a.left),a},Tg(t,o,r));return l.width=l.right-l.left,l.height=l.bottom-l.top,l.x=l.left,l.y=l.top,l}function Ag(t){var e=t.reference,n=t.element,r=t.placement,i=r?Fn(r):null,s=r?Qi(r):null,o=e.x+e.width/2-n.width/2,l=e.y+e.height/2-n.height/2,a;switch(i){case Ht:a={x:o,y:e.y-n.height};break;case on:a={x:o,y:e.y+e.height};break;case ln:a={x:e.x+e.width,y:l};break;case zt:a={x:e.x-n.width,y:l};break;default:a={x:e.x,y:e.y}}var c=i?Yu(i):null;if(c!=null){var u=c==="y"?"height":"width";switch(s){case Yi:a[c]=a[c]-(e[u]/2-n[u]/2);break;case uo:a[c]=a[c]+(e[u]/2-n[u]/2);break}}return a}function go(t,e){e===void 0&&(e={});var n=e,r=n.placement,i=r===void 0?t.placement:r,s=n.strategy,o=s===void 0?t.strategy:s,l=n.boundary,a=l===void 0?uE:l,c=n.rootBoundary,u=c===void 0?hg:c,d=n.elementContext,f=d===void 0?fo:d,h=n.altBoundary,p=h===void 0?!1:h,g=n.padding,v=g===void 0?0:g,w=xg(typeof v!="number"?v:kg(v,co)),S=f===fo?dE:fo,x=t.rects.popper,y=t.elements[p?S:f],C=VE(ci(y)?y:y.contextElement||Lr(t.elements.popper),a,u,o),E=Zi(t.elements.reference),T=Ag({reference:E,element:x,strategy:"absolute",placement:i}),D=ed(Object.assign({},x,T)),N=f===fo?D:E,A={top:C.top-N.top+w.top,bottom:N.bottom-C.bottom+w.bottom,left:C.left-N.left+w.left,right:N.right-C.right+w.right},R=t.modifiersData.offset;if(f===fo&&R){var P=R[i];Object.keys(A).forEach(function(B){var z=[ln,on].indexOf(B)>=0?1:-1,U=[Ht,on].indexOf(B)>=0?"y":"x";A[B]+=P[U]*z})}return A}function UE(t,e){e===void 0&&(e={});var n=e,r=n.placement,i=n.boundary,s=n.rootBoundary,o=n.padding,l=n.flipVariations,a=n.allowedAutoPlacements,c=a===void 0?mg:a,u=Qi(r),d=u?l?pg:pg.filter(function(p){return Qi(p)===u}):co,f=d.filter(function(p){return c.indexOf(p)>=0});f.length===0&&(f=d);var h=f.reduce(function(p,g){return p[g]=go(t,{placement:g,boundary:i,rootBoundary:s,padding:o})[Fn(g)],p},{});return Object.keys(h).sort(function(p,g){return h[p]-h[g]})}function WE(t){if(Fn(t)===qu)return[];var e=Bl(t);return[Sg(t),e,Sg(e)]}function qE(t){var e=t.state,n=t.options,r=t.name;if(!e.modifiersData[r]._skip){for(var i=n.mainAxis,s=i===void 0?!0:i,o=n.altAxis,l=o===void 0?!0:o,a=n.fallbackPlacements,c=n.padding,u=n.boundary,d=n.rootBoundary,f=n.altBoundary,h=n.flipVariations,p=h===void 0?!0:h,g=n.allowedAutoPlacements,v=e.options.placement,w=Fn(v),S=w===v,x=a||(S||!p?[Bl(v)]:WE(v)),y=[v].concat(x).reduce(function(ve,De){return ve.concat(Fn(De)===qu?UE(e,{placement:De,boundary:u,rootBoundary:d,padding:c,flipVariations:p,allowedAutoPlacements:g}):De)},[]),C=e.rects.reference,E=e.rects.popper,T=new Map,D=!0,N=y[0],A=0;A<y.length;A++){var R=y[A],P=Fn(R),B=Qi(R)===Yi,z=[Ht,on].indexOf(P)>=0,U=z?"width":"height",J=go(e,{placement:R,boundary:u,rootBoundary:d,altBoundary:f,padding:c}),G=z?B?ln:zt:B?on:Ht;C[U]>E[U]&&(G=Bl(G));var ie=Bl(G),Z=[];if(s&&Z.push(J[P]<=0),l&&Z.push(J[G]<=0,J[ie]<=0),Z.every(function(ve){return ve})){N=R,D=!1;break}T.set(R,Z)}if(D)for(var ke=p?3:1,Le=function(De){var Ie=y.find(function(tt){var nt=T.get(tt);if(nt)return nt.slice(0,De).every(function(Ge){return Ge})});if(Ie)return N=Ie,"break"},$e=ke;$e>0;$e--){var Ee=Le($e);if(Ee==="break")break}e.placement!==N&&(e.modifiersData[r]._skip=!0,e.placement=N,e.reset=!0)}}const KE={name:"flip",enabled:!0,phase:"main",fn:qE,requiresIfExists:["offset"],data:{_skip:!1}};function Mg(t,e,n){return n===void 0&&(n={x:0,y:0}),{top:t.top-e.height-n.y,right:t.right-e.width+n.x,bottom:t.bottom-e.height+n.y,left:t.left-e.width-n.x}}function Og(t){return[Ht,ln,on,zt].some(function(e){return t[e]>=0})}function JE(t){var e=t.state,n=t.name,r=e.rects.reference,i=e.rects.popper,s=e.modifiersData.preventOverflow,o=go(e,{elementContext:"reference"}),l=go(e,{altBoundary:!0}),a=Mg(o,r),c=Mg(l,i,s),u=Og(a),d=Og(c);e.modifiersData[n]={referenceClippingOffsets:a,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}const GE={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:JE};function YE(t,e,n){var r=Fn(t),i=[zt,Ht].indexOf(r)>=0?-1:1,s=typeof n=="function"?n(Object.assign({},e,{placement:t})):n,o=s[0],l=s[1];return o=o||0,l=(l||0)*i,[zt,ln].indexOf(r)>=0?{x:l,y:o}:{x:o,y:l}}function XE(t){var e=t.state,n=t.options,r=t.name,i=n.offset,s=i===void 0?[0,0]:i,o=mg.reduce(function(u,d){return u[d]=YE(d,e.rects,s),u},{}),l=o[e.placement],a=l.x,c=l.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=a,e.modifiersData.popperOffsets.y+=c),e.modifiersData[r]=o}const ZE={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:XE};function QE(t){var e=t.state,n=t.name;e.modifiersData[n]=Ag({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const eT={name:"popperOffsets",enabled:!0,phase:"read",fn:QE,data:{}};function tT(t){return t==="x"?"y":"x"}function nT(t){var e=t.state,n=t.options,r=t.name,i=n.mainAxis,s=i===void 0?!0:i,o=n.altAxis,l=o===void 0?!1:o,a=n.boundary,c=n.rootBoundary,u=n.altBoundary,d=n.padding,f=n.tether,h=f===void 0?!0:f,p=n.tetherOffset,g=p===void 0?0:p,v=go(e,{boundary:a,rootBoundary:c,padding:d,altBoundary:u}),w=Fn(e.placement),S=Qi(e.placement),x=!S,y=Yu(w),C=tT(y),E=e.modifiersData.popperOffsets,T=e.rects.reference,D=e.rects.popper,N=typeof g=="function"?g(Object.assign({},e.rects,{placement:e.placement})):g,A=typeof N=="number"?{mainAxis:N,altAxis:N}:Object.assign({mainAxis:0,altAxis:0},N),R=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,P={x:0,y:0};if(E){if(s){var B,z=y==="y"?Ht:zt,U=y==="y"?on:ln,J=y==="y"?"height":"width",G=E[y],ie=G+v[z],Z=G-v[U],ke=h?-D[J]/2:0,Le=S===Yi?T[J]:D[J],$e=S===Yi?-D[J]:-T[J],Ee=e.elements.arrow,ve=h&&Ee?Gu(Ee):{width:0,height:0},De=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:wg(),Ie=De[z],tt=De[U],nt=po(0,T[J],ve[J]),Ge=x?T[J]/2-ke-nt-Ie-A.mainAxis:Le-nt-Ie-A.mainAxis,Ye=x?-T[J]/2+ke+nt+tt+A.mainAxis:$e+nt+tt+A.mainAxis,Ot=e.elements.arrow&&ho(e.elements.arrow),xt=Ot?y==="y"?Ot.clientTop||0:Ot.clientLeft||0:0,it=(B=R==null?void 0:R[y])!=null?B:0,at=G+Ge-it-xt,$=G+Ye-it,j=po(h?Pl(ie,at):ie,G,h?ui(Z,$):Z);E[y]=j,P[y]=j-G}if(l){var q,te=y==="x"?Ht:zt,M=y==="x"?on:ln,m=E[C],b=C==="y"?"height":"width",k=m+v[te],I=m-v[M],F=[Ht,zt].indexOf(w)!==-1,H=(q=R==null?void 0:R[C])!=null?q:0,ne=F?k:m-T[b]-D[b]-H+A.altAxis,de=F?m+T[b]+D[b]-H-A.altAxis:I,_e=h&&F?TE(ne,m,de):po(h?ne:k,m,h?de:I);E[C]=_e,P[C]=_e-m}e.modifiersData[r]=P}}const rT={name:"preventOverflow",enabled:!0,phase:"main",fn:nT,requiresIfExists:["offset"]};function iT(t){return{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}}function sT(t){return t===Jt(t)||!an(t)?Xu(t):iT(t)}function oT(t){var e=t.getBoundingClientRect(),n=Xi(e.width)/t.offsetWidth||1,r=Xi(e.height)/t.offsetHeight||1;return n!==1||r!==1}function lT(t,e,n){n===void 0&&(n=!1);var r=an(e),i=an(e)&&oT(e),s=Lr(e),o=Zi(t,i,n),l={scrollLeft:0,scrollTop:0},a={x:0,y:0};return(r||!r&&!n)&&((Pn(e)!=="body"||Qu(s))&&(l=sT(e)),an(e)?(a=Zi(e,!0),a.x+=e.clientLeft,a.y+=e.clientTop):s&&(a.x=Zu(s))),{x:o.left+l.scrollLeft-a.x,y:o.top+l.scrollTop-a.y,width:o.width,height:o.height}}function aT(t){var e=new Map,n=new Set,r=[];t.forEach(function(s){e.set(s.name,s)});function i(s){n.add(s.name);var o=[].concat(s.requires||[],s.requiresIfExists||[]);o.forEach(function(l){if(!n.has(l)){var a=e.get(l);a&&i(a)}}),r.push(s)}return t.forEach(function(s){n.has(s.name)||i(s)}),r}function cT(t){var e=aT(t);return xE.reduce(function(n,r){return n.concat(e.filter(function(i){return i.phase===r}))},[])}function uT(t){var e;return function(){return e||(e=new Promise(function(n){Promise.resolve().then(function(){e=void 0,n(t())})})),e}}function dT(t){var e=t.reduce(function(n,r){var i=n[r.name];return n[r.name]=i?Object.assign({},i,r,{options:Object.assign({},i.options,r.options),data:Object.assign({},i.data,r.data)}):r,n},{});return Object.keys(e).map(function(n){return e[n]})}var _g={placement:"bottom",modifiers:[],strategy:"absolute"};function Ng(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return!e.some(function(r){return!(r&&typeof r.getBoundingClientRect=="function")})}function fT(t){t===void 0&&(t={});var e=t,n=e.defaultModifiers,r=n===void 0?[]:n,i=e.defaultOptions,s=i===void 0?_g:i;return function(l,a,c){c===void 0&&(c=s);var u={placement:"bottom",orderedModifiers:[],options:Object.assign({},_g,s),modifiersData:{},elements:{reference:l,popper:a},attributes:{},styles:{}},d=[],f=!1,h={state:u,setOptions:function(w){var S=typeof w=="function"?w(u.options):w;g(),u.options=Object.assign({},s,u.options,S),u.scrollParents={reference:ci(l)?mo(l):l.contextElement?mo(l.contextElement):[],popper:mo(a)};var x=cT(dT([].concat(r,u.options.modifiers)));return u.orderedModifiers=x.filter(function(y){return y.enabled}),p(),h.update()},forceUpdate:function(){if(!f){var w=u.elements,S=w.reference,x=w.popper;if(Ng(S,x)){u.rects={reference:lT(S,ho(x),u.options.strategy==="fixed"),popper:Gu(x)},u.reset=!1,u.placement=u.options.placement,u.orderedModifiers.forEach(function(A){return u.modifiersData[A.name]=Object.assign({},A.data)});for(var y=0;y<u.orderedModifiers.length;y++){if(u.reset===!0){u.reset=!1,y=-1;continue}var C=u.orderedModifiers[y],E=C.fn,T=C.options,D=T===void 0?{}:T,N=C.name;typeof E=="function"&&(u=E({state:u,options:D,name:N,instance:h})||u)}}}},update:uT(function(){return new Promise(function(v){h.forceUpdate(),v(u)})}),destroy:function(){g(),f=!0}};if(!Ng(l,a))return h;h.setOptions(c).then(function(v){!f&&c.onFirstUpdate&&c.onFirstUpdate(v)});function p(){u.orderedModifiers.forEach(function(v){var w=v.name,S=v.options,x=S===void 0?{}:S,y=v.effect;if(typeof y=="function"){var C=y({state:u,name:w,instance:h,options:x}),E=function(){};d.push(C||E)}})}function g(){d.forEach(function(v){return v()}),d=[]}return h}}var hT=[PE,eT,LE,gg,ZE,KE,rT,_E,GE],pT=fT({defaultModifiers:hT}),mT="tippy-box",Dg="tippy-content",gT="tippy-backdrop",Rg="tippy-arrow",Lg="tippy-svg-arrow",di={passive:!0,capture:!0},Ig=function(){return document.body};function yT(t,e){return{}.hasOwnProperty.call(t,e)}function td(t,e,n){if(Array.isArray(t)){var r=t[e];return r??(Array.isArray(n)?n[e]:n)}return t}function nd(t,e){var n={}.toString.call(t);return n.indexOf("[object")===0&&n.indexOf(e+"]")>-1}function Pg(t,e){return typeof t=="function"?t.apply(void 0,e):t}function Fg(t,e){if(e===0)return t;var n;return function(r){clearTimeout(n),n=setTimeout(function(){t(r)},e)}}function bT(t,e){var n=Object.assign({},t);return e.forEach(function(r){delete n[r]}),n}function vT(t){return t.split(/\s+/).filter(Boolean)}function es(t){return[].concat(t)}function $g(t,e){t.indexOf(e)===-1&&t.push(e)}function wT(t){return t.filter(function(e,n){return t.indexOf(e)===n})}function xT(t){return t.split("-")[0]}function jl(t){return[].slice.call(t)}function Bg(t){return Object.keys(t).reduce(function(e,n){return t[n]!==void 0&&(e[n]=t[n]),e},{})}function yo(){return document.createElement("div")}function bo(t){return["Element","Fragment"].some(function(e){return nd(t,e)})}function kT(t){return nd(t,"NodeList")}function CT(t){return nd(t,"MouseEvent")}function ST(t){return!!(t&&t._tippy&&t._tippy.reference===t)}function ET(t){return bo(t)?[t]:kT(t)?jl(t):Array.isArray(t)?t:jl(document.querySelectorAll(t))}function rd(t,e){t.forEach(function(n){n&&(n.style.transitionDuration=e+"ms")})}function jg(t,e){t.forEach(function(n){n&&n.setAttribute("data-state",e)})}function TT(t){var e,n=es(t),r=n[0];return r!=null&&(e=r.ownerDocument)!=null&&e.body?r.ownerDocument:document}function AT(t,e){var n=e.clientX,r=e.clientY;return t.every(function(i){var s=i.popperRect,o=i.popperState,l=i.props,a=l.interactiveBorder,c=xT(o.placement),u=o.modifiersData.offset;if(!u)return!0;var d=c==="bottom"?u.top.y:0,f=c==="top"?u.bottom.y:0,h=c==="right"?u.left.x:0,p=c==="left"?u.right.x:0,g=s.top-r+d>a,v=r-s.bottom-f>a,w=s.left-n+h>a,S=n-s.right-p>a;return g||v||w||S})}function id(t,e,n){var r=e+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(i){t[r](i,n)})}function Hg(t,e){for(var n=e;n;){var r;if(t.contains(n))return!0;n=n.getRootNode==null||(r=n.getRootNode())==null?void 0:r.host}return!1}var $n={isTouch:!1},zg=0;function MT(){$n.isTouch||($n.isTouch=!0,window.performance&&document.addEventListener("mousemove",Vg))}function Vg(){var t=performance.now();t-zg<20&&($n.isTouch=!1,document.removeEventListener("mousemove",Vg)),zg=t}function OT(){var t=document.activeElement;if(ST(t)){var e=t._tippy;t.blur&&!e.state.isVisible&&t.blur()}}function _T(){document.addEventListener("touchstart",MT,di),window.addEventListener("blur",OT)}var NT=typeof window<"u"&&typeof document<"u",DT=NT?!!window.msCrypto:!1;function ts(t){var e=t==="destroy"?"n already-":" ";return[t+"() was called on a"+e+"destroyed instance. This is a no-op but","indicates a potential memory leak."].join(" ")}function Ug(t){var e=/[ \t]{2,}/g,n=/^[ \t]*/gm;return t.replace(e," ").replace(n,"").trim()}function RT(t){return Ug(`
|
119
119
|
%ctippy.js
|
120
120
|
|
121
|
-
%c`+
|
121
|
+
%c`+Ug(t)+`
|
122
122
|
|
123
123
|
%c👷 This is a development-only message. It will be removed in production.
|
124
|
-
`)}function
|
124
|
+
`)}function Wg(t){return[RT(t),"color: #00C584; font-size: 1.3em; font-weight: bold;","line-height: 1.5","color: #a6a095;"]}var vo;process.env.NODE_ENV!=="production"&<();function LT(){vo=new Set}function sr(t,e){if(t&&!vo.has(e)){var n;vo.add(e),(n=console).warn.apply(n,Wg(e))}}function sd(t,e){if(t&&!vo.has(e)){var n;vo.add(e),(n=console).error.apply(n,Wg(e))}}function IT(t){var e=!t,n=Object.prototype.toString.call(t)==="[object Object]"&&!t.addEventListener;sd(e,["tippy() was passed","`"+String(t)+"`","as its targets (first) argument. Valid types are: String, Element,","Element[], or NodeList."].join(" ")),sd(n,["tippy() was passed a plain object which is not supported as an argument","for virtual positioning. Use props.getReferenceClientRect instead."].join(" "))}var qg={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},PT={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},Gt=Object.assign({appendTo:Ig,aria:{content:"auto",expanded:"auto"},delay:0,duration:[300,250],getReferenceClientRect:null,hideOnClick:!0,ignoreAttributes:!1,interactive:!1,interactiveBorder:2,interactiveDebounce:0,moveTransition:"",offset:[0,10],onAfterUpdate:function(){},onBeforeUpdate:function(){},onCreate:function(){},onDestroy:function(){},onHidden:function(){},onHide:function(){},onMount:function(){},onShow:function(){},onShown:function(){},onTrigger:function(){},onUntrigger:function(){},onClickOutside:function(){},placement:"top",plugins:[],popperOptions:{},render:null,showOnCreate:!1,touch:!0,trigger:"mouseenter focus",triggerTarget:null},qg,PT),FT=Object.keys(Gt),$T=function(e){process.env.NODE_ENV!=="production"&&Gg(e,[]);var n=Object.keys(e);n.forEach(function(r){Gt[r]=e[r]})};function Kg(t){var e=t.plugins||[],n=e.reduce(function(r,i){var s=i.name,o=i.defaultValue;if(s){var l;r[s]=t[s]!==void 0?t[s]:(l=Gt[s])!=null?l:o}return r},{});return Object.assign({},t,n)}function BT(t,e){var n=e?Object.keys(Kg(Object.assign({},Gt,{plugins:e}))):FT,r=n.reduce(function(i,s){var o=(t.getAttribute("data-tippy-"+s)||"").trim();if(!o)return i;if(s==="content")i[s]=o;else try{i[s]=JSON.parse(o)}catch{i[s]=o}return i},{});return r}function Jg(t,e){var n=Object.assign({},e,{content:Pg(e.content,[t])},e.ignoreAttributes?{}:BT(t,e.plugins));return n.aria=Object.assign({},Gt.aria,n.aria),n.aria={expanded:n.aria.expanded==="auto"?e.interactive:n.aria.expanded,content:n.aria.content==="auto"?e.interactive?null:"describedby":n.aria.content},n}function Gg(t,e){t===void 0&&(t={}),e===void 0&&(e=[]);var n=Object.keys(t);n.forEach(function(r){var i=bT(Gt,Object.keys(qg)),s=!yT(i,r);s&&(s=e.filter(function(o){return o.name===r}).length===0),sr(s,["`"+r+"`","is not a valid prop. You may have spelled it incorrectly, or if it's","a plugin, forgot to pass it in an array as props.plugins.",`
|
125
125
|
|
126
126
|
`,`All props: https://atomiks.github.io/tippyjs/v6/all-props/
|
127
|
-
`,"Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "))})}var jT=function(){return"innerHTML"};function
|
127
|
+
`,"Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "))})}var jT=function(){return"innerHTML"};function od(t,e){t[jT()]=e}function Yg(t){var e=yo();return t===!0?e.className=Rg:(e.className=Lg,bo(t)?e.appendChild(t):od(e,t)),e}function Xg(t,e){bo(e.content)?(od(t,""),t.appendChild(e.content)):typeof e.content!="function"&&(e.allowHTML?od(t,e.content):t.textContent=e.content)}function ld(t){var e=t.firstElementChild,n=jl(e.children);return{box:e,content:n.find(function(r){return r.classList.contains(Dg)}),arrow:n.find(function(r){return r.classList.contains(Rg)||r.classList.contains(Lg)}),backdrop:n.find(function(r){return r.classList.contains(gT)})}}function Zg(t){var e=yo(),n=yo();n.className=mT,n.setAttribute("data-state","hidden"),n.setAttribute("tabindex","-1");var r=yo();r.className=Dg,r.setAttribute("data-state","hidden"),Xg(r,t.props),e.appendChild(n),n.appendChild(r),i(t.props,t.props);function i(s,o){var l=ld(e),a=l.box,c=l.content,u=l.arrow;o.theme?a.setAttribute("data-theme",o.theme):a.removeAttribute("data-theme"),typeof o.animation=="string"?a.setAttribute("data-animation",o.animation):a.removeAttribute("data-animation"),o.inertia?a.setAttribute("data-inertia",""):a.removeAttribute("data-inertia"),a.style.maxWidth=typeof o.maxWidth=="number"?o.maxWidth+"px":o.maxWidth,o.role?a.setAttribute("role",o.role):a.removeAttribute("role"),(s.content!==o.content||s.allowHTML!==o.allowHTML)&&Xg(c,t.props),o.arrow?u?s.arrow!==o.arrow&&(a.removeChild(u),a.appendChild(Yg(o.arrow))):a.appendChild(Yg(o.arrow)):u&&a.removeChild(u)}return{popper:e,onUpdate:i}}Zg.$$tippy=!0;var HT=1,Hl=[],ad=[];function zT(t,e){var n=Jg(t,Object.assign({},Gt,Kg(Bg(e)))),r,i,s,o=!1,l=!1,a=!1,c=!1,u,d,f,h=[],p=Fg(at,n.interactiveDebounce),g,v=HT++,w=null,S=wT(n.plugins),x={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},y={id:v,reference:t,popper:yo(),popperInstance:w,props:n,state:x,plugins:S,clearDelayTimeouts:ne,setProps:de,setContent:_e,show:we,hide:ye,hideWithInteractivity:Xe,enable:F,disable:H,unmount:Mn,destroy:Qn};if(!n.render)return process.env.NODE_ENV!=="production"&&sd(!0,"render() function has not been supplied."),y;var C=n.render(y),E=C.popper,T=C.onUpdate;E.setAttribute("data-tippy-root",""),E.id="tippy-"+y.id,y.popper=E,t._tippy=y,E._tippy=y;var D=S.map(function(V){return V.fn(y)}),N=t.hasAttribute("aria-expanded");return Ot(),ke(),G(),ie("onCreate",[y]),n.showOnCreate&&k(),E.addEventListener("mouseenter",function(){y.props.interactive&&y.state.isVisible&&y.clearDelayTimeouts()}),E.addEventListener("mouseleave",function(){y.props.interactive&&y.props.trigger.indexOf("mouseenter")>=0&&z().addEventListener("mousemove",p)}),y;function A(){var V=y.props.touch;return Array.isArray(V)?V:[V,0]}function R(){return A()[0]==="hold"}function P(){var V;return!!((V=y.props.render)!=null&&V.$$tippy)}function B(){return g||t}function z(){var V=B().parentNode;return V?TT(V):document}function U(){return ld(E)}function J(V){return y.state.isMounted&&!y.state.isVisible||$n.isTouch||u&&u.type==="focus"?0:td(y.props.delay,V?0:1,Gt.delay)}function G(V){V===void 0&&(V=!1),E.style.pointerEvents=y.props.interactive&&!V?"":"none",E.style.zIndex=""+y.props.zIndex}function ie(V,ee,oe){if(oe===void 0&&(oe=!0),D.forEach(function(Me){Me[V]&&Me[V].apply(Me,ee)}),oe){var Ne;(Ne=y.props)[V].apply(Ne,ee)}}function Z(){var V=y.props.aria;if(V.content){var ee="aria-"+V.content,oe=E.id,Ne=es(y.props.triggerTarget||t);Ne.forEach(function(Me){var ft=Me.getAttribute(ee);if(y.state.isVisible)Me.setAttribute(ee,ft?ft+" "+oe:oe);else{var Pt=ft&&ft.replace(oe,"").trim();Pt?Me.setAttribute(ee,Pt):Me.removeAttribute(ee)}})}}function ke(){if(!(N||!y.props.aria.expanded)){var V=es(y.props.triggerTarget||t);V.forEach(function(ee){y.props.interactive?ee.setAttribute("aria-expanded",y.state.isVisible&&ee===B()?"true":"false"):ee.removeAttribute("aria-expanded")})}}function Le(){z().removeEventListener("mousemove",p),Hl=Hl.filter(function(V){return V!==p})}function $e(V){if(!($n.isTouch&&(a||V.type==="mousedown"))){var ee=V.composedPath&&V.composedPath()[0]||V.target;if(!(y.props.interactive&&Hg(E,ee))){if(es(y.props.triggerTarget||t).some(function(oe){return Hg(oe,ee)})){if($n.isTouch||y.state.isVisible&&y.props.trigger.indexOf("click")>=0)return}else ie("onClickOutside",[y,V]);y.props.hideOnClick===!0&&(y.clearDelayTimeouts(),y.hide(),l=!0,setTimeout(function(){l=!1}),y.state.isMounted||Ie())}}}function Ee(){a=!0}function ve(){a=!1}function De(){var V=z();V.addEventListener("mousedown",$e,!0),V.addEventListener("touchend",$e,di),V.addEventListener("touchstart",ve,di),V.addEventListener("touchmove",Ee,di)}function Ie(){var V=z();V.removeEventListener("mousedown",$e,!0),V.removeEventListener("touchend",$e,di),V.removeEventListener("touchstart",ve,di),V.removeEventListener("touchmove",Ee,di)}function tt(V,ee){Ge(V,function(){!y.state.isVisible&&E.parentNode&&E.parentNode.contains(E)&&ee()})}function nt(V,ee){Ge(V,ee)}function Ge(V,ee){var oe=U().box;function Ne(Me){Me.target===oe&&(id(oe,"remove",Ne),ee())}if(V===0)return ee();id(oe,"remove",d),id(oe,"add",Ne),d=Ne}function Ye(V,ee,oe){oe===void 0&&(oe=!1);var Ne=es(y.props.triggerTarget||t);Ne.forEach(function(Me){Me.addEventListener(V,ee,oe),h.push({node:Me,eventType:V,handler:ee,options:oe})})}function Ot(){R()&&(Ye("touchstart",it,{passive:!0}),Ye("touchend",$,{passive:!0})),vT(y.props.trigger).forEach(function(V){if(V!=="manual")switch(Ye(V,it),V){case"mouseenter":Ye("mouseleave",$);break;case"focus":Ye(DT?"focusout":"blur",j);break;case"focusin":Ye("focusout",j);break}})}function xt(){h.forEach(function(V){var ee=V.node,oe=V.eventType,Ne=V.handler,Me=V.options;ee.removeEventListener(oe,Ne,Me)}),h=[]}function it(V){var ee,oe=!1;if(!(!y.state.isEnabled||q(V)||l)){var Ne=((ee=u)==null?void 0:ee.type)==="focus";u=V,g=V.currentTarget,ke(),!y.state.isVisible&&CT(V)&&Hl.forEach(function(Me){return Me(V)}),V.type==="click"&&(y.props.trigger.indexOf("mouseenter")<0||o)&&y.props.hideOnClick!==!1&&y.state.isVisible?oe=!0:k(V),V.type==="click"&&(o=!oe),oe&&!Ne&&I(V)}}function at(V){var ee=V.target,oe=B().contains(ee)||E.contains(ee);if(!(V.type==="mousemove"&&oe)){var Ne=b().concat(E).map(function(Me){var ft,Pt=Me._tippy,tn=(ft=Pt.popperInstance)==null?void 0:ft.state;return tn?{popperRect:Me.getBoundingClientRect(),popperState:tn,props:n}:null}).filter(Boolean);AT(Ne,V)&&(Le(),I(V))}}function $(V){var ee=q(V)||y.props.trigger.indexOf("click")>=0&&o;if(!ee){if(y.props.interactive){y.hideWithInteractivity(V);return}I(V)}}function j(V){y.props.trigger.indexOf("focusin")<0&&V.target!==B()||y.props.interactive&&V.relatedTarget&&E.contains(V.relatedTarget)||I(V)}function q(V){return $n.isTouch?R()!==V.type.indexOf("touch")>=0:!1}function te(){M();var V=y.props,ee=V.popperOptions,oe=V.placement,Ne=V.offset,Me=V.getReferenceClientRect,ft=V.moveTransition,Pt=P()?ld(E).arrow:null,tn=Me?{getBoundingClientRect:Me,contextElement:Me.contextElement||B()}:t,Ps={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function($s){var br=$s.state;if(P()){var _h=U(),Bs=_h.box;["placement","reference-hidden","escaped"].forEach(function(Di){Di==="placement"?Bs.setAttribute("data-placement",br.placement):br.attributes.popper["data-popper-"+Di]?Bs.setAttribute("data-"+Di,""):Bs.removeAttribute("data-"+Di)}),br.attributes.popper={}}}},On=[{name:"offset",options:{offset:Ne}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!ft}},Ps];P()&&Pt&&On.push({name:"arrow",options:{element:Pt,padding:3}}),On.push.apply(On,(ee==null?void 0:ee.modifiers)||[]),y.popperInstance=pT(tn,E,Object.assign({},ee,{placement:oe,onFirstUpdate:f,modifiers:On}))}function M(){y.popperInstance&&(y.popperInstance.destroy(),y.popperInstance=null)}function m(){var V=y.props.appendTo,ee,oe=B();y.props.interactive&&V===Ig||V==="parent"?ee=oe.parentNode:ee=Pg(V,[oe]),ee.contains(E)||ee.appendChild(E),y.state.isMounted=!0,te(),process.env.NODE_ENV!=="production"&&sr(y.props.interactive&&V===Gt.appendTo&&oe.nextElementSibling!==E,["Interactive tippy element may not be accessible via keyboard","navigation because it is not directly after the reference element","in the DOM source order.",`
|
128
128
|
|
129
129
|
`,"Using a wrapper <div> or <span> tag around the reference element","solves this by creating a new parentNode context.",`
|
130
130
|
|
131
131
|
`,"Specifying `appendTo: document.body` silences this warning, but it","assumes you are using a focus management solution to handle","keyboard navigation.",`
|
132
132
|
|
133
|
-
`,"See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "))}function b(){return jl(E.querySelectorAll("[data-tippy-root]"))}function k(V){y.clearDelayTimeouts(),V&&ie("onTrigger",[y,V]),De();var ee=J(!0),oe=A(),Ne=oe[0],Me=oe[1];$n.isTouch&&Ne==="hold"&&Me&&(ee=Me),ee?r=setTimeout(function(){y.show()},ee):y.show()}function I(V){if(y.clearDelayTimeouts(),ie("onUntrigger",[y,V]),!y.state.isVisible){Ie();return}if(!(y.props.trigger.indexOf("mouseenter")>=0&&y.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(V.type)>=0&&o)){var ee=J(!1);ee?i=setTimeout(function(){y.state.isVisible&&y.hide()},ee):s=requestAnimationFrame(function(){y.hide()})}}function F(){y.state.isEnabled=!0}function H(){y.hide(),y.state.isEnabled=!1}function ne(){clearTimeout(r),clearTimeout(i),cancelAnimationFrame(s)}function de(V){if(process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,ts("setProps")),!y.state.isDestroyed){ie("onBeforeUpdate",[y,V]),xt();var ee=y.props,oe=
|
133
|
+
`,"See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "))}function b(){return jl(E.querySelectorAll("[data-tippy-root]"))}function k(V){y.clearDelayTimeouts(),V&&ie("onTrigger",[y,V]),De();var ee=J(!0),oe=A(),Ne=oe[0],Me=oe[1];$n.isTouch&&Ne==="hold"&&Me&&(ee=Me),ee?r=setTimeout(function(){y.show()},ee):y.show()}function I(V){if(y.clearDelayTimeouts(),ie("onUntrigger",[y,V]),!y.state.isVisible){Ie();return}if(!(y.props.trigger.indexOf("mouseenter")>=0&&y.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(V.type)>=0&&o)){var ee=J(!1);ee?i=setTimeout(function(){y.state.isVisible&&y.hide()},ee):s=requestAnimationFrame(function(){y.hide()})}}function F(){y.state.isEnabled=!0}function H(){y.hide(),y.state.isEnabled=!1}function ne(){clearTimeout(r),clearTimeout(i),cancelAnimationFrame(s)}function de(V){if(process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,ts("setProps")),!y.state.isDestroyed){ie("onBeforeUpdate",[y,V]),xt();var ee=y.props,oe=Jg(t,Object.assign({},ee,Bg(V),{ignoreAttributes:!0}));y.props=oe,Ot(),ee.interactiveDebounce!==oe.interactiveDebounce&&(Le(),p=Fg(at,oe.interactiveDebounce)),ee.triggerTarget&&!oe.triggerTarget?es(ee.triggerTarget).forEach(function(Ne){Ne.removeAttribute("aria-expanded")}):oe.triggerTarget&&t.removeAttribute("aria-expanded"),ke(),G(),T&&T(ee,oe),y.popperInstance&&(te(),b().forEach(function(Ne){requestAnimationFrame(Ne._tippy.popperInstance.forceUpdate)})),ie("onAfterUpdate",[y,V])}}function _e(V){y.setProps({content:V})}function we(){process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,ts("show"));var V=y.state.isVisible,ee=y.state.isDestroyed,oe=!y.state.isEnabled,Ne=$n.isTouch&&!y.props.touch,Me=td(y.props.duration,0,Gt.duration);if(!(V||ee||oe||Ne)&&!B().hasAttribute("disabled")&&(ie("onShow",[y],!1),y.props.onShow(y)!==!1)){if(y.state.isVisible=!0,P()&&(E.style.visibility="visible"),G(),De(),y.state.isMounted||(E.style.transition="none"),P()){var ft=U(),Pt=ft.box,tn=ft.content;rd([Pt,tn],0)}f=function(){var On;if(!(!y.state.isVisible||c)){if(c=!0,E.offsetHeight,E.style.transition=y.props.moveTransition,P()&&y.props.animation){var Fs=U(),$s=Fs.box,br=Fs.content;rd([$s,br],Me),jg([$s,br],"visible")}Z(),ke(),$g(ad,y),(On=y.popperInstance)==null||On.forceUpdate(),ie("onMount",[y]),y.props.animation&&P()&&nt(Me,function(){y.state.isShown=!0,ie("onShown",[y])})}},m()}}function ye(){process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,ts("hide"));var V=!y.state.isVisible,ee=y.state.isDestroyed,oe=!y.state.isEnabled,Ne=td(y.props.duration,1,Gt.duration);if(!(V||ee||oe)&&(ie("onHide",[y],!1),y.props.onHide(y)!==!1)){if(y.state.isVisible=!1,y.state.isShown=!1,c=!1,o=!1,P()&&(E.style.visibility="hidden"),Le(),Ie(),G(!0),P()){var Me=U(),ft=Me.box,Pt=Me.content;y.props.animation&&(rd([ft,Pt],Ne),jg([ft,Pt],"hidden"))}Z(),ke(),y.props.animation?P()&&tt(Ne,y.unmount):y.unmount()}}function Xe(V){process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,ts("hideWithInteractivity")),z().addEventListener("mousemove",p),$g(Hl,p),p(V)}function Mn(){process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,ts("unmount")),y.state.isVisible&&y.hide(),y.state.isMounted&&(M(),b().forEach(function(V){V._tippy.unmount()}),E.parentNode&&E.parentNode.removeChild(E),ad=ad.filter(function(V){return V!==y}),y.state.isMounted=!1,ie("onHidden",[y]))}function Qn(){process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,ts("destroy")),!y.state.isDestroyed&&(y.clearDelayTimeouts(),y.unmount(),xt(),delete t._tippy,y.state.isDestroyed=!0,ie("onDestroy",[y]))}}function fi(t,e){e===void 0&&(e={});var n=Gt.plugins.concat(e.plugins||[]);process.env.NODE_ENV!=="production"&&(IT(t),Gg(e,n)),_T();var r=Object.assign({},e,{plugins:n}),i=ET(t);if(process.env.NODE_ENV!=="production"){var s=bo(r.content),o=i.length>1;sr(s&&o,["tippy() was passed an Element as the `content` prop, but more than","one tippy instance was created by this invocation. This means the","content element will only be appended to the last tippy instance.",`
|
134
134
|
|
135
135
|
`,"Instead, pass the .innerHTML of the element, or use a function that","returns a cloned version of the element instead.",`
|
136
136
|
|
137
137
|
`,`1) content: element.innerHTML
|
138
|
-
`,"2) content: () => element.cloneNode(true)"].join(" "))}var l=i.reduce(function(a,c){var u=c&&zT(c,r);return u&&a.push(u),a},[]);return bo(t)?l[0]:l}fi.defaultProps=Gt,fi.setDefaultProps=$T,fi.currentInput=$n,Object.assign({},yg,{effect:function(e){var n=e.state,r={popper:{position:n.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(n.elements.popper.style,r.popper),n.styles=r,n.elements.arrow&&Object.assign(n.elements.arrow.style,r.arrow)}});var VT={name:"sticky",defaultValue:!1,fn:function(e){var n=e.reference,r=e.popper;function i(){return e.popperInstance?e.popperInstance.state.elements.reference:n}function s(c){return e.props.sticky===!0||e.props.sticky===c}var o=null,l=null;function a(){var c=s("reference")?i().getBoundingClientRect():null,u=s("popper")?r.getBoundingClientRect():null;(c&&ey(o,c)||u&&ey(l,u))&&e.popperInstance&&e.popperInstance.update(),o=c,l=u,e.state.isMounted&&requestAnimationFrame(a)}return{onMount:function(){e.props.sticky&&a()}}}};function ey(t,e){return t&&e?t.top!==e.top||t.right!==e.right||t.bottom!==e.bottom||t.left!==e.left:!0}fi.setDefaultProps({render:Qg});class UT{constructor({editor:e,element:n,view:r,tippyOptions:i={},updateDelay:s=250,shouldShow:o}){this.preventHide=!1,this.shouldShow=({view:l,state:a,from:c,to:u})=>{const{doc:d,selection:f}=a,{empty:h}=f,p=!d.textBetween(c,u).length&&$u(a.selection),g=this.element.contains(document.activeElement);return!(!(l.hasFocus()||g)||h||p||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:l})=>{var a;if(this.preventHide){this.preventHide=!1;return}l!=null&&l.relatedTarget&&(!((a=this.element.parentNode)===null||a===void 0)&&a.contains(l.relatedTarget))||this.hide()},this.tippyBlurHandler=l=>{this.blurHandler({event:l})},this.handleDebouncedUpdate=(l,a)=>{const c=!(a!=null&&a.selection.eq(l.state.selection)),u=!(a!=null&&a.doc.eq(l.state.doc));!c&&!u||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(l,c,u,a)},this.updateDelay))},this.updateHandler=(l,a,c,u)=>{var d,f,h;const{state:p,composing:g}=l,{selection:v}=p;if(g||!a&&!c)return;this.createTooltip();const{ranges:S}=v,x=Math.min(...S.map(E=>E.$from.pos)),y=Math.max(...S.map(E=>E.$to.pos));if(!((d=this.shouldShow)===null||d===void 0?void 0:d.call(this,{editor:this.editor,view:l,state:p,oldState:u,from:x,to:y}))){this.hide();return}(f=this.tippy)===null||f===void 0||f.setProps({getReferenceClientRect:((h=this.tippyOptions)===null||h===void 0?void 0:h.getReferenceClientRect)||(()=>{if(fg(p.selection)){let E=l.nodeDOM(x);const T=E.dataset.nodeViewWrapper?E:E.querySelector("[data-node-view-wrapper]");if(T&&(E=T.firstChild),E)return E.getBoundingClientRect()}return zS(l,x,y)})}),this.show()},this.editor=e,this.element=n,this.view=r,this.updateDelay=s,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.tippyOptions=i,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:e}=this.editor.options,n=!!e.parentElement;this.tippy||!n||(this.tippy=fi(e,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"top",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",this.tippyBlurHandler))}update(e,n){const{state:r}=e,i=r.selection.$from.pos!==r.selection.$to.pos;if(this.updateDelay>0&&i){this.handleDebouncedUpdate(e,n);return}const s=!(n!=null&&n.selection.eq(e.state.selection)),o=!(n!=null&&n.doc.eq(e.state.doc));this.updateHandler(e,s,o,n)}show(){var e;(e=this.tippy)===null||e===void 0||e.show()}hide(){var e;(e=this.tippy)===null||e===void 0||e.hide()}destroy(){var e,n;!((e=this.tippy)===null||e===void 0)&&e.popper.firstChild&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),(n=this.tippy)===null||n===void 0||n.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const ty=t=>new je({key:typeof t.pluginKey=="string"?new We(t.pluginKey):t.pluginKey,view:e=>new UT({view:e,...t})});Ue.create({name:"bubbleMenu",addOptions(){return{element:null,tippyOptions:{},pluginKey:"bubbleMenu",updateDelay:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[ty({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,updateDelay:this.options.updateDelay,shouldShow:this.options.shouldShow})]:[]}});const WT=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},qT=({renderers:t})=>_.createElement(_.Fragment,null,Object.entries(t).map(([e,n])=>nn.createPortal(n.reactElement,n.element,e)));class KT extends _.Component{constructor(e){super(e),this.editorContentRef=_.createRef(),this.initialized=!1,this.state={renderers:{}}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const{editor:e}=this.props;if(e&&e.options.element){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.options.element.childNodes),e.setOptions({element:n}),e.contentComponent=this,e.createNodeViews(),this.initialized=!0}}maybeFlushSync(e){this.initialized?nn.flushSync(e):e()}setRenderer(e,n){this.maybeFlushSync(()=>{this.setState(({renderers:r})=>({renderers:{...r,[e]:n}}))})}removeRenderer(e){this.maybeFlushSync(()=>{this.setState(({renderers:n})=>{const r={...n};return delete r[e],{renderers:r}})})}componentWillUnmount(){const{editor:e}=this.props;if(!e||(this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null,!e.options.element.firstChild))return;const n=document.createElement("div");n.append(...e.options.element.childNodes),e.setOptions({element:n})}render(){const{editor:e,innerRef:n,...r}=this.props;return _.createElement(_.Fragment,null,_.createElement("div",{ref:WT(n,this.editorContentRef),...r}),_.createElement(qT,{renderers:this.state.renderers}))}}const JT=_.forwardRef((t,e)=>{const n=_.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return _.createElement(KT,{key:n,innerRef:e,...t})}),GT=_.memo(JT);class YT extends oE{constructor(){super(...arguments),this.contentComponent=null}}const ny=(t={},e=[])=>{const n=_.useRef(null),[,r]=_.useState({}),{onBeforeCreate:i,onBlur:s,onCreate:o,onDestroy:l,onFocus:a,onSelectionUpdate:c,onTransaction:u,onUpdate:d}=t,f=_.useRef(i),h=_.useRef(s),p=_.useRef(o),g=_.useRef(l),v=_.useRef(a),w=_.useRef(c),S=_.useRef(u),x=_.useRef(d);return _.useEffect(()=>{n.current&&(i&&(n.current.off("beforeCreate",f.current),n.current.on("beforeCreate",i),f.current=i),s&&(n.current.off("blur",h.current),n.current.on("blur",s),h.current=s),o&&(n.current.off("create",p.current),n.current.on("create",o),p.current=o),l&&(n.current.off("destroy",g.current),n.current.on("destroy",l),g.current=l),a&&(n.current.off("focus",v.current),n.current.on("focus",a),v.current=a),c&&(n.current.off("selectionUpdate",w.current),n.current.on("selectionUpdate",c),w.current=c),u&&(n.current.off("transaction",S.current),n.current.on("transaction",u),S.current=u),d&&(n.current.off("update",x.current),n.current.on("update",d),x.current=d))},[i,s,o,l,a,c,u,d,n.current]),_.useEffect(()=>{let y=!0;const C=new YT(t);return n.current=C,n.current.on("transaction",()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{y&&r({})})})}),()=>{y=!1,C.destroy()}},e),n.current},ry=_.createContext({editor:null});ry.Consumer;const XT=()=>_.useContext(ry),iy=t=>{const[e,n]=_.useState(null),{editor:r}=XT();return _.useEffect(()=>{var i;if(!e||!((i=t.editor)===null||i===void 0)&&i.isDestroyed||r!=null&&r.isDestroyed)return;const{pluginKey:s="bubbleMenu",editor:o,tippyOptions:l={},updateDelay:a,shouldShow:c=null}=t,u=o||r;if(!u){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const d=ty({updateDelay:a,editor:u,element:e,pluginKey:s,shouldShow:c,tippyOptions:l});return u.registerPlugin(d),()=>u.unregisterPlugin(s)},[t.editor,r,e]),_.createElement("div",{ref:n,className:t.className,style:{visibility:"hidden"}},t.children)},sy=_.createContext({onDragStart:void 0}),oy=()=>_.useContext(sy),ly=t=>{const e=t.as||"div",{nodeViewContentRef:n}=oy();return _.createElement(e,{...t,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...t.style}})},wo=_.forwardRef((t,e)=>{const{onDragStart:n}=oy(),r=t.as||"div";return _.createElement(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function ZT(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function QT(t){var e;return typeof t=="object"&&((e=t.$$typeof)===null||e===void 0?void 0:e.toString())==="Symbol(react.forward_ref)"}class ay{constructor(e,{editor:n,props:r={},as:i="div",className:s="",attrs:o}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=n,this.props=r,this.element=document.createElement(i),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),o&&Object.keys(o).forEach(l=>{this.element.setAttribute(l,o[l])}),this.render()}render(){var e,n;const r=this.component,i=this.props;(ZT(r)||QT(r))&&(i.ref=s=>{this.ref=s}),this.reactElement=_.createElement(r,{...i}),(n=(e=this.editor)===null||e===void 0?void 0:e.contentComponent)===null||n===void 0||n.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e,n;(n=(e=this.editor)===null||e===void 0?void 0:e.contentComponent)===null||n===void 0||n.removeRenderer(this.id)}}class eA extends aE{mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,selected:!1,extension:this.extension,getPos:()=>this.getPos(),updateAttributes:(s={})=>this.updateAttributes(s),deleteNode:()=>this.deleteNode()};if(!this.component.displayName){const s=o=>o.charAt(0).toUpperCase()+o.substring(1);this.component.displayName=s(this.extension.name)}const n=s=>{const o=this.component,l=this.onDragStart.bind(this),a=c=>{c&&this.contentDOMElement&&c.firstChild!==this.contentDOMElement&&c.appendChild(this.contentDOMElement)};return _.createElement(_.Fragment,null,_.createElement(sy.Provider,{value:{onDragStart:l,nodeViewContentRef:a}},_.createElement(o,{...s})))};n.displayName="ReactNodeView",this.node.isLeaf?this.contentDOMElement=null:this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement&&(this.contentDOMElement.style.whiteSpace="inherit");let r=this.node.isInline?"span":"div";this.options.as&&(r=this.options.as);const{className:i=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.renderer=new ay(n,{editor:this.editor,props:e,as:r,className:`node-${this.node.type.name} ${i}`.trim(),attrs:this.options.attrs})}get dom(){var e;if(this.renderer.element.firstElementChild&&!(!((e=this.renderer.element.firstElementChild)===null||e===void 0)&&e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:e,to:n}=this.editor.state.selection;if(e<=this.getPos()&&n>=this.getPos()+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,n){const r=i=>{this.renderer.updateProps(i)};if(e.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const i=this.node,s=this.decorations;return this.node=e,this.decorations=n,this.options.update({oldNode:i,oldDecorations:s,newNode:e,newDecorations:n,updateProps:()=>r({node:e,decorations:n})})}return e===this.node&&this.decorations===n||(this.node=e,this.decorations=n,r({node:e,decorations: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}}function hi(t,e){return n=>n.editor.contentComponent?new eA(t,n,e):{}}var cy={exports:{}};/*!
|
138
|
+
`,"2) content: () => element.cloneNode(true)"].join(" "))}var l=i.reduce(function(a,c){var u=c&&zT(c,r);return u&&a.push(u),a},[]);return bo(t)?l[0]:l}fi.defaultProps=Gt,fi.setDefaultProps=$T,fi.currentInput=$n,Object.assign({},gg,{effect:function(e){var n=e.state,r={popper:{position:n.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(n.elements.popper.style,r.popper),n.styles=r,n.elements.arrow&&Object.assign(n.elements.arrow.style,r.arrow)}});var VT={name:"sticky",defaultValue:!1,fn:function(e){var n=e.reference,r=e.popper;function i(){return e.popperInstance?e.popperInstance.state.elements.reference:n}function s(c){return e.props.sticky===!0||e.props.sticky===c}var o=null,l=null;function a(){var c=s("reference")?i().getBoundingClientRect():null,u=s("popper")?r.getBoundingClientRect():null;(c&&Qg(o,c)||u&&Qg(l,u))&&e.popperInstance&&e.popperInstance.update(),o=c,l=u,e.state.isMounted&&requestAnimationFrame(a)}return{onMount:function(){e.props.sticky&&a()}}}};function Qg(t,e){return t&&e?t.top!==e.top||t.right!==e.right||t.bottom!==e.bottom||t.left!==e.left:!0}fi.setDefaultProps({render:Zg});class UT{constructor({editor:e,element:n,view:r,tippyOptions:i={},updateDelay:s=250,shouldShow:o}){this.preventHide=!1,this.shouldShow=({view:l,state:a,from:c,to:u})=>{const{doc:d,selection:f}=a,{empty:h}=f,p=!d.textBetween(c,u).length&&Fu(a.selection),g=this.element.contains(document.activeElement);return!(!(l.hasFocus()||g)||h||p||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:l})=>{var a;if(this.preventHide){this.preventHide=!1;return}l!=null&&l.relatedTarget&&(!((a=this.element.parentNode)===null||a===void 0)&&a.contains(l.relatedTarget))||this.hide()},this.tippyBlurHandler=l=>{this.blurHandler({event:l})},this.handleDebouncedUpdate=(l,a)=>{const c=!(a!=null&&a.selection.eq(l.state.selection)),u=!(a!=null&&a.doc.eq(l.state.doc));!c&&!u||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(l,c,u,a)},this.updateDelay))},this.updateHandler=(l,a,c,u)=>{var d,f,h;const{state:p,composing:g}=l,{selection:v}=p;if(g||!a&&!c)return;this.createTooltip();const{ranges:S}=v,x=Math.min(...S.map(E=>E.$from.pos)),y=Math.max(...S.map(E=>E.$to.pos));if(!((d=this.shouldShow)===null||d===void 0?void 0:d.call(this,{editor:this.editor,view:l,state:p,oldState:u,from:x,to:y}))){this.hide();return}(f=this.tippy)===null||f===void 0||f.setProps({getReferenceClientRect:((h=this.tippyOptions)===null||h===void 0?void 0:h.getReferenceClientRect)||(()=>{if(dg(p.selection)){let E=l.nodeDOM(x);const T=E.dataset.nodeViewWrapper?E:E.querySelector("[data-node-view-wrapper]");if(T&&(E=T.firstChild),E)return E.getBoundingClientRect()}return zS(l,x,y)})}),this.show()},this.editor=e,this.element=n,this.view=r,this.updateDelay=s,o&&(this.shouldShow=o),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.tippyOptions=i,this.element.remove(),this.element.style.visibility="visible"}createTooltip(){const{element:e}=this.editor.options,n=!!e.parentElement;this.tippy||!n||(this.tippy=fi(e,{duration:0,getReferenceClientRect:null,content:this.element,interactive:!0,trigger:"manual",placement:"top",hideOnClick:"toggle",...this.tippyOptions}),this.tippy.popper.firstChild&&this.tippy.popper.firstChild.addEventListener("blur",this.tippyBlurHandler))}update(e,n){const{state:r}=e,i=r.selection.$from.pos!==r.selection.$to.pos;if(this.updateDelay>0&&i){this.handleDebouncedUpdate(e,n);return}const s=!(n!=null&&n.selection.eq(e.state.selection)),o=!(n!=null&&n.doc.eq(e.state.doc));this.updateHandler(e,s,o,n)}show(){var e;(e=this.tippy)===null||e===void 0||e.show()}hide(){var e;(e=this.tippy)===null||e===void 0||e.hide()}destroy(){var e,n;!((e=this.tippy)===null||e===void 0)&&e.popper.firstChild&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),(n=this.tippy)===null||n===void 0||n.destroy(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler)}}const ey=t=>new je({key:typeof t.pluginKey=="string"?new We(t.pluginKey):t.pluginKey,view:e=>new UT({view:e,...t})});Ue.create({name:"bubbleMenu",addOptions(){return{element:null,tippyOptions:{},pluginKey:"bubbleMenu",updateDelay:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[ey({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,updateDelay:this.options.updateDelay,shouldShow:this.options.shouldShow})]:[]}});const WT=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},qT=({renderers:t})=>O.createElement(O.Fragment,null,Object.entries(t).map(([e,n])=>nn.createPortal(n.reactElement,n.element,e)));class KT extends O.Component{constructor(e){super(e),this.editorContentRef=O.createRef(),this.initialized=!1,this.state={renderers:{}}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const{editor:e}=this.props;if(e&&e.options.element){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.options.element.childNodes),e.setOptions({element:n}),e.contentComponent=this,e.createNodeViews(),this.initialized=!0}}maybeFlushSync(e){this.initialized?nn.flushSync(e):e()}setRenderer(e,n){this.maybeFlushSync(()=>{this.setState(({renderers:r})=>({renderers:{...r,[e]:n}}))})}removeRenderer(e){this.maybeFlushSync(()=>{this.setState(({renderers:n})=>{const r={...n};return delete r[e],{renderers:r}})})}componentWillUnmount(){const{editor:e}=this.props;if(!e||(this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),e.contentComponent=null,!e.options.element.firstChild))return;const n=document.createElement("div");n.append(...e.options.element.childNodes),e.setOptions({element:n})}render(){const{editor:e,innerRef:n,...r}=this.props;return O.createElement(O.Fragment,null,O.createElement("div",{ref:WT(n,this.editorContentRef),...r}),O.createElement(qT,{renderers:this.state.renderers}))}}const JT=O.forwardRef((t,e)=>{const n=O.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return O.createElement(KT,{key:n,innerRef:e,...t})}),GT=O.memo(JT);class YT extends oE{constructor(){super(...arguments),this.contentComponent=null}}const ty=(t={},e=[])=>{const n=O.useRef(null),[,r]=O.useState({}),{onBeforeCreate:i,onBlur:s,onCreate:o,onDestroy:l,onFocus:a,onSelectionUpdate:c,onTransaction:u,onUpdate:d}=t,f=O.useRef(i),h=O.useRef(s),p=O.useRef(o),g=O.useRef(l),v=O.useRef(a),w=O.useRef(c),S=O.useRef(u),x=O.useRef(d);return O.useEffect(()=>{n.current&&(i&&(n.current.off("beforeCreate",f.current),n.current.on("beforeCreate",i),f.current=i),s&&(n.current.off("blur",h.current),n.current.on("blur",s),h.current=s),o&&(n.current.off("create",p.current),n.current.on("create",o),p.current=o),l&&(n.current.off("destroy",g.current),n.current.on("destroy",l),g.current=l),a&&(n.current.off("focus",v.current),n.current.on("focus",a),v.current=a),c&&(n.current.off("selectionUpdate",w.current),n.current.on("selectionUpdate",c),w.current=c),u&&(n.current.off("transaction",S.current),n.current.on("transaction",u),S.current=u),d&&(n.current.off("update",x.current),n.current.on("update",d),x.current=d))},[i,s,o,l,a,c,u,d,n.current]),O.useEffect(()=>{let y=!0;const C=new YT(t);return n.current=C,n.current.on("transaction",()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{y&&r({})})})}),()=>{y=!1,C.destroy()}},e),n.current},ny=O.createContext({editor:null});ny.Consumer;const XT=()=>O.useContext(ny),ry=t=>{const[e,n]=O.useState(null),{editor:r}=XT();return O.useEffect(()=>{var i;if(!e||!((i=t.editor)===null||i===void 0)&&i.isDestroyed||r!=null&&r.isDestroyed)return;const{pluginKey:s="bubbleMenu",editor:o,tippyOptions:l={},updateDelay:a,shouldShow:c=null}=t,u=o||r;if(!u){console.warn("BubbleMenu component is not rendered inside of an editor component or does not have editor prop.");return}const d=ey({updateDelay:a,editor:u,element:e,pluginKey:s,shouldShow:c,tippyOptions:l});return u.registerPlugin(d),()=>u.unregisterPlugin(s)},[t.editor,r,e]),O.createElement("div",{ref:n,className:t.className,style:{visibility:"hidden"}},t.children)},iy=O.createContext({onDragStart:void 0}),sy=()=>O.useContext(iy),oy=t=>{const e=t.as||"div",{nodeViewContentRef:n}=sy();return O.createElement(e,{...t,ref:n,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...t.style}})},wo=O.forwardRef((t,e)=>{const{onDragStart:n}=sy(),r=t.as||"div";return O.createElement(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function ZT(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function QT(t){var e;return typeof t=="object"&&((e=t.$$typeof)===null||e===void 0?void 0:e.toString())==="Symbol(react.forward_ref)"}class ly{constructor(e,{editor:n,props:r={},as:i="div",className:s="",attrs:o}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=e,this.editor=n,this.props=r,this.element=document.createElement(i),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),o&&Object.keys(o).forEach(l=>{this.element.setAttribute(l,o[l])}),this.render()}render(){var e,n;const r=this.component,i=this.props;(ZT(r)||QT(r))&&(i.ref=s=>{this.ref=s}),this.reactElement=O.createElement(r,{...i}),(n=(e=this.editor)===null||e===void 0?void 0:e.contentComponent)===null||n===void 0||n.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e,n;(n=(e=this.editor)===null||e===void 0?void 0:e.contentComponent)===null||n===void 0||n.removeRenderer(this.id)}}class eA extends aE{mount(){const e={editor:this.editor,node:this.node,decorations:this.decorations,selected:!1,extension:this.extension,getPos:()=>this.getPos(),updateAttributes:(s={})=>this.updateAttributes(s),deleteNode:()=>this.deleteNode()};if(!this.component.displayName){const s=o=>o.charAt(0).toUpperCase()+o.substring(1);this.component.displayName=s(this.extension.name)}const n=s=>{const o=this.component,l=this.onDragStart.bind(this),a=c=>{c&&this.contentDOMElement&&c.firstChild!==this.contentDOMElement&&c.appendChild(this.contentDOMElement)};return O.createElement(O.Fragment,null,O.createElement(iy.Provider,{value:{onDragStart:l,nodeViewContentRef:a}},O.createElement(o,{...s})))};n.displayName="ReactNodeView",this.node.isLeaf?this.contentDOMElement=null:this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement&&(this.contentDOMElement.style.whiteSpace="inherit");let r=this.node.isInline?"span":"div";this.options.as&&(r=this.options.as);const{className:i=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.renderer=new ly(n,{editor:this.editor,props:e,as:r,className:`node-${this.node.type.name} ${i}`.trim(),attrs:this.options.attrs})}get dom(){var e;if(this.renderer.element.firstElementChild&&!(!((e=this.renderer.element.firstElementChild)===null||e===void 0)&&e.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:e,to:n}=this.editor.state.selection;if(e<=this.getPos()&&n>=this.getPos()+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,n){const r=i=>{this.renderer.updateProps(i)};if(e.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const i=this.node,s=this.decorations;return this.node=e,this.decorations=n,this.options.update({oldNode:i,oldDecorations:s,newNode:e,newDecorations:n,updateProps:()=>r({node:e,decorations:n})})}return e===this.node&&this.decorations===n||(this.node=e,this.decorations=n,r({node:e,decorations: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}}function hi(t,e){return n=>n.editor.contentComponent?new eA(t,n,e):{}}var ay={exports:{}};/*!
|
139
139
|
Copyright (c) 2018 Jed Watson.
|
140
140
|
Licensed under the MIT License (MIT), see
|
141
141
|
http://jedwatson.github.io/classnames
|
142
|
-
*/(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var s="",o=0;o<arguments.length;o++){var l=arguments[o];l&&(s=i(s,r(l)))}return s}function r(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return n.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var o="";for(var l in s)e.call(s,l)&&s[l]&&(o=i(o,l));return o}function i(s,o){return o?s?s+" "+o:s+o:s}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(
|
142
|
+
*/(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var s="",o=0;o<arguments.length;o++){var l=arguments[o];l&&(s=i(s,r(l)))}return s}function r(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return n.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var o="";for(var l in s)e.call(s,l)&&s[l]&&(o=i(o,l));return o}function i(s,o){return o?s?s+" "+o:s+o:s}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(ay);var tA=ay.exports;const Se=Pc(tA);/**
|
143
143
|
* @license lucide-react v0.379.0 - ISC
|
144
144
|
*
|
145
145
|
* This source code is licensed under the ISC license.
|
146
146
|
* See the LICENSE file in the root directory of this source tree.
|
147
|
-
*/const nA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),
|
147
|
+
*/const nA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),cy=(...t)=>t.filter((e,n,r)=>!!e&&r.indexOf(e)===n).join(" ");/**
|
148
148
|
* @license lucide-react v0.379.0 - ISC
|
149
149
|
*
|
150
150
|
* This source code is licensed under the ISC license.
|
@@ -154,249 +154,234 @@ img.ProseMirror-separator {
|
|
154
154
|
*
|
155
155
|
* This source code is licensed under the ISC license.
|
156
156
|
* See the LICENSE file in the root directory of this source tree.
|
157
|
-
*/const iA=
|
157
|
+
*/const iA=O.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:i="",children:s,iconNode:o,...l},a)=>O.createElement("svg",{ref:a,...rA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:cy("lucide",i),...l},[...o.map(([c,u])=>O.createElement(c,u)),...Array.isArray(s)?s:[s]]));/**
|
158
158
|
* @license lucide-react v0.379.0 - ISC
|
159
159
|
*
|
160
160
|
* This source code is licensed under the ISC license.
|
161
161
|
* See the LICENSE file in the root directory of this source tree.
|
162
|
-
*/const
|
162
|
+
*/const ge=(t,e)=>{const n=O.forwardRef(({className:r,...i},s)=>O.createElement(iA,{ref:s,iconNode:e,className:cy(`lucide-${nA(t)}`,r),...i}));return n.displayName=`${t}`,n};/**
|
163
163
|
* @license lucide-react v0.379.0 - ISC
|
164
164
|
*
|
165
165
|
* This source code is licensed under the ISC license.
|
166
166
|
* See the LICENSE file in the root directory of this source tree.
|
167
|
-
*/const sA=
|
167
|
+
*/const sA=ge("AlignCenter",[["line",{x1:"21",x2:"3",y1:"6",y2:"6",key:"1fp77t"}],["line",{x1:"17",x2:"7",y1:"12",y2:"12",key:"rsh8ii"}],["line",{x1:"19",x2:"5",y1:"18",y2:"18",key:"1t0tuv"}]]);/**
|
168
168
|
* @license lucide-react v0.379.0 - ISC
|
169
169
|
*
|
170
170
|
* This source code is licensed under the ISC license.
|
171
171
|
* See the LICENSE file in the root directory of this source tree.
|
172
|
-
*/const
|
172
|
+
*/const cd=ge("AlignLeft",[["line",{x1:"21",x2:"3",y1:"6",y2:"6",key:"1fp77t"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}],["line",{x1:"17",x2:"3",y1:"18",y2:"18",key:"1awlsn"}]]);/**
|
173
173
|
* @license lucide-react v0.379.0 - ISC
|
174
174
|
*
|
175
175
|
* This source code is licensed under the ISC license.
|
176
176
|
* See the LICENSE file in the root directory of this source tree.
|
177
|
-
*/const oA=
|
177
|
+
*/const oA=ge("AlignRight",[["line",{x1:"21",x2:"3",y1:"6",y2:"6",key:"1fp77t"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}],["line",{x1:"21",x2:"7",y1:"18",y2:"18",key:"1g9eri"}]]);/**
|
178
178
|
* @license lucide-react v0.379.0 - ISC
|
179
179
|
*
|
180
180
|
* This source code is licensed under the ISC license.
|
181
181
|
* See the LICENSE file in the root directory of this source tree.
|
182
|
-
*/const
|
182
|
+
*/const uy=ge("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
|
183
183
|
* @license lucide-react v0.379.0 - ISC
|
184
184
|
*
|
185
185
|
* This source code is licensed under the ISC license.
|
186
186
|
* See the LICENSE file in the root directory of this source tree.
|
187
|
-
*/const lA=
|
187
|
+
*/const lA=ge("Baseline",[["path",{d:"M4 20h16",key:"14thso"}],["path",{d:"m6 16 6-12 6 12",key:"1b4byz"}],["path",{d:"M8 12h8",key:"1wcyev"}]]);/**
|
188
188
|
* @license lucide-react v0.379.0 - ISC
|
189
189
|
*
|
190
190
|
* This source code is licensed under the ISC license.
|
191
191
|
* See the LICENSE file in the root directory of this source tree.
|
192
|
-
*/const
|
192
|
+
*/const dy=ge("Bold",[["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"}]]);/**
|
193
193
|
* @license lucide-react v0.379.0 - ISC
|
194
194
|
*
|
195
195
|
* This source code is licensed under the ISC license.
|
196
196
|
* See the LICENSE file in the root directory of this source tree.
|
197
|
-
*/const zl=
|
197
|
+
*/const zl=ge("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
|
198
198
|
* @license lucide-react v0.379.0 - ISC
|
199
199
|
*
|
200
200
|
* This source code is licensed under the ISC license.
|
201
201
|
* See the LICENSE file in the root directory of this source tree.
|
202
|
-
*/const Vl=
|
202
|
+
*/const Vl=ge("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
|
203
203
|
* @license lucide-react v0.379.0 - ISC
|
204
204
|
*
|
205
205
|
* This source code is licensed under the ISC license.
|
206
206
|
* See the LICENSE file in the root directory of this source tree.
|
207
|
-
*/const aA=
|
207
|
+
*/const aA=ge("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/**
|
208
208
|
* @license lucide-react v0.379.0 - ISC
|
209
209
|
*
|
210
210
|
* This source code is licensed under the ISC license.
|
211
211
|
* See the LICENSE file in the root directory of this source tree.
|
212
|
-
*/const Ul=
|
212
|
+
*/const Ul=ge("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/**
|
213
213
|
* @license lucide-react v0.379.0 - ISC
|
214
214
|
*
|
215
215
|
* This source code is licensed under the ISC license.
|
216
216
|
* See the LICENSE file in the root directory of this source tree.
|
217
|
-
*/const
|
217
|
+
*/const fy=ge("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);/**
|
218
218
|
* @license lucide-react v0.379.0 - ISC
|
219
219
|
*
|
220
220
|
* This source code is licensed under the ISC license.
|
221
221
|
* See the LICENSE file in the root directory of this source tree.
|
222
|
-
*/const cA=
|
222
|
+
*/const cA=ge("Columns3",[["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"}]]);/**
|
223
223
|
* @license lucide-react v0.379.0 - ISC
|
224
224
|
*
|
225
225
|
* This source code is licensed under the ISC license.
|
226
226
|
* See the LICENSE file in the root directory of this source tree.
|
227
|
-
*/const uA=
|
227
|
+
*/const uA=ge("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/**
|
228
228
|
* @license lucide-react v0.379.0 - ISC
|
229
229
|
*
|
230
230
|
* This source code is licensed under the ISC license.
|
231
231
|
* See the LICENSE file in the root directory of this source tree.
|
232
|
-
*/const dA=
|
232
|
+
*/const dA=ge("GripHorizontal",[["circle",{cx:"12",cy:"9",r:"1",key:"124mty"}],["circle",{cx:"19",cy:"9",r:"1",key:"1ruzo2"}],["circle",{cx:"5",cy:"9",r:"1",key:"1a8b28"}],["circle",{cx:"12",cy:"15",r:"1",key:"1e56xg"}],["circle",{cx:"19",cy:"15",r:"1",key:"1a92ep"}],["circle",{cx:"5",cy:"15",r:"1",key:"5r1jwy"}]]);/**
|
233
233
|
* @license lucide-react v0.379.0 - ISC
|
234
234
|
*
|
235
235
|
* This source code is licensed under the ISC license.
|
236
236
|
* See the LICENSE file in the root directory of this source tree.
|
237
|
-
*/const fA=
|
237
|
+
*/const fA=ge("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]);/**
|
238
238
|
* @license lucide-react v0.379.0 - ISC
|
239
239
|
*
|
240
240
|
* This source code is licensed under the ISC license.
|
241
241
|
* See the LICENSE file in the root directory of this source tree.
|
242
|
-
*/const
|
242
|
+
*/const ud=ge("Heading1",[["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"}]]);/**
|
243
243
|
* @license lucide-react v0.379.0 - ISC
|
244
244
|
*
|
245
245
|
* This source code is licensed under the ISC license.
|
246
246
|
* See the LICENSE file in the root directory of this source tree.
|
247
|
-
*/const
|
247
|
+
*/const dd=ge("Heading2",[["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"}]]);/**
|
248
248
|
* @license lucide-react v0.379.0 - ISC
|
249
249
|
*
|
250
250
|
* This source code is licensed under the ISC license.
|
251
251
|
* See the LICENSE file in the root directory of this source tree.
|
252
|
-
*/const
|
252
|
+
*/const fd=ge("Heading3",[["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"}]]);/**
|
253
253
|
* @license lucide-react v0.379.0 - ISC
|
254
254
|
*
|
255
255
|
* This source code is licensed under the ISC license.
|
256
256
|
* See the LICENSE file in the root directory of this source tree.
|
257
|
-
*/const
|
257
|
+
*/const hy=ge("Highlighter",[["path",{d:"m9 11-6 6v3h9l3-3",key:"1a3l36"}],["path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4",key:"14a9rk"}]]);/**
|
258
258
|
* @license lucide-react v0.379.0 - ISC
|
259
259
|
*
|
260
260
|
* This source code is licensed under the ISC license.
|
261
261
|
* See the LICENSE file in the root directory of this source tree.
|
262
|
-
*/const hA=
|
262
|
+
*/const hA=ge("ImagePlus",[["path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7",key:"31hg93"}],["line",{x1:"16",x2:"22",y1:"5",y2:"5",key:"ez7e4s"}],["line",{x1:"19",x2:"19",y1:"2",y2:"8",key:"1gkr8c"}],["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"}]]);/**
|
263
263
|
* @license lucide-react v0.379.0 - ISC
|
264
264
|
*
|
265
265
|
* This source code is licensed under the ISC license.
|
266
266
|
* See the LICENSE file in the root directory of this source tree.
|
267
|
-
*/const pA=
|
267
|
+
*/const pA=ge("Image",[["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"}]]);/**
|
268
268
|
* @license lucide-react v0.379.0 - ISC
|
269
269
|
*
|
270
270
|
* This source code is licensed under the ISC license.
|
271
271
|
* See the LICENSE file in the root directory of this source tree.
|
272
|
-
*/const
|
272
|
+
*/const py=ge("Italic",[["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"}]]);/**
|
273
273
|
* @license lucide-react v0.379.0 - ISC
|
274
274
|
*
|
275
275
|
* This source code is licensed under the ISC license.
|
276
276
|
* See the LICENSE file in the root directory of this source tree.
|
277
|
-
*/const
|
277
|
+
*/const my=ge("Link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);/**
|
278
278
|
* @license lucide-react v0.379.0 - ISC
|
279
279
|
*
|
280
280
|
* This source code is licensed under the ISC license.
|
281
281
|
* See the LICENSE file in the root directory of this source tree.
|
282
|
-
*/const
|
282
|
+
*/const gy=ge("ListChecks",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);/**
|
283
283
|
* @license lucide-react v0.379.0 - ISC
|
284
284
|
*
|
285
285
|
* This source code is licensed under the ISC license.
|
286
286
|
* See the LICENSE file in the root directory of this source tree.
|
287
|
-
*/const xo=
|
287
|
+
*/const xo=ge("ListOrdered",[["line",{x1:"10",x2:"21",y1:"6",y2:"6",key:"76qw6h"}],["line",{x1:"10",x2:"21",y1:"12",y2:"12",key:"16nom4"}],["line",{x1:"10",x2:"21",y1:"18",y2:"18",key:"u3jurt"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);/**
|
288
288
|
* @license lucide-react v0.379.0 - ISC
|
289
289
|
*
|
290
290
|
* This source code is licensed under the ISC license.
|
291
291
|
* See the LICENSE file in the root directory of this source tree.
|
292
|
-
*/const
|
292
|
+
*/const hd=ge("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/**
|
293
293
|
* @license lucide-react v0.379.0 - ISC
|
294
294
|
*
|
295
295
|
* This source code is licensed under the ISC license.
|
296
296
|
* See the LICENSE file in the root directory of this source tree.
|
297
|
-
*/const mA=
|
297
|
+
*/const mA=ge("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
|
298
298
|
* @license lucide-react v0.379.0 - ISC
|
299
299
|
*
|
300
300
|
* This source code is licensed under the ISC license.
|
301
301
|
* See the LICENSE file in the root directory of this source tree.
|
302
|
-
*/const gA=
|
302
|
+
*/const gA=ge("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);/**
|
303
303
|
* @license lucide-react v0.379.0 - ISC
|
304
304
|
*
|
305
305
|
* This source code is licensed under the ISC license.
|
306
306
|
* See the LICENSE file in the root directory of this source tree.
|
307
|
-
*/const yA=
|
307
|
+
*/const yA=ge("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
|
308
308
|
* @license lucide-react v0.379.0 - ISC
|
309
309
|
*
|
310
310
|
* This source code is licensed under the ISC license.
|
311
311
|
* See the LICENSE file in the root directory of this source tree.
|
312
|
-
*/const bA=
|
312
|
+
*/const bA=ge("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
|
313
313
|
* @license lucide-react v0.379.0 - ISC
|
314
314
|
*
|
315
315
|
* This source code is licensed under the ISC license.
|
316
316
|
* See the LICENSE file in the root directory of this source tree.
|
317
|
-
*/const vA=
|
317
|
+
*/const vA=ge("RemoveFormatting",[["path",{d:"M4 7V4h16v3",key:"9msm58"}],["path",{d:"M5 20h6",key:"1h6pxn"}],["path",{d:"M13 4 8 20",key:"kqq6aj"}],["path",{d:"m15 15 5 5",key:"me55sn"}],["path",{d:"m20 15-5 5",key:"11p7ol"}]]);/**
|
318
318
|
* @license lucide-react v0.379.0 - ISC
|
319
319
|
*
|
320
320
|
* This source code is licensed under the ISC license.
|
321
321
|
* See the LICENSE file in the root directory of this source tree.
|
322
|
-
*/const
|
322
|
+
*/const yy=ge("SquareCheckBig",[["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}],["path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11",key:"1jnkn4"}]]);/**
|
323
323
|
* @license lucide-react v0.379.0 - ISC
|
324
324
|
*
|
325
325
|
* This source code is licensed under the ISC license.
|
326
326
|
* See the LICENSE file in the root directory of this source tree.
|
327
|
-
*/const
|
327
|
+
*/const by=ge("Strikethrough",[["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"}]]);/**
|
328
328
|
* @license lucide-react v0.379.0 - ISC
|
329
329
|
*
|
330
330
|
* This source code is licensed under the ISC license.
|
331
331
|
* See the LICENSE file in the root directory of this source tree.
|
332
|
-
*/const
|
332
|
+
*/const wA=ge("Table",[["path",{d:"M12 3v18",key:"108xh3"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}]]);/**
|
333
333
|
* @license lucide-react v0.379.0 - ISC
|
334
334
|
*
|
335
335
|
* This source code is licensed under the ISC license.
|
336
336
|
* See the LICENSE file in the root directory of this source tree.
|
337
|
-
*/const
|
337
|
+
*/const xA=ge("Telescope",[["path",{d:"m10.065 12.493-6.18 1.318a.934.934 0 0 1-1.108-.702l-.537-2.15a1.07 1.07 0 0 1 .691-1.265l13.504-4.44",key:"k4qptu"}],["path",{d:"m13.56 11.747 4.332-.924",key:"19l80z"}],["path",{d:"m16 21-3.105-6.21",key:"7oh9d"}],["path",{d:"M16.485 5.94a2 2 0 0 1 1.455-2.425l1.09-.272a1 1 0 0 1 1.212.727l1.515 6.06a1 1 0 0 1-.727 1.213l-1.09.272a2 2 0 0 1-2.425-1.455z",key:"m7xp4m"}],["path",{d:"m6.158 8.633 1.114 4.456",key:"74o979"}],["path",{d:"m8 21 3.105-6.21",key:"1fvxut"}],["circle",{cx:"12",cy:"13",r:"2",key:"1c1ljs"}]]);/**
|
338
338
|
* @license lucide-react v0.379.0 - ISC
|
339
339
|
*
|
340
340
|
* This source code is licensed under the ISC license.
|
341
341
|
* See the LICENSE file in the root directory of this source tree.
|
342
|
-
*/const
|
342
|
+
*/const pd=ge("TextQuote",[["path",{d:"M17 6H3",key:"16j9eg"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 18H8",key:"1wfozv"}],["path",{d:"M3 12v6",key:"fv4c87"}]]);/**
|
343
343
|
* @license lucide-react v0.379.0 - ISC
|
344
344
|
*
|
345
345
|
* This source code is licensed under the ISC license.
|
346
346
|
* See the LICENSE file in the root directory of this source tree.
|
347
|
-
*/const
|
347
|
+
*/const vy=ge("Text",[["path",{d:"M17 6.1H3",key:"wptmhv"}],["path",{d:"M21 12.1H3",key:"1j38uz"}],["path",{d:"M15.1 18H3",key:"1nb16a"}]]);/**
|
348
348
|
* @license lucide-react v0.379.0 - ISC
|
349
349
|
*
|
350
350
|
* This source code is licensed under the ISC license.
|
351
351
|
* See the LICENSE file in the root directory of this source tree.
|
352
|
-
*/const
|
352
|
+
*/const kA=ge("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/**
|
353
353
|
* @license lucide-react v0.379.0 - ISC
|
354
354
|
*
|
355
355
|
* This source code is licensed under the ISC license.
|
356
356
|
* See the LICENSE file in the root directory of this source tree.
|
357
|
-
*/const
|
357
|
+
*/const wy=ge("Twitter",[["path",{d:"M22 4s-.7 2.1-2 3.4c1.6 10-9.4 17.3-18 11.6 2.2.1 4.4-.6 6-2C3 15.5.5 9.6 3 5c2.2 2.6 5.6 4.1 9 4-.9-4.2 4-6.6 7-3.8 1.1 0 3-1.2 3-1.2z",key:"pff0z6"}]]);/**
|
358
358
|
* @license lucide-react v0.379.0 - ISC
|
359
359
|
*
|
360
360
|
* This source code is licensed under the ISC license.
|
361
361
|
* See the LICENSE file in the root directory of this source tree.
|
362
|
-
*/const
|
362
|
+
*/const CA=ge("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/**
|
363
363
|
* @license lucide-react v0.379.0 - ISC
|
364
364
|
*
|
365
365
|
* This source code is licensed under the ISC license.
|
366
366
|
* See the LICENSE file in the root directory of this source tree.
|
367
|
-
*/const
|
367
|
+
*/const xy=ge("Underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);/**
|
368
368
|
* @license lucide-react v0.379.0 - ISC
|
369
369
|
*
|
370
370
|
* This source code is licensed under the ISC license.
|
371
371
|
* See the LICENSE file in the root directory of this source tree.
|
372
|
-
*/const xy=he("Twitter",[["path",{d:"M22 4s-.7 2.1-2 3.4c1.6 10-9.4 17.3-18 11.6 2.2.1 4.4-.6 6-2C3 15.5.5 9.6 3 5c2.2 2.6 5.6 4.1 9 4-.9-4.2 4-6.6 7-3.8 1.1 0 3-1.2 3-1.2z",key:"pff0z6"}]]);/**
|
373
|
-
|
374
|
-
*
|
375
|
-
* This source code is licensed under the ISC license.
|
376
|
-
* See the LICENSE file in the root directory of this source tree.
|
377
|
-
*/const TA=he("Type",[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]]);/**
|
378
|
-
* @license lucide-react v0.379.0 - ISC
|
379
|
-
*
|
380
|
-
* This source code is licensed under the ISC license.
|
381
|
-
* See the LICENSE file in the root directory of this source tree.
|
382
|
-
*/const ky=he("Underline",[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]]);/**
|
383
|
-
* @license lucide-react v0.379.0 - ISC
|
384
|
-
*
|
385
|
-
* This source code is licensed under the ISC license.
|
386
|
-
* See the LICENSE file in the root directory of this source tree.
|
387
|
-
*/const Cy=he("Youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]),AA=({editor:t,isOpen:e,setIsOpen:n})=>{const r=[{name:"Text",icon:wy,command:()=>t.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>t.isActive("paragraph")&&!t.isActive("bulletList")&&!t.isActive("orderedList")},{name:"Heading 1",icon:dd,command:()=>t.chain().focus().toggleHeading({level:1}).run(),isActive:()=>t.isActive("heading",{level:1})},{name:"Heading 2",icon:fd,command:()=>t.chain().focus().toggleHeading({level:2}).run(),isActive:()=>t.isActive("heading",{level:2})},{name:"Heading 3",icon:hd,command:()=>t.chain().focus().toggleHeading({level:3}).run(),isActive:()=>t.isActive("heading",{level:3})},{name:"To-do List",icon:by,command:()=>t.chain().focus().toggleTaskList().run(),isActive:()=>t.isActive("taskItem")},{name:"Bullet List",icon:xo,command:()=>t.chain().focus().toggleBulletList().run(),isActive:()=>t.isActive("bulletList")},{name:"Numbered List",icon:xo,command:()=>t.chain().focus().toggleOrderedList().run(),isActive:()=>t.isActive("orderedList")},{name:"Quote",icon:md,command:()=>t.chain().focus().toggleNode("paragraph","paragraph").toggleBlockquote().run(),isActive:()=>t.isActive("blockquote")},{name:"Code",icon:Ul,command:()=>t.chain().focus().toggleCode().run(),isActive:()=>t.isActive("code")}],i=r.filter(s=>s.isActive()).pop()??{name:"Multiple"};return O.jsxs("div",{className:"relative h-full",children:[O.jsxs("button",{className:"flex h-full items-center gap-1 p-2 text-sm font-medium text-stone-600 hover:bg-stone-100 active:bg-stone-200",onClick:()=>n(!e),children:[O.jsx("span",{children:i==null?void 0:i.name}),O.jsx(Vl,{className:"h-4 w-4"})]}),e&&O.jsx("section",{className:"fixed top-full z-[99999] mt-1 flex w-48 flex-col overflow-hidden rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1",children:r.map((s,o)=>O.jsxs("button",{onClick:()=>{s.command(),n(!1)},className:Se("flex items-center justify-between rounded-sm px-2 py-1 text-sm text-stone-600 hover:bg-stone-100",{"text-blue-600":s.isActive()}),children:[O.jsxs("div",{className:"flex items-center space-x-2",children:[O.jsx("div",{className:"rounded-sm border border-stone-200 p-1",children:O.jsx(s.icon,{className:"h-3 w-3"})}),O.jsx("span",{children:s.name})]}),i.name===s.name&&O.jsx(zl,{className:"h-4 w-4"})]},o))})]})},MA=({editor:t,isOpen:e,setIsOpen:n})=>{const r=[{name:"Default",color:"#000000"},{name:"Purple",color:"#9333EA"},{name:"Red",color:"#E00000"},{name:"Blue",color:"#2563EB"},{name:"Green",color:"#008A00"},{name:"Orange",color:"#FFA500"},{name:"Pink",color:"#BA4081"},{name:"Gray",color:"#A8A29E"}],i=r.find(({color:s})=>t.isActive("textStyle",{color:s}));return O.jsxs("div",{className:"",children:[O.jsxs("button",{className:"flex h-[100%] items-center gap-1 p-2 text-sm font-medium text-stone-600 hover:bg-stone-100 active:bg-stone-200",onClick:()=>n(!e),children:[O.jsx("span",{style:{color:(i==null?void 0:i.color)||"#000000"},children:"A"}),O.jsx(Vl,{className:"h-4 w-4 "})]}),e&&O.jsx("section",{className:"fixed top-full z-[99999] mt-1 flex w-48 flex-col overflow-hidden rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1",children:r.map(({name:s,color:o},l)=>O.jsxs("button",{onClick:()=>{t.chain().focus().setColor(o).run(),n(!1)},className:Se("flex items-center justify-between rounded-sm px-2 py-1 text-sm text-stone-600 hover:bg-stone-100",{"text-blue-600":t.isActive("textStyle",{color:o})}),children:[O.jsxs("div",{className:"flex items-center space-x-2",children:[O.jsx("div",{className:"rounded-sm border border-stone-200 px-1 py-px font-medium",style:{color:o},children:"A"}),O.jsx("span",{children:s})]}),t.isActive("textStyle",{color:o})&&O.jsx(zl,{className:"h-4 w-4"})]},l))})]})};var pe=(t=>(t[t.NONE=0]="NONE",t[t.HEADING=1]="HEADING",t[t.TEXT_COLOR=2]="TEXT_COLOR",t[t.HIGHLIGHT=3]="HIGHLIGHT",t[t.LINK=4]="LINK",t[t.FONT_FAMILY=5]="FONT_FAMILY",t[t.ALIGNMENT=6]="ALIGNMENT",t[t.LIST=7]="LIST",t))(pe||{});function OA(t){const[e,n]=_.useState(t),r=_.useRef(null),i=s=>{r&&r.current&&!r.current.contains(s.target)&&n(0)};return _.useEffect(()=>(document.addEventListener("click",i,!0),()=>{document.removeEventListener("click",i,!0)}),[]),{ref:r,toolVisibilty:e,setToolVisibility:n}}const Wl=new We("upload-image"),_A=()=>new je({key:Wl,state:{init(){return He.empty},apply(t,e){e=e.map(t.mapping,t.doc);const n=t.getMeta(this);if(n&&n.add){const{id:r,pos:i,src:s}=n.add,o=document.createElement("div");o.setAttribute("class","img-placeholder");const l=document.createElement("img");l.setAttribute("class","rounded-lg border border-stone-200"),l.src=s,o.appendChild(l);const a=ut.widget(i+1,o,{id:r});e=e.add(t.doc,[a])}else n&&n.remove&&(e=e.remove(e.find(void 0,void 0,r=>r.id==n.remove.id)));return e}},props:{decorations(t){return this.getState(t)}}});function NA(t,e){const r=Wl.getState(t).find(null,null,i=>i.id==e);return r.length?r[0].from:null}function Sy(t,e,n){if(t.type.includes("image/")){if(t.size>1024*1024){console.log("failed");return}}else{console.log("file is not an image");return}const r={},i=e.state.tr;i.selection.empty||i.deleteSelection();const s=new FileReader;s.readAsDataURL(t),s.onload=()=>{i.setMeta(Wl,{add:{id:r,pos:n,src:s.result}}),e.dispatch(i)},DA(t).then(o=>{const{schema:l}=e.state,a=NA(e.state,r);if(a==null)return;const c=typeof o=="object"?s.result:o,u=l.nodes.resizableMedia.create({src:c,"media-type":"img"}),d=e.state.tr.replaceWith(a-2,a+u.nodeSize,u).setMeta(Wl,{remove:{id:r}});e.dispatch(d)})}const DA=t=>new Promise(e=>{const n=new FileReader;n.readAsDataURL(t),n.onload=()=>e(n.result)}),RA=async t=>{const e=new FileReader;if(e.readAsDataURL(t),t.size>1024*1024)throw e.abort(),console.log("should be less than 1 mb"),new Error("Image too large");return await new Promise(r=>{e.onload=()=>{r(e.result)}})},Ey=[{title:"Trebuchet MS",value:"Trebuchet MS, sans-serif",command:t=>{t.chain().focus().setFontFamily("Trebuchet MS, sans-serif").run()}},{title:"Verdana",value:"Verdana, Geneva, sans-serif",command:t=>{t.chain().focus().setFontFamily("Verdana, Geneva, sans-serif").run()}},{title:"Georgia",value:"Georgia, serif",command:t=>{t.chain().focus().setFontFamily("Georgia, serif").run()}},{title:"Arial",value:"Arial, Helvetica, sans-serif",command:t=>{t.chain().focus().setFontFamily("Arial, Helvetica, sans-serif").run()}},{title:"Comic Sans MS",value:"Comic Sans MS, Comic Sans",command:t=>{t.chain().focus().setFontFamily("Comic Sans MS, Comic Sans").run()}},{title:"Impact",value:"Impact, Charcoal, sans-serif",command:t=>{t.chain().focus().setFontFamily("Impact, Charcoal, sans-serif").run()}},{title:"Palatino",value:"Palatino Linotype, Book Antiqua, Palatino, serif",command:t=>{t.chain().focus().setFontFamily("Palatino Linotype, Book Antiqua, Palatino, serif").run()}},{title:"Lucida Grande",value:"Lucida Sans Unicode, Lucida Grande, sans-serif",command:t=>{t.chain().focus().setFontFamily("Lucida Sans Unicode, Lucida Grande, sans-serif").run()}},{title:"Serif",value:"serif",command:t=>{t.chain().focus().setFontFamily("serif").run()}},{title:"Monospace",value:"monospace",command:t=>{t.chain().focus().setFontFamily("monospace").run()}},{title:"Cursive",value:"cursive",command:t=>{t.chain().focus().setFontFamily("cursive").run()}}],Ty=({editor:t})=>{const{ref:e,toolVisibilty:n,setToolVisibility:r}=OA(pe.NONE);return{toolbar:[{icon:O.jsx(lA,{size:20}),title:"Text Color",onClick:()=>r(pe.TEXT_COLOR),isActive:n===pe.TEXT_COLOR},{icon:O.jsx(py,{size:20}),title:"Highlight",onClick:()=>r(pe.HIGHLIGHT),isActive:n===pe.HIGHLIGHT},null,{icon:O.jsx(fy,{size:20}),title:"Bold",onClick:()=>t==null?void 0:t.chain().focus().toggleBold().run(),isActive:t==null?void 0:t.isActive("bold")},{icon:O.jsx(my,{size:20}),title:"Italic",onClick:()=>t==null?void 0:t.chain().focus().toggleItalic().run(),isActive:t==null?void 0:t.isActive("italic")},{icon:O.jsx(ky,{size:20}),title:"Underlined",onClick:()=>t==null?void 0:t.chain().focus().toggleUnderline().run(),isActive:t==null?void 0:t.isActive("underline")},{icon:O.jsx(vy,{size:20}),title:"Strikethrough",onClick:()=>t==null?void 0:t.chain().focus().toggleStrike().run(),isActive:t==null?void 0:t.isActive("strike")},null,{icon:O.jsx(pd,{size:20}),title:"List",onClick:()=>{t==null||t.chain().focus().toggleBulletList().run(),r(pe.NONE)},isActive:n===pe.LIST},{icon:O.jsx(xo,{size:20}),title:"Ordered List",onClick:()=>{t==null||t.chain().focus().toggleOrderedList().run(),r(pe.NONE)},isActive:n===pe.LIST},{icon:O.jsx(yy,{size:20}),title:"To-do List",onClick:()=>{t==null||t.chain().focus().toggleTaskList().run(),r(pe.NONE)},isActive:n===pe.LIST},{icon:O.jsx(ud,{size:20}),title:"Alignment",onClick:()=>r(pe.ALIGNMENT),isActive:n===pe.ALIGNMENT},{icon:O.jsx(md,{size:20}),title:"Quote",onClick:()=>t==null?void 0:t.chain().focus().toggleBlockquote().run(),isActive:t==null?void 0:t.isActive("blockquote")},null,{icon:O.jsx(hA,{size:20}),title:"Upload Image",onClick:()=>{t==null||t.chain().focus().deleteRange(t.state.selection).run();const s=document.createElement("input");s.type="file",s.accept="image/*",s.onchange=async()=>{var o;if((o=s.files)!=null&&o.length){const l=s.files[0],a=t.view.state.selection.from;Sy(l,t.view,a)}},s.click()},isActive:!1},{icon:O.jsx(gy,{size:20}),title:"Link",onClick:()=>r(pe.LINK),isActive:t==null?void 0:t.isActive("link")},{icon:O.jsx(Ul,{size:20}),title:"Code",onClick:()=>t==null?void 0:t.chain().focus().toggleCodeBlock().run(),isActive:t==null?void 0:t.isActive("codeBlock")}],toolRef:e,toolVisibilty:n,setToolVisibility:r}},Ay=({editor:t,setVisibility:e,elementRef:n})=>{const r=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}];return O.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-[50px] flex flex-wrap left-[20%] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-elevation-3 transition-all",children:[O.jsx(dy,{className:"cursor-pointer",onClick:()=>{t.chain().focus().unsetHighlight().run(),e(pe.NONE)}}),r.map(i=>O.jsx("div",{onClick:()=>{t.chain().focus().toggleHighlight({color:i.color}).run(),e(pe.NONE)},className:Se("w-6 drop-shadow rounded-full flex items-center justify-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6",i.code),children:O.jsx(zl,{size:14,className:Se(t.isActive("highlight",{color:i.color})?"visible":"invisible")})},i.color))]})},LA=({elementRef:t,editor:e,setToolVisibility:n})=>O.jsx("div",{ref:t,className:Se("z-50 h-auto absolute top-[50px] left-0 max-h-[330px] w-48 overflow-y-auto scroll-smooth bg-white px-1 py-2 shadow-elevation-3 transition-all animate-in fade-in slide-in-from-top-1"),children:Ey.map(r=>O.jsx("button",{onClick:()=>{r.command(e),n(pe.NONE)},style:{fontFamily:r.title},className:Se("flex w-full items-center space-x-2 rounded px-2 py-1 text-left text-sm color-text-default",e.isActive("textStyle",{fontFamily:r.value})?"color-bg-brand hover:color-bg-brand-hover":"hover:bg-[#f2f2f2]"),children:O.jsx("p",{className:"font-medium",children:r.title})},r.title))}),My=({elementRef:t,editor:e,setToolVisibility:n})=>O.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-[50px] right-[25%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-elevation-3 transition-all",children:[O.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("left").run(),n(pe.NONE)},className:Se("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer",e.isActive({textAlign:"left"})?"color-bg-brand hover:color-bg-brand-hover":"hover:bg-[#f2f2f2]"),children:O.jsx(ud,{})}),O.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("center").run(),n(pe.NONE)},className:Se("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer",e.isActive({textAlign:"center"})?"color-bg-brand hover:color-bg-brand-hover":"hover:bg-[#f2f2f2]"),children:O.jsx(sA,{})}),O.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("right").run(),n(pe.NONE)},className:Se("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer",e.isActive({textAlign:"right"})?"color-bg-brand hover:color-bg-brand-hover":"hover:bg-[#f2f2f2]"),children:O.jsx(oA,{})})]}),IA=({elementRef:t,editor:e,setToolVisibility:n})=>O.jsxs("div",{ref:t,className:Se("z-50 h-auto absolute gap-2 top-[50px] right-[30%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-elevation-3 transition-all"),children:[O.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"unordered list",children:O.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleBulletList().run(),n(pe.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("bulletList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:O.jsx(pd,{size:20})})}),O.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"ordered list",children:O.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleOrderedList().run(),n(pe.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("orderedList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:O.jsx(xo,{size:20})})}),O.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"to-do list",children:O.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleTaskList().run(),n(pe.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("taskList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:O.jsx(yy,{size:20})})})]}),Oy=({elementRef:t,editor:e,setToolVisibility:n,bubbleMenu:r,setIsLinkPopupOpen:i})=>{const[s,o]=_.useState(e.getAttributes("link").href),l=()=>{if(s===null)return;if(s===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}let a=s;!s.startsWith("http://")&&!s.startsWith("https://")&&(a="https://"+s);try{a.match(/^((http|https):\/\/)?([w|W]{3}\.)+[a-zA-Z0-9\-\.]{3,}\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?$/)&&e.chain().focus().extendMarkRange("link").setLink({href:a}).run()}catch{console.error("Invalid URL");return}e.chain().focus().extendMarkRange("link").setLink({href:a}).run(),n(pe.NONE),r&&i&&i(!1)};return O.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-[50px] items-center flex right-[10%] max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white p-2 shadow-elevation-3 transition-all",children:[O.jsx("input",{onChange:a=>o(a.target.value),className:"shadow-none border-[1px]",placeholder:"Add link here",value:s}),O.jsx("div",{className:"h-full flex items-center",children:O.jsx("button",{onClick:()=>l(),className:"min-w-fit",children:"Apply"})})]})},PA=({editor:t,setVisibility:e,elementRef:n})=>{const r=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}];return O.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-[50px] flex flex-wrap left-[100px] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-elevation-3 transition-all",children:[O.jsx(dy,{className:"cursor-pointer",onClick:()=>{t.chain().focus().unsetColor().run(),e(pe.NONE)}}),r.map(i=>O.jsx("div",{onClick:()=>{t.chain().focus().setColor(i.color).run(),e(pe.NONE)},className:Se("w-6 drop-shadow rounded-full flex justify-center items-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6",i.code),children:O.jsx(zl,{size:14,className:Se(t.isActive("textStyle",{color:i.color})?"visible":"invisible")})},i.color))]})},FA=({editor:t,setVisibility:e,elementRef:n})=>{const r=[{title:"Text",description:"Normal",icon:O.jsx(TA,{size:20}),command:i=>i.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>t.isActive("paragraph")&&!t.isActive("bulletList")&&!t.isActive("orderedList")},{title:"Heading 1",description:"Big",icon:O.jsx(dd,{size:20}),command:i=>{i.chain().focus().toggleHeading({level:1}).run()},isActive:()=>t.isActive("heading",{level:1})},{title:"Heading 2",description:"Medium",icon:O.jsx(fd,{size:20}),command:i=>{i.chain().focus().toggleHeading({level:2}).run()},isActive:()=>t.isActive("heading",{level:2})},{title:"Heading 3",description:"Small",icon:O.jsx(hd,{size:20}),command:i=>{i.chain().focus().toggleHeading({level:3}).run()},isActive:()=>t.isActive("heading",{level:3})}];return O.jsx("div",{ref:n,className:Se("absolute top-[50px] z-50 mt-1 flex w-48 flex-col overflow-hidden rounded bg-white p-1 shadow-elevation-3 animate-in fade-in slide-in-from-top-1","left-0"),children:r.map(i=>O.jsxs("button",{onClick:()=>{i.command(t),e(pe.NONE)},className:Se("flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm color-text-default",{"color-bg-brand hover:color-bg-brand-hover":i.isActive(),"hover:bg-[#f2f2f2]":!i.isActive()}),children:[O.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded bg-white",children:i.icon}),O.jsxs("div",{children:[O.jsx("p",{className:"font-medium",children:i.title}),O.jsxs("p",{className:"text-xs text-stone-500",children:[" ",i.description," "]})]})]},i.title))})},$A=t=>{const e=[{name:"Bold",isActive:()=>t.editor.isActive("bold"),command:()=>t.editor.chain().focus().toggleBold().run(),icon:O.jsx(fy,{size:20})},{name:"Italic",isActive:()=>t.editor.isActive("italic"),command:()=>t.editor.chain().focus().toggleItalic().run(),icon:O.jsx(my,{size:20})},{name:"Underline",isActive:()=>t.editor.isActive("underline"),command:()=>t.editor.chain().focus().toggleUnderline().run(),icon:O.jsx(ky,{size:20})},{name:"Strikethrough",isActive:()=>t.editor.isActive("strike"),command:()=>t.editor.chain().focus().toggleStrike().run(),icon:O.jsx(vy,{size:20})},{name:"Alignment",isActive:()=>d===pe.ALIGNMENT,command:()=>u(pe.ALIGNMENT),icon:O.jsx(ud,{size:20})},{name:"Code",isActive:()=>t.editor.isActive("codeBlock"),command:()=>t.editor.chain().focus().toggleCodeBlock().run(),icon:O.jsx(Ul,{size:20})},{name:"Link",isActive:()=>t.editor.isActive("link"),command:()=>a(!l),icon:O.jsx(gy,{size:20})}],n={...t,shouldShow:({state:f,editor:h})=>{const{selection:p}=f,{empty:g}=p;return!(h.isActive("image")||g||fg(p))},tippyOptions:{moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",onHidden:()=>{i(!1),o(!1),a(!1)}}},[r,i]=_.useState(!1),[s,o]=_.useState(!1),[l,a]=_.useState(!1),{toolRef:c,setToolVisibility:u,toolVisibilty:d}=Ty({editor:t.editor});return O.jsxs(iy,{...n,className:"flex gap-1 overflow-hidden rounded-[12px] h-[52px] min-w-[472px] w-full py-2 px-4 bg-white items-center shadow-elevation-3",children:[O.jsx(AA,{editor:t.editor,isOpen:r,setIsOpen:()=>{i(!r),o(!1)}}),O.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"}),e.map((f,h)=>O.jsxs("div",{className:"flex items-center gap-1",children:[O.jsx("button",{onClick:f.command,className:Se("min-w-fit w-8 h-8 px-2",{"color-bg-brand":f.isActive()}),children:f.icon}),(h===4||h===6)&&O.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"})]},h)),O.jsx(MA,{editor:t.editor,isOpen:s,setIsOpen:()=>{o(!s),i(!1)}}),O.jsx("button",{onClick:()=>u(pe.HIGHLIGHT),className:Se("min-w-fit w-8 h-8 px-2",{"color-bg-brand":d===pe.HIGHLIGHT}),children:O.jsx(py,{size:20})}),d===pe.ALIGNMENT&&O.jsx(My,{setToolVisibility:u,editor:t.editor,elementRef:c}),l&&O.jsx(Oy,{setToolVisibility:u,editor:t.editor,elementRef:c,bubbleMenu:!0,setIsLinkPopupOpen:a}),d===pe.HIGHLIGHT&&O.jsx(Ay,{setVisibility:u,editor:t.editor,elementRef:c})]})};function BA(){const t=["a","b","c","d","e","f","0","1","2","3","4","5","6","7","8","9"];let e=[];for(let n=0;n<36;n++)n===8||n===13||n===18||n===23?e[n]="-":e[n]=t[Math.ceil(Math.random()*t.length-1)];return e.join("")}var jA=BA;const HA=Fc(jA),_y=ze.create({name:"column",content:"dBlock+",isolating:!0,addAttributes(){return{position:{default:"",parseHTML:t=>t.getAttribute("data-position"),renderHTML:t=>({"data-position":t.position})}}},renderHTML({HTMLAttributes:t}){return["div",Ce(t,{"data-type":"column"}),0]},parseHTML(){return[{tag:'div[data-type="column"]'}]}}),zA=(t,e)=>Array.from({length:t},(n,r)=>e(r)),ql=({type:t,content:e})=>e?{type:t,content:e}:{type:t},VA=({content:t})=>ql({type:"paragraph",content:t}),Ny=({content:t})=>ql({type:"dBlock",content:t}),Dy=({content:t})=>ql({type:"column",content:t}),Ry=({content:t})=>ql({type:"columns",content:t}),Ly=t=>{const e=[Ny({content:[VA({})]})];return zA(t,()=>Dy({content:e}))},Iy=(t,e)=>{for(let n=t.depth;n>0;n--){const r=t.node(n),i=n>0?t.before(n):0,s=t.start(n);if(e({node:r,pos:i,start:s}))return{start:s,depth:n,node:r,pos:i}}throw Error("no ancestor found")};class Kl extends ue{constructor(n){const{$from:r,$to:i}=n;super(r,i);vr(this,"_$from");vr(this,"_$to");this._$from=r,this._$to=i}get $from(){return this._$from}get $to(){return this._$to}map(){return this}content(){return this.$from.doc.slice(this.from,this.to,!0)}eq(n){return n instanceof Kl&&n.anchor==this.anchor}toJSON(){return{type:"column",from:this.from,to:this.to}}expandSelection(n){var a;const r=({pos:c,node:u})=>u.type.name===_y.name?!0:n.resolve(c).depth<=0,{pos:i}=Iy(this.$from,r);this._$from=n.resolve(i);const{pos:s,node:o}=Iy(this.$to,r);this._$to=n.resolve(s+o.nodeSize),((a=this.getFirstNode())==null?void 0:a.type.name)===Jl.name&&(this._$from=n.resolve(this.$from.pos+2),this._$to=n.resolve(this.$to.pos+2));const l=this;l.$anchor=this._$from,l.$head=this._$to,l.ranges=[new eu(this._$from,this._$to)]}static create(n,r,i){const s=n.resolve(r),o=n.resolve(i),l=new ce(s,o);return new Kl(l)}getFirstNode(){return this.content().content.firstChild}}var pi=(t=>(t.AlignLeft="align-left",t.AlignRight="align-right",t.AlignCenter="align-center",t))(pi||{});const Jl=ze.create({name:"columns",group:"columns",content:"column{2,}",defining:!0,draggable:!0,isolating:!0,addAttributes(){return{layout:{default:"align-center"}}},addCommands(){return{unsetColumns:()=>({tr:t,dispatch:e})=>{try{if(!e)return;const n=t.selection.$from,i=Bu(n,({node:a})=>!this.options.nestedColumns&&a.type==this.type?!0:a.type==this.type);if(i===void 0)return;let s=[];i.node.descendants((a,c,u)=>{(u==null?void 0:u.type.name)===Jl.name&&s.push(a)}),s=s.reverse().filter(a=>a.content.size>0);const o=t.doc.resolve(i.pos),l=new se(o);return t=t.setSelection(l),s.forEach(a=>t=t.insert(i.pos,a)),t=t.deleteSelection(),e(t)}catch(n){console.error(n)}},setColumns:(t,e=!1)=>({tr:n,dispatch:r})=>{try{const{doc:i,selection:s}=n;if(!r){console.log("no dispatch");return}const o=new Kl(s);o.expandSelection(i);const{openStart:l,openEnd:a}=o.content();if(l!==a){console.warn("failed depth check");return}let c;if(e){const h=o.content().toJSON(),p=Dy(h),g=Ly(t-1);c=Ry({content:[p,...g]})}else{const h=Ly(t);c=Ry({content:h})}const u=i.type.schema.nodeFromJSON(Ny({content:[c]}));if(u===null)return;const d=o.$anchor.parent.type;if(!(h=>!(!h.contentMatch.matchType(this.type)||!this.options.nestedColumns&&h.name===Jl.name))(d)){console.warn("content not allowed");return}return n=n.setSelection(o),n=n.replaceSelectionWith(u,!1),r(n)}catch(i){console.error(i)}},setLayout:t=>({commands:e})=>e.updateAttributes("columns",{layout:t})}},renderHTML({HTMLAttributes:t}){return["div",{"data-type":"columns",class:`layout-${t.layout}`},0]},parseHTML(){return[{tag:'div[data-type="columns"]'}]}}),UA=(t,e)=>{const{view:n,state:{selection:{from:r}}}=t,i=document.querySelectorAll(".has-focus"),s=i.length,l=i[s-1];if(l&&l.getAttribute("data-type")&&l.getAttribute("data-type")===e||l&&l.classList&&l.classList.contains(e))return l;const a=n.domAtPos(r).node;let c=a;for(c.tagName||(c=a.parentElement);c&&!(c.getAttribute("data-type")&&c.getAttribute("data-type")===e)&&!c.classList.contains(e);)c=c.parentElement;return c},gd=_.forwardRef(({children:t,className:e,withShadow:n=!0,withBorder:r=!0,...i},s)=>{const o=Se(e,"bg-white rounded-md",n?"shadow-md":"",r?"border border-neutral-200":"");return O.jsx("div",{className:o,...i,ref:s,children:t})});gd.displayName="Surface";const Gl=_.forwardRef(({active:t,buttonSize:e="medium",children:n,disabled:r,variant:i="primary",className:s,activeClassname:o,...l},a)=>{const c=Se("flex group items-center justify-center border border-transparent gap-2 text-sm font-semibold rounded disabled:opacity-50 whitespace-nowrap",i==="primary"&&Se("text-white bg-black border-black dark:text-black dark:bg-white dark:border-white",!r&&!t&&"hover:bg-neutral-800 active:bg-neutral-900 dark:hover:bg-neutral-200 dark:active:bg-neutral-300",t&&Se("bg-neutral-900 dark:bg-neutral-300",o)),i==="secondary"&&Se("text-neutral-900 dark:text-white",!r&&!t&&"hover:bg-neutral-100 active:bg-neutral-200 dark:hover:bg-neutral-900 dark:active:bg-neutral-800",t&&"bg-neutral-200 dark:bg-neutral-800"),i==="tertiary"&&Se("bg-neutral-50 text-neutral-900 dark:bg-neutral-900 dark:text-white dark:border-neutral-900",!r&&!t&&"hover:bg-neutral-100 active:bg-neutral-200 dark:hover:bg-neutral-800 dark:active:bg-neutral-700",t&&Se("bg-neutral-200 dark:bg-neutral-800",o)),i==="ghost"&&Se("bg-transparent border-transparent text-neutral-500",!r&&!t&&"hover:bg-black/5 hover:text-neutral-700 active:bg-black/10 active:text-neutral-800 ",t&&Se("bg-black/10 text-neutral-800 ",o)),e==="medium"&&"py-2 px-3",e==="small"&&"py-1 px-2",e==="icon"&&"w-8 h-8",e==="iconSmall"&&"w-6 h-6",s);return O.jsx("button",{ref:a,disabled:r,className:c,...l,children:n})});Gl.displayName="Button";const Py=({content:t,children:e})=>{const[n,r]=_.useState(!1);return O.jsxs("div",{className:"relative inline-block",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[e,n&&O.jsx("div",{className:"absolute z-10 p-2 mt-2 text-sm text-white bg-gray-800 rounded shadow-lg",children:t})]})},Fy=_.forwardRef(({shouldShowContent:t=!0,children:e,isVertical:n=!1,className:r,...i},s)=>{const o=Se("text-black inline-flex h-full leading-none gap-0.5",n?"flex-col p-2":"flex-row p-1 items-center",r);return t?t&&O.jsx(gd,{className:o,...i,ref:s,children:e}):null});Fy.displayName="Toolbar";const $y=_.forwardRef(({horizontal:t,className:e,...n},r)=>{const i=Se("bg-neutral-200",t?"w-full min-w-[1.5rem] h-[1px] my-1 first:mt-0 last:mt-0":"h-full min-h-[1.5rem] w-[1px] mx-1 first:ml-0 last:mr-0",e);return O.jsx("div",{className:i,ref:r,...n})});$y.displayName="Toolbar.Divider";const By=_.forwardRef(({children:t,buttonSize:e="icon",variant:n="ghost",className:r,tooltip:i,activeClassname:s,...o},l)=>{const a=Se("gap-1 min-w-[2rem] px-2 w-auto",r),c=O.jsx(Gl,{activeClassname:s,className:a,variant:n,buttonSize:e,ref:l,...o,children:t});return i?O.jsx(Py,{content:i,children:c}):c});By.displayName="ToolbarButton";const ko={Wrapper:Fy,Divider:$y,Button:By},WA=({editor:t,appendTo:e})=>{const n=_.useCallback(()=>{const l=UA(t,"columns");return(l==null?void 0:l.getBoundingClientRect())||new DOMRect(-1e3,-1e3,0,0)},[t]),r=_.useCallback(()=>t.isActive("columns"),[t]),i=_.useCallback(()=>{t.chain().focus().setLayout(pi.AlignLeft).run()},[t]),s=_.useCallback(()=>{t.chain().focus().setLayout(pi.AlignRight).run()},[t]),o=_.useCallback(()=>{t.chain().focus().setLayout(pi.AlignCenter).run()},[t]);return O.jsx(iy,{editor:t,pluginKey:`columnsMenu-${HA()}`,shouldShow:r,updateDelay:0,tippyOptions:{offset:[0,8],popperOptions:{modifiers:[{name:"flip",enabled:!1}]},getReferenceClientRect:n,moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",appendTo:()=>e==null?void 0:e.current,plugins:[VT],sticky:"popper"},children:O.jsxs(ko.Wrapper,{children:[O.jsx(ko.Button,{tooltip:"Align left",active:t.isActive("columns",{layout:pi.AlignLeft}),onClick:i,children:O.jsx(gA,{size:20})}),O.jsx(ko.Button,{tooltip:"Align center",active:t.isActive("columns",{layout:pi.AlignCenter}),onClick:o,children:O.jsx(hy,{size:20})}),O.jsx(ko.Button,{tooltip:"Align right",active:t.isActive("columns",{layout:pi.AlignRight}),onClick:s,children:O.jsx(yA,{size:20})})]})})},jy=_.createContext(null),Yl=()=>_.useContext(jy),qA=({children:t,isPreviewMode:e})=>O.jsx(jy.Provider,{value:e,children:t}),Hy=({height:t,width:e})=>O.jsx("span",{className:"flex items-center justify-center ",children:O.jsx("span",{className:`${e?`w-${e}`:"w-8"} ${t?`h-${t}`:"h-8"} border-4 border-t-4 border-t-[#ccc] border-gray-500 rounded-full animate-spin`})}),KA=({editor:t})=>{var s;const{toolRef:e,toolVisibilty:n,setToolVisibility:r,toolbar:i}=Ty({editor:t});return O.jsxs("div",{className:"w-fit bg-transparent px-4 items-center h-16 flex gap-1 justify-center",children:[O.jsxs("button",{className:"bg-transparent flex items-center gap-2 min-w-[55px]",onClick:()=>r(pe.FONT_FAMILY),children:[O.jsx("span",{className:"text-sm",children:((s=Ey.find(o=>t==null?void 0:t.isActive("textStyle",{fontFamily:o.value})))==null?void 0:s.title)||"Font"}),O.jsx(Vl,{size:16})]}),O.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"}),O.jsxs("button",{className:"bg-transparent gap-2 flex items-center min-w-[55px]",onClick:()=>r(pe.HEADING),children:[O.jsx("span",{className:"text-sm",children:t!=null&&t.isActive("heading",{level:1})?"Heading 1":t!=null&&t.isActive("heading",{level:2})?"Heading 2":t!=null&&t.isActive("heading",{level:3})?"Heading 3":"Text"}),O.jsx(Vl,{size:16})]}),O.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"}),i.map(o=>o?O.jsx("div",{className:"tooltip tooltip-bottom","data-tip":o.title,children:O.jsx("span",{onClick:()=>o.onClick(),className:Se("rounded-lg w-8 h-8 p-1 flex cursor-pointer justify-center items-center",o.isActive?"bg-yellow-300":"hover:bg-[#f2f2f2]"),children:typeof o.icon=="string"?O.jsx("img",{src:o.icon,className:"w-4"}):o.icon})},o.title):O.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"})),n===pe.FONT_FAMILY&&O.jsx(LA,{setToolVisibility:r,editor:t,elementRef:e}),n===pe.HEADING&&O.jsx(FA,{setVisibility:r,editor:t,elementRef:e}),n===pe.TEXT_COLOR&&O.jsx(PA,{setVisibility:r,editor:t,elementRef:e}),n===pe.HIGHLIGHT&&O.jsx(Ay,{setVisibility:r,editor:t,elementRef:e}),n===pe.ALIGNMENT&&O.jsx(My,{setToolVisibility:r,editor:t,elementRef:e}),n===pe.LIST&&O.jsx(IA,{setToolVisibility:r,editor:t,elementRef:e}),n===pe.LINK&&O.jsx(Oy,{setToolVisibility:r,editor:t,elementRef:e})]})},Lt=()=>new Map,yd=t=>{const e=Lt();return t.forEach((n,r)=>{e.set(r,n)}),e},Vt=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},JA=(t,e)=>{const n=[];for(const[r,i]of t)n.push(e(i,r));return n},GA=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},or=()=>new Set,bd=t=>t[t.length-1],YA=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},lr=Array.from,XA=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},vd=Array.isArray;class wd{constructor(){this._observers=Lt()}on(e,n){return Vt(this._observers,e,or).add(n),n}once(e,n){const r=(...i)=>{this.off(e,r),n(...i)};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 lr((this._observers.get(e)||Lt()).values()).forEach(r=>r(...n))}destroy(){this._observers=Lt()}}class xd{constructor(){this._observers=Lt()}on(e,n){Vt(this._observers,e,or).add(n)}once(e,n){const r=(...i)=>{this.off(e,r),n(...i)};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 lr((this._observers.get(e)||Lt()).values()).forEach(r=>r(...n))}destroy(){this._observers=Lt()}}const wn=Math.floor,Xl=Math.abs,ZA=Math.log10,Ir=(t,e)=>t<e?t:e,ar=(t,e)=>t>e?t:e,zy=t=>t!==0?t<0:1/t<0,Bn=Date.now,QA=1200,e2=2500,Zl=3e4,kd=t=>{if(t.shouldConnect&&t.ws===null){const e=new WebSocket(t.url),n=t.binaryType;let r=null;n&&(e.binaryType=n),t.ws=e,t.connecting=!0,t.connected=!1,e.onmessage=o=>{t.lastMessageReceived=Bn();const l=o.data,a=typeof l=="string"?JSON.parse(l):l;a&&a.type==="pong"&&(clearTimeout(r),r=setTimeout(s,Zl/2)),t.emit("message",[a,t])};const i=o=>{t.ws!==null&&(t.ws=null,t.connecting=!1,t.connected?(t.connected=!1,t.emit("disconnect",[{type:"disconnect",error:o},t])):t.unsuccessfulReconnects++,setTimeout(kd,Ir(ZA(t.unsuccessfulReconnects+1)*QA,e2),t)),clearTimeout(r)},s=()=>{t.ws===e&&t.send({type:"ping"})};e.onclose=()=>i(null),e.onerror=o=>i(o),e.onopen=()=>{t.lastMessageReceived=Bn(),t.connecting=!1,t.connected=!0,t.unsuccessfulReconnects=0,t.emit("connect",[{type:"connect"},t]),r=setTimeout(s,Zl/2)}}};class t2 extends xd{constructor(e,{binaryType:n}={}){super(),this.url=e,this.ws=null,this.binaryType=n||null,this.connected=!1,this.connecting=!1,this.unsuccessfulReconnects=0,this.lastMessageReceived=0,this.shouldConnect=!0,this._checkInterval=setInterval(()=>{this.connected&&Zl<Bn()-this.lastMessageReceived&&this.ws.close()},Zl/2),kd(this)}send(e){this.ws&&this.ws.send(JSON.stringify(e))}destroy(){clearInterval(this._checkInterval),this.disconnect(),super.destroy()}disconnect(){this.shouldConnect=!1,this.ws!==null&&this.ws.close()}connect(){this.shouldConnect=!0,!this.connected&&this.ws===null&&kd(this)}}const xn=t=>new Error(t),kn=()=>{throw xn("Method unimplemented")},cn=()=>{throw xn("Unexpected case")},Vy=1,Uy=2,Cd=4,Sd=8,Co=32,cr=64,Yt=128,Ql=31,Ed=63,mi=127,n2=2147483647,r2=crypto.getRandomValues.bind(crypto),Wy=Math.random,qy=()=>r2(new Uint32Array(1))[0],i2=t=>t[wn(Wy()*t.length)],s2="10000000-1000-4000-8000"+-1e11,Ky=()=>s2.replace(/[018]/g,t=>(t^qy()&15>>t/4).toString(16)),Jy=Number.MAX_SAFE_INTEGER,o2=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&wn(t)===t),l2=String.fromCharCode,a2=t=>t.toLowerCase(),c2=/^\s*/g,u2=t=>t.replace(c2,""),d2=/([A-Z])/g,Gy=(t,e)=>u2(t.replace(d2,n=>`${e}${a2(n)}`)),f2=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.codePointAt(i);return r},So=typeof TextEncoder<"u"?new TextEncoder:null,Td=So?t=>So.encode(t):f2;let Eo=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Eo&&Eo.decode(new Uint8Array).length===1&&(Eo=null);class To{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const gt=()=>new To,h2=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},qe=t=>{const e=new Uint8Array(h2(t));let n=0;for(let r=0;r<t.bufs.length;r++){const i=t.bufs[r];e.set(i,n),n+=i.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},p2=(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(ar(n,e)*2),t.cpos=0)},yt=(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},Ao=yt,ae=(t,e)=>{for(;e>mi;)yt(t,Yt|mi&e),e=wn(e/128);yt(t,mi&e)},Ad=(t,e)=>{const n=zy(e);for(n&&(e=-e),yt(t,(e>Ed?Yt:0)|(n?cr:0)|Ed&e),e=wn(e/64);e>0;)yt(t,(e>mi?Yt:0)|mi&e),e=wn(e/128)},Md=new Uint8Array(3e4),m2=Md.length/3,g2=(t,e)=>{if(e.length<m2){const n=So.encodeInto(e,Md).written||0;ae(t,n);for(let r=0;r<n;r++)yt(t,Md[r])}else Ze(t,Td(e))},y2=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;ae(t,r);for(let i=0;i<r;i++)yt(t,n.codePointAt(i))},jn=So&&So.encodeInto?g2:y2,ea=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=Ir(n-r,e.length),s=e.length-i;t.cbuf.set(e.subarray(0,i),r),t.cpos+=i,s>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(ar(n*2,s)),t.cbuf.set(e.subarray(i)),t.cpos=s)},Ze=(t,e)=>{ae(t,e.byteLength),ea(t,e)},Od=(t,e)=>{p2(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},b2=(t,e)=>Od(t,4).setFloat32(0,e,!1),v2=(t,e)=>Od(t,8).setFloat64(0,e,!1),w2=(t,e)=>Od(t,8).setBigInt64(0,e,!1),Yy=new DataView(new ArrayBuffer(4)),x2=t=>(Yy.setFloat32(0,t),Yy.getFloat32(0)===t),ns=(t,e)=>{switch(typeof e){case"string":yt(t,119),jn(t,e);break;case"number":o2(e)&&Xl(e)<=n2?(yt(t,125),Ad(t,e)):x2(e)?(yt(t,124),b2(t,e)):(yt(t,123),v2(t,e));break;case"bigint":yt(t,122),w2(t,e);break;case"object":if(e===null)yt(t,126);else if(vd(e)){yt(t,117),ae(t,e.length);for(let n=0;n<e.length;n++)ns(t,e[n])}else if(e instanceof Uint8Array)yt(t,116),Ze(t,e);else{yt(t,118);const n=Object.keys(e);ae(t,n.length);for(let r=0;r<n.length;r++){const i=n[r];jn(t,i),ns(t,e[i])}}break;case"boolean":yt(t,e?120:121);break;default:yt(t,127)}};class Xy extends To{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&ae(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const Zy=t=>{t.count>0&&(Ad(t.encoder,t.count===1?t.s:-t.s),t.count>1&&ae(t.encoder,t.count-2))};class ta{constructor(){this.encoder=new To,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Zy(this),this.count=1,this.s=e)}toUint8Array(){return Zy(this),qe(this.encoder)}}const Qy=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);Ad(t.encoder,e),t.count>1&&ae(t.encoder,t.count-2)}};class _d{constructor(){this.encoder=new To,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Qy(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Qy(this),qe(this.encoder)}}class k2{constructor(){this.sarr=[],this.s="",this.lensE=new ta}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 To;return this.sarr.push(this.s),this.s="",jn(e,this.sarr.join("")),ea(e,this.lensE.toUint8Array()),qe(e)}}const e0=xn("Unexpected end of array"),t0=xn("Integer out of Range");class na{constructor(e){this.arr=e,this.pos=0}}const Hn=t=>new na(t),C2=t=>t.pos!==t.arr.length,S2=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},bt=t=>S2(t,me(t)),gi=t=>t.arr[t.pos++],me=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const i=t.arr[t.pos++];if(e=e+(i&mi)*n,n*=128,i<Yt)return e;if(e>Jy)throw t0}throw e0},Nd=t=>{let e=t.arr[t.pos++],n=e&Ed,r=64;const i=(e&cr)>0?-1:1;if(!(e&Yt))return i*n;const s=t.arr.length;for(;t.pos<s;){if(e=t.arr[t.pos++],n=n+(e&mi)*r,r*=128,e<Yt)return i*n;if(n>Jy)throw t0}throw e0},ur=Eo?t=>Eo.decode(bt(t)):t=>{let e=me(t);if(e===0)return"";{let n=String.fromCodePoint(gi(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(gi(t));else for(;e>0;){const r=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(n))}},Dd=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},E2=[t=>{},t=>null,Nd,t=>Dd(t,4).getFloat32(0,!1),t=>Dd(t,8).getFloat64(0,!1),t=>Dd(t,8).getBigInt64(0,!1),t=>!1,t=>!0,ur,t=>{const e=me(t),n={};for(let r=0;r<e;r++){const i=ur(t);n[i]=rs(t)}return n},t=>{const e=me(t),n=[];for(let r=0;r<e;r++)n.push(rs(t));return n},bt],rs=t=>E2[127-gi(t)](t);class n0 extends na{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),C2(this)?this.count=me(this)+1:this.count=-1),this.count--,this.s}}class ra extends na{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Nd(this);const e=zy(this.s);this.count=1,e&&(this.s=-this.s,this.count=me(this)+2)}return this.count--,this.s}}class Rd extends na{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=Nd(this),n=e&1;this.diff=wn(e/2),this.count=1,n&&(this.count=me(this)+2)}return this.s+=this.diff,this.count--,this.s}}class T2{constructor(e){this.decoder=new ra(e),this.str=ur(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 r0=t=>t===void 0?null:t;class A2{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let i0=new A2,Ld=!0;try{typeof localStorage<"u"&&localStorage&&(i0=localStorage,Ld=!1)}catch{}const s0=i0,M2=t=>Ld||addEventListener("storage",t),O2=t=>Ld||removeEventListener("storage",t),_2=Object.assign,Id=Object.keys,N2=(t,e)=>{for(const n in t)e(t[n],n)},o0=t=>Id(t).length,l0=t=>Id(t).length,D2=t=>{for(const e in t)return!1;return!0},R2=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},a0=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),L2=(t,e)=>t===e||l0(t)===l0(e)&&R2(t,(n,r)=>(n!==void 0||a0(e,r))&&e[r]===n),Pd=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&Pd(t,e,n+1)}},I2=()=>{},P2=t=>t,F2=(t,e)=>t===e,Mo=(t,e)=>{if(t==null||e==null)return F2(t,e);if(t.constructor!==e.constructor)return!1;if(t===e)return!0;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)||!Mo(t.get(n),e.get(n)))return!1;break}case Object:if(o0(t)!==o0(e))return!1;for(const n in t)if(!a0(t,n)||!Mo(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(!Mo(t[n],e[n]))return!1;break;default:return!1}return!0},$2=(t,e)=>e.includes(t),is=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Fd=typeof window<"u"&&typeof document<"u"&&!is;let zn;const B2=()=>{if(zn===void 0)if(is){zn=Lt();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&zn.set(e,""),e=r):e!==null&&(zn.set(e,r),e=null)}e!==null&&zn.set(e,"")}else typeof location=="object"?(zn=Lt(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");zn.set(`--${Gy(e,"-")}`,n),zn.set(`-${Gy(e,"-")}`,n)}})):zn=Lt();return zn},$d=t=>B2().has(t),ia=t=>r0(is?process.env[t.toUpperCase().replaceAll("-","_")]:s0.getItem(t));(t=>$d("--"+t)||ia(t)!==null)("production");const c0=is&&$2(process.env.FORCE_COLOR,["true","1","2"]),j2=!$d("--no-colors")&&(!is||process.stdout.isTTY||c0)&&(!is||$d("--color")||c0||ia("COLORTERM")!==null||(ia("TERM")||"").includes("color"));class H2{constructor(e,n){this.left=e,this.right=n}}const dr=(t,e)=>new H2(t,e),z2=typeof document<"u"?document:{};typeof DOMParser<"u"&&new DOMParser;const V2=t=>JA(t,(e,n)=>`${n}:${e};`).join(""),U2=JSON.stringify,W2=(t=>class{constructor(n){this._=n}destroy(){t(this._)}})(clearTimeout),Bd=(t,e)=>new W2(setTimeout(e,t)),fr=Symbol,un=fr(),yi=fr(),u0=fr(),jd=fr(),d0=fr(),f0=fr(),h0=fr(),sa=fr(),oa=fr(),q2=t=>{var r;t.length===1&&((r=t[0])==null?void 0:r.constructor)===Function&&(t=t[0]());const e=[];let n=0;for(;n<t.length;n++){const i=t[n];i===void 0||i.constructor===String||i.constructor===Number||i.constructor===Object&&e.push(JSON.stringify(i))}return e},p0=[d0,h0,sa,u0];let Hd=0,m0=Bn();const K2=(t,e)=>{const n=p0[Hd],r=ia("log"),i=r!==null&&(r==="*"||r==="true"||new RegExp(r,"gi").test(e));return Hd=(Hd+1)%p0.length,e+=": ",i?(...s)=>{var a;s.length===1&&((a=s[0])==null?void 0:a.constructor)===Function&&(s=s[0]());const o=Bn(),l=o-m0;m0=o,t(n,e,oa,...s.map(c=>{switch(c!=null&&c.constructor===Uint8Array&&(c=Array.from(c)),typeof c){case"string":case"symbol":return c;default:return U2(c)}}),n," +"+l+"ms")}:I2},J2={[un]:dr("font-weight","bold"),[yi]:dr("font-weight","normal"),[u0]:dr("color","blue"),[d0]:dr("color","green"),[jd]:dr("color","grey"),[f0]:dr("color","red"),[h0]:dr("color","purple"),[sa]:dr("color","orange"),[oa]:dr("color","black")},g0=j2?t=>{var o;t.length===1&&((o=t[0])==null?void 0:o.constructor)===Function&&(t=t[0]());const e=[],n=[],r=Lt();let i=[],s=0;for(;s<t.length;s++){const l=t[s],a=J2[l];if(a!==void 0)r.set(a.left,a.right);else{if(l===void 0)break;if(l.constructor===String||l.constructor===Number){const c=V2(r);s>0||c.length>0?(e.push("%c"+l),n.push(c)):e.push(l)}else break}}for(s>0&&(i=n,i.unshift(e.join("")));s<t.length;s++){const l=t[s];l instanceof Symbol||i.push(l)}return i}:q2,y0=(...t)=>{console.log(...g0(t)),b0.forEach(e=>e.print(t))},G2=(...t)=>{console.warn(...g0(t)),t.unshift(sa),b0.forEach(e=>e.print(t))},b0=or(),Y2=t=>K2(y0,t),ss=t=>new Promise(t);Promise.all.bind(Promise);const X2=t=>Promise.reject(t),zd=t=>Promise.resolve(t),v0=t=>new Uint8Array(t),Z2=(t,e,n)=>new Uint8Array(t,e,n),Q2=t=>new Uint8Array(t),eM=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=l2(t[n]);return btoa(e)},tM=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),nM=t=>{const e=atob(t),n=v0(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n},rM=t=>{const e=Buffer.from(t,"base64");return Z2(e.buffer,e.byteOffset,e.byteLength)},w0=Fd?eM:tM,x0=Fd?nM:rM,iM=t=>{const e=v0(t.byteLength);return e.set(t),e},k0=new Map;class sM{constructor(e){this.room=e,this.onmessage=null,this._onChange=n=>n.key===e&&this.onmessage!==null&&this.onmessage({data:x0(n.newValue||"")}),M2(this._onChange)}postMessage(e){s0.setItem(this.room,w0(Q2(e)))}close(){O2(this._onChange)}}const oM=typeof BroadcastChannel>"u"?sM:BroadcastChannel,Vd=t=>Vt(k0,t,()=>{const e=or(),n=new oM(t);return n.onmessage=r=>e.forEach(i=>i(r.data,"broadcastchannel")),{bc:n,subs:e}}),lM=(t,e)=>(Vd(t).subs.add(e),e),aM=(t,e)=>{const n=Vd(t),r=n.subs.delete(e);return r&&n.subs.size===0&&(n.bc.close(),k0.delete(t)),r},cM=(t,e,n=null)=>{const r=Vd(t);r.bc.postMessage(e),r.subs.forEach(i=>i(e,n))},C0=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},S0=t=>({[Symbol.iterator](){return this},next:t}),uM=(t,e)=>S0(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Ud=(t,e)=>S0(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class Wd{constructor(e,n){this.clock=e,this.len=n}}class ls{constructor(){this.clients=new Map}}const Pr=(t,e,n)=>e.clients.forEach((r,i)=>{const s=t.doc.store.clients.get(i);for(let o=0;o<r.length;o++){const l=r[o];q0(t,s,l.clock,l.len,n)}}),dM=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const i=wn((n+r)/2),s=t[i],o=s.clock;if(o<=e){if(e<o+s.len)return i;n=i+1}else r=i-1}return null},as=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&dM(n,e.clock)!==null},qd=t=>{t.clients.forEach(e=>{e.sort((i,s)=>i.clock-s.clock);let n,r;for(n=1,r=1;n<e.length;n++){const i=e[r-1],s=e[n];i.clock+i.len>=s.clock?i.len=ar(i.len,s.clock+s.len-i.clock):(r<n&&(e[r]=s),r++)}e.length=r})},Kd=t=>{const e=new ls;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,i)=>{if(!e.clients.has(i)){const s=r.slice();for(let o=n+1;o<t.length;o++)YA(s,t[o].clients.get(i)||[]);e.clients.set(i,s)}});return qd(e),e},Oo=(t,e,n,r)=>{Vt(t.clients,e,()=>[]).push(new Wd(n,r))},E0=()=>new ls,T0=t=>{const e=E0();return t.clients.forEach((n,r)=>{const i=[];for(let s=0;s<n.length;s++){const o=n[s];if(o.deleted){const l=o.id.clock;let a=o.length;if(s+1<n.length)for(let c=n[s+1];s+1<n.length&&c.deleted;c=n[++s+1])a+=c.length;i.push(new Wd(l,a))}}i.length>0&&e.clients.set(r,i)}),e},cs=(t,e)=>{ae(t.restEncoder,e.clients.size),lr(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),ae(t.restEncoder,n);const i=r.length;ae(t.restEncoder,i);for(let s=0;s<i;s++){const o=r[s];t.writeDsClock(o.clock),t.writeDsLen(o.len)}})},Jd=t=>{const e=new ls,n=me(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const i=me(t.restDecoder),s=me(t.restDecoder);if(s>0){const o=Vt(e.clients,i,()=>[]);for(let l=0;l<s;l++)o.push(new Wd(t.readDsClock(),t.readDsLen()))}}return e},A0=(t,e,n)=>{const r=new ls,i=me(t.restDecoder);for(let s=0;s<i;s++){t.resetDsCurVal();const o=me(t.restDecoder),l=me(t.restDecoder),a=n.clients.get(o)||[],c=rt(n,o);for(let u=0;u<l;u++){const d=t.readDsClock(),f=d+t.readDsLen();if(d<c){c<f&&Oo(r,o,c,f-c);let h=Vn(a,d),p=a[h];for(!p.deleted&&p.id.clock<d&&(a.splice(h+1,0,va(e,p,d-p.id.clock)),h++);h<a.length&&(p=a[h++],p.id.clock<f);)p.deleted||(f<p.id.clock+p.length&&a.splice(h,0,va(e,p,f-p.id.clock)),p.delete(e))}else Oo(r,o,d,f-d)}}if(r.clients.size>0){const s=new bi;return ae(s.restEncoder,0),cs(s,r),s.toUint8Array()}return null},M0=qy;class us extends wd{constructor({guid:e=Ky(),collectionid:n=null,gc:r=!0,gcFilter:i=()=>!0,meta:s=null,autoLoad:o=!1,shouldLoad:l=!0}={}){super(),this.gc=r,this.gcFilter=i,this.clientID=M0(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new V0,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=o,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.whenLoaded=ss(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const a=()=>ss(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&&Fe(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(lr(this.subdocs).map(e=>e.guid))}transact(e,n=null){return Fe(this,e,n)}get(e,n=Et){const r=Vt(this.share,e,()=>{const s=new n;return s._integrate(this,null),s}),i=r.constructor;if(n!==Et&&i!==n)if(i===Et){const s=new n;s._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=s}),s._start=r._start;for(let o=s._start;o!==null;o=o.right)o.parent=s;return s._length=r._length,this.share.set(e,s),s._integrate(this,null),s}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,ms)}getText(e=""){return this.get(e,wi)}getMap(e=""){return this.get(e,gs)}getXmlElement(e=""){return this.get(e,It)}getXmlFragment(e=""){return this.get(e,xi)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){lr(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new us({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,Fe(e.parent.doc,r=>{const i=n.doc;e.deleted||r.subdocsAdded.add(i),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class O0{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return me(this.restDecoder)}readDsLen(){return me(this.restDecoder)}}class _0 extends O0{readLeftID(){return ge(me(this.restDecoder),me(this.restDecoder))}readRightID(){return ge(me(this.restDecoder),me(this.restDecoder))}readClient(){return me(this.restDecoder)}readInfo(){return gi(this.restDecoder)}readString(){return ur(this.restDecoder)}readParentInfo(){return me(this.restDecoder)===1}readTypeRef(){return me(this.restDecoder)}readLen(){return me(this.restDecoder)}readAny(){return rs(this.restDecoder)}readBuf(){return iM(bt(this.restDecoder))}readJSON(){return JSON.parse(ur(this.restDecoder))}readKey(){return ur(this.restDecoder)}}class fM{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=me(this.restDecoder),this.dsCurrVal}readDsLen(){const e=me(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class ds extends fM{constructor(e){super(e),this.keys=[],me(e),this.keyClockDecoder=new Rd(bt(e)),this.clientDecoder=new ra(bt(e)),this.leftClockDecoder=new Rd(bt(e)),this.rightClockDecoder=new Rd(bt(e)),this.infoDecoder=new n0(bt(e),gi),this.stringDecoder=new T2(bt(e)),this.parentInfoDecoder=new n0(bt(e),gi),this.typeRefDecoder=new ra(bt(e)),this.lenDecoder=new ra(bt(e))}readLeftID(){return new fs(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new fs(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 rs(this.restDecoder)}readBuf(){return bt(this.restDecoder)}readJSON(){return rs(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 N0{constructor(){this.restEncoder=gt()}toUint8Array(){return qe(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){ae(this.restEncoder,e)}writeDsLen(e){ae(this.restEncoder,e)}}class _o extends N0{writeLeftID(e){ae(this.restEncoder,e.client),ae(this.restEncoder,e.clock)}writeRightID(e){ae(this.restEncoder,e.client),ae(this.restEncoder,e.clock)}writeClient(e){ae(this.restEncoder,e)}writeInfo(e){Ao(this.restEncoder,e)}writeString(e){jn(this.restEncoder,e)}writeParentInfo(e){ae(this.restEncoder,e?1:0)}writeTypeRef(e){ae(this.restEncoder,e)}writeLen(e){ae(this.restEncoder,e)}writeAny(e){ns(this.restEncoder,e)}writeBuf(e){Ze(this.restEncoder,e)}writeJSON(e){jn(this.restEncoder,JSON.stringify(e))}writeKey(e){jn(this.restEncoder,e)}}class D0{constructor(){this.restEncoder=gt(),this.dsCurrVal=0}toUint8Array(){return qe(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,ae(this.restEncoder,n)}writeDsLen(e){e===0&&cn(),ae(this.restEncoder,e-1),this.dsCurrVal+=e}}class bi extends D0{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new _d,this.clientEncoder=new ta,this.leftClockEncoder=new _d,this.rightClockEncoder=new _d,this.infoEncoder=new Xy(Ao),this.stringEncoder=new k2,this.parentInfoEncoder=new Xy(Ao),this.typeRefEncoder=new ta,this.lenEncoder=new ta}toUint8Array(){const e=gt();return ae(e,0),Ze(e,this.keyClockEncoder.toUint8Array()),Ze(e,this.clientEncoder.toUint8Array()),Ze(e,this.leftClockEncoder.toUint8Array()),Ze(e,this.rightClockEncoder.toUint8Array()),Ze(e,qe(this.infoEncoder)),Ze(e,this.stringEncoder.toUint8Array()),Ze(e,qe(this.parentInfoEncoder)),Ze(e,this.typeRefEncoder.toUint8Array()),Ze(e,this.lenEncoder.toUint8Array()),ea(e,qe(this.restEncoder)),qe(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){ns(this.restEncoder,e)}writeBuf(e){Ze(this.restEncoder,e)}writeJSON(e){ns(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 hM=(t,e,n,r)=>{r=ar(r,e[0].id.clock);const i=Vn(e,r);ae(t.restEncoder,e.length-i),t.writeClient(n),ae(t.restEncoder,r);const s=e[i];s.write(t,r-s.id.clock);for(let o=i+1;o<e.length;o++)e[o].write(t,0)},Gd=(t,e,n)=>{const r=new Map;n.forEach((i,s)=>{rt(e,s)>i&&r.set(s,i)}),Io(e).forEach((i,s)=>{n.has(s)||r.set(s,0)}),ae(t.restEncoder,r.size),lr(r.entries()).sort((i,s)=>s[0]-i[0]).forEach(([i,s])=>{hM(t,e.clients.get(i),i,s)})},pM=(t,e)=>{const n=Lt(),r=me(t.restDecoder);for(let i=0;i<r;i++){const s=me(t.restDecoder),o=new Array(s),l=t.readClient();let a=me(t.restDecoder);n.set(l,{i:0,refs:o});for(let c=0;c<s;c++){const u=t.readInfo();switch(Ql&u){case 0:{const d=t.readLen();o[c]=new dn(ge(l,a),d),a+=d;break}case 10:{const d=me(t.restDecoder);o[c]=new fn(ge(l,a),d),a+=d;break}default:{const d=(u&(cr|Yt))===0,f=new Ve(ge(l,a),null,(u&Yt)===Yt?t.readLeftID():null,null,(u&cr)===cr?t.readRightID():null,d?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,d&&(u&Co)===Co?t.readString():null,Cb(t,u));o[c]=f,a+=f.length}}}}return n},mM=(t,e,n)=>{const r=[];let i=lr(n.keys()).sort((h,p)=>h-p);if(i.length===0)return null;const s=()=>{if(i.length===0)return null;let h=n.get(i[i.length-1]);for(;h.refs.length===h.i;)if(i.pop(),i.length>0)h=n.get(i[i.length-1]);else return null;return h};let o=s();if(o===null)return null;const l=new V0,a=new Map,c=(h,p)=>{const g=a.get(h);(g==null||g>p)&&a.set(h,p)};let u=o.refs[o.i++];const d=new Map,f=()=>{for(const h of r){const p=h.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,[h]),i=i.filter(v=>v!==p)}r.length=0};for(;;){if(u.constructor!==fn){const p=Vt(d,u.id.client,()=>rt(e,u.id.client))-u.id.clock;if(p<0)r.push(u),c(u.id.client,u.id.clock-1),f();else{const g=u.getMissing(t,e);if(g!==null){r.push(u);const v=n.get(g)||{refs:[],i:0};if(v.refs.length===v.i)c(g,rt(e,g)),f();else{u=v.refs[v.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=s(),o===null)break;u=o.refs[o.i++]}}if(l.clients.size>0){const h=new bi;return Gd(h,l,new Map),ae(h.restEncoder,0),{missing:a,update:h.toUint8Array()}}return null},gM=(t,e)=>Gd(t,e.doc.store,e.beforeState),yM=(t,e,n,r=new ds(t))=>Fe(e,i=>{i.local=!1;let s=!1;const o=i.doc,l=o.store,a=pM(r,o),c=mM(i,l,a),u=l.pendingStructs;if(u){for(const[f,h]of u.missing)if(h<rt(l,f)){s=!0;break}if(c){for(const[f,h]of c.missing){const p=u.missing.get(f);(p==null||p>h)&&u.missing.set(f,h)}u.update=ca([u.update,c.update])}}else l.pendingStructs=c;const d=A0(r,i,l);if(l.pendingDs){const f=new ds(Hn(l.pendingDs));me(f.restDecoder);const h=A0(f,i,l);d&&h?l.pendingDs=ca([d,h]):l.pendingDs=d||h}else l.pendingDs=d;if(s){const f=l.pendingStructs.update;l.pendingStructs=null,R0(i.doc,f)}},n,!1),R0=(t,e,n,r=ds)=>{const i=Hn(e);yM(i,t,n,new r(i))},L0=(t,e,n)=>R0(t,e,n,_0),bM=(t,e,n=new Map)=>{Gd(t,e.store,n),cs(t,T0(e.store))},vM=(t,e=new Uint8Array([0]),n=new bi)=>{const r=I0(e);bM(n,t,r);const i=[n.toUint8Array()];if(t.store.pendingDs&&i.push(t.store.pendingDs),t.store.pendingStructs&&i.push(FM(t.store.pendingStructs.update,e)),i.length>1){if(n.constructor===_o)return IM(i.map((s,o)=>o===0?s:BM(s)));if(n.constructor===bi)return ca(i)}return i[0]},Yd=(t,e)=>vM(t,e,new _o),wM=t=>{const e=new Map,n=me(t.restDecoder);for(let r=0;r<n;r++){const i=me(t.restDecoder),s=me(t.restDecoder);e.set(i,s)}return e},I0=t=>wM(new O0(Hn(t))),P0=(t,e)=>(ae(t.restEncoder,e.size),lr(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{ae(t.restEncoder,n),ae(t.restEncoder,r)}),t),xM=(t,e)=>P0(t,Io(e.store)),kM=(t,e=new D0)=>(t instanceof Map?P0(e,t):xM(e,t),e.toUint8Array()),CM=t=>kM(t,new N0);class SM{constructor(){this.l=[]}}const F0=()=>new SM,$0=(t,e)=>t.l.push(e),B0=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(i=>e!==i),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},j0=(t,e,n)=>Pd(t.l,[e,n]);class fs{constructor(e,n){this.client=e,this.clock=n}}const hs=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,ge=(t,e)=>new fs(t,e),No=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw cn()},Do=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class Ro{constructor(e,n,r,i=0){this.type=e,this.tname=n,this.item=r,this.assoc=i}}const Lo=t=>new Ro(t.type==null?null:ge(t.type.client,t.type.clock),t.tname||null,t.item==null?null:ge(t.item.client,t.item.clock),t.assoc==null?0:t.assoc);class EM{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const TM=(t,e,n=0)=>new EM(t,e,n),la=(t,e,n)=>{let r=null,i=null;return t._item===null?i=No(t):r=ge(t._item.id.client,t._item.id.clock),new Ro(r,i,e,n)},Xd=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return la(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return la(t,ge(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return la(t,r.lastId,n);r=r.right}return la(t,null,n)},AM=(t,e,n=!0)=>{const r=e.store,i=t.item,s=t.type,o=t.tname,l=t.assoc;let a=null,c=0;if(i!==null){if(rt(r,i.client)<=i.clock)return null;const u=n?ff(r,i):{item:ps(r,i),diff:0},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 f=d.left;for(;f!==null;)!f.deleted&&f.countable&&(c+=f.length),f=f.left}}else{if(o!==null)a=e.get(o);else if(s!==null){if(rt(r,s.client)<=s.clock)return null;const{item:u}=n?ff(r,s):{item:ps(r,s)};if(u instanceof Ve&&u.content instanceof Sn)a=u.content.type;else return null}else throw cn();l>=0?c=a._length:c=0}return TM(a,c,t.assoc)},H0=(t,e)=>t===e||t!==null&&e!==null&&t.tname===e.tname&&hs(t.item,e.item)&&hs(t.type,e.type)&&t.assoc===e.assoc;class Zd{constructor(e,n){this.ds=e,this.sv=n}}const z0=(t,e)=>new Zd(t,e),MM=t=>z0(T0(t.store),Io(t.store)),vi=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!as(e.ds,t.id),Qd=(t,e)=>{const n=Vt(t.meta,Qd,or),r=t.doc.store;n.has(e)||(e.sv.forEach((i,s)=>{i<rt(r,s)&&Ut(t,ge(s,i))}),Pr(t,e.ds,i=>{}),n.add(e))};class V0{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Io=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const i=n[n.length-1];e.set(r,i.id.clock+i.length)}),e},rt=(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},U0=(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 cn()}n.push(e)},Vn=(t,e)=>{let n=0,r=t.length-1,i=t[r],s=i.id.clock;if(s===e)return r;let o=wn(e/(s+i.length-1)*r);for(;n<=r;){if(i=t[o],s=i.id.clock,s<=e){if(e<s+i.length)return o;n=o+1}else r=o-1;o=wn((n+r)/2)}throw cn()},ps=(t,e)=>{const n=t.clients.get(e.client);return n[Vn(n,e.clock)]},ef=(t,e,n)=>{const r=Vn(e,n),i=e[r];return i.id.clock<n&&i instanceof Ve?(e.splice(r+1,0,va(t,i,n-i.id.clock)),r+1):r},Ut=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[ef(t,n,e.clock)]},W0=(t,e,n)=>{const r=e.clients.get(n.client),i=Vn(r,n.clock),s=r[i];return n.clock!==s.id.clock+s.length-1&&s.constructor!==dn&&r.splice(i+1,0,va(t,s,n.clock-s.id.clock+1)),s},OM=(t,e,n)=>{const r=t.clients.get(e.id.client);r[Vn(r,e.id.clock)]=n},q0=(t,e,n,r,i)=>{if(r===0)return;const s=n+r;let o=ef(t,e,n),l;do l=e[o++],s<l.id.clock+l.length&&ef(t,e,s),i(l);while(o<e.length&&e[o].id.clock<s)};class _M{constructor(e,n,r){this.doc=e,this.deleteSet=new ls,this.beforeState=Io(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 K0=(t,e)=>e.deleteSet.clients.size===0&&!GA(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(qd(e.deleteSet),gM(t,e),cs(t,e.deleteSet),!0),J0=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&Vt(t.changed,e,or).add(n)},aa=(t,e)=>{let n=t[e],r=t[e-1],i=e;for(;i>0;n=r,r=t[--i-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 s=e-i;return s&&t.splice(e+1-s,s),s},NM=(t,e,n)=>{for(const[r,i]of t.clients.entries()){const s=e.clients.get(r);for(let o=i.length-1;o>=0;o--){const l=i[o],a=l.clock+l.len;for(let c=Vn(s,l.clock),u=s[c];c<s.length&&u.id.clock<a;u=s[++c]){const d=s[c];if(l.clock+l.len<=d.id.clock)break;d instanceof Ve&&d.deleted&&!d.keep&&n(d)&&d.gc(e,!1)}}}},DM=(t,e)=>{t.clients.forEach((n,r)=>{const i=e.clients.get(r);for(let s=n.length-1;s>=0;s--){const o=n[s],l=Ir(i.length-1,1+Vn(i,o.clock+o.len-1));for(let a=l,c=i[a];a>0&&c.id.clock>=o.clock;c=i[a])a-=1+aa(i,a)}})},G0=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,i=r.store,s=n.deleteSet,o=n._mergeStructs;try{qd(s),n.afterState=Io(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),j0(c._dEH,a,n))})}),l.push(()=>r.emit("afterTransaction",[n,r])),Pd(l,[]),n._needFormattingCleanup&&QM(n)}finally{r.gc&&NM(s,i,r.gcFilter),DM(s,i),n.afterState.forEach((u,d)=>{const f=n.beforeState.get(d)||0;if(f!==u){const h=i.clients.get(d),p=ar(Vn(h,f),1);for(let g=h.length-1;g>=p;)g-=1+aa(h,g)}});for(let u=o.length-1;u>=0;u--){const{client:d,clock:f}=o[u].id,h=i.clients.get(d),p=Vn(h,f);p+1<h.length&&aa(h,p+1)>1||p>0&&aa(h,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(y0(sa,un,"[yjs] ",yi,f0,"Changed the client-id because another client seems to be using it."),r.clientID=M0()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const u=new _o;K0(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const u=new bi;K0(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])):G0(t,e+1)}}},Fe=(t,e,n=null,r=!0)=>{const i=t._transactionCleanups;let s=!1,o=null;t._transaction===null&&(s=!0,t._transaction=new _M(t,n,r),i.push(t._transaction),i.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(s){const l=t._transaction===i[0];t._transaction=null,l&&G0(i,0)}}return o};class RM{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const Y0=(t,e,n)=>{Pr(t,n.deletions,r=>{r instanceof Ve&&e.scope.some(i=>Do(i,r))&&hf(r,!1)})},X0=(t,e,n)=>{let r=null;const i=t.doc,s=t.scope;if(Fe(i,o=>{for(;e.length>0&&t.currStackItem===null;){const l=i.store,a=e.pop(),c=new Set,u=[];let d=!1;Pr(o,a.insertions,f=>{if(f instanceof Ve){if(f.redone!==null){let{item:h,diff:p}=ff(l,f.id);p>0&&(h=Ut(o,ge(h.id.client,h.id.clock+p))),f=h}!f.deleted&&s.some(h=>Do(h,f))&&u.push(f)}}),Pr(o,a.deletions,f=>{f instanceof Ve&&s.some(h=>Do(h,f))&&!as(a.insertions,f.id)&&c.add(f)}),c.forEach(f=>{d=kb(o,f,c,a.insertions,t.ignoreRemoteMapChanges,t)!==null||d});for(let f=u.length-1;f>=0;f--){const h=u[f];t.deleteFilter(h)&&(h.delete(o),d=!0)}t.currStackItem=d?a:null}o.changed.forEach((l,a)=>{l.has(null)&&a._searchMarker&&(a._searchMarker.length=0)}),r=o},t),t.currStackItem!=null){const o=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:t.currStackItem,type:n,changedParentTypes:o,origin:t},t]),t.currStackItem=null}return t.currStackItem};class Z0 extends wd{constructor(e,{captureTimeout:n=500,captureTransaction:r=a=>!0,deleteFilter:i=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:l=vd(e)?e[0].doc:e.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(e),this.deleteFilter=i,s.add(this),this.trackedOrigins=s,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(v=>a.changedParentTypes.has(v))||!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 f=new ls;a.afterState.forEach((v,w)=>{const S=a.beforeState.get(w)||0,x=v-S;x>0&&Oo(f,w,S,x)});const h=Bn();let p=!1;if(this.lastChange>0&&h-this.lastChange<this.captureTimeout&&d.length>0&&!c&&!u){const v=d[d.length-1];v.deletions=Kd([v.deletions,a.deleteSet]),v.insertions=Kd([v.insertions,f])}else d.push(new RM(a.deleteSet,f)),p=!0;!c&&!u&&(this.lastChange=h),Pr(a,a.deleteSet,v=>{v instanceof Ve&&this.scope.some(w=>Do(w,v))&&hf(v,!0)});const g=[{stackItem:d[d.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){e=vd(e)?e:[e],e.forEach(n=>{this.scope.every(r=>r!==n)&&(n.doc!==this.doc&&G2("[yjs#509] Not same Y.Doc"),this.scope.push(n))})}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(i=>Y0(r,this,i)),this.undoStack=[]),n&&(this.redoStack.forEach(i=>Y0(r,this,i)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=X0(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=X0(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*LM(t){const e=me(t.restDecoder);for(let n=0;n<e;n++){const r=me(t.restDecoder),i=t.readClient();let s=me(t.restDecoder);for(let o=0;o<r;o++){const l=t.readInfo();if(l===10){const a=me(t.restDecoder);yield new fn(ge(i,s),a),s+=a}else if(Ql&l){const a=(l&(cr|Yt))===0,c=new Ve(ge(i,s),null,(l&Yt)===Yt?t.readLeftID():null,null,(l&cr)===cr?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(l&Co)===Co?t.readString():null,Cb(t,l));yield c,s+=c.length}else{const a=t.readLen();yield new dn(ge(i,s),a),s+=a}}}}class tf{constructor(e,n){this.gen=LM(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===fn);return this.curr}}class nf{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const IM=t=>ca(t,_0,_o),PM=(t,e)=>{if(t.constructor===dn){const{client:n,clock:r}=t.id;return new dn(ge(n,r+e),t.length-e)}else if(t.constructor===fn){const{client:n,clock:r}=t.id;return new fn(ge(n,r+e),t.length-e)}else{const n=t,{client:r,clock:i}=n.id;return new Ve(ge(r,i+e),null,ge(r,i+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},ca=(t,e=ds,n=bi)=>{if(t.length===1)return t[0];const r=t.map(u=>new e(Hn(u)));let i=r.map(u=>new tf(u,!0)),s=null;const o=new n,l=new nf(o);for(;i=i.filter(f=>f.curr!==null),i.sort((f,h)=>{if(f.curr.id.client===h.curr.id.client){const p=f.curr.id.clock-h.curr.id.clock;return p===0?f.curr.constructor===h.curr.constructor?0:f.curr.constructor===fn?1:-1:p}else return h.curr.id.client-f.curr.id.client}),i.length!==0;){const u=i[0],d=u.curr.id.client;if(s!==null){let f=u.curr,h=!1;for(;f!==null&&f.id.clock+f.length<=s.struct.id.clock+s.struct.length&&f.id.client>=s.struct.id.client;)f=u.next(),h=!0;if(f===null||f.id.client!==d||h&&f.id.clock>s.struct.id.clock+s.struct.length)continue;if(d!==s.struct.id.client)Fr(l,s.struct,s.offset),s={struct:f,offset:0},u.next();else if(s.struct.id.clock+s.struct.length<f.id.clock)if(s.struct.constructor===fn)s.struct.length=f.id.clock+f.length-s.struct.id.clock;else{Fr(l,s.struct,s.offset);const p=f.id.clock-s.struct.id.clock-s.struct.length;s={struct:new fn(ge(d,s.struct.id.clock+s.struct.length),p),offset:0}}else{const p=s.struct.id.clock+s.struct.length-f.id.clock;p>0&&(s.struct.constructor===fn?s.struct.length-=p:f=PM(f,p)),s.struct.mergeWith(f)||(Fr(l,s.struct,s.offset),s={struct:f,offset:0},u.next())}}else s={struct:u.curr,offset:0},u.next();for(let f=u.curr;f!==null&&f.id.client===d&&f.id.clock===s.struct.id.clock+s.struct.length&&f.constructor!==fn;f=u.next())Fr(l,s.struct,s.offset),s={struct:f,offset:0}}s!==null&&(Fr(l,s.struct,s.offset),s=null),rf(l);const a=r.map(u=>Jd(u)),c=Kd(a);return cs(o,c),o.toUint8Array()},FM=(t,e,n=ds,r=bi)=>{const i=I0(e),s=new r,o=new nf(s),l=new n(Hn(t)),a=new tf(l,!1);for(;a.curr;){const u=a.curr,d=u.id.client,f=i.get(d)||0;if(a.curr.constructor===fn){a.next();continue}if(u.id.clock+u.length>f)for(Fr(o,u,ar(f-u.id.clock,0)),a.next();a.curr&&a.curr.id.client===d;)Fr(o,a.curr,0),a.next();else for(;a.curr&&a.curr.id.client===d&&a.curr.id.clock+a.curr.length<=f;)a.next()}rf(o);const c=Jd(l);return cs(s,c),s.toUint8Array()},Q0=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:qe(t.encoder.restEncoder)}),t.encoder.restEncoder=gt(),t.written=0)},Fr=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&Q0(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),ae(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},rf=t=>{Q0(t);const e=t.encoder.restEncoder;ae(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];ae(e,r.written),ea(e,r.restEncoder)}},$M=(t,e,n,r)=>{const i=new n(Hn(t)),s=new tf(i,!1),o=new r,l=new nf(o);for(let c=s.curr;c!==null;c=s.next())Fr(l,e(c),0);rf(l);const a=Jd(i);return cs(o,a),o.toUint8Array()},BM=t=>$M(t,P2,ds,_o),eb="You must not compute changes after the event-handler fired.";class ua{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=jM(this.currentTarget,this.target))}deletes(e){return as(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw xn(eb);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(i=>{if(i!==null){const s=n._map.get(i);let o,l;if(this.adds(s)){let a=s.left;for(;a!==null&&this.adds(a);)a=a.left;if(this.deletes(s))if(a!==null&&this.deletes(a))o="delete",l=bd(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",l=bd(a.content.getContent())):(o="add",l=void 0)}else if(this.deletes(s))o="delete",l=bd(s.content.getContent());else return;e.set(i,{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 xn(eb);const n=this.target,r=or(),i=or(),s=[];if(e={added:r,deleted:i,delta:s,keys:this.keys},this.transaction.changed.get(n).has(null)){let l=null;const a=()=>{l&&s.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,i.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 jM=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,i=e._item.parent._start;for(;i!==e._item&&i!==null;)i.deleted||r++,i=i.right;n.unshift(r)}e=e._item.parent}return n},tb=80;let sf=0;class HM{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=sf++}}const zM=t=>{t.timestamp=sf++},nb=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=sf++},VM=(t,e,n)=>{if(t.length>=tb){const r=t.reduce((i,s)=>i.timestamp<s.timestamp?i:s);return nb(r,e,n),r}else{const r=new HM(e,n);return t.push(r),r}},da=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((s,o)=>Xl(e-s.index)<Xl(e-o.index)?s:o);let r=t._start,i=0;for(n!==null&&(r=n.p,i=n.index,zM(n));r.right!==null&&i<e;){if(!r.deleted&&r.countable){if(e<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>e;)r=r.left,!r.deleted&&r.countable&&(i-=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&&(i-=r.length);return n!==null&&Xl(n.index-i)<r.parent.length/tb?(nb(n,r,i),n):VM(t._searchMarker,r,i)},Po=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const i=t[r];if(n>0){let s=i.p;for(s.marker=!1;s&&(s.deleted||!s.countable);)s=s.left,s&&!s.deleted&&s.countable&&(i.index-=s.length);if(s===null||s.marker===!0){t.splice(r,1);continue}i.p=s,s.marker=!0}(e<i.index||n>0&&e===i.index)&&(i.index=ar(e,i.index+n))}},fa=(t,e,n)=>{const r=t,i=e.changedParentTypes;for(;Vt(i,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;j0(r._eH,n,e)};class Et{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=F0(),this._dEH=F0(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw kn()}clone(){throw kn()}_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){$0(this._eH,e)}observeDeep(e){$0(this._dEH,e)}unobserve(e){B0(this._eH,e)}unobserveDeep(e){B0(this._dEH,e)}toJSON(){}}const rb=(t,e,n)=>{e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const i=[];let s=t._start;for(;s!==null&&r>0;){if(s.countable&&!s.deleted){const o=s.content.getContent();if(o.length<=e)e-=o.length;else{for(let l=e;l<o.length&&r>0;l++)i.push(o[l]),r--;e=0}}s=s.right}return i},ib=t=>{const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let i=0;i<r.length;i++)e.push(r[i])}n=n.right}return e},sb=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&vi(r,e)){const i=r.content.getContent();for(let s=0;s<i.length;s++)n.push(i[s])}r=r.right}return n},Fo=(t,e)=>{let n=0,r=t._start;for(;r!==null;){if(r.countable&&!r.deleted){const i=r.content.getContent();for(let s=0;s<i.length;s++)e(i[s],n++,t)}r=r.right}},ob=(t,e)=>{const n=[];return Fo(t,(r,i)=>{n.push(e(r,i,t))}),n},UM=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 i=n[r++];return n.length<=r&&(n=null),{done:!1,value:i}}}},lb=(t,e)=>{const n=da(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}},ha=(t,e,n,r)=>{let i=n;const s=t.doc,o=s.clientID,l=s.store,a=n===null?e._start:n.right;let c=[];const u=()=>{c.length>0&&(i=new Ve(ge(o,rt(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new Ci(c)),i.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:i=new Ve(ge(o,rt(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new $o(new Uint8Array(d))),i.integrate(t,0);break;case us:i=new Ve(ge(o,rt(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new jo(d)),i.integrate(t,0);break;default:if(d instanceof Et)i=new Ve(ge(o,rt(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new Sn(d)),i.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},ab=()=>xn("Length exceeded!"),cb=(t,e,n,r)=>{if(n>e._length)throw ab();if(n===0)return e._searchMarker&&Po(e._searchMarker,n,r.length),ha(t,e,null,r);const i=n,s=da(e,n);let o=e._start;for(s!==null&&(o=s.p,n-=s.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&&Ut(t,ge(o.id.client,o.id.clock+n));break}n-=o.length}return e._searchMarker&&Po(e._searchMarker,i,r.length),ha(t,e,o,r)},WM=(t,e,n)=>{let i=(e._searchMarker||[]).reduce((s,o)=>o.index>s.index?o:s,{index:0,p:e._start}).p;if(i)for(;i.right;)i=i.right;return ha(t,e,i,n)},ub=(t,e,n,r)=>{if(r===0)return;const i=n,s=r,o=da(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&&Ut(t,ge(l.id.client,l.id.clock+n)),n-=l.length);for(;r>0&&l!==null;)l.deleted||(r<l.length&&Ut(t,ge(l.id.client,l.id.clock+r)),l.delete(t),r-=l.length),l=l.right;if(r>0)throw ab();e._searchMarker&&Po(e._searchMarker,i,-s+r)},pa=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},of=(t,e,n,r)=>{const i=e._map.get(n)||null,s=t.doc,o=s.clientID;let l;if(r==null)l=new Ci([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:l=new Ci([r]);break;case Uint8Array:l=new $o(r);break;case us:l=new jo(r);break;default:if(r instanceof Et)l=new Sn(r);else throw new Error("Unexpected content type")}new Ve(ge(o,rt(s.store,o)),i,i&&i.lastId,null,null,e,n,l).integrate(t,0)},lf=(t,e)=>{const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},db=t=>{const e={};return t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},fb=(t,e)=>{const n=t._map.get(e);return n!==void 0&&!n.deleted},qM=(t,e)=>{const n={};return t._map.forEach((r,i)=>{let s=r;for(;s!==null&&(!e.sv.has(s.id.client)||s.id.clock>=(e.sv.get(s.id.client)||0));)s=s.left;s!==null&&vi(s,e)&&(n[i]=s.content.getContent()[s.length-1])}),n},ma=t=>uM(t.entries(),e=>!e[1].deleted);class KM extends ua{constructor(e,n){super(e,n),this._transaction=n}}class ms extends Et{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new ms;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ms}clone(){const e=new ms;return e.insert(0,this.toArray().map(n=>n instanceof Et?n.clone():n)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}_callObserver(e,n){super._callObserver(e,n),fa(this,e,new KM(this,e))}insert(e,n){this.doc!==null?Fe(this.doc,r=>{cb(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?Fe(this.doc,n=>{WM(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?Fe(this.doc,r=>{ub(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return lb(this,e)}toArray(){return ib(this)}slice(e=0,n=this.length){return rb(this,e,n)}toJSON(){return this.map(e=>e instanceof Et?e.toJSON():e)}map(e){return ob(this,e)}forEach(e){Fo(this,e)}[Symbol.iterator](){return UM(this)}_write(e){e.writeTypeRef(yO)}}const JM=t=>new ms;class GM extends ua{constructor(e,n,r){super(e,n),this.keysChanged=r}}class gs extends Et{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,i)=>{this.set(i,r)}),this._prelimContent=null}_copy(){return new gs}clone(){const e=new gs;return this.forEach((n,r)=>{e.set(r,n instanceof Et?n.clone():n)}),e}_callObserver(e,n){fa(this,e,new GM(this,e,n))}toJSON(){const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const i=n.content.getContent()[n.length-1];e[r]=i instanceof Et?i.toJSON():i}}),e}get size(){return[...ma(this._map)].length}keys(){return Ud(ma(this._map),e=>e[0])}values(){return Ud(ma(this._map),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Ud(ma(this._map),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){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?Fe(this.doc,n=>{pa(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?Fe(this.doc,r=>{of(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return lf(this,e)}has(e){return fb(this,e)}clear(){this.doc!==null?Fe(this.doc,e=>{this.forEach(function(n,r,i){pa(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(bO)}}const YM=t=>new gs,$r=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&L2(t,e);class af{constructor(e,n,r,i){this.left=e,this.right=n,this.index=r,this.currentAttributes=i}forward(){switch(this.right===null&&cn(),this.right.content.constructor){case lt:this.right.deleted||ys(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 hb=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case lt:e.right.deleted||ys(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n<e.right.length&&Ut(t,ge(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},ga=(t,e,n,r)=>{const i=new Map,s=r?da(e,n):null;if(s){const o=new af(s.p.left,s.p,s.index,i);return hb(t,o,n-s.index)}else{const o=new af(null,e._start,0,i);return hb(t,o,n)}},pb=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===lt&&$r(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const i=t.doc,s=i.clientID;r.forEach((o,l)=>{const a=n.left,c=n.right,u=new Ve(ge(s,rt(i.store,s)),a,a&&a.lastId,c,c&&c.id,e,null,new lt(l,o));u.integrate(t,0),n.right=u,n.forward()})},ys=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},mb=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===lt&&$r(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},gb=(t,e,n,r)=>{const i=t.doc,s=i.clientID,o=new Map;for(const l in r){const a=r[l],c=n.currentAttributes.get(l)??null;if(!$r(c,a)){o.set(l,c);const{left:u,right:d}=n;n.right=new Ve(ge(s,rt(i.store,s)),u,u&&u.lastId,d,d&&d.id,e,null,new lt(l,a)),n.right.integrate(t,0),n.forward()}}return o},cf=(t,e,n,r,i)=>{n.currentAttributes.forEach((f,h)=>{i[h]===void 0&&(i[h]=null)});const s=t.doc,o=s.clientID;mb(n,i);const l=gb(t,e,n,i),a=r.constructor===String?new Cn(r):r instanceof Et?new Sn(r):new ki(r);let{left:c,right:u,index:d}=n;e._searchMarker&&Po(e._searchMarker,n.index,a.getLength()),u=new Ve(ge(o,rt(s.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(),pb(t,e,n,l)},yb=(t,e,n,r,i)=>{const s=t.doc,o=s.clientID;mb(n,i);const l=gb(t,e,n,i);e:for(;n.right!==null&&(r>0||l.size>0&&(n.right.deleted||n.right.content.constructor===lt));){if(!n.right.deleted)switch(n.right.content.constructor){case lt:{const{key:a,value:c}=n.right.content,u=i[a];if(u!==void 0){if($r(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&&Ut(t,ge(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+=`
|
388
|
-
`;n.right=new Ve(ge(o,rt(s.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new Cn(a)),n.right.integrate(t,0),n.forward()}pb(t,e,n,l)},bb=(t,e,n,r,i)=>{let s=e;const o=Lt();for(;s&&(!s.countable||s.deleted);){if(!s.deleted&&s.content.constructor===lt){const c=s.content;o.set(c.key,c)}s=s.right}let l=0,a=!1;for(;e!==s;){if(n===e&&(a=!0),!e.deleted){const c=e.content;switch(c.constructor){case lt:{const{key:u,value:d}=c,f=r.get(u)??null;(o.get(u)!==c||f===d)&&(e.delete(t),l++,!a&&(i.get(u)??null)===d&&f!==d&&(f===null?i.delete(u):i.set(u,f))),!a&&!e.deleted&&ys(i,c);break}}}e=e.right}return l},XM=(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===lt){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},ZM=t=>{let e=0;return Fe(t.doc,n=>{let r=t._start,i=t._start,s=Lt();const o=yd(s);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case lt:ys(o,i.content);break;default:e+=bb(n,r,i,s,o),s=yd(o),r=i;break}i=i.right}}),e},QM=t=>{const e=new Set,n=t.doc;for(const[r,i]of t.afterState.entries()){const s=t.beforeState.get(r)||0;i!==s&&q0(t,n.store.clients.get(r),s,i,o=>{!o.deleted&&o.content.constructor===lt&&o.constructor!==dn&&e.add(o.parent)})}Fe(n,r=>{Pr(t,t.deleteSet,i=>{if(i instanceof dn||!i.parent._hasFormatting||e.has(i.parent))return;const s=i.parent;i.content.constructor===lt?e.add(s):XM(r,i)});for(const i of e)ZM(i)})},vb=(t,e,n)=>{const r=n,i=yd(e.currentAttributes),s=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Sn:case ki:case Cn:n<e.right.length&&Ut(t,ge(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}s&&bb(t,s,e.right,i,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&Po(o._searchMarker,e.index,-r+n),e};class eO extends ua{constructor(e,n,r){super(e,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(i=>{i===null?this.childListChanged=!0:this.keysChanged.add(i)})}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=[];Fe(e,r=>{const i=new Map,s=new Map;let o=this.target._start,l=null;const a={};let c="",u=0,d=0;const f=()=>{if(l!==null){let h=null;switch(l){case"delete":d>0&&(h={delete:d}),d=0;break;case"insert":(typeof c=="object"||c.length>0)&&(h={insert:c},i.size>0&&(h.attributes={},i.forEach((p,g)=>{p!==null&&(h.attributes[g]=p)}))),c="";break;case"retain":u>0&&(h={retain:u},D2(a)||(h.attributes=_2({},a))),u=0;break}h&&n.push(h),l=null}};for(;o!==null;){switch(o.content.constructor){case Sn:case ki:this.adds(o)?this.deletes(o)||(f(),l="insert",c=o.content.getContent()[0],f()):this.deletes(o)?(l!=="delete"&&(f(),l="delete"),d+=1):o.deleted||(l!=="retain"&&(f(),l="retain"),u+=1);break;case Cn:this.adds(o)?this.deletes(o)||(l!=="insert"&&(f(),l="insert"),c+=o.content.str):this.deletes(o)?(l!=="delete"&&(f(),l="delete"),d+=o.length):o.deleted||(l!=="retain"&&(f(),l="retain"),u+=o.length);break;case lt:{const{key:h,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){const g=i.get(h)??null;$r(g,p)?p!==null&&o.delete(r):(l==="retain"&&f(),$r(p,s.get(h)??null)?delete a[h]:a[h]=p)}}else if(this.deletes(o)){s.set(h,p);const g=i.get(h)??null;$r(g,p)||(l==="retain"&&f(),a[h]=g)}else if(!o.deleted){s.set(h,p);const g=a[h];g!==void 0&&($r(g,p)?g!==null&&o.delete(r):(l==="retain"&&f(),p===null?delete a[h]:a[h]=p))}o.deleted||(l==="insert"&&f(),ys(i,o.content));break}}o=o.right}for(f();n.length>0;){const h=n[n.length-1];if(h.retain!==void 0&&h.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class wi extends Et{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return 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 wi}clone(){const e=new wi;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new eO(this,e,n);fa(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Cn&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?Fe(this.doc,r=>{const i=new af(null,this._start,0,new Map);for(let s=0;s<e.length;s++){const o=e[s];if(o.insert!==void 0){const l=!n&&typeof o.insert=="string"&&s===e.length-1&&i.right===null&&o.insert.slice(-1)===`
|
389
|
-
`?o.insert.slice(0,-1):o.insert;(typeof l!="string"||l.length>0)&&cf(r,this,i,l,o.attributes||{})}else o.retain!==void 0?yb(r,this,i,o.retain,o.attributes||{}):o.delete!==void 0&&vb(r,i,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){const i=[],s=new Map,o=this.doc;let l="",a=this._start;function c(){if(l.length>0){const d={};let f=!1;s.forEach((p,g)=>{f=!0,d[g]=p});const h={insert:l};f&&(h.attributes=d),i.push(h),l=""}}const u=()=>{for(;a!==null;){if(vi(a,e)||n!==void 0&&vi(a,n))switch(a.content.constructor){case Cn:{const d=s.get("ychange");e!==void 0&&!vi(a,e)?(d===void 0||d.user!==a.id.client||d.type!=="removed")&&(c(),s.set("ychange",r?r("removed",a.id):{type:"removed"})):n!==void 0&&!vi(a,n)?(d===void 0||d.user!==a.id.client||d.type!=="added")&&(c(),s.set("ychange",r?r("added",a.id):{type:"added"})):d!==void 0&&(c(),s.delete("ychange")),l+=a.content.str;break}case Sn:case ki:{c();const d={insert:a.content.getContent()[0]};if(s.size>0){const f={};d.attributes=f,s.forEach((h,p)=>{f[p]=h})}i.push(d);break}case lt:vi(a,e)&&(c(),ys(s,a.content));break}a=a.right}c()};return e||n?Fe(o,d=>{e&&Qd(d,e),n&&Qd(d,n),u()},"cleanup"):u(),i}insert(e,n,r){if(n.length<=0)return;const i=this.doc;i!==null?Fe(i,s=>{const o=ga(s,this,e,!r);r||(r={},o.currentAttributes.forEach((l,a)=>{r[a]=l})),cf(s,this,o,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const i=this.doc;i!==null?Fe(i,s=>{const o=ga(s,this,e,!r);cf(s,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?Fe(r,i=>{vb(i,ga(i,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const i=this.doc;i!==null?Fe(i,s=>{const o=ga(s,this,e,!1);o.right!==null&&yb(s,this,o,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?Fe(this.doc,n=>{pa(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?Fe(this.doc,r=>{of(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return lf(this,e)}getAttributes(){return db(this)}_write(e){e.writeTypeRef(vO)}}const tO=t=>new wi;class uf{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0}[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===It||n.constructor===xi)&&n._start!==null)e=n._start;else for(;e!==null;)if(e.right!==null){e=e.right;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 xi extends Et{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 xi}clone(){const e=new xi;return e.insert(0,this.toArray().map(n=>n instanceof Et?n.clone():n)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new uf(this,e)}querySelector(e){e=e.toUpperCase();const r=new uf(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),lr(new uf(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){fa(this,e,new iO(this,n,e))}toString(){return ob(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const i=e.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),Fo(this,s=>{i.insertBefore(s.toDOM(e,n,r),null)}),i}insert(e,n){this.doc!==null?Fe(this.doc,r=>{cb(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)Fe(this.doc,r=>{const i=e&&e instanceof Et?e._item:e;ha(r,this,i,n)});else{const r=this._prelimContent,i=e===null?0:r.findIndex(s=>s===e)+1;if(i===0&&e!==null)throw xn("Reference item not found");r.splice(i,0,...n)}}delete(e,n=1){this.doc!==null?Fe(this.doc,r=>{ub(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return ib(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return lb(this,e)}slice(e=0,n=this.length){return rb(this,e,n)}forEach(e){Fo(this,e)}_write(e){e.writeTypeRef(xO)}}const nO=t=>new xi;class It extends xi{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,i)=>{this.setAttribute(i,r)}),this._prelimAttrs=null}_copy(){return new It(this.nodeName)}clone(){const e=new It(this.nodeName),n=this.getAttributes();return N2(n,(r,i)=>{typeof r=="string"&&e.setAttribute(i,r)}),e.insert(0,this.toArray().map(r=>r instanceof Et?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const l in e)r.push(l);r.sort();const i=r.length;for(let l=0;l<i;l++){const a=r[l];n.push(a+'="'+e[a]+'"')}const s=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${s}${o}>${super.toString()}</${s}>`}removeAttribute(e){this.doc!==null?Fe(this.doc,n=>{pa(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?Fe(this.doc,r=>{of(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return lf(this,e)}hasAttribute(e){return fb(this,e)}getAttributes(e){return e?qM(this,e):db(this)}toDOM(e=document,n={},r){const i=e.createElement(this.nodeName),s=this.getAttributes();for(const o in s){const l=s[o];typeof l=="string"&&i.setAttribute(o,l)}return Fo(this,o=>{i.appendChild(o.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(wO),e.writeKey(this.nodeName)}}const rO=t=>new It(t.readKey());class iO extends ua{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i)})}}class ya extends gs{constructor(e){super(),this.hookName=e}_copy(){return new ya(this.hookName)}clone(){const e=new ya(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const i=n[this.hookName];let s;return i!==void 0?s=i.createDom(this):s=document.createElement(this.hookName),s.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef(kO),e.writeKey(this.hookName)}}const sO=t=>new ya(t.readKey());class Xt extends wi{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 Xt}clone(){const e=new Xt;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const i=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(e=>{const n=[];for(const i in e.attributes){const s=[];for(const o in e.attributes[i])s.push({key:o,value:e.attributes[i][o]});s.sort((o,l)=>o.key<l.key?-1:1),n.push({nodeName:i,attrs:s})}n.sort((i,s)=>i.nodeName<s.nodeName?-1:1);let r="";for(let i=0;i<n.length;i++){const s=n[i];r+=`<${s.nodeName}`;for(let o=0;o<s.attrs.length;o++){const l=s.attrs[o];r+=` ${l.key}="${l.value}"`}r+=">"}r+=e.insert;for(let i=n.length-1;i>=0;i--)r+=`</${n[i].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(CO)}}const oO=t=>new Xt;class df{constructor(e,n){this.id=e,this.length=n}get deleted(){throw kn()}mergeWith(e){return!1}write(e,n,r){throw kn()}integrate(e,n){throw kn()}}const lO=0;class dn extends df{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),U0(e.doc.store,this)}write(e,n){e.writeInfo(lO),e.writeLen(this.length-n)}getMissing(e,n){return null}}class $o{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new $o(this.content)}splice(e){throw kn()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const aO=t=>new $o(t.readBuf());class Bo{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Bo(this.len)}splice(e){const n=new Bo(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){Oo(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 cO=t=>new Bo(t.readLen()),wb=(t,e)=>new us({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class jo{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 jo(wb(this.doc.guid,this.opts))}splice(e){throw kn()}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 uO=t=>new jo(wb(t.readString(),t.readAny()));class ki{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ki(this.embed)}splice(e){throw kn()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const dO=t=>new ki(t.readJSON());class lt{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new lt(this.key,this.value)}splice(e){throw kn()}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 fO=t=>new lt(t.readKey(),t.readJSON());class ba{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ba(this.arr)}splice(e){const n=new ba(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 i=n;i<r;i++){const s=this.arr[i];e.writeString(s===void 0?"undefined":JSON.stringify(s))}}getRef(){return 2}}const hO=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const i=t.readString();i==="undefined"?n.push(void 0):n.push(JSON.parse(i))}return new ba(n)};class Ci{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Ci(this.arr)}splice(e){const n=new Ci(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 i=n;i<r;i++){const s=this.arr[i];e.writeAny(s)}}getRef(){return 8}}const pO=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new Ci(n)};class Cn{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Cn(this.str)}splice(e){const n=new Cn(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 mO=t=>new Cn(t.readString()),gO=[JM,YM,tO,rO,nO,sO,oO],yO=0,bO=1,vO=2,wO=3,xO=4,kO=5,CO=6;class Sn{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Sn(this.type._copy())}splice(e){throw kn()}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 SO=t=>new Sn(gO[t.readTypeRef()](t)),ff=(t,e)=>{let n=e,r=0,i;do r>0&&(n=ge(n.client,n.clock+r)),i=ps(t,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Ve);return{item:i,diff:r}},hf=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},va=(t,e,n)=>{const{client:r,clock:i}=e.id,s=new Ve(ge(r,i+n),e,ge(r,i+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&s.markDeleted(),e.keep&&(s.keep=!0),e.redone!==null&&(s.redone=ge(e.redone.client,e.redone.clock+n)),e.right=s,s.right!==null&&(s.right.left=s),t._mergeStructs.push(s),s.parentSub!==null&&s.right===null&&s.parent._map.set(s.parentSub,s),e.length=n,s},xb=(t,e)=>XA(t,n=>as(n.deletions,e)),kb=(t,e,n,r,i,s)=>{const o=t.doc,l=o.store,a=o.clientID,c=e.redone;if(c!==null)return Ut(t,c);let u=e.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||kb(t,u,n,r,i,s)===null))return null;for(;u.redone!==null;)u=Ut(t,u.redone)}const h=u===null?e.parent:u.content.type;if(e.parentSub===null){for(d=e.left,f=e;d!==null;){let w=d;for(;w!==null&&w.parent._item!==u;)w=w.redone===null?null:Ut(t,w.redone);if(w!==null&&w.parent._item===u){d=w;break}d=d.left}for(;f!==null;){let w=f;for(;w!==null&&w.parent._item!==u;)w=w.redone===null?null:Ut(t,w.redone);if(w!==null&&w.parent._item===u){f=w;break}f=f.right}}else if(f=null,e.right&&!i){for(d=e;d!==null&&d.right!==null&&(d.right.redone||as(r,d.right.id)||xb(s.undoStack,d.right.id)||xb(s.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Ut(t,d.redone);if(d&&d.right!==null)return null}else d=h._map.get(e.parentSub)||null;const p=rt(l,a),g=ge(a,p),v=new Ve(g,d,d&&d.lastId,f,f&&f.id,h,e.parentSub,e.content.copy());return e.redone=g,hf(v,!0),v.integrate(t,0),v};let Ve=class Fh extends df{constructor(e,n,r,i,s,o,l,a){super(e,a.getLength()),this.origin=r,this.left=n,this.right=i,this.rightOrigin=s,this.parent=o,this.parentSub=l,this.redone=null,this.content=a,this.info=this.content.isCountable()?Uy:0}set marker(e){(this.info&Sd)>0!==e&&(this.info^=Sd)}get marker(){return(this.info&Sd)>0}get keep(){return(this.info&Vy)>0}set keep(e){this.keep!==e&&(this.info^=Vy)}get countable(){return(this.info&Uy)>0}get deleted(){return(this.info&Cd)>0}set deleted(e){this.deleted!==e&&(this.info^=Cd)}markDeleted(){this.info|=Cd}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=rt(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=rt(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===fs&&this.id.client!==this.parent.client&&this.parent.clock>=rt(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=W0(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Ut(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===dn||this.right&&this.right.constructor===dn)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Fh&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===Fh&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===fs){const r=ps(n,this.parent);r.constructor===dn?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=W0(e,e.doc.store,ge(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,i;if(r!==null)i=r.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;const s=new Set,o=new Set;for(;i!==null&&i!==this.right;){if(o.add(i),s.add(i),hs(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,s.clear();else if(hs(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&o.has(ps(e.doc.store,i.origin)))s.has(ps(e.doc.store,i.origin))||(r=i,s.clear());else break;i=i.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),U0(e.doc.store,this),this.content.integrate(e,this),J0(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new dn(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:ge(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&hs(e.origin,this.lastId)&&this.right===e&&hs(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(),Oo(e.deleteSet,this.id.client,this.id.clock,this.length),J0(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw cn();this.content.gc(e),n?OM(e,this,new dn(this.id,this.length)):this.content=new Bo(this.length)}write(e,n){const r=n>0?ge(this.id.client,this.id.clock+n-1):this.origin,i=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&Ql|(r===null?0:Yt)|(i===null?0:cr)|(s===null?0:Co);if(e.writeInfo(o),r!==null&&e.writeLeftID(r),i!==null&&e.writeRightID(i),r===null&&i===null){const l=this.parent;if(l._item!==void 0){const a=l._item;if(a===null){const c=No(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===fs?(e.writeParentInfo(!1),e.writeLeftID(l)):cn();s!==null&&e.writeString(s)}this.content.write(e,n)}};const Cb=(t,e)=>EO[e&Ql](t),EO=[()=>{cn()},cO,hO,aO,mO,dO,fO,SO,pO,uO,()=>{cn()}],TO=10;class fn extends df{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){cn()}write(e,n){e.writeInfo(TO),ae(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const Sb=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Eb="__ $YJS$ __";Sb[Eb]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Sb[Eb]=!0;function wa(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Tb={exports:{}};(function(t,e){(function(n){t.exports=n()})(function(){var n=Math.floor,r=Math.abs,i=Math.pow;return function(){function s(o,l,a){function c(f,h){if(!l[f]){if(!o[f]){var p=typeof wa=="function"&&wa;if(!h&&p)return p(f,!0);if(u)return u(f,!0);var g=new Error("Cannot find module '"+f+"'");throw g.code="MODULE_NOT_FOUND",g}var v=l[f]={exports:{}};o[f][0].call(v.exports,function(w){var S=o[f][1][w];return c(S||w)},v,v.exports,s,o,l,a)}return l[f].exports}for(var u=typeof wa=="function"&&wa,d=0;d<a.length;d++)c(a[d]);return c}return s}()({1:[function(s,o,l){function a(y){var C=y.length;if(0<C%4)throw new Error("Invalid string. Length must be a multiple of 4");var E=y.indexOf("=");E===-1&&(E=C);var T=E===C?0:4-E%4;return[E,T]}function c(y,C,E){return 3*(C+E)/4-E}function u(y){var C,E,T=a(y),D=T[0],N=T[1],A=new v(c(y,D,N)),R=0,P=0<N?D-4:D;for(E=0;E<P;E+=4)C=g[y.charCodeAt(E)]<<18|g[y.charCodeAt(E+1)]<<12|g[y.charCodeAt(E+2)]<<6|g[y.charCodeAt(E+3)],A[R++]=255&C>>16,A[R++]=255&C>>8,A[R++]=255&C;return N===2&&(C=g[y.charCodeAt(E)]<<2|g[y.charCodeAt(E+1)]>>4,A[R++]=255&C),N===1&&(C=g[y.charCodeAt(E)]<<10|g[y.charCodeAt(E+1)]<<4|g[y.charCodeAt(E+2)]>>2,A[R++]=255&C>>8,A[R++]=255&C),A}function d(y){return p[63&y>>18]+p[63&y>>12]+p[63&y>>6]+p[63&y]}function f(y,C,E){for(var T,D=[],N=C;N<E;N+=3)T=(16711680&y[N]<<16)+(65280&y[N+1]<<8)+(255&y[N+2]),D.push(d(T));return D.join("")}function h(y){for(var C,E=y.length,T=E%3,D=[],N=16383,A=0,R=E-T;A<R;A+=N)D.push(f(y,A,A+N>R?R:A+N));return T===1?(C=y[E-1],D.push(p[C>>2]+p[63&C<<4]+"==")):T===2&&(C=(y[E-2]<<8)+y[E-1],D.push(p[C>>10]+p[63&C>>4]+p[63&C<<2]+"=")),D.join("")}l.byteLength=function(y){var C=a(y),E=C[0],T=C[1];return 3*(E+T)/4-T},l.toByteArray=u,l.fromByteArray=h;for(var p=[],g=[],v=typeof Uint8Array>"u"?Array:Uint8Array,w="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",S=0,x=w.length;S<x;++S)p[S]=w[S],g[w.charCodeAt(S)]=S;g[45]=62,g[95]=63},{}],2:[function(){},{}],3:[function(s,o,l){(function(){(function(){var a=String.fromCharCode,c=Math.min;function u(m){if(2147483647<m)throw new RangeError('The value "'+m+'" is invalid for option "size"');var b=new Uint8Array(m);return b.__proto__=d.prototype,b}function d(m,b,k){if(typeof m=="number"){if(typeof b=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(m)}return f(m,b,k)}function f(m,b,k){if(typeof m=="string")return v(m,b);if(ArrayBuffer.isView(m))return w(m);if(m==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof m);if($(m,ArrayBuffer)||m&&$(m.buffer,ArrayBuffer))return S(m,b,k);if(typeof m=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var I=m.valueOf&&m.valueOf();if(I!=null&&I!==m)return d.from(I,b,k);var F=x(m);if(F)return F;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof m[Symbol.toPrimitive]=="function")return d.from(m[Symbol.toPrimitive]("string"),b,k);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof m)}function h(m){if(typeof m!="number")throw new TypeError('"size" argument must be of type number');if(0>m)throw new RangeError('The value "'+m+'" is invalid for option "size"')}function p(m,b,k){return h(m),0>=m||b===void 0?u(m):typeof k=="string"?u(m).fill(b,k):u(m).fill(b)}function g(m){return h(m),u(0>m?0:0|y(m))}function v(m,b){if((typeof b!="string"||b==="")&&(b="utf8"),!d.isEncoding(b))throw new TypeError("Unknown encoding: "+b);var k=0|C(m,b),I=u(k),F=I.write(m,b);return F!==k&&(I=I.slice(0,F)),I}function w(m){for(var b=0>m.length?0:0|y(m.length),k=u(b),I=0;I<b;I+=1)k[I]=255&m[I];return k}function S(m,b,k){if(0>b||m.byteLength<b)throw new RangeError('"offset" is outside of buffer bounds');if(m.byteLength<b+(k||0))throw new RangeError('"length" is outside of buffer bounds');var I;return I=b===void 0&&k===void 0?new Uint8Array(m):k===void 0?new Uint8Array(m,b):new Uint8Array(m,b,k),I.__proto__=d.prototype,I}function x(m){if(d.isBuffer(m)){var b=0|y(m.length),k=u(b);return k.length===0||m.copy(k,0,0,b),k}return m.length===void 0?m.type==="Buffer"&&Array.isArray(m.data)?w(m.data):void 0:typeof m.length!="number"||j(m.length)?u(0):w(m)}function y(m){if(m>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|m}function C(m,b){if(d.isBuffer(m))return m.length;if(ArrayBuffer.isView(m)||$(m,ArrayBuffer))return m.byteLength;if(typeof m!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof m);var k=m.length,I=2<arguments.length&&arguments[2]===!0;if(!I&&k===0)return 0;for(var F=!1;;)switch(b){case"ascii":case"latin1":case"binary":return k;case"utf8":case"utf-8":return Ye(m).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*k;case"hex":return k>>>1;case"base64":return it(m).length;default:if(F)return I?-1:Ye(m).length;b=(""+b).toLowerCase(),F=!0}}function E(m,b,k){var I=!1;if((b===void 0||0>b)&&(b=0),b>this.length||((k===void 0||k>this.length)&&(k=this.length),0>=k)||(k>>>=0,b>>>=0,k<=b))return"";for(m||(m="utf8");;)switch(m){case"hex":return Le(this,b,k);case"utf8":case"utf-8":return G(this,b,k);case"ascii":return Z(this,b,k);case"latin1":case"binary":return ke(this,b,k);case"base64":return J(this,b,k);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $e(this,b,k);default:if(I)throw new TypeError("Unknown encoding: "+m);m=(m+"").toLowerCase(),I=!0}}function T(m,b,k){var I=m[b];m[b]=m[k],m[k]=I}function D(m,b,k,I,F){if(m.length===0)return-1;if(typeof k=="string"?(I=k,k=0):2147483647<k?k=2147483647:-2147483648>k&&(k=-2147483648),k=+k,j(k)&&(k=F?0:m.length-1),0>k&&(k=m.length+k),k>=m.length){if(F)return-1;k=m.length-1}else if(0>k)if(F)k=0;else return-1;if(typeof b=="string"&&(b=d.from(b,I)),d.isBuffer(b))return b.length===0?-1:N(m,b,k,I,F);if(typeof b=="number")return b&=255,typeof Uint8Array.prototype.indexOf=="function"?F?Uint8Array.prototype.indexOf.call(m,b,k):Uint8Array.prototype.lastIndexOf.call(m,b,k):N(m,[b],k,I,F);throw new TypeError("val must be string, number or Buffer")}function N(m,b,k,I,F){function H(Qn,V){return ne===1?Qn[V]:Qn.readUInt16BE(V*ne)}var ne=1,de=m.length,_e=b.length;if(I!==void 0&&(I=(I+"").toLowerCase(),I==="ucs2"||I==="ucs-2"||I==="utf16le"||I==="utf-16le")){if(2>m.length||2>b.length)return-1;ne=2,de/=2,_e/=2,k/=2}var we;if(F){var ye=-1;for(we=k;we<de;we++)if(H(m,we)!==H(b,ye===-1?0:we-ye))ye!==-1&&(we-=we-ye),ye=-1;else if(ye===-1&&(ye=we),we-ye+1===_e)return ye*ne}else for(k+_e>de&&(k=de-_e),we=k;0<=we;we--){for(var Xe=!0,Mn=0;Mn<_e;Mn++)if(H(m,we+Mn)!==H(b,Mn)){Xe=!1;break}if(Xe)return we}return-1}function A(m,b,k,I){k=+k||0;var F=m.length-k;I?(I=+I,I>F&&(I=F)):I=F;var H=b.length;I>H/2&&(I=H/2);for(var ne,de=0;de<I;++de){if(ne=parseInt(b.substr(2*de,2),16),j(ne))return de;m[k+de]=ne}return de}function R(m,b,k,I){return at(Ye(b,m.length-k),m,k,I)}function P(m,b,k,I){return at(Ot(b),m,k,I)}function B(m,b,k,I){return P(m,b,k,I)}function z(m,b,k,I){return at(it(b),m,k,I)}function U(m,b,k,I){return at(xt(b,m.length-k),m,k,I)}function J(m,b,k){return b===0&&k===m.length?q.fromByteArray(m):q.fromByteArray(m.slice(b,k))}function G(m,b,k){k=c(m.length,k);for(var I=[],F=b;F<k;){var H=m[F],ne=null,de=239<H?4:223<H?3:191<H?2:1;if(F+de<=k){var _e,we,ye,Xe;de===1?128>H&&(ne=H):de===2?(_e=m[F+1],(192&_e)==128&&(Xe=(31&H)<<6|63&_e,127<Xe&&(ne=Xe))):de===3?(_e=m[F+1],we=m[F+2],(192&_e)==128&&(192&we)==128&&(Xe=(15&H)<<12|(63&_e)<<6|63&we,2047<Xe&&(55296>Xe||57343<Xe)&&(ne=Xe))):de===4&&(_e=m[F+1],we=m[F+2],ye=m[F+3],(192&_e)==128&&(192&we)==128&&(192&ye)==128&&(Xe=(15&H)<<18|(63&_e)<<12|(63&we)<<6|63&ye,65535<Xe&&1114112>Xe&&(ne=Xe)))}ne===null?(ne=65533,de=1):65535<ne&&(ne-=65536,I.push(55296|1023&ne>>>10),ne=56320|1023&ne),I.push(ne),F+=de}return ie(I)}function ie(m){var b=m.length;if(b<=4096)return a.apply(String,m);for(var k="",I=0;I<b;)k+=a.apply(String,m.slice(I,I+=4096));return k}function Z(m,b,k){var I="";k=c(m.length,k);for(var F=b;F<k;++F)I+=a(127&m[F]);return I}function ke(m,b,k){var I="";k=c(m.length,k);for(var F=b;F<k;++F)I+=a(m[F]);return I}function Le(m,b,k){var I=m.length;(!b||0>b)&&(b=0),(!k||0>k||k>I)&&(k=I);for(var F="",H=b;H<k;++H)F+=Ge(m[H]);return F}function $e(m,b,k){for(var I=m.slice(b,k),F="",H=0;H<I.length;H+=2)F+=a(I[H]+256*I[H+1]);return F}function Ee(m,b,k){if(m%1!=0||0>m)throw new RangeError("offset is not uint");if(m+b>k)throw new RangeError("Trying to access beyond buffer length")}function ve(m,b,k,I,F,H){if(!d.isBuffer(m))throw new TypeError('"buffer" argument must be a Buffer instance');if(b>F||b<H)throw new RangeError('"value" argument is out of bounds');if(k+I>m.length)throw new RangeError("Index out of range")}function De(m,b,k,I){if(k+I>m.length)throw new RangeError("Index out of range");if(0>k)throw new RangeError("Index out of range")}function Ie(m,b,k,I,F){return b=+b,k>>>=0,F||De(m,b,k,4),te.write(m,b,k,I,23,4),k+4}function tt(m,b,k,I,F){return b=+b,k>>>=0,F||De(m,b,k,8),te.write(m,b,k,I,52,8),k+8}function nt(m){if(m=m.split("=")[0],m=m.trim().replace(M,""),2>m.length)return"";for(;m.length%4!=0;)m+="=";return m}function Ge(m){return 16>m?"0"+m.toString(16):m.toString(16)}function Ye(m,b){b=b||1/0;for(var k,I=m.length,F=null,H=[],ne=0;ne<I;++ne){if(k=m.charCodeAt(ne),55295<k&&57344>k){if(!F){if(56319<k){-1<(b-=3)&&H.push(239,191,189);continue}else if(ne+1===I){-1<(b-=3)&&H.push(239,191,189);continue}F=k;continue}if(56320>k){-1<(b-=3)&&H.push(239,191,189),F=k;continue}k=(F-55296<<10|k-56320)+65536}else F&&-1<(b-=3)&&H.push(239,191,189);if(F=null,128>k){if(0>(b-=1))break;H.push(k)}else if(2048>k){if(0>(b-=2))break;H.push(192|k>>6,128|63&k)}else if(65536>k){if(0>(b-=3))break;H.push(224|k>>12,128|63&k>>6,128|63&k)}else if(1114112>k){if(0>(b-=4))break;H.push(240|k>>18,128|63&k>>12,128|63&k>>6,128|63&k)}else throw new Error("Invalid code point")}return H}function Ot(m){for(var b=[],k=0;k<m.length;++k)b.push(255&m.charCodeAt(k));return b}function xt(m,b){for(var k,I,F,H=[],ne=0;ne<m.length&&!(0>(b-=2));++ne)k=m.charCodeAt(ne),I=k>>8,F=k%256,H.push(F),H.push(I);return H}function it(m){return q.toByteArray(nt(m))}function at(m,b,k,I){for(var F=0;F<I&&!(F+k>=b.length||F>=m.length);++F)b[F+k]=m[F];return F}function $(m,b){return m instanceof b||m!=null&&m.constructor!=null&&m.constructor.name!=null&&m.constructor.name===b.name}function j(m){return m!==m}var q=s("base64-js"),te=s("ieee754");l.Buffer=d,l.SlowBuffer=function(m){return+m!=m&&(m=0),d.alloc(+m)},l.INSPECT_MAX_BYTES=50,l.kMaxLength=2147483647,d.TYPED_ARRAY_SUPPORT=function(){try{var m=new Uint8Array(1);return m.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},m.foo()===42}catch{return!1}}(),d.TYPED_ARRAY_SUPPORT||typeof console>"u"||typeof console.error!="function"||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){return d.isBuffer(this)?this.buffer:void 0}}),Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){return d.isBuffer(this)?this.byteOffset:void 0}}),typeof Symbol<"u"&&Symbol.species!=null&&d[Symbol.species]===d&&Object.defineProperty(d,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),d.poolSize=8192,d.from=function(m,b,k){return f(m,b,k)},d.prototype.__proto__=Uint8Array.prototype,d.__proto__=Uint8Array,d.alloc=function(m,b,k){return p(m,b,k)},d.allocUnsafe=function(m){return g(m)},d.allocUnsafeSlow=function(m){return g(m)},d.isBuffer=function(m){return m!=null&&m._isBuffer===!0&&m!==d.prototype},d.compare=function(m,b){if($(m,Uint8Array)&&(m=d.from(m,m.offset,m.byteLength)),$(b,Uint8Array)&&(b=d.from(b,b.offset,b.byteLength)),!d.isBuffer(m)||!d.isBuffer(b))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(m===b)return 0;for(var k=m.length,I=b.length,F=0,H=c(k,I);F<H;++F)if(m[F]!==b[F]){k=m[F],I=b[F];break}return k<I?-1:I<k?1:0},d.isEncoding=function(m){switch((m+"").toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},d.concat=function(m,b){if(!Array.isArray(m))throw new TypeError('"list" argument must be an Array of Buffers');if(m.length===0)return d.alloc(0);var k;if(b===void 0)for(b=0,k=0;k<m.length;++k)b+=m[k].length;var I=d.allocUnsafe(b),F=0;for(k=0;k<m.length;++k){var H=m[k];if($(H,Uint8Array)&&(H=d.from(H)),!d.isBuffer(H))throw new TypeError('"list" argument must be an Array of Buffers');H.copy(I,F),F+=H.length}return I},d.byteLength=C,d.prototype._isBuffer=!0,d.prototype.swap16=function(){var m=this.length;if(m%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var b=0;b<m;b+=2)T(this,b,b+1);return this},d.prototype.swap32=function(){var m=this.length;if(m%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var b=0;b<m;b+=4)T(this,b,b+3),T(this,b+1,b+2);return this},d.prototype.swap64=function(){var m=this.length;if(m%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var b=0;b<m;b+=8)T(this,b,b+7),T(this,b+1,b+6),T(this,b+2,b+5),T(this,b+3,b+4);return this},d.prototype.toString=function(){var m=this.length;return m===0?"":arguments.length===0?G(this,0,m):E.apply(this,arguments)},d.prototype.toLocaleString=d.prototype.toString,d.prototype.equals=function(m){if(!d.isBuffer(m))throw new TypeError("Argument must be a Buffer");return this===m||d.compare(this,m)===0},d.prototype.inspect=function(){var m="",b=l.INSPECT_MAX_BYTES;return m=this.toString("hex",0,b).replace(/(.{2})/g,"$1 ").trim(),this.length>b&&(m+=" ... "),"<Buffer "+m+">"},d.prototype.compare=function(m,b,k,I,F){if($(m,Uint8Array)&&(m=d.from(m,m.offset,m.byteLength)),!d.isBuffer(m))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof m);if(b===void 0&&(b=0),k===void 0&&(k=m?m.length:0),I===void 0&&(I=0),F===void 0&&(F=this.length),0>b||k>m.length||0>I||F>this.length)throw new RangeError("out of range index");if(I>=F&&b>=k)return 0;if(I>=F)return-1;if(b>=k)return 1;if(b>>>=0,k>>>=0,I>>>=0,F>>>=0,this===m)return 0;for(var H=F-I,ne=k-b,de=c(H,ne),_e=this.slice(I,F),we=m.slice(b,k),ye=0;ye<de;++ye)if(_e[ye]!==we[ye]){H=_e[ye],ne=we[ye];break}return H<ne?-1:ne<H?1:0},d.prototype.includes=function(m,b,k){return this.indexOf(m,b,k)!==-1},d.prototype.indexOf=function(m,b,k){return D(this,m,b,k,!0)},d.prototype.lastIndexOf=function(m,b,k){return D(this,m,b,k,!1)},d.prototype.write=function(m,b,k,I){if(b===void 0)I="utf8",k=this.length,b=0;else if(k===void 0&&typeof b=="string")I=b,k=this.length,b=0;else if(isFinite(b))b>>>=0,isFinite(k)?(k>>>=0,I===void 0&&(I="utf8")):(I=k,k=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var F=this.length-b;if((k===void 0||k>F)&&(k=F),0<m.length&&(0>k||0>b)||b>this.length)throw new RangeError("Attempt to write outside buffer bounds");I||(I="utf8");for(var H=!1;;)switch(I){case"hex":return A(this,m,b,k);case"utf8":case"utf-8":return R(this,m,b,k);case"ascii":return P(this,m,b,k);case"latin1":case"binary":return B(this,m,b,k);case"base64":return z(this,m,b,k);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,m,b,k);default:if(H)throw new TypeError("Unknown encoding: "+I);I=(""+I).toLowerCase(),H=!0}},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},d.prototype.slice=function(m,b){var k=this.length;m=~~m,b=b===void 0?k:~~b,0>m?(m+=k,0>m&&(m=0)):m>k&&(m=k),0>b?(b+=k,0>b&&(b=0)):b>k&&(b=k),b<m&&(b=m);var I=this.subarray(m,b);return I.__proto__=d.prototype,I},d.prototype.readUIntLE=function(m,b,k){m>>>=0,b>>>=0,k||Ee(m,b,this.length);for(var I=this[m],F=1,H=0;++H<b&&(F*=256);)I+=this[m+H]*F;return I},d.prototype.readUIntBE=function(m,b,k){m>>>=0,b>>>=0,k||Ee(m,b,this.length);for(var I=this[m+--b],F=1;0<b&&(F*=256);)I+=this[m+--b]*F;return I},d.prototype.readUInt8=function(m,b){return m>>>=0,b||Ee(m,1,this.length),this[m]},d.prototype.readUInt16LE=function(m,b){return m>>>=0,b||Ee(m,2,this.length),this[m]|this[m+1]<<8},d.prototype.readUInt16BE=function(m,b){return m>>>=0,b||Ee(m,2,this.length),this[m]<<8|this[m+1]},d.prototype.readUInt32LE=function(m,b){return m>>>=0,b||Ee(m,4,this.length),(this[m]|this[m+1]<<8|this[m+2]<<16)+16777216*this[m+3]},d.prototype.readUInt32BE=function(m,b){return m>>>=0,b||Ee(m,4,this.length),16777216*this[m]+(this[m+1]<<16|this[m+2]<<8|this[m+3])},d.prototype.readIntLE=function(m,b,k){m>>>=0,b>>>=0,k||Ee(m,b,this.length);for(var I=this[m],F=1,H=0;++H<b&&(F*=256);)I+=this[m+H]*F;return F*=128,I>=F&&(I-=i(2,8*b)),I},d.prototype.readIntBE=function(m,b,k){m>>>=0,b>>>=0,k||Ee(m,b,this.length);for(var I=b,F=1,H=this[m+--I];0<I&&(F*=256);)H+=this[m+--I]*F;return F*=128,H>=F&&(H-=i(2,8*b)),H},d.prototype.readInt8=function(m,b){return m>>>=0,b||Ee(m,1,this.length),128&this[m]?-1*(255-this[m]+1):this[m]},d.prototype.readInt16LE=function(m,b){m>>>=0,b||Ee(m,2,this.length);var k=this[m]|this[m+1]<<8;return 32768&k?4294901760|k:k},d.prototype.readInt16BE=function(m,b){m>>>=0,b||Ee(m,2,this.length);var k=this[m+1]|this[m]<<8;return 32768&k?4294901760|k:k},d.prototype.readInt32LE=function(m,b){return m>>>=0,b||Ee(m,4,this.length),this[m]|this[m+1]<<8|this[m+2]<<16|this[m+3]<<24},d.prototype.readInt32BE=function(m,b){return m>>>=0,b||Ee(m,4,this.length),this[m]<<24|this[m+1]<<16|this[m+2]<<8|this[m+3]},d.prototype.readFloatLE=function(m,b){return m>>>=0,b||Ee(m,4,this.length),te.read(this,m,!0,23,4)},d.prototype.readFloatBE=function(m,b){return m>>>=0,b||Ee(m,4,this.length),te.read(this,m,!1,23,4)},d.prototype.readDoubleLE=function(m,b){return m>>>=0,b||Ee(m,8,this.length),te.read(this,m,!0,52,8)},d.prototype.readDoubleBE=function(m,b){return m>>>=0,b||Ee(m,8,this.length),te.read(this,m,!1,52,8)},d.prototype.writeUIntLE=function(m,b,k,I){if(m=+m,b>>>=0,k>>>=0,!I){var F=i(2,8*k)-1;ve(this,m,b,k,F,0)}var H=1,ne=0;for(this[b]=255&m;++ne<k&&(H*=256);)this[b+ne]=255&m/H;return b+k},d.prototype.writeUIntBE=function(m,b,k,I){if(m=+m,b>>>=0,k>>>=0,!I){var F=i(2,8*k)-1;ve(this,m,b,k,F,0)}var H=k-1,ne=1;for(this[b+H]=255&m;0<=--H&&(ne*=256);)this[b+H]=255&m/ne;return b+k},d.prototype.writeUInt8=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,1,255,0),this[b]=255&m,b+1},d.prototype.writeUInt16LE=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,2,65535,0),this[b]=255&m,this[b+1]=m>>>8,b+2},d.prototype.writeUInt16BE=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,2,65535,0),this[b]=m>>>8,this[b+1]=255&m,b+2},d.prototype.writeUInt32LE=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,4,4294967295,0),this[b+3]=m>>>24,this[b+2]=m>>>16,this[b+1]=m>>>8,this[b]=255&m,b+4},d.prototype.writeUInt32BE=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,4,4294967295,0),this[b]=m>>>24,this[b+1]=m>>>16,this[b+2]=m>>>8,this[b+3]=255&m,b+4},d.prototype.writeIntLE=function(m,b,k,I){if(m=+m,b>>>=0,!I){var F=i(2,8*k-1);ve(this,m,b,k,F-1,-F)}var H=0,ne=1,de=0;for(this[b]=255&m;++H<k&&(ne*=256);)0>m&&de===0&&this[b+H-1]!==0&&(de=1),this[b+H]=255&(m/ne>>0)-de;return b+k},d.prototype.writeIntBE=function(m,b,k,I){if(m=+m,b>>>=0,!I){var F=i(2,8*k-1);ve(this,m,b,k,F-1,-F)}var H=k-1,ne=1,de=0;for(this[b+H]=255&m;0<=--H&&(ne*=256);)0>m&&de===0&&this[b+H+1]!==0&&(de=1),this[b+H]=255&(m/ne>>0)-de;return b+k},d.prototype.writeInt8=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,1,127,-128),0>m&&(m=255+m+1),this[b]=255&m,b+1},d.prototype.writeInt16LE=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,2,32767,-32768),this[b]=255&m,this[b+1]=m>>>8,b+2},d.prototype.writeInt16BE=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,2,32767,-32768),this[b]=m>>>8,this[b+1]=255&m,b+2},d.prototype.writeInt32LE=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,4,2147483647,-2147483648),this[b]=255&m,this[b+1]=m>>>8,this[b+2]=m>>>16,this[b+3]=m>>>24,b+4},d.prototype.writeInt32BE=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,4,2147483647,-2147483648),0>m&&(m=4294967295+m+1),this[b]=m>>>24,this[b+1]=m>>>16,this[b+2]=m>>>8,this[b+3]=255&m,b+4},d.prototype.writeFloatLE=function(m,b,k){return Ie(this,m,b,!0,k)},d.prototype.writeFloatBE=function(m,b,k){return Ie(this,m,b,!1,k)},d.prototype.writeDoubleLE=function(m,b,k){return tt(this,m,b,!0,k)},d.prototype.writeDoubleBE=function(m,b,k){return tt(this,m,b,!1,k)},d.prototype.copy=function(m,b,k,I){if(!d.isBuffer(m))throw new TypeError("argument should be a Buffer");if(k||(k=0),I||I===0||(I=this.length),b>=m.length&&(b=m.length),b||(b=0),0<I&&I<k&&(I=k),I===k||m.length===0||this.length===0)return 0;if(0>b)throw new RangeError("targetStart out of bounds");if(0>k||k>=this.length)throw new RangeError("Index out of range");if(0>I)throw new RangeError("sourceEnd out of bounds");I>this.length&&(I=this.length),m.length-b<I-k&&(I=m.length-b+k);var F=I-k;if(this===m&&typeof Uint8Array.prototype.copyWithin=="function")this.copyWithin(b,k,I);else if(this===m&&k<b&&b<I)for(var H=F-1;0<=H;--H)m[H+b]=this[H+k];else Uint8Array.prototype.set.call(m,this.subarray(k,I),b);return F},d.prototype.fill=function(m,b,k,I){if(typeof m=="string"){if(typeof b=="string"?(I=b,b=0,k=this.length):typeof k=="string"&&(I=k,k=this.length),I!==void 0&&typeof I!="string")throw new TypeError("encoding must be a string");if(typeof I=="string"&&!d.isEncoding(I))throw new TypeError("Unknown encoding: "+I);if(m.length===1){var F=m.charCodeAt(0);(I==="utf8"&&128>F||I==="latin1")&&(m=F)}}else typeof m=="number"&&(m&=255);if(0>b||this.length<b||this.length<k)throw new RangeError("Out of range index");if(k<=b)return this;b>>>=0,k=k===void 0?this.length:k>>>0,m||(m=0);var H;if(typeof m=="number")for(H=b;H<k;++H)this[H]=m;else{var ne=d.isBuffer(m)?m:d.from(m,I),de=ne.length;if(de===0)throw new TypeError('The value "'+m+'" is invalid for argument "value"');for(H=0;H<k-b;++H)this[H+b]=ne[H%de]}return this};var M=/[^+/0-9A-Za-z-_]/g}).call(this)}).call(this,s("buffer").Buffer)},{"base64-js":1,buffer:3,ieee754:9}],4:[function(s,o,l){(function(a){(function(){function c(){let d;try{d=l.storage.getItem("debug")}catch{}return!d&&typeof a<"u"&&"env"in a&&(d=a.env.DEBUG),d}l.formatArgs=function(d){if(d[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+d[0]+(this.useColors?"%c ":" ")+"+"+o.exports.humanize(this.diff),!this.useColors)return;const f="color: "+this.color;d.splice(1,0,f,"color: inherit");let h=0,p=0;d[0].replace(/%[a-zA-Z%]/g,g=>{g==="%%"||(h++,g==="%c"&&(p=h))}),d.splice(p,0,f)},l.save=function(d){try{d?l.storage.setItem("debug",d):l.storage.removeItem("debug")}catch{}},l.load=c,l.useColors=function(){return!!(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&31<=parseInt(RegExp.$1,10)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},l.storage=function(){try{return localStorage}catch{}}(),l.destroy=(()=>{let d=!1;return()=>{d||(d=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),l.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],l.log=console.debug||console.log||(()=>{}),o.exports=s("./common")(l);const{formatters:u}=o.exports;u.j=function(d){try{return JSON.stringify(d)}catch(f){return"[UnexpectedJSONParseError]: "+f.message}}}).call(this)}).call(this,s("_process"))},{"./common":5,_process:12}],5:[function(s,o){o.exports=function(l){function a(d){function f(...g){if(!f.enabled)return;const v=f,w=+new Date,S=w-(h||w);v.diff=S,v.prev=h,v.curr=w,h=w,g[0]=a.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let x=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(C,E)=>{if(C==="%%")return"%";x++;const T=a.formatters[E];if(typeof T=="function"){const D=g[x];C=T.call(v,D),g.splice(x,1),x--}return C}),a.formatArgs.call(v,g),(v.log||a.log).apply(v,g)}let h,p=null;return f.namespace=d,f.useColors=a.useColors(),f.color=a.selectColor(d),f.extend=c,f.destroy=a.destroy,Object.defineProperty(f,"enabled",{enumerable:!0,configurable:!1,get:()=>p===null?a.enabled(d):p,set:g=>{p=g}}),typeof a.init=="function"&&a.init(f),f}function c(d,f){const h=a(this.namespace+(typeof f>"u"?":":f)+d);return h.log=this.log,h}function u(d){return d.toString().substring(2,d.toString().length-2).replace(/\.\*\?$/,"*")}return a.debug=a,a.default=a,a.coerce=function(d){return d instanceof Error?d.stack||d.message:d},a.disable=function(){const d=[...a.names.map(u),...a.skips.map(u).map(f=>"-"+f)].join(",");return a.enable(""),d},a.enable=function(d){a.save(d),a.names=[],a.skips=[];let f;const h=(typeof d=="string"?d:"").split(/[\s,]+/),p=h.length;for(f=0;f<p;f++)h[f]&&(d=h[f].replace(/\*/g,".*?"),d[0]==="-"?a.skips.push(new RegExp("^"+d.substr(1)+"$")):a.names.push(new RegExp("^"+d+"$")))},a.enabled=function(d){if(d[d.length-1]==="*")return!0;let f,h;for(f=0,h=a.skips.length;f<h;f++)if(a.skips[f].test(d))return!1;for(f=0,h=a.names.length;f<h;f++)if(a.names[f].test(d))return!0;return!1},a.humanize=s("ms"),a.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(l).forEach(d=>{a[d]=l[d]}),a.names=[],a.skips=[],a.formatters={},a.selectColor=function(d){let f=0;for(let h=0;h<d.length;h++)f=(f<<5)-f+d.charCodeAt(h),f|=0;return a.colors[r(f)%a.colors.length]},a.enable(a.load()),a}},{ms:11}],6:[function(s,o){function l(a,c){for(const u in c)Object.defineProperty(a,u,{value:c[u],enumerable:!0,configurable:!0});return a}o.exports=function(a,c,u){if(!a||typeof a=="string")throw new TypeError("Please pass an Error to err-code");u||(u={}),typeof c=="object"&&(u=c,c=""),c&&(u.code=c);try{return l(a,u)}catch{u.message=a.message,u.stack=a.stack;const f=function(){};return f.prototype=Object.create(Object.getPrototypeOf(a)),l(new f,u)}}},{}],7:[function(s,o){function l(A){console&&console.warn&&console.warn(A)}function a(){a.init.call(this)}function c(A){if(typeof A!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof A)}function u(A){return A._maxListeners===void 0?a.defaultMaxListeners:A._maxListeners}function d(A,R,P,B){var z,U,J;if(c(P),U=A._events,U===void 0?(U=A._events=Object.create(null),A._eventsCount=0):(U.newListener!==void 0&&(A.emit("newListener",R,P.listener?P.listener:P),U=A._events),J=U[R]),J===void 0)J=U[R]=P,++A._eventsCount;else if(typeof J=="function"?J=U[R]=B?[P,J]:[J,P]:B?J.unshift(P):J.push(P),z=u(A),0<z&&J.length>z&&!J.warned){J.warned=!0;var G=new Error("Possible EventEmitter memory leak detected. "+J.length+" "+(R+" listeners added. Use emitter.setMaxListeners() to increase limit"));G.name="MaxListenersExceededWarning",G.emitter=A,G.type=R,G.count=J.length,l(G)}return A}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(A,R,P){var B={fired:!1,wrapFn:void 0,target:A,type:R,listener:P},z=f.bind(B);return z.listener=P,B.wrapFn=z,z}function p(A,R,P){var B=A._events;if(B===void 0)return[];var z=B[R];return z===void 0?[]:typeof z=="function"?P?[z.listener||z]:[z]:P?S(z):v(z,z.length)}function g(A){var R=this._events;if(R!==void 0){var P=R[A];if(typeof P=="function")return 1;if(P!==void 0)return P.length}return 0}function v(A,R){for(var P=Array(R),B=0;B<R;++B)P[B]=A[B];return P}function w(A,R){for(;R+1<A.length;R++)A[R]=A[R+1];A.pop()}function S(A){for(var R=Array(A.length),P=0;P<R.length;++P)R[P]=A[P].listener||A[P];return R}function x(A,R,P){typeof A.on=="function"&&y(A,"error",R,P)}function y(A,R,P,B){if(typeof A.on=="function")B.once?A.once(R,P):A.on(R,P);else if(typeof A.addEventListener=="function")A.addEventListener(R,function z(U){B.once&&A.removeEventListener(R,z),P(U)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof A)}var C,E=typeof Reflect=="object"?Reflect:null,T=E&&typeof E.apply=="function"?E.apply:function(A,R,P){return Function.prototype.apply.call(A,R,P)};C=E&&typeof E.ownKeys=="function"?E.ownKeys:Object.getOwnPropertySymbols?function(A){return Object.getOwnPropertyNames(A).concat(Object.getOwnPropertySymbols(A))}:function(A){return Object.getOwnPropertyNames(A)};var D=Number.isNaN||function(A){return A!==A};o.exports=a,o.exports.once=function(A,R){return new Promise(function(P,B){function z(J){A.removeListener(R,U),B(J)}function U(){typeof A.removeListener=="function"&&A.removeListener("error",z),P([].slice.call(arguments))}y(A,R,U,{once:!0}),R!=="error"&&x(A,z,{once:!0})})},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var N=10;Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return N},set:function(A){if(typeof A!="number"||0>A||D(A))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+A+".");N=A}}),a.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(A){if(typeof A!="number"||0>A||D(A))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+A+".");return this._maxListeners=A,this},a.prototype.getMaxListeners=function(){return u(this)},a.prototype.emit=function(A){for(var R=[],P=1;P<arguments.length;P++)R.push(arguments[P]);var B=A==="error",z=this._events;if(z!==void 0)B=B&&z.error===void 0;else if(!B)return!1;if(B){var U;if(0<R.length&&(U=R[0]),U instanceof Error)throw U;var J=new Error("Unhandled error."+(U?" ("+U.message+")":""));throw J.context=U,J}var G=z[A];if(G===void 0)return!1;if(typeof G=="function")T(G,this,R);else for(var ie=G.length,Z=v(G,ie),P=0;P<ie;++P)T(Z[P],this,R);return!0},a.prototype.addListener=function(A,R){return d(this,A,R,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(A,R){return d(this,A,R,!0)},a.prototype.once=function(A,R){return c(R),this.on(A,h(this,A,R)),this},a.prototype.prependOnceListener=function(A,R){return c(R),this.prependListener(A,h(this,A,R)),this},a.prototype.removeListener=function(A,R){var P,B,z,U,J;if(c(R),B=this._events,B===void 0)return this;if(P=B[A],P===void 0)return this;if(P===R||P.listener===R)--this._eventsCount==0?this._events=Object.create(null):(delete B[A],B.removeListener&&this.emit("removeListener",A,P.listener||R));else if(typeof P!="function"){for(z=-1,U=P.length-1;0<=U;U--)if(P[U]===R||P[U].listener===R){J=P[U].listener,z=U;break}if(0>z)return this;z===0?P.shift():w(P,z),P.length===1&&(B[A]=P[0]),B.removeListener!==void 0&&this.emit("removeListener",A,J||R)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(A){var R,P,B;if(P=this._events,P===void 0)return this;if(P.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):P[A]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete P[A]),this;if(arguments.length===0){var z,U=Object.keys(P);for(B=0;B<U.length;++B)z=U[B],z!=="removeListener"&&this.removeAllListeners(z);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(R=P[A],typeof R=="function")this.removeListener(A,R);else if(R!==void 0)for(B=R.length-1;0<=B;B--)this.removeListener(A,R[B]);return this},a.prototype.listeners=function(A){return p(this,A,!0)},a.prototype.rawListeners=function(A){return p(this,A,!1)},a.listenerCount=function(A,R){return typeof A.listenerCount=="function"?A.listenerCount(R):g.call(A,R)},a.prototype.listenerCount=g,a.prototype.eventNames=function(){return 0<this._eventsCount?C(this._events):[]}},{}],8:[function(s,o){o.exports=function(){if(typeof globalThis>"u")return null;var l={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return l.RTCPeerConnection?l:null}},{}],9:[function(s,o,l){/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */l.read=function(a,c,u,d,f){var h,p,g=8*f-d-1,v=(1<<g)-1,w=v>>1,S=-7,x=u?f-1:0,y=u?-1:1,C=a[c+x];for(x+=y,h=C&(1<<-S)-1,C>>=-S,S+=g;0<S;h=256*h+a[c+x],x+=y,S-=8);for(p=h&(1<<-S)-1,h>>=-S,S+=d;0<S;p=256*p+a[c+x],x+=y,S-=8);if(h===0)h=1-w;else{if(h===v)return p?NaN:(C?-1:1)*(1/0);p+=i(2,d),h-=w}return(C?-1:1)*p*i(2,h-d)},l.write=function(a,c,u,d,f,h){var p,g,v,w=Math.LN2,S=Math.log,x=8*h-f-1,y=(1<<x)-1,C=y>>1,E=f===23?i(2,-24)-i(2,-77):0,T=d?0:h-1,D=d?1:-1,N=0>c||c===0&&0>1/c?1:0;for(c=r(c),isNaN(c)||c===1/0?(g=isNaN(c)?1:0,p=y):(p=n(S(c)/w),1>c*(v=i(2,-p))&&(p--,v*=2),c+=1<=p+C?E/v:E*i(2,1-C),2<=c*v&&(p++,v/=2),p+C>=y?(g=0,p=y):1<=p+C?(g=(c*v-1)*i(2,f),p+=C):(g=c*i(2,C-1)*i(2,f),p=0));8<=f;a[u+T]=255&g,T+=D,g/=256,f-=8);for(p=p<<f|g,x+=f;0<x;a[u+T]=255&p,T+=D,p/=256,x-=8);a[u+T-D]|=128*N}},{}],10:[function(s,o){o.exports=typeof Object.create=="function"?function(l,a){a&&(l.super_=a,l.prototype=Object.create(a.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}))}:function(l,a){if(a){l.super_=a;var c=function(){};c.prototype=a.prototype,l.prototype=new c,l.prototype.constructor=l}}},{}],11:[function(s,o){var l=Math.round;function a(f){if(f+="",!(100<f.length)){var h=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(f);if(h){var p=parseFloat(h[1]),g=(h[2]||"ms").toLowerCase();return g==="years"||g==="year"||g==="yrs"||g==="yr"||g==="y"?315576e5*p:g==="weeks"||g==="week"||g==="w"?6048e5*p:g==="days"||g==="day"||g==="d"?864e5*p:g==="hours"||g==="hour"||g==="hrs"||g==="hr"||g==="h"?36e5*p:g==="minutes"||g==="minute"||g==="mins"||g==="min"||g==="m"?6e4*p:g==="seconds"||g==="second"||g==="secs"||g==="sec"||g==="s"?1e3*p:g==="milliseconds"||g==="millisecond"||g==="msecs"||g==="msec"||g==="ms"?p:void 0}}}function c(f){var h=r(f);return 864e5<=h?l(f/864e5)+"d":36e5<=h?l(f/36e5)+"h":6e4<=h?l(f/6e4)+"m":1e3<=h?l(f/1e3)+"s":f+"ms"}function u(f){var h=r(f);return 864e5<=h?d(f,h,864e5,"day"):36e5<=h?d(f,h,36e5,"hour"):6e4<=h?d(f,h,6e4,"minute"):1e3<=h?d(f,h,1e3,"second"):f+" ms"}function d(f,h,p,g){return l(f/p)+" "+g+(h>=1.5*p?"s":"")}o.exports=function(f,h){h=h||{};var p=typeof f;if(p=="string"&&0<f.length)return a(f);if(p==="number"&&isFinite(f))return h.long?u(f):c(f);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(f))}},{}],12:[function(s,o){function l(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function c(E){if(g===setTimeout)return setTimeout(E,0);if((g===l||!g)&&setTimeout)return g=setTimeout,setTimeout(E,0);try{return g(E,0)}catch{try{return g.call(null,E,0)}catch{return g.call(this,E,0)}}}function u(E){if(v===clearTimeout)return clearTimeout(E);if((v===a||!v)&&clearTimeout)return v=clearTimeout,clearTimeout(E);try{return v(E)}catch{try{return v.call(null,E)}catch{return v.call(this,E)}}}function d(){y&&S&&(y=!1,S.length?x=S.concat(x):C=-1,x.length&&f())}function f(){if(!y){var E=c(d);y=!0;for(var T=x.length;T;){for(S=x,x=[];++C<T;)S&&S[C].run();C=-1,T=x.length}S=null,y=!1,u(E)}}function h(E,T){this.fun=E,this.array=T}function p(){}var g,v,w=o.exports={};(function(){try{g=typeof setTimeout=="function"?setTimeout:l}catch{g=l}try{v=typeof clearTimeout=="function"?clearTimeout:a}catch{v=a}})();var S,x=[],y=!1,C=-1;w.nextTick=function(E){var T=Array(arguments.length-1);if(1<arguments.length)for(var D=1;D<arguments.length;D++)T[D-1]=arguments[D];x.push(new h(E,T)),x.length!==1||y||c(f)},h.prototype.run=function(){this.fun.apply(null,this.array)},w.title="browser",w.browser=!0,w.env={},w.argv=[],w.version="",w.versions={},w.on=p,w.addListener=p,w.once=p,w.off=p,w.removeListener=p,w.removeAllListeners=p,w.emit=p,w.prependListener=p,w.prependOnceListener=p,w.listeners=function(){return[]},w.binding=function(){throw new Error("process.binding is not supported")},w.cwd=function(){return"/"},w.chdir=function(){throw new Error("process.chdir is not supported")},w.umask=function(){return 0}},{}],13:[function(s,o){(function(l){(function(){/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */let a;o.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window>"u"?l:window):c=>(a||(a=Promise.resolve())).then(c).catch(u=>setTimeout(()=>{throw u},0))}).call(this)}).call(this,typeof _n>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:_n)},{}],14:[function(s,o){(function(l,a){(function(){var c=s("safe-buffer").Buffer,u=a.crypto||a.msCrypto;o.exports=u&&u.getRandomValues?function(d,f){if(d>4294967295)throw new RangeError("requested too many random bytes");var h=c.allocUnsafe(d);if(0<d)if(65536<d)for(var p=0;p<d;p+=65536)u.getRandomValues(h.slice(p,p+65536));else u.getRandomValues(h);return typeof f=="function"?l.nextTick(function(){f(null,h)}):h}:function(){throw new Error(`Secure random number generation is not supported by this browser.
|
390
|
-
Use Chrome, Firefox or Internet Explorer 11`)}}).call(this)}).call(this,s("_process"),typeof _n>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:_n)},{_process:12,"safe-buffer":30}],15:[function(s,o){function l(p,g){p.prototype=Object.create(g.prototype),p.prototype.constructor=p,p.__proto__=g}function a(p,g,v){function w(x,y,C){return typeof g=="string"?g:g(x,y,C)}v||(v=Error);var S=function(x){function y(C,E,T){return x.call(this,w(C,E,T))||this}return l(y,x),y}(v);S.prototype.name=v.name,S.prototype.code=p,h[p]=S}function c(p,g){if(Array.isArray(p)){var v=p.length;return p=p.map(function(w){return w+""}),2<v?"one of ".concat(g," ").concat(p.slice(0,v-1).join(", "),", or ")+p[v-1]:v===2?"one of ".concat(g," ").concat(p[0]," or ").concat(p[1]):"of ".concat(g," ").concat(p[0])}return"of ".concat(g," ").concat(p+"")}function u(p,g,v){return p.substr(0,g.length)===g}function d(p,g,v){return(v===void 0||v>p.length)&&(v=p.length),p.substring(v-g.length,v)===g}function f(p,g,v){return typeof v!="number"&&(v=0),!(v+g.length>p.length)&&p.indexOf(g,v)!==-1}var h={};a("ERR_INVALID_OPT_VALUE",function(p,g){return'The value "'+g+'" is invalid for option "'+p+'"'},TypeError),a("ERR_INVALID_ARG_TYPE",function(p,g,v){var w;typeof g=="string"&&u(g,"not ")?(w="must not be",g=g.replace(/^not /,"")):w="must be";var S;if(d(p," argument"))S="The ".concat(p," ").concat(w," ").concat(c(g,"type"));else{var x=f(p,".")?"property":"argument";S='The "'.concat(p,'" ').concat(x," ").concat(w," ").concat(c(g,"type"))}return S+=". Received type ".concat(typeof v),S},TypeError),a("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),a("ERR_METHOD_NOT_IMPLEMENTED",function(p){return"The "+p+" method is not implemented"}),a("ERR_STREAM_PREMATURE_CLOSE","Premature close"),a("ERR_STREAM_DESTROYED",function(p){return"Cannot call "+p+" after a stream was destroyed"}),a("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),a("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),a("ERR_STREAM_WRITE_AFTER_END","write after end"),a("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),a("ERR_UNKNOWN_ENCODING",function(p){return"Unknown encoding: "+p},TypeError),a("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),o.exports.codes=h},{}],16:[function(s,o){(function(l){(function(){function a(w){return this instanceof a?(f.call(this,w),h.call(this,w),this.allowHalfOpen=!0,void(w&&(w.readable===!1&&(this.readable=!1),w.writable===!1&&(this.writable=!1),w.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",c))))):new a(w)}function c(){this._writableState.ended||l.nextTick(u,this)}function u(w){w.end()}var d=Object.keys||function(w){var S=[];for(var x in w)S.push(x);return S};o.exports=a;var f=s("./_stream_readable"),h=s("./_stream_writable");s("inherits")(a,f);for(var p,g=d(h.prototype),v=0;v<g.length;v++)p=g[v],a.prototype[p]||(a.prototype[p]=h.prototype[p]);Object.defineProperty(a.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(a.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(a.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(a.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(w){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=w,this._writableState.destroyed=w)}})}).call(this)}).call(this,s("_process"))},{"./_stream_readable":18,"./_stream_writable":20,_process:12,inherits:10}],17:[function(s,o){function l(c){return this instanceof l?void a.call(this,c):new l(c)}o.exports=l;var a=s("./_stream_transform");s("inherits")(l,a),l.prototype._transform=function(c,u,d){d(null,c)}},{"./_stream_transform":19,inherits:10}],18:[function(s,o){(function(l,a){(function(){function c(M){return $e.from(M)}function u(M){return $e.isBuffer(M)||M instanceof Ee}function d(M,m,b){return typeof M.prependListener=="function"?M.prependListener(m,b):void(M._events&&M._events[m]?Array.isArray(M._events[m])?M._events[m].unshift(b):M._events[m]=[b,M._events[m]]:M.on(m,b))}function f(M,m,b){ie=ie||s("./_stream_duplex"),M=M||{},typeof b!="boolean"&&(b=m instanceof ie),this.objectMode=!!M.objectMode,b&&(this.objectMode=this.objectMode||!!M.readableObjectMode),this.highWaterMark=Ot(this,M,"readableHighWaterMark",b),this.buffer=new nt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=M.emitClose!==!1,this.autoDestroy=!!M.autoDestroy,this.destroyed=!1,this.defaultEncoding=M.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,M.encoding&&(!De&&(De=s("string_decoder/").StringDecoder),this.decoder=new De(M.encoding),this.encoding=M.encoding)}function h(M){if(ie=ie||s("./_stream_duplex"),!(this instanceof h))return new h(M);var m=this instanceof ie;this._readableState=new f(M,this,m),this.readable=!0,M&&(typeof M.read=="function"&&(this._read=M.read),typeof M.destroy=="function"&&(this._destroy=M.destroy)),Le.call(this)}function p(M,m,b,k,I){Z("readableAddChunk",m);var F=M._readableState;if(m===null)F.reading=!1,x(M,F);else{var H;if(I||(H=v(F,m)),H)q(M,H);else if(!(F.objectMode||m&&0<m.length))k||(F.reading=!1,E(M,F));else if(typeof m=="string"||F.objectMode||Object.getPrototypeOf(m)===$e.prototype||(m=c(m)),k)F.endEmitted?q(M,new j):g(M,F,m,!0);else if(F.ended)q(M,new at);else{if(F.destroyed)return!1;F.reading=!1,F.decoder&&!b?(m=F.decoder.write(m),F.objectMode||m.length!==0?g(M,F,m,!1):E(M,F)):g(M,F,m,!1)}}return!F.ended&&(F.length<F.highWaterMark||F.length===0)}function g(M,m,b,k){m.flowing&&m.length===0&&!m.sync?(m.awaitDrain=0,M.emit("data",b)):(m.length+=m.objectMode?1:b.length,k?m.buffer.unshift(b):m.buffer.push(b),m.needReadable&&y(M)),E(M,m)}function v(M,m){var b;return u(m)||typeof m=="string"||m===void 0||M.objectMode||(b=new it("chunk",["string","Buffer","Uint8Array"],m)),b}function w(M){return 1073741824<=M?M=1073741824:(M--,M|=M>>>1,M|=M>>>2,M|=M>>>4,M|=M>>>8,M|=M>>>16,M++),M}function S(M,m){return 0>=M||m.length===0&&m.ended?0:m.objectMode?1:M===M?(M>m.highWaterMark&&(m.highWaterMark=w(M)),M<=m.length?M:m.ended?m.length:(m.needReadable=!0,0)):m.flowing&&m.length?m.buffer.head.data.length:m.length}function x(M,m){if(Z("onEofChunk"),!m.ended){if(m.decoder){var b=m.decoder.end();b&&b.length&&(m.buffer.push(b),m.length+=m.objectMode?1:b.length)}m.ended=!0,m.sync?y(M):(m.needReadable=!1,!m.emittedReadable&&(m.emittedReadable=!0,C(M)))}}function y(M){var m=M._readableState;Z("emitReadable",m.needReadable,m.emittedReadable),m.needReadable=!1,m.emittedReadable||(Z("emitReadable",m.flowing),m.emittedReadable=!0,l.nextTick(C,M))}function C(M){var m=M._readableState;Z("emitReadable_",m.destroyed,m.length,m.ended),!m.destroyed&&(m.length||m.ended)&&(M.emit("readable"),m.emittedReadable=!1),m.needReadable=!m.flowing&&!m.ended&&m.length<=m.highWaterMark,B(M)}function E(M,m){m.readingMore||(m.readingMore=!0,l.nextTick(T,M,m))}function T(M,m){for(;!m.reading&&!m.ended&&(m.length<m.highWaterMark||m.flowing&&m.length===0);){var b=m.length;if(Z("maybeReadMore read 0"),M.read(0),b===m.length)break}m.readingMore=!1}function D(M){return function(){var m=M._readableState;Z("pipeOnDrain",m.awaitDrain),m.awaitDrain&&m.awaitDrain--,m.awaitDrain===0&&ke(M,"data")&&(m.flowing=!0,B(M))}}function N(M){var m=M._readableState;m.readableListening=0<M.listenerCount("readable"),m.resumeScheduled&&!m.paused?m.flowing=!0:0<M.listenerCount("data")&&M.resume()}function A(M){Z("readable nexttick read 0"),M.read(0)}function R(M,m){m.resumeScheduled||(m.resumeScheduled=!0,l.nextTick(P,M,m))}function P(M,m){Z("resume",m.reading),m.reading||M.read(0),m.resumeScheduled=!1,M.emit("resume"),B(M),m.flowing&&!m.reading&&M.read(0)}function B(M){var m=M._readableState;for(Z("flow",m.flowing);m.flowing&&M.read()!==null;);}function z(M,m){if(m.length===0)return null;var b;return m.objectMode?b=m.buffer.shift():!M||M>=m.length?(b=m.decoder?m.buffer.join(""):m.buffer.length===1?m.buffer.first():m.buffer.concat(m.length),m.buffer.clear()):b=m.buffer.consume(M,m.decoder),b}function U(M){var m=M._readableState;Z("endReadable",m.endEmitted),m.endEmitted||(m.ended=!0,l.nextTick(J,m,M))}function J(M,m){if(Z("endReadableNT",M.endEmitted,M.length),!M.endEmitted&&M.length===0&&(M.endEmitted=!0,m.readable=!1,m.emit("end"),M.autoDestroy)){var b=m._writableState;(!b||b.autoDestroy&&b.finished)&&m.destroy()}}function G(M,m){for(var b=0,k=M.length;b<k;b++)if(M[b]===m)return b;return-1}o.exports=h;var ie;h.ReadableState=f;var Z;s("events").EventEmitter;var ke=function(M,m){return M.listeners(m).length},Le=s("./internal/streams/stream"),$e=s("buffer").Buffer,Ee=a.Uint8Array||function(){},ve=s("util");Z=ve&&ve.debuglog?ve.debuglog("stream"):function(){};var De,Ie,tt,nt=s("./internal/streams/buffer_list"),Ge=s("./internal/streams/destroy"),Ye=s("./internal/streams/state"),Ot=Ye.getHighWaterMark,xt=s("../errors").codes,it=xt.ERR_INVALID_ARG_TYPE,at=xt.ERR_STREAM_PUSH_AFTER_EOF,$=xt.ERR_METHOD_NOT_IMPLEMENTED,j=xt.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;s("inherits")(h,Le);var q=Ge.errorOrDestroy,te=["error","close","destroy","pause","resume"];Object.defineProperty(h.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._readableState.destroyed},set:function(M){this._readableState&&(this._readableState.destroyed=M)}}),h.prototype.destroy=Ge.destroy,h.prototype._undestroy=Ge.undestroy,h.prototype._destroy=function(M,m){m(M)},h.prototype.push=function(M,m){var b,k=this._readableState;return k.objectMode?b=!0:typeof M=="string"&&(m=m||k.defaultEncoding,m!==k.encoding&&(M=$e.from(M,m),m=""),b=!0),p(this,M,m,!1,b)},h.prototype.unshift=function(M){return p(this,M,null,!0,!1)},h.prototype.isPaused=function(){return this._readableState.flowing===!1},h.prototype.setEncoding=function(M){De||(De=s("string_decoder/").StringDecoder);var m=new De(M);this._readableState.decoder=m,this._readableState.encoding=this._readableState.decoder.encoding;for(var b=this._readableState.buffer.head,k="";b!==null;)k+=m.write(b.data),b=b.next;return this._readableState.buffer.clear(),k!==""&&this._readableState.buffer.push(k),this._readableState.length=k.length,this},h.prototype.read=function(M){Z("read",M),M=parseInt(M,10);var m=this._readableState,b=M;if(M!==0&&(m.emittedReadable=!1),M===0&&m.needReadable&&((m.highWaterMark===0?0<m.length:m.length>=m.highWaterMark)||m.ended))return Z("read: emitReadable",m.length,m.ended),m.length===0&&m.ended?U(this):y(this),null;if(M=S(M,m),M===0&&m.ended)return m.length===0&&U(this),null;var k=m.needReadable;Z("need readable",k),(m.length===0||m.length-M<m.highWaterMark)&&(k=!0,Z("length less than watermark",k)),m.ended||m.reading?(k=!1,Z("reading or ended",k)):k&&(Z("do read"),m.reading=!0,m.sync=!0,m.length===0&&(m.needReadable=!0),this._read(m.highWaterMark),m.sync=!1,!m.reading&&(M=S(b,m)));var I;return I=0<M?z(M,m):null,I===null?(m.needReadable=m.length<=m.highWaterMark,M=0):(m.length-=M,m.awaitDrain=0),m.length===0&&(!m.ended&&(m.needReadable=!0),b!==M&&m.ended&&U(this)),I!==null&&this.emit("data",I),I},h.prototype._read=function(){q(this,new $("_read()"))},h.prototype.pipe=function(M,m){function b(ee,oe){Z("onunpipe"),ee===we&&oe&&oe.hasUnpiped===!1&&(oe.hasUnpiped=!0,I())}function k(){Z("onend"),M.end()}function I(){Z("cleanup"),M.removeListener("close",ne),M.removeListener("finish",de),M.removeListener("drain",Qn),M.removeListener("error",H),M.removeListener("unpipe",b),we.removeListener("end",k),we.removeListener("end",_e),we.removeListener("data",F),V=!0,ye.awaitDrain&&(!M._writableState||M._writableState.needDrain)&&Qn()}function F(ee){Z("ondata");var oe=M.write(ee);Z("dest.write",oe),oe===!1&&((ye.pipesCount===1&&ye.pipes===M||1<ye.pipesCount&&G(ye.pipes,M)!==-1)&&!V&&(Z("false write response, pause",ye.awaitDrain),ye.awaitDrain++),we.pause())}function H(ee){Z("onerror",ee),_e(),M.removeListener("error",H),ke(M,"error")===0&&q(M,ee)}function ne(){M.removeListener("finish",de),_e()}function de(){Z("onfinish"),M.removeListener("close",ne),_e()}function _e(){Z("unpipe"),we.unpipe(M)}var we=this,ye=this._readableState;switch(ye.pipesCount){case 0:ye.pipes=M;break;case 1:ye.pipes=[ye.pipes,M];break;default:ye.pipes.push(M)}ye.pipesCount+=1,Z("pipe count=%d opts=%j",ye.pipesCount,m);var Xe=(!m||m.end!==!1)&&M!==l.stdout&&M!==l.stderr,Mn=Xe?k:_e;ye.endEmitted?l.nextTick(Mn):we.once("end",Mn),M.on("unpipe",b);var Qn=D(we);M.on("drain",Qn);var V=!1;return we.on("data",F),d(M,"error",H),M.once("close",ne),M.once("finish",de),M.emit("pipe",we),ye.flowing||(Z("pipe resume"),we.resume()),M},h.prototype.unpipe=function(M){var m=this._readableState,b={hasUnpiped:!1};if(m.pipesCount===0)return this;if(m.pipesCount===1)return M&&M!==m.pipes?this:(M||(M=m.pipes),m.pipes=null,m.pipesCount=0,m.flowing=!1,M&&M.emit("unpipe",this,b),this);if(!M){var k=m.pipes,I=m.pipesCount;m.pipes=null,m.pipesCount=0,m.flowing=!1;for(var F=0;F<I;F++)k[F].emit("unpipe",this,{hasUnpiped:!1});return this}var H=G(m.pipes,M);return H===-1?this:(m.pipes.splice(H,1),m.pipesCount-=1,m.pipesCount===1&&(m.pipes=m.pipes[0]),M.emit("unpipe",this,b),this)},h.prototype.on=function(M,m){var b=Le.prototype.on.call(this,M,m),k=this._readableState;return M==="data"?(k.readableListening=0<this.listenerCount("readable"),k.flowing!==!1&&this.resume()):M=="readable"&&!k.endEmitted&&!k.readableListening&&(k.readableListening=k.needReadable=!0,k.flowing=!1,k.emittedReadable=!1,Z("on readable",k.length,k.reading),k.length?y(this):!k.reading&&l.nextTick(A,this)),b},h.prototype.addListener=h.prototype.on,h.prototype.removeListener=function(M,m){var b=Le.prototype.removeListener.call(this,M,m);return M==="readable"&&l.nextTick(N,this),b},h.prototype.removeAllListeners=function(M){var m=Le.prototype.removeAllListeners.apply(this,arguments);return(M==="readable"||M===void 0)&&l.nextTick(N,this),m},h.prototype.resume=function(){var M=this._readableState;return M.flowing||(Z("resume"),M.flowing=!M.readableListening,R(this,M)),M.paused=!1,this},h.prototype.pause=function(){return Z("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Z("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},h.prototype.wrap=function(M){var m=this,b=this._readableState,k=!1;for(var I in M.on("end",function(){if(Z("wrapped end"),b.decoder&&!b.ended){var H=b.decoder.end();H&&H.length&&m.push(H)}m.push(null)}),M.on("data",function(H){if(Z("wrapped data"),b.decoder&&(H=b.decoder.write(H)),!(b.objectMode&&H==null)&&(b.objectMode||H&&H.length)){var ne=m.push(H);ne||(k=!0,M.pause())}}),M)this[I]===void 0&&typeof M[I]=="function"&&(this[I]=function(H){return function(){return M[H].apply(M,arguments)}}(I));for(var F=0;F<te.length;F++)M.on(te[F],this.emit.bind(this,te[F]));return this._read=function(H){Z("wrapped _read",H),k&&(k=!1,M.resume())},this},typeof Symbol=="function"&&(h.prototype[Symbol.asyncIterator]=function(){return Ie===void 0&&(Ie=s("./internal/streams/async_iterator")),Ie(this)}),Object.defineProperty(h.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(h.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(h.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(M){this._readableState&&(this._readableState.flowing=M)}}),h._fromList=z,Object.defineProperty(h.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),typeof Symbol=="function"&&(h.from=function(M,m){return tt===void 0&&(tt=s("./internal/streams/from")),tt(h,M,m)})}).call(this)}).call(this,s("_process"),typeof _n>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:_n)},{"../errors":15,"./_stream_duplex":16,"./internal/streams/async_iterator":21,"./internal/streams/buffer_list":22,"./internal/streams/destroy":23,"./internal/streams/from":25,"./internal/streams/state":27,"./internal/streams/stream":28,_process:12,buffer:3,events:7,inherits:10,"string_decoder/":31,util:2}],19:[function(s,o){function l(w,S){var x=this._transformState;x.transforming=!1;var y=x.writecb;if(y===null)return this.emit("error",new h);x.writechunk=null,x.writecb=null,S!=null&&this.push(S),y(w);var C=this._readableState;C.reading=!1,(C.needReadable||C.length<C.highWaterMark)&&this._read(C.highWaterMark)}function a(w){return this instanceof a?(v.call(this,w),this._transformState={afterTransform:l.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,w&&(typeof w.transform=="function"&&(this._transform=w.transform),typeof w.flush=="function"&&(this._flush=w.flush)),void this.on("prefinish",c)):new a(w)}function c(){var w=this;typeof this._flush!="function"||this._readableState.destroyed?u(this,null,null):this._flush(function(S,x){u(w,S,x)})}function u(w,S,x){if(S)return w.emit("error",S);if(x!=null&&w.push(x),w._writableState.length)throw new g;if(w._transformState.transforming)throw new p;return w.push(null)}o.exports=a;var d=s("../errors").codes,f=d.ERR_METHOD_NOT_IMPLEMENTED,h=d.ERR_MULTIPLE_CALLBACK,p=d.ERR_TRANSFORM_ALREADY_TRANSFORMING,g=d.ERR_TRANSFORM_WITH_LENGTH_0,v=s("./_stream_duplex");s("inherits")(a,v),a.prototype.push=function(w,S){return this._transformState.needTransform=!1,v.prototype.push.call(this,w,S)},a.prototype._transform=function(w,S,x){x(new f("_transform()"))},a.prototype._write=function(w,S,x){var y=this._transformState;if(y.writecb=x,y.writechunk=w,y.writeencoding=S,!y.transforming){var C=this._readableState;(y.needTransform||C.needReadable||C.length<C.highWaterMark)&&this._read(C.highWaterMark)}},a.prototype._read=function(){var w=this._transformState;w.writechunk===null||w.transforming?w.needTransform=!0:(w.transforming=!0,this._transform(w.writechunk,w.writeencoding,w.afterTransform))},a.prototype._destroy=function(w,S){v.prototype._destroy.call(this,w,function(x){S(x)})}},{"../errors":15,"./_stream_duplex":16,inherits:10}],20:[function(s,o){(function(l,a){(function(){function c($){var j=this;this.next=null,this.entry=null,this.finish=function(){U(j,$)}}function u($){return Z.from($)}function d($){return Z.isBuffer($)||$ instanceof ke}function f(){}function h($,j,q){J=J||s("./_stream_duplex"),$=$||{},typeof q!="boolean"&&(q=j instanceof J),this.objectMode=!!$.objectMode,q&&(this.objectMode=this.objectMode||!!$.writableObjectMode),this.highWaterMark=Ee(this,$,"writableHighWaterMark",q),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var te=$.decodeStrings===!1;this.decodeStrings=!te,this.defaultEncoding=$.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(M){E(j,M)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=$.emitClose!==!1,this.autoDestroy=!!$.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new c(this)}function p($){J=J||s("./_stream_duplex");var j=this instanceof J;return j||at.call(p,this)?(this._writableState=new h($,this,j),this.writable=!0,$&&(typeof $.write=="function"&&(this._write=$.write),typeof $.writev=="function"&&(this._writev=$.writev),typeof $.destroy=="function"&&(this._destroy=$.destroy),typeof $.final=="function"&&(this._final=$.final)),void ie.call(this)):new p($)}function g($,j){var q=new Ot;it($,q),l.nextTick(j,q)}function v($,j,q,te){var M;return q===null?M=new Ye:typeof q!="string"&&!j.objectMode&&(M=new De("chunk",["string","Buffer"],q)),!M||(it($,M),l.nextTick(te,M),!1)}function w($,j,q){return $.objectMode||$.decodeStrings===!1||typeof j!="string"||(j=Z.from(j,q)),j}function S($,j,q,te,M,m){if(!q){var b=w(j,te,M);te!==b&&(q=!0,M="buffer",te=b)}var k=j.objectMode?1:te.length;j.length+=k;var I=j.length<j.highWaterMark;if(I||(j.needDrain=!0),j.writing||j.corked){var F=j.lastBufferedRequest;j.lastBufferedRequest={chunk:te,encoding:M,isBuf:q,callback:m,next:null},F?F.next=j.lastBufferedRequest:j.bufferedRequest=j.lastBufferedRequest,j.bufferedRequestCount+=1}else x($,j,!1,k,te,M,m);return I}function x($,j,q,te,M,m,b){j.writelen=te,j.writecb=b,j.writing=!0,j.sync=!0,j.destroyed?j.onwrite(new Ge("write")):q?$._writev(M,j.onwrite):$._write(M,m,j.onwrite),j.sync=!1}function y($,j,q,te,M){--j.pendingcb,q?(l.nextTick(M,te),l.nextTick(B,$,j),$._writableState.errorEmitted=!0,it($,te)):(M(te),$._writableState.errorEmitted=!0,it($,te),B($,j))}function C($){$.writing=!1,$.writecb=null,$.length-=$.writelen,$.writelen=0}function E($,j){var q=$._writableState,te=q.sync,M=q.writecb;if(typeof M!="function")throw new tt;if(C(q),j)y($,q,te,j,M);else{var m=A(q)||$.destroyed;m||q.corked||q.bufferProcessing||!q.bufferedRequest||N($,q),te?l.nextTick(T,$,q,m,M):T($,q,m,M)}}function T($,j,q,te){q||D($,j),j.pendingcb--,te(),B($,j)}function D($,j){j.length===0&&j.needDrain&&(j.needDrain=!1,$.emit("drain"))}function N($,j){j.bufferProcessing=!0;var q=j.bufferedRequest;if($._writev&&q&&q.next){var te=j.bufferedRequestCount,M=Array(te),m=j.corkedRequestsFree;m.entry=q;for(var b=0,k=!0;q;)M[b]=q,q.isBuf||(k=!1),q=q.next,b+=1;M.allBuffers=k,x($,j,!0,j.length,M,"",m.finish),j.pendingcb++,j.lastBufferedRequest=null,m.next?(j.corkedRequestsFree=m.next,m.next=null):j.corkedRequestsFree=new c(j),j.bufferedRequestCount=0}else{for(;q;){var I=q.chunk,F=q.encoding,H=q.callback,ne=j.objectMode?1:I.length;if(x($,j,!1,ne,I,F,H),q=q.next,j.bufferedRequestCount--,j.writing)break}q===null&&(j.lastBufferedRequest=null)}j.bufferedRequest=q,j.bufferProcessing=!1}function A($){return $.ending&&$.length===0&&$.bufferedRequest===null&&!$.finished&&!$.writing}function R($,j){$._final(function(q){j.pendingcb--,q&&it($,q),j.prefinished=!0,$.emit("prefinish"),B($,j)})}function P($,j){j.prefinished||j.finalCalled||(typeof $._final!="function"||j.destroyed?(j.prefinished=!0,$.emit("prefinish")):(j.pendingcb++,j.finalCalled=!0,l.nextTick(R,$,j)))}function B($,j){var q=A(j);if(q&&(P($,j),j.pendingcb===0&&(j.finished=!0,$.emit("finish"),j.autoDestroy))){var te=$._readableState;(!te||te.autoDestroy&&te.endEmitted)&&$.destroy()}return q}function z($,j,q){j.ending=!0,B($,j),q&&(j.finished?l.nextTick(q):$.once("finish",q)),j.ended=!0,$.writable=!1}function U($,j,q){var te=$.entry;for($.entry=null;te;){var M=te.callback;j.pendingcb--,M(q),te=te.next}j.corkedRequestsFree.next=$}o.exports=p;var J;p.WritableState=h;var G={deprecate:s("util-deprecate")},ie=s("./internal/streams/stream"),Z=s("buffer").Buffer,ke=a.Uint8Array||function(){},Le=s("./internal/streams/destroy"),$e=s("./internal/streams/state"),Ee=$e.getHighWaterMark,ve=s("../errors").codes,De=ve.ERR_INVALID_ARG_TYPE,Ie=ve.ERR_METHOD_NOT_IMPLEMENTED,tt=ve.ERR_MULTIPLE_CALLBACK,nt=ve.ERR_STREAM_CANNOT_PIPE,Ge=ve.ERR_STREAM_DESTROYED,Ye=ve.ERR_STREAM_NULL_VALUES,Ot=ve.ERR_STREAM_WRITE_AFTER_END,xt=ve.ERR_UNKNOWN_ENCODING,it=Le.errorOrDestroy;s("inherits")(p,ie),h.prototype.getBuffer=function(){for(var $=this.bufferedRequest,j=[];$;)j.push($),$=$.next;return j},function(){try{Object.defineProperty(h.prototype,"buffer",{get:G.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var at;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(at=Function.prototype[Symbol.hasInstance],Object.defineProperty(p,Symbol.hasInstance,{value:function($){return!!at.call(this,$)||this===p&&$&&$._writableState instanceof h}})):at=function($){return $ instanceof this},p.prototype.pipe=function(){it(this,new nt)},p.prototype.write=function($,j,q){var te=this._writableState,M=!1,m=!te.objectMode&&d($);return m&&!Z.isBuffer($)&&($=u($)),typeof j=="function"&&(q=j,j=null),m?j="buffer":!j&&(j=te.defaultEncoding),typeof q!="function"&&(q=f),te.ending?g(this,q):(m||v(this,te,$,q))&&(te.pendingcb++,M=S(this,te,m,$,j,q)),M},p.prototype.cork=function(){this._writableState.corked++},p.prototype.uncork=function(){var $=this._writableState;$.corked&&($.corked--,!$.writing&&!$.corked&&!$.bufferProcessing&&$.bufferedRequest&&N(this,$))},p.prototype.setDefaultEncoding=function($){if(typeof $=="string"&&($=$.toLowerCase()),!(-1<["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf(($+"").toLowerCase())))throw new xt($);return this._writableState.defaultEncoding=$,this},Object.defineProperty(p.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(p.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),p.prototype._write=function($,j,q){q(new Ie("_write()"))},p.prototype._writev=null,p.prototype.end=function($,j,q){var te=this._writableState;return typeof $=="function"?(q=$,$=null,j=null):typeof j=="function"&&(q=j,j=null),$!=null&&this.write($,j),te.corked&&(te.corked=1,this.uncork()),te.ending||z(this,te,q),this},Object.defineProperty(p.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(p.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function($){this._writableState&&(this._writableState.destroyed=$)}}),p.prototype.destroy=Le.destroy,p.prototype._undestroy=Le.undestroy,p.prototype._destroy=function($,j){j($)}}).call(this)}).call(this,s("_process"),typeof _n>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:_n)},{"../errors":15,"./_stream_duplex":16,"./internal/streams/destroy":23,"./internal/streams/state":27,"./internal/streams/stream":28,_process:12,buffer:3,inherits:10,"util-deprecate":32}],21:[function(s,o){(function(l){(function(){function a(D,N,A){return N in D?Object.defineProperty(D,N,{value:A,enumerable:!0,configurable:!0,writable:!0}):D[N]=A,D}function c(D,N){return{value:D,done:N}}function u(D){var N=D[g];if(N!==null){var A=D[C].read();A!==null&&(D[x]=null,D[g]=null,D[v]=null,N(c(A,!1)))}}function d(D){l.nextTick(u,D)}function f(D,N){return function(A,R){D.then(function(){return N[S]?void A(c(void 0,!0)):void N[y](A,R)},R)}}var h,p=s("./end-of-stream"),g=Symbol("lastResolve"),v=Symbol("lastReject"),w=Symbol("error"),S=Symbol("ended"),x=Symbol("lastPromise"),y=Symbol("handlePromise"),C=Symbol("stream"),E=Object.getPrototypeOf(function(){}),T=Object.setPrototypeOf((h={get stream(){return this[C]},next:function(){var D=this,N=this[w];if(N!==null)return Promise.reject(N);if(this[S])return Promise.resolve(c(void 0,!0));if(this[C].destroyed)return new Promise(function(B,z){l.nextTick(function(){D[w]?z(D[w]):B(c(void 0,!0))})});var A,R=this[x];if(R)A=new Promise(f(R,this));else{var P=this[C].read();if(P!==null)return Promise.resolve(c(P,!1));A=new Promise(this[y])}return this[x]=A,A}},a(h,Symbol.asyncIterator,function(){return this}),a(h,"return",function(){var D=this;return new Promise(function(N,A){D[C].destroy(null,function(R){return R?void A(R):void N(c(void 0,!0))})})}),h),E);o.exports=function(D){var N,A=Object.create(T,(N={},a(N,C,{value:D,writable:!0}),a(N,g,{value:null,writable:!0}),a(N,v,{value:null,writable:!0}),a(N,w,{value:null,writable:!0}),a(N,S,{value:D._readableState.endEmitted,writable:!0}),a(N,y,{value:function(R,P){var B=A[C].read();B?(A[x]=null,A[g]=null,A[v]=null,R(c(B,!1))):(A[g]=R,A[v]=P)},writable:!0}),N));return A[x]=null,p(D,function(R){if(R&&R.code!=="ERR_STREAM_PREMATURE_CLOSE"){var P=A[v];return P!==null&&(A[x]=null,A[g]=null,A[v]=null,P(R)),void(A[w]=R)}var B=A[g];B!==null&&(A[x]=null,A[g]=null,A[v]=null,B(c(void 0,!0))),A[S]=!0}),D.on("readable",d.bind(null,A)),A}}).call(this)}).call(this,s("_process"))},{"./end-of-stream":24,_process:12}],22:[function(s,o){function l(x,y){var C=Object.keys(x);if(Object.getOwnPropertySymbols){var E=Object.getOwnPropertySymbols(x);y&&(E=E.filter(function(T){return Object.getOwnPropertyDescriptor(x,T).enumerable})),C.push.apply(C,E)}return C}function a(x){for(var y,C=1;C<arguments.length;C++)y=arguments[C]==null?{}:arguments[C],C%2?l(Object(y),!0).forEach(function(E){c(x,E,y[E])}):Object.getOwnPropertyDescriptors?Object.defineProperties(x,Object.getOwnPropertyDescriptors(y)):l(Object(y)).forEach(function(E){Object.defineProperty(x,E,Object.getOwnPropertyDescriptor(y,E))});return x}function c(x,y,C){return y in x?Object.defineProperty(x,y,{value:C,enumerable:!0,configurable:!0,writable:!0}):x[y]=C,x}function u(x,y){if(!(x instanceof y))throw new TypeError("Cannot call a class as a function")}function d(x,y){for(var C,E=0;E<y.length;E++)C=y[E],C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(x,C.key,C)}function f(x,y,C){return y&&d(x.prototype,y),x}function h(x,y,C){g.prototype.copy.call(x,y,C)}var p=s("buffer"),g=p.Buffer,v=s("util"),w=v.inspect,S=w&&w.custom||"inspect";o.exports=function(){function x(){u(this,x),this.head=null,this.tail=null,this.length=0}return f(x,[{key:"push",value:function(y){var C={data:y,next:null};0<this.length?this.tail.next=C:this.head=C,this.tail=C,++this.length}},{key:"unshift",value:function(y){var C={data:y,next:this.head};this.length===0&&(this.tail=C),this.head=C,++this.length}},{key:"shift",value:function(){if(this.length!==0){var y=this.head.data;return this.head=this.length===1?this.tail=null:this.head.next,--this.length,y}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(y){if(this.length===0)return"";for(var C=this.head,E=""+C.data;C=C.next;)E+=y+C.data;return E}},{key:"concat",value:function(y){if(this.length===0)return g.alloc(0);for(var C=g.allocUnsafe(y>>>0),E=this.head,T=0;E;)h(E.data,C,T),T+=E.data.length,E=E.next;return C}},{key:"consume",value:function(y,C){var E;return y<this.head.data.length?(E=this.head.data.slice(0,y),this.head.data=this.head.data.slice(y)):y===this.head.data.length?E=this.shift():E=C?this._getString(y):this._getBuffer(y),E}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(y){var C=this.head,E=1,T=C.data;for(y-=T.length;C=C.next;){var D=C.data,N=y>D.length?D.length:y;if(T+=N===D.length?D:D.slice(0,y),y-=N,y===0){N===D.length?(++E,this.head=C.next?C.next:this.tail=null):(this.head=C,C.data=D.slice(N));break}++E}return this.length-=E,T}},{key:"_getBuffer",value:function(y){var C=g.allocUnsafe(y),E=this.head,T=1;for(E.data.copy(C),y-=E.data.length;E=E.next;){var D=E.data,N=y>D.length?D.length:y;if(D.copy(C,C.length-y,0,N),y-=N,y===0){N===D.length?(++T,this.head=E.next?E.next:this.tail=null):(this.head=E,E.data=D.slice(N));break}++T}return this.length-=T,C}},{key:S,value:function(y,C){return w(this,a({},C,{depth:0,customInspect:!1}))}}]),x}()},{buffer:3,util:2}],23:[function(s,o){(function(l){(function(){function a(d,f){u(d,f),c(d)}function c(d){d._writableState&&!d._writableState.emitClose||d._readableState&&!d._readableState.emitClose||d.emit("close")}function u(d,f){d.emit("error",f)}o.exports={destroy:function(d,f){var h=this,p=this._readableState&&this._readableState.destroyed,g=this._writableState&&this._writableState.destroyed;return p||g?(f?f(d):d&&(this._writableState?!this._writableState.errorEmitted&&(this._writableState.errorEmitted=!0,l.nextTick(u,this,d)):l.nextTick(u,this,d)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(d||null,function(v){!f&&v?h._writableState?h._writableState.errorEmitted?l.nextTick(c,h):(h._writableState.errorEmitted=!0,l.nextTick(a,h,v)):l.nextTick(a,h,v):f?(l.nextTick(c,h),f(v)):l.nextTick(c,h)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(d,f){var h=d._readableState,p=d._writableState;h&&h.autoDestroy||p&&p.autoDestroy?d.destroy(f):d.emit("error",f)}}}).call(this)}).call(this,s("_process"))},{_process:12}],24:[function(s,o){function l(f){var h=!1;return function(){if(!h){h=!0;for(var p=arguments.length,g=Array(p),v=0;v<p;v++)g[v]=arguments[v];f.apply(this,g)}}}function a(){}function c(f){return f.setHeader&&typeof f.abort=="function"}function u(f,h,p){if(typeof h=="function")return u(f,null,h);h||(h={}),p=l(p||a);var g=h.readable||h.readable!==!1&&f.readable,v=h.writable||h.writable!==!1&&f.writable,w=function(){f.writable||x()},S=f._writableState&&f._writableState.finished,x=function(){v=!1,S=!0,g||p.call(f)},y=f._readableState&&f._readableState.endEmitted,C=function(){g=!1,y=!0,v||p.call(f)},E=function(N){p.call(f,N)},T=function(){var N;return g&&!y?(f._readableState&&f._readableState.ended||(N=new d),p.call(f,N)):v&&!S?(f._writableState&&f._writableState.ended||(N=new d),p.call(f,N)):void 0},D=function(){f.req.on("finish",x)};return c(f)?(f.on("complete",x),f.on("abort",T),f.req?D():f.on("request",D)):v&&!f._writableState&&(f.on("end",w),f.on("close",w)),f.on("end",C),f.on("finish",x),h.error!==!1&&f.on("error",E),f.on("close",T),function(){f.removeListener("complete",x),f.removeListener("abort",T),f.removeListener("request",D),f.req&&f.req.removeListener("finish",x),f.removeListener("end",w),f.removeListener("close",w),f.removeListener("finish",x),f.removeListener("end",C),f.removeListener("error",E),f.removeListener("close",T)}}var d=s("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;o.exports=u},{"../../../errors":15}],25:[function(s,o){o.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],26:[function(s,o){function l(S){var x=!1;return function(){x||(x=!0,S.apply(void 0,arguments))}}function a(S){if(S)throw S}function c(S){return S.setHeader&&typeof S.abort=="function"}function u(S,x,y,C){C=l(C);var E=!1;S.on("close",function(){E=!0}),p===void 0&&(p=s("./end-of-stream")),p(S,{readable:x,writable:y},function(D){return D?C(D):(E=!0,void C())});var T=!1;return function(D){if(!E)return T?void 0:(T=!0,c(S)?S.abort():typeof S.destroy=="function"?S.destroy():void C(D||new w("pipe")))}}function d(S){S()}function f(S,x){return S.pipe(x)}function h(S){return S.length&&typeof S[S.length-1]=="function"?S.pop():a}var p,g=s("../../../errors").codes,v=g.ERR_MISSING_ARGS,w=g.ERR_STREAM_DESTROYED;o.exports=function(){for(var S=arguments.length,x=Array(S),y=0;y<S;y++)x[y]=arguments[y];var C=h(x);if(Array.isArray(x[0])&&(x=x[0]),2>x.length)throw new v("streams");var E,T=x.map(function(D,N){var A=N<x.length-1;return u(D,A,0<N,function(R){E||(E=R),R&&T.forEach(d),A||(T.forEach(d),C(E))})});return x.reduce(f)}},{"../../../errors":15,"./end-of-stream":24}],27:[function(s,o){function l(c,u,d){return c.highWaterMark==null?u?c[d]:null:c.highWaterMark}var a=s("../../../errors").codes.ERR_INVALID_OPT_VALUE;o.exports={getHighWaterMark:function(c,u,d,f){var h=l(u,f,d);if(h!=null){if(!(isFinite(h)&&n(h)===h)||0>h){var p=f?d:"highWaterMark";throw new a(p,h)}return n(h)}return c.objectMode?16:16384}}},{"../../../errors":15}],28:[function(s,o){o.exports=s("events").EventEmitter},{events:7}],29:[function(s,o,l){l=o.exports=s("./lib/_stream_readable.js"),l.Stream=l,l.Readable=l,l.Writable=s("./lib/_stream_writable.js"),l.Duplex=s("./lib/_stream_duplex.js"),l.Transform=s("./lib/_stream_transform.js"),l.PassThrough=s("./lib/_stream_passthrough.js"),l.finished=s("./lib/internal/streams/end-of-stream.js"),l.pipeline=s("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":16,"./lib/_stream_passthrough.js":17,"./lib/_stream_readable.js":18,"./lib/_stream_transform.js":19,"./lib/_stream_writable.js":20,"./lib/internal/streams/end-of-stream.js":24,"./lib/internal/streams/pipeline.js":26}],30:[function(s,o,l){function a(f,h){for(var p in f)h[p]=f[p]}function c(f,h,p){return d(f,h,p)}/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var u=s("buffer"),d=u.Buffer;d.from&&d.alloc&&d.allocUnsafe&&d.allocUnsafeSlow?o.exports=u:(a(u,l),l.Buffer=c),c.prototype=Object.create(d.prototype),a(d,c),c.from=function(f,h,p){if(typeof f=="number")throw new TypeError("Argument must not be a number");return d(f,h,p)},c.alloc=function(f,h,p){if(typeof f!="number")throw new TypeError("Argument must be a number");var g=d(f);return h===void 0?g.fill(0):typeof p=="string"?g.fill(h,p):g.fill(h),g},c.allocUnsafe=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return d(f)},c.allocUnsafeSlow=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return u.SlowBuffer(f)}},{buffer:3}],31:[function(s,o,l){function a(T){if(!T)return"utf8";for(var D;;)switch(T){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return T;default:if(D)return;T=(""+T).toLowerCase(),D=!0}}function c(T){var D=a(T);if(typeof D!="string"&&(C.isEncoding===E||!E(T)))throw new Error("Unknown encoding: "+T);return D||T}function u(T){this.encoding=c(T);var D;switch(this.encoding){case"utf16le":this.text=g,this.end=v,D=4;break;case"utf8":this.fillLast=p,D=4;break;case"base64":this.text=w,this.end=S,D=3;break;default:return this.write=x,void(this.end=y)}this.lastNeed=0,this.lastTotal=0,this.lastChar=C.allocUnsafe(D)}function d(T){return 127>=T?0:T>>5==6?2:T>>4==14?3:T>>3==30?4:T>>6==2?-1:-2}function f(T,D,N){var A=D.length-1;if(A<N)return 0;var R=d(D[A]);return 0<=R?(0<R&&(T.lastNeed=R-1),R):--A<N||R===-2?0:(R=d(D[A]),0<=R?(0<R&&(T.lastNeed=R-2),R):--A<N||R===-2?0:(R=d(D[A]),0<=R?(0<R&&(R===2?R=0:T.lastNeed=R-3),R):0))}function h(T,D){if((192&D[0])!=128)return T.lastNeed=0,"�";if(1<T.lastNeed&&1<D.length){if((192&D[1])!=128)return T.lastNeed=1,"�";if(2<T.lastNeed&&2<D.length&&(192&D[2])!=128)return T.lastNeed=2,"�"}}function p(T){var D=this.lastTotal-this.lastNeed,N=h(this,T);return N===void 0?this.lastNeed<=T.length?(T.copy(this.lastChar,D,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(T.copy(this.lastChar,D,0,T.length),void(this.lastNeed-=T.length)):N}function g(T,D){if((T.length-D)%2==0){var N=T.toString("utf16le",D);if(N){var A=N.charCodeAt(N.length-1);if(55296<=A&&56319>=A)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=T[T.length-2],this.lastChar[1]=T[T.length-1],N.slice(0,-1)}return N}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=T[T.length-1],T.toString("utf16le",D,T.length-1)}function v(T){var D=T&&T.length?this.write(T):"";if(this.lastNeed){var N=this.lastTotal-this.lastNeed;return D+this.lastChar.toString("utf16le",0,N)}return D}function w(T,D){var N=(T.length-D)%3;return N==0?T.toString("base64",D):(this.lastNeed=3-N,this.lastTotal=3,N==1?this.lastChar[0]=T[T.length-1]:(this.lastChar[0]=T[T.length-2],this.lastChar[1]=T[T.length-1]),T.toString("base64",D,T.length-N))}function S(T){var D=T&&T.length?this.write(T):"";return this.lastNeed?D+this.lastChar.toString("base64",0,3-this.lastNeed):D}function x(T){return T.toString(this.encoding)}function y(T){return T&&T.length?this.write(T):""}var C=s("safe-buffer").Buffer,E=C.isEncoding||function(T){switch(T=""+T,T&&T.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};l.StringDecoder=u,u.prototype.write=function(T){if(T.length===0)return"";var D,N;if(this.lastNeed){if(D=this.fillLast(T),D===void 0)return"";N=this.lastNeed,this.lastNeed=0}else N=0;return N<T.length?D?D+this.text(T,N):this.text(T,N):D||""},u.prototype.end=function(T){var D=T&&T.length?this.write(T):"";return this.lastNeed?D+"�":D},u.prototype.text=function(T,D){var N=f(this,T,D);if(!this.lastNeed)return T.toString("utf8",D);this.lastTotal=N;var A=T.length-(N-this.lastNeed);return T.copy(this.lastChar,0,A),T.toString("utf8",D,A)},u.prototype.fillLast=function(T){return this.lastNeed<=T.length?(T.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(T.copy(this.lastChar,this.lastTotal-this.lastNeed,0,T.length),void(this.lastNeed-=T.length))}},{"safe-buffer":30}],32:[function(s,o){(function(l){(function(){function a(c){try{if(!l.localStorage)return!1}catch{return!1}var u=l.localStorage[c];return u!=null&&(u+"").toLowerCase()==="true"}o.exports=function(c,u){function d(){if(!f){if(a("throwDeprecation"))throw new Error(u);a("traceDeprecation")?console.trace(u):console.warn(u),f=!0}return c.apply(this,arguments)}if(a("noDeprecation"))return c;var f=!1;return d}}).call(this)}).call(this,typeof _n>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:_n)},{}],"/":[function(s,o){function l(S){return S.replace(/a=ice-options:trickle\s\n/g,"")}function a(S){console.warn(S)}/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */const c=s("debug")("simple-peer"),u=s("get-browser-rtc"),d=s("randombytes"),f=s("readable-stream"),h=s("queue-microtask"),p=s("err-code"),{Buffer:g}=s("buffer"),v=65536;class w extends f.Duplex{constructor(x){if(x=Object.assign({allowHalfOpen:!1},x),super(x),this._id=d(4).toString("hex").slice(0,7),this._debug("new peer %o",x),this.channelName=x.initiator?x.channelName||d(20).toString("hex"):null,this.initiator=x.initiator||!1,this.channelConfig=x.channelConfig||w.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},w.config,x.config),this.offerOptions=x.offerOptions||{},this.answerOptions=x.answerOptions||{},this.sdpTransform=x.sdpTransform||(y=>y),this.streams=x.streams||(x.stream?[x.stream]:[]),this.trickle=x.trickle===void 0||x.trickle,this.allowHalfTrickle=x.allowHalfTrickle!==void 0&&x.allowHalfTrickle,this.iceCompleteTimeout=x.iceCompleteTimeout||5e3,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=x.wrtc&&typeof x.wrtc=="object"?x.wrtc:u(),!this._wrtc)throw p(typeof window>"u"?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(y){return void this.destroy(p(y,"ERR_PC_CONSTRUCTOR"))}this._isReactNativeWebrtc=typeof this._pc._peerConnectionId=="number",this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=y=>{this._onIceCandidate(y)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(y=>{this.destroy(p(y,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=y=>{this._setupData(y)},this.streams&&this.streams.forEach(y=>{this.addStream(y)}),this._pc.ontrack=y=>{this._onTrack(y)},this._debug("initial negotiation"),this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&this._channel.readyState==="open"}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(x){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof x=="string")try{x=JSON.parse(x)}catch{x={}}this._debug("signal()"),x.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),x.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(x.transceiverRequest.kind,x.transceiverRequest.init)),x.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(x.candidate):this._pendingCandidates.push(x.candidate)),x.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(x)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(y=>{this._addIceCandidate(y)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(y=>{this.destroy(p(y,"ERR_SET_REMOTE_DESCRIPTION"))}),x.sdp||x.candidate||x.renegotiate||x.transceiverRequest||this.destroy(p(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(x){const y=new this._wrtc.RTCIceCandidate(x);this._pc.addIceCandidate(y).catch(C=>{!y.address||y.address.endsWith(".local")?a("Ignoring unsupported ICE candidate."):this.destroy(p(C,"ERR_ADD_ICE_CANDIDATE"))})}send(x){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(x)}}addTransceiver(x,y){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(x,y),this._needsNegotiation()}catch(C){this.destroy(p(C,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:x,init:y}})}}addStream(x){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),x.getTracks().forEach(y=>{this.addTrack(y,x)})}}addTrack(x,y){if(this.destroying)return;if(this.destroyed)throw p(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const C=this._senderMap.get(x)||new Map;let E=C.get(y);if(!E)E=this._pc.addTrack(x,y),C.set(y,E),this._senderMap.set(x,C),this._needsNegotiation();else throw E.removed?p(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):p(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(x,y,C){if(this.destroying)return;if(this.destroyed)throw p(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const E=this._senderMap.get(x),T=E?E.get(C):null;if(!T)throw p(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");y&&this._senderMap.set(y,E),T.replaceTrack==null?this.destroy(p(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK")):T.replaceTrack(y)}removeTrack(x,y){if(this.destroying)return;if(this.destroyed)throw p(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const C=this._senderMap.get(x),E=C?C.get(y):null;if(!E)throw p(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{E.removed=!0,this._pc.removeTrack(E)}catch(T){T.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(E):this.destroy(p(T,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(x){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),x.getTracks().forEach(y=>{this.removeTrack(y,x)})}}_needsNegotiation(){this._debug("_needsNegotiation"),this._batchedNegotiation||(this._batchedNegotiation=!0,h(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(x){this._destroy(x,()=>{})}_destroy(x,y){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",x&&(x.message||x)),h(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",x&&(x.message||x)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch{}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch{}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,x&&this.emit("error",x),this.emit("close"),y()}))}_setupData(x){if(!x.channel)return this.destroy(p(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=x.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=v),this.channelName=this._channel.label,this._channel.onmessage=C=>{this._onChannelMessage(C)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=C=>{const E=C.error instanceof Error?C.error:new Error(`Datachannel error: ${C.message} ${C.filename}:${C.lineno}:${C.colno}`);this.destroy(p(E,"ERR_DATA_CHANNEL"))};let y=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(y&&this._onChannelClose(),y=!0):y=!1},5e3)}_read(){}_write(x,y,C){if(this.destroyed)return C(p(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(x)}catch(E){return this.destroy(p(E,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>v?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=C):C(null)}else this._debug("write before connect"),this._chunk=x,this._cb=C}_onFinish(){if(!this.destroyed){const x=()=>{setTimeout(()=>this.destroy(),1e3)};this._connected?x():this.once("connect",x)}}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(x=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(x.sdp=l(x.sdp)),x.sdp=this.sdpTransform(x.sdp);const y=()=>{if(!this.destroyed){const C=this._pc.localDescription||x;this._debug("signal"),this.emit("signal",{type:C.type,sdp:C.sdp})}};this._pc.setLocalDescription(x).then(()=>{this._debug("createOffer success"),this.destroyed||(this.trickle||this._iceComplete?y():this.once("_iceComplete",y))}).catch(C=>{this.destroy(p(C,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(x=>{this.destroy(p(x,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(x=>{x.mid||!x.sender.track||x.requested||(x.requested=!0,this.addTransceiver(x.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(x=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(x.sdp=l(x.sdp)),x.sdp=this.sdpTransform(x.sdp);const y=()=>{if(!this.destroyed){const C=this._pc.localDescription||x;this._debug("signal"),this.emit("signal",{type:C.type,sdp:C.sdp}),this.initiator||this._requestMissingTransceivers()}};this._pc.setLocalDescription(x).then(()=>{this.destroyed||(this.trickle||this._iceComplete?y():this.once("_iceComplete",y))}).catch(C=>{this.destroy(p(C,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(x=>{this.destroy(p(x,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||this._pc.connectionState==="failed"&&this.destroy(p(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const x=this._pc.iceConnectionState,y=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",x,y),this.emit("iceStateChange",x,y),(x==="connected"||x==="completed")&&(this._pcReady=!0,this._maybeReady()),x==="failed"&&this.destroy(p(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),x==="closed"&&this.destroy(p(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(x){const y=C=>(Object.prototype.toString.call(C.values)==="[object Array]"&&C.values.forEach(E=>{Object.assign(C,E)}),C);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(C=>{const E=[];C.forEach(T=>{E.push(y(T))}),x(null,E)},C=>x(C)):0<this._pc.getStats.length?this._pc.getStats(C=>{if(this.destroyed)return;const E=[];C.result().forEach(T=>{const D={};T.names().forEach(N=>{D[N]=T.stat(N)}),D.id=T.id,D.type=T.type,D.timestamp=T.timestamp,E.push(y(D))}),x(null,E)},C=>x(C)):x(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const x=()=>{this.destroyed||this.getStats((y,C)=>{if(this.destroyed)return;y&&(C=[]);const E={},T={},D={};let N=!1;C.forEach(R=>{(R.type==="remotecandidate"||R.type==="remote-candidate")&&(E[R.id]=R),(R.type==="localcandidate"||R.type==="local-candidate")&&(T[R.id]=R),(R.type==="candidatepair"||R.type==="candidate-pair")&&(D[R.id]=R)});const A=R=>{N=!0;let P=T[R.localCandidateId];P&&(P.ip||P.address)?(this.localAddress=P.ip||P.address,this.localPort=+P.port):P&&P.ipAddress?(this.localAddress=P.ipAddress,this.localPort=+P.portNumber):typeof R.googLocalAddress=="string"&&(P=R.googLocalAddress.split(":"),this.localAddress=P[0],this.localPort=+P[1]),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let B=E[R.remoteCandidateId];B&&(B.ip||B.address)?(this.remoteAddress=B.ip||B.address,this.remotePort=+B.port):B&&B.ipAddress?(this.remoteAddress=B.ipAddress,this.remotePort=+B.portNumber):typeof R.googRemoteAddress=="string"&&(B=R.googRemoteAddress.split(":"),this.remoteAddress=B[0],this.remotePort=+B[1]),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(C.forEach(R=>{R.type==="transport"&&R.selectedCandidatePairId&&A(D[R.selectedCandidatePairId]),(R.type==="googCandidatePair"&&R.googActiveConnection==="true"||(R.type==="candidatepair"||R.type==="candidate-pair")&&R.selected)&&A(R)}),!N&&(!Object.keys(D).length||Object.keys(T).length))return void setTimeout(x,100);if(this._connecting=!1,this._connected=!0,this._chunk){try{this.send(this._chunk)}catch(P){return this.destroy(p(P,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const R=this._cb;this._cb=null,R(null)}typeof this._channel.bufferedAmountLowThreshold!="number"&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};x()}_onInterval(){this._cb&&this._channel&&!(this._channel.bufferedAmount>v)&&this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(this._pc.signalingState==="stable"&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(x=>{this._pc.removeTrack(x),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(x){this.destroyed||(x.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:x.candidate.candidate,sdpMLineIndex:x.candidate.sdpMLineIndex,sdpMid:x.candidate.sdpMid}}):!x.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),x.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(x){if(this.destroyed)return;let y=x.data;y instanceof ArrayBuffer&&(y=g.from(y)),this.push(y)}_onChannelBufferedAmountLow(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const x=this._cb;this._cb=null,x(null)}}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(x){this.destroyed||x.streams.forEach(y=>{this._debug("on track"),this.emit("track",x.track,y),this._remoteTracks.push({track:x.track,stream:y}),this._remoteStreams.some(C=>C.id===y.id)||(this._remoteStreams.push(y),h(()=>{this._debug("on stream"),this.emit("stream",y)}))})}_debug(){const x=[].slice.call(arguments);x[0]="["+this._id+"] "+x[0],c.apply(null,x)}}w.WEBRTC_SUPPORT=!!u(),w.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},w.channelConfig={},o.exports=w},{buffer:3,debug:4,"err-code":6,"get-browser-rtc":8,"queue-microtask":13,randombytes:14,"readable-stream":29}]},{},[])("/")})})(Tb);var AO=Tb.exports;const MO=Fc(AO),pf=0,mf=1,Ab=2,Mb=(t,e)=>{ae(t,pf);const n=CM(e);Ze(t,n)},Ob=(t,e,n)=>{ae(t,mf),Ze(t,Yd(e,n))},OO=(t,e,n)=>Ob(e,n,bt(t)),_b=(t,e,n)=>{try{L0(e,bt(t),n)}catch(r){console.error("Caught error while handling a Yjs update",r)}},_O=(t,e)=>{ae(t,Ab),Ze(t,e)},NO=_b,DO=(t,e,n,r)=>{const i=me(t);switch(i){case pf:OO(t,e,n);break;case mf:_b(t,n,r);break;case Ab:NO(t,n,r);break;default:throw new Error("Unknown message type")}return i},gf=3e4;class RO extends xd{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const n=Bn();this.getLocalState()!==null&&gf/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const r=[];this.meta.forEach((i,s)=>{s!==this.clientID&&gf<=n-i.lastUpdated&&this.states.has(s)&&r.push(s)}),r.length>0&&yf(this,r,"timeout")},wn(gf/10)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const n=this.clientID,r=this.meta.get(n),i=r===void 0?0:r.clock+1,s=this.states.get(n);e===null?this.states.delete(n):this.states.set(n,e),this.meta.set(n,{clock:i,lastUpdated:Bn()});const o=[],l=[],a=[],c=[];e===null?c.push(n):s==null?e!=null&&o.push(n):(l.push(n),Mo(s,e)||a.push(n)),(o.length>0||a.length>0||c.length>0)&&this.emit("change",[{added:o,updated:a,removed:c},"local"]),this.emit("update",[{added:o,updated:l,removed:c},"local"])}setLocalStateField(e,n){const r=this.getLocalState();r!==null&&this.setLocalState({...r,[e]:n})}getStates(){return this.states}}const yf=(t,e,n)=>{const r=[];for(let i=0;i<e.length;i++){const s=e[i];if(t.states.has(s)){if(t.states.delete(s),s===t.clientID){const o=t.meta.get(s);t.meta.set(s,{clock:o.clock+1,lastUpdated:Bn()})}r.push(s)}}r.length>0&&(t.emit("change",[{added:[],updated:[],removed:r},n]),t.emit("update",[{added:[],updated:[],removed:r},n]))},xa=(t,e,n=t.states)=>{const r=e.length,i=gt();ae(i,r);for(let s=0;s<r;s++){const o=e[s],l=n.get(o)||null,a=t.meta.get(o).clock;ae(i,o),ae(i,a),jn(i,JSON.stringify(l))}return qe(i)},LO=(t,e,n)=>{const r=Hn(e),i=Bn(),s=[],o=[],l=[],a=[],c=me(r);for(let u=0;u<c;u++){const d=me(r);let f=me(r);const h=JSON.parse(ur(r)),p=t.meta.get(d),g=t.states.get(d),v=p===void 0?0:p.clock;(v<f||v===f&&h===null&&t.states.has(d))&&(h===null?d===t.clientID&&t.getLocalState()!=null?f++:t.states.delete(d):t.states.set(d,h),t.meta.set(d,{clock:f,lastUpdated:i}),p===void 0&&h!==null?s.push(d):p!==void 0&&h===null?a.push(d):h!==null&&(Mo(h,g)||l.push(d),o.push(d)))}(s.length>0||l.length>0||a.length>0)&&t.emit("change",[{added:s,updated:l,removed:a},n]),(s.length>0||o.length>0||a.length>0)&&t.emit("update",[{added:s,updated:o,removed:a},n])},IO=(t,e)=>{const n=Td(t).buffer,r=Td(e).buffer;return crypto.subtle.importKey("raw",n,"PBKDF2",!1,["deriveKey"]).then(i=>crypto.subtle.deriveKey({name:"PBKDF2",salt:r,iterations:1e5,hash:"SHA-256"},i,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]))},Nb=(t,e)=>{if(!e)return zd(t);const n=crypto.getRandomValues(new Uint8Array(12));return crypto.subtle.encrypt({name:"AES-GCM",iv:n},e,t).then(r=>{const i=gt();return jn(i,"AES-GCM"),Ze(i,n),Ze(i,new Uint8Array(r)),qe(i)})},PO=(t,e)=>{const n=gt();return ns(n,t),Nb(qe(n),e)},Db=(t,e)=>{if(!e)return zd(t);const n=Hn(t);ur(n)!=="AES-GCM"&&X2(xn("Unknown encryption algorithm"));const i=bt(n),s=bt(n);return crypto.subtle.decrypt({name:"AES-GCM",iv:i},e,s).then(o=>new Uint8Array(o))},FO=(t,e)=>Db(t,e).then(n=>rs(Hn(new Uint8Array(n)))),Zt=Y2("y-webrtc"),bs=0,Rb=3,Ho=1,bf=4,ka=new Map,Si=new Map,Lb=t=>{let e=!0;t.webrtcConns.forEach(n=>{n.synced||(e=!1)}),(!e&&t.synced||e&&!t.synced)&&(t.synced=e,t.provider.emit("synced",[{synced:e}]),Zt("synced ",un,t.name,yi," with all peers"))},Ib=(t,e,n)=>{const r=Hn(e),i=gt(),s=me(r);if(t===void 0)return null;const o=t.awareness,l=t.doc;let a=!1;switch(s){case bs:{ae(i,bs);const c=DO(r,i,l,t);c===mf&&!t.synced&&n(),c===pf&&(a=!0);break}case Rb:ae(i,Ho),Ze(i,xa(o,Array.from(o.getStates().keys()))),a=!0;break;case Ho:LO(o,bt(r),t);break;case bf:{const c=gi(r)===1,u=ur(r);if(u!==t.peerId&&(t.bcConns.has(u)&&!c||!t.bcConns.has(u)&&c)){const d=[],f=[];c?(t.bcConns.add(u),f.push(u)):(t.bcConns.delete(u),d.push(u)),t.provider.emit("peers",[{added:f,removed:d,webrtcPeers:Array.from(t.webrtcConns.keys()),bcPeers:Array.from(t.bcConns)}]),$b(t)}break}default:return console.error("Unable to compute message"),i}return a?i:null},$O=(t,e)=>{const n=t.room;return Zt("received message from ",un,t.remotePeerId,jd," (",n.name,")",yi,oa),Ib(n,e,()=>{t.synced=!0,Zt("synced ",un,n.name,yi," with ",un,t.remotePeerId),Lb(n)})},vf=(t,e)=>{Zt("send message to ",un,t.remotePeerId,yi,jd," (",t.room.name,")",oa);try{t.peer.send(qe(e))}catch{}},BO=(t,e)=>{Zt("broadcast message in ",un,t.name,yi),t.webrtcConns.forEach(n=>{try{n.peer.send(e)}catch{}})};class Pb{constructor(e,n,r,i){Zt("establishing connection to ",un,r),this.room=i,this.remotePeerId=r,this.glareToken=void 0,this.closed=!1,this.connected=!1,this.synced=!1,this.peer=new MO({initiator:n,...i.provider.peerOpts}),this.peer.on("signal",s=>{this.glareToken===void 0&&(this.glareToken=Date.now()+Math.random()),xf(e,i,{to:r,from:i.peerId,type:"signal",token:this.glareToken,signal:s})}),this.peer.on("connect",()=>{Zt("connected to ",un,r),this.connected=!0;const o=i.provider.doc,l=i.awareness,a=gt();ae(a,bs),Mb(a,o),vf(this,a);const c=l.getStates();if(c.size>0){const u=gt();ae(u,Ho),Ze(u,xa(l,Array.from(c.keys()))),vf(this,u)}}),this.peer.on("close",()=>{this.connected=!1,this.closed=!0,i.webrtcConns.has(this.remotePeerId)&&(i.webrtcConns.delete(this.remotePeerId),i.provider.emit("peers",[{removed:[this.remotePeerId],added:[],webrtcPeers:Array.from(i.webrtcConns.keys()),bcPeers:Array.from(i.bcConns)}])),Lb(i),this.peer.destroy(),Zt("closed connection to ",un,r),wf(i)}),this.peer.on("error",s=>{Zt("Error in connection to ",un,r,": ",s),wf(i)}),this.peer.on("data",s=>{const o=$O(this,s);o!==null&&vf(this,o)})}destroy(){this.peer.destroy()}}const Br=(t,e)=>Nb(e,t.key).then(n=>t.mux(()=>cM(t.name,n))),Fb=(t,e)=>{t.bcconnected&&Br(t,e),BO(t,e)},wf=t=>{ka.forEach(e=>{e.connected&&(e.send({type:"subscribe",topics:[t.name]}),t.webrtcConns.size<t.provider.maxConns&&xf(e,t,{type:"announce",from:t.peerId}))})},$b=t=>{if(t.provider.filterBcConns){const e=gt();ae(e,bf),Ao(e,1),jn(e,t.peerId),Br(t,qe(e))}};class jO{constructor(e,n,r,i){this.peerId=Ky(),this.doc=e,this.awareness=n.awareness,this.provider=n,this.synced=!1,this.name=r,this.key=i,this.webrtcConns=new Map,this.bcConns=new Set,this.mux=C0(),this.bcconnected=!1,this._bcSubscriber=s=>Db(new Uint8Array(s),i).then(o=>this.mux(()=>{const l=Ib(this,o,()=>{});l&&Br(this,qe(l))})),this._docUpdateHandler=(s,o)=>{const l=gt();ae(l,bs),_O(l,s),Fb(this,qe(l))},this._awarenessUpdateHandler=({added:s,updated:o,removed:l},a)=>{const c=s.concat(o).concat(l),u=gt();ae(u,Ho),Ze(u,xa(this.awareness,c)),Fb(this,qe(u))},this._beforeUnloadHandler=()=>{yf(this.awareness,[e.clientID],"window unload"),Si.forEach(s=>{s.disconnect()})},typeof window<"u"?window.addEventListener("beforeunload",this._beforeUnloadHandler):typeof process<"u"&&process.on("exit",this._beforeUnloadHandler)}connect(){this.doc.on("update",this._docUpdateHandler),this.awareness.on("update",this._awarenessUpdateHandler),wf(this);const e=this.name;lM(e,this._bcSubscriber),this.bcconnected=!0,$b(this);const n=gt();ae(n,bs),Mb(n,this.doc),Br(this,qe(n));const r=gt();ae(r,bs),Ob(r,this.doc),Br(this,qe(r));const i=gt();ae(i,Rb),Br(this,qe(i));const s=gt();ae(s,Ho),Ze(s,xa(this.awareness,[this.doc.clientID])),Br(this,qe(s))}disconnect(){ka.forEach(n=>{n.connected&&n.send({type:"unsubscribe",topics:[this.name]})}),yf(this.awareness,[this.doc.clientID],"disconnect");const e=gt();ae(e,bf),Ao(e,0),jn(e,this.peerId),Br(this,qe(e)),aM(this.name,this._bcSubscriber),this.bcconnected=!1,this.doc.off("update",this._docUpdateHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.webrtcConns.forEach(n=>n.destroy())}destroy(){this.disconnect(),typeof window<"u"?window.removeEventListener("beforeunload",this._beforeUnloadHandler):typeof process<"u"&&process.off("exit",this._beforeUnloadHandler)}}const HO=(t,e,n,r)=>{if(Si.has(n))throw xn(`A Yjs Doc connected to room "${n}" already exists!`);const i=new jO(t,e,n,r);return Si.set(n,i),i},xf=(t,e,n)=>{e.key?PO(n,e.key).then(r=>{t.send({type:"publish",topic:e.name,data:w0(r)})}):t.send({type:"publish",topic:e.name,data:n})};class zO extends t2{constructor(e){super(e),this.providers=new Set,this.on("connect",()=>{Zt(`connected (${e})`);const n=Array.from(Si.keys());this.send({type:"subscribe",topics:n}),Si.forEach(r=>xf(this,r,{type:"announce",from:r.peerId}))}),this.on("message",n=>{switch(n.type){case"publish":{const r=n.topic,i=Si.get(r);if(i==null||typeof r!="string")return;const s=o=>{const l=i.webrtcConns,a=i.peerId;if(o==null||o.from===a||o.to!==void 0&&o.to!==a||i.bcConns.has(o.from))return;const c=l.has(o.from)?()=>{}:()=>i.provider.emit("peers",[{removed:[],added:[o.from],webrtcPeers:Array.from(i.webrtcConns.keys()),bcPeers:Array.from(i.bcConns)}]);switch(o.type){case"announce":l.size<i.provider.maxConns&&(Vt(l,o.from,()=>new Pb(this,!0,o.from,i)),c());break;case"signal":if(o.signal.type==="offer"){const u=l.get(o.from);if(u){const d=o.token,f=u.glareToken;if(f&&f>d){Zt("offer rejected: ",o.from);return}u.glareToken=void 0}}if(o.signal.type==="answer"){Zt("offer answered by: ",o.from);const u=l.get(o.from);u.glareToken=void 0}o.to===a&&(Vt(l,o.from,()=>new Pb(this,!1,o.from,i)).peer.signal(o.signal),c());break}};i.key?typeof n.data=="string"&&FO(x0(n.data),i.key).then(s):s(n.data)}}}),this.on("disconnect",()=>Zt(`disconnect (${e})`))}}const kf=t=>{t.emit("status",[{connected:t.connected}])};class VO extends wd{constructor(e,n,{signaling:r=["wss://y-webrtc-eu.fly.dev"],password:i=null,awareness:s=new RO(n),maxConns:o=20+wn(Wy()*15),filterBcConns:l=!0,peerOpts:a={}}={}){super(),this.roomName=e,this.doc=n,this.filterBcConns=l,this.awareness=s,this.shouldConnect=!1,this.signalingUrls=r,this.signalingConns=[],this.maxConns=o,this.peerOpts=a,this.key=i?IO(i,e):zd(null),this.room=null,this.key.then(c=>{this.room=HO(n,this,e,c),this.shouldConnect?this.room.connect():this.room.disconnect(),kf(this)}),this.connect(),this.destroy=this.destroy.bind(this),n.on("destroy",this.destroy)}get connected(){return this.room!==null&&this.shouldConnect}connect(){this.shouldConnect=!0,this.signalingUrls.forEach(e=>{const n=Vt(ka,e,()=>new zO(e));this.signalingConns.push(n),n.providers.add(this)}),this.room&&(this.room.connect(),kf(this))}disconnect(){this.shouldConnect=!1,this.signalingConns.forEach(e=>{e.providers.delete(this),e.providers.size===0&&(e.destroy(),ka.delete(e.url))}),this.room&&(this.room.disconnect(),kf(this))}destroy(){this.doc.off("destroy",this.destroy),this.key.then(()=>{this.room.destroy(),Si.delete(this.roomName)}),super.destroy()}}const Bb={attributes:{class:"prose-lg prose-headings:font-display prose prose-p:my-2 prose-h1:my-2 prose-h2:my-2 prose-h3:my-2 prose-ul:my-2 prose-ol:my-2 max-w-none focus:outline-none w-full",spellcheck:"false",suppressContentEditableWarning:"true"},handleDOMEvents:{keydown:(t,e)=>{if(["ArrowUp","ArrowDown","Enter"].includes(e.key)&&document.querySelector("#slash-command"))return!0}}},UO=/[\uD800-\uDBFF]/,WO=/[\uDC00-\uDFFF]/,qO=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&UO.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&&WO.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},Ke=new We("y-sync"),hr=new We("y-undo"),Ca=new We("yjs-cursor"),Sa=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!as(e.ds,t.id),KO=[{light:"#ecd44433",dark:"#ecd444"}],JO=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=or();t.forEach(i=>r.add(i)),e=e.filter(i=>!r.has(i))}t.set(n,i2(e))}return t.get(n)},GO=(t,{colors:e=KO,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{}}={})=>{let s=!1;const o=new je({props:{editable:l=>{const a=Ke.getState(l);return a.snapshot==null&&a.prevSnapshot==null}},key:Ke,state:{init:(l,a)=>({type:t,doc:t.doc,binding:null,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(l,a)=>{const c=l.getMeta(Ke);if(c!==void 0){a=Object.assign({},a);for(const u in c)a[u]=c[u]}return a.addToHistory=l.getMeta("addToHistory")!==!1,a.isChangeOrigin=c!==void 0&&!!c.isChangeOrigin,a.isUndoRedoOperation=c!==void 0&&!!c.isChangeOrigin&&!!c.isUndoRedoOperation,a.binding!==null&&c!==void 0&&(c.snapshot!=null||c.prevSnapshot!=null)&&Bd(0,()=>{a.binding==null||a.binding.isDestroyed||(c.restore==null?a.binding._renderSnapshot(c.snapshot,c.prevSnapshot,a):(a.binding._renderSnapshot(c.snapshot,c.snapshot,a),delete a.restore,delete a.snapshot,delete a.prevSnapshot,a.binding.mux(()=>{a.binding._prosemirrorChanged(a.binding.prosemirrorView.state.doc)})))}),a}},view:l=>{const a=new XO(t,l);return a._forceRerender(),i(),{update:()=>{const c=o.getState(l.state);if(c.snapshot==null&&c.prevSnapshot==null&&(s||l.state.doc.content.findDiffStart(l.state.doc.type.createAndFill().content)!==null)){if(s=!0,c.addToHistory===!1&&!c.isChangeOrigin){const u=hr.getState(l.state),d=u&&u.undoManager;d&&d.stopCapturing()}a.mux(()=>{c.doc.transact(u=>{u.meta.set("addToHistory",c.addToHistory),a._prosemirrorChanged(l.state.doc)},Ke)})}},destroy:()=>{a.destroy()}}}});return o},YO=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null){const r=Uo(n.doc,n.type,e.anchor,n.mapping),i=Uo(n.doc,n.type,e.head,n.mapping);r!==null&&i!==null&&(t=t.setSelection(ce.create(t.doc,r,i)))}},Cf=(t,e)=>({anchor:Ma(e.selection.anchor,t.type,t.mapping),head:Ma(e.selection.head,t.type,t.mapping)});class XO{constructor(e,n){this.type=e,this.prosemirrorView=n,this.mux=C0(),this.isDestroyed=!1,this.mapping=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&(this.beforeTransactionSelection=Cf(this,n.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),e.observeDeep(this._observeFunction),this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(Fd&&this._domSelectionInView===null&&(Bd(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection(),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 i=n.getBoundingClientRect(),s=z2.documentElement;return i.bottom>=0&&i.right>=0&&i.left<=(window.innerWidth||s.clientWidth||0)&&i.top<=(window.innerHeight||s.clientHeight||0)}renderSnapshot(e,n){n||(n=z0(E0(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Ke,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping=new Map,this.mux(()=>{const e=this.type.toArray().map(r=>Ea(r,this.prosemirrorView.state.schema,this.mapping)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Y(W.from(e),0,0));n.setMeta(Ke,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping=new Map,this.mux(()=>{const e=this.type.toArray().map(r=>Ea(r,this.prosemirrorView.state.schema,this.mapping)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Y(W.from(e),0,0));this.prosemirrorView.dispatch(n.setMeta(Ke,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){e||(e=MM(this.doc)),this.mapping=new Map,this.mux(()=>{this.doc.transact(i=>{const s=r.permanentUserData;s&&s.dss.forEach(c=>{Pr(i,c,u=>{})});const o=(c,u)=>{const d=c==="added"?s.getUserByClientId(u.client):s.getUserByDeletedId(u);return{user:d,type:c,color:JO(r.colorMapping,r.colors,d)}},l=sb(this.type,new Zd(n.ds,e.sv)).map(c=>!c._item.deleted||Sa(c._item,e)||Sa(c._item,n)?Ea(c,this.prosemirrorView.state.schema,new Map,e,n,o):null).filter(c=>c!==null),a=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Y(W.from(l),0,0));this.prosemirrorView.dispatch(a.setMeta(Ke,{isChangeOrigin:!0}))},Ke)})}_typeChanged(e,n){const r=Ke.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const i=(l,a)=>this.mapping.delete(a);Pr(n,n.deleteSet,l=>{if(l.constructor===Ve){const a=l.content.type;a&&this.mapping.delete(a)}}),n.changed.forEach(i),n.changedParentTypes.forEach(i);const s=this.type.toArray().map(l=>jb(l,this.prosemirrorView.state.schema,this.mapping)).filter(l=>l!==null);let o=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Y(W.from(s),0,0));YO(o,this.beforeTransactionSelection,this),o=o.setMeta(Ke,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof Z0}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(e){this.doc.transact(()=>{Tf(this.doc,this.type,e,this.mapping),this.beforeTransactionSelection=Cf(this,this.prosemirrorView.state)},Ke)}destroy(){this.isDestroyed=!0,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions)}}const jb=(t,e,n,r,i,s)=>{const o=n.get(t);if(o===void 0){if(t instanceof It)return Ea(t,e,n,r,i,s);throw kn()}return o},Ea=(t,e,n,r,i,s)=>{const o=[],l=a=>{if(a.constructor===It){const c=jb(a,e,n,r,i,s);c!==null&&o.push(c)}else{const c=ZO(a,e,n,r,i,s);c!==null&&c.forEach(u=>{u!==null&&o.push(u)})}};r===void 0||i===void 0?t.toArray().forEach(l):sb(t,new Zd(i.ds,r.sv)).forEach(l);try{const a=t.getAttributes(r);r!==void 0&&(Sa(t._item,r)?Sa(t._item,i)||(a.ychange=s?s("added",t._item.id):{type:"added"}):a.ychange=s?s("removed",t._item.id):{type:"removed"});const c=e.node(t.nodeName,a,o);return n.set(t,c),c}catch{return t.doc.transact(c=>{t._item.delete(c)},Ke),n.delete(t),null}},ZO=(t,e,n,r,i,s)=>{const o=[],l=t.toDelta(r,i,s);try{for(let a=0;a<l.length;a++){const c=l[a],u=[];for(const d in c.attributes)u.push(e.mark(d,c.attributes[d]));o.push(e.text(c.insert,u))}}catch{return t.doc.transact(c=>{t._item.delete(c)},Ke),null}return o},QO=(t,e)=>{const n=new Xt,r=t.map(i=>({insert:i.text,attributes:Ub(i.marks)}));return n.applyDelta(r),e.set(n,t),n},e_=(t,e)=>{const n=new It(t.type.name);for(const r in t.attrs){const i=t.attrs[r];i!==null&&r!=="ychange"&&n.setAttribute(r,i)}return n.insert(0,Ta(t).map(r=>Sf(r,e))),e.set(n,t),n},Sf=(t,e)=>t instanceof Array?QO(t,e):e_(t,e),Hb=t=>typeof t=="object"&&t!==null,Ef=(t,e)=>{const n=Object.keys(t).filter(i=>t[i]!==null);let r=n.length===Object.keys(e).filter(i=>e[i]!==null).length;for(let i=0;i<n.length&&r;i++){const s=n[i],o=t[s],l=e[s];r=s==="ychange"||o===l||Hb(o)&&Hb(l)&&Ef(o,l)}return r},Ta=t=>{const e=t.content.content,n=[];for(let r=0;r<e.length;r++){const i=e[r];if(i.isText){const s=[];for(let o=e[r];r<e.length&&o.isText;o=e[++r])s.push(o);r--,n.push(s)}else n.push(i)}return n},zb=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,i)=>r.insert===e[i].text&&Id(r.attributes||{}).length===e[i].marks.length&&e[i].marks.every(s=>Ef(r.attributes[s.type.name]||{},s.attrs)))},zo=(t,e)=>{if(t instanceof It&&!(e instanceof Array)&&Af(t,e)){const n=Ta(e);return t._length===n.length&&Ef(t.getAttributes(),e.attrs)&&t.toArray().every((r,i)=>zo(r,n[i]))}return t instanceof Xt&&e instanceof Array&&zb(t,e)},Aa=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),Vb=(t,e,n)=>{const r=t.toArray(),i=Ta(e),s=i.length,o=r.length,l=Ir(o,s);let a=0,c=0,u=!1;for(;a<l;a++){const d=r[a],f=i[a];if(Aa(n.get(d),f))u=!0;else if(!zo(d,f))break}for(;a+c<l;c++){const d=r[o-c-1],f=i[s-c-1];if(Aa(n.get(d),f))u=!0;else if(!zo(d,f))break}return{equalityFactor:a+c,foundMappedChild:u}},t_=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Cn?e+=n.content.str:n.content instanceof lt&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},n_=(t,e,n)=>{n.set(t,e);const{nAttrs:r,str:i}=t_(t),s=e.map(c=>({insert:c.text,attributes:Object.assign({},r,Ub(c.marks))})),{insert:o,remove:l,index:a}=qO(i,s.map(c=>c.insert).join(""));t.delete(a,l),t.insert(a,o),t.applyDelta(s.map(c=>({retain:c.insert.length,attributes:c.attributes})))},Ub=t=>{const e={};return t.forEach(n=>{n.type.name!=="ychange"&&(e[n.type.name]=n.attrs)}),e},Tf=(t,e,n,r)=>{if(e instanceof It&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.set(e,n),e instanceof It){const d=e.getAttributes(),f=n.attrs;for(const h in f)f[h]!==null?d[h]!==f[h]&&h!=="ychange"&&e.setAttribute(h,f[h]):e.removeAttribute(h);for(const h in d)f[h]===void 0&&e.removeAttribute(h)}const i=Ta(n),s=i.length,o=e.toArray(),l=o.length,a=Ir(s,l);let c=0,u=0;for(;c<a;c++){const d=o[c],f=i[c];if(!Aa(r.get(d),f))if(zo(d,f))r.set(d,f);else break}for(;u+c+1<a;u++){const d=o[l-u-1],f=i[s-u-1];if(!Aa(r.get(d),f))if(zo(d,f))r.set(d,f);else break}t.transact(()=>{for(;l-c-u>0&&s-c-u>0;){const f=o[c],h=i[c],p=o[l-u-1],g=i[s-u-1];if(f instanceof Xt&&h instanceof Array)zb(f,h)||n_(f,h,r),c+=1;else{let v=f instanceof It&&Af(f,h),w=p instanceof It&&Af(p,g);if(v&&w){const S=Vb(f,h,r),x=Vb(p,g,r);S.foundMappedChild&&!x.foundMappedChild?w=!1:!S.foundMappedChild&&x.foundMappedChild||S.equalityFactor<x.equalityFactor?v=!1:w=!1}v?(Tf(t,f,h,r),c+=1):w?(Tf(t,p,g,r),u+=1):(r.delete(e.get(c)),e.delete(c,1),e.insert(c,[Sf(h,r)]),c+=1)}}const d=l-c-u;if(l===1&&s===0&&o[0]instanceof Xt?(r.delete(o[0]),o[0].delete(0,o[0].length)):d>0&&(e.slice(c,c+d).forEach(f=>r.delete(f)),e.delete(c,d)),c+u<s){const f=[];for(let h=c;h<s-u;h++)f.push(Sf(i[h],r));e.insert(c,f)}},Ke)},Af=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name;let Vo=null;const r_=()=>{const t=Vo;Vo=null,t.forEach((e,n)=>{const r=n.state.tr,i=Ke.getState(n.state);i&&i.binding&&!i.binding.isDestroyed&&(e.forEach((s,o)=>{r.setMeta(o,s)}),n.dispatch(r))})},i_=(t,e,n)=>{Vo||(Vo=new Map,Bd(0,r_)),Vt(Vo,t,Lt).set(e,n)},Ma=(t,e,n)=>{if(t===0)return Xd(e,0);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof Xt){if(r._length>=t)return Xd(r,t);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 i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t<i)r=r._first.content.type,t--;else{if(t===1&&r._length===0&&i>1)return new Ro(r._item===null?null:r._item.id,r._item===null?No(r):null,null);if(t-=i,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 Ro(r._item===null?null:r._item.id,r._item===null?No(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 cn();if(t===0&&r.constructor!==Xt&&r!==e)return s_(r._item.parent,r._item)}return Xd(e,e._length)},s_=(t,e)=>{let n=null,r=null;return t._item===null?r=No(t):n=ge(t._item.id.client,t._item.id.clock),new Ro(n,r,e.id)},Uo=(t,e,n,r)=>{const i=AM(n,t);if(i===null||i.type!==e&&!Do(e,i.type._item))return null;let s=i.type,o=0;if(s.constructor===Xt)o=i.index;else if(s._item===null||!s._item.deleted){let l=s._first,a=0;for(;a<s._length&&a<i.index&&l!==null;){if(!l.deleted){const c=l.content.type;a++,c instanceof Xt?o+=c._length:o+=r.get(c).nodeSize}l=l.right}o+=1}for(;s!==e&&s._item!==null;){const l=s._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===s)break;a.deleted||(c instanceof Xt?o+=c._length:o+=r.get(c).nodeSize),a=a.right}}s=l}return o-1},o_=(t,e,n)=>t!==e,l_=t=>{const e=document.createElement("span");e.classList.add("ProseMirror-yjs-cursor"),e.setAttribute("style",`border-color: ${t.color}`);const n=document.createElement("div");n.setAttribute("style",`background-color: ${t.color}`),n.insertBefore(document.createTextNode(t.name),null);const r=document.createTextNode(""),i=document.createTextNode("");return e.insertBefore(r,null),e.insertBefore(n,null),e.insertBefore(i,null),e},Wb=t=>({style:`background-color: ${t.color}70`,class:"ProseMirror-yjs-selection"}),a_=/^#[0-9a-fA-F]{6}$/,qb=(t,e,n,r,i)=>{const s=Ke.getState(t),o=s.doc,l=[];return s.snapshot!=null||s.prevSnapshot!=null||s.binding===null?He.create(t.doc,[]):(e.getStates().forEach((a,c)=>{if(n(o.clientID,c,a)&&a.cursor!=null){const u=a.user||{};u.color==null?u.color="#ffa500":a_.test(u.color)||console.warn("A user uses an unsupported color format",u),u.name==null&&(u.name=`User: ${c}`);let d=Uo(o,s.type,Lo(a.cursor.anchor),s.binding.mapping),f=Uo(o,s.type,Lo(a.cursor.head),s.binding.mapping);if(d!==null&&f!==null){const h=ar(t.doc.content.size-1,0);d=Ir(d,h),f=Ir(f,h),l.push(ut.widget(f,()=>r(u),{key:c+"",side:10}));const p=Ir(d,f),g=ar(d,f);l.push(ut.inline(p,g,i(u),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),He.create(t.doc,l))},c_=(t,{awarenessStateFilter:e=o_,cursorBuilder:n=l_,selectionBuilder:r=Wb,getSelection:i=o=>o.selection}={},s="cursor")=>new je({key:Ca,state:{init(o,l){return qb(l,t,e,n,r)},apply(o,l,a,c){const u=Ke.getState(c),d=o.getMeta(Ca);return u&&u.isChangeOrigin||d&&d.awarenessUpdated?qb(c,t,e,n,r):l.map(o.mapping,o.doc)}},props:{decorations:o=>Ca.getState(o)},view:o=>{const l=()=>{o.docView&&i_(o,Ca,{awarenessUpdated:!0})},a=()=>{const c=Ke.getState(o.state),u=t.getLocalState()||{};if(c.binding!=null)if(o.hasFocus()){const d=i(o.state),f=Ma(d.anchor,c.type,c.binding.mapping),h=Ma(d.head,c.type,c.binding.mapping);(u.cursor==null||!H0(Lo(u.cursor.anchor),f)||!H0(Lo(u.cursor.head),h))&&t.setLocalStateField(s,{anchor:f,head:h})}else u.cursor!=null&&Uo(c.doc,c.type,Lo(u.cursor.anchor),c.binding.mapping)!==null&&t.setLocalStateField(s,null)};return t.on("change",l),o.dom.addEventListener("focusin",a),o.dom.addEventListener("focusout",a),{update:a,destroy:()=>{o.dom.removeEventListener("focusin",a),o.dom.removeEventListener("focusout",a),t.off("change",l),t.setLocalStateField(s,null)}}}}),u_=t=>{const e=hr.getState(t).undoManager;if(e!=null)return e.undo(),!0},d_=t=>{const e=hr.getState(t).undoManager;if(e!=null)return e.redo(),!0},f_=new Set(["paragraph"]),h_=(t,e)=>!(t instanceof Ve)||!(t.content instanceof Sn)||!(t.content.type instanceof wi||t.content.type instanceof It&&e.has(t.content.type.nodeName))||t.content.type._length===0,p_=({protectedNodes:t=f_,trackedOrigins:e=[],undoManager:n=null}={})=>new je({key:hr,state:{init:(r,i)=>{const s=Ke.getState(i),o=n||new Z0(s.type,{trackedOrigins:new Set([Ke].concat(e)),deleteFilter:l=>h_(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,i,s,o)=>{const l=Ke.getState(o).binding,a=i.undoManager,c=a.undoStack.length>0,u=a.redoStack.length>0;return l?{undoManager:a,prevSel:Cf(l,s),hasUndoOps:c,hasRedoOps:u}:c!==i.hasUndoOps||u!==i.hasRedoOps?Object.assign({},i,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):i}},view:r=>{const i=Ke.getState(r.state),s=hr.getState(r.state).undoManager;return s.on("stack-item-added",({stackItem:o})=>{const l=i.binding;l&&o.meta.set(l,hr.getState(r.state).prevSel)}),s.on("stack-item-popped",({stackItem:o})=>{const l=i.binding;l&&(l.beforeTransactionSelection=o.meta.get(l)||l.beforeTransactionSelection)}),{destroy:()=>{s.destroy()}}}}),m_=Ue.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null}},onCreate(){this.editor.extensionManager.extensions.find(t=>t.name==="history")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-history".')},addCommands(){return{undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),hr.getState(e).undoManager.undoStack.length===0?!1:n?u_(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),hr.getState(e).undoManager.redoStack.length===0?!1:n?d_(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=p_(),n=e.spec.view;e.spec.view=l=>{const{undoManager:a}=hr.getState(l.state);a.restore&&(a.restore(),a.restore=()=>{});const c=n?n(l):void 0;return{destroy:()=>{const u=a.trackedOrigins.has(a),d=a._observers;a.restore=()=>{u&&a.trackedOrigins.add(a),a.doc.on("afterTransaction",a.afterTransactionHandler),a._observers=d},c!=null&&c.destroy&&c.destroy()}}};const r=this.options.ySyncOptions,i=this.options.onFirstRender,s={...r?{...r}:{},...i?{onFirstRender:i}:{}};return[GO(t,s),e]}}),Kb=t=>Array.from(t.entries()).map(([e,n])=>({clientId:e,...n.user})),Jb=()=>null,g_=Ue.create({name:"collaborationCursor",addOptions(){return{provider:null,user:{name:null,color:null},render:t=>{const e=document.createElement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${t.color}`);const n=document.createElement("div");return n.classList.add("collaboration-cursor__label"),n.setAttribute("style",`background-color: ${t.color}`),n.insertBefore(document.createTextNode(t.name),null),e.insertBefore(n,null),e},selectionRender:Wb,onUpdate:Jb}},onCreate(){this.options.onUpdate!==Jb&&console.warn('[tiptap warn]: DEPRECATED: The "onUpdate" option is deprecated. Please use `editor.storage.collaborationCursor.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor')},addStorage(){return{users:[]}},addCommands(){return{updateUser:t=>()=>(this.options.user=t,this.options.provider.awareness.setLocalStateField("user",this.options.user),!0),user:t=>({editor:e})=>(console.warn('[tiptap warn]: DEPRECATED: The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor'),e.commands.updateUser(t))}},addProseMirrorPlugins(){return[c_((this.options.provider.awareness.setLocalStateField("user",this.options.user),this.storage.users=Kb(this.options.provider.awareness.states),this.options.provider.awareness.on("update",()=>{this.storage.users=Kb(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),y_=/^\s*>\s$/,b_=ze.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Gi({find:y_,type:this.type})]}}),v_=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,w_=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,x_=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,k_=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,C_=jt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ai({find:v_,type:this.type}),ai({find:x_,type:this.type})]},addPasteRules(){return[Rr({find:w_,type:this.type}),Rr({find:k_,type:this.type})]}}),S_=ze.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Ce(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Gb=jt.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=ao(t,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),Yb=/^\s*([-+*])\s$/,E_=ze.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",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(S_.name,this.editor.getAttributes(Gb.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Gi({find:Yb,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Gi({find:Yb,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Gb.name),editor:this.editor})),[t]}}),T_=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/,A_=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g,M_=jt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ai({find:T_,type:this.type})]},addPasteRules(){return[Rr({find:A_,type:this.type})]}}),O_=/^```([a-z]+)?[\s\n]$/,__=/^~~~([a-z]+)?[\s\n]$/,N_=ze.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:null,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options,s=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Ce(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
372
|
+
*/const ky=ge("Youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]),SA=({editor:t,isOpen:e,setIsOpen:n})=>{const r=[{name:"Text",icon:vy,command:()=>t.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>t.isActive("paragraph")&&!t.isActive("bulletList")&&!t.isActive("orderedList")},{name:"Heading 1",icon:ud,command:()=>t.chain().focus().toggleHeading({level:1}).run(),isActive:()=>t.isActive("heading",{level:1})},{name:"Heading 2",icon:dd,command:()=>t.chain().focus().toggleHeading({level:2}).run(),isActive:()=>t.isActive("heading",{level:2})},{name:"Heading 3",icon:fd,command:()=>t.chain().focus().toggleHeading({level:3}).run(),isActive:()=>t.isActive("heading",{level:3})},{name:"To-do List",icon:yy,command:()=>t.chain().focus().toggleTaskList().run(),isActive:()=>t.isActive("taskItem")},{name:"Bullet List",icon:xo,command:()=>t.chain().focus().toggleBulletList().run(),isActive:()=>t.isActive("bulletList")},{name:"Numbered List",icon:xo,command:()=>t.chain().focus().toggleOrderedList().run(),isActive:()=>t.isActive("orderedList")},{name:"Quote",icon:pd,command:()=>t.chain().focus().toggleNode("paragraph","paragraph").toggleBlockquote().run(),isActive:()=>t.isActive("blockquote")},{name:"Code",icon:Ul,command:()=>t.chain().focus().toggleCode().run(),isActive:()=>t.isActive("code")}],i=r.filter(s=>s.isActive()).pop()??{name:"Multiple"};return _.jsxs("div",{className:"relative h-full",children:[_.jsxs("button",{className:"flex h-full items-center gap-1 p-2 text-sm font-medium text-stone-600 hover:bg-stone-100 active:bg-stone-200",onClick:()=>n(!e),children:[_.jsx("span",{children:i==null?void 0:i.name}),_.jsx(Vl,{className:"h-4 w-4"})]}),e&&_.jsx("section",{className:"fixed top-full z-[99999] mt-1 flex w-48 flex-col overflow-hidden rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1",children:r.map((s,o)=>_.jsxs("button",{onClick:()=>{s.command(),n(!1)},className:Se("flex items-center justify-between rounded-sm px-2 py-1 text-sm text-stone-600 hover:bg-stone-100",{"text-blue-600":s.isActive()}),children:[_.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx("div",{className:"rounded-sm border border-stone-200 p-1",children:_.jsx(s.icon,{className:"h-3 w-3"})}),_.jsx("span",{children:s.name})]}),i.name===s.name&&_.jsx(zl,{className:"h-4 w-4"})]},o))})]})},EA=({editor:t,isOpen:e,setIsOpen:n})=>{const r=[{name:"Default",color:"#000000"},{name:"Purple",color:"#9333EA"},{name:"Red",color:"#E00000"},{name:"Blue",color:"#2563EB"},{name:"Green",color:"#008A00"},{name:"Orange",color:"#FFA500"},{name:"Pink",color:"#BA4081"},{name:"Gray",color:"#A8A29E"}],i=r.find(({color:s})=>t.isActive("textStyle",{color:s}));return _.jsxs("div",{className:"",children:[_.jsxs("button",{className:"flex h-[100%] items-center gap-1 p-2 text-sm font-medium text-stone-600 hover:bg-stone-100 active:bg-stone-200",onClick:()=>n(!e),children:[_.jsx("span",{style:{color:(i==null?void 0:i.color)||"#000000"},children:"A"}),_.jsx(Vl,{className:"h-4 w-4 "})]}),e&&_.jsx("section",{className:"fixed top-full z-[99999] mt-1 flex w-48 flex-col overflow-hidden rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1",children:r.map(({name:s,color:o},l)=>_.jsxs("button",{onClick:()=>{t.chain().focus().setColor(o).run(),n(!1)},className:Se("flex items-center justify-between rounded-sm px-2 py-1 text-sm text-stone-600 hover:bg-stone-100",{"text-blue-600":t.isActive("textStyle",{color:o})}),children:[_.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx("div",{className:"rounded-sm border border-stone-200 px-1 py-px font-medium",style:{color:o},children:"A"}),_.jsx("span",{children:s})]}),t.isActive("textStyle",{color:o})&&_.jsx(zl,{className:"h-4 w-4"})]},l))})]})};var he=(t=>(t[t.NONE=0]="NONE",t[t.HEADING=1]="HEADING",t[t.TEXT_COLOR=2]="TEXT_COLOR",t[t.HIGHLIGHT=3]="HIGHLIGHT",t[t.LINK=4]="LINK",t[t.FONT_FAMILY=5]="FONT_FAMILY",t[t.ALIGNMENT=6]="ALIGNMENT",t[t.LIST=7]="LIST",t))(he||{});function TA(t){const[e,n]=O.useState(t),r=O.useRef(null),i=s=>{r&&r.current&&!r.current.contains(s.target)&&n(0)};return O.useEffect(()=>(document.addEventListener("click",i,!0),()=>{document.removeEventListener("click",i,!0)}),[]),{ref:r,toolVisibilty:e,setToolVisibility:n}}const Wl=new We("upload-image"),AA=()=>new je({key:Wl,state:{init(){return He.empty},apply(t,e){e=e.map(t.mapping,t.doc);const n=t.getMeta(this);if(n&&n.add){const{id:r,pos:i,src:s}=n.add,o=document.createElement("div");o.setAttribute("class","img-placeholder");const l=document.createElement("img");l.setAttribute("class","rounded-lg border border-stone-200"),l.src=s,o.appendChild(l);const a=ut.widget(i+1,o,{id:r});e=e.add(t.doc,[a])}else n&&n.remove&&(e=e.remove(e.find(void 0,void 0,r=>r.id==n.remove.id)));return e}},props:{decorations(t){return this.getState(t)}}});function MA(t,e){const r=Wl.getState(t).find(null,null,i=>i.id==e);return r.length?r[0].from:null}function Cy(t,e,n){if(t.type.includes("image/")){if(t.size>1024*1024){console.log("failed");return}}else{console.log("file is not an image");return}const r={},i=e.state.tr;i.selection.empty||i.deleteSelection();const s=new FileReader;s.readAsDataURL(t),s.onload=()=>{i.setMeta(Wl,{add:{id:r,pos:n,src:s.result}}),e.dispatch(i)},OA(t).then(o=>{const{schema:l}=e.state,a=MA(e.state,r);if(a==null)return;const c=typeof o=="object"?s.result:o,u=l.nodes.resizableMedia.create({src:c,"media-type":"img"}),d=e.state.tr.replaceWith(a-2,a+u.nodeSize,u).setMeta(Wl,{remove:{id:r}});e.dispatch(d)})}const OA=t=>new Promise(e=>{const n=new FileReader;n.readAsDataURL(t),n.onload=()=>e(n.result)}),_A=async t=>{const e=new FileReader;if(e.readAsDataURL(t),t.size>1024*1024)throw e.abort(),console.log("should be less than 1 mb"),new Error("Image too large");return await new Promise(r=>{e.onload=()=>{r(e.result)}})},Sy=[{title:"Trebuchet MS",value:"Trebuchet MS, sans-serif",command:t=>{t.chain().focus().setFontFamily("Trebuchet MS, sans-serif").run()}},{title:"Verdana",value:"Verdana, Geneva, sans-serif",command:t=>{t.chain().focus().setFontFamily("Verdana, Geneva, sans-serif").run()}},{title:"Georgia",value:"Georgia, serif",command:t=>{t.chain().focus().setFontFamily("Georgia, serif").run()}},{title:"Arial",value:"Arial, Helvetica, sans-serif",command:t=>{t.chain().focus().setFontFamily("Arial, Helvetica, sans-serif").run()}},{title:"Comic Sans MS",value:"Comic Sans MS, Comic Sans",command:t=>{t.chain().focus().setFontFamily("Comic Sans MS, Comic Sans").run()}},{title:"Impact",value:"Impact, Charcoal, sans-serif",command:t=>{t.chain().focus().setFontFamily("Impact, Charcoal, sans-serif").run()}},{title:"Palatino",value:"Palatino Linotype, Book Antiqua, Palatino, serif",command:t=>{t.chain().focus().setFontFamily("Palatino Linotype, Book Antiqua, Palatino, serif").run()}},{title:"Lucida Grande",value:"Lucida Sans Unicode, Lucida Grande, sans-serif",command:t=>{t.chain().focus().setFontFamily("Lucida Sans Unicode, Lucida Grande, sans-serif").run()}},{title:"Serif",value:"serif",command:t=>{t.chain().focus().setFontFamily("serif").run()}},{title:"Monospace",value:"monospace",command:t=>{t.chain().focus().setFontFamily("monospace").run()}},{title:"Cursive",value:"cursive",command:t=>{t.chain().focus().setFontFamily("cursive").run()}}],Ey=({editor:t})=>{const{ref:e,toolVisibilty:n,setToolVisibility:r}=TA(he.NONE);return{toolbar:[{icon:_.jsx(lA,{size:20}),title:"Text Color",onClick:()=>r(he.TEXT_COLOR),isActive:n===he.TEXT_COLOR},{icon:_.jsx(hy,{size:20}),title:"Highlight",onClick:()=>r(he.HIGHLIGHT),isActive:n===he.HIGHLIGHT},null,{icon:_.jsx(dy,{size:20}),title:"Bold",onClick:()=>t==null?void 0:t.chain().focus().toggleBold().run(),isActive:t==null?void 0:t.isActive("bold")},{icon:_.jsx(py,{size:20}),title:"Italic",onClick:()=>t==null?void 0:t.chain().focus().toggleItalic().run(),isActive:t==null?void 0:t.isActive("italic")},{icon:_.jsx(xy,{size:20}),title:"Underlined",onClick:()=>t==null?void 0:t.chain().focus().toggleUnderline().run(),isActive:t==null?void 0:t.isActive("underline")},{icon:_.jsx(by,{size:20}),title:"Strikethrough",onClick:()=>t==null?void 0:t.chain().focus().toggleStrike().run(),isActive:t==null?void 0:t.isActive("strike")},null,{icon:_.jsx(hd,{size:20}),title:"List",onClick:()=>{t==null||t.chain().focus().toggleBulletList().run(),r(he.NONE)},isActive:n===he.LIST},{icon:_.jsx(xo,{size:20}),title:"Ordered List",onClick:()=>{t==null||t.chain().focus().toggleOrderedList().run(),r(he.NONE)},isActive:n===he.LIST},{icon:_.jsx(gy,{size:20}),title:"To-do List",onClick:()=>{t==null||t.chain().focus().toggleTaskList().run(),r(he.NONE)},isActive:n===he.LIST},{icon:_.jsx(cd,{size:20}),title:"Alignment",onClick:()=>r(he.ALIGNMENT),isActive:n===he.ALIGNMENT},{icon:_.jsx(pd,{size:20}),title:"Quote",onClick:()=>t==null?void 0:t.chain().focus().toggleBlockquote().run(),isActive:t==null?void 0:t.isActive("blockquote")},null,{icon:_.jsx(hA,{size:20}),title:"Upload Image",onClick:()=>{t==null||t.chain().focus().deleteRange(t.state.selection).run();const s=document.createElement("input");s.type="file",s.accept="image/*",s.onchange=async()=>{var o;if((o=s.files)!=null&&o.length){const l=s.files[0],a=t.view.state.selection.from;Cy(l,t.view,a)}},s.click()},isActive:!1},{icon:_.jsx(my,{size:20}),title:"Link",onClick:()=>r(he.LINK),isActive:t==null?void 0:t.isActive("link")},{icon:_.jsx(Ul,{size:20}),title:"Code",onClick:()=>t==null?void 0:t.chain().focus().toggleCodeBlock().run(),isActive:t==null?void 0:t.isActive("codeBlock")}],toolRef:e,toolVisibilty:n,setToolVisibility:r}},Ty=({editor:t,setVisibility:e,elementRef:n})=>{const r=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}];return _.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-[50px] flex flex-wrap left-[20%] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-elevation-3 transition-all",children:[_.jsx(uy,{className:"cursor-pointer",onClick:()=>{t.chain().focus().unsetHighlight().run(),e(he.NONE)}}),r.map(i=>_.jsx("div",{onClick:()=>{t.chain().focus().toggleHighlight({color:i.color}).run(),e(he.NONE)},className:Se("w-6 drop-shadow rounded-full flex items-center justify-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6",i.code),children:_.jsx(zl,{size:14,className:Se(t.isActive("highlight",{color:i.color})?"visible":"invisible")})},i.color))]})},NA=({elementRef:t,editor:e,setToolVisibility:n})=>_.jsx("div",{ref:t,className:Se("z-50 h-auto absolute top-[50px] left-0 max-h-[330px] w-48 overflow-y-auto scroll-smooth bg-white px-1 py-2 shadow-elevation-3 transition-all animate-in fade-in slide-in-from-top-1"),children:Sy.map(r=>_.jsx("button",{onClick:()=>{r.command(e),n(he.NONE)},style:{fontFamily:r.title},className:Se("flex w-full items-center space-x-2 rounded px-2 py-1 text-left text-sm color-text-default",e.isActive("textStyle",{fontFamily:r.value})?"color-bg-brand hover:color-bg-brand-hover":"hover:bg-[#f2f2f2]"),children:_.jsx("p",{className:"font-medium",children:r.title})},r.title))}),Ay=({elementRef:t,editor:e,setToolVisibility:n})=>_.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-[50px] right-[25%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-elevation-3 transition-all",children:[_.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("left").run(),n(he.NONE)},className:Se("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer",e.isActive({textAlign:"left"})?"color-bg-brand hover:color-bg-brand-hover":"hover:bg-[#f2f2f2]"),children:_.jsx(cd,{})}),_.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("center").run(),n(he.NONE)},className:Se("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer",e.isActive({textAlign:"center"})?"color-bg-brand hover:color-bg-brand-hover":"hover:bg-[#f2f2f2]"),children:_.jsx(sA,{})}),_.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("right").run(),n(he.NONE)},className:Se("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer",e.isActive({textAlign:"right"})?"color-bg-brand hover:color-bg-brand-hover":"hover:bg-[#f2f2f2]"),children:_.jsx(oA,{})})]}),DA=({elementRef:t,editor:e,setToolVisibility:n})=>_.jsxs("div",{ref:t,className:Se("z-50 h-auto absolute gap-2 top-[50px] right-[30%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-elevation-3 transition-all"),children:[_.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"unordered list",children:_.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleBulletList().run(),n(he.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("bulletList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:_.jsx(hd,{size:20})})}),_.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"ordered list",children:_.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleOrderedList().run(),n(he.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("orderedList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:_.jsx(xo,{size:20})})}),_.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"to-do list",children:_.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleTaskList().run(),n(he.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("taskList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:_.jsx(gy,{size:20})})})]}),My=({elementRef:t,editor:e,setToolVisibility:n,bubbleMenu:r,setIsLinkPopupOpen:i})=>{const[s,o]=O.useState(e.getAttributes("link").href),l=()=>{if(s===null)return;if(s===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}let a=s;!s.startsWith("http://")&&!s.startsWith("https://")&&(a="https://"+s);try{a.match(/^((http|https):\/\/)?([w|W]{3}\.)+[a-zA-Z0-9\-\.]{3,}\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?$/)&&e.chain().focus().extendMarkRange("link").setLink({href:a}).run()}catch{console.error("Invalid URL");return}e.chain().focus().extendMarkRange("link").setLink({href:a}).run(),n(he.NONE),r&&i&&i(!1)};return _.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-[50px] items-center flex right-[10%] max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white p-2 shadow-elevation-3 transition-all",children:[_.jsx("input",{onChange:a=>o(a.target.value),className:"shadow-none border-[1px]",placeholder:"Add link here",value:s}),_.jsx("div",{className:"h-full flex items-center",children:_.jsx("button",{onClick:()=>l(),className:"min-w-fit",children:"Apply"})})]})},RA=({editor:t,setVisibility:e,elementRef:n})=>{const r=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}];return _.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-[50px] flex flex-wrap left-[100px] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-elevation-3 transition-all",children:[_.jsx(uy,{className:"cursor-pointer",onClick:()=>{t.chain().focus().unsetColor().run(),e(he.NONE)}}),r.map(i=>_.jsx("div",{onClick:()=>{t.chain().focus().setColor(i.color).run(),e(he.NONE)},className:Se("w-6 drop-shadow rounded-full flex justify-center items-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6",i.code),children:_.jsx(zl,{size:14,className:Se(t.isActive("textStyle",{color:i.color})?"visible":"invisible")})},i.color))]})},LA=({editor:t,setVisibility:e,elementRef:n})=>{const r=[{title:"Text",description:"Normal",icon:_.jsx(CA,{size:20}),command:i=>i.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>t.isActive("paragraph")&&!t.isActive("bulletList")&&!t.isActive("orderedList")},{title:"Heading 1",description:"Big",icon:_.jsx(ud,{size:20}),command:i=>{i.chain().focus().toggleHeading({level:1}).run()},isActive:()=>t.isActive("heading",{level:1})},{title:"Heading 2",description:"Medium",icon:_.jsx(dd,{size:20}),command:i=>{i.chain().focus().toggleHeading({level:2}).run()},isActive:()=>t.isActive("heading",{level:2})},{title:"Heading 3",description:"Small",icon:_.jsx(fd,{size:20}),command:i=>{i.chain().focus().toggleHeading({level:3}).run()},isActive:()=>t.isActive("heading",{level:3})}];return _.jsx("div",{ref:n,className:Se("absolute top-[50px] z-50 mt-1 flex w-48 flex-col overflow-hidden rounded bg-white p-1 shadow-elevation-3 animate-in fade-in slide-in-from-top-1","left-0"),children:r.map(i=>_.jsxs("button",{onClick:()=>{i.command(t),e(he.NONE)},className:Se("flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm color-text-default",{"color-bg-brand hover:color-bg-brand-hover":i.isActive(),"hover:bg-[#f2f2f2]":!i.isActive()}),children:[_.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded bg-white",children:i.icon}),_.jsxs("div",{children:[_.jsx("p",{className:"font-medium",children:i.title}),_.jsxs("p",{className:"text-xs text-stone-500",children:[" ",i.description," "]})]})]},i.title))})},IA=t=>{const e=[{name:"Bold",isActive:()=>t.editor.isActive("bold"),command:()=>t.editor.chain().focus().toggleBold().run(),icon:_.jsx(dy,{size:20})},{name:"Italic",isActive:()=>t.editor.isActive("italic"),command:()=>t.editor.chain().focus().toggleItalic().run(),icon:_.jsx(py,{size:20})},{name:"Underline",isActive:()=>t.editor.isActive("underline"),command:()=>t.editor.chain().focus().toggleUnderline().run(),icon:_.jsx(xy,{size:20})},{name:"Strikethrough",isActive:()=>t.editor.isActive("strike"),command:()=>t.editor.chain().focus().toggleStrike().run(),icon:_.jsx(by,{size:20})},{name:"Alignment",isActive:()=>d===he.ALIGNMENT,command:()=>u(he.ALIGNMENT),icon:_.jsx(cd,{size:20})},{name:"Code",isActive:()=>t.editor.isActive("codeBlock"),command:()=>t.editor.chain().focus().toggleCodeBlock().run(),icon:_.jsx(Ul,{size:20})},{name:"Link",isActive:()=>t.editor.isActive("link"),command:()=>a(!l),icon:_.jsx(my,{size:20})}],n={...t,shouldShow:({state:f,editor:h})=>{const{selection:p}=f,{empty:g}=p;return!(h.isActive("image")||g||dg(p))},tippyOptions:{moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",onHidden:()=>{i(!1),o(!1),a(!1)}}},[r,i]=O.useState(!1),[s,o]=O.useState(!1),[l,a]=O.useState(!1),{toolRef:c,setToolVisibility:u,toolVisibilty:d}=Ey({editor:t.editor});return _.jsxs(ry,{...n,className:"flex gap-1 overflow-hidden rounded-[12px] h-[52px] min-w-[472px] w-full py-2 px-4 bg-white items-center shadow-elevation-3",children:[_.jsx(SA,{editor:t.editor,isOpen:r,setIsOpen:()=>{i(!r),o(!1)}}),_.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"}),e.map((f,h)=>_.jsxs("div",{className:"flex items-center gap-1",children:[_.jsx("button",{onClick:f.command,className:Se("min-w-fit w-8 h-8 px-2",{"color-bg-brand":f.isActive()}),children:f.icon}),(h===4||h===6)&&_.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"})]},h)),_.jsx(EA,{editor:t.editor,isOpen:s,setIsOpen:()=>{o(!s),i(!1)}}),_.jsx("button",{onClick:()=>u(he.HIGHLIGHT),className:Se("min-w-fit w-8 h-8 px-2",{"color-bg-brand":d===he.HIGHLIGHT}),children:_.jsx(hy,{size:20})}),d===he.ALIGNMENT&&_.jsx(Ay,{setToolVisibility:u,editor:t.editor,elementRef:c}),l&&_.jsx(My,{setToolVisibility:u,editor:t.editor,elementRef:c,bubbleMenu:!0,setIsLinkPopupOpen:a}),d===he.HIGHLIGHT&&_.jsx(Ty,{setVisibility:u,editor:t.editor,elementRef:c})]})};function PA(){const t=["a","b","c","d","e","f","0","1","2","3","4","5","6","7","8","9"];let e=[];for(let n=0;n<36;n++)n===8||n===13||n===18||n===23?e[n]="-":e[n]=t[Math.ceil(Math.random()*t.length-1)];return e.join("")}var FA=PA;const $A=Pc(FA),Oy=ze.create({name:"column",content:"dBlock+",isolating:!0,addAttributes(){return{position:{default:"",parseHTML:t=>t.getAttribute("data-position"),renderHTML:t=>({"data-position":t.position})}}},renderHTML({HTMLAttributes:t}){return["div",Ce(t,{"data-type":"column"}),0]},parseHTML(){return[{tag:'div[data-type="column"]'}]}}),BA=(t,e)=>Array.from({length:t},(n,r)=>e(r)),ql=({type:t,content:e})=>e?{type:t,content:e}:{type:t},jA=({content:t})=>ql({type:"paragraph",content:t}),_y=({content:t})=>ql({type:"dBlock",content:t}),Ny=({content:t})=>ql({type:"column",content:t}),Dy=({content:t})=>ql({type:"columns",content:t}),Ry=t=>{const e=[_y({content:[jA({})]})];return BA(t,()=>Ny({content:e}))},Ly=(t,e)=>{for(let n=t.depth;n>0;n--){const r=t.node(n),i=n>0?t.before(n):0,s=t.start(n);if(e({node:r,pos:i,start:s}))return{start:s,depth:n,node:r,pos:i}}throw Error("no ancestor found")};class Kl extends ue{constructor(n){const{$from:r,$to:i}=n;super(r,i);vr(this,"_$from");vr(this,"_$to");this._$from=r,this._$to=i}get $from(){return this._$from}get $to(){return this._$to}map(){return this}content(){return this.$from.doc.slice(this.from,this.to,!0)}eq(n){return n instanceof Kl&&n.anchor==this.anchor}toJSON(){return{type:"column",from:this.from,to:this.to}}expandSelection(n){var a;const r=({pos:c,node:u})=>u.type.name===Oy.name?!0:n.resolve(c).depth<=0,{pos:i}=Ly(this.$from,r);this._$from=n.resolve(i);const{pos:s,node:o}=Ly(this.$to,r);this._$to=n.resolve(s+o.nodeSize),((a=this.getFirstNode())==null?void 0:a.type.name)===Jl.name&&(this._$from=n.resolve(this.$from.pos+2),this._$to=n.resolve(this.$to.pos+2));const l=this;l.$anchor=this._$from,l.$head=this._$to,l.ranges=[new Qc(this._$from,this._$to)]}static create(n,r,i){const s=n.resolve(r),o=n.resolve(i),l=new ce(s,o);return new Kl(l)}getFirstNode(){return this.content().content.firstChild}}var pi=(t=>(t.AlignLeft="align-left",t.AlignRight="align-right",t.AlignCenter="align-center",t))(pi||{});const Jl=ze.create({name:"columns",group:"columns",content:"column{2,}",defining:!0,draggable:!0,isolating:!0,addAttributes(){return{layout:{default:"align-center"}}},addCommands(){return{unsetColumns:()=>({tr:t,dispatch:e})=>{try{if(!e)return;const n=t.selection.$from,i=$u(n,({node:a})=>!this.options.nestedColumns&&a.type==this.type?!0:a.type==this.type);if(i===void 0)return;let s=[];i.node.descendants((a,c,u)=>{(u==null?void 0:u.type.name)===Jl.name&&s.push(a)}),s=s.reverse().filter(a=>a.content.size>0);const o=t.doc.resolve(i.pos),l=new se(o);return t=t.setSelection(l),s.forEach(a=>t=t.insert(i.pos,a)),t=t.deleteSelection(),e(t)}catch(n){console.error(n)}},setColumns:(t,e=!1)=>({tr:n,dispatch:r})=>{try{const{doc:i,selection:s}=n;if(!r){console.log("no dispatch");return}const o=new Kl(s);o.expandSelection(i);const{openStart:l,openEnd:a}=o.content();if(l!==a){console.warn("failed depth check");return}let c;if(e){const h=o.content().toJSON(),p=Ny(h),g=Ry(t-1);c=Dy({content:[p,...g]})}else{const h=Ry(t);c=Dy({content:h})}const u=i.type.schema.nodeFromJSON(_y({content:[c]}));if(u===null)return;const d=o.$anchor.parent.type;if(!(h=>!(!h.contentMatch.matchType(this.type)||!this.options.nestedColumns&&h.name===Jl.name))(d)){console.warn("content not allowed");return}return n=n.setSelection(o),n=n.replaceSelectionWith(u,!1),r(n)}catch(i){console.error(i)}},setLayout:t=>({commands:e})=>e.updateAttributes("columns",{layout:t})}},renderHTML({HTMLAttributes:t}){return["div",{"data-type":"columns",class:`layout-${t.layout}`},0]},parseHTML(){return[{tag:'div[data-type="columns"]'}]}}),HA=(t,e)=>{const{view:n,state:{selection:{from:r}}}=t,i=document.querySelectorAll(".has-focus"),s=i.length,l=i[s-1];if(l&&l.getAttribute("data-type")&&l.getAttribute("data-type")===e||l&&l.classList&&l.classList.contains(e))return l;const a=n.domAtPos(r).node;let c=a;for(c.tagName||(c=a.parentElement);c&&!(c.getAttribute("data-type")&&c.getAttribute("data-type")===e)&&!c.classList.contains(e);)c=c.parentElement;return c},md=O.forwardRef(({children:t,className:e,withShadow:n=!0,withBorder:r=!0,...i},s)=>{const o=Se(e,"bg-white rounded-md",n?"shadow-md":"",r?"border border-neutral-200":"");return _.jsx("div",{className:o,...i,ref:s,children:t})});md.displayName="Surface";const Iy=O.forwardRef(({active:t,buttonSize:e="medium",children:n,disabled:r,variant:i="primary",className:s,activeClassname:o,...l},a)=>{const c=Se("flex group items-center justify-center border border-transparent gap-2 text-sm font-semibold rounded disabled:opacity-50 whitespace-nowrap",i==="primary"&&Se("text-white bg-black border-black dark:text-black dark:bg-white dark:border-white",!r&&!t&&"hover:bg-neutral-800 active:bg-neutral-900 dark:hover:bg-neutral-200 dark:active:bg-neutral-300",t&&Se("bg-neutral-900 dark:bg-neutral-300",o)),i==="secondary"&&Se("text-neutral-900 dark:text-white",!r&&!t&&"hover:bg-neutral-100 active:bg-neutral-200 dark:hover:bg-neutral-900 dark:active:bg-neutral-800",t&&"bg-neutral-200 dark:bg-neutral-800"),i==="tertiary"&&Se("bg-neutral-50 text-neutral-900 dark:bg-neutral-900 dark:text-white dark:border-neutral-900",!r&&!t&&"hover:bg-neutral-100 active:bg-neutral-200 dark:hover:bg-neutral-800 dark:active:bg-neutral-700",t&&Se("bg-neutral-200 dark:bg-neutral-800",o)),i==="ghost"&&Se("bg-transparent border-transparent text-neutral-500",!r&&!t&&"hover:bg-black/5 hover:text-neutral-700 active:bg-black/10 active:text-neutral-800 ",t&&Se("bg-black/10 text-neutral-800 ",o)),e==="medium"&&"py-2 px-3",e==="small"&&"py-1 px-2",e==="icon"&&"w-8 h-8",e==="iconSmall"&&"w-6 h-6",s);return _.jsx("button",{ref:a,disabled:r,className:c,...l,children:n})});Iy.displayName="Button";const Py=({content:t,children:e})=>{const[n,r]=O.useState(!1);return _.jsxs("div",{className:"relative inline-block",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[e,n&&_.jsx("div",{className:"absolute z-10 p-2 mt-2 text-sm text-white bg-gray-800 rounded shadow-lg",children:t})]})},Fy=O.forwardRef(({shouldShowContent:t=!0,children:e,isVertical:n=!1,className:r,...i},s)=>{const o=Se("text-black inline-flex h-full leading-none gap-0.5",n?"flex-col p-2":"flex-row p-1 items-center",r);return t?t&&_.jsx(md,{className:o,...i,ref:s,children:e}):null});Fy.displayName="Toolbar";const $y=O.forwardRef(({horizontal:t,className:e,...n},r)=>{const i=Se("bg-neutral-200",t?"w-full min-w-[1.5rem] h-[1px] my-1 first:mt-0 last:mt-0":"h-full min-h-[1.5rem] w-[1px] mx-1 first:ml-0 last:mr-0",e);return _.jsx("div",{className:i,ref:r,...n})});$y.displayName="Toolbar.Divider";const By=O.forwardRef(({children:t,buttonSize:e="icon",variant:n="ghost",className:r,tooltip:i,activeClassname:s,...o},l)=>{const a=Se("gap-1 min-w-[2rem] px-2 w-auto",r),c=_.jsx(Iy,{activeClassname:s,className:a,variant:n,buttonSize:e,ref:l,...o,children:t});return i?_.jsx(Py,{content:i,children:c}):c});By.displayName="ToolbarButton";const ko={Wrapper:Fy,Divider:$y,Button:By},zA=({editor:t,appendTo:e})=>{const n=O.useCallback(()=>{const l=HA(t,"columns");return(l==null?void 0:l.getBoundingClientRect())||new DOMRect(-1e3,-1e3,0,0)},[t]),r=O.useCallback(()=>t.isActive("columns"),[t]),i=O.useCallback(()=>{t.chain().focus().setLayout(pi.AlignLeft).run()},[t]),s=O.useCallback(()=>{t.chain().focus().setLayout(pi.AlignRight).run()},[t]),o=O.useCallback(()=>{t.chain().focus().setLayout(pi.AlignCenter).run()},[t]);return _.jsx(ry,{editor:t,pluginKey:`columnsMenu-${$A()}`,shouldShow:r,updateDelay:0,tippyOptions:{offset:[0,8],popperOptions:{modifiers:[{name:"flip",enabled:!1}]},getReferenceClientRect:n,moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",appendTo:()=>e==null?void 0:e.current,plugins:[VT],sticky:"popper"},children:_.jsxs(ko.Wrapper,{children:[_.jsx(ko.Button,{tooltip:"Align left",active:t.isActive("columns",{layout:pi.AlignLeft}),onClick:i,children:_.jsx(gA,{size:20})}),_.jsx(ko.Button,{tooltip:"Align center",active:t.isActive("columns",{layout:pi.AlignCenter}),onClick:o,children:_.jsx(fy,{size:20})}),_.jsx(ko.Button,{tooltip:"Align right",active:t.isActive("columns",{layout:pi.AlignRight}),onClick:s,children:_.jsx(yA,{size:20})})]})})},jy=O.createContext(null),Gl=()=>O.useContext(jy),VA=({children:t,isPreviewMode:e})=>_.jsx(jy.Provider,{value:e,children:t}),Hy=({height:t,width:e})=>_.jsx("span",{className:"flex items-center justify-center ",children:_.jsx("span",{className:`${e?`w-${e}`:"w-8"} ${t?`h-${t}`:"h-8"} border-4 border-t-4 border-t-[#ccc] border-gray-500 rounded-full animate-spin`})}),UA=({editor:t})=>{var s;const{toolRef:e,toolVisibilty:n,setToolVisibility:r,toolbar:i}=Ey({editor:t});return _.jsxs("div",{className:"w-fit bg-transparent px-4 items-center h-16 flex gap-1 justify-center",children:[_.jsxs("button",{className:"bg-transparent flex items-center gap-2 min-w-[55px]",onClick:()=>r(he.FONT_FAMILY),children:[_.jsx("span",{className:"text-sm",children:((s=Sy.find(o=>t==null?void 0:t.isActive("textStyle",{fontFamily:o.value})))==null?void 0:s.title)||"Font"}),_.jsx(Vl,{size:16})]}),_.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"}),_.jsxs("button",{className:"bg-transparent gap-2 flex items-center min-w-[55px]",onClick:()=>r(he.HEADING),children:[_.jsx("span",{className:"text-sm",children:t!=null&&t.isActive("heading",{level:1})?"Heading 1":t!=null&&t.isActive("heading",{level:2})?"Heading 2":t!=null&&t.isActive("heading",{level:3})?"Heading 3":"Text"}),_.jsx(Vl,{size:16})]}),_.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"}),i.map(o=>o?_.jsx("div",{className:"tooltip tooltip-bottom","data-tip":o.title,children:_.jsx("span",{onClick:()=>o.onClick(),className:Se("rounded-lg w-8 h-8 p-1 flex cursor-pointer justify-center items-center",o.isActive?"bg-yellow-300":"hover:bg-[#f2f2f2]"),children:typeof o.icon=="string"?_.jsx("img",{src:o.icon,className:"w-4"}):o.icon})},o.title):_.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"})),n===he.FONT_FAMILY&&_.jsx(NA,{setToolVisibility:r,editor:t,elementRef:e}),n===he.HEADING&&_.jsx(LA,{setVisibility:r,editor:t,elementRef:e}),n===he.TEXT_COLOR&&_.jsx(RA,{setVisibility:r,editor:t,elementRef:e}),n===he.HIGHLIGHT&&_.jsx(Ty,{setVisibility:r,editor:t,elementRef:e}),n===he.ALIGNMENT&&_.jsx(Ay,{setToolVisibility:r,editor:t,elementRef:e}),n===he.LIST&&_.jsx(DA,{setToolVisibility:r,editor:t,elementRef:e}),n===he.LINK&&_.jsx(My,{setToolVisibility:r,editor:t,elementRef:e})]})},Lt=()=>new Map,gd=t=>{const e=Lt();return t.forEach((n,r)=>{e.set(r,n)}),e},Vt=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},WA=(t,e)=>{const n=[];for(const[r,i]of t)n.push(e(i,r));return n},qA=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},or=()=>new Set,yd=t=>t[t.length-1],KA=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},lr=Array.from,JA=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},bd=Array.isArray;class vd{constructor(){this._observers=Lt()}on(e,n){return Vt(this._observers,e,or).add(n),n}once(e,n){const r=(...i)=>{this.off(e,r),n(...i)};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 lr((this._observers.get(e)||Lt()).values()).forEach(r=>r(...n))}destroy(){this._observers=Lt()}}class wd{constructor(){this._observers=Lt()}on(e,n){Vt(this._observers,e,or).add(n)}once(e,n){const r=(...i)=>{this.off(e,r),n(...i)};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 lr((this._observers.get(e)||Lt()).values()).forEach(r=>r(...n))}destroy(){this._observers=Lt()}}const wn=Math.floor,Yl=Math.abs,GA=Math.log10,Ir=(t,e)=>t<e?t:e,ar=(t,e)=>t>e?t:e,zy=t=>t!==0?t<0:1/t<0,Bn=Date.now,YA=1200,XA=2500,Xl=3e4,xd=t=>{if(t.shouldConnect&&t.ws===null){const e=new WebSocket(t.url),n=t.binaryType;let r=null;n&&(e.binaryType=n),t.ws=e,t.connecting=!0,t.connected=!1,e.onmessage=o=>{t.lastMessageReceived=Bn();const l=o.data,a=typeof l=="string"?JSON.parse(l):l;a&&a.type==="pong"&&(clearTimeout(r),r=setTimeout(s,Xl/2)),t.emit("message",[a,t])};const i=o=>{t.ws!==null&&(t.ws=null,t.connecting=!1,t.connected?(t.connected=!1,t.emit("disconnect",[{type:"disconnect",error:o},t])):t.unsuccessfulReconnects++,setTimeout(xd,Ir(GA(t.unsuccessfulReconnects+1)*YA,XA),t)),clearTimeout(r)},s=()=>{t.ws===e&&t.send({type:"ping"})};e.onclose=()=>i(null),e.onerror=o=>i(o),e.onopen=()=>{t.lastMessageReceived=Bn(),t.connecting=!1,t.connected=!0,t.unsuccessfulReconnects=0,t.emit("connect",[{type:"connect"},t]),r=setTimeout(s,Xl/2)}}};class ZA extends wd{constructor(e,{binaryType:n}={}){super(),this.url=e,this.ws=null,this.binaryType=n||null,this.connected=!1,this.connecting=!1,this.unsuccessfulReconnects=0,this.lastMessageReceived=0,this.shouldConnect=!0,this._checkInterval=setInterval(()=>{this.connected&&Xl<Bn()-this.lastMessageReceived&&this.ws.close()},Xl/2),xd(this)}send(e){this.ws&&this.ws.send(JSON.stringify(e))}destroy(){clearInterval(this._checkInterval),this.disconnect(),super.destroy()}disconnect(){this.shouldConnect=!1,this.ws!==null&&this.ws.close()}connect(){this.shouldConnect=!0,!this.connected&&this.ws===null&&xd(this)}}const xn=t=>new Error(t),kn=()=>{throw xn("Method unimplemented")},cn=()=>{throw xn("Unexpected case")},Vy=1,Uy=2,kd=4,Cd=8,Co=32,cr=64,Yt=128,Zl=31,Sd=63,mi=127,QA=2147483647,e2=crypto.getRandomValues.bind(crypto),Wy=Math.random,qy=()=>e2(new Uint32Array(1))[0],t2=t=>t[wn(Wy()*t.length)],n2="10000000-1000-4000-8000"+-1e11,Ky=()=>n2.replace(/[018]/g,t=>(t^qy()&15>>t/4).toString(16)),Jy=Number.MAX_SAFE_INTEGER,r2=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&wn(t)===t),i2=String.fromCharCode,s2=t=>t.toLowerCase(),o2=/^\s*/g,l2=t=>t.replace(o2,""),a2=/([A-Z])/g,Gy=(t,e)=>l2(t.replace(a2,n=>`${e}${s2(n)}`)),c2=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let i=0;i<n;i++)r[i]=e.codePointAt(i);return r},So=typeof TextEncoder<"u"?new TextEncoder:null,Ed=So?t=>So.encode(t):c2;let Eo=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Eo&&Eo.decode(new Uint8Array).length===1&&(Eo=null);class To{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const gt=()=>new To,u2=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},qe=t=>{const e=new Uint8Array(u2(t));let n=0;for(let r=0;r<t.bufs.length;r++){const i=t.bufs[r];e.set(i,n),n+=i.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},d2=(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(ar(n,e)*2),t.cpos=0)},yt=(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},Ao=yt,ae=(t,e)=>{for(;e>mi;)yt(t,Yt|mi&e),e=wn(e/128);yt(t,mi&e)},Td=(t,e)=>{const n=zy(e);for(n&&(e=-e),yt(t,(e>Sd?Yt:0)|(n?cr:0)|Sd&e),e=wn(e/64);e>0;)yt(t,(e>mi?Yt:0)|mi&e),e=wn(e/128)},Ad=new Uint8Array(3e4),f2=Ad.length/3,h2=(t,e)=>{if(e.length<f2){const n=So.encodeInto(e,Ad).written||0;ae(t,n);for(let r=0;r<n;r++)yt(t,Ad[r])}else Ze(t,Ed(e))},p2=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;ae(t,r);for(let i=0;i<r;i++)yt(t,n.codePointAt(i))},jn=So&&So.encodeInto?h2:p2,Ql=(t,e)=>{const n=t.cbuf.length,r=t.cpos,i=Ir(n-r,e.length),s=e.length-i;t.cbuf.set(e.subarray(0,i),r),t.cpos+=i,s>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(ar(n*2,s)),t.cbuf.set(e.subarray(i)),t.cpos=s)},Ze=(t,e)=>{ae(t,e.byteLength),Ql(t,e)},Md=(t,e)=>{d2(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},m2=(t,e)=>Md(t,4).setFloat32(0,e,!1),g2=(t,e)=>Md(t,8).setFloat64(0,e,!1),y2=(t,e)=>Md(t,8).setBigInt64(0,e,!1),Yy=new DataView(new ArrayBuffer(4)),b2=t=>(Yy.setFloat32(0,t),Yy.getFloat32(0)===t),ns=(t,e)=>{switch(typeof e){case"string":yt(t,119),jn(t,e);break;case"number":r2(e)&&Yl(e)<=QA?(yt(t,125),Td(t,e)):b2(e)?(yt(t,124),m2(t,e)):(yt(t,123),g2(t,e));break;case"bigint":yt(t,122),y2(t,e);break;case"object":if(e===null)yt(t,126);else if(bd(e)){yt(t,117),ae(t,e.length);for(let n=0;n<e.length;n++)ns(t,e[n])}else if(e instanceof Uint8Array)yt(t,116),Ze(t,e);else{yt(t,118);const n=Object.keys(e);ae(t,n.length);for(let r=0;r<n.length;r++){const i=n[r];jn(t,i),ns(t,e[i])}}break;case"boolean":yt(t,e?120:121);break;default:yt(t,127)}};class Xy extends To{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&ae(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const Zy=t=>{t.count>0&&(Td(t.encoder,t.count===1?t.s:-t.s),t.count>1&&ae(t.encoder,t.count-2))};class ea{constructor(){this.encoder=new To,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Zy(this),this.count=1,this.s=e)}toUint8Array(){return Zy(this),qe(this.encoder)}}const Qy=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);Td(t.encoder,e),t.count>1&&ae(t.encoder,t.count-2)}};class Od{constructor(){this.encoder=new To,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Qy(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Qy(this),qe(this.encoder)}}class v2{constructor(){this.sarr=[],this.s="",this.lensE=new ea}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 To;return this.sarr.push(this.s),this.s="",jn(e,this.sarr.join("")),Ql(e,this.lensE.toUint8Array()),qe(e)}}const e0=xn("Unexpected end of array"),t0=xn("Integer out of Range");class ta{constructor(e){this.arr=e,this.pos=0}}const Hn=t=>new ta(t),w2=t=>t.pos!==t.arr.length,x2=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},bt=t=>x2(t,pe(t)),gi=t=>t.arr[t.pos++],pe=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const i=t.arr[t.pos++];if(e=e+(i&mi)*n,n*=128,i<Yt)return e;if(e>Jy)throw t0}throw e0},_d=t=>{let e=t.arr[t.pos++],n=e&Sd,r=64;const i=(e&cr)>0?-1:1;if(!(e&Yt))return i*n;const s=t.arr.length;for(;t.pos<s;){if(e=t.arr[t.pos++],n=n+(e&mi)*r,r*=128,e<Yt)return i*n;if(n>Jy)throw t0}throw e0},ur=Eo?t=>Eo.decode(bt(t)):t=>{let e=pe(t);if(e===0)return"";{let n=String.fromCodePoint(gi(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(gi(t));else for(;e>0;){const r=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(n))}},Nd=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},k2=[t=>{},t=>null,_d,t=>Nd(t,4).getFloat32(0,!1),t=>Nd(t,8).getFloat64(0,!1),t=>Nd(t,8).getBigInt64(0,!1),t=>!1,t=>!0,ur,t=>{const e=pe(t),n={};for(let r=0;r<e;r++){const i=ur(t);n[i]=rs(t)}return n},t=>{const e=pe(t),n=[];for(let r=0;r<e;r++)n.push(rs(t));return n},bt],rs=t=>k2[127-gi(t)](t);class n0 extends ta{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),w2(this)?this.count=pe(this)+1:this.count=-1),this.count--,this.s}}class na extends ta{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=_d(this);const e=zy(this.s);this.count=1,e&&(this.s=-this.s,this.count=pe(this)+2)}return this.count--,this.s}}class Dd extends ta{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=_d(this),n=e&1;this.diff=wn(e/2),this.count=1,n&&(this.count=pe(this)+2)}return this.s+=this.diff,this.count--,this.s}}class C2{constructor(e){this.decoder=new na(e),this.str=ur(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 r0=t=>t===void 0?null:t;class S2{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let i0=new S2,Rd=!0;try{typeof localStorage<"u"&&localStorage&&(i0=localStorage,Rd=!1)}catch{}const s0=i0,E2=t=>Rd||addEventListener("storage",t),T2=t=>Rd||removeEventListener("storage",t),A2=Object.assign,Ld=Object.keys,M2=(t,e)=>{for(const n in t)e(t[n],n)},o0=t=>Ld(t).length,l0=t=>Ld(t).length,O2=t=>{for(const e in t)return!1;return!0},_2=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},a0=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),N2=(t,e)=>t===e||l0(t)===l0(e)&&_2(t,(n,r)=>(n!==void 0||a0(e,r))&&e[r]===n),Id=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&Id(t,e,n+1)}},D2=()=>{},R2=t=>t,L2=(t,e)=>t===e,Mo=(t,e)=>{if(t==null||e==null)return L2(t,e);if(t.constructor!==e.constructor)return!1;if(t===e)return!0;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)||!Mo(t.get(n),e.get(n)))return!1;break}case Object:if(o0(t)!==o0(e))return!1;for(const n in t)if(!a0(t,n)||!Mo(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(!Mo(t[n],e[n]))return!1;break;default:return!1}return!0},I2=(t,e)=>e.includes(t),is=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Pd=typeof window<"u"&&typeof document<"u"&&!is;let zn;const P2=()=>{if(zn===void 0)if(is){zn=Lt();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&zn.set(e,""),e=r):e!==null&&(zn.set(e,r),e=null)}e!==null&&zn.set(e,"")}else typeof location=="object"?(zn=Lt(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");zn.set(`--${Gy(e,"-")}`,n),zn.set(`-${Gy(e,"-")}`,n)}})):zn=Lt();return zn},Fd=t=>P2().has(t),ra=t=>r0(is?process.env[t.toUpperCase().replaceAll("-","_")]:s0.getItem(t));(t=>Fd("--"+t)||ra(t)!==null)("production");const c0=is&&I2(process.env.FORCE_COLOR,["true","1","2"]),F2=!Fd("--no-colors")&&(!is||process.stdout.isTTY||c0)&&(!is||Fd("--color")||c0||ra("COLORTERM")!==null||(ra("TERM")||"").includes("color"));class $2{constructor(e,n){this.left=e,this.right=n}}const dr=(t,e)=>new $2(t,e),B2=typeof document<"u"?document:{};typeof DOMParser<"u"&&new DOMParser;const j2=t=>WA(t,(e,n)=>`${n}:${e};`).join(""),H2=JSON.stringify,z2=(t=>class{constructor(n){this._=n}destroy(){t(this._)}})(clearTimeout),$d=(t,e)=>new z2(setTimeout(e,t)),fr=Symbol,un=fr(),yi=fr(),u0=fr(),Bd=fr(),d0=fr(),f0=fr(),h0=fr(),ia=fr(),sa=fr(),V2=t=>{var r;t.length===1&&((r=t[0])==null?void 0:r.constructor)===Function&&(t=t[0]());const e=[];let n=0;for(;n<t.length;n++){const i=t[n];i===void 0||i.constructor===String||i.constructor===Number||i.constructor===Object&&e.push(JSON.stringify(i))}return e},p0=[d0,h0,ia,u0];let jd=0,m0=Bn();const U2=(t,e)=>{const n=p0[jd],r=ra("log"),i=r!==null&&(r==="*"||r==="true"||new RegExp(r,"gi").test(e));return jd=(jd+1)%p0.length,e+=": ",i?(...s)=>{var a;s.length===1&&((a=s[0])==null?void 0:a.constructor)===Function&&(s=s[0]());const o=Bn(),l=o-m0;m0=o,t(n,e,sa,...s.map(c=>{switch(c!=null&&c.constructor===Uint8Array&&(c=Array.from(c)),typeof c){case"string":case"symbol":return c;default:return H2(c)}}),n," +"+l+"ms")}:D2},W2={[un]:dr("font-weight","bold"),[yi]:dr("font-weight","normal"),[u0]:dr("color","blue"),[d0]:dr("color","green"),[Bd]:dr("color","grey"),[f0]:dr("color","red"),[h0]:dr("color","purple"),[ia]:dr("color","orange"),[sa]:dr("color","black")},g0=F2?t=>{var o;t.length===1&&((o=t[0])==null?void 0:o.constructor)===Function&&(t=t[0]());const e=[],n=[],r=Lt();let i=[],s=0;for(;s<t.length;s++){const l=t[s],a=W2[l];if(a!==void 0)r.set(a.left,a.right);else{if(l===void 0)break;if(l.constructor===String||l.constructor===Number){const c=j2(r);s>0||c.length>0?(e.push("%c"+l),n.push(c)):e.push(l)}else break}}for(s>0&&(i=n,i.unshift(e.join("")));s<t.length;s++){const l=t[s];l instanceof Symbol||i.push(l)}return i}:V2,y0=(...t)=>{console.log(...g0(t)),b0.forEach(e=>e.print(t))},q2=(...t)=>{console.warn(...g0(t)),t.unshift(ia),b0.forEach(e=>e.print(t))},b0=or(),K2=t=>U2(y0,t),ss=t=>new Promise(t);Promise.all.bind(Promise);const J2=t=>Promise.reject(t),Hd=t=>Promise.resolve(t),v0=t=>new Uint8Array(t),G2=(t,e,n)=>new Uint8Array(t,e,n),Y2=t=>new Uint8Array(t),X2=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=i2(t[n]);return btoa(e)},Z2=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),Q2=t=>{const e=atob(t),n=v0(e.length);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n},eM=t=>{const e=Buffer.from(t,"base64");return G2(e.buffer,e.byteOffset,e.byteLength)},w0=Pd?X2:Z2,x0=Pd?Q2:eM,tM=t=>{const e=v0(t.byteLength);return e.set(t),e},k0=new Map;class nM{constructor(e){this.room=e,this.onmessage=null,this._onChange=n=>n.key===e&&this.onmessage!==null&&this.onmessage({data:x0(n.newValue||"")}),E2(this._onChange)}postMessage(e){s0.setItem(this.room,w0(Y2(e)))}close(){T2(this._onChange)}}const rM=typeof BroadcastChannel>"u"?nM:BroadcastChannel,zd=t=>Vt(k0,t,()=>{const e=or(),n=new rM(t);return n.onmessage=r=>e.forEach(i=>i(r.data,"broadcastchannel")),{bc:n,subs:e}}),iM=(t,e)=>(zd(t).subs.add(e),e),sM=(t,e)=>{const n=zd(t),r=n.subs.delete(e);return r&&n.subs.size===0&&(n.bc.close(),k0.delete(t)),r},oM=(t,e,n=null)=>{const r=zd(t);r.bc.postMessage(e),r.subs.forEach(i=>i(e,n))},C0=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},S0=t=>({[Symbol.iterator](){return this},next:t}),lM=(t,e)=>S0(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),Vd=(t,e)=>S0(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class Ud{constructor(e,n){this.clock=e,this.len=n}}class ls{constructor(){this.clients=new Map}}const Pr=(t,e,n)=>e.clients.forEach((r,i)=>{const s=t.doc.store.clients.get(i);for(let o=0;o<r.length;o++){const l=r[o];q0(t,s,l.clock,l.len,n)}}),aM=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const i=wn((n+r)/2),s=t[i],o=s.clock;if(o<=e){if(e<o+s.len)return i;n=i+1}else r=i-1}return null},as=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&aM(n,e.clock)!==null},Wd=t=>{t.clients.forEach(e=>{e.sort((i,s)=>i.clock-s.clock);let n,r;for(n=1,r=1;n<e.length;n++){const i=e[r-1],s=e[n];i.clock+i.len>=s.clock?i.len=ar(i.len,s.clock+s.len-i.clock):(r<n&&(e[r]=s),r++)}e.length=r})},qd=t=>{const e=new ls;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,i)=>{if(!e.clients.has(i)){const s=r.slice();for(let o=n+1;o<t.length;o++)KA(s,t[o].clients.get(i)||[]);e.clients.set(i,s)}});return Wd(e),e},Oo=(t,e,n,r)=>{Vt(t.clients,e,()=>[]).push(new Ud(n,r))},E0=()=>new ls,T0=t=>{const e=E0();return t.clients.forEach((n,r)=>{const i=[];for(let s=0;s<n.length;s++){const o=n[s];if(o.deleted){const l=o.id.clock;let a=o.length;if(s+1<n.length)for(let c=n[s+1];s+1<n.length&&c.deleted;c=n[++s+1])a+=c.length;i.push(new Ud(l,a))}}i.length>0&&e.clients.set(r,i)}),e},cs=(t,e)=>{ae(t.restEncoder,e.clients.size),lr(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),ae(t.restEncoder,n);const i=r.length;ae(t.restEncoder,i);for(let s=0;s<i;s++){const o=r[s];t.writeDsClock(o.clock),t.writeDsLen(o.len)}})},Kd=t=>{const e=new ls,n=pe(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const i=pe(t.restDecoder),s=pe(t.restDecoder);if(s>0){const o=Vt(e.clients,i,()=>[]);for(let l=0;l<s;l++)o.push(new Ud(t.readDsClock(),t.readDsLen()))}}return e},A0=(t,e,n)=>{const r=new ls,i=pe(t.restDecoder);for(let s=0;s<i;s++){t.resetDsCurVal();const o=pe(t.restDecoder),l=pe(t.restDecoder),a=n.clients.get(o)||[],c=rt(n,o);for(let u=0;u<l;u++){const d=t.readDsClock(),f=d+t.readDsLen();if(d<c){c<f&&Oo(r,o,c,f-c);let h=Vn(a,d),p=a[h];for(!p.deleted&&p.id.clock<d&&(a.splice(h+1,0,ba(e,p,d-p.id.clock)),h++);h<a.length&&(p=a[h++],p.id.clock<f);)p.deleted||(f<p.id.clock+p.length&&a.splice(h,0,ba(e,p,f-p.id.clock)),p.delete(e))}else Oo(r,o,d,f-d)}}if(r.clients.size>0){const s=new bi;return ae(s.restEncoder,0),cs(s,r),s.toUint8Array()}return null},M0=qy;class us extends vd{constructor({guid:e=Ky(),collectionid:n=null,gc:r=!0,gcFilter:i=()=>!0,meta:s=null,autoLoad:o=!1,shouldLoad:l=!0}={}){super(),this.gc=r,this.gcFilter=i,this.clientID=M0(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new V0,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=o,this.meta=s,this.isLoaded=!1,this.isSynced=!1,this.whenLoaded=ss(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const a=()=>ss(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&&Fe(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(lr(this.subdocs).map(e=>e.guid))}transact(e,n=null){return Fe(this,e,n)}get(e,n=Et){const r=Vt(this.share,e,()=>{const s=new n;return s._integrate(this,null),s}),i=r.constructor;if(n!==Et&&i!==n)if(i===Et){const s=new n;s._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=s}),s._start=r._start;for(let o=s._start;o!==null;o=o.right)o.parent=s;return s._length=r._length,this.share.set(e,s),s._integrate(this,null),s}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,ms)}getText(e=""){return this.get(e,wi)}getMap(e=""){return this.get(e,gs)}getXmlElement(e=""){return this.get(e,It)}getXmlFragment(e=""){return this.get(e,xi)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){lr(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new us({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,Fe(e.parent.doc,r=>{const i=n.doc;e.deleted||r.subdocsAdded.add(i),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class O0{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return pe(this.restDecoder)}readDsLen(){return pe(this.restDecoder)}}class _0 extends O0{readLeftID(){return me(pe(this.restDecoder),pe(this.restDecoder))}readRightID(){return me(pe(this.restDecoder),pe(this.restDecoder))}readClient(){return pe(this.restDecoder)}readInfo(){return gi(this.restDecoder)}readString(){return ur(this.restDecoder)}readParentInfo(){return pe(this.restDecoder)===1}readTypeRef(){return pe(this.restDecoder)}readLen(){return pe(this.restDecoder)}readAny(){return rs(this.restDecoder)}readBuf(){return tM(bt(this.restDecoder))}readJSON(){return JSON.parse(ur(this.restDecoder))}readKey(){return ur(this.restDecoder)}}class cM{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=pe(this.restDecoder),this.dsCurrVal}readDsLen(){const e=pe(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class ds extends cM{constructor(e){super(e),this.keys=[],pe(e),this.keyClockDecoder=new Dd(bt(e)),this.clientDecoder=new na(bt(e)),this.leftClockDecoder=new Dd(bt(e)),this.rightClockDecoder=new Dd(bt(e)),this.infoDecoder=new n0(bt(e),gi),this.stringDecoder=new C2(bt(e)),this.parentInfoDecoder=new n0(bt(e),gi),this.typeRefDecoder=new na(bt(e)),this.lenDecoder=new na(bt(e))}readLeftID(){return new fs(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new fs(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 rs(this.restDecoder)}readBuf(){return bt(this.restDecoder)}readJSON(){return rs(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 N0{constructor(){this.restEncoder=gt()}toUint8Array(){return qe(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){ae(this.restEncoder,e)}writeDsLen(e){ae(this.restEncoder,e)}}class _o extends N0{writeLeftID(e){ae(this.restEncoder,e.client),ae(this.restEncoder,e.clock)}writeRightID(e){ae(this.restEncoder,e.client),ae(this.restEncoder,e.clock)}writeClient(e){ae(this.restEncoder,e)}writeInfo(e){Ao(this.restEncoder,e)}writeString(e){jn(this.restEncoder,e)}writeParentInfo(e){ae(this.restEncoder,e?1:0)}writeTypeRef(e){ae(this.restEncoder,e)}writeLen(e){ae(this.restEncoder,e)}writeAny(e){ns(this.restEncoder,e)}writeBuf(e){Ze(this.restEncoder,e)}writeJSON(e){jn(this.restEncoder,JSON.stringify(e))}writeKey(e){jn(this.restEncoder,e)}}class D0{constructor(){this.restEncoder=gt(),this.dsCurrVal=0}toUint8Array(){return qe(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,ae(this.restEncoder,n)}writeDsLen(e){e===0&&cn(),ae(this.restEncoder,e-1),this.dsCurrVal+=e}}class bi extends D0{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Od,this.clientEncoder=new ea,this.leftClockEncoder=new Od,this.rightClockEncoder=new Od,this.infoEncoder=new Xy(Ao),this.stringEncoder=new v2,this.parentInfoEncoder=new Xy(Ao),this.typeRefEncoder=new ea,this.lenEncoder=new ea}toUint8Array(){const e=gt();return ae(e,0),Ze(e,this.keyClockEncoder.toUint8Array()),Ze(e,this.clientEncoder.toUint8Array()),Ze(e,this.leftClockEncoder.toUint8Array()),Ze(e,this.rightClockEncoder.toUint8Array()),Ze(e,qe(this.infoEncoder)),Ze(e,this.stringEncoder.toUint8Array()),Ze(e,qe(this.parentInfoEncoder)),Ze(e,this.typeRefEncoder.toUint8Array()),Ze(e,this.lenEncoder.toUint8Array()),Ql(e,qe(this.restEncoder)),qe(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){ns(this.restEncoder,e)}writeBuf(e){Ze(this.restEncoder,e)}writeJSON(e){ns(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 uM=(t,e,n,r)=>{r=ar(r,e[0].id.clock);const i=Vn(e,r);ae(t.restEncoder,e.length-i),t.writeClient(n),ae(t.restEncoder,r);const s=e[i];s.write(t,r-s.id.clock);for(let o=i+1;o<e.length;o++)e[o].write(t,0)},Jd=(t,e,n)=>{const r=new Map;n.forEach((i,s)=>{rt(e,s)>i&&r.set(s,i)}),Io(e).forEach((i,s)=>{n.has(s)||r.set(s,0)}),ae(t.restEncoder,r.size),lr(r.entries()).sort((i,s)=>s[0]-i[0]).forEach(([i,s])=>{uM(t,e.clients.get(i),i,s)})},dM=(t,e)=>{const n=Lt(),r=pe(t.restDecoder);for(let i=0;i<r;i++){const s=pe(t.restDecoder),o=new Array(s),l=t.readClient();let a=pe(t.restDecoder);n.set(l,{i:0,refs:o});for(let c=0;c<s;c++){const u=t.readInfo();switch(Zl&u){case 0:{const d=t.readLen();o[c]=new dn(me(l,a),d),a+=d;break}case 10:{const d=pe(t.restDecoder);o[c]=new fn(me(l,a),d),a+=d;break}default:{const d=(u&(cr|Yt))===0,f=new Ve(me(l,a),null,(u&Yt)===Yt?t.readLeftID():null,null,(u&cr)===cr?t.readRightID():null,d?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,d&&(u&Co)===Co?t.readString():null,Cb(t,u));o[c]=f,a+=f.length}}}}return n},fM=(t,e,n)=>{const r=[];let i=lr(n.keys()).sort((h,p)=>h-p);if(i.length===0)return null;const s=()=>{if(i.length===0)return null;let h=n.get(i[i.length-1]);for(;h.refs.length===h.i;)if(i.pop(),i.length>0)h=n.get(i[i.length-1]);else return null;return h};let o=s();if(o===null)return null;const l=new V0,a=new Map,c=(h,p)=>{const g=a.get(h);(g==null||g>p)&&a.set(h,p)};let u=o.refs[o.i++];const d=new Map,f=()=>{for(const h of r){const p=h.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,[h]),i=i.filter(v=>v!==p)}r.length=0};for(;;){if(u.constructor!==fn){const p=Vt(d,u.id.client,()=>rt(e,u.id.client))-u.id.clock;if(p<0)r.push(u),c(u.id.client,u.id.clock-1),f();else{const g=u.getMissing(t,e);if(g!==null){r.push(u);const v=n.get(g)||{refs:[],i:0};if(v.refs.length===v.i)c(g,rt(e,g)),f();else{u=v.refs[v.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=s(),o===null)break;u=o.refs[o.i++]}}if(l.clients.size>0){const h=new bi;return Jd(h,l,new Map),ae(h.restEncoder,0),{missing:a,update:h.toUint8Array()}}return null},hM=(t,e)=>Jd(t,e.doc.store,e.beforeState),pM=(t,e,n,r=new ds(t))=>Fe(e,i=>{i.local=!1;let s=!1;const o=i.doc,l=o.store,a=dM(r,o),c=fM(i,l,a),u=l.pendingStructs;if(u){for(const[f,h]of u.missing)if(h<rt(l,f)){s=!0;break}if(c){for(const[f,h]of c.missing){const p=u.missing.get(f);(p==null||p>h)&&u.missing.set(f,h)}u.update=aa([u.update,c.update])}}else l.pendingStructs=c;const d=A0(r,i,l);if(l.pendingDs){const f=new ds(Hn(l.pendingDs));pe(f.restDecoder);const h=A0(f,i,l);d&&h?l.pendingDs=aa([d,h]):l.pendingDs=d||h}else l.pendingDs=d;if(s){const f=l.pendingStructs.update;l.pendingStructs=null,R0(i.doc,f)}},n,!1),R0=(t,e,n,r=ds)=>{const i=Hn(e);pM(i,t,n,new r(i))},L0=(t,e,n)=>R0(t,e,n,_0),mM=(t,e,n=new Map)=>{Jd(t,e.store,n),cs(t,T0(e.store))},gM=(t,e=new Uint8Array([0]),n=new bi)=>{const r=I0(e);mM(n,t,r);const i=[n.toUint8Array()];if(t.store.pendingDs&&i.push(t.store.pendingDs),t.store.pendingStructs&&i.push(LM(t.store.pendingStructs.update,e)),i.length>1){if(n.constructor===_o)return DM(i.map((s,o)=>o===0?s:PM(s)));if(n.constructor===bi)return aa(i)}return i[0]},Gd=(t,e)=>gM(t,e,new _o),yM=t=>{const e=new Map,n=pe(t.restDecoder);for(let r=0;r<n;r++){const i=pe(t.restDecoder),s=pe(t.restDecoder);e.set(i,s)}return e},I0=t=>yM(new O0(Hn(t))),P0=(t,e)=>(ae(t.restEncoder,e.size),lr(e.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{ae(t.restEncoder,n),ae(t.restEncoder,r)}),t),bM=(t,e)=>P0(t,Io(e.store)),vM=(t,e=new D0)=>(t instanceof Map?P0(e,t):bM(e,t),e.toUint8Array()),wM=t=>vM(t,new N0);class xM{constructor(){this.l=[]}}const F0=()=>new xM,$0=(t,e)=>t.l.push(e),B0=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(i=>e!==i),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},j0=(t,e,n)=>Id(t.l,[e,n]);class fs{constructor(e,n){this.client=e,this.clock=n}}const hs=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,me=(t,e)=>new fs(t,e),No=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw cn()},Do=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class Ro{constructor(e,n,r,i=0){this.type=e,this.tname=n,this.item=r,this.assoc=i}}const Lo=t=>new Ro(t.type==null?null:me(t.type.client,t.type.clock),t.tname||null,t.item==null?null:me(t.item.client,t.item.clock),t.assoc==null?0:t.assoc);class kM{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const CM=(t,e,n=0)=>new kM(t,e,n),oa=(t,e,n)=>{let r=null,i=null;return t._item===null?i=No(t):r=me(t._item.id.client,t._item.id.clock),new Ro(r,i,e,n)},Yd=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return oa(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return oa(t,me(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return oa(t,r.lastId,n);r=r.right}return oa(t,null,n)},SM=(t,e,n=!0)=>{const r=e.store,i=t.item,s=t.type,o=t.tname,l=t.assoc;let a=null,c=0;if(i!==null){if(rt(r,i.client)<=i.clock)return null;const u=n?df(r,i):{item:ps(r,i),diff:0},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 f=d.left;for(;f!==null;)!f.deleted&&f.countable&&(c+=f.length),f=f.left}}else{if(o!==null)a=e.get(o);else if(s!==null){if(rt(r,s.client)<=s.clock)return null;const{item:u}=n?df(r,s):{item:ps(r,s)};if(u instanceof Ve&&u.content instanceof Sn)a=u.content.type;else return null}else throw cn();l>=0?c=a._length:c=0}return CM(a,c,t.assoc)},H0=(t,e)=>t===e||t!==null&&e!==null&&t.tname===e.tname&&hs(t.item,e.item)&&hs(t.type,e.type)&&t.assoc===e.assoc;class Xd{constructor(e,n){this.ds=e,this.sv=n}}const z0=(t,e)=>new Xd(t,e),EM=t=>z0(T0(t.store),Io(t.store)),vi=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!as(e.ds,t.id),Zd=(t,e)=>{const n=Vt(t.meta,Zd,or),r=t.doc.store;n.has(e)||(e.sv.forEach((i,s)=>{i<rt(r,s)&&Ut(t,me(s,i))}),Pr(t,e.ds,i=>{}),n.add(e))};class V0{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Io=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const i=n[n.length-1];e.set(r,i.id.clock+i.length)}),e},rt=(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},U0=(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 cn()}n.push(e)},Vn=(t,e)=>{let n=0,r=t.length-1,i=t[r],s=i.id.clock;if(s===e)return r;let o=wn(e/(s+i.length-1)*r);for(;n<=r;){if(i=t[o],s=i.id.clock,s<=e){if(e<s+i.length)return o;n=o+1}else r=o-1;o=wn((n+r)/2)}throw cn()},ps=(t,e)=>{const n=t.clients.get(e.client);return n[Vn(n,e.clock)]},Qd=(t,e,n)=>{const r=Vn(e,n),i=e[r];return i.id.clock<n&&i instanceof Ve?(e.splice(r+1,0,ba(t,i,n-i.id.clock)),r+1):r},Ut=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[Qd(t,n,e.clock)]},W0=(t,e,n)=>{const r=e.clients.get(n.client),i=Vn(r,n.clock),s=r[i];return n.clock!==s.id.clock+s.length-1&&s.constructor!==dn&&r.splice(i+1,0,ba(t,s,n.clock-s.id.clock+1)),s},TM=(t,e,n)=>{const r=t.clients.get(e.id.client);r[Vn(r,e.id.clock)]=n},q0=(t,e,n,r,i)=>{if(r===0)return;const s=n+r;let o=Qd(t,e,n),l;do l=e[o++],s<l.id.clock+l.length&&Qd(t,e,s),i(l);while(o<e.length&&e[o].id.clock<s)};class AM{constructor(e,n,r){this.doc=e,this.deleteSet=new ls,this.beforeState=Io(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 K0=(t,e)=>e.deleteSet.clients.size===0&&!qA(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(Wd(e.deleteSet),hM(t,e),cs(t,e.deleteSet),!0),J0=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&Vt(t.changed,e,or).add(n)},la=(t,e)=>{let n=t[e],r=t[e-1],i=e;for(;i>0;n=r,r=t[--i-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 s=e-i;return s&&t.splice(e+1-s,s),s},MM=(t,e,n)=>{for(const[r,i]of t.clients.entries()){const s=e.clients.get(r);for(let o=i.length-1;o>=0;o--){const l=i[o],a=l.clock+l.len;for(let c=Vn(s,l.clock),u=s[c];c<s.length&&u.id.clock<a;u=s[++c]){const d=s[c];if(l.clock+l.len<=d.id.clock)break;d instanceof Ve&&d.deleted&&!d.keep&&n(d)&&d.gc(e,!1)}}}},OM=(t,e)=>{t.clients.forEach((n,r)=>{const i=e.clients.get(r);for(let s=n.length-1;s>=0;s--){const o=n[s],l=Ir(i.length-1,1+Vn(i,o.clock+o.len-1));for(let a=l,c=i[a];a>0&&c.id.clock>=o.clock;c=i[a])a-=1+la(i,a)}})},G0=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,i=r.store,s=n.deleteSet,o=n._mergeStructs;try{Wd(s),n.afterState=Io(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),j0(c._dEH,a,n))})}),l.push(()=>r.emit("afterTransaction",[n,r])),Id(l,[]),n._needFormattingCleanup&&YM(n)}finally{r.gc&&MM(s,i,r.gcFilter),OM(s,i),n.afterState.forEach((u,d)=>{const f=n.beforeState.get(d)||0;if(f!==u){const h=i.clients.get(d),p=ar(Vn(h,f),1);for(let g=h.length-1;g>=p;)g-=1+la(h,g)}});for(let u=o.length-1;u>=0;u--){const{client:d,clock:f}=o[u].id,h=i.clients.get(d),p=Vn(h,f);p+1<h.length&&la(h,p+1)>1||p>0&&la(h,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(y0(ia,un,"[yjs] ",yi,f0,"Changed the client-id because another client seems to be using it."),r.clientID=M0()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const u=new _o;K0(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const u=new bi;K0(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])):G0(t,e+1)}}},Fe=(t,e,n=null,r=!0)=>{const i=t._transactionCleanups;let s=!1,o=null;t._transaction===null&&(s=!0,t._transaction=new AM(t,n,r),i.push(t._transaction),i.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{o=e(t._transaction)}finally{if(s){const l=t._transaction===i[0];t._transaction=null,l&&G0(i,0)}}return o};class _M{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const Y0=(t,e,n)=>{Pr(t,n.deletions,r=>{r instanceof Ve&&e.scope.some(i=>Do(i,r))&&ff(r,!1)})},X0=(t,e,n)=>{let r=null;const i=t.doc,s=t.scope;if(Fe(i,o=>{for(;e.length>0&&t.currStackItem===null;){const l=i.store,a=e.pop(),c=new Set,u=[];let d=!1;Pr(o,a.insertions,f=>{if(f instanceof Ve){if(f.redone!==null){let{item:h,diff:p}=df(l,f.id);p>0&&(h=Ut(o,me(h.id.client,h.id.clock+p))),f=h}!f.deleted&&s.some(h=>Do(h,f))&&u.push(f)}}),Pr(o,a.deletions,f=>{f instanceof Ve&&s.some(h=>Do(h,f))&&!as(a.insertions,f.id)&&c.add(f)}),c.forEach(f=>{d=kb(o,f,c,a.insertions,t.ignoreRemoteMapChanges,t)!==null||d});for(let f=u.length-1;f>=0;f--){const h=u[f];t.deleteFilter(h)&&(h.delete(o),d=!0)}t.currStackItem=d?a:null}o.changed.forEach((l,a)=>{l.has(null)&&a._searchMarker&&(a._searchMarker.length=0)}),r=o},t),t.currStackItem!=null){const o=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:t.currStackItem,type:n,changedParentTypes:o,origin:t},t]),t.currStackItem=null}return t.currStackItem};class Z0 extends vd{constructor(e,{captureTimeout:n=500,captureTransaction:r=a=>!0,deleteFilter:i=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:l=bd(e)?e[0].doc:e.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(e),this.deleteFilter=i,s.add(this),this.trackedOrigins=s,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(v=>a.changedParentTypes.has(v))||!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 f=new ls;a.afterState.forEach((v,w)=>{const S=a.beforeState.get(w)||0,x=v-S;x>0&&Oo(f,w,S,x)});const h=Bn();let p=!1;if(this.lastChange>0&&h-this.lastChange<this.captureTimeout&&d.length>0&&!c&&!u){const v=d[d.length-1];v.deletions=qd([v.deletions,a.deleteSet]),v.insertions=qd([v.insertions,f])}else d.push(new _M(a.deleteSet,f)),p=!0;!c&&!u&&(this.lastChange=h),Pr(a,a.deleteSet,v=>{v instanceof Ve&&this.scope.some(w=>Do(w,v))&&ff(v,!0)});const g=[{stackItem:d[d.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){e=bd(e)?e:[e],e.forEach(n=>{this.scope.every(r=>r!==n)&&(n.doc!==this.doc&&q2("[yjs#509] Not same Y.Doc"),this.scope.push(n))})}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(i=>Y0(r,this,i)),this.undoStack=[]),n&&(this.redoStack.forEach(i=>Y0(r,this,i)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=X0(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=X0(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*NM(t){const e=pe(t.restDecoder);for(let n=0;n<e;n++){const r=pe(t.restDecoder),i=t.readClient();let s=pe(t.restDecoder);for(let o=0;o<r;o++){const l=t.readInfo();if(l===10){const a=pe(t.restDecoder);yield new fn(me(i,s),a),s+=a}else if(Zl&l){const a=(l&(cr|Yt))===0,c=new Ve(me(i,s),null,(l&Yt)===Yt?t.readLeftID():null,null,(l&cr)===cr?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(l&Co)===Co?t.readString():null,Cb(t,l));yield c,s+=c.length}else{const a=t.readLen();yield new dn(me(i,s),a),s+=a}}}}class ef{constructor(e,n){this.gen=NM(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===fn);return this.curr}}class tf{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const DM=t=>aa(t,_0,_o),RM=(t,e)=>{if(t.constructor===dn){const{client:n,clock:r}=t.id;return new dn(me(n,r+e),t.length-e)}else if(t.constructor===fn){const{client:n,clock:r}=t.id;return new fn(me(n,r+e),t.length-e)}else{const n=t,{client:r,clock:i}=n.id;return new Ve(me(r,i+e),null,me(r,i+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},aa=(t,e=ds,n=bi)=>{if(t.length===1)return t[0];const r=t.map(u=>new e(Hn(u)));let i=r.map(u=>new ef(u,!0)),s=null;const o=new n,l=new tf(o);for(;i=i.filter(f=>f.curr!==null),i.sort((f,h)=>{if(f.curr.id.client===h.curr.id.client){const p=f.curr.id.clock-h.curr.id.clock;return p===0?f.curr.constructor===h.curr.constructor?0:f.curr.constructor===fn?1:-1:p}else return h.curr.id.client-f.curr.id.client}),i.length!==0;){const u=i[0],d=u.curr.id.client;if(s!==null){let f=u.curr,h=!1;for(;f!==null&&f.id.clock+f.length<=s.struct.id.clock+s.struct.length&&f.id.client>=s.struct.id.client;)f=u.next(),h=!0;if(f===null||f.id.client!==d||h&&f.id.clock>s.struct.id.clock+s.struct.length)continue;if(d!==s.struct.id.client)Fr(l,s.struct,s.offset),s={struct:f,offset:0},u.next();else if(s.struct.id.clock+s.struct.length<f.id.clock)if(s.struct.constructor===fn)s.struct.length=f.id.clock+f.length-s.struct.id.clock;else{Fr(l,s.struct,s.offset);const p=f.id.clock-s.struct.id.clock-s.struct.length;s={struct:new fn(me(d,s.struct.id.clock+s.struct.length),p),offset:0}}else{const p=s.struct.id.clock+s.struct.length-f.id.clock;p>0&&(s.struct.constructor===fn?s.struct.length-=p:f=RM(f,p)),s.struct.mergeWith(f)||(Fr(l,s.struct,s.offset),s={struct:f,offset:0},u.next())}}else s={struct:u.curr,offset:0},u.next();for(let f=u.curr;f!==null&&f.id.client===d&&f.id.clock===s.struct.id.clock+s.struct.length&&f.constructor!==fn;f=u.next())Fr(l,s.struct,s.offset),s={struct:f,offset:0}}s!==null&&(Fr(l,s.struct,s.offset),s=null),nf(l);const a=r.map(u=>Kd(u)),c=qd(a);return cs(o,c),o.toUint8Array()},LM=(t,e,n=ds,r=bi)=>{const i=I0(e),s=new r,o=new tf(s),l=new n(Hn(t)),a=new ef(l,!1);for(;a.curr;){const u=a.curr,d=u.id.client,f=i.get(d)||0;if(a.curr.constructor===fn){a.next();continue}if(u.id.clock+u.length>f)for(Fr(o,u,ar(f-u.id.clock,0)),a.next();a.curr&&a.curr.id.client===d;)Fr(o,a.curr,0),a.next();else for(;a.curr&&a.curr.id.client===d&&a.curr.id.clock+a.curr.length<=f;)a.next()}nf(o);const c=Kd(l);return cs(s,c),s.toUint8Array()},Q0=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:qe(t.encoder.restEncoder)}),t.encoder.restEncoder=gt(),t.written=0)},Fr=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&Q0(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),ae(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},nf=t=>{Q0(t);const e=t.encoder.restEncoder;ae(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];ae(e,r.written),Ql(e,r.restEncoder)}},IM=(t,e,n,r)=>{const i=new n(Hn(t)),s=new ef(i,!1),o=new r,l=new tf(o);for(let c=s.curr;c!==null;c=s.next())Fr(l,e(c),0);nf(l);const a=Kd(i);return cs(o,a),o.toUint8Array()},PM=t=>IM(t,R2,ds,_o),eb="You must not compute changes after the event-handler fired.";class ca{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=FM(this.currentTarget,this.target))}deletes(e){return as(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw xn(eb);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(i=>{if(i!==null){const s=n._map.get(i);let o,l;if(this.adds(s)){let a=s.left;for(;a!==null&&this.adds(a);)a=a.left;if(this.deletes(s))if(a!==null&&this.deletes(a))o="delete",l=yd(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",l=yd(a.content.getContent())):(o="add",l=void 0)}else if(this.deletes(s))o="delete",l=yd(s.content.getContent());else return;e.set(i,{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 xn(eb);const n=this.target,r=or(),i=or(),s=[];if(e={added:r,deleted:i,delta:s,keys:this.keys},this.transaction.changed.get(n).has(null)){let l=null;const a=()=>{l&&s.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,i.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 FM=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,i=e._item.parent._start;for(;i!==e._item&&i!==null;)i.deleted||r++,i=i.right;n.unshift(r)}e=e._item.parent}return n},tb=80;let rf=0;class $M{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=rf++}}const BM=t=>{t.timestamp=rf++},nb=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=rf++},jM=(t,e,n)=>{if(t.length>=tb){const r=t.reduce((i,s)=>i.timestamp<s.timestamp?i:s);return nb(r,e,n),r}else{const r=new $M(e,n);return t.push(r),r}},ua=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((s,o)=>Yl(e-s.index)<Yl(e-o.index)?s:o);let r=t._start,i=0;for(n!==null&&(r=n.p,i=n.index,BM(n));r.right!==null&&i<e;){if(!r.deleted&&r.countable){if(e<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>e;)r=r.left,!r.deleted&&r.countable&&(i-=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&&(i-=r.length);return n!==null&&Yl(n.index-i)<r.parent.length/tb?(nb(n,r,i),n):jM(t._searchMarker,r,i)},Po=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const i=t[r];if(n>0){let s=i.p;for(s.marker=!1;s&&(s.deleted||!s.countable);)s=s.left,s&&!s.deleted&&s.countable&&(i.index-=s.length);if(s===null||s.marker===!0){t.splice(r,1);continue}i.p=s,s.marker=!0}(e<i.index||n>0&&e===i.index)&&(i.index=ar(e,i.index+n))}},da=(t,e,n)=>{const r=t,i=e.changedParentTypes;for(;Vt(i,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;j0(r._eH,n,e)};class Et{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=F0(),this._dEH=F0(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw kn()}clone(){throw kn()}_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){$0(this._eH,e)}observeDeep(e){$0(this._dEH,e)}unobserve(e){B0(this._eH,e)}unobserveDeep(e){B0(this._dEH,e)}toJSON(){}}const rb=(t,e,n)=>{e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const i=[];let s=t._start;for(;s!==null&&r>0;){if(s.countable&&!s.deleted){const o=s.content.getContent();if(o.length<=e)e-=o.length;else{for(let l=e;l<o.length&&r>0;l++)i.push(o[l]),r--;e=0}}s=s.right}return i},ib=t=>{const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let i=0;i<r.length;i++)e.push(r[i])}n=n.right}return e},sb=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&vi(r,e)){const i=r.content.getContent();for(let s=0;s<i.length;s++)n.push(i[s])}r=r.right}return n},Fo=(t,e)=>{let n=0,r=t._start;for(;r!==null;){if(r.countable&&!r.deleted){const i=r.content.getContent();for(let s=0;s<i.length;s++)e(i[s],n++,t)}r=r.right}},ob=(t,e)=>{const n=[];return Fo(t,(r,i)=>{n.push(e(r,i,t))}),n},HM=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 i=n[r++];return n.length<=r&&(n=null),{done:!1,value:i}}}},lb=(t,e)=>{const n=ua(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}},fa=(t,e,n,r)=>{let i=n;const s=t.doc,o=s.clientID,l=s.store,a=n===null?e._start:n.right;let c=[];const u=()=>{c.length>0&&(i=new Ve(me(o,rt(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new Ci(c)),i.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:i=new Ve(me(o,rt(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new $o(new Uint8Array(d))),i.integrate(t,0);break;case us:i=new Ve(me(o,rt(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new jo(d)),i.integrate(t,0);break;default:if(d instanceof Et)i=new Ve(me(o,rt(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new Sn(d)),i.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},ab=()=>xn("Length exceeded!"),cb=(t,e,n,r)=>{if(n>e._length)throw ab();if(n===0)return e._searchMarker&&Po(e._searchMarker,n,r.length),fa(t,e,null,r);const i=n,s=ua(e,n);let o=e._start;for(s!==null&&(o=s.p,n-=s.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&&Ut(t,me(o.id.client,o.id.clock+n));break}n-=o.length}return e._searchMarker&&Po(e._searchMarker,i,r.length),fa(t,e,o,r)},zM=(t,e,n)=>{let i=(e._searchMarker||[]).reduce((s,o)=>o.index>s.index?o:s,{index:0,p:e._start}).p;if(i)for(;i.right;)i=i.right;return fa(t,e,i,n)},ub=(t,e,n,r)=>{if(r===0)return;const i=n,s=r,o=ua(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&&Ut(t,me(l.id.client,l.id.clock+n)),n-=l.length);for(;r>0&&l!==null;)l.deleted||(r<l.length&&Ut(t,me(l.id.client,l.id.clock+r)),l.delete(t),r-=l.length),l=l.right;if(r>0)throw ab();e._searchMarker&&Po(e._searchMarker,i,-s+r)},ha=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},sf=(t,e,n,r)=>{const i=e._map.get(n)||null,s=t.doc,o=s.clientID;let l;if(r==null)l=new Ci([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:l=new Ci([r]);break;case Uint8Array:l=new $o(r);break;case us:l=new jo(r);break;default:if(r instanceof Et)l=new Sn(r);else throw new Error("Unexpected content type")}new Ve(me(o,rt(s.store,o)),i,i&&i.lastId,null,null,e,n,l).integrate(t,0)},of=(t,e)=>{const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},db=t=>{const e={};return t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},fb=(t,e)=>{const n=t._map.get(e);return n!==void 0&&!n.deleted},VM=(t,e)=>{const n={};return t._map.forEach((r,i)=>{let s=r;for(;s!==null&&(!e.sv.has(s.id.client)||s.id.clock>=(e.sv.get(s.id.client)||0));)s=s.left;s!==null&&vi(s,e)&&(n[i]=s.content.getContent()[s.length-1])}),n},pa=t=>lM(t.entries(),e=>!e[1].deleted);class UM extends ca{constructor(e,n){super(e,n),this._transaction=n}}class ms extends Et{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new ms;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ms}clone(){const e=new ms;return e.insert(0,this.toArray().map(n=>n instanceof Et?n.clone():n)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}_callObserver(e,n){super._callObserver(e,n),da(this,e,new UM(this,e))}insert(e,n){this.doc!==null?Fe(this.doc,r=>{cb(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?Fe(this.doc,n=>{zM(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?Fe(this.doc,r=>{ub(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return lb(this,e)}toArray(){return ib(this)}slice(e=0,n=this.length){return rb(this,e,n)}toJSON(){return this.map(e=>e instanceof Et?e.toJSON():e)}map(e){return ob(this,e)}forEach(e){Fo(this,e)}[Symbol.iterator](){return HM(this)}_write(e){e.writeTypeRef(pO)}}const WM=t=>new ms;class qM extends ca{constructor(e,n,r){super(e,n),this.keysChanged=r}}class gs extends Et{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,i)=>{this.set(i,r)}),this._prelimContent=null}_copy(){return new gs}clone(){const e=new gs;return this.forEach((n,r)=>{e.set(r,n instanceof Et?n.clone():n)}),e}_callObserver(e,n){da(this,e,new qM(this,e,n))}toJSON(){const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const i=n.content.getContent()[n.length-1];e[r]=i instanceof Et?i.toJSON():i}}),e}get size(){return[...pa(this._map)].length}keys(){return Vd(pa(this._map),e=>e[0])}values(){return Vd(pa(this._map),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Vd(pa(this._map),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){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?Fe(this.doc,n=>{ha(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?Fe(this.doc,r=>{sf(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return of(this,e)}has(e){return fb(this,e)}clear(){this.doc!==null?Fe(this.doc,e=>{this.forEach(function(n,r,i){ha(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(mO)}}const KM=t=>new gs,$r=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&N2(t,e);class lf{constructor(e,n,r,i){this.left=e,this.right=n,this.index=r,this.currentAttributes=i}forward(){switch(this.right===null&&cn(),this.right.content.constructor){case lt:this.right.deleted||ys(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 hb=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case lt:e.right.deleted||ys(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n<e.right.length&&Ut(t,me(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},ma=(t,e,n,r)=>{const i=new Map,s=r?ua(e,n):null;if(s){const o=new lf(s.p.left,s.p,s.index,i);return hb(t,o,n-s.index)}else{const o=new lf(null,e._start,0,i);return hb(t,o,n)}},pb=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===lt&&$r(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const i=t.doc,s=i.clientID;r.forEach((o,l)=>{const a=n.left,c=n.right,u=new Ve(me(s,rt(i.store,s)),a,a&&a.lastId,c,c&&c.id,e,null,new lt(l,o));u.integrate(t,0),n.right=u,n.forward()})},ys=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},mb=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===lt&&$r(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},gb=(t,e,n,r)=>{const i=t.doc,s=i.clientID,o=new Map;for(const l in r){const a=r[l],c=n.currentAttributes.get(l)??null;if(!$r(c,a)){o.set(l,c);const{left:u,right:d}=n;n.right=new Ve(me(s,rt(i.store,s)),u,u&&u.lastId,d,d&&d.id,e,null,new lt(l,a)),n.right.integrate(t,0),n.forward()}}return o},af=(t,e,n,r,i)=>{n.currentAttributes.forEach((f,h)=>{i[h]===void 0&&(i[h]=null)});const s=t.doc,o=s.clientID;mb(n,i);const l=gb(t,e,n,i),a=r.constructor===String?new Cn(r):r instanceof Et?new Sn(r):new ki(r);let{left:c,right:u,index:d}=n;e._searchMarker&&Po(e._searchMarker,n.index,a.getLength()),u=new Ve(me(o,rt(s.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(),pb(t,e,n,l)},yb=(t,e,n,r,i)=>{const s=t.doc,o=s.clientID;mb(n,i);const l=gb(t,e,n,i);e:for(;n.right!==null&&(r>0||l.size>0&&(n.right.deleted||n.right.content.constructor===lt));){if(!n.right.deleted)switch(n.right.content.constructor){case lt:{const{key:a,value:c}=n.right.content,u=i[a];if(u!==void 0){if($r(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&&Ut(t,me(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+=`
|
373
|
+
`;n.right=new Ve(me(o,rt(s.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new Cn(a)),n.right.integrate(t,0),n.forward()}pb(t,e,n,l)},bb=(t,e,n,r,i)=>{let s=e;const o=Lt();for(;s&&(!s.countable||s.deleted);){if(!s.deleted&&s.content.constructor===lt){const c=s.content;o.set(c.key,c)}s=s.right}let l=0,a=!1;for(;e!==s;){if(n===e&&(a=!0),!e.deleted){const c=e.content;switch(c.constructor){case lt:{const{key:u,value:d}=c,f=r.get(u)??null;(o.get(u)!==c||f===d)&&(e.delete(t),l++,!a&&(i.get(u)??null)===d&&f!==d&&(f===null?i.delete(u):i.set(u,f))),!a&&!e.deleted&&ys(i,c);break}}}e=e.right}return l},JM=(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===lt){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},GM=t=>{let e=0;return Fe(t.doc,n=>{let r=t._start,i=t._start,s=Lt();const o=gd(s);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case lt:ys(o,i.content);break;default:e+=bb(n,r,i,s,o),s=gd(o),r=i;break}i=i.right}}),e},YM=t=>{const e=new Set,n=t.doc;for(const[r,i]of t.afterState.entries()){const s=t.beforeState.get(r)||0;i!==s&&q0(t,n.store.clients.get(r),s,i,o=>{!o.deleted&&o.content.constructor===lt&&o.constructor!==dn&&e.add(o.parent)})}Fe(n,r=>{Pr(t,t.deleteSet,i=>{if(i instanceof dn||!i.parent._hasFormatting||e.has(i.parent))return;const s=i.parent;i.content.constructor===lt?e.add(s):JM(r,i)});for(const i of e)GM(i)})},vb=(t,e,n)=>{const r=n,i=gd(e.currentAttributes),s=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Sn:case ki:case Cn:n<e.right.length&&Ut(t,me(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}s&&bb(t,s,e.right,i,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&Po(o._searchMarker,e.index,-r+n),e};class XM extends ca{constructor(e,n,r){super(e,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(i=>{i===null?this.childListChanged=!0:this.keysChanged.add(i)})}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=[];Fe(e,r=>{const i=new Map,s=new Map;let o=this.target._start,l=null;const a={};let c="",u=0,d=0;const f=()=>{if(l!==null){let h=null;switch(l){case"delete":d>0&&(h={delete:d}),d=0;break;case"insert":(typeof c=="object"||c.length>0)&&(h={insert:c},i.size>0&&(h.attributes={},i.forEach((p,g)=>{p!==null&&(h.attributes[g]=p)}))),c="";break;case"retain":u>0&&(h={retain:u},O2(a)||(h.attributes=A2({},a))),u=0;break}h&&n.push(h),l=null}};for(;o!==null;){switch(o.content.constructor){case Sn:case ki:this.adds(o)?this.deletes(o)||(f(),l="insert",c=o.content.getContent()[0],f()):this.deletes(o)?(l!=="delete"&&(f(),l="delete"),d+=1):o.deleted||(l!=="retain"&&(f(),l="retain"),u+=1);break;case Cn:this.adds(o)?this.deletes(o)||(l!=="insert"&&(f(),l="insert"),c+=o.content.str):this.deletes(o)?(l!=="delete"&&(f(),l="delete"),d+=o.length):o.deleted||(l!=="retain"&&(f(),l="retain"),u+=o.length);break;case lt:{const{key:h,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){const g=i.get(h)??null;$r(g,p)?p!==null&&o.delete(r):(l==="retain"&&f(),$r(p,s.get(h)??null)?delete a[h]:a[h]=p)}}else if(this.deletes(o)){s.set(h,p);const g=i.get(h)??null;$r(g,p)||(l==="retain"&&f(),a[h]=g)}else if(!o.deleted){s.set(h,p);const g=a[h];g!==void 0&&($r(g,p)?g!==null&&o.delete(r):(l==="retain"&&f(),p===null?delete a[h]:a[h]=p))}o.deleted||(l==="insert"&&f(),ys(i,o.content));break}}o=o.right}for(f();n.length>0;){const h=n[n.length-1];if(h.retain!==void 0&&h.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class wi extends Et{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return 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 wi}clone(){const e=new wi;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new XM(this,e,n);da(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Cn&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?Fe(this.doc,r=>{const i=new lf(null,this._start,0,new Map);for(let s=0;s<e.length;s++){const o=e[s];if(o.insert!==void 0){const l=!n&&typeof o.insert=="string"&&s===e.length-1&&i.right===null&&o.insert.slice(-1)===`
|
374
|
+
`?o.insert.slice(0,-1):o.insert;(typeof l!="string"||l.length>0)&&af(r,this,i,l,o.attributes||{})}else o.retain!==void 0?yb(r,this,i,o.retain,o.attributes||{}):o.delete!==void 0&&vb(r,i,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){const i=[],s=new Map,o=this.doc;let l="",a=this._start;function c(){if(l.length>0){const d={};let f=!1;s.forEach((p,g)=>{f=!0,d[g]=p});const h={insert:l};f&&(h.attributes=d),i.push(h),l=""}}const u=()=>{for(;a!==null;){if(vi(a,e)||n!==void 0&&vi(a,n))switch(a.content.constructor){case Cn:{const d=s.get("ychange");e!==void 0&&!vi(a,e)?(d===void 0||d.user!==a.id.client||d.type!=="removed")&&(c(),s.set("ychange",r?r("removed",a.id):{type:"removed"})):n!==void 0&&!vi(a,n)?(d===void 0||d.user!==a.id.client||d.type!=="added")&&(c(),s.set("ychange",r?r("added",a.id):{type:"added"})):d!==void 0&&(c(),s.delete("ychange")),l+=a.content.str;break}case Sn:case ki:{c();const d={insert:a.content.getContent()[0]};if(s.size>0){const f={};d.attributes=f,s.forEach((h,p)=>{f[p]=h})}i.push(d);break}case lt:vi(a,e)&&(c(),ys(s,a.content));break}a=a.right}c()};return e||n?Fe(o,d=>{e&&Zd(d,e),n&&Zd(d,n),u()},"cleanup"):u(),i}insert(e,n,r){if(n.length<=0)return;const i=this.doc;i!==null?Fe(i,s=>{const o=ma(s,this,e,!r);r||(r={},o.currentAttributes.forEach((l,a)=>{r[a]=l})),af(s,this,o,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const i=this.doc;i!==null?Fe(i,s=>{const o=ma(s,this,e,!r);af(s,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?Fe(r,i=>{vb(i,ma(i,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const i=this.doc;i!==null?Fe(i,s=>{const o=ma(s,this,e,!1);o.right!==null&&yb(s,this,o,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?Fe(this.doc,n=>{ha(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?Fe(this.doc,r=>{sf(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return of(this,e)}getAttributes(){return db(this)}_write(e){e.writeTypeRef(gO)}}const ZM=t=>new wi;class cf{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0}[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===It||n.constructor===xi)&&n._start!==null)e=n._start;else for(;e!==null;)if(e.right!==null){e=e.right;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 xi extends Et{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 xi}clone(){const e=new xi;return e.insert(0,this.toArray().map(n=>n instanceof Et?n.clone():n)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new cf(this,e)}querySelector(e){e=e.toUpperCase();const r=new cf(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),lr(new cf(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){da(this,e,new tO(this,n,e))}toString(){return ob(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const i=e.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),Fo(this,s=>{i.insertBefore(s.toDOM(e,n,r),null)}),i}insert(e,n){this.doc!==null?Fe(this.doc,r=>{cb(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)Fe(this.doc,r=>{const i=e&&e instanceof Et?e._item:e;fa(r,this,i,n)});else{const r=this._prelimContent,i=e===null?0:r.findIndex(s=>s===e)+1;if(i===0&&e!==null)throw xn("Reference item not found");r.splice(i,0,...n)}}delete(e,n=1){this.doc!==null?Fe(this.doc,r=>{ub(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return ib(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return lb(this,e)}slice(e=0,n=this.length){return rb(this,e,n)}forEach(e){Fo(this,e)}_write(e){e.writeTypeRef(bO)}}const QM=t=>new xi;class It extends xi{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,i)=>{this.setAttribute(i,r)}),this._prelimAttrs=null}_copy(){return new It(this.nodeName)}clone(){const e=new It(this.nodeName),n=this.getAttributes();return M2(n,(r,i)=>{typeof r=="string"&&e.setAttribute(i,r)}),e.insert(0,this.toArray().map(r=>r instanceof Et?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const l in e)r.push(l);r.sort();const i=r.length;for(let l=0;l<i;l++){const a=r[l];n.push(a+'="'+e[a]+'"')}const s=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${s}${o}>${super.toString()}</${s}>`}removeAttribute(e){this.doc!==null?Fe(this.doc,n=>{ha(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?Fe(this.doc,r=>{sf(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return of(this,e)}hasAttribute(e){return fb(this,e)}getAttributes(e){return e?VM(this,e):db(this)}toDOM(e=document,n={},r){const i=e.createElement(this.nodeName),s=this.getAttributes();for(const o in s){const l=s[o];typeof l=="string"&&i.setAttribute(o,l)}return Fo(this,o=>{i.appendChild(o.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(yO),e.writeKey(this.nodeName)}}const eO=t=>new It(t.readKey());class tO extends ca{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i)})}}class ga extends gs{constructor(e){super(),this.hookName=e}_copy(){return new ga(this.hookName)}clone(){const e=new ga(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const i=n[this.hookName];let s;return i!==void 0?s=i.createDom(this):s=document.createElement(this.hookName),s.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef(vO),e.writeKey(this.hookName)}}const nO=t=>new ga(t.readKey());class Xt extends wi{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 Xt}clone(){const e=new Xt;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const i=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(e=>{const n=[];for(const i in e.attributes){const s=[];for(const o in e.attributes[i])s.push({key:o,value:e.attributes[i][o]});s.sort((o,l)=>o.key<l.key?-1:1),n.push({nodeName:i,attrs:s})}n.sort((i,s)=>i.nodeName<s.nodeName?-1:1);let r="";for(let i=0;i<n.length;i++){const s=n[i];r+=`<${s.nodeName}`;for(let o=0;o<s.attrs.length;o++){const l=s.attrs[o];r+=` ${l.key}="${l.value}"`}r+=">"}r+=e.insert;for(let i=n.length-1;i>=0;i--)r+=`</${n[i].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(wO)}}const rO=t=>new Xt;class uf{constructor(e,n){this.id=e,this.length=n}get deleted(){throw kn()}mergeWith(e){return!1}write(e,n,r){throw kn()}integrate(e,n){throw kn()}}const iO=0;class dn extends uf{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),U0(e.doc.store,this)}write(e,n){e.writeInfo(iO),e.writeLen(this.length-n)}getMissing(e,n){return null}}class $o{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new $o(this.content)}splice(e){throw kn()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const sO=t=>new $o(t.readBuf());class Bo{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Bo(this.len)}splice(e){const n=new Bo(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){Oo(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 Bo(t.readLen()),wb=(t,e)=>new us({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class jo{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 jo(wb(this.doc.guid,this.opts))}splice(e){throw kn()}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 lO=t=>new jo(wb(t.readString(),t.readAny()));class ki{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ki(this.embed)}splice(e){throw kn()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const aO=t=>new ki(t.readJSON());class lt{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new lt(this.key,this.value)}splice(e){throw kn()}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 cO=t=>new lt(t.readKey(),t.readJSON());class ya{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ya(this.arr)}splice(e){const n=new ya(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 i=n;i<r;i++){const s=this.arr[i];e.writeString(s===void 0?"undefined":JSON.stringify(s))}}getRef(){return 2}}const uO=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const i=t.readString();i==="undefined"?n.push(void 0):n.push(JSON.parse(i))}return new ya(n)};class Ci{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Ci(this.arr)}splice(e){const n=new Ci(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 i=n;i<r;i++){const s=this.arr[i];e.writeAny(s)}}getRef(){return 8}}const dO=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new Ci(n)};class Cn{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Cn(this.str)}splice(e){const n=new Cn(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 fO=t=>new Cn(t.readString()),hO=[WM,KM,ZM,eO,QM,nO,rO],pO=0,mO=1,gO=2,yO=3,bO=4,vO=5,wO=6;class Sn{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Sn(this.type._copy())}splice(e){throw kn()}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 xO=t=>new Sn(hO[t.readTypeRef()](t)),df=(t,e)=>{let n=e,r=0,i;do r>0&&(n=me(n.client,n.clock+r)),i=ps(t,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof Ve);return{item:i,diff:r}},ff=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},ba=(t,e,n)=>{const{client:r,clock:i}=e.id,s=new Ve(me(r,i+n),e,me(r,i+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&s.markDeleted(),e.keep&&(s.keep=!0),e.redone!==null&&(s.redone=me(e.redone.client,e.redone.clock+n)),e.right=s,s.right!==null&&(s.right.left=s),t._mergeStructs.push(s),s.parentSub!==null&&s.right===null&&s.parent._map.set(s.parentSub,s),e.length=n,s},xb=(t,e)=>JA(t,n=>as(n.deletions,e)),kb=(t,e,n,r,i,s)=>{const o=t.doc,l=o.store,a=o.clientID,c=e.redone;if(c!==null)return Ut(t,c);let u=e.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||kb(t,u,n,r,i,s)===null))return null;for(;u.redone!==null;)u=Ut(t,u.redone)}const h=u===null?e.parent:u.content.type;if(e.parentSub===null){for(d=e.left,f=e;d!==null;){let w=d;for(;w!==null&&w.parent._item!==u;)w=w.redone===null?null:Ut(t,w.redone);if(w!==null&&w.parent._item===u){d=w;break}d=d.left}for(;f!==null;){let w=f;for(;w!==null&&w.parent._item!==u;)w=w.redone===null?null:Ut(t,w.redone);if(w!==null&&w.parent._item===u){f=w;break}f=f.right}}else if(f=null,e.right&&!i){for(d=e;d!==null&&d.right!==null&&(d.right.redone||as(r,d.right.id)||xb(s.undoStack,d.right.id)||xb(s.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Ut(t,d.redone);if(d&&d.right!==null)return null}else d=h._map.get(e.parentSub)||null;const p=rt(l,a),g=me(a,p),v=new Ve(g,d,d&&d.lastId,f,f&&f.id,h,e.parentSub,e.content.copy());return e.redone=g,ff(v,!0),v.integrate(t,0),v};let Ve=class Ph extends uf{constructor(e,n,r,i,s,o,l,a){super(e,a.getLength()),this.origin=r,this.left=n,this.right=i,this.rightOrigin=s,this.parent=o,this.parentSub=l,this.redone=null,this.content=a,this.info=this.content.isCountable()?Uy:0}set marker(e){(this.info&Cd)>0!==e&&(this.info^=Cd)}get marker(){return(this.info&Cd)>0}get keep(){return(this.info&Vy)>0}set keep(e){this.keep!==e&&(this.info^=Vy)}get countable(){return(this.info&Uy)>0}get deleted(){return(this.info&kd)>0}set deleted(e){this.deleted!==e&&(this.info^=kd)}markDeleted(){this.info|=kd}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=rt(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=rt(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===fs&&this.id.client!==this.parent.client&&this.parent.clock>=rt(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=W0(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Ut(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===dn||this.right&&this.right.constructor===dn)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Ph&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===Ph&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===fs){const r=ps(n,this.parent);r.constructor===dn?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=W0(e,e.doc.store,me(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,i;if(r!==null)i=r.right;else if(this.parentSub!==null)for(i=this.parent._map.get(this.parentSub)||null;i!==null&&i.left!==null;)i=i.left;else i=this.parent._start;const s=new Set,o=new Set;for(;i!==null&&i!==this.right;){if(o.add(i),s.add(i),hs(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,s.clear();else if(hs(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&o.has(ps(e.doc.store,i.origin)))s.has(ps(e.doc.store,i.origin))||(r=i,s.clear());else break;i=i.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),U0(e.doc.store,this),this.content.integrate(e,this),J0(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new dn(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:me(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&hs(e.origin,this.lastId)&&this.right===e&&hs(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(),Oo(e.deleteSet,this.id.client,this.id.clock,this.length),J0(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw cn();this.content.gc(e),n?TM(e,this,new dn(this.id,this.length)):this.content=new Bo(this.length)}write(e,n){const r=n>0?me(this.id.client,this.id.clock+n-1):this.origin,i=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&Zl|(r===null?0:Yt)|(i===null?0:cr)|(s===null?0:Co);if(e.writeInfo(o),r!==null&&e.writeLeftID(r),i!==null&&e.writeRightID(i),r===null&&i===null){const l=this.parent;if(l._item!==void 0){const a=l._item;if(a===null){const c=No(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===fs?(e.writeParentInfo(!1),e.writeLeftID(l)):cn();s!==null&&e.writeString(s)}this.content.write(e,n)}};const Cb=(t,e)=>kO[e&Zl](t),kO=[()=>{cn()},oO,uO,sO,fO,aO,cO,xO,dO,lO,()=>{cn()}],CO=10;class fn extends uf{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){cn()}write(e,n){e.writeInfo(CO),ae(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const Sb=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Eb="__ $YJS$ __";Sb[Eb]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Sb[Eb]=!0;function va(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Tb={exports:{}};(function(t,e){(function(n){t.exports=n()})(function(){var n=Math.floor,r=Math.abs,i=Math.pow;return function(){function s(o,l,a){function c(f,h){if(!l[f]){if(!o[f]){var p=typeof va=="function"&&va;if(!h&&p)return p(f,!0);if(u)return u(f,!0);var g=new Error("Cannot find module '"+f+"'");throw g.code="MODULE_NOT_FOUND",g}var v=l[f]={exports:{}};o[f][0].call(v.exports,function(w){var S=o[f][1][w];return c(S||w)},v,v.exports,s,o,l,a)}return l[f].exports}for(var u=typeof va=="function"&&va,d=0;d<a.length;d++)c(a[d]);return c}return s}()({1:[function(s,o,l){function a(y){var C=y.length;if(0<C%4)throw new Error("Invalid string. Length must be a multiple of 4");var E=y.indexOf("=");E===-1&&(E=C);var T=E===C?0:4-E%4;return[E,T]}function c(y,C,E){return 3*(C+E)/4-E}function u(y){var C,E,T=a(y),D=T[0],N=T[1],A=new v(c(y,D,N)),R=0,P=0<N?D-4:D;for(E=0;E<P;E+=4)C=g[y.charCodeAt(E)]<<18|g[y.charCodeAt(E+1)]<<12|g[y.charCodeAt(E+2)]<<6|g[y.charCodeAt(E+3)],A[R++]=255&C>>16,A[R++]=255&C>>8,A[R++]=255&C;return N===2&&(C=g[y.charCodeAt(E)]<<2|g[y.charCodeAt(E+1)]>>4,A[R++]=255&C),N===1&&(C=g[y.charCodeAt(E)]<<10|g[y.charCodeAt(E+1)]<<4|g[y.charCodeAt(E+2)]>>2,A[R++]=255&C>>8,A[R++]=255&C),A}function d(y){return p[63&y>>18]+p[63&y>>12]+p[63&y>>6]+p[63&y]}function f(y,C,E){for(var T,D=[],N=C;N<E;N+=3)T=(16711680&y[N]<<16)+(65280&y[N+1]<<8)+(255&y[N+2]),D.push(d(T));return D.join("")}function h(y){for(var C,E=y.length,T=E%3,D=[],N=16383,A=0,R=E-T;A<R;A+=N)D.push(f(y,A,A+N>R?R:A+N));return T===1?(C=y[E-1],D.push(p[C>>2]+p[63&C<<4]+"==")):T===2&&(C=(y[E-2]<<8)+y[E-1],D.push(p[C>>10]+p[63&C>>4]+p[63&C<<2]+"=")),D.join("")}l.byteLength=function(y){var C=a(y),E=C[0],T=C[1];return 3*(E+T)/4-T},l.toByteArray=u,l.fromByteArray=h;for(var p=[],g=[],v=typeof Uint8Array>"u"?Array:Uint8Array,w="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",S=0,x=w.length;S<x;++S)p[S]=w[S],g[w.charCodeAt(S)]=S;g[45]=62,g[95]=63},{}],2:[function(){},{}],3:[function(s,o,l){(function(){(function(){var a=String.fromCharCode,c=Math.min;function u(m){if(2147483647<m)throw new RangeError('The value "'+m+'" is invalid for option "size"');var b=new Uint8Array(m);return b.__proto__=d.prototype,b}function d(m,b,k){if(typeof m=="number"){if(typeof b=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(m)}return f(m,b,k)}function f(m,b,k){if(typeof m=="string")return v(m,b);if(ArrayBuffer.isView(m))return w(m);if(m==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof m);if($(m,ArrayBuffer)||m&&$(m.buffer,ArrayBuffer))return S(m,b,k);if(typeof m=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var I=m.valueOf&&m.valueOf();if(I!=null&&I!==m)return d.from(I,b,k);var F=x(m);if(F)return F;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof m[Symbol.toPrimitive]=="function")return d.from(m[Symbol.toPrimitive]("string"),b,k);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof m)}function h(m){if(typeof m!="number")throw new TypeError('"size" argument must be of type number');if(0>m)throw new RangeError('The value "'+m+'" is invalid for option "size"')}function p(m,b,k){return h(m),0>=m||b===void 0?u(m):typeof k=="string"?u(m).fill(b,k):u(m).fill(b)}function g(m){return h(m),u(0>m?0:0|y(m))}function v(m,b){if((typeof b!="string"||b==="")&&(b="utf8"),!d.isEncoding(b))throw new TypeError("Unknown encoding: "+b);var k=0|C(m,b),I=u(k),F=I.write(m,b);return F!==k&&(I=I.slice(0,F)),I}function w(m){for(var b=0>m.length?0:0|y(m.length),k=u(b),I=0;I<b;I+=1)k[I]=255&m[I];return k}function S(m,b,k){if(0>b||m.byteLength<b)throw new RangeError('"offset" is outside of buffer bounds');if(m.byteLength<b+(k||0))throw new RangeError('"length" is outside of buffer bounds');var I;return I=b===void 0&&k===void 0?new Uint8Array(m):k===void 0?new Uint8Array(m,b):new Uint8Array(m,b,k),I.__proto__=d.prototype,I}function x(m){if(d.isBuffer(m)){var b=0|y(m.length),k=u(b);return k.length===0||m.copy(k,0,0,b),k}return m.length===void 0?m.type==="Buffer"&&Array.isArray(m.data)?w(m.data):void 0:typeof m.length!="number"||j(m.length)?u(0):w(m)}function y(m){if(m>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|m}function C(m,b){if(d.isBuffer(m))return m.length;if(ArrayBuffer.isView(m)||$(m,ArrayBuffer))return m.byteLength;if(typeof m!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof m);var k=m.length,I=2<arguments.length&&arguments[2]===!0;if(!I&&k===0)return 0;for(var F=!1;;)switch(b){case"ascii":case"latin1":case"binary":return k;case"utf8":case"utf-8":return Ye(m).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*k;case"hex":return k>>>1;case"base64":return it(m).length;default:if(F)return I?-1:Ye(m).length;b=(""+b).toLowerCase(),F=!0}}function E(m,b,k){var I=!1;if((b===void 0||0>b)&&(b=0),b>this.length||((k===void 0||k>this.length)&&(k=this.length),0>=k)||(k>>>=0,b>>>=0,k<=b))return"";for(m||(m="utf8");;)switch(m){case"hex":return Le(this,b,k);case"utf8":case"utf-8":return G(this,b,k);case"ascii":return Z(this,b,k);case"latin1":case"binary":return ke(this,b,k);case"base64":return J(this,b,k);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $e(this,b,k);default:if(I)throw new TypeError("Unknown encoding: "+m);m=(m+"").toLowerCase(),I=!0}}function T(m,b,k){var I=m[b];m[b]=m[k],m[k]=I}function D(m,b,k,I,F){if(m.length===0)return-1;if(typeof k=="string"?(I=k,k=0):2147483647<k?k=2147483647:-2147483648>k&&(k=-2147483648),k=+k,j(k)&&(k=F?0:m.length-1),0>k&&(k=m.length+k),k>=m.length){if(F)return-1;k=m.length-1}else if(0>k)if(F)k=0;else return-1;if(typeof b=="string"&&(b=d.from(b,I)),d.isBuffer(b))return b.length===0?-1:N(m,b,k,I,F);if(typeof b=="number")return b&=255,typeof Uint8Array.prototype.indexOf=="function"?F?Uint8Array.prototype.indexOf.call(m,b,k):Uint8Array.prototype.lastIndexOf.call(m,b,k):N(m,[b],k,I,F);throw new TypeError("val must be string, number or Buffer")}function N(m,b,k,I,F){function H(Qn,V){return ne===1?Qn[V]:Qn.readUInt16BE(V*ne)}var ne=1,de=m.length,_e=b.length;if(I!==void 0&&(I=(I+"").toLowerCase(),I==="ucs2"||I==="ucs-2"||I==="utf16le"||I==="utf-16le")){if(2>m.length||2>b.length)return-1;ne=2,de/=2,_e/=2,k/=2}var we;if(F){var ye=-1;for(we=k;we<de;we++)if(H(m,we)!==H(b,ye===-1?0:we-ye))ye!==-1&&(we-=we-ye),ye=-1;else if(ye===-1&&(ye=we),we-ye+1===_e)return ye*ne}else for(k+_e>de&&(k=de-_e),we=k;0<=we;we--){for(var Xe=!0,Mn=0;Mn<_e;Mn++)if(H(m,we+Mn)!==H(b,Mn)){Xe=!1;break}if(Xe)return we}return-1}function A(m,b,k,I){k=+k||0;var F=m.length-k;I?(I=+I,I>F&&(I=F)):I=F;var H=b.length;I>H/2&&(I=H/2);for(var ne,de=0;de<I;++de){if(ne=parseInt(b.substr(2*de,2),16),j(ne))return de;m[k+de]=ne}return de}function R(m,b,k,I){return at(Ye(b,m.length-k),m,k,I)}function P(m,b,k,I){return at(Ot(b),m,k,I)}function B(m,b,k,I){return P(m,b,k,I)}function z(m,b,k,I){return at(it(b),m,k,I)}function U(m,b,k,I){return at(xt(b,m.length-k),m,k,I)}function J(m,b,k){return b===0&&k===m.length?q.fromByteArray(m):q.fromByteArray(m.slice(b,k))}function G(m,b,k){k=c(m.length,k);for(var I=[],F=b;F<k;){var H=m[F],ne=null,de=239<H?4:223<H?3:191<H?2:1;if(F+de<=k){var _e,we,ye,Xe;de===1?128>H&&(ne=H):de===2?(_e=m[F+1],(192&_e)==128&&(Xe=(31&H)<<6|63&_e,127<Xe&&(ne=Xe))):de===3?(_e=m[F+1],we=m[F+2],(192&_e)==128&&(192&we)==128&&(Xe=(15&H)<<12|(63&_e)<<6|63&we,2047<Xe&&(55296>Xe||57343<Xe)&&(ne=Xe))):de===4&&(_e=m[F+1],we=m[F+2],ye=m[F+3],(192&_e)==128&&(192&we)==128&&(192&ye)==128&&(Xe=(15&H)<<18|(63&_e)<<12|(63&we)<<6|63&ye,65535<Xe&&1114112>Xe&&(ne=Xe)))}ne===null?(ne=65533,de=1):65535<ne&&(ne-=65536,I.push(55296|1023&ne>>>10),ne=56320|1023&ne),I.push(ne),F+=de}return ie(I)}function ie(m){var b=m.length;if(b<=4096)return a.apply(String,m);for(var k="",I=0;I<b;)k+=a.apply(String,m.slice(I,I+=4096));return k}function Z(m,b,k){var I="";k=c(m.length,k);for(var F=b;F<k;++F)I+=a(127&m[F]);return I}function ke(m,b,k){var I="";k=c(m.length,k);for(var F=b;F<k;++F)I+=a(m[F]);return I}function Le(m,b,k){var I=m.length;(!b||0>b)&&(b=0),(!k||0>k||k>I)&&(k=I);for(var F="",H=b;H<k;++H)F+=Ge(m[H]);return F}function $e(m,b,k){for(var I=m.slice(b,k),F="",H=0;H<I.length;H+=2)F+=a(I[H]+256*I[H+1]);return F}function Ee(m,b,k){if(m%1!=0||0>m)throw new RangeError("offset is not uint");if(m+b>k)throw new RangeError("Trying to access beyond buffer length")}function ve(m,b,k,I,F,H){if(!d.isBuffer(m))throw new TypeError('"buffer" argument must be a Buffer instance');if(b>F||b<H)throw new RangeError('"value" argument is out of bounds');if(k+I>m.length)throw new RangeError("Index out of range")}function De(m,b,k,I){if(k+I>m.length)throw new RangeError("Index out of range");if(0>k)throw new RangeError("Index out of range")}function Ie(m,b,k,I,F){return b=+b,k>>>=0,F||De(m,b,k,4),te.write(m,b,k,I,23,4),k+4}function tt(m,b,k,I,F){return b=+b,k>>>=0,F||De(m,b,k,8),te.write(m,b,k,I,52,8),k+8}function nt(m){if(m=m.split("=")[0],m=m.trim().replace(M,""),2>m.length)return"";for(;m.length%4!=0;)m+="=";return m}function Ge(m){return 16>m?"0"+m.toString(16):m.toString(16)}function Ye(m,b){b=b||1/0;for(var k,I=m.length,F=null,H=[],ne=0;ne<I;++ne){if(k=m.charCodeAt(ne),55295<k&&57344>k){if(!F){if(56319<k){-1<(b-=3)&&H.push(239,191,189);continue}else if(ne+1===I){-1<(b-=3)&&H.push(239,191,189);continue}F=k;continue}if(56320>k){-1<(b-=3)&&H.push(239,191,189),F=k;continue}k=(F-55296<<10|k-56320)+65536}else F&&-1<(b-=3)&&H.push(239,191,189);if(F=null,128>k){if(0>(b-=1))break;H.push(k)}else if(2048>k){if(0>(b-=2))break;H.push(192|k>>6,128|63&k)}else if(65536>k){if(0>(b-=3))break;H.push(224|k>>12,128|63&k>>6,128|63&k)}else if(1114112>k){if(0>(b-=4))break;H.push(240|k>>18,128|63&k>>12,128|63&k>>6,128|63&k)}else throw new Error("Invalid code point")}return H}function Ot(m){for(var b=[],k=0;k<m.length;++k)b.push(255&m.charCodeAt(k));return b}function xt(m,b){for(var k,I,F,H=[],ne=0;ne<m.length&&!(0>(b-=2));++ne)k=m.charCodeAt(ne),I=k>>8,F=k%256,H.push(F),H.push(I);return H}function it(m){return q.toByteArray(nt(m))}function at(m,b,k,I){for(var F=0;F<I&&!(F+k>=b.length||F>=m.length);++F)b[F+k]=m[F];return F}function $(m,b){return m instanceof b||m!=null&&m.constructor!=null&&m.constructor.name!=null&&m.constructor.name===b.name}function j(m){return m!==m}var q=s("base64-js"),te=s("ieee754");l.Buffer=d,l.SlowBuffer=function(m){return+m!=m&&(m=0),d.alloc(+m)},l.INSPECT_MAX_BYTES=50,l.kMaxLength=2147483647,d.TYPED_ARRAY_SUPPORT=function(){try{var m=new Uint8Array(1);return m.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},m.foo()===42}catch{return!1}}(),d.TYPED_ARRAY_SUPPORT||typeof console>"u"||typeof console.error!="function"||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(d.prototype,"parent",{enumerable:!0,get:function(){return d.isBuffer(this)?this.buffer:void 0}}),Object.defineProperty(d.prototype,"offset",{enumerable:!0,get:function(){return d.isBuffer(this)?this.byteOffset:void 0}}),typeof Symbol<"u"&&Symbol.species!=null&&d[Symbol.species]===d&&Object.defineProperty(d,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),d.poolSize=8192,d.from=function(m,b,k){return f(m,b,k)},d.prototype.__proto__=Uint8Array.prototype,d.__proto__=Uint8Array,d.alloc=function(m,b,k){return p(m,b,k)},d.allocUnsafe=function(m){return g(m)},d.allocUnsafeSlow=function(m){return g(m)},d.isBuffer=function(m){return m!=null&&m._isBuffer===!0&&m!==d.prototype},d.compare=function(m,b){if($(m,Uint8Array)&&(m=d.from(m,m.offset,m.byteLength)),$(b,Uint8Array)&&(b=d.from(b,b.offset,b.byteLength)),!d.isBuffer(m)||!d.isBuffer(b))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(m===b)return 0;for(var k=m.length,I=b.length,F=0,H=c(k,I);F<H;++F)if(m[F]!==b[F]){k=m[F],I=b[F];break}return k<I?-1:I<k?1:0},d.isEncoding=function(m){switch((m+"").toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},d.concat=function(m,b){if(!Array.isArray(m))throw new TypeError('"list" argument must be an Array of Buffers');if(m.length===0)return d.alloc(0);var k;if(b===void 0)for(b=0,k=0;k<m.length;++k)b+=m[k].length;var I=d.allocUnsafe(b),F=0;for(k=0;k<m.length;++k){var H=m[k];if($(H,Uint8Array)&&(H=d.from(H)),!d.isBuffer(H))throw new TypeError('"list" argument must be an Array of Buffers');H.copy(I,F),F+=H.length}return I},d.byteLength=C,d.prototype._isBuffer=!0,d.prototype.swap16=function(){var m=this.length;if(m%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var b=0;b<m;b+=2)T(this,b,b+1);return this},d.prototype.swap32=function(){var m=this.length;if(m%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var b=0;b<m;b+=4)T(this,b,b+3),T(this,b+1,b+2);return this},d.prototype.swap64=function(){var m=this.length;if(m%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var b=0;b<m;b+=8)T(this,b,b+7),T(this,b+1,b+6),T(this,b+2,b+5),T(this,b+3,b+4);return this},d.prototype.toString=function(){var m=this.length;return m===0?"":arguments.length===0?G(this,0,m):E.apply(this,arguments)},d.prototype.toLocaleString=d.prototype.toString,d.prototype.equals=function(m){if(!d.isBuffer(m))throw new TypeError("Argument must be a Buffer");return this===m||d.compare(this,m)===0},d.prototype.inspect=function(){var m="",b=l.INSPECT_MAX_BYTES;return m=this.toString("hex",0,b).replace(/(.{2})/g,"$1 ").trim(),this.length>b&&(m+=" ... "),"<Buffer "+m+">"},d.prototype.compare=function(m,b,k,I,F){if($(m,Uint8Array)&&(m=d.from(m,m.offset,m.byteLength)),!d.isBuffer(m))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof m);if(b===void 0&&(b=0),k===void 0&&(k=m?m.length:0),I===void 0&&(I=0),F===void 0&&(F=this.length),0>b||k>m.length||0>I||F>this.length)throw new RangeError("out of range index");if(I>=F&&b>=k)return 0;if(I>=F)return-1;if(b>=k)return 1;if(b>>>=0,k>>>=0,I>>>=0,F>>>=0,this===m)return 0;for(var H=F-I,ne=k-b,de=c(H,ne),_e=this.slice(I,F),we=m.slice(b,k),ye=0;ye<de;++ye)if(_e[ye]!==we[ye]){H=_e[ye],ne=we[ye];break}return H<ne?-1:ne<H?1:0},d.prototype.includes=function(m,b,k){return this.indexOf(m,b,k)!==-1},d.prototype.indexOf=function(m,b,k){return D(this,m,b,k,!0)},d.prototype.lastIndexOf=function(m,b,k){return D(this,m,b,k,!1)},d.prototype.write=function(m,b,k,I){if(b===void 0)I="utf8",k=this.length,b=0;else if(k===void 0&&typeof b=="string")I=b,k=this.length,b=0;else if(isFinite(b))b>>>=0,isFinite(k)?(k>>>=0,I===void 0&&(I="utf8")):(I=k,k=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var F=this.length-b;if((k===void 0||k>F)&&(k=F),0<m.length&&(0>k||0>b)||b>this.length)throw new RangeError("Attempt to write outside buffer bounds");I||(I="utf8");for(var H=!1;;)switch(I){case"hex":return A(this,m,b,k);case"utf8":case"utf-8":return R(this,m,b,k);case"ascii":return P(this,m,b,k);case"latin1":case"binary":return B(this,m,b,k);case"base64":return z(this,m,b,k);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,m,b,k);default:if(H)throw new TypeError("Unknown encoding: "+I);I=(""+I).toLowerCase(),H=!0}},d.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},d.prototype.slice=function(m,b){var k=this.length;m=~~m,b=b===void 0?k:~~b,0>m?(m+=k,0>m&&(m=0)):m>k&&(m=k),0>b?(b+=k,0>b&&(b=0)):b>k&&(b=k),b<m&&(b=m);var I=this.subarray(m,b);return I.__proto__=d.prototype,I},d.prototype.readUIntLE=function(m,b,k){m>>>=0,b>>>=0,k||Ee(m,b,this.length);for(var I=this[m],F=1,H=0;++H<b&&(F*=256);)I+=this[m+H]*F;return I},d.prototype.readUIntBE=function(m,b,k){m>>>=0,b>>>=0,k||Ee(m,b,this.length);for(var I=this[m+--b],F=1;0<b&&(F*=256);)I+=this[m+--b]*F;return I},d.prototype.readUInt8=function(m,b){return m>>>=0,b||Ee(m,1,this.length),this[m]},d.prototype.readUInt16LE=function(m,b){return m>>>=0,b||Ee(m,2,this.length),this[m]|this[m+1]<<8},d.prototype.readUInt16BE=function(m,b){return m>>>=0,b||Ee(m,2,this.length),this[m]<<8|this[m+1]},d.prototype.readUInt32LE=function(m,b){return m>>>=0,b||Ee(m,4,this.length),(this[m]|this[m+1]<<8|this[m+2]<<16)+16777216*this[m+3]},d.prototype.readUInt32BE=function(m,b){return m>>>=0,b||Ee(m,4,this.length),16777216*this[m]+(this[m+1]<<16|this[m+2]<<8|this[m+3])},d.prototype.readIntLE=function(m,b,k){m>>>=0,b>>>=0,k||Ee(m,b,this.length);for(var I=this[m],F=1,H=0;++H<b&&(F*=256);)I+=this[m+H]*F;return F*=128,I>=F&&(I-=i(2,8*b)),I},d.prototype.readIntBE=function(m,b,k){m>>>=0,b>>>=0,k||Ee(m,b,this.length);for(var I=b,F=1,H=this[m+--I];0<I&&(F*=256);)H+=this[m+--I]*F;return F*=128,H>=F&&(H-=i(2,8*b)),H},d.prototype.readInt8=function(m,b){return m>>>=0,b||Ee(m,1,this.length),128&this[m]?-1*(255-this[m]+1):this[m]},d.prototype.readInt16LE=function(m,b){m>>>=0,b||Ee(m,2,this.length);var k=this[m]|this[m+1]<<8;return 32768&k?4294901760|k:k},d.prototype.readInt16BE=function(m,b){m>>>=0,b||Ee(m,2,this.length);var k=this[m+1]|this[m]<<8;return 32768&k?4294901760|k:k},d.prototype.readInt32LE=function(m,b){return m>>>=0,b||Ee(m,4,this.length),this[m]|this[m+1]<<8|this[m+2]<<16|this[m+3]<<24},d.prototype.readInt32BE=function(m,b){return m>>>=0,b||Ee(m,4,this.length),this[m]<<24|this[m+1]<<16|this[m+2]<<8|this[m+3]},d.prototype.readFloatLE=function(m,b){return m>>>=0,b||Ee(m,4,this.length),te.read(this,m,!0,23,4)},d.prototype.readFloatBE=function(m,b){return m>>>=0,b||Ee(m,4,this.length),te.read(this,m,!1,23,4)},d.prototype.readDoubleLE=function(m,b){return m>>>=0,b||Ee(m,8,this.length),te.read(this,m,!0,52,8)},d.prototype.readDoubleBE=function(m,b){return m>>>=0,b||Ee(m,8,this.length),te.read(this,m,!1,52,8)},d.prototype.writeUIntLE=function(m,b,k,I){if(m=+m,b>>>=0,k>>>=0,!I){var F=i(2,8*k)-1;ve(this,m,b,k,F,0)}var H=1,ne=0;for(this[b]=255&m;++ne<k&&(H*=256);)this[b+ne]=255&m/H;return b+k},d.prototype.writeUIntBE=function(m,b,k,I){if(m=+m,b>>>=0,k>>>=0,!I){var F=i(2,8*k)-1;ve(this,m,b,k,F,0)}var H=k-1,ne=1;for(this[b+H]=255&m;0<=--H&&(ne*=256);)this[b+H]=255&m/ne;return b+k},d.prototype.writeUInt8=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,1,255,0),this[b]=255&m,b+1},d.prototype.writeUInt16LE=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,2,65535,0),this[b]=255&m,this[b+1]=m>>>8,b+2},d.prototype.writeUInt16BE=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,2,65535,0),this[b]=m>>>8,this[b+1]=255&m,b+2},d.prototype.writeUInt32LE=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,4,4294967295,0),this[b+3]=m>>>24,this[b+2]=m>>>16,this[b+1]=m>>>8,this[b]=255&m,b+4},d.prototype.writeUInt32BE=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,4,4294967295,0),this[b]=m>>>24,this[b+1]=m>>>16,this[b+2]=m>>>8,this[b+3]=255&m,b+4},d.prototype.writeIntLE=function(m,b,k,I){if(m=+m,b>>>=0,!I){var F=i(2,8*k-1);ve(this,m,b,k,F-1,-F)}var H=0,ne=1,de=0;for(this[b]=255&m;++H<k&&(ne*=256);)0>m&&de===0&&this[b+H-1]!==0&&(de=1),this[b+H]=255&(m/ne>>0)-de;return b+k},d.prototype.writeIntBE=function(m,b,k,I){if(m=+m,b>>>=0,!I){var F=i(2,8*k-1);ve(this,m,b,k,F-1,-F)}var H=k-1,ne=1,de=0;for(this[b+H]=255&m;0<=--H&&(ne*=256);)0>m&&de===0&&this[b+H+1]!==0&&(de=1),this[b+H]=255&(m/ne>>0)-de;return b+k},d.prototype.writeInt8=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,1,127,-128),0>m&&(m=255+m+1),this[b]=255&m,b+1},d.prototype.writeInt16LE=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,2,32767,-32768),this[b]=255&m,this[b+1]=m>>>8,b+2},d.prototype.writeInt16BE=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,2,32767,-32768),this[b]=m>>>8,this[b+1]=255&m,b+2},d.prototype.writeInt32LE=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,4,2147483647,-2147483648),this[b]=255&m,this[b+1]=m>>>8,this[b+2]=m>>>16,this[b+3]=m>>>24,b+4},d.prototype.writeInt32BE=function(m,b,k){return m=+m,b>>>=0,k||ve(this,m,b,4,2147483647,-2147483648),0>m&&(m=4294967295+m+1),this[b]=m>>>24,this[b+1]=m>>>16,this[b+2]=m>>>8,this[b+3]=255&m,b+4},d.prototype.writeFloatLE=function(m,b,k){return Ie(this,m,b,!0,k)},d.prototype.writeFloatBE=function(m,b,k){return Ie(this,m,b,!1,k)},d.prototype.writeDoubleLE=function(m,b,k){return tt(this,m,b,!0,k)},d.prototype.writeDoubleBE=function(m,b,k){return tt(this,m,b,!1,k)},d.prototype.copy=function(m,b,k,I){if(!d.isBuffer(m))throw new TypeError("argument should be a Buffer");if(k||(k=0),I||I===0||(I=this.length),b>=m.length&&(b=m.length),b||(b=0),0<I&&I<k&&(I=k),I===k||m.length===0||this.length===0)return 0;if(0>b)throw new RangeError("targetStart out of bounds");if(0>k||k>=this.length)throw new RangeError("Index out of range");if(0>I)throw new RangeError("sourceEnd out of bounds");I>this.length&&(I=this.length),m.length-b<I-k&&(I=m.length-b+k);var F=I-k;if(this===m&&typeof Uint8Array.prototype.copyWithin=="function")this.copyWithin(b,k,I);else if(this===m&&k<b&&b<I)for(var H=F-1;0<=H;--H)m[H+b]=this[H+k];else Uint8Array.prototype.set.call(m,this.subarray(k,I),b);return F},d.prototype.fill=function(m,b,k,I){if(typeof m=="string"){if(typeof b=="string"?(I=b,b=0,k=this.length):typeof k=="string"&&(I=k,k=this.length),I!==void 0&&typeof I!="string")throw new TypeError("encoding must be a string");if(typeof I=="string"&&!d.isEncoding(I))throw new TypeError("Unknown encoding: "+I);if(m.length===1){var F=m.charCodeAt(0);(I==="utf8"&&128>F||I==="latin1")&&(m=F)}}else typeof m=="number"&&(m&=255);if(0>b||this.length<b||this.length<k)throw new RangeError("Out of range index");if(k<=b)return this;b>>>=0,k=k===void 0?this.length:k>>>0,m||(m=0);var H;if(typeof m=="number")for(H=b;H<k;++H)this[H]=m;else{var ne=d.isBuffer(m)?m:d.from(m,I),de=ne.length;if(de===0)throw new TypeError('The value "'+m+'" is invalid for argument "value"');for(H=0;H<k-b;++H)this[H+b]=ne[H%de]}return this};var M=/[^+/0-9A-Za-z-_]/g}).call(this)}).call(this,s("buffer").Buffer)},{"base64-js":1,buffer:3,ieee754:9}],4:[function(s,o,l){(function(a){(function(){function c(){let d;try{d=l.storage.getItem("debug")}catch{}return!d&&typeof a<"u"&&"env"in a&&(d=a.env.DEBUG),d}l.formatArgs=function(d){if(d[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+d[0]+(this.useColors?"%c ":" ")+"+"+o.exports.humanize(this.diff),!this.useColors)return;const f="color: "+this.color;d.splice(1,0,f,"color: inherit");let h=0,p=0;d[0].replace(/%[a-zA-Z%]/g,g=>{g==="%%"||(h++,g==="%c"&&(p=h))}),d.splice(p,0,f)},l.save=function(d){try{d?l.storage.setItem("debug",d):l.storage.removeItem("debug")}catch{}},l.load=c,l.useColors=function(){return!!(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&31<=parseInt(RegExp.$1,10)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},l.storage=function(){try{return localStorage}catch{}}(),l.destroy=(()=>{let d=!1;return()=>{d||(d=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),l.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],l.log=console.debug||console.log||(()=>{}),o.exports=s("./common")(l);const{formatters:u}=o.exports;u.j=function(d){try{return JSON.stringify(d)}catch(f){return"[UnexpectedJSONParseError]: "+f.message}}}).call(this)}).call(this,s("_process"))},{"./common":5,_process:12}],5:[function(s,o){o.exports=function(l){function a(d){function f(...g){if(!f.enabled)return;const v=f,w=+new Date,S=w-(h||w);v.diff=S,v.prev=h,v.curr=w,h=w,g[0]=a.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let x=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(C,E)=>{if(C==="%%")return"%";x++;const T=a.formatters[E];if(typeof T=="function"){const D=g[x];C=T.call(v,D),g.splice(x,1),x--}return C}),a.formatArgs.call(v,g),(v.log||a.log).apply(v,g)}let h,p=null;return f.namespace=d,f.useColors=a.useColors(),f.color=a.selectColor(d),f.extend=c,f.destroy=a.destroy,Object.defineProperty(f,"enabled",{enumerable:!0,configurable:!1,get:()=>p===null?a.enabled(d):p,set:g=>{p=g}}),typeof a.init=="function"&&a.init(f),f}function c(d,f){const h=a(this.namespace+(typeof f>"u"?":":f)+d);return h.log=this.log,h}function u(d){return d.toString().substring(2,d.toString().length-2).replace(/\.\*\?$/,"*")}return a.debug=a,a.default=a,a.coerce=function(d){return d instanceof Error?d.stack||d.message:d},a.disable=function(){const d=[...a.names.map(u),...a.skips.map(u).map(f=>"-"+f)].join(",");return a.enable(""),d},a.enable=function(d){a.save(d),a.names=[],a.skips=[];let f;const h=(typeof d=="string"?d:"").split(/[\s,]+/),p=h.length;for(f=0;f<p;f++)h[f]&&(d=h[f].replace(/\*/g,".*?"),d[0]==="-"?a.skips.push(new RegExp("^"+d.substr(1)+"$")):a.names.push(new RegExp("^"+d+"$")))},a.enabled=function(d){if(d[d.length-1]==="*")return!0;let f,h;for(f=0,h=a.skips.length;f<h;f++)if(a.skips[f].test(d))return!1;for(f=0,h=a.names.length;f<h;f++)if(a.names[f].test(d))return!0;return!1},a.humanize=s("ms"),a.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(l).forEach(d=>{a[d]=l[d]}),a.names=[],a.skips=[],a.formatters={},a.selectColor=function(d){let f=0;for(let h=0;h<d.length;h++)f=(f<<5)-f+d.charCodeAt(h),f|=0;return a.colors[r(f)%a.colors.length]},a.enable(a.load()),a}},{ms:11}],6:[function(s,o){function l(a,c){for(const u in c)Object.defineProperty(a,u,{value:c[u],enumerable:!0,configurable:!0});return a}o.exports=function(a,c,u){if(!a||typeof a=="string")throw new TypeError("Please pass an Error to err-code");u||(u={}),typeof c=="object"&&(u=c,c=""),c&&(u.code=c);try{return l(a,u)}catch{u.message=a.message,u.stack=a.stack;const f=function(){};return f.prototype=Object.create(Object.getPrototypeOf(a)),l(new f,u)}}},{}],7:[function(s,o){function l(A){console&&console.warn&&console.warn(A)}function a(){a.init.call(this)}function c(A){if(typeof A!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof A)}function u(A){return A._maxListeners===void 0?a.defaultMaxListeners:A._maxListeners}function d(A,R,P,B){var z,U,J;if(c(P),U=A._events,U===void 0?(U=A._events=Object.create(null),A._eventsCount=0):(U.newListener!==void 0&&(A.emit("newListener",R,P.listener?P.listener:P),U=A._events),J=U[R]),J===void 0)J=U[R]=P,++A._eventsCount;else if(typeof J=="function"?J=U[R]=B?[P,J]:[J,P]:B?J.unshift(P):J.push(P),z=u(A),0<z&&J.length>z&&!J.warned){J.warned=!0;var G=new Error("Possible EventEmitter memory leak detected. "+J.length+" "+(R+" listeners added. Use emitter.setMaxListeners() to increase limit"));G.name="MaxListenersExceededWarning",G.emitter=A,G.type=R,G.count=J.length,l(G)}return A}function f(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(A,R,P){var B={fired:!1,wrapFn:void 0,target:A,type:R,listener:P},z=f.bind(B);return z.listener=P,B.wrapFn=z,z}function p(A,R,P){var B=A._events;if(B===void 0)return[];var z=B[R];return z===void 0?[]:typeof z=="function"?P?[z.listener||z]:[z]:P?S(z):v(z,z.length)}function g(A){var R=this._events;if(R!==void 0){var P=R[A];if(typeof P=="function")return 1;if(P!==void 0)return P.length}return 0}function v(A,R){for(var P=Array(R),B=0;B<R;++B)P[B]=A[B];return P}function w(A,R){for(;R+1<A.length;R++)A[R]=A[R+1];A.pop()}function S(A){for(var R=Array(A.length),P=0;P<R.length;++P)R[P]=A[P].listener||A[P];return R}function x(A,R,P){typeof A.on=="function"&&y(A,"error",R,P)}function y(A,R,P,B){if(typeof A.on=="function")B.once?A.once(R,P):A.on(R,P);else if(typeof A.addEventListener=="function")A.addEventListener(R,function z(U){B.once&&A.removeEventListener(R,z),P(U)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof A)}var C,E=typeof Reflect=="object"?Reflect:null,T=E&&typeof E.apply=="function"?E.apply:function(A,R,P){return Function.prototype.apply.call(A,R,P)};C=E&&typeof E.ownKeys=="function"?E.ownKeys:Object.getOwnPropertySymbols?function(A){return Object.getOwnPropertyNames(A).concat(Object.getOwnPropertySymbols(A))}:function(A){return Object.getOwnPropertyNames(A)};var D=Number.isNaN||function(A){return A!==A};o.exports=a,o.exports.once=function(A,R){return new Promise(function(P,B){function z(J){A.removeListener(R,U),B(J)}function U(){typeof A.removeListener=="function"&&A.removeListener("error",z),P([].slice.call(arguments))}y(A,R,U,{once:!0}),R!=="error"&&x(A,z,{once:!0})})},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var N=10;Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return N},set:function(A){if(typeof A!="number"||0>A||D(A))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+A+".");N=A}}),a.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(A){if(typeof A!="number"||0>A||D(A))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+A+".");return this._maxListeners=A,this},a.prototype.getMaxListeners=function(){return u(this)},a.prototype.emit=function(A){for(var R=[],P=1;P<arguments.length;P++)R.push(arguments[P]);var B=A==="error",z=this._events;if(z!==void 0)B=B&&z.error===void 0;else if(!B)return!1;if(B){var U;if(0<R.length&&(U=R[0]),U instanceof Error)throw U;var J=new Error("Unhandled error."+(U?" ("+U.message+")":""));throw J.context=U,J}var G=z[A];if(G===void 0)return!1;if(typeof G=="function")T(G,this,R);else for(var ie=G.length,Z=v(G,ie),P=0;P<ie;++P)T(Z[P],this,R);return!0},a.prototype.addListener=function(A,R){return d(this,A,R,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(A,R){return d(this,A,R,!0)},a.prototype.once=function(A,R){return c(R),this.on(A,h(this,A,R)),this},a.prototype.prependOnceListener=function(A,R){return c(R),this.prependListener(A,h(this,A,R)),this},a.prototype.removeListener=function(A,R){var P,B,z,U,J;if(c(R),B=this._events,B===void 0)return this;if(P=B[A],P===void 0)return this;if(P===R||P.listener===R)--this._eventsCount==0?this._events=Object.create(null):(delete B[A],B.removeListener&&this.emit("removeListener",A,P.listener||R));else if(typeof P!="function"){for(z=-1,U=P.length-1;0<=U;U--)if(P[U]===R||P[U].listener===R){J=P[U].listener,z=U;break}if(0>z)return this;z===0?P.shift():w(P,z),P.length===1&&(B[A]=P[0]),B.removeListener!==void 0&&this.emit("removeListener",A,J||R)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(A){var R,P,B;if(P=this._events,P===void 0)return this;if(P.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):P[A]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete P[A]),this;if(arguments.length===0){var z,U=Object.keys(P);for(B=0;B<U.length;++B)z=U[B],z!=="removeListener"&&this.removeAllListeners(z);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(R=P[A],typeof R=="function")this.removeListener(A,R);else if(R!==void 0)for(B=R.length-1;0<=B;B--)this.removeListener(A,R[B]);return this},a.prototype.listeners=function(A){return p(this,A,!0)},a.prototype.rawListeners=function(A){return p(this,A,!1)},a.listenerCount=function(A,R){return typeof A.listenerCount=="function"?A.listenerCount(R):g.call(A,R)},a.prototype.listenerCount=g,a.prototype.eventNames=function(){return 0<this._eventsCount?C(this._events):[]}},{}],8:[function(s,o){o.exports=function(){if(typeof globalThis>"u")return null;var l={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return l.RTCPeerConnection?l:null}},{}],9:[function(s,o,l){/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */l.read=function(a,c,u,d,f){var h,p,g=8*f-d-1,v=(1<<g)-1,w=v>>1,S=-7,x=u?f-1:0,y=u?-1:1,C=a[c+x];for(x+=y,h=C&(1<<-S)-1,C>>=-S,S+=g;0<S;h=256*h+a[c+x],x+=y,S-=8);for(p=h&(1<<-S)-1,h>>=-S,S+=d;0<S;p=256*p+a[c+x],x+=y,S-=8);if(h===0)h=1-w;else{if(h===v)return p?NaN:(C?-1:1)*(1/0);p+=i(2,d),h-=w}return(C?-1:1)*p*i(2,h-d)},l.write=function(a,c,u,d,f,h){var p,g,v,w=Math.LN2,S=Math.log,x=8*h-f-1,y=(1<<x)-1,C=y>>1,E=f===23?i(2,-24)-i(2,-77):0,T=d?0:h-1,D=d?1:-1,N=0>c||c===0&&0>1/c?1:0;for(c=r(c),isNaN(c)||c===1/0?(g=isNaN(c)?1:0,p=y):(p=n(S(c)/w),1>c*(v=i(2,-p))&&(p--,v*=2),c+=1<=p+C?E/v:E*i(2,1-C),2<=c*v&&(p++,v/=2),p+C>=y?(g=0,p=y):1<=p+C?(g=(c*v-1)*i(2,f),p+=C):(g=c*i(2,C-1)*i(2,f),p=0));8<=f;a[u+T]=255&g,T+=D,g/=256,f-=8);for(p=p<<f|g,x+=f;0<x;a[u+T]=255&p,T+=D,p/=256,x-=8);a[u+T-D]|=128*N}},{}],10:[function(s,o){o.exports=typeof Object.create=="function"?function(l,a){a&&(l.super_=a,l.prototype=Object.create(a.prototype,{constructor:{value:l,enumerable:!1,writable:!0,configurable:!0}}))}:function(l,a){if(a){l.super_=a;var c=function(){};c.prototype=a.prototype,l.prototype=new c,l.prototype.constructor=l}}},{}],11:[function(s,o){var l=Math.round;function a(f){if(f+="",!(100<f.length)){var h=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(f);if(h){var p=parseFloat(h[1]),g=(h[2]||"ms").toLowerCase();return g==="years"||g==="year"||g==="yrs"||g==="yr"||g==="y"?315576e5*p:g==="weeks"||g==="week"||g==="w"?6048e5*p:g==="days"||g==="day"||g==="d"?864e5*p:g==="hours"||g==="hour"||g==="hrs"||g==="hr"||g==="h"?36e5*p:g==="minutes"||g==="minute"||g==="mins"||g==="min"||g==="m"?6e4*p:g==="seconds"||g==="second"||g==="secs"||g==="sec"||g==="s"?1e3*p:g==="milliseconds"||g==="millisecond"||g==="msecs"||g==="msec"||g==="ms"?p:void 0}}}function c(f){var h=r(f);return 864e5<=h?l(f/864e5)+"d":36e5<=h?l(f/36e5)+"h":6e4<=h?l(f/6e4)+"m":1e3<=h?l(f/1e3)+"s":f+"ms"}function u(f){var h=r(f);return 864e5<=h?d(f,h,864e5,"day"):36e5<=h?d(f,h,36e5,"hour"):6e4<=h?d(f,h,6e4,"minute"):1e3<=h?d(f,h,1e3,"second"):f+" ms"}function d(f,h,p,g){return l(f/p)+" "+g+(h>=1.5*p?"s":"")}o.exports=function(f,h){h=h||{};var p=typeof f;if(p=="string"&&0<f.length)return a(f);if(p==="number"&&isFinite(f))return h.long?u(f):c(f);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(f))}},{}],12:[function(s,o){function l(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function c(E){if(g===setTimeout)return setTimeout(E,0);if((g===l||!g)&&setTimeout)return g=setTimeout,setTimeout(E,0);try{return g(E,0)}catch{try{return g.call(null,E,0)}catch{return g.call(this,E,0)}}}function u(E){if(v===clearTimeout)return clearTimeout(E);if((v===a||!v)&&clearTimeout)return v=clearTimeout,clearTimeout(E);try{return v(E)}catch{try{return v.call(null,E)}catch{return v.call(this,E)}}}function d(){y&&S&&(y=!1,S.length?x=S.concat(x):C=-1,x.length&&f())}function f(){if(!y){var E=c(d);y=!0;for(var T=x.length;T;){for(S=x,x=[];++C<T;)S&&S[C].run();C=-1,T=x.length}S=null,y=!1,u(E)}}function h(E,T){this.fun=E,this.array=T}function p(){}var g,v,w=o.exports={};(function(){try{g=typeof setTimeout=="function"?setTimeout:l}catch{g=l}try{v=typeof clearTimeout=="function"?clearTimeout:a}catch{v=a}})();var S,x=[],y=!1,C=-1;w.nextTick=function(E){var T=Array(arguments.length-1);if(1<arguments.length)for(var D=1;D<arguments.length;D++)T[D-1]=arguments[D];x.push(new h(E,T)),x.length!==1||y||c(f)},h.prototype.run=function(){this.fun.apply(null,this.array)},w.title="browser",w.browser=!0,w.env={},w.argv=[],w.version="",w.versions={},w.on=p,w.addListener=p,w.once=p,w.off=p,w.removeListener=p,w.removeAllListeners=p,w.emit=p,w.prependListener=p,w.prependOnceListener=p,w.listeners=function(){return[]},w.binding=function(){throw new Error("process.binding is not supported")},w.cwd=function(){return"/"},w.chdir=function(){throw new Error("process.chdir is not supported")},w.umask=function(){return 0}},{}],13:[function(s,o){(function(l){(function(){/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */let a;o.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window>"u"?l:window):c=>(a||(a=Promise.resolve())).then(c).catch(u=>setTimeout(()=>{throw u},0))}).call(this)}).call(this,typeof _n>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:_n)},{}],14:[function(s,o){(function(l,a){(function(){var c=s("safe-buffer").Buffer,u=a.crypto||a.msCrypto;o.exports=u&&u.getRandomValues?function(d,f){if(d>4294967295)throw new RangeError("requested too many random bytes");var h=c.allocUnsafe(d);if(0<d)if(65536<d)for(var p=0;p<d;p+=65536)u.getRandomValues(h.slice(p,p+65536));else u.getRandomValues(h);return typeof f=="function"?l.nextTick(function(){f(null,h)}):h}:function(){throw new Error(`Secure random number generation is not supported by this browser.
|
375
|
+
Use Chrome, Firefox or Internet Explorer 11`)}}).call(this)}).call(this,s("_process"),typeof _n>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:_n)},{_process:12,"safe-buffer":30}],15:[function(s,o){function l(p,g){p.prototype=Object.create(g.prototype),p.prototype.constructor=p,p.__proto__=g}function a(p,g,v){function w(x,y,C){return typeof g=="string"?g:g(x,y,C)}v||(v=Error);var S=function(x){function y(C,E,T){return x.call(this,w(C,E,T))||this}return l(y,x),y}(v);S.prototype.name=v.name,S.prototype.code=p,h[p]=S}function c(p,g){if(Array.isArray(p)){var v=p.length;return p=p.map(function(w){return w+""}),2<v?"one of ".concat(g," ").concat(p.slice(0,v-1).join(", "),", or ")+p[v-1]:v===2?"one of ".concat(g," ").concat(p[0]," or ").concat(p[1]):"of ".concat(g," ").concat(p[0])}return"of ".concat(g," ").concat(p+"")}function u(p,g,v){return p.substr(0,g.length)===g}function d(p,g,v){return(v===void 0||v>p.length)&&(v=p.length),p.substring(v-g.length,v)===g}function f(p,g,v){return typeof v!="number"&&(v=0),!(v+g.length>p.length)&&p.indexOf(g,v)!==-1}var h={};a("ERR_INVALID_OPT_VALUE",function(p,g){return'The value "'+g+'" is invalid for option "'+p+'"'},TypeError),a("ERR_INVALID_ARG_TYPE",function(p,g,v){var w;typeof g=="string"&&u(g,"not ")?(w="must not be",g=g.replace(/^not /,"")):w="must be";var S;if(d(p," argument"))S="The ".concat(p," ").concat(w," ").concat(c(g,"type"));else{var x=f(p,".")?"property":"argument";S='The "'.concat(p,'" ').concat(x," ").concat(w," ").concat(c(g,"type"))}return S+=". Received type ".concat(typeof v),S},TypeError),a("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),a("ERR_METHOD_NOT_IMPLEMENTED",function(p){return"The "+p+" method is not implemented"}),a("ERR_STREAM_PREMATURE_CLOSE","Premature close"),a("ERR_STREAM_DESTROYED",function(p){return"Cannot call "+p+" after a stream was destroyed"}),a("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),a("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),a("ERR_STREAM_WRITE_AFTER_END","write after end"),a("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),a("ERR_UNKNOWN_ENCODING",function(p){return"Unknown encoding: "+p},TypeError),a("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),o.exports.codes=h},{}],16:[function(s,o){(function(l){(function(){function a(w){return this instanceof a?(f.call(this,w),h.call(this,w),this.allowHalfOpen=!0,void(w&&(w.readable===!1&&(this.readable=!1),w.writable===!1&&(this.writable=!1),w.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",c))))):new a(w)}function c(){this._writableState.ended||l.nextTick(u,this)}function u(w){w.end()}var d=Object.keys||function(w){var S=[];for(var x in w)S.push(x);return S};o.exports=a;var f=s("./_stream_readable"),h=s("./_stream_writable");s("inherits")(a,f);for(var p,g=d(h.prototype),v=0;v<g.length;v++)p=g[v],a.prototype[p]||(a.prototype[p]=h.prototype[p]);Object.defineProperty(a.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(a.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(a.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(a.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(w){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=w,this._writableState.destroyed=w)}})}).call(this)}).call(this,s("_process"))},{"./_stream_readable":18,"./_stream_writable":20,_process:12,inherits:10}],17:[function(s,o){function l(c){return this instanceof l?void a.call(this,c):new l(c)}o.exports=l;var a=s("./_stream_transform");s("inherits")(l,a),l.prototype._transform=function(c,u,d){d(null,c)}},{"./_stream_transform":19,inherits:10}],18:[function(s,o){(function(l,a){(function(){function c(M){return $e.from(M)}function u(M){return $e.isBuffer(M)||M instanceof Ee}function d(M,m,b){return typeof M.prependListener=="function"?M.prependListener(m,b):void(M._events&&M._events[m]?Array.isArray(M._events[m])?M._events[m].unshift(b):M._events[m]=[b,M._events[m]]:M.on(m,b))}function f(M,m,b){ie=ie||s("./_stream_duplex"),M=M||{},typeof b!="boolean"&&(b=m instanceof ie),this.objectMode=!!M.objectMode,b&&(this.objectMode=this.objectMode||!!M.readableObjectMode),this.highWaterMark=Ot(this,M,"readableHighWaterMark",b),this.buffer=new nt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=M.emitClose!==!1,this.autoDestroy=!!M.autoDestroy,this.destroyed=!1,this.defaultEncoding=M.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,M.encoding&&(!De&&(De=s("string_decoder/").StringDecoder),this.decoder=new De(M.encoding),this.encoding=M.encoding)}function h(M){if(ie=ie||s("./_stream_duplex"),!(this instanceof h))return new h(M);var m=this instanceof ie;this._readableState=new f(M,this,m),this.readable=!0,M&&(typeof M.read=="function"&&(this._read=M.read),typeof M.destroy=="function"&&(this._destroy=M.destroy)),Le.call(this)}function p(M,m,b,k,I){Z("readableAddChunk",m);var F=M._readableState;if(m===null)F.reading=!1,x(M,F);else{var H;if(I||(H=v(F,m)),H)q(M,H);else if(!(F.objectMode||m&&0<m.length))k||(F.reading=!1,E(M,F));else if(typeof m=="string"||F.objectMode||Object.getPrototypeOf(m)===$e.prototype||(m=c(m)),k)F.endEmitted?q(M,new j):g(M,F,m,!0);else if(F.ended)q(M,new at);else{if(F.destroyed)return!1;F.reading=!1,F.decoder&&!b?(m=F.decoder.write(m),F.objectMode||m.length!==0?g(M,F,m,!1):E(M,F)):g(M,F,m,!1)}}return!F.ended&&(F.length<F.highWaterMark||F.length===0)}function g(M,m,b,k){m.flowing&&m.length===0&&!m.sync?(m.awaitDrain=0,M.emit("data",b)):(m.length+=m.objectMode?1:b.length,k?m.buffer.unshift(b):m.buffer.push(b),m.needReadable&&y(M)),E(M,m)}function v(M,m){var b;return u(m)||typeof m=="string"||m===void 0||M.objectMode||(b=new it("chunk",["string","Buffer","Uint8Array"],m)),b}function w(M){return 1073741824<=M?M=1073741824:(M--,M|=M>>>1,M|=M>>>2,M|=M>>>4,M|=M>>>8,M|=M>>>16,M++),M}function S(M,m){return 0>=M||m.length===0&&m.ended?0:m.objectMode?1:M===M?(M>m.highWaterMark&&(m.highWaterMark=w(M)),M<=m.length?M:m.ended?m.length:(m.needReadable=!0,0)):m.flowing&&m.length?m.buffer.head.data.length:m.length}function x(M,m){if(Z("onEofChunk"),!m.ended){if(m.decoder){var b=m.decoder.end();b&&b.length&&(m.buffer.push(b),m.length+=m.objectMode?1:b.length)}m.ended=!0,m.sync?y(M):(m.needReadable=!1,!m.emittedReadable&&(m.emittedReadable=!0,C(M)))}}function y(M){var m=M._readableState;Z("emitReadable",m.needReadable,m.emittedReadable),m.needReadable=!1,m.emittedReadable||(Z("emitReadable",m.flowing),m.emittedReadable=!0,l.nextTick(C,M))}function C(M){var m=M._readableState;Z("emitReadable_",m.destroyed,m.length,m.ended),!m.destroyed&&(m.length||m.ended)&&(M.emit("readable"),m.emittedReadable=!1),m.needReadable=!m.flowing&&!m.ended&&m.length<=m.highWaterMark,B(M)}function E(M,m){m.readingMore||(m.readingMore=!0,l.nextTick(T,M,m))}function T(M,m){for(;!m.reading&&!m.ended&&(m.length<m.highWaterMark||m.flowing&&m.length===0);){var b=m.length;if(Z("maybeReadMore read 0"),M.read(0),b===m.length)break}m.readingMore=!1}function D(M){return function(){var m=M._readableState;Z("pipeOnDrain",m.awaitDrain),m.awaitDrain&&m.awaitDrain--,m.awaitDrain===0&&ke(M,"data")&&(m.flowing=!0,B(M))}}function N(M){var m=M._readableState;m.readableListening=0<M.listenerCount("readable"),m.resumeScheduled&&!m.paused?m.flowing=!0:0<M.listenerCount("data")&&M.resume()}function A(M){Z("readable nexttick read 0"),M.read(0)}function R(M,m){m.resumeScheduled||(m.resumeScheduled=!0,l.nextTick(P,M,m))}function P(M,m){Z("resume",m.reading),m.reading||M.read(0),m.resumeScheduled=!1,M.emit("resume"),B(M),m.flowing&&!m.reading&&M.read(0)}function B(M){var m=M._readableState;for(Z("flow",m.flowing);m.flowing&&M.read()!==null;);}function z(M,m){if(m.length===0)return null;var b;return m.objectMode?b=m.buffer.shift():!M||M>=m.length?(b=m.decoder?m.buffer.join(""):m.buffer.length===1?m.buffer.first():m.buffer.concat(m.length),m.buffer.clear()):b=m.buffer.consume(M,m.decoder),b}function U(M){var m=M._readableState;Z("endReadable",m.endEmitted),m.endEmitted||(m.ended=!0,l.nextTick(J,m,M))}function J(M,m){if(Z("endReadableNT",M.endEmitted,M.length),!M.endEmitted&&M.length===0&&(M.endEmitted=!0,m.readable=!1,m.emit("end"),M.autoDestroy)){var b=m._writableState;(!b||b.autoDestroy&&b.finished)&&m.destroy()}}function G(M,m){for(var b=0,k=M.length;b<k;b++)if(M[b]===m)return b;return-1}o.exports=h;var ie;h.ReadableState=f;var Z;s("events").EventEmitter;var ke=function(M,m){return M.listeners(m).length},Le=s("./internal/streams/stream"),$e=s("buffer").Buffer,Ee=a.Uint8Array||function(){},ve=s("util");Z=ve&&ve.debuglog?ve.debuglog("stream"):function(){};var De,Ie,tt,nt=s("./internal/streams/buffer_list"),Ge=s("./internal/streams/destroy"),Ye=s("./internal/streams/state"),Ot=Ye.getHighWaterMark,xt=s("../errors").codes,it=xt.ERR_INVALID_ARG_TYPE,at=xt.ERR_STREAM_PUSH_AFTER_EOF,$=xt.ERR_METHOD_NOT_IMPLEMENTED,j=xt.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;s("inherits")(h,Le);var q=Ge.errorOrDestroy,te=["error","close","destroy","pause","resume"];Object.defineProperty(h.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._readableState.destroyed},set:function(M){this._readableState&&(this._readableState.destroyed=M)}}),h.prototype.destroy=Ge.destroy,h.prototype._undestroy=Ge.undestroy,h.prototype._destroy=function(M,m){m(M)},h.prototype.push=function(M,m){var b,k=this._readableState;return k.objectMode?b=!0:typeof M=="string"&&(m=m||k.defaultEncoding,m!==k.encoding&&(M=$e.from(M,m),m=""),b=!0),p(this,M,m,!1,b)},h.prototype.unshift=function(M){return p(this,M,null,!0,!1)},h.prototype.isPaused=function(){return this._readableState.flowing===!1},h.prototype.setEncoding=function(M){De||(De=s("string_decoder/").StringDecoder);var m=new De(M);this._readableState.decoder=m,this._readableState.encoding=this._readableState.decoder.encoding;for(var b=this._readableState.buffer.head,k="";b!==null;)k+=m.write(b.data),b=b.next;return this._readableState.buffer.clear(),k!==""&&this._readableState.buffer.push(k),this._readableState.length=k.length,this},h.prototype.read=function(M){Z("read",M),M=parseInt(M,10);var m=this._readableState,b=M;if(M!==0&&(m.emittedReadable=!1),M===0&&m.needReadable&&((m.highWaterMark===0?0<m.length:m.length>=m.highWaterMark)||m.ended))return Z("read: emitReadable",m.length,m.ended),m.length===0&&m.ended?U(this):y(this),null;if(M=S(M,m),M===0&&m.ended)return m.length===0&&U(this),null;var k=m.needReadable;Z("need readable",k),(m.length===0||m.length-M<m.highWaterMark)&&(k=!0,Z("length less than watermark",k)),m.ended||m.reading?(k=!1,Z("reading or ended",k)):k&&(Z("do read"),m.reading=!0,m.sync=!0,m.length===0&&(m.needReadable=!0),this._read(m.highWaterMark),m.sync=!1,!m.reading&&(M=S(b,m)));var I;return I=0<M?z(M,m):null,I===null?(m.needReadable=m.length<=m.highWaterMark,M=0):(m.length-=M,m.awaitDrain=0),m.length===0&&(!m.ended&&(m.needReadable=!0),b!==M&&m.ended&&U(this)),I!==null&&this.emit("data",I),I},h.prototype._read=function(){q(this,new $("_read()"))},h.prototype.pipe=function(M,m){function b(ee,oe){Z("onunpipe"),ee===we&&oe&&oe.hasUnpiped===!1&&(oe.hasUnpiped=!0,I())}function k(){Z("onend"),M.end()}function I(){Z("cleanup"),M.removeListener("close",ne),M.removeListener("finish",de),M.removeListener("drain",Qn),M.removeListener("error",H),M.removeListener("unpipe",b),we.removeListener("end",k),we.removeListener("end",_e),we.removeListener("data",F),V=!0,ye.awaitDrain&&(!M._writableState||M._writableState.needDrain)&&Qn()}function F(ee){Z("ondata");var oe=M.write(ee);Z("dest.write",oe),oe===!1&&((ye.pipesCount===1&&ye.pipes===M||1<ye.pipesCount&&G(ye.pipes,M)!==-1)&&!V&&(Z("false write response, pause",ye.awaitDrain),ye.awaitDrain++),we.pause())}function H(ee){Z("onerror",ee),_e(),M.removeListener("error",H),ke(M,"error")===0&&q(M,ee)}function ne(){M.removeListener("finish",de),_e()}function de(){Z("onfinish"),M.removeListener("close",ne),_e()}function _e(){Z("unpipe"),we.unpipe(M)}var we=this,ye=this._readableState;switch(ye.pipesCount){case 0:ye.pipes=M;break;case 1:ye.pipes=[ye.pipes,M];break;default:ye.pipes.push(M)}ye.pipesCount+=1,Z("pipe count=%d opts=%j",ye.pipesCount,m);var Xe=(!m||m.end!==!1)&&M!==l.stdout&&M!==l.stderr,Mn=Xe?k:_e;ye.endEmitted?l.nextTick(Mn):we.once("end",Mn),M.on("unpipe",b);var Qn=D(we);M.on("drain",Qn);var V=!1;return we.on("data",F),d(M,"error",H),M.once("close",ne),M.once("finish",de),M.emit("pipe",we),ye.flowing||(Z("pipe resume"),we.resume()),M},h.prototype.unpipe=function(M){var m=this._readableState,b={hasUnpiped:!1};if(m.pipesCount===0)return this;if(m.pipesCount===1)return M&&M!==m.pipes?this:(M||(M=m.pipes),m.pipes=null,m.pipesCount=0,m.flowing=!1,M&&M.emit("unpipe",this,b),this);if(!M){var k=m.pipes,I=m.pipesCount;m.pipes=null,m.pipesCount=0,m.flowing=!1;for(var F=0;F<I;F++)k[F].emit("unpipe",this,{hasUnpiped:!1});return this}var H=G(m.pipes,M);return H===-1?this:(m.pipes.splice(H,1),m.pipesCount-=1,m.pipesCount===1&&(m.pipes=m.pipes[0]),M.emit("unpipe",this,b),this)},h.prototype.on=function(M,m){var b=Le.prototype.on.call(this,M,m),k=this._readableState;return M==="data"?(k.readableListening=0<this.listenerCount("readable"),k.flowing!==!1&&this.resume()):M=="readable"&&!k.endEmitted&&!k.readableListening&&(k.readableListening=k.needReadable=!0,k.flowing=!1,k.emittedReadable=!1,Z("on readable",k.length,k.reading),k.length?y(this):!k.reading&&l.nextTick(A,this)),b},h.prototype.addListener=h.prototype.on,h.prototype.removeListener=function(M,m){var b=Le.prototype.removeListener.call(this,M,m);return M==="readable"&&l.nextTick(N,this),b},h.prototype.removeAllListeners=function(M){var m=Le.prototype.removeAllListeners.apply(this,arguments);return(M==="readable"||M===void 0)&&l.nextTick(N,this),m},h.prototype.resume=function(){var M=this._readableState;return M.flowing||(Z("resume"),M.flowing=!M.readableListening,R(this,M)),M.paused=!1,this},h.prototype.pause=function(){return Z("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Z("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},h.prototype.wrap=function(M){var m=this,b=this._readableState,k=!1;for(var I in M.on("end",function(){if(Z("wrapped end"),b.decoder&&!b.ended){var H=b.decoder.end();H&&H.length&&m.push(H)}m.push(null)}),M.on("data",function(H){if(Z("wrapped data"),b.decoder&&(H=b.decoder.write(H)),!(b.objectMode&&H==null)&&(b.objectMode||H&&H.length)){var ne=m.push(H);ne||(k=!0,M.pause())}}),M)this[I]===void 0&&typeof M[I]=="function"&&(this[I]=function(H){return function(){return M[H].apply(M,arguments)}}(I));for(var F=0;F<te.length;F++)M.on(te[F],this.emit.bind(this,te[F]));return this._read=function(H){Z("wrapped _read",H),k&&(k=!1,M.resume())},this},typeof Symbol=="function"&&(h.prototype[Symbol.asyncIterator]=function(){return Ie===void 0&&(Ie=s("./internal/streams/async_iterator")),Ie(this)}),Object.defineProperty(h.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(h.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(h.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(M){this._readableState&&(this._readableState.flowing=M)}}),h._fromList=z,Object.defineProperty(h.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),typeof Symbol=="function"&&(h.from=function(M,m){return tt===void 0&&(tt=s("./internal/streams/from")),tt(h,M,m)})}).call(this)}).call(this,s("_process"),typeof _n>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:_n)},{"../errors":15,"./_stream_duplex":16,"./internal/streams/async_iterator":21,"./internal/streams/buffer_list":22,"./internal/streams/destroy":23,"./internal/streams/from":25,"./internal/streams/state":27,"./internal/streams/stream":28,_process:12,buffer:3,events:7,inherits:10,"string_decoder/":31,util:2}],19:[function(s,o){function l(w,S){var x=this._transformState;x.transforming=!1;var y=x.writecb;if(y===null)return this.emit("error",new h);x.writechunk=null,x.writecb=null,S!=null&&this.push(S),y(w);var C=this._readableState;C.reading=!1,(C.needReadable||C.length<C.highWaterMark)&&this._read(C.highWaterMark)}function a(w){return this instanceof a?(v.call(this,w),this._transformState={afterTransform:l.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,w&&(typeof w.transform=="function"&&(this._transform=w.transform),typeof w.flush=="function"&&(this._flush=w.flush)),void this.on("prefinish",c)):new a(w)}function c(){var w=this;typeof this._flush!="function"||this._readableState.destroyed?u(this,null,null):this._flush(function(S,x){u(w,S,x)})}function u(w,S,x){if(S)return w.emit("error",S);if(x!=null&&w.push(x),w._writableState.length)throw new g;if(w._transformState.transforming)throw new p;return w.push(null)}o.exports=a;var d=s("../errors").codes,f=d.ERR_METHOD_NOT_IMPLEMENTED,h=d.ERR_MULTIPLE_CALLBACK,p=d.ERR_TRANSFORM_ALREADY_TRANSFORMING,g=d.ERR_TRANSFORM_WITH_LENGTH_0,v=s("./_stream_duplex");s("inherits")(a,v),a.prototype.push=function(w,S){return this._transformState.needTransform=!1,v.prototype.push.call(this,w,S)},a.prototype._transform=function(w,S,x){x(new f("_transform()"))},a.prototype._write=function(w,S,x){var y=this._transformState;if(y.writecb=x,y.writechunk=w,y.writeencoding=S,!y.transforming){var C=this._readableState;(y.needTransform||C.needReadable||C.length<C.highWaterMark)&&this._read(C.highWaterMark)}},a.prototype._read=function(){var w=this._transformState;w.writechunk===null||w.transforming?w.needTransform=!0:(w.transforming=!0,this._transform(w.writechunk,w.writeencoding,w.afterTransform))},a.prototype._destroy=function(w,S){v.prototype._destroy.call(this,w,function(x){S(x)})}},{"../errors":15,"./_stream_duplex":16,inherits:10}],20:[function(s,o){(function(l,a){(function(){function c($){var j=this;this.next=null,this.entry=null,this.finish=function(){U(j,$)}}function u($){return Z.from($)}function d($){return Z.isBuffer($)||$ instanceof ke}function f(){}function h($,j,q){J=J||s("./_stream_duplex"),$=$||{},typeof q!="boolean"&&(q=j instanceof J),this.objectMode=!!$.objectMode,q&&(this.objectMode=this.objectMode||!!$.writableObjectMode),this.highWaterMark=Ee(this,$,"writableHighWaterMark",q),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var te=$.decodeStrings===!1;this.decodeStrings=!te,this.defaultEncoding=$.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(M){E(j,M)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=$.emitClose!==!1,this.autoDestroy=!!$.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new c(this)}function p($){J=J||s("./_stream_duplex");var j=this instanceof J;return j||at.call(p,this)?(this._writableState=new h($,this,j),this.writable=!0,$&&(typeof $.write=="function"&&(this._write=$.write),typeof $.writev=="function"&&(this._writev=$.writev),typeof $.destroy=="function"&&(this._destroy=$.destroy),typeof $.final=="function"&&(this._final=$.final)),void ie.call(this)):new p($)}function g($,j){var q=new Ot;it($,q),l.nextTick(j,q)}function v($,j,q,te){var M;return q===null?M=new Ye:typeof q!="string"&&!j.objectMode&&(M=new De("chunk",["string","Buffer"],q)),!M||(it($,M),l.nextTick(te,M),!1)}function w($,j,q){return $.objectMode||$.decodeStrings===!1||typeof j!="string"||(j=Z.from(j,q)),j}function S($,j,q,te,M,m){if(!q){var b=w(j,te,M);te!==b&&(q=!0,M="buffer",te=b)}var k=j.objectMode?1:te.length;j.length+=k;var I=j.length<j.highWaterMark;if(I||(j.needDrain=!0),j.writing||j.corked){var F=j.lastBufferedRequest;j.lastBufferedRequest={chunk:te,encoding:M,isBuf:q,callback:m,next:null},F?F.next=j.lastBufferedRequest:j.bufferedRequest=j.lastBufferedRequest,j.bufferedRequestCount+=1}else x($,j,!1,k,te,M,m);return I}function x($,j,q,te,M,m,b){j.writelen=te,j.writecb=b,j.writing=!0,j.sync=!0,j.destroyed?j.onwrite(new Ge("write")):q?$._writev(M,j.onwrite):$._write(M,m,j.onwrite),j.sync=!1}function y($,j,q,te,M){--j.pendingcb,q?(l.nextTick(M,te),l.nextTick(B,$,j),$._writableState.errorEmitted=!0,it($,te)):(M(te),$._writableState.errorEmitted=!0,it($,te),B($,j))}function C($){$.writing=!1,$.writecb=null,$.length-=$.writelen,$.writelen=0}function E($,j){var q=$._writableState,te=q.sync,M=q.writecb;if(typeof M!="function")throw new tt;if(C(q),j)y($,q,te,j,M);else{var m=A(q)||$.destroyed;m||q.corked||q.bufferProcessing||!q.bufferedRequest||N($,q),te?l.nextTick(T,$,q,m,M):T($,q,m,M)}}function T($,j,q,te){q||D($,j),j.pendingcb--,te(),B($,j)}function D($,j){j.length===0&&j.needDrain&&(j.needDrain=!1,$.emit("drain"))}function N($,j){j.bufferProcessing=!0;var q=j.bufferedRequest;if($._writev&&q&&q.next){var te=j.bufferedRequestCount,M=Array(te),m=j.corkedRequestsFree;m.entry=q;for(var b=0,k=!0;q;)M[b]=q,q.isBuf||(k=!1),q=q.next,b+=1;M.allBuffers=k,x($,j,!0,j.length,M,"",m.finish),j.pendingcb++,j.lastBufferedRequest=null,m.next?(j.corkedRequestsFree=m.next,m.next=null):j.corkedRequestsFree=new c(j),j.bufferedRequestCount=0}else{for(;q;){var I=q.chunk,F=q.encoding,H=q.callback,ne=j.objectMode?1:I.length;if(x($,j,!1,ne,I,F,H),q=q.next,j.bufferedRequestCount--,j.writing)break}q===null&&(j.lastBufferedRequest=null)}j.bufferedRequest=q,j.bufferProcessing=!1}function A($){return $.ending&&$.length===0&&$.bufferedRequest===null&&!$.finished&&!$.writing}function R($,j){$._final(function(q){j.pendingcb--,q&&it($,q),j.prefinished=!0,$.emit("prefinish"),B($,j)})}function P($,j){j.prefinished||j.finalCalled||(typeof $._final!="function"||j.destroyed?(j.prefinished=!0,$.emit("prefinish")):(j.pendingcb++,j.finalCalled=!0,l.nextTick(R,$,j)))}function B($,j){var q=A(j);if(q&&(P($,j),j.pendingcb===0&&(j.finished=!0,$.emit("finish"),j.autoDestroy))){var te=$._readableState;(!te||te.autoDestroy&&te.endEmitted)&&$.destroy()}return q}function z($,j,q){j.ending=!0,B($,j),q&&(j.finished?l.nextTick(q):$.once("finish",q)),j.ended=!0,$.writable=!1}function U($,j,q){var te=$.entry;for($.entry=null;te;){var M=te.callback;j.pendingcb--,M(q),te=te.next}j.corkedRequestsFree.next=$}o.exports=p;var J;p.WritableState=h;var G={deprecate:s("util-deprecate")},ie=s("./internal/streams/stream"),Z=s("buffer").Buffer,ke=a.Uint8Array||function(){},Le=s("./internal/streams/destroy"),$e=s("./internal/streams/state"),Ee=$e.getHighWaterMark,ve=s("../errors").codes,De=ve.ERR_INVALID_ARG_TYPE,Ie=ve.ERR_METHOD_NOT_IMPLEMENTED,tt=ve.ERR_MULTIPLE_CALLBACK,nt=ve.ERR_STREAM_CANNOT_PIPE,Ge=ve.ERR_STREAM_DESTROYED,Ye=ve.ERR_STREAM_NULL_VALUES,Ot=ve.ERR_STREAM_WRITE_AFTER_END,xt=ve.ERR_UNKNOWN_ENCODING,it=Le.errorOrDestroy;s("inherits")(p,ie),h.prototype.getBuffer=function(){for(var $=this.bufferedRequest,j=[];$;)j.push($),$=$.next;return j},function(){try{Object.defineProperty(h.prototype,"buffer",{get:G.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var at;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(at=Function.prototype[Symbol.hasInstance],Object.defineProperty(p,Symbol.hasInstance,{value:function($){return!!at.call(this,$)||this===p&&$&&$._writableState instanceof h}})):at=function($){return $ instanceof this},p.prototype.pipe=function(){it(this,new nt)},p.prototype.write=function($,j,q){var te=this._writableState,M=!1,m=!te.objectMode&&d($);return m&&!Z.isBuffer($)&&($=u($)),typeof j=="function"&&(q=j,j=null),m?j="buffer":!j&&(j=te.defaultEncoding),typeof q!="function"&&(q=f),te.ending?g(this,q):(m||v(this,te,$,q))&&(te.pendingcb++,M=S(this,te,m,$,j,q)),M},p.prototype.cork=function(){this._writableState.corked++},p.prototype.uncork=function(){var $=this._writableState;$.corked&&($.corked--,!$.writing&&!$.corked&&!$.bufferProcessing&&$.bufferedRequest&&N(this,$))},p.prototype.setDefaultEncoding=function($){if(typeof $=="string"&&($=$.toLowerCase()),!(-1<["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf(($+"").toLowerCase())))throw new xt($);return this._writableState.defaultEncoding=$,this},Object.defineProperty(p.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(p.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),p.prototype._write=function($,j,q){q(new Ie("_write()"))},p.prototype._writev=null,p.prototype.end=function($,j,q){var te=this._writableState;return typeof $=="function"?(q=$,$=null,j=null):typeof j=="function"&&(q=j,j=null),$!=null&&this.write($,j),te.corked&&(te.corked=1,this.uncork()),te.ending||z(this,te,q),this},Object.defineProperty(p.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(p.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function($){this._writableState&&(this._writableState.destroyed=$)}}),p.prototype.destroy=Le.destroy,p.prototype._undestroy=Le.undestroy,p.prototype._destroy=function($,j){j($)}}).call(this)}).call(this,s("_process"),typeof _n>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:_n)},{"../errors":15,"./_stream_duplex":16,"./internal/streams/destroy":23,"./internal/streams/state":27,"./internal/streams/stream":28,_process:12,buffer:3,inherits:10,"util-deprecate":32}],21:[function(s,o){(function(l){(function(){function a(D,N,A){return N in D?Object.defineProperty(D,N,{value:A,enumerable:!0,configurable:!0,writable:!0}):D[N]=A,D}function c(D,N){return{value:D,done:N}}function u(D){var N=D[g];if(N!==null){var A=D[C].read();A!==null&&(D[x]=null,D[g]=null,D[v]=null,N(c(A,!1)))}}function d(D){l.nextTick(u,D)}function f(D,N){return function(A,R){D.then(function(){return N[S]?void A(c(void 0,!0)):void N[y](A,R)},R)}}var h,p=s("./end-of-stream"),g=Symbol("lastResolve"),v=Symbol("lastReject"),w=Symbol("error"),S=Symbol("ended"),x=Symbol("lastPromise"),y=Symbol("handlePromise"),C=Symbol("stream"),E=Object.getPrototypeOf(function(){}),T=Object.setPrototypeOf((h={get stream(){return this[C]},next:function(){var D=this,N=this[w];if(N!==null)return Promise.reject(N);if(this[S])return Promise.resolve(c(void 0,!0));if(this[C].destroyed)return new Promise(function(B,z){l.nextTick(function(){D[w]?z(D[w]):B(c(void 0,!0))})});var A,R=this[x];if(R)A=new Promise(f(R,this));else{var P=this[C].read();if(P!==null)return Promise.resolve(c(P,!1));A=new Promise(this[y])}return this[x]=A,A}},a(h,Symbol.asyncIterator,function(){return this}),a(h,"return",function(){var D=this;return new Promise(function(N,A){D[C].destroy(null,function(R){return R?void A(R):void N(c(void 0,!0))})})}),h),E);o.exports=function(D){var N,A=Object.create(T,(N={},a(N,C,{value:D,writable:!0}),a(N,g,{value:null,writable:!0}),a(N,v,{value:null,writable:!0}),a(N,w,{value:null,writable:!0}),a(N,S,{value:D._readableState.endEmitted,writable:!0}),a(N,y,{value:function(R,P){var B=A[C].read();B?(A[x]=null,A[g]=null,A[v]=null,R(c(B,!1))):(A[g]=R,A[v]=P)},writable:!0}),N));return A[x]=null,p(D,function(R){if(R&&R.code!=="ERR_STREAM_PREMATURE_CLOSE"){var P=A[v];return P!==null&&(A[x]=null,A[g]=null,A[v]=null,P(R)),void(A[w]=R)}var B=A[g];B!==null&&(A[x]=null,A[g]=null,A[v]=null,B(c(void 0,!0))),A[S]=!0}),D.on("readable",d.bind(null,A)),A}}).call(this)}).call(this,s("_process"))},{"./end-of-stream":24,_process:12}],22:[function(s,o){function l(x,y){var C=Object.keys(x);if(Object.getOwnPropertySymbols){var E=Object.getOwnPropertySymbols(x);y&&(E=E.filter(function(T){return Object.getOwnPropertyDescriptor(x,T).enumerable})),C.push.apply(C,E)}return C}function a(x){for(var y,C=1;C<arguments.length;C++)y=arguments[C]==null?{}:arguments[C],C%2?l(Object(y),!0).forEach(function(E){c(x,E,y[E])}):Object.getOwnPropertyDescriptors?Object.defineProperties(x,Object.getOwnPropertyDescriptors(y)):l(Object(y)).forEach(function(E){Object.defineProperty(x,E,Object.getOwnPropertyDescriptor(y,E))});return x}function c(x,y,C){return y in x?Object.defineProperty(x,y,{value:C,enumerable:!0,configurable:!0,writable:!0}):x[y]=C,x}function u(x,y){if(!(x instanceof y))throw new TypeError("Cannot call a class as a function")}function d(x,y){for(var C,E=0;E<y.length;E++)C=y[E],C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(x,C.key,C)}function f(x,y,C){return y&&d(x.prototype,y),x}function h(x,y,C){g.prototype.copy.call(x,y,C)}var p=s("buffer"),g=p.Buffer,v=s("util"),w=v.inspect,S=w&&w.custom||"inspect";o.exports=function(){function x(){u(this,x),this.head=null,this.tail=null,this.length=0}return f(x,[{key:"push",value:function(y){var C={data:y,next:null};0<this.length?this.tail.next=C:this.head=C,this.tail=C,++this.length}},{key:"unshift",value:function(y){var C={data:y,next:this.head};this.length===0&&(this.tail=C),this.head=C,++this.length}},{key:"shift",value:function(){if(this.length!==0){var y=this.head.data;return this.head=this.length===1?this.tail=null:this.head.next,--this.length,y}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(y){if(this.length===0)return"";for(var C=this.head,E=""+C.data;C=C.next;)E+=y+C.data;return E}},{key:"concat",value:function(y){if(this.length===0)return g.alloc(0);for(var C=g.allocUnsafe(y>>>0),E=this.head,T=0;E;)h(E.data,C,T),T+=E.data.length,E=E.next;return C}},{key:"consume",value:function(y,C){var E;return y<this.head.data.length?(E=this.head.data.slice(0,y),this.head.data=this.head.data.slice(y)):y===this.head.data.length?E=this.shift():E=C?this._getString(y):this._getBuffer(y),E}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(y){var C=this.head,E=1,T=C.data;for(y-=T.length;C=C.next;){var D=C.data,N=y>D.length?D.length:y;if(T+=N===D.length?D:D.slice(0,y),y-=N,y===0){N===D.length?(++E,this.head=C.next?C.next:this.tail=null):(this.head=C,C.data=D.slice(N));break}++E}return this.length-=E,T}},{key:"_getBuffer",value:function(y){var C=g.allocUnsafe(y),E=this.head,T=1;for(E.data.copy(C),y-=E.data.length;E=E.next;){var D=E.data,N=y>D.length?D.length:y;if(D.copy(C,C.length-y,0,N),y-=N,y===0){N===D.length?(++T,this.head=E.next?E.next:this.tail=null):(this.head=E,E.data=D.slice(N));break}++T}return this.length-=T,C}},{key:S,value:function(y,C){return w(this,a({},C,{depth:0,customInspect:!1}))}}]),x}()},{buffer:3,util:2}],23:[function(s,o){(function(l){(function(){function a(d,f){u(d,f),c(d)}function c(d){d._writableState&&!d._writableState.emitClose||d._readableState&&!d._readableState.emitClose||d.emit("close")}function u(d,f){d.emit("error",f)}o.exports={destroy:function(d,f){var h=this,p=this._readableState&&this._readableState.destroyed,g=this._writableState&&this._writableState.destroyed;return p||g?(f?f(d):d&&(this._writableState?!this._writableState.errorEmitted&&(this._writableState.errorEmitted=!0,l.nextTick(u,this,d)):l.nextTick(u,this,d)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(d||null,function(v){!f&&v?h._writableState?h._writableState.errorEmitted?l.nextTick(c,h):(h._writableState.errorEmitted=!0,l.nextTick(a,h,v)):l.nextTick(a,h,v):f?(l.nextTick(c,h),f(v)):l.nextTick(c,h)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(d,f){var h=d._readableState,p=d._writableState;h&&h.autoDestroy||p&&p.autoDestroy?d.destroy(f):d.emit("error",f)}}}).call(this)}).call(this,s("_process"))},{_process:12}],24:[function(s,o){function l(f){var h=!1;return function(){if(!h){h=!0;for(var p=arguments.length,g=Array(p),v=0;v<p;v++)g[v]=arguments[v];f.apply(this,g)}}}function a(){}function c(f){return f.setHeader&&typeof f.abort=="function"}function u(f,h,p){if(typeof h=="function")return u(f,null,h);h||(h={}),p=l(p||a);var g=h.readable||h.readable!==!1&&f.readable,v=h.writable||h.writable!==!1&&f.writable,w=function(){f.writable||x()},S=f._writableState&&f._writableState.finished,x=function(){v=!1,S=!0,g||p.call(f)},y=f._readableState&&f._readableState.endEmitted,C=function(){g=!1,y=!0,v||p.call(f)},E=function(N){p.call(f,N)},T=function(){var N;return g&&!y?(f._readableState&&f._readableState.ended||(N=new d),p.call(f,N)):v&&!S?(f._writableState&&f._writableState.ended||(N=new d),p.call(f,N)):void 0},D=function(){f.req.on("finish",x)};return c(f)?(f.on("complete",x),f.on("abort",T),f.req?D():f.on("request",D)):v&&!f._writableState&&(f.on("end",w),f.on("close",w)),f.on("end",C),f.on("finish",x),h.error!==!1&&f.on("error",E),f.on("close",T),function(){f.removeListener("complete",x),f.removeListener("abort",T),f.removeListener("request",D),f.req&&f.req.removeListener("finish",x),f.removeListener("end",w),f.removeListener("close",w),f.removeListener("finish",x),f.removeListener("end",C),f.removeListener("error",E),f.removeListener("close",T)}}var d=s("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;o.exports=u},{"../../../errors":15}],25:[function(s,o){o.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],26:[function(s,o){function l(S){var x=!1;return function(){x||(x=!0,S.apply(void 0,arguments))}}function a(S){if(S)throw S}function c(S){return S.setHeader&&typeof S.abort=="function"}function u(S,x,y,C){C=l(C);var E=!1;S.on("close",function(){E=!0}),p===void 0&&(p=s("./end-of-stream")),p(S,{readable:x,writable:y},function(D){return D?C(D):(E=!0,void C())});var T=!1;return function(D){if(!E)return T?void 0:(T=!0,c(S)?S.abort():typeof S.destroy=="function"?S.destroy():void C(D||new w("pipe")))}}function d(S){S()}function f(S,x){return S.pipe(x)}function h(S){return S.length&&typeof S[S.length-1]=="function"?S.pop():a}var p,g=s("../../../errors").codes,v=g.ERR_MISSING_ARGS,w=g.ERR_STREAM_DESTROYED;o.exports=function(){for(var S=arguments.length,x=Array(S),y=0;y<S;y++)x[y]=arguments[y];var C=h(x);if(Array.isArray(x[0])&&(x=x[0]),2>x.length)throw new v("streams");var E,T=x.map(function(D,N){var A=N<x.length-1;return u(D,A,0<N,function(R){E||(E=R),R&&T.forEach(d),A||(T.forEach(d),C(E))})});return x.reduce(f)}},{"../../../errors":15,"./end-of-stream":24}],27:[function(s,o){function l(c,u,d){return c.highWaterMark==null?u?c[d]:null:c.highWaterMark}var a=s("../../../errors").codes.ERR_INVALID_OPT_VALUE;o.exports={getHighWaterMark:function(c,u,d,f){var h=l(u,f,d);if(h!=null){if(!(isFinite(h)&&n(h)===h)||0>h){var p=f?d:"highWaterMark";throw new a(p,h)}return n(h)}return c.objectMode?16:16384}}},{"../../../errors":15}],28:[function(s,o){o.exports=s("events").EventEmitter},{events:7}],29:[function(s,o,l){l=o.exports=s("./lib/_stream_readable.js"),l.Stream=l,l.Readable=l,l.Writable=s("./lib/_stream_writable.js"),l.Duplex=s("./lib/_stream_duplex.js"),l.Transform=s("./lib/_stream_transform.js"),l.PassThrough=s("./lib/_stream_passthrough.js"),l.finished=s("./lib/internal/streams/end-of-stream.js"),l.pipeline=s("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":16,"./lib/_stream_passthrough.js":17,"./lib/_stream_readable.js":18,"./lib/_stream_transform.js":19,"./lib/_stream_writable.js":20,"./lib/internal/streams/end-of-stream.js":24,"./lib/internal/streams/pipeline.js":26}],30:[function(s,o,l){function a(f,h){for(var p in f)h[p]=f[p]}function c(f,h,p){return d(f,h,p)}/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var u=s("buffer"),d=u.Buffer;d.from&&d.alloc&&d.allocUnsafe&&d.allocUnsafeSlow?o.exports=u:(a(u,l),l.Buffer=c),c.prototype=Object.create(d.prototype),a(d,c),c.from=function(f,h,p){if(typeof f=="number")throw new TypeError("Argument must not be a number");return d(f,h,p)},c.alloc=function(f,h,p){if(typeof f!="number")throw new TypeError("Argument must be a number");var g=d(f);return h===void 0?g.fill(0):typeof p=="string"?g.fill(h,p):g.fill(h),g},c.allocUnsafe=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return d(f)},c.allocUnsafeSlow=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return u.SlowBuffer(f)}},{buffer:3}],31:[function(s,o,l){function a(T){if(!T)return"utf8";for(var D;;)switch(T){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return T;default:if(D)return;T=(""+T).toLowerCase(),D=!0}}function c(T){var D=a(T);if(typeof D!="string"&&(C.isEncoding===E||!E(T)))throw new Error("Unknown encoding: "+T);return D||T}function u(T){this.encoding=c(T);var D;switch(this.encoding){case"utf16le":this.text=g,this.end=v,D=4;break;case"utf8":this.fillLast=p,D=4;break;case"base64":this.text=w,this.end=S,D=3;break;default:return this.write=x,void(this.end=y)}this.lastNeed=0,this.lastTotal=0,this.lastChar=C.allocUnsafe(D)}function d(T){return 127>=T?0:T>>5==6?2:T>>4==14?3:T>>3==30?4:T>>6==2?-1:-2}function f(T,D,N){var A=D.length-1;if(A<N)return 0;var R=d(D[A]);return 0<=R?(0<R&&(T.lastNeed=R-1),R):--A<N||R===-2?0:(R=d(D[A]),0<=R?(0<R&&(T.lastNeed=R-2),R):--A<N||R===-2?0:(R=d(D[A]),0<=R?(0<R&&(R===2?R=0:T.lastNeed=R-3),R):0))}function h(T,D){if((192&D[0])!=128)return T.lastNeed=0,"�";if(1<T.lastNeed&&1<D.length){if((192&D[1])!=128)return T.lastNeed=1,"�";if(2<T.lastNeed&&2<D.length&&(192&D[2])!=128)return T.lastNeed=2,"�"}}function p(T){var D=this.lastTotal-this.lastNeed,N=h(this,T);return N===void 0?this.lastNeed<=T.length?(T.copy(this.lastChar,D,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(T.copy(this.lastChar,D,0,T.length),void(this.lastNeed-=T.length)):N}function g(T,D){if((T.length-D)%2==0){var N=T.toString("utf16le",D);if(N){var A=N.charCodeAt(N.length-1);if(55296<=A&&56319>=A)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=T[T.length-2],this.lastChar[1]=T[T.length-1],N.slice(0,-1)}return N}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=T[T.length-1],T.toString("utf16le",D,T.length-1)}function v(T){var D=T&&T.length?this.write(T):"";if(this.lastNeed){var N=this.lastTotal-this.lastNeed;return D+this.lastChar.toString("utf16le",0,N)}return D}function w(T,D){var N=(T.length-D)%3;return N==0?T.toString("base64",D):(this.lastNeed=3-N,this.lastTotal=3,N==1?this.lastChar[0]=T[T.length-1]:(this.lastChar[0]=T[T.length-2],this.lastChar[1]=T[T.length-1]),T.toString("base64",D,T.length-N))}function S(T){var D=T&&T.length?this.write(T):"";return this.lastNeed?D+this.lastChar.toString("base64",0,3-this.lastNeed):D}function x(T){return T.toString(this.encoding)}function y(T){return T&&T.length?this.write(T):""}var C=s("safe-buffer").Buffer,E=C.isEncoding||function(T){switch(T=""+T,T&&T.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};l.StringDecoder=u,u.prototype.write=function(T){if(T.length===0)return"";var D,N;if(this.lastNeed){if(D=this.fillLast(T),D===void 0)return"";N=this.lastNeed,this.lastNeed=0}else N=0;return N<T.length?D?D+this.text(T,N):this.text(T,N):D||""},u.prototype.end=function(T){var D=T&&T.length?this.write(T):"";return this.lastNeed?D+"�":D},u.prototype.text=function(T,D){var N=f(this,T,D);if(!this.lastNeed)return T.toString("utf8",D);this.lastTotal=N;var A=T.length-(N-this.lastNeed);return T.copy(this.lastChar,0,A),T.toString("utf8",D,A)},u.prototype.fillLast=function(T){return this.lastNeed<=T.length?(T.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(T.copy(this.lastChar,this.lastTotal-this.lastNeed,0,T.length),void(this.lastNeed-=T.length))}},{"safe-buffer":30}],32:[function(s,o){(function(l){(function(){function a(c){try{if(!l.localStorage)return!1}catch{return!1}var u=l.localStorage[c];return u!=null&&(u+"").toLowerCase()==="true"}o.exports=function(c,u){function d(){if(!f){if(a("throwDeprecation"))throw new Error(u);a("traceDeprecation")?console.trace(u):console.warn(u),f=!0}return c.apply(this,arguments)}if(a("noDeprecation"))return c;var f=!1;return d}}).call(this)}).call(this,typeof _n>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:_n)},{}],"/":[function(s,o){function l(S){return S.replace(/a=ice-options:trickle\s\n/g,"")}function a(S){console.warn(S)}/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */const c=s("debug")("simple-peer"),u=s("get-browser-rtc"),d=s("randombytes"),f=s("readable-stream"),h=s("queue-microtask"),p=s("err-code"),{Buffer:g}=s("buffer"),v=65536;class w extends f.Duplex{constructor(x){if(x=Object.assign({allowHalfOpen:!1},x),super(x),this._id=d(4).toString("hex").slice(0,7),this._debug("new peer %o",x),this.channelName=x.initiator?x.channelName||d(20).toString("hex"):null,this.initiator=x.initiator||!1,this.channelConfig=x.channelConfig||w.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},w.config,x.config),this.offerOptions=x.offerOptions||{},this.answerOptions=x.answerOptions||{},this.sdpTransform=x.sdpTransform||(y=>y),this.streams=x.streams||(x.stream?[x.stream]:[]),this.trickle=x.trickle===void 0||x.trickle,this.allowHalfTrickle=x.allowHalfTrickle!==void 0&&x.allowHalfTrickle,this.iceCompleteTimeout=x.iceCompleteTimeout||5e3,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=x.wrtc&&typeof x.wrtc=="object"?x.wrtc:u(),!this._wrtc)throw p(typeof window>"u"?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(y){return void this.destroy(p(y,"ERR_PC_CONSTRUCTOR"))}this._isReactNativeWebrtc=typeof this._pc._peerConnectionId=="number",this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=y=>{this._onIceCandidate(y)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(y=>{this.destroy(p(y,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=y=>{this._setupData(y)},this.streams&&this.streams.forEach(y=>{this.addStream(y)}),this._pc.ontrack=y=>{this._onTrack(y)},this._debug("initial negotiation"),this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&this._channel.readyState==="open"}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(x){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof x=="string")try{x=JSON.parse(x)}catch{x={}}this._debug("signal()"),x.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),x.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(x.transceiverRequest.kind,x.transceiverRequest.init)),x.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(x.candidate):this._pendingCandidates.push(x.candidate)),x.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(x)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(y=>{this._addIceCandidate(y)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(y=>{this.destroy(p(y,"ERR_SET_REMOTE_DESCRIPTION"))}),x.sdp||x.candidate||x.renegotiate||x.transceiverRequest||this.destroy(p(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(x){const y=new this._wrtc.RTCIceCandidate(x);this._pc.addIceCandidate(y).catch(C=>{!y.address||y.address.endsWith(".local")?a("Ignoring unsupported ICE candidate."):this.destroy(p(C,"ERR_ADD_ICE_CANDIDATE"))})}send(x){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(x)}}addTransceiver(x,y){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(x,y),this._needsNegotiation()}catch(C){this.destroy(p(C,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:x,init:y}})}}addStream(x){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),x.getTracks().forEach(y=>{this.addTrack(y,x)})}}addTrack(x,y){if(this.destroying)return;if(this.destroyed)throw p(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const C=this._senderMap.get(x)||new Map;let E=C.get(y);if(!E)E=this._pc.addTrack(x,y),C.set(y,E),this._senderMap.set(x,C),this._needsNegotiation();else throw E.removed?p(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):p(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(x,y,C){if(this.destroying)return;if(this.destroyed)throw p(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const E=this._senderMap.get(x),T=E?E.get(C):null;if(!T)throw p(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");y&&this._senderMap.set(y,E),T.replaceTrack==null?this.destroy(p(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK")):T.replaceTrack(y)}removeTrack(x,y){if(this.destroying)return;if(this.destroyed)throw p(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const C=this._senderMap.get(x),E=C?C.get(y):null;if(!E)throw p(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{E.removed=!0,this._pc.removeTrack(E)}catch(T){T.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(E):this.destroy(p(T,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(x){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),x.getTracks().forEach(y=>{this.removeTrack(y,x)})}}_needsNegotiation(){this._debug("_needsNegotiation"),this._batchedNegotiation||(this._batchedNegotiation=!0,h(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(x){this._destroy(x,()=>{})}_destroy(x,y){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",x&&(x.message||x)),h(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",x&&(x.message||x)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch{}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch{}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,x&&this.emit("error",x),this.emit("close"),y()}))}_setupData(x){if(!x.channel)return this.destroy(p(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=x.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=v),this.channelName=this._channel.label,this._channel.onmessage=C=>{this._onChannelMessage(C)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=C=>{const E=C.error instanceof Error?C.error:new Error(`Datachannel error: ${C.message} ${C.filename}:${C.lineno}:${C.colno}`);this.destroy(p(E,"ERR_DATA_CHANNEL"))};let y=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(y&&this._onChannelClose(),y=!0):y=!1},5e3)}_read(){}_write(x,y,C){if(this.destroyed)return C(p(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(x)}catch(E){return this.destroy(p(E,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>v?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=C):C(null)}else this._debug("write before connect"),this._chunk=x,this._cb=C}_onFinish(){if(!this.destroyed){const x=()=>{setTimeout(()=>this.destroy(),1e3)};this._connected?x():this.once("connect",x)}}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(x=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(x.sdp=l(x.sdp)),x.sdp=this.sdpTransform(x.sdp);const y=()=>{if(!this.destroyed){const C=this._pc.localDescription||x;this._debug("signal"),this.emit("signal",{type:C.type,sdp:C.sdp})}};this._pc.setLocalDescription(x).then(()=>{this._debug("createOffer success"),this.destroyed||(this.trickle||this._iceComplete?y():this.once("_iceComplete",y))}).catch(C=>{this.destroy(p(C,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(x=>{this.destroy(p(x,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(x=>{x.mid||!x.sender.track||x.requested||(x.requested=!0,this.addTransceiver(x.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(x=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(x.sdp=l(x.sdp)),x.sdp=this.sdpTransform(x.sdp);const y=()=>{if(!this.destroyed){const C=this._pc.localDescription||x;this._debug("signal"),this.emit("signal",{type:C.type,sdp:C.sdp}),this.initiator||this._requestMissingTransceivers()}};this._pc.setLocalDescription(x).then(()=>{this.destroyed||(this.trickle||this._iceComplete?y():this.once("_iceComplete",y))}).catch(C=>{this.destroy(p(C,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(x=>{this.destroy(p(x,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||this._pc.connectionState==="failed"&&this.destroy(p(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const x=this._pc.iceConnectionState,y=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",x,y),this.emit("iceStateChange",x,y),(x==="connected"||x==="completed")&&(this._pcReady=!0,this._maybeReady()),x==="failed"&&this.destroy(p(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),x==="closed"&&this.destroy(p(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(x){const y=C=>(Object.prototype.toString.call(C.values)==="[object Array]"&&C.values.forEach(E=>{Object.assign(C,E)}),C);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(C=>{const E=[];C.forEach(T=>{E.push(y(T))}),x(null,E)},C=>x(C)):0<this._pc.getStats.length?this._pc.getStats(C=>{if(this.destroyed)return;const E=[];C.result().forEach(T=>{const D={};T.names().forEach(N=>{D[N]=T.stat(N)}),D.id=T.id,D.type=T.type,D.timestamp=T.timestamp,E.push(y(D))}),x(null,E)},C=>x(C)):x(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const x=()=>{this.destroyed||this.getStats((y,C)=>{if(this.destroyed)return;y&&(C=[]);const E={},T={},D={};let N=!1;C.forEach(R=>{(R.type==="remotecandidate"||R.type==="remote-candidate")&&(E[R.id]=R),(R.type==="localcandidate"||R.type==="local-candidate")&&(T[R.id]=R),(R.type==="candidatepair"||R.type==="candidate-pair")&&(D[R.id]=R)});const A=R=>{N=!0;let P=T[R.localCandidateId];P&&(P.ip||P.address)?(this.localAddress=P.ip||P.address,this.localPort=+P.port):P&&P.ipAddress?(this.localAddress=P.ipAddress,this.localPort=+P.portNumber):typeof R.googLocalAddress=="string"&&(P=R.googLocalAddress.split(":"),this.localAddress=P[0],this.localPort=+P[1]),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let B=E[R.remoteCandidateId];B&&(B.ip||B.address)?(this.remoteAddress=B.ip||B.address,this.remotePort=+B.port):B&&B.ipAddress?(this.remoteAddress=B.ipAddress,this.remotePort=+B.portNumber):typeof R.googRemoteAddress=="string"&&(B=R.googRemoteAddress.split(":"),this.remoteAddress=B[0],this.remotePort=+B[1]),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(C.forEach(R=>{R.type==="transport"&&R.selectedCandidatePairId&&A(D[R.selectedCandidatePairId]),(R.type==="googCandidatePair"&&R.googActiveConnection==="true"||(R.type==="candidatepair"||R.type==="candidate-pair")&&R.selected)&&A(R)}),!N&&(!Object.keys(D).length||Object.keys(T).length))return void setTimeout(x,100);if(this._connecting=!1,this._connected=!0,this._chunk){try{this.send(this._chunk)}catch(P){return this.destroy(p(P,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const R=this._cb;this._cb=null,R(null)}typeof this._channel.bufferedAmountLowThreshold!="number"&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};x()}_onInterval(){this._cb&&this._channel&&!(this._channel.bufferedAmount>v)&&this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(this._pc.signalingState==="stable"&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(x=>{this._pc.removeTrack(x),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(x){this.destroyed||(x.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:x.candidate.candidate,sdpMLineIndex:x.candidate.sdpMLineIndex,sdpMid:x.candidate.sdpMid}}):!x.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),x.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(x){if(this.destroyed)return;let y=x.data;y instanceof ArrayBuffer&&(y=g.from(y)),this.push(y)}_onChannelBufferedAmountLow(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const x=this._cb;this._cb=null,x(null)}}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(x){this.destroyed||x.streams.forEach(y=>{this._debug("on track"),this.emit("track",x.track,y),this._remoteTracks.push({track:x.track,stream:y}),this._remoteStreams.some(C=>C.id===y.id)||(this._remoteStreams.push(y),h(()=>{this._debug("on stream"),this.emit("stream",y)}))})}_debug(){const x=[].slice.call(arguments);x[0]="["+this._id+"] "+x[0],c.apply(null,x)}}w.WEBRTC_SUPPORT=!!u(),w.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},w.channelConfig={},o.exports=w},{buffer:3,debug:4,"err-code":6,"get-browser-rtc":8,"queue-microtask":13,randombytes:14,"readable-stream":29}]},{},[])("/")})})(Tb);var SO=Tb.exports;const EO=Pc(SO),hf=0,pf=1,Ab=2,Mb=(t,e)=>{ae(t,hf);const n=wM(e);Ze(t,n)},Ob=(t,e,n)=>{ae(t,pf),Ze(t,Gd(e,n))},TO=(t,e,n)=>Ob(e,n,bt(t)),_b=(t,e,n)=>{try{L0(e,bt(t),n)}catch(r){console.error("Caught error while handling a Yjs update",r)}},AO=(t,e)=>{ae(t,Ab),Ze(t,e)},MO=_b,OO=(t,e,n,r)=>{const i=pe(t);switch(i){case hf:TO(t,e,n);break;case pf:_b(t,n,r);break;case Ab:MO(t,n,r);break;default:throw new Error("Unknown message type")}return i},mf=3e4;class _O extends wd{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const n=Bn();this.getLocalState()!==null&&mf/2<=n-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const r=[];this.meta.forEach((i,s)=>{s!==this.clientID&&mf<=n-i.lastUpdated&&this.states.has(s)&&r.push(s)}),r.length>0&&gf(this,r,"timeout")},wn(mf/10)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const n=this.clientID,r=this.meta.get(n),i=r===void 0?0:r.clock+1,s=this.states.get(n);e===null?this.states.delete(n):this.states.set(n,e),this.meta.set(n,{clock:i,lastUpdated:Bn()});const o=[],l=[],a=[],c=[];e===null?c.push(n):s==null?e!=null&&o.push(n):(l.push(n),Mo(s,e)||a.push(n)),(o.length>0||a.length>0||c.length>0)&&this.emit("change",[{added:o,updated:a,removed:c},"local"]),this.emit("update",[{added:o,updated:l,removed:c},"local"])}setLocalStateField(e,n){const r=this.getLocalState();r!==null&&this.setLocalState({...r,[e]:n})}getStates(){return this.states}}const gf=(t,e,n)=>{const r=[];for(let i=0;i<e.length;i++){const s=e[i];if(t.states.has(s)){if(t.states.delete(s),s===t.clientID){const o=t.meta.get(s);t.meta.set(s,{clock:o.clock+1,lastUpdated:Bn()})}r.push(s)}}r.length>0&&(t.emit("change",[{added:[],updated:[],removed:r},n]),t.emit("update",[{added:[],updated:[],removed:r},n]))},wa=(t,e,n=t.states)=>{const r=e.length,i=gt();ae(i,r);for(let s=0;s<r;s++){const o=e[s],l=n.get(o)||null,a=t.meta.get(o).clock;ae(i,o),ae(i,a),jn(i,JSON.stringify(l))}return qe(i)},NO=(t,e,n)=>{const r=Hn(e),i=Bn(),s=[],o=[],l=[],a=[],c=pe(r);for(let u=0;u<c;u++){const d=pe(r);let f=pe(r);const h=JSON.parse(ur(r)),p=t.meta.get(d),g=t.states.get(d),v=p===void 0?0:p.clock;(v<f||v===f&&h===null&&t.states.has(d))&&(h===null?d===t.clientID&&t.getLocalState()!=null?f++:t.states.delete(d):t.states.set(d,h),t.meta.set(d,{clock:f,lastUpdated:i}),p===void 0&&h!==null?s.push(d):p!==void 0&&h===null?a.push(d):h!==null&&(Mo(h,g)||l.push(d),o.push(d)))}(s.length>0||l.length>0||a.length>0)&&t.emit("change",[{added:s,updated:l,removed:a},n]),(s.length>0||o.length>0||a.length>0)&&t.emit("update",[{added:s,updated:o,removed:a},n])},DO=(t,e)=>{const n=Ed(t).buffer,r=Ed(e).buffer;return crypto.subtle.importKey("raw",n,"PBKDF2",!1,["deriveKey"]).then(i=>crypto.subtle.deriveKey({name:"PBKDF2",salt:r,iterations:1e5,hash:"SHA-256"},i,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]))},Nb=(t,e)=>{if(!e)return Hd(t);const n=crypto.getRandomValues(new Uint8Array(12));return crypto.subtle.encrypt({name:"AES-GCM",iv:n},e,t).then(r=>{const i=gt();return jn(i,"AES-GCM"),Ze(i,n),Ze(i,new Uint8Array(r)),qe(i)})},RO=(t,e)=>{const n=gt();return ns(n,t),Nb(qe(n),e)},Db=(t,e)=>{if(!e)return Hd(t);const n=Hn(t);ur(n)!=="AES-GCM"&&J2(xn("Unknown encryption algorithm"));const i=bt(n),s=bt(n);return crypto.subtle.decrypt({name:"AES-GCM",iv:i},e,s).then(o=>new Uint8Array(o))},LO=(t,e)=>Db(t,e).then(n=>rs(Hn(new Uint8Array(n)))),Zt=K2("y-webrtc"),bs=0,Rb=3,Ho=1,yf=4,xa=new Map,Si=new Map,Lb=t=>{let e=!0;t.webrtcConns.forEach(n=>{n.synced||(e=!1)}),(!e&&t.synced||e&&!t.synced)&&(t.synced=e,t.provider.emit("synced",[{synced:e}]),Zt("synced ",un,t.name,yi," with all peers"))},Ib=(t,e,n)=>{const r=Hn(e),i=gt(),s=pe(r);if(t===void 0)return null;const o=t.awareness,l=t.doc;let a=!1;switch(s){case bs:{ae(i,bs);const c=OO(r,i,l,t);c===pf&&!t.synced&&n(),c===hf&&(a=!0);break}case Rb:ae(i,Ho),Ze(i,wa(o,Array.from(o.getStates().keys()))),a=!0;break;case Ho:NO(o,bt(r),t);break;case yf:{const c=gi(r)===1,u=ur(r);if(u!==t.peerId&&(t.bcConns.has(u)&&!c||!t.bcConns.has(u)&&c)){const d=[],f=[];c?(t.bcConns.add(u),f.push(u)):(t.bcConns.delete(u),d.push(u)),t.provider.emit("peers",[{added:f,removed:d,webrtcPeers:Array.from(t.webrtcConns.keys()),bcPeers:Array.from(t.bcConns)}]),$b(t)}break}default:return console.error("Unable to compute message"),i}return a?i:null},IO=(t,e)=>{const n=t.room;return Zt("received message from ",un,t.remotePeerId,Bd," (",n.name,")",yi,sa),Ib(n,e,()=>{t.synced=!0,Zt("synced ",un,n.name,yi," with ",un,t.remotePeerId),Lb(n)})},bf=(t,e)=>{Zt("send message to ",un,t.remotePeerId,yi,Bd," (",t.room.name,")",sa);try{t.peer.send(qe(e))}catch{}},PO=(t,e)=>{Zt("broadcast message in ",un,t.name,yi),t.webrtcConns.forEach(n=>{try{n.peer.send(e)}catch{}})};class Pb{constructor(e,n,r,i){Zt("establishing connection to ",un,r),this.room=i,this.remotePeerId=r,this.glareToken=void 0,this.closed=!1,this.connected=!1,this.synced=!1,this.peer=new EO({initiator:n,...i.provider.peerOpts}),this.peer.on("signal",s=>{this.glareToken===void 0&&(this.glareToken=Date.now()+Math.random()),wf(e,i,{to:r,from:i.peerId,type:"signal",token:this.glareToken,signal:s})}),this.peer.on("connect",()=>{Zt("connected to ",un,r),this.connected=!0;const o=i.provider.doc,l=i.awareness,a=gt();ae(a,bs),Mb(a,o),bf(this,a);const c=l.getStates();if(c.size>0){const u=gt();ae(u,Ho),Ze(u,wa(l,Array.from(c.keys()))),bf(this,u)}}),this.peer.on("close",()=>{this.connected=!1,this.closed=!0,i.webrtcConns.has(this.remotePeerId)&&(i.webrtcConns.delete(this.remotePeerId),i.provider.emit("peers",[{removed:[this.remotePeerId],added:[],webrtcPeers:Array.from(i.webrtcConns.keys()),bcPeers:Array.from(i.bcConns)}])),Lb(i),this.peer.destroy(),Zt("closed connection to ",un,r),vf(i)}),this.peer.on("error",s=>{Zt("Error in connection to ",un,r,": ",s),vf(i)}),this.peer.on("data",s=>{const o=IO(this,s);o!==null&&bf(this,o)})}destroy(){this.peer.destroy()}}const Br=(t,e)=>Nb(e,t.key).then(n=>t.mux(()=>oM(t.name,n))),Fb=(t,e)=>{t.bcconnected&&Br(t,e),PO(t,e)},vf=t=>{xa.forEach(e=>{e.connected&&(e.send({type:"subscribe",topics:[t.name]}),t.webrtcConns.size<t.provider.maxConns&&wf(e,t,{type:"announce",from:t.peerId}))})},$b=t=>{if(t.provider.filterBcConns){const e=gt();ae(e,yf),Ao(e,1),jn(e,t.peerId),Br(t,qe(e))}};class FO{constructor(e,n,r,i){this.peerId=Ky(),this.doc=e,this.awareness=n.awareness,this.provider=n,this.synced=!1,this.name=r,this.key=i,this.webrtcConns=new Map,this.bcConns=new Set,this.mux=C0(),this.bcconnected=!1,this._bcSubscriber=s=>Db(new Uint8Array(s),i).then(o=>this.mux(()=>{const l=Ib(this,o,()=>{});l&&Br(this,qe(l))})),this._docUpdateHandler=(s,o)=>{const l=gt();ae(l,bs),AO(l,s),Fb(this,qe(l))},this._awarenessUpdateHandler=({added:s,updated:o,removed:l},a)=>{const c=s.concat(o).concat(l),u=gt();ae(u,Ho),Ze(u,wa(this.awareness,c)),Fb(this,qe(u))},this._beforeUnloadHandler=()=>{gf(this.awareness,[e.clientID],"window unload"),Si.forEach(s=>{s.disconnect()})},typeof window<"u"?window.addEventListener("beforeunload",this._beforeUnloadHandler):typeof process<"u"&&process.on("exit",this._beforeUnloadHandler)}connect(){this.doc.on("update",this._docUpdateHandler),this.awareness.on("update",this._awarenessUpdateHandler),vf(this);const e=this.name;iM(e,this._bcSubscriber),this.bcconnected=!0,$b(this);const n=gt();ae(n,bs),Mb(n,this.doc),Br(this,qe(n));const r=gt();ae(r,bs),Ob(r,this.doc),Br(this,qe(r));const i=gt();ae(i,Rb),Br(this,qe(i));const s=gt();ae(s,Ho),Ze(s,wa(this.awareness,[this.doc.clientID])),Br(this,qe(s))}disconnect(){xa.forEach(n=>{n.connected&&n.send({type:"unsubscribe",topics:[this.name]})}),gf(this.awareness,[this.doc.clientID],"disconnect");const e=gt();ae(e,yf),Ao(e,0),jn(e,this.peerId),Br(this,qe(e)),sM(this.name,this._bcSubscriber),this.bcconnected=!1,this.doc.off("update",this._docUpdateHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.webrtcConns.forEach(n=>n.destroy())}destroy(){this.disconnect(),typeof window<"u"?window.removeEventListener("beforeunload",this._beforeUnloadHandler):typeof process<"u"&&process.off("exit",this._beforeUnloadHandler)}}const $O=(t,e,n,r)=>{if(Si.has(n))throw xn(`A Yjs Doc connected to room "${n}" already exists!`);const i=new FO(t,e,n,r);return Si.set(n,i),i},wf=(t,e,n)=>{e.key?RO(n,e.key).then(r=>{t.send({type:"publish",topic:e.name,data:w0(r)})}):t.send({type:"publish",topic:e.name,data:n})};class BO extends ZA{constructor(e){super(e),this.providers=new Set,this.on("connect",()=>{Zt(`connected (${e})`);const n=Array.from(Si.keys());this.send({type:"subscribe",topics:n}),Si.forEach(r=>wf(this,r,{type:"announce",from:r.peerId}))}),this.on("message",n=>{switch(n.type){case"publish":{const r=n.topic,i=Si.get(r);if(i==null||typeof r!="string")return;const s=o=>{const l=i.webrtcConns,a=i.peerId;if(o==null||o.from===a||o.to!==void 0&&o.to!==a||i.bcConns.has(o.from))return;const c=l.has(o.from)?()=>{}:()=>i.provider.emit("peers",[{removed:[],added:[o.from],webrtcPeers:Array.from(i.webrtcConns.keys()),bcPeers:Array.from(i.bcConns)}]);switch(o.type){case"announce":l.size<i.provider.maxConns&&(Vt(l,o.from,()=>new Pb(this,!0,o.from,i)),c());break;case"signal":if(o.signal.type==="offer"){const u=l.get(o.from);if(u){const d=o.token,f=u.glareToken;if(f&&f>d){Zt("offer rejected: ",o.from);return}u.glareToken=void 0}}if(o.signal.type==="answer"){Zt("offer answered by: ",o.from);const u=l.get(o.from);u.glareToken=void 0}o.to===a&&(Vt(l,o.from,()=>new Pb(this,!1,o.from,i)).peer.signal(o.signal),c());break}};i.key?typeof n.data=="string"&&LO(x0(n.data),i.key).then(s):s(n.data)}}}),this.on("disconnect",()=>Zt(`disconnect (${e})`))}}const xf=t=>{t.emit("status",[{connected:t.connected}])};class jO extends vd{constructor(e,n,{signaling:r=["wss://y-webrtc-eu.fly.dev"],password:i=null,awareness:s=new _O(n),maxConns:o=20+wn(Wy()*15),filterBcConns:l=!0,peerOpts:a={}}={}){super(),this.roomName=e,this.doc=n,this.filterBcConns=l,this.awareness=s,this.shouldConnect=!1,this.signalingUrls=r,this.signalingConns=[],this.maxConns=o,this.peerOpts=a,this.key=i?DO(i,e):Hd(null),this.room=null,this.key.then(c=>{this.room=$O(n,this,e,c),this.shouldConnect?this.room.connect():this.room.disconnect(),xf(this)}),this.connect(),this.destroy=this.destroy.bind(this),n.on("destroy",this.destroy)}get connected(){return this.room!==null&&this.shouldConnect}connect(){this.shouldConnect=!0,this.signalingUrls.forEach(e=>{const n=Vt(xa,e,()=>new BO(e));this.signalingConns.push(n),n.providers.add(this)}),this.room&&(this.room.connect(),xf(this))}disconnect(){this.shouldConnect=!1,this.signalingConns.forEach(e=>{e.providers.delete(this),e.providers.size===0&&(e.destroy(),xa.delete(e.url))}),this.room&&(this.room.disconnect(),xf(this))}destroy(){this.doc.off("destroy",this.destroy),this.key.then(()=>{this.room.destroy(),Si.delete(this.roomName)}),super.destroy()}}const Bb={attributes:{class:"prose-lg prose-headings:font-display prose prose-p:my-2 prose-h1:my-2 prose-h2:my-2 prose-h3:my-2 prose-ul:my-2 prose-ol:my-2 max-w-none focus:outline-none w-full",spellcheck:"false",suppressContentEditableWarning:"true"},handleDOMEvents:{keydown:(t,e)=>{if(["ArrowUp","ArrowDown","Enter"].includes(e.key)&&document.querySelector("#slash-command"))return!0}}},HO=/[\uD800-\uDBFF]/,zO=/[\uDC00-\uDFFF]/,VO=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&HO.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&&zO.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},Ke=new We("y-sync"),hr=new We("y-undo"),ka=new We("yjs-cursor"),Ca=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!as(e.ds,t.id),UO=[{light:"#ecd44433",dark:"#ecd444"}],WO=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=or();t.forEach(i=>r.add(i)),e=e.filter(i=>!r.has(i))}t.set(n,t2(e))}return t.get(n)},qO=(t,{colors:e=UO,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:i=()=>{}}={})=>{let s=!1;const o=new je({props:{editable:l=>{const a=Ke.getState(l);return a.snapshot==null&&a.prevSnapshot==null}},key:Ke,state:{init:(l,a)=>({type:t,doc:t.doc,binding:null,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(l,a)=>{const c=l.getMeta(Ke);if(c!==void 0){a=Object.assign({},a);for(const u in c)a[u]=c[u]}return a.addToHistory=l.getMeta("addToHistory")!==!1,a.isChangeOrigin=c!==void 0&&!!c.isChangeOrigin,a.isUndoRedoOperation=c!==void 0&&!!c.isChangeOrigin&&!!c.isUndoRedoOperation,a.binding!==null&&c!==void 0&&(c.snapshot!=null||c.prevSnapshot!=null)&&$d(0,()=>{a.binding==null||a.binding.isDestroyed||(c.restore==null?a.binding._renderSnapshot(c.snapshot,c.prevSnapshot,a):(a.binding._renderSnapshot(c.snapshot,c.snapshot,a),delete a.restore,delete a.snapshot,delete a.prevSnapshot,a.binding.mux(()=>{a.binding._prosemirrorChanged(a.binding.prosemirrorView.state.doc)})))}),a}},view:l=>{const a=new JO(t,l);return a._forceRerender(),i(),{update:()=>{const c=o.getState(l.state);if(c.snapshot==null&&c.prevSnapshot==null&&(s||l.state.doc.content.findDiffStart(l.state.doc.type.createAndFill().content)!==null)){if(s=!0,c.addToHistory===!1&&!c.isChangeOrigin){const u=hr.getState(l.state),d=u&&u.undoManager;d&&d.stopCapturing()}a.mux(()=>{c.doc.transact(u=>{u.meta.set("addToHistory",c.addToHistory),a._prosemirrorChanged(l.state.doc)},Ke)})}},destroy:()=>{a.destroy()}}}});return o},KO=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null){const r=Uo(n.doc,n.type,e.anchor,n.mapping),i=Uo(n.doc,n.type,e.head,n.mapping);r!==null&&i!==null&&(t=t.setSelection(ce.create(t.doc,r,i)))}},kf=(t,e)=>({anchor:Aa(e.selection.anchor,t.type,t.mapping),head:Aa(e.selection.head,t.type,t.mapping)});class JO{constructor(e,n){this.type=e,this.prosemirrorView=n,this.mux=C0(),this.isDestroyed=!1,this.mapping=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&(this.beforeTransactionSelection=kf(this,n.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),e.observeDeep(this._observeFunction),this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(Pd&&this._domSelectionInView===null&&($d(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection(),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 i=n.getBoundingClientRect(),s=B2.documentElement;return i.bottom>=0&&i.right>=0&&i.left<=(window.innerWidth||s.clientWidth||0)&&i.top<=(window.innerHeight||s.clientHeight||0)}renderSnapshot(e,n){n||(n=z0(E0(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Ke,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping=new Map,this.mux(()=>{const e=this.type.toArray().map(r=>Sa(r,this.prosemirrorView.state.schema,this.mapping)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Y(W.from(e),0,0));n.setMeta(Ke,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping=new Map,this.mux(()=>{const e=this.type.toArray().map(r=>Sa(r,this.prosemirrorView.state.schema,this.mapping)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Y(W.from(e),0,0));this.prosemirrorView.dispatch(n.setMeta(Ke,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){e||(e=EM(this.doc)),this.mapping=new Map,this.mux(()=>{this.doc.transact(i=>{const s=r.permanentUserData;s&&s.dss.forEach(c=>{Pr(i,c,u=>{})});const o=(c,u)=>{const d=c==="added"?s.getUserByClientId(u.client):s.getUserByDeletedId(u);return{user:d,type:c,color:WO(r.colorMapping,r.colors,d)}},l=sb(this.type,new Xd(n.ds,e.sv)).map(c=>!c._item.deleted||Ca(c._item,e)||Ca(c._item,n)?Sa(c,this.prosemirrorView.state.schema,new Map,e,n,o):null).filter(c=>c!==null),a=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Y(W.from(l),0,0));this.prosemirrorView.dispatch(a.setMeta(Ke,{isChangeOrigin:!0}))},Ke)})}_typeChanged(e,n){const r=Ke.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const i=(l,a)=>this.mapping.delete(a);Pr(n,n.deleteSet,l=>{if(l.constructor===Ve){const a=l.content.type;a&&this.mapping.delete(a)}}),n.changed.forEach(i),n.changedParentTypes.forEach(i);const s=this.type.toArray().map(l=>jb(l,this.prosemirrorView.state.schema,this.mapping)).filter(l=>l!==null);let o=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Y(W.from(s),0,0));KO(o,this.beforeTransactionSelection,this),o=o.setMeta(Ke,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof Z0}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(e){this.doc.transact(()=>{Ef(this.doc,this.type,e,this.mapping),this.beforeTransactionSelection=kf(this,this.prosemirrorView.state)},Ke)}destroy(){this.isDestroyed=!0,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions)}}const jb=(t,e,n,r,i,s)=>{const o=n.get(t);if(o===void 0){if(t instanceof It)return Sa(t,e,n,r,i,s);throw kn()}return o},Sa=(t,e,n,r,i,s)=>{const o=[],l=a=>{if(a.constructor===It){const c=jb(a,e,n,r,i,s);c!==null&&o.push(c)}else{const c=GO(a,e,n,r,i,s);c!==null&&c.forEach(u=>{u!==null&&o.push(u)})}};r===void 0||i===void 0?t.toArray().forEach(l):sb(t,new Xd(i.ds,r.sv)).forEach(l);try{const a=t.getAttributes(r);r!==void 0&&(Ca(t._item,r)?Ca(t._item,i)||(a.ychange=s?s("added",t._item.id):{type:"added"}):a.ychange=s?s("removed",t._item.id):{type:"removed"});const c=e.node(t.nodeName,a,o);return n.set(t,c),c}catch{return t.doc.transact(c=>{t._item.delete(c)},Ke),n.delete(t),null}},GO=(t,e,n,r,i,s)=>{const o=[],l=t.toDelta(r,i,s);try{for(let a=0;a<l.length;a++){const c=l[a],u=[];for(const d in c.attributes)u.push(e.mark(d,c.attributes[d]));o.push(e.text(c.insert,u))}}catch{return t.doc.transact(c=>{t._item.delete(c)},Ke),null}return o},YO=(t,e)=>{const n=new Xt,r=t.map(i=>({insert:i.text,attributes:Ub(i.marks)}));return n.applyDelta(r),e.set(n,t),n},XO=(t,e)=>{const n=new It(t.type.name);for(const r in t.attrs){const i=t.attrs[r];i!==null&&r!=="ychange"&&n.setAttribute(r,i)}return n.insert(0,Ea(t).map(r=>Cf(r,e))),e.set(n,t),n},Cf=(t,e)=>t instanceof Array?YO(t,e):XO(t,e),Hb=t=>typeof t=="object"&&t!==null,Sf=(t,e)=>{const n=Object.keys(t).filter(i=>t[i]!==null);let r=n.length===Object.keys(e).filter(i=>e[i]!==null).length;for(let i=0;i<n.length&&r;i++){const s=n[i],o=t[s],l=e[s];r=s==="ychange"||o===l||Hb(o)&&Hb(l)&&Sf(o,l)}return r},Ea=t=>{const e=t.content.content,n=[];for(let r=0;r<e.length;r++){const i=e[r];if(i.isText){const s=[];for(let o=e[r];r<e.length&&o.isText;o=e[++r])s.push(o);r--,n.push(s)}else n.push(i)}return n},zb=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,i)=>r.insert===e[i].text&&Ld(r.attributes||{}).length===e[i].marks.length&&e[i].marks.every(s=>Sf(r.attributes[s.type.name]||{},s.attrs)))},zo=(t,e)=>{if(t instanceof It&&!(e instanceof Array)&&Tf(t,e)){const n=Ea(e);return t._length===n.length&&Sf(t.getAttributes(),e.attrs)&&t.toArray().every((r,i)=>zo(r,n[i]))}return t instanceof Xt&&e instanceof Array&&zb(t,e)},Ta=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),Vb=(t,e,n)=>{const r=t.toArray(),i=Ea(e),s=i.length,o=r.length,l=Ir(o,s);let a=0,c=0,u=!1;for(;a<l;a++){const d=r[a],f=i[a];if(Ta(n.get(d),f))u=!0;else if(!zo(d,f))break}for(;a+c<l;c++){const d=r[o-c-1],f=i[s-c-1];if(Ta(n.get(d),f))u=!0;else if(!zo(d,f))break}return{equalityFactor:a+c,foundMappedChild:u}},ZO=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof Cn?e+=n.content.str:n.content instanceof lt&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},QO=(t,e,n)=>{n.set(t,e);const{nAttrs:r,str:i}=ZO(t),s=e.map(c=>({insert:c.text,attributes:Object.assign({},r,Ub(c.marks))})),{insert:o,remove:l,index:a}=VO(i,s.map(c=>c.insert).join(""));t.delete(a,l),t.insert(a,o),t.applyDelta(s.map(c=>({retain:c.insert.length,attributes:c.attributes})))},Ub=t=>{const e={};return t.forEach(n=>{n.type.name!=="ychange"&&(e[n.type.name]=n.attrs)}),e},Ef=(t,e,n,r)=>{if(e instanceof It&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.set(e,n),e instanceof It){const d=e.getAttributes(),f=n.attrs;for(const h in f)f[h]!==null?d[h]!==f[h]&&h!=="ychange"&&e.setAttribute(h,f[h]):e.removeAttribute(h);for(const h in d)f[h]===void 0&&e.removeAttribute(h)}const i=Ea(n),s=i.length,o=e.toArray(),l=o.length,a=Ir(s,l);let c=0,u=0;for(;c<a;c++){const d=o[c],f=i[c];if(!Ta(r.get(d),f))if(zo(d,f))r.set(d,f);else break}for(;u+c+1<a;u++){const d=o[l-u-1],f=i[s-u-1];if(!Ta(r.get(d),f))if(zo(d,f))r.set(d,f);else break}t.transact(()=>{for(;l-c-u>0&&s-c-u>0;){const f=o[c],h=i[c],p=o[l-u-1],g=i[s-u-1];if(f instanceof Xt&&h instanceof Array)zb(f,h)||QO(f,h,r),c+=1;else{let v=f instanceof It&&Tf(f,h),w=p instanceof It&&Tf(p,g);if(v&&w){const S=Vb(f,h,r),x=Vb(p,g,r);S.foundMappedChild&&!x.foundMappedChild?w=!1:!S.foundMappedChild&&x.foundMappedChild||S.equalityFactor<x.equalityFactor?v=!1:w=!1}v?(Ef(t,f,h,r),c+=1):w?(Ef(t,p,g,r),u+=1):(r.delete(e.get(c)),e.delete(c,1),e.insert(c,[Cf(h,r)]),c+=1)}}const d=l-c-u;if(l===1&&s===0&&o[0]instanceof Xt?(r.delete(o[0]),o[0].delete(0,o[0].length)):d>0&&(e.slice(c,c+d).forEach(f=>r.delete(f)),e.delete(c,d)),c+u<s){const f=[];for(let h=c;h<s-u;h++)f.push(Cf(i[h],r));e.insert(c,f)}},Ke)},Tf=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name;let Vo=null;const e_=()=>{const t=Vo;Vo=null,t.forEach((e,n)=>{const r=n.state.tr,i=Ke.getState(n.state);i&&i.binding&&!i.binding.isDestroyed&&(e.forEach((s,o)=>{r.setMeta(o,s)}),n.dispatch(r))})},t_=(t,e,n)=>{Vo||(Vo=new Map,$d(0,e_)),Vt(Vo,t,Lt).set(e,n)},Aa=(t,e,n)=>{if(t===0)return Yd(e,0);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof Xt){if(r._length>=t)return Yd(r,t);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 i=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t<i)r=r._first.content.type,t--;else{if(t===1&&r._length===0&&i>1)return new Ro(r._item===null?null:r._item.id,r._item===null?No(r):null,null);if(t-=i,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 Ro(r._item===null?null:r._item.id,r._item===null?No(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 cn();if(t===0&&r.constructor!==Xt&&r!==e)return n_(r._item.parent,r._item)}return Yd(e,e._length)},n_=(t,e)=>{let n=null,r=null;return t._item===null?r=No(t):n=me(t._item.id.client,t._item.id.clock),new Ro(n,r,e.id)},Uo=(t,e,n,r)=>{const i=SM(n,t);if(i===null||i.type!==e&&!Do(e,i.type._item))return null;let s=i.type,o=0;if(s.constructor===Xt)o=i.index;else if(s._item===null||!s._item.deleted){let l=s._first,a=0;for(;a<s._length&&a<i.index&&l!==null;){if(!l.deleted){const c=l.content.type;a++,c instanceof Xt?o+=c._length:o+=r.get(c).nodeSize}l=l.right}o+=1}for(;s!==e&&s._item!==null;){const l=s._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===s)break;a.deleted||(c instanceof Xt?o+=c._length:o+=r.get(c).nodeSize),a=a.right}}s=l}return o-1},r_=(t,e,n)=>t!==e,i_=t=>{const e=document.createElement("span");e.classList.add("ProseMirror-yjs-cursor"),e.setAttribute("style",`border-color: ${t.color}`);const n=document.createElement("div");n.setAttribute("style",`background-color: ${t.color}`),n.insertBefore(document.createTextNode(t.name),null);const r=document.createTextNode(""),i=document.createTextNode("");return e.insertBefore(r,null),e.insertBefore(n,null),e.insertBefore(i,null),e},Wb=t=>({style:`background-color: ${t.color}70`,class:"ProseMirror-yjs-selection"}),s_=/^#[0-9a-fA-F]{6}$/,qb=(t,e,n,r,i)=>{const s=Ke.getState(t),o=s.doc,l=[];return s.snapshot!=null||s.prevSnapshot!=null||s.binding===null?He.create(t.doc,[]):(e.getStates().forEach((a,c)=>{if(n(o.clientID,c,a)&&a.cursor!=null){const u=a.user||{};u.color==null?u.color="#ffa500":s_.test(u.color)||console.warn("A user uses an unsupported color format",u),u.name==null&&(u.name=`User: ${c}`);let d=Uo(o,s.type,Lo(a.cursor.anchor),s.binding.mapping),f=Uo(o,s.type,Lo(a.cursor.head),s.binding.mapping);if(d!==null&&f!==null){const h=ar(t.doc.content.size-1,0);d=Ir(d,h),f=Ir(f,h),l.push(ut.widget(f,()=>r(u),{key:c+"",side:10}));const p=Ir(d,f),g=ar(d,f);l.push(ut.inline(p,g,i(u),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),He.create(t.doc,l))},o_=(t,{awarenessStateFilter:e=r_,cursorBuilder:n=i_,selectionBuilder:r=Wb,getSelection:i=o=>o.selection}={},s="cursor")=>new je({key:ka,state:{init(o,l){return qb(l,t,e,n,r)},apply(o,l,a,c){const u=Ke.getState(c),d=o.getMeta(ka);return u&&u.isChangeOrigin||d&&d.awarenessUpdated?qb(c,t,e,n,r):l.map(o.mapping,o.doc)}},props:{decorations:o=>ka.getState(o)},view:o=>{const l=()=>{o.docView&&t_(o,ka,{awarenessUpdated:!0})},a=()=>{const c=Ke.getState(o.state),u=t.getLocalState()||{};if(c.binding!=null)if(o.hasFocus()){const d=i(o.state),f=Aa(d.anchor,c.type,c.binding.mapping),h=Aa(d.head,c.type,c.binding.mapping);(u.cursor==null||!H0(Lo(u.cursor.anchor),f)||!H0(Lo(u.cursor.head),h))&&t.setLocalStateField(s,{anchor:f,head:h})}else u.cursor!=null&&Uo(c.doc,c.type,Lo(u.cursor.anchor),c.binding.mapping)!==null&&t.setLocalStateField(s,null)};return t.on("change",l),o.dom.addEventListener("focusin",a),o.dom.addEventListener("focusout",a),{update:a,destroy:()=>{o.dom.removeEventListener("focusin",a),o.dom.removeEventListener("focusout",a),t.off("change",l),t.setLocalStateField(s,null)}}}}),l_=t=>{const e=hr.getState(t).undoManager;if(e!=null)return e.undo(),!0},a_=t=>{const e=hr.getState(t).undoManager;if(e!=null)return e.redo(),!0},c_=new Set(["paragraph"]),u_=(t,e)=>!(t instanceof Ve)||!(t.content instanceof Sn)||!(t.content.type instanceof wi||t.content.type instanceof It&&e.has(t.content.type.nodeName))||t.content.type._length===0,d_=({protectedNodes:t=c_,trackedOrigins:e=[],undoManager:n=null}={})=>new je({key:hr,state:{init:(r,i)=>{const s=Ke.getState(i),o=n||new Z0(s.type,{trackedOrigins:new Set([Ke].concat(e)),deleteFilter:l=>u_(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,i,s,o)=>{const l=Ke.getState(o).binding,a=i.undoManager,c=a.undoStack.length>0,u=a.redoStack.length>0;return l?{undoManager:a,prevSel:kf(l,s),hasUndoOps:c,hasRedoOps:u}:c!==i.hasUndoOps||u!==i.hasRedoOps?Object.assign({},i,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):i}},view:r=>{const i=Ke.getState(r.state),s=hr.getState(r.state).undoManager;return s.on("stack-item-added",({stackItem:o})=>{const l=i.binding;l&&o.meta.set(l,hr.getState(r.state).prevSel)}),s.on("stack-item-popped",({stackItem:o})=>{const l=i.binding;l&&(l.beforeTransactionSelection=o.meta.get(l)||l.beforeTransactionSelection)}),{destroy:()=>{s.destroy()}}}}),f_=Ue.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null}},onCreate(){this.editor.extensionManager.extensions.find(t=>t.name==="history")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-history".')},addCommands(){return{undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),hr.getState(e).undoManager.undoStack.length===0?!1:n?l_(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),hr.getState(e).undoManager.redoStack.length===0?!1:n?a_(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=d_(),n=e.spec.view;e.spec.view=l=>{const{undoManager:a}=hr.getState(l.state);a.restore&&(a.restore(),a.restore=()=>{});const c=n?n(l):void 0;return{destroy:()=>{const u=a.trackedOrigins.has(a),d=a._observers;a.restore=()=>{u&&a.trackedOrigins.add(a),a.doc.on("afterTransaction",a.afterTransactionHandler),a._observers=d},c!=null&&c.destroy&&c.destroy()}}};const r=this.options.ySyncOptions,i=this.options.onFirstRender,s={...r?{...r}:{},...i?{onFirstRender:i}:{}};return[qO(t,s),e]}}),Kb=t=>Array.from(t.entries()).map(([e,n])=>({clientId:e,...n.user})),Jb=()=>null,h_=Ue.create({name:"collaborationCursor",addOptions(){return{provider:null,user:{name:null,color:null},render:t=>{const e=document.createElement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${t.color}`);const n=document.createElement("div");return n.classList.add("collaboration-cursor__label"),n.setAttribute("style",`background-color: ${t.color}`),n.insertBefore(document.createTextNode(t.name),null),e.insertBefore(n,null),e},selectionRender:Wb,onUpdate:Jb}},onCreate(){this.options.onUpdate!==Jb&&console.warn('[tiptap warn]: DEPRECATED: The "onUpdate" option is deprecated. Please use `editor.storage.collaborationCursor.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor')},addStorage(){return{users:[]}},addCommands(){return{updateUser:t=>()=>(this.options.user=t,this.options.provider.awareness.setLocalStateField("user",this.options.user),!0),user:t=>({editor:e})=>(console.warn('[tiptap warn]: DEPRECATED: The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor'),e.commands.updateUser(t))}},addProseMirrorPlugins(){return[o_((this.options.provider.awareness.setLocalStateField("user",this.options.user),this.storage.users=Kb(this.options.provider.awareness.states),this.options.provider.awareness.on("update",()=>{this.storage.users=Kb(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),p_=/^\s*>\s$/,m_=ze.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return["blockquote",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Gi({find:p_,type:this.type})]}}),g_=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,y_=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,b_=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,v_=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,w_=jt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return["strong",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ai({find:g_,type:this.type}),ai({find:b_,type:this.type})]},addPasteRules(){return[Rr({find:y_,type:this.type}),Rr({find:v_,type:this.type})]}}),x_=ze.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Ce(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Gb=jt.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=ao(t,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),Yb=/^\s*([-+*])\s$/,k_=ze.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",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(x_.name,this.editor.getAttributes(Gb.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Gi({find:Yb,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Gi({find:Yb,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Gb.name),editor:this.editor})),[t]}}),C_=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/,S_=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g,E_=jt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ai({find:C_,type:this.type})]},addPasteRules(){return[Rr({find:S_,type:this.type})]}}),T_=/^```([a-z]+)?[\s\n]$/,A_=/^~~~([a-z]+)?[\s\n]$/,M_=ze.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:null,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options,s=[...((e=t.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",Ce(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
391
376
|
|
392
|
-
`);return!s||!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:i,empty:s}=n;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const l=i.after();return l===void 0||r.nodeAt(l)?!1:t.commands.exitCode()}}},addInputRules(){return[
|
393
|
-
`)),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),Xb=ze.create({name:"doc",topNode:!0,content:"block+"});function
|
394
|
-
`},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:s}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&o){const d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),z_=ze.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]}`,Ce(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>qu({find:new RegExp(`^(#{1,${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var _a=200,vt=function(){};vt.prototype.append=function(e){return e.length?(e=vt.from(e),!this.length&&e||e.length<_a&&this.leafAppend(e)||this.length<_a&&e.leafPrepend(this)||this.appendInner(e)):this},vt.prototype.prepend=function(e){return e.length?vt.from(e).append(this):this},vt.prototype.appendInner=function(e){return new V_(this,e)},vt.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?vt.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))},vt.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},vt.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)},vt.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},n,r),i},vt.from=function(e){return e instanceof vt?e:e&&e.length?new ev(e):vt.empty};var ev=function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var a=s;a<o;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,l){for(var a=s-1;a>=o;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=_a)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=_a)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(vt);vt.empty=new ev([]);var V_=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,i,s,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(i,l),s,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(vt);const U_=500;class En{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;n&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){i||(i=this.remapping(r,f+1),s=i.maps.length),s--,u.push(d);return}if(i){u.push(new Un(d.map));let h=d.step.map(i.slice(s)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Un(p,void 0,void 0,c.length+u.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(d.step);if(d.selection)return l=i?d.selection.map(i.slice(s)):d.selection,a=new En(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,i){let s=[],o=this.eventCount,l=this.items,a=!i&&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]),f=new Un(e.mapping.maps[u],d,n),h;(h=a&&a.merge(f))&&(f=h,u?s.pop():l=l.slice(0,l.length-1)),s.push(f),n&&(o++,n=void 0),i||(a=f)}let c=o-r.depth;return c>q_&&(l=W_(l,c),o-=c),new En(l.append(s),o)}remapping(e,n){let r=new Li;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new En(this.items.append(e.map(n=>new Un(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let a=n;this.items.forEach(f=>{let h=s.getMirror(--a);if(h==null)return;o=Math.min(o,h);let p=s.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),v=f.selection&&f.selection.map(s.slice(a+1,h));v&&l++,r.push(new Un(p,g,v))}else r.push(new Un(p))},i);let c=[];for(let f=n;f<o;f++)c.push(new Un(s.maps[f]));let u=this.items.slice(0,i).append(c).append(r),d=new En(u,l);return d.emptyItemCount()>U_&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;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&&s++;let d=new Un(c.invert(),a,u),f,h=i.length-1;(f=i.length&&i[h].merge(d))?i[h]=f:i.push(d)}}else o.map&&r--},this.items.length,0),new En(vt.from(i.reverse()),s)}}En.empty=new En(vt.empty,0);function W_(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Un{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Un(n.getMap().invert(),n,this.selection)}}}class jr{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const q_=20;function K_(t,e,n,r){let i=n.getMeta(Ei),s;if(i)return i.historyState;n.getMeta(Y_)&&(t=new jr(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Ei))return o.getMeta(Ei).redo?new jr(t.done.addTransform(n,void 0,r,Na(e)),t.undone,tv(n.mapping.maps[n.steps.length-1]),t.prevTime,t.prevComposition):new jr(t.done,t.undone.addTransform(n,void 0,r,Na(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||!J_(n,t.prevRanges)),c=o?Of(t.prevRanges,n.mapping):tv(n.mapping.maps[n.steps.length-1]);return new jr(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,Na(e)),En.empty,c,n.time,l??t.prevComposition)}else return(s=n.getMeta("rebased"))?new jr(t.done.rebased(n,s),t.undone.rebased(n,s),Of(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new jr(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Of(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function J_(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(n=!0)}),n}function tv(t){let e=[];return t.forEach((n,r,i,s)=>e.push(i,s)),e}function Of(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),s=e.map(t[r+1],-1);i<=s&&n.push(i,s)}return n}function G_(t,e,n){let r=Na(e),i=Ei.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),a=new jr(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(Ei,{redo:n,historyState:a})}let _f=!1,nv=null;function Na(t){let e=t.plugins;if(nv!=e){_f=!1,nv=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){_f=!0;break}}return _f}const Ei=new We("history"),Y_=new We("closeHistory");function X_(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new je({key:Ei,state:{init(){return new jr(En.empty,En.empty,null,0,-1)},apply(e,n,r){return K_(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?iv:r=="historyRedo"?sv:null;return i?(n.preventDefault(),i(e.state,e.dispatch)):!1}}}})}function rv(t,e){return(n,r)=>{let i=Ei.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=G_(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const iv=rv(!1,!0),sv=rv(!0,!0),Z_=Ue.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>iv(t,e),redo:()=>({state:t,dispatch:e})=>sv(t,e)}},addProseMirrorPlugins(){return[X_(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()}}}),ov=ze.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Ce(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{const{$to:n}=e.selection,r=t();return n.parentOffset===0?r.insertContentAt(Math.max(n.pos-2,0),{type:this.name}):r.insertContent({type:this.name}),r.command(({tr:i,dispatch:s})=>{var o;if(s){const{$to:l}=i.selection,a=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?i.setSelection(ce.create(i.doc,l.pos+1)):l.nodeAfter.isBlock?i.setSelection(se.create(i.doc,l.pos)):i.setSelection(ce.create(i.doc,l.pos));else{const c=(o=l.parent.type.contentMatch.defaultType)===null||o===void 0?void 0:o.create();c&&(i.insert(a,c),i.setSelection(ce.create(i.doc,a+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Wu({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Q_=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,eN=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,tN=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,nN=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,rN=jt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ai({find:Q_,type:this.type}),ai({find:tN,type:this.type})]},addPasteRules(){return[Rr({find:eN,type:this.type}),Rr({find:nN,type:this.type})]}}),iN=ze.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Ce(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),sN=ze.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Ce(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),lv=jt.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=ao(t,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),av=/^(\d+)\.\s$/,oN=ze.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",Ce(this.options.HTMLAttributes,n),0]:["ol",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(sN.name,this.editor.getAttributes(lv.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Gi({find:av,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=Gi({find:av,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(lv.name)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),lN=ze.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),aN=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,cN=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,uN=jt.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",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ai({find:aN,type:this.type})]},addPasteRules(){return[Rr({find:cN,type:this.type})]}}),dN=ze.create({name:"text",group:"inline"}),fN=Ue.create({name:"starterKit",addExtensions(){var t,e,n,r,i,s,o,l,a,c,u,d,f,h,p,g,v,w;const S=[];return this.options.blockquote!==!1&&S.push(b_.configure((t=this.options)===null||t===void 0?void 0:t.blockquote)),this.options.bold!==!1&&S.push(C_.configure((e=this.options)===null||e===void 0?void 0:e.bold)),this.options.bulletList!==!1&&S.push(E_.configure((n=this.options)===null||n===void 0?void 0:n.bulletList)),this.options.code!==!1&&S.push(M_.configure((r=this.options)===null||r===void 0?void 0:r.code)),this.options.codeBlock!==!1&&S.push(N_.configure((i=this.options)===null||i===void 0?void 0:i.codeBlock)),this.options.document!==!1&&S.push(Xb.configure((s=this.options)===null||s===void 0?void 0:s.document)),this.options.dropcursor!==!1&&S.push(Zb.configure((o=this.options)===null||o===void 0?void 0:o.dropcursor)),this.options.gapcursor!==!1&&S.push(Qb.configure((l=this.options)===null||l===void 0?void 0:l.gapcursor)),this.options.hardBreak!==!1&&S.push(H_.configure((a=this.options)===null||a===void 0?void 0:a.hardBreak)),this.options.heading!==!1&&S.push(z_.configure((c=this.options)===null||c===void 0?void 0:c.heading)),this.options.history!==!1&&S.push(Z_.configure((u=this.options)===null||u===void 0?void 0:u.history)),this.options.horizontalRule!==!1&&S.push(ov.configure((d=this.options)===null||d===void 0?void 0:d.horizontalRule)),this.options.italic!==!1&&S.push(rN.configure((f=this.options)===null||f===void 0?void 0:f.italic)),this.options.listItem!==!1&&S.push(iN.configure((h=this.options)===null||h===void 0?void 0:h.listItem)),this.options.orderedList!==!1&&S.push(oN.configure((p=this.options)===null||p===void 0?void 0:p.orderedList)),this.options.paragraph!==!1&&S.push(lN.configure((g=this.options)===null||g===void 0?void 0:g.paragraph)),this.options.strike!==!1&&S.push(uN.configure((v=this.options)===null||v===void 0?void 0:v.strike)),this.options.text!==!1&&S.push(dN.configure((w=this.options)===null||w===void 0?void 0:w.text)),S}}),hN=jt.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=ao(t,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),pN=Ue.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>{var e;return(e=t.style.fontFamily)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily.split(",").map(e=>CSS.escape(e.trim())).join(", ")}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),mN=Ue.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:"left"}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>t.style.textAlign||this.options.defaultAlignment,renderHTML:t=>t.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${t.textAlign}`}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).every(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(e=>e)}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),gN="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4vianca6w0s2x0a2z0ure5ba0by2idu3namex3narepublic11d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0cast4mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dabur3d1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0ardian6cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster6d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2tura4vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9dnavy5lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0a1b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp2w2ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4finity6ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",yN="ελ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",vs=(t,e)=>{for(const n in e)t[n]=e[n];return t},Nf="numeric",Df="ascii",Rf="alpha",Da="asciinumeric",Ra="alphanumeric",Lf="domain",cv="emoji",bN="scheme",vN="slashscheme",uv="whitespace";function wN(t,e){return t in e||(e[t]=[]),e[t]}function Ti(t,e,n){e[Nf]&&(e[Da]=!0,e[Ra]=!0),e[Df]&&(e[Da]=!0,e[Rf]=!0),e[Da]&&(e[Ra]=!0),e[Rf]&&(e[Ra]=!0),e[Ra]&&(e[Lf]=!0),e[cv]&&(e[Lf]=!0);for(const r in e){const i=wN(r,n);i.indexOf(t)<0&&i.push(t)}}function xN(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Wt(t){t===void 0&&(t=null),this.j={},this.jr=[],this.jd=null,this.t=t}Wt.groups={},Wt.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 i=e.jr[r][0],s=e.jr[r][1];if(s&&i.test(t))return s}return e.jd},has(t,e){return e===void 0&&(e=!1),e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||Wt.groups;let i;return e&&e.j?i=e:(i=new Wt(e),n&&r&&Ti(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const s=t.length;if(!s)return i;for(let o=0;o<s-1;o++)i=i.tt(t[o]);return i.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||Wt.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const s=e;let o,l=i.go(t);if(l?(o=new Wt,vs(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new Wt,s){if(r)if(o.t&&typeof o.t=="string"){const a=vs(xN(o.t,r),n);Ti(s,a,r)}else n&&Ti(s,n,r);o.t=s}return i.j[t]=o,o}};const xe=(t,e,n,r,i)=>t.ta(e,n,r,i),hn=(t,e,n,r,i)=>t.tr(e,n,r,i),dv=(t,e,n,r,i)=>t.ts(e,n,r,i),X=(t,e,n,r,i)=>t.tt(e,n,r,i),pr="WORD",If="UWORD",Wo="LOCALHOST",Pf="TLD",Ff="UTLD",La="SCHEME",ws="SLASH_SCHEME",$f="NUM",fv="WS",Bf="NL",qo="OPENBRACE",Ko="CLOSEBRACE",Ia="OPENBRACKET",Pa="CLOSEBRACKET",Fa="OPENPAREN",$a="CLOSEPAREN",Ba="OPENANGLEBRACKET",ja="CLOSEANGLEBRACKET",Ha="FULLWIDTHLEFTPAREN",za="FULLWIDTHRIGHTPAREN",Va="LEFTCORNERBRACKET",Ua="RIGHTCORNERBRACKET",Wa="LEFTWHITECORNERBRACKET",qa="RIGHTWHITECORNERBRACKET",Ka="FULLWIDTHLESSTHAN",Ja="FULLWIDTHGREATERTHAN",Ga="AMPERSAND",Ya="APOSTROPHE",Xa="ASTERISK",Hr="AT",Za="BACKSLASH",Qa="BACKTICK",ec="CARET",zr="COLON",jf="COMMA",tc="DOLLAR",Wn="DOT",nc="EQUALS",Hf="EXCLAMATION",qn="HYPHEN",rc="PERCENT",ic="PIPE",sc="PLUS",oc="POUND",lc="QUERY",zf="QUOTE",Vf="SEMI",Kn="SLASH",Jo="TILDE",ac="UNDERSCORE",hv="EMOJI",cc="SYM";var pv=Object.freeze({__proto__:null,WORD:pr,UWORD:If,LOCALHOST:Wo,TLD:Pf,UTLD:Ff,SCHEME:La,SLASH_SCHEME:ws,NUM:$f,WS:fv,NL:Bf,OPENBRACE:qo,CLOSEBRACE:Ko,OPENBRACKET:Ia,CLOSEBRACKET:Pa,OPENPAREN:Fa,CLOSEPAREN:$a,OPENANGLEBRACKET:Ba,CLOSEANGLEBRACKET:ja,FULLWIDTHLEFTPAREN:Ha,FULLWIDTHRIGHTPAREN:za,LEFTCORNERBRACKET:Va,RIGHTCORNERBRACKET:Ua,LEFTWHITECORNERBRACKET:Wa,RIGHTWHITECORNERBRACKET:qa,FULLWIDTHLESSTHAN:Ka,FULLWIDTHGREATERTHAN:Ja,AMPERSAND:Ga,APOSTROPHE:Ya,ASTERISK:Xa,AT:Hr,BACKSLASH:Za,BACKTICK:Qa,CARET:ec,COLON:zr,COMMA:jf,DOLLAR:tc,DOT:Wn,EQUALS:nc,EXCLAMATION:Hf,HYPHEN:qn,PERCENT:rc,PIPE:ic,PLUS:sc,POUND:oc,QUERY:lc,QUOTE:zf,SEMI:Vf,SLASH:Kn,TILDE:Jo,UNDERSCORE:ac,EMOJI:hv,SYM:cc});const xs=/[a-z]/,Uf=new RegExp("\\p{L}","u"),Wf=new RegExp("\\p{Emoji}","u"),qf=/\d/,mv=/\s/,gv=`
|
395
|
-
`,
|
377
|
+
`);return!s||!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:i,empty:s}=n;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const l=i.after();return l===void 0||r.nodeAt(l)?!1:t.commands.exitCode()}}},addInputRules(){return[Wu({find:T_,type:this.type,getAttributes:t=>({language:t[1]})}),Wu({find:A_,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new je({key:new We("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),i=r?JSON.parse(r):void 0,s=i==null?void 0:i.mode;if(!n||!s)return!1;const{tr:o}=t.state;return t.state.selection.from===t.state.doc.nodeSize-(1+t.state.selection.$to.depth*2)?o.insert(t.state.selection.from-1,this.type.create({language:s})):o.replaceSelectionWith(this.type.create({language:s})),o.setSelection(ce.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.insertText(n.replace(/\r\n?/g,`
|
378
|
+
`)),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),Xb=ze.create({name:"doc",topNode:!0,content:"block+"});function O_(t={}){return new je({view(e){return new __(e,t)}})}class __{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r;if(n){let l=e.nodeBefore,a=e.nodeAfter;if(l||a){let c=this.editorView.nodeDOM(this.cursorPos-(l?l.nodeSize:0));if(c){let u=c.getBoundingClientRect(),d=l?u.bottom:u.top;l&&a&&(d=(d+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:u.left,right:u.right,top:d-this.width/2,bottom:d+this.width/2}}}}if(!r){let l=this.editorView.coordsAtPos(this.cursorPos);r={left:l.left-this.width/2,right:l.left+this.width/2,top:l.top,bottom:l.bottom}}let i=this.editorView.dom.offsetParent;this.element||(this.element=i.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let s,o;if(!i||i==document.body&&getComputedStyle(i).position=="static")s=-pageXOffset,o=-pageYOffset;else{let l=i.getBoundingClientRect();s=l.left-i.scrollLeft,o=l.top-i.scrollTop}this.element.style.left=r.left-s+"px",this.element.style.top=r.top-o+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,n,e):i;if(n&&!s){let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=bp(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){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}}const Zb=Ue.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[O_(this.options)]}});class Qe extends ue{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Qe.valid(r)?new Qe(r):ue.near(r)}content(){return Y.empty}eq(e){return e instanceof Qe&&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 Qe(e.resolve(n.pos))}getBookmark(){return new Af(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!N_(e)||!D_(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Qe.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=n;let a=e.doc.resolve(i);if(Qe.valid(a))return a}for(;;){let o=n>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!se.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),r=!1;continue e}break}s=o,i+=n;let l=e.doc.resolve(i);if(Qe.valid(l))return l}return null}}}Qe.prototype.visible=!1,Qe.findFrom=Qe.findGapCursorFrom,ue.jsonID("gapcursor",Qe);class Af{constructor(e){this.pos=e}map(e){return new Af(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Qe.valid(n)?new Qe(n):ue.near(n)}}function N_(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function D_(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function R_(){return new je({props:{decorations:F_,createSelectionBetween(t,e,n){return e.pos==n.pos&&Qe.valid(n)?new Qe(n):null},handleClick:I_,handleKeyDown:L_,handleDOMEvents:{beforeinput:P_}}})}const L_=Mu({ArrowLeft:Ma("horiz",-1),ArrowRight:Ma("horiz",1),ArrowUp:Ma("vert",-1),ArrowDown:Ma("vert",1)});function Ma(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof ce){if(!s.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=Qe.findGapCursorFrom(l,e,a);return c?(i&&i(r.tr.setSelection(new Qe(c))),!0):!1}}function I_(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Qe.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&se.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Qe(r))),!0)}function P_(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Qe))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=W.empty;for(let o=r.length-1;o>=0;o--)i=W.from(r[o].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new Y(i,0,0));return s.setSelection(ce.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function F_(t){if(!(t.selection instanceof Qe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",He.create(t.doc,[ut.widget(t.selection.head,e,{key:"gapcursor"})])}const Qb=Ue.create({name:"gapCursor",addProseMirrorPlugins(){return[R_()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=be(re(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),$_=ze.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",Ce(this.options.HTMLAttributes,t)]},renderText(){return`
|
379
|
+
`},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:s}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,a=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&o){const d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),B_=ze.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]}`,Ce(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Wu({find:new RegExp(`^(#{1,${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var Oa=200,vt=function(){};vt.prototype.append=function(e){return e.length?(e=vt.from(e),!this.length&&e||e.length<Oa&&this.leafAppend(e)||this.length<Oa&&e.leafPrepend(this)||this.appendInner(e)):this},vt.prototype.prepend=function(e){return e.length?vt.from(e).append(this):this},vt.prototype.appendInner=function(e){return new j_(this,e)},vt.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?vt.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))},vt.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},vt.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)},vt.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},n,r),i},vt.from=function(e){return e instanceof vt?e:e&&e.length?new ev(e):vt.empty};var ev=function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var a=s;a<o;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,l){for(var a=s-1;a>=o;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Oa)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Oa)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(vt);vt.empty=new ev([]);var j_=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,i,s,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(i,l),s,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(vt);const H_=500;class En{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;n&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){i||(i=this.remapping(r,f+1),s=i.maps.length),s--,u.push(d);return}if(i){u.push(new Un(d.map));let h=d.step.map(i.slice(s)),p;h&&o.maybeStep(h).doc&&(p=o.mapping.maps[o.mapping.maps.length-1],c.push(new Un(p,void 0,void 0,c.length+u.length))),s--,p&&i.appendMap(p,s)}else o.maybeStep(d.step);if(d.selection)return l=i?d.selection.map(i.slice(s)):d.selection,a=new En(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,i){let s=[],o=this.eventCount,l=this.items,a=!i&&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]),f=new Un(e.mapping.maps[u],d,n),h;(h=a&&a.merge(f))&&(f=h,u?s.pop():l=l.slice(0,l.length-1)),s.push(f),n&&(o++,n=void 0),i||(a=f)}let c=o-r.depth;return c>V_&&(l=z_(l,c),o-=c),new En(l.append(s),o)}remapping(e,n){let r=new Li;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new En(this.items.append(e.map(n=>new Un(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let a=n;this.items.forEach(f=>{let h=s.getMirror(--a);if(h==null)return;o=Math.min(o,h);let p=s.maps[h];if(f.step){let g=e.steps[h].invert(e.docs[h]),v=f.selection&&f.selection.map(s.slice(a+1,h));v&&l++,r.push(new Un(p,g,v))}else r.push(new Un(p))},i);let c=[];for(let f=n;f<o;f++)c.push(new Un(s.maps[f]));let u=this.items.slice(0,i).append(c).append(r),d=new En(u,l);return d.emptyItemCount()>H_&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;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&&s++;let d=new Un(c.invert(),a,u),f,h=i.length-1;(f=i.length&&i[h].merge(d))?i[h]=f:i.push(d)}}else o.map&&r--},this.items.length,0),new En(vt.from(i.reverse()),s)}}En.empty=new En(vt.empty,0);function z_(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Un{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Un(n.getMap().invert(),n,this.selection)}}}class jr{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const V_=20;function U_(t,e,n,r){let i=n.getMeta(Ei),s;if(i)return i.historyState;n.getMeta(K_)&&(t=new jr(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Ei))return o.getMeta(Ei).redo?new jr(t.done.addTransform(n,void 0,r,_a(e)),t.undone,tv(n.mapping.maps[n.steps.length-1]),t.prevTime,t.prevComposition):new jr(t.done,t.undone.addTransform(n,void 0,r,_a(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||!W_(n,t.prevRanges)),c=o?Mf(t.prevRanges,n.mapping):tv(n.mapping.maps[n.steps.length-1]);return new jr(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,_a(e)),En.empty,c,n.time,l??t.prevComposition)}else return(s=n.getMeta("rebased"))?new jr(t.done.rebased(n,s),t.undone.rebased(n,s),Mf(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new jr(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Mf(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function W_(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(n=!0)}),n}function tv(t){let e=[];return t.forEach((n,r,i,s)=>e.push(i,s)),e}function Mf(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),s=e.map(t[r+1],-1);i<=s&&n.push(i,s)}return n}function q_(t,e,n){let r=_a(e),i=Ei.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),a=new jr(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(Ei,{redo:n,historyState:a})}let Of=!1,nv=null;function _a(t){let e=t.plugins;if(nv!=e){Of=!1,nv=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Of=!0;break}}return Of}const Ei=new We("history"),K_=new We("closeHistory");function J_(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new je({key:Ei,state:{init(){return new jr(En.empty,En.empty,null,0,-1)},apply(e,n,r){return U_(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?iv:r=="historyRedo"?sv:null;return i?(n.preventDefault(),i(e.state,e.dispatch)):!1}}}})}function rv(t,e){return(n,r)=>{let i=Ei.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=q_(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const iv=rv(!1,!0),sv=rv(!0,!0),G_=Ue.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>iv(t,e),redo:()=>({state:t,dispatch:e})=>sv(t,e)}},addProseMirrorPlugins(){return[J_(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()}}}),ov=ze.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",Ce(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{const{$to:n}=e.selection,r=t();return n.parentOffset===0?r.insertContentAt(Math.max(n.pos-2,0),{type:this.name}):r.insertContent({type:this.name}),r.command(({tr:i,dispatch:s})=>{var o;if(s){const{$to:l}=i.selection,a=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?i.setSelection(ce.create(i.doc,l.pos+1)):l.nodeAfter.isBlock?i.setSelection(se.create(i.doc,l.pos)):i.setSelection(ce.create(i.doc,l.pos));else{const c=(o=l.parent.type.contentMatch.defaultType)===null||o===void 0?void 0:o.create();c&&(i.insert(a,c),i.setSelection(ce.create(i.doc,a+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Uu({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Y_=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,X_=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Z_=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Q_=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,eN=jt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ai({find:Y_,type:this.type}),ai({find:Z_,type:this.type})]},addPasteRules(){return[Rr({find:X_,type:this.type}),Rr({find:Q_,type:this.type})]}}),tN=ze.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Ce(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),nN=ze.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",Ce(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),lv=jt.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=ao(t,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),av=/^(\d+)\.\s$/,rN=ze.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",Ce(this.options.HTMLAttributes,n),0]:["ol",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(nN.name,this.editor.getAttributes(lv.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Gi({find:av,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=Gi({find:av,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(lv.name)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),iN=ze.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),sN=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,oN=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,lN=jt.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",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ai({find:sN,type:this.type})]},addPasteRules(){return[Rr({find:oN,type:this.type})]}}),aN=ze.create({name:"text",group:"inline"}),cN=Ue.create({name:"starterKit",addExtensions(){var t,e,n,r,i,s,o,l,a,c,u,d,f,h,p,g,v,w;const S=[];return this.options.blockquote!==!1&&S.push(m_.configure((t=this.options)===null||t===void 0?void 0:t.blockquote)),this.options.bold!==!1&&S.push(w_.configure((e=this.options)===null||e===void 0?void 0:e.bold)),this.options.bulletList!==!1&&S.push(k_.configure((n=this.options)===null||n===void 0?void 0:n.bulletList)),this.options.code!==!1&&S.push(E_.configure((r=this.options)===null||r===void 0?void 0:r.code)),this.options.codeBlock!==!1&&S.push(M_.configure((i=this.options)===null||i===void 0?void 0:i.codeBlock)),this.options.document!==!1&&S.push(Xb.configure((s=this.options)===null||s===void 0?void 0:s.document)),this.options.dropcursor!==!1&&S.push(Zb.configure((o=this.options)===null||o===void 0?void 0:o.dropcursor)),this.options.gapcursor!==!1&&S.push(Qb.configure((l=this.options)===null||l===void 0?void 0:l.gapcursor)),this.options.hardBreak!==!1&&S.push($_.configure((a=this.options)===null||a===void 0?void 0:a.hardBreak)),this.options.heading!==!1&&S.push(B_.configure((c=this.options)===null||c===void 0?void 0:c.heading)),this.options.history!==!1&&S.push(G_.configure((u=this.options)===null||u===void 0?void 0:u.history)),this.options.horizontalRule!==!1&&S.push(ov.configure((d=this.options)===null||d===void 0?void 0:d.horizontalRule)),this.options.italic!==!1&&S.push(eN.configure((f=this.options)===null||f===void 0?void 0:f.italic)),this.options.listItem!==!1&&S.push(tN.configure((h=this.options)===null||h===void 0?void 0:h.listItem)),this.options.orderedList!==!1&&S.push(rN.configure((p=this.options)===null||p===void 0?void 0:p.orderedList)),this.options.paragraph!==!1&&S.push(iN.configure((g=this.options)===null||g===void 0?void 0:g.paragraph)),this.options.strike!==!1&&S.push(lN.configure((v=this.options)===null||v===void 0?void 0:v.strike)),this.options.text!==!1&&S.push(aN.configure((w=this.options)===null||w===void 0?void 0:w.text)),S}}),uN=jt.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:t=>t.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["span",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=ao(t,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),dN=Ue.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>{var e;return(e=t.style.fontFamily)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily.split(",").map(e=>CSS.escape(e.trim())).join(", ")}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),fN=Ue.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:"left"}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>t.style.textAlign||this.options.defaultAlignment,renderHTML:t=>t.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${t.textAlign}`}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).every(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(e=>e)}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),hN="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4vianca6w0s2x0a2z0ure5ba0by2idu3namex3narepublic11d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0cast4mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dabur3d1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0ardian6cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster6d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2tura4vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9dnavy5lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0a1b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp2w2ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4finity6ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",pN="ελ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",vs=(t,e)=>{for(const n in e)t[n]=e[n];return t},_f="numeric",Nf="ascii",Df="alpha",Na="asciinumeric",Da="alphanumeric",Rf="domain",cv="emoji",mN="scheme",gN="slashscheme",uv="whitespace";function yN(t,e){return t in e||(e[t]=[]),e[t]}function Ti(t,e,n){e[_f]&&(e[Na]=!0,e[Da]=!0),e[Nf]&&(e[Na]=!0,e[Df]=!0),e[Na]&&(e[Da]=!0),e[Df]&&(e[Da]=!0),e[Da]&&(e[Rf]=!0),e[cv]&&(e[Rf]=!0);for(const r in e){const i=yN(r,n);i.indexOf(t)<0&&i.push(t)}}function bN(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Wt(t){t===void 0&&(t=null),this.j={},this.jr=[],this.jd=null,this.t=t}Wt.groups={},Wt.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 i=e.jr[r][0],s=e.jr[r][1];if(s&&i.test(t))return s}return e.jd},has(t,e){return e===void 0&&(e=!1),e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||Wt.groups;let i;return e&&e.j?i=e:(i=new Wt(e),n&&r&&Ti(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const s=t.length;if(!s)return i;for(let o=0;o<s-1;o++)i=i.tt(t[o]);return i.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||Wt.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const s=e;let o,l=i.go(t);if(l?(o=new Wt,vs(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new Wt,s){if(r)if(o.t&&typeof o.t=="string"){const a=vs(bN(o.t,r),n);Ti(s,a,r)}else n&&Ti(s,n,r);o.t=s}return i.j[t]=o,o}};const xe=(t,e,n,r,i)=>t.ta(e,n,r,i),hn=(t,e,n,r,i)=>t.tr(e,n,r,i),dv=(t,e,n,r,i)=>t.ts(e,n,r,i),X=(t,e,n,r,i)=>t.tt(e,n,r,i),pr="WORD",Lf="UWORD",Wo="LOCALHOST",If="TLD",Pf="UTLD",Ra="SCHEME",ws="SLASH_SCHEME",Ff="NUM",fv="WS",$f="NL",qo="OPENBRACE",Ko="CLOSEBRACE",La="OPENBRACKET",Ia="CLOSEBRACKET",Pa="OPENPAREN",Fa="CLOSEPAREN",$a="OPENANGLEBRACKET",Ba="CLOSEANGLEBRACKET",ja="FULLWIDTHLEFTPAREN",Ha="FULLWIDTHRIGHTPAREN",za="LEFTCORNERBRACKET",Va="RIGHTCORNERBRACKET",Ua="LEFTWHITECORNERBRACKET",Wa="RIGHTWHITECORNERBRACKET",qa="FULLWIDTHLESSTHAN",Ka="FULLWIDTHGREATERTHAN",Ja="AMPERSAND",Ga="APOSTROPHE",Ya="ASTERISK",Hr="AT",Xa="BACKSLASH",Za="BACKTICK",Qa="CARET",zr="COLON",Bf="COMMA",ec="DOLLAR",Wn="DOT",tc="EQUALS",jf="EXCLAMATION",qn="HYPHEN",nc="PERCENT",rc="PIPE",ic="PLUS",sc="POUND",oc="QUERY",Hf="QUOTE",zf="SEMI",Kn="SLASH",Jo="TILDE",lc="UNDERSCORE",hv="EMOJI",ac="SYM";var pv=Object.freeze({__proto__:null,WORD:pr,UWORD:Lf,LOCALHOST:Wo,TLD:If,UTLD:Pf,SCHEME:Ra,SLASH_SCHEME:ws,NUM:Ff,WS:fv,NL:$f,OPENBRACE:qo,CLOSEBRACE:Ko,OPENBRACKET:La,CLOSEBRACKET:Ia,OPENPAREN:Pa,CLOSEPAREN:Fa,OPENANGLEBRACKET:$a,CLOSEANGLEBRACKET:Ba,FULLWIDTHLEFTPAREN:ja,FULLWIDTHRIGHTPAREN:Ha,LEFTCORNERBRACKET:za,RIGHTCORNERBRACKET:Va,LEFTWHITECORNERBRACKET:Ua,RIGHTWHITECORNERBRACKET:Wa,FULLWIDTHLESSTHAN:qa,FULLWIDTHGREATERTHAN:Ka,AMPERSAND:Ja,APOSTROPHE:Ga,ASTERISK:Ya,AT:Hr,BACKSLASH:Xa,BACKTICK:Za,CARET:Qa,COLON:zr,COMMA:Bf,DOLLAR:ec,DOT:Wn,EQUALS:tc,EXCLAMATION:jf,HYPHEN:qn,PERCENT:nc,PIPE:rc,PLUS:ic,POUND:sc,QUERY:oc,QUOTE:Hf,SEMI:zf,SLASH:Kn,TILDE:Jo,UNDERSCORE:lc,EMOJI:hv,SYM:ac});const xs=/[a-z]/,Vf=new RegExp("\\p{L}","u"),Uf=new RegExp("\\p{Emoji}","u"),Wf=/\d/,mv=/\s/,gv=`
|
380
|
+
`,vN="️",wN="";let cc=null,uc=null;function xN(t){t===void 0&&(t=[]);const e={};Wt.groups=e;const n=new Wt;cc==null&&(cc=yv(hN)),uc==null&&(uc=yv(pN)),X(n,"'",Ga),X(n,"{",qo),X(n,"}",Ko),X(n,"[",La),X(n,"]",Ia),X(n,"(",Pa),X(n,")",Fa),X(n,"<",$a),X(n,">",Ba),X(n,"(",ja),X(n,")",Ha),X(n,"「",za),X(n,"」",Va),X(n,"『",Ua),X(n,"』",Wa),X(n,"<",qa),X(n,">",Ka),X(n,"&",Ja),X(n,"*",Ya),X(n,"@",Hr),X(n,"`",Za),X(n,"^",Qa),X(n,":",zr),X(n,",",Bf),X(n,"$",ec),X(n,".",Wn),X(n,"=",tc),X(n,"!",jf),X(n,"-",qn),X(n,"%",nc),X(n,"|",rc),X(n,"+",ic),X(n,"#",sc),X(n,"?",oc),X(n,'"',Hf),X(n,"/",Kn),X(n,";",zf),X(n,"~",Jo),X(n,"_",lc),X(n,"\\",Xa);const r=hn(n,Wf,Ff,{[_f]:!0});hn(r,Wf,r);const i=hn(n,xs,pr,{[Nf]:!0});hn(i,xs,i);const s=hn(n,Vf,Lf,{[Df]:!0});hn(s,xs),hn(s,Vf,s);const o=hn(n,mv,fv,{[uv]:!0});X(n,gv,$f,{[uv]:!0}),X(o,gv),hn(o,mv,o);const l=hn(n,Uf,hv,{[cv]:!0});hn(l,Uf,l),X(l,vN,l);const a=X(l,wN);hn(a,Uf,l);const c=[[xs,i]],u=[[xs,null],[Vf,s]];for(let d=0;d<cc.length;d++)Vr(n,cc[d],If,pr,c);for(let d=0;d<uc.length;d++)Vr(n,uc[d],Pf,Lf,u);Ti(If,{tld:!0,ascii:!0},e),Ti(Pf,{utld:!0,alpha:!0},e),Vr(n,"file",Ra,pr,c),Vr(n,"mailto",Ra,pr,c),Vr(n,"http",ws,pr,c),Vr(n,"https",ws,pr,c),Vr(n,"ftp",ws,pr,c),Vr(n,"ftps",ws,pr,c),Ti(Ra,{scheme:!0,ascii:!0},e),Ti(ws,{slashscheme:!0,ascii:!0},e),t=t.sort((d,f)=>d[0]>f[0]?1:-1);for(let d=0;d<t.length;d++){const f=t[d][0],p=t[d][1]?{[mN]:!0}:{[gN]:!0};f.indexOf("-")>=0?p[Rf]=!0:xs.test(f)?Wf.test(f)?p[Na]=!0:p[Nf]=!0:p[_f]=!0,dv(n,f,f,p)}return dv(n,"localhost",Wo,{ascii:!0}),n.jd=new Wt(ac),{start:n,tokens:vs({groups:e},pv)}}function kN(t,e){const n=CN(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,i=[];let s=0,o=0;for(;o<r;){let l=t,a=null,c=0,u=null,d=-1,f=-1;for(;o<r&&(a=l.go(n[o]));)l=a,l.accepts()?(d=0,f=0,u=l):d>=0&&(d+=n[o].length,f++),c+=n[o].length,s+=n[o].length,o++;s-=d,o-=f,c-=d,i.push({t:u.t,v:e.slice(s-c,s),s:s-c,e:s})}return i}function CN(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),s,o=i<55296||i>56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function Vr(t,e,n,r,i){let s;const o=e.length;for(let l=0;l<o-1;l++){const a=e[l];t.j[a]?s=t.j[a]:(s=new Wt(r),s.jr=i.slice(),t.j[a]=s),t=s}return s=new Wt(n),s.jr=i.slice(),t.j[e[o-1]]=s,s}function yv(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let s=0;for(;i.indexOf(t[r+s])>=0;)s++;if(s>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+s),10);o>0;o--)n.pop();r+=s}else n.push(t[r]),r++}return e}const Go={defaultProtocol:"http",events:null,format:bv,formatHref:bv,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function qf(t,e){e===void 0&&(e=null);let n=vs({},Go);t&&(n=vs(n,t instanceof qf?t.o:t));const r=n.ignoreTags,i=[];for(let s=0;s<r.length;s++)i.push(r[s].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}qf.prototype={o:Go,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let i=this.o[t];return i&&(typeof i=="object"?(i=n.t in i?i[n.t]:Go[t],typeof i=="function"&&r&&(i=i(e,n))):typeof i=="function"&&r&&(i=i(e,n.t,n)),i)},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 bv(t){return t}function vv(t,e){this.t="token",this.v=t,this.tk=e}vv.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){return t===void 0&&(t=Go.defaultProtocol),{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),i=t.get("tagName",n,e),s=this.toFormattedString(t),o={},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&&vs(o,u),{tagName:i,attributes:o,content:s,eventListeners:d}}};function dc(t,e){class n extends vv{constructor(i,s){super(i,s),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const wv=dc("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),xv=dc("text"),SN=dc("nl"),fc=dc("url",{isLink:!0,toHref(t){return t===void 0&&(t=Go.defaultProtocol),this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Wo&&t[1].t===zr}}),pn=t=>new Wt(t);function EN(t){let{groups:e}=t;const n=e.domain.concat([Ja,Ya,Hr,Xa,Za,Qa,ec,tc,qn,Ff,nc,rc,ic,sc,Kn,ac,Jo,lc]),r=[Ga,zr,Bf,Wn,jf,oc,Hf,zf,$a,Ba,qo,Ko,Ia,La,Pa,Fa,ja,Ha,za,Va,Ua,Wa,qa,Ka],i=[Ja,Ga,Ya,Xa,Za,Qa,ec,tc,qn,qo,Ko,nc,rc,ic,sc,oc,Kn,ac,Jo,lc],s=pn(),o=X(s,Jo);xe(o,i,o),xe(o,e.domain,o);const l=pn(),a=pn(),c=pn();xe(s,e.domain,l),xe(s,e.scheme,a),xe(s,e.slashscheme,c),xe(l,i,o),xe(l,e.domain,l);const u=X(l,Hr);X(o,Hr,u),X(a,Hr,u),X(c,Hr,u);const d=X(o,Wn);xe(d,i,o),xe(d,e.domain,o);const f=pn();xe(u,e.domain,f),xe(f,e.domain,f);const h=X(f,Wn);xe(h,e.domain,f);const p=pn(wv);xe(h,e.tld,p),xe(h,e.utld,p),X(u,Wo,p);const g=X(f,qn);xe(g,e.domain,f),xe(p,e.domain,f),X(p,Wn,h),X(p,qn,g);const v=X(p,zr);xe(v,e.numeric,wv);const w=X(l,qn),S=X(l,Wn);xe(w,e.domain,l),xe(S,i,o),xe(S,e.domain,l);const x=pn(fc);xe(S,e.tld,x),xe(S,e.utld,x),xe(x,e.domain,l),xe(x,i,o),X(x,Wn,S),X(x,qn,w),X(x,Hr,u);const y=X(x,zr),C=pn(fc);xe(y,e.numeric,C);const E=pn(fc),T=pn();xe(E,n,E),xe(E,r,T),xe(T,n,E),xe(T,r,T),X(x,Kn,E),X(C,Kn,E);const D=X(a,zr),N=X(c,zr),A=X(N,Kn),R=X(A,Kn);xe(a,e.domain,l),X(a,Wn,S),X(a,qn,w),xe(c,e.domain,l),X(c,Wn,S),X(c,qn,w),xe(D,e.domain,E),X(D,Kn,E),xe(R,e.domain,E),xe(R,n,E),X(R,Kn,E);const P=[[qo,Ko],[La,Ia],[Pa,Fa],[$a,Ba],[ja,Ha],[za,Va],[Ua,Wa],[qa,Ka]];for(let B=0;B<P.length;B++){const[z,U]=P[B],J=X(E,z);X(T,z,J),X(J,U,E);const G=pn(fc);xe(J,n,G);const ie=pn();xe(J,r),xe(G,n,G),xe(G,r,ie),xe(ie,n,G),xe(ie,r,ie),X(G,U,E),X(ie,U,E)}return X(s,Wo,x),X(s,$f,SN),{start:s,tokens:pv}}function TN(t,e,n){let r=n.length,i=0,s=[],o=[];for(;i<r;){let l=t,a=null,c=null,u=0,d=null,f=-1;for(;i<r&&!(a=l.go(n[i].t));)o.push(n[i++]);for(;i<r&&(c=a||l.go(n[i].t));)a=null,l=c,l.accepts()?(f=0,d=l):f>=0&&f++,i++,u++;if(f<0)i-=u,i<r&&(o.push(n[i]),i++);else{o.length>0&&(s.push(Kf(xv,e,o)),o=[]),i-=f,u-=f;const h=d.t,p=n.slice(i-u,i);s.push(Kf(h,e,p))}}return o.length>0&&s.push(Kf(xv,e,o)),s}function Kf(t,e,n){const r=n[0].s,i=n[n.length-1].e,s=e.slice(r,i);return new t(s,n)}const AN=typeof console<"u"&&console&&console.warn||(()=>{}),MN="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Je={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function ON(){Wt.groups={},Je.scanner=null,Je.parser=null,Je.tokenQueue=[],Je.pluginQueue=[],Je.customSchemes=[],Je.initialized=!1}function kv(t,e){if(e===void 0&&(e=!1),Je.initialized&&AN(`linkifyjs: already initialized - will not register custom scheme "${t}" ${MN}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
|
396
381
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
397
382
|
2. Cannot start or end with "-"
|
398
|
-
3. "-" cannot repeat`);Je.customSchemes.push([t,e])}function RN(){Je.scanner=SN(Je.customSchemes);for(let t=0;t<Je.tokenQueue.length;t++)Je.tokenQueue[t][1]({scanner:Je.scanner});Je.parser=MN(Je.scanner.tokens);for(let t=0;t<Je.pluginQueue.length;t++)Je.pluginQueue[t][1]({scanner:Je.scanner,parser:Je.parser});Je.initialized=!0}function Cv(t){return Je.initialized||RN(),ON(Je.parser.start,t,EN(Je.scanner.start,t))}function Sv(t,e,n){if(e===void 0&&(e=null),n===void 0&&(n=null),e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new Kf(n),i=Cv(t),s=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&s.push(l.toFormattedObject(r))}return s}function LN(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function IN(t){return new je({key:new We("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,l=NS(n.doc,[...e]);if(BS(l).forEach(({newRange:c})=>{const u=RS(r.doc,c,h=>h.isTextblock);let d,f;if(u.length>1?(d=u[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ")):u.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")),d&&f){const h=f.split(" ").filter(w=>w!=="");if(h.length<=0)return!1;const p=h[h.length-1],g=d.pos+f.lastIndexOf(p);if(!p)return!1;const v=Cv(p).map(w=>w.toObject());if(!LN(v))return!1;v.filter(w=>w.isLink).map(w=>({...w,from:g+w.start+1,to:g+w.end+1})).filter(w=>r.schema.marks.code?!r.doc.rangeHasMark(w.from,w.to,r.schema.marks.code):!0).filter(w=>t.validate?t.validate(w.value):!0).forEach(w=>{Hu(w.from,w.to,r.doc).some(S=>S.mark.type===t.type)||o.addMark(w.from,w.to,t.type.create({href:w.href}))})}}),!!o.steps.length)return o}})}function PN(t){return new je({key:new We("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;if(t.whenNotEditable&&e.editable||r.button!==0)return!1;let o=r.target;const l=[];for(;o.nodeName!=="DIV";)l.push(o),o=o.parentNode;if(!l.find(f=>f.nodeName==="A"))return!1;const a=ug(e.state,t.type.name),c=r.target,u=(i=c==null?void 0:c.href)!==null&&i!==void 0?i:a.href,d=(s=c==null?void 0:c.target)!==null&&s!==void 0?s:a.target;return c&&u?(window.open(u,d),!0):!1}}})}function FN(t){return new je({key:new We("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{state:i}=e,{selection:s}=i,{empty:o}=s;if(o)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});const a=Sv(l).find(c=>c.isLink&&c.value===l);return!l||!a?!1:(t.editor.commands.setMark(t.type,{href:a.href}),!0)}}})}const $N=jt.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(t=>{if(typeof t=="string"){kv(t);return}kv(t.scheme,t.optionalSlashes)})},onDestroy(){DN()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:void 0}},addAttributes(){return{href:{default:null},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:t}){var e;return!((e=t.href)===null||e===void 0)&&e.startsWith("javascript:")?["a",Ce(this.options.HTMLAttributes,{...t,href:""}),0]:["a",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{setLink:t=>({chain:e})=>e().setMark(this.name,t).setMeta("preventAutolink",!0).run(),toggleLink:t=>({chain:e})=>e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Rr({find:t=>{const e=[];if(t){const n=Sv(t).filter(r=>r.isLink);n.length&&n.forEach(r=>e.push({text:r.value,data:{href:r.href},index:r.start}))}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[];return this.options.autolink&&t.push(IN({type:this.type,validate:this.options.validate})),this.options.openOnClick&&t.push(PN({type:this.type,whenNotEditable:this.options.openOnClick==="whenNotEditable"})),this.options.linkOnPaste&&t.push(FN({editor:this.editor,type:this.type})),t}}),BN=Ue.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,considerAnyAsEmpty:!1,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new je({key:new We("placeholder"),props:{decorations:({doc:t,selection:e})=>{var n;const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=e,s=[];if(!r)return null;const{firstChild:o}=t.content,l=o&&o.type.isLeaf,a=o&&o.isAtom,c=this.options.considerAnyAsEmpty?!0:o&&o.type.name===((n=t.type.contentMatch.defaultType)===null||n===void 0?void 0:n.name),u=t.content.childCount<=1&&o&&c&&o.nodeSize<=2&&(!l||!a);return t.descendants((d,f)=>{const h=i>=f&&i<=f+d.nodeSize,p=!d.isLeaf&&!d.childCount;if((h||!this.options.showOnlyCurrent)&&p){const g=[this.options.emptyNodeClass];u&&g.push(this.options.emptyEditorClass);const v=ut.node(f,f+d.nodeSize,{class:g.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:d,pos:f,hasAnchor:h}):this.options.placeholder});s.push(v)}return this.options.includeChildren}),He.create(t,s)}}})]}}),jN=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,HN=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,zN=jt.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",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[ai({find:jN,type:this.type})]},addPasteRules(){return[Rr({find:HN,type:this.type})]}}),VN=ze.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",Ce(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),UN=/^\s*(\[([( |x])?\])\s$/,WN=ze.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList"}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>t.getAttribute("data-checked")==="true",renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Ce(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div");return s.contentEditable="false",l.type="checkbox",l.addEventListener("change",c=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:u}=c.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:d})=>{const f=n(),h=d.doc.nodeAt(f);return d.setNodeMarkup(f,void 0,{...h==null?void 0:h.attrs,checked:u}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,u)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([c,u])=>{i.setAttribute(c,u)}),i.dataset.checked=t.attrs.checked,t.attrs.checked&&l.setAttribute("checked","checked"),s.append(l,o),i.append(s,a),Object.entries(e).forEach(([c,u])=>{i.setAttribute(c,u)}),{dom:i,contentDOM:a,update:c=>c.type!==this.type?!1:(i.dataset.checked=c.attrs.checked,c.attrs.checked?l.setAttribute("checked","checked"):l.removeAttribute("checked"),!0)}}},addInputRules(){return[Gi({find:UN,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),qN=jt.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",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function KN(t){var e;const{char:n,allowSpaces:r,allowedPrefixes:i,startOfLine:s,$position:o}=t,l=cE(n),a=new RegExp(`\\s${l}$`),c=s?"^":"",u=r?new RegExp(`${c}${l}.*?(?=\\s${l}|$)`,"gm"):new RegExp(`${c}(?:^)?${l}[^\\s${l}]*`,"gm"),d=((e=o.nodeBefore)===null||e===void 0?void 0:e.isText)&&o.nodeBefore.text;if(!d)return null;const f=o.pos-d.length,h=Array.from(d.matchAll(u)).pop();if(!h||h.input===void 0||h.index===void 0)return null;const p=h.input.slice(Math.max(0,h.index-1),h.index),g=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(p);if(i!==null&&!g)return null;const v=f+h.index;let w=v+h[0].length;return r&&a.test(d.slice(w-1,w+1))&&(h[0]+=" ",w+=1),v<o.pos&&w>=o.pos?{range:{from:v,to:w},query:h[0].slice(n.length),text:h[0]}:null}const JN=new We("suggestion");function GN({pluginKey:t=JN,editor:e,char:n="@",allowSpaces:r=!1,allowedPrefixes:i=[" "],startOfLine:s=!1,decorationTag:o="span",decorationClass:l="suggestion",command:a=()=>null,items:c=()=>[],render:u=()=>({}),allow:d=()=>!0,findSuggestionMatch:f=KN}){let h;const p=u==null?void 0:u(),g=new je({key:t,view(){return{update:async(v,w)=>{var S,x,y,C,E,T,D;const N=(S=this.key)===null||S===void 0?void 0:S.getState(w),A=(x=this.key)===null||x===void 0?void 0:x.getState(v.state),R=N.active&&A.active&&N.range.from!==A.range.from,P=!N.active&&A.active,B=N.active&&!A.active,z=!P&&!B&&N.query!==A.query,U=P||R,J=z&&!R,G=B||R;if(!U&&!J&&!G)return;const ie=G&&!U?N:A,Z=v.dom.querySelector(`[data-decoration-id="${ie.decorationId}"]`);h={editor:e,range:ie.range,query:ie.query,text:ie.text,items:[],command:ke=>a({editor:e,range:ie.range,props:ke}),decorationNode:Z,clientRect:Z?()=>{var ke;const{decorationId:Le}=(ke=this.key)===null||ke===void 0?void 0:ke.getState(e.state),$e=v.dom.querySelector(`[data-decoration-id="${Le}"]`);return($e==null?void 0:$e.getBoundingClientRect())||null}:null},U&&((y=p==null?void 0:p.onBeforeStart)===null||y===void 0||y.call(p,h)),J&&((C=p==null?void 0:p.onBeforeUpdate)===null||C===void 0||C.call(p,h)),(J||U)&&(h.items=await c({editor:e,query:ie.query})),G&&((E=p==null?void 0:p.onExit)===null||E===void 0||E.call(p,h)),J&&((T=p==null?void 0:p.onUpdate)===null||T===void 0||T.call(p,h)),U&&((D=p==null?void 0:p.onStart)===null||D===void 0||D.call(p,h))},destroy:()=>{var v;h&&((v=p==null?void 0:p.onExit)===null||v===void 0||v.call(p,h))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(v,w,S,x){const{isEditable:y}=e,{composing:C}=e.view,{selection:E}=v,{empty:T,from:D}=E,N={...w};if(N.composing=C,y&&(T||e.view.composing)){(D<w.range.from||D>w.range.to)&&!C&&!w.composing&&(N.active=!1);const A=f({char:n,allowSpaces:r,allowedPrefixes:i,startOfLine:s,$position:E.$from}),R=`id_${Math.floor(Math.random()*4294967295)}`;A&&d({editor:e,state:x,range:A.range})?(N.active=!0,N.decorationId=w.decorationId?w.decorationId:R,N.range=A.range,N.query=A.query,N.text=A.text):N.active=!1}else N.active=!1;return N.active||(N.decorationId=null,N.range={from:0,to:0},N.query=null,N.text=null),N}},props:{handleKeyDown(v,w){var S;const{active:x,range:y}=g.getState(v.state);return x&&((S=p==null?void 0:p.onKeyDown)===null||S===void 0?void 0:S.call(p,{view:v,event:w,range:y}))||!1},decorations(v){const{active:w,range:S,decorationId:x}=g.getState(v);return w?He.create(v.doc,[ut.inline(S.from,S.to,{nodeName:o,class:l,"data-decoration-id":x})]):null}}});return g}const YN=Ue.create({name:"slash-command",addOptions(){return{suggestion:{char:"/",command:({editor:t,range:e,props:n})=>{n.command({editor:t,range:e})}}}},addProseMirrorPlugins(){return[GN({editor:this.editor,...this.options.suggestion})]}}),XN=({query:t})=>[{title:"Text",description:"Just start typing with plain text.",searchTerms:["p","paragraph"],icon:O.jsx(wy,{size:18}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).toggleNode("paragraph","paragraph").run()}},{title:"To-do List",description:"Track tasks with a to-do list.",searchTerms:["todo","task","list","check","checkbox"],icon:O.jsx(by,{size:18}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).toggleTaskList().run()}},{title:"Heading 1",description:"Big section heading.",searchTerms:["title","big","large"],icon:O.jsx(dd,{size:18}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).setNode("heading",{level:1}).run()}},{title:"Heading 2",description:"Medium section heading.",searchTerms:["subtitle","medium"],icon:O.jsx(fd,{size:18}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).setNode("heading",{level:2}).run()}},{title:"Heading 3",description:"Small section heading.",searchTerms:["subtitle","small"],icon:O.jsx(hd,{size:18}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).setNode("heading",{level:3}).run()}},{title:"Bullet List",description:"Create a simple bullet list.",searchTerms:["unordered","point"],icon:O.jsx(pd,{size:18}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).toggleBulletList().run()}},{title:"Numbered List",description:"Create a list with numbering.",searchTerms:["ordered"],icon:O.jsx(xo,{size:18}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).toggleOrderedList().run()}},{title:"Divider",description:"Visually divide content.",searchTerms:["hr","divider","break","line","delimiter"],icon:O.jsx(mA,{size:18}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).setHorizontalRule().run()}},{title:"Quote",description:"Capture a quote.",searchTerms:["blockquote"],icon:O.jsx(md,{size:18}),image:"",command:({editor:e,range:n})=>e.chain().focus().deleteRange(n).toggleNode("paragraph","paragraph").toggleBlockquote().run()},{title:"Code",description:"Capture a code snippet.",searchTerms:["codeblock"],icon:O.jsx(Ul,{size:18}),image:"",command:({editor:e,range:n})=>e.chain().focus().deleteRange(n).toggleCodeBlock().run()},{title:"Table",description:"Create a table.",searchTerms:["table"],icon:O.jsx(CA,{size:18}),image:"",command:({editor:e,range:n})=>e.chain().focus().deleteRange(n).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{title:"Image",description:"Upload an image from your computer.",searchTerms:["photo","picture","media"],icon:O.jsx(pA,{size:18}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).run();const r=document.createElement("input");r.type="file",r.accept="image/*",r.onchange=async()=>{var i;if((i=r.files)!=null&&i.length){const s=r.files[0],o=e.view.state.selection.from;Sy(s,e.view,o)}},r.click()}},{title:"Video Embed",description:"Embed a video from YouTube, Vimeo, etc.",searchTerms:["iframe","embed","video","youtube"],icon:O.jsx(Cy,{}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).setActionButton("iframe").run()}},{title:"Twitter",description:"Embed a Twitter tweet.",searchTerms:["embed","twitter","tweet"],icon:O.jsx(xy,{}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).setActionButton("twitter").run()}},{title:"2 Columns",description:"Create 2 columns of block",searchTerms:["col","column","2","layout"],icon:O.jsx(hy,{}),image:"",command:({editor:e})=>{e.chain().focus().setColumns(2).focus(e.state.selection.head-1).run()}},{title:"3 Columns",description:"Create 3 columns of block",searchTerms:["col","column","3","layout"],icon:O.jsx(cA,{}),image:"",command:({editor:e})=>{e.chain().focus().setColumns(3).focus(e.state.selection.head-1).run()}}].filter(e=>{if(typeof t=="string"&&t.length>0){const n=t.toLowerCase();return e.title.toLowerCase().includes(n)||e.description.toLowerCase().includes(n)||e.searchTerms&&e.searchTerms.some(r=>r.includes(n))}return!0}),ZN=(t,e)=>{const n=t.offsetHeight,r=e?e.offsetHeight:0,i=e.offsetTop,s=i+r;i<t.scrollTop?t.scrollTop-=t.scrollTop-i+5:s>n+t.scrollTop&&(t.scrollTop+=s-n-t.scrollTop+5)},QN=({items:t,command:e,editor:n})=>{const[r,i]=_.useState(0),s=_.useCallback(l=>{const a=t[l];a&&(a.title==="Continue writing"||e(a))},[e,n,t]);_.useEffect(()=>{const l=["ArrowUp","ArrowDown","Enter"],a=c=>{if(l.includes(c.key))return c.preventDefault(),c.key==="ArrowUp"?(i((r+t.length-1)%t.length),!0):c.key==="ArrowDown"?(i((r+1)%t.length),!0):c.key==="Enter"?(s(r),!0):!1};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a)}},[t,r,i,s]),_.useEffect(()=>{i(0)},[t]);const o=_.useRef(null);return _.useLayoutEffect(()=>{const l=o==null?void 0:o.current,a=l==null?void 0:l.children[r];a&&l&&ZN(l,a)},[r]),t.length>0?O.jsx("div",{id:"slash-command",ref:o,className:"z-50 h-auto max-h-[330px] w-72 overflow-y-auto scroll-smooth rounded-md border border-[#DDD] bg-white px-1 py-2 shadow-md transition-all",children:t.map((l,a)=>O.jsxs("button",{className:`flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm text-neutral-500 hover:bg-neutral-100 hover:border-neutral-200 border border-transparent transition-all ${a===r?"bg-neutral-200 text-neutral-800":""}`,onClick:()=>s(a),children:[O.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border border-neutral-200 bg-white",children:l.icon}),O.jsxs("div",{children:[O.jsx("p",{className:"font-medium",children:l.title}),O.jsx("p",{className:"text-xs text-neutral-500",children:l.description})]})]},a))}):null},eD=()=>{let t=null,e=null;return{onStart:n=>{t=new ay(QN,{props:n,editor:n.editor}),e=fi("body",{getReferenceClientRect:n.clientRect,appendTo:()=>document.body,content:t.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"})},onUpdate:n=>{t==null||t.updateProps(n),e&&e[0].setProps({getReferenceClientRect:n.clientRect})},onKeyDown:n=>{var r;return n.event.key==="Escape"?(e==null||e[0].hide(),!0):(r=t==null?void 0:t.ref)==null?void 0:r.onKeyDown(n)},onExit:()=>{e==null||e[0].destroy(),t==null||t.destroy()}}},tD=YN.configure({suggestion:{items:XN,render:eD}}),nD=ov.extend({renderHTML(){return["div",Ce(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}}),rD=Ue.create({name:"columnExtension",addExtensions(){const t=[];return this.options.column!==!1&&t.push(_y),this.options.columns!==!1&&t.push(Jl),t}}),iD=Ue.create({name:"CustomKeymap",addCommands(){return{selectTextWithinNodeBoundaries:()=>({editor:t,commands:e})=>{const{state:n}=t,{tr:r}=n,i=r.selection.$from.start(),s=r.selection.$to.end();return e.setTextSelection({from:i,to:s})}}},addKeyboardShortcuts(){return{"Mod-a":({editor:t})=>{const{state:e}=t,{tr:n}=e,r=n.selection.from,i=n.selection.to,s=n.selection.$from.start(),o=n.selection.$to.end();return r>s||i<o?(t.chain().selectTextWithinNodeBoundaries().run(),!0):!1}}}}),sD=Ue.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;return(e=t.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),Ev=[{tooltip:"Align left",action:t=>t({dataAlign:"start",dataFloat:null}),icon:"AlignLeft",isActive:t=>t.dataAlign==="start"},{tooltip:"Align center",action:t=>t({dataAlign:"center",dataFloat:null}),icon:"AlignCenter",isActive:t=>t.dataAlign==="center"},{tooltip:"Align right",action:t=>t({dataAlign:"end",dataFloat:null}),icon:"AlignRight",isActive:t=>t.dataAlign==="end"},{tooltip:"Delete",icon:"Trash2",delete:t=>t()}];let ks;const Tv=({node:t,updateAttributes:e,deleteNode:n})=>{const r=Yl(),[i,s]=_.useState(),[o,l]=_.useState(0),[a,c]=_.useState(0),[u,d]=_.useState({}),f=_.useRef(null),[h,p]=_.useState(!1),g=()=>{const P={};Ev.forEach(({tooltip:B,isActive:z})=>{P[B]=!!(z!=null&&z(t.attrs))}),d(P)},v=()=>{const P=document.querySelector(".ProseMirror");if(P&&c(P==null?void 0:P.clientWidth),!!f.current){if(i==="video"){const B=f.current;B.addEventListener("loadeddata",function(){l(B.videoWidth/B.videoHeight),E("left",0)})}else if(i==="iframe"){const B=f.current;B.onload=()=>{l(B.offsetWidth/B.offsetHeight),E("left",0)}}else f.current.onload=()=>{l(f.current.naturalWidth/f.current.naturalHeight)};setTimeout(()=>g(),200)}},w=P=>{ks=P};_.useEffect(()=>{v()},[]);const S=({width:P,height:B})=>P<200||B<200,x=P=>{setTimeout(()=>T(P))},y=P=>{ks=P.clientX,setTimeout(()=>{document.addEventListener("mousemove",x),document.addEventListener("mouseup",C)}),p(!0)},C=()=>{ks=-1,document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",C),p(!1)},E=(P,B)=>{var J,G;if(!f.current){console.error("Media ref is undefined|null",{resizableImg:f.current});return}const z={width:(J=f.current)==null?void 0:J.width,height:(G=f.current)==null?void 0:G.height},U={width:-1,height:-1};P==="left"?U.width=z.width-Math.abs(B):(typeof z.width=="string"&&(z.width=Number(z.width)),U.width=z.width+Math.abs(B)),U.width>a&&(U.width=a),i==="iframe"?U.height=U.width/(16/9):U.height=U.width/o,!S(U)&&e(U)},T=P=>{if(ks===-1)return;const{clientX:B}=P,z=ks-B;if(z===0)return;const U=z>0?"left":"right";setTimeout(()=>{E(U,Math.abs(z)),ks=B})},[D,N]=_.useState(),[A,R]=_.useState();return _.useEffect(()=>{s(t.attrs["media-type"]),g(),N(t.attrs.dataFloat),R(t.attrs.dataAlign)},[t.attrs]),O.jsx(wo,{as:"article",className:Se("media-node-view not-prose transition-all ease-in-out w-full",D&&`f-${t.attrs.dataFloat}`,A&&`justify-${t.attrs.dataAlign}`),children:O.jsxs("div",{className:"w-fit flex relative group transition-all ease-in-out",children:[i==="img"&&O.jsx("img",{src:t.attrs.src,ref:f,className:"rounded-lg",alt:t.attrs.src,width:t.attrs.width,height:t.attrs.height}),i==="video"&&O.jsx("video",{ref:f,className:"rounded-lg",controls:!0,width:t.attrs.width,height:t.attrs.height,children:O.jsx("source",{src:t.attrs.src})}),i==="iframe"&&O.jsx("iframe",{ref:f,className:Se("rounded-lg max-w-full",h&&"pointer-events-none"),src:t.attrs.src,width:t.attrs.width,height:t.attrs.height}),!r&&O.jsxs(O.Fragment,{children:[O.jsx("div",{className:"horizontal-resize-handle group-hover:bg-black group-hover:border-2 group-hover:border-white/80",title:"Resize",onClick:({clientX:P})=>w(P),onMouseDown:y,onMouseUp:C}),O.jsx("section",{className:"media-control-buttons opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:Ev.map(P=>O.jsx("div",{className:"tooltip","data-tip":P.tooltip,children:O.jsx("button",{type:"button",className:Se("btn rounded-none h-8 px-2",u[P.tooltip]&&"active"),onClick:()=>{var B;return P.tooltip==="Delete"?n():(B=P.action)==null?void 0:B.call(P,e)},children:O.jsx("img",{src:P.icon,className:"w-4"})})}))})]})]})})},oD=ze.create({name:"iframe",group:"block",atom:!0,draggable:!0,addOptions(){return{allowFullscreen:!0,HTMLAttributes:{class:"iframe-wrapper"}}},addAttributes(){return{src:{default:null},frameborder:{default:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen},"media-type":{default:"iframe"},alt:{default:null},title:{default:null},width:{default:this.options.width},height:{default:this.options.height},dataAlign:{default:"left"},dataFloat:{default:null}}},addNodeView(){return hi(Tv)},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:t}){return["iframe",Ce(this.options.HTMLAttributes,t)]},addCommands(){return{setIframe:t=>({tr:e,dispatch:n})=>{const{selection:r}=e,i=this.type.create(t);return n&&e.replaceRangeWith(r.from-1,r.to,i),!0}}}});var lD="https://platform.twitter.com/widgets.js",Gf="createTweet",aD=function(e){var n=_.useRef(null),r=_.useState(!0),i=r[0],s=r[1];return _.useEffect(function(){var o=!0,l=require("scriptjs");return l(lD,"twitter-embed",function(){if(!window.twttr){console.error("Failure to load window.twttr, aborting load");return}if(o){if(!window.twttr.widgets[Gf]){console.error("Method "+Gf+" is not present anymore in twttr.widget api");return}window.twttr.widgets[Gf](e.tweetId,n==null?void 0:n.current,e.options).then(function(a){s(!1),e.onLoad&&e.onLoad(a)})}}),function(){o=!1}},[]),_.createElement(_.Fragment,null,i&&_.createElement(_.Fragment,null,e.placeholder),_.createElement("div",{ref:n}))};const cD=({node:t,editor:e})=>{const[n,r]=_.useState(!0);return _.useEffect(()=>{e==null||e.chain().focus()},[]),O.jsx(wo,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:O.jsxs("div",{className:"w-full max-w-sm",children:[n&&O.jsx(Hy,{width:5,height:5}),O.jsx(aD,{tweetId:t.attrs.tweetId,onLoad:()=>r(!1)})]})})},uD=ze.create({name:"embeddedTweet",group:"block",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:""}}},addAttributes(){return{tweetId:{default:null},align:{default:"center"}}},parseHTML(){return[{tag:"div[data-tweet-id]"}]},renderHTML({HTMLAttributes:t}){return["div",Ce(this.options.HTMLAttributes,t)]},addNodeView(){return hi(cD)},addCommands(){return{setTweetEmbed:t=>({commands:e})=>e.insertContent({type:this.name,attrs:{tweetId:t.tweetId,align:"center"},content:[]})}}}),dD=t=>new je({key:new We("media-paste-drop"),props:{handlePaste(e,n){var i;return Array.from(((i=n.clipboardData)==null?void 0:i.items)||[]).forEach(s=>{const o=s.getAsFile();if(((o==null?void 0:o.type.indexOf("image"))===0||(o==null?void 0:o.type.indexOf("video"))===0)&&(n.preventDefault(),o&&o.size>1024*1024))throw new Error("Image too large")}),!1},handleDrop(e,n){var l;if(!(n.dataTransfer&&n.dataTransfer.files&&n.dataTransfer.files.length))return!1;const i=Array.from(((l=n.dataTransfer)==null?void 0:l.files)??[]).filter(({type:a})=>/image|video/i.test(a));if(i.length===0)return!1;n.preventDefault();const{schema:s}=e.state,o=e.posAtCoords({left:n.clientX,top:n.clientY});return o?(i.forEach(async a=>{const c=new FileReader;if(t){const u=s.nodes.resizableMedia.create({src:await t(a),"media-type":a.type.includes("image")?"img":"video"}),d=e.state.tr.insert(o.pos,u);e.dispatch(d)}else c.onload=u=>{var h;const d=s.nodes.resizableMedia.create({src:(h=u.target)==null?void 0:h.result,"media-type":a.type.includes("image")?"img":"video"}),f=e.state.tr.insert(o.pos,d);e.dispatch(f)},c.readAsDataURL(a)}),!0):!1}}}),fD=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,hD=/!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/,pD=ze.create({name:"resizableMedia",addOptions(){return{HTMLAttributes:{class:"rounded-lg border border-stone-200"},uploadFn:async()=>""}},inline:!1,group:"block",draggable:!0,addAttributes(){return{src:{default:null},"media-type":{default:null},alt:{default:null},title:{default:null},width:{default:"100%"},height:{default:"auto"},dataAlign:{default:"left"},dataFloat:{default:null}}},selectable:!0,parseHTML(){return[{tag:'img[src]:not([src^="data:"])',getAttrs:t=>({src:t.getAttribute("src"),"media-type":"img"})},{tag:"video",getAttrs:t=>({src:t.getAttribute("src"),"media-type":"video"})}]},renderHTML({HTMLAttributes:t}){const{"media-type":e}=t;return e==="img"?["img",Ce(this.options.HTMLAttributes,t)]:e==="video"?["video",{controls:"true",style:"width: 100%",...t},["source",t]]:(e||console.error("TiptapMediaExtension-renderHTML method: Media Type not set, going default with image"),["img",Ce(this.options.HTMLAttributes,t)])},addCommands(){return{setMedia:t=>({commands:e})=>{const{"media-type":n}=t;return n==="img"?e.insertContent({type:this.name,attrs:t}):n==="video"?e.insertContent({type:this.name,attrs:{...t,controls:"true"}}):(n||console.error("TiptapMediaExtension-setMedia: Media Type not set, going default with image"),e.insertContent({type:this.name,attrs:t}))}}},addNodeView(){return hi(Tv)},addKeyboardShortcuts(){return{Enter:({editor:t})=>{const{selection:e}=t.state;if(e.empty)return!1;const n=e.$to.pos;return t.commands.insertContentAt(n,{type:"dBlock",content:[{type:"paragraph"}]})}}},addInputRules(){return[Wu({find:fD,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r,"media-type":"img"}}}),Wu({find:hD,type:this.type,getAttributes:t=>{const[,,e]=t;return{src:e,"media-type":"video"}}})]},addProseMirrorPlugins(){return[dD(this.options.uploadFn),_A()]}});function Av(t,e){let n;return(...i)=>{clearTimeout(n),n=setTimeout(()=>t(...i),e)}}function dt(){return dt=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},dt.apply(null,arguments)}function Ur(t,e,{checkForDefaultPrevented:n=!0}={}){return function(i){if(t==null||t(i),n===!1||!i.defaultPrevented)return e==null?void 0:e(i)}}function mD(t,e){typeof t=="function"?t(e):t!=null&&(t.current=e)}function Mv(...t){return e=>t.forEach(n=>mD(n,e))}function Ai(...t){return _.useCallback(Mv(...t),t)}function Ov(t,e=[]){let n=[];function r(s,o){const l=_.createContext(o),a=n.length;n=[...n,o];function c(d){const{scope:f,children:h,...p}=d,g=(f==null?void 0:f[t][a])||l,v=_.useMemo(()=>p,Object.values(p));return _.createElement(g.Provider,{value:v},h)}function u(d,f){const h=(f==null?void 0:f[t][a])||l,p=_.useContext(h);if(p)return p;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${s}\``)}return c.displayName=s+"Provider",[c,u]}const i=()=>{const s=n.map(o=>_.createContext(o));return function(l){const a=(l==null?void 0:l[t])||s;return _.useMemo(()=>({[`__scope${t}`]:{...l,[t]:a}}),[l,a])}};return i.scopeName=t,[r,gD(i,...e)]}function gD(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((l,{useScope:a,scopeName:c})=>{const d=a(s)[`__scope${c}`];return{...l,...d}},{});return _.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}const Yf=_.forwardRef((t,e)=>{const{children:n,...r}=t,i=_.Children.toArray(n),s=i.find(bD);if(s){const o=s.props.children,l=i.map(a=>a===s?_.Children.count(o)>1?_.Children.only(null):_.isValidElement(o)?o.props.children:null:a);return _.createElement(Xf,dt({},r,{ref:e}),_.isValidElement(o)?_.cloneElement(o,void 0,l):null)}return _.createElement(Xf,dt({},r,{ref:e}),n)});Yf.displayName="Slot";const Xf=_.forwardRef((t,e)=>{const{children:n,...r}=t;return _.isValidElement(n)?_.cloneElement(n,{...vD(r,n.props),ref:e?Mv(e,n.ref):n.ref}):_.Children.count(n)>1?_.Children.only(null):null});Xf.displayName="SlotClone";const yD=({children:t})=>_.createElement(_.Fragment,null,t);function bD(t){return _.isValidElement(t)&&t.type===yD}function vD(t,e){const n={...e};for(const r in e){const i=t[r],s=e[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...l)=>{s(...l),i(...l)}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...t,...n}}const Mi=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((t,e)=>{const n=_.forwardRef((r,i)=>{const{asChild:s,...o}=r,l=s?Yf:e;return _.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),_.createElement(l,dt({},o,{ref:i}))});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});function wD(t,e){t&&nn.flushSync(()=>t.dispatchEvent(e))}function Wr(t){const e=_.useRef(t);return _.useEffect(()=>{e.current=t}),_.useMemo(()=>(...n)=>{var r;return(r=e.current)===null||r===void 0?void 0:r.call(e,...n)},[])}function xD(t,e=globalThis==null?void 0:globalThis.document){const n=Wr(t);_.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return e.addEventListener("keydown",r),()=>e.removeEventListener("keydown",r)},[n,e])}const Zf="dismissableLayer.update",kD="dismissableLayer.pointerDownOutside",CD="dismissableLayer.focusOutside";let _v;const SD=_.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ED=_.forwardRef((t,e)=>{var n;const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:l,onDismiss:a,...c}=t,u=_.useContext(SD),[d,f]=_.useState(null),h=(n=d==null?void 0:d.ownerDocument)!==null&&n!==void 0?n:globalThis==null?void 0:globalThis.document,[,p]=_.useState({}),g=Ai(e,D=>f(D)),v=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),S=v.indexOf(w),x=d?v.indexOf(d):-1,y=u.layersWithOutsidePointerEventsDisabled.size>0,C=x>=S,E=TD(D=>{const N=D.target,A=[...u.branches].some(R=>R.contains(N));!C||A||(s==null||s(D),l==null||l(D),D.defaultPrevented||a==null||a())},h),T=AD(D=>{const N=D.target;[...u.branches].some(R=>R.contains(N))||(o==null||o(D),l==null||l(D),D.defaultPrevented||a==null||a())},h);return xD(D=>{x===u.layers.size-1&&(i==null||i(D),!D.defaultPrevented&&a&&(D.preventDefault(),a()))},h),_.useEffect(()=>{if(d)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(_v=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Nv(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=_v)}},[d,h,r,u]),_.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Nv())},[d,u]),_.useEffect(()=>{const D=()=>p({});return document.addEventListener(Zf,D),()=>document.removeEventListener(Zf,D)},[]),_.createElement(Mi.div,dt({},c,{ref:g,style:{pointerEvents:y?C?"auto":"none":void 0,...t.style},onFocusCapture:Ur(t.onFocusCapture,T.onFocusCapture),onBlurCapture:Ur(t.onBlurCapture,T.onBlurCapture),onPointerDownCapture:Ur(t.onPointerDownCapture,E.onPointerDownCapture)}))});function TD(t,e=globalThis==null?void 0:globalThis.document){const n=Wr(t),r=_.useRef(!1),i=_.useRef(()=>{});return _.useEffect(()=>{const s=l=>{if(l.target&&!r.current){let c=function(){Dv(kD,n,a,{discrete:!0})};const a={originalEvent:l};l.pointerType==="touch"?(e.removeEventListener("click",i.current),i.current=c,e.addEventListener("click",i.current,{once:!0})):c()}else e.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",s),e.removeEventListener("click",i.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function AD(t,e=globalThis==null?void 0:globalThis.document){const n=Wr(t),r=_.useRef(!1);return _.useEffect(()=>{const i=s=>{s.target&&!r.current&&Dv(CD,n,{originalEvent:s},{discrete:!1})};return e.addEventListener("focusin",i),()=>e.removeEventListener("focusin",i)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Nv(){const t=new CustomEvent(Zf);document.dispatchEvent(t)}function Dv(t,e,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&i.addEventListener(t,e,{once:!0}),r?wD(i,s):i.dispatchEvent(s)}let Qf=0;function MD(){_.useEffect(()=>{var t,e;const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",(t=n[0])!==null&&t!==void 0?t:Rv()),document.body.insertAdjacentElement("beforeend",(e=n[1])!==null&&e!==void 0?e:Rv()),Qf++,()=>{Qf===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(r=>r.remove()),Qf--}},[])}function Rv(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",t}const eh="focusScope.autoFocusOnMount",th="focusScope.autoFocusOnUnmount",Lv={bubbles:!1,cancelable:!0},OD=_.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...o}=t,[l,a]=_.useState(null),c=Wr(i),u=Wr(s),d=_.useRef(null),f=Ai(e,g=>a(g)),h=_.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;_.useEffect(()=>{if(r){let g=function(x){if(h.paused||!l)return;const y=x.target;l.contains(y)?d.current=y:qr(d.current,{select:!0})},v=function(x){if(h.paused||!l)return;const y=x.relatedTarget;y!==null&&(l.contains(y)||qr(d.current,{select:!0}))},w=function(x){if(document.activeElement===document.body)for(const C of x)C.removedNodes.length>0&&qr(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",v);const S=new MutationObserver(w);return l&&S.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",v),S.disconnect()}}},[r,l,h.paused]),_.useEffect(()=>{if(l){Fv.add(h);const g=document.activeElement;if(!l.contains(g)){const w=new CustomEvent(eh,Lv);l.addEventListener(eh,c),l.dispatchEvent(w),w.defaultPrevented||(_D(ID(Iv(l)),{select:!0}),document.activeElement===g&&qr(l))}return()=>{l.removeEventListener(eh,c),setTimeout(()=>{const w=new CustomEvent(th,Lv);l.addEventListener(th,u),l.dispatchEvent(w),w.defaultPrevented||qr(g??document.body,{select:!0}),l.removeEventListener(th,u),Fv.remove(h)},0)}}},[l,c,u,h]);const p=_.useCallback(g=>{if(!n&&!r||h.paused)return;const v=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,w=document.activeElement;if(v&&w){const S=g.currentTarget,[x,y]=ND(S);x&&y?!g.shiftKey&&w===y?(g.preventDefault(),n&&qr(x,{select:!0})):g.shiftKey&&w===x&&(g.preventDefault(),n&&qr(y,{select:!0})):w===S&&g.preventDefault()}},[n,r,h.paused]);return _.createElement(Mi.div,dt({tabIndex:-1},o,{ref:f,onKeyDown:p}))});function _D(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(qr(r,{select:e}),document.activeElement!==n)return}function ND(t){const e=Iv(t),n=Pv(e,t),r=Pv(e.reverse(),t);return[n,r]}function Iv(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function Pv(t,e){for(const n of t)if(!DD(n,{upTo:e}))return n}function DD(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function RD(t){return t instanceof HTMLInputElement&&"select"in t}function qr(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&RD(t)&&e&&t.select()}}const Fv=LD();function LD(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=$v(t,e),t.unshift(e)},remove(e){var n;t=$v(t,e),(n=t[0])===null||n===void 0||n.resume()}}}function $v(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function ID(t){return t.filter(e=>e.tagName!=="A")}const Cs=globalThis!=null&&globalThis.document?_.useLayoutEffect:()=>{},PD=le.useId||(()=>{});let FD=0;function $D(t){const[e,n]=le.useState(PD());return Cs(()=>{t||n(r=>r??String(FD++))},[t]),t||(e?`radix-${e}`:"")}const BD=["top","right","bottom","left"],Jn=Math.min,Qt=Math.max,pc=Math.round,mc=Math.floor,Kr=t=>({x:t,y:t}),jD={left:"right",right:"left",bottom:"top",top:"bottom"},HD={start:"end",end:"start"};function nh(t,e,n){return Qt(t,Jn(e,n))}function mr(t,e){return typeof t=="function"?t(e):t}function gr(t){return t.split("-")[0]}function Ss(t){return t.split("-")[1]}function rh(t){return t==="x"?"y":"x"}function ih(t){return t==="y"?"height":"width"}function Es(t){return["top","bottom"].includes(gr(t))?"y":"x"}function sh(t){return rh(Es(t))}function zD(t,e,n){n===void 0&&(n=!1);const r=Ss(t),i=sh(t),s=ih(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=gc(o)),[o,gc(o)]}function VD(t){const e=gc(t);return[oh(t),e,oh(e)]}function oh(t){return t.replace(/start|end/g,e=>HD[e])}function UD(t,e,n){const r=["left","right"],i=["right","left"],s=["top","bottom"],o=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:r:e?r:i;case"left":case"right":return e?s:o;default:return[]}}function WD(t,e,n,r){const i=Ss(t);let s=UD(gr(t),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(oh)))),s}function gc(t){return t.replace(/left|right|bottom|top/g,e=>jD[e])}function qD(t){return{top:0,right:0,bottom:0,left:0,...t}}function Bv(t){return typeof t!="number"?qD(t):{top:t,right:t,bottom:t,left:t}}function yc(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function jv(t,e,n){let{reference:r,floating:i}=t;const s=Es(e),o=sh(e),l=ih(o),a=gr(e),c=s==="y",u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[l]/2-i[l]/2;let h;switch(a){case"top":h={x:u,y:r.y-i.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-i.width,y:d};break;default:h={x:r.x,y:r.y}}switch(Ss(e)){case"start":h[o]-=f*(n&&c?-1:1);break;case"end":h[o]+=f*(n&&c?-1:1);break}return h}const KD=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,l=s.filter(Boolean),a=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:i}),{x:u,y:d}=jv(c,r,a),f=r,h={},p=0;for(let g=0;g<l.length;g++){const{name:v,fn:w}=l[g],{x:S,y:x,data:y,reset:C}=await w({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:h,rects:c,platform:o,elements:{reference:t,floating:e}});u=S??u,d=x??d,h={...h,[v]:{...h[v],...y}},C&&p<=50&&(p++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(c=C.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:i}):C.rects),{x:u,y:d}=jv(c,f,a)),g=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:h}};async function Yo(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:o,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:h=0}=mr(e,t),p=Bv(h),v=l[f?d==="floating"?"reference":"floating":d],w=yc(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:a})),S=d==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),y=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},C=yc(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:S,offsetParent:x,strategy:a}):S);return{top:(w.top-C.top+p.top)/y.y,bottom:(C.bottom-w.bottom+p.bottom)/y.y,left:(w.left-C.left+p.left)/y.x,right:(C.right-w.right+p.right)/y.x}}const JD=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:s,platform:o,elements:l,middlewareData:a}=e,{element:c,padding:u=0}=mr(t,e)||{};if(c==null)return{};const d=Bv(u),f={x:n,y:r},h=sh(i),p=ih(h),g=await o.getDimensions(c),v=h==="y",w=v?"top":"left",S=v?"bottom":"right",x=v?"clientHeight":"clientWidth",y=s.reference[p]+s.reference[h]-f[h]-s.floating[p],C=f[h]-s.reference[h],E=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let T=E?E[x]:0;(!T||!await(o.isElement==null?void 0:o.isElement(E)))&&(T=l.floating[x]||s.floating[p]);const D=y/2-C/2,N=T/2-g[p]/2-1,A=Jn(d[w],N),R=Jn(d[S],N),P=A,B=T-g[p]-R,z=T/2-g[p]/2+D,U=nh(P,z,B),J=!a.arrow&&Ss(i)!=null&&z!==U&&s.reference[p]/2-(z<P?A:R)-g[p]/2<0,G=J?z<P?z-P:z-B:0;return{[h]:f[h]+G,data:{[h]:U,centerOffset:z-U-G,...J&&{alignmentOffset:G}},reset:J}}}),GD=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...v}=mr(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=gr(i),S=gr(l)===l,x=await(a.isRTL==null?void 0:a.isRTL(c.floating)),y=f||(S||!g?[gc(l)]:VD(l));!f&&p!=="none"&&y.push(...WD(l,g,p,x));const C=[l,...y],E=await Yo(e,v),T=[];let D=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&T.push(E[w]),d){const P=zD(i,o,x);T.push(E[P[0]],E[P[1]])}if(D=[...D,{placement:i,overflows:T}],!T.every(P=>P<=0)){var N,A;const P=(((N=s.flip)==null?void 0:N.index)||0)+1,B=C[P];if(B)return{data:{index:P,overflows:D},reset:{placement:B}};let z=(A=D.filter(U=>U.overflows[0]<=0).sort((U,J)=>U.overflows[1]-J.overflows[1])[0])==null?void 0:A.placement;if(!z)switch(h){case"bestFit":{var R;const U=(R=D.map(J=>[J.placement,J.overflows.filter(G=>G>0).reduce((G,ie)=>G+ie,0)]).sort((J,G)=>J[1]-G[1])[0])==null?void 0:R[0];U&&(z=U);break}case"initialPlacement":z=l;break}if(i!==z)return{reset:{placement:z}}}return{}}}};function Hv(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function zv(t){return BD.some(e=>t[e]>=0)}const YD=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...i}=mr(t,e);switch(r){case"referenceHidden":{const s=await Yo(e,{...i,elementContext:"reference"}),o=Hv(s,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:zv(o)}}}case"escaped":{const s=await Yo(e,{...i,altBoundary:!0}),o=Hv(s,n.floating);return{data:{escapedOffsets:o,escaped:zv(o)}}}default:return{}}}}};async function XD(t,e){const{placement:n,platform:r,elements:i}=t,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=gr(n),l=Ss(n),a=Es(n)==="y",c=["left","top"].includes(o)?-1:1,u=s&&a?-1:1,d=mr(e,t);let{mainAxis:f,crossAxis:h,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return l&&typeof p=="number"&&(h=l==="end"?p*-1:p),a?{x:h*u,y:f*c}:{x:f*c,y:h*u}}const ZD=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:s,placement:o,middlewareData:l}=e,a=await XD(e,t);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+a.x,y:s+a.y,data:{...a,placement:o}}}}},QD=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i}=e,{mainAxis:s=!0,crossAxis:o=!1,limiter:l={fn:v=>{let{x:w,y:S}=v;return{x:w,y:S}}},...a}=mr(t,e),c={x:n,y:r},u=await Yo(e,a),d=Es(gr(i)),f=rh(d);let h=c[f],p=c[d];if(s){const v=f==="y"?"top":"left",w=f==="y"?"bottom":"right",S=h+u[v],x=h-u[w];h=nh(S,h,x)}if(o){const v=d==="y"?"top":"left",w=d==="y"?"bottom":"right",S=p+u[v],x=p-u[w];p=nh(S,p,x)}const g=l.fn({...e,[f]:h,[d]:p});return{...g,data:{x:g.x-n,y:g.y-r}}}}},eR=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=e,{offset:l=0,mainAxis:a=!0,crossAxis:c=!0}=mr(t,e),u={x:n,y:r},d=Es(i),f=rh(d);let h=u[f],p=u[d];const g=mr(l,e),v=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(a){const x=f==="y"?"height":"width",y=s.reference[f]-s.floating[x]+v.mainAxis,C=s.reference[f]+s.reference[x]-v.mainAxis;h<y?h=y:h>C&&(h=C)}if(c){var w,S;const x=f==="y"?"width":"height",y=["top","left"].includes(gr(i)),C=s.reference[d]-s.floating[x]+(y&&((w=o.offset)==null?void 0:w[d])||0)+(y?0:v.crossAxis),E=s.reference[d]+s.reference[x]+(y?0:((S=o.offset)==null?void 0:S[d])||0)-(y?v.crossAxis:0);p<C?p=C:p>E&&(p=E)}return{[f]:h,[d]:p}}}},tR=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:r,platform:i,elements:s}=e,{apply:o=()=>{},...l}=mr(t,e),a=await Yo(e,l),c=gr(n),u=Ss(n),d=Es(n)==="y",{width:f,height:h}=r.floating;let p,g;c==="top"||c==="bottom"?(p=c,g=u===(await(i.isRTL==null?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(g=c,p=u==="end"?"top":"bottom");const v=h-a.top-a.bottom,w=f-a.left-a.right,S=Jn(h-a[p],v),x=Jn(f-a[g],w),y=!e.middlewareData.shift;let C=S,E=x;if(d?E=u||y?Jn(x,w):w:C=u||y?Jn(S,v):v,y&&!u){const D=Qt(a.left,0),N=Qt(a.right,0),A=Qt(a.top,0),R=Qt(a.bottom,0);d?E=f-2*(D!==0||N!==0?D+N:Qt(a.left,a.right)):C=h-2*(A!==0||R!==0?A+R:Qt(a.top,a.bottom))}await o({...e,availableWidth:E,availableHeight:C});const T=await i.getDimensions(s.floating);return f!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function Ts(t){return Vv(t)?(t.nodeName||"").toLowerCase():"#document"}function en(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function yr(t){var e;return(e=(Vv(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Vv(t){return t instanceof Node||t instanceof en(t).Node}function Gn(t){return t instanceof Element||t instanceof en(t).Element}function Yn(t){return t instanceof HTMLElement||t instanceof en(t).HTMLElement}function Uv(t){return typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof en(t).ShadowRoot}function Xo(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=Tn(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!["inline","contents"].includes(i)}function nR(t){return["table","td","th"].includes(Ts(t))}function lh(t){const e=ah(),n=Tn(t);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function rR(t){let e=Jr(t);for(;Yn(e)&&!As(e);){if(lh(e))return e;e=Jr(e)}return null}function ah(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function As(t){return["html","body","#document"].includes(Ts(t))}function Tn(t){return en(t).getComputedStyle(t)}function bc(t){return Gn(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function Jr(t){if(Ts(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Uv(t)&&t.host||yr(t);return Uv(e)?e.host:e}function Wv(t){const e=Jr(t);return As(e)?t.ownerDocument?t.ownerDocument.body:t.body:Yn(e)&&Xo(e)?e:Wv(e)}function Zo(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=Wv(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),o=en(i);return s?e.concat(o,o.visualViewport||[],Xo(i)?i:[],o.frameElement&&n?Zo(o.frameElement):[]):e.concat(i,Zo(i,[],n))}function qv(t){const e=Tn(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=Yn(t),s=i?t.offsetWidth:n,o=i?t.offsetHeight:r,l=pc(n)!==s||pc(r)!==o;return l&&(n=s,r=o),{width:n,height:r,$:l}}function ch(t){return Gn(t)?t:t.contextElement}function Ms(t){const e=ch(t);if(!Yn(e))return Kr(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=qv(e);let o=(s?pc(n.width):n.width)/r,l=(s?pc(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const iR=Kr(0);function Kv(t){const e=en(t);return!ah()||!e.visualViewport?iR:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function sR(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==en(t)?!1:e}function Oi(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=ch(t);let o=Kr(1);e&&(r?Gn(r)&&(o=Ms(r)):o=Ms(t));const l=sR(s,n,r)?Kv(s):Kr(0);let a=(i.left+l.x)/o.x,c=(i.top+l.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(s){const f=en(s),h=r&&Gn(r)?en(r):r;let p=f,g=p.frameElement;for(;g&&r&&h!==p;){const v=Ms(g),w=g.getBoundingClientRect(),S=Tn(g),x=w.left+(g.clientLeft+parseFloat(S.paddingLeft))*v.x,y=w.top+(g.clientTop+parseFloat(S.paddingTop))*v.y;a*=v.x,c*=v.y,u*=v.x,d*=v.y,a+=x,c+=y,p=en(g),g=p.frameElement}}return yc({width:u,height:d,x:a,y:c})}const oR=[":popover-open",":modal"];function uh(t){return oR.some(e=>{try{return t.matches(e)}catch{return!1}})}function lR(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",o=yr(r),l=e?uh(e.floating):!1;if(r===o||l&&s)return n;let a={scrollLeft:0,scrollTop:0},c=Kr(1);const u=Kr(0),d=Yn(r);if((d||!d&&!s)&&((Ts(r)!=="body"||Xo(o))&&(a=bc(r)),Yn(r))){const f=Oi(r);c=Ms(r),u.x=f.x+r.clientLeft,u.y=f.y+r.clientTop}return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+u.x,y:n.y*c.y-a.scrollTop*c.y+u.y}}function aR(t){return Array.from(t.getClientRects())}function Jv(t){return Oi(yr(t)).left+bc(t).scrollLeft}function cR(t){const e=yr(t),n=bc(t),r=t.ownerDocument.body,i=Qt(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=Qt(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+Jv(t);const l=-n.scrollTop;return Tn(r).direction==="rtl"&&(o+=Qt(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:l}}function uR(t,e){const n=en(t),r=yr(t),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,l=0,a=0;if(i){s=i.width,o=i.height;const c=ah();(!c||c&&e==="fixed")&&(l=i.offsetLeft,a=i.offsetTop)}return{width:s,height:o,x:l,y:a}}function dR(t,e){const n=Oi(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=Yn(t)?Ms(t):Kr(1),o=t.clientWidth*s.x,l=t.clientHeight*s.y,a=i*s.x,c=r*s.y;return{width:o,height:l,x:a,y:c}}function Gv(t,e,n){let r;if(e==="viewport")r=uR(t,n);else if(e==="document")r=cR(yr(t));else if(Gn(e))r=dR(e,n);else{const i=Kv(t);r={...e,x:e.x-i.x,y:e.y-i.y}}return yc(r)}function Yv(t,e){const n=Jr(t);return n===e||!Gn(n)||As(n)?!1:Tn(n).position==="fixed"||Yv(n,e)}function fR(t,e){const n=e.get(t);if(n)return n;let r=Zo(t,[],!1).filter(l=>Gn(l)&&Ts(l)!=="body"),i=null;const s=Tn(t).position==="fixed";let o=s?Jr(t):t;for(;Gn(o)&&!As(o);){const l=Tn(o),a=lh(o);!a&&l.position==="fixed"&&(i=null),(s?!a&&!i:!a&&l.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||Xo(o)&&!a&&Yv(t,o))?r=r.filter(u=>u!==o):i=l,o=Jr(o)}return e.set(t,r),r}function hR(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const o=[...n==="clippingAncestors"?uh(e)?[]:fR(e,this._c):[].concat(n),r],l=o[0],a=o.reduce((c,u)=>{const d=Gv(e,u,i);return c.top=Qt(d.top,c.top),c.right=Jn(d.right,c.right),c.bottom=Jn(d.bottom,c.bottom),c.left=Qt(d.left,c.left),c},Gv(e,l,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function pR(t){const{width:e,height:n}=qv(t);return{width:e,height:n}}function mR(t,e,n){const r=Yn(e),i=yr(e),s=n==="fixed",o=Oi(t,!0,s,e);let l={scrollLeft:0,scrollTop:0};const a=Kr(0);if(r||!r&&!s)if((Ts(e)!=="body"||Xo(i))&&(l=bc(e)),r){const d=Oi(e,!0,s,e);a.x=d.x+e.clientLeft,a.y=d.y+e.clientTop}else i&&(a.x=Jv(i));const c=o.left+l.scrollLeft-a.x,u=o.top+l.scrollTop-a.y;return{x:c,y:u,width:o.width,height:o.height}}function dh(t){return Tn(t).position==="static"}function Xv(t,e){return!Yn(t)||Tn(t).position==="fixed"?null:e?e(t):t.offsetParent}function Zv(t,e){const n=en(t);if(uh(t))return n;if(!Yn(t)){let i=Jr(t);for(;i&&!As(i);){if(Gn(i)&&!dh(i))return i;i=Jr(i)}return n}let r=Xv(t,e);for(;r&&nR(r)&&dh(r);)r=Xv(r,e);return r&&As(r)&&dh(r)&&!lh(r)?n:r||rR(t)||n}const gR=async function(t){const e=this.getOffsetParent||Zv,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 Tn(t).direction==="rtl"}const bR={convertOffsetParentRelativeRectToViewportRelativeRect:lR,getDocumentElement:yr,getClippingRect:hR,getOffsetParent:Zv,getElementRects:gR,getClientRects:aR,getDimensions:pR,getScale:Ms,isElement:Gn,isRTL:yR};function vR(t,e){let n=null,r;const i=yr(t);function s(){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),s();const{left:c,top:u,width:d,height:f}=t.getBoundingClientRect();if(l||e(),!d||!f)return;const h=mc(u),p=mc(i.clientWidth-(c+d)),g=mc(i.clientHeight-(u+f)),v=mc(c),S={rootMargin:-h+"px "+-p+"px "+-g+"px "+-v+"px",threshold:Qt(0,Jn(1,a))||1};let x=!0;function y(C){const E=C[0].intersectionRatio;if(E!==a){if(!x)return o();E?o(!1,E):r=setTimeout(()=>{o(!1,1e-7)},1e3)}x=!1}try{n=new IntersectionObserver(y,{...S,root:i.ownerDocument})}catch{n=new IntersectionObserver(y,S)}n.observe(t)}return o(!0),s}function wR(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,c=ch(t),u=i||s?[...c?Zo(c):[],...Zo(e)]:[];u.forEach(w=>{i&&w.addEventListener("scroll",n,{passive:!0}),s&&w.addEventListener("resize",n)});const d=c&&l?vR(c,n):null;let f=-1,h=null;o&&(h=new ResizeObserver(w=>{let[S]=w;S&&S.target===c&&h&&(h.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(e)})),n()}),c&&!a&&h.observe(c),h.observe(e));let p,g=a?Oi(t):null;a&&v();function v(){const w=Oi(t);g&&(w.x!==g.x||w.y!==g.y||w.width!==g.width||w.height!==g.height)&&n(),g=w,p=requestAnimationFrame(v)}return n(),()=>{var w;u.forEach(S=>{i&&S.removeEventListener("scroll",n),s&&S.removeEventListener("resize",n)}),d==null||d(),(w=h)==null||w.disconnect(),h=null,a&&cancelAnimationFrame(p)}}const xR=ZD,kR=QD,CR=GD,SR=tR,ER=YD,Qv=JD,TR=eR,AR=(t,e,n)=>{const r=new Map,i={platform:bR,...n},s={...i.platform,_c:r};return KD(t,e,{...i,platform:s})};var vc=typeof document<"u"?_.useLayoutEffect:_.useEffect;function wc(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,i;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(!wc(t[r],e[r]))return!1;return!0}if(i=Object.keys(t),n=i.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&t.$$typeof)&&!wc(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function ew(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function tw(t,e){const n=ew(t);return Math.round(e*n)/n}function nw(t){const e=le.useRef(t);return vc(()=>{e.current=t}),e}function MR(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:l=!0,whileElementsMounted:a,open:c}=t,[u,d]=le.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[f,h]=le.useState(r);wc(f,r)||h(r);const[p,g]=le.useState(null),[v,w]=le.useState(null),S=le.useCallback(G=>{G!==E.current&&(E.current=G,g(G))},[]),x=le.useCallback(G=>{G!==T.current&&(T.current=G,w(G))},[]),y=s||p,C=o||v,E=le.useRef(null),T=le.useRef(null),D=le.useRef(u),N=a!=null,A=nw(a),R=nw(i),P=le.useCallback(()=>{if(!E.current||!T.current)return;const G={placement:e,strategy:n,middleware:f};R.current&&(G.platform=R.current),AR(E.current,T.current,G).then(ie=>{const Z={...ie,isPositioned:!0};B.current&&!wc(D.current,Z)&&(D.current=Z,m1.flushSync(()=>{d(Z)}))})},[f,e,n,R]);vc(()=>{c===!1&&D.current.isPositioned&&(D.current.isPositioned=!1,d(G=>({...G,isPositioned:!1})))},[c]);const B=le.useRef(!1);vc(()=>(B.current=!0,()=>{B.current=!1}),[]),vc(()=>{if(y&&(E.current=y),C&&(T.current=C),y&&C){if(A.current)return A.current(y,C,P);P()}},[y,C,P,A,N]);const z=le.useMemo(()=>({reference:E,floating:T,setReference:S,setFloating:x}),[S,x]),U=le.useMemo(()=>({reference:y,floating:C}),[y,C]),J=le.useMemo(()=>{const G={position:n,left:0,top:0};if(!U.floating)return G;const ie=tw(U.floating,u.x),Z=tw(U.floating,u.y);return l?{...G,transform:"translate("+ie+"px, "+Z+"px)",...ew(U.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:ie,top:Z}},[n,l,U.floating,u.x,u.y]);return le.useMemo(()=>({...u,update:P,refs:z,elements:U,floatingStyles:J}),[u,P,z,U,J])}const OR=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:i}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?Qv({element:r.current,padding:i}).fn(n):{}:r?Qv({element:r,padding:i}).fn(n):{}}}},_R=(t,e)=>({...xR(t),options:[t,e]}),NR=(t,e)=>({...kR(t),options:[t,e]}),DR=(t,e)=>({...TR(t),options:[t,e]}),RR=(t,e)=>({...CR(t),options:[t,e]}),LR=(t,e)=>({...SR(t),options:[t,e]}),IR=(t,e)=>({...ER(t),options:[t,e]}),PR=(t,e)=>({...OR(t),options:[t,e]}),FR=_.forwardRef((t,e)=>{const{children:n,width:r=10,height:i=5,...s}=t;return _.createElement(Mi.svg,dt({},s,{ref:e,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none"}),t.asChild?n:_.createElement("polygon",{points:"0,0 30,0 15,10"}))});function $R(t){const[e,n]=_.useState(void 0);return Cs(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,l;if("borderBoxSize"in s){const a=s.borderBoxSize,c=Array.isArray(a)?a[0]:a;o=c.inlineSize,l=c.blockSize}else o=t.offsetWidth,l=t.offsetHeight;n({width:o,height:l})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}const rw="Popper",[iw,sw]=Ov(rw),[BR,ow]=iw(rw),jR=t=>{const{__scopePopper:e,children:n}=t,[r,i]=_.useState(null);return _.createElement(BR,{scope:e,anchor:r,onAnchorChange:i},n)},HR="PopperAnchor",zR=_.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...i}=t,s=ow(HR,n),o=_.useRef(null),l=Ai(e,o);return _.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||o.current)}),r?null:_.createElement(Mi.div,dt({},i,{ref:l}))}),lw="PopperContent",[VR,UR]=iw(lw),WR=_.forwardRef((t,e)=>{var n,r,i,s,o,l,a,c;const{__scopePopper:u,side:d="bottom",sideOffset:f=0,align:h="center",alignOffset:p=0,arrowPadding:g=0,avoidCollisions:v=!0,collisionBoundary:w=[],collisionPadding:S=0,sticky:x="partial",hideWhenDetached:y=!1,updatePositionStrategy:C="optimized",onPlaced:E,...T}=t,D=ow(lw,u),[N,A]=_.useState(null),R=Ai(e,$=>A($)),[P,B]=_.useState(null),z=$R(P),U=(n=z==null?void 0:z.width)!==null&&n!==void 0?n:0,J=(r=z==null?void 0:z.height)!==null&&r!==void 0?r:0,G=d+(h!=="center"?"-"+h:""),ie=typeof S=="number"?S:{top:0,right:0,bottom:0,left:0,...S},Z=Array.isArray(w)?w:[w],ke=Z.length>0,Le={padding:ie,boundary:Z.filter(JR),altBoundary:ke},{refs:$e,floatingStyles:Ee,placement:ve,isPositioned:De,middlewareData:Ie}=MR({strategy:"fixed",placement:G,whileElementsMounted:(...$)=>wR(...$,{animationFrame:C==="always"}),elements:{reference:D.anchor},middleware:[_R({mainAxis:f+J,alignmentAxis:p}),v&&NR({mainAxis:!0,crossAxis:!1,limiter:x==="partial"?DR():void 0,...Le}),v&&RR({...Le}),LR({...Le,apply:({elements:$,rects:j,availableWidth:q,availableHeight:te})=>{const{width:M,height:m}=j.reference,b=$.floating.style;b.setProperty("--radix-popper-available-width",`${q}px`),b.setProperty("--radix-popper-available-height",`${te}px`),b.setProperty("--radix-popper-anchor-width",`${M}px`),b.setProperty("--radix-popper-anchor-height",`${m}px`)}}),P&&PR({element:P,padding:g}),GR({arrowWidth:U,arrowHeight:J}),y&&IR({strategy:"referenceHidden",...Le})]}),[tt,nt]=cw(ve),Ge=Wr(E);Cs(()=>{De&&(Ge==null||Ge())},[De,Ge]);const Ye=(i=Ie.arrow)===null||i===void 0?void 0:i.x,Ot=(s=Ie.arrow)===null||s===void 0?void 0:s.y,xt=((o=Ie.arrow)===null||o===void 0?void 0:o.centerOffset)!==0,[it,at]=_.useState();return Cs(()=>{N&&at(window.getComputedStyle(N).zIndex)},[N]),_.createElement("div",{ref:$e.setFloating,"data-radix-popper-content-wrapper":"",style:{...Ee,transform:De?Ee.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:it,"--radix-popper-transform-origin":[(l=Ie.transformOrigin)===null||l===void 0?void 0:l.x,(a=Ie.transformOrigin)===null||a===void 0?void 0:a.y].join(" ")},dir:t.dir},_.createElement(VR,{scope:u,placedSide:tt,onArrowChange:B,arrowX:Ye,arrowY:Ot,shouldHideArrow:xt},_.createElement(Mi.div,dt({"data-side":tt,"data-align":nt},T,{ref:R,style:{...T.style,animation:De?void 0:"none",opacity:(c=Ie.hide)!==null&&c!==void 0&&c.referenceHidden?0:void 0}}))))}),aw="PopperArrow",qR={top:"bottom",right:"left",bottom:"top",left:"right"},KR=_.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,s=UR(aw,r),o=qR[s.placedSide];return _.createElement("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0}},_.createElement(FR,dt({},i,{ref:n,style:{...i.style,display:"block"}})))});function JR(t){return t!==null}const GR=t=>({name:"transformOrigin",options:t,fn(e){var n,r,i,s,o;const{placement:l,rects:a,middlewareData:c}=e,d=((n=c.arrow)===null||n===void 0?void 0:n.centerOffset)!==0,f=d?0:t.arrowWidth,h=d?0:t.arrowHeight,[p,g]=cw(l),v={start:"0%",center:"50%",end:"100%"}[g],w=((r=(i=c.arrow)===null||i===void 0?void 0:i.x)!==null&&r!==void 0?r:0)+f/2,S=((s=(o=c.arrow)===null||o===void 0?void 0:o.y)!==null&&s!==void 0?s:0)+h/2;let x="",y="";return p==="bottom"?(x=d?v:`${w}px`,y=`${-h}px`):p==="top"?(x=d?v:`${w}px`,y=`${a.floating.height+h}px`):p==="right"?(x=`${-h}px`,y=d?v:`${S}px`):p==="left"&&(x=`${a.floating.width+h}px`,y=d?v:`${S}px`),{data:{x,y}}}});function cw(t){const[e,n="center"]=t.split("-");return[e,n]}const YR=jR,XR=zR,ZR=WR;function QR(t,e){return _.useReducer((n,r)=>{const i=e[n][r];return i??n},t)}const uw=t=>{const{present:e,children:n}=t,r=eL(e),i=typeof n=="function"?n({present:r.isPresent}):_.Children.only(n),s=Ai(r.ref,i.ref);return typeof n=="function"||r.isPresent?_.cloneElement(i,{ref:s}):null};uw.displayName="Presence";function eL(t){const[e,n]=_.useState(),r=_.useRef({}),i=_.useRef(t),s=_.useRef("none"),o=t?"mounted":"unmounted",[l,a]=QR(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return _.useEffect(()=>{const c=xc(r.current);s.current=l==="mounted"?c:"none"},[l]),Cs(()=>{const c=r.current,u=i.current;if(u!==t){const f=s.current,h=xc(c);t?a("MOUNT"):h==="none"||(c==null?void 0:c.display)==="none"?a("UNMOUNT"):a(u&&f!==h?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,a]),Cs(()=>{if(e){const c=d=>{const h=xc(r.current).includes(d.animationName);d.target===e&&h&&nn.flushSync(()=>a("ANIMATION_END"))},u=d=>{d.target===e&&(s.current=xc(r.current))};return e.addEventListener("animationstart",u),e.addEventListener("animationcancel",c),e.addEventListener("animationend",c),()=>{e.removeEventListener("animationstart",u),e.removeEventListener("animationcancel",c),e.removeEventListener("animationend",c)}}else a("ANIMATION_END")},[e,a]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:_.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function xc(t){return(t==null?void 0:t.animationName)||"none"}function tL({prop:t,defaultProp:e,onChange:n=()=>{}}){const[r,i]=nL({defaultProp:e,onChange:n}),s=t!==void 0,o=s?t:r,l=Wr(n),a=_.useCallback(c=>{if(s){const d=typeof c=="function"?c(t):c;d!==t&&l(d)}else i(c)},[s,t,i,l]);return[o,a]}function nL({defaultProp:t,onChange:e}){const n=_.useState(t),[r]=n,i=_.useRef(r),s=Wr(e);return _.useEffect(()=>{i.current!==r&&(s(r),i.current=r)},[r,i,s]),n}var rL=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Os=new WeakMap,kc=new WeakMap,Cc={},fh=0,dw=function(t){return t&&(t.host||dw(t.parentNode))},iL=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=dw(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},sL=function(t,e,n,r){var i=iL(e,Array.isArray(t)?t:[t]);Cc[n]||(Cc[n]=new WeakMap);var s=Cc[n],o=[],l=new Set,a=new Set(i),c=function(d){!d||l.has(d)||(l.add(d),c(d.parentNode))};i.forEach(c);var u=function(d){!d||a.has(d)||Array.prototype.forEach.call(d.children,function(f){if(l.has(f))u(f);else try{var h=f.getAttribute(r),p=h!==null&&h!=="false",g=(Os.get(f)||0)+1,v=(s.get(f)||0)+1;Os.set(f,g),s.set(f,v),o.push(f),g===1&&p&&kc.set(f,!0),v===1&&f.setAttribute(n,"true"),p||f.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",f,w)}})};return u(e),l.clear(),fh++,function(){o.forEach(function(d){var f=Os.get(d)-1,h=s.get(d)-1;Os.set(d,f),s.set(d,h),f||(kc.has(d)||d.removeAttribute(r),kc.delete(d)),h||d.removeAttribute(n)}),fh--,fh||(Os=new WeakMap,Os=new WeakMap,kc=new WeakMap,Cc={})}},oL=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),i=rL(t);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live]"))),sL(r,i,n,"aria-hidden")):function(){return null}},Xn=function(){return Xn=Object.assign||function(e){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},Xn.apply(this,arguments)};function fw(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n}function lL(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return t.concat(s||Array.prototype.slice.call(e))}typeof SuppressedError=="function"&&SuppressedError;var Sc="right-scroll-bar-position",Ec="width-before-scroll-bar",aL="with-scroll-bars-hidden",cL="--removed-body-scroll-bar-size";function hh(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function uL(t,e){var n=_.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=e,n.facade}var dL=typeof window<"u"?le.useLayoutEffect:le.useEffect,hw=new WeakMap;function fL(t,e){var n=uL(null,function(r){return t.forEach(function(i){return hh(i,r)})});return dL(function(){var r=hw.get(n);if(r){var i=new Set(r),s=new Set(t),o=n.current;i.forEach(function(l){s.has(l)||hh(l,null)}),s.forEach(function(l){i.has(l)||hh(l,o)})}hw.set(n,t)},[t]),n}function hL(t){return t}function pL(t,e){e===void 0&&(e=hL);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(s){var o=e(s,r);return n.push(o),function(){n=n.filter(function(l){return l!==o})}},assignSyncMedium:function(s){for(r=!0;n.length;){var o=n;n=[],o.forEach(s)}n={push:function(l){return s(l)},filter:function(){return n}}},assignMedium:function(s){r=!0;var o=[];if(n.length){var l=n;n=[],l.forEach(s),o=n}var a=function(){var u=o;o=[],u.forEach(s)},c=function(){return Promise.resolve().then(a)};c(),n={push:function(u){o.push(u),c()},filter:function(u){return o=o.filter(u),n}}}};return i}function mL(t){t===void 0&&(t={});var e=pL(null);return e.options=Xn({async:!0,ssr:!1},t),e}var pw=function(t){var e=t.sideCar,n=fw(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return le.createElement(r,Xn({},n))};pw.isSideCarExport=!0;function gL(t,e){return t.useMedium(e),pw}var mw=mL(),ph=function(){},Tc=le.forwardRef(function(t,e){var n=le.useRef(null),r=le.useState({onScrollCapture:ph,onWheelCapture:ph,onTouchMoveCapture:ph}),i=r[0],s=r[1],o=t.forwardProps,l=t.children,a=t.className,c=t.removeScrollBar,u=t.enabled,d=t.shards,f=t.sideCar,h=t.noIsolation,p=t.inert,g=t.allowPinchZoom,v=t.as,w=v===void 0?"div":v,S=fw(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as"]),x=f,y=fL([n,e]),C=Xn(Xn({},S),i);return le.createElement(le.Fragment,null,u&&le.createElement(x,{sideCar:mw,removeScrollBar:c,shards:d,noIsolation:h,inert:p,setCallbacks:s,allowPinchZoom:!!g,lockRef:n}),o?le.cloneElement(le.Children.only(l),Xn(Xn({},C),{ref:y})):le.createElement(w,Xn({},C,{className:a,ref:y}),l))});Tc.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Tc.classNames={fullWidth:Ec,zeroRight:Sc};var yL=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function bL(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=yL();return e&&t.setAttribute("nonce",e),t}function vL(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function wL(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var xL=function(){var t=0,e=null;return{add:function(n){t==0&&(e=bL())&&(vL(e,n),wL(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},kL=function(){var t=xL();return function(e,n){le.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},gw=function(){var t=kL(),e=function(n){var r=n.styles,i=n.dynamic;return t(r,i),null};return e},CL={left:0,top:0,right:0,gap:0},mh=function(t){return parseInt(t||"",10)||0},SL=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],i=e[t==="padding"?"paddingRight":"marginRight"];return[mh(n),mh(r),mh(i)]},EL=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return CL;var e=SL(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},TL=gw(),_s="data-scroll-locked",AL=function(t,e,n,r){var i=t.left,s=t.top,o=t.right,l=t.gap;return n===void 0&&(n="margin"),`
|
399
|
-
.`.concat(
|
383
|
+
3. "-" cannot repeat`);Je.customSchemes.push([t,e])}function _N(){Je.scanner=xN(Je.customSchemes);for(let t=0;t<Je.tokenQueue.length;t++)Je.tokenQueue[t][1]({scanner:Je.scanner});Je.parser=EN(Je.scanner.tokens);for(let t=0;t<Je.pluginQueue.length;t++)Je.pluginQueue[t][1]({scanner:Je.scanner,parser:Je.parser});Je.initialized=!0}function Cv(t){return Je.initialized||_N(),TN(Je.parser.start,t,kN(Je.scanner.start,t))}function Sv(t,e,n){if(e===void 0&&(e=null),n===void 0&&(n=null),e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new qf(n),i=Cv(t),s=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&s.push(l.toFormattedObject(r))}return s}function NN(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function DN(t){return new je({key:new We("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,l=NS(n.doc,[...e]);if(BS(l).forEach(({newRange:c})=>{const u=RS(r.doc,c,h=>h.isTextblock);let d,f;if(u.length>1?(d=u[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ")):u.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")),d&&f){const h=f.split(" ").filter(w=>w!=="");if(h.length<=0)return!1;const p=h[h.length-1],g=d.pos+f.lastIndexOf(p);if(!p)return!1;const v=Cv(p).map(w=>w.toObject());if(!NN(v))return!1;v.filter(w=>w.isLink).map(w=>({...w,from:g+w.start+1,to:g+w.end+1})).filter(w=>r.schema.marks.code?!r.doc.rangeHasMark(w.from,w.to,r.schema.marks.code):!0).filter(w=>t.validate?t.validate(w.value):!0).forEach(w=>{ju(w.from,w.to,r.doc).some(S=>S.mark.type===t.type)||o.addMark(w.from,w.to,t.type.create({href:w.href}))})}}),!!o.steps.length)return o}})}function RN(t){return new je({key:new We("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;if(t.whenNotEditable&&e.editable||r.button!==0)return!1;let o=r.target;const l=[];for(;o.nodeName!=="DIV";)l.push(o),o=o.parentNode;if(!l.find(f=>f.nodeName==="A"))return!1;const a=cg(e.state,t.type.name),c=r.target,u=(i=c==null?void 0:c.href)!==null&&i!==void 0?i:a.href,d=(s=c==null?void 0:c.target)!==null&&s!==void 0?s:a.target;return c&&u?(window.open(u,d),!0):!1}}})}function LN(t){return new je({key:new We("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{state:i}=e,{selection:s}=i,{empty:o}=s;if(o)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});const a=Sv(l).find(c=>c.isLink&&c.value===l);return!l||!a?!1:(t.editor.commands.setMark(t.type,{href:a.href}),!0)}}})}const IN=jt.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(t=>{if(typeof t=="string"){kv(t);return}kv(t.scheme,t.optionalSlashes)})},onDestroy(){ON()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:void 0}},addAttributes(){return{href:{default:null},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:t}){var e;return!((e=t.href)===null||e===void 0)&&e.startsWith("javascript:")?["a",Ce(this.options.HTMLAttributes,{...t,href:""}),0]:["a",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{setLink:t=>({chain:e})=>e().setMark(this.name,t).setMeta("preventAutolink",!0).run(),toggleLink:t=>({chain:e})=>e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Rr({find:t=>{const e=[];if(t){const n=Sv(t).filter(r=>r.isLink);n.length&&n.forEach(r=>e.push({text:r.value,data:{href:r.href},index:r.start}))}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[];return this.options.autolink&&t.push(DN({type:this.type,validate:this.options.validate})),this.options.openOnClick&&t.push(RN({type:this.type,whenNotEditable:this.options.openOnClick==="whenNotEditable"})),this.options.linkOnPaste&&t.push(LN({editor:this.editor,type:this.type})),t}}),PN=Ue.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,considerAnyAsEmpty:!1,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new je({key:new We("placeholder"),props:{decorations:({doc:t,selection:e})=>{var n;const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=e,s=[];if(!r)return null;const{firstChild:o}=t.content,l=o&&o.type.isLeaf,a=o&&o.isAtom,c=this.options.considerAnyAsEmpty?!0:o&&o.type.name===((n=t.type.contentMatch.defaultType)===null||n===void 0?void 0:n.name),u=t.content.childCount<=1&&o&&c&&o.nodeSize<=2&&(!l||!a);return t.descendants((d,f)=>{const h=i>=f&&i<=f+d.nodeSize,p=!d.isLeaf&&!d.childCount;if((h||!this.options.showOnlyCurrent)&&p){const g=[this.options.emptyNodeClass];u&&g.push(this.options.emptyEditorClass);const v=ut.node(f,f+d.nodeSize,{class:g.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:d,pos:f,hasAnchor:h}):this.options.placeholder});s.push(v)}return this.options.includeChildren}),He.create(t,s)}}})]}}),FN=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,$N=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,BN=jt.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",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[ai({find:FN,type:this.type})]},addPasteRules(){return[Rr({find:$N,type:this.type})]}}),jN=ze.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",Ce(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),HN=/^\s*(\[([( |x])?\])\s$/,zN=ze.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList"}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>t.getAttribute("data-checked")==="true",renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",Ce(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div");return s.contentEditable="false",l.type="checkbox",l.addEventListener("change",c=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:u}=c.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:d})=>{const f=n(),h=d.doc.nodeAt(f);return d.setNodeMarkup(f,void 0,{...h==null?void 0:h.attrs,checked:u}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,u)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([c,u])=>{i.setAttribute(c,u)}),i.dataset.checked=t.attrs.checked,t.attrs.checked&&l.setAttribute("checked","checked"),s.append(l,o),i.append(s,a),Object.entries(e).forEach(([c,u])=>{i.setAttribute(c,u)}),{dom:i,contentDOM:a,update:c=>c.type!==this.type?!1:(i.dataset.checked=c.attrs.checked,c.attrs.checked?l.setAttribute("checked","checked"):l.removeAttribute("checked"),!0)}}},addInputRules(){return[Gi({find:HN,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),VN=jt.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",Ce(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function UN(t){var e;const{char:n,allowSpaces:r,allowedPrefixes:i,startOfLine:s,$position:o}=t,l=cE(n),a=new RegExp(`\\s${l}$`),c=s?"^":"",u=r?new RegExp(`${c}${l}.*?(?=\\s${l}|$)`,"gm"):new RegExp(`${c}(?:^)?${l}[^\\s${l}]*`,"gm"),d=((e=o.nodeBefore)===null||e===void 0?void 0:e.isText)&&o.nodeBefore.text;if(!d)return null;const f=o.pos-d.length,h=Array.from(d.matchAll(u)).pop();if(!h||h.input===void 0||h.index===void 0)return null;const p=h.input.slice(Math.max(0,h.index-1),h.index),g=new RegExp(`^[${i==null?void 0:i.join("")}\0]?$`).test(p);if(i!==null&&!g)return null;const v=f+h.index;let w=v+h[0].length;return r&&a.test(d.slice(w-1,w+1))&&(h[0]+=" ",w+=1),v<o.pos&&w>=o.pos?{range:{from:v,to:w},query:h[0].slice(n.length),text:h[0]}:null}const WN=new We("suggestion");function qN({pluginKey:t=WN,editor:e,char:n="@",allowSpaces:r=!1,allowedPrefixes:i=[" "],startOfLine:s=!1,decorationTag:o="span",decorationClass:l="suggestion",command:a=()=>null,items:c=()=>[],render:u=()=>({}),allow:d=()=>!0,findSuggestionMatch:f=UN}){let h;const p=u==null?void 0:u(),g=new je({key:t,view(){return{update:async(v,w)=>{var S,x,y,C,E,T,D;const N=(S=this.key)===null||S===void 0?void 0:S.getState(w),A=(x=this.key)===null||x===void 0?void 0:x.getState(v.state),R=N.active&&A.active&&N.range.from!==A.range.from,P=!N.active&&A.active,B=N.active&&!A.active,z=!P&&!B&&N.query!==A.query,U=P||R,J=z&&!R,G=B||R;if(!U&&!J&&!G)return;const ie=G&&!U?N:A,Z=v.dom.querySelector(`[data-decoration-id="${ie.decorationId}"]`);h={editor:e,range:ie.range,query:ie.query,text:ie.text,items:[],command:ke=>a({editor:e,range:ie.range,props:ke}),decorationNode:Z,clientRect:Z?()=>{var ke;const{decorationId:Le}=(ke=this.key)===null||ke===void 0?void 0:ke.getState(e.state),$e=v.dom.querySelector(`[data-decoration-id="${Le}"]`);return($e==null?void 0:$e.getBoundingClientRect())||null}:null},U&&((y=p==null?void 0:p.onBeforeStart)===null||y===void 0||y.call(p,h)),J&&((C=p==null?void 0:p.onBeforeUpdate)===null||C===void 0||C.call(p,h)),(J||U)&&(h.items=await c({editor:e,query:ie.query})),G&&((E=p==null?void 0:p.onExit)===null||E===void 0||E.call(p,h)),J&&((T=p==null?void 0:p.onUpdate)===null||T===void 0||T.call(p,h)),U&&((D=p==null?void 0:p.onStart)===null||D===void 0||D.call(p,h))},destroy:()=>{var v;h&&((v=p==null?void 0:p.onExit)===null||v===void 0||v.call(p,h))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(v,w,S,x){const{isEditable:y}=e,{composing:C}=e.view,{selection:E}=v,{empty:T,from:D}=E,N={...w};if(N.composing=C,y&&(T||e.view.composing)){(D<w.range.from||D>w.range.to)&&!C&&!w.composing&&(N.active=!1);const A=f({char:n,allowSpaces:r,allowedPrefixes:i,startOfLine:s,$position:E.$from}),R=`id_${Math.floor(Math.random()*4294967295)}`;A&&d({editor:e,state:x,range:A.range})?(N.active=!0,N.decorationId=w.decorationId?w.decorationId:R,N.range=A.range,N.query=A.query,N.text=A.text):N.active=!1}else N.active=!1;return N.active||(N.decorationId=null,N.range={from:0,to:0},N.query=null,N.text=null),N}},props:{handleKeyDown(v,w){var S;const{active:x,range:y}=g.getState(v.state);return x&&((S=p==null?void 0:p.onKeyDown)===null||S===void 0?void 0:S.call(p,{view:v,event:w,range:y}))||!1},decorations(v){const{active:w,range:S,decorationId:x}=g.getState(v);return w?He.create(v.doc,[ut.inline(S.from,S.to,{nodeName:o,class:l,"data-decoration-id":x})]):null}}});return g}const KN=Ue.create({name:"slash-command",addOptions(){return{suggestion:{char:"/",command:({editor:t,range:e,props:n})=>{n.command({editor:t,range:e})}}}},addProseMirrorPlugins(){return[qN({editor:this.editor,...this.options.suggestion})]}}),JN=({query:t})=>[{title:"Text",description:"Just start typing with plain text.",searchTerms:["p","paragraph"],icon:_.jsx(vy,{size:18}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).toggleNode("paragraph","paragraph").run()}},{title:"To-do List",description:"Track tasks with a to-do list.",searchTerms:["todo","task","list","check","checkbox"],icon:_.jsx(yy,{size:18}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).toggleTaskList().run()}},{title:"Heading 1",description:"Big section heading.",searchTerms:["title","big","large"],icon:_.jsx(ud,{size:18}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).setNode("heading",{level:1}).run()}},{title:"Heading 2",description:"Medium section heading.",searchTerms:["subtitle","medium"],icon:_.jsx(dd,{size:18}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).setNode("heading",{level:2}).run()}},{title:"Heading 3",description:"Small section heading.",searchTerms:["subtitle","small"],icon:_.jsx(fd,{size:18}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).setNode("heading",{level:3}).run()}},{title:"Bullet List",description:"Create a simple bullet list.",searchTerms:["unordered","point"],icon:_.jsx(hd,{size:18}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).toggleBulletList().run()}},{title:"Numbered List",description:"Create a list with numbering.",searchTerms:["ordered"],icon:_.jsx(xo,{size:18}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).toggleOrderedList().run()}},{title:"Divider",description:"Visually divide content.",searchTerms:["hr","divider","break","line","delimiter"],icon:_.jsx(mA,{size:18}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).setHorizontalRule().run()}},{title:"Quote",description:"Capture a quote.",searchTerms:["blockquote"],icon:_.jsx(pd,{size:18}),image:"",command:({editor:e,range:n})=>e.chain().focus().deleteRange(n).toggleNode("paragraph","paragraph").toggleBlockquote().run()},{title:"Code",description:"Capture a code snippet.",searchTerms:["codeblock"],icon:_.jsx(Ul,{size:18}),image:"",command:({editor:e,range:n})=>e.chain().focus().deleteRange(n).toggleCodeBlock().run()},{title:"Table",description:"Create a table.",searchTerms:["table"],icon:_.jsx(wA,{size:18}),image:"",command:({editor:e,range:n})=>e.chain().focus().deleteRange(n).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{title:"Image",description:"Upload an image from your computer.",searchTerms:["photo","picture","media"],icon:_.jsx(pA,{size:18}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).run();const r=document.createElement("input");r.type="file",r.accept="image/*",r.onchange=async()=>{var i;if((i=r.files)!=null&&i.length){const s=r.files[0],o=e.view.state.selection.from;Cy(s,e.view,o)}},r.click()}},{title:"Video Embed",description:"Embed a video from YouTube, Vimeo, etc.",searchTerms:["iframe","embed","video","youtube"],icon:_.jsx(ky,{}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).setActionButton("iframe").run()}},{title:"Twitter",description:"Embed a Twitter tweet.",searchTerms:["embed","twitter","tweet"],icon:_.jsx(wy,{}),image:"",command:({editor:e,range:n})=>{e.chain().focus().deleteRange(n).setActionButton("twitter").run()}},{title:"2 Columns",description:"Create 2 columns of block",searchTerms:["col","column","2","layout"],icon:_.jsx(fy,{}),image:"",command:({editor:e})=>{e.chain().focus().setColumns(2).focus(e.state.selection.head-1).run()}},{title:"3 Columns",description:"Create 3 columns of block",searchTerms:["col","column","3","layout"],icon:_.jsx(cA,{}),image:"",command:({editor:e})=>{e.chain().focus().setColumns(3).focus(e.state.selection.head-1).run()}}].filter(e=>{if(typeof t=="string"&&t.length>0){const n=t.toLowerCase();return e.title.toLowerCase().includes(n)||e.description.toLowerCase().includes(n)||e.searchTerms&&e.searchTerms.some(r=>r.includes(n))}return!0}),GN=(t,e)=>{const n=t.offsetHeight,r=e?e.offsetHeight:0,i=e.offsetTop,s=i+r;i<t.scrollTop?t.scrollTop-=t.scrollTop-i+5:s>n+t.scrollTop&&(t.scrollTop+=s-n-t.scrollTop+5)},YN=({items:t,command:e,editor:n})=>{const[r,i]=O.useState(0),s=O.useCallback(l=>{const a=t[l];a&&(a.title==="Continue writing"||e(a))},[e,n,t]);O.useEffect(()=>{const l=["ArrowUp","ArrowDown","Enter"],a=c=>{if(l.includes(c.key))return c.preventDefault(),c.key==="ArrowUp"?(i((r+t.length-1)%t.length),!0):c.key==="ArrowDown"?(i((r+1)%t.length),!0):c.key==="Enter"?(s(r),!0):!1};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a)}},[t,r,i,s]),O.useEffect(()=>{i(0)},[t]);const o=O.useRef(null);return O.useLayoutEffect(()=>{const l=o==null?void 0:o.current,a=l==null?void 0:l.children[r];a&&l&&GN(l,a)},[r]),t.length>0?_.jsx("div",{id:"slash-command",ref:o,className:"z-50 h-auto max-h-[330px] w-72 overflow-y-auto scroll-smooth rounded-md border border-[#DDD] bg-white px-1 py-2 shadow-md transition-all",children:t.map((l,a)=>_.jsxs("button",{className:`flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm text-neutral-500 hover:bg-neutral-100 hover:border-neutral-200 border border-transparent transition-all ${a===r?"bg-neutral-200 text-neutral-800":""}`,onClick:()=>s(a),children:[_.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border border-neutral-200 bg-white",children:l.icon}),_.jsxs("div",{children:[_.jsx("p",{className:"font-medium",children:l.title}),_.jsx("p",{className:"text-xs text-neutral-500",children:l.description})]})]},a))}):null},XN=()=>{let t=null,e=null;return{onStart:n=>{t=new ly(YN,{props:n,editor:n.editor}),e=fi("body",{getReferenceClientRect:n.clientRect,appendTo:()=>document.body,content:t.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"})},onUpdate:n=>{t==null||t.updateProps(n),e&&e[0].setProps({getReferenceClientRect:n.clientRect})},onKeyDown:n=>{var r;return n.event.key==="Escape"?(e==null||e[0].hide(),!0):(r=t==null?void 0:t.ref)==null?void 0:r.onKeyDown(n)},onExit:()=>{e==null||e[0].destroy(),t==null||t.destroy()}}},ZN=KN.configure({suggestion:{items:JN,render:XN}}),QN=ov.extend({renderHTML(){return["div",Ce(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}}),eD=Ue.create({name:"columnExtension",addExtensions(){const t=[];return this.options.column!==!1&&t.push(Oy),this.options.columns!==!1&&t.push(Jl),t}}),tD=Ue.create({name:"CustomKeymap",addCommands(){return{selectTextWithinNodeBoundaries:()=>({editor:t,commands:e})=>{const{state:n}=t,{tr:r}=n,i=r.selection.$from.start(),s=r.selection.$to.end();return e.setTextSelection({from:i,to:s})}}},addKeyboardShortcuts(){return{"Mod-a":({editor:t})=>{const{state:e}=t,{tr:n}=e,r=n.selection.from,i=n.selection.to,s=n.selection.$from.start(),o=n.selection.$to.end();return r>s||i<o?(t.chain().selectTextWithinNodeBoundaries().run(),!0):!1}}}}),nD=Ue.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;return(e=t.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),Ev=[{tooltip:"Align left",action:t=>t({dataAlign:"start",dataFloat:null}),icon:"AlignLeft",isActive:t=>t.dataAlign==="start"},{tooltip:"Align center",action:t=>t({dataAlign:"center",dataFloat:null}),icon:"AlignCenter",isActive:t=>t.dataAlign==="center"},{tooltip:"Align right",action:t=>t({dataAlign:"end",dataFloat:null}),icon:"AlignRight",isActive:t=>t.dataAlign==="end"},{tooltip:"Delete",icon:"Trash2",delete:t=>t()}];let ks;const Tv=({node:t,updateAttributes:e,deleteNode:n})=>{const r=Gl(),[i,s]=O.useState(),[o,l]=O.useState(0),[a,c]=O.useState(0),[u,d]=O.useState({}),f=O.useRef(null),[h,p]=O.useState(!1),g=()=>{const P={};Ev.forEach(({tooltip:B,isActive:z})=>{P[B]=!!(z!=null&&z(t.attrs))}),d(P)},v=()=>{const P=document.querySelector(".ProseMirror");if(P&&c(P==null?void 0:P.clientWidth),!!f.current){if(i==="video"){const B=f.current;B.addEventListener("loadeddata",function(){l(B.videoWidth/B.videoHeight),E("left",0)})}else if(i==="iframe"){const B=f.current;B.onload=()=>{l(B.offsetWidth/B.offsetHeight),E("left",0)}}else f.current.onload=()=>{l(f.current.naturalWidth/f.current.naturalHeight)};setTimeout(()=>g(),200)}},w=P=>{ks=P};O.useEffect(()=>{v()},[]);const S=({width:P,height:B})=>P<200||B<200,x=P=>{setTimeout(()=>T(P))},y=P=>{ks=P.clientX,setTimeout(()=>{document.addEventListener("mousemove",x),document.addEventListener("mouseup",C)}),p(!0)},C=()=>{ks=-1,document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",C),p(!1)},E=(P,B)=>{var J,G;if(!f.current){console.error("Media ref is undefined|null",{resizableImg:f.current});return}const z={width:(J=f.current)==null?void 0:J.width,height:(G=f.current)==null?void 0:G.height},U={width:-1,height:-1};P==="left"?U.width=z.width-Math.abs(B):(typeof z.width=="string"&&(z.width=Number(z.width)),U.width=z.width+Math.abs(B)),U.width>a&&(U.width=a),i==="iframe"?U.height=U.width/(16/9):U.height=U.width/o,!S(U)&&e(U)},T=P=>{if(ks===-1)return;const{clientX:B}=P,z=ks-B;if(z===0)return;const U=z>0?"left":"right";setTimeout(()=>{E(U,Math.abs(z)),ks=B})},[D,N]=O.useState(),[A,R]=O.useState();return O.useEffect(()=>{s(t.attrs["media-type"]),g(),N(t.attrs.dataFloat),R(t.attrs.dataAlign)},[t.attrs]),_.jsx(wo,{as:"article",className:Se("media-node-view not-prose transition-all ease-in-out w-full",D&&`f-${t.attrs.dataFloat}`,A&&`justify-${t.attrs.dataAlign}`),children:_.jsxs("div",{className:"w-fit flex relative group transition-all ease-in-out",children:[i==="img"&&_.jsx("img",{src:t.attrs.src,ref:f,className:"rounded-lg",alt:t.attrs.src,width:t.attrs.width,height:t.attrs.height}),i==="video"&&_.jsx("video",{ref:f,className:"rounded-lg",controls:!0,width:t.attrs.width,height:t.attrs.height,children:_.jsx("source",{src:t.attrs.src})}),i==="iframe"&&_.jsx("iframe",{ref:f,className:Se("rounded-lg max-w-full",h&&"pointer-events-none"),src:t.attrs.src,width:t.attrs.width,height:t.attrs.height}),!r&&_.jsxs(_.Fragment,{children:[_.jsx("div",{className:"horizontal-resize-handle group-hover:bg-black group-hover:border-2 group-hover:border-white/80",title:"Resize",onClick:({clientX:P})=>w(P),onMouseDown:y,onMouseUp:C}),_.jsx("section",{className:"media-control-buttons opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:Ev.map(P=>_.jsx("div",{className:"tooltip","data-tip":P.tooltip,children:_.jsx("button",{type:"button",className:Se("btn rounded-none h-8 px-2",u[P.tooltip]&&"active"),onClick:()=>{var B;return P.tooltip==="Delete"?n():(B=P.action)==null?void 0:B.call(P,e)},children:_.jsx("img",{src:P.icon,className:"w-4"})})}))})]})]})})},rD=ze.create({name:"iframe",group:"block",atom:!0,draggable:!0,addOptions(){return{allowFullscreen:!0,HTMLAttributes:{class:"iframe-wrapper"}}},addAttributes(){return{src:{default:null},frameborder:{default:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen},"media-type":{default:"iframe"},alt:{default:null},title:{default:null},width:{default:this.options.width},height:{default:this.options.height},dataAlign:{default:"left"},dataFloat:{default:null}}},addNodeView(){return hi(Tv)},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:t}){return["iframe",Ce(this.options.HTMLAttributes,t)]},addCommands(){return{setIframe:t=>({tr:e,dispatch:n})=>{const{selection:r}=e,i=this.type.create(t);return n&&e.replaceRangeWith(r.from-1,r.to,i),!0}}}});var iD="https://platform.twitter.com/widgets.js",Jf="createTweet",sD=function(e){var n=O.useRef(null),r=O.useState(!0),i=r[0],s=r[1];return O.useEffect(function(){var o=!0,l=require("scriptjs");return l(iD,"twitter-embed",function(){if(!window.twttr){console.error("Failure to load window.twttr, aborting load");return}if(o){if(!window.twttr.widgets[Jf]){console.error("Method "+Jf+" is not present anymore in twttr.widget api");return}window.twttr.widgets[Jf](e.tweetId,n==null?void 0:n.current,e.options).then(function(a){s(!1),e.onLoad&&e.onLoad(a)})}}),function(){o=!1}},[]),O.createElement(O.Fragment,null,i&&O.createElement(O.Fragment,null,e.placeholder),O.createElement("div",{ref:n}))};const oD=({node:t,editor:e})=>{const[n,r]=O.useState(!0);return O.useEffect(()=>{e==null||e.chain().focus()},[]),_.jsx(wo,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:_.jsxs("div",{className:"w-full max-w-sm",children:[n&&_.jsx(Hy,{width:5,height:5}),_.jsx(sD,{tweetId:t.attrs.tweetId,onLoad:()=>r(!1)})]})})},lD=ze.create({name:"embeddedTweet",group:"block",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:""}}},addAttributes(){return{tweetId:{default:null},align:{default:"center"}}},parseHTML(){return[{tag:"div[data-tweet-id]"}]},renderHTML({HTMLAttributes:t}){return["div",Ce(this.options.HTMLAttributes,t)]},addNodeView(){return hi(oD)},addCommands(){return{setTweetEmbed:t=>({commands:e})=>e.insertContent({type:this.name,attrs:{tweetId:t.tweetId,align:"center"},content:[]})}}}),aD=t=>new je({key:new We("media-paste-drop"),props:{handlePaste(e,n){var i;return Array.from(((i=n.clipboardData)==null?void 0:i.items)||[]).forEach(s=>{const o=s.getAsFile();if(((o==null?void 0:o.type.indexOf("image"))===0||(o==null?void 0:o.type.indexOf("video"))===0)&&(n.preventDefault(),o&&o.size>1024*1024))throw new Error("Image too large")}),!1},handleDrop(e,n){var l;if(!(n.dataTransfer&&n.dataTransfer.files&&n.dataTransfer.files.length))return!1;const i=Array.from(((l=n.dataTransfer)==null?void 0:l.files)??[]).filter(({type:a})=>/image|video/i.test(a));if(i.length===0)return!1;n.preventDefault();const{schema:s}=e.state,o=e.posAtCoords({left:n.clientX,top:n.clientY});return o?(i.forEach(async a=>{const c=new FileReader;if(t){const u=s.nodes.resizableMedia.create({src:await t(a),"media-type":a.type.includes("image")?"img":"video"}),d=e.state.tr.insert(o.pos,u);e.dispatch(d)}else c.onload=u=>{var h;const d=s.nodes.resizableMedia.create({src:(h=u.target)==null?void 0:h.result,"media-type":a.type.includes("image")?"img":"video"}),f=e.state.tr.insert(o.pos,d);e.dispatch(f)},c.readAsDataURL(a)}),!0):!1}}}),cD=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,uD=/!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/,dD=ze.create({name:"resizableMedia",addOptions(){return{HTMLAttributes:{class:"rounded-lg border border-stone-200"},uploadFn:async()=>""}},inline:!1,group:"block",draggable:!0,addAttributes(){return{src:{default:null},"media-type":{default:null},alt:{default:null},title:{default:null},width:{default:"100%"},height:{default:"auto"},dataAlign:{default:"left"},dataFloat:{default:null}}},selectable:!0,parseHTML(){return[{tag:'img[src]:not([src^="data:"])',getAttrs:t=>({src:t.getAttribute("src"),"media-type":"img"})},{tag:"video",getAttrs:t=>({src:t.getAttribute("src"),"media-type":"video"})}]},renderHTML({HTMLAttributes:t}){const{"media-type":e}=t;return e==="img"?["img",Ce(this.options.HTMLAttributes,t)]:e==="video"?["video",{controls:"true",style:"width: 100%",...t},["source",t]]:(e||console.error("TiptapMediaExtension-renderHTML method: Media Type not set, going default with image"),["img",Ce(this.options.HTMLAttributes,t)])},addCommands(){return{setMedia:t=>({commands:e})=>{const{"media-type":n}=t;return n==="img"?e.insertContent({type:this.name,attrs:t}):n==="video"?e.insertContent({type:this.name,attrs:{...t,controls:"true"}}):(n||console.error("TiptapMediaExtension-setMedia: Media Type not set, going default with image"),e.insertContent({type:this.name,attrs:t}))}}},addNodeView(){return hi(Tv)},addKeyboardShortcuts(){return{Enter:({editor:t})=>{const{selection:e}=t.state;if(e.empty)return!1;const n=e.$to.pos;return t.commands.insertContentAt(n,{type:"dBlock",content:[{type:"paragraph"}]})}}},addInputRules(){return[Uu({find:cD,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r,"media-type":"img"}}}),Uu({find:uD,type:this.type,getAttributes:t=>{const[,,e]=t;return{src:e,"media-type":"video"}}})]},addProseMirrorPlugins(){return[aD(this.options.uploadFn),AA()]}});function Av(t,e){let n;return(...i)=>{clearTimeout(n),n=setTimeout(()=>t(...i),e)}}function dt(){return dt=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},dt.apply(null,arguments)}function Ur(t,e,{checkForDefaultPrevented:n=!0}={}){return function(i){if(t==null||t(i),n===!1||!i.defaultPrevented)return e==null?void 0:e(i)}}function fD(t,e){typeof t=="function"?t(e):t!=null&&(t.current=e)}function Mv(...t){return e=>t.forEach(n=>fD(n,e))}function Ai(...t){return O.useCallback(Mv(...t),t)}function Ov(t,e=[]){let n=[];function r(s,o){const l=O.createContext(o),a=n.length;n=[...n,o];function c(d){const{scope:f,children:h,...p}=d,g=(f==null?void 0:f[t][a])||l,v=O.useMemo(()=>p,Object.values(p));return O.createElement(g.Provider,{value:v},h)}function u(d,f){const h=(f==null?void 0:f[t][a])||l,p=O.useContext(h);if(p)return p;if(o!==void 0)return o;throw new Error(`\`${d}\` must be used within \`${s}\``)}return c.displayName=s+"Provider",[c,u]}const i=()=>{const s=n.map(o=>O.createContext(o));return function(l){const a=(l==null?void 0:l[t])||s;return O.useMemo(()=>({[`__scope${t}`]:{...l,[t]:a}}),[l,a])}};return i.scopeName=t,[r,hD(i,...e)]}function hD(...t){const e=t[0];if(t.length===1)return e;const n=()=>{const r=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const o=r.reduce((l,{useScope:a,scopeName:c})=>{const d=a(s)[`__scope${c}`];return{...l,...d}},{});return O.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])}};return n.scopeName=e.scopeName,n}const Gf=O.forwardRef((t,e)=>{const{children:n,...r}=t,i=O.Children.toArray(n),s=i.find(mD);if(s){const o=s.props.children,l=i.map(a=>a===s?O.Children.count(o)>1?O.Children.only(null):O.isValidElement(o)?o.props.children:null:a);return O.createElement(Yf,dt({},r,{ref:e}),O.isValidElement(o)?O.cloneElement(o,void 0,l):null)}return O.createElement(Yf,dt({},r,{ref:e}),n)});Gf.displayName="Slot";const Yf=O.forwardRef((t,e)=>{const{children:n,...r}=t;return O.isValidElement(n)?O.cloneElement(n,{...gD(r,n.props),ref:e?Mv(e,n.ref):n.ref}):O.Children.count(n)>1?O.Children.only(null):null});Yf.displayName="SlotClone";const pD=({children:t})=>O.createElement(O.Fragment,null,t);function mD(t){return O.isValidElement(t)&&t.type===pD}function gD(t,e){const n={...e};for(const r in e){const i=t[r],s=e[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...l)=>{s(...l),i(...l)}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...t,...n}}const Mi=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((t,e)=>{const n=O.forwardRef((r,i)=>{const{asChild:s,...o}=r,l=s?Gf:e;return O.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),O.createElement(l,dt({},o,{ref:i}))});return n.displayName=`Primitive.${e}`,{...t,[e]:n}},{});function yD(t,e){t&&nn.flushSync(()=>t.dispatchEvent(e))}function Wr(t){const e=O.useRef(t);return O.useEffect(()=>{e.current=t}),O.useMemo(()=>(...n)=>{var r;return(r=e.current)===null||r===void 0?void 0:r.call(e,...n)},[])}function bD(t,e=globalThis==null?void 0:globalThis.document){const n=Wr(t);O.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return e.addEventListener("keydown",r),()=>e.removeEventListener("keydown",r)},[n,e])}const Xf="dismissableLayer.update",vD="dismissableLayer.pointerDownOutside",wD="dismissableLayer.focusOutside";let _v;const xD=O.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),kD=O.forwardRef((t,e)=>{var n;const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:l,onDismiss:a,...c}=t,u=O.useContext(xD),[d,f]=O.useState(null),h=(n=d==null?void 0:d.ownerDocument)!==null&&n!==void 0?n:globalThis==null?void 0:globalThis.document,[,p]=O.useState({}),g=Ai(e,D=>f(D)),v=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),S=v.indexOf(w),x=d?v.indexOf(d):-1,y=u.layersWithOutsidePointerEventsDisabled.size>0,C=x>=S,E=CD(D=>{const N=D.target,A=[...u.branches].some(R=>R.contains(N));!C||A||(s==null||s(D),l==null||l(D),D.defaultPrevented||a==null||a())},h),T=SD(D=>{const N=D.target;[...u.branches].some(R=>R.contains(N))||(o==null||o(D),l==null||l(D),D.defaultPrevented||a==null||a())},h);return bD(D=>{x===u.layers.size-1&&(i==null||i(D),!D.defaultPrevented&&a&&(D.preventDefault(),a()))},h),O.useEffect(()=>{if(d)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(_v=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Nv(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=_v)}},[d,h,r,u]),O.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Nv())},[d,u]),O.useEffect(()=>{const D=()=>p({});return document.addEventListener(Xf,D),()=>document.removeEventListener(Xf,D)},[]),O.createElement(Mi.div,dt({},c,{ref:g,style:{pointerEvents:y?C?"auto":"none":void 0,...t.style},onFocusCapture:Ur(t.onFocusCapture,T.onFocusCapture),onBlurCapture:Ur(t.onBlurCapture,T.onBlurCapture),onPointerDownCapture:Ur(t.onPointerDownCapture,E.onPointerDownCapture)}))});function CD(t,e=globalThis==null?void 0:globalThis.document){const n=Wr(t),r=O.useRef(!1),i=O.useRef(()=>{});return O.useEffect(()=>{const s=l=>{if(l.target&&!r.current){let c=function(){Dv(vD,n,a,{discrete:!0})};const a={originalEvent:l};l.pointerType==="touch"?(e.removeEventListener("click",i.current),i.current=c,e.addEventListener("click",i.current,{once:!0})):c()}else e.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",s),e.removeEventListener("click",i.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function SD(t,e=globalThis==null?void 0:globalThis.document){const n=Wr(t),r=O.useRef(!1);return O.useEffect(()=>{const i=s=>{s.target&&!r.current&&Dv(wD,n,{originalEvent:s},{discrete:!1})};return e.addEventListener("focusin",i),()=>e.removeEventListener("focusin",i)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Nv(){const t=new CustomEvent(Xf);document.dispatchEvent(t)}function Dv(t,e,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&i.addEventListener(t,e,{once:!0}),r?yD(i,s):i.dispatchEvent(s)}let Zf=0;function ED(){O.useEffect(()=>{var t,e;const n=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",(t=n[0])!==null&&t!==void 0?t:Rv()),document.body.insertAdjacentElement("beforeend",(e=n[1])!==null&&e!==void 0?e:Rv()),Zf++,()=>{Zf===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(r=>r.remove()),Zf--}},[])}function Rv(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",t}const Qf="focusScope.autoFocusOnMount",eh="focusScope.autoFocusOnUnmount",Lv={bubbles:!1,cancelable:!0},TD=O.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...o}=t,[l,a]=O.useState(null),c=Wr(i),u=Wr(s),d=O.useRef(null),f=Ai(e,g=>a(g)),h=O.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;O.useEffect(()=>{if(r){let g=function(x){if(h.paused||!l)return;const y=x.target;l.contains(y)?d.current=y:qr(d.current,{select:!0})},v=function(x){if(h.paused||!l)return;const y=x.relatedTarget;y!==null&&(l.contains(y)||qr(d.current,{select:!0}))},w=function(x){if(document.activeElement===document.body)for(const C of x)C.removedNodes.length>0&&qr(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",v);const S=new MutationObserver(w);return l&&S.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",v),S.disconnect()}}},[r,l,h.paused]),O.useEffect(()=>{if(l){Fv.add(h);const g=document.activeElement;if(!l.contains(g)){const w=new CustomEvent(Qf,Lv);l.addEventListener(Qf,c),l.dispatchEvent(w),w.defaultPrevented||(AD(DD(Iv(l)),{select:!0}),document.activeElement===g&&qr(l))}return()=>{l.removeEventListener(Qf,c),setTimeout(()=>{const w=new CustomEvent(eh,Lv);l.addEventListener(eh,u),l.dispatchEvent(w),w.defaultPrevented||qr(g??document.body,{select:!0}),l.removeEventListener(eh,u),Fv.remove(h)},0)}}},[l,c,u,h]);const p=O.useCallback(g=>{if(!n&&!r||h.paused)return;const v=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,w=document.activeElement;if(v&&w){const S=g.currentTarget,[x,y]=MD(S);x&&y?!g.shiftKey&&w===y?(g.preventDefault(),n&&qr(x,{select:!0})):g.shiftKey&&w===x&&(g.preventDefault(),n&&qr(y,{select:!0})):w===S&&g.preventDefault()}},[n,r,h.paused]);return O.createElement(Mi.div,dt({tabIndex:-1},o,{ref:f,onKeyDown:p}))});function AD(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(qr(r,{select:e}),document.activeElement!==n)return}function MD(t){const e=Iv(t),n=Pv(e,t),r=Pv(e.reverse(),t);return[n,r]}function Iv(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function Pv(t,e){for(const n of t)if(!OD(n,{upTo:e}))return n}function OD(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function _D(t){return t instanceof HTMLInputElement&&"select"in t}function qr(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&_D(t)&&e&&t.select()}}const Fv=ND();function ND(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=$v(t,e),t.unshift(e)},remove(e){var n;t=$v(t,e),(n=t[0])===null||n===void 0||n.resume()}}}function $v(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function DD(t){return t.filter(e=>e.tagName!=="A")}const Cs=globalThis!=null&&globalThis.document?O.useLayoutEffect:()=>{},RD=le.useId||(()=>{});let LD=0;function ID(t){const[e,n]=le.useState(RD());return Cs(()=>{t||n(r=>r??String(LD++))},[t]),t||(e?`radix-${e}`:"")}const PD=["top","right","bottom","left"],Jn=Math.min,Qt=Math.max,hc=Math.round,pc=Math.floor,Kr=t=>({x:t,y:t}),FD={left:"right",right:"left",bottom:"top",top:"bottom"},$D={start:"end",end:"start"};function th(t,e,n){return Qt(t,Jn(e,n))}function mr(t,e){return typeof t=="function"?t(e):t}function gr(t){return t.split("-")[0]}function Ss(t){return t.split("-")[1]}function nh(t){return t==="x"?"y":"x"}function rh(t){return t==="y"?"height":"width"}function Es(t){return["top","bottom"].includes(gr(t))?"y":"x"}function ih(t){return nh(Es(t))}function BD(t,e,n){n===void 0&&(n=!1);const r=Ss(t),i=ih(t),s=rh(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=mc(o)),[o,mc(o)]}function jD(t){const e=mc(t);return[sh(t),e,sh(e)]}function sh(t){return t.replace(/start|end/g,e=>$D[e])}function HD(t,e,n){const r=["left","right"],i=["right","left"],s=["top","bottom"],o=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:r:e?r:i;case"left":case"right":return e?s:o;default:return[]}}function zD(t,e,n,r){const i=Ss(t);let s=HD(gr(t),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(sh)))),s}function mc(t){return t.replace(/left|right|bottom|top/g,e=>FD[e])}function VD(t){return{top:0,right:0,bottom:0,left:0,...t}}function Bv(t){return typeof t!="number"?VD(t):{top:t,right:t,bottom:t,left:t}}function gc(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function jv(t,e,n){let{reference:r,floating:i}=t;const s=Es(e),o=ih(e),l=rh(o),a=gr(e),c=s==="y",u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[l]/2-i[l]/2;let h;switch(a){case"top":h={x:u,y:r.y-i.height};break;case"bottom":h={x:u,y:r.y+r.height};break;case"right":h={x:r.x+r.width,y:d};break;case"left":h={x:r.x-i.width,y:d};break;default:h={x:r.x,y:r.y}}switch(Ss(e)){case"start":h[o]-=f*(n&&c?-1:1);break;case"end":h[o]+=f*(n&&c?-1:1);break}return h}const UD=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,l=s.filter(Boolean),a=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:i}),{x:u,y:d}=jv(c,r,a),f=r,h={},p=0;for(let g=0;g<l.length;g++){const{name:v,fn:w}=l[g],{x:S,y:x,data:y,reset:C}=await w({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:h,rects:c,platform:o,elements:{reference:t,floating:e}});u=S??u,d=x??d,h={...h,[v]:{...h[v],...y}},C&&p<=50&&(p++,typeof C=="object"&&(C.placement&&(f=C.placement),C.rects&&(c=C.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:i}):C.rects),{x:u,y:d}=jv(c,f,a)),g=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:h}};async function Yo(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:o,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:h=0}=mr(e,t),p=Bv(h),v=l[f?d==="floating"?"reference":"floating":d],w=gc(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(v)))==null||n?v:v.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:a})),S=d==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),y=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},C=gc(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:S,offsetParent:x,strategy:a}):S);return{top:(w.top-C.top+p.top)/y.y,bottom:(C.bottom-w.bottom+p.bottom)/y.y,left:(w.left-C.left+p.left)/y.x,right:(C.right-w.right+p.right)/y.x}}const WD=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:s,platform:o,elements:l,middlewareData:a}=e,{element:c,padding:u=0}=mr(t,e)||{};if(c==null)return{};const d=Bv(u),f={x:n,y:r},h=ih(i),p=rh(h),g=await o.getDimensions(c),v=h==="y",w=v?"top":"left",S=v?"bottom":"right",x=v?"clientHeight":"clientWidth",y=s.reference[p]+s.reference[h]-f[h]-s.floating[p],C=f[h]-s.reference[h],E=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let T=E?E[x]:0;(!T||!await(o.isElement==null?void 0:o.isElement(E)))&&(T=l.floating[x]||s.floating[p]);const D=y/2-C/2,N=T/2-g[p]/2-1,A=Jn(d[w],N),R=Jn(d[S],N),P=A,B=T-g[p]-R,z=T/2-g[p]/2+D,U=th(P,z,B),J=!a.arrow&&Ss(i)!=null&&z!==U&&s.reference[p]/2-(z<P?A:R)-g[p]/2<0,G=J?z<P?z-P:z-B:0;return{[h]:f[h]+G,data:{[h]:U,centerOffset:z-U-G,...J&&{alignmentOffset:G}},reset:J}}}),qD=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...v}=mr(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const w=gr(i),S=gr(l)===l,x=await(a.isRTL==null?void 0:a.isRTL(c.floating)),y=f||(S||!g?[mc(l)]:jD(l));!f&&p!=="none"&&y.push(...zD(l,g,p,x));const C=[l,...y],E=await Yo(e,v),T=[];let D=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&T.push(E[w]),d){const P=BD(i,o,x);T.push(E[P[0]],E[P[1]])}if(D=[...D,{placement:i,overflows:T}],!T.every(P=>P<=0)){var N,A;const P=(((N=s.flip)==null?void 0:N.index)||0)+1,B=C[P];if(B)return{data:{index:P,overflows:D},reset:{placement:B}};let z=(A=D.filter(U=>U.overflows[0]<=0).sort((U,J)=>U.overflows[1]-J.overflows[1])[0])==null?void 0:A.placement;if(!z)switch(h){case"bestFit":{var R;const U=(R=D.map(J=>[J.placement,J.overflows.filter(G=>G>0).reduce((G,ie)=>G+ie,0)]).sort((J,G)=>J[1]-G[1])[0])==null?void 0:R[0];U&&(z=U);break}case"initialPlacement":z=l;break}if(i!==z)return{reset:{placement:z}}}return{}}}};function Hv(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function zv(t){return PD.some(e=>t[e]>=0)}const KD=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...i}=mr(t,e);switch(r){case"referenceHidden":{const s=await Yo(e,{...i,elementContext:"reference"}),o=Hv(s,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:zv(o)}}}case"escaped":{const s=await Yo(e,{...i,altBoundary:!0}),o=Hv(s,n.floating);return{data:{escapedOffsets:o,escaped:zv(o)}}}default:return{}}}}};async function JD(t,e){const{placement:n,platform:r,elements:i}=t,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=gr(n),l=Ss(n),a=Es(n)==="y",c=["left","top"].includes(o)?-1:1,u=s&&a?-1:1,d=mr(e,t);let{mainAxis:f,crossAxis:h,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return l&&typeof p=="number"&&(h=l==="end"?p*-1:p),a?{x:h*u,y:f*c}:{x:f*c,y:h*u}}const GD=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:s,placement:o,middlewareData:l}=e,a=await JD(e,t);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+a.x,y:s+a.y,data:{...a,placement:o}}}}},YD=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i}=e,{mainAxis:s=!0,crossAxis:o=!1,limiter:l={fn:v=>{let{x:w,y:S}=v;return{x:w,y:S}}},...a}=mr(t,e),c={x:n,y:r},u=await Yo(e,a),d=Es(gr(i)),f=nh(d);let h=c[f],p=c[d];if(s){const v=f==="y"?"top":"left",w=f==="y"?"bottom":"right",S=h+u[v],x=h-u[w];h=th(S,h,x)}if(o){const v=d==="y"?"top":"left",w=d==="y"?"bottom":"right",S=p+u[v],x=p-u[w];p=th(S,p,x)}const g=l.fn({...e,[f]:h,[d]:p});return{...g,data:{x:g.x-n,y:g.y-r}}}}},XD=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=e,{offset:l=0,mainAxis:a=!0,crossAxis:c=!0}=mr(t,e),u={x:n,y:r},d=Es(i),f=nh(d);let h=u[f],p=u[d];const g=mr(l,e),v=typeof g=="number"?{mainAxis:g,crossAxis:0}:{mainAxis:0,crossAxis:0,...g};if(a){const x=f==="y"?"height":"width",y=s.reference[f]-s.floating[x]+v.mainAxis,C=s.reference[f]+s.reference[x]-v.mainAxis;h<y?h=y:h>C&&(h=C)}if(c){var w,S;const x=f==="y"?"width":"height",y=["top","left"].includes(gr(i)),C=s.reference[d]-s.floating[x]+(y&&((w=o.offset)==null?void 0:w[d])||0)+(y?0:v.crossAxis),E=s.reference[d]+s.reference[x]+(y?0:((S=o.offset)==null?void 0:S[d])||0)-(y?v.crossAxis:0);p<C?p=C:p>E&&(p=E)}return{[f]:h,[d]:p}}}},ZD=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:r,platform:i,elements:s}=e,{apply:o=()=>{},...l}=mr(t,e),a=await Yo(e,l),c=gr(n),u=Ss(n),d=Es(n)==="y",{width:f,height:h}=r.floating;let p,g;c==="top"||c==="bottom"?(p=c,g=u===(await(i.isRTL==null?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(g=c,p=u==="end"?"top":"bottom");const v=h-a.top-a.bottom,w=f-a.left-a.right,S=Jn(h-a[p],v),x=Jn(f-a[g],w),y=!e.middlewareData.shift;let C=S,E=x;if(d?E=u||y?Jn(x,w):w:C=u||y?Jn(S,v):v,y&&!u){const D=Qt(a.left,0),N=Qt(a.right,0),A=Qt(a.top,0),R=Qt(a.bottom,0);d?E=f-2*(D!==0||N!==0?D+N:Qt(a.left,a.right)):C=h-2*(A!==0||R!==0?A+R:Qt(a.top,a.bottom))}await o({...e,availableWidth:E,availableHeight:C});const T=await i.getDimensions(s.floating);return f!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function Ts(t){return Vv(t)?(t.nodeName||"").toLowerCase():"#document"}function en(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function yr(t){var e;return(e=(Vv(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Vv(t){return t instanceof Node||t instanceof en(t).Node}function Gn(t){return t instanceof Element||t instanceof en(t).Element}function Yn(t){return t instanceof HTMLElement||t instanceof en(t).HTMLElement}function Uv(t){return typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof en(t).ShadowRoot}function Xo(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=Tn(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!["inline","contents"].includes(i)}function QD(t){return["table","td","th"].includes(Ts(t))}function oh(t){const e=lh(),n=Tn(t);return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function eR(t){let e=Jr(t);for(;Yn(e)&&!As(e);){if(oh(e))return e;e=Jr(e)}return null}function lh(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function As(t){return["html","body","#document"].includes(Ts(t))}function Tn(t){return en(t).getComputedStyle(t)}function yc(t){return Gn(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function Jr(t){if(Ts(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Uv(t)&&t.host||yr(t);return Uv(e)?e.host:e}function Wv(t){const e=Jr(t);return As(e)?t.ownerDocument?t.ownerDocument.body:t.body:Yn(e)&&Xo(e)?e:Wv(e)}function Zo(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=Wv(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),o=en(i);return s?e.concat(o,o.visualViewport||[],Xo(i)?i:[],o.frameElement&&n?Zo(o.frameElement):[]):e.concat(i,Zo(i,[],n))}function qv(t){const e=Tn(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=Yn(t),s=i?t.offsetWidth:n,o=i?t.offsetHeight:r,l=hc(n)!==s||hc(r)!==o;return l&&(n=s,r=o),{width:n,height:r,$:l}}function ah(t){return Gn(t)?t:t.contextElement}function Ms(t){const e=ah(t);if(!Yn(e))return Kr(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=qv(e);let o=(s?hc(n.width):n.width)/r,l=(s?hc(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const tR=Kr(0);function Kv(t){const e=en(t);return!lh()||!e.visualViewport?tR:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function nR(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==en(t)?!1:e}function Oi(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=ah(t);let o=Kr(1);e&&(r?Gn(r)&&(o=Ms(r)):o=Ms(t));const l=nR(s,n,r)?Kv(s):Kr(0);let a=(i.left+l.x)/o.x,c=(i.top+l.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(s){const f=en(s),h=r&&Gn(r)?en(r):r;let p=f,g=p.frameElement;for(;g&&r&&h!==p;){const v=Ms(g),w=g.getBoundingClientRect(),S=Tn(g),x=w.left+(g.clientLeft+parseFloat(S.paddingLeft))*v.x,y=w.top+(g.clientTop+parseFloat(S.paddingTop))*v.y;a*=v.x,c*=v.y,u*=v.x,d*=v.y,a+=x,c+=y,p=en(g),g=p.frameElement}}return gc({width:u,height:d,x:a,y:c})}const rR=[":popover-open",":modal"];function ch(t){return rR.some(e=>{try{return t.matches(e)}catch{return!1}})}function iR(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",o=yr(r),l=e?ch(e.floating):!1;if(r===o||l&&s)return n;let a={scrollLeft:0,scrollTop:0},c=Kr(1);const u=Kr(0),d=Yn(r);if((d||!d&&!s)&&((Ts(r)!=="body"||Xo(o))&&(a=yc(r)),Yn(r))){const f=Oi(r);c=Ms(r),u.x=f.x+r.clientLeft,u.y=f.y+r.clientTop}return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+u.x,y:n.y*c.y-a.scrollTop*c.y+u.y}}function sR(t){return Array.from(t.getClientRects())}function Jv(t){return Oi(yr(t)).left+yc(t).scrollLeft}function oR(t){const e=yr(t),n=yc(t),r=t.ownerDocument.body,i=Qt(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=Qt(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+Jv(t);const l=-n.scrollTop;return Tn(r).direction==="rtl"&&(o+=Qt(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:l}}function lR(t,e){const n=en(t),r=yr(t),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,l=0,a=0;if(i){s=i.width,o=i.height;const c=lh();(!c||c&&e==="fixed")&&(l=i.offsetLeft,a=i.offsetTop)}return{width:s,height:o,x:l,y:a}}function aR(t,e){const n=Oi(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=Yn(t)?Ms(t):Kr(1),o=t.clientWidth*s.x,l=t.clientHeight*s.y,a=i*s.x,c=r*s.y;return{width:o,height:l,x:a,y:c}}function Gv(t,e,n){let r;if(e==="viewport")r=lR(t,n);else if(e==="document")r=oR(yr(t));else if(Gn(e))r=aR(e,n);else{const i=Kv(t);r={...e,x:e.x-i.x,y:e.y-i.y}}return gc(r)}function Yv(t,e){const n=Jr(t);return n===e||!Gn(n)||As(n)?!1:Tn(n).position==="fixed"||Yv(n,e)}function cR(t,e){const n=e.get(t);if(n)return n;let r=Zo(t,[],!1).filter(l=>Gn(l)&&Ts(l)!=="body"),i=null;const s=Tn(t).position==="fixed";let o=s?Jr(t):t;for(;Gn(o)&&!As(o);){const l=Tn(o),a=oh(o);!a&&l.position==="fixed"&&(i=null),(s?!a&&!i:!a&&l.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||Xo(o)&&!a&&Yv(t,o))?r=r.filter(u=>u!==o):i=l,o=Jr(o)}return e.set(t,r),r}function uR(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const o=[...n==="clippingAncestors"?ch(e)?[]:cR(e,this._c):[].concat(n),r],l=o[0],a=o.reduce((c,u)=>{const d=Gv(e,u,i);return c.top=Qt(d.top,c.top),c.right=Jn(d.right,c.right),c.bottom=Jn(d.bottom,c.bottom),c.left=Qt(d.left,c.left),c},Gv(e,l,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function dR(t){const{width:e,height:n}=qv(t);return{width:e,height:n}}function fR(t,e,n){const r=Yn(e),i=yr(e),s=n==="fixed",o=Oi(t,!0,s,e);let l={scrollLeft:0,scrollTop:0};const a=Kr(0);if(r||!r&&!s)if((Ts(e)!=="body"||Xo(i))&&(l=yc(e)),r){const d=Oi(e,!0,s,e);a.x=d.x+e.clientLeft,a.y=d.y+e.clientTop}else i&&(a.x=Jv(i));const c=o.left+l.scrollLeft-a.x,u=o.top+l.scrollTop-a.y;return{x:c,y:u,width:o.width,height:o.height}}function uh(t){return Tn(t).position==="static"}function Xv(t,e){return!Yn(t)||Tn(t).position==="fixed"?null:e?e(t):t.offsetParent}function Zv(t,e){const n=en(t);if(ch(t))return n;if(!Yn(t)){let i=Jr(t);for(;i&&!As(i);){if(Gn(i)&&!uh(i))return i;i=Jr(i)}return n}let r=Xv(t,e);for(;r&&QD(r)&&uh(r);)r=Xv(r,e);return r&&As(r)&&uh(r)&&!oh(r)?n:r||eR(t)||n}const hR=async function(t){const e=this.getOffsetParent||Zv,n=this.getDimensions,r=await n(t.floating);return{reference:fR(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function pR(t){return Tn(t).direction==="rtl"}const mR={convertOffsetParentRelativeRectToViewportRelativeRect:iR,getDocumentElement:yr,getClippingRect:uR,getOffsetParent:Zv,getElementRects:hR,getClientRects:sR,getDimensions:dR,getScale:Ms,isElement:Gn,isRTL:pR};function gR(t,e){let n=null,r;const i=yr(t);function s(){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),s();const{left:c,top:u,width:d,height:f}=t.getBoundingClientRect();if(l||e(),!d||!f)return;const h=pc(u),p=pc(i.clientWidth-(c+d)),g=pc(i.clientHeight-(u+f)),v=pc(c),S={rootMargin:-h+"px "+-p+"px "+-g+"px "+-v+"px",threshold:Qt(0,Jn(1,a))||1};let x=!0;function y(C){const E=C[0].intersectionRatio;if(E!==a){if(!x)return o();E?o(!1,E):r=setTimeout(()=>{o(!1,1e-7)},1e3)}x=!1}try{n=new IntersectionObserver(y,{...S,root:i.ownerDocument})}catch{n=new IntersectionObserver(y,S)}n.observe(t)}return o(!0),s}function yR(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,c=ah(t),u=i||s?[...c?Zo(c):[],...Zo(e)]:[];u.forEach(w=>{i&&w.addEventListener("scroll",n,{passive:!0}),s&&w.addEventListener("resize",n)});const d=c&&l?gR(c,n):null;let f=-1,h=null;o&&(h=new ResizeObserver(w=>{let[S]=w;S&&S.target===c&&h&&(h.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(e)})),n()}),c&&!a&&h.observe(c),h.observe(e));let p,g=a?Oi(t):null;a&&v();function v(){const w=Oi(t);g&&(w.x!==g.x||w.y!==g.y||w.width!==g.width||w.height!==g.height)&&n(),g=w,p=requestAnimationFrame(v)}return n(),()=>{var w;u.forEach(S=>{i&&S.removeEventListener("scroll",n),s&&S.removeEventListener("resize",n)}),d==null||d(),(w=h)==null||w.disconnect(),h=null,a&&cancelAnimationFrame(p)}}const bR=GD,vR=YD,wR=qD,xR=ZD,kR=KD,Qv=WD,CR=XD,SR=(t,e,n)=>{const r=new Map,i={platform:mR,...n},s={...i.platform,_c:r};return UD(t,e,{...i,platform:s})};var bc=typeof document<"u"?O.useLayoutEffect:O.useEffect;function vc(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,i;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(!vc(t[r],e[r]))return!1;return!0}if(i=Object.keys(t),n=i.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&t.$$typeof)&&!vc(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function ew(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function tw(t,e){const n=ew(t);return Math.round(e*n)/n}function nw(t){const e=le.useRef(t);return bc(()=>{e.current=t}),e}function ER(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:l=!0,whileElementsMounted:a,open:c}=t,[u,d]=le.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[f,h]=le.useState(r);vc(f,r)||h(r);const[p,g]=le.useState(null),[v,w]=le.useState(null),S=le.useCallback(G=>{G!==E.current&&(E.current=G,g(G))},[]),x=le.useCallback(G=>{G!==T.current&&(T.current=G,w(G))},[]),y=s||p,C=o||v,E=le.useRef(null),T=le.useRef(null),D=le.useRef(u),N=a!=null,A=nw(a),R=nw(i),P=le.useCallback(()=>{if(!E.current||!T.current)return;const G={placement:e,strategy:n,middleware:f};R.current&&(G.platform=R.current),SR(E.current,T.current,G).then(ie=>{const Z={...ie,isPositioned:!0};B.current&&!vc(D.current,Z)&&(D.current=Z,m1.flushSync(()=>{d(Z)}))})},[f,e,n,R]);bc(()=>{c===!1&&D.current.isPositioned&&(D.current.isPositioned=!1,d(G=>({...G,isPositioned:!1})))},[c]);const B=le.useRef(!1);bc(()=>(B.current=!0,()=>{B.current=!1}),[]),bc(()=>{if(y&&(E.current=y),C&&(T.current=C),y&&C){if(A.current)return A.current(y,C,P);P()}},[y,C,P,A,N]);const z=le.useMemo(()=>({reference:E,floating:T,setReference:S,setFloating:x}),[S,x]),U=le.useMemo(()=>({reference:y,floating:C}),[y,C]),J=le.useMemo(()=>{const G={position:n,left:0,top:0};if(!U.floating)return G;const ie=tw(U.floating,u.x),Z=tw(U.floating,u.y);return l?{...G,transform:"translate("+ie+"px, "+Z+"px)",...ew(U.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:ie,top:Z}},[n,l,U.floating,u.x,u.y]);return le.useMemo(()=>({...u,update:P,refs:z,elements:U,floatingStyles:J}),[u,P,z,U,J])}const TR=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:i}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?Qv({element:r.current,padding:i}).fn(n):{}:r?Qv({element:r,padding:i}).fn(n):{}}}},AR=(t,e)=>({...bR(t),options:[t,e]}),MR=(t,e)=>({...vR(t),options:[t,e]}),OR=(t,e)=>({...CR(t),options:[t,e]}),_R=(t,e)=>({...wR(t),options:[t,e]}),NR=(t,e)=>({...xR(t),options:[t,e]}),DR=(t,e)=>({...kR(t),options:[t,e]}),RR=(t,e)=>({...TR(t),options:[t,e]}),LR=O.forwardRef((t,e)=>{const{children:n,width:r=10,height:i=5,...s}=t;return O.createElement(Mi.svg,dt({},s,{ref:e,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none"}),t.asChild?n:O.createElement("polygon",{points:"0,0 30,0 15,10"}))});function IR(t){const[e,n]=O.useState(void 0);return Cs(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,l;if("borderBoxSize"in s){const a=s.borderBoxSize,c=Array.isArray(a)?a[0]:a;o=c.inlineSize,l=c.blockSize}else o=t.offsetWidth,l=t.offsetHeight;n({width:o,height:l})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}const rw="Popper",[iw,sw]=Ov(rw),[PR,ow]=iw(rw),FR=t=>{const{__scopePopper:e,children:n}=t,[r,i]=O.useState(null);return O.createElement(PR,{scope:e,anchor:r,onAnchorChange:i},n)},$R="PopperAnchor",BR=O.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...i}=t,s=ow($R,n),o=O.useRef(null),l=Ai(e,o);return O.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||o.current)}),r?null:O.createElement(Mi.div,dt({},i,{ref:l}))}),lw="PopperContent",[jR,HR]=iw(lw),zR=O.forwardRef((t,e)=>{var n,r,i,s,o,l,a,c;const{__scopePopper:u,side:d="bottom",sideOffset:f=0,align:h="center",alignOffset:p=0,arrowPadding:g=0,avoidCollisions:v=!0,collisionBoundary:w=[],collisionPadding:S=0,sticky:x="partial",hideWhenDetached:y=!1,updatePositionStrategy:C="optimized",onPlaced:E,...T}=t,D=ow(lw,u),[N,A]=O.useState(null),R=Ai(e,$=>A($)),[P,B]=O.useState(null),z=IR(P),U=(n=z==null?void 0:z.width)!==null&&n!==void 0?n:0,J=(r=z==null?void 0:z.height)!==null&&r!==void 0?r:0,G=d+(h!=="center"?"-"+h:""),ie=typeof S=="number"?S:{top:0,right:0,bottom:0,left:0,...S},Z=Array.isArray(w)?w:[w],ke=Z.length>0,Le={padding:ie,boundary:Z.filter(WR),altBoundary:ke},{refs:$e,floatingStyles:Ee,placement:ve,isPositioned:De,middlewareData:Ie}=ER({strategy:"fixed",placement:G,whileElementsMounted:(...$)=>yR(...$,{animationFrame:C==="always"}),elements:{reference:D.anchor},middleware:[AR({mainAxis:f+J,alignmentAxis:p}),v&&MR({mainAxis:!0,crossAxis:!1,limiter:x==="partial"?OR():void 0,...Le}),v&&_R({...Le}),NR({...Le,apply:({elements:$,rects:j,availableWidth:q,availableHeight:te})=>{const{width:M,height:m}=j.reference,b=$.floating.style;b.setProperty("--radix-popper-available-width",`${q}px`),b.setProperty("--radix-popper-available-height",`${te}px`),b.setProperty("--radix-popper-anchor-width",`${M}px`),b.setProperty("--radix-popper-anchor-height",`${m}px`)}}),P&&RR({element:P,padding:g}),qR({arrowWidth:U,arrowHeight:J}),y&&DR({strategy:"referenceHidden",...Le})]}),[tt,nt]=cw(ve),Ge=Wr(E);Cs(()=>{De&&(Ge==null||Ge())},[De,Ge]);const Ye=(i=Ie.arrow)===null||i===void 0?void 0:i.x,Ot=(s=Ie.arrow)===null||s===void 0?void 0:s.y,xt=((o=Ie.arrow)===null||o===void 0?void 0:o.centerOffset)!==0,[it,at]=O.useState();return Cs(()=>{N&&at(window.getComputedStyle(N).zIndex)},[N]),O.createElement("div",{ref:$e.setFloating,"data-radix-popper-content-wrapper":"",style:{...Ee,transform:De?Ee.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:it,"--radix-popper-transform-origin":[(l=Ie.transformOrigin)===null||l===void 0?void 0:l.x,(a=Ie.transformOrigin)===null||a===void 0?void 0:a.y].join(" ")},dir:t.dir},O.createElement(jR,{scope:u,placedSide:tt,onArrowChange:B,arrowX:Ye,arrowY:Ot,shouldHideArrow:xt},O.createElement(Mi.div,dt({"data-side":tt,"data-align":nt},T,{ref:R,style:{...T.style,animation:De?void 0:"none",opacity:(c=Ie.hide)!==null&&c!==void 0&&c.referenceHidden?0:void 0}}))))}),aw="PopperArrow",VR={top:"bottom",right:"left",bottom:"top",left:"right"},UR=O.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,s=HR(aw,r),o=VR[s.placedSide];return O.createElement("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0}},O.createElement(LR,dt({},i,{ref:n,style:{...i.style,display:"block"}})))});function WR(t){return t!==null}const qR=t=>({name:"transformOrigin",options:t,fn(e){var n,r,i,s,o;const{placement:l,rects:a,middlewareData:c}=e,d=((n=c.arrow)===null||n===void 0?void 0:n.centerOffset)!==0,f=d?0:t.arrowWidth,h=d?0:t.arrowHeight,[p,g]=cw(l),v={start:"0%",center:"50%",end:"100%"}[g],w=((r=(i=c.arrow)===null||i===void 0?void 0:i.x)!==null&&r!==void 0?r:0)+f/2,S=((s=(o=c.arrow)===null||o===void 0?void 0:o.y)!==null&&s!==void 0?s:0)+h/2;let x="",y="";return p==="bottom"?(x=d?v:`${w}px`,y=`${-h}px`):p==="top"?(x=d?v:`${w}px`,y=`${a.floating.height+h}px`):p==="right"?(x=`${-h}px`,y=d?v:`${S}px`):p==="left"&&(x=`${a.floating.width+h}px`,y=d?v:`${S}px`),{data:{x,y}}}});function cw(t){const[e,n="center"]=t.split("-");return[e,n]}const KR=FR,JR=BR,GR=zR;function YR(t,e){return O.useReducer((n,r)=>{const i=e[n][r];return i??n},t)}const uw=t=>{const{present:e,children:n}=t,r=XR(e),i=typeof n=="function"?n({present:r.isPresent}):O.Children.only(n),s=Ai(r.ref,i.ref);return typeof n=="function"||r.isPresent?O.cloneElement(i,{ref:s}):null};uw.displayName="Presence";function XR(t){const[e,n]=O.useState(),r=O.useRef({}),i=O.useRef(t),s=O.useRef("none"),o=t?"mounted":"unmounted",[l,a]=YR(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return O.useEffect(()=>{const c=wc(r.current);s.current=l==="mounted"?c:"none"},[l]),Cs(()=>{const c=r.current,u=i.current;if(u!==t){const f=s.current,h=wc(c);t?a("MOUNT"):h==="none"||(c==null?void 0:c.display)==="none"?a("UNMOUNT"):a(u&&f!==h?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,a]),Cs(()=>{if(e){const c=d=>{const h=wc(r.current).includes(d.animationName);d.target===e&&h&&nn.flushSync(()=>a("ANIMATION_END"))},u=d=>{d.target===e&&(s.current=wc(r.current))};return e.addEventListener("animationstart",u),e.addEventListener("animationcancel",c),e.addEventListener("animationend",c),()=>{e.removeEventListener("animationstart",u),e.removeEventListener("animationcancel",c),e.removeEventListener("animationend",c)}}else a("ANIMATION_END")},[e,a]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:O.useCallback(c=>{c&&(r.current=getComputedStyle(c)),n(c)},[])}}function wc(t){return(t==null?void 0:t.animationName)||"none"}function ZR({prop:t,defaultProp:e,onChange:n=()=>{}}){const[r,i]=QR({defaultProp:e,onChange:n}),s=t!==void 0,o=s?t:r,l=Wr(n),a=O.useCallback(c=>{if(s){const d=typeof c=="function"?c(t):c;d!==t&&l(d)}else i(c)},[s,t,i,l]);return[o,a]}function QR({defaultProp:t,onChange:e}){const n=O.useState(t),[r]=n,i=O.useRef(r),s=Wr(e);return O.useEffect(()=>{i.current!==r&&(s(r),i.current=r)},[r,i,s]),n}var eL=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Os=new WeakMap,xc=new WeakMap,kc={},dh=0,dw=function(t){return t&&(t.host||dw(t.parentNode))},tL=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=dw(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},nL=function(t,e,n,r){var i=tL(e,Array.isArray(t)?t:[t]);kc[n]||(kc[n]=new WeakMap);var s=kc[n],o=[],l=new Set,a=new Set(i),c=function(d){!d||l.has(d)||(l.add(d),c(d.parentNode))};i.forEach(c);var u=function(d){!d||a.has(d)||Array.prototype.forEach.call(d.children,function(f){if(l.has(f))u(f);else try{var h=f.getAttribute(r),p=h!==null&&h!=="false",g=(Os.get(f)||0)+1,v=(s.get(f)||0)+1;Os.set(f,g),s.set(f,v),o.push(f),g===1&&p&&xc.set(f,!0),v===1&&f.setAttribute(n,"true"),p||f.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",f,w)}})};return u(e),l.clear(),dh++,function(){o.forEach(function(d){var f=Os.get(d)-1,h=s.get(d)-1;Os.set(d,f),s.set(d,h),f||(xc.has(d)||d.removeAttribute(r),xc.delete(d)),h||d.removeAttribute(n)}),dh--,dh||(Os=new WeakMap,Os=new WeakMap,xc=new WeakMap,kc={})}},rL=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),i=eL(t);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live]"))),nL(r,i,n,"aria-hidden")):function(){return null}},Xn=function(){return Xn=Object.assign||function(e){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},Xn.apply(this,arguments)};function fw(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n}function iL(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return t.concat(s||Array.prototype.slice.call(e))}typeof SuppressedError=="function"&&SuppressedError;var Cc="right-scroll-bar-position",Sc="width-before-scroll-bar",sL="with-scroll-bars-hidden",oL="--removed-body-scroll-bar-size";function fh(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function lL(t,e){var n=O.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=e,n.facade}var aL=typeof window<"u"?le.useLayoutEffect:le.useEffect,hw=new WeakMap;function cL(t,e){var n=lL(null,function(r){return t.forEach(function(i){return fh(i,r)})});return aL(function(){var r=hw.get(n);if(r){var i=new Set(r),s=new Set(t),o=n.current;i.forEach(function(l){s.has(l)||fh(l,null)}),s.forEach(function(l){i.has(l)||fh(l,o)})}hw.set(n,t)},[t]),n}function uL(t){return t}function dL(t,e){e===void 0&&(e=uL);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(s){var o=e(s,r);return n.push(o),function(){n=n.filter(function(l){return l!==o})}},assignSyncMedium:function(s){for(r=!0;n.length;){var o=n;n=[],o.forEach(s)}n={push:function(l){return s(l)},filter:function(){return n}}},assignMedium:function(s){r=!0;var o=[];if(n.length){var l=n;n=[],l.forEach(s),o=n}var a=function(){var u=o;o=[],u.forEach(s)},c=function(){return Promise.resolve().then(a)};c(),n={push:function(u){o.push(u),c()},filter:function(u){return o=o.filter(u),n}}}};return i}function fL(t){t===void 0&&(t={});var e=dL(null);return e.options=Xn({async:!0,ssr:!1},t),e}var pw=function(t){var e=t.sideCar,n=fw(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return le.createElement(r,Xn({},n))};pw.isSideCarExport=!0;function hL(t,e){return t.useMedium(e),pw}var mw=fL(),hh=function(){},Ec=le.forwardRef(function(t,e){var n=le.useRef(null),r=le.useState({onScrollCapture:hh,onWheelCapture:hh,onTouchMoveCapture:hh}),i=r[0],s=r[1],o=t.forwardProps,l=t.children,a=t.className,c=t.removeScrollBar,u=t.enabled,d=t.shards,f=t.sideCar,h=t.noIsolation,p=t.inert,g=t.allowPinchZoom,v=t.as,w=v===void 0?"div":v,S=fw(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as"]),x=f,y=cL([n,e]),C=Xn(Xn({},S),i);return le.createElement(le.Fragment,null,u&&le.createElement(x,{sideCar:mw,removeScrollBar:c,shards:d,noIsolation:h,inert:p,setCallbacks:s,allowPinchZoom:!!g,lockRef:n}),o?le.cloneElement(le.Children.only(l),Xn(Xn({},C),{ref:y})):le.createElement(w,Xn({},C,{className:a,ref:y}),l))});Ec.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},Ec.classNames={fullWidth:Sc,zeroRight:Cc};var pL=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function mL(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=pL();return e&&t.setAttribute("nonce",e),t}function gL(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function yL(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var bL=function(){var t=0,e=null;return{add:function(n){t==0&&(e=mL())&&(gL(e,n),yL(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},vL=function(){var t=bL();return function(e,n){le.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},gw=function(){var t=vL(),e=function(n){var r=n.styles,i=n.dynamic;return t(r,i),null};return e},wL={left:0,top:0,right:0,gap:0},ph=function(t){return parseInt(t||"",10)||0},xL=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],i=e[t==="padding"?"paddingRight":"marginRight"];return[ph(n),ph(r),ph(i)]},kL=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return wL;var e=xL(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},CL=gw(),_s="data-scroll-locked",SL=function(t,e,n,r){var i=t.left,s=t.top,o=t.right,l=t.gap;return n===void 0&&(n="margin"),`
|
384
|
+
.`.concat(sL,` {
|
400
385
|
overflow: hidden `).concat(r,`;
|
401
386
|
padding-right: `).concat(l,"px ").concat(r,`;
|
402
387
|
}
|
@@ -413,27 +398,27 @@ Use Chrome, Firefox or Internet Explorer 11`)}}).call(this)}).call(this,s("_proc
|
|
413
398
|
`),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
|
414
399
|
}
|
415
400
|
|
416
|
-
.`).concat(
|
401
|
+
.`).concat(Cc,` {
|
417
402
|
right: `).concat(l,"px ").concat(r,`;
|
418
403
|
}
|
419
404
|
|
420
|
-
.`).concat(
|
405
|
+
.`).concat(Sc,` {
|
421
406
|
margin-right: `).concat(l,"px ").concat(r,`;
|
422
407
|
}
|
423
408
|
|
424
|
-
.`).concat(
|
409
|
+
.`).concat(Cc," .").concat(Cc,` {
|
425
410
|
right: 0 `).concat(r,`;
|
426
411
|
}
|
427
412
|
|
428
|
-
.`).concat(
|
413
|
+
.`).concat(Sc," .").concat(Sc,` {
|
429
414
|
margin-right: 0 `).concat(r,`;
|
430
415
|
}
|
431
416
|
|
432
417
|
body[`).concat(_s,`] {
|
433
|
-
`).concat(
|
418
|
+
`).concat(oL,": ").concat(l,`px;
|
434
419
|
}
|
435
|
-
`)},yw=function(){var t=parseInt(document.body.getAttribute(_s)||"0",10);return isFinite(t)?t:0},
|
420
|
+
`)},yw=function(){var t=parseInt(document.body.getAttribute(_s)||"0",10);return isFinite(t)?t:0},EL=function(){le.useEffect(function(){return document.body.setAttribute(_s,(yw()+1).toString()),function(){var t=yw()-1;t<=0?document.body.removeAttribute(_s):document.body.setAttribute(_s,t.toString())}},[])},TL=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,i=r===void 0?"margin":r;EL();var s=le.useMemo(function(){return kL(i)},[i]);return le.createElement(CL,{styles:SL(s,!e,i,n?"":"!important")})},mh=!1;if(typeof window<"u")try{var Tc=Object.defineProperty({},"passive",{get:function(){return mh=!0,!0}});window.addEventListener("test",Tc,Tc),window.removeEventListener("test",Tc,Tc)}catch{mh=!1}var Ns=mh?{passive:!1}:!1,AL=function(t){return t.tagName==="TEXTAREA"},bw=function(t,e){var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!AL(t)&&n[e]==="visible")},ML=function(t){return bw(t,"overflowY")},OL=function(t){return bw(t,"overflowX")},vw=function(t,e){var n=e;do{typeof ShadowRoot<"u"&&n instanceof ShadowRoot&&(n=n.host);var r=ww(t,n);if(r){var i=xw(t,n),s=i[1],o=i[2];if(s>o)return!0}n=n.parentNode}while(n&&n!==document.body);return!1},_L=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},NL=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},ww=function(t,e){return t==="v"?ML(e):OL(e)},xw=function(t,e){return t==="v"?_L(e):NL(e)},DL=function(t,e){return t==="h"&&e==="rtl"?-1:1},RL=function(t,e,n,r,i){var s=DL(t,window.getComputedStyle(e).direction),o=s*r,l=n.target,a=e.contains(l),c=!1,u=o>0,d=0,f=0;do{var h=xw(t,l),p=h[0],g=h[1],v=h[2],w=g-v-s*p;(p||w)&&ww(t,l)&&(d+=w,f+=p),l=l.parentNode}while(!a&&l!==document.body||a&&(e.contains(l)||e===l));return(u&&(d===0||!i)||!u&&(f===0||!i))&&(c=!0),c},Ac=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},kw=function(t){return[t.deltaX,t.deltaY]},Cw=function(t){return t&&"current"in t?t.current:t},LL=function(t,e){return t[0]===e[0]&&t[1]===e[1]},IL=function(t){return`
|
436
421
|
.block-interactivity-`.concat(t,` {pointer-events: none;}
|
437
422
|
.allow-interactivity-`).concat(t,` {pointer-events: all;}
|
438
|
-
`)},BL=0,Ds=[];function jL(t){var e=le.useRef([]),n=le.useRef([0,0]),r=le.useRef(),i=le.useState(BL++)[0],s=le.useState(function(){return gw()})[0],o=le.useRef(t);le.useEffect(function(){o.current=t},[t]),le.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(i));var g=lL([t.lockRef.current],(t.shards||[]).map(Cw),!0).filter(Boolean);return g.forEach(function(v){return v.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),g.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(i))})}}},[t.inert,t.lockRef.current,t.shards]);var l=le.useCallback(function(g,v){if("touches"in g&&g.touches.length===2)return!o.current.allowPinchZoom;var w=Mc(g),S=n.current,x="deltaX"in g?g.deltaX:S[0]-w[0],y="deltaY"in g?g.deltaY:S[1]-w[1],C,E=g.target,T=Math.abs(x)>Math.abs(y)?"h":"v";if("touches"in g&&T==="h"&&E.type==="range")return!1;var D=vw(T,E);if(!D)return!0;if(D?C=T:(C=T==="v"?"h":"v",D=vw(T,E)),!D)return!1;if(!r.current&&"changedTouches"in g&&(x||y)&&(r.current=C),!C)return!0;var N=r.current||C;return PL(N,v,g,N==="h"?x:y,!0)},[]),a=le.useCallback(function(g){var v=g;if(!(!Ds.length||Ds[Ds.length-1]!==s)){var w="deltaY"in v?kw(v):Mc(v),S=e.current.filter(function(C){return C.name===v.type&&C.target===v.target&&FL(C.delta,w)})[0];if(S&&S.should){v.cancelable&&v.preventDefault();return}if(!S){var x=(o.current.shards||[]).map(Cw).filter(Boolean).filter(function(C){return C.contains(v.target)}),y=x.length>0?l(v,x[0]):!o.current.noIsolation;y&&v.cancelable&&v.preventDefault()}}},[]),c=le.useCallback(function(g,v,w,S){var x={name:g,delta:v,target:w,should:S};e.current.push(x),setTimeout(function(){e.current=e.current.filter(function(y){return y!==x})},1)},[]),u=le.useCallback(function(g){n.current=Mc(g),r.current=void 0},[]),d=le.useCallback(function(g){c(g.type,kw(g),g.target,l(g,t.lockRef.current))},[]),f=le.useCallback(function(g){c(g.type,Mc(g),g.target,l(g,t.lockRef.current))},[]);le.useEffect(function(){return Ds.push(s),t.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",a,Ns),document.addEventListener("touchmove",a,Ns),document.addEventListener("touchstart",u,Ns),function(){Ds=Ds.filter(function(g){return g!==s}),document.removeEventListener("wheel",a,Ns),document.removeEventListener("touchmove",a,Ns),document.removeEventListener("touchstart",u,Ns)}},[]);var h=t.removeScrollBar,p=t.inert;return le.createElement(le.Fragment,null,p?le.createElement(s,{styles:$L(i)}):null,h?le.createElement(OL,{gapMode:"margin"}):null)}const HL=gL(mw,jL);var Sw=le.forwardRef(function(t,e){return le.createElement(Tc,Xn({},t,{ref:e,sideCar:HL}))});Sw.classNames=Tc.classNames;const Ew="Popover",[Tw,x3]=Ov(Ew,[sw]),yh=sw(),[zL,Rs]=Tw(Ew),VL=t=>{const{__scopePopover:e,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!1}=t,l=yh(e),a=_.useRef(null),[c,u]=_.useState(!1),[d=!1,f]=tL({prop:r,defaultProp:i,onChange:s});return _.createElement(YR,l,_.createElement(zL,{scope:e,contentId:$D(),triggerRef:a,open:d,onOpenChange:f,onOpenToggle:_.useCallback(()=>f(h=>!h),[f]),hasCustomAnchor:c,onCustomAnchorAdd:_.useCallback(()=>u(!0),[]),onCustomAnchorRemove:_.useCallback(()=>u(!1),[]),modal:o},n))},UL="PopoverTrigger",WL=_.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,i=Rs(UL,n),s=yh(n),o=Ai(e,i.triggerRef),l=_.createElement(Mi.button,dt({type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Mw(i.open)},r,{ref:o,onClick:Ur(t.onClick,i.onOpenToggle)}));return i.hasCustomAnchor?l:_.createElement(XR,dt({asChild:!0},s),l)}),qL="PopoverPortal",[k3,KL]=Tw(qL,{forceMount:void 0}),Qo="PopoverContent",JL=_.forwardRef((t,e)=>{const n=KL(Qo,t.__scopePopover),{forceMount:r=n.forceMount,...i}=t,s=Rs(Qo,t.__scopePopover);return _.createElement(uw,{present:r||s.open},s.modal?_.createElement(GL,dt({},i,{ref:e})):_.createElement(YL,dt({},i,{ref:e})))}),GL=_.forwardRef((t,e)=>{const n=Rs(Qo,t.__scopePopover),r=_.useRef(null),i=Ai(e,r),s=_.useRef(!1);return _.useEffect(()=>{const o=r.current;if(o)return oL(o)},[]),_.createElement(Sw,{as:Yf,allowPinchZoom:!0},_.createElement(Aw,dt({},t,{ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ur(t.onCloseAutoFocus,o=>{var l;o.preventDefault(),s.current||(l=n.triggerRef.current)===null||l===void 0||l.focus()}),onPointerDownOutside:Ur(t.onPointerDownOutside,o=>{const l=o.detail.originalEvent,a=l.button===0&&l.ctrlKey===!0,c=l.button===2||a;s.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:Ur(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})))}),YL=_.forwardRef((t,e)=>{const n=Rs(Qo,t.__scopePopover),r=_.useRef(!1),i=_.useRef(!1);return _.createElement(Aw,dt({},t,{ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o;if((o=t.onCloseAutoFocus)===null||o===void 0||o.call(t,s),!s.defaultPrevented){var l;r.current||(l=n.triggerRef.current)===null||l===void 0||l.focus(),s.preventDefault()}r.current=!1,i.current=!1},onInteractOutside:s=>{var o,l;(o=t.onInteractOutside)===null||o===void 0||o.call(t,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=s.target;((l=n.triggerRef.current)===null||l===void 0?void 0:l.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}}))}),Aw=_.forwardRef((t,e)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onInteractOutside:u,...d}=t,f=Rs(Qo,n),h=yh(n);return MD(),_.createElement(OD,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s},_.createElement(ED,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onDismiss:()=>f.onOpenChange(!1)},_.createElement(ZR,dt({"data-state":Mw(f.open),role:"dialog",id:f.contentId},h,d,{ref:e,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}}))))}),XL="PopoverClose",ZL=_.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,i=Rs(XL,n);return _.createElement(Mi.button,dt({type:"button"},r,{ref:e,onClick:Ur(t.onClick,()=>i.onOpenChange(!1))}))});function Mw(t){return t?"open":"closed"}const QL=VL,eI=WL,tI=JL,Oc=ZL,_c=({children:t,isActive:e,onClick:n,disabled:r,className:i})=>{const s=Se("flex items-center gap-2 p-1.5 text-xs font-medium text-neutral-500 text-left w-full rounded-md border border-transparent transition-all",!e&&!r,"hover:border-neutral-200 hover:bg-neutral-100",e&&!r&&"bg-neutral-200 text-neutral-800",r&&"text-neutral-300 cursor-not-allowed",i);return O.jsx("button",{className:s,disabled:r,onClick:n,children:t})},nI=(t,e,n)=>{const r=_.useCallback(()=>{const l=t.chain();l.setNodeSelection(n).unsetAllMarks(),(e==null?void 0:e.type.name)!=="paragraph"&&l.setParagraph(),l.run()},[t,n,e==null?void 0:e.type.name]),i=_.useCallback(()=>{t.commands.setNodeSelection(n);const{$anchor:l}=t.state.selection,a=l.node(1)||t.state.selection.node;t.chain().setMeta("hideDragHandle",!0).insertContentAt(n+((e==null?void 0:e.nodeSize)||0),a.toJSON()).run()},[t,n,e==null?void 0:e.nodeSize]),s=_.useCallback(()=>{t.chain().setMeta("hideDragHandle",!0).setNodeSelection(n).run(),document.execCommand("copy"),alert("copied")},[t,n]),o=_.useCallback(()=>{t.chain().setMeta("hideDragHandle",!0).setNodeSelection(n).deleteSelection().run()},[t,n]);return{resetTextFormatting:r,duplicateNode:i,copyNodeToClipboard:s,deleteNode:o}},rI=({node:t,getPos:e,editor:n,deleteNode:r})=>{const[i,s]=_.useState(!1),o=nI(n,t,e()),l=Yl(),a=["https://twitter.com","https://x.com"],c=_.useMemo(()=>{const{content:N}=t.content;return N[0].type.name==="table"},[t.content]),u=_.useMemo(()=>{var A;const{content:N}=t.content;return(A=N[0].content.content[0])==null?void 0:A.text},[t.content]),d=_.useMemo(()=>{var A;const{content:N}=t.content;return(A=N[0].content.content[1])==null?void 0:A.text},[t.content]),f=_.useMemo(()=>{const{content:N}=t.content;return N[0].content.content.find(A=>{var R;return(R=A==null?void 0:A.text)==null?void 0:R.match(/\/status\/([0-9]*)/)})},[t.content]),h=()=>{if(!u)return;let N=u;if(u.includes("<iframe"))N=d;else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(u):{const z=u.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);z&&z.length>0&&(N=`https://www.youtube.com/embed/${z[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(u):{const z=u.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);z&&z.length>0&&(N=`https://player.vimeo.com/video/${z[1]}`);break}default:return}const A=640,R=360,P=e(),B=P+t.nodeSize;N&&(n==null||n.chain().focus(P).deleteRange({from:P===0?P:P+1,to:B}).setIframe({src:N,width:A,height:R}).run())},p=N=>{const A=N.match(/\/status\/([0-9]*)/);return A&&A.length>0?A[1]:null},g=()=>{if(!u)return;let N=u;const A=a.some(z=>u.includes(z)),R=p(u);A&&R?N=R:f&&(N=p(f.text));const P=e(),B=P+t.nodeSize;N&&(n==null||n.chain().focus(P).deleteRange({from:P===2?P:P+1,to:B}).setTweetEmbed({tweetId:N}).run())},v=()=>{const N=e()+t.nodeSize;n.commands.insertContentAt(N,{type:"dBlock",content:[{type:"paragraph"}]})},w=()=>{const N=e();n.commands.insertContentAt(N,{type:"dBlock",content:[{type:"paragraph"}]})},S=()=>{r()},x=N=>{N.altKey?C():y()},y=()=>{v()},C=()=>{w()},E=N=>{N.altKey&&S()},D=Av(()=>{if(a.some(N=>u.includes(N))||f!=null&&f.text){g();return}else{h();return}},1e3);return _.useEffect(()=>{u&&D()},[u]),O.jsxs(wo,{as:"div",className:Se("flex gap-2 group w-full relative justify-center items-start",l&&"pointer-events-none",c&&"2xl:ml-4 pointer-events-auto"),children:[O.jsxs("section",{className:"lg:flex gap-1 hidden","aria-label":"left-menu",contentEditable:!1,children:[O.jsx(Py,{content:O.jsxs("div",{className:"flex flex-col w-40",children:[O.jsx("div",{className:"text-xs",children:"Click to add below"}),O.jsx("div",{className:"text-xs",children:"Opt + Click to add above"})]}),children:O.jsx("div",{className:`d-block-button cursor-pointer ${!l&&"group-hover:opacity-100"}`,contentEditable:!1,onClick:x,children:O.jsx(vA,{size:18})})}),O.jsxs(QL,{open:i,onOpenChange:s,children:[O.jsx(eI,{asChild:!0,children:O.jsx("div",{className:`d-block-button cursor-pointer ${!l&&"group-hover:opacity-100"}`,contentEditable:!1,draggable:!0,"data-drag-handle":!0,onClick:E,children:O.jsx(fA,{size:18})})}),O.jsx(tI,{side:"bottom",align:"start",sideOffset:8,className:"z-10",children:O.jsxs(gd,{className:"p-2 flex flex-col min-w-[16rem]",children:[O.jsx(Oc,{children:O.jsxs(_c,{onClick:o.resetTextFormatting,children:[O.jsx(wA,{size:18}),"Clear formatting"]})}),O.jsx(Oc,{children:O.jsxs(_c,{onClick:o.copyNodeToClipboard,children:[O.jsx(aA,{size:18}),"Copy to clipboard"]})}),O.jsx(Oc,{children:O.jsxs(_c,{onClick:o.duplicateNode,children:[O.jsx(uA,{size:18}),"Duplicate"]})}),O.jsx(ko.Divider,{horizontal:!0}),O.jsx(Oc,{children:O.jsxs(_c,{onClick:o.deleteNode,className:"text-red-500 hover:bg-red-500 bg-opacity-10 hover:bg-opacity-20",children:[O.jsx(EA,{size:18}),"Delete"]})})]})})]})]}),O.jsx(ly,{className:Se("node-view-content w-full",{"is-table min-w-auto":c})})]})},iI=ze.create({name:"dBlock",priority:1e3,group:"dBlock",content:"(block|columns)",draggable:!0,selectable:!1,inline:!1,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:'div[data-type="d-block"]'}]},renderHTML({HTMLAttributes:t}){return["div",Ce(t,{"data-type":"d-block"}),0]},addCommands(){return{setDBlock:t=>({state:e,chain:n})=>{const{selection:{from:r}}=e,i=t!==void 0||t!==null?r:t;return n().insertContentAt(i,{type:this.name,content:[{type:"paragraph"}]}).focus(i+2).run()},mergeDBlocksIntoList:t=>({state:e,dispatch:n})=>{if(!n)throw new Error("Dispatch function is not provided.");const{from:r,to:i}=e.selection;let s=e.tr;const o=[];if(e.doc.nodesBetween(r,i,a=>{if(a.type.name===this.name){const c=e.schema.nodes.listItem.create(null,a.content);c&&o.push(c)}}),o.length===0)return!1;const l=e.schema.nodes[t].create(null,o);return l?(s=s.replaceRangeWith(r,i,l),n(s),!0):!1},splitListToDBlocks:t=>({state:e,dispatch:n})=>{if(!n)throw new Error("Dispatch function is not provided.");const{from:r,to:i}=e.selection;let s=e.tr;return e.doc.nodesBetween(r,i,(o,l)=>{if(o.type.name===t){const a=e.schema.nodes[this.name].create(null,o.content);s=s.insert(l,a)}}),n(s),!0}}},addNodeView(){return hi(rI)},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setDBlock(),Enter:({editor:t})=>{var c;const{selection:{$head:e,from:n,to:r},doc:i}=t.state,s=e.node(e.depth-1);if((s==null?void 0:s.type.name)!=="dBlock")return!1;let o=-1,l="";i.descendants((u,d)=>{if(o!==-1)return!1;if(u.type.name===this.name)return;const[f,h]=[d,d+u.nodeSize];return f<=n&&r<=h&&(o=h,l=u.type.name),!1});const a=(c=i.slice(n,o))==null?void 0:c.toJSON().content;try{return l==="codeBlock"?t.chain().insertContentAt({from:n,to:o},`
|
439
|
-
`).focus(o+1).run():["columns","heading"].includes(l)?t.chain().insertContent({type:"dBlock",content:[{type:"paragraph"}]}).focus().run():t.chain().insertContentAt({from:n,to:o},{type:this.name,content:a}).focus(n+4).run()}catch(u){return console.error(`Error inserting content into dBlock node: ${u}`),!1}}}}});let bh,vh;if(typeof WeakMap<"u"){let t=new WeakMap;bh=e=>t.get(e),vh=(e,n)=>(t.set(e,n),n)}else{let t=[],e=10,n=0;bh=r=>{for(let i=0;i<t.length;i+=2)if(t[i]==r)return t[i+1]},vh=(r,i)=>(n==e&&(n=0),t[n++]=r,t[n++]=i)}class Ls{constructor(e,n,r,i){this.left=e,this.top=n,this.right=r,this.bottom=i}}class et{constructor(e,n,r,i){this.width=e,this.height=n,this.map=r,this.problems=i}findCell(e){for(let n=0;n<this.map.length;n++){let r=this.map[n];if(r!=e)continue;let i=n%this.width,s=n/this.width|0,o=i+1,l=s+1;for(let a=1;o<this.width&&this.map[n+a]==r;a++)o++;for(let a=1;l<this.height&&this.map[n+this.width*a]==r;a++)l++;return new Ls(i,s,o,l)}throw new RangeError("No cell with offset "+e+" found")}colCount(e){for(let n=0;n<this.map.length;n++)if(this.map[n]==e)return n%this.width;throw new RangeError("No cell with offset "+e+" found")}nextCell(e,n,r){let{left:i,right:s,top:o,bottom:l}=this.findCell(e);return n=="horiz"?(r<0?i==0:s==this.width)?null:this.map[o*this.width+(r<0?i-1:s)]:(r<0?o==0:l==this.height)?null:this.map[i+this.width*(r<0?o-1:l)]}rectBetween(e,n){let{left:r,right:i,top:s,bottom:o}=this.findCell(e),{left:l,right:a,top:c,bottom:u}=this.findCell(n);return new Ls(Math.min(r,l),Math.min(s,c),Math.max(i,a),Math.max(o,u))}cellsInRect(e){let n=[],r={};for(let i=e.top;i<e.bottom;i++)for(let s=e.left;s<e.right;s++){let o=i*this.width+s,l=this.map[o];r[l]||(r[l]=!0,(s!=e.left||!s||this.map[o-1]!=l)&&(i!=e.top||!i||this.map[o-this.width]!=l)&&n.push(l))}return n}positionAt(e,n,r){for(let i=0,s=0;;i++){let o=s+r.child(i).nodeSize;if(i==e){let l=n+e*this.width,a=(e+1)*this.width;for(;l<a&&this.map[l]<s;)l++;return l==a?o-1:this.map[l]}s=o}}static get(e){return bh(e)||vh(e,sI(e))}}function sI(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);let e=oI(t),n=t.childCount,r=[],i=0,s=null,o=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){let d=t.child(c);u++;for(let p=0;;p++){for(;i<r.length&&r[i]!=0;)i++;if(p==d.childCount)break;let g=d.child(p),{colspan:v,rowspan:w,colwidth:S}=g.attrs;for(let x=0;x<w;x++){if(x+c>=n){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:w-x});break}let y=i+x*e;for(let C=0;C<v;C++){r[y+C]==0?r[y+C]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:v-C});let E=S&&S[C];if(E){let T=(y+C)%e*2,D=o[T];D==null||D!=E&&o[T+1]==1?(o[T]=E,o[T+1]=1):D==E&&o[T+1]++}}}i+=v,u+=g.nodeSize}let f=(c+1)*e,h=0;for(;i<f;)r[i++]==0&&h++;h&&(s||(s=[])).push({type:"missing",row:c,n:h}),u++}let l=new et(e,n,r,s),a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<n&&(a=!0);return a&&lI(l,o,t),l}function oI(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){let i=t.child(r),s=0;if(n)for(let o=0;o<r;o++){let l=t.child(o);for(let a=0;a<l.childCount;a++){let c=l.child(a);o+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let o=0;o<i.childCount;o++){let l=i.child(o);s+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function lI(t,e,n){t.problems||(t.problems=[]);for(let r=0,i={};r<t.map.length;r++){let s=t.map[r];if(i[s])continue;i[s]=!0;let o=n.nodeAt(s),l=null;for(let a=0;a<o.attrs.colspan;a++){let c=(r+a)%t.width,u=e[c*2];u!=null&&(!o.attrs.colwidth||o.attrs.colwidth[a]!=u)&&((l||(l=aI(o.attrs)))[a]=u)}l&&t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function aI(t){if(t.colwidth)return t.colwidth.slice();let e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Mt(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(let n in t.nodes){let r=t.nodes[n],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const Gr=new We("selectingCells");function Is(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 cI(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 An(t){let 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 Nc(t){let e=t.selection;return e.$anchorCell?e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell:e.node&&e.node.type.spec.tableRole=="cell"?e.$anchor:Is(e.$head)||uI(e.$head)}function uI(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){let 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--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function wh(t){return t.parent.type.spec.tableRole=="row"&&t.nodeAfter}function dI(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function xh(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Ow(t,e,n){let r=t.start(-1),s=et.get(t.node(-1)).nextCell(t.pos-r,e,n);return s==null?null:t.node(0).resolve(r+s)}function wt(t,e,n){let r={};for(let i in t)r[i]=t[i];return r[e]=n,r}function _i(t,e,n=1){let r=wt(t,"colspan",t.colspan-n);return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function _w(t,e,n=1){let r=wt(t,"colspan",t.colspan+n);if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<n;i++)r.colwidth.splice(e,0,0)}return r}function fI(t,e,n){let r=Mt(e.type.schema).header_cell;for(let i=0;i<t.height;i++)if(e.nodeAt(t.map[n+i*t.width]).type!=r)return!1;return!0}class Ae extends ue{constructor(e,n=e){let r=e.node(-1),i=et.get(r),s=e.start(-1),o=i.rectBetween(e.pos-s,n.pos-s),l=e.node(0),a=i.cellsInRect(o).filter(u=>u!=n.pos-s);a.unshift(n.pos-s);let c=a.map(u=>{let d=r.nodeAt(u),f=u+s+1;return new eu(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){let r=e.resolve(n.map(this.$anchorCell.pos)),i=e.resolve(n.map(this.$headCell.pos));if(wh(r)&&wh(i)&&xh(r,i)){let s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?Ae.rowSelection(r,i):s&&this.isColSelection()?Ae.colSelection(r,i):new Ae(r,i)}return ce.between(r,i)}content(){let e=this.$anchorCell.node(-1),n=et.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},o=[];for(let a=i.top;a<i.bottom;a++){let c=[];for(let u=a*n.width+i.left,d=i.left;d<i.right;d++,u++){let f=n.map[u];if(!s[f]){s[f]=!0;let h=n.findCell(f),p=e.nodeAt(f),g=i.left-h.left,v=h.right-i.right;if(g>0||v>0){let w=p.attrs;g>0&&(w=_i(w,0,g)),v>0&&(w=_i(w,w.colspan-v,v)),h.left<i.left?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}if(h.top<i.top||h.bottom>i.bottom){let w=wt(p.attrs,"rowspan",Math.min(h.bottom,i.bottom)-Math.max(h.top,i.top));h.top<i.top?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}c.push(p)}}o.push(e.child(a).copy(W.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new Y(W.from(l),1,1)}replace(e,n=Y.empty){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:l,$to:a}=i[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?Y.empty:n)}let s=ue.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,n){this.replace(e,new Y(W.from(n),0,0))}forEachCell(e){let n=this.$anchorCell.node(-1),r=et.get(n),i=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let o=0;o<s.length;o++)e(n.nodeAt(s[o]),i+s[o])}isColSelection(){let e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){let r=et.get(e.node(-1)),i=e.start(-1),s=r.findCell(e.pos-i),o=r.findCell(n.pos-i),l=e.node(0);return s.top<=o.top?(s.top>0&&(e=l.resolve(i+r.map[s.left])),o.bottom<r.height&&(n=l.resolve(i+r.map[r.width*(r.height-1)+o.right-1]))):(o.top>0&&(n=l.resolve(i+r.map[o.left])),s.bottom<r.height&&(e=l.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))),new Ae(e,n)}isRowSelection(){let e=et.get(this.$anchorCell.node(-1)),n=this.$anchorCell.start(-1),r=e.colCount(this.$anchorCell.pos-n),i=e.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;let s=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,o)==e.width}eq(e){return e instanceof Ae&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){let r=et.get(e.node(-1)),i=e.start(-1),s=r.findCell(e.pos-i),o=r.findCell(n.pos-i),l=e.node(0);return s.left<=o.left?(s.left>0&&(e=l.resolve(i+r.map[s.top*r.width])),o.right<r.width&&(n=l.resolve(i+r.map[r.width*(o.top+1)-1]))):(o.left>0&&(n=l.resolve(i+r.map[o.top*r.width])),s.right<r.width&&(e=l.resolve(i+r.map[r.width*(s.top+1)-1]))),new Ae(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Ae(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Ae(e.resolve(n),e.resolve(r))}getBookmark(){return new kh(this.$anchorCell.pos,this.$headCell.pos)}}Ae.prototype.visible=!1,ue.jsonID("cell",Ae);class kh{constructor(e,n){this.anchor=e,this.head=n}map(e){return new kh(e.map(this.anchor),e.map(this.head))}resolve(e){let 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&&xh(n,r)?new Ae(n,r):ue.near(r,1)}}function hI(t){if(!(t.selection instanceof Ae))return null;let e=[];return t.selection.forEachCell((n,r)=>{e.push(ut.node(r,r+n.nodeSize,{class:"selectedCell"}))}),He.create(t.doc,e)}function pI({$from:t,$to:e}){if(t.pos==e.pos||t.pos<t.pos-6)return!1;let n=t.pos,r=e.pos,i=t.depth;for(;i>=0&&!(t.after(i+1)<t.end(i));i--,n++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function mI({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){let s=t.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){n=s;break}}for(let i=e.depth;i>0;i--){let s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return n!==r&&e.parentOffset===0}function gI(t,e,n){let r=(e||t).selection,i=(e||t).doc,s,o;if(r instanceof se&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=Ae.create(i,r.from);else if(o=="row"){let l=i.resolve(r.from+1);s=Ae.rowSelection(l,l)}else if(!n){let l=et.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=Ae.create(i,a+1,c)}}else r instanceof ce&&pI(r)?s=ce.create(i,r.from):r instanceof ce&&mI(r)&&(s=ce.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=t.tr)).setSelection(s),e}function yI(t){if(!t.size)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.firstChild.type.spec.tableRole=="table");)n--,r--,e=e.firstChild.content;let i=e.firstChild,s=i.type.spec.tableRole,o=i.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,u=a?0:Math.max(0,n-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=Ch(Mt(o).row,new Y(c,u,d)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(n||r?Ch(Mt(o).row,new Y(e,n,r)).content:e);else return null;return bI(o,l)}function bI(t,e){let n=[];for(let i=0;i<e.length;i++){let s=e[i];for(let o=s.childCount-1;o>=0;o--){let{rowspan:l,colspan:a}=s.child(o).attrs;for(let c=i;c<i+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let i=0;i<n.length;i++)r=Math.max(r,n[i]);for(let i=0;i<n.length;i++)if(i>=e.length&&e.push(W.empty),n[i]<r){let s=Mt(t).cell.createAndFill(),o=[];for(let l=n[i];l<r;l++)o.push(s);e[i]=e[i].append(W.from(o))}return{height:e.length,width:r,rows:e}}function Ch(t,e){let n=t.createAndFill();return new Zc(n).replace(0,n.content.size,e).doc}function vI({width:t,height:e,rows:n},r,i){if(t!=r){let s=[],o=[];for(let l=0;l<n.length;l++){let a=n[l],c=[];for(let u=s[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.create(_i(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)s[l+h]=(s[l+h]||0)+f.attrs.colspan}o.push(W.from(c))}n=o,t=r}if(e!=i){let s=[];for(let o=0,l=0;o<i;o++,l++){let a=[],c=n[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);o+d.attrs.rowspan>i&&(d=d.type.create(wt(d.attrs,"rowspan",Math.max(1,i-d.attrs.rowspan)),d.content)),a.push(d)}s.push(W.from(a))}n=s,e=i}return{width:t,height:e,rows:n}}function wI(t,e,n,r,i,s,o){let l=t.doc.type.schema,a=Mt(l),c,u;if(i>e.width)for(let d=0,f=0;d<e.height;d++){let h=n.child(d);f+=h.nodeSize;let p=[],g;h.lastChild==null||h.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=u||(u=a.header_cell.createAndFill());for(let v=e.width;v<i;v++)p.push(g);t.insert(t.mapping.slice(o).map(f-1+r),p)}if(s>e.height){let d=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,i);p++){let v=p>=e.width?!1:n.nodeAt(e.map[g+p]).type==a.header_cell;d.push(v?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,W.from(d)),h=[];for(let p=e.height;p<s;p++)h.push(f);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),h)}return!!(c||u)}function Nw(t,e,n,r,i,s,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=i;c<s;c++){let u=o*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;let f=n.nodeAt(d),{top:h,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,wt(f.attrs,"rowspan",o-h)),t.insert(t.mapping.slice(l).map(e.positionAt(o,p,n)),f.type.createAndFill(wt(f.attrs,"rowspan",h+f.attrs.rowspan-o))),c+=f.attrs.colspan-1}}return a}function Dw(t,e,n,r,i,s,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=i;c<s;c++){let u=c*e.width+o,d=e.map[u];if(e.map[u-1]==d){a=!0;let f=n.nodeAt(d),h=e.colCount(d),p=t.mapping.slice(l).map(d+r);t.setNodeMarkup(p,null,_i(f.attrs,o-h,f.attrs.colspan-(o-h))),t.insert(p+f.nodeSize,f.type.createAndFill(_i(f.attrs,0,o-h))),c+=f.attrs.rowspan-1}}return a}function Rw(t,e,n,r,i){let s=n?t.doc.nodeAt(n-1):t.doc,o=et.get(s),{top:l,left:a}=r,c=a+i.width,u=l+i.height,d=t.tr,f=0;function h(){s=n?d.doc.nodeAt(n-1):d.doc,o=et.get(s),f=d.mapping.maps.length}wI(d,o,s,n,c,u,f)&&h(),Nw(d,o,s,n,a,c,l,f)&&h(),Nw(d,o,s,n,a,c,u,f)&&h(),Dw(d,o,s,n,l,u,a,f)&&h(),Dw(d,o,s,n,l,u,c,f)&&h();for(let p=l;p<u;p++){let g=o.positionAt(p,a,s),v=o.positionAt(p,c,s);d.replace(d.mapping.slice(f).map(g+n),d.mapping.slice(f).map(v+n),new Y(i.rows[p-l],0,0))}h(),d.setSelection(new Ae(d.doc.resolve(n+o.positionAt(l,a,s)),d.doc.resolve(n+o.positionAt(u-1,c-1,s)))),e(d)}const xI=Ou({ArrowLeft:Rc("horiz",-1),ArrowRight:Rc("horiz",1),ArrowUp:Rc("vert",-1),ArrowDown:Rc("vert",1),"Shift-ArrowLeft":Lc("horiz",-1),"Shift-ArrowRight":Lc("horiz",1),"Shift-ArrowUp":Lc("vert",-1),"Shift-ArrowDown":Lc("vert",1),Backspace:Ic,"Mod-Backspace":Ic,Delete:Ic,"Mod-Delete":Ic});function Dc(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Rc(t,e){return(n,r,i)=>{let s=n.selection;if(s instanceof Ae)return Dc(n,r,ue.near(s.$headCell,e));if(t!="horiz"&&!s.empty)return!1;let o=Lw(i,t,e);if(o==null)return!1;if(t=="horiz")return Dc(n,r,ue.near(n.doc.resolve(s.head+e),e));{let l=n.doc.resolve(o),a=Ow(l,t,e),c;return a?c=ue.near(a,1):e<0?c=ue.near(n.doc.resolve(l.before(-1)),-1):c=ue.near(n.doc.resolve(l.after(-1)),1),Dc(n,r,c)}}}function Lc(t,e){return(n,r,i)=>{let s=n.selection;if(!(s instanceof Ae)){let l=Lw(i,t,e);if(l==null)return!1;s=new Ae(n.doc.resolve(l))}let o=Ow(s.$headCell,t,e);return o?Dc(n,r,new Ae(s.$anchorCell,o)):!1}}function Ic(t,e){let n=t.selection;if(!(n instanceof Ae))return!1;if(e){let r=t.tr,i=Mt(t.schema).cell.createAndFill().content;n.forEachCell((s,o)=>{s.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+s.nodeSize-1),new Y(i,0,0))}),r.docChanged&&e(r)}return!0}function kI(t,e){let n=t.state.doc,r=Is(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Ae(r))),!0):!1}function CI(t,e,n){if(!An(t.state))return!1;let r=yI(n),i=t.state.selection;if(i instanceof Ae){r||(r={width:1,height:1,rows:[W.from(Ch(Mt(t.state.schema).cell,n))]});let s=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),l=et.get(s).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=vI(r,l.right-l.left,l.bottom-l.top),Rw(t.state,t.dispatch,o,l,r),!0}else if(r){let s=Nc(t.state),o=s.start(-1);return Rw(t.state,t.dispatch,o,et.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function SI(t,e){if(e.ctrlKey||e.metaKey)return;let n=Iw(t,e.target),r;if(e.shiftKey&&t.state.selection instanceof Ae)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&n&&(r=Is(t.state.selection.$anchor))!=null&&Sh(t,e).pos!=r.pos)i(r,e),e.preventDefault();else if(!n)return;function i(l,a){let c=Sh(t,a),u=Gr.getState(t.state)==null;if(!c||!xh(l,c))if(u)c=l;else return;let d=new Ae(l,c);if(u||!t.state.selection.eq(d)){let f=t.state.tr.setSelection(d);u&&f.setMeta(Gr,l.pos),t.dispatch(f)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",o),Gr.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Gr,-1))}function o(l){let a=Gr.getState(t.state),c;if(a!=null)c=t.state.doc.resolve(a);else if(Iw(t,l.target)!=n&&(c=Sh(t,e),!c))return s();c&&i(c,l)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",o)}function Lw(t,e,n){if(!(t.state.selection instanceof ce))return null;let{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){let s=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){let l=r.before(i),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?l:null}}return null}function Iw(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e}function Sh(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?Is(t.state.doc.resolve(n.pos)):null}const EI=new We("fix-tables");function Pw(t,e,n,r){let i=t.childCount,s=e.childCount;e:for(let o=0,l=0;o<s;o++){let a=e.child(o);for(let c=l,u=Math.min(i,o+3);c<u;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<i&&t.child(l).sameMarkup(a)?Pw(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function Fw(t,e){let n,r=(i,s)=>{i.type.spec.tableRole=="table"&&(n=TI(t,i,s,n))};return e?e.doc!=t.doc&&Pw(e.doc,t.doc,0,r):t.doc.descendants(r),n}function TI(t,e,n,r){let i=et.get(e);if(!i.problems)return r;r||(r=t.tr);let s=[];for(let a=0;a<i.height;a++)s.push(0);for(let a=0;a<i.problems.length;a++){let c=i.problems[a];if(c.type=="collision"){let u=e.nodeAt(c.pos);for(let d=0;d<u.attrs.rowspan;d++)s[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,_i(u.attrs,u.attrs.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,wt(u.attrs,"rowspan",u.attrs.rowspan-c.n))}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,wt(u.attrs,"colwidth",c.colwidth))}}let o,l;for(let a=0;a<s.length;a++)s[a]&&(o==null&&(o=a),l=a);for(let a=0,c=n+1;a<i.height;a++){let u=e.child(a),d=c+u.nodeSize,f=s[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let v=0;v<f;v++)p.push(Mt(t.schema)[h].createAndFill());let g=(a==0||o==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(g),p)}c=d}return r.setMeta(EI,{fixTables:!0})}function Zn(t){let e=t.selection,n=Nc(t),r=n.node(-1),i=n.start(-1),s=et.get(r),o;return e instanceof Ae?o=s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o=s.findCell(n.pos-i),o.tableStart=i,o.map=s,o.table=r,o}function $w(t,{map:e,tableStart:n,table:r},i){let s=i>0?-1:0;fI(e,r,i+s)&&(s=i==0||i==e.width?null:0);for(let o=0;o<e.height;o++){let l=o*e.width+i;if(i>0&&i<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,_w(c.attrs,i-e.colCount(a))),o+=c.attrs.rowspan-1}else{let a=s==null?Mt(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,c=e.positionAt(o,i,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function AI(t,e){if(!An(t))return!1;if(e){let n=Zn(t);e($w(t.tr,n,n.left))}return!0}function MI(t,e){if(!An(t))return!1;if(e){let n=Zn(t);e($w(t.tr,n,n.right))}return!0}function OI(t,{map:e,table:n,tableStart:r},i){let s=t.mapping.maps.length;for(let o=0;o<e.height;){let l=o*e.width+i,a=e.map[l],c=n.nodeAt(a);if(i>0&&e.map[l-1]==a||i<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(s).map(r+a),null,_i(c.attrs,i-e.colCount(a)));else{let u=t.mapping.slice(s).map(r+a);t.delete(u,u+c.nodeSize)}o+=c.attrs.rowspan}}function _I(t,e){if(!An(t))return!1;if(e){let n=Zn(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;OI(r,n,i),i!=n.left;i--)n.table=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc,n.map=et.get(n.table);e(r)}return!0}function NI(t,e,n){let r=Mt(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(e.nodeAt(t.map[i+n*t.width]).type!=r)return!1;return!0}function Bw(t,{map:e,tableStart:n,table:r},i){let s=n;for(let a=0;a<i;a++)s+=r.child(a).nodeSize;let o=[],l=i>0?-1:0;NI(e,r,i+l)&&(l=i==0||i==e.height?null:0);for(let a=0,c=e.width*i;a<e.width;a++,c++)if(i>0&&i<e.height&&e.map[c]==e.map[c-e.width]){let u=e.map[c],d=r.nodeAt(u).attrs;t.setNodeMarkup(n+u,null,wt(d,"rowspan",d.rowspan+1)),a+=d.colspan-1}else{let u=l==null?Mt(r.type.schema).cell:r.nodeAt(e.map[c+l*e.width]).type;o.push(u.createAndFill())}return t.insert(s,Mt(r.type.schema).row.create(null,o)),t}function DI(t,e){if(!An(t))return!1;if(e){let n=Zn(t);e(Bw(t.tr,n,n.top))}return!0}function RI(t,e){if(!An(t))return!1;if(e){let n=Zn(t);e(Bw(t.tr,n,n.bottom))}return!0}function LI(t,{map:e,table:n,tableStart:r},i){let s=0;for(let a=0;a<i;a++)s+=n.child(a).nodeSize;let o=s+n.child(i).nodeSize,l=t.mapping.maps.length;t.delete(s+r,o+r);for(let a=0,c=i*e.width;a<e.width;a++,c++){let u=e.map[c];if(i>0&&u==e.map[c-e.width]){let d=n.nodeAt(u).attrs;t.setNodeMarkup(t.mapping.slice(l).map(u+r),null,wt(d,"rowspan",d.rowspan-1)),a+=d.colspan-1}else if(i<e.width&&u==e.map[c+e.width]){let d=n.nodeAt(u),f=d.type.create(wt(d.attrs,"rowspan",d.attrs.rowspan-1),d.content),h=e.positionAt(i+1,a,n);t.insert(t.mapping.slice(l).map(r+h),f),a+=d.attrs.colspan-1}}}function II(t,e){if(!An(t))return!1;if(e){let n=Zn(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;LI(r,n,i),i!=n.top;i--)n.table=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc,n.map=et.get(n.table);e(r)}return!0}function jw(t){let e=t.content;return e.childCount==1&&e.firstChild.isTextblock&&e.firstChild.childCount==0}function PI({width:t,height:e,map:n},r){let i=r.top*t+r.left,s=i,o=(r.bottom-1)*t+r.left,l=i+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[s]==n[s-1]||r.right<t&&n[l]==n[l+1])return!0;s+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[i]==n[i-t]||r.bottom<e&&n[o]==n[o+t])return!0;i++,o++}return!1}function Hw(t,e){let n=t.selection;if(!(n instanceof Ae)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=Zn(t),{map:i}=r;if(PI(i,r))return!1;if(e){let s=t.tr,o={},l=W.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){let f=i.map[u*i.width+d],h=r.table.nodeAt(f);if(!o[f])if(o[f]=!0,a==null)a=f,c=h;else{jw(h)||(l=l.append(h.content));let p=s.mapping.map(f+r.tableStart);s.delete(p,p+h.nodeSize)}}if(s.setNodeMarkup(a+r.tableStart,null,wt(_w(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),"rowspan",r.bottom-r.top)),l.size){let u=a+1+c.content.size,d=jw(c)?a+1:u;s.replaceWith(d+r.tableStart,u+r.tableStart,l)}s.setSelection(new Ae(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function zw(t,e){const n=Mt(t.schema);return FI(({node:r})=>n[r.type.spec.tableRole])(t,e)}function FI(t){return(e,n)=>{let r=e.selection,i,s;if(r instanceof Ae){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{if(i=cI(r.$from),!i)return!1;s=Is(r.$from).pos}if(i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let o=i.attrs,l=[],a=o.colwidth;o.rowspan>1&&(o=wt(o,"rowspan",1)),o.colspan>1&&(o=wt(o,"colspan",1));let c=Zn(e),u=e.tr;for(let f=0;f<c.right-c.left;f++)l.push(a?wt(o,"colwidth",a&&a[f]?[a[f]]:null):o);let d;for(let f=c.top;f<c.bottom;f++){let h=c.map.positionAt(f,c.left,c.table);f==c.top&&(h+=i.nodeSize);for(let p=c.left,g=0;p<c.right;p++,g++)p==c.left&&f==c.top||u.insert(d=u.mapping.map(h+c.tableStart,1),t({node:i,row:f,col:p}).createAndFill(l[g]))}u.setNodeMarkup(s,t({node:i,row:c.top,col:c.left}),l[0]),r instanceof Ae&&u.setSelection(new Ae(u.doc.resolve(r.$anchorCell.pos),d&&u.doc.resolve(d))),n(u)}return!0}}function $I(t,e){return function(n,r){if(!An(n))return!1;let i=Nc(n);if(i.nodeAfter.attrs[t]===e)return!1;if(r){let s=n.tr;n.selection instanceof Ae?n.selection.forEachCell((o,l)=>{o.attrs[t]!==e&&s.setNodeMarkup(l,null,wt(o.attrs,t,e))}):s.setNodeMarkup(i.pos,null,wt(i.nodeAfter.attrs,t,e)),r(s)}return!0}}function BI(t){return function(e,n){if(!An(e))return!1;if(n){let r=Mt(e.schema),i=Zn(e),s=e.tr,o=i.map.cellsInRect(t=="column"?new Ls(i.left,0,i.right,i.map.height):t=="row"?new Ls(0,i.top,i.map.width,i.bottom):i),l=o.map(a=>i.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(i.tableStart+o[a],r.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<o.length;a++)s.setNodeMarkup(i.tableStart+o[a],r.header_cell,l[a].attrs);n(s)}return!0}}function Vw(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 i=0;i<r.length;i++){const s=e.table.nodeAt(r[i]);if(s&&s.type!==n.header_cell)return!1}return!0}function el(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?BI(t):function(n,r){if(!An(n))return!1;if(r){let i=Mt(n.schema),s=Zn(n),o=n.tr,l=Vw("row",s,i),a=Vw("column",s,i),u=(t==="column"?l:t==="row"?a:!1)?1:0,d=t=="column"?new Ls(0,u,1,s.map.height):t=="row"?new Ls(u,0,s.map.width,1):s,f=t=="column"?a?i.cell:i.header_cell:t=="row"?l?i.cell:i.header_cell:i.cell;s.map.cellsInRect(d).forEach(h=>{const p=h+s.tableStart,g=o.doc.nodeAt(p);g&&o.setNodeMarkup(p,f,g.attrs)}),r(o)}return!0}}el("row",{useDeprecatedLogic:!0}),el("column",{useDeprecatedLogic:!0});let jI=el("cell",{useDeprecatedLogic:!0});function HI(t,e){if(e<0){let n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,i=t.before();r>=0;r--){let s=t.node(-1).child(r);if(s.childCount)return i-1-s.lastChild.nodeSize;i-=s.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;let n=t.node(-1);for(let r=t.indexAfter(-1),i=t.after();r<n.childCount;r++){let s=n.child(r);if(s.childCount)return i+1;i+=s.nodeSize}}}function Uw(t){return function(e,n){if(!An(e))return!1;let r=HI(Nc(e),t);if(r!=null){if(n){let i=e.doc.resolve(r);n(e.tr.setSelection(ce.between(i,dI(i))).scrollIntoView())}return!0}}}function zI(t,e){let 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}let VI=class{constructor(e,n){this.node=e,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Eh(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,Eh(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Eh(t,e,n,r,i,s){let o=0,l=!0,a=e.firstChild,c=t.firstChild;for(let u=0,d=0;u<c.childCount;u++){let{colspan:f,colwidth:h}=c.child(u).attrs;for(let p=0;p<f;p++,d++){let g=i==d?s:h&&h[p],v=g?g+"px":"";o+=g||r,g||(l=!1),a?(a.style.width!=v&&(a.style.width=v),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=v}}for(;a;){let u=a.nextSibling;a.parentNode.removeChild(a),a=u}l?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}const mn=new We("tableColumnResizing");function UI({handleWidth:t=5,cellMinWidth:e=25,View:n=VI,lastColumnResizable:r=!0}={}){return new je({key:mn,state:{init(s,o){return this.spec.props.nodeViews[Mt(o.schema).table.name]=(l,a)=>new n(l,e,a),new tl(-1,!1)},apply(s,o){return o.apply(s)}},props:{attributes(s){return mn.getState(s).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove(s,o){WI(s,o,t,e,r)},mouseleave(s){qI(s)},mousedown(s,o){KI(s,o,e)}},decorations(s){let o=mn.getState(s);if(o.activeHandle>-1)return QI(s,o.activeHandle)},nodeViews:{}}})}class tl{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){let n=this,r=e.getMeta(mn);if(r&&r.setHandle!=null)return new tl(r.setHandle,null);if(r&&r.setDragging!==void 0)return new tl(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);wh(e.doc.resolve(i))||(i=null),n=new tl(i,n.dragging)}return n}}function WI(t,e,n,r,i){let s=mn.getState(t.state);if(!s.dragging){let o=GI(e.target),l=-1;if(o){let{left:a,right:c}=o.getBoundingClientRect();e.clientX-a<=n?l=Ww(t,e,"left"):c-e.clientX<=n&&(l=Ww(t,e,"right"))}if(l!=s.activeHandle){if(!i&&l!==-1){let a=t.state.doc.resolve(l),c=a.node(-1),u=et.get(c),d=a.start(-1);if(u.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==u.width-1)return}Kw(t,l)}}}function qI(t){let e=mn.getState(t.state);e.activeHandle>-1&&!e.dragging&&Kw(t,-1)}function KI(t,e,n){let r=mn.getState(t.state);if(r.activeHandle==-1||r.dragging)return!1;let i=t.state.doc.nodeAt(r.activeHandle),s=JI(t,r.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(mn,{setDragging:{startX:e.clientX,startWidth:s}}));function o(a){window.removeEventListener("mouseup",o),window.removeEventListener("mousemove",l);let c=mn.getState(t.state);c.dragging&&(YI(t,c.activeHandle,qw(c.dragging,a,n)),t.dispatch(t.state.tr.setMeta(mn,{setDragging:null})))}function l(a){if(!a.which)return o(a);let c=mn.getState(t.state),u=qw(c.dragging,a,n);XI(t,c.activeHandle,u,n)}return window.addEventListener("mouseup",o),window.addEventListener("mousemove",l),e.preventDefault(),!0}function JI(t,e,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let s=t.domAtPos(e),l=s.node.childNodes[s.offset].offsetWidth,a=n;if(r)for(let c=0;c<n;c++)r[c]&&(l-=r[c],a--);return l/a}function GI(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Ww(t,e,n){let r=t.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return-1;let{pos:i}=r,s=Is(t.state.doc.resolve(i));if(!s)return-1;if(n=="right")return s.pos;let o=et.get(s.node(-1)),l=s.start(-1),a=o.map.indexOf(s.pos-l);return a%o.width==0?-1:l+o.map[a-1]}function qw(t,e,n){let r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function Kw(t,e){t.dispatch(t.state.tr.setMeta(mn,{setHandle:e}))}function YI(t,e,n){let r=t.state.doc.resolve(e),i=r.node(-1),s=et.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<s.height;c++){let u=c*s.width+l;if(c&&s.map[u]==s.map[u-s.width])continue;let d=s.map[u],{attrs:f}=i.nodeAt(d),h=f.colspan==1?0:l-s.colCount(d);if(f.colwidth&&f.colwidth[h]==n)continue;let p=f.colwidth?f.colwidth.slice():ZI(f.colspan);p[h]=n,a.setNodeMarkup(o+d,null,wt(f,"colwidth",p))}a.docChanged&&t.dispatch(a)}function XI(t,e,n,r){let i=t.state.doc.resolve(e),s=i.node(-1),o=i.start(-1),l=et.get(s).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,a=t.domAtPos(i.start(-1)).node;for(;a.nodeName!="TABLE";)a=a.parentNode;Eh(s,a.firstChild,a,r,l,n)}function ZI(t){let e=[];for(let n=0;n<t;n++)e.push(0);return e}function QI(t,e){let n=[],r=t.doc.resolve(e),i=r.node(-1),s=et.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan;for(let a=0;a<s.height;a++){let c=l+a*s.width-1;if((l==s.width||s.map[c]!=s.map[c+1])&&(a==0||s.map[c-1]!=s.map[c-1-s.width])){let u=s.map[c],d=o+u+i.nodeAt(u).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",n.push(ut.widget(d,f))}}return He.create(t.doc,n)}function eP({allowTableNodeSelection:t=!1}={}){return new je({key:Gr,state:{init(){return null},apply(e,n){let r=e.getMeta(Gr);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;let{deleted:i,pos:s}=e.mapping.mapResult(n);return i?null:s}},props:{decorations:hI,handleDOMEvents:{mousedown:SI},createSelectionBetween(e){if(Gr.getState(e.state)!=null)return e.state.selection},handleTripleClick:kI,handleKeyDown:xI,handlePaste:CI},appendTransaction(e,n,r){return gI(r,Fw(r,n),t)}})}function Jw(t,e,n,r,i,s){var u;let o=0,l=!0,a=e.firstChild;const c=t.firstChild;if(c)for(let d=0,f=0;d<c.childCount;d+=1){const{colspan:h,colwidth:p}=c.child(d).attrs;for(let g=0;g<h;g+=1,f+=1){const v=i===f?s:p&&p[g],w=v?`${v}px`:"";o+=v||r,v||(l=!1),a?(a.style.width!==w&&(a.style.width=w),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=w}}for(;a;){const d=a.nextSibling;(u=a==null?void 0:a.parentNode)==null||u.removeChild(a),a=d}l?(n.style.width=`${o}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${o}px`)}class tP{constructor(e,n){vr(this,"node");vr(this,"cellMinWidth");vr(this,"dom");vr(this,"table");vr(this,"colgroup");vr(this,"contentDOM");this.node=e,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Jw(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,Jw(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function Gw(t,e){return t.createAndFill()}function nP(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 rP(t,e,n,r,i){const s=nP(t),o=[],l=[];for(let c=0;c<n;c+=1){const u=Gw(s.cell);if(u&&l.push(u),r){const d=Gw(s.header_cell);d&&o.push(d)}}const a=[];for(let c=0;c<e;c+=1)a.push(s.row.createChecked(null,r&&c===0?o:l));return s.table.createChecked(null,a)}function iP(t){return t instanceof Ae}const Pc=({editor:t})=>{const{selection:e}=t.state;if(!iP(e))return!1;let n=0;const r=Bu(e.ranges[0].$from,s=>s.type.name==="table");return r==null||r.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},sP=ze.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:tP,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){let n=0,r=!0;try{t.content.firstChild.content.forEach(s=>{if(s.attrs.colwidth)s.attrs.colwidth.forEach(o=>{o?n+=o:(r=!1,n+=this.options.cellMinWidth)});else{r=!1;const o=s.attrs.colspan?s.attrs.colspan:1;n+=this.options.cellMinWidth*o}})}catch{r=!1}return r&&n>0?e.style=`width: ${n}px;`:n&&n>0?e.style=`min-width: ${n}px`:e.style=null,["div",{class:"table-wrapper"},["table",Ce(this.options.HTMLAttributes,e),["tbody",0]]]},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:s})=>{const{selection:o}=r,l=rP(s.schema,t,e,n);if(i){const a=r.selection.anchor+1;r.replaceRangeWith(o.from-1,o.to,l).scrollIntoView().setSelection(ce.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>AI(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>MI(t,e),deleteColumn:()=>({state:t,dispatch:e})=>_I(t,e),addRowBefore:()=>({state:t,dispatch:e})=>DI(t,e),addRowAfter:()=>({state:t,dispatch:e})=>RI(t,e),deleteRow:()=>({state:t,dispatch:e})=>II(t,e),deleteTable:()=>({state:t,dispatch:e})=>zI(t,e),mergeCells:()=>({state:t,dispatch:e})=>Hw(t,e),splitCell:()=>({state:t,dispatch:e})=>zw(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>el("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>el("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>jI(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Hw(t,e)?!0:zw(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>$I(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Uw(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Uw(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&Fw(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Ae.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:Pc,"Mod-Backspace":Pc,Delete:Pc,"Mod-Delete":Pc}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[UI({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],eP({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:be(re(t,"tableRole",e))}}});function Yw(t,e){if(t==null)return{};var n={},r=Object.keys(t),i,s;for(s=0;s<r.length;s++)i=r[s],!(e.indexOf(i)>=0)&&(n[i]=t[i]);return n}var Xw=typeof window<"u"&&typeof document<"u";function Th(t,e){t&&(typeof t=="function"&&t(e),{}.hasOwnProperty.call(t,"current")&&(t.current=e))}function Zw(){return Xw&&document.createElement("div")}function oP(t){var e={"data-placement":t.placement};return t.referenceHidden&&(e["data-reference-hidden"]=""),t.escaped&&(e["data-escaped"]=""),e}function Qw(t,e){if(t===e)return!0;if(typeof t=="object"&&t!=null&&typeof e=="object"&&e!=null){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(var n in t)if(e.hasOwnProperty(n)){if(!Qw(t[n],e[n]))return!1}else return!1;return!0}else return!1}function lP(t){var e=[];return t.forEach(function(n){e.find(function(r){return Qw(n,r)})||e.push(n)}),e}function aP(t,e){var n,r;return Object.assign({},e,{popperOptions:Object.assign({},t.popperOptions,e.popperOptions,{modifiers:lP([].concat(((n=t.popperOptions)==null?void 0:n.modifiers)||[],((r=e.popperOptions)==null?void 0:r.modifiers)||[]))})})}var Ah=Xw?_.useLayoutEffect:_.useEffect;function cP(t){var e=_.useRef();return e.current||(e.current=typeof t=="function"?t():t),e.current}function e1(t,e,n){n.split(/\s+/).forEach(function(r){r&&t.classList[e](r)})}var uP={name:"className",defaultValue:"",fn:function(e){var n=e.popper.firstElementChild,r=function(){var l;return!!((l=e.props.render)!=null&&l.$$tippy)};function i(){if(e.props.className&&!r()){process.env.NODE_ENV!=="production"&&console.warn(["@tippyjs/react: Cannot use `className` prop in conjunction with","`render` prop. Place the className on the element you are","rendering."].join(" "));return}e1(n,"add",e.props.className)}function s(){r()&&e1(n,"remove",e.props.className)}return{onCreate:i,onBeforeUpdate:s,onAfterUpdate:i}}};function dP(t){function e(n){var r=n.children,i=n.content,s=n.visible,o=n.singleton,l=n.render,a=n.reference,c=n.disabled,u=c===void 0?!1:c,d=n.ignoreAttributes,f=d===void 0?!0:d;n.__source,n.__self;var h=Yw(n,["children","content","visible","singleton","render","reference","disabled","ignoreAttributes","__source","__self"]),p=s!==void 0,g=o!==void 0,v=_.useState(!1),w=v[0],S=v[1],x=_.useState({}),y=x[0],C=x[1],E=_.useState(),T=E[0],D=E[1],N=cP(function(){return{container:Zw(),renders:1}}),A=Object.assign({ignoreAttributes:f},h,{content:N.container});p&&(process.env.NODE_ENV!=="production"&&["trigger","hideOnClick","showOnCreate"].forEach(function(z){A[z]!==void 0&&console.warn(["@tippyjs/react: Cannot specify `"+z+"` prop in","controlled mode (`visible` prop)"].join(" "))}),A.trigger="manual",A.hideOnClick=!1),g&&(u=!0);var R=A,P=A.plugins||[];l&&(R=Object.assign({},A,{plugins:g&&o.data!=null?[].concat(P,[{fn:function(){return{onTrigger:function(J,G){var ie=o.data.children.find(function(Z){var ke=Z.instance;return ke.reference===G.currentTarget});J.state.$$activeSingletonInstance=ie.instance,D(ie.content)}}}}]):P,render:function(){return{popper:N.container}}}));var B=[a].concat(r?[r.type]:[]);return Ah(function(){var z=a;a&&a.hasOwnProperty("current")&&(z=a.current);var U=t(z||N.ref||Zw(),Object.assign({},R,{plugins:[uP].concat(A.plugins||[])}));return N.instance=U,u&&U.disable(),s&&U.show(),g&&o.hook({instance:U,content:i,props:R,setSingletonContent:D}),S(!0),function(){U.destroy(),o==null||o.cleanup(U)}},B),Ah(function(){var z;if(N.renders===1){N.renders++;return}var U=N.instance;U.setProps(aP(U.props,R)),(z=U.popperInstance)==null||z.forceUpdate(),u?U.disable():U.enable(),p&&(s?U.show():U.hide()),g&&o.hook({instance:U,content:i,props:R,setSingletonContent:D})}),Ah(function(){var z;if(l){var U=N.instance;U.setProps({popperOptions:Object.assign({},U.props.popperOptions,{modifiers:[].concat((((z=U.props.popperOptions)==null?void 0:z.modifiers)||[]).filter(function(J){var G=J.name;return G!=="$$tippyReact"}),[{name:"$$tippyReact",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(G){var ie,Z=G.state,ke=(ie=Z.modifiersData)==null?void 0:ie.hide;(y.placement!==Z.placement||y.referenceHidden!==(ke==null?void 0:ke.isReferenceHidden)||y.escaped!==(ke==null?void 0:ke.hasPopperEscaped))&&C({placement:Z.placement,referenceHidden:ke==null?void 0:ke.isReferenceHidden,escaped:ke==null?void 0:ke.hasPopperEscaped}),Z.attributes.popper={}}}])})})}},[y.placement,y.referenceHidden,y.escaped].concat(B)),_.createElement(_.Fragment,null,r?_.cloneElement(r,{ref:function(U){N.ref=U,Th(r.ref,U)}}):null,w&&nn.createPortal(l?l(oP(y),T,N.instance):i,N.container))}return e}var fP=function(t,e){return _.forwardRef(function(r,i){var s=r.children,o=Yw(r,["children"]);return _.createElement(t,Object.assign({},e,o),s?_.cloneElement(s,{ref:function(a){Th(i,a),Th(s.ref,a)}}):null)})},hP=fP(dP(fi));const pP=[{name:"Add row above",action:t=>t.chain().focus().addRowBefore().run(),icon:O.jsx("svg",{viewBox:"0 0 24 24",children:O.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7h2v-2h4v2h2v-2h4v2h2v-2h4v2h2v-7M4 14h4v3H4v-3m6 0h4v3h-4v-3m10 0v3h-4v-3h4m-9-4h2V7h3V5h-3V2h-2v3H8v2h3v3Z"})})},{name:"Add row below",action:t=>t.chain().focus().addRowAfter().run(),icon:O.jsx("svg",{viewBox:"0 0 24 24",children:O.jsx("path",{fill:"currentColor",d:"M22 10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V3h2v2h4V3h2v2h4V3h2v2h4V3h2v7M4 10h4V7H4v3m6 0h4V7h-4v3m10 0V7h-4v3h4m-9 4h2v3h3v2h-3v3h-2v-3H8v-2h3v-3Z"})})},{name:"Add left column",action:t=>t.chain().focus().addColumnBefore().run(),icon:O.jsx("svg",{viewBox:"0 0 24 24",children:O.jsx("path",{fill:"currentColor",d:"M13 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h9V2h-9m7 8v4h-7v-4h7m0 6v4h-7v-4h7m0-12v4h-7V4h7M9 11H6V8H4v3H1v2h3v3h2v-3h3v-2Z"})})},{name:"Add right column",action:t=>t.chain().focus().addColumnAfter().run(),icon:O.jsx("svg",{viewBox:"0 0 24 24",children:O.jsx("path",{fill:"currentColor",d:"M11 2a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H2V2h9m-7 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m11 7h3V8h2v3h3v2h-3v3h-2v-3h-3v-2Z"})})},{name:"Remove row",action:t=>t.chain().focus().deleteRow().run(),icon:O.jsx("svg",{viewBox:"0 0 24 24",children:O.jsx("path",{fill:"currentColor",d:"M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41L9.41 13M22 9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3M4 9h4V6H4v3m6 0h4V6h-4v3m6 0h4V6h-4v3Z"})})},{name:"Remove column",action:t=>t.chain().focus().deleteColumn().run(),icon:O.jsx("svg",{viewBox:"0 0 24 24",children:O.jsx("path",{fill:"currentColor",d:"M4 2h7a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m13.59 8L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59L17.59 12Z"})})},{name:"Toggle header row",action:t=>t.chain().focus().toggleHeaderRow().run(),icon:O.jsx("svg",{viewBox:"0 0 24 24",children:O.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4M4 14h4v-4H4v4m6 0h4v-4h-4v4m6 0h4v-4h-4v4Z"})})},{name:"Toggle header column",action:t=>t.chain().focus().toggleHeaderColumn().run(),icon:O.jsx("svg",{viewBox:"0 0 24 24",children:O.jsx("path",{fill:"currentColor",d:"M8 2h8a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h8v-4H8m0 6v4h8v-4H8M8 4v4h8V4H8Z"})})},{name:"Toggle header cell",action:t=>t.chain().focus().toggleHeaderCell().run(),icon:O.jsx("svg",{viewBox:"0 0 24 24",children:O.jsx("path",{fill:"currentColor",d:"M21 19a1 1 0 0 1-1 1h-1v-2h2v1m-6 1v-2h2v2h-2m-4 0v-2h2v2h-2m-4 0v-2h2v2H7m-3 0a1 1 0 0 1-1-1v-1h2v2H4M19 4H5a2 2 0 0 0-2 2v2h18V6c0-1.11-.89-2-2-2M5 14H3v2h2v-2m0-4H3v2h2v-2m16 0h-2v2h2v-2m0 4h-2v2h2v-2m-10 2v-2h2v2h-2m0-4v-2h2v2h-2"})})},{name:"Remove table",action:t=>t.chain().focus().deleteTable().run(),icon:O.jsx("svg",{viewBox:"0 0 24 24",children:O.jsx("path",{fill:"currentColor",d:"M12.35 20H10v-3h2.09c.12-.72.37-1.39.72-2H10v-3h4v1.54c.58-.54 1.25-.93 2-1.19V12h4v.35c.75.26 1.42.65 2 1.19V5c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v15c0 1.1.9 2 2 2h9.54c-.54-.58-.93-1.25-1.19-2M16 7h4v3h-4V7m-6 0h4v3h-4V7M8 20H4v-3h4v3m0-5H4v-3h4v3m0-5H4V7h4v3m6.46 5.88l1.42-1.42L18 16.59l2.12-2.13l1.42 1.42L19.41 18l2.13 2.12l-1.42 1.42L18 19.41l-2.12 2.13l-1.42-1.42L16.59 18l-2.13-2.12"})})}],t1=({node:t,getPos:e,selected:n,editor:r})=>{const[i,s]=_.useState(!1),o=Yl(),l=_.useRef(null),a=()=>{const{from:u,to:d}=r.state.selection,f=e(),h=f+t.nodeSize;s(f<=u&&d<=h)};_.useEffect(()=>(r.on("selectionUpdate",a),setTimeout(a,100),()=>{r.off("selectionUpdate",a)}));const c=()=>{var f,h;let u=(f=l.current)==null?void 0:f.clientTop;u&&(u+=5);let d=(h=l.current)==null?void 0:h.clientLeft;return d&&(d+=5),{top:`${u}px`,left:`${d}px`}};return O.jsxs(wo,{className:"group",children:[O.jsx(ly,{as:"span"}),(i||n)&&O.jsx(hP,{appendTo:document.body,trigger:"click",interactive:!0,animation:"shift-toward-subtle",placement:"right-start",content:O.jsx("article",{className:"dropdown",contentEditable:!1,children:O.jsx("ul",{tabIndex:0,className:"dropdown-content fixed menu menu-compact p-2 shadow bg-base-100 rounded-box w-56",style:c(),children:pP.map(u=>O.jsx("li",{children:O.jsxs("button",{type:"button",className:"button",onClick:()=>u.action(r),children:[O.jsx("span",{children:u.icon}),O.jsx("span",{children:u.name})]})},u.name))})}),children:O.jsx("label",{tabIndex:0,className:Se("trigger-button",{hidden:o}),contentEditable:!1,children:O.jsx(dA,{fontSize:"small"})})})]})},mP=ze.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",Ce(this.options.HTMLAttributes,t),0]},addNodeView(){return hi(t1,{as:"td",className:"relative"})}}),gP=ze.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",Ce(this.options.HTMLAttributes,t),0]},addNodeView(){return hi(t1,{as:"th",className:"relative"})}}),n1=t=>(t.stopPropagation(),t.preventDefault(),t),yP=function(t){const e=t.scrollHeight>t.clientHeight,r=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!r},r1=function(t){return!t||t===document.body?document.body:yP(t)?t:r1(t.parentNode)},Mh=(t,e,n)=>{const r=document.createElement(t);if(!r)throw new Error(`Element with name ${t} can't be created.`);return e&&Object.entries(e).forEach(([i,s])=>r.setAttribute(i,s)),n&&Object.entries(n).forEach(([i,s])=>r.addEventListener(i,s)),r},bP=ze.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Ce(this.options.HTMLAttributes,t),0]},addNodeView(){return({editor:t,HTMLAttributes:e,getPos:n})=>{const r=()=>n(),i=r1(t.options.element);let s=!1;const o={deleteRow:()=>{this.editor.chain().deleteNode("tableRow").focus().run()},selectRow:()=>{const w=r(),S=t.state.doc.resolve(w),x=new se(S);t.view.dispatch(t.state.tr.setSelection(x))}},l=()=>{s=!0},a=()=>{s=!1},c=Mh("section",{class:"absolute hidden flex items-center w-2 bg-gray-200 z-50 cursor-pointer border-1 border-indigo-600 rounded-l opacity-25 hover:opacity-100",contenteditable:"false"},{click:w=>{w&&n1(w),o.selectRow()},mouseenter:()=>{l()},mouseover:()=>{l()},mouseleave:()=>{a(),f()}}),u=Mh("button",{class:"text-sm px-1 absolute -translate-x-[125%] hover:active:-translate-x-[125%] mr-2"},{click:w=>{w&&n1(w),o.deleteRow()}}),d=()=>{g(),c.classList.remove("hidden")},f=()=>{setTimeout(()=>{s||c.classList.add("hidden")},100)},h=Mh("tr",{...e},{mouseenter:d,mouseover:d,mouseleave:f});c.append(u),document.body.append(c);let p="";const g=()=>{setTimeout(()=>{const w=h.getBoundingClientRect(),S=JSON.stringify(w);p!==S&&(c.style.top=`${w.top+document.documentElement.scrollTop}px`,c.style.left=`${w.x+document.documentElement.scrollLeft-8}px`,c.style.height=`${w.height+1}px`,p=S)})};return setTimeout(()=>{g()},100),t.on("selectionUpdate",g),t.on("update",g),i==null||i.addEventListener("scroll",g),document.addEventListener("scroll",g),{dom:h,contentDOM:h,destroy:()=>{c.remove(),t.off("selectionUpdate",g),t.off("update",g),i==null||i.removeEventListener("scroll",g),document.removeEventListener("scroll",g)}}}}}),vP=[sP.configure({resizable:!0}),mP,gP,bP],wP=Xb.extend({content:"(dBlock|columns)+"});function i1({types:t,node:e}){return e!=null&&e.type?Array.isArray(t)&&t.includes(e.type)||e.type===t:!1}const xP=Ue.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const t=new We(this.name),e=Object.entries(this.editor.schema.nodes).map(([,n])=>n).filter(n=>this.options.notAfter.includes(n.name));return[new je({key:t,appendTransaction:(n,r,i)=>{const{doc:s,tr:o,schema:l}=i,a=t.getState(i),c=s.content.size,u=l.nodes[this.options.node];if(a)return o.insert(c,u.create())},state:{init:(n,r)=>{const i=r.tr.doc.lastChild;return!i1({node:i,types:e})},apply:(n,r)=>{var s,o,l;if(!n.docChanged)return r;const i=(l=(o=(s=n.doc.lastChild)==null?void 0:s.content)==null?void 0:o.content)==null?void 0:l[0];return!i1({node:i,types:e})}}})]}}),kP=({node:t,editor:e,getPos:n})=>{const[r,i]=_.useState(""),s=Yl(),o=["https://twitter.com","https://x.com"],l=()=>{switch(t.attrs.data){case"twitter":return O.jsx(xy,{});case"iframe":return O.jsx(Cy,{});default:return O.jsx(SA,{})}},a=()=>{switch(t.attrs.data){case"twitter":return"Embed a Twitter tweet";case"iframe":return"Embed a video";default:return"Embed an URL"}},c=()=>{if(!r){alert("Please enter a url");return}let p=r;if(r.includes("<iframe")){const x=r.match(/src="([^"]*)"/);x&&x.length>0&&(p=x[1])}else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(r):{const x=r.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);x&&x.length>0&&(p=`https://www.youtube.com/embed/${x[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(r):{const x=r.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);x&&x.length>0&&(p=`https://player.vimeo.com/video/${x[1]}`);break}default:{alert("Please enter a valid url");return}}const g=640,v=360,w=n(),S=w+t.nodeSize;p&&(e==null||e.chain().focus(w).deleteRange({from:w,to:S}).setIframe({src:p,width:g,height:v}).run())},u=()=>{if(!r){alert("Please enter a url");return}let p=r;const g=o.some(y=>r.includes(y)),v=r.match(/\/status\/([0-9]*)/),w=v&&v.length>0;if(g&&w)p=v[1];else{alert("invalid url");return}const S=n(),x=S+t.nodeSize;p&&(e==null||e.chain().focus(S).deleteRange({from:S,to:x}).setTweetEmbed({tweetId:p}).run())},f=Av(()=>{switch(t.attrs.data){case"twitter":u();break;default:c();break}},500);_.useEffect(()=>{r&&f()},[r]),_.useEffect(()=>{e==null||e.chain().focus()},[]);const h=_.useRef(null);return _.useEffect(()=>{var p;(p=h.current)==null||p.focus()},[]),O.jsx(wo,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:!s&&O.jsxs("div",{className:"relative w-full",children:[O.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:l()}),O.jsx("input",{ref:h,value:r,placeholder:a(),onChange:p=>i(p.target.value),onClick:p=>p.stopPropagation(),className:"bg-stone-200 p-3 pl-10 rounded-xl w-full hover:bg-stone-300 cursor-pointer transition-all ease-in-out"})]})})},CP=ze.create({name:"actionButton",group:"block",content:"block*",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:"rounded-lg bg-stone-500"}}},addAttributes(){return{data:{default:null}}},addNodeView(){return hi(kP)},parseHTML(){return[{tag:"div[data-action-node]"}]},renderHTML({HTMLAttributes:t}){return console.log("action"),["div",Ce(t,{"data-action-node":""}),0]},addCommands(){return{setActionButton:t=>({commands:e})=>e.insertContent({type:this.name,attrs:{data:t},content:[]})}}}),SP=[pN,fN.configure({strike:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bold:{HTMLAttributes:{class:"select-text pointer-events-auto"}},italic:{HTMLAttributes:{class:"select-text pointer-events-auto"}},heading:{HTMLAttributes:{class:"select-text pointer-events-auto"}},paragraph:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bulletList:{HTMLAttributes:{class:"flex flex-col items-start list-disc list-outside space-y-4 ml-6"}},orderedList:{HTMLAttributes:{class:"flex flex-col items-start list-decimal list-outside space-y-4 ml-6"}},listItem:{HTMLAttributes:{class:"leading-normal"}},blockquote:{HTMLAttributes:{class:"rounded-lg bg-stone-100 p-5 font-serif italic text-stone-800"}},codeBlock:{HTMLAttributes:{class:"rounded-lg bg-transparent border border-[#DDE2E4] p-5 font-mono font-medium text-stone-800"}},code:{HTMLAttributes:{class:"rounded-md bg-stone-200 p-1.5 font-mono font-medium text-black text-sm",spellcheck:"false"}},history:!1,gapcursor:!1,dropcursor:!1,document:!1,horizontalRule:!1}),mN.configure({types:["heading","paragraph"]}),nD,$N.configure({HTMLAttributes:{class:"text-blue-500 font-bold transition-colors cursor-pointer select-text pointer-events-auto"},openOnClick:!0}),BN.configure({placeholder:()=>"",includeChildren:!0,showOnlyCurrent:!0}),zN.configure({multicolor:!0}),tD,qN.configure({HTMLAttributes:{class:"select-text pointer-events-auto"}}),hN,sD,VN.configure({HTMLAttributes:{class:"not-prose space-y-4 ml-2"}}),WN.configure({HTMLAttributes:{class:"flex items-start"},nested:!0}),Zb.configure({width:3,color:"#d1d5db"}),Qb,iI,xP,wP,...vP,pD.configure({uploadFn:RA}),iD,oD,uD,CP.extend({addInputRules(){return[s1(/^(?:twt|###|___\s|\*\*\*\s)$/,"twitter",this.type),s1(/^(?:ytb|@@@|___\s|\*\*\*\s)$/,"iframe",this.type)]}}),rD],s1=(t,e,n)=>new oo({find:t,handler:({state:r,range:i,commands:s})=>{const o={data:e},{tr:l}=r,a=i.from,c=i.to;l.insert(a-1,n.create(o)).delete(l.mapping.map(a),l.mapping.map(c)),s.focus(c-1)}}),Ni=t=>ss((e,n)=>{t.onerror=r=>n(new Error(r.target.error)),t.onsuccess=r=>e(r.target.result)}),EP=(t,e)=>ss((n,r)=>{const i=indexedDB.open(t);i.onupgradeneeded=s=>e(s.target.result),i.onerror=s=>r(xn(s.target.error)),i.onsuccess=s=>{const o=s.target.result;o.onversionchange=()=>{o.close()},n(o)}}),TP=t=>Ni(indexedDB.deleteDatabase(t)),AP=(t,e)=>e.forEach(n=>t.createObjectStore.apply(t,n)),nl=(t,e,n="readwrite")=>{const r=t.transaction(e,n);return e.map(i=>IP(r,i))},o1=(t,e)=>Ni(t.count(e)),MP=(t,e)=>Ni(t.get(e)),l1=(t,e)=>Ni(t.delete(e)),OP=(t,e,n)=>Ni(t.put(e,n)),Oh=(t,e)=>Ni(t.add(e)),_P=(t,e,n)=>Ni(t.getAll(e,n)),NP=(t,e,n)=>{let r=null;return LP(t,e,i=>(r=i,!1),n).then(()=>r)},DP=(t,e=null)=>NP(t,e,"prev"),RP=(t,e)=>ss((n,r)=>{t.onerror=r,t.onsuccess=async i=>{const s=i.target.result;if(s===null||await e(s)===!1)return n();s.continue()}}),LP=(t,e,n,r="next")=>RP(t.openKeyCursor(e,r),i=>n(i.key)),IP=(t,e)=>t.objectStore(e),PP=(t,e)=>IDBKeyRange.upperBound(t,e),FP=(t,e)=>IDBKeyRange.lowerBound(t,e),_h="custom",a1="updates",c1=500,u1=(t,e=()=>{},n=()=>{})=>{const[r]=nl(t.db,[a1]);return _P(r,FP(t._dbref,!1)).then(i=>{t._destroyed||(e(r),Fe(t.doc,()=>{i.forEach(s=>L0(t.doc,s))},t,!1),n(r))}).then(()=>DP(r).then(i=>{t._dbref=i+1})).then(()=>o1(r).then(i=>{t._dbsize=i})).then(()=>r)},$P=(t,e=!0)=>u1(t).then(n=>{(e||t._dbsize>=c1)&&Oh(n,Yd(t.doc)).then(()=>l1(n,PP(t._dbref,!0))).then(()=>o1(n).then(r=>{t._dbsize=r}))});class BP extends xd{constructor(e,n){super(),this.doc=n,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=EP(e,r=>AP(r,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=ss(r=>this.on("synced",()=>r(this))),this._db.then(r=>{this.db=r,u1(this,o=>Oh(o,Yd(n)),()=>{if(this._destroyed)return this;this.synced=!0,this.emit("synced",[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(r,i)=>{if(this.db&&i!==this){const[s]=nl(this.db,[a1]);Oh(s,r),++this._dbsize>=c1&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{$P(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},n.on("update",this._storeUpdate),this.destroy=this.destroy.bind(this),n.on("destroy",this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off("update",this._storeUpdate),this.doc.off("destroy",this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{TP(this.name)})}get(e){return this._db.then(n=>{const[r]=nl(n,[_h],"readonly");return MP(r,e)})}set(e,n){return this._db.then(r=>{const[i]=nl(r,[_h]);return OP(i,n,e)})}del(e){return this._db.then(n=>{const[r]=nl(n,[_h]);return l1(r,e)})}}const d1=["#30bced","#6eeb83","#fa69d1","#ecd444","#ee6352","#db3041","#0ad7f2","#1bff39"],jP=({isPreviewMode:t,data:e,enableCollaboration:n,collaborationId:r})=>{const[i,s]=_.useState({plugin:{title:"Untitled"}}),[o]=_.useState(new us),[l,a]=_.useState(!1),[c,u]=_.useState([...SP]),d=ny({extensions:c,editorProps:Bb,autofocus:"start"},[c]),f=ny({extensions:c,editorProps:Bb,autofocus:"start"}),h=w=>{if(!n||!r||!w)throw new Error("docId or username is not provided");a(!0);const S=new VO(r,o,{signaling:["wss://fileverse-signaling-server-0529292ff51c.herokuapp.com/"]});u([...c,m_.configure({document:o}),g_.configure({provider:S,user:{name:w,color:d1[Math.floor(Math.random()*d1.length)]}})]);const x=setTimeout(()=>{a(!1)},100);return()=>{clearTimeout(x),S.destroy(),o.destroy(),a(!1)}};_.useEffect(()=>{r&&new BP(r,o)},[r]);const p=_.useRef(null),g=_.useMemo(()=>n&&r&&d&&!l?d:f,[d,f,l]),v=w=>{var S;(S=p.current)!=null&&S.contains(w.target)||g==null||g.chain().focus().run()};return _.useEffect(()=>{g==null||g.chain().focus()},[]),_.useEffect(()=>{g==null||g.setEditable(!t)},[t]),_.useEffect(()=>{e&&g&&(g==null||g.commands.setContent(e.editorJSONData),s(e.metaData))},[e,g]),{editor:g,pluginMetaData:i,setPluginMetaData:s,focusEditor:v,ref:p,loading:l,connect:h}},HP=({isPreviewMode:t=!1,onPublish:e,data:n,togglePreviewMode:r,enableCollaboration:i,collaborationId:s,username:o,onAutoSave:l})=>{const{editor:a,pluginMetaData:c,focusEditor:u,setPluginMetaData:d,ref:f,loading:h,connect:p}=jP({isPreviewMode:t,data:n,enableCollaboration:i,collaborationId:s,onPublish:e,togglePreviewMode:r});return _.useEffect(()=>{i&&o&&p(o)},[i]),_.useEffect(()=>{if(a&&l){const g=setInterval(()=>{l({metaData:c,editorJSONData:a.getJSON()})},1e4);return()=>clearInterval(g)}},[a,l,c]),!a||h?O.jsxs("div",{className:"w-screen h-screen flex flex-col gap-4 justify-center items-center",children:[O.jsx(Hy,{}),O.jsx("p",{children:"Loading Editor..."})]}):O.jsx("div",{"data-cy":"single-webpage",className:"bg-[#f8f9fa]",children:O.jsx("div",{className:"h-full flex flex-col overflow-scroll no-scrollbar",children:O.jsxs("div",{className:"w-full h-screen",children:[O.jsx("div",{className:"h-fit relative bg-[#f8f9fa]",children:O.jsxs("div",{className:"flex items-center justify-center pl-4 pr-4 gap-2 h-16",children:[O.jsx("div",{className:"grow",children:O.jsx(b1,{isPreviewMode:t,metaData:c,setMetaData:d})}),!t&&O.jsx("div",{className:"grow relative",children:O.jsx(KA,{editor:a})}),O.jsx("div",{children:O.jsxs(Gl,{variant:"secondary",onClick:()=>r(t),children:[t?O.jsx(bA,{size:14}):O.jsx(xA,{size:14})," ",t?"Edit":"Preview"]})}),e&&O.jsx("div",{children:O.jsxs(Gl,{onClick:()=>e({metaData:c,editorJSONData:a.getJSON()}),children:[O.jsx(kA,{size:14})," Share"]})})]})}),O.jsx("main",{className:"h-screen lg:h-full w-full rounded-[8px] flex flex-col justify-start items-center gap-2",children:O.jsx("div",{onClick:u,className:"w-full flex justify-center relative",children:O.jsx("div",{className:"p-12 sm:p-[96px] mt-4 min-h-[900px] bg-white overflow-scroll no-scrollbar w-full sm:w-[70%] max-w-[856px]",children:O.jsxs("div",{ref:f,className:"w-full pt-4 h-full",children:[!t&&O.jsxs("div",{children:[O.jsx($A,{editor:a}),O.jsx(WA,{editor:a,appendTo:f})]}),O.jsx(qA,{isPreviewMode:t,children:O.jsx(GT,{editor:a})})]})})})})]})})})};$t.DdocEditor=HP,Object.defineProperty($t,Symbol.toStringTag,{value:"Module"})});
|
423
|
+
`)},PL=0,Ds=[];function FL(t){var e=le.useRef([]),n=le.useRef([0,0]),r=le.useRef(),i=le.useState(PL++)[0],s=le.useState(function(){return gw()})[0],o=le.useRef(t);le.useEffect(function(){o.current=t},[t]),le.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(i));var g=iL([t.lockRef.current],(t.shards||[]).map(Cw),!0).filter(Boolean);return g.forEach(function(v){return v.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),g.forEach(function(v){return v.classList.remove("allow-interactivity-".concat(i))})}}},[t.inert,t.lockRef.current,t.shards]);var l=le.useCallback(function(g,v){if("touches"in g&&g.touches.length===2)return!o.current.allowPinchZoom;var w=Ac(g),S=n.current,x="deltaX"in g?g.deltaX:S[0]-w[0],y="deltaY"in g?g.deltaY:S[1]-w[1],C,E=g.target,T=Math.abs(x)>Math.abs(y)?"h":"v";if("touches"in g&&T==="h"&&E.type==="range")return!1;var D=vw(T,E);if(!D)return!0;if(D?C=T:(C=T==="v"?"h":"v",D=vw(T,E)),!D)return!1;if(!r.current&&"changedTouches"in g&&(x||y)&&(r.current=C),!C)return!0;var N=r.current||C;return RL(N,v,g,N==="h"?x:y,!0)},[]),a=le.useCallback(function(g){var v=g;if(!(!Ds.length||Ds[Ds.length-1]!==s)){var w="deltaY"in v?kw(v):Ac(v),S=e.current.filter(function(C){return C.name===v.type&&C.target===v.target&&LL(C.delta,w)})[0];if(S&&S.should){v.cancelable&&v.preventDefault();return}if(!S){var x=(o.current.shards||[]).map(Cw).filter(Boolean).filter(function(C){return C.contains(v.target)}),y=x.length>0?l(v,x[0]):!o.current.noIsolation;y&&v.cancelable&&v.preventDefault()}}},[]),c=le.useCallback(function(g,v,w,S){var x={name:g,delta:v,target:w,should:S};e.current.push(x),setTimeout(function(){e.current=e.current.filter(function(y){return y!==x})},1)},[]),u=le.useCallback(function(g){n.current=Ac(g),r.current=void 0},[]),d=le.useCallback(function(g){c(g.type,kw(g),g.target,l(g,t.lockRef.current))},[]),f=le.useCallback(function(g){c(g.type,Ac(g),g.target,l(g,t.lockRef.current))},[]);le.useEffect(function(){return Ds.push(s),t.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",a,Ns),document.addEventListener("touchmove",a,Ns),document.addEventListener("touchstart",u,Ns),function(){Ds=Ds.filter(function(g){return g!==s}),document.removeEventListener("wheel",a,Ns),document.removeEventListener("touchmove",a,Ns),document.removeEventListener("touchstart",u,Ns)}},[]);var h=t.removeScrollBar,p=t.inert;return le.createElement(le.Fragment,null,p?le.createElement(s,{styles:IL(i)}):null,h?le.createElement(TL,{gapMode:"margin"}):null)}const $L=hL(mw,FL);var Sw=le.forwardRef(function(t,e){return le.createElement(Ec,Xn({},t,{ref:e,sideCar:$L}))});Sw.classNames=Ec.classNames;const Ew="Popover",[Tw,bF]=Ov(Ew,[sw]),gh=sw(),[BL,Rs]=Tw(Ew),jL=t=>{const{__scopePopover:e,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:o=!1}=t,l=gh(e),a=O.useRef(null),[c,u]=O.useState(!1),[d=!1,f]=ZR({prop:r,defaultProp:i,onChange:s});return O.createElement(KR,l,O.createElement(BL,{scope:e,contentId:ID(),triggerRef:a,open:d,onOpenChange:f,onOpenToggle:O.useCallback(()=>f(h=>!h),[f]),hasCustomAnchor:c,onCustomAnchorAdd:O.useCallback(()=>u(!0),[]),onCustomAnchorRemove:O.useCallback(()=>u(!1),[]),modal:o},n))},HL="PopoverTrigger",zL=O.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,i=Rs(HL,n),s=gh(n),o=Ai(e,i.triggerRef),l=O.createElement(Mi.button,dt({type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.contentId,"data-state":Mw(i.open)},r,{ref:o,onClick:Ur(t.onClick,i.onOpenToggle)}));return i.hasCustomAnchor?l:O.createElement(JR,dt({asChild:!0},s),l)}),VL="PopoverPortal",[vF,UL]=Tw(VL,{forceMount:void 0}),Qo="PopoverContent",WL=O.forwardRef((t,e)=>{const n=UL(Qo,t.__scopePopover),{forceMount:r=n.forceMount,...i}=t,s=Rs(Qo,t.__scopePopover);return O.createElement(uw,{present:r||s.open},s.modal?O.createElement(qL,dt({},i,{ref:e})):O.createElement(KL,dt({},i,{ref:e})))}),qL=O.forwardRef((t,e)=>{const n=Rs(Qo,t.__scopePopover),r=O.useRef(null),i=Ai(e,r),s=O.useRef(!1);return O.useEffect(()=>{const o=r.current;if(o)return rL(o)},[]),O.createElement(Sw,{as:Gf,allowPinchZoom:!0},O.createElement(Aw,dt({},t,{ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ur(t.onCloseAutoFocus,o=>{var l;o.preventDefault(),s.current||(l=n.triggerRef.current)===null||l===void 0||l.focus()}),onPointerDownOutside:Ur(t.onPointerDownOutside,o=>{const l=o.detail.originalEvent,a=l.button===0&&l.ctrlKey===!0,c=l.button===2||a;s.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:Ur(t.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})))}),KL=O.forwardRef((t,e)=>{const n=Rs(Qo,t.__scopePopover),r=O.useRef(!1),i=O.useRef(!1);return O.createElement(Aw,dt({},t,{ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o;if((o=t.onCloseAutoFocus)===null||o===void 0||o.call(t,s),!s.defaultPrevented){var l;r.current||(l=n.triggerRef.current)===null||l===void 0||l.focus(),s.preventDefault()}r.current=!1,i.current=!1},onInteractOutside:s=>{var o,l;(o=t.onInteractOutside)===null||o===void 0||o.call(t,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=s.target;((l=n.triggerRef.current)===null||l===void 0?void 0:l.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}}))}),Aw=O.forwardRef((t,e)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onInteractOutside:u,...d}=t,f=Rs(Qo,n),h=gh(n);return ED(),O.createElement(TD,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s},O.createElement(kD,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onDismiss:()=>f.onOpenChange(!1)},O.createElement(GR,dt({"data-state":Mw(f.open),role:"dialog",id:f.contentId},h,d,{ref:e,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}}))))}),JL="PopoverClose",GL=O.forwardRef((t,e)=>{const{__scopePopover:n,...r}=t,i=Rs(JL,n);return O.createElement(Mi.button,dt({type:"button"},r,{ref:e,onClick:Ur(t.onClick,()=>i.onOpenChange(!1))}))});function Mw(t){return t?"open":"closed"}const YL=jL,XL=zL,ZL=WL,Mc=GL,Oc=({children:t,isActive:e,onClick:n,disabled:r,className:i})=>{const s=Se("flex items-center gap-2 p-1.5 text-xs font-medium text-neutral-500 text-left w-full rounded-md border border-transparent transition-all",!e&&!r,"hover:border-neutral-200 hover:bg-neutral-100",e&&!r&&"bg-neutral-200 text-neutral-800",r&&"text-neutral-300 cursor-not-allowed",i);return _.jsx("button",{className:s,disabled:r,onClick:n,children:t})},QL=(t,e,n)=>{const r=O.useCallback(()=>{const l=t.chain();l.setNodeSelection(n).unsetAllMarks(),(e==null?void 0:e.type.name)!=="paragraph"&&l.setParagraph(),l.run()},[t,n,e==null?void 0:e.type.name]),i=O.useCallback(()=>{t.commands.setNodeSelection(n);const{$anchor:l}=t.state.selection,a=l.node(1)||t.state.selection.node;t.chain().setMeta("hideDragHandle",!0).insertContentAt(n+((e==null?void 0:e.nodeSize)||0),a.toJSON()).run()},[t,n,e==null?void 0:e.nodeSize]),s=O.useCallback(()=>{t.chain().setMeta("hideDragHandle",!0).setNodeSelection(n).run(),document.execCommand("copy"),alert("copied")},[t,n]),o=O.useCallback(()=>{t.chain().setMeta("hideDragHandle",!0).setNodeSelection(n).deleteSelection().run()},[t,n]);return{resetTextFormatting:r,duplicateNode:i,copyNodeToClipboard:s,deleteNode:o}},eI=({node:t,getPos:e,editor:n,deleteNode:r})=>{const[i,s]=O.useState(!1),o=QL(n,t,e()),l=Gl(),a=["https://twitter.com","https://x.com"],c=O.useMemo(()=>{const{content:N}=t.content;return N[0].type.name==="table"},[t.content]),u=O.useMemo(()=>{var A;const{content:N}=t.content;return(A=N[0].content.content[0])==null?void 0:A.text},[t.content]),d=O.useMemo(()=>{var A;const{content:N}=t.content;return(A=N[0].content.content[1])==null?void 0:A.text},[t.content]),f=O.useMemo(()=>{const{content:N}=t.content;return N[0].content.content.find(A=>{var R;return(R=A==null?void 0:A.text)==null?void 0:R.match(/\/status\/([0-9]*)/)})},[t.content]),h=()=>{if(!u)return;let N=u;if(u.includes("<iframe"))N=d;else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(u):{const z=u.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);z&&z.length>0&&(N=`https://www.youtube.com/embed/${z[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(u):{const z=u.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);z&&z.length>0&&(N=`https://player.vimeo.com/video/${z[1]}`);break}default:return}const A=640,R=360,P=e(),B=P+t.nodeSize;N&&(n==null||n.chain().focus(P).deleteRange({from:P===0?P:P+1,to:B}).setIframe({src:N,width:A,height:R}).run())},p=N=>{const A=N.match(/\/status\/([0-9]*)/);return A&&A.length>0?A[1]:null},g=()=>{if(!u)return;let N=u;const A=a.some(z=>u.includes(z)),R=p(u);A&&R?N=R:f&&(N=p(f.text));const P=e(),B=P+t.nodeSize;N&&(n==null||n.chain().focus(P).deleteRange({from:P===2?P:P+1,to:B}).setTweetEmbed({tweetId:N}).run())},v=()=>{const N=e()+t.nodeSize;n.commands.insertContentAt(N,{type:"dBlock",content:[{type:"paragraph"}]})},w=()=>{const N=e();n.commands.insertContentAt(N,{type:"dBlock",content:[{type:"paragraph"}]})},S=()=>{r()},x=N=>{N.altKey?C():y()},y=()=>{v()},C=()=>{w()},E=N=>{N.altKey&&S()},D=Av(()=>{if(a.some(N=>u.includes(N))||f!=null&&f.text){g();return}else{h();return}},1e3);return O.useEffect(()=>{u&&D()},[u]),_.jsxs(wo,{as:"div",className:Se("flex gap-2 group w-full relative justify-center items-start",l&&"pointer-events-none",c&&"2xl:ml-4 pointer-events-auto"),children:[_.jsxs("section",{className:"lg:flex gap-1 hidden","aria-label":"left-menu",contentEditable:!1,children:[_.jsx(Py,{content:_.jsxs("div",{className:"flex flex-col w-40",children:[_.jsx("div",{className:"text-xs",children:"Click to add below"}),_.jsx("div",{className:"text-xs",children:"Opt + Click to add above"})]}),children:_.jsx("div",{className:`d-block-button cursor-pointer ${!l&&"group-hover:opacity-100"}`,contentEditable:!1,onClick:x,children:_.jsx(bA,{size:18})})}),_.jsxs(YL,{open:i,onOpenChange:s,children:[_.jsx(XL,{asChild:!0,children:_.jsx("div",{className:`d-block-button cursor-pointer ${!l&&"group-hover:opacity-100"}`,contentEditable:!1,draggable:!0,"data-drag-handle":!0,onClick:E,children:_.jsx(fA,{size:18})})}),_.jsx(ZL,{side:"bottom",align:"start",sideOffset:8,className:"z-10",children:_.jsxs(md,{className:"p-2 flex flex-col min-w-[16rem]",children:[_.jsx(Mc,{children:_.jsxs(Oc,{onClick:o.resetTextFormatting,children:[_.jsx(vA,{size:18}),"Clear formatting"]})}),_.jsx(Mc,{children:_.jsxs(Oc,{onClick:o.copyNodeToClipboard,children:[_.jsx(aA,{size:18}),"Copy to clipboard"]})}),_.jsx(Mc,{children:_.jsxs(Oc,{onClick:o.duplicateNode,children:[_.jsx(uA,{size:18}),"Duplicate"]})}),_.jsx(ko.Divider,{horizontal:!0}),_.jsx(Mc,{children:_.jsxs(Oc,{onClick:o.deleteNode,className:"text-red-500 hover:bg-red-500 bg-opacity-10 hover:bg-opacity-20",children:[_.jsx(kA,{size:18}),"Delete"]})})]})})]})]}),_.jsx(oy,{className:Se("node-view-content w-full",{"is-table min-w-auto":c})})]})},tI=ze.create({name:"dBlock",priority:1e3,group:"dBlock",content:"(block|columns)",draggable:!0,selectable:!1,inline:!1,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:'div[data-type="d-block"]'}]},renderHTML({HTMLAttributes:t}){return["div",Ce(t,{"data-type":"d-block"}),0]},addCommands(){return{setDBlock:t=>({state:e,chain:n})=>{const{selection:{from:r}}=e,i=t!==void 0||t!==null?r:t;return n().insertContentAt(i,{type:this.name,content:[{type:"paragraph"}]}).focus(i+2).run()},mergeDBlocksIntoList:t=>({state:e,dispatch:n})=>{if(!n)throw new Error("Dispatch function is not provided.");const{from:r,to:i}=e.selection;let s=e.tr;const o=[];if(e.doc.nodesBetween(r,i,a=>{if(a.type.name===this.name){const c=e.schema.nodes.listItem.create(null,a.content);c&&o.push(c)}}),o.length===0)return!1;const l=e.schema.nodes[t].create(null,o);return l?(s=s.replaceRangeWith(r,i,l),n(s),!0):!1},splitListToDBlocks:t=>({state:e,dispatch:n})=>{if(!n)throw new Error("Dispatch function is not provided.");const{from:r,to:i}=e.selection;let s=e.tr;return e.doc.nodesBetween(r,i,(o,l)=>{if(o.type.name===t){const a=e.schema.nodes[this.name].create(null,o.content);s=s.insert(l,a)}}),n(s),!0}}},addNodeView(){return hi(eI)},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setDBlock(),Enter:({editor:t})=>{var c;const{selection:{$head:e,from:n,to:r},doc:i}=t.state,s=e.node(e.depth-1);if((s==null?void 0:s.type.name)!=="dBlock")return!1;let o=-1,l="";i.descendants((u,d)=>{if(o!==-1)return!1;if(u.type.name===this.name)return;const[f,h]=[d,d+u.nodeSize];return f<=n&&r<=h&&(o=h,l=u.type.name),!1});const a=(c=i.slice(n,o))==null?void 0:c.toJSON().content;try{return l==="codeBlock"?t.chain().insertContentAt({from:n,to:o},`
|
424
|
+
`).focus(o+1).run():["columns","heading"].includes(l)?t.chain().insertContent({type:"dBlock",content:[{type:"paragraph"}]}).focus().run():t.chain().insertContentAt({from:n,to:o},{type:this.name,content:a}).focus(n+4).run()}catch(u){return console.error(`Error inserting content into dBlock node: ${u}`),!1}}}}});let yh,bh;if(typeof WeakMap<"u"){let t=new WeakMap;yh=e=>t.get(e),bh=(e,n)=>(t.set(e,n),n)}else{let t=[],e=10,n=0;yh=r=>{for(let i=0;i<t.length;i+=2)if(t[i]==r)return t[i+1]},bh=(r,i)=>(n==e&&(n=0),t[n++]=r,t[n++]=i)}class Ls{constructor(e,n,r,i){this.left=e,this.top=n,this.right=r,this.bottom=i}}class et{constructor(e,n,r,i){this.width=e,this.height=n,this.map=r,this.problems=i}findCell(e){for(let n=0;n<this.map.length;n++){let r=this.map[n];if(r!=e)continue;let i=n%this.width,s=n/this.width|0,o=i+1,l=s+1;for(let a=1;o<this.width&&this.map[n+a]==r;a++)o++;for(let a=1;l<this.height&&this.map[n+this.width*a]==r;a++)l++;return new Ls(i,s,o,l)}throw new RangeError("No cell with offset "+e+" found")}colCount(e){for(let n=0;n<this.map.length;n++)if(this.map[n]==e)return n%this.width;throw new RangeError("No cell with offset "+e+" found")}nextCell(e,n,r){let{left:i,right:s,top:o,bottom:l}=this.findCell(e);return n=="horiz"?(r<0?i==0:s==this.width)?null:this.map[o*this.width+(r<0?i-1:s)]:(r<0?o==0:l==this.height)?null:this.map[i+this.width*(r<0?o-1:l)]}rectBetween(e,n){let{left:r,right:i,top:s,bottom:o}=this.findCell(e),{left:l,right:a,top:c,bottom:u}=this.findCell(n);return new Ls(Math.min(r,l),Math.min(s,c),Math.max(i,a),Math.max(o,u))}cellsInRect(e){let n=[],r={};for(let i=e.top;i<e.bottom;i++)for(let s=e.left;s<e.right;s++){let o=i*this.width+s,l=this.map[o];r[l]||(r[l]=!0,(s!=e.left||!s||this.map[o-1]!=l)&&(i!=e.top||!i||this.map[o-this.width]!=l)&&n.push(l))}return n}positionAt(e,n,r){for(let i=0,s=0;;i++){let o=s+r.child(i).nodeSize;if(i==e){let l=n+e*this.width,a=(e+1)*this.width;for(;l<a&&this.map[l]<s;)l++;return l==a?o-1:this.map[l]}s=o}}static get(e){return yh(e)||bh(e,nI(e))}}function nI(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);let e=rI(t),n=t.childCount,r=[],i=0,s=null,o=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){let d=t.child(c);u++;for(let p=0;;p++){for(;i<r.length&&r[i]!=0;)i++;if(p==d.childCount)break;let g=d.child(p),{colspan:v,rowspan:w,colwidth:S}=g.attrs;for(let x=0;x<w;x++){if(x+c>=n){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:w-x});break}let y=i+x*e;for(let C=0;C<v;C++){r[y+C]==0?r[y+C]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:v-C});let E=S&&S[C];if(E){let T=(y+C)%e*2,D=o[T];D==null||D!=E&&o[T+1]==1?(o[T]=E,o[T+1]=1):D==E&&o[T+1]++}}}i+=v,u+=g.nodeSize}let f=(c+1)*e,h=0;for(;i<f;)r[i++]==0&&h++;h&&(s||(s=[])).push({type:"missing",row:c,n:h}),u++}let l=new et(e,n,r,s),a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<n&&(a=!0);return a&&iI(l,o,t),l}function rI(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){let i=t.child(r),s=0;if(n)for(let o=0;o<r;o++){let l=t.child(o);for(let a=0;a<l.childCount;a++){let c=l.child(a);o+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let o=0;o<i.childCount;o++){let l=i.child(o);s+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function iI(t,e,n){t.problems||(t.problems=[]);for(let r=0,i={};r<t.map.length;r++){let s=t.map[r];if(i[s])continue;i[s]=!0;let o=n.nodeAt(s),l=null;for(let a=0;a<o.attrs.colspan;a++){let c=(r+a)%t.width,u=e[c*2];u!=null&&(!o.attrs.colwidth||o.attrs.colwidth[a]!=u)&&((l||(l=sI(o.attrs)))[a]=u)}l&&t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function sI(t){if(t.colwidth)return t.colwidth.slice();let e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Mt(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(let n in t.nodes){let r=t.nodes[n],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const Gr=new We("selectingCells");function Is(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 oI(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 An(t){let 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 _c(t){let e=t.selection;return e.$anchorCell?e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell:e.node&&e.node.type.spec.tableRole=="cell"?e.$anchor:Is(e.$head)||lI(e.$head)}function lI(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){let 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--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function vh(t){return t.parent.type.spec.tableRole=="row"&&t.nodeAfter}function aI(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function wh(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Ow(t,e,n){let r=t.start(-1),s=et.get(t.node(-1)).nextCell(t.pos-r,e,n);return s==null?null:t.node(0).resolve(r+s)}function wt(t,e,n){let r={};for(let i in t)r[i]=t[i];return r[e]=n,r}function _i(t,e,n=1){let r=wt(t,"colspan",t.colspan-n);return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function _w(t,e,n=1){let r=wt(t,"colspan",t.colspan+n);if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<n;i++)r.colwidth.splice(e,0,0)}return r}function cI(t,e,n){let r=Mt(e.type.schema).header_cell;for(let i=0;i<t.height;i++)if(e.nodeAt(t.map[n+i*t.width]).type!=r)return!1;return!0}class Ae extends ue{constructor(e,n=e){let r=e.node(-1),i=et.get(r),s=e.start(-1),o=i.rectBetween(e.pos-s,n.pos-s),l=e.node(0),a=i.cellsInRect(o).filter(u=>u!=n.pos-s);a.unshift(n.pos-s);let c=a.map(u=>{let d=r.nodeAt(u),f=u+s+1;return new Qc(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){let r=e.resolve(n.map(this.$anchorCell.pos)),i=e.resolve(n.map(this.$headCell.pos));if(vh(r)&&vh(i)&&wh(r,i)){let s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?Ae.rowSelection(r,i):s&&this.isColSelection()?Ae.colSelection(r,i):new Ae(r,i)}return ce.between(r,i)}content(){let e=this.$anchorCell.node(-1),n=et.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},o=[];for(let a=i.top;a<i.bottom;a++){let c=[];for(let u=a*n.width+i.left,d=i.left;d<i.right;d++,u++){let f=n.map[u];if(!s[f]){s[f]=!0;let h=n.findCell(f),p=e.nodeAt(f),g=i.left-h.left,v=h.right-i.right;if(g>0||v>0){let w=p.attrs;g>0&&(w=_i(w,0,g)),v>0&&(w=_i(w,w.colspan-v,v)),h.left<i.left?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}if(h.top<i.top||h.bottom>i.bottom){let w=wt(p.attrs,"rowspan",Math.min(h.bottom,i.bottom)-Math.max(h.top,i.top));h.top<i.top?p=p.type.createAndFill(w):p=p.type.create(w,p.content)}c.push(p)}}o.push(e.child(a).copy(W.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new Y(W.from(l),1,1)}replace(e,n=Y.empty){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:l,$to:a}=i[o],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),o?Y.empty:n)}let s=ue.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,n){this.replace(e,new Y(W.from(n),0,0))}forEachCell(e){let n=this.$anchorCell.node(-1),r=et.get(n),i=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let o=0;o<s.length;o++)e(n.nodeAt(s[o]),i+s[o])}isColSelection(){let e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){let r=et.get(e.node(-1)),i=e.start(-1),s=r.findCell(e.pos-i),o=r.findCell(n.pos-i),l=e.node(0);return s.top<=o.top?(s.top>0&&(e=l.resolve(i+r.map[s.left])),o.bottom<r.height&&(n=l.resolve(i+r.map[r.width*(r.height-1)+o.right-1]))):(o.top>0&&(n=l.resolve(i+r.map[o.left])),s.bottom<r.height&&(e=l.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))),new Ae(e,n)}isRowSelection(){let e=et.get(this.$anchorCell.node(-1)),n=this.$anchorCell.start(-1),r=e.colCount(this.$anchorCell.pos-n),i=e.colCount(this.$headCell.pos-n);if(Math.min(r,i)>0)return!1;let s=r+this.$anchorCell.nodeAfter.attrs.colspan,o=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,o)==e.width}eq(e){return e instanceof Ae&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){let r=et.get(e.node(-1)),i=e.start(-1),s=r.findCell(e.pos-i),o=r.findCell(n.pos-i),l=e.node(0);return s.left<=o.left?(s.left>0&&(e=l.resolve(i+r.map[s.top*r.width])),o.right<r.width&&(n=l.resolve(i+r.map[r.width*(o.top+1)-1]))):(o.left>0&&(n=l.resolve(i+r.map[o.top*r.width])),s.right<r.width&&(e=l.resolve(i+r.map[r.width*(s.top+1)-1]))),new Ae(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new Ae(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new Ae(e.resolve(n),e.resolve(r))}getBookmark(){return new xh(this.$anchorCell.pos,this.$headCell.pos)}}Ae.prototype.visible=!1,ue.jsonID("cell",Ae);class xh{constructor(e,n){this.anchor=e,this.head=n}map(e){return new xh(e.map(this.anchor),e.map(this.head))}resolve(e){let 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&&wh(n,r)?new Ae(n,r):ue.near(r,1)}}function uI(t){if(!(t.selection instanceof Ae))return null;let e=[];return t.selection.forEachCell((n,r)=>{e.push(ut.node(r,r+n.nodeSize,{class:"selectedCell"}))}),He.create(t.doc,e)}function dI({$from:t,$to:e}){if(t.pos==e.pos||t.pos<t.pos-6)return!1;let n=t.pos,r=e.pos,i=t.depth;for(;i>=0&&!(t.after(i+1)<t.end(i));i--,n++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function fI({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){let s=t.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){n=s;break}}for(let i=e.depth;i>0;i--){let s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return n!==r&&e.parentOffset===0}function hI(t,e,n){let r=(e||t).selection,i=(e||t).doc,s,o;if(r instanceof se&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=Ae.create(i,r.from);else if(o=="row"){let l=i.resolve(r.from+1);s=Ae.rowSelection(l,l)}else if(!n){let l=et.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=Ae.create(i,a+1,c)}}else r instanceof ce&&dI(r)?s=ce.create(i,r.from):r instanceof ce&&fI(r)&&(s=ce.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=t.tr)).setSelection(s),e}function pI(t){if(!t.size)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.firstChild.type.spec.tableRole=="table");)n--,r--,e=e.firstChild.content;let i=e.firstChild,s=i.type.spec.tableRole,o=i.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,u=a?0:Math.max(0,n-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=kh(Mt(o).row,new Y(c,u,d)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(n||r?kh(Mt(o).row,new Y(e,n,r)).content:e);else return null;return mI(o,l)}function mI(t,e){let n=[];for(let i=0;i<e.length;i++){let s=e[i];for(let o=s.childCount-1;o>=0;o--){let{rowspan:l,colspan:a}=s.child(o).attrs;for(let c=i;c<i+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let i=0;i<n.length;i++)r=Math.max(r,n[i]);for(let i=0;i<n.length;i++)if(i>=e.length&&e.push(W.empty),n[i]<r){let s=Mt(t).cell.createAndFill(),o=[];for(let l=n[i];l<r;l++)o.push(s);e[i]=e[i].append(W.from(o))}return{height:e.length,width:r,rows:e}}function kh(t,e){let n=t.createAndFill();return new Xc(n).replace(0,n.content.size,e).doc}function gI({width:t,height:e,rows:n},r,i){if(t!=r){let s=[],o=[];for(let l=0;l<n.length;l++){let a=n[l],c=[];for(let u=s[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.create(_i(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)s[l+h]=(s[l+h]||0)+f.attrs.colspan}o.push(W.from(c))}n=o,t=r}if(e!=i){let s=[];for(let o=0,l=0;o<i;o++,l++){let a=[],c=n[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);o+d.attrs.rowspan>i&&(d=d.type.create(wt(d.attrs,"rowspan",Math.max(1,i-d.attrs.rowspan)),d.content)),a.push(d)}s.push(W.from(a))}n=s,e=i}return{width:t,height:e,rows:n}}function yI(t,e,n,r,i,s,o){let l=t.doc.type.schema,a=Mt(l),c,u;if(i>e.width)for(let d=0,f=0;d<e.height;d++){let h=n.child(d);f+=h.nodeSize;let p=[],g;h.lastChild==null||h.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=u||(u=a.header_cell.createAndFill());for(let v=e.width;v<i;v++)p.push(g);t.insert(t.mapping.slice(o).map(f-1+r),p)}if(s>e.height){let d=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,i);p++){let v=p>=e.width?!1:n.nodeAt(e.map[g+p]).type==a.header_cell;d.push(v?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,W.from(d)),h=[];for(let p=e.height;p<s;p++)h.push(f);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),h)}return!!(c||u)}function Nw(t,e,n,r,i,s,o,l){if(o==0||o==e.height)return!1;let a=!1;for(let c=i;c<s;c++){let u=o*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;let f=n.nodeAt(d),{top:h,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,wt(f.attrs,"rowspan",o-h)),t.insert(t.mapping.slice(l).map(e.positionAt(o,p,n)),f.type.createAndFill(wt(f.attrs,"rowspan",h+f.attrs.rowspan-o))),c+=f.attrs.colspan-1}}return a}function Dw(t,e,n,r,i,s,o,l){if(o==0||o==e.width)return!1;let a=!1;for(let c=i;c<s;c++){let u=c*e.width+o,d=e.map[u];if(e.map[u-1]==d){a=!0;let f=n.nodeAt(d),h=e.colCount(d),p=t.mapping.slice(l).map(d+r);t.setNodeMarkup(p,null,_i(f.attrs,o-h,f.attrs.colspan-(o-h))),t.insert(p+f.nodeSize,f.type.createAndFill(_i(f.attrs,0,o-h))),c+=f.attrs.rowspan-1}}return a}function Rw(t,e,n,r,i){let s=n?t.doc.nodeAt(n-1):t.doc,o=et.get(s),{top:l,left:a}=r,c=a+i.width,u=l+i.height,d=t.tr,f=0;function h(){s=n?d.doc.nodeAt(n-1):d.doc,o=et.get(s),f=d.mapping.maps.length}yI(d,o,s,n,c,u,f)&&h(),Nw(d,o,s,n,a,c,l,f)&&h(),Nw(d,o,s,n,a,c,u,f)&&h(),Dw(d,o,s,n,l,u,a,f)&&h(),Dw(d,o,s,n,l,u,c,f)&&h();for(let p=l;p<u;p++){let g=o.positionAt(p,a,s),v=o.positionAt(p,c,s);d.replace(d.mapping.slice(f).map(g+n),d.mapping.slice(f).map(v+n),new Y(i.rows[p-l],0,0))}h(),d.setSelection(new Ae(d.doc.resolve(n+o.positionAt(l,a,s)),d.doc.resolve(n+o.positionAt(u-1,c-1,s)))),e(d)}const bI=Mu({ArrowLeft:Dc("horiz",-1),ArrowRight:Dc("horiz",1),ArrowUp:Dc("vert",-1),ArrowDown:Dc("vert",1),"Shift-ArrowLeft":Rc("horiz",-1),"Shift-ArrowRight":Rc("horiz",1),"Shift-ArrowUp":Rc("vert",-1),"Shift-ArrowDown":Rc("vert",1),Backspace:Lc,"Mod-Backspace":Lc,Delete:Lc,"Mod-Delete":Lc});function Nc(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Dc(t,e){return(n,r,i)=>{let s=n.selection;if(s instanceof Ae)return Nc(n,r,ue.near(s.$headCell,e));if(t!="horiz"&&!s.empty)return!1;let o=Lw(i,t,e);if(o==null)return!1;if(t=="horiz")return Nc(n,r,ue.near(n.doc.resolve(s.head+e),e));{let l=n.doc.resolve(o),a=Ow(l,t,e),c;return a?c=ue.near(a,1):e<0?c=ue.near(n.doc.resolve(l.before(-1)),-1):c=ue.near(n.doc.resolve(l.after(-1)),1),Nc(n,r,c)}}}function Rc(t,e){return(n,r,i)=>{let s=n.selection;if(!(s instanceof Ae)){let l=Lw(i,t,e);if(l==null)return!1;s=new Ae(n.doc.resolve(l))}let o=Ow(s.$headCell,t,e);return o?Nc(n,r,new Ae(s.$anchorCell,o)):!1}}function Lc(t,e){let n=t.selection;if(!(n instanceof Ae))return!1;if(e){let r=t.tr,i=Mt(t.schema).cell.createAndFill().content;n.forEachCell((s,o)=>{s.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+s.nodeSize-1),new Y(i,0,0))}),r.docChanged&&e(r)}return!0}function vI(t,e){let n=t.state.doc,r=Is(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Ae(r))),!0):!1}function wI(t,e,n){if(!An(t.state))return!1;let r=pI(n),i=t.state.selection;if(i instanceof Ae){r||(r={width:1,height:1,rows:[W.from(kh(Mt(t.state.schema).cell,n))]});let s=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),l=et.get(s).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=gI(r,l.right-l.left,l.bottom-l.top),Rw(t.state,t.dispatch,o,l,r),!0}else if(r){let s=_c(t.state),o=s.start(-1);return Rw(t.state,t.dispatch,o,et.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function xI(t,e){if(e.ctrlKey||e.metaKey)return;let n=Iw(t,e.target),r;if(e.shiftKey&&t.state.selection instanceof Ae)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&n&&(r=Is(t.state.selection.$anchor))!=null&&Ch(t,e).pos!=r.pos)i(r,e),e.preventDefault();else if(!n)return;function i(l,a){let c=Ch(t,a),u=Gr.getState(t.state)==null;if(!c||!wh(l,c))if(u)c=l;else return;let d=new Ae(l,c);if(u||!t.state.selection.eq(d)){let f=t.state.tr.setSelection(d);u&&f.setMeta(Gr,l.pos),t.dispatch(f)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",o),Gr.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(Gr,-1))}function o(l){let a=Gr.getState(t.state),c;if(a!=null)c=t.state.doc.resolve(a);else if(Iw(t,l.target)!=n&&(c=Ch(t,e),!c))return s();c&&i(c,l)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",o)}function Lw(t,e,n){if(!(t.state.selection instanceof ce))return null;let{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){let s=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){let l=r.before(i),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?l:null}}return null}function Iw(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e}function Ch(t,e){let n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?Is(t.state.doc.resolve(n.pos)):null}const kI=new We("fix-tables");function Pw(t,e,n,r){let i=t.childCount,s=e.childCount;e:for(let o=0,l=0;o<s;o++){let a=e.child(o);for(let c=l,u=Math.min(i,o+3);c<u;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<i&&t.child(l).sameMarkup(a)?Pw(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function Fw(t,e){let n,r=(i,s)=>{i.type.spec.tableRole=="table"&&(n=CI(t,i,s,n))};return e?e.doc!=t.doc&&Pw(e.doc,t.doc,0,r):t.doc.descendants(r),n}function CI(t,e,n,r){let i=et.get(e);if(!i.problems)return r;r||(r=t.tr);let s=[];for(let a=0;a<i.height;a++)s.push(0);for(let a=0;a<i.problems.length;a++){let c=i.problems[a];if(c.type=="collision"){let u=e.nodeAt(c.pos);for(let d=0;d<u.attrs.rowspan;d++)s[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,_i(u.attrs,u.attrs.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,wt(u.attrs,"rowspan",u.attrs.rowspan-c.n))}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,wt(u.attrs,"colwidth",c.colwidth))}}let o,l;for(let a=0;a<s.length;a++)s[a]&&(o==null&&(o=a),l=a);for(let a=0,c=n+1;a<i.height;a++){let u=e.child(a),d=c+u.nodeSize,f=s[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let v=0;v<f;v++)p.push(Mt(t.schema)[h].createAndFill());let g=(a==0||o==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(g),p)}c=d}return r.setMeta(kI,{fixTables:!0})}function Zn(t){let e=t.selection,n=_c(t),r=n.node(-1),i=n.start(-1),s=et.get(r),o;return e instanceof Ae?o=s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o=s.findCell(n.pos-i),o.tableStart=i,o.map=s,o.table=r,o}function $w(t,{map:e,tableStart:n,table:r},i){let s=i>0?-1:0;cI(e,r,i+s)&&(s=i==0||i==e.width?null:0);for(let o=0;o<e.height;o++){let l=o*e.width+i;if(i>0&&i<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,_w(c.attrs,i-e.colCount(a))),o+=c.attrs.rowspan-1}else{let a=s==null?Mt(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,c=e.positionAt(o,i,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function SI(t,e){if(!An(t))return!1;if(e){let n=Zn(t);e($w(t.tr,n,n.left))}return!0}function EI(t,e){if(!An(t))return!1;if(e){let n=Zn(t);e($w(t.tr,n,n.right))}return!0}function TI(t,{map:e,table:n,tableStart:r},i){let s=t.mapping.maps.length;for(let o=0;o<e.height;){let l=o*e.width+i,a=e.map[l],c=n.nodeAt(a);if(i>0&&e.map[l-1]==a||i<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(s).map(r+a),null,_i(c.attrs,i-e.colCount(a)));else{let u=t.mapping.slice(s).map(r+a);t.delete(u,u+c.nodeSize)}o+=c.attrs.rowspan}}function AI(t,e){if(!An(t))return!1;if(e){let n=Zn(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;TI(r,n,i),i!=n.left;i--)n.table=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc,n.map=et.get(n.table);e(r)}return!0}function MI(t,e,n){let r=Mt(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(e.nodeAt(t.map[i+n*t.width]).type!=r)return!1;return!0}function Bw(t,{map:e,tableStart:n,table:r},i){let s=n;for(let a=0;a<i;a++)s+=r.child(a).nodeSize;let o=[],l=i>0?-1:0;MI(e,r,i+l)&&(l=i==0||i==e.height?null:0);for(let a=0,c=e.width*i;a<e.width;a++,c++)if(i>0&&i<e.height&&e.map[c]==e.map[c-e.width]){let u=e.map[c],d=r.nodeAt(u).attrs;t.setNodeMarkup(n+u,null,wt(d,"rowspan",d.rowspan+1)),a+=d.colspan-1}else{let u=l==null?Mt(r.type.schema).cell:r.nodeAt(e.map[c+l*e.width]).type;o.push(u.createAndFill())}return t.insert(s,Mt(r.type.schema).row.create(null,o)),t}function OI(t,e){if(!An(t))return!1;if(e){let n=Zn(t);e(Bw(t.tr,n,n.top))}return!0}function _I(t,e){if(!An(t))return!1;if(e){let n=Zn(t);e(Bw(t.tr,n,n.bottom))}return!0}function NI(t,{map:e,table:n,tableStart:r},i){let s=0;for(let a=0;a<i;a++)s+=n.child(a).nodeSize;let o=s+n.child(i).nodeSize,l=t.mapping.maps.length;t.delete(s+r,o+r);for(let a=0,c=i*e.width;a<e.width;a++,c++){let u=e.map[c];if(i>0&&u==e.map[c-e.width]){let d=n.nodeAt(u).attrs;t.setNodeMarkup(t.mapping.slice(l).map(u+r),null,wt(d,"rowspan",d.rowspan-1)),a+=d.colspan-1}else if(i<e.width&&u==e.map[c+e.width]){let d=n.nodeAt(u),f=d.type.create(wt(d.attrs,"rowspan",d.attrs.rowspan-1),d.content),h=e.positionAt(i+1,a,n);t.insert(t.mapping.slice(l).map(r+h),f),a+=d.attrs.colspan-1}}}function DI(t,e){if(!An(t))return!1;if(e){let n=Zn(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;NI(r,n,i),i!=n.top;i--)n.table=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc,n.map=et.get(n.table);e(r)}return!0}function jw(t){let e=t.content;return e.childCount==1&&e.firstChild.isTextblock&&e.firstChild.childCount==0}function RI({width:t,height:e,map:n},r){let i=r.top*t+r.left,s=i,o=(r.bottom-1)*t+r.left,l=i+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[s]==n[s-1]||r.right<t&&n[l]==n[l+1])return!0;s+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[i]==n[i-t]||r.bottom<e&&n[o]==n[o+t])return!0;i++,o++}return!1}function Hw(t,e){let n=t.selection;if(!(n instanceof Ae)||n.$anchorCell.pos==n.$headCell.pos)return!1;let r=Zn(t),{map:i}=r;if(RI(i,r))return!1;if(e){let s=t.tr,o={},l=W.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){let f=i.map[u*i.width+d],h=r.table.nodeAt(f);if(!o[f])if(o[f]=!0,a==null)a=f,c=h;else{jw(h)||(l=l.append(h.content));let p=s.mapping.map(f+r.tableStart);s.delete(p,p+h.nodeSize)}}if(s.setNodeMarkup(a+r.tableStart,null,wt(_w(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),"rowspan",r.bottom-r.top)),l.size){let u=a+1+c.content.size,d=jw(c)?a+1:u;s.replaceWith(d+r.tableStart,u+r.tableStart,l)}s.setSelection(new Ae(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function zw(t,e){const n=Mt(t.schema);return LI(({node:r})=>n[r.type.spec.tableRole])(t,e)}function LI(t){return(e,n)=>{let r=e.selection,i,s;if(r instanceof Ae){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{if(i=oI(r.$from),!i)return!1;s=Is(r.$from).pos}if(i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let o=i.attrs,l=[],a=o.colwidth;o.rowspan>1&&(o=wt(o,"rowspan",1)),o.colspan>1&&(o=wt(o,"colspan",1));let c=Zn(e),u=e.tr;for(let f=0;f<c.right-c.left;f++)l.push(a?wt(o,"colwidth",a&&a[f]?[a[f]]:null):o);let d;for(let f=c.top;f<c.bottom;f++){let h=c.map.positionAt(f,c.left,c.table);f==c.top&&(h+=i.nodeSize);for(let p=c.left,g=0;p<c.right;p++,g++)p==c.left&&f==c.top||u.insert(d=u.mapping.map(h+c.tableStart,1),t({node:i,row:f,col:p}).createAndFill(l[g]))}u.setNodeMarkup(s,t({node:i,row:c.top,col:c.left}),l[0]),r instanceof Ae&&u.setSelection(new Ae(u.doc.resolve(r.$anchorCell.pos),d&&u.doc.resolve(d))),n(u)}return!0}}function II(t,e){return function(n,r){if(!An(n))return!1;let i=_c(n);if(i.nodeAfter.attrs[t]===e)return!1;if(r){let s=n.tr;n.selection instanceof Ae?n.selection.forEachCell((o,l)=>{o.attrs[t]!==e&&s.setNodeMarkup(l,null,wt(o.attrs,t,e))}):s.setNodeMarkup(i.pos,null,wt(i.nodeAfter.attrs,t,e)),r(s)}return!0}}function PI(t){return function(e,n){if(!An(e))return!1;if(n){let r=Mt(e.schema),i=Zn(e),s=e.tr,o=i.map.cellsInRect(t=="column"?new Ls(i.left,0,i.right,i.map.height):t=="row"?new Ls(0,i.top,i.map.width,i.bottom):i),l=o.map(a=>i.table.nodeAt(a));for(let a=0;a<o.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(i.tableStart+o[a],r.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<o.length;a++)s.setNodeMarkup(i.tableStart+o[a],r.header_cell,l[a].attrs);n(s)}return!0}}function Vw(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 i=0;i<r.length;i++){const s=e.table.nodeAt(r[i]);if(s&&s.type!==n.header_cell)return!1}return!0}function el(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?PI(t):function(n,r){if(!An(n))return!1;if(r){let i=Mt(n.schema),s=Zn(n),o=n.tr,l=Vw("row",s,i),a=Vw("column",s,i),u=(t==="column"?l:t==="row"?a:!1)?1:0,d=t=="column"?new Ls(0,u,1,s.map.height):t=="row"?new Ls(u,0,s.map.width,1):s,f=t=="column"?a?i.cell:i.header_cell:t=="row"?l?i.cell:i.header_cell:i.cell;s.map.cellsInRect(d).forEach(h=>{const p=h+s.tableStart,g=o.doc.nodeAt(p);g&&o.setNodeMarkup(p,f,g.attrs)}),r(o)}return!0}}el("row",{useDeprecatedLogic:!0}),el("column",{useDeprecatedLogic:!0});let FI=el("cell",{useDeprecatedLogic:!0});function $I(t,e){if(e<0){let n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,i=t.before();r>=0;r--){let s=t.node(-1).child(r);if(s.childCount)return i-1-s.lastChild.nodeSize;i-=s.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;let n=t.node(-1);for(let r=t.indexAfter(-1),i=t.after();r<n.childCount;r++){let s=n.child(r);if(s.childCount)return i+1;i+=s.nodeSize}}}function Uw(t){return function(e,n){if(!An(e))return!1;let r=$I(_c(e),t);if(r!=null){if(n){let i=e.doc.resolve(r);n(e.tr.setSelection(ce.between(i,aI(i))).scrollIntoView())}return!0}}}function BI(t,e){let 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}let jI=class{constructor(e,n){this.node=e,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Sh(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,Sh(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Sh(t,e,n,r,i,s){let o=0,l=!0,a=e.firstChild,c=t.firstChild;for(let u=0,d=0;u<c.childCount;u++){let{colspan:f,colwidth:h}=c.child(u).attrs;for(let p=0;p<f;p++,d++){let g=i==d?s:h&&h[p],v=g?g+"px":"";o+=g||r,g||(l=!1),a?(a.style.width!=v&&(a.style.width=v),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=v}}for(;a;){let u=a.nextSibling;a.parentNode.removeChild(a),a=u}l?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}const mn=new We("tableColumnResizing");function HI({handleWidth:t=5,cellMinWidth:e=25,View:n=jI,lastColumnResizable:r=!0}={}){return new je({key:mn,state:{init(s,o){return this.spec.props.nodeViews[Mt(o.schema).table.name]=(l,a)=>new n(l,e,a),new tl(-1,!1)},apply(s,o){return o.apply(s)}},props:{attributes(s){return mn.getState(s).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove(s,o){zI(s,o,t,e,r)},mouseleave(s){VI(s)},mousedown(s,o){UI(s,o,e)}},decorations(s){let o=mn.getState(s);if(o.activeHandle>-1)return YI(s,o.activeHandle)},nodeViews:{}}})}class tl{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){let n=this,r=e.getMeta(mn);if(r&&r.setHandle!=null)return new tl(r.setHandle,null);if(r&&r.setDragging!==void 0)return new tl(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);vh(e.doc.resolve(i))||(i=null),n=new tl(i,n.dragging)}return n}}function zI(t,e,n,r,i){let s=mn.getState(t.state);if(!s.dragging){let o=qI(e.target),l=-1;if(o){let{left:a,right:c}=o.getBoundingClientRect();e.clientX-a<=n?l=Ww(t,e,"left"):c-e.clientX<=n&&(l=Ww(t,e,"right"))}if(l!=s.activeHandle){if(!i&&l!==-1){let a=t.state.doc.resolve(l),c=a.node(-1),u=et.get(c),d=a.start(-1);if(u.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==u.width-1)return}Kw(t,l)}}}function VI(t){let e=mn.getState(t.state);e.activeHandle>-1&&!e.dragging&&Kw(t,-1)}function UI(t,e,n){let r=mn.getState(t.state);if(r.activeHandle==-1||r.dragging)return!1;let i=t.state.doc.nodeAt(r.activeHandle),s=WI(t,r.activeHandle,i.attrs);t.dispatch(t.state.tr.setMeta(mn,{setDragging:{startX:e.clientX,startWidth:s}}));function o(a){window.removeEventListener("mouseup",o),window.removeEventListener("mousemove",l);let c=mn.getState(t.state);c.dragging&&(KI(t,c.activeHandle,qw(c.dragging,a,n)),t.dispatch(t.state.tr.setMeta(mn,{setDragging:null})))}function l(a){if(!a.which)return o(a);let c=mn.getState(t.state),u=qw(c.dragging,a,n);JI(t,c.activeHandle,u,n)}return window.addEventListener("mouseup",o),window.addEventListener("mousemove",l),e.preventDefault(),!0}function WI(t,e,{colspan:n,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let s=t.domAtPos(e),l=s.node.childNodes[s.offset].offsetWidth,a=n;if(r)for(let c=0;c<n;c++)r[c]&&(l-=r[c],a--);return l/a}function qI(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Ww(t,e,n){let r=t.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return-1;let{pos:i}=r,s=Is(t.state.doc.resolve(i));if(!s)return-1;if(n=="right")return s.pos;let o=et.get(s.node(-1)),l=s.start(-1),a=o.map.indexOf(s.pos-l);return a%o.width==0?-1:l+o.map[a-1]}function qw(t,e,n){let r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function Kw(t,e){t.dispatch(t.state.tr.setMeta(mn,{setHandle:e}))}function KI(t,e,n){let r=t.state.doc.resolve(e),i=r.node(-1),s=et.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<s.height;c++){let u=c*s.width+l;if(c&&s.map[u]==s.map[u-s.width])continue;let d=s.map[u],{attrs:f}=i.nodeAt(d),h=f.colspan==1?0:l-s.colCount(d);if(f.colwidth&&f.colwidth[h]==n)continue;let p=f.colwidth?f.colwidth.slice():GI(f.colspan);p[h]=n,a.setNodeMarkup(o+d,null,wt(f,"colwidth",p))}a.docChanged&&t.dispatch(a)}function JI(t,e,n,r){let i=t.state.doc.resolve(e),s=i.node(-1),o=i.start(-1),l=et.get(s).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1,a=t.domAtPos(i.start(-1)).node;for(;a.nodeName!="TABLE";)a=a.parentNode;Sh(s,a.firstChild,a,r,l,n)}function GI(t){let e=[];for(let n=0;n<t;n++)e.push(0);return e}function YI(t,e){let n=[],r=t.doc.resolve(e),i=r.node(-1),s=et.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan;for(let a=0;a<s.height;a++){let c=l+a*s.width-1;if((l==s.width||s.map[c]!=s.map[c+1])&&(a==0||s.map[c-1]!=s.map[c-1-s.width])){let u=s.map[c],d=o+u+i.nodeAt(u).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",n.push(ut.widget(d,f))}}return He.create(t.doc,n)}function XI({allowTableNodeSelection:t=!1}={}){return new je({key:Gr,state:{init(){return null},apply(e,n){let r=e.getMeta(Gr);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;let{deleted:i,pos:s}=e.mapping.mapResult(n);return i?null:s}},props:{decorations:uI,handleDOMEvents:{mousedown:xI},createSelectionBetween(e){if(Gr.getState(e.state)!=null)return e.state.selection},handleTripleClick:vI,handleKeyDown:bI,handlePaste:wI},appendTransaction(e,n,r){return hI(r,Fw(r,n),t)}})}function Jw(t,e,n,r,i,s){var u;let o=0,l=!0,a=e.firstChild;const c=t.firstChild;if(c)for(let d=0,f=0;d<c.childCount;d+=1){const{colspan:h,colwidth:p}=c.child(d).attrs;for(let g=0;g<h;g+=1,f+=1){const v=i===f?s:p&&p[g],w=v?`${v}px`:"";o+=v||r,v||(l=!1),a?(a.style.width!==w&&(a.style.width=w),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=w}}for(;a;){const d=a.nextSibling;(u=a==null?void 0:a.parentNode)==null||u.removeChild(a),a=d}l?(n.style.width=`${o}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${o}px`)}class ZI{constructor(e,n){vr(this,"node");vr(this,"cellMinWidth");vr(this,"dom");vr(this,"table");vr(this,"colgroup");vr(this,"contentDOM");this.node=e,this.cellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Jw(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,Jw(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function Gw(t,e){return t.createAndFill()}function QI(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 eP(t,e,n,r,i){const s=QI(t),o=[],l=[];for(let c=0;c<n;c+=1){const u=Gw(s.cell);if(u&&l.push(u),r){const d=Gw(s.header_cell);d&&o.push(d)}}const a=[];for(let c=0;c<e;c+=1)a.push(s.row.createChecked(null,r&&c===0?o:l));return s.table.createChecked(null,a)}function tP(t){return t instanceof Ae}const Ic=({editor:t})=>{const{selection:e}=t.state;if(!tP(e))return!1;let n=0;const r=$u(e.ranges[0].$from,s=>s.type.name==="table");return r==null||r.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},nP=ze.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:ZI,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){let n=0,r=!0;try{t.content.firstChild.content.forEach(s=>{if(s.attrs.colwidth)s.attrs.colwidth.forEach(o=>{o?n+=o:(r=!1,n+=this.options.cellMinWidth)});else{r=!1;const o=s.attrs.colspan?s.attrs.colspan:1;n+=this.options.cellMinWidth*o}})}catch{r=!1}return r&&n>0?e.style=`width: ${n}px;`:n&&n>0?e.style=`min-width: ${n}px`:e.style=null,["div",{class:"table-wrapper"},["table",Ce(this.options.HTMLAttributes,e),["tbody",0]]]},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:s})=>{const{selection:o}=r,l=eP(s.schema,t,e,n);if(i){const a=r.selection.anchor+1;r.replaceRangeWith(o.from-1,o.to,l).scrollIntoView().setSelection(ce.near(r.doc.resolve(a)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>SI(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>EI(t,e),deleteColumn:()=>({state:t,dispatch:e})=>AI(t,e),addRowBefore:()=>({state:t,dispatch:e})=>OI(t,e),addRowAfter:()=>({state:t,dispatch:e})=>_I(t,e),deleteRow:()=>({state:t,dispatch:e})=>DI(t,e),deleteTable:()=>({state:t,dispatch:e})=>BI(t,e),mergeCells:()=>({state:t,dispatch:e})=>Hw(t,e),splitCell:()=>({state:t,dispatch:e})=>zw(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>el("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>el("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>FI(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Hw(t,e)?!0:zw(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>II(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Uw(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Uw(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&Fw(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Ae.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:Ic,"Mod-Backspace":Ic,Delete:Ic,"Mod-Delete":Ic}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[HI({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],XI({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:be(re(t,"tableRole",e))}}});function Yw(t,e){if(t==null)return{};var n={},r=Object.keys(t),i,s;for(s=0;s<r.length;s++)i=r[s],!(e.indexOf(i)>=0)&&(n[i]=t[i]);return n}var Xw=typeof window<"u"&&typeof document<"u";function Eh(t,e){t&&(typeof t=="function"&&t(e),{}.hasOwnProperty.call(t,"current")&&(t.current=e))}function Zw(){return Xw&&document.createElement("div")}function rP(t){var e={"data-placement":t.placement};return t.referenceHidden&&(e["data-reference-hidden"]=""),t.escaped&&(e["data-escaped"]=""),e}function Qw(t,e){if(t===e)return!0;if(typeof t=="object"&&t!=null&&typeof e=="object"&&e!=null){if(Object.keys(t).length!==Object.keys(e).length)return!1;for(var n in t)if(e.hasOwnProperty(n)){if(!Qw(t[n],e[n]))return!1}else return!1;return!0}else return!1}function iP(t){var e=[];return t.forEach(function(n){e.find(function(r){return Qw(n,r)})||e.push(n)}),e}function sP(t,e){var n,r;return Object.assign({},e,{popperOptions:Object.assign({},t.popperOptions,e.popperOptions,{modifiers:iP([].concat(((n=t.popperOptions)==null?void 0:n.modifiers)||[],((r=e.popperOptions)==null?void 0:r.modifiers)||[]))})})}var Th=Xw?O.useLayoutEffect:O.useEffect;function oP(t){var e=O.useRef();return e.current||(e.current=typeof t=="function"?t():t),e.current}function e1(t,e,n){n.split(/\s+/).forEach(function(r){r&&t.classList[e](r)})}var lP={name:"className",defaultValue:"",fn:function(e){var n=e.popper.firstElementChild,r=function(){var l;return!!((l=e.props.render)!=null&&l.$$tippy)};function i(){if(e.props.className&&!r()){process.env.NODE_ENV!=="production"&&console.warn(["@tippyjs/react: Cannot use `className` prop in conjunction with","`render` prop. Place the className on the element you are","rendering."].join(" "));return}e1(n,"add",e.props.className)}function s(){r()&&e1(n,"remove",e.props.className)}return{onCreate:i,onBeforeUpdate:s,onAfterUpdate:i}}};function aP(t){function e(n){var r=n.children,i=n.content,s=n.visible,o=n.singleton,l=n.render,a=n.reference,c=n.disabled,u=c===void 0?!1:c,d=n.ignoreAttributes,f=d===void 0?!0:d;n.__source,n.__self;var h=Yw(n,["children","content","visible","singleton","render","reference","disabled","ignoreAttributes","__source","__self"]),p=s!==void 0,g=o!==void 0,v=O.useState(!1),w=v[0],S=v[1],x=O.useState({}),y=x[0],C=x[1],E=O.useState(),T=E[0],D=E[1],N=oP(function(){return{container:Zw(),renders:1}}),A=Object.assign({ignoreAttributes:f},h,{content:N.container});p&&(process.env.NODE_ENV!=="production"&&["trigger","hideOnClick","showOnCreate"].forEach(function(z){A[z]!==void 0&&console.warn(["@tippyjs/react: Cannot specify `"+z+"` prop in","controlled mode (`visible` prop)"].join(" "))}),A.trigger="manual",A.hideOnClick=!1),g&&(u=!0);var R=A,P=A.plugins||[];l&&(R=Object.assign({},A,{plugins:g&&o.data!=null?[].concat(P,[{fn:function(){return{onTrigger:function(J,G){var ie=o.data.children.find(function(Z){var ke=Z.instance;return ke.reference===G.currentTarget});J.state.$$activeSingletonInstance=ie.instance,D(ie.content)}}}}]):P,render:function(){return{popper:N.container}}}));var B=[a].concat(r?[r.type]:[]);return Th(function(){var z=a;a&&a.hasOwnProperty("current")&&(z=a.current);var U=t(z||N.ref||Zw(),Object.assign({},R,{plugins:[lP].concat(A.plugins||[])}));return N.instance=U,u&&U.disable(),s&&U.show(),g&&o.hook({instance:U,content:i,props:R,setSingletonContent:D}),S(!0),function(){U.destroy(),o==null||o.cleanup(U)}},B),Th(function(){var z;if(N.renders===1){N.renders++;return}var U=N.instance;U.setProps(sP(U.props,R)),(z=U.popperInstance)==null||z.forceUpdate(),u?U.disable():U.enable(),p&&(s?U.show():U.hide()),g&&o.hook({instance:U,content:i,props:R,setSingletonContent:D})}),Th(function(){var z;if(l){var U=N.instance;U.setProps({popperOptions:Object.assign({},U.props.popperOptions,{modifiers:[].concat((((z=U.props.popperOptions)==null?void 0:z.modifiers)||[]).filter(function(J){var G=J.name;return G!=="$$tippyReact"}),[{name:"$$tippyReact",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(G){var ie,Z=G.state,ke=(ie=Z.modifiersData)==null?void 0:ie.hide;(y.placement!==Z.placement||y.referenceHidden!==(ke==null?void 0:ke.isReferenceHidden)||y.escaped!==(ke==null?void 0:ke.hasPopperEscaped))&&C({placement:Z.placement,referenceHidden:ke==null?void 0:ke.isReferenceHidden,escaped:ke==null?void 0:ke.hasPopperEscaped}),Z.attributes.popper={}}}])})})}},[y.placement,y.referenceHidden,y.escaped].concat(B)),O.createElement(O.Fragment,null,r?O.cloneElement(r,{ref:function(U){N.ref=U,Eh(r.ref,U)}}):null,w&&nn.createPortal(l?l(rP(y),T,N.instance):i,N.container))}return e}var cP=function(t,e){return O.forwardRef(function(r,i){var s=r.children,o=Yw(r,["children"]);return O.createElement(t,Object.assign({},e,o),s?O.cloneElement(s,{ref:function(a){Eh(i,a),Eh(s.ref,a)}}):null)})},uP=cP(aP(fi));const dP=[{name:"Add row above",action:t=>t.chain().focus().addRowBefore().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7h2v-2h4v2h2v-2h4v2h2v-2h4v2h2v-7M4 14h4v3H4v-3m6 0h4v3h-4v-3m10 0v3h-4v-3h4m-9-4h2V7h3V5h-3V2h-2v3H8v2h3v3Z"})})},{name:"Add row below",action:t=>t.chain().focus().addRowAfter().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M22 10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V3h2v2h4V3h2v2h4V3h2v2h4V3h2v7M4 10h4V7H4v3m6 0h4V7h-4v3m10 0V7h-4v3h4m-9 4h2v3h3v2h-3v3h-2v-3H8v-2h3v-3Z"})})},{name:"Add left column",action:t=>t.chain().focus().addColumnBefore().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M13 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h9V2h-9m7 8v4h-7v-4h7m0 6v4h-7v-4h7m0-12v4h-7V4h7M9 11H6V8H4v3H1v2h3v3h2v-3h3v-2Z"})})},{name:"Add right column",action:t=>t.chain().focus().addColumnAfter().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M11 2a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H2V2h9m-7 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m11 7h3V8h2v3h3v2h-3v3h-2v-3h-3v-2Z"})})},{name:"Remove row",action:t=>t.chain().focus().deleteRow().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41L9.41 13M22 9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3M4 9h4V6H4v3m6 0h4V6h-4v3m6 0h4V6h-4v3Z"})})},{name:"Remove column",action:t=>t.chain().focus().deleteColumn().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M4 2h7a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m13.59 8L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59L17.59 12Z"})})},{name:"Toggle header row",action:t=>t.chain().focus().toggleHeaderRow().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4M4 14h4v-4H4v4m6 0h4v-4h-4v4m6 0h4v-4h-4v4Z"})})},{name:"Toggle header column",action:t=>t.chain().focus().toggleHeaderColumn().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M8 2h8a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h8v-4H8m0 6v4h8v-4H8M8 4v4h8V4H8Z"})})},{name:"Toggle header cell",action:t=>t.chain().focus().toggleHeaderCell().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M21 19a1 1 0 0 1-1 1h-1v-2h2v1m-6 1v-2h2v2h-2m-4 0v-2h2v2h-2m-4 0v-2h2v2H7m-3 0a1 1 0 0 1-1-1v-1h2v2H4M19 4H5a2 2 0 0 0-2 2v2h18V6c0-1.11-.89-2-2-2M5 14H3v2h2v-2m0-4H3v2h2v-2m16 0h-2v2h2v-2m0 4h-2v2h2v-2m-10 2v-2h2v2h-2m0-4v-2h2v2h-2"})})},{name:"Remove table",action:t=>t.chain().focus().deleteTable().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M12.35 20H10v-3h2.09c.12-.72.37-1.39.72-2H10v-3h4v1.54c.58-.54 1.25-.93 2-1.19V12h4v.35c.75.26 1.42.65 2 1.19V5c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v15c0 1.1.9 2 2 2h9.54c-.54-.58-.93-1.25-1.19-2M16 7h4v3h-4V7m-6 0h4v3h-4V7M8 20H4v-3h4v3m0-5H4v-3h4v3m0-5H4V7h4v3m6.46 5.88l1.42-1.42L18 16.59l2.12-2.13l1.42 1.42L19.41 18l2.13 2.12l-1.42 1.42L18 19.41l-2.12 2.13l-1.42-1.42L16.59 18l-2.13-2.12"})})}],t1=({node:t,getPos:e,selected:n,editor:r})=>{const[i,s]=O.useState(!1),o=Gl(),l=O.useRef(null),a=()=>{const{from:u,to:d}=r.state.selection,f=e(),h=f+t.nodeSize;s(f<=u&&d<=h)};O.useEffect(()=>(r.on("selectionUpdate",a),setTimeout(a,100),()=>{r.off("selectionUpdate",a)}));const c=()=>{var f,h;let u=(f=l.current)==null?void 0:f.clientTop;u&&(u+=5);let d=(h=l.current)==null?void 0:h.clientLeft;return d&&(d+=5),{top:`${u}px`,left:`${d}px`}};return _.jsxs(wo,{className:"group",children:[_.jsx(oy,{as:"span"}),(i||n)&&_.jsx(uP,{appendTo:document.body,trigger:"click",interactive:!0,animation:"shift-toward-subtle",placement:"right-start",content:_.jsx("article",{className:"dropdown",contentEditable:!1,children:_.jsx("ul",{tabIndex:0,className:"dropdown-content fixed menu menu-compact p-2 shadow bg-base-100 rounded-box w-56",style:c(),children:dP.map(u=>_.jsx("li",{children:_.jsxs("button",{type:"button",className:"button",onClick:()=>u.action(r),children:[_.jsx("span",{children:u.icon}),_.jsx("span",{children:u.name})]})},u.name))})}),children:_.jsx("label",{tabIndex:0,className:Se("trigger-button",{hidden:o}),contentEditable:!1,children:_.jsx(dA,{fontSize:"small"})})})]})},fP=ze.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",Ce(this.options.HTMLAttributes,t),0]},addNodeView(){return hi(t1,{as:"td",className:"relative"})}}),hP=ze.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",Ce(this.options.HTMLAttributes,t),0]},addNodeView(){return hi(t1,{as:"th",className:"relative"})}}),n1=t=>(t.stopPropagation(),t.preventDefault(),t),pP=function(t){const e=t.scrollHeight>t.clientHeight,r=window.getComputedStyle(t).overflowY.indexOf("hidden")!==-1;return e&&!r},r1=function(t){return!t||t===document.body?document.body:pP(t)?t:r1(t.parentNode)},Ah=(t,e,n)=>{const r=document.createElement(t);if(!r)throw new Error(`Element with name ${t} can't be created.`);return e&&Object.entries(e).forEach(([i,s])=>r.setAttribute(i,s)),n&&Object.entries(n).forEach(([i,s])=>r.addEventListener(i,s)),r},mP=ze.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",Ce(this.options.HTMLAttributes,t),0]},addNodeView(){return({editor:t,HTMLAttributes:e,getPos:n})=>{const r=()=>n(),i=r1(t.options.element);let s=!1;const o={deleteRow:()=>{this.editor.chain().deleteNode("tableRow").focus().run()},selectRow:()=>{const w=r(),S=t.state.doc.resolve(w),x=new se(S);t.view.dispatch(t.state.tr.setSelection(x))}},l=()=>{s=!0},a=()=>{s=!1},c=Ah("section",{class:"absolute hidden flex items-center w-2 bg-gray-200 z-50 cursor-pointer border-1 border-indigo-600 rounded-l opacity-25 hover:opacity-100",contenteditable:"false"},{click:w=>{w&&n1(w),o.selectRow()},mouseenter:()=>{l()},mouseover:()=>{l()},mouseleave:()=>{a(),f()}}),u=Ah("button",{class:"text-sm px-1 absolute -translate-x-[125%] hover:active:-translate-x-[125%] mr-2"},{click:w=>{w&&n1(w),o.deleteRow()}}),d=()=>{g(),c.classList.remove("hidden")},f=()=>{setTimeout(()=>{s||c.classList.add("hidden")},100)},h=Ah("tr",{...e},{mouseenter:d,mouseover:d,mouseleave:f});c.append(u),document.body.append(c);let p="";const g=()=>{setTimeout(()=>{const w=h.getBoundingClientRect(),S=JSON.stringify(w);p!==S&&(c.style.top=`${w.top+document.documentElement.scrollTop}px`,c.style.left=`${w.x+document.documentElement.scrollLeft-8}px`,c.style.height=`${w.height+1}px`,p=S)})};return setTimeout(()=>{g()},100),t.on("selectionUpdate",g),t.on("update",g),i==null||i.addEventListener("scroll",g),document.addEventListener("scroll",g),{dom:h,contentDOM:h,destroy:()=>{c.remove(),t.off("selectionUpdate",g),t.off("update",g),i==null||i.removeEventListener("scroll",g),document.removeEventListener("scroll",g)}}}}}),gP=[nP.configure({resizable:!0}),fP,hP,mP],yP=Xb.extend({content:"(dBlock|columns)+"});function i1({types:t,node:e}){return e!=null&&e.type?Array.isArray(t)&&t.includes(e.type)||e.type===t:!1}const bP=Ue.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const t=new We(this.name),e=Object.entries(this.editor.schema.nodes).map(([,n])=>n).filter(n=>this.options.notAfter.includes(n.name));return[new je({key:t,appendTransaction:(n,r,i)=>{const{doc:s,tr:o,schema:l}=i,a=t.getState(i),c=s.content.size,u=l.nodes[this.options.node];if(a)return o.insert(c,u.create())},state:{init:(n,r)=>{const i=r.tr.doc.lastChild;return!i1({node:i,types:e})},apply:(n,r)=>{var s,o,l;if(!n.docChanged)return r;const i=(l=(o=(s=n.doc.lastChild)==null?void 0:s.content)==null?void 0:o.content)==null?void 0:l[0];return!i1({node:i,types:e})}}})]}}),vP=({node:t,editor:e,getPos:n})=>{const[r,i]=O.useState(""),s=Gl(),o=["https://twitter.com","https://x.com"],l=()=>{switch(t.attrs.data){case"twitter":return _.jsx(wy,{});case"iframe":return _.jsx(ky,{});default:return _.jsx(xA,{})}},a=()=>{switch(t.attrs.data){case"twitter":return"Embed a Twitter tweet";case"iframe":return"Embed a video";default:return"Embed an URL"}},c=()=>{if(!r){alert("Please enter a url");return}let p=r;if(r.includes("<iframe")){const x=r.match(/src="([^"]*)"/);x&&x.length>0&&(p=x[1])}else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(r):{const x=r.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);x&&x.length>0&&(p=`https://www.youtube.com/embed/${x[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(r):{const x=r.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);x&&x.length>0&&(p=`https://player.vimeo.com/video/${x[1]}`);break}default:{alert("Please enter a valid url");return}}const g=640,v=360,w=n(),S=w+t.nodeSize;p&&(e==null||e.chain().focus(w).deleteRange({from:w,to:S}).setIframe({src:p,width:g,height:v}).run())},u=()=>{if(!r){alert("Please enter a url");return}let p=r;const g=o.some(y=>r.includes(y)),v=r.match(/\/status\/([0-9]*)/),w=v&&v.length>0;if(g&&w)p=v[1];else{alert("invalid url");return}const S=n(),x=S+t.nodeSize;p&&(e==null||e.chain().focus(S).deleteRange({from:S,to:x}).setTweetEmbed({tweetId:p}).run())},f=Av(()=>{switch(t.attrs.data){case"twitter":u();break;default:c();break}},500);O.useEffect(()=>{r&&f()},[r]),O.useEffect(()=>{e==null||e.chain().focus()},[]);const h=O.useRef(null);return O.useEffect(()=>{var p;(p=h.current)==null||p.focus()},[]),_.jsx(wo,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:!s&&_.jsxs("div",{className:"relative w-full",children:[_.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:l()}),_.jsx("input",{ref:h,value:r,placeholder:a(),onChange:p=>i(p.target.value),onClick:p=>p.stopPropagation(),className:"bg-stone-200 p-3 pl-10 rounded-xl w-full hover:bg-stone-300 cursor-pointer transition-all ease-in-out"})]})})},wP=ze.create({name:"actionButton",group:"block",content:"block*",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:"rounded-lg bg-stone-500"}}},addAttributes(){return{data:{default:null}}},addNodeView(){return hi(vP)},parseHTML(){return[{tag:"div[data-action-node]"}]},renderHTML({HTMLAttributes:t}){return console.log("action"),["div",Ce(t,{"data-action-node":""}),0]},addCommands(){return{setActionButton:t=>({commands:e})=>e.insertContent({type:this.name,attrs:{data:t},content:[]})}}}),xP=[dN,cN.configure({strike:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bold:{HTMLAttributes:{class:"select-text pointer-events-auto"}},italic:{HTMLAttributes:{class:"select-text pointer-events-auto"}},heading:{HTMLAttributes:{class:"select-text pointer-events-auto"}},paragraph:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bulletList:{HTMLAttributes:{class:"flex flex-col items-start list-disc list-outside space-y-4 ml-6"}},orderedList:{HTMLAttributes:{class:"flex flex-col items-start list-decimal list-outside space-y-4 ml-6"}},listItem:{HTMLAttributes:{class:"leading-normal"}},blockquote:{HTMLAttributes:{class:"rounded-lg bg-stone-100 p-5 font-serif italic text-stone-800"}},codeBlock:{HTMLAttributes:{class:"rounded-lg bg-transparent border border-[#DDE2E4] p-5 font-mono font-medium text-stone-800"}},code:{HTMLAttributes:{class:"rounded-md bg-stone-200 p-1.5 font-mono font-medium text-black text-sm",spellcheck:"false"}},history:!1,gapcursor:!1,dropcursor:!1,document:!1,horizontalRule:!1}),fN.configure({types:["heading","paragraph"]}),QN,IN.configure({HTMLAttributes:{class:"text-blue-500 font-bold transition-colors cursor-pointer select-text pointer-events-auto"},openOnClick:!0}),PN.configure({placeholder:()=>"",includeChildren:!0,showOnlyCurrent:!0}),BN.configure({multicolor:!0}),ZN,VN.configure({HTMLAttributes:{class:"select-text pointer-events-auto"}}),uN,nD,jN.configure({HTMLAttributes:{class:"not-prose space-y-4 ml-2"}}),zN.configure({HTMLAttributes:{class:"flex items-start"},nested:!0}),Zb.configure({width:3,color:"#d1d5db"}),Qb,tI,bP,yP,...gP,dD.configure({uploadFn:_A}),tD,rD,lD,wP.extend({addInputRules(){return[s1(/^(?:twt|###|___\s|\*\*\*\s)$/,"twitter",this.type),s1(/^(?:ytb|@@@|___\s|\*\*\*\s)$/,"iframe",this.type)]}}),eD],s1=(t,e,n)=>new oo({find:t,handler:({state:r,range:i,commands:s})=>{const o={data:e},{tr:l}=r,a=i.from,c=i.to;l.insert(a-1,n.create(o)).delete(l.mapping.map(a),l.mapping.map(c)),s.focus(c-1)}}),Ni=t=>ss((e,n)=>{t.onerror=r=>n(new Error(r.target.error)),t.onsuccess=r=>e(r.target.result)}),kP=(t,e)=>ss((n,r)=>{const i=indexedDB.open(t);i.onupgradeneeded=s=>e(s.target.result),i.onerror=s=>r(xn(s.target.error)),i.onsuccess=s=>{const o=s.target.result;o.onversionchange=()=>{o.close()},n(o)}}),CP=t=>Ni(indexedDB.deleteDatabase(t)),SP=(t,e)=>e.forEach(n=>t.createObjectStore.apply(t,n)),nl=(t,e,n="readwrite")=>{const r=t.transaction(e,n);return e.map(i=>DP(r,i))},o1=(t,e)=>Ni(t.count(e)),EP=(t,e)=>Ni(t.get(e)),l1=(t,e)=>Ni(t.delete(e)),TP=(t,e,n)=>Ni(t.put(e,n)),Mh=(t,e)=>Ni(t.add(e)),AP=(t,e,n)=>Ni(t.getAll(e,n)),MP=(t,e,n)=>{let r=null;return NP(t,e,i=>(r=i,!1),n).then(()=>r)},OP=(t,e=null)=>MP(t,e,"prev"),_P=(t,e)=>ss((n,r)=>{t.onerror=r,t.onsuccess=async i=>{const s=i.target.result;if(s===null||await e(s)===!1)return n();s.continue()}}),NP=(t,e,n,r="next")=>_P(t.openKeyCursor(e,r),i=>n(i.key)),DP=(t,e)=>t.objectStore(e),RP=(t,e)=>IDBKeyRange.upperBound(t,e),LP=(t,e)=>IDBKeyRange.lowerBound(t,e),Oh="custom",a1="updates",c1=500,u1=(t,e=()=>{},n=()=>{})=>{const[r]=nl(t.db,[a1]);return AP(r,LP(t._dbref,!1)).then(i=>{t._destroyed||(e(r),Fe(t.doc,()=>{i.forEach(s=>L0(t.doc,s))},t,!1),n(r))}).then(()=>OP(r).then(i=>{t._dbref=i+1})).then(()=>o1(r).then(i=>{t._dbsize=i})).then(()=>r)},IP=(t,e=!0)=>u1(t).then(n=>{(e||t._dbsize>=c1)&&Mh(n,Gd(t.doc)).then(()=>l1(n,RP(t._dbref,!0))).then(()=>o1(n).then(r=>{t._dbsize=r}))});class PP extends wd{constructor(e,n){super(),this.doc=n,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=kP(e,r=>SP(r,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=ss(r=>this.on("synced",()=>r(this))),this._db.then(r=>{this.db=r,u1(this,o=>Mh(o,Gd(n)),()=>{if(this._destroyed)return this;this.synced=!0,this.emit("synced",[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(r,i)=>{if(this.db&&i!==this){const[s]=nl(this.db,[a1]);Mh(s,r),++this._dbsize>=c1&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{IP(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},n.on("update",this._storeUpdate),this.destroy=this.destroy.bind(this),n.on("destroy",this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off("update",this._storeUpdate),this.doc.off("destroy",this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{CP(this.name)})}get(e){return this._db.then(n=>{const[r]=nl(n,[Oh],"readonly");return EP(r,e)})}set(e,n){return this._db.then(r=>{const[i]=nl(r,[Oh]);return TP(i,n,e)})}del(e){return this._db.then(n=>{const[r]=nl(n,[Oh]);return l1(r,e)})}}const d1=["#30bced","#6eeb83","#fa69d1","#ecd444","#ee6352","#db3041","#0ad7f2","#1bff39"],FP=({isPreviewMode:t,data:e,enableCollaboration:n,collaborationId:r})=>{const[i,s]=O.useState({plugin:{title:"Untitled"}}),[o]=O.useState(new us),[l,a]=O.useState(!1),[c,u]=O.useState([...xP]),d=ty({extensions:c,editorProps:Bb,autofocus:"start"},[c]),f=ty({extensions:c,editorProps:Bb,autofocus:"start"}),h=w=>{if(!n||!r||!w)throw new Error("docId or username is not provided");a(!0);const S=new jO(r,o,{signaling:["wss://fileverse-signaling-server-0529292ff51c.herokuapp.com/"]});u([...c,f_.configure({document:o}),h_.configure({provider:S,user:{name:w,color:d1[Math.floor(Math.random()*d1.length)]}})]);const x=setTimeout(()=>{a(!1)},100);return()=>{clearTimeout(x),S.destroy(),o.destroy(),a(!1)}};O.useEffect(()=>{r&&new PP(r,o)},[r]);const p=O.useRef(null),g=O.useMemo(()=>n&&r&&d&&!l?d:f,[d,f,l]),v=w=>{var S;(S=p.current)!=null&&S.contains(w.target)||g==null||g.chain().focus().run()};return O.useEffect(()=>{g==null||g.chain().focus()},[]),O.useEffect(()=>{g==null||g.setEditable(!t)},[t]),O.useEffect(()=>{e&&g&&(g==null||g.commands.setContent(e.editorJSONData),s(e.metaData))},[e,g]),{editor:g,pluginMetaData:i,setPluginMetaData:s,focusEditor:v,ref:p,loading:l,connect:h}},$P=({isPreviewMode:t=!1,data:e,enableCollaboration:n,collaborationId:r,username:i,onAutoSave:s,renderToolRightSection:o})=>{const{editor:l,pluginMetaData:a,focusEditor:c,setPluginMetaData:u,ref:d,loading:f,connect:h}=FP({isPreviewMode:t,data:e,enableCollaboration:n,collaborationId:r});return O.useEffect(()=>{n&&i&&h(i)},[n]),O.useEffect(()=>{if(l&&s){const p=setInterval(()=>{s({metaData:a,editorJSONData:l.getJSON()})},1e4);return()=>clearInterval(p)}},[l,s,a]),!l||f?_.jsxs("div",{className:"w-screen h-screen flex flex-col gap-4 justify-center items-center",children:[_.jsx(Hy,{}),_.jsx("p",{children:"Loading Editor..."})]}):_.jsx("div",{"data-cy":"single-webpage",className:"bg-[#f8f9fa]",children:_.jsx("div",{className:"h-full flex flex-col overflow-scroll no-scrollbar",children:_.jsxs("div",{className:"w-full h-screen",children:[_.jsx("div",{className:"h-fit relative bg-[#f8f9fa]",children:_.jsxs("div",{className:"flex items-center justify-center pl-4 pr-4 gap-2 h-16",children:[_.jsx("div",{className:"grow",children:_.jsx(b1,{isPreviewMode:t,metaData:a,setMetaData:u})}),!t&&_.jsx("div",{className:"grow relative",children:_.jsx(UA,{editor:l})}),o==null?void 0:o({editor:l,pluginMetaData:a})]})}),_.jsx("main",{className:"h-screen lg:h-full w-full rounded-[8px] flex flex-col justify-start items-center gap-2",children:_.jsx("div",{onClick:c,className:"w-full flex justify-center relative",children:_.jsx("div",{className:"p-12 sm:p-[96px] mt-4 min-h-[900px] bg-white overflow-scroll no-scrollbar w-full sm:w-[70%] max-w-[856px]",children:_.jsxs("div",{ref:d,className:"w-full pt-4 h-full",children:[!t&&_.jsxs("div",{children:[_.jsx(IA,{editor:l}),_.jsx(zA,{editor:l,appendTo:d})]}),_.jsx(VA,{isPreviewMode:t,children:_.jsx(GT,{editor:l})})]})})})})]})})})};$t.DdocEditor=$P,Object.defineProperty($t,Symbol.toStringTag,{value:"Module"})});
|