@ones-editor/editor 1.1.17-beta.11 → 1.1.17-beta.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -28,7 +28,7 @@ Available method signatures are:
|
|
|
28
28
|
${t}
|
|
29
29
|
\`\`\`
|
|
30
30
|
`:""}function CC(n){if(!window.isSecureContext||n.selection.range.isCollapsed())return!1;const t=Xc(n);Qf(n,t);const e=jf(n,t);Yf(e,t);let r="";if(Z5(n)){const i=n.selection.range.getSelectedBlocks()[0],s=at(i.block);nt(s)&&(r=tT(n,rl(n,t)))}else{const i=[];t.blocks.root.forEach((s,o)=>{i.push(H0(n,s,t,[{containerId:"root",blockIndex:o}]))}),i[i.length-1]=i[i.length-1].trimEnd(),r=i.join(`
|
|
31
|
-
`)}return Tf([{type:"text/plain",data:new Blob([r],{type:"text/plain"})}]),!0}const nM=Object.freeze(Object.defineProperty({__proto__:null,editorHandleEnter:q5,editorHandleDelete:X5,editorHandleBackspace:Y5,editorHandleInsertBr:Q5,editorHandlePastePlainText:J5,isSelectedCodeTextBlock:Z5,getSelectedCodeBlockMarkdown:tT,editorHandleCopyMarkdown:CC},Symbol.toStringTag,{value:"Module"})),nm={ArrowDown:u5,ArrowUp:c5,ArrowLeft:l5,ArrowRight:a5,"Shift+ArrowDown":f5,"Shift+ArrowUp":m5,"Shift+ArrowLeft":d5,"Shift+ArrowRight":h5,"CtrlOrCmd+ArrowLeft":p5,"CtrlOrCmd+ArrowRight":C5,"CtrlOrCmd+Shift+ArrowLeft":E5,"CtrlOrCmd+Shift+ArrowRight":A5,"CtrlOrCmd+ArrowUp":x5,"CtrlOrCmd+ArrowDown":aC,"CtrlOrCmd+Shift+ArrowUp":b5,"CtrlOrCmd+Shift+ArrowDown":cC,"CtrlOrCmd+A":uC,Home:R5,End:w5,"Shift+Home":y5,"Shift+End":k5,PageUp:_5,PageDown:M5,"Shift+PageUp":O5,"Shift+PageDown":N5,"CtrlOrCmd+Z":j_,"CtrlOrCmd+Shift+Z":z_,Enter:q5,Delete:X5,Backspace:Y5,"Shift+Enter":Q5,"CtrlOrCmd+Shift+V":J5,"CtrlOrCmd+Shift+C":CC};function eT(n,t){return n.shortcuts.handleKeyboardEvents(n,t)!==void 0}function nT(n,t,e){if(t.type==="embed"){const s=t.embedData,o=s.src;if(o&&typeof o=="string"){const l=e.get(o);if(l)s.src=l;else{let c="";o.split("|").forEach(h=>{const C=e.get(h);C&&(c+=c?`|${C}`:`${C}`)}),c&&(s.src=c)}}return}const r=t.text;r&&r.forEach(s=>{if(s.attributes&&s.attributes.src&&typeof s.attributes.src=="string"){const o=e.get(s.attributes.src);o&&(s.attributes.src=o)}});const i=t.children;i&&i.forEach(s=>{n.blocks[s].forEach(l=>{nT(n,l,e)})})}function rT(n,t,e){if(e.size===0)return;t.blocks.root.forEach(i=>{const s=n.editorBlocks.getBlockClass(i.type);s.replaceResources?s.replaceResources(i,e):nT(t,i,e)})}async function rM(n,t){let e=t.filter(o=>o.indexOf(":")===-1);const r=[];e.forEach(o=>{const l=o.split("|");r.push(...l)}),e=Array.from(new Set(r)),e=r;const i=await n.doc.addResources(e),s=new Map;if(e.length!==i.length)return s;for(let o=0;o<e.length;o++)s.set(e[o],i[o]);return s}function iM(n,t){var l,c,d,h;const r=t.meta.serverId;if(!r||typeof r!="string")return!1;const i=(c=(l=n.doc).getServerMeta)==null?void 0:c.call(l);if(!i)return!1;const s=/.*(?=\/)/;return((d=(i.serverId||"").match(s))==null?void 0:d[0])===((h=r.match(s))==null?void 0:h[0])}async function EC(n,t){const r=t.meta.resources;if(!r||Object.keys(r).length===0)return;let i=new Map;if(iM(n,t)){const o=Array.from(Object.keys(r));i=await rM(n,o),rT(n,t,i)}const s=new Map;Object.entries(r).forEach(([o,l])=>{i.get(o)===void 0&&o!==l&&s.set(o,l)}),s.size!==0&&rT(n,t,s)}async function sM(n,t,e){await EC(n,t),n.undoManager.runInGroup(()=>{const{start:r,end:i}=n.selection.range,s=n.getBlockById(r.blockId);if(r.blockId===i.blockId&&Se(s)){const o=at(s),l=n.getBlockIndex(s),[c]=n.insertDocAt(o,l+1,t,e);c&&n.selection.selectBlock(c,Ct(n,c))}else{n.clearSelectedContents();const{block:o,offset:l}=jc(n);n.insertDoc(o,l,t,e)}})}const oM=["text/x-ones-editor-doc","image/*","text/office-html","text/html","text/plain","text/markdown","*"];function lM(n){let t;for(const e of oM)if(t=n[e],t)break;return t||null}class aM{constructor(t){m(this,"editor");m(this,"handlers",[]);m(this,"hookExecutionAttempt",(t,e,r)=>{for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleBeforeCopy){const o=s.handleBeforeCopy(this.editor,e,r);if(o===!0)return!0;if(typeof o=="object"&&o!=null)return o}}});m(this,"onPasteText",async(t,e)=>{const r=new DataTransfer;r.setData("text/plain",t);const i=await this.editor.dataConverter.fromData(this.editor,r,e);if(i){const s=[];this.pasteDocs(i,null,s)}});m(this,"onBlur",Ke.default(()=>{const t=this.editor.selection.range;if(!t.isCollapsed()){let e=null;if(ua(t.anchor)){const r=t.anchor.childContainerId,i=mi(this.editor,r);e=a3(this.editor,i)}else e=this.editor.getBlockById(t.anchor.blockId);if(e){let r=t.start;t.isSimple()||(r=ht(e,0,"normal")),this.editor.selection.setSelection(r,void 0,{noScroll:!0})}}this.removeActiveForBlur()},200));m(this,"removeActiveForBlur",Ke.default(()=>{ut(this.editor.rootElement,"active")},200));this.editor=t}onInsertText(t,e){if(!ot(this.editor,this.editor.getFocusedBlock()))return;const{containerId:r,blockIndex:i,offset:s}=jc(this.editor);this.handleBeforeInsertText(r,i,s,e)||(this.defaultInsertText(this.editor,r,i,s,e),this.handleAfterInsertText(r,i,s,e),this.editor.selection.updateLastCaretRect())}onKeyDown(t){if(this.handleBeforeKeyDown(t))return!0;const e=this.defaultHandleKeydown(this.editor,t);return this.handleAfterKeyDown(t)?!0:e}onChanged(t){for(let e=0;e<this.handlers.length;e++){const r=this.handlers[e];r.handleChanged&&r.handleChanged(this.editor,t)}}onRemoteChanged(t){for(let e=0;e<this.handlers.length;e++){const r=this.handlers[e];r.handleRemoteChanged&&r.handleRemoteChanged(this.editor,t)}}onCompositionStart(t){if(!ot(this.editor,this.editor.getFocusedBlock()))return;this.editor.updateCompositionText("",!1);const{containerId:e,blockIndex:r,offset:i}=jc(this.editor);for(let s=0;s<this.handlers.length;s++){const o=this.handlers[s];o.handleCompositionStart&&o.handleCompositionStart(this.editor,e,r,i)}}onUpdateCompositionText(t,e,r){if(!ot(this.editor,this.editor.getFocusedBlock()))return;this.editor.updateCompositionText(e,r),this.editor.selection.caret.update();const{containerId:i,blockIndex:s,offset:o}=jc(this.editor);for(let l=0;l<this.handlers.length;l++){const c=this.handlers[l];c.handleUpdateCompositionText&&c.handleUpdateCompositionText(this.editor,i,s,o,r)}this.editor.selection.updateLastCaretRect()}onCopy(t){Z_(this.editor,t,this.hookExecutionAttempt)}onCopyWithoutEvent(){tM(this.editor,this.hookExecutionAttempt)}onCut(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforeCut&&i.handleBeforeCut(this.editor,t)===!0)return}if(this.onCopy(t),this.editor.selection.range.isCollapsed()){const r=this.editor.selection.focusedBlock;Se(r)&&this.editor.deleteBlock(r)}else q0(this.editor)}onPaste(t){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData)return;const e=this.editor.dataConverter.fromData(this.editor,t.clipboardData),r=Array.from(t.clipboardData.files);e.then(async i=>{i&&this.pasteDocs(i,t,r)})}onFocus(){q(this.editor.rootElement,"active"),this.onBlur.cancel(),this.removeActiveForBlur.cancel()}addHandler(t){this.handlers.push(t),this.handlers=this.handlers.sort((e,r)=>{var o,l;const i=(o=e.order)!=null?o:1;return((l=r.order)!=null?l:1)-i})}removeHandler(t){const e=this.handlers.indexOf(t);e!==-1&&this.handlers.splice(e)}handleBeforeInsertText(t,e,r,i){for(let s=0;s<this.handlers.length;s++){const o=this.handlers[s];if(o.handleBeforeInsertText&&o.handleBeforeInsertText(this.editor,t,e,r,i))return!0}return!1}handleAfterInsertText(t,e,r,i){for(let s=0;s<this.handlers.length;s++){const o=this.handlers[s];if(o.handleAfterInsertText&&o.handleAfterInsertText(this.editor,t,e,r,i))return!0}return!1}handleBeforeKeyDown(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforeKeyDown&&i.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterKeyDown&&i.handleAfterKeyDown(this.editor,t))return!0}return e}handleAfterKeyDown(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforeKeyDown&&i.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterKeyDown&&i.handleAfterKeyDown(this.editor,t))return!0}return e}defaultInsertText(t,e,r,i,s){G1(this.editor,s)}defaultHandleKeydown(t,e){return eT(this.editor,e)?(e.preventDefault(),e.stopPropagation(),!0):!1}async pasteDoc(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforePasteDoc&&await i.handleBeforePasteDoc(this.editor,t))return}const e={blockIdMap:new Map,containerIdMap:new Map,boxIdMap:new Map};await sM(this.editor,t,e);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterPasteDoc&&await i.handleAfterPasteDoc(this.editor,t,e))return}}async pasteDocs(t,e,r){for(let s=0;s<this.handlers.length;s++){const o=this.handlers[s];if(o.handleBeforePaste&&await o.handleBeforePaste(this.editor,e,t,r))return}const i=lM(t);if(!!i){await this.pasteDoc(i);for(let s=0;s<this.handlers.length;s++){const o=this.handlers[s];if(o.handleAfterPaste&&await o.handleAfterPaste(this.editor,e,t))return}}}destroy(){this.handlers.forEach(t=>{var e;(e=t.destroy)==null||e.call(t,this.editor)}),this.handlers=[]}forEach(t){this.handlers.forEach(t)}}function cM(n,t,e){const r=Xo(t,e);return r.remove(),r}D("copy-dom-attributes");const iT=["onabort","onanimationcancel","onanimationend","onanimationiteration","onanimationstart","onauxclick","onblur","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","onformdata","ongotpointercapture","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onlostpointercapture","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onpause","onplay","onplaying","onpointercancel","onpointerdown","onpointerenter","onpointerleave","onpointermove","onpointerout","onpointerover","onpointerup","onprogress","onratechange","onreset","onresize","onscroll","onsecuritypolicyviolation","onseeked","onseeking","onselect","onselectionchange","onselectstart","onslotchange","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","ontouchcancel","ontouchend","ontouchmove","ontouchstart","ontransitioncancel","ontransitionend","ontransitionrun","ontransitionstart","onvolumechange","onwaiting","onwebkitanimationend","onwebkitanimationiteration","onwebkitanimationstart","onwebkittransitionend","onwheel"];function uM(n,t){for(let l=0;l<iT.length;l++){const c=iT[l];t[c]=n[c]}const e=n.attributes,r=t.attributes,i=[],s=[];for(let l=0;l<e.length;l++){const c=e[l],d=r.getNamedItem(c.name);d?d.value!==c.value&&(d.value=c.value,s.push(c)):i.push(c)}const o=[];for(let l=0;l<r.length;l++){const c=r[l];e.getNamedItem(c.name)||o.push(c)}i.forEach(l=>{t.setAttribute(l.name,l.value)}),s.forEach(l=>{t.setAttribute(l.name,l.value)}),o.forEach(l=>{t.removeAttribute(l.name)})}function sT(n){const t=Array.from(n.childNodes).filter(e=>!kv(e));return t.forEach(e=>{e.remove()}),t}function oT(n,t,e){var d;const r=n.getContainerById(t),i=Xo(r,e),s=Jo(i),o=n.doc.getBlockData(t,e),l=le(n,i);if(!((d=l==null?void 0:l.handleUpdateBlock)==null?void 0:d.call(l,n,i,o))){const h=n.editorBlocks.createBlock(s,r,o),C=sT(h);sT(i),C.forEach(A=>{i.appendChild(A)});const E=x0(h);if(E){const A=x0(i);A&&A.remove(),i.appendChild(E)}uM(h,i)}n.editorBlockRenders.updateBlock(n,s,i,o),Kv(n,i,o),n.blockHooks.forEach(h=>{var C;(C=h.update)==null||C.call(h,n,s,r,i,o)}),setTimeout(()=>{n.selection.updateSelection(null)})}const fM=D("transform-selection");function lT(n,t,e,r){const{range:i}=n.selection,{anchor:s,focus:o}=i;if(s.blockId!==t&&o.blockId!==t)return i;p(fM,s.isSimple()&&o.isSimple(),"invalid text pos type");let l=s;if(s.blockId===t){const d=$n.transformCursor(s.offset,e,r);l=ht(t,d,"normal")}let c=o;if(o.blockId===t){const d=$n.transformCursor(o.offset,e,r);c=ht(t,d,"normal")}return mn(n,{anchor:l,focus:c})}const dM=D("handle-block-text-changed");function hM(n,t,e,r,i){const s=n.getContainerById(t),o=Xo(s,e),l=n.doc.getBlockData(t,e);if(p(dM,l.text,"no block text"),vv(n,o).setBlockText(n,o,l.text),!i){const c=lT(n,l.id,r,i);n.selection.setRange(c,{noScroll:!0})}}function mM(n,t){const e=At.default(n);return t.delete.forEach(i=>{delete e[i]}),{...e,...t.insert}}function aT(n,t,e,r){const i=le(n,t);i.handleDeleteBlock&&i.handleDeleteBlock(n,t,e,r),n.emit("blockDeleted",n,t,e,r)}function gM(n,t,e,r){const i=n.getBlockByIndex(t,e);i.querySelectorAll('[data-type="editor-block"]').forEach(s=>{aT(n,s,r,{child:!0})}),aT(n,i,r,{child:!1})}const vi=D("editor-doc");class pM extends Sc{constructor(e,r,i){super();m(this,"localEvents",[]);this.editor=e,this.externalDoc=r,this.externalDoc.registerCallback(this),this.registerLocalEvents(i)}beginBatchUpdate(){return this.externalDoc.beginBatchUpdate()}endBatchUpdate(){return this.externalDoc.endBatchUpdate()}registerLocalEvents(e){this.localEvents.push(e)}toJSON(){return this.externalDoc.toJSON()}getVersionHelper(){var r,i;return(i=(r=this.externalDoc).getVersionHelper)==null?void 0:i.call(r)}getContainerBlocks(e){return this.externalDoc.getContainerBlocks(e)}findContainerBlocks(e){return this.externalDoc.findContainerBlocks(e)}getBlockData(e,r){return this.externalDoc.getBlockData(e,r)}verifyBlockWritable(e,r){const i=this.editor.getBlockByIndex(e,r);p(vi,this.editor.isBlockWritable(i),`block is not writable, ${e}, ${r}`)}localUpdateBlockText(e,r,i,s){p(vi,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(e,r);const o=this.getBlockData(e,r),l=o.text;p(vi,l,`no text, ${e}, ${r}`);const c=lT(this.editor,o.id,i,!0),d=$n.apply(l,i);this.localEvents.forEach(C=>C.onBeforeUpdateBlockText(e,o.id,l,d,c.toDocRange()));const h=this.externalDoc.localUpdateBlockText(e,r,i);return this.editor.selection.setRange(c,s),h}localUpdateBlockData(e,r,i,s){p(vi,!this.editor.readonly,"editor is readonly");const o=this.editor.getBlockByIndex(e,r);if(!this.editor.isBlockWritable(o)){const h=Array.from(i.delete).filter(E=>E!=="comments"),C=Object.keys(i.insert).filter(E=>E!=="comments");(h.length>0||C.length>0)&&p(vi,!1,`block is not writable, comment supported only, ${JSON.stringify(i)}}`)}const l=At.default(this.getBlockData(e,r)),c=At.default(mM(l,i));this.localEvents.forEach(h=>h.onBeforeUpdateBlockData(e,l.id,l,c,s));const d=this.externalDoc.localUpdateBlockData(e,r,i,s);return this.editor.selection.setRange(Zo(this.editor,s)),d}localInsertBlock(e,r,i,s,o){p(vi,!this.editor.readonly,"editor is readonly"),this.localEvents.forEach(c=>c.onBeforeInsertBlock(e,r,i,s));const l=this.externalDoc.localInsertBlock(e,r,i,s);return o!=null&&o.noFocus||this.editor.selection.setRange(Zo(this.editor,s),o),l}localDeleteBlock(e,r,i){p(vi,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(e,r);const s=At.default(this.getBlockData(e,r));this.localEvents.forEach(l=>l.onBeforeDeleteBlock(e,r,s,i));const o=this.externalDoc.localDeleteBlock(e,r,i);return this.editor.selection.setRange(Zo(this.editor,i)),o}localDeleteChildContainers(e){return p(vi,!this.editor.readonly,"editor is readonly"),e.forEach(r=>{const i=At.default(this.getContainerBlocks(r));this.localEvents.forEach(s=>s.onBeforeDeleteChildContainer(r,i))}),this.externalDoc.localDeleteChildContainers(e)}localInsertChildContainers(e){p(vi,!this.editor.readonly,"editor is readonly");const r=At.default(e);r.forEach(i=>{this.localEvents.forEach(s=>s.onBeforeInsertChildContainer(i.containerId,i.blocks))}),this.externalDoc.localInsertChildContainers(r)}onRequestReload(e){vi.debug(`reload doc: ${e}`),this.editor.reload(),this.callbacks.forEach(i=>{var s;return(s=i.onRequestReload)==null?void 0:s.call(i,e)});const r=!1;this.editor.emit("docChanged",this.editor,r)}onUpdateBlockText(e,r,i,s){this.callbacks.forEach(o=>{var l;return(l=o.onUpdateBlockText)==null?void 0:l.call(o,e,r,i,s)}),hM(this.editor,e,r,i,s),this.editor.emit("docChanged",this.editor,s)}onUpdateBlockData(e,r,i,s){this.callbacks.forEach(o=>{var l;return(l=o.onUpdateBlockData)==null?void 0:l.call(o,e,r,i,s)}),oT(this.editor,e,r),this.editor.emit("docChanged",this.editor,s)}onInsertBlock(e,r,i,s){this.callbacks.forEach(l=>{var c;return(c=l.onInsertBlock)==null?void 0:c.call(l,e,r,i,s)});const o=this.editor.getContainerById(e);II(this.editor,o,r,i),this.editor.emit("docChanged",this.editor,s)}onDeleteBlock(e,r,i){gM(this.editor,e,r,i),this.callbacks.forEach(o=>{var l;return(l=o.onDeleteBlock)==null?void 0:l.call(o,e,r,i)});const s=this.editor.getContainerById(e);cM(this.editor,s,r),this.editor.emit("docChanged",this.editor,i)}onInsertChildContainer(e,r,i){this.callbacks.forEach(s=>{var o;return(o=s.onInsertChildContainer)==null?void 0:o.call(s,e,r,i)})}onDeleteChildContainer(e,r){this.callbacks.forEach(i=>{var s;return(s=i.onDeleteChildContainer)==null?void 0:s.call(i,e,r)})}onCustomMessage(e){this.callbacks.forEach(r=>{var i;return(i=r.onCustomMessage)==null?void 0:i.call(r,e)})}onStatusChanged(e){this.callbacks.forEach(r=>{var i;return(i=r.onStatusChanged)==null?void 0:i.call(r,e)})}onError(e){this.callbacks.forEach(r=>{var i;return(i=r.onError)==null?void 0:i.call(r,e)})}onAuthRecover(){this.callbacks.forEach(e=>{var r;return(r=e.onAuthRecover)==null?void 0:r.call(e)})}uploadResource(e,r){return this.externalDoc.uploadResource(e,r)}addResources(e){return this.externalDoc.addResources(e)}buildResourceUrl(e,r){return this.externalDoc.buildResourceUrl(e,r)}request(e,r){return this.externalDoc.request(e,r)}broadcastMessage(e){return this.externalDoc.broadcastMessage(e)}getUser(){return this.externalDoc.getUser()}getRemoteUsers(){return this.externalDoc.getRemoteUsers()}triggerReAuth(){var e,r;return(r=(e=this.externalDoc).triggerReAuth)==null?void 0:r.call(e)}destroy(){this.externalDoc.destroy(),this.clearCallbacks()}getServerMeta(){var e,r,i;return(i=(r=(e=this.externalDoc).getServerMeta)==null?void 0:r.call(e))!=null?i:{}}reset(e){vi.log("reset doc"),this.externalDoc=e,this.externalDoc.registerCallback(this),this.editor.reload()}}function cT(n,t){if(n.length===0){n.push(t);return}const e=n[n.length-1];if(!e.combinable(t)){n.push(t);return}e.combine(t)}const rm=D("undo-action");class Yc{constructor(t,e,r){m(this,"beforeRange");m(this,"afterRange");this.containerId=e,this.beforeRange=t.selection.range.clone().toDocRange(),this.afterRange=r}undo(t){return!1}redo(t){return!1}combinable(t){return p(rm,t,"no other action"),!1}combine(t){p(rm,!1,"no other")}setAfterRange(t){this.afterRange&&rm.warn("after range has already set"),this.afterRange=t}findContainerById(t,e){return!!t.doc.findContainerBlocks(e)}findBlockById(t,e){const r=t.doc.findContainerBlocks(this.containerId);return r?r.some(i=>i.id===e):!1}checkBlockData(t,e){if(Array.isArray(e.children)){const r=t.doc.toJSON();for(let i=0;i<e.children.length;i++){const s=e.children[i];if(!r.blocks[s])return rm.warn(`container (${s}) not found, deleted by others?`),!1}}return!0}}const Qc=D("block-action");class uT extends Yc{constructor(e,r,i,s,o){super(e,r,o);m(this,"blockData");m(this,"blockIndex");this.blockData=At.default(s),this.blockIndex=i}deleteBlock(e,r){if(!this.findContainerById(e,this.containerId))return Qc.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.findBlockById(e,this.blockData.id))return Qc.warn(`block (${this.blockData.id}) not found, deleted by others?`),!1;if(!e.getContainerById(this.containerId))return!1;const s=e.getBlockById(this.blockData.id);if(!s)return!1;try{p(Qc,this.blockIndex===Rt(s),"invalid block index"),G0(e,s,Zo(e,r))}catch(o){Qc.warn(o.message),e.selection.selectBlock(s,0)}return!0}insertBlock(e,r){if(!this.findContainerById(e,this.containerId))return Qc.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.checkBlockData(e,this.blockData))return!1;try{Gc(e,this.containerId,this.blockIndex,At.default(this.blockData),r)}catch(i){Qc.warn(i.message);const s=e.doc.getContainerBlocks(this.containerId),o=Math.min(s.length-1,this.blockIndex),l=e.getBlockByIndex(this.containerId,o);e.selection.selectBlock(l,0)}return!0}}D("insert-block-action");class CM extends uT{undo(t){return this.deleteBlock(t,this.beforeRange)}redo(t){return this.insertBlock(t,this.afterRange)}}class EM extends uT{undo(t){return this.insertBlock(t,this.beforeRange)}redo(t){return this.deleteBlock(t,this.afterRange)}}class AM extends Yc{constructor(e){super(e,pt(e.rootContainer),e.selection.range.toDocRange());m(this,"actions",[])}addAction(e){cT(this.actions,e),this.afterRange=e.afterRange}undo(e){let r=!1;return this.actions.concat().reverse().forEach(i=>{i.undo(e)&&(r=!0)}),r}redo(e){let r=!1;return this.actions.forEach(i=>{i.redo(e)&&(r=!0)}),r}setAfterRange(e){this.afterRange=e;const r=this.actions[this.actions.length-1];!r||r instanceof Yc&&(r.afterRange||r.setAfterRange(e))}}const ll=D("update-block-data-action");class im extends Yc{constructor(e,r,i,s,o,l){super(e,r,l);m(this,"beforeBlockData");m(this,"afterBlockData");m(this,"blockId");this.blockId=i,p(ll,this.blockId===s.id,"invalid block id"),p(ll,this.blockId===o.id,"invalid block id"),this.beforeBlockData=At.default(s),this.afterBlockData=At.default(o),p(ll,this.beforeBlockData.type===this.afterBlockData.type,"invalid block type")}undo(e){if(!e.findBlockById(this.blockId))return ll.warn(`block (${this.blockId}) not found, deleted by others?`),!1;const r=e.getBlockById(this.blockId);if(!r||!this.checkBlockData(e,this.beforeBlockData))return!1;const i=e.getContainerById(this.containerId);return p(ll,i,"no container"),Y0(e,r,im.toAttributes(this.beforeBlockData),this.beforeRange),!0}redo(e){if(!e.findBlockById(this.blockId))return ll.warn(`block (${this.blockId}) not found, deleted by others?`),!1;p(ll,e,"no editor");const r=e.getBlockById(this.blockId);if(!r||!this.checkBlockData(e,this.beforeBlockData))return!1;const i=e.getContainerById(this.containerId);return p(ll,i,"no container"),Y0(e,r,im.toAttributes(this.afterBlockData),this.afterRange),!0}static toAttributes(e){const r=At.default(e);return delete r.id,delete r.type,r}}const pa=D("update-block-text-action");class Jf extends Yc{constructor(e,r,i,s,o,l){super(e,r,l);m(this,"beforeRichTextData");m(this,"afterRichTextData");m(this,"blockId");m(this,"type");this.blockId=i,this.beforeRichTextData=At.default(s),this.afterRichTextData=At.default(o),this.type=Jf.calType(s,o)}static calType(e,r){p(pa,e,"no old data"),p(pa,r,"no new data");const s=$n.diff(e,r),o=new Set;let l=!1;const c=h=>Qb(h)?`cjk_${h}`:Xb(h)?"number":f0(h)?"space":Yb(h)?"letter":"unknown";let d=!1;return s.forEach(h=>{h.insert?h.insert===" "?o.add("insert_letter"):typeof h.insert=="string"&&h.insert.startsWith(" ")&&h.insert.length>1?(l=!0,d=!0,o.add(`insert_${c(h.insert.substr(1))}`)):o.add(`insert_${c(h.insert)}`):h.delete&&(l?l=!1:o.add("delete"))}),{textType:Array.from(o).join("|"),begin:d}}undo(e){if(!this.findContainerById(e,this.containerId))return pa.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.findBlockById(e,this.blockId))return pa.warn(`block (${this.blockId}) not found, deleted by others?`),!1;if(!e.getContainerById(this.containerId))return!1;const i=e.getBlockById(this.blockId);return i?(X0(e,i,this.beforeRichTextData),!0):!1}redo(e){if(!this.findContainerById(e,this.containerId))return pa.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.findBlockById(e,this.blockId))return pa.warn(`block (${this.blockId}) not found, deleted by others?`),!1;if(!e.getContainerById(this.containerId))return!1;const i=e.getBlockById(this.blockId);return i?(X0(e,i,this.afterRichTextData),!0):!1}combinable(e){if(!(e instanceof Jf)||e.type.begin||this.type.textType!==e.type.textType||e.blockId!==this.blockId)return!1;const r=e.beforeRange,i=r.anchor;if(!i.isSimple())return!1;const s=this.afterRange;if(!s)return!1;const o=s.anchor;return!(!o.isSimple()||o.blockId!==r.anchor.blockId||o.offset!==i.offset)}combine(e){p(pa,e instanceof Jf,"invalid action type");const r=e;this.afterRichTextData=r.afterRichTextData,this.afterRange=e.afterRange}}const fT=D("child-container-action");class dT extends Yc{constructor(t,e,r){super(t,e,t.selection.range.toDocRange()),this.blocks=r}deleteChildContainer(t){return this.findContainerById(t,this.containerId)?(t.doc.localDeleteChildContainers([this.containerId]),!0):(fT.warn(`container (${this.containerId}) not found, deleted by others?`),!1)}insertChildContainer(t){return this.findContainerById(t,this.containerId)?(fT.warn(`container (${this.containerId}) already exists`),!1):(t.doc.localInsertChildContainers([{containerId:this.containerId,blocks:At.default(this.blocks)}]),!0)}}class xM extends dT{undo(t){return this.deleteChildContainer(t)}redo(t){return this.insertChildContainer(t)}}class bM extends dT{undo(t){return this.insertChildContainer(t)}redo(t){return this.deleteChildContainer(t)}}const Bi=D("undo");class vM{constructor(t){m(this,"editor");m(this,"actions",[]);m(this,"undoCursor");m(this,"currentGroup",null);m(this,"groupCounter",0);m(this,"undoRedoing",!1);m(this,"handleSelectionChange",t=>{if(this.currentGroup){this.currentGroup.setAfterRange(t.selection.range.toDocRange());return}const e=this.actions[this.actions.length-1];!e||e.afterRange||e.setAfterRange(t.selection.range.toDocRange())});this.editor=t,this.undoCursor=-1,this.editor.addListener("selectionChanged",this.handleSelectionChange)}reset(){this.actions=[],this.undoCursor=-1}prepareSaveUndoState(){this.undoCursor!==-1&&(this.actions.splice(this.undoCursor),this.undoCursor=-1)}addAction(t){this.currentGroup?this.currentGroup.addAction(t):(cT(this.actions,t),setTimeout(()=>{this.editor.input.handleChanged(t)}))}beginGroup(){this.groupCounter===0?(p(Bi,!this.currentGroup,"current group already exists"),this.currentGroup=new AM(this.editor),this.groupCounter=1):(p(Bi,this.currentGroup,"current group not exists"),this.groupCounter+=1)}endGroup(){p(Bi,this.currentGroup,"current group not exists"),p(Bi,this.groupCounter>0,"group counter === 0"),this.groupCounter-=1,this.groupCounter===0&&(this.currentGroup.actions.length===0?Bi.warn("empty undo group, skip it"):(this.actions.push(this.currentGroup),this.editor.input.handleChanged(this.currentGroup)),this.currentGroup=null)}hasGroup(){return this.groupCounter>0}runInGroup(t){this.beginGroup();try{const e=t();return setTimeout(()=>this.editor.selection.caret.update()),e}catch(e){throw Bi.error(`failed to run action: ${e.message}`),e}finally{this.endGroup()}}undo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor>0;){this.undoCursor-=1;const t=this.actions[this.undoCursor];if(t.undo(this.editor)){try{this.editor.selection.setRange(Zo(this.editor,t.beforeRange))}catch(e){Bi.error(`undo: failed to restore caret pos: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}redo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor<this.actions.length;){const t=this.actions[this.undoCursor];if(this.undoCursor+=1,t.redo(this.editor)){try{const e=t.afterRange;e?this.editor.selection.setRange(Zo(this.editor,e)):Bi.warn("no after range")}catch(e){Bi.error(`redo: failed to set caret pos after redo: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}canUndo(){return!(this.actions.length===0||this.undoCursor===0)}canRedo(){return!(this.actions.length===0||this.undoCursor===-1||this.undoCursor===this.actions.length)}lastAction(){var e;const t=this.undoCursor===-1?this.actions.length-1:this.undoCursor-1;return(e=this.actions[t])!=null?e:null}undoTo(t){for(;;){const e=this.lastAction();if(!e||e===t)return!0;if(!this.undo())return!1}}onBeforeUpdateBlockText(t,e,r,i,s){this.undoRedoing||(this.prepareSaveUndoState(),$n.diff(r,i).length!==0&&this.addAction(new Jf(this.editor,t,e,r,i,s)))}onBeforeUpdateBlockData(t,e,r,i,s){if(this.undoRedoing)return;this.prepareSaveUndoState();const o=new im(this.editor,t,e,r,i,s);this.addAction(o)}onBeforeInsertBlock(t,e,r,i){this.undoRedoing||(this.prepareSaveUndoState(),p(Bi,e>=0,"invalid block index"),p(Bi,r,"no block data"),this.addAction(new CM(this.editor,t,e,r,i)))}onBeforeDeleteBlock(t,e,r,i){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new EM(this.editor,t,e,r,i)))}onBeforeInsertChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new xM(this.editor,t,e)))}onBeforeDeleteChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new bM(this.editor,t,e)))}}class BM{async fromData(t,e){const r=e.getData("text/x-ones-editor-doc");if(r)return{"text/x-ones-editor-doc":JSON.parse(r)}}}class TM{constructor(){m(this,"converters",[]);m(this,"converterTypes",["text/plain","text/markdown","text/html","text/x-ones-editor-doc"]);this.addConverter(new BM)}prepareData(t){const e=new DataTransfer;for(let r=0;r<this.converterTypes.length;r++)e.setData(this.converterTypes[r],t.getData(this.converterTypes[r]));return e}async fromData(t,e,r){let i={};const s=this.prepareData(e);for(const o of this.converters){const l=await o.fromData(t,s,r);l&&(i={...i,...l})}return i}addConverter(t){this.converters.push(t)}}function yM(n){n.editorBlocks.registerBlockClass(lr),n.editorBlocks.registerBlockClass(l3),n.editorBoxes.registerBoxClass(AB),n.editorBoxes.registerBoxClass(xB),n.editorBoxes.registerBoxClass(BB),n.editorBoxes.registerBoxClass(TB),n.editorInsertions.registerInsertionClass(yB),n.editorBlockRenders.registerRender(new yv)}function kM(n,t){yM(n),t!=null&&t.blocks&&t.blocks.forEach(e=>n.editorBlocks.registerBlockClass(e)),t!=null&&t.boxes&&t.boxes.forEach(e=>n.editorBoxes.registerBoxClass(e)),t!=null&&t.embeds&&t.embeds.forEach(e=>n.editorEmbeds.registerEmbedClass(e)),t!=null&&t.insertions&&t.insertions.forEach(e=>n.editorInsertions.registerInsertionClass(e)),t!=null&&t.decorators&&t.decorators.forEach(e=>n.editorDecorators.registerDecorator(e)),t!=null&&t.dataConverters&&t.dataConverters.forEach(e=>n.dataConverter.addConverter(e)),t!=null&&t.commandProviders&&t.commandProviders.forEach(e=>n.editorCommandProviders.registerCommandProvider(e)),t!=null&&t.textRenders&&t.textRenders.forEach(e=>n.editorBlockRenders.registerRender(e))}const sm=D("range-commands");function hT(n,t){n.forEach(e=>{e.source=t,e.children&&hT(e.children,t)})}function mT(n,t){n.forEach(e=>{e.group=t,e.children&&mT(e.children,t)})}function gT(n,t,e,r){const i=dt(t);p(sm,i===e.start.blockId,"invalid start range"),p(sm,i===e.end.blockId,"invalid end range");const s=n.editorCommandProviders.getCommandProviders();let o=[];if(s.forEach(l=>{const c=l.getAvailableCommands(n,t,e);hT(c,r),mT(c,l.id),o.push(...c)}),s.forEach(l=>{if(l.filterCommands){const c=l.filterCommands(n,t,e,o);c&&(o=c)}}),Pt(n,t)){if(!ua(e.start))return o;p(sm,!e.start.isSimple(),"invalid start pos"),p(sm,!e.end.isSimple(),"invalid end pos");const l=e.start.childContainerId,c=mi(n,l),h=ye(c)[0];if(h){const C=Ct(n,h),E=mn(n,{anchor:ht(h,0,"home"),focus:ht(h,C,"end")}),A=gT(n,h,E,r);o.push(...A)}}return o}function pT(n,t){const e=n.getEditor(),r=n.getSelectedBlocks(),i=[],s=n.isReverse()?r[0]:r[r.length-1],o=mn(e,{anchor:s.start,focus:s.end});return gT(e,s.block,o,t).forEach(c=>{i.push(c)}),i}function CT(n,t,e,r,i,s){var h;const o=n.editorCommandProviders.getCommandProviders();for(let C=0;C<o.length;C++){const E=o[C];if(E.beforeExecuteCommand&&E.beforeExecuteCommand(n,t,e,r,i))return!1}const l=n.editorCommandProviders.getCommandProvider(r.group),c={};if((h=l.executeCommand)!=null&&h.call(l,n,t,e,r,i,{}))return s[dt(t)]=c,!0;let d=!1;return Pt(n,t)&&Oc(n,t,e.start,e.end).forEach(E=>{ye(E).forEach(v=>{const R=Ct(n,v),S=mn(n,{anchor:ht(v,0,"home"),focus:ht(v,R,"end")});CT(n,v,S,r,i,s)&&(d=!0)})}),o.forEach(C=>{C.afterExecuteCommand&&C.afterExecuteCommand(n,t,e,r,i,s)}),d}function ET(n,t,e){const r=n.getEditor(),i={},s=r.editorCommandProviders.getCommandProvider(t.group);return s.executeRangeCommand&&s.executeRangeCommand(r,n,t,e,i)||(n.getSelectedBlocks().forEach(l=>{const c=mn(r,{anchor:l.start,focus:l.end});CT(r,l.block,c,t,e,i)}),r.focus()),i}const RM=D("command-providers");class AT{constructor(t){m(this,"providers",[]);this.editor=t}registerCommandProvider(t){this.providers.push(t)}getCommandProviders(){return this.providers}getCommandProvider(t){const e=this.providers.find(r=>r.id===t);return p(RM,e,`no command provider, id=${t}`),e}getCommands(t,e){return pT(t,e)}executeCommand(t,e,r){return this.editor.emit("beforeExecCommand",this.editor,e,{source:e.source}),this.editor.undoManager.runInGroup(()=>ET(t,e,r))}getEmptyBlockTextAttributes(t,e){let r={};if(this.providers.forEach(i=>{var o;const s=(o=i.getEmptyBlockTextAttributes)==null?void 0:o.call(i,t,e);s&&(r={...r,...s})}),Object.keys(r).length!==0)return r}}function wM(n,t){const e=at(t),r=pt(e),i=Rt(t);oT(n,r,i)}const xT=D("update-block-text");function SM(n,t,e){const r=n.getBoxById(t.id),i=nt(r);p(xT,i,"no parent block"),p(xT,ot(n,i),"not a text block");const s=n.getBlockText(i),o=fB(s,"id",t.id,t);GB(n,i,o,e)}function LM(n,t){for(const e of n.blockHooks)if(e.writable){const r=e.writable(n,t);if(typeof r=="boolean")return r}return!0}function IM(n){if(n.readonly)return!1;const t=Ji(n);return!!n.isBlockWritable(t.map(e=>e.block))}class DM{constructor(t){this.editor=t}getKey(t){return`${this.editor.id}-${t}`}getItem(t){return window.localStorage.getItem(this.getKey(t))}setItem(t,e){if(!e){this.removeItem(t);return}window.localStorage.setItem(this.getKey(t),e)}removeItem(t){window.localStorage.removeItem(this.getKey(t))}}class _M{constructor(){m(this,"shortcuts",[])}handleKeyboardEvents(t,e){const r=this.shortcuts;for(const i of r){const s=Object.entries(i);for(const[o,l]of s)if(Wi(e,o)){const c=l(t,e);if(c!==void 0)return c}}}}const Xs=D("editor");class MM extends Fe.TypedEmitter{constructor(e,r,i){var s,o,l,c,d,h,C,E,A;super();m(this,"parent");m(this,"rootElement");m(this,"contentElement");m(this,"rootContainerObject");m(this,"rootContainer");m(this,"input");m(this,"selection");m(this,"selectionHandler");m(this,"doc");m(this,"id");m(this,"clientId");m(this,"compositingText","");m(this,"undoManager");m(this,"shortcuts",new _M);m(this,"dataConverter",new TM);m(this,"editorBlocks",new r3(this));m(this,"editorBoxes",new vB(this));m(this,"editorInsertions",new RB(this));m(this,"editorEmbeds",new s3(this));m(this,"editorDecorators",new wB(this));m(this,"editorCommandProviders",new AT(this));m(this,"editorBlockRenders",new bI(this));m(this,"blockHooks",[]);m(this,"domEvents",new __(this));m(this,"customs",new Map);m(this,"options");m(this,"version","");m(this,"inputHandlers",new aM(this));m(this,"settingsProvider");m(this,"_readonly",!1);m(this,"getColor",e=>{const r=this.options.colors;return r.length===0?"#FF1A75":r[e%r.length]});Xs.debug("create editor"),this.setMaxListeners(100),this.options={colors:(s=i==null?void 0:i.colors)!=null?s:["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"],componentsOptions:(l=(o=i==null?void 0:i.components)==null?void 0:o.options)!=null?l:{},scrollContainer:i==null?void 0:i.scrollContainer,enableComments:(c=i==null?void 0:i.enableComments)!=null?c:!0,enableContextMenu:(d=i==null?void 0:i.enableContextMenu)!=null?d:!0},this.settingsProvider=(h=i==null?void 0:i.settingsProvider)!=null?h:new DM(this),kM(this,i==null?void 0:i.components),this.blockHooks.push(...(E=(C=i==null?void 0:i.components)==null?void 0:C.blockHooks)!=null?E:[]),this.id=(A=i==null?void 0:i.id)!=null?A:it(),this.clientId=it(),this.undoManager=new vM(this),this.doc=new pM(this,r,this.undoManager),this.parent=e,this.rootElement=B("div",["editor-root"],this.parent),this.rootElement.setAttribute("data-editor-client-id",this.clientId),this.contentElement=B("div",["editor-content"],this.rootElement),this.rootContainerObject=t3(this),this.rootContainer=this.rootContainerObject.rootContainer,this.input=new Q8(this,this.inputHandlers),this.selection=new K_(this),this.selectionHandler=new H_(this),i!=null&&i.shortcuts&&this.shortcuts.shortcuts.push(...i.shortcuts),Ae.isMobile&&q(this.rootElement,"mobile"),Ae.isSafari&&q(this.rootElement,"safari"),this._readonly&&q(this.rootElement,"readonly"),this.emit("load",this,!1)}get readonly(){return this._readonly}set readonly(e){this._readonly=e,e?q(this.rootElement,"readonly"):ut(this.rootElement,"readonly"),this.emit("readonlyChanged",this)}get scrollContainer(){return this.options.scrollContainer?this.options.scrollContainer:dn(this.rootContainer)}addCustom(e,r){const i=this.customs.get(e);if(i)return i;const s=r(this);return this.customs.set(e,s),s}getCustom(e){const r=this.customs.get(e);return p(Xs,r,`${e} does not exists`),r}replaceCustom(e,r){const i=this.customs.get(e);return i&&i.destroy(),this.customs.set(e,r),r}findCustom(e){return this.customs.get(e)}findCustomByType(e){const r=this.customs.values();for(const i of r)if(i instanceof e)return i;return null}destroyCustom(e){const r=this.customs.get(e);r&&(this.customs.delete(e),r.destroy())}getComponentOptions(e){return this.options.componentsOptions[e]}registerLocalEvents(e){this.doc.registerLocalEvents(e)}reload(){this.rootContainerObject.reload(),this.emit("load",this,!0)}createBlock(e,r,i){return this.editorBlocks.createBlock(e,r,i)}createBox(e,r){return this.editorBoxes.createBox(e,r)}createInsertion(e,r){return this.editorInsertions.createInsertion(e,r)}destroy(){Xs.debug("destroy editor"),this.emit("destroy",this),this.input.destroy(),this.rootContainerObject.destroy(),this.rootElement.remove(),this.doc.destroy(),this.customs.forEach(e=>e.destroy()),this.customs.clear(),this.selection.destroy(),this.domEvents.destroy(),this.removeAllListeners(),this.inputHandlers.destroy()}focus(){this.input.focus()}focusToBlock(e,r){J1(this,e,r)}isWritable(){return IM(this)}isBlockWritable(e){return LM(this,e)}getChildContainerData(e){const r=this.doc.getContainerBlocks(e);return(!r||!Array.isArray(r))&&(p(Xs,r,`no child container data: ${e}, ${JSON.stringify(this.doc)}`),p(Xs,Array.isArray(r),`container data is not an array: ${JSON.stringify(r)}`)),r}createChildContainer(e,r,i){return e3(this,e,r,i)}getFirstBlock(){return this.rootContainer.querySelector("[data-type=editor-block]")}getLastBlock(){const e=Array.from(this.rootContainer.querySelectorAll(":scope [data-type=editor-block]"));return e[e.length-1]}getFocusedBlock(){return this.selection.getFocusedBlock()}findBlockById(e){const r=this.rootContainer.querySelector(`#${e}`);return r&&p(Xs,oa(r),"not an valid block element"),r!=null?r:null}findBoxById(e){const r=this.rootContainer.querySelector(`#${e}`);return r&&p(Xs,b0(r),"not an valid box element"),r!=null?r:null}getBlockById(e){const r=this.findBlockById(e);return p(Xs,r,`no block, id=${e}`),r}getBoxById(e){const r=this.findBoxById(e);return p(Xs,r,`no box, id=${e}`),r}getBlockByIndex(e,r){const i=this.getContainerById(e);return Xo(i,r)}findBlockByIndex(e,r){const i=this.getContainerById(e);return xv(i,r)}getBlockIndex(e){if(typeof e=="string"){const r=this.getBlockById(e);return Rt(r)}return Rt(e)}getContainerById(e){return mi(this,e)}getParentContainer(e){return at(e)}reloadBlock(e){wM(this,e)}contains(e){const r=e instanceof Element?e:e.parentElement;return r?r.closest("div.editor-root")===this.rootElement:!1}insertBlock(e,r,i,s,o){const l={blockId:i.id,offset:0},c={anchor:l,focus:l};return Gc(this,e,r,i,s!=null?s:c,o)}insertEmbed(e,r,i,s,o){const l={id:it(),type:"embed",embedType:i,embedData:s};return this.insertBlock(e,r,l,o)}deleteBlock(e,r){Y1(this,e,r)}mergeTextBlock(e,r){return HB(this,e,r)}breakTextBlock(e,r,i){return Wc(this,e,r,i).newBlock}getTextPosition(){return jc(this)}getBlockString(e,r){const i=this.getBlockText(e);return ke(i,r)}getBlockData(e){return nl(this,e)}getBoxData(e){return CB(this,e)}getBlockText(e){return Qn(this,e)}setBlockText(e,r){GB(this,e,r)}deleteTextFromBlock(e,r,i,s){return q1(this,e,r,i,s)}insertTextToBlock(e,r,i,s){return NB(this,e,r,i,s)}insertBoxToBlock(e,r,i){return PB(this,e,r,i)}pasteDoc(e){return this.inputHandlers.pasteDoc(e)}insertDoc(e,r,i,s){XB(this,e,r,i,s)}insertDocAt(e,r,i,s){return eC(this,e,r,i,s)}deleteChildContainers(e){$B(this,e)}replaceBlockText(e,r){return X0(this,e,r)}updateBlockData(e,r,i){const s={...this.getBlockData(e),...r},{id:o,type:l,...c}=s;return Y0(this,e,c,(i!=null?i:this.selection.range).toDocRange())}updateEmbedData(e,r,i){return WB(this,e,r,i)}updateBoxData(e,r){SM(this,e,r)}getSelectedText(){const e=Xc(this);return rl(this,e)}clearSelectedContents(){q0(this)}insertTextBlock(e,r,i,s){const o=es(e!=null?e:"");return VB(this,o,r,i,s==null?void 0:s.newRange,s==null?void 0:s.insertBlockOptions)}updateCompositionText(e,r){if(e&&!r&&(this.selection.range.isCollapsed()||this.clearSelectedContents()),!e&&!r){W1(this);return}r?(this.compositingText="",Cf()?e||W1(this):G1(this,e)):(this.compositingText=e,FB(this))}}function Zf(n,t,e){return new MM(n,t,e)}function UM(n){const t=(r,i)=>{const s=r.findIndex(l=>l.id===i.id);if(s===-1){r.push(i);return}const o=r[s];if(o.value!==i.value){r.splice(s,1);return}if(!!o.states){if(!i.states){o.states=[];return}o.states=yp.default(o.states,i.states)}},e=[];return n.forEach(r=>{r.forEach(i=>{t(e,i)})}),e}const OM=["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"];class td extends Fe.TypedEmitter{constructor(e){super();m(this,"users",new Map);m(this,"cursors",new Map);m(this,"addingUser",!1);m(this,"colors");this.colors=e&&e.length>0?e:OM}setCursor(e){this.addUser(e.user);const r=this.cursors.get(e.user.userId);if(r&&pf.default(r,e))return;this.cursors.set(e.user.userId,e);const i=new Set([e.range.anchor.blockId,e.range.focus.blockId]),s=new Set(i);r&&new Set([r.range.anchor.blockId,r.range.focus.blockId]).forEach(l=>{i.has(l)||s.add(l)}),this.emit("remote-carets-change",[...s])}addUsers(e){this.addingUser=!0,e.forEach(r=>this.addUser(r)),this.addingUser=!1,this.emit("change",Array.from(this.users.values()))}addUser(e){this.users.set(e.userId,e),this.addingUser||this.emit("change",Array.from(this.users.values()))}findUser(e){var r;return(r=this.users.get(e))!=null?r:null}removeUser(e){this.users.delete(e),this.emit("change",Array.from(this.users.values()));const r=this.cursors.get(e);if(r){const i=new Set(new Set([r==null?void 0:r.range.anchor.blockId,r==null?void 0:r.range.focus.blockId]));this.cursors.delete(e),this.emit("remote-carets-change",[...i])}}updateUsers(e){this.users.forEach(r=>{e.find(i=>i.userId===r.userId)||this.removeUser(r.userId)}),this.users.clear(),this.addingUser=!0;try{e.forEach(r=>{this.addUser(r)})}finally{this.addingUser=!1}setTimeout(()=>{this.emit("change",Array.from(this.users.values()))},300)}getSimpleCursors(e){const r=new Map;return Array.from(this.cursors.values()).filter(i=>i.range.anchor.blockId===e&&O0(i.range)).forEach(i=>{const s=i.range.focus.offset;let o=r.get(s);o||(o=[],r.set(s,o)),o.push(i)}),r}getCursors(e){return Array.from(this.cursors.values()).filter(r=>r.range.anchor.blockId===e||r.range.focus.blockId===e)}onUpdateBlockText(e,r,i){if(!e.text)return;this.getCursors(e.id).forEach(l=>{if(O0(l.range)){const{anchor:c,focus:d}=l.range;c.blockId===e.id&&(c.offset=$n.transformCursor(c.offset,r,i)),d.blockId===e.id&&(d.offset=$n.transformCursor(d.offset,r,i))}})}getFixedUserColor(e,r){let i=0;Array.from(e).forEach(o=>{i+=o.charCodeAt(0)});const s=i%this.colors.length;return this.colors[s]}destroy(){this.removeAllListeners()}}const In=D("local-doc");class AC extends Sc{constructor(e,r){super();m(this,"doc");m(this,"serviceUrl");e?this.doc=e:this.doc={meta:{},comments:{},blocks:{root:[es("")]}},this.serviceUrl=(r==null?void 0:r.serverUrl)||""}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return At.default(this.doc)}getContainerBlocks(e){return this.doc.blocks[e]}findContainerBlocks(e){return this.doc.blocks[e]}getBlockData(e,r){const i=this.getContainerBlocks(e);p(In,i,`no container data: ${e}`);const s=i[r];return p(In,s,`no block data: ${r}`),s}localUpdateBlockText(e,r,i){const s=this.getBlockData(e,r);p(In,s.text,"no text for data");const o=$n.apply(s.text,i);return s.text=o,p(In,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(l=>{var c;return(c=l.onUpdateBlockText)==null?void 0:c.call(l,e,r,i,!0)}),o}localUpdateBlockData(e,r,i){const s=this.getBlockData(e,r);return i.delete.forEach(o=>delete s[o]),Object.entries(i.insert).forEach(([o,l])=>{s[o]=l}),p(In,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var l;return(l=o.onUpdateBlockData)==null?void 0:l.call(o,e,r,i,!0)}),s}localInsertBlock(e,r,i){const s=this.getContainerBlocks(e);return p(In,s,`no container data: ${e}`),p(In,r>=0&&r<=s.length,`invalid block index: ${r}, ${s.length}`),s.splice(r,0,i),p(In,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var l;return(l=o.onInsertBlock)==null?void 0:l.call(o,e,r,i,!0)}),i}localDeleteBlock(e,r){const i=this.getContainerBlocks(e);p(In,i,`no container data: ${e}`),p(In,r>=0&&r<=i.length,`invalid block index: ${r}, ${i.length}`);const s=i[r];return i.splice(r,1),p(In,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var l;return(l=o.onDeleteBlock)==null?void 0:l.call(o,e,r,!0)}),s}localInsertChildContainers(e){e.forEach(({containerId:r,blocks:i})=>{this.doc.blocks[r]=i,p(In,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var o;return(o=s.onInsertChildContainer)==null?void 0:o.call(s,r,i,!0)})})}localDeleteChildContainers(e){In.debug(`delete child containers: ${e}`),e.forEach(r=>{p(In,this.doc.blocks[r],`no child container: ${r}`),delete this.doc.blocks[r]}),e.forEach(r=>{p(In,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var s;return(s=i.onDeleteChildContainer)==null?void 0:s.call(i,r,!0)})})}uploadResource(e,r){p(In,!1,"not implemented")}async addResources(e){return e}buildResourceUrl(e){return e}request(e,r){p(In,!1,"not implemented")}broadcastMessage(e){}getServerMeta(){return{serverId:this.serviceUrl}}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new td}setDoc(e){this.doc=At.default(e),this.callbacks.forEach(r=>{var i;return(i=r.onRequestReload)==null?void 0:i.call(r,"change doc")})}destroy(){this.clearCallbacks()}}class NM{constructor(t){this.cleanup=t}destroy(){var t;(t=this.cleanup)==null||t.call(this)}}function xC(n,t,e){n.addCustom(t,()=>{var s;const r=(s=e())!=null?s:void 0;return new NM(r)})}const bT=D("find-block");function vT(n,t){const e=$r(t);if(!e){if(jr(t))return null;const r=la(t);return p(bT,r,"no parent block"),vT(n,r)}return Pt(n,e)?Nc(n,e,{visibleOnly:!0}):e}function BT(n,t){const e=Hr(t);if(!e){if(jr(t))return null;const r=la(t);return p(bT,r,"no parent block"),BT(n,r)}return Pt(n,e)?d1(n,e,{visibleOnly:!0}):e}const PM=D("remote-cursor");class FM{constructor(){m(this,"remoteUsers",new td)}onCustomMessage(t){const e=t;if(e.type==="onlineUsers"){const r=e;this.handleUpdateUsers(r.users)}else e.type==="caret"?this.handleUpdateCaret(e):PM.debug(`unknown remote message received: ${t}`)}handleUpdateUsers(t){this.remoteUsers.updateUsers(t)}handleUpdateCaret(t){const e=this.remoteUsers.findUser(t.userId);!e||this.remoteUsers.setCursor({oneseditor:"cursor",user:e,range:t.range,time:Date.now()})}destroy(){this.remoteUsers.destroy()}}function KM(n){const{blocks:t,meta:e,comments:r,...i}=n;return{rootBlocks:t,meta:e,comments:r,childBlocks:i}}function VM(n){const{blocks:t,meta:e,comments:r}=n,{root:i,...s}=t;return{blocks:i,meta:e,comments:r,...s}}function Ys(n){const{childBlocks:t,meta:e,comments:r,rootBlocks:i}=KM(At.default(n));return{blocks:{root:i,...t},meta:e,comments:r}}function Qs(n){return n==="root"?"blocks":n}function Jc(n){return n==="blocks"?"root":n}const $M={type:{name:"rich-text",uri:"http://sharejs.org/types/rich-text/v1",create(n){return new Kn.default(n)},apply(n,t){const e=new Kn.default(n),r=new Kn.default(t);return e.compose(r).ops},compose(n,t){const e=new Kn.default(n),r=new Kn.default(t);return e.compose(r).ops},diff(n,t){const e=new Kn.default(n),r=new Kn.default(t);return e.diff(r).ops},transform(n,t,e){const r=new Kn.default(n);return new Kn.default(t).transform(r,e==="left").ops},transformCursor(n,t,e){return t.transformPosition(n,!e)},normalize(n){return n},serialize(n){return n.ops},deserialize(n){return n},transformPresence(n,t,e){if(!n)return null;const r=new Kn.default(t),i=this.transformCursor(n.index,r,e),s=this.transformCursor(n.index+n.length,r,e);return{...n,index:i,length:s-i}}}};var al={},bC=Tp.default.EventEmitter;al.EventEmitter=bC,al.mixin=HM;function HM(n){for(var t in bC.prototype)n.prototype[t]=bC.prototype[t]}var TT=["info","warn","error"];function yT(){var n={};TT.forEach(function(t){n[t]=console[t].bind(console)}),this.setMethods(n)}var jM=yT;yT.prototype.setMethods=function(n){n=n||{};var t=this;TT.forEach(function(e){typeof n[e]=="function"&&(t[e]=n[e])})};var zM=jM,GM=new zM,kT=GM;function Ca(n,t){this.code=n,this.message=t||"",Error.captureStackTrace?Error.captureStackTrace(this,Ca):this.stack=new Error().stack}Ca.prototype=Object.create(Error.prototype),Ca.prototype.constructor=Ca,Ca.prototype.name="ShareDBError",Ca.CODES={ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT:"ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT",ERR_APPLY_SNAPSHOT_NOT_PROVIDED:"ERR_APPLY_SNAPSHOT_NOT_PROVIDED",ERR_FIXUP_IS_ONLY_VALID_ON_APPLY:"ERR_FIXUP_IS_ONLY_VALID_ON_APPLY",ERR_CANNOT_FIXUP_DELETION:"ERR_CANNOT_FIXUP_DELETION",ERR_CLIENT_ID_BADLY_FORMED:"ERR_CLIENT_ID_BADLY_FORMED",ERR_CANNOT_PING_OFFLINE:"ERR_CANNOT_PING_OFFLINE",ERR_CONNECTION_SEQ_INTEGER_OVERFLOW:"ERR_CONNECTION_SEQ_INTEGER_OVERFLOW",ERR_CONNECTION_STATE_TRANSITION_INVALID:"ERR_CONNECTION_STATE_TRANSITION_INVALID",ERR_DATABASE_ADAPTER_NOT_FOUND:"ERR_DATABASE_ADAPTER_NOT_FOUND",ERR_DATABASE_DOES_NOT_SUPPORT_SUBSCRIBE:"ERR_DATABASE_DOES_NOT_SUPPORT_SUBSCRIBE",ERR_DATABASE_METHOD_NOT_IMPLEMENTED:"ERR_DATABASE_METHOD_NOT_IMPLEMENTED",ERR_DEFAULT_TYPE_MISMATCH:"ERR_DEFAULT_TYPE_MISMATCH",ERR_DOC_MISSING_VERSION:"ERR_DOC_MISSING_VERSION",ERR_DOC_ALREADY_CREATED:"ERR_DOC_ALREADY_CREATED",ERR_DOC_DOES_NOT_EXIST:"ERR_DOC_DOES_NOT_EXIST",ERR_DOC_TYPE_NOT_RECOGNIZED:"ERR_DOC_TYPE_NOT_RECOGNIZED",ERR_DOC_WAS_DELETED:"ERR_DOC_WAS_DELETED",ERR_INFLIGHT_OP_MISSING:"ERR_INFLIGHT_OP_MISSING",ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION:"ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION",ERR_MAX_SUBMIT_RETRIES_EXCEEDED:"ERR_MAX_SUBMIT_RETRIES_EXCEEDED",ERR_MESSAGE_BADLY_FORMED:"ERR_MESSAGE_BADLY_FORMED",ERR_MILESTONE_ARGUMENT_INVALID:"ERR_MILESTONE_ARGUMENT_INVALID",ERR_OP_ALREADY_SUBMITTED:"ERR_OP_ALREADY_SUBMITTED",ERR_OP_NOT_ALLOWED_IN_PROJECTION:"ERR_OP_NOT_ALLOWED_IN_PROJECTION",ERR_OP_SUBMIT_REJECTED:"ERR_OP_SUBMIT_REJECTED",ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM:"ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM",ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM:"ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM",ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT:"ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT",ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED:"ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED",ERR_OT_OP_BADLY_FORMED:"ERR_OT_OP_BADLY_FORMED",ERR_OT_OP_NOT_APPLIED:"ERR_OT_OP_NOT_APPLIED",ERR_OT_OP_NOT_PROVIDED:"ERR_OT_OP_NOT_PROVIDED",ERR_PRESENCE_TRANSFORM_FAILED:"ERR_PRESENCE_TRANSFORM_FAILED",ERR_PROTOCOL_VERSION_NOT_SUPPORTED:"ERR_PROTOCOL_VERSION_NOT_SUPPORTED",ERR_QUERY_CHANNEL_MISSING:"ERR_QUERY_CHANNEL_MISSING",ERR_QUERY_EMITTER_LISTENER_NOT_ASSIGNED:"ERR_QUERY_EMITTER_LISTENER_NOT_ASSIGNED",ERR_SNAPSHOT_READ_SILENT_REJECTION:"ERR_SNAPSHOT_READ_SILENT_REJECTION",ERR_SNAPSHOT_READS_REJECTED:"ERR_SNAPSHOT_READS_REJECTED",ERR_SUBMIT_TRANSFORM_OPS_NOT_FOUND:"ERR_SUBMIT_TRANSFORM_OPS_NOT_FOUND",ERR_TYPE_CANNOT_BE_PROJECTED:"ERR_TYPE_CANNOT_BE_PROJECTED",ERR_TYPE_DOES_NOT_SUPPORT_COMPOSE:"ERR_TYPE_DOES_NOT_SUPPORT_COMPOSE",ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE:"ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE",ERR_UNKNOWN_ERROR:"ERR_UNKNOWN_ERROR"};var om=Ca,ed={},RT=WM;function WM(n,t,e,r){var i=function(o,l,c,d){t(c,o,l,"left"),t(d,l,o,"right")},s=n.transformX=function(o,l){e(o),e(l);for(var c=[],d=0;d<l.length;d++){for(var h=l[d],C=[],E=0;E<o.length;){var A=[];if(i(o[E],h,C,A),E++,A.length===1)h=A[0];else if(A.length===0){for(var v=E;v<o.length;v++)r(C,o[v]);h=null;break}else{for(var R=s(o.slice(E),A),S=0;S<R[0].length;S++)r(C,R[0][S]);for(var O=0;O<R[1].length;O++)r(c,R[1][O]);h=null;break}}h!=null&&r(c,h),o=C}return[o,c]};n.transform=function(o,l,c){if(!(c==="left"||c==="right"))throw new Error("type must be 'left' or 'right'");return l.length===0?o:o.length===1&&l.length===1?t([],o[0],l[0],c):c==="left"?s(o,l)[0]:s(l,o)[1]}}var wT={exports:{}},cl=wT.exports={name:"text0",uri:"http://sharejs.org/types/textv0",create:function(n){if(n!=null&&typeof n!="string")throw new Error("Initial data must be a string");return n||""}},vC=function(n,t,e){return n.slice(0,t)+e+n.slice(t)},BC=function(n){if(typeof n.p!="number")throw new Error("component missing position field");if(typeof n.i=="string"==(typeof n.d=="string"))throw new Error("component needs an i or d field");if(n.p<0)throw new Error("position cannot be negative")},lm=function(n){for(var t=0;t<n.length;t++)BC(n[t])};cl.apply=function(n,t){var e;lm(t);for(var r=0;r<t.length;r++){var i=t[r];if(i.i!=null)n=vC(n,i.p,i.i);else{if(e=n.slice(i.p,i.p+i.d.length),i.d!==e)throw new Error("Delete component '"+i.d+"' does not match deleted text '"+e+"'");n=n.slice(0,i.p)+n.slice(i.p+i.d.length)}}return n};var Js=cl._append=function(n,t){if(!(t.i===""||t.d===""))if(n.length===0)n.push(t);else{var e=n[n.length-1];e.i!=null&&t.i!=null&&e.p<=t.p&&t.p<=e.p+e.i.length?n[n.length-1]={i:vC(e.i,t.p-e.p,t.i),p:e.p}:e.d!=null&&t.d!=null&&t.p<=e.p&&e.p<=t.p+t.d.length?n[n.length-1]={d:vC(t.d,e.p-t.p,e.d),p:t.p}:n.push(t)}};cl.compose=function(n,t){lm(n),lm(t);for(var e=n.slice(),r=0;r<t.length;r++)Js(e,t[r]);return e},cl.normalize=function(n){var t=[];(n.i!=null||n.p!=null)&&(n=[n]);for(var e=0;e<n.length;e++){var r=n[e];r.p==null&&(r.p=0),Js(t,r)}return t};var TC=function(n,t,e){return t.i!=null?t.p<n||t.p===n&&e?n+t.i.length:n:n<=t.p?n:n<=t.p+t.d.length?t.p:n-t.d.length};cl.transformCursor=function(n,t,e){for(var r=e==="right",i=0;i<t.length;i++)n=TC(n,t[i],r);return n};var qM=cl._tc=function(n,t,e,r){if(BC(t),BC(e),t.i!=null)Js(n,{i:t.i,p:TC(t.p,e,r==="right")});else if(e.i!=null){var i=t.d;t.p<e.p&&(Js(n,{d:i.slice(0,e.p-t.p),p:t.p}),i=i.slice(e.p-t.p)),i!==""&&Js(n,{d:i,p:t.p+e.i.length})}else if(t.p>=e.p+e.d.length)Js(n,{d:t.d,p:t.p-e.d.length});else if(t.p+t.d.length<=e.p)Js(n,t);else{var s={d:"",p:t.p};t.p<e.p&&(s.d=t.d.slice(0,e.p-t.p)),t.p+t.d.length>e.p+e.d.length&&(s.d+=t.d.slice(e.p+e.d.length-t.p));var o=Math.max(t.p,e.p),l=Math.min(t.p+t.d.length,e.p+e.d.length),c=t.d.slice(o-t.p,l-t.p),d=e.d.slice(o-e.p,l-e.p);if(c!==d)throw new Error("Delete ops delete different text in the same region of the document");s.d!==""&&(s.p=TC(s.p,e),Js(n,s))}return n},XM=function(n){return n.i!=null?{d:n.i,p:n.p}:{i:n.d,p:n.p}};cl.invert=function(n){n=n.slice().reverse();for(var t=0;t<n.length;t++)n[t]=XM(n[t]);return n},RT(cl,qM,lm,Js);var am=function(n){return Object.prototype.toString.call(n)=="[object Array]"},YM=function(n){return!!n&&n.constructor===Object},Ti=function(n){return JSON.parse(JSON.stringify(n))},Ft={name:"json0",uri:"http://sharejs.org/types/JSONv0"},Zs={};Ft.registerSubtype=function(n){Zs[n.name]=n},Ft.create=function(n){return n===void 0?null:Ti(n)},Ft.invertComponent=function(n){var t={p:n.p};return n.t&&Zs[n.t]&&(t.t=n.t,t.o=Zs[n.t].invert(n.o)),n.si!==void 0&&(t.sd=n.si),n.sd!==void 0&&(t.si=n.sd),n.oi!==void 0&&(t.od=n.oi),n.od!==void 0&&(t.oi=n.od),n.li!==void 0&&(t.ld=n.li),n.ld!==void 0&&(t.li=n.ld),n.na!==void 0&&(t.na=-n.na),n.lm!==void 0&&(t.lm=n.p[n.p.length-1],t.p=n.p.slice(0,n.p.length-1).concat([n.lm])),t},Ft.invert=function(n){for(var t=n.slice().reverse(),e=[],r=0;r<t.length;r++)e.push(Ft.invertComponent(t[r]));return e},Ft.checkValidOp=function(n){for(var t=0;t<n.length;t++)if(!am(n[t].p))throw new Error("Missing path")},Ft.checkList=function(n){if(!am(n))throw new Error("Referenced element not a list")},Ft.checkObj=function(n){if(!YM(n))throw new Error("Referenced element not an object (it was "+JSON.stringify(n)+")")};function nd(n){n.t="text0";var t={p:n.p.pop()};n.si!=null&&(t.i=n.si),n.sd!=null&&(t.d=n.sd),n.o=[t]}function rd(n){n.p.push(n.o[0].p),n.o[0].i!=null&&(n.si=n.o[0].i),n.o[0].d!=null&&(n.sd=n.o[0].d),delete n.t,delete n.o}Ft.apply=function(n,t){Ft.checkValidOp(t),t=Ti(t);for(var e={data:n},r=0;r<t.length;r++){var i=t[r];(i.si!=null||i.sd!=null)&&nd(i);for(var s=null,o=e,l="data",c=0;c<i.p.length;c++){var d=i.p[c];if(s=o,o=o[l],l=d,s==null)throw new Error("Path invalid")}if(i.t&&i.o!==void 0&&Zs[i.t])o[l]=Zs[i.t].apply(o[l],i.o);else if(i.na!==void 0){if(typeof o[l]!="number")throw new Error("Referenced element not a number");o[l]+=i.na}else if(i.li!==void 0&&i.ld!==void 0)Ft.checkList(o),o[l]=i.li;else if(i.li!==void 0)Ft.checkList(o),o.splice(l,0,i.li);else if(i.ld!==void 0)Ft.checkList(o),o.splice(l,1);else if(i.lm!==void 0){if(Ft.checkList(o),i.lm!=l){var h=o[l];o.splice(l,1),o.splice(i.lm,0,h)}}else if(i.oi!==void 0)Ft.checkObj(o),o[l]=i.oi;else if(i.od!==void 0)Ft.checkObj(o),delete o[l];else throw new Error("invalid / missing instruction in op")}return e.data},Ft.shatter=function(n){for(var t=[],e=0;e<n.length;e++)t.push([n[e]]);return t},Ft.incrementalApply=function(n,t,e){for(var r=0;r<t.length;r++){var i=[t[r]];n=Ft.apply(n,i),e(i,n)}return n};var QM=Ft.pathMatches=function(n,t,e){if(n.length!=t.length)return!1;for(var r=0;r<n.length;r++)if(n[r]!==t[r]&&(!e||r!==n.length-1))return!1;return!0};Ft.append=function(n,t){if(t=Ti(t),n.length===0){n.push(t);return}var e=n[n.length-1];if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(nd(t),nd(e)),QM(t.p,e.p))if(t.t&&e.t&&t.t===e.t&&Zs[t.t]){if(e.o=Zs[t.t].compose(e.o,t.o),t.si!=null||t.sd!=null){for(var r=t.p,i=0;i<e.o.length-1;i++)t.o=[e.o.pop()],t.p=r.slice(),rd(t),n.push(t);rd(e)}}else e.na!=null&&t.na!=null?n[n.length-1]={p:e.p,na:e.na+t.na}:e.li!==void 0&&t.li===void 0&&t.ld===e.li?e.ld!==void 0?delete e.li:n.pop():e.od!==void 0&&e.oi===void 0&&t.oi!==void 0&&t.od===void 0?e.oi=t.oi:e.oi!==void 0&&t.od!==void 0?t.oi!==void 0?e.oi=t.oi:e.od!==void 0?delete e.oi:n.pop():t.lm!==void 0&&t.p[t.p.length-1]===t.lm||n.push(t);else(t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(rd(t),rd(e)),n.push(t)},Ft.compose=function(n,t){Ft.checkValidOp(n),Ft.checkValidOp(t);for(var e=Ti(n),r=0;r<t.length;r++)Ft.append(e,t[r]);return e},Ft.normalize=function(n){var t=[];n=am(n)?n:[n];for(var e=0;e<n.length;e++){var r=n[e];r.p==null&&(r.p=[]),Ft.append(t,r)}return t},Ft.commonLengthForOps=function(n,t){var e=n.p.length,r=t.p.length;if((n.na!=null||n.t)&&e++,(t.na!=null||t.t)&&r++,e===0)return-1;if(r===0)return null;e--,r--;for(var i=0;i<e;i++){var s=n.p[i];if(i>=r||s!==t.p[i])return null}return e},Ft.canOpAffectPath=function(n,t){return Ft.commonLengthForOps({p:t},n)!=null},Ft.transformComponent=function(n,t,e,r){t=Ti(t);var i=Ft.commonLengthForOps(e,t),s=Ft.commonLengthForOps(t,e),o=t.p.length,l=e.p.length;if((t.na!=null||t.t)&&o++,(e.na!=null||e.t)&&l++,s!=null&&l>o&&t.p[s]==e.p[s]){if(t.ld!==void 0){var c=Ti(e);c.p=c.p.slice(o),t.ld=Ft.apply(Ti(t.ld),[c])}else if(t.od!==void 0){var c=Ti(e);c.p=c.p.slice(o),t.od=Ft.apply(Ti(t.od),[c])}}if(i!=null){var d=o==l,c=e;if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(nd(t),c=Ti(e),nd(c)),c.t&&Zs[c.t]){if(t.t&&t.t===c.t){var h=Zs[t.t].transform(t.o,c.o,r);if(t.si!=null||t.sd!=null)for(var C=t.p,E=0;E<h.length;E++)t.o=[h[E]],t.p=C.slice(),rd(t),Ft.append(n,t);else(!am(h)||h.length>0)&&(t.o=h,Ft.append(n,t));return n}}else if(e.na===void 0){if(e.li!==void 0&&e.ld!==void 0){if(e.p[i]===t.p[i])if(d){if(t.ld!==void 0)if(t.li!==void 0&&r==="left")t.ld=Ti(e.li);else return n}else return n}else if(e.li!==void 0)t.li!==void 0&&t.ld===void 0&&d&&t.p[i]===e.p[i]?r==="right"&&t.p[i]++:e.p[i]<=t.p[i]&&t.p[i]++,t.lm!==void 0&&d&&e.p[i]<=t.lm&&t.lm++;else if(e.ld!==void 0){if(t.lm!==void 0&&d){if(e.p[i]===t.p[i])return n;var C=e.p[i],A=t.p[i],v=t.lm;(C<v||C===v&&A<v)&&t.lm--}if(e.p[i]<t.p[i])t.p[i]--;else if(e.p[i]===t.p[i]){if(l<o)return n;if(t.ld!==void 0)if(t.li!==void 0)delete t.ld;else return n}}else if(e.lm!==void 0)if(t.lm!==void 0&&o===l){var A=t.p[i],v=t.lm,R=e.p[i],S=e.lm;if(R!==S)if(A===R)if(r==="left")t.p[i]=S,A===v&&(t.lm=S);else return n;else A>R&&t.p[i]--,A>S?t.p[i]++:A===S&&R>S&&(t.p[i]++,A===v&&t.lm++),(v>R||v===R&&v>A)&&t.lm--,v>S?t.lm++:v===S&&(S>R&&v>A||S<R&&v<A?r==="right"&&t.lm++:v>A?t.lm++:v===R&&t.lm--)}else if(t.li!==void 0&&t.ld===void 0&&d){var A=e.p[i],v=e.lm;C=t.p[i],C>A&&t.p[i]--,C>v&&t.p[i]++}else{var A=e.p[i],v=e.lm;C=t.p[i],C===A?t.p[i]=v:(C>A&&t.p[i]--,(C>v||C===v&&A>v)&&t.p[i]++)}else if(e.oi!==void 0&&e.od!==void 0){if(t.p[i]===e.p[i])if(t.oi!==void 0&&d){if(r==="right")return n;t.od=e.oi}else return n}else if(e.oi!==void 0){if(t.oi!==void 0&&t.p[i]===e.p[i])if(r==="left")Ft.append(n,{p:t.p,od:e.oi});else return n}else if(e.od!==void 0&&t.p[i]==e.p[i]){if(!d)return n;if(t.oi!==void 0)delete t.od;else return n}}}return Ft.append(n,t),n},RT(Ft,Ft.transformComponent,Ft.checkValidOp,Ft.append);var JM=wT.exports;Ft.registerSubtype(JM);var ZM=Ft,tU={type:ZM};(function(n){n.defaultType=tU.type,n.map={},n.register=function(t){t.name&&(n.map[t.name]=t),t.uri&&(n.map[t.uri]=t)},n.register(n.defaultType)})(ed);var Wr={};(function(n){n.doNothing=t;function t(){}n.hasKeys=function(e){for(var r in e)return!0;return!1},n.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e},n.isValidVersion=function(e){return e===null?!0:n.isInteger(e)&&e>=0},n.isValidTimestamp=function(e){return n.isValidVersion(e)},n.MAX_SAFE_INTEGER=9007199254740991,n.dig=function(){for(var e=arguments[0],r=1;r<arguments.length;r++){var i=arguments[r];e=e[i]||(r===arguments.length-1?void 0:{})}return e},n.digOrCreate=function(){for(var e=arguments[0],r=arguments[arguments.length-1],i=1;i<arguments.length-1;i++){var s=arguments[i];e=e[s]||(e[s]=i===arguments.length-2?r():{})}return e},n.digAndRemove=function(){for(var e=arguments[0],r=[e],i=1;i<arguments.length-1;i++){var s=arguments[i];if(!e.hasOwnProperty(s))break;e=e[s],r.push(e)}for(var i=r.length-1;i>=0;i--){var o=r[i],s=arguments[i+1],l=o[s];(i===r.length-1||!n.hasKeys(l))&&delete o[s]}},n.supportsPresence=function(e){return e&&typeof e.transformPresence=="function"},n.callEach=function(e,r){var i=!1;return e.forEach(function(s){s&&(s(r),i=!0)}),i},n.truthy=function(e){return!!e},n.nextTick=function(e){if(typeof process<"u"&&process.nextTick)return process.nextTick.apply(null,arguments);for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];setTimeout(function(){e.apply(null,r)})},n.clone=function(e){return e===void 0?void 0:JSON.parse(JSON.stringify(e))}})(Wr);var ST=Array.isArray,LT=Object.keys,eU=Object.prototype.hasOwnProperty,nU=function n(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var r=ST(t),i=ST(e),s,o,l;if(r&&i){if(o=t.length,o!=e.length)return!1;for(s=o;s--!==0;)if(!n(t[s],e[s]))return!1;return!0}if(r!=i)return!1;var c=t instanceof Date,d=e instanceof Date;if(c!=d)return!1;if(c&&d)return t.getTime()==e.getTime();var h=t instanceof RegExp,C=e instanceof RegExp;if(h!=C)return!1;if(h&&C)return t.toString()==e.toString();var E=LT(t);if(o=E.length,o!==LT(e).length)return!1;for(s=o;s--!==0;)if(!eU.call(e,E[s]))return!1;for(s=o;s--!==0;)if(l=E[s],!n(t[l],e[l]))return!1;return!0}return t!==t&&e!==e},ul={};ul.ACTIONS={initLegacy:"init",handshake:"hs",queryFetch:"qf",querySubscribe:"qs",queryUnsubscribe:"qu",queryUpdate:"q",bulkFetch:"bf",bulkSubscribe:"bs",bulkUnsubscribe:"bu",fetch:"f",fixup:"fixup",subscribe:"s",unsubscribe:"u",op:"op",snapshotFetch:"nf",snapshotFetchByTimestamp:"nt",pingPong:"pp",presence:"p",presenceSubscribe:"ps",presenceUnsubscribe:"pu",presenceRequest:"pr"};var IT=al,rU=kT,Tr=om,cm=ed,yi=Wr,iU=yi.clone,sU=nU,yC=ul.ACTIONS,ar=Tr.CODES,oU=Xt;function Xt(n,t,e){IT.EventEmitter.call(this),this.connection=n,this.collection=t,this.id=e,this.version=null,this.type=null,this.data=void 0,this.inflightFetch=[],this.inflightSubscribe=null,this.pendingFetch=[],this.pendingSubscribe=[],this.subscribed=!1,this.wantSubscribe=!1,this._wantsDestroy=!1,this.inflightOp=null,this.pendingOps=[],this.type=null,this.applyStack=null,this.preventCompose=!1,this.submitSource=!1,this.paused=!1,this._dataStateVersion=0}IT.mixin(Xt),Xt.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this;t.whenNothingPending(function(){t.wantSubscribe?t.unsubscribe(function(e){if(e)return n?n(e):t.emit("error",e);t.connection._destroyDoc(t),n&&n()}):(t.connection._destroyDoc(t),n&&n())})},Xt.prototype._setType=function(n){if(typeof n=="string"&&(n=cm.map[n]),n)this.type=n;else if(n===null)this.type=n,this._setData(void 0);else{var t=new Tr(ar.ERR_DOC_TYPE_NOT_RECOGNIZED,"Missing type "+n);return this.emit("error",t)}},Xt.prototype._setData=function(n){this.data=n,this._dataStateVersion++},Xt.prototype.ingestSnapshot=function(n,t){if(!n)return t&&t();if(typeof n.v!="number"){var e=new Tr(ar.ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION,"Missing version in ingested snapshot. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}if(this.type||this.hasWritePending()){if(this.version==null){if(this.hasWritePending())return t&&this.once("no write pending",t);var e=new Tr(ar.ERR_DOC_MISSING_VERSION,"Cannot ingest snapshot in doc with null version. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}return n.v>this.version?this.fetch(t):t&&t()}if(this.version>n.v)return t&&t();this.version=n.v;var r=n.type===void 0?cm.defaultType:n.type;this._setType(r),this._setData(this.type&&this.type.deserialize?this.type.deserialize(n.data):n.data),this.emit("load"),t&&t()},Xt.prototype.whenNothingPending=function(n){var t=this;yi.nextTick(function(){if(t.hasPending()){t.once("nothing pending",n);return}n()})},Xt.prototype.hasPending=function(){return!!(this.inflightOp||this.pendingOps.length||this.inflightFetch.length||this.inflightSubscribe||this.pendingFetch.length||this.pendingSubscribe.length)},Xt.prototype.hasWritePending=function(){return!!(this.inflightOp||this.pendingOps.length)},Xt.prototype._emitNothingPending=function(){this.hasWritePending()||(this.emit("no write pending"),!this.hasPending()&&this.emit("nothing pending"))},Xt.prototype._emitResponseError=function(n,t){if(n&&n.code===ar.ERR_SNAPSHOT_READ_SILENT_REJECTION){this.wantSubscribe=!1,t&&t(),this._emitNothingPending();return}if(t){t(n),this._emitNothingPending();return}this._emitNothingPending(),this.emit("error",n)},Xt.prototype._handleFetch=function(n,t){var e=this.pendingFetch;this.pendingFetch=[];var r=this.inflightFetch.shift();if(r&&e.push(r),e.length&&(r=function(i){yi.callEach(e,i)}),n)return this._emitResponseError(n,r);this.ingestSnapshot(t,r),this._emitNothingPending()},Xt.prototype._handleSubscribe=function(n,t){var e=this.inflightSubscribe;this.inflightSubscribe=null;var r=this.pendingFetch;this.pendingFetch=[],e.callback&&r.push(e.callback);var i;if(r.length&&(i=function(s){yi.callEach(r,s)}),n)return this._emitResponseError(n,i);this.subscribed=e.wantSubscribe,this.subscribed?this.ingestSnapshot(t,i):i&&i(),this._emitNothingPending(),this._flushSubscribe()},Xt.prototype._handleOp=function(n,t){if(n)return this.inflightOp?(n.code===ar.ERR_OP_SUBMIT_REJECTED&&(n=null),this._rollback(n)):this.emit("error",n);if(this.inflightOp&&t.src===this.inflightOp.src&&t.seq===this.inflightOp.seq){this._opAcknowledged(t);return}if(this.version==null||t.v>this.version){this.fetch();return}if(!(t.v<this.version)){if(this.inflightOp){var e=id(this.inflightOp,t);if(e)return this._hardRollback(e)}for(var r=0;r<this.pendingOps.length;r++){var e=id(this.pendingOps[r],t);if(e)return this._hardRollback(e)}this.version++;try{this._otApply(t,!1)}catch(i){return this._hardRollback(i)}}},Xt.prototype._onConnectionStateChanged=function(){this.connection.canSend?(this.flush(),this._resubscribe()):(this.inflightOp&&(this.pendingOps.unshift(this.inflightOp),this.inflightOp=null),this.subscribed=!1,this.inflightSubscribe&&(this.inflightSubscribe.wantSubscribe?(this.pendingSubscribe.unshift(this.inflightSubscribe),this.inflightSubscribe=null):this._handleSubscribe()),this.inflightFetch.length&&(this.pendingFetch=this.pendingFetch.concat(this.inflightFetch),this.inflightFetch.length=0))},Xt.prototype._resubscribe=function(){if(!this.pendingSubscribe.length&&this.wantSubscribe)return this.subscribe();var n=this.pendingSubscribe.some(function(t){return t.wantSubscribe});!n&&this.pendingFetch.length&&this.fetch(),this._flushSubscribe()},Xt.prototype.fetch=function(n){if(this.connection.canSend){var t=this.connection.sendFetch(this);lU(this.inflightFetch,t,n);return}this.pendingFetch.push(n)},Xt.prototype.subscribe=function(n){var t=!0;this._queueSubscribe(t,n)},Xt.prototype.unsubscribe=function(n){var t=!1;this._queueSubscribe(t,n)},Xt.prototype._queueSubscribe=function(n,t){var e=this.pendingSubscribe[this.pendingSubscribe.length-1]||this.inflightSubscribe,r=e&&e.wantSubscribe===n;if(r){e.callback=aU([e.callback,t]);return}this.pendingSubscribe.push({wantSubscribe:!!n,callback:t}),this._flushSubscribe()},Xt.prototype._flushSubscribe=function(){if(!(this.inflightSubscribe||!this.pendingSubscribe.length)){if(this.connection.canSend){this.inflightSubscribe=this.pendingSubscribe.shift(),this.wantSubscribe=this.inflightSubscribe.wantSubscribe,this.wantSubscribe?this.connection.sendSubscribe(this):(this.subscribed=!1,this.connection.sendUnsubscribe(this));return}if(!this.pendingSubscribe[0].wantSubscribe){this.inflightSubscribe=this.pendingSubscribe.shift();var n=this;yi.nextTick(function(){n._handleSubscribe()})}}};function lU(n,t,e){if(t){var r=n.pop();n.push(function(i){r&&r(i),e&&e(i)})}else n.push(e)}function aU(n){return n=n.filter(yi.truthy),n.length?function(t){yi.callEach(n,t)}:null}Xt.prototype.flush=function(){!this.connection.canSend||this.inflightOp||!this.paused&&this.pendingOps.length&&this._sendOp()};function cU(n){delete n.op,delete n.create,delete n.del}function id(n,t){if(n.del)return cU(t);if(t.del)return new Tr(ar.ERR_DOC_WAS_DELETED,"Document was deleted");if(t.create)return new Tr(ar.ERR_DOC_ALREADY_CREATED,"Document already created");if("op"in t){if(n.create)return new Tr(ar.ERR_DOC_ALREADY_CREATED,"Document already created");if(n.type.transformX){var e=n.type.transformX(n.op,t.op);n.op=e[0],t.op=e[1]}else{var r=n.type.transform(n.op,t.op,"left"),i=n.type.transform(t.op,n.op,"right");n.op=r,t.op=i}}}Xt.prototype._otApply=function(n,t){if("op"in n){if(!this.type)throw new Tr(ar.ERR_DOC_DOES_NOT_EXIST,"Cannot apply op to uncreated document. "+this.collection+"."+this.id);if(this.emit("before op batch",n.op,t),!t&&this.type===cm.defaultType&&n.op.length>1){this.applyStack||(this.applyStack=[]);for(var e=this.applyStack.length,r=0;r<n.op.length;r++){var i=n.op[r],s={op:[i]};this.emit("before op",s.op,t,n.src);for(var o=e;o<this.applyStack.length;o++){var l=id(this.applyStack[o],s);if(l)return this._hardRollback(l)}this._setData(this.type.apply(this.data,s.op)),this.emit("op",s.op,t,n.src)}this.emit("op batch",n.op,t),this._popApplyStack(e);return}this.emit("before op",n.op,t,n.src),this._setData(this.type.apply(this.data,n.op)),this.emit("op",n.op,t,n.src),this.emit("op batch",n.op,t);return}if(n.create){this._setType(n.create.type),this.type.deserialize?this.type.createDeserialized?this._setData(this.type.createDeserialized(n.create.data)):this._setData(this.type.deserialize(this.type.create(n.create.data))):this._setData(this.type.create(n.create.data)),this.emit("create",t);return}if(n.del){var c=this.data;this._setType(null),this.emit("del",c,t);return}},Xt.prototype._sendOp=function(){if(!!this.connection.canSend){var n=this.connection.id;this.inflightOp||(this.inflightOp=this.pendingOps.shift());var t=this.inflightOp;if(!t){var e=new Tr(ar.ERR_INFLIGHT_OP_MISSING,"No op to send on call to _sendOp");return this.emit("error",e)}if(t.sentAt=Date.now(),t.retries=t.retries==null?0:t.retries+1,t.seq==null){if(this.connection.seq>=yi.MAX_SAFE_INTEGER)return this.emit("error",new Tr(ar.ERR_CONNECTION_SEQ_INTEGER_OVERFLOW,"Connection seq has exceeded the max safe integer, maybe from being open for too long"));t.seq=this.connection.seq++}this.connection.sendOp(this,t),t.src==null&&(t.src=n)}},Xt.prototype._submit=function(n,t,e){if(t||(t=!0),"op"in n){if(!this.type){var r=new Tr(ar.ERR_DOC_DOES_NOT_EXIST,"Cannot submit op. Document has not been created. "+this.collection+"."+this.id);return e?e(r):this.emit("error",r)}this.type.normalize&&(n.op=this.type.normalize(n.op))}try{this._pushOp(n,t,e),this._otApply(n,t)}catch(s){return this._hardRollback(s)}var i=this;yi.nextTick(function(){i.flush()})},Xt.prototype._pushOp=function(n,t,e){if(n.source=t,this.applyStack)this.applyStack.push(n);else{var r=this._tryCompose(n);if(r){r.callbacks.push(e);return}}n.type=this.type,n.callbacks=[e],this.pendingOps.push(n)},Xt.prototype._popApplyStack=function(n){if(n>0){this.applyStack.length=n;return}var t=this.applyStack[0];if(this.applyStack=null,!!t){var e=this.pendingOps.indexOf(t);if(e!==-1)for(var r=this.pendingOps.splice(e),e=0;e<r.length;e++){var t=r[e],i=this._tryCompose(t);i?i.callbacks=i.callbacks.concat(t.callbacks):this.pendingOps.push(t)}}},Xt.prototype._tryCompose=function(n){if(!this.preventCompose){var t=this.pendingOps[this.pendingOps.length-1];if(!(!t||t.sentAt)&&!(this.submitSource&&!sU(n.source,t.source))){if(t.create&&"op"in n)return t.create.data=this.type.apply(t.create.data,n.op),t;if("op"in t&&"op"in n&&this.type.compose)return t.op=this.type.compose(t.op,n.op),t}}},Xt.prototype.submitOp=function(n,t,e){typeof t=="function"&&(e=t,t=null);var r={op:n},i=t&&t.source;this._submit(r,i,e)},Xt.prototype.create=function(n,t,e,r){if(typeof t=="function"?(r=t,e=null,t=null):typeof e=="function"&&(r=e,e=null),t||(t=cm.defaultType.uri),this.type){var i=new Tr(ar.ERR_DOC_ALREADY_CREATED,"Document already exists");return r?r(i):this.emit("error",i)}var s={create:{type:t,data:n}},o=e&&e.source;this._submit(s,o,r)},Xt.prototype.del=function(n,t){if(typeof n=="function"&&(t=n,n=null),!this.type){var e=new Tr(ar.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");return t?t(e):this.emit("error",e)}var r={del:!0},i=n&&n.source;this._submit(r,i,t)},Xt.prototype.pause=function(){this.paused=!0},Xt.prototype.resume=function(){this.paused=!1,this.flush()},Xt.prototype.toSnapshot=function(){return{v:this.version,data:iU(this.data),type:this.type.uri}},Xt.prototype._opAcknowledged=function(n){if(this.inflightOp.create)this.version=n.v;else if(n.v!==this.version)return rU.warn("Invalid version from server. Expected: "+this.version+" Received: "+n.v,n),this.fetch();if(n[yC.fixup])for(var t=0;t<n[yC.fixup].length;t++){for(var e=n[yC.fixup][t],r=0;r<this.pendingOps.length;r++){var i=id(this.pendingOps[t],e);if(i)return this._hardRollback(i)}try{this._otApply(e,!1)}catch(s){return this._hardRollback(s)}}this.version++,this._clearInflightOp()},Xt.prototype._rollback=function(n){var t=this.inflightOp;if("op"in t&&t.type.invert){try{t.op=t.type.invert(t.op)}catch{return this._hardRollback(n)}for(var e=0;e<this.pendingOps.length;e++){var r=id(this.pendingOps[e],t);if(r)return this._hardRollback(r)}try{this._otApply(t,!1)}catch(i){return this._hardRollback(i)}this._clearInflightOp(n);return}this._hardRollback(n)},Xt.prototype._hardRollback=function(n){var t=[];this.inflightOp&&t.push(this.inflightOp),t=t.concat(this.pendingOps),this._setType(null),this.version=null,this.inflightOp=null,this.pendingOps=[];var e=this;this.fetch(function(){for(var r=!!t.length,i=0;i<t.length;i++)r=yi.callEach(t[i].callbacks,n)&&r;if(n&&!r)return e.emit("error",n)})},Xt.prototype._clearInflightOp=function(n){var t=this.inflightOp;this.inflightOp=null;var e=yi.callEach(t.callbacks,n);if(this.flush(),this._emitNothingPending(),n&&!e)return this.emit("error",n)};var DT=al,_T=ul.ACTIONS,uU=Wr,fU=cr;function cr(n,t,e,r,i,s,o){DT.EventEmitter.call(this),this.action=n,this.connection=t,this.id=e,this.collection=r,this.query=i,this.results=null,s&&s.results&&(this.results=s.results,delete s.results),this.extra=void 0,this.options=s,this.callback=o,this.ready=!1,this.sent=!1}DT.mixin(cr),cr.prototype.hasPending=function(){return!this.ready},cr.prototype.send=function(){if(!!this.connection.canSend){var n={a:this.action,id:this.id,c:this.collection,q:this.query};if(this.options&&(n.o=this.options),this.results){for(var t=[],e=0;e<this.results.length;e++){var r=this.results[e];t.push([r.id,r.version])}n.r=t}this.connection.send(n),this.sent=!0}},cr.prototype.destroy=function(n){this.connection.canSend&&this.action===_T.querySubscribe&&this.connection.send({a:_T.queryUnsubscribe,id:this.id}),this.connection._destroyQuery(this),n&&uU.nextTick(n)},cr.prototype._onConnectionStateChanged=function(){this.connection.canSend&&!this.sent?this.send():this.sent=!1},cr.prototype._handleFetch=function(n,t,e){this.connection._destroyQuery(this),this._handleResponse(n,t,e)},cr.prototype._handleSubscribe=function(n,t,e){this._handleResponse(n,t,e)},cr.prototype._handleResponse=function(n,t,e){var r=this.callback;if(this.callback=null,n)return this._finishResponse(n,r);if(!t)return this._finishResponse(null,r);var i=this,s=1,o=function(h){if(h)return i._finishResponse(h,r);--s||i._finishResponse(null,r)};if(Array.isArray(t))s+=t.length,this.results=this._ingestSnapshots(t,o),this.extra=e;else for(var l in t){s++;var c=t[l],d=this.connection.get(c.c||this.collection,l);d.ingestSnapshot(c,o)}o()},cr.prototype._ingestSnapshots=function(n,t){for(var e=[],r=0;r<n.length;r++){var i=n[r],s=this.connection.get(i.c||this.collection,i.d);s.ingestSnapshot(i,t),e.push(s)}return e},cr.prototype._finishResponse=function(n,t){if(this.emit("ready"),this.ready=!0,n)return this.connection._destroyQuery(this),t?t(n):this.emit("error",n);t&&t(null,this.results,this.extra)},cr.prototype._handleError=function(n){this.emit("error",n)},cr.prototype._handleDiff=function(n){for(var t=0;t<n.length;t++){var e=n[t];e.type==="insert"&&(e.values=this._ingestSnapshots(e.values))}for(var t=0;t<n.length;t++){var e=n[t];switch(e.type){case"insert":var r=e.values;Array.prototype.splice.apply(this.results,[e.index,0].concat(r)),this.emit("insert",r,e.index);break;case"remove":var s=e.howMany||1,i=this.results.splice(e.index,s);this.emit("remove",i,e.index);break;case"move":var s=e.howMany||1,o=this.results.splice(e.from,s);Array.prototype.splice.apply(this.results,[e.to,0].concat(o)),this.emit("move",o,e.from,e.to);break}}this.emit("changed",this.results)},cr.prototype._handleExtra=function(n){this.extra=n,this.emit("extra",n)};var MT=al,dU=ul.ACTIONS,hU=Wr,UT=rs;function rs(n,t){if(MT.EventEmitter.call(this),!t||typeof t!="string")throw new Error("LocalPresence presenceId must be a string");this.presence=n,this.presenceId=t,this.connection=n.connection,this.presenceVersion=0,this.value=null,this._pendingMessages=[],this._callbacksByPresenceVersion={}}MT.mixin(rs),rs.prototype.submit=function(n,t){this.value=n,this.send(t)},rs.prototype.send=function(n){var t=this._message();this._pendingMessages.push(t),this._callbacksByPresenceVersion[t.pv]=n,this._sendPending()},rs.prototype.destroy=function(n){var t=this;this.submit(null,function(e){if(e)return t._callbackOrEmit(e,n);delete t.presence.localPresences[t.presenceId],n&&n()})},rs.prototype._sendPending=function(){if(!!this.connection.canSend){var n=this;this._pendingMessages.forEach(function(t){n.connection.send(t)}),this._pendingMessages=[]}},rs.prototype._ack=function(n,t){var e=this._getCallback(t);this._callbackOrEmit(n,e)},rs.prototype._message=function(){return{a:dU.presence,ch:this.presence.channel,id:this.presenceId,p:this.value,pv:this.presenceVersion++}},rs.prototype._getCallback=function(n){var t=this._callbacksByPresenceVersion[n];return delete this._callbacksByPresenceVersion[n],t},rs.prototype._callbackOrEmit=function(n,t){if(t)return hU.nextTick(t,n);n&&this.emit("error",n)};var mU=Wr,OT=kC;function kC(n,t){this.presence=n,this.presenceId=t,this.connection=this.presence.connection,this.value=null,this.presenceVersion=0}kC.prototype.receiveUpdate=function(n){n.pv<this.presenceVersion||(this.value=n.p,this.presenceVersion=n.pv,this.presence._updateRemotePresence(this))},kC.prototype.destroy=function(n){delete this.presence._remotePresenceInstances[this.presenceId],delete this.presence.remotePresences[this.presenceId],n&&mU.nextTick(n)};var RC={exports:{}};(function(n,t){(function(e,r){r(t)})(vn,function(e){function r(y,I){I=I|0;for(var U=Math.max(y.length-I,0),F=Array(U),z=0;z<U;z++)F[z]=y[I+z];return F}var i=function(y){var I=r(arguments,1);return function(){var U=r(arguments);return y.apply(null,I.concat(U))}},s=function(y){return function(){var I=r(arguments),U=I.pop();y.call(this,I,U)}};function o(y){var I=typeof y;return y!=null&&(I=="object"||I=="function")}var l=typeof setImmediate=="function"&&setImmediate,c=typeof process=="object"&&typeof process.nextTick=="function";function d(y){setTimeout(y,0)}function h(y){return function(I){var U=r(arguments,1);y(function(){I.apply(null,U)})}}var C;l?C=setImmediate:c?C=process.nextTick:C=d;var E=h(C);function A(y){return s(function(I,U){var F;try{F=y.apply(this,I)}catch(z){return U(z)}o(F)&&typeof F.then=="function"?F.then(function(z){v(U,null,z)},function(z){v(U,z.message?z:new Error(z))}):U(null,F)})}function v(y,I,U){try{y(I,U)}catch(F){E(R,F)}}function R(y){throw y}var S=typeof Symbol=="function";function O(y){return S&&y[Symbol.toStringTag]==="AsyncFunction"}function M(y){return O(y)?A(y):y}function V(y){return function(I){var U=r(arguments,1),F=s(function(z,j){var Z=this;return y(I,function(rt,mt){M(rt).apply(Z,z.concat(mt))},j)});return U.length?F.apply(this,U):F}}var J=typeof vn=="object"&&vn&&vn.Object===Object&&vn,Q=typeof self=="object"&&self&&self.Object===Object&&self,X=J||Q||Function("return this")(),ct=X.Symbol,xt=Object.prototype,bt=xt.hasOwnProperty,wt=xt.toString,yt=ct?ct.toStringTag:void 0;function Yt(y){var I=bt.call(y,yt),U=y[yt];try{y[yt]=void 0;var F=!0}catch{}var z=wt.call(y);return F&&(I?y[yt]=U:delete y[yt]),z}var Ve=Object.prototype,Ce=Ve.toString;function Gn(y){return Ce.call(y)}var Jr="[object Null]",Mn="[object Undefined]",Bn=ct?ct.toStringTag:void 0;function Zr(y){return y==null?y===void 0?Mn:Jr:Bn&&Bn in Object(y)?Yt(y):Gn(y)}var Oi="[object AsyncFunction]",fr="[object Function]",lh="[object GeneratorFunction]",ah="[object Proxy]";function ch(y){if(!o(y))return!1;var I=Zr(y);return I==fr||I==lh||I==Oi||I==ah}var ps=9007199254740991;function so(y){return typeof y=="number"&&y>-1&&y%1==0&&y<=ps}function oo(y){return y!=null&&so(y.length)&&!ch(y)}var ee={};function zt(){}function ti(y){return function(){if(y!==null){var I=y;y=null,I.apply(this,arguments)}}}var Un=typeof Symbol=="function"&&Symbol.iterator,lo=function(y){return Un&&y[Un]&&y[Un]()};function Ua(y,I){for(var U=-1,F=Array(y);++U<y;)F[U]=I(U);return F}function Tn(y){return y!=null&&typeof y=="object"}var Cs="[object Arguments]";function Oa(y){return Tn(y)&&Zr(y)==Cs}var tr=Object.prototype,Nu=tr.hasOwnProperty,uh=tr.propertyIsEnumerable,ao=Oa(function(){return arguments}())?Oa:function(y){return Tn(y)&&Nu.call(y,"callee")&&!uh.call(y,"callee")},_e=Array.isArray;function co(){return!1}var uo=typeof e=="object"&&e&&!e.nodeType&&e,Pu=uo&&!0&&n&&!n.nodeType&&n,fo=Pu&&Pu.exports===uo,Fu=fo?X.Buffer:void 0,ho=Fu?Fu.isBuffer:void 0,Es=ho||co,mo=9007199254740991,Na=/^(?:0|[1-9]\d*)$/;function Pa(y,I){var U=typeof y;return I=I==null?mo:I,!!I&&(U=="number"||U!="symbol"&&Na.test(y))&&y>-1&&y%1==0&&y<I}var go="[object Arguments]",Fa="[object Array]",Ka="[object Boolean]",As="[object Date]",po="[object Error]",Sl="[object Function]",Ku="[object Map]",Sr="[object Number]",xs="[object Object]",Vu="[object RegExp]",Va="[object Set]",$u="[object String]",fh="[object WeakMap]",dh="[object ArrayBuffer]",hh="[object DataView]",Ll="[object Float32Array]",Co="[object Float64Array]",$a="[object Int8Array]",bs="[object Int16Array]",Eo="[object Int32Array]",Ao="[object Uint8Array]",Ha="[object Uint8ClampedArray]",mh="[object Uint16Array]",gh="[object Uint32Array]",Ee={};Ee[Ll]=Ee[Co]=Ee[$a]=Ee[bs]=Ee[Eo]=Ee[Ao]=Ee[Ha]=Ee[mh]=Ee[gh]=!0,Ee[go]=Ee[Fa]=Ee[dh]=Ee[Ka]=Ee[hh]=Ee[As]=Ee[po]=Ee[Sl]=Ee[Ku]=Ee[Sr]=Ee[xs]=Ee[Vu]=Ee[Va]=Ee[$u]=Ee[fh]=!1;function ph(y){return Tn(y)&&so(y.length)&&!!Ee[Zr(y)]}function Il(y){return function(I){return y(I)}}var Dl=typeof e=="object"&&e&&!e.nodeType&&e,vs=Dl&&!0&&n&&!n.nodeType&&n,Ni=vs&&vs.exports===Dl,_l=Ni&&J.process,Hu=function(){try{var y=vs&&vs.require&&vs.require("util").types;return y||_l&&_l.binding&&_l.binding("util")}catch{}}(),ju=Hu&&Hu.isTypedArray,Ch=ju?Il(ju):ph,Eh=Object.prototype,Lr=Eh.hasOwnProperty;function Ah(y,I){var U=_e(y),F=!U&&ao(y),z=!U&&!F&&Es(y),j=!U&&!F&&!z&&Ch(y),Z=U||F||z||j,rt=Z?Ua(y.length,String):[],mt=rt.length;for(var Tt in y)(I||Lr.call(y,Tt))&&!(Z&&(Tt=="length"||z&&(Tt=="offset"||Tt=="parent")||j&&(Tt=="buffer"||Tt=="byteLength"||Tt=="byteOffset")||Pa(Tt,mt)))&&rt.push(Tt);return rt}var Ml=Object.prototype;function xh(y){var I=y&&y.constructor,U=typeof I=="function"&&I.prototype||Ml;return y===U}function Ul(y,I){return function(U){return y(I(U))}}var bh=Ul(Object.keys,Object),Ir=Object.prototype,vh=Ir.hasOwnProperty;function zu(y){if(!xh(y))return bh(y);var I=[];for(var U in Object(y))vh.call(y,U)&&U!="constructor"&&I.push(U);return I}function Ol(y){return oo(y)?Ah(y):zu(y)}function Gu(y){var I=-1,U=y.length;return function(){return++I<U?{value:y[I],key:I}:null}}function Bh(y){var I=-1;return function(){var F=y.next();return F.done?null:(I++,{value:F.value,key:I})}}function xo(y){var I=Ol(y),U=-1,F=I.length;return function z(){var j=I[++U];return j==="__proto__"?z():U<F?{value:y[j],key:j}:null}}function Th(y){if(oo(y))return Gu(y);var I=lo(y);return I?Bh(I):xo(y)}function dr(y){return function(){if(y===null)throw new Error("Callback was already called.");var I=y;y=null,I.apply(this,arguments)}}function On(y){return function(I,U,F){if(F=ti(F||zt),y<=0||!I)return F(null);var z=Th(I),j=!1,Z=0,rt=!1;function mt(gt,Lt){if(Z-=1,gt)j=!0,F(gt);else{if(Lt===ee||j&&Z<=0)return j=!0,F(null);rt||Tt()}}function Tt(){for(rt=!0;Z<y&&!j;){var gt=z();if(gt===null){j=!0,Z<=0&&F(null);return}Z+=1,U(gt.value,gt.key,dr(mt))}rt=!1}Tt()}}function ei(y,I,U,F){On(I)(y,M(U),F)}function Ge(y,I){return function(U,F,z){return y(U,I,F,z)}}function ja(y,I,U){U=ti(U||zt);var F=0,z=0,j=y.length;j===0&&U(null);function Z(rt,mt){rt?U(rt):(++z===j||mt===ee)&&U(null)}for(;F<j;F++)I(y[F],F,dr(Z))}var yh=Ge(ei,1/0),Dr=function(y,I,U){var F=oo(y)?ja:yh;F(y,M(I),U)};function _r(y){return function(I,U,F){return y(Dr,I,M(U),F)}}function Bs(y,I,U,F){F=F||zt,I=I||[];var z=[],j=0,Z=M(U);y(I,function(rt,mt,Tt){var gt=j++;Z(rt,function(Lt,de){z[gt]=de,Tt(Lt)})},function(rt){F(rt,z)})}var bo=_r(Bs),za=V(bo);function Pi(y){return function(I,U,F,z){return y(On(U),I,M(F),z)}}var hr=Pi(Bs),Ga=Ge(hr,1),Wa=V(Ga);function Ts(y,I){for(var U=-1,F=y==null?0:y.length;++U<F&&I(y[U],U,y)!==!1;);return y}function qa(y){return function(I,U,F){for(var z=-1,j=Object(I),Z=F(I),rt=Z.length;rt--;){var mt=Z[y?rt:++z];if(U(j[mt],mt,j)===!1)break}return I}}var ys=qa();function ks(y,I){return y&&ys(y,I,Ol)}function Wu(y,I,U,F){for(var z=y.length,j=U+(F?1:-1);F?j--:++j<z;)if(I(y[j],j,y))return j;return-1}function kh(y){return y!==y}function qu(y,I,U){for(var F=U-1,z=y.length;++F<z;)if(y[F]===I)return F;return-1}function vo(y,I,U){return I===I?qu(y,I,U):Wu(y,kh,U)}var Nl=function(y,I,U){typeof I=="function"&&(U=I,I=null),U=ti(U||zt);var F=Ol(y),z=F.length;if(!z)return U(null);I||(I=z);var j={},Z=0,rt=!1,mt=Object.create(null),Tt=[],gt=[],Lt={};ks(y,function(Ie,Te){if(!_e(Ie)){de(Te,[Ie]),gt.push(Te);return}var Pe=Ie.slice(0,Ie.length-1),li=Pe.length;if(li===0){de(Te,Ie),gt.push(Te);return}Lt[Te]=li,Ts(Pe,function(w){if(!y[w])throw new Error("async.auto task `"+Te+"` has a non-existent dependency `"+w+"` in "+Pe.join(", "));Pn(w,function(){li--,li===0&&de(Te,Ie)})})}),Lx(),en();function de(Ie,Te){Tt.push(function(){oi(Ie,Te)})}function en(){if(Tt.length===0&&Z===0)return U(null,j);for(;Tt.length&&Z<I;){var Ie=Tt.shift();Ie()}}function Pn(Ie,Te){var Pe=mt[Ie];Pe||(Pe=mt[Ie]=[]),Pe.push(Te)}function mr(Ie){var Te=mt[Ie]||[];Ts(Te,function(Pe){Pe()}),en()}function oi(Ie,Te){if(!rt){var Pe=dr(function(w,Is){if(Z--,arguments.length>2&&(Is=r(arguments,1)),w){var Hl={};ks(j,function(gr,Qt){Hl[Qt]=gr}),Hl[Ie]=Is,rt=!0,mt=Object.create(null),U(w,Hl)}else j[Ie]=Is,mr(Ie)});Z++;var li=M(Te[Te.length-1]);Te.length>1?li(j,Pe):li(Pe)}}function Lx(){for(var Ie,Te=0;gt.length;)Ie=gt.pop(),Te++,Ts(Ix(Ie),function(Pe){--Lt[Pe]===0&>.push(Pe)});if(Te!==z)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function Ix(Ie){var Te=[];return ks(y,function(Pe,li){_e(Pe)&&vo(Pe,Ie,0)>=0&&Te.push(li)}),Te}};function ni(y,I){for(var U=-1,F=y==null?0:y.length,z=Array(F);++U<F;)z[U]=I(y[U],U,y);return z}var Rh="[object Symbol]";function Xu(y){return typeof y=="symbol"||Tn(y)&&Zr(y)==Rh}var wh=1/0,Xa=ct?ct.prototype:void 0,Bo=Xa?Xa.toString:void 0;function Ya(y){if(typeof y=="string")return y;if(_e(y))return ni(y,Ya)+"";if(Xu(y))return Bo?Bo.call(y):"";var I=y+"";return I=="0"&&1/y==-wh?"-0":I}function Rs(y,I,U){var F=-1,z=y.length;I<0&&(I=-I>z?0:z+I),U=U>z?z:U,U<0&&(U+=z),z=I>U?0:U-I>>>0,I>>>=0;for(var j=Array(z);++F<z;)j[F]=y[F+I];return j}function ri(y,I,U){var F=y.length;return U=U===void 0?F:U,!I&&U>=F?y:Rs(y,I,U)}function Qa(y,I){for(var U=y.length;U--&&vo(I,y[U],0)>-1;);return U}function Yu(y,I){for(var U=-1,F=y.length;++U<F&&vo(I,y[U],0)>-1;);return U}function Pl(y){return y.split("")}var Sh="\\ud800-\\udfff",Lh="\\u0300-\\u036f",Ih="\\ufe20-\\ufe2f",me="\\u20d0-\\u20ff",fe=Lh+Ih+me,Dh="\\ufe0e\\ufe0f",Fl="\\u200d",Fi=RegExp("["+Fl+Sh+fe+Dh+"]");function _h(y){return Fi.test(y)}var Kl="\\ud800-\\udfff",Qu="\\u0300-\\u036f",Ja="\\ufe20-\\ufe2f",Ki="\\u20d0-\\u20ff",We=Qu+Ja+Ki,Za="\\ufe0e\\ufe0f",ii="["+Kl+"]",ws="["+We+"]",si="\\ud83c[\\udffb-\\udfff]",En="(?:"+ws+"|"+si+")",To="[^"+Kl+"]",tc="(?:\\ud83c[\\udde6-\\uddff]){2}",ec="[\\ud800-\\udbff][\\udc00-\\udfff]",Ju="\\u200d",nc=En+"?",yo="["+Za+"]?",Nn="(?:"+Ju+"(?:"+[To,tc,ec].join("|")+")"+yo+nc+")*",Mh=yo+nc+Nn,Wn="(?:"+[To+ws+"?",ws,tc,ec,ii].join("|")+")",k=RegExp(si+"(?="+si+")|"+Wn+Mh,"g");function N(y){return y.match(k)||[]}function W(y){return _h(y)?N(y):Pl(y)}function lt(y){return y==null?"":Ya(y)}var St=/^\s+|\s+$/g;function ft(y,I,U){if(y=lt(y),y&&(U||I===void 0))return y.replace(St,"");if(!y||!(I=Ya(I)))return y;var F=W(y),z=W(I),j=Yu(F,z),Z=Qa(F,z)+1;return ri(F,j,Z).join("")}var $t=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,te=/,/,ce=/(=.+)?(\s*)$/,Re=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;function we(y){return y=y.toString().replace(Re,""),y=y.match($t)[2].replace(" ",""),y=y?y.split(te):[],y=y.map(function(I){return ft(I.replace(ce,""))}),y}function Le(y,I){var U={};ks(y,function(F,z){var j,Z=O(F),rt=!Z&&F.length===1||Z&&F.length===0;if(_e(F))j=F.slice(0,-1),F=F[F.length-1],U[z]=j.concat(j.length>0?mt:F);else if(rt)U[z]=F;else{if(j=we(F),F.length===0&&!Z&&j.length===0)throw new Error("autoInject task functions require explicit parameters.");Z||j.pop(),U[z]=j.concat(mt)}function mt(Tt,gt){var Lt=ni(j,function(de){return Tt[de]});Lt.push(gt),M(F).apply(null,Lt)}}),Nl(U,I)}function ne(){this.head=this.tail=null,this.length=0}function yn(y,I){y.length=1,y.head=y.tail=I}ne.prototype.removeLink=function(y){return y.prev?y.prev.next=y.next:this.head=y.next,y.next?y.next.prev=y.prev:this.tail=y.prev,y.prev=y.next=null,this.length-=1,y},ne.prototype.empty=function(){for(;this.head;)this.shift();return this},ne.prototype.insertAfter=function(y,I){I.prev=y,I.next=y.next,y.next?y.next.prev=I:this.tail=I,y.next=I,this.length+=1},ne.prototype.insertBefore=function(y,I){I.prev=y.prev,I.next=y,y.prev?y.prev.next=I:this.head=I,y.prev=I,this.length+=1},ne.prototype.unshift=function(y){this.head?this.insertBefore(this.head,y):yn(this,y)},ne.prototype.push=function(y){this.tail?this.insertAfter(this.tail,y):yn(this,y)},ne.prototype.shift=function(){return this.head&&this.removeLink(this.head)},ne.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)},ne.prototype.toArray=function(){for(var y=Array(this.length),I=this.head,U=0;U<this.length;U++)y[U]=I.data,I=I.next;return y},ne.prototype.remove=function(y){for(var I=this.head;I;){var U=I.next;y(I)&&this.removeLink(I),I=U}return this};function un(y,I,U){if(I==null)I=1;else if(I===0)throw new Error("Concurrency must not be zero");var F=M(y),z=0,j=[],Z=!1;function rt(Lt,de,en){if(en!=null&&typeof en!="function")throw new Error("task callback must be a function");if(gt.started=!0,_e(Lt)||(Lt=[Lt]),Lt.length===0&>.idle())return E(function(){gt.drain()});for(var Pn=0,mr=Lt.length;Pn<mr;Pn++){var oi={data:Lt[Pn],callback:en||zt};de?gt._tasks.unshift(oi):gt._tasks.push(oi)}Z||(Z=!0,E(function(){Z=!1,gt.process()}))}function mt(Lt){return function(de){z-=1;for(var en=0,Pn=Lt.length;en<Pn;en++){var mr=Lt[en],oi=vo(j,mr,0);oi===0?j.shift():oi>0&&j.splice(oi,1),mr.callback.apply(mr,arguments),de!=null&>.error(de,mr.data)}z<=gt.concurrency-gt.buffer&>.unsaturated(),gt.idle()&>.drain(),gt.process()}}var Tt=!1,gt={_tasks:new ne,concurrency:I,payload:U,saturated:zt,unsaturated:zt,buffer:I/4,empty:zt,drain:zt,error:zt,started:!1,paused:!1,push:function(Lt,de){rt(Lt,!1,de)},kill:function(){gt.drain=zt,gt._tasks.empty()},unshift:function(Lt,de){rt(Lt,!0,de)},remove:function(Lt){gt._tasks.remove(Lt)},process:function(){if(!Tt){for(Tt=!0;!gt.paused&&z<gt.concurrency&>._tasks.length;){var Lt=[],de=[],en=gt._tasks.length;gt.payload&&(en=Math.min(en,gt.payload));for(var Pn=0;Pn<en;Pn++){var mr=gt._tasks.shift();Lt.push(mr),j.push(mr),de.push(mr.data)}z+=1,gt._tasks.length===0&>.empty(),z===gt.concurrency&>.saturated();var oi=dr(mt(Lt));F(de,oi)}Tt=!1}},length:function(){return gt._tasks.length},running:function(){return z},workersList:function(){return j},idle:function(){return gt._tasks.length+z===0},pause:function(){gt.paused=!0},resume:function(){gt.paused!==!1&&(gt.paused=!1,E(gt.process))}};return gt}function kn(y,I){return un(y,1,I)}var Rn=Ge(ei,1);function An(y,I,U,F){F=ti(F||zt);var z=M(U);Rn(y,function(j,Z,rt){z(I,j,function(mt,Tt){I=Tt,rt(mt)})},function(j){F(j,I)})}function ko(){var y=ni(arguments,M);return function(){var I=r(arguments),U=this,F=I[I.length-1];typeof F=="function"?I.pop():F=zt,An(y,I,function(z,j,Z){j.apply(U,z.concat(function(rt){var mt=r(arguments,1);Z(rt,mt)}))},function(z,j){F.apply(U,[z].concat(j))})}}var Vi=function(){return ko.apply(null,r(arguments).reverse())},Ss=Array.prototype.concat,rc=function(y,I,U,F){F=F||zt;var z=M(U);hr(y,I,function(j,Z){z(j,function(rt){return rt?Z(rt):Z(null,r(arguments,1))})},function(j,Z){for(var rt=[],mt=0;mt<Z.length;mt++)Z[mt]&&(rt=Ss.apply(rt,Z[mt]));return F(j,rt)})},Ng=Ge(rc,1/0),Zu=Ge(rc,1),tf=function(){var y=r(arguments),I=[null].concat(y);return function(){var U=arguments[arguments.length-1];return U.apply(this,I)}};function ic(y){return y}function Ro(y,I){return function(U,F,z,j){j=j||zt;var Z=!1,rt;U(F,function(mt,Tt,gt){z(mt,function(Lt,de){Lt?gt(Lt):y(de)&&!rt?(Z=!0,rt=I(!0,mt),gt(null,ee)):gt()})},function(mt){mt?j(mt):j(null,Z?rt:I(!1))})}}function qn(y,I){return I}var Vl=_r(Ro(ic,qn)),$i=Pi(Ro(ic,qn)),sc=Ge($i,1);function Uh(y){return function(I){var U=r(arguments,1);U.push(function(F){var z=r(arguments,1);typeof console=="object"&&(F?console.error&&console.error(F):console[y]&&Ts(z,function(j){console[y](j)}))}),M(I).apply(null,U)}}var Pg=Uh("dir");function Fg(y,I,U){U=dr(U||zt);var F=M(y),z=M(I);function j(rt){if(rt)return U(rt);var mt=r(arguments,1);mt.push(Z),z.apply(this,mt)}function Z(rt,mt){if(rt)return U(rt);if(!mt)return U(null);F(j)}Z(null,!0)}function Oh(y,I,U){U=dr(U||zt);var F=M(y),z=function(j){if(j)return U(j);var Z=r(arguments,1);if(I.apply(this,Z))return F(z);U.apply(null,[null].concat(Z))};F(z)}function Kg(y,I,U){Oh(y,function(){return!I.apply(this,arguments)},U)}function Vg(y,I,U){U=dr(U||zt);var F=M(I),z=M(y);function j(rt){if(rt)return U(rt);z(Z)}function Z(rt,mt){if(rt)return U(rt);if(!mt)return U(null);F(j)}z(Z)}function wo(y){return function(I,U,F){return y(I,F)}}function ef(y,I,U){Dr(y,wo(M(I)),U)}function oc(y,I,U,F){On(I)(y,wo(M(U)),F)}var So=Ge(oc,1);function nf(y){return O(y)?y:s(function(I,U){var F=!0;I.push(function(){var z=arguments;F?E(function(){U.apply(null,z)}):U.apply(null,z)}),y.apply(this,I),F=!1})}function Mr(y){return!y}var Lo=_r(Ro(Mr,Mr)),lc=Pi(Ro(Mr,Mr)),rf=Ge(lc,1);function $g(y){return function(I){return I==null?void 0:I[y]}}function $l(y,I,U,F){var z=new Array(I.length);y(I,function(j,Z,rt){U(j,function(mt,Tt){z[Z]=!!Tt,rt(mt)})},function(j){if(j)return F(j);for(var Z=[],rt=0;rt<I.length;rt++)z[rt]&&Z.push(I[rt]);F(null,Z)})}function Ur(y,I,U,F){var z=[];y(I,function(j,Z,rt){U(j,function(mt,Tt){mt?rt(mt):(Tt&&z.push({index:Z,value:j}),rt())})},function(j){j?F(j):F(null,ni(z.sort(function(Z,rt){return Z.index-rt.index}),$g("value")))})}function sf(y,I,U,F){var z=oo(I)?$l:Ur;z(y,I,M(U),F||zt)}var of=_r(sf),ac=Pi(sf),lf=Ge(ac,1);function Hg(y,I){var U=dr(I||zt),F=M(nf(y));function z(j){if(j)return U(j);F(z)}z()}var af=function(y,I,U,F){F=F||zt;var z=M(U);hr(y,I,function(j,Z){z(j,function(rt,mt){return rt?Z(rt):Z(null,{key:mt,val:j})})},function(j,Z){for(var rt={},mt=Object.prototype.hasOwnProperty,Tt=0;Tt<Z.length;Tt++)if(Z[Tt]){var gt=Z[Tt].key,Lt=Z[Tt].val;mt.call(rt,gt)?rt[gt].push(Lt):rt[gt]=[Lt]}return F(j,rt)})},Io=Ge(af,1/0),$=Ge(af,1),Y=Uh("log");function G(y,I,U,F){F=ti(F||zt);var z={},j=M(U);ei(y,I,function(Z,rt,mt){j(Z,rt,function(Tt,gt){if(Tt)return mt(Tt);z[rt]=gt,mt()})},function(Z){F(Z,z)})}var vt=Ge(G,1/0),Nt=Ge(G,1);function se(y,I){return I in y}function qe(y,I){var U=Object.create(null),F=Object.create(null);I=I||ic;var z=M(y),j=s(function(rt,mt){var Tt=I.apply(null,rt);se(U,Tt)?E(function(){mt.apply(null,U[Tt])}):se(F,Tt)?F[Tt].push(mt):(F[Tt]=[mt],z.apply(null,rt.concat(function(){var gt=r(arguments);U[Tt]=gt;var Lt=F[Tt];delete F[Tt];for(var de=0,en=Lt.length;de<en;de++)Lt[de].apply(null,gt)})))});return j.memo=U,j.unmemoized=y,j}var ue;c?ue=process.nextTick:l?ue=setImmediate:ue=d;var cf=h(ue);function Nh(y,I,U){U=U||zt;var F=oo(I)?[]:{};y(I,function(z,j,Z){M(z)(function(rt,mt){arguments.length>2&&(mt=r(arguments,1)),F[j]=mt,Z(rt)})},function(z){U(z,F)})}function er(y,I){Nh(Dr,y,I)}function cc(y,I,U){Nh(On(I),y,U)}var Ph=function(y,I){var U=M(y);return un(function(F,z){U(F[0],z)},I,1)},Do=function(y,I){var U=Ph(y,I);return U.push=function(F,z,j){if(j==null&&(j=zt),typeof j!="function")throw new Error("task callback must be a function");if(U.started=!0,_e(F)||(F=[F]),F.length===0)return E(function(){U.drain()});z=z||0;for(var Z=U._tasks.head;Z&&z>=Z.priority;)Z=Z.next;for(var rt=0,mt=F.length;rt<mt;rt++){var Tt={data:F[rt],priority:z,callback:j};Z?U._tasks.insertBefore(Z,Tt):U._tasks.push(Tt)}E(U.process)},delete U.unshift,U};function uc(y,I){if(I=ti(I||zt),!_e(y))return I(new TypeError("First argument to race must be an array of functions"));if(!y.length)return I();for(var U=0,F=y.length;U<F;U++)M(y[U])(I)}function _o(y,I,U,F){var z=r(y).reverse();An(z,I,U,F)}function oe(y){var I=M(y);return s(function(F,z){return F.push(function(Z,rt){if(Z)z(null,{error:Z});else{var mt;arguments.length<=2?mt=rt:mt=r(arguments,1),z(null,{value:mt})}}),I.apply(this,F)})}function jg(y){var I;return _e(y)?I=ni(y,oe):(I={},ks(y,function(U,F){I[F]=oe.call(this,U)})),I}function Fh(y,I,U,F){sf(y,I,function(z,j){U(z,function(Z,rt){j(Z,!rt)})},F)}var fc=_r(Fh),Kh=Pi(Fh),zg=Ge(Kh,1);function Gg(y){return function(){return y}}function Mo(y,I,U){var F=5,z=0,j={times:F,intervalFunc:Gg(z)};function Z(gt,Lt){if(typeof Lt=="object")gt.times=+Lt.times||F,gt.intervalFunc=typeof Lt.interval=="function"?Lt.interval:Gg(+Lt.interval||z),gt.errorFilter=Lt.errorFilter;else if(typeof Lt=="number"||typeof Lt=="string")gt.times=+Lt||F;else throw new Error("Invalid arguments for async.retry")}if(arguments.length<3&&typeof y=="function"?(U=I||zt,I=y):(Z(j,y),U=U||zt),typeof I!="function")throw new Error("Invalid arguments for async.retry");var rt=M(I),mt=1;function Tt(){rt(function(gt){gt&&mt++<j.times&&(typeof j.errorFilter!="function"||j.errorFilter(gt))?setTimeout(Tt,j.intervalFunc(mt)):U.apply(null,arguments)})}Tt()}var Hi=function(y,I){I||(I=y,y=null);var U=M(I);return s(function(F,z){function j(Z){U.apply(null,F.concat(Z))}y?Mo(y,j,z):Mo(j,z)})};function dc(y,I){Nh(Rn,y,I)}var hc=_r(Ro(Boolean,ic)),Ls=Pi(Ro(Boolean,ic)),mc=Ge(Ls,1);function Vh(y,I,U){var F=M(I);bo(y,function(j,Z){F(j,function(rt,mt){if(rt)return Z(rt);Z(null,{value:j,criteria:mt})})},function(j,Z){if(j)return U(j);U(null,ni(Z.sort(z),$g("value")))});function z(j,Z){var rt=j.criteria,mt=Z.criteria;return rt<mt?-1:rt>mt?1:0}}function gc(y,I,U){var F=M(y);return s(function(z,j){var Z=!1,rt;function mt(){var Tt=y.name||"anonymous",gt=new Error('Callback function "'+Tt+'" timed out.');gt.code="ETIMEDOUT",U&&(gt.info=U),Z=!0,j(gt)}z.push(function(){Z||(j.apply(null,arguments),clearTimeout(rt))}),rt=setTimeout(mt,I),F.apply(null,z)})}var Wg=Math.ceil,pc=Math.max;function Uo(y,I,U,F){for(var z=-1,j=pc(Wg((I-y)/(U||1)),0),Z=Array(j);j--;)Z[F?j:++z]=y,y+=U;return Z}function Oo(y,I,U,F){var z=M(U);hr(Uo(0,y,1),I,z,F)}var qg=Ge(Oo,1/0),Xg=Ge(Oo,1);function Yg(y,I,U,F){arguments.length<=3&&(F=U,U=I,I=_e(y)?[]:{}),F=ti(F||zt);var z=M(U);Dr(y,function(j,Z,rt){z(I,j,Z,rt)},function(j){F(j,I)})}function Cc(y,I){var U=null,F;I=I||zt,So(y,function(z,j){M(z)(function(Z,rt){arguments.length>2?F=r(arguments,1):F=rt,U=Z,j(!Z)})},function(){I(U,F)})}function Ec(y){return function(){return(y.unmemoized||y).apply(null,arguments)}}function Ac(y,I,U){U=dr(U||zt);var F=M(I);if(!y())return U(null);var z=function(j){if(j)return U(j);if(y())return F(z);var Z=r(arguments,1);U.apply(null,[null].concat(Z))};F(z)}function Qg(y,I,U){Ac(function(){return!y.apply(this,arguments)},I,U)}var $h=function(y,I){if(I=ti(I||zt),!_e(y))return I(new Error("First argument to waterfall must be an array of functions"));if(!y.length)return I();var U=0;function F(j){var Z=M(y[U++]);j.push(dr(z)),Z.apply(null,j)}function z(j){if(j||U===y.length)return I.apply(null,arguments);F(r(arguments,1))}F([])},Sx={apply:i,applyEach:za,applyEachSeries:Wa,asyncify:A,auto:Nl,autoInject:Le,cargo:kn,compose:Vi,concat:Ng,concatLimit:rc,concatSeries:Zu,constant:tf,detect:Vl,detectLimit:$i,detectSeries:sc,dir:Pg,doDuring:Fg,doUntil:Kg,doWhilst:Oh,during:Vg,each:ef,eachLimit:oc,eachOf:Dr,eachOfLimit:ei,eachOfSeries:Rn,eachSeries:So,ensureAsync:nf,every:Lo,everyLimit:lc,everySeries:rf,filter:of,filterLimit:ac,filterSeries:lf,forever:Hg,groupBy:Io,groupByLimit:af,groupBySeries:$,log:Y,map:bo,mapLimit:hr,mapSeries:Ga,mapValues:vt,mapValuesLimit:G,mapValuesSeries:Nt,memoize:qe,nextTick:cf,parallel:er,parallelLimit:cc,priorityQueue:Do,queue:Ph,race:uc,reduce:An,reduceRight:_o,reflect:oe,reflectAll:jg,reject:fc,rejectLimit:Kh,rejectSeries:zg,retry:Mo,retryable:Hi,seq:ko,series:dc,setImmediate:E,some:hc,someLimit:Ls,someSeries:mc,sortBy:Vh,timeout:gc,times:qg,timesLimit:Oo,timesSeries:Xg,transform:Yg,tryEach:Cc,unmemoize:Ec,until:Qg,waterfall:$h,whilst:Ac,all:Lo,allLimit:lc,allSeries:rf,any:hc,anyLimit:Ls,anySeries:mc,find:Vl,findLimit:$i,findSeries:sc,forEach:ef,forEachSeries:So,forEachLimit:oc,forEachOf:Dr,forEachOfSeries:Rn,forEachOfLimit:ei,inject:An,foldl:An,foldr:_o,select:of,selectLimit:ac,selectSeries:lf,wrapSync:A};e.default=Sx,e.apply=i,e.applyEach=za,e.applyEachSeries=Wa,e.asyncify=A,e.auto=Nl,e.autoInject=Le,e.cargo=kn,e.compose=Vi,e.concat=Ng,e.concatLimit=rc,e.concatSeries=Zu,e.constant=tf,e.detect=Vl,e.detectLimit=$i,e.detectSeries=sc,e.dir=Pg,e.doDuring=Fg,e.doUntil=Kg,e.doWhilst=Oh,e.during=Vg,e.each=ef,e.eachLimit=oc,e.eachOf=Dr,e.eachOfLimit=ei,e.eachOfSeries=Rn,e.eachSeries=So,e.ensureAsync=nf,e.every=Lo,e.everyLimit=lc,e.everySeries=rf,e.filter=of,e.filterLimit=ac,e.filterSeries=lf,e.forever=Hg,e.groupBy=Io,e.groupByLimit=af,e.groupBySeries=$,e.log=Y,e.map=bo,e.mapLimit=hr,e.mapSeries=Ga,e.mapValues=vt,e.mapValuesLimit=G,e.mapValuesSeries=Nt,e.memoize=qe,e.nextTick=cf,e.parallel=er,e.parallelLimit=cc,e.priorityQueue=Do,e.queue=Ph,e.race=uc,e.reduce=An,e.reduceRight=_o,e.reflect=oe,e.reflectAll=jg,e.reject=fc,e.rejectLimit=Kh,e.rejectSeries=zg,e.retry=Mo,e.retryable=Hi,e.seq=ko,e.series=dc,e.setImmediate=E,e.some=hc,e.someLimit=Ls,e.someSeries=mc,e.sortBy=Vh,e.timeout=gc,e.times=qg,e.timesLimit=Oo,e.timesSeries=Xg,e.transform=Yg,e.tryEach=Cc,e.unmemoize=Ec,e.until=Qg,e.waterfall=$h,e.whilst=Ac,e.all=Lo,e.allLimit=lc,e.allSeries=rf,e.any=hc,e.anyLimit=Ls,e.anySeries=mc,e.find=Vl,e.findLimit=$i,e.findSeries=sc,e.forEach=ef,e.forEachSeries=So,e.forEachLimit=oc,e.forEachOf=Dr,e.forEachOfSeries=Rn,e.forEachOfLimit=ei,e.inject=An,e.foldl=An,e.foldr=_o,e.select=of,e.selectLimit=ac,e.selectSeries=lf,e.wrapSync=A,Object.defineProperty(e,"__esModule",{value:!0})})})(RC,RC.exports);var NT={exports:{}},wC=NT.exports=function(n,t){if(t||(t=16),n===void 0&&(n=128),n<=0)return"0";for(var e=Math.log(Math.pow(2,n))/Math.log(t),r=2;e===1/0;r*=2)e=Math.log(Math.pow(2,n/r))/Math.log(t)*r;for(var i=e-Math.floor(e),s="",r=0;r<Math.floor(e);r++){var o=Math.floor(Math.random()*t).toString(t);s=o+s}if(i){var l=Math.pow(t,i),o=Math.floor(Math.random()*l).toString(t);s=o+s}var c=parseInt(s,t);return c!==1/0&&c>=Math.pow(2,n)?wC(n,t):s};wC.rack=function(n,t,e){var r=function(s){var o=0;do{if(o++>10)if(e)n+=e;else throw new Error("too many ID collisions, use more bits");var l=wC(n,t)}while(Object.hasOwnProperty.call(i,l));return i[l]=s,l},i=r.hats={};return r.get=function(s){return r.hats[s]},r.set=function(s,o){return r.hats[s]=o,r},r.bits=n||128,r.base=t||16,r};var PT=al,gU=UT,pU=OT,um=Wr,SC=RC.exports,CU=NT.exports,FT=ul.ACTIONS,KT=on;function on(n,t){if(PT.EventEmitter.call(this),!t||typeof t!="string")throw new Error("Presence channel must be provided");this.connection=n,this.channel=t,this.wantSubscribe=!1,this.subscribed=!1,this.remotePresences={},this.localPresences={},this._remotePresenceInstances={},this._subscriptionCallbacksBySeq={},this._wantsDestroy=!1}PT.mixin(on),on.prototype.subscribe=function(n){this._sendSubscriptionAction(!0,n)},on.prototype.unsubscribe=function(n){this._sendSubscriptionAction(!1,n)},on.prototype.create=function(n){if(this._wantsDestroy)throw new Error("Presence is being destroyed");n=n||CU();var t=this._createLocalPresence(n);return this.localPresences[n]=t,t},on.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this,e=Object.keys(t.localPresences);this.unsubscribe(function(r){if(r)return t._callbackOrEmit(r,n);var i=Object.keys(t._remotePresenceInstances);SC.parallel([function(s){SC.each(e,function(o,l){t.localPresences[o].destroy(l)},s)},function(s){if(!t._wantsDestroy)return s();SC.each(i,function(o,l){t._remotePresenceInstances[o].destroy(l)},s)}],function(s){t._wantsDestroy&&delete t.connection._presences[t.channel],t._callbackOrEmit(s,n)})})},on.prototype._sendSubscriptionAction=function(n,t){this.wantSubscribe=!!n;var e=this.wantSubscribe?FT.presenceSubscribe:FT.presenceUnsubscribe,r=this.connection._presenceSeq++;this._subscriptionCallbacksBySeq[r]=t,this.connection.canSend&&this.connection._sendPresenceAction(e,r,this)},on.prototype._handleSubscribe=function(n,t){this.wantSubscribe&&(this.subscribed=!0);var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},on.prototype._handleUnsubscribe=function(n,t){this.subscribed=!1;var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},on.prototype._receiveUpdate=function(n,t){var e=um.dig(this.localPresences,t.id);if(e)return e._ack(n,t.pv);if(n)return this.emit("error",n);var r=this,i=um.digOrCreate(this._remotePresenceInstances,t.id,function(){return r._createRemotePresence(t.id)});i.receiveUpdate(t)},on.prototype._updateRemotePresence=function(n){this.remotePresences[n.presenceId]=n.value,n.value===null&&this._removeRemotePresence(n.presenceId),this.emit("receive",n.presenceId,n.value)},on.prototype._broadcastAllLocalPresence=function(n){if(n)return this.emit("error",n);for(var t in this.localPresences){var e=this.localPresences[t];e.value!==null&&e.send()}},on.prototype._removeRemotePresence=function(n){this._remotePresenceInstances[n].destroy(),delete this._remotePresenceInstances[n],delete this.remotePresences[n]},on.prototype._onConnectionStateChanged=function(){if(!!this.connection.canSend){this._resubscribe();for(var n in this.localPresences)this.localPresences[n]._sendPending()}},on.prototype._resubscribe=function(){var n=[];for(var t in this._subscriptionCallbacksBySeq){var e=this._subscriptionCallback(t);n.push(e)}if(!this.wantSubscribe)return this._callEachOrEmit(n);var r=this;this.subscribe(function(i){r._callEachOrEmit(n,i)})},on.prototype._subscriptionCallback=function(n){var t=this._subscriptionCallbacksBySeq[n];return delete this._subscriptionCallbacksBySeq[n],t},on.prototype._callbackOrEmit=function(n,t){if(t)return um.nextTick(t,n);n&&this.emit("error",n)},on.prototype._createLocalPresence=function(n){return new gU(this,n)},on.prototype._createRemotePresence=function(n){return new pU(this,n)},on.prototype._callEachOrEmit=function(n,t){var e=um.callEach(n,t);!e&&t&&this.emit("error",t)};var sd=UT,VT=om,EU=Wr,$T=VT.CODES,AU=ki;function ki(n,t){sd.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this._doc=this.connection.get(this.collection,this.id),this._emitter=this.connection._docPresenceEmitter,this._isSending=!1,this._docDataVersionByPresenceVersion={},this._opHandler=this._transformAgainstOp.bind(this),this._createOrDelHandler=this._handleCreateOrDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._destroyHandler=this.destroy.bind(this),this._registerWithDoc()}ki.prototype=Object.create(sd.prototype),ki.prototype.submit=function(n,t){if(!this._doc.type){if(n===null)return this._callbackOrEmit(null,t);var e={code:$T.ERR_DOC_DOES_NOT_EXIST,message:"Cannot submit presence. Document has not been created"};return this._callbackOrEmit(e,t)}this._docDataVersionByPresenceVersion[this.presenceVersion]=this._doc._dataStateVersion,sd.prototype.submit.call(this,n,t)},ki.prototype.destroy=function(n){this._emitter.removeEventListener(this._doc,"op",this._opHandler),this._emitter.removeEventListener(this._doc,"create",this._createOrDelHandler),this._emitter.removeEventListener(this._doc,"del",this._createOrDelHandler),this._emitter.removeEventListener(this._doc,"load",this._loadHandler),this._emitter.removeEventListener(this._doc,"destroy",this._destroyHandler),sd.prototype.destroy.call(this,n)},ki.prototype._sendPending=function(){if(!this._isSending){this._isSending=!0;var n=this;this._doc.whenNothingPending(function(){n._isSending=!1,n.connection.canSend&&(n._pendingMessages.forEach(function(t){t.t=n._doc.type.uri,t.v=n._doc.version,n.connection.send(t)}),n._pendingMessages=[],n._docDataVersionByPresenceVersion={})})}},ki.prototype._registerWithDoc=function(){this._emitter.addEventListener(this._doc,"op",this._opHandler),this._emitter.addEventListener(this._doc,"create",this._createOrDelHandler),this._emitter.addEventListener(this._doc,"del",this._createOrDelHandler),this._emitter.addEventListener(this._doc,"load",this._loadHandler),this._emitter.addEventListener(this._doc,"destroy",this._destroyHandler)},ki.prototype._transformAgainstOp=function(n,t){var e=this,r=this._doc._dataStateVersion;this._pendingMessages.forEach(function(i){var s=e._docDataVersionByPresenceVersion[i.pv];if(!(s>=r))try{i.p=e._transformPresence(i.p,n,t),e._docDataVersionByPresenceVersion[i.pv]=r}catch(l){var o=e._getCallback(i.pv);e._callbackOrEmit(l,o)}});try{this.value=this._transformPresence(this.value,n,t)}catch(i){this.emit("error",i)}},ki.prototype._handleCreateOrDel=function(){this._pendingMessages.forEach(function(n){n.p=null}),this.value=null},ki.prototype._handleLoad=function(){this.value=null,this._pendingMessages=[],this._docDataVersionByPresenceVersion={}},ki.prototype._message=function(){var n=sd.prototype._message.call(this);return n.c=this.collection,n.d=this.id,n.v=null,n.t=null,n},ki.prototype._transformPresence=function(n,t,e){var r=this._doc.type;if(!EU.supportsPresence(r))throw new VT($T.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,"Type does not support presence: "+r.name);return r.transformPresence(n,t,e)};var HT={};(function(n){var t=ed,e=om,r=Wr,i=e.CODES;n.checkOp=function(l){if(l==null||typeof l!="object")return new e(i.ERR_OT_OP_BADLY_FORMED,"Op must be an object");if(l.create!=null){if(typeof l.create!="object")return new e(i.ERR_OT_OP_BADLY_FORMED,"Create data must be an object");var c=l.create.type;if(typeof c!="string")return new e(i.ERR_OT_OP_BADLY_FORMED,"Missing create type");var d=t.map[c];if(d==null||typeof d!="object")return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type")}else if(l.del!=null){if(l.del!==!0)return new e(i.ERR_OT_OP_BADLY_FORMED,"del value must be true")}else if(!("op"in l))return new e(i.ERR_OT_OP_BADLY_FORMED,"Missing op, create, or del");if(l.src!=null&&typeof l.src!="string")return new e(i.ERR_OT_OP_BADLY_FORMED,"src must be a string");if(l.seq!=null&&typeof l.seq!="number")return new e(i.ERR_OT_OP_BADLY_FORMED,"seq must be a number");if(l.src==null&&l.seq!=null||l.src!=null&&l.seq==null)return new e(i.ERR_OT_OP_BADLY_FORMED,"Both src and seq must be set together");if(l.m!=null&&typeof l.m!="object")return new e(i.ERR_OT_OP_BADLY_FORMED,"op.m must be an object or null")},n.normalizeType=function(l){return t.map[l]&&t.map[l].uri},n.apply=function(l,c){if(typeof l!="object")return new e(i.ERR_APPLY_SNAPSHOT_NOT_PROVIDED,"Missing snapshot");if(l.v!=null&&c.v!=null&&l.v!==c.v)return new e(i.ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT,"Version mismatch");if(c.create){if(l.type)return new e(i.ERR_DOC_ALREADY_CREATED,"Document already exists");var d=c.create,h=t.map[d.type];if(!h)return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=h.create(d.data),l.type=h.uri,l.v++}catch(E){return E}}else if(c.del)l.data=void 0,l.type=null,l.v++;else if("op"in c){var C=s(l,c.op);if(C)return C;l.v++}else l.v++};function s(l,c){if(!l.type)return new e(i.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(c===void 0)return new e(i.ERR_OT_OP_NOT_PROVIDED,"Missing op");var d=t.map[l.type];if(!d)return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=d.apply(l.data,c)}catch(h){return new e(i.ERR_OT_OP_NOT_APPLIED,h.message)}}n.transform=function(l,c,d){if(c.v!=null&&c.v!==d.v)return new e(i.ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM,"Version mismatch");if(d.del){if(c.create||"op"in c)return new e(i.ERR_DOC_WAS_DELETED,"Document was deleted")}else{if(d.create&&("op"in c||c.create||c.del)||"op"in d&&c.create)return new e(i.ERR_DOC_ALREADY_CREATED,"Document was created remotely");if("op"in d&&"op"in c){if(!l)return new e(i.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(typeof l=="string"&&(l=t.map[l],!l))return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{c.op=l.transform(c.op,d.op,"left")}catch(h){return h}}}c.v!=null&&c.v++},n.applyOps=function(l,c,d){d=d||{};for(var h=0;h<c.length;h++){var C=c[h];if(d._normalizeLegacyJson0Ops)try{o(l,C)}catch{return new e(i.ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED,"Cannot normalize legacy json0 op")}l.v=C.v;var E=n.apply(l,C);if(E)return E}},n.transformPresence=function(l,c,d){var h=this.checkOp(c);if(h)return h;var C=l.t;if(typeof C=="string"&&(C=t.map[C]),!C)return{code:i.ERR_DOC_TYPE_NOT_RECOGNIZED,message:"Unknown type"};if(!r.supportsPresence(C))return{code:i.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,message:"Type does not support presence"};if(c.create||c.del){l.p=null,l.v++;return}try{l.p=l.p===null?null:C.transformPresence(l.p,c.op,d)}catch(E){return{code:i.ERR_PRESENCE_TRANSFORM_FAILED,message:E.message||E}}l.v++};function o(l,c){if(l.type===t.defaultType.uri){var d=c.op;if(!!d){var h=l.data;d.length>1&&(h=r.clone(h));for(var C=0;C<d.length;C++){var E=d[C];typeof E.lm=="string"&&(E.lm=+E.lm);for(var A=E.p,v=h,R=0;R<A.length;R++){var S=A[R];Object.prototype.toString.call(v)=="[object Array]"?A[R]=+S:v.constructor===Object&&(A[R]=S.toString()),v=v[S]}C<d.length-1&&(h=t.defaultType.apply(h,[E]))}}}}})(HT);var od=OT,xU=HT,bU=qr;function qr(n,t){od.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this.src=null,this.presenceVersion=null,this._doc=this.connection.get(this.collection,this.id),this._emitter=this.connection._docPresenceEmitter,this._pending=null,this._opCache=null,this._pendingSetPending=!1,this._opHandler=this._handleOp.bind(this),this._createDelHandler=this._handleCreateDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._registerWithDoc()}qr.prototype=Object.create(od.prototype),qr.prototype.receiveUpdate=function(n){this._pending&&n.pv<this._pending.pv||(this.src=n.src,this._pending=n,this._setPendingPresence())},qr.prototype.destroy=function(n){this._emitter.removeEventListener(this._doc,"op",this._opHandler),this._emitter.removeEventListener(this._doc,"create",this._createDelHandler),this._emitter.removeEventListener(this._doc,"del",this._createDelHandler),this._emitter.removeEventListener(this._doc,"load",this._loadHandler),od.prototype.destroy.call(this,n)},qr.prototype._registerWithDoc=function(){this._emitter.addEventListener(this._doc,"op",this._opHandler),this._emitter.addEventListener(this._doc,"create",this._createDelHandler),this._emitter.addEventListener(this._doc,"del",this._createDelHandler),this._emitter.addEventListener(this._doc,"load",this._loadHandler)},qr.prototype._setPendingPresence=function(){if(!this._pendingSetPending){this._pendingSetPending=!0;var n=this;this._doc.whenNothingPending(function(){if(n._pendingSetPending=!1,!!n._pending){if(n._pending.pv<n.presenceVersion)return n._pending=null;if(n._pending.v>n._doc.version)return n._doc.fetch();!n._catchUpStalePresence()||(n.value=n._pending.p,n.presenceVersion=n._pending.pv,n._pending=null,n.presence._updateRemotePresence(n))}})}},qr.prototype._handleOp=function(n,t,e){var r=e===this.src;this._transformAgainstOp(n,r),this._cacheOp(n,r),this._setPendingPresence()},od.prototype._handleCreateDel=function(){this._cacheOp(null),this._setPendingPresence()},od.prototype._handleLoad=function(){this.value=null,this._pending=null,this._opCache=null,this.presence._updateRemotePresence(this)},qr.prototype._transformAgainstOp=function(n,t){if(!!this.value){try{this.value=this._doc.type.transformPresence(this.value,n,t)}catch(e){return this.presence.emit("error",e)}this.presence._updateRemotePresence(this)}},qr.prototype._catchUpStalePresence=function(){if(this._pending.v>=this._doc.version)return!0;if(!this._opCache)return this._startCachingOps(),this._doc.fetch(),this.presence.subscribe(),!1;for(;this._opCache[this._pending.v];){var n=this._opCache[this._pending.v],t=n.op,e=n.isOwnOp;t===null?(this._pending.p=null,this._pending.v++):xU.transformPresence(this._pending,t,e)}var r=this._pending.v>=this._doc.version;return r&&this._stopCachingOps(),r},qr.prototype._startCachingOps=function(){this._opCache=[]},qr.prototype._stopCachingOps=function(){this._opCache=null},qr.prototype._cacheOp=function(n,t){this._opCache&&(n=n?{op:n}:null,this._opCache[this._doc.version-1]={op:n,isOwnOp:t})};var jT=KT,vU=AU,BU=bU;function Zc(n,t,e){var r=Zc.channel(t,e);jT.call(this,n,r),this.collection=t,this.id=e}var TU=Zc;Zc.prototype=Object.create(jT.prototype),Zc.channel=function(n,t){return n+"."+t},Zc.prototype._createLocalPresence=function(n){return new vU(this,n)},Zc.prototype._createRemotePresence=function(n){return new BU(this,n)};var yU=kU;function kU(n,t,e,r,i){this.id=n,this.v=t,this.type=e,this.data=r,this.m=i}var RU=yU,zT=al,GT=ld;function ld(n,t,e,r,i){if(zT.EventEmitter.call(this),typeof i!="function")throw new Error("Callback is required for SnapshotRequest");this.requestId=t,this.connection=n,this.id=r,this.collection=e,this.callback=i,this.sent=!1}zT.mixin(ld),ld.prototype.send=function(){!this.connection.canSend||(this.connection.send(this._message()),this.sent=!0)},ld.prototype._onConnectionStateChanged=function(){this.connection.canSend?this.sent||this.send():this.sent=!1},ld.prototype._handleResponse=function(n,t){if(this.emit("ready"),n)return this.callback(n);var e=t.meta?t.meta:null,r=new RU(this.id,t.v,t.type,t.data,e);this.callback(null,r)};var WT=GT,wU=Wr,SU=ul.ACTIONS,LU=LC;function LC(n,t,e,r,i,s){if(WT.call(this,n,t,e,r,s),!wU.isValidVersion(i))throw new Error("Snapshot version must be a positive integer or null");this.version=i}LC.prototype=Object.create(WT.prototype),LC.prototype._message=function(){return{a:SU.snapshotFetch,id:this.requestId,c:this.collection,d:this.id,v:this.version}};var qT=GT,IU=Wr,DU=ul.ACTIONS,_U=IC;function IC(n,t,e,r,i,s){if(qT.call(this,n,t,e,r,s),!IU.isValidTimestamp(i))throw new Error("Snapshot timestamp must be a positive integer or null");this.timestamp=i}IC.prototype=Object.create(qT.prototype),IC.prototype._message=function(){return{a:DU.snapshotFetchByTimestamp,id:this.requestId,c:this.collection,d:this.id,ts:this.timestamp}};var is=Wr,MU=Tp.default.EventEmitter,UU=["create","del","destroy","load","op"],OU=ad;function ad(){this._docs={},this._forwarders={},this._emitters={}}ad.prototype.addEventListener=function(n,t,e){this._registerDoc(n);var r=is.dig(this._emitters,n.collection,n.id);r.on(t,e)},ad.prototype.removeEventListener=function(n,t,e){var r=is.dig(this._emitters,n.collection,n.id);!r||(r.off(t,e),r._eventsCount===1&&this._unregisterDoc(n))},ad.prototype._registerDoc=function(n){var t=!0;if(is.digOrCreate(this._docs,n.collection,n.id,function(){return t=!1,n}),!t){var e=is.digOrCreate(this._emitters,n.collection,n.id,function(){var i=new MU;return i.setMaxListeners(1e3),i}),r=this;UU.forEach(function(i){var s=is.digOrCreate(r._forwarders,n.collection,n.id,i,function(){return e.emit.bind(e,i)});n.on(i,s)}),this.addEventListener(n,"destroy",this._unregisterDoc.bind(this,n))}},ad.prototype._unregisterDoc=function(n){var t=is.dig(this._forwarders,n.collection,n.id);for(var e in t)n.off(e,t[e]);var r=is.dig(this._emitters,n.collection,n.id);r.removeAllListeners(),is.digAndRemove(this._forwarders,n.collection,n.id),is.digAndRemove(this._emitters,n.collection,n.id),is.digAndRemove(this._docs,n.collection,n.id)};var NU=oU,PU=fU,FU=KT,XT=TU,KU=LU,VU=_U,YT=al,tu=om,ve=ul.ACTIONS,QT=ed,Ri=Wr,cd=kT,$U=OU,ud=tu.CODES;function JT(n){return n.readyState===0||n.readyState===1?"connecting":"disconnected"}var HU=Ut;function Ut(n){YT.EventEmitter.call(this),this.collections={},this.nextQueryId=1,this.nextSnapshotRequestId=1,this.queries={},this._presences={},this._docPresenceEmitter=new $U,this._snapshotRequests={},this.seq=1,this._presenceSeq=1,this.id=null,this.agent=null,this.debug=!1,this.state=JT(n),this.bindToSocket(n)}YT.mixin(Ut),Ut.prototype.bindToSocket=function(n){this.socket&&(this.socket.close(),this.socket.onmessage=null,this.socket.onopen=null,this.socket.onerror=null,this.socket.onclose=null),this.socket=n;var t=JT(n);this._setState(t),this.canSend=!1;var e=this;n.onmessage=function(r){try{var i=typeof r.data=="string"?JSON.parse(r.data):r.data}catch{cd.warn("Failed to parse message",r);return}e.debug&&cd.info("RECV",JSON.stringify(i));var s={data:i};if(e.emit("receive",s),!!s.data)try{e.handleMessage(s.data)}catch(o){Ri.nextTick(function(){e.emit("error",o)})}},n.readyState===1&&e._initializeHandshake(),n.onopen=function(){e._setState("connecting"),e._initializeHandshake()},n.onerror=function(r){e.emit("connection error",r)},n.onclose=function(r){r==="closed"||r==="Closed"?e._setState("closed",r):r==="stopped"||r==="Stopped by server"?e._setState("stopped",r):e._setState("disconnected",r)}},Ut.prototype.handleMessage=function(n){var t=null;switch(n.error&&(t=ZT(n.error,n),delete n.error),n.a){case ve.initLegacy:return this._handleLegacyInit(n);case ve.handshake:return this._handleHandshake(t,n);case ve.queryFetch:var e=this.queries[n.id];e&&e._handleFetch(t,n.data,n.extra);return;case ve.querySubscribe:var e=this.queries[n.id];e&&e._handleSubscribe(t,n.data,n.extra);return;case ve.queryUnsubscribe:return;case ve.queryUpdate:var e=this.queries[n.id];if(!e)return;if(t)return e._handleError(t);n.diff&&e._handleDiff(n.diff),n.hasOwnProperty("extra")&&e._handleExtra(n.extra);return;case ve.bulkFetch:return this._handleBulkMessage(t,n,"_handleFetch");case ve.bulkSubscribe:case ve.bulkUnsubscribe:return this._handleBulkMessage(t,n,"_handleSubscribe");case ve.snapshotFetch:case ve.snapshotFetchByTimestamp:return this._handleSnapshotFetch(t,n);case ve.fetch:var r=this.getExisting(n.c,n.d);r&&r._handleFetch(t,n.data);return;case ve.subscribe:case ve.unsubscribe:var r=this.getExisting(n.c,n.d);r&&r._handleSubscribe(t,n.data);return;case ve.op:var r=this.getExisting(n.c,n.d);r&&r._handleOp(t,n);return;case ve.presence:return this._handlePresence(t,n);case ve.presenceSubscribe:return this._handlePresenceSubscribe(t,n);case ve.presenceUnsubscribe:return this._handlePresenceUnsubscribe(t,n);case ve.presenceRequest:return this._handlePresenceRequest(t,n);case ve.pingPong:return this._handlePingPong(t);default:cd.warn("Ignoring unrecognized message",n)}};function ZT(n,t){var e=new Error(n.message);return e.code=n.code,t&&(e.data=t),e}Ut.prototype._handleBulkMessage=function(n,t,e){if(t.data)for(var r in t.data){var i=t.data[r],s=this.getExisting(t.c,r);s&&(n?s[e](n):i.error?s[e](ZT(i.error)):s[e](null,i))}else if(Array.isArray(t.b))for(var o=0;o<t.b.length;o++){var r=t.b[o],s=this.getExisting(t.c,r);s&&s[e](n)}else if(t.b)for(var r in t.b){var s=this.getExisting(t.c,r);s&&s[e](n)}else cd.error("Invalid bulk message",t)},Ut.prototype._reset=function(){this.agent=null},Ut.prototype._setState=function(n,t){if(this.state!==n){if(n==="connecting"&&this.state!=="disconnected"&&this.state!=="stopped"&&this.state!=="closed"||n==="connected"&&this.state!=="connecting"){var e=new tu(ud.ERR_CONNECTION_STATE_TRANSITION_INVALID,"Cannot transition directly from "+this.state+" to "+n);return this.emit("error",e)}this.state=n,this.canSend=n==="connected",(n==="disconnected"||n==="stopped"||n==="closed")&&this._reset(),this.startBulk();for(var r in this.queries){var i=this.queries[r];i._onConnectionStateChanged()}for(var s in this.collections){var o=this.collections[s];for(var r in o)o[r]._onConnectionStateChanged()}for(var l in this._presences)this._presences[l]._onConnectionStateChanged();for(var r in this._snapshotRequests){var c=this._snapshotRequests[r];c._onConnectionStateChanged()}this.endBulk(),this.emit(n,t),this.emit("state",n,t)}},Ut.prototype.startBulk=function(){this.bulk||(this.bulk={})},Ut.prototype.endBulk=function(){if(this.bulk)for(var n in this.bulk){var t=this.bulk[n];this._sendBulk("f",n,t.f),this._sendBulk("s",n,t.s),this._sendBulk("u",n,t.u)}this.bulk=null},Ut.prototype._sendBulk=function(n,t,e){if(!!e){var r=[],i={},s=0,o;for(var l in e){var c=e[l];c==null?r.push(l):(i[l]=c,o=l,s++)}if(r.length===1){var l=r[0];this.send({a:n,c:t,d:l})}else r.length&&this.send({a:"b"+n,c:t,b:r});if(s===1){var d=i[o];this.send({a:n,c:t,d:o,v:d})}else s&&this.send({a:"b"+n,c:t,b:i})}},Ut.prototype._sendActions=function(n,t,e){if(this._addDoc(t),this.bulk){var r=this.bulk[t.collection]||(this.bulk[t.collection]={}),i=r[n]||(r[n]={}),s=i.hasOwnProperty(t.id);return i[t.id]=e,s}else{var o={a:n,c:t.collection,d:t.id,v:e};this.send(o)}},Ut.prototype.sendFetch=function(n){return this._sendActions(ve.fetch,n,n.version)},Ut.prototype.sendSubscribe=function(n){return this._sendActions(ve.subscribe,n,n.version)},Ut.prototype.sendUnsubscribe=function(n){return this._sendActions(ve.unsubscribe,n)},Ut.prototype.sendOp=function(n,t){this._addDoc(n);var e={a:ve.op,c:n.collection,d:n.id,v:n.version,src:t.src,seq:t.seq,x:{}};"op"in t&&(e.op=t.op),t.create&&(e.create=t.create),t.del&&(e.del=t.del),n.submitSource&&(e.x.source=t.source),this.send(e)},Ut.prototype.send=function(n){this.debug&&cd.info("SEND",JSON.stringify(n)),this.emit("send",n),this.socket.send(JSON.stringify(n))},Ut.prototype.ping=function(){if(!this.canSend)throw new tu(ud.ERR_CANNOT_PING_OFFLINE,"Socket must be CONNECTED to ping");var n={a:ve.pingPong};this.send(n)},Ut.prototype.close=function(){this.socket.close()},Ut.prototype.getExisting=function(n,t){if(this.collections[n])return this.collections[n][t]},Ut.prototype.get=function(n,t){var e=this.collections[n]||(this.collections[n]={}),r=e[t];return r||(r=e[t]=new NU(this,n,t),this.emit("doc",r)),r._wantsDestroy=!1,r},Ut.prototype._destroyDoc=function(n){!n._wantsDestroy||(Ri.digAndRemove(this.collections,n.collection,n.id),n.emit("destroy"))},Ut.prototype._addDoc=function(n){var t=this.collections[n.collection];t||(t=this.collections[n.collection]={}),t[n.id]!==n&&(t[n.id]=n)},Ut.prototype._createQuery=function(n,t,e,r,i){var s=this.nextQueryId++,o=new PU(n,this,s,t,e,r,i);return this.queries[s]=o,o.send(),o},Ut.prototype._destroyQuery=function(n){delete this.queries[n.id]},Ut.prototype.createFetchQuery=function(n,t,e,r){return this._createQuery(ve.queryFetch,n,t,e,r)},Ut.prototype.createSubscribeQuery=function(n,t,e,r){return this._createQuery(ve.querySubscribe,n,t,e,r)},Ut.prototype.hasPending=function(){return!!(this._firstDoc(fm)||this._firstQuery(fm)||this._firstSnapshotRequest())};function fm(n){return n.hasPending()}Ut.prototype.hasWritePending=function(){return!!this._firstDoc(jU)};function jU(n){return n.hasWritePending()}Ut.prototype.whenNothingPending=function(n){var t=this._firstDoc(fm);if(t){t.once("nothing pending",this._nothingPendingRetry(n));return}var e=this._firstQuery(fm);if(e){e.once("ready",this._nothingPendingRetry(n));return}var r=this._firstSnapshotRequest();if(r){r.once("ready",this._nothingPendingRetry(n));return}Ri.nextTick(n)},Ut.prototype._nothingPendingRetry=function(n){var t=this;return function(){Ri.nextTick(function(){t.whenNothingPending(n)})}},Ut.prototype._firstDoc=function(n){for(var t in this.collections){var e=this.collections[t];for(var r in e){var i=e[r];if(n(i))return i}}},Ut.prototype._firstQuery=function(n){for(var t in this.queries){var e=this.queries[t];if(n(e))return e}},Ut.prototype._firstSnapshotRequest=function(){for(var n in this._snapshotRequests)return this._snapshotRequests[n]},Ut.prototype.fetchSnapshot=function(n,t,e,r){typeof e=="function"&&(r=e,e=null);var i=this.nextSnapshotRequestId++,s=new KU(this,i,n,t,e,r);this._snapshotRequests[s.requestId]=s,s.send()},Ut.prototype.fetchSnapshotByTimestamp=function(n,t,e,r){typeof e=="function"&&(r=e,e=null);var i=this.nextSnapshotRequestId++,s=new VU(this,i,n,t,e,r);this._snapshotRequests[s.requestId]=s,s.send()},Ut.prototype._handleSnapshotFetch=function(n,t){var e=this._snapshotRequests[t.id];!e||(delete this._snapshotRequests[t.id],e._handleResponse(n,t))},Ut.prototype._handleLegacyInit=function(n){if(n.protocolMinor)return this._initializeHandshake();this._initialize(n)},Ut.prototype._initializeHandshake=function(){this.send({a:ve.handshake,id:this.id})},Ut.prototype._handleHandshake=function(n,t){if(n)return this.emit("error",n);this._initialize(t)},Ut.prototype._handlePingPong=function(n){if(n)return this.emit("error",n);this.emit("pong")},Ut.prototype._initialize=function(n){if(this.state==="connecting"){if(n.protocol!==1)return this.emit("error",new tu(ud.ERR_PROTOCOL_VERSION_NOT_SUPPORTED,"Unsupported protocol version: "+n.protocol));if(QT.map[n.type]!==QT.defaultType)return this.emit("error",new tu(ud.ERR_DEFAULT_TYPE_MISMATCH,n.type+" does not match the server default type"));if(typeof n.id!="string")return this.emit("error",new tu(ud.ERR_CLIENT_ID_BADLY_FORMED,"Client id must be a string"));this.id=n.id,this._setState("connected")}},Ut.prototype.getPresence=function(n){var t=this,e=Ri.digOrCreate(this._presences,n,function(){return new FU(t,n)});return e._wantsDestroy=!1,e},Ut.prototype.getDocPresence=function(n,t){var e=XT.channel(n,t),r=this,i=Ri.digOrCreate(this._presences,e,function(){return new XT(r,n,t)});return i._wantsDestroy=!1,i},Ut.prototype._sendPresenceAction=function(n,t,e){this._addPresence(e);var r={a:n,ch:e.channel,seq:t};return this.send(r),r.seq},Ut.prototype._addPresence=function(n){Ri.digOrCreate(this._presences,n.channel,function(){return n})},Ut.prototype._handlePresenceSubscribe=function(n,t){var e=Ri.dig(this._presences,t.ch);e&&e._handleSubscribe(n,t.seq)},Ut.prototype._handlePresenceUnsubscribe=function(n,t){var e=Ri.dig(this._presences,t.ch);e&&e._handleUnsubscribe(n,t.seq)},Ut.prototype._handlePresence=function(n,t){var e=Ri.dig(this._presences,t.ch);e&&e._receiveUpdate(n,t)},Ut.prototype._handlePresenceRequest=function(n,t){var e=Ri.dig(this._presences,t.ch);e&&e._broadcastAllLocalPresence(n,t)};var ty=HU,zU=ed;const fd={err:1001,msg:"user auth error",name:"AuthError"},dm={err:1002,msg:"you don't have required permission",name:"PermissionError"},DC={err:1003,msg:"Too many user connected",name:"MaxUserError"},dd={err:1004,msg:"document server changed, reload it",name:"RequestReloadError"},GU={err:1005,msg:"app id must be at least 2 chars, doc id must be at least 5 chars",name:"DocIdError"},WU={err:1028,msg:"upload file ext not allowed",name:"FileExtError"},Ea="x-live-editor-token",eu="x-live-editor-base-url",Hn=D("auth-connection");function qU(n){try{n()}catch(t){Hn.error(t)}}class XU{constructor(t,e){m(this,"enabled",!0);m(this,"connection");m(this,"ws");m(this,"retryCount");m(this,"events",new vb.EventEmitter);m(this,"token",null);m(this,"resourceToken",null);m(this,"pingOptions",{interval:5e4,timeout:15e4});m(this,"reAuth",async()=>{if(this.connection&&this.reauthFunc){const t=await this.reauthFunc();await this.auth(t);const e=this.pingOptions;this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t,options:{ping:e}})}}});this.url=t,this.reauthFunc=e,this.retryCount=0}getBaseURL(){const t=new URL(this.url);return`${t.protocol==="wss:"?"https:":"http:"}//${t.host}${t.pathname}`}getBase64BaseURL(){return qi(this.getBaseURL())}async auth(t){p(Hn,t.token,"no auth token");const e=`${this.getBaseURL()}/auth`,r=await window.fetch(e,{method:"GET",headers:{[Ea]:t.token,[eu]:this.getBase64BaseURL()},credentials:"include"});return r.status,this.enabled?(this.token=t.token,await r.json()):{read:"",user:""}}async logout(){if(!this.token)return;const t=`${this.getBaseURL()}/logout`;await window.fetch(t,{method:"GET",headers:{[eu]:qi(this.getBaseURL())}})}async init(t){const e=await this.auth(t);if(!this.enabled)return;this.resourceToken=e.read,this.ws=new J6.default(this.url,void 0,{maxReconnectionDelay:2500,minReconnectionDelay:1e3}),this.connection=Object.create(ty.prototype),p(Hn,this.connection,"no this.connection");const r=this.ws,i=this.pingOptions;this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t,options:{ping:i}}),this._ping==null&&(this._ping=window.setInterval(()=>{var d;const c=Date.now();c-((d=this.lastReceiveTime)!=null?d:0)>i.interval&&this.send({a:"ping",id:this.id,ts:c}),this.lastReceiveTime&&c-this.lastReceiveTime>i.timeout&&r&&r.readyState===r.OPEN&&(r.reconnect(),this.lastReceiveTime=Date.now())},1e3))};const s=this.connection.handleMessage.bind(this.connection);let o=!1;this.connection.handleMessage=l=>{var d;const c=l;if(this.connection&&(this.connection.lastReceiveTime=Date.now()),"err"in c||c.a==="pong")o=!1,this.handleMessage(c);else{Object.prototype.hasOwnProperty.call(c,"a")&&c.a==="hs"&&this.retryCount>=5&&(o?(Hn.info("retrying re-auth success"),o=!1,this.emitAuthRecover()):o=!0),Object.prototype.hasOwnProperty.call(c,"a")&&c.a!=="init"&&c.a!=="hs"&&(this.retryCount=0);try{s(c)}catch(h){if((h==null?void 0:h.type)==="writeConflict"){this.emitWriteConflictError(h,c);return}if((d=h==null?void 0:h.message)!=null&&d.startsWith("Cannot invert subtype")){this.emitWriteConflictError(h,c);return}throw h}}},ty.apply(this.connection,[this.ws])}async reConnect(t){var r,i;(r=this.ws)==null||r.close();const e=this.pingOptions;if(this.connection&&this.reauthFunc){const s=await this.reauthFunc();await this.auth(s),(i=this.ws)==null||i.reconnect(),this.connection._initializeHandshake=function(){t&&(s.token=t),this.send({a:"hs",id:this.id,auth:s,options:{ping:e}})}}}async handleAuthError(){var t,e;if(this.reauthFunc){if(!this.enabled)return;(t=this.ws)==null||t.close(),this.retryCount+=1,Hn.info(`retrying re-auth attempt no. ${this.retryCount}`);try{if(this.connection){const r=await this.reauthFunc();if(window.isReauthError)throw new Error("reauth error");await this.auth(r);const i=this.pingOptions;(e=this.ws)==null||e.reconnect(),this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:r,options:{ping:i}})}}}catch(r){Hn.error(r),this.retryCount>=5&&(Hn.warn("retry auth times exceed 5, broadcast auth error"),this.emitAuthError());const i=30*1e3;setTimeout(()=>this.handleAuthError(),Math.min(2*this.retryCount*1e3,i))}}}emitPermissionError(){const t=new Error(dm.msg);t.code=dm.err,this.events.emit("error",t)}emitAuthRecover(){this.events.emit("authRecover")}emitAuthError(){const t=new Error(fd.msg);t.code=fd.err,this.events.emit("error",t)}emitRequestReloadError(){const t=new Error(dd.msg);t.code=dd.err,this.events.emit("requestReloadError",t)}emitWriteConflictError(t,e){t.orgMsg=e,this.events.emit("writeConflictError",t)}emitMaxUsersError(){this.events.emit("maxUsersError"),this.end(!1)}handleMessage(t){const e=t;if(e.a==="pong")return;const r=e.err;if(r===fd.err)Hn.warn("auth error"),this.handleAuthError();else if(r===DC.err)Hn.warn(DC.msg),this.emitMaxUsersError();else if(r===dd.err){Hn.warn(dd.msg);try{this.emitRequestReloadError()}catch(i){Hn.error(`error occurred while process reload error: ${JSON.stringify(i)}`)}finally{this.end(!1)}}else r===dm.err?this.emitPermissionError():(Hn.error(`unknown message received: ${JSON.stringify(e)}`),this.emitAuthError())}get(t,e){return p(Hn,this.connection,"no this.connection"),this.connection.get(t,e)}addEventListener(t,e){t==="error"?this.events.addListener(t,e):(p(Hn,this.ws,"no this.ws"),this.ws.addEventListener(t,e))}onAuthError(t){this.events.addListener("error",t)}onAuthRecover(t){this.events.addListener("authRecover",t)}onWriteConflictError(t){this.events.addListener("writeConflictError",t)}onMaxUsersError(t){p(Hn,this.events.listenerCount("maxUsersError")===0,"too many maxUserError listener"),this.events.addListener("maxUsersError",t)}onRequestReloadError(t){p(Hn,this.events.listenerCount("requestReloadError")===0,"to many requestReloadError listener"),this.events.addListener("requestReloadError",t)}end(t){var e,r;this.enabled=!1,this.reauthFunc=void 0,this.events.removeAllListeners(),qU(()=>{var i;return(i=this.connection)==null?void 0:i.close()}),(e=this.connection)!=null&&e._ping&&window.clearInterval(this.connection._ping),this.connection=void 0,(r=this.ws)==null||r.close(),this.ws=void 0,t&&this.logout()}}D("utils/file");function YU(){function n(){return new Promise(t=>{const e=new FileReader;e.onload=()=>{t(e.result)},e.readAsArrayBuffer(this)})}File.prototype.arrayBuffer=File.prototype.arrayBuffer||n,Blob.prototype.arrayBuffer=Blob.prototype.arrayBuffer||n}YU();async function QU(n){const e=n.size,r=Math.floor((e+102400-1)/102400),i=new Z6.Hash;for(let o=0;o<r;o++){const l=o*102400;let c=l+102400;c>e&&(c=e);const h=await n.slice(l,c,n.type).arrayBuffer();i.update(new Uint8Array(h))}const s=i.digest();return qi(s)}const ss=D("sharedb-doc/client"),JU=Bb.default.create();class ZU{constructor(t,e,r){m(this,"connection");m(this,"auth");m(this,"doc",null);m(this,"reauthFunc");m(this,"clientId",it());m(this,"getDoc",async()=>{const t=r=>new Promise((i,s)=>{r.fetch(o=>{o?s(o):i()})});p(ss,!this.doc,"This websocket has opened a doc."),await this.connection.init(this.auth);const e=this.connection.get(this.auth.appId,this.auth.docId);return this.doc=e,await t(e),ss.debug(e),e});this.auth=t;const i=`${e}/${this.auth.appId}/${this.auth.docId}`;zU.register(Zh.type),this.connection=new XU(i,r),this.reauthFunc=r}editorServer(){const t=this.apiServer(),e=`/${this.auth.appId}/${this.auth.docId}`;return p(ss,t.endsWith(e),`invalid api server: ${t}, ${e}`),t.substr(0,t.length-e.length)}close(t){this.connection.end(t),this.doc=null}on(t,e){this.connection.addEventListener(t,r=>{(t==="error"||this.doc)&&e(r)})}onAuthError(t){this.connection.onAuthError(t)}onAuthRecover(t){this.connection.onAuthRecover(t)}onWriteConflictError(t){this.connection.onWriteConflictError(t)}onMaxUsersError(t){this.connection.onMaxUsersError(t)}onRequestReloadError(t){this.connection.onRequestReloadError(t)}async authOnly(){await this.connection.auth(this.auth)}getResourceToken(){return this.connection.resourceToken}hasDocContainer(){return!!this.doc}apiServer(){const t=this.connection.url;if(t.startsWith("ws://"))return`http://${t.substring(5)}`;if(t.startsWith("wss://"))return`https://${t.substring(6)}`;throw new Error(`invalid server url: ${t}`)}async getFileUrlByHash(t,e,r,i,s){try{const o=`${t}/${e}`,l=await this.request(o,{method:"post",headers:{...s},data:{name:r,size:i}});return l.data&&Array.isArray(l.data)&&l.data.length===1?l.data[0]:""}catch{return""}}async getFileUrlsByHashes(t){const r=`${this.apiServer()}/resources`;try{const i=`${r}/hash`,s=await this.request(i,{method:"post",headers:{[Ea]:this.connection.token},data:{resources:t}});return s.data&&Array.isArray(s.data)?s.data:[]}catch{return[]}}async uploadFile(t,e,r,i,s){let o=e.size;if(o===0)throw new Error("file is empty");o+=500;const l=A=>{ss.info(`on progress: ${A.loaded}`);let v=A.loaded*100/o;v>100&&(v=100),i(v)},c=await QU(e),d=await this.getFileUrlByHash(t,c,e.name,e.size,r);if(d)return i(-1),d;let h=t;s!=null&&s.thumbnail&&(h+="/thumbnail");const C=new FormData;C.append("file-size",`${e.size}`),C.append("file-hash",c),C.append("file",e,e.name);const E=await this.request(h,{method:"post",data:C,withCredentials:!0,headers:{...r},onUploadProgress:l});return ss.info(E),i(100),Array.isArray(E.data)?E.data[0]:E.data}async uploadResource(t,e=()=>{},r){const s=`${this.apiServer()}/resources`;p(ss,this.connection.token,"no connection token");const o=await this.uploadFile(s,t,{[Ea]:this.connection.token},e,r);return p(ss,o,"no result"),o}async request(t,e){var s,o;let r=this.connection.token,i;for(let l=0;l<2;l++){const c=e||{};c.url=t,c.headers||(c.headers={}),p(ss,r,"no token"),c.headers={...c.headers,[Ea]:r,[eu]:this.connection.getBase64BaseURL()};try{return await JU(t,c)}catch(d){if(i=d,((s=d==null?void 0:d.response)==null?void 0:s.status)===403&&this.reauthFunc){const h=await this.reauthFunc();if(await this.connection.auth(h),!h.token)throw d;r=h.token;continue}throw(o=d.response)!=null&&o.data&&(d.responseData=d.response.data),d}}throw p(ss,i,"no error"),i}async getVersions(){const e=`${this.apiServer()}/versions?withExtra=true`,i=(await this.request(e)).data.versions;return i.forEach(s=>{s.extra&&(s.extra=JSON.parse(s.extra))}),i}async getVersion(t){const r=`${this.apiServer()}/versions/${t}`,i=await this.request(r);return JSON.parse(i.data.data)}async getLatestVersion(){const e=`${this.apiServer()}/versions/latest`,r=await this.request(e);return JSON.parse(r.data.data)}async getVersionOps(t,e){let i=`${this.apiServer()}/versions/before/${t}?withOp=true`;e!==void 0&&e!==0&&(i+=`&from=${e}`);const s=await this.request(i),o=s.data.ops,l=Tb.default(o,h=>!!h.create);let c=null;l!==-1&&(c=o[l],o.splice(0,l+1));let d;return c?(p(ss,c.create,"no createDoc.create"),d=c.create.data):d=JSON.parse(s.data.data),d.blocks||(d.blocks=[]),{doc:d,ops:s.data.ops}}async updateVersionExtra(t,e,r){const s=`${this.apiServer()}/versions/${t}/tags/${e}`;await this.request(s,{method:"post",data:{extra:JSON.stringify(r)}})}async revertVersion(t){const r=`${this.apiServer()}/versions/revert/${t}`;await this.request(r,{method:"post",data:{}})}async createVersion(t,e){const i=`${this.apiServer()}/versions`;return(await this.request(i,{method:"post",data:{publish:e,tag:t}})).data}async recognizeLink(t){const r=`${this.apiServer()}/resources/external/${qi(t)}`;return(await this.request(r)).data}getResourceId(t){const e=/\/resources\/([^?]+)/,r=t.match(e);return r&&r.length>=2?r[1]:""}buildResourceUrl(t,e){var o,l;if(!t)return"";if(t.startsWith("file:")||t.startsWith("data:")||t.startsWith("blob:"))return t;const r=this.apiServer();if(t.startsWith("http:")||t.startsWith("https:")){const c=r.replace(/\/[^/]*$/,"");if(c&&t.includes(c)){const d=this.auth.docId,h=`${c}/`,C="/resources",E=t.indexOf(h),A=t.indexOf(C,E+h.length);if(E!==-1&&A!==-1){const v=t.substring(E+h.length,A);if(v!==d){let R=t.replace(v,d);const S=new URL(R),O="token";(o=S.searchParams)==null||o.delete(O),R=S.toString();const M=this.getResourceId(R);return e!=null&&e.syncNewResources&&((l=e==null?void 0:e.syncNewResources)==null||l.call(e,M,R)),R}return t}return t}return t}let i=`${r}/resources/${encodeURIComponent(t)}`;const s=[];if(e!=null&&e.withToken&&s.push(`token=${this.getResourceToken()}`),e!=null&&e.downloadFileName&&s.push(`&fileName=${encodeURIComponent(e.downloadFileName)}`),s.length>0){const c=s.join("&");i+=`?${c}`}return i}reAuth(){this.connection.reAuth()}}function tO(){return{blocks:[{id:it(),type:"text",text:[]}],comments:{},meta:{}}}const _C=D("block-ids");class eO{constructor(){m(this,"ids",new Map)}onInsertBlock(t){const e=Array.from(this.ids.keys()).sort((i,s)=>s-i);for(let i=0;i<e.length;i++){const s=e[i];if(s>=t){const o=this.ids.get(s);p(_C,o!==void 0,"old id is not exists"),this.ids.delete(s),this.ids.set(s+1,o)}}const r=it();this.ids.set(t,r)}onDeleteBlock(t){this.ids.delete(t);const e=Array.from(this.ids.keys()).sort((r,i)=>r-i);for(let r=0;r<e.length;r++){const i=e[r];if(i>t){const s=this.ids.get(i);p(_C,s!==void 0,"old id is not exists"),this.ids.delete(i),this.ids.set(i-1,s)}}}getId(t){let e=this.ids.get(t);return e||(e=it(),this.ids.set(t,e)),e}getById(t){return Array.from(this.ids.entries()).find(([,e])=>e===t)}}class nO{constructor(){m(this,"ids",new Map)}getContainerIds(t){let e=this.ids.get(t);return e||(e=new eO,this.ids.set(t,e)),e}onInsertBlock(t,e){this.getContainerIds(t).onInsertBlock(e)}onDeleteBlock(t,e){this.getContainerIds(t).onDeleteBlock(e)}getBlockId(t,e){return this.getContainerIds(t).getId(e)}getBlockIndexById(t){const e=Array.from(this.ids.entries());for(let r=0;r<e.length;r++){const i=e[r],s=i[1].getById(t);if(s)return{containerId:i[0],blockIndex:s[0]}}return p(_C,!1,"fault error: failed to get block index"),{containerId:"error",blockIndex:-1}}}class ey{constructor(t=new Set,e=new Map){this.deletedKeys=t,this.insertedValues=e}insert(t,e){this.insertedValues.set(t,e)}delete(t){this.deletedKeys.add(t)}toDocBlockDelta(){const t={};return this.insertedValues.forEach((e,r)=>{t[r]=e}),{insert:t,delete:Array.from(this.deletedKeys)}}}const MC=D("op-parse-handler");class rO{constructor(t,e){m(this,"actions",[]);this.outerHandler=t,this.local=e}pushActions(t){if(!t.containerId){this.actions.push(t);return}const r={...t,containerId:(i=>i==="blocks"?"root":i)(t.containerId)};this.actions.push(r)}onDeleteBlock(t,e){this.pushActions({type:"deleteBlock",containerId:t,blockIndex:e})}onInsertBlock(t,e,r){this.pushActions({type:"insertBlock",containerId:t,blockIndex:e,data:r})}onDeleteBlockData(t,e,r){this.pushActions({type:"deleteBlockData",containerId:t,blockIndex:e,key:r})}onInsertBlockData(t,e,r,i){this.pushActions({type:"insertBlockData",containerId:t,blockIndex:e,key:r,value:i})}onUpdateBlockText(t,e,r){this.pushActions({type:"updateBlockText",containerId:t,blockIndex:e,richTextData:r})}onDeleteContainer(t){this.pushActions({type:"deleteContainer",containerId:t})}onCreateContainer(t,e){this.pushActions({type:"createContainer",containerId:t,data:e})}onDeleteComment(t){this.pushActions({type:"deleteComment",commentId:t})}onCreateComment(t){this.pushActions({type:"createComment",commentId:t})}onUpdateComment(t){this.pushActions({type:"updateComment",commentId:t})}end(){const t=this.actions,e=new Set,r=new Map,i=new nO,s=t.filter(o=>o.type==="deleteBlock"||o.type==="deleteBlockData");for(const o of s)if(o.type==="deleteBlock"){const l=o,c=i.getBlockId(l.containerId,l.blockIndex);i.onDeleteBlock(l.containerId,l.blockIndex);const d=r.get(c);d&&(MC.debug(`ignore update object data before delete block: ${JSON.stringify(d)}`),r.delete(c));const h=`${l.containerId}-${l.blockIndex}`;e.add(h),this.outerHandler.onDeleteBlock(l.containerId,l.blockIndex,this.local)}else if(o.type==="deleteBlockData"){const l=o,c=`${l.containerId}-${l.blockIndex}`;if(e.has(c)){MC.warn("delete block data after delete block, ignore it");continue}const d=i.getBlockId(l.containerId,l.blockIndex);let h=r.get(d);h||(h=new ey,r.set(d,h)),h.delete(l.key)}else p(MC,!1,`invalid action type, ${o.type}`);this.actions.forEach(o=>{if(o.type==="deleteContainer"){const l=o;this.outerHandler.onDeleteContainer(l.containerId,this.local)}else if(o.type==="deleteComment"){const l=o;this.outerHandler.onDeleteComment(l.commentId,this.local)}}),this.actions.forEach(o=>{if(o.type==="createContainer"){const l=o;this.outerHandler.onCreateContainer(l.containerId,l.data,this.local)}}),this.actions.forEach(o=>{if(o.type==="insertBlock"){const l=o;this.outerHandler.onInsertBlock(l.containerId,l.blockIndex,l.data,this.local)}else if(o.type==="insertBlockData"){const l=o,c=i.getBlockId(l.containerId,l.blockIndex);let d=r.get(c);d||(d=new ey,r.set(c,d)),d.insert(l.key,l.value)}else if(o.type==="updateBlockText"){const l=o;this.outerHandler.onUpdateBlockText(l.containerId,l.blockIndex,l.richTextData,this.local)}else if(o.type==="createComment"){const l=o;this.outerHandler.onCreateComment(l.commentId,this.local)}else if(o.type==="updateComment"){const l=o;this.outerHandler.onUpdateComment(l.commentId,this.local)}}),Array.from(r.entries()).forEach(([o,l])=>{const{containerId:c,blockIndex:d}=i.getBlockIndexById(o);this.outerHandler.onUpdateBlockData(c,d,l.toDocBlockDelta(),this.local)})}}const ln=D("op-parser");class ny{}class UC{constructor(t){m(this,"key");this.key=t}}function iO(n,t,e){const r=t.concat(),i=r[0];if(typeof i!="number"||(r.shift(),r.length===1))return!1;const s=r[0];if(typeof s!="object"||!s.i||Object.keys(s).length!==1)return!1;for(let l=1;l<r.length;l++){const c=r[l];if(!Array.isArray(c)||c.length!==2||typeof c[0]!="string")return!1;const h=c[1];if(typeof h!="object"||h.i===void 0||Object.keys(h).length!==1)return!1}const o=s.i;p(ln,o.id,"block id is required"),p(ln,o.type,"block type is required");for(let l=1;l<r.length;l++){const c=r[l],d=c[0],h=c[1];o[d]=h.i}return e.onInsertBlock(n,i,o),!0}function OC(n,t,e,r){if(e==="upsert"&&iO(n,t,r))return;p(ln,Array.isArray(t),`invalid block op: ${n}, ${JSON.stringify(t)}`);const i=t.concat(),s=i[0];i.shift();const o=[];for(;i.length>0;){const l=i[0];if(l==="text"){const c=i[1];if(p(ln,typeof c=="object",`invalid block op: ${n}, ${JSON.stringify(t)}`),p(ln,c.et==="rich-text",`invalid block op: ${n}, ${JSON.stringify(t)}`),i.splice(0,2),e==="upsert"){const h=c.e;r.onUpdateBlockText(n,s,h)}p(ln,i.length===0,`invalid block ops.length !== 0, ${JSON.stringify(i)}`)}else if(Array.isArray(l)){p(ln,l.length===2,`invalid block op: data.length !== 2, ${JSON.stringify(l)}`);const c=l[0];p(ln,typeof c=="string",`invalid block op: key ${JSON.stringify(c)}`);const d=l[1];if(c==="text"){if(p(ln,typeof d=="object",`invalid opData type, ${JSON.stringify(d)}`),d.i&&e==="upsert"&&r.onInsertBlockData(n,s,c,d.i),d.r&&e==="remove"&&r.onDeleteBlockData(n,s,c),d.et==="rich-text"&&e==="upsert"){const C=d.e;r.onUpdateBlockText(n,s,C)}}else e==="remove"&&d.r&&o.push(new UC(c)),e==="upsert"&&d.i&&r.onInsertBlockData(n,s,c,d.i);i.shift()}else if(typeof l=="object"){const c=l;e==="remove"&&c.r&&o.push(new ny),e==="upsert"&&c.i&&r.onInsertBlock(n,s,c.i),i.shift()}else{p(ln,typeof l=="string","data is not string"),p(ln,l!=="text","data !== 'text'"),p(ln,i.length===2,`invalid block op: ops.length !== 2, ${JSON.stringify(i)}`);const c=l,d=i[1];e==="remove"&&d.r&&o.push(new UC(c)),e==="upsert"&&d.i&&r.onInsertBlockData(n,s,c,d.i),i.splice(0,2)}}o.reverse(),o.forEach(l=>{l instanceof ny?r.onDeleteBlock(n,s):l instanceof UC?r.onDeleteBlockData(n,s,l.key):p(ln,!1,`invalid action type: ${typeof l}, ${JSON.stringify(l)}`)})}function sO(n,t,e){ln.warn(`unsupported meta op, ${JSON.stringify(n)}`)}function oO(n,t,e){const r=n[1],i=n[2];p(ln,r,`invalid comment op, no commentId: ${JSON.stringify(n)}`),p(ln,i,`invalid comment op, no actions: ${JSON.stringify(n)}`),typeof i=="string"?ln.error(`unknown comment op, ${JSON.stringify(n)}`):i.i&&i.r?t==="upsert"&&e.onUpdateComment(r):i.i?t==="upsert"&&e.onCreateComment(r):i.r?t==="remove"&&e.onDeleteComment(r):ln.error(`unknown comment op, ${JSON.stringify(n)}`)}function NC(n,t,e){const r=n[0];if(Array.isArray(r)){r.forEach(o=>{NC(o,t,e)});return}const i=r;if(p(ln,typeof i=="string",`invalid container id: ${JSON.stringify(n)}`),i==="meta"){sO(n);return}if(i==="comments"){oO(n,t,e);return}const s=i;if(Array.isArray(n[1]))t==="remove"?n.slice(1).reverse().forEach(o=>{OC(s,o,t,e)}):n.slice(1).forEach(o=>{OC(s,o,t,e)});else if(typeof n[1]=="object"){const o=n[1];o.r&&t==="remove"&&e.onDeleteContainer(s),o.i&&t==="upsert"&&e.onCreateContainer(s,o.i)}else p(ln,typeof n[1]=="number",`invalid ops[1], not a number: ${JSON.stringify(n)}`),OC(s,n.slice(1),t,e)}function PC(n,t,e){const r=new rO(t,e);for(let i=0;i<2;i++){const s=i===0?"remove":"upsert",o=At.default(n),l=o[0];Array.isArray(l)?o.forEach(c=>{NC(c,s,r)}):NC(o,s,r)}r.end()}const lO=D("sharedb-comments");function FC(n){const t=n.blocks;p(lO,t,"no comment blocks");const e={blocks:{root:t},meta:{},comments:{}};return Object.entries(n).forEach(([r,i])=>{Array.isArray(i)&&(e.blocks[r]=i)}),At.default(e)}function ry(n){const{id:t,groupId:e,userId:r,displayName:i,avatarUrl:s,abstract:o,created:l,modified:c}=n;return{id:t,groupId:e,userId:r,displayName:i,avatarUrl:s,abstract:o,created:l,modified:c}}function KC(n,t){const e=VM(t),{comments:r,meta:i,blocks:s,...o}=e,l={...n,blocks:s,...o},c=At.default(l);return delete c.children,c}const Be=D("sharedb-doc/doc-container"),iy="ot-json1";Zh.type.registerSubtype($M.type),Zh.type.name=iy,Zh.type.invert=null;class hd extends Sc{constructor(e,r,i=!0){super();m(this,"doc");m(this,"client");m(this,"localPresence");m(this,"remoteCaretHandler",new FM);m(this,"batching",0);m(this,"status","clean");m(this,"disableLogout");m(this,"destroyed",!1);m(this,"handleNothingPending",()=>{this.setStatus("clean")});m(this,"handleCreate",()=>{this.handleReload("doc created")});m(this,"handleDel",()=>{});m(this,"handleReload",e=>{this.callbacks.forEach(r=>{var i;return(i=r.onRequestReload)==null?void 0:i.call(r,e)})});m(this,"handleReset",async e=>{const r=new Error(`reset doc: ${e}`);r.code="ResetDoc",this.callbacks.forEach(i=>{var s;return(s=i.onError)==null?void 0:s.call(i,r)}),this.destroy()});m(this,"handleWriteConflictError",e=>{this.handleReset(`write conflict: ${e.message}, ${JSON.stringify(e.orgMsg)}`)});m(this,"insertObject",async(e,r,i)=>{const s=[e,r,{i}];return this.submitOp(s)});m(this,"deleteObject",async(e,r)=>{const i=[e,r,{r:!0}];return this.submitOp(i)});m(this,"replaceObject",async(e,r,i)=>{const s=[e,r,{r:!0,i}];return this.submitOp(s)});m(this,"updateObject",async(e,r,i)=>{const s=this.data()[e][r],o=[e,r];return Object.entries(i).forEach(([l,c])=>{if(!pf.default(s[l],c))if(s[l]===void 0){if(c!=null){const d={i:c};o.push([l,d])}}else if(c==null){const d={r:!0};o.push([l,d])}else{const d={r:!0,i:c};o.push([l,d])}}),Object.entries(s).forEach(([l,c])=>{if((i[l]===void 0||i[l]===null)&&c!==void 0){const d={r:!0};o.push([l,d])}}),o.length<=2?Promise.resolve():this.submitOp(o)});m(this,"broadcastMessage",async e=>{const r={type:"custom",data:e,clientId:this.client.clientId};this.localPresence&&this.localPresence.submit(r)});m(this,"data",()=>this.doc.data);m(this,"submitOp",async e=>new Promise((r,i)=>{if(this.destroyed){Be.warn("submit op after destroyed");return}this.setStatus("dirty"),this.doc.submitOp(e,{},s=>{s?(Be.error(`invalid op, ${s.message}, ${JSON.stringify(e)}`),i(s),Be.error("Transform detected write conflict, reload editor"),this.handleReset("write conflict")):r()}),this.doc.data||(Be.error("no data after submit op, may be the submitted op is invalid"),this.handleReset(`invalid op, ${JSON.stringify(e)}`))}));m(this,"createDoc",async e=>new Promise((r,i)=>{this.doc.create(e,iy,s=>{s?i(s):r()})}));m(this,"submitInsertChildContainers",async e=>{if(e.length===0)return Promise.resolve();const r=e.map(({containerId:i,blocks:s})=>[Qs(i),{i:s}]);return this.submitOp([r])});m(this,"submitDeleteChildContainer",async e=>{const r=[Qs(e),{r:!0}];return this.submitOp(r)});m(this,"submitInsertBlock",async(e,r,i)=>{const s=[Qs(e),r,{i}];return this.submitOp(s)});m(this,"submitDeleteBlock",async(e,r)=>{const i=[Qs(e),r,{r:!0}];return this.submitOp(i)});m(this,"submitUpdateBlockData",async(e,r,i)=>{if(i.delete.length===0&&Object.keys(i.insert).length===0)return Promise.resolve();const s=[Qs(e),r],o=new Set(i.delete);Object.entries(i.insert).forEach(([c,d])=>{if(o.has(c)){const h={r:!0,i:d};s.push([c,h])}});const l=new Set(Object.keys(i.insert));return i.delete.forEach(c=>{if(l.has(c))return;const d={r:!0};s.push([c,d])}),Object.entries(i.insert).forEach(([c,d])=>{if(o.has(c))return;const h={i:d};s.push([c,h])}),this.submitOp(s)});m(this,"submitUpdateRichText",async(e,r,i)=>{const s=[Qs(e),r,"text",{e:i,et:"rich-text"}];return this.submitOp(s)});m(this,"handleOp",(e,r,i)=>{if(this.destroyed){Be.warn("handleOp: destroyed");return}try{PC(e,this,!!r)}catch(s){throw Be.error(s),s}});this.client=e,this.doc=r,this.doc.preventCompose=!0,this.disableLogout=i,this.registerCallback(this.remoteCaretHandler)}beginBatchUpdate(){return this.doc.preventCompose=!1,this.batching++,this.batching}endBatchUpdate(){return this.batching--,p(Be,this.batching>=0,"invalid call beginBatchUpdate/endBatchUpdate"),this.batching===0&&(this.doc.preventCompose=!0),this.batching}static async load(e){try{const r=new ZU(e.auth,e.serverUrl,e.reauthFunc),i=await r.getDoc(),s=new hd(r,i,e.disableLogout);if(i.type===null){if(e.autoCreateDoc===!1){const o=new Error("doc not exists");throw o.code="DocNotExists",o}await s.createDoc(e.templateData||tO())}return await s.initPresence(),await s.subscribe(),s.initEvents(),s}catch(r){throw Be.error(r),Be.error(`failed to load doc: ${JSON.stringify(r)}`),r}}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.forEach(r=>{var i;return(i=r.onStatusChanged)==null?void 0:i.call(r,e)}))}initEvents(){this.doc.on("nothing pending",this.handleNothingPending),this.doc.on("create",this.handleCreate),this.doc.on("del",this.handleDel),this.client.onAuthError(e=>{this.callbacks.forEach(r=>{var i;return(i=r.onError)==null?void 0:i.call(r,e)})}),this.client.onAuthRecover(()=>{this.callbacks.forEach(e=>{var r;return(r=e.onAuthRecover)==null?void 0:r.call(e)})}),this.client.onWriteConflictError(this.handleWriteConflictError)}clearEvents(){this.doc.off("nothing pending",this.handleNothingPending),this.doc.off("create",this.handleCreate),this.doc.off("del",this.handleDel)}initPresence(){return new Promise((e,r)=>{if(this.localPresence)e();else{const i=this.doc.connection.getPresence(`${this.doc.collection}:${this.doc.id}`);i.on("receive",(s,o)=>{this.onCustomMessage(o)}),i.subscribe(s=>{s?r(s):(this.localPresence=i.create(it()),e())})}})}subscribe(){return new Promise((e,r)=>{this.doc.subscribe(i=>{i?r(i):(this.doc.on("op",this.handleOp),e())})})}toJSON(){return Ys(this.data())}getContainerBlocks(e){const r=this.data();p(Be,r,"no doc data");const i=r[Qs(e)];return p(Be,i,`no container data: ${e}`),At.default(i)}findContainerBlocks(e){const r=this.data();p(Be,r,"no doc data");const i=r[Qs(e)];return i!=null?i:null}getBlockData(e,r){const i=this.data();p(Be,i,"no doc data");const s=i[Qs(e)];p(Be,s,`no container data: ${e}`);const o=s[r];return p(Be,o,`no block data: ${r}`),At.default(o)}localInsertBlock(e,r,i){return this.submitInsertBlock(e,r,i),this.getBlockData(e,r)}localDeleteBlock(e,r){const i=this.getBlockData(e,r);return this.submitDeleteBlock(e,r),i}localUpdateBlockText(e,r,i){const s=this.getBlockData(e,r);p(Be,s.text,"no block text");const o=At.default(s.text);this.submitUpdateRichText(e,r,i);const l=$n.apply(o,i);return p(Be,l,"no block text"),l}localUpdateBlockData(e,r,i){const s=At.default(this.getBlockData(e,r));return this.submitUpdateBlockData(e,r,i),s}localInsertChildContainers(e){this.submitInsertChildContainers(e)}localDeleteChildContainers(e){this.beginBatchUpdate(),e.forEach(r=>{this.submitDeleteChildContainer(r)}),this.endBatchUpdate()}getComments(){return Object.values(this.data().comments).map(r=>ry(r))}getComment(e){return this.data().comments[e]}getCommentDoc(e){const r=this.data().comments[e];return FC(r)}localCreateComment(e,r){const i=KC(e,r),o=["comments",i.id,{i}];return this.submitOp(o)}localDeleteComment(e){const r=["comments",e,{r:!0}];return this.submitOp(r)}localUpdateComment(e,r){const i=KC(e,r),s=["comments",e.id,{r:!0,i}];return this.submitOp(s)}destroy(){var e;this.destroyed=!0,this.clearEvents(),this.clearCallbacks(),this.doc.destroy(),(e=this.localPresence)==null||e.destroy(),this.client.close(!this.disableLogout),this.remoteCaretHandler.destroy()}onDeleteBlock(e,r,i){p(Be,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var o;return(o=s.onDeleteBlock)==null?void 0:o.call(s,Jc(e),r,i)})}onInsertBlock(e,r,i,s){p(Be,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var l;return(l=o.onInsertBlock)==null?void 0:l.call(o,Jc(e),r,i,s)})}onUpdateBlockData(e,r,i,s){p(Be,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var l;return(l=o.onUpdateBlockData)==null?void 0:l.call(o,Jc(e),r,i,s)})}onUpdateBlockText(e,r,i,s){p(Be,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var l;return(l=o.onUpdateBlockText)==null?void 0:l.call(o,Jc(e),r,i,s)})}onDeleteContainer(e,r){p(Be,this.callbacks.length>0,"no callbacks"),p(Be,e!=="root","should not delete root container in doc"),this.callbacks.forEach(i=>{var s;return(s=i.onDeleteChildContainer)==null?void 0:s.call(i,Jc(e),r)})}onCreateContainer(e,r,i){p(Be,this.callbacks.length>0,"no callbacks"),p(Be,e!=="root","should not create root container in doc"),this.callbacks.forEach(s=>{var o;return(o=s.onInsertChildContainer)==null?void 0:o.call(s,Jc(e),r,i)})}onDeleteComment(e,r){p(Be,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var s;return(s=i.onDeleteComment)==null?void 0:s.call(i,e,r)})}onCreateComment(e,r){p(Be,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var s;return(s=i.onCreateComment)==null?void 0:s.call(i,e,r)})}onUpdateComment(e,r){p(Be,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var s;return(s=i.onUpdateComment)==null?void 0:s.call(i,e,r)})}onCustomMessage(e){const r=e;(r==null?void 0:r.type)==="custom"&&(r==null?void 0:r.clientId)!==this.client.clientId?this.callbacks.forEach(i=>{var s;return(s=i.onCustomMessage)==null?void 0:s.call(i,r.data)}):(r==null?void 0:r.type)==="onlineUsers"&&setTimeout(()=>{const i={type:"custom",data:e,clientId:"-"};this.onCustomMessage(i)})}onAuthRecover(){this.callbacks.forEach(e=>{var r;return(r=e.onAuthRecover)==null?void 0:r.call(e)})}async addResources(e){let r=[];return e.forEach(s=>{const o=s.split("|");r.push(...o)}),r=Array.from(new Set(r)),await this.client.getFileUrlsByHashes(r)}async uploadResource(e,r){var s;return{resourceId:await this.client.uploadResource(e,(s=r==null?void 0:r.onProgress)!=null?s:()=>{})}}buildResourceUrl(e,r){return this.client.buildResourceUrl(e,r)}request(e,r){return this.client.request(e,r)}getUser(){const e=this.client.clientId,{permission:r,userId:i,displayName:s,avatarUrl:o}=this.client.auth;return{permission:r,clientId:e,userId:i,displayName:s,avatarUrl:o,rainbowIndex:0}}getRemoteUsers(){return this.remoteCaretHandler.remoteUsers}getVersionHelper(){return this}getVersions(){return this.client.getVersions()}async getVersion(e){const r=await this.client.getVersion(e);return Ys(r)}async getLatestVersion(){const e=await this.client.getLatestVersion();return Ys(e)}async getHistoryData(e,r){const{doc:i,ops:s}=await this.client.getVersionOps(e,r),o=s.map(l=>({user:l.meta.createdBy,data:l}));return{doc:Ys(i),historyData:o}}async getVersionData(e,r){const{doc:i,ops:s}=await this.client.getVersionOps(e,r);return{doc:Ys(i),versionData:s}}async updateVersionExtra(e,r,i){await this.client.updateVersionExtra(e,r,i)}revertVersion(e){return this.client.revertVersion(e)}createVersion(e,r){return this.client.createVersion(e,r)}async recognizeLink(e){return this.client.recognizeLink(e)}parseHistoryData(e,r){PC(e.data.op,r,!0)}getServerMeta(){return{appId:this.client.auth.appId,docId:this.client.auth.docId,serverId:this.client.apiServer()}}triggerReAuth(){this.client.reAuth()}}D("remote-cursor");class sy{constructor(t){m(this,"handleDocSelectionChange",()=>{this.broadcastCaretPos()});m(this,"broadcastCaretPos",Ke.default(()=>{const t={type:"caret",userId:this.editor.doc.getUser().userId,range:this.editor.selection.range.toDocRange()};this.editor.doc.broadcastMessage(t)},300));m(this,"handleRemoteCaretsChanged",t=>{t.forEach(e=>{const r=this.editor.findBlockById(e);r&&this.editor.reloadBlock(r)})});this.editor=t,this.editor.addListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().addListener("remote-carets-change",this.handleRemoteCaretsChanged)}destroy(){this.editor.removeListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().removeListener("remote-carets-change",this.handleRemoteCaretsChanged)}}const oy=D("remote-cursor-decorator");class VC{decorateText(t,e,r){const i=t.doc.getRemoteUsers();if(!i)return{};const s=new Map,{containerId:o,blockIndex:l}=e[e.length-1];p(oy,typeof o=="string","invalid path containerId"),p(oy,typeof l=="number","invalid path blockIndex");const c=t.doc.getBlockData(o,l),d=Vn(r);return i.getSimpleCursors(c.id).forEach((C,E)=>{E>d&&(E=d);const A=C.map(R=>({id:it(),type:"remote-cursor",name:R.user.displayName,time:R.time,rainbowIndex:R.user.rainbowIndex})),v=s.get(E);v?v.push(...A):s.set(E,A)}),{insertions:s}}}const $C=D("sharedb-doc/share-db-server"),aO=Bb.default.create();class cO{constructor(t,e){m(this,"auth");m(this,"clientId",it());this.serverUrl=e,this.auth=t}editorServer(){const t=this.apiServer(),e=`/${this.auth.appId}/${this.auth.docId}`;return p($C,t.endsWith(e),`invalid api server: ${t}, ${e}`),t.substr(0,t.length-e.length)}apiServer(){const t=`${this.serverUrl}/${this.auth.appId}/${this.auth.docId}`;if(t.startsWith("ws://"))return`http://${t.substring(5)}`;if(t.startsWith("wss://"))return`https://${t.substring(6)}`;throw new Error(`invalid server url: ${t}`)}getBaseURL(){const t=new URL(this.apiServer());return`${t.protocol}//${t.host}${t.pathname}`}getBase64BaseURL(){return qi(this.getBaseURL())}async request(t,e){var s;const r=this.auth.token,i=e||{};i.url=t,i.headers||(i.headers={}),p($C,r,"no token"),i.headers={...i.headers,[Ea]:r,[eu]:this.getBase64BaseURL()};try{return await aO(t,i)}catch(o){throw(s=o.response)!=null&&s.data&&(o.responseData=o.response.data),o}}async getVersions(){const e=`${this.apiServer()}/versions?withExtra=true`,i=(await this.request(e)).data.versions;return i.forEach(s=>{s.extra&&(s.extra=JSON.parse(s.extra))}),i}async getVersion(t){const r=`${this.apiServer()}/versions/${t}`,i=await this.request(r);return JSON.parse(i.data.data)}async getLatestVersion(){const e=`${this.apiServer()}/versions/latest`,r=await this.request(e);return JSON.parse(r.data.data)}async getVersionOps(t,e){let i=`${this.apiServer()}/versions/before/${t}?withOp=true`;e!==void 0&&e!==0&&(i+=`&from=${e}`);const s=await this.request(i),o=s.data.ops,l=Tb.default(o,h=>!!h.create);let c=null;l!==-1&&(c=o[l],o.splice(0,l+1));let d;return c?(p($C,c.create,"no createDoc.create"),d=c.create.data):d=JSON.parse(s.data.data),d.blocks||(d.blocks=[]),{doc:d,ops:s.data.ops}}async updateVersionExtra(t,e,r){const s=`${this.apiServer()}/versions/${t}/tags/${e}`;await this.request(s,{method:"post",data:{extra:JSON.stringify(r)}})}async revertVersion(t){const r=`${this.apiServer()}/versions/revert/${t}`;await this.request(r,{method:"post",data:{}})}async createVersion(t,e){const i=`${this.apiServer()}/versions`;return(await this.request(i,{method:"post",data:{publish:e,tag:t}})).data}buildResourceUrl(t,e){if(!t)return"";if(t.startsWith("https:")||t.startsWith("http:")||t.startsWith("file:")||t.startsWith("data:")||t.startsWith("blob:"))return t;let i=`${this.apiServer()}/resources/${encodeURIComponent(t)}`;const s=[];if(e!=null&&e.withToken,e!=null&&e.downloadFileName&&s.push(`&fileName=${encodeURIComponent(e.downloadFileName)}`),s.length>0){const o=s.join("&");i+=`?${o}`}return i}}const uO=D("sharedb-doc/share-db-server");function ly(n){const t=new URL(n);return`${t.protocol==="wss:"?"https:":"http:"}//${t.host}${t.pathname}`}function fO(n){return qi(ly(n))}class hm extends Sc{constructor(e){super();m(this,"remoteUsers",new td);m(this,"client");this.options=e,this.client=new cO(e.auth,e.serverUrl)}destroy(){}buildResourceUrl(e,r){return this.client.buildResourceUrl(e,r)}getRemoteUsers(){return this.remoteUsers}getVersionHelper(){return this}getVersions(){return this.client.getVersions()}async getVersion(e){const r=await this.client.getVersion(e);return Ys(r)}async getLatestVersion(){const e=await this.client.getLatestVersion();return Ys(e)}async getHistoryData(e,r){const{doc:i,ops:s}=await this.client.getVersionOps(e,r),o=s.map(l=>({user:l.meta.createdBy,data:l}));return{doc:Ys(i),historyData:o}}async getVersionData(e,r){const{doc:i,ops:s}=await this.client.getVersionOps(e,r);return{doc:Ys(i),versionData:s}}async updateVersionExtra(e,r,i){await this.client.updateVersionExtra(e,r,i)}revertVersion(e){return this.client.revertVersion(e)}createVersion(e,r){return this.client.createVersion(e,r)}parseHistoryData(e,r){PC(e.data.op,r,!0)}getServerMeta(){return{appId:this.client.auth.appId,docId:this.client.auth.docId,serverId:this.client.apiServer()}}static async auth(e,r){p(uO,e.token,"no auth token");const i=`${ly(r)}/auth`,s=await window.fetch(i,{method:"GET",headers:{[Ea]:e.token,[eu]:fO(r)},credentials:"include"});if(s.status!==200)throw new Error("http auth error");return await s.json()}static async load(e){const r=`${e.serverUrl}/${e.auth.appId}/${e.auth.docId}`;return await this.auth(e.auth,r),new hm(e)}}class ay extends Fe.TypedEmitter{constructor(t){super(),this.editor=t,this.editor.doc.registerCallback(this)}handleChild(t,e,r){if(ie(mi(this.editor,t)))return;const i=this.editor.getBlockByIndex(t,e),s=nt(this.editor.getContainerById(t));s&&this.emit("change",this.editor,{containerId:t,blockIndex:e},s,i,r)}onUpdateBlockData(t,e){this.handleChild(t,e,"data-change")}onUpdateBlockText(t,e){this.handleChild(t,e,"text-change")}onInsertBlock(t,e){ie(mi(this.editor,t))||this.emit("insert",this.editor,{containerId:t,blockIndex:e})}onDeleteBlock(t,e){this.handleChild(t,e,"remove")}destroy(){this.editor.doc.unregisterCallback(this)}}function cy(n,t){const e=n.addCustom("child-block-tracker",()=>new ay(n));e.addListener("change",t),e.addListener("insert",t)}function uy(n,t){const e=n.addCustom("child-block-tracker",()=>new ay(n));e.removeListener("change",t),e.removeListener("insert",t)}const _lt="",dO={colorPalette:{colorDesc:"\u5B57\u4F53\u989C\u8272",name:"\u6587\u672C\u989C\u8272",backgroundDesc:"\u80CC\u666F\u989C\u8272",reset:"\u6062\u590D\u9ED8\u8BA4"},search:{emptyTips:"\u6682\u65E0\u641C\u7D22\u7ED3\u679C"}},hO={colorPalette:{colorDesc:"Text color",name:"Text color",backgroundDesc:"Background color",reset:"Restore default values"},search:{emptyTips:"No results found"}},mO={colorPalette:{colorDesc:"\u30D5\u30A9\u30F3\u30C8\u306E\u8272",name:"\u30C6\u30AD\u30B9\u30C8\u306E\u8272",backgroundDesc:"\u80CC\u666F\u8272",reset:"\u30C7\u30D5\u30A9\u30EB\u30C8\u306B\u623B\u3059"},search:{emptyTips:"\u691C\u7D22\u7D50\u679C\u304C\u3042\u308A\u307E\u305B\u3093"}};_.mergeLang({"zh-CN":dO,"en-US":hO,"ja-JP":mO});const Mlt="";D("button");function Xr(n,t,e,r,i){const s=B("button",["editor-button"],null);return s.setAttribute("data-button-id",n),i&&s.setAttribute(`data-editor-tooltip-${i}`,t),e?typeof e=="string"?e.startsWith("<")?s.innerHTML=e:s.innerText=e:s.appendChild(e):s.innerText=t,r&&(r.indexOf("checked")!==-1&&q(s,"checked"),r.indexOf("disabled")!==-1&&(s.disabled=!0),r.indexOf("primary")!==-1&&q(s,"primary")),s}const Ult="",mm=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
31
|
+
`)}return Tf([{type:"text/plain",data:new Blob([r],{type:"text/plain"})}]),!0}const nM=Object.freeze(Object.defineProperty({__proto__:null,editorHandleEnter:q5,editorHandleDelete:X5,editorHandleBackspace:Y5,editorHandleInsertBr:Q5,editorHandlePastePlainText:J5,isSelectedCodeTextBlock:Z5,getSelectedCodeBlockMarkdown:tT,editorHandleCopyMarkdown:CC},Symbol.toStringTag,{value:"Module"})),nm={ArrowDown:u5,ArrowUp:c5,ArrowLeft:l5,ArrowRight:a5,"Shift+ArrowDown":f5,"Shift+ArrowUp":m5,"Shift+ArrowLeft":d5,"Shift+ArrowRight":h5,"CtrlOrCmd+ArrowLeft":p5,"CtrlOrCmd+ArrowRight":C5,"CtrlOrCmd+Shift+ArrowLeft":E5,"CtrlOrCmd+Shift+ArrowRight":A5,"CtrlOrCmd+ArrowUp":x5,"CtrlOrCmd+ArrowDown":aC,"CtrlOrCmd+Shift+ArrowUp":b5,"CtrlOrCmd+Shift+ArrowDown":cC,"CtrlOrCmd+A":uC,Home:R5,End:w5,"Shift+Home":y5,"Shift+End":k5,PageUp:_5,PageDown:M5,"Shift+PageUp":O5,"Shift+PageDown":N5,"CtrlOrCmd+Z":j_,"CtrlOrCmd+Shift+Z":z_,Enter:q5,Delete:X5,Backspace:Y5,"Shift+Enter":Q5,"CtrlOrCmd+Shift+V":J5,"CtrlOrCmd+Shift+C":CC};function eT(n,t){return n.shortcuts.handleKeyboardEvents(n,t)!==void 0}function nT(n,t,e){if(t.type==="embed"){const s=t.embedData,o=s.src;if(o&&typeof o=="string"){const l=e.get(o);if(l)s.src=l;else{let c="";o.split("|").forEach(h=>{const C=e.get(h);C&&(c+=c?`|${C}`:`${C}`)}),c&&(s.src=c)}}return}const r=t.text;r&&r.forEach(s=>{if(s.attributes&&s.attributes.src&&typeof s.attributes.src=="string"){const o=e.get(s.attributes.src);o&&(s.attributes.src=o)}});const i=t.children;i&&i.forEach(s=>{n.blocks[s].forEach(l=>{nT(n,l,e)})})}function rT(n,t,e){if(e.size===0)return;t.blocks.root.forEach(i=>{const s=n.editorBlocks.getBlockClass(i.type);s.replaceResources?s.replaceResources(i,e):nT(t,i,e)})}async function rM(n,t){let e=t.filter(o=>o.indexOf(":")===-1);const r=[];e.forEach(o=>{const l=o.split("|");r.push(...l)}),e=Array.from(new Set(r)),e=r;const i=await n.doc.addResources(e),s=new Map;if(e.length!==i.length)return s;for(let o=0;o<e.length;o++)s.set(e[o],i[o]);return s}function iM(n,t){var l,c,d,h;const r=t.meta.serverId;if(!r||typeof r!="string")return!1;const i=(c=(l=n.doc).getServerMeta)==null?void 0:c.call(l);if(!i)return!1;const s=/.*(?=\/)/;return((d=(i.serverId||"").match(s))==null?void 0:d[0])===((h=r.match(s))==null?void 0:h[0])}async function EC(n,t){const r=t.meta.resources;if(!r||Object.keys(r).length===0)return;let i=new Map;if(iM(n,t)){const o=Array.from(Object.keys(r));i=await rM(n,o),rT(n,t,i)}const s=new Map;Object.entries(r).forEach(([o,l])=>{i.get(o)===void 0&&o!==l&&s.set(o,l)}),s.size!==0&&rT(n,t,s)}async function sM(n,t,e){await EC(n,t),n.undoManager.runInGroup(()=>{const{start:r,end:i}=n.selection.range,s=n.getBlockById(r.blockId);if(r.blockId===i.blockId&&Se(s)){const o=at(s),l=n.getBlockIndex(s),[c]=n.insertDocAt(o,l+1,t,e);c&&n.selection.selectBlock(c,Ct(n,c))}else{n.clearSelectedContents();const{block:o,offset:l}=jc(n);n.insertDoc(o,l,t,e)}})}const oM=["text/x-ones-editor-doc","image/*","text/office-html","text/html","text/plain","text/markdown","*"];function lM(n){let t;for(const e of oM)if(t=n[e],t)break;return t||null}class aM{constructor(t){m(this,"editor");m(this,"handlers",[]);m(this,"hookExecutionAttempt",(t,e,r)=>{for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleBeforeCopy){const o=s.handleBeforeCopy(this.editor,e,r);if(o===!0)return!0;if(typeof o=="object"&&o!=null)return o}}});m(this,"onPasteText",async(t,e)=>{const r=new DataTransfer;r.setData("text/plain",t);const i=await this.editor.dataConverter.fromData(this.editor,r,e);if(i){const s=[];this.pasteDocs(i,null,s)}});m(this,"onBlur",Ke.default(()=>{const t=this.editor.selection.range;if(!t.isCollapsed()){let e=null;if(ua(t.anchor)){const r=t.anchor.childContainerId,i=mi(this.editor,r);e=a3(this.editor,i)}else e=this.editor.getBlockById(t.anchor.blockId);if(e){let r=t.start;t.isSimple()||(r=ht(e,0,"normal")),this.editor.selection.setSelection(r,void 0,{noScroll:!0})}}this.removeActiveForBlur()},200));m(this,"removeActiveForBlur",Ke.default(()=>{ut(this.editor.rootElement,"active")},200));this.editor=t}onInsertText(t,e){if(!ot(this.editor,this.editor.getFocusedBlock()))return;const{containerId:r,blockIndex:i,offset:s}=jc(this.editor);this.handleBeforeInsertText(r,i,s,e)||(this.defaultInsertText(this.editor,r,i,s,e),this.handleAfterInsertText(r,i,s,e),this.editor.selection.updateLastCaretRect())}onKeyDown(t){if(this.handleBeforeKeyDown(t))return!0;const e=this.defaultHandleKeydown(this.editor,t);return this.handleAfterKeyDown(t)?!0:e}onChanged(t){for(let e=0;e<this.handlers.length;e++){const r=this.handlers[e];r.handleChanged&&r.handleChanged(this.editor,t)}}onRemoteChanged(t){for(let e=0;e<this.handlers.length;e++){const r=this.handlers[e];r.handleRemoteChanged&&r.handleRemoteChanged(this.editor,t)}}onCompositionStart(t){if(!ot(this.editor,this.editor.getFocusedBlock()))return;this.editor.updateCompositionText("",!1);const{containerId:e,blockIndex:r,offset:i}=jc(this.editor);for(let s=0;s<this.handlers.length;s++){const o=this.handlers[s];o.handleCompositionStart&&o.handleCompositionStart(this.editor,e,r,i)}}onUpdateCompositionText(t,e,r){if(!ot(this.editor,this.editor.getFocusedBlock()))return;this.editor.updateCompositionText(e,r),this.editor.selection.caret.update();const{containerId:i,blockIndex:s,offset:o}=jc(this.editor);for(let l=0;l<this.handlers.length;l++){const c=this.handlers[l];c.handleUpdateCompositionText&&c.handleUpdateCompositionText(this.editor,i,s,o,r)}this.editor.selection.updateLastCaretRect()}onCopy(t){Z_(this.editor,t,this.hookExecutionAttempt)}onCopyWithoutEvent(){tM(this.editor,this.hookExecutionAttempt)}onCut(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforeCut&&i.handleBeforeCut(this.editor,t)===!0)return}if(this.onCopy(t),this.editor.selection.range.isCollapsed()){const r=this.editor.selection.focusedBlock;Se(r)&&this.editor.deleteBlock(r)}else q0(this.editor)}onPaste(t){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData)return;const e=this.editor.dataConverter.fromData(this.editor,t.clipboardData),r=Array.from(t.clipboardData.files);e.then(async i=>{i&&this.pasteDocs(i,t,r)})}onFocus(){q(this.editor.rootElement,"active"),this.onBlur.cancel(),this.removeActiveForBlur.cancel()}addHandler(t){this.handlers.push(t),this.handlers=this.handlers.sort((e,r)=>{var o,l;const i=(o=e.order)!=null?o:1;return((l=r.order)!=null?l:1)-i})}removeHandler(t){const e=this.handlers.indexOf(t);e!==-1&&this.handlers.splice(e)}handleBeforeInsertText(t,e,r,i){for(let s=0;s<this.handlers.length;s++){const o=this.handlers[s];if(o.handleBeforeInsertText&&o.handleBeforeInsertText(this.editor,t,e,r,i))return!0}return!1}handleAfterInsertText(t,e,r,i){for(let s=0;s<this.handlers.length;s++){const o=this.handlers[s];if(o.handleAfterInsertText&&o.handleAfterInsertText(this.editor,t,e,r,i))return!0}return!1}handleBeforeKeyDown(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforeKeyDown&&i.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterKeyDown&&i.handleAfterKeyDown(this.editor,t))return!0}return e}handleAfterKeyDown(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforeKeyDown&&i.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterKeyDown&&i.handleAfterKeyDown(this.editor,t))return!0}return e}defaultInsertText(t,e,r,i,s){G1(this.editor,s)}defaultHandleKeydown(t,e){return eT(this.editor,e)?(e.preventDefault(),e.stopPropagation(),!0):!1}async pasteDoc(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforePasteDoc&&await i.handleBeforePasteDoc(this.editor,t))return}const e={blockIdMap:new Map,containerIdMap:new Map,boxIdMap:new Map};await sM(this.editor,t,e);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterPasteDoc&&await i.handleAfterPasteDoc(this.editor,t,e))return}}async pasteDocs(t,e,r){for(let s=0;s<this.handlers.length;s++){const o=this.handlers[s];if(o.handleBeforePaste&&await o.handleBeforePaste(this.editor,e,t,r))return}const i=lM(t);if(!!i){await this.pasteDoc(i);for(let s=0;s<this.handlers.length;s++){const o=this.handlers[s];if(o.handleAfterPaste&&await o.handleAfterPaste(this.editor,e,t))return}}}destroy(){this.handlers.forEach(t=>{var e;(e=t.destroy)==null||e.call(t,this.editor)}),this.handlers=[]}forEach(t){this.handlers.forEach(t)}}function cM(n,t,e){const r=Xo(t,e);return r.remove(),r}D("copy-dom-attributes");const iT=["onabort","onanimationcancel","onanimationend","onanimationiteration","onanimationstart","onauxclick","onblur","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","onformdata","ongotpointercapture","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onlostpointercapture","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onpause","onplay","onplaying","onpointercancel","onpointerdown","onpointerenter","onpointerleave","onpointermove","onpointerout","onpointerover","onpointerup","onprogress","onratechange","onreset","onresize","onscroll","onsecuritypolicyviolation","onseeked","onseeking","onselect","onselectionchange","onselectstart","onslotchange","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","ontouchcancel","ontouchend","ontouchmove","ontouchstart","ontransitioncancel","ontransitionend","ontransitionrun","ontransitionstart","onvolumechange","onwaiting","onwebkitanimationend","onwebkitanimationiteration","onwebkitanimationstart","onwebkittransitionend","onwheel"];function uM(n,t){for(let l=0;l<iT.length;l++){const c=iT[l];t[c]=n[c]}const e=n.attributes,r=t.attributes,i=[],s=[];for(let l=0;l<e.length;l++){const c=e[l],d=r.getNamedItem(c.name);d?d.value!==c.value&&(d.value=c.value,s.push(c)):i.push(c)}const o=[];for(let l=0;l<r.length;l++){const c=r[l];e.getNamedItem(c.name)||o.push(c)}i.forEach(l=>{t.setAttribute(l.name,l.value)}),s.forEach(l=>{t.setAttribute(l.name,l.value)}),o.forEach(l=>{t.removeAttribute(l.name)})}function sT(n){const t=Array.from(n.childNodes).filter(e=>!kv(e));return t.forEach(e=>{e.remove()}),t}function oT(n,t,e){var d;const r=n.getContainerById(t),i=Xo(r,e),s=Jo(i),o=n.doc.getBlockData(t,e),l=le(n,i);if((d=l==null?void 0:l.handleUpdateBlock)==null?void 0:d.call(l,n,i,o))n.editorBlockRenders.updateBlock(n,s,i,o);else{const h=n.editorBlocks.createBlock(s,r,o),C=sT(h);sT(i),C.forEach(A=>{i.appendChild(A)});const E=x0(h);if(E){const A=x0(i);A&&A.remove(),i.appendChild(E)}uM(h,i)}Kv(n,i,o),n.blockHooks.forEach(h=>{var C;(C=h.update)==null||C.call(h,n,s,r,i,o)}),setTimeout(()=>{n.selection.updateSelection(null)})}const fM=D("transform-selection");function lT(n,t,e,r){const{range:i}=n.selection,{anchor:s,focus:o}=i;if(s.blockId!==t&&o.blockId!==t)return i;p(fM,s.isSimple()&&o.isSimple(),"invalid text pos type");let l=s;if(s.blockId===t){const d=$n.transformCursor(s.offset,e,r);l=ht(t,d,"normal")}let c=o;if(o.blockId===t){const d=$n.transformCursor(o.offset,e,r);c=ht(t,d,"normal")}return mn(n,{anchor:l,focus:c})}const dM=D("handle-block-text-changed");function hM(n,t,e,r,i){const s=n.getContainerById(t),o=Xo(s,e),l=n.doc.getBlockData(t,e);if(p(dM,l.text,"no block text"),vv(n,o).setBlockText(n,o,l.text),!i){const c=lT(n,l.id,r,i);n.selection.setRange(c,{noScroll:!0})}}function mM(n,t){const e=At.default(n);return t.delete.forEach(i=>{delete e[i]}),{...e,...t.insert}}function aT(n,t,e,r){const i=le(n,t);i.handleDeleteBlock&&i.handleDeleteBlock(n,t,e,r),n.emit("blockDeleted",n,t,e,r)}function gM(n,t,e,r){const i=n.getBlockByIndex(t,e);i.querySelectorAll('[data-type="editor-block"]').forEach(s=>{aT(n,s,r,{child:!0})}),aT(n,i,r,{child:!1})}const vi=D("editor-doc");class pM extends Sc{constructor(e,r,i){super();m(this,"localEvents",[]);this.editor=e,this.externalDoc=r,this.externalDoc.registerCallback(this),this.registerLocalEvents(i)}beginBatchUpdate(){return this.externalDoc.beginBatchUpdate()}endBatchUpdate(){return this.externalDoc.endBatchUpdate()}registerLocalEvents(e){this.localEvents.push(e)}toJSON(){return this.externalDoc.toJSON()}getVersionHelper(){var r,i;return(i=(r=this.externalDoc).getVersionHelper)==null?void 0:i.call(r)}getContainerBlocks(e){return this.externalDoc.getContainerBlocks(e)}findContainerBlocks(e){return this.externalDoc.findContainerBlocks(e)}getBlockData(e,r){return this.externalDoc.getBlockData(e,r)}verifyBlockWritable(e,r){const i=this.editor.getBlockByIndex(e,r);p(vi,this.editor.isBlockWritable(i),`block is not writable, ${e}, ${r}`)}localUpdateBlockText(e,r,i,s){p(vi,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(e,r);const o=this.getBlockData(e,r),l=o.text;p(vi,l,`no text, ${e}, ${r}`);const c=lT(this.editor,o.id,i,!0),d=$n.apply(l,i);this.localEvents.forEach(C=>C.onBeforeUpdateBlockText(e,o.id,l,d,c.toDocRange()));const h=this.externalDoc.localUpdateBlockText(e,r,i);return this.editor.selection.setRange(c,s),h}localUpdateBlockData(e,r,i,s){p(vi,!this.editor.readonly,"editor is readonly");const o=this.editor.getBlockByIndex(e,r);if(!this.editor.isBlockWritable(o)){const h=Array.from(i.delete).filter(E=>E!=="comments"),C=Object.keys(i.insert).filter(E=>E!=="comments");(h.length>0||C.length>0)&&p(vi,!1,`block is not writable, comment supported only, ${JSON.stringify(i)}}`)}const l=At.default(this.getBlockData(e,r)),c=At.default(mM(l,i));this.localEvents.forEach(h=>h.onBeforeUpdateBlockData(e,l.id,l,c,s));const d=this.externalDoc.localUpdateBlockData(e,r,i,s);return this.editor.selection.setRange(Zo(this.editor,s)),d}localInsertBlock(e,r,i,s,o){p(vi,!this.editor.readonly,"editor is readonly"),this.localEvents.forEach(c=>c.onBeforeInsertBlock(e,r,i,s));const l=this.externalDoc.localInsertBlock(e,r,i,s);return o!=null&&o.noFocus||this.editor.selection.setRange(Zo(this.editor,s),o),l}localDeleteBlock(e,r,i){p(vi,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(e,r);const s=At.default(this.getBlockData(e,r));this.localEvents.forEach(l=>l.onBeforeDeleteBlock(e,r,s,i));const o=this.externalDoc.localDeleteBlock(e,r,i);return this.editor.selection.setRange(Zo(this.editor,i)),o}localDeleteChildContainers(e){return p(vi,!this.editor.readonly,"editor is readonly"),e.forEach(r=>{const i=At.default(this.getContainerBlocks(r));this.localEvents.forEach(s=>s.onBeforeDeleteChildContainer(r,i))}),this.externalDoc.localDeleteChildContainers(e)}localInsertChildContainers(e){p(vi,!this.editor.readonly,"editor is readonly");const r=At.default(e);r.forEach(i=>{this.localEvents.forEach(s=>s.onBeforeInsertChildContainer(i.containerId,i.blocks))}),this.externalDoc.localInsertChildContainers(r)}onRequestReload(e){vi.debug(`reload doc: ${e}`),this.editor.reload(),this.callbacks.forEach(i=>{var s;return(s=i.onRequestReload)==null?void 0:s.call(i,e)});const r=!1;this.editor.emit("docChanged",this.editor,r)}onUpdateBlockText(e,r,i,s){this.callbacks.forEach(o=>{var l;return(l=o.onUpdateBlockText)==null?void 0:l.call(o,e,r,i,s)}),hM(this.editor,e,r,i,s),this.editor.emit("docChanged",this.editor,s)}onUpdateBlockData(e,r,i,s){this.callbacks.forEach(o=>{var l;return(l=o.onUpdateBlockData)==null?void 0:l.call(o,e,r,i,s)}),oT(this.editor,e,r),this.editor.emit("docChanged",this.editor,s)}onInsertBlock(e,r,i,s){this.callbacks.forEach(l=>{var c;return(c=l.onInsertBlock)==null?void 0:c.call(l,e,r,i,s)});const o=this.editor.getContainerById(e);II(this.editor,o,r,i),this.editor.emit("docChanged",this.editor,s)}onDeleteBlock(e,r,i){gM(this.editor,e,r,i),this.callbacks.forEach(o=>{var l;return(l=o.onDeleteBlock)==null?void 0:l.call(o,e,r,i)});const s=this.editor.getContainerById(e);cM(this.editor,s,r),this.editor.emit("docChanged",this.editor,i)}onInsertChildContainer(e,r,i){this.callbacks.forEach(s=>{var o;return(o=s.onInsertChildContainer)==null?void 0:o.call(s,e,r,i)})}onDeleteChildContainer(e,r){this.callbacks.forEach(i=>{var s;return(s=i.onDeleteChildContainer)==null?void 0:s.call(i,e,r)})}onCustomMessage(e){this.callbacks.forEach(r=>{var i;return(i=r.onCustomMessage)==null?void 0:i.call(r,e)})}onStatusChanged(e){this.callbacks.forEach(r=>{var i;return(i=r.onStatusChanged)==null?void 0:i.call(r,e)})}onError(e){this.callbacks.forEach(r=>{var i;return(i=r.onError)==null?void 0:i.call(r,e)})}onAuthRecover(){this.callbacks.forEach(e=>{var r;return(r=e.onAuthRecover)==null?void 0:r.call(e)})}uploadResource(e,r){return this.externalDoc.uploadResource(e,r)}addResources(e){return this.externalDoc.addResources(e)}buildResourceUrl(e,r){return this.externalDoc.buildResourceUrl(e,r)}request(e,r){return this.externalDoc.request(e,r)}broadcastMessage(e){return this.externalDoc.broadcastMessage(e)}getUser(){return this.externalDoc.getUser()}getRemoteUsers(){return this.externalDoc.getRemoteUsers()}triggerReAuth(){var e,r;return(r=(e=this.externalDoc).triggerReAuth)==null?void 0:r.call(e)}destroy(){this.externalDoc.destroy(),this.clearCallbacks()}getServerMeta(){var e,r,i;return(i=(r=(e=this.externalDoc).getServerMeta)==null?void 0:r.call(e))!=null?i:{}}reset(e){vi.log("reset doc"),this.externalDoc=e,this.externalDoc.registerCallback(this),this.editor.reload()}}function cT(n,t){if(n.length===0){n.push(t);return}const e=n[n.length-1];if(!e.combinable(t)){n.push(t);return}e.combine(t)}const rm=D("undo-action");class Yc{constructor(t,e,r){m(this,"beforeRange");m(this,"afterRange");this.containerId=e,this.beforeRange=t.selection.range.clone().toDocRange(),this.afterRange=r}undo(t){return!1}redo(t){return!1}combinable(t){return p(rm,t,"no other action"),!1}combine(t){p(rm,!1,"no other")}setAfterRange(t){this.afterRange&&rm.warn("after range has already set"),this.afterRange=t}findContainerById(t,e){return!!t.doc.findContainerBlocks(e)}findBlockById(t,e){const r=t.doc.findContainerBlocks(this.containerId);return r?r.some(i=>i.id===e):!1}checkBlockData(t,e){if(Array.isArray(e.children)){const r=t.doc.toJSON();for(let i=0;i<e.children.length;i++){const s=e.children[i];if(!r.blocks[s])return rm.warn(`container (${s}) not found, deleted by others?`),!1}}return!0}}const Qc=D("block-action");class uT extends Yc{constructor(e,r,i,s,o){super(e,r,o);m(this,"blockData");m(this,"blockIndex");this.blockData=At.default(s),this.blockIndex=i}deleteBlock(e,r){if(!this.findContainerById(e,this.containerId))return Qc.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.findBlockById(e,this.blockData.id))return Qc.warn(`block (${this.blockData.id}) not found, deleted by others?`),!1;if(!e.getContainerById(this.containerId))return!1;const s=e.getBlockById(this.blockData.id);if(!s)return!1;try{p(Qc,this.blockIndex===Rt(s),"invalid block index"),G0(e,s,Zo(e,r))}catch(o){Qc.warn(o.message),e.selection.selectBlock(s,0)}return!0}insertBlock(e,r){if(!this.findContainerById(e,this.containerId))return Qc.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.checkBlockData(e,this.blockData))return!1;try{Gc(e,this.containerId,this.blockIndex,At.default(this.blockData),r)}catch(i){Qc.warn(i.message);const s=e.doc.getContainerBlocks(this.containerId),o=Math.min(s.length-1,this.blockIndex),l=e.getBlockByIndex(this.containerId,o);e.selection.selectBlock(l,0)}return!0}}D("insert-block-action");class CM extends uT{undo(t){return this.deleteBlock(t,this.beforeRange)}redo(t){return this.insertBlock(t,this.afterRange)}}class EM extends uT{undo(t){return this.insertBlock(t,this.beforeRange)}redo(t){return this.deleteBlock(t,this.afterRange)}}class AM extends Yc{constructor(e){super(e,pt(e.rootContainer),e.selection.range.toDocRange());m(this,"actions",[])}addAction(e){cT(this.actions,e),this.afterRange=e.afterRange}undo(e){let r=!1;return this.actions.concat().reverse().forEach(i=>{i.undo(e)&&(r=!0)}),r}redo(e){let r=!1;return this.actions.forEach(i=>{i.redo(e)&&(r=!0)}),r}setAfterRange(e){this.afterRange=e;const r=this.actions[this.actions.length-1];!r||r instanceof Yc&&(r.afterRange||r.setAfterRange(e))}}const ll=D("update-block-data-action");class im extends Yc{constructor(e,r,i,s,o,l){super(e,r,l);m(this,"beforeBlockData");m(this,"afterBlockData");m(this,"blockId");this.blockId=i,p(ll,this.blockId===s.id,"invalid block id"),p(ll,this.blockId===o.id,"invalid block id"),this.beforeBlockData=At.default(s),this.afterBlockData=At.default(o),p(ll,this.beforeBlockData.type===this.afterBlockData.type,"invalid block type")}undo(e){if(!e.findBlockById(this.blockId))return ll.warn(`block (${this.blockId}) not found, deleted by others?`),!1;const r=e.getBlockById(this.blockId);if(!r||!this.checkBlockData(e,this.beforeBlockData))return!1;const i=e.getContainerById(this.containerId);return p(ll,i,"no container"),Y0(e,r,im.toAttributes(this.beforeBlockData),this.beforeRange),!0}redo(e){if(!e.findBlockById(this.blockId))return ll.warn(`block (${this.blockId}) not found, deleted by others?`),!1;p(ll,e,"no editor");const r=e.getBlockById(this.blockId);if(!r||!this.checkBlockData(e,this.beforeBlockData))return!1;const i=e.getContainerById(this.containerId);return p(ll,i,"no container"),Y0(e,r,im.toAttributes(this.afterBlockData),this.afterRange),!0}static toAttributes(e){const r=At.default(e);return delete r.id,delete r.type,r}}const pa=D("update-block-text-action");class Jf extends Yc{constructor(e,r,i,s,o,l){super(e,r,l);m(this,"beforeRichTextData");m(this,"afterRichTextData");m(this,"blockId");m(this,"type");this.blockId=i,this.beforeRichTextData=At.default(s),this.afterRichTextData=At.default(o),this.type=Jf.calType(s,o)}static calType(e,r){p(pa,e,"no old data"),p(pa,r,"no new data");const s=$n.diff(e,r),o=new Set;let l=!1;const c=h=>Qb(h)?`cjk_${h}`:Xb(h)?"number":f0(h)?"space":Yb(h)?"letter":"unknown";let d=!1;return s.forEach(h=>{h.insert?h.insert===" "?o.add("insert_letter"):typeof h.insert=="string"&&h.insert.startsWith(" ")&&h.insert.length>1?(l=!0,d=!0,o.add(`insert_${c(h.insert.substr(1))}`)):o.add(`insert_${c(h.insert)}`):h.delete&&(l?l=!1:o.add("delete"))}),{textType:Array.from(o).join("|"),begin:d}}undo(e){if(!this.findContainerById(e,this.containerId))return pa.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.findBlockById(e,this.blockId))return pa.warn(`block (${this.blockId}) not found, deleted by others?`),!1;if(!e.getContainerById(this.containerId))return!1;const i=e.getBlockById(this.blockId);return i?(X0(e,i,this.beforeRichTextData),!0):!1}redo(e){if(!this.findContainerById(e,this.containerId))return pa.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.findBlockById(e,this.blockId))return pa.warn(`block (${this.blockId}) not found, deleted by others?`),!1;if(!e.getContainerById(this.containerId))return!1;const i=e.getBlockById(this.blockId);return i?(X0(e,i,this.afterRichTextData),!0):!1}combinable(e){if(!(e instanceof Jf)||e.type.begin||this.type.textType!==e.type.textType||e.blockId!==this.blockId)return!1;const r=e.beforeRange,i=r.anchor;if(!i.isSimple())return!1;const s=this.afterRange;if(!s)return!1;const o=s.anchor;return!(!o.isSimple()||o.blockId!==r.anchor.blockId||o.offset!==i.offset)}combine(e){p(pa,e instanceof Jf,"invalid action type");const r=e;this.afterRichTextData=r.afterRichTextData,this.afterRange=e.afterRange}}const fT=D("child-container-action");class dT extends Yc{constructor(t,e,r){super(t,e,t.selection.range.toDocRange()),this.blocks=r}deleteChildContainer(t){return this.findContainerById(t,this.containerId)?(t.doc.localDeleteChildContainers([this.containerId]),!0):(fT.warn(`container (${this.containerId}) not found, deleted by others?`),!1)}insertChildContainer(t){return this.findContainerById(t,this.containerId)?(fT.warn(`container (${this.containerId}) already exists`),!1):(t.doc.localInsertChildContainers([{containerId:this.containerId,blocks:At.default(this.blocks)}]),!0)}}class xM extends dT{undo(t){return this.deleteChildContainer(t)}redo(t){return this.insertChildContainer(t)}}class bM extends dT{undo(t){return this.insertChildContainer(t)}redo(t){return this.deleteChildContainer(t)}}const Bi=D("undo");class vM{constructor(t){m(this,"editor");m(this,"actions",[]);m(this,"undoCursor");m(this,"currentGroup",null);m(this,"groupCounter",0);m(this,"undoRedoing",!1);m(this,"handleSelectionChange",t=>{if(this.currentGroup){this.currentGroup.setAfterRange(t.selection.range.toDocRange());return}const e=this.actions[this.actions.length-1];!e||e.afterRange||e.setAfterRange(t.selection.range.toDocRange())});this.editor=t,this.undoCursor=-1,this.editor.addListener("selectionChanged",this.handleSelectionChange)}reset(){this.actions=[],this.undoCursor=-1}prepareSaveUndoState(){this.undoCursor!==-1&&(this.actions.splice(this.undoCursor),this.undoCursor=-1)}addAction(t){this.currentGroup?this.currentGroup.addAction(t):(cT(this.actions,t),setTimeout(()=>{this.editor.input.handleChanged(t)}))}beginGroup(){this.groupCounter===0?(p(Bi,!this.currentGroup,"current group already exists"),this.currentGroup=new AM(this.editor),this.groupCounter=1):(p(Bi,this.currentGroup,"current group not exists"),this.groupCounter+=1)}endGroup(){p(Bi,this.currentGroup,"current group not exists"),p(Bi,this.groupCounter>0,"group counter === 0"),this.groupCounter-=1,this.groupCounter===0&&(this.currentGroup.actions.length===0?Bi.warn("empty undo group, skip it"):(this.actions.push(this.currentGroup),this.editor.input.handleChanged(this.currentGroup)),this.currentGroup=null)}hasGroup(){return this.groupCounter>0}runInGroup(t){this.beginGroup();try{const e=t();return setTimeout(()=>this.editor.selection.caret.update()),e}catch(e){throw Bi.error(`failed to run action: ${e.message}`),e}finally{this.endGroup()}}undo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor>0;){this.undoCursor-=1;const t=this.actions[this.undoCursor];if(t.undo(this.editor)){try{this.editor.selection.setRange(Zo(this.editor,t.beforeRange))}catch(e){Bi.error(`undo: failed to restore caret pos: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}redo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor<this.actions.length;){const t=this.actions[this.undoCursor];if(this.undoCursor+=1,t.redo(this.editor)){try{const e=t.afterRange;e?this.editor.selection.setRange(Zo(this.editor,e)):Bi.warn("no after range")}catch(e){Bi.error(`redo: failed to set caret pos after redo: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}canUndo(){return!(this.actions.length===0||this.undoCursor===0)}canRedo(){return!(this.actions.length===0||this.undoCursor===-1||this.undoCursor===this.actions.length)}lastAction(){var e;const t=this.undoCursor===-1?this.actions.length-1:this.undoCursor-1;return(e=this.actions[t])!=null?e:null}undoTo(t){for(;;){const e=this.lastAction();if(!e||e===t)return!0;if(!this.undo())return!1}}onBeforeUpdateBlockText(t,e,r,i,s){this.undoRedoing||(this.prepareSaveUndoState(),$n.diff(r,i).length!==0&&this.addAction(new Jf(this.editor,t,e,r,i,s)))}onBeforeUpdateBlockData(t,e,r,i,s){if(this.undoRedoing)return;this.prepareSaveUndoState();const o=new im(this.editor,t,e,r,i,s);this.addAction(o)}onBeforeInsertBlock(t,e,r,i){this.undoRedoing||(this.prepareSaveUndoState(),p(Bi,e>=0,"invalid block index"),p(Bi,r,"no block data"),this.addAction(new CM(this.editor,t,e,r,i)))}onBeforeDeleteBlock(t,e,r,i){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new EM(this.editor,t,e,r,i)))}onBeforeInsertChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new xM(this.editor,t,e)))}onBeforeDeleteChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new bM(this.editor,t,e)))}}class BM{async fromData(t,e){const r=e.getData("text/x-ones-editor-doc");if(r)return{"text/x-ones-editor-doc":JSON.parse(r)}}}class TM{constructor(){m(this,"converters",[]);m(this,"converterTypes",["text/plain","text/markdown","text/html","text/x-ones-editor-doc"]);this.addConverter(new BM)}prepareData(t){const e=new DataTransfer;for(let r=0;r<this.converterTypes.length;r++)e.setData(this.converterTypes[r],t.getData(this.converterTypes[r]));return e}async fromData(t,e,r){let i={};const s=this.prepareData(e);for(const o of this.converters){const l=await o.fromData(t,s,r);l&&(i={...i,...l})}return i}addConverter(t){this.converters.push(t)}}function yM(n){n.editorBlocks.registerBlockClass(lr),n.editorBlocks.registerBlockClass(l3),n.editorBoxes.registerBoxClass(AB),n.editorBoxes.registerBoxClass(xB),n.editorBoxes.registerBoxClass(BB),n.editorBoxes.registerBoxClass(TB),n.editorInsertions.registerInsertionClass(yB),n.editorBlockRenders.registerRender(new yv)}function kM(n,t){yM(n),t!=null&&t.blocks&&t.blocks.forEach(e=>n.editorBlocks.registerBlockClass(e)),t!=null&&t.boxes&&t.boxes.forEach(e=>n.editorBoxes.registerBoxClass(e)),t!=null&&t.embeds&&t.embeds.forEach(e=>n.editorEmbeds.registerEmbedClass(e)),t!=null&&t.insertions&&t.insertions.forEach(e=>n.editorInsertions.registerInsertionClass(e)),t!=null&&t.decorators&&t.decorators.forEach(e=>n.editorDecorators.registerDecorator(e)),t!=null&&t.dataConverters&&t.dataConverters.forEach(e=>n.dataConverter.addConverter(e)),t!=null&&t.commandProviders&&t.commandProviders.forEach(e=>n.editorCommandProviders.registerCommandProvider(e)),t!=null&&t.textRenders&&t.textRenders.forEach(e=>n.editorBlockRenders.registerRender(e))}const sm=D("range-commands");function hT(n,t){n.forEach(e=>{e.source=t,e.children&&hT(e.children,t)})}function mT(n,t){n.forEach(e=>{e.group=t,e.children&&mT(e.children,t)})}function gT(n,t,e,r){const i=dt(t);p(sm,i===e.start.blockId,"invalid start range"),p(sm,i===e.end.blockId,"invalid end range");const s=n.editorCommandProviders.getCommandProviders();let o=[];if(s.forEach(l=>{const c=l.getAvailableCommands(n,t,e);hT(c,r),mT(c,l.id),o.push(...c)}),s.forEach(l=>{if(l.filterCommands){const c=l.filterCommands(n,t,e,o);c&&(o=c)}}),Pt(n,t)){if(!ua(e.start))return o;p(sm,!e.start.isSimple(),"invalid start pos"),p(sm,!e.end.isSimple(),"invalid end pos");const l=e.start.childContainerId,c=mi(n,l),h=ye(c)[0];if(h){const C=Ct(n,h),E=mn(n,{anchor:ht(h,0,"home"),focus:ht(h,C,"end")}),A=gT(n,h,E,r);o.push(...A)}}return o}function pT(n,t){const e=n.getEditor(),r=n.getSelectedBlocks(),i=[],s=n.isReverse()?r[0]:r[r.length-1],o=mn(e,{anchor:s.start,focus:s.end});return gT(e,s.block,o,t).forEach(c=>{i.push(c)}),i}function CT(n,t,e,r,i,s){var h;const o=n.editorCommandProviders.getCommandProviders();for(let C=0;C<o.length;C++){const E=o[C];if(E.beforeExecuteCommand&&E.beforeExecuteCommand(n,t,e,r,i))return!1}const l=n.editorCommandProviders.getCommandProvider(r.group),c={};if((h=l.executeCommand)!=null&&h.call(l,n,t,e,r,i,{}))return s[dt(t)]=c,!0;let d=!1;return Pt(n,t)&&Oc(n,t,e.start,e.end).forEach(E=>{ye(E).forEach(v=>{const R=Ct(n,v),S=mn(n,{anchor:ht(v,0,"home"),focus:ht(v,R,"end")});CT(n,v,S,r,i,s)&&(d=!0)})}),o.forEach(C=>{C.afterExecuteCommand&&C.afterExecuteCommand(n,t,e,r,i,s)}),d}function ET(n,t,e){const r=n.getEditor(),i={},s=r.editorCommandProviders.getCommandProvider(t.group);return s.executeRangeCommand&&s.executeRangeCommand(r,n,t,e,i)||(n.getSelectedBlocks().forEach(l=>{const c=mn(r,{anchor:l.start,focus:l.end});CT(r,l.block,c,t,e,i)}),r.focus()),i}const RM=D("command-providers");class AT{constructor(t){m(this,"providers",[]);this.editor=t}registerCommandProvider(t){this.providers.push(t)}getCommandProviders(){return this.providers}getCommandProvider(t){const e=this.providers.find(r=>r.id===t);return p(RM,e,`no command provider, id=${t}`),e}getCommands(t,e){return pT(t,e)}executeCommand(t,e,r){return this.editor.emit("beforeExecCommand",this.editor,e,{source:e.source}),this.editor.undoManager.runInGroup(()=>ET(t,e,r))}getEmptyBlockTextAttributes(t,e){let r={};if(this.providers.forEach(i=>{var o;const s=(o=i.getEmptyBlockTextAttributes)==null?void 0:o.call(i,t,e);s&&(r={...r,...s})}),Object.keys(r).length!==0)return r}}function wM(n,t){const e=at(t),r=pt(e),i=Rt(t);oT(n,r,i)}const xT=D("update-block-text");function SM(n,t,e){const r=n.getBoxById(t.id),i=nt(r);p(xT,i,"no parent block"),p(xT,ot(n,i),"not a text block");const s=n.getBlockText(i),o=fB(s,"id",t.id,t);GB(n,i,o,e)}function LM(n,t){for(const e of n.blockHooks)if(e.writable){const r=e.writable(n,t);if(typeof r=="boolean")return r}return!0}function IM(n){if(n.readonly)return!1;const t=Ji(n);return!!n.isBlockWritable(t.map(e=>e.block))}class DM{constructor(t){this.editor=t}getKey(t){return`${this.editor.id}-${t}`}getItem(t){return window.localStorage.getItem(this.getKey(t))}setItem(t,e){if(!e){this.removeItem(t);return}window.localStorage.setItem(this.getKey(t),e)}removeItem(t){window.localStorage.removeItem(this.getKey(t))}}class _M{constructor(){m(this,"shortcuts",[])}handleKeyboardEvents(t,e){const r=this.shortcuts;for(const i of r){const s=Object.entries(i);for(const[o,l]of s)if(Wi(e,o)){const c=l(t,e);if(c!==void 0)return c}}}}const Xs=D("editor");class MM extends Fe.TypedEmitter{constructor(e,r,i){var s,o,l,c,d,h,C,E,A;super();m(this,"parent");m(this,"rootElement");m(this,"contentElement");m(this,"rootContainerObject");m(this,"rootContainer");m(this,"input");m(this,"selection");m(this,"selectionHandler");m(this,"doc");m(this,"id");m(this,"clientId");m(this,"compositingText","");m(this,"undoManager");m(this,"shortcuts",new _M);m(this,"dataConverter",new TM);m(this,"editorBlocks",new r3(this));m(this,"editorBoxes",new vB(this));m(this,"editorInsertions",new RB(this));m(this,"editorEmbeds",new s3(this));m(this,"editorDecorators",new wB(this));m(this,"editorCommandProviders",new AT(this));m(this,"editorBlockRenders",new bI(this));m(this,"blockHooks",[]);m(this,"domEvents",new __(this));m(this,"customs",new Map);m(this,"options");m(this,"version","");m(this,"inputHandlers",new aM(this));m(this,"settingsProvider");m(this,"_readonly",!1);m(this,"getColor",e=>{const r=this.options.colors;return r.length===0?"#FF1A75":r[e%r.length]});Xs.debug("create editor"),this.setMaxListeners(100),this.options={colors:(s=i==null?void 0:i.colors)!=null?s:["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"],componentsOptions:(l=(o=i==null?void 0:i.components)==null?void 0:o.options)!=null?l:{},scrollContainer:i==null?void 0:i.scrollContainer,enableComments:(c=i==null?void 0:i.enableComments)!=null?c:!0,enableContextMenu:(d=i==null?void 0:i.enableContextMenu)!=null?d:!0},this.settingsProvider=(h=i==null?void 0:i.settingsProvider)!=null?h:new DM(this),kM(this,i==null?void 0:i.components),this.blockHooks.push(...(E=(C=i==null?void 0:i.components)==null?void 0:C.blockHooks)!=null?E:[]),this.id=(A=i==null?void 0:i.id)!=null?A:it(),this.clientId=it(),this.undoManager=new vM(this),this.doc=new pM(this,r,this.undoManager),this.parent=e,this.rootElement=B("div",["editor-root"],this.parent),this.rootElement.setAttribute("data-editor-client-id",this.clientId),this.contentElement=B("div",["editor-content"],this.rootElement),this.rootContainerObject=t3(this),this.rootContainer=this.rootContainerObject.rootContainer,this.input=new Q8(this,this.inputHandlers),this.selection=new K_(this),this.selectionHandler=new H_(this),i!=null&&i.shortcuts&&this.shortcuts.shortcuts.push(...i.shortcuts),Ae.isMobile&&q(this.rootElement,"mobile"),Ae.isSafari&&q(this.rootElement,"safari"),this._readonly&&q(this.rootElement,"readonly"),this.emit("load",this,!1)}get readonly(){return this._readonly}set readonly(e){this._readonly=e,e?q(this.rootElement,"readonly"):ut(this.rootElement,"readonly"),this.emit("readonlyChanged",this)}get scrollContainer(){return this.options.scrollContainer?this.options.scrollContainer:dn(this.rootContainer)}addCustom(e,r){const i=this.customs.get(e);if(i)return i;const s=r(this);return this.customs.set(e,s),s}getCustom(e){const r=this.customs.get(e);return p(Xs,r,`${e} does not exists`),r}replaceCustom(e,r){const i=this.customs.get(e);return i&&i.destroy(),this.customs.set(e,r),r}findCustom(e){return this.customs.get(e)}findCustomByType(e){const r=this.customs.values();for(const i of r)if(i instanceof e)return i;return null}destroyCustom(e){const r=this.customs.get(e);r&&(this.customs.delete(e),r.destroy())}getComponentOptions(e){return this.options.componentsOptions[e]}registerLocalEvents(e){this.doc.registerLocalEvents(e)}reload(){this.rootContainerObject.reload(),this.emit("load",this,!0)}createBlock(e,r,i){return this.editorBlocks.createBlock(e,r,i)}createBox(e,r){return this.editorBoxes.createBox(e,r)}createInsertion(e,r){return this.editorInsertions.createInsertion(e,r)}destroy(){Xs.debug("destroy editor"),this.emit("destroy",this),this.input.destroy(),this.rootContainerObject.destroy(),this.rootElement.remove(),this.doc.destroy(),this.customs.forEach(e=>e.destroy()),this.customs.clear(),this.selection.destroy(),this.domEvents.destroy(),this.removeAllListeners(),this.inputHandlers.destroy()}focus(){this.input.focus()}focusToBlock(e,r){J1(this,e,r)}isWritable(){return IM(this)}isBlockWritable(e){return LM(this,e)}getChildContainerData(e){const r=this.doc.getContainerBlocks(e);return(!r||!Array.isArray(r))&&(p(Xs,r,`no child container data: ${e}, ${JSON.stringify(this.doc)}`),p(Xs,Array.isArray(r),`container data is not an array: ${JSON.stringify(r)}`)),r}createChildContainer(e,r,i){return e3(this,e,r,i)}getFirstBlock(){return this.rootContainer.querySelector("[data-type=editor-block]")}getLastBlock(){const e=Array.from(this.rootContainer.querySelectorAll(":scope [data-type=editor-block]"));return e[e.length-1]}getFocusedBlock(){return this.selection.getFocusedBlock()}findBlockById(e){const r=this.rootContainer.querySelector(`#${e}`);return r&&p(Xs,oa(r),"not an valid block element"),r!=null?r:null}findBoxById(e){const r=this.rootContainer.querySelector(`#${e}`);return r&&p(Xs,b0(r),"not an valid box element"),r!=null?r:null}getBlockById(e){const r=this.findBlockById(e);return p(Xs,r,`no block, id=${e}`),r}getBoxById(e){const r=this.findBoxById(e);return p(Xs,r,`no box, id=${e}`),r}getBlockByIndex(e,r){const i=this.getContainerById(e);return Xo(i,r)}findBlockByIndex(e,r){const i=this.getContainerById(e);return xv(i,r)}getBlockIndex(e){if(typeof e=="string"){const r=this.getBlockById(e);return Rt(r)}return Rt(e)}getContainerById(e){return mi(this,e)}getParentContainer(e){return at(e)}reloadBlock(e){wM(this,e)}contains(e){const r=e instanceof Element?e:e.parentElement;return r?r.closest("div.editor-root")===this.rootElement:!1}insertBlock(e,r,i,s,o){const l={blockId:i.id,offset:0},c={anchor:l,focus:l};return Gc(this,e,r,i,s!=null?s:c,o)}insertEmbed(e,r,i,s,o){const l={id:it(),type:"embed",embedType:i,embedData:s};return this.insertBlock(e,r,l,o)}deleteBlock(e,r){Y1(this,e,r)}mergeTextBlock(e,r){return HB(this,e,r)}breakTextBlock(e,r,i){return Wc(this,e,r,i).newBlock}getTextPosition(){return jc(this)}getBlockString(e,r){const i=this.getBlockText(e);return ke(i,r)}getBlockData(e){return nl(this,e)}getBoxData(e){return CB(this,e)}getBlockText(e){return Qn(this,e)}setBlockText(e,r){GB(this,e,r)}deleteTextFromBlock(e,r,i,s){return q1(this,e,r,i,s)}insertTextToBlock(e,r,i,s){return NB(this,e,r,i,s)}insertBoxToBlock(e,r,i){return PB(this,e,r,i)}pasteDoc(e){return this.inputHandlers.pasteDoc(e)}insertDoc(e,r,i,s){XB(this,e,r,i,s)}insertDocAt(e,r,i,s){return eC(this,e,r,i,s)}deleteChildContainers(e){$B(this,e)}replaceBlockText(e,r){return X0(this,e,r)}updateBlockData(e,r,i){const s={...this.getBlockData(e),...r},{id:o,type:l,...c}=s;return Y0(this,e,c,(i!=null?i:this.selection.range).toDocRange())}updateEmbedData(e,r,i){return WB(this,e,r,i)}updateBoxData(e,r){SM(this,e,r)}getSelectedText(){const e=Xc(this);return rl(this,e)}clearSelectedContents(){q0(this)}insertTextBlock(e,r,i,s){const o=es(e!=null?e:"");return VB(this,o,r,i,s==null?void 0:s.newRange,s==null?void 0:s.insertBlockOptions)}updateCompositionText(e,r){if(e&&!r&&(this.selection.range.isCollapsed()||this.clearSelectedContents()),!e&&!r){W1(this);return}r?(this.compositingText="",Cf()?e||W1(this):G1(this,e)):(this.compositingText=e,FB(this))}}function Zf(n,t,e){return new MM(n,t,e)}function UM(n){const t=(r,i)=>{const s=r.findIndex(l=>l.id===i.id);if(s===-1){r.push(i);return}const o=r[s];if(o.value!==i.value){r.splice(s,1);return}if(!!o.states){if(!i.states){o.states=[];return}o.states=yp.default(o.states,i.states)}},e=[];return n.forEach(r=>{r.forEach(i=>{t(e,i)})}),e}const OM=["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"];class td extends Fe.TypedEmitter{constructor(e){super();m(this,"users",new Map);m(this,"cursors",new Map);m(this,"addingUser",!1);m(this,"colors");this.colors=e&&e.length>0?e:OM}setCursor(e){this.addUser(e.user);const r=this.cursors.get(e.user.userId);if(r&&pf.default(r,e))return;this.cursors.set(e.user.userId,e);const i=new Set([e.range.anchor.blockId,e.range.focus.blockId]),s=new Set(i);r&&new Set([r.range.anchor.blockId,r.range.focus.blockId]).forEach(l=>{i.has(l)||s.add(l)}),this.emit("remote-carets-change",[...s])}addUsers(e){this.addingUser=!0,e.forEach(r=>this.addUser(r)),this.addingUser=!1,this.emit("change",Array.from(this.users.values()))}addUser(e){this.users.set(e.userId,e),this.addingUser||this.emit("change",Array.from(this.users.values()))}findUser(e){var r;return(r=this.users.get(e))!=null?r:null}removeUser(e){this.users.delete(e),this.emit("change",Array.from(this.users.values()));const r=this.cursors.get(e);if(r){const i=new Set(new Set([r==null?void 0:r.range.anchor.blockId,r==null?void 0:r.range.focus.blockId]));this.cursors.delete(e),this.emit("remote-carets-change",[...i])}}updateUsers(e){this.users.forEach(r=>{e.find(i=>i.userId===r.userId)||this.removeUser(r.userId)}),this.users.clear(),this.addingUser=!0;try{e.forEach(r=>{this.addUser(r)})}finally{this.addingUser=!1}setTimeout(()=>{this.emit("change",Array.from(this.users.values()))},300)}getSimpleCursors(e){const r=new Map;return Array.from(this.cursors.values()).filter(i=>i.range.anchor.blockId===e&&O0(i.range)).forEach(i=>{const s=i.range.focus.offset;let o=r.get(s);o||(o=[],r.set(s,o)),o.push(i)}),r}getCursors(e){return Array.from(this.cursors.values()).filter(r=>r.range.anchor.blockId===e||r.range.focus.blockId===e)}onUpdateBlockText(e,r,i){if(!e.text)return;this.getCursors(e.id).forEach(l=>{if(O0(l.range)){const{anchor:c,focus:d}=l.range;c.blockId===e.id&&(c.offset=$n.transformCursor(c.offset,r,i)),d.blockId===e.id&&(d.offset=$n.transformCursor(d.offset,r,i))}})}getFixedUserColor(e,r){let i=0;Array.from(e).forEach(o=>{i+=o.charCodeAt(0)});const s=i%this.colors.length;return this.colors[s]}destroy(){this.removeAllListeners()}}const In=D("local-doc");class AC extends Sc{constructor(e,r){super();m(this,"doc");m(this,"serviceUrl");e?this.doc=e:this.doc={meta:{},comments:{},blocks:{root:[es("")]}},this.serviceUrl=(r==null?void 0:r.serverUrl)||""}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return At.default(this.doc)}getContainerBlocks(e){return this.doc.blocks[e]}findContainerBlocks(e){return this.doc.blocks[e]}getBlockData(e,r){const i=this.getContainerBlocks(e);p(In,i,`no container data: ${e}`);const s=i[r];return p(In,s,`no block data: ${r}`),s}localUpdateBlockText(e,r,i){const s=this.getBlockData(e,r);p(In,s.text,"no text for data");const o=$n.apply(s.text,i);return s.text=o,p(In,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(l=>{var c;return(c=l.onUpdateBlockText)==null?void 0:c.call(l,e,r,i,!0)}),o}localUpdateBlockData(e,r,i){const s=this.getBlockData(e,r);return i.delete.forEach(o=>delete s[o]),Object.entries(i.insert).forEach(([o,l])=>{s[o]=l}),p(In,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var l;return(l=o.onUpdateBlockData)==null?void 0:l.call(o,e,r,i,!0)}),s}localInsertBlock(e,r,i){const s=this.getContainerBlocks(e);return p(In,s,`no container data: ${e}`),p(In,r>=0&&r<=s.length,`invalid block index: ${r}, ${s.length}`),s.splice(r,0,i),p(In,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var l;return(l=o.onInsertBlock)==null?void 0:l.call(o,e,r,i,!0)}),i}localDeleteBlock(e,r){const i=this.getContainerBlocks(e);p(In,i,`no container data: ${e}`),p(In,r>=0&&r<=i.length,`invalid block index: ${r}, ${i.length}`);const s=i[r];return i.splice(r,1),p(In,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var l;return(l=o.onDeleteBlock)==null?void 0:l.call(o,e,r,!0)}),s}localInsertChildContainers(e){e.forEach(({containerId:r,blocks:i})=>{this.doc.blocks[r]=i,p(In,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var o;return(o=s.onInsertChildContainer)==null?void 0:o.call(s,r,i,!0)})})}localDeleteChildContainers(e){In.debug(`delete child containers: ${e}`),e.forEach(r=>{p(In,this.doc.blocks[r],`no child container: ${r}`),delete this.doc.blocks[r]}),e.forEach(r=>{p(In,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var s;return(s=i.onDeleteChildContainer)==null?void 0:s.call(i,r,!0)})})}uploadResource(e,r){p(In,!1,"not implemented")}async addResources(e){return e}buildResourceUrl(e){return e}request(e,r){p(In,!1,"not implemented")}broadcastMessage(e){}getServerMeta(){return{serverId:this.serviceUrl}}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new td}setDoc(e){this.doc=At.default(e),this.callbacks.forEach(r=>{var i;return(i=r.onRequestReload)==null?void 0:i.call(r,"change doc")})}destroy(){this.clearCallbacks()}}class NM{constructor(t){this.cleanup=t}destroy(){var t;(t=this.cleanup)==null||t.call(this)}}function xC(n,t,e){n.addCustom(t,()=>{var s;const r=(s=e())!=null?s:void 0;return new NM(r)})}const bT=D("find-block");function vT(n,t){const e=$r(t);if(!e){if(jr(t))return null;const r=la(t);return p(bT,r,"no parent block"),vT(n,r)}return Pt(n,e)?Nc(n,e,{visibleOnly:!0}):e}function BT(n,t){const e=Hr(t);if(!e){if(jr(t))return null;const r=la(t);return p(bT,r,"no parent block"),BT(n,r)}return Pt(n,e)?d1(n,e,{visibleOnly:!0}):e}const PM=D("remote-cursor");class FM{constructor(){m(this,"remoteUsers",new td)}onCustomMessage(t){const e=t;if(e.type==="onlineUsers"){const r=e;this.handleUpdateUsers(r.users)}else e.type==="caret"?this.handleUpdateCaret(e):PM.debug(`unknown remote message received: ${t}`)}handleUpdateUsers(t){this.remoteUsers.updateUsers(t)}handleUpdateCaret(t){const e=this.remoteUsers.findUser(t.userId);!e||this.remoteUsers.setCursor({oneseditor:"cursor",user:e,range:t.range,time:Date.now()})}destroy(){this.remoteUsers.destroy()}}function KM(n){const{blocks:t,meta:e,comments:r,...i}=n;return{rootBlocks:t,meta:e,comments:r,childBlocks:i}}function VM(n){const{blocks:t,meta:e,comments:r}=n,{root:i,...s}=t;return{blocks:i,meta:e,comments:r,...s}}function Ys(n){const{childBlocks:t,meta:e,comments:r,rootBlocks:i}=KM(At.default(n));return{blocks:{root:i,...t},meta:e,comments:r}}function Qs(n){return n==="root"?"blocks":n}function Jc(n){return n==="blocks"?"root":n}const $M={type:{name:"rich-text",uri:"http://sharejs.org/types/rich-text/v1",create(n){return new Kn.default(n)},apply(n,t){const e=new Kn.default(n),r=new Kn.default(t);return e.compose(r).ops},compose(n,t){const e=new Kn.default(n),r=new Kn.default(t);return e.compose(r).ops},diff(n,t){const e=new Kn.default(n),r=new Kn.default(t);return e.diff(r).ops},transform(n,t,e){const r=new Kn.default(n);return new Kn.default(t).transform(r,e==="left").ops},transformCursor(n,t,e){return t.transformPosition(n,!e)},normalize(n){return n},serialize(n){return n.ops},deserialize(n){return n},transformPresence(n,t,e){if(!n)return null;const r=new Kn.default(t),i=this.transformCursor(n.index,r,e),s=this.transformCursor(n.index+n.length,r,e);return{...n,index:i,length:s-i}}}};var al={},bC=Tp.default.EventEmitter;al.EventEmitter=bC,al.mixin=HM;function HM(n){for(var t in bC.prototype)n.prototype[t]=bC.prototype[t]}var TT=["info","warn","error"];function yT(){var n={};TT.forEach(function(t){n[t]=console[t].bind(console)}),this.setMethods(n)}var jM=yT;yT.prototype.setMethods=function(n){n=n||{};var t=this;TT.forEach(function(e){typeof n[e]=="function"&&(t[e]=n[e])})};var zM=jM,GM=new zM,kT=GM;function Ca(n,t){this.code=n,this.message=t||"",Error.captureStackTrace?Error.captureStackTrace(this,Ca):this.stack=new Error().stack}Ca.prototype=Object.create(Error.prototype),Ca.prototype.constructor=Ca,Ca.prototype.name="ShareDBError",Ca.CODES={ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT:"ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT",ERR_APPLY_SNAPSHOT_NOT_PROVIDED:"ERR_APPLY_SNAPSHOT_NOT_PROVIDED",ERR_FIXUP_IS_ONLY_VALID_ON_APPLY:"ERR_FIXUP_IS_ONLY_VALID_ON_APPLY",ERR_CANNOT_FIXUP_DELETION:"ERR_CANNOT_FIXUP_DELETION",ERR_CLIENT_ID_BADLY_FORMED:"ERR_CLIENT_ID_BADLY_FORMED",ERR_CANNOT_PING_OFFLINE:"ERR_CANNOT_PING_OFFLINE",ERR_CONNECTION_SEQ_INTEGER_OVERFLOW:"ERR_CONNECTION_SEQ_INTEGER_OVERFLOW",ERR_CONNECTION_STATE_TRANSITION_INVALID:"ERR_CONNECTION_STATE_TRANSITION_INVALID",ERR_DATABASE_ADAPTER_NOT_FOUND:"ERR_DATABASE_ADAPTER_NOT_FOUND",ERR_DATABASE_DOES_NOT_SUPPORT_SUBSCRIBE:"ERR_DATABASE_DOES_NOT_SUPPORT_SUBSCRIBE",ERR_DATABASE_METHOD_NOT_IMPLEMENTED:"ERR_DATABASE_METHOD_NOT_IMPLEMENTED",ERR_DEFAULT_TYPE_MISMATCH:"ERR_DEFAULT_TYPE_MISMATCH",ERR_DOC_MISSING_VERSION:"ERR_DOC_MISSING_VERSION",ERR_DOC_ALREADY_CREATED:"ERR_DOC_ALREADY_CREATED",ERR_DOC_DOES_NOT_EXIST:"ERR_DOC_DOES_NOT_EXIST",ERR_DOC_TYPE_NOT_RECOGNIZED:"ERR_DOC_TYPE_NOT_RECOGNIZED",ERR_DOC_WAS_DELETED:"ERR_DOC_WAS_DELETED",ERR_INFLIGHT_OP_MISSING:"ERR_INFLIGHT_OP_MISSING",ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION:"ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION",ERR_MAX_SUBMIT_RETRIES_EXCEEDED:"ERR_MAX_SUBMIT_RETRIES_EXCEEDED",ERR_MESSAGE_BADLY_FORMED:"ERR_MESSAGE_BADLY_FORMED",ERR_MILESTONE_ARGUMENT_INVALID:"ERR_MILESTONE_ARGUMENT_INVALID",ERR_OP_ALREADY_SUBMITTED:"ERR_OP_ALREADY_SUBMITTED",ERR_OP_NOT_ALLOWED_IN_PROJECTION:"ERR_OP_NOT_ALLOWED_IN_PROJECTION",ERR_OP_SUBMIT_REJECTED:"ERR_OP_SUBMIT_REJECTED",ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM:"ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM",ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM:"ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM",ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT:"ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT",ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED:"ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED",ERR_OT_OP_BADLY_FORMED:"ERR_OT_OP_BADLY_FORMED",ERR_OT_OP_NOT_APPLIED:"ERR_OT_OP_NOT_APPLIED",ERR_OT_OP_NOT_PROVIDED:"ERR_OT_OP_NOT_PROVIDED",ERR_PRESENCE_TRANSFORM_FAILED:"ERR_PRESENCE_TRANSFORM_FAILED",ERR_PROTOCOL_VERSION_NOT_SUPPORTED:"ERR_PROTOCOL_VERSION_NOT_SUPPORTED",ERR_QUERY_CHANNEL_MISSING:"ERR_QUERY_CHANNEL_MISSING",ERR_QUERY_EMITTER_LISTENER_NOT_ASSIGNED:"ERR_QUERY_EMITTER_LISTENER_NOT_ASSIGNED",ERR_SNAPSHOT_READ_SILENT_REJECTION:"ERR_SNAPSHOT_READ_SILENT_REJECTION",ERR_SNAPSHOT_READS_REJECTED:"ERR_SNAPSHOT_READS_REJECTED",ERR_SUBMIT_TRANSFORM_OPS_NOT_FOUND:"ERR_SUBMIT_TRANSFORM_OPS_NOT_FOUND",ERR_TYPE_CANNOT_BE_PROJECTED:"ERR_TYPE_CANNOT_BE_PROJECTED",ERR_TYPE_DOES_NOT_SUPPORT_COMPOSE:"ERR_TYPE_DOES_NOT_SUPPORT_COMPOSE",ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE:"ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE",ERR_UNKNOWN_ERROR:"ERR_UNKNOWN_ERROR"};var om=Ca,ed={},RT=WM;function WM(n,t,e,r){var i=function(o,l,c,d){t(c,o,l,"left"),t(d,l,o,"right")},s=n.transformX=function(o,l){e(o),e(l);for(var c=[],d=0;d<l.length;d++){for(var h=l[d],C=[],E=0;E<o.length;){var A=[];if(i(o[E],h,C,A),E++,A.length===1)h=A[0];else if(A.length===0){for(var v=E;v<o.length;v++)r(C,o[v]);h=null;break}else{for(var R=s(o.slice(E),A),S=0;S<R[0].length;S++)r(C,R[0][S]);for(var O=0;O<R[1].length;O++)r(c,R[1][O]);h=null;break}}h!=null&&r(c,h),o=C}return[o,c]};n.transform=function(o,l,c){if(!(c==="left"||c==="right"))throw new Error("type must be 'left' or 'right'");return l.length===0?o:o.length===1&&l.length===1?t([],o[0],l[0],c):c==="left"?s(o,l)[0]:s(l,o)[1]}}var wT={exports:{}},cl=wT.exports={name:"text0",uri:"http://sharejs.org/types/textv0",create:function(n){if(n!=null&&typeof n!="string")throw new Error("Initial data must be a string");return n||""}},vC=function(n,t,e){return n.slice(0,t)+e+n.slice(t)},BC=function(n){if(typeof n.p!="number")throw new Error("component missing position field");if(typeof n.i=="string"==(typeof n.d=="string"))throw new Error("component needs an i or d field");if(n.p<0)throw new Error("position cannot be negative")},lm=function(n){for(var t=0;t<n.length;t++)BC(n[t])};cl.apply=function(n,t){var e;lm(t);for(var r=0;r<t.length;r++){var i=t[r];if(i.i!=null)n=vC(n,i.p,i.i);else{if(e=n.slice(i.p,i.p+i.d.length),i.d!==e)throw new Error("Delete component '"+i.d+"' does not match deleted text '"+e+"'");n=n.slice(0,i.p)+n.slice(i.p+i.d.length)}}return n};var Js=cl._append=function(n,t){if(!(t.i===""||t.d===""))if(n.length===0)n.push(t);else{var e=n[n.length-1];e.i!=null&&t.i!=null&&e.p<=t.p&&t.p<=e.p+e.i.length?n[n.length-1]={i:vC(e.i,t.p-e.p,t.i),p:e.p}:e.d!=null&&t.d!=null&&t.p<=e.p&&e.p<=t.p+t.d.length?n[n.length-1]={d:vC(t.d,e.p-t.p,e.d),p:t.p}:n.push(t)}};cl.compose=function(n,t){lm(n),lm(t);for(var e=n.slice(),r=0;r<t.length;r++)Js(e,t[r]);return e},cl.normalize=function(n){var t=[];(n.i!=null||n.p!=null)&&(n=[n]);for(var e=0;e<n.length;e++){var r=n[e];r.p==null&&(r.p=0),Js(t,r)}return t};var TC=function(n,t,e){return t.i!=null?t.p<n||t.p===n&&e?n+t.i.length:n:n<=t.p?n:n<=t.p+t.d.length?t.p:n-t.d.length};cl.transformCursor=function(n,t,e){for(var r=e==="right",i=0;i<t.length;i++)n=TC(n,t[i],r);return n};var qM=cl._tc=function(n,t,e,r){if(BC(t),BC(e),t.i!=null)Js(n,{i:t.i,p:TC(t.p,e,r==="right")});else if(e.i!=null){var i=t.d;t.p<e.p&&(Js(n,{d:i.slice(0,e.p-t.p),p:t.p}),i=i.slice(e.p-t.p)),i!==""&&Js(n,{d:i,p:t.p+e.i.length})}else if(t.p>=e.p+e.d.length)Js(n,{d:t.d,p:t.p-e.d.length});else if(t.p+t.d.length<=e.p)Js(n,t);else{var s={d:"",p:t.p};t.p<e.p&&(s.d=t.d.slice(0,e.p-t.p)),t.p+t.d.length>e.p+e.d.length&&(s.d+=t.d.slice(e.p+e.d.length-t.p));var o=Math.max(t.p,e.p),l=Math.min(t.p+t.d.length,e.p+e.d.length),c=t.d.slice(o-t.p,l-t.p),d=e.d.slice(o-e.p,l-e.p);if(c!==d)throw new Error("Delete ops delete different text in the same region of the document");s.d!==""&&(s.p=TC(s.p,e),Js(n,s))}return n},XM=function(n){return n.i!=null?{d:n.i,p:n.p}:{i:n.d,p:n.p}};cl.invert=function(n){n=n.slice().reverse();for(var t=0;t<n.length;t++)n[t]=XM(n[t]);return n},RT(cl,qM,lm,Js);var am=function(n){return Object.prototype.toString.call(n)=="[object Array]"},YM=function(n){return!!n&&n.constructor===Object},Ti=function(n){return JSON.parse(JSON.stringify(n))},Ft={name:"json0",uri:"http://sharejs.org/types/JSONv0"},Zs={};Ft.registerSubtype=function(n){Zs[n.name]=n},Ft.create=function(n){return n===void 0?null:Ti(n)},Ft.invertComponent=function(n){var t={p:n.p};return n.t&&Zs[n.t]&&(t.t=n.t,t.o=Zs[n.t].invert(n.o)),n.si!==void 0&&(t.sd=n.si),n.sd!==void 0&&(t.si=n.sd),n.oi!==void 0&&(t.od=n.oi),n.od!==void 0&&(t.oi=n.od),n.li!==void 0&&(t.ld=n.li),n.ld!==void 0&&(t.li=n.ld),n.na!==void 0&&(t.na=-n.na),n.lm!==void 0&&(t.lm=n.p[n.p.length-1],t.p=n.p.slice(0,n.p.length-1).concat([n.lm])),t},Ft.invert=function(n){for(var t=n.slice().reverse(),e=[],r=0;r<t.length;r++)e.push(Ft.invertComponent(t[r]));return e},Ft.checkValidOp=function(n){for(var t=0;t<n.length;t++)if(!am(n[t].p))throw new Error("Missing path")},Ft.checkList=function(n){if(!am(n))throw new Error("Referenced element not a list")},Ft.checkObj=function(n){if(!YM(n))throw new Error("Referenced element not an object (it was "+JSON.stringify(n)+")")};function nd(n){n.t="text0";var t={p:n.p.pop()};n.si!=null&&(t.i=n.si),n.sd!=null&&(t.d=n.sd),n.o=[t]}function rd(n){n.p.push(n.o[0].p),n.o[0].i!=null&&(n.si=n.o[0].i),n.o[0].d!=null&&(n.sd=n.o[0].d),delete n.t,delete n.o}Ft.apply=function(n,t){Ft.checkValidOp(t),t=Ti(t);for(var e={data:n},r=0;r<t.length;r++){var i=t[r];(i.si!=null||i.sd!=null)&&nd(i);for(var s=null,o=e,l="data",c=0;c<i.p.length;c++){var d=i.p[c];if(s=o,o=o[l],l=d,s==null)throw new Error("Path invalid")}if(i.t&&i.o!==void 0&&Zs[i.t])o[l]=Zs[i.t].apply(o[l],i.o);else if(i.na!==void 0){if(typeof o[l]!="number")throw new Error("Referenced element not a number");o[l]+=i.na}else if(i.li!==void 0&&i.ld!==void 0)Ft.checkList(o),o[l]=i.li;else if(i.li!==void 0)Ft.checkList(o),o.splice(l,0,i.li);else if(i.ld!==void 0)Ft.checkList(o),o.splice(l,1);else if(i.lm!==void 0){if(Ft.checkList(o),i.lm!=l){var h=o[l];o.splice(l,1),o.splice(i.lm,0,h)}}else if(i.oi!==void 0)Ft.checkObj(o),o[l]=i.oi;else if(i.od!==void 0)Ft.checkObj(o),delete o[l];else throw new Error("invalid / missing instruction in op")}return e.data},Ft.shatter=function(n){for(var t=[],e=0;e<n.length;e++)t.push([n[e]]);return t},Ft.incrementalApply=function(n,t,e){for(var r=0;r<t.length;r++){var i=[t[r]];n=Ft.apply(n,i),e(i,n)}return n};var QM=Ft.pathMatches=function(n,t,e){if(n.length!=t.length)return!1;for(var r=0;r<n.length;r++)if(n[r]!==t[r]&&(!e||r!==n.length-1))return!1;return!0};Ft.append=function(n,t){if(t=Ti(t),n.length===0){n.push(t);return}var e=n[n.length-1];if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(nd(t),nd(e)),QM(t.p,e.p))if(t.t&&e.t&&t.t===e.t&&Zs[t.t]){if(e.o=Zs[t.t].compose(e.o,t.o),t.si!=null||t.sd!=null){for(var r=t.p,i=0;i<e.o.length-1;i++)t.o=[e.o.pop()],t.p=r.slice(),rd(t),n.push(t);rd(e)}}else e.na!=null&&t.na!=null?n[n.length-1]={p:e.p,na:e.na+t.na}:e.li!==void 0&&t.li===void 0&&t.ld===e.li?e.ld!==void 0?delete e.li:n.pop():e.od!==void 0&&e.oi===void 0&&t.oi!==void 0&&t.od===void 0?e.oi=t.oi:e.oi!==void 0&&t.od!==void 0?t.oi!==void 0?e.oi=t.oi:e.od!==void 0?delete e.oi:n.pop():t.lm!==void 0&&t.p[t.p.length-1]===t.lm||n.push(t);else(t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(rd(t),rd(e)),n.push(t)},Ft.compose=function(n,t){Ft.checkValidOp(n),Ft.checkValidOp(t);for(var e=Ti(n),r=0;r<t.length;r++)Ft.append(e,t[r]);return e},Ft.normalize=function(n){var t=[];n=am(n)?n:[n];for(var e=0;e<n.length;e++){var r=n[e];r.p==null&&(r.p=[]),Ft.append(t,r)}return t},Ft.commonLengthForOps=function(n,t){var e=n.p.length,r=t.p.length;if((n.na!=null||n.t)&&e++,(t.na!=null||t.t)&&r++,e===0)return-1;if(r===0)return null;e--,r--;for(var i=0;i<e;i++){var s=n.p[i];if(i>=r||s!==t.p[i])return null}return e},Ft.canOpAffectPath=function(n,t){return Ft.commonLengthForOps({p:t},n)!=null},Ft.transformComponent=function(n,t,e,r){t=Ti(t);var i=Ft.commonLengthForOps(e,t),s=Ft.commonLengthForOps(t,e),o=t.p.length,l=e.p.length;if((t.na!=null||t.t)&&o++,(e.na!=null||e.t)&&l++,s!=null&&l>o&&t.p[s]==e.p[s]){if(t.ld!==void 0){var c=Ti(e);c.p=c.p.slice(o),t.ld=Ft.apply(Ti(t.ld),[c])}else if(t.od!==void 0){var c=Ti(e);c.p=c.p.slice(o),t.od=Ft.apply(Ti(t.od),[c])}}if(i!=null){var d=o==l,c=e;if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(nd(t),c=Ti(e),nd(c)),c.t&&Zs[c.t]){if(t.t&&t.t===c.t){var h=Zs[t.t].transform(t.o,c.o,r);if(t.si!=null||t.sd!=null)for(var C=t.p,E=0;E<h.length;E++)t.o=[h[E]],t.p=C.slice(),rd(t),Ft.append(n,t);else(!am(h)||h.length>0)&&(t.o=h,Ft.append(n,t));return n}}else if(e.na===void 0){if(e.li!==void 0&&e.ld!==void 0){if(e.p[i]===t.p[i])if(d){if(t.ld!==void 0)if(t.li!==void 0&&r==="left")t.ld=Ti(e.li);else return n}else return n}else if(e.li!==void 0)t.li!==void 0&&t.ld===void 0&&d&&t.p[i]===e.p[i]?r==="right"&&t.p[i]++:e.p[i]<=t.p[i]&&t.p[i]++,t.lm!==void 0&&d&&e.p[i]<=t.lm&&t.lm++;else if(e.ld!==void 0){if(t.lm!==void 0&&d){if(e.p[i]===t.p[i])return n;var C=e.p[i],A=t.p[i],v=t.lm;(C<v||C===v&&A<v)&&t.lm--}if(e.p[i]<t.p[i])t.p[i]--;else if(e.p[i]===t.p[i]){if(l<o)return n;if(t.ld!==void 0)if(t.li!==void 0)delete t.ld;else return n}}else if(e.lm!==void 0)if(t.lm!==void 0&&o===l){var A=t.p[i],v=t.lm,R=e.p[i],S=e.lm;if(R!==S)if(A===R)if(r==="left")t.p[i]=S,A===v&&(t.lm=S);else return n;else A>R&&t.p[i]--,A>S?t.p[i]++:A===S&&R>S&&(t.p[i]++,A===v&&t.lm++),(v>R||v===R&&v>A)&&t.lm--,v>S?t.lm++:v===S&&(S>R&&v>A||S<R&&v<A?r==="right"&&t.lm++:v>A?t.lm++:v===R&&t.lm--)}else if(t.li!==void 0&&t.ld===void 0&&d){var A=e.p[i],v=e.lm;C=t.p[i],C>A&&t.p[i]--,C>v&&t.p[i]++}else{var A=e.p[i],v=e.lm;C=t.p[i],C===A?t.p[i]=v:(C>A&&t.p[i]--,(C>v||C===v&&A>v)&&t.p[i]++)}else if(e.oi!==void 0&&e.od!==void 0){if(t.p[i]===e.p[i])if(t.oi!==void 0&&d){if(r==="right")return n;t.od=e.oi}else return n}else if(e.oi!==void 0){if(t.oi!==void 0&&t.p[i]===e.p[i])if(r==="left")Ft.append(n,{p:t.p,od:e.oi});else return n}else if(e.od!==void 0&&t.p[i]==e.p[i]){if(!d)return n;if(t.oi!==void 0)delete t.od;else return n}}}return Ft.append(n,t),n},RT(Ft,Ft.transformComponent,Ft.checkValidOp,Ft.append);var JM=wT.exports;Ft.registerSubtype(JM);var ZM=Ft,tU={type:ZM};(function(n){n.defaultType=tU.type,n.map={},n.register=function(t){t.name&&(n.map[t.name]=t),t.uri&&(n.map[t.uri]=t)},n.register(n.defaultType)})(ed);var Wr={};(function(n){n.doNothing=t;function t(){}n.hasKeys=function(e){for(var r in e)return!0;return!1},n.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e},n.isValidVersion=function(e){return e===null?!0:n.isInteger(e)&&e>=0},n.isValidTimestamp=function(e){return n.isValidVersion(e)},n.MAX_SAFE_INTEGER=9007199254740991,n.dig=function(){for(var e=arguments[0],r=1;r<arguments.length;r++){var i=arguments[r];e=e[i]||(r===arguments.length-1?void 0:{})}return e},n.digOrCreate=function(){for(var e=arguments[0],r=arguments[arguments.length-1],i=1;i<arguments.length-1;i++){var s=arguments[i];e=e[s]||(e[s]=i===arguments.length-2?r():{})}return e},n.digAndRemove=function(){for(var e=arguments[0],r=[e],i=1;i<arguments.length-1;i++){var s=arguments[i];if(!e.hasOwnProperty(s))break;e=e[s],r.push(e)}for(var i=r.length-1;i>=0;i--){var o=r[i],s=arguments[i+1],l=o[s];(i===r.length-1||!n.hasKeys(l))&&delete o[s]}},n.supportsPresence=function(e){return e&&typeof e.transformPresence=="function"},n.callEach=function(e,r){var i=!1;return e.forEach(function(s){s&&(s(r),i=!0)}),i},n.truthy=function(e){return!!e},n.nextTick=function(e){if(typeof process<"u"&&process.nextTick)return process.nextTick.apply(null,arguments);for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];setTimeout(function(){e.apply(null,r)})},n.clone=function(e){return e===void 0?void 0:JSON.parse(JSON.stringify(e))}})(Wr);var ST=Array.isArray,LT=Object.keys,eU=Object.prototype.hasOwnProperty,nU=function n(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var r=ST(t),i=ST(e),s,o,l;if(r&&i){if(o=t.length,o!=e.length)return!1;for(s=o;s--!==0;)if(!n(t[s],e[s]))return!1;return!0}if(r!=i)return!1;var c=t instanceof Date,d=e instanceof Date;if(c!=d)return!1;if(c&&d)return t.getTime()==e.getTime();var h=t instanceof RegExp,C=e instanceof RegExp;if(h!=C)return!1;if(h&&C)return t.toString()==e.toString();var E=LT(t);if(o=E.length,o!==LT(e).length)return!1;for(s=o;s--!==0;)if(!eU.call(e,E[s]))return!1;for(s=o;s--!==0;)if(l=E[s],!n(t[l],e[l]))return!1;return!0}return t!==t&&e!==e},ul={};ul.ACTIONS={initLegacy:"init",handshake:"hs",queryFetch:"qf",querySubscribe:"qs",queryUnsubscribe:"qu",queryUpdate:"q",bulkFetch:"bf",bulkSubscribe:"bs",bulkUnsubscribe:"bu",fetch:"f",fixup:"fixup",subscribe:"s",unsubscribe:"u",op:"op",snapshotFetch:"nf",snapshotFetchByTimestamp:"nt",pingPong:"pp",presence:"p",presenceSubscribe:"ps",presenceUnsubscribe:"pu",presenceRequest:"pr"};var IT=al,rU=kT,Tr=om,cm=ed,yi=Wr,iU=yi.clone,sU=nU,yC=ul.ACTIONS,ar=Tr.CODES,oU=Xt;function Xt(n,t,e){IT.EventEmitter.call(this),this.connection=n,this.collection=t,this.id=e,this.version=null,this.type=null,this.data=void 0,this.inflightFetch=[],this.inflightSubscribe=null,this.pendingFetch=[],this.pendingSubscribe=[],this.subscribed=!1,this.wantSubscribe=!1,this._wantsDestroy=!1,this.inflightOp=null,this.pendingOps=[],this.type=null,this.applyStack=null,this.preventCompose=!1,this.submitSource=!1,this.paused=!1,this._dataStateVersion=0}IT.mixin(Xt),Xt.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this;t.whenNothingPending(function(){t.wantSubscribe?t.unsubscribe(function(e){if(e)return n?n(e):t.emit("error",e);t.connection._destroyDoc(t),n&&n()}):(t.connection._destroyDoc(t),n&&n())})},Xt.prototype._setType=function(n){if(typeof n=="string"&&(n=cm.map[n]),n)this.type=n;else if(n===null)this.type=n,this._setData(void 0);else{var t=new Tr(ar.ERR_DOC_TYPE_NOT_RECOGNIZED,"Missing type "+n);return this.emit("error",t)}},Xt.prototype._setData=function(n){this.data=n,this._dataStateVersion++},Xt.prototype.ingestSnapshot=function(n,t){if(!n)return t&&t();if(typeof n.v!="number"){var e=new Tr(ar.ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION,"Missing version in ingested snapshot. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}if(this.type||this.hasWritePending()){if(this.version==null){if(this.hasWritePending())return t&&this.once("no write pending",t);var e=new Tr(ar.ERR_DOC_MISSING_VERSION,"Cannot ingest snapshot in doc with null version. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}return n.v>this.version?this.fetch(t):t&&t()}if(this.version>n.v)return t&&t();this.version=n.v;var r=n.type===void 0?cm.defaultType:n.type;this._setType(r),this._setData(this.type&&this.type.deserialize?this.type.deserialize(n.data):n.data),this.emit("load"),t&&t()},Xt.prototype.whenNothingPending=function(n){var t=this;yi.nextTick(function(){if(t.hasPending()){t.once("nothing pending",n);return}n()})},Xt.prototype.hasPending=function(){return!!(this.inflightOp||this.pendingOps.length||this.inflightFetch.length||this.inflightSubscribe||this.pendingFetch.length||this.pendingSubscribe.length)},Xt.prototype.hasWritePending=function(){return!!(this.inflightOp||this.pendingOps.length)},Xt.prototype._emitNothingPending=function(){this.hasWritePending()||(this.emit("no write pending"),!this.hasPending()&&this.emit("nothing pending"))},Xt.prototype._emitResponseError=function(n,t){if(n&&n.code===ar.ERR_SNAPSHOT_READ_SILENT_REJECTION){this.wantSubscribe=!1,t&&t(),this._emitNothingPending();return}if(t){t(n),this._emitNothingPending();return}this._emitNothingPending(),this.emit("error",n)},Xt.prototype._handleFetch=function(n,t){var e=this.pendingFetch;this.pendingFetch=[];var r=this.inflightFetch.shift();if(r&&e.push(r),e.length&&(r=function(i){yi.callEach(e,i)}),n)return this._emitResponseError(n,r);this.ingestSnapshot(t,r),this._emitNothingPending()},Xt.prototype._handleSubscribe=function(n,t){var e=this.inflightSubscribe;this.inflightSubscribe=null;var r=this.pendingFetch;this.pendingFetch=[],e.callback&&r.push(e.callback);var i;if(r.length&&(i=function(s){yi.callEach(r,s)}),n)return this._emitResponseError(n,i);this.subscribed=e.wantSubscribe,this.subscribed?this.ingestSnapshot(t,i):i&&i(),this._emitNothingPending(),this._flushSubscribe()},Xt.prototype._handleOp=function(n,t){if(n)return this.inflightOp?(n.code===ar.ERR_OP_SUBMIT_REJECTED&&(n=null),this._rollback(n)):this.emit("error",n);if(this.inflightOp&&t.src===this.inflightOp.src&&t.seq===this.inflightOp.seq){this._opAcknowledged(t);return}if(this.version==null||t.v>this.version){this.fetch();return}if(!(t.v<this.version)){if(this.inflightOp){var e=id(this.inflightOp,t);if(e)return this._hardRollback(e)}for(var r=0;r<this.pendingOps.length;r++){var e=id(this.pendingOps[r],t);if(e)return this._hardRollback(e)}this.version++;try{this._otApply(t,!1)}catch(i){return this._hardRollback(i)}}},Xt.prototype._onConnectionStateChanged=function(){this.connection.canSend?(this.flush(),this._resubscribe()):(this.inflightOp&&(this.pendingOps.unshift(this.inflightOp),this.inflightOp=null),this.subscribed=!1,this.inflightSubscribe&&(this.inflightSubscribe.wantSubscribe?(this.pendingSubscribe.unshift(this.inflightSubscribe),this.inflightSubscribe=null):this._handleSubscribe()),this.inflightFetch.length&&(this.pendingFetch=this.pendingFetch.concat(this.inflightFetch),this.inflightFetch.length=0))},Xt.prototype._resubscribe=function(){if(!this.pendingSubscribe.length&&this.wantSubscribe)return this.subscribe();var n=this.pendingSubscribe.some(function(t){return t.wantSubscribe});!n&&this.pendingFetch.length&&this.fetch(),this._flushSubscribe()},Xt.prototype.fetch=function(n){if(this.connection.canSend){var t=this.connection.sendFetch(this);lU(this.inflightFetch,t,n);return}this.pendingFetch.push(n)},Xt.prototype.subscribe=function(n){var t=!0;this._queueSubscribe(t,n)},Xt.prototype.unsubscribe=function(n){var t=!1;this._queueSubscribe(t,n)},Xt.prototype._queueSubscribe=function(n,t){var e=this.pendingSubscribe[this.pendingSubscribe.length-1]||this.inflightSubscribe,r=e&&e.wantSubscribe===n;if(r){e.callback=aU([e.callback,t]);return}this.pendingSubscribe.push({wantSubscribe:!!n,callback:t}),this._flushSubscribe()},Xt.prototype._flushSubscribe=function(){if(!(this.inflightSubscribe||!this.pendingSubscribe.length)){if(this.connection.canSend){this.inflightSubscribe=this.pendingSubscribe.shift(),this.wantSubscribe=this.inflightSubscribe.wantSubscribe,this.wantSubscribe?this.connection.sendSubscribe(this):(this.subscribed=!1,this.connection.sendUnsubscribe(this));return}if(!this.pendingSubscribe[0].wantSubscribe){this.inflightSubscribe=this.pendingSubscribe.shift();var n=this;yi.nextTick(function(){n._handleSubscribe()})}}};function lU(n,t,e){if(t){var r=n.pop();n.push(function(i){r&&r(i),e&&e(i)})}else n.push(e)}function aU(n){return n=n.filter(yi.truthy),n.length?function(t){yi.callEach(n,t)}:null}Xt.prototype.flush=function(){!this.connection.canSend||this.inflightOp||!this.paused&&this.pendingOps.length&&this._sendOp()};function cU(n){delete n.op,delete n.create,delete n.del}function id(n,t){if(n.del)return cU(t);if(t.del)return new Tr(ar.ERR_DOC_WAS_DELETED,"Document was deleted");if(t.create)return new Tr(ar.ERR_DOC_ALREADY_CREATED,"Document already created");if("op"in t){if(n.create)return new Tr(ar.ERR_DOC_ALREADY_CREATED,"Document already created");if(n.type.transformX){var e=n.type.transformX(n.op,t.op);n.op=e[0],t.op=e[1]}else{var r=n.type.transform(n.op,t.op,"left"),i=n.type.transform(t.op,n.op,"right");n.op=r,t.op=i}}}Xt.prototype._otApply=function(n,t){if("op"in n){if(!this.type)throw new Tr(ar.ERR_DOC_DOES_NOT_EXIST,"Cannot apply op to uncreated document. "+this.collection+"."+this.id);if(this.emit("before op batch",n.op,t),!t&&this.type===cm.defaultType&&n.op.length>1){this.applyStack||(this.applyStack=[]);for(var e=this.applyStack.length,r=0;r<n.op.length;r++){var i=n.op[r],s={op:[i]};this.emit("before op",s.op,t,n.src);for(var o=e;o<this.applyStack.length;o++){var l=id(this.applyStack[o],s);if(l)return this._hardRollback(l)}this._setData(this.type.apply(this.data,s.op)),this.emit("op",s.op,t,n.src)}this.emit("op batch",n.op,t),this._popApplyStack(e);return}this.emit("before op",n.op,t,n.src),this._setData(this.type.apply(this.data,n.op)),this.emit("op",n.op,t,n.src),this.emit("op batch",n.op,t);return}if(n.create){this._setType(n.create.type),this.type.deserialize?this.type.createDeserialized?this._setData(this.type.createDeserialized(n.create.data)):this._setData(this.type.deserialize(this.type.create(n.create.data))):this._setData(this.type.create(n.create.data)),this.emit("create",t);return}if(n.del){var c=this.data;this._setType(null),this.emit("del",c,t);return}},Xt.prototype._sendOp=function(){if(!!this.connection.canSend){var n=this.connection.id;this.inflightOp||(this.inflightOp=this.pendingOps.shift());var t=this.inflightOp;if(!t){var e=new Tr(ar.ERR_INFLIGHT_OP_MISSING,"No op to send on call to _sendOp");return this.emit("error",e)}if(t.sentAt=Date.now(),t.retries=t.retries==null?0:t.retries+1,t.seq==null){if(this.connection.seq>=yi.MAX_SAFE_INTEGER)return this.emit("error",new Tr(ar.ERR_CONNECTION_SEQ_INTEGER_OVERFLOW,"Connection seq has exceeded the max safe integer, maybe from being open for too long"));t.seq=this.connection.seq++}this.connection.sendOp(this,t),t.src==null&&(t.src=n)}},Xt.prototype._submit=function(n,t,e){if(t||(t=!0),"op"in n){if(!this.type){var r=new Tr(ar.ERR_DOC_DOES_NOT_EXIST,"Cannot submit op. Document has not been created. "+this.collection+"."+this.id);return e?e(r):this.emit("error",r)}this.type.normalize&&(n.op=this.type.normalize(n.op))}try{this._pushOp(n,t,e),this._otApply(n,t)}catch(s){return this._hardRollback(s)}var i=this;yi.nextTick(function(){i.flush()})},Xt.prototype._pushOp=function(n,t,e){if(n.source=t,this.applyStack)this.applyStack.push(n);else{var r=this._tryCompose(n);if(r){r.callbacks.push(e);return}}n.type=this.type,n.callbacks=[e],this.pendingOps.push(n)},Xt.prototype._popApplyStack=function(n){if(n>0){this.applyStack.length=n;return}var t=this.applyStack[0];if(this.applyStack=null,!!t){var e=this.pendingOps.indexOf(t);if(e!==-1)for(var r=this.pendingOps.splice(e),e=0;e<r.length;e++){var t=r[e],i=this._tryCompose(t);i?i.callbacks=i.callbacks.concat(t.callbacks):this.pendingOps.push(t)}}},Xt.prototype._tryCompose=function(n){if(!this.preventCompose){var t=this.pendingOps[this.pendingOps.length-1];if(!(!t||t.sentAt)&&!(this.submitSource&&!sU(n.source,t.source))){if(t.create&&"op"in n)return t.create.data=this.type.apply(t.create.data,n.op),t;if("op"in t&&"op"in n&&this.type.compose)return t.op=this.type.compose(t.op,n.op),t}}},Xt.prototype.submitOp=function(n,t,e){typeof t=="function"&&(e=t,t=null);var r={op:n},i=t&&t.source;this._submit(r,i,e)},Xt.prototype.create=function(n,t,e,r){if(typeof t=="function"?(r=t,e=null,t=null):typeof e=="function"&&(r=e,e=null),t||(t=cm.defaultType.uri),this.type){var i=new Tr(ar.ERR_DOC_ALREADY_CREATED,"Document already exists");return r?r(i):this.emit("error",i)}var s={create:{type:t,data:n}},o=e&&e.source;this._submit(s,o,r)},Xt.prototype.del=function(n,t){if(typeof n=="function"&&(t=n,n=null),!this.type){var e=new Tr(ar.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");return t?t(e):this.emit("error",e)}var r={del:!0},i=n&&n.source;this._submit(r,i,t)},Xt.prototype.pause=function(){this.paused=!0},Xt.prototype.resume=function(){this.paused=!1,this.flush()},Xt.prototype.toSnapshot=function(){return{v:this.version,data:iU(this.data),type:this.type.uri}},Xt.prototype._opAcknowledged=function(n){if(this.inflightOp.create)this.version=n.v;else if(n.v!==this.version)return rU.warn("Invalid version from server. Expected: "+this.version+" Received: "+n.v,n),this.fetch();if(n[yC.fixup])for(var t=0;t<n[yC.fixup].length;t++){for(var e=n[yC.fixup][t],r=0;r<this.pendingOps.length;r++){var i=id(this.pendingOps[t],e);if(i)return this._hardRollback(i)}try{this._otApply(e,!1)}catch(s){return this._hardRollback(s)}}this.version++,this._clearInflightOp()},Xt.prototype._rollback=function(n){var t=this.inflightOp;if("op"in t&&t.type.invert){try{t.op=t.type.invert(t.op)}catch{return this._hardRollback(n)}for(var e=0;e<this.pendingOps.length;e++){var r=id(this.pendingOps[e],t);if(r)return this._hardRollback(r)}try{this._otApply(t,!1)}catch(i){return this._hardRollback(i)}this._clearInflightOp(n);return}this._hardRollback(n)},Xt.prototype._hardRollback=function(n){var t=[];this.inflightOp&&t.push(this.inflightOp),t=t.concat(this.pendingOps),this._setType(null),this.version=null,this.inflightOp=null,this.pendingOps=[];var e=this;this.fetch(function(){for(var r=!!t.length,i=0;i<t.length;i++)r=yi.callEach(t[i].callbacks,n)&&r;if(n&&!r)return e.emit("error",n)})},Xt.prototype._clearInflightOp=function(n){var t=this.inflightOp;this.inflightOp=null;var e=yi.callEach(t.callbacks,n);if(this.flush(),this._emitNothingPending(),n&&!e)return this.emit("error",n)};var DT=al,_T=ul.ACTIONS,uU=Wr,fU=cr;function cr(n,t,e,r,i,s,o){DT.EventEmitter.call(this),this.action=n,this.connection=t,this.id=e,this.collection=r,this.query=i,this.results=null,s&&s.results&&(this.results=s.results,delete s.results),this.extra=void 0,this.options=s,this.callback=o,this.ready=!1,this.sent=!1}DT.mixin(cr),cr.prototype.hasPending=function(){return!this.ready},cr.prototype.send=function(){if(!!this.connection.canSend){var n={a:this.action,id:this.id,c:this.collection,q:this.query};if(this.options&&(n.o=this.options),this.results){for(var t=[],e=0;e<this.results.length;e++){var r=this.results[e];t.push([r.id,r.version])}n.r=t}this.connection.send(n),this.sent=!0}},cr.prototype.destroy=function(n){this.connection.canSend&&this.action===_T.querySubscribe&&this.connection.send({a:_T.queryUnsubscribe,id:this.id}),this.connection._destroyQuery(this),n&&uU.nextTick(n)},cr.prototype._onConnectionStateChanged=function(){this.connection.canSend&&!this.sent?this.send():this.sent=!1},cr.prototype._handleFetch=function(n,t,e){this.connection._destroyQuery(this),this._handleResponse(n,t,e)},cr.prototype._handleSubscribe=function(n,t,e){this._handleResponse(n,t,e)},cr.prototype._handleResponse=function(n,t,e){var r=this.callback;if(this.callback=null,n)return this._finishResponse(n,r);if(!t)return this._finishResponse(null,r);var i=this,s=1,o=function(h){if(h)return i._finishResponse(h,r);--s||i._finishResponse(null,r)};if(Array.isArray(t))s+=t.length,this.results=this._ingestSnapshots(t,o),this.extra=e;else for(var l in t){s++;var c=t[l],d=this.connection.get(c.c||this.collection,l);d.ingestSnapshot(c,o)}o()},cr.prototype._ingestSnapshots=function(n,t){for(var e=[],r=0;r<n.length;r++){var i=n[r],s=this.connection.get(i.c||this.collection,i.d);s.ingestSnapshot(i,t),e.push(s)}return e},cr.prototype._finishResponse=function(n,t){if(this.emit("ready"),this.ready=!0,n)return this.connection._destroyQuery(this),t?t(n):this.emit("error",n);t&&t(null,this.results,this.extra)},cr.prototype._handleError=function(n){this.emit("error",n)},cr.prototype._handleDiff=function(n){for(var t=0;t<n.length;t++){var e=n[t];e.type==="insert"&&(e.values=this._ingestSnapshots(e.values))}for(var t=0;t<n.length;t++){var e=n[t];switch(e.type){case"insert":var r=e.values;Array.prototype.splice.apply(this.results,[e.index,0].concat(r)),this.emit("insert",r,e.index);break;case"remove":var s=e.howMany||1,i=this.results.splice(e.index,s);this.emit("remove",i,e.index);break;case"move":var s=e.howMany||1,o=this.results.splice(e.from,s);Array.prototype.splice.apply(this.results,[e.to,0].concat(o)),this.emit("move",o,e.from,e.to);break}}this.emit("changed",this.results)},cr.prototype._handleExtra=function(n){this.extra=n,this.emit("extra",n)};var MT=al,dU=ul.ACTIONS,hU=Wr,UT=rs;function rs(n,t){if(MT.EventEmitter.call(this),!t||typeof t!="string")throw new Error("LocalPresence presenceId must be a string");this.presence=n,this.presenceId=t,this.connection=n.connection,this.presenceVersion=0,this.value=null,this._pendingMessages=[],this._callbacksByPresenceVersion={}}MT.mixin(rs),rs.prototype.submit=function(n,t){this.value=n,this.send(t)},rs.prototype.send=function(n){var t=this._message();this._pendingMessages.push(t),this._callbacksByPresenceVersion[t.pv]=n,this._sendPending()},rs.prototype.destroy=function(n){var t=this;this.submit(null,function(e){if(e)return t._callbackOrEmit(e,n);delete t.presence.localPresences[t.presenceId],n&&n()})},rs.prototype._sendPending=function(){if(!!this.connection.canSend){var n=this;this._pendingMessages.forEach(function(t){n.connection.send(t)}),this._pendingMessages=[]}},rs.prototype._ack=function(n,t){var e=this._getCallback(t);this._callbackOrEmit(n,e)},rs.prototype._message=function(){return{a:dU.presence,ch:this.presence.channel,id:this.presenceId,p:this.value,pv:this.presenceVersion++}},rs.prototype._getCallback=function(n){var t=this._callbacksByPresenceVersion[n];return delete this._callbacksByPresenceVersion[n],t},rs.prototype._callbackOrEmit=function(n,t){if(t)return hU.nextTick(t,n);n&&this.emit("error",n)};var mU=Wr,OT=kC;function kC(n,t){this.presence=n,this.presenceId=t,this.connection=this.presence.connection,this.value=null,this.presenceVersion=0}kC.prototype.receiveUpdate=function(n){n.pv<this.presenceVersion||(this.value=n.p,this.presenceVersion=n.pv,this.presence._updateRemotePresence(this))},kC.prototype.destroy=function(n){delete this.presence._remotePresenceInstances[this.presenceId],delete this.presence.remotePresences[this.presenceId],n&&mU.nextTick(n)};var RC={exports:{}};(function(n,t){(function(e,r){r(t)})(vn,function(e){function r(y,I){I=I|0;for(var U=Math.max(y.length-I,0),F=Array(U),z=0;z<U;z++)F[z]=y[I+z];return F}var i=function(y){var I=r(arguments,1);return function(){var U=r(arguments);return y.apply(null,I.concat(U))}},s=function(y){return function(){var I=r(arguments),U=I.pop();y.call(this,I,U)}};function o(y){var I=typeof y;return y!=null&&(I=="object"||I=="function")}var l=typeof setImmediate=="function"&&setImmediate,c=typeof process=="object"&&typeof process.nextTick=="function";function d(y){setTimeout(y,0)}function h(y){return function(I){var U=r(arguments,1);y(function(){I.apply(null,U)})}}var C;l?C=setImmediate:c?C=process.nextTick:C=d;var E=h(C);function A(y){return s(function(I,U){var F;try{F=y.apply(this,I)}catch(z){return U(z)}o(F)&&typeof F.then=="function"?F.then(function(z){v(U,null,z)},function(z){v(U,z.message?z:new Error(z))}):U(null,F)})}function v(y,I,U){try{y(I,U)}catch(F){E(R,F)}}function R(y){throw y}var S=typeof Symbol=="function";function O(y){return S&&y[Symbol.toStringTag]==="AsyncFunction"}function M(y){return O(y)?A(y):y}function V(y){return function(I){var U=r(arguments,1),F=s(function(z,j){var Z=this;return y(I,function(rt,mt){M(rt).apply(Z,z.concat(mt))},j)});return U.length?F.apply(this,U):F}}var J=typeof vn=="object"&&vn&&vn.Object===Object&&vn,Q=typeof self=="object"&&self&&self.Object===Object&&self,X=J||Q||Function("return this")(),ct=X.Symbol,xt=Object.prototype,bt=xt.hasOwnProperty,wt=xt.toString,yt=ct?ct.toStringTag:void 0;function Yt(y){var I=bt.call(y,yt),U=y[yt];try{y[yt]=void 0;var F=!0}catch{}var z=wt.call(y);return F&&(I?y[yt]=U:delete y[yt]),z}var Ve=Object.prototype,Ce=Ve.toString;function Gn(y){return Ce.call(y)}var Jr="[object Null]",Mn="[object Undefined]",Bn=ct?ct.toStringTag:void 0;function Zr(y){return y==null?y===void 0?Mn:Jr:Bn&&Bn in Object(y)?Yt(y):Gn(y)}var Oi="[object AsyncFunction]",fr="[object Function]",lh="[object GeneratorFunction]",ah="[object Proxy]";function ch(y){if(!o(y))return!1;var I=Zr(y);return I==fr||I==lh||I==Oi||I==ah}var ps=9007199254740991;function so(y){return typeof y=="number"&&y>-1&&y%1==0&&y<=ps}function oo(y){return y!=null&&so(y.length)&&!ch(y)}var ee={};function zt(){}function ti(y){return function(){if(y!==null){var I=y;y=null,I.apply(this,arguments)}}}var Un=typeof Symbol=="function"&&Symbol.iterator,lo=function(y){return Un&&y[Un]&&y[Un]()};function Ua(y,I){for(var U=-1,F=Array(y);++U<y;)F[U]=I(U);return F}function Tn(y){return y!=null&&typeof y=="object"}var Cs="[object Arguments]";function Oa(y){return Tn(y)&&Zr(y)==Cs}var tr=Object.prototype,Nu=tr.hasOwnProperty,uh=tr.propertyIsEnumerable,ao=Oa(function(){return arguments}())?Oa:function(y){return Tn(y)&&Nu.call(y,"callee")&&!uh.call(y,"callee")},_e=Array.isArray;function co(){return!1}var uo=typeof e=="object"&&e&&!e.nodeType&&e,Pu=uo&&!0&&n&&!n.nodeType&&n,fo=Pu&&Pu.exports===uo,Fu=fo?X.Buffer:void 0,ho=Fu?Fu.isBuffer:void 0,Es=ho||co,mo=9007199254740991,Na=/^(?:0|[1-9]\d*)$/;function Pa(y,I){var U=typeof y;return I=I==null?mo:I,!!I&&(U=="number"||U!="symbol"&&Na.test(y))&&y>-1&&y%1==0&&y<I}var go="[object Arguments]",Fa="[object Array]",Ka="[object Boolean]",As="[object Date]",po="[object Error]",Sl="[object Function]",Ku="[object Map]",Sr="[object Number]",xs="[object Object]",Vu="[object RegExp]",Va="[object Set]",$u="[object String]",fh="[object WeakMap]",dh="[object ArrayBuffer]",hh="[object DataView]",Ll="[object Float32Array]",Co="[object Float64Array]",$a="[object Int8Array]",bs="[object Int16Array]",Eo="[object Int32Array]",Ao="[object Uint8Array]",Ha="[object Uint8ClampedArray]",mh="[object Uint16Array]",gh="[object Uint32Array]",Ee={};Ee[Ll]=Ee[Co]=Ee[$a]=Ee[bs]=Ee[Eo]=Ee[Ao]=Ee[Ha]=Ee[mh]=Ee[gh]=!0,Ee[go]=Ee[Fa]=Ee[dh]=Ee[Ka]=Ee[hh]=Ee[As]=Ee[po]=Ee[Sl]=Ee[Ku]=Ee[Sr]=Ee[xs]=Ee[Vu]=Ee[Va]=Ee[$u]=Ee[fh]=!1;function ph(y){return Tn(y)&&so(y.length)&&!!Ee[Zr(y)]}function Il(y){return function(I){return y(I)}}var Dl=typeof e=="object"&&e&&!e.nodeType&&e,vs=Dl&&!0&&n&&!n.nodeType&&n,Ni=vs&&vs.exports===Dl,_l=Ni&&J.process,Hu=function(){try{var y=vs&&vs.require&&vs.require("util").types;return y||_l&&_l.binding&&_l.binding("util")}catch{}}(),ju=Hu&&Hu.isTypedArray,Ch=ju?Il(ju):ph,Eh=Object.prototype,Lr=Eh.hasOwnProperty;function Ah(y,I){var U=_e(y),F=!U&&ao(y),z=!U&&!F&&Es(y),j=!U&&!F&&!z&&Ch(y),Z=U||F||z||j,rt=Z?Ua(y.length,String):[],mt=rt.length;for(var Tt in y)(I||Lr.call(y,Tt))&&!(Z&&(Tt=="length"||z&&(Tt=="offset"||Tt=="parent")||j&&(Tt=="buffer"||Tt=="byteLength"||Tt=="byteOffset")||Pa(Tt,mt)))&&rt.push(Tt);return rt}var Ml=Object.prototype;function xh(y){var I=y&&y.constructor,U=typeof I=="function"&&I.prototype||Ml;return y===U}function Ul(y,I){return function(U){return y(I(U))}}var bh=Ul(Object.keys,Object),Ir=Object.prototype,vh=Ir.hasOwnProperty;function zu(y){if(!xh(y))return bh(y);var I=[];for(var U in Object(y))vh.call(y,U)&&U!="constructor"&&I.push(U);return I}function Ol(y){return oo(y)?Ah(y):zu(y)}function Gu(y){var I=-1,U=y.length;return function(){return++I<U?{value:y[I],key:I}:null}}function Bh(y){var I=-1;return function(){var F=y.next();return F.done?null:(I++,{value:F.value,key:I})}}function xo(y){var I=Ol(y),U=-1,F=I.length;return function z(){var j=I[++U];return j==="__proto__"?z():U<F?{value:y[j],key:j}:null}}function Th(y){if(oo(y))return Gu(y);var I=lo(y);return I?Bh(I):xo(y)}function dr(y){return function(){if(y===null)throw new Error("Callback was already called.");var I=y;y=null,I.apply(this,arguments)}}function On(y){return function(I,U,F){if(F=ti(F||zt),y<=0||!I)return F(null);var z=Th(I),j=!1,Z=0,rt=!1;function mt(gt,Lt){if(Z-=1,gt)j=!0,F(gt);else{if(Lt===ee||j&&Z<=0)return j=!0,F(null);rt||Tt()}}function Tt(){for(rt=!0;Z<y&&!j;){var gt=z();if(gt===null){j=!0,Z<=0&&F(null);return}Z+=1,U(gt.value,gt.key,dr(mt))}rt=!1}Tt()}}function ei(y,I,U,F){On(I)(y,M(U),F)}function Ge(y,I){return function(U,F,z){return y(U,I,F,z)}}function ja(y,I,U){U=ti(U||zt);var F=0,z=0,j=y.length;j===0&&U(null);function Z(rt,mt){rt?U(rt):(++z===j||mt===ee)&&U(null)}for(;F<j;F++)I(y[F],F,dr(Z))}var yh=Ge(ei,1/0),Dr=function(y,I,U){var F=oo(y)?ja:yh;F(y,M(I),U)};function _r(y){return function(I,U,F){return y(Dr,I,M(U),F)}}function Bs(y,I,U,F){F=F||zt,I=I||[];var z=[],j=0,Z=M(U);y(I,function(rt,mt,Tt){var gt=j++;Z(rt,function(Lt,de){z[gt]=de,Tt(Lt)})},function(rt){F(rt,z)})}var bo=_r(Bs),za=V(bo);function Pi(y){return function(I,U,F,z){return y(On(U),I,M(F),z)}}var hr=Pi(Bs),Ga=Ge(hr,1),Wa=V(Ga);function Ts(y,I){for(var U=-1,F=y==null?0:y.length;++U<F&&I(y[U],U,y)!==!1;);return y}function qa(y){return function(I,U,F){for(var z=-1,j=Object(I),Z=F(I),rt=Z.length;rt--;){var mt=Z[y?rt:++z];if(U(j[mt],mt,j)===!1)break}return I}}var ys=qa();function ks(y,I){return y&&ys(y,I,Ol)}function Wu(y,I,U,F){for(var z=y.length,j=U+(F?1:-1);F?j--:++j<z;)if(I(y[j],j,y))return j;return-1}function kh(y){return y!==y}function qu(y,I,U){for(var F=U-1,z=y.length;++F<z;)if(y[F]===I)return F;return-1}function vo(y,I,U){return I===I?qu(y,I,U):Wu(y,kh,U)}var Nl=function(y,I,U){typeof I=="function"&&(U=I,I=null),U=ti(U||zt);var F=Ol(y),z=F.length;if(!z)return U(null);I||(I=z);var j={},Z=0,rt=!1,mt=Object.create(null),Tt=[],gt=[],Lt={};ks(y,function(Ie,Te){if(!_e(Ie)){de(Te,[Ie]),gt.push(Te);return}var Pe=Ie.slice(0,Ie.length-1),li=Pe.length;if(li===0){de(Te,Ie),gt.push(Te);return}Lt[Te]=li,Ts(Pe,function(w){if(!y[w])throw new Error("async.auto task `"+Te+"` has a non-existent dependency `"+w+"` in "+Pe.join(", "));Pn(w,function(){li--,li===0&&de(Te,Ie)})})}),Lx(),en();function de(Ie,Te){Tt.push(function(){oi(Ie,Te)})}function en(){if(Tt.length===0&&Z===0)return U(null,j);for(;Tt.length&&Z<I;){var Ie=Tt.shift();Ie()}}function Pn(Ie,Te){var Pe=mt[Ie];Pe||(Pe=mt[Ie]=[]),Pe.push(Te)}function mr(Ie){var Te=mt[Ie]||[];Ts(Te,function(Pe){Pe()}),en()}function oi(Ie,Te){if(!rt){var Pe=dr(function(w,Is){if(Z--,arguments.length>2&&(Is=r(arguments,1)),w){var Hl={};ks(j,function(gr,Qt){Hl[Qt]=gr}),Hl[Ie]=Is,rt=!0,mt=Object.create(null),U(w,Hl)}else j[Ie]=Is,mr(Ie)});Z++;var li=M(Te[Te.length-1]);Te.length>1?li(j,Pe):li(Pe)}}function Lx(){for(var Ie,Te=0;gt.length;)Ie=gt.pop(),Te++,Ts(Ix(Ie),function(Pe){--Lt[Pe]===0&>.push(Pe)});if(Te!==z)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function Ix(Ie){var Te=[];return ks(y,function(Pe,li){_e(Pe)&&vo(Pe,Ie,0)>=0&&Te.push(li)}),Te}};function ni(y,I){for(var U=-1,F=y==null?0:y.length,z=Array(F);++U<F;)z[U]=I(y[U],U,y);return z}var Rh="[object Symbol]";function Xu(y){return typeof y=="symbol"||Tn(y)&&Zr(y)==Rh}var wh=1/0,Xa=ct?ct.prototype:void 0,Bo=Xa?Xa.toString:void 0;function Ya(y){if(typeof y=="string")return y;if(_e(y))return ni(y,Ya)+"";if(Xu(y))return Bo?Bo.call(y):"";var I=y+"";return I=="0"&&1/y==-wh?"-0":I}function Rs(y,I,U){var F=-1,z=y.length;I<0&&(I=-I>z?0:z+I),U=U>z?z:U,U<0&&(U+=z),z=I>U?0:U-I>>>0,I>>>=0;for(var j=Array(z);++F<z;)j[F]=y[F+I];return j}function ri(y,I,U){var F=y.length;return U=U===void 0?F:U,!I&&U>=F?y:Rs(y,I,U)}function Qa(y,I){for(var U=y.length;U--&&vo(I,y[U],0)>-1;);return U}function Yu(y,I){for(var U=-1,F=y.length;++U<F&&vo(I,y[U],0)>-1;);return U}function Pl(y){return y.split("")}var Sh="\\ud800-\\udfff",Lh="\\u0300-\\u036f",Ih="\\ufe20-\\ufe2f",me="\\u20d0-\\u20ff",fe=Lh+Ih+me,Dh="\\ufe0e\\ufe0f",Fl="\\u200d",Fi=RegExp("["+Fl+Sh+fe+Dh+"]");function _h(y){return Fi.test(y)}var Kl="\\ud800-\\udfff",Qu="\\u0300-\\u036f",Ja="\\ufe20-\\ufe2f",Ki="\\u20d0-\\u20ff",We=Qu+Ja+Ki,Za="\\ufe0e\\ufe0f",ii="["+Kl+"]",ws="["+We+"]",si="\\ud83c[\\udffb-\\udfff]",En="(?:"+ws+"|"+si+")",To="[^"+Kl+"]",tc="(?:\\ud83c[\\udde6-\\uddff]){2}",ec="[\\ud800-\\udbff][\\udc00-\\udfff]",Ju="\\u200d",nc=En+"?",yo="["+Za+"]?",Nn="(?:"+Ju+"(?:"+[To,tc,ec].join("|")+")"+yo+nc+")*",Mh=yo+nc+Nn,Wn="(?:"+[To+ws+"?",ws,tc,ec,ii].join("|")+")",k=RegExp(si+"(?="+si+")|"+Wn+Mh,"g");function N(y){return y.match(k)||[]}function W(y){return _h(y)?N(y):Pl(y)}function lt(y){return y==null?"":Ya(y)}var St=/^\s+|\s+$/g;function ft(y,I,U){if(y=lt(y),y&&(U||I===void 0))return y.replace(St,"");if(!y||!(I=Ya(I)))return y;var F=W(y),z=W(I),j=Yu(F,z),Z=Qa(F,z)+1;return ri(F,j,Z).join("")}var $t=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,te=/,/,ce=/(=.+)?(\s*)$/,Re=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;function we(y){return y=y.toString().replace(Re,""),y=y.match($t)[2].replace(" ",""),y=y?y.split(te):[],y=y.map(function(I){return ft(I.replace(ce,""))}),y}function Le(y,I){var U={};ks(y,function(F,z){var j,Z=O(F),rt=!Z&&F.length===1||Z&&F.length===0;if(_e(F))j=F.slice(0,-1),F=F[F.length-1],U[z]=j.concat(j.length>0?mt:F);else if(rt)U[z]=F;else{if(j=we(F),F.length===0&&!Z&&j.length===0)throw new Error("autoInject task functions require explicit parameters.");Z||j.pop(),U[z]=j.concat(mt)}function mt(Tt,gt){var Lt=ni(j,function(de){return Tt[de]});Lt.push(gt),M(F).apply(null,Lt)}}),Nl(U,I)}function ne(){this.head=this.tail=null,this.length=0}function yn(y,I){y.length=1,y.head=y.tail=I}ne.prototype.removeLink=function(y){return y.prev?y.prev.next=y.next:this.head=y.next,y.next?y.next.prev=y.prev:this.tail=y.prev,y.prev=y.next=null,this.length-=1,y},ne.prototype.empty=function(){for(;this.head;)this.shift();return this},ne.prototype.insertAfter=function(y,I){I.prev=y,I.next=y.next,y.next?y.next.prev=I:this.tail=I,y.next=I,this.length+=1},ne.prototype.insertBefore=function(y,I){I.prev=y.prev,I.next=y,y.prev?y.prev.next=I:this.head=I,y.prev=I,this.length+=1},ne.prototype.unshift=function(y){this.head?this.insertBefore(this.head,y):yn(this,y)},ne.prototype.push=function(y){this.tail?this.insertAfter(this.tail,y):yn(this,y)},ne.prototype.shift=function(){return this.head&&this.removeLink(this.head)},ne.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)},ne.prototype.toArray=function(){for(var y=Array(this.length),I=this.head,U=0;U<this.length;U++)y[U]=I.data,I=I.next;return y},ne.prototype.remove=function(y){for(var I=this.head;I;){var U=I.next;y(I)&&this.removeLink(I),I=U}return this};function un(y,I,U){if(I==null)I=1;else if(I===0)throw new Error("Concurrency must not be zero");var F=M(y),z=0,j=[],Z=!1;function rt(Lt,de,en){if(en!=null&&typeof en!="function")throw new Error("task callback must be a function");if(gt.started=!0,_e(Lt)||(Lt=[Lt]),Lt.length===0&>.idle())return E(function(){gt.drain()});for(var Pn=0,mr=Lt.length;Pn<mr;Pn++){var oi={data:Lt[Pn],callback:en||zt};de?gt._tasks.unshift(oi):gt._tasks.push(oi)}Z||(Z=!0,E(function(){Z=!1,gt.process()}))}function mt(Lt){return function(de){z-=1;for(var en=0,Pn=Lt.length;en<Pn;en++){var mr=Lt[en],oi=vo(j,mr,0);oi===0?j.shift():oi>0&&j.splice(oi,1),mr.callback.apply(mr,arguments),de!=null&>.error(de,mr.data)}z<=gt.concurrency-gt.buffer&>.unsaturated(),gt.idle()&>.drain(),gt.process()}}var Tt=!1,gt={_tasks:new ne,concurrency:I,payload:U,saturated:zt,unsaturated:zt,buffer:I/4,empty:zt,drain:zt,error:zt,started:!1,paused:!1,push:function(Lt,de){rt(Lt,!1,de)},kill:function(){gt.drain=zt,gt._tasks.empty()},unshift:function(Lt,de){rt(Lt,!0,de)},remove:function(Lt){gt._tasks.remove(Lt)},process:function(){if(!Tt){for(Tt=!0;!gt.paused&&z<gt.concurrency&>._tasks.length;){var Lt=[],de=[],en=gt._tasks.length;gt.payload&&(en=Math.min(en,gt.payload));for(var Pn=0;Pn<en;Pn++){var mr=gt._tasks.shift();Lt.push(mr),j.push(mr),de.push(mr.data)}z+=1,gt._tasks.length===0&>.empty(),z===gt.concurrency&>.saturated();var oi=dr(mt(Lt));F(de,oi)}Tt=!1}},length:function(){return gt._tasks.length},running:function(){return z},workersList:function(){return j},idle:function(){return gt._tasks.length+z===0},pause:function(){gt.paused=!0},resume:function(){gt.paused!==!1&&(gt.paused=!1,E(gt.process))}};return gt}function kn(y,I){return un(y,1,I)}var Rn=Ge(ei,1);function An(y,I,U,F){F=ti(F||zt);var z=M(U);Rn(y,function(j,Z,rt){z(I,j,function(mt,Tt){I=Tt,rt(mt)})},function(j){F(j,I)})}function ko(){var y=ni(arguments,M);return function(){var I=r(arguments),U=this,F=I[I.length-1];typeof F=="function"?I.pop():F=zt,An(y,I,function(z,j,Z){j.apply(U,z.concat(function(rt){var mt=r(arguments,1);Z(rt,mt)}))},function(z,j){F.apply(U,[z].concat(j))})}}var Vi=function(){return ko.apply(null,r(arguments).reverse())},Ss=Array.prototype.concat,rc=function(y,I,U,F){F=F||zt;var z=M(U);hr(y,I,function(j,Z){z(j,function(rt){return rt?Z(rt):Z(null,r(arguments,1))})},function(j,Z){for(var rt=[],mt=0;mt<Z.length;mt++)Z[mt]&&(rt=Ss.apply(rt,Z[mt]));return F(j,rt)})},Ng=Ge(rc,1/0),Zu=Ge(rc,1),tf=function(){var y=r(arguments),I=[null].concat(y);return function(){var U=arguments[arguments.length-1];return U.apply(this,I)}};function ic(y){return y}function Ro(y,I){return function(U,F,z,j){j=j||zt;var Z=!1,rt;U(F,function(mt,Tt,gt){z(mt,function(Lt,de){Lt?gt(Lt):y(de)&&!rt?(Z=!0,rt=I(!0,mt),gt(null,ee)):gt()})},function(mt){mt?j(mt):j(null,Z?rt:I(!1))})}}function qn(y,I){return I}var Vl=_r(Ro(ic,qn)),$i=Pi(Ro(ic,qn)),sc=Ge($i,1);function Uh(y){return function(I){var U=r(arguments,1);U.push(function(F){var z=r(arguments,1);typeof console=="object"&&(F?console.error&&console.error(F):console[y]&&Ts(z,function(j){console[y](j)}))}),M(I).apply(null,U)}}var Pg=Uh("dir");function Fg(y,I,U){U=dr(U||zt);var F=M(y),z=M(I);function j(rt){if(rt)return U(rt);var mt=r(arguments,1);mt.push(Z),z.apply(this,mt)}function Z(rt,mt){if(rt)return U(rt);if(!mt)return U(null);F(j)}Z(null,!0)}function Oh(y,I,U){U=dr(U||zt);var F=M(y),z=function(j){if(j)return U(j);var Z=r(arguments,1);if(I.apply(this,Z))return F(z);U.apply(null,[null].concat(Z))};F(z)}function Kg(y,I,U){Oh(y,function(){return!I.apply(this,arguments)},U)}function Vg(y,I,U){U=dr(U||zt);var F=M(I),z=M(y);function j(rt){if(rt)return U(rt);z(Z)}function Z(rt,mt){if(rt)return U(rt);if(!mt)return U(null);F(j)}z(Z)}function wo(y){return function(I,U,F){return y(I,F)}}function ef(y,I,U){Dr(y,wo(M(I)),U)}function oc(y,I,U,F){On(I)(y,wo(M(U)),F)}var So=Ge(oc,1);function nf(y){return O(y)?y:s(function(I,U){var F=!0;I.push(function(){var z=arguments;F?E(function(){U.apply(null,z)}):U.apply(null,z)}),y.apply(this,I),F=!1})}function Mr(y){return!y}var Lo=_r(Ro(Mr,Mr)),lc=Pi(Ro(Mr,Mr)),rf=Ge(lc,1);function $g(y){return function(I){return I==null?void 0:I[y]}}function $l(y,I,U,F){var z=new Array(I.length);y(I,function(j,Z,rt){U(j,function(mt,Tt){z[Z]=!!Tt,rt(mt)})},function(j){if(j)return F(j);for(var Z=[],rt=0;rt<I.length;rt++)z[rt]&&Z.push(I[rt]);F(null,Z)})}function Ur(y,I,U,F){var z=[];y(I,function(j,Z,rt){U(j,function(mt,Tt){mt?rt(mt):(Tt&&z.push({index:Z,value:j}),rt())})},function(j){j?F(j):F(null,ni(z.sort(function(Z,rt){return Z.index-rt.index}),$g("value")))})}function sf(y,I,U,F){var z=oo(I)?$l:Ur;z(y,I,M(U),F||zt)}var of=_r(sf),ac=Pi(sf),lf=Ge(ac,1);function Hg(y,I){var U=dr(I||zt),F=M(nf(y));function z(j){if(j)return U(j);F(z)}z()}var af=function(y,I,U,F){F=F||zt;var z=M(U);hr(y,I,function(j,Z){z(j,function(rt,mt){return rt?Z(rt):Z(null,{key:mt,val:j})})},function(j,Z){for(var rt={},mt=Object.prototype.hasOwnProperty,Tt=0;Tt<Z.length;Tt++)if(Z[Tt]){var gt=Z[Tt].key,Lt=Z[Tt].val;mt.call(rt,gt)?rt[gt].push(Lt):rt[gt]=[Lt]}return F(j,rt)})},Io=Ge(af,1/0),$=Ge(af,1),Y=Uh("log");function G(y,I,U,F){F=ti(F||zt);var z={},j=M(U);ei(y,I,function(Z,rt,mt){j(Z,rt,function(Tt,gt){if(Tt)return mt(Tt);z[rt]=gt,mt()})},function(Z){F(Z,z)})}var vt=Ge(G,1/0),Nt=Ge(G,1);function se(y,I){return I in y}function qe(y,I){var U=Object.create(null),F=Object.create(null);I=I||ic;var z=M(y),j=s(function(rt,mt){var Tt=I.apply(null,rt);se(U,Tt)?E(function(){mt.apply(null,U[Tt])}):se(F,Tt)?F[Tt].push(mt):(F[Tt]=[mt],z.apply(null,rt.concat(function(){var gt=r(arguments);U[Tt]=gt;var Lt=F[Tt];delete F[Tt];for(var de=0,en=Lt.length;de<en;de++)Lt[de].apply(null,gt)})))});return j.memo=U,j.unmemoized=y,j}var ue;c?ue=process.nextTick:l?ue=setImmediate:ue=d;var cf=h(ue);function Nh(y,I,U){U=U||zt;var F=oo(I)?[]:{};y(I,function(z,j,Z){M(z)(function(rt,mt){arguments.length>2&&(mt=r(arguments,1)),F[j]=mt,Z(rt)})},function(z){U(z,F)})}function er(y,I){Nh(Dr,y,I)}function cc(y,I,U){Nh(On(I),y,U)}var Ph=function(y,I){var U=M(y);return un(function(F,z){U(F[0],z)},I,1)},Do=function(y,I){var U=Ph(y,I);return U.push=function(F,z,j){if(j==null&&(j=zt),typeof j!="function")throw new Error("task callback must be a function");if(U.started=!0,_e(F)||(F=[F]),F.length===0)return E(function(){U.drain()});z=z||0;for(var Z=U._tasks.head;Z&&z>=Z.priority;)Z=Z.next;for(var rt=0,mt=F.length;rt<mt;rt++){var Tt={data:F[rt],priority:z,callback:j};Z?U._tasks.insertBefore(Z,Tt):U._tasks.push(Tt)}E(U.process)},delete U.unshift,U};function uc(y,I){if(I=ti(I||zt),!_e(y))return I(new TypeError("First argument to race must be an array of functions"));if(!y.length)return I();for(var U=0,F=y.length;U<F;U++)M(y[U])(I)}function _o(y,I,U,F){var z=r(y).reverse();An(z,I,U,F)}function oe(y){var I=M(y);return s(function(F,z){return F.push(function(Z,rt){if(Z)z(null,{error:Z});else{var mt;arguments.length<=2?mt=rt:mt=r(arguments,1),z(null,{value:mt})}}),I.apply(this,F)})}function jg(y){var I;return _e(y)?I=ni(y,oe):(I={},ks(y,function(U,F){I[F]=oe.call(this,U)})),I}function Fh(y,I,U,F){sf(y,I,function(z,j){U(z,function(Z,rt){j(Z,!rt)})},F)}var fc=_r(Fh),Kh=Pi(Fh),zg=Ge(Kh,1);function Gg(y){return function(){return y}}function Mo(y,I,U){var F=5,z=0,j={times:F,intervalFunc:Gg(z)};function Z(gt,Lt){if(typeof Lt=="object")gt.times=+Lt.times||F,gt.intervalFunc=typeof Lt.interval=="function"?Lt.interval:Gg(+Lt.interval||z),gt.errorFilter=Lt.errorFilter;else if(typeof Lt=="number"||typeof Lt=="string")gt.times=+Lt||F;else throw new Error("Invalid arguments for async.retry")}if(arguments.length<3&&typeof y=="function"?(U=I||zt,I=y):(Z(j,y),U=U||zt),typeof I!="function")throw new Error("Invalid arguments for async.retry");var rt=M(I),mt=1;function Tt(){rt(function(gt){gt&&mt++<j.times&&(typeof j.errorFilter!="function"||j.errorFilter(gt))?setTimeout(Tt,j.intervalFunc(mt)):U.apply(null,arguments)})}Tt()}var Hi=function(y,I){I||(I=y,y=null);var U=M(I);return s(function(F,z){function j(Z){U.apply(null,F.concat(Z))}y?Mo(y,j,z):Mo(j,z)})};function dc(y,I){Nh(Rn,y,I)}var hc=_r(Ro(Boolean,ic)),Ls=Pi(Ro(Boolean,ic)),mc=Ge(Ls,1);function Vh(y,I,U){var F=M(I);bo(y,function(j,Z){F(j,function(rt,mt){if(rt)return Z(rt);Z(null,{value:j,criteria:mt})})},function(j,Z){if(j)return U(j);U(null,ni(Z.sort(z),$g("value")))});function z(j,Z){var rt=j.criteria,mt=Z.criteria;return rt<mt?-1:rt>mt?1:0}}function gc(y,I,U){var F=M(y);return s(function(z,j){var Z=!1,rt;function mt(){var Tt=y.name||"anonymous",gt=new Error('Callback function "'+Tt+'" timed out.');gt.code="ETIMEDOUT",U&&(gt.info=U),Z=!0,j(gt)}z.push(function(){Z||(j.apply(null,arguments),clearTimeout(rt))}),rt=setTimeout(mt,I),F.apply(null,z)})}var Wg=Math.ceil,pc=Math.max;function Uo(y,I,U,F){for(var z=-1,j=pc(Wg((I-y)/(U||1)),0),Z=Array(j);j--;)Z[F?j:++z]=y,y+=U;return Z}function Oo(y,I,U,F){var z=M(U);hr(Uo(0,y,1),I,z,F)}var qg=Ge(Oo,1/0),Xg=Ge(Oo,1);function Yg(y,I,U,F){arguments.length<=3&&(F=U,U=I,I=_e(y)?[]:{}),F=ti(F||zt);var z=M(U);Dr(y,function(j,Z,rt){z(I,j,Z,rt)},function(j){F(j,I)})}function Cc(y,I){var U=null,F;I=I||zt,So(y,function(z,j){M(z)(function(Z,rt){arguments.length>2?F=r(arguments,1):F=rt,U=Z,j(!Z)})},function(){I(U,F)})}function Ec(y){return function(){return(y.unmemoized||y).apply(null,arguments)}}function Ac(y,I,U){U=dr(U||zt);var F=M(I);if(!y())return U(null);var z=function(j){if(j)return U(j);if(y())return F(z);var Z=r(arguments,1);U.apply(null,[null].concat(Z))};F(z)}function Qg(y,I,U){Ac(function(){return!y.apply(this,arguments)},I,U)}var $h=function(y,I){if(I=ti(I||zt),!_e(y))return I(new Error("First argument to waterfall must be an array of functions"));if(!y.length)return I();var U=0;function F(j){var Z=M(y[U++]);j.push(dr(z)),Z.apply(null,j)}function z(j){if(j||U===y.length)return I.apply(null,arguments);F(r(arguments,1))}F([])},Sx={apply:i,applyEach:za,applyEachSeries:Wa,asyncify:A,auto:Nl,autoInject:Le,cargo:kn,compose:Vi,concat:Ng,concatLimit:rc,concatSeries:Zu,constant:tf,detect:Vl,detectLimit:$i,detectSeries:sc,dir:Pg,doDuring:Fg,doUntil:Kg,doWhilst:Oh,during:Vg,each:ef,eachLimit:oc,eachOf:Dr,eachOfLimit:ei,eachOfSeries:Rn,eachSeries:So,ensureAsync:nf,every:Lo,everyLimit:lc,everySeries:rf,filter:of,filterLimit:ac,filterSeries:lf,forever:Hg,groupBy:Io,groupByLimit:af,groupBySeries:$,log:Y,map:bo,mapLimit:hr,mapSeries:Ga,mapValues:vt,mapValuesLimit:G,mapValuesSeries:Nt,memoize:qe,nextTick:cf,parallel:er,parallelLimit:cc,priorityQueue:Do,queue:Ph,race:uc,reduce:An,reduceRight:_o,reflect:oe,reflectAll:jg,reject:fc,rejectLimit:Kh,rejectSeries:zg,retry:Mo,retryable:Hi,seq:ko,series:dc,setImmediate:E,some:hc,someLimit:Ls,someSeries:mc,sortBy:Vh,timeout:gc,times:qg,timesLimit:Oo,timesSeries:Xg,transform:Yg,tryEach:Cc,unmemoize:Ec,until:Qg,waterfall:$h,whilst:Ac,all:Lo,allLimit:lc,allSeries:rf,any:hc,anyLimit:Ls,anySeries:mc,find:Vl,findLimit:$i,findSeries:sc,forEach:ef,forEachSeries:So,forEachLimit:oc,forEachOf:Dr,forEachOfSeries:Rn,forEachOfLimit:ei,inject:An,foldl:An,foldr:_o,select:of,selectLimit:ac,selectSeries:lf,wrapSync:A};e.default=Sx,e.apply=i,e.applyEach=za,e.applyEachSeries=Wa,e.asyncify=A,e.auto=Nl,e.autoInject=Le,e.cargo=kn,e.compose=Vi,e.concat=Ng,e.concatLimit=rc,e.concatSeries=Zu,e.constant=tf,e.detect=Vl,e.detectLimit=$i,e.detectSeries=sc,e.dir=Pg,e.doDuring=Fg,e.doUntil=Kg,e.doWhilst=Oh,e.during=Vg,e.each=ef,e.eachLimit=oc,e.eachOf=Dr,e.eachOfLimit=ei,e.eachOfSeries=Rn,e.eachSeries=So,e.ensureAsync=nf,e.every=Lo,e.everyLimit=lc,e.everySeries=rf,e.filter=of,e.filterLimit=ac,e.filterSeries=lf,e.forever=Hg,e.groupBy=Io,e.groupByLimit=af,e.groupBySeries=$,e.log=Y,e.map=bo,e.mapLimit=hr,e.mapSeries=Ga,e.mapValues=vt,e.mapValuesLimit=G,e.mapValuesSeries=Nt,e.memoize=qe,e.nextTick=cf,e.parallel=er,e.parallelLimit=cc,e.priorityQueue=Do,e.queue=Ph,e.race=uc,e.reduce=An,e.reduceRight=_o,e.reflect=oe,e.reflectAll=jg,e.reject=fc,e.rejectLimit=Kh,e.rejectSeries=zg,e.retry=Mo,e.retryable=Hi,e.seq=ko,e.series=dc,e.setImmediate=E,e.some=hc,e.someLimit=Ls,e.someSeries=mc,e.sortBy=Vh,e.timeout=gc,e.times=qg,e.timesLimit=Oo,e.timesSeries=Xg,e.transform=Yg,e.tryEach=Cc,e.unmemoize=Ec,e.until=Qg,e.waterfall=$h,e.whilst=Ac,e.all=Lo,e.allLimit=lc,e.allSeries=rf,e.any=hc,e.anyLimit=Ls,e.anySeries=mc,e.find=Vl,e.findLimit=$i,e.findSeries=sc,e.forEach=ef,e.forEachSeries=So,e.forEachLimit=oc,e.forEachOf=Dr,e.forEachOfSeries=Rn,e.forEachOfLimit=ei,e.inject=An,e.foldl=An,e.foldr=_o,e.select=of,e.selectLimit=ac,e.selectSeries=lf,e.wrapSync=A,Object.defineProperty(e,"__esModule",{value:!0})})})(RC,RC.exports);var NT={exports:{}},wC=NT.exports=function(n,t){if(t||(t=16),n===void 0&&(n=128),n<=0)return"0";for(var e=Math.log(Math.pow(2,n))/Math.log(t),r=2;e===1/0;r*=2)e=Math.log(Math.pow(2,n/r))/Math.log(t)*r;for(var i=e-Math.floor(e),s="",r=0;r<Math.floor(e);r++){var o=Math.floor(Math.random()*t).toString(t);s=o+s}if(i){var l=Math.pow(t,i),o=Math.floor(Math.random()*l).toString(t);s=o+s}var c=parseInt(s,t);return c!==1/0&&c>=Math.pow(2,n)?wC(n,t):s};wC.rack=function(n,t,e){var r=function(s){var o=0;do{if(o++>10)if(e)n+=e;else throw new Error("too many ID collisions, use more bits");var l=wC(n,t)}while(Object.hasOwnProperty.call(i,l));return i[l]=s,l},i=r.hats={};return r.get=function(s){return r.hats[s]},r.set=function(s,o){return r.hats[s]=o,r},r.bits=n||128,r.base=t||16,r};var PT=al,gU=UT,pU=OT,um=Wr,SC=RC.exports,CU=NT.exports,FT=ul.ACTIONS,KT=on;function on(n,t){if(PT.EventEmitter.call(this),!t||typeof t!="string")throw new Error("Presence channel must be provided");this.connection=n,this.channel=t,this.wantSubscribe=!1,this.subscribed=!1,this.remotePresences={},this.localPresences={},this._remotePresenceInstances={},this._subscriptionCallbacksBySeq={},this._wantsDestroy=!1}PT.mixin(on),on.prototype.subscribe=function(n){this._sendSubscriptionAction(!0,n)},on.prototype.unsubscribe=function(n){this._sendSubscriptionAction(!1,n)},on.prototype.create=function(n){if(this._wantsDestroy)throw new Error("Presence is being destroyed");n=n||CU();var t=this._createLocalPresence(n);return this.localPresences[n]=t,t},on.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this,e=Object.keys(t.localPresences);this.unsubscribe(function(r){if(r)return t._callbackOrEmit(r,n);var i=Object.keys(t._remotePresenceInstances);SC.parallel([function(s){SC.each(e,function(o,l){t.localPresences[o].destroy(l)},s)},function(s){if(!t._wantsDestroy)return s();SC.each(i,function(o,l){t._remotePresenceInstances[o].destroy(l)},s)}],function(s){t._wantsDestroy&&delete t.connection._presences[t.channel],t._callbackOrEmit(s,n)})})},on.prototype._sendSubscriptionAction=function(n,t){this.wantSubscribe=!!n;var e=this.wantSubscribe?FT.presenceSubscribe:FT.presenceUnsubscribe,r=this.connection._presenceSeq++;this._subscriptionCallbacksBySeq[r]=t,this.connection.canSend&&this.connection._sendPresenceAction(e,r,this)},on.prototype._handleSubscribe=function(n,t){this.wantSubscribe&&(this.subscribed=!0);var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},on.prototype._handleUnsubscribe=function(n,t){this.subscribed=!1;var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},on.prototype._receiveUpdate=function(n,t){var e=um.dig(this.localPresences,t.id);if(e)return e._ack(n,t.pv);if(n)return this.emit("error",n);var r=this,i=um.digOrCreate(this._remotePresenceInstances,t.id,function(){return r._createRemotePresence(t.id)});i.receiveUpdate(t)},on.prototype._updateRemotePresence=function(n){this.remotePresences[n.presenceId]=n.value,n.value===null&&this._removeRemotePresence(n.presenceId),this.emit("receive",n.presenceId,n.value)},on.prototype._broadcastAllLocalPresence=function(n){if(n)return this.emit("error",n);for(var t in this.localPresences){var e=this.localPresences[t];e.value!==null&&e.send()}},on.prototype._removeRemotePresence=function(n){this._remotePresenceInstances[n].destroy(),delete this._remotePresenceInstances[n],delete this.remotePresences[n]},on.prototype._onConnectionStateChanged=function(){if(!!this.connection.canSend){this._resubscribe();for(var n in this.localPresences)this.localPresences[n]._sendPending()}},on.prototype._resubscribe=function(){var n=[];for(var t in this._subscriptionCallbacksBySeq){var e=this._subscriptionCallback(t);n.push(e)}if(!this.wantSubscribe)return this._callEachOrEmit(n);var r=this;this.subscribe(function(i){r._callEachOrEmit(n,i)})},on.prototype._subscriptionCallback=function(n){var t=this._subscriptionCallbacksBySeq[n];return delete this._subscriptionCallbacksBySeq[n],t},on.prototype._callbackOrEmit=function(n,t){if(t)return um.nextTick(t,n);n&&this.emit("error",n)},on.prototype._createLocalPresence=function(n){return new gU(this,n)},on.prototype._createRemotePresence=function(n){return new pU(this,n)},on.prototype._callEachOrEmit=function(n,t){var e=um.callEach(n,t);!e&&t&&this.emit("error",t)};var sd=UT,VT=om,EU=Wr,$T=VT.CODES,AU=ki;function ki(n,t){sd.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this._doc=this.connection.get(this.collection,this.id),this._emitter=this.connection._docPresenceEmitter,this._isSending=!1,this._docDataVersionByPresenceVersion={},this._opHandler=this._transformAgainstOp.bind(this),this._createOrDelHandler=this._handleCreateOrDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._destroyHandler=this.destroy.bind(this),this._registerWithDoc()}ki.prototype=Object.create(sd.prototype),ki.prototype.submit=function(n,t){if(!this._doc.type){if(n===null)return this._callbackOrEmit(null,t);var e={code:$T.ERR_DOC_DOES_NOT_EXIST,message:"Cannot submit presence. Document has not been created"};return this._callbackOrEmit(e,t)}this._docDataVersionByPresenceVersion[this.presenceVersion]=this._doc._dataStateVersion,sd.prototype.submit.call(this,n,t)},ki.prototype.destroy=function(n){this._emitter.removeEventListener(this._doc,"op",this._opHandler),this._emitter.removeEventListener(this._doc,"create",this._createOrDelHandler),this._emitter.removeEventListener(this._doc,"del",this._createOrDelHandler),this._emitter.removeEventListener(this._doc,"load",this._loadHandler),this._emitter.removeEventListener(this._doc,"destroy",this._destroyHandler),sd.prototype.destroy.call(this,n)},ki.prototype._sendPending=function(){if(!this._isSending){this._isSending=!0;var n=this;this._doc.whenNothingPending(function(){n._isSending=!1,n.connection.canSend&&(n._pendingMessages.forEach(function(t){t.t=n._doc.type.uri,t.v=n._doc.version,n.connection.send(t)}),n._pendingMessages=[],n._docDataVersionByPresenceVersion={})})}},ki.prototype._registerWithDoc=function(){this._emitter.addEventListener(this._doc,"op",this._opHandler),this._emitter.addEventListener(this._doc,"create",this._createOrDelHandler),this._emitter.addEventListener(this._doc,"del",this._createOrDelHandler),this._emitter.addEventListener(this._doc,"load",this._loadHandler),this._emitter.addEventListener(this._doc,"destroy",this._destroyHandler)},ki.prototype._transformAgainstOp=function(n,t){var e=this,r=this._doc._dataStateVersion;this._pendingMessages.forEach(function(i){var s=e._docDataVersionByPresenceVersion[i.pv];if(!(s>=r))try{i.p=e._transformPresence(i.p,n,t),e._docDataVersionByPresenceVersion[i.pv]=r}catch(l){var o=e._getCallback(i.pv);e._callbackOrEmit(l,o)}});try{this.value=this._transformPresence(this.value,n,t)}catch(i){this.emit("error",i)}},ki.prototype._handleCreateOrDel=function(){this._pendingMessages.forEach(function(n){n.p=null}),this.value=null},ki.prototype._handleLoad=function(){this.value=null,this._pendingMessages=[],this._docDataVersionByPresenceVersion={}},ki.prototype._message=function(){var n=sd.prototype._message.call(this);return n.c=this.collection,n.d=this.id,n.v=null,n.t=null,n},ki.prototype._transformPresence=function(n,t,e){var r=this._doc.type;if(!EU.supportsPresence(r))throw new VT($T.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,"Type does not support presence: "+r.name);return r.transformPresence(n,t,e)};var HT={};(function(n){var t=ed,e=om,r=Wr,i=e.CODES;n.checkOp=function(l){if(l==null||typeof l!="object")return new e(i.ERR_OT_OP_BADLY_FORMED,"Op must be an object");if(l.create!=null){if(typeof l.create!="object")return new e(i.ERR_OT_OP_BADLY_FORMED,"Create data must be an object");var c=l.create.type;if(typeof c!="string")return new e(i.ERR_OT_OP_BADLY_FORMED,"Missing create type");var d=t.map[c];if(d==null||typeof d!="object")return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type")}else if(l.del!=null){if(l.del!==!0)return new e(i.ERR_OT_OP_BADLY_FORMED,"del value must be true")}else if(!("op"in l))return new e(i.ERR_OT_OP_BADLY_FORMED,"Missing op, create, or del");if(l.src!=null&&typeof l.src!="string")return new e(i.ERR_OT_OP_BADLY_FORMED,"src must be a string");if(l.seq!=null&&typeof l.seq!="number")return new e(i.ERR_OT_OP_BADLY_FORMED,"seq must be a number");if(l.src==null&&l.seq!=null||l.src!=null&&l.seq==null)return new e(i.ERR_OT_OP_BADLY_FORMED,"Both src and seq must be set together");if(l.m!=null&&typeof l.m!="object")return new e(i.ERR_OT_OP_BADLY_FORMED,"op.m must be an object or null")},n.normalizeType=function(l){return t.map[l]&&t.map[l].uri},n.apply=function(l,c){if(typeof l!="object")return new e(i.ERR_APPLY_SNAPSHOT_NOT_PROVIDED,"Missing snapshot");if(l.v!=null&&c.v!=null&&l.v!==c.v)return new e(i.ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT,"Version mismatch");if(c.create){if(l.type)return new e(i.ERR_DOC_ALREADY_CREATED,"Document already exists");var d=c.create,h=t.map[d.type];if(!h)return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=h.create(d.data),l.type=h.uri,l.v++}catch(E){return E}}else if(c.del)l.data=void 0,l.type=null,l.v++;else if("op"in c){var C=s(l,c.op);if(C)return C;l.v++}else l.v++};function s(l,c){if(!l.type)return new e(i.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(c===void 0)return new e(i.ERR_OT_OP_NOT_PROVIDED,"Missing op");var d=t.map[l.type];if(!d)return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=d.apply(l.data,c)}catch(h){return new e(i.ERR_OT_OP_NOT_APPLIED,h.message)}}n.transform=function(l,c,d){if(c.v!=null&&c.v!==d.v)return new e(i.ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM,"Version mismatch");if(d.del){if(c.create||"op"in c)return new e(i.ERR_DOC_WAS_DELETED,"Document was deleted")}else{if(d.create&&("op"in c||c.create||c.del)||"op"in d&&c.create)return new e(i.ERR_DOC_ALREADY_CREATED,"Document was created remotely");if("op"in d&&"op"in c){if(!l)return new e(i.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(typeof l=="string"&&(l=t.map[l],!l))return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{c.op=l.transform(c.op,d.op,"left")}catch(h){return h}}}c.v!=null&&c.v++},n.applyOps=function(l,c,d){d=d||{};for(var h=0;h<c.length;h++){var C=c[h];if(d._normalizeLegacyJson0Ops)try{o(l,C)}catch{return new e(i.ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED,"Cannot normalize legacy json0 op")}l.v=C.v;var E=n.apply(l,C);if(E)return E}},n.transformPresence=function(l,c,d){var h=this.checkOp(c);if(h)return h;var C=l.t;if(typeof C=="string"&&(C=t.map[C]),!C)return{code:i.ERR_DOC_TYPE_NOT_RECOGNIZED,message:"Unknown type"};if(!r.supportsPresence(C))return{code:i.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,message:"Type does not support presence"};if(c.create||c.del){l.p=null,l.v++;return}try{l.p=l.p===null?null:C.transformPresence(l.p,c.op,d)}catch(E){return{code:i.ERR_PRESENCE_TRANSFORM_FAILED,message:E.message||E}}l.v++};function o(l,c){if(l.type===t.defaultType.uri){var d=c.op;if(!!d){var h=l.data;d.length>1&&(h=r.clone(h));for(var C=0;C<d.length;C++){var E=d[C];typeof E.lm=="string"&&(E.lm=+E.lm);for(var A=E.p,v=h,R=0;R<A.length;R++){var S=A[R];Object.prototype.toString.call(v)=="[object Array]"?A[R]=+S:v.constructor===Object&&(A[R]=S.toString()),v=v[S]}C<d.length-1&&(h=t.defaultType.apply(h,[E]))}}}}})(HT);var od=OT,xU=HT,bU=qr;function qr(n,t){od.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this.src=null,this.presenceVersion=null,this._doc=this.connection.get(this.collection,this.id),this._emitter=this.connection._docPresenceEmitter,this._pending=null,this._opCache=null,this._pendingSetPending=!1,this._opHandler=this._handleOp.bind(this),this._createDelHandler=this._handleCreateDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._registerWithDoc()}qr.prototype=Object.create(od.prototype),qr.prototype.receiveUpdate=function(n){this._pending&&n.pv<this._pending.pv||(this.src=n.src,this._pending=n,this._setPendingPresence())},qr.prototype.destroy=function(n){this._emitter.removeEventListener(this._doc,"op",this._opHandler),this._emitter.removeEventListener(this._doc,"create",this._createDelHandler),this._emitter.removeEventListener(this._doc,"del",this._createDelHandler),this._emitter.removeEventListener(this._doc,"load",this._loadHandler),od.prototype.destroy.call(this,n)},qr.prototype._registerWithDoc=function(){this._emitter.addEventListener(this._doc,"op",this._opHandler),this._emitter.addEventListener(this._doc,"create",this._createDelHandler),this._emitter.addEventListener(this._doc,"del",this._createDelHandler),this._emitter.addEventListener(this._doc,"load",this._loadHandler)},qr.prototype._setPendingPresence=function(){if(!this._pendingSetPending){this._pendingSetPending=!0;var n=this;this._doc.whenNothingPending(function(){if(n._pendingSetPending=!1,!!n._pending){if(n._pending.pv<n.presenceVersion)return n._pending=null;if(n._pending.v>n._doc.version)return n._doc.fetch();!n._catchUpStalePresence()||(n.value=n._pending.p,n.presenceVersion=n._pending.pv,n._pending=null,n.presence._updateRemotePresence(n))}})}},qr.prototype._handleOp=function(n,t,e){var r=e===this.src;this._transformAgainstOp(n,r),this._cacheOp(n,r),this._setPendingPresence()},od.prototype._handleCreateDel=function(){this._cacheOp(null),this._setPendingPresence()},od.prototype._handleLoad=function(){this.value=null,this._pending=null,this._opCache=null,this.presence._updateRemotePresence(this)},qr.prototype._transformAgainstOp=function(n,t){if(!!this.value){try{this.value=this._doc.type.transformPresence(this.value,n,t)}catch(e){return this.presence.emit("error",e)}this.presence._updateRemotePresence(this)}},qr.prototype._catchUpStalePresence=function(){if(this._pending.v>=this._doc.version)return!0;if(!this._opCache)return this._startCachingOps(),this._doc.fetch(),this.presence.subscribe(),!1;for(;this._opCache[this._pending.v];){var n=this._opCache[this._pending.v],t=n.op,e=n.isOwnOp;t===null?(this._pending.p=null,this._pending.v++):xU.transformPresence(this._pending,t,e)}var r=this._pending.v>=this._doc.version;return r&&this._stopCachingOps(),r},qr.prototype._startCachingOps=function(){this._opCache=[]},qr.prototype._stopCachingOps=function(){this._opCache=null},qr.prototype._cacheOp=function(n,t){this._opCache&&(n=n?{op:n}:null,this._opCache[this._doc.version-1]={op:n,isOwnOp:t})};var jT=KT,vU=AU,BU=bU;function Zc(n,t,e){var r=Zc.channel(t,e);jT.call(this,n,r),this.collection=t,this.id=e}var TU=Zc;Zc.prototype=Object.create(jT.prototype),Zc.channel=function(n,t){return n+"."+t},Zc.prototype._createLocalPresence=function(n){return new vU(this,n)},Zc.prototype._createRemotePresence=function(n){return new BU(this,n)};var yU=kU;function kU(n,t,e,r,i){this.id=n,this.v=t,this.type=e,this.data=r,this.m=i}var RU=yU,zT=al,GT=ld;function ld(n,t,e,r,i){if(zT.EventEmitter.call(this),typeof i!="function")throw new Error("Callback is required for SnapshotRequest");this.requestId=t,this.connection=n,this.id=r,this.collection=e,this.callback=i,this.sent=!1}zT.mixin(ld),ld.prototype.send=function(){!this.connection.canSend||(this.connection.send(this._message()),this.sent=!0)},ld.prototype._onConnectionStateChanged=function(){this.connection.canSend?this.sent||this.send():this.sent=!1},ld.prototype._handleResponse=function(n,t){if(this.emit("ready"),n)return this.callback(n);var e=t.meta?t.meta:null,r=new RU(this.id,t.v,t.type,t.data,e);this.callback(null,r)};var WT=GT,wU=Wr,SU=ul.ACTIONS,LU=LC;function LC(n,t,e,r,i,s){if(WT.call(this,n,t,e,r,s),!wU.isValidVersion(i))throw new Error("Snapshot version must be a positive integer or null");this.version=i}LC.prototype=Object.create(WT.prototype),LC.prototype._message=function(){return{a:SU.snapshotFetch,id:this.requestId,c:this.collection,d:this.id,v:this.version}};var qT=GT,IU=Wr,DU=ul.ACTIONS,_U=IC;function IC(n,t,e,r,i,s){if(qT.call(this,n,t,e,r,s),!IU.isValidTimestamp(i))throw new Error("Snapshot timestamp must be a positive integer or null");this.timestamp=i}IC.prototype=Object.create(qT.prototype),IC.prototype._message=function(){return{a:DU.snapshotFetchByTimestamp,id:this.requestId,c:this.collection,d:this.id,ts:this.timestamp}};var is=Wr,MU=Tp.default.EventEmitter,UU=["create","del","destroy","load","op"],OU=ad;function ad(){this._docs={},this._forwarders={},this._emitters={}}ad.prototype.addEventListener=function(n,t,e){this._registerDoc(n);var r=is.dig(this._emitters,n.collection,n.id);r.on(t,e)},ad.prototype.removeEventListener=function(n,t,e){var r=is.dig(this._emitters,n.collection,n.id);!r||(r.off(t,e),r._eventsCount===1&&this._unregisterDoc(n))},ad.prototype._registerDoc=function(n){var t=!0;if(is.digOrCreate(this._docs,n.collection,n.id,function(){return t=!1,n}),!t){var e=is.digOrCreate(this._emitters,n.collection,n.id,function(){var i=new MU;return i.setMaxListeners(1e3),i}),r=this;UU.forEach(function(i){var s=is.digOrCreate(r._forwarders,n.collection,n.id,i,function(){return e.emit.bind(e,i)});n.on(i,s)}),this.addEventListener(n,"destroy",this._unregisterDoc.bind(this,n))}},ad.prototype._unregisterDoc=function(n){var t=is.dig(this._forwarders,n.collection,n.id);for(var e in t)n.off(e,t[e]);var r=is.dig(this._emitters,n.collection,n.id);r.removeAllListeners(),is.digAndRemove(this._forwarders,n.collection,n.id),is.digAndRemove(this._emitters,n.collection,n.id),is.digAndRemove(this._docs,n.collection,n.id)};var NU=oU,PU=fU,FU=KT,XT=TU,KU=LU,VU=_U,YT=al,tu=om,ve=ul.ACTIONS,QT=ed,Ri=Wr,cd=kT,$U=OU,ud=tu.CODES;function JT(n){return n.readyState===0||n.readyState===1?"connecting":"disconnected"}var HU=Ut;function Ut(n){YT.EventEmitter.call(this),this.collections={},this.nextQueryId=1,this.nextSnapshotRequestId=1,this.queries={},this._presences={},this._docPresenceEmitter=new $U,this._snapshotRequests={},this.seq=1,this._presenceSeq=1,this.id=null,this.agent=null,this.debug=!1,this.state=JT(n),this.bindToSocket(n)}YT.mixin(Ut),Ut.prototype.bindToSocket=function(n){this.socket&&(this.socket.close(),this.socket.onmessage=null,this.socket.onopen=null,this.socket.onerror=null,this.socket.onclose=null),this.socket=n;var t=JT(n);this._setState(t),this.canSend=!1;var e=this;n.onmessage=function(r){try{var i=typeof r.data=="string"?JSON.parse(r.data):r.data}catch{cd.warn("Failed to parse message",r);return}e.debug&&cd.info("RECV",JSON.stringify(i));var s={data:i};if(e.emit("receive",s),!!s.data)try{e.handleMessage(s.data)}catch(o){Ri.nextTick(function(){e.emit("error",o)})}},n.readyState===1&&e._initializeHandshake(),n.onopen=function(){e._setState("connecting"),e._initializeHandshake()},n.onerror=function(r){e.emit("connection error",r)},n.onclose=function(r){r==="closed"||r==="Closed"?e._setState("closed",r):r==="stopped"||r==="Stopped by server"?e._setState("stopped",r):e._setState("disconnected",r)}},Ut.prototype.handleMessage=function(n){var t=null;switch(n.error&&(t=ZT(n.error,n),delete n.error),n.a){case ve.initLegacy:return this._handleLegacyInit(n);case ve.handshake:return this._handleHandshake(t,n);case ve.queryFetch:var e=this.queries[n.id];e&&e._handleFetch(t,n.data,n.extra);return;case ve.querySubscribe:var e=this.queries[n.id];e&&e._handleSubscribe(t,n.data,n.extra);return;case ve.queryUnsubscribe:return;case ve.queryUpdate:var e=this.queries[n.id];if(!e)return;if(t)return e._handleError(t);n.diff&&e._handleDiff(n.diff),n.hasOwnProperty("extra")&&e._handleExtra(n.extra);return;case ve.bulkFetch:return this._handleBulkMessage(t,n,"_handleFetch");case ve.bulkSubscribe:case ve.bulkUnsubscribe:return this._handleBulkMessage(t,n,"_handleSubscribe");case ve.snapshotFetch:case ve.snapshotFetchByTimestamp:return this._handleSnapshotFetch(t,n);case ve.fetch:var r=this.getExisting(n.c,n.d);r&&r._handleFetch(t,n.data);return;case ve.subscribe:case ve.unsubscribe:var r=this.getExisting(n.c,n.d);r&&r._handleSubscribe(t,n.data);return;case ve.op:var r=this.getExisting(n.c,n.d);r&&r._handleOp(t,n);return;case ve.presence:return this._handlePresence(t,n);case ve.presenceSubscribe:return this._handlePresenceSubscribe(t,n);case ve.presenceUnsubscribe:return this._handlePresenceUnsubscribe(t,n);case ve.presenceRequest:return this._handlePresenceRequest(t,n);case ve.pingPong:return this._handlePingPong(t);default:cd.warn("Ignoring unrecognized message",n)}};function ZT(n,t){var e=new Error(n.message);return e.code=n.code,t&&(e.data=t),e}Ut.prototype._handleBulkMessage=function(n,t,e){if(t.data)for(var r in t.data){var i=t.data[r],s=this.getExisting(t.c,r);s&&(n?s[e](n):i.error?s[e](ZT(i.error)):s[e](null,i))}else if(Array.isArray(t.b))for(var o=0;o<t.b.length;o++){var r=t.b[o],s=this.getExisting(t.c,r);s&&s[e](n)}else if(t.b)for(var r in t.b){var s=this.getExisting(t.c,r);s&&s[e](n)}else cd.error("Invalid bulk message",t)},Ut.prototype._reset=function(){this.agent=null},Ut.prototype._setState=function(n,t){if(this.state!==n){if(n==="connecting"&&this.state!=="disconnected"&&this.state!=="stopped"&&this.state!=="closed"||n==="connected"&&this.state!=="connecting"){var e=new tu(ud.ERR_CONNECTION_STATE_TRANSITION_INVALID,"Cannot transition directly from "+this.state+" to "+n);return this.emit("error",e)}this.state=n,this.canSend=n==="connected",(n==="disconnected"||n==="stopped"||n==="closed")&&this._reset(),this.startBulk();for(var r in this.queries){var i=this.queries[r];i._onConnectionStateChanged()}for(var s in this.collections){var o=this.collections[s];for(var r in o)o[r]._onConnectionStateChanged()}for(var l in this._presences)this._presences[l]._onConnectionStateChanged();for(var r in this._snapshotRequests){var c=this._snapshotRequests[r];c._onConnectionStateChanged()}this.endBulk(),this.emit(n,t),this.emit("state",n,t)}},Ut.prototype.startBulk=function(){this.bulk||(this.bulk={})},Ut.prototype.endBulk=function(){if(this.bulk)for(var n in this.bulk){var t=this.bulk[n];this._sendBulk("f",n,t.f),this._sendBulk("s",n,t.s),this._sendBulk("u",n,t.u)}this.bulk=null},Ut.prototype._sendBulk=function(n,t,e){if(!!e){var r=[],i={},s=0,o;for(var l in e){var c=e[l];c==null?r.push(l):(i[l]=c,o=l,s++)}if(r.length===1){var l=r[0];this.send({a:n,c:t,d:l})}else r.length&&this.send({a:"b"+n,c:t,b:r});if(s===1){var d=i[o];this.send({a:n,c:t,d:o,v:d})}else s&&this.send({a:"b"+n,c:t,b:i})}},Ut.prototype._sendActions=function(n,t,e){if(this._addDoc(t),this.bulk){var r=this.bulk[t.collection]||(this.bulk[t.collection]={}),i=r[n]||(r[n]={}),s=i.hasOwnProperty(t.id);return i[t.id]=e,s}else{var o={a:n,c:t.collection,d:t.id,v:e};this.send(o)}},Ut.prototype.sendFetch=function(n){return this._sendActions(ve.fetch,n,n.version)},Ut.prototype.sendSubscribe=function(n){return this._sendActions(ve.subscribe,n,n.version)},Ut.prototype.sendUnsubscribe=function(n){return this._sendActions(ve.unsubscribe,n)},Ut.prototype.sendOp=function(n,t){this._addDoc(n);var e={a:ve.op,c:n.collection,d:n.id,v:n.version,src:t.src,seq:t.seq,x:{}};"op"in t&&(e.op=t.op),t.create&&(e.create=t.create),t.del&&(e.del=t.del),n.submitSource&&(e.x.source=t.source),this.send(e)},Ut.prototype.send=function(n){this.debug&&cd.info("SEND",JSON.stringify(n)),this.emit("send",n),this.socket.send(JSON.stringify(n))},Ut.prototype.ping=function(){if(!this.canSend)throw new tu(ud.ERR_CANNOT_PING_OFFLINE,"Socket must be CONNECTED to ping");var n={a:ve.pingPong};this.send(n)},Ut.prototype.close=function(){this.socket.close()},Ut.prototype.getExisting=function(n,t){if(this.collections[n])return this.collections[n][t]},Ut.prototype.get=function(n,t){var e=this.collections[n]||(this.collections[n]={}),r=e[t];return r||(r=e[t]=new NU(this,n,t),this.emit("doc",r)),r._wantsDestroy=!1,r},Ut.prototype._destroyDoc=function(n){!n._wantsDestroy||(Ri.digAndRemove(this.collections,n.collection,n.id),n.emit("destroy"))},Ut.prototype._addDoc=function(n){var t=this.collections[n.collection];t||(t=this.collections[n.collection]={}),t[n.id]!==n&&(t[n.id]=n)},Ut.prototype._createQuery=function(n,t,e,r,i){var s=this.nextQueryId++,o=new PU(n,this,s,t,e,r,i);return this.queries[s]=o,o.send(),o},Ut.prototype._destroyQuery=function(n){delete this.queries[n.id]},Ut.prototype.createFetchQuery=function(n,t,e,r){return this._createQuery(ve.queryFetch,n,t,e,r)},Ut.prototype.createSubscribeQuery=function(n,t,e,r){return this._createQuery(ve.querySubscribe,n,t,e,r)},Ut.prototype.hasPending=function(){return!!(this._firstDoc(fm)||this._firstQuery(fm)||this._firstSnapshotRequest())};function fm(n){return n.hasPending()}Ut.prototype.hasWritePending=function(){return!!this._firstDoc(jU)};function jU(n){return n.hasWritePending()}Ut.prototype.whenNothingPending=function(n){var t=this._firstDoc(fm);if(t){t.once("nothing pending",this._nothingPendingRetry(n));return}var e=this._firstQuery(fm);if(e){e.once("ready",this._nothingPendingRetry(n));return}var r=this._firstSnapshotRequest();if(r){r.once("ready",this._nothingPendingRetry(n));return}Ri.nextTick(n)},Ut.prototype._nothingPendingRetry=function(n){var t=this;return function(){Ri.nextTick(function(){t.whenNothingPending(n)})}},Ut.prototype._firstDoc=function(n){for(var t in this.collections){var e=this.collections[t];for(var r in e){var i=e[r];if(n(i))return i}}},Ut.prototype._firstQuery=function(n){for(var t in this.queries){var e=this.queries[t];if(n(e))return e}},Ut.prototype._firstSnapshotRequest=function(){for(var n in this._snapshotRequests)return this._snapshotRequests[n]},Ut.prototype.fetchSnapshot=function(n,t,e,r){typeof e=="function"&&(r=e,e=null);var i=this.nextSnapshotRequestId++,s=new KU(this,i,n,t,e,r);this._snapshotRequests[s.requestId]=s,s.send()},Ut.prototype.fetchSnapshotByTimestamp=function(n,t,e,r){typeof e=="function"&&(r=e,e=null);var i=this.nextSnapshotRequestId++,s=new VU(this,i,n,t,e,r);this._snapshotRequests[s.requestId]=s,s.send()},Ut.prototype._handleSnapshotFetch=function(n,t){var e=this._snapshotRequests[t.id];!e||(delete this._snapshotRequests[t.id],e._handleResponse(n,t))},Ut.prototype._handleLegacyInit=function(n){if(n.protocolMinor)return this._initializeHandshake();this._initialize(n)},Ut.prototype._initializeHandshake=function(){this.send({a:ve.handshake,id:this.id})},Ut.prototype._handleHandshake=function(n,t){if(n)return this.emit("error",n);this._initialize(t)},Ut.prototype._handlePingPong=function(n){if(n)return this.emit("error",n);this.emit("pong")},Ut.prototype._initialize=function(n){if(this.state==="connecting"){if(n.protocol!==1)return this.emit("error",new tu(ud.ERR_PROTOCOL_VERSION_NOT_SUPPORTED,"Unsupported protocol version: "+n.protocol));if(QT.map[n.type]!==QT.defaultType)return this.emit("error",new tu(ud.ERR_DEFAULT_TYPE_MISMATCH,n.type+" does not match the server default type"));if(typeof n.id!="string")return this.emit("error",new tu(ud.ERR_CLIENT_ID_BADLY_FORMED,"Client id must be a string"));this.id=n.id,this._setState("connected")}},Ut.prototype.getPresence=function(n){var t=this,e=Ri.digOrCreate(this._presences,n,function(){return new FU(t,n)});return e._wantsDestroy=!1,e},Ut.prototype.getDocPresence=function(n,t){var e=XT.channel(n,t),r=this,i=Ri.digOrCreate(this._presences,e,function(){return new XT(r,n,t)});return i._wantsDestroy=!1,i},Ut.prototype._sendPresenceAction=function(n,t,e){this._addPresence(e);var r={a:n,ch:e.channel,seq:t};return this.send(r),r.seq},Ut.prototype._addPresence=function(n){Ri.digOrCreate(this._presences,n.channel,function(){return n})},Ut.prototype._handlePresenceSubscribe=function(n,t){var e=Ri.dig(this._presences,t.ch);e&&e._handleSubscribe(n,t.seq)},Ut.prototype._handlePresenceUnsubscribe=function(n,t){var e=Ri.dig(this._presences,t.ch);e&&e._handleUnsubscribe(n,t.seq)},Ut.prototype._handlePresence=function(n,t){var e=Ri.dig(this._presences,t.ch);e&&e._receiveUpdate(n,t)},Ut.prototype._handlePresenceRequest=function(n,t){var e=Ri.dig(this._presences,t.ch);e&&e._broadcastAllLocalPresence(n,t)};var ty=HU,zU=ed;const fd={err:1001,msg:"user auth error",name:"AuthError"},dm={err:1002,msg:"you don't have required permission",name:"PermissionError"},DC={err:1003,msg:"Too many user connected",name:"MaxUserError"},dd={err:1004,msg:"document server changed, reload it",name:"RequestReloadError"},GU={err:1005,msg:"app id must be at least 2 chars, doc id must be at least 5 chars",name:"DocIdError"},WU={err:1028,msg:"upload file ext not allowed",name:"FileExtError"},Ea="x-live-editor-token",eu="x-live-editor-base-url",Hn=D("auth-connection");function qU(n){try{n()}catch(t){Hn.error(t)}}class XU{constructor(t,e){m(this,"enabled",!0);m(this,"connection");m(this,"ws");m(this,"retryCount");m(this,"events",new vb.EventEmitter);m(this,"token",null);m(this,"resourceToken",null);m(this,"pingOptions",{interval:5e4,timeout:15e4});m(this,"reAuth",async()=>{if(this.connection&&this.reauthFunc){const t=await this.reauthFunc();await this.auth(t);const e=this.pingOptions;this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t,options:{ping:e}})}}});this.url=t,this.reauthFunc=e,this.retryCount=0}getBaseURL(){const t=new URL(this.url);return`${t.protocol==="wss:"?"https:":"http:"}//${t.host}${t.pathname}`}getBase64BaseURL(){return qi(this.getBaseURL())}async auth(t){p(Hn,t.token,"no auth token");const e=`${this.getBaseURL()}/auth`,r=await window.fetch(e,{method:"GET",headers:{[Ea]:t.token,[eu]:this.getBase64BaseURL()},credentials:"include"});return r.status,this.enabled?(this.token=t.token,await r.json()):{read:"",user:""}}async logout(){if(!this.token)return;const t=`${this.getBaseURL()}/logout`;await window.fetch(t,{method:"GET",headers:{[eu]:qi(this.getBaseURL())}})}async init(t){const e=await this.auth(t);if(!this.enabled)return;this.resourceToken=e.read,this.ws=new J6.default(this.url,void 0,{maxReconnectionDelay:2500,minReconnectionDelay:1e3}),this.connection=Object.create(ty.prototype),p(Hn,this.connection,"no this.connection");const r=this.ws,i=this.pingOptions;this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t,options:{ping:i}}),this._ping==null&&(this._ping=window.setInterval(()=>{var d;const c=Date.now();c-((d=this.lastReceiveTime)!=null?d:0)>i.interval&&this.send({a:"ping",id:this.id,ts:c}),this.lastReceiveTime&&c-this.lastReceiveTime>i.timeout&&r&&r.readyState===r.OPEN&&(r.reconnect(),this.lastReceiveTime=Date.now())},1e3))};const s=this.connection.handleMessage.bind(this.connection);let o=!1;this.connection.handleMessage=l=>{var d;const c=l;if(this.connection&&(this.connection.lastReceiveTime=Date.now()),"err"in c||c.a==="pong")o=!1,this.handleMessage(c);else{Object.prototype.hasOwnProperty.call(c,"a")&&c.a==="hs"&&this.retryCount>=5&&(o?(Hn.info("retrying re-auth success"),o=!1,this.emitAuthRecover()):o=!0),Object.prototype.hasOwnProperty.call(c,"a")&&c.a!=="init"&&c.a!=="hs"&&(this.retryCount=0);try{s(c)}catch(h){if((h==null?void 0:h.type)==="writeConflict"){this.emitWriteConflictError(h,c);return}if((d=h==null?void 0:h.message)!=null&&d.startsWith("Cannot invert subtype")){this.emitWriteConflictError(h,c);return}throw h}}},ty.apply(this.connection,[this.ws])}async reConnect(t){var r,i;(r=this.ws)==null||r.close();const e=this.pingOptions;if(this.connection&&this.reauthFunc){const s=await this.reauthFunc();await this.auth(s),(i=this.ws)==null||i.reconnect(),this.connection._initializeHandshake=function(){t&&(s.token=t),this.send({a:"hs",id:this.id,auth:s,options:{ping:e}})}}}async handleAuthError(){var t,e;if(this.reauthFunc){if(!this.enabled)return;(t=this.ws)==null||t.close(),this.retryCount+=1,Hn.info(`retrying re-auth attempt no. ${this.retryCount}`);try{if(this.connection){const r=await this.reauthFunc();if(window.isReauthError)throw new Error("reauth error");await this.auth(r);const i=this.pingOptions;(e=this.ws)==null||e.reconnect(),this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:r,options:{ping:i}})}}}catch(r){Hn.error(r),this.retryCount>=5&&(Hn.warn("retry auth times exceed 5, broadcast auth error"),this.emitAuthError());const i=30*1e3;setTimeout(()=>this.handleAuthError(),Math.min(2*this.retryCount*1e3,i))}}}emitPermissionError(){const t=new Error(dm.msg);t.code=dm.err,this.events.emit("error",t)}emitAuthRecover(){this.events.emit("authRecover")}emitAuthError(){const t=new Error(fd.msg);t.code=fd.err,this.events.emit("error",t)}emitRequestReloadError(){const t=new Error(dd.msg);t.code=dd.err,this.events.emit("requestReloadError",t)}emitWriteConflictError(t,e){t.orgMsg=e,this.events.emit("writeConflictError",t)}emitMaxUsersError(){this.events.emit("maxUsersError"),this.end(!1)}handleMessage(t){const e=t;if(e.a==="pong")return;const r=e.err;if(r===fd.err)Hn.warn("auth error"),this.handleAuthError();else if(r===DC.err)Hn.warn(DC.msg),this.emitMaxUsersError();else if(r===dd.err){Hn.warn(dd.msg);try{this.emitRequestReloadError()}catch(i){Hn.error(`error occurred while process reload error: ${JSON.stringify(i)}`)}finally{this.end(!1)}}else r===dm.err?this.emitPermissionError():(Hn.error(`unknown message received: ${JSON.stringify(e)}`),this.emitAuthError())}get(t,e){return p(Hn,this.connection,"no this.connection"),this.connection.get(t,e)}addEventListener(t,e){t==="error"?this.events.addListener(t,e):(p(Hn,this.ws,"no this.ws"),this.ws.addEventListener(t,e))}onAuthError(t){this.events.addListener("error",t)}onAuthRecover(t){this.events.addListener("authRecover",t)}onWriteConflictError(t){this.events.addListener("writeConflictError",t)}onMaxUsersError(t){p(Hn,this.events.listenerCount("maxUsersError")===0,"too many maxUserError listener"),this.events.addListener("maxUsersError",t)}onRequestReloadError(t){p(Hn,this.events.listenerCount("requestReloadError")===0,"to many requestReloadError listener"),this.events.addListener("requestReloadError",t)}end(t){var e,r;this.enabled=!1,this.reauthFunc=void 0,this.events.removeAllListeners(),qU(()=>{var i;return(i=this.connection)==null?void 0:i.close()}),(e=this.connection)!=null&&e._ping&&window.clearInterval(this.connection._ping),this.connection=void 0,(r=this.ws)==null||r.close(),this.ws=void 0,t&&this.logout()}}D("utils/file");function YU(){function n(){return new Promise(t=>{const e=new FileReader;e.onload=()=>{t(e.result)},e.readAsArrayBuffer(this)})}File.prototype.arrayBuffer=File.prototype.arrayBuffer||n,Blob.prototype.arrayBuffer=Blob.prototype.arrayBuffer||n}YU();async function QU(n){const e=n.size,r=Math.floor((e+102400-1)/102400),i=new Z6.Hash;for(let o=0;o<r;o++){const l=o*102400;let c=l+102400;c>e&&(c=e);const h=await n.slice(l,c,n.type).arrayBuffer();i.update(new Uint8Array(h))}const s=i.digest();return qi(s)}const ss=D("sharedb-doc/client"),JU=Bb.default.create();class ZU{constructor(t,e,r){m(this,"connection");m(this,"auth");m(this,"doc",null);m(this,"reauthFunc");m(this,"clientId",it());m(this,"getDoc",async()=>{const t=r=>new Promise((i,s)=>{r.fetch(o=>{o?s(o):i()})});p(ss,!this.doc,"This websocket has opened a doc."),await this.connection.init(this.auth);const e=this.connection.get(this.auth.appId,this.auth.docId);return this.doc=e,await t(e),ss.debug(e),e});this.auth=t;const i=`${e}/${this.auth.appId}/${this.auth.docId}`;zU.register(Zh.type),this.connection=new XU(i,r),this.reauthFunc=r}editorServer(){const t=this.apiServer(),e=`/${this.auth.appId}/${this.auth.docId}`;return p(ss,t.endsWith(e),`invalid api server: ${t}, ${e}`),t.substr(0,t.length-e.length)}close(t){this.connection.end(t),this.doc=null}on(t,e){this.connection.addEventListener(t,r=>{(t==="error"||this.doc)&&e(r)})}onAuthError(t){this.connection.onAuthError(t)}onAuthRecover(t){this.connection.onAuthRecover(t)}onWriteConflictError(t){this.connection.onWriteConflictError(t)}onMaxUsersError(t){this.connection.onMaxUsersError(t)}onRequestReloadError(t){this.connection.onRequestReloadError(t)}async authOnly(){await this.connection.auth(this.auth)}getResourceToken(){return this.connection.resourceToken}hasDocContainer(){return!!this.doc}apiServer(){const t=this.connection.url;if(t.startsWith("ws://"))return`http://${t.substring(5)}`;if(t.startsWith("wss://"))return`https://${t.substring(6)}`;throw new Error(`invalid server url: ${t}`)}async getFileUrlByHash(t,e,r,i,s){try{const o=`${t}/${e}`,l=await this.request(o,{method:"post",headers:{...s},data:{name:r,size:i}});return l.data&&Array.isArray(l.data)&&l.data.length===1?l.data[0]:""}catch{return""}}async getFileUrlsByHashes(t){const r=`${this.apiServer()}/resources`;try{const i=`${r}/hash`,s=await this.request(i,{method:"post",headers:{[Ea]:this.connection.token},data:{resources:t}});return s.data&&Array.isArray(s.data)?s.data:[]}catch{return[]}}async uploadFile(t,e,r,i,s){let o=e.size;if(o===0)throw new Error("file is empty");o+=500;const l=A=>{ss.info(`on progress: ${A.loaded}`);let v=A.loaded*100/o;v>100&&(v=100),i(v)},c=await QU(e),d=await this.getFileUrlByHash(t,c,e.name,e.size,r);if(d)return i(-1),d;let h=t;s!=null&&s.thumbnail&&(h+="/thumbnail");const C=new FormData;C.append("file-size",`${e.size}`),C.append("file-hash",c),C.append("file",e,e.name);const E=await this.request(h,{method:"post",data:C,withCredentials:!0,headers:{...r},onUploadProgress:l});return ss.info(E),i(100),Array.isArray(E.data)?E.data[0]:E.data}async uploadResource(t,e=()=>{},r){const s=`${this.apiServer()}/resources`;p(ss,this.connection.token,"no connection token");const o=await this.uploadFile(s,t,{[Ea]:this.connection.token},e,r);return p(ss,o,"no result"),o}async request(t,e){var s,o;let r=this.connection.token,i;for(let l=0;l<2;l++){const c=e||{};c.url=t,c.headers||(c.headers={}),p(ss,r,"no token"),c.headers={...c.headers,[Ea]:r,[eu]:this.connection.getBase64BaseURL()};try{return await JU(t,c)}catch(d){if(i=d,((s=d==null?void 0:d.response)==null?void 0:s.status)===403&&this.reauthFunc){const h=await this.reauthFunc();if(await this.connection.auth(h),!h.token)throw d;r=h.token;continue}throw(o=d.response)!=null&&o.data&&(d.responseData=d.response.data),d}}throw p(ss,i,"no error"),i}async getVersions(){const e=`${this.apiServer()}/versions?withExtra=true`,i=(await this.request(e)).data.versions;return i.forEach(s=>{s.extra&&(s.extra=JSON.parse(s.extra))}),i}async getVersion(t){const r=`${this.apiServer()}/versions/${t}`,i=await this.request(r);return JSON.parse(i.data.data)}async getLatestVersion(){const e=`${this.apiServer()}/versions/latest`,r=await this.request(e);return JSON.parse(r.data.data)}async getVersionOps(t,e){let i=`${this.apiServer()}/versions/before/${t}?withOp=true`;e!==void 0&&e!==0&&(i+=`&from=${e}`);const s=await this.request(i),o=s.data.ops,l=Tb.default(o,h=>!!h.create);let c=null;l!==-1&&(c=o[l],o.splice(0,l+1));let d;return c?(p(ss,c.create,"no createDoc.create"),d=c.create.data):d=JSON.parse(s.data.data),d.blocks||(d.blocks=[]),{doc:d,ops:s.data.ops}}async updateVersionExtra(t,e,r){const s=`${this.apiServer()}/versions/${t}/tags/${e}`;await this.request(s,{method:"post",data:{extra:JSON.stringify(r)}})}async revertVersion(t){const r=`${this.apiServer()}/versions/revert/${t}`;await this.request(r,{method:"post",data:{}})}async createVersion(t,e){const i=`${this.apiServer()}/versions`;return(await this.request(i,{method:"post",data:{publish:e,tag:t}})).data}async recognizeLink(t){const r=`${this.apiServer()}/resources/external/${qi(t)}`;return(await this.request(r)).data}getResourceId(t){const e=/\/resources\/([^?]+)/,r=t.match(e);return r&&r.length>=2?r[1]:""}buildResourceUrl(t,e){var o,l;if(!t)return"";if(t.startsWith("file:")||t.startsWith("data:")||t.startsWith("blob:"))return t;const r=this.apiServer();if(t.startsWith("http:")||t.startsWith("https:")){const c=r.replace(/\/[^/]*$/,"");if(c&&t.includes(c)){const d=this.auth.docId,h=`${c}/`,C="/resources",E=t.indexOf(h),A=t.indexOf(C,E+h.length);if(E!==-1&&A!==-1){const v=t.substring(E+h.length,A);if(v!==d){let R=t.replace(v,d);const S=new URL(R),O="token";(o=S.searchParams)==null||o.delete(O),R=S.toString();const M=this.getResourceId(R);return e!=null&&e.syncNewResources&&((l=e==null?void 0:e.syncNewResources)==null||l.call(e,M,R)),R}return t}return t}return t}let i=`${r}/resources/${encodeURIComponent(t)}`;const s=[];if(e!=null&&e.withToken&&s.push(`token=${this.getResourceToken()}`),e!=null&&e.downloadFileName&&s.push(`&fileName=${encodeURIComponent(e.downloadFileName)}`),s.length>0){const c=s.join("&");i+=`?${c}`}return i}reAuth(){this.connection.reAuth()}}function tO(){return{blocks:[{id:it(),type:"text",text:[]}],comments:{},meta:{}}}const _C=D("block-ids");class eO{constructor(){m(this,"ids",new Map)}onInsertBlock(t){const e=Array.from(this.ids.keys()).sort((i,s)=>s-i);for(let i=0;i<e.length;i++){const s=e[i];if(s>=t){const o=this.ids.get(s);p(_C,o!==void 0,"old id is not exists"),this.ids.delete(s),this.ids.set(s+1,o)}}const r=it();this.ids.set(t,r)}onDeleteBlock(t){this.ids.delete(t);const e=Array.from(this.ids.keys()).sort((r,i)=>r-i);for(let r=0;r<e.length;r++){const i=e[r];if(i>t){const s=this.ids.get(i);p(_C,s!==void 0,"old id is not exists"),this.ids.delete(i),this.ids.set(i-1,s)}}}getId(t){let e=this.ids.get(t);return e||(e=it(),this.ids.set(t,e)),e}getById(t){return Array.from(this.ids.entries()).find(([,e])=>e===t)}}class nO{constructor(){m(this,"ids",new Map)}getContainerIds(t){let e=this.ids.get(t);return e||(e=new eO,this.ids.set(t,e)),e}onInsertBlock(t,e){this.getContainerIds(t).onInsertBlock(e)}onDeleteBlock(t,e){this.getContainerIds(t).onDeleteBlock(e)}getBlockId(t,e){return this.getContainerIds(t).getId(e)}getBlockIndexById(t){const e=Array.from(this.ids.entries());for(let r=0;r<e.length;r++){const i=e[r],s=i[1].getById(t);if(s)return{containerId:i[0],blockIndex:s[0]}}return p(_C,!1,"fault error: failed to get block index"),{containerId:"error",blockIndex:-1}}}class ey{constructor(t=new Set,e=new Map){this.deletedKeys=t,this.insertedValues=e}insert(t,e){this.insertedValues.set(t,e)}delete(t){this.deletedKeys.add(t)}toDocBlockDelta(){const t={};return this.insertedValues.forEach((e,r)=>{t[r]=e}),{insert:t,delete:Array.from(this.deletedKeys)}}}const MC=D("op-parse-handler");class rO{constructor(t,e){m(this,"actions",[]);this.outerHandler=t,this.local=e}pushActions(t){if(!t.containerId){this.actions.push(t);return}const r={...t,containerId:(i=>i==="blocks"?"root":i)(t.containerId)};this.actions.push(r)}onDeleteBlock(t,e){this.pushActions({type:"deleteBlock",containerId:t,blockIndex:e})}onInsertBlock(t,e,r){this.pushActions({type:"insertBlock",containerId:t,blockIndex:e,data:r})}onDeleteBlockData(t,e,r){this.pushActions({type:"deleteBlockData",containerId:t,blockIndex:e,key:r})}onInsertBlockData(t,e,r,i){this.pushActions({type:"insertBlockData",containerId:t,blockIndex:e,key:r,value:i})}onUpdateBlockText(t,e,r){this.pushActions({type:"updateBlockText",containerId:t,blockIndex:e,richTextData:r})}onDeleteContainer(t){this.pushActions({type:"deleteContainer",containerId:t})}onCreateContainer(t,e){this.pushActions({type:"createContainer",containerId:t,data:e})}onDeleteComment(t){this.pushActions({type:"deleteComment",commentId:t})}onCreateComment(t){this.pushActions({type:"createComment",commentId:t})}onUpdateComment(t){this.pushActions({type:"updateComment",commentId:t})}end(){const t=this.actions,e=new Set,r=new Map,i=new nO,s=t.filter(o=>o.type==="deleteBlock"||o.type==="deleteBlockData");for(const o of s)if(o.type==="deleteBlock"){const l=o,c=i.getBlockId(l.containerId,l.blockIndex);i.onDeleteBlock(l.containerId,l.blockIndex);const d=r.get(c);d&&(MC.debug(`ignore update object data before delete block: ${JSON.stringify(d)}`),r.delete(c));const h=`${l.containerId}-${l.blockIndex}`;e.add(h),this.outerHandler.onDeleteBlock(l.containerId,l.blockIndex,this.local)}else if(o.type==="deleteBlockData"){const l=o,c=`${l.containerId}-${l.blockIndex}`;if(e.has(c)){MC.warn("delete block data after delete block, ignore it");continue}const d=i.getBlockId(l.containerId,l.blockIndex);let h=r.get(d);h||(h=new ey,r.set(d,h)),h.delete(l.key)}else p(MC,!1,`invalid action type, ${o.type}`);this.actions.forEach(o=>{if(o.type==="deleteContainer"){const l=o;this.outerHandler.onDeleteContainer(l.containerId,this.local)}else if(o.type==="deleteComment"){const l=o;this.outerHandler.onDeleteComment(l.commentId,this.local)}}),this.actions.forEach(o=>{if(o.type==="createContainer"){const l=o;this.outerHandler.onCreateContainer(l.containerId,l.data,this.local)}}),this.actions.forEach(o=>{if(o.type==="insertBlock"){const l=o;this.outerHandler.onInsertBlock(l.containerId,l.blockIndex,l.data,this.local)}else if(o.type==="insertBlockData"){const l=o,c=i.getBlockId(l.containerId,l.blockIndex);let d=r.get(c);d||(d=new ey,r.set(c,d)),d.insert(l.key,l.value)}else if(o.type==="updateBlockText"){const l=o;this.outerHandler.onUpdateBlockText(l.containerId,l.blockIndex,l.richTextData,this.local)}else if(o.type==="createComment"){const l=o;this.outerHandler.onCreateComment(l.commentId,this.local)}else if(o.type==="updateComment"){const l=o;this.outerHandler.onUpdateComment(l.commentId,this.local)}}),Array.from(r.entries()).forEach(([o,l])=>{const{containerId:c,blockIndex:d}=i.getBlockIndexById(o);this.outerHandler.onUpdateBlockData(c,d,l.toDocBlockDelta(),this.local)})}}const ln=D("op-parser");class ny{}class UC{constructor(t){m(this,"key");this.key=t}}function iO(n,t,e){const r=t.concat(),i=r[0];if(typeof i!="number"||(r.shift(),r.length===1))return!1;const s=r[0];if(typeof s!="object"||!s.i||Object.keys(s).length!==1)return!1;for(let l=1;l<r.length;l++){const c=r[l];if(!Array.isArray(c)||c.length!==2||typeof c[0]!="string")return!1;const h=c[1];if(typeof h!="object"||h.i===void 0||Object.keys(h).length!==1)return!1}const o=s.i;p(ln,o.id,"block id is required"),p(ln,o.type,"block type is required");for(let l=1;l<r.length;l++){const c=r[l],d=c[0],h=c[1];o[d]=h.i}return e.onInsertBlock(n,i,o),!0}function OC(n,t,e,r){if(e==="upsert"&&iO(n,t,r))return;p(ln,Array.isArray(t),`invalid block op: ${n}, ${JSON.stringify(t)}`);const i=t.concat(),s=i[0];i.shift();const o=[];for(;i.length>0;){const l=i[0];if(l==="text"){const c=i[1];if(p(ln,typeof c=="object",`invalid block op: ${n}, ${JSON.stringify(t)}`),p(ln,c.et==="rich-text",`invalid block op: ${n}, ${JSON.stringify(t)}`),i.splice(0,2),e==="upsert"){const h=c.e;r.onUpdateBlockText(n,s,h)}p(ln,i.length===0,`invalid block ops.length !== 0, ${JSON.stringify(i)}`)}else if(Array.isArray(l)){p(ln,l.length===2,`invalid block op: data.length !== 2, ${JSON.stringify(l)}`);const c=l[0];p(ln,typeof c=="string",`invalid block op: key ${JSON.stringify(c)}`);const d=l[1];if(c==="text"){if(p(ln,typeof d=="object",`invalid opData type, ${JSON.stringify(d)}`),d.i&&e==="upsert"&&r.onInsertBlockData(n,s,c,d.i),d.r&&e==="remove"&&r.onDeleteBlockData(n,s,c),d.et==="rich-text"&&e==="upsert"){const C=d.e;r.onUpdateBlockText(n,s,C)}}else e==="remove"&&d.r&&o.push(new UC(c)),e==="upsert"&&d.i&&r.onInsertBlockData(n,s,c,d.i);i.shift()}else if(typeof l=="object"){const c=l;e==="remove"&&c.r&&o.push(new ny),e==="upsert"&&c.i&&r.onInsertBlock(n,s,c.i),i.shift()}else{p(ln,typeof l=="string","data is not string"),p(ln,l!=="text","data !== 'text'"),p(ln,i.length===2,`invalid block op: ops.length !== 2, ${JSON.stringify(i)}`);const c=l,d=i[1];e==="remove"&&d.r&&o.push(new UC(c)),e==="upsert"&&d.i&&r.onInsertBlockData(n,s,c,d.i),i.splice(0,2)}}o.reverse(),o.forEach(l=>{l instanceof ny?r.onDeleteBlock(n,s):l instanceof UC?r.onDeleteBlockData(n,s,l.key):p(ln,!1,`invalid action type: ${typeof l}, ${JSON.stringify(l)}`)})}function sO(n,t,e){ln.warn(`unsupported meta op, ${JSON.stringify(n)}`)}function oO(n,t,e){const r=n[1],i=n[2];p(ln,r,`invalid comment op, no commentId: ${JSON.stringify(n)}`),p(ln,i,`invalid comment op, no actions: ${JSON.stringify(n)}`),typeof i=="string"?ln.error(`unknown comment op, ${JSON.stringify(n)}`):i.i&&i.r?t==="upsert"&&e.onUpdateComment(r):i.i?t==="upsert"&&e.onCreateComment(r):i.r?t==="remove"&&e.onDeleteComment(r):ln.error(`unknown comment op, ${JSON.stringify(n)}`)}function NC(n,t,e){const r=n[0];if(Array.isArray(r)){r.forEach(o=>{NC(o,t,e)});return}const i=r;if(p(ln,typeof i=="string",`invalid container id: ${JSON.stringify(n)}`),i==="meta"){sO(n);return}if(i==="comments"){oO(n,t,e);return}const s=i;if(Array.isArray(n[1]))t==="remove"?n.slice(1).reverse().forEach(o=>{OC(s,o,t,e)}):n.slice(1).forEach(o=>{OC(s,o,t,e)});else if(typeof n[1]=="object"){const o=n[1];o.r&&t==="remove"&&e.onDeleteContainer(s),o.i&&t==="upsert"&&e.onCreateContainer(s,o.i)}else p(ln,typeof n[1]=="number",`invalid ops[1], not a number: ${JSON.stringify(n)}`),OC(s,n.slice(1),t,e)}function PC(n,t,e){const r=new rO(t,e);for(let i=0;i<2;i++){const s=i===0?"remove":"upsert",o=At.default(n),l=o[0];Array.isArray(l)?o.forEach(c=>{NC(c,s,r)}):NC(o,s,r)}r.end()}const lO=D("sharedb-comments");function FC(n){const t=n.blocks;p(lO,t,"no comment blocks");const e={blocks:{root:t},meta:{},comments:{}};return Object.entries(n).forEach(([r,i])=>{Array.isArray(i)&&(e.blocks[r]=i)}),At.default(e)}function ry(n){const{id:t,groupId:e,userId:r,displayName:i,avatarUrl:s,abstract:o,created:l,modified:c}=n;return{id:t,groupId:e,userId:r,displayName:i,avatarUrl:s,abstract:o,created:l,modified:c}}function KC(n,t){const e=VM(t),{comments:r,meta:i,blocks:s,...o}=e,l={...n,blocks:s,...o},c=At.default(l);return delete c.children,c}const Be=D("sharedb-doc/doc-container"),iy="ot-json1";Zh.type.registerSubtype($M.type),Zh.type.name=iy,Zh.type.invert=null;class hd extends Sc{constructor(e,r,i=!0){super();m(this,"doc");m(this,"client");m(this,"localPresence");m(this,"remoteCaretHandler",new FM);m(this,"batching",0);m(this,"status","clean");m(this,"disableLogout");m(this,"destroyed",!1);m(this,"handleNothingPending",()=>{this.setStatus("clean")});m(this,"handleCreate",()=>{this.handleReload("doc created")});m(this,"handleDel",()=>{});m(this,"handleReload",e=>{this.callbacks.forEach(r=>{var i;return(i=r.onRequestReload)==null?void 0:i.call(r,e)})});m(this,"handleReset",async e=>{const r=new Error(`reset doc: ${e}`);r.code="ResetDoc",this.callbacks.forEach(i=>{var s;return(s=i.onError)==null?void 0:s.call(i,r)}),this.destroy()});m(this,"handleWriteConflictError",e=>{this.handleReset(`write conflict: ${e.message}, ${JSON.stringify(e.orgMsg)}`)});m(this,"insertObject",async(e,r,i)=>{const s=[e,r,{i}];return this.submitOp(s)});m(this,"deleteObject",async(e,r)=>{const i=[e,r,{r:!0}];return this.submitOp(i)});m(this,"replaceObject",async(e,r,i)=>{const s=[e,r,{r:!0,i}];return this.submitOp(s)});m(this,"updateObject",async(e,r,i)=>{const s=this.data()[e][r],o=[e,r];return Object.entries(i).forEach(([l,c])=>{if(!pf.default(s[l],c))if(s[l]===void 0){if(c!=null){const d={i:c};o.push([l,d])}}else if(c==null){const d={r:!0};o.push([l,d])}else{const d={r:!0,i:c};o.push([l,d])}}),Object.entries(s).forEach(([l,c])=>{if((i[l]===void 0||i[l]===null)&&c!==void 0){const d={r:!0};o.push([l,d])}}),o.length<=2?Promise.resolve():this.submitOp(o)});m(this,"broadcastMessage",async e=>{const r={type:"custom",data:e,clientId:this.client.clientId};this.localPresence&&this.localPresence.submit(r)});m(this,"data",()=>this.doc.data);m(this,"submitOp",async e=>new Promise((r,i)=>{if(this.destroyed){Be.warn("submit op after destroyed");return}this.setStatus("dirty"),this.doc.submitOp(e,{},s=>{s?(Be.error(`invalid op, ${s.message}, ${JSON.stringify(e)}`),i(s),Be.error("Transform detected write conflict, reload editor"),this.handleReset("write conflict")):r()}),this.doc.data||(Be.error("no data after submit op, may be the submitted op is invalid"),this.handleReset(`invalid op, ${JSON.stringify(e)}`))}));m(this,"createDoc",async e=>new Promise((r,i)=>{this.doc.create(e,iy,s=>{s?i(s):r()})}));m(this,"submitInsertChildContainers",async e=>{if(e.length===0)return Promise.resolve();const r=e.map(({containerId:i,blocks:s})=>[Qs(i),{i:s}]);return this.submitOp([r])});m(this,"submitDeleteChildContainer",async e=>{const r=[Qs(e),{r:!0}];return this.submitOp(r)});m(this,"submitInsertBlock",async(e,r,i)=>{const s=[Qs(e),r,{i}];return this.submitOp(s)});m(this,"submitDeleteBlock",async(e,r)=>{const i=[Qs(e),r,{r:!0}];return this.submitOp(i)});m(this,"submitUpdateBlockData",async(e,r,i)=>{if(i.delete.length===0&&Object.keys(i.insert).length===0)return Promise.resolve();const s=[Qs(e),r],o=new Set(i.delete);Object.entries(i.insert).forEach(([c,d])=>{if(o.has(c)){const h={r:!0,i:d};s.push([c,h])}});const l=new Set(Object.keys(i.insert));return i.delete.forEach(c=>{if(l.has(c))return;const d={r:!0};s.push([c,d])}),Object.entries(i.insert).forEach(([c,d])=>{if(o.has(c))return;const h={i:d};s.push([c,h])}),this.submitOp(s)});m(this,"submitUpdateRichText",async(e,r,i)=>{const s=[Qs(e),r,"text",{e:i,et:"rich-text"}];return this.submitOp(s)});m(this,"handleOp",(e,r,i)=>{if(this.destroyed){Be.warn("handleOp: destroyed");return}try{PC(e,this,!!r)}catch(s){throw Be.error(s),s}});this.client=e,this.doc=r,this.doc.preventCompose=!0,this.disableLogout=i,this.registerCallback(this.remoteCaretHandler)}beginBatchUpdate(){return this.doc.preventCompose=!1,this.batching++,this.batching}endBatchUpdate(){return this.batching--,p(Be,this.batching>=0,"invalid call beginBatchUpdate/endBatchUpdate"),this.batching===0&&(this.doc.preventCompose=!0),this.batching}static async load(e){try{const r=new ZU(e.auth,e.serverUrl,e.reauthFunc),i=await r.getDoc(),s=new hd(r,i,e.disableLogout);if(i.type===null){if(e.autoCreateDoc===!1){const o=new Error("doc not exists");throw o.code="DocNotExists",o}await s.createDoc(e.templateData||tO())}return await s.initPresence(),await s.subscribe(),s.initEvents(),s}catch(r){throw Be.error(r),Be.error(`failed to load doc: ${JSON.stringify(r)}`),r}}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.forEach(r=>{var i;return(i=r.onStatusChanged)==null?void 0:i.call(r,e)}))}initEvents(){this.doc.on("nothing pending",this.handleNothingPending),this.doc.on("create",this.handleCreate),this.doc.on("del",this.handleDel),this.client.onAuthError(e=>{this.callbacks.forEach(r=>{var i;return(i=r.onError)==null?void 0:i.call(r,e)})}),this.client.onAuthRecover(()=>{this.callbacks.forEach(e=>{var r;return(r=e.onAuthRecover)==null?void 0:r.call(e)})}),this.client.onWriteConflictError(this.handleWriteConflictError)}clearEvents(){this.doc.off("nothing pending",this.handleNothingPending),this.doc.off("create",this.handleCreate),this.doc.off("del",this.handleDel)}initPresence(){return new Promise((e,r)=>{if(this.localPresence)e();else{const i=this.doc.connection.getPresence(`${this.doc.collection}:${this.doc.id}`);i.on("receive",(s,o)=>{this.onCustomMessage(o)}),i.subscribe(s=>{s?r(s):(this.localPresence=i.create(it()),e())})}})}subscribe(){return new Promise((e,r)=>{this.doc.subscribe(i=>{i?r(i):(this.doc.on("op",this.handleOp),e())})})}toJSON(){return Ys(this.data())}getContainerBlocks(e){const r=this.data();p(Be,r,"no doc data");const i=r[Qs(e)];return p(Be,i,`no container data: ${e}`),At.default(i)}findContainerBlocks(e){const r=this.data();p(Be,r,"no doc data");const i=r[Qs(e)];return i!=null?i:null}getBlockData(e,r){const i=this.data();p(Be,i,"no doc data");const s=i[Qs(e)];p(Be,s,`no container data: ${e}`);const o=s[r];return p(Be,o,`no block data: ${r}`),At.default(o)}localInsertBlock(e,r,i){return this.submitInsertBlock(e,r,i),this.getBlockData(e,r)}localDeleteBlock(e,r){const i=this.getBlockData(e,r);return this.submitDeleteBlock(e,r),i}localUpdateBlockText(e,r,i){const s=this.getBlockData(e,r);p(Be,s.text,"no block text");const o=At.default(s.text);this.submitUpdateRichText(e,r,i);const l=$n.apply(o,i);return p(Be,l,"no block text"),l}localUpdateBlockData(e,r,i){const s=At.default(this.getBlockData(e,r));return this.submitUpdateBlockData(e,r,i),s}localInsertChildContainers(e){this.submitInsertChildContainers(e)}localDeleteChildContainers(e){this.beginBatchUpdate(),e.forEach(r=>{this.submitDeleteChildContainer(r)}),this.endBatchUpdate()}getComments(){return Object.values(this.data().comments).map(r=>ry(r))}getComment(e){return this.data().comments[e]}getCommentDoc(e){const r=this.data().comments[e];return FC(r)}localCreateComment(e,r){const i=KC(e,r),o=["comments",i.id,{i}];return this.submitOp(o)}localDeleteComment(e){const r=["comments",e,{r:!0}];return this.submitOp(r)}localUpdateComment(e,r){const i=KC(e,r),s=["comments",e.id,{r:!0,i}];return this.submitOp(s)}destroy(){var e;this.destroyed=!0,this.clearEvents(),this.clearCallbacks(),this.doc.destroy(),(e=this.localPresence)==null||e.destroy(),this.client.close(!this.disableLogout),this.remoteCaretHandler.destroy()}onDeleteBlock(e,r,i){p(Be,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var o;return(o=s.onDeleteBlock)==null?void 0:o.call(s,Jc(e),r,i)})}onInsertBlock(e,r,i,s){p(Be,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var l;return(l=o.onInsertBlock)==null?void 0:l.call(o,Jc(e),r,i,s)})}onUpdateBlockData(e,r,i,s){p(Be,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var l;return(l=o.onUpdateBlockData)==null?void 0:l.call(o,Jc(e),r,i,s)})}onUpdateBlockText(e,r,i,s){p(Be,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var l;return(l=o.onUpdateBlockText)==null?void 0:l.call(o,Jc(e),r,i,s)})}onDeleteContainer(e,r){p(Be,this.callbacks.length>0,"no callbacks"),p(Be,e!=="root","should not delete root container in doc"),this.callbacks.forEach(i=>{var s;return(s=i.onDeleteChildContainer)==null?void 0:s.call(i,Jc(e),r)})}onCreateContainer(e,r,i){p(Be,this.callbacks.length>0,"no callbacks"),p(Be,e!=="root","should not create root container in doc"),this.callbacks.forEach(s=>{var o;return(o=s.onInsertChildContainer)==null?void 0:o.call(s,Jc(e),r,i)})}onDeleteComment(e,r){p(Be,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var s;return(s=i.onDeleteComment)==null?void 0:s.call(i,e,r)})}onCreateComment(e,r){p(Be,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var s;return(s=i.onCreateComment)==null?void 0:s.call(i,e,r)})}onUpdateComment(e,r){p(Be,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var s;return(s=i.onUpdateComment)==null?void 0:s.call(i,e,r)})}onCustomMessage(e){const r=e;(r==null?void 0:r.type)==="custom"&&(r==null?void 0:r.clientId)!==this.client.clientId?this.callbacks.forEach(i=>{var s;return(s=i.onCustomMessage)==null?void 0:s.call(i,r.data)}):(r==null?void 0:r.type)==="onlineUsers"&&setTimeout(()=>{const i={type:"custom",data:e,clientId:"-"};this.onCustomMessage(i)})}onAuthRecover(){this.callbacks.forEach(e=>{var r;return(r=e.onAuthRecover)==null?void 0:r.call(e)})}async addResources(e){let r=[];return e.forEach(s=>{const o=s.split("|");r.push(...o)}),r=Array.from(new Set(r)),await this.client.getFileUrlsByHashes(r)}async uploadResource(e,r){var s;return{resourceId:await this.client.uploadResource(e,(s=r==null?void 0:r.onProgress)!=null?s:()=>{})}}buildResourceUrl(e,r){return this.client.buildResourceUrl(e,r)}request(e,r){return this.client.request(e,r)}getUser(){const e=this.client.clientId,{permission:r,userId:i,displayName:s,avatarUrl:o}=this.client.auth;return{permission:r,clientId:e,userId:i,displayName:s,avatarUrl:o,rainbowIndex:0}}getRemoteUsers(){return this.remoteCaretHandler.remoteUsers}getVersionHelper(){return this}getVersions(){return this.client.getVersions()}async getVersion(e){const r=await this.client.getVersion(e);return Ys(r)}async getLatestVersion(){const e=await this.client.getLatestVersion();return Ys(e)}async getHistoryData(e,r){const{doc:i,ops:s}=await this.client.getVersionOps(e,r),o=s.map(l=>({user:l.meta.createdBy,data:l}));return{doc:Ys(i),historyData:o}}async getVersionData(e,r){const{doc:i,ops:s}=await this.client.getVersionOps(e,r);return{doc:Ys(i),versionData:s}}async updateVersionExtra(e,r,i){await this.client.updateVersionExtra(e,r,i)}revertVersion(e){return this.client.revertVersion(e)}createVersion(e,r){return this.client.createVersion(e,r)}async recognizeLink(e){return this.client.recognizeLink(e)}parseHistoryData(e,r){PC(e.data.op,r,!0)}getServerMeta(){return{appId:this.client.auth.appId,docId:this.client.auth.docId,serverId:this.client.apiServer()}}triggerReAuth(){this.client.reAuth()}}D("remote-cursor");class sy{constructor(t){m(this,"handleDocSelectionChange",()=>{this.broadcastCaretPos()});m(this,"broadcastCaretPos",Ke.default(()=>{const t={type:"caret",userId:this.editor.doc.getUser().userId,range:this.editor.selection.range.toDocRange()};this.editor.doc.broadcastMessage(t)},300));m(this,"handleRemoteCaretsChanged",t=>{t.forEach(e=>{const r=this.editor.findBlockById(e);r&&this.editor.reloadBlock(r)})});this.editor=t,this.editor.addListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().addListener("remote-carets-change",this.handleRemoteCaretsChanged)}destroy(){this.editor.removeListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().removeListener("remote-carets-change",this.handleRemoteCaretsChanged)}}const oy=D("remote-cursor-decorator");class VC{decorateText(t,e,r){const i=t.doc.getRemoteUsers();if(!i)return{};const s=new Map,{containerId:o,blockIndex:l}=e[e.length-1];p(oy,typeof o=="string","invalid path containerId"),p(oy,typeof l=="number","invalid path blockIndex");const c=t.doc.getBlockData(o,l),d=Vn(r);return i.getSimpleCursors(c.id).forEach((C,E)=>{E>d&&(E=d);const A=C.map(R=>({id:it(),type:"remote-cursor",name:R.user.displayName,time:R.time,rainbowIndex:R.user.rainbowIndex})),v=s.get(E);v?v.push(...A):s.set(E,A)}),{insertions:s}}}const $C=D("sharedb-doc/share-db-server"),aO=Bb.default.create();class cO{constructor(t,e){m(this,"auth");m(this,"clientId",it());this.serverUrl=e,this.auth=t}editorServer(){const t=this.apiServer(),e=`/${this.auth.appId}/${this.auth.docId}`;return p($C,t.endsWith(e),`invalid api server: ${t}, ${e}`),t.substr(0,t.length-e.length)}apiServer(){const t=`${this.serverUrl}/${this.auth.appId}/${this.auth.docId}`;if(t.startsWith("ws://"))return`http://${t.substring(5)}`;if(t.startsWith("wss://"))return`https://${t.substring(6)}`;throw new Error(`invalid server url: ${t}`)}getBaseURL(){const t=new URL(this.apiServer());return`${t.protocol}//${t.host}${t.pathname}`}getBase64BaseURL(){return qi(this.getBaseURL())}async request(t,e){var s;const r=this.auth.token,i=e||{};i.url=t,i.headers||(i.headers={}),p($C,r,"no token"),i.headers={...i.headers,[Ea]:r,[eu]:this.getBase64BaseURL()};try{return await aO(t,i)}catch(o){throw(s=o.response)!=null&&s.data&&(o.responseData=o.response.data),o}}async getVersions(){const e=`${this.apiServer()}/versions?withExtra=true`,i=(await this.request(e)).data.versions;return i.forEach(s=>{s.extra&&(s.extra=JSON.parse(s.extra))}),i}async getVersion(t){const r=`${this.apiServer()}/versions/${t}`,i=await this.request(r);return JSON.parse(i.data.data)}async getLatestVersion(){const e=`${this.apiServer()}/versions/latest`,r=await this.request(e);return JSON.parse(r.data.data)}async getVersionOps(t,e){let i=`${this.apiServer()}/versions/before/${t}?withOp=true`;e!==void 0&&e!==0&&(i+=`&from=${e}`);const s=await this.request(i),o=s.data.ops,l=Tb.default(o,h=>!!h.create);let c=null;l!==-1&&(c=o[l],o.splice(0,l+1));let d;return c?(p($C,c.create,"no createDoc.create"),d=c.create.data):d=JSON.parse(s.data.data),d.blocks||(d.blocks=[]),{doc:d,ops:s.data.ops}}async updateVersionExtra(t,e,r){const s=`${this.apiServer()}/versions/${t}/tags/${e}`;await this.request(s,{method:"post",data:{extra:JSON.stringify(r)}})}async revertVersion(t){const r=`${this.apiServer()}/versions/revert/${t}`;await this.request(r,{method:"post",data:{}})}async createVersion(t,e){const i=`${this.apiServer()}/versions`;return(await this.request(i,{method:"post",data:{publish:e,tag:t}})).data}buildResourceUrl(t,e){if(!t)return"";if(t.startsWith("https:")||t.startsWith("http:")||t.startsWith("file:")||t.startsWith("data:")||t.startsWith("blob:"))return t;let i=`${this.apiServer()}/resources/${encodeURIComponent(t)}`;const s=[];if(e!=null&&e.withToken,e!=null&&e.downloadFileName&&s.push(`&fileName=${encodeURIComponent(e.downloadFileName)}`),s.length>0){const o=s.join("&");i+=`?${o}`}return i}}const uO=D("sharedb-doc/share-db-server");function ly(n){const t=new URL(n);return`${t.protocol==="wss:"?"https:":"http:"}//${t.host}${t.pathname}`}function fO(n){return qi(ly(n))}class hm extends Sc{constructor(e){super();m(this,"remoteUsers",new td);m(this,"client");this.options=e,this.client=new cO(e.auth,e.serverUrl)}destroy(){}buildResourceUrl(e,r){return this.client.buildResourceUrl(e,r)}getRemoteUsers(){return this.remoteUsers}getVersionHelper(){return this}getVersions(){return this.client.getVersions()}async getVersion(e){const r=await this.client.getVersion(e);return Ys(r)}async getLatestVersion(){const e=await this.client.getLatestVersion();return Ys(e)}async getHistoryData(e,r){const{doc:i,ops:s}=await this.client.getVersionOps(e,r),o=s.map(l=>({user:l.meta.createdBy,data:l}));return{doc:Ys(i),historyData:o}}async getVersionData(e,r){const{doc:i,ops:s}=await this.client.getVersionOps(e,r);return{doc:Ys(i),versionData:s}}async updateVersionExtra(e,r,i){await this.client.updateVersionExtra(e,r,i)}revertVersion(e){return this.client.revertVersion(e)}createVersion(e,r){return this.client.createVersion(e,r)}parseHistoryData(e,r){PC(e.data.op,r,!0)}getServerMeta(){return{appId:this.client.auth.appId,docId:this.client.auth.docId,serverId:this.client.apiServer()}}static async auth(e,r){p(uO,e.token,"no auth token");const i=`${ly(r)}/auth`,s=await window.fetch(i,{method:"GET",headers:{[Ea]:e.token,[eu]:fO(r)},credentials:"include"});if(s.status!==200)throw new Error("http auth error");return await s.json()}static async load(e){const r=`${e.serverUrl}/${e.auth.appId}/${e.auth.docId}`;return await this.auth(e.auth,r),new hm(e)}}class ay extends Fe.TypedEmitter{constructor(t){super(),this.editor=t,this.editor.doc.registerCallback(this)}handleChild(t,e,r){if(ie(mi(this.editor,t)))return;const i=this.editor.getBlockByIndex(t,e),s=nt(this.editor.getContainerById(t));s&&this.emit("change",this.editor,{containerId:t,blockIndex:e},s,i,r)}onUpdateBlockData(t,e){this.handleChild(t,e,"data-change")}onUpdateBlockText(t,e){this.handleChild(t,e,"text-change")}onInsertBlock(t,e){ie(mi(this.editor,t))||this.emit("insert",this.editor,{containerId:t,blockIndex:e})}onDeleteBlock(t,e){this.handleChild(t,e,"remove")}destroy(){this.editor.doc.unregisterCallback(this)}}function cy(n,t){const e=n.addCustom("child-block-tracker",()=>new ay(n));e.addListener("change",t),e.addListener("insert",t)}function uy(n,t){const e=n.addCustom("child-block-tracker",()=>new ay(n));e.removeListener("change",t),e.removeListener("insert",t)}const _lt="",dO={colorPalette:{colorDesc:"\u5B57\u4F53\u989C\u8272",name:"\u6587\u672C\u989C\u8272",backgroundDesc:"\u80CC\u666F\u989C\u8272",reset:"\u6062\u590D\u9ED8\u8BA4"},search:{emptyTips:"\u6682\u65E0\u641C\u7D22\u7ED3\u679C"}},hO={colorPalette:{colorDesc:"Text color",name:"Text color",backgroundDesc:"Background color",reset:"Restore default values"},search:{emptyTips:"No results found"}},mO={colorPalette:{colorDesc:"\u30D5\u30A9\u30F3\u30C8\u306E\u8272",name:"\u30C6\u30AD\u30B9\u30C8\u306E\u8272",backgroundDesc:"\u80CC\u666F\u8272",reset:"\u30C7\u30D5\u30A9\u30EB\u30C8\u306B\u623B\u3059"},search:{emptyTips:"\u691C\u7D22\u7D50\u679C\u304C\u3042\u308A\u307E\u305B\u3093"}};_.mergeLang({"zh-CN":dO,"en-US":hO,"ja-JP":mO});const Mlt="";D("button");function Xr(n,t,e,r,i){const s=B("button",["editor-button"],null);return s.setAttribute("data-button-id",n),i&&s.setAttribute(`data-editor-tooltip-${i}`,t),e?typeof e=="string"?e.startsWith("<")?s.innerHTML=e:s.innerText=e:s.appendChild(e):s.innerText=t,r&&(r.indexOf("checked")!==-1&&q(s,"checked"),r.indexOf("disabled")!==-1&&(s.disabled=!0),r.indexOf("primary")!==-1&&q(s,"primary")),s}const Ult="",mm=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
32
32
|
<path d="M8.00874 7.89952L12.9497 2.94975M8.00874 7.89952L12.9497 12.8492M8.00874 7.89952L3.05025 12.8492M8.00874 7.89952L3.05025 2.94975" stroke="currentColor" stroke-linejoin="round"/>
|
|
33
33
|
</svg>
|
|
34
34
|
`,fy=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -959,4 +959,4 @@ ${s.mermaidText}
|
|
|
959
959
|
${s.flowchartText}
|
|
960
960
|
\`\`\`\`\`\``}return""}const DJ={embedType:"flowchart",convertFrom:SJ,handleUpdateBlock:wJ,createEmbedContent:RJ,getBlockProperties:LJ,convertTo:IJ},_J=D("plantuml-helper");function kS(n,t){var l;let r=((l=(n.getComponentOptions("plantuml")||{}).cdn)==null?void 0:l.plantuml)||uJ;r.endsWith("/")||(r+="/");const i=s9.default.encode(t);p(_J,i,i),r+=i;const o=new URLSearchParams(document.location.search).get("doc");return Np(r,{id:`${o}-${it()}`})}async function MJ(n,t){try{const e=await Ex(n,t);return(await n.doc.uploadResource(e)).resourceId}catch{return Promise.resolve(t)}}class Uu extends vx{constructor(t){super(t,"plantuml","plantumlText")}static get(t,e){return t.addCustom(`plantuml-${e.id}`,()=>new Uu(t))}code2ObjectUrl(t){return Promise.resolve(kS(this.editor,t))}code2ResourceId(t){const e=kS(this.editor,t);return MJ(this.editor,e)}destroy(){}}function UJ(n,t,e){Uu.get(n,e).createEmbedContent(t,e)}function OJ(n,t,e){const r=Uu.get(n,e),i=jt(t);return r.updateEmbedContent(i,e),!0}function NJ(n,t,e){const{data:r}=e,i=n.getBlockString(t).trim();if(!r||r.embedType!=="plantuml"||i!=="```plantuml"||!ot(n,t))return null;const s={src:"",plantumlText:""};return{blockData:{id:it(),type:"embed",embedType:"plantuml",embedData:s},onConverted:(c,d)=>{Uu.get(c,c.getBlockData(d)).editGraph(jt(d))}}}function PJ(n,t){return Uu.get(n,n.getBlockData(t)).getBlockProperties(t)}function FJ(n,t,e,r){const{embedData:i}=t,s=i;if(r==="html")return s.src?`<img src="${n.doc.buildResourceUrl(s.src,{withToken:!0})}" />`:s.flowchartText?`<div>${s.flowchartText}</div>`:"<p>[plantuml]</p>";if(r==="markdown"){if(s.src)return`})`;if(s.flowchartText)return`\`\`\`plantuml\`\`\`
|
|
961
961
|
${s.flowchartText}
|
|
962
|
-
\`\`\`\`\`\``}return""}const KJ={embedType:"plantuml",convertFrom:NJ,handleUpdateBlock:OJ,createEmbedContent:UJ,getBlockProperties:PJ,convertTo:FJ},zat="",VJ="hr",$J={dividingLine:{type:"\u5206\u5272\u7EBF",abstract:"\u5206\u5272\u7EBF"}},HJ={dividingLine:{type:"Dividing-Line",abstract:"Dividing-Line"}},jJ={dividingLine:{type:"\u533A\u5207\u308A\u7DDA",abstract:"\u533A\u5207\u308A\u7DDA"}};_.mergeLang({"zh-CN":$J,"en-US":HJ,"ja-JP":jJ});function zJ(n,t){const e=B("div",["editor-embed-container"],t);B("hr",["editor-embed-hr"],e)}function GJ(n,t,e,r){return r==="html"?"<hr />":r==="markdown"?"---":"------------"}function WJ(){return{name:"hr",insertEmbedCommandItems:[{id:"insert-hr",name:_.t("dividingLine.type"),icon:Fy,order:500,group:"common",subText:Jn("insert-hr")}],handleInsertEmptyEmbed:async(n,t)=>{const{containerId:e,blockIndex:r}=t;return n.insertEmbed(e,r,VJ,{})}}}function qJ(n,t,e){const{data:r}=e;if(!r||r.embedType!=="dividing-line"||!ot(n,t))return null;const i={};return{blockData:{id:it(),type:"embed",embedType:"hr",embedData:i}}}function XJ(){return{abstract:_.t("dividingLine.abstract")}}const YJ={embedType:"hr",createEmbedContent:zJ,convertTo:GJ,getOptions:WJ,convertFrom:qJ,getBlockProperties:XJ},Gat="",Wat="",QJ={media:{upload:{failed:'<div class="line-1">{name}\u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <span class="retry-upload">\u91CD\u8BD5</span></div>',maxSizeFailed:'<div class="line-1">{name}\u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u6587\u4EF6\u5927\u5C0F\u8D85\u8FC7\u9650\u5236\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6</div>'},load:{failed:'<div class="line-1">{name}\u52A0\u8F7D\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <span class="retry-upload">\u91CD\u8BD5</span></div>'},audio:{menuItem:"\u97F3\u9891",abstract:"\u97F3\u9891"},video:{menuItem:"\u89C6\u9891",abstract:"\u89C6\u9891"}}},JJ={media:{upload:{failed:'<div class="line-1">{name} upload failed</div><div class="line-2">Network error, you can <span class="retry-upload">Retry</span></div>',maxSizeFailed:'<div class="line-1">{name} upload failed</div><div class="line-2">The file size exceeds limit. Please choose another file.</div>'},load:{failed:'<div class="line-1">{name} loading failed</div><div class="line-2">Network error, you can <span class="retry-upload">Retry</span></div>'},audio:{menuItem:"Audio",abstract:"Audio"},video:{menuItem:"Video",abstract:"Video"}}},ZJ={media:{upload:{failed:'<div class="line-1">{name}\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F</div><div class="line-2">\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 <span class="retry-upload">\u518D\u8A66\u884C</span></div>',maxSizeFailed:'<div class="line-1">{name}\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F</div><div class="line-2">\u30D5\u30A1\u30A4\u30EB\u306E\u30B5\u30A4\u30BA\u304C\u4E0A\u9650\u3092\u8D85\u3048\u3066\u3044\u308B\u305F\u3081\u3001\u4ED6\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044</div>'},load:{failed:'<div class="line-1">{name}\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F</div><div class="line-2">\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 <span class="retry-upload">\u518D\u8A66\u884C</span></div>'},audio:{menuItem:"\u97F3\u58F0",abstract:"\u97F3\u58F0"},video:{menuItem:"\u52D5\u753B",abstract:"\u52D5\u753B"}}};_.mergeLang({"zh-CN":QJ,"en-US":JJ,"ja-JP":ZJ});var Ui=(n=>(n.AUDIO="audio",n.VIDEO="video",n))(Ui||{}),sh=(n=>(n.Empty="empty",n.Progress="progress",n.Error="error",n))(sh||{});const RS=10*1024*1024,tZ=["wav","mp3","aac","ogg","webm","flac"],eZ=["ogg","mp4","webm"],nZ=()=>{};function wS(n){var h,C,E,A,v,R;const t=(h=n.getComponentOptions("media"))!=null?h:{},{allowedMedias:e,maxSize:r,callbacks:i}=t,s=(C=e==null?void 0:e.audio)!=null?C:tZ,o=(E=e==null?void 0:e.video)!=null?E:eZ,l=(A=r==null?void 0:r.audio)!=null?A:RS,c=(v=r==null?void 0:r.video)!=null?v:RS,d=(R=i==null?void 0:i.onError)!=null?R:nZ;return{allowedMedias:{audio:s,video:o},maxSize:{audio:l,video:c},callbacks:{onError:d}}}function rZ(n,t){const e=s=>s.map(o=>`.${o}`).join(","),{allowedMedias:r}=wS(n),i=r[t];return i?e(i):"*"}function iZ(n,t,e){const{maxSize:r,callbacks:i,allowedMedias:s}=wS(t),{[e]:o}=r,{[e]:l}=s;if(o&&n.size>o){const d=new Error("media is too large");throw d.code=`MaxMediaSize-${e}`,i!=null&&i.onError&&(i==null||i.onError(t,d)),d}const c=yf(n.name);if(l&&!l.includes(c.toLowerCase())){const d=new Error(`media file is not allowed: ${c}`);throw d.code="NotAllowedFile",i!=null&&i.onError&&(i==null||i.onError(t,d)),d}}function sZ(n){return n===sh.Empty||n===sh.Error}const Cn=D("media");class oZ extends Fe.TypedEmitter{constructor(e){super();m(this,"mediaContainer",null);m(this,"media",null);m(this,"abstract",null);m(this,"handleMediaLoadError",(e,r)=>{if(!r.target||!(r.target instanceof Node)||!(r.target instanceof Element?r.target:r.target.parentElement))return;const s=nt(r.target);if(!s||!s.contains(this.mediaContainer))return;const o=this.renderError();this.updateMediaContent(o),this.emit("mediaError",e,"load_error",dt(s))});m(this,"handleUploadFile",async e=>{p(Cn,this.abstract,"no abstract"),p(Cn,this.mediaContainer,"The media element not exist");const{editor:r}=this.options,i=nt(this.mediaContainer);p(Cn,i,"The block element not exist");const s=r.getBlockData(i);try{const{resourceId:o}=await r.doc.uploadResource(e,{onProgress:C=>{this.renderProgress(C,e)}}),{name:l,type:c,size:d}=e,h={...s,embedData:{...s.embedData,src:o,fileName:l,fileSize:d,fileType:c}};r.updateBlockData(i,h)}catch(o){Cn.error(o),this.emit("mediaError",r,"upload_error",s.id),this.renderRetry(e,o)}ut(i,"media-block-uploading")});m(this,"destroy",()=>{this.mediaContainer=null});this.options=e}bindMediaEvent(){const{editor:e}=this.options;this.media&&e.domEvents.addEventListener(this.media,"error",this.handleMediaLoadError)}unbindMediaEvent(){const{editor:e}=this.options;this.media&&e.domEvents.removeEventListener(this.media,"error",this.handleMediaLoadError)}updateMediaContent(e){p(Cn,this.mediaContainer,"The media element not exist"),this.mediaContainer.innerHTML="",this.mediaContainer.append(e)}renderError(){p(Cn,this.abstract,"no abstract");const{editor:e,createMediaElement:r}=this.options,{mediaIcon:i,mediaName:s}=this.abstract;p(Cn,this.mediaContainer,"The media element not exist");const o=nt(this.mediaContainer);p(Cn,o,"The block element not exist");const l=e.getBlockData(o),c=B("div",["media-error","embed-selected-content","embed-hover-content"],null),d=B("span",["media-error-icon"],c);d.innerHTML=i;const h=B("div",[],c);h.innerHTML=_.t("media.load.failed",{name:s}),c.appendChild(h);const C=h.querySelector(".retry-upload");return p(Cn,C,"The element not exist"),e.domEvents.addEventListener(C,"click",(E,A)=>{const v=B("div",["media-element"],null),R=this.getResourceUrl(l),S=r(E,v,l,R);this.unbindMediaEvent(),this.media=S,this.bindMediaEvent(),this.updateMediaContent(v)}),this.setFullScreen(),c}renderRetry(e,r){var E,A;p(Cn,this.abstract,"no abstract");const{editor:i}=this.options,{mediaIcon:s,mediaName:o}=this.abstract,l=B("div",["media-error","embed-selected-content","embed-hover-content"],null),c=B("span",["media-error-icon"],l);c.innerHTML=s;const d=B("div",[],l);let h=_.t("media.upload.failed",{name:o});(((E=r.response)==null?void 0:E.status)===420||((A=r.response)==null?void 0:A.status)===413)&&(h=_.t("media.upload.maxSizeFailed",{name:o})),d.innerHTML=h,l.appendChild(d);const C=d.querySelector(".retry-upload");C&&i.domEvents.addEventListener(C,"click",()=>{i.readonly||(p(Cn,this.abstract,"no abstract"),this.handleUploadFile(e))}),this.updateMediaContent(l),this.setFullScreen()}renderProgress(e,r){p(Cn,this.mediaContainer,"The media element not exist");const i=this.mediaContainer.querySelector(":scope .media-progress"),s=e===-1||e===100?100:e;if(i){const{updateProgressElement:o}=this.options;o(i,s)}else{const{createProgressElement:o}=this.options,l=nt(this.mediaContainer);p(Cn,l,"The element not exist"),q(l,"media-block-uploading");const c=B("div",["media-progress"],null);o(c,s,r),this.updateMediaContent(c)}this.setFullScreen()}renderMediaElement(e,r){p(Cn,this.mediaContainer,"The media element not exist");const i=this.mediaContainer.querySelector(":scope > .media-element"),{createMediaElement:s,updateMediaElement:o,editor:l}=this.options,c=this.getResourceUrl(e,r);if(i){const d=o(l,i,e,c);this.unbindMediaEvent(),this.media=d,this.bindMediaEvent()}else{const d=B("div",["media-element"],null),h=s(l,d,e,c);this.unbindMediaEvent(),this.media=h,this.bindMediaEvent(),this.updateMediaContent(d)}}renderEmpty(e){p(Cn,this.abstract,"no abstract"),p(Cn,this.mediaContainer,"The media element not exist");const r=B("div",["media-empty","embed-selected-content","embed-hover-content"],this.mediaContainer);r.innerHTML=this.abstract.mediaIcon,this.updateMediaContent(r);const{editor:i}=this.options;i.findBlockById(e.id)&&this.emit("mediaError",i,"empty",e.id),this.setFullScreen()}getResourceUrl(e,r){const{src:i}=e.embedData,{editor:s}=this.options;return s.doc.buildResourceUrl(i,{syncNewResources:async(o,l)=>{var d,h;if(!r)return;await s.doc.addResources([o]);const c=(h=(d=s.doc).getServerMeta)==null?void 0:h.call(d).appId;if(l!==e.embedData.src&&c&&e.embedData.src.includes(c)){const C=nt(r);if(C&&!s.readonly&&s.isBlockWritable(C)){const E=At.default(e);E.embedData.src=o,s.updateBlockData(C,E)}}}})}setFullScreen(){p(Cn,this.mediaContainer,"The media element not exist"),q(this.mediaContainer,"full-screen")}removeFullScreen(){p(Cn,this.mediaContainer,"The media element not exist"),ut(this.mediaContainer,"full-screen")}updateBlockAlign(e,r){const i=nt(r);p(Cn,i,"The block element not exist");const{align:s}=e;e.embedType==="video"&&(i.hasAttribute("data-style-align")&&i.removeAttribute("data-style-align"),i.setAttribute("data-style-align",s))}render(e,r){const{src:i}=e.embedData;(!this.mediaContainer||!r.contains(this.mediaContainer))&&(this.mediaContainer=B("div",["media"],r)),this.updateBlockAlign(e,r),sZ(i)?i===sh.Empty&&this.renderEmpty(e):this.renderMediaElement(e,r)}setAbstract(e){this.abstract=e}}D("media-embed");const lZ="left";class SS{constructor(){m(this,"handleInsertEmptyEmbed",async(t,e)=>{var C;const{containerId:r,blockIndex:i}=e;let s;(C=e.data)!=null&&C.file&&(s=e.data.file);const o=rZ(t,this.embedType);if(s=s!=null?s:await _c(o,{}),!s)return null;const{mediaType:l}=this.getAbstract();try{iZ(s,t,l)}catch{return null}const c={id:it(),type:"embed",embedType:this.embedType,embedData:{src:sh.Empty}};l==="video"&&(c.align=lZ);const d=t.insertBlock(r,i,c);return await this.getMedia(t,c.id).handleUploadFile(s),d})}getMedia(t,e){const r=t.addCustom(`media-${e}`,()=>new oZ({editor:t,createMediaElement:this.createMediaElement,updateMediaElement:this.updateMediaElement,createProgressElement:this.createProgressElement,updateProgressElement:this.updateProgressElement}));return r.setAbstract({...this.getAbstract()}),r}getOptions(){const{menuItem:t,mediaIcon:e,mediaName:r,order:i,group:s}=this.getAbstract();return{name:r,insertEmbedCommandItems:[{id:`insert-${this.embedType}`,name:t,icon:e,order:i,group:s,subText:Jn(`insert-${this.embedType}`)}],handleInsertEmptyEmbed:this.handleInsertEmptyEmbed}}createEmbedContent(t,e,r){const{id:i}=r;this.getMedia(t,i).render(r,e)}handleUpdateBlock(t,e,r){const{id:i}=r,s=this.getMedia(t,i),o=jt(e);return s.render(r,o),!0}handleDeleteBlock(t,e){const r=e.id,i=this.getMedia(t,r);i.removeAllListeners(),i.destroy()}convertTo(t,e,r,i){const s=e.embedData,o=t.doc.buildResourceUrl(s.src,{withToken:!0});return i==="html"?`<${s.type} src="${o}" />`:i==="markdown"?``:o}}function LS(n,t){const e=B("div",["uploading-progress-mask"],n),r=B("div",["uploading-progress-bar"],e),i=B("div",["uploading-progress-bar-value"],r);i.style.width=`${t}%`}function IS(n,t){const e=n.querySelector(".uploading-progress-bar-value");e&&(e.style.width=`${t}%`)}const aZ=D("media-audio");class cZ extends SS{constructor(){super(...arguments);m(this,"embedType",Ui.AUDIO);m(this,"updateProgressElement",IS);m(this,"createMediaElement",(e,r,i,s)=>{const o=B("div",["audio-container","embed-hover-content","embed-selected-content"],r),l=B("audio",[],o);return l.innerHTML="Your browser does not support the <code>audio</code> element.",l.controls=!0,l.src=s,setTimeout(()=>{this.getMedia(e,i.id).setFullScreen()}),l})}getAbstract(){return{mediaIcon:Oy,mediaName:_.t(`media.${Ui.AUDIO}.menuItem`),menuItem:_.t(`media.${Ui.AUDIO}.menuItem`),order:800,mediaType:Ui.AUDIO,group:"common"}}getBlockProperties(){return{abstract:`${_.t(`media.${Ui.AUDIO}.abstract`)}`}}updateMediaElement(e,r,i,s){const o=r.querySelector(":scope .audio-container > audio");return p(aZ,o,"The media element not exist"),o.src!==s&&(o.src=s),o}createProgressElement(e,r){const i=B("audio",[],e);i.innerHTML="Your browser does not support the <code>audio</code> element.",i.controls=!0,i.src="about:blank",LS(e,r)}}const uZ=new cZ;D("video-resizer");function DS(n){return n&&Se(n)&&sn(n)==="video"}const fZ=50;class Bx{constructor(t){m(this,"currentResizableElement",null);m(this,"resizing",!1);m(this,"handleHoveringBlockChange",(t,e)=>{if(!this.resizing&&!window.isDragging&&(e&&DS(e)&&this.disableBlockResize(e),t&&DS(t)&&this.editor.isBlockWritable(t))){const r=this.getVideoElement(t);if(!r)return;this.enableBlockResize(t,r)}});m(this,"handleResizing",(t,e)=>{if(this.resizing=!0,!this.currentResizableElement)return;const r=t.getBlock();if(!r)return;const i=r.getBoundingClientRect().width,s=Math.min(Math.max(e.width,fZ),i);this.currentResizableElement.style.width=`${s}px`,this.currentResizableElement.style.pointerEvents="none"});m(this,"handleResized",t=>{this.resizing=!1;const e=t.getBlock();if(!this.currentResizableElement||!e)return;const r=this.editor.getBlockData(e),{width:i}=this.currentResizableElement.getBoundingClientRect();this.currentResizableElement.style.pointerEvents="auto",this.editor.updateBlockData(e,{...r,width:i})});this.editor=t,He.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentResizableElement=null,He.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}getVideoElement(t){return jt(t).querySelector(":scope .video-container > video")}updateResizer(t){const e=this.editor.findCustom(`${dt(t)}-resizer`);e&&e.updateResizer()}disableBlockResize(t){const e=this.editor.findCustom(`${dt(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t,e){const r=this.editor.addCustom(`${dt(t)}-resizer`,()=>new Nd(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}));r.enableResize(t,e),r.removeListener("resizing",this.handleResizing),r.removeListener("resized",this.handleResized),r.addListener("resizing",this.handleResizing),r.addListener("resized",this.handleResized),this.currentResizableElement=e}}const dZ=D("video");class hZ extends SS{constructor(){super(...arguments);m(this,"embedType",Ui.VIDEO);m(this,"updateProgressElement",IS);m(this,"createMediaElement",(e,r,i,s)=>{const o=B("div",["video-container","embed-selected-content","drag-preview-element"],r),l=B("video",[],o);return l.innerHTML="Your browser does not support the <code>video</code> element.",l.controls=!0,l.src=s,l.addEventListener("canplay",()=>{e.addCustom("video-resizer",()=>new Bx(e)),this.getMedia(e,i.id).removeListener("mediaError",this.handleMediaError),this.getMedia(e,i.id).addListener("mediaError",this.handleMediaError),this.getMedia(e,i.id).removeFullScreen()}),i.width&&(l.style.width=`${i.width}px`),l});m(this,"createProgressElement",(e,r,i)=>{const s=B("video",["progress-video"],e);s.innerHTML="Your browser does not support the <code>audio</code> element.",s.controls=!0,LS(e,r),Dc(i).then(o=>{const l=e.querySelector(".progress-video");l&&e1(e)&&(l.src=o)})})}getAbstract(){return{mediaName:_.t(`media.${Ui.VIDEO}.menuItem`),mediaIcon:Ny,menuItem:_.t(`media.${Ui.VIDEO}.menuItem`),order:700,mediaType:Ui.VIDEO,group:"common"}}getBlockProperties(){return{abstract:`${_.t(`media.${Ui.VIDEO}.abstract`)}`}}handleMediaError(e,r,i){const s=e.addCustom("video-resizer",()=>new Bx(e)),o=e.getBlockById(i);s.disableBlockResize(o)}updateMediaElement(e,r,i,s){const o=r.querySelector(":scope .video-container > video");p(dZ,o,"The media element not exist"),o.src!==s&&(o.src=s),i.width?o.style.width=`${i.width}px`:o.style.width="";const l=e.getBlockById(i.id);return setTimeout(()=>{e.addCustom("video-resizer",()=>new Bx(e)).updateResizer(l)}),o}}const mZ=new hZ,_S=[lA,gA,pA,kk],Tx=[vS,gQ,BJ,DJ,KJ,yK,YJ,mZ,uZ,Rz,Z4,aX],MS=[Pk,nS,y4,Hk];function gZ(n,t,e){var i,s,o,l;di.level=(i=e.logLevel)!=null?i:Wo.DEBUG;const r=Zf(n,t,{components:{blocks:[..._S,...((s=e==null?void 0:e.components)==null?void 0:s.blocks)||[]],embeds:[...Tx,...((o=e.components)==null?void 0:o.embeds)||[]],boxes:[...MS,...((l=e.components)==null?void 0:l.boxes)||[]],textRenders:[new $E],options:{...e.componentsOptions}}});return r.readonly=!0,r.addCustom("heading-collapse",()=>new ax(r)),r.addCustom("editor-tooltip",()=>new Sd(r)),r.addListener("clickLink",(c,d,h)=>{var E;if((E=e==null?void 0:e.events)!=null&&E.onClickLink){e.events.onClickLink(c,d,h);return}const C=h.getAttribute("link");C&&(c.readonly||d.ctrlKey||d.metaKey)&&window.open(C,"_blank")}),r}class US{constructor(t){this.createOptions=t,t.lang&&_.setLang(t.lang)}createHistoryEditor(t,e){return gZ(t,e,this.createOptions)}}function OS(n,{root:t,childDoc:e,doc:r}){var h,C;e.uploadResource=r.uploadResource.bind(r),e.buildResourceUrl=r.buildResourceUrl.bind(r);const i=n.getComponentOptions("comment"),s={image:{defaultAlign:"left"},table:{locatingContainer:t,hideCellMenu:!0,hideToolbar:!0},...i==null?void 0:i.componentsOptions},o=[];n.editorBlocks.forEach(E=>{E.blockType==="text"||E.blockType==="embed"||o.push(E)});const l=[];n.editorEmbeds.forEach(E=>{l.push(E)});const c=[];n.editorBoxes.forEach(E=>{E.boxType==="text"||E.boxType==="br"||E.boxType==="image"||E.boxType==="anchor"||c.push(E)});const d=Zf(t,e,{shortcuts:[nm],components:{blocks:o,commandProviders:[new Mm],decorators:[new og],embeds:l,boxes:c,options:s}});if(d.input.addHandler(new ag),d.input.addHandler(new UA(d)),d.input.addHandler(new VA(d)),d.input.addHandler(new Eq(d)),d.input.addHandler(new dg),d.addCustom("image-paste-handler",()=>new MA(d)),Ae.isMobile||d.addCustom("editor-tooltip",()=>new Sd(d)),n.options.enableContextMenu!==!1&&d.addCustom("editor-context-menu",E=>new jA(E)),(h=n.options.componentsOptions)!=null&&h.mention){const E=n.options.componentsOptions.mention;d.addCustom("mention",()=>new eS(d,{...E}))}if((C=n.options.componentsOptions)!=null&&C.comment){const E=n.options.componentsOptions.comment;E.onCommentEditorClick&&d.addListener("click",E.onCommentEditorClick)}return d}function pZ(n,t){const e=Array.from(n.rootContainer.querySelectorAll(`[comment-${t.toLocaleLowerCase()}="${t}"]`)),r=new Set;e.forEach(i=>{const s=nt(i);s&&r.add(s)}),r.forEach(i=>{Aq(n,i,t)})}class CZ{constructor(t){m(this,"listeners",new Set);m(this,"doc");this.editor=t,this.doc=this.editor.doc.externalDoc,this.doc.registerCallback(this)}getComments(){return this.doc.getComments()}getComment(t){return this.doc.getComment(t)}getCommentDoc(t){return this.doc.getCommentDoc(t)}localCreateComment(t,e){this.doc.localCreateComment(t,e)}localDeleteComment(t){const e=this.getComment(t);this.doc.localDeleteComment(t);const r=e.groupId;this.getComments().filter(s=>s.groupId===r).length===0&&pZ(this.editor,r)}localUpdateComment(t,e){this.doc.localUpdateComment(t,e)}onCreateComment(t,e){Array.from(this.listeners.values()).forEach(r=>r.onCreateComment(t,e))}onDeleteComment(t,e){Array.from(this.listeners.values()).forEach(r=>r.onDeleteComment(t,e))}onUpdateComment(t,e){Array.from(this.listeners.values()).forEach(r=>r.onUpdateComment(t,e))}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}createCommentEditor(t,e){return OS(this.editor,{root:t,childDoc:e,doc:this.doc})}allowEdit(t){return t.userId===this.doc.getUser().userId}}class EZ{constructor(t,e){m(this,"listeners",new Set);this.editor=t,this.localDoc=e}get doc(){return this.localDoc.toJSON()}getComments(){return Object.values(this.doc.comments)}getComment(t){return this.doc.comments[t]}getCommentDoc(t){const e=this.doc.comments[t];return FC(e)}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}localCreateComment(t,e){}localDeleteComment(t){}localUpdateComment(t,e){}createCommentEditor(t,e){return OS(this.editor,{root:t,childDoc:e,doc:this.localDoc})}allowEdit(t){return t.userId===this.localDoc.getUser().userId}}const AZ={placeholder:{common:{title:"\u8BF7\u8F93\u5165\u6807\u9898",readonlyTitle:"\u8BF7\u8F93\u5165\u6807\u9898",content:"\u70B9\u51FB + \uFF0C\u6216\u8F93\u5165 / \u5FEB\u6377\u63D2\u5165\u7EC4\u4EF6",contentInTable:"\u8F93\u5165 / \u5FEB\u6377\u63D2\u5165\u7EC4\u4EF6"},local:{readonlyTitle:"\u672A\u547D\u540D"}},copyCutProperty:{copy:"\u590D\u5236",cut:"\u526A\u5207",unsafeEnvTips:"\u7531\u4E8E\u5F53\u524D http \u8BBF\u95EE\u73AF\u5883\u4E0B\u7684\u9650\u5236\uFF0C\u8BF7\u4F7F\u7528\u5FEB\u6377\u952E({shortCut}) {operation}",limitedEnvTips:"\u7531\u4E8E\u6D4F\u89C8\u5668\u9650\u5236\uFF0C\u8BF7\u4F7F\u7528 {shortCut} \u7C98\u8D34"}},xZ={placeholder:{common:{title:"Enter a title",readonlyTitle:"Enter a title",content:'Click "+", or enter "/" to insert components quickly',contentInTable:'Enter "/" to insert components quickly'},local:{readonlyTitle:"Untitled"}},copyCutProperty:{copy:"Copy",cut:"Cut",unsafeEnvTips:"Due to the limitations of the current http access environment, please use the shortcut ({shortCut}) {operation}",limitedEnvTips:"Press {shortCut} to paste due to browser restrictions"}},bZ={placeholder:{common:{title:"\u30BF\u30A4\u30C8\u30EB\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",readonlyTitle:"\u30BF\u30A4\u30C8\u30EB\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",content:"\u300C+\u300D\u3092\u30AF\u30EA\u30C3\u30AF\u3059\u308B\u304B\u3001\u300C/\u300D\u3092\u5165\u529B\u3059\u308B\u3068\u3001\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u304C\u7D20\u65E9\u304F\u633F\u5165\u3067\u304D\u307E\u3059",contentInTable:"\u300C/\u300D\u3092\u5165\u529B\u3059\u308B\u3068\u3001\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u304C\u7D20\u65E9\u304F\u633F\u5165\u3067\u304D\u307E\u3059"},local:{readonlyTitle:"\u7121\u984C"}},copyCutProperty:{copy:"\u8907\u88FD",cut:"\u5207\u308B",unsafeEnvTips:"HTTP\u74B0\u5883\u306E\u5236\u7D04\u306B\u3088\u308A\u3001{operation}\u3059\u308B\u306B\u306F\u3001\u30B7\u30E7\u30FC\u30C8\u30AB\u30C3\u30C8({shortCut}) \u3092\u3054\u4F7F\u7528\u304F\u3060\u3055\u3044",limitedEnvTips:"\u30D6\u30E9\u30A6\u30B6\u30FC\u306E\u5236\u9650\u306B\u3088\u308A\u3001\u300C{shortCut}\u300D\u3092\u4F7F\u7528\u3057\u3066\u8CBC\u308A\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044"}};_.mergeLang({"zh-CN":AZ,"en-US":xZ,"ja-JP":bZ});const vZ="UEsDBBQABgAIAAAAIQBk9WPugQEAACkGAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0lMtqwzAQR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MAABAAAAAAAAAAAAAAAAAA/DMAAGRvY1Byb3BzL2FwcC54bWxQSwECLQAUAAYACAAAACEAiD+lv+EAAABVAQAAGAAAAAAAAAAAAAAAAAAHNwAAY3VzdG9tWG1sL2l0ZW1Qcm9wczEueG1sUEsBAi0AFAAGAAgAAAAhAMEnywi2AAAAIQEAABMAAAAAAAAAAAAAAAAARjgAAGN1c3RvbVhtbC9pdGVtMS54bWxQSwECLQAUAAYACAAAACEAdD85esIAAAAoAQAAHgAAAAAAAAAAAAAAAABVOQAAY3VzdG9tWG1sL19yZWxzL2l0ZW0xLnhtbC5yZWxzUEsBAi0AFAAGAAgAAAAhAOuAYExTAwAAjw4AABIAAAAAAAAAAAAAAAAAWzsAAHdvcmQvZm9udFRhYmxlLnhtbFBLBQYAAAAADwAPANQDAADePgAAAAA=",BZ=()=>Pp(vZ),TZ=D("image-to-docx");async function yZ(n){return new Promise((t,e)=>{const r=new Image;r.onload=()=>{t({width:r.naturalWidth,height:r.naturalHeight})},r.onerror=e,r.src=n})}async function NS(n,t){if(n.width&&n.height)return{width:n.width,height:n.height,buffer:t};try{const e=await Dc(new File([t],"",{})),r=await yZ(e);return r.width===void 0||r.height===void 0?{width:345,height:230,buffer:t}:n.width||n.height?{width:n.width||r.width*n.height/r.height,height:n.height||r.height*n.width/r.width,buffer:t}:{width:r.width,height:r.height,buffer:t}}catch(e){TZ.error(e);return}}function kZ(n,t){let e=n.filter(o=>o!=null);const r=t-(e.length-1)*20,i=.87,s=e.reduce((o,l)=>o+l.width,0);return s>r&&(e=e.map(o=>({width:o.width*r/s,height:o.height*r/s,buffer:o.buffer}))),e.map(o=>({width:o.width*i,height:o.height*i,buffer:o.buffer}))}function RZ(n,t,e){if(!e||typeof e!="object")return;const r=e,i=n.filter(o=>o!=null),s=t-(i.length-1)*20;i.forEach((o,l)=>{if(i.length===1&&r.widthPercent){const d=r.widthPercent,h=o.width;o.width=s*(d/100),o.height*=o.width/h;return}const c=`${l}_flex`;if(r[c]){const d=r[c],h=o.width;o.width=s*d,o.height*=o.width/h}})}function PS(n=[0,1,2,3,4,5,6,7],t=1){return n.map(e=>{let r;switch(e%3){case 0:r=Bt.LevelFormat.DECIMAL;break;case 1:r=Bt.LevelFormat.LOWER_LETTER;break;default:r=Bt.LevelFormat.LOWER_ROMAN;break}return{level:e,format:r,text:`%${e+1}. `,alignment:Bt.AlignmentType.START,start:t,style:{paragraph:{indent:{left:Bt.convertInchesToTwip(.3*(e+1)),hanging:Bt.convertInchesToTwip(.2)}}}}})}function wZ(){return[0,1,2,3,4,5,6,7].map(n=>{let t;switch(n%3){case 0:t="\u2022";break;case 1:t="\u25E6";break;default:t="\u25AA";break}return{level:n,format:Bt.LevelFormat.BULLET,text:t,alignment:Bt.AlignmentType.START,style:{paragraph:{indent:{left:Bt.convertInchesToTwip(.3*(n+1)),hanging:Bt.convertInchesToTwip(.2)}}}}})}function SZ(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:Bt.LevelFormat.BULLET,text:"\u2611",alignment:Bt.AlignmentType.START,style:{paragraph:{indent:{left:Bt.convertInchesToTwip(.3*(n+1)),hanging:Bt.convertInchesToTwip(.2)}}}}))}function LZ(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:Bt.LevelFormat.BULLET,text:"\u2610",alignment:Bt.AlignmentType.START,style:{paragraph:{indent:{left:Bt.convertInchesToTwip(.3*(n+1)),hanging:Bt.convertInchesToTwip(.2)}}}}))}var oh=(n=>(n.NUMBERING="number-numbering-reference",n.BULLET="number-bullet-reference",n.CHECKED="checked-bullet-reference",n.UNCHECKED="unchecked-bullet-reference",n))(oh||{});const IZ=[{levels:PS(),reference:"number-numbering-reference"},{levels:wZ(),reference:"number-bullet-reference"},{levels:SZ(),reference:"checked-bullet-reference"},{levels:LZ(),reference:"unchecked-bullet-reference"}];function DZ(n){switch(n){case"style-color-0":return"d83931";case"style-color-1":return"de7802";case"style-color-2":return"dc9b04";case"style-color-3":return"2ea121";case"style-color-4":return"245bdb";case"style-color-5":return"6425d0";case"style-color-6":return"8f959e";default:return}}function _Z(n){switch(n){case"style-bg-color-1":case"style-bg-color-2":case"style-bg-color-8":case"style-bg-color-9":return"yellow";case"style-bg-color-0":case"style-bg-color-5":return"magenta";case"style-bg-color-3":return"green";case"style-bg-color-4":case"style-bg-color-11":return"blue";case"style-bg-color-6":return"lightGray";case"style-bg-color-7":return"red";case"style-bg-color-10":return"darkGreen";case"style-bg-color-12":return"darkMagenta";case"style-bg-color-13":return"darkGray";default:return}}function MZ(n){switch(n){case"style-bg-color-0":return"fbbab6";case"style-bg-color-1":return"ffdcb0";case"style-bg-color-2":return"fff7a0";case"style-bg-color-3":return"ceefc5";case"style-bg-color-4":return"d1ddfb";case"style-bg-color-5":return"d9cbf8";case"style-bg-color-6":return"eaeaea";case"style-bg-color-7":return"fe837c";case"style-bg-color-8":return"ffbd6a";case"style-bg-color-9":return"ffe662";case"style-bg-color-10":return"a8f393";case"style-bg-color-11":return"98b5ff";case"style-bg-color-12":return"b394f8";case"style-bg-color-13":return"b1b1b1";default:return}}const UZ=/rgb\((\d+),\s*(\d+),\s*(\d+)\)/;function FS(n){if(typeof n=="string"&&n.length>0){if(n[0]==="#")return n.substring(1);const t=n.match(UZ);if(t){const e=o=>{let l=Number(o).toString(16);return l.length<2&&(l=`0${l}`),l},r=e(t[1]),i=e(t[2]),s=e(t[3]);return`${r}${i}${s}`}if(n==="red")return"FF0000";if(n==="green")return"00FF00";if(n==="blue")return"0000FF"}}function _n(n,t){if(n&&n.attributes&&n.attributes[t])return n.attributes[t];if(n&&n.attributes&&n.attributes.box&&n.attributes.inputType&&t==="style-underline")return!0}function KS(n,t,e){for(let r=0;r<=e;++r){const i=`${t}${r}`;if(_n(n,i))return i}}function Ug(n,t,e){n.attributes=n.attributes||{},n.attributes[t]=e}function yx(n){return n==="image"||n==="drawio"||n==="plantuml"||n==="mermaid"||n==="flowchart"}function VS(n){return n&&n.startsWith("//")?`https:${n}`:n&&!n.startsWith("http://")&&!n.startsWith("https://")?`https://${n}`:n}function OZ(n){const t=_n(n,"inlineStyle");if(t==null)return;const e=t.split(";");for(const r of e){const i=r.split(":");if(i.length!==2)continue;const s=i[0].trim().toLowerCase(),o=i[1].trim().toLowerCase();s==="font-size"&&Ug(n,"inline-style-font-size",o),s==="color"&&Ug(n,"inline-style-color",o),s==="background-color"&&Ug(n,"inline-style-background-color",o),s==="font-family"&&Ug(n,"inline-style-font-family",o)}}function NZ(n,t){if(t==null)return n==null?void 0:n.normal;if(n)return n[`heading${t}`]}function PZ(n){const t=`${_n(n,"inline-style-font-size")}`;if(t&&t.indexOf("px")>0)return+t.replace(/px/g,"")}function FZ(n){if(n.attributes&&n.attributes.box&&n.attributes.text)return` ${n.attributes.text} `;if(n.attributes&&n.attributes.box&&n.attributes.inputType)return n.attributes.value?`${n.attributes.value}`:" "}function KZ(n){if(n.attributes&&n.attributes.box&&n.attributes.text)return` @${n.attributes.text} `}function VZ(n){return _n(n,"inline-style-font-family")}function $Z(n){const t=_n(n,"inline-style-background-color");return FS(t)}function HZ(n){const t=_n(n,"inline-style-color");return FS(t)}function jZ(n){OZ(n);const t=_n(n,"type")==="mention";return{box:n.attributes&&n.attributes.box?n.attributes:void 0,inlineCode:!!_n(n,"style-code"),link:VS(_n(n,"link")),size:PZ(n),text:t?KZ(n):FZ(n)||n.insert,bold:!!_n(n,"style-bold"),underline:!!_n(n,"style-underline"),italics:!!_n(n,"style-italic"),strike:!!_n(n,"style-strikethrough"),superScript:!!_n(n,"style-super"),subScript:!!_n(n,"style-sub"),math:_n(n,"type")==="math"?_n(n,"src"):void 0,mention:t,fontFamily:VZ(n),background:$Z(n),color:t?"338fe5":DZ(KS(n,"style-color-",6))||HZ(n),highlight:KS(n,"style-bg-color-",13)}}function zZ(){return[new Bt.Paragraph({border:{top:{color:"auto",style:Bt.BorderStyle.DASHED,size:4,space:1}},spacing:{before:300}}),new Bt.Paragraph({spacing:{line:0}})]}function GZ(){return new Bt.Paragraph({children:[new Bt.TextRun({text:"[\u89C6\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:Bt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function WZ(){return new Bt.Paragraph({children:[new Bt.TextRun({text:"[\u97F3\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:Bt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function qZ(n,t){return new Bt.Paragraph({children:[new Bt.ExternalHyperlink({children:[new Bt.TextRun({style:"Hyperlink",text:t||n})],link:n})]})}function $S(n){if(n.heading!=null)return`Heading${n.heading}`}function HS(n){if(n.alignment!=null){if(n.alignment==="center")return Bt.AlignmentType.CENTER;if(n.alignment==="right")return Bt.AlignmentType.RIGHT;if(n.alignment==="left")return Bt.AlignmentType.LEFT}}function XZ(n){if(n.indent)return{left:Bt.convertInchesToTwip(.3*n.indent-.2)};if(n.padding)return{left:Bt.convertInchesToTwip(.3*n.padding)}}function YZ(n){return{type:Bt.ShadingType.CLEAR,color:"FFFFFF",fill:n}}function QZ(n){const t=n.split(",");if(t.length!==0)return t[0].trim()}function jS(n,t){let e;e=n.inlineCode?"InlineCode":void 0,e=n.link?"Hyperlink":e;const r=n.size||t,i=r!=null?Math.floor(r*1.5+.5):void 0;return new Bt.TextRun({text:n.text,bold:n.bold||void 0,underline:n.underline?{type:Bt.UnderlineType.SINGLE}:void 0,italics:n.italics||void 0,strike:n.strike||void 0,superScript:n.superScript||void 0,subScript:n.subScript||void 0,size:i,style:e,font:n.fontFamily?QZ(n.fontFamily):void 0,shading:n.background?YZ(n.background):void 0,color:n.color,highlight:_Z(n.highlight)})}function JZ(n,t){if(n.link)return new Bt.ExternalHyperlink({children:[jS(n,t)],link:n.link})}async function zS(n,t,e,r,i){const[s]=await i(n,t,e);if(s==null)return;const o=await NS({width:r||0,height:0,src:e},s);return new Bt.ImageRun({data:s,transformation:{width:(o==null?void 0:o.width)||100,height:(o==null?void 0:o.height)||20}})}function ZZ(n){if(n.heading||n.heading)return n.heading}function ttt(n){if(n.align&&(n.align==="center"||n.align==="right"||n.align==="left"))return n.align}function ett(n){if(n.textOnly===!0&&n.level!=null)return n.level}async function ntt(n,t){var r;const e=[];if(n.text&&Array.isArray(n.text)){for(let i=0;i<n.text.length;i++){const s=n.text[i];if(((r=s.attributes)==null?void 0:r.box)===!0&&t){const o=await t(s);if(o){n.text.splice(i+1,0,...o);continue}}e.push(jZ(s))}return e}}function rtt(n){if(n.type==="list"&&n.textOnly!==!0)return{checkbox:n.checkbox,groupId:n.groupId,ordered:!!n.ordered,level:n.level||1,start:n.start||0}}function itt(n,t){if(n.type==="embed"&&n.embedType&&yx(n.embedType)&&n.embedData&&n.embedData.src)return n.embedData.src.split("|").map(r=>{const i=t(r),s=n.embedData[`${i}_width`],o=n.embedData[`${i}_height`];return{src:r,width:s,height:o}})}function stt(n){if(n.padding)return n.padding}function ott(n){return!!(n.type==="embed"&&n.embedType&&yx(n.embedType)&&n.embedData&&n.embedData.src)}async function Og(n,t,e){return{quoted:!!n.quoted,heading:ZZ(n),alignment:ttt(n),indent:ett(n),padding:stt(n),texts:await ntt(n,e),list:rtt(n),images:itt(n,t),border:ott(n)}}async function ltt(n,t,e,r){const i=[];if(!n.children)return[];for(const s of n.children){const o=[];for(const l of t.blocks[s])o.push(await Og(l,e,r));i.push(o)}return i}const att=D("to-docx");function ctt(n,t){return Array(n).fill(0).map(()=>Array(t).fill(0).map(()=>({cellId:void 0,color:void 0,from:void 0,rowSpan:1,colSpan:1,width:0,originalWidth:void 0,align:void 0})))}function utt(n,t,e,r){const i=!!n.hasColTitle,s=!!n.hasRowTitle,o=!!n.isStripeStyle,l="F5F8FB";for(let c=0;c<t;c++)for(let d=0;d<e;d++)(i&&d===0||s&&c===0||o&&c%2===1)&&(r[c][d].color=l)}function ftt(n){p(att,n.children,"no table children");const t=n.rows,e=n.cols,r=n.colsWidth;if(r)for(let o=0;o<r.length;o++)r[o]===0&&(r[o]=100);const i=ctt(t,e);let s=0;for(let o=0;o<t;++o)for(let l=0;l<e;++l){if(i[o][l].originalWidth=r?r[l]:void 0,i[o][l].from!==void 0)continue;const c=n.children[s];s+=1,i[o][l].cellId=c,i[o][l].color=MZ(n[`${c}_background`]),i[o][l].width=r?r[l]:100,i[o][l].align=n[`${c}_align`];const d=n[`${c}_rowSpan`]||1,h=n[`${c}_colSpan`]||1;if(i[o][l].rowSpan=d,i[o][l].colSpan=h,d>1||h>1){let C=0;for(let E=0;E<d;E++)for(let A=0;A<h;A++)E===0&&(C+=r?r[l+A]:80),!(E===0&&A===0)&&(i[o+E][l+A].from=[o,l]);i[o][l].width=C}}return utt(n,t,e,i),i}async function dtt(n,t,e,r,i,s,o,l,c,d){async function h(E){if(l&&E.type!=="_exportVirtualBlock"){const A=await l(i,s,E);if(A){await r.addDoc(n,A,d);return}}if(E.type==="text"||E.textOnly===!0){const A=await Og(E,o,c);await r.addTextBlock(A);return}if(E.type==="code"){const A=await ltt(E,e,o,c);await r.addCodeBlockObject(A);return}if(E.type==="list"&&E.textOnly!==!0){const A=await Og(E,o,c);await r.addListBlockObject(n,A);return}if(E.type==="embed"&&E.embedType){const A=E,v=A.embedData,R=A.embedType;if(yx(R)){const S=await Og(E,o,c);await r.addImagesBlockObject(E,S,d)}else E.embedType==="hr"?r.addSeparatorBlock():E.embedType==="video"?r.addVideoPlaceholder():E.embedType==="audio"?r.addAudioPlaceholder():E.embedType==="webpage"?r.addHyperlinkParagraph(VS(v.src),v.title):r.addOtherEmbedBlock(R,E.embedData);return}if(E.type==="table"){let A=[];if(E.colsWidth)A=E.colsWidth;else{const R=E.cols;A=new Array(R);for(let S=0;S<A.length;S++)A[S]=100;E.colsWidth=A}const v=ftt(E);await r.addTableMatrix(A,v,e),r.addEmptyParagraph()}E.type==="_exportVirtualBlock"&&await r.addVirtualBlock(E.id,e,d)}function C(E){var R;const A=((R=E==null?void 0:E.embedData)==null?void 0:R.exportSpec)||(E==null?void 0:E.exportSpec);if(!A)return[E];const v=[];for(const{type:S,data:O}of A){if(S==="text"){const M={id:it(),text:[{insert:O}],type:"text"};v.push(M);continue}if(S==="image"){const M={id:it(),type:"embed",embedType:"image",align:"left",embedData:{src:O}};v.push(M);continue}if(S==="link"){const M={id:it(),type:"embed",embedType:"webpage",embedData:{src:O.url,title:O.title}};v.push(M);continue}if(S==="block")for(const M of O){if(!e.blocks[M])continue;const J={id:M,type:"_exportVirtualBlock"};v.push(J)}}return v}for(const E of t)for(const A of C(E))!A||await h(A)}function htt(){return{listMaxInst:1,listInstMap:{},listRefMap:{},levelConfigs:[]}}const mtt=D("to-docx");class gtt{constructor(t,e,r,i,s,o){m(this,"paragraphs");this.appId=t,this.docId=e,this.state=r,this.readImageFunc=i,this.convertBlocksFunc=s,this.defaultFontSize=o,this.paragraphs=[]}async addTextBlock(t){this.paragraphs.push(new Bt.Paragraph({heading:$S(t),alignment:HS(t),children:await this.paragraphsFromBlockTexts(t),indent:XZ(t)}))}async addEmptyImagePlaceHolder(){this.paragraphs.push(new Bt.Paragraph({text:`[${_.t("docx.imageExportFailed")}]`,shading:{type:Bt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}}))}async paragraphsFromBlockTexts(t){if(t.texts==null)return;const e=NZ(this.defaultFontSize,t.heading),r=[];for(const i of t.texts){if(i.link){const s=JZ(i,e);s&&r.push(s);continue}if(i.box&&i.box.type&&i.box.type==="br"){r.push(new Bt.TextRun({text:"",break:1}));continue}if(i.box&&i.box.type&&i.box.type==="image"){const s=await zS(this.appId,this.docId,i.box.src,i.box.width,this.readImageFunc);s&&r.push(s);continue}if(i.math){const s=await zS(this.appId,this.docId,i.math,0,this.readImageFunc);s&&r.push(s);continue}r.push(jS(i,e))}return r}async addCodeBlockObject(t){for(const e of t)for(const r of e){const i={style:Bt.BorderStyle.SINGLE,color:"#DEDEDE"};this.paragraphs.push(new Bt.Paragraph({style:"Code",border:{left:{...i},right:{...i},top:{...i},bottom:{...i}},children:await this.paragraphsFromBlockTexts(r)}))}}async addListBlockObject(t,e){if(e.list==null)return;let r;const i=e.list.checkbox?`${t}-${e.list.groupId}-${e.list.checkbox}`:`${t}-${e.list.groupId}`;if(this.state.listInstMap[i])r=this.state.listInstMap[i];else if(r=this.state.listMaxInst,this.state.listMaxInst+=1,this.state.listInstMap[i]=r,e.list.start>0&&e.list.ordered){const o=`number-numbering-reference-${r}`,l=PS([e.list.level-1],e.list.start);this.state.levelConfigs.push({levels:l,reference:o,inst:r}),this.state.listRefMap[i]=o}else e.list.ordered?this.state.listRefMap[i]=oh.NUMBERING:e.list.checkbox&&e.list.checkbox==="checked"?this.state.listRefMap[i]=oh.CHECKED:e.list.checkbox&&e.list.checkbox==="unchecked"?this.state.listRefMap[i]=oh.UNCHECKED:this.state.listRefMap[i]=oh.BULLET;const s=$S(e);e.texts&&this.paragraphs.push(new Bt.Paragraph({heading:s,children:await this.paragraphsFromBlockTexts(e),numbering:{reference:this.state.listRefMap[i],level:e.list.level-1,instance:r}}))}imageDimWithBufferToImageRun(t){return new Bt.ImageRun({data:t.buffer,transformation:{width:t.width,height:t.height}})}async addImagesBlockObject(t,e,r){if(e.images==null){if(t.type==="embed"&&t.embedType==="image"){const{src:c}=t.embedData;c||this.addEmptyImagePlaceHolder()}return}const i=[],s=await Promise.all(e.images.map(async c=>{const[d,h]=await this.readImageFunc(this.appId,this.docId,c.src);if(d){const C=await NS(c,d);if(C)return C}i.push(h)}));RZ(s,r,t.embedData);const o=kZ(s,r),l={style:Bt.BorderStyle.SINGLE,color:"#DEDEDE"};o.length&&this.paragraphs.push(new Bt.Paragraph({border:e.border?{left:{...l},right:{...l},top:{...l},bottom:{...l}}:void 0,alignment:HS(e)||Bt.AlignmentType.CENTER,children:o.map(c=>this.imageDimWithBufferToImageRun(c)).flatMap((c,d,h)=>c==null?[]:h.length-1!==d?[c,new Bt.TextRun({text:" "})]:c)})),i.forEach(c=>{this.addHyperlinkParagraph(c)})}addSeparatorBlock(){zZ().forEach(t=>this.paragraphs.push(t))}addEmptyParagraph(){this.paragraphs.push(new Bt.Paragraph(""))}addVideoPlaceholder(){this.paragraphs.push(GZ())}addAudioPlaceholder(){this.paragraphs.push(WZ())}addHyperlinkParagraph(t,e){t!=null&&this.paragraphs.push(qZ(t,e))}async addTableMatrix(t,e,r){const i=t.map(s=>s!==0?s*15:1500);this.paragraphs.push(new Bt.Table({rows:await this.generateTableRows(e,r),columnWidths:i}))}async generateRowCells(t,e){const r=[];for(const i of t){const s=i.cellId;if(s===void 0)continue;const o=i.width*.9;r.push(new Bt.TableCell({children:await this.convertBlocksFunc(s,e.blocks[s],e,this.appId,this.docId,this.state,o),columnSpan:i.colSpan,rowSpan:i.rowSpan,width:{type:Bt.WidthType.DXA,size:i.width*15},shading:i.color?{fill:i.color,type:Bt.ShadingType.CLEAR,color:"auto"}:void 0}))}return r}async generateTableRows(t,e){const r=[];for(const i of t)r.push(new Bt.TableRow({children:await this.generateRowCells(i,e)}));return r}async addDoc(t,e,r){const i=await this.convertBlocksFunc(t,e.blocks.root,e,this.appId,this.docId,this.state,r);i&&(this.paragraphs=this.paragraphs.concat(i))}async addVirtualBlock(t,e,r){const i=await this.convertBlocksFunc(t,e.blocks[t],e,this.appId,this.docId,this.state,r);this.paragraphs.push(...i)}async addOtherEmbedBlock(){}}class ptt{constructor(t,e,r,i,s,o,l,c){m(this,"convertBlocks",async(t,e,r,i,s,o,l=720)=>{const c=new gtt(i,s,o,this.readImage,this.convertBlocks,this.defaultFontSize);return await dtt(t,e,r,c,i,s,this.md5HexFunc,this.getDocByBlock,this.getTextsByBox,l||720),c.paragraphs});this.templateData=t,this.docData=e,this.md5HexFunc=r,this.readImage=i,this.defaultFontSize=s,this.getDocByBlock=o,this.getTextsByBox=l,this.backgroundImageOptions=c}async convert(t,e){return this.snapshot2docx(this.docData,t,e)}async snapshot2docx(t,e,r){const i=new Bt.ImportDotx,s=this.templateData?await i.extract(this.templateData):void 0,o=t.blocks.root;p(mtt,o,"data must have blocks");const l=htt(),c=await this.convertBlocks("blocks",o,t,e,r,l),d=this.backgroundImageOptions?{default:new Bt.Header({children:[new Bt.Paragraph({children:[new Bt.ImageRun(this.backgroundImageOptions)]})]})}:{},h=new Bt.Document({numbering:{config:[...IZ,...l.levelConfigs]},sections:[{headers:d,children:c,properties:{page:{size:{width:12240,height:15840},margin:{top:1440,bottom:1440,left:1440,right:1440}}}}]},{template:s});return Bt.Packer.toBlob(h)}}async function Ctt(n,t,e,r){const i=n.doc.buildResourceUrl(r,{withToken:!0});let s=await cS(i);if(!s)return[void 0,i];if(s.type.indexOf("/svg")!==-1){const l=await oS(s);l&&(s=new File([l],s.name))}return[await s.arrayBuffer(),i]}async function Ett(n,t,e){const r=n.editorBlocks.getBlockClass(e.type);if(r.toStandardDoc)return r.toStandardDoc(n,e,t)}async function Att(n,t){const e=t.attributes,r=n.editorBoxes.getBoxClass(e.type);if(r.toStandardText)return r.toStandardText(n,e)}async function xtt(n,t){let{template:e,download:r,backgroundImageOptions:i}=t!=null?t:{};e||(e=BZ());const s=n.doc.toJSON(),o=(C,E,A)=>Ctt(n,C,E,A),l=async(C,E,A)=>Ett(n,s,A),c=async C=>Att(n,C),h=await new ptt(e,s,t0.default,o,void 0,l,c,i).convert("_appId","_docId");if(r){const C=URL.createObjectURL(h),E=document.createElement("a");E.setAttribute("download",`${aS(n)}.docx`),E.setAttribute("href",`${C}`),E.click(),E.remove()}return h}const kx=D("create-editor");async function btt(n,t){var o,l,c,d,h,C,E,A,v,R,S,O,M,V,J,Q;p(kx,n,"app does not exists"),t.lang&&_.setLang(t.lang),di.level=(o=t.logLevel)!=null?o:Wo.DEBUG;const e=t.onReauth?async()=>{var bt;const X=t.user.userId,ct=t.docId,xt=await((bt=t.onReauth)==null?void 0:bt.call(t,X,ct,t.permission));return{userId:X,docId:ct,permission:t.permission,appId:t.appId,token:xt,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl}}:void 0,r={auth:{appId:t.appId,docId:t.docId,userId:t.user.userId,permission:t.permission,token:t.token,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl},serverUrl:t.serverUrl,reauthFunc:e,disableLogout:t.disableLogout},i=await hd.load(r),s=Zf(n,i,{id:t.id,scrollContainer:t==null?void 0:t.scrollContainer,enableComments:t==null?void 0:t.enableComments,enableContextMenu:t==null?void 0:t.enableContextMenu,components:{blocks:[..._S,...((l=t==null?void 0:t.components)==null?void 0:l.blocks)||[]],embeds:[...Tx,...((c=t.components)==null?void 0:c.embeds)||[]],boxes:[...MS,...((d=t.components)==null?void 0:d.boxes)||[]],commandProviders:[new Mm,...((h=t.components)==null?void 0:h.commandProviders)||[]],decorators:[new og,new VC],insertions:[K1],blockHooks:[new SA,new tw,...((C=t.components)==null?void 0:C.blockHooks)||[]],textRenders:[new C4,new $E,...((E=t.components)==null?void 0:E.textRenders)||[]],options:{...t.componentsOptions}},shortcuts:[Lq,sH,Cz,aA,Hw,fF,nA,mX,nm,iF,...t.shortcuts||[]],colors:["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"]});if(s.editorCommandProviders.registerCommandProvider(new hs(s)),s.input.addHandler(new rY),s.input.addHandler(new ag),s.input.addHandler(new LK),s.input.addHandler(new cz),s.input.addHandler(new CA(s,{hideTitle:t.hideTitle,headingLevel:1,titlePlaceholder:_.t("placeholder.common.title"),contentPlaceholder:_.t("placeholder.common.content"),readonlyTitlePlaceholder:_.t("placeholder.common.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0,applyContentPlaceholder:(A=t.placeholder)==null?void 0:A.applyContentPlaceholder})),s.input.addHandler(new tg(s,(v=t.componentsOptions)==null?void 0:v.quickMenu)),s.input.addHandler(new UA(s)),s.input.addHandler(new VA(s)),s.input.addHandler(new dg),s.doc.registerCallback(new iY(s)),s.addCustom("remote-cursor",()=>new sy(s)),s.addCustom("block-menu",X=>new rw(X)),Ae.isMobile||s.addCustom("editor-tooltip",()=>new Sd(s)),t!=null&&t.enableComments&&s.addCustom("editor-comments",X=>new p4(X,new CZ(X))),t.enableContextMenu!==!1&&s.addCustom("editor-context-menu",X=>new jA(X)),s.addCustom("create-options",()=>new Sb(s,t)),s.addCustom("drop-target",()=>new Wd(s)),s.addCustom("list-to-mindmap",()=>new Wm(s)),s.addCustom("list-to-mention",()=>new yY(s)),s.addCustom("mobile-helper",()=>new WY(s)),s.addCustom("code-caret",()=>new eH(s)),s.addCustom("image-paste-handler",()=>new MA(s)),(R=t.componentsOptions)!=null&&R.mention){const X=t.componentsOptions.mention;s.addCustom("mention",()=>new eS(s,X))}if(s.addCustom("heading-collapse",()=>new ax(s)),s.addCustom(_g,X=>new gx(X)),Au.register(s),Wd.register(s),wl.register(s),vl.register(s),s.addListener("clickLink",(X,ct,xt)=>{var wt;if((wt=t==null?void 0:t.events)!=null&&wt.onClickLink){t.events.onClickLink(X,ct,xt);return}const bt=xt.getAttribute("link");bt&&(X.readonly||ct.ctrlKey||ct.metaKey)&&window.open(bt,"_blank")}),(O=(S=t.componentsOptions)==null?void 0:S.remoteCarets)!=null&&O.onUserChanged){const X=(V=(M=t.componentsOptions)==null?void 0:M.remoteCarets)==null?void 0:V.onUserChanged;s.doc.getRemoteUsers().on("change",ct=>{X(s,ct)})}return(Q=(J=t.componentsOptions)==null?void 0:J.templates)!=null&&Q.templates.length&&(s.addListener("docChanged",()=>{Dg(s)}),s.addListener("resize",()=>{Dg(s,{reset:!0})}),setTimeout(()=>{Dg(s)},100)),s.doc.registerCallback({onError:async X=>{if(X.code==="ResetDoc"){kx.error(`reset doc: ${X.message}`);const ct=await hd.load(r);s.doc.reset(ct)}}}),s.version="1.1.17-beta.11",di.level===Wo.DEBUG&&(window.setReauthFail=X=>{window.isReauthError=X},window.reConnect=X=>s.doc.externalDoc.client.connection.reConnect(X)),s}function vtt(n){return n.toJSON!==void 0}async function Btt(n,t,e){var s,o,l,c,d,h,C,E;p(kx,n,"app does not exists");const r=vtt(t)?t:new AC(t,{serverUrl:e.serverUrl||""});e.lang&&_.setLang(e.lang),di.level=(s=e.logLevel)!=null?s:Wo.DEBUG;const i=Zf(n,r,{id:e.id,scrollContainer:e==null?void 0:e.scrollContainer,components:{blocks:[lA,gA,pA,kk,...(l=(o=e.components)==null?void 0:o.blocks)!=null?l:[]],commandProviders:[new Mm],decorators:[new og,new VC],embeds:[...Tx,...((c=e.components)==null?void 0:c.embeds)||[]],boxes:[Pk,nS,y4,Hk,...((d=e.components)==null?void 0:d.boxes)||[]],insertions:[K1],blockHooks:[new SA,...((h=e.components)==null?void 0:h.blockHooks)||[]],textRenders:[new C4,new $E,...((C=e.components)==null?void 0:C.textRenders)||[]],options:{...e.componentsOptions}},shortcuts:[aA,Hw,nA,nm]});return i.editorCommandProviders.registerCommandProvider(new hs(i)),i.input.addHandler(new ag),i.input.addHandler(new CA(i,{hideTitle:e.hideTitle,headingLevel:1,titlePlaceholder:_.t("placeholder.common.title"),contentPlaceholder:_.t("placeholder.common.content"),readonlyTitlePlaceholder:_.t("placeholder.local.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),i.input.addHandler(new tg(i,(E=e.componentsOptions)==null?void 0:E.quickMenu)),i.input.addHandler(new UA(i)),i.input.addHandler(new VA(i)),i.input.addHandler(new dg),i.addCustom("block-menu",A=>new rw(A)),Ae.isMobile||i.addCustom("editor-tooltip",()=>new Sd(i)),i.addCustom("image-paste-handler",()=>new MA(i)),e!=null&&e.enableComments&&i.addCustom("editor-comments",A=>new p4(A,new EZ(A,r))),e.enableContextMenu!==!1&&i.addCustom("editor-context-menu",A=>new jA(A)),i.addCustom("heading-collapse",()=>new ax(i)),i.addListener("clickLink",(A,v,R)=>{var O;if((O=e==null?void 0:e.events)!=null&&O.onClickLink){e.events.onClickLink(A,v,R);return}const S=R.getAttribute("link");S&&(A.readonly||v.ctrlKey||v.metaKey)&&window.open(S,"_blank")}),i.addCustom(_g,A=>new gx(A)),Au.register(i),i.version="1.1.17-beta.11",i}async function Ttt(n,t,e){var h;const r=n.doc.externalDoc.client.auth,i=await hm.load({auth:r,serverUrl:e});if(!((h=i.getVersionHelper)==null?void 0:h.call(i)))throw new Error("the editor does not support to show versions");const o=n.getCustom("create-options");if(!o)throw new Error("the editor does not support to show versions");const l=o.getData(),c=new US(l),d=n.addCustom("version-dialog",()=>new V4(i,c));return d.show(t),d}b.tippy=e9,b.AnchorBox=TB,b.AuthError=fd,b.AuthHeader=Ea,b.AutoScroll=C0,b.BaseURLHeader=eu,b.BasicCommands=JF,b.BlockExclusiveHook=tw,b.BlockLockerHook=SA,b.BlockLockerPasteHandler=dg,b.BlockResizer=Nd,b.BrBox=xB,b.CodeBlock=gA,b.CodeLineBlock=pA,b.CodeTextDecorator=og,b.DOC_RE_AUTH_KEYS=_g,b.DefaultShortcuts=nm,b.DocIdError=GU,b.DocReAuthCallbacks=gx,b.DragDrop=Wb,b.DrawioEmbed=vS,b.EditorBlocks=r3,b.EditorBoxes=vB,b.EditorCommandProviders=AT,b.EditorComplexBlockPosition=Ai,b.EditorComplexSelectionRange=Qi,b.EditorDecorators=wB,b.EditorEmbeds=s3,b.EditorInsertions=RB,b.EditorSimpleBlockPosition=hn,b.EditorSimpleSelectionRange=xn,b.EmbedBlock=l3,b.EmbedBlockResizer=eh,b.EnforceWithDocumentTitleHandler=CA,b.EventCallbacks=Sc,b.FILL_CHAR=p8,b.FileExtError=WU,b.GroupOrder=Lk,b.HeadingBlockScrollListener=EY,b.ImageBox=BB,b.InlineBoxCommandProvider=jk,b.InputtingInsertion=yB,b.LocalDoc=AC,b.LogLevel=Wo,b.Logger=di,b.MIN_DISTANCE_THRESHOLD=zb,b.ManualCloseDialog=gd,b.ManualMenu=fl,b.ManualToolbar=md,b.MarkdownInputHandler=ag,b.MaxUserError=DC,b.Mindmap=Gm,b.OnesEditorAutoSuggest=aE,b.OnesEditorCustomDataWrapper=Sb,b.OnesEditorExclusiveBlock=vl,b.OnesEditorHoveringBlock=He,b.OnesEditorIcons=DO,b.OnesEditorQuickMenu=tg,b.OnesEditorToc=ih,b.OnesEditorTocProvider=wl,b.OnesEditorToolbar=Au,b.OnesEditorTooltip=Sd,b.OnesEditorVersionsDialog=V4,b.PermissionError=dm,b.Popup=su,b.ReAuthToolbar=uS,b.RemoteCarets=sy,b.RemoteCaretsDecorator=VC,b.RemoteCaretsInsertion=K1,b.RemoteUsers=td,b.RequestReloadError=dd,b.RichText=$n,b.ShareDBDoc=hd,b.ShareDBDocVersionsProvider=US,b.ShareDBServer=hm,b.SimpleCache=Nb,b.StandardEmbedBlockCommands=tx,b.TEXT_STYLE_BACKGROUND_COLOR_PREFIX=A1,b.TEXT_STYLE_COLOR_PREFIX=E1,b.TableBlock=lA,b.TableBlockCommandProvider=Mm,b.TableShortcuts=aA,b.TextBlock=lr,b.TextBox=AB,b.TextColorItem=B2,b.TextStyleShortcuts=nA,b.TocEmbed=Z4,b.ZERO_WIDTH_SPACE_CHAR=xf,b.abbreviation=E0,b.addAttribute=R0,b.addClass=q,b.addCommentToBlock=th,b.addDays=uI,b.addMetaToDoc=Qf,b.addMonths=cI,b.animateScrollTo=ea,b.applyPlaceholderToBlock=Ud,b.assert=p,b.autoShowHideTemplates=Dg,b.bindKeyDownEvent=c0,b.blockToDoc=hC,b.blockToHtml=H1,b.blockToMarkdown=H0,b.blockToText=$0,b.blocksToDoc=$5,b.clearAllSelection=Nv,b.clientType=Ae,b.cloneBlock=il,b.cloneChildContainer=Z1,b.cloneDoc=tC,b.cloneText=uB,b.commentToShareDbComment=KC,b.compareElement=l0,b.comparePosition=u1,b.complexBlockAdjustSelectionPos=T0,b.complexBlockFindNearestChildBlock=a7,b.complexBlockGetAllChildContainers=Ln,b.complexBlockGetBottomChildContainers=f3,b.complexBlockGetDeepFirstChild=a3,b.complexBlockGetFirstSimpleChild=d1,b.complexBlockGetLastSimpleChild=Nc,b.complexBlockGetSelectedContainers=Oc,b.complexBlockGetTopChildContainers=u3,b.containerToDoc=H5,b.continuousScroll=cv,b.convertBlockFrom=v0,b.convertImageFileToPng=oS,b.convertImageSrcToPng=VY,b.converterIntercept=lg,b.copyBlockAttributes=KB,b.copyResourcesFromDoc=EC,b.createBlockAnchor=$s,b.createBlockCaretAnchor=h3,b.createBlockContentElement=aa,b.createBlockElement=wv,b.createBlockSimpleDocRange=N0,b.createBlockSimpleRange=Oe,b.createBoxContentElement=Iv,b.createBoxElement=Sv,b.createBoxOp=cB,b.createChildContainer=e3,b.createComplexBlockPosition=De,b.createComplexDocPos=gB,b.createComplexDocRange=A8,b.createContainer=dB,b.createContainerElement=qp,b.createDeleteOps=sB,b.createEditor=Zf,b.createEditorSelectionRange=mn,b.createElement=B,b.createEmptyContainer=qs,b.createEmptyDoc=Ws,b.createEmptyTextBlockData=U0,b.createExpandedRange=s0,b.createIconButton=Jl,b.createImage=wp,b.createInsertOps=_0,b.createInsertionContentElement=Mv,b.createInsertionElement=Dv,b.createLocalEditor=Btt,b.createOnesEditor=btt,b.createRange=Pb,b.createRichText=ma,b.createRootContainer=t3,b.createSimpleBlockPosition=ht,b.createSimpleDocPos=mB,b.createTextBlockData=es,b.createTextButton=Ra,b.createTextOp=Gr,b.createTextWithReplaceSoftReturn=I1,b.daysAfter=Hp,b.deleteText=_1,b.diffDays=fI,b.disablePageScroll=Kp,b.docToHtml=UB,b.docToHtmlFragment=jf,b.docToMarkdown=OB,b.docToText=rl,b.downloadImageToFile=cS,b.downloadObjectToFile=Ex,b.downloadSvgToString=hS,b.editLink=kd,b.editorAddComment=bq,b.editorAddTextAttribute=QB,b.editorAutoInsertBlock=VB,b.editorBreakTextBlock=Wc,b.editorClearCompositionText=W1,b.editorClearSelectedContents=q0,b.editorCopyBlock=pC,b.editorCopyDoc=em,b.editorDeleteBlock=Y1,b.editorDeleteBlockText=q1,b.editorDeleteBlockWithoutChildren=G0,b.editorDeleteChildContainer=C_,b.editorDeleteChildContainers=$B,b.editorFocusToBlock=J1,b.editorFocusToEnd=O_,b.editorGetBlockData=nl,b.editorGetBlockText=Qn,b.editorGetBlockTextEx=F0,b.editorGetBoxData=CB,b.editorHandleKeyboardEvent=eT,b.editorInsertBlock=Gc,b.editorInsertBoxToBlock=PB,b.editorInsertDoc=XB,b.editorInsertDocAt=eC,b.editorInsertText=G1,b.editorInsertTextToBlock=NB,b.editorInsertTextToBlockEx=z1,b.editorMergeTextBlock=HB,b.editorMoveDown=u5,b.editorMoveEnd=aC,b.editorMoveHome=x5,b.editorMoveLeft=l5,b.editorMoveLineEnd=w5,b.editorMoveLineHome=R5,b.editorMovePageDown=M5,b.editorMovePageUp=_5,b.editorMoveRight=a5,b.editorMoveUp=c5,b.editorMoveWordEnd=C5,b.editorMoveWordLeft=p5,b.editorRangeClearColor=ZB,b.editorRangeGetColor=t5,b.editorRangeSetColor=JB,b.editorRemoveTextAttribute=b_,b.editorReplaceBlockText=X0,b.editorReplaceContainer=YB,b.editorRunOnce=xC,b.editorSelectAll=uC,b.editorSelectContainer=J0,b.editorSelectDown=f5,b.editorSelectEnd=cC,b.editorSelectHome=b5,b.editorSelectLeft=d5,b.editorSelectLineEnd=k5,b.editorSelectLineHome=y5,b.editorSelectPageDown=N5,b.editorSelectPageUp=O5,b.editorSelectRight=h5,b.editorSelectUp=m5,b.editorSelectWordEnd=A5,b.editorSelectWordLeft=E5,b.editorSetTextColor=qc,b.editorShowFindDialog=hW,b.editorToDocx=xtt,b.editorUpdateBlockData=Y0,b.editorUpdateCompositionText=FB,b.editorUpdateEmbedData=WB,b.enablePageScroll=Vp,b.escapeHtmlText=u0,b.escapeRegExp=Wp,b.escapeSpace=G9,b.exclusiveBlock=kA,b.executeBlockCommand=Gv,b.executeEmbedBlockCommand=zv,b.executeRangeCommand=ET,b.fileToDataUrl=Dc,b.findAfterOffsetNotType=N1,b.findAllText=fC,b.findBlockByIndex=xv,b.findEventTargetBlock=Vb,b.findInsertionById=_v,b.findNextOffset=F8,b.findNextVisibleSimpleBlock=BT,b.findPrevOffset=P8,b.findPrevOffsetNotType=O1,b.findPrevSimpleBlockBeforeChildContainer=c3,b.findPrevVisibleSimpleBlock=vT,b.findTarget=Ic,b.findWordEnd=F1,b.findWordLeft=P1,b.format=kf,b.formatBytes=uv,b.formatDate=zp,b.fragmentToHtml=iv,b.fromBase64=vf,b.fromBase64ToBlob=Pp,b.fromBase64ToUint8Array=rI,b.fromDocRange=Zo,b.fromNowString=Gp,b.genId=it,b.getAllChildBlocks=p1,b.getAllQuickMenuItems=eA,b.getAllSelectedBlocks=Ji,b.getAttributesAt=Vc,b.getBlockBackground=Qp,b.getBlockByIndex=Xo,b.getBlockCaretRect=Qo,b.getBlockClass=le,b.getBlockClassByType=sa,b.getBlockClientRects=Fs,b.getBlockCommandsWithHook=i1,b.getBlockContent=jt,b.getBlockHeading=If,b.getBlockId=dt,b.getBlockIndex=Rt,b.getBlockInfo=$d,b.getBlockKind=pi,b.getBlockMinWidth=Fv,b.getBlockNearestRangeFromPoint=m1,b.getBlockOptions=TI,b.getBlockPath=Jo,b.getBlockProperties=$v,b.getBlockRangeFromPoint=y0,b.getBlockStyles=BI,b.getBlockTextLength=Ct,b.getBlockTools=xe,b.getBlockType=Ot,b.getBoxContent=Zp,b.getBoxId=Lv,b.getBoxTypeFromElement=Lf,b.getChildBlockCount=gi,b.getChildBlocks=ye,b.getChildOffset=tl,b.getColorFromAttributes=b1,b.getColorFromContent=A0,b.getComplexBlockClass=Vr,b.getContainerBlockPath=Qv,b.getContainerBlocks=Ov,b.getContainerBlocksElement=wf,b.getContainerById=mi,b.getContainerId=pt,b.getContainerMinWidth=a1,b.getContainerToolsElement=xI,b.getContainerWidth=n3,b.getDistanceSquare=qo,b.getElementFromPoint=Me,b.getElementOffset=Af,b.getElementScale=Kr,b.getEmbedType=sn,b.getExistsBlockTools=x0,b.getExistsContainerById=Rf,b.getFileExt=yf,b.getFirstChildBlock=Ue,b.getFirstClientRect=o0,b.getHeadingBlockChildren=Uc,b.getHeadingMenuOptions=XE,b.getHorizontalPadding=Lp,b.getInsertionContent=t1,b.getLastChildBlock=Qe,b.getLastClientRect=Zl,b.getListAllNextBrothers=mu,b.getLogger=D,b.getNextBlock=ae,b.getNextHiddenBlocks=Xv,b.getNextValidOffset=da,b.getNextVisibleBlock=Hr,b.getOffsetFromPoint=Sp,b.getOffsetInfoAfter=Vf,b.getOffsetInfoBefore=K0,b.getOpAt=F3,b.getOpLength=k0,b.getParentBlock=nt,b.getParentBlockExcludeSelf=la,b.getParentBox=Jp,b.getParentContainer=at,b.getPrevBlock=Je,b.getPrevValidOffset=el,b.getPrevVisibleBlock=$r,b.getRangeCommands=pT,b.getReferenceClientRect=nk,b.getRootBlock=r1,b.getScrollContainer=dn,b.getSpecialBlockCommands=Hv,b.getStandardEmbedBlockProperties=ex,b.getTextAfterOffset=O8,b.getTextAttributes=j1,b.getTextBeforeOffset=N8,b.getTextBlockChild=Mf,b.getTextBlockClass=vv,b.getTextBlockContentChildTextLength=zr,b.getTextBlockContentChildType=Yv,b.getTextBlockContentChildren=Yi,b.getTextLength=Vn,b.getTextOpLength=C1,b.getTextWidth=m0,b.getToolbar=Km,b.handleBlockElementUpdated=Kv,b.hasAltOnly=J9,b.hasClass=Mt,b.hasCtrlOrCmd=Zb,b.hasCtrlOrCmdOnly=Q9,b.hashCode=Cv,b.hideBlock=Rv,b.hideTemplates=sS,b.htmlToFragment=h0,b.i18n=_,b.includeBigTable=aN,b.injectDocToHtmlFragment=Yf,b.injectStyle=jb,b.inputActions=nM,b.insertEmptyBlock=RI,b.insertEmptyEmbedBlock=s1,b.insertText=Gs,b.intersectionCommands=UM,b.isBackspace=ev,b.isBlock=oa,b.isBlockLocked=fg,b.isBlockLockedByOthers=wA,b.isBlockLockedBySelf=Hd,b.isBlockTools=kv,b.isBox=b0,b.isBoxOp=Hs,b.isCJK=Qb,b.isChildContainer=Ei,b.isChildNode=pe,b.isCodeBlock=Di,b.isCollapsedHeadingBlock=Xi,b.isCollapsedRange=E8,b.isComplexBlockPosition=ua,b.isComplexKindBlock=Pt,b.isContainer=Ps,b.isContainerSelectedAllChildBlocks=P5,b.isControlEvent=ra,b.isDelete=tI,b.isDraggingFiles=g0,b.isElementVisible=_p,b.isEmbedBlock=Se,b.isEmptyContainer=Uf,b.isEmptyDoc=M1,b.isEmptyTextBlock=be,b.isEmptyTextBlockWithoutCompositionText=Md,b.isEnterOnly=tv,b.isEscape=d0,b.isExclusiveBlock=Vd,b.isExpandedHeadingBlock=qv,b.isFirefox=Cf,b.isFirstChildBlockInComplexBlock=l7,b.isHeadingBlock=Sn,b.isHighSurrogate=$9,b.isInBlock=e1,b.isInBlockTools=Mc,b.isLetter=Yb,b.isLowSurrogate=H9,b.isMatchShortcut=Wi,b.isMoveForward=X9,b.isNavigationEvent=q9,b.isNavigationKey=Jb,b.isNodeRemoved=Ef,b.isNumber=Xb,b.isPrintableKey=Op,b.isRootBlock=jr,b.isRootContainer=ie,b.isSafari=Ql,b.isSameDay=jp,b.isSelectBoxOnly=Ii,b.isShiftEnter=Z9,b.isShiftTab=nI,b.isShortcutEvent=Y9,b.isSimpleBlock=vI,b.isSimpleBlockPosition=xi,b.isSimplePos=hB,b.isSimpleRange=O0,b.isSpace=f0,b.isTab=eI,b.isTextBlockContentBoxChild=br,b.isTextBlockContentChild=Df,b.isTextBlockContentInsertionChild=Vs,b.isTextBlockContentTextChild=_f,b.isTextKindBlock=ot,b.isTextKindBlockType=Sf,b.isTitleBlock=Ns,b.isToday=fv,b.isValidOffset=or,b.isVisibleBlock=Yo,b.isYesterday=dv,b.loadJs=Kb,b.loadJsPromise=ta,b.lockers=hi,b.mergeCommands=Fm,b.mergeDocs=ga,b.mergeOps=D1,b.mergeText=m8,b.multiSplitText=V3,b.overflowText=hv,b.parseShortcut=nv,b.patchNode=Bf,b.pointInRect=na,b.rangeAddAttribute=Pf,b.rangeGetTextColor=q3,b.rangeRemoveAttribute=Kc,b.rangeSetTextColor=z3,b.rangeTransformText=H3,b.registerDragDrop=Mp,b.removeAttribute=x1,b.removeClass=ut,b.removeLastBr=u8,b.removePlaceholderFromBlock=kR,b.removeStyle=Hb,b.replaceAll=dI,b.replaceAllCaseInsensitive=hI,b.replaceAllText=K5,b.replaceText=M0,b.requestDownload=p0,b.resetListStart=pu,b.scrollIntoView=Hf,b.scrollable=av,b.selectFile=_c,b.selectedBlockToDoc=Z0,b.selectionToDoc=Xc,b.setAttributes=a0,b.setClipboardData=Tf,b.setClipboardDataByEvent=oI,b.setColorToAttributes=G3,b.setDataset=Ip,b.setDefaultCursor=bf,b.setStyles=Dp,b.shareDBCommentToDocObject=FC,b.shareDBDocCommentToComment=ry,b.shortcutToDisplayText=fn,b.showBlock=Yp,b.showDocVersions=Ttt,b.showTemplates=hx,b.splitText=sr,b.splitToThree=gn,b.stringToDataUrl=Fp,b.stringToObjectUrl=$p,b.subText=$3,b.textNodeOffsetFromPoint=Fb,b.titleFromEditor=aS,b.toBase64URL=qi,b.toMindmap=zm,b.toPlainText=ke,b.toPlainTextKeepLength=U1,b.trimChar=Up,b.unexclusiveBlock=RA,b.unicodeLength=j9,b.unicodeSubstr=z9,b.updateBlockSelection=Pv,b.updateOpAttributes=fB,b.updateTextBlockContent=U8,b.updateUrl=Np;for(const n in Fe)n!=="default"&&!b.hasOwnProperty(n)&&Object.defineProperty(b,n,{enumerable:!0,get:()=>Fe[n]});Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
962
|
+
\`\`\`\`\`\``}return""}const KJ={embedType:"plantuml",convertFrom:NJ,handleUpdateBlock:OJ,createEmbedContent:UJ,getBlockProperties:PJ,convertTo:FJ},zat="",VJ="hr",$J={dividingLine:{type:"\u5206\u5272\u7EBF",abstract:"\u5206\u5272\u7EBF"}},HJ={dividingLine:{type:"Dividing-Line",abstract:"Dividing-Line"}},jJ={dividingLine:{type:"\u533A\u5207\u308A\u7DDA",abstract:"\u533A\u5207\u308A\u7DDA"}};_.mergeLang({"zh-CN":$J,"en-US":HJ,"ja-JP":jJ});function zJ(n,t){const e=B("div",["editor-embed-container"],t);B("hr",["editor-embed-hr"],e)}function GJ(n,t,e,r){return r==="html"?"<hr />":r==="markdown"?"---":"------------"}function WJ(){return{name:"hr",insertEmbedCommandItems:[{id:"insert-hr",name:_.t("dividingLine.type"),icon:Fy,order:500,group:"common",subText:Jn("insert-hr")}],handleInsertEmptyEmbed:async(n,t)=>{const{containerId:e,blockIndex:r}=t;return n.insertEmbed(e,r,VJ,{})}}}function qJ(n,t,e){const{data:r}=e;if(!r||r.embedType!=="dividing-line"||!ot(n,t))return null;const i={};return{blockData:{id:it(),type:"embed",embedType:"hr",embedData:i}}}function XJ(){return{abstract:_.t("dividingLine.abstract")}}const YJ={embedType:"hr",createEmbedContent:zJ,convertTo:GJ,getOptions:WJ,convertFrom:qJ,getBlockProperties:XJ},Gat="",Wat="",QJ={media:{upload:{failed:'<div class="line-1">{name}\u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <span class="retry-upload">\u91CD\u8BD5</span></div>',maxSizeFailed:'<div class="line-1">{name}\u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u6587\u4EF6\u5927\u5C0F\u8D85\u8FC7\u9650\u5236\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6</div>'},load:{failed:'<div class="line-1">{name}\u52A0\u8F7D\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <span class="retry-upload">\u91CD\u8BD5</span></div>'},audio:{menuItem:"\u97F3\u9891",abstract:"\u97F3\u9891"},video:{menuItem:"\u89C6\u9891",abstract:"\u89C6\u9891"}}},JJ={media:{upload:{failed:'<div class="line-1">{name} upload failed</div><div class="line-2">Network error, you can <span class="retry-upload">Retry</span></div>',maxSizeFailed:'<div class="line-1">{name} upload failed</div><div class="line-2">The file size exceeds limit. Please choose another file.</div>'},load:{failed:'<div class="line-1">{name} loading failed</div><div class="line-2">Network error, you can <span class="retry-upload">Retry</span></div>'},audio:{menuItem:"Audio",abstract:"Audio"},video:{menuItem:"Video",abstract:"Video"}}},ZJ={media:{upload:{failed:'<div class="line-1">{name}\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F</div><div class="line-2">\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 <span class="retry-upload">\u518D\u8A66\u884C</span></div>',maxSizeFailed:'<div class="line-1">{name}\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F</div><div class="line-2">\u30D5\u30A1\u30A4\u30EB\u306E\u30B5\u30A4\u30BA\u304C\u4E0A\u9650\u3092\u8D85\u3048\u3066\u3044\u308B\u305F\u3081\u3001\u4ED6\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044</div>'},load:{failed:'<div class="line-1">{name}\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F</div><div class="line-2">\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 <span class="retry-upload">\u518D\u8A66\u884C</span></div>'},audio:{menuItem:"\u97F3\u58F0",abstract:"\u97F3\u58F0"},video:{menuItem:"\u52D5\u753B",abstract:"\u52D5\u753B"}}};_.mergeLang({"zh-CN":QJ,"en-US":JJ,"ja-JP":ZJ});var Ui=(n=>(n.AUDIO="audio",n.VIDEO="video",n))(Ui||{}),sh=(n=>(n.Empty="empty",n.Progress="progress",n.Error="error",n))(sh||{});const RS=10*1024*1024,tZ=["wav","mp3","aac","ogg","webm","flac"],eZ=["ogg","mp4","webm"],nZ=()=>{};function wS(n){var h,C,E,A,v,R;const t=(h=n.getComponentOptions("media"))!=null?h:{},{allowedMedias:e,maxSize:r,callbacks:i}=t,s=(C=e==null?void 0:e.audio)!=null?C:tZ,o=(E=e==null?void 0:e.video)!=null?E:eZ,l=(A=r==null?void 0:r.audio)!=null?A:RS,c=(v=r==null?void 0:r.video)!=null?v:RS,d=(R=i==null?void 0:i.onError)!=null?R:nZ;return{allowedMedias:{audio:s,video:o},maxSize:{audio:l,video:c},callbacks:{onError:d}}}function rZ(n,t){const e=s=>s.map(o=>`.${o}`).join(","),{allowedMedias:r}=wS(n),i=r[t];return i?e(i):"*"}function iZ(n,t,e){const{maxSize:r,callbacks:i,allowedMedias:s}=wS(t),{[e]:o}=r,{[e]:l}=s;if(o&&n.size>o){const d=new Error("media is too large");throw d.code=`MaxMediaSize-${e}`,i!=null&&i.onError&&(i==null||i.onError(t,d)),d}const c=yf(n.name);if(l&&!l.includes(c.toLowerCase())){const d=new Error(`media file is not allowed: ${c}`);throw d.code="NotAllowedFile",i!=null&&i.onError&&(i==null||i.onError(t,d)),d}}function sZ(n){return n===sh.Empty||n===sh.Error}const Cn=D("media");class oZ extends Fe.TypedEmitter{constructor(e){super();m(this,"mediaContainer",null);m(this,"media",null);m(this,"abstract",null);m(this,"handleMediaLoadError",(e,r)=>{if(!r.target||!(r.target instanceof Node)||!(r.target instanceof Element?r.target:r.target.parentElement))return;const s=nt(r.target);if(!s||!s.contains(this.mediaContainer))return;const o=this.renderError();this.updateMediaContent(o),this.emit("mediaError",e,"load_error",dt(s))});m(this,"handleUploadFile",async e=>{p(Cn,this.abstract,"no abstract"),p(Cn,this.mediaContainer,"The media element not exist");const{editor:r}=this.options,i=nt(this.mediaContainer);p(Cn,i,"The block element not exist");const s=r.getBlockData(i);try{const{resourceId:o}=await r.doc.uploadResource(e,{onProgress:C=>{this.renderProgress(C,e)}}),{name:l,type:c,size:d}=e,h={...s,embedData:{...s.embedData,src:o,fileName:l,fileSize:d,fileType:c}};r.updateBlockData(i,h)}catch(o){Cn.error(o),this.emit("mediaError",r,"upload_error",s.id),this.renderRetry(e,o)}ut(i,"media-block-uploading")});m(this,"destroy",()=>{this.mediaContainer=null});this.options=e}bindMediaEvent(){const{editor:e}=this.options;this.media&&e.domEvents.addEventListener(this.media,"error",this.handleMediaLoadError)}unbindMediaEvent(){const{editor:e}=this.options;this.media&&e.domEvents.removeEventListener(this.media,"error",this.handleMediaLoadError)}updateMediaContent(e){p(Cn,this.mediaContainer,"The media element not exist"),this.mediaContainer.innerHTML="",this.mediaContainer.append(e)}renderError(){p(Cn,this.abstract,"no abstract");const{editor:e,createMediaElement:r}=this.options,{mediaIcon:i,mediaName:s}=this.abstract;p(Cn,this.mediaContainer,"The media element not exist");const o=nt(this.mediaContainer);p(Cn,o,"The block element not exist");const l=e.getBlockData(o),c=B("div",["media-error","embed-selected-content","embed-hover-content"],null),d=B("span",["media-error-icon"],c);d.innerHTML=i;const h=B("div",[],c);h.innerHTML=_.t("media.load.failed",{name:s}),c.appendChild(h);const C=h.querySelector(".retry-upload");return p(Cn,C,"The element not exist"),e.domEvents.addEventListener(C,"click",(E,A)=>{const v=B("div",["media-element"],null),R=this.getResourceUrl(l),S=r(E,v,l,R);this.unbindMediaEvent(),this.media=S,this.bindMediaEvent(),this.updateMediaContent(v)}),this.setFullScreen(),c}renderRetry(e,r){var E,A;p(Cn,this.abstract,"no abstract");const{editor:i}=this.options,{mediaIcon:s,mediaName:o}=this.abstract,l=B("div",["media-error","embed-selected-content","embed-hover-content"],null),c=B("span",["media-error-icon"],l);c.innerHTML=s;const d=B("div",[],l);let h=_.t("media.upload.failed",{name:o});(((E=r.response)==null?void 0:E.status)===420||((A=r.response)==null?void 0:A.status)===413)&&(h=_.t("media.upload.maxSizeFailed",{name:o})),d.innerHTML=h,l.appendChild(d);const C=d.querySelector(".retry-upload");C&&i.domEvents.addEventListener(C,"click",()=>{i.readonly||(p(Cn,this.abstract,"no abstract"),this.handleUploadFile(e))}),this.updateMediaContent(l),this.setFullScreen()}renderProgress(e,r){p(Cn,this.mediaContainer,"The media element not exist");const i=this.mediaContainer.querySelector(":scope .media-progress"),s=e===-1||e===100?100:e;if(i){const{updateProgressElement:o}=this.options;o(i,s)}else{const{createProgressElement:o}=this.options,l=nt(this.mediaContainer);p(Cn,l,"The element not exist"),q(l,"media-block-uploading");const c=B("div",["media-progress"],null);o(c,s,r),this.updateMediaContent(c)}this.setFullScreen()}renderMediaElement(e,r){p(Cn,this.mediaContainer,"The media element not exist");const i=this.mediaContainer.querySelector(":scope > .media-element"),{createMediaElement:s,updateMediaElement:o,editor:l}=this.options,c=this.getResourceUrl(e,r);if(i){const d=o(l,i,e,c);this.unbindMediaEvent(),this.media=d,this.bindMediaEvent()}else{const d=B("div",["media-element"],null),h=s(l,d,e,c);this.unbindMediaEvent(),this.media=h,this.bindMediaEvent(),this.updateMediaContent(d)}}renderEmpty(e){p(Cn,this.abstract,"no abstract"),p(Cn,this.mediaContainer,"The media element not exist");const r=B("div",["media-empty","embed-selected-content","embed-hover-content"],this.mediaContainer);r.innerHTML=this.abstract.mediaIcon,this.updateMediaContent(r);const{editor:i}=this.options;i.findBlockById(e.id)&&this.emit("mediaError",i,"empty",e.id),this.setFullScreen()}getResourceUrl(e,r){const{src:i}=e.embedData,{editor:s}=this.options;return s.doc.buildResourceUrl(i,{syncNewResources:async(o,l)=>{var d,h;if(!r)return;await s.doc.addResources([o]);const c=(h=(d=s.doc).getServerMeta)==null?void 0:h.call(d).appId;if(l!==e.embedData.src&&c&&e.embedData.src.includes(c)){const C=nt(r);if(C&&!s.readonly&&s.isBlockWritable(C)){const E=At.default(e);E.embedData.src=o,s.updateBlockData(C,E)}}}})}setFullScreen(){p(Cn,this.mediaContainer,"The media element not exist"),q(this.mediaContainer,"full-screen")}removeFullScreen(){p(Cn,this.mediaContainer,"The media element not exist"),ut(this.mediaContainer,"full-screen")}updateBlockAlign(e,r){const i=nt(r);p(Cn,i,"The block element not exist");const{align:s}=e;e.embedType==="video"&&(i.hasAttribute("data-style-align")&&i.removeAttribute("data-style-align"),i.setAttribute("data-style-align",s))}render(e,r){const{src:i}=e.embedData;(!this.mediaContainer||!r.contains(this.mediaContainer))&&(this.mediaContainer=B("div",["media"],r)),this.updateBlockAlign(e,r),sZ(i)?i===sh.Empty&&this.renderEmpty(e):this.renderMediaElement(e,r)}setAbstract(e){this.abstract=e}}D("media-embed");const lZ="left";class SS{constructor(){m(this,"handleInsertEmptyEmbed",async(t,e)=>{var C;const{containerId:r,blockIndex:i}=e;let s;(C=e.data)!=null&&C.file&&(s=e.data.file);const o=rZ(t,this.embedType);if(s=s!=null?s:await _c(o,{}),!s)return null;const{mediaType:l}=this.getAbstract();try{iZ(s,t,l)}catch{return null}const c={id:it(),type:"embed",embedType:this.embedType,embedData:{src:sh.Empty}};l==="video"&&(c.align=lZ);const d=t.insertBlock(r,i,c);return await this.getMedia(t,c.id).handleUploadFile(s),d})}getMedia(t,e){const r=t.addCustom(`media-${e}`,()=>new oZ({editor:t,createMediaElement:this.createMediaElement,updateMediaElement:this.updateMediaElement,createProgressElement:this.createProgressElement,updateProgressElement:this.updateProgressElement}));return r.setAbstract({...this.getAbstract()}),r}getOptions(){const{menuItem:t,mediaIcon:e,mediaName:r,order:i,group:s}=this.getAbstract();return{name:r,insertEmbedCommandItems:[{id:`insert-${this.embedType}`,name:t,icon:e,order:i,group:s,subText:Jn(`insert-${this.embedType}`)}],handleInsertEmptyEmbed:this.handleInsertEmptyEmbed}}createEmbedContent(t,e,r){const{id:i}=r;this.getMedia(t,i).render(r,e)}handleUpdateBlock(t,e,r){const{id:i}=r,s=this.getMedia(t,i),o=jt(e);return s.render(r,o),!0}handleDeleteBlock(t,e){const r=e.id,i=this.getMedia(t,r);i.removeAllListeners(),i.destroy()}convertTo(t,e,r,i){const s=e.embedData,o=t.doc.buildResourceUrl(s.src,{withToken:!0});return i==="html"?`<${s.type} src="${o}" />`:i==="markdown"?``:o}}function LS(n,t){const e=B("div",["uploading-progress-mask"],n),r=B("div",["uploading-progress-bar"],e),i=B("div",["uploading-progress-bar-value"],r);i.style.width=`${t}%`}function IS(n,t){const e=n.querySelector(".uploading-progress-bar-value");e&&(e.style.width=`${t}%`)}const aZ=D("media-audio");class cZ extends SS{constructor(){super(...arguments);m(this,"embedType",Ui.AUDIO);m(this,"updateProgressElement",IS);m(this,"createMediaElement",(e,r,i,s)=>{const o=B("div",["audio-container","embed-hover-content","embed-selected-content"],r),l=B("audio",[],o);return l.innerHTML="Your browser does not support the <code>audio</code> element.",l.controls=!0,l.src=s,setTimeout(()=>{this.getMedia(e,i.id).setFullScreen()}),l})}getAbstract(){return{mediaIcon:Oy,mediaName:_.t(`media.${Ui.AUDIO}.menuItem`),menuItem:_.t(`media.${Ui.AUDIO}.menuItem`),order:800,mediaType:Ui.AUDIO,group:"common"}}getBlockProperties(){return{abstract:`${_.t(`media.${Ui.AUDIO}.abstract`)}`}}updateMediaElement(e,r,i,s){const o=r.querySelector(":scope .audio-container > audio");return p(aZ,o,"The media element not exist"),o.src!==s&&(o.src=s),o}createProgressElement(e,r){const i=B("audio",[],e);i.innerHTML="Your browser does not support the <code>audio</code> element.",i.controls=!0,i.src="about:blank",LS(e,r)}}const uZ=new cZ;D("video-resizer");function DS(n){return n&&Se(n)&&sn(n)==="video"}const fZ=50;class Bx{constructor(t){m(this,"currentResizableElement",null);m(this,"resizing",!1);m(this,"handleHoveringBlockChange",(t,e)=>{if(!this.resizing&&!window.isDragging&&(e&&DS(e)&&this.disableBlockResize(e),t&&DS(t)&&this.editor.isBlockWritable(t))){const r=this.getVideoElement(t);if(!r)return;this.enableBlockResize(t,r)}});m(this,"handleResizing",(t,e)=>{if(this.resizing=!0,!this.currentResizableElement)return;const r=t.getBlock();if(!r)return;const i=r.getBoundingClientRect().width,s=Math.min(Math.max(e.width,fZ),i);this.currentResizableElement.style.width=`${s}px`,this.currentResizableElement.style.pointerEvents="none"});m(this,"handleResized",t=>{this.resizing=!1;const e=t.getBlock();if(!this.currentResizableElement||!e)return;const r=this.editor.getBlockData(e),{width:i}=this.currentResizableElement.getBoundingClientRect();this.currentResizableElement.style.pointerEvents="auto",this.editor.updateBlockData(e,{...r,width:i})});this.editor=t,He.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentResizableElement=null,He.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}getVideoElement(t){return jt(t).querySelector(":scope .video-container > video")}updateResizer(t){const e=this.editor.findCustom(`${dt(t)}-resizer`);e&&e.updateResizer()}disableBlockResize(t){const e=this.editor.findCustom(`${dt(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t,e){const r=this.editor.addCustom(`${dt(t)}-resizer`,()=>new Nd(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}));r.enableResize(t,e),r.removeListener("resizing",this.handleResizing),r.removeListener("resized",this.handleResized),r.addListener("resizing",this.handleResizing),r.addListener("resized",this.handleResized),this.currentResizableElement=e}}const dZ=D("video");class hZ extends SS{constructor(){super(...arguments);m(this,"embedType",Ui.VIDEO);m(this,"updateProgressElement",IS);m(this,"createMediaElement",(e,r,i,s)=>{const o=B("div",["video-container","embed-selected-content","drag-preview-element"],r),l=B("video",[],o);return l.innerHTML="Your browser does not support the <code>video</code> element.",l.controls=!0,l.src=s,l.addEventListener("canplay",()=>{e.addCustom("video-resizer",()=>new Bx(e)),this.getMedia(e,i.id).removeListener("mediaError",this.handleMediaError),this.getMedia(e,i.id).addListener("mediaError",this.handleMediaError),this.getMedia(e,i.id).removeFullScreen()}),i.width&&(l.style.width=`${i.width}px`),l});m(this,"createProgressElement",(e,r,i)=>{const s=B("video",["progress-video"],e);s.innerHTML="Your browser does not support the <code>audio</code> element.",s.controls=!0,LS(e,r),Dc(i).then(o=>{const l=e.querySelector(".progress-video");l&&e1(e)&&(l.src=o)})})}getAbstract(){return{mediaName:_.t(`media.${Ui.VIDEO}.menuItem`),mediaIcon:Ny,menuItem:_.t(`media.${Ui.VIDEO}.menuItem`),order:700,mediaType:Ui.VIDEO,group:"common"}}getBlockProperties(){return{abstract:`${_.t(`media.${Ui.VIDEO}.abstract`)}`}}handleMediaError(e,r,i){const s=e.addCustom("video-resizer",()=>new Bx(e)),o=e.getBlockById(i);s.disableBlockResize(o)}updateMediaElement(e,r,i,s){const o=r.querySelector(":scope .video-container > video");p(dZ,o,"The media element not exist"),o.src!==s&&(o.src=s),i.width?o.style.width=`${i.width}px`:o.style.width="";const l=e.getBlockById(i.id);return setTimeout(()=>{e.addCustom("video-resizer",()=>new Bx(e)).updateResizer(l)}),o}}const mZ=new hZ,_S=[lA,gA,pA,kk],Tx=[vS,gQ,BJ,DJ,KJ,yK,YJ,mZ,uZ,Rz,Z4,aX],MS=[Pk,nS,y4,Hk];function gZ(n,t,e){var i,s,o,l;di.level=(i=e.logLevel)!=null?i:Wo.DEBUG;const r=Zf(n,t,{components:{blocks:[..._S,...((s=e==null?void 0:e.components)==null?void 0:s.blocks)||[]],embeds:[...Tx,...((o=e.components)==null?void 0:o.embeds)||[]],boxes:[...MS,...((l=e.components)==null?void 0:l.boxes)||[]],textRenders:[new $E],options:{...e.componentsOptions}}});return r.readonly=!0,r.addCustom("heading-collapse",()=>new ax(r)),r.addCustom("editor-tooltip",()=>new Sd(r)),r.addListener("clickLink",(c,d,h)=>{var E;if((E=e==null?void 0:e.events)!=null&&E.onClickLink){e.events.onClickLink(c,d,h);return}const C=h.getAttribute("link");C&&(c.readonly||d.ctrlKey||d.metaKey)&&window.open(C,"_blank")}),r}class US{constructor(t){this.createOptions=t,t.lang&&_.setLang(t.lang)}createHistoryEditor(t,e){return gZ(t,e,this.createOptions)}}function OS(n,{root:t,childDoc:e,doc:r}){var h,C;e.uploadResource=r.uploadResource.bind(r),e.buildResourceUrl=r.buildResourceUrl.bind(r);const i=n.getComponentOptions("comment"),s={image:{defaultAlign:"left"},table:{locatingContainer:t,hideCellMenu:!0,hideToolbar:!0},...i==null?void 0:i.componentsOptions},o=[];n.editorBlocks.forEach(E=>{E.blockType==="text"||E.blockType==="embed"||o.push(E)});const l=[];n.editorEmbeds.forEach(E=>{l.push(E)});const c=[];n.editorBoxes.forEach(E=>{E.boxType==="text"||E.boxType==="br"||E.boxType==="image"||E.boxType==="anchor"||c.push(E)});const d=Zf(t,e,{shortcuts:[nm],components:{blocks:o,commandProviders:[new Mm],decorators:[new og],embeds:l,boxes:c,options:s}});if(d.input.addHandler(new ag),d.input.addHandler(new UA(d)),d.input.addHandler(new VA(d)),d.input.addHandler(new Eq(d)),d.input.addHandler(new dg),d.addCustom("image-paste-handler",()=>new MA(d)),Ae.isMobile||d.addCustom("editor-tooltip",()=>new Sd(d)),n.options.enableContextMenu!==!1&&d.addCustom("editor-context-menu",E=>new jA(E)),(h=n.options.componentsOptions)!=null&&h.mention){const E=n.options.componentsOptions.mention;d.addCustom("mention",()=>new eS(d,{...E}))}if((C=n.options.componentsOptions)!=null&&C.comment){const E=n.options.componentsOptions.comment;E.onCommentEditorClick&&d.addListener("click",E.onCommentEditorClick)}return d}function pZ(n,t){const e=Array.from(n.rootContainer.querySelectorAll(`[comment-${t.toLocaleLowerCase()}="${t}"]`)),r=new Set;e.forEach(i=>{const s=nt(i);s&&r.add(s)}),r.forEach(i=>{Aq(n,i,t)})}class CZ{constructor(t){m(this,"listeners",new Set);m(this,"doc");this.editor=t,this.doc=this.editor.doc.externalDoc,this.doc.registerCallback(this)}getComments(){return this.doc.getComments()}getComment(t){return this.doc.getComment(t)}getCommentDoc(t){return this.doc.getCommentDoc(t)}localCreateComment(t,e){this.doc.localCreateComment(t,e)}localDeleteComment(t){const e=this.getComment(t);this.doc.localDeleteComment(t);const r=e.groupId;this.getComments().filter(s=>s.groupId===r).length===0&&pZ(this.editor,r)}localUpdateComment(t,e){this.doc.localUpdateComment(t,e)}onCreateComment(t,e){Array.from(this.listeners.values()).forEach(r=>r.onCreateComment(t,e))}onDeleteComment(t,e){Array.from(this.listeners.values()).forEach(r=>r.onDeleteComment(t,e))}onUpdateComment(t,e){Array.from(this.listeners.values()).forEach(r=>r.onUpdateComment(t,e))}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}createCommentEditor(t,e){return OS(this.editor,{root:t,childDoc:e,doc:this.doc})}allowEdit(t){return t.userId===this.doc.getUser().userId}}class EZ{constructor(t,e){m(this,"listeners",new Set);this.editor=t,this.localDoc=e}get doc(){return this.localDoc.toJSON()}getComments(){return Object.values(this.doc.comments)}getComment(t){return this.doc.comments[t]}getCommentDoc(t){const e=this.doc.comments[t];return FC(e)}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}localCreateComment(t,e){}localDeleteComment(t){}localUpdateComment(t,e){}createCommentEditor(t,e){return OS(this.editor,{root:t,childDoc:e,doc:this.localDoc})}allowEdit(t){return t.userId===this.localDoc.getUser().userId}}const AZ={placeholder:{common:{title:"\u8BF7\u8F93\u5165\u6807\u9898",readonlyTitle:"\u8BF7\u8F93\u5165\u6807\u9898",content:"\u70B9\u51FB + \uFF0C\u6216\u8F93\u5165 / \u5FEB\u6377\u63D2\u5165\u7EC4\u4EF6",contentInTable:"\u8F93\u5165 / \u5FEB\u6377\u63D2\u5165\u7EC4\u4EF6"},local:{readonlyTitle:"\u672A\u547D\u540D"}},copyCutProperty:{copy:"\u590D\u5236",cut:"\u526A\u5207",unsafeEnvTips:"\u7531\u4E8E\u5F53\u524D http \u8BBF\u95EE\u73AF\u5883\u4E0B\u7684\u9650\u5236\uFF0C\u8BF7\u4F7F\u7528\u5FEB\u6377\u952E({shortCut}) {operation}",limitedEnvTips:"\u7531\u4E8E\u6D4F\u89C8\u5668\u9650\u5236\uFF0C\u8BF7\u4F7F\u7528 {shortCut} \u7C98\u8D34"}},xZ={placeholder:{common:{title:"Enter a title",readonlyTitle:"Enter a title",content:'Click "+", or enter "/" to insert components quickly',contentInTable:'Enter "/" to insert components quickly'},local:{readonlyTitle:"Untitled"}},copyCutProperty:{copy:"Copy",cut:"Cut",unsafeEnvTips:"Due to the limitations of the current http access environment, please use the shortcut ({shortCut}) {operation}",limitedEnvTips:"Press {shortCut} to paste due to browser restrictions"}},bZ={placeholder:{common:{title:"\u30BF\u30A4\u30C8\u30EB\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",readonlyTitle:"\u30BF\u30A4\u30C8\u30EB\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",content:"\u300C+\u300D\u3092\u30AF\u30EA\u30C3\u30AF\u3059\u308B\u304B\u3001\u300C/\u300D\u3092\u5165\u529B\u3059\u308B\u3068\u3001\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u304C\u7D20\u65E9\u304F\u633F\u5165\u3067\u304D\u307E\u3059",contentInTable:"\u300C/\u300D\u3092\u5165\u529B\u3059\u308B\u3068\u3001\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u304C\u7D20\u65E9\u304F\u633F\u5165\u3067\u304D\u307E\u3059"},local:{readonlyTitle:"\u7121\u984C"}},copyCutProperty:{copy:"\u8907\u88FD",cut:"\u5207\u308B",unsafeEnvTips:"HTTP\u74B0\u5883\u306E\u5236\u7D04\u306B\u3088\u308A\u3001{operation}\u3059\u308B\u306B\u306F\u3001\u30B7\u30E7\u30FC\u30C8\u30AB\u30C3\u30C8({shortCut}) \u3092\u3054\u4F7F\u7528\u304F\u3060\u3055\u3044",limitedEnvTips:"\u30D6\u30E9\u30A6\u30B6\u30FC\u306E\u5236\u9650\u306B\u3088\u308A\u3001\u300C{shortCut}\u300D\u3092\u4F7F\u7528\u3057\u3066\u8CBC\u308A\u4ED8\u3051\u3066\u304F\u3060\u3055\u3044"}};_.mergeLang({"zh-CN":AZ,"en-US":xZ,"ja-JP":bZ});const vZ="UEsDBBQABgAIAAAAIQBk9WPugQEAACkGAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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WzsAAHdvcmQvZm9udFRhYmxlLnhtbFBLBQYAAAAADwAPANQDAADePgAAAAA=",BZ=()=>Pp(vZ),TZ=D("image-to-docx");async function yZ(n){return new Promise((t,e)=>{const r=new Image;r.onload=()=>{t({width:r.naturalWidth,height:r.naturalHeight})},r.onerror=e,r.src=n})}async function NS(n,t){if(n.width&&n.height)return{width:n.width,height:n.height,buffer:t};try{const e=await Dc(new File([t],"",{})),r=await yZ(e);return r.width===void 0||r.height===void 0?{width:345,height:230,buffer:t}:n.width||n.height?{width:n.width||r.width*n.height/r.height,height:n.height||r.height*n.width/r.width,buffer:t}:{width:r.width,height:r.height,buffer:t}}catch(e){TZ.error(e);return}}function kZ(n,t){let e=n.filter(o=>o!=null);const r=t-(e.length-1)*20,i=.87,s=e.reduce((o,l)=>o+l.width,0);return s>r&&(e=e.map(o=>({width:o.width*r/s,height:o.height*r/s,buffer:o.buffer}))),e.map(o=>({width:o.width*i,height:o.height*i,buffer:o.buffer}))}function RZ(n,t,e){if(!e||typeof e!="object")return;const r=e,i=n.filter(o=>o!=null),s=t-(i.length-1)*20;i.forEach((o,l)=>{if(i.length===1&&r.widthPercent){const d=r.widthPercent,h=o.width;o.width=s*(d/100),o.height*=o.width/h;return}const c=`${l}_flex`;if(r[c]){const d=r[c],h=o.width;o.width=s*d,o.height*=o.width/h}})}function PS(n=[0,1,2,3,4,5,6,7],t=1){return n.map(e=>{let r;switch(e%3){case 0:r=Bt.LevelFormat.DECIMAL;break;case 1:r=Bt.LevelFormat.LOWER_LETTER;break;default:r=Bt.LevelFormat.LOWER_ROMAN;break}return{level:e,format:r,text:`%${e+1}. `,alignment:Bt.AlignmentType.START,start:t,style:{paragraph:{indent:{left:Bt.convertInchesToTwip(.3*(e+1)),hanging:Bt.convertInchesToTwip(.2)}}}}})}function wZ(){return[0,1,2,3,4,5,6,7].map(n=>{let t;switch(n%3){case 0:t="\u2022";break;case 1:t="\u25E6";break;default:t="\u25AA";break}return{level:n,format:Bt.LevelFormat.BULLET,text:t,alignment:Bt.AlignmentType.START,style:{paragraph:{indent:{left:Bt.convertInchesToTwip(.3*(n+1)),hanging:Bt.convertInchesToTwip(.2)}}}}})}function SZ(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:Bt.LevelFormat.BULLET,text:"\u2611",alignment:Bt.AlignmentType.START,style:{paragraph:{indent:{left:Bt.convertInchesToTwip(.3*(n+1)),hanging:Bt.convertInchesToTwip(.2)}}}}))}function LZ(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:Bt.LevelFormat.BULLET,text:"\u2610",alignment:Bt.AlignmentType.START,style:{paragraph:{indent:{left:Bt.convertInchesToTwip(.3*(n+1)),hanging:Bt.convertInchesToTwip(.2)}}}}))}var oh=(n=>(n.NUMBERING="number-numbering-reference",n.BULLET="number-bullet-reference",n.CHECKED="checked-bullet-reference",n.UNCHECKED="unchecked-bullet-reference",n))(oh||{});const IZ=[{levels:PS(),reference:"number-numbering-reference"},{levels:wZ(),reference:"number-bullet-reference"},{levels:SZ(),reference:"checked-bullet-reference"},{levels:LZ(),reference:"unchecked-bullet-reference"}];function DZ(n){switch(n){case"style-color-0":return"d83931";case"style-color-1":return"de7802";case"style-color-2":return"dc9b04";case"style-color-3":return"2ea121";case"style-color-4":return"245bdb";case"style-color-5":return"6425d0";case"style-color-6":return"8f959e";default:return}}function _Z(n){switch(n){case"style-bg-color-1":case"style-bg-color-2":case"style-bg-color-8":case"style-bg-color-9":return"yellow";case"style-bg-color-0":case"style-bg-color-5":return"magenta";case"style-bg-color-3":return"green";case"style-bg-color-4":case"style-bg-color-11":return"blue";case"style-bg-color-6":return"lightGray";case"style-bg-color-7":return"red";case"style-bg-color-10":return"darkGreen";case"style-bg-color-12":return"darkMagenta";case"style-bg-color-13":return"darkGray";default:return}}function MZ(n){switch(n){case"style-bg-color-0":return"fbbab6";case"style-bg-color-1":return"ffdcb0";case"style-bg-color-2":return"fff7a0";case"style-bg-color-3":return"ceefc5";case"style-bg-color-4":return"d1ddfb";case"style-bg-color-5":return"d9cbf8";case"style-bg-color-6":return"eaeaea";case"style-bg-color-7":return"fe837c";case"style-bg-color-8":return"ffbd6a";case"style-bg-color-9":return"ffe662";case"style-bg-color-10":return"a8f393";case"style-bg-color-11":return"98b5ff";case"style-bg-color-12":return"b394f8";case"style-bg-color-13":return"b1b1b1";default:return}}const UZ=/rgb\((\d+),\s*(\d+),\s*(\d+)\)/;function FS(n){if(typeof n=="string"&&n.length>0){if(n[0]==="#")return n.substring(1);const t=n.match(UZ);if(t){const e=o=>{let l=Number(o).toString(16);return l.length<2&&(l=`0${l}`),l},r=e(t[1]),i=e(t[2]),s=e(t[3]);return`${r}${i}${s}`}if(n==="red")return"FF0000";if(n==="green")return"00FF00";if(n==="blue")return"0000FF"}}function _n(n,t){if(n&&n.attributes&&n.attributes[t])return n.attributes[t];if(n&&n.attributes&&n.attributes.box&&n.attributes.inputType&&t==="style-underline")return!0}function KS(n,t,e){for(let r=0;r<=e;++r){const i=`${t}${r}`;if(_n(n,i))return i}}function Ug(n,t,e){n.attributes=n.attributes||{},n.attributes[t]=e}function yx(n){return n==="image"||n==="drawio"||n==="plantuml"||n==="mermaid"||n==="flowchart"}function VS(n){return n&&n.startsWith("//")?`https:${n}`:n&&!n.startsWith("http://")&&!n.startsWith("https://")?`https://${n}`:n}function OZ(n){const t=_n(n,"inlineStyle");if(t==null)return;const e=t.split(";");for(const r of e){const i=r.split(":");if(i.length!==2)continue;const s=i[0].trim().toLowerCase(),o=i[1].trim().toLowerCase();s==="font-size"&&Ug(n,"inline-style-font-size",o),s==="color"&&Ug(n,"inline-style-color",o),s==="background-color"&&Ug(n,"inline-style-background-color",o),s==="font-family"&&Ug(n,"inline-style-font-family",o)}}function NZ(n,t){if(t==null)return n==null?void 0:n.normal;if(n)return n[`heading${t}`]}function PZ(n){const t=`${_n(n,"inline-style-font-size")}`;if(t&&t.indexOf("px")>0)return+t.replace(/px/g,"")}function FZ(n){if(n.attributes&&n.attributes.box&&n.attributes.text)return` ${n.attributes.text} `;if(n.attributes&&n.attributes.box&&n.attributes.inputType)return n.attributes.value?`${n.attributes.value}`:" "}function KZ(n){if(n.attributes&&n.attributes.box&&n.attributes.text)return` @${n.attributes.text} `}function VZ(n){return _n(n,"inline-style-font-family")}function $Z(n){const t=_n(n,"inline-style-background-color");return FS(t)}function HZ(n){const t=_n(n,"inline-style-color");return FS(t)}function jZ(n){OZ(n);const t=_n(n,"type")==="mention";return{box:n.attributes&&n.attributes.box?n.attributes:void 0,inlineCode:!!_n(n,"style-code"),link:VS(_n(n,"link")),size:PZ(n),text:t?KZ(n):FZ(n)||n.insert,bold:!!_n(n,"style-bold"),underline:!!_n(n,"style-underline"),italics:!!_n(n,"style-italic"),strike:!!_n(n,"style-strikethrough"),superScript:!!_n(n,"style-super"),subScript:!!_n(n,"style-sub"),math:_n(n,"type")==="math"?_n(n,"src"):void 0,mention:t,fontFamily:VZ(n),background:$Z(n),color:t?"338fe5":DZ(KS(n,"style-color-",6))||HZ(n),highlight:KS(n,"style-bg-color-",13)}}function zZ(){return[new Bt.Paragraph({border:{top:{color:"auto",style:Bt.BorderStyle.DASHED,size:4,space:1}},spacing:{before:300}}),new Bt.Paragraph({spacing:{line:0}})]}function GZ(){return new Bt.Paragraph({children:[new Bt.TextRun({text:"[\u89C6\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:Bt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function WZ(){return new Bt.Paragraph({children:[new Bt.TextRun({text:"[\u97F3\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:Bt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function qZ(n,t){return new Bt.Paragraph({children:[new Bt.ExternalHyperlink({children:[new Bt.TextRun({style:"Hyperlink",text:t||n})],link:n})]})}function $S(n){if(n.heading!=null)return`Heading${n.heading}`}function HS(n){if(n.alignment!=null){if(n.alignment==="center")return Bt.AlignmentType.CENTER;if(n.alignment==="right")return Bt.AlignmentType.RIGHT;if(n.alignment==="left")return Bt.AlignmentType.LEFT}}function XZ(n){if(n.indent)return{left:Bt.convertInchesToTwip(.3*n.indent-.2)};if(n.padding)return{left:Bt.convertInchesToTwip(.3*n.padding)}}function YZ(n){return{type:Bt.ShadingType.CLEAR,color:"FFFFFF",fill:n}}function QZ(n){const t=n.split(",");if(t.length!==0)return t[0].trim()}function jS(n,t){let e;e=n.inlineCode?"InlineCode":void 0,e=n.link?"Hyperlink":e;const r=n.size||t,i=r!=null?Math.floor(r*1.5+.5):void 0;return new Bt.TextRun({text:n.text,bold:n.bold||void 0,underline:n.underline?{type:Bt.UnderlineType.SINGLE}:void 0,italics:n.italics||void 0,strike:n.strike||void 0,superScript:n.superScript||void 0,subScript:n.subScript||void 0,size:i,style:e,font:n.fontFamily?QZ(n.fontFamily):void 0,shading:n.background?YZ(n.background):void 0,color:n.color,highlight:_Z(n.highlight)})}function JZ(n,t){if(n.link)return new Bt.ExternalHyperlink({children:[jS(n,t)],link:n.link})}async function zS(n,t,e,r,i){const[s]=await i(n,t,e);if(s==null)return;const o=await NS({width:r||0,height:0,src:e},s);return new Bt.ImageRun({data:s,transformation:{width:(o==null?void 0:o.width)||100,height:(o==null?void 0:o.height)||20}})}function ZZ(n){if(n.heading||n.heading)return n.heading}function ttt(n){if(n.align&&(n.align==="center"||n.align==="right"||n.align==="left"))return n.align}function ett(n){if(n.textOnly===!0&&n.level!=null)return n.level}async function ntt(n,t){var r;const e=[];if(n.text&&Array.isArray(n.text)){for(let i=0;i<n.text.length;i++){const s=n.text[i];if(((r=s.attributes)==null?void 0:r.box)===!0&&t){const o=await t(s);if(o){n.text.splice(i+1,0,...o);continue}}e.push(jZ(s))}return e}}function rtt(n){if(n.type==="list"&&n.textOnly!==!0)return{checkbox:n.checkbox,groupId:n.groupId,ordered:!!n.ordered,level:n.level||1,start:n.start||0}}function itt(n,t){if(n.type==="embed"&&n.embedType&&yx(n.embedType)&&n.embedData&&n.embedData.src)return n.embedData.src.split("|").map(r=>{const i=t(r),s=n.embedData[`${i}_width`],o=n.embedData[`${i}_height`];return{src:r,width:s,height:o}})}function stt(n){if(n.padding)return n.padding}function ott(n){return!!(n.type==="embed"&&n.embedType&&yx(n.embedType)&&n.embedData&&n.embedData.src)}async function Og(n,t,e){return{quoted:!!n.quoted,heading:ZZ(n),alignment:ttt(n),indent:ett(n),padding:stt(n),texts:await ntt(n,e),list:rtt(n),images:itt(n,t),border:ott(n)}}async function ltt(n,t,e,r){const i=[];if(!n.children)return[];for(const s of n.children){const o=[];for(const l of t.blocks[s])o.push(await Og(l,e,r));i.push(o)}return i}const att=D("to-docx");function ctt(n,t){return Array(n).fill(0).map(()=>Array(t).fill(0).map(()=>({cellId:void 0,color:void 0,from:void 0,rowSpan:1,colSpan:1,width:0,originalWidth:void 0,align:void 0})))}function utt(n,t,e,r){const i=!!n.hasColTitle,s=!!n.hasRowTitle,o=!!n.isStripeStyle,l="F5F8FB";for(let c=0;c<t;c++)for(let d=0;d<e;d++)(i&&d===0||s&&c===0||o&&c%2===1)&&(r[c][d].color=l)}function ftt(n){p(att,n.children,"no table children");const t=n.rows,e=n.cols,r=n.colsWidth;if(r)for(let o=0;o<r.length;o++)r[o]===0&&(r[o]=100);const i=ctt(t,e);let s=0;for(let o=0;o<t;++o)for(let l=0;l<e;++l){if(i[o][l].originalWidth=r?r[l]:void 0,i[o][l].from!==void 0)continue;const c=n.children[s];s+=1,i[o][l].cellId=c,i[o][l].color=MZ(n[`${c}_background`]),i[o][l].width=r?r[l]:100,i[o][l].align=n[`${c}_align`];const d=n[`${c}_rowSpan`]||1,h=n[`${c}_colSpan`]||1;if(i[o][l].rowSpan=d,i[o][l].colSpan=h,d>1||h>1){let C=0;for(let E=0;E<d;E++)for(let A=0;A<h;A++)E===0&&(C+=r?r[l+A]:80),!(E===0&&A===0)&&(i[o+E][l+A].from=[o,l]);i[o][l].width=C}}return utt(n,t,e,i),i}async function dtt(n,t,e,r,i,s,o,l,c,d){async function h(E){if(l&&E.type!=="_exportVirtualBlock"){const A=await l(i,s,E);if(A){await r.addDoc(n,A,d);return}}if(E.type==="text"||E.textOnly===!0){const A=await Og(E,o,c);await r.addTextBlock(A);return}if(E.type==="code"){const A=await ltt(E,e,o,c);await r.addCodeBlockObject(A);return}if(E.type==="list"&&E.textOnly!==!0){const A=await Og(E,o,c);await r.addListBlockObject(n,A);return}if(E.type==="embed"&&E.embedType){const A=E,v=A.embedData,R=A.embedType;if(yx(R)){const S=await Og(E,o,c);await r.addImagesBlockObject(E,S,d)}else E.embedType==="hr"?r.addSeparatorBlock():E.embedType==="video"?r.addVideoPlaceholder():E.embedType==="audio"?r.addAudioPlaceholder():E.embedType==="webpage"?r.addHyperlinkParagraph(VS(v.src),v.title):r.addOtherEmbedBlock(R,E.embedData);return}if(E.type==="table"){let A=[];if(E.colsWidth)A=E.colsWidth;else{const R=E.cols;A=new Array(R);for(let S=0;S<A.length;S++)A[S]=100;E.colsWidth=A}const v=ftt(E);await r.addTableMatrix(A,v,e),r.addEmptyParagraph()}E.type==="_exportVirtualBlock"&&await r.addVirtualBlock(E.id,e,d)}function C(E){var R;const A=((R=E==null?void 0:E.embedData)==null?void 0:R.exportSpec)||(E==null?void 0:E.exportSpec);if(!A)return[E];const v=[];for(const{type:S,data:O}of A){if(S==="text"){const M={id:it(),text:[{insert:O}],type:"text"};v.push(M);continue}if(S==="image"){const M={id:it(),type:"embed",embedType:"image",align:"left",embedData:{src:O}};v.push(M);continue}if(S==="link"){const M={id:it(),type:"embed",embedType:"webpage",embedData:{src:O.url,title:O.title}};v.push(M);continue}if(S==="block")for(const M of O){if(!e.blocks[M])continue;const J={id:M,type:"_exportVirtualBlock"};v.push(J)}}return v}for(const E of t)for(const A of C(E))!A||await h(A)}function htt(){return{listMaxInst:1,listInstMap:{},listRefMap:{},levelConfigs:[]}}const mtt=D("to-docx");class gtt{constructor(t,e,r,i,s,o){m(this,"paragraphs");this.appId=t,this.docId=e,this.state=r,this.readImageFunc=i,this.convertBlocksFunc=s,this.defaultFontSize=o,this.paragraphs=[]}async addTextBlock(t){this.paragraphs.push(new Bt.Paragraph({heading:$S(t),alignment:HS(t),children:await this.paragraphsFromBlockTexts(t),indent:XZ(t)}))}async addEmptyImagePlaceHolder(){this.paragraphs.push(new Bt.Paragraph({text:`[${_.t("docx.imageExportFailed")}]`,shading:{type:Bt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}}))}async paragraphsFromBlockTexts(t){if(t.texts==null)return;const e=NZ(this.defaultFontSize,t.heading),r=[];for(const i of t.texts){if(i.link){const s=JZ(i,e);s&&r.push(s);continue}if(i.box&&i.box.type&&i.box.type==="br"){r.push(new Bt.TextRun({text:"",break:1}));continue}if(i.box&&i.box.type&&i.box.type==="image"){const s=await zS(this.appId,this.docId,i.box.src,i.box.width,this.readImageFunc);s&&r.push(s);continue}if(i.math){const s=await zS(this.appId,this.docId,i.math,0,this.readImageFunc);s&&r.push(s);continue}r.push(jS(i,e))}return r}async addCodeBlockObject(t){for(const e of t)for(const r of e){const i={style:Bt.BorderStyle.SINGLE,color:"#DEDEDE"};this.paragraphs.push(new Bt.Paragraph({style:"Code",border:{left:{...i},right:{...i},top:{...i},bottom:{...i}},children:await this.paragraphsFromBlockTexts(r)}))}}async addListBlockObject(t,e){if(e.list==null)return;let r;const i=e.list.checkbox?`${t}-${e.list.groupId}-${e.list.checkbox}`:`${t}-${e.list.groupId}`;if(this.state.listInstMap[i])r=this.state.listInstMap[i];else if(r=this.state.listMaxInst,this.state.listMaxInst+=1,this.state.listInstMap[i]=r,e.list.start>0&&e.list.ordered){const o=`number-numbering-reference-${r}`,l=PS([e.list.level-1],e.list.start);this.state.levelConfigs.push({levels:l,reference:o,inst:r}),this.state.listRefMap[i]=o}else e.list.ordered?this.state.listRefMap[i]=oh.NUMBERING:e.list.checkbox&&e.list.checkbox==="checked"?this.state.listRefMap[i]=oh.CHECKED:e.list.checkbox&&e.list.checkbox==="unchecked"?this.state.listRefMap[i]=oh.UNCHECKED:this.state.listRefMap[i]=oh.BULLET;const s=$S(e);e.texts&&this.paragraphs.push(new Bt.Paragraph({heading:s,children:await this.paragraphsFromBlockTexts(e),numbering:{reference:this.state.listRefMap[i],level:e.list.level-1,instance:r}}))}imageDimWithBufferToImageRun(t){return new Bt.ImageRun({data:t.buffer,transformation:{width:t.width,height:t.height}})}async addImagesBlockObject(t,e,r){if(e.images==null){if(t.type==="embed"&&t.embedType==="image"){const{src:c}=t.embedData;c||this.addEmptyImagePlaceHolder()}return}const i=[],s=await Promise.all(e.images.map(async c=>{const[d,h]=await this.readImageFunc(this.appId,this.docId,c.src);if(d){const C=await NS(c,d);if(C)return C}i.push(h)}));RZ(s,r,t.embedData);const o=kZ(s,r),l={style:Bt.BorderStyle.SINGLE,color:"#DEDEDE"};o.length&&this.paragraphs.push(new Bt.Paragraph({border:e.border?{left:{...l},right:{...l},top:{...l},bottom:{...l}}:void 0,alignment:HS(e)||Bt.AlignmentType.CENTER,children:o.map(c=>this.imageDimWithBufferToImageRun(c)).flatMap((c,d,h)=>c==null?[]:h.length-1!==d?[c,new Bt.TextRun({text:" "})]:c)})),i.forEach(c=>{this.addHyperlinkParagraph(c)})}addSeparatorBlock(){zZ().forEach(t=>this.paragraphs.push(t))}addEmptyParagraph(){this.paragraphs.push(new Bt.Paragraph(""))}addVideoPlaceholder(){this.paragraphs.push(GZ())}addAudioPlaceholder(){this.paragraphs.push(WZ())}addHyperlinkParagraph(t,e){t!=null&&this.paragraphs.push(qZ(t,e))}async addTableMatrix(t,e,r){const i=t.map(s=>s!==0?s*15:1500);this.paragraphs.push(new Bt.Table({rows:await this.generateTableRows(e,r),columnWidths:i}))}async generateRowCells(t,e){const r=[];for(const i of t){const s=i.cellId;if(s===void 0)continue;const o=i.width*.9;r.push(new Bt.TableCell({children:await this.convertBlocksFunc(s,e.blocks[s],e,this.appId,this.docId,this.state,o),columnSpan:i.colSpan,rowSpan:i.rowSpan,width:{type:Bt.WidthType.DXA,size:i.width*15},shading:i.color?{fill:i.color,type:Bt.ShadingType.CLEAR,color:"auto"}:void 0}))}return r}async generateTableRows(t,e){const r=[];for(const i of t)r.push(new Bt.TableRow({children:await this.generateRowCells(i,e)}));return r}async addDoc(t,e,r){const i=await this.convertBlocksFunc(t,e.blocks.root,e,this.appId,this.docId,this.state,r);i&&(this.paragraphs=this.paragraphs.concat(i))}async addVirtualBlock(t,e,r){const i=await this.convertBlocksFunc(t,e.blocks[t],e,this.appId,this.docId,this.state,r);this.paragraphs.push(...i)}async addOtherEmbedBlock(){}}class ptt{constructor(t,e,r,i,s,o,l,c){m(this,"convertBlocks",async(t,e,r,i,s,o,l=720)=>{const c=new gtt(i,s,o,this.readImage,this.convertBlocks,this.defaultFontSize);return await dtt(t,e,r,c,i,s,this.md5HexFunc,this.getDocByBlock,this.getTextsByBox,l||720),c.paragraphs});this.templateData=t,this.docData=e,this.md5HexFunc=r,this.readImage=i,this.defaultFontSize=s,this.getDocByBlock=o,this.getTextsByBox=l,this.backgroundImageOptions=c}async convert(t,e){return this.snapshot2docx(this.docData,t,e)}async snapshot2docx(t,e,r){const i=new Bt.ImportDotx,s=this.templateData?await i.extract(this.templateData):void 0,o=t.blocks.root;p(mtt,o,"data must have blocks");const l=htt(),c=await this.convertBlocks("blocks",o,t,e,r,l),d=this.backgroundImageOptions?{default:new Bt.Header({children:[new Bt.Paragraph({children:[new Bt.ImageRun(this.backgroundImageOptions)]})]})}:{},h=new Bt.Document({numbering:{config:[...IZ,...l.levelConfigs]},sections:[{headers:d,children:c,properties:{page:{size:{width:12240,height:15840},margin:{top:1440,bottom:1440,left:1440,right:1440}}}}]},{template:s});return Bt.Packer.toBlob(h)}}async function Ctt(n,t,e,r){const i=n.doc.buildResourceUrl(r,{withToken:!0});let s=await cS(i);if(!s)return[void 0,i];if(s.type.indexOf("/svg")!==-1){const l=await oS(s);l&&(s=new File([l],s.name))}return[await s.arrayBuffer(),i]}async function Ett(n,t,e){const r=n.editorBlocks.getBlockClass(e.type);if(r.toStandardDoc)return r.toStandardDoc(n,e,t)}async function Att(n,t){const e=t.attributes,r=n.editorBoxes.getBoxClass(e.type);if(r.toStandardText)return r.toStandardText(n,e)}async function xtt(n,t){let{template:e,download:r,backgroundImageOptions:i}=t!=null?t:{};e||(e=BZ());const s=n.doc.toJSON(),o=(C,E,A)=>Ctt(n,C,E,A),l=async(C,E,A)=>Ett(n,s,A),c=async C=>Att(n,C),h=await new ptt(e,s,t0.default,o,void 0,l,c,i).convert("_appId","_docId");if(r){const C=URL.createObjectURL(h),E=document.createElement("a");E.setAttribute("download",`${aS(n)}.docx`),E.setAttribute("href",`${C}`),E.click(),E.remove()}return h}const kx=D("create-editor");async function btt(n,t){var o,l,c,d,h,C,E,A,v,R,S,O,M,V,J,Q;p(kx,n,"app does not exists"),t.lang&&_.setLang(t.lang),di.level=(o=t.logLevel)!=null?o:Wo.DEBUG;const e=t.onReauth?async()=>{var bt;const X=t.user.userId,ct=t.docId,xt=await((bt=t.onReauth)==null?void 0:bt.call(t,X,ct,t.permission));return{userId:X,docId:ct,permission:t.permission,appId:t.appId,token:xt,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl}}:void 0,r={auth:{appId:t.appId,docId:t.docId,userId:t.user.userId,permission:t.permission,token:t.token,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl},serverUrl:t.serverUrl,reauthFunc:e,disableLogout:t.disableLogout},i=await hd.load(r),s=Zf(n,i,{id:t.id,scrollContainer:t==null?void 0:t.scrollContainer,enableComments:t==null?void 0:t.enableComments,enableContextMenu:t==null?void 0:t.enableContextMenu,components:{blocks:[..._S,...((l=t==null?void 0:t.components)==null?void 0:l.blocks)||[]],embeds:[...Tx,...((c=t.components)==null?void 0:c.embeds)||[]],boxes:[...MS,...((d=t.components)==null?void 0:d.boxes)||[]],commandProviders:[new Mm,...((h=t.components)==null?void 0:h.commandProviders)||[]],decorators:[new og,new VC],insertions:[K1],blockHooks:[new SA,new tw,...((C=t.components)==null?void 0:C.blockHooks)||[]],textRenders:[new C4,new $E,...((E=t.components)==null?void 0:E.textRenders)||[]],options:{...t.componentsOptions}},shortcuts:[Lq,sH,Cz,aA,Hw,fF,nA,mX,nm,iF,...t.shortcuts||[]],colors:["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"]});if(s.editorCommandProviders.registerCommandProvider(new hs(s)),s.input.addHandler(new rY),s.input.addHandler(new ag),s.input.addHandler(new LK),s.input.addHandler(new cz),s.input.addHandler(new CA(s,{hideTitle:t.hideTitle,headingLevel:1,titlePlaceholder:_.t("placeholder.common.title"),contentPlaceholder:_.t("placeholder.common.content"),readonlyTitlePlaceholder:_.t("placeholder.common.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0,applyContentPlaceholder:(A=t.placeholder)==null?void 0:A.applyContentPlaceholder})),s.input.addHandler(new tg(s,(v=t.componentsOptions)==null?void 0:v.quickMenu)),s.input.addHandler(new UA(s)),s.input.addHandler(new VA(s)),s.input.addHandler(new dg),s.doc.registerCallback(new iY(s)),s.addCustom("remote-cursor",()=>new sy(s)),s.addCustom("block-menu",X=>new rw(X)),Ae.isMobile||s.addCustom("editor-tooltip",()=>new Sd(s)),t!=null&&t.enableComments&&s.addCustom("editor-comments",X=>new p4(X,new CZ(X))),t.enableContextMenu!==!1&&s.addCustom("editor-context-menu",X=>new jA(X)),s.addCustom("create-options",()=>new Sb(s,t)),s.addCustom("drop-target",()=>new Wd(s)),s.addCustom("list-to-mindmap",()=>new Wm(s)),s.addCustom("list-to-mention",()=>new yY(s)),s.addCustom("mobile-helper",()=>new WY(s)),s.addCustom("code-caret",()=>new eH(s)),s.addCustom("image-paste-handler",()=>new MA(s)),(R=t.componentsOptions)!=null&&R.mention){const X=t.componentsOptions.mention;s.addCustom("mention",()=>new eS(s,X))}if(s.addCustom("heading-collapse",()=>new ax(s)),s.addCustom(_g,X=>new gx(X)),Au.register(s),Wd.register(s),wl.register(s),vl.register(s),s.addListener("clickLink",(X,ct,xt)=>{var wt;if((wt=t==null?void 0:t.events)!=null&&wt.onClickLink){t.events.onClickLink(X,ct,xt);return}const bt=xt.getAttribute("link");bt&&(X.readonly||ct.ctrlKey||ct.metaKey)&&window.open(bt,"_blank")}),(O=(S=t.componentsOptions)==null?void 0:S.remoteCarets)!=null&&O.onUserChanged){const X=(V=(M=t.componentsOptions)==null?void 0:M.remoteCarets)==null?void 0:V.onUserChanged;s.doc.getRemoteUsers().on("change",ct=>{X(s,ct)})}return(Q=(J=t.componentsOptions)==null?void 0:J.templates)!=null&&Q.templates.length&&(s.addListener("docChanged",()=>{Dg(s)}),s.addListener("resize",()=>{Dg(s,{reset:!0})}),setTimeout(()=>{Dg(s)},100)),s.doc.registerCallback({onError:async X=>{if(X.code==="ResetDoc"){kx.error(`reset doc: ${X.message}`);const ct=await hd.load(r);s.doc.reset(ct)}}}),s.version="1.1.17-beta.12",di.level===Wo.DEBUG&&(window.setReauthFail=X=>{window.isReauthError=X},window.reConnect=X=>s.doc.externalDoc.client.connection.reConnect(X)),s}function vtt(n){return n.toJSON!==void 0}async function Btt(n,t,e){var s,o,l,c,d,h,C,E;p(kx,n,"app does not exists");const r=vtt(t)?t:new AC(t,{serverUrl:e.serverUrl||""});e.lang&&_.setLang(e.lang),di.level=(s=e.logLevel)!=null?s:Wo.DEBUG;const i=Zf(n,r,{id:e.id,scrollContainer:e==null?void 0:e.scrollContainer,components:{blocks:[lA,gA,pA,kk,...(l=(o=e.components)==null?void 0:o.blocks)!=null?l:[]],commandProviders:[new Mm],decorators:[new og,new VC],embeds:[...Tx,...((c=e.components)==null?void 0:c.embeds)||[]],boxes:[Pk,nS,y4,Hk,...((d=e.components)==null?void 0:d.boxes)||[]],insertions:[K1],blockHooks:[new SA,...((h=e.components)==null?void 0:h.blockHooks)||[]],textRenders:[new C4,new $E,...((C=e.components)==null?void 0:C.textRenders)||[]],options:{...e.componentsOptions}},shortcuts:[aA,Hw,nA,nm]});return i.editorCommandProviders.registerCommandProvider(new hs(i)),i.input.addHandler(new ag),i.input.addHandler(new CA(i,{hideTitle:e.hideTitle,headingLevel:1,titlePlaceholder:_.t("placeholder.common.title"),contentPlaceholder:_.t("placeholder.common.content"),readonlyTitlePlaceholder:_.t("placeholder.local.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),i.input.addHandler(new tg(i,(E=e.componentsOptions)==null?void 0:E.quickMenu)),i.input.addHandler(new UA(i)),i.input.addHandler(new VA(i)),i.input.addHandler(new dg),i.addCustom("block-menu",A=>new rw(A)),Ae.isMobile||i.addCustom("editor-tooltip",()=>new Sd(i)),i.addCustom("image-paste-handler",()=>new MA(i)),e!=null&&e.enableComments&&i.addCustom("editor-comments",A=>new p4(A,new EZ(A,r))),e.enableContextMenu!==!1&&i.addCustom("editor-context-menu",A=>new jA(A)),i.addCustom("heading-collapse",()=>new ax(i)),i.addListener("clickLink",(A,v,R)=>{var O;if((O=e==null?void 0:e.events)!=null&&O.onClickLink){e.events.onClickLink(A,v,R);return}const S=R.getAttribute("link");S&&(A.readonly||v.ctrlKey||v.metaKey)&&window.open(S,"_blank")}),i.addCustom(_g,A=>new gx(A)),Au.register(i),i.version="1.1.17-beta.12",i}async function Ttt(n,t,e){var h;const r=n.doc.externalDoc.client.auth,i=await hm.load({auth:r,serverUrl:e});if(!((h=i.getVersionHelper)==null?void 0:h.call(i)))throw new Error("the editor does not support to show versions");const o=n.getCustom("create-options");if(!o)throw new Error("the editor does not support to show versions");const l=o.getData(),c=new US(l),d=n.addCustom("version-dialog",()=>new V4(i,c));return d.show(t),d}b.tippy=e9,b.AnchorBox=TB,b.AuthError=fd,b.AuthHeader=Ea,b.AutoScroll=C0,b.BaseURLHeader=eu,b.BasicCommands=JF,b.BlockExclusiveHook=tw,b.BlockLockerHook=SA,b.BlockLockerPasteHandler=dg,b.BlockResizer=Nd,b.BrBox=xB,b.CodeBlock=gA,b.CodeLineBlock=pA,b.CodeTextDecorator=og,b.DOC_RE_AUTH_KEYS=_g,b.DefaultShortcuts=nm,b.DocIdError=GU,b.DocReAuthCallbacks=gx,b.DragDrop=Wb,b.DrawioEmbed=vS,b.EditorBlocks=r3,b.EditorBoxes=vB,b.EditorCommandProviders=AT,b.EditorComplexBlockPosition=Ai,b.EditorComplexSelectionRange=Qi,b.EditorDecorators=wB,b.EditorEmbeds=s3,b.EditorInsertions=RB,b.EditorSimpleBlockPosition=hn,b.EditorSimpleSelectionRange=xn,b.EmbedBlock=l3,b.EmbedBlockResizer=eh,b.EnforceWithDocumentTitleHandler=CA,b.EventCallbacks=Sc,b.FILL_CHAR=p8,b.FileExtError=WU,b.GroupOrder=Lk,b.HeadingBlockScrollListener=EY,b.ImageBox=BB,b.InlineBoxCommandProvider=jk,b.InputtingInsertion=yB,b.LocalDoc=AC,b.LogLevel=Wo,b.Logger=di,b.MIN_DISTANCE_THRESHOLD=zb,b.ManualCloseDialog=gd,b.ManualMenu=fl,b.ManualToolbar=md,b.MarkdownInputHandler=ag,b.MaxUserError=DC,b.Mindmap=Gm,b.OnesEditorAutoSuggest=aE,b.OnesEditorCustomDataWrapper=Sb,b.OnesEditorExclusiveBlock=vl,b.OnesEditorHoveringBlock=He,b.OnesEditorIcons=DO,b.OnesEditorQuickMenu=tg,b.OnesEditorToc=ih,b.OnesEditorTocProvider=wl,b.OnesEditorToolbar=Au,b.OnesEditorTooltip=Sd,b.OnesEditorVersionsDialog=V4,b.PermissionError=dm,b.Popup=su,b.ReAuthToolbar=uS,b.RemoteCarets=sy,b.RemoteCaretsDecorator=VC,b.RemoteCaretsInsertion=K1,b.RemoteUsers=td,b.RequestReloadError=dd,b.RichText=$n,b.ShareDBDoc=hd,b.ShareDBDocVersionsProvider=US,b.ShareDBServer=hm,b.SimpleCache=Nb,b.StandardEmbedBlockCommands=tx,b.TEXT_STYLE_BACKGROUND_COLOR_PREFIX=A1,b.TEXT_STYLE_COLOR_PREFIX=E1,b.TableBlock=lA,b.TableBlockCommandProvider=Mm,b.TableShortcuts=aA,b.TextBlock=lr,b.TextBox=AB,b.TextColorItem=B2,b.TextStyleShortcuts=nA,b.TocEmbed=Z4,b.ZERO_WIDTH_SPACE_CHAR=xf,b.abbreviation=E0,b.addAttribute=R0,b.addClass=q,b.addCommentToBlock=th,b.addDays=uI,b.addMetaToDoc=Qf,b.addMonths=cI,b.animateScrollTo=ea,b.applyPlaceholderToBlock=Ud,b.assert=p,b.autoShowHideTemplates=Dg,b.bindKeyDownEvent=c0,b.blockToDoc=hC,b.blockToHtml=H1,b.blockToMarkdown=H0,b.blockToText=$0,b.blocksToDoc=$5,b.clearAllSelection=Nv,b.clientType=Ae,b.cloneBlock=il,b.cloneChildContainer=Z1,b.cloneDoc=tC,b.cloneText=uB,b.commentToShareDbComment=KC,b.compareElement=l0,b.comparePosition=u1,b.complexBlockAdjustSelectionPos=T0,b.complexBlockFindNearestChildBlock=a7,b.complexBlockGetAllChildContainers=Ln,b.complexBlockGetBottomChildContainers=f3,b.complexBlockGetDeepFirstChild=a3,b.complexBlockGetFirstSimpleChild=d1,b.complexBlockGetLastSimpleChild=Nc,b.complexBlockGetSelectedContainers=Oc,b.complexBlockGetTopChildContainers=u3,b.containerToDoc=H5,b.continuousScroll=cv,b.convertBlockFrom=v0,b.convertImageFileToPng=oS,b.convertImageSrcToPng=VY,b.converterIntercept=lg,b.copyBlockAttributes=KB,b.copyResourcesFromDoc=EC,b.createBlockAnchor=$s,b.createBlockCaretAnchor=h3,b.createBlockContentElement=aa,b.createBlockElement=wv,b.createBlockSimpleDocRange=N0,b.createBlockSimpleRange=Oe,b.createBoxContentElement=Iv,b.createBoxElement=Sv,b.createBoxOp=cB,b.createChildContainer=e3,b.createComplexBlockPosition=De,b.createComplexDocPos=gB,b.createComplexDocRange=A8,b.createContainer=dB,b.createContainerElement=qp,b.createDeleteOps=sB,b.createEditor=Zf,b.createEditorSelectionRange=mn,b.createElement=B,b.createEmptyContainer=qs,b.createEmptyDoc=Ws,b.createEmptyTextBlockData=U0,b.createExpandedRange=s0,b.createIconButton=Jl,b.createImage=wp,b.createInsertOps=_0,b.createInsertionContentElement=Mv,b.createInsertionElement=Dv,b.createLocalEditor=Btt,b.createOnesEditor=btt,b.createRange=Pb,b.createRichText=ma,b.createRootContainer=t3,b.createSimpleBlockPosition=ht,b.createSimpleDocPos=mB,b.createTextBlockData=es,b.createTextButton=Ra,b.createTextOp=Gr,b.createTextWithReplaceSoftReturn=I1,b.daysAfter=Hp,b.deleteText=_1,b.diffDays=fI,b.disablePageScroll=Kp,b.docToHtml=UB,b.docToHtmlFragment=jf,b.docToMarkdown=OB,b.docToText=rl,b.downloadImageToFile=cS,b.downloadObjectToFile=Ex,b.downloadSvgToString=hS,b.editLink=kd,b.editorAddComment=bq,b.editorAddTextAttribute=QB,b.editorAutoInsertBlock=VB,b.editorBreakTextBlock=Wc,b.editorClearCompositionText=W1,b.editorClearSelectedContents=q0,b.editorCopyBlock=pC,b.editorCopyDoc=em,b.editorDeleteBlock=Y1,b.editorDeleteBlockText=q1,b.editorDeleteBlockWithoutChildren=G0,b.editorDeleteChildContainer=C_,b.editorDeleteChildContainers=$B,b.editorFocusToBlock=J1,b.editorFocusToEnd=O_,b.editorGetBlockData=nl,b.editorGetBlockText=Qn,b.editorGetBlockTextEx=F0,b.editorGetBoxData=CB,b.editorHandleKeyboardEvent=eT,b.editorInsertBlock=Gc,b.editorInsertBoxToBlock=PB,b.editorInsertDoc=XB,b.editorInsertDocAt=eC,b.editorInsertText=G1,b.editorInsertTextToBlock=NB,b.editorInsertTextToBlockEx=z1,b.editorMergeTextBlock=HB,b.editorMoveDown=u5,b.editorMoveEnd=aC,b.editorMoveHome=x5,b.editorMoveLeft=l5,b.editorMoveLineEnd=w5,b.editorMoveLineHome=R5,b.editorMovePageDown=M5,b.editorMovePageUp=_5,b.editorMoveRight=a5,b.editorMoveUp=c5,b.editorMoveWordEnd=C5,b.editorMoveWordLeft=p5,b.editorRangeClearColor=ZB,b.editorRangeGetColor=t5,b.editorRangeSetColor=JB,b.editorRemoveTextAttribute=b_,b.editorReplaceBlockText=X0,b.editorReplaceContainer=YB,b.editorRunOnce=xC,b.editorSelectAll=uC,b.editorSelectContainer=J0,b.editorSelectDown=f5,b.editorSelectEnd=cC,b.editorSelectHome=b5,b.editorSelectLeft=d5,b.editorSelectLineEnd=k5,b.editorSelectLineHome=y5,b.editorSelectPageDown=N5,b.editorSelectPageUp=O5,b.editorSelectRight=h5,b.editorSelectUp=m5,b.editorSelectWordEnd=A5,b.editorSelectWordLeft=E5,b.editorSetTextColor=qc,b.editorShowFindDialog=hW,b.editorToDocx=xtt,b.editorUpdateBlockData=Y0,b.editorUpdateCompositionText=FB,b.editorUpdateEmbedData=WB,b.enablePageScroll=Vp,b.escapeHtmlText=u0,b.escapeRegExp=Wp,b.escapeSpace=G9,b.exclusiveBlock=kA,b.executeBlockCommand=Gv,b.executeEmbedBlockCommand=zv,b.executeRangeCommand=ET,b.fileToDataUrl=Dc,b.findAfterOffsetNotType=N1,b.findAllText=fC,b.findBlockByIndex=xv,b.findEventTargetBlock=Vb,b.findInsertionById=_v,b.findNextOffset=F8,b.findNextVisibleSimpleBlock=BT,b.findPrevOffset=P8,b.findPrevOffsetNotType=O1,b.findPrevSimpleBlockBeforeChildContainer=c3,b.findPrevVisibleSimpleBlock=vT,b.findTarget=Ic,b.findWordEnd=F1,b.findWordLeft=P1,b.format=kf,b.formatBytes=uv,b.formatDate=zp,b.fragmentToHtml=iv,b.fromBase64=vf,b.fromBase64ToBlob=Pp,b.fromBase64ToUint8Array=rI,b.fromDocRange=Zo,b.fromNowString=Gp,b.genId=it,b.getAllChildBlocks=p1,b.getAllQuickMenuItems=eA,b.getAllSelectedBlocks=Ji,b.getAttributesAt=Vc,b.getBlockBackground=Qp,b.getBlockByIndex=Xo,b.getBlockCaretRect=Qo,b.getBlockClass=le,b.getBlockClassByType=sa,b.getBlockClientRects=Fs,b.getBlockCommandsWithHook=i1,b.getBlockContent=jt,b.getBlockHeading=If,b.getBlockId=dt,b.getBlockIndex=Rt,b.getBlockInfo=$d,b.getBlockKind=pi,b.getBlockMinWidth=Fv,b.getBlockNearestRangeFromPoint=m1,b.getBlockOptions=TI,b.getBlockPath=Jo,b.getBlockProperties=$v,b.getBlockRangeFromPoint=y0,b.getBlockStyles=BI,b.getBlockTextLength=Ct,b.getBlockTools=xe,b.getBlockType=Ot,b.getBoxContent=Zp,b.getBoxId=Lv,b.getBoxTypeFromElement=Lf,b.getChildBlockCount=gi,b.getChildBlocks=ye,b.getChildOffset=tl,b.getColorFromAttributes=b1,b.getColorFromContent=A0,b.getComplexBlockClass=Vr,b.getContainerBlockPath=Qv,b.getContainerBlocks=Ov,b.getContainerBlocksElement=wf,b.getContainerById=mi,b.getContainerId=pt,b.getContainerMinWidth=a1,b.getContainerToolsElement=xI,b.getContainerWidth=n3,b.getDistanceSquare=qo,b.getElementFromPoint=Me,b.getElementOffset=Af,b.getElementScale=Kr,b.getEmbedType=sn,b.getExistsBlockTools=x0,b.getExistsContainerById=Rf,b.getFileExt=yf,b.getFirstChildBlock=Ue,b.getFirstClientRect=o0,b.getHeadingBlockChildren=Uc,b.getHeadingMenuOptions=XE,b.getHorizontalPadding=Lp,b.getInsertionContent=t1,b.getLastChildBlock=Qe,b.getLastClientRect=Zl,b.getListAllNextBrothers=mu,b.getLogger=D,b.getNextBlock=ae,b.getNextHiddenBlocks=Xv,b.getNextValidOffset=da,b.getNextVisibleBlock=Hr,b.getOffsetFromPoint=Sp,b.getOffsetInfoAfter=Vf,b.getOffsetInfoBefore=K0,b.getOpAt=F3,b.getOpLength=k0,b.getParentBlock=nt,b.getParentBlockExcludeSelf=la,b.getParentBox=Jp,b.getParentContainer=at,b.getPrevBlock=Je,b.getPrevValidOffset=el,b.getPrevVisibleBlock=$r,b.getRangeCommands=pT,b.getReferenceClientRect=nk,b.getRootBlock=r1,b.getScrollContainer=dn,b.getSpecialBlockCommands=Hv,b.getStandardEmbedBlockProperties=ex,b.getTextAfterOffset=O8,b.getTextAttributes=j1,b.getTextBeforeOffset=N8,b.getTextBlockChild=Mf,b.getTextBlockClass=vv,b.getTextBlockContentChildTextLength=zr,b.getTextBlockContentChildType=Yv,b.getTextBlockContentChildren=Yi,b.getTextLength=Vn,b.getTextOpLength=C1,b.getTextWidth=m0,b.getToolbar=Km,b.handleBlockElementUpdated=Kv,b.hasAltOnly=J9,b.hasClass=Mt,b.hasCtrlOrCmd=Zb,b.hasCtrlOrCmdOnly=Q9,b.hashCode=Cv,b.hideBlock=Rv,b.hideTemplates=sS,b.htmlToFragment=h0,b.i18n=_,b.includeBigTable=aN,b.injectDocToHtmlFragment=Yf,b.injectStyle=jb,b.inputActions=nM,b.insertEmptyBlock=RI,b.insertEmptyEmbedBlock=s1,b.insertText=Gs,b.intersectionCommands=UM,b.isBackspace=ev,b.isBlock=oa,b.isBlockLocked=fg,b.isBlockLockedByOthers=wA,b.isBlockLockedBySelf=Hd,b.isBlockTools=kv,b.isBox=b0,b.isBoxOp=Hs,b.isCJK=Qb,b.isChildContainer=Ei,b.isChildNode=pe,b.isCodeBlock=Di,b.isCollapsedHeadingBlock=Xi,b.isCollapsedRange=E8,b.isComplexBlockPosition=ua,b.isComplexKindBlock=Pt,b.isContainer=Ps,b.isContainerSelectedAllChildBlocks=P5,b.isControlEvent=ra,b.isDelete=tI,b.isDraggingFiles=g0,b.isElementVisible=_p,b.isEmbedBlock=Se,b.isEmptyContainer=Uf,b.isEmptyDoc=M1,b.isEmptyTextBlock=be,b.isEmptyTextBlockWithoutCompositionText=Md,b.isEnterOnly=tv,b.isEscape=d0,b.isExclusiveBlock=Vd,b.isExpandedHeadingBlock=qv,b.isFirefox=Cf,b.isFirstChildBlockInComplexBlock=l7,b.isHeadingBlock=Sn,b.isHighSurrogate=$9,b.isInBlock=e1,b.isInBlockTools=Mc,b.isLetter=Yb,b.isLowSurrogate=H9,b.isMatchShortcut=Wi,b.isMoveForward=X9,b.isNavigationEvent=q9,b.isNavigationKey=Jb,b.isNodeRemoved=Ef,b.isNumber=Xb,b.isPrintableKey=Op,b.isRootBlock=jr,b.isRootContainer=ie,b.isSafari=Ql,b.isSameDay=jp,b.isSelectBoxOnly=Ii,b.isShiftEnter=Z9,b.isShiftTab=nI,b.isShortcutEvent=Y9,b.isSimpleBlock=vI,b.isSimpleBlockPosition=xi,b.isSimplePos=hB,b.isSimpleRange=O0,b.isSpace=f0,b.isTab=eI,b.isTextBlockContentBoxChild=br,b.isTextBlockContentChild=Df,b.isTextBlockContentInsertionChild=Vs,b.isTextBlockContentTextChild=_f,b.isTextKindBlock=ot,b.isTextKindBlockType=Sf,b.isTitleBlock=Ns,b.isToday=fv,b.isValidOffset=or,b.isVisibleBlock=Yo,b.isYesterday=dv,b.loadJs=Kb,b.loadJsPromise=ta,b.lockers=hi,b.mergeCommands=Fm,b.mergeDocs=ga,b.mergeOps=D1,b.mergeText=m8,b.multiSplitText=V3,b.overflowText=hv,b.parseShortcut=nv,b.patchNode=Bf,b.pointInRect=na,b.rangeAddAttribute=Pf,b.rangeGetTextColor=q3,b.rangeRemoveAttribute=Kc,b.rangeSetTextColor=z3,b.rangeTransformText=H3,b.registerDragDrop=Mp,b.removeAttribute=x1,b.removeClass=ut,b.removeLastBr=u8,b.removePlaceholderFromBlock=kR,b.removeStyle=Hb,b.replaceAll=dI,b.replaceAllCaseInsensitive=hI,b.replaceAllText=K5,b.replaceText=M0,b.requestDownload=p0,b.resetListStart=pu,b.scrollIntoView=Hf,b.scrollable=av,b.selectFile=_c,b.selectedBlockToDoc=Z0,b.selectionToDoc=Xc,b.setAttributes=a0,b.setClipboardData=Tf,b.setClipboardDataByEvent=oI,b.setColorToAttributes=G3,b.setDataset=Ip,b.setDefaultCursor=bf,b.setStyles=Dp,b.shareDBCommentToDocObject=FC,b.shareDBDocCommentToComment=ry,b.shortcutToDisplayText=fn,b.showBlock=Yp,b.showDocVersions=Ttt,b.showTemplates=hx,b.splitText=sr,b.splitToThree=gn,b.stringToDataUrl=Fp,b.stringToObjectUrl=$p,b.subText=$3,b.textNodeOffsetFromPoint=Fb,b.titleFromEditor=aS,b.toBase64URL=qi,b.toMindmap=zm,b.toPlainText=ke,b.toPlainTextKeepLength=U1,b.trimChar=Up,b.unexclusiveBlock=RA,b.unicodeLength=j9,b.unicodeSubstr=z9,b.updateBlockSelection=Pv,b.updateOpAttributes=fB,b.updateTextBlockContent=U8,b.updateUrl=Np;for(const n in Fe)n!=="default"&&!b.hasOwnProperty(n)&&Object.defineProperty(b,n,{enumerable:!0,get:()=>Fe[n]});Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|