@emailmaker/emailmaker 1.1.7 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/{emailmaker-core.0f53b24b.js → emailmaker-core.808bee5e.js} +1 -1
  2. package/emailmaker-esm.js +2 -2
  3. package/emailmaker.js +2 -2
  4. package/iframe/js/amp.CdTI2-VC.js +1 -0
  5. package/iframe/js/iframe-eblock.js +1 -1
  6. package/iframe/js/iframe.js +1 -1
  7. package/iframe/js/rules.CNqvmp_P.js +1 -1
  8. package/iframe/js/sanitize-html.tGUeRBWs.js +1 -0
  9. package/package.json +1 -1
  10. package/static/core/{f67b8fa2.js → 136331f7.js} +2 -2
  11. package/static/core/{5f66a133.js → 1f9fcb39.js} +3 -3
  12. package/static/core/{b330862b.js → 31f5d274.js} +2 -2
  13. package/static/core/{542c10a0.js → 461a4018.js} +1 -1
  14. package/static/core/{54c69205.js → 6eb88f06.js} +1 -1
  15. package/static/core/80d0f890.js +1 -0
  16. package/static/core/{e5c35767.js → 8147252b.js} +1 -1
  17. package/static/core/{425f6198.js → 97e1264b.js} +2 -2
  18. package/static/core/9ef47c7c.js +1 -0
  19. package/static/core/{6f1c8ca5.js → a56dd82d.js} +2 -2
  20. package/static/core/{eb4e7505.js → ae2bef91.js} +1 -1
  21. package/static/core/{c7f99585.js → bfd98708.js} +1 -1
  22. package/static/core/{e1ac64f3.js → d3d60ed0.js} +4 -4
  23. package/static/core/{37323be2.js → d55c0f70.js} +10 -10
  24. package/static/core/fdb48e3f.js +78 -0
  25. package/two_step_headless_plugin.html +558 -0
  26. package/iframe/js/amp.BtGt-xkd.js +0 -1
  27. package/iframe/js/sanitize-html.BzjMWt1k.js +0 -1
  28. package/static/core/99f965a4.js +0 -1
  29. package/static/core/c19a7448.js +0 -78
  30. package/static/core/de149603.js +0 -1
  31. /package/iframe/{iframe-eblock.0f53b24b.html → iframe-eblock.808bee5e.html} +0 -0
  32. /package/iframe/{iframe.0f53b24b.html → iframe.808bee5e.html} +0 -0
