@fileverse-dev/ddoc 1.1.5 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(Bt,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):(Bt=typeof globalThis<"u"?globalThis:Bt||self,O(Bt.ddoc={},Bt.React,Bt.ReactDOM))})(this,function(Bt,O,nn){"use strict";var NL=Object.defineProperty;var DL=(Bt,O,nn)=>O in Bt?NL(Bt,O,{enumerable:!0,configurable:!0,writable:!0,value:nn}):Bt[O]=nn;var vr=(Bt,O,nn)=>(DL(Bt,typeof O!="symbol"?O+"":O,nn),nn);function Eh(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const le=Eh(O),ew=Eh(nn);var On=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Nc(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Dc={exports:{}},$s={};/**
1
+ (function(Bt,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):(Bt=typeof globalThis<"u"?globalThis:Bt||self,O(Bt.ddoc={},Bt.React,Bt.ReactDOM))})(this,function(Bt,O,nn){"use strict";var LL=Object.defineProperty;var IL=(Bt,O,nn)=>O in Bt?LL(Bt,O,{enumerable:!0,configurable:!0,writable:!0,value:nn}):Bt[O]=nn;var vr=(Bt,O,nn)=>(IL(Bt,typeof O!="symbol"?O+"":O,nn),nn);function Eh(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const le=Eh(O),ew=Eh(nn);var On=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Nc(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Dc={exports:{}},$s={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -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 Ah;function nw(){return Ah||(Ah=1,process.env.NODE_ENV!=="production"&&function(){var n=O,e=Symbol.for("react.element"),t=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=n.__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];C("error",L,Q)}}function C(L,K,Q){{var fe=w.ReactDebugCurrentFrame,Ne=fe.getStackAddendum();Ne!==""&&(K+="%s",Q=Q.concat([Ne]));var $e=Q.map(function(Ae){return String(Ae)});$e.unshift("Warning: "+K),Function.prototype.apply.call(console[L],console,$e)}}var y=!1,k=!1,E=!1,T=!1,N=!1,_;_=Symbol.for("react.module.reference");function A(L){return!!(typeof L=="string"||typeof L=="function"||L===r||L===s||N||L===i||L===c||L===u||T||L===h||y||k||E||typeof L=="object"&&L!==null&&(L.$$typeof===f||L.$$typeof===d||L.$$typeof===o||L.$$typeof===l||L.$$typeof===a||L.$$typeof===_||L.getModuleId!==void 0))}function R(L,K,Q){var fe=L.displayName;if(fe)return fe;var Ne=K.displayName||K.name||"";return Ne!==""?Q+"("+Ne+")":Q}function P(L){return L.displayName||"Context"}function $(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 t: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:$(L.type)||"Memo";case f:{var Ne=L,$e=Ne._payload,Ae=Ne._init;try{return $(Ae($e))}catch{return null}}}return null}var V=Object.assign,U=0,J,G,ie,X,we,Re,Pe;function xe(){}xe.__reactDisabledLog=!0;function ye(){{if(U===0){J=console.log,G=console.info,ie=console.warn,X=console.error,we=console.group,Re=console.groupCollapsed,Pe=console.groupEnd;var L={configurable:!0,enumerable:!0,value:xe,writable:!0};Object.defineProperties(console,{info:L,log:L,warn:L,error:L,group:L,groupCollapsed:L,groupEnd:L})}U++}}function _e(){{if(U--,U===0){var L={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:V({},L,{value:J}),info:V({},L,{value:G}),warn:V({},L,{value:ie}),error:V({},L,{value:X}),group:V({},L,{value:we}),groupCollapsed:V({},L,{value:Re}),groupEnd:V({},L,{value:Pe})})}U<0&&S("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Le=w.ReactCurrentDispatcher,tt;function nt(L,K,Q){{if(tt===void 0)try{throw Error()}catch(Ne){var fe=Ne.stack.trim().match(/\n( *(at )?)/);tt=fe&&fe[1]||""}return`
18
- `+tt+L}}var Ge=!1,Ye;{var Ot=typeof WeakMap=="function"?WeakMap:Map;Ye=new Ot}function Ct(L,K){if(!L||Ge)return"";{var Q=Ye.get(L);if(Q!==void 0)return Q}var fe;Ge=!0;var Ne=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var $e;$e=Le.current,Le.current=null,ye();try{if(K){var Ae=function(){throw Error()};if(Object.defineProperty(Ae.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ae,[])}catch(qt){fe=qt}Reflect.construct(L,[],Ae)}else{try{Ae.call()}catch(qt){fe=qt}L.call(Ae.prototype)}}else{try{throw Error()}catch(qt){fe=qt}L()}}catch(qt){if(qt&&fe&&typeof qt.stack=="string"){for(var ke=qt.stack.split(`
17
+ */var Ah;function nw(){return Ah||(Ah=1,process.env.NODE_ENV!=="production"&&function(){var n=O,e=Symbol.for("react.element"),t=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=n.__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,De=fe.getStackAddendum();De!==""&&(K+="%s",Q=Q.concat([De]));var $e=Q.map(function(Ae){return String(Ae)});$e.unshift("Warning: "+K),Function.prototype.apply.call(console[L],console,$e)}}var y=!1,k=!1,E=!1,T=!1,N=!1,_;_=Symbol.for("react.module.reference");function A(L){return!!(typeof L=="string"||typeof L=="function"||L===r||L===s||N||L===i||L===c||L===u||T||L===h||y||k||E||typeof L=="object"&&L!==null&&(L.$$typeof===f||L.$$typeof===d||L.$$typeof===o||L.$$typeof===l||L.$$typeof===a||L.$$typeof===_||L.getModuleId!==void 0))}function R(L,K,Q){var fe=L.displayName;if(fe)return fe;var De=K.displayName||K.name||"";return De!==""?Q+"("+De+")":Q}function P(L){return L.displayName||"Context"}function $(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 t: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:$(L.type)||"Memo";case f:{var De=L,$e=De._payload,Ae=De._init;try{return $(Ae($e))}catch{return null}}}return null}var V=Object.assign,U=0,J,G,ie,X,we,Re,Pe;function Ce(){}Ce.__reactDisabledLog=!0;function ye(){{if(U===0){J=console.log,G=console.info,ie=console.warn,X=console.error,we=console.group,Re=console.groupCollapsed,Pe=console.groupEnd;var L={configurable:!0,enumerable:!0,value:Ce,writable:!0};Object.defineProperties(console,{info:L,log:L,warn:L,error:L,group:L,groupCollapsed:L,groupEnd:L})}U++}}function Ne(){{if(U--,U===0){var L={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:V({},L,{value:J}),info:V({},L,{value:G}),warn:V({},L,{value:ie}),error:V({},L,{value:X}),group:V({},L,{value:we}),groupCollapsed:V({},L,{value:Re}),groupEnd:V({},L,{value:Pe})})}U<0&&S("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Le=w.ReactCurrentDispatcher,tt;function nt(L,K,Q){{if(tt===void 0)try{throw Error()}catch(De){var fe=De.stack.trim().match(/\n( *(at )?)/);tt=fe&&fe[1]||""}return`
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 De=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var $e;$e=Le.current,Le.current=null,ye();try{if(K){var Ae=function(){throw Error()};if(Object.defineProperty(Ae.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ae,[])}catch(qt){fe=qt}Reflect.construct(L,[],Ae)}else{try{Ae.call()}catch(qt){fe=qt}L.call(Ae.prototype)}}else{try{throw Error()}catch(qt){fe=qt}L()}}catch(qt){if(qt&&fe&&typeof qt.stack=="string"){for(var ke=qt.stack.split(`
19
19
  `),Ft=fe.stack.split(`
20
20
  `),st=ke.length-1,ct=Ft.length-1;st>=1&&ct>=0&&ke[st]!==Ft[ct];)ct--;for(;st>=1&&ct>=0;st--,ct--)if(ke[st]!==Ft[ct]){if(st!==1||ct!==1)do if(st--,ct--,ct<0||ke[st]!==Ft[ct]){var gn=`
21
- `+ke[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,Le.current=$e,_e(),Error.prepareStackTrace=Ne}var Bs=L?L.displayName||L.name:"",Di=Bs?nt(Bs):"";return typeof L=="function"&&Ye.set(L,Di),Di}function it(L,K,Q){return Ct(L,!1)}function at(L){var K=L.prototype;return!!(K&&K.isReactComponent)}function B(L,K,Q){if(L==null)return"";if(typeof L=="function")return Ct(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 B(L.type,K,Q);case f:{var fe=L,Ne=fe._payload,$e=fe._init;try{return B($e(Ne),K,Q)}catch{}}}return""}var j=Object.prototype.hasOwnProperty,q={},te=w.ReactDebugCurrentFrame;function M(L){if(L){var K=L._owner,Q=B(L.type,L._source,K?K.type:null);te.setExtraStackFrame(Q)}else te.setExtraStackFrame(null)}function m(L,K,Q,fe,Ne){{var $e=Function.call.bind(j);for(var Ae in L)if($e(L,Ae)){var ke=void 0;try{if(typeof L[Ae]!="function"){var Ft=Error((fe||"React class")+": "+Q+" type `"+Ae+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof L[Ae]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ft.name="Invariant Violation",Ft}ke=L[Ae](K,Ae,fe,Q,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(st){ke=st}ke&&!(ke instanceof Error)&&(M(Ne),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,Ae,typeof ke),M(null)),ke instanceof Error&&!(ke.message in q)&&(q[ke.message]=!0,M(Ne),S("Failed %s type: %s",Q,ke.message),M(null))}}}var b=Array.isArray;function x(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,Me={key:!0,ref:!0,__self:!0,__source:!0},be,me,Ze;Ze={};function An(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 z(L,K){if(typeof L.ref=="string"&&de.current&&K&&de.current.stateNode!==K){var Q=$(de.current.type);Ze[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',$(de.current.type),L.ref),Ze[Q]=!0)}}function ee(L,K){{var Q=function(){be||(be=!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(){me||(me=!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 Oe=function(L,K,Q,fe,Ne,$e,Ae){var ke={$$typeof:e,type:L,key:K,ref:Q,props:Ae,_owner:$e};return ke._store={},Object.defineProperty(ke._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ke,"_self",{configurable:!1,enumerable:!1,writable:!1,value:fe}),Object.defineProperty(ke,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ne}),Object.freeze&&(Object.freeze(ke.props),Object.freeze(ke)),ke};function Ee(L,K,Q,fe,Ne){{var $e,Ae={},ke=null,Ft=null;Q!==void 0&&(ne(Q),ke=""+Q),Qn(K)&&(ne(K.key),ke=""+K.key),An(K)&&(Ft=K.ref,z(K,Ne));for($e in K)j.call(K,$e)&&!Me.hasOwnProperty($e)&&(Ae[$e]=K[$e]);if(L&&L.defaultProps){var st=L.defaultProps;for($e in st)Ae[$e]===void 0&&(Ae[$e]=st[$e])}if(ke||Ft){var ct=typeof L=="function"?L.displayName||L.name||"Unknown":L;ke&&ee(Ae,ct),Ft&&oe(Ae,ct)}return Oe(L,ke,Ft,Ne,fe,de.current,Ae)}}var ft=w.ReactCurrentOwner,Pt=w.ReactDebugCurrentFrame;function tn(L){if(L){var K=L._owner,Q=B(L.type,L._source,K?K.type:null);Pt.setExtraStackFrame(Q)}else Pt.setExtraStackFrame(null)}var Ls;Ls=!1;function Mn(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function Is(){{if(ft.current){var L=$(ft.current.type);if(L)return`
21
+ `+ke[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,Le.current=$e,Ne(),Error.prepareStackTrace=De}var Bs=L?L.displayName||L.name:"",Di=Bs?nt(Bs):"";return typeof L=="function"&&Ye.set(L,Di),Di}function it(L,K,Q){return xt(L,!1)}function at(L){var K=L.prototype;return!!(K&&K.isReactComponent)}function B(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 B(L.type,K,Q);case f:{var fe=L,De=fe._payload,$e=fe._init;try{return B($e(De),K,Q)}catch{}}}return""}var j=Object.prototype.hasOwnProperty,q={},te=w.ReactDebugCurrentFrame;function M(L){if(L){var K=L._owner,Q=B(L.type,L._source,K?K.type:null);te.setExtraStackFrame(Q)}else te.setExtraStackFrame(null)}function m(L,K,Q,fe,De){{var $e=Function.call.bind(j);for(var Ae in L)if($e(L,Ae)){var ke=void 0;try{if(typeof L[Ae]!="function"){var Ft=Error((fe||"React class")+": "+Q+" type `"+Ae+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof L[Ae]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Ft.name="Invariant Violation",Ft}ke=L[Ae](K,Ae,fe,Q,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(st){ke=st}ke&&!(ke instanceof Error)&&(M(De),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,Ae,typeof ke),M(null)),ke instanceof Error&&!(ke.message in q)&&(q[ke.message]=!0,M(De),S("Failed %s type: %s",Q,ke.message),M(null))}}}var b=Array.isArray;function C(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,Oe={key:!0,ref:!0,__self:!0,__source:!0},be,me,Ze;Ze={};function An(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 z(L,K){if(typeof L.ref=="string"&&de.current&&K&&de.current.stateNode!==K){var Q=$(de.current.type);Ze[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',$(de.current.type),L.ref),Ze[Q]=!0)}}function ee(L,K){{var Q=function(){be||(be=!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(){me||(me=!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 _e=function(L,K,Q,fe,De,$e,Ae){var ke={$$typeof:e,type:L,key:K,ref:Q,props:Ae,_owner:$e};return ke._store={},Object.defineProperty(ke._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ke,"_self",{configurable:!1,enumerable:!1,writable:!1,value:fe}),Object.defineProperty(ke,"_source",{configurable:!1,enumerable:!1,writable:!1,value:De}),Object.freeze&&(Object.freeze(ke.props),Object.freeze(ke)),ke};function Ee(L,K,Q,fe,De){{var $e,Ae={},ke=null,Ft=null;Q!==void 0&&(ne(Q),ke=""+Q),Qn(K)&&(ne(K.key),ke=""+K.key),An(K)&&(Ft=K.ref,z(K,De));for($e in K)j.call(K,$e)&&!Oe.hasOwnProperty($e)&&(Ae[$e]=K[$e]);if(L&&L.defaultProps){var st=L.defaultProps;for($e in st)Ae[$e]===void 0&&(Ae[$e]=st[$e])}if(ke||Ft){var ct=typeof L=="function"?L.displayName||L.name||"Unknown":L;ke&&ee(Ae,ct),Ft&&oe(Ae,ct)}return _e(L,ke,Ft,De,fe,de.current,Ae)}}var ft=w.ReactCurrentOwner,Pt=w.ReactDebugCurrentFrame;function tn(L){if(L){var K=L._owner,Q=B(L.type,L._source,K?K.type:null);Pt.setExtraStackFrame(Q)}else Pt.setExtraStackFrame(null)}var Ls;Ls=!1;function Mn(L){return typeof L=="object"&&L!==null&&L.$$typeof===e}function Is(){{if(ft.current){var L=$(ft.current.type);if(L)return`
22
22
 
23
23
  Check the render method of \``+L+"`."}return""}}function Ps(L){return""}var br={};function bh(L){{var K=Is();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 Fs(L,K){{if(!L._store||L._store.validated||L.key!=null)return;L._store.validated=!0;var Q=bh(K);if(br[Q])return;br[Q]=!0;var fe="";L&&L._owner&&L._owner!==ft.current&&(fe=" It was passed a child from "+$(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 Ni(L,K){{if(typeof L!="object")return;if(x(L))for(var Q=0;Q<L.length;Q++){var fe=L[Q];Mn(fe)&&Fs(fe,K)}else if(Mn(L))L._store&&(L._store.validated=!0);else if(L){var Ne=v(L);if(typeof Ne=="function"&&Ne!==L.entries)for(var $e=Ne.call(L),Ae;!(Ae=$e.next()).done;)Mn(Ae.value)&&Fs(Ae.value,K)}}}function kL(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=$(K);m(Q,L.props,"prop",fe,L)}else if(K.PropTypes!==void 0&&!Ls){Ls=!0;var Ne=$(K);S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ne||"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 SL(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 Zv={};function Xv(L,K,Q,fe,Ne,$e){{var Ae=A(L);if(!Ae){var ke="";(L===void 0||typeof L=="object"&&L!==null&&Object.keys(L).length===0)&&(ke+=" 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=Ps();Ft?ke+=Ft:ke+=Is();var st;L===null?st="null":x(L)?st="array":L!==void 0&&L.$$typeof===e?(st="<"+($(L.type)||"Unknown")+" />",ke=" 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,ke)}var ct=Ee(L,K,Q,Ne,$e);if(ct==null)return ct;if(Ae){var gn=K.children;if(gn!==void 0)if(fe)if(x(gn)){for(var Bs=0;Bs<gn.length;Bs++)Ni(gn[Bs],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 Ni(gn,L)}if(j.call(K,"key")){var Di=$(L),qt=Object.keys(K).filter(function(_L){return _L!=="key"}),vh=qt.length>0?"{key: someKey, "+qt.join(": ..., ")+": ...}":"{key: someKey}";if(!Zv[Di+vh]){var OL=qt.length>0?"{"+qt.join(": ..., ")+": ...}":"{}";S(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+Q+">.")}return K}}function Fs(L,K){{if(!L._store||L._store.validated||L.key!=null)return;L._store.validated=!0;var Q=bh(K);if(br[Q])return;br[Q]=!0;var fe="";L&&L._owner&&L._owner!==ft.current&&(fe=" It was passed a child from "+$(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 Ni(L,K){{if(typeof L!="object")return;if(C(L))for(var Q=0;Q<L.length;Q++){var fe=L[Q];Mn(fe)&&Fs(fe,K)}else if(Mn(L))L._store&&(L._store.validated=!0);else if(L){var De=v(L);if(typeof De=="function"&&De!==L.entries)for(var $e=De.call(L),Ae;!(Ae=$e.next()).done;)Mn(Ae.value)&&Fs(Ae.value,K)}}}function TL(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=$(K);m(Q,L.props,"prop",fe,L)}else if(K.PropTypes!==void 0&&!Ls){Ls=!0;var De=$(K);S("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",De||"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 AL(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 Zv={};function Xv(L,K,Q,fe,De,$e){{var Ae=A(L);if(!Ae){var ke="";(L===void 0||typeof L=="object"&&L!==null&&Object.keys(L).length===0)&&(ke+=" 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=Ps();Ft?ke+=Ft:ke+=Is();var st;L===null?st="null":C(L)?st="array":L!==void 0&&L.$$typeof===e?(st="<"+($(L.type)||"Unknown")+" />",ke=" 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,ke)}var ct=Ee(L,K,Q,De,$e);if(ct==null)return ct;if(Ae){var gn=K.children;if(gn!==void 0)if(fe)if(C(gn)){for(var Bs=0;Bs<gn.length;Bs++)Ni(gn[Bs],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 Ni(gn,L)}if(j.call(K,"key")){var Di=$(L),qt=Object.keys(K).filter(function(RL){return RL!=="key"}),vh=qt.length>0?"{key: someKey, "+qt.join(": ..., ")+": ...}":"{key: someKey}";if(!Zv[Di+vh]){var DL=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} />`,vh,Di,OL,Di),Zv[Di+vh]=!0}}return L===r?SL(ct):kL(ct),ct}}function EL(L,K,Q){return Xv(L,K,Q,!0)}function TL(L,K,Q){return Xv(L,K,Q,!1)}var AL=TL,ML=EL;js.Fragment=r,js.jsx=AL,js.jsxs=ML}()),js}process.env.NODE_ENV==="production"?Dc.exports=tw():Dc.exports=nw();var D=Dc.exports;const rw="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAA9fSURBVHgB7Z0LmFRlGcf/75nZ2ZnZXZA7BOyFS7BiKYhAGZYpGSlqaKWCyZNWmima5VOWPZh000zxbiZikFgaPeI1NUsMVFxBBQQV2AVWQK7K7s7MzuW8vd8Zgb3NMrs75zZ7fs9z5lzmzMyZ73++9/u+9/u+9xBcDlcjiECoH5IoRZLLAd8x0LgShKFg9JZTjpKlWPZ9sk/Gh0i2WD4B1Mv2Plnvl+VDeeMdOb4Omr4R9bwN0dgOGo8EXAzBZfDfRagJ4WMB7Rwwj5cjlSLKQPknBcglLMIS9kgSrZGdV5Di57Et+gadjBhchCsE5trQEDRq35Cc+RXZO0kuOwx7iMjvrwTTCyjkv9Dg6DY4HMcKbJheKr4Y0M+XnDpOLjUEJ8HcCKIqua4HENOWUmXdXjgQRwnMVWJm+wcnIUU/kMQ7W8xkEO4gJtf6FHz6bVQW+x8chCMEZpZytSZ4oZSrl8juRFn8cC+vSbLei/KGh0hV5mzGVoH5A4SRCM+SzcskKY5BPkFYK8sd2B1ZJDXxCGzCNoG5JjxVRL1eNifBJZW9TqBy8Gr5d7+g8sgzsAHLE5bfLToWQf4VdJyJ7kNclmclteeI0KthIZYJzLv7lqAucpX84uWyOwDdERZnioa7kAjOo5H7DsACLBGYt4bHS469Tf7gifBQqb4cpH2fyurXwWQ0mIjUjjWuDl2JlDQhPHEPo9JC15ertOE55mpgWg7mdf2KEa6/X37iPHhkQvnDF6IxPJtG76mDCZgisNSQx0r2fUS+/tPwyAJ6H4HkNBrc+C5yTM4FFrMjzR56Qjb7wiN7mOqg0dlUXv8ickhO7T9vDp0rqxfgidtxiEvA+lLeHJ6GHJIzgXlT0QzxHy+SKy2CR2cpEpu6lGuCM5hzY127LLC6EK4uvlLqyyIuCuHRdVhbgOrQD5EDunyXGDlX4wVwdweBMyF9BpXHHkYX6JLARnkhJgUeZtEoJnImDYs+hk7SaYG5tvjLSKSWemWu2XCDvJxKFdFX0Qk6JTBXB0YDBdLvyT3gYQV7Rakpnemo6HAly+g0YP8TnriW0kfayY8Y3sEO0iGBlW8Z9ZF5cjeNgIfF8KdRVP+njvquO2SijY4D0C3wasw2wrOlPL4927OzFpjfLx4DPy+XrZ7wsJNd8OF0Ko1UZXNyVtmdN6AEfv0+T1xH0F/1rfMGqQtlQXb2PBC+Sl69/lynoPqTCyJXZ3PqEU10uusPasCY64fZ3L0wiWQKtlA5Qto5X/AhZ6jhP0SnUUXDW+2ddmSBq8OPyyovBsgVHR1BJApbOPNUHx6/P+eu+qVUETmrvRParQ1zTeFUsfdT821Q66xzfQgUWPOnNmxiLFtpmtk4kzcWTqURjRmH5GYU2BiUHvfNzfmsPQdwy88D6H2UNQI/+nTKTIEBn+96rsJLmQbXZ87ByfBMeR0LF7L/I0Ysnvn9HbsZjXGYxqD+lpq8SeirZodE7m7rzTYFNjqbq3GFvLrSOJ/5vUa8vV5vdfxg+Ttpesy0oYyfGkBY868Q/DmsTx0BpdFlotl9RGhlKtrOwTVFF0k3vmvnCtXVMw7UAz2KCYEm9Zq+Zg5HkPtpz36W34T1qHldxuS92IKWb2Uw0Xwp8oAl9wUw6ThThx0fYnMt47On2Tj5n7SLJRcvklycbHq4lcC8tWQyUqmJyAOChYSisDWlTLFdMQcOwlIWbyv5nNivl5sebp2D9eRst0z2u3tRAq+/3XoK7pbt6fXcOxIYaFKFp6QI+P1PAwg5ZxSaX7S7TNaZBeaqkr7g5OlwCf99RTeaIZl49iXzmie9ehLm/ohFYAdlBqbpKvQFVRwOFNM8B/fSp0nudUvYhENcfqEfJ3/emmrrgTrG968zsY3VNQpB4e80bTI1F1jji+FCJo314ZyvWiPwrr2MAme7fs6XpbXAvClYKqvxcCDbP2TUfNC6rK3dkT62dTtjxSodZnFcJSEccolLgHG8CjtFQ6K1avdwDvZpM+VNRw5c//29Sdy+IHPAuZ//wTyTWRgAViwJYtwY1/h8Qkho35D1rWrnsMBMU2B/UJh26duLMGSgdQm9fpN5VsFUWAWMayIwv69yrj7B6c2jqy/247rLrSkAG8R1P+HsKDZtcfZN3yaEk1TIR/omUmk3D4XG2xge0CP3hNPxPA+aaJ8yz/az5NkUrv1d6/J05670+tb5Scx/NAmzePDmQkw+wRrXpgWcI8uqtMCMzzvBOqs2Znsmcc8+lgWmYddoD1NgnKBWfiM+JDkrytzUL/lw83XWNTZnXRNH1RqXVqgywaiUzoegH4NCAxF31oz8o3oAY0ZaZyqL8rH2QeiP7aF+fiNSOqwdlvNeNWPx0tZl6ap16Vy0ZoOOG+aZF2h9uni9PjMqb8raTASUtlIGayOsbv++X61jzm2ZBVz7HstinsDDS6k7CKwiBZT7kZLy16YKVtkQwvnTrJvm9MS/U1j3Xp6Vte0h2qrUrYRNjCzT8NtrrSsdtn+oi8DoPmhcqclL9wwM2h0gDNXEb9kbHvkJo7fUNKgXPPITpl6qKpnVNEQPF0JcpAS2boi2h9X4lcD5+rwED5gcENzDfjQ44Nk+mdi7n1G7k9VcqTZRx9W4LDVlxKNNWJpJsGnOe/v8aXESo0+JoWJyFDOuiiPVwgGli6azb4hj1JdjGPHFGO58yLx+YheTVCa6Hg5DiXftbxNGzkyKbqpj4rllze/DF1ekcIeIGokxPpZ+5J/dFEfNNi8nt6BeBOaP4DBUra+xsblYeosc3Ngo5zWpHqqzNa890BzGfimDycQxEp1DCXfzdYFDAh53tIZTTmxeHzz1Cz6cNcV36PwrLipA6afsbxDE5Mb7x9NJPPZ0ylheW21j54aGfX5RWT0Ddxwcxg8v8uOkiRrqG4BjK8mYKdgUNV558e0BvLWeEZDto0c6o0GgipXzrnTM1Jadfrn935Hq6FlwIJ8d3b5oSvSJxzmrGa+mtZw71QetxaWPO8aG8kPnDaq70PSnb3UnBvQh/OWPhVaGcMgMaWulwz+1pdXt5hBU/20kSkYZa+RTQrNtY9VkrTZVABS/RWMI4on0olBlr+PQ9I1+BGkL4lCX6bg5c+dLWfbmO3xYzE9e2jLKSuDePYFlfw8agVDMZv/HjHFnHA7Z4MAGWhx+bPUjHt0NhHfKgaFwGEMHaVi2MnsHxhA5f0A/68rkbTvaltUhtYK92BHdqaVng9MGOJBrL+2Yrb3gLD98FpU2R/Ug7HszhNTmcLNl64oQfE4of5nW0ngk0smhc1axh61G1aIvnZGdyGPHaPjetywMTkUwbiaNmi/klEo98Qq1+mRuEh6TQuRncCC3Xh8wotI9mGFOkkrQ44/R8Nd5hejdK/epq6LT3nRv4pATpSEKJBLpdrijSfHzapUWeGXkLUwIR0Rkx43xDxYC828KYPppPtz2YBJVa1L4+ED6+KhhmhGfY+Z0v2nRblIi8N+edGR/THtEsC36htowBFbzSLkay2Tzq3AoZ5ziMxaFikMZKEibRLNR5emPv1uAwS0mnqsbqrjIqWMleCWdnI6006SA4+dEascK3JSgheZROSy+eYYP48a4aGwE0wsHNw8LnMSj0hL+tZjpELop6zfqGNQvva3K2pTrLLNBI1hfeHDnkMA0MlrLNeFV6MbPZrj6xtadBI6vTLWEUEXDY1sP7jZvg+hYLCd0W4GHlRIK/K17rRzqyW2bFD3QdLe5wBR5ABy+RUTuls8BvvvGQpx2kovHIbJUrOJas6fBNvs3hleL6Z/wcCtPUWXd3qYHWruJUql7xCadizx+fN1PfpfAzfcfdpx8sCNfxnLp81oeaS3igdgr6BN+DXlc2dq5i40lz3iNhsVebnmwlcDKQc3V9Gcx6Hkr8NxrCjBlcmu/dcUQN0/y0O9t62jbZri8YSGqw9c4LfpOrigbTJhwbB5N6iCsRVnsobbealNg9fQO3gx1R9wBE7s3392s4w/3Wzdg/d3qvBw3zeKkupMyzFDJXJEqiMxHKnyBESTNJFSH+U9+49jg2m5hNUI9F6Lt52JlFpiGIso1qbnibn8aOWbUcM0YFmsXw8vyxDwzEtBSv6DBOyKZTulWD6fMOzQspbL2H0555FvZT9fL64fwcBbq8bJx3HCk044oMA1teFu+7C54OI27aGRk1ZFOyq4w2hWZJ8Z8OTycwnLsCs7L5sSsm0C8KXyC3A5PQj1D3sNG6GMk6UQaWZ/VjJSsq5M0PPK6yPxreNiJOA30X2YrrqJj7YXy6J3Q+RF42MVCPCQadIAOe6l4HYoRDlXJR0fBwzoYG6XcPZ4m7TvQkY91yg3JNeGx8oNq3G0feJgP0QE0JibSqHiHZ6B0yqVD5ZHVIvMZsjTAw2Qkjf2pr3dGXEWnfXZUEX1VcvEsqFF8HubBdAENib2ITtIlpywNiz4GnVz5QEsXkBTTPJOGRZaiC3TZ607DG/4qt9ls44I8cofGP0JZw8PoIjnp62WW79lcdIFc1CJ4dJVGybnfofKui6vIaWc+bwlPk3byYvnaInh0hgbJLbOMoi9H5Hy0Bm8qOkVy8hLZ7AGPjrBHUm+aUXnNIaYMx+HqwGiw7wkxNSPgkQX0HojPSzc/c4spQxuoQtps8agKrvYgvMpX+5AUaY2h8WaIqzBt7AqNRh3KI5dIfr5G2ssdcq91Cxi7jdbHguhMGr2nDiZhyUBg3lI8Brp+H7rxzMVm6FiBAsym0ojpsVEsG+nNu/uWoC5ylfzi5bLbPZ/VpIbZaLgLieA8GrnPEqtm+VD+Tzoq5sjmVDgw+JqJiEeKfkkVDW/BQmybqyFCf02EvlE2x9p5HSajXECvyHquVKKegQ3YmrBchTD6hGdKMlyRd9NkGGvFHN+Dgp4L2hu3bDaOyDk8R5LiouC3pVJ/qexOhHuRDgJILxs9oOZ3qSlAsBnHmUbeHJwsQs+WKztddoNwAyz+Y42WQE/dg32xV9UMTTgEx5Z9XFvSB3piGlLaJZKA450XVoKjknyr5LoeBvefTxU1MTgQV1RueFOwFKRdKK7PU8XzM8G2iHwEFQ1wmfSBP4dC/VEaEq2Fw3Fd7ZX/I2Z7aOh4+GiKXP7n5MhnJNH7yj/JbZNLTewi7JTfWC89PFXinFiCVZE3VVRAuAjXN08k6QswKDRQqjel0LUR0PQxSNHRUm0bkH42stZLzlJPWFVT+pv+36RUhhpA+n45rJ48s80QU02mJr1G5N2K4QN2EznT9GbL/wFLC+Kh6JIF9QAAAABJRU5ErkJggg==",iw=({metaData:n,setMetaData:e,isPreviewMode:t})=>D.jsxs("div",{className:"flex items-center gap-4",children:[D.jsx("img",{src:rw,alt:"Fileverse",className:"w-10 h-10 object-cover mr-2 rounded-lg cursor-pointer"}),D.jsx("input",{className:"custom-input mx-2 focus:outline-none",disabled:t,type:"text",placeholder:"Untitled",defaultValue:n.plugin.title||"",onChange:r=>e({...n,plugin:{...n.plugin,title:r.target.value}})})]});function xt(n){this.content=n}xt.prototype={constructor:xt,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new xt(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new xt(t)},addToStart:function(n,e){return new xt([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new xt(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new xt(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=xt.from(n),n.size?new xt(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=xt.from(n),n.size?new xt(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=xt.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},xt.from=function(n){if(n instanceof xt)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new xt(e)};function Mh(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=Mh(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function Oh(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,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++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=Oh(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class W{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;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,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-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 t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.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,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new W(r,i)}cutByIndex(e,t){return e==t?W.empty:e==0&&t==this.content.length?this:new W(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,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 t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return Mh(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Oh(this,e,t,r)}findIndex(e,t=-1){if(e==0)return Qo(0,e);if(e==this.size)return Qo(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||t>0?Qo(r+1,o):Qo(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,t){if(!t)return W.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new W(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return W.empty;let t,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)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new W(t||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 Rc={index:0,offset:0};function Qo(n,e){return Rc.index=n,Rc.offset=e,Rc}function el(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!el(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!el(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Ie=class wh{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,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))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&el(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);return r.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return wh.none;if(e instanceof wh)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};Ie.none=[];class tl extends Error{}class Y{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Nh(this.content,e+this.openStart,t);return r&&new Y(r,this.openStart,this.openEnd)}removeBetween(e,t){return new Y(_h(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return Y.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Y(W.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new Y(e,r,i)}}Y.empty=new Y(W.empty,0,0);function _h(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(_h(s.content,e-i-1,t-i-1)))}function Nh(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),o=n.maybeChild(i);if(s==e||o.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=Nh(o.content,e-s-1,t);return l&&n.replaceChild(i,o.copy(l))}function sw(n,e,t){if(t.openStart>n.depth)throw new tl("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new tl("Inconsistent open depths");return Dh(n,e,t,0)}function Dh(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let o=Dh(n,e,t,r+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return Zr(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=ow(t,n);return Zr(s,Lh(n,o,l,e,r))}else return Zr(s,nl(n,e,r))}function Rh(n,e){if(!e.type.compatibleContent(n.type))throw new tl("Cannot join "+e.type.name+" onto "+n.type.name)}function Lc(n,e,t){let r=n.node(t);return Rh(r,e.node(t)),r}function Yr(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Hs(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(Yr(n.nodeAfter,r),s++));for(let l=s;l<o;l++)Yr(i.child(l),r);e&&e.depth==t&&e.textOffset&&Yr(e.nodeBefore,r)}function Zr(n,e){return n.type.checkContent(e),n.copy(e)}function Lh(n,e,t,r,i){let s=n.depth>i&&Lc(n,e,i+1),o=r.depth>i&&Lc(t,r,i+1),l=[];return Hs(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(Rh(s,o),Yr(Zr(s,Lh(n,e,t,r,i+1)),l)):(s&&Yr(Zr(s,nl(n,e,i+1)),l),Hs(e,t,i,l),o&&Yr(Zr(o,nl(t,r,i+1)),l)),Hs(r,null,i,l),new W(l)}function nl(n,e,t){let r=[];if(Hs(null,n,t,r),n.depth>t){let i=Lc(n,e,t+1);Yr(Zr(i,nl(n,e,t+1)),r)}return Hs(e,null,t,r),new W(r)}function ow(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(W.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Vs{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return Ie.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);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 t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.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 t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new rl(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;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 Vs(t,r,s)}static resolveCached(e,t){for(let i=0;i<Ic.length;i++){let s=Ic[i];if(s.pos==t&&s.doc==e)return s}let r=Ic[Pc]=Vs.resolve(e,t);return Pc=(Pc+1)%lw,r}}let Ic=[],Pc=0,lw=12;class rl{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const aw=Object.create(null);let Xr=class Ch{constructor(e,t,r,i=Ie.none){this.type=e,this.attrs=t,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,t,r,i=0){this.content.nodesBetween(e,t,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,t,r,i){return this.content.textBetween(e,t,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,t,r){return this.type==e&&el(this.attrs,t||e.defaultAttrs||aw)&&Ie.sameSet(this.marks,r||Ie.none)}copy(e=null){return e==this.content?this:new Ch(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Ch(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return Y.empty;let i=this.resolve(e),s=this.resolve(t),o=r?0:i.sharedDepth(t),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,t,r){return sw(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return Vs.resolveCached(this,e)}resolveNoCache(e){return Vs.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,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()+")"),Ih(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=W.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,t);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,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,t);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=Ie.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!Ie.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=W.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,r)}};Xr.prototype.text=void 0;class il extends Xr{constructor(e,t,r,i){if(super(e,t,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):Ih(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new il(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new il(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Ih(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Qr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new cw(e,t);if(r.next==null)return Qr.empty;let i=Ph(r);r.next&&r.err("Unexpected trailing text");let s=gw(mw(i));return yw(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let s=t;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:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function s(o,l){let a=o.matchFragment(e,r);if(a&&(!t||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 t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let 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 t)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(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 cw{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Ph(n){let e=[];do e.push(uw(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function uw(n){let e=[];do e.push(dw(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function dw(n){let e=pw(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=fw(n,e);else break;return e}function Fh(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function fw(n,e){let t=Fh(n),r=t;return n.eat(",")&&(n.next!="}"?r=Fh(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function hw(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let o=t[s];o.groups.indexOf(e)>-1&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function pw(n){if(n.eat("(")){let e=Ph(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=hw(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function mw(n){let e=[[]];return i(s(n,0),t()),e;function t(){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=t())}else if(o.type=="star"){let a=t();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();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=t();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=t();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 Bh(n,e){return e-n}function $h(n,e){let t=[];return r(e),t.sort(Bh);function r(i){let s=n[i];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&r(a)}}}function gw(n){let e=Object.create(null);return t($h(n,0));function t(r){let i=[];r.forEach(o=>{n[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]);$h(n,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new Qr(r.indexOf(n.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Bh);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function yw(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],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 jh(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Hh(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function Vh(n){let e=Object.create(null);if(n)for(let t in n)e[t]=new bw(n[t]);return e}let zh=class Qv{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Vh(r.attrs),this.defaultAttrs=jh(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:Hh(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Xr(this,this.computeAttrs(e),W.from(t),Ie.setFrom(r))}createChecked(e=null,t,r){return t=W.from(t),this.checkContent(t),new Xr(this,this.computeAttrs(e),t,Ie.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=W.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(W.empty,!0);return s?new Xr(this,e,t.append(s),Ie.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:Ie.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,o)=>r[s]=new Qv(s,t,o));let i=t.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 bw{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class sl{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Vh(i.attrs),this.excluded=null;let s=jh(this.attrs);this.instance=s?new Ie(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Ie(this,Hh(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new sl(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}}class vw{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=xt.from(e.nodes),t.marks=xt.from(e.marks||{}),this.nodes=zh.compile(this.spec.nodes,this),this.marks=sl.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?Uh(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==""?[]:Uh(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,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof zh){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new il(r,r.defaultAttrs,e,Ie.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Xr.fromJSON(this,e)}markFromJSON(e){return Ie.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Uh(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],s=n.marks[i],o=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function ww(n){return n.tag!=null}function Cw(n){return n.style!=null}let Fc=class xh{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach(r=>{ww(r)?this.tags.push(r):Cw(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,t={}){let r=new Jh(this,t,!1);return r.addAll(e,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Jh(this,t,!0);return r.addAll(e,t.from,t.to),Y.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(Sw(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,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)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Gh(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=Gh(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new xh(e,xh.schemaRules(e)))}};const Wh={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},xw={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},qh={ol:!0,ul:!0},ol=1,ll=2,zs=4;function Kh(n,e,t){return e!=null?(e?ol:0)|(e==="full"?ll:0):n&&n.whitespace=="pre"?ol|ll:t&~zs}class al{constructor(e,t,r,i,s,o,l){this.type=e,this.attrs=t,this.marks=r,this.pendingMarks=i,this.solid=s,this.options=l,this.content=[],this.activeMarks=Ie.none,this.stashMarks=[],this.match=o||(l&zs?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(W.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);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&ol)){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 t=W.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(W.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,r=this.pendingMarks;t<r.length;t++){let i=r[t];(this.type?this.type.allowsMarkType(i.type):Ew(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&&!Wh.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Jh{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0;let i=t.topNode,s,o=Kh(null,t.preserveWhitespace,0)|(r?zs:0);i?s=new al(i.type,i.attrs,Ie.none,Ie.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new al(null,null,Ie.none,Ie.none,!0,null,o):s=new al(e.schema.topNodeType,null,Ie.none,Ie.none,!0,null,o),this.nodes=[s],this.find=t.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,t){let r=e.style;if(!r||!r.length)return t();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]);t();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 t=e.nodeValue,r=this.top;if(r.options&ll||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(r.options&ol)r.options&ll?t=t.replace(/\r\n?/g,`
32
- `):t=t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&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))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)}addElement(e,t){let r=e.nodeName.toLowerCase(),i;qh.hasOwnProperty(r)&&this.parser.normalizeLists&&kw(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,t));if(s?s.ignore:xw.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(Wh.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 t=Ie.none,r=Ie.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))}):t=this.parser.schema.marks[a.mark].create(a.attrs).addToSet(t),a.consuming===!1)l=a;else break}}return[t,r]}addElementByRule(e,t,r){let i,s,o;t.node?(s=this.parser.schema.nodes[t.node],s.isLeaf?this.insertNode(s.create(t.attrs))||this.leafFallback(e):i=this.enter(s,t.attrs||null,t.preserveWhitespace)):(o=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(o));let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a)}i&&this.sync(l)&&this.open--,o&&this.removePendingMark(o,l)}addAll(e,t,r){let i=t||0;for(let s=t?e.childNodes[t]: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 t,r;for(let i=this.open;i>=0;i--){let s=this.nodes[i],o=s.findWrapping(e);if(o&&(!t||t.length>o.length)&&(t=o,r=s,!o.length)||s.solid)break}if(!t)return!1;this.sync(r);for(let i=0;i<t.length;i++)this.enterInner(t[i],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&this.enterInner(t)}if(this.findPlace(e)){this.closeExtra();let t=this.top;t.applyPending(e.type),t.match&&(t.match=t.match.matchType(e.type));let r=t.activeMarks;for(let i=0;i<e.marks.length;i++)(!t.type||t.type.allowsMarkType(e.marks[i].type))&&(r=e.marks[i].addToSet(r));return t.content.push(e.mark(r)),!0}return!1}enter(e,t,r){let i=this.findPlace(e.create(t));return i&&this.enterInner(e,t,!0,r),i}enterInner(e,t=null,r=!1,i){this.closeExtra();let s=this.top;s.applyPending(e),s.match=s.match&&s.match.matchType(e);let o=Kh(e,i,s.options);s.options&zs&&s.content.length==0&&(o|=zs),this.nodes.push(new al(e,t,s.activeMarks,s.pendingMarks,r,null,o)),this.open++}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,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=t[l];if(c==""){if(l==t.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(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let t=Tw(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){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==t)break}}}function kw(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&qh.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Sw(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Gh(n){let e={};for(let t in n)e[t]=n[t];return e}function Ew(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))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 Tw(n,e){for(let t=0;t<e.length;t++)if(n.eq(e[t]))return e[t]}class _n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Bc(t).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,t);u&&(s.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=_n.renderSpec(Bc(t),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,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&_n.renderSpec(Bc(r),i(e,t))}static renderSpec(e,t,r=null){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[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=t[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<t.length;u++){let d=t[u];if(d===0){if(u<t.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}=_n.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 _n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Yh(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Yh(e.marks)}}function Yh(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Bc(n){return n.document||window.document}const Zh=65535,Xh=Math.pow(2,16);function Aw(n,e){return n+e*Xh}function Qh(n){return n&Zh}function Mw(n){return(n-(n&Zh))/Xh}const ep=1,tp=2,cl=4,np=8;class $c{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&np)>0}get deletedBefore(){return(this.delInfo&(ep|cl))>0}get deletedAfter(){return(this.delInfo&(tp|cl))>0}get deletedAcross(){return(this.delInfo&cl)>0}}class Kt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Kt.empty)return Kt.empty}recover(e){let t=0,r=Qh(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+Mw(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let 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:t:t,h=a+i+(f<0?0:u);if(r)return h;let p=e==(t<0?a:d)?null:Aw(l/3,e-a),g=e==a?tp:e==d?ep:cl;return(t<0?e!=a:e!=d)&&(g|=np),new $c(h,g,p)}i+=u-c}return r?e+i:new $c(e+i,0,null)}touches(e,t){let r=0,i=Qh(t),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 t=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+t],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 Ri{constructor(e=[],t,r=0,i=e.length){this.maps=e,this.mirror=t,this.from=r,this.to=i}slice(e=0,t=this.maps.length){return new Ri(this.maps,this.mirror,e,t)}copy(){return new Ri(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,r=this.maps.length;t<e.maps.length;t++){let i=e.getMirror(t);this.appendMap(e.maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this.maps.length+e.maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new Ri;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this.maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this.maps[s],l=o.mapResult(e,t);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 $c(e,i,null)}}const jc=Object.create(null);class Tt{getMap(){return Kt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=jc[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in jc)throw new RangeError("Duplicate use of step JSON ID "+e);return jc[e]=t,t.prototype.jsonID=e,t}}class ot{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new ot(e,null)}static fail(e){return new ot(null,e)}static fromReplace(e,t,r,i){try{return ot.ok(e.replace(t,r,i))}catch(s){if(s instanceof tl)return ot.fail(s.message);throw s}}}function Hc(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(Hc(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return W.fromArray(r)}class wr extends Tt{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new Y(Hc(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return ot.fromReplace(e,this.from,this.to,s)}invert(){return new Nn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new wr(t.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,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new wr(t.from,t.to,e.markFromJSON(t.mark))}}Tt.jsonID("addMark",wr);class Nn extends Tt{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new Y(Hc(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return ot.fromReplace(e,this.from,this.to,r)}invert(){return new wr(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Nn(t.pos,r.pos,this.mark)}merge(e){return e instanceof Nn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Nn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Nn(t.from,t.to,e.markFromJSON(t.mark))}}Tt.jsonID("removeMark",Nn);class Cr extends Tt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ot.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ot.fromReplace(e,this.pos,this.pos+1,new Y(W.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new Cr(this.pos,t.marks[i]);return new Cr(this.pos,this.mark)}}return new Li(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Cr(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Cr(t.pos,e.markFromJSON(t.mark))}}Tt.jsonID("addNodeMark",Cr);class Li extends Tt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ot.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ot.fromReplace(e,this.pos,this.pos+1,new Y(W.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Cr(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Li(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Li(t.pos,e.markFromJSON(t.mark))}}Tt.jsonID("removeNodeMark",Li);class ht extends Tt{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&Vc(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 t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new ht(t.pos,Math.max(t.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 t=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),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=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,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ht(t.from,t.to,Y.fromJSON(e,t.slice),!!t.structure)}}Tt.jsonID("replace",ht);class pt extends Tt{constructor(e,t,r,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Vc(e,this.from,this.gapFrom)||Vc(e,this.gapTo,this.to)))return ot.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ot.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.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 t=this.gapTo-this.gapFrom;return new pt(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new pt(t.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,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new pt(t.from,t.to,t.gapFrom,t.gapTo,Y.fromJSON(e,t.slice),t.insert,!!t.structure)}}Tt.jsonID("replaceAround",pt);function Vc(n,e,t){let r=n.resolve(e),i=t-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 Ow(n,e,t,r){let i=[],s=[],o,l;n.doc.nodesBetween(e,t,(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,t),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 Nn(f,h,d[g])));l&&l.to==f?l.to=h:s.push(l=new wr(f,h,r))}}),i.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function _w(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof sl){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,t);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=>n.step(new Nn(o.from,o.to,o.style)))}function rp(n,e,t,r=t.contentMatch,i=!0){let s=n.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++)t.allowsMarkType(c.marks[f].type)||n.step(new Nn(l,u,c.marks[f]));if(i&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new Y(W.from(t.schema.text(" ",t.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);n.replace(l,l,new Y(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function Nw(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Ii(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),s=n.$from.index(r),o=n.$to.indexAfter(r);if(r<n.depth&&i.canReplace(s,o,t))return r;if(r==0||i.type.spec.isolating||!Nw(i,s,o))break}return null}function Dw(n,e,t){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>t;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>t;p--)g||i.after(p+1)<i.end(p)?(g=!0,f=W.from(i.node(p).copy(f)),h++):c++;n.step(new pt(a,c,o,l,new Y(u.append(f),d,h),u.size-d,!0))}function zc(n,e,t=null,r=n){let i=Rw(n,e),s=i&&Lw(r,e);return s?i.map(ip).concat({type:e,attrs:t}).concat(s.map(ip)):null}function ip(n){return{type:n,attrs:null}}function Rw(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(r,i,o)?s:null}function Lw(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.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(t.child(c).type);return!a||!a.validEnd?null:o}function Iw(n,e,t){let r=W.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[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(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new pt(i,s,i,s,new Y(r,0,0),t.length,!0))}function Pw(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{if(o.isTextblock&&!o.hasMarkup(r,i)&&$w(n.doc,n.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&&Bw(n,o,l,s),rp(n,n.mapping.slice(s).map(l,1),r,void 0,a===null);let c=n.mapping.slice(s),u=c.map(l,1),d=c.map(l+o.nodeSize,1);return n.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&&Fw(n,o,l,s),!1}})}function Fw(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Bw(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
34
- `))}})}function $w(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function jw(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new pt(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new Y(W.from(o),0,0),1,!0))}function Pi(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,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=t-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 Hw(n,e,t=1,r){let i=n.doc.resolve(e),s=W.empty,o=W.empty;for(let l=i.depth,a=i.depth-t,c=t-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))}n.step(new ht(e,e,new Y(s.append(o),t,t),!0))}function xr(n,e){let t=n.resolve(e),r=t.index();return sp(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function sp(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function ul(n,e,t=-1){let r=n.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):t>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&&sp(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function Vw(n,e,t){let r=new ht(e-t,e+t,Y.empty,!0);n.step(r)}function zw(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))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,t))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function op(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.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 dl(n,e,t=e,r=Y.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return lp(i,s,r)?new ht(e,t,r):new Uw(i,s,r).fit()}function lp(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Uw{constructor(e,t,r){this.$from=e,this.$to=t,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(),t=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,t):a.size||r.pos!=this.$to.pos?new ht(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Uc(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(t==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(t==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:t,openEnd:r}=this.unplaced,i=Uc(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Y(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Uc(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new Y(Us(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new Y(Us(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)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[t];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(ap(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=Ws(this.placed,t,W.from(u)),this.frontier[t].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(Us(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new Y(Us(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Wc(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Wc(e,t,i,r,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Wc(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Ws(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.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,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Ws(this.placed,this.depth,W.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(W.empty,!0);t.childCount&&(this.placed=Ws(this.placed,this.frontier.length,t))}}function Us(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Us(n.firstChild.content,e-1,t)))}function Ws(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Ws(n.lastChild.content,e-1,t)))}function Uc(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function ap(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,ap(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(W.empty,!0)))),n.copy(r)}function Wc(n,e,t,r,i){let s=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!Ww(t,s.content,o)?l:null}function Ww(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function qw(n){return n.spec.defining||n.spec.definingForContent}function Kw(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(lp(i,s,r))return n.step(new ht(e,t,r));let o=up(i,n.doc.resolve(t));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=qw(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),C=i.index(v-1);if(S.canReplaceWith(C,C,p.type,p.marks))return n.replace(i.before(v),w?s.after(v):t,new Y(cp(r.content,0,r.openStart,h),h,r.openEnd))}}let d=n.steps.length;for(let f=o.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>d));f--){let h=o[f];h<0||(e=i.before(h),t=s.after(h))}}function cp(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(cp(s.content,e+1,t,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(W.empty,!0))}return n}function Jw(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=zw(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new Y(W.from(r),0,0))}function Gw(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),s=up(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 n.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 n.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&&t>r.end(o)&&i.end(o)-t!=i.depth-o)return n.delete(r.before(o),t);n.delete(e,t)}function up(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(s<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class Fi extends Tt{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return ot.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return ot.fromReplace(e,this.pos,this.pos+1,new Y(W.from(i),0,t.isLeaf?0:1))}getMap(){return Kt.empty}invert(e){return new Fi(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Fi(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Fi(t.pos,t.attr,t.value)}}Tt.jsonID("attr",Fi);class qs extends Tt{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return ot.ok(r)}getMap(){return Kt.empty}invert(e){return new qs(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new qs(t.attr,t.value)}}Tt.jsonID("docAttr",qs);let Bi=class extends Error{};Bi=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},Bi.prototype=Object.create(Error.prototype),Bi.prototype.constructor=Bi,Bi.prototype.name="TransformError";class qc{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ri}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Bi(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=Y.empty){let i=dl(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new Y(W.from(r),0,0))}delete(e,t){return this.replace(e,t,Y.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Kw(this,e,t,r),this}replaceRangeWith(e,t,r){return Jw(this,e,t,r),this}deleteRange(e,t){return Gw(this,e,t),this}lift(e,t){return Dw(this,e,t),this}join(e,t=1){return Vw(this,e,t),this}wrap(e,t){return Iw(this,e,t),this}setBlockType(e,t=e,r,i=null){return Pw(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return jw(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new Fi(e,t,r)),this}setDocAttribute(e,t){return this.step(new qs(e,t)),this}addNodeMark(e,t){return this.step(new Cr(e,t)),this}removeNodeMark(e,t){if(!(t instanceof Ie)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new Li(e,t)),this}split(e,t=1,r){return Hw(this,e,t,r),this}addMark(e,t,r){return Ow(this,e,t,r),this}removeMark(e,t,r){return _w(this,e,t,r),this}clearIncompatible(e,t,r){return rp(this,e,t,r),this}}const Kc=Object.create(null);class ue{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Jc(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Y.empty){let r=t.content.lastChild,i=null;for(let l=0;l<t.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:t),l==0&&hp(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){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,t),hp(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new ce(e):$i(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?$i(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):$i(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new yn(e.node(0))}static atStart(e){return $i(e,e,0,0,1)||new yn(e)}static atEnd(e){return $i(e,e,e.content.size,e.childCount,-1)||new yn(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Kc[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Kc)throw new RangeError("Duplicate use of selection JSON ID "+e);return Kc[e]=t,t.prototype.jsonID=e,t}getBookmark(){return ce.between(this.$anchor,this.$head).getBookmark()}}ue.prototype.visible=!0;class Jc{constructor(e,t){this.$from=e,this.$to=t}}let dp=!1;function fp(n){!dp&&!n.parent.inlineContent&&(dp=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class ce extends ue{constructor(e,t=e){fp(e),fp(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return ue.near(r);let i=e.resolve(t.map(this.anchor));return new ce(i.parent.inlineContent?i:r,r)}replace(e,t=Y.empty){if(super.replace(e,t),t==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 fl(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ce(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=ue.findFrom(t,r,!0)||ue.findFrom(t,-r,!0);if(s)t=s.$head;else return ue.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(ue.findFrom(e,-r,!0)||ue.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new ce(e,t)}}ue.jsonID("text",ce);class fl{constructor(e,t){this.anchor=e,this.head=t}map(e){return new fl(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 t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.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 Gc(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new se(e.resolve(t.anchor))}static create(e,t){return new se(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}se.prototype.visible=!1,ue.jsonID("node",se);class Gc{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new fl(r,r):new Gc(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&se.isSelectable(r)?new se(t):ue.near(t)}}class yn extends ue{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Y.empty){if(t==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,t)}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 Yw}}ue.jsonID("all",yn);const Yw={map(){return this},resolve(n){return new yn(n)}};function $i(n,e,t,r,i,s=!1){if(e.inlineContent)return ce.create(n,t);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(n,t-(i<0?l.nodeSize:0))}else{let a=$i(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function hp(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof ht||i instanceof pt))return;let s=n.mapping.maps[r],o;s.forEach((l,a,c,u)=>{o==null&&(o=u)}),n.setSelection(ue.near(n.doc.resolve(o),t))}const pp=1,hl=2,mp=4;let Zw=class extends qc{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|pp)&~hl,this.storedMarks=null,this}get selectionSet(){return(this.updated&pp)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=hl,this}ensureMarks(e){return Ie.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&hl)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~hl,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Ie.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,s)),this.selection.empty||this.setSelection(ue.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=mp,this}get scrolledIntoView(){return(this.updated&mp)>0}};function gp(n,e){return!e||!n?n:n.bind(e)}class Ks{constructor(e,t,r){this.name=e,this.init=gp(t.init,r),this.apply=gp(t.apply,r)}}const Xw=[new Ks("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Ks("selection",{init(n,e){return n.selection||ue.atStart(e.doc)},apply(n){return n.selection}}),new Ks("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Ks("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Yc{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Xw.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Ks(r.key,r.spec.state,r))})}}class ji{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let 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 t=[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<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,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:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),s=!0}i&&(i[o]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new ji(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new Zw(this)}static create(e){let t=new Yc(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new ji(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new Yc(this.schema,e.plugins),r=t.fields,i=new ji(t);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 t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Yc(e.schema,e.plugins),s=new ji(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Xr.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=ue.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=c.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function yp(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=yp(i,e,{})),t[r]=i}return t}class je{constructor(e){this.spec=e,this.props={},e.props&&yp(e.props,this,this.props),this.key=e.key?e.key.key:bp("plugin")}getState(e){return e[this.key]}}const Zc=Object.create(null);function bp(n){return n in Zc?n+"$"+ ++Zc[n]:(Zc[n]=0,n+"$")}class We{constructor(e="key"){this.key=bp(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const kt=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Js=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Xc=null;const er=function(n,e,t){let r=Xc||(Xc=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Qw=function(){Xc=null},ei=function(n,e,t,r){return t&&(vp(n,e,t,r,-1)||vp(n,e,t,r,1))},e2=/^(img|br|input|textarea|hr)$/i;function vp(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Dn(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Gs(n)||e2.test(n.nodeName)||n.contentEditable=="false")return!1;e=kt(n)+(i<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?Dn(n):0}else return!1}}function Dn(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function t2(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Dn(n)}else if(n.parentNode&&!Gs(n))e=kt(n),n=n.parentNode;else return null}}function n2(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Gs(n))e=kt(n)+1,n=n.parentNode;else return null}}function r2(n,e,t){for(let r=e==0,i=e==Dn(n);r||i;){if(n==t)return!0;let s=kt(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,i=i&&s==Dn(n)}}function Gs(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const pl=function(n){return n.focusNode&&ei(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function ti(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function i2(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function s2(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:r.offset}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:r.startOffset}}}const Rn=typeof navigator<"u"?navigator:null,wp=typeof document<"u"?document:null,kr=Rn&&Rn.userAgent||"",Qc=/Edge\/(\d+)/.exec(kr),Cp=/MSIE \d/.exec(kr),eu=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(kr),$t=!!(Cp||eu||Qc),Sr=Cp?document.documentMode:eu?+eu[1]:Qc?+Qc[1]:0,bn=!$t&&/gecko\/(\d+)/i.test(kr);bn&&+(/Firefox\/(\d+)/.exec(kr)||[0,0])[1];const tu=!$t&&/Chrome\/(\d+)/.exec(kr),_t=!!tu,o2=tu?+tu[1]:0,Nt=!$t&&!!Rn&&/Apple Computer/.test(Rn.vendor),Hi=Nt&&(/Mobile\/\w+/.test(kr)||!!Rn&&Rn.maxTouchPoints>2),rn=Hi||(Rn?/Mac/.test(Rn.platform):!1),l2=Rn?/Win/.test(Rn.platform):!1,vn=/Android \d/.test(kr),Ys=!!wp&&"webkitFontSmoothing"in wp.documentElement.style,a2=Ys?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function c2(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function tr(n,e){return typeof n=="number"?n:n[e]}function u2(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function xp(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=t||n.dom;o;o=Js(o)){if(o.nodeType!=1)continue;let l=o,a=l==s.body,c=a?c2(s):u2(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 d2(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=n.root.elementFromPoint(s,o);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:kp(n.dom)}}function kp(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Js(r));return e}function f2({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Sp(t,r==0?0:r-e)}function Sp(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:s}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let Vi=null;function h2(n){if(n.setActive)return n.setActive();if(Vi)return n.focus(Vi);let e=kp(n);n.focus(Vi==null?{get preventScroll(){return Vi={preventScroll:!0},!0}}:void 0),Vi||(Vi=!1,Sp(e,0))}function Ep(n,e){let t,r=2e8,i,s=0,o=e.top,l=e.top,a,c;for(let u=n.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){t=u,r=g,i=g&&t.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});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=d+1)}}return!t&&a&&(t=a,i=c,r=0),t&&t.nodeType==3?p2(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:Ep(t,i)}function p2(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let s=Er(r,1);if(s.top!=s.bottom&&nu(e,s))return{node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function nu(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function m2(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function g2(n,e,t){let{node:r,offset:i}=Ep(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,i,s)}function y2(n,e,t,r){let i=-1;for(let s=e,o=!1;s!=n.dom;){let l=n.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:n.docView.posFromDOM(e,t,-1)}function Tp(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let o=n.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(nu(e,c))return Tp(o,e,c)}}if((s=(s+1)%r)==i)break}return n}function b2(n,e){let t=n.dom.ownerDocument,r,i=0,s=s2(t,e.left,e.top);s&&({node:r,offset:i}=s);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!o||!n.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=n.dom.getBoundingClientRect();if(!nu(e,c)||(o=Tp(n.dom,e,c),!o))return null}if(Nt)for(let c=o;r&&c;c=Js(c))c.draggable&&(r=void 0);if(o=m2(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;Ys&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=y2(n,r,i,e))}l==null&&(l=g2(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ap(n){return n.top<n.bottom||n.left<n.right}function Er(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Ap(r))return r}return Array.prototype.find.call(t,Ap)||n.getBoundingClientRect()}const v2=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Mp(n,e,t){let{node:r,offset:i,atom:s}=n.docView.domFromPos(e,t<0?-1:1),o=Ys||bn;if(r.nodeType==3)if(o&&(v2.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let a=Er(er(r,i,i),t);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 Zs(u,u.left<c.left)}}return a}else{let a=i,c=i,u=t<0?1:-1;return t<0&&!i?(c++,u=-1):t>=0&&i==r.nodeValue.length?(a--,u=1):t<0?a--:c++,Zs(Er(er(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==Dn(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return ru(a.getBoundingClientRect(),!1)}if(s==null&&i<Dn(r)){let a=r.childNodes[i];if(a.nodeType==1)return ru(a.getBoundingClientRect(),!0)}return ru(r.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==Dn(r))){let a=r.childNodes[i-1],c=a.nodeType==3?er(a,Dn(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Zs(Er(c,1),!1)}if(s==null&&i<Dn(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 Zs(Er(c,-1),!0)}return Zs(Er(r.nodeType==3?er(r):r,-t),t>=0)}function Zs(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function ru(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Op(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function w2(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Op(n,e,()=>{let{node:s}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Mp(n,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&&(t=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const C2=/[\u0590-\u08ac]/;function x2(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=n.domSelection();return!C2.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Op(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:g}=n.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 _p=null,Np=null,Dp=!1;function k2(n,e,t){return _p==e&&Np==t?Dp:(_p=e,Np=t,Dp=t=="up"||t=="down"?w2(n,e,t):x2(n,e,t))}const sn=0,Rp=1,ni=2,Ln=3;class Xs{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=sn,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let i=this.children[t];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,t,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[t-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[t];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=t>kt(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(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==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,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!t||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 t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],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,t){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 Pp){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Lp&&s.side>=0;r--);if(t<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?kt(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,t):{node:this.contentDOM,offset:s?kt(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let 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&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,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=kt(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){s=kt(d.dom);break}t+=d.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,i=!1){let s=Math.min(e,t),o=Math.max(e,t);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,t-h-p.border,r,i);h=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.getSelection(),u=!1;if((bn||Nt)&&e==t){let{node:f,offset:h}=l;if(f.nodeType==3){if(u=!!(h&&f.nodeValue[h-1]==`
30
+ <%s key={someKey} {...props} />`,vh,Di,DL,Di),Zv[Di+vh]=!0}}return L===r?AL(ct):TL(ct),ct}}function ML(L,K,Q){return Xv(L,K,Q,!0)}function OL(L,K,Q){return Xv(L,K,Q,!1)}var _L=OL,NL=ML;js.Fragment=r,js.jsx=_L,js.jsxs=NL}()),js}process.env.NODE_ENV==="production"?Dc.exports=tw():Dc.exports=nw();var D=Dc.exports;const rw="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAACXBIWXMAACE4AAAhOAFFljFgAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAA9fSURBVHgB7Z0LmFRlGcf/75nZ2ZnZXZA7BOyFS7BiKYhAGZYpGSlqaKWCyZNWmima5VOWPZh000zxbiZikFgaPeI1NUsMVFxBBQQV2AVWQK7K7s7MzuW8vd8Zgb3NMrs75zZ7fs9z5lzmzMyZ73++9/u+9/u+9xBcDlcjiECoH5IoRZLLAd8x0LgShKFg9JZTjpKlWPZ9sk/Gh0i2WD4B1Mv2Plnvl+VDeeMdOb4Omr4R9bwN0dgOGo8EXAzBZfDfRagJ4WMB7Rwwj5cjlSLKQPknBcglLMIS9kgSrZGdV5Di57Et+gadjBhchCsE5trQEDRq35Cc+RXZO0kuOwx7iMjvrwTTCyjkv9Dg6DY4HMcKbJheKr4Y0M+XnDpOLjUEJ8HcCKIqua4HENOWUmXdXjgQRwnMVWJm+wcnIUU/kMQ7W8xkEO4gJtf6FHz6bVQW+x8chCMEZpZytSZ4oZSrl8juRFn8cC+vSbLei/KGh0hV5mzGVoH5A4SRCM+SzcskKY5BPkFYK8sd2B1ZJDXxCGzCNoG5JjxVRL1eNifBJZW9TqBy8Gr5d7+g8sgzsAHLE5bfLToWQf4VdJyJ7kNclmclteeI0KthIZYJzLv7lqAucpX84uWyOwDdERZnioa7kAjOo5H7DsACLBGYt4bHS469Tf7gifBQqb4cpH2fyurXwWQ0mIjUjjWuDl2JlDQhPHEPo9JC15ertOE55mpgWg7mdf2KEa6/X37iPHhkQvnDF6IxPJtG76mDCZgisNSQx0r2fUS+/tPwyAJ6H4HkNBrc+C5yTM4FFrMjzR56Qjb7wiN7mOqg0dlUXv8ickhO7T9vDp0rqxfgidtxiEvA+lLeHJ6GHJIzgXlT0QzxHy+SKy2CR2cpEpu6lGuCM5hzY127LLC6EK4uvlLqyyIuCuHRdVhbgOrQD5EDunyXGDlX4wVwdweBMyF9BpXHHkYX6JLARnkhJgUeZtEoJnImDYs+hk7SaYG5tvjLSKSWemWu2XCDvJxKFdFX0Qk6JTBXB0YDBdLvyT3gYQV7Rakpnemo6HAly+g0YP8TnriW0kfayY8Y3sEO0iGBlW8Z9ZF5cjeNgIfF8KdRVP+njvquO2SijY4D0C3wasw2wrOlPL4927OzFpjfLx4DPy+XrZ7wsJNd8OF0Ko1UZXNyVtmdN6AEfv0+T1xH0F/1rfMGqQtlQXb2PBC+Sl69/lynoPqTCyJXZ3PqEU10uusPasCY64fZ3L0wiWQKtlA5Qto5X/AhZ6jhP0SnUUXDW+2ddmSBq8OPyyovBsgVHR1BJApbOPNUHx6/P+eu+qVUETmrvRParQ1zTeFUsfdT821Q66xzfQgUWPOnNmxiLFtpmtk4kzcWTqURjRmH5GYU2BiUHvfNzfmsPQdwy88D6H2UNQI/+nTKTIEBn+96rsJLmQbXZ87ByfBMeR0LF7L/I0Ysnvn9HbsZjXGYxqD+lpq8SeirZodE7m7rzTYFNjqbq3GFvLrSOJ/5vUa8vV5vdfxg+Ttpesy0oYyfGkBY868Q/DmsTx0BpdFlotl9RGhlKtrOwTVFF0k3vmvnCtXVMw7UAz2KCYEm9Zq+Zg5HkPtpz36W34T1qHldxuS92IKWb2Uw0Xwp8oAl9wUw6ThThx0fYnMt47On2Tj5n7SLJRcvklycbHq4lcC8tWQyUqmJyAOChYSisDWlTLFdMQcOwlIWbyv5nNivl5sebp2D9eRst0z2u3tRAq+/3XoK7pbt6fXcOxIYaFKFp6QI+P1PAwg5ZxSaX7S7TNaZBeaqkr7g5OlwCf99RTeaIZl49iXzmie9ehLm/ohFYAdlBqbpKvQFVRwOFNM8B/fSp0nudUvYhENcfqEfJ3/emmrrgTrG968zsY3VNQpB4e80bTI1F1jji+FCJo314ZyvWiPwrr2MAme7fs6XpbXAvClYKqvxcCDbP2TUfNC6rK3dkT62dTtjxSodZnFcJSEccolLgHG8CjtFQ6K1avdwDvZpM+VNRw5c//29Sdy+IHPAuZ//wTyTWRgAViwJYtwY1/h8Qkho35D1rWrnsMBMU2B/UJh26duLMGSgdQm9fpN5VsFUWAWMayIwv69yrj7B6c2jqy/247rLrSkAG8R1P+HsKDZtcfZN3yaEk1TIR/omUmk3D4XG2xge0CP3hNPxPA+aaJ8yz/az5NkUrv1d6/J05670+tb5Scx/NAmzePDmQkw+wRrXpgWcI8uqtMCMzzvBOqs2Znsmcc8+lgWmYddoD1NgnKBWfiM+JDkrytzUL/lw83XWNTZnXRNH1RqXVqgywaiUzoegH4NCAxF31oz8o3oAY0ZaZyqL8rH2QeiP7aF+fiNSOqwdlvNeNWPx0tZl6ap16Vy0ZoOOG+aZF2h9uni9PjMqb8raTASUtlIGayOsbv++X61jzm2ZBVz7HstinsDDS6k7CKwiBZT7kZLy16YKVtkQwvnTrJvm9MS/U1j3Xp6Vte0h2qrUrYRNjCzT8NtrrSsdtn+oi8DoPmhcqclL9wwM2h0gDNXEb9kbHvkJo7fUNKgXPPITpl6qKpnVNEQPF0JcpAS2boi2h9X4lcD5+rwED5gcENzDfjQ44Nk+mdi7n1G7k9VcqTZRx9W4LDVlxKNNWJpJsGnOe/v8aXESo0+JoWJyFDOuiiPVwgGli6azb4hj1JdjGPHFGO58yLx+YheTVCa6Hg5DiXftbxNGzkyKbqpj4rllze/DF1ekcIeIGokxPpZ+5J/dFEfNNi8nt6BeBOaP4DBUra+xsblYeosc3Ngo5zWpHqqzNa890BzGfimDycQxEp1DCXfzdYFDAh53tIZTTmxeHzz1Cz6cNcV36PwrLipA6afsbxDE5Mb7x9NJPPZ0ylheW21j54aGfX5RWT0Ddxwcxg8v8uOkiRrqG4BjK8mYKdgUNV558e0BvLWeEZDto0c6o0GgipXzrnTM1Jadfrn935Hq6FlwIJ8d3b5oSvSJxzmrGa+mtZw71QetxaWPO8aG8kPnDaq70PSnb3UnBvQh/OWPhVaGcMgMaWulwz+1pdXt5hBU/20kSkYZa+RTQrNtY9VkrTZVABS/RWMI4on0olBlr+PQ9I1+BGkL4lCX6bg5c+dLWfbmO3xYzE9e2jLKSuDePYFlfw8agVDMZv/HjHFnHA7Z4MAGWhx+bPUjHt0NhHfKgaFwGEMHaVi2MnsHxhA5f0A/68rkbTvaltUhtYK92BHdqaVng9MGOJBrL+2Yrb3gLD98FpU2R/Ug7HszhNTmcLNl64oQfE4of5nW0ngk0smhc1axh61G1aIvnZGdyGPHaPjetywMTkUwbiaNmi/klEo98Qq1+mRuEh6TQuRncCC3Xh8wotI9mGFOkkrQ44/R8Nd5hejdK/epq6LT3nRv4pATpSEKJBLpdrijSfHzapUWeGXkLUwIR0Rkx43xDxYC828KYPppPtz2YBJVa1L4+ED6+KhhmhGfY+Z0v2nRblIi8N+edGR/THtEsC36htowBFbzSLkay2Tzq3AoZ5ziMxaFikMZKEibRLNR5emPv1uAwS0mnqsbqrjIqWMleCWdnI6006SA4+dEascK3JSgheZROSy+eYYP48a4aGwE0wsHNw8LnMSj0hL+tZjpELop6zfqGNQvva3K2pTrLLNBI1hfeHDnkMA0MlrLNeFV6MbPZrj6xtadBI6vTLWEUEXDY1sP7jZvg+hYLCd0W4GHlRIK/K17rRzqyW2bFD3QdLe5wBR5ABy+RUTuls8BvvvGQpx2kovHIbJUrOJas6fBNvs3hleL6Z/wcCtPUWXd3qYHWruJUql7xCadizx+fN1PfpfAzfcfdpx8sCNfxnLp81oeaS3igdgr6BN+DXlc2dq5i40lz3iNhsVebnmwlcDKQc3V9Gcx6Hkr8NxrCjBlcmu/dcUQN0/y0O9t62jbZri8YSGqw9c4LfpOrigbTJhwbB5N6iCsRVnsobbealNg9fQO3gx1R9wBE7s3392s4w/3Wzdg/d3qvBw3zeKkupMyzFDJXJEqiMxHKnyBESTNJFSH+U9+49jg2m5hNUI9F6Lt52JlFpiGIso1qbnibn8aOWbUcM0YFmsXw8vyxDwzEtBSv6DBOyKZTulWD6fMOzQspbL2H0555FvZT9fL64fwcBbq8bJx3HCk044oMA1teFu+7C54OI27aGRk1ZFOyq4w2hWZJ8Z8OTycwnLsCs7L5sSsm0C8KXyC3A5PQj1D3sNG6GMk6UQaWZ/VjJSsq5M0PPK6yPxreNiJOA30X2YrrqJj7YXy6J3Q+RF42MVCPCQadIAOe6l4HYoRDlXJR0fBwzoYG6XcPZ4m7TvQkY91yg3JNeGx8oNq3G0feJgP0QE0JibSqHiHZ6B0yqVD5ZHVIvMZsjTAw2Qkjf2pr3dGXEWnfXZUEX1VcvEsqFF8HubBdAENib2ITtIlpywNiz4GnVz5QEsXkBTTPJOGRZaiC3TZ607DG/4qt9ls44I8cofGP0JZw8PoIjnp62WW79lcdIFc1CJ4dJVGybnfofKui6vIaWc+bwlPk3byYvnaInh0hgbJLbOMoi9H5Hy0Bm8qOkVy8hLZ7AGPjrBHUm+aUXnNIaYMx+HqwGiw7wkxNSPgkQX0HojPSzc/c4spQxuoQtps8agKrvYgvMpX+5AUaY2h8WaIqzBt7AqNRh3KI5dIfr5G2ssdcq91Cxi7jdbHguhMGr2nDiZhyUBg3lI8Brp+H7rxzMVm6FiBAsym0ojpsVEsG+nNu/uWoC5ylfzi5bLbPZ/VpIbZaLgLieA8GrnPEqtm+VD+Tzoq5sjmVDgw+JqJiEeKfkkVDW/BQmybqyFCf02EvlE2x9p5HSajXECvyHquVKKegQ3YmrBchTD6hGdKMlyRd9NkGGvFHN+Dgp4L2hu3bDaOyDk8R5LiouC3pVJ/qexOhHuRDgJILxs9oOZ3qSlAsBnHmUbeHJwsQs+WKztddoNwAyz+Y42WQE/dg32xV9UMTTgEx5Z9XFvSB3piGlLaJZKA450XVoKjknyr5LoeBvefTxU1MTgQV1RueFOwFKRdKK7PU8XzM8G2iHwEFQ1wmfSBP4dC/VEaEq2Fw3Fd7ZX/I2Z7aOh4+GiKXP7n5MhnJNH7yj/JbZNLTewi7JTfWC89PFXinFiCVZE3VVRAuAjXN08k6QswKDRQqjel0LUR0PQxSNHRUm0bkH42stZLzlJPWFVT+pv+36RUhhpA+n45rJ48s80QU02mJr1G5N2K4QN2EznT9GbL/wFLC+Kh6JIF9QAAAABJRU5ErkJggg==",iw=({metaData:n,setMetaData:e,isPreviewMode:t})=>D.jsxs("div",{className:"flex items-center gap-4",children:[D.jsx("img",{src:rw,alt:"Fileverse",className:"w-10 h-10 object-cover mr-2 rounded-lg cursor-pointer"}),D.jsx("input",{className:"custom-input mx-2 focus:outline-none",disabled:t,type:"text",placeholder:"Untitled",value:n.plugin.title||"",onChange:r=>e({...n,plugin:{...n.plugin,title:r.target.value}})})]});function Ct(n){this.content=n}Ct.prototype={constructor:Ct,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,i=r.find(n),s=r.content.slice();return i==-1?s.push(t||n,e):(s[i+1]=e,t&&(s[i]=t)),new Ct(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Ct(t)},addToStart:function(n,e){return new Ct([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Ct(t)},addBefore:function(n,e,t){var r=this.remove(e),i=r.content.slice(),s=r.find(n);return i.splice(s==-1?i.length:s,0,e,t),new Ct(i)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Ct.from(n),n.size?new Ct(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Ct.from(n),n.size?new Ct(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Ct.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},Ct.from=function(n){if(n instanceof Ct)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Ct(e)};function Mh(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let i=n.child(r),s=e.child(r);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=Mh(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function Oh(n,e,t,r){for(let i=n.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:r};let o=n.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,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++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=Oh(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class W{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,i=0,s){for(let o=0,l=0;l<t;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,t-u),r,i+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-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 t=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(i[i.length-1]=t.withText(t.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,t=this.size){if(e==0&&t==this.size)return this;let r=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),i+=l.nodeSize),o=a}return new W(r,i)}cutByIndex(e,t){return e==t?W.empty:e==0&&t==this.content.length?this:new W(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return i[e]=t,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 t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let i=this.content[t];e(i,r,t),r+=i.nodeSize}}findDiffStart(e,t=0){return Mh(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Oh(this,e,t,r)}findIndex(e,t=-1){if(e==0)return Qo(0,e);if(e==this.size)return Qo(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||t>0?Qo(r+1,o):Qo(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,t){if(!t)return W.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new W(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return W.empty;let t,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)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new W(t||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 Rc={index:0,offset:0};function Qo(n,e){return Rc.index=n,Rc.offset=e,Rc}function el(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!el(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!el(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let Ie=class wh{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,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))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&el(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);return r.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return wh.none;if(e instanceof wh)return[e];let t=e.slice();return t.sort((r,i)=>r.type.rank-i.type.rank),t}};Ie.none=[];class tl extends Error{}class Y{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Nh(this.content,e+this.openStart,t);return r&&new Y(r,this.openStart,this.openEnd)}removeBetween(e,t){return new Y(_h(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return Y.empty;let r=t.openStart||0,i=t.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Y(W.fromJSON(e,t.content),r,i)}static maxOpen(e,t=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new Y(e,r,i)}}Y.empty=new Y(W.empty,0,0);function _h(n,e,t){let{index:r,offset:i}=n.findIndex(e),s=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(i==e||s.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(_h(s.content,e-i-1,t-i-1)))}function Nh(n,e,t,r){let{index:i,offset:s}=n.findIndex(e),o=n.maybeChild(i);if(s==e||o.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=Nh(o.content,e-s-1,t);return l&&n.replaceChild(i,o.copy(l))}function sw(n,e,t){if(t.openStart>n.depth)throw new tl("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new tl("Inconsistent open depths");return Dh(n,e,t,0)}function Dh(n,e,t,r){let i=n.index(r),s=n.node(r);if(i==e.index(r)&&r<n.depth-t.openStart){let o=Dh(n,e,t,r+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return Zr(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=ow(t,n);return Zr(s,Lh(n,o,l,e,r))}else return Zr(s,nl(n,e,r))}function Rh(n,e){if(!e.type.compatibleContent(n.type))throw new tl("Cannot join "+e.type.name+" onto "+n.type.name)}function Lc(n,e,t){let r=n.node(t);return Rh(r,e.node(t)),r}function Yr(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Hs(n,e,t,r){let i=(e||n).node(t),s=0,o=e?e.index(t):i.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(Yr(n.nodeAfter,r),s++));for(let l=s;l<o;l++)Yr(i.child(l),r);e&&e.depth==t&&e.textOffset&&Yr(e.nodeBefore,r)}function Zr(n,e){return n.type.checkContent(e),n.copy(e)}function Lh(n,e,t,r,i){let s=n.depth>i&&Lc(n,e,i+1),o=r.depth>i&&Lc(t,r,i+1),l=[];return Hs(null,n,i,l),s&&o&&e.index(i)==t.index(i)?(Rh(s,o),Yr(Zr(s,Lh(n,e,t,r,i+1)),l)):(s&&Yr(Zr(s,nl(n,e,i+1)),l),Hs(e,t,i,l),o&&Yr(Zr(o,nl(t,r,i+1)),l)),Hs(r,null,i,l),new W(l)}function nl(n,e,t){let r=[];if(Hs(null,n,t,r),n.depth>t){let i=Lc(n,e,t+1);Yr(Zr(i,nl(n,e,t+1)),r)}return Hs(e,null,t,r),new W(r)}function ow(n,e){let t=e.depth-n.openStart,i=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(W.from(i));return{start:i.resolveNoCache(n.openStart+t),end:i.resolveNoCache(i.content.size-n.openEnd-t)}}class Vs{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(t);return r?e.child(t).cut(r):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return Ie.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),i=e.maybeChild(t);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 t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.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 t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new rl(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],i=0,s=t;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 Vs(t,r,s)}static resolveCached(e,t){for(let i=0;i<Ic.length;i++){let s=Ic[i];if(s.pos==t&&s.doc==e)return s}let r=Ic[Pc]=Vs.resolve(e,t);return Pc=(Pc+1)%lw,r}}let Ic=[],Pc=0,lw=12;class rl{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const aw=Object.create(null);let Xr=class xh{constructor(e,t,r,i=Ie.none){this.type=e,this.attrs=t,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,t,r,i=0){this.content.nodesBetween(e,t,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,t,r,i){return this.content.textBetween(e,t,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,t,r){return this.type==e&&el(this.attrs,t||e.defaultAttrs||aw)&&Ie.sameSet(this.marks,r||Ie.none)}copy(e=null){return e==this.content?this:new xh(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new xh(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return Y.empty;let i=this.resolve(e),s=this.resolve(t),o=r?0:i.sharedDepth(t),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,t,r){return sw(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let i=this.content.child(t-1);return{node:i,index:t-1,offset:r-i.nodeSize}}resolve(e){return Vs.resolveCached(this,e)}resolveNoCache(e){return Vs.resolve(this,e)}rangeHasMark(e,t,r){let i=!1;return t>e&&this.nodesBetween(e,t,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()+")"),Ih(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=W.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,t);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,t,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,t);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=Ie.none;for(let t=0;t<this.marks.length;t++)e=this.marks[t].addToSet(e);if(!Ie.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let i=W.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,i,r)}};Xr.prototype.text=void 0;class il extends Xr{constructor(e,t,r,i){if(super(e,t,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):Ih(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new il(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new il(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Ih(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Qr{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new cw(e,t);if(r.next==null)return Qr.empty;let i=Ph(r);r.next&&r.err("Unexpected trailing text");let s=gw(mw(i));return yw(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let i=this;for(let s=t;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:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let i=[this];function s(o,l){let a=o.matchFragment(e,r);if(a&&(!t||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 t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let 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 t)&&(!i.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&t(r.next[i].next)}return t(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 cw{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Ph(n){let e=[];do e.push(uw(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function uw(n){let e=[];do e.push(dw(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function dw(n){let e=pw(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=fw(n,e);else break;return e}function Fh(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function fw(n,e){let t=Fh(n),r=t;return n.eat(",")&&(n.next!="}"?r=Fh(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function hw(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let i=[];for(let s in t){let o=t[s];o.groups.indexOf(e)>-1&&i.push(o)}return i.length==0&&n.err("No node type or group '"+e+"' found"),i}function pw(n){if(n.eat("(")){let e=Ph(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=hw(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function mw(n){let e=[[]];return i(s(n,0),t()),e;function t(){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=t())}else if(o.type=="star"){let a=t();return r(l,a),i(s(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();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=t();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=t();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 Bh(n,e){return e-n}function $h(n,e){let t=[];return r(e),t.sort(Bh);function r(i){let s=n[i];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&r(a)}}}function gw(n){let e=Object.create(null);return t($h(n,0));function t(r){let i=[];r.forEach(o=>{n[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]);$h(n,a).forEach(u=>{c||i.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new Qr(r.indexOf(n.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Bh);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function yw(n,e){for(let t=0,r=[n];t<r.length;t++){let i=r[t],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 jh(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Hh(n,e){let t=Object.create(null);for(let r in n){let i=e&&e[r];if(i===void 0){let s=n[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=i}return t}function Vh(n){let e=Object.create(null);if(n)for(let t in n)e[t]=new bw(n[t]);return e}let zh=class Qv{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Vh(r.attrs),this.defaultAttrs=jh(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:Hh(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Xr(this,this.computeAttrs(e),W.from(t),Ie.setFrom(r))}createChecked(e=null,t,r){return t=W.from(t),this.checkContent(t),new Xr(this,this.computeAttrs(e),t,Ie.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=W.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(W.empty,!0);return s?new Xr(this,e,t.append(s),Ie.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:Ie.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,o)=>r[s]=new Qv(s,t,o));let i=t.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 bw{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class sl{constructor(e,t,r,i){this.name=e,this.rank=t,this.schema=r,this.spec=i,this.attrs=Vh(i.attrs),this.excluded=null;let s=jh(this.attrs);this.instance=s?new Ie(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Ie(this,Hh(this.attrs,e))}static compile(e,t){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new sl(s,i++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}}class vw{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=Ct.from(e.nodes),t.marks=Ct.from(e.marks||{}),this.nodes=zh.compile(this.spec.nodes,this),this.marks=sl.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?Uh(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==""?[]:Uh(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,t=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof zh){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,i)}text(e,t){let r=this.nodes.text;return new il(r,r.defaultAttrs,e,Ie.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Xr.fromJSON(this,e)}markFromJSON(e){return Ie.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Uh(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r],s=n.marks[i],o=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function ww(n){return n.tag!=null}function xw(n){return n.style!=null}let Fc=class Ch{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[],t.forEach(r=>{ww(r)?this.tags.push(r):xw(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,t={}){let r=new Jh(this,t,!1);return r.addAll(e,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Jh(this,t,!0);return r.addAll(e,t.from,t.to),Y.maxOpen(r.finish())}matchTag(e,t,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(Sw(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,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)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=Gh(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=Gh(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ch(e,Ch.schemaRules(e)))}};const Wh={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},Cw={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},qh={ol:!0,ul:!0},ol=1,ll=2,zs=4;function Kh(n,e,t){return e!=null?(e?ol:0)|(e==="full"?ll:0):n&&n.whitespace=="pre"?ol|ll:t&~zs}class al{constructor(e,t,r,i,s,o,l){this.type=e,this.attrs=t,this.marks=r,this.pendingMarks=i,this.solid=s,this.options=l,this.content=[],this.activeMarks=Ie.none,this.stashMarks=[],this.match=o||(l&zs?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(W.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);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&ol)){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 t=W.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(W.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,r=this.pendingMarks;t<r.length;t++){let i=r[t];(this.type?this.type.allowsMarkType(i.type):Ew(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&&!Wh.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Jh{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0;let i=t.topNode,s,o=Kh(null,t.preserveWhitespace,0)|(r?zs:0);i?s=new al(i.type,i.attrs,Ie.none,Ie.none,!0,t.topMatch||i.type.contentMatch,o):r?s=new al(null,null,Ie.none,Ie.none,!0,null,o):s=new al(e.schema.topNodeType,null,Ie.none,Ie.none,!0,null,o),this.nodes=[s],this.find=t.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,t){let r=e.style;if(!r||!r.length)return t();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]);t();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 t=e.nodeValue,r=this.top;if(r.options&ll||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(r.options&ol)r.options&ll?t=t.replace(/\r\n?/g,`
32
+ `):t=t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&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))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)}addElement(e,t){let r=e.nodeName.toLowerCase(),i;qh.hasOwnProperty(r)&&this.parser.normalizeLists&&kw(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,t));if(s?s.ignore:Cw.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(Wh.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 t=Ie.none,r=Ie.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))}):t=this.parser.schema.marks[a.mark].create(a.attrs).addToSet(t),a.consuming===!1)l=a;else break}}return[t,r]}addElementByRule(e,t,r){let i,s,o;t.node?(s=this.parser.schema.nodes[t.node],s.isLeaf?this.insertNode(s.create(t.attrs))||this.leafFallback(e):i=this.enter(s,t.attrs||null,t.preserveWhitespace)):(o=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(o));let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a)}i&&this.sync(l)&&this.open--,o&&this.removePendingMark(o,l)}addAll(e,t,r){let i=t||0;for(let s=t?e.childNodes[t]: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 t,r;for(let i=this.open;i>=0;i--){let s=this.nodes[i],o=s.findWrapping(e);if(o&&(!t||t.length>o.length)&&(t=o,r=s,!o.length)||s.solid)break}if(!t)return!1;this.sync(r);for(let i=0;i<t.length;i++)this.enterInner(t[i],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&this.enterInner(t)}if(this.findPlace(e)){this.closeExtra();let t=this.top;t.applyPending(e.type),t.match&&(t.match=t.match.matchType(e.type));let r=t.activeMarks;for(let i=0;i<e.marks.length;i++)(!t.type||t.type.allowsMarkType(e.marks[i].type))&&(r=e.marks[i].addToSet(r));return t.content.push(e.mark(r)),!0}return!1}enter(e,t,r){let i=this.findPlace(e.create(t));return i&&this.enterInner(e,t,!0,r),i}enterInner(e,t=null,r=!1,i){this.closeExtra();let s=this.top;s.applyPending(e),s.match=s.match&&s.match.matchType(e);let o=Kh(e,i,s.options);s.options&zs&&s.content.length==0&&(o|=zs),this.nodes.push(new al(e,t,s.activeMarks,s.pendingMarks,r,null,o)),this.open++}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,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=t[l];if(c==""){if(l==t.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(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let t=Tw(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){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==t)break}}}function kw(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&qh.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Sw(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Gh(n){let e={};for(let t in n)e[t]=n[t];return e}function Ew(n,e){let t=e.schema.nodes;for(let r in t){let i=t[r];if(!i.allowsMarkType(n))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 Tw(n,e){for(let t=0;t<e.length;t++)if(n.eq(e[t]))return e[t]}class _n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Bc(t).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,t);u&&(s.push([c,i]),i.appendChild(u.dom),i=u.contentDOM||u.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:i}=_n.renderSpec(Bc(t),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,t,i)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let i=this.marks[e.type.name];return i&&_n.renderSpec(Bc(r),i(e,t))}static renderSpec(e,t,r=null){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let i=t[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=t[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<t.length;u++){let d=t[u];if(d===0){if(u<t.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}=_n.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 _n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Yh(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Yh(e.marks)}}function Yh(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Bc(n){return n.document||window.document}const Zh=65535,Xh=Math.pow(2,16);function Aw(n,e){return n+e*Xh}function Qh(n){return n&Zh}function Mw(n){return(n-(n&Zh))/Xh}const ep=1,tp=2,cl=4,np=8;class $c{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&np)>0}get deletedBefore(){return(this.delInfo&(ep|cl))>0}get deletedAfter(){return(this.delInfo&(tp|cl))>0}get deletedAcross(){return(this.delInfo&cl)>0}}class Kt{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Kt.empty)return Kt.empty}recover(e){let t=0,r=Qh(e);if(!this.inverted)for(let i=0;i<r;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+t+Mw(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let 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:t:t,h=a+i+(f<0?0:u);if(r)return h;let p=e==(t<0?a:d)?null:Aw(l/3,e-a),g=e==a?tp:e==d?ep:cl;return(t<0?e!=a:e!=d)&&(g|=np),new $c(h,g,p)}i+=u-c}return r?e+i:new $c(e+i,0,null)}touches(e,t){let r=0,i=Qh(t),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 t=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+t],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 Ri{constructor(e=[],t,r=0,i=e.length){this.maps=e,this.mirror=t,this.from=r,this.to=i}slice(e=0,t=this.maps.length){return new Ri(this.maps,this.mirror,e,t)}copy(){return new Ri(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,r=this.maps.length;t<e.maps.length;t++){let i=e.getMirror(t);this.appendMap(e.maps[t],i!=null&&i<t?r+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this.maps.length+e.maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e.maps[t].invert(),i!=null&&i>t?r-i-1:void 0)}}invert(){let e=new Ri;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this.maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this.maps[s],l=o.mapResult(e,t);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 $c(e,i,null)}}const jc=Object.create(null);class Tt{getMap(){return Kt.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=jc[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in jc)throw new RangeError("Duplicate use of step JSON ID "+e);return jc[e]=t,t.prototype.jsonID=e,t}}class ot{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new ot(e,null)}static fail(e){return new ot(null,e)}static fromReplace(e,t,r,i){try{return ot.ok(e.replace(t,r,i))}catch(s){if(s instanceof tl)return ot.fail(s.message);throw s}}}function Hc(n,e,t){let r=[];for(let i=0;i<n.childCount;i++){let s=n.child(i);s.content.size&&(s=s.copy(Hc(s.content,e,s))),s.isInline&&(s=e(s,t,i)),r.push(s)}return W.fromArray(r)}class wr extends Tt{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new Y(Hc(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return ot.fromReplace(e,this.from,this.to,s)}invert(){return new Nn(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new wr(t.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,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new wr(t.from,t.to,e.markFromJSON(t.mark))}}Tt.jsonID("addMark",wr);class Nn extends Tt{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new Y(Hc(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return ot.fromReplace(e,this.from,this.to,r)}invert(){return new wr(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Nn(t.pos,r.pos,this.mark)}merge(e){return e instanceof Nn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Nn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Nn(t.from,t.to,e.markFromJSON(t.mark))}}Tt.jsonID("removeMark",Nn);class xr extends Tt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ot.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ot.fromReplace(e,this.pos,this.pos+1,new Y(W.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(r))return new xr(this.pos,t.marks[i]);return new xr(this.pos,this.mark)}}return new Li(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new xr(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new xr(t.pos,e.markFromJSON(t.mark))}}Tt.jsonID("addNodeMark",xr);class Li extends Tt{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ot.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ot.fromReplace(e,this.pos,this.pos+1,new Y(W.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new xr(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Li(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Li(t.pos,e.markFromJSON(t.mark))}}Tt.jsonID("removeNodeMark",Li);class ht extends Tt{constructor(e,t,r,i=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=i}apply(e){return this.structure&&Vc(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 t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new ht(t.pos,Math.max(t.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 t=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),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=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,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ht(t.from,t.to,Y.fromJSON(e,t.slice),!!t.structure)}}Tt.jsonID("replace",ht);class pt extends Tt{constructor(e,t,r,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Vc(e,this.from,this.gapFrom)||Vc(e,this.gapTo,this.to)))return ot.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ot.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.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 t=this.gapTo-this.gapFrom;return new pt(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||i<t.pos||s>r.pos?null:new pt(t.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,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new pt(t.from,t.to,t.gapFrom,t.gapTo,Y.fromJSON(e,t.slice),t.insert,!!t.structure)}}Tt.jsonID("replaceAround",pt);function Vc(n,e,t){let r=n.resolve(e),i=t-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 Ow(n,e,t,r){let i=[],s=[],o,l;n.doc.nodesBetween(e,t,(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,t),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 Nn(f,h,d[g])));l&&l.to==f?l.to=h:s.push(l=new wr(f,h,r))}}),i.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function _w(n,e,t,r){let i=[],s=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(r instanceof sl){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,t);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=>n.step(new Nn(o.from,o.to,o.style)))}function rp(n,e,t,r=t.contentMatch,i=!0){let s=n.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++)t.allowsMarkType(c.marks[f].type)||n.step(new Nn(l,u,c.marks[f]));if(i&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new Y(W.from(t.schema.text(" ",t.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);n.replace(l,l,new Y(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function Nw(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Ii(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let i=n.$from.node(r),s=n.$from.index(r),o=n.$to.indexAfter(r);if(r<n.depth&&i.canReplace(s,o,t))return r;if(r==0||i.type.spec.isolating||!Nw(i,s,o))break}return null}function Dw(n,e,t){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>t;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>t;p--)g||i.after(p+1)<i.end(p)?(g=!0,f=W.from(i.node(p).copy(f)),h++):c++;n.step(new pt(a,c,o,l,new Y(u.append(f),d,h),u.size-d,!0))}function zc(n,e,t=null,r=n){let i=Rw(n,e),s=i&&Lw(r,e);return s?i.map(ip).concat({type:e,attrs:t}).concat(s.map(ip)):null}function ip(n){return{type:n,attrs:null}}function Rw(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return t.canReplaceWith(r,i,o)?s:null}function Lw(n,e){let{parent:t,startIndex:r,endIndex:i}=n,s=t.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(t.child(c).type);return!a||!a.validEnd?null:o}function Iw(n,e,t){let r=W.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[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(t[o].type.create(t[o].attrs,r))}let i=e.start,s=e.end;n.step(new pt(i,s,i,s,new Y(r,0,0),t.length,!0))}function Pw(n,e,t,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{if(o.isTextblock&&!o.hasMarkup(r,i)&&$w(n.doc,n.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&&Bw(n,o,l,s),rp(n,n.mapping.slice(s).map(l,1),r,void 0,a===null);let c=n.mapping.slice(s),u=c.map(l,1),d=c.map(l+o.nodeSize,1);return n.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&&Fw(n,o,l,s),!1}})}function Fw(n,e,t,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=n.mapping.slice(r).map(t+1+s+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Bw(n,e,t,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+s);n.replaceWith(o,o+1,e.type.schema.text(`
34
+ `))}})}function $w(n,e,t){let r=n.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,t)}function jw(n,e,t,r,i){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(r,null,i||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new pt(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new Y(W.from(o),0,0),1,!0))}function Pi(n,e,t=1,r){let i=n.resolve(e),s=i.depth-t,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=t-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 Hw(n,e,t=1,r){let i=n.doc.resolve(e),s=W.empty,o=W.empty;for(let l=i.depth,a=i.depth-t,c=t-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))}n.step(new ht(e,e,new Y(s.append(o),t,t),!0))}function Cr(n,e){let t=n.resolve(e),r=t.index();return sp(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function sp(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function ul(n,e,t=-1){let r=n.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):t>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&&sp(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=t<0?r.before(i):r.after(i)}}function Vw(n,e,t){let r=new ht(e-t,e+t,Y.empty,!0);n.step(r)}function zw(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,t))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,t))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function op(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.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 dl(n,e,t=e,r=Y.empty){if(e==t&&!r.size)return null;let i=n.resolve(e),s=n.resolve(t);return lp(i,s,r)?new ht(e,t,r):new Uw(i,s,r).fit()}function lp(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Uw{constructor(e,t,r){this.$from=e,this.$to=t,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(),t=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,t):a.size||r.pos!=this.$to.pos?new ht(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=Uc(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(t==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(t==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:t,openEnd:r}=this.unplaced,i=Uc(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Y(e,t+1,Math.max(r,i.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,i=Uc(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new Y(Us(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new Y(Us(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:i,wrap:s}){for(;this.depth>t;)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[t];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(ap(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=Ws(this.placed,t,W.from(u)),this.frontier[t].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(Us(o.content,e-1,1),e-1,h<0?o.openEnd:e-1):new Y(Us(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Wc(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=Wc(e,t,i,r,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Wc(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:o,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Ws(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.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,t=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Ws(this.placed,this.depth,W.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(W.empty,!0);t.childCount&&(this.placed=Ws(this.placed,this.frontier.length,t))}}function Us(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Us(n.firstChild.content,e-1,t)))}function Ws(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Ws(n.lastChild.content,e-1,t)))}function Uc(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function ap(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,ap(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(W.empty,!0)))),n.copy(r)}function Wc(n,e,t,r,i){let s=n.node(e),o=i?n.indexAfter(e):n.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!Ww(t,s.content,o)?l:null}function Ww(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function qw(n){return n.spec.defining||n.spec.definingForContent}function Kw(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let i=n.doc.resolve(e),s=n.doc.resolve(t);if(lp(i,s,r))return n.step(new ht(e,t,r));let o=up(i,n.doc.resolve(t));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=qw(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 n.replace(i.before(v),w?s.after(v):t,new Y(cp(r.content,0,r.openStart,h),h,r.openEnd))}}let d=n.steps.length;for(let f=o.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>d));f--){let h=o[f];h<0||(e=i.before(h),t=s.after(h))}}function cp(n,e,t,r,i){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(cp(s.content,e+1,t,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(n).append(n);n=o.append(s.matchFragment(o).fillBefore(W.empty,!0))}return n}function Jw(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let i=zw(n.doc,e,r.type);i!=null&&(e=t=i)}n.replaceRange(e,t,new Y(W.from(r),0,0))}function Gw(n,e,t){let r=n.doc.resolve(e),i=n.doc.resolve(t),s=up(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 n.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 n.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&&t>r.end(o)&&i.end(o)-t!=i.depth-o)return n.delete(r.before(o),t);n.delete(e,t)}function up(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let i=r;i>=0;i--){let s=n.start(i);if(s<n.pos-(n.depth-i)||e.end(i)>e.pos+(e.depth-i)||n.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==n.depth&&i==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class Fi extends Tt{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return ot.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let i=t.type.create(r,null,t.marks);return ot.fromReplace(e,this.pos,this.pos+1,new Y(W.from(i),0,t.isLeaf?0:1))}getMap(){return Kt.empty}invert(e){return new Fi(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Fi(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Fi(t.pos,t.attr,t.value)}}Tt.jsonID("attr",Fi);class qs extends Tt{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return ot.ok(r)}getMap(){return Kt.empty}invert(e){return new qs(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new qs(t.attr,t.value)}}Tt.jsonID("docAttr",qs);let Bi=class extends Error{};Bi=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},Bi.prototype=Object.create(Error.prototype),Bi.prototype.constructor=Bi,Bi.prototype.name="TransformError";class qc{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ri}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Bi(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=Y.empty){let i=dl(this.doc,e,t,r);return i&&this.step(i),this}replaceWith(e,t,r){return this.replace(e,t,new Y(W.from(r),0,0))}delete(e,t){return this.replace(e,t,Y.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Kw(this,e,t,r),this}replaceRangeWith(e,t,r){return Jw(this,e,t,r),this}deleteRange(e,t){return Gw(this,e,t),this}lift(e,t){return Dw(this,e,t),this}join(e,t=1){return Vw(this,e,t),this}wrap(e,t){return Iw(this,e,t),this}setBlockType(e,t=e,r,i=null){return Pw(this,e,t,r,i),this}setNodeMarkup(e,t,r=null,i){return jw(this,e,t,r,i),this}setNodeAttribute(e,t,r){return this.step(new Fi(e,t,r)),this}setDocAttribute(e,t){return this.step(new qs(e,t)),this}addNodeMark(e,t){return this.step(new xr(e,t)),this}removeNodeMark(e,t){if(!(t instanceof Ie)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new Li(e,t)),this}split(e,t=1,r){return Hw(this,e,t,r),this}addMark(e,t,r){return Ow(this,e,t,r),this}removeMark(e,t,r){return _w(this,e,t,r),this}clearIncompatible(e,t,r){return rp(this,e,t,r),this}}const Kc=Object.create(null);class ue{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Jc(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=Y.empty){let r=t.content.lastChild,i=null;for(let l=0;l<t.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:t),l==0&&hp(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){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,t),hp(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let i=e.parent.inlineContent?new ce(e):$i(e.node(0),e.parent,e.pos,e.index(),t,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?$i(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):$i(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new yn(e.node(0))}static atStart(e){return $i(e,e,0,0,1)||new yn(e)}static atEnd(e){return $i(e,e,e.content.size,e.childCount,-1)||new yn(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Kc[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Kc)throw new RangeError("Duplicate use of selection JSON ID "+e);return Kc[e]=t,t.prototype.jsonID=e,t}getBookmark(){return ce.between(this.$anchor,this.$head).getBookmark()}}ue.prototype.visible=!0;class Jc{constructor(e,t){this.$from=e,this.$to=t}}let dp=!1;function fp(n){!dp&&!n.parent.inlineContent&&(dp=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class ce extends ue{constructor(e,t=e){fp(e),fp(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return ue.near(r);let i=e.resolve(t.map(this.anchor));return new ce(i.parent.inlineContent?i:r,r)}replace(e,t=Y.empty){if(super.replace(e,t),t==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 fl(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ce(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let i=e.resolve(t);return new this(i,r==t?i:e.resolve(r))}static between(e,t,r){let i=e.pos-t.pos;if((!r||i)&&(r=i>=0?1:-1),!t.parent.inlineContent){let s=ue.findFrom(t,r,!0)||ue.findFrom(t,-r,!0);if(s)t=s.$head;else return ue.near(t,r)}return e.parent.inlineContent||(i==0?e=t:(e=(ue.findFrom(e,-r,!0)||ue.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new ce(e,t)}}ue.jsonID("text",ce);class fl{constructor(e,t){this.anchor=e,this.head=t}map(e){return new fl(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 t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:i}=t.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 Gc(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new se(e.resolve(t.anchor))}static create(e,t){return new se(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}se.prototype.visible=!1,ue.jsonID("node",se);class Gc{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new fl(r,r):new Gc(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&se.isSelectable(r)?new se(t):ue.near(t)}}class yn extends ue{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=Y.empty){if(t==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,t)}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 Yw}}ue.jsonID("all",yn);const Yw={map(){return this},resolve(n){return new yn(n)}};function $i(n,e,t,r,i,s=!1){if(e.inlineContent)return ce.create(n,t);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(n,t-(i<0?l.nodeSize:0))}else{let a=$i(n,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function hp(n,e,t){let r=n.steps.length-1;if(r<e)return;let i=n.steps[r];if(!(i instanceof ht||i instanceof pt))return;let s=n.mapping.maps[r],o;s.forEach((l,a,c,u)=>{o==null&&(o=u)}),n.setSelection(ue.near(n.doc.resolve(o),t))}const pp=1,hl=2,mp=4;let Zw=class extends qc{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|pp)&~hl,this.storedMarks=null,this}get selectionSet(){return(this.updated&pp)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=hl,this}ensureMarks(e){return Ie.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&hl)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~hl,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Ie.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=r==t?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,i.text(e,s)),this.selection.empty||this.setSelection(ue.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=mp,this}get scrolledIntoView(){return(this.updated&mp)>0}};function gp(n,e){return!e||!n?n:n.bind(e)}class Ks{constructor(e,t,r){this.name=e,this.init=gp(t.init,r),this.apply=gp(t.apply,r)}}const Xw=[new Ks("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Ks("selection",{init(n,e){return n.selection||ue.atStart(e.doc)},apply(n){return n.selection}}),new Ks("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Ks("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Yc{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Xw.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Ks(r.key,r.spec.state,r))})}}class ji{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let 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 t=[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<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,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:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),s=!0}i&&(i[o]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new ji(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new Zw(this)}static create(e){let t=new Yc(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new ji(t);for(let i=0;i<t.fields.length;i++)r[t.fields[i].name]=t.fields[i].init(e,r);return r}reconfigure(e){let t=new Yc(this.schema,e.plugins),r=t.fields,i=new ji(t);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 t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],s=i.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Yc(e.schema,e.plugins),s=new ji(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Xr.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=ue.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=c.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function yp(n,e,t){for(let r in n){let i=n[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=yp(i,e,{})),t[r]=i}return t}class je{constructor(e){this.spec=e,this.props={},e.props&&yp(e.props,this,this.props),this.key=e.key?e.key.key:bp("plugin")}getState(e){return e[this.key]}}const Zc=Object.create(null);function bp(n){return n in Zc?n+"$"+ ++Zc[n]:(Zc[n]=0,n+"$")}class We{constructor(e="key"){this.key=bp(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const kt=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Js=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Xc=null;const er=function(n,e,t){let r=Xc||(Xc=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Qw=function(){Xc=null},ei=function(n,e,t,r){return t&&(vp(n,e,t,r,-1)||vp(n,e,t,r,1))},e2=/^(img|br|input|textarea|hr)$/i;function vp(n,e,t,r,i){for(;;){if(n==t&&e==r)return!0;if(e==(i<0?0:Dn(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Gs(n)||e2.test(n.nodeName)||n.contentEditable=="false")return!1;e=kt(n)+(i<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(i<0?-1:0)],n.contentEditable=="false")return!1;e=i<0?Dn(n):0}else return!1}}function Dn(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function t2(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Dn(n)}else if(n.parentNode&&!Gs(n))e=kt(n),n=n.parentNode;else return null}}function n2(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Gs(n))e=kt(n)+1,n=n.parentNode;else return null}}function r2(n,e,t){for(let r=e==0,i=e==Dn(n);r||i;){if(n==t)return!0;let s=kt(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,i=i&&s==Dn(n)}}function Gs(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const pl=function(n){return n.focusNode&&ei(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function ti(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function i2(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function s2(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:r.offset}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:r.startOffset}}}const Rn=typeof navigator<"u"?navigator:null,wp=typeof document<"u"?document:null,kr=Rn&&Rn.userAgent||"",Qc=/Edge\/(\d+)/.exec(kr),xp=/MSIE \d/.exec(kr),eu=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(kr),$t=!!(xp||eu||Qc),Sr=xp?document.documentMode:eu?+eu[1]:Qc?+Qc[1]:0,bn=!$t&&/gecko\/(\d+)/i.test(kr);bn&&+(/Firefox\/(\d+)/.exec(kr)||[0,0])[1];const tu=!$t&&/Chrome\/(\d+)/.exec(kr),_t=!!tu,o2=tu?+tu[1]:0,Nt=!$t&&!!Rn&&/Apple Computer/.test(Rn.vendor),Hi=Nt&&(/Mobile\/\w+/.test(kr)||!!Rn&&Rn.maxTouchPoints>2),rn=Hi||(Rn?/Mac/.test(Rn.platform):!1),l2=Rn?/Win/.test(Rn.platform):!1,vn=/Android \d/.test(kr),Ys=!!wp&&"webkitFontSmoothing"in wp.documentElement.style,a2=Ys?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function c2(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function tr(n,e){return typeof n=="number"?n:n[e]}function u2(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Cp(n,e,t){let r=n.someProp("scrollThreshold")||0,i=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let o=t||n.dom;o;o=Js(o)){if(o.nodeType!=1)continue;let l=o,a=l==s.body,c=a?c2(s):u2(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 d2(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=n.root.elementFromPoint(s,o);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:kp(n.dom)}}function kp(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Js(r));return e}function f2({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Sp(t,r==0?0:r-e)}function Sp(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:i,left:s}=n[t];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let Vi=null;function h2(n){if(n.setActive)return n.setActive();if(Vi)return n.focus(Vi);let e=kp(n);n.focus(Vi==null?{get preventScroll(){return Vi={preventScroll:!0},!0}}:void 0),Vi||(Vi=!1,Sp(e,0))}function Ep(n,e){let t,r=2e8,i,s=0,o=e.top,l=e.top,a,c;for(let u=n.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){t=u,r=g,i=g&&t.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});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=d+1)}}return!t&&a&&(t=a,i=c,r=0),t&&t.nodeType==3?p2(t,i):!t||r&&t.nodeType==1?{node:n,offset:s}:Ep(t,i)}function p2(n,e){let t=n.nodeValue.length,r=document.createRange();for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let s=Er(r,1);if(s.top!=s.bottom&&nu(e,s))return{node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function nu(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function m2(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function g2(n,e,t){let{node:r,offset:i}=Ep(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return n.docView.posFromDOM(r,i,s)}function y2(n,e,t,r){let i=-1;for(let s=e,o=!1;s!=n.dom;){let l=n.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:n.docView.posFromDOM(e,t,-1)}function Tp(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let o=n.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(nu(e,c))return Tp(o,e,c)}}if((s=(s+1)%r)==i)break}return n}function b2(n,e){let t=n.dom.ownerDocument,r,i=0,s=s2(t,e.left,e.top);s&&({node:r,offset:i}=s);let o=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!o||!n.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=n.dom.getBoundingClientRect();if(!nu(e,c)||(o=Tp(n.dom,e,c),!o))return null}if(Nt)for(let c=o;r&&c;c=Js(c))c.draggable&&(r=void 0);if(o=m2(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;Ys&&i&&r.nodeType==1&&(c=r.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,r==n.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=y2(n,r,i,e))}l==null&&(l=g2(n,o,e));let a=n.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ap(n){return n.top<n.bottom||n.left<n.right}function Er(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Ap(r))return r}return Array.prototype.find.call(t,Ap)||n.getBoundingClientRect()}const v2=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Mp(n,e,t){let{node:r,offset:i,atom:s}=n.docView.domFromPos(e,t<0?-1:1),o=Ys||bn;if(r.nodeType==3)if(o&&(v2.test(r.nodeValue)||(t<0?!i:i==r.nodeValue.length))){let a=Er(er(r,i,i),t);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 Zs(u,u.left<c.left)}}return a}else{let a=i,c=i,u=t<0?1:-1;return t<0&&!i?(c++,u=-1):t>=0&&i==r.nodeValue.length?(a--,u=1):t<0?a--:c++,Zs(Er(er(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==Dn(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return ru(a.getBoundingClientRect(),!1)}if(s==null&&i<Dn(r)){let a=r.childNodes[i];if(a.nodeType==1)return ru(a.getBoundingClientRect(),!0)}return ru(r.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==Dn(r))){let a=r.childNodes[i-1],c=a.nodeType==3?er(a,Dn(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Zs(Er(c,1),!1)}if(s==null&&i<Dn(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 Zs(Er(c,-1),!0)}return Zs(Er(r.nodeType==3?er(r):r,-t),t>=0)}function Zs(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function ru(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Op(n,e,t){let r=n.state,i=n.root.activeElement;r!=e&&n.updateState(e),i!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),i!=n.dom&&i&&i.focus()}}function w2(n,e,t){let r=e.selection,i=t=="up"?r.$from:r.$to;return Op(n,e,()=>{let{node:s}=n.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Mp(n,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&&(t=="up"?o.top-u.top>(u.bottom-o.top)*2:u.bottom-o.bottom>(o.bottom-u.top)*2))return!1}}return!0})}const x2=/[\u0590-\u08ac]/;function C2(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=n.domSelection();return!x2.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:Op(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:g}=n.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 _p=null,Np=null,Dp=!1;function k2(n,e,t){return _p==e&&Np==t?Dp:(_p=e,Np=t,Dp=t=="up"||t=="down"?w2(n,e,t):C2(n,e,t))}const sn=0,Rp=1,ni=2,Ln=3;class Xs{constructor(e,t,r,i){this.parent=e,this.children=t,this.dom=r,this.contentDOM=i,this.dirty=sn,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let i=this.children[t];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,t,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[t-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[t];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=t>kt(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(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==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,t=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!t||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 t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let i=this.children[t],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,t){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 Pp){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Lp&&s.side>=0;r--);if(t<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?kt(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,t):{node:this.contentDOM,offset:s?kt(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let 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&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,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=kt(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){s=kt(d.dom);break}t+=d.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,i=!1){let s=Math.min(e,t),o=Math.max(e,t);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,t-h-p.border,r,i);h=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.getSelection(),u=!1;if((bn||Nt)&&e==t){let{node:f,offset:h}=l;if(f.nodeType==3){if(u=!!(h&&f.nodeValue[h-1]==`
35
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:kt(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==t)&&!u){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){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,t){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&&t>=r:e<o&&t>r){let l=r+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==o?ni:Rp,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Ln:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?ni:Ln}r=o}this.dirty=ni}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?ni:Rp;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class Lp extends Xs{constructor(e,t,r,i){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.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=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==sn&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class S2 extends Xs{constructor(e,t,r,i){super(e,[],t,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class ri extends Xs{constructor(e,t,r,i){super(e,[],r,i),this.mark=t}static create(e,t,r,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,r);return(!o||!o.dom)&&(o=_n.renderSpec(document,t.type.spec.toDOM(t,r))),new ri(e,t,o.dom,o.contentDOM||o.dom)}parseRule(){return this.dirty&Ln||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ln&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),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,t,r){let i=ri.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;t<o&&(s=ou(s,t,o,r)),e>0&&(s=ou(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}}class Tr extends Xs{constructor(e,t,r,i,s,o,l,a,c){super(e,[],s,o),this.node=t,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,t,r,i,s,o){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},r,i),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=_n.renderSpec(document,t.type.spec.toDOM(t)));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=$p(u,r,t),c?a=new E2(e,t,r,i,u,d||null,f,c,s,o+1):t.isText?new ml(e,t,r,i,u,f,s):new Tr(e,t,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 t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>W.empty)}return e}matchesNode(e,t,r){return this.dirty==sn&&e.eq(this.node)&&su(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new A2(this,o&&o.node,e);_2(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?Ie.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),Fp(this.contentDOM,this.children,e),Hi&&N2(this.dom))}localCompositionInfo(e,t){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof ce)||r<t||i>t+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=D2(this.node.content,o,r-t,i-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:i}){if(this.getDesc(t))return;let s=t;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 S2(this,s,t,i);e.input.compositionNodes.push(o),this.children=ou(this.children,r,r+i.length,e,o)}update(e,t,r,i){return this.dirty==Ln||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,i),!0)}updateInner(e,t,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=sn}updateOuterDeco(e){if(su(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Bp(this.dom,this.nodeDOM,iu(this.outerDeco,this.node,t),iu(e,this.node,t)),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 Ip(n,e,t,r,i){$p(r,e,n);let s=new Tr(void 0,n,e,t,r,r,r,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class ml extends Tr{constructor(e,t,r,i,s,o,l){super(e,t,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,t,r,i){return this.dirty==Ln||this.dirty!=sn&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(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 t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new ml(this.parent,i,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ln)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Pp extends Xs{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 E2 extends Tr{constructor(e,t,r,i,s,o,l,a,c,u){super(e,t,r,i,s,o,l,c,u),this.spec=a}update(e,t,r,i){if(this.dirty==Ln)return!1;if(this.spec.update){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,i){this.spec.setSelection?this.spec.setSelection(e,t,r):super.setSelection(e,t,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 Fp(n,e,t){let r=n.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==n){for(;l!=r;)r=jp(r),i=!0;r=r.nextSibling}else i=!0,n.insertBefore(l,r);if(o instanceof ri){let a=r?r.previousSibling:n.lastChild;Fp(o.contentDOM,o.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=jp(r),i=!0;i&&t.trackWrites==n&&(t.trackWrites=null)}const Qs=function(n){n&&(this.nodeName=n)};Qs.prototype=Object.create(null);const ii=[new Qs];function iu(n,e,t){if(n.length==0)return ii;let r=t?ii[0]:new Qs,i=[r];for(let s=0;s<n.length;s++){let o=n[s].type.attrs;if(o){o.nodeName&&i.push(r=new Qs(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&i.length==1&&i.push(r=new Qs(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 Bp(n,e,t,r){if(t==ii&&r==ii)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],l=t[s];if(s){let a;l&&l.nodeName==o.nodeName&&i!=n&&(a=i.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=ii[0]),i=a}T2(i,l||ii[0],o)}return i}function T2(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&n.classList.add(i[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)n.style.removeProperty(i[1])}t.style&&(n.style.cssText+=t.style)}}function $p(n,e,t){return Bp(n,n,ii,iu(e,t,n.nodeType!=1))}function su(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function jp(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class A2{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=M2(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){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],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,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,t,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,t,r)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,i,s){let o=this.top.children[i];return o.dirty==Ln&&o.dom==o.contentDOM&&(o.dirty=ni),o.update(e,t,r,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=t}}updateNextNode(e,t,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!=Ln&&su(t,a.outerDeco));if(!f&&a.update(e,t,r,i))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,t,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,t,r,i,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content))return null;let l=Tr.create(this.top,t,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,t,r,i,s){let o=Tr.create(this.top,e,t,r,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,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 Lp(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof ri;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof ml)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Nt||_t)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let i=new Pp(this.top,[],r,null);t!=this.top?t.children.push(i):t.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 M2(n,e){let t=e,r=t.children.length,i=n.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof ri)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function O2(n,e){return n.type.side-e.type.side}function _2(n,e,t,r){let i=e.locals(n),s=0;if(i.length==0){for(let c=0;c<n.childCount;c++){let u=n.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(O2);for(let v=0;v<d.length;v++)t(d[v],c,!!a)}else t(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<n.childCount)h=c,f=n.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 N2(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function D2(n,e,t,r){for(let i=0,s=0;i<n.childCount&&s<=r;){let o=n.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;i<n.childCount;){let c=n.child(i++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){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>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function ou(n,e,t,r,i){let s=[];for(let o=0,l=0;o<n.length;o++){let a=n[o],c=l,u=l+=a.size;c>=t||u<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,r)),i&&(s.push(i),i=void 0),u>t&&s.push(a.slice(t-c,a.size,r)))}return s}function lu(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let i=n.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=r.resolve(o),a,c;if(pl(t)){for(a=l;i&&!i.node;)i=i.parent;let u=i.node;if(i&&u.isAtom&&se.isSelectable(u)&&i.parent&&!(u.isInline&&r2(t.focusNode,t.focusOffset,i.dom))){let d=i.posBefore;c=new se(o==d?l:r.resolve(d))}}else{let u=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(u<0)return null;a=r.resolve(u)}if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=cu(n,a,l,u)}return c}function Hp(n){return n.editable?n.hasFocus():Jp(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function nr(n,e=!1){let t=n.state.selection;if(Wp(n,t),!!Hp(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&_t){let r=n.domSelectionRange(),i=n.domObserver.currentSelection;if(r.anchorNode&&i.anchorNode&&ei(r.anchorNode,r.anchorOffset,i.anchorNode,i.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)L2(n);else{let{anchor:r,head:i}=t,s,o;Vp&&!(t instanceof ce)&&(t.$from.parent.inlineContent||(s=zp(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=zp(n,t.to))),n.docView.setSelection(r,i,n.root,e),Vp&&(s&&Up(s),o&&Up(o)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&R2(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Vp=Nt||_t&&o2<63;function zp(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),i=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(Nt&&i&&i.contentEditable=="false")return au(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return au(i);if(s)return au(s)}}function au(n){return n.contentEditable="true",Nt&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Up(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function R2(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Hp(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function L2(n){let e=n.domSelection(),t=document.createRange(),r=n.cursorWrapper.dom,i=r.nodeName=="IMG";i?t.setEnd(r.parentNode,kt(r)+1):t.setEnd(r,0),t.collapse(!1),e.removeAllRanges(),e.addRange(t),!i&&!n.state.selection.visible&&$t&&Sr<=11&&(r.disabled=!0,r.disabled=!1)}function Wp(n,e){if(e instanceof se){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(qp(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else qp(n)}function qp(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function cu(n,e,t,r){return n.someProp("createSelectionBetween",i=>i(n,e,t))||ce.between(e,t,r)}function Kp(n){return n.editable&&!n.hasFocus()?!1:Jp(n)}function Jp(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function I2(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return ei(e.node,e.offset,t.anchorNode,t.anchorOffset)}function uu(n,e){let{$anchor:t,$head:r}=n.selection,i=e>0?t.max(r):t.min(r),s=i.parent.inlineContent?i.depth?n.doc.resolve(e>0?i.after():i.before()):null:i;return s&&ue.findFrom(s,e)}function Ar(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Gp(n,e,t){let r=n.state.selection;if(r instanceof ce)if(t.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=n.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Ar(n,new ce(r.$anchor,o))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let i=uu(n.state,e);return i&&i instanceof se?Ar(n,i):!1}else if(!(rn&&t.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=n.docView.descAt(l))&&!o.contentDOM?se.isSelectable(s)?Ar(n,new se(e<0?n.state.doc.resolve(i.pos-s.nodeSize):i)):Ys?Ar(n,new ce(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof se&&r.node.isInline)return Ar(n,new ce(e>0?r.$to:r.$from));{let i=uu(n.state,e);return i?Ar(n,i):!1}}}function gl(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function eo(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function zi(n,e){return e<0?P2(n):F2(n)}function P2(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i,s,o=!1;for(bn&&t.nodeType==1&&r<gl(t)&&eo(t.childNodes[r],-1)&&(o=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(eo(l,-1))i=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Yp(t))break;{let l=t.previousSibling;for(;l&&eo(l,-1);)i=t.parentNode,s=kt(l),l=l.previousSibling;if(l)t=l,r=gl(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}o?du(n,t,r):i&&du(n,i,s)}function F2(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let i=gl(t),s,o;for(;;)if(r<i){if(t.nodeType!=1)break;let l=t.childNodes[r];if(eo(l,1))s=t,o=++r;else break}else{if(Yp(t))break;{let l=t.nextSibling;for(;l&&eo(l,1);)s=l.parentNode,o=kt(l)+1,l=l.nextSibling;if(l)t=l,r=0,i=gl(t);else{if(t=t.parentNode,t==n.dom)break;r=i=0}}}s&&du(n,s,o)}function Yp(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function B2(n,e){for(;n&&e==n.childNodes.length&&!Gs(n);)e=kt(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function $2(n,e){for(;n&&!e&&!Gs(n);)e=kt(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function du(n,e,t){if(e.nodeType!=3){let s,o;(o=B2(e,t))?(e=o,t=0):(s=$2(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(pl(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:i}=n;setTimeout(()=>{n.state==i&&nr(n)},50)}function Zp(n,e){let t=n.state.doc.resolve(e);if(!(_t||l2)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.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<t.end()){let s=n.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(n.dom).direction=="rtl"?"rtl":"ltr"}function Xp(n,e,t){let r=n.state.selection;if(r instanceof ce&&!r.empty||t.indexOf("s")>-1||rn&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let o=uu(n.state,e);if(o&&o instanceof se)return Ar(n,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(n,l):!1}return!1}function Qp(n,e){if(!(n.state.selection instanceof ce))return!0;let{$head:t,$anchor:r,empty:i}=n.state.selection;if(!t.sameParent(r))return!0;if(!i)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=n.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),n.dispatch(o),!0}return!1}function em(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function j2(n){if(!Nt||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;em(n,r,"true"),setTimeout(()=>em(n,r,"false"),20)}return!1}function H2(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function V2(n,e){let t=e.keyCode,r=H2(e);if(t==8||rn&&t==72&&r=="c")return Qp(n,-1)||zi(n,-1);if(t==46&&!e.shiftKey||rn&&t==68&&r=="c")return Qp(n,1)||zi(n,1);if(t==13||t==27)return!0;if(t==37||rn&&t==66&&r=="c"){let i=t==37?Zp(n,n.state.selection.from)=="ltr"?-1:1:-1;return Gp(n,i,r)||zi(n,i)}else if(t==39||rn&&t==70&&r=="c"){let i=t==39?Zp(n,n.state.selection.from)=="ltr"?1:-1:1;return Gp(n,i,r)||zi(n,i)}else{if(t==38||rn&&t==80&&r=="c")return Xp(n,-1,r)||zi(n,-1);if(t==40||rn&&t==78&&r=="c")return j2(n)||Xp(n,1,r)||zi(n,1);if(r==(rn?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function tm(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{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;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let o=n.someProp("clipboardSerializer")||_n.fromSchema(n.state.schema),l=cm(),a=l.createElement("div");a.appendChild(o.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=lm[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(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
36
36
 
37
37
  `);return{dom:a,text:f,slice:e}}function nm(n,e,t,r,i){let s=i.parent.type.spec.code,o,l;if(!t&&!e)return null;let a=e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,s||r,n)}),s)return e?new Y(W.from(n.state.schema.text(e.replace(/\r\n?/g,`
38
- `))),0,0):Y.empty;let d=n.someProp("clipboardTextParser",f=>f(e,i,r,n));if(d)l=d;else{let f=i.marks(),{schema:h}=n.state,p=_n.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 n.someProp("transformPastedHTML",d=>{t=d(t,n)}),o=W2(t),Ys&&q2(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=(n.someProp("clipboardParser")||n.someProp("domParser")||Fc.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!z2.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=K2(om(l,+u[1],+u[2]),u[4]);else if(l=Y.maxOpen(U2(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=om(l,d,f)}return n.someProp("transformPasted",d=>{l=d(l,n)}),l}const z2=/^(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 U2(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&im(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=sm(o[o.length-1],s.length));let u=rm(l,a);o.push(u),i=i.matchType(u.type),s=a}}),o)return W.from(o)}return n}function rm(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,W.from(n));return n}function im(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=im(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(W.from(rm(t,n,i+1))))}}function sm(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,sm(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(W.empty,!0);return n.copy(t.append(r))}function fu(n,e,t,r,i,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),i<r-1&&(l=fu(l,e,t,r,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(W.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function om(n,e,t){return e<n.openStart&&(n=new Y(fu(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new Y(fu(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const lm={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 am=null;function cm(){return am||(am=document.implementation.createHTMLDocument("title"))}function W2(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=cm().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&lm[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=n,i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function q2(n){let e=n.querySelectorAll(_t?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function K2(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.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={},J2={touchstart:!0,touchmove:!0};class G2{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 Y2(n){for(let e in Dt){let t=Dt[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{X2(n,r)&&!pu(n,r)&&(n.editable||!(r.type in Rt))&&t(n,r)},J2[e]?{passive:!0}:void 0)}Nt&&n.dom.addEventListener("input",()=>null),hu(n)}function Mr(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Z2(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function hu(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>pu(n,r))})}function pu(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function X2(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Q2(n,e){!pu(n,e)&&Dt[e.type]&&(n.editable||!(e.type in Rt))&&Dt[e.type](n,e)}Rt.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!dm(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(vn&&_t&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Hi&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,ti(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||V2(n,t)?t.preventDefault():Mr(n,"key")},Rt.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},Rt.keypress=(n,e)=>{let t=e;if(dm(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||rn&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof ce)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,i))&&n.dispatch(n.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function yl(n){return{left:n.clientX,top:n.clientY}}function eC(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function mu(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),i,!0):l(n,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function Ui(n,e,t){n.focused||n.focus();let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function tC(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&se.isSelectable(r)?(Ui(n,new se(t)),!0):!1}function nC(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof se&&(r=t.node);let s=n.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&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(Ui(n,se.create(n.state.doc,i)),!0):!1}function rC(n,e,t,r,i){return mu(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?nC(n,t):tC(n,t))}function iC(n,e,t,r){return mu(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function sC(n,e,t,r){return mu(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||oC(n,t,r)}function oC(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Ui(n,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)Ui(n,ce.create(r,l+1,l+1+o.content.size));else if(se.isSelectable(o))Ui(n,se.create(r,l));else continue;return!0}}function gu(n){return bl(n)}const um=rn?"metaKey":"ctrlKey";Dt.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=gu(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&eC(t,n.input.lastClick)&&!t[um]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s};let o=n.posAtCoords(yl(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new lC(n,o,t,!!r)):(s=="doubleClick"?iC:sC)(n,o.pos,o.inside,t)?t.preventDefault():Mr(n,"pointer"))};class lC{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[um],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.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 t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(yl(e))),this.updateAllowDefault(e),this.allowDefault||!t?Mr(this.view,"pointer"):rC(this.view,t.pos,t.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(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ui(this.view,ue.near(this.view.state.doc.resolve(t.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=n=>{n.input.lastTouch=Date.now(),gu(n),Mr(n,"pointer")},Dt.touchmove=n=>{n.input.lastTouch=Date.now(),Mr(n,"pointer")},Dt.contextmenu=n=>gu(n);function dm(n,e){return n.composing?!0:Nt&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const aC=vn?5e3:-1;Rt.compositionstart=Rt.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),bl(n,!0),n.markCursor=null;else if(bl(n),bn&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.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){n.domSelection().collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}fm(n,aC)},Rt.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,fm(n,20))};function fm(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>bl(n),e))}function hm(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=uC());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function cC(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=t2(e.focusNode,e.focusOffset),r=n2(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function uC(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function bl(n,e=!1){if(!(vn&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),hm(n),e||n.docView&&n.docView.dirty){let t=lu(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):n.updateState(n.state),!0}return!1}}function dC(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const to=$t&&Sr<15||Hi&&a2<604;Dt.copy=Rt.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=to?null:t.clipboardData,o=r.content(),{dom:l,text:a}=tm(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):dC(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function fC(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function hC(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?no(n,r.value,null,i,e):no(n,r.textContent,r.innerHTML,i,e)},50)}function no(n,e,t,r,i){let s=nm(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,s||Y.empty)))return!0;if(!s)return!1;let o=fC(s),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function pm(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Rt.paste=(n,e)=>{let t=e;if(n.composing&&!vn)return;let r=to?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&no(n,pm(r),r.getData("text/html"),i,t)?t.preventDefault():hC(n,t)};class mm{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const gm=rn?"altKey":"ctrlKey";Dt.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(yl(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof se?i.to-1:i.to))){if(r&&r.mightDrag)o=se.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(o=se.create(n.state.doc,d.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:u}=tm(n,l);t.dataTransfer.clearData(),t.dataTransfer.setData(to?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",to||t.dataTransfer.setData("text/plain",c),n.dragging=new mm(u,!t[gm],o)},Dt.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},Rt.dragover=Rt.dragenter=(n,e)=>e.preventDefault(),Rt.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(yl(t));if(!i)return;let s=n.state.doc.resolve(i.pos),o=r&&r.slice;o?n.someProp("transformPasted",p=>{o=p(o,n)}):o=nm(n,pm(t.dataTransfer),to?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[gm]);if(n.someProp("handleDrop",p=>p(n,t,o||Y.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?op(n.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let c=n.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(cu(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},Dt.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&nr(n)},20))},Dt.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},Dt.beforeinput=(n,e)=>{if(_t&&vn&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,ti(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in Rt)Dt[n]=Rt[n];function ro(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class vl{constructor(e,t){this.toDOM=e,this.spec=t||si,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.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 vl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ro(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Or{constructor(e,t){this.attrs=e,this.spec=t||si}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new ut(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Or&&ro(this.attrs,e.attrs)&&ro(this.spec,e.spec)}static is(e){return e.type instanceof Or}destroy(){}}class yu{constructor(e,t){this.attrs=e,this.spec=t||si}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new ut(s.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof yu&&ro(this.attrs,e.attrs)&&ro(this.spec,e.spec)}destroy(){}}class ut{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new ut(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new ut(e,e,new vl(t,r))}static inline(e,t,r,i){return new ut(e,t,new Or(r,i))}static node(e,t,r,i){return new ut(e,t,new yu(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Or}get widget(){return this.type instanceof vl}}const Wi=[],si={};class He{constructor(e,t){this.local=e.length?e:Wi,this.children=t.length?t:Wi}static create(e,t){return t.length?wl(t,e,0,si):At}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&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]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,i+l,s)}}map(e,t,r){return this==At||e.maps.length==0?this:this.mapInner(e,t,0,0,r||si)}mapInner(e,t,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(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?pC(this.children,o||[],e,t,r,i,s):o?new He(o.sort(oi),Wi):At}add(e,t){return t.length?this==At?He.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=bm(t,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,wl(u,l,c+1,si)),s+=3}});let o=ym(s?vm(t):t,-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,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+t,a=r[s+1]+t;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,t)&&(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,t){if(this==At)return this;if(t.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+t.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),Wi);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 t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return bu(this.localsInner(e))}localsInner(e){if(this==At)return Wi;if(e.inlineContent||!this.local.some(Or.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Or||t.push(this.local[r]);return t}}He.empty=new He([],[]),He.removeOverlap=bu;const At=He.empty;class _r{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,si));return _r.from(r)}forChild(e,t){if(t.isLeaf)return He.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);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 t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?bu(r?t:t.sort(oi)):Wi}static from(e){switch(e.length){case 0:return At;case 1:return e[0];default:return new _r(e.every(t=>t instanceof He)?e:e.reduce((t,r)=>t.concat(r instanceof He?r:r.members),[]))}}}function pC(n,e,t,r,i,s,o){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let d=0;t.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 C=l[w]+u-d;h>=C?l[w+1]=f<=C?-2:-1:f>=u&&v&&(l[w]+=v,l[w+1]+=v)}d+=v}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),d=u-i;if(d<0||d>=r.content.size){a=!0;continue}let f=t.map(n[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(t,v,u+1,n[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=mC(l,n,e,t,i,s,o),u=wl(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 ym(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new ut(i.from+e,i.to+e,i.type))}return t}function mC(n,e,t,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?t.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<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function bm(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<r&&((i||(i=[])).push(o),n[s]=null);return i}function vm(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function wl(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let c=bm(n,l,a+t);if(c){s=!0;let u=wl(c,l,t+a+1,r);u!=At&&i.push(a,a+l.nodeSize,u)}});let o=ym(s?vm(n):n,-t).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(n,e){return n.from-e.from||n.to-e.to}function bu(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),wm(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),wm(e,i,r.copy(s.from,r.to)));break}}}return e}function wm(n,e,t){for(;e<n.length&&oi(t,n[e])>0;)e++;n.splice(e,0,t)}function vu(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=At&&e.push(r)}),n.cursorWrapper&&e.push(He.create(n.state.doc,[n.cursorWrapper.deco])),_r.from(e)}const gC={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},yC=$t&&Sr<=11;class bC{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 vC{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new bC,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]);$t&&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()}),yC&&(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,gC)),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 t=0;t<e.length;t++)this.queue.push(e[t]);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(Kp(this.view)){if(this.suppressingSelectionUpdates)return nr(this.view);if($t&&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 t=new Set,r;for(let s=e.focusNode;s;s=Js(s))t.add(s);for(let s=e.anchorNode;s;s=Js(s))if(t.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 t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Kp(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let d=this.registerMutation(t[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||xC(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&&pl(r)&&(c=lu(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),wC(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,t){if(t.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++)t.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($t&&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?kt(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?kt(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 Cm=new WeakMap,xm=!1;function wC(n){if(!Cm.has(n)&&(Cm.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=bn,xm)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."),xm=!0}}function km(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return ei(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function CC(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return km(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?km(n,t):null}function xC(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function kC(n,e,t){let{node:r,fromOffset:i,toOffset:s,from:o,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,u=a.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],pl(a)||c.push({node:a.focusNode,offset:a.focusOffset})),_t&&n.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=n.state.doc,f=n.someProp("domParser")||Fc.fromSchema(n.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:SC,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 SC(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Nt&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Nt&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const EC=/^(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 TC(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let _=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,A=lu(n,_);if(A&&!n.state.selection.eq(A)){if(_t&&vn&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",P=>P(n,ti(13,"Enter"))))return;let R=n.state.tr.setSelection(A);_=="pointer"?R.setMeta("pointer",!0):_=="key"&&R.scrollIntoView(),s&&R.setMeta("composition",s),n.dispatch(R)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=kC(n,e,t),u=n.state.doc,d=u.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=OC(d.content,c.doc.content,c.from,f,h);if((Hi&&n.input.lastIOSEnter>Date.now()-225||vn)&&i.some(_=>_.nodeType==1&&!EC.test(_.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",_=>_(n,ti(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof ce&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let _=Sm(n,n.state.doc,c.sel);if(_&&!_.eq(n.state.selection)){let A=n.state.tr.setSelection(_);s&&A.setMeta("composition",s),n.dispatch(A)}}return}n.input.domChangeCount++,n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof ce&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),$t&&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,C;if((Hi&&n.input.lastIOSEnter>Date.now()-225&&(!S||i.some(_=>_.nodeName=="DIV"||_.nodeName=="P"))||!S&&g.pos<c.doc.content.size&&!g.sameParent(v)&&(C=ue.findFrom(c.doc.resolve(g.pos+1),1,!0))&&C.head==v.pos)&&n.someProp("handleKeyDown",_=>_(n,ti(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&MC(u,p.start,p.endA,g,v)&&n.someProp("handleKeyDown",_=>_(n,ti(8,"Backspace")))){vn&&_t&&n.domObserver.suppressSelectionUpdates();return}_t&&vn&&p.endB==p.start&&(n.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(()=>{n.someProp("handleKeyDown",function(_){return _(n,ti(13,"Enter"))})},20));let y=p.start,k=p.endA,E,T,N;if(S){if(g.pos==v.pos)$t&&Sr<=11&&g.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>nr(n),20)),E=n.state.tr.delete(y,k),T=u.resolve(p.start).marksAcross(u.resolve(p.endA));else if(p.endA==p.endB&&(N=AC(g.parent.content.cut(g.parentOffset,v.parentOffset),w.parent.content.cut(w.parentOffset,p.endA-w.start()))))E=n.state.tr,N.type=="add"?E.addMark(y,k,N.mark):E.removeMark(y,k,N.mark);else if(g.parent.child(g.index()).isText&&g.index()==v.index()-(v.textOffset?0:1)){let _=g.parent.textBetween(g.parentOffset,v.parentOffset);if(n.someProp("handleTextInput",A=>A(n,y,k,_)))return;E=n.state.tr.insertText(_,y,k)}}if(E||(E=n.state.tr.replace(y,k,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let _=Sm(n,E.doc,c.sel);_&&!(_t&&vn&&n.composing&&_.empty&&(p.start!=p.endB||n.input.lastAndroidDelete<Date.now()-100)&&(_.head==y||_.head==E.mapping.map(k)-1)||$t&&_.empty&&_.head==y)&&E.setSelection(_)}T&&E.ensureMarks(T),s&&E.setMeta("composition",s),n.dispatch(E.scrollIntoView())}function Sm(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:cu(n,e.resolve(t.anchor),e.resolve(t.head))}function AC(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,o,l,a;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<t.length;u++)s=t[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(n))return{mark:l,type:o}}function MC(n,e,t,r,i){if(t-e<=i.pos-r.pos||wu(r,!0,!1)<i.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=n.resolve(wu(s,!0,!0));return!o.parent.isTextblock||o.pos>t||wu(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function wu(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function OC(n,e,t,r,i){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:o,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let a=Math.max(0,s-Math.min(o,l));r-=o+a-s}if(o<s&&n.size<e.size){let a=r<=s&&r>=o?s-r:0;s-=a,s&&s<e.size&&Em(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<n.size&&Em(n.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function Em(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class _C{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new G2,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(_m),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=Mm(this),Am(this),this.nodeViews=Om(this),this.docView=Ip(this.state.doc,Tm(this),vu(this),this.dom,this),this.domObserver=new vC(this,(r,i,s,o)=>TC(this,r,i,s,o)),this.domObserver.start(),Y2(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&hu(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(_m),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(hm(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Om(this);DC(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&hu(this),this.editable=Mm(this),Am(this);let a=vu(this),c=Tm(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&&d2(this);if(o){this.domObserver.stop();let h=d&&($t||_t)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&NC(i.selection,e.selection);if(d){let p=_t?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=cC(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ip(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&I2(this))?nr(this,h):(Wp(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&&f2(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof se){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&xp(this,t.getBoundingClientRect(),e)}else xp(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-t.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,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=t?t(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=t?t(l):l))return i}}hasFocus(){if($t){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&&h2(this.dom),nr(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return b2(this,e)}coordsAtPos(e,t=1){return Mp(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return k2(this,t||this.state,e)}pasteHTML(e,t){return no(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return no(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Z2(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],vu(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Qw())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Q2(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return Nt&&this.root.nodeType===11&&i2(this.dom.ownerDocument)==this.dom&&CC(this,e)||e}domSelection(){return this.root.getSelection()}}function Tm(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[ut.node(0,n.state.doc.content.size,e)]}function Am(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ut.widget(n.state.selection.head,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Mm(n){return!n.someProp("editable",e=>e(n.state)===!1)}function NC(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Om(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function DC(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function _m(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}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:"'"},Cl={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},RC=typeof navigator<"u"&&/Mac/.test(navigator.platform),LC=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),Cl[St]=String.fromCharCode(St);for(var Cu in Nr)Cl.hasOwnProperty(Cu)||(Cl[Cu]=Nr[Cu]);function IC(n){var e=RC&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||LC&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Cl:Nr)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const PC=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function FC(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");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))PC?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function BC(n){let e=Object.create(null);for(let t in n)e[FC(t)]=n[t];return e}function xu(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function $C(n){return new je({props:{handleKeyDown:ku(n)}})}function ku(n){let e=BC(n);return function(t,r){let i=IC(r),s,o=e[xu(i,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[xu(i,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||i.charCodeAt(0)>127)&&(s=Nr[r.keyCode])&&s!=i){let l=e[xu(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const jC=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Nm(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const HC=(n,e,t)=>{let r=Nm(n,t);if(!r)return!1;let i=Su(r);if(!i){let o=r.blockRange(),l=o&&Ii(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(!s.type.spec.isolating&&Im(n,i,e))return!0;if(r.parent.content.size==0&&(qi(s,"end")||se.isSelectable(s))){let o=dl(n.doc,r.before(),r.after(),Y.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(qi(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(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},VC=(n,e,t)=>{let r=Nm(n,t);if(!r)return!1;let i=Su(r);return i?Dm(n,i,e):!1},zC=(n,e,t)=>{let r=Rm(n,t);if(!r)return!1;let i=Eu(r);return i?Dm(n,i,e):!1};function Dm(n,e,t){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=dl(n.doc,s,a,Y.empty);if(!c||c.from!=s||c instanceof ht&&c.slice.size>=a-s)return!1;if(t){let u=n.tr.step(c);u.setSelection(ce.create(u.doc,s)),t(u.scrollIntoView())}return!0}function qi(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const UC=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=Su(r)}let o=s&&s.nodeBefore;return!o||!se.isSelectable(o)?!1:(e&&e(n.tr.setSelection(se.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function Su(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Rm(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const WC=(n,e,t)=>{let r=Rm(n,t);if(!r)return!1;let i=Eu(r);if(!i)return!1;let s=i.nodeAfter;if(Im(n,i,e))return!0;if(r.parent.content.size==0&&(qi(s,"start")||se.isSelectable(s))){let o=dl(n.doc,r.before(),r.after(),Y.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(qi(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(n.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},qC=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=Eu(r)}let o=s&&s.nodeAfter;return!o||!se.isSelectable(o)?!1:(e&&e(n.tr.setSelection(se.create(n.doc,s.pos)).scrollIntoView()),!0)};function Eu(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const KC=(n,e)=>{let t=n.selection,r=t instanceof se,i;if(r){if(t.node.isTextblock||!xr(n.doc,t.from))return!1;i=t.from}else if(i=ul(n.doc,t.from,-1),i==null)return!1;if(e){let s=n.tr.join(i);r&&s.setSelection(se.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},JC=(n,e)=>{let t=n.selection,r;if(t instanceof se){if(t.node.isTextblock||!xr(n.doc,t.to))return!1;r=t.to}else if(r=ul(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},GC=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&Ii(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},YC=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
39
- `).scrollIntoView()),!0)};function Lm(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const ZC=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=Lm(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(ue.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},XC=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof yn||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=Lm(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=n.tr.insert(o,s.createAndFill());l.setSelection(ce.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},QC=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Pi(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Ii(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)},ex=(n,e)=>{let{$from:t,to:r}=n.selection,i,s=t.sharedDepth(r);return s==0?!1:(i=t.before(s),e&&e(n.tr.setSelection(se.create(n.doc,i))),!0)};function tx(n,e,t){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)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||xr(n.doc,e.pos))?!1:(t&&t(n.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function Im(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s,o;if(r.type.spec.isolating||i.type.spec.isolating)return!1;if(tx(n,e,t))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(t){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=n.tr.step(new pt(e.pos-1,d,e.pos,d,new Y(f,1,0),s.length,!0)),p=d+2*s.length;xr(h.doc,p)&&h.join(p),t(h.scrollIntoView())}return!0}let a=ue.findFrom(e,1),c=a&&a.$from.blockRange(a.$to),u=c&&Ii(c);if(u!=null&&u>=e.depth)return t&&t(n.tr.lift(c,u).scrollIntoView()),!0;if(l&&qi(i,"start",!0)&&qi(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(t){let g=W.empty;for(let w=f.length-1;w>=0;w--)g=W.from(f[w].copy(g));let v=n.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));t(v.scrollIntoView())}return!0}}return!1}function Pm(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(ce.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const nx=Pm(-1),rx=Pm(1);function ix(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&zc(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Fm(n,e=null){return function(t,r){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let u=t.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,n,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 sx(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=!1,a=o;if(!o)return!1;if(o.depth>=2&&i.node(o.depth-1).type.compatibleContent(n)&&o.startIndex==0){if(i.index(o.depth-1)==0)return!1;let u=t.doc.resolve(o.start-2);a=new rl(u,u,o.depth),o.endIndex<o.parent.childCount&&(o=new rl(i,t.doc.resolve(s.end(o.depth)),o.depth)),l=!0}let c=zc(a,n,e,o);return c?(r&&r(ox(t.tr,o,c,l,n).scrollIntoView()),!0):!1}}function ox(n,e,t,r,i){let s=W.empty;for(let u=t.length-1;u>=0;u--)s=W.from(t[u].type.create(t[u].attrs,s));n.step(new pt(e.start-(r?2:0),e.end,e.start,e.end,new Y(s,0,0),t.length,!0));let o=0;for(let u=0;u<t.length;u++)t[u].type==i&&(o=u+1);let l=t.length-o,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&Pi(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function lx(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?ax(e,t,n,s):cx(e,t,s):!0:!1}}function ax(n,e,t,r){let i=n.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(t.create(null,r.parent.copy())),1,0),1,!0)),r=new rl(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=Ii(r);if(l==null)return!1;i.lift(r,l);let a=i.mapping.map(s,-1)-1;return xr(i.doc,a)&&i.join(a),e(i.scrollIntoView()),!0}function cx(n,e,t){let r=n.tr,i=t.parent;for(let h=t.end,p=t.endIndex-1,g=t.startIndex;p>g;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(t.start),o=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.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 ux(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);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!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=W.from(c?n.create():null),d=new Y(W.from(n.create(null,W.from(l.type.create(null,u)))),c?3:1,0),f=s.start,h=s.end;t(e.tr.step(new pt(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}function xl(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:i}=t,{storedMarks:s}=t;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=t.selection,i=t.doc,s=t.storedMarks,t}}}class kl{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:t,state:r}=this,{view:i}=t,{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,t=!0){const{rawCommands:r,editor:i,state:s}=this,{view:o}=i,l=[],a=!!e,c=e||s.tr,u=()=>(!a&&t&&!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,t),w=h(...g)(v);return l.push(w),d}])),run:u};return d}createCan(e){const{rawCommands:t,state:r}=this,i=!1,s=e||r.tr,o=this.buildProps(s,i);return{...Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...u)=>c(...u)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,i)}}buildProps(e,t=!0){const{rawCommands:r,editor:i,state:s}=this,{view:o}=i,l={tr:e,editor:i,view:o,state:xl({state:s,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}}class dx{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(i=>i!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}}function re(n,e,t){return n.config[e]===void 0&&n.parent?re(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?re(n.parent,e,t):null}):n.config[e]}function Sl(n){const e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Bm(n){const e=[],{nodeExtensions:t,markExtensions:r}=Sl(n),i=[...t,...r],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.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(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function Ce(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).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 Tu(n,e){return e.filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>Ce(t,r),{})}function $m(n){return typeof n=="function"}function ge(n,e=void 0,...t){return $m(n)?e?n.bind(e)(...t):n(...t):n}function fx(n={}){return Object.keys(n).length===0&&n.constructor===Object}function hx(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function jm(n,e){return n.style?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const i=e.reduce((s,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(t):hx(t.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...r,...i}}}}function Hm(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&fx(t)?!1:t!=null))}function px(n,e){var t;const r=Bm(n),{nodeExtensions:i,markExtensions:s}=Sl(n),o=(t=i.find(c=>re(c,"topNode")))===null||t===void 0?void 0:t.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=n.reduce((w,S)=>{const C=re(S,"extendNodeSchema",d);return{...w,...C?C(c):{}}},{}),h=Hm({...f,content:ge(re(c,"content",d)),marks:ge(re(c,"marks",d)),group:ge(re(c,"group",d)),inline:ge(re(c,"inline",d)),atom:ge(re(c,"atom",d)),selectable:ge(re(c,"selectable",d)),draggable:ge(re(c,"draggable",d)),code:ge(re(c,"code",d)),defining:ge(re(c,"defining",d)),isolating:ge(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=ge(re(c,"parseHTML",d));p&&(h.parseDOM=p.map(w=>jm(w,u)));const g=re(c,"renderHTML",d);g&&(h.toDOM=w=>g({node:w,HTMLAttributes:Tu(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=n.reduce((v,w)=>{const S=re(w,"extendMarkSchema",d);return{...v,...S?S(c):{}}},{}),h=Hm({...f,inclusive:ge(re(c,"inclusive",d)),excludes:ge(re(c,"excludes",d)),group:ge(re(c,"group",d)),spanning:ge(re(c,"spanning",d)),code:ge(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=ge(re(c,"parseHTML",d));p&&(h.parseDOM=p.map(v=>jm(v,u)));const g=re(c,"renderHTML",d);return g&&(h.toDOM=v=>g({mark:v,HTMLAttributes:Tu(v,u)})),[c.name,h]}));return new vw({topNode:o,nodes:l,marks:a})}function Au(n,e){return e.nodes[n]||e.marks[n]||null}function Vm(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}const mx=(n,e=500)=>{let t="";const r=n.parentOffset;return n.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%";t+=u.slice(0,Math.max(0,r-s))}),t};function Mu(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class io{constructor(e){this.find=e.find,this.handler=e.handler}}const gx=(n,e)=>{if(Mu(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function El(n){var e;const{editor:t,from:r,to:i,text:s,rules:o,plugin:l}=n,{view:a}=t;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=mx(c)+s;return o.forEach(f=>{if(u)return;const h=gx(d,f.find);if(!h)return;const p=a.state.tr,g=xl({state:a.state,transaction:p}),v={from:r-(h[0].length-s.length),to:i},{commands:w,chain:S,can:C}=new kl({editor:t,state:g});f.handler({state:g,range:v,match:h,commands:w,chain:S,can:C})===null||!p.steps.length||(p.setMeta(l,{transform:p,from:r,to:i,text:s}),a.dispatch(p),u=!0)}),u}function yx(n){const{editor:e,rules:t}=n,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;El({editor:e,from:c,to:d,text:u,rules:t,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return El({editor:e,from:s,to:o,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&El({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?El({editor:e,from:o.pos,to:o.pos,text:`
40
- `,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function bx(n){return typeof n=="number"}class vx{constructor(e){this.find=e.find,this.handler=e.handler}}const wx=(n,e,t)=>{if(Mu(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=n,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 Cx(n){const{editor:e,state:t,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=n,{commands:a,chain:c,can:u}=new kl({editor:e,state:t}),d=[];return t.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,"");wx(w,s.find,o).forEach(C=>{if(C.index===void 0)return;const y=g+C.index+1,k=y+C[0].length,E={from:t.tr.mapping.map(y),to:t.tr.mapping.map(k)},T=s.handler({state:t,range:E,match:C,commands:a,chain:c,can:u,pasteEvent:o,dropEvent:l});d.push(T)})}),d.every(h=>h!==null)}const xx=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function kx(n){const{editor:e,rules:t}=n;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=xl({state:u,transaction:g});if(!(!Cx({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 t.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:k,text:E}=w,T=k+E.length,N=xx(E);return a({rule:u,state:h,from:k,to:{b:T},pasteEvt:N})}const C=f.doc.content.findDiffStart(h.doc.content),y=f.doc.content.findDiffEnd(h.doc.content);if(!(!bx(C)||!y||C===y.b))return a({rule:u,state:h,from:C,to:y,pasteEvt:o})}}))}function Sx(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return[...new Set(e)]}class Ki{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=Ki.resolve(e),this.schema=px(this.extensions,t),this.setupExtensions()}static resolve(e){const t=Ki.sort(Ki.flatten(e)),r=Sx(t.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.`),t}static flatten(e){return e.map(t=>{const r={name:t.name,options:t.options,storage:t.storage},i=re(t,"addExtensions",r);return i?[t,...this.flatten(i())]:t}).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,t)=>{const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Au(t.name,this.schema)},i=re(t,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,t=Ki.sort([...this.extensions].reverse()),r=[],i=[],s=t.map(o=>{const l={name:o.name,options:o.options,storage:o.storage,editor:e,type:Au(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=$C(u);a.push(d);const f=re(o,"addInputRules",l);Vm(o,e.options.enableInputRules)&&f&&r.push(...f());const h=re(o,"addPasteRules",l);Vm(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[yx({editor:e,rules:r}),...kx({editor:e,rules:i}),...s]}get attributes(){return Bm(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=Sl(this.extensions);return Object.fromEntries(t.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=Tu(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 t;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Au(e.name,this.schema)};e.type==="mark"&&(!((t=ge(re(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&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 Ex(n){return Object.prototype.toString.call(n).slice(8,-1)}function Ou(n){return Ex(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Tl(n,e){const t={...n};return Ou(n)&&Ou(e)&&Object.keys(e).forEach(r=>{Ou(e[r])?r in n?t[r]=Tl(n[r],e[r]):Object.assign(t,{[r]:e[r]}):Object.assign(t,{[r]:e[r]})}),t}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=ge(re(this,"addOptions",{name:this.name}))),this.storage=ge(re(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Ue(e)}configure(e={}){const t=this.extend();return t.parent=this.parent,t.options=Tl(this.options,e),t.storage=ge(re(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new Ue({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ge(re(t,"addOptions",{name:t.name})),t.storage=ge(re(t,"addStorage",{name:t.name,options:t.options})),t}}function zm(n,e,t){const{from:r,to:i}=e,{blockSeparator:s=`
38
+ `))),0,0):Y.empty;let d=n.someProp("clipboardTextParser",f=>f(e,i,r,n));if(d)l=d;else{let f=i.marks(),{schema:h}=n.state,p=_n.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 n.someProp("transformPastedHTML",d=>{t=d(t,n)}),o=W2(t),Ys&&q2(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=(n.someProp("clipboardParser")||n.someProp("domParser")||Fc.fromSchema(n.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!z2.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=K2(om(l,+u[1],+u[2]),u[4]);else if(l=Y.maxOpen(U2(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=om(l,d,f)}return n.someProp("transformPasted",d=>{l=d(l,n)}),l}const z2=/^(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 U2(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(n.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&im(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=sm(o[o.length-1],s.length));let u=rm(l,a);o.push(u),i=i.matchType(u.type),s=a}}),o)return W.from(o)}return n}function rm(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,W.from(n));return n}function im(n,e,t,r,i){if(i<n.length&&i<e.length&&n[i]==e[i]){let s=im(n,e,t,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==n.length-1?t.type:n[i+1]))return r.copy(r.content.append(W.from(rm(t,n,i+1))))}}function sm(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,sm(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(W.empty,!0);return n.copy(t.append(r))}function fu(n,e,t,r,i,s){let o=e<0?n.firstChild:n.lastChild,l=o.content;return n.childCount>1&&(s=0),i<r-1&&(l=fu(l,e,t,r,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(W.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,o.copy(l))}function om(n,e,t){return e<n.openStart&&(n=new Y(fu(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new Y(fu(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const lm={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 am=null;function cm(){return am||(am=document.implementation.createHTMLDocument("title"))}function W2(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=cm().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),i;if((i=r&&lm[r[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=n,i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function q2(n){let e=n.querySelectorAll(_t?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function K2(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:i,openStart:s,openEnd:o}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.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={},J2={touchstart:!0,touchmove:!0};class G2{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 Y2(n){for(let e in Dt){let t=Dt[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{X2(n,r)&&!pu(n,r)&&(n.editable||!(r.type in Rt))&&t(n,r)},J2[e]?{passive:!0}:void 0)}Nt&&n.dom.addEventListener("input",()=>null),hu(n)}function Mr(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Z2(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function hu(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>pu(n,r))})}function pu(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function X2(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Q2(n,e){!pu(n,e)&&Dt[e.type]&&(n.editable||!(e.type in Rt))&&Dt[e.type](n,e)}Rt.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!dm(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(vn&&_t&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),Hi&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",i=>i(n,ti(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||V2(n,t)?t.preventDefault():Mr(n,"key")},Rt.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},Rt.keypress=(n,e)=>{let t=e;if(dm(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||rn&&t.metaKey)return;if(n.someProp("handleKeyPress",i=>i(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof ce)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(t.charCode);!/[\r\n]/.test(i)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,i))&&n.dispatch(n.state.tr.insertText(i).scrollIntoView()),t.preventDefault()}};function yl(n){return{left:n.clientX,top:n.clientY}}function ex(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function mu(n,e,t,r,i){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(n.someProp(e,l=>o>s.depth?l(n,t,s.nodeAfter,s.before(o),i,!0):l(n,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function Ui(n,e,t){n.focused||n.focus();let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function tx(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&se.isSelectable(r)?(Ui(n,new se(t)),!0):!1}function nx(n,e){if(e==-1)return!1;let t=n.state.selection,r,i;t instanceof se&&(r=t.node);let s=n.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&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(Ui(n,se.create(n.state.doc,i)),!0):!1}function rx(n,e,t,r,i){return mu(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(i?nx(n,t):tx(n,t))}function ix(n,e,t,r){return mu(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",i=>i(n,e,r))}function sx(n,e,t,r){return mu(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",i=>i(n,e,r))||ox(n,t,r)}function ox(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Ui(n,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)Ui(n,ce.create(r,l+1,l+1+o.content.size));else if(se.isSelectable(o))Ui(n,se.create(r,l));else continue;return!0}}function gu(n){return bl(n)}const um=rn?"metaKey":"ctrlKey";Dt.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=gu(n),i=Date.now(),s="singleClick";i-n.input.lastClick.time<500&&ex(t,n.input.lastClick)&&!t[um]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s};let o=n.posAtCoords(yl(t));o&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new lx(n,o,t,!!r)):(s=="doubleClick"?ix:sx)(n,o.pos,o.inside,t)?t.preventDefault():Mr(n,"pointer"))};class lx{constructor(e,t,r,i){this.view=e,this.pos=t,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[um],this.allowDefault=r.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let u=e.state.doc.resolve(t.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 t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(yl(e))),this.updateAllowDefault(e),this.allowDefault||!t?Mr(this.view,"pointer"):rx(this.view,t.pos,t.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(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ui(this.view,ue.near(this.view.state.doc.resolve(t.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=n=>{n.input.lastTouch=Date.now(),gu(n),Mr(n,"pointer")},Dt.touchmove=n=>{n.input.lastTouch=Date.now(),Mr(n,"pointer")},Dt.contextmenu=n=>gu(n);function dm(n,e){return n.composing?!0:Nt&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const ax=vn?5e3:-1;Rt.compositionstart=Rt.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),bl(n,!0),n.markCursor=null;else if(bl(n),bn&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.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){n.domSelection().collapse(o,o.nodeValue.length);break}else i=o,s=-1}}n.input.composing=!0}fm(n,ax)},Rt.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,fm(n,20))};function fm(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>bl(n),e))}function hm(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=ux());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function cx(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=t2(e.focusNode,e.focusOffset),r=n2(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let i=r.pmViewDesc;if(!i||!i.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function ux(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function bl(n,e=!1){if(!(vn&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),hm(n),e||n.docView&&n.docView.dirty){let t=lu(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):n.updateState(n.state),!0}return!1}}function dx(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const to=$t&&Sr<15||Hi&&a2<604;Dt.copy=Rt.cut=(n,e)=>{let t=e,r=n.state.selection,i=t.type=="cut";if(r.empty)return;let s=to?null:t.clipboardData,o=r.content(),{dom:l,text:a}=tm(n,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):dx(n,l),i&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function fx(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function hx(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?no(n,r.value,null,i,e):no(n,r.textContent,r.innerHTML,i,e)},50)}function no(n,e,t,r,i){let s=nm(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,i,s||Y.empty)))return!0;if(!s)return!1;let o=fx(s),l=o?n.state.tr.replaceSelectionWith(o,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function pm(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Rt.paste=(n,e)=>{let t=e;if(n.composing&&!vn)return;let r=to?null:t.clipboardData,i=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&no(n,pm(r),r.getData("text/html"),i,t)?t.preventDefault():hx(n,t)};class mm{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const gm=rn?"altKey":"ctrlKey";Dt.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let i=n.state.selection,s=i.empty?null:n.posAtCoords(yl(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof se?i.to-1:i.to))){if(r&&r.mightDrag)o=se.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(o=se.create(n.state.doc,d.posBefore))}}let l=(o||n.state.selection).content(),{dom:a,text:c,slice:u}=tm(n,l);t.dataTransfer.clearData(),t.dataTransfer.setData(to?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",to||t.dataTransfer.setData("text/plain",c),n.dragging=new mm(u,!t[gm],o)},Dt.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},Rt.dragover=Rt.dragenter=(n,e)=>e.preventDefault(),Rt.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let i=n.posAtCoords(yl(t));if(!i)return;let s=n.state.doc.resolve(i.pos),o=r&&r.slice;o?n.someProp("transformPasted",p=>{o=p(o,n)}):o=nm(n,pm(t.dataTransfer),to?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[gm]);if(n.someProp("handleDrop",p=>p(n,t,o||Y.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?op(n.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let c=n.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(cu(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},Dt.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&nr(n)},20))},Dt.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},Dt.beforeinput=(n,e)=>{if(_t&&vn&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,ti(8,"Backspace")))))return;let{$cursor:i}=n.state.selection;i&&i.pos>0&&n.dispatch(n.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let n in Rt)Dt[n]=Rt[n];function ro(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class vl{constructor(e,t){this.toDOM=e,this.spec=t||si,this.side=this.spec.side||0}map(e,t,r,i){let{pos:s,deleted:o}=e.mapResult(t.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 vl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&ro(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Or{constructor(e,t){this.attrs=e,this.spec=t||si}map(e,t,r,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new ut(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Or&&ro(this.attrs,e.attrs)&&ro(this.spec,e.spec)}static is(e){return e.type instanceof Or}destroy(){}}class yu{constructor(e,t){this.attrs=e,this.spec=t||si}map(e,t,r,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new ut(s.pos-r,o.pos-r,this)}valid(e,t){let{index:r,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(r)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof yu&&ro(this.attrs,e.attrs)&&ro(this.spec,e.spec)}destroy(){}}class ut{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new ut(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new ut(e,e,new vl(t,r))}static inline(e,t,r,i){return new ut(e,t,new Or(r,i))}static node(e,t,r,i){return new ut(e,t,new yu(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Or}get widget(){return this.type instanceof vl}}const Wi=[],si={};class He{constructor(e,t){this.local=e.length?e:Wi,this.children=t.length?t:Wi}static create(e,t){return t.length?wl(t,e,0,si):At}find(e,t,r){let i=[];return this.findInner(e??0,t??1e9,i,0,r),i}findInner(e,t,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&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]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,r,i+l,s)}}map(e,t,r){return this==At||e.maps.length==0?this:this.mapInner(e,t,0,0,r||si)}mapInner(e,t,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(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?px(this.children,o||[],e,t,r,i,s):o?new He(o.sort(oi),Wi):At}add(e,t){return t.length?this==At?He.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let i,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=bm(t,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,wl(u,l,c+1,si)),s+=3}});let o=ym(s?vm(t):t,-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,t){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+t,a=r[s+1]+t;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,t)&&(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,t){if(this==At)return this;if(t.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+t.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),Wi);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 t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return bu(this.localsInner(e))}localsInner(e){if(this==At)return Wi;if(e.inlineContent||!this.local.some(Or.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Or||t.push(this.local[r]);return t}}He.empty=new He([],[]),He.removeOverlap=bu;const At=He.empty;class _r{constructor(e){this.members=e}map(e,t){const r=this.members.map(i=>i.map(e,t,si));return _r.from(r)}forChild(e,t){if(t.isLeaf)return He.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);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 t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?bu(r?t:t.sort(oi)):Wi}static from(e){switch(e.length){case 0:return At;case 1:return e[0];default:return new _r(e.every(t=>t instanceof He)?e:e.reduce((t,r)=>t.concat(r instanceof He?r:r.members),[]))}}}function px(n,e,t,r,i,s,o){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let d=0;t.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=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),d=u-i;if(d<0||d>=r.content.size){a=!0;continue}let f=t.map(n[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(t,v,u+1,n[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=mx(l,n,e,t,i,s,o),u=wl(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 ym(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let i=n[r];t.push(new ut(i.from+e,i.to+e,i.type))}return t}function mx(n,e,t,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?t.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<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function bm(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,i=null;for(let s=0,o;s<n.length;s++)(o=n[s])&&o.from>t&&o.to<r&&((i||(i=[])).push(o),n[s]=null);return i}function vm(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function wl(n,e,t,r){let i=[],s=!1;e.forEach((l,a)=>{let c=bm(n,l,a+t);if(c){s=!0;let u=wl(c,l,t+a+1,r);u!=At&&i.push(a,a+l.nodeSize,u)}});let o=ym(s?vm(n):n,-t).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(n,e){return n.from-e.from||n.to-e.to}function bu(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[i]=s.copy(s.from,r.to),wm(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),wm(e,i,r.copy(s.from,r.to)));break}}}return e}function wm(n,e,t){for(;e<n.length&&oi(t,n[e])>0;)e++;n.splice(e,0,t)}function vu(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=At&&e.push(r)}),n.cursorWrapper&&e.push(He.create(n.state.doc,[n.cursorWrapper.deco])),_r.from(e)}const gx={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},yx=$t&&Sr<=11;class bx{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 vx{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new bx,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]);$t&&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()}),yx&&(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,gx)),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 t=0;t<e.length;t++)this.queue.push(e[t]);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(Kp(this.view)){if(this.suppressingSelectionUpdates)return nr(this.view);if($t&&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 t=new Set,r;for(let s=e.focusNode;s;s=Js(s))t.add(s);for(let s=e.anchorNode;s;s=Js(s))if(t.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 t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Kp(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let d=this.registerMutation(t[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||Cx(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&&pl(r)&&(c=lu(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),wx(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,t){if(t.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++)t.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($t&&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?kt(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?kt(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 xm=new WeakMap,Cm=!1;function wx(n){if(!xm.has(n)&&(xm.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=bn,Cm)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."),Cm=!0}}function km(n,e){let t=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=n.domAtPos(n.state.selection.anchor);return ei(o.node,o.offset,i,s)&&([t,r,i,s]=[i,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:i,focusOffset:s}}function xx(n,e){if(e.getComposedRanges){let i=e.getComposedRanges(n.root)[0];if(i)return km(n,i)}let t;function r(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?km(n,t):null}function Cx(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function kx(n,e,t){let{node:r,fromOffset:i,toOffset:s,from:o,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,u=a.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],pl(a)||c.push({node:a.focusNode,offset:a.focusOffset})),_t&&n.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=n.state.doc,f=n.someProp("domParser")||Fc.fromSchema(n.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:Sx,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 Sx(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(Nt&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||Nt&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Ex=/^(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 Tx(n,e,t,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let _=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,A=lu(n,_);if(A&&!n.state.selection.eq(A)){if(_t&&vn&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",P=>P(n,ti(13,"Enter"))))return;let R=n.state.tr.setSelection(A);_=="pointer"?R.setMeta("pointer",!0):_=="key"&&R.scrollIntoView(),s&&R.setMeta("composition",s),n.dispatch(R)}return}let o=n.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=kx(n,e,t),u=n.state.doc,d=u.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=Ox(d.content,c.doc.content,c.from,f,h);if((Hi&&n.input.lastIOSEnter>Date.now()-225||vn)&&i.some(_=>_.nodeType==1&&!Ex.test(_.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",_=>_(n,ti(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof ce&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let _=Sm(n,n.state.doc,c.sel);if(_&&!_.eq(n.state.selection)){let A=n.state.tr.setSelection(_);s&&A.setMeta("composition",s),n.dispatch(A)}}return}n.input.domChangeCount++,n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof ce&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),$t&&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((Hi&&n.input.lastIOSEnter>Date.now()-225&&(!S||i.some(_=>_.nodeName=="DIV"||_.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)&&n.someProp("handleKeyDown",_=>_(n,ti(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Mx(u,p.start,p.endA,g,v)&&n.someProp("handleKeyDown",_=>_(n,ti(8,"Backspace")))){vn&&_t&&n.domObserver.suppressSelectionUpdates();return}_t&&vn&&p.endB==p.start&&(n.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(()=>{n.someProp("handleKeyDown",function(_){return _(n,ti(13,"Enter"))})},20));let y=p.start,k=p.endA,E,T,N;if(S){if(g.pos==v.pos)$t&&Sr<=11&&g.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>nr(n),20)),E=n.state.tr.delete(y,k),T=u.resolve(p.start).marksAcross(u.resolve(p.endA));else if(p.endA==p.endB&&(N=Ax(g.parent.content.cut(g.parentOffset,v.parentOffset),w.parent.content.cut(w.parentOffset,p.endA-w.start()))))E=n.state.tr,N.type=="add"?E.addMark(y,k,N.mark):E.removeMark(y,k,N.mark);else if(g.parent.child(g.index()).isText&&g.index()==v.index()-(v.textOffset?0:1)){let _=g.parent.textBetween(g.parentOffset,v.parentOffset);if(n.someProp("handleTextInput",A=>A(n,y,k,_)))return;E=n.state.tr.insertText(_,y,k)}}if(E||(E=n.state.tr.replace(y,k,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let _=Sm(n,E.doc,c.sel);_&&!(_t&&vn&&n.composing&&_.empty&&(p.start!=p.endB||n.input.lastAndroidDelete<Date.now()-100)&&(_.head==y||_.head==E.mapping.map(k)-1)||$t&&_.empty&&_.head==y)&&E.setSelection(_)}T&&E.ensureMarks(T),s&&E.setMeta("composition",s),n.dispatch(E.scrollIntoView())}function Sm(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:cu(n,e.resolve(t.anchor),e.resolve(t.head))}function Ax(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,i=t,s=r,o,l,a;for(let u=0;u<r.length;u++)i=r[u].removeFromSet(i);for(let u=0;u<t.length;u++)s=t[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(n))return{mark:l,type:o}}function Mx(n,e,t,r,i){if(t-e<=i.pos-r.pos||wu(r,!0,!1)<i.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=n.resolve(wu(s,!0,!0));return!o.parent.isTextblock||o.pos>t||wu(o,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function wu(n,e,t){let r=n.depth,i=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,i++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function Ox(n,e,t,r,i){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:o,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(i=="end"){let a=Math.max(0,s-Math.min(o,l));r-=o+a-s}if(o<s&&n.size<e.size){let a=r<=s&&r>=o?s-r:0;s-=a,s&&s<e.size&&Em(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<n.size&&Em(n.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function Em(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class _x{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new G2,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(_m),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=Mm(this),Am(this),this.nodeViews=Om(this),this.docView=Ip(this.state.doc,Tm(this),vu(this),this.dom,this),this.domObserver=new vx(this,(r,i,s,o)=>Tx(this,r,i,s,o)),this.domObserver.start(),Y2(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&hu(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(_m),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(hm(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Om(this);Dx(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&hu(this),this.editable=Mm(this),Am(this);let a=vu(this),c=Tm(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&&d2(this);if(o){this.domObserver.stop();let h=d&&($t||_t)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Nx(i.selection,e.selection);if(d){let p=_t?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=cx(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ip(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&I2(this))?nr(this,h):(Wp(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&&f2(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof se){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Cp(this,t.getBoundingClientRect(),e)}else Cp(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,i=-1;if(this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-t.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,t){let r=this._props&&this._props[e],i;if(r!=null&&(i=t?t(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=t?t(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=t?t(l):l))return i}}hasFocus(){if($t){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&&h2(this.dom),nr(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return b2(this,e)}coordsAtPos(e,t=1){return Mp(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let i=this.docView.posFromDOM(e,t,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return k2(this,t||this.state,e)}pasteHTML(e,t){return no(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return no(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Z2(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],vu(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Qw())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Q2(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return Nt&&this.root.nodeType===11&&i2(this.dom.ownerDocument)==this.dom&&xx(this,e)||e}domSelection(){return this.root.getSelection()}}function Tm(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[ut.node(0,n.state.doc.content.size,e)]}function Am(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ut.widget(n.state.selection.head,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Mm(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Nx(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Om(n){let e=Object.create(null);function t(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Dx(n,e){let t=0,r=0;for(let i in n){if(n[i]!=e[i])return!0;t++}for(let i in e)r++;return t!=r}function _m(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}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:"'"},xl={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Rx=typeof navigator<"u"&&/Mac/.test(navigator.platform),Lx=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),xl[St]=String.fromCharCode(St);for(var xu in Nr)xl.hasOwnProperty(xu)||(xl[xu]=Nr[xu]);function Ix(n){var e=Rx&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Lx&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?xl:Nr)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Px=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Fx(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");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))Px?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Bx(n){let e=Object.create(null);for(let t in n)e[Fx(t)]=n[t];return e}function Cu(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function $x(n){return new je({props:{handleKeyDown:ku(n)}})}function ku(n){let e=Bx(n);return function(t,r){let i=Ix(r),s,o=e[Cu(i,r)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Cu(i,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||i.charCodeAt(0)>127)&&(s=Nr[r.keyCode])&&s!=i){let l=e[Cu(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const jx=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Nm(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Hx=(n,e,t)=>{let r=Nm(n,t);if(!r)return!1;let i=Su(r);if(!i){let o=r.blockRange(),l=o&&Ii(o);return l==null?!1:(e&&e(n.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(!s.type.spec.isolating&&Im(n,i,e))return!0;if(r.parent.content.size==0&&(qi(s,"end")||se.isSelectable(s))){let o=dl(n.doc,r.before(),r.after(),Y.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(qi(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(n.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},Vx=(n,e,t)=>{let r=Nm(n,t);if(!r)return!1;let i=Su(r);return i?Dm(n,i,e):!1},zx=(n,e,t)=>{let r=Rm(n,t);if(!r)return!1;let i=Eu(r);return i?Dm(n,i,e):!1};function Dm(n,e,t){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=dl(n.doc,s,a,Y.empty);if(!c||c.from!=s||c instanceof ht&&c.slice.size>=a-s)return!1;if(t){let u=n.tr.step(c);u.setSelection(ce.create(u.doc,s)),t(u.scrollIntoView())}return!0}function qi(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Ux=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=Su(r)}let o=s&&s.nodeBefore;return!o||!se.isSelectable(o)?!1:(e&&e(n.tr.setSelection(se.create(n.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function Su(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Rm(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Wx=(n,e,t)=>{let r=Rm(n,t);if(!r)return!1;let i=Eu(r);if(!i)return!1;let s=i.nodeAfter;if(Im(n,i,e))return!0;if(r.parent.content.size==0&&(qi(s,"start")||se.isSelectable(s))){let o=dl(n.doc,r.before(),r.after(),Y.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=n.tr.step(o);l.setSelection(qi(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(n.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},qx=(n,e,t)=>{let{$head:r,empty:i}=n.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=Eu(r)}let o=s&&s.nodeAfter;return!o||!se.isSelectable(o)?!1:(e&&e(n.tr.setSelection(se.create(n.doc,s.pos)).scrollIntoView()),!0)};function Eu(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Kx=(n,e)=>{let t=n.selection,r=t instanceof se,i;if(r){if(t.node.isTextblock||!Cr(n.doc,t.from))return!1;i=t.from}else if(i=ul(n.doc,t.from,-1),i==null)return!1;if(e){let s=n.tr.join(i);r&&s.setSelection(se.create(s.doc,i-n.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Jx=(n,e)=>{let t=n.selection,r;if(t instanceof se){if(t.node.isTextblock||!Cr(n.doc,t.to))return!1;r=t.to}else if(r=ul(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Gx=(n,e)=>{let{$from:t,$to:r}=n.selection,i=t.blockRange(r),s=i&&Ii(i);return s==null?!1:(e&&e(n.tr.lift(i,s).scrollIntoView()),!0)},Yx=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
39
+ `).scrollIntoView()),!0)};function Lm(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Zx=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=Lm(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,o.createAndFill());a.setSelection(ue.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Xx=(n,e)=>{let t=n.selection,{$from:r,$to:i}=t;if(t instanceof yn||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=Lm(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=n.tr.insert(o,s.createAndFill());l.setSelection(ce.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},Qx=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Pi(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),i=r&&Ii(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)},eC=(n,e)=>{let{$from:t,to:r}=n.selection,i,s=t.sharedDepth(r);return s==0?!1:(i=t.before(s),e&&e(n.tr.setSelection(se.create(n.doc,i))),!0)};function tC(n,e,t){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)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Cr(n.doc,e.pos))?!1:(t&&t(n.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function Im(n,e,t){let r=e.nodeBefore,i=e.nodeAfter,s,o;if(r.type.spec.isolating||i.type.spec.isolating)return!1;if(tC(n,e,t))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(t){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=n.tr.step(new pt(e.pos-1,d,e.pos,d,new Y(f,1,0),s.length,!0)),p=d+2*s.length;Cr(h.doc,p)&&h.join(p),t(h.scrollIntoView())}return!0}let a=ue.findFrom(e,1),c=a&&a.$from.blockRange(a.$to),u=c&&Ii(c);if(u!=null&&u>=e.depth)return t&&t(n.tr.lift(c,u).scrollIntoView()),!0;if(l&&qi(i,"start",!0)&&qi(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(t){let g=W.empty;for(let w=f.length-1;w>=0;w--)g=W.from(f[w].copy(g));let v=n.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));t(v.scrollIntoView())}return!0}}return!1}function Pm(n){return function(e,t){let r=e.selection,i=n<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(ce.create(e.doc,n<0?i.start(s):i.end(s)))),!0):!1}}const nC=Pm(-1),rC=Pm(1);function iC(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=o&&zc(o,n,e);return l?(r&&r(t.tr.wrap(o,l).scrollIntoView()),!0):!1}}function Fm(n,e=null){return function(t,r){let i=!1;for(let s=0;s<t.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(o,l,(a,c)=>{if(i)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)i=!0;else{let u=t.doc.resolve(c),d=u.index();i=u.parent.canReplaceWith(d,d+1,n)}})}if(!i)return!1;if(r){let s=t.tr;for(let o=0;o<t.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[o];s.setBlockType(l,a,n,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 sC(n,e=null){return function(t,r){let{$from:i,$to:s}=t.selection,o=i.blockRange(s),l=!1,a=o;if(!o)return!1;if(o.depth>=2&&i.node(o.depth-1).type.compatibleContent(n)&&o.startIndex==0){if(i.index(o.depth-1)==0)return!1;let u=t.doc.resolve(o.start-2);a=new rl(u,u,o.depth),o.endIndex<o.parent.childCount&&(o=new rl(i,t.doc.resolve(s.end(o.depth)),o.depth)),l=!0}let c=zc(a,n,e,o);return c?(r&&r(oC(t.tr,o,c,l,n).scrollIntoView()),!0):!1}}function oC(n,e,t,r,i){let s=W.empty;for(let u=t.length-1;u>=0;u--)s=W.from(t[u].type.create(t[u].attrs,s));n.step(new pt(e.start-(r?2:0),e.end,e.start,e.end,new Y(s,0,0),t.length,!0));let o=0;for(let u=0;u<t.length;u++)t[u].type==i&&(o=u+1);let l=t.length-o,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&Pi(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function lC(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?aC(e,t,n,s):cC(e,t,s):!0:!1}}function aC(n,e,t,r){let i=n.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(t.create(null,r.parent.copy())),1,0),1,!0)),r=new rl(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=Ii(r);if(l==null)return!1;i.lift(r,l);let a=i.mapping.map(s,-1)-1;return Cr(i.doc,a)&&i.join(a),e(i.scrollIntoView()),!0}function cC(n,e,t){let r=n.tr,i=t.parent;for(let h=t.end,p=t.endIndex-1,g=t.startIndex;p>g;p--)h-=i.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(t.start),o=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.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 uC(n){return function(e,t){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,c=>c.childCount>0&&c.firstChild.type==n);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!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=W.from(c?n.create():null),d=new Y(W.from(n.create(null,W.from(l.type.create(null,u)))),c?3:1,0),f=s.start,h=s.end;t(e.tr.step(new pt(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}function Cl(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:i}=t,{storedMarks:s}=t;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=t.selection,i=t.doc,s=t.storedMarks,t}}}class kl{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:t,state:r}=this,{view:i}=t,{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,t=!0){const{rawCommands:r,editor:i,state:s}=this,{view:o}=i,l=[],a=!!e,c=e||s.tr,u=()=>(!a&&t&&!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,t),w=h(...g)(v);return l.push(w),d}])),run:u};return d}createCan(e){const{rawCommands:t,state:r}=this,i=!1,s=e||r.tr,o=this.buildProps(s,i);return{...Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...u)=>c(...u)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,i)}}buildProps(e,t=!0){const{rawCommands:r,editor:i,state:s}=this,{view:o}=i,l={tr:e,editor:i,view:o,state:Cl({state:s,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}}class dC{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){const r=this.callbacks[e];return r&&r.forEach(i=>i.apply(this,t)),this}off(e,t){const r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(i=>i!==t):delete this.callbacks[e]),this}removeAllListeners(){this.callbacks={}}}function re(n,e,t){return n.config[e]===void 0&&n.parent?re(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?re(n.parent,e,t):null}):n.config[e]}function Sl(n){const e=n.filter(i=>i.type==="extension"),t=n.filter(i=>i.type==="node"),r=n.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Bm(n){const e=[],{nodeExtensions:t,markExtensions:r}=Sl(n),i=[...t,...r],s={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.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(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function xe(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).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 Tu(n,e){return e.filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>xe(t,r),{})}function $m(n){return typeof n=="function"}function ge(n,e=void 0,...t){return $m(n)?e?n.bind(e)(...t):n(...t):n}function fC(n={}){return Object.keys(n).length===0&&n.constructor===Object}function hC(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function jm(n,e){return n.style?n:{...n,getAttrs:t=>{const r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;const i=e.reduce((s,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(t):hC(t.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...r,...i}}}}function Hm(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&fC(t)?!1:t!=null))}function pC(n,e){var t;const r=Bm(n),{nodeExtensions:i,markExtensions:s}=Sl(n),o=(t=i.find(c=>re(c,"topNode")))===null||t===void 0?void 0:t.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=n.reduce((w,S)=>{const x=re(S,"extendNodeSchema",d);return{...w,...x?x(c):{}}},{}),h=Hm({...f,content:ge(re(c,"content",d)),marks:ge(re(c,"marks",d)),group:ge(re(c,"group",d)),inline:ge(re(c,"inline",d)),atom:ge(re(c,"atom",d)),selectable:ge(re(c,"selectable",d)),draggable:ge(re(c,"draggable",d)),code:ge(re(c,"code",d)),defining:ge(re(c,"defining",d)),isolating:ge(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=ge(re(c,"parseHTML",d));p&&(h.parseDOM=p.map(w=>jm(w,u)));const g=re(c,"renderHTML",d);g&&(h.toDOM=w=>g({node:w,HTMLAttributes:Tu(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=n.reduce((v,w)=>{const S=re(w,"extendMarkSchema",d);return{...v,...S?S(c):{}}},{}),h=Hm({...f,inclusive:ge(re(c,"inclusive",d)),excludes:ge(re(c,"excludes",d)),group:ge(re(c,"group",d)),spanning:ge(re(c,"spanning",d)),code:ge(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=ge(re(c,"parseHTML",d));p&&(h.parseDOM=p.map(v=>jm(v,u)));const g=re(c,"renderHTML",d);return g&&(h.toDOM=v=>g({mark:v,HTMLAttributes:Tu(v,u)})),[c.name,h]}));return new vw({topNode:o,nodes:l,marks:a})}function Au(n,e){return e.nodes[n]||e.marks[n]||null}function Vm(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}const mC=(n,e=500)=>{let t="";const r=n.parentOffset;return n.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%";t+=u.slice(0,Math.max(0,r-s))}),t};function Mu(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class io{constructor(e){this.find=e.find,this.handler=e.handler}}const gC=(n,e)=>{if(Mu(e))return e.exec(n);const t=e(n);if(!t)return null;const r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function El(n){var e;const{editor:t,from:r,to:i,text:s,rules:o,plugin:l}=n,{view:a}=t;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=mC(c)+s;return o.forEach(f=>{if(u)return;const h=gC(d,f.find);if(!h)return;const p=a.state.tr,g=Cl({state:a.state,transaction:p}),v={from:r-(h[0].length-s.length),to:i},{commands:w,chain:S,can:x}=new kl({editor:t,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 yC(n){const{editor:e,rules:t}=n,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;El({editor:e,from:c,to:d,text:u,rules:t,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return El({editor:e,from:s,to:o,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&El({editor:e,from:s.pos,to:s.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?El({editor:e,from:o.pos,to:o.pos,text:`
40
+ `,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function bC(n){return typeof n=="number"}class vC{constructor(e){this.find=e.find,this.handler=e.handler}}const wC=(n,e,t)=>{if(Mu(e))return[...n.matchAll(e)];const r=e(n,t);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=n,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 xC(n){const{editor:e,state:t,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=n,{commands:a,chain:c,can:u}=new kl({editor:e,state:t}),d=[];return t.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,"");wC(w,s.find,o).forEach(x=>{if(x.index===void 0)return;const y=g+x.index+1,k=y+x[0].length,E={from:t.tr.mapping.map(y),to:t.tr.mapping.map(k)},T=s.handler({state:t,range:E,match:x,commands:a,chain:c,can:u,pasteEvent:o,dropEvent:l});d.push(T)})}),d.every(h=>h!==null)}const CC=n=>{var e;const t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function kC(n){const{editor:e,rules:t}=n;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=Cl({state:u,transaction:g});if(!(!xC({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 t.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:k,text:E}=w,T=k+E.length,N=CC(E);return a({rule:u,state:h,from:k,to:{b:T},pasteEvt:N})}const x=f.doc.content.findDiffStart(h.doc.content),y=f.doc.content.findDiffEnd(h.doc.content);if(!(!bC(x)||!y||x===y.b))return a({rule:u,state:h,from:x,to:y,pasteEvt:o})}}))}function SC(n){const e=n.filter((t,r)=>n.indexOf(t)!==r);return[...new Set(e)]}class Ki{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=Ki.resolve(e),this.schema=pC(this.extensions,t),this.setupExtensions()}static resolve(e){const t=Ki.sort(Ki.flatten(e)),r=SC(t.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.`),t}static flatten(e){return e.map(t=>{const r={name:t.name,options:t.options,storage:t.storage},i=re(t,"addExtensions",r);return i?[t,...this.flatten(i())]:t}).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,t)=>{const r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Au(t.name,this.schema)},i=re(t,"addCommands",r);return i?{...e,...i()}:e},{})}get plugins(){const{editor:e}=this,t=Ki.sort([...this.extensions].reverse()),r=[],i=[],s=t.map(o=>{const l={name:o.name,options:o.options,storage:o.storage,editor:e,type:Au(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=$x(u);a.push(d);const f=re(o,"addInputRules",l);Vm(o,e.options.enableInputRules)&&f&&r.push(...f());const h=re(o,"addPasteRules",l);Vm(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[yC({editor:e,rules:r}),...kC({editor:e,rules:i}),...s]}get attributes(){return Bm(this.extensions)}get nodeViews(){const{editor:e}=this,{nodeExtensions:t}=Sl(this.extensions);return Object.fromEntries(t.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=Tu(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 t;this.editor.extensionStorage[e.name]=e.storage;const r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Au(e.name,this.schema)};e.type==="mark"&&(!((t=ge(re(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&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 EC(n){return Object.prototype.toString.call(n).slice(8,-1)}function Ou(n){return EC(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Tl(n,e){const t={...n};return Ou(n)&&Ou(e)&&Object.keys(e).forEach(r=>{Ou(e[r])?r in n?t[r]=Tl(n[r],e[r]):Object.assign(t,{[r]:e[r]}):Object.assign(t,{[r]:e[r]})}),t}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=ge(re(this,"addOptions",{name:this.name}))),this.storage=ge(re(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new Ue(e)}configure(e={}){const t=this.extend();return t.parent=this.parent,t.options=Tl(this.options,e),t.storage=ge(re(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new Ue({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ge(re(t,"addOptions",{name:t.name})),t.storage=ge(re(t,"addStorage",{name:t.name,options:t.options})),t}}function zm(n,e,t){const{from:r,to:i}=e,{blockSeparator:s=`
41
41
 
42
- `,textSerializers:o={}}=t||{};let l="";return n.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 Um(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const Tx=Ue.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new je({key:new We("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{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=Um(t);return zm(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),Ax=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),Mx=(n=!1)=>({commands:e})=>e.setContent("",n),Ox=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:s,$to:o})=>{n.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=Ii(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},_x=n=>e=>n(e),Nx=()=>({state:n,dispatch:e})=>XC(n,e),Dx=(n,e)=>({editor:t,tr:r})=>{const{state:i}=t,s=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new ce(r.doc.resolve(o-1))),!0},Rx=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const i=n.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);n.delete(l,a).scrollIntoView()}return!0}return!1},Lx=n=>({tr:e,state:t,dispatch:r})=>{const i=mt(n,t.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},Ix=n=>({tr:e,dispatch:t})=>{const{from:r,to:i}=n;return t&&e.delete(r,i),!0},Px=()=>({state:n,dispatch:e})=>jC(n,e),Fx=()=>({commands:n})=>n.keyboardShortcut("Enter"),Bx=()=>({state:n,dispatch:e})=>ZC(n,e);function Al(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:Mu(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function _u(n,e,t={}){return n.find(r=>r.type===e&&Al(r.attrs,t))}function $x(n,e,t={}){return!!_u(n,e,t)}function Nu(n,e,t={}){if(!n||!e)return;let r=n.parent.childAfter(n.parentOffset);if(n.parentOffset===r.offset&&r.offset!==0&&(r=n.parent.childBefore(n.parentOffset)),!r.node)return;const i=_u([...r.node.marks],e,t);if(!i)return;let s=r.index,o=n.start()+r.offset,l=s+1,a=o+r.node.nodeSize;for(_u([...r.node.marks],e,t);s>0&&i.isInSet(n.parent.child(s-1).marks);)s-=1,o-=n.parent.child(s).nodeSize;for(;l<n.parent.childCount&&$x([...n.parent.child(l).marks],e,t);)a+=n.parent.child(l).nodeSize,l+=1;return{from:o,to:a}}function Dr(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}const jx=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const s=Dr(n,r.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:u}=l;if(i){const d=Nu(a,s,e);if(d&&d.from<=c&&d.to>=u){const f=ce.create(o,d.from,d.to);t.setSelection(f)}}return!0},Hx=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function Du(n){return n instanceof ce}function rr(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function Wm(n,e=null){if(!e)return null;const t=ue.atStart(n),r=ue.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const i=t.from,s=r.to;return e==="all"?ce.create(n,rr(0,i,s),rr(n.content.size,i,s)):ce.create(n,rr(e,i,s),rr(e,i,s))}function Ml(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const Vx=(n=null,e={})=>({editor:t,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{Ml()&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(s&&n===null&&!Du(t.state.selection))return o(),!0;const l=Wm(i.doc,n)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},zx=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),Ux=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),qm=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&qm(r)}return n};function Km(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return qm(t)}function Ol(n,e,t){t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,i=typeof n=="string";if(r)try{return Array.isArray(n)&&n.length>0?W.fromArray(n.map(o=>e.nodeFromJSON(o))):e.nodeFromJSON(n)}catch(s){return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),Ol("",e,t)}if(i){const s=Fc.fromSchema(e);return t.slice?s.parseSlice(Km(n),t.parseOptions).content:s.parse(Km(n),t.parseOptions)}return Ol("",e,t)}function Wx(n,e,t){const r=n.steps.length-1;if(r<e)return;const i=n.steps[r];if(!(i instanceof ht||i instanceof pt))return;const s=n.mapping.maps[r];let o=0;s.forEach((l,a,c,u)=>{o===0&&(o=u)}),n.setSelection(ue.near(n.doc.resolve(o),t))}const qx=n=>n.toString().startsWith("<"),Kx=(n,e,t)=>({tr:r,dispatch:i,editor:s})=>{if(i){t={parseOptions:{},updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};const o=Ol(e,s.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions}});if(o.toString()==="<>")return!0;let{from:l,to:a}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},c=!0,u=!0;if((qx(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)),t.updateSelection&&Wx(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:l,text:f}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:l,text:f})}return!0},Jx=()=>({state:n,dispatch:e})=>KC(n,e),Gx=()=>({state:n,dispatch:e})=>JC(n,e),Yx=()=>({state:n,dispatch:e})=>HC(n,e),Zx=()=>({state:n,dispatch:e})=>WC(n,e),Xx=()=>({tr:n,state:e,dispatch:t})=>{try{const r=ul(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},Qx=()=>({state:n,dispatch:e,tr:t})=>{try{const r=ul(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},ek=()=>({state:n,dispatch:e})=>VC(n,e),tk=()=>({state:n,dispatch:e})=>zC(n,e);function Jm(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function nk(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");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))Ml()||Jm()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}const rk=n=>({editor:e,view:t,tr:r,dispatch:i})=>{const s=nk(n).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(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a==null||a.steps.forEach(c=>{const u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function so(n,e,t={}){const{from:r,to:i,empty:s}=n.selection,o=e?mt(e,n.schema):null,l=[];n.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=>Al(d.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=a}const ik=(n,e={})=>({state:t,dispatch:r})=>{const i=mt(n,t.schema);return so(t,i,e)?GC(t,r):!1},sk=()=>({state:n,dispatch:e})=>QC(n,e),ok=n=>({state:e,dispatch:t})=>{const r=mt(n,e.schema);return lx(r)(e,t)},lk=()=>({state:n,dispatch:e})=>YC(n,e);function _l(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Gm(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}const ak=(n,e)=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null;const l=_l(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(s=mt(n,r.schema)),l==="mark"&&(o=Dr(n,r.schema)),i&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,u)=>{s&&s===c.type&&t.setNodeMarkup(u,void 0,Gm(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(d=>{o===d.type&&t.addMark(u,u+c.nodeSize,o.create(Gm(d.attrs,e)))})})}),!0):!1},ck=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),uk=()=>({tr:n,commands:e})=>e.setTextSelection({from:0,to:n.doc.content.size}),dk=()=>({state:n,dispatch:e})=>UC(n,e),fk=()=>({state:n,dispatch:e})=>qC(n,e),hk=()=>({state:n,dispatch:e})=>ex(n,e),pk=()=>({state:n,dispatch:e})=>rx(n,e),mk=()=>({state:n,dispatch:e})=>nx(n,e);function Ym(n,e,t={}){return Ol(n,e,{slice:!1,parseOptions:t})}const gk=(n,e=!1,t={})=>({tr:r,editor:i,dispatch:s})=>{const{doc:o}=r,l=Ym(n,i.schema,t);return s&&r.replaceWith(0,o.content.size,l).setMeta("preventUpdate",!e),!0};function oo(n,e){const t=Dr(e,n.schema),{from:r,to:i,empty:s}=n.selection,o=[];s?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function yk(n,e){const t=new qc(n);return e.forEach(r=>{r.steps.forEach(i=>{t.step(i)})}),t}function bk(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function vk(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(i,s)=>{t(i)&&r.push({node:i,pos:s})}),r}function Ru(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function Lu(n){return e=>Ru(e.$from,n)}function wk(n,e){const t=_n.fromSchema(e).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}function Ck(n,e){const t={from:0,to:n.content.size};return zm(n,t,e)}function xk(n,e){const t=mt(e,n.schema),{from:r,to:i}=n.selection,s=[];n.doc.nodesBetween(r,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function Zm(n,e){const t=_l(typeof e=="string"?e:e.name,n.schema);return t==="node"?xk(n,e):t==="mark"?oo(n,e):{}}function kk(n,e=JSON.stringify){const t={};return n.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function Sk(n){const e=kk(n);return e.length===1?e:e.filter((t,r)=>!e.filter((s,o)=>o!==r).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function Ek(n){const{mapping:e,steps:t}=n,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}=t[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}})})}),Sk(r)}function Iu(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(i=>{const s=t.resolve(n-1),o=Nu(s,i.type);o&&r.push({mark:i,...o})}):t.nodesBetween(n,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 Nl(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const i=n.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}function Pu(n,e,t={}){const{empty:r,ranges:i}=n.selection,s=e?Dr(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>Al(d.attrs,t,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:d,$to:f})=>{const h=d.pos,p=f.pos;n.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),C=S-w;o+=C,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=>Al(d.mark.attrs,t,{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 Tk(n,e,t={}){if(!e)return so(n,null,t)||Pu(n,null,t);const r=_l(e,n.schema);return r==="node"?so(n,e,t):r==="mark"?Pu(n,e,t):!1}function Xm(n,e){const{nodeExtensions:t}=Sl(e),r=t.find(o=>o.name===n);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=ge(re(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function Ak(n){var e;const t=(e=n.type.createAndFill())===null||e===void 0?void 0:e.toJSON(),r=n.toJSON();return JSON.stringify(t)===JSON.stringify(r)}function Qm(n){return n instanceof se}function Mk(n,e,t){const i=n.state.doc.content.size,s=rr(e,0,i),o=rr(t,0,i),l=n.coordsAtPos(s),a=n.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 Ok(n,e,t){var r;const{selection:i}=e;let s=null;if(Du(i)&&(s=i.$cursor),s){const l=(r=n.storedMarks)!==null&&r!==void 0?r:s.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}const{ranges:o}=i;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(t));c=h&&p}return!c}),c})}const _k=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:l}=s,a=Dr(n,r.schema);if(i)if(o){const c=oo(r,a);t.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&&t.addMark(p,g,a.create({...w.attrs,...e}))}):t.addMark(p,g,a.create(e))})});return Ok(r,t,a)},Nk=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Dk=(n,e={})=>({state:t,dispatch:r,chain:i})=>{const s=mt(n,t.schema);return s.isTextblock?i().command(({commands:o})=>Fm(s,e)(t)?!0:o.clearNodes()).command(({state:o})=>Fm(s,e)(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Rk=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,i=rr(n,0,r.content.size),s=se.create(r,i);e.setSelection(s)}return!0},Lk=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:i,to:s}=typeof n=="number"?{from:n,to:n}:n,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},Ik=n=>({state:e,dispatch:t})=>{const r=mt(n,e.schema);return ux(r)(e,t)};function eg(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(i=>e==null?void 0:e.includes(i.type.name));n.tr.ensureMarks(r)}}const Pk=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,u=Nl(c,l.node().type.name,l.node().attrs);if(s instanceof se&&s.node.isBlock)return!l.parentOffset||!Pi(o,l.pos)?!1:(r&&(n&&eg(t,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:bk(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,p=Pi(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&Pi(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)}n&&eg(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return!0},Fk=n=>({tr:e,state:t,dispatch:r,editor:i})=>{var s;const o=mt(n,t.schema),{$from:l,$to:a}=t.selection,c=t.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,C=Nl(d,l.node().type.name,l.node().attrs),y=((s=o.contentMatch.defaultType)===null||s===void 0?void 0:s.createAndFill(C))||void 0;v=v.append(W.from(o.createAndFill(null,y)||void 0));const k=l.before(l.depth-(w-1));e.replace(k,l.after(-S),new Y(v,4-w,0));let E=-1;e.doc.nodesBetween(k,e.doc.content.size,(T,N)=>{if(E>-1)return!1;T.isTextblock&&T.content.size===0&&(E=N+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=Nl(d,u.type.name,u.attrs),p=Nl(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(!Pi(e.doc,l.pos,2))return!1;if(r){const{selection:v,storedMarks:w}=t,{splittableMarks:S}=i.extensionManager,C=w||v.$to.parentOffset&&v.$from.marks();if(e.split(l.pos,2,g).scrollIntoView(),!C||!r)return!0;const y=C.filter(k=>S.includes(k.type.name));e.ensureMarks(y)}return!0},Fu=(n,e)=>{const t=Lu(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&xr(n.doc,t.pos)&&n.join(t.pos),!0},Bu=(n,e)=>{const t=Lu(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&xr(n.doc,r)&&n.join(r),!0};var Bk=Object.freeze({__proto__:null,blur:Ax,clearContent:Mx,clearNodes:Ox,command:_x,createParagraphNear:Nx,cut:Dx,deleteCurrentNode:Rx,deleteNode:Lx,deleteRange:Ix,deleteSelection:Px,enter:Fx,exitCode:Bx,extendMarkRange:jx,first:Hx,focus:Vx,forEach:zx,insertContent:Ux,insertContentAt:Kx,joinUp:Jx,joinDown:Gx,joinBackward:Yx,joinForward:Zx,joinItemBackward:Xx,joinItemForward:Qx,joinTextblockBackward:ek,joinTextblockForward:tk,keyboardShortcut:rk,lift:ik,liftEmptyBlock:sk,liftListItem:ok,newlineInCode:lk,resetAttributes:ak,scrollIntoView:ck,selectAll:uk,selectNodeBackward:dk,selectNodeForward:fk,selectParentNode:hk,selectTextblockEnd:pk,selectTextblockStart:mk,setContent:gk,setMark:_k,setMeta:Nk,setNode:Dk,setNodeSelection:Rk,setTextSelection:Lk,sinkListItem:Ik,splitBlock:Pk,splitListItem:Fk,toggleList:(n,e,t,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:f}=i.extensionManager,h=mt(n,o.schema),p=mt(e,o.schema),{selection:g,storedMarks:v}=o,{$from:w,$to:S}=g,C=w.blockRange(S),y=v||g.$to.parentOffset&&g.$from.marks();if(!C)return!1;const k=Lu(E=>Xm(E.type.name,d))(g);if(C.depth>=1&&k&&C.depth-k.depth<=1){if(k.node.type===h)return c.liftListItem(p);if(Xm(k.node.type.name,d)&&h.validContent(k.node.content)&&l)return a().command(()=>(s.setNodeMarkup(k.pos,h),!0)).command(()=>Fu(s,h)).command(()=>Bu(s,h)).run()}return!t||!y||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Fu(s,h)).command(()=>Bu(s,h)).run():a().command(()=>{const E=u().wrapInList(h,r),T=y.filter(N=>f.includes(N.type.name));return s.ensureMarks(T),E?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Fu(s,h)).command(()=>Bu(s,h)).run()},toggleMark:(n,e={},t={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=Dr(n,r.schema);return Pu(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},toggleNode:(n,e,t={})=>({state:r,commands:i})=>{const s=mt(n,r.schema),o=mt(e,r.schema);return so(r,s,t)?i.setNode(o):i.setNode(s,t)},toggleWrap:(n,e={})=>({state:t,commands:r})=>{const i=mt(n,t.schema);return so(t,i,e)?r.lift(i):r.wrapIn(i,e)},undoInputRule:()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const i=t[r];let s;if(i.spec.isInputRules&&(s=i.getState(n))){if(e){const o=n.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,n.schema.text(s.text,a))}else o.delete(s.from,s.to)}return!0}}return!1},unsetAllMarks:()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:i}=t;return r||e&&i.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},unsetMark:(n,e={})=>({tr:t,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Dr(n,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=Nu(c,a,p);g&&(f=g.from,h=g.to),t.removeMark(f,h,a)}else d.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},updateAttributes:(n,e={})=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null;const l=_l(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(s=mt(n,r.schema)),l==="mark"&&(o=Dr(n,r.schema)),i&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,u=a.$to.pos;r.doc.nodesBetween(c,u,(d,f)=>{s&&s===d.type&&t.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);t.addMark(p,g,o.create({...h.attrs,...e}))}})})}),!0):!1},wrapIn:(n,e={})=>({state:t,dispatch:r})=>{const i=mt(n,t.schema);return ix(i,e)(t,r)},wrapInList:(n,e={})=>({state:t,dispatch:r})=>{const i=mt(n,t.schema);return sx(i,e)(t,r)}});const $k=Ue.create({name:"commands",addCommands(){return{...Bk}}}),jk=Ue.create({name:"editable",addProseMirrorPlugins(){return[new je({key:new We("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Hk=Ue.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new je({key:new We("focusEvents"),props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Vk=Ue.create({name:"keymap",addKeyboardShortcuts(){const n=()=>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:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":n,"Alt-Backspace":n,"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 Ml()||Jm()?s:i},addProseMirrorPlugins(){return[new je({key:new We("clearDocument"),appendTransaction:(n,e,t)=>{if(!(n.some(p=>p.docChanged)&&!e.doc.eq(t.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)||!(t.doc.textBetween(0,t.doc.content.size," "," ").length===0))return;const d=t.tr,f=xl({state:t,transaction:d}),{commands:h}=new kl({editor:this.editor,state:f});if(h.clearNodes(),!!d.steps.length)return d}})]}}),zk=Ue.create({name:"tabindex",addProseMirrorPlugins(){return[new je({key:new We("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});class li{constructor(e,t,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,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 t=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}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,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),t=this.resolvedPos.doc.resolve(e);return new li(t,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((t,r)=>{const i=t.isBlock&&!t.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?t:null);i&&(l.actualDepth=this.depth+1),e.push(new li(o,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(t).length>0){const s=i.node.attrs,o=Object.keys(t);for(let l=0;l<o.length;l+=1){const a=o[l];if(s[a]!==t[a])break}}else r=i;i=i.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(t);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&s.every(a=>t[a]===o.node.attrs[a])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,t,r))))}),i}setAttribute(e){const t=this.editor.state.selection;this.editor.chain().setTextSelection(this.from).updateAttributes(this.node.type.name,e).setTextSelection(t.from).run()}}const Uk=`.ProseMirror {
42
+ `,textSerializers:o={}}=t||{};let l="";return n.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 Um(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}const TC=Ue.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new je({key:new We("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{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=Um(t);return zm(r,{from:o,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),AC=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),MC=(n=!1)=>({commands:e})=>e.setContent("",n),OC=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:i}=r;return t&&i.forEach(({$from:s,$to:o})=>{n.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=Ii(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},_C=n=>e=>n(e),NC=()=>({state:n,dispatch:e})=>Xx(n,e),DC=(n,e)=>({editor:t,tr:r})=>{const{state:i}=t,s=i.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new ce(r.doc.resolve(o-1))),!0},RC=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const i=n.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);n.delete(l,a).scrollIntoView()}return!0}return!1},LC=n=>({tr:e,state:t,dispatch:r})=>{const i=mt(n,t.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},IC=n=>({tr:e,dispatch:t})=>{const{from:r,to:i}=n;return t&&e.delete(r,i),!0},PC=()=>({state:n,dispatch:e})=>jx(n,e),FC=()=>({commands:n})=>n.keyboardShortcut("Enter"),BC=()=>({state:n,dispatch:e})=>Zx(n,e);function Al(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>t.strict?e[i]===n[i]:Mu(e[i])?e[i].test(n[i]):e[i]===n[i]):!0}function _u(n,e,t={}){return n.find(r=>r.type===e&&Al(r.attrs,t))}function $C(n,e,t={}){return!!_u(n,e,t)}function Nu(n,e,t={}){if(!n||!e)return;let r=n.parent.childAfter(n.parentOffset);if(n.parentOffset===r.offset&&r.offset!==0&&(r=n.parent.childBefore(n.parentOffset)),!r.node)return;const i=_u([...r.node.marks],e,t);if(!i)return;let s=r.index,o=n.start()+r.offset,l=s+1,a=o+r.node.nodeSize;for(_u([...r.node.marks],e,t);s>0&&i.isInSet(n.parent.child(s-1).marks);)s-=1,o-=n.parent.child(s).nodeSize;for(;l<n.parent.childCount&&$C([...n.parent.child(l).marks],e,t);)a+=n.parent.child(l).nodeSize,l+=1;return{from:o,to:a}}function Dr(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}const jC=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const s=Dr(n,r.schema),{doc:o,selection:l}=t,{$from:a,from:c,to:u}=l;if(i){const d=Nu(a,s,e);if(d&&d.from<=c&&d.to>=u){const f=ce.create(o,d.from,d.to);t.setSelection(f)}}return!0},HC=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function Du(n){return n instanceof ce}function rr(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function Wm(n,e=null){if(!e)return null;const t=ue.atStart(n),r=ue.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const i=t.from,s=r.to;return e==="all"?ce.create(n,rr(0,i,s),rr(n.content.size,i,s)):ce.create(n,rr(e,i,s),rr(e,i,s))}function Ml(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const VC=(n=null,e={})=>({editor:t,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{Ml()&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(s&&n===null&&!Du(t.state.selection))return o(),!0;const l=Wm(i.doc,n)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||i.setSelection(l),a&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},zC=(n,e)=>t=>n.every((r,i)=>e(r,{...t,index:i})),UC=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),qm=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&qm(r)}return n};function Km(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return qm(t)}function Ol(n,e,t){t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,i=typeof n=="string";if(r)try{return Array.isArray(n)&&n.length>0?W.fromArray(n.map(o=>e.nodeFromJSON(o))):e.nodeFromJSON(n)}catch(s){return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),Ol("",e,t)}if(i){const s=Fc.fromSchema(e);return t.slice?s.parseSlice(Km(n),t.parseOptions).content:s.parse(Km(n),t.parseOptions)}return Ol("",e,t)}function WC(n,e,t){const r=n.steps.length-1;if(r<e)return;const i=n.steps[r];if(!(i instanceof ht||i instanceof pt))return;const s=n.mapping.maps[r];let o=0;s.forEach((l,a,c,u)=>{o===0&&(o=u)}),n.setSelection(ue.near(n.doc.resolve(o),t))}const qC=n=>n.toString().startsWith("<"),KC=(n,e,t)=>({tr:r,dispatch:i,editor:s})=>{if(i){t={parseOptions:{},updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};const o=Ol(e,s.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions}});if(o.toString()==="<>")return!0;let{from:l,to:a}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},c=!0,u=!0;if((qC(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)),t.updateSelection&&WC(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:l,text:f}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:l,text:f})}return!0},JC=()=>({state:n,dispatch:e})=>Kx(n,e),GC=()=>({state:n,dispatch:e})=>Jx(n,e),YC=()=>({state:n,dispatch:e})=>Hx(n,e),ZC=()=>({state:n,dispatch:e})=>Wx(n,e),XC=()=>({tr:n,state:e,dispatch:t})=>{try{const r=ul(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},QC=()=>({state:n,dispatch:e,tr:t})=>{try{const r=ul(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},ek=()=>({state:n,dispatch:e})=>Vx(n,e),tk=()=>({state:n,dispatch:e})=>zx(n,e);function Jm(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function nk(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");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))Ml()||Jm()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),i&&(t=`Ctrl-${t}`),o&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}const rk=n=>({editor:e,view:t,tr:r,dispatch:i})=>{const s=nk(n).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(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a==null||a.steps.forEach(c=>{const u=c.map(r.mapping);u&&i&&r.maybeStep(u)}),!0};function so(n,e,t={}){const{from:r,to:i,empty:s}=n.selection,o=e?mt(e,n.schema):null,l=[];n.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=>Al(d.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=a}const ik=(n,e={})=>({state:t,dispatch:r})=>{const i=mt(n,t.schema);return so(t,i,e)?Gx(t,r):!1},sk=()=>({state:n,dispatch:e})=>Qx(n,e),ok=n=>({state:e,dispatch:t})=>{const r=mt(n,e.schema);return lC(r)(e,t)},lk=()=>({state:n,dispatch:e})=>Yx(n,e);function _l(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Gm(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,i)=>(t.includes(i)||(r[i]=n[i]),r),{})}const ak=(n,e)=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null;const l=_l(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(s=mt(n,r.schema)),l==="mark"&&(o=Dr(n,r.schema)),i&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,u)=>{s&&s===c.type&&t.setNodeMarkup(u,void 0,Gm(c.attrs,e)),o&&c.marks.length&&c.marks.forEach(d=>{o===d.type&&t.addMark(u,u+c.nodeSize,o.create(Gm(d.attrs,e)))})})}),!0):!1},ck=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),uk=()=>({tr:n,commands:e})=>e.setTextSelection({from:0,to:n.doc.content.size}),dk=()=>({state:n,dispatch:e})=>Ux(n,e),fk=()=>({state:n,dispatch:e})=>qx(n,e),hk=()=>({state:n,dispatch:e})=>eC(n,e),pk=()=>({state:n,dispatch:e})=>rC(n,e),mk=()=>({state:n,dispatch:e})=>nC(n,e);function Ym(n,e,t={}){return Ol(n,e,{slice:!1,parseOptions:t})}const gk=(n,e=!1,t={})=>({tr:r,editor:i,dispatch:s})=>{const{doc:o}=r,l=Ym(n,i.schema,t);return s&&r.replaceWith(0,o.content.size,l).setMeta("preventUpdate",!e),!0};function oo(n,e){const t=Dr(e,n.schema),{from:r,to:i,empty:s}=n.selection,o=[];s?(n.storedMarks&&o.push(...n.storedMarks),o.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,i,a=>{o.push(...a.marks)});const l=o.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function yk(n,e){const t=new qc(n);return e.forEach(r=>{r.steps.forEach(i=>{t.step(i)})}),t}function bk(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function vk(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(i,s)=>{t(i)&&r.push({node:i,pos:s})}),r}function Ru(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function Lu(n){return e=>Ru(e.$from,n)}function wk(n,e){const t=_n.fromSchema(e).serializeFragment(n),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(t),i.innerHTML}function xk(n,e){const t={from:0,to:n.content.size};return zm(n,t,e)}function Ck(n,e){const t=mt(e,n.schema),{from:r,to:i}=n.selection,s=[];n.doc.nodesBetween(r,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===t.name);return o?{...o.attrs}:{}}function Zm(n,e){const t=_l(typeof e=="string"?e:e.name,n.schema);return t==="node"?Ck(n,e):t==="mark"?oo(n,e):{}}function kk(n,e=JSON.stringify){const t={};return n.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(t,i)?!1:t[i]=!0})}function Sk(n){const e=kk(n);return e.length===1?e:e.filter((t,r)=>!e.filter((s,o)=>o!==r).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function Ek(n){const{mapping:e,steps:t}=n,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}=t[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}})})}),Sk(r)}function Iu(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(i=>{const s=t.resolve(n-1),o=Nu(s,i.type);o&&r.push({mark:i,...o})}):t.nodesBetween(n,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 Nl(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const i=n.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}function Pu(n,e,t={}){const{empty:r,ranges:i}=n.selection,s=e?Dr(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>Al(d.attrs,t,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:d,$to:f})=>{const h=d.pos,p=f.pos;n.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=>Al(d.mark.attrs,t,{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 Tk(n,e,t={}){if(!e)return so(n,null,t)||Pu(n,null,t);const r=_l(e,n.schema);return r==="node"?so(n,e,t):r==="mark"?Pu(n,e,t):!1}function Xm(n,e){const{nodeExtensions:t}=Sl(e),r=t.find(o=>o.name===n);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=ge(re(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function Ak(n){var e;const t=(e=n.type.createAndFill())===null||e===void 0?void 0:e.toJSON(),r=n.toJSON();return JSON.stringify(t)===JSON.stringify(r)}function Qm(n){return n instanceof se}function Mk(n,e,t){const i=n.state.doc.content.size,s=rr(e,0,i),o=rr(t,0,i),l=n.coordsAtPos(s),a=n.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 Ok(n,e,t){var r;const{selection:i}=e;let s=null;if(Du(i)&&(s=i.$cursor),s){const l=(r=n.storedMarks)!==null&&r!==void 0?r:s.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}const{ranges:o}=i;return o.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(t));c=h&&p}return!c}),c})}const _k=(n,e={})=>({tr:t,state:r,dispatch:i})=>{const{selection:s}=t,{empty:o,ranges:l}=s,a=Dr(n,r.schema);if(i)if(o){const c=oo(r,a);t.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&&t.addMark(p,g,a.create({...w.attrs,...e}))}):t.addMark(p,g,a.create(e))})});return Ok(r,t,a)},Nk=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),Dk=(n,e={})=>({state:t,dispatch:r,chain:i})=>{const s=mt(n,t.schema);return s.isTextblock?i().command(({commands:o})=>Fm(s,e)(t)?!0:o.clearNodes()).command(({state:o})=>Fm(s,e)(o,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Rk=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,i=rr(n,0,r.content.size),s=se.create(r,i);e.setSelection(s)}return!0},Lk=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:i,to:s}=typeof n=="number"?{from:n,to:n}:n,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},Ik=n=>({state:e,dispatch:t})=>{const r=mt(n,e.schema);return uC(r)(e,t)};function eg(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(i=>e==null?void 0:e.includes(i.type.name));n.tr.ensureMarks(r)}}const Pk=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:a}=s,c=i.extensionManager.attributes,u=Nl(c,l.node().type.name,l.node().attrs);if(s instanceof se&&s.node.isBlock)return!l.parentOffset||!Pi(o,l.pos)?!1:(r&&(n&&eg(t,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:bk(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,p=Pi(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&Pi(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)}n&&eg(t,i.extensionManager.splittableMarks),e.scrollIntoView()}return!0},Fk=n=>({tr:e,state:t,dispatch:r,editor:i})=>{var s;const o=mt(n,t.schema),{$from:l,$to:a}=t.selection,c=t.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=Nl(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 k=l.before(l.depth-(w-1));e.replace(k,l.after(-S),new Y(v,4-w,0));let E=-1;e.doc.nodesBetween(k,e.doc.content.size,(T,N)=>{if(E>-1)return!1;T.isTextblock&&T.content.size===0&&(E=N+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=Nl(d,u.type.name,u.attrs),p=Nl(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(!Pi(e.doc,l.pos,2))return!1;if(r){const{selection:v,storedMarks:w}=t,{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(k=>S.includes(k.type.name));e.ensureMarks(y)}return!0},Fu=(n,e)=>{const t=Lu(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&Cr(n.doc,t.pos)&&n.join(t.pos),!0},Bu=(n,e)=>{const t=Lu(o=>o.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const i=n.doc.nodeAt(r);return t.node.type===(i==null?void 0:i.type)&&Cr(n.doc,r)&&n.join(r),!0};var Bk=Object.freeze({__proto__:null,blur:AC,clearContent:MC,clearNodes:OC,command:_C,createParagraphNear:NC,cut:DC,deleteCurrentNode:RC,deleteNode:LC,deleteRange:IC,deleteSelection:PC,enter:FC,exitCode:BC,extendMarkRange:jC,first:HC,focus:VC,forEach:zC,insertContent:UC,insertContentAt:KC,joinUp:JC,joinDown:GC,joinBackward:YC,joinForward:ZC,joinItemBackward:XC,joinItemForward:QC,joinTextblockBackward:ek,joinTextblockForward:tk,keyboardShortcut:rk,lift:ik,liftEmptyBlock:sk,liftListItem:ok,newlineInCode:lk,resetAttributes:ak,scrollIntoView:ck,selectAll:uk,selectNodeBackward:dk,selectNodeForward:fk,selectParentNode:hk,selectTextblockEnd:pk,selectTextblockStart:mk,setContent:gk,setMark:_k,setMeta:Nk,setNode:Dk,setNodeSelection:Rk,setTextSelection:Lk,sinkListItem:Ik,splitBlock:Pk,splitListItem:Fk,toggleList:(n,e,t,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:f}=i.extensionManager,h=mt(n,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 k=Lu(E=>Xm(E.type.name,d))(g);if(x.depth>=1&&k&&x.depth-k.depth<=1){if(k.node.type===h)return c.liftListItem(p);if(Xm(k.node.type.name,d)&&h.validContent(k.node.content)&&l)return a().command(()=>(s.setNodeMarkup(k.pos,h),!0)).command(()=>Fu(s,h)).command(()=>Bu(s,h)).run()}return!t||!y||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Fu(s,h)).command(()=>Bu(s,h)).run():a().command(()=>{const E=u().wrapInList(h,r),T=y.filter(N=>f.includes(N.type.name));return s.ensureMarks(T),E?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Fu(s,h)).command(()=>Bu(s,h)).run()},toggleMark:(n,e={},t={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=t,o=Dr(n,r.schema);return Pu(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},toggleNode:(n,e,t={})=>({state:r,commands:i})=>{const s=mt(n,r.schema),o=mt(e,r.schema);return so(r,s,t)?i.setNode(o):i.setNode(s,t)},toggleWrap:(n,e={})=>({state:t,commands:r})=>{const i=mt(n,t.schema);return so(t,i,e)?r.lift(i):r.wrapIn(i,e)},undoInputRule:()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const i=t[r];let s;if(i.spec.isInputRules&&(s=i.getState(n))){if(e){const o=n.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,n.schema.text(s.text,a))}else o.delete(s.from,s.to)}return!0}}return!1},unsetAllMarks:()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:i}=t;return r||e&&i.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},unsetMark:(n,e={})=>({tr:t,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=t,a=Dr(n,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=Nu(c,a,p);g&&(f=g.from,h=g.to),t.removeMark(f,h,a)}else d.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},updateAttributes:(n,e={})=>({tr:t,state:r,dispatch:i})=>{let s=null,o=null;const l=_l(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(s=mt(n,r.schema)),l==="mark"&&(o=Dr(n,r.schema)),i&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,u=a.$to.pos;r.doc.nodesBetween(c,u,(d,f)=>{s&&s===d.type&&t.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);t.addMark(p,g,o.create({...h.attrs,...e}))}})})}),!0):!1},wrapIn:(n,e={})=>({state:t,dispatch:r})=>{const i=mt(n,t.schema);return iC(i,e)(t,r)},wrapInList:(n,e={})=>({state:t,dispatch:r})=>{const i=mt(n,t.schema);return sC(i,e)(t,r)}});const $k=Ue.create({name:"commands",addCommands(){return{...Bk}}}),jk=Ue.create({name:"editable",addProseMirrorPlugins(){return[new je({key:new We("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Hk=Ue.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new je({key:new We("focusEvents"),props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Vk=Ue.create({name:"keymap",addKeyboardShortcuts(){const n=()=>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:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},s={...r,"Ctrl-h":n,"Alt-Backspace":n,"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 Ml()||Jm()?s:i},addProseMirrorPlugins(){return[new je({key:new We("clearDocument"),appendTransaction:(n,e,t)=>{if(!(n.some(p=>p.docChanged)&&!e.doc.eq(t.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)||!(t.doc.textBetween(0,t.doc.content.size," "," ").length===0))return;const d=t.tr,f=Cl({state:t,transaction:d}),{commands:h}=new kl({editor:this.editor,state:f});if(h.clearNodes(),!!d.steps.length)return d}})]}}),zk=Ue.create({name:"tabindex",addProseMirrorPlugins(){return[new je({key:new We("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});class li{constructor(e,t,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,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 t=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}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,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),t=this.resolvedPos.doc.resolve(e);return new li(t,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((t,r)=>{const i=t.isBlock&&!t.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?t:null);i&&(l.actualDepth=this.depth+1),e.push(new li(o,this.editor,i,i?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(t).length>0){const s=i.node.attrs,o=Object.keys(t);for(let l=0;l<o.length;l+=1){const a=o[l];if(s[a]!==t[a])break}}else r=i;i=i.parent}return r}querySelector(e,t={}){return this.querySelectorAll(e,t,!0)[0]||null}querySelectorAll(e,t={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(t);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&s.every(a=>t[a]===o.node.attrs[a])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,t,r))))}),i}setAttribute(e){const t=this.editor.state.selection;this.editor.chain().setTextSelection(this.from).updateAttributes(this.node.type.name,e).setTextSelection(t.from).run()}}const Uk=`.ProseMirror {
43
43
  position: relative;
44
44
  }
45
45
 
@@ -113,29 +113,29 @@ img.ProseMirror-separator {
113
113
 
114
114
  .tippy-box[data-animation=fade][data-state=hidden] {
115
115
  opacity: 0
116
- }`;function Wk(n,e,t){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=n,document.getElementsByTagName("head")[0].appendChild(i),i}let qk=class extends dx{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=Wk(Uk,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,t=!0){this.setOptions({editable:e}),t&&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,t){const r=$m(t)?t(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 t=typeof e=="string"?`${e}$`:e.key,r=this.state.reconfigure({plugins:this.state.plugins.filter(i=>!i.key.startsWith(t))});this.view.updateState(r)}createExtensionManager(){var e,t;const i=[...this.options.enableCoreExtensions?[jk,Tx.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),$k,Hk,Vk,zk]:[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new Ki(i,this)}createCommandManager(){this.commandManager=new kl({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const e=Ym(this.options.content,this.schema,this.options.parseOptions),t=Wm(e,this.options.autofocus);this.view=new _C(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:ji.create({doc:e,selection:t||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 t=this.capturedTransaction;return this.capturedTransaction=null,t}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 t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.view.updateState(t),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 Zm(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,i=typeof e=="string"?t:e;return Tk(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return wk(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=`
116
+ }`;function Wk(n,e,t){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=n,document.getElementsByTagName("head")[0].appendChild(i),i}let qk=class extends dC{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=Wk(Uk,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,t=!0){this.setOptions({editable:e}),t&&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,t){const r=$m(t)?t(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 t=typeof e=="string"?`${e}$`:e.key,r=this.state.reconfigure({plugins:this.state.plugins.filter(i=>!i.key.startsWith(t))});this.view.updateState(r)}createExtensionManager(){var e,t;const i=[...this.options.enableCoreExtensions?[jk,TC.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),$k,Hk,Vk,zk]:[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new Ki(i,this)}createCommandManager(){this.commandManager=new kl({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){const e=Ym(this.options.content,this.schema,this.options.parseOptions),t=Wm(e,this.options.autofocus);this.view=new _x(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:ji.create({doc:e,selection:t||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 t=this.capturedTransaction;return this.capturedTransaction=null,t}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 t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.view.updateState(t),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 Zm(this.state,e)}isActive(e,t){const r=typeof e=="string"?e:null,i=typeof e=="string"?t:e;return Tk(this.state,r,i)}getJSON(){return this.state.doc.toJSON()}getHTML(){return wk(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:t=`
117
117
 
118
- `,textSerializers:r={}}=e||{};return Ck(this.state.doc,{blockSeparator:t,textSerializers:{...Um(this.schema),...r}})}get isEmpty(){return Ak(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,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new li(t,this)}get $doc(){return this.$pos(0)}};function ai(n){return new io({find:n.find,handler:({state:e,range:t,match:r})=>{const i=ge(n.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=t.from+l.indexOf(o),u=c+o.length;if(Iu(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>c).length)return null;u<t.to&&s.delete(u,t.to),c>t.from&&s.delete(t.from+a,c);const f=t.from+a+o.length;s.addMark(t.from+a,f,n.type.create(i||{})),s.removeStoredMark(n.type)}}})}function $u(n){return new io({find:n.find,handler:({state:e,range:t,match:r})=>{const i=ge(n.getAttributes,void 0,r)||{},{tr:s}=e,o=t.from;let l=t.to;const a=n.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,n.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l));s.scrollIntoView()}})}function ju(n){return new io({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),s=ge(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)}})}function Ji(n){return new io({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const s=ge(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&zc(a,n.type,s);if(!c)return null;if(o.wrap(a,c),n.keepMarks&&n.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=n.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(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(d,s).run()}const u=o.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&xr(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&o.join(t.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=ge(re(this,"addOptions",{name:this.name}))),this.storage=ge(re(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new jt(e)}configure(e={}){const t=this.extend();return t.options=Tl(this.options,e),t.storage=ge(re(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new jt({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ge(re(t,"addOptions",{name:t.name})),t.storage=ge(re(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){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)===t.name))return!1;const a=o.find(c=>(c==null?void 0:c.type.name)===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}}let Ve=class kh{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=ge(re(this,"addOptions",{name:this.name}))),this.storage=ge(re(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new kh(e)}configure(e={}){const t=this.extend();return t.options=Tl(this.options,e),t.storage=ge(re(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new kh({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ge(re(t,"addOptions",{name:t.name})),t.storage=ge(re(t,"addStorage",{name:t.name,options:t.options})),t}};function Kk(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}class Jk{constructor(e,t,r){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...r},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.getPos=t.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,r,i,s,o,l,a;const{view:c}=this.editor,u=e.target,d=u.nodeType===3?(t=u.parentElement)===null||t===void 0?void 0:t.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,C=(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+C}(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 t;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)&&!(!((t=this.contentDOM)===null||t===void 0)&&t.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"&&(Ml()||Kk())&&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:t})=>{const r=this.getPos();return t.setNodeMarkup(r,void 0,{...this.node.attrs,...e}),!0})}deleteNode(){const e=this.getPos(),t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}}function Rr(n){return new vx({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const s=ge(n.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=t.to;if(l){const u=a.search(/\S/),d=t.from+a.indexOf(l),f=d+l.length;if(Iu(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(v=>v===n.type&&v!==p.mark.type)).filter(p=>p.to>d).length)return null;f<t.to&&o.delete(f,t.to),d>t.from&&o.delete(t.from+u,d),c=t.from+u+l.length,o.addMark(t.from+u,c,n.type.create(s||{})),o.removeStoredMark(n.type)}}})}function Gk(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var Ht="top",on="bottom",ln="right",Vt="left",Hu="auto",lo=[Ht,on,ln,Vt],Gi="start",ao="end",Yk="clippingParents",tg="viewport",co="popper",Zk="reference",ng=lo.reduce(function(n,e){return n.concat([e+"-"+Gi,e+"-"+ao])},[]),rg=[].concat(lo,[Hu]).reduce(function(n,e){return n.concat([e,e+"-"+Gi,e+"-"+ao])},[]),Xk="beforeRead",Qk="read",eS="afterRead",tS="beforeMain",nS="main",rS="afterMain",iS="beforeWrite",sS="write",oS="afterWrite",lS=[Xk,Qk,eS,tS,nS,rS,iS,sS,oS];function In(n){return n?(n.nodeName||"").toLowerCase():null}function Jt(n){if(n==null)return window;if(n.toString()!=="[object Window]"){var e=n.ownerDocument;return e&&e.defaultView||window}return n}function ci(n){var e=Jt(n).Element;return n instanceof e||n instanceof Element}function an(n){var e=Jt(n).HTMLElement;return n instanceof e||n instanceof HTMLElement}function Vu(n){if(typeof ShadowRoot>"u")return!1;var e=Jt(n).ShadowRoot;return n instanceof e||n instanceof ShadowRoot}function aS(n){var e=n.state;Object.keys(e.elements).forEach(function(t){var r=e.styles[t]||{},i=e.attributes[t]||{},s=e.elements[t];!an(s)||!In(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 cS(n){var e=n.state,t={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,t.popper),e.styles=t,e.elements.arrow&&Object.assign(e.elements.arrow.style,t.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]:t[r]),l=o.reduce(function(a,c){return a[c]="",a},{});!an(i)||!In(i)||(Object.assign(i.style,l),Object.keys(s).forEach(function(a){i.removeAttribute(a)}))})}}const ig={name:"applyStyles",enabled:!0,phase:"write",fn:aS,effect:cS,requires:["computeStyles"]};function Pn(n){return n.split("-")[0]}var ui=Math.max,Dl=Math.min,Yi=Math.round;function zu(){var n=navigator.userAgentData;return n!=null&&n.brands&&Array.isArray(n.brands)?n.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function sg(){return!/^((?!chrome|android).)*safari/i.test(zu())}function Zi(n,e,t){e===void 0&&(e=!1),t===void 0&&(t=!1);var r=n.getBoundingClientRect(),i=1,s=1;e&&an(n)&&(i=n.offsetWidth>0&&Yi(r.width)/n.offsetWidth||1,s=n.offsetHeight>0&&Yi(r.height)/n.offsetHeight||1);var o=ci(n)?Jt(n):window,l=o.visualViewport,a=!sg()&&t,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 Uu(n){var e=Zi(n),t=n.offsetWidth,r=n.offsetHeight;return Math.abs(e.width-t)<=1&&(t=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:n.offsetLeft,y:n.offsetTop,width:t,height:r}}function og(n,e){var t=e.getRootNode&&e.getRootNode();if(n.contains(e))return!0;if(t&&Vu(t)){var r=e;do{if(r&&n.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function ir(n){return Jt(n).getComputedStyle(n)}function uS(n){return["table","td","th"].indexOf(In(n))>=0}function Lr(n){return((ci(n)?n.ownerDocument:n.document)||window.document).documentElement}function Rl(n){return In(n)==="html"?n:n.assignedSlot||n.parentNode||(Vu(n)?n.host:null)||Lr(n)}function lg(n){return!an(n)||ir(n).position==="fixed"?null:n.offsetParent}function dS(n){var e=/firefox/i.test(zu()),t=/Trident/i.test(zu());if(t&&an(n)){var r=ir(n);if(r.position==="fixed")return null}var i=Rl(n);for(Vu(i)&&(i=i.host);an(i)&&["html","body"].indexOf(In(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 uo(n){for(var e=Jt(n),t=lg(n);t&&uS(t)&&ir(t).position==="static";)t=lg(t);return t&&(In(t)==="html"||In(t)==="body"&&ir(t).position==="static")?e:t||dS(n)||e}function Wu(n){return["top","bottom"].indexOf(n)>=0?"x":"y"}function fo(n,e,t){return ui(n,Dl(e,t))}function fS(n,e,t){var r=fo(n,e,t);return r>t?t:r}function ag(){return{top:0,right:0,bottom:0,left:0}}function cg(n){return Object.assign({},ag(),n)}function ug(n,e){return e.reduce(function(t,r){return t[r]=n,t},{})}var hS=function(e,t){return e=typeof e=="function"?e(Object.assign({},t.rects,{placement:t.placement})):e,cg(typeof e!="number"?e:ug(e,lo))};function pS(n){var e,t=n.state,r=n.name,i=n.options,s=t.elements.arrow,o=t.modifiersData.popperOffsets,l=Pn(t.placement),a=Wu(l),c=[Vt,ln].indexOf(l)>=0,u=c?"height":"width";if(!(!s||!o)){var d=hS(i.padding,t),f=Uu(s),h=a==="y"?Ht:Vt,p=a==="y"?on:ln,g=t.rects.reference[u]+t.rects.reference[a]-o[a]-t.rects.popper[u],v=o[a]-t.rects.reference[a],w=uo(s),S=w?a==="y"?w.clientHeight||0:w.clientWidth||0:0,C=g/2-v/2,y=d[h],k=S-f[u]-d[p],E=S/2-f[u]/2+C,T=fo(y,E,k),N=a;t.modifiersData[r]=(e={},e[N]=T,e.centerOffset=T-E,e)}}function mS(n){var e=n.state,t=n.options,r=t.element,i=r===void 0?"[data-popper-arrow]":r;i!=null&&(typeof i=="string"&&(i=e.elements.popper.querySelector(i),!i)||og(e.elements.popper,i)&&(e.elements.arrow=i))}const gS={name:"arrow",enabled:!0,phase:"main",fn:pS,effect:mS,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Xi(n){return n.split("-")[1]}var yS={top:"auto",right:"auto",bottom:"auto",left:"auto"};function bS(n,e){var t=n.x,r=n.y,i=e.devicePixelRatio||1;return{x:Yi(t*i)/i||0,y:Yi(r*i)/i||0}}function dg(n){var e,t=n.popper,r=n.popperRect,i=n.placement,s=n.variation,o=n.offsets,l=n.position,a=n.gpuAcceleration,c=n.adaptive,u=n.roundOffsets,d=n.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"),C=Vt,y=Ht,k=window;if(c){var E=uo(t),T="clientHeight",N="clientWidth";if(E===Jt(t)&&(E=Lr(t),ir(E).position!=="static"&&l==="absolute"&&(T="scrollHeight",N="scrollWidth")),E=E,i===Ht||(i===Vt||i===ln)&&s===ao){y=on;var _=d&&E===k&&k.visualViewport?k.visualViewport.height:E[T];g-=_-r.height,g*=a?1:-1}if(i===Vt||(i===Ht||i===on)&&s===ao){C=ln;var A=d&&E===k&&k.visualViewport?k.visualViewport.width:E[N];h-=A-r.width,h*=a?1:-1}}var R=Object.assign({position:l},c&&yS),P=u===!0?bS({x:h,y:g},Jt(t)):{x:h,y:g};if(h=P.x,g=P.y,a){var $;return Object.assign({},R,($={},$[y]=S?"0":"",$[C]=w?"0":"",$.transform=(k.devicePixelRatio||1)<=1?"translate("+h+"px, "+g+"px)":"translate3d("+h+"px, "+g+"px, 0)",$))}return Object.assign({},R,(e={},e[y]=S?g+"px":"",e[C]=w?h+"px":"",e.transform="",e))}function vS(n){var e=n.state,t=n.options,r=t.gpuAcceleration,i=r===void 0?!0:r,s=t.adaptive,o=s===void 0?!0:s,l=t.roundOffsets,a=l===void 0?!0:l,c={placement:Pn(e.placement),variation:Xi(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,dg(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,dg(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 wS={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:vS,data:{}};var Ll={passive:!0};function CS(n){var e=n.state,t=n.instance,r=n.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",t.update,Ll)}),l&&a.addEventListener("resize",t.update,Ll),function(){s&&c.forEach(function(u){u.removeEventListener("scroll",t.update,Ll)}),l&&a.removeEventListener("resize",t.update,Ll)}}const xS={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:CS,data:{}};var kS={left:"right",right:"left",bottom:"top",top:"bottom"};function Il(n){return n.replace(/left|right|bottom|top/g,function(e){return kS[e]})}var SS={start:"end",end:"start"};function fg(n){return n.replace(/start|end/g,function(e){return SS[e]})}function qu(n){var e=Jt(n),t=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:t,scrollTop:r}}function Ku(n){return Zi(Lr(n)).left+qu(n).scrollLeft}function ES(n,e){var t=Jt(n),r=Lr(n),i=t.visualViewport,s=r.clientWidth,o=r.clientHeight,l=0,a=0;if(i){s=i.width,o=i.height;var c=sg();(c||!c&&e==="fixed")&&(l=i.offsetLeft,a=i.offsetTop)}return{width:s,height:o,x:l+Ku(n),y:a}}function TS(n){var e,t=Lr(n),r=qu(n),i=(e=n.ownerDocument)==null?void 0:e.body,s=ui(t.scrollWidth,t.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),o=ui(t.scrollHeight,t.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),l=-r.scrollLeft+Ku(n),a=-r.scrollTop;return ir(i||t).direction==="rtl"&&(l+=ui(t.clientWidth,i?i.clientWidth:0)-s),{width:s,height:o,x:l,y:a}}function Ju(n){var e=ir(n),t=e.overflow,r=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+i+r)}function hg(n){return["html","body","#document"].indexOf(In(n))>=0?n.ownerDocument.body:an(n)&&Ju(n)?n:hg(Rl(n))}function ho(n,e){var t;e===void 0&&(e=[]);var r=hg(n),i=r===((t=n.ownerDocument)==null?void 0:t.body),s=Jt(r),o=i?[s].concat(s.visualViewport||[],Ju(r)?r:[]):r,l=e.concat(o);return i?l:l.concat(ho(Rl(o)))}function Gu(n){return Object.assign({},n,{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height})}function AS(n,e){var t=Zi(n,!1,e==="fixed");return t.top=t.top+n.clientTop,t.left=t.left+n.clientLeft,t.bottom=t.top+n.clientHeight,t.right=t.left+n.clientWidth,t.width=n.clientWidth,t.height=n.clientHeight,t.x=t.left,t.y=t.top,t}function pg(n,e,t){return e===tg?Gu(ES(n,t)):ci(e)?AS(e,t):Gu(TS(Lr(n)))}function MS(n){var e=ho(Rl(n)),t=["absolute","fixed"].indexOf(ir(n).position)>=0,r=t&&an(n)?uo(n):n;return ci(r)?e.filter(function(i){return ci(i)&&og(i,r)&&In(i)!=="body"}):[]}function OS(n,e,t,r){var i=e==="clippingParents"?MS(n):[].concat(e),s=[].concat(i,[t]),o=s[0],l=s.reduce(function(a,c){var u=pg(n,c,r);return a.top=ui(u.top,a.top),a.right=Dl(u.right,a.right),a.bottom=Dl(u.bottom,a.bottom),a.left=ui(u.left,a.left),a},pg(n,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(n){var e=n.reference,t=n.element,r=n.placement,i=r?Pn(r):null,s=r?Xi(r):null,o=e.x+e.width/2-t.width/2,l=e.y+e.height/2-t.height/2,a;switch(i){case Ht:a={x:o,y:e.y-t.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 Vt:a={x:e.x-t.width,y:l};break;default:a={x:e.x,y:e.y}}var c=i?Wu(i):null;if(c!=null){var u=c==="y"?"height":"width";switch(s){case Gi:a[c]=a[c]-(e[u]/2-t[u]/2);break;case ao:a[c]=a[c]+(e[u]/2-t[u]/2);break}}return a}function po(n,e){e===void 0&&(e={});var t=e,r=t.placement,i=r===void 0?n.placement:r,s=t.strategy,o=s===void 0?n.strategy:s,l=t.boundary,a=l===void 0?Yk:l,c=t.rootBoundary,u=c===void 0?tg:c,d=t.elementContext,f=d===void 0?co:d,h=t.altBoundary,p=h===void 0?!1:h,g=t.padding,v=g===void 0?0:g,w=cg(typeof v!="number"?v:ug(v,lo)),S=f===co?Zk:co,C=n.rects.popper,y=n.elements[p?S:f],k=OS(ci(y)?y:y.contextElement||Lr(n.elements.popper),a,u,o),E=Zi(n.elements.reference),T=mg({reference:E,element:C,strategy:"absolute",placement:i}),N=Gu(Object.assign({},C,T)),_=f===co?N:E,A={top:k.top-_.top+w.top,bottom:_.bottom-k.bottom+w.bottom,left:k.left-_.left+w.left,right:_.right-k.right+w.right},R=n.modifiersData.offset;if(f===co&&R){var P=R[i];Object.keys(A).forEach(function($){var V=[ln,on].indexOf($)>=0?1:-1,U=[Ht,on].indexOf($)>=0?"y":"x";A[$]+=P[U]*V})}return A}function _S(n,e){e===void 0&&(e={});var t=e,r=t.placement,i=t.boundary,s=t.rootBoundary,o=t.padding,l=t.flipVariations,a=t.allowedAutoPlacements,c=a===void 0?rg:a,u=Xi(r),d=u?l?ng:ng.filter(function(p){return Xi(p)===u}):lo,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]=po(n,{placement:g,boundary:i,rootBoundary:s,padding:o})[Pn(g)],p},{});return Object.keys(h).sort(function(p,g){return h[p]-h[g]})}function NS(n){if(Pn(n)===Hu)return[];var e=Il(n);return[fg(n),e,fg(e)]}function DS(n){var e=n.state,t=n.options,r=n.name;if(!e.modifiersData[r]._skip){for(var i=t.mainAxis,s=i===void 0?!0:i,o=t.altAxis,l=o===void 0?!0:o,a=t.fallbackPlacements,c=t.padding,u=t.boundary,d=t.rootBoundary,f=t.altBoundary,h=t.flipVariations,p=h===void 0?!0:h,g=t.allowedAutoPlacements,v=e.options.placement,w=Pn(v),S=w===v,C=a||(S||!p?[Il(v)]:NS(v)),y=[v].concat(C).reduce(function(ye,_e){return ye.concat(Pn(_e)===Hu?_S(e,{placement:_e,boundary:u,rootBoundary:d,padding:c,flipVariations:p,allowedAutoPlacements:g}):_e)},[]),k=e.rects.reference,E=e.rects.popper,T=new Map,N=!0,_=y[0],A=0;A<y.length;A++){var R=y[A],P=Pn(R),$=Xi(R)===Gi,V=[Ht,on].indexOf(P)>=0,U=V?"width":"height",J=po(e,{placement:R,boundary:u,rootBoundary:d,altBoundary:f,padding:c}),G=V?$?ln:Vt:$?on:Ht;k[U]>E[U]&&(G=Il(G));var ie=Il(G),X=[];if(s&&X.push(J[P]<=0),l&&X.push(J[G]<=0,J[ie]<=0),X.every(function(ye){return ye})){_=R,N=!1;break}T.set(R,X)}if(N)for(var we=p?3:1,Re=function(_e){var Le=y.find(function(tt){var nt=T.get(tt);if(nt)return nt.slice(0,_e).every(function(Ge){return Ge})});if(Le)return _=Le,"break"},Pe=we;Pe>0;Pe--){var xe=Re(Pe);if(xe==="break")break}e.placement!==_&&(e.modifiersData[r]._skip=!0,e.placement=_,e.reset=!0)}}const RS={name:"flip",enabled:!0,phase:"main",fn:DS,requiresIfExists:["offset"],data:{_skip:!1}};function gg(n,e,t){return t===void 0&&(t={x:0,y:0}),{top:n.top-e.height-t.y,right:n.right-e.width+t.x,bottom:n.bottom-e.height+t.y,left:n.left-e.width-t.x}}function yg(n){return[Ht,ln,on,Vt].some(function(e){return n[e]>=0})}function LS(n){var e=n.state,t=n.name,r=e.rects.reference,i=e.rects.popper,s=e.modifiersData.preventOverflow,o=po(e,{elementContext:"reference"}),l=po(e,{altBoundary:!0}),a=gg(o,r),c=gg(l,i,s),u=yg(a),d=yg(c);e.modifiersData[t]={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 IS={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:LS};function PS(n,e,t){var r=Pn(n),i=[Vt,Ht].indexOf(r)>=0?-1:1,s=typeof t=="function"?t(Object.assign({},e,{placement:n})):t,o=s[0],l=s[1];return o=o||0,l=(l||0)*i,[Vt,ln].indexOf(r)>=0?{x:l,y:o}:{x:o,y:l}}function FS(n){var e=n.state,t=n.options,r=n.name,i=t.offset,s=i===void 0?[0,0]:i,o=rg.reduce(function(u,d){return u[d]=PS(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 BS={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:FS};function $S(n){var e=n.state,t=n.name;e.modifiersData[t]=mg({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const jS={name:"popperOffsets",enabled:!0,phase:"read",fn:$S,data:{}};function HS(n){return n==="x"?"y":"x"}function VS(n){var e=n.state,t=n.options,r=n.name,i=t.mainAxis,s=i===void 0?!0:i,o=t.altAxis,l=o===void 0?!1:o,a=t.boundary,c=t.rootBoundary,u=t.altBoundary,d=t.padding,f=t.tether,h=f===void 0?!0:f,p=t.tetherOffset,g=p===void 0?0:p,v=po(e,{boundary:a,rootBoundary:c,padding:d,altBoundary:u}),w=Pn(e.placement),S=Xi(e.placement),C=!S,y=Wu(w),k=HS(y),E=e.modifiersData.popperOffsets,T=e.rects.reference,N=e.rects.popper,_=typeof g=="function"?g(Object.assign({},e.rects,{placement:e.placement})):g,A=typeof _=="number"?{mainAxis:_,altAxis:_}:Object.assign({mainAxis:0,altAxis:0},_),R=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,P={x:0,y:0};if(E){if(s){var $,V=y==="y"?Ht:Vt,U=y==="y"?on:ln,J=y==="y"?"height":"width",G=E[y],ie=G+v[V],X=G-v[U],we=h?-N[J]/2:0,Re=S===Gi?T[J]:N[J],Pe=S===Gi?-N[J]:-T[J],xe=e.elements.arrow,ye=h&&xe?Uu(xe):{width:0,height:0},_e=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:ag(),Le=_e[V],tt=_e[U],nt=fo(0,T[J],ye[J]),Ge=C?T[J]/2-we-nt-Le-A.mainAxis:Re-nt-Le-A.mainAxis,Ye=C?-T[J]/2+we+nt+tt+A.mainAxis:Pe+nt+tt+A.mainAxis,Ot=e.elements.arrow&&uo(e.elements.arrow),Ct=Ot?y==="y"?Ot.clientTop||0:Ot.clientLeft||0:0,it=($=R==null?void 0:R[y])!=null?$:0,at=G+Ge-it-Ct,B=G+Ye-it,j=fo(h?Dl(ie,at):ie,G,h?ui(X,B):X);E[y]=j,P[y]=j-G}if(l){var q,te=y==="x"?Ht:Vt,M=y==="x"?on:ln,m=E[k],b=k==="y"?"height":"width",x=m+v[te],I=m-v[M],F=[Ht,Vt].indexOf(w)!==-1,H=(q=R==null?void 0:R[k])!=null?q:0,ne=F?x:m-T[b]-N[b]-H+A.altAxis,de=F?m+T[b]+N[b]-H-A.altAxis:I,Me=h&&F?fS(ne,m,de):fo(h?ne:x,m,h?de:I);E[k]=Me,P[k]=Me-m}e.modifiersData[r]=P}}const zS={name:"preventOverflow",enabled:!0,phase:"main",fn:VS,requiresIfExists:["offset"]};function US(n){return{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}}function WS(n){return n===Jt(n)||!an(n)?qu(n):US(n)}function qS(n){var e=n.getBoundingClientRect(),t=Yi(e.width)/n.offsetWidth||1,r=Yi(e.height)/n.offsetHeight||1;return t!==1||r!==1}function KS(n,e,t){t===void 0&&(t=!1);var r=an(e),i=an(e)&&qS(e),s=Lr(e),o=Zi(n,i,t),l={scrollLeft:0,scrollTop:0},a={x:0,y:0};return(r||!r&&!t)&&((In(e)!=="body"||Ju(s))&&(l=WS(e)),an(e)?(a=Zi(e,!0),a.x+=e.clientLeft,a.y+=e.clientTop):s&&(a.x=Ku(s))),{x:o.left+l.scrollLeft-a.x,y:o.top+l.scrollTop-a.y,width:o.width,height:o.height}}function JS(n){var e=new Map,t=new Set,r=[];n.forEach(function(s){e.set(s.name,s)});function i(s){t.add(s.name);var o=[].concat(s.requires||[],s.requiresIfExists||[]);o.forEach(function(l){if(!t.has(l)){var a=e.get(l);a&&i(a)}}),r.push(s)}return n.forEach(function(s){t.has(s.name)||i(s)}),r}function GS(n){var e=JS(n);return lS.reduce(function(t,r){return t.concat(e.filter(function(i){return i.phase===r}))},[])}function YS(n){var e;return function(){return e||(e=new Promise(function(t){Promise.resolve().then(function(){e=void 0,t(n())})})),e}}function ZS(n){var e=n.reduce(function(t,r){var i=t[r.name];return t[r.name]=i?Object.assign({},i,r,{options:Object.assign({},i.options,r.options),data:Object.assign({},i.data,r.data)}):r,t},{});return Object.keys(e).map(function(t){return e[t]})}var bg={placement:"bottom",modifiers:[],strategy:"absolute"};function vg(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return!e.some(function(r){return!(r&&typeof r.getBoundingClientRect=="function")})}function XS(n){n===void 0&&(n={});var e=n,t=e.defaultModifiers,r=t===void 0?[]:t,i=e.defaultOptions,s=i===void 0?bg:i;return function(l,a,c){c===void 0&&(c=s);var u={placement:"bottom",orderedModifiers:[],options:Object.assign({},bg,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)?ho(l):l.contextElement?ho(l.contextElement):[],popper:ho(a)};var C=GS(ZS([].concat(r,u.options.modifiers)));return u.orderedModifiers=C.filter(function(y){return y.enabled}),p(),h.update()},forceUpdate:function(){if(!f){var w=u.elements,S=w.reference,C=w.popper;if(vg(S,C)){u.rects={reference:KS(S,uo(C),u.options.strategy==="fixed"),popper:Uu(C)},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 k=u.orderedModifiers[y],E=k.fn,T=k.options,N=T===void 0?{}:T,_=k.name;typeof E=="function"&&(u=E({state:u,options:N,name:_,instance:h})||u)}}}},update:YS(function(){return new Promise(function(v){h.forceUpdate(),v(u)})}),destroy:function(){g(),f=!0}};if(!vg(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,C=S===void 0?{}:S,y=v.effect;if(typeof y=="function"){var k=y({state:u,name:w,instance:h,options:C}),E=function(){};d.push(k||E)}})}function g(){d.forEach(function(v){return v()}),d=[]}return h}}var QS=[xS,jS,wS,ig,BS,RS,zS,gS,IS],eE=XS({defaultModifiers:QS}),tE="tippy-box",wg="tippy-content",nE="tippy-backdrop",Cg="tippy-arrow",xg="tippy-svg-arrow",di={passive:!0,capture:!0},kg=function(){return document.body};function rE(n,e){return{}.hasOwnProperty.call(n,e)}function Yu(n,e,t){if(Array.isArray(n)){var r=n[e];return r??(Array.isArray(t)?t[e]:t)}return n}function Zu(n,e){var t={}.toString.call(n);return t.indexOf("[object")===0&&t.indexOf(e+"]")>-1}function Sg(n,e){return typeof n=="function"?n.apply(void 0,e):n}function Eg(n,e){if(e===0)return n;var t;return function(r){clearTimeout(t),t=setTimeout(function(){n(r)},e)}}function iE(n,e){var t=Object.assign({},n);return e.forEach(function(r){delete t[r]}),t}function sE(n){return n.split(/\s+/).filter(Boolean)}function Qi(n){return[].concat(n)}function Tg(n,e){n.indexOf(e)===-1&&n.push(e)}function oE(n){return n.filter(function(e,t){return n.indexOf(e)===t})}function lE(n){return n.split("-")[0]}function Pl(n){return[].slice.call(n)}function Ag(n){return Object.keys(n).reduce(function(e,t){return n[t]!==void 0&&(e[t]=n[t]),e},{})}function mo(){return document.createElement("div")}function go(n){return["Element","Fragment"].some(function(e){return Zu(n,e)})}function aE(n){return Zu(n,"NodeList")}function cE(n){return Zu(n,"MouseEvent")}function uE(n){return!!(n&&n._tippy&&n._tippy.reference===n)}function dE(n){return go(n)?[n]:aE(n)?Pl(n):Array.isArray(n)?n:Pl(document.querySelectorAll(n))}function Xu(n,e){n.forEach(function(t){t&&(t.style.transitionDuration=e+"ms")})}function Mg(n,e){n.forEach(function(t){t&&t.setAttribute("data-state",e)})}function fE(n){var e,t=Qi(n),r=t[0];return r!=null&&(e=r.ownerDocument)!=null&&e.body?r.ownerDocument:document}function hE(n,e){var t=e.clientX,r=e.clientY;return n.every(function(i){var s=i.popperRect,o=i.popperState,l=i.props,a=l.interactiveBorder,c=lE(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-t+h>a,S=t-s.right-p>a;return g||v||w||S})}function Qu(n,e,t){var r=e+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(i){n[r](i,t)})}function Og(n,e){for(var t=e;t;){var r;if(n.contains(t))return!0;t=t.getRootNode==null||(r=t.getRootNode())==null?void 0:r.host}return!1}var Fn={isTouch:!1},_g=0;function pE(){Fn.isTouch||(Fn.isTouch=!0,window.performance&&document.addEventListener("mousemove",Ng))}function Ng(){var n=performance.now();n-_g<20&&(Fn.isTouch=!1,document.removeEventListener("mousemove",Ng)),_g=n}function mE(){var n=document.activeElement;if(uE(n)){var e=n._tippy;n.blur&&!e.state.isVisible&&n.blur()}}function gE(){document.addEventListener("touchstart",pE,di),window.addEventListener("blur",mE)}var yE=typeof window<"u"&&typeof document<"u",bE=yE?!!window.msCrypto:!1;function es(n){var e=n==="destroy"?"n already-":" ";return[n+"() was called on a"+e+"destroyed instance. This is a no-op but","indicates a potential memory leak."].join(" ")}function Dg(n){var e=/[ \t]{2,}/g,t=/^[ \t]*/gm;return n.replace(e," ").replace(t,"").trim()}function vE(n){return Dg(`
118
+ `,textSerializers:r={}}=e||{};return xk(this.state.doc,{blockSeparator:t,textSerializers:{...Um(this.schema),...r}})}get isEmpty(){return Ak(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,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){const t=this.state.doc.resolve(e);return new li(t,this)}get $doc(){return this.$pos(0)}};function ai(n){return new io({find:n.find,handler:({state:e,range:t,match:r})=>{const i=ge(n.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=t.from+l.indexOf(o),u=c+o.length;if(Iu(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>c).length)return null;u<t.to&&s.delete(u,t.to),c>t.from&&s.delete(t.from+a,c);const f=t.from+a+o.length;s.addMark(t.from+a,f,n.type.create(i||{})),s.removeStoredMark(n.type)}}})}function $u(n){return new io({find:n.find,handler:({state:e,range:t,match:r})=>{const i=ge(n.getAttributes,void 0,r)||{},{tr:s}=e,o=t.from;let l=t.to;const a=n.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,n.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l));s.scrollIntoView()}})}function ju(n){return new io({find:n.find,handler:({state:e,range:t,match:r})=>{const i=e.doc.resolve(t.from),s=ge(n.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)}})}function Ji(n){return new io({find:n.find,handler:({state:e,range:t,match:r,chain:i})=>{const s=ge(n.getAttributes,void 0,r)||{},o=e.tr.delete(t.from,t.to),a=o.doc.resolve(t.from).blockRange(),c=a&&zc(a,n.type,s);if(!c)return null;if(o.wrap(a,c),n.keepMarks&&n.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=n.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(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(d,s).run()}const u=o.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&Cr(o.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&o.join(t.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=ge(re(this,"addOptions",{name:this.name}))),this.storage=ge(re(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new jt(e)}configure(e={}){const t=this.extend();return t.options=Tl(this.options,e),t.storage=ge(re(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new jt({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ge(re(t,"addOptions",{name:t.name})),t.storage=ge(re(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){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)===t.name))return!1;const a=o.find(c=>(c==null?void 0:c.type.name)===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",i.pos),e.view.dispatch(r),!0}return!1}}let Ve=class kh{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=ge(re(this,"addOptions",{name:this.name}))),this.storage=ge(re(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new kh(e)}configure(e={}){const t=this.extend();return t.options=Tl(this.options,e),t.storage=ge(re(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new kh({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=ge(re(t,"addOptions",{name:t.name})),t.storage=ge(re(t,"addStorage",{name:t.name,options:t.options})),t}};function Kk(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}class Jk{constructor(e,t,r){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options={stopEvent:null,ignoreMutation:null,...r},this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.getPos=t.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,r,i,s,o,l,a;const{view:c}=this.editor,u=e.target,d=u.nodeType===3?(t=u.parentElement)===null||t===void 0?void 0:t.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 t;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)&&!(!((t=this.contentDOM)===null||t===void 0)&&t.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"&&(Ml()||Kk())&&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:t})=>{const r=this.getPos();return t.setNodeMarkup(r,void 0,{...this.node.attrs,...e}),!0})}deleteNode(){const e=this.getPos(),t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}}function Rr(n){return new vC({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:i})=>{const s=ge(n.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=t.to;if(l){const u=a.search(/\S/),d=t.from+a.indexOf(l),f=d+l.length;if(Iu(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(v=>v===n.type&&v!==p.mark.type)).filter(p=>p.to>d).length)return null;f<t.to&&o.delete(f,t.to),d>t.from&&o.delete(t.from+u,d),c=t.from+u+l.length,o.addMark(t.from+u,c,n.type.create(s||{})),o.removeStoredMark(n.type)}}})}function Gk(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}var Ht="top",on="bottom",ln="right",Vt="left",Hu="auto",lo=[Ht,on,ln,Vt],Gi="start",ao="end",Yk="clippingParents",tg="viewport",co="popper",Zk="reference",ng=lo.reduce(function(n,e){return n.concat([e+"-"+Gi,e+"-"+ao])},[]),rg=[].concat(lo,[Hu]).reduce(function(n,e){return n.concat([e,e+"-"+Gi,e+"-"+ao])},[]),Xk="beforeRead",Qk="read",eS="afterRead",tS="beforeMain",nS="main",rS="afterMain",iS="beforeWrite",sS="write",oS="afterWrite",lS=[Xk,Qk,eS,tS,nS,rS,iS,sS,oS];function In(n){return n?(n.nodeName||"").toLowerCase():null}function Jt(n){if(n==null)return window;if(n.toString()!=="[object Window]"){var e=n.ownerDocument;return e&&e.defaultView||window}return n}function ci(n){var e=Jt(n).Element;return n instanceof e||n instanceof Element}function an(n){var e=Jt(n).HTMLElement;return n instanceof e||n instanceof HTMLElement}function Vu(n){if(typeof ShadowRoot>"u")return!1;var e=Jt(n).ShadowRoot;return n instanceof e||n instanceof ShadowRoot}function aS(n){var e=n.state;Object.keys(e.elements).forEach(function(t){var r=e.styles[t]||{},i=e.attributes[t]||{},s=e.elements[t];!an(s)||!In(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 cS(n){var e=n.state,t={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,t.popper),e.styles=t,e.elements.arrow&&Object.assign(e.elements.arrow.style,t.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]:t[r]),l=o.reduce(function(a,c){return a[c]="",a},{});!an(i)||!In(i)||(Object.assign(i.style,l),Object.keys(s).forEach(function(a){i.removeAttribute(a)}))})}}const ig={name:"applyStyles",enabled:!0,phase:"write",fn:aS,effect:cS,requires:["computeStyles"]};function Pn(n){return n.split("-")[0]}var ui=Math.max,Dl=Math.min,Yi=Math.round;function zu(){var n=navigator.userAgentData;return n!=null&&n.brands&&Array.isArray(n.brands)?n.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}function sg(){return!/^((?!chrome|android).)*safari/i.test(zu())}function Zi(n,e,t){e===void 0&&(e=!1),t===void 0&&(t=!1);var r=n.getBoundingClientRect(),i=1,s=1;e&&an(n)&&(i=n.offsetWidth>0&&Yi(r.width)/n.offsetWidth||1,s=n.offsetHeight>0&&Yi(r.height)/n.offsetHeight||1);var o=ci(n)?Jt(n):window,l=o.visualViewport,a=!sg()&&t,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 Uu(n){var e=Zi(n),t=n.offsetWidth,r=n.offsetHeight;return Math.abs(e.width-t)<=1&&(t=e.width),Math.abs(e.height-r)<=1&&(r=e.height),{x:n.offsetLeft,y:n.offsetTop,width:t,height:r}}function og(n,e){var t=e.getRootNode&&e.getRootNode();if(n.contains(e))return!0;if(t&&Vu(t)){var r=e;do{if(r&&n.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function ir(n){return Jt(n).getComputedStyle(n)}function uS(n){return["table","td","th"].indexOf(In(n))>=0}function Lr(n){return((ci(n)?n.ownerDocument:n.document)||window.document).documentElement}function Rl(n){return In(n)==="html"?n:n.assignedSlot||n.parentNode||(Vu(n)?n.host:null)||Lr(n)}function lg(n){return!an(n)||ir(n).position==="fixed"?null:n.offsetParent}function dS(n){var e=/firefox/i.test(zu()),t=/Trident/i.test(zu());if(t&&an(n)){var r=ir(n);if(r.position==="fixed")return null}var i=Rl(n);for(Vu(i)&&(i=i.host);an(i)&&["html","body"].indexOf(In(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 uo(n){for(var e=Jt(n),t=lg(n);t&&uS(t)&&ir(t).position==="static";)t=lg(t);return t&&(In(t)==="html"||In(t)==="body"&&ir(t).position==="static")?e:t||dS(n)||e}function Wu(n){return["top","bottom"].indexOf(n)>=0?"x":"y"}function fo(n,e,t){return ui(n,Dl(e,t))}function fS(n,e,t){var r=fo(n,e,t);return r>t?t:r}function ag(){return{top:0,right:0,bottom:0,left:0}}function cg(n){return Object.assign({},ag(),n)}function ug(n,e){return e.reduce(function(t,r){return t[r]=n,t},{})}var hS=function(e,t){return e=typeof e=="function"?e(Object.assign({},t.rects,{placement:t.placement})):e,cg(typeof e!="number"?e:ug(e,lo))};function pS(n){var e,t=n.state,r=n.name,i=n.options,s=t.elements.arrow,o=t.modifiersData.popperOffsets,l=Pn(t.placement),a=Wu(l),c=[Vt,ln].indexOf(l)>=0,u=c?"height":"width";if(!(!s||!o)){var d=hS(i.padding,t),f=Uu(s),h=a==="y"?Ht:Vt,p=a==="y"?on:ln,g=t.rects.reference[u]+t.rects.reference[a]-o[a]-t.rects.popper[u],v=o[a]-t.rects.reference[a],w=uo(s),S=w?a==="y"?w.clientHeight||0:w.clientWidth||0:0,x=g/2-v/2,y=d[h],k=S-f[u]-d[p],E=S/2-f[u]/2+x,T=fo(y,E,k),N=a;t.modifiersData[r]=(e={},e[N]=T,e.centerOffset=T-E,e)}}function mS(n){var e=n.state,t=n.options,r=t.element,i=r===void 0?"[data-popper-arrow]":r;i!=null&&(typeof i=="string"&&(i=e.elements.popper.querySelector(i),!i)||og(e.elements.popper,i)&&(e.elements.arrow=i))}const gS={name:"arrow",enabled:!0,phase:"main",fn:pS,effect:mS,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]};function Xi(n){return n.split("-")[1]}var yS={top:"auto",right:"auto",bottom:"auto",left:"auto"};function bS(n,e){var t=n.x,r=n.y,i=e.devicePixelRatio||1;return{x:Yi(t*i)/i||0,y:Yi(r*i)/i||0}}function dg(n){var e,t=n.popper,r=n.popperRect,i=n.placement,s=n.variation,o=n.offsets,l=n.position,a=n.gpuAcceleration,c=n.adaptive,u=n.roundOffsets,d=n.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=Vt,y=Ht,k=window;if(c){var E=uo(t),T="clientHeight",N="clientWidth";if(E===Jt(t)&&(E=Lr(t),ir(E).position!=="static"&&l==="absolute"&&(T="scrollHeight",N="scrollWidth")),E=E,i===Ht||(i===Vt||i===ln)&&s===ao){y=on;var _=d&&E===k&&k.visualViewport?k.visualViewport.height:E[T];g-=_-r.height,g*=a?1:-1}if(i===Vt||(i===Ht||i===on)&&s===ao){x=ln;var A=d&&E===k&&k.visualViewport?k.visualViewport.width:E[N];h-=A-r.width,h*=a?1:-1}}var R=Object.assign({position:l},c&&yS),P=u===!0?bS({x:h,y:g},Jt(t)):{x:h,y:g};if(h=P.x,g=P.y,a){var $;return Object.assign({},R,($={},$[y]=S?"0":"",$[x]=w?"0":"",$.transform=(k.devicePixelRatio||1)<=1?"translate("+h+"px, "+g+"px)":"translate3d("+h+"px, "+g+"px, 0)",$))}return Object.assign({},R,(e={},e[y]=S?g+"px":"",e[x]=w?h+"px":"",e.transform="",e))}function vS(n){var e=n.state,t=n.options,r=t.gpuAcceleration,i=r===void 0?!0:r,s=t.adaptive,o=s===void 0?!0:s,l=t.roundOffsets,a=l===void 0?!0:l,c={placement:Pn(e.placement),variation:Xi(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,dg(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,dg(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 wS={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:vS,data:{}};var Ll={passive:!0};function xS(n){var e=n.state,t=n.instance,r=n.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",t.update,Ll)}),l&&a.addEventListener("resize",t.update,Ll),function(){s&&c.forEach(function(u){u.removeEventListener("scroll",t.update,Ll)}),l&&a.removeEventListener("resize",t.update,Ll)}}const CS={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:xS,data:{}};var kS={left:"right",right:"left",bottom:"top",top:"bottom"};function Il(n){return n.replace(/left|right|bottom|top/g,function(e){return kS[e]})}var SS={start:"end",end:"start"};function fg(n){return n.replace(/start|end/g,function(e){return SS[e]})}function qu(n){var e=Jt(n),t=e.pageXOffset,r=e.pageYOffset;return{scrollLeft:t,scrollTop:r}}function Ku(n){return Zi(Lr(n)).left+qu(n).scrollLeft}function ES(n,e){var t=Jt(n),r=Lr(n),i=t.visualViewport,s=r.clientWidth,o=r.clientHeight,l=0,a=0;if(i){s=i.width,o=i.height;var c=sg();(c||!c&&e==="fixed")&&(l=i.offsetLeft,a=i.offsetTop)}return{width:s,height:o,x:l+Ku(n),y:a}}function TS(n){var e,t=Lr(n),r=qu(n),i=(e=n.ownerDocument)==null?void 0:e.body,s=ui(t.scrollWidth,t.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),o=ui(t.scrollHeight,t.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),l=-r.scrollLeft+Ku(n),a=-r.scrollTop;return ir(i||t).direction==="rtl"&&(l+=ui(t.clientWidth,i?i.clientWidth:0)-s),{width:s,height:o,x:l,y:a}}function Ju(n){var e=ir(n),t=e.overflow,r=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+i+r)}function hg(n){return["html","body","#document"].indexOf(In(n))>=0?n.ownerDocument.body:an(n)&&Ju(n)?n:hg(Rl(n))}function ho(n,e){var t;e===void 0&&(e=[]);var r=hg(n),i=r===((t=n.ownerDocument)==null?void 0:t.body),s=Jt(r),o=i?[s].concat(s.visualViewport||[],Ju(r)?r:[]):r,l=e.concat(o);return i?l:l.concat(ho(Rl(o)))}function Gu(n){return Object.assign({},n,{left:n.x,top:n.y,right:n.x+n.width,bottom:n.y+n.height})}function AS(n,e){var t=Zi(n,!1,e==="fixed");return t.top=t.top+n.clientTop,t.left=t.left+n.clientLeft,t.bottom=t.top+n.clientHeight,t.right=t.left+n.clientWidth,t.width=n.clientWidth,t.height=n.clientHeight,t.x=t.left,t.y=t.top,t}function pg(n,e,t){return e===tg?Gu(ES(n,t)):ci(e)?AS(e,t):Gu(TS(Lr(n)))}function MS(n){var e=ho(Rl(n)),t=["absolute","fixed"].indexOf(ir(n).position)>=0,r=t&&an(n)?uo(n):n;return ci(r)?e.filter(function(i){return ci(i)&&og(i,r)&&In(i)!=="body"}):[]}function OS(n,e,t,r){var i=e==="clippingParents"?MS(n):[].concat(e),s=[].concat(i,[t]),o=s[0],l=s.reduce(function(a,c){var u=pg(n,c,r);return a.top=ui(u.top,a.top),a.right=Dl(u.right,a.right),a.bottom=Dl(u.bottom,a.bottom),a.left=ui(u.left,a.left),a},pg(n,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(n){var e=n.reference,t=n.element,r=n.placement,i=r?Pn(r):null,s=r?Xi(r):null,o=e.x+e.width/2-t.width/2,l=e.y+e.height/2-t.height/2,a;switch(i){case Ht:a={x:o,y:e.y-t.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 Vt:a={x:e.x-t.width,y:l};break;default:a={x:e.x,y:e.y}}var c=i?Wu(i):null;if(c!=null){var u=c==="y"?"height":"width";switch(s){case Gi:a[c]=a[c]-(e[u]/2-t[u]/2);break;case ao:a[c]=a[c]+(e[u]/2-t[u]/2);break}}return a}function po(n,e){e===void 0&&(e={});var t=e,r=t.placement,i=r===void 0?n.placement:r,s=t.strategy,o=s===void 0?n.strategy:s,l=t.boundary,a=l===void 0?Yk:l,c=t.rootBoundary,u=c===void 0?tg:c,d=t.elementContext,f=d===void 0?co:d,h=t.altBoundary,p=h===void 0?!1:h,g=t.padding,v=g===void 0?0:g,w=cg(typeof v!="number"?v:ug(v,lo)),S=f===co?Zk:co,x=n.rects.popper,y=n.elements[p?S:f],k=OS(ci(y)?y:y.contextElement||Lr(n.elements.popper),a,u,o),E=Zi(n.elements.reference),T=mg({reference:E,element:x,strategy:"absolute",placement:i}),N=Gu(Object.assign({},x,T)),_=f===co?N:E,A={top:k.top-_.top+w.top,bottom:_.bottom-k.bottom+w.bottom,left:k.left-_.left+w.left,right:_.right-k.right+w.right},R=n.modifiersData.offset;if(f===co&&R){var P=R[i];Object.keys(A).forEach(function($){var V=[ln,on].indexOf($)>=0?1:-1,U=[Ht,on].indexOf($)>=0?"y":"x";A[$]+=P[U]*V})}return A}function _S(n,e){e===void 0&&(e={});var t=e,r=t.placement,i=t.boundary,s=t.rootBoundary,o=t.padding,l=t.flipVariations,a=t.allowedAutoPlacements,c=a===void 0?rg:a,u=Xi(r),d=u?l?ng:ng.filter(function(p){return Xi(p)===u}):lo,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]=po(n,{placement:g,boundary:i,rootBoundary:s,padding:o})[Pn(g)],p},{});return Object.keys(h).sort(function(p,g){return h[p]-h[g]})}function NS(n){if(Pn(n)===Hu)return[];var e=Il(n);return[fg(n),e,fg(e)]}function DS(n){var e=n.state,t=n.options,r=n.name;if(!e.modifiersData[r]._skip){for(var i=t.mainAxis,s=i===void 0?!0:i,o=t.altAxis,l=o===void 0?!0:o,a=t.fallbackPlacements,c=t.padding,u=t.boundary,d=t.rootBoundary,f=t.altBoundary,h=t.flipVariations,p=h===void 0?!0:h,g=t.allowedAutoPlacements,v=e.options.placement,w=Pn(v),S=w===v,x=a||(S||!p?[Il(v)]:NS(v)),y=[v].concat(x).reduce(function(ye,Ne){return ye.concat(Pn(Ne)===Hu?_S(e,{placement:Ne,boundary:u,rootBoundary:d,padding:c,flipVariations:p,allowedAutoPlacements:g}):Ne)},[]),k=e.rects.reference,E=e.rects.popper,T=new Map,N=!0,_=y[0],A=0;A<y.length;A++){var R=y[A],P=Pn(R),$=Xi(R)===Gi,V=[Ht,on].indexOf(P)>=0,U=V?"width":"height",J=po(e,{placement:R,boundary:u,rootBoundary:d,altBoundary:f,padding:c}),G=V?$?ln:Vt:$?on:Ht;k[U]>E[U]&&(G=Il(G));var ie=Il(G),X=[];if(s&&X.push(J[P]<=0),l&&X.push(J[G]<=0,J[ie]<=0),X.every(function(ye){return ye})){_=R,N=!1;break}T.set(R,X)}if(N)for(var we=p?3:1,Re=function(Ne){var Le=y.find(function(tt){var nt=T.get(tt);if(nt)return nt.slice(0,Ne).every(function(Ge){return Ge})});if(Le)return _=Le,"break"},Pe=we;Pe>0;Pe--){var Ce=Re(Pe);if(Ce==="break")break}e.placement!==_&&(e.modifiersData[r]._skip=!0,e.placement=_,e.reset=!0)}}const RS={name:"flip",enabled:!0,phase:"main",fn:DS,requiresIfExists:["offset"],data:{_skip:!1}};function gg(n,e,t){return t===void 0&&(t={x:0,y:0}),{top:n.top-e.height-t.y,right:n.right-e.width+t.x,bottom:n.bottom-e.height+t.y,left:n.left-e.width-t.x}}function yg(n){return[Ht,ln,on,Vt].some(function(e){return n[e]>=0})}function LS(n){var e=n.state,t=n.name,r=e.rects.reference,i=e.rects.popper,s=e.modifiersData.preventOverflow,o=po(e,{elementContext:"reference"}),l=po(e,{altBoundary:!0}),a=gg(o,r),c=gg(l,i,s),u=yg(a),d=yg(c);e.modifiersData[t]={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 IS={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:LS};function PS(n,e,t){var r=Pn(n),i=[Vt,Ht].indexOf(r)>=0?-1:1,s=typeof t=="function"?t(Object.assign({},e,{placement:n})):t,o=s[0],l=s[1];return o=o||0,l=(l||0)*i,[Vt,ln].indexOf(r)>=0?{x:l,y:o}:{x:o,y:l}}function FS(n){var e=n.state,t=n.options,r=n.name,i=t.offset,s=i===void 0?[0,0]:i,o=rg.reduce(function(u,d){return u[d]=PS(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 BS={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:FS};function $S(n){var e=n.state,t=n.name;e.modifiersData[t]=mg({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}const jS={name:"popperOffsets",enabled:!0,phase:"read",fn:$S,data:{}};function HS(n){return n==="x"?"y":"x"}function VS(n){var e=n.state,t=n.options,r=n.name,i=t.mainAxis,s=i===void 0?!0:i,o=t.altAxis,l=o===void 0?!1:o,a=t.boundary,c=t.rootBoundary,u=t.altBoundary,d=t.padding,f=t.tether,h=f===void 0?!0:f,p=t.tetherOffset,g=p===void 0?0:p,v=po(e,{boundary:a,rootBoundary:c,padding:d,altBoundary:u}),w=Pn(e.placement),S=Xi(e.placement),x=!S,y=Wu(w),k=HS(y),E=e.modifiersData.popperOffsets,T=e.rects.reference,N=e.rects.popper,_=typeof g=="function"?g(Object.assign({},e.rects,{placement:e.placement})):g,A=typeof _=="number"?{mainAxis:_,altAxis:_}:Object.assign({mainAxis:0,altAxis:0},_),R=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,P={x:0,y:0};if(E){if(s){var $,V=y==="y"?Ht:Vt,U=y==="y"?on:ln,J=y==="y"?"height":"width",G=E[y],ie=G+v[V],X=G-v[U],we=h?-N[J]/2:0,Re=S===Gi?T[J]:N[J],Pe=S===Gi?-N[J]:-T[J],Ce=e.elements.arrow,ye=h&&Ce?Uu(Ce):{width:0,height:0},Ne=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:ag(),Le=Ne[V],tt=Ne[U],nt=fo(0,T[J],ye[J]),Ge=x?T[J]/2-we-nt-Le-A.mainAxis:Re-nt-Le-A.mainAxis,Ye=x?-T[J]/2+we+nt+tt+A.mainAxis:Pe+nt+tt+A.mainAxis,Ot=e.elements.arrow&&uo(e.elements.arrow),xt=Ot?y==="y"?Ot.clientTop||0:Ot.clientLeft||0:0,it=($=R==null?void 0:R[y])!=null?$:0,at=G+Ge-it-xt,B=G+Ye-it,j=fo(h?Dl(ie,at):ie,G,h?ui(X,B):X);E[y]=j,P[y]=j-G}if(l){var q,te=y==="x"?Ht:Vt,M=y==="x"?on:ln,m=E[k],b=k==="y"?"height":"width",C=m+v[te],I=m-v[M],F=[Ht,Vt].indexOf(w)!==-1,H=(q=R==null?void 0:R[k])!=null?q:0,ne=F?C:m-T[b]-N[b]-H+A.altAxis,de=F?m+T[b]+N[b]-H-A.altAxis:I,Oe=h&&F?fS(ne,m,de):fo(h?ne:C,m,h?de:I);E[k]=Oe,P[k]=Oe-m}e.modifiersData[r]=P}}const zS={name:"preventOverflow",enabled:!0,phase:"main",fn:VS,requiresIfExists:["offset"]};function US(n){return{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}}function WS(n){return n===Jt(n)||!an(n)?qu(n):US(n)}function qS(n){var e=n.getBoundingClientRect(),t=Yi(e.width)/n.offsetWidth||1,r=Yi(e.height)/n.offsetHeight||1;return t!==1||r!==1}function KS(n,e,t){t===void 0&&(t=!1);var r=an(e),i=an(e)&&qS(e),s=Lr(e),o=Zi(n,i,t),l={scrollLeft:0,scrollTop:0},a={x:0,y:0};return(r||!r&&!t)&&((In(e)!=="body"||Ju(s))&&(l=WS(e)),an(e)?(a=Zi(e,!0),a.x+=e.clientLeft,a.y+=e.clientTop):s&&(a.x=Ku(s))),{x:o.left+l.scrollLeft-a.x,y:o.top+l.scrollTop-a.y,width:o.width,height:o.height}}function JS(n){var e=new Map,t=new Set,r=[];n.forEach(function(s){e.set(s.name,s)});function i(s){t.add(s.name);var o=[].concat(s.requires||[],s.requiresIfExists||[]);o.forEach(function(l){if(!t.has(l)){var a=e.get(l);a&&i(a)}}),r.push(s)}return n.forEach(function(s){t.has(s.name)||i(s)}),r}function GS(n){var e=JS(n);return lS.reduce(function(t,r){return t.concat(e.filter(function(i){return i.phase===r}))},[])}function YS(n){var e;return function(){return e||(e=new Promise(function(t){Promise.resolve().then(function(){e=void 0,t(n())})})),e}}function ZS(n){var e=n.reduce(function(t,r){var i=t[r.name];return t[r.name]=i?Object.assign({},i,r,{options:Object.assign({},i.options,r.options),data:Object.assign({},i.data,r.data)}):r,t},{});return Object.keys(e).map(function(t){return e[t]})}var bg={placement:"bottom",modifiers:[],strategy:"absolute"};function vg(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return!e.some(function(r){return!(r&&typeof r.getBoundingClientRect=="function")})}function XS(n){n===void 0&&(n={});var e=n,t=e.defaultModifiers,r=t===void 0?[]:t,i=e.defaultOptions,s=i===void 0?bg:i;return function(l,a,c){c===void 0&&(c=s);var u={placement:"bottom",orderedModifiers:[],options:Object.assign({},bg,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)?ho(l):l.contextElement?ho(l.contextElement):[],popper:ho(a)};var x=GS(ZS([].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(vg(S,x)){u.rects={reference:KS(S,uo(x),u.options.strategy==="fixed"),popper:Uu(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 k=u.orderedModifiers[y],E=k.fn,T=k.options,N=T===void 0?{}:T,_=k.name;typeof E=="function"&&(u=E({state:u,options:N,name:_,instance:h})||u)}}}},update:YS(function(){return new Promise(function(v){h.forceUpdate(),v(u)})}),destroy:function(){g(),f=!0}};if(!vg(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 k=y({state:u,name:w,instance:h,options:x}),E=function(){};d.push(k||E)}})}function g(){d.forEach(function(v){return v()}),d=[]}return h}}var QS=[CS,jS,wS,ig,BS,RS,zS,gS,IS],eE=XS({defaultModifiers:QS}),tE="tippy-box",wg="tippy-content",nE="tippy-backdrop",xg="tippy-arrow",Cg="tippy-svg-arrow",di={passive:!0,capture:!0},kg=function(){return document.body};function rE(n,e){return{}.hasOwnProperty.call(n,e)}function Yu(n,e,t){if(Array.isArray(n)){var r=n[e];return r??(Array.isArray(t)?t[e]:t)}return n}function Zu(n,e){var t={}.toString.call(n);return t.indexOf("[object")===0&&t.indexOf(e+"]")>-1}function Sg(n,e){return typeof n=="function"?n.apply(void 0,e):n}function Eg(n,e){if(e===0)return n;var t;return function(r){clearTimeout(t),t=setTimeout(function(){n(r)},e)}}function iE(n,e){var t=Object.assign({},n);return e.forEach(function(r){delete t[r]}),t}function sE(n){return n.split(/\s+/).filter(Boolean)}function Qi(n){return[].concat(n)}function Tg(n,e){n.indexOf(e)===-1&&n.push(e)}function oE(n){return n.filter(function(e,t){return n.indexOf(e)===t})}function lE(n){return n.split("-")[0]}function Pl(n){return[].slice.call(n)}function Ag(n){return Object.keys(n).reduce(function(e,t){return n[t]!==void 0&&(e[t]=n[t]),e},{})}function mo(){return document.createElement("div")}function go(n){return["Element","Fragment"].some(function(e){return Zu(n,e)})}function aE(n){return Zu(n,"NodeList")}function cE(n){return Zu(n,"MouseEvent")}function uE(n){return!!(n&&n._tippy&&n._tippy.reference===n)}function dE(n){return go(n)?[n]:aE(n)?Pl(n):Array.isArray(n)?n:Pl(document.querySelectorAll(n))}function Xu(n,e){n.forEach(function(t){t&&(t.style.transitionDuration=e+"ms")})}function Mg(n,e){n.forEach(function(t){t&&t.setAttribute("data-state",e)})}function fE(n){var e,t=Qi(n),r=t[0];return r!=null&&(e=r.ownerDocument)!=null&&e.body?r.ownerDocument:document}function hE(n,e){var t=e.clientX,r=e.clientY;return n.every(function(i){var s=i.popperRect,o=i.popperState,l=i.props,a=l.interactiveBorder,c=lE(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-t+h>a,S=t-s.right-p>a;return g||v||w||S})}function Qu(n,e,t){var r=e+"EventListener";["transitionend","webkitTransitionEnd"].forEach(function(i){n[r](i,t)})}function Og(n,e){for(var t=e;t;){var r;if(n.contains(t))return!0;t=t.getRootNode==null||(r=t.getRootNode())==null?void 0:r.host}return!1}var Fn={isTouch:!1},_g=0;function pE(){Fn.isTouch||(Fn.isTouch=!0,window.performance&&document.addEventListener("mousemove",Ng))}function Ng(){var n=performance.now();n-_g<20&&(Fn.isTouch=!1,document.removeEventListener("mousemove",Ng)),_g=n}function mE(){var n=document.activeElement;if(uE(n)){var e=n._tippy;n.blur&&!e.state.isVisible&&n.blur()}}function gE(){document.addEventListener("touchstart",pE,di),window.addEventListener("blur",mE)}var yE=typeof window<"u"&&typeof document<"u",bE=yE?!!window.msCrypto:!1;function es(n){var e=n==="destroy"?"n already-":" ";return[n+"() was called on a"+e+"destroyed instance. This is a no-op but","indicates a potential memory leak."].join(" ")}function Dg(n){var e=/[ \t]{2,}/g,t=/^[ \t]*/gm;return n.replace(e," ").replace(t,"").trim()}function vE(n){return Dg(`
119
119
  %ctippy.js
120
120
 
121
121
  %c`+Dg(n)+`
122
122
 
123
123
  %c👷‍ This is a development-only message. It will be removed in production.
124
- `)}function Rg(n){return[vE(n),"color: #00C584; font-size: 1.3em; font-weight: bold;","line-height: 1.5","color: #a6a095;"]}var yo;process.env.NODE_ENV!=="production"&&wE();function wE(){yo=new Set}function sr(n,e){if(n&&!yo.has(e)){var t;yo.add(e),(t=console).warn.apply(t,Rg(e))}}function ed(n,e){if(n&&!yo.has(e)){var t;yo.add(e),(t=console).error.apply(t,Rg(e))}}function CE(n){var e=!n,t=Object.prototype.toString.call(n)==="[object Object]"&&!n.addEventListener;ed(e,["tippy() was passed","`"+String(n)+"`","as its targets (first) argument. Valid types are: String, Element,","Element[], or NodeList."].join(" ")),ed(t,["tippy() was passed a plain object which is not supported as an argument","for virtual positioning. Use props.getReferenceClientRect instead."].join(" "))}var Lg={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},xE={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},Gt=Object.assign({appendTo:kg,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},Lg,xE),kE=Object.keys(Gt),SE=function(e){process.env.NODE_ENV!=="production"&&Fg(e,[]);var t=Object.keys(e);t.forEach(function(r){Gt[r]=e[r]})};function Ig(n){var e=n.plugins||[],t=e.reduce(function(r,i){var s=i.name,o=i.defaultValue;if(s){var l;r[s]=n[s]!==void 0?n[s]:(l=Gt[s])!=null?l:o}return r},{});return Object.assign({},n,t)}function EE(n,e){var t=e?Object.keys(Ig(Object.assign({},Gt,{plugins:e}))):kE,r=t.reduce(function(i,s){var o=(n.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 Pg(n,e){var t=Object.assign({},e,{content:Sg(e.content,[n])},e.ignoreAttributes?{}:EE(n,e.plugins));return t.aria=Object.assign({},Gt.aria,t.aria),t.aria={expanded:t.aria.expanded==="auto"?e.interactive:t.aria.expanded,content:t.aria.content==="auto"?e.interactive?null:"describedby":t.aria.content},t}function Fg(n,e){n===void 0&&(n={}),e===void 0&&(e=[]);var t=Object.keys(n);t.forEach(function(r){var i=iE(Gt,Object.keys(Lg)),s=!rE(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.",`
124
+ `)}function Rg(n){return[vE(n),"color: #00C584; font-size: 1.3em; font-weight: bold;","line-height: 1.5","color: #a6a095;"]}var yo;process.env.NODE_ENV!=="production"&&wE();function wE(){yo=new Set}function sr(n,e){if(n&&!yo.has(e)){var t;yo.add(e),(t=console).warn.apply(t,Rg(e))}}function ed(n,e){if(n&&!yo.has(e)){var t;yo.add(e),(t=console).error.apply(t,Rg(e))}}function xE(n){var e=!n,t=Object.prototype.toString.call(n)==="[object Object]"&&!n.addEventListener;ed(e,["tippy() was passed","`"+String(n)+"`","as its targets (first) argument. Valid types are: String, Element,","Element[], or NodeList."].join(" ")),ed(t,["tippy() was passed a plain object which is not supported as an argument","for virtual positioning. Use props.getReferenceClientRect instead."].join(" "))}var Lg={animateFill:!1,followCursor:!1,inlinePositioning:!1,sticky:!1},CE={allowHTML:!1,animation:"fade",arrow:!0,content:"",inertia:!1,maxWidth:350,role:"tooltip",theme:"",zIndex:9999},Gt=Object.assign({appendTo:kg,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},Lg,CE),kE=Object.keys(Gt),SE=function(e){process.env.NODE_ENV!=="production"&&Fg(e,[]);var t=Object.keys(e);t.forEach(function(r){Gt[r]=e[r]})};function Ig(n){var e=n.plugins||[],t=e.reduce(function(r,i){var s=i.name,o=i.defaultValue;if(s){var l;r[s]=n[s]!==void 0?n[s]:(l=Gt[s])!=null?l:o}return r},{});return Object.assign({},n,t)}function EE(n,e){var t=e?Object.keys(Ig(Object.assign({},Gt,{plugins:e}))):kE,r=t.reduce(function(i,s){var o=(n.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 Pg(n,e){var t=Object.assign({},e,{content:Sg(e.content,[n])},e.ignoreAttributes?{}:EE(n,e.plugins));return t.aria=Object.assign({},Gt.aria,t.aria),t.aria={expanded:t.aria.expanded==="auto"?e.interactive:t.aria.expanded,content:t.aria.content==="auto"?e.interactive?null:"describedby":t.aria.content},t}function Fg(n,e){n===void 0&&(n={}),e===void 0&&(e=[]);var t=Object.keys(n);t.forEach(function(r){var i=iE(Gt,Object.keys(Lg)),s=!rE(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 TE=function(){return"innerHTML"};function td(n,e){n[TE()]=e}function Bg(n){var e=mo();return n===!0?e.className=Cg:(e.className=xg,go(n)?e.appendChild(n):td(e,n)),e}function $g(n,e){go(e.content)?(td(n,""),n.appendChild(e.content)):typeof e.content!="function"&&(e.allowHTML?td(n,e.content):n.textContent=e.content)}function nd(n){var e=n.firstElementChild,t=Pl(e.children);return{box:e,content:t.find(function(r){return r.classList.contains(wg)}),arrow:t.find(function(r){return r.classList.contains(Cg)||r.classList.contains(xg)}),backdrop:t.find(function(r){return r.classList.contains(nE)})}}function jg(n){var e=mo(),t=mo();t.className=tE,t.setAttribute("data-state","hidden"),t.setAttribute("tabindex","-1");var r=mo();r.className=wg,r.setAttribute("data-state","hidden"),$g(r,n.props),e.appendChild(t),t.appendChild(r),i(n.props,n.props);function i(s,o){var l=nd(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)&&$g(c,n.props),o.arrow?u?s.arrow!==o.arrow&&(a.removeChild(u),a.appendChild(Bg(o.arrow))):a.appendChild(Bg(o.arrow)):u&&a.removeChild(u)}return{popper:e,onUpdate:i}}jg.$$tippy=!0;var AE=1,Fl=[],rd=[];function ME(n,e){var t=Pg(n,Object.assign({},Gt,Ig(Ag(e)))),r,i,s,o=!1,l=!1,a=!1,c=!1,u,d,f,h=[],p=Eg(at,t.interactiveDebounce),g,v=AE++,w=null,S=oE(t.plugins),C={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},y={id:v,reference:n,popper:mo(),popperInstance:w,props:t,state:C,plugins:S,clearDelayTimeouts:ne,setProps:de,setContent:Me,show:be,hide:me,hideWithInteractivity:Ze,enable:F,disable:H,unmount:An,destroy:Qn};if(!t.render)return process.env.NODE_ENV!=="production"&&ed(!0,"render() function has not been supplied."),y;var k=t.render(y),E=k.popper,T=k.onUpdate;E.setAttribute("data-tippy-root",""),E.id="tippy-"+y.id,y.popper=E,n._tippy=y,E._tippy=y;var N=S.map(function(z){return z.fn(y)}),_=n.hasAttribute("aria-expanded");return Ot(),we(),G(),ie("onCreate",[y]),t.showOnCreate&&x(),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&&V().addEventListener("mousemove",p)}),y;function A(){var z=y.props.touch;return Array.isArray(z)?z:[z,0]}function R(){return A()[0]==="hold"}function P(){var z;return!!((z=y.props.render)!=null&&z.$$tippy)}function $(){return g||n}function V(){var z=$().parentNode;return z?fE(z):document}function U(){return nd(E)}function J(z){return y.state.isMounted&&!y.state.isVisible||Fn.isTouch||u&&u.type==="focus"?0:Yu(y.props.delay,z?0:1,Gt.delay)}function G(z){z===void 0&&(z=!1),E.style.pointerEvents=y.props.interactive&&!z?"":"none",E.style.zIndex=""+y.props.zIndex}function ie(z,ee,oe){if(oe===void 0&&(oe=!0),N.forEach(function(Ee){Ee[z]&&Ee[z].apply(Ee,ee)}),oe){var Oe;(Oe=y.props)[z].apply(Oe,ee)}}function X(){var z=y.props.aria;if(z.content){var ee="aria-"+z.content,oe=E.id,Oe=Qi(y.props.triggerTarget||n);Oe.forEach(function(Ee){var ft=Ee.getAttribute(ee);if(y.state.isVisible)Ee.setAttribute(ee,ft?ft+" "+oe:oe);else{var Pt=ft&&ft.replace(oe,"").trim();Pt?Ee.setAttribute(ee,Pt):Ee.removeAttribute(ee)}})}}function we(){if(!(_||!y.props.aria.expanded)){var z=Qi(y.props.triggerTarget||n);z.forEach(function(ee){y.props.interactive?ee.setAttribute("aria-expanded",y.state.isVisible&&ee===$()?"true":"false"):ee.removeAttribute("aria-expanded")})}}function Re(){V().removeEventListener("mousemove",p),Fl=Fl.filter(function(z){return z!==p})}function Pe(z){if(!(Fn.isTouch&&(a||z.type==="mousedown"))){var ee=z.composedPath&&z.composedPath()[0]||z.target;if(!(y.props.interactive&&Og(E,ee))){if(Qi(y.props.triggerTarget||n).some(function(oe){return Og(oe,ee)})){if(Fn.isTouch||y.state.isVisible&&y.props.trigger.indexOf("click")>=0)return}else ie("onClickOutside",[y,z]);y.props.hideOnClick===!0&&(y.clearDelayTimeouts(),y.hide(),l=!0,setTimeout(function(){l=!1}),y.state.isMounted||Le())}}}function xe(){a=!0}function ye(){a=!1}function _e(){var z=V();z.addEventListener("mousedown",Pe,!0),z.addEventListener("touchend",Pe,di),z.addEventListener("touchstart",ye,di),z.addEventListener("touchmove",xe,di)}function Le(){var z=V();z.removeEventListener("mousedown",Pe,!0),z.removeEventListener("touchend",Pe,di),z.removeEventListener("touchstart",ye,di),z.removeEventListener("touchmove",xe,di)}function tt(z,ee){Ge(z,function(){!y.state.isVisible&&E.parentNode&&E.parentNode.contains(E)&&ee()})}function nt(z,ee){Ge(z,ee)}function Ge(z,ee){var oe=U().box;function Oe(Ee){Ee.target===oe&&(Qu(oe,"remove",Oe),ee())}if(z===0)return ee();Qu(oe,"remove",d),Qu(oe,"add",Oe),d=Oe}function Ye(z,ee,oe){oe===void 0&&(oe=!1);var Oe=Qi(y.props.triggerTarget||n);Oe.forEach(function(Ee){Ee.addEventListener(z,ee,oe),h.push({node:Ee,eventType:z,handler:ee,options:oe})})}function Ot(){R()&&(Ye("touchstart",it,{passive:!0}),Ye("touchend",B,{passive:!0})),sE(y.props.trigger).forEach(function(z){if(z!=="manual")switch(Ye(z,it),z){case"mouseenter":Ye("mouseleave",B);break;case"focus":Ye(bE?"focusout":"blur",j);break;case"focusin":Ye("focusout",j);break}})}function Ct(){h.forEach(function(z){var ee=z.node,oe=z.eventType,Oe=z.handler,Ee=z.options;ee.removeEventListener(oe,Oe,Ee)}),h=[]}function it(z){var ee,oe=!1;if(!(!y.state.isEnabled||q(z)||l)){var Oe=((ee=u)==null?void 0:ee.type)==="focus";u=z,g=z.currentTarget,we(),!y.state.isVisible&&cE(z)&&Fl.forEach(function(Ee){return Ee(z)}),z.type==="click"&&(y.props.trigger.indexOf("mouseenter")<0||o)&&y.props.hideOnClick!==!1&&y.state.isVisible?oe=!0:x(z),z.type==="click"&&(o=!oe),oe&&!Oe&&I(z)}}function at(z){var ee=z.target,oe=$().contains(ee)||E.contains(ee);if(!(z.type==="mousemove"&&oe)){var Oe=b().concat(E).map(function(Ee){var ft,Pt=Ee._tippy,tn=(ft=Pt.popperInstance)==null?void 0:ft.state;return tn?{popperRect:Ee.getBoundingClientRect(),popperState:tn,props:t}:null}).filter(Boolean);hE(Oe,z)&&(Re(),I(z))}}function B(z){var ee=q(z)||y.props.trigger.indexOf("click")>=0&&o;if(!ee){if(y.props.interactive){y.hideWithInteractivity(z);return}I(z)}}function j(z){y.props.trigger.indexOf("focusin")<0&&z.target!==$()||y.props.interactive&&z.relatedTarget&&E.contains(z.relatedTarget)||I(z)}function q(z){return Fn.isTouch?R()!==z.type.indexOf("touch")>=0:!1}function te(){M();var z=y.props,ee=z.popperOptions,oe=z.placement,Oe=z.offset,Ee=z.getReferenceClientRect,ft=z.moveTransition,Pt=P()?nd(E).arrow:null,tn=Ee?{getBoundingClientRect:Ee,contextElement:Ee.contextElement||$()}:n,Ls={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Ps){var br=Ps.state;if(P()){var bh=U(),Fs=bh.box;["placement","reference-hidden","escaped"].forEach(function(Ni){Ni==="placement"?Fs.setAttribute("data-placement",br.placement):br.attributes.popper["data-popper-"+Ni]?Fs.setAttribute("data-"+Ni,""):Fs.removeAttribute("data-"+Ni)}),br.attributes.popper={}}}},Mn=[{name:"offset",options:{offset:Oe}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!ft}},Ls];P()&&Pt&&Mn.push({name:"arrow",options:{element:Pt,padding:3}}),Mn.push.apply(Mn,(ee==null?void 0:ee.modifiers)||[]),y.popperInstance=eE(tn,E,Object.assign({},ee,{placement:oe,onFirstUpdate:f,modifiers:Mn}))}function M(){y.popperInstance&&(y.popperInstance.destroy(),y.popperInstance=null)}function m(){var z=y.props.appendTo,ee,oe=$();y.props.interactive&&z===kg||z==="parent"?ee=oe.parentNode:ee=Sg(z,[oe]),ee.contains(E)||ee.appendChild(E),y.state.isMounted=!0,te(),process.env.NODE_ENV!=="production"&&sr(y.props.interactive&&z===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.",`
127
+ `,"Plugins: https://atomiks.github.io/tippyjs/v6/plugins/"].join(" "))})}var TE=function(){return"innerHTML"};function td(n,e){n[TE()]=e}function Bg(n){var e=mo();return n===!0?e.className=xg:(e.className=Cg,go(n)?e.appendChild(n):td(e,n)),e}function $g(n,e){go(e.content)?(td(n,""),n.appendChild(e.content)):typeof e.content!="function"&&(e.allowHTML?td(n,e.content):n.textContent=e.content)}function nd(n){var e=n.firstElementChild,t=Pl(e.children);return{box:e,content:t.find(function(r){return r.classList.contains(wg)}),arrow:t.find(function(r){return r.classList.contains(xg)||r.classList.contains(Cg)}),backdrop:t.find(function(r){return r.classList.contains(nE)})}}function jg(n){var e=mo(),t=mo();t.className=tE,t.setAttribute("data-state","hidden"),t.setAttribute("tabindex","-1");var r=mo();r.className=wg,r.setAttribute("data-state","hidden"),$g(r,n.props),e.appendChild(t),t.appendChild(r),i(n.props,n.props);function i(s,o){var l=nd(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)&&$g(c,n.props),o.arrow?u?s.arrow!==o.arrow&&(a.removeChild(u),a.appendChild(Bg(o.arrow))):a.appendChild(Bg(o.arrow)):u&&a.removeChild(u)}return{popper:e,onUpdate:i}}jg.$$tippy=!0;var AE=1,Fl=[],rd=[];function ME(n,e){var t=Pg(n,Object.assign({},Gt,Ig(Ag(e)))),r,i,s,o=!1,l=!1,a=!1,c=!1,u,d,f,h=[],p=Eg(at,t.interactiveDebounce),g,v=AE++,w=null,S=oE(t.plugins),x={isEnabled:!0,isVisible:!1,isDestroyed:!1,isMounted:!1,isShown:!1},y={id:v,reference:n,popper:mo(),popperInstance:w,props:t,state:x,plugins:S,clearDelayTimeouts:ne,setProps:de,setContent:Oe,show:be,hide:me,hideWithInteractivity:Ze,enable:F,disable:H,unmount:An,destroy:Qn};if(!t.render)return process.env.NODE_ENV!=="production"&&ed(!0,"render() function has not been supplied."),y;var k=t.render(y),E=k.popper,T=k.onUpdate;E.setAttribute("data-tippy-root",""),E.id="tippy-"+y.id,y.popper=E,n._tippy=y,E._tippy=y;var N=S.map(function(z){return z.fn(y)}),_=n.hasAttribute("aria-expanded");return Ot(),we(),G(),ie("onCreate",[y]),t.showOnCreate&&C(),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&&V().addEventListener("mousemove",p)}),y;function A(){var z=y.props.touch;return Array.isArray(z)?z:[z,0]}function R(){return A()[0]==="hold"}function P(){var z;return!!((z=y.props.render)!=null&&z.$$tippy)}function $(){return g||n}function V(){var z=$().parentNode;return z?fE(z):document}function U(){return nd(E)}function J(z){return y.state.isMounted&&!y.state.isVisible||Fn.isTouch||u&&u.type==="focus"?0:Yu(y.props.delay,z?0:1,Gt.delay)}function G(z){z===void 0&&(z=!1),E.style.pointerEvents=y.props.interactive&&!z?"":"none",E.style.zIndex=""+y.props.zIndex}function ie(z,ee,oe){if(oe===void 0&&(oe=!0),N.forEach(function(Ee){Ee[z]&&Ee[z].apply(Ee,ee)}),oe){var _e;(_e=y.props)[z].apply(_e,ee)}}function X(){var z=y.props.aria;if(z.content){var ee="aria-"+z.content,oe=E.id,_e=Qi(y.props.triggerTarget||n);_e.forEach(function(Ee){var ft=Ee.getAttribute(ee);if(y.state.isVisible)Ee.setAttribute(ee,ft?ft+" "+oe:oe);else{var Pt=ft&&ft.replace(oe,"").trim();Pt?Ee.setAttribute(ee,Pt):Ee.removeAttribute(ee)}})}}function we(){if(!(_||!y.props.aria.expanded)){var z=Qi(y.props.triggerTarget||n);z.forEach(function(ee){y.props.interactive?ee.setAttribute("aria-expanded",y.state.isVisible&&ee===$()?"true":"false"):ee.removeAttribute("aria-expanded")})}}function Re(){V().removeEventListener("mousemove",p),Fl=Fl.filter(function(z){return z!==p})}function Pe(z){if(!(Fn.isTouch&&(a||z.type==="mousedown"))){var ee=z.composedPath&&z.composedPath()[0]||z.target;if(!(y.props.interactive&&Og(E,ee))){if(Qi(y.props.triggerTarget||n).some(function(oe){return Og(oe,ee)})){if(Fn.isTouch||y.state.isVisible&&y.props.trigger.indexOf("click")>=0)return}else ie("onClickOutside",[y,z]);y.props.hideOnClick===!0&&(y.clearDelayTimeouts(),y.hide(),l=!0,setTimeout(function(){l=!1}),y.state.isMounted||Le())}}}function Ce(){a=!0}function ye(){a=!1}function Ne(){var z=V();z.addEventListener("mousedown",Pe,!0),z.addEventListener("touchend",Pe,di),z.addEventListener("touchstart",ye,di),z.addEventListener("touchmove",Ce,di)}function Le(){var z=V();z.removeEventListener("mousedown",Pe,!0),z.removeEventListener("touchend",Pe,di),z.removeEventListener("touchstart",ye,di),z.removeEventListener("touchmove",Ce,di)}function tt(z,ee){Ge(z,function(){!y.state.isVisible&&E.parentNode&&E.parentNode.contains(E)&&ee()})}function nt(z,ee){Ge(z,ee)}function Ge(z,ee){var oe=U().box;function _e(Ee){Ee.target===oe&&(Qu(oe,"remove",_e),ee())}if(z===0)return ee();Qu(oe,"remove",d),Qu(oe,"add",_e),d=_e}function Ye(z,ee,oe){oe===void 0&&(oe=!1);var _e=Qi(y.props.triggerTarget||n);_e.forEach(function(Ee){Ee.addEventListener(z,ee,oe),h.push({node:Ee,eventType:z,handler:ee,options:oe})})}function Ot(){R()&&(Ye("touchstart",it,{passive:!0}),Ye("touchend",B,{passive:!0})),sE(y.props.trigger).forEach(function(z){if(z!=="manual")switch(Ye(z,it),z){case"mouseenter":Ye("mouseleave",B);break;case"focus":Ye(bE?"focusout":"blur",j);break;case"focusin":Ye("focusout",j);break}})}function xt(){h.forEach(function(z){var ee=z.node,oe=z.eventType,_e=z.handler,Ee=z.options;ee.removeEventListener(oe,_e,Ee)}),h=[]}function it(z){var ee,oe=!1;if(!(!y.state.isEnabled||q(z)||l)){var _e=((ee=u)==null?void 0:ee.type)==="focus";u=z,g=z.currentTarget,we(),!y.state.isVisible&&cE(z)&&Fl.forEach(function(Ee){return Ee(z)}),z.type==="click"&&(y.props.trigger.indexOf("mouseenter")<0||o)&&y.props.hideOnClick!==!1&&y.state.isVisible?oe=!0:C(z),z.type==="click"&&(o=!oe),oe&&!_e&&I(z)}}function at(z){var ee=z.target,oe=$().contains(ee)||E.contains(ee);if(!(z.type==="mousemove"&&oe)){var _e=b().concat(E).map(function(Ee){var ft,Pt=Ee._tippy,tn=(ft=Pt.popperInstance)==null?void 0:ft.state;return tn?{popperRect:Ee.getBoundingClientRect(),popperState:tn,props:t}:null}).filter(Boolean);hE(_e,z)&&(Re(),I(z))}}function B(z){var ee=q(z)||y.props.trigger.indexOf("click")>=0&&o;if(!ee){if(y.props.interactive){y.hideWithInteractivity(z);return}I(z)}}function j(z){y.props.trigger.indexOf("focusin")<0&&z.target!==$()||y.props.interactive&&z.relatedTarget&&E.contains(z.relatedTarget)||I(z)}function q(z){return Fn.isTouch?R()!==z.type.indexOf("touch")>=0:!1}function te(){M();var z=y.props,ee=z.popperOptions,oe=z.placement,_e=z.offset,Ee=z.getReferenceClientRect,ft=z.moveTransition,Pt=P()?nd(E).arrow:null,tn=Ee?{getBoundingClientRect:Ee,contextElement:Ee.contextElement||$()}:n,Ls={name:"$$tippy",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Ps){var br=Ps.state;if(P()){var bh=U(),Fs=bh.box;["placement","reference-hidden","escaped"].forEach(function(Ni){Ni==="placement"?Fs.setAttribute("data-placement",br.placement):br.attributes.popper["data-popper-"+Ni]?Fs.setAttribute("data-"+Ni,""):Fs.removeAttribute("data-"+Ni)}),br.attributes.popper={}}}},Mn=[{name:"offset",options:{offset:_e}},{name:"preventOverflow",options:{padding:{top:2,bottom:2,left:5,right:5}}},{name:"flip",options:{padding:5}},{name:"computeStyles",options:{adaptive:!ft}},Ls];P()&&Pt&&Mn.push({name:"arrow",options:{element:Pt,padding:3}}),Mn.push.apply(Mn,(ee==null?void 0:ee.modifiers)||[]),y.popperInstance=eE(tn,E,Object.assign({},ee,{placement:oe,onFirstUpdate:f,modifiers:Mn}))}function M(){y.popperInstance&&(y.popperInstance.destroy(),y.popperInstance=null)}function m(){var z=y.props.appendTo,ee,oe=$();y.props.interactive&&z===kg||z==="parent"?ee=oe.parentNode:ee=Sg(z,[oe]),ee.contains(E)||ee.appendChild(E),y.state.isMounted=!0,te(),process.env.NODE_ENV!=="production"&&sr(y.props.interactive&&z===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 Pl(E.querySelectorAll("[data-tippy-root]"))}function x(z){y.clearDelayTimeouts(),z&&ie("onTrigger",[y,z]),_e();var ee=J(!0),oe=A(),Oe=oe[0],Ee=oe[1];Fn.isTouch&&Oe==="hold"&&Ee&&(ee=Ee),ee?r=setTimeout(function(){y.show()},ee):y.show()}function I(z){if(y.clearDelayTimeouts(),ie("onUntrigger",[y,z]),!y.state.isVisible){Le();return}if(!(y.props.trigger.indexOf("mouseenter")>=0&&y.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(z.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(z){if(process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,es("setProps")),!y.state.isDestroyed){ie("onBeforeUpdate",[y,z]),Ct();var ee=y.props,oe=Pg(n,Object.assign({},ee,Ag(z),{ignoreAttributes:!0}));y.props=oe,Ot(),ee.interactiveDebounce!==oe.interactiveDebounce&&(Re(),p=Eg(at,oe.interactiveDebounce)),ee.triggerTarget&&!oe.triggerTarget?Qi(ee.triggerTarget).forEach(function(Oe){Oe.removeAttribute("aria-expanded")}):oe.triggerTarget&&n.removeAttribute("aria-expanded"),we(),G(),T&&T(ee,oe),y.popperInstance&&(te(),b().forEach(function(Oe){requestAnimationFrame(Oe._tippy.popperInstance.forceUpdate)})),ie("onAfterUpdate",[y,z])}}function Me(z){y.setProps({content:z})}function be(){process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,es("show"));var z=y.state.isVisible,ee=y.state.isDestroyed,oe=!y.state.isEnabled,Oe=Fn.isTouch&&!y.props.touch,Ee=Yu(y.props.duration,0,Gt.duration);if(!(z||ee||oe||Oe)&&!$().hasAttribute("disabled")&&(ie("onShow",[y],!1),y.props.onShow(y)!==!1)){if(y.state.isVisible=!0,P()&&(E.style.visibility="visible"),G(),_e(),y.state.isMounted||(E.style.transition="none"),P()){var ft=U(),Pt=ft.box,tn=ft.content;Xu([Pt,tn],0)}f=function(){var Mn;if(!(!y.state.isVisible||c)){if(c=!0,E.offsetHeight,E.style.transition=y.props.moveTransition,P()&&y.props.animation){var Is=U(),Ps=Is.box,br=Is.content;Xu([Ps,br],Ee),Mg([Ps,br],"visible")}X(),we(),Tg(rd,y),(Mn=y.popperInstance)==null||Mn.forceUpdate(),ie("onMount",[y]),y.props.animation&&P()&&nt(Ee,function(){y.state.isShown=!0,ie("onShown",[y])})}},m()}}function me(){process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,es("hide"));var z=!y.state.isVisible,ee=y.state.isDestroyed,oe=!y.state.isEnabled,Oe=Yu(y.props.duration,1,Gt.duration);if(!(z||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"),Re(),Le(),G(!0),P()){var Ee=U(),ft=Ee.box,Pt=Ee.content;y.props.animation&&(Xu([ft,Pt],Oe),Mg([ft,Pt],"hidden"))}X(),we(),y.props.animation?P()&&tt(Oe,y.unmount):y.unmount()}}function Ze(z){process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,es("hideWithInteractivity")),V().addEventListener("mousemove",p),Tg(Fl,p),p(z)}function An(){process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,es("unmount")),y.state.isVisible&&y.hide(),y.state.isMounted&&(M(),b().forEach(function(z){z._tippy.unmount()}),E.parentNode&&E.parentNode.removeChild(E),rd=rd.filter(function(z){return z!==y}),y.state.isMounted=!1,ie("onHidden",[y]))}function Qn(){process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,es("destroy")),!y.state.isDestroyed&&(y.clearDelayTimeouts(),y.unmount(),Ct(),delete n._tippy,y.state.isDestroyed=!0,ie("onDestroy",[y]))}}function fi(n,e){e===void 0&&(e={});var t=Gt.plugins.concat(e.plugins||[]);process.env.NODE_ENV!=="production"&&(CE(n),Fg(e,t)),gE();var r=Object.assign({},e,{plugins:t}),i=dE(n);if(process.env.NODE_ENV!=="production"){var s=go(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.",`
133
+ `,"See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity"].join(" "))}function b(){return Pl(E.querySelectorAll("[data-tippy-root]"))}function C(z){y.clearDelayTimeouts(),z&&ie("onTrigger",[y,z]),Ne();var ee=J(!0),oe=A(),_e=oe[0],Ee=oe[1];Fn.isTouch&&_e==="hold"&&Ee&&(ee=Ee),ee?r=setTimeout(function(){y.show()},ee):y.show()}function I(z){if(y.clearDelayTimeouts(),ie("onUntrigger",[y,z]),!y.state.isVisible){Le();return}if(!(y.props.trigger.indexOf("mouseenter")>=0&&y.props.trigger.indexOf("click")>=0&&["mouseleave","mousemove"].indexOf(z.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(z){if(process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,es("setProps")),!y.state.isDestroyed){ie("onBeforeUpdate",[y,z]),xt();var ee=y.props,oe=Pg(n,Object.assign({},ee,Ag(z),{ignoreAttributes:!0}));y.props=oe,Ot(),ee.interactiveDebounce!==oe.interactiveDebounce&&(Re(),p=Eg(at,oe.interactiveDebounce)),ee.triggerTarget&&!oe.triggerTarget?Qi(ee.triggerTarget).forEach(function(_e){_e.removeAttribute("aria-expanded")}):oe.triggerTarget&&n.removeAttribute("aria-expanded"),we(),G(),T&&T(ee,oe),y.popperInstance&&(te(),b().forEach(function(_e){requestAnimationFrame(_e._tippy.popperInstance.forceUpdate)})),ie("onAfterUpdate",[y,z])}}function Oe(z){y.setProps({content:z})}function be(){process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,es("show"));var z=y.state.isVisible,ee=y.state.isDestroyed,oe=!y.state.isEnabled,_e=Fn.isTouch&&!y.props.touch,Ee=Yu(y.props.duration,0,Gt.duration);if(!(z||ee||oe||_e)&&!$().hasAttribute("disabled")&&(ie("onShow",[y],!1),y.props.onShow(y)!==!1)){if(y.state.isVisible=!0,P()&&(E.style.visibility="visible"),G(),Ne(),y.state.isMounted||(E.style.transition="none"),P()){var ft=U(),Pt=ft.box,tn=ft.content;Xu([Pt,tn],0)}f=function(){var Mn;if(!(!y.state.isVisible||c)){if(c=!0,E.offsetHeight,E.style.transition=y.props.moveTransition,P()&&y.props.animation){var Is=U(),Ps=Is.box,br=Is.content;Xu([Ps,br],Ee),Mg([Ps,br],"visible")}X(),we(),Tg(rd,y),(Mn=y.popperInstance)==null||Mn.forceUpdate(),ie("onMount",[y]),y.props.animation&&P()&&nt(Ee,function(){y.state.isShown=!0,ie("onShown",[y])})}},m()}}function me(){process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,es("hide"));var z=!y.state.isVisible,ee=y.state.isDestroyed,oe=!y.state.isEnabled,_e=Yu(y.props.duration,1,Gt.duration);if(!(z||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"),Re(),Le(),G(!0),P()){var Ee=U(),ft=Ee.box,Pt=Ee.content;y.props.animation&&(Xu([ft,Pt],_e),Mg([ft,Pt],"hidden"))}X(),we(),y.props.animation?P()&&tt(_e,y.unmount):y.unmount()}}function Ze(z){process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,es("hideWithInteractivity")),V().addEventListener("mousemove",p),Tg(Fl,p),p(z)}function An(){process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,es("unmount")),y.state.isVisible&&y.hide(),y.state.isMounted&&(M(),b().forEach(function(z){z._tippy.unmount()}),E.parentNode&&E.parentNode.removeChild(E),rd=rd.filter(function(z){return z!==y}),y.state.isMounted=!1,ie("onHidden",[y]))}function Qn(){process.env.NODE_ENV!=="production"&&sr(y.state.isDestroyed,es("destroy")),!y.state.isDestroyed&&(y.clearDelayTimeouts(),y.unmount(),xt(),delete n._tippy,y.state.isDestroyed=!0,ie("onDestroy",[y]))}}function fi(n,e){e===void 0&&(e={});var t=Gt.plugins.concat(e.plugins||[]);process.env.NODE_ENV!=="production"&&(xE(n),Fg(e,t)),gE();var r=Object.assign({},e,{plugins:t}),i=dE(n);if(process.env.NODE_ENV!=="production"){var s=go(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&&ME(c,r);return u&&a.push(u),a},[]);return go(n)?l[0]:l}fi.defaultProps=Gt,fi.setDefaultProps=SE,fi.currentInput=Fn,Object.assign({},ig,{effect:function(e){var t=e.state,r={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,r.popper),t.styles=r,t.elements.arrow&&Object.assign(t.elements.arrow.style,r.arrow)}});var OE={name:"sticky",defaultValue:!1,fn:function(e){var t=e.reference,r=e.popper;function i(){return e.popperInstance?e.popperInstance.state.elements.reference:t}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&&Hg(o,c)||u&&Hg(l,u))&&e.popperInstance&&e.popperInstance.update(),o=c,l=u,e.state.isMounted&&requestAnimationFrame(a)}return{onMount:function(){e.props.sticky&&a()}}}};function Hg(n,e){return n&&e?n.top!==e.top||n.right!==e.right||n.bottom!==e.bottom||n.left!==e.left:!0}fi.setDefaultProps({render:jg});class _E{constructor({editor:e,element:t,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&&Du(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,C=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:C,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(Qm(p.selection)){let E=l.nodeDOM(C);const T=E.dataset.nodeViewWrapper?E:E.querySelector("[data-node-view-wrapper]");if(T&&(E=T.firstChild),E)return E.getBoundingClientRect()}return Mk(l,C,y)})}),this.show()},this.editor=e,this.element=t,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,t=!!e.parentElement;this.tippy||!t||(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,t){const{state:r}=e,i=r.selection.$from.pos!==r.selection.$to.pos;if(this.updateDelay>0&&i){this.handleDebouncedUpdate(e,t);return}const s=!(t!=null&&t.selection.eq(e.state.selection)),o=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,s,o,t)}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,t;!((e=this.tippy)===null||e===void 0)&&e.popper.firstChild&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),(t=this.tippy)===null||t===void 0||t.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 Vg=n=>new je({key:typeof n.pluginKey=="string"?new We(n.pluginKey):n.pluginKey,view:e=>new _E({view:e,...n})});Ue.create({name:"bubbleMenu",addOptions(){return{element:null,tippyOptions:{},pluginKey:"bubbleMenu",updateDelay:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Vg({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,updateDelay:this.options.updateDelay,shouldShow:this.options.shouldShow})]:[]}});const NE=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},DE=({renderers:n})=>O.createElement(O.Fragment,null,Object.entries(n).map(([e,t])=>nn.createPortal(t.reactElement,t.element,e)));class RE 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 t=this.editorContentRef.current;t.append(...e.options.element.childNodes),e.setOptions({element:t}),e.contentComponent=this,e.createNodeViews(),this.initialized=!0}}maybeFlushSync(e){this.initialized?nn.flushSync(e):e()}setRenderer(e,t){this.maybeFlushSync(()=>{this.setState(({renderers:r})=>({renderers:{...r,[e]:t}}))})}removeRenderer(e){this.maybeFlushSync(()=>{this.setState(({renderers:t})=>{const r={...t};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 t=document.createElement("div");t.append(...e.options.element.childNodes),e.setOptions({element:t})}render(){const{editor:e,innerRef:t,...r}=this.props;return O.createElement(O.Fragment,null,O.createElement("div",{ref:NE(t,this.editorContentRef),...r}),O.createElement(DE,{renderers:this.state.renderers}))}}const LE=O.forwardRef((n,e)=>{const t=O.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return O.createElement(RE,{key:t,innerRef:e,...n})}),IE=O.memo(LE);class PE extends qk{constructor(){super(...arguments),this.contentComponent=null}}const FE=(n={},e=[])=>{const t=O.useRef(null),[,r]=O.useState({}),{onBeforeCreate:i,onBlur:s,onCreate:o,onDestroy:l,onFocus:a,onSelectionUpdate:c,onTransaction:u,onUpdate:d}=n,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),C=O.useRef(d);return O.useEffect(()=>{t.current&&(i&&(t.current.off("beforeCreate",f.current),t.current.on("beforeCreate",i),f.current=i),s&&(t.current.off("blur",h.current),t.current.on("blur",s),h.current=s),o&&(t.current.off("create",p.current),t.current.on("create",o),p.current=o),l&&(t.current.off("destroy",g.current),t.current.on("destroy",l),g.current=l),a&&(t.current.off("focus",v.current),t.current.on("focus",a),v.current=a),c&&(t.current.off("selectionUpdate",w.current),t.current.on("selectionUpdate",c),w.current=c),u&&(t.current.off("transaction",S.current),t.current.on("transaction",u),S.current=u),d&&(t.current.off("update",C.current),t.current.on("update",d),C.current=d))},[i,s,o,l,a,c,u,d,t.current]),O.useEffect(()=>{let y=!0;const k=new PE(n);return t.current=k,t.current.on("transaction",()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{y&&r({})})})}),()=>{y=!1,k.destroy()}},e),t.current},zg=O.createContext({editor:null});zg.Consumer;const BE=()=>O.useContext(zg),Ug=n=>{const[e,t]=O.useState(null),{editor:r}=BE();return O.useEffect(()=>{var i;if(!e||!((i=n.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}=n,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=Vg({updateDelay:a,editor:u,element:e,pluginKey:s,shouldShow:c,tippyOptions:l});return u.registerPlugin(d),()=>u.unregisterPlugin(s)},[n.editor,r,e]),O.createElement("div",{ref:t,className:n.className,style:{visibility:"hidden"}},n.children)},Wg=O.createContext({onDragStart:void 0}),qg=()=>O.useContext(Wg),Kg=n=>{const e=n.as||"div",{nodeViewContentRef:t}=qg();return O.createElement(e,{...n,ref:t,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...n.style}})},bo=O.forwardRef((n,e)=>{const{onDragStart:t}=qg(),r=n.as||"div";return O.createElement(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function $E(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function jE(n){var e;return typeof n=="object"&&((e=n.$$typeof)===null||e===void 0?void 0:e.toString())==="Symbol(react.forward_ref)"}class Jg{constructor(e,{editor:t,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=t,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,t;const r=this.component,i=this.props;($E(r)||jE(r))&&(i.ref=s=>{this.ref=s}),this.reactElement=O.createElement(r,{...i}),(t=(e=this.editor)===null||e===void 0?void 0:e.contentComponent)===null||t===void 0||t.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e,t;(t=(e=this.editor)===null||e===void 0?void 0:e.contentComponent)===null||t===void 0||t.removeRenderer(this.id)}}class HE extends Jk{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 t=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(Wg.Provider,{value:{onDragStart:l,nodeViewContentRef:a}},O.createElement(o,{...s})))};t.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 Jg(t,{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:t}=this.editor.state.selection;if(e<=this.getPos()&&t>=this.getPos()+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,t){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=t,this.options.update({oldNode:i,oldDecorations:s,newNode:e,newDecorations:t,updateProps:()=>r({node:e,decorations:t})})}return e===this.node&&this.decorations===t||(this.node=e,this.decorations=t,r({node:e,decorations:t})),!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(n,e){return t=>t.editor.contentComponent?new HE(n,t,e):{}}var Gg={exports:{}};/*!
138
+ `,"2) content: () => element.cloneNode(true)"].join(" "))}var l=i.reduce(function(a,c){var u=c&&ME(c,r);return u&&a.push(u),a},[]);return go(n)?l[0]:l}fi.defaultProps=Gt,fi.setDefaultProps=SE,fi.currentInput=Fn,Object.assign({},ig,{effect:function(e){var t=e.state,r={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};Object.assign(t.elements.popper.style,r.popper),t.styles=r,t.elements.arrow&&Object.assign(t.elements.arrow.style,r.arrow)}});var OE={name:"sticky",defaultValue:!1,fn:function(e){var t=e.reference,r=e.popper;function i(){return e.popperInstance?e.popperInstance.state.elements.reference:t}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&&Hg(o,c)||u&&Hg(l,u))&&e.popperInstance&&e.popperInstance.update(),o=c,l=u,e.state.isMounted&&requestAnimationFrame(a)}return{onMount:function(){e.props.sticky&&a()}}}};function Hg(n,e){return n&&e?n.top!==e.top||n.right!==e.right||n.bottom!==e.bottom||n.left!==e.left:!0}fi.setDefaultProps({render:jg});class _E{constructor({editor:e,element:t,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&&Du(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(Qm(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 Mk(l,x,y)})}),this.show()},this.editor=e,this.element=t,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,t=!!e.parentElement;this.tippy||!t||(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,t){const{state:r}=e,i=r.selection.$from.pos!==r.selection.$to.pos;if(this.updateDelay>0&&i){this.handleDebouncedUpdate(e,t);return}const s=!(t!=null&&t.selection.eq(e.state.selection)),o=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,s,o,t)}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,t;!((e=this.tippy)===null||e===void 0)&&e.popper.firstChild&&this.tippy.popper.firstChild.removeEventListener("blur",this.tippyBlurHandler),(t=this.tippy)===null||t===void 0||t.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 Vg=n=>new je({key:typeof n.pluginKey=="string"?new We(n.pluginKey):n.pluginKey,view:e=>new _E({view:e,...n})});Ue.create({name:"bubbleMenu",addOptions(){return{element:null,tippyOptions:{},pluginKey:"bubbleMenu",updateDelay:void 0,shouldShow:null}},addProseMirrorPlugins(){return this.options.element?[Vg({pluginKey:this.options.pluginKey,editor:this.editor,element:this.options.element,tippyOptions:this.options.tippyOptions,updateDelay:this.options.updateDelay,shouldShow:this.options.shouldShow})]:[]}});const NE=(...n)=>e=>{n.forEach(t=>{typeof t=="function"?t(e):t&&(t.current=e)})},DE=({renderers:n})=>O.createElement(O.Fragment,null,Object.entries(n).map(([e,t])=>nn.createPortal(t.reactElement,t.element,e)));class RE 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 t=this.editorContentRef.current;t.append(...e.options.element.childNodes),e.setOptions({element:t}),e.contentComponent=this,e.createNodeViews(),this.initialized=!0}}maybeFlushSync(e){this.initialized?nn.flushSync(e):e()}setRenderer(e,t){this.maybeFlushSync(()=>{this.setState(({renderers:r})=>({renderers:{...r,[e]:t}}))})}removeRenderer(e){this.maybeFlushSync(()=>{this.setState(({renderers:t})=>{const r={...t};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 t=document.createElement("div");t.append(...e.options.element.childNodes),e.setOptions({element:t})}render(){const{editor:e,innerRef:t,...r}=this.props;return O.createElement(O.Fragment,null,O.createElement("div",{ref:NE(t,this.editorContentRef),...r}),O.createElement(DE,{renderers:this.state.renderers}))}}const LE=O.forwardRef((n,e)=>{const t=O.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[n.editor]);return O.createElement(RE,{key:t,innerRef:e,...n})}),IE=O.memo(LE);class PE extends qk{constructor(){super(...arguments),this.contentComponent=null}}const FE=(n={},e=[])=>{const t=O.useRef(null),[,r]=O.useState({}),{onBeforeCreate:i,onBlur:s,onCreate:o,onDestroy:l,onFocus:a,onSelectionUpdate:c,onTransaction:u,onUpdate:d}=n,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(()=>{t.current&&(i&&(t.current.off("beforeCreate",f.current),t.current.on("beforeCreate",i),f.current=i),s&&(t.current.off("blur",h.current),t.current.on("blur",s),h.current=s),o&&(t.current.off("create",p.current),t.current.on("create",o),p.current=o),l&&(t.current.off("destroy",g.current),t.current.on("destroy",l),g.current=l),a&&(t.current.off("focus",v.current),t.current.on("focus",a),v.current=a),c&&(t.current.off("selectionUpdate",w.current),t.current.on("selectionUpdate",c),w.current=c),u&&(t.current.off("transaction",S.current),t.current.on("transaction",u),S.current=u),d&&(t.current.off("update",x.current),t.current.on("update",d),x.current=d))},[i,s,o,l,a,c,u,d,t.current]),O.useEffect(()=>{let y=!0;const k=new PE(n);return t.current=k,t.current.on("transaction",()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{y&&r({})})})}),()=>{y=!1,k.destroy()}},e),t.current},zg=O.createContext({editor:null});zg.Consumer;const BE=()=>O.useContext(zg),Ug=n=>{const[e,t]=O.useState(null),{editor:r}=BE();return O.useEffect(()=>{var i;if(!e||!((i=n.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}=n,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=Vg({updateDelay:a,editor:u,element:e,pluginKey:s,shouldShow:c,tippyOptions:l});return u.registerPlugin(d),()=>u.unregisterPlugin(s)},[n.editor,r,e]),O.createElement("div",{ref:t,className:n.className,style:{visibility:"hidden"}},n.children)},Wg=O.createContext({onDragStart:void 0}),qg=()=>O.useContext(Wg),Kg=n=>{const e=n.as||"div",{nodeViewContentRef:t}=qg();return O.createElement(e,{...n,ref:t,"data-node-view-content":"",style:{whiteSpace:"pre-wrap",...n.style}})},bo=O.forwardRef((n,e)=>{const{onDragStart:t}=qg(),r=n.as||"div";return O.createElement(r,{...n,ref:e,"data-node-view-wrapper":"",onDragStart:t,style:{whiteSpace:"normal",...n.style}})});function $E(n){return!!(typeof n=="function"&&n.prototype&&n.prototype.isReactComponent)}function jE(n){var e;return typeof n=="object"&&((e=n.$$typeof)===null||e===void 0?void 0:e.toString())==="Symbol(react.forward_ref)"}class Jg{constructor(e,{editor:t,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=t,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,t;const r=this.component,i=this.props;($E(r)||jE(r))&&(i.ref=s=>{this.ref=s}),this.reactElement=O.createElement(r,{...i}),(t=(e=this.editor)===null||e===void 0?void 0:e.contentComponent)===null||t===void 0||t.setRenderer(this.id,this)}updateProps(e={}){this.props={...this.props,...e},this.render()}destroy(){var e,t;(t=(e=this.editor)===null||e===void 0?void 0:e.contentComponent)===null||t===void 0||t.removeRenderer(this.id)}}class HE extends Jk{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 t=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(Wg.Provider,{value:{onDragStart:l,nodeViewContentRef:a}},O.createElement(o,{...s})))};t.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 Jg(t,{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:t}=this.editor.state.selection;if(e<=this.getPos()&&t>=this.getPos()+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(e,t){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=t,this.options.update({oldNode:i,oldDecorations:s,newNode:e,newDecorations:t,updateProps:()=>r({node:e,decorations:t})})}return e===this.node&&this.decorations===t||(this.node=e,this.decorations=t,r({node:e,decorations:t})),!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(n,e){return t=>t.editor.contentComponent?new HE(n,t,e):{}}var Gg={exports:{}};/*!
139
139
  Copyright (c) 2018 Jed Watson.
140
140
  Licensed under the MIT License (MIT), see
141
141
  http://jedwatson.github.io/classnames
@@ -159,164 +159,179 @@ img.ProseMirror-separator {
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 De=(n,e)=>{const t=O.forwardRef(({className:r,...i},s)=>O.createElement(WE,{ref:s,iconNode:e,className:n0(`lucide-${zE(n)}`,r),...i}));return t.displayName=`${n}`,t};/**
162
+ */const Me=(n,e)=>{const t=O.forwardRef(({className:r,...i},s)=>O.createElement(WE,{ref:s,iconNode:e,className:n0(`lucide-${zE(n)}`,r),...i}));return t.displayName=`${n}`,t};/**
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 r0=De("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
167
+ */const r0=Me("Ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]);/**
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 Bl=De("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
172
+ */const Bl=Me("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
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 id=De("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
177
+ */const id=Me("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/**
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 qE=De("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"}]]);/**
182
+ */const qE=Me("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"}]]);/**
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 i0=De("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/**
187
+ */const i0=Me("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]);/**
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 s0=De("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);/**
192
+ */const s0=Me("Columns2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);/**
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 KE=De("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"}]]);/**
197
+ */const KE=Me("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"}]]);/**
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 JE=De("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"}]]);/**
202
+ */const JE=Me("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"}]]);/**
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 GE=De("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"}]]);/**
207
+ */const GE=Me("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"}]]);/**
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 YE=De("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"}]]);/**
212
+ */const YE=Me("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"}]]);/**
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 o0=De("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"}]]);/**
217
+ */const o0=Me("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"}]]);/**
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 l0=De("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"}]]);/**
222
+ */const l0=Me("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"}]]);/**
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 a0=De("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"}]]);/**
227
+ */const a0=Me("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"}]]);/**
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 ZE=De("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"}]]);/**
232
+ */const ZE=Me("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"}]]);/**
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 sd=De("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"}]]);/**
237
+ */const sd=Me("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"}]]);/**
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 XE=De("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"}]]);/**
242
+ */const XE=Me("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"}]]);/**
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 QE=De("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
247
+ */const QE=Me("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
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 eT=De("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);/**
252
+ */const eT=Me("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);/**
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 tT=De("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
257
+ */const tT=Me("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);/**
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 nT=De("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
262
+ */const nT=Me("Pencil",[["path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z",key:"5qss01"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);/**
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 rT=De("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"}]]);/**
267
+ */const rT=Me("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/**
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 c0=De("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"}]]);/**
272
+ */const iT=Me("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"}]]);/**
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 iT=De("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"}]]);/**
277
+ */const sT=Me("ScanEye",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M5 12s2.5-5 7-5 7 5 7 5-2.5 5-7 5-7-5-7-5",key:"nhuolu"}]]);/**
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 sT=De("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"}]]);/**
282
+ */const oT=Me("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/**
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 u0=De("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"}]]);/**
287
+ */const c0=Me("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"}]]);/**
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 d0=De("Text",[["path",{d:"M17 6.1H3",key:"wptmhv"}],["path",{d:"M21 12.1H3",key:"1j38uz"}],["path",{d:"M15.1 18H3",key:"1nb16a"}]]);/**
292
+ */const lT=Me("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"}]]);/**
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 oT=De("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"}]]);/**
297
+ */const aT=Me("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"}]]);/**
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 f0=De("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"}]]);/**
302
+ */const u0=Me("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"}]]);/**
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 h0=De("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"}]]),lT=({editor:n,isOpen:e,setIsOpen:t})=>{const r=[{name:"Text",icon:d0,command:()=>n.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>n.isActive("paragraph")&&!n.isActive("bulletList")&&!n.isActive("orderedList")},{name:"Heading 1",icon:o0,command:()=>n.chain().focus().toggleHeading({level:1}).run(),isActive:()=>n.isActive("heading",{level:1})},{name:"Heading 2",icon:l0,command:()=>n.chain().focus().toggleHeading({level:2}).run(),isActive:()=>n.isActive("heading",{level:2})},{name:"Heading 3",icon:a0,command:()=>n.chain().focus().toggleHeading({level:3}).run(),isActive:()=>n.isActive("heading",{level:3})},{name:"To-do List",icon:c0,command:()=>n.chain().focus().toggleTaskList().run(),isActive:()=>n.isActive("taskItem")},{name:"Bullet List",icon:sd,command:()=>n.chain().focus().toggleBulletList().run(),isActive:()=>n.isActive("bulletList")},{name:"Numbered List",icon:sd,command:()=>n.chain().focus().toggleOrderedList().run(),isActive:()=>n.isActive("orderedList")},{name:"Quote",icon:u0,command:()=>n.chain().focus().toggleNode("paragraph","paragraph").toggleBlockquote().run(),isActive:()=>n.isActive("blockquote")},{name:"Code",icon:i0,command:()=>n.chain().focus().toggleCode().run(),isActive:()=>n.isActive("code")}],i=r.filter(s=>s.isActive()).pop()??{name:"Multiple"};return D.jsxs("div",{className:"relative h-full",children:[D.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:()=>t(!e),children:[D.jsx("span",{children:i==null?void 0:i.name}),D.jsx(id,{className:"h-4 w-4"})]}),e&&D.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)=>D.jsxs("button",{onClick:()=>{s.command(),t(!1)},className:Fe("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:[D.jsxs("div",{className:"flex items-center space-x-2",children:[D.jsx("div",{className:"rounded-sm border border-stone-200 p-1",children:D.jsx(s.icon,{className:"h-3 w-3"})}),D.jsx("span",{children:s.name})]}),i.name===s.name&&D.jsx(Bl,{className:"h-4 w-4"})]},o))})]})},aT=({editor:n,isOpen:e,setIsOpen:t})=>{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})=>n.isActive("textStyle",{color:s}));return D.jsxs("div",{className:"",children:[D.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:()=>t(!e),children:[D.jsx("span",{style:{color:(i==null?void 0:i.color)||"#000000"},children:"A"}),D.jsx(id,{className:"h-4 w-4 "})]}),e&&D.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)=>D.jsxs("button",{onClick:()=>{n.chain().focus().setColor(o).run(),t(!1)},className:Fe("flex items-center justify-between rounded-sm px-2 py-1 text-sm text-stone-600 hover:bg-stone-100",{"text-blue-600":n.isActive("textStyle",{color:o})}),children:[D.jsxs("div",{className:"flex items-center space-x-2",children:[D.jsx("div",{className:"rounded-sm border border-stone-200 px-1 py-px font-medium",style:{color:o},children:"A"}),D.jsx("span",{children:s})]}),n.isActive("textStyle",{color:o})&&D.jsx(Bl,{className:"h-4 w-4"})]},l))})]})};var Te=(n=>(n[n.NONE=0]="NONE",n[n.HEADING=1]="HEADING",n[n.TEXT_COLOR=2]="TEXT_COLOR",n[n.HIGHLIGHT=3]="HIGHLIGHT",n[n.LINK=4]="LINK",n[n.FONT_FAMILY=5]="FONT_FAMILY",n[n.ALIGNMENT=6]="ALIGNMENT",n[n.LIST=7]="LIST",n))(Te||{});function cT(n){const[e,t]=O.useState(n),r=O.useRef(null),i=s=>{r&&r.current&&!r.current.contains(s.target)&&t(0)};return O.useEffect(()=>(document.addEventListener("click",i,!0),()=>{document.removeEventListener("click",i,!0)}),[]),{ref:r,toolVisibilty:e,setToolVisibility:t}}const uT="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_349_446'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_349_446)'%3e%3cpath%20d='M5.55%2019L2%2015.45L3.4%2014.05L5.525%2016.175L9.775%2011.925L11.175%2013.35L5.55%2019ZM5.55%2011L2%207.45005L3.4%206.05005L5.525%208.17505L9.775%203.92505L11.175%205.35005L5.55%2011ZM13%2017V15H22V17H13ZM13%209.00005V7.00005H22V9.00005H13Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",dT="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_337_2594'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_337_2594)'%3e%3cpath%20d='M3.9751%2017L7.7251%207H9.5251L13.2751%2017H11.5501L10.6501%2014.45H6.6001L5.7001%2017H3.9751ZM7.1251%2013H10.1251L8.6751%208.85H8.5751L7.1251%2013ZM16.3501%2017.275C15.5334%2017.275%2014.8918%2017.0625%2014.4251%2016.6375C13.9584%2016.2125%2013.7251%2015.6333%2013.7251%2014.9C13.7251%2014.2%2013.9959%2013.6292%2014.5376%2013.1875C15.0793%2012.7458%2015.7751%2012.525%2016.6251%2012.525C17.0084%2012.525%2017.3626%2012.5542%2017.6876%2012.6125C18.0126%2012.6708%2018.2918%2012.7667%2018.5251%2012.9V12.55C18.5251%2012.1%2018.3709%2011.7417%2018.0626%2011.475C17.7543%2011.2083%2017.3334%2011.075%2016.8001%2011.075C16.4501%2011.075%2016.1209%2011.15%2015.8126%2011.3C15.5043%2011.45%2015.2418%2011.6667%2015.0251%2011.95L13.9501%2011.15C14.2668%2010.7%2014.6668%2010.3583%2015.1501%2010.125C15.6334%209.89167%2016.1918%209.775%2016.8251%209.775C17.8584%209.775%2018.6501%2010.0208%2019.2001%2010.5125C19.7501%2011.0042%2020.0251%2011.7167%2020.0251%2012.65V17.05H18.5501V16.2H18.4751C18.2584%2016.5333%2017.9668%2016.7958%2017.6001%2016.9875C17.2334%2017.1792%2016.8168%2017.275%2016.3501%2017.275ZM16.6001%2016.025C17.1334%2016.025%2017.5876%2015.8375%2017.9626%2015.4625C18.3376%2015.0875%2018.5251%2014.6333%2018.5251%2014.1C18.2918%2013.9667%2018.0251%2013.8667%2017.7251%2013.8C17.4251%2013.7333%2017.1501%2013.7%2016.9001%2013.7C16.3668%2013.7%2015.9584%2013.8042%2015.6751%2014.0125C15.3918%2014.2208%2015.2501%2014.5167%2015.2501%2014.9C15.2501%2015.2333%2015.3751%2015.5042%2015.6251%2015.7125C15.8751%2015.9208%2016.2001%2016.025%2016.6001%2016.025Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",p0="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_224_2464'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_224_2464)'%3e%3cpath%20d='M3%2021V19H21V21H3ZM7%2017V15H17V17H7ZM3%2013V11H21V13H3ZM7%209V7H17V9H7ZM3%205V3H21V5H3Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",od="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_337_2575'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_337_2575)'%3e%3cpath%20d='M3%2021V19H21V21H3ZM3%2017V15H15V17H3ZM3%2013V11H21V13H3ZM3%209V7H15V9H3ZM3%205V3H21V5H3Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",m0="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_224_2470'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_224_2470)'%3e%3cpath%20d='M3%205V3H21V5H3ZM9%209V7H21V9H9ZM3%2013V11H21V13H3ZM9%2017V15H21V17H9ZM3%2021V19H21V21H3Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",g0="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_337_2572'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_337_2572)'%3e%3cpath%20d='M9%2019V17H21V19H9ZM9%2013V11H21V13H9ZM9%207V5H21V7H9ZM5%2020C4.45%2020%203.97917%2019.8042%203.5875%2019.4125C3.19583%2019.0208%203%2018.55%203%2018C3%2017.45%203.19583%2016.9792%203.5875%2016.5875C3.97917%2016.1958%204.45%2016%205%2016C5.55%2016%206.02083%2016.1958%206.4125%2016.5875C6.80417%2016.9792%207%2017.45%207%2018C7%2018.55%206.80417%2019.0208%206.4125%2019.4125C6.02083%2019.8042%205.55%2020%205%2020ZM5%2014C4.45%2014%203.97917%2013.8042%203.5875%2013.4125C3.19583%2013.0208%203%2012.55%203%2012C3%2011.45%203.19583%2010.9792%203.5875%2010.5875C3.97917%2010.1958%204.45%2010%205%2010C5.55%2010%206.02083%2010.1958%206.4125%2010.5875C6.80417%2010.9792%207%2011.45%207%2012C7%2012.55%206.80417%2013.0208%206.4125%2013.4125C6.02083%2013.8042%205.55%2014%205%2014ZM5%208C4.45%208%203.97917%207.80417%203.5875%207.4125C3.19583%207.02083%203%206.55%203%206C3%205.45%203.19583%204.97917%203.5875%204.5875C3.97917%204.19583%204.45%204%205%204C5.55%204%206.02083%204.19583%206.4125%204.5875C6.80417%204.97917%207%205.45%207%206C7%206.55%206.80417%207.02083%206.4125%207.4125C6.02083%207.80417%205.55%208%205%208Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",fT="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_349_458'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_349_458)'%3e%3cpath%20d='M3%2022V20.5H5.5V19.75H4V18.25H5.5V17.5H3V16H6C6.28333%2016%206.52083%2016.0958%206.7125%2016.2875C6.90417%2016.4792%207%2016.7167%207%2017V18C7%2018.2833%206.90417%2018.5208%206.7125%2018.7125C6.52083%2018.9042%206.28333%2019%206%2019C6.28333%2019%206.52083%2019.0958%206.7125%2019.2875C6.90417%2019.4792%207%2019.7167%207%2020V21C7%2021.2833%206.90417%2021.5208%206.7125%2021.7125C6.52083%2021.9042%206.28333%2022%206%2022H3ZM3%2015V12.25C3%2011.9667%203.09583%2011.7292%203.2875%2011.5375C3.47917%2011.3458%203.71667%2011.25%204%2011.25H5.5V10.5H3V9H6C6.28333%209%206.52083%209.09583%206.7125%209.2875C6.90417%209.47917%207%209.71667%207%2010V11.75C7%2012.0333%206.90417%2012.2708%206.7125%2012.4625C6.52083%2012.6542%206.28333%2012.75%206%2012.75H4.5V13.5H7V15H3ZM4.5%208V3.5H3V2H6V8H4.5ZM9%2019V17H21V19H9ZM9%2013V11H21V13H9ZM9%207V5H21V7H9Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",hT="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_337_2560'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_337_2560)'%3e%3cpath%20d='M5%2019V17H19V19H5ZM6.9%2015L11%204H13L17.1%2015H15.2L14.25%2012.2H9.8L8.8%2015H6.9ZM10.35%2010.6H13.65L12.05%206.05H11.95L10.35%2010.6Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",pT="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='m228-240%2092-160q-66%200-113-47t-47-113q0-66%2047-113t113-47q66%200%20113%2047t47%20113q0%2023-5.5%2042.5T458-480L320-240h-92Zm360%200%2092-160q-66%200-113-47t-47-113q0-66%2047-113t113-47q66%200%20113%2047t47%20113q0%2023-5.5%2042.5T818-480L680-240h-92ZM320-500q25%200%2042.5-17.5T380-560q0-25-17.5-42.5T320-620q-25%200-42.5%2017.5T260-560q0%2025%2017.5%2042.5T320-500Zm360%200q25%200%2042.5-17.5T740-560q0-25-17.5-42.5T680-620q-25%200-42.5%2017.5T620-560q0%2025%2017.5%2042.5T680-500Zm0-60Zm-360%200Z'/%3e%3c/svg%3e",mT="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M200-280v-400h80v160h160v-160h80v400h-80v-160H280v160h-80Zm480%200v-320h-80v-80h160v400h-80Z'/%3e%3c/svg%3e",gT="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M120-280v-400h80v160h160v-160h80v400h-80v-160H200v160h-80Zm400%200v-160q0-33%2023.5-56.5T600-520h160v-80H520v-80h240q33%200%2056.5%2023.5T840-600v80q0%2033-23.5%2056.5T760-440H600v80h240v80H520Z'/%3e%3c/svg%3e",yT="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M120-280v-400h80v160h160v-160h80v400h-80v-160H200v160h-80Zm400%200v-80h240v-80H600v-80h160v-80H520v-80h240q33%200%2056.5%2023.5T840-600v240q0%2033-23.5%2056.5T760-280H520Z'/%3e%3c/svg%3e",bT="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M680-360q-17%200-28.5-11.5T640-400v-160q0-17%2011.5-28.5T680-600h120q17%200%2028.5%2011.5T840-560v40h-60v-20h-80v120h80v-20h60v40q0%2017-11.5%2028.5T800-360H680Zm-300%200v-240h160q17%200%2028.5%2011.5T580-560v40q0%2017-11.5%2028.5T540-480q17%200%2028.5%2011.5T580-440v40q0%2017-11.5%2028.5T540-360H380Zm60-150h80v-30h-80v30Zm0%2090h80v-30h-80v30Zm-320%2060v-200q0-17%2011.5-28.5T160-600h120q17%200%2028.5%2011.5T320-560v200h-60v-60h-80v60h-60Zm60-120h80v-60h-80v60Z'/%3e%3c/svg%3e",vT="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M544-400%20440-504%20240-304l104%20104%20200-200Zm-47-161%20104%20104%20199-199-104-104-199%20199Zm-84-28%20216%20216-229%20229q-24%2024-56%2024t-56-24l-2-2-26%2026H60l126-126-2-2q-24-24-24-56t24-56l229-229Zm0%200%20227-227q24-24%2056-24t56%2024l104%20104q24%2024%2024%2056t-24%2056L629-373%20413-589Z'/%3e%3c/svg%3e",wT="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3cpath%20fill='currentColor'%20d='M19%205v14H5V5h14m0-2H5c-1.1%200-2%20.9-2%202v14c0%201.1.9%202%202%202h14c1.1%200%202-.9%202-2V5c0-1.1-.9-2-2-2zm-4.86%208.86l-3%203.87L9%2013.14L6%2017h12l-3.86-5.14z'/%3e%3c/svg%3e",$l=new We("upload-image"),CT=()=>new je({key:$l,state:{init(){return He.empty},apply(n,e){e=e.map(n.mapping,n.doc);const t=n.getMeta(this);if(t&&t.add){const{id:r,pos:i,src:s}=t.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(n.doc,[a])}else t&&t.remove&&(e=e.remove(e.find(void 0,void 0,r=>r.id==t.remove.id)));return e}},props:{decorations(n){return this.getState(n)}}});function xT(n,e){const r=$l.getState(n).find(null,null,i=>i.id==e);return r.length?r[0].from:null}function y0(n,e,t){if(n.type.includes("image/")){if(n.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(n),s.onload=()=>{i.setMeta($l,{add:{id:r,pos:t,src:s.result}}),e.dispatch(i)},kT(n).then(o=>{const{schema:l}=e.state,a=xT(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($l,{remove:{id:r}});e.dispatch(d)})}const kT=n=>new Promise(e=>{const t=new FileReader;t.readAsDataURL(n),t.onload=()=>e(t.result)}),ST=async n=>{const e=new FileReader;if(e.readAsDataURL(n),n.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)}})},b0=({editor:n})=>{const{ref:e,toolVisibilty:t,setToolVisibility:r}=cT(Te.NONE);return{toolbar:[{icon:dT,title:"Font",onClick:()=>r(Te.FONT_FAMILY),isActive:t===Te.FONT_FAMILY},{icon:hT,title:"Text Color",onClick:()=>r(Te.TEXT_COLOR),isActive:t===Te.TEXT_COLOR},{icon:vT,title:"Highlight",onClick:()=>r(Te.HIGHLIGHT),isActive:t===Te.HIGHLIGHT},null,{icon:Yg,title:"Bold",onClick:()=>n==null?void 0:n.chain().focus().toggleBold().run(),isActive:n==null?void 0:n.isActive("bold")},{icon:Zg,title:"Italic",onClick:()=>n==null?void 0:n.chain().focus().toggleItalic().run(),isActive:n==null?void 0:n.isActive("italic")},{icon:Xg,title:"Underlined",onClick:()=>n==null?void 0:n.chain().focus().toggleUnderline().run(),isActive:n==null?void 0:n.isActive("underline")},{icon:e0,title:"Strikethrough",onClick:()=>n==null?void 0:n.chain().focus().toggleStrike().run(),isActive:n==null?void 0:n.isActive("strike")},null,{icon:g0,title:"List",onClick:()=>r(Te.LIST),isActive:t===Te.LIST},{icon:od,title:"Alignment",onClick:()=>r(Te.ALIGNMENT),isActive:t===Te.ALIGNMENT},{icon:pT,title:"Quote",onClick:()=>n==null?void 0:n.chain().focus().toggleBlockquote().run(),isActive:n==null?void 0:n.isActive("blockquote")},null,{icon:wT,title:"Upload Image",onClick:()=>{n==null||n.chain().focus().deleteRange(n.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=n.view.state.selection.from;y0(l,n.view,a)}},s.click()},isActive:!1},{icon:t0,title:"Link",onClick:()=>r(Te.LINK),isActive:n==null?void 0:n.isActive("link")},{icon:Qg,title:"Code",onClick:()=>n==null?void 0:n.chain().focus().toggleCodeBlock().run(),isActive:n==null?void 0:n.isActive("codeBlock")}],toolRef:e,toolVisibilty:t,setToolVisibility:r}},ET=({editor:n,setVisibility:e,elementRef:t})=>{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 D.jsxs("div",{ref:t,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-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all",children:[D.jsx(r0,{className:"cursor-pointer",onClick:()=>{n.chain().focus().unsetHighlight().run(),e(Te.NONE)}}),r.map(i=>D.jsx("div",{onClick:()=>{n.chain().focus().toggleHighlight({color:i.color}).run(),e(Te.NONE)},className:`w-6 ${i.code} drop-shadow rounded-full flex items-center justify-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6`,children:D.jsx(Bl,{size:14,className:`${n.isActive("highlight",{color:i.color})?"visible":"invisible"}`})},i.color))]})},TT=({elementRef:n,editor:e,setToolVisibility:t})=>{const r=[{title:"Trebuchet MS",command:i=>{i.chain().focus().setFontFamily("Trebuchet MS, sans-serif").run()}},{title:"Verdana",command:i=>{i.chain().focus().setFontFamily("Verdana, Geneva, sans-serif").run()}},{title:"Georgia",command:i=>{i.chain().focus().setFontFamily("Georgia, serif").run()}},{title:"Arial",command:i=>{i.chain().focus().setFontFamily("Arial, Helvetica, sans-serif").run()}},{title:"Comic Sans MS",command:i=>{i.chain().focus().setFontFamily("Comic Sans MS, Comic Sans").run()}},{title:"Impact",command:i=>{i.chain().focus().setFontFamily("Impact, Charcoal, sans-serif").run()}},{title:"Palatino",command:i=>{i.chain().focus().setFontFamily("Palatino Linotype, Book Antiqua, Palatino, serif").run()}},{title:"Lucida Grande",command:i=>{i.chain().focus().setFontFamily("Lucida Sans Unicode, Lucida Grande, sans-serif").run()}},{title:"Serif",command:i=>{i.chain().focus().setFontFamily("serif").run()}},{title:"Monospace",command:i=>{i.chain().focus().setFontFamily("monospace").run()}},{title:"Cursive",command:i=>{i.chain().focus().setFontFamily("cursive").run()}}];return D.jsx("div",{ref:n,className:Fe("z-50 h-auto absolute top-[50px] left-[20%] max-h-[330px] w-48 overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all"),children:r.map(i=>D.jsx("button",{onClick:()=>{i.command(e),t(Te.NONE)},style:{fontFamily:i.title},className:`flex w-full ${e.isActive("textStyle",{fontFamily:i.title})?"bg-red-500":""} items-center space-x-2 rounded-md px-2 py-1 text-left text-sm text-stone-900 hover:bg-stone-100`,children:D.jsx("p",{className:"font-medium",children:i.title})},i.title))})},AT=({elementRef:n,editor:e,setToolVisibility:t})=>D.jsxs("div",{ref:n,className:Fe("z-50 h-auto absolute gap-2 top-[50px] right-[25%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all"),children:[D.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("left").run(),t(Te.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive({textAlign:"left"})&&"bg-[#f2f2f2]"} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:D.jsx("img",{src:od,alt:"align left"})}),D.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("center").run(),t(Te.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive({textAlign:"center"})&&"bg-[#f2f2f2]"} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:D.jsx("img",{src:p0,alt:"align center"})}),D.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("right").run(),t(Te.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive({textAlign:"right"})&&"bg-[#f2f2f2]"} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:D.jsx("img",{src:m0,alt:"align right"})})]}),MT=({elementRef:n,editor:e,setToolVisibility:t})=>D.jsxs("div",{ref:n,className:Fe("z-50 h-auto absolute gap-2 top-[50px] right-[30%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all"),children:[D.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"unordered list",children:D.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleBulletList().run(),t(Te.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("bulletList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:D.jsx("img",{src:g0,alt:"bullet list"})})}),D.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"ordered list",children:D.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleOrderedList().run(),t(Te.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("orderedList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:D.jsx("img",{src:fT,alt:"numbered list"})})}),D.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"to-do list",children:D.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleTaskList().run(),t(Te.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("taskList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:D.jsx("img",{src:uT,alt:"checklist"})})})]}),v0=({elementRef:n,editor:e,setToolVisibility:t,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(),t(Te.NONE),r&&i&&i(!1)};return D.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-[50px] items-center flex right-[10%] max-h-[330px] overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white p-2 shadow-md transition-all",children:[D.jsx("input",{onChange:a=>o(a.target.value),className:"border-2 focus:border-black px-2 py-1.5 rounded w-full font-medium text-sm",placeholder:"Add link here",value:s}),D.jsx("div",{className:"h-full flex items-center",children:D.jsx("button",{onClick:()=>l(),className:"min-w-fit",children:"Apply"})})]})},OT=({editor:n,setVisibility:e,elementRef:t})=>{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 D.jsxs("div",{ref:t,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-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all",children:[D.jsx(r0,{className:"cursor-pointer",onClick:()=>{n.chain().focus().unsetColor().run(),e(Te.NONE)}}),r.map(i=>D.jsx("div",{onClick:()=>{n.chain().focus().setColor(i.color).run(),e(Te.NONE)},className:`w-6 ${i.code} drop-shadow rounded-full flex justify-center items-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6`,children:D.jsx(Bl,{size:14,className:`${n.isActive("textStyle",{color:i.color})?"visible":"invisible"}`})},i.color))]})},_T=({editor:n,setVisibility:e,elementRef:t})=>{const r=[{title:"Text",description:"Normal",icon:bT,command:i=>i.chain().focus().toggleNode("paragraph","paragraph").run()},{title:"Heading 1",description:"Big",icon:mT,command:i=>{i.chain().focus().toggleHeading({level:1}).run()}},{title:"Heading 2",description:"Medium",icon:gT,command:i=>{i.chain().focus().toggleHeading({level:2}).run()}},{title:"Heading 3",description:"Small",icon:yT,command:i=>{i.chain().focus().toggleHeading({level:3}).run()}}];return D.jsx("section",{ref:t,className:Fe(" absolute top-[50px] z-50 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","left-0"),children:r.map(i=>D.jsxs("button",{onClick:()=>{i.command(n),e(Te.NONE)},className:"flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm text-stone-900 hover:bg-stone-100",children:[D.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border border-stone-200 bg-white",children:D.jsx("img",{src:i.icon,alt:i.title})}),D.jsxs("div",{children:[D.jsx("p",{className:"font-medium",children:i.title}),D.jsxs("p",{className:"text-xs text-stone-500",children:[" ",i.description," "]})]})]},i.title))})},NT=n=>{const e=[{name:"bold",isActive:()=>n.editor.isActive("bold"),command:()=>n.editor.chain().focus().toggleBold().run(),icon:Yg},{name:"italic",isActive:()=>n.editor.isActive("italic"),command:()=>n.editor.chain().focus().toggleItalic().run(),icon:Zg},{name:"underline",isActive:()=>n.editor.isActive("underline"),command:()=>n.editor.chain().focus().toggleUnderline().run(),icon:Xg},{name:"strike",isActive:()=>n.editor.isActive("strike"),command:()=>n.editor.chain().focus().toggleStrike().run(),icon:e0},{name:"codeBlock",isActive:()=>n.editor.isActive("codeBlock"),command:()=>n.editor.chain().focus().toggleCodeBlock().run(),icon:Qg},{name:"link",isActive:()=>n.editor.isActive("link"),command:()=>a(!l),icon:t0}],t={...n,shouldShow:({state:d,editor:f})=>{const{selection:h}=d,{empty:p}=h;return!(f.isActive("image")||p||Qm(h))},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}=b0({editor:n.editor});return D.jsxs(Ug,{...t,className:"flex gap-1 overflow-hidden rounded border border-stone-200 bg-white shadow-xl",children:[D.jsx(lT,{editor:n.editor,isOpen:r,setIsOpen:()=>{i(!r),o(!1)}}),e.map((d,f)=>D.jsx("button",{onClick:d.command,className:" py-2 text-stone-600 hover:bg-stone-100 active:bg-stone-200",children:D.jsx("img",{src:d.icon,className:Fe(" p-1 rounded-lg h-6 w-6",{"bg-yellow-300":d.isActive()})})},f)),D.jsx(aT,{editor:n.editor,isOpen:s,setIsOpen:()=>{o(!s),i(!1)}}),l&&D.jsx(v0,{setToolVisibility:u,editor:n.editor,elementRef:c,bubbleMenu:!0,setIsLinkPopupOpen:a})]})};function DT(){const n=["a","b","c","d","e","f","0","1","2","3","4","5","6","7","8","9"];let e=[];for(let t=0;t<36;t++)t===8||t===13||t===18||t===23?e[t]="-":e[t]=n[Math.ceil(Math.random()*n.length-1)];return e.join("")}var RT=DT;const LT=Nc(RT),w0=Ve.create({name:"column",content:"dBlock+",isolating:!0,addAttributes(){return{position:{default:"",parseHTML:n=>n.getAttribute("data-position"),renderHTML:n=>({"data-position":n.position})}}},renderHTML({HTMLAttributes:n}){return["div",Ce(n,{"data-type":"column"}),0]},parseHTML(){return[{tag:'div[data-type="column"]'}]}}),IT=(n,e)=>Array.from({length:n},(t,r)=>e(r)),jl=({type:n,content:e})=>e?{type:n,content:e}:{type:n},PT=({content:n})=>jl({type:"paragraph",content:n}),C0=({content:n})=>jl({type:"dBlock",content:n}),x0=({content:n})=>jl({type:"column",content:n}),k0=({content:n})=>jl({type:"columns",content:n}),S0=n=>{const e=[C0({content:[PT({})]})];return IT(n,()=>x0({content:e}))},E0=(n,e)=>{for(let t=n.depth;t>0;t--){const r=n.node(t),i=t>0?n.before(t):0,s=n.start(t);if(e({node:r,pos:i,start:s}))return{start:s,depth:t,node:r,pos:i}}throw Error("no ancestor found")};class Hl extends ue{constructor(t){const{$from:r,$to:i}=t;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(t){return t instanceof Hl&&t.anchor==this.anchor}toJSON(){return{type:"column",from:this.from,to:this.to}}expandSelection(t){var a;const r=({pos:c,node:u})=>u.type.name===w0.name?!0:t.resolve(c).depth<=0,{pos:i}=E0(this.$from,r);this._$from=t.resolve(i);const{pos:s,node:o}=E0(this.$to,r);this._$to=t.resolve(s+o.nodeSize),((a=this.getFirstNode())==null?void 0:a.type.name)===Vl.name&&(this._$from=t.resolve(this.$from.pos+2),this._$to=t.resolve(this.$to.pos+2));const l=this;l.$anchor=this._$from,l.$head=this._$to,l.ranges=[new Jc(this._$from,this._$to)]}static create(t,r,i){const s=t.resolve(r),o=t.resolve(i),l=new ce(s,o);return new Hl(l)}getFirstNode(){return this.content().content.firstChild}}var pi=(n=>(n.AlignLeft="align-left",n.AlignRight="align-right",n.AlignCenter="align-center",n))(pi||{});const Vl=Ve.create({name:"columns",group:"columns",content:"column{2,}",defining:!0,draggable:!0,isolating:!0,addAttributes(){return{layout:{default:"align-center"}}},addCommands(){return{unsetColumns:()=>({tr:n,dispatch:e})=>{try{if(!e)return;const t=n.selection.$from,i=Ru(t,({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)===Vl.name&&s.push(a)}),s=s.reverse().filter(a=>a.content.size>0);const o=n.doc.resolve(i.pos),l=new se(o);return n=n.setSelection(l),s.forEach(a=>n=n.insert(i.pos,a)),n=n.deleteSelection(),e(n)}catch(t){console.error(t)}},setColumns:(n,e=!1)=>({tr:t,dispatch:r})=>{try{const{doc:i,selection:s}=t;if(!r){console.log("no dispatch");return}const o=new Hl(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=x0(h),g=S0(n-1);c=k0({content:[p,...g]})}else{const h=S0(n);c=k0({content:h})}const u=i.type.schema.nodeFromJSON(C0({content:[c]}));if(u===null)return;const d=o.$anchor.parent.type;if(!(h=>!(!h.contentMatch.matchType(this.type)||!this.options.nestedColumns&&h.name===Vl.name))(d)){console.warn("content not allowed");return}return t=t.setSelection(o),t=t.replaceSelectionWith(u,!1),r(t)}catch(i){console.error(i)}},setLayout:n=>({commands:e})=>e.updateAttributes("columns",{layout:n})}},renderHTML({HTMLAttributes:n}){return["div",{"data-type":"columns",class:`layout-${n.layout}`},0]},parseHTML(){return[{tag:'div[data-type="columns"]'}]}}),FT=(n,e)=>{const{view:t,state:{selection:{from:r}}}=n,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=t.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},ld=O.forwardRef(({children:n,className:e,withShadow:t=!0,withBorder:r=!0,...i},s)=>{const o=Fe(e,"bg-white rounded-md",t?"shadow-md":"",r?"border border-neutral-200":"");return D.jsx("div",{className:o,...i,ref:s,children:n})});ld.displayName="Surface";const zl=O.forwardRef(({active:n,buttonSize:e="medium",children:t,disabled:r,variant:i="primary",className:s,activeClassname:o,...l},a)=>{const c=Fe("flex group items-center justify-center border border-transparent gap-2 text-sm font-semibold rounded-md disabled:opacity-50 whitespace-nowrap",i==="primary"&&Fe("text-white bg-black border-black dark:text-black dark:bg-white dark:border-white",!r&&!n&&"hover:bg-neutral-800 active:bg-neutral-900 dark:hover:bg-neutral-200 dark:active:bg-neutral-300",n&&Fe("bg-neutral-900 dark:bg-neutral-300",o)),i==="secondary"&&Fe("text-neutral-900 dark:text-white",!r&&!n&&"hover:bg-neutral-100 active:bg-neutral-200 dark:hover:bg-neutral-900 dark:active:bg-neutral-800",n&&"bg-neutral-200 dark:bg-neutral-800"),i==="tertiary"&&Fe("bg-neutral-50 text-neutral-900 dark:bg-neutral-900 dark:text-white dark:border-neutral-900",!r&&!n&&"hover:bg-neutral-100 active:bg-neutral-200 dark:hover:bg-neutral-800 dark:active:bg-neutral-700",n&&Fe("bg-neutral-200 dark:bg-neutral-800",o)),i==="ghost"&&Fe("bg-transparent border-transparent text-neutral-500",!r&&!n&&"hover:bg-black/5 hover:text-neutral-700 active:bg-black/10 active:text-neutral-800 ",n&&Fe("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 D.jsx("button",{ref:a,disabled:r,className:c,...l,children:t})});zl.displayName="Button";const T0=({content:n,children:e})=>{const[t,r]=O.useState(!1);return D.jsxs("div",{className:"relative inline-block",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[e,t&&D.jsx("div",{className:"absolute z-10 p-2 mt-2 text-sm text-white bg-gray-800 rounded shadow-lg",children:n})]})},A0=O.forwardRef(({shouldShowContent:n=!0,children:e,isVertical:t=!1,className:r,...i},s)=>{const o=Fe("text-black inline-flex h-full leading-none gap-0.5",t?"flex-col p-2":"flex-row p-1 items-center",r);return n?n&&D.jsx(ld,{className:o,...i,ref:s,children:e}):null});A0.displayName="Toolbar";const M0=O.forwardRef(({horizontal:n,className:e,...t},r)=>{const i=Fe("bg-neutral-200",n?"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 D.jsx("div",{className:i,ref:r,...t})});M0.displayName="Toolbar.Divider";const O0=O.forwardRef(({children:n,buttonSize:e="icon",variant:t="ghost",className:r,tooltip:i,activeClassname:s,...o},l)=>{const a=Fe("gap-1 min-w-[2rem] px-2 w-auto",r),c=D.jsx(zl,{activeClassname:s,className:a,variant:t,buttonSize:e,ref:l,...o,children:n});return i?D.jsx(T0,{content:i,children:c}):c});O0.displayName="ToolbarButton";const vo={Wrapper:A0,Divider:M0,Button:O0},BT=({editor:n,appendTo:e})=>{const t=O.useCallback(()=>{const l=FT(n,"columns");return(l==null?void 0:l.getBoundingClientRect())||new DOMRect(-1e3,-1e3,0,0)},[n]),r=O.useCallback(()=>n.isActive("columns"),[n]),i=O.useCallback(()=>{n.chain().focus().setLayout(pi.AlignLeft).run()},[n]),s=O.useCallback(()=>{n.chain().focus().setLayout(pi.AlignRight).run()},[n]),o=O.useCallback(()=>{n.chain().focus().setLayout(pi.AlignCenter).run()},[n]);return D.jsx(Ug,{editor:n,pluginKey:`columnsMenu-${LT()}`,shouldShow:r,updateDelay:0,tippyOptions:{offset:[0,8],popperOptions:{modifiers:[{name:"flip",enabled:!1}]},getReferenceClientRect:t,moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",appendTo:()=>e==null?void 0:e.current,plugins:[OE],sticky:"popper"},children:D.jsxs(vo.Wrapper,{children:[D.jsx(vo.Button,{tooltip:"Align left",active:n.isActive("columns",{layout:pi.AlignLeft}),onClick:i,children:D.jsx(eT,{size:20})}),D.jsx(vo.Button,{tooltip:"Align center",active:n.isActive("columns",{layout:pi.AlignCenter}),onClick:o,children:D.jsx(s0,{size:20})}),D.jsx(vo.Button,{tooltip:"Align right",active:n.isActive("columns",{layout:pi.AlignRight}),onClick:s,children:D.jsx(tT,{size:20})})]})})},_0=O.createContext(null),Ul=()=>O.useContext(_0),$T=({children:n,isPreviewMode:e})=>D.jsx(_0.Provider,{value:e,children:n}),N0=({height:n,width:e})=>D.jsx("span",{className:"flex items-center justify-center ",children:D.jsx("span",{className:`${e?`w-${e}`:"w-8"} ${n?`h-${n}`:"h-8"} border-4 border-t-4 border-t-[#ccc] border-gray-500 rounded-full animate-spin`})}),jT=({editor:n})=>{const{toolRef:e,toolVisibilty:t,setToolVisibility:r,toolbar:i}=b0({editor:n});return D.jsxs("div",{className:"w-fit bg-transparent px-4 items-center rounded-lg h-16 flex gap-1 justify-center",children:[D.jsxs("button",{className:"hover:bg-[#f2f2f2] border gap-2 rounded-lg w-28 h-8 p-1 flex justify-center items-center",onClick:()=>r(Te.HEADING),children:[D.jsx("span",{className:"text-sm",children:n!=null&&n.isActive("heading",{level:1})?"Heading 1":n!=null&&n.isActive("heading",{level:2})?"Heading 2":n!=null&&n.isActive("heading",{level:3})?"Heading 3":"Text"}),D.jsx(id,{className:"h-4 w-4"})]}),i.map((s,o)=>s?D.jsx("div",{className:"tooltip tooltip-bottom","data-tip":s.title,children:D.jsx("span",{onClick:()=>s.onClick(),className:Fe("rounded-lg w-8 h-8 p-1 flex cursor-pointer justify-center items-center",s.isActive?"bg-yellow-300":"hover:bg-[#f2f2f2]"),children:typeof s.icon=="string"?D.jsx("img",{src:s.icon,className:"w-4"}):s.icon})},s.title):D.jsx("div",{className:" w-[1px] h-[50%] bg-[#777777]"},o)),t===Te.HEADING&&D.jsx(_T,{setVisibility:r,editor:n,elementRef:e}),t===Te.TEXT_COLOR&&D.jsx(OT,{setVisibility:r,editor:n,elementRef:e}),t===Te.HIGHLIGHT&&D.jsx(ET,{setVisibility:r,editor:n,elementRef:e}),t===Te.FONT_FAMILY&&D.jsx(TT,{setToolVisibility:r,editor:n,elementRef:e}),t===Te.ALIGNMENT&&D.jsx(AT,{setToolVisibility:r,editor:n,elementRef:e}),t===Te.LIST&&D.jsx(MT,{setToolVisibility:r,editor:n,elementRef:e}),t===Te.LINK&&D.jsx(v0,{setToolVisibility:r,editor:n,elementRef:e})]})},Lt=()=>new Map,ad=n=>{const e=Lt();return n.forEach((t,r)=>{e.set(r,t)}),e},zt=(n,e,t)=>{let r=n.get(e);return r===void 0&&n.set(e,r=t()),r},HT=(n,e)=>{const t=[];for(const[r,i]of n)t.push(e(i,r));return t},VT=(n,e)=>{for(const[t,r]of n)if(e(r,t))return!0;return!1},or=()=>new Set,cd=n=>n[n.length-1],zT=(n,e)=>{for(let t=0;t<e.length;t++)n.push(e[t])},lr=Array.from,UT=(n,e)=>{for(let t=0;t<n.length;t++)if(e(n[t],t,n))return!0;return!1},ud=Array.isArray;class dd{constructor(){this._observers=Lt()}on(e,t){return zt(this._observers,e,or).add(t),t}once(e,t){const r=(...i)=>{this.off(e,r),t(...i)};this.on(e,r)}off(e,t){const r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return lr((this._observers.get(e)||Lt()).values()).forEach(r=>r(...t))}destroy(){this._observers=Lt()}}class D0{constructor(){this._observers=Lt()}on(e,t){zt(this._observers,e,or).add(t)}once(e,t){const r=(...i)=>{this.off(e,r),t(...i)};this.on(e,r)}off(e,t){const r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return lr((this._observers.get(e)||Lt()).values()).forEach(r=>r(...t))}destroy(){this._observers=Lt()}}const wn=Math.floor,Wl=Math.abs,WT=Math.log10,Ir=(n,e)=>n<e?n:e,ar=(n,e)=>n>e?n:e,R0=n=>n!==0?n<0:1/n<0,Bn=Date.now,qT=1200,KT=2500,ql=3e4,fd=n=>{if(n.shouldConnect&&n.ws===null){const e=new WebSocket(n.url),t=n.binaryType;let r=null;t&&(e.binaryType=t),n.ws=e,n.connecting=!0,n.connected=!1,e.onmessage=o=>{n.lastMessageReceived=Bn();const l=o.data,a=typeof l=="string"?JSON.parse(l):l;a&&a.type==="pong"&&(clearTimeout(r),r=setTimeout(s,ql/2)),n.emit("message",[a,n])};const i=o=>{n.ws!==null&&(n.ws=null,n.connecting=!1,n.connected?(n.connected=!1,n.emit("disconnect",[{type:"disconnect",error:o},n])):n.unsuccessfulReconnects++,setTimeout(fd,Ir(WT(n.unsuccessfulReconnects+1)*qT,KT),n)),clearTimeout(r)},s=()=>{n.ws===e&&n.send({type:"ping"})};e.onclose=()=>i(null),e.onerror=o=>i(o),e.onopen=()=>{n.lastMessageReceived=Bn(),n.connecting=!1,n.connected=!0,n.unsuccessfulReconnects=0,n.emit("connect",[{type:"connect"},n]),r=setTimeout(s,ql/2)}}};class JT extends D0{constructor(e,{binaryType:t}={}){super(),this.url=e,this.ws=null,this.binaryType=t||null,this.connected=!1,this.connecting=!1,this.unsuccessfulReconnects=0,this.lastMessageReceived=0,this.shouldConnect=!0,this._checkInterval=setInterval(()=>{this.connected&&ql<Bn()-this.lastMessageReceived&&this.ws.close()},ql/2),fd(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&&fd(this)}}const $n=n=>new Error(n),Cn=()=>{throw $n("Method unimplemented")},cn=()=>{throw $n("Unexpected case")},L0=1,I0=2,hd=4,pd=8,wo=32,cr=64,Yt=128,Kl=31,md=63,mi=127,GT=2147483647,YT=crypto.getRandomValues.bind(crypto),P0=Math.random,F0=()=>YT(new Uint32Array(1))[0],ZT=n=>n[wn(P0()*n.length)],XT="10000000-1000-4000-8000"+-1e11,B0=()=>XT.replace(/[018]/g,n=>(n^F0()&15>>n/4).toString(16)),$0=Number.MAX_SAFE_INTEGER,QT=Number.isInteger||(n=>typeof n=="number"&&isFinite(n)&&wn(n)===n),eA=String.fromCharCode,tA=n=>n.toLowerCase(),nA=/^\s*/g,rA=n=>n.replace(nA,""),iA=/([A-Z])/g,j0=(n,e)=>rA(n.replace(iA,t=>`${e}${tA(t)}`)),sA=n=>{const e=unescape(encodeURIComponent(n)),t=e.length,r=new Uint8Array(t);for(let i=0;i<t;i++)r[i]=e.codePointAt(i);return r},Co=typeof TextEncoder<"u"?new TextEncoder:null,gd=Co?n=>Co.encode(n):sA;let xo=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});xo&&xo.decode(new Uint8Array).length===1&&(xo=null);class ko{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const gt=()=>new ko,oA=n=>{let e=n.cpos;for(let t=0;t<n.bufs.length;t++)e+=n.bufs[t].length;return e},qe=n=>{const e=new Uint8Array(oA(n));let t=0;for(let r=0;r<n.bufs.length;r++){const i=n.bufs[r];e.set(i,t),t+=i.length}return e.set(new Uint8Array(n.cbuf.buffer,0,n.cpos),t),e},lA=(n,e)=>{const t=n.cbuf.length;t-n.cpos<e&&(n.bufs.push(new Uint8Array(n.cbuf.buffer,0,n.cpos)),n.cbuf=new Uint8Array(ar(t,e)*2),n.cpos=0)},yt=(n,e)=>{const t=n.cbuf.length;n.cpos===t&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(t*2),n.cpos=0),n.cbuf[n.cpos++]=e},So=yt,ae=(n,e)=>{for(;e>mi;)yt(n,Yt|mi&e),e=wn(e/128);yt(n,mi&e)},yd=(n,e)=>{const t=R0(e);for(t&&(e=-e),yt(n,(e>md?Yt:0)|(t?cr:0)|md&e),e=wn(e/64);e>0;)yt(n,(e>mi?Yt:0)|mi&e),e=wn(e/128)},bd=new Uint8Array(3e4),aA=bd.length/3,cA=(n,e)=>{if(e.length<aA){const t=Co.encodeInto(e,bd).written||0;ae(n,t);for(let r=0;r<t;r++)yt(n,bd[r])}else Xe(n,gd(e))},uA=(n,e)=>{const t=unescape(encodeURIComponent(e)),r=t.length;ae(n,r);for(let i=0;i<r;i++)yt(n,t.codePointAt(i))},jn=Co&&Co.encodeInto?cA:uA,Jl=(n,e)=>{const t=n.cbuf.length,r=n.cpos,i=Ir(t-r,e.length),s=e.length-i;n.cbuf.set(e.subarray(0,i),r),n.cpos+=i,s>0&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(ar(t*2,s)),n.cbuf.set(e.subarray(i)),n.cpos=s)},Xe=(n,e)=>{ae(n,e.byteLength),Jl(n,e)},vd=(n,e)=>{lA(n,e);const t=new DataView(n.cbuf.buffer,n.cpos,e);return n.cpos+=e,t},dA=(n,e)=>vd(n,4).setFloat32(0,e,!1),fA=(n,e)=>vd(n,8).setFloat64(0,e,!1),hA=(n,e)=>vd(n,8).setBigInt64(0,e,!1),H0=new DataView(new ArrayBuffer(4)),pA=n=>(H0.setFloat32(0,n),H0.getFloat32(0)===n),ts=(n,e)=>{switch(typeof e){case"string":yt(n,119),jn(n,e);break;case"number":QT(e)&&Wl(e)<=GT?(yt(n,125),yd(n,e)):pA(e)?(yt(n,124),dA(n,e)):(yt(n,123),fA(n,e));break;case"bigint":yt(n,122),hA(n,e);break;case"object":if(e===null)yt(n,126);else if(ud(e)){yt(n,117),ae(n,e.length);for(let t=0;t<e.length;t++)ts(n,e[t])}else if(e instanceof Uint8Array)yt(n,116),Xe(n,e);else{yt(n,118);const t=Object.keys(e);ae(n,t.length);for(let r=0;r<t.length;r++){const i=t[r];jn(n,i),ts(n,e[i])}}break;case"boolean":yt(n,e?120:121);break;default:yt(n,127)}};class V0 extends ko{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 z0=n=>{n.count>0&&(yd(n.encoder,n.count===1?n.s:-n.s),n.count>1&&ae(n.encoder,n.count-2))};class Gl{constructor(){this.encoder=new ko,this.s=0,this.count=0}write(e){this.s===e?this.count++:(z0(this),this.count=1,this.s=e)}toUint8Array(){return z0(this),qe(this.encoder)}}const U0=n=>{if(n.count>0){const e=n.diff*2+(n.count===1?0:1);yd(n.encoder,e),n.count>1&&ae(n.encoder,n.count-2)}};class wd{constructor(){this.encoder=new ko,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(U0(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return U0(this),qe(this.encoder)}}class mA{constructor(){this.sarr=[],this.s="",this.lensE=new Gl}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 ko;return this.sarr.push(this.s),this.s="",jn(e,this.sarr.join("")),Jl(e,this.lensE.toUint8Array()),qe(e)}}const W0=$n("Unexpected end of array"),q0=$n("Integer out of Range");class Yl{constructor(e){this.arr=e,this.pos=0}}const Hn=n=>new Yl(n),gA=n=>n.pos!==n.arr.length,yA=(n,e)=>{const t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},bt=n=>yA(n,he(n)),gi=n=>n.arr[n.pos++],he=n=>{let e=0,t=1;const r=n.arr.length;for(;n.pos<r;){const i=n.arr[n.pos++];if(e=e+(i&mi)*t,t*=128,i<Yt)return e;if(e>$0)throw q0}throw W0},Cd=n=>{let e=n.arr[n.pos++],t=e&md,r=64;const i=(e&cr)>0?-1:1;if(!(e&Yt))return i*t;const s=n.arr.length;for(;n.pos<s;){if(e=n.arr[n.pos++],t=t+(e&mi)*r,r*=128,e<Yt)return i*t;if(t>$0)throw q0}throw W0},ur=xo?n=>xo.decode(bt(n)):n=>{let e=he(n);if(e===0)return"";{let t=String.fromCodePoint(gi(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(gi(n));else for(;e>0;){const r=e<1e4?e:1e4,i=n.arr.subarray(n.pos,n.pos+r);n.pos+=r,t+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(t))}},xd=(n,e)=>{const t=new DataView(n.arr.buffer,n.arr.byteOffset+n.pos,e);return n.pos+=e,t},bA=[n=>{},n=>null,Cd,n=>xd(n,4).getFloat32(0,!1),n=>xd(n,8).getFloat64(0,!1),n=>xd(n,8).getBigInt64(0,!1),n=>!1,n=>!0,ur,n=>{const e=he(n),t={};for(let r=0;r<e;r++){const i=ur(n);t[i]=ns(n)}return t},n=>{const e=he(n),t=[];for(let r=0;r<e;r++)t.push(ns(n));return t},bt],ns=n=>bA[127-gi(n)](n);class K0 extends Yl{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),gA(this)?this.count=he(this)+1:this.count=-1),this.count--,this.s}}class Zl extends Yl{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Cd(this);const e=R0(this.s);this.count=1,e&&(this.s=-this.s,this.count=he(this)+2)}return this.count--,this.s}}class kd extends Yl{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=Cd(this),t=e&1;this.diff=wn(e/2),this.count=1,t&&(this.count=he(this)+2)}return this.s+=this.diff,this.count--,this.s}}class vA{constructor(e){this.decoder=new Zl(e),this.str=ur(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}const J0=n=>n===void 0?null:n;class wA{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}let G0=new wA,Sd=!0;try{typeof localStorage<"u"&&localStorage&&(G0=localStorage,Sd=!1)}catch{}const Y0=G0,CA=n=>Sd||addEventListener("storage",n),xA=n=>Sd||removeEventListener("storage",n),kA=Object.assign,Ed=Object.keys,SA=(n,e)=>{for(const t in n)e(n[t],t)},Z0=n=>Ed(n).length,X0=n=>Ed(n).length,EA=n=>{for(const e in n)return!1;return!0},TA=(n,e)=>{for(const t in n)if(!e(n[t],t))return!1;return!0},Q0=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),AA=(n,e)=>n===e||X0(n)===X0(e)&&TA(n,(t,r)=>(t!==void 0||Q0(e,r))&&e[r]===t),Td=(n,e,t=0)=>{try{for(;t<n.length;t++)n[t](...e)}finally{t<n.length&&Td(n,e,t+1)}},MA=()=>{},OA=n=>n,_A=(n,e)=>n===e,Eo=(n,e)=>{if(n==null||e==null)return _A(n,e);if(n.constructor!==e.constructor)return!1;if(n===e)return!0;switch(n.constructor){case ArrayBuffer:n=new Uint8Array(n),e=new Uint8Array(e);case Uint8Array:{if(n.byteLength!==e.byteLength)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;break}case Set:{if(n.size!==e.size)return!1;for(const t of n)if(!e.has(t))return!1;break}case Map:{if(n.size!==e.size)return!1;for(const t of n.keys())if(!e.has(t)||!Eo(n.get(t),e.get(t)))return!1;break}case Object:if(Z0(n)!==Z0(e))return!1;for(const t in n)if(!Q0(n,t)||!Eo(n[t],e[t]))return!1;break;case Array:if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!Eo(n[t],e[t]))return!1;break;default:return!1}return!0},NA=(n,e)=>e.includes(n),rs=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Ad=typeof window<"u"&&typeof document<"u"&&!rs;let Vn;const DA=()=>{if(Vn===void 0)if(rs){Vn=Lt();const n=process.argv;let e=null;for(let t=0;t<n.length;t++){const r=n[t];r[0]==="-"?(e!==null&&Vn.set(e,""),e=r):e!==null&&(Vn.set(e,r),e=null)}e!==null&&Vn.set(e,"")}else typeof location=="object"?(Vn=Lt(),(location.search||"?").slice(1).split("&").forEach(n=>{if(n.length!==0){const[e,t]=n.split("=");Vn.set(`--${j0(e,"-")}`,t),Vn.set(`-${j0(e,"-")}`,t)}})):Vn=Lt();return Vn},Md=n=>DA().has(n),Xl=n=>J0(rs?process.env[n.toUpperCase().replaceAll("-","_")]:Y0.getItem(n));(n=>Md("--"+n)||Xl(n)!==null)("production");const ey=rs&&NA(process.env.FORCE_COLOR,["true","1","2"]),RA=!Md("--no-colors")&&(!rs||process.stdout.isTTY||ey)&&(!rs||Md("--color")||ey||Xl("COLORTERM")!==null||(Xl("TERM")||"").includes("color"));class LA{constructor(e,t){this.left=e,this.right=t}}const dr=(n,e)=>new LA(n,e),IA=typeof document<"u"?document:{};typeof DOMParser<"u"&&new DOMParser;const PA=n=>HT(n,(e,t)=>`${t}:${e};`).join(""),FA=JSON.stringify,BA=(n=>class{constructor(t){this._=t}destroy(){n(this._)}})(clearTimeout),Od=(n,e)=>new BA(setTimeout(e,n)),fr=Symbol,un=fr(),yi=fr(),ty=fr(),_d=fr(),ny=fr(),ry=fr(),iy=fr(),Ql=fr(),ea=fr(),$A=n=>{var r;n.length===1&&((r=n[0])==null?void 0:r.constructor)===Function&&(n=n[0]());const e=[];let t=0;for(;t<n.length;t++){const i=n[t];i===void 0||i.constructor===String||i.constructor===Number||i.constructor===Object&&e.push(JSON.stringify(i))}return e},sy=[ny,iy,Ql,ty];let Nd=0,oy=Bn();const jA=(n,e)=>{const t=sy[Nd],r=Xl("log"),i=r!==null&&(r==="*"||r==="true"||new RegExp(r,"gi").test(e));return Nd=(Nd+1)%sy.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-oy;oy=o,n(t,e,ea,...s.map(c=>{switch(c!=null&&c.constructor===Uint8Array&&(c=Array.from(c)),typeof c){case"string":case"symbol":return c;default:return FA(c)}}),t," +"+l+"ms")}:MA},HA={[un]:dr("font-weight","bold"),[yi]:dr("font-weight","normal"),[ty]:dr("color","blue"),[ny]:dr("color","green"),[_d]:dr("color","grey"),[ry]:dr("color","red"),[iy]:dr("color","purple"),[Ql]:dr("color","orange"),[ea]:dr("color","black")},ly=RA?n=>{var o;n.length===1&&((o=n[0])==null?void 0:o.constructor)===Function&&(n=n[0]());const e=[],t=[],r=Lt();let i=[],s=0;for(;s<n.length;s++){const l=n[s],a=HA[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=PA(r);s>0||c.length>0?(e.push("%c"+l),t.push(c)):e.push(l)}else break}}for(s>0&&(i=t,i.unshift(e.join("")));s<n.length;s++){const l=n[s];l instanceof Symbol||i.push(l)}return i}:$A,ay=(...n)=>{console.log(...ly(n)),cy.forEach(e=>e.print(n))},VA=(...n)=>{console.warn(...ly(n)),n.unshift(Ql),cy.forEach(e=>e.print(n))},cy=or(),zA=n=>jA(ay,n),uy=n=>new Promise(n);Promise.all.bind(Promise);const UA=n=>Promise.reject(n),Dd=n=>Promise.resolve(n),dy=n=>new Uint8Array(n),WA=(n,e,t)=>new Uint8Array(n,e,t),qA=n=>new Uint8Array(n),KA=n=>{let e="";for(let t=0;t<n.byteLength;t++)e+=eA(n[t]);return btoa(e)},JA=n=>Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString("base64"),GA=n=>{const e=atob(n),t=dy(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t},YA=n=>{const e=Buffer.from(n,"base64");return WA(e.buffer,e.byteOffset,e.byteLength)},fy=Ad?KA:JA,hy=Ad?GA:YA,ZA=n=>{const e=dy(n.byteLength);return e.set(n),e},py=new Map;class XA{constructor(e){this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&this.onmessage!==null&&this.onmessage({data:hy(t.newValue||"")}),CA(this._onChange)}postMessage(e){Y0.setItem(this.room,fy(qA(e)))}close(){xA(this._onChange)}}const QA=typeof BroadcastChannel>"u"?XA:BroadcastChannel,Rd=n=>zt(py,n,()=>{const e=or(),t=new QA(n);return t.onmessage=r=>e.forEach(i=>i(r.data,"broadcastchannel")),{bc:t,subs:e}}),eM=(n,e)=>(Rd(n).subs.add(e),e),tM=(n,e)=>{const t=Rd(n),r=t.subs.delete(e);return r&&t.subs.size===0&&(t.bc.close(),py.delete(n)),r},nM=(n,e,t=null)=>{const r=Rd(n);r.bc.postMessage(e),r.subs.forEach(i=>i(e,t))},my=()=>{let n=!0;return(e,t)=>{if(n){n=!1;try{e()}finally{n=!0}}else t!==void 0&&t()}},gy=n=>({[Symbol.iterator](){return this},next:n}),rM=(n,e)=>gy(()=>{let t;do t=n.next();while(!t.done&&!e(t.value));return t}),Ld=(n,e)=>gy(()=>{const{done:t,value:r}=n.next();return{done:t,value:t?void 0:e(r)}});class Id{constructor(e,t){this.clock=e,this.len=t}}class is{constructor(){this.clients=new Map}}const Pr=(n,e,t)=>e.clients.forEach((r,i)=>{const s=n.doc.store.clients.get(i);for(let o=0;o<r.length;o++){const l=r[o];Fy(n,s,l.clock,l.len,t)}}),iM=(n,e)=>{let t=0,r=n.length-1;for(;t<=r;){const i=wn((t+r)/2),s=n[i],o=s.clock;if(o<=e){if(e<o+s.len)return i;t=i+1}else r=i-1}return null},ss=(n,e)=>{const t=n.clients.get(e.client);return t!==void 0&&iM(t,e.clock)!==null},Pd=n=>{n.clients.forEach(e=>{e.sort((i,s)=>i.clock-s.clock);let t,r;for(t=1,r=1;t<e.length;t++){const i=e[r-1],s=e[t];i.clock+i.len>=s.clock?i.len=ar(i.len,s.clock+s.len-i.clock):(r<t&&(e[r]=s),r++)}e.length=r})},Fd=n=>{const e=new is;for(let t=0;t<n.length;t++)n[t].clients.forEach((r,i)=>{if(!e.clients.has(i)){const s=r.slice();for(let o=t+1;o<n.length;o++)zT(s,n[o].clients.get(i)||[]);e.clients.set(i,s)}});return Pd(e),e},To=(n,e,t,r)=>{zt(n.clients,e,()=>[]).push(new Id(t,r))},yy=()=>new is,by=n=>{const e=yy();return n.clients.forEach((t,r)=>{const i=[];for(let s=0;s<t.length;s++){const o=t[s];if(o.deleted){const l=o.id.clock;let a=o.length;if(s+1<t.length)for(let c=t[s+1];s+1<t.length&&c.deleted;c=t[++s+1])a+=c.length;i.push(new Id(l,a))}}i.length>0&&e.clients.set(r,i)}),e},ls=(n,e)=>{ae(n.restEncoder,e.clients.size),lr(e.clients.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{n.resetDsCurVal(),ae(n.restEncoder,t);const i=r.length;ae(n.restEncoder,i);for(let s=0;s<i;s++){const o=r[s];n.writeDsClock(o.clock),n.writeDsLen(o.len)}})},Bd=n=>{const e=new is,t=he(n.restDecoder);for(let r=0;r<t;r++){n.resetDsCurVal();const i=he(n.restDecoder),s=he(n.restDecoder);if(s>0){const o=zt(e.clients,i,()=>[]);for(let l=0;l<s;l++)o.push(new Id(n.readDsClock(),n.readDsLen()))}}return e},vy=(n,e,t)=>{const r=new is,i=he(n.restDecoder);for(let s=0;s<i;s++){n.resetDsCurVal();const o=he(n.restDecoder),l=he(n.restDecoder),a=t.clients.get(o)||[],c=rt(t,o);for(let u=0;u<l;u++){const d=n.readDsClock(),f=d+n.readDsLen();if(d<c){c<f&&To(r,o,c,f-c);let h=zn(a,d),p=a[h];for(!p.deleted&&p.id.clock<d&&(a.splice(h+1,0,ha(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,ha(e,p,f-p.id.clock)),p.delete(e))}else To(r,o,d,f-d)}}if(r.clients.size>0){const s=new bi;return ae(s.restEncoder,0),ls(s,r),s.toUint8Array()}return null},wy=F0;class as extends dd{constructor({guid:e=B0(),collectionid:t=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=wy(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Ly,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=uy(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const a=()=>uy(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&&Be(e.parent.doc,t=>{t.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,t=null){return Be(this,e,t)}get(e,t=Et){const r=zt(this.share,e,()=>{const s=new t;return s._integrate(this,null),s}),i=r.constructor;if(t!==Et&&i!==t)if(i===Et){const s=new t;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,hs)}getText(e=""){return this.get(e,wi)}getMap(e=""){return this.get(e,ps)}getXmlElement(e=""){return this.get(e,It)}getXmlFragment(e=""){return this.get(e,Ci)}toJSON(){const e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON()}),e}destroy(){lr(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(e!==null){this._item=null;const t=e.content;t.doc=new as({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,Be(e.parent.doc,r=>{const i=t.doc;e.deleted||r.subdocsAdded.add(i),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class Cy{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return he(this.restDecoder)}readDsLen(){return he(this.restDecoder)}}class xy extends Cy{readLeftID(){return pe(he(this.restDecoder),he(this.restDecoder))}readRightID(){return pe(he(this.restDecoder),he(this.restDecoder))}readClient(){return he(this.restDecoder)}readInfo(){return gi(this.restDecoder)}readString(){return ur(this.restDecoder)}readParentInfo(){return he(this.restDecoder)===1}readTypeRef(){return he(this.restDecoder)}readLen(){return he(this.restDecoder)}readAny(){return ns(this.restDecoder)}readBuf(){return ZA(bt(this.restDecoder))}readJSON(){return JSON.parse(ur(this.restDecoder))}readKey(){return ur(this.restDecoder)}}class sM{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=he(this.restDecoder),this.dsCurrVal}readDsLen(){const e=he(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class cs extends sM{constructor(e){super(e),this.keys=[],he(e),this.keyClockDecoder=new kd(bt(e)),this.clientDecoder=new Zl(bt(e)),this.leftClockDecoder=new kd(bt(e)),this.rightClockDecoder=new kd(bt(e)),this.infoDecoder=new K0(bt(e),gi),this.stringDecoder=new vA(bt(e)),this.parentInfoDecoder=new K0(bt(e),gi),this.typeRefDecoder=new Zl(bt(e)),this.lenDecoder=new Zl(bt(e))}readLeftID(){return new us(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new us(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 ns(this.restDecoder)}readBuf(){return bt(this.restDecoder)}readJSON(){return ns(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const t=this.stringDecoder.read();return this.keys.push(t),t}}}class ky{constructor(){this.restEncoder=gt()}toUint8Array(){return qe(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){ae(this.restEncoder,e)}writeDsLen(e){ae(this.restEncoder,e)}}class Ao extends ky{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){So(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){ts(this.restEncoder,e)}writeBuf(e){Xe(this.restEncoder,e)}writeJSON(e){jn(this.restEncoder,JSON.stringify(e))}writeKey(e){jn(this.restEncoder,e)}}class Sy{constructor(){this.restEncoder=gt(),this.dsCurrVal=0}toUint8Array(){return qe(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,ae(this.restEncoder,t)}writeDsLen(e){e===0&&cn(),ae(this.restEncoder,e-1),this.dsCurrVal+=e}}class bi extends Sy{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new wd,this.clientEncoder=new Gl,this.leftClockEncoder=new wd,this.rightClockEncoder=new wd,this.infoEncoder=new V0(So),this.stringEncoder=new mA,this.parentInfoEncoder=new V0(So),this.typeRefEncoder=new Gl,this.lenEncoder=new Gl}toUint8Array(){const e=gt();return ae(e,0),Xe(e,this.keyClockEncoder.toUint8Array()),Xe(e,this.clientEncoder.toUint8Array()),Xe(e,this.leftClockEncoder.toUint8Array()),Xe(e,this.rightClockEncoder.toUint8Array()),Xe(e,qe(this.infoEncoder)),Xe(e,this.stringEncoder.toUint8Array()),Xe(e,qe(this.parentInfoEncoder)),Xe(e,this.typeRefEncoder.toUint8Array()),Xe(e,this.lenEncoder.toUint8Array()),Jl(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){ts(this.restEncoder,e)}writeBuf(e){Xe(this.restEncoder,e)}writeJSON(e){ts(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}}const oM=(n,e,t,r)=>{r=ar(r,e[0].id.clock);const i=zn(e,r);ae(n.restEncoder,e.length-i),n.writeClient(t),ae(n.restEncoder,r);const s=e[i];s.write(n,r-s.id.clock);for(let o=i+1;o<e.length;o++)e[o].write(n,0)},$d=(n,e,t)=>{const r=new Map;t.forEach((i,s)=>{rt(e,s)>i&&r.set(s,i)}),Do(e).forEach((i,s)=>{t.has(s)||r.set(s,0)}),ae(n.restEncoder,r.size),lr(r.entries()).sort((i,s)=>s[0]-i[0]).forEach(([i,s])=>{oM(n,e.clients.get(i),i,s)})},lM=(n,e)=>{const t=Lt(),r=he(n.restDecoder);for(let i=0;i<r;i++){const s=he(n.restDecoder),o=new Array(s),l=n.readClient();let a=he(n.restDecoder);t.set(l,{i:0,refs:o});for(let c=0;c<s;c++){const u=n.readInfo();switch(Kl&u){case 0:{const d=n.readLen();o[c]=new dn(pe(l,a),d),a+=d;break}case 10:{const d=he(n.restDecoder);o[c]=new fn(pe(l,a),d),a+=d;break}default:{const d=(u&(cr|Yt))===0,f=new ze(pe(l,a),null,(u&Yt)===Yt?n.readLeftID():null,null,(u&cr)===cr?n.readRightID():null,d?n.readParentInfo()?e.get(n.readString()):n.readLeftID():null,d&&(u&wo)===wo?n.readString():null,pb(n,u));o[c]=f,a+=f.length}}}}return t},aM=(n,e,t)=>{const r=[];let i=lr(t.keys()).sort((h,p)=>h-p);if(i.length===0)return null;const s=()=>{if(i.length===0)return null;let h=t.get(i[i.length-1]);for(;h.refs.length===h.i;)if(i.pop(),i.length>0)h=t.get(i[i.length-1]);else return null;return h};let o=s();if(o===null)return null;const l=new Ly,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=t.get(p);g?(g.i--,l.clients.set(p,g.refs.slice(g.i)),t.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=zt(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(n,e);if(g!==null){r.push(u);const v=t.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(n,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 $d(h,l,new Map),ae(h.restEncoder,0),{missing:a,update:h.toUint8Array()}}return null},cM=(n,e)=>$d(n,e.doc.store,e.beforeState),uM=(n,e,t,r=new cs(n))=>Be(e,i=>{i.local=!1;let s=!1;const o=i.doc,l=o.store,a=lM(r,o),c=aM(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=ra([u.update,c.update])}}else l.pendingStructs=c;const d=vy(r,i,l);if(l.pendingDs){const f=new cs(Hn(l.pendingDs));he(f.restDecoder);const h=vy(f,i,l);d&&h?l.pendingDs=ra([d,h]):l.pendingDs=d||h}else l.pendingDs=d;if(s){const f=l.pendingStructs.update;l.pendingStructs=null,Ey(i.doc,f)}},t,!1),Ey=(n,e,t,r=cs)=>{const i=Hn(e);uM(i,n,t,new r(i))},dM=(n,e,t)=>Ey(n,e,t,xy),fM=(n,e,t=new Map)=>{$d(n,e.store,t),ls(n,by(e.store))},hM=(n,e=new Uint8Array([0]),t=new bi)=>{const r=Ty(e);fM(t,n,r);const i=[t.toUint8Array()];if(n.store.pendingDs&&i.push(n.store.pendingDs),n.store.pendingStructs&&i.push(DM(n.store.pendingStructs.update,e)),i.length>1){if(t.constructor===Ao)return _M(i.map((s,o)=>o===0?s:LM(s)));if(t.constructor===bi)return ra(i)}return i[0]},pM=(n,e)=>hM(n,e,new Ao),mM=n=>{const e=new Map,t=he(n.restDecoder);for(let r=0;r<t;r++){const i=he(n.restDecoder),s=he(n.restDecoder);e.set(i,s)}return e},Ty=n=>mM(new Cy(Hn(n))),Ay=(n,e)=>(ae(n.restEncoder,e.size),lr(e.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{ae(n.restEncoder,t),ae(n.restEncoder,r)}),n),gM=(n,e)=>Ay(n,Do(e.store)),yM=(n,e=new Sy)=>(n instanceof Map?Ay(e,n):gM(e,n),e.toUint8Array()),bM=n=>yM(n,new ky);class vM{constructor(){this.l=[]}}const My=()=>new vM,Oy=(n,e)=>n.l.push(e),_y=(n,e)=>{const t=n.l,r=t.length;n.l=t.filter(i=>e!==i),r===n.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},Ny=(n,e,t)=>Td(n.l,[e,t]);class us{constructor(e,t){this.client=e,this.clock=t}}const ds=(n,e)=>n===e||n!==null&&e!==null&&n.client===e.client&&n.clock===e.clock,pe=(n,e)=>new us(n,e),Mo=n=>{for(const[e,t]of n.doc.share.entries())if(t===n)return e;throw cn()},Oo=(n,e)=>{for(;e!==null;){if(e.parent===n)return!0;e=e.parent._item}return!1};class _o{constructor(e,t,r,i=0){this.type=e,this.tname=t,this.item=r,this.assoc=i}}const No=n=>new _o(n.type==null?null:pe(n.type.client,n.type.clock),n.tname||null,n.item==null?null:pe(n.item.client,n.item.clock),n.assoc==null?0:n.assoc);class wM{constructor(e,t,r=0){this.type=e,this.index=t,this.assoc=r}}const CM=(n,e,t=0)=>new wM(n,e,t),ta=(n,e,t)=>{let r=null,i=null;return n._item===null?i=Mo(n):r=pe(n._item.id.client,n._item.id.clock),new _o(r,i,e,t)},jd=(n,e,t=0)=>{let r=n._start;if(t<0){if(e===0)return ta(n,null,t);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return ta(n,pe(r.id.client,r.id.clock+e),t);e-=r.length}if(r.right===null&&t<0)return ta(n,r.lastId,t);r=r.right}return ta(n,null,t)},xM=(n,e,t=!0)=>{const r=e.store,i=n.item,s=n.type,o=n.tname,l=n.assoc;let a=null,c=0;if(i!==null){if(rt(r,i.client)<=i.clock)return null;const u=t?ef(r,i):{item:fs(r,i),diff:0},d=u.item;if(!(d instanceof ze))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}=t?ef(r,s):{item:fs(r,s)};if(u instanceof ze&&u.content instanceof kn)a=u.content.type;else return null}else throw cn();l>=0?c=a._length:c=0}return CM(a,c,n.assoc)},Dy=(n,e)=>n===e||n!==null&&e!==null&&n.tname===e.tname&&ds(n.item,e.item)&&ds(n.type,e.type)&&n.assoc===e.assoc;class Hd{constructor(e,t){this.ds=e,this.sv=t}}const Ry=(n,e)=>new Hd(n,e),kM=n=>Ry(by(n.store),Do(n.store)),vi=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&(e.sv.get(n.id.client)||0)>n.id.clock&&!ss(e.ds,n.id),Vd=(n,e)=>{const t=zt(n.meta,Vd,or),r=n.doc.store;t.has(e)||(e.sv.forEach((i,s)=>{i<rt(r,s)&&Ut(n,pe(s,i))}),Pr(n,e.ds,i=>{}),t.add(e))};class Ly{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Do=n=>{const e=new Map;return n.clients.forEach((t,r)=>{const i=t[t.length-1];e.set(r,i.id.clock+i.length)}),e},rt=(n,e)=>{const t=n.clients.get(e);if(t===void 0)return 0;const r=t[t.length-1];return r.id.clock+r.length},Iy=(n,e)=>{let t=n.clients.get(e.id.client);if(t===void 0)t=[],n.clients.set(e.id.client,t);else{const r=t[t.length-1];if(r.id.clock+r.length!==e.id.clock)throw cn()}t.push(e)},zn=(n,e)=>{let t=0,r=n.length-1,i=n[r],s=i.id.clock;if(s===e)return r;let o=wn(e/(s+i.length-1)*r);for(;t<=r;){if(i=n[o],s=i.id.clock,s<=e){if(e<s+i.length)return o;t=o+1}else r=o-1;o=wn((t+r)/2)}throw cn()},fs=(n,e)=>{const t=n.clients.get(e.client);return t[zn(t,e.clock)]},zd=(n,e,t)=>{const r=zn(e,t),i=e[r];return i.id.clock<t&&i instanceof ze?(e.splice(r+1,0,ha(n,i,t-i.id.clock)),r+1):r},Ut=(n,e)=>{const t=n.doc.store.clients.get(e.client);return t[zd(n,t,e.clock)]},Py=(n,e,t)=>{const r=e.clients.get(t.client),i=zn(r,t.clock),s=r[i];return t.clock!==s.id.clock+s.length-1&&s.constructor!==dn&&r.splice(i+1,0,ha(n,s,t.clock-s.id.clock+1)),s},SM=(n,e,t)=>{const r=n.clients.get(e.id.client);r[zn(r,e.id.clock)]=t},Fy=(n,e,t,r,i)=>{if(r===0)return;const s=t+r;let o=zd(n,e,t),l;do l=e[o++],s<l.id.clock+l.length&&zd(n,e,s),i(l);while(o<e.length&&e[o].id.clock<s)};class EM{constructor(e,t,r){this.doc=e,this.deleteSet=new is,this.beforeState=Do(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const By=(n,e)=>e.deleteSet.clients.size===0&&!VT(e.afterState,(t,r)=>e.beforeState.get(r)!==t)?!1:(Pd(e.deleteSet),cM(n,e),ls(n,e.deleteSet),!0),$y=(n,e,t)=>{const r=e._item;(r===null||r.id.clock<(n.beforeState.get(r.id.client)||0)&&!r.deleted)&&zt(n.changed,e,or).add(t)},na=(n,e)=>{let t=n[e],r=n[e-1],i=e;for(;i>0;t=r,r=n[--i-1]){if(r.deleted===t.deleted&&r.constructor===t.constructor&&r.mergeWith(t)){t instanceof ze&&t.parentSub!==null&&t.parent._map.get(t.parentSub)===t&&t.parent._map.set(t.parentSub,r);continue}break}const s=e-i;return s&&n.splice(e+1-s,s),s},TM=(n,e,t)=>{for(const[r,i]of n.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=zn(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 ze&&d.deleted&&!d.keep&&t(d)&&d.gc(e,!1)}}}},AM=(n,e)=>{n.clients.forEach((t,r)=>{const i=e.clients.get(r);for(let s=t.length-1;s>=0;s--){const o=t[s],l=Ir(i.length-1,1+zn(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+na(i,a)}})},jy=(n,e)=>{if(e<n.length){const t=n[e],r=t.doc,i=r.store,s=t.deleteSet,o=t._mergeStructs;try{Pd(s),t.afterState=Do(t.doc.store),r.emit("beforeObserverCalls",[t,r]);const l=[];t.changed.forEach((a,c)=>l.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(t,a)})),l.push(()=>{t.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),Ny(c._dEH,a,t))})}),l.push(()=>r.emit("afterTransaction",[t,r])),Td(l,[]),t._needFormattingCleanup&&JM(t)}finally{r.gc&&TM(s,i,r.gcFilter),AM(s,i),t.afterState.forEach((u,d)=>{const f=t.beforeState.get(d)||0;if(f!==u){const h=i.clients.get(d),p=ar(zn(h,f),1);for(let g=h.length-1;g>=p;)g-=1+na(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=zn(h,f);p+1<h.length&&na(h,p+1)>1||p>0&&na(h,p)}if(!t.local&&t.afterState.get(r.clientID)!==t.beforeState.get(r.clientID)&&(ay(Ql,un,"[yjs] ",yi,ry,"Changed the client-id because another client seems to be using it."),r.clientID=wy()),r.emit("afterTransactionCleanup",[t,r]),r._observers.has("update")){const u=new Ao;By(u,t)&&r.emit("update",[u.toUint8Array(),t.origin,r,t])}if(r._observers.has("updateV2")){const u=new bi;By(u,t)&&r.emit("updateV2",[u.toUint8Array(),t.origin,r,t])}const{subdocsAdded:l,subdocsLoaded:a,subdocsRemoved:c}=t;(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,t]),c.forEach(u=>u.destroy())),n.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,n])):jy(n,e+1)}}},Be=(n,e,t=null,r=!0)=>{const i=n._transactionCleanups;let s=!1,o=null;n._transaction===null&&(s=!0,n._transaction=new EM(n,t,r),i.push(n._transaction),i.length===1&&n.emit("beforeAllTransactions",[n]),n.emit("beforeTransaction",[n._transaction,n]));try{o=e(n._transaction)}finally{if(s){const l=n._transaction===i[0];n._transaction=null,l&&jy(i,0)}}return o};class MM{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}}const Hy=(n,e,t)=>{Pr(n,t.deletions,r=>{r instanceof ze&&e.scope.some(i=>Oo(i,r))&&tf(r,!1)})},Vy=(n,e,t)=>{let r=null;const i=n.doc,s=n.scope;if(Be(i,o=>{for(;e.length>0&&n.currStackItem===null;){const l=i.store,a=e.pop(),c=new Set,u=[];let d=!1;Pr(o,a.insertions,f=>{if(f instanceof ze){if(f.redone!==null){let{item:h,diff:p}=ef(l,f.id);p>0&&(h=Ut(o,pe(h.id.client,h.id.clock+p))),f=h}!f.deleted&&s.some(h=>Oo(h,f))&&u.push(f)}}),Pr(o,a.deletions,f=>{f instanceof ze&&s.some(h=>Oo(h,f))&&!ss(a.insertions,f.id)&&c.add(f)}),c.forEach(f=>{d=hb(o,f,c,a.insertions,n.ignoreRemoteMapChanges,n)!==null||d});for(let f=u.length-1;f>=0;f--){const h=u[f];n.deleteFilter(h)&&(h.delete(o),d=!0)}n.currStackItem=d?a:null}o.changed.forEach((l,a)=>{l.has(null)&&a._searchMarker&&(a._searchMarker.length=0)}),r=o},n),n.currStackItem!=null){const o=r.changedParentTypes;n.emit("stack-item-popped",[{stackItem:n.currStackItem,type:t,changedParentTypes:o,origin:n},n]),n.currStackItem=null}return n.currStackItem};class zy extends dd{constructor(e,{captureTimeout:t=500,captureTransaction:r=a=>!0,deleteFilter:i=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:l=ud(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=t,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 is;a.afterState.forEach((v,w)=>{const S=a.beforeState.get(w)||0,C=v-S;C>0&&To(f,w,S,C)});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=Fd([v.deletions,a.deleteSet]),v.insertions=Fd([v.insertions,f])}else d.push(new MM(a.deleteSet,f)),p=!0;!c&&!u&&(this.lastChange=h),Pr(a,a.deleteSet,v=>{v instanceof ze&&this.scope.some(w=>Oo(w,v))&&tf(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=ud(e)?e:[e],e.forEach(t=>{this.scope.every(r=>r!==t)&&(t.doc!==this.doc&&VA("[yjs#509] Not same Y.Doc"),this.scope.push(t))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(i=>Hy(r,this,i)),this.undoStack=[]),t&&(this.redoStack.forEach(i=>Hy(r,this,i)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Vy(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Vy(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*OM(n){const e=he(n.restDecoder);for(let t=0;t<e;t++){const r=he(n.restDecoder),i=n.readClient();let s=he(n.restDecoder);for(let o=0;o<r;o++){const l=n.readInfo();if(l===10){const a=he(n.restDecoder);yield new fn(pe(i,s),a),s+=a}else if(Kl&l){const a=(l&(cr|Yt))===0,c=new ze(pe(i,s),null,(l&Yt)===Yt?n.readLeftID():null,null,(l&cr)===cr?n.readRightID():null,a?n.readParentInfo()?n.readString():n.readLeftID():null,a&&(l&wo)===wo?n.readString():null,pb(n,l));yield c,s+=c.length}else{const a=n.readLen();yield new dn(pe(i,s),a),s+=a}}}}class Ud{constructor(e,t){this.gen=OM(e),this.curr=null,this.done=!1,this.filterSkips=t,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 Wd{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const _M=n=>ra(n,xy,Ao),NM=(n,e)=>{if(n.constructor===dn){const{client:t,clock:r}=n.id;return new dn(pe(t,r+e),n.length-e)}else if(n.constructor===fn){const{client:t,clock:r}=n.id;return new fn(pe(t,r+e),n.length-e)}else{const t=n,{client:r,clock:i}=t.id;return new ze(pe(r,i+e),null,pe(r,i+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},ra=(n,e=cs,t=bi)=>{if(n.length===1)return n[0];const r=n.map(u=>new e(Hn(u)));let i=r.map(u=>new Ud(u,!0)),s=null;const o=new t,l=new Wd(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(pe(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=NM(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),qd(l);const a=r.map(u=>Bd(u)),c=Fd(a);return ls(o,c),o.toUint8Array()},DM=(n,e,t=cs,r=bi)=>{const i=Ty(e),s=new r,o=new Wd(s),l=new t(Hn(n)),a=new Ud(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()}qd(o);const c=Bd(l);return ls(s,c),s.toUint8Array()},Uy=n=>{n.written>0&&(n.clientStructs.push({written:n.written,restEncoder:qe(n.encoder.restEncoder)}),n.encoder.restEncoder=gt(),n.written=0)},Fr=(n,e,t)=>{n.written>0&&n.currClient!==e.id.client&&Uy(n),n.written===0&&(n.currClient=e.id.client,n.encoder.writeClient(e.id.client),ae(n.encoder.restEncoder,e.id.clock+t)),e.write(n.encoder,t),n.written++},qd=n=>{Uy(n);const e=n.encoder.restEncoder;ae(e,n.clientStructs.length);for(let t=0;t<n.clientStructs.length;t++){const r=n.clientStructs[t];ae(e,r.written),Jl(e,r.restEncoder)}},RM=(n,e,t,r)=>{const i=new t(Hn(n)),s=new Ud(i,!1),o=new r,l=new Wd(o);for(let c=s.curr;c!==null;c=s.next())Fr(l,e(c),0);qd(l);const a=Bd(i);return ls(o,a),o.toUint8Array()},LM=n=>RM(n,OA,cs,Ao),Wy="You must not compute changes after the event-handler fired.";class ia{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=IM(this.currentTarget,this.target))}deletes(e){return ss(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw $n(Wy);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach(i=>{if(i!==null){const s=t._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=cd(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",l=cd(a.content.getContent())):(o="add",l=void 0)}else if(this.deletes(s))o="delete",l=cd(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 $n(Wy);const t=this.target,r=or(),i=or(),s=[];if(e={added:r,deleted:i,delta:s,keys:this.keys},this.transaction.changed.get(t).has(null)){let l=null;const a=()=>{l&&s.push(l)};for(let c=t._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 IM=(n,e)=>{const t=[];for(;e._item!==null&&e!==n;){if(e._item.parentSub!==null)t.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;t.unshift(r)}e=e._item.parent}return t},qy=80;let Kd=0;class PM{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Kd++}}const FM=n=>{n.timestamp=Kd++},Ky=(n,e,t)=>{n.p.marker=!1,n.p=e,e.marker=!0,n.index=t,n.timestamp=Kd++},BM=(n,e,t)=>{if(n.length>=qy){const r=n.reduce((i,s)=>i.timestamp<s.timestamp?i:s);return Ky(r,e,t),r}else{const r=new PM(e,t);return n.push(r),r}},sa=(n,e)=>{if(n._start===null||e===0||n._searchMarker===null)return null;const t=n._searchMarker.length===0?null:n._searchMarker.reduce((s,o)=>Wl(e-s.index)<Wl(e-o.index)?s:o);let r=n._start,i=0;for(t!==null&&(r=t.p,i=t.index,FM(t));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 t!==null&&Wl(t.index-i)<r.parent.length/qy?(Ky(t,r,i),t):BM(n._searchMarker,r,i)},Ro=(n,e,t)=>{for(let r=n.length-1;r>=0;r--){const i=n[r];if(t>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){n.splice(r,1);continue}i.p=s,s.marker=!0}(e<i.index||t>0&&e===i.index)&&(i.index=ar(e,i.index+t))}},oa=(n,e,t)=>{const r=n,i=e.changedParentTypes;for(;zt(i,n,()=>[]).push(t),n._item!==null;)n=n._item.parent;Ny(r._eH,t,e)};class Et{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=My(),this._dEH=My(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Cn()}clone(){throw Cn()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){Oy(this._eH,e)}observeDeep(e){Oy(this._dEH,e)}unobserve(e){_y(this._eH,e)}unobserveDeep(e){_y(this._dEH,e)}toJSON(){}}const Jy=(n,e,t)=>{e<0&&(e=n._length+e),t<0&&(t=n._length+t);let r=t-e;const i=[];let s=n._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},Gy=n=>{const e=[];let t=n._start;for(;t!==null;){if(t.countable&&!t.deleted){const r=t.content.getContent();for(let i=0;i<r.length;i++)e.push(r[i])}t=t.right}return e},Yy=(n,e)=>{const t=[];let r=n._start;for(;r!==null;){if(r.countable&&vi(r,e)){const i=r.content.getContent();for(let s=0;s<i.length;s++)t.push(i[s])}r=r.right}return t},Lo=(n,e)=>{let t=0,r=n._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],t++,n)}r=r.right}},Zy=(n,e)=>{const t=[];return Lo(n,(r,i)=>{t.push(e(r,i,n))}),t},$M=n=>{let e=n._start,t=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(t===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};t=e.content.getContent(),r=0,e=e.right}const i=t[r++];return t.length<=r&&(t=null),{done:!1,value:i}}}},Xy=(n,e)=>{const t=sa(n,e);let r=n._start;for(t!==null&&(r=t.p,e-=t.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},la=(n,e,t,r)=>{let i=t;const s=n.doc,o=s.clientID,l=s.store,a=t===null?e._start:t.right;let c=[];const u=()=>{c.length>0&&(i=new ze(pe(o,rt(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new ki(c)),i.integrate(n,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 ze(pe(o,rt(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new Io(new Uint8Array(d))),i.integrate(n,0);break;case as:i=new ze(pe(o,rt(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new Fo(d)),i.integrate(n,0);break;default:if(d instanceof Et)i=new ze(pe(o,rt(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new kn(d)),i.integrate(n,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},Qy=()=>$n("Length exceeded!"),eb=(n,e,t,r)=>{if(t>e._length)throw Qy();if(t===0)return e._searchMarker&&Ro(e._searchMarker,t,r.length),la(n,e,null,r);const i=t,s=sa(e,t);let o=e._start;for(s!==null&&(o=s.p,t-=s.index,t===0&&(o=o.prev,t+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(t<=o.length){t<o.length&&Ut(n,pe(o.id.client,o.id.clock+t));break}t-=o.length}return e._searchMarker&&Ro(e._searchMarker,i,r.length),la(n,e,o,r)},jM=(n,e,t)=>{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 la(n,e,i,t)},tb=(n,e,t,r)=>{if(r===0)return;const i=t,s=r,o=sa(e,t);let l=e._start;for(o!==null&&(l=o.p,t-=o.index);l!==null&&t>0;l=l.right)!l.deleted&&l.countable&&(t<l.length&&Ut(n,pe(l.id.client,l.id.clock+t)),t-=l.length);for(;r>0&&l!==null;)l.deleted||(r<l.length&&Ut(n,pe(l.id.client,l.id.clock+r)),l.delete(n),r-=l.length),l=l.right;if(r>0)throw Qy();e._searchMarker&&Ro(e._searchMarker,i,-s+r)},aa=(n,e,t)=>{const r=e._map.get(t);r!==void 0&&r.delete(n)},Jd=(n,e,t,r)=>{const i=e._map.get(t)||null,s=n.doc,o=s.clientID;let l;if(r==null)l=new ki([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:l=new ki([r]);break;case Uint8Array:l=new Io(r);break;case as:l=new Fo(r);break;default:if(r instanceof Et)l=new kn(r);else throw new Error("Unexpected content type")}new ze(pe(o,rt(s.store,o)),i,i&&i.lastId,null,null,e,t,l).integrate(n,0)},Gd=(n,e)=>{const t=n._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},nb=n=>{const e={};return n._map.forEach((t,r)=>{t.deleted||(e[r]=t.content.getContent()[t.length-1])}),e},rb=(n,e)=>{const t=n._map.get(e);return t!==void 0&&!t.deleted},HM=(n,e)=>{const t={};return n._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)&&(t[i]=s.content.getContent()[s.length-1])}),t},ca=n=>rM(n.entries(),e=>!e[1].deleted);class VM extends ia{constructor(e,t){super(e,t),this._transaction=t}}class hs extends Et{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new hs;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new hs}clone(){const e=new hs;return e.insert(0,this.toArray().map(t=>t instanceof Et?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}_callObserver(e,t){super._callObserver(e,t),oa(this,e,new VM(this,e))}insert(e,t){this.doc!==null?Be(this.doc,r=>{eb(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?Be(this.doc,t=>{jM(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?Be(this.doc,r=>{tb(r,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return Xy(this,e)}toArray(){return Gy(this)}slice(e=0,t=this.length){return Jy(this,e,t)}toJSON(){return this.map(e=>e instanceof Et?e.toJSON():e)}map(e){return Zy(this,e)}forEach(e){Lo(this,e)}[Symbol.iterator](){return $M(this)}_write(e){e.writeTypeRef(fO)}}const zM=n=>new hs;class UM extends ia{constructor(e,t,r){super(e,t),this.keysChanged=r}}class ps extends Et{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((r,i)=>{this.set(i,r)}),this._prelimContent=null}_copy(){return new ps}clone(){const e=new ps;return this.forEach((t,r)=>{e.set(r,t instanceof Et?t.clone():t)}),e}_callObserver(e,t){oa(this,e,new UM(this,e,t))}toJSON(){const e={};return this._map.forEach((t,r)=>{if(!t.deleted){const i=t.content.getContent()[t.length-1];e[r]=i instanceof Et?i.toJSON():i}}),e}get size(){return[...ca(this._map)].length}keys(){return Ld(ca(this._map),e=>e[0])}values(){return Ld(ca(this._map),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Ld(ca(this._map),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this._map.forEach((t,r)=>{t.deleted||e(t.content.getContent()[t.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?Be(this.doc,t=>{aa(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?Be(this.doc,r=>{Jd(r,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return Gd(this,e)}has(e){return rb(this,e)}clear(){this.doc!==null?Be(this.doc,e=>{this.forEach(function(t,r,i){aa(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(hO)}}const WM=n=>new ps,Br=(n,e)=>n===e||typeof n=="object"&&typeof e=="object"&&n&&e&&AA(n,e);class Yd{constructor(e,t,r,i){this.left=e,this.right=t,this.index=r,this.currentAttributes=i}forward(){switch(this.right===null&&cn(),this.right.content.constructor){case lt:this.right.deleted||ms(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 ib=(n,e,t)=>{for(;e.right!==null&&t>0;){switch(e.right.content.constructor){case lt:e.right.deleted||ms(e.currentAttributes,e.right.content);break;default:e.right.deleted||(t<e.right.length&&Ut(n,pe(e.right.id.client,e.right.id.clock+t)),e.index+=e.right.length,t-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},ua=(n,e,t,r)=>{const i=new Map,s=r?sa(e,t):null;if(s){const o=new Yd(s.p.left,s.p,s.index,i);return ib(n,o,t-s.index)}else{const o=new Yd(null,e._start,0,i);return ib(n,o,t)}},sb=(n,e,t,r)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===lt&&Br(r.get(t.right.content.key),t.right.content.value));)t.right.deleted||r.delete(t.right.content.key),t.forward();const i=n.doc,s=i.clientID;r.forEach((o,l)=>{const a=t.left,c=t.right,u=new ze(pe(s,rt(i.store,s)),a,a&&a.lastId,c,c&&c.id,e,null,new lt(l,o));u.integrate(n,0),t.right=u,t.forward()})},ms=(n,e)=>{const{key:t,value:r}=e;r===null?n.delete(t):n.set(t,r)},ob=(n,e)=>{for(;n.right!==null;){if(!(n.right.deleted||n.right.content.constructor===lt&&Br(e[n.right.content.key]??null,n.right.content.value)))break;n.forward()}},lb=(n,e,t,r)=>{const i=n.doc,s=i.clientID,o=new Map;for(const l in r){const a=r[l],c=t.currentAttributes.get(l)??null;if(!Br(c,a)){o.set(l,c);const{left:u,right:d}=t;t.right=new ze(pe(s,rt(i.store,s)),u,u&&u.lastId,d,d&&d.id,e,null,new lt(l,a)),t.right.integrate(n,0),t.forward()}}return o},Zd=(n,e,t,r,i)=>{t.currentAttributes.forEach((f,h)=>{i[h]===void 0&&(i[h]=null)});const s=n.doc,o=s.clientID;ob(t,i);const l=lb(n,e,t,i),a=r.constructor===String?new xn(r):r instanceof Et?new kn(r):new xi(r);let{left:c,right:u,index:d}=t;e._searchMarker&&Ro(e._searchMarker,t.index,a.getLength()),u=new ze(pe(o,rt(s.store,o)),c,c&&c.lastId,u,u&&u.id,e,null,a),u.integrate(n,0),t.right=u,t.index=d,t.forward(),sb(n,e,t,l)},ab=(n,e,t,r,i)=>{const s=n.doc,o=s.clientID;ob(t,i);const l=lb(n,e,t,i);e:for(;t.right!==null&&(r>0||l.size>0&&(t.right.deleted||t.right.content.constructor===lt));){if(!t.right.deleted)switch(t.right.content.constructor){case lt:{const{key:a,value:c}=t.right.content,u=i[a];if(u!==void 0){if(Br(u,c))l.delete(a);else{if(r===0)break e;l.set(a,c)}t.right.delete(n)}else t.currentAttributes.set(a,c);break}default:r<t.right.length&&Ut(n,pe(t.right.id.client,t.right.id.clock+r)),r-=t.right.length;break}t.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
308
- `;t.right=new ze(pe(o,rt(s.store,o)),t.left,t.left&&t.left.lastId,t.right,t.right&&t.right.id,e,null,new xn(a)),t.right.integrate(n,0),t.forward()}sb(n,e,t,l)},cb=(n,e,t,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(t===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(n),l++,!a&&(i.get(u)??null)===d&&f!==d&&(f===null?i.delete(u):i.set(u,f))),!a&&!e.deleted&&ms(i,c);break}}}e=e.right}return l},qM=(n,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const t=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===lt){const r=e.content.key;t.has(r)?e.delete(n):t.add(r)}e=e.left}},KM=n=>{let e=0;return Be(n.doc,t=>{let r=n._start,i=n._start,s=Lt();const o=ad(s);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case lt:ms(o,i.content);break;default:e+=cb(t,r,i,s,o),s=ad(o),r=i;break}i=i.right}}),e},JM=n=>{const e=new Set,t=n.doc;for(const[r,i]of n.afterState.entries()){const s=n.beforeState.get(r)||0;i!==s&&Fy(n,t.store.clients.get(r),s,i,o=>{!o.deleted&&o.content.constructor===lt&&o.constructor!==dn&&e.add(o.parent)})}Be(t,r=>{Pr(n,n.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):qM(r,i)});for(const i of e)KM(i)})},ub=(n,e,t)=>{const r=t,i=ad(e.currentAttributes),s=e.right;for(;t>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case kn:case xi:case xn:t<e.right.length&&Ut(n,pe(e.right.id.client,e.right.id.clock+t)),t-=e.right.length,e.right.delete(n);break}e.forward()}s&&cb(n,s,e.right,i,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&Ro(o._searchMarker,e.index,-r+t),e};class GM extends ia{constructor(e,t,r){super(e,t),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,t=[];Be(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},EA(a)||(h.attributes=kA({},a))),u=0;break}h&&t.push(h),l=null}};for(;o!==null;){switch(o.content.constructor){case kn:case xi: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 xn: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;Br(g,p)?p!==null&&o.delete(r):(l==="retain"&&f(),Br(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;Br(g,p)||(l==="retain"&&f(),a[h]=g)}else if(!o.deleted){s.set(h,p);const g=a[h];g!==void 0&&(Br(g,p)?g!==null&&o.delete(r):(l==="retain"&&f(),p===null?delete a[h]:a[h]=p))}o.deleted||(l==="insert"&&f(),ms(i,o.content));break}}o=o.right}for(f();t.length>0;){const h=t[t.length-1];if(h.retain!==void 0&&h.attributes===void 0)t.pop();else break}}),this._delta=t}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,t){super._integrate(e,t);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,t){super._callObserver(e,t);const r=new GM(this,e,t);oa(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){let e="",t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===xn&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc!==null?Be(this.doc,r=>{const i=new Yd(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=!t&&typeof o.insert=="string"&&s===e.length-1&&i.right===null&&o.insert.slice(-1)===`
309
- `?o.insert.slice(0,-1):o.insert;(typeof l!="string"||l.length>0)&&Zd(r,this,i,l,o.attributes||{})}else o.retain!==void 0?ab(r,this,i,o.retain,o.attributes||{}):o.delete!==void 0&&ub(r,i,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,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)||t!==void 0&&vi(a,t))switch(a.content.constructor){case xn:{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"})):t!==void 0&&!vi(a,t)?(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 kn:case xi:{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(),ms(s,a.content));break}a=a.right}c()};return e||t?Be(o,d=>{e&&Vd(d,e),t&&Vd(d,t),u()},"cleanup"):u(),i}insert(e,t,r){if(t.length<=0)return;const i=this.doc;i!==null?Be(i,s=>{const o=ua(s,this,e,!r);r||(r={},o.currentAttributes.forEach((l,a)=>{r[a]=l})),Zd(s,this,o,t,r)}):this._pending.push(()=>this.insert(e,t,r))}insertEmbed(e,t,r){const i=this.doc;i!==null?Be(i,s=>{const o=ua(s,this,e,!r);Zd(s,this,o,t,r||{})}):this._pending.push(()=>this.insertEmbed(e,t,r||{}))}delete(e,t){if(t===0)return;const r=this.doc;r!==null?Be(r,i=>{ub(i,ua(i,this,e,!0),t)}):this._pending.push(()=>this.delete(e,t))}format(e,t,r){if(t===0)return;const i=this.doc;i!==null?Be(i,s=>{const o=ua(s,this,e,!1);o.right!==null&&ab(s,this,o,t,r)}):this._pending.push(()=>this.format(e,t,r))}removeAttribute(e){this.doc!==null?Be(this.doc,t=>{aa(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?Be(this.doc,r=>{Jd(r,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return Gd(this,e)}getAttributes(){return nb(this)}_write(e){e.writeTypeRef(pO)}}const YM=n=>new wi;class Xd{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===It||t.constructor===Ci)&&t._start!==null)e=t._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 Ci extends Et{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Ci}clone(){const e=new Ci;return e.insert(0,this.toArray().map(t=>t instanceof Et?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Xd(this,e)}querySelector(e){e=e.toUpperCase();const r=new Xd(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),lr(new Xd(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){oa(this,e,new QM(this,t,e))}toString(){return Zy(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},r){const i=e.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),Lo(this,s=>{i.insertBefore(s.toDOM(e,t,r),null)}),i}insert(e,t){this.doc!==null?Be(this.doc,r=>{eb(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)Be(this.doc,r=>{const i=e&&e instanceof Et?e._item:e;la(r,this,i,t)});else{const r=this._prelimContent,i=e===null?0:r.findIndex(s=>s===e)+1;if(i===0&&e!==null)throw $n("Reference item not found");r.splice(i,0,...t)}}delete(e,t=1){this.doc!==null?Be(this.doc,r=>{tb(r,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return Gy(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Xy(this,e)}slice(e=0,t=this.length){return Jy(this,e,t)}forEach(e){Lo(this,e)}_write(e){e.writeTypeRef(gO)}}const ZM=n=>new Ci;class It extends Ci{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,t){super._integrate(e,t),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),t=this.getAttributes();return SA(t,(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(),t=[],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];t.push(a+'="'+e[a]+'"')}const s=this.nodeName.toLocaleLowerCase(),o=t.length>0?" "+t.join(" "):"";return`<${s}${o}>${super.toString()}</${s}>`}removeAttribute(e){this.doc!==null?Be(this.doc,t=>{aa(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?Be(this.doc,r=>{Jd(r,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return Gd(this,e)}hasAttribute(e){return rb(this,e)}getAttributes(e){return e?HM(this,e):nb(this)}toDOM(e=document,t={},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 Lo(this,o=>{i.appendChild(o.toDOM(e,t,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(mO),e.writeKey(this.nodeName)}}const XM=n=>new It(n.readKey());class QM extends ia{constructor(e,t,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i)})}}class da extends ps{constructor(e){super(),this.hookName=e}_copy(){return new da(this.hookName)}clone(){const e=new da(this.hookName);return this.forEach((t,r)=>{e.set(r,t)}),e}toDOM(e=document,t={},r){const i=t[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(yO),e.writeKey(this.hookName)}}const eO=n=>new da(n.readKey());class Zt 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 Zt}clone(){const e=new Zt;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,r){const i=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(e=>{const t=[];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),t.push({nodeName:i,attrs:s})}t.sort((i,s)=>i.nodeName<s.nodeName?-1:1);let r="";for(let i=0;i<t.length;i++){const s=t[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=t.length-1;i>=0;i--)r+=`</${t[i].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(bO)}}const tO=n=>new Zt;class Qd{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Cn()}mergeWith(e){return!1}write(e,t,r){throw Cn()}integrate(e,t){throw Cn()}}const nO=0;class dn extends Qd{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),Iy(e.doc.store,this)}write(e,t){e.writeInfo(nO),e.writeLen(this.length-t)}getMissing(e,t){return null}}class Io{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Io(this.content)}splice(e){throw Cn()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}const rO=n=>new Io(n.readBuf());class Po{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Po(this.len)}splice(e){const t=new Po(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){To(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}}const iO=n=>new Po(n.readLen()),db=(n,e)=>new as({guid:n,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Fo{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 t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Fo(db(this.doc.guid,this.opts))}splice(e){throw Cn()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,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,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const sO=n=>new Fo(db(n.readString(),n.readAny()));class xi{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new xi(this.embed)}splice(e){throw Cn()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}const oO=n=>new xi(n.readJSON());class lt{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new lt(this.key,this.value)}splice(e){throw Cn()}mergeWith(e){return!1}integrate(e,t){const r=t.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const lO=n=>new lt(n.readKey(),n.readJSON());class fa{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new fa(this.arr)}splice(e){const t=new fa(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const r=this.arr.length;e.writeLen(r-t);for(let i=t;i<r;i++){const s=this.arr[i];e.writeString(s===void 0?"undefined":JSON.stringify(s))}}getRef(){return 2}}const aO=n=>{const e=n.readLen(),t=[];for(let r=0;r<e;r++){const i=n.readString();i==="undefined"?t.push(void 0):t.push(JSON.parse(i))}return new fa(t)};class ki{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ki(this.arr)}splice(e){const t=new ki(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const r=this.arr.length;e.writeLen(r-t);for(let i=t;i<r;i++){const s=this.arr[i];e.writeAny(s)}}getRef(){return 8}}const cO=n=>{const e=n.readLen(),t=[];for(let r=0;r<e;r++)t.push(n.readAny());return new ki(t)};class xn{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new xn(this.str)}splice(e){const t=new xn(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)+"�",t.str="�"+t.str.slice(1)),t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}}const uO=n=>new xn(n.readString()),dO=[zM,WM,YM,XM,ZM,eO,tO],fO=0,hO=1,pO=2,mO=3,gO=4,yO=5,bO=6;class kn{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new kn(this.type._copy())}splice(e){throw Cn()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.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 t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.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,t){this.type._write(e)}getRef(){return 7}}const vO=n=>new kn(dO[n.readTypeRef()](n)),ef=(n,e)=>{let t=e,r=0,i;do r>0&&(t=pe(t.client,t.clock+r)),i=fs(n,t),r=t.clock-i.id.clock,t=i.redone;while(t!==null&&i instanceof ze);return{item:i,diff:r}},tf=(n,e)=>{for(;n!==null&&n.keep!==e;)n.keep=e,n=n.parent._item},ha=(n,e,t)=>{const{client:r,clock:i}=e.id,s=new ze(pe(r,i+t),e,pe(r,i+t-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(t));return e.deleted&&s.markDeleted(),e.keep&&(s.keep=!0),e.redone!==null&&(s.redone=pe(e.redone.client,e.redone.clock+t)),e.right=s,s.right!==null&&(s.right.left=s),n._mergeStructs.push(s),s.parentSub!==null&&s.right===null&&s.parent._map.set(s.parentSub,s),e.length=t,s},fb=(n,e)=>UT(n,t=>ss(t.deletions,e)),hb=(n,e,t,r,i,s)=>{const o=n.doc,l=o.store,a=o.clientID,c=e.redone;if(c!==null)return Ut(n,c);let u=e.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!t.has(u)||hb(n,u,t,r,i,s)===null))return null;for(;u.redone!==null;)u=Ut(n,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(n,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(n,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||ss(r,d.right.id)||fb(s.undoStack,d.right.id)||fb(s.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Ut(n,d.redone);if(d&&d.right!==null)return null}else d=h._map.get(e.parentSub)||null;const p=rt(l,a),g=pe(a,p),v=new ze(g,d,d&&d.lastId,f,f&&f.id,h,e.parentSub,e.content.copy());return e.redone=g,tf(v,!0),v.integrate(n,0),v};let ze=class Sh extends Qd{constructor(e,t,r,i,s,o,l,a){super(e,a.getLength()),this.origin=r,this.left=t,this.right=i,this.rightOrigin=s,this.parent=o,this.parentSub=l,this.redone=null,this.content=a,this.info=this.content.isCountable()?I0:0}set marker(e){(this.info&pd)>0!==e&&(this.info^=pd)}get marker(){return(this.info&pd)>0}get keep(){return(this.info&L0)>0}set keep(e){this.keep!==e&&(this.info^=L0)}get countable(){return(this.info&I0)>0}get deleted(){return(this.info&hd)>0}set deleted(e){this.deleted!==e&&(this.info^=hd)}markDeleted(){this.info|=hd}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=rt(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=rt(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===us&&this.id.client!==this.parent.client&&this.parent.clock>=rt(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Py(e,t,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===Sh&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===Sh&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===us){const r=fs(t,this.parent);r.constructor===dn?this.parent=null:this.parent=r.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Py(e,e.doc.store,pe(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),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),ds(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,s.clear();else if(ds(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&o.has(fs(e.doc.store,i.origin)))s.has(fs(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),Iy(e.doc.store,this),this.content.integrate(e,this),$y(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:pe(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&ds(e.origin,this.lastId)&&this.right===e&&ds(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 t=this.parent._searchMarker;return t&&t.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 t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),To(e.deleteSet,this.id.client,this.id.clock,this.length),$y(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw cn();this.content.gc(e),t?SM(e,this,new dn(this.id,this.length)):this.content=new Po(this.length)}write(e,t){const r=t>0?pe(this.id.client,this.id.clock+t-1):this.origin,i=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&Kl|(r===null?0:Yt)|(i===null?0:cr)|(s===null?0:wo);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=Mo(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===us?(e.writeParentInfo(!1),e.writeLeftID(l)):cn();s!==null&&e.writeString(s)}this.content.write(e,t)}};const pb=(n,e)=>wO[e&Kl](n),wO=[()=>{cn()},iO,aO,rO,uO,oO,lO,vO,cO,sO,()=>{cn()}],CO=10;class fn extends Qd{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){cn()}write(e,t){e.writeInfo(CO),ae(e.restEncoder,this.length-t)}getMissing(e,t){return null}}const mb=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},gb="__ $YJS$ __";mb[gb]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),mb[gb]=!0;function pa(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var yb={exports:{}};(function(n,e){(function(t){n.exports=t()})(function(){var t=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 pa=="function"&&pa;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 pa=="function"&&pa,d=0;d<a.length;d++)c(a[d]);return c}return s}()({1:[function(s,o,l){function a(y){var k=y.length;if(0<k%4)throw new Error("Invalid string. Length must be a multiple of 4");var E=y.indexOf("=");E===-1&&(E=k);var T=E===k?0:4-E%4;return[E,T]}function c(y,k,E){return 3*(k+E)/4-E}function u(y){var k,E,T=a(y),N=T[0],_=T[1],A=new v(c(y,N,_)),R=0,P=0<_?N-4:N;for(E=0;E<P;E+=4)k=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&k>>16,A[R++]=255&k>>8,A[R++]=255&k;return _===2&&(k=g[y.charCodeAt(E)]<<2|g[y.charCodeAt(E+1)]>>4,A[R++]=255&k),_===1&&(k=g[y.charCodeAt(E)]<<10|g[y.charCodeAt(E+1)]<<4|g[y.charCodeAt(E+2)]>>2,A[R++]=255&k>>8,A[R++]=255&k),A}function d(y){return p[63&y>>18]+p[63&y>>12]+p[63&y>>6]+p[63&y]}function f(y,k,E){for(var T,N=[],_=k;_<E;_+=3)T=(16711680&y[_]<<16)+(65280&y[_+1]<<8)+(255&y[_+2]),N.push(d(T));return N.join("")}function h(y){for(var k,E=y.length,T=E%3,N=[],_=16383,A=0,R=E-T;A<R;A+=_)N.push(f(y,A,A+_>R?R:A+_));return T===1?(k=y[E-1],N.push(p[k>>2]+p[63&k<<4]+"==")):T===2&&(k=(y[E-2]<<8)+y[E-1],N.push(p[k>>10]+p[63&k>>4]+p[63&k<<2]+"=")),N.join("")}l.byteLength=function(y){var k=a(y),E=k[0],T=k[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,C=w.length;S<C;++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,x){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,x)}function f(m,b,x){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(B(m,ArrayBuffer)||m&&B(m.buffer,ArrayBuffer))return S(m,b,x);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,x);var F=C(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,x);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,x){return h(m),0>=m||b===void 0?u(m):typeof x=="string"?u(m).fill(b,x):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 x=0|k(m,b),I=u(x),F=I.write(m,b);return F!==x&&(I=I.slice(0,F)),I}function w(m){for(var b=0>m.length?0:0|y(m.length),x=u(b),I=0;I<b;I+=1)x[I]=255&m[I];return x}function S(m,b,x){if(0>b||m.byteLength<b)throw new RangeError('"offset" is outside of buffer bounds');if(m.byteLength<b+(x||0))throw new RangeError('"length" is outside of buffer bounds');var I;return I=b===void 0&&x===void 0?new Uint8Array(m):x===void 0?new Uint8Array(m,b):new Uint8Array(m,b,x),I.__proto__=d.prototype,I}function C(m){if(d.isBuffer(m)){var b=0|y(m.length),x=u(b);return x.length===0||m.copy(x,0,0,b),x}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 k(m,b){if(d.isBuffer(m))return m.length;if(ArrayBuffer.isView(m)||B(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 x=m.length,I=2<arguments.length&&arguments[2]===!0;if(!I&&x===0)return 0;for(var F=!1;;)switch(b){case"ascii":case"latin1":case"binary":return x;case"utf8":case"utf-8":return Ye(m).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*x;case"hex":return x>>>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,x){var I=!1;if((b===void 0||0>b)&&(b=0),b>this.length||((x===void 0||x>this.length)&&(x=this.length),0>=x)||(x>>>=0,b>>>=0,x<=b))return"";for(m||(m="utf8");;)switch(m){case"hex":return Re(this,b,x);case"utf8":case"utf-8":return G(this,b,x);case"ascii":return X(this,b,x);case"latin1":case"binary":return we(this,b,x);case"base64":return J(this,b,x);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Pe(this,b,x);default:if(I)throw new TypeError("Unknown encoding: "+m);m=(m+"").toLowerCase(),I=!0}}function T(m,b,x){var I=m[b];m[b]=m[x],m[x]=I}function N(m,b,x,I,F){if(m.length===0)return-1;if(typeof x=="string"?(I=x,x=0):2147483647<x?x=2147483647:-2147483648>x&&(x=-2147483648),x=+x,j(x)&&(x=F?0:m.length-1),0>x&&(x=m.length+x),x>=m.length){if(F)return-1;x=m.length-1}else if(0>x)if(F)x=0;else return-1;if(typeof b=="string"&&(b=d.from(b,I)),d.isBuffer(b))return b.length===0?-1:_(m,b,x,I,F);if(typeof b=="number")return b&=255,typeof Uint8Array.prototype.indexOf=="function"?F?Uint8Array.prototype.indexOf.call(m,b,x):Uint8Array.prototype.lastIndexOf.call(m,b,x):_(m,[b],x,I,F);throw new TypeError("val must be string, number or Buffer")}function _(m,b,x,I,F){function H(Qn,z){return ne===1?Qn[z]:Qn.readUInt16BE(z*ne)}var ne=1,de=m.length,Me=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,Me/=2,x/=2}var be;if(F){var me=-1;for(be=x;be<de;be++)if(H(m,be)!==H(b,me===-1?0:be-me))me!==-1&&(be-=be-me),me=-1;else if(me===-1&&(me=be),be-me+1===Me)return me*ne}else for(x+Me>de&&(x=de-Me),be=x;0<=be;be--){for(var Ze=!0,An=0;An<Me;An++)if(H(m,be+An)!==H(b,An)){Ze=!1;break}if(Ze)return be}return-1}function A(m,b,x,I){x=+x||0;var F=m.length-x;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[x+de]=ne}return de}function R(m,b,x,I){return at(Ye(b,m.length-x),m,x,I)}function P(m,b,x,I){return at(Ot(b),m,x,I)}function $(m,b,x,I){return P(m,b,x,I)}function V(m,b,x,I){return at(it(b),m,x,I)}function U(m,b,x,I){return at(Ct(b,m.length-x),m,x,I)}function J(m,b,x){return b===0&&x===m.length?q.fromByteArray(m):q.fromByteArray(m.slice(b,x))}function G(m,b,x){x=c(m.length,x);for(var I=[],F=b;F<x;){var H=m[F],ne=null,de=239<H?4:223<H?3:191<H?2:1;if(F+de<=x){var Me,be,me,Ze;de===1?128>H&&(ne=H):de===2?(Me=m[F+1],(192&Me)==128&&(Ze=(31&H)<<6|63&Me,127<Ze&&(ne=Ze))):de===3?(Me=m[F+1],be=m[F+2],(192&Me)==128&&(192&be)==128&&(Ze=(15&H)<<12|(63&Me)<<6|63&be,2047<Ze&&(55296>Ze||57343<Ze)&&(ne=Ze))):de===4&&(Me=m[F+1],be=m[F+2],me=m[F+3],(192&Me)==128&&(192&be)==128&&(192&me)==128&&(Ze=(15&H)<<18|(63&Me)<<12|(63&be)<<6|63&me,65535<Ze&&1114112>Ze&&(ne=Ze)))}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 x="",I=0;I<b;)x+=a.apply(String,m.slice(I,I+=4096));return x}function X(m,b,x){var I="";x=c(m.length,x);for(var F=b;F<x;++F)I+=a(127&m[F]);return I}function we(m,b,x){var I="";x=c(m.length,x);for(var F=b;F<x;++F)I+=a(m[F]);return I}function Re(m,b,x){var I=m.length;(!b||0>b)&&(b=0),(!x||0>x||x>I)&&(x=I);for(var F="",H=b;H<x;++H)F+=Ge(m[H]);return F}function Pe(m,b,x){for(var I=m.slice(b,x),F="",H=0;H<I.length;H+=2)F+=a(I[H]+256*I[H+1]);return F}function xe(m,b,x){if(m%1!=0||0>m)throw new RangeError("offset is not uint");if(m+b>x)throw new RangeError("Trying to access beyond buffer length")}function ye(m,b,x,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(x+I>m.length)throw new RangeError("Index out of range")}function _e(m,b,x,I){if(x+I>m.length)throw new RangeError("Index out of range");if(0>x)throw new RangeError("Index out of range")}function Le(m,b,x,I,F){return b=+b,x>>>=0,F||_e(m,b,x,4),te.write(m,b,x,I,23,4),x+4}function tt(m,b,x,I,F){return b=+b,x>>>=0,F||_e(m,b,x,8),te.write(m,b,x,I,52,8),x+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 x,I=m.length,F=null,H=[],ne=0;ne<I;++ne){if(x=m.charCodeAt(ne),55295<x&&57344>x){if(!F){if(56319<x){-1<(b-=3)&&H.push(239,191,189);continue}else if(ne+1===I){-1<(b-=3)&&H.push(239,191,189);continue}F=x;continue}if(56320>x){-1<(b-=3)&&H.push(239,191,189),F=x;continue}x=(F-55296<<10|x-56320)+65536}else F&&-1<(b-=3)&&H.push(239,191,189);if(F=null,128>x){if(0>(b-=1))break;H.push(x)}else if(2048>x){if(0>(b-=2))break;H.push(192|x>>6,128|63&x)}else if(65536>x){if(0>(b-=3))break;H.push(224|x>>12,128|63&x>>6,128|63&x)}else if(1114112>x){if(0>(b-=4))break;H.push(240|x>>18,128|63&x>>12,128|63&x>>6,128|63&x)}else throw new Error("Invalid code point")}return H}function Ot(m){for(var b=[],x=0;x<m.length;++x)b.push(255&m.charCodeAt(x));return b}function Ct(m,b){for(var x,I,F,H=[],ne=0;ne<m.length&&!(0>(b-=2));++ne)x=m.charCodeAt(ne),I=x>>8,F=x%256,H.push(F),H.push(I);return H}function it(m){return q.toByteArray(nt(m))}function at(m,b,x,I){for(var F=0;F<I&&!(F+x>=b.length||F>=m.length);++F)b[F+x]=m[F];return F}function B(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,x){return f(m,b,x)},d.prototype.__proto__=Uint8Array.prototype,d.__proto__=Uint8Array,d.alloc=function(m,b,x){return p(m,b,x)},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(B(m,Uint8Array)&&(m=d.from(m,m.offset,m.byteLength)),B(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 x=m.length,I=b.length,F=0,H=c(x,I);F<H;++F)if(m[F]!==b[F]){x=m[F],I=b[F];break}return x<I?-1:I<x?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 x;if(b===void 0)for(b=0,x=0;x<m.length;++x)b+=m[x].length;var I=d.allocUnsafe(b),F=0;for(x=0;x<m.length;++x){var H=m[x];if(B(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=k,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,x,I,F){if(B(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),x===void 0&&(x=m?m.length:0),I===void 0&&(I=0),F===void 0&&(F=this.length),0>b||x>m.length||0>I||F>this.length)throw new RangeError("out of range index");if(I>=F&&b>=x)return 0;if(I>=F)return-1;if(b>=x)return 1;if(b>>>=0,x>>>=0,I>>>=0,F>>>=0,this===m)return 0;for(var H=F-I,ne=x-b,de=c(H,ne),Me=this.slice(I,F),be=m.slice(b,x),me=0;me<de;++me)if(Me[me]!==be[me]){H=Me[me],ne=be[me];break}return H<ne?-1:ne<H?1:0},d.prototype.includes=function(m,b,x){return this.indexOf(m,b,x)!==-1},d.prototype.indexOf=function(m,b,x){return N(this,m,b,x,!0)},d.prototype.lastIndexOf=function(m,b,x){return N(this,m,b,x,!1)},d.prototype.write=function(m,b,x,I){if(b===void 0)I="utf8",x=this.length,b=0;else if(x===void 0&&typeof b=="string")I=b,x=this.length,b=0;else if(isFinite(b))b>>>=0,isFinite(x)?(x>>>=0,I===void 0&&(I="utf8")):(I=x,x=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var F=this.length-b;if((x===void 0||x>F)&&(x=F),0<m.length&&(0>x||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,x);case"utf8":case"utf-8":return R(this,m,b,x);case"ascii":return P(this,m,b,x);case"latin1":case"binary":return $(this,m,b,x);case"base64":return V(this,m,b,x);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,m,b,x);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 x=this.length;m=~~m,b=b===void 0?x:~~b,0>m?(m+=x,0>m&&(m=0)):m>x&&(m=x),0>b?(b+=x,0>b&&(b=0)):b>x&&(b=x),b<m&&(b=m);var I=this.subarray(m,b);return I.__proto__=d.prototype,I},d.prototype.readUIntLE=function(m,b,x){m>>>=0,b>>>=0,x||xe(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,x){m>>>=0,b>>>=0,x||xe(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||xe(m,1,this.length),this[m]},d.prototype.readUInt16LE=function(m,b){return m>>>=0,b||xe(m,2,this.length),this[m]|this[m+1]<<8},d.prototype.readUInt16BE=function(m,b){return m>>>=0,b||xe(m,2,this.length),this[m]<<8|this[m+1]},d.prototype.readUInt32LE=function(m,b){return m>>>=0,b||xe(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||xe(m,4,this.length),16777216*this[m]+(this[m+1]<<16|this[m+2]<<8|this[m+3])},d.prototype.readIntLE=function(m,b,x){m>>>=0,b>>>=0,x||xe(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,x){m>>>=0,b>>>=0,x||xe(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||xe(m,1,this.length),128&this[m]?-1*(255-this[m]+1):this[m]},d.prototype.readInt16LE=function(m,b){m>>>=0,b||xe(m,2,this.length);var x=this[m]|this[m+1]<<8;return 32768&x?4294901760|x:x},d.prototype.readInt16BE=function(m,b){m>>>=0,b||xe(m,2,this.length);var x=this[m+1]|this[m]<<8;return 32768&x?4294901760|x:x},d.prototype.readInt32LE=function(m,b){return m>>>=0,b||xe(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||xe(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||xe(m,4,this.length),te.read(this,m,!0,23,4)},d.prototype.readFloatBE=function(m,b){return m>>>=0,b||xe(m,4,this.length),te.read(this,m,!1,23,4)},d.prototype.readDoubleLE=function(m,b){return m>>>=0,b||xe(m,8,this.length),te.read(this,m,!0,52,8)},d.prototype.readDoubleBE=function(m,b){return m>>>=0,b||xe(m,8,this.length),te.read(this,m,!1,52,8)},d.prototype.writeUIntLE=function(m,b,x,I){if(m=+m,b>>>=0,x>>>=0,!I){var F=i(2,8*x)-1;ye(this,m,b,x,F,0)}var H=1,ne=0;for(this[b]=255&m;++ne<x&&(H*=256);)this[b+ne]=255&m/H;return b+x},d.prototype.writeUIntBE=function(m,b,x,I){if(m=+m,b>>>=0,x>>>=0,!I){var F=i(2,8*x)-1;ye(this,m,b,x,F,0)}var H=x-1,ne=1;for(this[b+H]=255&m;0<=--H&&(ne*=256);)this[b+H]=255&m/ne;return b+x},d.prototype.writeUInt8=function(m,b,x){return m=+m,b>>>=0,x||ye(this,m,b,1,255,0),this[b]=255&m,b+1},d.prototype.writeUInt16LE=function(m,b,x){return m=+m,b>>>=0,x||ye(this,m,b,2,65535,0),this[b]=255&m,this[b+1]=m>>>8,b+2},d.prototype.writeUInt16BE=function(m,b,x){return m=+m,b>>>=0,x||ye(this,m,b,2,65535,0),this[b]=m>>>8,this[b+1]=255&m,b+2},d.prototype.writeUInt32LE=function(m,b,x){return m=+m,b>>>=0,x||ye(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,x){return m=+m,b>>>=0,x||ye(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,x,I){if(m=+m,b>>>=0,!I){var F=i(2,8*x-1);ye(this,m,b,x,F-1,-F)}var H=0,ne=1,de=0;for(this[b]=255&m;++H<x&&(ne*=256);)0>m&&de===0&&this[b+H-1]!==0&&(de=1),this[b+H]=255&(m/ne>>0)-de;return b+x},d.prototype.writeIntBE=function(m,b,x,I){if(m=+m,b>>>=0,!I){var F=i(2,8*x-1);ye(this,m,b,x,F-1,-F)}var H=x-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+x},d.prototype.writeInt8=function(m,b,x){return m=+m,b>>>=0,x||ye(this,m,b,1,127,-128),0>m&&(m=255+m+1),this[b]=255&m,b+1},d.prototype.writeInt16LE=function(m,b,x){return m=+m,b>>>=0,x||ye(this,m,b,2,32767,-32768),this[b]=255&m,this[b+1]=m>>>8,b+2},d.prototype.writeInt16BE=function(m,b,x){return m=+m,b>>>=0,x||ye(this,m,b,2,32767,-32768),this[b]=m>>>8,this[b+1]=255&m,b+2},d.prototype.writeInt32LE=function(m,b,x){return m=+m,b>>>=0,x||ye(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,x){return m=+m,b>>>=0,x||ye(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,x){return Le(this,m,b,!0,x)},d.prototype.writeFloatBE=function(m,b,x){return Le(this,m,b,!1,x)},d.prototype.writeDoubleLE=function(m,b,x){return tt(this,m,b,!0,x)},d.prototype.writeDoubleBE=function(m,b,x){return tt(this,m,b,!1,x)},d.prototype.copy=function(m,b,x,I){if(!d.isBuffer(m))throw new TypeError("argument should be a Buffer");if(x||(x=0),I||I===0||(I=this.length),b>=m.length&&(b=m.length),b||(b=0),0<I&&I<x&&(I=x),I===x||m.length===0||this.length===0)return 0;if(0>b)throw new RangeError("targetStart out of bounds");if(0>x||x>=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-x&&(I=m.length-b+x);var F=I-x;if(this===m&&typeof Uint8Array.prototype.copyWithin=="function")this.copyWithin(b,x,I);else if(this===m&&x<b&&b<I)for(var H=F-1;0<=H;--H)m[H+b]=this[H+x];else Uint8Array.prototype.set.call(m,this.subarray(x,I),b);return F},d.prototype.fill=function(m,b,x,I){if(typeof m=="string"){if(typeof b=="string"?(I=b,b=0,x=this.length):typeof x=="string"&&(I=x,x=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<x)throw new RangeError("Out of range index");if(x<=b)return this;b>>>=0,x=x===void 0?this.length:x>>>0,m||(m=0);var H;if(typeof m=="number")for(H=b;H<x;++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<x-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 C=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(k,E)=>{if(k==="%%")return"%";C++;const T=a.formatters[E];if(typeof T=="function"){const N=g[C];k=T.call(v,N),g.splice(C,1),C--}return k}),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,$){var V,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]=$?[P,J]:[J,P]:$?J.unshift(P):J.push(P),V=u(A),0<V&&J.length>V&&!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 $={fired:!1,wrapFn:void 0,target:A,type:R,listener:P},V=f.bind($);return V.listener=P,$.wrapFn=V,V}function p(A,R,P){var $=A._events;if($===void 0)return[];var V=$[R];return V===void 0?[]:typeof V=="function"?P?[V.listener||V]:[V]:P?S(V):v(V,V.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),$=0;$<R;++$)P[$]=A[$];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 C(A,R,P){typeof A.on=="function"&&y(A,"error",R,P)}function y(A,R,P,$){if(typeof A.on=="function")$.once?A.once(R,P):A.on(R,P);else if(typeof A.addEventListener=="function")A.addEventListener(R,function V(U){$.once&&A.removeEventListener(R,V),P(U)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof A)}var k,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)};k=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 N=Number.isNaN||function(A){return A!==A};o.exports=a,o.exports.once=function(A,R){return new Promise(function(P,$){function V(J){A.removeListener(R,U),$(J)}function U(){typeof A.removeListener=="function"&&A.removeListener("error",V),P([].slice.call(arguments))}y(A,R,U,{once:!0}),R!=="error"&&C(A,V,{once:!0})})},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var _=10;Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return _},set:function(A){if(typeof A!="number"||0>A||N(A))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+A+".");_=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||N(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 $=A==="error",V=this._events;if(V!==void 0)$=$&&V.error===void 0;else if(!$)return!1;if($){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=V[A];if(G===void 0)return!1;if(typeof G=="function")T(G,this,R);else for(var ie=G.length,X=v(G,ie),P=0;P<ie;++P)T(X[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,$,V,U,J;if(c(R),$=this._events,$===void 0)return this;if(P=$[A],P===void 0)return this;if(P===R||P.listener===R)--this._eventsCount==0?this._events=Object.create(null):(delete $[A],$.removeListener&&this.emit("removeListener",A,P.listener||R));else if(typeof P!="function"){for(V=-1,U=P.length-1;0<=U;U--)if(P[U]===R||P[U].listener===R){J=P[U].listener,V=U;break}if(0>V)return this;V===0?P.shift():w(P,V),P.length===1&&($[A]=P[0]),$.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,$;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 V,U=Object.keys(P);for($=0;$<U.length;++$)V=U[$],V!=="removeListener"&&this.removeAllListeners(V);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($=R.length-1;0<=$;$--)this.removeListener(A,R[$]);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?k(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,C=u?f-1:0,y=u?-1:1,k=a[c+C];for(C+=y,h=k&(1<<-S)-1,k>>=-S,S+=g;0<S;h=256*h+a[c+C],C+=y,S-=8);for(p=h&(1<<-S)-1,h>>=-S,S+=d;0<S;p=256*p+a[c+C],C+=y,S-=8);if(h===0)h=1-w;else{if(h===v)return p?NaN:(k?-1:1)*(1/0);p+=i(2,d),h-=w}return(k?-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,C=8*h-f-1,y=(1<<C)-1,k=y>>1,E=f===23?i(2,-24)-i(2,-77):0,T=d?0:h-1,N=d?1:-1,_=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=t(S(c)/w),1>c*(v=i(2,-p))&&(p--,v*=2),c+=1<=p+k?E/v:E*i(2,1-k),2<=c*v&&(p++,v/=2),p+k>=y?(g=0,p=y):1<=p+k?(g=(c*v-1)*i(2,f),p+=k):(g=c*i(2,k-1)*i(2,f),p=0));8<=f;a[u+T]=255&g,T+=N,g/=256,f-=8);for(p=p<<f|g,C+=f;0<C;a[u+T]=255&p,T+=N,p/=256,C-=8);a[u+T-N]|=128*_}},{}],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?C=S.concat(C):k=-1,C.length&&f())}function f(){if(!y){var E=c(d);y=!0;for(var T=C.length;T;){for(S=C,C=[];++k<T;)S&&S[k].run();k=-1,T=C.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,C=[],y=!1,k=-1;w.nextTick=function(E){var T=Array(arguments.length-1);if(1<arguments.length)for(var N=1;N<arguments.length;N++)T[N-1]=arguments[N];C.push(new h(E,T)),C.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 On>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:On)},{}],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.
310
- Use Chrome, Firefox or Internet Explorer 11`)}}).call(this)}).call(this,s("_process"),typeof On>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:On)},{_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(C,y,k){return typeof g=="string"?g:g(C,y,k)}v||(v=Error);var S=function(C){function y(k,E,T){return C.call(this,w(k,E,T))||this}return l(y,C),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 C=f(p,".")?"property":"argument";S='The "'.concat(p,'" ').concat(C," ").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 C in w)S.push(C);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 Pe.from(M)}function u(M){return Pe.isBuffer(M)||M instanceof xe}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&&(!_e&&(_e=s("string_decoder/").StringDecoder),this.decoder=new _e(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)),Re.call(this)}function p(M,m,b,x,I){X("readableAddChunk",m);var F=M._readableState;if(m===null)F.reading=!1,C(M,F);else{var H;if(I||(H=v(F,m)),H)q(M,H);else if(!(F.objectMode||m&&0<m.length))x||(F.reading=!1,E(M,F));else if(typeof m=="string"||F.objectMode||Object.getPrototypeOf(m)===Pe.prototype||(m=c(m)),x)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,x){m.flowing&&m.length===0&&!m.sync?(m.awaitDrain=0,M.emit("data",b)):(m.length+=m.objectMode?1:b.length,x?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 C(M,m){if(X("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,k(M)))}}function y(M){var m=M._readableState;X("emitReadable",m.needReadable,m.emittedReadable),m.needReadable=!1,m.emittedReadable||(X("emitReadable",m.flowing),m.emittedReadable=!0,l.nextTick(k,M))}function k(M){var m=M._readableState;X("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,$(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(X("maybeReadMore read 0"),M.read(0),b===m.length)break}m.readingMore=!1}function N(M){return function(){var m=M._readableState;X("pipeOnDrain",m.awaitDrain),m.awaitDrain&&m.awaitDrain--,m.awaitDrain===0&&we(M,"data")&&(m.flowing=!0,$(M))}}function _(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){X("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){X("resume",m.reading),m.reading||M.read(0),m.resumeScheduled=!1,M.emit("resume"),$(M),m.flowing&&!m.reading&&M.read(0)}function $(M){var m=M._readableState;for(X("flow",m.flowing);m.flowing&&M.read()!==null;);}function V(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;X("endReadable",m.endEmitted),m.endEmitted||(m.ended=!0,l.nextTick(J,m,M))}function J(M,m){if(X("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,x=M.length;b<x;b++)if(M[b]===m)return b;return-1}o.exports=h;var ie;h.ReadableState=f;var X;s("events").EventEmitter;var we=function(M,m){return M.listeners(m).length},Re=s("./internal/streams/stream"),Pe=s("buffer").Buffer,xe=a.Uint8Array||function(){},ye=s("util");X=ye&&ye.debuglog?ye.debuglog("stream"):function(){};var _e,Le,tt,nt=s("./internal/streams/buffer_list"),Ge=s("./internal/streams/destroy"),Ye=s("./internal/streams/state"),Ot=Ye.getHighWaterMark,Ct=s("../errors").codes,it=Ct.ERR_INVALID_ARG_TYPE,at=Ct.ERR_STREAM_PUSH_AFTER_EOF,B=Ct.ERR_METHOD_NOT_IMPLEMENTED,j=Ct.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;s("inherits")(h,Re);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,x=this._readableState;return x.objectMode?b=!0:typeof M=="string"&&(m=m||x.defaultEncoding,m!==x.encoding&&(M=Pe.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){_e||(_e=s("string_decoder/").StringDecoder);var m=new _e(M);this._readableState.decoder=m,this._readableState.encoding=this._readableState.decoder.encoding;for(var b=this._readableState.buffer.head,x="";b!==null;)x+=m.write(b.data),b=b.next;return this._readableState.buffer.clear(),x!==""&&this._readableState.buffer.push(x),this._readableState.length=x.length,this},h.prototype.read=function(M){X("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 X("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 x=m.needReadable;X("need readable",x),(m.length===0||m.length-M<m.highWaterMark)&&(x=!0,X("length less than watermark",x)),m.ended||m.reading?(x=!1,X("reading or ended",x)):x&&(X("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?V(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 B("_read()"))},h.prototype.pipe=function(M,m){function b(ee,oe){X("onunpipe"),ee===be&&oe&&oe.hasUnpiped===!1&&(oe.hasUnpiped=!0,I())}function x(){X("onend"),M.end()}function I(){X("cleanup"),M.removeListener("close",ne),M.removeListener("finish",de),M.removeListener("drain",Qn),M.removeListener("error",H),M.removeListener("unpipe",b),be.removeListener("end",x),be.removeListener("end",Me),be.removeListener("data",F),z=!0,me.awaitDrain&&(!M._writableState||M._writableState.needDrain)&&Qn()}function F(ee){X("ondata");var oe=M.write(ee);X("dest.write",oe),oe===!1&&((me.pipesCount===1&&me.pipes===M||1<me.pipesCount&&G(me.pipes,M)!==-1)&&!z&&(X("false write response, pause",me.awaitDrain),me.awaitDrain++),be.pause())}function H(ee){X("onerror",ee),Me(),M.removeListener("error",H),we(M,"error")===0&&q(M,ee)}function ne(){M.removeListener("finish",de),Me()}function de(){X("onfinish"),M.removeListener("close",ne),Me()}function Me(){X("unpipe"),be.unpipe(M)}var be=this,me=this._readableState;switch(me.pipesCount){case 0:me.pipes=M;break;case 1:me.pipes=[me.pipes,M];break;default:me.pipes.push(M)}me.pipesCount+=1,X("pipe count=%d opts=%j",me.pipesCount,m);var Ze=(!m||m.end!==!1)&&M!==l.stdout&&M!==l.stderr,An=Ze?x:Me;me.endEmitted?l.nextTick(An):be.once("end",An),M.on("unpipe",b);var Qn=N(be);M.on("drain",Qn);var z=!1;return be.on("data",F),d(M,"error",H),M.once("close",ne),M.once("finish",de),M.emit("pipe",be),me.flowing||(X("pipe resume"),be.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 x=m.pipes,I=m.pipesCount;m.pipes=null,m.pipesCount=0,m.flowing=!1;for(var F=0;F<I;F++)x[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=Re.prototype.on.call(this,M,m),x=this._readableState;return M==="data"?(x.readableListening=0<this.listenerCount("readable"),x.flowing!==!1&&this.resume()):M=="readable"&&!x.endEmitted&&!x.readableListening&&(x.readableListening=x.needReadable=!0,x.flowing=!1,x.emittedReadable=!1,X("on readable",x.length,x.reading),x.length?y(this):!x.reading&&l.nextTick(A,this)),b},h.prototype.addListener=h.prototype.on,h.prototype.removeListener=function(M,m){var b=Re.prototype.removeListener.call(this,M,m);return M==="readable"&&l.nextTick(_,this),b},h.prototype.removeAllListeners=function(M){var m=Re.prototype.removeAllListeners.apply(this,arguments);return(M==="readable"||M===void 0)&&l.nextTick(_,this),m},h.prototype.resume=function(){var M=this._readableState;return M.flowing||(X("resume"),M.flowing=!M.readableListening,R(this,M)),M.paused=!1,this},h.prototype.pause=function(){return X("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(X("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},h.prototype.wrap=function(M){var m=this,b=this._readableState,x=!1;for(var I in M.on("end",function(){if(X("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(X("wrapped data"),b.decoder&&(H=b.decoder.write(H)),!(b.objectMode&&H==null)&&(b.objectMode||H&&H.length)){var ne=m.push(H);ne||(x=!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){X("wrapped _read",H),x&&(x=!1,M.resume())},this},typeof Symbol=="function"&&(h.prototype[Symbol.asyncIterator]=function(){return Le===void 0&&(Le=s("./internal/streams/async_iterator")),Le(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=V,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 On>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:On)},{"../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 C=this._transformState;C.transforming=!1;var y=C.writecb;if(y===null)return this.emit("error",new h);C.writechunk=null,C.writecb=null,S!=null&&this.push(S),y(w);var k=this._readableState;k.reading=!1,(k.needReadable||k.length<k.highWaterMark)&&this._read(k.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,C){u(w,S,C)})}function u(w,S,C){if(S)return w.emit("error",S);if(C!=null&&w.push(C),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,C){C(new f("_transform()"))},a.prototype._write=function(w,S,C){var y=this._transformState;if(y.writecb=C,y.writechunk=w,y.writeencoding=S,!y.transforming){var k=this._readableState;(y.needTransform||k.needReadable||k.length<k.highWaterMark)&&this._read(k.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(C){S(C)})}},{"../errors":15,"./_stream_duplex":16,inherits:10}],20:[function(s,o){(function(l,a){(function(){function c(B){var j=this;this.next=null,this.entry=null,this.finish=function(){U(j,B)}}function u(B){return X.from(B)}function d(B){return X.isBuffer(B)||B instanceof we}function f(){}function h(B,j,q){J=J||s("./_stream_duplex"),B=B||{},typeof q!="boolean"&&(q=j instanceof J),this.objectMode=!!B.objectMode,q&&(this.objectMode=this.objectMode||!!B.writableObjectMode),this.highWaterMark=xe(this,B,"writableHighWaterMark",q),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var te=B.decodeStrings===!1;this.decodeStrings=!te,this.defaultEncoding=B.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=B.emitClose!==!1,this.autoDestroy=!!B.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new c(this)}function p(B){J=J||s("./_stream_duplex");var j=this instanceof J;return j||at.call(p,this)?(this._writableState=new h(B,this,j),this.writable=!0,B&&(typeof B.write=="function"&&(this._write=B.write),typeof B.writev=="function"&&(this._writev=B.writev),typeof B.destroy=="function"&&(this._destroy=B.destroy),typeof B.final=="function"&&(this._final=B.final)),void ie.call(this)):new p(B)}function g(B,j){var q=new Ot;it(B,q),l.nextTick(j,q)}function v(B,j,q,te){var M;return q===null?M=new Ye:typeof q!="string"&&!j.objectMode&&(M=new _e("chunk",["string","Buffer"],q)),!M||(it(B,M),l.nextTick(te,M),!1)}function w(B,j,q){return B.objectMode||B.decodeStrings===!1||typeof j!="string"||(j=X.from(j,q)),j}function S(B,j,q,te,M,m){if(!q){var b=w(j,te,M);te!==b&&(q=!0,M="buffer",te=b)}var x=j.objectMode?1:te.length;j.length+=x;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 C(B,j,!1,x,te,M,m);return I}function C(B,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?B._writev(M,j.onwrite):B._write(M,m,j.onwrite),j.sync=!1}function y(B,j,q,te,M){--j.pendingcb,q?(l.nextTick(M,te),l.nextTick($,B,j),B._writableState.errorEmitted=!0,it(B,te)):(M(te),B._writableState.errorEmitted=!0,it(B,te),$(B,j))}function k(B){B.writing=!1,B.writecb=null,B.length-=B.writelen,B.writelen=0}function E(B,j){var q=B._writableState,te=q.sync,M=q.writecb;if(typeof M!="function")throw new tt;if(k(q),j)y(B,q,te,j,M);else{var m=A(q)||B.destroyed;m||q.corked||q.bufferProcessing||!q.bufferedRequest||_(B,q),te?l.nextTick(T,B,q,m,M):T(B,q,m,M)}}function T(B,j,q,te){q||N(B,j),j.pendingcb--,te(),$(B,j)}function N(B,j){j.length===0&&j.needDrain&&(j.needDrain=!1,B.emit("drain"))}function _(B,j){j.bufferProcessing=!0;var q=j.bufferedRequest;if(B._writev&&q&&q.next){var te=j.bufferedRequestCount,M=Array(te),m=j.corkedRequestsFree;m.entry=q;for(var b=0,x=!0;q;)M[b]=q,q.isBuf||(x=!1),q=q.next,b+=1;M.allBuffers=x,C(B,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(C(B,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(B){return B.ending&&B.length===0&&B.bufferedRequest===null&&!B.finished&&!B.writing}function R(B,j){B._final(function(q){j.pendingcb--,q&&it(B,q),j.prefinished=!0,B.emit("prefinish"),$(B,j)})}function P(B,j){j.prefinished||j.finalCalled||(typeof B._final!="function"||j.destroyed?(j.prefinished=!0,B.emit("prefinish")):(j.pendingcb++,j.finalCalled=!0,l.nextTick(R,B,j)))}function $(B,j){var q=A(j);if(q&&(P(B,j),j.pendingcb===0&&(j.finished=!0,B.emit("finish"),j.autoDestroy))){var te=B._readableState;(!te||te.autoDestroy&&te.endEmitted)&&B.destroy()}return q}function V(B,j,q){j.ending=!0,$(B,j),q&&(j.finished?l.nextTick(q):B.once("finish",q)),j.ended=!0,B.writable=!1}function U(B,j,q){var te=B.entry;for(B.entry=null;te;){var M=te.callback;j.pendingcb--,M(q),te=te.next}j.corkedRequestsFree.next=B}o.exports=p;var J;p.WritableState=h;var G={deprecate:s("util-deprecate")},ie=s("./internal/streams/stream"),X=s("buffer").Buffer,we=a.Uint8Array||function(){},Re=s("./internal/streams/destroy"),Pe=s("./internal/streams/state"),xe=Pe.getHighWaterMark,ye=s("../errors").codes,_e=ye.ERR_INVALID_ARG_TYPE,Le=ye.ERR_METHOD_NOT_IMPLEMENTED,tt=ye.ERR_MULTIPLE_CALLBACK,nt=ye.ERR_STREAM_CANNOT_PIPE,Ge=ye.ERR_STREAM_DESTROYED,Ye=ye.ERR_STREAM_NULL_VALUES,Ot=ye.ERR_STREAM_WRITE_AFTER_END,Ct=ye.ERR_UNKNOWN_ENCODING,it=Re.errorOrDestroy;s("inherits")(p,ie),h.prototype.getBuffer=function(){for(var B=this.bufferedRequest,j=[];B;)j.push(B),B=B.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(B){return!!at.call(this,B)||this===p&&B&&B._writableState instanceof h}})):at=function(B){return B instanceof this},p.prototype.pipe=function(){it(this,new nt)},p.prototype.write=function(B,j,q){var te=this._writableState,M=!1,m=!te.objectMode&&d(B);return m&&!X.isBuffer(B)&&(B=u(B)),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,B,q))&&(te.pendingcb++,M=S(this,te,m,B,j,q)),M},p.prototype.cork=function(){this._writableState.corked++},p.prototype.uncork=function(){var B=this._writableState;B.corked&&(B.corked--,!B.writing&&!B.corked&&!B.bufferProcessing&&B.bufferedRequest&&_(this,B))},p.prototype.setDefaultEncoding=function(B){if(typeof B=="string"&&(B=B.toLowerCase()),!(-1<["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((B+"").toLowerCase())))throw new Ct(B);return this._writableState.defaultEncoding=B,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(B,j,q){q(new Le("_write()"))},p.prototype._writev=null,p.prototype.end=function(B,j,q){var te=this._writableState;return typeof B=="function"?(q=B,B=null,j=null):typeof j=="function"&&(q=j,j=null),B!=null&&this.write(B,j),te.corked&&(te.corked=1,this.uncork()),te.ending||V(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(B){this._writableState&&(this._writableState.destroyed=B)}}),p.prototype.destroy=Re.destroy,p.prototype._undestroy=Re.undestroy,p.prototype._destroy=function(B,j){j(B)}}).call(this)}).call(this,s("_process"),typeof On>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:On)},{"../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(N,_,A){return _ in N?Object.defineProperty(N,_,{value:A,enumerable:!0,configurable:!0,writable:!0}):N[_]=A,N}function c(N,_){return{value:N,done:_}}function u(N){var _=N[g];if(_!==null){var A=N[k].read();A!==null&&(N[C]=null,N[g]=null,N[v]=null,_(c(A,!1)))}}function d(N){l.nextTick(u,N)}function f(N,_){return function(A,R){N.then(function(){return _[S]?void A(c(void 0,!0)):void _[y](A,R)},R)}}var h,p=s("./end-of-stream"),g=Symbol("lastResolve"),v=Symbol("lastReject"),w=Symbol("error"),S=Symbol("ended"),C=Symbol("lastPromise"),y=Symbol("handlePromise"),k=Symbol("stream"),E=Object.getPrototypeOf(function(){}),T=Object.setPrototypeOf((h={get stream(){return this[k]},next:function(){var N=this,_=this[w];if(_!==null)return Promise.reject(_);if(this[S])return Promise.resolve(c(void 0,!0));if(this[k].destroyed)return new Promise(function($,V){l.nextTick(function(){N[w]?V(N[w]):$(c(void 0,!0))})});var A,R=this[C];if(R)A=new Promise(f(R,this));else{var P=this[k].read();if(P!==null)return Promise.resolve(c(P,!1));A=new Promise(this[y])}return this[C]=A,A}},a(h,Symbol.asyncIterator,function(){return this}),a(h,"return",function(){var N=this;return new Promise(function(_,A){N[k].destroy(null,function(R){return R?void A(R):void _(c(void 0,!0))})})}),h),E);o.exports=function(N){var _,A=Object.create(T,(_={},a(_,k,{value:N,writable:!0}),a(_,g,{value:null,writable:!0}),a(_,v,{value:null,writable:!0}),a(_,w,{value:null,writable:!0}),a(_,S,{value:N._readableState.endEmitted,writable:!0}),a(_,y,{value:function(R,P){var $=A[k].read();$?(A[C]=null,A[g]=null,A[v]=null,R(c($,!1))):(A[g]=R,A[v]=P)},writable:!0}),_));return A[C]=null,p(N,function(R){if(R&&R.code!=="ERR_STREAM_PREMATURE_CLOSE"){var P=A[v];return P!==null&&(A[C]=null,A[g]=null,A[v]=null,P(R)),void(A[w]=R)}var $=A[g];$!==null&&(A[C]=null,A[g]=null,A[v]=null,$(c(void 0,!0))),A[S]=!0}),N.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(C,y){var k=Object.keys(C);if(Object.getOwnPropertySymbols){var E=Object.getOwnPropertySymbols(C);y&&(E=E.filter(function(T){return Object.getOwnPropertyDescriptor(C,T).enumerable})),k.push.apply(k,E)}return k}function a(C){for(var y,k=1;k<arguments.length;k++)y=arguments[k]==null?{}:arguments[k],k%2?l(Object(y),!0).forEach(function(E){c(C,E,y[E])}):Object.getOwnPropertyDescriptors?Object.defineProperties(C,Object.getOwnPropertyDescriptors(y)):l(Object(y)).forEach(function(E){Object.defineProperty(C,E,Object.getOwnPropertyDescriptor(y,E))});return C}function c(C,y,k){return y in C?Object.defineProperty(C,y,{value:k,enumerable:!0,configurable:!0,writable:!0}):C[y]=k,C}function u(C,y){if(!(C instanceof y))throw new TypeError("Cannot call a class as a function")}function d(C,y){for(var k,E=0;E<y.length;E++)k=y[E],k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(C,k.key,k)}function f(C,y,k){return y&&d(C.prototype,y),C}function h(C,y,k){g.prototype.copy.call(C,y,k)}var p=s("buffer"),g=p.Buffer,v=s("util"),w=v.inspect,S=w&&w.custom||"inspect";o.exports=function(){function C(){u(this,C),this.head=null,this.tail=null,this.length=0}return f(C,[{key:"push",value:function(y){var k={data:y,next:null};0<this.length?this.tail.next=k:this.head=k,this.tail=k,++this.length}},{key:"unshift",value:function(y){var k={data:y,next:this.head};this.length===0&&(this.tail=k),this.head=k,++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 k=this.head,E=""+k.data;k=k.next;)E+=y+k.data;return E}},{key:"concat",value:function(y){if(this.length===0)return g.alloc(0);for(var k=g.allocUnsafe(y>>>0),E=this.head,T=0;E;)h(E.data,k,T),T+=E.data.length,E=E.next;return k}},{key:"consume",value:function(y,k){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=k?this._getString(y):this._getBuffer(y),E}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(y){var k=this.head,E=1,T=k.data;for(y-=T.length;k=k.next;){var N=k.data,_=y>N.length?N.length:y;if(T+=_===N.length?N:N.slice(0,y),y-=_,y===0){_===N.length?(++E,this.head=k.next?k.next:this.tail=null):(this.head=k,k.data=N.slice(_));break}++E}return this.length-=E,T}},{key:"_getBuffer",value:function(y){var k=g.allocUnsafe(y),E=this.head,T=1;for(E.data.copy(k),y-=E.data.length;E=E.next;){var N=E.data,_=y>N.length?N.length:y;if(N.copy(k,k.length-y,0,_),y-=_,y===0){_===N.length?(++T,this.head=E.next?E.next:this.tail=null):(this.head=E,E.data=N.slice(_));break}++T}return this.length-=T,k}},{key:S,value:function(y,k){return w(this,a({},k,{depth:0,customInspect:!1}))}}]),C}()},{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||C()},S=f._writableState&&f._writableState.finished,C=function(){v=!1,S=!0,g||p.call(f)},y=f._readableState&&f._readableState.endEmitted,k=function(){g=!1,y=!0,v||p.call(f)},E=function(_){p.call(f,_)},T=function(){var _;return g&&!y?(f._readableState&&f._readableState.ended||(_=new d),p.call(f,_)):v&&!S?(f._writableState&&f._writableState.ended||(_=new d),p.call(f,_)):void 0},N=function(){f.req.on("finish",C)};return c(f)?(f.on("complete",C),f.on("abort",T),f.req?N():f.on("request",N)):v&&!f._writableState&&(f.on("end",w),f.on("close",w)),f.on("end",k),f.on("finish",C),h.error!==!1&&f.on("error",E),f.on("close",T),function(){f.removeListener("complete",C),f.removeListener("abort",T),f.removeListener("request",N),f.req&&f.req.removeListener("finish",C),f.removeListener("end",w),f.removeListener("close",w),f.removeListener("finish",C),f.removeListener("end",k),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 C=!1;return function(){C||(C=!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,C,y,k){k=l(k);var E=!1;S.on("close",function(){E=!0}),p===void 0&&(p=s("./end-of-stream")),p(S,{readable:C,writable:y},function(N){return N?k(N):(E=!0,void k())});var T=!1;return function(N){if(!E)return T?void 0:(T=!0,c(S)?S.abort():typeof S.destroy=="function"?S.destroy():void k(N||new w("pipe")))}}function d(S){S()}function f(S,C){return S.pipe(C)}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,C=Array(S),y=0;y<S;y++)C[y]=arguments[y];var k=h(C);if(Array.isArray(C[0])&&(C=C[0]),2>C.length)throw new v("streams");var E,T=C.map(function(N,_){var A=_<C.length-1;return u(N,A,0<_,function(R){E||(E=R),R&&T.forEach(d),A||(T.forEach(d),k(E))})});return C.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)&&t(h)===h)||0>h){var p=f?d:"highWaterMark";throw new a(p,h)}return t(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 N;;)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(N)return;T=(""+T).toLowerCase(),N=!0}}function c(T){var N=a(T);if(typeof N!="string"&&(k.isEncoding===E||!E(T)))throw new Error("Unknown encoding: "+T);return N||T}function u(T){this.encoding=c(T);var N;switch(this.encoding){case"utf16le":this.text=g,this.end=v,N=4;break;case"utf8":this.fillLast=p,N=4;break;case"base64":this.text=w,this.end=S,N=3;break;default:return this.write=C,void(this.end=y)}this.lastNeed=0,this.lastTotal=0,this.lastChar=k.allocUnsafe(N)}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,N,_){var A=N.length-1;if(A<_)return 0;var R=d(N[A]);return 0<=R?(0<R&&(T.lastNeed=R-1),R):--A<_||R===-2?0:(R=d(N[A]),0<=R?(0<R&&(T.lastNeed=R-2),R):--A<_||R===-2?0:(R=d(N[A]),0<=R?(0<R&&(R===2?R=0:T.lastNeed=R-3),R):0))}function h(T,N){if((192&N[0])!=128)return T.lastNeed=0,"�";if(1<T.lastNeed&&1<N.length){if((192&N[1])!=128)return T.lastNeed=1,"�";if(2<T.lastNeed&&2<N.length&&(192&N[2])!=128)return T.lastNeed=2,"�"}}function p(T){var N=this.lastTotal-this.lastNeed,_=h(this,T);return _===void 0?this.lastNeed<=T.length?(T.copy(this.lastChar,N,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(T.copy(this.lastChar,N,0,T.length),void(this.lastNeed-=T.length)):_}function g(T,N){if((T.length-N)%2==0){var _=T.toString("utf16le",N);if(_){var A=_.charCodeAt(_.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],_.slice(0,-1)}return _}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=T[T.length-1],T.toString("utf16le",N,T.length-1)}function v(T){var N=T&&T.length?this.write(T):"";if(this.lastNeed){var _=this.lastTotal-this.lastNeed;return N+this.lastChar.toString("utf16le",0,_)}return N}function w(T,N){var _=(T.length-N)%3;return _==0?T.toString("base64",N):(this.lastNeed=3-_,this.lastTotal=3,_==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",N,T.length-_))}function S(T){var N=T&&T.length?this.write(T):"";return this.lastNeed?N+this.lastChar.toString("base64",0,3-this.lastNeed):N}function C(T){return T.toString(this.encoding)}function y(T){return T&&T.length?this.write(T):""}var k=s("safe-buffer").Buffer,E=k.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 N,_;if(this.lastNeed){if(N=this.fillLast(T),N===void 0)return"";_=this.lastNeed,this.lastNeed=0}else _=0;return _<T.length?N?N+this.text(T,_):this.text(T,_):N||""},u.prototype.end=function(T){var N=T&&T.length?this.write(T):"";return this.lastNeed?N+"�":N},u.prototype.text=function(T,N){var _=f(this,T,N);if(!this.lastNeed)return T.toString("utf8",N);this.lastTotal=_;var A=T.length-(_-this.lastNeed);return T.copy(this.lastChar,0,A),T.toString("utf8",N,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 On>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:On)},{}],"/":[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(C){if(C=Object.assign({allowHalfOpen:!1},C),super(C),this._id=d(4).toString("hex").slice(0,7),this._debug("new peer %o",C),this.channelName=C.initiator?C.channelName||d(20).toString("hex"):null,this.initiator=C.initiator||!1,this.channelConfig=C.channelConfig||w.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},w.config,C.config),this.offerOptions=C.offerOptions||{},this.answerOptions=C.answerOptions||{},this.sdpTransform=C.sdpTransform||(y=>y),this.streams=C.streams||(C.stream?[C.stream]:[]),this.trickle=C.trickle===void 0||C.trickle,this.allowHalfTrickle=C.allowHalfTrickle!==void 0&&C.allowHalfTrickle,this.iceCompleteTimeout=C.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=C.wrtc&&typeof C.wrtc=="object"?C.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(C){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof C=="string")try{C=JSON.parse(C)}catch{C={}}this._debug("signal()"),C.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),C.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(C.transceiverRequest.kind,C.transceiverRequest.init)),C.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(C.candidate):this._pendingCandidates.push(C.candidate)),C.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(C)).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"))}),C.sdp||C.candidate||C.renegotiate||C.transceiverRequest||this.destroy(p(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(C){const y=new this._wrtc.RTCIceCandidate(C);this._pc.addIceCandidate(y).catch(k=>{!y.address||y.address.endsWith(".local")?a("Ignoring unsupported ICE candidate."):this.destroy(p(k,"ERR_ADD_ICE_CANDIDATE"))})}send(C){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(C)}}addTransceiver(C,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(C,y),this._needsNegotiation()}catch(k){this.destroy(p(k,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:C,init:y}})}}addStream(C){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),C.getTracks().forEach(y=>{this.addTrack(y,C)})}}addTrack(C,y){if(this.destroying)return;if(this.destroyed)throw p(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const k=this._senderMap.get(C)||new Map;let E=k.get(y);if(!E)E=this._pc.addTrack(C,y),k.set(y,E),this._senderMap.set(C,k),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(C,y,k){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(C),T=E?E.get(k):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(C,y){if(this.destroying)return;if(this.destroyed)throw p(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const k=this._senderMap.get(C),E=k?k.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(C){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),C.getTracks().forEach(y=>{this.removeTrack(y,C)})}}_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(C){this._destroy(C,()=>{})}_destroy(C,y){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",C&&(C.message||C)),h(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",C&&(C.message||C)),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,C&&this.emit("error",C),this.emit("close"),y()}))}_setupData(C){if(!C.channel)return this.destroy(p(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=C.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=v),this.channelName=this._channel.label,this._channel.onmessage=k=>{this._onChannelMessage(k)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=k=>{const E=k.error instanceof Error?k.error:new Error(`Datachannel error: ${k.message} ${k.filename}:${k.lineno}:${k.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(C,y,k){if(this.destroyed)return k(p(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(C)}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=k):k(null)}else this._debug("write before connect"),this._chunk=C,this._cb=k}_onFinish(){if(!this.destroyed){const C=()=>{setTimeout(()=>this.destroy(),1e3)};this._connected?C():this.once("connect",C)}}_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(C=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(C.sdp=l(C.sdp)),C.sdp=this.sdpTransform(C.sdp);const y=()=>{if(!this.destroyed){const k=this._pc.localDescription||C;this._debug("signal"),this.emit("signal",{type:k.type,sdp:k.sdp})}};this._pc.setLocalDescription(C).then(()=>{this._debug("createOffer success"),this.destroyed||(this.trickle||this._iceComplete?y():this.once("_iceComplete",y))}).catch(k=>{this.destroy(p(k,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(C=>{this.destroy(p(C,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(C=>{C.mid||!C.sender.track||C.requested||(C.requested=!0,this.addTransceiver(C.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(C=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(C.sdp=l(C.sdp)),C.sdp=this.sdpTransform(C.sdp);const y=()=>{if(!this.destroyed){const k=this._pc.localDescription||C;this._debug("signal"),this.emit("signal",{type:k.type,sdp:k.sdp}),this.initiator||this._requestMissingTransceivers()}};this._pc.setLocalDescription(C).then(()=>{this.destroyed||(this.trickle||this._iceComplete?y():this.once("_iceComplete",y))}).catch(k=>{this.destroy(p(k,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(C=>{this.destroy(p(C,"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 C=this._pc.iceConnectionState,y=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",C,y),this.emit("iceStateChange",C,y),(C==="connected"||C==="completed")&&(this._pcReady=!0,this._maybeReady()),C==="failed"&&this.destroy(p(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),C==="closed"&&this.destroy(p(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(C){const y=k=>(Object.prototype.toString.call(k.values)==="[object Array]"&&k.values.forEach(E=>{Object.assign(k,E)}),k);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(k=>{const E=[];k.forEach(T=>{E.push(y(T))}),C(null,E)},k=>C(k)):0<this._pc.getStats.length?this._pc.getStats(k=>{if(this.destroyed)return;const E=[];k.result().forEach(T=>{const N={};T.names().forEach(_=>{N[_]=T.stat(_)}),N.id=T.id,N.type=T.type,N.timestamp=T.timestamp,E.push(y(N))}),C(null,E)},k=>C(k)):C(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 C=()=>{this.destroyed||this.getStats((y,k)=>{if(this.destroyed)return;y&&(k=[]);const E={},T={},N={};let _=!1;k.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")&&(N[R.id]=R)});const A=R=>{_=!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 $=E[R.remoteCandidateId];$&&($.ip||$.address)?(this.remoteAddress=$.ip||$.address,this.remotePort=+$.port):$&&$.ipAddress?(this.remoteAddress=$.ipAddress,this.remotePort=+$.portNumber):typeof R.googRemoteAddress=="string"&&($=R.googRemoteAddress.split(":"),this.remoteAddress=$[0],this.remotePort=+$[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(k.forEach(R=>{R.type==="transport"&&R.selectedCandidatePairId&&A(N[R.selectedCandidatePairId]),(R.type==="googCandidatePair"&&R.googActiveConnection==="true"||(R.type==="candidatepair"||R.type==="candidate-pair")&&R.selected)&&A(R)}),!_&&(!Object.keys(N).length||Object.keys(T).length))return void setTimeout(C,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")})};C()}_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(C=>{this._pc.removeTrack(C),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(C){this.destroyed||(C.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:C.candidate.candidate,sdpMLineIndex:C.candidate.sdpMLineIndex,sdpMid:C.candidate.sdpMid}}):!C.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),C.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(C){if(this.destroyed)return;let y=C.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 C=this._cb;this._cb=null,C(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(C){this.destroyed||C.streams.forEach(y=>{this._debug("on track"),this.emit("track",C.track,y),this._remoteTracks.push({track:C.track,stream:y}),this._remoteStreams.some(k=>k.id===y.id)||(this._remoteStreams.push(y),h(()=>{this._debug("on stream"),this.emit("stream",y)}))})}_debug(){const C=[].slice.call(arguments);C[0]="["+this._id+"] "+C[0],c.apply(null,C)}}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}]},{},[])("/")})})(yb);var xO=yb.exports;const kO=Nc(xO),nf=0,rf=1,bb=2,vb=(n,e)=>{ae(n,nf);const t=bM(e);Xe(n,t)},wb=(n,e,t)=>{ae(n,rf),Xe(n,pM(e,t))},SO=(n,e,t)=>wb(e,t,bt(n)),Cb=(n,e,t)=>{try{dM(e,bt(n),t)}catch(r){console.error("Caught error while handling a Yjs update",r)}},EO=(n,e)=>{ae(n,bb),Xe(n,e)},TO=Cb,AO=(n,e,t,r)=>{const i=he(n);switch(i){case nf:SO(n,e,t);break;case rf:Cb(n,t,r);break;case bb:TO(n,t,r);break;default:throw new Error("Unknown message type")}return i},sf=3e4;class MO extends D0{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=Bn();this.getLocalState()!==null&&sf/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const r=[];this.meta.forEach((i,s)=>{s!==this.clientID&&sf<=t-i.lastUpdated&&this.states.has(s)&&r.push(s)}),r.length>0&&of(this,r,"timeout")},wn(sf/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 t=this.clientID,r=this.meta.get(t),i=r===void 0?0:r.clock+1,s=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:i,lastUpdated:Bn()});const o=[],l=[],a=[],c=[];e===null?c.push(t):s==null?e!=null&&o.push(t):(l.push(t),Eo(s,e)||a.push(t)),(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,t){const r=this.getLocalState();r!==null&&this.setLocalState({...r,[e]:t})}getStates(){return this.states}}const of=(n,e,t)=>{const r=[];for(let i=0;i<e.length;i++){const s=e[i];if(n.states.has(s)){if(n.states.delete(s),s===n.clientID){const o=n.meta.get(s);n.meta.set(s,{clock:o.clock+1,lastUpdated:Bn()})}r.push(s)}}r.length>0&&(n.emit("change",[{added:[],updated:[],removed:r},t]),n.emit("update",[{added:[],updated:[],removed:r},t]))},ma=(n,e,t=n.states)=>{const r=e.length,i=gt();ae(i,r);for(let s=0;s<r;s++){const o=e[s],l=t.get(o)||null,a=n.meta.get(o).clock;ae(i,o),ae(i,a),jn(i,JSON.stringify(l))}return qe(i)},OO=(n,e,t)=>{const r=Hn(e),i=Bn(),s=[],o=[],l=[],a=[],c=he(r);for(let u=0;u<c;u++){const d=he(r);let f=he(r);const h=JSON.parse(ur(r)),p=n.meta.get(d),g=n.states.get(d),v=p===void 0?0:p.clock;(v<f||v===f&&h===null&&n.states.has(d))&&(h===null?d===n.clientID&&n.getLocalState()!=null?f++:n.states.delete(d):n.states.set(d,h),n.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&&(Eo(h,g)||l.push(d),o.push(d)))}(s.length>0||l.length>0||a.length>0)&&n.emit("change",[{added:s,updated:l,removed:a},t]),(s.length>0||o.length>0||a.length>0)&&n.emit("update",[{added:s,updated:o,removed:a},t])},_O=(n,e)=>{const t=gd(n).buffer,r=gd(e).buffer;return crypto.subtle.importKey("raw",t,"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"]))},xb=(n,e)=>{if(!e)return Dd(n);const t=crypto.getRandomValues(new Uint8Array(12));return crypto.subtle.encrypt({name:"AES-GCM",iv:t},e,n).then(r=>{const i=gt();return jn(i,"AES-GCM"),Xe(i,t),Xe(i,new Uint8Array(r)),qe(i)})},NO=(n,e)=>{const t=gt();return ts(t,n),xb(qe(t),e)},kb=(n,e)=>{if(!e)return Dd(n);const t=Hn(n);ur(t)!=="AES-GCM"&&UA($n("Unknown encryption algorithm"));const i=bt(t),s=bt(t);return crypto.subtle.decrypt({name:"AES-GCM",iv:i},e,s).then(o=>new Uint8Array(o))},DO=(n,e)=>kb(n,e).then(t=>ns(Hn(new Uint8Array(t)))),Xt=zA("y-webrtc"),gs=0,Sb=3,Bo=1,lf=4,ga=new Map,Si=new Map,Eb=n=>{let e=!0;n.webrtcConns.forEach(t=>{t.synced||(e=!1)}),(!e&&n.synced||e&&!n.synced)&&(n.synced=e,n.provider.emit("synced",[{synced:e}]),Xt("synced ",un,n.name,yi," with all peers"))},Tb=(n,e,t)=>{const r=Hn(e),i=gt(),s=he(r);if(n===void 0)return null;const o=n.awareness,l=n.doc;let a=!1;switch(s){case gs:{ae(i,gs);const c=AO(r,i,l,n);c===rf&&!n.synced&&t(),c===nf&&(a=!0);break}case Sb:ae(i,Bo),Xe(i,ma(o,Array.from(o.getStates().keys()))),a=!0;break;case Bo:OO(o,bt(r),n);break;case lf:{const c=gi(r)===1,u=ur(r);if(u!==n.peerId&&(n.bcConns.has(u)&&!c||!n.bcConns.has(u)&&c)){const d=[],f=[];c?(n.bcConns.add(u),f.push(u)):(n.bcConns.delete(u),d.push(u)),n.provider.emit("peers",[{added:f,removed:d,webrtcPeers:Array.from(n.webrtcConns.keys()),bcPeers:Array.from(n.bcConns)}]),Ob(n)}break}default:return console.error("Unable to compute message"),i}return a?i:null},RO=(n,e)=>{const t=n.room;return Xt("received message from ",un,n.remotePeerId,_d," (",t.name,")",yi,ea),Tb(t,e,()=>{n.synced=!0,Xt("synced ",un,t.name,yi," with ",un,n.remotePeerId),Eb(t)})},af=(n,e)=>{Xt("send message to ",un,n.remotePeerId,yi,_d," (",n.room.name,")",ea);try{n.peer.send(qe(e))}catch{}},LO=(n,e)=>{Xt("broadcast message in ",un,n.name,yi),n.webrtcConns.forEach(t=>{try{t.peer.send(e)}catch{}})};class Ab{constructor(e,t,r,i){Xt("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 kO({initiator:t,...i.provider.peerOpts}),this.peer.on("signal",s=>{this.glareToken===void 0&&(this.glareToken=Date.now()+Math.random()),uf(e,i,{to:r,from:i.peerId,type:"signal",token:this.glareToken,signal:s})}),this.peer.on("connect",()=>{Xt("connected to ",un,r),this.connected=!0;const o=i.provider.doc,l=i.awareness,a=gt();ae(a,gs),vb(a,o),af(this,a);const c=l.getStates();if(c.size>0){const u=gt();ae(u,Bo),Xe(u,ma(l,Array.from(c.keys()))),af(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)}])),Eb(i),this.peer.destroy(),Xt("closed connection to ",un,r),cf(i)}),this.peer.on("error",s=>{Xt("Error in connection to ",un,r,": ",s),cf(i)}),this.peer.on("data",s=>{const o=RO(this,s);o!==null&&af(this,o)})}destroy(){this.peer.destroy()}}const $r=(n,e)=>xb(e,n.key).then(t=>n.mux(()=>nM(n.name,t))),Mb=(n,e)=>{n.bcconnected&&$r(n,e),LO(n,e)},cf=n=>{ga.forEach(e=>{e.connected&&(e.send({type:"subscribe",topics:[n.name]}),n.webrtcConns.size<n.provider.maxConns&&uf(e,n,{type:"announce",from:n.peerId}))})},Ob=n=>{if(n.provider.filterBcConns){const e=gt();ae(e,lf),So(e,1),jn(e,n.peerId),$r(n,qe(e))}};class IO{constructor(e,t,r,i){this.peerId=B0(),this.doc=e,this.awareness=t.awareness,this.provider=t,this.synced=!1,this.name=r,this.key=i,this.webrtcConns=new Map,this.bcConns=new Set,this.mux=my(),this.bcconnected=!1,this._bcSubscriber=s=>kb(new Uint8Array(s),i).then(o=>this.mux(()=>{const l=Tb(this,o,()=>{});l&&$r(this,qe(l))})),this._docUpdateHandler=(s,o)=>{const l=gt();ae(l,gs),EO(l,s),Mb(this,qe(l))},this._awarenessUpdateHandler=({added:s,updated:o,removed:l},a)=>{const c=s.concat(o).concat(l),u=gt();ae(u,Bo),Xe(u,ma(this.awareness,c)),Mb(this,qe(u))},this._beforeUnloadHandler=()=>{of(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),cf(this);const e=this.name;eM(e,this._bcSubscriber),this.bcconnected=!0,Ob(this);const t=gt();ae(t,gs),vb(t,this.doc),$r(this,qe(t));const r=gt();ae(r,gs),wb(r,this.doc),$r(this,qe(r));const i=gt();ae(i,Sb),$r(this,qe(i));const s=gt();ae(s,Bo),Xe(s,ma(this.awareness,[this.doc.clientID])),$r(this,qe(s))}disconnect(){ga.forEach(t=>{t.connected&&t.send({type:"unsubscribe",topics:[this.name]})}),of(this.awareness,[this.doc.clientID],"disconnect");const e=gt();ae(e,lf),So(e,0),jn(e,this.peerId),$r(this,qe(e)),tM(this.name,this._bcSubscriber),this.bcconnected=!1,this.doc.off("update",this._docUpdateHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.webrtcConns.forEach(t=>t.destroy())}destroy(){this.disconnect(),typeof window<"u"?window.removeEventListener("beforeunload",this._beforeUnloadHandler):typeof process<"u"&&process.off("exit",this._beforeUnloadHandler)}}const PO=(n,e,t,r)=>{if(Si.has(t))throw $n(`A Yjs Doc connected to room "${t}" already exists!`);const i=new IO(n,e,t,r);return Si.set(t,i),i},uf=(n,e,t)=>{e.key?NO(t,e.key).then(r=>{n.send({type:"publish",topic:e.name,data:fy(r)})}):n.send({type:"publish",topic:e.name,data:t})};class FO extends JT{constructor(e){super(e),this.providers=new Set,this.on("connect",()=>{Xt(`connected (${e})`);const t=Array.from(Si.keys());this.send({type:"subscribe",topics:t}),Si.forEach(r=>uf(this,r,{type:"announce",from:r.peerId}))}),this.on("message",t=>{switch(t.type){case"publish":{const r=t.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&&(zt(l,o.from,()=>new Ab(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){Xt("offer rejected: ",o.from);return}u.glareToken=void 0}}if(o.signal.type==="answer"){Xt("offer answered by: ",o.from);const u=l.get(o.from);u.glareToken=void 0}o.to===a&&(zt(l,o.from,()=>new Ab(this,!1,o.from,i)).peer.signal(o.signal),c());break}};i.key?typeof t.data=="string"&&DO(hy(t.data),i.key).then(s):s(t.data)}}}),this.on("disconnect",()=>Xt(`disconnect (${e})`))}}const df=n=>{n.emit("status",[{connected:n.connected}])};class BO extends dd{constructor(e,t,{signaling:r=["wss://y-webrtc-eu.fly.dev"],password:i=null,awareness:s=new MO(t),maxConns:o=20+wn(P0()*15),filterBcConns:l=!0,peerOpts:a={}}={}){super(),this.roomName=e,this.doc=t,this.filterBcConns=l,this.awareness=s,this.shouldConnect=!1,this.signalingUrls=r,this.signalingConns=[],this.maxConns=o,this.peerOpts=a,this.key=i?_O(i,e):Dd(null),this.room=null,this.key.then(c=>{this.room=PO(t,this,e,c),this.shouldConnect?this.room.connect():this.room.disconnect(),df(this)}),this.connect(),this.destroy=this.destroy.bind(this),t.on("destroy",this.destroy)}get connected(){return this.room!==null&&this.shouldConnect}connect(){this.shouldConnect=!0,this.signalingUrls.forEach(e=>{const t=zt(ga,e,()=>new FO(e));this.signalingConns.push(t),t.providers.add(this)}),this.room&&(this.room.connect(),df(this))}disconnect(){this.shouldConnect=!1,this.signalingConns.forEach(e=>{e.providers.delete(this),e.providers.size===0&&(e.destroy(),ga.delete(e.url))}),this.room&&(this.room.disconnect(),df(this))}destroy(){this.doc.off("destroy",this.destroy),this.key.then(()=>{this.room.destroy(),Si.delete(this.roomName)}),super.destroy()}}const $O={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:(n,e)=>{if(["ArrowUp","ArrowDown","Enter"].includes(e.key)&&document.querySelector("#slash-command"))return!0}}},jO=/[\uD800-\uDBFF]/,HO=/[\uDC00-\uDFFF]/,VO=(n,e)=>{let t=0,r=0;for(;t<n.length&&t<e.length&&n[t]===e[t];)t++;for(t>0&&jO.test(n[t-1])&&t--;r+t<n.length&&r+t<e.length&&n[n.length-r-1]===e[e.length-r-1];)r++;return r>0&&HO.test(n[n.length-r])&&r--,{index:t,remove:n.length-t-r,insert:e.slice(t,e.length-r)}},Ke=new We("y-sync"),hr=new We("y-undo"),ya=new We("yjs-cursor"),ba=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&e.sv.get(n.id.client)>n.id.clock&&!ss(e.ds,n.id),zO=[{light:"#ecd44433",dark:"#ecd444"}],UO=(n,e,t)=>{if(!n.has(t)){if(n.size<e.length){const r=or();n.forEach(i=>r.add(i)),e=e.filter(i=>!r.has(i))}n.set(t,ZT(e))}return n.get(t)},WO=(n,{colors:e=zO,colorMapping:t=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:n,doc:n.doc,binding:null,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:t,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)&&Od(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 KO(n,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},qO=(n,e,t)=>{if(e!==null&&e.anchor!==null&&e.head!==null){const r=Ho(t.doc,t.type,e.anchor,t.mapping),i=Ho(t.doc,t.type,e.head,t.mapping);r!==null&&i!==null&&(n=n.setSelection(ce.create(n.doc,r,i)))}},ff=(n,e)=>({anchor:xa(e.selection.anchor,n.type,n.mapping),head:xa(e.selection.head,n.type,n.mapping)});class KO{constructor(e,t){this.type=e,this.prosemirrorView=t,this.mux=my(),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=ff(this,t.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()?(Ad&&this._domSelectionInView===null&&(Od(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection(),t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);const i=t.getBoundingClientRect(),s=IA.documentElement;return i.bottom>=0&&i.right>=0&&i.left<=(window.innerWidth||s.clientWidth||0)&&i.top<=(window.innerHeight||s.clientHeight||0)}renderSnapshot(e,t){t||(t=Ry(yy(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Ke,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping=new Map,this.mux(()=>{const e=this.type.toArray().map(r=>va(r,this.prosemirrorView.state.schema,this.mapping)).filter(r=>r!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Y(W.from(e),0,0));t.setMeta(Ke,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping=new Map,this.mux(()=>{const e=this.type.toArray().map(r=>va(r,this.prosemirrorView.state.schema,this.mapping)).filter(r=>r!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Y(W.from(e),0,0));this.prosemirrorView.dispatch(t.setMeta(Ke,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,r){e||(e=kM(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:UO(r.colorMapping,r.colors,d)}},l=Yy(this.type,new Hd(t.ds,e.sv)).map(c=>!c._item.deleted||ba(c._item,e)||ba(c._item,t)?va(c,this.prosemirrorView.state.schema,new Map,e,t,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,t){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(t,t.deleteSet,l=>{if(l.constructor===ze){const a=l.content.type;a&&this.mapping.delete(a)}}),t.changed.forEach(i),t.changedParentTypes.forEach(i);const s=this.type.toArray().map(l=>_b(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));qO(o,this.beforeTransactionSelection,this),o=o.setMeta(Ke,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof zy}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(e){this.doc.transact(()=>{mf(this.doc,this.type,e,this.mapping),this.beforeTransactionSelection=ff(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 _b=(n,e,t,r,i,s)=>{const o=t.get(n);if(o===void 0){if(n instanceof It)return va(n,e,t,r,i,s);throw Cn()}return o},va=(n,e,t,r,i,s)=>{const o=[],l=a=>{if(a.constructor===It){const c=_b(a,e,t,r,i,s);c!==null&&o.push(c)}else{const c=JO(a,e,t,r,i,s);c!==null&&c.forEach(u=>{u!==null&&o.push(u)})}};r===void 0||i===void 0?n.toArray().forEach(l):Yy(n,new Hd(i.ds,r.sv)).forEach(l);try{const a=n.getAttributes(r);r!==void 0&&(ba(n._item,r)?ba(n._item,i)||(a.ychange=s?s("added",n._item.id):{type:"added"}):a.ychange=s?s("removed",n._item.id):{type:"removed"});const c=e.node(n.nodeName,a,o);return t.set(n,c),c}catch{return n.doc.transact(c=>{n._item.delete(c)},Ke),t.delete(n),null}},JO=(n,e,t,r,i,s)=>{const o=[],l=n.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 n.doc.transact(c=>{n._item.delete(c)},Ke),null}return o},GO=(n,e)=>{const t=new Zt,r=n.map(i=>({insert:i.text,attributes:Lb(i.marks)}));return t.applyDelta(r),e.set(t,n),t},YO=(n,e)=>{const t=new It(n.type.name);for(const r in n.attrs){const i=n.attrs[r];i!==null&&r!=="ychange"&&t.setAttribute(r,i)}return t.insert(0,wa(n).map(r=>hf(r,e))),e.set(t,n),t},hf=(n,e)=>n instanceof Array?GO(n,e):YO(n,e),Nb=n=>typeof n=="object"&&n!==null,pf=(n,e)=>{const t=Object.keys(n).filter(i=>n[i]!==null);let r=t.length===Object.keys(e).filter(i=>e[i]!==null).length;for(let i=0;i<t.length&&r;i++){const s=t[i],o=n[s],l=e[s];r=s==="ychange"||o===l||Nb(o)&&Nb(l)&&pf(o,l)}return r},wa=n=>{const e=n.content.content,t=[];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--,t.push(s)}else t.push(i)}return t},Db=(n,e)=>{const t=n.toDelta();return t.length===e.length&&t.every((r,i)=>r.insert===e[i].text&&Ed(r.attributes||{}).length===e[i].marks.length&&e[i].marks.every(s=>pf(r.attributes[s.type.name]||{},s.attrs)))},$o=(n,e)=>{if(n instanceof It&&!(e instanceof Array)&&gf(n,e)){const t=wa(e);return n._length===t.length&&pf(n.getAttributes(),e.attrs)&&n.toArray().every((r,i)=>$o(r,t[i]))}return n instanceof Zt&&e instanceof Array&&Db(n,e)},Ca=(n,e)=>n===e||n instanceof Array&&e instanceof Array&&n.length===e.length&&n.every((t,r)=>e[r]===t),Rb=(n,e,t)=>{const r=n.toArray(),i=wa(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(Ca(t.get(d),f))u=!0;else if(!$o(d,f))break}for(;a+c<l;c++){const d=r[o-c-1],f=i[s-c-1];if(Ca(t.get(d),f))u=!0;else if(!$o(d,f))break}return{equalityFactor:a+c,foundMappedChild:u}},ZO=n=>{let e="",t=n._start;const r={};for(;t!==null;)t.deleted||(t.countable&&t.content instanceof xn?e+=t.content.str:t.content instanceof lt&&(r[t.content.key]=null)),t=t.right;return{str:e,nAttrs:r}},XO=(n,e,t)=>{t.set(n,e);const{nAttrs:r,str:i}=ZO(n),s=e.map(c=>({insert:c.text,attributes:Object.assign({},r,Lb(c.marks))})),{insert:o,remove:l,index:a}=VO(i,s.map(c=>c.insert).join(""));n.delete(a,l),n.insert(a,o),n.applyDelta(s.map(c=>({retain:c.insert.length,attributes:c.attributes})))},Lb=n=>{const e={};return n.forEach(t=>{t.type.name!=="ychange"&&(e[t.type.name]=t.attrs)}),e},mf=(n,e,t,r)=>{if(e instanceof It&&e.nodeName!==t.type.name)throw new Error("node name mismatch!");if(r.set(e,t),e instanceof It){const d=e.getAttributes(),f=t.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=wa(t),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(!Ca(r.get(d),f))if($o(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(!Ca(r.get(d),f))if($o(d,f))r.set(d,f);else break}n.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 Zt&&h instanceof Array)Db(f,h)||XO(f,h,r),c+=1;else{let v=f instanceof It&&gf(f,h),w=p instanceof It&&gf(p,g);if(v&&w){const S=Rb(f,h,r),C=Rb(p,g,r);S.foundMappedChild&&!C.foundMappedChild?w=!1:!S.foundMappedChild&&C.foundMappedChild||S.equalityFactor<C.equalityFactor?v=!1:w=!1}v?(mf(n,f,h,r),c+=1):w?(mf(n,p,g,r),u+=1):(r.delete(e.get(c)),e.delete(c,1),e.insert(c,[hf(h,r)]),c+=1)}}const d=l-c-u;if(l===1&&s===0&&o[0]instanceof Zt?(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(hf(i[h],r));e.insert(c,f)}},Ke)},gf=(n,e)=>!(e instanceof Array)&&n.nodeName===e.type.name;let jo=null;const QO=()=>{const n=jo;jo=null,n.forEach((e,t)=>{const r=t.state.tr,i=Ke.getState(t.state);i&&i.binding&&!i.binding.isDestroyed&&(e.forEach((s,o)=>{r.setMeta(o,s)}),t.dispatch(r))})},e3=(n,e,t)=>{jo||(jo=new Map,Od(0,QO)),zt(jo,n,Lt).set(e,t)},xa=(n,e,t)=>{if(n===0)return jd(e,0);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof Zt){if(r._length>=n)return jd(r,n);if(n-=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,n--;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=(t.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&n<i)r=r._first.content.type,n--;else{if(n===1&&r._length===0&&i>1)return new _o(r._item===null?null:r._item.id,r._item===null?Mo(r):null,null);if(n-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(n===0)return r=r._item===null?r:r._item.parent,new _o(r._item===null?null:r._item.id,r._item===null?Mo(r):null,null);do r=r._item.parent,n--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw cn();if(n===0&&r.constructor!==Zt&&r!==e)return t3(r._item.parent,r._item)}return jd(e,e._length)},t3=(n,e)=>{let t=null,r=null;return n._item===null?r=Mo(n):t=pe(n._item.id.client,n._item.id.clock),new _o(t,r,e.id)},Ho=(n,e,t,r)=>{const i=xM(t,n);if(i===null||i.type!==e&&!Oo(e,i.type._item))return null;let s=i.type,o=0;if(s.constructor===Zt)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 Zt?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 Zt?o+=c._length:o+=r.get(c).nodeSize),a=a.right}}s=l}return o-1},n3=(n,e,t)=>n!==e,r3=n=>{const e=document.createElement("span");e.classList.add("ProseMirror-yjs-cursor"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");t.setAttribute("style",`background-color: ${n.color}`),t.insertBefore(document.createTextNode(n.name),null);const r=document.createTextNode("⁠"),i=document.createTextNode("⁠");return e.insertBefore(r,null),e.insertBefore(t,null),e.insertBefore(i,null),e},Ib=n=>({style:`background-color: ${n.color}70`,class:"ProseMirror-yjs-selection"}),i3=/^#[0-9a-fA-F]{6}$/,Pb=(n,e,t,r,i)=>{const s=Ke.getState(n),o=s.doc,l=[];return s.snapshot!=null||s.prevSnapshot!=null||s.binding===null?He.create(n.doc,[]):(e.getStates().forEach((a,c)=>{if(t(o.clientID,c,a)&&a.cursor!=null){const u=a.user||{};u.color==null?u.color="#ffa500":i3.test(u.color)||console.warn("A user uses an unsupported color format",u),u.name==null&&(u.name=`User: ${c}`);let d=Ho(o,s.type,No(a.cursor.anchor),s.binding.mapping),f=Ho(o,s.type,No(a.cursor.head),s.binding.mapping);if(d!==null&&f!==null){const h=ar(n.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(n.doc,l))},s3=(n,{awarenessStateFilter:e=n3,cursorBuilder:t=r3,selectionBuilder:r=Ib,getSelection:i=o=>o.selection}={},s="cursor")=>new je({key:ya,state:{init(o,l){return Pb(l,n,e,t,r)},apply(o,l,a,c){const u=Ke.getState(c),d=o.getMeta(ya);return u&&u.isChangeOrigin||d&&d.awarenessUpdated?Pb(c,n,e,t,r):l.map(o.mapping,o.doc)}},props:{decorations:o=>ya.getState(o)},view:o=>{const l=()=>{o.docView&&e3(o,ya,{awarenessUpdated:!0})},a=()=>{const c=Ke.getState(o.state),u=n.getLocalState()||{};if(c.binding!=null)if(o.hasFocus()){const d=i(o.state),f=xa(d.anchor,c.type,c.binding.mapping),h=xa(d.head,c.type,c.binding.mapping);(u.cursor==null||!Dy(No(u.cursor.anchor),f)||!Dy(No(u.cursor.head),h))&&n.setLocalStateField(s,{anchor:f,head:h})}else u.cursor!=null&&Ho(c.doc,c.type,No(u.cursor.anchor),c.binding.mapping)!==null&&n.setLocalStateField(s,null)};return n.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),n.off("change",l),n.setLocalStateField(s,null)}}}}),o3=n=>{const e=hr.getState(n).undoManager;if(e!=null)return e.undo(),!0},l3=n=>{const e=hr.getState(n).undoManager;if(e!=null)return e.redo(),!0},a3=new Set(["paragraph"]),c3=(n,e)=>!(n instanceof ze)||!(n.content instanceof kn)||!(n.content.type instanceof wi||n.content.type instanceof It&&e.has(n.content.type.nodeName))||n.content.type._length===0,u3=({protectedNodes:n=a3,trackedOrigins:e=[],undoManager:t=null}={})=>new je({key:hr,state:{init:(r,i)=>{const s=Ke.getState(i),o=t||new zy(s.type,{trackedOrigins:new Set([Ke].concat(e)),deleteFilter:l=>c3(l,n),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:ff(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()}}}}),d3=Ue.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null}},onCreate(){this.editor.extensionManager.extensions.find(n=>n.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:n,state:e,dispatch:t})=>(n.setMeta("preventDispatch",!0),hr.getState(e).undoManager.undoStack.length===0?!1:t?o3(e):!0),redo:()=>({tr:n,state:e,dispatch:t})=>(n.setMeta("preventDispatch",!0),hr.getState(e).undoManager.redoStack.length===0?!1:t?l3(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 n=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),e=u3(),t=e.spec.view;e.spec.view=l=>{const{undoManager:a}=hr.getState(l.state);a.restore&&(a.restore(),a.restore=()=>{});const c=t?t(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[WO(n,s),e]}}),Fb=n=>Array.from(n.entries()).map(([e,t])=>({clientId:e,...t.user})),Bb=()=>null,f3=Ue.create({name:"collaborationCursor",addOptions(){return{provider:null,user:{name:null,color:null},render:n=>{const e=document.createElement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");return t.classList.add("collaboration-cursor__label"),t.setAttribute("style",`background-color: ${n.color}`),t.insertBefore(document.createTextNode(n.name),null),e.insertBefore(t,null),e},selectionRender:Ib,onUpdate:Bb}},onCreate(){this.options.onUpdate!==Bb&&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:n=>()=>(this.options.user=n,this.options.provider.awareness.setLocalStateField("user",this.options.user),!0),user:n=>({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(n))}},addProseMirrorPlugins(){return[s3((this.options.provider.awareness.setLocalStateField("user",this.options.user),this.storage.users=Fb(this.options.provider.awareness.states),this.options.provider.awareness.on("update",()=>{this.storage.users=Fb(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),h3=/^\s*>\s$/,p3=Ve.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",Ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Ji({find:h3,type:this.type})]}}),m3=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,g3=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,y3=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,b3=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,v3=jt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",Ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ai({find:m3,type:this.type}),ai({find:y3,type:this.type})]},addPasteRules(){return[Rr({find:g3,type:this.type}),Rr({find:b3,type:this.type})]}}),w3=Ve.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",Ce(this.options.HTMLAttributes,n),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)}}}),$b=jt.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",Ce(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=oo(n,this.type);return Object.entries(t).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),jb=/^\s*([-+*])\s$/,C3=Ve.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:n}){return["ul",Ce(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(w3.name,this.editor.getAttributes($b.name)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Ji({find:jb,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Ji({find:jb,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes($b.name),editor:this.editor})),[n]}}),x3=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/,k3=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g,S3=jt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",Ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ai({find:x3,type:this.type})]},addPasteRules(){return[Rr({find:k3,type:this.type})]}}),E3=/^```([a-z]+)?[\s\n]$/,T3=/^~~~([a-z]+)?[\s\n]$/,A3=Ve.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:n=>{var e;const{languageClassPrefix:t}=this.options,s=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",Ce(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
307
+ */const d0=Me("Text",[["path",{d:"M17 6.1H3",key:"wptmhv"}],["path",{d:"M21 12.1H3",key:"1j38uz"}],["path",{d:"M15.1 18H3",key:"1nb16a"}]]);/**
308
+ * @license lucide-react v0.379.0 - ISC
309
+ *
310
+ * This source code is licensed under the ISC license.
311
+ * See the LICENSE file in the root directory of this source tree.
312
+ */const cT=Me("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"}]]);/**
313
+ * @license lucide-react v0.379.0 - ISC
314
+ *
315
+ * This source code is licensed under the ISC license.
316
+ * See the LICENSE file in the root directory of this source tree.
317
+ */const f0=Me("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"}]]);/**
318
+ * @license lucide-react v0.379.0 - ISC
319
+ *
320
+ * This source code is licensed under the ISC license.
321
+ * See the LICENSE file in the root directory of this source tree.
322
+ */const h0=Me("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"}]]),uT=({editor:n,isOpen:e,setIsOpen:t})=>{const r=[{name:"Text",icon:d0,command:()=>n.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>n.isActive("paragraph")&&!n.isActive("bulletList")&&!n.isActive("orderedList")},{name:"Heading 1",icon:o0,command:()=>n.chain().focus().toggleHeading({level:1}).run(),isActive:()=>n.isActive("heading",{level:1})},{name:"Heading 2",icon:l0,command:()=>n.chain().focus().toggleHeading({level:2}).run(),isActive:()=>n.isActive("heading",{level:2})},{name:"Heading 3",icon:a0,command:()=>n.chain().focus().toggleHeading({level:3}).run(),isActive:()=>n.isActive("heading",{level:3})},{name:"To-do List",icon:c0,command:()=>n.chain().focus().toggleTaskList().run(),isActive:()=>n.isActive("taskItem")},{name:"Bullet List",icon:sd,command:()=>n.chain().focus().toggleBulletList().run(),isActive:()=>n.isActive("bulletList")},{name:"Numbered List",icon:sd,command:()=>n.chain().focus().toggleOrderedList().run(),isActive:()=>n.isActive("orderedList")},{name:"Quote",icon:u0,command:()=>n.chain().focus().toggleNode("paragraph","paragraph").toggleBlockquote().run(),isActive:()=>n.isActive("blockquote")},{name:"Code",icon:i0,command:()=>n.chain().focus().toggleCode().run(),isActive:()=>n.isActive("code")}],i=r.filter(s=>s.isActive()).pop()??{name:"Multiple"};return D.jsxs("div",{className:"relative h-full",children:[D.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:()=>t(!e),children:[D.jsx("span",{children:i==null?void 0:i.name}),D.jsx(id,{className:"h-4 w-4"})]}),e&&D.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)=>D.jsxs("button",{onClick:()=>{s.command(),t(!1)},className:Fe("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:[D.jsxs("div",{className:"flex items-center space-x-2",children:[D.jsx("div",{className:"rounded-sm border border-stone-200 p-1",children:D.jsx(s.icon,{className:"h-3 w-3"})}),D.jsx("span",{children:s.name})]}),i.name===s.name&&D.jsx(Bl,{className:"h-4 w-4"})]},o))})]})},dT=({editor:n,isOpen:e,setIsOpen:t})=>{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})=>n.isActive("textStyle",{color:s}));return D.jsxs("div",{className:"",children:[D.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:()=>t(!e),children:[D.jsx("span",{style:{color:(i==null?void 0:i.color)||"#000000"},children:"A"}),D.jsx(id,{className:"h-4 w-4 "})]}),e&&D.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)=>D.jsxs("button",{onClick:()=>{n.chain().focus().setColor(o).run(),t(!1)},className:Fe("flex items-center justify-between rounded-sm px-2 py-1 text-sm text-stone-600 hover:bg-stone-100",{"text-blue-600":n.isActive("textStyle",{color:o})}),children:[D.jsxs("div",{className:"flex items-center space-x-2",children:[D.jsx("div",{className:"rounded-sm border border-stone-200 px-1 py-px font-medium",style:{color:o},children:"A"}),D.jsx("span",{children:s})]}),n.isActive("textStyle",{color:o})&&D.jsx(Bl,{className:"h-4 w-4"})]},l))})]})};var Te=(n=>(n[n.NONE=0]="NONE",n[n.HEADING=1]="HEADING",n[n.TEXT_COLOR=2]="TEXT_COLOR",n[n.HIGHLIGHT=3]="HIGHLIGHT",n[n.LINK=4]="LINK",n[n.FONT_FAMILY=5]="FONT_FAMILY",n[n.ALIGNMENT=6]="ALIGNMENT",n[n.LIST=7]="LIST",n))(Te||{});function fT(n){const[e,t]=O.useState(n),r=O.useRef(null),i=s=>{r&&r.current&&!r.current.contains(s.target)&&t(0)};return O.useEffect(()=>(document.addEventListener("click",i,!0),()=>{document.removeEventListener("click",i,!0)}),[]),{ref:r,toolVisibilty:e,setToolVisibility:t}}const hT="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_349_446'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_349_446)'%3e%3cpath%20d='M5.55%2019L2%2015.45L3.4%2014.05L5.525%2016.175L9.775%2011.925L11.175%2013.35L5.55%2019ZM5.55%2011L2%207.45005L3.4%206.05005L5.525%208.17505L9.775%203.92505L11.175%205.35005L5.55%2011ZM13%2017V15H22V17H13ZM13%209.00005V7.00005H22V9.00005H13Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",pT="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_337_2594'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_337_2594)'%3e%3cpath%20d='M3.9751%2017L7.7251%207H9.5251L13.2751%2017H11.5501L10.6501%2014.45H6.6001L5.7001%2017H3.9751ZM7.1251%2013H10.1251L8.6751%208.85H8.5751L7.1251%2013ZM16.3501%2017.275C15.5334%2017.275%2014.8918%2017.0625%2014.4251%2016.6375C13.9584%2016.2125%2013.7251%2015.6333%2013.7251%2014.9C13.7251%2014.2%2013.9959%2013.6292%2014.5376%2013.1875C15.0793%2012.7458%2015.7751%2012.525%2016.6251%2012.525C17.0084%2012.525%2017.3626%2012.5542%2017.6876%2012.6125C18.0126%2012.6708%2018.2918%2012.7667%2018.5251%2012.9V12.55C18.5251%2012.1%2018.3709%2011.7417%2018.0626%2011.475C17.7543%2011.2083%2017.3334%2011.075%2016.8001%2011.075C16.4501%2011.075%2016.1209%2011.15%2015.8126%2011.3C15.5043%2011.45%2015.2418%2011.6667%2015.0251%2011.95L13.9501%2011.15C14.2668%2010.7%2014.6668%2010.3583%2015.1501%2010.125C15.6334%209.89167%2016.1918%209.775%2016.8251%209.775C17.8584%209.775%2018.6501%2010.0208%2019.2001%2010.5125C19.7501%2011.0042%2020.0251%2011.7167%2020.0251%2012.65V17.05H18.5501V16.2H18.4751C18.2584%2016.5333%2017.9668%2016.7958%2017.6001%2016.9875C17.2334%2017.1792%2016.8168%2017.275%2016.3501%2017.275ZM16.6001%2016.025C17.1334%2016.025%2017.5876%2015.8375%2017.9626%2015.4625C18.3376%2015.0875%2018.5251%2014.6333%2018.5251%2014.1C18.2918%2013.9667%2018.0251%2013.8667%2017.7251%2013.8C17.4251%2013.7333%2017.1501%2013.7%2016.9001%2013.7C16.3668%2013.7%2015.9584%2013.8042%2015.6751%2014.0125C15.3918%2014.2208%2015.2501%2014.5167%2015.2501%2014.9C15.2501%2015.2333%2015.3751%2015.5042%2015.6251%2015.7125C15.8751%2015.9208%2016.2001%2016.025%2016.6001%2016.025Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",p0="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_224_2464'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_224_2464)'%3e%3cpath%20d='M3%2021V19H21V21H3ZM7%2017V15H17V17H7ZM3%2013V11H21V13H3ZM7%209V7H17V9H7ZM3%205V3H21V5H3Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",od="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_337_2575'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_337_2575)'%3e%3cpath%20d='M3%2021V19H21V21H3ZM3%2017V15H15V17H3ZM3%2013V11H21V13H3ZM3%209V7H15V9H3ZM3%205V3H21V5H3Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",m0="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_224_2470'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_224_2470)'%3e%3cpath%20d='M3%205V3H21V5H3ZM9%209V7H21V9H9ZM3%2013V11H21V13H3ZM9%2017V15H21V17H9ZM3%2021V19H21V21H3Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",g0="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_337_2572'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_337_2572)'%3e%3cpath%20d='M9%2019V17H21V19H9ZM9%2013V11H21V13H9ZM9%207V5H21V7H9ZM5%2020C4.45%2020%203.97917%2019.8042%203.5875%2019.4125C3.19583%2019.0208%203%2018.55%203%2018C3%2017.45%203.19583%2016.9792%203.5875%2016.5875C3.97917%2016.1958%204.45%2016%205%2016C5.55%2016%206.02083%2016.1958%206.4125%2016.5875C6.80417%2016.9792%207%2017.45%207%2018C7%2018.55%206.80417%2019.0208%206.4125%2019.4125C6.02083%2019.8042%205.55%2020%205%2020ZM5%2014C4.45%2014%203.97917%2013.8042%203.5875%2013.4125C3.19583%2013.0208%203%2012.55%203%2012C3%2011.45%203.19583%2010.9792%203.5875%2010.5875C3.97917%2010.1958%204.45%2010%205%2010C5.55%2010%206.02083%2010.1958%206.4125%2010.5875C6.80417%2010.9792%207%2011.45%207%2012C7%2012.55%206.80417%2013.0208%206.4125%2013.4125C6.02083%2013.8042%205.55%2014%205%2014ZM5%208C4.45%208%203.97917%207.80417%203.5875%207.4125C3.19583%207.02083%203%206.55%203%206C3%205.45%203.19583%204.97917%203.5875%204.5875C3.97917%204.19583%204.45%204%205%204C5.55%204%206.02083%204.19583%206.4125%204.5875C6.80417%204.97917%207%205.45%207%206C7%206.55%206.80417%207.02083%206.4125%207.4125C6.02083%207.80417%205.55%208%205%208Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",mT="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_349_458'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_349_458)'%3e%3cpath%20d='M3%2022V20.5H5.5V19.75H4V18.25H5.5V17.5H3V16H6C6.28333%2016%206.52083%2016.0958%206.7125%2016.2875C6.90417%2016.4792%207%2016.7167%207%2017V18C7%2018.2833%206.90417%2018.5208%206.7125%2018.7125C6.52083%2018.9042%206.28333%2019%206%2019C6.28333%2019%206.52083%2019.0958%206.7125%2019.2875C6.90417%2019.4792%207%2019.7167%207%2020V21C7%2021.2833%206.90417%2021.5208%206.7125%2021.7125C6.52083%2021.9042%206.28333%2022%206%2022H3ZM3%2015V12.25C3%2011.9667%203.09583%2011.7292%203.2875%2011.5375C3.47917%2011.3458%203.71667%2011.25%204%2011.25H5.5V10.5H3V9H6C6.28333%209%206.52083%209.09583%206.7125%209.2875C6.90417%209.47917%207%209.71667%207%2010V11.75C7%2012.0333%206.90417%2012.2708%206.7125%2012.4625C6.52083%2012.6542%206.28333%2012.75%206%2012.75H4.5V13.5H7V15H3ZM4.5%208V3.5H3V2H6V8H4.5ZM9%2019V17H21V19H9ZM9%2013V11H21V13H9ZM9%207V5H21V7H9Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",gT="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_337_2560'%20style='mask-type:alpha'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='24'%20height='24'%3e%3crect%20width='24'%20height='24'%20fill='%23D9D9D9'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_337_2560)'%3e%3cpath%20d='M5%2019V17H19V19H5ZM6.9%2015L11%204H13L17.1%2015H15.2L14.25%2012.2H9.8L8.8%2015H6.9ZM10.35%2010.6H13.65L12.05%206.05H11.95L10.35%2010.6Z'%20fill='%231C1B1F'/%3e%3c/g%3e%3c/svg%3e",yT="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='m228-240%2092-160q-66%200-113-47t-47-113q0-66%2047-113t113-47q66%200%20113%2047t47%20113q0%2023-5.5%2042.5T458-480L320-240h-92Zm360%200%2092-160q-66%200-113-47t-47-113q0-66%2047-113t113-47q66%200%20113%2047t47%20113q0%2023-5.5%2042.5T818-480L680-240h-92ZM320-500q25%200%2042.5-17.5T380-560q0-25-17.5-42.5T320-620q-25%200-42.5%2017.5T260-560q0%2025%2017.5%2042.5T320-500Zm360%200q25%200%2042.5-17.5T740-560q0-25-17.5-42.5T680-620q-25%200-42.5%2017.5T620-560q0%2025%2017.5%2042.5T680-500Zm0-60Zm-360%200Z'/%3e%3c/svg%3e",bT="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M200-280v-400h80v160h160v-160h80v400h-80v-160H280v160h-80Zm480%200v-320h-80v-80h160v400h-80Z'/%3e%3c/svg%3e",vT="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M120-280v-400h80v160h160v-160h80v400h-80v-160H200v160h-80Zm400%200v-160q0-33%2023.5-56.5T600-520h160v-80H520v-80h240q33%200%2056.5%2023.5T840-600v80q0%2033-23.5%2056.5T760-440H600v80h240v80H520Z'/%3e%3c/svg%3e",wT="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M120-280v-400h80v160h160v-160h80v400h-80v-160H200v160h-80Zm400%200v-80h240v-80H600v-80h160v-80H520v-80h240q33%200%2056.5%2023.5T840-600v240q0%2033-23.5%2056.5T760-280H520Z'/%3e%3c/svg%3e",xT="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M680-360q-17%200-28.5-11.5T640-400v-160q0-17%2011.5-28.5T680-600h120q17%200%2028.5%2011.5T840-560v40h-60v-20h-80v120h80v-20h60v40q0%2017-11.5%2028.5T800-360H680Zm-300%200v-240h160q17%200%2028.5%2011.5T580-560v40q0%2017-11.5%2028.5T540-480q17%200%2028.5%2011.5T580-440v40q0%2017-11.5%2028.5T540-360H380Zm60-150h80v-30h-80v30Zm0%2090h80v-30h-80v30Zm-320%2060v-200q0-17%2011.5-28.5T160-600h120q17%200%2028.5%2011.5T320-560v200h-60v-60h-80v60h-60Zm60-120h80v-60h-80v60Z'/%3e%3c/svg%3e",CT="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20height='24'%20viewBox='0%20-960%20960%20960'%20width='24'%3e%3cpath%20d='M544-400%20440-504%20240-304l104%20104%20200-200Zm-47-161%20104%20104%20199-199-104-104-199%20199Zm-84-28%20216%20216-229%20229q-24%2024-56%2024t-56-24l-2-2-26%2026H60l126-126-2-2q-24-24-24-56t24-56l229-229Zm0%200%20227-227q24-24%2056-24t56%2024l104%20104q24%2024%2024%2056t-24%2056L629-373%20413-589Z'/%3e%3c/svg%3e",kT="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3cpath%20fill='currentColor'%20d='M19%205v14H5V5h14m0-2H5c-1.1%200-2%20.9-2%202v14c0%201.1.9%202%202%202h14c1.1%200%202-.9%202-2V5c0-1.1-.9-2-2-2zm-4.86%208.86l-3%203.87L9%2013.14L6%2017h12l-3.86-5.14z'/%3e%3c/svg%3e",$l=new We("upload-image"),ST=()=>new je({key:$l,state:{init(){return He.empty},apply(n,e){e=e.map(n.mapping,n.doc);const t=n.getMeta(this);if(t&&t.add){const{id:r,pos:i,src:s}=t.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(n.doc,[a])}else t&&t.remove&&(e=e.remove(e.find(void 0,void 0,r=>r.id==t.remove.id)));return e}},props:{decorations(n){return this.getState(n)}}});function ET(n,e){const r=$l.getState(n).find(null,null,i=>i.id==e);return r.length?r[0].from:null}function y0(n,e,t){if(n.type.includes("image/")){if(n.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(n),s.onload=()=>{i.setMeta($l,{add:{id:r,pos:t,src:s.result}}),e.dispatch(i)},TT(n).then(o=>{const{schema:l}=e.state,a=ET(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($l,{remove:{id:r}});e.dispatch(d)})}const TT=n=>new Promise(e=>{const t=new FileReader;t.readAsDataURL(n),t.onload=()=>e(t.result)}),AT=async n=>{const e=new FileReader;if(e.readAsDataURL(n),n.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)}})},b0=({editor:n})=>{const{ref:e,toolVisibilty:t,setToolVisibility:r}=fT(Te.NONE);return{toolbar:[{icon:pT,title:"Font",onClick:()=>r(Te.FONT_FAMILY),isActive:t===Te.FONT_FAMILY},{icon:gT,title:"Text Color",onClick:()=>r(Te.TEXT_COLOR),isActive:t===Te.TEXT_COLOR},{icon:CT,title:"Highlight",onClick:()=>r(Te.HIGHLIGHT),isActive:t===Te.HIGHLIGHT},null,{icon:Yg,title:"Bold",onClick:()=>n==null?void 0:n.chain().focus().toggleBold().run(),isActive:n==null?void 0:n.isActive("bold")},{icon:Zg,title:"Italic",onClick:()=>n==null?void 0:n.chain().focus().toggleItalic().run(),isActive:n==null?void 0:n.isActive("italic")},{icon:Xg,title:"Underlined",onClick:()=>n==null?void 0:n.chain().focus().toggleUnderline().run(),isActive:n==null?void 0:n.isActive("underline")},{icon:e0,title:"Strikethrough",onClick:()=>n==null?void 0:n.chain().focus().toggleStrike().run(),isActive:n==null?void 0:n.isActive("strike")},null,{icon:g0,title:"List",onClick:()=>r(Te.LIST),isActive:t===Te.LIST},{icon:od,title:"Alignment",onClick:()=>r(Te.ALIGNMENT),isActive:t===Te.ALIGNMENT},{icon:yT,title:"Quote",onClick:()=>n==null?void 0:n.chain().focus().toggleBlockquote().run(),isActive:n==null?void 0:n.isActive("blockquote")},null,{icon:kT,title:"Upload Image",onClick:()=>{n==null||n.chain().focus().deleteRange(n.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=n.view.state.selection.from;y0(l,n.view,a)}},s.click()},isActive:!1},{icon:t0,title:"Link",onClick:()=>r(Te.LINK),isActive:n==null?void 0:n.isActive("link")},{icon:Qg,title:"Code",onClick:()=>n==null?void 0:n.chain().focus().toggleCodeBlock().run(),isActive:n==null?void 0:n.isActive("codeBlock")}],toolRef:e,toolVisibilty:t,setToolVisibility:r}},MT=({editor:n,setVisibility:e,elementRef:t})=>{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 D.jsxs("div",{ref:t,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-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all",children:[D.jsx(r0,{className:"cursor-pointer",onClick:()=>{n.chain().focus().unsetHighlight().run(),e(Te.NONE)}}),r.map(i=>D.jsx("div",{onClick:()=>{n.chain().focus().toggleHighlight({color:i.color}).run(),e(Te.NONE)},className:`w-6 ${i.code} drop-shadow rounded-full flex items-center justify-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6`,children:D.jsx(Bl,{size:14,className:`${n.isActive("highlight",{color:i.color})?"visible":"invisible"}`})},i.color))]})},OT=({elementRef:n,editor:e,setToolVisibility:t})=>{const r=[{title:"Trebuchet MS",command:i=>{i.chain().focus().setFontFamily("Trebuchet MS, sans-serif").run()}},{title:"Verdana",command:i=>{i.chain().focus().setFontFamily("Verdana, Geneva, sans-serif").run()}},{title:"Georgia",command:i=>{i.chain().focus().setFontFamily("Georgia, serif").run()}},{title:"Arial",command:i=>{i.chain().focus().setFontFamily("Arial, Helvetica, sans-serif").run()}},{title:"Comic Sans MS",command:i=>{i.chain().focus().setFontFamily("Comic Sans MS, Comic Sans").run()}},{title:"Impact",command:i=>{i.chain().focus().setFontFamily("Impact, Charcoal, sans-serif").run()}},{title:"Palatino",command:i=>{i.chain().focus().setFontFamily("Palatino Linotype, Book Antiqua, Palatino, serif").run()}},{title:"Lucida Grande",command:i=>{i.chain().focus().setFontFamily("Lucida Sans Unicode, Lucida Grande, sans-serif").run()}},{title:"Serif",command:i=>{i.chain().focus().setFontFamily("serif").run()}},{title:"Monospace",command:i=>{i.chain().focus().setFontFamily("monospace").run()}},{title:"Cursive",command:i=>{i.chain().focus().setFontFamily("cursive").run()}}];return D.jsx("div",{ref:n,className:Fe("z-50 h-auto absolute top-[50px] left-[20%] max-h-[330px] w-48 overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all"),children:r.map(i=>D.jsx("button",{onClick:()=>{i.command(e),t(Te.NONE)},style:{fontFamily:i.title},className:`flex w-full ${e.isActive("textStyle",{fontFamily:i.title})?"bg-red-500":""} items-center space-x-2 rounded-md px-2 py-1 text-left text-sm text-stone-900 hover:bg-stone-100`,children:D.jsx("p",{className:"font-medium",children:i.title})},i.title))})},_T=({elementRef:n,editor:e,setToolVisibility:t})=>D.jsxs("div",{ref:n,className:Fe("z-50 h-auto absolute gap-2 top-[50px] right-[25%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all"),children:[D.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("left").run(),t(Te.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive({textAlign:"left"})&&"bg-[#f2f2f2]"} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:D.jsx("img",{src:od,alt:"align left"})}),D.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("center").run(),t(Te.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive({textAlign:"center"})&&"bg-[#f2f2f2]"} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:D.jsx("img",{src:p0,alt:"align center"})}),D.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("right").run(),t(Te.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive({textAlign:"right"})&&"bg-[#f2f2f2]"} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:D.jsx("img",{src:m0,alt:"align right"})})]}),NT=({elementRef:n,editor:e,setToolVisibility:t})=>D.jsxs("div",{ref:n,className:Fe("z-50 h-auto absolute gap-2 top-[50px] right-[30%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all"),children:[D.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"unordered list",children:D.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleBulletList().run(),t(Te.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("bulletList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:D.jsx("img",{src:g0,alt:"bullet list"})})}),D.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"ordered list",children:D.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleOrderedList().run(),t(Te.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("orderedList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:D.jsx("img",{src:mT,alt:"numbered list"})})}),D.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"to-do list",children:D.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleTaskList().run(),t(Te.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("taskList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:D.jsx("img",{src:hT,alt:"checklist"})})})]}),v0=({elementRef:n,editor:e,setToolVisibility:t,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(),t(Te.NONE),r&&i&&i(!1)};return D.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-[50px] items-center flex right-[10%] max-h-[330px] overflow-y-auto scroll-smooth rounded-md border border-stone-200 bg-white p-2 shadow-md transition-all",children:[D.jsx("input",{onChange:a=>o(a.target.value),className:"border-2 focus:border-black px-2 py-1.5 rounded w-full font-medium text-sm",placeholder:"Add link here",value:s}),D.jsx("div",{className:"h-full flex items-center",children:D.jsx("button",{onClick:()=>l(),className:"min-w-fit",children:"Apply"})})]})},DT=({editor:n,setVisibility:e,elementRef:t})=>{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 D.jsxs("div",{ref:t,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-md border border-stone-200 bg-white px-1 py-2 shadow-md transition-all",children:[D.jsx(r0,{className:"cursor-pointer",onClick:()=>{n.chain().focus().unsetColor().run(),e(Te.NONE)}}),r.map(i=>D.jsx("div",{onClick:()=>{n.chain().focus().setColor(i.color).run(),e(Te.NONE)},className:`w-6 ${i.code} drop-shadow rounded-full flex justify-center items-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6`,children:D.jsx(Bl,{size:14,className:`${n.isActive("textStyle",{color:i.color})?"visible":"invisible"}`})},i.color))]})},RT=({editor:n,setVisibility:e,elementRef:t})=>{const r=[{title:"Text",description:"Normal",icon:xT,command:i=>i.chain().focus().toggleNode("paragraph","paragraph").run()},{title:"Heading 1",description:"Big",icon:bT,command:i=>{i.chain().focus().toggleHeading({level:1}).run()}},{title:"Heading 2",description:"Medium",icon:vT,command:i=>{i.chain().focus().toggleHeading({level:2}).run()}},{title:"Heading 3",description:"Small",icon:wT,command:i=>{i.chain().focus().toggleHeading({level:3}).run()}}];return D.jsx("section",{ref:t,className:Fe(" absolute top-[50px] z-50 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","left-0"),children:r.map(i=>D.jsxs("button",{onClick:()=>{i.command(n),e(Te.NONE)},className:"flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm text-stone-900 hover:bg-stone-100",children:[D.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border border-stone-200 bg-white",children:D.jsx("img",{src:i.icon,alt:i.title})}),D.jsxs("div",{children:[D.jsx("p",{className:"font-medium",children:i.title}),D.jsxs("p",{className:"text-xs text-stone-500",children:[" ",i.description," "]})]})]},i.title))})},LT=n=>{const e=[{name:"bold",isActive:()=>n.editor.isActive("bold"),command:()=>n.editor.chain().focus().toggleBold().run(),icon:Yg},{name:"italic",isActive:()=>n.editor.isActive("italic"),command:()=>n.editor.chain().focus().toggleItalic().run(),icon:Zg},{name:"underline",isActive:()=>n.editor.isActive("underline"),command:()=>n.editor.chain().focus().toggleUnderline().run(),icon:Xg},{name:"strike",isActive:()=>n.editor.isActive("strike"),command:()=>n.editor.chain().focus().toggleStrike().run(),icon:e0},{name:"codeBlock",isActive:()=>n.editor.isActive("codeBlock"),command:()=>n.editor.chain().focus().toggleCodeBlock().run(),icon:Qg},{name:"link",isActive:()=>n.editor.isActive("link"),command:()=>a(!l),icon:t0}],t={...n,shouldShow:({state:d,editor:f})=>{const{selection:h}=d,{empty:p}=h;return!(f.isActive("image")||p||Qm(h))},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}=b0({editor:n.editor});return D.jsxs(Ug,{...t,className:"flex gap-1 overflow-hidden rounded border border-stone-200 bg-white shadow-xl",children:[D.jsx(uT,{editor:n.editor,isOpen:r,setIsOpen:()=>{i(!r),o(!1)}}),e.map((d,f)=>D.jsx("button",{onClick:d.command,className:" py-2 text-stone-600 hover:bg-stone-100 active:bg-stone-200",children:D.jsx("img",{src:d.icon,className:Fe(" p-1 rounded-lg h-6 w-6",{"bg-yellow-300":d.isActive()})})},f)),D.jsx(dT,{editor:n.editor,isOpen:s,setIsOpen:()=>{o(!s),i(!1)}}),l&&D.jsx(v0,{setToolVisibility:u,editor:n.editor,elementRef:c,bubbleMenu:!0,setIsLinkPopupOpen:a})]})};function IT(){const n=["a","b","c","d","e","f","0","1","2","3","4","5","6","7","8","9"];let e=[];for(let t=0;t<36;t++)t===8||t===13||t===18||t===23?e[t]="-":e[t]=n[Math.ceil(Math.random()*n.length-1)];return e.join("")}var PT=IT;const FT=Nc(PT),w0=Ve.create({name:"column",content:"dBlock+",isolating:!0,addAttributes(){return{position:{default:"",parseHTML:n=>n.getAttribute("data-position"),renderHTML:n=>({"data-position":n.position})}}},renderHTML({HTMLAttributes:n}){return["div",xe(n,{"data-type":"column"}),0]},parseHTML(){return[{tag:'div[data-type="column"]'}]}}),BT=(n,e)=>Array.from({length:n},(t,r)=>e(r)),jl=({type:n,content:e})=>e?{type:n,content:e}:{type:n},$T=({content:n})=>jl({type:"paragraph",content:n}),x0=({content:n})=>jl({type:"dBlock",content:n}),C0=({content:n})=>jl({type:"column",content:n}),k0=({content:n})=>jl({type:"columns",content:n}),S0=n=>{const e=[x0({content:[$T({})]})];return BT(n,()=>C0({content:e}))},E0=(n,e)=>{for(let t=n.depth;t>0;t--){const r=n.node(t),i=t>0?n.before(t):0,s=n.start(t);if(e({node:r,pos:i,start:s}))return{start:s,depth:t,node:r,pos:i}}throw Error("no ancestor found")};class Hl extends ue{constructor(t){const{$from:r,$to:i}=t;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(t){return t instanceof Hl&&t.anchor==this.anchor}toJSON(){return{type:"column",from:this.from,to:this.to}}expandSelection(t){var a;const r=({pos:c,node:u})=>u.type.name===w0.name?!0:t.resolve(c).depth<=0,{pos:i}=E0(this.$from,r);this._$from=t.resolve(i);const{pos:s,node:o}=E0(this.$to,r);this._$to=t.resolve(s+o.nodeSize),((a=this.getFirstNode())==null?void 0:a.type.name)===Vl.name&&(this._$from=t.resolve(this.$from.pos+2),this._$to=t.resolve(this.$to.pos+2));const l=this;l.$anchor=this._$from,l.$head=this._$to,l.ranges=[new Jc(this._$from,this._$to)]}static create(t,r,i){const s=t.resolve(r),o=t.resolve(i),l=new ce(s,o);return new Hl(l)}getFirstNode(){return this.content().content.firstChild}}var pi=(n=>(n.AlignLeft="align-left",n.AlignRight="align-right",n.AlignCenter="align-center",n))(pi||{});const Vl=Ve.create({name:"columns",group:"columns",content:"column{2,}",defining:!0,draggable:!0,isolating:!0,addAttributes(){return{layout:{default:"align-center"}}},addCommands(){return{unsetColumns:()=>({tr:n,dispatch:e})=>{try{if(!e)return;const t=n.selection.$from,i=Ru(t,({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)===Vl.name&&s.push(a)}),s=s.reverse().filter(a=>a.content.size>0);const o=n.doc.resolve(i.pos),l=new se(o);return n=n.setSelection(l),s.forEach(a=>n=n.insert(i.pos,a)),n=n.deleteSelection(),e(n)}catch(t){console.error(t)}},setColumns:(n,e=!1)=>({tr:t,dispatch:r})=>{try{const{doc:i,selection:s}=t;if(!r){console.log("no dispatch");return}const o=new Hl(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=C0(h),g=S0(n-1);c=k0({content:[p,...g]})}else{const h=S0(n);c=k0({content:h})}const u=i.type.schema.nodeFromJSON(x0({content:[c]}));if(u===null)return;const d=o.$anchor.parent.type;if(!(h=>!(!h.contentMatch.matchType(this.type)||!this.options.nestedColumns&&h.name===Vl.name))(d)){console.warn("content not allowed");return}return t=t.setSelection(o),t=t.replaceSelectionWith(u,!1),r(t)}catch(i){console.error(i)}},setLayout:n=>({commands:e})=>e.updateAttributes("columns",{layout:n})}},renderHTML({HTMLAttributes:n}){return["div",{"data-type":"columns",class:`layout-${n.layout}`},0]},parseHTML(){return[{tag:'div[data-type="columns"]'}]}}),jT=(n,e)=>{const{view:t,state:{selection:{from:r}}}=n,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=t.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},ld=O.forwardRef(({children:n,className:e,withShadow:t=!0,withBorder:r=!0,...i},s)=>{const o=Fe(e,"bg-white rounded-md",t?"shadow-md":"",r?"border border-neutral-200":"");return D.jsx("div",{className:o,...i,ref:s,children:n})});ld.displayName="Surface";const zl=O.forwardRef(({active:n,buttonSize:e="medium",children:t,disabled:r,variant:i="primary",className:s,activeClassname:o,...l},a)=>{const c=Fe("flex group items-center justify-center border border-transparent gap-2 text-sm font-semibold rounded-md disabled:opacity-50 whitespace-nowrap",i==="primary"&&Fe("text-white bg-black border-black dark:text-black dark:bg-white dark:border-white",!r&&!n&&"hover:bg-neutral-800 active:bg-neutral-900 dark:hover:bg-neutral-200 dark:active:bg-neutral-300",n&&Fe("bg-neutral-900 dark:bg-neutral-300",o)),i==="secondary"&&Fe("text-neutral-900 dark:text-white",!r&&!n&&"hover:bg-neutral-100 active:bg-neutral-200 dark:hover:bg-neutral-900 dark:active:bg-neutral-800",n&&"bg-neutral-200 dark:bg-neutral-800"),i==="tertiary"&&Fe("bg-neutral-50 text-neutral-900 dark:bg-neutral-900 dark:text-white dark:border-neutral-900",!r&&!n&&"hover:bg-neutral-100 active:bg-neutral-200 dark:hover:bg-neutral-800 dark:active:bg-neutral-700",n&&Fe("bg-neutral-200 dark:bg-neutral-800",o)),i==="ghost"&&Fe("bg-transparent border-transparent text-neutral-500",!r&&!n&&"hover:bg-black/5 hover:text-neutral-700 active:bg-black/10 active:text-neutral-800 ",n&&Fe("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 D.jsx("button",{ref:a,disabled:r,className:c,...l,children:t})});zl.displayName="Button";const T0=({content:n,children:e})=>{const[t,r]=O.useState(!1);return D.jsxs("div",{className:"relative inline-block",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[e,t&&D.jsx("div",{className:"absolute z-10 p-2 mt-2 text-sm text-white bg-gray-800 rounded shadow-lg",children:n})]})},A0=O.forwardRef(({shouldShowContent:n=!0,children:e,isVertical:t=!1,className:r,...i},s)=>{const o=Fe("text-black inline-flex h-full leading-none gap-0.5",t?"flex-col p-2":"flex-row p-1 items-center",r);return n?n&&D.jsx(ld,{className:o,...i,ref:s,children:e}):null});A0.displayName="Toolbar";const M0=O.forwardRef(({horizontal:n,className:e,...t},r)=>{const i=Fe("bg-neutral-200",n?"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 D.jsx("div",{className:i,ref:r,...t})});M0.displayName="Toolbar.Divider";const O0=O.forwardRef(({children:n,buttonSize:e="icon",variant:t="ghost",className:r,tooltip:i,activeClassname:s,...o},l)=>{const a=Fe("gap-1 min-w-[2rem] px-2 w-auto",r),c=D.jsx(zl,{activeClassname:s,className:a,variant:t,buttonSize:e,ref:l,...o,children:n});return i?D.jsx(T0,{content:i,children:c}):c});O0.displayName="ToolbarButton";const vo={Wrapper:A0,Divider:M0,Button:O0},HT=({editor:n,appendTo:e})=>{const t=O.useCallback(()=>{const l=jT(n,"columns");return(l==null?void 0:l.getBoundingClientRect())||new DOMRect(-1e3,-1e3,0,0)},[n]),r=O.useCallback(()=>n.isActive("columns"),[n]),i=O.useCallback(()=>{n.chain().focus().setLayout(pi.AlignLeft).run()},[n]),s=O.useCallback(()=>{n.chain().focus().setLayout(pi.AlignRight).run()},[n]),o=O.useCallback(()=>{n.chain().focus().setLayout(pi.AlignCenter).run()},[n]);return D.jsx(Ug,{editor:n,pluginKey:`columnsMenu-${FT()}`,shouldShow:r,updateDelay:0,tippyOptions:{offset:[0,8],popperOptions:{modifiers:[{name:"flip",enabled:!1}]},getReferenceClientRect:t,moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",appendTo:()=>e==null?void 0:e.current,plugins:[OE],sticky:"popper"},children:D.jsxs(vo.Wrapper,{children:[D.jsx(vo.Button,{tooltip:"Align left",active:n.isActive("columns",{layout:pi.AlignLeft}),onClick:i,children:D.jsx(eT,{size:20})}),D.jsx(vo.Button,{tooltip:"Align center",active:n.isActive("columns",{layout:pi.AlignCenter}),onClick:o,children:D.jsx(s0,{size:20})}),D.jsx(vo.Button,{tooltip:"Align right",active:n.isActive("columns",{layout:pi.AlignRight}),onClick:s,children:D.jsx(tT,{size:20})})]})})},_0=O.createContext(null),Ul=()=>O.useContext(_0),VT=({children:n,isPreviewMode:e})=>D.jsx(_0.Provider,{value:e,children:n}),N0=({height:n,width:e})=>D.jsx("span",{className:"flex items-center justify-center ",children:D.jsx("span",{className:`${e?`w-${e}`:"w-8"} ${n?`h-${n}`:"h-8"} border-4 border-t-4 border-t-[#ccc] border-gray-500 rounded-full animate-spin`})}),zT=({editor:n})=>{const{toolRef:e,toolVisibilty:t,setToolVisibility:r,toolbar:i}=b0({editor:n});return D.jsxs("div",{className:"w-fit bg-transparent px-4 items-center rounded-lg h-16 flex gap-1 justify-center",children:[D.jsxs("button",{className:"hover:bg-[#f2f2f2] border gap-2 rounded-lg w-28 h-8 p-1 flex justify-center items-center",onClick:()=>r(Te.HEADING),children:[D.jsx("span",{className:"text-sm",children:n!=null&&n.isActive("heading",{level:1})?"Heading 1":n!=null&&n.isActive("heading",{level:2})?"Heading 2":n!=null&&n.isActive("heading",{level:3})?"Heading 3":"Text"}),D.jsx(id,{className:"h-4 w-4"})]}),i.map((s,o)=>s?D.jsx("div",{className:"tooltip tooltip-bottom","data-tip":s.title,children:D.jsx("span",{onClick:()=>s.onClick(),className:Fe("rounded-lg w-8 h-8 p-1 flex cursor-pointer justify-center items-center",s.isActive?"bg-yellow-300":"hover:bg-[#f2f2f2]"),children:typeof s.icon=="string"?D.jsx("img",{src:s.icon,className:"w-4"}):s.icon})},s.title):D.jsx("div",{className:" w-[1px] h-[50%] bg-[#777777]"},o)),t===Te.HEADING&&D.jsx(RT,{setVisibility:r,editor:n,elementRef:e}),t===Te.TEXT_COLOR&&D.jsx(DT,{setVisibility:r,editor:n,elementRef:e}),t===Te.HIGHLIGHT&&D.jsx(MT,{setVisibility:r,editor:n,elementRef:e}),t===Te.FONT_FAMILY&&D.jsx(OT,{setToolVisibility:r,editor:n,elementRef:e}),t===Te.ALIGNMENT&&D.jsx(_T,{setToolVisibility:r,editor:n,elementRef:e}),t===Te.LIST&&D.jsx(NT,{setToolVisibility:r,editor:n,elementRef:e}),t===Te.LINK&&D.jsx(v0,{setToolVisibility:r,editor:n,elementRef:e})]})},Lt=()=>new Map,ad=n=>{const e=Lt();return n.forEach((t,r)=>{e.set(r,t)}),e},zt=(n,e,t)=>{let r=n.get(e);return r===void 0&&n.set(e,r=t()),r},UT=(n,e)=>{const t=[];for(const[r,i]of n)t.push(e(i,r));return t},WT=(n,e)=>{for(const[t,r]of n)if(e(r,t))return!0;return!1},or=()=>new Set,cd=n=>n[n.length-1],qT=(n,e)=>{for(let t=0;t<e.length;t++)n.push(e[t])},lr=Array.from,KT=(n,e)=>{for(let t=0;t<n.length;t++)if(e(n[t],t,n))return!0;return!1},ud=Array.isArray;class dd{constructor(){this._observers=Lt()}on(e,t){return zt(this._observers,e,or).add(t),t}once(e,t){const r=(...i)=>{this.off(e,r),t(...i)};this.on(e,r)}off(e,t){const r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return lr((this._observers.get(e)||Lt()).values()).forEach(r=>r(...t))}destroy(){this._observers=Lt()}}class D0{constructor(){this._observers=Lt()}on(e,t){zt(this._observers,e,or).add(t)}once(e,t){const r=(...i)=>{this.off(e,r),t(...i)};this.on(e,r)}off(e,t){const r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return lr((this._observers.get(e)||Lt()).values()).forEach(r=>r(...t))}destroy(){this._observers=Lt()}}const wn=Math.floor,Wl=Math.abs,JT=Math.log10,Ir=(n,e)=>n<e?n:e,ar=(n,e)=>n>e?n:e,R0=n=>n!==0?n<0:1/n<0,Bn=Date.now,GT=1200,YT=2500,ql=3e4,fd=n=>{if(n.shouldConnect&&n.ws===null){const e=new WebSocket(n.url),t=n.binaryType;let r=null;t&&(e.binaryType=t),n.ws=e,n.connecting=!0,n.connected=!1,e.onmessage=o=>{n.lastMessageReceived=Bn();const l=o.data,a=typeof l=="string"?JSON.parse(l):l;a&&a.type==="pong"&&(clearTimeout(r),r=setTimeout(s,ql/2)),n.emit("message",[a,n])};const i=o=>{n.ws!==null&&(n.ws=null,n.connecting=!1,n.connected?(n.connected=!1,n.emit("disconnect",[{type:"disconnect",error:o},n])):n.unsuccessfulReconnects++,setTimeout(fd,Ir(JT(n.unsuccessfulReconnects+1)*GT,YT),n)),clearTimeout(r)},s=()=>{n.ws===e&&n.send({type:"ping"})};e.onclose=()=>i(null),e.onerror=o=>i(o),e.onopen=()=>{n.lastMessageReceived=Bn(),n.connecting=!1,n.connected=!0,n.unsuccessfulReconnects=0,n.emit("connect",[{type:"connect"},n]),r=setTimeout(s,ql/2)}}};class ZT extends D0{constructor(e,{binaryType:t}={}){super(),this.url=e,this.ws=null,this.binaryType=t||null,this.connected=!1,this.connecting=!1,this.unsuccessfulReconnects=0,this.lastMessageReceived=0,this.shouldConnect=!0,this._checkInterval=setInterval(()=>{this.connected&&ql<Bn()-this.lastMessageReceived&&this.ws.close()},ql/2),fd(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&&fd(this)}}const $n=n=>new Error(n),xn=()=>{throw $n("Method unimplemented")},cn=()=>{throw $n("Unexpected case")},L0=1,I0=2,hd=4,pd=8,wo=32,cr=64,Yt=128,Kl=31,md=63,mi=127,XT=2147483647,QT=crypto.getRandomValues.bind(crypto),P0=Math.random,F0=()=>QT(new Uint32Array(1))[0],eA=n=>n[wn(P0()*n.length)],tA="10000000-1000-4000-8000"+-1e11,B0=()=>tA.replace(/[018]/g,n=>(n^F0()&15>>n/4).toString(16)),$0=Number.MAX_SAFE_INTEGER,nA=Number.isInteger||(n=>typeof n=="number"&&isFinite(n)&&wn(n)===n),rA=String.fromCharCode,iA=n=>n.toLowerCase(),sA=/^\s*/g,oA=n=>n.replace(sA,""),lA=/([A-Z])/g,j0=(n,e)=>oA(n.replace(lA,t=>`${e}${iA(t)}`)),aA=n=>{const e=unescape(encodeURIComponent(n)),t=e.length,r=new Uint8Array(t);for(let i=0;i<t;i++)r[i]=e.codePointAt(i);return r},xo=typeof TextEncoder<"u"?new TextEncoder:null,gd=xo?n=>xo.encode(n):aA;let Co=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Co&&Co.decode(new Uint8Array).length===1&&(Co=null);class ko{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const gt=()=>new ko,cA=n=>{let e=n.cpos;for(let t=0;t<n.bufs.length;t++)e+=n.bufs[t].length;return e},qe=n=>{const e=new Uint8Array(cA(n));let t=0;for(let r=0;r<n.bufs.length;r++){const i=n.bufs[r];e.set(i,t),t+=i.length}return e.set(new Uint8Array(n.cbuf.buffer,0,n.cpos),t),e},uA=(n,e)=>{const t=n.cbuf.length;t-n.cpos<e&&(n.bufs.push(new Uint8Array(n.cbuf.buffer,0,n.cpos)),n.cbuf=new Uint8Array(ar(t,e)*2),n.cpos=0)},yt=(n,e)=>{const t=n.cbuf.length;n.cpos===t&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(t*2),n.cpos=0),n.cbuf[n.cpos++]=e},So=yt,ae=(n,e)=>{for(;e>mi;)yt(n,Yt|mi&e),e=wn(e/128);yt(n,mi&e)},yd=(n,e)=>{const t=R0(e);for(t&&(e=-e),yt(n,(e>md?Yt:0)|(t?cr:0)|md&e),e=wn(e/64);e>0;)yt(n,(e>mi?Yt:0)|mi&e),e=wn(e/128)},bd=new Uint8Array(3e4),dA=bd.length/3,fA=(n,e)=>{if(e.length<dA){const t=xo.encodeInto(e,bd).written||0;ae(n,t);for(let r=0;r<t;r++)yt(n,bd[r])}else Xe(n,gd(e))},hA=(n,e)=>{const t=unescape(encodeURIComponent(e)),r=t.length;ae(n,r);for(let i=0;i<r;i++)yt(n,t.codePointAt(i))},jn=xo&&xo.encodeInto?fA:hA,Jl=(n,e)=>{const t=n.cbuf.length,r=n.cpos,i=Ir(t-r,e.length),s=e.length-i;n.cbuf.set(e.subarray(0,i),r),n.cpos+=i,s>0&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(ar(t*2,s)),n.cbuf.set(e.subarray(i)),n.cpos=s)},Xe=(n,e)=>{ae(n,e.byteLength),Jl(n,e)},vd=(n,e)=>{uA(n,e);const t=new DataView(n.cbuf.buffer,n.cpos,e);return n.cpos+=e,t},pA=(n,e)=>vd(n,4).setFloat32(0,e,!1),mA=(n,e)=>vd(n,8).setFloat64(0,e,!1),gA=(n,e)=>vd(n,8).setBigInt64(0,e,!1),H0=new DataView(new ArrayBuffer(4)),yA=n=>(H0.setFloat32(0,n),H0.getFloat32(0)===n),ts=(n,e)=>{switch(typeof e){case"string":yt(n,119),jn(n,e);break;case"number":nA(e)&&Wl(e)<=XT?(yt(n,125),yd(n,e)):yA(e)?(yt(n,124),pA(n,e)):(yt(n,123),mA(n,e));break;case"bigint":yt(n,122),gA(n,e);break;case"object":if(e===null)yt(n,126);else if(ud(e)){yt(n,117),ae(n,e.length);for(let t=0;t<e.length;t++)ts(n,e[t])}else if(e instanceof Uint8Array)yt(n,116),Xe(n,e);else{yt(n,118);const t=Object.keys(e);ae(n,t.length);for(let r=0;r<t.length;r++){const i=t[r];jn(n,i),ts(n,e[i])}}break;case"boolean":yt(n,e?120:121);break;default:yt(n,127)}};class V0 extends ko{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 z0=n=>{n.count>0&&(yd(n.encoder,n.count===1?n.s:-n.s),n.count>1&&ae(n.encoder,n.count-2))};class Gl{constructor(){this.encoder=new ko,this.s=0,this.count=0}write(e){this.s===e?this.count++:(z0(this),this.count=1,this.s=e)}toUint8Array(){return z0(this),qe(this.encoder)}}const U0=n=>{if(n.count>0){const e=n.diff*2+(n.count===1?0:1);yd(n.encoder,e),n.count>1&&ae(n.encoder,n.count-2)}};class wd{constructor(){this.encoder=new ko,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(U0(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return U0(this),qe(this.encoder)}}class bA{constructor(){this.sarr=[],this.s="",this.lensE=new Gl}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 ko;return this.sarr.push(this.s),this.s="",jn(e,this.sarr.join("")),Jl(e,this.lensE.toUint8Array()),qe(e)}}const W0=$n("Unexpected end of array"),q0=$n("Integer out of Range");class Yl{constructor(e){this.arr=e,this.pos=0}}const Hn=n=>new Yl(n),vA=n=>n.pos!==n.arr.length,wA=(n,e)=>{const t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},bt=n=>wA(n,he(n)),gi=n=>n.arr[n.pos++],he=n=>{let e=0,t=1;const r=n.arr.length;for(;n.pos<r;){const i=n.arr[n.pos++];if(e=e+(i&mi)*t,t*=128,i<Yt)return e;if(e>$0)throw q0}throw W0},xd=n=>{let e=n.arr[n.pos++],t=e&md,r=64;const i=(e&cr)>0?-1:1;if(!(e&Yt))return i*t;const s=n.arr.length;for(;n.pos<s;){if(e=n.arr[n.pos++],t=t+(e&mi)*r,r*=128,e<Yt)return i*t;if(t>$0)throw q0}throw W0},ur=Co?n=>Co.decode(bt(n)):n=>{let e=he(n);if(e===0)return"";{let t=String.fromCodePoint(gi(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(gi(n));else for(;e>0;){const r=e<1e4?e:1e4,i=n.arr.subarray(n.pos,n.pos+r);n.pos+=r,t+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(t))}},Cd=(n,e)=>{const t=new DataView(n.arr.buffer,n.arr.byteOffset+n.pos,e);return n.pos+=e,t},xA=[n=>{},n=>null,xd,n=>Cd(n,4).getFloat32(0,!1),n=>Cd(n,8).getFloat64(0,!1),n=>Cd(n,8).getBigInt64(0,!1),n=>!1,n=>!0,ur,n=>{const e=he(n),t={};for(let r=0;r<e;r++){const i=ur(n);t[i]=ns(n)}return t},n=>{const e=he(n),t=[];for(let r=0;r<e;r++)t.push(ns(n));return t},bt],ns=n=>xA[127-gi(n)](n);class K0 extends Yl{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),vA(this)?this.count=he(this)+1:this.count=-1),this.count--,this.s}}class Zl extends Yl{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=xd(this);const e=R0(this.s);this.count=1,e&&(this.s=-this.s,this.count=he(this)+2)}return this.count--,this.s}}class kd extends Yl{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=xd(this),t=e&1;this.diff=wn(e/2),this.count=1,t&&(this.count=he(this)+2)}return this.s+=this.diff,this.count--,this.s}}class CA{constructor(e){this.decoder=new Zl(e),this.str=ur(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}const J0=n=>n===void 0?null:n;class kA{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}let G0=new kA,Sd=!0;try{typeof localStorage<"u"&&localStorage&&(G0=localStorage,Sd=!1)}catch{}const Y0=G0,SA=n=>Sd||addEventListener("storage",n),EA=n=>Sd||removeEventListener("storage",n),TA=Object.assign,Ed=Object.keys,AA=(n,e)=>{for(const t in n)e(n[t],t)},Z0=n=>Ed(n).length,X0=n=>Ed(n).length,MA=n=>{for(const e in n)return!1;return!0},OA=(n,e)=>{for(const t in n)if(!e(n[t],t))return!1;return!0},Q0=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),_A=(n,e)=>n===e||X0(n)===X0(e)&&OA(n,(t,r)=>(t!==void 0||Q0(e,r))&&e[r]===t),Td=(n,e,t=0)=>{try{for(;t<n.length;t++)n[t](...e)}finally{t<n.length&&Td(n,e,t+1)}},NA=()=>{},DA=n=>n,RA=(n,e)=>n===e,Eo=(n,e)=>{if(n==null||e==null)return RA(n,e);if(n.constructor!==e.constructor)return!1;if(n===e)return!0;switch(n.constructor){case ArrayBuffer:n=new Uint8Array(n),e=new Uint8Array(e);case Uint8Array:{if(n.byteLength!==e.byteLength)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;break}case Set:{if(n.size!==e.size)return!1;for(const t of n)if(!e.has(t))return!1;break}case Map:{if(n.size!==e.size)return!1;for(const t of n.keys())if(!e.has(t)||!Eo(n.get(t),e.get(t)))return!1;break}case Object:if(Z0(n)!==Z0(e))return!1;for(const t in n)if(!Q0(n,t)||!Eo(n[t],e[t]))return!1;break;case Array:if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!Eo(n[t],e[t]))return!1;break;default:return!1}return!0},LA=(n,e)=>e.includes(n),rs=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",Ad=typeof window<"u"&&typeof document<"u"&&!rs;let Vn;const IA=()=>{if(Vn===void 0)if(rs){Vn=Lt();const n=process.argv;let e=null;for(let t=0;t<n.length;t++){const r=n[t];r[0]==="-"?(e!==null&&Vn.set(e,""),e=r):e!==null&&(Vn.set(e,r),e=null)}e!==null&&Vn.set(e,"")}else typeof location=="object"?(Vn=Lt(),(location.search||"?").slice(1).split("&").forEach(n=>{if(n.length!==0){const[e,t]=n.split("=");Vn.set(`--${j0(e,"-")}`,t),Vn.set(`-${j0(e,"-")}`,t)}})):Vn=Lt();return Vn},Md=n=>IA().has(n),Xl=n=>J0(rs?process.env[n.toUpperCase().replaceAll("-","_")]:Y0.getItem(n));(n=>Md("--"+n)||Xl(n)!==null)("production");const ey=rs&&LA(process.env.FORCE_COLOR,["true","1","2"]),PA=!Md("--no-colors")&&(!rs||process.stdout.isTTY||ey)&&(!rs||Md("--color")||ey||Xl("COLORTERM")!==null||(Xl("TERM")||"").includes("color"));class FA{constructor(e,t){this.left=e,this.right=t}}const dr=(n,e)=>new FA(n,e),BA=typeof document<"u"?document:{};typeof DOMParser<"u"&&new DOMParser;const $A=n=>UT(n,(e,t)=>`${t}:${e};`).join(""),jA=JSON.stringify,HA=(n=>class{constructor(t){this._=t}destroy(){n(this._)}})(clearTimeout),Od=(n,e)=>new HA(setTimeout(e,n)),fr=Symbol,un=fr(),yi=fr(),ty=fr(),_d=fr(),ny=fr(),ry=fr(),iy=fr(),Ql=fr(),ea=fr(),VA=n=>{var r;n.length===1&&((r=n[0])==null?void 0:r.constructor)===Function&&(n=n[0]());const e=[];let t=0;for(;t<n.length;t++){const i=n[t];i===void 0||i.constructor===String||i.constructor===Number||i.constructor===Object&&e.push(JSON.stringify(i))}return e},sy=[ny,iy,Ql,ty];let Nd=0,oy=Bn();const zA=(n,e)=>{const t=sy[Nd],r=Xl("log"),i=r!==null&&(r==="*"||r==="true"||new RegExp(r,"gi").test(e));return Nd=(Nd+1)%sy.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-oy;oy=o,n(t,e,ea,...s.map(c=>{switch(c!=null&&c.constructor===Uint8Array&&(c=Array.from(c)),typeof c){case"string":case"symbol":return c;default:return jA(c)}}),t," +"+l+"ms")}:NA},UA={[un]:dr("font-weight","bold"),[yi]:dr("font-weight","normal"),[ty]:dr("color","blue"),[ny]:dr("color","green"),[_d]:dr("color","grey"),[ry]:dr("color","red"),[iy]:dr("color","purple"),[Ql]:dr("color","orange"),[ea]:dr("color","black")},ly=PA?n=>{var o;n.length===1&&((o=n[0])==null?void 0:o.constructor)===Function&&(n=n[0]());const e=[],t=[],r=Lt();let i=[],s=0;for(;s<n.length;s++){const l=n[s],a=UA[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=$A(r);s>0||c.length>0?(e.push("%c"+l),t.push(c)):e.push(l)}else break}}for(s>0&&(i=t,i.unshift(e.join("")));s<n.length;s++){const l=n[s];l instanceof Symbol||i.push(l)}return i}:VA,ay=(...n)=>{console.log(...ly(n)),cy.forEach(e=>e.print(n))},WA=(...n)=>{console.warn(...ly(n)),n.unshift(Ql),cy.forEach(e=>e.print(n))},cy=or(),qA=n=>zA(ay,n),uy=n=>new Promise(n);Promise.all.bind(Promise);const KA=n=>Promise.reject(n),Dd=n=>Promise.resolve(n),dy=n=>new Uint8Array(n),JA=(n,e,t)=>new Uint8Array(n,e,t),GA=n=>new Uint8Array(n),YA=n=>{let e="";for(let t=0;t<n.byteLength;t++)e+=rA(n[t]);return btoa(e)},ZA=n=>Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString("base64"),XA=n=>{const e=atob(n),t=dy(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t},QA=n=>{const e=Buffer.from(n,"base64");return JA(e.buffer,e.byteOffset,e.byteLength)},fy=Ad?YA:ZA,hy=Ad?XA:QA,eM=n=>{const e=dy(n.byteLength);return e.set(n),e},py=new Map;class tM{constructor(e){this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&this.onmessage!==null&&this.onmessage({data:hy(t.newValue||"")}),SA(this._onChange)}postMessage(e){Y0.setItem(this.room,fy(GA(e)))}close(){EA(this._onChange)}}const nM=typeof BroadcastChannel>"u"?tM:BroadcastChannel,Rd=n=>zt(py,n,()=>{const e=or(),t=new nM(n);return t.onmessage=r=>e.forEach(i=>i(r.data,"broadcastchannel")),{bc:t,subs:e}}),rM=(n,e)=>(Rd(n).subs.add(e),e),iM=(n,e)=>{const t=Rd(n),r=t.subs.delete(e);return r&&t.subs.size===0&&(t.bc.close(),py.delete(n)),r},sM=(n,e,t=null)=>{const r=Rd(n);r.bc.postMessage(e),r.subs.forEach(i=>i(e,t))},my=()=>{let n=!0;return(e,t)=>{if(n){n=!1;try{e()}finally{n=!0}}else t!==void 0&&t()}},gy=n=>({[Symbol.iterator](){return this},next:n}),oM=(n,e)=>gy(()=>{let t;do t=n.next();while(!t.done&&!e(t.value));return t}),Ld=(n,e)=>gy(()=>{const{done:t,value:r}=n.next();return{done:t,value:t?void 0:e(r)}});class Id{constructor(e,t){this.clock=e,this.len=t}}class is{constructor(){this.clients=new Map}}const Pr=(n,e,t)=>e.clients.forEach((r,i)=>{const s=n.doc.store.clients.get(i);for(let o=0;o<r.length;o++){const l=r[o];Fy(n,s,l.clock,l.len,t)}}),lM=(n,e)=>{let t=0,r=n.length-1;for(;t<=r;){const i=wn((t+r)/2),s=n[i],o=s.clock;if(o<=e){if(e<o+s.len)return i;t=i+1}else r=i-1}return null},ss=(n,e)=>{const t=n.clients.get(e.client);return t!==void 0&&lM(t,e.clock)!==null},Pd=n=>{n.clients.forEach(e=>{e.sort((i,s)=>i.clock-s.clock);let t,r;for(t=1,r=1;t<e.length;t++){const i=e[r-1],s=e[t];i.clock+i.len>=s.clock?i.len=ar(i.len,s.clock+s.len-i.clock):(r<t&&(e[r]=s),r++)}e.length=r})},Fd=n=>{const e=new is;for(let t=0;t<n.length;t++)n[t].clients.forEach((r,i)=>{if(!e.clients.has(i)){const s=r.slice();for(let o=t+1;o<n.length;o++)qT(s,n[o].clients.get(i)||[]);e.clients.set(i,s)}});return Pd(e),e},To=(n,e,t,r)=>{zt(n.clients,e,()=>[]).push(new Id(t,r))},yy=()=>new is,by=n=>{const e=yy();return n.clients.forEach((t,r)=>{const i=[];for(let s=0;s<t.length;s++){const o=t[s];if(o.deleted){const l=o.id.clock;let a=o.length;if(s+1<t.length)for(let c=t[s+1];s+1<t.length&&c.deleted;c=t[++s+1])a+=c.length;i.push(new Id(l,a))}}i.length>0&&e.clients.set(r,i)}),e},ls=(n,e)=>{ae(n.restEncoder,e.clients.size),lr(e.clients.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{n.resetDsCurVal(),ae(n.restEncoder,t);const i=r.length;ae(n.restEncoder,i);for(let s=0;s<i;s++){const o=r[s];n.writeDsClock(o.clock),n.writeDsLen(o.len)}})},Bd=n=>{const e=new is,t=he(n.restDecoder);for(let r=0;r<t;r++){n.resetDsCurVal();const i=he(n.restDecoder),s=he(n.restDecoder);if(s>0){const o=zt(e.clients,i,()=>[]);for(let l=0;l<s;l++)o.push(new Id(n.readDsClock(),n.readDsLen()))}}return e},vy=(n,e,t)=>{const r=new is,i=he(n.restDecoder);for(let s=0;s<i;s++){n.resetDsCurVal();const o=he(n.restDecoder),l=he(n.restDecoder),a=t.clients.get(o)||[],c=rt(t,o);for(let u=0;u<l;u++){const d=n.readDsClock(),f=d+n.readDsLen();if(d<c){c<f&&To(r,o,c,f-c);let h=zn(a,d),p=a[h];for(!p.deleted&&p.id.clock<d&&(a.splice(h+1,0,ha(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,ha(e,p,f-p.id.clock)),p.delete(e))}else To(r,o,d,f-d)}}if(r.clients.size>0){const s=new bi;return ae(s.restEncoder,0),ls(s,r),s.toUint8Array()}return null},wy=F0;class as extends dd{constructor({guid:e=B0(),collectionid:t=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=wy(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Ly,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=uy(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const a=()=>uy(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&&Be(e.parent.doc,t=>{t.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,t=null){return Be(this,e,t)}get(e,t=Et){const r=zt(this.share,e,()=>{const s=new t;return s._integrate(this,null),s}),i=r.constructor;if(t!==Et&&i!==t)if(i===Et){const s=new t;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,hs)}getText(e=""){return this.get(e,wi)}getMap(e=""){return this.get(e,ps)}getXmlElement(e=""){return this.get(e,It)}getXmlFragment(e=""){return this.get(e,xi)}toJSON(){const e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON()}),e}destroy(){lr(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(e!==null){this._item=null;const t=e.content;t.doc=new as({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,Be(e.parent.doc,r=>{const i=t.doc;e.deleted||r.subdocsAdded.add(i),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class xy{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return he(this.restDecoder)}readDsLen(){return he(this.restDecoder)}}class Cy extends xy{readLeftID(){return pe(he(this.restDecoder),he(this.restDecoder))}readRightID(){return pe(he(this.restDecoder),he(this.restDecoder))}readClient(){return he(this.restDecoder)}readInfo(){return gi(this.restDecoder)}readString(){return ur(this.restDecoder)}readParentInfo(){return he(this.restDecoder)===1}readTypeRef(){return he(this.restDecoder)}readLen(){return he(this.restDecoder)}readAny(){return ns(this.restDecoder)}readBuf(){return eM(bt(this.restDecoder))}readJSON(){return JSON.parse(ur(this.restDecoder))}readKey(){return ur(this.restDecoder)}}class aM{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=he(this.restDecoder),this.dsCurrVal}readDsLen(){const e=he(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class cs extends aM{constructor(e){super(e),this.keys=[],he(e),this.keyClockDecoder=new kd(bt(e)),this.clientDecoder=new Zl(bt(e)),this.leftClockDecoder=new kd(bt(e)),this.rightClockDecoder=new kd(bt(e)),this.infoDecoder=new K0(bt(e),gi),this.stringDecoder=new CA(bt(e)),this.parentInfoDecoder=new K0(bt(e),gi),this.typeRefDecoder=new Zl(bt(e)),this.lenDecoder=new Zl(bt(e))}readLeftID(){return new us(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new us(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 ns(this.restDecoder)}readBuf(){return bt(this.restDecoder)}readJSON(){return ns(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const t=this.stringDecoder.read();return this.keys.push(t),t}}}class ky{constructor(){this.restEncoder=gt()}toUint8Array(){return qe(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){ae(this.restEncoder,e)}writeDsLen(e){ae(this.restEncoder,e)}}class Ao extends ky{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){So(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){ts(this.restEncoder,e)}writeBuf(e){Xe(this.restEncoder,e)}writeJSON(e){jn(this.restEncoder,JSON.stringify(e))}writeKey(e){jn(this.restEncoder,e)}}class Sy{constructor(){this.restEncoder=gt(),this.dsCurrVal=0}toUint8Array(){return qe(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,ae(this.restEncoder,t)}writeDsLen(e){e===0&&cn(),ae(this.restEncoder,e-1),this.dsCurrVal+=e}}class bi extends Sy{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new wd,this.clientEncoder=new Gl,this.leftClockEncoder=new wd,this.rightClockEncoder=new wd,this.infoEncoder=new V0(So),this.stringEncoder=new bA,this.parentInfoEncoder=new V0(So),this.typeRefEncoder=new Gl,this.lenEncoder=new Gl}toUint8Array(){const e=gt();return ae(e,0),Xe(e,this.keyClockEncoder.toUint8Array()),Xe(e,this.clientEncoder.toUint8Array()),Xe(e,this.leftClockEncoder.toUint8Array()),Xe(e,this.rightClockEncoder.toUint8Array()),Xe(e,qe(this.infoEncoder)),Xe(e,this.stringEncoder.toUint8Array()),Xe(e,qe(this.parentInfoEncoder)),Xe(e,this.typeRefEncoder.toUint8Array()),Xe(e,this.lenEncoder.toUint8Array()),Jl(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){ts(this.restEncoder,e)}writeBuf(e){Xe(this.restEncoder,e)}writeJSON(e){ts(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}}const cM=(n,e,t,r)=>{r=ar(r,e[0].id.clock);const i=zn(e,r);ae(n.restEncoder,e.length-i),n.writeClient(t),ae(n.restEncoder,r);const s=e[i];s.write(n,r-s.id.clock);for(let o=i+1;o<e.length;o++)e[o].write(n,0)},$d=(n,e,t)=>{const r=new Map;t.forEach((i,s)=>{rt(e,s)>i&&r.set(s,i)}),Do(e).forEach((i,s)=>{t.has(s)||r.set(s,0)}),ae(n.restEncoder,r.size),lr(r.entries()).sort((i,s)=>s[0]-i[0]).forEach(([i,s])=>{cM(n,e.clients.get(i),i,s)})},uM=(n,e)=>{const t=Lt(),r=he(n.restDecoder);for(let i=0;i<r;i++){const s=he(n.restDecoder),o=new Array(s),l=n.readClient();let a=he(n.restDecoder);t.set(l,{i:0,refs:o});for(let c=0;c<s;c++){const u=n.readInfo();switch(Kl&u){case 0:{const d=n.readLen();o[c]=new dn(pe(l,a),d),a+=d;break}case 10:{const d=he(n.restDecoder);o[c]=new fn(pe(l,a),d),a+=d;break}default:{const d=(u&(cr|Yt))===0,f=new ze(pe(l,a),null,(u&Yt)===Yt?n.readLeftID():null,null,(u&cr)===cr?n.readRightID():null,d?n.readParentInfo()?e.get(n.readString()):n.readLeftID():null,d&&(u&wo)===wo?n.readString():null,pb(n,u));o[c]=f,a+=f.length}}}}return t},dM=(n,e,t)=>{const r=[];let i=lr(t.keys()).sort((h,p)=>h-p);if(i.length===0)return null;const s=()=>{if(i.length===0)return null;let h=t.get(i[i.length-1]);for(;h.refs.length===h.i;)if(i.pop(),i.length>0)h=t.get(i[i.length-1]);else return null;return h};let o=s();if(o===null)return null;const l=new Ly,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=t.get(p);g?(g.i--,l.clients.set(p,g.refs.slice(g.i)),t.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=zt(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(n,e);if(g!==null){r.push(u);const v=t.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(n,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 $d(h,l,new Map),ae(h.restEncoder,0),{missing:a,update:h.toUint8Array()}}return null},fM=(n,e)=>$d(n,e.doc.store,e.beforeState),hM=(n,e,t,r=new cs(n))=>Be(e,i=>{i.local=!1;let s=!1;const o=i.doc,l=o.store,a=uM(r,o),c=dM(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=ra([u.update,c.update])}}else l.pendingStructs=c;const d=vy(r,i,l);if(l.pendingDs){const f=new cs(Hn(l.pendingDs));he(f.restDecoder);const h=vy(f,i,l);d&&h?l.pendingDs=ra([d,h]):l.pendingDs=d||h}else l.pendingDs=d;if(s){const f=l.pendingStructs.update;l.pendingStructs=null,Ey(i.doc,f)}},t,!1),Ey=(n,e,t,r=cs)=>{const i=Hn(e);hM(i,n,t,new r(i))},pM=(n,e,t)=>Ey(n,e,t,Cy),mM=(n,e,t=new Map)=>{$d(n,e.store,t),ls(n,by(e.store))},gM=(n,e=new Uint8Array([0]),t=new bi)=>{const r=Ty(e);mM(t,n,r);const i=[t.toUint8Array()];if(n.store.pendingDs&&i.push(n.store.pendingDs),n.store.pendingStructs&&i.push(IM(n.store.pendingStructs.update,e)),i.length>1){if(t.constructor===Ao)return RM(i.map((s,o)=>o===0?s:FM(s)));if(t.constructor===bi)return ra(i)}return i[0]},yM=(n,e)=>gM(n,e,new Ao),bM=n=>{const e=new Map,t=he(n.restDecoder);for(let r=0;r<t;r++){const i=he(n.restDecoder),s=he(n.restDecoder);e.set(i,s)}return e},Ty=n=>bM(new xy(Hn(n))),Ay=(n,e)=>(ae(n.restEncoder,e.size),lr(e.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{ae(n.restEncoder,t),ae(n.restEncoder,r)}),n),vM=(n,e)=>Ay(n,Do(e.store)),wM=(n,e=new Sy)=>(n instanceof Map?Ay(e,n):vM(e,n),e.toUint8Array()),xM=n=>wM(n,new ky);class CM{constructor(){this.l=[]}}const My=()=>new CM,Oy=(n,e)=>n.l.push(e),_y=(n,e)=>{const t=n.l,r=t.length;n.l=t.filter(i=>e!==i),r===n.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},Ny=(n,e,t)=>Td(n.l,[e,t]);class us{constructor(e,t){this.client=e,this.clock=t}}const ds=(n,e)=>n===e||n!==null&&e!==null&&n.client===e.client&&n.clock===e.clock,pe=(n,e)=>new us(n,e),Mo=n=>{for(const[e,t]of n.doc.share.entries())if(t===n)return e;throw cn()},Oo=(n,e)=>{for(;e!==null;){if(e.parent===n)return!0;e=e.parent._item}return!1};class _o{constructor(e,t,r,i=0){this.type=e,this.tname=t,this.item=r,this.assoc=i}}const No=n=>new _o(n.type==null?null:pe(n.type.client,n.type.clock),n.tname||null,n.item==null?null:pe(n.item.client,n.item.clock),n.assoc==null?0:n.assoc);class kM{constructor(e,t,r=0){this.type=e,this.index=t,this.assoc=r}}const SM=(n,e,t=0)=>new kM(n,e,t),ta=(n,e,t)=>{let r=null,i=null;return n._item===null?i=Mo(n):r=pe(n._item.id.client,n._item.id.clock),new _o(r,i,e,t)},jd=(n,e,t=0)=>{let r=n._start;if(t<0){if(e===0)return ta(n,null,t);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return ta(n,pe(r.id.client,r.id.clock+e),t);e-=r.length}if(r.right===null&&t<0)return ta(n,r.lastId,t);r=r.right}return ta(n,null,t)},EM=(n,e,t=!0)=>{const r=e.store,i=n.item,s=n.type,o=n.tname,l=n.assoc;let a=null,c=0;if(i!==null){if(rt(r,i.client)<=i.clock)return null;const u=t?ef(r,i):{item:fs(r,i),diff:0},d=u.item;if(!(d instanceof ze))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}=t?ef(r,s):{item:fs(r,s)};if(u instanceof ze&&u.content instanceof kn)a=u.content.type;else return null}else throw cn();l>=0?c=a._length:c=0}return SM(a,c,n.assoc)},Dy=(n,e)=>n===e||n!==null&&e!==null&&n.tname===e.tname&&ds(n.item,e.item)&&ds(n.type,e.type)&&n.assoc===e.assoc;class Hd{constructor(e,t){this.ds=e,this.sv=t}}const Ry=(n,e)=>new Hd(n,e),TM=n=>Ry(by(n.store),Do(n.store)),vi=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&(e.sv.get(n.id.client)||0)>n.id.clock&&!ss(e.ds,n.id),Vd=(n,e)=>{const t=zt(n.meta,Vd,or),r=n.doc.store;t.has(e)||(e.sv.forEach((i,s)=>{i<rt(r,s)&&Ut(n,pe(s,i))}),Pr(n,e.ds,i=>{}),t.add(e))};class Ly{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Do=n=>{const e=new Map;return n.clients.forEach((t,r)=>{const i=t[t.length-1];e.set(r,i.id.clock+i.length)}),e},rt=(n,e)=>{const t=n.clients.get(e);if(t===void 0)return 0;const r=t[t.length-1];return r.id.clock+r.length},Iy=(n,e)=>{let t=n.clients.get(e.id.client);if(t===void 0)t=[],n.clients.set(e.id.client,t);else{const r=t[t.length-1];if(r.id.clock+r.length!==e.id.clock)throw cn()}t.push(e)},zn=(n,e)=>{let t=0,r=n.length-1,i=n[r],s=i.id.clock;if(s===e)return r;let o=wn(e/(s+i.length-1)*r);for(;t<=r;){if(i=n[o],s=i.id.clock,s<=e){if(e<s+i.length)return o;t=o+1}else r=o-1;o=wn((t+r)/2)}throw cn()},fs=(n,e)=>{const t=n.clients.get(e.client);return t[zn(t,e.clock)]},zd=(n,e,t)=>{const r=zn(e,t),i=e[r];return i.id.clock<t&&i instanceof ze?(e.splice(r+1,0,ha(n,i,t-i.id.clock)),r+1):r},Ut=(n,e)=>{const t=n.doc.store.clients.get(e.client);return t[zd(n,t,e.clock)]},Py=(n,e,t)=>{const r=e.clients.get(t.client),i=zn(r,t.clock),s=r[i];return t.clock!==s.id.clock+s.length-1&&s.constructor!==dn&&r.splice(i+1,0,ha(n,s,t.clock-s.id.clock+1)),s},AM=(n,e,t)=>{const r=n.clients.get(e.id.client);r[zn(r,e.id.clock)]=t},Fy=(n,e,t,r,i)=>{if(r===0)return;const s=t+r;let o=zd(n,e,t),l;do l=e[o++],s<l.id.clock+l.length&&zd(n,e,s),i(l);while(o<e.length&&e[o].id.clock<s)};class MM{constructor(e,t,r){this.doc=e,this.deleteSet=new is,this.beforeState=Do(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const By=(n,e)=>e.deleteSet.clients.size===0&&!WT(e.afterState,(t,r)=>e.beforeState.get(r)!==t)?!1:(Pd(e.deleteSet),fM(n,e),ls(n,e.deleteSet),!0),$y=(n,e,t)=>{const r=e._item;(r===null||r.id.clock<(n.beforeState.get(r.id.client)||0)&&!r.deleted)&&zt(n.changed,e,or).add(t)},na=(n,e)=>{let t=n[e],r=n[e-1],i=e;for(;i>0;t=r,r=n[--i-1]){if(r.deleted===t.deleted&&r.constructor===t.constructor&&r.mergeWith(t)){t instanceof ze&&t.parentSub!==null&&t.parent._map.get(t.parentSub)===t&&t.parent._map.set(t.parentSub,r);continue}break}const s=e-i;return s&&n.splice(e+1-s,s),s},OM=(n,e,t)=>{for(const[r,i]of n.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=zn(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 ze&&d.deleted&&!d.keep&&t(d)&&d.gc(e,!1)}}}},_M=(n,e)=>{n.clients.forEach((t,r)=>{const i=e.clients.get(r);for(let s=t.length-1;s>=0;s--){const o=t[s],l=Ir(i.length-1,1+zn(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+na(i,a)}})},jy=(n,e)=>{if(e<n.length){const t=n[e],r=t.doc,i=r.store,s=t.deleteSet,o=t._mergeStructs;try{Pd(s),t.afterState=Do(t.doc.store),r.emit("beforeObserverCalls",[t,r]);const l=[];t.changed.forEach((a,c)=>l.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(t,a)})),l.push(()=>{t.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),Ny(c._dEH,a,t))})}),l.push(()=>r.emit("afterTransaction",[t,r])),Td(l,[]),t._needFormattingCleanup&&ZM(t)}finally{r.gc&&OM(s,i,r.gcFilter),_M(s,i),t.afterState.forEach((u,d)=>{const f=t.beforeState.get(d)||0;if(f!==u){const h=i.clients.get(d),p=ar(zn(h,f),1);for(let g=h.length-1;g>=p;)g-=1+na(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=zn(h,f);p+1<h.length&&na(h,p+1)>1||p>0&&na(h,p)}if(!t.local&&t.afterState.get(r.clientID)!==t.beforeState.get(r.clientID)&&(ay(Ql,un,"[yjs] ",yi,ry,"Changed the client-id because another client seems to be using it."),r.clientID=wy()),r.emit("afterTransactionCleanup",[t,r]),r._observers.has("update")){const u=new Ao;By(u,t)&&r.emit("update",[u.toUint8Array(),t.origin,r,t])}if(r._observers.has("updateV2")){const u=new bi;By(u,t)&&r.emit("updateV2",[u.toUint8Array(),t.origin,r,t])}const{subdocsAdded:l,subdocsLoaded:a,subdocsRemoved:c}=t;(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,t]),c.forEach(u=>u.destroy())),n.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,n])):jy(n,e+1)}}},Be=(n,e,t=null,r=!0)=>{const i=n._transactionCleanups;let s=!1,o=null;n._transaction===null&&(s=!0,n._transaction=new MM(n,t,r),i.push(n._transaction),i.length===1&&n.emit("beforeAllTransactions",[n]),n.emit("beforeTransaction",[n._transaction,n]));try{o=e(n._transaction)}finally{if(s){const l=n._transaction===i[0];n._transaction=null,l&&jy(i,0)}}return o};class NM{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}}const Hy=(n,e,t)=>{Pr(n,t.deletions,r=>{r instanceof ze&&e.scope.some(i=>Oo(i,r))&&tf(r,!1)})},Vy=(n,e,t)=>{let r=null;const i=n.doc,s=n.scope;if(Be(i,o=>{for(;e.length>0&&n.currStackItem===null;){const l=i.store,a=e.pop(),c=new Set,u=[];let d=!1;Pr(o,a.insertions,f=>{if(f instanceof ze){if(f.redone!==null){let{item:h,diff:p}=ef(l,f.id);p>0&&(h=Ut(o,pe(h.id.client,h.id.clock+p))),f=h}!f.deleted&&s.some(h=>Oo(h,f))&&u.push(f)}}),Pr(o,a.deletions,f=>{f instanceof ze&&s.some(h=>Oo(h,f))&&!ss(a.insertions,f.id)&&c.add(f)}),c.forEach(f=>{d=hb(o,f,c,a.insertions,n.ignoreRemoteMapChanges,n)!==null||d});for(let f=u.length-1;f>=0;f--){const h=u[f];n.deleteFilter(h)&&(h.delete(o),d=!0)}n.currStackItem=d?a:null}o.changed.forEach((l,a)=>{l.has(null)&&a._searchMarker&&(a._searchMarker.length=0)}),r=o},n),n.currStackItem!=null){const o=r.changedParentTypes;n.emit("stack-item-popped",[{stackItem:n.currStackItem,type:t,changedParentTypes:o,origin:n},n]),n.currStackItem=null}return n.currStackItem};class zy extends dd{constructor(e,{captureTimeout:t=500,captureTransaction:r=a=>!0,deleteFilter:i=()=>!0,trackedOrigins:s=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:l=ud(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=t,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 is;a.afterState.forEach((v,w)=>{const S=a.beforeState.get(w)||0,x=v-S;x>0&&To(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=Fd([v.deletions,a.deleteSet]),v.insertions=Fd([v.insertions,f])}else d.push(new NM(a.deleteSet,f)),p=!0;!c&&!u&&(this.lastChange=h),Pr(a,a.deleteSet,v=>{v instanceof ze&&this.scope.some(w=>Oo(w,v))&&tf(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=ud(e)?e:[e],e.forEach(t=>{this.scope.every(r=>r!==t)&&(t.doc!==this.doc&&WA("[yjs#509] Not same Y.Doc"),this.scope.push(t))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(i=>Hy(r,this,i)),this.undoStack=[]),t&&(this.redoStack.forEach(i=>Hy(r,this,i)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Vy(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Vy(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*DM(n){const e=he(n.restDecoder);for(let t=0;t<e;t++){const r=he(n.restDecoder),i=n.readClient();let s=he(n.restDecoder);for(let o=0;o<r;o++){const l=n.readInfo();if(l===10){const a=he(n.restDecoder);yield new fn(pe(i,s),a),s+=a}else if(Kl&l){const a=(l&(cr|Yt))===0,c=new ze(pe(i,s),null,(l&Yt)===Yt?n.readLeftID():null,null,(l&cr)===cr?n.readRightID():null,a?n.readParentInfo()?n.readString():n.readLeftID():null,a&&(l&wo)===wo?n.readString():null,pb(n,l));yield c,s+=c.length}else{const a=n.readLen();yield new dn(pe(i,s),a),s+=a}}}}class Ud{constructor(e,t){this.gen=DM(e),this.curr=null,this.done=!1,this.filterSkips=t,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 Wd{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const RM=n=>ra(n,Cy,Ao),LM=(n,e)=>{if(n.constructor===dn){const{client:t,clock:r}=n.id;return new dn(pe(t,r+e),n.length-e)}else if(n.constructor===fn){const{client:t,clock:r}=n.id;return new fn(pe(t,r+e),n.length-e)}else{const t=n,{client:r,clock:i}=t.id;return new ze(pe(r,i+e),null,pe(r,i+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},ra=(n,e=cs,t=bi)=>{if(n.length===1)return n[0];const r=n.map(u=>new e(Hn(u)));let i=r.map(u=>new Ud(u,!0)),s=null;const o=new t,l=new Wd(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(pe(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=LM(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),qd(l);const a=r.map(u=>Bd(u)),c=Fd(a);return ls(o,c),o.toUint8Array()},IM=(n,e,t=cs,r=bi)=>{const i=Ty(e),s=new r,o=new Wd(s),l=new t(Hn(n)),a=new Ud(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()}qd(o);const c=Bd(l);return ls(s,c),s.toUint8Array()},Uy=n=>{n.written>0&&(n.clientStructs.push({written:n.written,restEncoder:qe(n.encoder.restEncoder)}),n.encoder.restEncoder=gt(),n.written=0)},Fr=(n,e,t)=>{n.written>0&&n.currClient!==e.id.client&&Uy(n),n.written===0&&(n.currClient=e.id.client,n.encoder.writeClient(e.id.client),ae(n.encoder.restEncoder,e.id.clock+t)),e.write(n.encoder,t),n.written++},qd=n=>{Uy(n);const e=n.encoder.restEncoder;ae(e,n.clientStructs.length);for(let t=0;t<n.clientStructs.length;t++){const r=n.clientStructs[t];ae(e,r.written),Jl(e,r.restEncoder)}},PM=(n,e,t,r)=>{const i=new t(Hn(n)),s=new Ud(i,!1),o=new r,l=new Wd(o);for(let c=s.curr;c!==null;c=s.next())Fr(l,e(c),0);qd(l);const a=Bd(i);return ls(o,a),o.toUint8Array()},FM=n=>PM(n,DA,cs,Ao),Wy="You must not compute changes after the event-handler fired.";class ia{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=BM(this.currentTarget,this.target))}deletes(e){return ss(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw $n(Wy);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach(i=>{if(i!==null){const s=t._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=cd(a.content.getContent());else return;else a!==null&&this.deletes(a)?(o="update",l=cd(a.content.getContent())):(o="add",l=void 0)}else if(this.deletes(s))o="delete",l=cd(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 $n(Wy);const t=this.target,r=or(),i=or(),s=[];if(e={added:r,deleted:i,delta:s,keys:this.keys},this.transaction.changed.get(t).has(null)){let l=null;const a=()=>{l&&s.push(l)};for(let c=t._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 BM=(n,e)=>{const t=[];for(;e._item!==null&&e!==n;){if(e._item.parentSub!==null)t.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;t.unshift(r)}e=e._item.parent}return t},qy=80;let Kd=0;class $M{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Kd++}}const jM=n=>{n.timestamp=Kd++},Ky=(n,e,t)=>{n.p.marker=!1,n.p=e,e.marker=!0,n.index=t,n.timestamp=Kd++},HM=(n,e,t)=>{if(n.length>=qy){const r=n.reduce((i,s)=>i.timestamp<s.timestamp?i:s);return Ky(r,e,t),r}else{const r=new $M(e,t);return n.push(r),r}},sa=(n,e)=>{if(n._start===null||e===0||n._searchMarker===null)return null;const t=n._searchMarker.length===0?null:n._searchMarker.reduce((s,o)=>Wl(e-s.index)<Wl(e-o.index)?s:o);let r=n._start,i=0;for(t!==null&&(r=t.p,i=t.index,jM(t));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 t!==null&&Wl(t.index-i)<r.parent.length/qy?(Ky(t,r,i),t):HM(n._searchMarker,r,i)},Ro=(n,e,t)=>{for(let r=n.length-1;r>=0;r--){const i=n[r];if(t>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){n.splice(r,1);continue}i.p=s,s.marker=!0}(e<i.index||t>0&&e===i.index)&&(i.index=ar(e,i.index+t))}},oa=(n,e,t)=>{const r=n,i=e.changedParentTypes;for(;zt(i,n,()=>[]).push(t),n._item!==null;)n=n._item.parent;Ny(r._eH,t,e)};class Et{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=My(),this._dEH=My(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw xn()}clone(){throw xn()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){Oy(this._eH,e)}observeDeep(e){Oy(this._dEH,e)}unobserve(e){_y(this._eH,e)}unobserveDeep(e){_y(this._dEH,e)}toJSON(){}}const Jy=(n,e,t)=>{e<0&&(e=n._length+e),t<0&&(t=n._length+t);let r=t-e;const i=[];let s=n._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},Gy=n=>{const e=[];let t=n._start;for(;t!==null;){if(t.countable&&!t.deleted){const r=t.content.getContent();for(let i=0;i<r.length;i++)e.push(r[i])}t=t.right}return e},Yy=(n,e)=>{const t=[];let r=n._start;for(;r!==null;){if(r.countable&&vi(r,e)){const i=r.content.getContent();for(let s=0;s<i.length;s++)t.push(i[s])}r=r.right}return t},Lo=(n,e)=>{let t=0,r=n._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],t++,n)}r=r.right}},Zy=(n,e)=>{const t=[];return Lo(n,(r,i)=>{t.push(e(r,i,n))}),t},VM=n=>{let e=n._start,t=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(t===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};t=e.content.getContent(),r=0,e=e.right}const i=t[r++];return t.length<=r&&(t=null),{done:!1,value:i}}}},Xy=(n,e)=>{const t=sa(n,e);let r=n._start;for(t!==null&&(r=t.p,e-=t.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},la=(n,e,t,r)=>{let i=t;const s=n.doc,o=s.clientID,l=s.store,a=t===null?e._start:t.right;let c=[];const u=()=>{c.length>0&&(i=new ze(pe(o,rt(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new ki(c)),i.integrate(n,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 ze(pe(o,rt(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new Io(new Uint8Array(d))),i.integrate(n,0);break;case as:i=new ze(pe(o,rt(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new Fo(d)),i.integrate(n,0);break;default:if(d instanceof Et)i=new ze(pe(o,rt(l,o)),i,i&&i.lastId,a,a&&a.id,e,null,new kn(d)),i.integrate(n,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},Qy=()=>$n("Length exceeded!"),eb=(n,e,t,r)=>{if(t>e._length)throw Qy();if(t===0)return e._searchMarker&&Ro(e._searchMarker,t,r.length),la(n,e,null,r);const i=t,s=sa(e,t);let o=e._start;for(s!==null&&(o=s.p,t-=s.index,t===0&&(o=o.prev,t+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(t<=o.length){t<o.length&&Ut(n,pe(o.id.client,o.id.clock+t));break}t-=o.length}return e._searchMarker&&Ro(e._searchMarker,i,r.length),la(n,e,o,r)},zM=(n,e,t)=>{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 la(n,e,i,t)},tb=(n,e,t,r)=>{if(r===0)return;const i=t,s=r,o=sa(e,t);let l=e._start;for(o!==null&&(l=o.p,t-=o.index);l!==null&&t>0;l=l.right)!l.deleted&&l.countable&&(t<l.length&&Ut(n,pe(l.id.client,l.id.clock+t)),t-=l.length);for(;r>0&&l!==null;)l.deleted||(r<l.length&&Ut(n,pe(l.id.client,l.id.clock+r)),l.delete(n),r-=l.length),l=l.right;if(r>0)throw Qy();e._searchMarker&&Ro(e._searchMarker,i,-s+r)},aa=(n,e,t)=>{const r=e._map.get(t);r!==void 0&&r.delete(n)},Jd=(n,e,t,r)=>{const i=e._map.get(t)||null,s=n.doc,o=s.clientID;let l;if(r==null)l=new ki([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:l=new ki([r]);break;case Uint8Array:l=new Io(r);break;case as:l=new Fo(r);break;default:if(r instanceof Et)l=new kn(r);else throw new Error("Unexpected content type")}new ze(pe(o,rt(s.store,o)),i,i&&i.lastId,null,null,e,t,l).integrate(n,0)},Gd=(n,e)=>{const t=n._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},nb=n=>{const e={};return n._map.forEach((t,r)=>{t.deleted||(e[r]=t.content.getContent()[t.length-1])}),e},rb=(n,e)=>{const t=n._map.get(e);return t!==void 0&&!t.deleted},UM=(n,e)=>{const t={};return n._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)&&(t[i]=s.content.getContent()[s.length-1])}),t},ca=n=>oM(n.entries(),e=>!e[1].deleted);class WM extends ia{constructor(e,t){super(e,t),this._transaction=t}}class hs extends Et{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new hs;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new hs}clone(){const e=new hs;return e.insert(0,this.toArray().map(t=>t instanceof Et?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}_callObserver(e,t){super._callObserver(e,t),oa(this,e,new WM(this,e))}insert(e,t){this.doc!==null?Be(this.doc,r=>{eb(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?Be(this.doc,t=>{zM(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?Be(this.doc,r=>{tb(r,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return Xy(this,e)}toArray(){return Gy(this)}slice(e=0,t=this.length){return Jy(this,e,t)}toJSON(){return this.map(e=>e instanceof Et?e.toJSON():e)}map(e){return Zy(this,e)}forEach(e){Lo(this,e)}[Symbol.iterator](){return VM(this)}_write(e){e.writeTypeRef(mO)}}const qM=n=>new hs;class KM extends ia{constructor(e,t,r){super(e,t),this.keysChanged=r}}class ps extends Et{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((r,i)=>{this.set(i,r)}),this._prelimContent=null}_copy(){return new ps}clone(){const e=new ps;return this.forEach((t,r)=>{e.set(r,t instanceof Et?t.clone():t)}),e}_callObserver(e,t){oa(this,e,new KM(this,e,t))}toJSON(){const e={};return this._map.forEach((t,r)=>{if(!t.deleted){const i=t.content.getContent()[t.length-1];e[r]=i instanceof Et?i.toJSON():i}}),e}get size(){return[...ca(this._map)].length}keys(){return Ld(ca(this._map),e=>e[0])}values(){return Ld(ca(this._map),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Ld(ca(this._map),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this._map.forEach((t,r)=>{t.deleted||e(t.content.getContent()[t.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?Be(this.doc,t=>{aa(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?Be(this.doc,r=>{Jd(r,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return Gd(this,e)}has(e){return rb(this,e)}clear(){this.doc!==null?Be(this.doc,e=>{this.forEach(function(t,r,i){aa(e,i,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(gO)}}const JM=n=>new ps,Br=(n,e)=>n===e||typeof n=="object"&&typeof e=="object"&&n&&e&&_A(n,e);class Yd{constructor(e,t,r,i){this.left=e,this.right=t,this.index=r,this.currentAttributes=i}forward(){switch(this.right===null&&cn(),this.right.content.constructor){case lt:this.right.deleted||ms(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 ib=(n,e,t)=>{for(;e.right!==null&&t>0;){switch(e.right.content.constructor){case lt:e.right.deleted||ms(e.currentAttributes,e.right.content);break;default:e.right.deleted||(t<e.right.length&&Ut(n,pe(e.right.id.client,e.right.id.clock+t)),e.index+=e.right.length,t-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},ua=(n,e,t,r)=>{const i=new Map,s=r?sa(e,t):null;if(s){const o=new Yd(s.p.left,s.p,s.index,i);return ib(n,o,t-s.index)}else{const o=new Yd(null,e._start,0,i);return ib(n,o,t)}},sb=(n,e,t,r)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===lt&&Br(r.get(t.right.content.key),t.right.content.value));)t.right.deleted||r.delete(t.right.content.key),t.forward();const i=n.doc,s=i.clientID;r.forEach((o,l)=>{const a=t.left,c=t.right,u=new ze(pe(s,rt(i.store,s)),a,a&&a.lastId,c,c&&c.id,e,null,new lt(l,o));u.integrate(n,0),t.right=u,t.forward()})},ms=(n,e)=>{const{key:t,value:r}=e;r===null?n.delete(t):n.set(t,r)},ob=(n,e)=>{for(;n.right!==null;){if(!(n.right.deleted||n.right.content.constructor===lt&&Br(e[n.right.content.key]??null,n.right.content.value)))break;n.forward()}},lb=(n,e,t,r)=>{const i=n.doc,s=i.clientID,o=new Map;for(const l in r){const a=r[l],c=t.currentAttributes.get(l)??null;if(!Br(c,a)){o.set(l,c);const{left:u,right:d}=t;t.right=new ze(pe(s,rt(i.store,s)),u,u&&u.lastId,d,d&&d.id,e,null,new lt(l,a)),t.right.integrate(n,0),t.forward()}}return o},Zd=(n,e,t,r,i)=>{t.currentAttributes.forEach((f,h)=>{i[h]===void 0&&(i[h]=null)});const s=n.doc,o=s.clientID;ob(t,i);const l=lb(n,e,t,i),a=r.constructor===String?new Cn(r):r instanceof Et?new kn(r):new Ci(r);let{left:c,right:u,index:d}=t;e._searchMarker&&Ro(e._searchMarker,t.index,a.getLength()),u=new ze(pe(o,rt(s.store,o)),c,c&&c.lastId,u,u&&u.id,e,null,a),u.integrate(n,0),t.right=u,t.index=d,t.forward(),sb(n,e,t,l)},ab=(n,e,t,r,i)=>{const s=n.doc,o=s.clientID;ob(t,i);const l=lb(n,e,t,i);e:for(;t.right!==null&&(r>0||l.size>0&&(t.right.deleted||t.right.content.constructor===lt));){if(!t.right.deleted)switch(t.right.content.constructor){case lt:{const{key:a,value:c}=t.right.content,u=i[a];if(u!==void 0){if(Br(u,c))l.delete(a);else{if(r===0)break e;l.set(a,c)}t.right.delete(n)}else t.currentAttributes.set(a,c);break}default:r<t.right.length&&Ut(n,pe(t.right.id.client,t.right.id.clock+r)),r-=t.right.length;break}t.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
323
+ `;t.right=new ze(pe(o,rt(s.store,o)),t.left,t.left&&t.left.lastId,t.right,t.right&&t.right.id,e,null,new Cn(a)),t.right.integrate(n,0),t.forward()}sb(n,e,t,l)},cb=(n,e,t,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(t===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(n),l++,!a&&(i.get(u)??null)===d&&f!==d&&(f===null?i.delete(u):i.set(u,f))),!a&&!e.deleted&&ms(i,c);break}}}e=e.right}return l},GM=(n,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const t=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===lt){const r=e.content.key;t.has(r)?e.delete(n):t.add(r)}e=e.left}},YM=n=>{let e=0;return Be(n.doc,t=>{let r=n._start,i=n._start,s=Lt();const o=ad(s);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case lt:ms(o,i.content);break;default:e+=cb(t,r,i,s,o),s=ad(o),r=i;break}i=i.right}}),e},ZM=n=>{const e=new Set,t=n.doc;for(const[r,i]of n.afterState.entries()){const s=n.beforeState.get(r)||0;i!==s&&Fy(n,t.store.clients.get(r),s,i,o=>{!o.deleted&&o.content.constructor===lt&&o.constructor!==dn&&e.add(o.parent)})}Be(t,r=>{Pr(n,n.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):GM(r,i)});for(const i of e)YM(i)})},ub=(n,e,t)=>{const r=t,i=ad(e.currentAttributes),s=e.right;for(;t>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case kn:case Ci:case Cn:t<e.right.length&&Ut(n,pe(e.right.id.client,e.right.id.clock+t)),t-=e.right.length,e.right.delete(n);break}e.forward()}s&&cb(n,s,e.right,i,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&Ro(o._searchMarker,e.index,-r+t),e};class XM extends ia{constructor(e,t,r){super(e,t),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,t=[];Be(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},MA(a)||(h.attributes=TA({},a))),u=0;break}h&&t.push(h),l=null}};for(;o!==null;){switch(o.content.constructor){case kn:case Ci: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;Br(g,p)?p!==null&&o.delete(r):(l==="retain"&&f(),Br(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;Br(g,p)||(l==="retain"&&f(),a[h]=g)}else if(!o.deleted){s.set(h,p);const g=a[h];g!==void 0&&(Br(g,p)?g!==null&&o.delete(r):(l==="retain"&&f(),p===null?delete a[h]:a[h]=p))}o.deleted||(l==="insert"&&f(),ms(i,o.content));break}}o=o.right}for(f();t.length>0;){const h=t[t.length-1];if(h.retain!==void 0&&h.attributes===void 0)t.pop();else break}}),this._delta=t}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,t){super._integrate(e,t);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,t){super._callObserver(e,t);const r=new XM(this,e,t);oa(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){let e="",t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Cn&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc!==null?Be(this.doc,r=>{const i=new Yd(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=!t&&typeof o.insert=="string"&&s===e.length-1&&i.right===null&&o.insert.slice(-1)===`
324
+ `?o.insert.slice(0,-1):o.insert;(typeof l!="string"||l.length>0)&&Zd(r,this,i,l,o.attributes||{})}else o.retain!==void 0?ab(r,this,i,o.retain,o.attributes||{}):o.delete!==void 0&&ub(r,i,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,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)||t!==void 0&&vi(a,t))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"})):t!==void 0&&!vi(a,t)?(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 kn:case Ci:{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(),ms(s,a.content));break}a=a.right}c()};return e||t?Be(o,d=>{e&&Vd(d,e),t&&Vd(d,t),u()},"cleanup"):u(),i}insert(e,t,r){if(t.length<=0)return;const i=this.doc;i!==null?Be(i,s=>{const o=ua(s,this,e,!r);r||(r={},o.currentAttributes.forEach((l,a)=>{r[a]=l})),Zd(s,this,o,t,r)}):this._pending.push(()=>this.insert(e,t,r))}insertEmbed(e,t,r){const i=this.doc;i!==null?Be(i,s=>{const o=ua(s,this,e,!r);Zd(s,this,o,t,r||{})}):this._pending.push(()=>this.insertEmbed(e,t,r||{}))}delete(e,t){if(t===0)return;const r=this.doc;r!==null?Be(r,i=>{ub(i,ua(i,this,e,!0),t)}):this._pending.push(()=>this.delete(e,t))}format(e,t,r){if(t===0)return;const i=this.doc;i!==null?Be(i,s=>{const o=ua(s,this,e,!1);o.right!==null&&ab(s,this,o,t,r)}):this._pending.push(()=>this.format(e,t,r))}removeAttribute(e){this.doc!==null?Be(this.doc,t=>{aa(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?Be(this.doc,r=>{Jd(r,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return Gd(this,e)}getAttributes(){return nb(this)}_write(e){e.writeTypeRef(yO)}}const QM=n=>new wi;class Xd{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===It||t.constructor===xi)&&t._start!==null)e=t._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,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new xi}clone(){const e=new xi;return e.insert(0,this.toArray().map(t=>t instanceof Et?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new Xd(this,e)}querySelector(e){e=e.toUpperCase();const r=new Xd(this,i=>i.nodeName&&i.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),lr(new Xd(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){oa(this,e,new nO(this,t,e))}toString(){return Zy(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},r){const i=e.createDocumentFragment();return r!==void 0&&r._createAssociation(i,this),Lo(this,s=>{i.insertBefore(s.toDOM(e,t,r),null)}),i}insert(e,t){this.doc!==null?Be(this.doc,r=>{eb(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)Be(this.doc,r=>{const i=e&&e instanceof Et?e._item:e;la(r,this,i,t)});else{const r=this._prelimContent,i=e===null?0:r.findIndex(s=>s===e)+1;if(i===0&&e!==null)throw $n("Reference item not found");r.splice(i,0,...t)}}delete(e,t=1){this.doc!==null?Be(this.doc,r=>{tb(r,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return Gy(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Xy(this,e)}slice(e=0,t=this.length){return Jy(this,e,t)}forEach(e){Lo(this,e)}_write(e){e.writeTypeRef(vO)}}const eO=n=>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,t){super._integrate(e,t),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),t=this.getAttributes();return AA(t,(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(),t=[],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];t.push(a+'="'+e[a]+'"')}const s=this.nodeName.toLocaleLowerCase(),o=t.length>0?" "+t.join(" "):"";return`<${s}${o}>${super.toString()}</${s}>`}removeAttribute(e){this.doc!==null?Be(this.doc,t=>{aa(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?Be(this.doc,r=>{Jd(r,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return Gd(this,e)}hasAttribute(e){return rb(this,e)}getAttributes(e){return e?UM(this,e):nb(this)}toDOM(e=document,t={},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 Lo(this,o=>{i.appendChild(o.toDOM(e,t,r))}),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(bO),e.writeKey(this.nodeName)}}const tO=n=>new It(n.readKey());class nO extends ia{constructor(e,t,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(i=>{i===null?this.childListChanged=!0:this.attributesChanged.add(i)})}}class da extends ps{constructor(e){super(),this.hookName=e}_copy(){return new da(this.hookName)}clone(){const e=new da(this.hookName);return this.forEach((t,r)=>{e.set(r,t)}),e}toDOM(e=document,t={},r){const i=t[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(wO),e.writeKey(this.hookName)}}const rO=n=>new da(n.readKey());class Zt 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 Zt}clone(){const e=new Zt;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,r){const i=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(i,this),i}toString(){return this.toDelta().map(e=>{const t=[];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),t.push({nodeName:i,attrs:s})}t.sort((i,s)=>i.nodeName<s.nodeName?-1:1);let r="";for(let i=0;i<t.length;i++){const s=t[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=t.length-1;i>=0;i--)r+=`</${t[i].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(xO)}}const iO=n=>new Zt;class Qd{constructor(e,t){this.id=e,this.length=t}get deleted(){throw xn()}mergeWith(e){return!1}write(e,t,r){throw xn()}integrate(e,t){throw xn()}}const sO=0;class dn extends Qd{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),Iy(e.doc.store,this)}write(e,t){e.writeInfo(sO),e.writeLen(this.length-t)}getMissing(e,t){return null}}class Io{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Io(this.content)}splice(e){throw xn()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}const oO=n=>new Io(n.readBuf());class Po{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Po(this.len)}splice(e){const t=new Po(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){To(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}}const lO=n=>new Po(n.readLen()),db=(n,e)=>new as({guid:n,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Fo{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 t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Fo(db(this.doc.guid,this.opts))}splice(e){throw xn()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,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,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const aO=n=>new Fo(db(n.readString(),n.readAny()));class Ci{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new Ci(this.embed)}splice(e){throw xn()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}const cO=n=>new Ci(n.readJSON());class lt{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new lt(this.key,this.value)}splice(e){throw xn()}mergeWith(e){return!1}integrate(e,t){const r=t.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const uO=n=>new lt(n.readKey(),n.readJSON());class fa{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new fa(this.arr)}splice(e){const t=new fa(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const r=this.arr.length;e.writeLen(r-t);for(let i=t;i<r;i++){const s=this.arr[i];e.writeString(s===void 0?"undefined":JSON.stringify(s))}}getRef(){return 2}}const dO=n=>{const e=n.readLen(),t=[];for(let r=0;r<e;r++){const i=n.readString();i==="undefined"?t.push(void 0):t.push(JSON.parse(i))}return new fa(t)};class ki{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new ki(this.arr)}splice(e){const t=new ki(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const r=this.arr.length;e.writeLen(r-t);for(let i=t;i<r;i++){const s=this.arr[i];e.writeAny(s)}}getRef(){return 8}}const fO=n=>{const e=n.readLen(),t=[];for(let r=0;r<e;r++)t.push(n.readAny());return new ki(t)};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 t=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)+"�",t.str="�"+t.str.slice(1)),t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}}const hO=n=>new Cn(n.readString()),pO=[qM,JM,QM,tO,eO,rO,iO],mO=0,gO=1,yO=2,bO=3,vO=4,wO=5,xO=6;class kn{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new kn(this.type._copy())}splice(e){throw xn()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.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 t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.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,t){this.type._write(e)}getRef(){return 7}}const CO=n=>new kn(pO[n.readTypeRef()](n)),ef=(n,e)=>{let t=e,r=0,i;do r>0&&(t=pe(t.client,t.clock+r)),i=fs(n,t),r=t.clock-i.id.clock,t=i.redone;while(t!==null&&i instanceof ze);return{item:i,diff:r}},tf=(n,e)=>{for(;n!==null&&n.keep!==e;)n.keep=e,n=n.parent._item},ha=(n,e,t)=>{const{client:r,clock:i}=e.id,s=new ze(pe(r,i+t),e,pe(r,i+t-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(t));return e.deleted&&s.markDeleted(),e.keep&&(s.keep=!0),e.redone!==null&&(s.redone=pe(e.redone.client,e.redone.clock+t)),e.right=s,s.right!==null&&(s.right.left=s),n._mergeStructs.push(s),s.parentSub!==null&&s.right===null&&s.parent._map.set(s.parentSub,s),e.length=t,s},fb=(n,e)=>KT(n,t=>ss(t.deletions,e)),hb=(n,e,t,r,i,s)=>{const o=n.doc,l=o.store,a=o.clientID,c=e.redone;if(c!==null)return Ut(n,c);let u=e.parent._item,d=null,f;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!t.has(u)||hb(n,u,t,r,i,s)===null))return null;for(;u.redone!==null;)u=Ut(n,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(n,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(n,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||ss(r,d.right.id)||fb(s.undoStack,d.right.id)||fb(s.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Ut(n,d.redone);if(d&&d.right!==null)return null}else d=h._map.get(e.parentSub)||null;const p=rt(l,a),g=pe(a,p),v=new ze(g,d,d&&d.lastId,f,f&&f.id,h,e.parentSub,e.content.copy());return e.redone=g,tf(v,!0),v.integrate(n,0),v};let ze=class Sh extends Qd{constructor(e,t,r,i,s,o,l,a){super(e,a.getLength()),this.origin=r,this.left=t,this.right=i,this.rightOrigin=s,this.parent=o,this.parentSub=l,this.redone=null,this.content=a,this.info=this.content.isCountable()?I0:0}set marker(e){(this.info&pd)>0!==e&&(this.info^=pd)}get marker(){return(this.info&pd)>0}get keep(){return(this.info&L0)>0}set keep(e){this.keep!==e&&(this.info^=L0)}get countable(){return(this.info&I0)>0}get deleted(){return(this.info&hd)>0}set deleted(e){this.deleted!==e&&(this.info^=hd)}markDeleted(){this.info|=hd}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=rt(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=rt(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===us&&this.id.client!==this.parent.client&&this.parent.clock>=rt(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Py(e,t,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===Sh&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===Sh&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===us){const r=fs(t,this.parent);r.constructor===dn?this.parent=null:this.parent=r.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Py(e,e.doc.store,pe(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),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),ds(this.origin,i.origin)){if(i.id.client<this.id.client)r=i,s.clear();else if(ds(this.rightOrigin,i.rightOrigin))break}else if(i.origin!==null&&o.has(fs(e.doc.store,i.origin)))s.has(fs(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),Iy(e.doc.store,this),this.content.integrate(e,this),$y(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:pe(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&ds(e.origin,this.lastId)&&this.right===e&&ds(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 t=this.parent._searchMarker;return t&&t.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 t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),To(e.deleteSet,this.id.client,this.id.clock,this.length),$y(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw cn();this.content.gc(e),t?AM(e,this,new dn(this.id,this.length)):this.content=new Po(this.length)}write(e,t){const r=t>0?pe(this.id.client,this.id.clock+t-1):this.origin,i=this.rightOrigin,s=this.parentSub,o=this.content.getRef()&Kl|(r===null?0:Yt)|(i===null?0:cr)|(s===null?0:wo);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=Mo(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===us?(e.writeParentInfo(!1),e.writeLeftID(l)):cn();s!==null&&e.writeString(s)}this.content.write(e,t)}};const pb=(n,e)=>kO[e&Kl](n),kO=[()=>{cn()},lO,dO,oO,hO,cO,uO,CO,fO,aO,()=>{cn()}],SO=10;class fn extends Qd{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){cn()}write(e,t){e.writeInfo(SO),ae(e.restEncoder,this.length-t)}getMissing(e,t){return null}}const mb=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},gb="__ $YJS$ __";mb[gb]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),mb[gb]=!0;function pa(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var yb={exports:{}};(function(n,e){(function(t){n.exports=t()})(function(){var t=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 pa=="function"&&pa;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 pa=="function"&&pa,d=0;d<a.length;d++)c(a[d]);return c}return s}()({1:[function(s,o,l){function a(y){var k=y.length;if(0<k%4)throw new Error("Invalid string. Length must be a multiple of 4");var E=y.indexOf("=");E===-1&&(E=k);var T=E===k?0:4-E%4;return[E,T]}function c(y,k,E){return 3*(k+E)/4-E}function u(y){var k,E,T=a(y),N=T[0],_=T[1],A=new v(c(y,N,_)),R=0,P=0<_?N-4:N;for(E=0;E<P;E+=4)k=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&k>>16,A[R++]=255&k>>8,A[R++]=255&k;return _===2&&(k=g[y.charCodeAt(E)]<<2|g[y.charCodeAt(E+1)]>>4,A[R++]=255&k),_===1&&(k=g[y.charCodeAt(E)]<<10|g[y.charCodeAt(E+1)]<<4|g[y.charCodeAt(E+2)]>>2,A[R++]=255&k>>8,A[R++]=255&k),A}function d(y){return p[63&y>>18]+p[63&y>>12]+p[63&y>>6]+p[63&y]}function f(y,k,E){for(var T,N=[],_=k;_<E;_+=3)T=(16711680&y[_]<<16)+(65280&y[_+1]<<8)+(255&y[_+2]),N.push(d(T));return N.join("")}function h(y){for(var k,E=y.length,T=E%3,N=[],_=16383,A=0,R=E-T;A<R;A+=_)N.push(f(y,A,A+_>R?R:A+_));return T===1?(k=y[E-1],N.push(p[k>>2]+p[63&k<<4]+"==")):T===2&&(k=(y[E-2]<<8)+y[E-1],N.push(p[k>>10]+p[63&k>>4]+p[63&k<<2]+"=")),N.join("")}l.byteLength=function(y){var k=a(y),E=k[0],T=k[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,C){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,C)}function f(m,b,C){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(B(m,ArrayBuffer)||m&&B(m.buffer,ArrayBuffer))return S(m,b,C);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,C);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,C);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,C){return h(m),0>=m||b===void 0?u(m):typeof C=="string"?u(m).fill(b,C):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 C=0|k(m,b),I=u(C),F=I.write(m,b);return F!==C&&(I=I.slice(0,F)),I}function w(m){for(var b=0>m.length?0:0|y(m.length),C=u(b),I=0;I<b;I+=1)C[I]=255&m[I];return C}function S(m,b,C){if(0>b||m.byteLength<b)throw new RangeError('"offset" is outside of buffer bounds');if(m.byteLength<b+(C||0))throw new RangeError('"length" is outside of buffer bounds');var I;return I=b===void 0&&C===void 0?new Uint8Array(m):C===void 0?new Uint8Array(m,b):new Uint8Array(m,b,C),I.__proto__=d.prototype,I}function x(m){if(d.isBuffer(m)){var b=0|y(m.length),C=u(b);return C.length===0||m.copy(C,0,0,b),C}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 k(m,b){if(d.isBuffer(m))return m.length;if(ArrayBuffer.isView(m)||B(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 C=m.length,I=2<arguments.length&&arguments[2]===!0;if(!I&&C===0)return 0;for(var F=!1;;)switch(b){case"ascii":case"latin1":case"binary":return C;case"utf8":case"utf-8":return Ye(m).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*C;case"hex":return C>>>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,C){var I=!1;if((b===void 0||0>b)&&(b=0),b>this.length||((C===void 0||C>this.length)&&(C=this.length),0>=C)||(C>>>=0,b>>>=0,C<=b))return"";for(m||(m="utf8");;)switch(m){case"hex":return Re(this,b,C);case"utf8":case"utf-8":return G(this,b,C);case"ascii":return X(this,b,C);case"latin1":case"binary":return we(this,b,C);case"base64":return J(this,b,C);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Pe(this,b,C);default:if(I)throw new TypeError("Unknown encoding: "+m);m=(m+"").toLowerCase(),I=!0}}function T(m,b,C){var I=m[b];m[b]=m[C],m[C]=I}function N(m,b,C,I,F){if(m.length===0)return-1;if(typeof C=="string"?(I=C,C=0):2147483647<C?C=2147483647:-2147483648>C&&(C=-2147483648),C=+C,j(C)&&(C=F?0:m.length-1),0>C&&(C=m.length+C),C>=m.length){if(F)return-1;C=m.length-1}else if(0>C)if(F)C=0;else return-1;if(typeof b=="string"&&(b=d.from(b,I)),d.isBuffer(b))return b.length===0?-1:_(m,b,C,I,F);if(typeof b=="number")return b&=255,typeof Uint8Array.prototype.indexOf=="function"?F?Uint8Array.prototype.indexOf.call(m,b,C):Uint8Array.prototype.lastIndexOf.call(m,b,C):_(m,[b],C,I,F);throw new TypeError("val must be string, number or Buffer")}function _(m,b,C,I,F){function H(Qn,z){return ne===1?Qn[z]:Qn.readUInt16BE(z*ne)}var ne=1,de=m.length,Oe=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,Oe/=2,C/=2}var be;if(F){var me=-1;for(be=C;be<de;be++)if(H(m,be)!==H(b,me===-1?0:be-me))me!==-1&&(be-=be-me),me=-1;else if(me===-1&&(me=be),be-me+1===Oe)return me*ne}else for(C+Oe>de&&(C=de-Oe),be=C;0<=be;be--){for(var Ze=!0,An=0;An<Oe;An++)if(H(m,be+An)!==H(b,An)){Ze=!1;break}if(Ze)return be}return-1}function A(m,b,C,I){C=+C||0;var F=m.length-C;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[C+de]=ne}return de}function R(m,b,C,I){return at(Ye(b,m.length-C),m,C,I)}function P(m,b,C,I){return at(Ot(b),m,C,I)}function $(m,b,C,I){return P(m,b,C,I)}function V(m,b,C,I){return at(it(b),m,C,I)}function U(m,b,C,I){return at(xt(b,m.length-C),m,C,I)}function J(m,b,C){return b===0&&C===m.length?q.fromByteArray(m):q.fromByteArray(m.slice(b,C))}function G(m,b,C){C=c(m.length,C);for(var I=[],F=b;F<C;){var H=m[F],ne=null,de=239<H?4:223<H?3:191<H?2:1;if(F+de<=C){var Oe,be,me,Ze;de===1?128>H&&(ne=H):de===2?(Oe=m[F+1],(192&Oe)==128&&(Ze=(31&H)<<6|63&Oe,127<Ze&&(ne=Ze))):de===3?(Oe=m[F+1],be=m[F+2],(192&Oe)==128&&(192&be)==128&&(Ze=(15&H)<<12|(63&Oe)<<6|63&be,2047<Ze&&(55296>Ze||57343<Ze)&&(ne=Ze))):de===4&&(Oe=m[F+1],be=m[F+2],me=m[F+3],(192&Oe)==128&&(192&be)==128&&(192&me)==128&&(Ze=(15&H)<<18|(63&Oe)<<12|(63&be)<<6|63&me,65535<Ze&&1114112>Ze&&(ne=Ze)))}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 C="",I=0;I<b;)C+=a.apply(String,m.slice(I,I+=4096));return C}function X(m,b,C){var I="";C=c(m.length,C);for(var F=b;F<C;++F)I+=a(127&m[F]);return I}function we(m,b,C){var I="";C=c(m.length,C);for(var F=b;F<C;++F)I+=a(m[F]);return I}function Re(m,b,C){var I=m.length;(!b||0>b)&&(b=0),(!C||0>C||C>I)&&(C=I);for(var F="",H=b;H<C;++H)F+=Ge(m[H]);return F}function Pe(m,b,C){for(var I=m.slice(b,C),F="",H=0;H<I.length;H+=2)F+=a(I[H]+256*I[H+1]);return F}function Ce(m,b,C){if(m%1!=0||0>m)throw new RangeError("offset is not uint");if(m+b>C)throw new RangeError("Trying to access beyond buffer length")}function ye(m,b,C,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(C+I>m.length)throw new RangeError("Index out of range")}function Ne(m,b,C,I){if(C+I>m.length)throw new RangeError("Index out of range");if(0>C)throw new RangeError("Index out of range")}function Le(m,b,C,I,F){return b=+b,C>>>=0,F||Ne(m,b,C,4),te.write(m,b,C,I,23,4),C+4}function tt(m,b,C,I,F){return b=+b,C>>>=0,F||Ne(m,b,C,8),te.write(m,b,C,I,52,8),C+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 C,I=m.length,F=null,H=[],ne=0;ne<I;++ne){if(C=m.charCodeAt(ne),55295<C&&57344>C){if(!F){if(56319<C){-1<(b-=3)&&H.push(239,191,189);continue}else if(ne+1===I){-1<(b-=3)&&H.push(239,191,189);continue}F=C;continue}if(56320>C){-1<(b-=3)&&H.push(239,191,189),F=C;continue}C=(F-55296<<10|C-56320)+65536}else F&&-1<(b-=3)&&H.push(239,191,189);if(F=null,128>C){if(0>(b-=1))break;H.push(C)}else if(2048>C){if(0>(b-=2))break;H.push(192|C>>6,128|63&C)}else if(65536>C){if(0>(b-=3))break;H.push(224|C>>12,128|63&C>>6,128|63&C)}else if(1114112>C){if(0>(b-=4))break;H.push(240|C>>18,128|63&C>>12,128|63&C>>6,128|63&C)}else throw new Error("Invalid code point")}return H}function Ot(m){for(var b=[],C=0;C<m.length;++C)b.push(255&m.charCodeAt(C));return b}function xt(m,b){for(var C,I,F,H=[],ne=0;ne<m.length&&!(0>(b-=2));++ne)C=m.charCodeAt(ne),I=C>>8,F=C%256,H.push(F),H.push(I);return H}function it(m){return q.toByteArray(nt(m))}function at(m,b,C,I){for(var F=0;F<I&&!(F+C>=b.length||F>=m.length);++F)b[F+C]=m[F];return F}function B(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,C){return f(m,b,C)},d.prototype.__proto__=Uint8Array.prototype,d.__proto__=Uint8Array,d.alloc=function(m,b,C){return p(m,b,C)},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(B(m,Uint8Array)&&(m=d.from(m,m.offset,m.byteLength)),B(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 C=m.length,I=b.length,F=0,H=c(C,I);F<H;++F)if(m[F]!==b[F]){C=m[F],I=b[F];break}return C<I?-1:I<C?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 C;if(b===void 0)for(b=0,C=0;C<m.length;++C)b+=m[C].length;var I=d.allocUnsafe(b),F=0;for(C=0;C<m.length;++C){var H=m[C];if(B(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=k,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,C,I,F){if(B(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),C===void 0&&(C=m?m.length:0),I===void 0&&(I=0),F===void 0&&(F=this.length),0>b||C>m.length||0>I||F>this.length)throw new RangeError("out of range index");if(I>=F&&b>=C)return 0;if(I>=F)return-1;if(b>=C)return 1;if(b>>>=0,C>>>=0,I>>>=0,F>>>=0,this===m)return 0;for(var H=F-I,ne=C-b,de=c(H,ne),Oe=this.slice(I,F),be=m.slice(b,C),me=0;me<de;++me)if(Oe[me]!==be[me]){H=Oe[me],ne=be[me];break}return H<ne?-1:ne<H?1:0},d.prototype.includes=function(m,b,C){return this.indexOf(m,b,C)!==-1},d.prototype.indexOf=function(m,b,C){return N(this,m,b,C,!0)},d.prototype.lastIndexOf=function(m,b,C){return N(this,m,b,C,!1)},d.prototype.write=function(m,b,C,I){if(b===void 0)I="utf8",C=this.length,b=0;else if(C===void 0&&typeof b=="string")I=b,C=this.length,b=0;else if(isFinite(b))b>>>=0,isFinite(C)?(C>>>=0,I===void 0&&(I="utf8")):(I=C,C=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var F=this.length-b;if((C===void 0||C>F)&&(C=F),0<m.length&&(0>C||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,C);case"utf8":case"utf-8":return R(this,m,b,C);case"ascii":return P(this,m,b,C);case"latin1":case"binary":return $(this,m,b,C);case"base64":return V(this,m,b,C);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,m,b,C);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 C=this.length;m=~~m,b=b===void 0?C:~~b,0>m?(m+=C,0>m&&(m=0)):m>C&&(m=C),0>b?(b+=C,0>b&&(b=0)):b>C&&(b=C),b<m&&(b=m);var I=this.subarray(m,b);return I.__proto__=d.prototype,I},d.prototype.readUIntLE=function(m,b,C){m>>>=0,b>>>=0,C||Ce(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,C){m>>>=0,b>>>=0,C||Ce(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||Ce(m,1,this.length),this[m]},d.prototype.readUInt16LE=function(m,b){return m>>>=0,b||Ce(m,2,this.length),this[m]|this[m+1]<<8},d.prototype.readUInt16BE=function(m,b){return m>>>=0,b||Ce(m,2,this.length),this[m]<<8|this[m+1]},d.prototype.readUInt32LE=function(m,b){return m>>>=0,b||Ce(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||Ce(m,4,this.length),16777216*this[m]+(this[m+1]<<16|this[m+2]<<8|this[m+3])},d.prototype.readIntLE=function(m,b,C){m>>>=0,b>>>=0,C||Ce(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,C){m>>>=0,b>>>=0,C||Ce(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||Ce(m,1,this.length),128&this[m]?-1*(255-this[m]+1):this[m]},d.prototype.readInt16LE=function(m,b){m>>>=0,b||Ce(m,2,this.length);var C=this[m]|this[m+1]<<8;return 32768&C?4294901760|C:C},d.prototype.readInt16BE=function(m,b){m>>>=0,b||Ce(m,2,this.length);var C=this[m+1]|this[m]<<8;return 32768&C?4294901760|C:C},d.prototype.readInt32LE=function(m,b){return m>>>=0,b||Ce(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||Ce(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||Ce(m,4,this.length),te.read(this,m,!0,23,4)},d.prototype.readFloatBE=function(m,b){return m>>>=0,b||Ce(m,4,this.length),te.read(this,m,!1,23,4)},d.prototype.readDoubleLE=function(m,b){return m>>>=0,b||Ce(m,8,this.length),te.read(this,m,!0,52,8)},d.prototype.readDoubleBE=function(m,b){return m>>>=0,b||Ce(m,8,this.length),te.read(this,m,!1,52,8)},d.prototype.writeUIntLE=function(m,b,C,I){if(m=+m,b>>>=0,C>>>=0,!I){var F=i(2,8*C)-1;ye(this,m,b,C,F,0)}var H=1,ne=0;for(this[b]=255&m;++ne<C&&(H*=256);)this[b+ne]=255&m/H;return b+C},d.prototype.writeUIntBE=function(m,b,C,I){if(m=+m,b>>>=0,C>>>=0,!I){var F=i(2,8*C)-1;ye(this,m,b,C,F,0)}var H=C-1,ne=1;for(this[b+H]=255&m;0<=--H&&(ne*=256);)this[b+H]=255&m/ne;return b+C},d.prototype.writeUInt8=function(m,b,C){return m=+m,b>>>=0,C||ye(this,m,b,1,255,0),this[b]=255&m,b+1},d.prototype.writeUInt16LE=function(m,b,C){return m=+m,b>>>=0,C||ye(this,m,b,2,65535,0),this[b]=255&m,this[b+1]=m>>>8,b+2},d.prototype.writeUInt16BE=function(m,b,C){return m=+m,b>>>=0,C||ye(this,m,b,2,65535,0),this[b]=m>>>8,this[b+1]=255&m,b+2},d.prototype.writeUInt32LE=function(m,b,C){return m=+m,b>>>=0,C||ye(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,C){return m=+m,b>>>=0,C||ye(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,C,I){if(m=+m,b>>>=0,!I){var F=i(2,8*C-1);ye(this,m,b,C,F-1,-F)}var H=0,ne=1,de=0;for(this[b]=255&m;++H<C&&(ne*=256);)0>m&&de===0&&this[b+H-1]!==0&&(de=1),this[b+H]=255&(m/ne>>0)-de;return b+C},d.prototype.writeIntBE=function(m,b,C,I){if(m=+m,b>>>=0,!I){var F=i(2,8*C-1);ye(this,m,b,C,F-1,-F)}var H=C-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+C},d.prototype.writeInt8=function(m,b,C){return m=+m,b>>>=0,C||ye(this,m,b,1,127,-128),0>m&&(m=255+m+1),this[b]=255&m,b+1},d.prototype.writeInt16LE=function(m,b,C){return m=+m,b>>>=0,C||ye(this,m,b,2,32767,-32768),this[b]=255&m,this[b+1]=m>>>8,b+2},d.prototype.writeInt16BE=function(m,b,C){return m=+m,b>>>=0,C||ye(this,m,b,2,32767,-32768),this[b]=m>>>8,this[b+1]=255&m,b+2},d.prototype.writeInt32LE=function(m,b,C){return m=+m,b>>>=0,C||ye(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,C){return m=+m,b>>>=0,C||ye(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,C){return Le(this,m,b,!0,C)},d.prototype.writeFloatBE=function(m,b,C){return Le(this,m,b,!1,C)},d.prototype.writeDoubleLE=function(m,b,C){return tt(this,m,b,!0,C)},d.prototype.writeDoubleBE=function(m,b,C){return tt(this,m,b,!1,C)},d.prototype.copy=function(m,b,C,I){if(!d.isBuffer(m))throw new TypeError("argument should be a Buffer");if(C||(C=0),I||I===0||(I=this.length),b>=m.length&&(b=m.length),b||(b=0),0<I&&I<C&&(I=C),I===C||m.length===0||this.length===0)return 0;if(0>b)throw new RangeError("targetStart out of bounds");if(0>C||C>=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-C&&(I=m.length-b+C);var F=I-C;if(this===m&&typeof Uint8Array.prototype.copyWithin=="function")this.copyWithin(b,C,I);else if(this===m&&C<b&&b<I)for(var H=F-1;0<=H;--H)m[H+b]=this[H+C];else Uint8Array.prototype.set.call(m,this.subarray(C,I),b);return F},d.prototype.fill=function(m,b,C,I){if(typeof m=="string"){if(typeof b=="string"?(I=b,b=0,C=this.length):typeof C=="string"&&(I=C,C=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<C)throw new RangeError("Out of range index");if(C<=b)return this;b>>>=0,C=C===void 0?this.length:C>>>0,m||(m=0);var H;if(typeof m=="number")for(H=b;H<C;++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<C-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,(k,E)=>{if(k==="%%")return"%";x++;const T=a.formatters[E];if(typeof T=="function"){const N=g[x];k=T.call(v,N),g.splice(x,1),x--}return k}),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,$){var V,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]=$?[P,J]:[J,P]:$?J.unshift(P):J.push(P),V=u(A),0<V&&J.length>V&&!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 $={fired:!1,wrapFn:void 0,target:A,type:R,listener:P},V=f.bind($);return V.listener=P,$.wrapFn=V,V}function p(A,R,P){var $=A._events;if($===void 0)return[];var V=$[R];return V===void 0?[]:typeof V=="function"?P?[V.listener||V]:[V]:P?S(V):v(V,V.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),$=0;$<R;++$)P[$]=A[$];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,$){if(typeof A.on=="function")$.once?A.once(R,P):A.on(R,P);else if(typeof A.addEventListener=="function")A.addEventListener(R,function V(U){$.once&&A.removeEventListener(R,V),P(U)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof A)}var k,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)};k=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 N=Number.isNaN||function(A){return A!==A};o.exports=a,o.exports.once=function(A,R){return new Promise(function(P,$){function V(J){A.removeListener(R,U),$(J)}function U(){typeof A.removeListener=="function"&&A.removeListener("error",V),P([].slice.call(arguments))}y(A,R,U,{once:!0}),R!=="error"&&x(A,V,{once:!0})})},a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var _=10;Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return _},set:function(A){if(typeof A!="number"||0>A||N(A))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+A+".");_=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||N(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 $=A==="error",V=this._events;if(V!==void 0)$=$&&V.error===void 0;else if(!$)return!1;if($){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=V[A];if(G===void 0)return!1;if(typeof G=="function")T(G,this,R);else for(var ie=G.length,X=v(G,ie),P=0;P<ie;++P)T(X[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,$,V,U,J;if(c(R),$=this._events,$===void 0)return this;if(P=$[A],P===void 0)return this;if(P===R||P.listener===R)--this._eventsCount==0?this._events=Object.create(null):(delete $[A],$.removeListener&&this.emit("removeListener",A,P.listener||R));else if(typeof P!="function"){for(V=-1,U=P.length-1;0<=U;U--)if(P[U]===R||P[U].listener===R){J=P[U].listener,V=U;break}if(0>V)return this;V===0?P.shift():w(P,V),P.length===1&&($[A]=P[0]),$.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,$;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 V,U=Object.keys(P);for($=0;$<U.length;++$)V=U[$],V!=="removeListener"&&this.removeAllListeners(V);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($=R.length-1;0<=$;$--)this.removeListener(A,R[$]);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?k(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,k=a[c+x];for(x+=y,h=k&(1<<-S)-1,k>>=-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:(k?-1:1)*(1/0);p+=i(2,d),h-=w}return(k?-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,k=y>>1,E=f===23?i(2,-24)-i(2,-77):0,T=d?0:h-1,N=d?1:-1,_=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=t(S(c)/w),1>c*(v=i(2,-p))&&(p--,v*=2),c+=1<=p+k?E/v:E*i(2,1-k),2<=c*v&&(p++,v/=2),p+k>=y?(g=0,p=y):1<=p+k?(g=(c*v-1)*i(2,f),p+=k):(g=c*i(2,k-1)*i(2,f),p=0));8<=f;a[u+T]=255&g,T+=N,g/=256,f-=8);for(p=p<<f|g,x+=f;0<x;a[u+T]=255&p,T+=N,p/=256,x-=8);a[u+T-N]|=128*_}},{}],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):k=-1,x.length&&f())}function f(){if(!y){var E=c(d);y=!0;for(var T=x.length;T;){for(S=x,x=[];++k<T;)S&&S[k].run();k=-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,k=-1;w.nextTick=function(E){var T=Array(arguments.length-1);if(1<arguments.length)for(var N=1;N<arguments.length;N++)T[N-1]=arguments[N];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 On>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:On)},{}],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.
325
+ Use Chrome, Firefox or Internet Explorer 11`)}}).call(this)}).call(this,s("_process"),typeof On>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:On)},{_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,k){return typeof g=="string"?g:g(x,y,k)}v||(v=Error);var S=function(x){function y(k,E,T){return x.call(this,w(k,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 Pe.from(M)}function u(M){return Pe.isBuffer(M)||M instanceof Ce}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&&(!Ne&&(Ne=s("string_decoder/").StringDecoder),this.decoder=new Ne(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)),Re.call(this)}function p(M,m,b,C,I){X("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))C||(F.reading=!1,E(M,F));else if(typeof m=="string"||F.objectMode||Object.getPrototypeOf(m)===Pe.prototype||(m=c(m)),C)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,C){m.flowing&&m.length===0&&!m.sync?(m.awaitDrain=0,M.emit("data",b)):(m.length+=m.objectMode?1:b.length,C?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(X("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,k(M)))}}function y(M){var m=M._readableState;X("emitReadable",m.needReadable,m.emittedReadable),m.needReadable=!1,m.emittedReadable||(X("emitReadable",m.flowing),m.emittedReadable=!0,l.nextTick(k,M))}function k(M){var m=M._readableState;X("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,$(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(X("maybeReadMore read 0"),M.read(0),b===m.length)break}m.readingMore=!1}function N(M){return function(){var m=M._readableState;X("pipeOnDrain",m.awaitDrain),m.awaitDrain&&m.awaitDrain--,m.awaitDrain===0&&we(M,"data")&&(m.flowing=!0,$(M))}}function _(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){X("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){X("resume",m.reading),m.reading||M.read(0),m.resumeScheduled=!1,M.emit("resume"),$(M),m.flowing&&!m.reading&&M.read(0)}function $(M){var m=M._readableState;for(X("flow",m.flowing);m.flowing&&M.read()!==null;);}function V(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;X("endReadable",m.endEmitted),m.endEmitted||(m.ended=!0,l.nextTick(J,m,M))}function J(M,m){if(X("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,C=M.length;b<C;b++)if(M[b]===m)return b;return-1}o.exports=h;var ie;h.ReadableState=f;var X;s("events").EventEmitter;var we=function(M,m){return M.listeners(m).length},Re=s("./internal/streams/stream"),Pe=s("buffer").Buffer,Ce=a.Uint8Array||function(){},ye=s("util");X=ye&&ye.debuglog?ye.debuglog("stream"):function(){};var Ne,Le,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,B=xt.ERR_METHOD_NOT_IMPLEMENTED,j=xt.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;s("inherits")(h,Re);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,C=this._readableState;return C.objectMode?b=!0:typeof M=="string"&&(m=m||C.defaultEncoding,m!==C.encoding&&(M=Pe.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){Ne||(Ne=s("string_decoder/").StringDecoder);var m=new Ne(M);this._readableState.decoder=m,this._readableState.encoding=this._readableState.decoder.encoding;for(var b=this._readableState.buffer.head,C="";b!==null;)C+=m.write(b.data),b=b.next;return this._readableState.buffer.clear(),C!==""&&this._readableState.buffer.push(C),this._readableState.length=C.length,this},h.prototype.read=function(M){X("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 X("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 C=m.needReadable;X("need readable",C),(m.length===0||m.length-M<m.highWaterMark)&&(C=!0,X("length less than watermark",C)),m.ended||m.reading?(C=!1,X("reading or ended",C)):C&&(X("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?V(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 B("_read()"))},h.prototype.pipe=function(M,m){function b(ee,oe){X("onunpipe"),ee===be&&oe&&oe.hasUnpiped===!1&&(oe.hasUnpiped=!0,I())}function C(){X("onend"),M.end()}function I(){X("cleanup"),M.removeListener("close",ne),M.removeListener("finish",de),M.removeListener("drain",Qn),M.removeListener("error",H),M.removeListener("unpipe",b),be.removeListener("end",C),be.removeListener("end",Oe),be.removeListener("data",F),z=!0,me.awaitDrain&&(!M._writableState||M._writableState.needDrain)&&Qn()}function F(ee){X("ondata");var oe=M.write(ee);X("dest.write",oe),oe===!1&&((me.pipesCount===1&&me.pipes===M||1<me.pipesCount&&G(me.pipes,M)!==-1)&&!z&&(X("false write response, pause",me.awaitDrain),me.awaitDrain++),be.pause())}function H(ee){X("onerror",ee),Oe(),M.removeListener("error",H),we(M,"error")===0&&q(M,ee)}function ne(){M.removeListener("finish",de),Oe()}function de(){X("onfinish"),M.removeListener("close",ne),Oe()}function Oe(){X("unpipe"),be.unpipe(M)}var be=this,me=this._readableState;switch(me.pipesCount){case 0:me.pipes=M;break;case 1:me.pipes=[me.pipes,M];break;default:me.pipes.push(M)}me.pipesCount+=1,X("pipe count=%d opts=%j",me.pipesCount,m);var Ze=(!m||m.end!==!1)&&M!==l.stdout&&M!==l.stderr,An=Ze?C:Oe;me.endEmitted?l.nextTick(An):be.once("end",An),M.on("unpipe",b);var Qn=N(be);M.on("drain",Qn);var z=!1;return be.on("data",F),d(M,"error",H),M.once("close",ne),M.once("finish",de),M.emit("pipe",be),me.flowing||(X("pipe resume"),be.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 C=m.pipes,I=m.pipesCount;m.pipes=null,m.pipesCount=0,m.flowing=!1;for(var F=0;F<I;F++)C[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=Re.prototype.on.call(this,M,m),C=this._readableState;return M==="data"?(C.readableListening=0<this.listenerCount("readable"),C.flowing!==!1&&this.resume()):M=="readable"&&!C.endEmitted&&!C.readableListening&&(C.readableListening=C.needReadable=!0,C.flowing=!1,C.emittedReadable=!1,X("on readable",C.length,C.reading),C.length?y(this):!C.reading&&l.nextTick(A,this)),b},h.prototype.addListener=h.prototype.on,h.prototype.removeListener=function(M,m){var b=Re.prototype.removeListener.call(this,M,m);return M==="readable"&&l.nextTick(_,this),b},h.prototype.removeAllListeners=function(M){var m=Re.prototype.removeAllListeners.apply(this,arguments);return(M==="readable"||M===void 0)&&l.nextTick(_,this),m},h.prototype.resume=function(){var M=this._readableState;return M.flowing||(X("resume"),M.flowing=!M.readableListening,R(this,M)),M.paused=!1,this},h.prototype.pause=function(){return X("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(X("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},h.prototype.wrap=function(M){var m=this,b=this._readableState,C=!1;for(var I in M.on("end",function(){if(X("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(X("wrapped data"),b.decoder&&(H=b.decoder.write(H)),!(b.objectMode&&H==null)&&(b.objectMode||H&&H.length)){var ne=m.push(H);ne||(C=!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){X("wrapped _read",H),C&&(C=!1,M.resume())},this},typeof Symbol=="function"&&(h.prototype[Symbol.asyncIterator]=function(){return Le===void 0&&(Le=s("./internal/streams/async_iterator")),Le(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=V,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 On>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:On)},{"../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 k=this._readableState;k.reading=!1,(k.needReadable||k.length<k.highWaterMark)&&this._read(k.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 k=this._readableState;(y.needTransform||k.needReadable||k.length<k.highWaterMark)&&this._read(k.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(B){var j=this;this.next=null,this.entry=null,this.finish=function(){U(j,B)}}function u(B){return X.from(B)}function d(B){return X.isBuffer(B)||B instanceof we}function f(){}function h(B,j,q){J=J||s("./_stream_duplex"),B=B||{},typeof q!="boolean"&&(q=j instanceof J),this.objectMode=!!B.objectMode,q&&(this.objectMode=this.objectMode||!!B.writableObjectMode),this.highWaterMark=Ce(this,B,"writableHighWaterMark",q),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var te=B.decodeStrings===!1;this.decodeStrings=!te,this.defaultEncoding=B.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=B.emitClose!==!1,this.autoDestroy=!!B.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new c(this)}function p(B){J=J||s("./_stream_duplex");var j=this instanceof J;return j||at.call(p,this)?(this._writableState=new h(B,this,j),this.writable=!0,B&&(typeof B.write=="function"&&(this._write=B.write),typeof B.writev=="function"&&(this._writev=B.writev),typeof B.destroy=="function"&&(this._destroy=B.destroy),typeof B.final=="function"&&(this._final=B.final)),void ie.call(this)):new p(B)}function g(B,j){var q=new Ot;it(B,q),l.nextTick(j,q)}function v(B,j,q,te){var M;return q===null?M=new Ye:typeof q!="string"&&!j.objectMode&&(M=new Ne("chunk",["string","Buffer"],q)),!M||(it(B,M),l.nextTick(te,M),!1)}function w(B,j,q){return B.objectMode||B.decodeStrings===!1||typeof j!="string"||(j=X.from(j,q)),j}function S(B,j,q,te,M,m){if(!q){var b=w(j,te,M);te!==b&&(q=!0,M="buffer",te=b)}var C=j.objectMode?1:te.length;j.length+=C;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(B,j,!1,C,te,M,m);return I}function x(B,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?B._writev(M,j.onwrite):B._write(M,m,j.onwrite),j.sync=!1}function y(B,j,q,te,M){--j.pendingcb,q?(l.nextTick(M,te),l.nextTick($,B,j),B._writableState.errorEmitted=!0,it(B,te)):(M(te),B._writableState.errorEmitted=!0,it(B,te),$(B,j))}function k(B){B.writing=!1,B.writecb=null,B.length-=B.writelen,B.writelen=0}function E(B,j){var q=B._writableState,te=q.sync,M=q.writecb;if(typeof M!="function")throw new tt;if(k(q),j)y(B,q,te,j,M);else{var m=A(q)||B.destroyed;m||q.corked||q.bufferProcessing||!q.bufferedRequest||_(B,q),te?l.nextTick(T,B,q,m,M):T(B,q,m,M)}}function T(B,j,q,te){q||N(B,j),j.pendingcb--,te(),$(B,j)}function N(B,j){j.length===0&&j.needDrain&&(j.needDrain=!1,B.emit("drain"))}function _(B,j){j.bufferProcessing=!0;var q=j.bufferedRequest;if(B._writev&&q&&q.next){var te=j.bufferedRequestCount,M=Array(te),m=j.corkedRequestsFree;m.entry=q;for(var b=0,C=!0;q;)M[b]=q,q.isBuf||(C=!1),q=q.next,b+=1;M.allBuffers=C,x(B,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(B,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(B){return B.ending&&B.length===0&&B.bufferedRequest===null&&!B.finished&&!B.writing}function R(B,j){B._final(function(q){j.pendingcb--,q&&it(B,q),j.prefinished=!0,B.emit("prefinish"),$(B,j)})}function P(B,j){j.prefinished||j.finalCalled||(typeof B._final!="function"||j.destroyed?(j.prefinished=!0,B.emit("prefinish")):(j.pendingcb++,j.finalCalled=!0,l.nextTick(R,B,j)))}function $(B,j){var q=A(j);if(q&&(P(B,j),j.pendingcb===0&&(j.finished=!0,B.emit("finish"),j.autoDestroy))){var te=B._readableState;(!te||te.autoDestroy&&te.endEmitted)&&B.destroy()}return q}function V(B,j,q){j.ending=!0,$(B,j),q&&(j.finished?l.nextTick(q):B.once("finish",q)),j.ended=!0,B.writable=!1}function U(B,j,q){var te=B.entry;for(B.entry=null;te;){var M=te.callback;j.pendingcb--,M(q),te=te.next}j.corkedRequestsFree.next=B}o.exports=p;var J;p.WritableState=h;var G={deprecate:s("util-deprecate")},ie=s("./internal/streams/stream"),X=s("buffer").Buffer,we=a.Uint8Array||function(){},Re=s("./internal/streams/destroy"),Pe=s("./internal/streams/state"),Ce=Pe.getHighWaterMark,ye=s("../errors").codes,Ne=ye.ERR_INVALID_ARG_TYPE,Le=ye.ERR_METHOD_NOT_IMPLEMENTED,tt=ye.ERR_MULTIPLE_CALLBACK,nt=ye.ERR_STREAM_CANNOT_PIPE,Ge=ye.ERR_STREAM_DESTROYED,Ye=ye.ERR_STREAM_NULL_VALUES,Ot=ye.ERR_STREAM_WRITE_AFTER_END,xt=ye.ERR_UNKNOWN_ENCODING,it=Re.errorOrDestroy;s("inherits")(p,ie),h.prototype.getBuffer=function(){for(var B=this.bufferedRequest,j=[];B;)j.push(B),B=B.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(B){return!!at.call(this,B)||this===p&&B&&B._writableState instanceof h}})):at=function(B){return B instanceof this},p.prototype.pipe=function(){it(this,new nt)},p.prototype.write=function(B,j,q){var te=this._writableState,M=!1,m=!te.objectMode&&d(B);return m&&!X.isBuffer(B)&&(B=u(B)),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,B,q))&&(te.pendingcb++,M=S(this,te,m,B,j,q)),M},p.prototype.cork=function(){this._writableState.corked++},p.prototype.uncork=function(){var B=this._writableState;B.corked&&(B.corked--,!B.writing&&!B.corked&&!B.bufferProcessing&&B.bufferedRequest&&_(this,B))},p.prototype.setDefaultEncoding=function(B){if(typeof B=="string"&&(B=B.toLowerCase()),!(-1<["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((B+"").toLowerCase())))throw new xt(B);return this._writableState.defaultEncoding=B,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(B,j,q){q(new Le("_write()"))},p.prototype._writev=null,p.prototype.end=function(B,j,q){var te=this._writableState;return typeof B=="function"?(q=B,B=null,j=null):typeof j=="function"&&(q=j,j=null),B!=null&&this.write(B,j),te.corked&&(te.corked=1,this.uncork()),te.ending||V(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(B){this._writableState&&(this._writableState.destroyed=B)}}),p.prototype.destroy=Re.destroy,p.prototype._undestroy=Re.undestroy,p.prototype._destroy=function(B,j){j(B)}}).call(this)}).call(this,s("_process"),typeof On>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:On)},{"../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(N,_,A){return _ in N?Object.defineProperty(N,_,{value:A,enumerable:!0,configurable:!0,writable:!0}):N[_]=A,N}function c(N,_){return{value:N,done:_}}function u(N){var _=N[g];if(_!==null){var A=N[k].read();A!==null&&(N[x]=null,N[g]=null,N[v]=null,_(c(A,!1)))}}function d(N){l.nextTick(u,N)}function f(N,_){return function(A,R){N.then(function(){return _[S]?void A(c(void 0,!0)):void _[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"),k=Symbol("stream"),E=Object.getPrototypeOf(function(){}),T=Object.setPrototypeOf((h={get stream(){return this[k]},next:function(){var N=this,_=this[w];if(_!==null)return Promise.reject(_);if(this[S])return Promise.resolve(c(void 0,!0));if(this[k].destroyed)return new Promise(function($,V){l.nextTick(function(){N[w]?V(N[w]):$(c(void 0,!0))})});var A,R=this[x];if(R)A=new Promise(f(R,this));else{var P=this[k].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 N=this;return new Promise(function(_,A){N[k].destroy(null,function(R){return R?void A(R):void _(c(void 0,!0))})})}),h),E);o.exports=function(N){var _,A=Object.create(T,(_={},a(_,k,{value:N,writable:!0}),a(_,g,{value:null,writable:!0}),a(_,v,{value:null,writable:!0}),a(_,w,{value:null,writable:!0}),a(_,S,{value:N._readableState.endEmitted,writable:!0}),a(_,y,{value:function(R,P){var $=A[k].read();$?(A[x]=null,A[g]=null,A[v]=null,R(c($,!1))):(A[g]=R,A[v]=P)},writable:!0}),_));return A[x]=null,p(N,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 $=A[g];$!==null&&(A[x]=null,A[g]=null,A[v]=null,$(c(void 0,!0))),A[S]=!0}),N.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 k=Object.keys(x);if(Object.getOwnPropertySymbols){var E=Object.getOwnPropertySymbols(x);y&&(E=E.filter(function(T){return Object.getOwnPropertyDescriptor(x,T).enumerable})),k.push.apply(k,E)}return k}function a(x){for(var y,k=1;k<arguments.length;k++)y=arguments[k]==null?{}:arguments[k],k%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,k){return y in x?Object.defineProperty(x,y,{value:k,enumerable:!0,configurable:!0,writable:!0}):x[y]=k,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 k,E=0;E<y.length;E++)k=y[E],k.enumerable=k.enumerable||!1,k.configurable=!0,"value"in k&&(k.writable=!0),Object.defineProperty(x,k.key,k)}function f(x,y,k){return y&&d(x.prototype,y),x}function h(x,y,k){g.prototype.copy.call(x,y,k)}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 k={data:y,next:null};0<this.length?this.tail.next=k:this.head=k,this.tail=k,++this.length}},{key:"unshift",value:function(y){var k={data:y,next:this.head};this.length===0&&(this.tail=k),this.head=k,++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 k=this.head,E=""+k.data;k=k.next;)E+=y+k.data;return E}},{key:"concat",value:function(y){if(this.length===0)return g.alloc(0);for(var k=g.allocUnsafe(y>>>0),E=this.head,T=0;E;)h(E.data,k,T),T+=E.data.length,E=E.next;return k}},{key:"consume",value:function(y,k){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=k?this._getString(y):this._getBuffer(y),E}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(y){var k=this.head,E=1,T=k.data;for(y-=T.length;k=k.next;){var N=k.data,_=y>N.length?N.length:y;if(T+=_===N.length?N:N.slice(0,y),y-=_,y===0){_===N.length?(++E,this.head=k.next?k.next:this.tail=null):(this.head=k,k.data=N.slice(_));break}++E}return this.length-=E,T}},{key:"_getBuffer",value:function(y){var k=g.allocUnsafe(y),E=this.head,T=1;for(E.data.copy(k),y-=E.data.length;E=E.next;){var N=E.data,_=y>N.length?N.length:y;if(N.copy(k,k.length-y,0,_),y-=_,y===0){_===N.length?(++T,this.head=E.next?E.next:this.tail=null):(this.head=E,E.data=N.slice(_));break}++T}return this.length-=T,k}},{key:S,value:function(y,k){return w(this,a({},k,{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,k=function(){g=!1,y=!0,v||p.call(f)},E=function(_){p.call(f,_)},T=function(){var _;return g&&!y?(f._readableState&&f._readableState.ended||(_=new d),p.call(f,_)):v&&!S?(f._writableState&&f._writableState.ended||(_=new d),p.call(f,_)):void 0},N=function(){f.req.on("finish",x)};return c(f)?(f.on("complete",x),f.on("abort",T),f.req?N():f.on("request",N)):v&&!f._writableState&&(f.on("end",w),f.on("close",w)),f.on("end",k),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",N),f.req&&f.req.removeListener("finish",x),f.removeListener("end",w),f.removeListener("close",w),f.removeListener("finish",x),f.removeListener("end",k),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,k){k=l(k);var E=!1;S.on("close",function(){E=!0}),p===void 0&&(p=s("./end-of-stream")),p(S,{readable:x,writable:y},function(N){return N?k(N):(E=!0,void k())});var T=!1;return function(N){if(!E)return T?void 0:(T=!0,c(S)?S.abort():typeof S.destroy=="function"?S.destroy():void k(N||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 k=h(x);if(Array.isArray(x[0])&&(x=x[0]),2>x.length)throw new v("streams");var E,T=x.map(function(N,_){var A=_<x.length-1;return u(N,A,0<_,function(R){E||(E=R),R&&T.forEach(d),A||(T.forEach(d),k(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)&&t(h)===h)||0>h){var p=f?d:"highWaterMark";throw new a(p,h)}return t(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 N;;)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(N)return;T=(""+T).toLowerCase(),N=!0}}function c(T){var N=a(T);if(typeof N!="string"&&(k.isEncoding===E||!E(T)))throw new Error("Unknown encoding: "+T);return N||T}function u(T){this.encoding=c(T);var N;switch(this.encoding){case"utf16le":this.text=g,this.end=v,N=4;break;case"utf8":this.fillLast=p,N=4;break;case"base64":this.text=w,this.end=S,N=3;break;default:return this.write=x,void(this.end=y)}this.lastNeed=0,this.lastTotal=0,this.lastChar=k.allocUnsafe(N)}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,N,_){var A=N.length-1;if(A<_)return 0;var R=d(N[A]);return 0<=R?(0<R&&(T.lastNeed=R-1),R):--A<_||R===-2?0:(R=d(N[A]),0<=R?(0<R&&(T.lastNeed=R-2),R):--A<_||R===-2?0:(R=d(N[A]),0<=R?(0<R&&(R===2?R=0:T.lastNeed=R-3),R):0))}function h(T,N){if((192&N[0])!=128)return T.lastNeed=0,"�";if(1<T.lastNeed&&1<N.length){if((192&N[1])!=128)return T.lastNeed=1,"�";if(2<T.lastNeed&&2<N.length&&(192&N[2])!=128)return T.lastNeed=2,"�"}}function p(T){var N=this.lastTotal-this.lastNeed,_=h(this,T);return _===void 0?this.lastNeed<=T.length?(T.copy(this.lastChar,N,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(T.copy(this.lastChar,N,0,T.length),void(this.lastNeed-=T.length)):_}function g(T,N){if((T.length-N)%2==0){var _=T.toString("utf16le",N);if(_){var A=_.charCodeAt(_.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],_.slice(0,-1)}return _}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=T[T.length-1],T.toString("utf16le",N,T.length-1)}function v(T){var N=T&&T.length?this.write(T):"";if(this.lastNeed){var _=this.lastTotal-this.lastNeed;return N+this.lastChar.toString("utf16le",0,_)}return N}function w(T,N){var _=(T.length-N)%3;return _==0?T.toString("base64",N):(this.lastNeed=3-_,this.lastTotal=3,_==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",N,T.length-_))}function S(T){var N=T&&T.length?this.write(T):"";return this.lastNeed?N+this.lastChar.toString("base64",0,3-this.lastNeed):N}function x(T){return T.toString(this.encoding)}function y(T){return T&&T.length?this.write(T):""}var k=s("safe-buffer").Buffer,E=k.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 N,_;if(this.lastNeed){if(N=this.fillLast(T),N===void 0)return"";_=this.lastNeed,this.lastNeed=0}else _=0;return _<T.length?N?N+this.text(T,_):this.text(T,_):N||""},u.prototype.end=function(T){var N=T&&T.length?this.write(T):"";return this.lastNeed?N+"�":N},u.prototype.text=function(T,N){var _=f(this,T,N);if(!this.lastNeed)return T.toString("utf8",N);this.lastTotal=_;var A=T.length-(_-this.lastNeed);return T.copy(this.lastChar,0,A),T.toString("utf8",N,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 On>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:On)},{}],"/":[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(k=>{!y.address||y.address.endsWith(".local")?a("Ignoring unsupported ICE candidate."):this.destroy(p(k,"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(k){this.destroy(p(k,"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 k=this._senderMap.get(x)||new Map;let E=k.get(y);if(!E)E=this._pc.addTrack(x,y),k.set(y,E),this._senderMap.set(x,k),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,k){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(k):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 k=this._senderMap.get(x),E=k?k.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=k=>{this._onChannelMessage(k)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=k=>{const E=k.error instanceof Error?k.error:new Error(`Datachannel error: ${k.message} ${k.filename}:${k.lineno}:${k.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,k){if(this.destroyed)return k(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=k):k(null)}else this._debug("write before connect"),this._chunk=x,this._cb=k}_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 k=this._pc.localDescription||x;this._debug("signal"),this.emit("signal",{type:k.type,sdp:k.sdp})}};this._pc.setLocalDescription(x).then(()=>{this._debug("createOffer success"),this.destroyed||(this.trickle||this._iceComplete?y():this.once("_iceComplete",y))}).catch(k=>{this.destroy(p(k,"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 k=this._pc.localDescription||x;this._debug("signal"),this.emit("signal",{type:k.type,sdp:k.sdp}),this.initiator||this._requestMissingTransceivers()}};this._pc.setLocalDescription(x).then(()=>{this.destroyed||(this.trickle||this._iceComplete?y():this.once("_iceComplete",y))}).catch(k=>{this.destroy(p(k,"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=k=>(Object.prototype.toString.call(k.values)==="[object Array]"&&k.values.forEach(E=>{Object.assign(k,E)}),k);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(k=>{const E=[];k.forEach(T=>{E.push(y(T))}),x(null,E)},k=>x(k)):0<this._pc.getStats.length?this._pc.getStats(k=>{if(this.destroyed)return;const E=[];k.result().forEach(T=>{const N={};T.names().forEach(_=>{N[_]=T.stat(_)}),N.id=T.id,N.type=T.type,N.timestamp=T.timestamp,E.push(y(N))}),x(null,E)},k=>x(k)):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,k)=>{if(this.destroyed)return;y&&(k=[]);const E={},T={},N={};let _=!1;k.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")&&(N[R.id]=R)});const A=R=>{_=!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 $=E[R.remoteCandidateId];$&&($.ip||$.address)?(this.remoteAddress=$.ip||$.address,this.remotePort=+$.port):$&&$.ipAddress?(this.remoteAddress=$.ipAddress,this.remotePort=+$.portNumber):typeof R.googRemoteAddress=="string"&&($=R.googRemoteAddress.split(":"),this.remoteAddress=$[0],this.remotePort=+$[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(k.forEach(R=>{R.type==="transport"&&R.selectedCandidatePairId&&A(N[R.selectedCandidatePairId]),(R.type==="googCandidatePair"&&R.googActiveConnection==="true"||(R.type==="candidatepair"||R.type==="candidate-pair")&&R.selected)&&A(R)}),!_&&(!Object.keys(N).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(k=>k.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}]},{},[])("/")})})(yb);var EO=yb.exports;const TO=Nc(EO),nf=0,rf=1,bb=2,vb=(n,e)=>{ae(n,nf);const t=xM(e);Xe(n,t)},wb=(n,e,t)=>{ae(n,rf),Xe(n,yM(e,t))},AO=(n,e,t)=>wb(e,t,bt(n)),xb=(n,e,t)=>{try{pM(e,bt(n),t)}catch(r){console.error("Caught error while handling a Yjs update",r)}},MO=(n,e)=>{ae(n,bb),Xe(n,e)},OO=xb,_O=(n,e,t,r)=>{const i=he(n);switch(i){case nf:AO(n,e,t);break;case rf:xb(n,t,r);break;case bb:OO(n,t,r);break;default:throw new Error("Unknown message type")}return i},sf=3e4;class NO extends D0{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=Bn();this.getLocalState()!==null&&sf/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const r=[];this.meta.forEach((i,s)=>{s!==this.clientID&&sf<=t-i.lastUpdated&&this.states.has(s)&&r.push(s)}),r.length>0&&of(this,r,"timeout")},wn(sf/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 t=this.clientID,r=this.meta.get(t),i=r===void 0?0:r.clock+1,s=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:i,lastUpdated:Bn()});const o=[],l=[],a=[],c=[];e===null?c.push(t):s==null?e!=null&&o.push(t):(l.push(t),Eo(s,e)||a.push(t)),(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,t){const r=this.getLocalState();r!==null&&this.setLocalState({...r,[e]:t})}getStates(){return this.states}}const of=(n,e,t)=>{const r=[];for(let i=0;i<e.length;i++){const s=e[i];if(n.states.has(s)){if(n.states.delete(s),s===n.clientID){const o=n.meta.get(s);n.meta.set(s,{clock:o.clock+1,lastUpdated:Bn()})}r.push(s)}}r.length>0&&(n.emit("change",[{added:[],updated:[],removed:r},t]),n.emit("update",[{added:[],updated:[],removed:r},t]))},ma=(n,e,t=n.states)=>{const r=e.length,i=gt();ae(i,r);for(let s=0;s<r;s++){const o=e[s],l=t.get(o)||null,a=n.meta.get(o).clock;ae(i,o),ae(i,a),jn(i,JSON.stringify(l))}return qe(i)},DO=(n,e,t)=>{const r=Hn(e),i=Bn(),s=[],o=[],l=[],a=[],c=he(r);for(let u=0;u<c;u++){const d=he(r);let f=he(r);const h=JSON.parse(ur(r)),p=n.meta.get(d),g=n.states.get(d),v=p===void 0?0:p.clock;(v<f||v===f&&h===null&&n.states.has(d))&&(h===null?d===n.clientID&&n.getLocalState()!=null?f++:n.states.delete(d):n.states.set(d,h),n.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&&(Eo(h,g)||l.push(d),o.push(d)))}(s.length>0||l.length>0||a.length>0)&&n.emit("change",[{added:s,updated:l,removed:a},t]),(s.length>0||o.length>0||a.length>0)&&n.emit("update",[{added:s,updated:o,removed:a},t])},RO=(n,e)=>{const t=gd(n).buffer,r=gd(e).buffer;return crypto.subtle.importKey("raw",t,"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"]))},Cb=(n,e)=>{if(!e)return Dd(n);const t=crypto.getRandomValues(new Uint8Array(12));return crypto.subtle.encrypt({name:"AES-GCM",iv:t},e,n).then(r=>{const i=gt();return jn(i,"AES-GCM"),Xe(i,t),Xe(i,new Uint8Array(r)),qe(i)})},LO=(n,e)=>{const t=gt();return ts(t,n),Cb(qe(t),e)},kb=(n,e)=>{if(!e)return Dd(n);const t=Hn(n);ur(t)!=="AES-GCM"&&KA($n("Unknown encryption algorithm"));const i=bt(t),s=bt(t);return crypto.subtle.decrypt({name:"AES-GCM",iv:i},e,s).then(o=>new Uint8Array(o))},IO=(n,e)=>kb(n,e).then(t=>ns(Hn(new Uint8Array(t)))),Xt=qA("y-webrtc"),gs=0,Sb=3,Bo=1,lf=4,ga=new Map,Si=new Map,Eb=n=>{let e=!0;n.webrtcConns.forEach(t=>{t.synced||(e=!1)}),(!e&&n.synced||e&&!n.synced)&&(n.synced=e,n.provider.emit("synced",[{synced:e}]),Xt("synced ",un,n.name,yi," with all peers"))},Tb=(n,e,t)=>{const r=Hn(e),i=gt(),s=he(r);if(n===void 0)return null;const o=n.awareness,l=n.doc;let a=!1;switch(s){case gs:{ae(i,gs);const c=_O(r,i,l,n);c===rf&&!n.synced&&t(),c===nf&&(a=!0);break}case Sb:ae(i,Bo),Xe(i,ma(o,Array.from(o.getStates().keys()))),a=!0;break;case Bo:DO(o,bt(r),n);break;case lf:{const c=gi(r)===1,u=ur(r);if(u!==n.peerId&&(n.bcConns.has(u)&&!c||!n.bcConns.has(u)&&c)){const d=[],f=[];c?(n.bcConns.add(u),f.push(u)):(n.bcConns.delete(u),d.push(u)),n.provider.emit("peers",[{added:f,removed:d,webrtcPeers:Array.from(n.webrtcConns.keys()),bcPeers:Array.from(n.bcConns)}]),Ob(n)}break}default:return console.error("Unable to compute message"),i}return a?i:null},PO=(n,e)=>{const t=n.room;return Xt("received message from ",un,n.remotePeerId,_d," (",t.name,")",yi,ea),Tb(t,e,()=>{n.synced=!0,Xt("synced ",un,t.name,yi," with ",un,n.remotePeerId),Eb(t)})},af=(n,e)=>{Xt("send message to ",un,n.remotePeerId,yi,_d," (",n.room.name,")",ea);try{n.peer.send(qe(e))}catch{}},FO=(n,e)=>{Xt("broadcast message in ",un,n.name,yi),n.webrtcConns.forEach(t=>{try{t.peer.send(e)}catch{}})};class Ab{constructor(e,t,r,i){Xt("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 TO({initiator:t,...i.provider.peerOpts}),this.peer.on("signal",s=>{this.glareToken===void 0&&(this.glareToken=Date.now()+Math.random()),uf(e,i,{to:r,from:i.peerId,type:"signal",token:this.glareToken,signal:s})}),this.peer.on("connect",()=>{Xt("connected to ",un,r),this.connected=!0;const o=i.provider.doc,l=i.awareness,a=gt();ae(a,gs),vb(a,o),af(this,a);const c=l.getStates();if(c.size>0){const u=gt();ae(u,Bo),Xe(u,ma(l,Array.from(c.keys()))),af(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)}])),Eb(i),this.peer.destroy(),Xt("closed connection to ",un,r),cf(i)}),this.peer.on("error",s=>{Xt("Error in connection to ",un,r,": ",s),cf(i)}),this.peer.on("data",s=>{const o=PO(this,s);o!==null&&af(this,o)})}destroy(){this.peer.destroy()}}const $r=(n,e)=>Cb(e,n.key).then(t=>n.mux(()=>sM(n.name,t))),Mb=(n,e)=>{n.bcconnected&&$r(n,e),FO(n,e)},cf=n=>{ga.forEach(e=>{e.connected&&(e.send({type:"subscribe",topics:[n.name]}),n.webrtcConns.size<n.provider.maxConns&&uf(e,n,{type:"announce",from:n.peerId}))})},Ob=n=>{if(n.provider.filterBcConns){const e=gt();ae(e,lf),So(e,1),jn(e,n.peerId),$r(n,qe(e))}};class BO{constructor(e,t,r,i){this.peerId=B0(),this.doc=e,this.awareness=t.awareness,this.provider=t,this.synced=!1,this.name=r,this.key=i,this.webrtcConns=new Map,this.bcConns=new Set,this.mux=my(),this.bcconnected=!1,this._bcSubscriber=s=>kb(new Uint8Array(s),i).then(o=>this.mux(()=>{const l=Tb(this,o,()=>{});l&&$r(this,qe(l))})),this._docUpdateHandler=(s,o)=>{const l=gt();ae(l,gs),MO(l,s),Mb(this,qe(l))},this._awarenessUpdateHandler=({added:s,updated:o,removed:l},a)=>{const c=s.concat(o).concat(l),u=gt();ae(u,Bo),Xe(u,ma(this.awareness,c)),Mb(this,qe(u))},this._beforeUnloadHandler=()=>{of(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),cf(this);const e=this.name;rM(e,this._bcSubscriber),this.bcconnected=!0,Ob(this);const t=gt();ae(t,gs),vb(t,this.doc),$r(this,qe(t));const r=gt();ae(r,gs),wb(r,this.doc),$r(this,qe(r));const i=gt();ae(i,Sb),$r(this,qe(i));const s=gt();ae(s,Bo),Xe(s,ma(this.awareness,[this.doc.clientID])),$r(this,qe(s))}disconnect(){ga.forEach(t=>{t.connected&&t.send({type:"unsubscribe",topics:[this.name]})}),of(this.awareness,[this.doc.clientID],"disconnect");const e=gt();ae(e,lf),So(e,0),jn(e,this.peerId),$r(this,qe(e)),iM(this.name,this._bcSubscriber),this.bcconnected=!1,this.doc.off("update",this._docUpdateHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.webrtcConns.forEach(t=>t.destroy())}destroy(){this.disconnect(),typeof window<"u"?window.removeEventListener("beforeunload",this._beforeUnloadHandler):typeof process<"u"&&process.off("exit",this._beforeUnloadHandler)}}const $O=(n,e,t,r)=>{if(Si.has(t))throw $n(`A Yjs Doc connected to room "${t}" already exists!`);const i=new BO(n,e,t,r);return Si.set(t,i),i},uf=(n,e,t)=>{e.key?LO(t,e.key).then(r=>{n.send({type:"publish",topic:e.name,data:fy(r)})}):n.send({type:"publish",topic:e.name,data:t})};class jO extends ZT{constructor(e){super(e),this.providers=new Set,this.on("connect",()=>{Xt(`connected (${e})`);const t=Array.from(Si.keys());this.send({type:"subscribe",topics:t}),Si.forEach(r=>uf(this,r,{type:"announce",from:r.peerId}))}),this.on("message",t=>{switch(t.type){case"publish":{const r=t.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&&(zt(l,o.from,()=>new Ab(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){Xt("offer rejected: ",o.from);return}u.glareToken=void 0}}if(o.signal.type==="answer"){Xt("offer answered by: ",o.from);const u=l.get(o.from);u.glareToken=void 0}o.to===a&&(zt(l,o.from,()=>new Ab(this,!1,o.from,i)).peer.signal(o.signal),c());break}};i.key?typeof t.data=="string"&&IO(hy(t.data),i.key).then(s):s(t.data)}}}),this.on("disconnect",()=>Xt(`disconnect (${e})`))}}const df=n=>{n.emit("status",[{connected:n.connected}])};class HO extends dd{constructor(e,t,{signaling:r=["wss://y-webrtc-eu.fly.dev"],password:i=null,awareness:s=new NO(t),maxConns:o=20+wn(P0()*15),filterBcConns:l=!0,peerOpts:a={}}={}){super(),this.roomName=e,this.doc=t,this.filterBcConns=l,this.awareness=s,this.shouldConnect=!1,this.signalingUrls=r,this.signalingConns=[],this.maxConns=o,this.peerOpts=a,this.key=i?RO(i,e):Dd(null),this.room=null,this.key.then(c=>{this.room=$O(t,this,e,c),this.shouldConnect?this.room.connect():this.room.disconnect(),df(this)}),this.connect(),this.destroy=this.destroy.bind(this),t.on("destroy",this.destroy)}get connected(){return this.room!==null&&this.shouldConnect}connect(){this.shouldConnect=!0,this.signalingUrls.forEach(e=>{const t=zt(ga,e,()=>new jO(e));this.signalingConns.push(t),t.providers.add(this)}),this.room&&(this.room.connect(),df(this))}disconnect(){this.shouldConnect=!1,this.signalingConns.forEach(e=>{e.providers.delete(this),e.providers.size===0&&(e.destroy(),ga.delete(e.url))}),this.room&&(this.room.disconnect(),df(this))}destroy(){this.doc.off("destroy",this.destroy),this.key.then(()=>{this.room.destroy(),Si.delete(this.roomName)}),super.destroy()}}const VO={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:(n,e)=>{if(["ArrowUp","ArrowDown","Enter"].includes(e.key)&&document.querySelector("#slash-command"))return!0}}},zO=/[\uD800-\uDBFF]/,UO=/[\uDC00-\uDFFF]/,WO=(n,e)=>{let t=0,r=0;for(;t<n.length&&t<e.length&&n[t]===e[t];)t++;for(t>0&&zO.test(n[t-1])&&t--;r+t<n.length&&r+t<e.length&&n[n.length-r-1]===e[e.length-r-1];)r++;return r>0&&UO.test(n[n.length-r])&&r--,{index:t,remove:n.length-t-r,insert:e.slice(t,e.length-r)}},Ke=new We("y-sync"),hr=new We("y-undo"),ya=new We("yjs-cursor"),ba=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&e.sv.get(n.id.client)>n.id.clock&&!ss(e.ds,n.id),qO=[{light:"#ecd44433",dark:"#ecd444"}],KO=(n,e,t)=>{if(!n.has(t)){if(n.size<e.length){const r=or();n.forEach(i=>r.add(i)),e=e.filter(i=>!r.has(i))}n.set(t,eA(e))}return n.get(t)},JO=(n,{colors:e=qO,colorMapping:t=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:n,doc:n.doc,binding:null,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:t,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)&&Od(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 YO(n,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},GO=(n,e,t)=>{if(e!==null&&e.anchor!==null&&e.head!==null){const r=Ho(t.doc,t.type,e.anchor,t.mapping),i=Ho(t.doc,t.type,e.head,t.mapping);r!==null&&i!==null&&(n=n.setSelection(ce.create(n.doc,r,i)))}},ff=(n,e)=>({anchor:Ca(e.selection.anchor,n.type,n.mapping),head:Ca(e.selection.head,n.type,n.mapping)});class YO{constructor(e,t){this.type=e,this.prosemirrorView=t,this.mux=my(),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=ff(this,t.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()?(Ad&&this._domSelectionInView===null&&(Od(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection(),t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);const i=t.getBoundingClientRect(),s=BA.documentElement;return i.bottom>=0&&i.right>=0&&i.left<=(window.innerWidth||s.clientWidth||0)&&i.top<=(window.innerHeight||s.clientHeight||0)}renderSnapshot(e,t){t||(t=Ry(yy(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Ke,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping=new Map,this.mux(()=>{const e=this.type.toArray().map(r=>va(r,this.prosemirrorView.state.schema,this.mapping)).filter(r=>r!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Y(W.from(e),0,0));t.setMeta(Ke,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping=new Map,this.mux(()=>{const e=this.type.toArray().map(r=>va(r,this.prosemirrorView.state.schema,this.mapping)).filter(r=>r!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new Y(W.from(e),0,0));this.prosemirrorView.dispatch(t.setMeta(Ke,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,r){e||(e=TM(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:KO(r.colorMapping,r.colors,d)}},l=Yy(this.type,new Hd(t.ds,e.sv)).map(c=>!c._item.deleted||ba(c._item,e)||ba(c._item,t)?va(c,this.prosemirrorView.state.schema,new Map,e,t,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,t){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(t,t.deleteSet,l=>{if(l.constructor===ze){const a=l.content.type;a&&this.mapping.delete(a)}}),t.changed.forEach(i),t.changedParentTypes.forEach(i);const s=this.type.toArray().map(l=>_b(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));GO(o,this.beforeTransactionSelection,this),o=o.setMeta(Ke,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof zy}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(e){this.doc.transact(()=>{mf(this.doc,this.type,e,this.mapping),this.beforeTransactionSelection=ff(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 _b=(n,e,t,r,i,s)=>{const o=t.get(n);if(o===void 0){if(n instanceof It)return va(n,e,t,r,i,s);throw xn()}return o},va=(n,e,t,r,i,s)=>{const o=[],l=a=>{if(a.constructor===It){const c=_b(a,e,t,r,i,s);c!==null&&o.push(c)}else{const c=ZO(a,e,t,r,i,s);c!==null&&c.forEach(u=>{u!==null&&o.push(u)})}};r===void 0||i===void 0?n.toArray().forEach(l):Yy(n,new Hd(i.ds,r.sv)).forEach(l);try{const a=n.getAttributes(r);r!==void 0&&(ba(n._item,r)?ba(n._item,i)||(a.ychange=s?s("added",n._item.id):{type:"added"}):a.ychange=s?s("removed",n._item.id):{type:"removed"});const c=e.node(n.nodeName,a,o);return t.set(n,c),c}catch{return n.doc.transact(c=>{n._item.delete(c)},Ke),t.delete(n),null}},ZO=(n,e,t,r,i,s)=>{const o=[],l=n.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 n.doc.transact(c=>{n._item.delete(c)},Ke),null}return o},XO=(n,e)=>{const t=new Zt,r=n.map(i=>({insert:i.text,attributes:Lb(i.marks)}));return t.applyDelta(r),e.set(t,n),t},QO=(n,e)=>{const t=new It(n.type.name);for(const r in n.attrs){const i=n.attrs[r];i!==null&&r!=="ychange"&&t.setAttribute(r,i)}return t.insert(0,wa(n).map(r=>hf(r,e))),e.set(t,n),t},hf=(n,e)=>n instanceof Array?XO(n,e):QO(n,e),Nb=n=>typeof n=="object"&&n!==null,pf=(n,e)=>{const t=Object.keys(n).filter(i=>n[i]!==null);let r=t.length===Object.keys(e).filter(i=>e[i]!==null).length;for(let i=0;i<t.length&&r;i++){const s=t[i],o=n[s],l=e[s];r=s==="ychange"||o===l||Nb(o)&&Nb(l)&&pf(o,l)}return r},wa=n=>{const e=n.content.content,t=[];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--,t.push(s)}else t.push(i)}return t},Db=(n,e)=>{const t=n.toDelta();return t.length===e.length&&t.every((r,i)=>r.insert===e[i].text&&Ed(r.attributes||{}).length===e[i].marks.length&&e[i].marks.every(s=>pf(r.attributes[s.type.name]||{},s.attrs)))},$o=(n,e)=>{if(n instanceof It&&!(e instanceof Array)&&gf(n,e)){const t=wa(e);return n._length===t.length&&pf(n.getAttributes(),e.attrs)&&n.toArray().every((r,i)=>$o(r,t[i]))}return n instanceof Zt&&e instanceof Array&&Db(n,e)},xa=(n,e)=>n===e||n instanceof Array&&e instanceof Array&&n.length===e.length&&n.every((t,r)=>e[r]===t),Rb=(n,e,t)=>{const r=n.toArray(),i=wa(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(xa(t.get(d),f))u=!0;else if(!$o(d,f))break}for(;a+c<l;c++){const d=r[o-c-1],f=i[s-c-1];if(xa(t.get(d),f))u=!0;else if(!$o(d,f))break}return{equalityFactor:a+c,foundMappedChild:u}},e3=n=>{let e="",t=n._start;const r={};for(;t!==null;)t.deleted||(t.countable&&t.content instanceof Cn?e+=t.content.str:t.content instanceof lt&&(r[t.content.key]=null)),t=t.right;return{str:e,nAttrs:r}},t3=(n,e,t)=>{t.set(n,e);const{nAttrs:r,str:i}=e3(n),s=e.map(c=>({insert:c.text,attributes:Object.assign({},r,Lb(c.marks))})),{insert:o,remove:l,index:a}=WO(i,s.map(c=>c.insert).join(""));n.delete(a,l),n.insert(a,o),n.applyDelta(s.map(c=>({retain:c.insert.length,attributes:c.attributes})))},Lb=n=>{const e={};return n.forEach(t=>{t.type.name!=="ychange"&&(e[t.type.name]=t.attrs)}),e},mf=(n,e,t,r)=>{if(e instanceof It&&e.nodeName!==t.type.name)throw new Error("node name mismatch!");if(r.set(e,t),e instanceof It){const d=e.getAttributes(),f=t.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=wa(t),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(!xa(r.get(d),f))if($o(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(!xa(r.get(d),f))if($o(d,f))r.set(d,f);else break}n.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 Zt&&h instanceof Array)Db(f,h)||t3(f,h,r),c+=1;else{let v=f instanceof It&&gf(f,h),w=p instanceof It&&gf(p,g);if(v&&w){const S=Rb(f,h,r),x=Rb(p,g,r);S.foundMappedChild&&!x.foundMappedChild?w=!1:!S.foundMappedChild&&x.foundMappedChild||S.equalityFactor<x.equalityFactor?v=!1:w=!1}v?(mf(n,f,h,r),c+=1):w?(mf(n,p,g,r),u+=1):(r.delete(e.get(c)),e.delete(c,1),e.insert(c,[hf(h,r)]),c+=1)}}const d=l-c-u;if(l===1&&s===0&&o[0]instanceof Zt?(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(hf(i[h],r));e.insert(c,f)}},Ke)},gf=(n,e)=>!(e instanceof Array)&&n.nodeName===e.type.name;let jo=null;const n3=()=>{const n=jo;jo=null,n.forEach((e,t)=>{const r=t.state.tr,i=Ke.getState(t.state);i&&i.binding&&!i.binding.isDestroyed&&(e.forEach((s,o)=>{r.setMeta(o,s)}),t.dispatch(r))})},r3=(n,e,t)=>{jo||(jo=new Map,Od(0,n3)),zt(jo,n,Lt).set(e,t)},Ca=(n,e,t)=>{if(n===0)return jd(e,0);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof Zt){if(r._length>=n)return jd(r,n);if(n-=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,n--;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=(t.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&n<i)r=r._first.content.type,n--;else{if(n===1&&r._length===0&&i>1)return new _o(r._item===null?null:r._item.id,r._item===null?Mo(r):null,null);if(n-=i,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(n===0)return r=r._item===null?r:r._item.parent,new _o(r._item===null?null:r._item.id,r._item===null?Mo(r):null,null);do r=r._item.parent,n--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw cn();if(n===0&&r.constructor!==Zt&&r!==e)return i3(r._item.parent,r._item)}return jd(e,e._length)},i3=(n,e)=>{let t=null,r=null;return n._item===null?r=Mo(n):t=pe(n._item.id.client,n._item.id.clock),new _o(t,r,e.id)},Ho=(n,e,t,r)=>{const i=EM(t,n);if(i===null||i.type!==e&&!Oo(e,i.type._item))return null;let s=i.type,o=0;if(s.constructor===Zt)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 Zt?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 Zt?o+=c._length:o+=r.get(c).nodeSize),a=a.right}}s=l}return o-1},s3=(n,e,t)=>n!==e,o3=n=>{const e=document.createElement("span");e.classList.add("ProseMirror-yjs-cursor"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");t.setAttribute("style",`background-color: ${n.color}`),t.insertBefore(document.createTextNode(n.name),null);const r=document.createTextNode("⁠"),i=document.createTextNode("⁠");return e.insertBefore(r,null),e.insertBefore(t,null),e.insertBefore(i,null),e},Ib=n=>({style:`background-color: ${n.color}70`,class:"ProseMirror-yjs-selection"}),l3=/^#[0-9a-fA-F]{6}$/,Pb=(n,e,t,r,i)=>{const s=Ke.getState(n),o=s.doc,l=[];return s.snapshot!=null||s.prevSnapshot!=null||s.binding===null?He.create(n.doc,[]):(e.getStates().forEach((a,c)=>{if(t(o.clientID,c,a)&&a.cursor!=null){const u=a.user||{};u.color==null?u.color="#ffa500":l3.test(u.color)||console.warn("A user uses an unsupported color format",u),u.name==null&&(u.name=`User: ${c}`);let d=Ho(o,s.type,No(a.cursor.anchor),s.binding.mapping),f=Ho(o,s.type,No(a.cursor.head),s.binding.mapping);if(d!==null&&f!==null){const h=ar(n.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(n.doc,l))},a3=(n,{awarenessStateFilter:e=s3,cursorBuilder:t=o3,selectionBuilder:r=Ib,getSelection:i=o=>o.selection}={},s="cursor")=>new je({key:ya,state:{init(o,l){return Pb(l,n,e,t,r)},apply(o,l,a,c){const u=Ke.getState(c),d=o.getMeta(ya);return u&&u.isChangeOrigin||d&&d.awarenessUpdated?Pb(c,n,e,t,r):l.map(o.mapping,o.doc)}},props:{decorations:o=>ya.getState(o)},view:o=>{const l=()=>{o.docView&&r3(o,ya,{awarenessUpdated:!0})},a=()=>{const c=Ke.getState(o.state),u=n.getLocalState()||{};if(c.binding!=null)if(o.hasFocus()){const d=i(o.state),f=Ca(d.anchor,c.type,c.binding.mapping),h=Ca(d.head,c.type,c.binding.mapping);(u.cursor==null||!Dy(No(u.cursor.anchor),f)||!Dy(No(u.cursor.head),h))&&n.setLocalStateField(s,{anchor:f,head:h})}else u.cursor!=null&&Ho(c.doc,c.type,No(u.cursor.anchor),c.binding.mapping)!==null&&n.setLocalStateField(s,null)};return n.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),n.off("change",l),n.setLocalStateField(s,null)}}}}),c3=n=>{const e=hr.getState(n).undoManager;if(e!=null)return e.undo(),!0},u3=n=>{const e=hr.getState(n).undoManager;if(e!=null)return e.redo(),!0},d3=new Set(["paragraph"]),f3=(n,e)=>!(n instanceof ze)||!(n.content instanceof kn)||!(n.content.type instanceof wi||n.content.type instanceof It&&e.has(n.content.type.nodeName))||n.content.type._length===0,h3=({protectedNodes:n=d3,trackedOrigins:e=[],undoManager:t=null}={})=>new je({key:hr,state:{init:(r,i)=>{const s=Ke.getState(i),o=t||new zy(s.type,{trackedOrigins:new Set([Ke].concat(e)),deleteFilter:l=>f3(l,n),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:ff(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()}}}}),p3=Ue.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null}},onCreate(){this.editor.extensionManager.extensions.find(n=>n.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:n,state:e,dispatch:t})=>(n.setMeta("preventDispatch",!0),hr.getState(e).undoManager.undoStack.length===0?!1:t?c3(e):!0),redo:()=>({tr:n,state:e,dispatch:t})=>(n.setMeta("preventDispatch",!0),hr.getState(e).undoManager.redoStack.length===0?!1:t?u3(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 n=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),e=h3(),t=e.spec.view;e.spec.view=l=>{const{undoManager:a}=hr.getState(l.state);a.restore&&(a.restore(),a.restore=()=>{});const c=t?t(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[JO(n,s),e]}}),Fb=n=>Array.from(n.entries()).map(([e,t])=>({clientId:e,...t.user})),Bb=()=>null,m3=Ue.create({name:"collaborationCursor",addOptions(){return{provider:null,user:{name:null,color:null},render:n=>{const e=document.createElement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");return t.classList.add("collaboration-cursor__label"),t.setAttribute("style",`background-color: ${n.color}`),t.insertBefore(document.createTextNode(n.name),null),e.insertBefore(t,null),e},selectionRender:Ib,onUpdate:Bb}},onCreate(){this.options.onUpdate!==Bb&&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:n=>()=>(this.options.user=n,this.options.provider.awareness.setLocalStateField("user",this.options.user),!0),user:n=>({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(n))}},addProseMirrorPlugins(){return[a3((this.options.provider.awareness.setLocalStateField("user",this.options.user),this.storage.users=Fb(this.options.provider.awareness.states),this.options.provider.awareness.on("update",()=>{this.storage.users=Fb(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),g3=/^\s*>\s$/,y3=Ve.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",xe(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Ji({find:g3,type:this.type})]}}),b3=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,v3=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,w3=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,x3=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,C3=jt.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",xe(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ai({find:b3,type:this.type}),ai({find:w3,type:this.type})]},addPasteRules(){return[Rr({find:v3,type:this.type}),Rr({find:x3,type:this.type})]}}),k3=Ve.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",xe(this.options.HTMLAttributes,n),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)}}}),$b=jt.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",xe(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=oo(n,this.type);return Object.entries(t).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),jb=/^\s*([-+*])\s$/,S3=Ve.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:n}){return["ul",xe(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(k3.name,this.editor.getAttributes($b.name)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Ji({find:jb,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Ji({find:jb,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes($b.name),editor:this.editor})),[n]}}),E3=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/,T3=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g,A3=jt.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",xe(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[ai({find:E3,type:this.type})]},addPasteRules(){return[Rr({find:T3,type:this.type})]}}),M3=/^```([a-z]+)?[\s\n]$/,O3=/^~~~([a-z]+)?[\s\n]$/,_3=Ve.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:n=>{var e;const{languageClassPrefix:t}=this.options,s=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",xe(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:i}=t;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
311
326
 
312
- `);return!s||!o?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:i,empty:s}=t;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:n.commands.exitCode()}}},addInputRules(){return[ju({find:E3,type:this.type,getAttributes:n=>({language:n[1]})}),ju({find:T3,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new je({key:new We("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=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(!t||!s)return!1;const{tr:o}=n.state;return n.state.selection.from===n.state.doc.nodeSize-(1+n.state.selection.$to.depth*2)?o.insert(n.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(t.replace(/\r\n?/g,`
313
- `)),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),Hb=Ve.create({name:"doc",topNode:!0,content:"block+"});function M3(n={}){return new je({view(e){return new O3(e,n)}})}class O3{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.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),t=!e.parent.inlineContent,r;if(t){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",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);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 t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!s){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=op(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 Vb=Ue.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[M3(this.options)]}});class Qe extends ue{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.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,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Qe(e.resolve(t.pos))}getBookmark(){return new yf(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!_3(e)||!N3(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,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(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let a=e.doc.resolve(i);if(Qe.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!se.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),r=!1;continue e}break}s=o,i+=t;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 yf{constructor(e){this.pos=e}map(e){return new yf(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Qe.valid(t)?new Qe(t):ue.near(t)}}function _3(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-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 N3(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;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 D3(){return new je({props:{decorations:P3,createSelectionBetween(n,e,t){return e.pos==t.pos&&Qe.valid(t)?new Qe(t):null},handleClick:L3,handleKeyDown:R3,handleDOMEvents:{beforeinput:I3}}})}const R3=ku({ArrowLeft:ka("horiz",-1),ArrowRight:ka("horiz",1),ArrowUp:ka("vert",-1),ArrowDown:ka("vert",1)});function ka(n,e){const t=n=="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(t)||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 L3(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Qe.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&se.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Qe(r))),!0)}function I3(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Qe))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=W.empty;for(let o=r.length-1;o>=0;o--)i=W.from(r[o].createAndFill(null,i));let s=n.state.tr.replace(t.pos,t.pos,new Y(i,0,0));return s.setSelection(ce.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function P3(n){if(!(n.selection instanceof Qe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",He.create(n.doc,[ut.widget(n.selection.head,e,{key:"gapcursor"})])}const zb=Ue.create({name:"gapCursor",addProseMirrorPlugins(){return[D3()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=ge(re(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),F3=Ve.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",Ce(this.options.HTMLAttributes,n)]},renderText(){return`
314
- `},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:i,storedMarks:s}=t;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()}}}),B3=Ve.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(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,Ce(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>ju({find:new RegExp(`^(#{1,${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var Sa=200,vt=function(){};vt.prototype.append=function(e){return e.length?(e=vt.from(e),!this.length&&e||e.length<Sa&&this.leafAppend(e)||this.length<Sa&&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 $3(this,e)},vt.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?vt.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},vt.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},vt.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)},vt.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,r),i},vt.from=function(e){return e instanceof vt?e:e&&e.length?new Ub(e):vt.empty};var Ub=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(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<=Sa)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Sa)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(vt);vt.empty=new Ub([]);var $3=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,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 j3=500;class Sn{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;t&&(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 Sn(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,t,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,t),h;(h=a&&a.merge(f))&&(f=h,u?s.pop():l=l.slice(0,l.length-1)),s.push(f),t&&(o++,t=void 0),i||(a=f)}let c=o-r.depth;return c>V3&&(l=H3(l,c),o-=c),new Sn(l.append(s),o)}remapping(e,t){let r=new Ri;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,t),r}addMaps(e){return this.eventCount==0?this:new Sn(this.items.append(e.map(t=>new Un(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let a=t;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=t;f<o;f++)c.push(new Un(s.maps[f]));let u=this.items.slice(0,i).append(c).append(r),d=new Sn(u,l);return d.emptyItemCount()>j3&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,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(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=o.selection&&o.selection.map(t.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 Sn(vt.from(i.reverse()),s)}}Sn.empty=new Sn(vt.empty,0);function H3(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}class Un{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Un(t.getMap().invert(),t,this.selection)}}}class jr{constructor(e,t,r,i,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const V3=20;function z3(n,e,t,r){let i=t.getMeta(Ei),s;if(i)return i.historyState;t.getMeta(q3)&&(n=new jr(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(Ei))return o.getMeta(Ei).redo?new jr(n.done.addTransform(t,void 0,r,Ea(e)),n.undone,Wb(t.mapping.maps[t.steps.length-1]),n.prevTime,n.prevComposition):new jr(n.done,n.undone.addTransform(t,void 0,r,Ea(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!U3(t,n.prevRanges)),c=o?bf(n.prevRanges,t.mapping):Wb(t.mapping.maps[t.steps.length-1]);return new jr(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Ea(e)),Sn.empty,c,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new jr(n.done.rebased(t,s),n.undone.rebased(t,s),bf(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new jr(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),bf(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function U3(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function Wb(n){let e=[];return n.forEach((t,r,i,s)=>e.push(i,s)),e}function bf(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),s=e.map(n[r+1],-1);i<=s&&t.push(i,s)}return t}function W3(n,e,t){let r=Ea(e),i=Ei.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),a=new jr(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(Ei,{redo:t,historyState:a})}let vf=!1,qb=null;function Ea(n){let e=n.plugins;if(qb!=e){vf=!1,qb=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){vf=!0;break}}return vf}const Ei=new We("history"),q3=new We("closeHistory");function K3(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new je({key:Ei,state:{init(){return new jr(Sn.empty,Sn.empty,null,0,-1)},apply(e,t,r){return z3(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?Jb:r=="historyRedo"?Gb:null;return i?(t.preventDefault(),i(e.state,e.dispatch)):!1}}}})}function Kb(n,e){return(t,r)=>{let i=Ei.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let s=W3(i,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}const Jb=Kb(!1,!0),Gb=Kb(!0,!0),J3=Ue.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Jb(n,e),redo:()=>({state:n,dispatch:e})=>Gb(n,e)}},addProseMirrorPlugins(){return[K3(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()}}}),Yb=Ve.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",Ce(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{const{$to:t}=e.selection,r=n();return t.parentOffset===0?r.insertContentAt(Math.max(t.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[$u({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),G3=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Y3=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Z3=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,X3=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Q3=jt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",Ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ai({find:G3,type:this.type}),ai({find:Z3,type:this.type})]},addPasteRules(){return[Rr({find:Y3,type:this.type}),Rr({find:X3,type:this.type})]}}),e_=Ve.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",Ce(this.options.HTMLAttributes,n),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)}}}),t_=Ve.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",Ce(this.options.HTMLAttributes,n),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)}}}),Zb=jt.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",Ce(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=oo(n,this.type);return Object.entries(t).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),Xb=/^(\d+)\.\s$/,n_=Ve.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:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",Ce(this.options.HTMLAttributes,t),0]:["ol",Ce(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(t_.name,this.editor.getAttributes(Zb.name)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Ji({find:Xb,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Ji({find:Xb,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Zb.name)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),r_=Ve.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",Ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),i_=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,s_=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,o_=jt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",Ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ai({find:i_,type:this.type})]},addPasteRules(){return[Rr({find:s_,type:this.type})]}}),l_=Ve.create({name:"text",group:"inline"}),a_=Ue.create({name:"starterKit",addExtensions(){var n,e,t,r,i,s,o,l,a,c,u,d,f,h,p,g,v,w;const S=[];return this.options.blockquote!==!1&&S.push(p3.configure((n=this.options)===null||n===void 0?void 0:n.blockquote)),this.options.bold!==!1&&S.push(v3.configure((e=this.options)===null||e===void 0?void 0:e.bold)),this.options.bulletList!==!1&&S.push(C3.configure((t=this.options)===null||t===void 0?void 0:t.bulletList)),this.options.code!==!1&&S.push(S3.configure((r=this.options)===null||r===void 0?void 0:r.code)),this.options.codeBlock!==!1&&S.push(A3.configure((i=this.options)===null||i===void 0?void 0:i.codeBlock)),this.options.document!==!1&&S.push(Hb.configure((s=this.options)===null||s===void 0?void 0:s.document)),this.options.dropcursor!==!1&&S.push(Vb.configure((o=this.options)===null||o===void 0?void 0:o.dropcursor)),this.options.gapcursor!==!1&&S.push(zb.configure((l=this.options)===null||l===void 0?void 0:l.gapcursor)),this.options.hardBreak!==!1&&S.push(F3.configure((a=this.options)===null||a===void 0?void 0:a.hardBreak)),this.options.heading!==!1&&S.push(B3.configure((c=this.options)===null||c===void 0?void 0:c.heading)),this.options.history!==!1&&S.push(J3.configure((u=this.options)===null||u===void 0?void 0:u.history)),this.options.horizontalRule!==!1&&S.push(Yb.configure((d=this.options)===null||d===void 0?void 0:d.horizontalRule)),this.options.italic!==!1&&S.push(Q3.configure((f=this.options)===null||f===void 0?void 0:f.italic)),this.options.listItem!==!1&&S.push(e_.configure((h=this.options)===null||h===void 0?void 0:h.listItem)),this.options.orderedList!==!1&&S.push(n_.configure((p=this.options)===null||p===void 0?void 0:p.orderedList)),this.options.paragraph!==!1&&S.push(r_.configure((g=this.options)===null||g===void 0?void 0:g.paragraph)),this.options.strike!==!1&&S.push(o_.configure((v=this.options)===null||v===void 0?void 0:v.strike)),this.options.text!==!1&&S.push(l_.configure((w=this.options)===null||w===void 0?void 0:w.text)),S}}),c_=jt.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",Ce(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=oo(n,this.type);return Object.entries(t).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),u_=Ue.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:n=>{var e;return(e=n.style.fontFamily)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.fontFamily?{style:`font-family: ${n.fontFamily.split(",").map(e=>CSS.escape(e.trim())).join(", ")}`}:{}}}}]},addCommands(){return{setFontFamily:n=>({chain:e})=>e().setMark("textStyle",{fontFamily:n}).run(),unsetFontFamily:()=>({chain:n})=>n().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),d_=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:n=>n.style.textAlign||this.options.defaultAlignment,renderHTML:n=>n.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${n.textAlign}`}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).every(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.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")}}}),f_="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4vianca6w0s2x0a2z0ure5ba0by2idu3namex3narepublic11d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0cast4mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dabur3d1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0ardian6cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster6d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2tura4vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9dnavy5lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0a1b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp2w2ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4finity6ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",h_="ελ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",ys=(n,e)=>{for(const t in e)n[t]=e[t];return n},wf="numeric",Cf="ascii",xf="alpha",Ta="asciinumeric",Aa="alphanumeric",kf="domain",Qb="emoji",p_="scheme",m_="slashscheme",e1="whitespace";function g_(n,e){return n in e||(e[n]=[]),e[n]}function Ti(n,e,t){e[wf]&&(e[Ta]=!0,e[Aa]=!0),e[Cf]&&(e[Ta]=!0,e[xf]=!0),e[Ta]&&(e[Aa]=!0),e[xf]&&(e[Aa]=!0),e[Aa]&&(e[kf]=!0),e[Qb]&&(e[kf]=!0);for(const r in e){const i=g_(r,t);i.indexOf(n)<0&&i.push(n)}}function y_(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Wt(n){n===void 0&&(n=null),this.j={},this.jr=[],this.jd=null,this.t=n}Wt.groups={},Wt.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],s=e.jr[r][1];if(s&&i.test(n))return s}return e.jd},has(n,e){return e===void 0&&(e=!1),e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let i=0;i<n.length;i++)this.tt(n[i],e,t,r)},tr(n,e,t,r){r=r||Wt.groups;let i;return e&&e.j?i=e:(i=new Wt(e),t&&r&&Ti(e,t,r)),this.jr.push([n,i]),i},ts(n,e,t,r){let i=this;const s=n.length;if(!s)return i;for(let o=0;o<s-1;o++)i=i.tt(n[o]);return i.tt(n[s-1],e,t,r)},tt(n,e,t,r){r=r||Wt.groups;const i=this;if(e&&e.j)return i.j[n]=e,e;const s=e;let o,l=i.go(n);if(l?(o=new Wt,ys(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=ys(y_(o.t,r),t);Ti(s,a,r)}else t&&Ti(s,t,r);o.t=s}return i.j[n]=o,o}};const ve=(n,e,t,r,i)=>n.ta(e,t,r,i),hn=(n,e,t,r,i)=>n.tr(e,t,r,i),t1=(n,e,t,r,i)=>n.ts(e,t,r,i),Z=(n,e,t,r,i)=>n.tt(e,t,r,i),pr="WORD",Sf="UWORD",Vo="LOCALHOST",Ef="TLD",Tf="UTLD",Ma="SCHEME",bs="SLASH_SCHEME",Af="NUM",n1="WS",Mf="NL",zo="OPENBRACE",Uo="CLOSEBRACE",Oa="OPENBRACKET",_a="CLOSEBRACKET",Na="OPENPAREN",Da="CLOSEPAREN",Ra="OPENANGLEBRACKET",La="CLOSEANGLEBRACKET",Ia="FULLWIDTHLEFTPAREN",Pa="FULLWIDTHRIGHTPAREN",Fa="LEFTCORNERBRACKET",Ba="RIGHTCORNERBRACKET",$a="LEFTWHITECORNERBRACKET",ja="RIGHTWHITECORNERBRACKET",Ha="FULLWIDTHLESSTHAN",Va="FULLWIDTHGREATERTHAN",za="AMPERSAND",Ua="APOSTROPHE",Wa="ASTERISK",Hr="AT",qa="BACKSLASH",Ka="BACKTICK",Ja="CARET",Vr="COLON",Of="COMMA",Ga="DOLLAR",Wn="DOT",Ya="EQUALS",_f="EXCLAMATION",qn="HYPHEN",Za="PERCENT",Xa="PIPE",Qa="PLUS",ec="POUND",tc="QUERY",Nf="QUOTE",Df="SEMI",Kn="SLASH",Wo="TILDE",nc="UNDERSCORE",r1="EMOJI",rc="SYM";var i1=Object.freeze({__proto__:null,WORD:pr,UWORD:Sf,LOCALHOST:Vo,TLD:Ef,UTLD:Tf,SCHEME:Ma,SLASH_SCHEME:bs,NUM:Af,WS:n1,NL:Mf,OPENBRACE:zo,CLOSEBRACE:Uo,OPENBRACKET:Oa,CLOSEBRACKET:_a,OPENPAREN:Na,CLOSEPAREN:Da,OPENANGLEBRACKET:Ra,CLOSEANGLEBRACKET:La,FULLWIDTHLEFTPAREN:Ia,FULLWIDTHRIGHTPAREN:Pa,LEFTCORNERBRACKET:Fa,RIGHTCORNERBRACKET:Ba,LEFTWHITECORNERBRACKET:$a,RIGHTWHITECORNERBRACKET:ja,FULLWIDTHLESSTHAN:Ha,FULLWIDTHGREATERTHAN:Va,AMPERSAND:za,APOSTROPHE:Ua,ASTERISK:Wa,AT:Hr,BACKSLASH:qa,BACKTICK:Ka,CARET:Ja,COLON:Vr,COMMA:Of,DOLLAR:Ga,DOT:Wn,EQUALS:Ya,EXCLAMATION:_f,HYPHEN:qn,PERCENT:Za,PIPE:Xa,PLUS:Qa,POUND:ec,QUERY:tc,QUOTE:Nf,SEMI:Df,SLASH:Kn,TILDE:Wo,UNDERSCORE:nc,EMOJI:r1,SYM:rc});const vs=/[a-z]/,Rf=new RegExp("\\p{L}","u"),Lf=new RegExp("\\p{Emoji}","u"),If=/\d/,s1=/\s/,o1=`
315
- `,b_="️",v_="‍";let ic=null,sc=null;function w_(n){n===void 0&&(n=[]);const e={};Wt.groups=e;const t=new Wt;ic==null&&(ic=l1(f_)),sc==null&&(sc=l1(h_)),Z(t,"'",Ua),Z(t,"{",zo),Z(t,"}",Uo),Z(t,"[",Oa),Z(t,"]",_a),Z(t,"(",Na),Z(t,")",Da),Z(t,"<",Ra),Z(t,">",La),Z(t,"(",Ia),Z(t,")",Pa),Z(t,"「",Fa),Z(t,"」",Ba),Z(t,"『",$a),Z(t,"』",ja),Z(t,"<",Ha),Z(t,">",Va),Z(t,"&",za),Z(t,"*",Wa),Z(t,"@",Hr),Z(t,"`",Ka),Z(t,"^",Ja),Z(t,":",Vr),Z(t,",",Of),Z(t,"$",Ga),Z(t,".",Wn),Z(t,"=",Ya),Z(t,"!",_f),Z(t,"-",qn),Z(t,"%",Za),Z(t,"|",Xa),Z(t,"+",Qa),Z(t,"#",ec),Z(t,"?",tc),Z(t,'"',Nf),Z(t,"/",Kn),Z(t,";",Df),Z(t,"~",Wo),Z(t,"_",nc),Z(t,"\\",qa);const r=hn(t,If,Af,{[wf]:!0});hn(r,If,r);const i=hn(t,vs,pr,{[Cf]:!0});hn(i,vs,i);const s=hn(t,Rf,Sf,{[xf]:!0});hn(s,vs),hn(s,Rf,s);const o=hn(t,s1,n1,{[e1]:!0});Z(t,o1,Mf,{[e1]:!0}),Z(o,o1),hn(o,s1,o);const l=hn(t,Lf,r1,{[Qb]:!0});hn(l,Lf,l),Z(l,b_,l);const a=Z(l,v_);hn(a,Lf,l);const c=[[vs,i]],u=[[vs,null],[Rf,s]];for(let d=0;d<ic.length;d++)zr(t,ic[d],Ef,pr,c);for(let d=0;d<sc.length;d++)zr(t,sc[d],Tf,Sf,u);Ti(Ef,{tld:!0,ascii:!0},e),Ti(Tf,{utld:!0,alpha:!0},e),zr(t,"file",Ma,pr,c),zr(t,"mailto",Ma,pr,c),zr(t,"http",bs,pr,c),zr(t,"https",bs,pr,c),zr(t,"ftp",bs,pr,c),zr(t,"ftps",bs,pr,c),Ti(Ma,{scheme:!0,ascii:!0},e),Ti(bs,{slashscheme:!0,ascii:!0},e),n=n.sort((d,f)=>d[0]>f[0]?1:-1);for(let d=0;d<n.length;d++){const f=n[d][0],p=n[d][1]?{[p_]:!0}:{[m_]:!0};f.indexOf("-")>=0?p[kf]=!0:vs.test(f)?If.test(f)?p[Ta]=!0:p[Cf]=!0:p[wf]=!0,t1(t,f,f,p)}return t1(t,"localhost",Vo,{ascii:!0}),t.jd=new Wt(rc),{start:t,tokens:ys({groups:e},i1)}}function C_(n,e){const t=x_(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,i=[];let s=0,o=0;for(;o<r;){let l=n,a=null,c=0,u=null,d=-1,f=-1;for(;o<r&&(a=l.go(t[o]));)l=a,l.accepts()?(d=0,f=0,u=l):d>=0&&(d+=t[o].length,f++),c+=t[o].length,s+=t[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 x_(n){const e=[],t=n.length;let r=0;for(;r<t;){let i=n.charCodeAt(r),s,o=i<55296||i>56319||r+1===t||(s=n.charCodeAt(r+1))<56320||s>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function zr(n,e,t,r,i){let s;const o=e.length;for(let l=0;l<o-1;l++){const a=e[l];n.j[a]?s=n.j[a]:(s=new Wt(r),s.jr=i.slice(),n.j[a]=s),n=s}return s=new Wt(t),s.jr=i.slice(),n.j[e[o-1]]=s,s}function l1(n){const e=[],t=[];let r=0,i="0123456789";for(;r<n.length;){let s=0;for(;i.indexOf(n[r+s])>=0;)s++;if(s>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+s),10);o>0;o--)t.pop();r+=s}else t.push(n[r]),r++}return e}const qo={defaultProtocol:"http",events:null,format:a1,formatHref:a1,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Pf(n,e){e===void 0&&(e=null);let t=ys({},qo);n&&(t=ys(t,n instanceof Pf?n.o:n));const r=t.ignoreTags,i=[];for(let s=0;s<r.length;s++)i.push(r[s].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=i}Pf.prototype={o:qo,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let i=this.o[n];return i&&(typeof i=="object"?(i=t.t in i?i[t.t]:qo[n],typeof i=="function"&&r&&(i=i(e,t))):typeof i=="function"&&r&&(i=i(e,t.t,t)),i)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function a1(n){return n}function c1(n,e){this.t="token",this.v=n,this.tk=e}c1.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n){return n===void 0&&(n=qo.defaultProtocol),{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),i=n.get("tagName",t,e),s=this.toFormattedString(n),o={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),u=n.getObj("attributes",t,e),d=n.getObj("events",t,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),u&&ys(o,u),{tagName:i,attributes:o,content:s,eventListeners:d}}};function oc(n,e){class t extends c1{constructor(i,s){super(i,s),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const u1=oc("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),d1=oc("text"),k_=oc("nl"),lc=oc("url",{isLink:!0,toHref(n){return n===void 0&&(n=qo.defaultProtocol),this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==Vo&&n[1].t===Vr}}),pn=n=>new Wt(n);function S_(n){let{groups:e}=n;const t=e.domain.concat([za,Wa,Hr,qa,Ka,Ja,Ga,Ya,qn,Af,Za,Xa,Qa,ec,Kn,rc,Wo,nc]),r=[Ua,Vr,Of,Wn,_f,tc,Nf,Df,Ra,La,zo,Uo,_a,Oa,Na,Da,Ia,Pa,Fa,Ba,$a,ja,Ha,Va],i=[za,Ua,Wa,qa,Ka,Ja,Ga,Ya,qn,zo,Uo,Za,Xa,Qa,ec,tc,Kn,rc,Wo,nc],s=pn(),o=Z(s,Wo);ve(o,i,o),ve(o,e.domain,o);const l=pn(),a=pn(),c=pn();ve(s,e.domain,l),ve(s,e.scheme,a),ve(s,e.slashscheme,c),ve(l,i,o),ve(l,e.domain,l);const u=Z(l,Hr);Z(o,Hr,u),Z(a,Hr,u),Z(c,Hr,u);const d=Z(o,Wn);ve(d,i,o),ve(d,e.domain,o);const f=pn();ve(u,e.domain,f),ve(f,e.domain,f);const h=Z(f,Wn);ve(h,e.domain,f);const p=pn(u1);ve(h,e.tld,p),ve(h,e.utld,p),Z(u,Vo,p);const g=Z(f,qn);ve(g,e.domain,f),ve(p,e.domain,f),Z(p,Wn,h),Z(p,qn,g);const v=Z(p,Vr);ve(v,e.numeric,u1);const w=Z(l,qn),S=Z(l,Wn);ve(w,e.domain,l),ve(S,i,o),ve(S,e.domain,l);const C=pn(lc);ve(S,e.tld,C),ve(S,e.utld,C),ve(C,e.domain,l),ve(C,i,o),Z(C,Wn,S),Z(C,qn,w),Z(C,Hr,u);const y=Z(C,Vr),k=pn(lc);ve(y,e.numeric,k);const E=pn(lc),T=pn();ve(E,t,E),ve(E,r,T),ve(T,t,E),ve(T,r,T),Z(C,Kn,E),Z(k,Kn,E);const N=Z(a,Vr),_=Z(c,Vr),A=Z(_,Kn),R=Z(A,Kn);ve(a,e.domain,l),Z(a,Wn,S),Z(a,qn,w),ve(c,e.domain,l),Z(c,Wn,S),Z(c,qn,w),ve(N,e.domain,E),Z(N,Kn,E),ve(R,e.domain,E),ve(R,t,E),Z(R,Kn,E);const P=[[zo,Uo],[Oa,_a],[Na,Da],[Ra,La],[Ia,Pa],[Fa,Ba],[$a,ja],[Ha,Va]];for(let $=0;$<P.length;$++){const[V,U]=P[$],J=Z(E,V);Z(T,V,J),Z(J,U,E);const G=pn(lc);ve(J,t,G);const ie=pn();ve(J,r),ve(G,t,G),ve(G,r,ie),ve(ie,t,G),ve(ie,r,ie),Z(G,U,E),Z(ie,U,E)}return Z(s,Vo,C),Z(s,Mf,k_),{start:s,tokens:i1}}function E_(n,e,t){let r=t.length,i=0,s=[],o=[];for(;i<r;){let l=n,a=null,c=null,u=0,d=null,f=-1;for(;i<r&&!(a=l.go(t[i].t));)o.push(t[i++]);for(;i<r&&(c=a||l.go(t[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(t[i]),i++);else{o.length>0&&(s.push(Ff(d1,e,o)),o=[]),i-=f,u-=f;const h=d.t,p=t.slice(i-u,i);s.push(Ff(h,e,p))}}return o.length>0&&s.push(Ff(d1,e,o)),s}function Ff(n,e,t){const r=t[0].s,i=t[t.length-1].e,s=e.slice(r,i);return new n(s,t)}const T_=typeof console<"u"&&console&&console.warn||(()=>{}),A_="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 M_(){Wt.groups={},Je.scanner=null,Je.parser=null,Je.tokenQueue=[],Je.pluginQueue=[],Je.customSchemes=[],Je.initialized=!1}function f1(n,e){if(e===void 0&&(e=!1),Je.initialized&&T_(`linkifyjs: already initialized - will not register custom scheme "${n}" ${A_}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
327
+ `);return!s||!o?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:i,empty:s}=t;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:n.commands.exitCode()}}},addInputRules(){return[ju({find:M3,type:this.type,getAttributes:n=>({language:n[1]})}),ju({find:O3,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new je({key:new We("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=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(!t||!s)return!1;const{tr:o}=n.state;return n.state.selection.from===n.state.doc.nodeSize-(1+n.state.selection.$to.depth*2)?o.insert(n.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(t.replace(/\r\n?/g,`
328
+ `)),o.setMeta("paste",!0),n.dispatch(o),!0}}})]}}),Hb=Ve.create({name:"doc",topNode:!0,content:"block+"});function N3(n={}){return new je({view(e){return new D3(e,n)}})}class D3{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.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),t=!e.parent.inlineContent,r;if(t){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",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);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 t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!s){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=op(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 Vb=Ue.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[N3(this.options)]}});class Qe extends ue{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.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,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Qe(e.resolve(t.pos))}getBookmark(){return new yf(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!R3(e)||!L3(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,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(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let a=e.doc.resolve(i);if(Qe.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!se.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),r=!1;continue e}break}s=o,i+=t;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 yf{constructor(e){this.pos=e}map(e){return new yf(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Qe.valid(t)?new Qe(t):ue.near(t)}}function R3(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t-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 L3(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(t);;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 I3(){return new je({props:{decorations:$3,createSelectionBetween(n,e,t){return e.pos==t.pos&&Qe.valid(t)?new Qe(t):null},handleClick:F3,handleKeyDown:P3,handleDOMEvents:{beforeinput:B3}}})}const P3=ku({ArrowLeft:ka("horiz",-1),ArrowRight:ka("horiz",1),ArrowUp:ka("vert",-1),ArrowDown:ka("vert",1)});function ka(n,e){const t=n=="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(t)||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 F3(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Qe.valid(r))return!1;let i=n.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&se.isSelectable(n.state.doc.nodeAt(i.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Qe(r))),!0)}function B3(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Qe))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let i=W.empty;for(let o=r.length-1;o>=0;o--)i=W.from(r[o].createAndFill(null,i));let s=n.state.tr.replace(t.pos,t.pos,new Y(i,0,0));return s.setSelection(ce.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function $3(n){if(!(n.selection instanceof Qe))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",He.create(n.doc,[ut.widget(n.selection.head,e,{key:"gapcursor"})])}const zb=Ue.create({name:"gapCursor",addProseMirrorPlugins(){return[I3()]},extendNodeSchema(n){var e;const t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=ge(re(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}}),j3=Ve.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",xe(this.options.HTMLAttributes,n)]},renderText(){return`
329
+ `},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:i,storedMarks:s}=t;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()}}}),H3=Ve.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(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,xe(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>ju({find:new RegExp(`^(#{1,${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var Sa=200,vt=function(){};vt.prototype.append=function(e){return e.length?(e=vt.from(e),!this.length&&e||e.length<Sa&&this.leafAppend(e)||this.length<Sa&&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 V3(this,e)},vt.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?vt.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},vt.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},vt.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)},vt.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,r),i},vt.from=function(e){return e instanceof vt?e:e&&e.length?new Ub(e):vt.empty};var Ub=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(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<=Sa)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Sa)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(vt);vt.empty=new Ub([]);var V3=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,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 z3=500;class Sn{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,s;t&&(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 Sn(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,t,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,t),h;(h=a&&a.merge(f))&&(f=h,u?s.pop():l=l.slice(0,l.length-1)),s.push(f),t&&(o++,t=void 0),i||(a=f)}let c=o-r.depth;return c>W3&&(l=U3(l,c),o-=c),new Sn(l.append(s),o)}remapping(e,t){let r=new Ri;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,t),r}addMaps(e){return this.eventCount==0?this:new Sn(this.items.append(e.map(t=>new Un(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let a=t;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=t;f<o;f++)c.push(new Un(s.maps[f]));let u=this.items.slice(0,i).append(c).append(r),d=new Sn(u,l);return d.emptyItemCount()>z3&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,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(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=o.selection&&o.selection.map(t.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 Sn(vt.from(i.reverse()),s)}}Sn.empty=new Sn(vt.empty,0);function U3(n,e){let t;return n.forEach((r,i)=>{if(r.selection&&e--==0)return t=i,!1}),n.slice(t)}class Un{constructor(e,t,r,i){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Un(t.getMap().invert(),t,this.selection)}}}class jr{constructor(e,t,r,i,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const W3=20;function q3(n,e,t,r){let i=t.getMeta(Ei),s;if(i)return i.historyState;t.getMeta(G3)&&(n=new jr(n.done,n.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(o&&o.getMeta(Ei))return o.getMeta(Ei).redo?new jr(n.done.addTransform(t,void 0,r,Ea(e)),n.undone,Wb(t.mapping.maps[t.steps.length-1]),n.prevTime,n.prevComposition):new jr(n.done,n.undone.addTransform(t,void 0,r,Ea(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!o&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!K3(t,n.prevRanges)),c=o?bf(n.prevRanges,t.mapping):Wb(t.mapping.maps[t.steps.length-1]);return new jr(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Ea(e)),Sn.empty,c,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new jr(n.done.rebased(t,s),n.undone.rebased(t,s),bf(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new jr(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),bf(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function K3(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function Wb(n){let e=[];return n.forEach((t,r,i,s)=>e.push(i,s)),e}function bf(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let i=e.map(n[r],1),s=e.map(n[r+1],-1);i<=s&&t.push(i,s)}return t}function J3(n,e,t){let r=Ea(e),i=Ei.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),a=new jr(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(Ei,{redo:t,historyState:a})}let vf=!1,qb=null;function Ea(n){let e=n.plugins;if(qb!=e){vf=!1,qb=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){vf=!0;break}}return vf}const Ei=new We("history"),G3=new We("closeHistory");function Y3(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new je({key:Ei,state:{init(){return new jr(Sn.empty,Sn.empty,null,0,-1)},apply(e,t,r){return q3(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,i=r=="historyUndo"?Jb:r=="historyRedo"?Gb:null;return i?(t.preventDefault(),i(e.state,e.dispatch)):!1}}}})}function Kb(n,e){return(t,r)=>{let i=Ei.getState(t);if(!i||(n?i.undone:i.done).eventCount==0)return!1;if(r){let s=J3(i,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}const Jb=Kb(!1,!0),Gb=Kb(!0,!0),Z3=Ue.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>Jb(n,e),redo:()=>({state:n,dispatch:e})=>Gb(n,e)}},addProseMirrorPlugins(){return[Y3(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()}}}),Yb=Ve.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",xe(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{const{$to:t}=e.selection,r=n();return t.parentOffset===0?r.insertContentAt(Math.max(t.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[$u({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),X3=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Q3=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,e_=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,t_=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,n_=jt.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",xe(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ai({find:X3,type:this.type}),ai({find:e_,type:this.type})]},addPasteRules(){return[Rr({find:Q3,type:this.type}),Rr({find:t_,type:this.type})]}}),r_=Ve.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",xe(this.options.HTMLAttributes,n),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)}}}),i_=Ve.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",xe(this.options.HTMLAttributes,n),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)}}}),Zb=jt.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",xe(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=oo(n,this.type);return Object.entries(t).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),Xb=/^(\d+)\.\s$/,s_=Ve.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:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",xe(this.options.HTMLAttributes,t),0]:["ol",xe(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(i_.name,this.editor.getAttributes(Zb.name)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Ji({find:Xb,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Ji({find:Xb,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Zb.name)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),o_=Ve.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",xe(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),l_=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,a_=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,c_=jt.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",xe(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[ai({find:l_,type:this.type})]},addPasteRules(){return[Rr({find:a_,type:this.type})]}}),u_=Ve.create({name:"text",group:"inline"}),d_=Ue.create({name:"starterKit",addExtensions(){var n,e,t,r,i,s,o,l,a,c,u,d,f,h,p,g,v,w;const S=[];return this.options.blockquote!==!1&&S.push(y3.configure((n=this.options)===null||n===void 0?void 0:n.blockquote)),this.options.bold!==!1&&S.push(C3.configure((e=this.options)===null||e===void 0?void 0:e.bold)),this.options.bulletList!==!1&&S.push(S3.configure((t=this.options)===null||t===void 0?void 0:t.bulletList)),this.options.code!==!1&&S.push(A3.configure((r=this.options)===null||r===void 0?void 0:r.code)),this.options.codeBlock!==!1&&S.push(_3.configure((i=this.options)===null||i===void 0?void 0:i.codeBlock)),this.options.document!==!1&&S.push(Hb.configure((s=this.options)===null||s===void 0?void 0:s.document)),this.options.dropcursor!==!1&&S.push(Vb.configure((o=this.options)===null||o===void 0?void 0:o.dropcursor)),this.options.gapcursor!==!1&&S.push(zb.configure((l=this.options)===null||l===void 0?void 0:l.gapcursor)),this.options.hardBreak!==!1&&S.push(j3.configure((a=this.options)===null||a===void 0?void 0:a.hardBreak)),this.options.heading!==!1&&S.push(H3.configure((c=this.options)===null||c===void 0?void 0:c.heading)),this.options.history!==!1&&S.push(Z3.configure((u=this.options)===null||u===void 0?void 0:u.history)),this.options.horizontalRule!==!1&&S.push(Yb.configure((d=this.options)===null||d===void 0?void 0:d.horizontalRule)),this.options.italic!==!1&&S.push(n_.configure((f=this.options)===null||f===void 0?void 0:f.italic)),this.options.listItem!==!1&&S.push(r_.configure((h=this.options)===null||h===void 0?void 0:h.listItem)),this.options.orderedList!==!1&&S.push(s_.configure((p=this.options)===null||p===void 0?void 0:p.orderedList)),this.options.paragraph!==!1&&S.push(o_.configure((g=this.options)===null||g===void 0?void 0:g.paragraph)),this.options.strike!==!1&&S.push(c_.configure((v=this.options)===null||v===void 0?void 0:v.strike)),this.options.text!==!1&&S.push(u_.configure((w=this.options)===null||w===void 0?void 0:w.text)),S}}),f_=jt.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",xe(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=oo(n,this.type);return Object.entries(t).some(([,i])=>!!i)?!0:e.unsetMark(this.name)}}}}),h_=Ue.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:n=>{var e;return(e=n.style.fontFamily)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.fontFamily?{style:`font-family: ${n.fontFamily.split(",").map(e=>CSS.escape(e.trim())).join(", ")}`}:{}}}}]},addCommands(){return{setFontFamily:n=>({chain:e})=>e().setMark("textStyle",{fontFamily:n}).run(),unsetFontFamily:()=>({chain:n})=>n().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),p_=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:n=>n.style.textAlign||this.options.defaultAlignment,renderHTML:n=>n.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${n.textAlign}`}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).every(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.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")}}}),m_="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4vianca6w0s2x0a2z0ure5ba0by2idu3namex3narepublic11d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0cast4mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dabur3d1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0ardian6cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster6d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2tura4vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9dnavy5lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0a1b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp2w2ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4finity6ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",g_="ελ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",ys=(n,e)=>{for(const t in e)n[t]=e[t];return n},wf="numeric",xf="ascii",Cf="alpha",Ta="asciinumeric",Aa="alphanumeric",kf="domain",Qb="emoji",y_="scheme",b_="slashscheme",e1="whitespace";function v_(n,e){return n in e||(e[n]=[]),e[n]}function Ti(n,e,t){e[wf]&&(e[Ta]=!0,e[Aa]=!0),e[xf]&&(e[Ta]=!0,e[Cf]=!0),e[Ta]&&(e[Aa]=!0),e[Cf]&&(e[Aa]=!0),e[Aa]&&(e[kf]=!0),e[Qb]&&(e[kf]=!0);for(const r in e){const i=v_(r,t);i.indexOf(n)<0&&i.push(n)}}function w_(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Wt(n){n===void 0&&(n=null),this.j={},this.jr=[],this.jd=null,this.t=n}Wt.groups={},Wt.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const i=e.jr[r][0],s=e.jr[r][1];if(s&&i.test(n))return s}return e.jd},has(n,e){return e===void 0&&(e=!1),e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let i=0;i<n.length;i++)this.tt(n[i],e,t,r)},tr(n,e,t,r){r=r||Wt.groups;let i;return e&&e.j?i=e:(i=new Wt(e),t&&r&&Ti(e,t,r)),this.jr.push([n,i]),i},ts(n,e,t,r){let i=this;const s=n.length;if(!s)return i;for(let o=0;o<s-1;o++)i=i.tt(n[o]);return i.tt(n[s-1],e,t,r)},tt(n,e,t,r){r=r||Wt.groups;const i=this;if(e&&e.j)return i.j[n]=e,e;const s=e;let o,l=i.go(n);if(l?(o=new Wt,ys(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=ys(w_(o.t,r),t);Ti(s,a,r)}else t&&Ti(s,t,r);o.t=s}return i.j[n]=o,o}};const ve=(n,e,t,r,i)=>n.ta(e,t,r,i),hn=(n,e,t,r,i)=>n.tr(e,t,r,i),t1=(n,e,t,r,i)=>n.ts(e,t,r,i),Z=(n,e,t,r,i)=>n.tt(e,t,r,i),pr="WORD",Sf="UWORD",Vo="LOCALHOST",Ef="TLD",Tf="UTLD",Ma="SCHEME",bs="SLASH_SCHEME",Af="NUM",n1="WS",Mf="NL",zo="OPENBRACE",Uo="CLOSEBRACE",Oa="OPENBRACKET",_a="CLOSEBRACKET",Na="OPENPAREN",Da="CLOSEPAREN",Ra="OPENANGLEBRACKET",La="CLOSEANGLEBRACKET",Ia="FULLWIDTHLEFTPAREN",Pa="FULLWIDTHRIGHTPAREN",Fa="LEFTCORNERBRACKET",Ba="RIGHTCORNERBRACKET",$a="LEFTWHITECORNERBRACKET",ja="RIGHTWHITECORNERBRACKET",Ha="FULLWIDTHLESSTHAN",Va="FULLWIDTHGREATERTHAN",za="AMPERSAND",Ua="APOSTROPHE",Wa="ASTERISK",Hr="AT",qa="BACKSLASH",Ka="BACKTICK",Ja="CARET",Vr="COLON",Of="COMMA",Ga="DOLLAR",Wn="DOT",Ya="EQUALS",_f="EXCLAMATION",qn="HYPHEN",Za="PERCENT",Xa="PIPE",Qa="PLUS",ec="POUND",tc="QUERY",Nf="QUOTE",Df="SEMI",Kn="SLASH",Wo="TILDE",nc="UNDERSCORE",r1="EMOJI",rc="SYM";var i1=Object.freeze({__proto__:null,WORD:pr,UWORD:Sf,LOCALHOST:Vo,TLD:Ef,UTLD:Tf,SCHEME:Ma,SLASH_SCHEME:bs,NUM:Af,WS:n1,NL:Mf,OPENBRACE:zo,CLOSEBRACE:Uo,OPENBRACKET:Oa,CLOSEBRACKET:_a,OPENPAREN:Na,CLOSEPAREN:Da,OPENANGLEBRACKET:Ra,CLOSEANGLEBRACKET:La,FULLWIDTHLEFTPAREN:Ia,FULLWIDTHRIGHTPAREN:Pa,LEFTCORNERBRACKET:Fa,RIGHTCORNERBRACKET:Ba,LEFTWHITECORNERBRACKET:$a,RIGHTWHITECORNERBRACKET:ja,FULLWIDTHLESSTHAN:Ha,FULLWIDTHGREATERTHAN:Va,AMPERSAND:za,APOSTROPHE:Ua,ASTERISK:Wa,AT:Hr,BACKSLASH:qa,BACKTICK:Ka,CARET:Ja,COLON:Vr,COMMA:Of,DOLLAR:Ga,DOT:Wn,EQUALS:Ya,EXCLAMATION:_f,HYPHEN:qn,PERCENT:Za,PIPE:Xa,PLUS:Qa,POUND:ec,QUERY:tc,QUOTE:Nf,SEMI:Df,SLASH:Kn,TILDE:Wo,UNDERSCORE:nc,EMOJI:r1,SYM:rc});const vs=/[a-z]/,Rf=new RegExp("\\p{L}","u"),Lf=new RegExp("\\p{Emoji}","u"),If=/\d/,s1=/\s/,o1=`
330
+ `,x_="️",C_="‍";let ic=null,sc=null;function k_(n){n===void 0&&(n=[]);const e={};Wt.groups=e;const t=new Wt;ic==null&&(ic=l1(m_)),sc==null&&(sc=l1(g_)),Z(t,"'",Ua),Z(t,"{",zo),Z(t,"}",Uo),Z(t,"[",Oa),Z(t,"]",_a),Z(t,"(",Na),Z(t,")",Da),Z(t,"<",Ra),Z(t,">",La),Z(t,"(",Ia),Z(t,")",Pa),Z(t,"「",Fa),Z(t,"」",Ba),Z(t,"『",$a),Z(t,"』",ja),Z(t,"<",Ha),Z(t,">",Va),Z(t,"&",za),Z(t,"*",Wa),Z(t,"@",Hr),Z(t,"`",Ka),Z(t,"^",Ja),Z(t,":",Vr),Z(t,",",Of),Z(t,"$",Ga),Z(t,".",Wn),Z(t,"=",Ya),Z(t,"!",_f),Z(t,"-",qn),Z(t,"%",Za),Z(t,"|",Xa),Z(t,"+",Qa),Z(t,"#",ec),Z(t,"?",tc),Z(t,'"',Nf),Z(t,"/",Kn),Z(t,";",Df),Z(t,"~",Wo),Z(t,"_",nc),Z(t,"\\",qa);const r=hn(t,If,Af,{[wf]:!0});hn(r,If,r);const i=hn(t,vs,pr,{[xf]:!0});hn(i,vs,i);const s=hn(t,Rf,Sf,{[Cf]:!0});hn(s,vs),hn(s,Rf,s);const o=hn(t,s1,n1,{[e1]:!0});Z(t,o1,Mf,{[e1]:!0}),Z(o,o1),hn(o,s1,o);const l=hn(t,Lf,r1,{[Qb]:!0});hn(l,Lf,l),Z(l,x_,l);const a=Z(l,C_);hn(a,Lf,l);const c=[[vs,i]],u=[[vs,null],[Rf,s]];for(let d=0;d<ic.length;d++)zr(t,ic[d],Ef,pr,c);for(let d=0;d<sc.length;d++)zr(t,sc[d],Tf,Sf,u);Ti(Ef,{tld:!0,ascii:!0},e),Ti(Tf,{utld:!0,alpha:!0},e),zr(t,"file",Ma,pr,c),zr(t,"mailto",Ma,pr,c),zr(t,"http",bs,pr,c),zr(t,"https",bs,pr,c),zr(t,"ftp",bs,pr,c),zr(t,"ftps",bs,pr,c),Ti(Ma,{scheme:!0,ascii:!0},e),Ti(bs,{slashscheme:!0,ascii:!0},e),n=n.sort((d,f)=>d[0]>f[0]?1:-1);for(let d=0;d<n.length;d++){const f=n[d][0],p=n[d][1]?{[y_]:!0}:{[b_]:!0};f.indexOf("-")>=0?p[kf]=!0:vs.test(f)?If.test(f)?p[Ta]=!0:p[xf]=!0:p[wf]=!0,t1(t,f,f,p)}return t1(t,"localhost",Vo,{ascii:!0}),t.jd=new Wt(rc),{start:t,tokens:ys({groups:e},i1)}}function S_(n,e){const t=E_(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,i=[];let s=0,o=0;for(;o<r;){let l=n,a=null,c=0,u=null,d=-1,f=-1;for(;o<r&&(a=l.go(t[o]));)l=a,l.accepts()?(d=0,f=0,u=l):d>=0&&(d+=t[o].length,f++),c+=t[o].length,s+=t[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 E_(n){const e=[],t=n.length;let r=0;for(;r<t;){let i=n.charCodeAt(r),s,o=i<55296||i>56319||r+1===t||(s=n.charCodeAt(r+1))<56320||s>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function zr(n,e,t,r,i){let s;const o=e.length;for(let l=0;l<o-1;l++){const a=e[l];n.j[a]?s=n.j[a]:(s=new Wt(r),s.jr=i.slice(),n.j[a]=s),n=s}return s=new Wt(t),s.jr=i.slice(),n.j[e[o-1]]=s,s}function l1(n){const e=[],t=[];let r=0,i="0123456789";for(;r<n.length;){let s=0;for(;i.indexOf(n[r+s])>=0;)s++;if(s>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+s),10);o>0;o--)t.pop();r+=s}else t.push(n[r]),r++}return e}const qo={defaultProtocol:"http",events:null,format:a1,formatHref:a1,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Pf(n,e){e===void 0&&(e=null);let t=ys({},qo);n&&(t=ys(t,n instanceof Pf?n.o:n));const r=t.ignoreTags,i=[];for(let s=0;s<r.length;s++)i.push(r[s].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=i}Pf.prototype={o:qo,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let i=this.o[n];return i&&(typeof i=="object"?(i=t.t in i?i[t.t]:qo[n],typeof i=="function"&&r&&(i=i(e,t))):typeof i=="function"&&r&&(i=i(e,t.t,t)),i)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function a1(n){return n}function c1(n,e){this.t="token",this.v=n,this.tk=e}c1.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n){return n===void 0&&(n=qo.defaultProtocol),{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),i=n.get("tagName",t,e),s=this.toFormattedString(n),o={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),u=n.getObj("attributes",t,e),d=n.getObj("events",t,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),u&&ys(o,u),{tagName:i,attributes:o,content:s,eventListeners:d}}};function oc(n,e){class t extends c1{constructor(i,s){super(i,s),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const u1=oc("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),d1=oc("text"),T_=oc("nl"),lc=oc("url",{isLink:!0,toHref(n){return n===void 0&&(n=qo.defaultProtocol),this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==Vo&&n[1].t===Vr}}),pn=n=>new Wt(n);function A_(n){let{groups:e}=n;const t=e.domain.concat([za,Wa,Hr,qa,Ka,Ja,Ga,Ya,qn,Af,Za,Xa,Qa,ec,Kn,rc,Wo,nc]),r=[Ua,Vr,Of,Wn,_f,tc,Nf,Df,Ra,La,zo,Uo,_a,Oa,Na,Da,Ia,Pa,Fa,Ba,$a,ja,Ha,Va],i=[za,Ua,Wa,qa,Ka,Ja,Ga,Ya,qn,zo,Uo,Za,Xa,Qa,ec,tc,Kn,rc,Wo,nc],s=pn(),o=Z(s,Wo);ve(o,i,o),ve(o,e.domain,o);const l=pn(),a=pn(),c=pn();ve(s,e.domain,l),ve(s,e.scheme,a),ve(s,e.slashscheme,c),ve(l,i,o),ve(l,e.domain,l);const u=Z(l,Hr);Z(o,Hr,u),Z(a,Hr,u),Z(c,Hr,u);const d=Z(o,Wn);ve(d,i,o),ve(d,e.domain,o);const f=pn();ve(u,e.domain,f),ve(f,e.domain,f);const h=Z(f,Wn);ve(h,e.domain,f);const p=pn(u1);ve(h,e.tld,p),ve(h,e.utld,p),Z(u,Vo,p);const g=Z(f,qn);ve(g,e.domain,f),ve(p,e.domain,f),Z(p,Wn,h),Z(p,qn,g);const v=Z(p,Vr);ve(v,e.numeric,u1);const w=Z(l,qn),S=Z(l,Wn);ve(w,e.domain,l),ve(S,i,o),ve(S,e.domain,l);const x=pn(lc);ve(S,e.tld,x),ve(S,e.utld,x),ve(x,e.domain,l),ve(x,i,o),Z(x,Wn,S),Z(x,qn,w),Z(x,Hr,u);const y=Z(x,Vr),k=pn(lc);ve(y,e.numeric,k);const E=pn(lc),T=pn();ve(E,t,E),ve(E,r,T),ve(T,t,E),ve(T,r,T),Z(x,Kn,E),Z(k,Kn,E);const N=Z(a,Vr),_=Z(c,Vr),A=Z(_,Kn),R=Z(A,Kn);ve(a,e.domain,l),Z(a,Wn,S),Z(a,qn,w),ve(c,e.domain,l),Z(c,Wn,S),Z(c,qn,w),ve(N,e.domain,E),Z(N,Kn,E),ve(R,e.domain,E),ve(R,t,E),Z(R,Kn,E);const P=[[zo,Uo],[Oa,_a],[Na,Da],[Ra,La],[Ia,Pa],[Fa,Ba],[$a,ja],[Ha,Va]];for(let $=0;$<P.length;$++){const[V,U]=P[$],J=Z(E,V);Z(T,V,J),Z(J,U,E);const G=pn(lc);ve(J,t,G);const ie=pn();ve(J,r),ve(G,t,G),ve(G,r,ie),ve(ie,t,G),ve(ie,r,ie),Z(G,U,E),Z(ie,U,E)}return Z(s,Vo,x),Z(s,Mf,T_),{start:s,tokens:i1}}function M_(n,e,t){let r=t.length,i=0,s=[],o=[];for(;i<r;){let l=n,a=null,c=null,u=0,d=null,f=-1;for(;i<r&&!(a=l.go(t[i].t));)o.push(t[i++]);for(;i<r&&(c=a||l.go(t[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(t[i]),i++);else{o.length>0&&(s.push(Ff(d1,e,o)),o=[]),i-=f,u-=f;const h=d.t,p=t.slice(i-u,i);s.push(Ff(h,e,p))}}return o.length>0&&s.push(Ff(d1,e,o)),s}function Ff(n,e,t){const r=t[0].s,i=t[t.length-1].e,s=e.slice(r,i);return new n(s,t)}const O_=typeof console<"u"&&console&&console.warn||(()=>{}),__="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 N_(){Wt.groups={},Je.scanner=null,Je.parser=null,Je.tokenQueue=[],Je.pluginQueue=[],Je.customSchemes=[],Je.initialized=!1}function f1(n,e){if(e===void 0&&(e=!1),Je.initialized&&O_(`linkifyjs: already initialized - will not register custom scheme "${n}" ${__}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
316
331
  1. Must only contain digits, lowercase ASCII letters or "-"
317
332
  2. Cannot start or end with "-"
318
- 3. "-" cannot repeat`);Je.customSchemes.push([n,e])}function O_(){Je.scanner=w_(Je.customSchemes);for(let n=0;n<Je.tokenQueue.length;n++)Je.tokenQueue[n][1]({scanner:Je.scanner});Je.parser=S_(Je.scanner.tokens);for(let n=0;n<Je.pluginQueue.length;n++)Je.pluginQueue[n][1]({scanner:Je.scanner,parser:Je.parser});Je.initialized=!0}function h1(n){return Je.initialized||O_(),E_(Je.parser.start,n,C_(Je.scanner.start,n))}function p1(n,e,t){if(e===void 0&&(e=null),t===void 0&&(t=null),e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new Pf(t),i=h1(n),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 __(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function N_(n){return new je({key:new We("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,l=yk(t.doc,[...e]);if(Ek(l).forEach(({newRange:c})=>{const u=vk(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=h1(p).map(w=>w.toObject());if(!__(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=>n.validate?n.validate(w.value):!0).forEach(w=>{Iu(w.from,w.to,r.doc).some(S=>S.mark.type===n.type)||o.addMark(w.from,w.to,n.type.create({href:w.href}))})}}),!!o.steps.length)return o}})}function D_(n){return new je({key:new We("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,s;if(n.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=Zm(e.state,n.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 R_(n){return new je({key:new We("handlePasteLink"),props:{handlePaste:(e,t,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=p1(l).find(c=>c.isLink&&c.value===l);return!l||!a?!1:(n.editor.commands.setMark(n.type,{href:a.href}),!0)}}})}const L_=jt.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(n=>{if(typeof n=="string"){f1(n);return}f1(n.scheme,n.optionalSlashes)})},onDestroy(){M_()},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:n}){var e;return!((e=n.href)===null||e===void 0)&&e.startsWith("javascript:")?["a",Ce(this.options.HTMLAttributes,{...n,href:""}),0]:["a",Ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setLink:n=>({chain:e})=>e().setMark(this.name,n).setMeta("preventAutolink",!0).run(),toggleLink:n=>({chain:e})=>e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Rr({find:n=>{const e=[];if(n){const t=p1(n).filter(r=>r.isLink);t.length&&t.forEach(r=>e.push({text:r.value,data:{href:r.href},index:r.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[];return this.options.autolink&&n.push(N_({type:this.type,validate:this.options.validate})),this.options.openOnClick&&n.push(D_({type:this.type,whenNotEditable:this.options.openOnClick==="whenNotEditable"})),this.options.linkOnPaste&&n.push(R_({editor:this.editor,type:this.type})),n}}),I_=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:n,selection:e})=>{var t;const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=e,s=[];if(!r)return null;const{firstChild:o}=n.content,l=o&&o.type.isLeaf,a=o&&o.isAtom,c=this.options.considerAnyAsEmpty?!0:o&&o.type.name===((t=n.type.contentMatch.defaultType)===null||t===void 0?void 0:t.name),u=n.content.childCount<=1&&o&&c&&o.nodeSize<=2&&(!l||!a);return n.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(n,s)}}})]}}),P_=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,F_=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,B_=jt.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",Ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[ai({find:P_,type:this.type})]},addPasteRules(){return[Rr({find:F_,type:this.type})]}}),$_=Ve.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:n}){return["ul",Ce(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),j_=/^\s*(\[([( |x])?\])\s$/,H_=Ve.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:n=>n.getAttribute("data-checked")==="true",renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",Ce(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,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 t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:d})=>{const f=t(),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(n,u)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([c,u])=>{i.setAttribute(c,u)}),i.dataset.checked=n.attrs.checked,n.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[Ji({find:j_,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),V_=jt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",Ce(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function z_(n){var e;const{char:t,allowSpaces:r,allowedPrefixes:i,startOfLine:s,$position:o}=n,l=Gk(t),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(t.length),text:h[0]}:null}const U_=new We("suggestion");function W_({pluginKey:n=U_,editor:e,char:t="@",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=z_}){let h;const p=u==null?void 0:u(),g=new je({key:n,view(){return{update:async(v,w)=>{var S,C,y,k,E,T,N;const _=(S=this.key)===null||S===void 0?void 0:S.getState(w),A=(C=this.key)===null||C===void 0?void 0:C.getState(v.state),R=_.active&&A.active&&_.range.from!==A.range.from,P=!_.active&&A.active,$=_.active&&!A.active,V=!P&&!$&&_.query!==A.query,U=P||R,J=V&&!R,G=$||R;if(!U&&!J&&!G)return;const ie=G&&!U?_:A,X=v.dom.querySelector(`[data-decoration-id="${ie.decorationId}"]`);h={editor:e,range:ie.range,query:ie.query,text:ie.text,items:[],command:we=>a({editor:e,range:ie.range,props:we}),decorationNode:X,clientRect:X?()=>{var we;const{decorationId:Re}=(we=this.key)===null||we===void 0?void 0:we.getState(e.state),Pe=v.dom.querySelector(`[data-decoration-id="${Re}"]`);return(Pe==null?void 0:Pe.getBoundingClientRect())||null}:null},U&&((y=p==null?void 0:p.onBeforeStart)===null||y===void 0||y.call(p,h)),J&&((k=p==null?void 0:p.onBeforeUpdate)===null||k===void 0||k.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&&((N=p==null?void 0:p.onStart)===null||N===void 0||N.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,C){const{isEditable:y}=e,{composing:k}=e.view,{selection:E}=v,{empty:T,from:N}=E,_={...w};if(_.composing=k,y&&(T||e.view.composing)){(N<w.range.from||N>w.range.to)&&!k&&!w.composing&&(_.active=!1);const A=f({char:t,allowSpaces:r,allowedPrefixes:i,startOfLine:s,$position:E.$from}),R=`id_${Math.floor(Math.random()*4294967295)}`;A&&d({editor:e,state:C,range:A.range})?(_.active=!0,_.decorationId=w.decorationId?w.decorationId:R,_.range=A.range,_.query=A.query,_.text=A.text):_.active=!1}else _.active=!1;return _.active||(_.decorationId=null,_.range={from:0,to:0},_.query=null,_.text=null),_}},props:{handleKeyDown(v,w){var S;const{active:C,range:y}=g.getState(v.state);return C&&((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:C}=g.getState(v);return w?He.create(v.doc,[ut.inline(S.from,S.to,{nodeName:o,class:l,"data-decoration-id":C})]):null}}});return g}const q_=Ue.create({name:"slash-command",addOptions(){return{suggestion:{char:"/",command:({editor:n,range:e,props:t})=>{t.command({editor:n,range:e})}}}},addProseMirrorPlugins(){return[W_({editor:this.editor,...this.options.suggestion})]}}),K_=({query:n})=>[{title:"Text",description:"Just start typing with plain text.",searchTerms:["p","paragraph"],icon:D.jsx(d0,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").run()}},{title:"To-do List",description:"Track tasks with a to-do list.",searchTerms:["todo","task","list","check","checkbox"],icon:D.jsx(c0,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleTaskList().run()}},{title:"Heading 1",description:"Big section heading.",searchTerms:["title","big","large"],icon:D.jsx(o0,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:1}).run()}},{title:"Heading 2",description:"Medium section heading.",searchTerms:["subtitle","medium"],icon:D.jsx(l0,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:2}).run()}},{title:"Heading 3",description:"Small section heading.",searchTerms:["subtitle","small"],icon:D.jsx(a0,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:3}).run()}},{title:"Bullet List",description:"Create a simple bullet list.",searchTerms:["unordered","point"],icon:D.jsx(XE,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleBulletList().run()}},{title:"Numbered List",description:"Create a list with numbering.",searchTerms:["ordered"],icon:D.jsx(sd,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleOrderedList().run()}},{title:"Divider",description:"Visually divide content.",searchTerms:["hr","divider","break","line","delimiter"],icon:D.jsx(QE,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setHorizontalRule().run()}},{title:"Quote",description:"Capture a quote.",searchTerms:["blockquote"],icon:D.jsx(u0,{size:18}),image:"",command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").toggleBlockquote().run()},{title:"Code",description:"Capture a code snippet.",searchTerms:["codeblock"],icon:D.jsx(i0,{size:18}),image:"",command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).toggleCodeBlock().run()},{title:"Table",description:"Create a table.",searchTerms:["table"],icon:D.jsx(iT,{size:18}),image:"",command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{title:"Image",description:"Upload an image from your computer.",searchTerms:["photo","picture","media"],icon:D.jsx(ZE,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).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;y0(s,e.view,o)}},r.click()}},{title:"Video Embed",description:"Embed a video from YouTube, Vimeo, etc.",searchTerms:["iframe","embed","video","youtube"],icon:D.jsx(h0,{}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setActionButton("iframe").run()}},{title:"Twitter",description:"Embed a Twitter tweet.",searchTerms:["embed","twitter","tweet"],icon:D.jsx(f0,{}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setActionButton("twitter").run()}},{title:"2 Columns",description:"Create 2 columns of block",searchTerms:["col","column","2","layout"],icon:D.jsx(s0,{}),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:D.jsx(KE,{}),image:"",command:({editor:e})=>{e.chain().focus().setColumns(3).focus(e.state.selection.head-1).run()}}].filter(e=>{if(typeof n=="string"&&n.length>0){const t=n.toLowerCase();return e.title.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.searchTerms&&e.searchTerms.some(r=>r.includes(t))}return!0}),J_=(n,e)=>{const t=n.offsetHeight,r=e?e.offsetHeight:0,i=e.offsetTop,s=i+r;i<n.scrollTop?n.scrollTop-=n.scrollTop-i+5:s>t+n.scrollTop&&(n.scrollTop+=s-t-n.scrollTop+5)},G_=({items:n,command:e,editor:t})=>{const[r,i]=O.useState(0),s=O.useCallback(l=>{const a=n[l];a&&(a.title==="Continue writing"||e(a))},[e,t,n]);O.useEffect(()=>{const l=["ArrowUp","ArrowDown","Enter"],a=c=>{if(l.includes(c.key))return c.preventDefault(),c.key==="ArrowUp"?(i((r+n.length-1)%n.length),!0):c.key==="ArrowDown"?(i((r+1)%n.length),!0):c.key==="Enter"?(s(r),!0):!1};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a)}},[n,r,i,s]),O.useEffect(()=>{i(0)},[n]);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&&J_(l,a)},[r]),n.length>0?D.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:n.map((l,a)=>D.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:[D.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border border-neutral-200 bg-white",children:l.icon}),D.jsxs("div",{children:[D.jsx("p",{className:"font-medium",children:l.title}),D.jsx("p",{className:"text-xs text-neutral-500",children:l.description})]})]},a))}):null},Y_=()=>{let n=null,e=null;return{onStart:t=>{n=new Jg(G_,{props:t,editor:t.editor}),e=fi("body",{getReferenceClientRect:t.clientRect,appendTo:()=>document.body,content:n.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"})},onUpdate:t=>{n==null||n.updateProps(t),e&&e[0].setProps({getReferenceClientRect:t.clientRect})},onKeyDown:t=>{var r;return t.event.key==="Escape"?(e==null||e[0].hide(),!0):(r=n==null?void 0:n.ref)==null?void 0:r.onKeyDown(t)},onExit:()=>{e==null||e[0].destroy(),n==null||n.destroy()}}},Z_=q_.configure({suggestion:{items:K_,render:Y_}}),X_=Yb.extend({renderHTML(){return["div",Ce(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}}),Q_=Ue.create({name:"columnExtension",addExtensions(){const n=[];return this.options.column!==!1&&n.push(w0),this.options.columns!==!1&&n.push(Vl),n}}),eN=Ue.create({name:"CustomKeymap",addCommands(){return{selectTextWithinNodeBoundaries:()=>({editor:n,commands:e})=>{const{state:t}=n,{tr:r}=t,i=r.selection.$from.start(),s=r.selection.$to.end();return e.setTextSelection({from:i,to:s})}}},addKeyboardShortcuts(){return{"Mod-a":({editor:n})=>{const{state:e}=n,{tr:t}=e,r=t.selection.from,i=t.selection.to,s=t.selection.$from.start(),o=t.selection.$to.end();return r>s||i<o?(n.chain().selectTextWithinNodeBoundaries().run(),!0):!1}}}}),tN=Ue.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:n=>{var e;return(e=n.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}}}}]},addCommands(){return{setColor:n=>({chain:e})=>e().setMark("textStyle",{color:n}).run(),unsetColor:()=>({chain:n})=>n().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),m1=[{tooltip:"Align left",action:n=>n({dataAlign:"start",dataFloat:null}),icon:od,isActive:n=>n.dataAlign==="start"},{tooltip:"Align center",action:n=>n({dataAlign:"center",dataFloat:null}),icon:p0,isActive:n=>n.dataAlign==="center"},{tooltip:"Align right",action:n=>n({dataAlign:"end",dataFloat:null}),icon:m0,isActive:n=>n.dataAlign==="end"},{tooltip:"Delete",icon:"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3cpath%20fill='currentColor'%20d='M19%204h-3.5l-1-1h-5l-1%201H5v2h14M6%2019a2%202%200%200%200%202%202h8a2%202%200%200%200%202-2V7H6v12Z'/%3e%3c/svg%3e",delete:n=>n()}];let ws;const g1=({node:n,updateAttributes:e,deleteNode:t})=>{const r=Ul(),[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={};m1.forEach(({tooltip:$,isActive:V})=>{P[$]=!!(V!=null&&V(n.attrs))}),d(P)},v=()=>{const P=document.querySelector(".ProseMirror");if(P&&c(P==null?void 0:P.clientWidth),!!f.current){if(i==="video"){const $=f.current;$.addEventListener("loadeddata",function(){l($.videoWidth/$.videoHeight),E("left",0)})}else if(i==="iframe"){const $=f.current;$.onload=()=>{l($.offsetWidth/$.offsetHeight),E("left",0)}}else f.current.onload=()=>{l(f.current.naturalWidth/f.current.naturalHeight)};setTimeout(()=>g(),200)}},w=P=>{ws=P};O.useEffect(()=>{v()},[]);const S=({width:P,height:$})=>P<200||$<200,C=P=>{setTimeout(()=>T(P))},y=P=>{ws=P.clientX,setTimeout(()=>{document.addEventListener("mousemove",C),document.addEventListener("mouseup",k)}),p(!0)},k=()=>{ws=-1,document.removeEventListener("mousemove",C),document.removeEventListener("mouseup",k),p(!1)},E=(P,$)=>{var J,G;if(!f.current){console.error("Media ref is undefined|null",{resizableImg:f.current});return}const V={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=V.width-Math.abs($):(typeof V.width=="string"&&(V.width=Number(V.width)),U.width=V.width+Math.abs($)),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(ws===-1)return;const{clientX:$}=P,V=ws-$;if(V===0)return;const U=V>0?"left":"right";setTimeout(()=>{E(U,Math.abs(V)),ws=$})},[N,_]=O.useState(),[A,R]=O.useState();return O.useEffect(()=>{s(n.attrs["media-type"]),g(),_(n.attrs.dataFloat),R(n.attrs.dataAlign)},[n.attrs]),D.jsx(bo,{as:"article",className:Fe("media-node-view not-prose transition-all ease-in-out w-full",N&&`f-${n.attrs.dataFloat}`,A&&`justify-${n.attrs.dataAlign}`),children:D.jsxs("div",{className:"w-fit flex relative group transition-all ease-in-out",children:[i==="img"&&D.jsx("img",{src:n.attrs.src,ref:f,className:"rounded-lg",alt:n.attrs.src,width:n.attrs.width,height:n.attrs.height}),i==="video"&&D.jsx("video",{ref:f,className:"rounded-lg",controls:!0,width:n.attrs.width,height:n.attrs.height,children:D.jsx("source",{src:n.attrs.src})}),i==="iframe"&&D.jsx("iframe",{ref:f,className:Fe("rounded-lg max-w-full",h&&"pointer-events-none"),src:n.attrs.src,width:n.attrs.width,height:n.attrs.height}),!r&&D.jsxs(D.Fragment,{children:[D.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:k}),D.jsx("section",{className:"media-control-buttons opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:m1.map(P=>D.jsx("div",{className:"tooltip","data-tip":P.tooltip,children:D.jsx("button",{type:"button",className:Fe("btn rounded-none h-8 px-2",u[P.tooltip]&&"active"),onClick:()=>{var $;return P.tooltip==="Delete"?t():($=P.action)==null?void 0:$.call(P,e)},children:D.jsx("img",{src:P.icon,className:"w-4"})})}))})]})]})})},nN=Ve.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(g1)},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:n}){return["iframe",Ce(this.options.HTMLAttributes,n)]},addCommands(){return{setIframe:n=>({tr:e,dispatch:t})=>{const{selection:r}=e,i=this.type.create(n);return t&&e.replaceRangeWith(r.from-1,r.to,i),!0}}}});var rN="https://platform.twitter.com/widgets.js",Bf="createTweet",iN=function(e){var t=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(rN,"twitter-embed",function(){if(!window.twttr){console.error("Failure to load window.twttr, aborting load");return}if(o){if(!window.twttr.widgets[Bf]){console.error("Method "+Bf+" is not present anymore in twttr.widget api");return}window.twttr.widgets[Bf](e.tweetId,t==null?void 0:t.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:t}))};const sN=({node:n,editor:e})=>{const[t,r]=O.useState(!0);return O.useEffect(()=>{e==null||e.chain().focus()},[]),D.jsx(bo,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:D.jsxs("div",{className:"w-full max-w-sm",children:[t&&D.jsx(N0,{width:5,height:5}),D.jsx(iN,{tweetId:n.attrs.tweetId,onLoad:()=>r(!1)})]})})},oN=Ve.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:n}){return["div",Ce(this.options.HTMLAttributes,n)]},addNodeView(){return hi(sN)},addCommands(){return{setTweetEmbed:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{tweetId:n.tweetId,align:"center"},content:[]})}}}),lN=n=>new je({key:new We("media-paste-drop"),props:{handlePaste(e,t){var i;return Array.from(((i=t.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)&&(t.preventDefault(),o&&o.size>1024*1024))throw new Error("Image too large")}),!1},handleDrop(e,t){var l;if(!(t.dataTransfer&&t.dataTransfer.files&&t.dataTransfer.files.length))return!1;const i=Array.from(((l=t.dataTransfer)==null?void 0:l.files)??[]).filter(({type:a})=>/image|video/i.test(a));if(i.length===0)return!1;t.preventDefault();const{schema:s}=e.state,o=e.posAtCoords({left:t.clientX,top:t.clientY});return o?(i.forEach(async a=>{const c=new FileReader;if(n){const u=s.nodes.resizableMedia.create({src:await n(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}}}),aN=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,cN=/!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/,uN=Ve.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:n=>({src:n.getAttribute("src"),"media-type":"img"})},{tag:"video",getAttrs:n=>({src:n.getAttribute("src"),"media-type":"video"})}]},renderHTML({HTMLAttributes:n}){const{"media-type":e}=n;return e==="img"?["img",Ce(this.options.HTMLAttributes,n)]:e==="video"?["video",{controls:"true",style:"width: 100%",...n},["source",n]]:(e||console.error("TiptapMediaExtension-renderHTML method: Media Type not set, going default with image"),["img",Ce(this.options.HTMLAttributes,n)])},addCommands(){return{setMedia:n=>({commands:e})=>{const{"media-type":t}=n;return t==="img"?e.insertContent({type:this.name,attrs:n}):t==="video"?e.insertContent({type:this.name,attrs:{...n,controls:"true"}}):(t||console.error("TiptapMediaExtension-setMedia: Media Type not set, going default with image"),e.insertContent({type:this.name,attrs:n}))}}},addNodeView(){return hi(g1)},addKeyboardShortcuts(){return{Enter:({editor:n})=>{const{selection:e}=n.state;if(e.empty)return!1;const t=e.$to.pos;return n.commands.insertContentAt(t,{type:"dBlock",content:[{type:"paragraph"}]})}}},addInputRules(){return[$u({find:aN,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r,"media-type":"img"}}}),$u({find:cN,type:this.type,getAttributes:n=>{const[,,e]=n;return{src:e,"media-type":"video"}}})]},addProseMirrorPlugins(){return[lN(this.options.uploadFn),CT()]}});function y1(n,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>n(...i),e)}}function dt(){return dt=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},dt.apply(null,arguments)}function Ur(n,e,{checkForDefaultPrevented:t=!0}={}){return function(i){if(n==null||n(i),t===!1||!i.defaultPrevented)return e==null?void 0:e(i)}}function dN(n,e){typeof n=="function"?n(e):n!=null&&(n.current=e)}function b1(...n){return e=>n.forEach(t=>dN(t,e))}function Ai(...n){return O.useCallback(b1(...n),n)}function v1(n,e=[]){let t=[];function r(s,o){const l=O.createContext(o),a=t.length;t=[...t,o];function c(d){const{scope:f,children:h,...p}=d,g=(f==null?void 0:f[n][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[n][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=t.map(o=>O.createContext(o));return function(l){const a=(l==null?void 0:l[n])||s;return O.useMemo(()=>({[`__scope${n}`]:{...l,[n]:a}}),[l,a])}};return i.scopeName=n,[r,fN(i,...e)]}function fN(...n){const e=n[0];if(n.length===1)return e;const t=()=>{const r=n.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 t.scopeName=e.scopeName,t}const $f=O.forwardRef((n,e)=>{const{children:t,...r}=n,i=O.Children.toArray(t),s=i.find(pN);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(jf,dt({},r,{ref:e}),O.isValidElement(o)?O.cloneElement(o,void 0,l):null)}return O.createElement(jf,dt({},r,{ref:e}),t)});$f.displayName="Slot";const jf=O.forwardRef((n,e)=>{const{children:t,...r}=n;return O.isValidElement(t)?O.cloneElement(t,{...mN(r,t.props),ref:e?b1(e,t.ref):t.ref}):O.Children.count(t)>1?O.Children.only(null):null});jf.displayName="SlotClone";const hN=({children:n})=>O.createElement(O.Fragment,null,n);function pN(n){return O.isValidElement(n)&&n.type===hN}function mN(n,e){const t={...e};for(const r in e){const i=n[r],s=e[r];/^on[A-Z]/.test(r)?i&&s?t[r]=(...l)=>{s(...l),i(...l)}:i&&(t[r]=i):r==="style"?t[r]={...i,...s}:r==="className"&&(t[r]=[i,s].filter(Boolean).join(" "))}return{...n,...t}}const Mi=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((n,e)=>{const t=O.forwardRef((r,i)=>{const{asChild:s,...o}=r,l=s?$f:e;return O.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),O.createElement(l,dt({},o,{ref:i}))});return t.displayName=`Primitive.${e}`,{...n,[e]:t}},{});function gN(n,e){n&&nn.flushSync(()=>n.dispatchEvent(e))}function Wr(n){const e=O.useRef(n);return O.useEffect(()=>{e.current=n}),O.useMemo(()=>(...t)=>{var r;return(r=e.current)===null||r===void 0?void 0:r.call(e,...t)},[])}function yN(n,e=globalThis==null?void 0:globalThis.document){const t=Wr(n);O.useEffect(()=>{const r=i=>{i.key==="Escape"&&t(i)};return e.addEventListener("keydown",r),()=>e.removeEventListener("keydown",r)},[t,e])}const Hf="dismissableLayer.update",bN="dismissableLayer.pointerDownOutside",vN="dismissableLayer.focusOutside";let w1;const wN=O.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),CN=O.forwardRef((n,e)=>{var t;const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:l,onDismiss:a,...c}=n,u=O.useContext(wN),[d,f]=O.useState(null),h=(t=d==null?void 0:d.ownerDocument)!==null&&t!==void 0?t:globalThis==null?void 0:globalThis.document,[,p]=O.useState({}),g=Ai(e,N=>f(N)),v=Array.from(u.layers),[w]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),S=v.indexOf(w),C=d?v.indexOf(d):-1,y=u.layersWithOutsidePointerEventsDisabled.size>0,k=C>=S,E=xN(N=>{const _=N.target,A=[...u.branches].some(R=>R.contains(_));!k||A||(s==null||s(N),l==null||l(N),N.defaultPrevented||a==null||a())},h),T=kN(N=>{const _=N.target;[...u.branches].some(R=>R.contains(_))||(o==null||o(N),l==null||l(N),N.defaultPrevented||a==null||a())},h);return yN(N=>{C===u.layers.size-1&&(i==null||i(N),!N.defaultPrevented&&a&&(N.preventDefault(),a()))},h),O.useEffect(()=>{if(d)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(w1=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),C1(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=w1)}},[d,h,r,u]),O.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),C1())},[d,u]),O.useEffect(()=>{const N=()=>p({});return document.addEventListener(Hf,N),()=>document.removeEventListener(Hf,N)},[]),O.createElement(Mi.div,dt({},c,{ref:g,style:{pointerEvents:y?k?"auto":"none":void 0,...n.style},onFocusCapture:Ur(n.onFocusCapture,T.onFocusCapture),onBlurCapture:Ur(n.onBlurCapture,T.onBlurCapture),onPointerDownCapture:Ur(n.onPointerDownCapture,E.onPointerDownCapture)}))});function xN(n,e=globalThis==null?void 0:globalThis.document){const t=Wr(n),r=O.useRef(!1),i=O.useRef(()=>{});return O.useEffect(()=>{const s=l=>{if(l.target&&!r.current){let c=function(){x1(bN,t,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,t]),{onPointerDownCapture:()=>r.current=!0}}function kN(n,e=globalThis==null?void 0:globalThis.document){const t=Wr(n),r=O.useRef(!1);return O.useEffect(()=>{const i=s=>{s.target&&!r.current&&x1(vN,t,{originalEvent:s},{discrete:!1})};return e.addEventListener("focusin",i),()=>e.removeEventListener("focusin",i)},[e,t]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function C1(){const n=new CustomEvent(Hf);document.dispatchEvent(n)}function x1(n,e,t,{discrete:r}){const i=t.originalEvent.target,s=new CustomEvent(n,{bubbles:!1,cancelable:!0,detail:t});e&&i.addEventListener(n,e,{once:!0}),r?gN(i,s):i.dispatchEvent(s)}let Vf=0;function SN(){O.useEffect(()=>{var n,e;const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",(n=t[0])!==null&&n!==void 0?n:k1()),document.body.insertAdjacentElement("beforeend",(e=t[1])!==null&&e!==void 0?e:k1()),Vf++,()=>{Vf===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(r=>r.remove()),Vf--}},[])}function k1(){const n=document.createElement("span");return n.setAttribute("data-radix-focus-guard",""),n.tabIndex=0,n.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",n}const zf="focusScope.autoFocusOnMount",Uf="focusScope.autoFocusOnUnmount",S1={bubbles:!1,cancelable:!0},EN=O.forwardRef((n,e)=>{const{loop:t=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...o}=n,[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(C){if(h.paused||!l)return;const y=C.target;l.contains(y)?d.current=y:qr(d.current,{select:!0})},v=function(C){if(h.paused||!l)return;const y=C.relatedTarget;y!==null&&(l.contains(y)||qr(d.current,{select:!0}))},w=function(C){if(document.activeElement===document.body)for(const k of C)k.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){A1.add(h);const g=document.activeElement;if(!l.contains(g)){const w=new CustomEvent(zf,S1);l.addEventListener(zf,c),l.dispatchEvent(w),w.defaultPrevented||(TN(NN(E1(l)),{select:!0}),document.activeElement===g&&qr(l))}return()=>{l.removeEventListener(zf,c),setTimeout(()=>{const w=new CustomEvent(Uf,S1);l.addEventListener(Uf,u),l.dispatchEvent(w),w.defaultPrevented||qr(g??document.body,{select:!0}),l.removeEventListener(Uf,u),A1.remove(h)},0)}}},[l,c,u,h]);const p=O.useCallback(g=>{if(!t&&!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,[C,y]=AN(S);C&&y?!g.shiftKey&&w===y?(g.preventDefault(),t&&qr(C,{select:!0})):g.shiftKey&&w===C&&(g.preventDefault(),t&&qr(y,{select:!0})):w===S&&g.preventDefault()}},[t,r,h.paused]);return O.createElement(Mi.div,dt({tabIndex:-1},o,{ref:f,onKeyDown:p}))});function TN(n,{select:e=!1}={}){const t=document.activeElement;for(const r of n)if(qr(r,{select:e}),document.activeElement!==t)return}function AN(n){const e=E1(n),t=T1(e,n),r=T1(e.reverse(),n);return[t,r]}function E1(n){const e=[],t=document.createTreeWalker(n,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(;t.nextNode();)e.push(t.currentNode);return e}function T1(n,e){for(const t of n)if(!MN(t,{upTo:e}))return t}function MN(n,{upTo:e}){if(getComputedStyle(n).visibility==="hidden")return!0;for(;n;){if(e!==void 0&&n===e)return!1;if(getComputedStyle(n).display==="none")return!0;n=n.parentElement}return!1}function ON(n){return n instanceof HTMLInputElement&&"select"in n}function qr(n,{select:e=!1}={}){if(n&&n.focus){const t=document.activeElement;n.focus({preventScroll:!0}),n!==t&&ON(n)&&e&&n.select()}}const A1=_N();function _N(){let n=[];return{add(e){const t=n[0];e!==t&&(t==null||t.pause()),n=M1(n,e),n.unshift(e)},remove(e){var t;n=M1(n,e),(t=n[0])===null||t===void 0||t.resume()}}}function M1(n,e){const t=[...n],r=t.indexOf(e);return r!==-1&&t.splice(r,1),t}function NN(n){return n.filter(e=>e.tagName!=="A")}const Cs=globalThis!=null&&globalThis.document?O.useLayoutEffect:()=>{},DN=le.useId||(()=>{});let RN=0;function LN(n){const[e,t]=le.useState(DN());return Cs(()=>{n||t(r=>r??String(RN++))},[n]),n||(e?`radix-${e}`:"")}const IN=["top","right","bottom","left"],Jn=Math.min,Qt=Math.max,ac=Math.round,cc=Math.floor,Kr=n=>({x:n,y:n}),PN={left:"right",right:"left",bottom:"top",top:"bottom"},FN={start:"end",end:"start"};function Wf(n,e,t){return Qt(n,Jn(e,t))}function mr(n,e){return typeof n=="function"?n(e):n}function gr(n){return n.split("-")[0]}function xs(n){return n.split("-")[1]}function qf(n){return n==="x"?"y":"x"}function Kf(n){return n==="y"?"height":"width"}function ks(n){return["top","bottom"].includes(gr(n))?"y":"x"}function Jf(n){return qf(ks(n))}function BN(n,e,t){t===void 0&&(t=!1);const r=xs(n),i=Jf(n),s=Kf(i);let o=i==="x"?r===(t?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=uc(o)),[o,uc(o)]}function $N(n){const e=uc(n);return[Gf(n),e,Gf(e)]}function Gf(n){return n.replace(/start|end/g,e=>FN[e])}function jN(n,e,t){const r=["left","right"],i=["right","left"],s=["top","bottom"],o=["bottom","top"];switch(n){case"top":case"bottom":return t?e?i:r:e?r:i;case"left":case"right":return e?s:o;default:return[]}}function HN(n,e,t,r){const i=xs(n);let s=jN(gr(n),t==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(Gf)))),s}function uc(n){return n.replace(/left|right|bottom|top/g,e=>PN[e])}function VN(n){return{top:0,right:0,bottom:0,left:0,...n}}function O1(n){return typeof n!="number"?VN(n):{top:n,right:n,bottom:n,left:n}}function dc(n){const{x:e,y:t,width:r,height:i}=n;return{width:r,height:i,top:t,left:e,right:e+r,bottom:t+i,x:e,y:t}}function _1(n,e,t){let{reference:r,floating:i}=n;const s=ks(e),o=Jf(e),l=Kf(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(xs(e)){case"start":h[o]-=f*(t&&c?-1:1);break;case"end":h[o]+=f*(t&&c?-1:1);break}return h}const zN=async(n,e,t)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=t,l=s.filter(Boolean),a=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:n,floating:e,strategy:i}),{x:u,y:d}=_1(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:C,data:y,reset:k}=await w({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:h,rects:c,platform:o,elements:{reference:n,floating:e}});u=S??u,d=C??d,h={...h,[v]:{...h[v],...y}},k&&p<=50&&(p++,typeof k=="object"&&(k.placement&&(f=k.placement),k.rects&&(c=k.rects===!0?await o.getElementRects({reference:n,floating:e,strategy:i}):k.rects),{x:u,y:d}=_1(c,f,a)),g=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:h}};async function Ko(n,e){var t;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:o,elements:l,strategy:a}=n,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:h=0}=mr(e,n),p=O1(h),v=l[f?d==="floating"?"reference":"floating":d],w=dc(await s.getClippingRect({element:(t=await(s.isElement==null?void 0:s.isElement(v)))==null||t?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,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),y=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},k=dc(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:S,offsetParent:C,strategy:a}):S);return{top:(w.top-k.top+p.top)/y.y,bottom:(k.bottom-w.bottom+p.bottom)/y.y,left:(w.left-k.left+p.left)/y.x,right:(k.right-w.right+p.right)/y.x}}const UN=n=>({name:"arrow",options:n,async fn(e){const{x:t,y:r,placement:i,rects:s,platform:o,elements:l,middlewareData:a}=e,{element:c,padding:u=0}=mr(n,e)||{};if(c==null)return{};const d=O1(u),f={x:t,y:r},h=Jf(i),p=Kf(h),g=await o.getDimensions(c),v=h==="y",w=v?"top":"left",S=v?"bottom":"right",C=v?"clientHeight":"clientWidth",y=s.reference[p]+s.reference[h]-f[h]-s.floating[p],k=f[h]-s.reference[h],E=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let T=E?E[C]:0;(!T||!await(o.isElement==null?void 0:o.isElement(E)))&&(T=l.floating[C]||s.floating[p]);const N=y/2-k/2,_=T/2-g[p]/2-1,A=Jn(d[w],_),R=Jn(d[S],_),P=A,$=T-g[p]-R,V=T/2-g[p]/2+N,U=Wf(P,V,$),J=!a.arrow&&xs(i)!=null&&V!==U&&s.reference[p]/2-(V<P?A:R)-g[p]/2<0,G=J?V<P?V-P:V-$:0;return{[h]:f[h]+G,data:{[h]:U,centerOffset:V-U-G,...J&&{alignmentOffset:G}},reset:J}}}),WN=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,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(n,e);if((t=s.arrow)!=null&&t.alignmentOffset)return{};const w=gr(i),S=gr(l)===l,C=await(a.isRTL==null?void 0:a.isRTL(c.floating)),y=f||(S||!g?[uc(l)]:$N(l));!f&&p!=="none"&&y.push(...HN(l,g,p,C));const k=[l,...y],E=await Ko(e,v),T=[];let N=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&T.push(E[w]),d){const P=BN(i,o,C);T.push(E[P[0]],E[P[1]])}if(N=[...N,{placement:i,overflows:T}],!T.every(P=>P<=0)){var _,A;const P=(((_=s.flip)==null?void 0:_.index)||0)+1,$=k[P];if($)return{data:{index:P,overflows:N},reset:{placement:$}};let V=(A=N.filter(U=>U.overflows[0]<=0).sort((U,J)=>U.overflows[1]-J.overflows[1])[0])==null?void 0:A.placement;if(!V)switch(h){case"bestFit":{var R;const U=(R=N.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&&(V=U);break}case"initialPlacement":V=l;break}if(i!==V)return{reset:{placement:V}}}return{}}}};function N1(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function D1(n){return IN.some(e=>n[e]>=0)}const qN=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t}=e,{strategy:r="referenceHidden",...i}=mr(n,e);switch(r){case"referenceHidden":{const s=await Ko(e,{...i,elementContext:"reference"}),o=N1(s,t.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:D1(o)}}}case"escaped":{const s=await Ko(e,{...i,altBoundary:!0}),o=N1(s,t.floating);return{data:{escapedOffsets:o,escaped:D1(o)}}}default:return{}}}}};async function KN(n,e){const{placement:t,platform:r,elements:i}=n,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=gr(t),l=xs(t),a=ks(t)==="y",c=["left","top"].includes(o)?-1:1,u=s&&a?-1:1,d=mr(e,n);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 JN=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,r;const{x:i,y:s,placement:o,middlewareData:l}=e,a=await KN(e,n);return o===((t=l.offset)==null?void 0:t.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+a.x,y:s+a.y,data:{...a,placement:o}}}}},GN=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,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(n,e),c={x:t,y:r},u=await Ko(e,a),d=ks(gr(i)),f=qf(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],C=h-u[w];h=Wf(S,h,C)}if(o){const v=d==="y"?"top":"left",w=d==="y"?"bottom":"right",S=p+u[v],C=p-u[w];p=Wf(S,p,C)}const g=l.fn({...e,[f]:h,[d]:p});return{...g,data:{x:g.x-t,y:g.y-r}}}}},YN=function(n){return n===void 0&&(n={}),{options:n,fn(e){const{x:t,y:r,placement:i,rects:s,middlewareData:o}=e,{offset:l=0,mainAxis:a=!0,crossAxis:c=!0}=mr(n,e),u={x:t,y:r},d=ks(i),f=qf(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 C=f==="y"?"height":"width",y=s.reference[f]-s.floating[C]+v.mainAxis,k=s.reference[f]+s.reference[C]-v.mainAxis;h<y?h=y:h>k&&(h=k)}if(c){var w,S;const C=f==="y"?"width":"height",y=["top","left"].includes(gr(i)),k=s.reference[d]-s.floating[C]+(y&&((w=o.offset)==null?void 0:w[d])||0)+(y?0:v.crossAxis),E=s.reference[d]+s.reference[C]+(y?0:((S=o.offset)==null?void 0:S[d])||0)-(y?v.crossAxis:0);p<k?p=k:p>E&&(p=E)}return{[f]:h,[d]:p}}}},ZN=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(e){const{placement:t,rects:r,platform:i,elements:s}=e,{apply:o=()=>{},...l}=mr(n,e),a=await Ko(e,l),c=gr(t),u=xs(t),d=ks(t)==="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),C=Jn(f-a[g],w),y=!e.middlewareData.shift;let k=S,E=C;if(d?E=u||y?Jn(C,w):w:k=u||y?Jn(S,v):v,y&&!u){const N=Qt(a.left,0),_=Qt(a.right,0),A=Qt(a.top,0),R=Qt(a.bottom,0);d?E=f-2*(N!==0||_!==0?N+_:Qt(a.left,a.right)):k=h-2*(A!==0||R!==0?A+R:Qt(a.top,a.bottom))}await o({...e,availableWidth:E,availableHeight:k});const T=await i.getDimensions(s.floating);return f!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function Ss(n){return R1(n)?(n.nodeName||"").toLowerCase():"#document"}function en(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function yr(n){var e;return(e=(R1(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function R1(n){return n instanceof Node||n instanceof en(n).Node}function Gn(n){return n instanceof Element||n instanceof en(n).Element}function Yn(n){return n instanceof HTMLElement||n instanceof en(n).HTMLElement}function L1(n){return typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof en(n).ShadowRoot}function Jo(n){const{overflow:e,overflowX:t,overflowY:r,display:i}=En(n);return/auto|scroll|overlay|hidden|clip/.test(e+r+t)&&!["inline","contents"].includes(i)}function XN(n){return["table","td","th"].includes(Ss(n))}function Yf(n){const e=Zf(),t=En(n);return t.transform!=="none"||t.perspective!=="none"||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(t.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(t.contain||"").includes(r))}function QN(n){let e=Jr(n);for(;Yn(e)&&!Es(e);){if(Yf(e))return e;e=Jr(e)}return null}function Zf(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Es(n){return["html","body","#document"].includes(Ss(n))}function En(n){return en(n).getComputedStyle(n)}function fc(n){return Gn(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.pageXOffset,scrollTop:n.pageYOffset}}function Jr(n){if(Ss(n)==="html")return n;const e=n.assignedSlot||n.parentNode||L1(n)&&n.host||yr(n);return L1(e)?e.host:e}function I1(n){const e=Jr(n);return Es(e)?n.ownerDocument?n.ownerDocument.body:n.body:Yn(e)&&Jo(e)?e:I1(e)}function Go(n,e,t){var r;e===void 0&&(e=[]),t===void 0&&(t=!0);const i=I1(n),s=i===((r=n.ownerDocument)==null?void 0:r.body),o=en(i);return s?e.concat(o,o.visualViewport||[],Jo(i)?i:[],o.frameElement&&t?Go(o.frameElement):[]):e.concat(i,Go(i,[],t))}function P1(n){const e=En(n);let t=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=Yn(n),s=i?n.offsetWidth:t,o=i?n.offsetHeight:r,l=ac(t)!==s||ac(r)!==o;return l&&(t=s,r=o),{width:t,height:r,$:l}}function Xf(n){return Gn(n)?n:n.contextElement}function Ts(n){const e=Xf(n);if(!Yn(e))return Kr(1);const t=e.getBoundingClientRect(),{width:r,height:i,$:s}=P1(e);let o=(s?ac(t.width):t.width)/r,l=(s?ac(t.height):t.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const eD=Kr(0);function F1(n){const e=en(n);return!Zf()||!e.visualViewport?eD:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function tD(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==en(n)?!1:e}function Oi(n,e,t,r){e===void 0&&(e=!1),t===void 0&&(t=!1);const i=n.getBoundingClientRect(),s=Xf(n);let o=Kr(1);e&&(r?Gn(r)&&(o=Ts(r)):o=Ts(n));const l=tD(s,t,r)?F1(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=Ts(g),w=g.getBoundingClientRect(),S=En(g),C=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+=C,c+=y,p=en(g),g=p.frameElement}}return dc({width:u,height:d,x:a,y:c})}const nD=[":popover-open",":modal"];function Qf(n){return nD.some(e=>{try{return n.matches(e)}catch{return!1}})}function rD(n){let{elements:e,rect:t,offsetParent:r,strategy:i}=n;const s=i==="fixed",o=yr(r),l=e?Qf(e.floating):!1;if(r===o||l&&s)return t;let a={scrollLeft:0,scrollTop:0},c=Kr(1);const u=Kr(0),d=Yn(r);if((d||!d&&!s)&&((Ss(r)!=="body"||Jo(o))&&(a=fc(r)),Yn(r))){const f=Oi(r);c=Ts(r),u.x=f.x+r.clientLeft,u.y=f.y+r.clientTop}return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-a.scrollLeft*c.x+u.x,y:t.y*c.y-a.scrollTop*c.y+u.y}}function iD(n){return Array.from(n.getClientRects())}function B1(n){return Oi(yr(n)).left+fc(n).scrollLeft}function sD(n){const e=yr(n),t=fc(n),r=n.ownerDocument.body,i=Qt(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=Qt(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-t.scrollLeft+B1(n);const l=-t.scrollTop;return En(r).direction==="rtl"&&(o+=Qt(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:l}}function oD(n,e){const t=en(n),r=yr(n),i=t.visualViewport;let s=r.clientWidth,o=r.clientHeight,l=0,a=0;if(i){s=i.width,o=i.height;const c=Zf();(!c||c&&e==="fixed")&&(l=i.offsetLeft,a=i.offsetTop)}return{width:s,height:o,x:l,y:a}}function lD(n,e){const t=Oi(n,!0,e==="fixed"),r=t.top+n.clientTop,i=t.left+n.clientLeft,s=Yn(n)?Ts(n):Kr(1),o=n.clientWidth*s.x,l=n.clientHeight*s.y,a=i*s.x,c=r*s.y;return{width:o,height:l,x:a,y:c}}function $1(n,e,t){let r;if(e==="viewport")r=oD(n,t);else if(e==="document")r=sD(yr(n));else if(Gn(e))r=lD(e,t);else{const i=F1(n);r={...e,x:e.x-i.x,y:e.y-i.y}}return dc(r)}function j1(n,e){const t=Jr(n);return t===e||!Gn(t)||Es(t)?!1:En(t).position==="fixed"||j1(t,e)}function aD(n,e){const t=e.get(n);if(t)return t;let r=Go(n,[],!1).filter(l=>Gn(l)&&Ss(l)!=="body"),i=null;const s=En(n).position==="fixed";let o=s?Jr(n):n;for(;Gn(o)&&!Es(o);){const l=En(o),a=Yf(o);!a&&l.position==="fixed"&&(i=null),(s?!a&&!i:!a&&l.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||Jo(o)&&!a&&j1(n,o))?r=r.filter(u=>u!==o):i=l,o=Jr(o)}return e.set(n,r),r}function cD(n){let{element:e,boundary:t,rootBoundary:r,strategy:i}=n;const o=[...t==="clippingAncestors"?Qf(e)?[]:aD(e,this._c):[].concat(t),r],l=o[0],a=o.reduce((c,u)=>{const d=$1(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},$1(e,l,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function uD(n){const{width:e,height:t}=P1(n);return{width:e,height:t}}function dD(n,e,t){const r=Yn(e),i=yr(e),s=t==="fixed",o=Oi(n,!0,s,e);let l={scrollLeft:0,scrollTop:0};const a=Kr(0);if(r||!r&&!s)if((Ss(e)!=="body"||Jo(i))&&(l=fc(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=B1(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 eh(n){return En(n).position==="static"}function H1(n,e){return!Yn(n)||En(n).position==="fixed"?null:e?e(n):n.offsetParent}function V1(n,e){const t=en(n);if(Qf(n))return t;if(!Yn(n)){let i=Jr(n);for(;i&&!Es(i);){if(Gn(i)&&!eh(i))return i;i=Jr(i)}return t}let r=H1(n,e);for(;r&&XN(r)&&eh(r);)r=H1(r,e);return r&&Es(r)&&eh(r)&&!Yf(r)?t:r||QN(n)||t}const fD=async function(n){const e=this.getOffsetParent||V1,t=this.getDimensions,r=await t(n.floating);return{reference:dD(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function hD(n){return En(n).direction==="rtl"}const pD={convertOffsetParentRelativeRectToViewportRelativeRect:rD,getDocumentElement:yr,getClippingRect:cD,getOffsetParent:V1,getElementRects:fD,getClientRects:iD,getDimensions:uD,getScale:Ts,isElement:Gn,isRTL:hD};function mD(n,e){let t=null,r;const i=yr(n);function s(){var l;clearTimeout(r),(l=t)==null||l.disconnect(),t=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}=n.getBoundingClientRect();if(l||e(),!d||!f)return;const h=cc(u),p=cc(i.clientWidth-(c+d)),g=cc(i.clientHeight-(u+f)),v=cc(c),S={rootMargin:-h+"px "+-p+"px "+-g+"px "+-v+"px",threshold:Qt(0,Jn(1,a))||1};let C=!0;function y(k){const E=k[0].intersectionRatio;if(E!==a){if(!C)return o();E?o(!1,E):r=setTimeout(()=>{o(!1,1e-7)},1e3)}C=!1}try{t=new IntersectionObserver(y,{...S,root:i.ownerDocument})}catch{t=new IntersectionObserver(y,S)}t.observe(n)}return o(!0),s}function gD(n,e,t,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=Xf(n),u=i||s?[...c?Go(c):[],...Go(e)]:[];u.forEach(w=>{i&&w.addEventListener("scroll",t,{passive:!0}),s&&w.addEventListener("resize",t)});const d=c&&l?mD(c,t):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 C;(C=h)==null||C.observe(e)})),t()}),c&&!a&&h.observe(c),h.observe(e));let p,g=a?Oi(n):null;a&&v();function v(){const w=Oi(n);g&&(w.x!==g.x||w.y!==g.y||w.width!==g.width||w.height!==g.height)&&t(),g=w,p=requestAnimationFrame(v)}return t(),()=>{var w;u.forEach(S=>{i&&S.removeEventListener("scroll",t),s&&S.removeEventListener("resize",t)}),d==null||d(),(w=h)==null||w.disconnect(),h=null,a&&cancelAnimationFrame(p)}}const yD=JN,bD=GN,vD=WN,wD=ZN,CD=qN,z1=UN,xD=YN,kD=(n,e,t)=>{const r=new Map,i={platform:pD,...t},s={...i.platform,_c:r};return zN(n,e,{...i,platform:s})};var hc=typeof document<"u"?O.useLayoutEffect:O.useEffect;function pc(n,e){if(n===e)return!0;if(typeof n!=typeof e)return!1;if(typeof n=="function"&&n.toString()===e.toString())return!0;let t,r,i;if(n&&e&&typeof n=="object"){if(Array.isArray(n)){if(t=n.length,t!==e.length)return!1;for(r=t;r--!==0;)if(!pc(n[r],e[r]))return!1;return!0}if(i=Object.keys(n),t=i.length,t!==Object.keys(e).length)return!1;for(r=t;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=t;r--!==0;){const s=i[r];if(!(s==="_owner"&&n.$$typeof)&&!pc(n[s],e[s]))return!1}return!0}return n!==n&&e!==e}function U1(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function W1(n,e){const t=U1(n);return Math.round(e*t)/t}function q1(n){const e=le.useRef(n);return hc(()=>{e.current=n}),e}function SD(n){n===void 0&&(n={});const{placement:e="bottom",strategy:t="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:l=!0,whileElementsMounted:a,open:c}=n,[u,d]=le.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[f,h]=le.useState(r);pc(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))},[]),C=le.useCallback(G=>{G!==T.current&&(T.current=G,w(G))},[]),y=s||p,k=o||v,E=le.useRef(null),T=le.useRef(null),N=le.useRef(u),_=a!=null,A=q1(a),R=q1(i),P=le.useCallback(()=>{if(!E.current||!T.current)return;const G={placement:e,strategy:t,middleware:f};R.current&&(G.platform=R.current),kD(E.current,T.current,G).then(ie=>{const X={...ie,isPositioned:!0};$.current&&!pc(N.current,X)&&(N.current=X,ew.flushSync(()=>{d(X)}))})},[f,e,t,R]);hc(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,d(G=>({...G,isPositioned:!1})))},[c]);const $=le.useRef(!1);hc(()=>($.current=!0,()=>{$.current=!1}),[]),hc(()=>{if(y&&(E.current=y),k&&(T.current=k),y&&k){if(A.current)return A.current(y,k,P);P()}},[y,k,P,A,_]);const V=le.useMemo(()=>({reference:E,floating:T,setReference:S,setFloating:C}),[S,C]),U=le.useMemo(()=>({reference:y,floating:k}),[y,k]),J=le.useMemo(()=>{const G={position:t,left:0,top:0};if(!U.floating)return G;const ie=W1(U.floating,u.x),X=W1(U.floating,u.y);return l?{...G,transform:"translate("+ie+"px, "+X+"px)",...U1(U.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:ie,top:X}},[t,l,U.floating,u.x,u.y]);return le.useMemo(()=>({...u,update:P,refs:V,elements:U,floatingStyles:J}),[u,P,V,U,J])}const ED=n=>{function e(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:n,fn(t){const{element:r,padding:i}=typeof n=="function"?n(t):n;return r&&e(r)?r.current!=null?z1({element:r.current,padding:i}).fn(t):{}:r?z1({element:r,padding:i}).fn(t):{}}}},TD=(n,e)=>({...yD(n),options:[n,e]}),AD=(n,e)=>({...bD(n),options:[n,e]}),MD=(n,e)=>({...xD(n),options:[n,e]}),OD=(n,e)=>({...vD(n),options:[n,e]}),_D=(n,e)=>({...wD(n),options:[n,e]}),ND=(n,e)=>({...CD(n),options:[n,e]}),DD=(n,e)=>({...ED(n),options:[n,e]}),RD=O.forwardRef((n,e)=>{const{children:t,width:r=10,height:i=5,...s}=n;return O.createElement(Mi.svg,dt({},s,{ref:e,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none"}),n.asChild?t:O.createElement("polygon",{points:"0,0 30,0 15,10"}))});function LD(n){const[e,t]=O.useState(void 0);return Cs(()=>{if(n){t({width:n.offsetWidth,height:n.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=n.offsetWidth,l=n.offsetHeight;t({width:o,height:l})});return r.observe(n,{box:"border-box"}),()=>r.unobserve(n)}else t(void 0)},[n]),e}const K1="Popper",[J1,G1]=v1(K1),[ID,Y1]=J1(K1),PD=n=>{const{__scopePopper:e,children:t}=n,[r,i]=O.useState(null);return O.createElement(ID,{scope:e,anchor:r,onAnchorChange:i},t)},FD="PopperAnchor",BD=O.forwardRef((n,e)=>{const{__scopePopper:t,virtualRef:r,...i}=n,s=Y1(FD,t),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}))}),Z1="PopperContent",[$D,jD]=J1(Z1),HD=O.forwardRef((n,e)=>{var t,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:C="partial",hideWhenDetached:y=!1,updatePositionStrategy:k="optimized",onPlaced:E,...T}=n,N=Y1(Z1,u),[_,A]=O.useState(null),R=Ai(e,B=>A(B)),[P,$]=O.useState(null),V=LD(P),U=(t=V==null?void 0:V.width)!==null&&t!==void 0?t:0,J=(r=V==null?void 0:V.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},X=Array.isArray(w)?w:[w],we=X.length>0,Re={padding:ie,boundary:X.filter(UD),altBoundary:we},{refs:Pe,floatingStyles:xe,placement:ye,isPositioned:_e,middlewareData:Le}=SD({strategy:"fixed",placement:G,whileElementsMounted:(...B)=>gD(...B,{animationFrame:k==="always"}),elements:{reference:N.anchor},middleware:[TD({mainAxis:f+J,alignmentAxis:p}),v&&AD({mainAxis:!0,crossAxis:!1,limiter:C==="partial"?MD():void 0,...Re}),v&&OD({...Re}),_D({...Re,apply:({elements:B,rects:j,availableWidth:q,availableHeight:te})=>{const{width:M,height:m}=j.reference,b=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&&DD({element:P,padding:g}),WD({arrowWidth:U,arrowHeight:J}),y&&ND({strategy:"referenceHidden",...Re})]}),[tt,nt]=Q1(ye),Ge=Wr(E);Cs(()=>{_e&&(Ge==null||Ge())},[_e,Ge]);const Ye=(i=Le.arrow)===null||i===void 0?void 0:i.x,Ot=(s=Le.arrow)===null||s===void 0?void 0:s.y,Ct=((o=Le.arrow)===null||o===void 0?void 0:o.centerOffset)!==0,[it,at]=O.useState();return Cs(()=>{_&&at(window.getComputedStyle(_).zIndex)},[_]),O.createElement("div",{ref:Pe.setFloating,"data-radix-popper-content-wrapper":"",style:{...xe,transform:_e?xe.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:it,"--radix-popper-transform-origin":[(l=Le.transformOrigin)===null||l===void 0?void 0:l.x,(a=Le.transformOrigin)===null||a===void 0?void 0:a.y].join(" ")},dir:n.dir},O.createElement($D,{scope:u,placedSide:tt,onArrowChange:$,arrowX:Ye,arrowY:Ot,shouldHideArrow:Ct},O.createElement(Mi.div,dt({"data-side":tt,"data-align":nt},T,{ref:R,style:{...T.style,animation:_e?void 0:"none",opacity:(c=Le.hide)!==null&&c!==void 0&&c.referenceHidden?0:void 0}}))))}),X1="PopperArrow",VD={top:"bottom",right:"left",bottom:"top",left:"right"},zD=O.forwardRef(function(e,t){const{__scopePopper:r,...i}=e,s=jD(X1,r),o=VD[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(RD,dt({},i,{ref:t,style:{...i.style,display:"block"}})))});function UD(n){return n!==null}const WD=n=>({name:"transformOrigin",options:n,fn(e){var t,r,i,s,o;const{placement:l,rects:a,middlewareData:c}=e,d=((t=c.arrow)===null||t===void 0?void 0:t.centerOffset)!==0,f=d?0:n.arrowWidth,h=d?0:n.arrowHeight,[p,g]=Q1(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 C="",y="";return p==="bottom"?(C=d?v:`${w}px`,y=`${-h}px`):p==="top"?(C=d?v:`${w}px`,y=`${a.floating.height+h}px`):p==="right"?(C=`${-h}px`,y=d?v:`${S}px`):p==="left"&&(C=`${a.floating.width+h}px`,y=d?v:`${S}px`),{data:{x:C,y}}}});function Q1(n){const[e,t="center"]=n.split("-");return[e,t]}const qD=PD,KD=BD,JD=HD;function GD(n,e){return O.useReducer((t,r)=>{const i=e[t][r];return i??t},n)}const ev=n=>{const{present:e,children:t}=n,r=YD(e),i=typeof t=="function"?t({present:r.isPresent}):O.Children.only(t),s=Ai(r.ref,i.ref);return typeof t=="function"||r.isPresent?O.cloneElement(i,{ref:s}):null};ev.displayName="Presence";function YD(n){const[e,t]=O.useState(),r=O.useRef({}),i=O.useRef(n),s=O.useRef("none"),o=n?"mounted":"unmounted",[l,a]=GD(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return O.useEffect(()=>{const c=mc(r.current);s.current=l==="mounted"?c:"none"},[l]),Cs(()=>{const c=r.current,u=i.current;if(u!==n){const f=s.current,h=mc(c);n?a("MOUNT"):h==="none"||(c==null?void 0:c.display)==="none"?a("UNMOUNT"):a(u&&f!==h?"ANIMATION_OUT":"UNMOUNT"),i.current=n}},[n,a]),Cs(()=>{if(e){const c=d=>{const h=mc(r.current).includes(d.animationName);d.target===e&&h&&nn.flushSync(()=>a("ANIMATION_END"))},u=d=>{d.target===e&&(s.current=mc(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)),t(c)},[])}}function mc(n){return(n==null?void 0:n.animationName)||"none"}function ZD({prop:n,defaultProp:e,onChange:t=()=>{}}){const[r,i]=XD({defaultProp:e,onChange:t}),s=n!==void 0,o=s?n:r,l=Wr(t),a=O.useCallback(c=>{if(s){const d=typeof c=="function"?c(n):c;d!==n&&l(d)}else i(c)},[s,n,i,l]);return[o,a]}function XD({defaultProp:n,onChange:e}){const t=O.useState(n),[r]=t,i=O.useRef(r),s=Wr(e);return O.useEffect(()=>{i.current!==r&&(s(r),i.current=r)},[r,i,s]),t}var QD=function(n){if(typeof document>"u")return null;var e=Array.isArray(n)?n[0]:n;return e.ownerDocument.body},As=new WeakMap,gc=new WeakMap,yc={},th=0,tv=function(n){return n&&(n.host||tv(n.parentNode))},eR=function(n,e){return e.map(function(t){if(n.contains(t))return t;var r=tv(t);return r&&n.contains(r)?r:(console.error("aria-hidden",t,"in not contained inside",n,". Doing nothing"),null)}).filter(function(t){return!!t})},tR=function(n,e,t,r){var i=eR(e,Array.isArray(n)?n:[n]);yc[t]||(yc[t]=new WeakMap);var s=yc[t],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=(As.get(f)||0)+1,v=(s.get(f)||0)+1;As.set(f,g),s.set(f,v),o.push(f),g===1&&p&&gc.set(f,!0),v===1&&f.setAttribute(t,"true"),p||f.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",f,w)}})};return u(e),l.clear(),th++,function(){o.forEach(function(d){var f=As.get(d)-1,h=s.get(d)-1;As.set(d,f),s.set(d,h),f||(gc.has(d)||d.removeAttribute(r),gc.delete(d)),h||d.removeAttribute(t)}),th--,th||(As=new WeakMap,As=new WeakMap,gc=new WeakMap,yc={})}},nR=function(n,e,t){t===void 0&&(t="data-aria-hidden");var r=Array.from(Array.isArray(n)?n:[n]),i=QD(n);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live]"))),tR(r,i,t,"aria-hidden")):function(){return null}},Zn=function(){return Zn=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++){t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},Zn.apply(this,arguments)};function nv(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t}function rR(n,e,t){if(t||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 n.concat(s||Array.prototype.slice.call(e))}typeof SuppressedError=="function"&&SuppressedError;var bc="right-scroll-bar-position",vc="width-before-scroll-bar",iR="with-scroll-bars-hidden",sR="--removed-body-scroll-bar-size";function nh(n,e){return typeof n=="function"?n(e):n&&(n.current=e),n}function oR(n,e){var t=O.useState(function(){return{value:n,callback:e,facade:{get current(){return t.value},set current(r){var i=t.value;i!==r&&(t.value=r,t.callback(r,i))}}}})[0];return t.callback=e,t.facade}var lR=typeof window<"u"?le.useLayoutEffect:le.useEffect,rv=new WeakMap;function aR(n,e){var t=oR(null,function(r){return n.forEach(function(i){return nh(i,r)})});return lR(function(){var r=rv.get(t);if(r){var i=new Set(r),s=new Set(n),o=t.current;i.forEach(function(l){s.has(l)||nh(l,null)}),s.forEach(function(l){i.has(l)||nh(l,o)})}rv.set(t,n)},[n]),t}function cR(n){return n}function uR(n,e){e===void 0&&(e=cR);var t=[],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 t.length?t[t.length-1]:n},useMedium:function(s){var o=e(s,r);return t.push(o),function(){t=t.filter(function(l){return l!==o})}},assignSyncMedium:function(s){for(r=!0;t.length;){var o=t;t=[],o.forEach(s)}t={push:function(l){return s(l)},filter:function(){return t}}},assignMedium:function(s){r=!0;var o=[];if(t.length){var l=t;t=[],l.forEach(s),o=t}var a=function(){var u=o;o=[],u.forEach(s)},c=function(){return Promise.resolve().then(a)};c(),t={push:function(u){o.push(u),c()},filter:function(u){return o=o.filter(u),t}}}};return i}function dR(n){n===void 0&&(n={});var e=uR(null);return e.options=Zn({async:!0,ssr:!1},n),e}var iv=function(n){var e=n.sideCar,t=nv(n,["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,Zn({},t))};iv.isSideCarExport=!0;function fR(n,e){return n.useMedium(e),iv}var sv=dR(),rh=function(){},wc=le.forwardRef(function(n,e){var t=le.useRef(null),r=le.useState({onScrollCapture:rh,onWheelCapture:rh,onTouchMoveCapture:rh}),i=r[0],s=r[1],o=n.forwardProps,l=n.children,a=n.className,c=n.removeScrollBar,u=n.enabled,d=n.shards,f=n.sideCar,h=n.noIsolation,p=n.inert,g=n.allowPinchZoom,v=n.as,w=v===void 0?"div":v,S=nv(n,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as"]),C=f,y=aR([t,e]),k=Zn(Zn({},S),i);return le.createElement(le.Fragment,null,u&&le.createElement(C,{sideCar:sv,removeScrollBar:c,shards:d,noIsolation:h,inert:p,setCallbacks:s,allowPinchZoom:!!g,lockRef:t}),o?le.cloneElement(le.Children.only(l),Zn(Zn({},k),{ref:y})):le.createElement(w,Zn({},k,{className:a,ref:y}),l))});wc.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},wc.classNames={fullWidth:vc,zeroRight:bc};var hR=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function pR(){if(!document)return null;var n=document.createElement("style");n.type="text/css";var e=hR();return e&&n.setAttribute("nonce",e),n}function mR(n,e){n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}function gR(n){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(n)}var yR=function(){var n=0,e=null;return{add:function(t){n==0&&(e=pR())&&(mR(e,t),gR(e)),n++},remove:function(){n--,!n&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},bR=function(){var n=yR();return function(e,t){le.useEffect(function(){return n.add(e),function(){n.remove()}},[e&&t])}},ov=function(){var n=bR(),e=function(t){var r=t.styles,i=t.dynamic;return n(r,i),null};return e},vR={left:0,top:0,right:0,gap:0},ih=function(n){return parseInt(n||"",10)||0},wR=function(n){var e=window.getComputedStyle(document.body),t=e[n==="padding"?"paddingLeft":"marginLeft"],r=e[n==="padding"?"paddingTop":"marginTop"],i=e[n==="padding"?"paddingRight":"marginRight"];return[ih(t),ih(r),ih(i)]},CR=function(n){if(n===void 0&&(n="margin"),typeof window>"u")return vR;var e=wR(n),t=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-t+e[2]-e[0])}},xR=ov(),Ms="data-scroll-locked",kR=function(n,e,t,r){var i=n.left,s=n.top,o=n.right,l=n.gap;return t===void 0&&(t="margin"),`
319
- .`.concat(iR,` {
333
+ 3. "-" cannot repeat`);Je.customSchemes.push([n,e])}function D_(){Je.scanner=k_(Je.customSchemes);for(let n=0;n<Je.tokenQueue.length;n++)Je.tokenQueue[n][1]({scanner:Je.scanner});Je.parser=A_(Je.scanner.tokens);for(let n=0;n<Je.pluginQueue.length;n++)Je.pluginQueue[n][1]({scanner:Je.scanner,parser:Je.parser});Je.initialized=!0}function h1(n){return Je.initialized||D_(),M_(Je.parser.start,n,S_(Je.scanner.start,n))}function p1(n,e,t){if(e===void 0&&(e=null),t===void 0&&(t=null),e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new Pf(t),i=h1(n),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 R_(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function L_(n){return new je({key:new We("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,l=yk(t.doc,[...e]);if(Ek(l).forEach(({newRange:c})=>{const u=vk(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=h1(p).map(w=>w.toObject());if(!R_(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=>n.validate?n.validate(w.value):!0).forEach(w=>{Iu(w.from,w.to,r.doc).some(S=>S.mark.type===n.type)||o.addMark(w.from,w.to,n.type.create({href:w.href}))})}}),!!o.steps.length)return o}})}function I_(n){return new je({key:new We("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,s;if(n.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=Zm(e.state,n.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 P_(n){return new je({key:new We("handlePasteLink"),props:{handlePaste:(e,t,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=p1(l).find(c=>c.isLink&&c.value===l);return!l||!a?!1:(n.editor.commands.setMark(n.type,{href:a.href}),!0)}}})}const F_=jt.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(n=>{if(typeof n=="string"){f1(n);return}f1(n.scheme,n.optionalSlashes)})},onDestroy(){N_()},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:n}){var e;return!((e=n.href)===null||e===void 0)&&e.startsWith("javascript:")?["a",xe(this.options.HTMLAttributes,{...n,href:""}),0]:["a",xe(this.options.HTMLAttributes,n),0]},addCommands(){return{setLink:n=>({chain:e})=>e().setMark(this.name,n).setMeta("preventAutolink",!0).run(),toggleLink:n=>({chain:e})=>e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[Rr({find:n=>{const e=[];if(n){const t=p1(n).filter(r=>r.isLink);t.length&&t.forEach(r=>e.push({text:r.value,data:{href:r.href},index:r.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[];return this.options.autolink&&n.push(L_({type:this.type,validate:this.options.validate})),this.options.openOnClick&&n.push(I_({type:this.type,whenNotEditable:this.options.openOnClick==="whenNotEditable"})),this.options.linkOnPaste&&n.push(P_({editor:this.editor,type:this.type})),n}}),B_=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:n,selection:e})=>{var t;const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:i}=e,s=[];if(!r)return null;const{firstChild:o}=n.content,l=o&&o.type.isLeaf,a=o&&o.isAtom,c=this.options.considerAnyAsEmpty?!0:o&&o.type.name===((t=n.type.contentMatch.defaultType)===null||t===void 0?void 0:t.name),u=n.content.childCount<=1&&o&&c&&o.nodeSize<=2&&(!l||!a);return n.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(n,s)}}})]}}),$_=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,j_=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,H_=jt.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",xe(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[ai({find:$_,type:this.type})]},addPasteRules(){return[Rr({find:j_,type:this.type})]}}),V_=Ve.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:n}){return["ul",xe(this.options.HTMLAttributes,n,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:n})=>n.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}}),z_=/^\s*(\[([( |x])?\])\s$/,U_=Ve.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:n=>n.getAttribute("data-checked")==="true",renderHTML:n=>({"data-checked":n.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:n,HTMLAttributes:e}){return["li",xe(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:n.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const n={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...n,Tab:()=>this.editor.commands.sinkListItem(this.name)}:n},addNodeView(){return({node:n,HTMLAttributes:e,getPos:t,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 t=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:d})=>{const f=t(),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(n,u)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([c,u])=>{i.setAttribute(c,u)}),i.dataset.checked=n.attrs.checked,n.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[Ji({find:z_,type:this.type,getAttributes:n=>({checked:n[n.length-1]==="x"})})]}}),W_=jt.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",xe(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});function q_(n){var e;const{char:t,allowSpaces:r,allowedPrefixes:i,startOfLine:s,$position:o}=n,l=Gk(t),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(t.length),text:h[0]}:null}const K_=new We("suggestion");function J_({pluginKey:n=K_,editor:e,char:t="@",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=q_}){let h;const p=u==null?void 0:u(),g=new je({key:n,view(){return{update:async(v,w)=>{var S,x,y,k,E,T,N;const _=(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=_.active&&A.active&&_.range.from!==A.range.from,P=!_.active&&A.active,$=_.active&&!A.active,V=!P&&!$&&_.query!==A.query,U=P||R,J=V&&!R,G=$||R;if(!U&&!J&&!G)return;const ie=G&&!U?_:A,X=v.dom.querySelector(`[data-decoration-id="${ie.decorationId}"]`);h={editor:e,range:ie.range,query:ie.query,text:ie.text,items:[],command:we=>a({editor:e,range:ie.range,props:we}),decorationNode:X,clientRect:X?()=>{var we;const{decorationId:Re}=(we=this.key)===null||we===void 0?void 0:we.getState(e.state),Pe=v.dom.querySelector(`[data-decoration-id="${Re}"]`);return(Pe==null?void 0:Pe.getBoundingClientRect())||null}:null},U&&((y=p==null?void 0:p.onBeforeStart)===null||y===void 0||y.call(p,h)),J&&((k=p==null?void 0:p.onBeforeUpdate)===null||k===void 0||k.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&&((N=p==null?void 0:p.onStart)===null||N===void 0||N.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:k}=e.view,{selection:E}=v,{empty:T,from:N}=E,_={...w};if(_.composing=k,y&&(T||e.view.composing)){(N<w.range.from||N>w.range.to)&&!k&&!w.composing&&(_.active=!1);const A=f({char:t,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})?(_.active=!0,_.decorationId=w.decorationId?w.decorationId:R,_.range=A.range,_.query=A.query,_.text=A.text):_.active=!1}else _.active=!1;return _.active||(_.decorationId=null,_.range={from:0,to:0},_.query=null,_.text=null),_}},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 G_=Ue.create({name:"slash-command",addOptions(){return{suggestion:{char:"/",command:({editor:n,range:e,props:t})=>{t.command({editor:n,range:e})}}}},addProseMirrorPlugins(){return[J_({editor:this.editor,...this.options.suggestion})]}}),Y_=({query:n})=>[{title:"Text",description:"Just start typing with plain text.",searchTerms:["p","paragraph"],icon:D.jsx(d0,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").run()}},{title:"To-do List",description:"Track tasks with a to-do list.",searchTerms:["todo","task","list","check","checkbox"],icon:D.jsx(c0,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleTaskList().run()}},{title:"Heading 1",description:"Big section heading.",searchTerms:["title","big","large"],icon:D.jsx(o0,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:1}).run()}},{title:"Heading 2",description:"Medium section heading.",searchTerms:["subtitle","medium"],icon:D.jsx(l0,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:2}).run()}},{title:"Heading 3",description:"Small section heading.",searchTerms:["subtitle","small"],icon:D.jsx(a0,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setNode("heading",{level:3}).run()}},{title:"Bullet List",description:"Create a simple bullet list.",searchTerms:["unordered","point"],icon:D.jsx(XE,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleBulletList().run()}},{title:"Numbered List",description:"Create a list with numbering.",searchTerms:["ordered"],icon:D.jsx(sd,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).toggleOrderedList().run()}},{title:"Divider",description:"Visually divide content.",searchTerms:["hr","divider","break","line","delimiter"],icon:D.jsx(QE,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setHorizontalRule().run()}},{title:"Quote",description:"Capture a quote.",searchTerms:["blockquote"],icon:D.jsx(u0,{size:18}),image:"",command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).toggleNode("paragraph","paragraph").toggleBlockquote().run()},{title:"Code",description:"Capture a code snippet.",searchTerms:["codeblock"],icon:D.jsx(i0,{size:18}),image:"",command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).toggleCodeBlock().run()},{title:"Table",description:"Create a table.",searchTerms:["table"],icon:D.jsx(lT,{size:18}),image:"",command:({editor:e,range:t})=>e.chain().focus().deleteRange(t).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{title:"Image",description:"Upload an image from your computer.",searchTerms:["photo","picture","media"],icon:D.jsx(ZE,{size:18}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).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;y0(s,e.view,o)}},r.click()}},{title:"Video Embed",description:"Embed a video from YouTube, Vimeo, etc.",searchTerms:["iframe","embed","video","youtube"],icon:D.jsx(h0,{}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setActionButton("iframe").run()}},{title:"Twitter",description:"Embed a Twitter tweet.",searchTerms:["embed","twitter","tweet"],icon:D.jsx(f0,{}),image:"",command:({editor:e,range:t})=>{e.chain().focus().deleteRange(t).setActionButton("twitter").run()}},{title:"2 Columns",description:"Create 2 columns of block",searchTerms:["col","column","2","layout"],icon:D.jsx(s0,{}),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:D.jsx(KE,{}),image:"",command:({editor:e})=>{e.chain().focus().setColumns(3).focus(e.state.selection.head-1).run()}}].filter(e=>{if(typeof n=="string"&&n.length>0){const t=n.toLowerCase();return e.title.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||e.searchTerms&&e.searchTerms.some(r=>r.includes(t))}return!0}),Z_=(n,e)=>{const t=n.offsetHeight,r=e?e.offsetHeight:0,i=e.offsetTop,s=i+r;i<n.scrollTop?n.scrollTop-=n.scrollTop-i+5:s>t+n.scrollTop&&(n.scrollTop+=s-t-n.scrollTop+5)},X_=({items:n,command:e,editor:t})=>{const[r,i]=O.useState(0),s=O.useCallback(l=>{const a=n[l];a&&(a.title==="Continue writing"||e(a))},[e,t,n]);O.useEffect(()=>{const l=["ArrowUp","ArrowDown","Enter"],a=c=>{if(l.includes(c.key))return c.preventDefault(),c.key==="ArrowUp"?(i((r+n.length-1)%n.length),!0):c.key==="ArrowDown"?(i((r+1)%n.length),!0):c.key==="Enter"?(s(r),!0):!1};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a)}},[n,r,i,s]),O.useEffect(()=>{i(0)},[n]);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&&Z_(l,a)},[r]),n.length>0?D.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:n.map((l,a)=>D.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:[D.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border border-neutral-200 bg-white",children:l.icon}),D.jsxs("div",{children:[D.jsx("p",{className:"font-medium",children:l.title}),D.jsx("p",{className:"text-xs text-neutral-500",children:l.description})]})]},a))}):null},Q_=()=>{let n=null,e=null;return{onStart:t=>{n=new Jg(X_,{props:t,editor:t.editor}),e=fi("body",{getReferenceClientRect:t.clientRect,appendTo:()=>document.body,content:n.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"})},onUpdate:t=>{n==null||n.updateProps(t),e&&e[0].setProps({getReferenceClientRect:t.clientRect})},onKeyDown:t=>{var r;return t.event.key==="Escape"?(e==null||e[0].hide(),!0):(r=n==null?void 0:n.ref)==null?void 0:r.onKeyDown(t)},onExit:()=>{e==null||e[0].destroy(),n==null||n.destroy()}}},eN=G_.configure({suggestion:{items:Y_,render:Q_}}),tN=Yb.extend({renderHTML(){return["div",xe(this.options.HTMLAttributes,{"data-type":this.name}),["hr"]]}}),nN=Ue.create({name:"columnExtension",addExtensions(){const n=[];return this.options.column!==!1&&n.push(w0),this.options.columns!==!1&&n.push(Vl),n}}),rN=Ue.create({name:"CustomKeymap",addCommands(){return{selectTextWithinNodeBoundaries:()=>({editor:n,commands:e})=>{const{state:t}=n,{tr:r}=t,i=r.selection.$from.start(),s=r.selection.$to.end();return e.setTextSelection({from:i,to:s})}}},addKeyboardShortcuts(){return{"Mod-a":({editor:n})=>{const{state:e}=n,{tr:t}=e,r=t.selection.from,i=t.selection.to,s=t.selection.$from.start(),o=t.selection.$to.end();return r>s||i<o?(n.chain().selectTextWithinNodeBoundaries().run(),!0):!1}}}}),iN=Ue.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:n=>{var e;return(e=n.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}}}}]},addCommands(){return{setColor:n=>({chain:e})=>e().setMark("textStyle",{color:n}).run(),unsetColor:()=>({chain:n})=>n().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),m1=[{tooltip:"Align left",action:n=>n({dataAlign:"start",dataFloat:null}),icon:od,isActive:n=>n.dataAlign==="start"},{tooltip:"Align center",action:n=>n({dataAlign:"center",dataFloat:null}),icon:p0,isActive:n=>n.dataAlign==="center"},{tooltip:"Align right",action:n=>n({dataAlign:"end",dataFloat:null}),icon:m0,isActive:n=>n.dataAlign==="end"},{tooltip:"Delete",icon:"data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%3e%3cpath%20fill='currentColor'%20d='M19%204h-3.5l-1-1h-5l-1%201H5v2h14M6%2019a2%202%200%200%200%202%202h8a2%202%200%200%200%202-2V7H6v12Z'/%3e%3c/svg%3e",delete:n=>n()}];let ws;const g1=({node:n,updateAttributes:e,deleteNode:t})=>{const r=Ul(),[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={};m1.forEach(({tooltip:$,isActive:V})=>{P[$]=!!(V!=null&&V(n.attrs))}),d(P)},v=()=>{const P=document.querySelector(".ProseMirror");if(P&&c(P==null?void 0:P.clientWidth),!!f.current){if(i==="video"){const $=f.current;$.addEventListener("loadeddata",function(){l($.videoWidth/$.videoHeight),E("left",0)})}else if(i==="iframe"){const $=f.current;$.onload=()=>{l($.offsetWidth/$.offsetHeight),E("left",0)}}else f.current.onload=()=>{l(f.current.naturalWidth/f.current.naturalHeight)};setTimeout(()=>g(),200)}},w=P=>{ws=P};O.useEffect(()=>{v()},[]);const S=({width:P,height:$})=>P<200||$<200,x=P=>{setTimeout(()=>T(P))},y=P=>{ws=P.clientX,setTimeout(()=>{document.addEventListener("mousemove",x),document.addEventListener("mouseup",k)}),p(!0)},k=()=>{ws=-1,document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",k),p(!1)},E=(P,$)=>{var J,G;if(!f.current){console.error("Media ref is undefined|null",{resizableImg:f.current});return}const V={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=V.width-Math.abs($):(typeof V.width=="string"&&(V.width=Number(V.width)),U.width=V.width+Math.abs($)),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(ws===-1)return;const{clientX:$}=P,V=ws-$;if(V===0)return;const U=V>0?"left":"right";setTimeout(()=>{E(U,Math.abs(V)),ws=$})},[N,_]=O.useState(),[A,R]=O.useState();return O.useEffect(()=>{s(n.attrs["media-type"]),g(),_(n.attrs.dataFloat),R(n.attrs.dataAlign)},[n.attrs]),D.jsx(bo,{as:"article",className:Fe("media-node-view not-prose transition-all ease-in-out w-full",N&&`f-${n.attrs.dataFloat}`,A&&`justify-${n.attrs.dataAlign}`),children:D.jsxs("div",{className:"w-fit flex relative group transition-all ease-in-out",children:[i==="img"&&D.jsx("img",{src:n.attrs.src,ref:f,className:"rounded-lg",alt:n.attrs.src,width:n.attrs.width,height:n.attrs.height}),i==="video"&&D.jsx("video",{ref:f,className:"rounded-lg",controls:!0,width:n.attrs.width,height:n.attrs.height,children:D.jsx("source",{src:n.attrs.src})}),i==="iframe"&&D.jsx("iframe",{ref:f,className:Fe("rounded-lg max-w-full",h&&"pointer-events-none"),src:n.attrs.src,width:n.attrs.width,height:n.attrs.height}),!r&&D.jsxs(D.Fragment,{children:[D.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:k}),D.jsx("section",{className:"media-control-buttons opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:m1.map(P=>D.jsx("div",{className:"tooltip","data-tip":P.tooltip,children:D.jsx("button",{type:"button",className:Fe("btn rounded-none h-8 px-2",u[P.tooltip]&&"active"),onClick:()=>{var $;return P.tooltip==="Delete"?t():($=P.action)==null?void 0:$.call(P,e)},children:D.jsx("img",{src:P.icon,className:"w-4"})})}))})]})]})})},sN=Ve.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(g1)},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:n}){return["iframe",xe(this.options.HTMLAttributes,n)]},addCommands(){return{setIframe:n=>({tr:e,dispatch:t})=>{const{selection:r}=e,i=this.type.create(n);return t&&e.replaceRangeWith(r.from-1,r.to,i),!0}}}});var oN="https://platform.twitter.com/widgets.js",Bf="createTweet",lN=function(e){var t=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(oN,"twitter-embed",function(){if(!window.twttr){console.error("Failure to load window.twttr, aborting load");return}if(o){if(!window.twttr.widgets[Bf]){console.error("Method "+Bf+" is not present anymore in twttr.widget api");return}window.twttr.widgets[Bf](e.tweetId,t==null?void 0:t.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:t}))};const aN=({node:n,editor:e})=>{const[t,r]=O.useState(!0);return O.useEffect(()=>{e==null||e.chain().focus()},[]),D.jsx(bo,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:D.jsxs("div",{className:"w-full max-w-sm",children:[t&&D.jsx(N0,{width:5,height:5}),D.jsx(lN,{tweetId:n.attrs.tweetId,onLoad:()=>r(!1)})]})})},cN=Ve.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:n}){return["div",xe(this.options.HTMLAttributes,n)]},addNodeView(){return hi(aN)},addCommands(){return{setTweetEmbed:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{tweetId:n.tweetId,align:"center"},content:[]})}}}),uN=n=>new je({key:new We("media-paste-drop"),props:{handlePaste(e,t){var i;return Array.from(((i=t.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)&&(t.preventDefault(),o&&o.size>1024*1024))throw new Error("Image too large")}),!1},handleDrop(e,t){var l;if(!(t.dataTransfer&&t.dataTransfer.files&&t.dataTransfer.files.length))return!1;const i=Array.from(((l=t.dataTransfer)==null?void 0:l.files)??[]).filter(({type:a})=>/image|video/i.test(a));if(i.length===0)return!1;t.preventDefault();const{schema:s}=e.state,o=e.posAtCoords({left:t.clientX,top:t.clientY});return o?(i.forEach(async a=>{const c=new FileReader;if(n){const u=s.nodes.resizableMedia.create({src:await n(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}}}),dN=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,fN=/!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\)/,hN=Ve.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:n=>({src:n.getAttribute("src"),"media-type":"img"})},{tag:"video",getAttrs:n=>({src:n.getAttribute("src"),"media-type":"video"})}]},renderHTML({HTMLAttributes:n}){const{"media-type":e}=n;return e==="img"?["img",xe(this.options.HTMLAttributes,n)]:e==="video"?["video",{controls:"true",style:"width: 100%",...n},["source",n]]:(e||console.error("TiptapMediaExtension-renderHTML method: Media Type not set, going default with image"),["img",xe(this.options.HTMLAttributes,n)])},addCommands(){return{setMedia:n=>({commands:e})=>{const{"media-type":t}=n;return t==="img"?e.insertContent({type:this.name,attrs:n}):t==="video"?e.insertContent({type:this.name,attrs:{...n,controls:"true"}}):(t||console.error("TiptapMediaExtension-setMedia: Media Type not set, going default with image"),e.insertContent({type:this.name,attrs:n}))}}},addNodeView(){return hi(g1)},addKeyboardShortcuts(){return{Enter:({editor:n})=>{const{selection:e}=n.state;if(e.empty)return!1;const t=e.$to.pos;return n.commands.insertContentAt(t,{type:"dBlock",content:[{type:"paragraph"}]})}}},addInputRules(){return[$u({find:dN,type:this.type,getAttributes:n=>{const[,,e,t,r]=n;return{src:t,alt:e,title:r,"media-type":"img"}}}),$u({find:fN,type:this.type,getAttributes:n=>{const[,,e]=n;return{src:e,"media-type":"video"}}})]},addProseMirrorPlugins(){return[uN(this.options.uploadFn),ST()]}});function y1(n,e){let t;return(...i)=>{clearTimeout(t),t=setTimeout(()=>n(...i),e)}}function dt(){return dt=Object.assign?Object.assign.bind():function(n){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},dt.apply(null,arguments)}function Ur(n,e,{checkForDefaultPrevented:t=!0}={}){return function(i){if(n==null||n(i),t===!1||!i.defaultPrevented)return e==null?void 0:e(i)}}function pN(n,e){typeof n=="function"?n(e):n!=null&&(n.current=e)}function b1(...n){return e=>n.forEach(t=>pN(t,e))}function Ai(...n){return O.useCallback(b1(...n),n)}function v1(n,e=[]){let t=[];function r(s,o){const l=O.createContext(o),a=t.length;t=[...t,o];function c(d){const{scope:f,children:h,...p}=d,g=(f==null?void 0:f[n][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[n][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=t.map(o=>O.createContext(o));return function(l){const a=(l==null?void 0:l[n])||s;return O.useMemo(()=>({[`__scope${n}`]:{...l,[n]:a}}),[l,a])}};return i.scopeName=n,[r,mN(i,...e)]}function mN(...n){const e=n[0];if(n.length===1)return e;const t=()=>{const r=n.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 t.scopeName=e.scopeName,t}const $f=O.forwardRef((n,e)=>{const{children:t,...r}=n,i=O.Children.toArray(t),s=i.find(yN);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(jf,dt({},r,{ref:e}),O.isValidElement(o)?O.cloneElement(o,void 0,l):null)}return O.createElement(jf,dt({},r,{ref:e}),t)});$f.displayName="Slot";const jf=O.forwardRef((n,e)=>{const{children:t,...r}=n;return O.isValidElement(t)?O.cloneElement(t,{...bN(r,t.props),ref:e?b1(e,t.ref):t.ref}):O.Children.count(t)>1?O.Children.only(null):null});jf.displayName="SlotClone";const gN=({children:n})=>O.createElement(O.Fragment,null,n);function yN(n){return O.isValidElement(n)&&n.type===gN}function bN(n,e){const t={...e};for(const r in e){const i=n[r],s=e[r];/^on[A-Z]/.test(r)?i&&s?t[r]=(...l)=>{s(...l),i(...l)}:i&&(t[r]=i):r==="style"?t[r]={...i,...s}:r==="className"&&(t[r]=[i,s].filter(Boolean).join(" "))}return{...n,...t}}const Mi=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce((n,e)=>{const t=O.forwardRef((r,i)=>{const{asChild:s,...o}=r,l=s?$f:e;return O.useEffect(()=>{window[Symbol.for("radix-ui")]=!0},[]),O.createElement(l,dt({},o,{ref:i}))});return t.displayName=`Primitive.${e}`,{...n,[e]:t}},{});function vN(n,e){n&&nn.flushSync(()=>n.dispatchEvent(e))}function Wr(n){const e=O.useRef(n);return O.useEffect(()=>{e.current=n}),O.useMemo(()=>(...t)=>{var r;return(r=e.current)===null||r===void 0?void 0:r.call(e,...t)},[])}function wN(n,e=globalThis==null?void 0:globalThis.document){const t=Wr(n);O.useEffect(()=>{const r=i=>{i.key==="Escape"&&t(i)};return e.addEventListener("keydown",r),()=>e.removeEventListener("keydown",r)},[t,e])}const Hf="dismissableLayer.update",xN="dismissableLayer.pointerDownOutside",CN="dismissableLayer.focusOutside";let w1;const kN=O.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),SN=O.forwardRef((n,e)=>{var t;const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:o,onInteractOutside:l,onDismiss:a,...c}=n,u=O.useContext(kN),[d,f]=O.useState(null),h=(t=d==null?void 0:d.ownerDocument)!==null&&t!==void 0?t:globalThis==null?void 0:globalThis.document,[,p]=O.useState({}),g=Ai(e,N=>f(N)),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,k=x>=S,E=EN(N=>{const _=N.target,A=[...u.branches].some(R=>R.contains(_));!k||A||(s==null||s(N),l==null||l(N),N.defaultPrevented||a==null||a())},h),T=TN(N=>{const _=N.target;[...u.branches].some(R=>R.contains(_))||(o==null||o(N),l==null||l(N),N.defaultPrevented||a==null||a())},h);return wN(N=>{x===u.layers.size-1&&(i==null||i(N),!N.defaultPrevented&&a&&(N.preventDefault(),a()))},h),O.useEffect(()=>{if(d)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(w1=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),x1(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=w1)}},[d,h,r,u]),O.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),x1())},[d,u]),O.useEffect(()=>{const N=()=>p({});return document.addEventListener(Hf,N),()=>document.removeEventListener(Hf,N)},[]),O.createElement(Mi.div,dt({},c,{ref:g,style:{pointerEvents:y?k?"auto":"none":void 0,...n.style},onFocusCapture:Ur(n.onFocusCapture,T.onFocusCapture),onBlurCapture:Ur(n.onBlurCapture,T.onBlurCapture),onPointerDownCapture:Ur(n.onPointerDownCapture,E.onPointerDownCapture)}))});function EN(n,e=globalThis==null?void 0:globalThis.document){const t=Wr(n),r=O.useRef(!1),i=O.useRef(()=>{});return O.useEffect(()=>{const s=l=>{if(l.target&&!r.current){let c=function(){C1(xN,t,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,t]),{onPointerDownCapture:()=>r.current=!0}}function TN(n,e=globalThis==null?void 0:globalThis.document){const t=Wr(n),r=O.useRef(!1);return O.useEffect(()=>{const i=s=>{s.target&&!r.current&&C1(CN,t,{originalEvent:s},{discrete:!1})};return e.addEventListener("focusin",i),()=>e.removeEventListener("focusin",i)},[e,t]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function x1(){const n=new CustomEvent(Hf);document.dispatchEvent(n)}function C1(n,e,t,{discrete:r}){const i=t.originalEvent.target,s=new CustomEvent(n,{bubbles:!1,cancelable:!0,detail:t});e&&i.addEventListener(n,e,{once:!0}),r?vN(i,s):i.dispatchEvent(s)}let Vf=0;function AN(){O.useEffect(()=>{var n,e;const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",(n=t[0])!==null&&n!==void 0?n:k1()),document.body.insertAdjacentElement("beforeend",(e=t[1])!==null&&e!==void 0?e:k1()),Vf++,()=>{Vf===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(r=>r.remove()),Vf--}},[])}function k1(){const n=document.createElement("span");return n.setAttribute("data-radix-focus-guard",""),n.tabIndex=0,n.style.cssText="outline: none; opacity: 0; position: fixed; pointer-events: none",n}const zf="focusScope.autoFocusOnMount",Uf="focusScope.autoFocusOnUnmount",S1={bubbles:!1,cancelable:!0},MN=O.forwardRef((n,e)=>{const{loop:t=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...o}=n,[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 k of x)k.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){A1.add(h);const g=document.activeElement;if(!l.contains(g)){const w=new CustomEvent(zf,S1);l.addEventListener(zf,c),l.dispatchEvent(w),w.defaultPrevented||(ON(LN(E1(l)),{select:!0}),document.activeElement===g&&qr(l))}return()=>{l.removeEventListener(zf,c),setTimeout(()=>{const w=new CustomEvent(Uf,S1);l.addEventListener(Uf,u),l.dispatchEvent(w),w.defaultPrevented||qr(g??document.body,{select:!0}),l.removeEventListener(Uf,u),A1.remove(h)},0)}}},[l,c,u,h]);const p=O.useCallback(g=>{if(!t&&!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]=_N(S);x&&y?!g.shiftKey&&w===y?(g.preventDefault(),t&&qr(x,{select:!0})):g.shiftKey&&w===x&&(g.preventDefault(),t&&qr(y,{select:!0})):w===S&&g.preventDefault()}},[t,r,h.paused]);return O.createElement(Mi.div,dt({tabIndex:-1},o,{ref:f,onKeyDown:p}))});function ON(n,{select:e=!1}={}){const t=document.activeElement;for(const r of n)if(qr(r,{select:e}),document.activeElement!==t)return}function _N(n){const e=E1(n),t=T1(e,n),r=T1(e.reverse(),n);return[t,r]}function E1(n){const e=[],t=document.createTreeWalker(n,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(;t.nextNode();)e.push(t.currentNode);return e}function T1(n,e){for(const t of n)if(!NN(t,{upTo:e}))return t}function NN(n,{upTo:e}){if(getComputedStyle(n).visibility==="hidden")return!0;for(;n;){if(e!==void 0&&n===e)return!1;if(getComputedStyle(n).display==="none")return!0;n=n.parentElement}return!1}function DN(n){return n instanceof HTMLInputElement&&"select"in n}function qr(n,{select:e=!1}={}){if(n&&n.focus){const t=document.activeElement;n.focus({preventScroll:!0}),n!==t&&DN(n)&&e&&n.select()}}const A1=RN();function RN(){let n=[];return{add(e){const t=n[0];e!==t&&(t==null||t.pause()),n=M1(n,e),n.unshift(e)},remove(e){var t;n=M1(n,e),(t=n[0])===null||t===void 0||t.resume()}}}function M1(n,e){const t=[...n],r=t.indexOf(e);return r!==-1&&t.splice(r,1),t}function LN(n){return n.filter(e=>e.tagName!=="A")}const xs=globalThis!=null&&globalThis.document?O.useLayoutEffect:()=>{},IN=le.useId||(()=>{});let PN=0;function FN(n){const[e,t]=le.useState(IN());return xs(()=>{n||t(r=>r??String(PN++))},[n]),n||(e?`radix-${e}`:"")}const BN=["top","right","bottom","left"],Jn=Math.min,Qt=Math.max,ac=Math.round,cc=Math.floor,Kr=n=>({x:n,y:n}),$N={left:"right",right:"left",bottom:"top",top:"bottom"},jN={start:"end",end:"start"};function Wf(n,e,t){return Qt(n,Jn(e,t))}function mr(n,e){return typeof n=="function"?n(e):n}function gr(n){return n.split("-")[0]}function Cs(n){return n.split("-")[1]}function qf(n){return n==="x"?"y":"x"}function Kf(n){return n==="y"?"height":"width"}function ks(n){return["top","bottom"].includes(gr(n))?"y":"x"}function Jf(n){return qf(ks(n))}function HN(n,e,t){t===void 0&&(t=!1);const r=Cs(n),i=Jf(n),s=Kf(i);let o=i==="x"?r===(t?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=uc(o)),[o,uc(o)]}function VN(n){const e=uc(n);return[Gf(n),e,Gf(e)]}function Gf(n){return n.replace(/start|end/g,e=>jN[e])}function zN(n,e,t){const r=["left","right"],i=["right","left"],s=["top","bottom"],o=["bottom","top"];switch(n){case"top":case"bottom":return t?e?i:r:e?r:i;case"left":case"right":return e?s:o;default:return[]}}function UN(n,e,t,r){const i=Cs(n);let s=zN(gr(n),t==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(Gf)))),s}function uc(n){return n.replace(/left|right|bottom|top/g,e=>$N[e])}function WN(n){return{top:0,right:0,bottom:0,left:0,...n}}function O1(n){return typeof n!="number"?WN(n):{top:n,right:n,bottom:n,left:n}}function dc(n){const{x:e,y:t,width:r,height:i}=n;return{width:r,height:i,top:t,left:e,right:e+r,bottom:t+i,x:e,y:t}}function _1(n,e,t){let{reference:r,floating:i}=n;const s=ks(e),o=Jf(e),l=Kf(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(Cs(e)){case"start":h[o]-=f*(t&&c?-1:1);break;case"end":h[o]+=f*(t&&c?-1:1);break}return h}const qN=async(n,e,t)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=t,l=s.filter(Boolean),a=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:n,floating:e,strategy:i}),{x:u,y:d}=_1(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:k}=await w({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:h,rects:c,platform:o,elements:{reference:n,floating:e}});u=S??u,d=x??d,h={...h,[v]:{...h[v],...y}},k&&p<=50&&(p++,typeof k=="object"&&(k.placement&&(f=k.placement),k.rects&&(c=k.rects===!0?await o.getElementRects({reference:n,floating:e,strategy:i}):k.rects),{x:u,y:d}=_1(c,f,a)),g=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:h}};async function Ko(n,e){var t;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:o,elements:l,strategy:a}=n,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:h=0}=mr(e,n),p=O1(h),v=l[f?d==="floating"?"reference":"floating":d],w=dc(await s.getClippingRect({element:(t=await(s.isElement==null?void 0:s.isElement(v)))==null||t?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},k=dc(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:S,offsetParent:x,strategy:a}):S);return{top:(w.top-k.top+p.top)/y.y,bottom:(k.bottom-w.bottom+p.bottom)/y.y,left:(w.left-k.left+p.left)/y.x,right:(k.right-w.right+p.right)/y.x}}const KN=n=>({name:"arrow",options:n,async fn(e){const{x:t,y:r,placement:i,rects:s,platform:o,elements:l,middlewareData:a}=e,{element:c,padding:u=0}=mr(n,e)||{};if(c==null)return{};const d=O1(u),f={x:t,y:r},h=Jf(i),p=Kf(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],k=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 N=y/2-k/2,_=T/2-g[p]/2-1,A=Jn(d[w],_),R=Jn(d[S],_),P=A,$=T-g[p]-R,V=T/2-g[p]/2+N,U=Wf(P,V,$),J=!a.arrow&&Cs(i)!=null&&V!==U&&s.reference[p]/2-(V<P?A:R)-g[p]/2<0,G=J?V<P?V-P:V-$:0;return{[h]:f[h]+G,data:{[h]:U,centerOffset:V-U-G,...J&&{alignmentOffset:G}},reset:J}}}),JN=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,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(n,e);if((t=s.arrow)!=null&&t.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?[uc(l)]:VN(l));!f&&p!=="none"&&y.push(...UN(l,g,p,x));const k=[l,...y],E=await Ko(e,v),T=[];let N=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&T.push(E[w]),d){const P=HN(i,o,x);T.push(E[P[0]],E[P[1]])}if(N=[...N,{placement:i,overflows:T}],!T.every(P=>P<=0)){var _,A;const P=(((_=s.flip)==null?void 0:_.index)||0)+1,$=k[P];if($)return{data:{index:P,overflows:N},reset:{placement:$}};let V=(A=N.filter(U=>U.overflows[0]<=0).sort((U,J)=>U.overflows[1]-J.overflows[1])[0])==null?void 0:A.placement;if(!V)switch(h){case"bestFit":{var R;const U=(R=N.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&&(V=U);break}case"initialPlacement":V=l;break}if(i!==V)return{reset:{placement:V}}}return{}}}};function N1(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function D1(n){return BN.some(e=>n[e]>=0)}const GN=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t}=e,{strategy:r="referenceHidden",...i}=mr(n,e);switch(r){case"referenceHidden":{const s=await Ko(e,{...i,elementContext:"reference"}),o=N1(s,t.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:D1(o)}}}case"escaped":{const s=await Ko(e,{...i,altBoundary:!0}),o=N1(s,t.floating);return{data:{escapedOffsets:o,escaped:D1(o)}}}default:return{}}}}};async function YN(n,e){const{placement:t,platform:r,elements:i}=n,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=gr(t),l=Cs(t),a=ks(t)==="y",c=["left","top"].includes(o)?-1:1,u=s&&a?-1:1,d=mr(e,n);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 ZN=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,r;const{x:i,y:s,placement:o,middlewareData:l}=e,a=await YN(e,n);return o===((t=l.offset)==null?void 0:t.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+a.x,y:s+a.y,data:{...a,placement:o}}}}},XN=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,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(n,e),c={x:t,y:r},u=await Ko(e,a),d=ks(gr(i)),f=qf(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=Wf(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=Wf(S,p,x)}const g=l.fn({...e,[f]:h,[d]:p});return{...g,data:{x:g.x-t,y:g.y-r}}}}},QN=function(n){return n===void 0&&(n={}),{options:n,fn(e){const{x:t,y:r,placement:i,rects:s,middlewareData:o}=e,{offset:l=0,mainAxis:a=!0,crossAxis:c=!0}=mr(n,e),u={x:t,y:r},d=ks(i),f=qf(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,k=s.reference[f]+s.reference[x]-v.mainAxis;h<y?h=y:h>k&&(h=k)}if(c){var w,S;const x=f==="y"?"width":"height",y=["top","left"].includes(gr(i)),k=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<k?p=k:p>E&&(p=E)}return{[f]:h,[d]:p}}}},eD=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(e){const{placement:t,rects:r,platform:i,elements:s}=e,{apply:o=()=>{},...l}=mr(n,e),a=await Ko(e,l),c=gr(t),u=Cs(t),d=ks(t)==="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 k=S,E=x;if(d?E=u||y?Jn(x,w):w:k=u||y?Jn(S,v):v,y&&!u){const N=Qt(a.left,0),_=Qt(a.right,0),A=Qt(a.top,0),R=Qt(a.bottom,0);d?E=f-2*(N!==0||_!==0?N+_:Qt(a.left,a.right)):k=h-2*(A!==0||R!==0?A+R:Qt(a.top,a.bottom))}await o({...e,availableWidth:E,availableHeight:k});const T=await i.getDimensions(s.floating);return f!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function Ss(n){return R1(n)?(n.nodeName||"").toLowerCase():"#document"}function en(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function yr(n){var e;return(e=(R1(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function R1(n){return n instanceof Node||n instanceof en(n).Node}function Gn(n){return n instanceof Element||n instanceof en(n).Element}function Yn(n){return n instanceof HTMLElement||n instanceof en(n).HTMLElement}function L1(n){return typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof en(n).ShadowRoot}function Jo(n){const{overflow:e,overflowX:t,overflowY:r,display:i}=En(n);return/auto|scroll|overlay|hidden|clip/.test(e+r+t)&&!["inline","contents"].includes(i)}function tD(n){return["table","td","th"].includes(Ss(n))}function Yf(n){const e=Zf(),t=En(n);return t.transform!=="none"||t.perspective!=="none"||(t.containerType?t.containerType!=="normal":!1)||!e&&(t.backdropFilter?t.backdropFilter!=="none":!1)||!e&&(t.filter?t.filter!=="none":!1)||["transform","perspective","filter"].some(r=>(t.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(t.contain||"").includes(r))}function nD(n){let e=Jr(n);for(;Yn(e)&&!Es(e);){if(Yf(e))return e;e=Jr(e)}return null}function Zf(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Es(n){return["html","body","#document"].includes(Ss(n))}function En(n){return en(n).getComputedStyle(n)}function fc(n){return Gn(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.pageXOffset,scrollTop:n.pageYOffset}}function Jr(n){if(Ss(n)==="html")return n;const e=n.assignedSlot||n.parentNode||L1(n)&&n.host||yr(n);return L1(e)?e.host:e}function I1(n){const e=Jr(n);return Es(e)?n.ownerDocument?n.ownerDocument.body:n.body:Yn(e)&&Jo(e)?e:I1(e)}function Go(n,e,t){var r;e===void 0&&(e=[]),t===void 0&&(t=!0);const i=I1(n),s=i===((r=n.ownerDocument)==null?void 0:r.body),o=en(i);return s?e.concat(o,o.visualViewport||[],Jo(i)?i:[],o.frameElement&&t?Go(o.frameElement):[]):e.concat(i,Go(i,[],t))}function P1(n){const e=En(n);let t=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=Yn(n),s=i?n.offsetWidth:t,o=i?n.offsetHeight:r,l=ac(t)!==s||ac(r)!==o;return l&&(t=s,r=o),{width:t,height:r,$:l}}function Xf(n){return Gn(n)?n:n.contextElement}function Ts(n){const e=Xf(n);if(!Yn(e))return Kr(1);const t=e.getBoundingClientRect(),{width:r,height:i,$:s}=P1(e);let o=(s?ac(t.width):t.width)/r,l=(s?ac(t.height):t.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const rD=Kr(0);function F1(n){const e=en(n);return!Zf()||!e.visualViewport?rD:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function iD(n,e,t){return e===void 0&&(e=!1),!t||e&&t!==en(n)?!1:e}function Oi(n,e,t,r){e===void 0&&(e=!1),t===void 0&&(t=!1);const i=n.getBoundingClientRect(),s=Xf(n);let o=Kr(1);e&&(r?Gn(r)&&(o=Ts(r)):o=Ts(n));const l=iD(s,t,r)?F1(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=Ts(g),w=g.getBoundingClientRect(),S=En(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 dc({width:u,height:d,x:a,y:c})}const sD=[":popover-open",":modal"];function Qf(n){return sD.some(e=>{try{return n.matches(e)}catch{return!1}})}function oD(n){let{elements:e,rect:t,offsetParent:r,strategy:i}=n;const s=i==="fixed",o=yr(r),l=e?Qf(e.floating):!1;if(r===o||l&&s)return t;let a={scrollLeft:0,scrollTop:0},c=Kr(1);const u=Kr(0),d=Yn(r);if((d||!d&&!s)&&((Ss(r)!=="body"||Jo(o))&&(a=fc(r)),Yn(r))){const f=Oi(r);c=Ts(r),u.x=f.x+r.clientLeft,u.y=f.y+r.clientTop}return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-a.scrollLeft*c.x+u.x,y:t.y*c.y-a.scrollTop*c.y+u.y}}function lD(n){return Array.from(n.getClientRects())}function B1(n){return Oi(yr(n)).left+fc(n).scrollLeft}function aD(n){const e=yr(n),t=fc(n),r=n.ownerDocument.body,i=Qt(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=Qt(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-t.scrollLeft+B1(n);const l=-t.scrollTop;return En(r).direction==="rtl"&&(o+=Qt(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:l}}function cD(n,e){const t=en(n),r=yr(n),i=t.visualViewport;let s=r.clientWidth,o=r.clientHeight,l=0,a=0;if(i){s=i.width,o=i.height;const c=Zf();(!c||c&&e==="fixed")&&(l=i.offsetLeft,a=i.offsetTop)}return{width:s,height:o,x:l,y:a}}function uD(n,e){const t=Oi(n,!0,e==="fixed"),r=t.top+n.clientTop,i=t.left+n.clientLeft,s=Yn(n)?Ts(n):Kr(1),o=n.clientWidth*s.x,l=n.clientHeight*s.y,a=i*s.x,c=r*s.y;return{width:o,height:l,x:a,y:c}}function $1(n,e,t){let r;if(e==="viewport")r=cD(n,t);else if(e==="document")r=aD(yr(n));else if(Gn(e))r=uD(e,t);else{const i=F1(n);r={...e,x:e.x-i.x,y:e.y-i.y}}return dc(r)}function j1(n,e){const t=Jr(n);return t===e||!Gn(t)||Es(t)?!1:En(t).position==="fixed"||j1(t,e)}function dD(n,e){const t=e.get(n);if(t)return t;let r=Go(n,[],!1).filter(l=>Gn(l)&&Ss(l)!=="body"),i=null;const s=En(n).position==="fixed";let o=s?Jr(n):n;for(;Gn(o)&&!Es(o);){const l=En(o),a=Yf(o);!a&&l.position==="fixed"&&(i=null),(s?!a&&!i:!a&&l.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||Jo(o)&&!a&&j1(n,o))?r=r.filter(u=>u!==o):i=l,o=Jr(o)}return e.set(n,r),r}function fD(n){let{element:e,boundary:t,rootBoundary:r,strategy:i}=n;const o=[...t==="clippingAncestors"?Qf(e)?[]:dD(e,this._c):[].concat(t),r],l=o[0],a=o.reduce((c,u)=>{const d=$1(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},$1(e,l,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function hD(n){const{width:e,height:t}=P1(n);return{width:e,height:t}}function pD(n,e,t){const r=Yn(e),i=yr(e),s=t==="fixed",o=Oi(n,!0,s,e);let l={scrollLeft:0,scrollTop:0};const a=Kr(0);if(r||!r&&!s)if((Ss(e)!=="body"||Jo(i))&&(l=fc(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=B1(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 eh(n){return En(n).position==="static"}function H1(n,e){return!Yn(n)||En(n).position==="fixed"?null:e?e(n):n.offsetParent}function V1(n,e){const t=en(n);if(Qf(n))return t;if(!Yn(n)){let i=Jr(n);for(;i&&!Es(i);){if(Gn(i)&&!eh(i))return i;i=Jr(i)}return t}let r=H1(n,e);for(;r&&tD(r)&&eh(r);)r=H1(r,e);return r&&Es(r)&&eh(r)&&!Yf(r)?t:r||nD(n)||t}const mD=async function(n){const e=this.getOffsetParent||V1,t=this.getDimensions,r=await t(n.floating);return{reference:pD(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function gD(n){return En(n).direction==="rtl"}const yD={convertOffsetParentRelativeRectToViewportRelativeRect:oD,getDocumentElement:yr,getClippingRect:fD,getOffsetParent:V1,getElementRects:mD,getClientRects:lD,getDimensions:hD,getScale:Ts,isElement:Gn,isRTL:gD};function bD(n,e){let t=null,r;const i=yr(n);function s(){var l;clearTimeout(r),(l=t)==null||l.disconnect(),t=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}=n.getBoundingClientRect();if(l||e(),!d||!f)return;const h=cc(u),p=cc(i.clientWidth-(c+d)),g=cc(i.clientHeight-(u+f)),v=cc(c),S={rootMargin:-h+"px "+-p+"px "+-g+"px "+-v+"px",threshold:Qt(0,Jn(1,a))||1};let x=!0;function y(k){const E=k[0].intersectionRatio;if(E!==a){if(!x)return o();E?o(!1,E):r=setTimeout(()=>{o(!1,1e-7)},1e3)}x=!1}try{t=new IntersectionObserver(y,{...S,root:i.ownerDocument})}catch{t=new IntersectionObserver(y,S)}t.observe(n)}return o(!0),s}function vD(n,e,t,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=Xf(n),u=i||s?[...c?Go(c):[],...Go(e)]:[];u.forEach(w=>{i&&w.addEventListener("scroll",t,{passive:!0}),s&&w.addEventListener("resize",t)});const d=c&&l?bD(c,t):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)})),t()}),c&&!a&&h.observe(c),h.observe(e));let p,g=a?Oi(n):null;a&&v();function v(){const w=Oi(n);g&&(w.x!==g.x||w.y!==g.y||w.width!==g.width||w.height!==g.height)&&t(),g=w,p=requestAnimationFrame(v)}return t(),()=>{var w;u.forEach(S=>{i&&S.removeEventListener("scroll",t),s&&S.removeEventListener("resize",t)}),d==null||d(),(w=h)==null||w.disconnect(),h=null,a&&cancelAnimationFrame(p)}}const wD=ZN,xD=XN,CD=JN,kD=eD,SD=GN,z1=KN,ED=QN,TD=(n,e,t)=>{const r=new Map,i={platform:yD,...t},s={...i.platform,_c:r};return qN(n,e,{...i,platform:s})};var hc=typeof document<"u"?O.useLayoutEffect:O.useEffect;function pc(n,e){if(n===e)return!0;if(typeof n!=typeof e)return!1;if(typeof n=="function"&&n.toString()===e.toString())return!0;let t,r,i;if(n&&e&&typeof n=="object"){if(Array.isArray(n)){if(t=n.length,t!==e.length)return!1;for(r=t;r--!==0;)if(!pc(n[r],e[r]))return!1;return!0}if(i=Object.keys(n),t=i.length,t!==Object.keys(e).length)return!1;for(r=t;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=t;r--!==0;){const s=i[r];if(!(s==="_owner"&&n.$$typeof)&&!pc(n[s],e[s]))return!1}return!0}return n!==n&&e!==e}function U1(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function W1(n,e){const t=U1(n);return Math.round(e*t)/t}function q1(n){const e=le.useRef(n);return hc(()=>{e.current=n}),e}function AD(n){n===void 0&&(n={});const{placement:e="bottom",strategy:t="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:l=!0,whileElementsMounted:a,open:c}=n,[u,d]=le.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[f,h]=le.useState(r);pc(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,k=o||v,E=le.useRef(null),T=le.useRef(null),N=le.useRef(u),_=a!=null,A=q1(a),R=q1(i),P=le.useCallback(()=>{if(!E.current||!T.current)return;const G={placement:e,strategy:t,middleware:f};R.current&&(G.platform=R.current),TD(E.current,T.current,G).then(ie=>{const X={...ie,isPositioned:!0};$.current&&!pc(N.current,X)&&(N.current=X,ew.flushSync(()=>{d(X)}))})},[f,e,t,R]);hc(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,d(G=>({...G,isPositioned:!1})))},[c]);const $=le.useRef(!1);hc(()=>($.current=!0,()=>{$.current=!1}),[]),hc(()=>{if(y&&(E.current=y),k&&(T.current=k),y&&k){if(A.current)return A.current(y,k,P);P()}},[y,k,P,A,_]);const V=le.useMemo(()=>({reference:E,floating:T,setReference:S,setFloating:x}),[S,x]),U=le.useMemo(()=>({reference:y,floating:k}),[y,k]),J=le.useMemo(()=>{const G={position:t,left:0,top:0};if(!U.floating)return G;const ie=W1(U.floating,u.x),X=W1(U.floating,u.y);return l?{...G,transform:"translate("+ie+"px, "+X+"px)",...U1(U.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:ie,top:X}},[t,l,U.floating,u.x,u.y]);return le.useMemo(()=>({...u,update:P,refs:V,elements:U,floatingStyles:J}),[u,P,V,U,J])}const MD=n=>{function e(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:n,fn(t){const{element:r,padding:i}=typeof n=="function"?n(t):n;return r&&e(r)?r.current!=null?z1({element:r.current,padding:i}).fn(t):{}:r?z1({element:r,padding:i}).fn(t):{}}}},OD=(n,e)=>({...wD(n),options:[n,e]}),_D=(n,e)=>({...xD(n),options:[n,e]}),ND=(n,e)=>({...ED(n),options:[n,e]}),DD=(n,e)=>({...CD(n),options:[n,e]}),RD=(n,e)=>({...kD(n),options:[n,e]}),LD=(n,e)=>({...SD(n),options:[n,e]}),ID=(n,e)=>({...MD(n),options:[n,e]}),PD=O.forwardRef((n,e)=>{const{children:t,width:r=10,height:i=5,...s}=n;return O.createElement(Mi.svg,dt({},s,{ref:e,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none"}),n.asChild?t:O.createElement("polygon",{points:"0,0 30,0 15,10"}))});function FD(n){const[e,t]=O.useState(void 0);return xs(()=>{if(n){t({width:n.offsetWidth,height:n.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=n.offsetWidth,l=n.offsetHeight;t({width:o,height:l})});return r.observe(n,{box:"border-box"}),()=>r.unobserve(n)}else t(void 0)},[n]),e}const K1="Popper",[J1,G1]=v1(K1),[BD,Y1]=J1(K1),$D=n=>{const{__scopePopper:e,children:t}=n,[r,i]=O.useState(null);return O.createElement(BD,{scope:e,anchor:r,onAnchorChange:i},t)},jD="PopperAnchor",HD=O.forwardRef((n,e)=>{const{__scopePopper:t,virtualRef:r,...i}=n,s=Y1(jD,t),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}))}),Z1="PopperContent",[VD,zD]=J1(Z1),UD=O.forwardRef((n,e)=>{var t,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:k="optimized",onPlaced:E,...T}=n,N=Y1(Z1,u),[_,A]=O.useState(null),R=Ai(e,B=>A(B)),[P,$]=O.useState(null),V=FD(P),U=(t=V==null?void 0:V.width)!==null&&t!==void 0?t:0,J=(r=V==null?void 0:V.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},X=Array.isArray(w)?w:[w],we=X.length>0,Re={padding:ie,boundary:X.filter(KD),altBoundary:we},{refs:Pe,floatingStyles:Ce,placement:ye,isPositioned:Ne,middlewareData:Le}=AD({strategy:"fixed",placement:G,whileElementsMounted:(...B)=>vD(...B,{animationFrame:k==="always"}),elements:{reference:N.anchor},middleware:[OD({mainAxis:f+J,alignmentAxis:p}),v&&_D({mainAxis:!0,crossAxis:!1,limiter:x==="partial"?ND():void 0,...Re}),v&&DD({...Re}),RD({...Re,apply:({elements:B,rects:j,availableWidth:q,availableHeight:te})=>{const{width:M,height:m}=j.reference,b=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&&ID({element:P,padding:g}),JD({arrowWidth:U,arrowHeight:J}),y&&LD({strategy:"referenceHidden",...Re})]}),[tt,nt]=Q1(ye),Ge=Wr(E);xs(()=>{Ne&&(Ge==null||Ge())},[Ne,Ge]);const Ye=(i=Le.arrow)===null||i===void 0?void 0:i.x,Ot=(s=Le.arrow)===null||s===void 0?void 0:s.y,xt=((o=Le.arrow)===null||o===void 0?void 0:o.centerOffset)!==0,[it,at]=O.useState();return xs(()=>{_&&at(window.getComputedStyle(_).zIndex)},[_]),O.createElement("div",{ref:Pe.setFloating,"data-radix-popper-content-wrapper":"",style:{...Ce,transform:Ne?Ce.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:it,"--radix-popper-transform-origin":[(l=Le.transformOrigin)===null||l===void 0?void 0:l.x,(a=Le.transformOrigin)===null||a===void 0?void 0:a.y].join(" ")},dir:n.dir},O.createElement(VD,{scope:u,placedSide:tt,onArrowChange:$,arrowX:Ye,arrowY:Ot,shouldHideArrow:xt},O.createElement(Mi.div,dt({"data-side":tt,"data-align":nt},T,{ref:R,style:{...T.style,animation:Ne?void 0:"none",opacity:(c=Le.hide)!==null&&c!==void 0&&c.referenceHidden?0:void 0}}))))}),X1="PopperArrow",WD={top:"bottom",right:"left",bottom:"top",left:"right"},qD=O.forwardRef(function(e,t){const{__scopePopper:r,...i}=e,s=zD(X1,r),o=WD[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(PD,dt({},i,{ref:t,style:{...i.style,display:"block"}})))});function KD(n){return n!==null}const JD=n=>({name:"transformOrigin",options:n,fn(e){var t,r,i,s,o;const{placement:l,rects:a,middlewareData:c}=e,d=((t=c.arrow)===null||t===void 0?void 0:t.centerOffset)!==0,f=d?0:n.arrowWidth,h=d?0:n.arrowHeight,[p,g]=Q1(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 Q1(n){const[e,t="center"]=n.split("-");return[e,t]}const GD=$D,YD=HD,ZD=UD;function XD(n,e){return O.useReducer((t,r)=>{const i=e[t][r];return i??t},n)}const ev=n=>{const{present:e,children:t}=n,r=QD(e),i=typeof t=="function"?t({present:r.isPresent}):O.Children.only(t),s=Ai(r.ref,i.ref);return typeof t=="function"||r.isPresent?O.cloneElement(i,{ref:s}):null};ev.displayName="Presence";function QD(n){const[e,t]=O.useState(),r=O.useRef({}),i=O.useRef(n),s=O.useRef("none"),o=n?"mounted":"unmounted",[l,a]=XD(o,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return O.useEffect(()=>{const c=mc(r.current);s.current=l==="mounted"?c:"none"},[l]),xs(()=>{const c=r.current,u=i.current;if(u!==n){const f=s.current,h=mc(c);n?a("MOUNT"):h==="none"||(c==null?void 0:c.display)==="none"?a("UNMOUNT"):a(u&&f!==h?"ANIMATION_OUT":"UNMOUNT"),i.current=n}},[n,a]),xs(()=>{if(e){const c=d=>{const h=mc(r.current).includes(d.animationName);d.target===e&&h&&nn.flushSync(()=>a("ANIMATION_END"))},u=d=>{d.target===e&&(s.current=mc(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)),t(c)},[])}}function mc(n){return(n==null?void 0:n.animationName)||"none"}function eR({prop:n,defaultProp:e,onChange:t=()=>{}}){const[r,i]=tR({defaultProp:e,onChange:t}),s=n!==void 0,o=s?n:r,l=Wr(t),a=O.useCallback(c=>{if(s){const d=typeof c=="function"?c(n):c;d!==n&&l(d)}else i(c)},[s,n,i,l]);return[o,a]}function tR({defaultProp:n,onChange:e}){const t=O.useState(n),[r]=t,i=O.useRef(r),s=Wr(e);return O.useEffect(()=>{i.current!==r&&(s(r),i.current=r)},[r,i,s]),t}var nR=function(n){if(typeof document>"u")return null;var e=Array.isArray(n)?n[0]:n;return e.ownerDocument.body},As=new WeakMap,gc=new WeakMap,yc={},th=0,tv=function(n){return n&&(n.host||tv(n.parentNode))},rR=function(n,e){return e.map(function(t){if(n.contains(t))return t;var r=tv(t);return r&&n.contains(r)?r:(console.error("aria-hidden",t,"in not contained inside",n,". Doing nothing"),null)}).filter(function(t){return!!t})},iR=function(n,e,t,r){var i=rR(e,Array.isArray(n)?n:[n]);yc[t]||(yc[t]=new WeakMap);var s=yc[t],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=(As.get(f)||0)+1,v=(s.get(f)||0)+1;As.set(f,g),s.set(f,v),o.push(f),g===1&&p&&gc.set(f,!0),v===1&&f.setAttribute(t,"true"),p||f.setAttribute(r,"true")}catch(w){console.error("aria-hidden: cannot operate on ",f,w)}})};return u(e),l.clear(),th++,function(){o.forEach(function(d){var f=As.get(d)-1,h=s.get(d)-1;As.set(d,f),s.set(d,h),f||(gc.has(d)||d.removeAttribute(r),gc.delete(d)),h||d.removeAttribute(t)}),th--,th||(As=new WeakMap,As=new WeakMap,gc=new WeakMap,yc={})}},sR=function(n,e,t){t===void 0&&(t="data-aria-hidden");var r=Array.from(Array.isArray(n)?n:[n]),i=nR(n);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live]"))),iR(r,i,t,"aria-hidden")):function(){return null}},Zn=function(){return Zn=Object.assign||function(e){for(var t,r=1,i=arguments.length;r<i;r++){t=arguments[r];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s])}return e},Zn.apply(this,arguments)};function nv(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(n);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(n,r[i])&&(t[r[i]]=n[r[i]]);return t}function oR(n,e,t){if(t||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 n.concat(s||Array.prototype.slice.call(e))}typeof SuppressedError=="function"&&SuppressedError;var bc="right-scroll-bar-position",vc="width-before-scroll-bar",lR="with-scroll-bars-hidden",aR="--removed-body-scroll-bar-size";function nh(n,e){return typeof n=="function"?n(e):n&&(n.current=e),n}function cR(n,e){var t=O.useState(function(){return{value:n,callback:e,facade:{get current(){return t.value},set current(r){var i=t.value;i!==r&&(t.value=r,t.callback(r,i))}}}})[0];return t.callback=e,t.facade}var uR=typeof window<"u"?le.useLayoutEffect:le.useEffect,rv=new WeakMap;function dR(n,e){var t=cR(null,function(r){return n.forEach(function(i){return nh(i,r)})});return uR(function(){var r=rv.get(t);if(r){var i=new Set(r),s=new Set(n),o=t.current;i.forEach(function(l){s.has(l)||nh(l,null)}),s.forEach(function(l){i.has(l)||nh(l,o)})}rv.set(t,n)},[n]),t}function fR(n){return n}function hR(n,e){e===void 0&&(e=fR);var t=[],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 t.length?t[t.length-1]:n},useMedium:function(s){var o=e(s,r);return t.push(o),function(){t=t.filter(function(l){return l!==o})}},assignSyncMedium:function(s){for(r=!0;t.length;){var o=t;t=[],o.forEach(s)}t={push:function(l){return s(l)},filter:function(){return t}}},assignMedium:function(s){r=!0;var o=[];if(t.length){var l=t;t=[],l.forEach(s),o=t}var a=function(){var u=o;o=[],u.forEach(s)},c=function(){return Promise.resolve().then(a)};c(),t={push:function(u){o.push(u),c()},filter:function(u){return o=o.filter(u),t}}}};return i}function pR(n){n===void 0&&(n={});var e=hR(null);return e.options=Zn({async:!0,ssr:!1},n),e}var iv=function(n){var e=n.sideCar,t=nv(n,["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,Zn({},t))};iv.isSideCarExport=!0;function mR(n,e){return n.useMedium(e),iv}var sv=pR(),rh=function(){},wc=le.forwardRef(function(n,e){var t=le.useRef(null),r=le.useState({onScrollCapture:rh,onWheelCapture:rh,onTouchMoveCapture:rh}),i=r[0],s=r[1],o=n.forwardProps,l=n.children,a=n.className,c=n.removeScrollBar,u=n.enabled,d=n.shards,f=n.sideCar,h=n.noIsolation,p=n.inert,g=n.allowPinchZoom,v=n.as,w=v===void 0?"div":v,S=nv(n,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as"]),x=f,y=dR([t,e]),k=Zn(Zn({},S),i);return le.createElement(le.Fragment,null,u&&le.createElement(x,{sideCar:sv,removeScrollBar:c,shards:d,noIsolation:h,inert:p,setCallbacks:s,allowPinchZoom:!!g,lockRef:t}),o?le.cloneElement(le.Children.only(l),Zn(Zn({},k),{ref:y})):le.createElement(w,Zn({},k,{className:a,ref:y}),l))});wc.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},wc.classNames={fullWidth:vc,zeroRight:bc};var gR=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function yR(){if(!document)return null;var n=document.createElement("style");n.type="text/css";var e=gR();return e&&n.setAttribute("nonce",e),n}function bR(n,e){n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}function vR(n){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(n)}var wR=function(){var n=0,e=null;return{add:function(t){n==0&&(e=yR())&&(bR(e,t),vR(e)),n++},remove:function(){n--,!n&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},xR=function(){var n=wR();return function(e,t){le.useEffect(function(){return n.add(e),function(){n.remove()}},[e&&t])}},ov=function(){var n=xR(),e=function(t){var r=t.styles,i=t.dynamic;return n(r,i),null};return e},CR={left:0,top:0,right:0,gap:0},ih=function(n){return parseInt(n||"",10)||0},kR=function(n){var e=window.getComputedStyle(document.body),t=e[n==="padding"?"paddingLeft":"marginLeft"],r=e[n==="padding"?"paddingTop":"marginTop"],i=e[n==="padding"?"paddingRight":"marginRight"];return[ih(t),ih(r),ih(i)]},SR=function(n){if(n===void 0&&(n="margin"),typeof window>"u")return CR;var e=kR(n),t=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-t+e[2]-e[0])}},ER=ov(),Ms="data-scroll-locked",TR=function(n,e,t,r){var i=n.left,s=n.top,o=n.right,l=n.gap;return t===void 0&&(t="margin"),`
334
+ .`.concat(lR,` {
320
335
  overflow: hidden `).concat(r,`;
321
336
  padding-right: `).concat(l,"px ").concat(r,`;
322
337
  }
@@ -350,10 +365,10 @@ Use Chrome, Firefox or Internet Explorer 11`)}}).call(this)}).call(this,s("_proc
350
365
  }
351
366
 
352
367
  body[`).concat(Ms,`] {
353
- `).concat(sR,": ").concat(l,`px;
368
+ `).concat(aR,": ").concat(l,`px;
354
369
  }
355
- `)},lv=function(){var n=parseInt(document.body.getAttribute(Ms)||"0",10);return isFinite(n)?n:0},SR=function(){le.useEffect(function(){return document.body.setAttribute(Ms,(lv()+1).toString()),function(){var n=lv()-1;n<=0?document.body.removeAttribute(Ms):document.body.setAttribute(Ms,n.toString())}},[])},ER=function(n){var e=n.noRelative,t=n.noImportant,r=n.gapMode,i=r===void 0?"margin":r;SR();var s=le.useMemo(function(){return CR(i)},[i]);return le.createElement(xR,{styles:kR(s,!e,i,t?"":"!important")})},sh=!1;if(typeof window<"u")try{var Cc=Object.defineProperty({},"passive",{get:function(){return sh=!0,!0}});window.addEventListener("test",Cc,Cc),window.removeEventListener("test",Cc,Cc)}catch{sh=!1}var Os=sh?{passive:!1}:!1,TR=function(n){return n.tagName==="TEXTAREA"},av=function(n,e){var t=window.getComputedStyle(n);return t[e]!=="hidden"&&!(t.overflowY===t.overflowX&&!TR(n)&&t[e]==="visible")},AR=function(n){return av(n,"overflowY")},MR=function(n){return av(n,"overflowX")},cv=function(n,e){var t=e;do{typeof ShadowRoot<"u"&&t instanceof ShadowRoot&&(t=t.host);var r=uv(n,t);if(r){var i=dv(n,t),s=i[1],o=i[2];if(s>o)return!0}t=t.parentNode}while(t&&t!==document.body);return!1},OR=function(n){var e=n.scrollTop,t=n.scrollHeight,r=n.clientHeight;return[e,t,r]},_R=function(n){var e=n.scrollLeft,t=n.scrollWidth,r=n.clientWidth;return[e,t,r]},uv=function(n,e){return n==="v"?AR(e):MR(e)},dv=function(n,e){return n==="v"?OR(e):_R(e)},NR=function(n,e){return n==="h"&&e==="rtl"?-1:1},DR=function(n,e,t,r,i){var s=NR(n,window.getComputedStyle(e).direction),o=s*r,l=t.target,a=e.contains(l),c=!1,u=o>0,d=0,f=0;do{var h=dv(n,l),p=h[0],g=h[1],v=h[2],w=g-v-s*p;(p||w)&&uv(n,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},xc=function(n){return"changedTouches"in n?[n.changedTouches[0].clientX,n.changedTouches[0].clientY]:[0,0]},fv=function(n){return[n.deltaX,n.deltaY]},hv=function(n){return n&&"current"in n?n.current:n},RR=function(n,e){return n[0]===e[0]&&n[1]===e[1]},LR=function(n){return`
370
+ `)},lv=function(){var n=parseInt(document.body.getAttribute(Ms)||"0",10);return isFinite(n)?n:0},AR=function(){le.useEffect(function(){return document.body.setAttribute(Ms,(lv()+1).toString()),function(){var n=lv()-1;n<=0?document.body.removeAttribute(Ms):document.body.setAttribute(Ms,n.toString())}},[])},MR=function(n){var e=n.noRelative,t=n.noImportant,r=n.gapMode,i=r===void 0?"margin":r;AR();var s=le.useMemo(function(){return SR(i)},[i]);return le.createElement(ER,{styles:TR(s,!e,i,t?"":"!important")})},sh=!1;if(typeof window<"u")try{var xc=Object.defineProperty({},"passive",{get:function(){return sh=!0,!0}});window.addEventListener("test",xc,xc),window.removeEventListener("test",xc,xc)}catch{sh=!1}var Os=sh?{passive:!1}:!1,OR=function(n){return n.tagName==="TEXTAREA"},av=function(n,e){var t=window.getComputedStyle(n);return t[e]!=="hidden"&&!(t.overflowY===t.overflowX&&!OR(n)&&t[e]==="visible")},_R=function(n){return av(n,"overflowY")},NR=function(n){return av(n,"overflowX")},cv=function(n,e){var t=e;do{typeof ShadowRoot<"u"&&t instanceof ShadowRoot&&(t=t.host);var r=uv(n,t);if(r){var i=dv(n,t),s=i[1],o=i[2];if(s>o)return!0}t=t.parentNode}while(t&&t!==document.body);return!1},DR=function(n){var e=n.scrollTop,t=n.scrollHeight,r=n.clientHeight;return[e,t,r]},RR=function(n){var e=n.scrollLeft,t=n.scrollWidth,r=n.clientWidth;return[e,t,r]},uv=function(n,e){return n==="v"?_R(e):NR(e)},dv=function(n,e){return n==="v"?DR(e):RR(e)},LR=function(n,e){return n==="h"&&e==="rtl"?-1:1},IR=function(n,e,t,r,i){var s=LR(n,window.getComputedStyle(e).direction),o=s*r,l=t.target,a=e.contains(l),c=!1,u=o>0,d=0,f=0;do{var h=dv(n,l),p=h[0],g=h[1],v=h[2],w=g-v-s*p;(p||w)&&uv(n,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},Cc=function(n){return"changedTouches"in n?[n.changedTouches[0].clientX,n.changedTouches[0].clientY]:[0,0]},fv=function(n){return[n.deltaX,n.deltaY]},hv=function(n){return n&&"current"in n?n.current:n},PR=function(n,e){return n[0]===e[0]&&n[1]===e[1]},FR=function(n){return`
356
371
  .block-interactivity-`.concat(n,` {pointer-events: none;}
357
372
  .allow-interactivity-`).concat(n,` {pointer-events: all;}
358
- `)},IR=0,_s=[];function PR(n){var e=le.useRef([]),t=le.useRef([0,0]),r=le.useRef(),i=le.useState(IR++)[0],s=le.useState(function(){return ov()})[0],o=le.useRef(n);le.useEffect(function(){o.current=n},[n]),le.useEffect(function(){if(n.inert){document.body.classList.add("block-interactivity-".concat(i));var g=rR([n.lockRef.current],(n.shards||[]).map(hv),!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))})}}},[n.inert,n.lockRef.current,n.shards]);var l=le.useCallback(function(g,v){if("touches"in g&&g.touches.length===2)return!o.current.allowPinchZoom;var w=xc(g),S=t.current,C="deltaX"in g?g.deltaX:S[0]-w[0],y="deltaY"in g?g.deltaY:S[1]-w[1],k,E=g.target,T=Math.abs(C)>Math.abs(y)?"h":"v";if("touches"in g&&T==="h"&&E.type==="range")return!1;var N=cv(T,E);if(!N)return!0;if(N?k=T:(k=T==="v"?"h":"v",N=cv(T,E)),!N)return!1;if(!r.current&&"changedTouches"in g&&(C||y)&&(r.current=k),!k)return!0;var _=r.current||k;return DR(_,v,g,_==="h"?C:y,!0)},[]),a=le.useCallback(function(g){var v=g;if(!(!_s.length||_s[_s.length-1]!==s)){var w="deltaY"in v?fv(v):xc(v),S=e.current.filter(function(k){return k.name===v.type&&k.target===v.target&&RR(k.delta,w)})[0];if(S&&S.should){v.cancelable&&v.preventDefault();return}if(!S){var C=(o.current.shards||[]).map(hv).filter(Boolean).filter(function(k){return k.contains(v.target)}),y=C.length>0?l(v,C[0]):!o.current.noIsolation;y&&v.cancelable&&v.preventDefault()}}},[]),c=le.useCallback(function(g,v,w,S){var C={name:g,delta:v,target:w,should:S};e.current.push(C),setTimeout(function(){e.current=e.current.filter(function(y){return y!==C})},1)},[]),u=le.useCallback(function(g){t.current=xc(g),r.current=void 0},[]),d=le.useCallback(function(g){c(g.type,fv(g),g.target,l(g,n.lockRef.current))},[]),f=le.useCallback(function(g){c(g.type,xc(g),g.target,l(g,n.lockRef.current))},[]);le.useEffect(function(){return _s.push(s),n.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",a,Os),document.addEventListener("touchmove",a,Os),document.addEventListener("touchstart",u,Os),function(){_s=_s.filter(function(g){return g!==s}),document.removeEventListener("wheel",a,Os),document.removeEventListener("touchmove",a,Os),document.removeEventListener("touchstart",u,Os)}},[]);var h=n.removeScrollBar,p=n.inert;return le.createElement(le.Fragment,null,p?le.createElement(s,{styles:LR(i)}):null,h?le.createElement(ER,{gapMode:"margin"}):null)}const FR=fR(sv,PR);var pv=le.forwardRef(function(n,e){return le.createElement(wc,Zn({},n,{ref:e,sideCar:FR}))});pv.classNames=wc.classNames;const mv="Popover",[gv,r4]=v1(mv,[G1]),oh=G1(),[BR,Ns]=gv(mv),$R=n=>{const{__scopePopover:e,children:t,open:r,defaultOpen:i,onOpenChange:s,modal:o=!1}=n,l=oh(e),a=O.useRef(null),[c,u]=O.useState(!1),[d=!1,f]=ZD({prop:r,defaultProp:i,onChange:s});return O.createElement(qD,l,O.createElement(BR,{scope:e,contentId:LN(),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},t))},jR="PopoverTrigger",HR=O.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,i=Ns(jR,t),s=oh(t),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":bv(i.open)},r,{ref:o,onClick:Ur(n.onClick,i.onOpenToggle)}));return i.hasCustomAnchor?l:O.createElement(KD,dt({asChild:!0},s),l)}),VR="PopoverPortal",[i4,zR]=gv(VR,{forceMount:void 0}),Yo="PopoverContent",UR=O.forwardRef((n,e)=>{const t=zR(Yo,n.__scopePopover),{forceMount:r=t.forceMount,...i}=n,s=Ns(Yo,n.__scopePopover);return O.createElement(ev,{present:r||s.open},s.modal?O.createElement(WR,dt({},i,{ref:e})):O.createElement(qR,dt({},i,{ref:e})))}),WR=O.forwardRef((n,e)=>{const t=Ns(Yo,n.__scopePopover),r=O.useRef(null),i=Ai(e,r),s=O.useRef(!1);return O.useEffect(()=>{const o=r.current;if(o)return nR(o)},[]),O.createElement(pv,{as:$f,allowPinchZoom:!0},O.createElement(yv,dt({},n,{ref:i,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ur(n.onCloseAutoFocus,o=>{var l;o.preventDefault(),s.current||(l=t.triggerRef.current)===null||l===void 0||l.focus()}),onPointerDownOutside:Ur(n.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(n.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})))}),qR=O.forwardRef((n,e)=>{const t=Ns(Yo,n.__scopePopover),r=O.useRef(!1),i=O.useRef(!1);return O.createElement(yv,dt({},n,{ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o;if((o=n.onCloseAutoFocus)===null||o===void 0||o.call(n,s),!s.defaultPrevented){var l;r.current||(l=t.triggerRef.current)===null||l===void 0||l.focus(),s.preventDefault()}r.current=!1,i.current=!1},onInteractOutside:s=>{var o,l;(o=n.onInteractOutside)===null||o===void 0||o.call(n,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=s.target;((l=t.triggerRef.current)===null||l===void 0?void 0:l.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}}))}),yv=O.forwardRef((n,e)=>{const{__scopePopover:t,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onInteractOutside:u,...d}=n,f=Ns(Yo,t),h=oh(t);return SN(),O.createElement(EN,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s},O.createElement(CN,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onDismiss:()=>f.onOpenChange(!1)},O.createElement(JD,dt({"data-state":bv(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)"}}))))}),KR="PopoverClose",JR=O.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,i=Ns(KR,t);return O.createElement(Mi.button,dt({type:"button"},r,{ref:e,onClick:Ur(n.onClick,()=>i.onOpenChange(!1))}))});function bv(n){return n?"open":"closed"}const GR=$R,YR=HR,ZR=UR,kc=JR,Sc=({children:n,isActive:e,onClick:t,disabled:r,className:i})=>{const s=Fe("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 D.jsx("button",{className:s,disabled:r,onClick:t,children:n})},XR=(n,e,t)=>{const r=O.useCallback(()=>{const l=n.chain();l.setNodeSelection(t).unsetAllMarks(),(e==null?void 0:e.type.name)!=="paragraph"&&l.setParagraph(),l.run()},[n,t,e==null?void 0:e.type.name]),i=O.useCallback(()=>{n.commands.setNodeSelection(t);const{$anchor:l}=n.state.selection,a=l.node(1)||n.state.selection.node;n.chain().setMeta("hideDragHandle",!0).insertContentAt(t+((e==null?void 0:e.nodeSize)||0),a.toJSON()).run()},[n,t,e==null?void 0:e.nodeSize]),s=O.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).run(),document.execCommand("copy"),alert("copied")},[n,t]),o=O.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).deleteSelection().run()},[n,t]);return{resetTextFormatting:r,duplicateNode:i,copyNodeToClipboard:s,deleteNode:o}},QR=({node:n,getPos:e,editor:t,deleteNode:r})=>{const[i,s]=O.useState(!1),o=XR(t,n,e()),l=Ul(),a=["https://twitter.com","https://x.com"],c=O.useMemo(()=>{const{content:_}=n.content;return _[0].type.name==="table"},[n.content]),u=O.useMemo(()=>{var A;const{content:_}=n.content;return(A=_[0].content.content[0])==null?void 0:A.text},[n.content]),d=O.useMemo(()=>{var A;const{content:_}=n.content;return(A=_[0].content.content[1])==null?void 0:A.text},[n.content]),f=O.useMemo(()=>{const{content:_}=n.content;return _[0].content.content.find(A=>{var R;return(R=A==null?void 0:A.text)==null?void 0:R.match(/\/status\/([0-9]*)/)})},[n.content]),h=()=>{if(!u)return;let _=u;if(u.includes("<iframe"))_=d;else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(u):{const V=u.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);V&&V.length>0&&(_=`https://www.youtube.com/embed/${V[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(u):{const V=u.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);V&&V.length>0&&(_=`https://player.vimeo.com/video/${V[1]}`);break}default:return}const A=640,R=360,P=e(),$=P+n.nodeSize;_&&(t==null||t.chain().focus(P).deleteRange({from:P===0?P:P+1,to:$}).setIframe({src:_,width:A,height:R}).run())},p=_=>{const A=_.match(/\/status\/([0-9]*)/);return A&&A.length>0?A[1]:null},g=()=>{if(!u)return;let _=u;const A=a.some(V=>u.includes(V)),R=p(u);A&&R?_=R:f&&(_=p(f.text));const P=e(),$=P+n.nodeSize;_&&(t==null||t.chain().focus(P).deleteRange({from:P===2?P:P+1,to:$}).setTweetEmbed({tweetId:_}).run())},v=()=>{const _=e()+n.nodeSize;t.commands.insertContentAt(_,{type:"dBlock",content:[{type:"paragraph"}]})},w=()=>{const _=e();t.commands.insertContentAt(_,{type:"dBlock",content:[{type:"paragraph"}]})},S=()=>{r()},C=_=>{_.altKey?k():y()},y=()=>{v()},k=()=>{w()},E=_=>{_.altKey&&S()},N=y1(()=>{if(a.some(_=>u.includes(_))||f!=null&&f.text){g();return}else{h();return}},1e3);return O.useEffect(()=>{u&&N()},[u]),D.jsxs(bo,{as:"div",className:Fe("flex gap-2 group w-full relative justify-center items-start",l&&"pointer-events-none",c&&"2xl:ml-4 pointer-events-auto"),children:[D.jsxs("section",{className:"lg:flex gap-1 hidden","aria-label":"left-menu",contentEditable:!1,children:[D.jsx(T0,{content:D.jsxs("div",{className:"flex flex-col w-40",children:[D.jsx("div",{className:"text-xs",children:"Click to add below"}),D.jsx("div",{className:"text-xs",children:"Opt + Click to add above"})]}),children:D.jsx("div",{className:`d-block-button cursor-pointer ${!l&&"group-hover:opacity-100"}`,contentEditable:!1,onClick:C,children:D.jsx(nT,{size:18})})}),D.jsxs(GR,{open:i,onOpenChange:s,children:[D.jsx(YR,{asChild:!0,children:D.jsx("div",{className:`d-block-button cursor-pointer ${!l&&"group-hover:opacity-100"}`,contentEditable:!1,draggable:!0,"data-drag-handle":!0,onClick:E,children:D.jsx(YE,{size:18})})}),D.jsx(ZR,{side:"bottom",align:"start",sideOffset:8,className:"z-10",children:D.jsxs(ld,{className:"p-2 flex flex-col min-w-[16rem]",children:[D.jsx(kc,{children:D.jsxs(Sc,{onClick:o.resetTextFormatting,children:[D.jsx(rT,{size:18}),"Clear formatting"]})}),D.jsx(kc,{children:D.jsxs(Sc,{onClick:o.copyNodeToClipboard,children:[D.jsx(qE,{size:18}),"Copy to clipboard"]})}),D.jsx(kc,{children:D.jsxs(Sc,{onClick:o.duplicateNode,children:[D.jsx(JE,{size:18}),"Duplicate"]})}),D.jsx(vo.Divider,{horizontal:!0}),D.jsx(kc,{children:D.jsxs(Sc,{onClick:o.deleteNode,className:"text-red-500 hover:bg-red-500 bg-opacity-10 hover:bg-opacity-20",children:[D.jsx(oT,{size:18}),"Delete"]})})]})})]})]}),D.jsx(Kg,{className:Fe("node-view-content w-full",{"is-table min-w-auto":c})})]})},e5=Ve.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:n}){return["div",Ce(n,{"data-type":"d-block"}),0]},addCommands(){return{setDBlock:n=>({state:e,chain:t})=>{const{selection:{from:r}}=e,i=n!==void 0||n!==null?r:n;return t().insertContentAt(i,{type:this.name,content:[{type:"paragraph"}]}).focus(i+2).run()},mergeDBlocksIntoList:n=>({state:e,dispatch:t})=>{if(!t)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[n].create(null,o);return l?(s=s.replaceRangeWith(r,i,l),t(s),!0):!1},splitListToDBlocks:n=>({state:e,dispatch:t})=>{if(!t)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===n){const a=e.schema.nodes[this.name].create(null,o.content);s=s.insert(l,a)}}),t(s),!0}}},addNodeView(){return hi(QR)},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setDBlock(),Enter:({editor:n})=>{var c;const{selection:{$head:e,from:t,to:r},doc:i}=n.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<=t&&r<=h&&(o=h,l=u.type.name),!1});const a=(c=i.slice(t,o))==null?void 0:c.toJSON().content;try{return l==="codeBlock"?n.chain().insertContentAt({from:t,to:o},`
359
- `).focus(o+1).run():["columns","heading"].includes(l)?n.chain().insertContent({type:"dBlock",content:[{type:"paragraph"}]}).focus().run():n.chain().insertContentAt({from:t,to:o},{type:this.name,content:a}).focus(t+4).run()}catch(u){return console.error(`Error inserting content into dBlock node: ${u}`),!1}}}}});let lh,ah;if(typeof WeakMap<"u"){let n=new WeakMap;lh=e=>n.get(e),ah=(e,t)=>(n.set(e,t),t)}else{let n=[],e=10,t=0;lh=r=>{for(let i=0;i<n.length;i+=2)if(n[i]==r)return n[i+1]},ah=(r,i)=>(t==e&&(t=0),n[t++]=r,n[t++]=i)}class Ds{constructor(e,t,r,i){this.left=e,this.top=t,this.right=r,this.bottom=i}}class et{constructor(e,t,r,i){this.width=e,this.height=t,this.map=r,this.problems=i}findCell(e){for(let t=0;t<this.map.length;t++){let r=this.map[t];if(r!=e)continue;let i=t%this.width,s=t/this.width|0,o=i+1,l=s+1;for(let a=1;o<this.width&&this.map[t+a]==r;a++)o++;for(let a=1;l<this.height&&this.map[t+this.width*a]==r;a++)l++;return new Ds(i,s,o,l)}throw new RangeError("No cell with offset "+e+" found")}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError("No cell with offset "+e+" found")}nextCell(e,t,r){let{left:i,right:s,top:o,bottom:l}=this.findCell(e);return t=="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,t){let{left:r,right:i,top:s,bottom:o}=this.findCell(e),{left:l,right:a,top:c,bottom:u}=this.findCell(t);return new Ds(Math.min(r,l),Math.min(s,c),Math.max(i,a),Math.max(o,u))}cellsInRect(e){let t=[],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)&&t.push(l))}return t}positionAt(e,t,r){for(let i=0,s=0;;i++){let o=s+r.child(i).nodeSize;if(i==e){let l=t+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 lh(e)||ah(e,t5(e))}}function t5(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);let e=n5(n),t=n.childCount,r=[],i=0,s=null,o=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){let d=n.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 C=0;C<w;C++){if(C+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:w-C});break}let y=i+C*e;for(let k=0;k<v;k++){r[y+k]==0?r[y+k]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:v-k});let E=S&&S[k];if(E){let T=(y+k)%e*2,N=o[T];N==null||N!=E&&o[T+1]==1?(o[T]=E,o[T+1]=1):N==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,t,r,s),a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(a=!0);return a&&r5(l,o,n),l}function n5(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){let i=n.child(r),s=0;if(t)for(let o=0;o<r;o++){let l=n.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&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function r5(n,e,t){n.problems||(n.problems=[]);for(let r=0,i={};r<n.map.length;r++){let s=n.map[r];if(i[s])continue;i[s]=!0;let o=t.nodeAt(s),l=null;for(let a=0;a<o.attrs.colspan;a++){let c=(r+a)%n.width,u=e[c*2];u!=null&&(!o.attrs.colwidth||o.attrs.colwidth[a]!=u)&&((l||(l=i5(o.attrs)))[a]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function i5(n){if(n.colwidth)return n.colwidth.slice();let e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Mt(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(let t in n.nodes){let r=n.nodes[t],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const Gr=new We("selectingCells");function Rs(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function s5(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Tn(n){let e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Ec(n){let e=n.selection;return e.$anchorCell?e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell:e.node&&e.node.type.spec.tableRole=="cell"?e.$anchor:Rs(e.$head)||o5(e.$head)}function o5(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function ch(n){return n.parent.type.spec.tableRole=="row"&&n.nodeAfter}function l5(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function uh(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function vv(n,e,t){let r=n.start(-1),s=et.get(n.node(-1)).nextCell(n.pos-r,e,t);return s==null?null:n.node(0).resolve(r+s)}function wt(n,e,t){let r={};for(let i in n)r[i]=n[i];return r[e]=t,r}function _i(n,e,t=1){let r=wt(n,"colspan",n.colspan-t);return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function wv(n,e,t=1){let r=wt(n,"colspan",n.colspan+t);if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<t;i++)r.colwidth.splice(e,0,0)}return r}function a5(n,e,t){let r=Mt(e.type.schema).header_cell;for(let i=0;i<n.height;i++)if(e.nodeAt(n.map[t+i*n.width]).type!=r)return!1;return!0}class Se extends ue{constructor(e,t=e){let r=e.node(-1),i=et.get(r),s=e.start(-1),o=i.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=i.cellsInRect(o).filter(u=>u!=t.pos-s);a.unshift(t.pos-s);let c=a.map(u=>{let d=r.nodeAt(u),f=u+s+1;return new Jc(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let r=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(ch(r)&&ch(i)&&uh(r,i)){let s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?Se.rowSelection(r,i):s&&this.isColSelection()?Se.colSelection(r,i):new Se(r,i)}return ce.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=et.get(e),r=this.$anchorCell.start(-1),i=t.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*t.width+i.left,d=i.left;d<i.right;d++,u++){let f=t.map[u];if(!s[f]){s[f]=!0;let h=t.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,t=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:t)}let s=ue.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new Y(W.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),r=et.get(t),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(t.nodeAt(s[o]),i+s[o])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let r=et.get(e.node(-1)),i=e.start(-1),s=r.findCell(e.pos-i),o=r.findCell(t.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&&(t=l.resolve(i+r.map[r.width*(r.height-1)+o.right-1]))):(o.top>0&&(t=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 Se(e,t)}isRowSelection(){let e=et.get(this.$anchorCell.node(-1)),t=this.$anchorCell.start(-1),r=e.colCount(this.$anchorCell.pos-t),i=e.colCount(this.$headCell.pos-t);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 Se&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let r=et.get(e.node(-1)),i=e.start(-1),s=r.findCell(e.pos-i),o=r.findCell(t.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&&(t=l.resolve(i+r.map[r.width*(o.top+1)-1]))):(o.left>0&&(t=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 Se(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Se(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new Se(e.resolve(t),e.resolve(r))}getBookmark(){return new dh(this.$anchorCell.pos,this.$headCell.pos)}}Se.prototype.visible=!1,ue.jsonID("cell",Se);class dh{constructor(e,t){this.anchor=e,this.head=t}map(e){return new dh(e.map(this.anchor),e.map(this.head))}resolve(e){let t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&uh(t,r)?new Se(t,r):ue.near(r,1)}}function c5(n){if(!(n.selection instanceof Se))return null;let e=[];return n.selection.forEachCell((t,r)=>{e.push(ut.node(r,r+t.nodeSize,{class:"selectedCell"}))}),He.create(n.doc,e)}function u5({$from:n,$to:e}){if(n.pos==e.pos||n.pos<n.pos-6)return!1;let t=n.pos,r=e.pos,i=n.depth;for(;i>=0&&!(n.after(i+1)<n.end(i));i--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(i).type.spec.tableRole)}function d5({$from:n,$to:e}){let t,r;for(let i=n.depth;i>0;i--){let s=n.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=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 t!==r&&e.parentOffset===0}function f5(n,e,t){let r=(e||n).selection,i=(e||n).doc,s,o;if(r instanceof se&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=Se.create(i,r.from);else if(o=="row"){let l=i.resolve(r.from+1);s=Se.rowSelection(l,l)}else if(!t){let l=et.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=Se.create(i,a+1,c)}}else r instanceof ce&&u5(r)?s=ce.create(i,r.from):r instanceof ce&&d5(r)&&(s=ce.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}function h5(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.firstChild.type.spec.tableRole=="table");)t--,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,t-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=fh(Mt(o).row,new Y(c,u,d)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?fh(Mt(o).row,new Y(e,t,r)).content:e);else return null;return p5(o,l)}function p5(n,e){let t=[];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++)t[c]=(t[c]||0)+a}}let r=0;for(let i=0;i<t.length;i++)r=Math.max(r,t[i]);for(let i=0;i<t.length;i++)if(i>=e.length&&e.push(W.empty),t[i]<r){let s=Mt(n).cell.createAndFill(),o=[];for(let l=t[i];l<r;l++)o.push(s);e[i]=e[i].append(W.from(o))}return{height:e.length,width:r,rows:e}}function fh(n,e){let t=n.createAndFill();return new qc(t).replace(0,t.content.size,e).doc}function m5({width:n,height:e,rows:t},r,i){if(n!=r){let s=[],o=[];for(let l=0;l<t.length;l++){let a=t[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))}t=o,n=r}if(e!=i){let s=[];for(let o=0,l=0;o<i;o++,l++){let a=[],c=t[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))}t=s,e=i}return{width:n,height:e,rows:t}}function g5(n,e,t,r,i,s,o){let l=n.doc.type.schema,a=Mt(l),c,u;if(i>e.width)for(let d=0,f=0;d<e.height;d++){let h=t.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);n.insert(n.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:t.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);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),h)}return!!(c||u)}function Cv(n,e,t,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=t.nodeAt(d),{top:h,left:p}=e.findCell(d);n.setNodeMarkup(n.mapping.slice(l).map(d+r),null,wt(f.attrs,"rowspan",o-h)),n.insert(n.mapping.slice(l).map(e.positionAt(o,p,t)),f.type.createAndFill(wt(f.attrs,"rowspan",h+f.attrs.rowspan-o))),c+=f.attrs.colspan-1}}return a}function xv(n,e,t,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=t.nodeAt(d),h=e.colCount(d),p=n.mapping.slice(l).map(d+r);n.setNodeMarkup(p,null,_i(f.attrs,o-h,f.attrs.colspan-(o-h))),n.insert(p+f.nodeSize,f.type.createAndFill(_i(f.attrs,0,o-h))),c+=f.attrs.rowspan-1}}return a}function kv(n,e,t,r,i){let s=t?n.doc.nodeAt(t-1):n.doc,o=et.get(s),{top:l,left:a}=r,c=a+i.width,u=l+i.height,d=n.tr,f=0;function h(){s=t?d.doc.nodeAt(t-1):d.doc,o=et.get(s),f=d.mapping.maps.length}g5(d,o,s,t,c,u,f)&&h(),Cv(d,o,s,t,a,c,l,f)&&h(),Cv(d,o,s,t,a,c,u,f)&&h(),xv(d,o,s,t,l,u,a,f)&&h(),xv(d,o,s,t,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+t),d.mapping.slice(f).map(v+t),new Y(i.rows[p-l],0,0))}h(),d.setSelection(new Se(d.doc.resolve(t+o.positionAt(l,a,s)),d.doc.resolve(t+o.positionAt(u-1,c-1,s)))),e(d)}const y5=ku({ArrowLeft:Ac("horiz",-1),ArrowRight:Ac("horiz",1),ArrowUp:Ac("vert",-1),ArrowDown:Ac("vert",1),"Shift-ArrowLeft":Mc("horiz",-1),"Shift-ArrowRight":Mc("horiz",1),"Shift-ArrowUp":Mc("vert",-1),"Shift-ArrowDown":Mc("vert",1),Backspace:Oc,"Mod-Backspace":Oc,Delete:Oc,"Mod-Delete":Oc});function Tc(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Ac(n,e){return(t,r,i)=>{let s=t.selection;if(s instanceof Se)return Tc(t,r,ue.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;let o=Sv(i,n,e);if(o==null)return!1;if(n=="horiz")return Tc(t,r,ue.near(t.doc.resolve(s.head+e),e));{let l=t.doc.resolve(o),a=vv(l,n,e),c;return a?c=ue.near(a,1):e<0?c=ue.near(t.doc.resolve(l.before(-1)),-1):c=ue.near(t.doc.resolve(l.after(-1)),1),Tc(t,r,c)}}}function Mc(n,e){return(t,r,i)=>{let s=t.selection;if(!(s instanceof Se)){let l=Sv(i,n,e);if(l==null)return!1;s=new Se(t.doc.resolve(l))}let o=vv(s.$headCell,n,e);return o?Tc(t,r,new Se(s.$anchorCell,o)):!1}}function Oc(n,e){let t=n.selection;if(!(t instanceof Se))return!1;if(e){let r=n.tr,i=Mt(n.schema).cell.createAndFill().content;t.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 b5(n,e){let t=n.state.doc,r=Rs(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new Se(r))),!0):!1}function v5(n,e,t){if(!Tn(n.state))return!1;let r=h5(t),i=n.state.selection;if(i instanceof Se){r||(r={width:1,height:1,rows:[W.from(fh(Mt(n.state.schema).cell,t))]});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=m5(r,l.right-l.left,l.bottom-l.top),kv(n.state,n.dispatch,o,l,r),!0}else if(r){let s=Ec(n.state),o=s.start(-1);return kv(n.state,n.dispatch,o,et.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function w5(n,e){if(e.ctrlKey||e.metaKey)return;let t=Ev(n,e.target),r;if(e.shiftKey&&n.state.selection instanceof Se)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&t&&(r=Rs(n.state.selection.$anchor))!=null&&hh(n,e).pos!=r.pos)i(r,e),e.preventDefault();else if(!t)return;function i(l,a){let c=hh(n,a),u=Gr.getState(n.state)==null;if(!c||!uh(l,c))if(u)c=l;else return;let d=new Se(l,c);if(u||!n.state.selection.eq(d)){let f=n.state.tr.setSelection(d);u&&f.setMeta(Gr,l.pos),n.dispatch(f)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",o),Gr.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Gr,-1))}function o(l){let a=Gr.getState(n.state),c;if(a!=null)c=n.state.doc.resolve(a);else if(Ev(n,l.target)!=t&&(c=hh(n,e),!c))return s();c&&i(c,l)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",o)}function Sv(n,e,t){if(!(n.state.selection instanceof ce))return null;let{$head:r}=n.state.selection;for(let i=r.depth-1;i>=0;i--){let s=r.node(i);if((t<0?r.index(i):r.indexAfter(i))!=(t<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"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Ev(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e}function hh(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Rs(n.state.doc.resolve(t.pos)):null}const C5=new We("fix-tables");function Tv(n,e,t,r){let i=n.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(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<i&&n.child(l).sameMarkup(a)?Tv(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function Av(n,e){let t,r=(i,s)=>{i.type.spec.tableRole=="table"&&(t=x5(n,i,s,t))};return e?e.doc!=n.doc&&Tv(e.doc,n.doc,0,r):n.doc.descendants(r),t}function x5(n,e,t,r){let i=et.get(e);if(!i.problems)return r;r||(r=n.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(t+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(t+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(t+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=t+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(n.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(C5,{fixTables:!0})}function Xn(n){let e=n.selection,t=Ec(n),r=t.node(-1),i=t.start(-1),s=et.get(r),o;return e instanceof Se?o=s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o=s.findCell(t.pos-i),o.tableStart=i,o.map=s,o.table=r,o}function Mv(n,{map:e,tableStart:t,table:r},i){let s=i>0?-1:0;a5(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);n.setNodeMarkup(n.mapping.map(t+a),null,wv(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);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function k5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Mv(n.tr,t,t.left))}return!0}function S5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Mv(n.tr,t,t.right))}return!0}function E5(n,{map:e,table:t,tableStart:r},i){let s=n.mapping.maps.length;for(let o=0;o<e.height;){let l=o*e.width+i,a=e.map[l],c=t.nodeAt(a);if(i>0&&e.map[l-1]==a||i<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(s).map(r+a),null,_i(c.attrs,i-e.colCount(a)));else{let u=n.mapping.slice(s).map(r+a);n.delete(u,u+c.nodeSize)}o+=c.attrs.rowspan}}function T5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let i=t.right-1;E5(r,t,i),i!=t.left;i--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=et.get(t.table);e(r)}return!0}function A5(n,e,t){let r=Mt(e.type.schema).header_cell;for(let i=0;i<n.width;i++)if(e.nodeAt(n.map[i+t*n.width]).type!=r)return!1;return!0}function Ov(n,{map:e,tableStart:t,table:r},i){let s=t;for(let a=0;a<i;a++)s+=r.child(a).nodeSize;let o=[],l=i>0?-1:0;A5(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;n.setNodeMarkup(t+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 n.insert(s,Mt(r.type.schema).row.create(null,o)),n}function M5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Ov(n.tr,t,t.top))}return!0}function O5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Ov(n.tr,t,t.bottom))}return!0}function _5(n,{map:e,table:t,tableStart:r},i){let s=0;for(let a=0;a<i;a++)s+=t.child(a).nodeSize;let o=s+t.child(i).nodeSize,l=n.mapping.maps.length;n.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=t.nodeAt(u).attrs;n.setNodeMarkup(n.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=t.nodeAt(u),f=d.type.create(wt(d.attrs,"rowspan",d.attrs.rowspan-1),d.content),h=e.positionAt(i+1,a,t);n.insert(n.mapping.slice(l).map(r+h),f),a+=d.attrs.colspan-1}}}function N5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let i=t.bottom-1;_5(r,t,i),i!=t.top;i--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=et.get(t.table);e(r)}return!0}function _v(n){let e=n.content;return e.childCount==1&&e.firstChild.isTextblock&&e.firstChild.childCount==0}function D5({width:n,height:e,map:t},r){let i=r.top*n+r.left,s=i,o=(r.bottom-1)*n+r.left,l=i+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[s]==t[s-1]||r.right<n&&t[l]==t[l+1])return!0;s+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[i]==t[i-n]||r.bottom<e&&t[o]==t[o+n])return!0;i++,o++}return!1}function Nv(n,e){let t=n.selection;if(!(t instanceof Se)||t.$anchorCell.pos==t.$headCell.pos)return!1;let r=Xn(n),{map:i}=r;if(D5(i,r))return!1;if(e){let s=n.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{_v(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(wv(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=_v(c)?a+1:u;s.replaceWith(d+r.tableStart,u+r.tableStart,l)}s.setSelection(new Se(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function Dv(n,e){const t=Mt(n.schema);return R5(({node:r})=>t[r.type.spec.tableRole])(n,e)}function R5(n){return(e,t)=>{let r=e.selection,i,s;if(r instanceof Se){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{if(i=s5(r.$from),!i)return!1;s=Rs(r.$from).pos}if(i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(t){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=Xn(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),n({node:i,row:f,col:p}).createAndFill(l[g]))}u.setNodeMarkup(s,n({node:i,row:c.top,col:c.left}),l[0]),r instanceof Se&&u.setSelection(new Se(u.doc.resolve(r.$anchorCell.pos),d&&u.doc.resolve(d))),t(u)}return!0}}function L5(n,e){return function(t,r){if(!Tn(t))return!1;let i=Ec(t);if(i.nodeAfter.attrs[n]===e)return!1;if(r){let s=t.tr;t.selection instanceof Se?t.selection.forEachCell((o,l)=>{o.attrs[n]!==e&&s.setNodeMarkup(l,null,wt(o.attrs,n,e))}):s.setNodeMarkup(i.pos,null,wt(i.nodeAfter.attrs,n,e)),r(s)}return!0}}function I5(n){return function(e,t){if(!Tn(e))return!1;if(t){let r=Mt(e.schema),i=Xn(e),s=e.tr,o=i.map.cellsInRect(n=="column"?new Ds(i.left,0,i.right,i.map.height):n=="row"?new Ds(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);t(s)}return!0}}function Rv(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const s=e.table.nodeAt(r[i]);if(s&&s.type!==t.header_cell)return!1}return!0}function Zo(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?I5(n):function(t,r){if(!Tn(t))return!1;if(r){let i=Mt(t.schema),s=Xn(t),o=t.tr,l=Rv("row",s,i),a=Rv("column",s,i),u=(n==="column"?l:n==="row"?a:!1)?1:0,d=n=="column"?new Ds(0,u,1,s.map.height):n=="row"?new Ds(u,0,s.map.width,1):s,f=n=="column"?a?i.cell:i.header_cell:n=="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}}Zo("row",{useDeprecatedLogic:!0}),Zo("column",{useDeprecatedLogic:!0});let P5=Zo("cell",{useDeprecatedLogic:!0});function F5(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,i=n.before();r>=0;r--){let s=n.node(-1).child(r);if(s.childCount)return i-1-s.lastChild.nodeSize;i-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;let t=n.node(-1);for(let r=n.indexAfter(-1),i=n.after();r<t.childCount;r++){let s=t.child(r);if(s.childCount)return i+1;i+=s.nodeSize}}}function Lv(n){return function(e,t){if(!Tn(e))return!1;let r=F5(Ec(e),n);if(r!=null){if(t){let i=e.doc.resolve(r);t(e.tr.setSelection(ce.between(i,l5(i))).scrollIntoView())}return!0}}}function B5(n,e){let t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}let $5=class{constructor(e,t){this.node=e,this.cellMinWidth=t,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")),ph(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,ph(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function ph(n,e,t,r,i,s){let o=0,l=!0,a=e.firstChild,c=n.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?(t.style.width=o+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=o+"px")}const mn=new We("tableColumnResizing");function j5({handleWidth:n=5,cellMinWidth:e=25,View:t=$5,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 t(l,e,a),new Xo(-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){H5(s,o,n,e,r)},mouseleave(s){V5(s)},mousedown(s,o){z5(s,o,e)}},decorations(s){let o=mn.getState(s);if(o.activeHandle>-1)return G5(s,o.activeHandle)},nodeViews:{}}})}class Xo{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,r=e.getMeta(mn);if(r&&r.setHandle!=null)return new Xo(r.setHandle,null);if(r&&r.setDragging!==void 0)return new Xo(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);ch(e.doc.resolve(i))||(i=null),t=new Xo(i,t.dragging)}return t}}function H5(n,e,t,r,i){let s=mn.getState(n.state);if(!s.dragging){let o=W5(e.target),l=-1;if(o){let{left:a,right:c}=o.getBoundingClientRect();e.clientX-a<=t?l=Iv(n,e,"left"):c-e.clientX<=t&&(l=Iv(n,e,"right"))}if(l!=s.activeHandle){if(!i&&l!==-1){let a=n.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}Fv(n,l)}}}function V5(n){let e=mn.getState(n.state);e.activeHandle>-1&&!e.dragging&&Fv(n,-1)}function z5(n,e,t){let r=mn.getState(n.state);if(r.activeHandle==-1||r.dragging)return!1;let i=n.state.doc.nodeAt(r.activeHandle),s=U5(n,r.activeHandle,i.attrs);n.dispatch(n.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(n.state);c.dragging&&(q5(n,c.activeHandle,Pv(c.dragging,a,t)),n.dispatch(n.state.tr.setMeta(mn,{setDragging:null})))}function l(a){if(!a.which)return o(a);let c=mn.getState(n.state),u=Pv(c.dragging,a,t);K5(n,c.activeHandle,u,t)}return window.addEventListener("mouseup",o),window.addEventListener("mousemove",l),e.preventDefault(),!0}function U5(n,e,{colspan:t,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let s=n.domAtPos(e),l=s.node.childNodes[s.offset].offsetWidth,a=t;if(r)for(let c=0;c<t;c++)r[c]&&(l-=r[c],a--);return l/a}function W5(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Iv(n,e,t){let r=n.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return-1;let{pos:i}=r,s=Rs(n.state.doc.resolve(i));if(!s)return-1;if(t=="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 Pv(n,e,t){let r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function Fv(n,e){n.dispatch(n.state.tr.setMeta(mn,{setHandle:e}))}function q5(n,e,t){let r=n.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=n.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]==t)continue;let p=f.colwidth?f.colwidth.slice():J5(f.colspan);p[h]=t,a.setNodeMarkup(o+d,null,wt(f,"colwidth",p))}a.docChanged&&n.dispatch(a)}function K5(n,e,t,r){let i=n.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=n.domAtPos(i.start(-1)).node;for(;a.nodeName!="TABLE";)a=a.parentNode;ph(s,a.firstChild,a,r,l,t)}function J5(n){let e=[];for(let t=0;t<n;t++)e.push(0);return e}function G5(n,e){let t=[],r=n.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",t.push(ut.widget(d,f))}}return He.create(n.doc,t)}function Y5({allowTableNodeSelection:n=!1}={}){return new je({key:Gr,state:{init(){return null},apply(e,t){let r=e.getMeta(Gr);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;let{deleted:i,pos:s}=e.mapping.mapResult(t);return i?null:s}},props:{decorations:c5,handleDOMEvents:{mousedown:w5},createSelectionBetween(e){if(Gr.getState(e.state)!=null)return e.state.selection},handleTripleClick:b5,handleKeyDown:y5,handlePaste:v5},appendTransaction(e,t,r){return f5(r,Av(r,t),n)}})}function Bv(n,e,t,r,i,s){var u;let o=0,l=!0,a=e.firstChild;const c=n.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?(t.style.width=`${o}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${o}px`)}class Z5{constructor(e,t){vr(this,"node");vr(this,"cellMinWidth");vr(this,"dom");vr(this,"table");vr(this,"colgroup");vr(this,"contentDOM");this.node=e,this.cellMinWidth=t,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")),Bv(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,Bv(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function $v(n,e){return n.createAndFill()}function X5(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function Q5(n,e,t,r,i){const s=X5(n),o=[],l=[];for(let c=0;c<t;c+=1){const u=$v(s.cell);if(u&&l.push(u),r){const d=$v(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 eL(n){return n instanceof Se}const _c=({editor:n})=>{const{selection:e}=n.state;if(!eL(e))return!1;let t=0;const r=Ru(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)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},tL=Ve.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:Z5,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){let t=0,r=!0;try{n.content.firstChild.content.forEach(s=>{if(s.attrs.colwidth)s.attrs.colwidth.forEach(o=>{o?t+=o:(r=!1,t+=this.options.cellMinWidth)});else{r=!1;const o=s.attrs.colspan?s.attrs.colspan:1;t+=this.options.cellMinWidth*o}})}catch{r=!1}return r&&t>0?e.style=`width: ${t}px;`:t&&t>0?e.style=`min-width: ${t}px`:e.style=null,["div",{class:"table-wrapper"},["table",Ce(this.options.HTMLAttributes,e),["tbody",0]]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:i,editor:s})=>{const{selection:o}=r,l=Q5(s.schema,n,e,t);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:n,dispatch:e})=>k5(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>S5(n,e),deleteColumn:()=>({state:n,dispatch:e})=>T5(n,e),addRowBefore:()=>({state:n,dispatch:e})=>M5(n,e),addRowAfter:()=>({state:n,dispatch:e})=>O5(n,e),deleteRow:()=>({state:n,dispatch:e})=>N5(n,e),deleteTable:()=>({state:n,dispatch:e})=>B5(n,e),mergeCells:()=>({state:n,dispatch:e})=>Nv(n,e),splitCell:()=>({state:n,dispatch:e})=>Dv(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>Zo("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>Zo("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>P5(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>Nv(n,e)?!0:Dv(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>L5(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>Lv(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>Lv(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&Av(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=Se.create(e.doc,n.anchorCell,n.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:_c,"Mod-Backspace":_c,Delete:_c,"Mod-Delete":_c}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[j5({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Y5({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:ge(re(n,"tableRole",e))}}});function jv(n,e){if(n==null)return{};var t={},r=Object.keys(n),i,s;for(s=0;s<r.length;s++)i=r[s],!(e.indexOf(i)>=0)&&(t[i]=n[i]);return t}var Hv=typeof window<"u"&&typeof document<"u";function mh(n,e){n&&(typeof n=="function"&&n(e),{}.hasOwnProperty.call(n,"current")&&(n.current=e))}function Vv(){return Hv&&document.createElement("div")}function nL(n){var e={"data-placement":n.placement};return n.referenceHidden&&(e["data-reference-hidden"]=""),n.escaped&&(e["data-escaped"]=""),e}function zv(n,e){if(n===e)return!0;if(typeof n=="object"&&n!=null&&typeof e=="object"&&e!=null){if(Object.keys(n).length!==Object.keys(e).length)return!1;for(var t in n)if(e.hasOwnProperty(t)){if(!zv(n[t],e[t]))return!1}else return!1;return!0}else return!1}function rL(n){var e=[];return n.forEach(function(t){e.find(function(r){return zv(t,r)})||e.push(t)}),e}function iL(n,e){var t,r;return Object.assign({},e,{popperOptions:Object.assign({},n.popperOptions,e.popperOptions,{modifiers:rL([].concat(((t=n.popperOptions)==null?void 0:t.modifiers)||[],((r=e.popperOptions)==null?void 0:r.modifiers)||[]))})})}var gh=Hv?O.useLayoutEffect:O.useEffect;function sL(n){var e=O.useRef();return e.current||(e.current=typeof n=="function"?n():n),e.current}function Uv(n,e,t){t.split(/\s+/).forEach(function(r){r&&n.classList[e](r)})}var oL={name:"className",defaultValue:"",fn:function(e){var t=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}Uv(t,"add",e.props.className)}function s(){r()&&Uv(t,"remove",e.props.className)}return{onCreate:i,onBeforeUpdate:s,onAfterUpdate:i}}};function lL(n){function e(t){var r=t.children,i=t.content,s=t.visible,o=t.singleton,l=t.render,a=t.reference,c=t.disabled,u=c===void 0?!1:c,d=t.ignoreAttributes,f=d===void 0?!0:d;t.__source,t.__self;var h=jv(t,["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],C=O.useState({}),y=C[0],k=C[1],E=O.useState(),T=E[0],N=E[1],_=sL(function(){return{container:Vv(),renders:1}}),A=Object.assign({ignoreAttributes:f},h,{content:_.container});p&&(process.env.NODE_ENV!=="production"&&["trigger","hideOnClick","showOnCreate"].forEach(function(V){A[V]!==void 0&&console.warn(["@tippyjs/react: Cannot specify `"+V+"` 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(X){var we=X.instance;return we.reference===G.currentTarget});J.state.$$activeSingletonInstance=ie.instance,N(ie.content)}}}}]):P,render:function(){return{popper:_.container}}}));var $=[a].concat(r?[r.type]:[]);return gh(function(){var V=a;a&&a.hasOwnProperty("current")&&(V=a.current);var U=n(V||_.ref||Vv(),Object.assign({},R,{plugins:[oL].concat(A.plugins||[])}));return _.instance=U,u&&U.disable(),s&&U.show(),g&&o.hook({instance:U,content:i,props:R,setSingletonContent:N}),S(!0),function(){U.destroy(),o==null||o.cleanup(U)}},$),gh(function(){var V;if(_.renders===1){_.renders++;return}var U=_.instance;U.setProps(iL(U.props,R)),(V=U.popperInstance)==null||V.forceUpdate(),u?U.disable():U.enable(),p&&(s?U.show():U.hide()),g&&o.hook({instance:U,content:i,props:R,setSingletonContent:N})}),gh(function(){var V;if(l){var U=_.instance;U.setProps({popperOptions:Object.assign({},U.props.popperOptions,{modifiers:[].concat((((V=U.props.popperOptions)==null?void 0:V.modifiers)||[]).filter(function(J){var G=J.name;return G!=="$$tippyReact"}),[{name:"$$tippyReact",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(G){var ie,X=G.state,we=(ie=X.modifiersData)==null?void 0:ie.hide;(y.placement!==X.placement||y.referenceHidden!==(we==null?void 0:we.isReferenceHidden)||y.escaped!==(we==null?void 0:we.hasPopperEscaped))&&k({placement:X.placement,referenceHidden:we==null?void 0:we.isReferenceHidden,escaped:we==null?void 0:we.hasPopperEscaped}),X.attributes.popper={}}}])})})}},[y.placement,y.referenceHidden,y.escaped].concat($)),O.createElement(O.Fragment,null,r?O.cloneElement(r,{ref:function(U){_.ref=U,mh(r.ref,U)}}):null,w&&nn.createPortal(l?l(nL(y),T,_.instance):i,_.container))}return e}var aL=function(n,e){return O.forwardRef(function(r,i){var s=r.children,o=jv(r,["children"]);return O.createElement(n,Object.assign({},e,o),s?O.cloneElement(s,{ref:function(a){mh(i,a),mh(s.ref,a)}}):null)})},cL=aL(lL(fi));const uL=[{name:"Add row above",action:n=>n.chain().focus().addRowBefore().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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:n=>n.chain().focus().addRowAfter().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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:n=>n.chain().focus().addColumnBefore().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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:n=>n.chain().focus().addColumnAfter().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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:n=>n.chain().focus().deleteRow().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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:n=>n.chain().focus().deleteColumn().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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:n=>n.chain().focus().toggleHeaderRow().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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:n=>n.chain().focus().toggleHeaderColumn().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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:n=>n.chain().focus().toggleHeaderCell().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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:n=>n.chain().focus().deleteTable().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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"})})}],Wv=({node:n,getPos:e,selected:t,editor:r})=>{const[i,s]=O.useState(!1),o=Ul(),l=O.useRef(null),a=()=>{const{from:u,to:d}=r.state.selection,f=e(),h=f+n.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 D.jsxs(bo,{className:"group",children:[D.jsx(Kg,{as:"span"}),(i||t)&&D.jsx(cL,{appendTo:document.body,trigger:"click",interactive:!0,animation:"shift-toward-subtle",placement:"right-start",content:D.jsx("article",{className:"dropdown",contentEditable:!1,children:D.jsx("ul",{tabIndex:0,className:"dropdown-content fixed menu menu-compact p-2 shadow bg-base-100 rounded-box w-56",style:c(),children:uL.map(u=>D.jsx("li",{children:D.jsxs("button",{type:"button",className:"button",onClick:()=>u.action(r),children:[D.jsx("span",{children:u.icon}),D.jsx("span",{children:u.name})]})},u.name))})}),children:D.jsx("label",{tabIndex:0,className:Fe("trigger-button",{hidden:o}),contentEditable:!1,children:D.jsx(GE,{fontSize:"small"})})})]})},dL=Ve.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",Ce(this.options.HTMLAttributes,n),0]},addNodeView(){return hi(Wv,{as:"td",className:"relative"})}}),fL=Ve.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",Ce(this.options.HTMLAttributes,n),0]},addNodeView(){return hi(Wv,{as:"th",className:"relative"})}}),qv=n=>(n.stopPropagation(),n.preventDefault(),n),hL=function(n){const e=n.scrollHeight>n.clientHeight,r=window.getComputedStyle(n).overflowY.indexOf("hidden")!==-1;return e&&!r},Kv=function(n){return!n||n===document.body?document.body:hL(n)?n:Kv(n.parentNode)},yh=(n,e,t)=>{const r=document.createElement(n);if(!r)throw new Error(`Element with name ${n} can't be created.`);return e&&Object.entries(e).forEach(([i,s])=>r.setAttribute(i,s)),t&&Object.entries(t).forEach(([i,s])=>r.addEventListener(i,s)),r},pL=Ve.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",Ce(this.options.HTMLAttributes,n),0]},addNodeView(){return({editor:n,HTMLAttributes:e,getPos:t})=>{const r=()=>t(),i=Kv(n.options.element);let s=!1;const o={deleteRow:()=>{this.editor.chain().deleteNode("tableRow").focus().run()},selectRow:()=>{const w=r(),S=n.state.doc.resolve(w),C=new se(S);n.view.dispatch(n.state.tr.setSelection(C))}},l=()=>{s=!0},a=()=>{s=!1},c=yh("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&&qv(w),o.selectRow()},mouseenter:()=>{l()},mouseover:()=>{l()},mouseleave:()=>{a(),f()}}),u=yh("button",{class:"text-sm px-1 absolute -translate-x-[125%] hover:active:-translate-x-[125%] mr-2"},{click:w=>{w&&qv(w),o.deleteRow()}}),d=()=>{g(),c.classList.remove("hidden")},f=()=>{setTimeout(()=>{s||c.classList.add("hidden")},100)},h=yh("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),n.on("selectionUpdate",g),n.on("update",g),i==null||i.addEventListener("scroll",g),document.addEventListener("scroll",g),{dom:h,contentDOM:h,destroy:()=>{c.remove(),n.off("selectionUpdate",g),n.off("update",g),i==null||i.removeEventListener("scroll",g),document.removeEventListener("scroll",g)}}}}}),mL=[tL.configure({resizable:!0}),dL,fL,pL],gL=Hb.extend({content:"(dBlock|columns)+"});function Jv({types:n,node:e}){return e!=null&&e.type?Array.isArray(n)&&n.includes(e.type)||e.type===n:!1}const yL=Ue.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const n=new We(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>this.options.notAfter.includes(t.name));return[new je({key:n,appendTransaction:(t,r,i)=>{const{doc:s,tr:o,schema:l}=i,a=n.getState(i),c=s.content.size,u=l.nodes[this.options.node];if(a)return o.insert(c,u.create())},state:{init:(t,r)=>{const i=r.tr.doc.lastChild;return!Jv({node:i,types:e})},apply:(t,r)=>{var s,o,l;if(!t.docChanged)return r;const i=(l=(o=(s=t.doc.lastChild)==null?void 0:s.content)==null?void 0:o.content)==null?void 0:l[0];return!Jv({node:i,types:e})}}})]}}),bL=({node:n,editor:e,getPos:t})=>{const[r,i]=O.useState(""),s=Ul(),o=["https://twitter.com","https://x.com"],l=()=>{switch(n.attrs.data){case"twitter":return D.jsx(f0,{});case"iframe":return D.jsx(h0,{});default:return D.jsx(sT,{})}},a=()=>{switch(n.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 C=r.match(/src="([^"]*)"/);C&&C.length>0&&(p=C[1])}else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(r):{const C=r.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);C&&C.length>0&&(p=`https://www.youtube.com/embed/${C[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(r):{const C=r.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);C&&C.length>0&&(p=`https://player.vimeo.com/video/${C[1]}`);break}default:{alert("Please enter a valid url");return}}const g=640,v=360,w=t(),S=w+n.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=t(),C=S+n.nodeSize;p&&(e==null||e.chain().focus(S).deleteRange({from:S,to:C}).setTweetEmbed({tweetId:p}).run())},f=y1(()=>{switch(n.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()},[]),D.jsx(bo,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:!s&&D.jsxs("div",{className:"relative w-full",children:[D.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:l()}),D.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"})]})})},vL=Ve.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(bL)},parseHTML(){return[{tag:"div[data-action-node]"}]},renderHTML({HTMLAttributes:n}){return console.log("action"),["div",Ce(n,{"data-action-node":""}),0]},addCommands(){return{setActionButton:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{data:n},content:[]})}}}),wL=[u_,a_.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}),d_.configure({types:["heading","paragraph"]}),X_,L_.configure({HTMLAttributes:{class:"text-blue-500 font-bold transition-colors cursor-pointer select-text pointer-events-auto"},openOnClick:!0}),I_.configure({placeholder:()=>"",includeChildren:!0,showOnlyCurrent:!0}),B_.configure({multicolor:!0}),Z_,V_.configure({HTMLAttributes:{class:"select-text pointer-events-auto"}}),c_,tN,$_.configure({HTMLAttributes:{class:"not-prose space-y-4 ml-2"}}),H_.configure({HTMLAttributes:{class:"flex items-start"},nested:!0}),Vb.configure({width:3,color:"#d1d5db"}),zb,e5,yL,gL,...mL,uN.configure({uploadFn:ST}),eN,nN,oN,vL.extend({addInputRules(){return[Gv(/^(?:twt|###|___\s|\*\*\*\s)$/,"twitter",this.type),Gv(/^(?:ytb|@@@|___\s|\*\*\*\s)$/,"iframe",this.type)]}}),Q_],Gv=(n,e,t)=>new io({find:n,handler:({state:r,range:i,commands:s})=>{const o={data:e},{tr:l}=r,a=i.from,c=i.to;l.insert(a-1,t.create(o)).delete(l.mapping.map(a),l.mapping.map(c)),s.focus(c-1)}}),Yv=["#30bced","#6eeb83","#fa69d1","#ecd444","#ee6352","#db3041","#0ad7f2","#1bff39"],CL=({isPreviewMode:n,data:e,enableCollaboration:t,collaborationId:r})=>{const[i,s]=O.useState({plugin:{title:"Untitled"}}),[o]=O.useState(new as),l=O.useRef(null),a=[...wL,d3.configure({document:o})];O.useEffect(()=>{if(r&&t){const f=new BO(r||"default-room",o,{signaling:["wss://fileverse-signaling-server-0529292ff51c.herokuapp.com/"]});return l.current=f,()=>{f.destroy(),o.destroy()}}},[r,o]),O.useEffect(()=>{t&&r&&(a.some(h=>h.name==="collaborationCursor")||a.push(f3.configure({provider:l.current,user:{color:Yv[Math.floor(Math.random()*Yv.length)]}})))},[l.current]);const c=FE({extensions:a,editorProps:$O,autofocus:"start"}),u=O.useRef(null),d=f=>{var h;(h=u.current)!=null&&h.contains(f.target)||c==null||c.chain().focus().run()};return O.useEffect(()=>{c==null||c.chain().focus()},[]),O.useEffect(()=>{c==null||c.setEditable(!n)},[n]),O.useEffect(()=>{e&&c&&(c==null||c.commands.setContent(e.editorJSONData),s(e.metaData))},[e,c]),{editor:c,pluginMetaData:i,setPluginMetaData:s,focusEditor:d,ref:u}},xL=({isPreviewMode:n=!1,onPublish:e,data:t,togglePreviewMode:r,enableCollaboration:i,collaborationId:s})=>{const{editor:o,pluginMetaData:l,focusEditor:a,setPluginMetaData:c,ref:u}=CL({isPreviewMode:n,data:t,enableCollaboration:i,collaborationId:s,onPublish:e,togglePreviewMode:r});return o?D.jsx("div",{"data-cy":"single-webpage",className:"bg-[#f9fbfd]",children:D.jsx("div",{className:"h-full flex flex-col overflow-scroll no-scrollbar",children:D.jsxs("div",{className:"w-full h-screen",children:[D.jsx("div",{className:"h-fit relative bg-[#ffffff]",children:D.jsxs("div",{className:"flex items-center justify-center pl-4 pr-4 border-b-1 border gap-2 h-16",children:[D.jsx("div",{className:"grow",children:D.jsx(iw,{isPreviewMode:n,metaData:l,setMetaData:c})}),!n&&D.jsx("div",{className:"grow relative",children:D.jsx(jT,{editor:o})}),D.jsx("div",{children:D.jsx(zl,{onClick:()=>r(n),children:n?"Edit":"Preview"})}),e&&D.jsx("div",{children:D.jsx(zl,{onClick:()=>e({metaData:l,editorJSONData:o.getJSON()}),children:"Publish"})})]})}),D.jsx("main",{className:"h-screen lg:h-full w-full rounded-[8px] flex flex-col justify-start items-center gap-2",children:D.jsx("div",{onClick:a,className:"w-full flex justify-center relative",children:D.jsx("div",{className:"p-12 sm:p-[96px] mt-4 min-h-[900px] shadow-inner bg-white overflow-scroll no-scrollbar rounded-md w-full sm:w-[70%] max-w-[856px]",children:D.jsxs("div",{ref:u,className:"w-full pt-4 h-full",children:[!n&&D.jsxs("div",{children:[D.jsx(NT,{editor:o}),D.jsx(BT,{editor:o,appendTo:u})]}),D.jsx($T,{isPreviewMode:n,children:D.jsx(IE,{editor:o})})]})})})})]})})}):D.jsxs("div",{className:"w-screen h-screen flex flex-col gap-4 justify-center items-center",children:[D.jsx(N0,{}),D.jsx("p",{children:"Loading Editor..."})]})};Bt.DdocEditor=xL,Object.defineProperty(Bt,Symbol.toStringTag,{value:"Module"})});
373
+ `)},BR=0,_s=[];function $R(n){var e=le.useRef([]),t=le.useRef([0,0]),r=le.useRef(),i=le.useState(BR++)[0],s=le.useState(function(){return ov()})[0],o=le.useRef(n);le.useEffect(function(){o.current=n},[n]),le.useEffect(function(){if(n.inert){document.body.classList.add("block-interactivity-".concat(i));var g=oR([n.lockRef.current],(n.shards||[]).map(hv),!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))})}}},[n.inert,n.lockRef.current,n.shards]);var l=le.useCallback(function(g,v){if("touches"in g&&g.touches.length===2)return!o.current.allowPinchZoom;var w=Cc(g),S=t.current,x="deltaX"in g?g.deltaX:S[0]-w[0],y="deltaY"in g?g.deltaY:S[1]-w[1],k,E=g.target,T=Math.abs(x)>Math.abs(y)?"h":"v";if("touches"in g&&T==="h"&&E.type==="range")return!1;var N=cv(T,E);if(!N)return!0;if(N?k=T:(k=T==="v"?"h":"v",N=cv(T,E)),!N)return!1;if(!r.current&&"changedTouches"in g&&(x||y)&&(r.current=k),!k)return!0;var _=r.current||k;return IR(_,v,g,_==="h"?x:y,!0)},[]),a=le.useCallback(function(g){var v=g;if(!(!_s.length||_s[_s.length-1]!==s)){var w="deltaY"in v?fv(v):Cc(v),S=e.current.filter(function(k){return k.name===v.type&&k.target===v.target&&PR(k.delta,w)})[0];if(S&&S.should){v.cancelable&&v.preventDefault();return}if(!S){var x=(o.current.shards||[]).map(hv).filter(Boolean).filter(function(k){return k.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){t.current=Cc(g),r.current=void 0},[]),d=le.useCallback(function(g){c(g.type,fv(g),g.target,l(g,n.lockRef.current))},[]),f=le.useCallback(function(g){c(g.type,Cc(g),g.target,l(g,n.lockRef.current))},[]);le.useEffect(function(){return _s.push(s),n.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",a,Os),document.addEventListener("touchmove",a,Os),document.addEventListener("touchstart",u,Os),function(){_s=_s.filter(function(g){return g!==s}),document.removeEventListener("wheel",a,Os),document.removeEventListener("touchmove",a,Os),document.removeEventListener("touchstart",u,Os)}},[]);var h=n.removeScrollBar,p=n.inert;return le.createElement(le.Fragment,null,p?le.createElement(s,{styles:FR(i)}):null,h?le.createElement(MR,{gapMode:"margin"}):null)}const jR=mR(sv,$R);var pv=le.forwardRef(function(n,e){return le.createElement(wc,Zn({},n,{ref:e,sideCar:jR}))});pv.classNames=wc.classNames;const mv="Popover",[gv,o4]=v1(mv,[G1]),oh=G1(),[HR,Ns]=gv(mv),VR=n=>{const{__scopePopover:e,children:t,open:r,defaultOpen:i,onOpenChange:s,modal:o=!1}=n,l=oh(e),a=O.useRef(null),[c,u]=O.useState(!1),[d=!1,f]=eR({prop:r,defaultProp:i,onChange:s});return O.createElement(GD,l,O.createElement(HR,{scope:e,contentId:FN(),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},t))},zR="PopoverTrigger",UR=O.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,i=Ns(zR,t),s=oh(t),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":bv(i.open)},r,{ref:o,onClick:Ur(n.onClick,i.onOpenToggle)}));return i.hasCustomAnchor?l:O.createElement(YD,dt({asChild:!0},s),l)}),WR="PopoverPortal",[l4,qR]=gv(WR,{forceMount:void 0}),Yo="PopoverContent",KR=O.forwardRef((n,e)=>{const t=qR(Yo,n.__scopePopover),{forceMount:r=t.forceMount,...i}=n,s=Ns(Yo,n.__scopePopover);return O.createElement(ev,{present:r||s.open},s.modal?O.createElement(JR,dt({},i,{ref:e})):O.createElement(GR,dt({},i,{ref:e})))}),JR=O.forwardRef((n,e)=>{const t=Ns(Yo,n.__scopePopover),r=O.useRef(null),i=Ai(e,r),s=O.useRef(!1);return O.useEffect(()=>{const o=r.current;if(o)return sR(o)},[]),O.createElement(pv,{as:$f,allowPinchZoom:!0},O.createElement(yv,dt({},n,{ref:i,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ur(n.onCloseAutoFocus,o=>{var l;o.preventDefault(),s.current||(l=t.triggerRef.current)===null||l===void 0||l.focus()}),onPointerDownOutside:Ur(n.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(n.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})))}),GR=O.forwardRef((n,e)=>{const t=Ns(Yo,n.__scopePopover),r=O.useRef(!1),i=O.useRef(!1);return O.createElement(yv,dt({},n,{ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var o;if((o=n.onCloseAutoFocus)===null||o===void 0||o.call(n,s),!s.defaultPrevented){var l;r.current||(l=t.triggerRef.current)===null||l===void 0||l.focus(),s.preventDefault()}r.current=!1,i.current=!1},onInteractOutside:s=>{var o,l;(o=n.onInteractOutside)===null||o===void 0||o.call(n,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=s.target;((l=t.triggerRef.current)===null||l===void 0?void 0:l.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}}))}),yv=O.forwardRef((n,e)=>{const{__scopePopover:t,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:o,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onInteractOutside:u,...d}=n,f=Ns(Yo,t),h=oh(t);return AN(),O.createElement(MN,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s},O.createElement(SN,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:l,onPointerDownOutside:a,onFocusOutside:c,onDismiss:()=>f.onOpenChange(!1)},O.createElement(ZD,dt({"data-state":bv(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)"}}))))}),YR="PopoverClose",ZR=O.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,i=Ns(YR,t);return O.createElement(Mi.button,dt({type:"button"},r,{ref:e,onClick:Ur(n.onClick,()=>i.onOpenChange(!1))}))});function bv(n){return n?"open":"closed"}const XR=VR,QR=UR,e5=KR,kc=ZR,Sc=({children:n,isActive:e,onClick:t,disabled:r,className:i})=>{const s=Fe("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 D.jsx("button",{className:s,disabled:r,onClick:t,children:n})},t5=(n,e,t)=>{const r=O.useCallback(()=>{const l=n.chain();l.setNodeSelection(t).unsetAllMarks(),(e==null?void 0:e.type.name)!=="paragraph"&&l.setParagraph(),l.run()},[n,t,e==null?void 0:e.type.name]),i=O.useCallback(()=>{n.commands.setNodeSelection(t);const{$anchor:l}=n.state.selection,a=l.node(1)||n.state.selection.node;n.chain().setMeta("hideDragHandle",!0).insertContentAt(t+((e==null?void 0:e.nodeSize)||0),a.toJSON()).run()},[n,t,e==null?void 0:e.nodeSize]),s=O.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).run(),document.execCommand("copy"),alert("copied")},[n,t]),o=O.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).deleteSelection().run()},[n,t]);return{resetTextFormatting:r,duplicateNode:i,copyNodeToClipboard:s,deleteNode:o}},n5=({node:n,getPos:e,editor:t,deleteNode:r})=>{const[i,s]=O.useState(!1),o=t5(t,n,e()),l=Ul(),a=["https://twitter.com","https://x.com"],c=O.useMemo(()=>{const{content:_}=n.content;return _[0].type.name==="table"},[n.content]),u=O.useMemo(()=>{var A;const{content:_}=n.content;return(A=_[0].content.content[0])==null?void 0:A.text},[n.content]),d=O.useMemo(()=>{var A;const{content:_}=n.content;return(A=_[0].content.content[1])==null?void 0:A.text},[n.content]),f=O.useMemo(()=>{const{content:_}=n.content;return _[0].content.content.find(A=>{var R;return(R=A==null?void 0:A.text)==null?void 0:R.match(/\/status\/([0-9]*)/)})},[n.content]),h=()=>{if(!u)return;let _=u;if(u.includes("<iframe"))_=d;else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(u):{const V=u.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);V&&V.length>0&&(_=`https://www.youtube.com/embed/${V[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(u):{const V=u.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);V&&V.length>0&&(_=`https://player.vimeo.com/video/${V[1]}`);break}default:return}const A=640,R=360,P=e(),$=P+n.nodeSize;_&&(t==null||t.chain().focus(P).deleteRange({from:P===0?P:P+1,to:$}).setIframe({src:_,width:A,height:R}).run())},p=_=>{const A=_.match(/\/status\/([0-9]*)/);return A&&A.length>0?A[1]:null},g=()=>{if(!u)return;let _=u;const A=a.some(V=>u.includes(V)),R=p(u);A&&R?_=R:f&&(_=p(f.text));const P=e(),$=P+n.nodeSize;_&&(t==null||t.chain().focus(P).deleteRange({from:P===2?P:P+1,to:$}).setTweetEmbed({tweetId:_}).run())},v=()=>{const _=e()+n.nodeSize;t.commands.insertContentAt(_,{type:"dBlock",content:[{type:"paragraph"}]})},w=()=>{const _=e();t.commands.insertContentAt(_,{type:"dBlock",content:[{type:"paragraph"}]})},S=()=>{r()},x=_=>{_.altKey?k():y()},y=()=>{v()},k=()=>{w()},E=_=>{_.altKey&&S()},N=y1(()=>{if(a.some(_=>u.includes(_))||f!=null&&f.text){g();return}else{h();return}},1e3);return O.useEffect(()=>{u&&N()},[u]),D.jsxs(bo,{as:"div",className:Fe("flex gap-2 group w-full relative justify-center items-start",l&&"pointer-events-none",c&&"2xl:ml-4 pointer-events-auto"),children:[D.jsxs("section",{className:"lg:flex gap-1 hidden","aria-label":"left-menu",contentEditable:!1,children:[D.jsx(T0,{content:D.jsxs("div",{className:"flex flex-col w-40",children:[D.jsx("div",{className:"text-xs",children:"Click to add below"}),D.jsx("div",{className:"text-xs",children:"Opt + Click to add above"})]}),children:D.jsx("div",{className:`d-block-button cursor-pointer ${!l&&"group-hover:opacity-100"}`,contentEditable:!1,onClick:x,children:D.jsx(rT,{size:18})})}),D.jsxs(XR,{open:i,onOpenChange:s,children:[D.jsx(QR,{asChild:!0,children:D.jsx("div",{className:`d-block-button cursor-pointer ${!l&&"group-hover:opacity-100"}`,contentEditable:!1,draggable:!0,"data-drag-handle":!0,onClick:E,children:D.jsx(YE,{size:18})})}),D.jsx(e5,{side:"bottom",align:"start",sideOffset:8,className:"z-10",children:D.jsxs(ld,{className:"p-2 flex flex-col min-w-[16rem]",children:[D.jsx(kc,{children:D.jsxs(Sc,{onClick:o.resetTextFormatting,children:[D.jsx(iT,{size:18}),"Clear formatting"]})}),D.jsx(kc,{children:D.jsxs(Sc,{onClick:o.copyNodeToClipboard,children:[D.jsx(qE,{size:18}),"Copy to clipboard"]})}),D.jsx(kc,{children:D.jsxs(Sc,{onClick:o.duplicateNode,children:[D.jsx(JE,{size:18}),"Duplicate"]})}),D.jsx(vo.Divider,{horizontal:!0}),D.jsx(kc,{children:D.jsxs(Sc,{onClick:o.deleteNode,className:"text-red-500 hover:bg-red-500 bg-opacity-10 hover:bg-opacity-20",children:[D.jsx(cT,{size:18}),"Delete"]})})]})})]})]}),D.jsx(Kg,{className:Fe("node-view-content w-full",{"is-table min-w-auto":c})})]})},r5=Ve.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:n}){return["div",xe(n,{"data-type":"d-block"}),0]},addCommands(){return{setDBlock:n=>({state:e,chain:t})=>{const{selection:{from:r}}=e,i=n!==void 0||n!==null?r:n;return t().insertContentAt(i,{type:this.name,content:[{type:"paragraph"}]}).focus(i+2).run()},mergeDBlocksIntoList:n=>({state:e,dispatch:t})=>{if(!t)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[n].create(null,o);return l?(s=s.replaceRangeWith(r,i,l),t(s),!0):!1},splitListToDBlocks:n=>({state:e,dispatch:t})=>{if(!t)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===n){const a=e.schema.nodes[this.name].create(null,o.content);s=s.insert(l,a)}}),t(s),!0}}},addNodeView(){return hi(n5)},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setDBlock(),Enter:({editor:n})=>{var c;const{selection:{$head:e,from:t,to:r},doc:i}=n.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<=t&&r<=h&&(o=h,l=u.type.name),!1});const a=(c=i.slice(t,o))==null?void 0:c.toJSON().content;try{return l==="codeBlock"?n.chain().insertContentAt({from:t,to:o},`
374
+ `).focus(o+1).run():["columns","heading"].includes(l)?n.chain().insertContent({type:"dBlock",content:[{type:"paragraph"}]}).focus().run():n.chain().insertContentAt({from:t,to:o},{type:this.name,content:a}).focus(t+4).run()}catch(u){return console.error(`Error inserting content into dBlock node: ${u}`),!1}}}}});let lh,ah;if(typeof WeakMap<"u"){let n=new WeakMap;lh=e=>n.get(e),ah=(e,t)=>(n.set(e,t),t)}else{let n=[],e=10,t=0;lh=r=>{for(let i=0;i<n.length;i+=2)if(n[i]==r)return n[i+1]},ah=(r,i)=>(t==e&&(t=0),n[t++]=r,n[t++]=i)}class Ds{constructor(e,t,r,i){this.left=e,this.top=t,this.right=r,this.bottom=i}}class et{constructor(e,t,r,i){this.width=e,this.height=t,this.map=r,this.problems=i}findCell(e){for(let t=0;t<this.map.length;t++){let r=this.map[t];if(r!=e)continue;let i=t%this.width,s=t/this.width|0,o=i+1,l=s+1;for(let a=1;o<this.width&&this.map[t+a]==r;a++)o++;for(let a=1;l<this.height&&this.map[t+this.width*a]==r;a++)l++;return new Ds(i,s,o,l)}throw new RangeError("No cell with offset "+e+" found")}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError("No cell with offset "+e+" found")}nextCell(e,t,r){let{left:i,right:s,top:o,bottom:l}=this.findCell(e);return t=="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,t){let{left:r,right:i,top:s,bottom:o}=this.findCell(e),{left:l,right:a,top:c,bottom:u}=this.findCell(t);return new Ds(Math.min(r,l),Math.min(s,c),Math.max(i,a),Math.max(o,u))}cellsInRect(e){let t=[],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)&&t.push(l))}return t}positionAt(e,t,r){for(let i=0,s=0;;i++){let o=s+r.child(i).nodeSize;if(i==e){let l=t+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 lh(e)||ah(e,i5(e))}}function i5(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);let e=s5(n),t=n.childCount,r=[],i=0,s=null,o=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){let d=n.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>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:w-x});break}let y=i+x*e;for(let k=0;k<v;k++){r[y+k]==0?r[y+k]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:v-k});let E=S&&S[k];if(E){let T=(y+k)%e*2,N=o[T];N==null||N!=E&&o[T+1]==1?(o[T]=E,o[T+1]=1):N==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,t,r,s),a=!1;for(let c=0;!a&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(a=!0);return a&&o5(l,o,n),l}function s5(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){let i=n.child(r),s=0;if(t)for(let o=0;o<r;o++){let l=n.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&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function o5(n,e,t){n.problems||(n.problems=[]);for(let r=0,i={};r<n.map.length;r++){let s=n.map[r];if(i[s])continue;i[s]=!0;let o=t.nodeAt(s),l=null;for(let a=0;a<o.attrs.colspan;a++){let c=(r+a)%n.width,u=e[c*2];u!=null&&(!o.attrs.colwidth||o.attrs.colwidth[a]!=u)&&((l||(l=l5(o.attrs)))[a]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function l5(n){if(n.colwidth)return n.colwidth.slice();let e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Mt(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(let t in n.nodes){let r=n.nodes[t],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const Gr=new We("selectingCells");function Rs(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function a5(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Tn(n){let e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Ec(n){let e=n.selection;return e.$anchorCell?e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell:e.node&&e.node.type.spec.tableRole=="cell"?e.$anchor:Rs(e.$head)||c5(e.$head)}function c5(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function ch(n){return n.parent.type.spec.tableRole=="row"&&n.nodeAfter}function u5(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function uh(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function vv(n,e,t){let r=n.start(-1),s=et.get(n.node(-1)).nextCell(n.pos-r,e,t);return s==null?null:n.node(0).resolve(r+s)}function wt(n,e,t){let r={};for(let i in n)r[i]=n[i];return r[e]=t,r}function _i(n,e,t=1){let r=wt(n,"colspan",n.colspan-t);return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}function wv(n,e,t=1){let r=wt(n,"colspan",n.colspan+t);if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<t;i++)r.colwidth.splice(e,0,0)}return r}function d5(n,e,t){let r=Mt(e.type.schema).header_cell;for(let i=0;i<n.height;i++)if(e.nodeAt(n.map[t+i*n.width]).type!=r)return!1;return!0}class Se extends ue{constructor(e,t=e){let r=e.node(-1),i=et.get(r),s=e.start(-1),o=i.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=i.cellsInRect(o).filter(u=>u!=t.pos-s);a.unshift(t.pos-s);let c=a.map(u=>{let d=r.nodeAt(u),f=u+s+1;return new Jc(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let r=e.resolve(t.map(this.$anchorCell.pos)),i=e.resolve(t.map(this.$headCell.pos));if(ch(r)&&ch(i)&&uh(r,i)){let s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?Se.rowSelection(r,i):s&&this.isColSelection()?Se.colSelection(r,i):new Se(r,i)}return ce.between(r,i)}content(){let e=this.$anchorCell.node(-1),t=et.get(e),r=this.$anchorCell.start(-1),i=t.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*t.width+i.left,d=i.left;d<i.right;d++,u++){let f=t.map[u];if(!s[f]){s[f]=!0;let h=t.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,t=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:t)}let s=ue.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new Y(W.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),r=et.get(t),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(t.nodeAt(s[o]),i+s[o])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let r=et.get(e.node(-1)),i=e.start(-1),s=r.findCell(e.pos-i),o=r.findCell(t.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&&(t=l.resolve(i+r.map[r.width*(r.height-1)+o.right-1]))):(o.top>0&&(t=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 Se(e,t)}isRowSelection(){let e=et.get(this.$anchorCell.node(-1)),t=this.$anchorCell.start(-1),r=e.colCount(this.$anchorCell.pos-t),i=e.colCount(this.$headCell.pos-t);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 Se&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let r=et.get(e.node(-1)),i=e.start(-1),s=r.findCell(e.pos-i),o=r.findCell(t.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&&(t=l.resolve(i+r.map[r.width*(o.top+1)-1]))):(o.left>0&&(t=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 Se(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Se(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new Se(e.resolve(t),e.resolve(r))}getBookmark(){return new dh(this.$anchorCell.pos,this.$headCell.pos)}}Se.prototype.visible=!1,ue.jsonID("cell",Se);class dh{constructor(e,t){this.anchor=e,this.head=t}map(e){return new dh(e.map(this.anchor),e.map(this.head))}resolve(e){let t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&uh(t,r)?new Se(t,r):ue.near(r,1)}}function f5(n){if(!(n.selection instanceof Se))return null;let e=[];return n.selection.forEachCell((t,r)=>{e.push(ut.node(r,r+t.nodeSize,{class:"selectedCell"}))}),He.create(n.doc,e)}function h5({$from:n,$to:e}){if(n.pos==e.pos||n.pos<n.pos-6)return!1;let t=n.pos,r=e.pos,i=n.depth;for(;i>=0&&!(n.after(i+1)<n.end(i));i--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(i).type.spec.tableRole)}function p5({$from:n,$to:e}){let t,r;for(let i=n.depth;i>0;i--){let s=n.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=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 t!==r&&e.parentOffset===0}function m5(n,e,t){let r=(e||n).selection,i=(e||n).doc,s,o;if(r instanceof se&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=Se.create(i,r.from);else if(o=="row"){let l=i.resolve(r.from+1);s=Se.rowSelection(l,l)}else if(!t){let l=et.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=Se.create(i,a+1,c)}}else r instanceof ce&&h5(r)?s=ce.create(i,r.from):r instanceof ce&&p5(r)&&(s=ce.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}function g5(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.firstChild.type.spec.tableRole=="table");)t--,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,t-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=fh(Mt(o).row,new Y(c,u,d)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?fh(Mt(o).row,new Y(e,t,r)).content:e);else return null;return y5(o,l)}function y5(n,e){let t=[];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++)t[c]=(t[c]||0)+a}}let r=0;for(let i=0;i<t.length;i++)r=Math.max(r,t[i]);for(let i=0;i<t.length;i++)if(i>=e.length&&e.push(W.empty),t[i]<r){let s=Mt(n).cell.createAndFill(),o=[];for(let l=t[i];l<r;l++)o.push(s);e[i]=e[i].append(W.from(o))}return{height:e.length,width:r,rows:e}}function fh(n,e){let t=n.createAndFill();return new qc(t).replace(0,t.content.size,e).doc}function b5({width:n,height:e,rows:t},r,i){if(n!=r){let s=[],o=[];for(let l=0;l<t.length;l++){let a=t[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))}t=o,n=r}if(e!=i){let s=[];for(let o=0,l=0;o<i;o++,l++){let a=[],c=t[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))}t=s,e=i}return{width:n,height:e,rows:t}}function v5(n,e,t,r,i,s,o){let l=n.doc.type.schema,a=Mt(l),c,u;if(i>e.width)for(let d=0,f=0;d<e.height;d++){let h=t.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);n.insert(n.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:t.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);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),h)}return!!(c||u)}function xv(n,e,t,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=t.nodeAt(d),{top:h,left:p}=e.findCell(d);n.setNodeMarkup(n.mapping.slice(l).map(d+r),null,wt(f.attrs,"rowspan",o-h)),n.insert(n.mapping.slice(l).map(e.positionAt(o,p,t)),f.type.createAndFill(wt(f.attrs,"rowspan",h+f.attrs.rowspan-o))),c+=f.attrs.colspan-1}}return a}function Cv(n,e,t,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=t.nodeAt(d),h=e.colCount(d),p=n.mapping.slice(l).map(d+r);n.setNodeMarkup(p,null,_i(f.attrs,o-h,f.attrs.colspan-(o-h))),n.insert(p+f.nodeSize,f.type.createAndFill(_i(f.attrs,0,o-h))),c+=f.attrs.rowspan-1}}return a}function kv(n,e,t,r,i){let s=t?n.doc.nodeAt(t-1):n.doc,o=et.get(s),{top:l,left:a}=r,c=a+i.width,u=l+i.height,d=n.tr,f=0;function h(){s=t?d.doc.nodeAt(t-1):d.doc,o=et.get(s),f=d.mapping.maps.length}v5(d,o,s,t,c,u,f)&&h(),xv(d,o,s,t,a,c,l,f)&&h(),xv(d,o,s,t,a,c,u,f)&&h(),Cv(d,o,s,t,l,u,a,f)&&h(),Cv(d,o,s,t,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+t),d.mapping.slice(f).map(v+t),new Y(i.rows[p-l],0,0))}h(),d.setSelection(new Se(d.doc.resolve(t+o.positionAt(l,a,s)),d.doc.resolve(t+o.positionAt(u-1,c-1,s)))),e(d)}const w5=ku({ArrowLeft:Ac("horiz",-1),ArrowRight:Ac("horiz",1),ArrowUp:Ac("vert",-1),ArrowDown:Ac("vert",1),"Shift-ArrowLeft":Mc("horiz",-1),"Shift-ArrowRight":Mc("horiz",1),"Shift-ArrowUp":Mc("vert",-1),"Shift-ArrowDown":Mc("vert",1),Backspace:Oc,"Mod-Backspace":Oc,Delete:Oc,"Mod-Delete":Oc});function Tc(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Ac(n,e){return(t,r,i)=>{let s=t.selection;if(s instanceof Se)return Tc(t,r,ue.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;let o=Sv(i,n,e);if(o==null)return!1;if(n=="horiz")return Tc(t,r,ue.near(t.doc.resolve(s.head+e),e));{let l=t.doc.resolve(o),a=vv(l,n,e),c;return a?c=ue.near(a,1):e<0?c=ue.near(t.doc.resolve(l.before(-1)),-1):c=ue.near(t.doc.resolve(l.after(-1)),1),Tc(t,r,c)}}}function Mc(n,e){return(t,r,i)=>{let s=t.selection;if(!(s instanceof Se)){let l=Sv(i,n,e);if(l==null)return!1;s=new Se(t.doc.resolve(l))}let o=vv(s.$headCell,n,e);return o?Tc(t,r,new Se(s.$anchorCell,o)):!1}}function Oc(n,e){let t=n.selection;if(!(t instanceof Se))return!1;if(e){let r=n.tr,i=Mt(n.schema).cell.createAndFill().content;t.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 x5(n,e){let t=n.state.doc,r=Rs(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new Se(r))),!0):!1}function C5(n,e,t){if(!Tn(n.state))return!1;let r=g5(t),i=n.state.selection;if(i instanceof Se){r||(r={width:1,height:1,rows:[W.from(fh(Mt(n.state.schema).cell,t))]});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=b5(r,l.right-l.left,l.bottom-l.top),kv(n.state,n.dispatch,o,l,r),!0}else if(r){let s=Ec(n.state),o=s.start(-1);return kv(n.state,n.dispatch,o,et.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function k5(n,e){if(e.ctrlKey||e.metaKey)return;let t=Ev(n,e.target),r;if(e.shiftKey&&n.state.selection instanceof Se)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&t&&(r=Rs(n.state.selection.$anchor))!=null&&hh(n,e).pos!=r.pos)i(r,e),e.preventDefault();else if(!t)return;function i(l,a){let c=hh(n,a),u=Gr.getState(n.state)==null;if(!c||!uh(l,c))if(u)c=l;else return;let d=new Se(l,c);if(u||!n.state.selection.eq(d)){let f=n.state.tr.setSelection(d);u&&f.setMeta(Gr,l.pos),n.dispatch(f)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",o),Gr.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Gr,-1))}function o(l){let a=Gr.getState(n.state),c;if(a!=null)c=n.state.doc.resolve(a);else if(Ev(n,l.target)!=t&&(c=hh(n,e),!c))return s();c&&i(c,l)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",o)}function Sv(n,e,t){if(!(n.state.selection instanceof ce))return null;let{$head:r}=n.state.selection;for(let i=r.depth-1;i>=0;i--){let s=r.node(i);if((t<0?r.index(i):r.indexAfter(i))!=(t<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"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Ev(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e}function hh(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Rs(n.state.doc.resolve(t.pos)):null}const S5=new We("fix-tables");function Tv(n,e,t,r){let i=n.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(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<i&&n.child(l).sameMarkup(a)?Tv(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function Av(n,e){let t,r=(i,s)=>{i.type.spec.tableRole=="table"&&(t=E5(n,i,s,t))};return e?e.doc!=n.doc&&Tv(e.doc,n.doc,0,r):n.doc.descendants(r),t}function E5(n,e,t,r){let i=et.get(e);if(!i.problems)return r;r||(r=n.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(t+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(t+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(t+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=t+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(n.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(S5,{fixTables:!0})}function Xn(n){let e=n.selection,t=Ec(n),r=t.node(-1),i=t.start(-1),s=et.get(r),o;return e instanceof Se?o=s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):o=s.findCell(t.pos-i),o.tableStart=i,o.map=s,o.table=r,o}function Mv(n,{map:e,tableStart:t,table:r},i){let s=i>0?-1:0;d5(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);n.setNodeMarkup(n.mapping.map(t+a),null,wv(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);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function T5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Mv(n.tr,t,t.left))}return!0}function A5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Mv(n.tr,t,t.right))}return!0}function M5(n,{map:e,table:t,tableStart:r},i){let s=n.mapping.maps.length;for(let o=0;o<e.height;){let l=o*e.width+i,a=e.map[l],c=t.nodeAt(a);if(i>0&&e.map[l-1]==a||i<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(s).map(r+a),null,_i(c.attrs,i-e.colCount(a)));else{let u=n.mapping.slice(s).map(r+a);n.delete(u,u+c.nodeSize)}o+=c.attrs.rowspan}}function O5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let i=t.right-1;M5(r,t,i),i!=t.left;i--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=et.get(t.table);e(r)}return!0}function _5(n,e,t){let r=Mt(e.type.schema).header_cell;for(let i=0;i<n.width;i++)if(e.nodeAt(n.map[i+t*n.width]).type!=r)return!1;return!0}function Ov(n,{map:e,tableStart:t,table:r},i){let s=t;for(let a=0;a<i;a++)s+=r.child(a).nodeSize;let o=[],l=i>0?-1:0;_5(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;n.setNodeMarkup(t+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 n.insert(s,Mt(r.type.schema).row.create(null,o)),n}function N5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Ov(n.tr,t,t.top))}return!0}function D5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n);e(Ov(n.tr,t,t.bottom))}return!0}function R5(n,{map:e,table:t,tableStart:r},i){let s=0;for(let a=0;a<i;a++)s+=t.child(a).nodeSize;let o=s+t.child(i).nodeSize,l=n.mapping.maps.length;n.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=t.nodeAt(u).attrs;n.setNodeMarkup(n.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=t.nodeAt(u),f=d.type.create(wt(d.attrs,"rowspan",d.attrs.rowspan-1),d.content),h=e.positionAt(i+1,a,t);n.insert(n.mapping.slice(l).map(r+h),f),a+=d.attrs.colspan-1}}}function L5(n,e){if(!Tn(n))return!1;if(e){let t=Xn(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let i=t.bottom-1;R5(r,t,i),i!=t.top;i--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=et.get(t.table);e(r)}return!0}function _v(n){let e=n.content;return e.childCount==1&&e.firstChild.isTextblock&&e.firstChild.childCount==0}function I5({width:n,height:e,map:t},r){let i=r.top*n+r.left,s=i,o=(r.bottom-1)*n+r.left,l=i+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[s]==t[s-1]||r.right<n&&t[l]==t[l+1])return!0;s+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[i]==t[i-n]||r.bottom<e&&t[o]==t[o+n])return!0;i++,o++}return!1}function Nv(n,e){let t=n.selection;if(!(t instanceof Se)||t.$anchorCell.pos==t.$headCell.pos)return!1;let r=Xn(n),{map:i}=r;if(I5(i,r))return!1;if(e){let s=n.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{_v(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(wv(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=_v(c)?a+1:u;s.replaceWith(d+r.tableStart,u+r.tableStart,l)}s.setSelection(new Se(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function Dv(n,e){const t=Mt(n.schema);return P5(({node:r})=>t[r.type.spec.tableRole])(n,e)}function P5(n){return(e,t)=>{let r=e.selection,i,s;if(r instanceof Se){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{if(i=a5(r.$from),!i)return!1;s=Rs(r.$from).pos}if(i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(t){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=Xn(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),n({node:i,row:f,col:p}).createAndFill(l[g]))}u.setNodeMarkup(s,n({node:i,row:c.top,col:c.left}),l[0]),r instanceof Se&&u.setSelection(new Se(u.doc.resolve(r.$anchorCell.pos),d&&u.doc.resolve(d))),t(u)}return!0}}function F5(n,e){return function(t,r){if(!Tn(t))return!1;let i=Ec(t);if(i.nodeAfter.attrs[n]===e)return!1;if(r){let s=t.tr;t.selection instanceof Se?t.selection.forEachCell((o,l)=>{o.attrs[n]!==e&&s.setNodeMarkup(l,null,wt(o.attrs,n,e))}):s.setNodeMarkup(i.pos,null,wt(i.nodeAfter.attrs,n,e)),r(s)}return!0}}function B5(n){return function(e,t){if(!Tn(e))return!1;if(t){let r=Mt(e.schema),i=Xn(e),s=e.tr,o=i.map.cellsInRect(n=="column"?new Ds(i.left,0,i.right,i.map.height):n=="row"?new Ds(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);t(s)}return!0}}function Rv(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let i=0;i<r.length;i++){const s=e.table.nodeAt(r[i]);if(s&&s.type!==t.header_cell)return!1}return!0}function Zo(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?B5(n):function(t,r){if(!Tn(t))return!1;if(r){let i=Mt(t.schema),s=Xn(t),o=t.tr,l=Rv("row",s,i),a=Rv("column",s,i),u=(n==="column"?l:n==="row"?a:!1)?1:0,d=n=="column"?new Ds(0,u,1,s.map.height):n=="row"?new Ds(u,0,s.map.width,1):s,f=n=="column"?a?i.cell:i.header_cell:n=="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}}Zo("row",{useDeprecatedLogic:!0}),Zo("column",{useDeprecatedLogic:!0});let $5=Zo("cell",{useDeprecatedLogic:!0});function j5(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,i=n.before();r>=0;r--){let s=n.node(-1).child(r);if(s.childCount)return i-1-s.lastChild.nodeSize;i-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;let t=n.node(-1);for(let r=n.indexAfter(-1),i=n.after();r<t.childCount;r++){let s=t.child(r);if(s.childCount)return i+1;i+=s.nodeSize}}}function Lv(n){return function(e,t){if(!Tn(e))return!1;let r=j5(Ec(e),n);if(r!=null){if(t){let i=e.doc.resolve(r);t(e.tr.setSelection(ce.between(i,u5(i))).scrollIntoView())}return!0}}}function H5(n,e){let t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}let V5=class{constructor(e,t){this.node=e,this.cellMinWidth=t,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")),ph(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,ph(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function ph(n,e,t,r,i,s){let o=0,l=!0,a=e.firstChild,c=n.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?(t.style.width=o+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=o+"px")}const mn=new We("tableColumnResizing");function z5({handleWidth:n=5,cellMinWidth:e=25,View:t=V5,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 t(l,e,a),new Xo(-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){U5(s,o,n,e,r)},mouseleave(s){W5(s)},mousedown(s,o){q5(s,o,e)}},decorations(s){let o=mn.getState(s);if(o.activeHandle>-1)return X5(s,o.activeHandle)},nodeViews:{}}})}class Xo{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,r=e.getMeta(mn);if(r&&r.setHandle!=null)return new Xo(r.setHandle,null);if(r&&r.setDragging!==void 0)return new Xo(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let i=e.mapping.map(t.activeHandle,-1);ch(e.doc.resolve(i))||(i=null),t=new Xo(i,t.dragging)}return t}}function U5(n,e,t,r,i){let s=mn.getState(n.state);if(!s.dragging){let o=J5(e.target),l=-1;if(o){let{left:a,right:c}=o.getBoundingClientRect();e.clientX-a<=t?l=Iv(n,e,"left"):c-e.clientX<=t&&(l=Iv(n,e,"right"))}if(l!=s.activeHandle){if(!i&&l!==-1){let a=n.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}Fv(n,l)}}}function W5(n){let e=mn.getState(n.state);e.activeHandle>-1&&!e.dragging&&Fv(n,-1)}function q5(n,e,t){let r=mn.getState(n.state);if(r.activeHandle==-1||r.dragging)return!1;let i=n.state.doc.nodeAt(r.activeHandle),s=K5(n,r.activeHandle,i.attrs);n.dispatch(n.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(n.state);c.dragging&&(G5(n,c.activeHandle,Pv(c.dragging,a,t)),n.dispatch(n.state.tr.setMeta(mn,{setDragging:null})))}function l(a){if(!a.which)return o(a);let c=mn.getState(n.state),u=Pv(c.dragging,a,t);Y5(n,c.activeHandle,u,t)}return window.addEventListener("mouseup",o),window.addEventListener("mousemove",l),e.preventDefault(),!0}function K5(n,e,{colspan:t,colwidth:r}){let i=r&&r[r.length-1];if(i)return i;let s=n.domAtPos(e),l=s.node.childNodes[s.offset].offsetWidth,a=t;if(r)for(let c=0;c<t;c++)r[c]&&(l-=r[c],a--);return l/a}function J5(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Iv(n,e,t){let r=n.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return-1;let{pos:i}=r,s=Rs(n.state.doc.resolve(i));if(!s)return-1;if(t=="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 Pv(n,e,t){let r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function Fv(n,e){n.dispatch(n.state.tr.setMeta(mn,{setHandle:e}))}function G5(n,e,t){let r=n.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=n.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]==t)continue;let p=f.colwidth?f.colwidth.slice():Z5(f.colspan);p[h]=t,a.setNodeMarkup(o+d,null,wt(f,"colwidth",p))}a.docChanged&&n.dispatch(a)}function Y5(n,e,t,r){let i=n.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=n.domAtPos(i.start(-1)).node;for(;a.nodeName!="TABLE";)a=a.parentNode;ph(s,a.firstChild,a,r,l,t)}function Z5(n){let e=[];for(let t=0;t<n;t++)e.push(0);return e}function X5(n,e){let t=[],r=n.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",t.push(ut.widget(d,f))}}return He.create(n.doc,t)}function Q5({allowTableNodeSelection:n=!1}={}){return new je({key:Gr,state:{init(){return null},apply(e,t){let r=e.getMeta(Gr);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;let{deleted:i,pos:s}=e.mapping.mapResult(t);return i?null:s}},props:{decorations:f5,handleDOMEvents:{mousedown:k5},createSelectionBetween(e){if(Gr.getState(e.state)!=null)return e.state.selection},handleTripleClick:x5,handleKeyDown:w5,handlePaste:C5},appendTransaction(e,t,r){return m5(r,Av(r,t),n)}})}function Bv(n,e,t,r,i,s){var u;let o=0,l=!0,a=e.firstChild;const c=n.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?(t.style.width=`${o}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${o}px`)}class eL{constructor(e,t){vr(this,"node");vr(this,"cellMinWidth");vr(this,"dom");vr(this,"table");vr(this,"colgroup");vr(this,"contentDOM");this.node=e,this.cellMinWidth=t,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")),Bv(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,Bv(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function $v(n,e){return n.createAndFill()}function tL(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function nL(n,e,t,r,i){const s=tL(n),o=[],l=[];for(let c=0;c<t;c+=1){const u=$v(s.cell);if(u&&l.push(u),r){const d=$v(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 rL(n){return n instanceof Se}const _c=({editor:n})=>{const{selection:e}=n.state;if(!rL(e))return!1;let t=0;const r=Ru(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)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},iL=Ve.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:eL,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){let t=0,r=!0;try{n.content.firstChild.content.forEach(s=>{if(s.attrs.colwidth)s.attrs.colwidth.forEach(o=>{o?t+=o:(r=!1,t+=this.options.cellMinWidth)});else{r=!1;const o=s.attrs.colspan?s.attrs.colspan:1;t+=this.options.cellMinWidth*o}})}catch{r=!1}return r&&t>0?e.style=`width: ${t}px;`:t&&t>0?e.style=`min-width: ${t}px`:e.style=null,["div",{class:"table-wrapper"},["table",xe(this.options.HTMLAttributes,e),["tbody",0]]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:i,editor:s})=>{const{selection:o}=r,l=nL(s.schema,n,e,t);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:n,dispatch:e})=>T5(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>A5(n,e),deleteColumn:()=>({state:n,dispatch:e})=>O5(n,e),addRowBefore:()=>({state:n,dispatch:e})=>N5(n,e),addRowAfter:()=>({state:n,dispatch:e})=>D5(n,e),deleteRow:()=>({state:n,dispatch:e})=>L5(n,e),deleteTable:()=>({state:n,dispatch:e})=>H5(n,e),mergeCells:()=>({state:n,dispatch:e})=>Nv(n,e),splitCell:()=>({state:n,dispatch:e})=>Dv(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>Zo("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>Zo("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>$5(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>Nv(n,e)?!0:Dv(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>F5(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>Lv(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>Lv(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&Av(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=Se.create(e.doc,n.anchorCell,n.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:_c,"Mod-Backspace":_c,Delete:_c,"Mod-Delete":_c}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[z5({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Q5({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:ge(re(n,"tableRole",e))}}});function jv(n,e){if(n==null)return{};var t={},r=Object.keys(n),i,s;for(s=0;s<r.length;s++)i=r[s],!(e.indexOf(i)>=0)&&(t[i]=n[i]);return t}var Hv=typeof window<"u"&&typeof document<"u";function mh(n,e){n&&(typeof n=="function"&&n(e),{}.hasOwnProperty.call(n,"current")&&(n.current=e))}function Vv(){return Hv&&document.createElement("div")}function sL(n){var e={"data-placement":n.placement};return n.referenceHidden&&(e["data-reference-hidden"]=""),n.escaped&&(e["data-escaped"]=""),e}function zv(n,e){if(n===e)return!0;if(typeof n=="object"&&n!=null&&typeof e=="object"&&e!=null){if(Object.keys(n).length!==Object.keys(e).length)return!1;for(var t in n)if(e.hasOwnProperty(t)){if(!zv(n[t],e[t]))return!1}else return!1;return!0}else return!1}function oL(n){var e=[];return n.forEach(function(t){e.find(function(r){return zv(t,r)})||e.push(t)}),e}function lL(n,e){var t,r;return Object.assign({},e,{popperOptions:Object.assign({},n.popperOptions,e.popperOptions,{modifiers:oL([].concat(((t=n.popperOptions)==null?void 0:t.modifiers)||[],((r=e.popperOptions)==null?void 0:r.modifiers)||[]))})})}var gh=Hv?O.useLayoutEffect:O.useEffect;function aL(n){var e=O.useRef();return e.current||(e.current=typeof n=="function"?n():n),e.current}function Uv(n,e,t){t.split(/\s+/).forEach(function(r){r&&n.classList[e](r)})}var cL={name:"className",defaultValue:"",fn:function(e){var t=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}Uv(t,"add",e.props.className)}function s(){r()&&Uv(t,"remove",e.props.className)}return{onCreate:i,onBeforeUpdate:s,onAfterUpdate:i}}};function uL(n){function e(t){var r=t.children,i=t.content,s=t.visible,o=t.singleton,l=t.render,a=t.reference,c=t.disabled,u=c===void 0?!1:c,d=t.ignoreAttributes,f=d===void 0?!0:d;t.__source,t.__self;var h=jv(t,["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],k=x[1],E=O.useState(),T=E[0],N=E[1],_=aL(function(){return{container:Vv(),renders:1}}),A=Object.assign({ignoreAttributes:f},h,{content:_.container});p&&(process.env.NODE_ENV!=="production"&&["trigger","hideOnClick","showOnCreate"].forEach(function(V){A[V]!==void 0&&console.warn(["@tippyjs/react: Cannot specify `"+V+"` 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(X){var we=X.instance;return we.reference===G.currentTarget});J.state.$$activeSingletonInstance=ie.instance,N(ie.content)}}}}]):P,render:function(){return{popper:_.container}}}));var $=[a].concat(r?[r.type]:[]);return gh(function(){var V=a;a&&a.hasOwnProperty("current")&&(V=a.current);var U=n(V||_.ref||Vv(),Object.assign({},R,{plugins:[cL].concat(A.plugins||[])}));return _.instance=U,u&&U.disable(),s&&U.show(),g&&o.hook({instance:U,content:i,props:R,setSingletonContent:N}),S(!0),function(){U.destroy(),o==null||o.cleanup(U)}},$),gh(function(){var V;if(_.renders===1){_.renders++;return}var U=_.instance;U.setProps(lL(U.props,R)),(V=U.popperInstance)==null||V.forceUpdate(),u?U.disable():U.enable(),p&&(s?U.show():U.hide()),g&&o.hook({instance:U,content:i,props:R,setSingletonContent:N})}),gh(function(){var V;if(l){var U=_.instance;U.setProps({popperOptions:Object.assign({},U.props.popperOptions,{modifiers:[].concat((((V=U.props.popperOptions)==null?void 0:V.modifiers)||[]).filter(function(J){var G=J.name;return G!=="$$tippyReact"}),[{name:"$$tippyReact",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(G){var ie,X=G.state,we=(ie=X.modifiersData)==null?void 0:ie.hide;(y.placement!==X.placement||y.referenceHidden!==(we==null?void 0:we.isReferenceHidden)||y.escaped!==(we==null?void 0:we.hasPopperEscaped))&&k({placement:X.placement,referenceHidden:we==null?void 0:we.isReferenceHidden,escaped:we==null?void 0:we.hasPopperEscaped}),X.attributes.popper={}}}])})})}},[y.placement,y.referenceHidden,y.escaped].concat($)),O.createElement(O.Fragment,null,r?O.cloneElement(r,{ref:function(U){_.ref=U,mh(r.ref,U)}}):null,w&&nn.createPortal(l?l(sL(y),T,_.instance):i,_.container))}return e}var dL=function(n,e){return O.forwardRef(function(r,i){var s=r.children,o=jv(r,["children"]);return O.createElement(n,Object.assign({},e,o),s?O.cloneElement(s,{ref:function(a){mh(i,a),mh(s.ref,a)}}):null)})},fL=dL(uL(fi));const hL=[{name:"Add row above",action:n=>n.chain().focus().addRowBefore().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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:n=>n.chain().focus().addRowAfter().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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:n=>n.chain().focus().addColumnBefore().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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:n=>n.chain().focus().addColumnAfter().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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:n=>n.chain().focus().deleteRow().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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:n=>n.chain().focus().deleteColumn().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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:n=>n.chain().focus().toggleHeaderRow().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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:n=>n.chain().focus().toggleHeaderColumn().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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:n=>n.chain().focus().toggleHeaderCell().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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:n=>n.chain().focus().deleteTable().run(),icon:D.jsx("svg",{viewBox:"0 0 24 24",children:D.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"})})}],Wv=({node:n,getPos:e,selected:t,editor:r})=>{const[i,s]=O.useState(!1),o=Ul(),l=O.useRef(null),a=()=>{const{from:u,to:d}=r.state.selection,f=e(),h=f+n.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 D.jsxs(bo,{className:"group",children:[D.jsx(Kg,{as:"span"}),(i||t)&&D.jsx(fL,{appendTo:document.body,trigger:"click",interactive:!0,animation:"shift-toward-subtle",placement:"right-start",content:D.jsx("article",{className:"dropdown",contentEditable:!1,children:D.jsx("ul",{tabIndex:0,className:"dropdown-content fixed menu menu-compact p-2 shadow bg-base-100 rounded-box w-56",style:c(),children:hL.map(u=>D.jsx("li",{children:D.jsxs("button",{type:"button",className:"button",onClick:()=>u.action(r),children:[D.jsx("span",{children:u.icon}),D.jsx("span",{children:u.name})]})},u.name))})}),children:D.jsx("label",{tabIndex:0,className:Fe("trigger-button",{hidden:o}),contentEditable:!1,children:D.jsx(GE,{fontSize:"small"})})})]})},pL=Ve.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",xe(this.options.HTMLAttributes,n),0]},addNodeView(){return hi(Wv,{as:"td",className:"relative"})}}),mL=Ve.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",xe(this.options.HTMLAttributes,n),0]},addNodeView(){return hi(Wv,{as:"th",className:"relative"})}}),qv=n=>(n.stopPropagation(),n.preventDefault(),n),gL=function(n){const e=n.scrollHeight>n.clientHeight,r=window.getComputedStyle(n).overflowY.indexOf("hidden")!==-1;return e&&!r},Kv=function(n){return!n||n===document.body?document.body:gL(n)?n:Kv(n.parentNode)},yh=(n,e,t)=>{const r=document.createElement(n);if(!r)throw new Error(`Element with name ${n} can't be created.`);return e&&Object.entries(e).forEach(([i,s])=>r.setAttribute(i,s)),t&&Object.entries(t).forEach(([i,s])=>r.addEventListener(i,s)),r},yL=Ve.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",xe(this.options.HTMLAttributes,n),0]},addNodeView(){return({editor:n,HTMLAttributes:e,getPos:t})=>{const r=()=>t(),i=Kv(n.options.element);let s=!1;const o={deleteRow:()=>{this.editor.chain().deleteNode("tableRow").focus().run()},selectRow:()=>{const w=r(),S=n.state.doc.resolve(w),x=new se(S);n.view.dispatch(n.state.tr.setSelection(x))}},l=()=>{s=!0},a=()=>{s=!1},c=yh("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&&qv(w),o.selectRow()},mouseenter:()=>{l()},mouseover:()=>{l()},mouseleave:()=>{a(),f()}}),u=yh("button",{class:"text-sm px-1 absolute -translate-x-[125%] hover:active:-translate-x-[125%] mr-2"},{click:w=>{w&&qv(w),o.deleteRow()}}),d=()=>{g(),c.classList.remove("hidden")},f=()=>{setTimeout(()=>{s||c.classList.add("hidden")},100)},h=yh("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),n.on("selectionUpdate",g),n.on("update",g),i==null||i.addEventListener("scroll",g),document.addEventListener("scroll",g),{dom:h,contentDOM:h,destroy:()=>{c.remove(),n.off("selectionUpdate",g),n.off("update",g),i==null||i.removeEventListener("scroll",g),document.removeEventListener("scroll",g)}}}}}),bL=[iL.configure({resizable:!0}),pL,mL,yL],vL=Hb.extend({content:"(dBlock|columns)+"});function Jv({types:n,node:e}){return e!=null&&e.type?Array.isArray(n)&&n.includes(e.type)||e.type===n:!1}const wL=Ue.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const n=new We(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>this.options.notAfter.includes(t.name));return[new je({key:n,appendTransaction:(t,r,i)=>{const{doc:s,tr:o,schema:l}=i,a=n.getState(i),c=s.content.size,u=l.nodes[this.options.node];if(a)return o.insert(c,u.create())},state:{init:(t,r)=>{const i=r.tr.doc.lastChild;return!Jv({node:i,types:e})},apply:(t,r)=>{var s,o,l;if(!t.docChanged)return r;const i=(l=(o=(s=t.doc.lastChild)==null?void 0:s.content)==null?void 0:o.content)==null?void 0:l[0];return!Jv({node:i,types:e})}}})]}}),xL=({node:n,editor:e,getPos:t})=>{const[r,i]=O.useState(""),s=Ul(),o=["https://twitter.com","https://x.com"],l=()=>{switch(n.attrs.data){case"twitter":return D.jsx(f0,{});case"iframe":return D.jsx(h0,{});default:return D.jsx(aT,{})}},a=()=>{switch(n.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=t(),S=w+n.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=t(),x=S+n.nodeSize;p&&(e==null||e.chain().focus(S).deleteRange({from:S,to:x}).setTweetEmbed({tweetId:p}).run())},f=y1(()=>{switch(n.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()},[]),D.jsx(bo,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:!s&&D.jsxs("div",{className:"relative w-full",children:[D.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:l()}),D.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"})]})})},CL=Ve.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(xL)},parseHTML(){return[{tag:"div[data-action-node]"}]},renderHTML({HTMLAttributes:n}){return console.log("action"),["div",xe(n,{"data-action-node":""}),0]},addCommands(){return{setActionButton:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{data:n},content:[]})}}}),kL=[h_,d_.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}),p_.configure({types:["heading","paragraph"]}),tN,F_.configure({HTMLAttributes:{class:"text-blue-500 font-bold transition-colors cursor-pointer select-text pointer-events-auto"},openOnClick:!0}),B_.configure({placeholder:()=>"",includeChildren:!0,showOnlyCurrent:!0}),H_.configure({multicolor:!0}),eN,W_.configure({HTMLAttributes:{class:"select-text pointer-events-auto"}}),f_,iN,V_.configure({HTMLAttributes:{class:"not-prose space-y-4 ml-2"}}),U_.configure({HTMLAttributes:{class:"flex items-start"},nested:!0}),Vb.configure({width:3,color:"#d1d5db"}),zb,r5,wL,vL,...bL,hN.configure({uploadFn:AT}),rN,sN,cN,CL.extend({addInputRules(){return[Gv(/^(?:twt|###|___\s|\*\*\*\s)$/,"twitter",this.type),Gv(/^(?:ytb|@@@|___\s|\*\*\*\s)$/,"iframe",this.type)]}}),nN],Gv=(n,e,t)=>new io({find:n,handler:({state:r,range:i,commands:s})=>{const o={data:e},{tr:l}=r,a=i.from,c=i.to;l.insert(a-1,t.create(o)).delete(l.mapping.map(a),l.mapping.map(c)),s.focus(c-1)}}),Yv=["#30bced","#6eeb83","#fa69d1","#ecd444","#ee6352","#db3041","#0ad7f2","#1bff39"],SL=({isPreviewMode:n,data:e,enableCollaboration:t,collaborationId:r})=>{const[i,s]=O.useState({plugin:{title:"Untitled"}}),[o]=O.useState(new as),l=O.useRef(null),a=[...kL,p3.configure({document:o})];O.useEffect(()=>{if(r&&t){const f=new HO(r||"default-room",o,{signaling:["wss://fileverse-signaling-server-0529292ff51c.herokuapp.com/"]});return l.current=f,()=>{f.destroy(),o.destroy()}}},[r,o]),O.useEffect(()=>{t&&r&&(a.some(h=>h.name==="collaborationCursor")||a.push(m3.configure({provider:l.current,user:{color:Yv[Math.floor(Math.random()*Yv.length)]}})))},[l.current]);const c=FE({extensions:a,editorProps:VO,autofocus:"start"}),u=O.useRef(null),d=f=>{var h;(h=u.current)!=null&&h.contains(f.target)||c==null||c.chain().focus().run()};return O.useEffect(()=>{c==null||c.chain().focus()},[]),O.useEffect(()=>{c==null||c.setEditable(!n)},[n]),O.useEffect(()=>{e&&c&&(c==null||c.commands.setContent(e.editorJSONData),s(e.metaData))},[e,c]),{editor:c,pluginMetaData:i,setPluginMetaData:s,focusEditor:d,ref:u}},EL=({isPreviewMode:n=!1,onPublish:e,data:t,togglePreviewMode:r,enableCollaboration:i,collaborationId:s})=>{const{editor:o,pluginMetaData:l,focusEditor:a,setPluginMetaData:c,ref:u}=SL({isPreviewMode:n,data:t,enableCollaboration:i,collaborationId:s,onPublish:e,togglePreviewMode:r});return o?D.jsx("div",{"data-cy":"single-webpage",className:"bg-[#f9fbfd]",children:D.jsx("div",{className:"h-full flex flex-col overflow-scroll no-scrollbar",children:D.jsxs("div",{className:"w-full h-screen",children:[D.jsx("div",{className:"h-fit relative bg-[#ffffff]",children:D.jsxs("div",{className:"flex items-center justify-center pl-4 pr-4 border-b-1 border gap-2 h-16",children:[D.jsx("div",{className:"grow",children:D.jsx(iw,{isPreviewMode:n,metaData:l,setMetaData:c})}),!n&&D.jsx("div",{className:"grow relative",children:D.jsx(zT,{editor:o})}),D.jsx("div",{children:D.jsxs(zl,{onClick:()=>r(n),children:[n?D.jsx(nT,{size:14}):D.jsx(sT,{size:14})," ",n?"Edit":"Preview"]})}),e&&D.jsx("div",{children:D.jsxs(zl,{onClick:()=>e({metaData:l,editorJSONData:o.getJSON()}),children:[D.jsx(oT,{size:14})," Share"]})})]})}),D.jsx("main",{className:"h-screen lg:h-full w-full rounded-[8px] flex flex-col justify-start items-center gap-2",children:D.jsx("div",{onClick:a,className:"w-full flex justify-center relative",children:D.jsx("div",{className:"p-12 sm:p-[96px] mt-4 min-h-[900px] shadow-inner bg-white overflow-scroll no-scrollbar rounded-md w-full sm:w-[70%] max-w-[856px]",children:D.jsxs("div",{ref:u,className:"w-full pt-4 h-full",children:[!n&&D.jsxs("div",{children:[D.jsx(LT,{editor:o}),D.jsx(HT,{editor:o,appendTo:u})]}),D.jsx(VT,{isPreviewMode:n,children:D.jsx(IE,{editor:o})})]})})})})]})})}):D.jsxs("div",{className:"w-screen h-screen flex flex-col gap-4 justify-center items-center",children:[D.jsx(N0,{}),D.jsx("p",{children:"Loading Editor..."})]})};Bt.DdocEditor=EL,Object.defineProperty(Bt,Symbol.toStringTag,{value:"Module"})});