@emailmaker/emailmaker 1.1.15 → 1.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{emailmaker-core.4725286d.js → emailmaker-core.89101e30.js} +1 -1
- package/emailmaker-esm.js +5 -5
- package/emailmaker.js +7 -7
- package/iframe/js/amp.BbapYQ7c.js +1 -0
- package/iframe/js/iframe-eblock.js +1 -1
- package/iframe/js/iframe.js +1 -1
- package/iframe/js/rules.CNqvmp_P.js +1 -1
- package/iframe/js/sanitize-html/sanitize-html.js +21756 -0
- package/iframe/js/sanitize-html/sanitize-html.min.js +16923 -0
- package/package.json +1 -1
- package/singlepage_headless_plugin.html +1 -1
- package/static/core/{83237bf7.js → 18ba331f.js} +1 -1
- package/static/core/{68af1b9e.js → 20f9532b.js} +1 -1
- package/static/core/28fbe0b6.js +834 -0
- package/static/core/{f3a4e54b.js → 313b4001.js} +2 -2
- package/static/core/{b8a67517.js → 39c9310d.js} +2 -2
- package/static/core/{3a08a74d.js → 52228076.js} +1 -1
- package/static/core/7efc3bcb.js +51 -0
- package/static/core/{83bfcbe5.js → 7ff62923.js} +4 -4
- package/static/core/8194155c.js +1 -0
- package/static/core/{a1e4c546.js → 8202e0f8.js} +2 -2
- package/static/core/{fcaec856.js → 873a79c1.js} +2 -2
- package/static/core/{70f01bbc.js → 9bc6d2d5.js} +1 -1
- package/static/core/{8597dcdb.js → ce528e2c.js} +6 -6
- package/static/core/{dbca3d8c.js → f99ffa93.js} +6 -6
- package/static/esm/{c4069a00.js → 6efa3ebe.js} +1 -1
- package/two_step_headless_plugin.html +1 -1
- package/vite/index.cjs +21 -3
- package/vite/index.js +21 -3
- package/iframe/js/amp.ChogY1pX.js +0 -1
- package/iframe/js/sanitize-html.CeWggAnN.js +0 -1
- package/static/core/5b0b84dc.js +0 -51
- package/static/core/c086d422.js +0 -834
- package/static/core/e683373a.js +0 -1
- /package/iframe/{iframe-eblock.4725286d.html → iframe-eblock.89101e30.html} +0 -0
- /package/iframe/{iframe.4725286d.html → iframe.89101e30.html} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.setAttribute(`data-emailmaker`,`true`),e.appendChild(document.createTextNode(`.monaco-editor{width:100%;height:100%}.monaco-editor .monaco-hover{border-radius:6px}.monaco-editor .monaco-editor .scroll-decoration{box-shadow:none}.monaco-editor,.monaco-editor *,.monaco-editor .view-lines,.monaco-editor .view-lines *,.monaco-editor .view-lines .view-line,.monaco-editor .view-lines .monaco-mouse-cursor-text,.monaco-editor .view-line,.monaco-editor .monaco-mouse-cursor-text{font-family:var(--monaco-editor-font-family,"Source Code Pro", Consolas, "Courier New", monospace)!important}.monaco-editor .view-line,.monaco-editor .view-line span,.monaco-editor .view-line span.inline-selected-text{font-variant-ligatures:none;font-feature-settings:"liga" 0, "calt" 0;font-kerning:none;white-space:pre;font-family:var(--monaco-monospace-font,var(--monaco-editor-font-family,"Source Code Pro", Consolas, "Courier New", monospace))!important;font-size:var(--monaco-editor-font-size,14px)!important;font-weight:400!important}.monaco-editor .standalone-colorpicker-body{max-width:460px!important}.monaco-editor .standalone-colorpicker-body .colorpicker-body .saturation-wrap{flex:0 auto;max-width:280px}.blocks-app .colorpicker-body .saturation-box,.blocks-app .colorpicker-body .strip{border-radius:4px}.blocks-app .scrollbar.vertical{width:5px!important}.blocks-app .scrollbar.vertical .slider{border-radius:5px!important;width:5px!important}.blocks-app .user-cursor{z-index:10;border-left:2px solid #ff00e1;width:2px;height:20px;position:absolute}.blocks-app .cursor-hover{color:#fff;text-wrap-mode:nowrap;z-index:10000;border-radius:7px 7px 7px 0;margin-left:-2px;padding:0 5px;font-size:12px;position:absolute;top:-17px}.blocks-app .user-selection-decoration{background-color:#8080eb4d}.monaco-editor__spin{z-index:1000;align-items:center;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();__emailmaker__.define(`static/core/
|
|
1
|
+
(function(){try{if(typeof document<`u`){var e=document.createElement(`style`);e.setAttribute(`data-emailmaker`,`true`),e.appendChild(document.createTextNode(`.monaco-editor{width:100%;height:100%}.monaco-editor .monaco-hover{border-radius:6px}.monaco-editor .monaco-editor .scroll-decoration{box-shadow:none}.monaco-editor,.monaco-editor *,.monaco-editor .view-lines,.monaco-editor .view-lines *,.monaco-editor .view-lines .view-line,.monaco-editor .view-lines .monaco-mouse-cursor-text,.monaco-editor .view-line,.monaco-editor .monaco-mouse-cursor-text{font-family:var(--monaco-editor-font-family,"Source Code Pro", Consolas, "Courier New", monospace)!important}.monaco-editor .view-line,.monaco-editor .view-line span,.monaco-editor .view-line span.inline-selected-text{font-variant-ligatures:none;font-feature-settings:"liga" 0, "calt" 0;font-kerning:none;white-space:pre;font-family:var(--monaco-monospace-font,var(--monaco-editor-font-family,"Source Code Pro", Consolas, "Courier New", monospace))!important;font-size:var(--monaco-editor-font-size,14px)!important;font-weight:400!important}.monaco-editor .standalone-colorpicker-body{max-width:460px!important}.monaco-editor .standalone-colorpicker-body .colorpicker-body .saturation-wrap{flex:0 auto;max-width:280px}.blocks-app .colorpicker-body .saturation-box,.blocks-app .colorpicker-body .strip{border-radius:4px}.blocks-app .scrollbar.vertical{width:5px!important}.blocks-app .scrollbar.vertical .slider{border-radius:5px!important;width:5px!important}.blocks-app .user-cursor{z-index:10;border-left:2px solid #ff00e1;width:2px;height:20px;position:absolute}.blocks-app .cursor-hover{color:#fff;text-wrap-mode:nowrap;z-index:10000;border-radius:7px 7px 7px 0;margin-left:-2px;padding:0 5px;font-size:12px;position:absolute;top:-17px}.blocks-app .user-selection-decoration{background-color:#8080eb4d}.monaco-editor__spin{z-index:1000;align-items:center;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}`)),document.head.appendChild(e)}}catch(e){console.error(`vite-plugin-css-injected-by-js`,e)}})();__emailmaker__.define(`static/core/ce528e2c.js`,[`require`,`exports`,`module`,`static/core/354bf8a9.js`,`static/core/68599f0c.js`,`static/core/873a79c1.js`,`static/core/7efc3bcb.js`,`static/core/313b4001.js`,`static/core/e4e7c3852.js`,`static/core/c7357e24.js`,`static/core/52228076.js`,`react`,`react/jsx-runtime`],function(e,t,n){let r=e("./354bf8a9.js"),i=e("./7efc3bcb.js"),a=e("./68599f0c.js"),o=e("./52228076.js");e("./c7357e24.js");let s=e("./e4e7c3852.js"),c=e("./313b4001.js"),l=e("./873a79c1.js"),u=e("react"),d=r.l(u,1);u=r.l(u);let f=e("react/jsx-runtime");function p(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function m(e){if(Array.isArray(e))return e}function ee(e,t,n){return(t=x(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function te(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
2
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function g(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function _(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?g(Object(n),!0).forEach(function(t){ee(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):g(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function v(e,t){if(e==null)return{};var n,r,i=ne(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function ne(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function y(e,t){return m(e)||h(e,t)||re(e,t)||te()}function b(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function x(e){var t=b(e,`string`);return typeof t==`symbol`?t:t+``}function re(e,t){if(e){if(typeof e==`string`)return p(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?p(e,t):void 0}}function S(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function C(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function w(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?C(Object(n),!0).forEach(function(t){S(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):C(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function T(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){return t.reduceRight(function(e,t){return t(e)},e)}}function E(e){return function t(){for(var n=this,r=arguments.length,i=Array(r),a=0;a<r;a++)i[a]=arguments[a];return i.length>=e.length?e.apply(this,i):function(){for(var e=arguments.length,r=Array(e),a=0;a<e;a++)r[a]=arguments[a];return t.apply(n,[].concat(i,r))}}}function D(e){return{}.toString.call(e).includes(`Object`)}function ie(e){return!Object.keys(e).length}function O(e){return typeof e==`function`}function ae(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function oe(e,t){return D(t)||de(`changeType`),Object.keys(t).some(function(t){return!ae(e,t)})&&de(`changeField`),t}function se(e){O(e)||de(`selectorType`)}function ce(e){O(e)||D(e)||de(`handlerType`),D(e)&&Object.values(e).some(function(e){return!O(e)})&&de(`handlersType`)}function le(e){e||de(`initialIsRequired`),D(e)||de(`initialType`),ie(e)&&de(`initialContent`)}function ue(e,t){throw Error(e[t]||e.default)}var de=E(ue)({initialIsRequired:`initial state is required`,initialType:`initial state should be an object`,initialContent:`initial state shouldn't be an empty object`,handlerType:`handler should be an object or a function`,handlersType:`all handlers should be a functions`,selectorType:`selector should be a function`,changeType:`provided value of changes should be an object`,changeField:`it seams you want to change a field in the state which is not specified in the "initial" state`,default:"an unknown error accured in `state-local` package"}),fe={changes:oe,selector:se,handler:ce,initial:le};function pe(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};fe.initial(e),fe.handler(t);var n={current:e},r=E(ge)(n,t),i=E(he)(n),a=E(fe.changes)(e),o=E(me)(n);function s(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(e){return e};return fe.selector(e),e(n.current)}function c(e){T(r,i,a,o)(e)}return[s,c]}function me(e,t){return O(t)?t(e.current):t}function he(e,t){return e.current=w(w({},e.current),t),t}function ge(e,t,n){return O(t)?t(e.current):Object.keys(n).forEach(function(n){return t[n]?.call(t,e.current[n])}),n}var _e={create:pe},ve={paths:{vs:`https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs`}};function ye(e){return function t(){for(var n=this,r=arguments.length,i=Array(r),a=0;a<r;a++)i[a]=arguments[a];return i.length>=e.length?e.apply(this,i):function(){for(var e=arguments.length,r=Array(e),a=0;a<e;a++)r[a]=arguments[a];return t.apply(n,[].concat(i,r))}}}function be(e){return{}.toString.call(e).includes(`Object`)}function xe(e){return e||Ce(`configIsRequired`),be(e)||Ce(`configType`),e.urls?{paths:{vs:e.urls.monacoBase}}:e}function Se(e,t){throw Error(e[t]||e.default)}var Ce=ye(Se)({configIsRequired:`the configuration object is required`,configType:`the configuration object should be an object`,default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
3
3
|
You are using deprecated way of configuration.
|
|
4
4
|
|
|
@@ -31,10 +31,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
31
31
|
`},Xs={markup:`html`,stylesheet:`css`},Zs={type:`markup`,syntax:`html`,variables:Ys,snippets:{},options:{inlineElements:`a.abbr.acronym.applet.b.basefont.bdo.big.br.button.cite.code.del.dfn.em.font.i.iframe.img.input.ins.kbd.label.map.object.q.s.samp.select.small.span.strike.strong.sub.sup.textarea.tt.u.var`.split(`.`),"output.indent":` `,"output.baseIndent":``,"output.newline":`
|
|
32
32
|
`,"output.tagCase":``,"output.attributeCase":``,"output.attributeQuotes":`double`,"output.format":!0,"output.formatLeafNode":!1,"output.formatSkip":[`html`],"output.formatForce":[`body`],"output.inlineBreak":3,"output.compactBoolean":!1,"output.booleanAttributes":[`contenteditable`,`seamless`,`async`,`autofocus`,`autoplay`,`checked`,`controls`,`defer`,`disabled`,`formnovalidate`,`hidden`,`ismap`,`loop`,`multiple`,`muted`,`novalidate`,`readonly`,`required`,`reversed`,`selected`,`typemustmatch`],"output.reverseAttributes":!1,"output.selfClosingStyle":`html`,"output.field":(e,t)=>t,"output.text":e=>e,"markup.href":!0,"comment.enabled":!1,"comment.trigger":[`id`,`class`],"comment.before":``,"comment.after":`
|
|
33
33
|
<!-- /[#ID][.CLASS] -->`,"bem.enabled":!1,"bem.element":`__`,"bem.modifier":`_`,"jsx.enabled":!1,"stylesheet.keywords":[`auto`,`inherit`,`unset`,`none`],"stylesheet.unitless":[`z-index`,`line-height`,`opacity`,`font-weight`,`zoom`,`flex`,`flex-grow`,`flex-shrink`],"stylesheet.shortHex":!0,"stylesheet.between":`: `,"stylesheet.after":`;`,"stylesheet.intUnit":`px`,"stylesheet.floatUnit":`em`,"stylesheet.unitAliases":{e:`em`,p:`%`,x:`ex`,r:`rem`},"stylesheet.json":!1,"stylesheet.jsonDoubleQuotes":!1,"stylesheet.fuzzySearchMinScore":0,"stylesheet.strictMatch":!1}},Qs={markup:{snippets:$s(Gs)},xhtml:{options:{"output.selfClosingStyle":`xhtml`}},xml:{options:{"output.selfClosingStyle":`xml`}},xsl:{snippets:$s(qs),options:{"output.selfClosingStyle":`xml`}},jsx:{options:{"jsx.enabled":!0,"markup.attributes":{class:`className`,"class*":`styleName`,for:`htmlFor`},"markup.valuePrefix":{"class*":`styles`}}},vue:{options:{"markup.attributes":{"class*":`:class`}}},svelte:{options:{"jsx.enabled":!0}},pug:{snippets:$s(Js)},stylesheet:{snippets:$s(Ks)},sass:{options:{"stylesheet.after":``}},stylus:{options:{"stylesheet.between":` `,"stylesheet.after":``}}};function $s(e){let t={};return Object.keys(e).forEach(n=>{for(let r of n.split(`|`))t[r]=e[n]}),t}function ec(e={},t={}){let n=e.type||`markup`,r=e.syntax||Xs[n];return Object.assign(Object.assign(Object.assign({},Zs),e),{type:n,syntax:r,variables:tc(n,r,`variables`,e,t),snippets:tc(n,r,`snippets`,e,t),options:tc(n,r,`options`,e,t)})}function tc(e,t,n,r,i={}){let a=Qs[e],o=i[e],s=Qs[t],c=i[t];return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},Zs[n]),a&&a[n]),s&&s[n]),o&&o[n]),c&&c[n]),r[n])}function nc(e,t=0){return{text:e,start:t,pos:e.length}}function rc(e){return e.pos===e.start}function ic(e,t=0){return e.text.charCodeAt(e.pos-1+t)}function ac(e){if(!rc(e))return e.text.charCodeAt(--e.pos)}function oc(e,t){if(rc(e))return!1;let n=typeof t==`function`?t(ic(e)):t===ic(e);return n&&e.pos--,!!n}function sc(e,t){let n=e.pos;for(;oc(e,t););return e.pos<n}var cc;(function(e){e[e.SingleQuote=39]=`SingleQuote`,e[e.DoubleQuote=34]=`DoubleQuote`,e[e.Escape=92]=`Escape`})(cc||={});function lc(e){return e===cc.SingleQuote||e===cc.DoubleQuote}function uc(e){let t=e.pos,n=ac(e);if(lc(n)){for(;!rc(e);)if(ac(e)===n&&ic(e)!==cc.Escape)return!0}return e.pos=t,!1}var P;(function(e){e[e.SquareL=91]=`SquareL`,e[e.SquareR=93]=`SquareR`,e[e.RoundL=40]=`RoundL`,e[e.RoundR=41]=`RoundR`,e[e.CurlyL=123]=`CurlyL`,e[e.CurlyR=125]=`CurlyR`})(P||={});var dc={[P.SquareL]:P.SquareR,[P.RoundL]:P.RoundR,[P.CurlyL]:P.CurlyR},F;(function(e){e[e.Tab=9]=`Tab`,e[e.Space=32]=`Space`,e[e.Dash=45]=`Dash`,e[e.Slash=47]=`Slash`,e[e.Colon=58]=`Colon`,e[e.Equals=61]=`Equals`,e[e.AngleLeft=60]=`AngleLeft`,e[e.AngleRight=62]=`AngleRight`})(F||={});function fc(e){let t=e.pos;if(!oc(e,F.AngleRight))return!1;let n=!1;for(oc(e,F.Slash);!rc(e);){if(sc(e,bc),gc(e)){if(oc(e,F.Slash)){n=oc(e,F.AngleLeft);break}else if(oc(e,F.AngleLeft)){n=!0;break}else if(oc(e,bc))continue;else if(oc(e,F.Equals)){if(gc(e))continue;break}else if(hc(e)){n=!0;break}break}if(!pc(e))break}return e.pos=t,n}function pc(e){return mc(e)||hc(e)}function mc(e){let t=e.pos;return uc(e)&&oc(e,F.Equals)&&gc(e)?!0:(e.pos=t,!1)}function hc(e){let t=e.pos,n=[];for(;!rc(e);){let t=ic(e);if(Cc(t))n.push(t);else if(Sc(t)){if(n.pop()!==dc[t])break}else if(!xc(t))break;e.pos--}return t!==e.pos&&oc(e,F.Equals)&&gc(e)?!0:(e.pos=t,!1)}function gc(e){return sc(e,_c)}function _c(e){return e===F.Colon||e===F.Dash||vc(e)||yc(e)}function vc(e){return e&=-33,e>=65&&e<=90}function yc(e){return e>47&&e<58}function bc(e){return e===F.Space||e===F.Tab}function xc(e){return!isNaN(e)&&e!==F.Equals&&!bc(e)&&!lc(e)}function Sc(e){return e===P.CurlyL||e===P.RoundL||e===P.SquareL}function Cc(e){return e===P.CurlyR||e===P.RoundR||e===P.SquareR}var wc=e=>e.charCodeAt(0),Tc=`#.*:$-_!@%^+>/`.split(``).map(wc),Ec={type:`markup`,lookAhead:!0,prefix:``};function Dc(e,t=e.length,n={}){let r=Object.assign(Object.assign({},Ec),n);t=Math.min(e.length,Math.max(0,t??e.length)),r.lookAhead&&(t=Oc(e,t,r));let i,a=kc(e,t,r.prefix||``);if(a===-1)return;let o=nc(e,a);o.pos=t;let s=[];for(;!rc(o);){if(i=ic(o),s.includes(P.CurlyR)){if(i===P.CurlyR){s.push(i),o.pos--;continue}if(i!==P.CurlyL){o.pos--;continue}}if(Pc(i,r.type))s.push(i);else if(Nc(i,r.type)){if(s.pop()!==dc[i])break}else if(s.includes(P.SquareR)||s.includes(P.CurlyR)){o.pos--;continue}else if(fc(o)||!Mc(i))break;o.pos--}if(!s.length&&o.pos!==t){let r=e.slice(o.pos,t).replace(/^[*+>^]+/,``);return{abbreviation:r,location:t-r.length,start:n.prefix?a-n.prefix.length:t-r.length,end:t}}}function Oc(e,t,n){for(lc(e.charCodeAt(t))&&t++;Pc(e.charCodeAt(t),n.type);)t++;return t}function kc(e,t,n){if(!n)return 0;let r=nc(e),i=n.split(``).map(wc);r.pos=t;let a;for(;!rc(r);)if(!(Ac(r,P.SquareR,P.SquareL)||Ac(r,P.CurlyR,P.CurlyL))){if(a=r.pos,jc(r,i))return a;r.pos--}return-1}function Ac(e,t,n){let r=e.pos;if(oc(e,t))for(;!rc(e);){if(oc(e,n))return!0;e.pos--}return e.pos=r,!1}function jc(e,t){let n=e.pos,r=!1;for(let n=t.length-1;n>=0&&!rc(e)&&oc(e,t[n]);n--)r=n===0;return r||(e.pos=n),r}function Mc(e){return e>64&&e<91||e>96&&e<123||e>47&&e<58||Tc.includes(e)}function Nc(e,t){return e===P.RoundL||t===`markup`&&(e===P.SquareL||e===P.CurlyL)}function Pc(e,t){return e===P.RoundR||t===`markup`&&(e===P.SquareR||e===P.CurlyR)}function Fc(e,t){let n=ec(t);return n.type===`stylesheet`?Lc(e,n):Ic(e,n)}function Ic(e,t){return Jo(qo(e,t),t)}function Lc(e,t){return gs(Es(e,t),t)}var Rc={properties:`additive-symbols.align-content.align-items.justify-items.justify-self.justify-items.align-self.all.alt.animation.animation-delay.animation-direction.animation-duration.animation-fill-mode.animation-iteration-count.animation-name.animation-play-state.animation-timing-function.backface-visibility.background.background-attachment.background-blend-mode.background-clip.background-color.background-image.background-origin.background-position.background-position-x.background-position-y.background-repeat.background-size.behavior.block-size.border.border-block-end.border-block-start.border-block-end-color.border-block-start-color.border-block-end-style.border-block-start-style.border-block-end-width.border-block-start-width.border-bottom.border-bottom-color.border-bottom-left-radius.border-bottom-right-radius.border-bottom-style.border-bottom-width.border-collapse.border-color.border-image.border-image-outset.border-image-repeat.border-image-slice.border-image-source.border-image-width.border-inline-end.border-inline-start.border-inline-end-color.border-inline-start-color.border-inline-end-style.border-inline-start-style.border-inline-end-width.border-inline-start-width.border-left.border-left-color.border-left-style.border-left-width.border-radius.border-right.border-right-color.border-right-style.border-right-width.border-spacing.border-style.border-top.border-top-color.border-top-left-radius.border-top-right-radius.border-top-style.border-top-width.border-width.bottom.box-decoration-break.box-shadow.box-sizing.break-after.break-before.break-inside.caption-side.caret-color.clear.clip.clip-path.clip-rule.color.color-interpolation-filters.column-count.column-fill.column-gap.column-rule.column-rule-color.column-rule-style.column-rule-width.columns.column-span.column-width.contain.content.counter-increment.counter-reset.cursor.direction.display.empty-cells.enable-background.fallback.fill.fill-opacity.fill-rule.filter.flex.flex-basis.flex-direction.flex-flow.flex-grow.flex-shrink.flex-wrap.float.flood-color.flood-opacity.font.font-family.font-feature-settings.font-kerning.font-language-override.font-size.font-size-adjust.font-stretch.font-style.font-synthesis.font-variant.font-variant-alternates.font-variant-caps.font-variant-east-asian.font-variant-ligatures.font-variant-numeric.font-variant-position.font-weight.glyph-orientation-horizontal.glyph-orientation-vertical.grid-area.grid-auto-columns.grid-auto-flow.grid-auto-rows.grid-column.grid-column-end.grid-column-gap.grid-column-start.grid-gap.grid-row.grid-row-end.grid-row-gap.grid-row-start.grid-template.grid-template-areas.grid-template-columns.grid-template-rows.height.hyphens.image-orientation.image-rendering.ime-mode.inline-size.isolation.justify-content.kerning.left.letter-spacing.lighting-color.line-break.line-height.list-style.list-style-image.list-style-position.list-style-type.margin.margin-block-end.margin-block-start.margin-bottom.margin-inline-end.margin-inline-start.margin-left.margin-right.margin-top.marker.marker-end.marker-mid.marker-start.mask-type.max-block-size.max-height.max-inline-size.max-width.min-block-size.min-height.min-inline-size.min-width.mix-blend-mode.motion.motion-offset.motion-path.motion-rotation.-moz-animation.-moz-animation-delay.-moz-animation-direction.-moz-animation-duration.-moz-animation-iteration-count.-moz-animation-name.-moz-animation-play-state.-moz-animation-timing-function.-moz-appearance.-moz-backface-visibility.-moz-background-clip.-moz-background-inline-policy.-moz-background-origin.-moz-border-bottom-colors.-moz-border-image.-moz-border-left-colors.-moz-border-right-colors.-moz-border-top-colors.-moz-box-align.-moz-box-direction.-moz-box-flex.-moz-box-flexgroup.-moz-box-ordinal-group.-moz-box-orient.-moz-box-pack.-moz-box-sizing.-moz-column-count.-moz-column-gap.-moz-column-rule.-moz-column-rule-color.-moz-column-rule-style.-moz-column-rule-width.-moz-columns.-moz-column-width.-moz-font-feature-settings.-moz-hyphens.-moz-perspective.-moz-perspective-origin.-moz-text-align-last.-moz-text-decoration-color.-moz-text-decoration-line.-moz-text-decoration-style.-moz-text-size-adjust.-moz-transform.-moz-transform-origin.-moz-transition.-moz-transition-delay.-moz-transition-duration.-moz-transition-property.-moz-transition-timing-function.-moz-user-focus.-moz-user-select.-ms-accelerator.-ms-behavior.-ms-block-progression.-ms-content-zoom-chaining.-ms-content-zooming.-ms-content-zoom-limit.-ms-content-zoom-limit-max.-ms-content-zoom-limit-min.-ms-content-zoom-snap.-ms-content-zoom-snap-points.-ms-content-zoom-snap-type.-ms-filter.-ms-flex.-ms-flex-align.-ms-flex-direction.-ms-flex-flow.-ms-flex-item-align.-ms-flex-line-pack.-ms-flex-order.-ms-flex-pack.-ms-flex-wrap.-ms-flow-from.-ms-flow-into.-ms-grid-column.-ms-grid-column-align.-ms-grid-columns.-ms-grid-column-span.-ms-grid-layer.-ms-grid-row.-ms-grid-row-align.-ms-grid-rows.-ms-grid-row-span.-ms-high-contrast-adjust.-ms-hyphenate-limit-chars.-ms-hyphenate-limit-lines.-ms-hyphenate-limit-zone.-ms-hyphens.-ms-ime-mode.-ms-interpolation-mode.-ms-layout-grid.-ms-layout-grid-char.-ms-layout-grid-line.-ms-layout-grid-mode.-ms-layout-grid-type.-ms-line-break.-ms-overflow-style.-ms-perspective.-ms-perspective-origin.-ms-perspective-origin-x.-ms-perspective-origin-y.-ms-progress-appearance.-ms-scrollbar-3dlight-color.-ms-scrollbar-arrow-color.-ms-scrollbar-base-color.-ms-scrollbar-darkshadow-color.-ms-scrollbar-face-color.-ms-scrollbar-highlight-color.-ms-scrollbar-shadow-color.-ms-scrollbar-track-color.-ms-scroll-chaining.-ms-scroll-limit.-ms-scroll-limit-x-max.-ms-scroll-limit-x-min.-ms-scroll-limit-y-max.-ms-scroll-limit-y-min.-ms-scroll-rails.-ms-scroll-snap-points-x.-ms-scroll-snap-points-y.-ms-scroll-snap-type.-ms-scroll-snap-x.-ms-scroll-snap-y.-ms-scroll-translation.-ms-text-align-last.-ms-text-autospace.-ms-text-combine-horizontal.-ms-text-justify.-ms-text-kashida-space.-ms-text-overflow.-ms-text-size-adjust.-ms-text-underline-position.-ms-touch-action.-ms-touch-select.-ms-transform.-ms-transform-origin.-ms-transform-origin-x.-ms-transform-origin-y.-ms-transform-origin-z.-ms-user-select.-ms-word-break.-ms-word-wrap.-ms-wrap-flow.-ms-wrap-margin.-ms-wrap-through.-ms-writing-mode.-ms-zoom.-ms-zoom-animation.nav-down.nav-index.nav-left.nav-right.nav-up.negative.-o-animation.-o-animation-delay.-o-animation-direction.-o-animation-duration.-o-animation-fill-mode.-o-animation-iteration-count.-o-animation-name.-o-animation-play-state.-o-animation-timing-function.object-fit.object-position.-o-border-image.-o-object-fit.-o-object-position.opacity.order.orphans.-o-table-baseline.-o-tab-size.-o-text-overflow.-o-transform.-o-transform-origin.-o-transition.-o-transition-delay.-o-transition-duration.-o-transition-property.-o-transition-timing-function.offset-block-end.offset-block-start.offset-inline-end.offset-inline-start.outline.outline-color.outline-offset.outline-style.outline-width.overflow.overflow-wrap.overflow-x.overflow-y.pad.padding.padding-bottom.padding-block-end.padding-block-start.padding-inline-end.padding-inline-start.padding-left.padding-right.padding-top.page-break-after.page-break-before.page-break-inside.paint-order.perspective.perspective-origin.pointer-events.position.prefix.quotes.range.resize.right.ruby-align.ruby-overhang.ruby-position.ruby-span.scrollbar-3dlight-color.scrollbar-arrow-color.scrollbar-base-color.scrollbar-darkshadow-color.scrollbar-face-color.scrollbar-highlight-color.scrollbar-shadow-color.scrollbar-track-color.scroll-behavior.scroll-snap-coordinate.scroll-snap-destination.scroll-snap-points-x.scroll-snap-points-y.scroll-snap-type.shape-image-threshold.shape-margin.shape-outside.shape-rendering.size.src.stop-color.stop-opacity.stroke.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke-width.suffix.system.symbols.table-layout.tab-size.text-align.text-align-last.text-anchor.text-decoration.text-decoration-color.text-decoration-line.text-decoration-style.text-indent.text-justify.text-orientation.text-overflow.text-rendering.text-shadow.text-transform.text-underline-position.top.touch-action.transform.transform-origin.transform-style.transition.transition-delay.transition-duration.transition-property.transition-timing-function.unicode-bidi.unicode-range.user-select.vertical-align.visibility.-webkit-animation.-webkit-animation-delay.-webkit-animation-direction.-webkit-animation-duration.-webkit-animation-fill-mode.-webkit-animation-iteration-count.-webkit-animation-name.-webkit-animation-play-state.-webkit-animation-timing-function.-webkit-appearance.-webkit-backdrop-filter.-webkit-backface-visibility.-webkit-background-clip.-webkit-background-composite.-webkit-background-origin.-webkit-border-image.-webkit-box-align.-webkit-box-direction.-webkit-box-flex.-webkit-box-flex-group.-webkit-box-ordinal-group.-webkit-box-orient.-webkit-box-pack.-webkit-box-reflect.-webkit-box-sizing.-webkit-break-after.-webkit-break-before.-webkit-break-inside.-webkit-column-break-after.-webkit-column-break-before.-webkit-column-break-inside.-webkit-column-count.-webkit-column-gap.-webkit-column-rule.-webkit-column-rule-color.-webkit-column-rule-style.-webkit-column-rule-width.-webkit-columns.-webkit-column-span.-webkit-column-width.-webkit-filter.-webkit-flow-from.-webkit-flow-into.-webkit-font-feature-settings.-webkit-hyphens.-webkit-line-break.-webkit-margin-bottom-collapse.-webkit-margin-collapse.-webkit-margin-start.-webkit-margin-top-collapse.-webkit-mask-clip.-webkit-mask-image.-webkit-mask-origin.-webkit-mask-repeat.-webkit-mask-size.-webkit-nbsp-mode.-webkit-overflow-scrolling.-webkit-padding-start.-webkit-perspective.-webkit-perspective-origin.-webkit-region-fragment.-webkit-tap-highlight-color.-webkit-text-fill-color.-webkit-text-size-adjust.-webkit-text-stroke.-webkit-text-stroke-color.-webkit-text-stroke-width.-webkit-touch-callout.-webkit-transform.-webkit-transform-origin.-webkit-transform-origin-x.-webkit-transform-origin-y.-webkit-transform-origin-z.-webkit-transform-style.-webkit-transition.-webkit-transition-delay.-webkit-transition-duration.-webkit-transition-property.-webkit-transition-timing-function.-webkit-user-drag.-webkit-user-modify.-webkit-user-select.white-space.widows.width.will-change.word-break.word-spacing.word-wrap.writing-mode.z-index.zoom`.split(`.`)},zc={tags:`body.head.html.address.blockquote.dd.div.section.article.aside.header.footer.nav.menu.dl.dt.fieldset.form.frame.frameset.h1.h2.h3.h4.h5.h6.iframe.noframes.object.ol.p.ul.applet.center.dir.hr.pre.a.abbr.acronym.area.b.base.basefont.bdo.big.br.button.caption.cite.code.col.colgroup.del.dfn.em.font.i.img.input.ins.isindex.kbd.label.legend.li.link.map.meta.noscript.optgroup.option.param.q.s.samp.script.select.small.span.strike.strong.style.sub.sup.table.tbody.td.textarea.tfoot.th.thead.title.tr.tt.u.var.canvas.main.figure.plaintext.figcaption.hgroup.details.summary`.split(`.`)},Bc=new Map,Vc,Hc=new Map,Uc=/^[a-z,A-Z,!,(,[,#,\.\{]/,Wc=/^[a-z,A-Z,!,(,[,#,\.]/,Gc=/^-?[a-z,A-Z,!,@,#]/,Kc=/[a-z,A-Z\.]/,qc=[...zc.tags,`lorem`],Jc=`bem`,Yc=`|`,Xc=`t`,Zc=`c`,Qc=3;function $c(e,t,n,r,i){let a=cl(r);if(!a){if(!Bc.has(r)){let e=Object.assign(Object.assign({},dl(r)),ol[r]);Bc.set(r,Object.keys(e))}Vc=Bc.get(r)??[]}let o=pl(e,t,n,{lookAhead:!a,type:ll(r)});if(!o)return;let{abbreviationRange:s,abbreviation:c,currentLineTillPosition:l,filter:u}=o;if(tl(l)===c&&l.endsWith(`<${c}`)&&!a)return;let d=gl(r,u),f=``,p,m=[];if(((t,n)=>{if(ml(t,c)){try{f=Fc(n,d),a&&`!important`.startsWith(n)&&(f=`!important`)}catch{}!f||hl(t,n,f,d.options)||(p={kind:e.languages.CompletionItemKind.Property,label:c+(u?`|`+u.replace(`,`,`|`):``),documentation:nl(f),detail:`Emmet abbreviation`,insertTextRules:e.languages.CompletionItemInsertTextRule.InsertAsSnippet,range:s,insertText:il(al(f))},m=[p])}})(r,c),a){if(c.length>4&&Rc.properties.some(e=>e.startsWith(c)))return{suggestions:[],incomplete:!0};if(p&&f.length&&(p.range=s,p.insertText=il(al(f)),p.documentation=nl(f),p.label=rl(f),p.filterText=c,m=el(e,(Hc.has(r)?Hc.get(r):Hc.get(`css`))??[],c,c,s,d,`Emmet Custom Snippet`,!1),!m.find(e=>e.insertText===p?.insertText))){let e=RegExp(`.*`+c.split(``).map(e=>e===`$`||e===`+`?`\\`+e:e).join(`.*`)+`.*`,`i`);(/\d/.test(c)||e.test(p.label))&&m.push(p)}}else{let t=c,n=c.match(/(>|\+)([\w:-]+)$/);if(n&&n.length===3&&(t=n[2]),r!==`xml`){let n=el(e,qc,t,c,s,d,`Emmet Abbreviation`);m=m.concat(n)}{let n=el(e,Vc.filter(e=>!qc.includes(e)),t,c,s,d,`Emmet Abbreviation`);p&&n.length>0&&t!==c&&(p.sortText=`0`+p.label,n.forEach(e=>{e.filterText=c,e.sortText=`9`+c})),m=m.concat(n)}r===`html`&&m.length>=2&&c.includes(`:`)&&p?.insertText===`<${c}>\${0}</${c}>`&&(m=m.filter(e=>e.label!==c))}return m.length?{suggestions:m,incomplete:!0}:void 0}function el(e,t,n,r,i,a,o,s=!0){if(!n||!t)return[];let c=[];return t.forEach(t=>{if(!t.startsWith(n.toLowerCase())||s&&t===n.toLowerCase())return;let l=r+t.substr(n.length),u;try{u=Fc(l,a)}catch{}if(!u)return;let d={kind:e.languages.CompletionItemKind.Property,label:n+t.substr(n.length),documentation:nl(u),detail:o,insertTextRules:e.languages.CompletionItemInsertTextRule.InsertAsSnippet,range:i,insertText:il(al(u))};c.push(d)}),c}function tl(e){if(e){let t=e.match(/[\w,:,-,\.]*$/);if(t)return t[0]}}function nl(e){return e.replace(/([^\\])\$\{\d+\}/g,`$1|`).replace(/\$\{\d+:([^\}]+)\}/g,`$1`)}function rl(e){return e.replace(/([^\\])\$\{\d+\}/g,`$1`).replace(/\$\{\d+:([^\}]+)\}/g,`$1`)}function il(e){return e&&e.replace(/([^\\])(\$)([^\{])/g,`$1\\$2$3`)}function al(e){if(!e||!e.trim())return e;let t=-1,n=[],r=!1,i=!1,a=0,o=e.length;try{for(;a<o&&!r;){if(e[a++]!=`$`||e[a++]!=`{`)continue;let s=-1,c=-1;for(;a<o&&/\d/.test(e[a]);)s=s<0?a:s,c=a+1,a++;if(s===-1||c===-1||a>=o||e[a]!=`}`&&e[a]!=`:`)continue;let l=e.substring(s,c);if(r=l===`0`,r)break;let u=!1;if(e[a++]==`:`)for(;a<o;){if(e[a]==`}`){u=!0;break}a++}Number(l)>Number(t)?(t=Number(l),n=[{numberStart:s,numberEnd:c}],i=!u):Number(l)===t&&n.push({numberStart:s,numberEnd:c})}}catch{}if(i&&!r)for(let t=0;t<n.length;t++){let r=n[t].numberStart,i=n[t].numberEnd;e=e.substr(0,r)+`0`+e.substr(i)}return e}var ol={},sl=(e,t)=>`\${${e}${t?`:`+t:``}}`;function cl(e){return e===`css`}function ll(e){return cl(e)?`stylesheet`:`markup`}function ul(e){return cl(e)?`css`:`html`}function dl(e){let t=ec({type:ll(e),syntax:e});return e===`xml`?{}:t.snippets}function fl(e,t){let n;for(let r=0;r<Qc;r++)if(e.endsWith(`${Yc}${Jc}`,t))t-=4,n=n?`bem,`+n:Jc;else if(e.endsWith(`${Yc}${Zc}`,t))t-=2,n=n?`c,`+n:Zc;else if(e.endsWith(`${Yc}${Xc}`,t))t-=2,n=n?`t,`+n:Xc;else break;return{pos:t,filter:n}}function pl(e,t,n,r){let i=t.getLineContent(n.lineNumber),a=i.substr(0,n.column-1),{pos:o,filter:s}=fl(a,n.column-1),c=s?s.length+1:0,l=Dc(i,o,r);if(l)return{abbreviationRange:new e.Range(n.lineNumber,l.location+1,n.lineNumber,l.location+l.abbreviation.length+c+1),abbreviation:l.abbreviation,currentLineTillPosition:a,filter:s}}function ml(e,t){if(!t)return!1;if(cl(e)){if(t.includes(`#`)){if(t.startsWith(`#`))return/^#[\d,a-f,A-F]{1,6}$/.test(t);if(qc.includes(t.substring(0,t.indexOf(`#`))))return!1}return Gc.test(t)}return t.startsWith(`!`)?!/[^!]/.test(t):(/\(/.test(t)||/\)/.test(t))&&!/\{[^\}\{]*[\(\)]+[^\}\{]*\}(?:[>\+\*\^]|$)/.test(t)&&!/\(.*\)[>\+\*\^]/.test(t)&&!/\[[^\[\]\(\)]+=".*"\]/.test(t)&&!/[>\+\*\^]\(.*\)/.test(t)?!1:e===`jsx`?Wc.test(t)&&Kc.test(t):Uc.test(t)&&Kc.test(t)}function hl(e,t,n,r){if(cl(e)&&r){let e=r[`stylesheet.between`]??`: `,i=r[`stylesheet.after`]??`;`,a=t.indexOf(e[0],Math.max(t.length-e.length,0));return a=a>=0?a:t.length,n===`${t.substring(0,a)}${e}\${0}${i}`||n.replace(/\s/g,``)===t.replace(/\s/g,``)+i}if(e===`xml`&&qc.some(e=>e.startsWith(t.toLowerCase())))return!0;if(qc.includes(t.toLowerCase())||Vc.includes(t)||/[-,:]/.test(t)&&!/--|::/.test(t)&&!t.endsWith(`:`)||t===`.`)return!1;let i=t.match(/^([a-z,A-Z,\d]*)\.$/);return i?!(i[1]&&zc.tags.includes(i[1])):e===`jsx`&&/^([A-Z][A-Za-z0-9]*)+$/.test(t)?!1:n.toLowerCase()===`<${t.toLowerCase()}>\${1}</${t.toLowerCase()}>`}function gl(e,t){let n=t?t.split(`,`).map(e=>e.trim()):[],r=n.includes(`bem`),i={"output.formatSkip":[`html`],"output.formatForce":[`body`],"output.field":sl,"output.inlineBreak":0,"output.compactBoolean":!1,"output.reverseAttributes":!1,"markup.href":!0,"comment.enabled":n.includes(`c`),"comment.trigger":[`id`,`class`],"comment.before":``,"comment.after":`
|
|
34
|
-
<!-- /[#ID][.CLASS] -->`,"bem.enabled":r,"bem.element":`__`,"bem.modifier":`_`,"jsx.enabled":e===`jsx`,"stylesheet.shortHex":!0,"stylesheet.between":e===`stylus`?` `:`: `,"stylesheet.after":e===`sass`||e===`stylus`?``:`;`,"stylesheet.intUnit":`px`,"stylesheet.floatUnit":`em`,"stylesheet.unitAliases":{e:`em`,p:`%`,x:`ex`,r:`rem`},"stylesheet.fuzzySearchMinScore":.3,"output.format":!0,"output.selfClosingStyle":`html`},a=ll(e),o=ul(e);return{type:a,options:i,variables:{},snippets:a===`stylesheet`?ol[e]??ol[o]:ol[e],syntax:e,text:void 0,maxRepeat:1e3}}function _l(e,t,n,r){let i=e[t],a=i.type;return n===`html`?a===``&&(t===0||e[t-1].type===`delimiter.html`)||e[0].type===`text.html.basic`:n===`css`?a===``?!0:a===`tag.`+r:n===`jsx`?i.language===`mdx`&&a===``?!0:!!t&&[`identifier.js`,`type.identifier.js`,`identifier.ts`,`type.identifier.ts`].includes(a):!1}var vl=new WeakMap;function yl(e){if(vl.has(e))return vl.get(e);let t=e._tokenization||e.tokenization._tokenization,n=t?._tokenizationStateStore;if(!t||!n){let r=e.tokenization,i=r.grammarTokens||r._tokens||r.tokens?._value;i?(t=i._defaultBackgroundTokenizer,n=t._tokenizerWithStateStore):(Object.values(r).some(e=>t=e.tokenizeViewport&&e),Object.values(t).some(e=>n=e.tokenizationSupport&&e))}let r=n.tokenizationSupport||t._tokenizationSupport,i={_stateStore:n,_support:r};return vl.set(e,i),i}function bl(e,t,n,r){let i=e.tokenization;if(typeof i?.getLineTokens!=`function`)return
|
|
34
|
+
<!-- /[#ID][.CLASS] -->`,"bem.enabled":r,"bem.element":`__`,"bem.modifier":`_`,"jsx.enabled":e===`jsx`,"stylesheet.shortHex":!0,"stylesheet.between":e===`stylus`?` `:`: `,"stylesheet.after":e===`sass`||e===`stylus`?``:`;`,"stylesheet.intUnit":`px`,"stylesheet.floatUnit":`em`,"stylesheet.unitAliases":{e:`em`,p:`%`,x:`ex`,r:`rem`},"stylesheet.fuzzySearchMinScore":.3,"output.format":!0,"output.selfClosingStyle":`html`},a=ll(e),o=ul(e);return{type:a,options:i,variables:{},snippets:a===`stylesheet`?ol[e]??ol[o]:ol[e],syntax:e,text:void 0,maxRepeat:1e3}}function _l(e,t,n,r){let i=e[t],a=i.type;return n===`html`?a===``&&(t===0||e[t-1].type===`delimiter.html`)||e[0].type===`text.html.basic`:n===`css`?a===``?!0:a===`tag.`+r:n===`jsx`?i.language===`mdx`&&a===``?!0:!!t&&[`identifier.js`,`type.identifier.js`,`identifier.ts`,`type.identifier.ts`].includes(a):!1}var vl=new WeakMap;function yl(e){if(vl.has(e))return vl.get(e);let t=e._tokenization||e.tokenization._tokenization,n=t?._tokenizationStateStore;if(!t||!n){let r=e.tokenization,i=r.grammarTokens||r._tokens||r.tokens?._value;i?(t=i._defaultBackgroundTokenizer,n=t._tokenizerWithStateStore):(Object.values(r).some(e=>t=e.tokenizeViewport&&e),Object.values(t).some(e=>n=e.tokenizationSupport&&e))}let r=n.tokenizationSupport||t._tokenizationSupport,i={_stateStore:n,_support:r};return vl.set(e,i),i}function bl(e,t,n,r){let i=e.tokenization;if(typeof i?.getLineTokens!=`function`)return Sl(e,t,n,r);let{column:a,lineNumber:o}=t,s=i.getLineTokens(o),c=-1;for(let e=s.getCount()-1;e>=0;e--)if(a-1>s.getStartOffset(e)){c=e;break}return!(c<0||s.getStandardTokenType(c)!==0)}function xl(e,t){let n=e.getBeginState?.call(e,t-1);if(n)return n.clone();let r=e.getStartState?.call(e,t);return r?r.clone():null}function Sl(e,t,n,r){let{column:i,lineNumber:a}=t,{_stateStore:o,_support:s}=yl(e);if(!o||!s||typeof s.tokenize!=`function`)return!1;let c=xl(o,a);if(!c)return!1;let l=s.tokenize(e.getLineContent(a),!0,c,0).tokens,u=!1;for(let e=l.length-1;e>=0;e--)if(i-1>l[e].offset){u=_l(l,e,n,r);break}return u}function Cl(e,t,n,r,i){return i?.tokenizer===`standard`?bl(e,t,n,r):Sl(e,t,n,r)}var wl={html:[`!`,`.`,`}`,`:`,`*`,`$`,`]`,`/`,`>`,`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],jade:[`!`,`.`,`}`,`:`,`*`,`$`,`]`,`/`,`>`,`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],slim:[`!`,`.`,`}`,`:`,`*`,`$`,`]`,`/`,`>`,`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],haml:[`!`,`.`,`}`,`:`,`*`,`$`,`]`,`/`,`>`,`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],xml:[`.`,`}`,`*`,`$`,`]`,`/`,`>`,`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],xsl:[`!`,`.`,`}`,`*`,`$`,`/`,`]`,`>`,`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],css:[`:`,`!`,`-`,`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],scss:[`:`,`!`,`-`,`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],sass:[`:`,`!`,`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],less:[`:`,`!`,`-`,`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],stylus:[`:`,`!`,`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],javascript:[`!`,`.`,`}`,`*`,`$`,`]`,`/`,`>`,`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],typescript:[`!`,`.`,`}`,`*`,`$`,`]`,`/`,`>`,`0`,`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`]},Tl={handlebars:`html`,php:`html`,twig:`html`};function El(e,t,n,r){if(!e)return()=>{};let i=t.map(t=>e.languages.registerCompletionItemProvider(t,{triggerCharacters:wl[Tl[t]||t],provideCompletionItems:(i,a)=>{try{return Cl(i,a,n,t,r)?$c(e,i,a,n):void 0}catch{return}}}));return()=>{i.forEach(e=>e.dispose())}}function Dl(e=window.monaco,t=[`html`],n){return El(e,t,`html`,n)}function Ol(e=window.monaco,t=[`css`],n){return El(e,t,`css`,n)}var kl=(e,t)=>(jl(),Ml(e.user.color,t),e.cursor?[{range:new l._.Range(e.cursor.lineNumber,e.cursor.column,e.cursor.lineNumber,e.cursor.column),options:{className:`applyColorToThis backgroundPrefix-${e.user.color.slice(1)}`,afterContentClassName:`cursor-hover`,beforeContentClassName:``,style:`--cursor-color: ${e.user.color};`}}]:[]),Al=e=>e.selection?[{range:new l._.Range(e.selection.startLineNumber,e.selection.startColumn,e.selection.endLineNumber,e.selection.endColumn),options:{className:`user-selection-decoration`}}]:[],jl=()=>{let e=document.styleSheets[0];Array.from(e.cssRules).some(e=>e.cssText.includes(`.applyColorToThis`))||e.insertRule(`.applyColorToThis {
|
|
35
35
|
border-left: 2px solid var(--cursor-color, #000);
|
|
36
36
|
color: var(--cursor-color, #000);
|
|
37
|
-
}`,e.cssRules.length)},jl=(e,t)=>{let n=`backgroundPrefix-${e.slice(1)}`,r=document.styleSheets[0];Array.from(r.cssRules).some(e=>e.cssText.includes(`.${n}`))||r.insertRule(`.${n} { --cursor-color: ${e===t.color?`#000000`:e}; }`,r.cssRules.length)},Ml=(e,t,n,r,i)=>{for(let a=0;a<e.length;a++){let o=e[a],s=o.className.split(` `);for(let e of s)if(e.startsWith(t)){let a=`#${e.replace(t,``)}`,s=r.find(e=>e.user.color===a);s&&(n&&a!==i?.color?Nl(o,a,s?.user?.name?.first_name?`${s?.user?.name?.first_name} ${s?.user?.name?.last_name}`.replace(/[\n\r]/g,``):s.user.name.email.split(`@`)[0]):o.style.backgroundColor=a)}}},Nl=(e,t,n)=>{if(!e.textContent){let r=document.createElement(`div`);r.style.background=t,r.style.color=`#fff`,r.textContent=n,r.className=`cursor-hover`,e.appendChild(r)}},Pl=(e,t,n,r,i,a)=>{if(r)return;i(!0);let o=e.flatMap(e=>[...Ol(e,a),...kl(e)]);n.current=t.deltaDecorations(n.current,o.map(e=>({range:e.range,options:e.options}))),Ml(document.getElementsByClassName(`applyColorToThis`),`backgroundPrefix-`,!0,e,a),i(!1)},Fl=(e,t)=>{t.setLocalStateField(`cursor`,e.position)},Il=(e,t)=>{let n=e.selection;t.setLocalStateField(`selection`,{startLineNumber:n.startLineNumber,startColumn:n.startColumn,endLineNumber:n.endLineNumber,endColumn:n.endColumn})},Ll=(e,t)=>e.filter(e=>e.user.color!==t.color),Rl=()=>{let e=(e,t,n)=>e>100&&t>50&&t<150&&n<100,t=(e,t,n)=>{let r=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},i=r(e),a=r(t),o=r(n);return .2126*i+.7152*a+.0722*o},n=(e,n,r)=>{let i=t(255,255,255),a=t(e,n,r);return(i+.05)/(a+.05)>=4.5},r;do{let t=Math.floor(Math.random()*206+50),i=Math.floor(Math.random()*206+50),a=Math.floor(Math.random()*206+50);t+i+a>=400&&!e(t,i,a)&&n(t,i,a)&&(r=`#${(t<<16|i<<8|a).toString(16).padStart(6,`0`)}`)}while(!r);return r},zl=({CHECK_INTERVAL:e,SLEEP_THRESHOLD:t,provider:n,handleOfflineCollaboration:r,isNewEmailGeneration:i,saveEmailFromEditor:a})=>{let o=Date.now();return setInterval(()=>{let e=Date.now(),r=e-o;r>t&&n&&(a(),window.location.reload(),window.location.reload()),r<t&&!n&&document.visibilityState,o=e},e)};r.i();var Bl=()=>new Map,Vl=e=>{let t=Bl();return e.forEach((e,n)=>{t.set(n,e)}),t},Hl=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Ul=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},Wl=()=>new Set,Gl=e=>e[e.length-1],Kl=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},ql=Array.from,Jl=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Yl=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},Xl=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},Zl=Array.isArray,Ql=class{constructor(){this._observers=Bl()}on(e,t){return Hl(this._observers,e,Wl).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return ql((this._observers.get(e)||Bl()).values()).forEach(e=>e(...t))}destroy(){this._observers=Bl()}},$l=class{constructor(){this._observers=Bl()}on(e,t){Hl(this._observers,e,Wl).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return ql((this._observers.get(e)||Bl()).values()).forEach(e=>e(...t))}destroy(){this._observers=Bl()}},eu=Math.floor,tu=Math.abs,nu=(e,t)=>e<t?e:t,ru=(e,t)=>e>t?e:t;Number.isNaN;var iu=Math.pow,au=e=>e===0?1/e<0:e<0,ou=2**53-1,su=-(2**53-1),cu=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&eu(e)===e);Number.isNaN,Number.parseInt;var lu=String.fromCharCode;String.fromCodePoint,lu(65535);var uu=e=>e.toLowerCase(),du=/^\s*/g,fu=e=>e.replace(du,``),pu=/([A-Z])/g,mu=(e,t)=>fu(e.replace(pu,e=>`${t}${uu(e)}`)),hu=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},gu=typeof TextEncoder<`u`?new TextEncoder:null,_u=gu?e=>gu.encode(e):hu,vu=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});vu&&vu.decode(new Uint8Array).length===1&&(vu=null);var yu=(e,t)=>Xl(t,()=>e).join(``),bu=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},I=()=>new bu,xu=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},L=e=>{let t=new Uint8Array(xu(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},Su=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(ru(n,t)*2),e.cpos=0)},R=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},Cu=R,z=(e,t)=>{for(;t>127;)R(e,128|127&t),t=eu(t/128);R(e,127&t)},wu=(e,t)=>{let n=au(t);for(n&&(t=-t),R(e,(t>63?128:0)|(n?64:0)|63&t),t=eu(t/64);t>0;)R(e,(t>127?128:0)|127&t),t=eu(t/128)},Tu=new Uint8Array(3e4),Eu=Tu.length/3,Du=gu&&gu.encodeInto?(e,t)=>{if(t.length<Eu){let n=gu.encodeInto(t,Tu).written||0;z(e,n);for(let t=0;t<n;t++)R(e,Tu[t])}else B(e,_u(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;z(e,r);for(let t=0;t<r;t++)R(e,n.codePointAt(t))},Ou=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=nu(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(ru(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},B=(e,t)=>{z(e,t.byteLength),Ou(e,t)},ku=(e,t)=>{Su(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},Au=(e,t)=>ku(e,4).setFloat32(0,t,!1),ju=(e,t)=>ku(e,8).setFloat64(0,t,!1),Mu=(e,t)=>ku(e,8).setBigInt64(0,t,!1),Nu=new DataView(new ArrayBuffer(4)),Pu=e=>(Nu.setFloat32(0,e),Nu.getFloat32(0)===e),Fu=(e,t)=>{switch(typeof t){case`string`:R(e,119),Du(e,t);break;case`number`:cu(t)&&tu(t)<=2147483647?(R(e,125),wu(e,t)):Pu(t)?(R(e,124),Au(e,t)):(R(e,123),ju(e,t));break;case`bigint`:R(e,122),Mu(e,t);break;case`object`:if(t===null)R(e,126);else if(Zl(t)){R(e,117),z(e,t.length);for(let n=0;n<t.length;n++)Fu(e,t[n])}else if(t instanceof Uint8Array)R(e,116),B(e,t);else{R(e,118);let n=Object.keys(t);z(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];Du(e,i),Fu(e,t[i])}}break;case`boolean`:R(e,t?120:121);break;default:R(e,127)}},Iu=class extends bu{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&z(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},Lu=e=>{e.count>0&&(wu(e.encoder,e.count===1?e.s:-e.s),e.count>1&&z(e.encoder,e.count-2))},Ru=class{constructor(){this.encoder=new bu,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Lu(this),this.count=1,this.s=e)}toUint8Array(){return Lu(this),L(this.encoder)}},zu=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);wu(e.encoder,t),e.count>1&&z(e.encoder,e.count-2)}},Bu=class{constructor(){this.encoder=new bu,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(zu(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return zu(this),L(this.encoder)}},Vu=class{constructor(){this.sarr=[],this.s=``,this.lensE=new Ru}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new bu;return this.sarr.push(this.s),this.s=``,Du(e,this.sarr.join(``)),Ou(e,this.lensE.toUint8Array()),L(e)}},Hu=e=>Error(e),Uu=()=>{throw Hu(`Method unimplemented`)},V=()=>{throw Hu(`Unexpected case`)},Wu=Hu(`Unexpected end of array`),Gu=Hu(`Integer out of Range`),Ku=class{constructor(e){this.arr=e,this.pos=0}},qu=e=>new Ku(e),Ju=e=>e.pos!==e.arr.length,Yu=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},H=e=>Yu(e,U(e)),Xu=e=>e.arr[e.pos++],U=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>ou)throw Gu}throw Wu},Zu=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>ou)throw Gu}throw Wu},Qu=vu?e=>vu.decode(H(e)):e=>{let t=U(e);if(t===0)return``;{let n=String.fromCodePoint(Xu(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Xu(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},$u=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},ed=[e=>void 0,e=>null,Zu,e=>$u(e,4).getFloat32(0,!1),e=>$u(e,8).getFloat64(0,!1),e=>$u(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Qu,e=>{let t=U(e),n={};for(let r=0;r<t;r++){let t=Qu(e);n[t]=td(e)}return n},e=>{let t=U(e),n=[];for(let r=0;r<t;r++)n.push(td(e));return n},H],td=e=>ed[127-Xu(e)](e),nd=class extends Ku{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Ju(this)?this.count=U(this)+1:this.count=-1),this.count--,this.s}},rd=class extends Ku{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Zu(this);let e=au(this.s);this.count=1,e&&(this.s=-this.s,this.count=U(this)+2)}return this.count--,this.s}},id=class extends Ku{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Zu(this),t=e&1;this.diff=eu(e/2),this.count=1,t&&(this.count=U(this)+2)}return this.s+=this.diff,this.count--,this.s}},ad=class{constructor(e){this.decoder=new rd(e),this.str=Qu(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var od=crypto.getRandomValues.bind(crypto),sd=()=>od(new Uint32Array(1))[0],cd=`10000000-1000-4000-8000-100000000000`,ld=()=>cd.replace(/[018]/g,e=>(e^sd()&15>>e/4).toString(16)),ud=Date.now,dd=e=>new Promise(e);Promise.all.bind(Promise),a.n(),r.n();var fd=e=>e===void 0?null:e,pd=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}},md=!0;try{typeof localStorage<`u`&&localStorage&&(pd=localStorage,md=!1)}catch{}var hd=pd,gd=e=>md||addEventListener(`storage`,e),_d=e=>md||removeEventListener(`storage`,e),vd=Symbol(`Equality`),yd=(e,t)=>e===t||!!e?.[vd]?.(t)||!1,bd=e=>typeof e==`object`,xd=Object.assign,Sd=Object.keys,Cd=(e,t)=>{for(let n in e)t(e[n],n)},wd=(e,t)=>{let n=[];for(let r in e)n.push(t(e[r],r));return n},Td=e=>Sd(e).length,Ed=e=>{for(let t in e)return!1;return!0},Dd=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},Od=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),kd=(e,t)=>e===t||Td(e)===Td(t)&&Dd(e,(e,n)=>(e!==void 0||Od(t,n))&&yd(t[n],e)),Ad=Object.freeze,jd=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&jd(e[t])}return Ad(e)},Md=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Md(e,t,n+1)}},Nd=e=>e,Pd=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[vd]!=null)return e[vd](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!Pd(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Td(e)!==Td(t))return!1;for(let n in e)if(!Od(e,n)||!Pd(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Pd(e[n],t[n]))return!1;break;default:return!1}return!0},Fd=(e,t)=>t.includes(e),Id=a.t!==void 0&&a.t.release&&/node|io\.js/.test(a.t.release.name)&&Object.prototype.toString.call(a.t===void 0?0:a.t)===`[object process]`,Ld=typeof window<`u`&&typeof document<`u`&&!Id;typeof navigator<`u`&&/Mac/.test(navigator.platform);var Rd,zd=[],Bd=()=>{if(Rd===void 0)if(Id){Rd=Bl();let e=a.t.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&Rd.set(t,``),t=r):t===null?zd.push(r):(Rd.set(t,r),t=null)}t!==null&&Rd.set(t,``)}else typeof location==`object`?(Rd=Bl(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);Rd.set(`--${mu(t,`-`)}`,n),Rd.set(`-${mu(t,`-`)}`,n)}})):Rd=Bl();return Rd},Vd=e=>Bd().has(e),Hd=e=>fd(Id?a.t.env[e.toUpperCase().replaceAll(`-`,`_`)]:hd.getItem(e)),Ud=e=>Vd(`--`+e)||Hd(e)!==null,Wd=Ud(`production`);Id&&Fd(a.t.env.FORCE_COLOR,[`true`,`1`,`2`])||!Vd(`--no-colors`)&&!Ud(`no-color`)&&(!Id||a.t.stdout.isTTY)&&(!Id||Vd(`--color`)||Hd(`COLORTERM`)!==null||(Hd(`TERM`)||``).includes(`color`));var Gd=e=>new Uint8Array(e),Kd=(e,t,n)=>new Uint8Array(e,t,n),qd=e=>new Uint8Array(e),Jd=e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=lu(e[n]);return btoa(t)},Yd=e=>r.t.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Xd=e=>{let t=atob(e),n=Gd(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n},Zd=e=>{let t=r.t.from(e,`base64`);return Kd(t.buffer,t.byteOffset,t.byteLength)},Qd=Ld?Jd:Yd,$d=Ld?Xd:Zd,ef=e=>{let t=Gd(e.byteLength);return t.set(e),t},tf=class{constructor(e,t){this.left=e,this.right=t}},nf=(e,t)=>new tf(e,t),rf=e=>e.next()>=.5,af=(e,t,n)=>eu(e.next()*(n+1-t)+t),of=(e,t,n)=>eu(e.next()*(n+1-t)+t),sf=(e,t,n)=>of(e,t,n),cf=e=>lu(sf(e,97,122)),lf=(e,t=0,n=20)=>{let r=sf(e,t,n),i=``;for(let t=0;t<r;t++)i+=cf(e);return i},uf=(e,t)=>t[sf(e,0,t.length-1)],df=Symbol(`0schema`),ff=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(yu(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
38
|
-
`)}},pf=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[vd]?yd(e,t):Zl(e)?Jl(e,e=>Yl(t,t=>pf(e,t))):bd(e)?Dd(e,(e,n)=>pf(e,t[n])):!1,W=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),pf(t,n)}equals(e){return this.constructor===e.constructor&&Pd(this.shape,e.shape)}[df](){return!0}[vd](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Uu()}get nullable(){return Wf(this,ap)}get optional(){return new Sf(this)}cast(e){return lp(e,this),e}expect(e){return lp(e,this),e}},mf=class extends W{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}},G=(e,t=null)=>new mf(e,t);G(mf);var hf=class extends W{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},K=e=>new hf(e);G(hf);var gf=class extends W{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},_f=(...e)=>new gf(e),vf=G(gf),yf=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),bf=e=>{if(ep.check(e))return[yf(e)];if(vf.check(e))return e.shape.map(e=>e+``);if($f.check(e))return[`[+-]?\\d+.?\\d*`];if(tp.check(e))return[`.*`];if(Gf.check(e))return e.shape.map(bf).flat(1);V()};G(class extends W{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(bf).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var xf=Symbol(`optional`),Sf=class extends W{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[xf](){return!0}},Cf=G(Sf),wf=class extends W{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new wf,G(wf);var Tf=class e extends W{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):Dd(this.shape,(n,r)=>{let i=this._isPartial&&!Od(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Ef=e=>new Tf(e),Df=G(Tf),Of=K(e=>e!=null&&(e.constructor===Object||e.constructor==null)),kf=class extends W{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&Dd(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}},Af=(e,t)=>new kf(e,t),jf=G(kf),Mf=class extends W{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&Dd(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},Nf=(...e)=>new Mf(e);G(Mf);var Pf=class extends W{constructor(e){super(),this.shape=e.length===1?e[0]:new Uf(e)}check(e,t){let n=Zl(e)&&Jl(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},Ff=(...e)=>new Pf(e),If=G(Pf),Lf=K(e=>Zl(e)),Rf=class extends W{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},zf=(e,t=null)=>new Rf(e,t);G(Rf);var Bf=zf(W),Vf=G(class extends W{constructor(e){super(),this.len=e.length-1,this.args=Nf(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),Hf=K(e=>typeof e==`function`);G(class extends W{constructor(e){super(),this.shape=e}check(e,t){let n=Jl(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var Uf=class extends W{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=Yl(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},Wf=(...e)=>e.findIndex(e=>Gf.check(e))>=0?Wf(...e.map(e=>cp(e)).map(e=>Gf.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new Uf(e),Gf=G(Uf),Kf=()=>!0,qf=K(Kf),Jf=G(hf,e=>e.shape===Kf),Yf=K(e=>typeof e==`bigint`),Xf=K(e=>e===Yf),Zf=K(e=>typeof e==`symbol`);K(e=>e===Zf);var Qf=K(e=>typeof e==`number`),$f=K(e=>e===Qf),ep=K(e=>typeof e==`string`),tp=K(e=>e===ep),np=K(e=>typeof e==`boolean`),rp=K(e=>e===np),ip=_f(void 0);G(gf,e=>e.shape.length===1&&e.shape[0]===void 0),_f(void 0);var ap=_f(null),op=G(gf,e=>e.shape.length===1&&e.shape[0]===null);G(Uint8Array),G(mf,e=>e.shape===Uint8Array);var sp=Wf(Qf,ep,ap,ip,Yf,np,Zf);(()=>{let e=Ff(qf),t=Af(ep,qf),n=Wf(Qf,ep,ap,np,e,t);return e.shape=n,t.shape.values=n,n})();var cp=e=>{if(Bf.check(e))return e;if(Of.check(e)){let t={};for(let n in e)t[n]=cp(e[n]);return Ef(t)}else if(Lf.check(e))return Wf(...e.map(cp));else if(sp.check(e))return _f(e);else if(Hf.check(e))return G(e);V()},lp=Wd?()=>{}:(e,t)=>{let n=new ff;if(!t.check(e,n))throw Hu(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},up=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:cp(e),h:t}),this}else(e){return this.if(qf,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw Hu(`Unhandled pattern`)}}},dp=(e=>new up(e))(qf).if($f,(e,t)=>af(t,su,ou)).if(tp,(e,t)=>lf(t)).if(rp,(e,t)=>rf(t)).if(Xf,(e,t)=>BigInt(af(t,su,ou))).if(Gf,(e,t)=>fp(t,uf(t,e.shape))).if(Df,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(Cf.check(i)){if(rf(t))continue;i=i.shape}n[r]=dp(i,t)}return n}).if(If,(e,t)=>{let n=[],r=of(t,0,42);for(let i=0;i<r;i++)n.push(fp(t,e.shape));return n}).if(vf,(e,t)=>uf(t,e.shape)).if(op,(e,t)=>null).if(Vf,(e,t)=>{let n=fp(t,e.res);return()=>n}).if(Jf,(e,t)=>fp(t,uf(t,[Qf,ep,ap,ip,Yf,np,Ff(Qf),Af(Wf(`a`,`b`,`c`),Qf)]))).if(jf,(e,t)=>{let n={},r=af(t,0,3);for(let i=0;i<r;i++){let r=fp(t,e.shape.keys);n[r]=fp(t,e.shape.values)}return n}).done(),fp=(e,t)=>dp(cp(t),e),pp=typeof document<`u`?document:{};K(e=>e.nodeType===_p),typeof DOMParser<`u`&&new DOMParser,K(e=>e.nodeType===mp),K(e=>e.nodeType===hp);var mp=pp.ELEMENT_NODE,hp=pp.TEXT_NODE;pp.CDATA_SECTION_NODE,pp.COMMENT_NODE;var gp=pp.DOCUMENT_NODE;pp.DOCUMENT_TYPE_NODE;var _p=pp.DOCUMENT_FRAGMENT_NODE;K(e=>e.nodeType===gp);var vp=Symbol,yp=vp(),bp=vp();vp(),vp(),vp();var xp=vp();vp();var Sp=vp();vp(),ud(),nf(`font-weight`,`bold`),nf(`font-weight`,`normal`),nf(`color`,`blue`),nf(`color`,`green`),nf(`color`,`grey`),nf(`color`,`red`),nf(`color`,`purple`),nf(`color`,`orange`),nf(`color`,`black`);var Cp=(...e)=>{Tp.forEach(t=>t.print(e))},wp=(...e)=>{e.unshift(Sp),Tp.forEach(t=>t.print(e))},Tp=Wl(),Ep=e=>({[Symbol.iterator](){return this},next:e}),Dp=(e,t)=>Ep(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),Op=(e,t)=>Ep(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),kp=class{constructor(e,t){this.clock=e,this.len=t}},Ap=class{constructor(){this.clients=new Map}},jp=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r<t.length&&o.clock<a;o=t[++r])Hm(e,i,o.clock,o.len,n)}}),Mp=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=eu((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},Np=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&Mp(n,t.clock)!==null},Pp=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new kp(r.clock,ru(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},Fp=e=>{let t=new Ap;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)Kl(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return Pp(t),t},Ip=(e,t,n,r)=>{Hl(e.clients,t,()=>[]).push(new kp(n,r))},Lp=()=>new Ap,Rp=e=>{let t=Lp();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new kp(i,a))}}r.length>0&&t.clients.set(n,r)}),t},zp=(e,t)=>{z(e.restEncoder,t.clients.size),ql(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),z(e.restEncoder,t);let r=n.length;z(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},Bp=e=>{let t=new Ap,n=U(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=U(e.restDecoder),r=U(e.restDecoder);if(r>0){let i=Hl(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new kp(e.readDsClock(),e.readDsLen()))}}return t},Vp=(e,t,n)=>{let r=new Ap,i=U(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=U(e.restDecoder),a=U(e.restDecoder),o=n.clients.get(i)||[],s=J(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&Ip(r,i,s,a-s);let e=Im(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,Yg(t,c,n-c.id.clock)),e++);e<o.length&&(c=o[e++],c.id.clock<a);)c.deleted||(a<c.id.clock+c.length&&o.splice(e,0,Yg(t,c,a-c.id.clock)),c.delete(t))}else Ip(r,i,n,a-n)}}if(r.clients.size>0){let e=new Zp;return z(e.restEncoder,0),zp(e,r),e.toUint8Array()}return null},Hp=sd,Up=class e extends Ql{constructor({guid:e=ld(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=Hp(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Nm,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=dd(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>dd(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&Y(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(ql(this.subdocs).map(e=>e.guid))}transact(e,t=null){return Y(this,e,t)}get(e,t=Z){let n=Hl(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==Z&&r!==t)if(r===Z){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=``){return this.get(e,zh)}getText(e=``){return this.get(e,og)}getMap(e=``){return this.get(e,Hh)}getXmlElement(e=``){return this.get(e,dg)}getXmlFragment(e=``){return this.get(e,lg)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,ql(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,Y(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},Wp=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return U(this.restDecoder)}readDsLen(){return U(this.restDecoder)}},Gp=class extends Wp{readLeftID(){return q(U(this.restDecoder),U(this.restDecoder))}readRightID(){return q(U(this.restDecoder),U(this.restDecoder))}readClient(){return U(this.restDecoder)}readInfo(){return Xu(this.restDecoder)}readString(){return Qu(this.restDecoder)}readParentInfo(){return U(this.restDecoder)===1}readTypeRef(){return U(this.restDecoder)}readLen(){return U(this.restDecoder)}readAny(){return td(this.restDecoder)}readBuf(){return ef(H(this.restDecoder))}readJSON(){return JSON.parse(Qu(this.restDecoder))}readKey(){return Qu(this.restDecoder)}},Kp=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=U(this.restDecoder),this.dsCurrVal}readDsLen(){let e=U(this.restDecoder)+1;return this.dsCurrVal+=e,e}},qp=class extends Kp{constructor(e){super(e),this.keys=[],U(e),this.keyClockDecoder=new id(H(e)),this.clientDecoder=new rd(H(e)),this.leftClockDecoder=new id(H(e)),this.rightClockDecoder=new id(H(e)),this.infoDecoder=new nd(H(e),Xu),this.stringDecoder=new ad(H(e)),this.parentInfoDecoder=new nd(H(e),Xu),this.typeRefDecoder=new rd(H(e)),this.lenDecoder=new rd(H(e))}readLeftID(){return new bm(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new bm(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 td(this.restDecoder)}readBuf(){return H(this.restDecoder)}readJSON(){return td(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},Jp=class{constructor(){this.restEncoder=I()}toUint8Array(){return L(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){z(this.restEncoder,e)}writeDsLen(e){z(this.restEncoder,e)}},Yp=class extends Jp{writeLeftID(e){z(this.restEncoder,e.client),z(this.restEncoder,e.clock)}writeRightID(e){z(this.restEncoder,e.client),z(this.restEncoder,e.clock)}writeClient(e){z(this.restEncoder,e)}writeInfo(e){Cu(this.restEncoder,e)}writeString(e){Du(this.restEncoder,e)}writeParentInfo(e){z(this.restEncoder,+!!e)}writeTypeRef(e){z(this.restEncoder,e)}writeLen(e){z(this.restEncoder,e)}writeAny(e){Fu(this.restEncoder,e)}writeBuf(e){B(this.restEncoder,e)}writeJSON(e){Du(this.restEncoder,JSON.stringify(e))}writeKey(e){Du(this.restEncoder,e)}},Xp=class{constructor(){this.restEncoder=I(),this.dsCurrVal=0}toUint8Array(){return L(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,z(this.restEncoder,t)}writeDsLen(e){e===0&&V(),z(this.restEncoder,e-1),this.dsCurrVal+=e}},Zp=class extends Xp{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Bu,this.clientEncoder=new Ru,this.leftClockEncoder=new Bu,this.rightClockEncoder=new Bu,this.infoEncoder=new Iu(Cu),this.stringEncoder=new Vu,this.parentInfoEncoder=new Iu(Cu),this.typeRefEncoder=new Ru,this.lenEncoder=new Ru}toUint8Array(){let e=I();return z(e,0),B(e,this.keyClockEncoder.toUint8Array()),B(e,this.clientEncoder.toUint8Array()),B(e,this.leftClockEncoder.toUint8Array()),B(e,this.rightClockEncoder.toUint8Array()),B(e,L(this.infoEncoder)),B(e,this.stringEncoder.toUint8Array()),B(e,L(this.parentInfoEncoder)),B(e,this.typeRefEncoder.toUint8Array()),B(e,this.lenEncoder.toUint8Array()),Ou(e,L(this.restEncoder)),L(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)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Fu(this.restEncoder,e)}writeBuf(e){B(this.restEncoder,e)}writeJSON(e){Fu(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},Qp=(e,t,n,r)=>{r=ru(r,t[0].id.clock);let i=Im(t,r);z(e.restEncoder,t.length-i),e.writeClient(n),z(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},$p=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{J(t,n)>e&&r.set(n,e)}),Pm(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),z(e.restEncoder,r.size),ql(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{Qp(e,t.clients.get(n),n,r)})},em=(e,t)=>{let n=Bl(),r=U(e.restDecoder);for(let i=0;i<r;i++){let r=U(e.restDecoder),i=Array(r),a=e.readClient(),o=U(e.restDecoder);n.set(a,{i:0,refs:i});for(let n=0;n<r;n++){let r=e.readInfo();switch(31&r){case 0:{let t=e.readLen();i[n]=new bg(q(a,o),t),o+=t;break}case 10:{let t=U(e.restDecoder);i[n]=new $g(q(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new $(q(a,o),null,(r&128)==128?e.readLeftID():null,null,(r&64)==64?e.readRightID():null,s?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,s&&(r&32)==32?e.readString():null,Xg(e,r));i[n]=c,o+=c.length}}}}return n},tm=(e,t,n)=>{let r=[],i=ql(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new Nm,c=new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==$g){let i=Hl(d,u.id.client,()=>J(t,u.id.client))-u.id.clock;if(i<0)r.push(u),l(u.id.client,u.id.clock-1),f();else{let a=u.getMissing(e,t);if(a!==null){r.push(u);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)l(a,J(t,a)),f();else{u=e.refs[e.i++];continue}}else (i===0||i<u.length)&&(u.integrate(e,i),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=a(),o===null)break;u=o.refs[o.i++]}}if(s.clients.size>0){let e=new Zp;return $p(e,s,new Map),z(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},nm=(e,t)=>$p(e,t.doc.store,t.beforeState),rm=(e,t,n,r=new qp(e))=>Y(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=tm(e,i,em(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<J(i,e)){t=!0;break}if(a){for(let[e,t]of a.missing){let n=o.missing.get(e);(n==null||n>t)&&o.missing.set(e,t)}o.update=th([o.update,a.update])}}else i.pendingStructs=a;let s=Vp(r,e,i);if(i.pendingDs){let t=new qp(qu(i.pendingDs));U(t.restDecoder);let n=Vp(t,e,i);s&&n?i.pendingDs=th([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,im(e.doc,t)}},n,!1),im=(e,t,n,r=qp)=>{let i=qu(t);rm(i,e,n,new r(i))},am=(e,t,n)=>im(e,t,n,Gp),om=(e,t,n=new Map)=>{$p(e,t.store,n),zp(e,Rp(t.store))},sm=(e,t=new Uint8Array([0]),n=new Zp)=>{om(n,e,um(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(nh(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Yp)return $m(r.map((e,t)=>t===0?e:sh(e)));if(n.constructor===Zp)return th(r)}return r[0]},cm=(e,t)=>sm(e,t,new Yp),lm=e=>{let t=new Map,n=U(e.restDecoder);for(let r=0;r<n;r++){let n=U(e.restDecoder),r=U(e.restDecoder);t.set(n,r)}return t},um=e=>lm(new Wp(qu(e))),dm=(e,t)=>(z(e.restEncoder,t.size),ql(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{z(e.restEncoder,t),z(e.restEncoder,n)}),e),fm=(e,t)=>dm(e,Pm(t.store)),pm=(e,t=new Xp)=>(e instanceof Map?dm(t,e):fm(t,e),t.toUint8Array()),mm=e=>pm(e,new Jp),hm=class{constructor(){this.l=[]}},gm=()=>new hm,_m=(e,t)=>e.l.push(t),vm=(e,t)=>{let n=e.l;n.length,e.l=n.filter(e=>t!==e),e.l.length},ym=(e,t,n)=>Md(e.l,[t,n]),bm=class{constructor(e,t){this.client=e,this.clock=t}},xm=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,q=(e,t)=>new bm(e,t),Sm=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw V()},Cm=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},wm=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},Tm=(e,t,n=0)=>new wm(e,t,n),Em=(e,t,n)=>{let r=null,i=null;return e._item===null?i=Sm(e):r=q(e._item.id.client,e._item.id.clock),new Cm(r,i,t,n)},Dm=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return Em(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return Em(e,q(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return Em(e,r.lastId,n);r=r.right}return Em(e,null,n)},Om=(e,t)=>{let n=Lm(e,t);return{item:n,diff:t.clock-n.id.clock}},km=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if(J(r,i.client)<=i.clock)return null;let e=n?Jg(r,i):Om(r,i),t=e.item;if(!(t instanceof $))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(J(r,a.client)<=a.clock)return null;let{item:e}=n?Jg(r,a):{item:Lm(r,a)};if(e instanceof $&&e.content instanceof Kg)c=e.content.type;else return null}else throw V();l=s>=0?c._length:0}return Tm(c,l,e.assoc)},Am=class{constructor(e,t){this.ds=e,this.sv=t}};((e,t)=>new Am(e,t))(Lp(),new Map);var jm=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Np(t.ds,e.id),Mm=(e,t)=>{let n=Hl(e.meta,Mm,Wl),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<J(r,n)&&zm(e,q(n,t))}),jp(e,t.ds,e=>{}),n.add(t))},Nm=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Pm=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},J=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},Fm=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw V()}n.push(t)},Im=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=eu(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=eu((n+r)/2)}throw V()},Lm=(e,t)=>{let n=e.clients.get(t.client);return n[Im(n,t.clock)]},Rm=(e,t,n)=>{let r=Im(t,n),i=t[r];return i.id.clock<n&&i instanceof $?(t.splice(r+1,0,Yg(e,i,n-i.id.clock)),r+1):r},zm=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Rm(e,n,t.clock)]},Bm=(e,t,n)=>{let r=t.clients.get(n.client),i=Im(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==bg&&r.splice(i+1,0,Yg(e,a,n.clock-a.id.clock+1)),a},Vm=(e,t,n)=>{let r=e.clients.get(t.id.client);r[Im(r,t.id.clock)]=n},Hm=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=Rm(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&Rm(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Um=class{constructor(e,t,n){this.doc=e,this.deleteSet=new Ap,this.beforeState=Pm(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=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},Wm=(e,t)=>t.deleteSet.clients.size===0&&!Ul(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(Pp(t.deleteSet),nm(e,t),zp(e,t.deleteSet),!0),Gm=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&Hl(e.changed,t,Wl).add(n)},Km=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof $&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},qm=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=Im(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof $&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},Jm=(e,t)=>{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=nu(r.length-1,1+Im(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+Km(r,e)}})},Ym=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{Pp(a),n.afterState=Pm(n.doc.store),r.emit(`beforeObserverCalls`,[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{(r._item===null||!r._item.deleted)&&r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&(t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{ym(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&rg(n)})}),Md(e,[])}finally{r.gc&&qm(a,i,r.gcFilter),Jm(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=ru(Im(e,r),1);for(let t=e.length-1;t>=n;)t-=1+Km(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=Im(r,n);a+1<r.length&&Km(r,a+1)>1||a>0&&Km(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(Cp(Sp,yp,`[yjs] `,bp,xp,`Changed the client-id because another client seems to be using it.`),r.clientID=Hp()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Yp;Wm(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new Zp;Wm(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):Ym(e,t+1)}}},Y=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Um(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&Ym(i,0)}}return o};function*Xm(e){let t=U(e.restDecoder);for(let n=0;n<t;n++){let t=U(e.restDecoder),n=e.readClient(),r=U(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=U(e.restDecoder);yield new $g(q(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new $(q(n,r),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(t&32)==32?e.readString():null,Xg(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new bg(q(n,r),t),r+=t}}}}var Zm=class{constructor(e,t){this.gen=Xm(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===$g);return this.curr}},Qm=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},$m=e=>th(e,Gp,Yp),eh=(e,t)=>{if(e.constructor===bg){let{client:n,clock:r}=e.id;return new bg(q(n,r+t),e.length-t)}else if(e.constructor===$g){let{client:n,clock:r}=e.id;return new $g(q(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new $(q(r,i+t),null,q(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},th=(e,t=qp,n=Zp)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(qu(e))),i=r.map(e=>new Zm(e,!0)),a=null,o=new n,s=new Qm(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===$g?1:-1:n}else return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)ih(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock)if(a.struct.constructor===$g)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{ih(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new $g(q(t,a.struct.id.clock+a.struct.length),e),offset:0}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===$g?a.struct.length-=t:n=eh(n,t)),a.struct.mergeWith(n)||(ih(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==$g;n=e.next())ih(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(ih(s,a.struct,a.offset),a=null),ah(s),zp(o,Fp(r.map(e=>Bp(e)))),o.toUint8Array()},nh=(e,t,n=qp,r=Zp)=>{let i=um(t),a=new r,o=new Qm(a),s=new n(qu(e)),c=new Zm(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===$g){c.next();continue}if(e.id.clock+e.length>n)for(ih(o,e,ru(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)ih(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}return ah(o),zp(a,Bp(s)),a.toUint8Array()},rh=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:L(e.encoder.restEncoder)}),e.encoder.restEncoder=I(),e.written=0)},ih=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&rh(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),z(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},ah=e=>{rh(e);let t=e.encoder.restEncoder;z(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];z(t,r.written),Ou(t,r.restEncoder)}},oh=(e,t,n,r)=>{let i=new n(qu(e)),a=new Zm(i,!1),o=new r,s=new Qm(o);for(let e=a.curr;e!==null;e=a.next())ih(s,t(e),0);return ah(s),zp(o,Bp(i)),o.toUint8Array()},sh=e=>oh(e,Nd,qp,Yp),ch=`You must not compute changes after the event-handler fired.`,lh=class{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||=uh(this.currentTarget,this.target)}deletes(e){return Np(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Hu(ch);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r))if(e!==null&&this.deletes(e))i=`delete`,a=Gl(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=Gl(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=Gl(r.content.getContent());else return;e.set(n,{action:i,oldValue:a})}}),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 Hu(ch);let t=this.target,n=Wl(),r=Wl(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}},uh=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},X=()=>{wp(`Invalid access: Add Yjs type to a document before reading data.`)},dh=80,fh=0,ph=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=fh++}},mh=e=>{e.timestamp=fh++},hh=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=fh++},gh=(e,t,n)=>{if(e.length>=dh){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return hh(r,t,n),r}else{let r=new ph(t,n);return e.push(r),r}},_h=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>tu(t-e.index)<tu(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,mh(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&tu(n.index-i)<r.parent.length/dh?(hh(n,r,i),n):gh(e._searchMarker,r,i)},vh=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=ru(t,i.index+n))}},yh=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;Hl(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;ym(r._eH,n,t)},Z=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=gm(),this._dEH=gm(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Uu()}clone(){throw Uu()}_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){_m(this._eH,e)}observeDeep(e){_m(this._dEH,e)}unobserve(e){vm(this._eH,e)}unobserveDeep(e){vm(this._dEH,e)}toJSON(){}},bh=(e,t,n)=>{e.doc??X(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},xh=e=>{e.doc??X();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},Sh=(e,t)=>{let n=0,r=e._start;for(e.doc??X();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},Ch=(e,t)=>{let n=[];return Sh(e,(r,i)=>{n.push(t(r,i,e))}),n},wh=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},Th=(e,t)=>{e.doc??X();let n=_h(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},Eh=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new $(q(o,J(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Pg(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new $(q(o,J(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new xg(new Uint8Array(n))),i.integrate(e,0);break;case Up:i=new $(q(o,J(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Eg(n)),i.integrate(e,0);break;default:if(n instanceof Z)i=new $(q(o,J(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Kg(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},Dh=()=>Hu(`Length exceeded!`),Oh=(e,t,n,r)=>{if(n>t._length)throw Dh();if(n===0)return t._searchMarker&&vh(t._searchMarker,n,r.length),Eh(e,t,null,r);let i=n,a=_h(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&zm(e,q(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&vh(t._searchMarker,i,r.length),Eh(e,t,o,r)},kh=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return Eh(e,t,r,n)},Ah=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=_h(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n<s.length&&zm(e,q(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&zm(e,q(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw Dh();t._searchMarker&&vh(t._searchMarker,i,-a+r)},jh=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Mh=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new Pg([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new Pg([r]);break;case Uint8Array:s=new xg(r);break;case Up:s=new Eg(r);break;default:if(r instanceof Z)s=new Kg(r);else throw Error(`Unexpected content type`)}new $(q(o,J(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},Nh=(e,t)=>{e.doc??X();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Ph=e=>{let t={};return e.doc??X(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},Fh=(e,t)=>{e.doc??X();let n=e._map.get(t);return n!==void 0&&!n.deleted},Ih=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&jm(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},Lh=e=>(e.doc??X(),Dp(e._map.entries(),e=>!e[1].deleted)),Rh=class extends lh{},zh=class e extends Z{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof Z?e.clone():e)),t}get length(){return this.doc??X(),this._length}_callObserver(e,t){super._callObserver(e,t),yh(this,e,new Rh(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Y(this.doc,n=>{Oh(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):Y(this.doc,t=>{kh(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Y(this.doc,n=>{Ah(n,this,e,t)})}get(e){return Th(this,e)}toArray(){return xh(this)}slice(e=0,t=this.length){return bh(this,e,t)}toJSON(){return this.map(e=>e instanceof Z?e.toJSON():e)}map(e){return Ch(this,e)}forEach(e){Sh(this,e)}[Symbol.iterator](){return wh(this)}_write(e){e.writeTypeRef(zg)}},Bh=e=>new zh,Vh=class extends lh{constructor(e,t,n){super(e,t),this.keysChanged=n}},Hh=class e extends Z{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((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof Z?e.clone():e)}),t}_callObserver(e,t){yh(this,e,new Vh(this,e,t))}toJSON(){this.doc??X();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof Z?r.toJSON():r}}),e}get size(){return[...Lh(this)].length}keys(){return Op(Lh(this),e=>e[0])}values(){return Op(Lh(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return Op(Lh(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??X(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):Y(this.doc,t=>{jh(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):Y(this.doc,n=>{Mh(n,this,e,t)}),t}get(e){return Nh(this,e)}has(e){return Fh(this,e)}clear(){this.doc===null?this._prelimContent.clear():Y(this.doc,e=>{this.forEach(function(t,n,r){jh(e,r,n)})})}_write(e){e.writeTypeRef(Bg)}},Uh=e=>new Hh,Wh=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&kd(e,t),Gh=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&V(),this.right.content.constructor){case Q:this.right.deleted||Yh(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}},Kh=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case Q:t.right.deleted||Yh(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&zm(e,q(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},qh=(e,t,n,r)=>{let i=new Map,a=r?_h(t,n):null;return a?Kh(e,new Gh(a.p.left,a.p,a.index,i),n-a.index):Kh(e,new Gh(null,t._start,0,i),n)},Jh=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Q&&Wh(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new $(q(a,J(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new Q(o,r));l.integrate(e,0),n.right=l,n.forward()})},Yh=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Xh=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===Q&&Wh(t[e.right.content.key]??null,e.right.content.value));)e.forward()},Zh=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!Wh(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new $(q(a,J(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new Q(s,c)),n.right.integrate(e,0),n.forward()}}return o},Qh=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;Xh(n,i);let s=Zh(e,t,n,i),c=r.constructor===String?new Ig(r):r instanceof Z?new Kg(r):new Og(r),{left:l,right:u,index:d}=n;t._searchMarker&&vh(t._searchMarker,n.index,c.getLength()),u=new $(q(o,J(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),Jh(e,t,n,s)},$h=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;Xh(n,i);let s=Zh(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===Q));){if(!n.right.deleted)switch(n.right.content.constructor){case Q:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(Wh(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r<n.right.length&&zm(e,q(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`
|
|
39
|
-
`;n.right=new $(q(o,J(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new
|
|
40
|
-
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&Qh(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&ig(n,r,a.delete):$h(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??X();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(jm(s,e)||t!==void 0&&jm(s,t))switch(s.content.constructor){case Ig:{let r=i.get(`ychange`);e!==void 0&&!jm(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!jm(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case Kg:case Og:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case Q:jm(s,e)&&(c(),Yh(i,s.content));break}s=s.right}c()};return e||t?Y(a,n=>{e&&Mm(n,e),t&&Mm(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):Y(r,r=>{let i=qh(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),Qh(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):Y(r,r=>{let i=qh(r,this,e,!n);Qh(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):Y(n,n=>{ig(n,qh(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):Y(r,r=>{let i=qh(r,this,e,!1);i.right!==null&&$h(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):Y(this.doc,t=>{jh(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):Y(this.doc,n=>{Mh(n,this,e,t)})}getAttribute(e){return Nh(this,e)}getAttributes(){return Ph(this)}_write(e){e.writeTypeRef(Vg)}},sg=e=>new og,cg=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??X()}[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===dg||t.constructor===lg)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}else e=e.parent===this._root?null: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})}},lg=class e extends Z{constructor(){super(),this._prelimContent=[]}get firstChild(){let 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 e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof Z?e.clone():e)),t}get length(){return this.doc??X(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new cg(this,e)}querySelector(e){e=e.toUpperCase();let t=new cg(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),ql(new cg(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){yh(this,e,new pg(this,t,e))}toString(){return Ch(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),Sh(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Y(this.doc,n=>{Oh(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)Y(this.doc,n=>{let r=e&&e instanceof Z?e._item:e;Eh(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw Hu(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Y(this.doc,n=>{Ah(n,this,e,t)})}toArray(){return xh(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Th(this,e)}slice(e=0,t=this.length){return bh(this,e,t)}forEach(e){Sh(this,e)}_write(e){e.writeTypeRef(Ug)}},ug=e=>new lg,dg=class e extends lg{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return Cd(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof Z?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+`="`+e[r]+`"`)}let i=this.nodeName.toLocaleLowerCase();return`<${i}${t.length>0?` `+t.join(` `):``}>${super.toString()}</${i}>`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):Y(this.doc,t=>{jh(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):Y(this.doc,n=>{Mh(n,this,e,t)})}getAttribute(e){return Nh(this,e)}hasAttribute(e){return Fh(this,e)}getAttributes(e){return e?Ih(this,e):Ph(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return Sh(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Hg),e.writeKey(this.nodeName)}},fg=e=>new dg(e.readKey()),pg=class extends lh{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},mg=class e extends Hh{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(Wg),e.writeKey(this.hookName)}},hg=e=>new mg(e.readKey()),gg=class e extends og{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(Gg)}},_g=e=>new gg,vg=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Uu()}mergeWith(e){return!1}write(e,t,n){throw Uu()}integrate(e,t){throw Uu()}},yg=0,bg=class extends vg{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),Fm(e.doc.store,this)}write(e,t){e.writeInfo(yg),e.writeLen(this.length-t)}getMissing(e,t){return null}},xg=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw Uu()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},Sg=e=>new xg(e.readBuf()),Cg=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){Ip(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}},wg=e=>new Cg(e.readLen()),Tg=(e,t)=>new Up({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),Eg=class e{constructor(e){e._item,this.doc=e;let 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 e(Tg(this.doc.guid,this.opts))}splice(e){throw Uu()}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}},Dg=e=>new Eg(Tg(e.readString(),e.readAny())),Og=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw Uu()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},kg=e=>new Og(e.readJSON()),Q=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw Uu()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},Ag=e=>new Q(e.readKey(),e.readJSON()),jg=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(t===void 0?`undefined`:JSON.stringify(t))}}getRef(){return 2}},Mg=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();t===`undefined`?n.push(void 0):n.push(JSON.parse(t))}return new jg(n)},Ng=Hd(`node_env`)===`development`,Pg=class e{constructor(e){this.arr=e,Ng&&jd(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}},Fg=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new Pg(n)},Ig=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}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}},Lg=e=>new Ig(e.readString()),Rg=[Bh,Uh,sg,fg,ug,hg,_g],zg=0,Bg=1,Vg=2,Hg=3,Ug=4,Wg=5,Gg=6,Kg=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw Uu()}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(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.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(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},qg=e=>new Kg(Rg[e.readTypeRef()](e)),Jg=(e,t)=>{let n=t,r=0,i;do r>0&&(n=q(n.client,n.clock+r)),i=Lm(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof $);return{item:i,diff:r}},Yg=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new $(q(r,i+n),t,q(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=q(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},$=class e extends vg{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=J(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=J(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===bm&&this.id.client!==this.parent.client&&this.parent.clock>=J(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Bm(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=zm(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===bg||this.right&&this.right.constructor===bg)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===bm){let e=Lm(n,this.parent);e.constructor===bg?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Bm(e,e.doc.store,q(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 t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),xm(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(xm(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(Lm(e.doc.store,n.origin)))r.has(Lm(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null){let e=this.left.right;this.right=e,this.left.right=this}else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right===null?this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)):this.right.left=this,this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Fm(e.doc.store,this),this.content.integrate(e,this),Gm(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new bg(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:q(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&xm(e.origin,this.lastId)&&this.right===e&&xm(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)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.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){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),Ip(e.deleteSet,this.id.client,this.id.clock,this.length),Gm(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw V();this.content.gc(e),t?Vm(e,this,new bg(this.id,this.length)):this.content=new Cg(this.length)}write(e,t){let n=t>0?q(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=Sm(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===bm?(e.writeParentInfo(!1),e.writeLeftID(t)):V();i!==null&&e.writeString(i)}this.content.write(e,t)}},Xg=(e,t)=>Zg[t&31](e),Zg=[()=>{V()},wg,Mg,Sg,Lg,kg,Ag,qg,Fg,Dg,()=>{V()}],Qg=10,$g=class extends vg{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){V()}write(e,t){e.writeInfo(Qg),z(e.restEncoder,this.length-t)}getMissing(e,t){return null}},e_=typeof globalThis<`u`?globalThis:typeof window<`u`?window:r.r===void 0?{}:r.r,t_=`__ $YJS$ __`;e_[t_],e_[t_]=!0;var n_=new Map,r_=class{constructor(e){this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&this.onmessage!==null&&this.onmessage({data:$d(t.newValue||``)}),gd(this._onChange)}postMessage(e){hd.setItem(this.room,Qd(qd(e)))}close(){_d(this._onChange)}},i_=typeof BroadcastChannel>`u`?r_:BroadcastChannel,a_=e=>Hl(n_,e,()=>{let t=Wl(),n=new i_(e);return n.onmessage=e=>t.forEach(t=>t(e.data,`broadcastchannel`)),{bc:n,subs:t}}),o_=(e,t)=>(a_(e).subs.add(t),t),s_=(e,t)=>{let n=a_(e),r=n.subs.delete(t);return r&&n.subs.size===0&&(n.bc.close(),n_.delete(e)),r},c_=(e,t,n=null)=>{let r=a_(e);r.bc.postMessage(t),r.subs.forEach(e=>e(t,n))},l_=(e,t)=>{z(e,0),B(e,mm(t))},u_=(e,t,n)=>{z(e,1),B(e,cm(t,n))},d_=(e,t,n)=>u_(t,n,H(e)),f_=(e,t,n,r)=>{try{am(t,H(e),n)}catch(e){r?.(e)}},p_=(e,t)=>{z(e,2),B(e,t)},m_=f_,h_=(e,t,n,r,i)=>{let a=U(e);switch(a){case 0:d_(e,t,n);break;case 1:f_(e,n,r,i);break;case 2:m_(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},g_=(e,t,n)=>{switch(U(e)){case 0:n(t,Qu(e))}},__=3e4,v_=class extends $l{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=ud();this.getLocalState()!==null&&3e4/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&3e4<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&y_(this,t,`timeout`)},eu(__/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){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:ud()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),Pd(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},y_=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:ud()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},b_=(e,t,n=e.states)=>{let r=t.length,i=I();z(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;z(i,r),z(i,s),Du(i,JSON.stringify(o))}return L(i)},x_=(e,t,n)=>{let r=qu(t),i=ud(),a=[],o=[],s=[],c=[],l=U(r);for(let t=0;t<l;t++){let t=U(r),n=U(r),l=JSON.parse(Qu(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(Pd(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},S_=e=>wd(e,(e,t)=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join(`&`);a.n();var C_=[];C_[0]=(e,t,n,r,i)=>{z(e,0);let a=h_(t,e,n.doc,n);r&&a===1&&!n.synced&&(n.synced=!0)},C_[3]=(e,t,n,r,i)=>{z(e,1),B(e,b_(n.awareness,Array.from(n.awareness.getStates().keys())))},C_[1]=(e,t,n,r,i)=>{x_(n.awareness,H(t),n)},C_[2]=(e,t,n,r,i)=>{g_(t,n.doc,(e,t)=>T_(n,t))};var w_=3e4,T_=(e,t)=>void 0,E_=(e,t,n)=>{let r=qu(t),i=I(),a=U(r),o=e.messageHandlers[a];return o&&o(i,r,e,n,a),i},D_=(e,t,n)=>{t===e.ws&&(e.emit(`connection-close`,[n,e]),e.ws=null,t.close(),e.wsconnecting=!1,e.wsconnected?(e.wsconnected=!1,e.synced=!1,y_(e.awareness,Array.from(e.awareness.getStates().keys()).filter(t=>t!==e.doc.clientID),e),e.emit(`status`,[{status:`disconnected`}])):e.wsUnsuccessfulReconnects++,setTimeout(O_,nu(iu(2,e.wsUnsuccessfulReconnects)*100,e.maxBackoffTime),e))},O_=e=>{if(e.shouldConnect&&e.ws===null){let t=new e._WS(e.url,e.protocols);t.binaryType=`arraybuffer`,e.ws=t,e.wsconnecting=!0,e.wsconnected=!1,e.synced=!1,t.onmessage=n=>{e.wsLastMessageReceived=ud();let r=E_(e,new Uint8Array(n.data),!0);xu(r)>1&&t.send(L(r))},t.onerror=t=>{e.emit(`connection-error`,[t,e])},t.onclose=n=>{D_(e,t,n)},t.onopen=()=>{e.wsLastMessageReceived=ud(),e.wsconnecting=!1,e.wsconnected=!0,e.wsUnsuccessfulReconnects=0,e.emit(`status`,[{status:`connected`}]);let n=I();if(z(n,0),l_(n,e.doc),t.send(L(n)),e.awareness.getLocalState()!==null){let n=I();z(n,1),B(n,b_(e.awareness,[e.doc.clientID])),t.send(L(n))}},e.emit(`status`,[{status:`connecting`}])}},k_=(e,t)=>{let n=e.ws;e.wsconnected&&n&&n.readyState===n.OPEN&&n.send(t),e.bcconnected&&c_(e.bcChannel,t,e)},A_=class extends Ql{constructor(e,t,n,{connect:r=!0,awareness:i=new v_(n),params:o={},protocols:s=[],WebSocketPolyfill:c=WebSocket,resyncInterval:l=-1,maxBackoffTime:u=2500,disableBc:d=!1}={}){for(super();e[e.length-1]===`/`;)e=e.slice(0,e.length-1);this.serverUrl=e,this.bcChannel=e+`/`+t,this.maxBackoffTime=u,this.params=o,this.protocols=s,this.roomname=t,this.doc=n,this._WS=c,this.awareness=i,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=d,this.wsUnsuccessfulReconnects=0,this.messageHandlers=C_.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=r,this._resyncInterval=0,l>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){let e=I();z(e,0),l_(e,n),this.ws.send(L(e))}},l)),this._bcSubscriber=(e,t)=>{if(t!==this){let t=E_(this,new Uint8Array(e),!1);xu(t)>1&&c_(this.bcChannel,L(t),this)}},this._updateHandler=(e,t)=>{if(t!==this){let t=I();z(t,0),p_(t,e),k_(this,L(t))}},this.doc.on(`update`,this._updateHandler),this._awarenessUpdateHandler=({added:e,updated:t,removed:n},r)=>{let a=e.concat(t).concat(n),o=I();z(o,1),B(o,b_(i,a)),k_(this,L(o))},this._exitHandler=()=>{y_(this.awareness,[n.clientID],`app closed`)},Id&&a.t!==void 0&&a.t.on(`exit`,this._exitHandler),i.on(`update`,this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&w_<ud()-this.wsLastMessageReceived&&D_(this,this.ws,null)},w_/10),r&&this.connect()}get url(){let e=S_(this.params);return this.serverUrl+`/`+this.roomname+(e.length===0?``:`?`+e)}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,this.emit(`synced`,[e]),this.emit(`sync`,[e]))}destroy(){this._resyncInterval!==0&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),Id&&a.t!==void 0&&a.t.off(`exit`,this._exitHandler),this.awareness.off(`update`,this._awarenessUpdateHandler),this.doc.off(`update`,this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||=(o_(this.bcChannel,this._bcSubscriber),!0);let e=I();z(e,0),l_(e,this.doc),c_(this.bcChannel,L(e),this);let t=I();z(t,0),u_(t,this.doc),c_(this.bcChannel,L(t),this);let n=I();z(n,3),c_(this.bcChannel,L(n),this);let r=I();z(r,1),B(r,b_(this.awareness,[this.doc.clientID])),c_(this.bcChannel,L(r),this)}disconnectBc(){let e=I();z(e,1),B(e,b_(this.awareness,[this.doc.clientID],new Map)),k_(this,L(e)),this.bcconnected&&=(s_(this.bcChannel,this._bcSubscriber),!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&D_(this,this.ws,null)}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(O_(this),this.connectBc())}},j_=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},M_=class{constructor(e,t,n){this.start=e,this.end=t,this.direction=n}},N_=(e,t,n)=>{let r=e.getSelection();if(r!==null){let e=r.getStartPosition(),i=r.getEndPosition();return new M_(Dm(n,t.getOffsetAt(e)),Dm(n,t.getOffsetAt(i)),r.getDirection())}return null},P_=(e,t,n,r)=>{let i=km(n.start,r),a=km(n.end,r);if(i!==null&&a!==null&&i.type===t&&a.type===t){let t=e.getModel(),r=t.getPositionAt(i.index),o=t.getPositionAt(a.index);return s.l.createWithDirection(r.lineNumber,r.column,o.lineNumber,o.column,n.direction)}return null},F_=class{constructor(e,t,n=new Set,r=null){this.doc=e.doc,this.ytext=e,this.monacoModel=t,this.editors=n,this.mux=j_(),this._savedSelections=new Map,this._beforeTransaction=()=>{this.mux(()=>{this._savedSelections=new Map,n.forEach(n=>{if(n.getModel()===t){let r=N_(n,t,e);r!==null&&this._savedSelections.set(n,r)}})})},this.doc.on(`beforeAllTransactions`,this._beforeTransaction),this._decorations=new Map,this._rerenderDecorations=()=>{n.forEach(n=>{if(r&&n.getModel()===t){let i=this._decorations.get(n)||[],a=[];r.getStates().forEach((n,r)=>{if(r!==this.doc.clientID&&n.selection!=null&&n.selection.anchor!=null&&n.selection.head!=null){let i=km(n.selection.anchor,this.doc),o=km(n.selection.head,this.doc);if(i!==null&&o!==null&&i.type===e&&o.type===e){let e,n,c,l;i.index<o.index?(e=t.getPositionAt(i.index),n=t.getPositionAt(o.index),c=`yRemoteSelectionHead yRemoteSelectionHead-`+r,l=null):(e=t.getPositionAt(o.index),n=t.getPositionAt(i.index),c=null,l=`yRemoteSelectionHead yRemoteSelectionHead-`+r),a.push({range:new s.c(e.lineNumber,e.column,n.lineNumber,n.column),options:{className:`yRemoteSelection yRemoteSelection-`+r,afterContentClassName:c,beforeContentClassName:l}})}}}),this._decorations.set(n,n.deltaDecorations(i,a))}else this._decorations.delete(n)})},this._ytextObserver=n=>{this.mux(()=>{let r=0;n.delta.forEach(e=>{if(e.retain!==void 0)r+=e.retain;else if(e.insert!==void 0){let n=t.getPositionAt(r),i=new s.l(n.lineNumber,n.column,n.lineNumber,n.column),a=e.insert;t.applyEdits([{range:i,text:a}]),r+=a.length}else if(e.delete!==void 0){let n=t.getPositionAt(r),i=t.getPositionAt(r+e.delete),a=new s.l(n.lineNumber,n.column,i.lineNumber,i.column);t.applyEdits([{range:a,text:``}])}else throw V()}),this._savedSelections.forEach((t,n)=>{let r=P_(n,e,t,this.doc);r!==null&&n.setSelection(r)})}),this._rerenderDecorations()},e.observe(this._ytextObserver);{let n=e.toString();t.getValue()!==n&&t.setValue(n)}this._monacoChangeHandler=t.onDidChangeContent(t=>{this.mux(()=>{this.doc.transact(()=>{t.changes.sort((e,t)=>t.rangeOffset-e.rangeOffset).forEach(t=>{e.delete(t.rangeOffset,t.rangeLength),e.insert(t.rangeOffset,t.text)})},this)})}),this._monacoDisposeHandler=t.onWillDispose(()=>{this.destroy()}),r&&(n.forEach(n=>{n.onDidChangeCursorSelection(()=>{if(n.getModel()===t){let i=n.getSelection();if(i===null)return;let a=t.getOffsetAt(i.getStartPosition()),o=t.getOffsetAt(i.getEndPosition());if(i.getDirection()===s.u.RTL){let e=a;a=o,o=e}r.setLocalStateField(`selection`,{anchor:Dm(e,a),head:Dm(e,o)})}}),r.on(`change`,this._rerenderDecorations)}),this.awareness=r)}destroy(){this._monacoChangeHandler.dispose(),this._monacoDisposeHandler.dispose(),this.ytext.unobserve(this._ytextObserver),this.doc.off(`beforeAllTransactions`,this._beforeTransaction),this.awareness&&this.awareness.off(`change`,this._rerenderDecorations)}};function I_(e,t){let[n]=i.Ft(),r=i.wi(i.qt);return{saveEmailFromEditor:(0,u.useCallback)(()=>{let a=new Date().toISOString().slice(0,19).replace(`T`,` `),o=i.ba.isPlugin?r:e.project,s={parent:e?.id,...e?.meta===void 0?{}:{meta:e.meta},title:e.title,author:e.author,project:o,html:t?.getValue()||``,excerpt:a,subject:e.subject,preheader:e.preheader,common_styles:e.common_styles,parent_email:e.parent_email};n({emailId:e?.id,body:s}).catch(e=>{})},[t,e,r,n])}}var L_=()=>{let[e,t]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{let e=navigator.platform.toUpperCase().includes(`MAC`),n=n=>{let r=(e?n.metaKey:n.ctrlKey)&&n.code===`KeyZ`,i=r&&n.shiftKey;(r||i)&&(t(!0),n.preventDefault())},r=()=>{t(!1)},i=e=>{e.data?.operation===`application_action`&&(e.data.action===`undo`||e.data.action===`redo`)&&(t(!0),setTimeout(()=>t(!1),500))};return document.addEventListener(`keydown`,n,!0),document.addEventListener(`keyup`,r,!0),window.addEventListener(`message`,i),()=>{document.removeEventListener(`keydown`,n,!0),document.removeEventListener(`keyup`,r,!0),window.removeEventListener(`message`,i)}},[]),e},R_=({email:e,editorRef:t,setIsSpin:n,newEmailAiGeneratorRef:r})=>{let a=(0,u.useMemo)(()=>new Up,[]),o=l.l(),s=(0,u.useRef)([]),c=(0,u.useRef)([]),d=(0,u.useRef)(!1),f=(0,u.useRef)(0),p=(0,u.useRef)(``),[m,ee]=(0,u.useState)(null),[h,te]=(0,u.useState)(null),[g,_]=(0,u.useState)(!1),[v,ne]=(0,u.useState)([]),[y,b]=(0,u.useState)(!1),[x,re]=(0,u.useState)(!1),S=l.p(o),C=i.wi(i.n),{saveEmailFromEditor:w}=I_(e,m),T=(0,u.useRef)(null),[E,D]=(0,u.useState)(!1),[ie]=i.It(),O=e?.id,ae=!!(O===`3769995`||i.ba.isPlugin),oe=(0,u.useMemo)(()=>({name:{first_name:ae?C?.username:C?.first_name,last_name:ae?``:C?.last_name,email:C?.email},color:Rl()}),[C,ae]),se=(0,u.useMemo)(()=>Ll(v,oe),[oe,v]),ce=(0,u.useCallback)(()=>{h&&(h?.destroy(),te(null))},[h]),le=(0,u.useCallback)(()=>{try{w()}catch{}},[w]),ue=(0,u.useCallback)(async e=>{try{return await ie({emailId:O,source:`editor`,html:e}).unwrap(),!0}catch{return!1}},[O,ie]),de=(0,u.useCallback)(async e=>{if(await ue(e)&&E){let e=setTimeout(()=>{D(!1)},0);return()=>clearTimeout(e)}},[ue,D,E]);(0,u.useEffect)(()=>{!O||!i.Gi.isEditor||(v.length===1&&f.current>1&&h&&le(),f.current=v.length)},[v.length,h,le]),(0,u.useEffect)(()=>{if(!O||!i.Gi.isEditor||E)return;let e=new A_(l.s,ae?`${O}-plugin`:`${O}-collaborate`,a);return te(e),e.awareness.setLocalStateField(`user`,oe),()=>{e?.destroy(),a?.destroy()}},[a,oe,ae,O,E]);let fe=(0,u.useCallback)(e=>{if(!d.current){d.current=!0;try{let t=c.current,n=Array.from(e.getStates().values());(n.length>1||n.length!==t.length)&&(ne(n),requestAnimationFrame(()=>{Pl(n,m,s,g,_,oe)})),c.current=n}finally{d.current=!1}}},[m,s,g,_,oe]);(0,u.useEffect)(()=>{if(!h||!m||!i.Gi.isEditor||!t.current||!m.getModel()||E)return;let e=null,r=h.awareness,o=a.getText(`monaco`),s=async i=>{let a=Array.from(r.getStates().values());if(i){if(o._length>0&&a.length>1&&!T.current){let e=m?.getModel()?.getValue()?.toString()||``,r=e=>e.replace(/\s+/g,` `).trim();r(e)!==r(o.toString())&&(await pe(t,n),n?.(!1),m.executeEdits(`collaboration`,[{range:m.getModel().getFullModelRange(),text:o.toString(),forceMoveMarkers:!0}]))}o._length>0&&a.length===1&&!T.current&&o.applyDelta([{delete:o._length},{insert:t.current?.getModel().getValue()}]),o._length===0&&o.insert(0,t.current?.getModel().getValue()),T.current&&o.applyDelta([{delete:o._length},{insert:T.current}]),e=new F_(o,m?.getModel(),new Set([m]),r),m?.onDidChangeCursorPosition(e=>Fl(e,r)),m?.onDidChangeCursorSelection(e=>Il(e,r)),r.on(`change`,()=>fe(r)),T.current=null}};return h.on(`sync`,s),()=>{e&&e.destroy(),h.off(`sync`,s)}},[m,h,a,t,fe,n,E]),(0,u.useEffect)(()=>{if(!h||!m||!i.Gi.isEditor||!t.current||E)return;let e=h?.awareness,n=setInterval(()=>{fe(e)},500);return()=>clearInterval(n)},[h,m,g,t,y,fe,ce,E]);async function pe(e,t){await new Promise(n=>{let r=()=>{t?.(!0),(e.current?.getModel()?.getValue()?.length||0)>0?n():setTimeout(r,100)};r()})}if((0,u.useEffect)(()=>{if(!O||!i.Gi.isEditor||y)return;let e=zl({CHECK_INTERVAL:l.n,SLEEP_THRESHOLD:l.o,provider:h,handleOfflineCollaboration:ce,isNewEmailGeneration:E,saveEmailFromEditor:w});return()=>{clearInterval(e)}},[O,h,y,ce,b,E]),m&&se.length>0){let e=m?.getModel()?.getValue()?.toString()||``;p.current!==e&&`clear`in S&&S.clear(),p.current=e}let me=L_()&&se.length>0;return(0,u.useEffect)(()=>{if(!O||!i.Gi.isEditor)return;let e=setInterval(()=>{if(r?.current&&!E&&(ce(),D(!0)),!r?.current&&E){let e=o?.getValue();T.current=e,de(e)}},300);return()=>clearInterval(e)},[E,h,O,i.Gi.isEditor]),(0,u.useEffect)(()=>{if(!O||!i.Gi.isEditor)return;let e=()=>{document.visibilityState===`hidden`&&w()};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[e,O,i.Gi.isEditor]),[m,se,ee,y,me]};l.d(),l.v.options.format.wrapLineLength=0,He.config({monaco:s.m}),hn(),El(s.m),Dl(s.m,[`html`]);var z_=`'Source Code Pro', Consolas, 'Courier New', monospace`,B_=14;t.default=({email:e,readOnly:t,setOtherUsers:n,newEmailAiGeneratorRef:r})=>{let a=l.l();a.getLanguageId()!==`html`&&s.p.setModelLanguage(a,`html`);let d=i.q(i.vo.ON_CODE_VALIDATE_ID),p=i.xt(),m=i.wi(i.sr),ee=i.wi(o.u),h=i.wi(i.ar),te=e?.hasOwnProperty(`type`)?ee:m,g=i.wi(i.i),_=i.Ti(),v=(0,u.useRef)(null),ne=(0,u.useRef)(null),y=(0,u.useRef)(null),b=(0,u.useRef)([]),x=i.sn(),re=(0,u.useCallback)(()=>{_(i.o(!1))},[_]),[S,C]=(0,u.useState)(!1),w=c.o(),{__:T}=c.h(),{token:E}=c.zt(),[,D,ie,O,ae]=R_({email:e,editorRef:ne,setIsSpin:C,newEmailAiGeneratorRef:r});b.current=D,(0,u.useEffect)(()=>{t||n(b.current)},[D?.length,n,t]);let oe=(0,u.useMemo)(()=>()=>{w.error({message:T(l.i)})},[T,w]),se=(0,u.useMemo)(()=>()=>{w.warning({message:T(l.r)})},[T,w]);(0,u.useEffect)(()=>{O&&oe()},[O,oe]),(0,u.useEffect)(()=>{ae&&se()},[ae,se]),(0,u.useEffect)(()=>re(),[re]),(0,u.useEffect)(()=>{if(h){let{current:e}=v;e&&(e.revealRangeInCenterIfOutsideViewport(h),e.setSelection(h))}},[h]);let ce=(0,u.useCallback)(()=>{if(v.current){let e=v.current.getDomNode();if(e){let t=g.fontFamily||z_,n=g.fontSize||B_;e.style.setProperty(`--monaco-editor-font-family`,t,`important`),e.style.setProperty(`--monaco-monospace-font`,t,`important`),e.style.setProperty(`--monaco-editor-font-size`,`${n}px`,`important`),e.style.setProperty(`font-family`,t,`important`),e.style.setProperty(`font-size`,`${n}px`,`important`)}}},[g.fontFamily,g.fontSize]);(0,u.useEffect)(()=>{if(ce(),v.current){let e=v.current.getDomNode();if(e){let t=new MutationObserver(()=>{ce()});return t.observe(e,{childList:!0,subtree:!0}),()=>{t.disconnect()}}}},[g.fontFamily,ce]);let le=e=>{let{current:t}=v;if(t&&!t.hasTextFocus()){let n=t.getModel(),r=n.getPositionAt(e.start),i=n.getPositionAt(e.end),a={startColumn:r.column,startLineNumber:r.lineNumber,endColumn:i.column,endLineNumber:i.lineNumber};t.revealRangeInCenterIfOutsideViewport(a),t.setSelection(a)}},ue=async e=>{let{current:t}=v;if(t){let n=t.getModel();p({operation:i.oa.UPDATE_EDITOR_POSITION_FROM_EDITOR,data:n.getOffsetAt(e)})}};(0,u.useEffect)(()=>{matchMedia(i.xa).addEventListener(`change`,t=>{let n=window.localStorage.getItem(i.da.em_color_scheme),r=t.matches?i.Ki:i.la;e.hasOwnProperty(`type`)?_(n?o.g(n===`dark`?`vs-${n}`:i.la):o.g(r===`dark`?`vs-${r}`:i.la)):_(n?i.xr(n===`dark`?`vs-${n}`:i.la):i.xr(r===`dark`?`vs-${r}`:i.la))})},[_,e]),(0,u.useEffect)(()=>{let t=window.localStorage.getItem(i.da.em_color_scheme),n=matchMedia(`(prefers-color-scheme: dark)`).matches?i.Ki:i.la;e?.hasOwnProperty(`type`)?_(t?o.g(t===`dark`?`vs-${t}`:i.la):o.g(n===`dark`?`vs-${n}`:i.la)):_(t?i.xr(t===`dark`?`vs-${t}`:i.la):i.xr(n===`dark`?`vs-${n}`:i.la))},[_,e]);let de=(e,t)=>{v.current=e,ne.current=e;let n=e.getContribution(`editor.linkDetector`).openerService,r=n.open.bind(n),a=document.createElement(`div`),c=new ln.default(e,s.m,{"doctype-html5":!1,"html-lang-require":!1,"head-script-disabled":!1,"style-disabled":!1,"script-disabled":!1,"attr-lowercase":!1,"attr-value-single-quotes":!1,"attr-value-not-empty":!1,"attr-sorted":!1,"attr-whitespace":!1,"input-requires-label":!1,"tag-self-close":!1,"tagname-lowercase":!1,"href-abs-or-rel":!1,"inline-style-disabled":!1,"space-tab-mixed-disabled":!1,"attr-no-unnecessary-whitespace":!0,"tags-check":{img:{selfclosing:!1,attrsRequired:[`src`,`alt`]},a:{selfclosing:!1,attrsRequired:[]}},"empty-tag-not-self-closed":!1,"attr-value-double-quotes":!0,"doctype-first":!0,"tag-pair":!0,"spec-char-escape":!0,"id-unique":!0,"src-not-empty":!0,"attr-no-duplication":!0,"title-require":!0,"alt-require":!0,"inline-script-disabled":!0,"id-class-value":!1,"id-class-ad-disabled":!0,"attr-unsafe-chars":!0,csslint:{"display-property-grouping":!0,"known-properties":!0}});i.Gi.isEditor&&ne.current&&ie(ne.current),c.watch(),e.getContribution(`editor.linkDetector`).openerService.open=e=>(a.innerHTML=e,r(a.textContent)),_(i.o(!0)),e.onMouseUp(()=>{let t=e.getSelection();t.startColumn===t.endColumn&&t.startLineNumber===t.endLineNumber&&ue(e.getPosition())}),e.onDidBlurEditorWidget(()=>{p({operation:i.oa.EDITOR_CHANGE_FOCUS,data:!1}),_(o.i(!1))}),e.onDidFocusEditorWidget(()=>{p({operation:i.oa.EDITOR_CHANGE_FOCUS,data:!0}),_(o.i(!0))}),e.onDidChangeModelContent(()=>{setTimeout(()=>{ce()},0)}),setTimeout(()=>{ce()},100)};l.g(e=>{let t=e.data.operation,n=e.data;y.current=t,t===i.oa.UPDATE_EDITOR_POSITION_FROM_IFRAME&&le(n.data)});let fe=(0,u.useMemo)(()=>document.createElement(`div`),[]),pe=(0,u.useMemo)(()=>({...g,fontFamily:g.fontFamily||z_,fontSize:g.fontSize||B_,fontWeight:g.fontWeight||`normal`,domReadOnly:t,readOnly:t,unusualLineTerminators:`off`,mouseWheelZoom:!0,wordWrap:x.onlyCodeModeInMobile?`off`:g.wordWrap,ariaContainerElement:fe,unicodeHighlight:{ambiguousCharacters:!1,invisibleCharacters:!1}}),[g,x.onlyCodeModeInMobile,t,fe]);function me(e){e[0]?.message!==`Doctype must be declared first.`&&(i.ba.isPlugin&&d.fire(e),_(i.Ir(e)))}return a?.uri&&(0,f.jsxs)(f.Fragment,{children:[S&&(0,f.jsx)(c.W,{style:{position:`fixed`,width:`100%`,height:`100%`,top:0,left:0,zIndex:E?.zIndexPopupBase,background:E?.colorBgLayout}}),(0,f.jsx)(`div`,{id:`monaco-editor-root`,style:{width:`100%`,height:`100%`},children:(0,f.jsx)(lt,{theme:te,className:`monaco-editor`,defaultLanguage:`html`,onMount:de,options:pe,keepCurrentModel:!0,path:a.uri.toString(),onValidate:me})})]})}});
|
|
37
|
+
}`,e.cssRules.length)},Ml=(e,t)=>{let n=`backgroundPrefix-${e.slice(1)}`,r=document.styleSheets[0];Array.from(r.cssRules).some(e=>e.cssText.includes(`.${n}`))||r.insertRule(`.${n} { --cursor-color: ${e===t.color?`#000000`:e}; }`,r.cssRules.length)},Nl=(e,t,n,r,i)=>{for(let a=0;a<e.length;a++){let o=e[a],s=o.className.split(` `);for(let e of s)if(e.startsWith(t)){let a=`#${e.replace(t,``)}`,s=r.find(e=>e.user.color===a);s&&(n&&a!==i?.color?Pl(o,a,s?.user?.name?.first_name?`${s?.user?.name?.first_name} ${s?.user?.name?.last_name}`.replace(/[\n\r]/g,``):s.user.name.email.split(`@`)[0]):o.style.backgroundColor=a)}}},Pl=(e,t,n)=>{if(!e.textContent){let r=document.createElement(`div`);r.style.background=t,r.style.color=`#fff`,r.textContent=n,r.className=`cursor-hover`,e.appendChild(r)}},Fl=(e,t,n,r,i,a)=>{if(r)return;i(!0);let o=e.flatMap(e=>[...kl(e,a),...Al(e)]);n.current=t.deltaDecorations(n.current,o.map(e=>({range:e.range,options:e.options}))),Nl(document.getElementsByClassName(`applyColorToThis`),`backgroundPrefix-`,!0,e,a),i(!1)},Il=(e,t)=>{t.setLocalStateField(`cursor`,e.position)},Ll=(e,t)=>{let n=e.selection;t.setLocalStateField(`selection`,{startLineNumber:n.startLineNumber,startColumn:n.startColumn,endLineNumber:n.endLineNumber,endColumn:n.endColumn})},Rl=(e,t)=>e.filter(e=>e.user.color!==t.color),zl=()=>{let e=(e,t,n)=>e>100&&t>50&&t<150&&n<100,t=(e,t,n)=>{let r=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},i=r(e),a=r(t),o=r(n);return .2126*i+.7152*a+.0722*o},n=(e,n,r)=>{let i=t(255,255,255),a=t(e,n,r);return(i+.05)/(a+.05)>=4.5},r;do{let t=Math.floor(Math.random()*206+50),i=Math.floor(Math.random()*206+50),a=Math.floor(Math.random()*206+50);t+i+a>=400&&!e(t,i,a)&&n(t,i,a)&&(r=`#${(t<<16|i<<8|a).toString(16).padStart(6,`0`)}`)}while(!r);return r},Bl=({CHECK_INTERVAL:e,SLEEP_THRESHOLD:t,provider:n,handleOfflineCollaboration:r,isNewEmailGeneration:i,saveEmailFromEditor:a})=>{let o=Date.now();return setInterval(()=>{let e=Date.now(),r=e-o;r>t&&n&&(a(),window.location.reload(),window.location.reload()),r<t&&!n&&document.visibilityState,o=e},e)};r.i();var Vl=()=>new Map,Hl=e=>{let t=Vl();return e.forEach((e,n)=>{t.set(n,e)}),t},Ul=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},Wl=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1},Gl=()=>new Set,Kl=e=>e[e.length-1],ql=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},Jl=Array.from,Yl=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},Xl=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},Zl=(e,t)=>{let n=Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},Ql=Array.isArray,$l=class{constructor(){this._observers=Vl()}on(e,t){return Ul(this._observers,e,Gl).add(t),t}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return Jl((this._observers.get(e)||Vl()).values()).forEach(e=>e(...t))}destroy(){this._observers=Vl()}},eu=class{constructor(){this._observers=Vl()}on(e,t){Ul(this._observers,e,Gl).add(t)}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){let n=this._observers.get(e);n!==void 0&&(n.delete(t),n.size===0&&this._observers.delete(e))}emit(e,t){return Jl((this._observers.get(e)||Vl()).values()).forEach(e=>e(...t))}destroy(){this._observers=Vl()}},tu=Math.floor,nu=Math.abs,ru=(e,t)=>e<t?e:t,iu=(e,t)=>e>t?e:t;Number.isNaN;var au=Math.pow,ou=e=>e===0?1/e<0:e<0,su=2**53-1,cu=-(2**53-1),lu=Number.isInteger||(e=>typeof e==`number`&&isFinite(e)&&tu(e)===e);Number.isNaN,Number.parseInt;var uu=String.fromCharCode;String.fromCodePoint,uu(65535);var du=e=>e.toLowerCase(),fu=/^\s*/g,pu=e=>e.replace(fu,``),mu=/([A-Z])/g,hu=(e,t)=>pu(e.replace(mu,e=>`${t}${du(e)}`)),gu=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.codePointAt(e);return r},_u=typeof TextEncoder<`u`?new TextEncoder:null,vu=_u?e=>_u.encode(e):gu,yu=typeof TextDecoder>`u`?null:new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});yu&&yu.decode(new Uint8Array).length===1&&(yu=null);var bu=(e,t)=>Zl(t,()=>e).join(``),xu=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},I=()=>new xu,Su=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},L=e=>{let t=new Uint8Array(Su(e)),n=0;for(let r=0;r<e.bufs.length;r++){let i=e.bufs[r];t.set(i,n),n+=i.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},Cu=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(iu(n,t)*2),e.cpos=0)},R=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},wu=R,z=(e,t)=>{for(;t>127;)R(e,128|127&t),t=tu(t/128);R(e,127&t)},Tu=(e,t)=>{let n=ou(t);for(n&&(t=-t),R(e,(t>63?128:0)|(n?64:0)|63&t),t=tu(t/64);t>0;)R(e,(t>127?128:0)|127&t),t=tu(t/128)},Eu=new Uint8Array(3e4),Du=Eu.length/3,Ou=_u&&_u.encodeInto?(e,t)=>{if(t.length<Du){let n=_u.encodeInto(t,Eu).written||0;z(e,n);for(let t=0;t<n;t++)R(e,Eu[t])}else B(e,vu(t))}:(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;z(e,r);for(let t=0;t<r;t++)R(e,n.codePointAt(t))},ku=(e,t)=>{let n=e.cbuf.length,r=e.cpos,i=ru(n-r,t.length),a=t.length-i;e.cbuf.set(t.subarray(0,i),r),e.cpos+=i,a>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(iu(n*2,a)),e.cbuf.set(t.subarray(i)),e.cpos=a)},B=(e,t)=>{z(e,t.byteLength),ku(e,t)},Au=(e,t)=>{Cu(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},ju=(e,t)=>Au(e,4).setFloat32(0,t,!1),Mu=(e,t)=>Au(e,8).setFloat64(0,t,!1),Nu=(e,t)=>Au(e,8).setBigInt64(0,t,!1),Pu=new DataView(new ArrayBuffer(4)),Fu=e=>(Pu.setFloat32(0,e),Pu.getFloat32(0)===e),Iu=(e,t)=>{switch(typeof t){case`string`:R(e,119),Ou(e,t);break;case`number`:lu(t)&&nu(t)<=2147483647?(R(e,125),Tu(e,t)):Fu(t)?(R(e,124),ju(e,t)):(R(e,123),Mu(e,t));break;case`bigint`:R(e,122),Nu(e,t);break;case`object`:if(t===null)R(e,126);else if(Ql(t)){R(e,117),z(e,t.length);for(let n=0;n<t.length;n++)Iu(e,t[n])}else if(t instanceof Uint8Array)R(e,116),B(e,t);else{R(e,118);let n=Object.keys(t);z(e,n.length);for(let r=0;r<n.length;r++){let i=n[r];Ou(e,i),Iu(e,t[i])}}break;case`boolean`:R(e,t?120:121);break;default:R(e,127)}},Lu=class extends xu{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&z(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}},Ru=e=>{e.count>0&&(Tu(e.encoder,e.count===1?e.s:-e.s),e.count>1&&z(e.encoder,e.count-2))},zu=class{constructor(){this.encoder=new xu,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Ru(this),this.count=1,this.s=e)}toUint8Array(){return Ru(this),L(this.encoder)}},Bu=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);Tu(e.encoder,t),e.count>1&&z(e.encoder,e.count-2)}},Vu=class{constructor(){this.encoder=new xu,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Bu(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Bu(this),L(this.encoder)}},Hu=class{constructor(){this.sarr=[],this.s=``,this.lensE=new zu}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=``),this.lensE.write(e.length)}toUint8Array(){let e=new xu;return this.sarr.push(this.s),this.s=``,Ou(e,this.sarr.join(``)),ku(e,this.lensE.toUint8Array()),L(e)}},Uu=e=>Error(e),Wu=()=>{throw Uu(`Method unimplemented`)},V=()=>{throw Uu(`Unexpected case`)},Gu=Uu(`Unexpected end of array`),Ku=Uu(`Integer out of Range`),qu=class{constructor(e){this.arr=e,this.pos=0}},Ju=e=>new qu(e),Yu=e=>e.pos!==e.arr.length,Xu=(e,t)=>{let n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},H=e=>Xu(e,U(e)),Zu=e=>e.arr[e.pos++],U=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let r=e.arr[e.pos++];if(t+=(r&127)*n,n*=128,r<128)return t;if(t>su)throw Ku}throw Gu},Qu=e=>{let t=e.arr[e.pos++],n=t&63,r=64,i=(t&64)>0?-1:1;if(!(t&128))return i*n;let a=e.arr.length;for(;e.pos<a;){if(t=e.arr[e.pos++],n+=(t&127)*r,r*=128,t<128)return i*n;if(n>su)throw Ku}throw Gu},$u=yu?e=>yu.decode(H(e)):e=>{let t=U(e);if(t===0)return``;{let n=String.fromCodePoint(Zu(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Zu(e));else for(;t>0;){let r=t<1e4?t:1e4,i=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,i),t-=r}return decodeURIComponent(escape(n))}},ed=(e,t)=>{let n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},td=[e=>void 0,e=>null,Qu,e=>ed(e,4).getFloat32(0,!1),e=>ed(e,8).getFloat64(0,!1),e=>ed(e,8).getBigInt64(0,!1),e=>!1,e=>!0,$u,e=>{let t=U(e),n={};for(let r=0;r<t;r++){let t=$u(e);n[t]=nd(e)}return n},e=>{let t=U(e),n=[];for(let r=0;r<t;r++)n.push(nd(e));return n},H],nd=e=>td[127-Zu(e)](e),rd=class extends qu{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Yu(this)?this.count=U(this)+1:this.count=-1),this.count--,this.s}},id=class extends qu{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=Qu(this);let e=ou(this.s);this.count=1,e&&(this.s=-this.s,this.count=U(this)+2)}return this.count--,this.s}},ad=class extends qu{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let e=Qu(this),t=e&1;this.diff=tu(e/2),this.count=1,t&&(this.count=U(this)+2)}return this.s+=this.diff,this.count--,this.s}},od=class{constructor(e){this.decoder=new id(e),this.str=$u(this.decoder),this.spos=0}read(){let e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}};crypto.subtle;var sd=crypto.getRandomValues.bind(crypto),cd=()=>sd(new Uint32Array(1))[0],ld=`10000000-1000-4000-8000-100000000000`,ud=()=>ld.replace(/[018]/g,e=>(e^cd()&15>>e/4).toString(16)),dd=Date.now,fd=e=>new Promise(e);Promise.all.bind(Promise),a.n(),r.n();var pd=e=>e===void 0?null:e,md=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}},hd=!0;try{typeof localStorage<`u`&&localStorage&&(md=localStorage,hd=!1)}catch{}var gd=md,_d=e=>hd||addEventListener(`storage`,e),vd=e=>hd||removeEventListener(`storage`,e),yd=Symbol(`Equality`),bd=(e,t)=>e===t||!!e?.[yd]?.(t)||!1,xd=e=>typeof e==`object`,Sd=Object.assign,Cd=Object.keys,wd=(e,t)=>{for(let n in e)t(e[n],n)},Td=(e,t)=>{let n=[];for(let r in e)n.push(t(e[r],r));return n},Ed=e=>Cd(e).length,Dd=e=>{for(let t in e)return!1;return!0},Od=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},kd=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Ad=(e,t)=>e===t||Ed(e)===Ed(t)&&Od(e,(e,n)=>(e!==void 0||kd(t,n))&&bd(t[n],e)),jd=Object.freeze,Md=e=>{for(let t in e){let n=e[t];(typeof n==`object`||typeof n==`function`)&&Md(e[t])}return jd(e)},Nd=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Nd(e,t,n+1)}},Pd=e=>e,Fd=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[yd]!=null)return e[yd](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!Fd(e.get(n),t.get(n)))return!1;break;case void 0:case Object:if(Ed(e)!==Ed(t))return!1;for(let n in e)if(!kd(e,n)||!Fd(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Fd(e[n],t[n]))return!1;break;default:return!1}return!0},Id=(e,t)=>t.includes(e),Ld=a.t!==void 0&&a.t.release&&/node|io\.js/.test(a.t.release.name)&&Object.prototype.toString.call(a.t===void 0?0:a.t)===`[object process]`,Rd=typeof window<`u`&&typeof document<`u`&&!Ld;typeof navigator<`u`&&/Mac/.test(navigator.platform);var zd,Bd=[],Vd=()=>{if(zd===void 0)if(Ld){zd=Vl();let e=a.t.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]===`-`?(t!==null&&zd.set(t,``),t=r):t===null?Bd.push(r):(zd.set(t,r),t=null)}t!==null&&zd.set(t,``)}else typeof location==`object`?(zd=Vl(),(location.search||`?`).slice(1).split(`&`).forEach(e=>{if(e.length!==0){let[t,n]=e.split(`=`);zd.set(`--${hu(t,`-`)}`,n),zd.set(`-${hu(t,`-`)}`,n)}})):zd=Vl();return zd},Hd=e=>Vd().has(e),Ud=e=>pd(Ld?a.t.env[e.toUpperCase().replaceAll(`-`,`_`)]:gd.getItem(e)),Wd=e=>Hd(`--`+e)||Ud(e)!==null,Gd=Wd(`production`);Ld&&Id(a.t.env.FORCE_COLOR,[`true`,`1`,`2`])||!Hd(`--no-colors`)&&!Wd(`no-color`)&&(!Ld||a.t.stdout.isTTY)&&(!Ld||Hd(`--color`)||Ud(`COLORTERM`)!==null||(Ud(`TERM`)||``).includes(`color`));var Kd=e=>new Uint8Array(e),qd=(e,t,n)=>new Uint8Array(e,t,n),Jd=e=>new Uint8Array(e),Yd=e=>{let t=``;for(let n=0;n<e.byteLength;n++)t+=uu(e[n]);return btoa(t)},Xd=e=>r.t.from(e.buffer,e.byteOffset,e.byteLength).toString(`base64`),Zd=e=>{let t=atob(e),n=Kd(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n},Qd=e=>{let t=r.t.from(e,`base64`);return qd(t.buffer,t.byteOffset,t.byteLength)},$d=Rd?Yd:Xd,ef=Rd?Zd:Qd,tf=e=>{let t=Kd(e.byteLength);return t.set(e),t},nf=class{constructor(e,t){this.left=e,this.right=t}},rf=(e,t)=>new nf(e,t),af=e=>e.next()>=.5,of=(e,t,n)=>tu(e.next()*(n+1-t)+t),sf=(e,t,n)=>tu(e.next()*(n+1-t)+t),cf=(e,t,n)=>sf(e,t,n),lf=e=>uu(cf(e,97,122)),uf=(e,t=0,n=20)=>{let r=cf(e,t,n),i=``;for(let t=0;t<r;t++)i+=lf(e);return i},df=(e,t)=>t[cf(e,0,t.length-1)],ff=Symbol(`0schema`),pf=class{constructor(){this._rerrs=[]}extend(e,t,n,r=null){this._rerrs.push({path:e,expected:t,has:n,message:r})}toString(){let e=[];for(let t=this._rerrs.length-1;t>0;t--){let n=this._rerrs[t];e.push(bu(` `,(this._rerrs.length-t)*2)+`${n.path==null?``:`[${n.path}] `}${n.has} doesn't match ${n.expected}. ${n.message}`)}return e.join(`
|
|
38
|
+
`)}},mf=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[yd]?bd(e,t):Ql(e)?Yl(e,e=>Xl(t,t=>mf(e,t))):xd(e)?Od(e,(e,n)=>mf(e,t[n])):!1,W=class{static _dilutes=!1;extends(e){let[t,n]=[this.shape,e.shape];return this.constructor._dilutes&&([n,t]=[t,n]),mf(t,n)}equals(e){return this.constructor===e.constructor&&Fd(this.shape,e.shape)}[ff](){return!0}[yd](e){return this.equals(e)}validate(e){return this.check(e)}check(e,t){Wu()}get nullable(){return Gf(this,op)}get optional(){return new Cf(this)}cast(e){return up(e,this),e}expect(e){return up(e,this),e}},hf=class extends W{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t=void 0){let n=e?.constructor===this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name,e?.constructor===this.shape?`Check failed`:`Constructor match failed`),n}},G=(e,t=null)=>new hf(e,t);G(hf);var gf=class extends W{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape(e);return!n&&t?.extend(null,`custom prop`,e?.constructor.name,`failed to check custom prop`),n}},K=e=>new gf(e);G(gf);var _f=class extends W{constructor(e){super(),this.shape=e}check(e,t){let n=this.shape.some(t=>t===e);return!n&&t?.extend(null,this.shape.join(` | `),e.toString()),n}},vf=(...e)=>new _f(e),yf=G(_f),bf=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,e=>`\\`+e)),xf=e=>{if(tp.check(e))return[bf(e)];if(yf.check(e))return e.shape.map(e=>e+``);if(ep.check(e))return[`[+-]?\\d+.?\\d*`];if(np.check(e))return[`.*`];if(Kf.check(e))return e.shape.map(xf).flat(1);V()};G(class extends W{constructor(e){super(),this.shape=e,this._r=RegExp(`^`+e.map(xf).map(e=>`(${e.join(`|`)})`).join(``)+`$`)}check(e,t){let n=this._r.exec(e)!=null;return!n&&t?.extend(null,this._r.toString(),e.toString(),`String doesn't match string template.`),n}});var Sf=Symbol(`optional`),Cf=class extends W{constructor(e){super(),this.shape=e}check(e,t){let n=e===void 0||this.shape.check(e);return!n&&t?.extend(null,`undefined (optional)`,`()`),n}get[Sf](){return!0}},wf=G(Cf),Tf=class extends W{check(e,t){return t?.extend(null,`never`,typeof e),!1}};new Tf,G(Tf);var Ef=class e extends W{constructor(e,t=!1){super(),this.shape=e,this._isPartial=t}static _dilutes=!0;get partial(){return new e(this.shape,!0)}check(e,t){return e==null?(t?.extend(null,`object`,`null`),!1):Od(this.shape,(n,r)=>{let i=this._isPartial&&!kd(e,r)||n.check(e[r],t);return!i&&t?.extend(r.toString(),n.toString(),typeof e[r],`Object property does not match`),i})}},Df=e=>new Ef(e),Of=G(Ef),kf=K(e=>e!=null&&(e.constructor===Object||e.constructor==null)),Af=class extends W{constructor(e,t){super(),this.shape={keys:e,values:t}}check(e,t){return e!=null&&Od(e,(n,r)=>{let i=this.shape.keys.check(r,t);return!i&&t?.extend(r+``,`Record`,typeof e,i?`Key doesn't match schema`:`Value doesn't match value`),i&&this.shape.values.check(n,t)})}},jf=(e,t)=>new Af(e,t),Mf=G(Af),Nf=class extends W{constructor(e){super(),this.shape=e}check(e,t){return e!=null&&Od(this.shape,(n,r)=>{let i=n.check(e[r],t);return!i&&t?.extend(r.toString(),`Tuple`,typeof n),i})}},Pf=(...e)=>new Nf(e);G(Nf);var Ff=class extends W{constructor(e){super(),this.shape=e.length===1?e[0]:new Wf(e)}check(e,t){let n=Ql(e)&&Yl(e,e=>this.shape.check(e));return!n&&t?.extend(null,`Array`,``),n}},If=(...e)=>new Ff(e),Lf=G(Ff),Rf=K(e=>Ql(e)),zf=class extends W{constructor(e,t){super(),this.shape=e,this._c=t}check(e,t){let n=e instanceof this.shape&&(this._c==null||this._c(e));return!n&&t?.extend(null,this.shape.name,e?.constructor.name),n}},Bf=(e,t=null)=>new zf(e,t);G(zf);var Vf=Bf(W),Hf=G(class extends W{constructor(e){super(),this.len=e.length-1,this.args=Pf(...e.slice(-1)),this.res=e[this.len]}check(e,t){let n=e.constructor===Function&&e.length<=this.len;return!n&&t?.extend(null,`function`,typeof e),n}}),Uf=K(e=>typeof e==`function`);G(class extends W{constructor(e){super(),this.shape=e}check(e,t){let n=Yl(this.shape,n=>n.check(e,t));return!n&&t?.extend(null,`Intersectinon`,typeof e),n}},e=>e.shape.length>0);var Wf=class extends W{static _dilutes=!0;constructor(e){super(),this.shape=e}check(e,t){let n=Xl(this.shape,n=>n.check(e,t));return t?.extend(null,`Union`,typeof e),n}},Gf=(...e)=>e.findIndex(e=>Kf.check(e))>=0?Gf(...e.map(e=>lp(e)).map(e=>Kf.check(e)?e.shape:[e]).flat(1)):e.length===1?e[0]:new Wf(e),Kf=G(Wf),qf=()=>!0,Jf=K(qf),Yf=G(gf,e=>e.shape===qf),Xf=K(e=>typeof e==`bigint`),Zf=K(e=>e===Xf),Qf=K(e=>typeof e==`symbol`);K(e=>e===Qf);var $f=K(e=>typeof e==`number`),ep=K(e=>e===$f),tp=K(e=>typeof e==`string`),np=K(e=>e===tp),rp=K(e=>typeof e==`boolean`),ip=K(e=>e===rp),ap=vf(void 0);G(_f,e=>e.shape.length===1&&e.shape[0]===void 0),vf(void 0);var op=vf(null),sp=G(_f,e=>e.shape.length===1&&e.shape[0]===null);G(Uint8Array),G(hf,e=>e.shape===Uint8Array);var cp=Gf($f,tp,op,ap,Xf,rp,Qf);(()=>{let e=If(Jf),t=jf(tp,Jf),n=Gf($f,tp,op,rp,e,t);return e.shape=n,t.shape.values=n,n})();var lp=e=>{if(Vf.check(e))return e;if(kf.check(e)){let t={};for(let n in e)t[n]=lp(e[n]);return Df(t)}else if(Rf.check(e))return Gf(...e.map(lp));else if(cp.check(e))return vf(e);else if(Uf.check(e))return G(e);V()},up=Gd?()=>{}:(e,t)=>{let n=new pf;if(!t.check(e,n))throw Uu(`Expected value to be of type ${t.constructor.name}.\n${n.toString()}`)},dp=class{constructor(e){this.patterns=[],this.$state=e}if(e,t){return this.patterns.push({if:lp(e),h:t}),this}else(e){return this.if(Jf,e)}done(){return(e,t)=>{for(let n=0;n<this.patterns.length;n++){let r=this.patterns[n];if(r.if.check(e))return r.h(e,t)}throw Uu(`Unhandled pattern`)}}},fp=(e=>new dp(e))(Jf).if(ep,(e,t)=>of(t,cu,su)).if(np,(e,t)=>uf(t)).if(ip,(e,t)=>af(t)).if(Zf,(e,t)=>BigInt(of(t,cu,su))).if(Kf,(e,t)=>pp(t,df(t,e.shape))).if(Of,(e,t)=>{let n={};for(let r in e.shape){let i=e.shape[r];if(wf.check(i)){if(af(t))continue;i=i.shape}n[r]=fp(i,t)}return n}).if(Lf,(e,t)=>{let n=[],r=sf(t,0,42);for(let i=0;i<r;i++)n.push(pp(t,e.shape));return n}).if(yf,(e,t)=>df(t,e.shape)).if(sp,(e,t)=>null).if(Hf,(e,t)=>{let n=pp(t,e.res);return()=>n}).if(Yf,(e,t)=>pp(t,df(t,[$f,tp,op,ap,Xf,rp,If($f),jf(Gf(`a`,`b`,`c`),$f)]))).if(Mf,(e,t)=>{let n={},r=of(t,0,3);for(let i=0;i<r;i++){let r=pp(t,e.shape.keys);n[r]=pp(t,e.shape.values)}return n}).done(),pp=(e,t)=>fp(lp(t),e),mp=typeof document<`u`?document:{};K(e=>e.nodeType===vp),typeof DOMParser<`u`&&new DOMParser,K(e=>e.nodeType===hp),K(e=>e.nodeType===gp);var hp=mp.ELEMENT_NODE,gp=mp.TEXT_NODE;mp.CDATA_SECTION_NODE,mp.COMMENT_NODE;var _p=mp.DOCUMENT_NODE;mp.DOCUMENT_TYPE_NODE;var vp=mp.DOCUMENT_FRAGMENT_NODE;K(e=>e.nodeType===_p);var yp=Symbol,bp=yp(),xp=yp();yp(),yp(),yp();var Sp=yp();yp();var Cp=yp();yp(),dd(),rf(`font-weight`,`bold`),rf(`font-weight`,`normal`),rf(`color`,`blue`),rf(`color`,`green`),rf(`color`,`grey`),rf(`color`,`red`),rf(`color`,`purple`),rf(`color`,`orange`),rf(`color`,`black`);var wp=(...e)=>{Ep.forEach(t=>t.print(e))},Tp=(...e)=>{e.unshift(Cp),Ep.forEach(t=>t.print(e))},Ep=Gl(),Dp=e=>({[Symbol.iterator](){return this},next:e}),Op=(e,t)=>Dp(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),kp=(e,t)=>Dp(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}),Ap=class{constructor(e,t){this.clock=e,this.len=t}},jp=class{constructor(){this.clients=new Map}},Mp=(e,t,n)=>t.clients.forEach((t,r)=>{let i=e.doc.store.clients.get(r);if(i!=null){let r=i[i.length-1],a=r.id.clock+r.length;for(let r=0,o=t[r];r<t.length&&o.clock<a;o=t[++r])Um(e,i,o.clock,o.len,n)}}),Np=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let i=tu((n+r)/2),a=e[i],o=a.clock;if(o<=t){if(t<o+a.len)return i;n=i+1}else r=i-1}return null},Pp=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&Np(n,t.clock)!==null},Fp=e=>{e.clients.forEach(e=>{e.sort((e,t)=>e.clock-t.clock);let t,n;for(t=1,n=1;t<e.length;t++){let r=e[n-1],i=e[t];r.clock+r.len>=i.clock?e[n-1]=new Ap(r.clock,iu(r.len,i.clock+i.len-r.clock)):(n<t&&(e[n]=i),n++)}e.length=n})},Ip=e=>{let t=new jp;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,i)=>{if(!t.clients.has(i)){let a=r.slice();for(let t=n+1;t<e.length;t++)ql(a,e[t].clients.get(i)||[]);t.clients.set(i,a)}});return Fp(t),t},Lp=(e,t,n,r)=>{Ul(e.clients,t,()=>[]).push(new Ap(n,r))},Rp=()=>new jp,zp=e=>{let t=Rp();return e.clients.forEach((e,n)=>{let r=[];for(let t=0;t<e.length;t++){let n=e[t];if(n.deleted){let i=n.id.clock,a=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[++t+1])a+=n.length;r.push(new Ap(i,a))}}r.length>0&&t.clients.set(n,r)}),t},Bp=(e,t)=>{z(e.restEncoder,t.clients.size),Jl(t.clients.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{e.resetDsCurVal(),z(e.restEncoder,t);let r=n.length;z(e.restEncoder,r);for(let t=0;t<r;t++){let r=n[t];e.writeDsClock(r.clock),e.writeDsLen(r.len)}})},Vp=e=>{let t=new jp,n=U(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let n=U(e.restDecoder),r=U(e.restDecoder);if(r>0){let i=Ul(t.clients,n,()=>[]);for(let t=0;t<r;t++)i.push(new Ap(e.readDsClock(),e.readDsLen()))}}return t},Hp=(e,t,n)=>{let r=new jp,i=U(e.restDecoder);for(let a=0;a<i;a++){e.resetDsCurVal();let i=U(e.restDecoder),a=U(e.restDecoder),o=n.clients.get(i)||[],s=J(n,i);for(let n=0;n<a;n++){let n=e.readDsClock(),a=n+e.readDsLen();if(n<s){s<a&&Lp(r,i,s,a-s);let e=Lm(o,n),c=o[e];for(!c.deleted&&c.id.clock<n&&(o.splice(e+1,0,Xg(t,c,n-c.id.clock)),e++);e<o.length&&(c=o[e++],c.id.clock<a);)c.deleted||(a<c.id.clock+c.length&&o.splice(e,0,Xg(t,c,a-c.id.clock)),c.delete(t))}else Lp(r,i,n,a-n)}}if(r.clients.size>0){let e=new Qp;return z(e.restEncoder,0),Bp(e,r),e.toUint8Array()}return null},Up=cd,Wp=class e extends $l{constructor({guid:e=ud(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:a=!1,shouldLoad:o=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=Up(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new Pm,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=o,this.autoLoad=a,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=fd(e=>{this.on(`load`,()=>{this.isLoaded=!0,e(this)})});let s=()=>fd(e=>{let t=n=>{(n===void 0||n===!0)&&(this.off(`sync`,t),e())};this.on(`sync`,t)});this.on(`sync`,e=>{e===!1&&this.isSynced&&(this.whenSynced=s()),this.isSynced=e===void 0||e===!0,this.isSynced&&!this.isLoaded&&this.emit(`load`,[this])}),this.whenSynced=s()}load(){let e=this._item;e!==null&&!this.shouldLoad&&Y(e.parent.doc,e=>{e.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Jl(this.subdocs).map(e=>e.guid))}transact(e,t=null){return Y(this,e,t)}get(e,t=Z){let n=Ul(this.share,e,()=>{let e=new t;return e._integrate(this,null),e}),r=n.constructor;if(t!==Z&&r!==t)if(r===Z){let r=new t;r._map=n._map,n._map.forEach(e=>{for(;e!==null;e=e.left)e.parent=r}),r._start=n._start;for(let e=r._start;e!==null;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}else throw Error(`Type with the name ${e} has already been defined with a different constructor`);return n}getArray(e=``){return this.get(e,Bh)}getText(e=``){return this.get(e,sg)}getMap(e=``){return this.get(e,Uh)}getXmlElement(e=``){return this.get(e,fg)}getXmlFragment(e=``){return this.get(e,ug)}toJSON(){let e={};return this.share.forEach((t,n)=>{e[n]=t.toJSON()}),e}destroy(){this.isDestroyed=!0,Jl(this.subdocs).forEach(e=>e.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,Y(t.parent.doc,e=>{let r=n.doc;t.deleted||e.subdocsAdded.add(r),e.subdocsRemoved.add(this)},null,!0)}this.emit(`destroyed`,[!0]),this.emit(`destroy`,[this]),super.destroy()}},Gp=class{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return U(this.restDecoder)}readDsLen(){return U(this.restDecoder)}},Kp=class extends Gp{readLeftID(){return q(U(this.restDecoder),U(this.restDecoder))}readRightID(){return q(U(this.restDecoder),U(this.restDecoder))}readClient(){return U(this.restDecoder)}readInfo(){return Zu(this.restDecoder)}readString(){return $u(this.restDecoder)}readParentInfo(){return U(this.restDecoder)===1}readTypeRef(){return U(this.restDecoder)}readLen(){return U(this.restDecoder)}readAny(){return nd(this.restDecoder)}readBuf(){return tf(H(this.restDecoder))}readJSON(){return JSON.parse($u(this.restDecoder))}readKey(){return $u(this.restDecoder)}},qp=class{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=U(this.restDecoder),this.dsCurrVal}readDsLen(){let e=U(this.restDecoder)+1;return this.dsCurrVal+=e,e}},Jp=class extends qp{constructor(e){super(e),this.keys=[],U(e),this.keyClockDecoder=new ad(H(e)),this.clientDecoder=new id(H(e)),this.leftClockDecoder=new ad(H(e)),this.rightClockDecoder=new ad(H(e)),this.infoDecoder=new rd(H(e),Zu),this.stringDecoder=new od(H(e)),this.parentInfoDecoder=new rd(H(e),Zu),this.typeRefDecoder=new id(H(e)),this.lenDecoder=new id(H(e))}readLeftID(){return new xm(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new xm(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 nd(this.restDecoder)}readBuf(){return H(this.restDecoder)}readJSON(){return nd(this.restDecoder)}readKey(){let e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{let e=this.stringDecoder.read();return this.keys.push(e),e}}},Yp=class{constructor(){this.restEncoder=I()}toUint8Array(){return L(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){z(this.restEncoder,e)}writeDsLen(e){z(this.restEncoder,e)}},Xp=class extends Yp{writeLeftID(e){z(this.restEncoder,e.client),z(this.restEncoder,e.clock)}writeRightID(e){z(this.restEncoder,e.client),z(this.restEncoder,e.clock)}writeClient(e){z(this.restEncoder,e)}writeInfo(e){wu(this.restEncoder,e)}writeString(e){Ou(this.restEncoder,e)}writeParentInfo(e){z(this.restEncoder,+!!e)}writeTypeRef(e){z(this.restEncoder,e)}writeLen(e){z(this.restEncoder,e)}writeAny(e){Iu(this.restEncoder,e)}writeBuf(e){B(this.restEncoder,e)}writeJSON(e){Ou(this.restEncoder,JSON.stringify(e))}writeKey(e){Ou(this.restEncoder,e)}},Zp=class{constructor(){this.restEncoder=I(),this.dsCurrVal=0}toUint8Array(){return L(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){let t=e-this.dsCurrVal;this.dsCurrVal=e,z(this.restEncoder,t)}writeDsLen(e){e===0&&V(),z(this.restEncoder,e-1),this.dsCurrVal+=e}},Qp=class extends Zp{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Vu,this.clientEncoder=new zu,this.leftClockEncoder=new Vu,this.rightClockEncoder=new Vu,this.infoEncoder=new Lu(wu),this.stringEncoder=new Hu,this.parentInfoEncoder=new Lu(wu),this.typeRefEncoder=new zu,this.lenEncoder=new zu}toUint8Array(){let e=I();return z(e,0),B(e,this.keyClockEncoder.toUint8Array()),B(e,this.clientEncoder.toUint8Array()),B(e,this.leftClockEncoder.toUint8Array()),B(e,this.rightClockEncoder.toUint8Array()),B(e,L(this.infoEncoder)),B(e,this.stringEncoder.toUint8Array()),B(e,L(this.parentInfoEncoder)),B(e,this.typeRefEncoder.toUint8Array()),B(e,this.lenEncoder.toUint8Array()),ku(e,L(this.restEncoder)),L(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)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Iu(this.restEncoder,e)}writeBuf(e){B(this.restEncoder,e)}writeJSON(e){Iu(this.restEncoder,e)}writeKey(e){let t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}},$p=(e,t,n,r)=>{r=iu(r,t[0].id.clock);let i=Lm(t,r);z(e.restEncoder,t.length-i),e.writeClient(n),z(e.restEncoder,r);let a=t[i];a.write(e,r-a.id.clock);for(let n=i+1;n<t.length;n++)t[n].write(e,0)},em=(e,t,n)=>{let r=new Map;n.forEach((e,n)=>{J(t,n)>e&&r.set(n,e)}),Fm(t).forEach((e,t)=>{n.has(t)||r.set(t,0)}),z(e.restEncoder,r.size),Jl(r.entries()).sort((e,t)=>t[0]-e[0]).forEach(([n,r])=>{$p(e,t.clients.get(n),n,r)})},tm=(e,t)=>{let n=Vl(),r=U(e.restDecoder);for(let i=0;i<r;i++){let r=U(e.restDecoder),i=Array(r),a=e.readClient(),o=U(e.restDecoder);n.set(a,{i:0,refs:i});for(let n=0;n<r;n++){let r=e.readInfo();switch(31&r){case 0:{let t=e.readLen();i[n]=new xg(q(a,o),t),o+=t;break}case 10:{let t=U(e.restDecoder);i[n]=new e_(q(a,o),t),o+=t;break}default:{let s=(r&192)==0,c=new $(q(a,o),null,(r&128)==128?e.readLeftID():null,null,(r&64)==64?e.readRightID():null,s?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,s&&(r&32)==32?e.readString():null,Zg(e,r));i[n]=c,o+=c.length}}}}return n},nm=(e,t,n)=>{let r=[],i=Jl(n.keys()).sort((e,t)=>e-t);if(i.length===0)return null;let a=()=>{if(i.length===0)return null;let e=n.get(i[i.length-1]);for(;e.refs.length===e.i;)if(i.pop(),i.length>0)e=n.get(i[i.length-1]);else return null;return e},o=a();if(o===null)return null;let s=new Pm,c=new Map,l=(e,t)=>{let n=c.get(e);(n==null||n>t)&&c.set(e,t)},u=o.refs[o.i++],d=new Map,f=()=>{for(let e of r){let t=e.id.client,r=n.get(t);r?(r.i--,s.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):s.clients.set(t,[e]),i=i.filter(e=>e!==t)}r.length=0};for(;;){if(u.constructor!==e_){let i=Ul(d,u.id.client,()=>J(t,u.id.client))-u.id.clock;if(i<0)r.push(u),l(u.id.client,u.id.clock-1),f();else{let a=u.getMissing(e,t);if(a!==null){r.push(u);let e=n.get(a)||{refs:[],i:0};if(e.refs.length===e.i)l(a,J(t,a)),f();else{u=e.refs[e.i++];continue}}else (i===0||i<u.length)&&(u.integrate(e,i),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=a(),o===null)break;u=o.refs[o.i++]}}if(s.clients.size>0){let e=new Qp;return em(e,s,new Map),z(e.restEncoder,0),{missing:c,update:e.toUint8Array()}}return null},rm=(e,t)=>em(e,t.doc.store,t.beforeState),im=(e,t,n,r=new Jp(e))=>Y(t,e=>{e.local=!1;let t=!1,n=e.doc,i=n.store,a=nm(e,i,tm(r,n)),o=i.pendingStructs;if(o){for(let[e,n]of o.missing)if(n<J(i,e)){t=!0;break}if(a){for(let[e,t]of a.missing){let n=o.missing.get(e);(n==null||n>t)&&o.missing.set(e,t)}o.update=nh([o.update,a.update])}}else i.pendingStructs=a;let s=Hp(r,e,i);if(i.pendingDs){let t=new Jp(Ju(i.pendingDs));U(t.restDecoder);let n=Hp(t,e,i);s&&n?i.pendingDs=nh([s,n]):i.pendingDs=s||n}else i.pendingDs=s;if(t){let t=i.pendingStructs.update;i.pendingStructs=null,am(e.doc,t)}},n,!1),am=(e,t,n,r=Jp)=>{let i=Ju(t);im(i,e,n,new r(i))},om=(e,t,n)=>am(e,t,n,Kp),sm=(e,t,n=new Map)=>{em(e,t.store,n),Bp(e,zp(t.store))},cm=(e,t=new Uint8Array([0]),n=new Qp)=>{sm(n,e,dm(t));let r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(rh(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Xp)return eh(r.map((e,t)=>t===0?e:ch(e)));if(n.constructor===Qp)return nh(r)}return r[0]},lm=(e,t)=>cm(e,t,new Xp),um=e=>{let t=new Map,n=U(e.restDecoder);for(let r=0;r<n;r++){let n=U(e.restDecoder),r=U(e.restDecoder);t.set(n,r)}return t},dm=e=>um(new Gp(Ju(e))),fm=(e,t)=>(z(e.restEncoder,t.size),Jl(t.entries()).sort((e,t)=>t[0]-e[0]).forEach(([t,n])=>{z(e.restEncoder,t),z(e.restEncoder,n)}),e),pm=(e,t)=>fm(e,Fm(t.store)),mm=(e,t=new Zp)=>(e instanceof Map?fm(t,e):pm(t,e),t.toUint8Array()),hm=e=>mm(e,new Yp),gm=class{constructor(){this.l=[]}},_m=()=>new gm,vm=(e,t)=>e.l.push(t),ym=(e,t)=>{let n=e.l;n.length,e.l=n.filter(e=>t!==e),e.l.length},bm=(e,t,n)=>Nd(e.l,[t,n]),xm=class{constructor(e,t){this.client=e,this.clock=t}},Sm=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,q=(e,t)=>new xm(e,t),Cm=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw V()},wm=class{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}},Tm=class{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}},Em=(e,t,n=0)=>new Tm(e,t,n),Dm=(e,t,n)=>{let r=null,i=null;return e._item===null?i=Cm(e):r=q(e._item.id.client,e._item.id.clock),new wm(r,i,t,n)},Om=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return Dm(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return Dm(e,q(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return Dm(e,r.lastId,n);r=r.right}return Dm(e,null,n)},km=(e,t)=>{let n=Rm(e,t);return{item:n,diff:t.clock-n.id.clock}},Am=(e,t,n=!0)=>{let r=t.store,i=e.item,a=e.type,o=e.tname,s=e.assoc,c=null,l=0;if(i!==null){if(J(r,i.client)<=i.clock)return null;let e=n?Yg(r,i):km(r,i),t=e.item;if(!(t instanceof $))return null;if(c=t.parent,c._item===null||!c._item.deleted){l=t.deleted||!t.countable?0:e.diff+(s>=0?0:1);let n=t.left;for(;n!==null;)!n.deleted&&n.countable&&(l+=n.length),n=n.left}}else{if(o!==null)c=t.get(o);else if(a!==null){if(J(r,a.client)<=a.clock)return null;let{item:e}=n?Yg(r,a):{item:Rm(r,a)};if(e instanceof $&&e.content instanceof qg)c=e.content.type;else return null}else throw V();l=s>=0?c._length:0}return Em(c,l,e.assoc)},jm=class{constructor(e,t){this.ds=e,this.sv=t}};((e,t)=>new jm(e,t))(Rp(),new Map);var Mm=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Pp(t.ds,e.id),Nm=(e,t)=>{let n=Ul(e.meta,Nm,Gl),r=e.doc.store;n.has(t)||(t.sv.forEach((t,n)=>{t<J(r,n)&&Bm(e,q(n,t))}),Mp(e,t.ds,e=>{}),n.add(t))},Pm=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},Fm=e=>{let t=new Map;return e.clients.forEach((e,n)=>{let r=e[e.length-1];t.set(n,r.id.clock+r.length)}),t},J=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},Im=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw V()}n.push(t)},Lm=(e,t)=>{let n=0,r=e.length-1,i=e[r],a=i.id.clock;if(a===t)return r;let o=tu(t/(a+i.length-1)*r);for(;n<=r;){if(i=e[o],a=i.id.clock,a<=t){if(t<a+i.length)return o;n=o+1}else r=o-1;o=tu((n+r)/2)}throw V()},Rm=(e,t)=>{let n=e.clients.get(t.client);return n[Lm(n,t.clock)]},zm=(e,t,n)=>{let r=Lm(t,n),i=t[r];return i.id.clock<n&&i instanceof $?(t.splice(r+1,0,Xg(e,i,n-i.id.clock)),r+1):r},Bm=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[zm(e,n,t.clock)]},Vm=(e,t,n)=>{let r=t.clients.get(n.client),i=Lm(r,n.clock),a=r[i];return n.clock!==a.id.clock+a.length-1&&a.constructor!==xg&&r.splice(i+1,0,Xg(e,a,n.clock-a.id.clock+1)),a},Hm=(e,t,n)=>{let r=e.clients.get(t.id.client);r[Lm(r,t.id.clock)]=n},Um=(e,t,n,r,i)=>{if(r===0)return;let a=n+r,o=zm(e,t,n),s;do s=t[o++],a<s.id.clock+s.length&&zm(e,t,a),i(s);while(o<t.length&&t[o].id.clock<a)},Wm=class{constructor(e,t,n){this.doc=e,this.deleteSet=new jp,this.beforeState=Fm(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=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},Gm=(e,t)=>t.deleteSet.clients.size===0&&!Wl(t.afterState,(e,n)=>t.beforeState.get(n)!==e)?!1:(Fp(t.deleteSet),rm(e,t),Bp(e,t.deleteSet),!0),Km=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&Ul(e.changed,t,Gl).add(n)},qm=(e,t)=>{let n=e[t],r=e[t-1],i=t;for(;i>0;n=r,r=e[--i-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof $&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let a=t-i;return a&&e.splice(t+1-a,a),a},Jm=(e,t,n)=>{for(let[r,i]of e.clients.entries()){let e=t.clients.get(r);for(let r=i.length-1;r>=0;r--){let a=i[r],o=a.clock+a.len;for(let r=Lm(e,a.clock),i=e[r];r<e.length&&i.id.clock<o;i=e[++r]){let i=e[r];if(a.clock+a.len<=i.id.clock)break;i instanceof $&&i.deleted&&!i.keep&&n(i)&&i.gc(t,!1)}}}},Ym=(e,t)=>{e.clients.forEach((e,n)=>{let r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){let n=e[t],i=ru(r.length-1,1+Lm(r,n.clock+n.len-1));for(let e=i,t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+qm(r,e)}})},Xm=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,i=r.store,a=n.deleteSet,o=n._mergeStructs;try{Fp(a),n.afterState=Fm(n.doc.store),r.emit(`beforeObserverCalls`,[n,r]);let e=[];n.changed.forEach((t,r)=>e.push(()=>{(r._item===null||!r._item.deleted)&&r._callObserver(n,t)})),e.push(()=>{n.changedParentTypes.forEach((t,r)=>{r._dEH.l.length>0&&(r._item===null||!r._item.deleted)&&(t=t.filter(e=>e.target._item===null||!e.target._item.deleted),t.forEach(e=>{e.currentTarget=r,e._path=null}),t.sort((e,t)=>e.path.length-t.path.length),e.push(()=>{bm(r._dEH,t,n)}))}),e.push(()=>r.emit(`afterTransaction`,[n,r])),e.push(()=>{n._needFormattingCleanup&&ig(n)})}),Nd(e,[])}finally{r.gc&&Jm(a,i,r.gcFilter),Ym(a,i),n.afterState.forEach((e,t)=>{let r=n.beforeState.get(t)||0;if(r!==e){let e=i.clients.get(t),n=iu(Lm(e,r),1);for(let t=e.length-1;t>=n;)t-=1+qm(e,t)}});for(let e=o.length-1;e>=0;e--){let{client:t,clock:n}=o[e].id,r=i.clients.get(t),a=Lm(r,n);a+1<r.length&&qm(r,a+1)>1||a>0&&qm(r,a)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(wp(Cp,bp,`[yjs] `,xp,Sp,`Changed the client-id because another client seems to be using it.`),r.clientID=Up()),r.emit(`afterTransactionCleanup`,[n,r]),r._observers.has(`update`)){let e=new Xp;Gm(e,n)&&r.emit(`update`,[e.toUint8Array(),n.origin,r,n])}if(r._observers.has(`updateV2`)){let e=new Qp;Gm(e,n)&&r.emit(`updateV2`,[e.toUint8Array(),n.origin,r,n])}let{subdocsAdded:s,subdocsLoaded:c,subdocsRemoved:l}=n;(s.size>0||l.size>0||c.size>0)&&(s.forEach(e=>{e.clientID=r.clientID,e.collectionid??=r.collectionid,r.subdocs.add(e)}),l.forEach(e=>r.subdocs.delete(e)),r.emit(`subdocs`,[{loaded:c,added:s,removed:l},r,n]),l.forEach(e=>e.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit(`afterAllTransactions`,[r,e])):Xm(e,t+1)}}},Y=(e,t,n=null,r=!0)=>{let i=e._transactionCleanups,a=!1,o=null;e._transaction===null&&(a=!0,e._transaction=new Wm(e,n,r),i.push(e._transaction),i.length===1&&e.emit(`beforeAllTransactions`,[e]),e.emit(`beforeTransaction`,[e._transaction,e]));try{o=t(e._transaction)}finally{if(a){let t=e._transaction===i[0];e._transaction=null,t&&Xm(i,0)}}return o};function*Zm(e){let t=U(e.restDecoder);for(let n=0;n<t;n++){let t=U(e.restDecoder),n=e.readClient(),r=U(e.restDecoder);for(let i=0;i<t;i++){let t=e.readInfo();if(t===10){let t=U(e.restDecoder);yield new e_(q(n,r),t),r+=t}else if(31&t){let i=(t&192)==0,a=new $(q(n,r),null,(t&128)==128?e.readLeftID():null,null,(t&64)==64?e.readRightID():null,i?e.readParentInfo()?e.readString():e.readLeftID():null,i&&(t&32)==32?e.readString():null,Zg(e,t));yield a,r+=a.length}else{let t=e.readLen();yield new xg(q(n,r),t),r+=t}}}}var Qm=class{constructor(e,t){this.gen=Zm(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===e_);return this.curr}},$m=class{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}},eh=e=>nh(e,Kp,Xp),th=(e,t)=>{if(e.constructor===xg){let{client:n,clock:r}=e.id;return new xg(q(n,r+t),e.length-t)}else if(e.constructor===e_){let{client:n,clock:r}=e.id;return new e_(q(n,r+t),e.length-t)}else{let n=e,{client:r,clock:i}=n.id;return new $(q(r,i+t),null,q(r,i+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},nh=(e,t=Jp,n=Qp)=>{if(e.length===1)return e[0];let r=e.map(e=>new t(Ju(e))),i=r.map(e=>new Qm(e,!0)),a=null,o=new n,s=new $m(o);for(;i=i.filter(e=>e.curr!==null),i.sort((e,t)=>{if(e.curr.id.client===t.curr.id.client){let n=e.curr.id.clock-t.curr.id.clock;return n===0?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===e_?1:-1:n}else return t.curr.id.client-e.curr.id.client}),i.length!==0;){let e=i[0],t=e.curr.id.client;if(a!==null){let n=e.curr,r=!1;for(;n!==null&&n.id.clock+n.length<=a.struct.id.clock+a.struct.length&&n.id.client>=a.struct.id.client;)n=e.next(),r=!0;if(n===null||n.id.client!==t||r&&n.id.clock>a.struct.id.clock+a.struct.length)continue;if(t!==a.struct.id.client)ah(s,a.struct,a.offset),a={struct:n,offset:0},e.next();else if(a.struct.id.clock+a.struct.length<n.id.clock)if(a.struct.constructor===e_)a.struct.length=n.id.clock+n.length-a.struct.id.clock;else{ah(s,a.struct,a.offset);let e=n.id.clock-a.struct.id.clock-a.struct.length;a={struct:new e_(q(t,a.struct.id.clock+a.struct.length),e),offset:0}}else{let t=a.struct.id.clock+a.struct.length-n.id.clock;t>0&&(a.struct.constructor===e_?a.struct.length-=t:n=th(n,t)),a.struct.mergeWith(n)||(ah(s,a.struct,a.offset),a={struct:n,offset:0},e.next())}}else a={struct:e.curr,offset:0},e.next();for(let n=e.curr;n!==null&&n.id.client===t&&n.id.clock===a.struct.id.clock+a.struct.length&&n.constructor!==e_;n=e.next())ah(s,a.struct,a.offset),a={struct:n,offset:0}}return a!==null&&(ah(s,a.struct,a.offset),a=null),oh(s),Bp(o,Ip(r.map(e=>Vp(e)))),o.toUint8Array()},rh=(e,t,n=Jp,r=Qp)=>{let i=dm(t),a=new r,o=new $m(a),s=new n(Ju(e)),c=new Qm(s,!1);for(;c.curr;){let e=c.curr,t=e.id.client,n=i.get(t)||0;if(c.curr.constructor===e_){c.next();continue}if(e.id.clock+e.length>n)for(ah(o,e,iu(n-e.id.clock,0)),c.next();c.curr&&c.curr.id.client===t;)ah(o,c.curr,0),c.next();else for(;c.curr&&c.curr.id.client===t&&c.curr.id.clock+c.curr.length<=n;)c.next()}return oh(o),Bp(a,Vp(s)),a.toUint8Array()},ih=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:L(e.encoder.restEncoder)}),e.encoder.restEncoder=I(),e.written=0)},ah=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&ih(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),z(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},oh=e=>{ih(e);let t=e.encoder.restEncoder;z(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];z(t,r.written),ku(t,r.restEncoder)}},sh=(e,t,n,r)=>{let i=new n(Ju(e)),a=new Qm(i,!1),o=new r,s=new $m(o);for(let e=a.curr;e!==null;e=a.next())ah(s,t(e),0);return oh(s),Bp(o,Vp(i)),o.toUint8Array()},ch=e=>sh(e,Pd,Jp,Xp),lh=`You must not compute changes after the event-handler fired.`,uh=class{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||=dh(this.currentTarget,this.target)}deletes(e){return Pp(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Uu(lh);let e=new Map,t=this.target;this.transaction.changed.get(t).forEach(n=>{if(n!==null){let r=t._map.get(n),i,a;if(this.adds(r)){let e=r.left;for(;e!==null&&this.adds(e);)e=e.left;if(this.deletes(r))if(e!==null&&this.deletes(e))i=`delete`,a=Kl(e.content.getContent());else return;else e!==null&&this.deletes(e)?(i=`update`,a=Kl(e.content.getContent())):(i=`add`,a=void 0)}else if(this.deletes(r))i=`delete`,a=Kl(r.content.getContent());else return;e.set(n,{action:i,oldValue:a})}}),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 Uu(lh);let t=this.target,n=Gl(),r=Gl(),i=[];if(e={added:n,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let e=null,a=()=>{e&&i.push(e)};for(let i=t._start;i!==null;i=i.right)i.deleted?this.deletes(i)&&!this.adds(i)&&((e===null||e.delete===void 0)&&(a(),e={delete:0}),e.delete+=i.length,r.add(i)):this.adds(i)?((e===null||e.insert===void 0)&&(a(),e={insert:[]}),e.insert=e.insert.concat(i.content.getContent()),n.add(i)):((e===null||e.retain===void 0)&&(a(),e={retain:0}),e.retain+=i.length);e!==null&&e.retain===void 0&&a()}this._changes=e}return e}},dh=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},X=()=>{Tp(`Invalid access: Add Yjs type to a document before reading data.`)},fh=80,ph=0,mh=class{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=ph++}},hh=e=>{e.timestamp=ph++},gh=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=ph++},_h=(e,t,n)=>{if(e.length>=fh){let r=e.reduce((e,t)=>e.timestamp<t.timestamp?e:t);return gh(r,t,n),r}else{let r=new mh(t,n);return e.push(r),r}},vh=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((e,n)=>nu(t-e.index)<nu(t-n.index)?e:n),r=e._start,i=0;for(n!==null&&(r=n.p,i=n.index,hh(n));r.right!==null&&i<t;){if(!r.deleted&&r.countable){if(t<i+r.length)break;i+=r.length}r=r.right}for(;r.left!==null&&i>t;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(i-=r.length);return n!==null&&nu(n.index-i)<r.parent.length/fh?(gh(n,r,i),n):_h(e._searchMarker,r,i)},yh=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let i=e[r];if(n>0){let t=i.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(i.index-=t.length);if(t===null||t.marker===!0){e.splice(r,1);continue}i.p=t,t.marker=!0}(t<i.index||n>0&&t===i.index)&&(i.index=iu(t,i.index+n))}},bh=(e,t,n)=>{let r=e,i=t.changedParentTypes;for(;Ul(i,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;bm(r._eH,n,t)},Z=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=_m(),this._dEH=_m(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Wu()}clone(){throw Wu()}_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){vm(this._eH,e)}observeDeep(e){vm(this._dEH,e)}unobserve(e){ym(this._eH,e)}unobserveDeep(e){ym(this._dEH,e)}toJSON(){}},xh=(e,t,n)=>{e.doc??X(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,i=[],a=e._start;for(;a!==null&&r>0;){if(a.countable&&!a.deleted){let e=a.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)i.push(e[n]),r--;t=0}}a=a.right}return i},Sh=e=>{e.doc??X();let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},Ch=(e,t)=>{let n=0,r=e._start;for(e.doc??X();r!==null;){if(r.countable&&!r.deleted){let i=r.content.getContent();for(let r=0;r<i.length;r++)t(i[r],n++,e)}r=r.right}},wh=(e,t)=>{let n=[];return Ch(e,(r,i)=>{n.push(t(r,i,e))}),n},Th=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},Eh=(e,t)=>{e.doc??X();let n=vh(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},Dh=(e,t,n,r)=>{let i=n,a=e.doc,o=a.clientID,s=a.store,c=n===null?t._start:n.right,l=[],u=()=>{l.length>0&&(i=new $(q(o,J(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Fg(l)),i.integrate(e,0),l=[])};r.forEach(n=>{if(n===null)l.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:l.push(n);break;default:switch(u(),n.constructor){case Uint8Array:case ArrayBuffer:i=new $(q(o,J(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Sg(new Uint8Array(n))),i.integrate(e,0);break;case Wp:i=new $(q(o,J(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new Dg(n)),i.integrate(e,0);break;default:if(n instanceof Z)i=new $(q(o,J(s,o)),i,i&&i.lastId,c,c&&c.id,t,null,new qg(n)),i.integrate(e,0);else throw Error(`Unexpected content type in insert operation`)}}}),u()},Oh=()=>Uu(`Length exceeded!`),kh=(e,t,n,r)=>{if(n>t._length)throw Oh();if(n===0)return t._searchMarker&&yh(t._searchMarker,n,r.length),Dh(e,t,null,r);let i=n,a=vh(t,n),o=t._start;for(a!==null&&(o=a.p,n-=a.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&Bm(e,q(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&yh(t._searchMarker,i,r.length),Dh(e,t,o,r)},Ah=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((e,t)=>t.index>e.index?t:e,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return Dh(e,t,r,n)},jh=(e,t,n,r)=>{if(r===0)return;let i=n,a=r,o=vh(t,n),s=t._start;for(o!==null&&(s=o.p,n-=o.index);s!==null&&n>0;s=s.right)!s.deleted&&s.countable&&(n<s.length&&Bm(e,q(s.id.client,s.id.clock+n)),n-=s.length);for(;r>0&&s!==null;)s.deleted||(r<s.length&&Bm(e,q(s.id.client,s.id.clock+r)),s.delete(e),r-=s.length),s=s.right;if(r>0)throw Oh();t._searchMarker&&yh(t._searchMarker,i,-a+r)},Mh=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Nh=(e,t,n,r)=>{let i=t._map.get(n)||null,a=e.doc,o=a.clientID,s;if(r==null)s=new Fg([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:s=new Fg([r]);break;case Uint8Array:s=new Sg(r);break;case Wp:s=new Dg(r);break;default:if(r instanceof Z)s=new qg(r);else throw Error(`Unexpected content type`)}new $(q(o,J(a.store,o)),i,i&&i.lastId,null,null,t,n,s).integrate(e,0)},Ph=(e,t)=>{e.doc??X();let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Fh=e=>{let t={};return e.doc??X(),e._map.forEach((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])}),t},Ih=(e,t)=>{e.doc??X();let n=e._map.get(t);return n!==void 0&&!n.deleted},Lh=(e,t)=>{let n={};return e._map.forEach((e,r)=>{let i=e;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&Mm(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},Rh=e=>(e.doc??X(),Op(e._map.entries(),e=>!e[1].deleted)),zh=class extends uh{},Bh=class e extends Z{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof Z?e.clone():e)),t}get length(){return this.doc??X(),this._length}_callObserver(e,t){super._callObserver(e,t),bh(this,e,new zh(this,e))}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Y(this.doc,n=>{kh(n,this,e,t)})}push(e){this.doc===null?this._prelimContent.push(...e):Y(this.doc,t=>{Ah(t,this,e)})}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Y(this.doc,n=>{jh(n,this,e,t)})}get(e){return Eh(this,e)}toArray(){return Sh(this)}slice(e=0,t=this.length){return xh(this,e,t)}toJSON(){return this.map(e=>e instanceof Z?e.toJSON():e)}map(e){return wh(this,e)}forEach(e){Ch(this,e)}[Symbol.iterator](){return Th(this)}_write(e){e.writeTypeRef(Bg)}},Vh=e=>new Bh,Hh=class extends uh{constructor(e,t,n){super(e,t),this.keysChanged=n}},Uh=class e extends Z{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((e,t)=>{this.set(t,e)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((e,n)=>{t.set(n,e instanceof Z?e.clone():e)}),t}_callObserver(e,t){bh(this,e,new Hh(this,e,t))}toJSON(){this.doc??X();let e={};return this._map.forEach((t,n)=>{if(!t.deleted){let r=t.content.getContent()[t.length-1];e[n]=r instanceof Z?r.toJSON():r}}),e}get size(){return[...Rh(this)].length}keys(){return kp(Rh(this),e=>e[0])}values(){return kp(Rh(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return kp(Rh(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??X(),this._map.forEach((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc===null?this._prelimContent.delete(e):Y(this.doc,t=>{Mh(t,this,e)})}set(e,t){return this.doc===null?this._prelimContent.set(e,t):Y(this.doc,n=>{Nh(n,this,e,t)}),t}get(e){return Ph(this,e)}has(e){return Ih(this,e)}clear(){this.doc===null?this._prelimContent.clear():Y(this.doc,e=>{this.forEach(function(t,n,r){Mh(e,r,n)})})}_write(e){e.writeTypeRef(Vg)}},Wh=e=>new Uh,Gh=(e,t)=>e===t||typeof e==`object`&&typeof t==`object`&&e&&t&&Ad(e,t),Kh=class{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){switch(this.right===null&&V(),this.right.content.constructor){case Q:this.right.deleted||Xh(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}},qh=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case Q:t.right.deleted||Xh(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&Bm(e,q(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},Jh=(e,t,n,r)=>{let i=new Map,a=r?vh(t,n):null;return a?qh(e,new Kh(a.p.left,a.p,a.index,i),n-a.index):qh(e,new Kh(null,t._start,0,i),n)},Yh=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Q&&Gh(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let i=e.doc,a=i.clientID;r.forEach((r,o)=>{let s=n.left,c=n.right,l=new $(q(a,J(i.store,a)),s,s&&s.lastId,c,c&&c.id,t,null,new Q(o,r));l.integrate(e,0),n.right=l,n.forward()})},Xh=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Zh=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===Q&&Gh(t[e.right.content.key]??null,e.right.content.value));)e.forward()},Qh=(e,t,n,r)=>{let i=e.doc,a=i.clientID,o=new Map;for(let s in r){let c=r[s],l=n.currentAttributes.get(s)??null;if(!Gh(l,c)){o.set(s,l);let{left:r,right:u}=n;n.right=new $(q(a,J(i.store,a)),r,r&&r.lastId,u,u&&u.id,t,null,new Q(s,c)),n.right.integrate(e,0),n.forward()}}return o},$h=(e,t,n,r,i)=>{n.currentAttributes.forEach((e,t)=>{i[t]===void 0&&(i[t]=null)});let a=e.doc,o=a.clientID;Zh(n,i);let s=Qh(e,t,n,i),c=r.constructor===String?new Lg(r):r instanceof Z?new qg(r):new kg(r),{left:l,right:u,index:d}=n;t._searchMarker&&yh(t._searchMarker,n.index,c.getLength()),u=new $(q(o,J(a.store,o)),l,l&&l.lastId,u,u&&u.id,t,null,c),u.integrate(e,0),n.right=u,n.index=d,n.forward(),Yh(e,t,n,s)},eg=(e,t,n,r,i)=>{let a=e.doc,o=a.clientID;Zh(n,i);let s=Qh(e,t,n,i);iterationLoop:for(;n.right!==null&&(r>0||s.size>0&&(n.right.deleted||n.right.content.constructor===Q));){if(!n.right.deleted)switch(n.right.content.constructor){case Q:{let{key:t,value:a}=n.right.content,o=i[t];if(o!==void 0){if(Gh(o,a))s.delete(t);else{if(r===0)break iterationLoop;s.set(t,a)}n.right.delete(e)}else n.currentAttributes.set(t,a);break}default:r<n.right.length&&Bm(e,q(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let i=``;for(;r>0;r--)i+=`
|
|
39
|
+
`;n.right=new $(q(o,J(a.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Lg(i)),n.right.integrate(e,0),n.forward()}Yh(e,t,n,s)},tg=(e,t,n,r,i)=>{let a=t,o=Vl();for(;a&&(!a.countable||a.deleted);){if(!a.deleted&&a.content.constructor===Q){let e=a.content;o.set(e.key,e)}a=a.right}let s=0,c=!1;for(;t!==a;){if(n===t&&(c=!0),!t.deleted){let n=t.content;switch(n.constructor){case Q:{let{key:a,value:l}=n,u=r.get(a)??null;(o.get(a)!==n||u===l)&&(t.delete(e),s++,!c&&(i.get(a)??null)===l&&u!==l&&(u===null?i.delete(a):i.set(a,u))),!c&&!t.deleted&&Xh(i,n);break}}}t=t.right}return s},ng=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===Q){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},rg=e=>{let t=0;return Y(e.doc,n=>{let r=e._start,i=e._start,a=Vl(),o=Hl(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case Q:Xh(o,i.content);break;default:t+=tg(n,r,i,a,o),a=Hl(o),r=i;break}i=i.right}}),t},ig=e=>{let t=new Set,n=e.doc;for(let[r,i]of e.afterState.entries()){let a=e.beforeState.get(r)||0;i!==a&&Um(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===Q&&e.constructor!==xg&&t.add(e.parent)})}Y(n,n=>{Mp(e,e.deleteSet,e=>{if(e instanceof xg||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===Q?t.add(r):ng(n,e)});for(let e of t)rg(e)})},ag=(e,t,n)=>{let r=n,i=Hl(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case qg:case kg:case Lg:n<t.right.length&&Bm(e,q(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&tg(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&yh(o._searchMarker,t.index,-r+n),t},og=class extends uh{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach(e=>{e===null?this.childListChanged=!0:this.keysChanged.add(e)})}get changes(){if(this._changes===null){let 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){let e=this.target.doc,t=[];Y(e,e=>{let n=new Map,r=new Map,i=this.target._start,a=null,o={},s=``,c=0,l=0,u=()=>{if(a!==null){let e=null;switch(a){case`delete`:l>0&&(e={delete:l}),l=0;break;case`insert`:(typeof s==`object`||s.length>0)&&(e={insert:s},n.size>0&&(e.attributes={},n.forEach((t,n)=>{t!==null&&(e.attributes[n]=t)}))),s=``;break;case`retain`:c>0&&(e={retain:c},Dd(o)||(e.attributes=Sd({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case qg:case kg:this.adds(i)?this.deletes(i)||(u(),a=`insert`,s=i.content.getContent()[0],u()):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=1):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=1);break;case Lg:this.adds(i)?this.deletes(i)||(a!==`insert`&&(u(),a=`insert`),s+=i.content.str):this.deletes(i)?(a!==`delete`&&(u(),a=`delete`),l+=i.length):i.deleted||(a!==`retain`&&(u(),a=`retain`),c+=i.length);break;case Q:{let{key:t,value:s}=i.content;if(this.adds(i))this.deletes(i)||(Gh(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Gh(s,r.get(t)??null)?delete o[t]:o[t]=s));else if(this.deletes(i)){r.set(t,s);let e=n.get(t)??null;Gh(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Gh(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Xh(n,i.content));break}}i=i.right}for(u();t.length>0;){let e=t[t.length-1];if(e.retain!==void 0&&e.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}},sg=class e extends Z{constructor(e){super(),this._pending=e===void 0?[]:[()=>this.insert(0,e)],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??X(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(e=>e())}catch{}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(e,t){super._callObserver(e,t);let n=new og(this,e,t);bh(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??X();let e=``,t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Lg&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc===null?this._pending.push(()=>this.applyDelta(e)):Y(this.doc,n=>{let r=new Kh(null,this._start,0,new Map);for(let i=0;i<e.length;i++){let a=e[i];if(a.insert!==void 0){let o=!t&&typeof a.insert==`string`&&i===e.length-1&&r.right===null&&a.insert.slice(-1)===`
|
|
40
|
+
`?a.insert.slice(0,-1):a.insert;(typeof o!=`string`||o.length>0)&&$h(n,this,r,o,a.attributes||{})}else a.retain===void 0?a.delete!==void 0&&ag(n,r,a.delete):eg(n,this,r,a.retain,a.attributes||{})}})}toDelta(e,t,n){this.doc??X();let r=[],i=new Map,a=this.doc,o=``,s=this._start;function c(){if(o.length>0){let e={},t=!1;i.forEach((n,r)=>{t=!0,e[r]=n});let n={insert:o};t&&(n.attributes=e),r.push(n),o=``}}let l=()=>{for(;s!==null;){if(Mm(s,e)||t!==void 0&&Mm(s,t))switch(s.content.constructor){case Lg:{let r=i.get(`ychange`);e!==void 0&&!Mm(s,e)?(r===void 0||r.user!==s.id.client||r.type!==`removed`)&&(c(),i.set(`ychange`,n?n(`removed`,s.id):{type:`removed`})):t!==void 0&&!Mm(s,t)?(r===void 0||r.user!==s.id.client||r.type!==`added`)&&(c(),i.set(`ychange`,n?n(`added`,s.id):{type:`added`})):r!==void 0&&(c(),i.delete(`ychange`)),o+=s.content.str;break}case qg:case kg:{c();let e={insert:s.content.getContent()[0]};if(i.size>0){let t={};e.attributes=t,i.forEach((e,n)=>{t[n]=e})}r.push(e);break}case Q:Mm(s,e)&&(c(),Xh(i,s.content));break}s=s.right}c()};return e||t?Y(a,n=>{e&&Nm(n,e),t&&Nm(n,t),l()},`cleanup`):l(),r}insert(e,t,n){if(t.length<=0)return;let r=this.doc;r===null?this._pending.push(()=>this.insert(e,t,n)):Y(r,r=>{let i=Jh(r,this,e,!n);n||(n={},i.currentAttributes.forEach((e,t)=>{n[t]=e})),$h(r,this,i,t,n)})}insertEmbed(e,t,n){let r=this.doc;r===null?this._pending.push(()=>this.insertEmbed(e,t,n||{})):Y(r,r=>{let i=Jh(r,this,e,!n);$h(r,this,i,t,n||{})})}delete(e,t){if(t===0)return;let n=this.doc;n===null?this._pending.push(()=>this.delete(e,t)):Y(n,n=>{ag(n,Jh(n,this,e,!0),t)})}format(e,t,n){if(t===0)return;let r=this.doc;r===null?this._pending.push(()=>this.format(e,t,n)):Y(r,r=>{let i=Jh(r,this,e,!1);i.right!==null&&eg(r,this,i,t,n)})}removeAttribute(e){this.doc===null?this._pending.push(()=>this.removeAttribute(e)):Y(this.doc,t=>{Mh(t,this,e)})}setAttribute(e,t){this.doc===null?this._pending.push(()=>this.setAttribute(e,t)):Y(this.doc,n=>{Nh(n,this,e,t)})}getAttribute(e){return Ph(this,e)}getAttributes(){return Fh(this)}_write(e){e.writeTypeRef(Hg)}},cg=e=>new sg,lg=class{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??X()}[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===fg||t.constructor===ug)&&t._start!==null)e=t._start;else for(;e!==null;){let t=e.next;if(t!==null){e=t;break}else e=e.parent===this._root?null: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})}},ug=class e extends Z{constructor(){super(),this._prelimContent=[]}get firstChild(){let 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 e}clone(){let t=new e;return t.insert(0,this.toArray().map(e=>e instanceof Z?e.clone():e)),t}get length(){return this.doc??X(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new lg(this,e)}querySelector(e){e=e.toUpperCase();let t=new lg(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),Jl(new lg(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){bh(this,e,new mg(this,t,e))}toString(){return wh(this,e=>e.toString()).join(``)}toJSON(){return this.toString()}toDOM(e=document,t={},n){let r=e.createDocumentFragment();return n!==void 0&&n._createAssociation(r,this),Ch(this,i=>{r.insertBefore(i.toDOM(e,t,n),null)}),r}insert(e,t){this.doc===null?this._prelimContent.splice(e,0,...t):Y(this.doc,n=>{kh(n,this,e,t)})}insertAfter(e,t){if(this.doc!==null)Y(this.doc,n=>{let r=e&&e instanceof Z?e._item:e;Dh(n,this,r,t)});else{let n=this._prelimContent,r=e===null?0:n.findIndex(t=>t===e)+1;if(r===0&&e!==null)throw Uu(`Reference item not found`);n.splice(r,0,...t)}}delete(e,t=1){this.doc===null?this._prelimContent.splice(e,t):Y(this.doc,n=>{jh(n,this,e,t)})}toArray(){return Sh(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return Eh(this,e)}slice(e=0,t=this.length){return xh(this,e,t)}forEach(e){Ch(this,e)}_write(e){e.writeTypeRef(Wg)}},dg=e=>new ug,fg=class e extends ug{constructor(e=`UNDEFINED`){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((e,t)=>{this.setAttribute(t,e)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName);return wd(this.getAttributes(),(e,n)=>{t.setAttribute(n,e)}),t.insert(0,this.toArray().map(e=>e instanceof Z?e.clone():e)),t}toString(){let e=this.getAttributes(),t=[],n=[];for(let t in e)n.push(t);n.sort();let r=n.length;for(let i=0;i<r;i++){let r=n[i];t.push(r+`="`+e[r]+`"`)}let i=this.nodeName.toLocaleLowerCase();return`<${i}${t.length>0?` `+t.join(` `):``}>${super.toString()}</${i}>`}removeAttribute(e){this.doc===null?this._prelimAttrs.delete(e):Y(this.doc,t=>{Mh(t,this,e)})}setAttribute(e,t){this.doc===null?this._prelimAttrs.set(e,t):Y(this.doc,n=>{Nh(n,this,e,t)})}getAttribute(e){return Ph(this,e)}hasAttribute(e){return Ih(this,e)}getAttributes(e){return e?Lh(this,e):Fh(this)}toDOM(e=document,t={},n){let r=e.createElement(this.nodeName),i=this.getAttributes();for(let e in i){let t=i[e];typeof t==`string`&&r.setAttribute(e,t)}return Ch(this,i=>{r.appendChild(i.toDOM(e,t,n))}),n!==void 0&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(Ug),e.writeKey(this.nodeName)}},pg=e=>new fg(e.readKey()),mg=class extends uh{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(e=>{e===null?this.childListChanged=!0:this.attributesChanged.add(e)})}},hg=class e extends Uh{constructor(e){super(),this.hookName=e}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((e,n)=>{t.set(n,e)}),t}toDOM(e=document,t={},n){let r=t[this.hookName],i;return i=r===void 0?document.createElement(this.hookName):r.createDom(this),i.setAttribute(`data-yjs-hook`,this.hookName),n!==void 0&&n._createAssociation(i,this),i}_write(e){e.writeTypeRef(Gg),e.writeKey(this.hookName)}},gg=e=>new hg(e.readKey()),_g=class e extends sg{get nextSibling(){let e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){let e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(e=document,t,n){let r=e.createTextNode(this.toString());return n!==void 0&&n._createAssociation(r,this),r}toString(){return this.toDelta().map(e=>{let t=[];for(let n in e.attributes){let r=[];for(let t in e.attributes[n])r.push({key:t,value:e.attributes[n][t]});r.sort((e,t)=>e.key<t.key?-1:1),t.push({nodeName:n,attrs:r})}t.sort((e,t)=>e.nodeName<t.nodeName?-1:1);let n=``;for(let e=0;e<t.length;e++){let r=t[e];n+=`<${r.nodeName}`;for(let e=0;e<r.attrs.length;e++){let t=r.attrs[e];n+=` ${t.key}="${t.value}"`}n+=`>`}n+=e.insert;for(let e=t.length-1;e>=0;e--)n+=`</${t[e].nodeName}>`;return n}).join(``)}toJSON(){return this.toString()}_write(e){e.writeTypeRef(Kg)}},vg=e=>new _g,yg=class{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Wu()}mergeWith(e){return!1}write(e,t,n){throw Wu()}integrate(e,t){throw Wu()}},bg=0,xg=class extends yg{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),Im(e.doc.store,this)}write(e,t){e.writeInfo(bg),e.writeLen(this.length-t)}getMissing(e,t){return null}},Sg=class e{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(e){throw Wu()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}},Cg=e=>new Sg(e.readBuf()),wg=class e{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){Lp(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}},Tg=e=>new wg(e.readLen()),Eg=(e,t)=>new Wp({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),Dg=class e{constructor(e){e._item,this.doc=e;let 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 e(Eg(this.doc.guid,this.opts))}splice(e){throw Wu()}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}},Og=e=>new Dg(Eg(e.readString(),e.readAny())),kg=class e{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(e){throw Wu()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}},Ag=e=>new kg(e.readJSON()),Q=class e{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(e){throw Wu()}mergeWith(e){return!1}integrate(e,t){let n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}},jg=e=>new Q(e.readKey(),e.readJSON()),Mg=class e{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeString(t===void 0?`undefined`:JSON.stringify(t))}}getRef(){return 2}},Ng=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let t=e.readString();t===`undefined`?n.push(void 0):n.push(JSON.parse(t))}return new Mg(n)},Pg=Ud(`node_env`)===`development`,Fg=class e{constructor(e){this.arr=e,Pg&&Md(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){let n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){let t=this.arr[r];e.writeAny(t)}}getRef(){return 8}},Ig=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new Fg(n)},Lg=class e{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split(``)}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+`�`,n.str=`�`+n.str.slice(1)),n}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}},Rg=e=>new Lg(e.readString()),zg=[Vh,Wh,cg,pg,dg,gg,vg],Bg=0,Vg=1,Hg=2,Ug=3,Wg=4,Gg=5,Kg=6,qg=class e{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(e){throw Wu()}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(t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.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(t=>{for(;t!==null;)t.gc(e,!0),t=t.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}},Jg=e=>new qg(zg[e.readTypeRef()](e)),Yg=(e,t)=>{let n=t,r=0,i;do r>0&&(n=q(n.client,n.clock+r)),i=Rm(e,n),r=n.clock-i.id.clock,n=i.redone;while(n!==null&&i instanceof $);return{item:i,diff:r}},Xg=(e,t,n)=>{let{client:r,clock:i}=t.id,a=new $(q(r,i+n),t,q(r,i+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&a.markDeleted(),t.keep&&(a.keep=!0),t.redone!==null&&(a.redone=q(t.redone.client,t.redone.clock+n)),t.right=a,a.right!==null&&(a.right.left=a),e._mergeStructs.push(a),a.parentSub!==null&&a.right===null&&a.parent._map.set(a.parentSub,a),t.length=n,a},$=class e extends yg{constructor(e,t,n,r,i,a,o,s){super(e,s.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=i,this.parent=a,this.parentSub=o,this.redone=null,this.content=s,this.info=this.content.isCountable()?2:0}set marker(e){(this.info&8)>0!==e&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=J(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=J(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===xm&&this.id.client!==this.parent.client&&this.parent.clock>=J(n,this.parent.client))return this.parent.client;if(this.origin&&=(this.left=Vm(t,n,this.origin),this.left.lastId),this.rightOrigin&&=(this.right=Bm(t,this.rightOrigin),this.right.id),this.left&&this.left.constructor===xg||this.right&&this.right.constructor===xg)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===xm){let e=Rm(n,this.parent);e.constructor===xg?this.parent=null:this.parent=e.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=Vm(e,e.doc.store,q(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 t=this.left,n;if(t!==null)n=t.right;else if(this.parentSub!==null)for(n=this.parent._map.get(this.parentSub)||null;n!==null&&n.left!==null;)n=n.left;else n=this.parent._start;let r=new Set,i=new Set;for(;n!==null&&n!==this.right;){if(i.add(n),r.add(n),Sm(this.origin,n.origin)){if(n.id.client<this.id.client)t=n,r.clear();else if(Sm(this.rightOrigin,n.rightOrigin))break}else if(n.origin!==null&&i.has(Rm(e.doc.store,n.origin)))r.has(Rm(e.doc.store,n.origin))||(t=n,r.clear());else break;n=n.right}this.left=t}if(this.left!==null){let e=this.left.right;this.right=e,this.left.right=this}else{let e;if(this.parentSub!==null)for(e=this.parent._map.get(this.parentSub)||null;e!==null&&e.left!==null;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}this.right===null?this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)):this.right.left=this,this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Im(e.doc.store,this),this.content.integrate(e,this),Km(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new xg(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:q(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Sm(e.origin,this.lastId)&&this.right===e&&Sm(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)){let t=this.parent._searchMarker;return t&&t.forEach(t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.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){let t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),Lp(e.deleteSet,this.id.client,this.id.clock,this.length),Km(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw V();this.content.gc(e),t?Hm(e,this,new xg(this.id,this.length)):this.content=new wg(this.length)}write(e,t){let n=t>0?q(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,i=this.parentSub,a=this.content.getRef()&31|(n===null?0:128)|(r===null?0:64)|(i===null?0:32);if(e.writeInfo(a),n!==null&&e.writeLeftID(n),r!==null&&e.writeRightID(r),n===null&&r===null){let t=this.parent;if(t._item!==void 0){let n=t._item;if(n===null){let n=Cm(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===xm?(e.writeParentInfo(!1),e.writeLeftID(t)):V();i!==null&&e.writeString(i)}this.content.write(e,t)}},Zg=(e,t)=>Qg[t&31](e),Qg=[()=>{V()},Tg,Ng,Cg,Rg,Ag,jg,Jg,Ig,Og,()=>{V()}],$g=10,e_=class extends yg{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor?(this.length+=e.length,!0):!1}integrate(e,t){V()}write(e,t){e.writeInfo($g),z(e.restEncoder,this.length-t)}getMissing(e,t){return null}},t_=typeof globalThis<`u`?globalThis:typeof window<`u`?window:r.r===void 0?{}:r.r,n_=`__ $YJS$ __`;t_[n_],t_[n_]=!0;var r_=new Map,i_=class{constructor(e){this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&this.onmessage!==null&&this.onmessage({data:ef(t.newValue||``)}),_d(this._onChange)}postMessage(e){gd.setItem(this.room,$d(Jd(e)))}close(){vd(this._onChange)}},a_=typeof BroadcastChannel>`u`?i_:BroadcastChannel,o_=e=>Ul(r_,e,()=>{let t=Gl(),n=new a_(e);return n.onmessage=e=>t.forEach(t=>t(e.data,`broadcastchannel`)),{bc:n,subs:t}}),s_=(e,t)=>(o_(e).subs.add(t),t),c_=(e,t)=>{let n=o_(e),r=n.subs.delete(t);return r&&n.subs.size===0&&(n.bc.close(),r_.delete(e)),r},l_=(e,t,n=null)=>{let r=o_(e);r.bc.postMessage(t),r.subs.forEach(e=>e(t,n))},u_=(e,t)=>{z(e,0),B(e,hm(t))},d_=(e,t,n)=>{z(e,1),B(e,lm(t,n))},f_=(e,t,n)=>d_(t,n,H(e)),p_=(e,t,n,r)=>{try{om(t,H(e),n)}catch(e){r?.(e)}},m_=(e,t)=>{z(e,2),B(e,t)},h_=p_,g_=(e,t,n,r,i)=>{let a=U(e);switch(a){case 0:f_(e,t,n);break;case 1:p_(e,n,r,i);break;case 2:h_(e,n,r,i);break;default:throw Error(`Unknown message type`)}return a},__=(e,t,n)=>{switch(U(e)){case 0:n(t,$u(e))}},v_=3e4,y_=class extends eu{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{let e=dd();this.getLocalState()!==null&&3e4/2<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());let t=[];this.meta.forEach((n,r)=>{r!==this.clientID&&3e4<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)}),t.length>0&&b_(this,t,`timeout`)},tu(v_/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){let t=this.clientID,n=this.meta.get(t),r=n===void 0?0:n.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:dd()});let a=[],o=[],s=[],c=[];e===null?c.push(t):i==null?e!=null&&a.push(t):(o.push(t),Fd(i,e)||s.push(t)),(a.length>0||s.length>0||c.length>0)&&this.emit(`change`,[{added:a,updated:s,removed:c},`local`]),this.emit(`update`,[{added:a,updated:o,removed:c},`local`])}setLocalStateField(e,t){let n=this.getLocalState();n!==null&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}},b_=(e,t,n)=>{let r=[];for(let n=0;n<t.length;n++){let i=t[n];if(e.states.has(i)){if(e.states.delete(i),i===e.clientID){let t=e.meta.get(i);e.meta.set(i,{clock:t.clock+1,lastUpdated:dd()})}r.push(i)}}r.length>0&&(e.emit(`change`,[{added:[],updated:[],removed:r},n]),e.emit(`update`,[{added:[],updated:[],removed:r},n]))},x_=(e,t,n=e.states)=>{let r=t.length,i=I();z(i,r);for(let a=0;a<r;a++){let r=t[a],o=n.get(r)||null,s=e.meta.get(r).clock;z(i,r),z(i,s),Ou(i,JSON.stringify(o))}return L(i)},S_=(e,t,n)=>{let r=Ju(t),i=dd(),a=[],o=[],s=[],c=[],l=U(r);for(let t=0;t<l;t++){let t=U(r),n=U(r),l=JSON.parse($u(r)),u=e.meta.get(t),d=e.states.get(t),f=u===void 0?0:u.clock;(f<n||f===n&&l===null&&e.states.has(t))&&(l===null?t===e.clientID&&e.getLocalState()!=null?n++:e.states.delete(t):e.states.set(t,l),e.meta.set(t,{clock:n,lastUpdated:i}),u===void 0&&l!==null?a.push(t):u!==void 0&&l===null?c.push(t):l!==null&&(Fd(l,d)||s.push(t),o.push(t)))}(a.length>0||s.length>0||c.length>0)&&e.emit(`change`,[{added:a,updated:s,removed:c},n]),(a.length>0||o.length>0||c.length>0)&&e.emit(`update`,[{added:a,updated:o,removed:c},n])},C_=e=>Td(e,(e,t)=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join(`&`);a.n();var w_=[];w_[0]=(e,t,n,r,i)=>{z(e,0);let a=g_(t,e,n.doc,n);r&&a===1&&!n.synced&&(n.synced=!0)},w_[3]=(e,t,n,r,i)=>{z(e,1),B(e,x_(n.awareness,Array.from(n.awareness.getStates().keys())))},w_[1]=(e,t,n,r,i)=>{S_(n.awareness,H(t),n)},w_[2]=(e,t,n,r,i)=>{__(t,n.doc,(e,t)=>E_(n,t))};var T_=3e4,E_=(e,t)=>void 0,D_=(e,t,n)=>{let r=Ju(t),i=I(),a=U(r),o=e.messageHandlers[a];return o&&o(i,r,e,n,a),i},O_=(e,t,n)=>{t===e.ws&&(e.emit(`connection-close`,[n,e]),e.ws=null,t.close(),e.wsconnecting=!1,e.wsconnected?(e.wsconnected=!1,e.synced=!1,b_(e.awareness,Array.from(e.awareness.getStates().keys()).filter(t=>t!==e.doc.clientID),e),e.emit(`status`,[{status:`disconnected`}])):e.wsUnsuccessfulReconnects++,setTimeout(k_,ru(au(2,e.wsUnsuccessfulReconnects)*100,e.maxBackoffTime),e))},k_=e=>{if(e.shouldConnect&&e.ws===null){let t=new e._WS(e.url,e.protocols);t.binaryType=`arraybuffer`,e.ws=t,e.wsconnecting=!0,e.wsconnected=!1,e.synced=!1,t.onmessage=n=>{e.wsLastMessageReceived=dd();let r=D_(e,new Uint8Array(n.data),!0);Su(r)>1&&t.send(L(r))},t.onerror=t=>{e.emit(`connection-error`,[t,e])},t.onclose=n=>{O_(e,t,n)},t.onopen=()=>{e.wsLastMessageReceived=dd(),e.wsconnecting=!1,e.wsconnected=!0,e.wsUnsuccessfulReconnects=0,e.emit(`status`,[{status:`connected`}]);let n=I();if(z(n,0),u_(n,e.doc),t.send(L(n)),e.awareness.getLocalState()!==null){let n=I();z(n,1),B(n,x_(e.awareness,[e.doc.clientID])),t.send(L(n))}},e.emit(`status`,[{status:`connecting`}])}},A_=(e,t)=>{let n=e.ws;e.wsconnected&&n&&n.readyState===n.OPEN&&n.send(t),e.bcconnected&&l_(e.bcChannel,t,e)},j_=class extends $l{constructor(e,t,n,{connect:r=!0,awareness:i=new y_(n),params:o={},protocols:s=[],WebSocketPolyfill:c=WebSocket,resyncInterval:l=-1,maxBackoffTime:u=2500,disableBc:d=!1}={}){for(super();e[e.length-1]===`/`;)e=e.slice(0,e.length-1);this.serverUrl=e,this.bcChannel=e+`/`+t,this.maxBackoffTime=u,this.params=o,this.protocols=s,this.roomname=t,this.doc=n,this._WS=c,this.awareness=i,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=d,this.wsUnsuccessfulReconnects=0,this.messageHandlers=w_.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=r,this._resyncInterval=0,l>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){let e=I();z(e,0),u_(e,n),this.ws.send(L(e))}},l)),this._bcSubscriber=(e,t)=>{if(t!==this){let t=D_(this,new Uint8Array(e),!1);Su(t)>1&&l_(this.bcChannel,L(t),this)}},this._updateHandler=(e,t)=>{if(t!==this){let t=I();z(t,0),m_(t,e),A_(this,L(t))}},this.doc.on(`update`,this._updateHandler),this._awarenessUpdateHandler=({added:e,updated:t,removed:n},r)=>{let a=e.concat(t).concat(n),o=I();z(o,1),B(o,x_(i,a)),A_(this,L(o))},this._exitHandler=()=>{b_(this.awareness,[n.clientID],`app closed`)},Ld&&a.t!==void 0&&a.t.on(`exit`,this._exitHandler),i.on(`update`,this._awarenessUpdateHandler),this._checkInterval=setInterval(()=>{this.wsconnected&&T_<dd()-this.wsLastMessageReceived&&O_(this,this.ws,null)},T_/10),r&&this.connect()}get url(){let e=C_(this.params);return this.serverUrl+`/`+this.roomname+(e.length===0?``:`?`+e)}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,this.emit(`synced`,[e]),this.emit(`sync`,[e]))}destroy(){this._resyncInterval!==0&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),Ld&&a.t!==void 0&&a.t.off(`exit`,this._exitHandler),this.awareness.off(`update`,this._awarenessUpdateHandler),this.doc.off(`update`,this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||=(s_(this.bcChannel,this._bcSubscriber),!0);let e=I();z(e,0),u_(e,this.doc),l_(this.bcChannel,L(e),this);let t=I();z(t,0),d_(t,this.doc),l_(this.bcChannel,L(t),this);let n=I();z(n,3),l_(this.bcChannel,L(n),this);let r=I();z(r,1),B(r,x_(this.awareness,[this.doc.clientID])),l_(this.bcChannel,L(r),this)}disconnectBc(){let e=I();z(e,1),B(e,x_(this.awareness,[this.doc.clientID],new Map)),A_(this,L(e)),this.bcconnected&&=(c_(this.bcChannel,this._bcSubscriber),!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&O_(this,this.ws,null)}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(k_(this),this.connectBc())}},M_=()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else n!==void 0&&n()}},N_=class{constructor(e,t,n){this.start=e,this.end=t,this.direction=n}},P_=(e,t,n)=>{let r=e.getSelection();if(r!==null){let e=r.getStartPosition(),i=r.getEndPosition();return new N_(Om(n,t.getOffsetAt(e)),Om(n,t.getOffsetAt(i)),r.getDirection())}return null},F_=(e,t,n,r)=>{let i=Am(n.start,r),a=Am(n.end,r);if(i!==null&&a!==null&&i.type===t&&a.type===t){let t=e.getModel(),r=t.getPositionAt(i.index),o=t.getPositionAt(a.index);return s.l.createWithDirection(r.lineNumber,r.column,o.lineNumber,o.column,n.direction)}return null},I_=class{constructor(e,t,n=new Set,r=null){this.doc=e.doc,this.ytext=e,this.monacoModel=t,this.editors=n,this.mux=M_(),this._savedSelections=new Map,this._beforeTransaction=()=>{this.mux(()=>{this._savedSelections=new Map,n.forEach(n=>{if(n.getModel()===t){let r=P_(n,t,e);r!==null&&this._savedSelections.set(n,r)}})})},this.doc.on(`beforeAllTransactions`,this._beforeTransaction),this._decorations=new Map,this._rerenderDecorations=()=>{n.forEach(n=>{if(r&&n.getModel()===t){let i=this._decorations.get(n)||[],a=[];r.getStates().forEach((n,r)=>{if(r!==this.doc.clientID&&n.selection!=null&&n.selection.anchor!=null&&n.selection.head!=null){let i=Am(n.selection.anchor,this.doc),o=Am(n.selection.head,this.doc);if(i!==null&&o!==null&&i.type===e&&o.type===e){let e,n,c,l;i.index<o.index?(e=t.getPositionAt(i.index),n=t.getPositionAt(o.index),c=`yRemoteSelectionHead yRemoteSelectionHead-`+r,l=null):(e=t.getPositionAt(o.index),n=t.getPositionAt(i.index),c=null,l=`yRemoteSelectionHead yRemoteSelectionHead-`+r),a.push({range:new s.c(e.lineNumber,e.column,n.lineNumber,n.column),options:{className:`yRemoteSelection yRemoteSelection-`+r,afterContentClassName:c,beforeContentClassName:l}})}}}),this._decorations.set(n,n.deltaDecorations(i,a))}else this._decorations.delete(n)})},this._ytextObserver=n=>{this.mux(()=>{let r=0;n.delta.forEach(e=>{if(e.retain!==void 0)r+=e.retain;else if(e.insert!==void 0){let n=t.getPositionAt(r),i=new s.l(n.lineNumber,n.column,n.lineNumber,n.column),a=e.insert;t.applyEdits([{range:i,text:a}]),r+=a.length}else if(e.delete!==void 0){let n=t.getPositionAt(r),i=t.getPositionAt(r+e.delete),a=new s.l(n.lineNumber,n.column,i.lineNumber,i.column);t.applyEdits([{range:a,text:``}])}else throw V()}),this._savedSelections.forEach((t,n)=>{let r=F_(n,e,t,this.doc);r!==null&&n.setSelection(r)})}),this._rerenderDecorations()},e.observe(this._ytextObserver);{let n=e.toString();t.getValue()!==n&&t.setValue(n)}this._monacoChangeHandler=t.onDidChangeContent(t=>{this.mux(()=>{this.doc.transact(()=>{t.changes.sort((e,t)=>t.rangeOffset-e.rangeOffset).forEach(t=>{e.delete(t.rangeOffset,t.rangeLength),e.insert(t.rangeOffset,t.text)})},this)})}),this._monacoDisposeHandler=t.onWillDispose(()=>{this.destroy()}),r&&(n.forEach(n=>{n.onDidChangeCursorSelection(()=>{if(n.getModel()===t){let i=n.getSelection();if(i===null)return;let a=t.getOffsetAt(i.getStartPosition()),o=t.getOffsetAt(i.getEndPosition());if(i.getDirection()===s.u.RTL){let e=a;a=o,o=e}r.setLocalStateField(`selection`,{anchor:Om(e,a),head:Om(e,o)})}}),r.on(`change`,this._rerenderDecorations)}),this.awareness=r)}destroy(){this._monacoChangeHandler.dispose(),this._monacoDisposeHandler.dispose(),this.ytext.unobserve(this._ytextObserver),this.doc.off(`beforeAllTransactions`,this._beforeTransaction),this.awareness&&this.awareness.off(`change`,this._rerenderDecorations)}};function L_(e,t){let[n]=i.Ft(),r=i.Ci(i.Kt);return{saveEmailFromEditor:(0,u.useCallback)(()=>{let a=new Date().toISOString().slice(0,19).replace(`T`,` `),o=i.ya.isPlugin?r:e.project,s={parent:e?.id,...e?.meta===void 0?{}:{meta:e.meta},title:e.title,author:e.author,project:o,html:t?.getValue()||``,excerpt:a,subject:e.subject,preheader:e.preheader,common_styles:e.common_styles,parent_email:e.parent_email};n({emailId:e?.id,body:s}).catch(e=>{})},[t,e,r,n])}}var R_=()=>{let[e,t]=(0,u.useState)(!1);return(0,u.useEffect)(()=>{let e=navigator.platform.toUpperCase().includes(`MAC`),n=n=>{let r=(e?n.metaKey:n.ctrlKey)&&n.code===`KeyZ`,i=r&&n.shiftKey;(r||i)&&(t(!0),n.preventDefault())},r=()=>{t(!1)},i=e=>{e.data?.operation===`application_action`&&(e.data.action===`undo`||e.data.action===`redo`)&&(t(!0),setTimeout(()=>t(!1),500))};return document.addEventListener(`keydown`,n,!0),document.addEventListener(`keyup`,r,!0),window.addEventListener(`message`,i),()=>{document.removeEventListener(`keydown`,n,!0),document.removeEventListener(`keyup`,r,!0),window.removeEventListener(`message`,i)}},[]),e},z_=({email:e,editorRef:t,setIsSpin:n,newEmailAiGeneratorRef:r})=>{let a=(0,u.useMemo)(()=>new Wp,[]),o=l.l(),s=(0,u.useRef)([]),c=(0,u.useRef)([]),d=(0,u.useRef)(!1),f=(0,u.useRef)(0),p=(0,u.useRef)(``),[m,ee]=(0,u.useState)(null),[h,te]=(0,u.useState)(null),[g,_]=(0,u.useState)(!1),[v,ne]=(0,u.useState)([]),[y,b]=(0,u.useState)(!1),[x,re]=(0,u.useState)(!1),S=l.p(o),C=i.Ci(i.n),{saveEmailFromEditor:w}=L_(e,m),T=(0,u.useRef)(null),[E,D]=(0,u.useState)(!1),[ie]=i.It(),O=e?.id,ae=!!(O===`3769995`||i.ya.isPlugin),oe=(0,u.useMemo)(()=>({name:{first_name:ae?C?.username:C?.first_name,last_name:ae?``:C?.last_name,email:C?.email},color:zl()}),[C,ae]),se=(0,u.useMemo)(()=>Rl(v,oe),[oe,v]),ce=(0,u.useCallback)(()=>{h&&(h?.destroy(),te(null))},[h]),le=(0,u.useCallback)(()=>{try{w()}catch{}},[w]),ue=(0,u.useCallback)(async e=>{try{return await ie({emailId:O,source:`editor`,html:e}).unwrap(),!0}catch{return!1}},[O,ie]),de=(0,u.useCallback)(async e=>{if(await ue(e)&&E){let e=setTimeout(()=>{D(!1)},0);return()=>clearTimeout(e)}},[ue,D,E]);(0,u.useEffect)(()=>{!O||!i.Wi.isEditor||(v.length===1&&f.current>1&&h&&le(),f.current=v.length)},[v.length,h,le]),(0,u.useEffect)(()=>{if(!O||!i.Wi.isEditor||E)return;let e=new j_(l.s,ae?`${O}-plugin`:`${O}-collaborate`,a);return te(e),e.awareness.setLocalStateField(`user`,oe),()=>{e?.destroy(),a?.destroy()}},[a,oe,ae,O,E]);let fe=(0,u.useCallback)(e=>{if(!d.current){d.current=!0;try{let t=c.current,n=Array.from(e.getStates().values());(n.length>1||n.length!==t.length)&&(ne(n),requestAnimationFrame(()=>{Fl(n,m,s,g,_,oe)})),c.current=n}finally{d.current=!1}}},[m,s,g,_,oe]);(0,u.useEffect)(()=>{if(!h||!m||!i.Wi.isEditor||!t.current||!m.getModel()||E)return;let e=null,r=h.awareness,o=a.getText(`monaco`),s=async i=>{let a=Array.from(r.getStates().values());if(i){if(o._length>0&&a.length>1&&!T.current){let e=m?.getModel()?.getValue()?.toString()||``,r=e=>e.replace(/\s+/g,` `).trim();r(e)!==r(o.toString())&&(await pe(t,n),n?.(!1),m.executeEdits(`collaboration`,[{range:m.getModel().getFullModelRange(),text:o.toString(),forceMoveMarkers:!0}]))}o._length>0&&a.length===1&&!T.current&&o.applyDelta([{delete:o._length},{insert:t.current?.getModel().getValue()}]),o._length===0&&o.insert(0,t.current?.getModel().getValue()),T.current&&o.applyDelta([{delete:o._length},{insert:T.current}]),e=new I_(o,m?.getModel(),new Set([m]),r),m?.onDidChangeCursorPosition(e=>Il(e,r)),m?.onDidChangeCursorSelection(e=>Ll(e,r)),r.on(`change`,()=>fe(r)),T.current=null}};return h.on(`sync`,s),()=>{e&&e.destroy(),h.off(`sync`,s)}},[m,h,a,t,fe,n,E]),(0,u.useEffect)(()=>{if(!h||!m||!i.Wi.isEditor||!t.current||E)return;let e=h?.awareness,n=setInterval(()=>{fe(e)},500);return()=>clearInterval(n)},[h,m,g,t,y,fe,ce,E]);async function pe(e,t){await new Promise(n=>{let r=()=>{t?.(!0),(e.current?.getModel()?.getValue()?.length||0)>0?n():setTimeout(r,100)};r()})}if((0,u.useEffect)(()=>{if(!O||!i.Wi.isEditor||y)return;let e=Bl({CHECK_INTERVAL:l.n,SLEEP_THRESHOLD:l.o,provider:h,handleOfflineCollaboration:ce,isNewEmailGeneration:E,saveEmailFromEditor:w});return()=>{clearInterval(e)}},[O,h,y,ce,b,E]),m&&se.length>0){let e=m?.getModel()?.getValue()?.toString()||``;p.current!==e&&`clear`in S&&S.clear(),p.current=e}let me=R_()&&se.length>0;return(0,u.useEffect)(()=>{if(!O||!i.Wi.isEditor)return;let e=setInterval(()=>{if(r?.current&&!E&&(ce(),D(!0)),!r?.current&&E){let e=o?.getValue();T.current=e,de(e)}},300);return()=>clearInterval(e)},[E,h,O,i.Wi.isEditor]),(0,u.useEffect)(()=>{if(!O||!i.Wi.isEditor)return;let e=()=>{document.visibilityState===`hidden`&&w()};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[e,O,i.Wi.isEditor]),[m,se,ee,y,me]};l.d(),l.v.options.format.wrapLineLength=0,He.config({monaco:s.m}),hn();var B_={tokenizer:`standard`};Dl(s.m,[`html`],B_),Ol(s.m,[`html`],B_);var V_=`'Source Code Pro', Consolas, 'Courier New', monospace`,H_=14;t.default=({email:e,readOnly:t,setOtherUsers:n,newEmailAiGeneratorRef:r})=>{let a=l.l();a.getLanguageId()!==`html`&&s.p.setModelLanguage(a,`html`);let d=i.q(i._o.ON_CODE_VALIDATE_ID),p=i.xt(),m=i.Ci(i.or),ee=i.Ci(o.u),h=i.Ci(i.ir),te=e?.hasOwnProperty(`type`)?ee:m,g=i.Ci(i.i),_=i.wi(),v=(0,u.useRef)(null),ne=(0,u.useRef)(null),y=(0,u.useRef)(null),b=(0,u.useRef)([]),x=i.on(),re=(0,u.useCallback)(()=>{_(i.o(!1))},[_]),[S,C]=(0,u.useState)(!1),w=c.o(),{__:T}=c.h(),{token:E}=c.zt(),[,D,ie,O,ae]=z_({email:e,editorRef:ne,setIsSpin:C,newEmailAiGeneratorRef:r});b.current=D,(0,u.useEffect)(()=>{t||n(b.current)},[D?.length,n,t]);let oe=(0,u.useMemo)(()=>()=>{w.error({message:T(l.i)})},[T,w]),se=(0,u.useMemo)(()=>()=>{w.warning({message:T(l.r)})},[T,w]);(0,u.useEffect)(()=>{O&&oe()},[O,oe]),(0,u.useEffect)(()=>{ae&&se()},[ae,se]),(0,u.useEffect)(()=>re(),[re]),(0,u.useEffect)(()=>{if(h){let{current:e}=v;e&&(e.revealRangeInCenterIfOutsideViewport(h),e.setSelection(h))}},[h]);let ce=(0,u.useCallback)(()=>{if(v.current){let e=v.current.getDomNode();if(e){let t=g.fontFamily||V_,n=g.fontSize||H_;e.style.setProperty(`--monaco-editor-font-family`,t,`important`),e.style.setProperty(`--monaco-monospace-font`,t,`important`),e.style.setProperty(`--monaco-editor-font-size`,`${n}px`,`important`),e.style.setProperty(`font-family`,t,`important`),e.style.setProperty(`font-size`,`${n}px`,`important`)}}},[g.fontFamily,g.fontSize]);(0,u.useEffect)(()=>{if(ce(),v.current){let e=v.current.getDomNode();if(e){let t=new MutationObserver(()=>{ce()});return t.observe(e,{childList:!0,subtree:!0}),()=>{t.disconnect()}}}},[g.fontFamily,ce]);let le=e=>{let{current:t}=v;if(t&&!t.hasTextFocus()){let n=t.getModel(),r=n.getPositionAt(e.start),i=n.getPositionAt(e.end),a={startColumn:r.column,startLineNumber:r.lineNumber,endColumn:i.column,endLineNumber:i.lineNumber};t.revealRangeInCenterIfOutsideViewport(a),t.setSelection(a)}},ue=async e=>{let{current:t}=v;if(t){let n=t.getModel();p({operation:i.aa.UPDATE_EDITOR_POSITION_FROM_EDITOR,data:n.getOffsetAt(e)})}};(0,u.useEffect)(()=>{matchMedia(i.ba).addEventListener(`change`,t=>{let n=window.localStorage.getItem(i.ua.em_color_scheme),r=t.matches?i.Gi:i.ca;e.hasOwnProperty(`type`)?_(n?o.g(n===`dark`?`vs-${n}`:i.ca):o.g(r===`dark`?`vs-${r}`:i.ca)):_(n?i.br(n===`dark`?`vs-${n}`:i.ca):i.br(r===`dark`?`vs-${r}`:i.ca))})},[_,e]),(0,u.useEffect)(()=>{let t=window.localStorage.getItem(i.ua.em_color_scheme),n=matchMedia(`(prefers-color-scheme: dark)`).matches?i.Gi:i.ca;e?.hasOwnProperty(`type`)?_(t?o.g(t===`dark`?`vs-${t}`:i.ca):o.g(n===`dark`?`vs-${n}`:i.ca)):_(t?i.br(t===`dark`?`vs-${t}`:i.ca):i.br(n===`dark`?`vs-${n}`:i.ca))},[_,e]);let de=(e,t)=>{v.current=e,ne.current=e;let n=e.getContribution(`editor.linkDetector`).openerService,r=n.open.bind(n),a=document.createElement(`div`),c=new ln.default(e,s.m,{"doctype-html5":!1,"html-lang-require":!1,"head-script-disabled":!1,"style-disabled":!1,"script-disabled":!1,"attr-lowercase":!1,"attr-value-single-quotes":!1,"attr-value-not-empty":!1,"attr-sorted":!1,"attr-whitespace":!1,"input-requires-label":!1,"tag-self-close":!1,"tagname-lowercase":!1,"href-abs-or-rel":!1,"inline-style-disabled":!1,"space-tab-mixed-disabled":!1,"attr-no-unnecessary-whitespace":!0,"tags-check":{img:{selfclosing:!1,attrsRequired:[`src`,`alt`]},a:{selfclosing:!1,attrsRequired:[]}},"empty-tag-not-self-closed":!1,"attr-value-double-quotes":!0,"doctype-first":!0,"tag-pair":!0,"spec-char-escape":!0,"id-unique":!0,"src-not-empty":!0,"attr-no-duplication":!0,"title-require":!0,"alt-require":!0,"inline-script-disabled":!0,"id-class-value":!1,"id-class-ad-disabled":!0,"attr-unsafe-chars":!0,csslint:{"display-property-grouping":!0,"known-properties":!0}});i.Wi.isEditor&&ne.current&&ie(ne.current),c.watch(),e.getContribution(`editor.linkDetector`).openerService.open=e=>(a.innerHTML=e,r(a.textContent)),_(i.o(!0)),e.onMouseUp(()=>{let t=e.getSelection();t.startColumn===t.endColumn&&t.startLineNumber===t.endLineNumber&&ue(e.getPosition())}),e.onDidBlurEditorWidget(()=>{p({operation:i.aa.EDITOR_CHANGE_FOCUS,data:!1}),_(o.i(!1))}),e.onDidFocusEditorWidget(()=>{p({operation:i.aa.EDITOR_CHANGE_FOCUS,data:!0}),_(o.i(!0))}),e.onDidChangeModelContent(()=>{setTimeout(()=>{ce()},0)}),setTimeout(()=>{ce()},100)};l.g(e=>{let t=e.data.operation,n=e.data;y.current=t,t===i.aa.UPDATE_EDITOR_POSITION_FROM_IFRAME&&le(n.data)});let fe=(0,u.useMemo)(()=>document.createElement(`div`),[]),pe=(0,u.useMemo)(()=>({...g,fontFamily:g.fontFamily||V_,fontSize:g.fontSize||H_,fontWeight:g.fontWeight||`normal`,domReadOnly:t,readOnly:t,unusualLineTerminators:`off`,mouseWheelZoom:!0,wordWrap:x.onlyCodeModeInMobile?`off`:g.wordWrap,ariaContainerElement:fe,unicodeHighlight:{ambiguousCharacters:!1,invisibleCharacters:!1}}),[g,x.onlyCodeModeInMobile,t,fe]);function me(e){e[0]?.message!==`Doctype must be declared first.`&&(i.ya.isPlugin&&d.fire(e),_(i.Fr(e)))}return a?.uri&&(0,f.jsxs)(f.Fragment,{children:[S&&(0,f.jsx)(c.W,{style:{position:`fixed`,width:`100%`,height:`100%`,top:0,left:0,zIndex:E?.zIndexPopupBase,background:E?.colorBgLayout}}),(0,f.jsx)(`div`,{id:`monaco-editor-root`,style:{width:`100%`,height:`100%`},children:(0,f.jsx)(lt,{theme:te,className:`monaco-editor`,defaultLanguage:`html`,onMount:de,options:pe,keepCurrentModel:!0,path:a.uri.toString(),onValidate:me})})]})}});
|