@@ -0,0 +1 @@
1
+ __emailmaker__.define(`static/core/9ef47c7c.js`,[`require`,`exports`,`module`,`static/core/1f9fcb39.js`],function(e,t,n){let r=e("./1f9fcb39.js");function i(e){return e!=null&&Object.prototype.hasOwnProperty.call(e,`meta`)}function a(e,t){return i(e)?e.meta:t}var o=r.Cr({appliedShowToken:0,invalidateEmailId:null,editorThemeColor:`light`,isSettingsDisabled:!1,emailAutosaveTimestamps:{},settings:{backgroundColor:``,backgroundImage:[{type:`url`,value:``}],backgroundPositionX:``,backgroundPositionY:``,backgroundRepeat:``,textStrong:!1,textItalic:!1,textUnderline:!1},elementSettings:{},searchFilters:{},emailCommonStyles:``,saveTime:null,mobileViewActive:{shutdown:!0,styles:!0},email:{id:void 0,is_inited:!1,isNew:!1,subject:void 0,preheader:void 0,description:``,html:``,project:void 0,project_author:``,project_title:``,tags:[],utm_parameters:{utm_source:``,utm_medium:``,utm_campaign:``,utm_term:``,utm_content:``},parent_email:null,common_styles:`{}`,title:null,emailtags:[],group:[],isAmp:!1},emailIsEdit:!1,isCodeMode:!1,codeModeDirection:void 0,emailViewType:void 0,changeKey:null,problemsList:[],activeProblemRange:null,emailGroups:{},parentGroupOfProject:null,projectGroups:[],isNeedUpdateAppearance:!1,isNeedUpdateContentAppearance:!1}),s=`emailSlice`,c=r.qr({name:s,initialState:o,reducers:{setEditorThemeColor:(e,t)=>{e.editorThemeColor=t.payload},setEmailFromHistory:(e,{payload:t})=>{if(!t)return;let n=e.email,r=t?.preheader===void 0,i=t?.subject===void 0,o=a(t,n.meta);e.email={...n,html:t?.html,preheader:r?n.preheader:t?.preheader,subject:i?n.subject:t?.subject,common_styles:typeof t?.common_styles==`string`&&t?.common_styles.startsWith(`{`)?t?.common_styles:n.common_styles||`{}`,...o===void 0?{}:{meta:o}},e.isNeedUpdateAppearance=!0,e.isNeedUpdateContentAppearance=!0},setEmailSettings:(e,{payload:t})=>{Object.assign(e,{...e,settings:{...t},isSettingsDisabled:!1})},setEmailSettingsDisable:(e,t)=>{e.isSettingsDisabled=t.payload},setElementSettings:(e,{payload:t})=>{e.elementSettings=t},setSearchFilters:(e,t)=>{e.searchFilters=t.payload},updateSearchFilters:(e,t)=>{e.searchFilters={...e.searchFilters,...t.payload}},setEmailHTML:(e,t)=>{e.email.html=t.payload},setEmailSubject:(e,t)=>{(e.email.title===e.email.subject||!e.email.subject&&!e.email.title)&&(e.email.title=t.payload),e.email.subject=t.payload},setEmailPreheader:(e,t)=>{e.email.preheader=t.payload},resetEmailSlice:e=>{let t=e.emailAutosaveTimestamps;return{...o,emailAutosaveTimestamps:t}},setEmailTitle:(e,t)=>{e.email.title=t.payload},setEmailMeta:(e,t)=>{if(t.payload===void 0){delete e.email.meta;return}e.email.meta={...e.email.meta??{},...t.payload}},setIsInited:(e,t)=>{e.email.is_inited=t.payload},setEmailIsAmp:(e,t)=>{e.email.isAmp=t.payload},setProblemsList:(e,t)=>{e.problemsList=t.payload},setActiveProblemRange:(e,t)=>{e.activeProblemRange=t.payload},setIsNeedUpdateContentAppearance:(e,t)=>{e.isNeedUpdateContentAppearance=t.payload},setIsNeedUpdateAppearance:(e,t)=>{e.isNeedUpdateAppearance=t.payload},setEmailGroups:(e,{payload:t})=>{let n=Object.keys(t)[0],r=e.emailGroups,i=e.parentGroupOfProject,a=e.projectGroups,o={};i&&a.length&&(t[n]?.forEach(e=>{let t=a.find(e=>e.id===+n),r=t?.children.find(t=>t.id===+e);r?(o.hasOwnProperty(t.id)||(o[t.id]=[]),o[t.id].push({label:r.name,value:r.id})):(o.hasOwnProperty(n)||(o[n]=[]),o[n].push({label:e,value:null}))}),t[n].length===0&&(o[n]=[])),e.emailGroups={...r,...o}}},extraReducers:e=>{e.addMatcher(e=>e.type===`emailsApi/queries/queryResultPatched`,(e,t)=>{let n=t.payload.queryCacheKey.match(/\("([0-9]+)"\)/),r=t.payload?.patches[0];r?.path?.[0]&&(e.email[r?.path[0]]=r.value),n?.[1]&&(e.invalidateEmailId=n[1]),e.emailIsEdit=!0}),e.addMatcher(e=>e.type===`emailsApi/invalidateTags`,(e,t)=>{if(t.payload[0].id===+e.invalidateEmailId)return o}),e.addMatcher(r.Wt.endpoints.editEmail.matchFulfilled,(e,{payload:t})=>{e.invalidateEmailId=null;let n=a(t,e.email.meta);e.email={...e.email,...t,renderGuid:e.email.renderGuid,...n===void 0?{}:{meta:n}}}),e.addMatcher(r.Wt.endpoints.autoSaveEmail.matchFulfilled,(e,t)=>{e.email.id?.toString()===t.payload.parent?.toString()&&(e.email.html=t.payload.html,t.payload.modified&&(e.email.modified=t.payload.modified,e.emailAutosaveTimestamps[t.payload.parent]=t.payload.modified))}),e.addMatcher(r.Wt.endpoints.getEmail.matchFulfilled,(e,{payload:t})=>{let n=e.email,i=a(t,t.id===n?.id?n.meta:void 0),s=n?.id!=null&&n.id===t.id,c=t.showToken,l=c!==void 0&&c!==e.appliedShowToken,u=s&&t.modified!==void 0&&n.modified===t.modified,d=s&&n.is_inited===!0&&u&&!l&&!!n.html?.trim(),f=s&&n.renderGuid?n.renderGuid:t.renderGuid??r.ro(),{showToken:p,...m}=t;e.email={...o.email,...m,renderGuid:f,...d?{html:n.html}:{},is_inited:t.is_inited||(s?n?.is_inited:o.email.is_inited),common_styles:typeof t?.common_styles==`string`&&t?.common_styles.startsWith(`{`)?t?.common_styles:`{}`,...i===void 0?{}:{meta:i}},c===void 0?(!s||n.is_inited!==!0||!u)&&(e.appliedShowToken+=1):e.appliedShowToken=c,e.emailIsEdit=!1}),e.addMatcher(r.Et.endpoints.getGroups.matchFulfilled,(e,{meta:t,payload:n})=>{let r=e.email.group,i=t.arg.originalArgs.parent,a=n;i&&(e.parentGroupOfProject=i,e.projectGroups=a);let o={};i&&r.length&&a.length&&r?.forEach(e=>{a?.forEach(t=>{let n=t.children.find(t=>t.id===e);n&&(o.hasOwnProperty(t.id)||(o[t.id]=[]),o[t.id].push({label:n.name,value:n.id}))})}),e.emailGroups=o}),e.addMatcher(r.zt.endpoints.getProject.matchFulfilled,(e,{meta:t,payload:n})=>{e.parentGroupOfProject=n.group?.[0]||null})}}),{setEditorThemeColor:l,setEmailSettings:u,setElementSettings:d,setEmailSettingsDisable:f,setSearchFilters:p,updateSearchFilters:m,setEmailSubject:ee,setEmailPreheader:h,setEmailHTML:te,resetEmailSlice:ne,setEmailTitle:re,setEmailFromHistory:ie,setEmailMeta:g,setIsInited:_,setEmailIsAmp:v,setProblemsList:y,setActiveProblemRange:b,setEmailGroups:x,setIsNeedUpdateAppearance:S,setIsNeedUpdateContentAppearance:C}=c.actions,w=e=>e[s].isNeedUpdateContentAppearance,T=e=>e[s].email,E=e=>e[s].appliedShowToken,D=e=>e[s].settings,O=e=>e[s].emailGroups,k=e=>e[s].problemsList,A=e=>e[s].searchFilters,j=e=>e[s].projectGroups,M=e=>e[s].emailAutosaveTimestamps,N=e=>e[s].elementSettings,P=e=>e[s].editorThemeColor,F=e=>e[s].invalidateEmailId,I=e=>e[s].isSettingsDisabled,L=e=>e[s].activeProblemRange,R=e=>e[s].isNeedUpdateAppearance,z=r.Cr({invalidateBlockId:null,isCodeMode:!1,codeModeDirection:`right`,editorThemeColor:`light`,isSettingsDisabled:!1,settings:{width:``},elementSettings:{},searchFilters:{},block:{id:void 0,isNew:!1,subject:``,description:``,html:``,project:void 0,project_title:``,project_author:void 0,tags:[],type:`Other`,title:null,isAmp:!1},monacoDidMount:!1}),B=`blockSlice`,V=r.qr({name:B,initialState:z,reducers:{switchCodeMode:e=>{e.isCodeMode=!e.isCodeMode},setEditorThemeColor:(e,t)=>{e.editorThemeColor=t.payload},setBlockSettings:(e,t)=>{Object.assign(e,{...e,settings:t.payload,isSettingsDisabled:!1})},setBlockSettingsDisable:(e,t)=>{e.isSettingsDisabled=t.payload},setElementSettings:(e,t)=>{e.elementSettings=t.payload},setSearchFilters:(e,t)=>{e.searchFilters=t.payload},setBlockHtml:(e,t)=>{e.block.html=t.payload},resetBlockSlice:()=>z,setBlockIsAmp:(e,t)=>{e.block.isAmp=t.payload}},extraReducers:e=>{e.addMatcher(e=>e.type===`blocksApi/queries/queryResultPatched`,(e,t)=>{let n=t.payload.queryCacheKey.match(/\(([0-9]+)\)/),r=t.payload?.patches[0];if(r?.path?.[0]&&(e.block[r?.path[0]]=r.value),n?.[1]&&(e.invalidateBlockId=n[1]),t.payload.queryCacheKey.startsWith(`getBlock`)){let n=t.payload?.patches[0];n?.path?.[0]&&(e.block[n?.path[0]]=n.value)}}),e.addMatcher(e=>e.type===`blocksApi/invalidateTags`,(e,t)=>{if(t.payload[0].id===+e.invalidateBlockId)return{...z,isCodeMode:e?.isCodeMode,codeModeDirection:e.codeModeDirection}}),e.addMatcher(r.er.endpoints.editBlock.matchFulfilled,(e,{payload:t})=>{e.invalidateBlockId=null,e.block={...e.block,...t,renderGuid:e.block.renderGuid}}),e.addMatcher(r.er.endpoints.autoSaveBlock.matchFulfilled,(e,t)=>{e?.block.id?.toString()===t.payload.id?.toString()&&(e.block.html=t.payload.html)}),e.addMatcher(r.er.endpoints.getBlock.matchFulfilled,(e,{payload:t})=>{e.block={...z.block,...t}})}}),{switchCodeMode:ae,setEditorThemeColor:H,setBlockSettings:U,setElementSettings:W,setBlockSettingsDisable:G,setSearchFilters:K,setBlockHtml:oe,resetBlockSlice:q,setBlockIsAmp:se}=V.actions,J=e=>e[B].block,Y=e=>e[B].isCodeMode,ce=e=>e[B].settings,le=e=>e[B].searchFilters,X=e=>e[B].elementSettings,ue=e=>e[B].editorThemeColor,de=e=>e[B].isSettingsDisabled,Z=r.Cr({isCollapsed:!0,isMonacoFocusing:!1}),Q=`defaultModePanesSlice`,$=r.qr({name:Q,initialState:Z,reducers:{setMonacoFocusing:(e,t)=>{e.isMonacoFocusing=t.payload},resetPanes:()=>Z}}),{resetPanes:fe,setMonacoFocusing:pe}=$.actions,me=e=>e[Q].isMonacoFocusing;Object.defineProperty(t,"$",{enumerable:!0,get:function(){return p}}),Object.defineProperty(t,"A",{enumerable:!0,get:function(){return F}}),Object.defineProperty(t,"B",{enumerable:!0,get:function(){return x}}),Object.defineProperty(t,"C",{enumerable:!0,get:function(){return P}}),Object.defineProperty(t,"D",{enumerable:!0,get:function(){return A}}),Object.defineProperty(t,"E",{enumerable:!0,get:function(){return M}}),Object.defineProperty(t,"F",{enumerable:!0,get:function(){return j}}),Object.defineProperty(t,"G",{enumerable:!0,get:function(){return u}}),Object.defineProperty(t,"H",{enumerable:!0,get:function(){return v}}),Object.defineProperty(t,"I",{enumerable:!0,get:function(){return b}}),Object.defineProperty(t,"J",{enumerable:!0,get:function(){return re}}),Object.defineProperty(t,"K",{enumerable:!0,get:function(){return f}}),Object.defineProperty(t,"L",{enumerable:!0,get:function(){return l}}),Object.defineProperty(t,"M",{enumerable:!0,get:function(){return w}}),Object.defineProperty(t,"N",{enumerable:!0,get:function(){return I}}),Object.defineProperty(t,"O",{enumerable:!0,get:function(){return O}}),Object.defineProperty(t,"P",{enumerable:!0,get:function(){return k}}),Object.defineProperty(t,"Q",{enumerable:!0,get:function(){return y}}),Object.defineProperty(t,"R",{enumerable:!0,get:function(){return d}}),Object.defineProperty(t,"S",{enumerable:!0,get:function(){return E}}),Object.defineProperty(t,"T",{enumerable:!0,get:function(){return T}}),Object.defineProperty(t,"U",{enumerable:!0,get:function(){return g}}),Object.defineProperty(t,"V",{enumerable:!0,get:function(){return te}}),Object.defineProperty(t,"W",{enumerable:!0,get:function(){return h}}),Object.defineProperty(t,"X",{enumerable:!0,get:function(){return S}}),Object.defineProperty(t,"Y",{enumerable:!0,get:function(){return _}}),Object.defineProperty(t,"Z",{enumerable:!0,get:function(){return C}}),Object.defineProperty(t,"_",{enumerable:!0,get:function(){return W}}),Object.defineProperty(t,"a",{enumerable:!0,get:function(){return V}}),Object.defineProperty(t,"b",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(t,"c",{enumerable:!0,get:function(){return le}}),Object.defineProperty(t,"d",{enumerable:!0,get:function(){return X}}),Object.defineProperty(t,"et",{enumerable:!0,get:function(){return m}}),Object.defineProperty(t,"f",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(t,"g",{enumerable:!0,get:function(){return H}}),Object.defineProperty(t,"h",{enumerable:!0,get:function(){return G}}),Object.defineProperty(t,"i",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(t,"j",{enumerable:!0,get:function(){return R}}),Object.defineProperty(t,"k",{enumerable:!0,get:function(){return D}}),Object.defineProperty(t,"l",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(t,"m",{enumerable:!0,get:function(){return U}}),Object.defineProperty(t,"n",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(t,"o",{enumerable:!0,get:function(){return q}}),Object.defineProperty(t,"p",{enumerable:!0,get:function(){return de}}),Object.defineProperty(t,"q",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(t,"r",{enumerable:!0,get:function(){return me}}),Object.defineProperty(t,"s",{enumerable:!0,get:function(){return J}}),Object.defineProperty(t,"t",{enumerable:!0,get:function(){return $}}),Object.defineProperty(t,"u",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(t,"v",{enumerable:!0,get:function(){return K}}),Object.defineProperty(t,"w",{enumerable:!0,get:function(){return N}}),Object.defineProperty(t,"x",{enumerable:!0,get:function(){return L}}),Object.defineProperty(t,"y",{enumerable:!0,get:function(){return c}}),Object.defineProperty(t,"z",{enumerable:!0,get:function(){return ie}})});
@@ -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/6f1c8ca5.js`,[`require`,`exports`,`module`,`static/core/354bf8a9.js`,`static/core/68599f0c.js`,`static/core/f67b8fa2.js`,`static/core/5f66a133.js`,`static/core/425f6198.js`,`static/core/e4e7c3852.js`,`static/core/c7357e24.js`,`static/core/99f965a4.js`,`react`,`react/jsx-runtime`],function(e,t,n){let r=e("./354bf8a9.js"),i=e("./5f66a133.js"),a=e("./68599f0c.js"),o=e("./99f965a4.js");e("./c7357e24.js");let s=e("./e4e7c3852.js"),c=e("./425f6198.js"),l=e("./f67b8fa2.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.
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/a56dd82d.js`,[`require`,`exports`,`module`,`static/core/354bf8a9.js`,`static/core/68599f0c.js`,`static/core/136331f7.js`,`static/core/1f9fcb39.js`,`static/core/97e1264b.js`,`static/core/e4e7c3852.js`,`static/core/c7357e24.js`,`static/core/9ef47c7c.js`,`react`,`react/jsx-runtime`],function(e,t,n){let r=e("./354bf8a9.js"),i=e("./1f9fcb39.js"),a=e("./68599f0c.js"),o=e("./9ef47c7c.js");e("./c7357e24.js");let s=e("./e4e7c3852.js"),c=e("./97e1264b.js"),l=e("./136331f7.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
 
@@ -37,4 +37,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
37
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
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
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 Ig(i)),n.right.integrate(e,0),n.forward()}Jh(e,t,n,s)},eg=(e,t,n,r,i)=>{let a=t,o=Bl();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&&Yh(i,n);break}}}t=t.right}return s},tg=(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}},ng=e=>{let t=0;return Y(e.doc,n=>{let r=e._start,i=e._start,a=Bl(),o=Vl(a);for(;i;){if(i.deleted===!1)switch(i.content.constructor){case Q:Yh(o,i.content);break;default:t+=eg(n,r,i,a,o),a=Vl(o),r=i;break}i=i.right}}),t},rg=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&&Hm(e,n.store.clients.get(r),a,i,e=>{!e.deleted&&e.content.constructor===Q&&e.constructor!==bg&&t.add(e.parent)})}Y(n,n=>{jp(e,e.deleteSet,e=>{if(e instanceof bg||!e.parent._hasFormatting||t.has(e.parent))return;let r=e.parent;e.content.constructor===Q?t.add(r):tg(n,e)});for(let e of t)ng(e)})},ig=(e,t,n)=>{let r=n,i=Vl(t.currentAttributes),a=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Kg:case Og:case Ig:n<t.right.length&&zm(e,q(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}a&&eg(e,a,t.right,i,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&vh(o._searchMarker,t.index,-r+n),t},ag=class extends lh{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},Ed(o)||(e.attributes=xd({},o))),c=0;break}e&&t.push(e),a=null}};for(;i!==null;){switch(i.content.constructor){case Kg:case Og: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 Ig: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)||(Wh(n.get(t)??null,s)?s!==null&&i.delete(e):(a===`retain`&&u(),Wh(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;Wh(e,s)||(a===`retain`&&u(),o[t]=e)}else if(!i.deleted){r.set(t,s);let n=o[t];n!==void 0&&(Wh(n,s)?n!==null&&i.delete(e):(a===`retain`&&u(),s===null?delete o[t]:o[t]=s))}i.deleted||(a===`insert`&&u(),Yh(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}},og=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 ag(this,e,t);yh(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===Ig&&(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 Gh(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)&&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.qt(),r=i.Fr(i.in);return{saveEmailFromEditor:(0,u.useCallback)(()=>{let a=new Date().toISOString().slice(0,19).replace(`T`,` `),o=i.ji.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.Fr(i.n),{saveEmailFromEditor:w}=I_(e,m),T=(0,u.useRef)(null),[E,D]=(0,u.useState)(!1),[ie]=i.Jt(),O=e?.id,ae=!!(O===`3769995`||i.ji.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.ni.isEditor||(v.length===1&&f.current>1&&h&&le(),f.current=v.length)},[v.length,h,le]),(0,u.useEffect)(()=>{if(!O||!i.ni.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.ni.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.ni.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.ni.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.ni.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.ni.isEditor]),(0,u.useEffect)(()=>{if(!O||!i.ni.isEditor)return;let e=()=>{document.visibilityState===`hidden`&&w()};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[e,O,i.ni.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.Oa.ON_CODE_VALIDATE_ID),p=i.xt(),m=i.Fr(o.S),ee=i.Fr(o.u),h=i.Fr(o.x),te=e?.hasOwnProperty(`type`)?ee:m,g=i.Fr(i.i),_=i.Ir(),v=(0,u.useRef)(null),ne=(0,u.useRef)(null),y=(0,u.useRef)(null),b=(0,u.useRef)([]),x=i.vn(),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._i.UPDATE_EDITOR_POSITION_FROM_EDITOR,data:n.getOffsetAt(e)})}};(0,u.useEffect)(()=>{matchMedia(i.Mi).addEventListener(`change`,t=>{let n=window.localStorage.getItem(i.Si.em_color_scheme),r=t.matches?i.ri:i.bi;e.hasOwnProperty(`type`)?_(n?o.g(n===`dark`?`vs-${n}`:i.bi):o.g(r===`dark`?`vs-${r}`:i.bi)):_(n?o.I(n===`dark`?`vs-${n}`:i.bi):o.I(r===`dark`?`vs-${r}`:i.bi))})},[_,e]),(0,u.useEffect)(()=>{let t=window.localStorage.getItem(i.Si.em_color_scheme),n=matchMedia(`(prefers-color-scheme: dark)`).matches?i.ri:i.bi;e?.hasOwnProperty(`type`)?_(t?o.g(t===`dark`?`vs-${t}`:i.bi):o.g(n===`dark`?`vs-${n}`:i.bi)):_(t?o.I(t===`dark`?`vs-${t}`:i.bi):o.I(n===`dark`?`vs-${n}`:i.bi))},[_,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.ni.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._i.EDITOR_CHANGE_FOCUS,data:!1}),_(o.i(!1))}),e.onDidFocusEditorWidget(()=>{p({operation:i._i.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._i.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.ji.isPlugin&&d.fire(e),_(o.Z(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})})]})}});
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.qt(),r=i.Br(i.in);return{saveEmailFromEditor:(0,u.useCallback)(()=>{let a=new Date().toISOString().slice(0,19).replace(`T`,` `),o=i.Ii.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.Br(i.n),{saveEmailFromEditor:w}=I_(e,m),T=(0,u.useRef)(null),[E,D]=(0,u.useState)(!1),[ie]=i.Jt(),O=e?.id,ae=!!(O===`3769995`||i.Ii.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.si.isEditor||(v.length===1&&f.current>1&&h&&le(),f.current=v.length)},[v.length,h,le]),(0,u.useEffect)(()=>{if(!O||!i.si.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.si.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.si.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.si.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.si.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.si.isEditor]),(0,u.useEffect)(()=>{if(!O||!i.si.isEditor)return;let e=()=>{document.visibilityState===`hidden`&&w()};return document.addEventListener(`visibilitychange`,e),()=>{document.removeEventListener(`visibilitychange`,e)}},[e,O,i.si.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.Na.ON_CODE_VALIDATE_ID),p=i.xt(),m=i.Br(o.C),ee=i.Br(o.u),h=i.Br(o.x),te=e?.hasOwnProperty(`type`)?ee:m,g=i.Br(i.i),_=i.Vr(),v=(0,u.useRef)(null),ne=(0,u.useRef)(null),y=(0,u.useRef)(null),b=(0,u.useRef)([]),x=i.vn(),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.Si.UPDATE_EDITOR_POSITION_FROM_EDITOR,data:n.getOffsetAt(e)})}};(0,u.useEffect)(()=>{matchMedia(i.Li).addEventListener(`change`,t=>{let n=window.localStorage.getItem(i.Di.em_color_scheme),r=t.matches?i.ci:i.Ti;e.hasOwnProperty(`type`)?_(n?o.g(n===`dark`?`vs-${n}`:i.Ti):o.g(r===`dark`?`vs-${r}`:i.Ti)):_(n?o.L(n===`dark`?`vs-${n}`:i.Ti):o.L(r===`dark`?`vs-${r}`:i.Ti))})},[_,e]),(0,u.useEffect)(()=>{let t=window.localStorage.getItem(i.Di.em_color_scheme),n=matchMedia(`(prefers-color-scheme: dark)`).matches?i.ci:i.Ti;e?.hasOwnProperty(`type`)?_(t?o.g(t===`dark`?`vs-${t}`:i.Ti):o.g(n===`dark`?`vs-${n}`:i.Ti)):_(t?o.L(t===`dark`?`vs-${t}`:i.Ti):o.L(n===`dark`?`vs-${n}`:i.Ti))},[_,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.si.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.Si.EDITOR_CHANGE_FOCUS,data:!1}),_(o.i(!1))}),e.onDidFocusEditorWidget(()=>{p({operation:i.Si.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.Si.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.Ii.isPlugin&&d.fire(e),_(o.Q(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})})]})}});