@reviseio/engine 0.0.0-stage → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/FONT-LICENSE-HAN-EXT-B.txt +91 -0
  3. package/FONT-LICENSE-KATEX.txt +95 -0
  4. package/FONT-LICENSE-LIBERATION.txt +102 -0
  5. package/FONT-LICENSE-NOTO-MULTILINGUAL.txt +93 -0
  6. package/FONT-LICENSE-NOTO-SANS-SC.txt +93 -0
  7. package/FONT-LICENSE-NOTO.txt +94 -0
  8. package/FONT-LICENSE-SOURCE-CODE-PRO.txt +94 -0
  9. package/FONT-LICENSE-SOURCE-SERIF-4.txt +93 -0
  10. package/LICENSE +141 -0
  11. package/README.md +11 -2
  12. package/THIRD-PARTY-NOTICES.md +3376 -0
  13. package/assets/historyMaterializeWorker-Kl0syEbc.js +618 -0
  14. package/chunks/AgentHtmlConverter-CnnB8-WI.js +379 -0
  15. package/chunks/AgentPageRenderViews-BTLjPZJQ.js +2 -0
  16. package/chunks/AgentPageRenderer-DLgUGrGy.js +180 -0
  17. package/chunks/BidiText-Bkp4Y90s.js +160 -0
  18. package/chunks/BlockDiff-B6-aJxHo.js +42 -0
  19. package/chunks/CanvasRenderer-C1Vegx9Y.js +110 -0
  20. package/chunks/ColorParserFull-BKH72fK8.js +446 -0
  21. package/chunks/DocumentCompare-C8295s35.js +6 -0
  22. package/chunks/DocumentLayout-CsU5MR-3.js +12 -0
  23. package/chunks/DocumentLayoutEngine-C62pyGVf.js +218 -0
  24. package/chunks/DocumentMutator-Bat_oLBQ.js +13 -0
  25. package/chunks/DocumentScrubber-BZQn_z92.js +21 -0
  26. package/chunks/DocumentSession-BDcazSEv.js +1 -0
  27. package/chunks/DocumentStylesheet-CEEt18sr.js +7 -0
  28. package/chunks/DocxConverter-BC31uYIL.js +1236 -0
  29. package/chunks/DocxGraft-L10HXM3U.js +8 -0
  30. package/chunks/HorizontalRuleOrnaments-gmUZ3R7Q.js +3 -0
  31. package/chunks/HtmlConverter-C5ihhZ6G.js +267 -0
  32. package/chunks/ListNumbering-Qlu6AuRZ.js +23 -0
  33. package/chunks/MarkdownConverter-DofaSeC4.js +57 -0
  34. package/chunks/MathRenderer-Bz9WEVvF.js +68 -0
  35. package/chunks/OdtConverter-c1fTWoAt.js +125 -0
  36. package/chunks/OfficeImportShared-CrOpHpJ-.js +30 -0
  37. package/chunks/PageNumeralFonts-BWzI061X.js +5 -0
  38. package/chunks/ParagraphDiffAnalysis-DrmStvmz.js +36 -0
  39. package/chunks/PdfConverter-DX7fsRH5.js +457 -0
  40. package/chunks/RtfConverter-hbJ2529G.js +186 -0
  41. package/chunks/TableBorders-DVhdvo6f.js +32 -0
  42. package/chunks/TableGrid-DbroRucl.js +12 -0
  43. package/chunks/TextDecoding-IPbuUqcC.js +2 -0
  44. package/chunks/TextFileDecoder-BZBBejlR.js +10 -0
  45. package/chunks/TxtConverter-YHv5FXWb.js +14 -0
  46. package/chunks/Typography-B4gndEdB.js +28 -0
  47. package/chunks/UnicodeUtils-CXtusU4g.js +10 -0
  48. package/chunks/XmlConverter-BRRluy9k.js +55 -0
  49. package/chunks/_commonjsHelpers-DaMA6jEr.js +2 -0
  50. package/chunks/_revise-sdk-lazy-harfbuzz-CDWdjF9f.js +1 -0
  51. package/chunks/base64-Di1bxoXD.js +1 -0
  52. package/chunks/browser-module-CFmqfGkE.js +1791 -0
  53. package/chunks/bundle.min-DRpfgV69.js +782 -0
  54. package/chunks/capture-i_dPkQIS.js +11 -0
  55. package/chunks/carrier-pYM9xf6x.js +6 -0
  56. package/chunks/chromeImageLayout-BiQ3Iz1-.js +18 -0
  57. package/chunks/engine-LMUnxdm2.js +520 -0
  58. package/chunks/footnoteFlatten-EE85Hjre.js +6 -0
  59. package/chunks/graftExport-G-dG7Vcc.js +104 -0
  60. package/chunks/html2canvas.esm-CntiHiYW.js +997 -0
  61. package/chunks/index-BLb10wQt.js +1002 -0
  62. package/chunks/index-BWdRWxoH.js +1807 -0
  63. package/chunks/index.es-CI0QPo8w.js +780 -0
  64. package/chunks/jspdf.es.min-DU74zN8b.js +1792 -0
  65. package/chunks/jszip.min-CPW0h1Kx.js +476 -0
  66. package/chunks/katex-DWj8TvwO.js +1462 -0
  67. package/chunks/pdf-BLWDCiFF.js +1828 -0
  68. package/chunks/purify.es-BwLardii.js +107 -0
  69. package/chunks/serverDocumentSession-DGDU5Lh3.js +1011 -0
  70. package/chunks/signatures-DTNDS2PH.js +21 -0
  71. package/chunks/suggestionAuthorship-B-IuLQlE.js +1 -0
  72. package/chunks/web-tree-sitter-BXGZGnNj.js +2 -0
  73. package/chunks/xmlScan-DXjt2cTS.js +8 -0
  74. package/engine.d.ts +179 -0
  75. package/engine.js +3 -0
  76. package/package.json +64 -4
  77. package/serverToolContract.d.ts +420 -0
  78. package/serverToolInputs.generated.d.ts +264 -0
@@ -0,0 +1,618 @@
1
+ (function(){"use strict";const U=()=>new Map,tn=e=>{const t=U();return e.forEach((n,r)=>{t.set(r,n)}),t},B=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},yi=(e,t)=>{const n=[];for(const[
2
+ r,s]of e)n.push(t(s,r));return n},wi=(e,t)=>{for(const[n,r]of e)if(t(r,n))return!0;return!1},Wt=()=>new Set,en=e=>e[e.length-1],ki=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},ft=Array.from,Si=(e,t)=>{
3
+ for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},_i=(e,t)=>{const n=new Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n},nn=Array.isArray;class rn{constructor(){this._observers=U()}on(t,n){
4
+ return B(this._observers,t,Wt).add(n),n}once(t,n){const r=(...s)=>{this.off(t,r),n(...s)};this.on(t,r)}off(t,n){const r=this._observers.get(t);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(
5
+ t))}emit(t,n){return ft((this._observers.get(t)||U()).values()).forEach(r=>r(...n))}destroy(){this._observers=U()}}const pt=Math.floor,Ce=Math.abs,Qn=(e,t)=>e<t?e:t,Ct=(e,t)=>e>t?e:t,tr=e=>e!==0?e<0:1/
6
+ e<0,er=1,nr=2,sn=4,on=8,ne=32,ct=64,F=128,vi=1<<29,Ee=31,cn=63,Et=127,xi=2147483647,rr=Number.MAX_SAFE_INTEGER,Ci=Number.isInteger||(e=>typeof e=="number"&&isFinite(e)&&pt(e)===e),Ei=e=>e.toLowerCase(),
7
+ Ai=/^\s*/g,Di=e=>e.replace(Ai,""),Pi=/([A-Z])/g,sr=(e,t)=>Di(e.replace(Pi,n=>`${t}${Ei(n)}`)),Ni=e=>{const t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=t.codePointAt(
8
+ s);return r},re=typeof TextEncoder<"u"?new TextEncoder:null,Ii=re?e=>re.encode(e):Ni;let se=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});se&&se.decode(new Uint8Array).length===
9
+ 1&&(se=null);const Mi=(e,t)=>_i(t,()=>e).join("");class ie{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Jt=()=>new ie,Ti=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)
10
+ t+=e.bufs[n].length;return t},H=e=>{const t=new Uint8Array(Ti(e));let n=0;for(let r=0;r<e.bufs.length;r++){const s=e.bufs[r];t.set(s,n),n+=s.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),
11
+ n),t},Oi=(e,t)=>{const n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(Ct(n,t)*2),e.cpos=0)},N=(e,t)=>{const n=e.cbuf.length;e.cpos===n&&(e.bufs.
12
+ push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},oe=N,m=(e,t)=>{for(;t>Et;)N(e,F|Et&t),t=pt(t/128);N(e,Et&t)},Ae=(e,t)=>{const n=tr(t);for(n&&(t=-t),N(e,(t>cn?F:0)|(n?ct:0)|cn&t),
13
+ t=pt(t/64);t>0;)N(e,(t>Et?F:0)|Et&t),t=pt(t/128)},ln=new Uint8Array(3e4),Ui=ln.length/3,Fi=(e,t)=>{if(t.length<Ui){const n=re.encodeInto(t,ln).written||0;m(e,n);for(let r=0;r<n;r++)N(e,ln[r])}else z(e,
14
+ Ii(t))},Li=(e,t)=>{const n=unescape(encodeURIComponent(t)),r=n.length;m(e,r);for(let s=0;s<r;s++)N(e,n.codePointAt(s))},At=re&&re.encodeInto?Fi:Li,Ri=(e,t)=>ce(e,H(t)),ce=(e,t)=>{const n=e.cbuf.length,
15
+ r=e.cpos,s=Qn(n-r,t.length),i=t.length-s;e.cbuf.set(t.subarray(0,s),r),e.cpos+=s,i>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(Ct(n*2,i)),e.cbuf.set(t.subarray(s)),e.cpos=i)},z=(e,t)=>{m(e,t.byteLength),
16
+ ce(e,t)},an=(e,t)=>{Oi(e,t);const n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},ji=(e,t)=>an(e,4).setFloat32(0,t,!1),Vi=(e,t)=>an(e,8).setFloat64(0,t,!1),Bi=(e,t)=>an(e,8).setBigInt64(0,t,
17
+ !1),ir=new DataView(new ArrayBuffer(4)),zi=e=>(ir.setFloat32(0,e),ir.getFloat32(0)===e),le=(e,t)=>{switch(typeof t){case"string":N(e,119),At(e,t);break;case"number":Ci(t)&&Ce(t)<=xi?(N(e,125),Ae(e,t)):
18
+ zi(t)?(N(e,124),ji(e,t)):(N(e,123),Vi(e,t));break;case"bigint":N(e,122),Bi(e,t);break;case"object":if(t===null)N(e,126);else if(nn(t)){N(e,117),m(e,t.length);for(let n=0;n<t.length;n++)le(e,t[n])}else if(t instanceof
19
+ Uint8Array)N(e,116),z(e,t);else{N(e,118);const n=Object.keys(t);m(e,n.length);for(let r=0;r<n.length;r++){const s=n[r];At(e,s),le(e,t[s])}}break;case"boolean":N(e,t?120:121);break;default:N(e,127)}};class or extends ie{constructor(t){
20
+ super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&m(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}}const cr=e=>{e.count>0&&(Ae(e.encoder,e.count===1?
21
+ e.s:-e.s),e.count>1&&m(e.encoder,e.count-2))};class De{constructor(){this.encoder=new ie,this.s=0,this.count=0}write(t){this.s===t?this.count++:(cr(this),this.count=1,this.s=t)}toUint8Array(){return cr(
22
+ this),H(this.encoder)}}const lr=e=>{if(e.count>0){const t=e.diff*2+(e.count===1?0:1);Ae(e.encoder,t),e.count>1&&m(e.encoder,e.count-2)}};class dn{constructor(){this.encoder=new ie,this.s=0,this.count=
23
+ 0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(lr(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return lr(this),H(this.encoder)}}class Wi{constructor(){this.sarr=
24
+ [],this.s="",this.lensE=new De}write(t){this.s+=t,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(t.length)}toUint8Array(){const t=new ie;return this.sarr.push(this.s),this.s="",
25
+ At(t,this.sarr.join("")),ce(t,this.lensE.toUint8Array()),H(t)}}const mt=e=>new Error(e),tt=()=>{throw mt("Method unimplemented")},j=()=>{throw mt("Unexpected case")},ar=mt("Unexpected end of array"),dr=mt(
26
+ "Integer out of Range");class Pe{constructor(t){this.arr=t,this.pos=0}}const T=e=>new Pe(e),hr=e=>e.pos!==e.arr.length,Ji=(e,t)=>{const n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.
27
+ pos+=t,n},W=e=>Ji(e,S(e)),Gt=e=>e.arr[e.pos++],S=e=>{let t=0,n=1;const r=e.arr.length;for(;e.pos<r;){const s=e.arr[e.pos++];if(t=t+(s&Et)*n,n*=128,s<F)return t;if(t>rr)throw dr}throw ar},Ne=e=>{let t=e.
28
+ arr[e.pos++],n=t&cn,r=64;const s=(t&ct)>0?-1:1;if((t&F)===0)return s*n;const i=e.arr.length;for(;e.pos<i;){if(t=e.arr[e.pos++],n=n+(t&Et)*r,r*=128,t<F)return s*n;if(n>rr)throw dr}throw ar},Dt=se?e=>se.
29
+ decode(W(e)):e=>{let t=S(e);if(t===0)return"";{let n=String.fromCodePoint(Gt(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Gt(e));else for(;t>0;){const r=t<1e4?t:1e4,s=e.arr.subarray(e.pos,e.pos+r);
30
+ e.pos+=r,n+=String.fromCodePoint.apply(null,s),t-=r}return decodeURIComponent(escape(n))}},hn=(e,t)=>{const n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Gi=[e=>{},e=>null,Ne,
31
+ e=>hn(e,4).getFloat32(0,!1),e=>hn(e,8).getFloat64(0,!1),e=>hn(e,8).getBigInt64(0,!1),e=>!1,e=>!0,Dt,e=>{const t=S(e),n={};for(let r=0;r<t;r++){const s=Dt(e);n[s]=ae(e)}return n},e=>{const t=S(e),n=[];
32
+ for(let r=0;r<t;r++)n.push(ae(e));return n},W],ae=e=>Gi[127-Gt(e)](e);class ur extends Pe{constructor(t,n){super(t),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(
33
+ this),hr(this)?this.count=S(this)+1:this.count=-1),this.count--,this.s}}class Ie extends Pe{constructor(t){super(t),this.s=0,this.count=0}read(){if(this.count===0){this.s=Ne(this);const t=tr(this.s);this.
34
+ count=1,t&&(this.s=-this.s,this.count=S(this)+2)}return this.count--,this.s}}class un extends Pe{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const t=Ne(this),n=t&
35
+ 1;this.diff=pt(t/2),this.count=1,n&&(this.count=S(this)+2)}return this.s+=this.diff,this.count--,this.s}}class Hi{constructor(t){this.decoder=new Ie(t),this.str=Dt(this.decoder),this.spos=0}read(){const t=this.
36
+ spos+this.decoder.read(),n=this.str.slice(this.spos,t);return this.spos=t,n}}const Xi=crypto.getRandomValues.bind(crypto),gr=()=>Xi(new Uint32Array(1))[0],qi="10000000-1000-4000-8000"+-1e11,$i=()=>qi.
37
+ replace(/[018]/g,e=>(e^gr()&15>>e/4).toString(16)),Ki=Date.now,fr=e=>new Promise(e);Promise.all.bind(Promise);const Yi=e=>e===void 0?null:e;class Zi{constructor(){this.map=new Map}setItem(t,n){this.map.
38
+ set(t,n)}getItem(t){return this.map.get(t)}}let pr=new Zi,Qi=!0;try{typeof localStorage<"u"&&localStorage&&(pr=localStorage,Qi=!1)}catch{}const to=pr,eo=Object.assign,no=Object.keys,ro=(e,t)=>{for(const n in e)
39
+ t(e[n],n)},mr=e=>no(e).length,so=e=>{for(const t in e)return!1;return!0},io=(e,t)=>{for(const n in e)if(!t(e[n],n))return!1;return!0},oo=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),co=(e,t)=>e===
40
+ t||mr(e)===mr(t)&&io(e,(n,r)=>(n!==void 0||oo(t,r))&&t[r]===n),lo=Object.freeze,br=e=>{for(const t in e){const n=e[t];(typeof n=="object"||typeof n=="function")&&br(e[t])}return lo(e)},gn=(e,t,n=0)=>{
41
+ try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&gn(e,t,n+1)}},yr=e=>e,ao=(e,t)=>t.includes(e),de=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.
42
+ toString.call(typeof process<"u"?process:0)==="[object process]";let et;const ho=()=>{if(et===void 0)if(de){et=U();const e=process.argv;let t=null;for(let n=0;n<e.length;n++){const r=e[n];r[0]==="-"?(t!==
43
+ null&&et.set(t,""),t=r):t!==null&&(et.set(t,r),t=null)}t!==null&&et.set(t,"")}else typeof location=="object"?(et=U(),(location.search||"?").slice(1).split("&").forEach(e=>{if(e.length!==0){const[t,n]=e.
44
+ split("=");et.set(`--${sr(t,"-")}`,n),et.set(`-${sr(t,"-")}`,n)}})):et=U();return et},fn=e=>ho().has(e),Me=e=>Yi(de?process.env[e.toUpperCase().replaceAll("-","_")]:to.getItem(e)),wr=e=>fn("--"+e)||Me(
45
+ e)!==null;wr("production");const uo=de&&ao(process.env.FORCE_COLOR,["true","1","2"])||!fn("--no-colors")&&!wr("no-color")&&(!de||process.stdout.isTTY)&&(!de||fn("--color")||Me("COLORTERM")!==null||(Me(
46
+ "TERM")||"").includes("color")),go=e=>new Uint8Array(e),fo=e=>{const t=go(e.byteLength);return t.set(e),t};class po{constructor(t,n){this.left=t,this.right=n}}const lt=(e,t)=>new po(e,t);typeof DOMParser<
47
+ "u"&&new DOMParser;const mo=e=>yi(e,(t,n)=>`${n}:${t};`).join(""),at=Symbol,kr=at(),Sr=at(),bo=at(),yo=at(),wo=at(),_r=at(),ko=at(),pn=at(),So=at(),_o=e=>{e.length===1&&e[0]?.constructor===Function&&(e=
48
+ e[0]());const t=[],n=[];let r=0;for(;r<e.length;r++){const s=e[r];if(s===void 0)break;if(s.constructor===String||s.constructor===Number)t.push(s);else if(s.constructor===Object)break}for(r>0&&n.push(t.
49
+ join(""));r<e.length;r++){const s=e[r];s instanceof Symbol||n.push(s)}return n},vo={[kr]:lt("font-weight","bold"),[Sr]:lt("font-weight","normal"),[bo]:lt("color","blue"),[wo]:lt("color","green"),[yo]:lt(
50
+ "color","grey"),[_r]:lt("color","red"),[ko]:lt("color","purple"),[pn]:lt("color","orange"),[So]:lt("color","black")},vr=uo?e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());const t=[],n=[],r=U();
51
+ let s=[],i=0;for(;i<e.length;i++){const o=e[i],c=vo[o];if(c!==void 0)r.set(c.left,c.right);else{if(o===void 0)break;if(o.constructor===String||o.constructor===Number){const l=mo(r);i>0||l.length>0?(t.
52
+ push("%c"+o),n.push(l)):t.push(o)}else break}}for(i>0&&(s=n,s.unshift(t.join("")));i<e.length;i++){const o=e[i];o instanceof Symbol||s.push(o)}return s}:_o,mn=(...e)=>{[...vr(e)],Cr.forEach(t=>t.print(
53
+ e))},xr=(...e)=>{console.warn(...vr(e)),e.unshift(pn),Cr.forEach(t=>t.print(e))},Cr=Wt(),Er=e=>({[Symbol.iterator](){return this},next:e}),xo=(e,t)=>Er(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));
54
+ return n}),bn=(e,t)=>Er(()=>{const{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}});class Co extends rn{constructor(t,n){super(),this.doc=t,this.awareness=n}}class yn{constructor(t,n){this.
55
+ clock=t,this.len=n}}class Ht{constructor(){this.clients=new Map}}const Pt=(e,t,n)=>t.clients.forEach((r,s)=>{const i=e.doc.store.clients.get(s);if(i!=null){const o=i[i.length-1],c=o.id.clock+o.length;
56
+ for(let l=0,d=r[l];l<r.length&&d.clock<c;d=r[++l])Gr(e,i,d.clock,d.len,n)}}),Eo=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){const s=pt((n+r)/2),i=e[s],o=i.clock;if(o<=t){if(t<o+i.len)return s;n=s+1}else r=
57
+ s-1}return null},Nt=(e,t)=>{const n=e.clients.get(t.client);return n!==void 0&&Eo(n,t.clock)!==null},wn=e=>{e.clients.forEach(t=>{t.sort((s,i)=>s.clock-i.clock);let n,r;for(n=1,r=1;n<t.length;n++){const s=t[r-
58
+ 1],i=t[n];s.clock+s.len>=i.clock?s.len=Ct(s.len,i.clock+i.len-s.clock):(r<n&&(t[r]=i),r++)}t.length=r})},It=e=>{const t=new Ht;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,s)=>{if(!t.clients.has(
59
+ s)){const i=r.slice();for(let o=n+1;o<e.length;o++)ki(i,e[o].clients.get(s)||[]);t.clients.set(s,i)}});return wn(t),t},he=(e,t,n,r)=>{B(e.clients,t,()=>[]).push(new yn(n,r))},Te=()=>new Ht,kn=e=>{const t=Te();
60
+ return e.clients.forEach((n,r)=>{const s=[];for(let i=0;i<n.length;i++){const o=n[i];if(o.deleted){const c=o.id.clock;let l=o.length;if(i+1<n.length)for(let d=n[i+1];i+1<n.length&&d.deleted;d=n[++i+1])
61
+ l+=d.length;s.push(new yn(c,l))}}s.length>0&&t.clients.set(r,s)}),t},nt=(e,t)=>{m(e.restEncoder,t.clients.size),ft(t.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{e.resetDsCurVal(),m(e.restEncoder,
62
+ n);const s=r.length;m(e.restEncoder,s);for(let i=0;i<s;i++){const o=r[i];e.writeDsClock(o.clock),e.writeDsLen(o.len)}})},dt=e=>{const t=new Ht,n=S(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();
63
+ const s=S(e.restDecoder),i=S(e.restDecoder);if(i>0){const o=B(t.clients,s,()=>[]);for(let c=0;c<i;c++)o.push(new yn(e.readDsClock(),e.readDsLen()))}}return t},Ar=(e,t,n)=>{const r=new Ht,s=S(e.restDecoder);
64
+ for(let i=0;i<s;i++){e.resetDsCurVal();const o=S(e.restDecoder),c=S(e.restDecoder),l=n.clients.get(o)||[],d=A(n,o);for(let a=0;a<c;a++){const h=e.readDsClock(),u=h+e.readDsLen();if(h<d){d<u&&he(r,o,d,
65
+ u-d);let g=q(l,h),f=l[g];for(!f.deleted&&f.id.clock<h&&(l.splice(g+1,0,Xe(t,f,h-f.id.clock)),g++);g<l.length&&(f=l[g++],f.id.clock<u);)f.deleted||(u<f.id.clock+f.length&&l.splice(g,0,Xe(t,f,u-f.id.clock)),
66
+ f.delete(t))}else he(r,o,h,u-h)}}if(r.clients.size>0){const i=new Y;return m(i.restEncoder,0),nt(i,r),i.toUint8Array()}return null},Dr=(e,t)=>{if(e.clients.size!==t.clients.size)return!1;for(const[n,r]of e.
67
+ clients.entries()){const s=t.clients.get(n);if(s===void 0||r.length!==s.length)return!1;for(let i=0;i<r.length;i++){const o=r[i],c=s[i];if(o.clock!==c.clock||o.len!==c.len)return!1}}return!0},Pr=gr;class rt extends rn{constructor({
68
+ guid:t=$i(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:c=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=Pr(),this.guid=t,this.collectionid=n,this.share=
69
+ new Map,this.store=new Wr,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.
70
+ isDestroyed=!1,this.whenLoaded=fr(d=>{this.on("load",()=>{this.isLoaded=!0,d(this)})});const l=()=>fr(d=>{const a=h=>{(h===void 0||h===!0)&&(this.off("sync",a),d())};this.on("sync",a)});this.on("sync",
71
+ d=>{d===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=d===void 0||d===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const t=this._item;t!==null&&!this.
72
+ shouldLoad&&E(t.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(ft(this.subdocs).map(t=>t.guid))}transact(t,n=null){
73
+ return E(this,t,n)}get(t,n=P){const r=B(this.share,t,()=>{const i=new n;return i._integrate(this,null),i}),s=r.constructor;if(n!==P&&s!==n)if(s===P){const i=new n;i._map=r._map,r._map.forEach(o=>{for(;o!==
74
+ null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(t,i),i._integrate(this,null),i}else throw new Error(`Type with t\
75
+ he name ${t} has already been defined with a different constructor`);return r}getArray(t=""){return this.get(t,ht)}getText(t=""){return this.get(t,Ut)}getMap(t=""){return this.get(t,St)}getXmlElement(t=""){
76
+ return this.get(t,st)}getXmlFragment(t=""){return this.get(t,vt)}toJSON(){const t={};return this.share.forEach((n,r)=>{t[r]=n.toJSON()}),t}destroy(){this.isDestroyed=!0,ft(this.subdocs).forEach(n=>n.destroy());
77
+ const t=this._item;if(t!==null){this._item=null;const n=t.content;n.doc=new rt({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,E(t.parent.doc,r=>{const s=n.doc;t.deleted||r.subdocsAdded.add(s),
78
+ r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class ue{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return S(this.restDecoder)}readDsLen(){
79
+ return S(this.restDecoder)}}class X extends ue{readLeftID(){return y(S(this.restDecoder),S(this.restDecoder))}readRightID(){return y(S(this.restDecoder),S(this.restDecoder))}readClient(){return S(this.
80
+ restDecoder)}readInfo(){return Gt(this.restDecoder)}readString(){return Dt(this.restDecoder)}readParentInfo(){return S(this.restDecoder)===1}readTypeRef(){return S(this.restDecoder)}readLen(){return S(
81
+ this.restDecoder)}readAny(){return ae(this.restDecoder)}readBuf(){return fo(W(this.restDecoder))}readJSON(){return JSON.parse(Dt(this.restDecoder))}readKey(){return Dt(this.restDecoder)}}class Nr{constructor(t){
82
+ this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=S(this.restDecoder),this.dsCurrVal}readDsLen(){const t=S(this.restDecoder)+1;return this.dsCurrVal+=
83
+ t,t}}class J extends Nr{constructor(t){super(t),this.keys=[],S(t),this.keyClockDecoder=new un(W(t)),this.clientDecoder=new Ie(W(t)),this.leftClockDecoder=new un(W(t)),this.rightClockDecoder=new un(W(t)),
84
+ this.infoDecoder=new ur(W(t),Gt),this.stringDecoder=new Hi(W(t)),this.parentInfoDecoder=new ur(W(t),Gt),this.typeRefDecoder=new Ie(W(t)),this.lenDecoder=new Ie(W(t))}readLeftID(){return new Mt(this.clientDecoder.
85
+ read(),this.leftClockDecoder.read())}readRightID(){return new Mt(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.
86
+ read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){
87
+ return ae(this.restDecoder)}readBuf(){return W(this.restDecoder)}readJSON(){return ae(this.restDecoder)}readKey(){const t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{const n=this.
88
+ stringDecoder.read();return this.keys.push(n),n}}}class Xt{constructor(){this.restEncoder=Jt()}toUint8Array(){return H(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){m(this.restEncoder,t)}writeDsLen(t){
89
+ m(this.restEncoder,t)}}class bt extends Xt{writeLeftID(t){m(this.restEncoder,t.client),m(this.restEncoder,t.clock)}writeRightID(t){m(this.restEncoder,t.client),m(this.restEncoder,t.clock)}writeClient(t){
90
+ m(this.restEncoder,t)}writeInfo(t){oe(this.restEncoder,t)}writeString(t){At(this.restEncoder,t)}writeParentInfo(t){m(this.restEncoder,t?1:0)}writeTypeRef(t){m(this.restEncoder,t)}writeLen(t){m(this.restEncoder,
91
+ t)}writeAny(t){le(this.restEncoder,t)}writeBuf(t){z(this.restEncoder,t)}writeJSON(t){At(this.restEncoder,JSON.stringify(t))}writeKey(t){At(this.restEncoder,t)}}class Oe{constructor(){this.restEncoder=
92
+ Jt(),this.dsCurrVal=0}toUint8Array(){return H(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){const n=t-this.dsCurrVal;this.dsCurrVal=t,m(this.restEncoder,n)}writeDsLen(t){t===0&&j(),
93
+ m(this.restEncoder,t-1),this.dsCurrVal+=t}}class Y extends Oe{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new dn,this.clientEncoder=new De,this.leftClockEncoder=new dn,
94
+ this.rightClockEncoder=new dn,this.infoEncoder=new or(oe),this.stringEncoder=new Wi,this.parentInfoEncoder=new or(oe),this.typeRefEncoder=new De,this.lenEncoder=new De}toUint8Array(){const t=Jt();return m(
95
+ t,0),z(t,this.keyClockEncoder.toUint8Array()),z(t,this.clientEncoder.toUint8Array()),z(t,this.leftClockEncoder.toUint8Array()),z(t,this.rightClockEncoder.toUint8Array()),z(t,H(this.infoEncoder)),z(t,this.
96
+ stringEncoder.toUint8Array()),z(t,H(this.parentInfoEncoder)),z(t,this.typeRefEncoder.toUint8Array()),z(t,this.lenEncoder.toUint8Array()),ce(t,H(this.restEncoder)),H(t)}writeLeftID(t){this.clientEncoder.
97
+ write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.
98
+ infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){
99
+ le(this.restEncoder,t)}writeBuf(t){z(this.restEncoder,t)}writeJSON(t){le(this.restEncoder,t)}writeKey(t){const n=this.keyMap.get(t);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.
100
+ write(t)):this.keyClockEncoder.write(n)}}const Ao=(e,t,n,r)=>{r=Ct(r,t[0].id.clock);const s=q(t,r);m(e.restEncoder,t.length-s),e.writeClient(n),m(e.restEncoder,r);const i=t[s];i.write(e,r-i.id.clock);
101
+ for(let o=s+1;o<t.length;o++)t[o].write(e,0)},Sn=(e,t,n)=>{const r=new Map;n.forEach((s,i)=>{A(t,i)>s&&r.set(i,s)}),fe(t).forEach((s,i)=>{n.has(i)||r.set(i,0)}),m(e.restEncoder,r.size),ft(r.entries()).
102
+ sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{Ao(e,t.clients.get(s),s,i)})},Do=(e,t)=>{const n=U(),r=S(e.restDecoder);for(let s=0;s<r;s++){const i=S(e.restDecoder),o=new Array(i),c=e.readClient();let l=S(e.
103
+ restDecoder);n.set(c,{i:0,refs:o});for(let d=0;d<i;d++){const a=e.readInfo();switch(Ee&a){case 0:{const h=e.readLen();o[d]=new V(y(c,l),h),l+=h;break}case 10:{const h=S(e.restDecoder);o[d]=new L(y(c,l),
104
+ h),l+=h;break}default:{const h=(a&(ct|F))===0,u=new x(y(c,l),null,(a&F)===F?e.readLeftID():null,null,(a&ct)===ct?e.readRightID():null,h?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,h&&
105
+ (a&ne)===ne?e.readString():null,Fs(e,a));o[d]=u,l+=u.length}}}}return n},Po=(e,t,n)=>{const r=[];let s=ft(n.keys()).sort((g,f)=>g-f);if(s.length===0)return null;const i=()=>{if(s.length===0)return null;
106
+ let g=n.get(s[s.length-1]);for(;g.refs.length===g.i;)if(s.pop(),s.length>0)g=n.get(s[s.length-1]);else return null;return g};let o=i();if(o===null)return null;const c=new Wr,l=new Map,d=(g,f)=>{const p=l.
107
+ get(g);(p==null||p>f)&&l.set(g,f)};let a=o.refs[o.i++];const h=new Map,u=()=>{for(const g of r){const f=g.id.client,p=n.get(f);p?(p.i--,c.clients.set(f,p.refs.slice(p.i)),n.delete(f),p.i=0,p.refs=[]):
108
+ c.clients.set(f,[g]),s=s.filter(_=>_!==f)}r.length=0};for(;;){if(a.constructor!==L){const g=B(h,a.id.client,()=>A(t,a.id.client))-a.id.clock;if(g<0)r.push(a),d(a.id.client,a.id.clock-1),u();else{const f=a.
109
+ getMissing(e,t);if(f!==null){r.push(a);const p=n.get(f)||{refs:[],i:0};if(p.refs.length===p.i)d(f,A(t,f)),u();else{a=p.refs[p.i++];continue}}else(g===0||g<a.length)&&(a.integrate(e,g),h.set(a.id.client,
110
+ a.id.clock+a.length))}}if(r.length>0)a=r.pop();else if(o!==null&&o.i<o.refs.length)a=o.refs[o.i++];else{if(o=i(),o===null)break;a=o.refs[o.i++]}}if(c.clients.size>0){const g=new Y;return Sn(g,c,new Map),
111
+ m(g.restEncoder,0),{missing:l,update:g.toUint8Array()}}return null},No=(e,t)=>Sn(e,t.doc.store,t.beforeState),_n=(e,t,n,r=new J(e))=>E(t,s=>{s.local=!1;let i=!1;const o=s.doc,c=o.store,l=Do(r,o),d=Po(
112
+ s,c,l),a=c.pendingStructs;if(a){for(const[u,g]of a.missing)if(g<A(c,u)){i=!0;break}if(d){for(const[u,g]of d.missing){const f=a.missing.get(u);(f==null||f>g)&&a.missing.set(u,g)}a.update=pe([a.update,d.
113
+ update])}}else c.pendingStructs=d;const h=Ar(r,s,c);if(c.pendingDs){const u=new J(T(c.pendingDs));S(u.restDecoder);const g=Ar(u,s,c);h&&g?c.pendingDs=pe([h,g]):c.pendingDs=h||g}else c.pendingDs=h;if(i){
114
+ const u=c.pendingStructs.update;c.pendingStructs=null,Ue(s.doc,u)}},n,!1),Io=(e,t,n)=>_n(e,t,n,new X(e)),Ue=(e,t,n,r=J)=>{const s=T(t);_n(s,e,n,new r(s))},Ir=(e,t,n)=>Ue(e,t,n,X),Mo=(e,t,n=new Map)=>{
115
+ Sn(e,t.store,n),nt(e,kn(t.store))},Mr=(e,t=new Uint8Array([0]),n=new Y)=>{const r=vn(t);Mo(n,e,r);const s=[n.toUint8Array()];if(e.store.pendingDs&&s.push(e.store.pendingDs),e.store.pendingStructs&&s.push(
116
+ Mn(e.store.pendingStructs.update,t)),s.length>1){if(n.constructor===bt)return ns(s.map((i,o)=>o===0?i:cs(i)));if(n.constructor===Y)return pe(s)}return s[0]},To=(e,t)=>Mr(e,t,new bt),Tr=e=>{const t=new Map,
117
+ n=S(e.restDecoder);for(let r=0;r<n;r++){const s=S(e.restDecoder),i=S(e.restDecoder);t.set(s,i)}return t},vn=e=>Tr(new ue(T(e))),xn=(e,t)=>(m(e.restEncoder,t.size),ft(t.entries()).sort((n,r)=>r[0]-n[0]).
118
+ forEach(([n,r])=>{m(e.restEncoder,n),m(e.restEncoder,r)}),e),Oo=(e,t)=>xn(e,fe(t.store)),Uo=(e,t=new Oe)=>(e instanceof Map?xn(t,e):Oo(t,e),t.toUint8Array()),Fo=e=>Uo(e,new Xt);class Lo{constructor(){
119
+ this.l=[]}}const Or=()=>new Lo,Ur=(e,t)=>e.l.push(t),Fr=(e,t)=>{const n=e.l,r=n.length;e.l=n.filter(s=>t!==s),r===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},
120
+ Lr=(e,t,n)=>gn(e.l,[t,n]);class Mt{constructor(t,n){this.client=t,this.clock=n}}const Tt=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,y=(e,t)=>new Mt(e,t),Rr=(e,t)=>{m(e,t.
121
+ client),m(e,t.clock)},jr=e=>y(S(e),S(e)),Cn=e=>{for(const[t,n]of e.doc.share.entries())if(n===e)return t;throw j()},ge=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},Ro=e=>{
122
+ const t=[];let n=e._start;for(;n;)t.push(n),n=n.right;t.filter(r=>!r.deleted).map(r=>r.content)};class jo{constructor(t,n=t.getMap("users")){const r=new Map;this.yusers=n,this.doc=t,this.clients=new Map,
123
+ this.dss=r;const s=(i,o)=>{const c=i.get("ds"),l=i.get("ids"),d=a=>this.clients.set(a,o);c.observe(a=>{a.changes.added.forEach(h=>{h.content.getContent().forEach(u=>{u instanceof Uint8Array&&this.dss.
124
+ set(o,It([this.dss.get(o)||Te(),dt(new ue(T(u)))]))})})}),this.dss.set(o,It(c.map(a=>dt(new ue(T(a)))))),l.observe(a=>a.changes.added.forEach(h=>h.content.getContent().forEach(d))),l.forEach(d)};n.observe(
125
+ i=>{i.keysChanged.forEach(o=>s(n.get(o),o))}),n.forEach(s)}setUserMapping(t,n,r,{filter:s=()=>!0}={}){const i=this.yusers;let o=i.get(r);o||(o=new St,o.set("ids",new ht),o.set("ds",new ht),i.set(r,o)),
126
+ o.get("ids").push([n]),i.observe(c=>{setTimeout(()=>{const l=i.get(r);if(l!==o){o=l,this.clients.forEach((h,u)=>{r===h&&o.get("ids").push([u])});const d=new Xt,a=this.dss.get(r);a&&(nt(d,a),o.get("ds").
127
+ push([d.toUint8Array()]))}},0)}),t.on("afterTransaction",c=>{setTimeout(()=>{const l=o.get("ds"),d=c.deleteSet;if(c.local&&d.clients.size>0&&s(c,d)){const a=new Xt;nt(a,d),l.push([a.toUint8Array()])}})})}getUserByClientId(t){
128
+ return this.clients.get(t)||null}getUserByDeletedId(t){for(const[n,r]of this.dss.entries())if(Nt(r,t))return n;return null}}class Fe{constructor(t,n,r,s=0){this.type=t,this.tname=n,this.item=r,this.assoc=
129
+ s}}const Vo=e=>{const t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),e.assoc!=null&&(t.assoc=e.assoc),t},Bo=e=>new Fe(e.type==null?null:y(e.type.client,e.type.clock),
130
+ e.tname??null,e.item==null?null:y(e.item.client,e.item.clock),e.assoc==null?0:e.assoc);class Vr{constructor(t,n,r=0){this.type=t,this.index=n,this.assoc=r}}const zo=(e,t,n=0)=>new Vr(e,t,n),Le=(e,t,n)=>{
131
+ let r=null,s=null;return e._item===null?s=Cn(e):r=y(e._item.id.client,e._item.id.clock),new Fe(r,s,t,n)},Wo=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return Le(e,null,n);t--}for(;r!==null;){if(!r.deleted&&
132
+ r.countable){if(r.length>t)return Le(e,y(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return Le(e,r.lastId,n);r=r.right}return Le(e,null,n)},Jo=(e,t)=>{const{type:n,tname:r,item:s,assoc:i}=t;
133
+ if(s!==null)m(e,0),Rr(e,s);else if(r!==null)oe(e,1),At(e,r);else if(n!==null)oe(e,2),Rr(e,n);else throw j();return Ae(e,i),e},Go=e=>{const t=Jt();return Jo(t,e),H(t)},Ho=e=>{let t=null,n=null,r=null;switch(S(
134
+ e)){case 0:r=jr(e);break;case 1:n=Dt(e);break;case 2:t=jr(e)}const s=hr(e)?Ne(e):0;return new Fe(t,n,r,s)},Xo=e=>Ho(T(e)),qo=(e,t)=>{const n=Ot(e,t),r=t.clock-n.id.clock;return{item:n,diff:r}},$o=(e,t,n=!0)=>{
135
+ const r=t.store,s=e.item,i=e.type,o=e.tname,c=e.assoc;let l=null,d=0;if(s!==null){if(A(r,s.client)<=s.clock)return null;const a=n?Vn(r,s):qo(r,s),h=a.item;if(!(h instanceof x))return null;if(l=h.parent,
136
+ l._item===null||!l._item.deleted){d=h.deleted||!h.countable?0:a.diff+(c>=0?0:1);let u=h.left;for(;u!==null;)!u.deleted&&u.countable&&(d+=u.length),u=u.left}}else{if(o!==null)l=t.get(o);else if(i!==null){
137
+ if(A(r,i.client)<=i.clock)return null;const{item:a}=n?Vn(r,i):{item:Ot(r,i)};if(a instanceof x&&a.content instanceof K)l=a.content.type;else return null}else throw j();c>=0?d=l._length:d=0}return zo(l,
138
+ d,e.assoc)},Ko=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&Tt(e.item,t.item)&&Tt(e.type,t.type)&&e.assoc===t.assoc;class En{constructor(t,n){this.ds=t,this.sv=n}}const Yo=(e,t)=>{const n=e.ds.
139
+ clients,r=t.ds.clients,s=e.sv,i=t.sv;if(s.size!==i.size||n.size!==r.size)return!1;for(const[o,c]of s.entries())if(i.get(o)!==c)return!1;for(const[o,c]of n.entries()){const l=r.get(o)||[];if(c.length!==
140
+ l.length)return!1;for(let d=0;d<c.length;d++){const a=c[d],h=l[d];if(a.clock!==h.clock||a.len!==h.len)return!1}}return!0},Br=(e,t=new Oe)=>(nt(t,e.ds),xn(t,e.sv),t.toUint8Array()),Zo=e=>Br(e,new Xt),zr=(e,t=new Nr(
141
+ T(e)))=>new En(dt(t),Tr(t)),Qo=e=>zr(e,new ue(T(e))),An=(e,t)=>new En(e,t),tc=An(Te(),new Map),ec=e=>An(kn(e.store),fe(e.store)),yt=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||
142
+ 0)>e.id.clock&&!Nt(t.ds,e.id),Dn=(e,t)=>{const n=B(e.meta,Dn,Wt),r=e.doc.store;n.has(t)||(t.sv.forEach((s,i)=>{s<A(r,i)&&O(e,y(i,s))}),Pt(e,t.ds,s=>{}),n.add(t))},nc=(e,t,n=new rt)=>{if(e.gc)throw new Error(
143
+ "Garbage-collection must be disabled in `originDoc`!");const{sv:r,ds:s}=t,i=new Y;return e.transact(o=>{let c=0;r.forEach(l=>{l>0&&c++}),m(i.restEncoder,c);for(const[l,d]of r){if(d===0)continue;d<A(e.
144
+ store,l)&&O(o,y(l,d));const a=e.store.clients.get(l)||[],h=q(a,d-1);m(i.restEncoder,h+1),i.writeClient(l),m(i.restEncoder,0);for(let u=0;u<=h;u++)a[u].write(i,0)}nt(i,s)}),Ue(n,i.toUint8Array(),"snaps\
145
+ hot"),n},rc=(e,t,n=J)=>{const r=new n(T(t)),s=new wt(r,!1);for(let o=s.curr;o!==null;o=s.next())if((e.sv.get(o.id.client)||0)<o.id.clock+o.length)return!1;const i=It([e.ds,dt(r)]);return Dr(e.ds,i)},sc=(e,t)=>rc(
146
+ e,t,X);class Wr{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const fe=e=>{const t=new Map;return e.clients.forEach((n,r)=>{const s=n[n.length-1];t.set(r,s.id.clock+
147
+ s.length)}),t},A=(e,t)=>{const n=e.clients.get(t);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},Jr=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(
148
+ t.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==t.id.clock)throw j()}n.push(t)},q=(e,t)=>{let n=0,r=e.length-1,s=e[r],i=s.id.clock;if(i===t)return r;let o=pt(t/(i+s.length-1)*r);for(;n<=
149
+ r;){if(s=e[o],i=s.id.clock,i<=t){if(t<i+s.length)return o;n=o+1}else r=o-1;o=pt((n+r)/2)}throw j()},Ot=(e,t)=>{const n=e.clients.get(t.client);return n[q(n,t.clock)]},Pn=(e,t,n)=>{const r=q(t,n),s=t[r];
150
+ return s.id.clock<n&&s instanceof x?(t.splice(r+1,0,Xe(e,s,n-s.id.clock)),r+1):r},O=(e,t)=>{const n=e.doc.store.clients.get(t.client);return n[Pn(e,n,t.clock)]},Nn=(e,t,n)=>{const r=t.clients.get(n.client),
151
+ s=q(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==V&&r.splice(s+1,0,Xe(e,i,n.clock-i.id.clock+1)),i},ic=(e,t,n)=>{const r=e.clients.get(t.id.client);r[q(r,t.id.clock)]=n},Gr=(e,t,n,r,s)=>{
152
+ if(r===0)return;const i=n+r;let o=Pn(e,t,n),c;do c=t[o++],i<c.id.clock+c.length&&Pn(e,t,i),s(c);while(o<t.length&&t[o].id.clock<i)};class Hr{constructor(t,n,r){this.doc=t,this.deleteSet=new Ht,this.beforeState=
153
+ fe(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=
154
+ new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const Xr=(e,t)=>t.deleteSet.clients.size===0&&!wi(t.afterState,(n,r)=>t.beforeState.get(r)!==n)?!1:(wn(t.deleteSet),No(e,t),nt(e,t.deleteSet),
155
+ !0),qr=(e,t,n)=>{const r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&B(e.changed,t,Wt).add(n)},Re=(e,t)=>{let n=e[t],r=e[t-1],s=t;for(;s>0;n=r,r=e[--s-1]){if(r.deleted===
156
+ n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof x&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const i=t-s;return i&&
157
+ e.splice(t+1-i,i),i},$r=(e,t,n)=>{for(const[r,s]of e.clients.entries()){const i=t.clients.get(r);for(let o=s.length-1;o>=0;o--){const c=s[o],l=c.clock+c.len;for(let d=q(i,c.clock),a=i[d];d<i.length&&a.
158
+ id.clock<l;a=i[++d]){const h=i[d];if(c.clock+c.len<=h.id.clock)break;h instanceof x&&h.deleted&&!h.keep&&n(h)&&h.gc(t,!1)}}}},Kr=(e,t)=>{e.clients.forEach((n,r)=>{const s=t.clients.get(r);for(let i=n.
159
+ length-1;i>=0;i--){const o=n[i],c=Qn(s.length-1,1+q(s,o.clock+o.len-1));for(let l=c,d=s[l];l>0&&d.id.clock>=o.clock;d=s[l])l-=1+Re(s,l)}})},oc=(e,t,n)=>{$r(e,t,n),Kr(e,t)},Yr=(e,t)=>{if(t<e.length){const n=e[t],
160
+ r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{wn(i),n.afterState=fe(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const c=[];n.changed.forEach((l,d)=>c.push(()=>{(d._item===null||!d._item.deleted)&&
161
+ d._callObserver(n,l)})),c.push(()=>{n.changedParentTypes.forEach((l,d)=>{d._dEH.l.length>0&&(d._item===null||!d._item.deleted)&&(l=l.filter(a=>a.target._item===null||!a.target._item.deleted),l.forEach(
162
+ a=>{a.currentTarget=d,a._path=null}),l.sort((a,h)=>a.path.length-h.path.length),Lr(d._dEH,l,n))})}),c.push(()=>r.emit("afterTransaction",[n,r])),gn(c,[]),n._needFormattingCleanup&&Ic(n)}finally{r.gc&&
163
+ $r(i,s,r.gcFilter),Kr(i,s),n.afterState.forEach((a,h)=>{const u=n.beforeState.get(h)||0;if(u!==a){const g=s.clients.get(h),f=Ct(q(g,u),1);for(let p=g.length-1;p>=f;)p-=1+Re(g,p)}});for(let a=o.length-
164
+ 1;a>=0;a--){const{client:h,clock:u}=o[a].id,g=s.clients.get(h),f=q(g,u);f+1<g.length&&Re(g,f+1)>1||f>0&&Re(g,f)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(mn(pn,kr,"[y\
165
+ js] ",Sr,_r,"Changed the client-id because another client seems to be using it."),r.clientID=Pr()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const a=new bt;Xr(a,n)&&r.emit("u\
166
+ pdate",[a.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const a=new Y;Xr(a,n)&&r.emit("updateV2",[a.toUint8Array(),n.origin,r,n])}const{subdocsAdded:c,subdocsLoaded:l,subdocsRemoved:d}=n;
167
+ (c.size>0||d.size>0||l.size>0)&&(c.forEach(a=>{a.clientID=r.clientID,a.collectionid==null&&(a.collectionid=r.collectionid),r.subdocs.add(a)}),d.forEach(a=>r.subdocs.delete(a)),r.emit("subdocs",[{loaded:l,
168
+ added:c,removed:d},r,n]),d.forEach(a=>a.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,e])):Yr(e,t+1)}}},E=(e,t,n=null,r=!0)=>{const s=e._transactionCleanups;let i=!1,
169
+ o=null;e._transaction===null&&(i=!0,e._transaction=new Hr(e,n,r),s.push(e._transaction),s.length===1&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{o=t(e._transaction)}finally{
170
+ if(i){const c=e._transaction===s[0];e._transaction=null,c&&Yr(s,0)}}return o};class cc{constructor(t,n){this.insertions=n,this.deletions=t,this.meta=new Map}}const Zr=(e,t,n)=>{Pt(e,n.deletions,r=>{r instanceof
171
+ x&&t.scope.some(s=>s===e.doc||ge(s,r))&&Bn(r,!1)})},Qr=(e,t,n)=>{let r=null;const s=e.doc,i=e.scope;E(s,c=>{for(;t.length>0&&e.currStackItem===null;){const l=s.store,d=t.pop(),a=new Set,h=[];let u=!1;
172
+ Pt(c,d.insertions,g=>{if(g instanceof x){if(g.redone!==null){let{item:f,diff:p}=Vn(l,g.id);p>0&&(f=O(c,y(f.id.client,f.id.clock+p))),g=f}!g.deleted&&i.some(f=>f===c.doc||ge(f,g))&&h.push(g)}}),Pt(c,d.
173
+ deletions,g=>{g instanceof x&&i.some(f=>f===c.doc||ge(f,g))&&!Nt(d.insertions,g.id)&&a.add(g)}),a.forEach(g=>{u=Us(c,g,a,d.insertions,e.ignoreRemoteMapChanges,e)!==null||u});for(let g=h.length-1;g>=0;g--){
174
+ const f=h[g];e.deleteFilter(f)&&(f.delete(c),u=!0)}e.currStackItem=u?d:null}c.changed.forEach((l,d)=>{l.has(null)&&d._searchMarker&&(d._searchMarker.length=0)}),r=c},e);const o=e.currStackItem;if(o!=null){
175
+ const c=r.changedParentTypes;e.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:c,origin:e},e]),e.currStackItem=null}return o};class lc extends rn{constructor(t,{captureTimeout:n=500,captureTransaction:r=l=>!0,
176
+ deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:c=nn(t)?t[0].doc:t instanceof rt?t:t.doc}={}){super(),this.scope=[],this.doc=c,this.addToScope(t),this.deleteFilter=
177
+ s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=
178
+ o,this.captureTimeout=n,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(_=>l.changedParentTypes.has(_)||_===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||
179
+ !this.trackedOrigins.has(l.origin.constructor)))return;const d=this.undoing,a=this.redoing,h=d?this.redoStack:this.undoStack;d?this.stopCapturing():a||this.clear(!1,!0);const u=new Ht;l.afterState.forEach(
180
+ (_,k)=>{const b=l.beforeState.get(k)||0,M=_-b;M>0&&he(u,k,b,M)});const g=Ki();let f=!1;if(this.lastChange>0&&g-this.lastChange<this.captureTimeout&&h.length>0&&!d&&!a){const _=h[h.length-1];_.deletions=
181
+ It([_.deletions,l.deleteSet]),_.insertions=It([_.insertions,u])}else h.push(new cc(l.deleteSet,u)),f=!0;!d&&!a&&(this.lastChange=g),Pt(l,l.deleteSet,_=>{_ instanceof x&&this.scope.some(k=>k===l.doc||ge(
182
+ k,_))&&Bn(_,!0)});const p=[{stackItem:h[h.length-1],origin:l.origin,type:d?"redo":"undo",changedParentTypes:l.changedParentTypes},this];f?this.emit("stack-item-added",p):this.emit("stack-item-updated",
183
+ p)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(t){const n=new Set(this.scope);t=nn(t)?t:[t],t.forEach(r=>{n.has(r)||(n.add(r),(r instanceof
184
+ P?r.doc!==this.doc:r!==this.doc)&&xr("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,n=!0){
185
+ (t&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{t&&(this.undoStack.forEach(s=>Zr(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>Zr(r,this,s)),this.redoStack=[]),this.emit("s\
186
+ tack-cleared",[{undoStackCleared:t,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=Qr(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.
187
+ redoing=!0;let t;try{t=Qr(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(
188
+ this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*ac(e){const t=S(e.restDecoder);for(let n=0;n<t;n++){const r=S(e.restDecoder),s=e.readClient();let i=S(e.restDecoder);
189
+ for(let o=0;o<r;o++){const c=e.readInfo();if(c===10){const l=S(e.restDecoder);yield new L(y(s,i),l),i+=l}else if((Ee&c)!==0){const l=(c&(ct|F))===0,d=new x(y(s,i),null,(c&F)===F?e.readLeftID():null,null,
190
+ (c&ct)===ct?e.readRightID():null,l?e.readParentInfo()?e.readString():e.readLeftID():null,l&&(c&ne)===ne?e.readString():null,Fs(e,c));yield d,i+=d.length}else{const l=e.readLen();yield new V(y(s,i),l),
191
+ i+=l}}}}class wt{constructor(t,n){this.gen=ac(t),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.
192
+ curr.constructor===L);return this.curr}}const dc=e=>ts(e,X),ts=(e,t=J)=>{const n=[],r=new t(T(e)),s=new wt(r,!1);for(let o=s.curr;o!==null;o=s.next())n.push(o);mn("Structs: ",n);const i=dt(r);mn("Dele\
193
+ teSet: ",i)},hc=e=>es(e,X),es=(e,t=J)=>{const n=[],r=new t(T(e)),s=new wt(r,!1);for(let i=s.curr;i!==null;i=s.next())n.push(i);return{structs:n,ds:dt(r)}};class In{constructor(t){this.currClient=0,this.
194
+ startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}const ns=e=>pe(e,X,bt),rs=(e,t=Oe,n=J)=>{const r=new t,s=new wt(new n(T(e)),!1);let i=s.curr;if(i!==null){let o=0,c=i.id.client,l=i.id.
195
+ clock!==0,d=l?0:i.id.clock+i.length;for(;i!==null;i=s.next())c!==i.id.client&&(d!==0&&(o++,m(r.restEncoder,c),m(r.restEncoder,d)),c=i.id.client,d=0,l=i.id.clock!==0),i.constructor===L&&(l=!0),l||(d=i.
196
+ id.clock+i.length);d!==0&&(o++,m(r.restEncoder,c),m(r.restEncoder,d));const a=Jt();return m(a,o),Ri(a,r.restEncoder),r.restEncoder=a,r.toUint8Array()}else return m(r.restEncoder,0),r.toUint8Array()},uc=e=>rs(
197
+ e,Xt,X),ss=(e,t=J)=>{const n=new Map,r=new Map,s=new wt(new t(T(e)),!1);let i=s.curr;if(i!==null){let o=i.id.client,c=i.id.clock;for(n.set(o,c);i!==null;i=s.next())o!==i.id.client&&(r.set(o,c),n.set(i.
198
+ id.client,i.id.clock),o=i.id.client),c=i.id.clock+i.length;r.set(o,c)}return{from:n,to:r}},gc=e=>ss(e,X),fc=(e,t)=>{if(e.constructor===V){const{client:n,clock:r}=e.id;return new V(y(n,r+t),e.length-t)}else if(e.
199
+ constructor===L){const{client:n,clock:r}=e.id;return new L(y(n,r+t),e.length-t)}else{const n=e,{client:r,clock:s}=n.id;return new x(y(r,s+t),null,y(r,s+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.
200
+ splice(t))}},pe=(e,t=J,n=Y)=>{if(e.length===1)return e[0];const r=e.map(a=>new t(T(a)));let s=r.map(a=>new wt(a,!0)),i=null;const o=new n,c=new In(o);for(;s=s.filter(a=>a.curr!==null),s.sort((a,h)=>{if(a.
201
+ curr.id.client===h.curr.id.client){const u=a.curr.id.clock-h.curr.id.clock;return u===0?a.curr.constructor===h.curr.constructor?0:a.curr.constructor===L?1:-1:u}else return h.curr.id.client-a.curr.id.client}),
202
+ s.length!==0;){const a=s[0],h=a.curr.id.client;if(i!==null){let u=a.curr,g=!1;for(;u!==null&&u.id.clock+u.length<=i.struct.id.clock+i.struct.length&&u.id.client>=i.struct.id.client;)u=a.next(),g=!0;if(u===
203
+ null||u.id.client!==h||g&&u.id.clock>i.struct.id.clock+i.struct.length)continue;if(h!==i.struct.id.client)kt(c,i.struct,i.offset),i={struct:u,offset:0},a.next();else if(i.struct.id.clock+i.struct.length<
204
+ u.id.clock)if(i.struct.constructor===L)i.struct.length=u.id.clock+u.length-i.struct.id.clock;else{kt(c,i.struct,i.offset);const f=u.id.clock-i.struct.id.clock-i.struct.length;i={struct:new L(y(h,i.struct.
205
+ id.clock+i.struct.length),f),offset:0}}else{const f=i.struct.id.clock+i.struct.length-u.id.clock;f>0&&(i.struct.constructor===L?i.struct.length-=f:u=fc(u,f)),i.struct.mergeWith(u)||(kt(c,i.struct,i.offset),
206
+ i={struct:u,offset:0},a.next())}}else i={struct:a.curr,offset:0},a.next();for(let u=a.curr;u!==null&&u.id.client===h&&u.id.clock===i.struct.id.clock+i.struct.length&&u.constructor!==L;u=a.next())kt(c,
207
+ i.struct,i.offset),i={struct:u,offset:0}}i!==null&&(kt(c,i.struct,i.offset),i=null),Tn(c);const l=r.map(a=>dt(a)),d=It(l);return nt(o,d),o.toUint8Array()},Mn=(e,t,n=J,r=Y)=>{const s=vn(t),i=new r,o=new In(
208
+ i),c=new n(T(e)),l=new wt(c,!1);for(;l.curr;){const a=l.curr,h=a.id.client,u=s.get(h)||0;if(l.curr.constructor===L){l.next();continue}if(a.id.clock+a.length>u)for(kt(o,a,Ct(u-a.id.clock,0)),l.next();l.
209
+ curr&&l.curr.id.client===h;)kt(o,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===h&&l.curr.id.clock+l.curr.length<=u;)l.next()}Tn(o);const d=dt(c);return nt(i,d),i.toUint8Array()},pc=(e,t)=>Mn(
210
+ e,t,X,bt),is=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:H(e.encoder.restEncoder)}),e.encoder.restEncoder=Jt(),e.written=0)},kt=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&
211
+ is(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),m(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},Tn=e=>{is(e);const t=e.encoder.restEncoder;m(
212
+ t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){const r=e.clientStructs[n];m(t,r.written),ce(t,r.restEncoder)}},je=(e,t,n,r)=>{const s=new n(T(e)),i=new wt(s,!1),o=new r,c=new In(o);
213
+ for(let d=i.curr;d!==null;d=i.next())kt(c,t(d),0);Tn(c);const l=dt(s);return nt(o,l),o.toUint8Array()},os=({formatting:e=!0,subdocs:t=!0,yxml:n=!0}={})=>{let r=0;const s=U(),i=U(),o=U(),c=U();return c.
214
+ set(null,null),l=>{switch(l.constructor){case V:case L:return l;case x:{const d=l,a=d.content;switch(a.constructor){case Lt:break;case K:{if(n){const h=a.type;h instanceof st&&(h.nodeName=B(i,h.nodeName,
215
+ ()=>"node-"+r)),h instanceof $t&&(h.hookName=B(i,h.hookName,()=>"hook-"+r))}break}case gt:{const h=a;h.arr=h.arr.map(()=>r);break}case Ft:{const h=a;h.content=new Uint8Array([r]);break}case Rt:{const h=a;
216
+ t&&(h.opts={},h.doc.guid=r+"");break}case ut:{const h=a;h.embed={};break}case D:{const h=a;e&&(h.key=B(o,h.key,()=>r+""),h.value=B(c,h.value,()=>({i:r})));break}case Yt:{const h=a;h.arr=h.arr.map(()=>r);
217
+ break}case $:{const h=a;h.str=Mi(r%10+"",h.str.length);break}default:j()}return d.parentSub&&(d.parentSub=B(s,d.parentSub,()=>r+"")),r++,l}default:j()}}},mc=(e,t)=>je(e,os(t),X,bt),bc=(e,t)=>je(e,os(t),
218
+ J,Y),yc=e=>je(e,yr,X,Y),cs=e=>je(e,yr,J,bt),ls="You must not compute changes after the event-handler fired.";class me{constructor(t,n){this.target=t,this.currentTarget=t,this.transaction=n,this._changes=
219
+ null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=wc(this.currentTarget,this.target))}deletes(t){return Nt(this.transaction.deleteSet,t.id)}get keys(){if(this.
220
+ _keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw mt(ls);const t=new Map,n=this.target;this.transaction.changed.get(n).forEach(r=>{if(r!==null){const s=n._map.get(r);let i,o;
221
+ if(this.adds(s)){let c=s.left;for(;c!==null&&this.adds(c);)c=c.left;if(this.deletes(s))if(c!==null&&this.deletes(c))i="delete",o=en(c.content.getContent());else return;else c!==null&&this.deletes(c)?(i=
222
+ "update",o=en(c.content.getContent())):(i="add",o=void 0)}else if(this.deletes(s))i="delete",o=en(s.content.getContent());else return;t.set(r,{action:i,oldValue:o})}}),this._keys=t}return this._keys}get delta(){
223
+ return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===
224
+ 0)throw mt(ls);const n=this.target,r=Wt(),s=Wt(),i=[];if(t={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let o=null;const c=()=>{o&&i.push(o)};for(let l=n._start;l!==
225
+ null;l=l.right)l.deleted?this.deletes(l)&&!this.adds(l)&&((o===null||o.delete===void 0)&&(c(),o={delete:0}),o.delete+=l.length,s.add(l)):this.adds(l)?((o===null||o.insert===void 0)&&(c(),o={insert:[]}),
226
+ o.insert=o.insert.concat(l.content.getContent()),r.add(l)):((o===null||o.retain===void 0)&&(c(),o={retain:0}),o.retain+=l.length);o!==null&&o.retain===void 0&&c()}this._changes=t}return t}}const wc=(e,t)=>{
227
+ const n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let r=0,s=t._item.parent._start;for(;s!==t._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),
228
+ s=s.right;n.unshift(r)}t=t._item.parent}return n},I=()=>{xr("Invalid access: Add Yjs type to a document before reading data.")},as=80;let On=0;class kc{constructor(t,n){t.marker=!0,this.p=t,this.index=
229
+ n,this.timestamp=On++}}const Sc=e=>{e.timestamp=On++},ds=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=On++},_c=(e,t,n)=>{if(e.length>=as){const r=e.reduce((s,i)=>s.timestamp<i.timestamp?
230
+ s:i);return ds(r,t,n),r}else{const r=new kc(t,n);return e.push(r),r}},Ve=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;const n=e._searchMarker.length===0?null:e._searchMarker.reduce(
231
+ (i,o)=>Ce(t-i.index)<Ce(t-o.index)?i:o);let r=e._start,s=0;for(n!==null&&(r=n.p,s=n.index,Sc(n));r.right!==null&&s<t;){if(!r.deleted&&r.countable){if(t<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==
232
+ null&&s>t;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);
233
+ return n!==null&&Ce(n.index-s)<r.parent.length/as?(ds(n,r,s),n):_c(e._searchMarker,r,s)},be=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){const s=e[r];if(n>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)
234
+ i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){e.splice(r,1);continue}s.p=i,i.marker=!0}(t<s.index||n>0&&t===s.index)&&(s.index=Ct(t,s.index+n))}},vc=e=>{e.doc??I();
235
+ let t=e._start;const n=[];for(;t;)n.push(t),t=t.right;return n},Be=(e,t,n)=>{const r=e,s=t.changedParentTypes;for(;B(s,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;Lr(r._eH,n,t)};class P{constructor(){
236
+ this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Or(),this._dEH=Or(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,n){
237
+ this.doc=t,this._item=n}_copy(){throw tt()}clone(){throw tt()}_write(t){}get _first(){let t=this._start;for(;t!==null&&t.deleted;)t=t.right;return t}_callObserver(t,n){!t.local&&this._searchMarker&&(this.
238
+ _searchMarker.length=0)}observe(t){Ur(this._eH,t)}observeDeep(t){Ur(this._dEH,t)}unobserve(t){Fr(this._eH,t)}unobserveDeep(t){Fr(this._dEH,t)}toJSON(){}}const hs=(e,t,n)=>{e.doc??I(),t<0&&(t=e._length+
239
+ t),n<0&&(n=e._length+n);let r=n-t;const s=[];let i=e._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){const o=i.content.getContent();if(o.length<=t)t-=o.length;else{for(let c=t;c<o.length&&r>0;c++)
240
+ s.push(o[c]),r--;t=0}}i=i.right}return s},us=e=>{e.doc??I();const t=[];let n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let s=0;s<r.length;s++)t.push(r[s])}
241
+ n=n.right}return t},xc=(e,t)=>{const n=[];let r=e._start;for(;r!==null;){if(r.countable&&yt(r,t)){const s=r.content.getContent();for(let i=0;i<s.length;i++)n.push(s[i])}r=r.right}return n},ye=(e,t)=>{
242
+ let n=0,r=e._start;for(e.doc??I();r!==null;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let i=0;i<s.length;i++)t(s[i],n++,e)}r=r.right}},gs=(e,t)=>{const n=[];return ye(e,(r,s)=>{n.
243
+ push(t(r,s,e))}),n},Cc=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.
244
+ getContent(),r=0,t=t.right}const s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},fs=(e,t)=>{e.doc??I();const n=Ve(e,t);let r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.
245
+ deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},ze=(e,t,n,r)=>{let s=n;const i=e.doc,o=i.clientID,c=i.store,l=n===null?t._start:n.right;let d=[];const a=()=>{d.length>
246
+ 0&&(s=new x(y(o,A(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new gt(d)),s.integrate(e,0),d=[])};r.forEach(h=>{if(h===null)d.push(h);else switch(h.constructor){case Number:case Object:case Boolean:case Array:case String:
247
+ d.push(h);break;default:switch(a(),h.constructor){case Uint8Array:case ArrayBuffer:s=new x(y(o,A(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new Ft(new Uint8Array(h))),s.integrate(e,0);break;case rt:s=new x(
248
+ y(o,A(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new Rt(h)),s.integrate(e,0);break;default:if(h instanceof P)s=new x(y(o,A(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new K(h)),s.integrate(e,0);else throw new Error(
249
+ "Unexpected content type in insert operation")}}}),a()},ps=()=>mt("Length exceeded!"),ms=(e,t,n,r)=>{if(n>t._length)throw ps();if(n===0)return t._searchMarker&&be(t._searchMarker,n,r.length),ze(e,t,null,
250
+ r);const s=n,i=Ve(t,n);let o=t._start;for(i!==null&&(o=i.p,n-=i.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&
251
+ O(e,y(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&be(t._searchMarker,s,r.length),ze(e,t,o,r)},Ec=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((s,i)=>i.index>s.index?i:s,{index:0,
252
+ p:t._start}).p;if(r)for(;r.right;)r=r.right;return ze(e,t,r,n)},bs=(e,t,n,r)=>{if(r===0)return;const s=n,i=r,o=Ve(t,n);let c=t._start;for(o!==null&&(c=o.p,n-=o.index);c!==null&&n>0;c=c.right)!c.deleted&&
253
+ c.countable&&(n<c.length&&O(e,y(c.id.client,c.id.clock+n)),n-=c.length);for(;r>0&&c!==null;)c.deleted||(r<c.length&&O(e,y(c.id.client,c.id.clock+r)),c.delete(e),r-=c.length),c=c.right;if(r>0)throw ps();
254
+ t._searchMarker&&be(t._searchMarker,s,-i+r)},We=(e,t,n)=>{const r=t._map.get(n);r!==void 0&&r.delete(e)},Un=(e,t,n,r)=>{const s=t._map.get(n)||null,i=e.doc,o=i.clientID;let c;if(r==null)c=new gt([r]);else
255
+ switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new gt([r]);break;case Uint8Array:c=new Ft(r);break;case rt:c=new Rt(r);break;default:if(r instanceof
256
+ P)c=new K(r);else throw new Error("Unexpected content type")}new x(y(o,A(i.store,o)),s,s&&s.lastId,null,null,t,n,c).integrate(e,0)},Fn=(e,t)=>{e.doc??I();const n=e._map.get(t);return n!==void 0&&!n.deleted?
257
+ n.content.getContent()[n.length-1]:void 0},ys=e=>{const t={};return e.doc??I(),e._map.forEach((n,r)=>{n.deleted||(t[r]=n.content.getContent()[n.length-1])}),t},ws=(e,t)=>{e.doc??I();const n=e._map.get(
258
+ t);return n!==void 0&&!n.deleted},Ac=(e,t,n)=>{let r=e._map.get(t)||null;for(;r!==null&&(!n.sv.has(r.id.client)||r.id.clock>=(n.sv.get(r.id.client)||0));)r=r.left;return r!==null&&yt(r,n)?r.content.getContent()[r.
259
+ length-1]:void 0},ks=(e,t)=>{const n={};return e._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&yt(i,t)&&(n[s]=i.content.
260
+ getContent()[i.length-1])}),n},Je=e=>(e.doc??I(),xo(e._map.entries(),t=>!t[1].deleted));class Ss extends me{}class ht extends P{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){
261
+ const n=new ht;return n.push(t),n}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new ht}clone(){const t=new ht;return t.insert(0,this.
262
+ toArray().map(n=>n instanceof P?n.clone():n)),t}get length(){return this.doc??I(),this._length}_callObserver(t,n){super._callObserver(t,n),Be(this,t,new Ss(this,t))}insert(t,n){this.doc!==null?E(this.
263
+ doc,r=>{ms(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}push(t){this.doc!==null?E(this.doc,n=>{Ec(n,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,n=1){this.doc!==
264
+ null?E(this.doc,r=>{bs(r,this,t,n)}):this._prelimContent.splice(t,n)}get(t){return fs(this,t)}toArray(){return us(this)}slice(t=0,n=this.length){return hs(this,t,n)}toJSON(){return this.map(t=>t instanceof
265
+ P?t.toJSON():t)}map(t){return gs(this,t)}forEach(t){ye(this,t)}[Symbol.iterator](){return Cc(this)}_write(t){t.writeTypeRef(qc)}}const Dc=e=>new ht;class _s extends me{constructor(t,n,r){super(t,n),this.
266
+ keysChanged=r}}class St extends P{constructor(t){super(),this._prelimContent=null,t===void 0?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,n){super._integrate(t,n),this._prelimContent.
267
+ forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new St}clone(){const t=new St;return this.forEach((n,r)=>{t.set(r,n instanceof P?n.clone():n)}),t}_callObserver(t,n){Be(this,t,new _s(
268
+ this,t,n))}toJSON(){this.doc??I();const t={};return this._map.forEach((n,r)=>{if(!n.deleted){const s=n.content.getContent()[n.length-1];t[r]=s instanceof P?s.toJSON():s}}),t}get size(){return[...Je(this)].
269
+ length}keys(){return bn(Je(this),t=>t[0])}values(){return bn(Je(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return bn(Je(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){
270
+ this.doc??I(),this._map.forEach((n,r)=>{n.deleted||t(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?E(this.doc,n=>{We(n,this,t)}):this.
271
+ _prelimContent.delete(t)}set(t,n){return this.doc!==null?E(this.doc,r=>{Un(r,this,t,n)}):this._prelimContent.set(t,n),n}get(t){return Fn(this,t)}has(t){return ws(this,t)}clear(){this.doc!==null?E(this.
272
+ doc,t=>{this.forEach(function(n,r,s){We(t,s,r)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef($c)}}const Pc=e=>new St,_t=(e,t)=>e===t||typeof e=="object"&&typeof t=="object"&&e&&t&&co(e,t);class Ln{constructor(t,n,r,s){
273
+ this.left=t,this.right=n,this.index=r,this.currentAttributes=s}forward(){switch(this.right===null&&j(),this.right.content.constructor){case D:this.right.deleted||qt(this.currentAttributes,this.right.content);
274
+ break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const vs=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case D:
275
+ t.right.deleted||qt(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&O(e,y(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);break}
276
+ t.left=t.right,t.right=t.right.right}return t},Ge=(e,t,n,r)=>{const s=new Map,i=r?Ve(t,n):null;if(i){const o=new Ln(i.p.left,i.p,i.index,s);return vs(e,o,n-i.index)}else{const o=new Ln(null,t._start,0,
277
+ s);return vs(e,o,n)}},xs=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===D&&_t(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.
278
+ content.key),n.forward();const s=e.doc,i=s.clientID;r.forEach((o,c)=>{const l=n.left,d=n.right,a=new x(y(i,A(s.store,i)),l,l&&l.lastId,d,d&&d.id,t,null,new D(c,o));a.integrate(e,0),n.right=a,n.forward()})},
279
+ qt=(e,t)=>{const{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Cs=(e,t)=>{for(;e.right!==null&&(e.right.deleted||e.right.content.constructor===D&&_t(t[e.right.content.key]??null,e.right.content.value));)
280
+ e.forward()},Es=(e,t,n,r)=>{const s=e.doc,i=s.clientID,o=new Map;for(const c in r){const l=r[c],d=n.currentAttributes.get(c)??null;if(!_t(d,l)){o.set(c,d);const{left:a,right:h}=n;n.right=new x(y(i,A(s.
281
+ store,i)),a,a&&a.lastId,h,h&&h.id,t,null,new D(c,l)),n.right.integrate(e,0),n.forward()}}return o},Rn=(e,t,n,r,s)=>{n.currentAttributes.forEach((u,g)=>{s[g]===void 0&&(s[g]=null)});const i=e.doc,o=i.clientID;
282
+ Cs(n,s);const c=Es(e,t,n,s),l=r.constructor===String?new $(r):r instanceof P?new K(r):new ut(r);let{left:d,right:a,index:h}=n;t._searchMarker&&be(t._searchMarker,n.index,l.getLength()),a=new x(y(o,A(i.
283
+ store,o)),d,d&&d.lastId,a,a&&a.id,t,null,l),a.integrate(e,0),n.right=a,n.index=h,n.forward(),xs(e,t,n,c)},As=(e,t,n,r,s)=>{const i=e.doc,o=i.clientID;Cs(n,s);const c=Es(e,t,n,s);t:for(;n.right!==null&&
284
+ (r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===D));){if(!n.right.deleted)switch(n.right.content.constructor){case D:{const{key:l,value:d}=n.right.content,a=s[l];if(a!==void 0){if(_t(a,
285
+ d))c.delete(l);else{if(r===0)break t;c.set(l,d)}n.right.delete(e)}else n.currentAttributes.set(l,d);break}default:r<n.right.length&&O(e,y(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}
286
+ n.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
287
+ `;n.right=new x(y(o,A(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new $(l)),n.right.integrate(e,0),n.forward()}xs(e,t,n,c)},Ds=(e,t,n,r,s)=>{let i=t;const o=U();for(;i&&
288
+ (!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===D){const d=i.content;o.set(d.key,d)}i=i.right}let c=0,l=!1;for(;t!==i;){if(n===t&&(l=!0),!t.deleted){const d=t.content;switch(d.constructor){case D:{
289
+ const{key:a,value:h}=d,u=r.get(a)??null;(o.get(a)!==d||u===h)&&(t.delete(e),c++,!l&&(s.get(a)??null)===h&&u!==h&&(u===null?s.delete(a):s.set(a,u))),!l&&!t.deleted&&qt(s,d);break}}}t=t.right}return c},
290
+ Nc=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;const n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===D){const r=t.content.key;n.has(r)?
291
+ t.delete(e):n.add(r)}t=t.left}},Ps=e=>{let t=0;return E(e.doc,n=>{let r=e._start,s=e._start,i=U();const o=tn(i);for(;s;){if(s.deleted===!1)switch(s.content.constructor){case D:qt(o,s.content);break;default:
292
+ t+=Ds(n,r,s,i,o),i=tn(o),r=s;break}s=s.right}}),t},Ic=e=>{const t=new Set,n=e.doc;for(const[r,s]of e.afterState.entries()){const i=e.beforeState.get(r)||0;s!==i&&Gr(e,n.store.clients.get(r),i,s,o=>{!o.
293
+ deleted&&o.content.constructor===D&&o.constructor!==V&&t.add(o.parent)})}E(n,r=>{Pt(e,e.deleteSet,s=>{if(s instanceof V||!s.parent._hasFormatting||t.has(s.parent))return;const i=s.parent;s.content.constructor===
294
+ D?t.add(i):Nc(r,s)});for(const s of t)Ps(s)})},Ns=(e,t,n)=>{const r=n,s=tn(t.currentAttributes),i=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case K:case ut:case $:
295
+ n<t.right.length&&O(e,y(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}i&&Ds(e,i,t.right,s,t.currentAttributes);const o=(t.left||t.right).parent;return o.
296
+ _searchMarker&&be(o._searchMarker,t.index,-r+n),t};class Is extends me{constructor(t,n,r){super(t,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(s=>{s===null?this.childListChanged=!0:this.
297
+ keysChanged.add(s)})}get changes(){if(this._changes===null){const t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){
298
+ const t=this.target.doc,n=[];E(t,r=>{const s=new Map,i=new Map;let o=this.target._start,c=null;const l={};let d="",a=0,h=0;const u=()=>{if(c!==null){let g=null;switch(c){case"delete":h>0&&(g={delete:h}),
299
+ h=0;break;case"insert":(typeof d=="object"||d.length>0)&&(g={insert:d},s.size>0&&(g.attributes={},s.forEach((f,p)=>{f!==null&&(g.attributes[p]=f)}))),d="";break;case"retain":a>0&&(g={retain:a},so(l)||
300
+ (g.attributes=eo({},l))),a=0;break}g&&n.push(g),c=null}};for(;o!==null;){switch(o.content.constructor){case K:case ut:this.adds(o)?this.deletes(o)||(u(),c="insert",d=o.content.getContent()[0],u()):this.
301
+ deletes(o)?(c!=="delete"&&(u(),c="delete"),h+=1):o.deleted||(c!=="retain"&&(u(),c="retain"),a+=1);break;case $:this.adds(o)?this.deletes(o)||(c!=="insert"&&(u(),c="insert"),d+=o.content.str):this.deletes(
302
+ o)?(c!=="delete"&&(u(),c="delete"),h+=o.length):o.deleted||(c!=="retain"&&(u(),c="retain"),a+=o.length);break;case D:{const{key:g,value:f}=o.content;if(this.adds(o)){if(!this.deletes(o)){const p=s.get(
303
+ g)??null;_t(p,f)?f!==null&&o.delete(r):(c==="retain"&&u(),_t(f,i.get(g)??null)?delete l[g]:l[g]=f)}}else if(this.deletes(o)){i.set(g,f);const p=s.get(g)??null;_t(p,f)||(c==="retain"&&u(),l[g]=p)}else if(!o.
304
+ deleted){i.set(g,f);const p=l[g];p!==void 0&&(_t(p,f)?p!==null&&o.delete(r):(c==="retain"&&u(),f===null?delete l[g]:l[g]=f))}o.deleted||(c==="insert"&&u(),qt(s,o.content));break}}o=o.right}for(u();n.length>
305
+ 0;){const g=n[n.length-1];if(g.retain!==void 0&&g.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class Ut extends P{constructor(t){super(),this._pending=t!==void 0?[()=>this.
306
+ insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??I(),this._length}_integrate(t,n){super._integrate(t,n);try{this._pending.forEach(r=>r())}catch(r){console.error(
307
+ r)}this._pending=null}_copy(){return new Ut}clone(){const t=new Ut;return t.applyDelta(this.toDelta()),t}_callObserver(t,n){super._callObserver(t,n);const r=new Is(this,t,n);Be(this,t,r),!t.local&&this.
308
+ _hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??I();let t="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===$&&(t+=n.content.str),n=n.right;return t}toJSON(){
309
+ return this.toString()}applyDelta(t,{sanitize:n=!0}={}){this.doc!==null?E(this.doc,r=>{const s=new Ln(null,this._start,0,new Map);for(let i=0;i<t.length;i++){const o=t[i];if(o.insert!==void 0){const c=!n&&
310
+ typeof o.insert=="string"&&i===t.length-1&&s.right===null&&o.insert.slice(-1)===`
311
+ `?o.insert.slice(0,-1):o.insert;(typeof c!="string"||c.length>0)&&Rn(r,this,s,c,o.attributes||{})}else o.retain!==void 0?As(r,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&Ns(r,s,o.delete)}}):this.
312
+ _pending.push(()=>this.applyDelta(t))}toDelta(t,n,r){this.doc??I();const s=[],i=new Map,o=this.doc;let c="",l=this._start;function d(){if(c.length>0){const h={};let u=!1;i.forEach((f,p)=>{u=!0,h[p]=f});
313
+ const g={insert:c};u&&(g.attributes=h),s.push(g),c=""}}const a=()=>{for(;l!==null;){if(yt(l,t)||n!==void 0&&yt(l,n))switch(l.content.constructor){case $:{const h=i.get("ychange");t!==void 0&&!yt(l,t)?
314
+ (h===void 0||h.user!==l.id.client||h.type!=="removed")&&(d(),i.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!yt(l,n)?(h===void 0||h.user!==l.id.client||h.type!=="added")&&(d(),i.set(
315
+ "ychange",r?r("added",l.id):{type:"added"})):h!==void 0&&(d(),i.delete("ychange")),c+=l.content.str;break}case K:case ut:{d();const h={insert:l.content.getContent()[0]};if(i.size>0){const u={};h.attributes=
316
+ u,i.forEach((g,f)=>{u[f]=g})}s.push(h);break}case D:yt(l,t)&&(d(),qt(i,l.content));break}l=l.right}d()};return t||n?E(o,h=>{t&&Dn(h,t),n&&Dn(h,n),a()},"cleanup"):a(),s}insert(t,n,r){if(n.length<=0)return;
317
+ const s=this.doc;s!==null?E(s,i=>{const o=Ge(i,this,t,!r);r||(r={},o.currentAttributes.forEach((c,l)=>{r[l]=c})),Rn(i,this,o,n,r)}):this._pending.push(()=>this.insert(t,n,r))}insertEmbed(t,n,r){const s=this.
318
+ doc;s!==null?E(s,i=>{const o=Ge(i,this,t,!r);Rn(i,this,o,n,r||{})}):this._pending.push(()=>this.insertEmbed(t,n,r||{}))}delete(t,n){if(n===0)return;const r=this.doc;r!==null?E(r,s=>{Ns(s,Ge(s,this,t,!0),
319
+ n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,r){if(n===0)return;const s=this.doc;s!==null?E(s,i=>{const o=Ge(i,this,t,!1);o.right!==null&&As(i,this,o,n,r)}):this._pending.push(()=>this.format(
320
+ t,n,r))}removeAttribute(t){this.doc!==null?E(this.doc,n=>{We(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?E(this.doc,r=>{Un(r,this,t,n)}):this._pending.
321
+ push(()=>this.setAttribute(t,n))}getAttribute(t){return Fn(this,t)}getAttributes(){return ys(this)}_write(t){t.writeTypeRef(Kc)}}const Mc=e=>new Ut;class jn{constructor(t,n=()=>!0){this._filter=n,this.
322
+ _root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??I()}[Symbol.iterator](){return this}next(){let t=this._currentNode,n=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||
323
+ !this._filter(n)))do if(n=t.content.type,!t.deleted&&(n.constructor===st||n.constructor===vt)&&n._start!==null)t=n._start;else for(;t!==null;){const r=t.next;if(r!==null){t=r;break}else t.parent===this.
324
+ _root?t=null:t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,t===null?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}}
325
+ class vt extends P{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),
326
+ this._prelimContent=null}_copy(){return new vt}clone(){const t=new vt;return t.insert(0,this.toArray().map(n=>n instanceof P?n.clone():n)),t}get length(){return this.doc??I(),this._prelimContent===null?
327
+ this._length:this._prelimContent.length}createTreeWalker(t){return new jn(this,t)}querySelector(t){t=t.toUpperCase();const n=new jn(this,r=>r.nodeName&&r.nodeName.toUpperCase()===t).next();return n.done?
328
+ null:n.value}querySelectorAll(t){return t=t.toUpperCase(),ft(new jn(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){Be(this,t,new Ms(this,n,t))}toString(){return gs(this,t=>t.toString()).
329
+ join("")}toJSON(){return this.toString()}toDOM(t=document,n={},r){const s=t.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),ye(this,i=>{s.insertBefore(i.toDOM(t,n,r),null)}),s}insert(t,n){
330
+ this.doc!==null?E(this.doc,r=>{ms(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)E(this.doc,r=>{const s=t&&t instanceof P?t._item:t;ze(r,this,s,n)});else{const r=this.
331
+ _prelimContent,s=t===null?0:r.findIndex(i=>i===t)+1;if(s===0&&t!==null)throw mt("Reference item not found");r.splice(s,0,...n)}}delete(t,n=1){this.doc!==null?E(this.doc,r=>{bs(r,this,t,n)}):this._prelimContent.
332
+ splice(t,n)}toArray(){return us(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return fs(this,t)}slice(t=0,n=this.length){return hs(this,t,n)}forEach(t){ye(this,t)}_write(t){
333
+ t.writeTypeRef(Zc)}}const Tc=e=>new vt;class st extends vt{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?
334
+ t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,n){super._integrate(t,n),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),
335
+ this._prelimAttrs=null}_copy(){return new st(this.nodeName)}clone(){const t=new st(this.nodeName),n=this.getAttributes();return ro(n,(r,s)=>{typeof r=="string"&&t.setAttribute(s,r)}),t.insert(0,this.toArray().
336
+ map(r=>r instanceof P?r.clone():r)),t}toString(){const t=this.getAttributes(),n=[],r=[];for(const c in t)r.push(c);r.sort();const s=r.length;for(let c=0;c<s;c++){const l=r[c];n.push(l+'="'+t[l]+'"')}const i=this.
337
+ nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(t){this.doc!==null?E(this.doc,n=>{We(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){
338
+ this.doc!==null?E(this.doc,r=>{Un(r,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return Fn(this,t)}hasAttribute(t){return ws(this,t)}getAttributes(t){return t?ks(this,t):ys(this)}toDOM(t=document,n={},r){
339
+ const s=t.createElement(this.nodeName),i=this.getAttributes();for(const o in i){const c=i[o];typeof c=="string"&&s.setAttribute(o,c)}return ye(this,o=>{s.appendChild(o.toDOM(t,n,r))}),r!==void 0&&r._createAssociation(
340
+ s,this),s}_write(t){t.writeTypeRef(Yc),t.writeKey(this.nodeName)}}const Oc=e=>new st(e.readKey());class Ms extends me{constructor(t,n,r){super(t,r),this.childListChanged=!1,this.attributesChanged=new Set,
341
+ n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}}class $t extends St{constructor(t){super(),this.hookName=t}_copy(){return new $t(this.hookName)}clone(){const t=new $t(
342
+ this.hookName);return this.forEach((n,r)=>{t.set(r,n)}),t}toDOM(t=document,n={},r){const s=n[this.hookName];let i;return s!==void 0?i=s.createDom(this):i=document.createElement(this.hookName),i.setAttribute(
343
+ "data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(i,this),i}_write(t){t.writeTypeRef(Qc),t.writeKey(this.hookName)}}const Uc=e=>new $t(e.readKey());class Kt extends Ut{get nextSibling(){
344
+ const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new Kt}clone(){const t=new Kt;
345
+ return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,r){const s=t.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(t=>{const n=[];
346
+ for(const s in t.attributes){const i=[];for(const o in t.attributes[s])i.push({key:o,value:t.attributes[s][o]});i.sort((o,c)=>o.key<c.key?-1:1),n.push({nodeName:s,attrs:i})}n.sort((s,i)=>s.nodeName<i.
347
+ nodeName?-1:1);let r="";for(let s=0;s<n.length;s++){const i=n[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){const c=i.attrs[o];r+=` ${c.key}="${c.value}"`}r+=">"}r+=t.insert;for(let s=n.length-
348
+ 1;s>=0;s--)r+=`</${n[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(tl)}}const Fc=e=>new Kt;class He{constructor(t,n){this.id=t,this.length=n}get deleted(){
349
+ throw tt()}mergeWith(t){return!1}write(t,n,r){throw tt()}integrate(t,n){throw tt()}}const Lc=0;class V extends He{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?
350
+ !1:(this.length+=t.length,!0)}integrate(t,n){n>0&&(this.id.clock+=n,this.length-=n),Jr(t.doc.store,this)}write(t,n){t.writeInfo(Lc),t.writeLen(this.length-n)}getMissing(t,n){return null}}class Ft{constructor(t){
351
+ this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Ft(this.content)}splice(t){throw tt()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){
352
+ t.writeBuf(this.content)}getRef(){return 3}}const Rc=e=>new Ft(e.readBuf());class Lt{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Lt(
353
+ this.len)}splice(t){const n=new Lt(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){he(t.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(t){}gc(t){}write(t,n){
354
+ t.writeLen(this.len-n)}getRef(){return 1}}const jc=e=>new Lt(e.readLen()),Ts=(e,t)=>new rt({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class Rt{constructor(t){t._item&&console.error("This d\
355
+ ocument was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;const n={};this.opts=n,t.gc||(n.gc=!1),t.autoLoad&&(n.autoLoad=!0),t.meta!==
356
+ null&&(n.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Rt(Ts(this.doc.guid,this.opts))}splice(t){throw tt()}mergeWith(t){return!1}integrate(t,n){
357
+ this.doc._item=n,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,n){
358
+ t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}const Vc=e=>new Rt(Ts(e.readString(),e.readAny()));class ut{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.
359
+ embed]}isCountable(){return!0}copy(){return new ut(this.embed)}splice(t){throw tt()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}}const Bc=e=>new ut(
360
+ e.readJSON());class D{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new D(this.key,this.value)}splice(t){throw tt()}mergeWith(t){
361
+ return!1}integrate(t,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,n){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}const zc=e=>new D(e.readKey(),
362
+ e.readJSON());class Yt{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Yt(this.arr)}splice(t){const n=new Yt(this.arr.
363
+ slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const r=this.arr.length;t.writeLen(r-n);for(let s=n;s<
364
+ r;s++){const i=this.arr[s];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}const Wc=e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++){const s=e.readString();s==="undefined"?
365
+ n.push(void 0):n.push(JSON.parse(s))}return new Yt(n)},Jc=Me("node_env")==="development";class gt{constructor(t){this.arr=t,Jc&&br(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){
366
+ return!0}copy(){return new gt(this.arr)}splice(t){const n=new gt(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){
367
+ const r=this.arr.length;t.writeLen(r-n);for(let s=n;s<r;s++){const i=this.arr[s];t.writeAny(i)}}getRef(){return 8}}const Gc=e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new gt(
368
+ n)};class ${constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new $(this.str)}splice(t){const n=new $(this.str.slice(
369
+ t));this.str=this.str.slice(0,t);const r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){
370
+ t.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const Hc=e=>new $(e.readString()),Xc=[Dc,Pc,Mc,Oc,Tc,Uc,Fc],qc=0,$c=1,Kc=2,Yc=3,Zc=4,Qc=5,tl=6;class K{constructor(t){this.type=t}getLength(){
371
+ return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new K(this.type._copy())}splice(t){throw tt()}mergeWith(t){return!1}integrate(t,n){this.type._integrate(t.doc,n)}delete(t){
372
+ let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(t.beforeState.get(n.id.client)||0)&&t._mergeStructs.push(n):n.delete(t),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(t.beforeState.
373
+ get(r.id.client)||0)&&t._mergeStructs.push(r):r.delete(t)}),t.changed.delete(this.type)}gc(t){let n=this.type._start;for(;n!==null;)n.gc(t,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{
374
+ for(;r!==null;)r.gc(t,!0),r=r.left}),this.type._map=new Map}write(t,n){this.type._write(t)}getRef(){return 7}}const el=e=>new K(Xc[e.readTypeRef()](e)),Vn=(e,t)=>{let n=t,r=0,s;do r>0&&(n=y(n.client,n.
375
+ clock+r)),s=Ot(e,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof x);return{item:s,diff:r}},Bn=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Xe=(e,t,n)=>{const{client:r,
376
+ clock:s}=t.id,i=new x(y(r,s+n),t,y(r,s+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&i.markDeleted(),t.keep&&(i.keep=!0),t.redone!==null&&(i.redone=y(t.redone.
377
+ client,t.redone.clock+n)),t.right=i,i.right!==null&&(i.right.left=i),e._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),t.length=n,i},Os=(e,t)=>Si(e,n=>Nt(n.deletions,
378
+ t)),Us=(e,t,n,r,s,i)=>{const o=e.doc,c=o.store,l=o.clientID,d=t.redone;if(d!==null)return O(e,d);let a=t.parent._item,h=null,u;if(a!==null&&a.deleted===!0){if(a.redone===null&&(!n.has(a)||Us(e,a,n,r,s,
379
+ i)===null))return null;for(;a.redone!==null;)a=O(e,a.redone)}const g=a===null?t.parent:a.content.type;if(t.parentSub===null){for(h=t.left,u=t;h!==null;){let k=h;for(;k!==null&&k.parent._item!==a;)k=k.
380
+ redone===null?null:O(e,k.redone);if(k!==null&&k.parent._item===a){h=k;break}h=h.left}for(;u!==null;){let k=u;for(;k!==null&&k.parent._item!==a;)k=k.redone===null?null:O(e,k.redone);if(k!==null&&k.parent.
381
+ _item===a){u=k;break}u=u.right}}else if(u=null,t.right&&!s){for(h=t;h!==null&&h.right!==null&&(h.right.redone||Nt(r,h.right.id)||Os(i.undoStack,h.right.id)||Os(i.redoStack,h.right.id));)for(h=h.right;h.
382
+ redone;)h=O(e,h.redone);if(h&&h.right!==null)return null}else h=g._map.get(t.parentSub)||null;const f=A(c,l),p=y(l,f),_=new x(p,h,h&&h.lastId,u,u&&u.id,g,t.parentSub,t.content.copy());return t.redone=
383
+ p,Bn(_,!0),_.integrate(e,0),_};class x extends He{constructor(t,n,r,s,i,o,c,l){super(t,l.getLength()),this.origin=r,this.left=n,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=c,this.redone=
384
+ null,this.content=l,this.info=this.content.isCountable()?nr:0}set marker(t){(this.info&on)>0!==t&&(this.info^=on)}get marker(){return(this.info&on)>0}get keep(){return(this.info&er)>0}set keep(t){this.
385
+ keep!==t&&(this.info^=er)}get countable(){return(this.info&nr)>0}get deleted(){return(this.info&sn)>0}set deleted(t){this.deleted!==t&&(this.info^=sn)}markDeleted(){this.info|=sn}getMissing(t,n){if(this.
386
+ origin&&this.origin.client!==this.id.client&&this.origin.clock>=A(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=
387
+ A(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Mt&&this.id.client!==this.parent.client&&this.parent.clock>=A(n,this.parent.client))return this.parent.
388
+ client;if(this.origin&&(this.left=Nn(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=O(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===
389
+ V||this.right&&this.right.constructor===V)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===x?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.
390
+ right.constructor===x&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Mt){const r=Ot(n,this.parent);r.constructor===V?this.parent=null:this.parent=
391
+ r.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=Nn(t,t.doc.store,y(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.
392
+ length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.
393
+ parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;const i=new Set,o=new Set;for(;s!==null&&s!==this.right;){if(o.add(s),i.add(s),Tt(this.origin,s.origin)){
394
+ if(s.id.client<this.id.client)r=s,i.clear();else if(Tt(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(Ot(t.doc.store,s.origin)))i.has(Ot(t.doc.store,s.origin))||(r=s,i.clear());else
395
+ break;s=s.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&
396
+ r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==
397
+ null&&this.left.delete(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),Jr(t.doc.store,this),this.content.integrate(t,this),qr(t,this.parent,this.parentSub),
398
+ (this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new V(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&
399
+ t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:y(this.id.client,this.id.clock+this.length-1)}mergeWith(t){
400
+ if(this.constructor===t.constructor&&Tt(t.origin,this.lastId)&&this.right===t&&Tt(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===
401
+ t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===t&&
402
+ (r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.
403
+ deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),he(t.deleteSet,this.id.client,this.id.clock,this.length),qr(t,n,this.parentSub),this.content.
404
+ delete(t)}}gc(t,n){if(!this.deleted)throw j();this.content.gc(t),n?ic(t,this,new V(this.id,this.length)):this.content=new Lt(this.length)}write(t,n){const r=n>0?y(this.id.client,this.id.clock+n-1):this.
405
+ origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&Ee|(r===null?0:F)|(s===null?0:ct)|(i===null?0:ne);if(t.writeInfo(o),r!==null&&t.writeLeftID(r),s!==null&&t.writeRightID(s),r===null&&
406
+ s===null){const c=this.parent;if(c._item!==void 0){const l=c._item;if(l===null){const d=Cn(c);t.writeParentInfo(!0),t.writeString(d)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else c.constructor===
407
+ String?(t.writeParentInfo(!0),t.writeString(c)):c.constructor===Mt?(t.writeParentInfo(!1),t.writeLeftID(c)):j();i!==null&&t.writeString(i)}this.content.write(t,n)}}const Fs=(e,t)=>nl[t&Ee](e),nl=[()=>{
408
+ j()},jc,Wc,Rc,Hc,Bc,zc,el,Gc,Vc,()=>{j()}],rl=10;class L extends He{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){j()}write(t,n){
409
+ t.writeInfo(rl),m(t.restEncoder,this.length-n)}getMissing(t,n){return null}}const Ls=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Rs="__ $YJS$ __";Ls[Rs]===!0&&
410
+ console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),Ls[Rs]=!0;var sl=Object.freeze({__proto__:null,AbsolutePosition:Vr,
411
+ AbstractConnector:Co,AbstractStruct:He,AbstractType:P,Array:ht,ContentAny:gt,ContentBinary:Ft,ContentDeleted:Lt,ContentDoc:Rt,ContentEmbed:ut,ContentFormat:D,ContentJSON:Yt,ContentString:$,ContentType:K,
412
+ Doc:rt,GC:V,ID:Mt,Item:x,Map:St,PermanentUserData:jo,RelativePosition:Fe,Skip:L,Snapshot:En,Text:Ut,Transaction:Hr,UndoManager:lc,UpdateDecoderV1:X,UpdateDecoderV2:J,UpdateEncoderV1:bt,UpdateEncoderV2:Y,
413
+ XmlElement:st,XmlFragment:vt,XmlHook:$t,XmlText:Kt,YArrayEvent:Ss,YEvent:me,YMapEvent:_s,YTextEvent:Is,YXmlEvent:Ms,applyUpdate:Ir,applyUpdateV2:Ue,cleanupYTextFormatting:Ps,compareIDs:Tt,compareRelativePositions:Ko,
414
+ convertUpdateFormatV1ToV2:yc,convertUpdateFormatV2ToV1:cs,createAbsolutePositionFromRelativePosition:$o,createDeleteSet:Te,createDeleteSetFromStructStore:kn,createDocFromSnapshot:nc,createID:y,createRelativePositionFromJSON:Bo,
415
+ createRelativePositionFromTypeIndex:Wo,createSnapshot:An,decodeRelativePosition:Xo,decodeSnapshot:Qo,decodeSnapshotV2:zr,decodeStateVector:vn,decodeUpdate:hc,decodeUpdateV2:es,diffUpdate:pc,diffUpdateV2:Mn,
416
+ emptySnapshot:tc,encodeRelativePosition:Go,encodeSnapshot:Zo,encodeSnapshotV2:Br,encodeStateAsUpdate:To,encodeStateAsUpdateV2:Mr,encodeStateVector:Fo,encodeStateVectorFromUpdate:uc,encodeStateVectorFromUpdateV2:rs,
417
+ equalDeleteSets:Dr,equalSnapshots:Yo,findIndexSS:q,findRootTypeKey:Cn,getItem:Ot,getItemCleanEnd:Nn,getItemCleanStart:O,getState:A,getTypeChildren:vc,isDeleted:Nt,isParentOf:ge,iterateDeletedStructs:Pt,
418
+ logType:Ro,logUpdate:dc,logUpdateV2:ts,mergeDeleteSets:It,mergeUpdates:ns,mergeUpdatesV2:pe,obfuscateUpdate:mc,obfuscateUpdateV2:bc,parseUpdateMeta:gc,parseUpdateMetaV2:ss,readUpdate:Io,readUpdateV2:_n,
419
+ relativePositionToJSON:Vo,snapshot:ec,snapshotContainsUpdate:sc,transact:E,tryGc:oc,typeListToArraySnapshot:xc,typeMapGetAllSnapshot:ks,typeMapGetSnapshot:Ac});const il="chromeImageBands",ol="chromeIm\
420
+ ages",cl="__legacyMirrorHash",ll=[["header","default"],["header","first"],["header","even"],["footer","default"],["footer","first"],["footer","even"]],js=(e,t)=>`${e}:${t}`,zn=e=>e.getMap(il),Wn=e=>e.
421
+ getMap("metadata").get(ol);function al(e){if(e===void 0)return"none";const t=JSON.stringify(e)??"";let n=2166136261;for(let r=0;r<t.length;r++)n=Math.imul(n^t.charCodeAt(r),16777619);return(n>>>0).toString(
422
+ 36)}function dl(e){const t=zn(e).get(cl);return typeof t=="string"&&t!==al(Wn(e))}function Vs(e){const t=Wn(e);return Array.isArray(t)?t:[]}const Bs=new WeakMap,zs=new WeakMap;function hl(e){let t=Bs.
423
+ get(e);if(!t){const n={version:0};zn(e).observe(()=>{n.version++}),Bs.set(e,n),t=n}return t.version}function ul(e){if(dl(e))return Vs(e);const t=zn(e),n=Vs(e).filter(s=>!t.has(js(s.side,s.slot))),r=ll.
424
+ flatMap(([s,i])=>{const o=t.get(js(s,i));return Array.isArray(o)?o:[]});return[...n,...r]}function gl(e){const t=Wn(e),n=hl(e),r=zs.get(e);if(r&&r.legacy===t&&r.version===n)return r.records;const s=ul(
425
+ e),i=s.length>0?s:void 0;return zs.set(e,{legacy:t,version:n,records:i}),i}const Jn=["lineSpacing","spaceBefore","spaceAfter"],it=(e,t)=>e>>>t|e<<32-t,fl=e=>it(e,2)^it(e,13)^it(e,22),pl=e=>it(e,6)^it(
426
+ e,11)^it(e,25),ml=e=>it(e,7)^it(e,18)^e>>>3,bl=e=>it(e,17)^it(e,19)^e>>>10,yl=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,
427
+ 607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,
428
+ 3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,
429
+ 430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),wl=new Uint32Array([1779033703,
430
+ 3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class kl{constructor(){const t=new ArrayBuffer(320);this._H=new Uint32Array(t,0,8),this._H.set(wl),this._W=new Uint32Array(
431
+ t,64,64)}_updateHash(){const t=this._H,n=this._W;for(let h=16;h<64;h++)n[h]=bl(n[h-2])+n[h-7]+ml(n[h-15])+n[h-16];let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],l=t[5],d=t[6],a=t[7];for(let h=0,u,g;h<64;h++)u=
432
+ a+pl(c)+(c&l^~c&d)+yl[h]+n[h]>>>0,g=fl(r)+(r&s^r&i^s&i)>>>0,a=d,d=l,l=c,c=o+u>>>0,o=i,i=s,s=r,r=u+g>>>0;t[0]+=r,t[1]+=s,t[2]+=i,t[3]+=o,t[4]+=c,t[5]+=l,t[6]+=d,t[7]+=a}digest(t){let n=0;for(;n+56<=t.length;){
433
+ let o=0;for(;o<16&&n+3<t.length;o++)this._W[o]=t[n++]<<24|t[n++]<<16|t[n++]<<8|t[n++];if(n%64!==0){for(this._W.fill(0,o,16);n<t.length;)this._W[o]|=t[n]<<(3-n%4)*8,n++;this._W[o]|=F<<(3-n%4)*8}this._updateHash()}
434
+ const r=n%64!==0;this._W.fill(0,0,16);let s=0;for(;n<t.length;s++)for(let o=3;o>=0&&n<t.length;o--)this._W[s]|=t[n++]<<o*8;r||(this._W[s-(n%4===0?0:1)]|=F<<(3-n%4)*8),this._W[14]=t.byteLength/vi,this.
435
+ _W[15]=t.byteLength*8,this._updateHash();const i=new Uint8Array(32);for(let o=0;o<this._H.length;o++)for(let c=0;c<4;c++)i[o*4+c]=this._H[o]>>>(3-c)*8;return i}}const Sl=e=>new kl().digest(e),_l="revi\
436
+ se:styles:v1",vl="sharedStylesVersion",Ws="_reviseTextStyle",xl="_reviseParagraphStyle",Js=new Set(["fontFamily","fontSize","bold","italic","underline","strikethrough","doubleStrikethrough","smallCaps",
437
+ "allCaps","superscript","subscript","hidden","color","backgroundColor","letterSpacing","lang","code","docxRunPropertyResets","oxmlRPr"]),Gs=new Set(["align","lineSpacing","spaceBefore","spaceAfter","c\
438
+ ontextualSpacing","direction","tabStops","borders","shading","leftIndent","firstLineIndent","pagination"]);class qe extends Error{constructor(){super(...arguments),this.name="SharedStyleError"}}function Hs(e){
439
+ return JSON.stringify(Object.fromEntries(Object.entries(e).filter(([,t])=>t!=null).sort(([t],[n])=>t<n?-1:t>n?1:0)))}function Cl(e,t){return`${e}:${Array.from(Sl(new TextEncoder().encode(t)).subarray(
440
+ 0,16),n=>n.toString(16).padStart(2,"0")).join("")}`}function El(e){return!!e?.share.has("metadata")&&e.getMap("metadata").get(vl)===1}const Xs=new WeakMap;function qs(e,t,n){if(t==null)return{};if(!e||
441
+ typeof t!="string"||!t.startsWith(`${n}:`))throw new qe("Invalid shared style reference");const r=e.getMap(_l).get(t);if(typeof r!="string")throw new qe("Missing shared style definition; resync the do\
442
+ cument");let s=Xs.get(e);s||Xs.set(e,s=new Map);const i=s.get(t);if(i?.json===r)return i.marks;if(Cl(n,r)!==t)throw new qe("Modified shared style definition");const o=JSON.parse(r),c=n==="t"?Js:Gs;if(!o||
443
+ typeof o!="object"||Array.isArray(o)||Object.entries(o).some(([l,d])=>!c.has(l)||!["string","number","boolean"].includes(typeof d)))throw new qe("Invalid shared style properties");return Object.freeze(
444
+ o),s.size>=4096&&s.clear(),s.set(t,{json:r,marks:o}),o}function Al(e,t={}){const n={...qs(e.doc,t[Ws],"t"),...t};delete n[Ws];for(const[r,s]of Object.entries(t))Js.has(r)&&s!==null&&typeof s=="object"&&
445
+ s._reviseStyleUnset===1&&Object.keys(s).length===1&&delete n[r];return n}function $s(e){if(!El(e.doc))return e.toDelta();const t=[];for(const n of e.toDelta()){const r=Al(e,n.attributes),s={...n};Object.
446
+ keys(r).length?s.attributes=r:delete s.attributes;const i=t[t.length-1];i&&typeof i.insert=="string"&&typeof s.insert=="string"&&Hs(i.attributes??{})===Hs(s.attributes??{})?i.insert+=s.insert:t.push(s)}
447
+ return t}function $e(e,t){const n=e.getAttribute(t);return n!=null||!Gs.has(t)||!e.doc?n:qs(e.doc,e.getAttribute(xl),"p")[t]}function Dl(e){const t=e.notes;if(!t||t.length===0)return;const n=new Map;let r;
448
+ const s=c=>{if(!c||typeof c!="object")return;if(Array.isArray(c)){for(const d of c)s(d);return}const l=c;if(l.type==="text"){r===void 0&&typeof l.text=="string"&&l.text.length>0&&(r=l.marks?.fontFamily),
449
+ l.marks?.footnoteRef&&!n.has(l.marks.footnoteRef)&&n.set(l.marks.footnoteRef,l.marks?.fontFamily);return}l.children&&s(l.children)};s(e.children);let i=!1;const o=t.map(c=>{const l=c.id,d=n.has(l)?n.get(
450
+ l)??r:r;let a=!1;const h=c.children.map(u=>{if(u.type!=="paragraph"||!Array.isArray(u.children))return u;let g=!1;const f=u.children.map(p=>{if(p.type!=="text")return p;const _=p.marks??{};if(_.fontFamily===
451
+ d||d===void 0&&_.fontFamily===void 0)return p;g=!0;const k={..._};return d===void 0?delete k.fontFamily:k.fontFamily=d,{...p,marks:k}});return g?(a=!0,{...u,children:f}):u});return a?(i=!0,{...c,children:h}):
452
+ c});i&&(e.notes=o)}function Ks(e,t){if(!t)return;const n=new Set(t.split(","));n.has("keepNext")&&(e.keepNext=!0),n.has("keepLines")&&(e.keepLines=!0),n.has("noWidow")&&(e.widowControl=!1)}function we(){
453
+ const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";let t="";for(let n=0;n<6;n++)t+=e.charAt(Math.floor(Math.random()*e.length));return t}const Pl=[{value:"arial",label:"Arial",cssValue:"\
454
+ Arial, sans-serif"},{value:"helvetica",label:"Helvetica",cssValue:"Helvetica, Arial, sans-serif"},{value:"times",label:"Times New Roman",cssValue:"'Times New Roman', Times, serif"},{value:"computermod\
455
+ ern",label:"Computer Modern",cssValue:"KaTeX_Main, 'Times New Roman', serif"},{value:"georgia",label:"Georgia",cssValue:"Georgia, serif"},{value:"sourceserif4",label:"Source Serif 4",cssValue:"'Source\
456
+ Serif 4', serif"},{value:"garamond",label:"Garamond",cssValue:"Garamond, 'Times New Roman', serif"},{value:"palatino",label:"Palatino",cssValue:"'Palatino Linotype', Palatino, serif"},{value:"bookman",
457
+ label:"Bookman",cssValue:"'Bookman Old Style', Bookman, serif"},{value:"verdana",label:"Verdana",cssValue:"Verdana, Geneva, sans-serif"},{value:"trebuchet",label:"Trebuchet MS",cssValue:"'Trebuchet MS\
458
+ ', Helvetica, sans-serif"},{value:"courier",label:"Courier New",cssValue:"'Courier New', Courier, monospace"},{value:"lucida",label:"Lucida Console",cssValue:"'Lucida Console', Monaco, monospace"},{value:"\
459
+ impact",label:"Impact",cssValue:"Impact, Charcoal, sans-serif"},{value:"comicsans",label:"Comic Sans MS",cssValue:"'Comic Sans MS', cursive"}];function Nl(e){return e.trim().replace(/^["']|["']$/g,"")}
460
+ const Il=new Map;let Ys={};function Ml(e){!e||Object.keys(e).length===0||(Ys={...Ys,...e},Il.clear())}new Set(Pl.map(e=>Nl(e.cssValue.split(",")[0]).toLowerCase()));const Tl=["bold","italic","underlin\
461
+ e","strikethrough","doubleStrikethrough","smallCaps","allCaps","hidden","superscript","subscript"],ke="Arial, sans-serif",Ol=new Set(Tl);function Zs(e){const t=Ul(e);for(const n of Ol)e?.[n]===!1&&(t[n]=
462
+ !1);return t}function Ul(e){const t={};for(const[n,r]of Object.entries(e??{}))r===!0?t[n]=!0:(typeof r=="string"&&r!==""||typeof r=="number")&&(t[n]=r);return t.fontFamily||(t.fontFamily=ke),t}function Fl(e){
463
+ const t=e;return JSON.stringify(Object.keys(t).sort().map(n=>[n,t[n]]))}function Qs(e){const t=[];let n=null;for(const r of e){const s=Fl(r.marks??{}),i=t[t.length-1];if(i&&s===n){t[t.length-1]={...i,
464
+ text:i.text+r.text};continue}t.push(r),n=s}return t}Object.fromEntries("aliceblue:f0f8ff,antiquewhite:faebd7,aqua:00ffff,aquamarine:7fffd4,azure:f0ffff,beige:f5f5dc,bisque:ffe4c4,black:000000,blanched\
465
+ almond:ffebcd,blue:0000ff,blueviolet:8a2be2,brown:a52a2a,burlywood:deb887,cadetblue:5f9ea0,chartreuse:7fff00,chocolate:d2691e,coral:ff7f50,cornflowerblue:6495ed,cornsilk:fff8dc,crimson:dc143c,cyan:00f\
466
+ fff,darkblue:00008b,darkcyan:008b8b,darkgoldenrod:b8860b,darkgray:a9a9a9,darkgreen:006400,darkgrey:a9a9a9,darkkhaki:bdb76b,darkmagenta:8b008b,darkolivegreen:556b2f,darkorange:ff8c00,darkorchid:9932cc,\
467
+ darkred:8b0000,darksalmon:e9967a,darkseagreen:8fbc8f,darkslateblue:483d8b,darkslategray:2f4f4f,darkslategrey:2f4f4f,darkturquoise:00ced1,darkviolet:9400d3,deeppink:ff1493,deepskyblue:00bfff,dimgray:69\
468
+ 6969,dimgrey:696969,dodgerblue:1e90ff,firebrick:b22222,floralwhite:fffaf0,forestgreen:228b22,fuchsia:ff00ff,gainsboro:dcdcdc,ghostwhite:f8f8ff,gold:ffd700,goldenrod:daa520,gray:808080,green:008000,gre\
469
+ enyellow:adff2f,grey:808080,honeydew:f0fff0,hotpink:ff69b4,indianred:cd5c5c,indigo:4b0082,ivory:fffff0,khaki:f0e68c,lavender:e6e6fa,lavenderblush:fff0f5,lawngreen:7cfc00,lemonchiffon:fffacd,lightblue:\
470
+ add8e6,lightcoral:f08080,lightcyan:e0ffff,lightgoldenrodyellow:fafad2,lightgray:d3d3d3,lightgreen:90ee90,lightgrey:d3d3d3,lightpink:ffb6c1,lightsalmon:ffa07a,lightseagreen:20b2aa,lightskyblue:87cefa,l\
471
+ ightslategray:778899,lightslategrey:778899,lightsteelblue:b0c4de,lightyellow:ffffe0,lime:00ff00,limegreen:32cd32,linen:faf0e6,magenta:ff00ff,maroon:800000,mediumaquamarine:66cdaa,mediumblue:0000cd,med\
472
+ iumorchid:ba55d3,mediumpurple:9370db,mediumseagreen:3cb371,mediumslateblue:7b68ee,mediumspringgreen:00fa9a,mediumturquoise:48d1cc,mediumvioletred:c71585,midnightblue:191970,mintcream:f5fffa,mistyrose:\
473
+ ffe4e1,moccasin:ffe4b5,navajowhite:ffdead,navy:000080,oldlace:fdf5e6,olive:808000,olivedrab:6b8e23,orange:ffa500,orangered:ff4500,orchid:da70d6,palegoldenrod:eee8aa,palegreen:98fb98,paleturquoise:afee\
474
+ ee,palevioletred:db7093,papayawhip:ffefd5,peachpuff:ffdab9,peru:cd853f,pink:ffc0cb,plum:dda0dd,powderblue:b0e0e6,purple:800080,rebeccapurple:663399,red:ff0000,rosybrown:bc8f8f,royalblue:4169e1,saddleb\
475
+ rown:8b4513,salmon:fa8072,sandybrown:f4a460,seagreen:2e8b57,seashell:fff5ee,sienna:a0522d,silver:c0c0c0,skyblue:87ceeb,slateblue:6a5acd,slategray:708090,slategrey:708090,snow:fffafa,springgreen:00ff7f\
476
+ ,steelblue:4682b4,tan:d2b48c,teal:008080,thistle:d8bfd8,tomato:ff6347,turquoise:40e0d0,violet:ee82ee,wheat:f5deb3,white:ffffff,whitesmoke:f5f5f5,yellow:ffff00,yellowgreen:9acd32".split(",").map(e=>e.split(
477
+ ":")));const Ll=6,Rl=96,Zt=96,jl=1*Zt,Gn=Zt*.5,Vl=1;function Bl(e){return typeof e!="number"||!Number.isFinite(e)?0:Math.max(0,e)}function zl(e){return typeof e!="number"||!Number.isFinite(e)?0:Math.max(
478
+ 0,Math.round(e))}function Wl(e){if(typeof e!="number"||!Number.isFinite(e))return 0;const t=Math.round(e);return t<0?-1:t>0?1:0}function ti(e,t=Gn){return!Number.isFinite(t)||t<=0?0:Math.max(0,Math.round(
479
+ Bl(e)/t))}function ei(e,t){const n=t?.indentStepPx??Gn;if(t?.firstLine){const s=t?.storedAsUnits?Wl(e):e&&e<0?-1:ti(e,n)>0?Vl:0;return s===0?void 0:s}const r=t?.storedAsUnits?zl(e):ti(e,n);return r>0?
480
+ r:void 0}function ni(e,t){return typeof e=="object"&&e!==null&&e.constructor?.name===t}function Hn(e){return e instanceof st||ni(e,"YXmlElement")&&typeof e.nodeName=="string"&&typeof e.getAttribute=="\
481
+ function"}function Jl(e){return e instanceof Kt||ni(e,"YXmlText")&&typeof e.toDelta=="function"}const Gl="Arial, sans-serif",G=[{attr:"structuralSuggestionId",kind:"string"},{attr:"structuralSuggestio\
482
+ nKind",kind:"enum",enum:["insert","delete","split","merge","change"]},{attr:"structuralSuggestionRole",kind:"enum",enum:["before","after"]},{attr:"structuralSuggestionLabel",kind:"string"},{attr:"stru\
483
+ cturalSuggestionRecord",kind:"string"},{attr:"structuralSuggestionRecords",kind:"string"}],R=[{attr:"diffState",kind:"enum",enum:["insert","delete","equal"]},{attr:"suggestionId",kind:"string"}];[...G.
484
+ map(e=>e.attr),...R.map(e=>e.attr)];const Xn=Object.fromEntries([{type:"paragraph",attrs:[{attr:"heading",kind:"int"},{attr:"align",kind:"string"},{attr:"lineSpacing",kind:"float"},{attr:"spaceBefore",
485
+ kind:"float"},{attr:"spaceAfter",kind:"float"},{attr:"contextualSpacing",kind:"boolean"},{attr:"styleId",kind:"string"},{attr:"direction",kind:"string"},{attr:"tabStops",kind:"string"},{attr:"borders",
486
+ kind:"string"},{attr:"shading",kind:"string"},{attr:"oxmlAttrs",kind:"string"},{attr:"oxmlPPr",kind:"string"},{attr:"leftIndent",kind:"float"},{attr:"firstLineIndent",kind:"float"},...G,...R],children:"\
487
+ text"},{type:"list",attrs:[{attr:"variant",kind:"string"},{attr:"startNumber",kind:"int"},{attr:"numberingChainId",kind:"string"},{attr:"numberingFormat",kind:"string"},...Jn.map(e=>({attr:e,kind:"flo\
488
+ at"})),{attr:"contextualSpacing",kind:"boolean"},...G,...R],children:"list-items"},{type:"list-item",attrs:[...Jn.map(e=>({attr:e,kind:"float"})),{attr:"checked",kind:"boolean"},{attr:"indentLevel",kind:"\
489
+ int",validate:e=>e>0},{attr:"direction",kind:"string"},...G],children:"text"},{type:"table",attrs:[{attr:"columnWidths",kind:"json"},{attr:"tableWidth",kind:"int"},{attr:"align",kind:"enum",enum:["lef\
490
+ t","center","right"]},{attr:"borderColor",kind:"string"},{attr:"borderWidth",kind:"int"},{attr:"borders",kind:"string"},{attr:"cellPadding",kind:"int"},{attr:"hasHeader",kind:"booleanTrue"},{attr:"doc\
491
+ xTablePropertyOverrides",kind:"string"},{attr:"oxmlTblPr",kind:"string"},...G,...R],children:"table-rows"},{type:"table-row",attrs:[{attr:"oxmlAttrs",kind:"string"},{attr:"oxmlTrPr",kind:"string"},...R,
492
+ ...G],children:"blocks"},{type:"table-cell",attrs:[{attr:"verticalAlign",kind:"string"},{attr:"backgroundColor",kind:"string"},{attr:"borders",kind:"string"},{attr:"padding",kind:"string"},{attr:"colS\
493
+ pan",kind:"int",validate:e=>e>1},{attr:"rowSpan",kind:"int",validate:e=>e>1},{attr:"oxmlTcPr",kind:"string"},...R,...G],children:"blocks"},{type:"container",attrs:[{attr:"borderColor",kind:"string"},{
494
+ attr:"padding",kind:"int"},...G,...R],children:"blocks"},{type:"header-footer",attrs:[{attr:"side",kind:"enum",enum:["header","footer"]},{attr:"slot",kind:"enum",enum:["default","first","even"]},{attr:"\
495
+ sectionIndex",kind:"int",validate:e=>e>=0}],children:"blocks"},{type:"footnote",attrs:[{attr:"noteKind",kind:"enum",enum:["endnote"]},...G,...R],children:"blocks"},{type:"code",attrs:[{attr:"language",
496
+ kind:"string"},{attr:"toolCallId",kind:"string"},{attr:"renderDiagram",kind:"boolean"},{attr:"showDiagramSource",kind:"boolean"},...R,...G],children:"rawtext"},{type:"math",attrs:[{attr:"displayMode",
497
+ kind:"enum",enum:["inline","block"]},{attr:"align",kind:"enum",enum:["left","center","right"]},{attr:"showDiagramSource",kind:"boolean"},...R,...G],children:"rawtext"},{type:"image",attrs:[{attr:"src",
498
+ kind:"string"},{attr:"sourceUrl",kind:"string"},{attr:"width",kind:"int"},{attr:"height",kind:"int"},{attr:"alt",kind:"string"},{attr:"align",kind:"string"},{attr:"uploading",kind:"boolean"},{attr:"te\
499
+ mpId",kind:"string"},{attr:"originalFormat",kind:"enum",enum:["emf","wmf"]},{attr:"originalDataUrl",kind:"string"},{attr:"anchorXml",kind:"string"},...R,...G],children:"none"},{type:"page-break",attrs:[
500
+ ...R,{attr:"structuralSuggestionRecord",kind:"string"}],children:"none"},{type:"docx-raw",attrs:[{attr:"xml",kind:"string"},{attr:"tagName",kind:"string"},{attr:"detail",kind:"string"},{attr:"origin",
501
+ kind:"enum",enum:["run","body"]},...G,...R],children:"none"},{type:"section-break",attrs:[{attr:"layout",kind:"json"},{attr:"breakType",kind:"enum",enum:["nextPage","continuous","evenPage","oddPage"]},
502
+ ...R],children:"none"},{type:"toc",attrs:[{attr:"direction",kind:"enum",enum:["rtl","ltr"]},{attr:"align",kind:"enum",enum:["left","center","right","justify"]},{attr:"levels",kind:"int",validate:e=>e>=
503
+ 1&&e<=6},{attr:"instr",kind:"string"},{attr:"fontFamily",kind:"string"},{attr:"fontSize",kind:"float",validate:e=>e>=Ll&&e<=Rl},{attr:"color",kind:"string"},...R,{attr:"structuralSuggestionRecord",kind:"\
504
+ string"}],children:"none"},{type:"placeholder",attrs:[{attr:"height",kind:"int"}],children:"none"}].map(e=>[e.type,e])),Hl={image:{src:"",width:200,height:200},code:{content:""},math:{displayMode:"blo\
505
+ ck"},placeholder:{height:100},list:{variant:"unordered"}};function Xl(e,t){if(!(t==null||t===""))switch(e.kind){case"string":return t;case"int":{const n=parseInt(t,10);return Number.isNaN(n)||e.validate&&
506
+ !e.validate(n)?void 0:n}case"float":{const n=parseFloat(t);return Number.isNaN(n)||e.validate&&!e.validate(n)?void 0:n}case"boolean":return t==="true"?!0:t==="false"?!1:void 0;case"booleanTrue":return t===
507
+ "true"?!0:void 0;case"json":try{return JSON.parse(t)}catch{return}case"enum":return e.enum?.includes(t)?t:void 0}}function ql(e){const t=[],n=$s(e);for(const r of n){if(typeof r.insert!="string")continue;
508
+ const s=r.attributes||{},i={type:"text",text:r.insert,marks:Zs(s)};t.push(i)}return Qs(t)}function ri(e){for(let t=0;t<e.length;t++){const n=e.get(t);if(Jl(n))return n}return null}function si(e){const t=$e(
509
+ e,"_emptyTextMarks");let n={fontFamily:Gl};if(t)try{n=JSON.parse(t)}catch{}return[{type:"text",text:"",marks:n}]}function $l(e){const t=ri(e);if(!t)return si(e);const n=ql(t);return n.length>0?n:si(e)}
510
+ function Kl(e,t){for(const[n,r]of[["leftIndent",!1],["firstLineIndent",!0]])if(typeof e[n]=="number"){if(e[n]===0)continue;const s=ei(e[n],{indentStepPx:t.indentStepPx,storedAsUnits:t.storedAsUnits,firstLine:r});
511
+ s===void 0?delete e[n]:e[n]=s}}function Ke(e,t,n,r){const s=e.nodeName,i=Xn[s]??Xn.paragraph,o=Xn[s]?s:"paragraph",c={type:o,id:$e(e,"id")||we()};for(const d of i.attrs){const a=Xl(d,$e(e,d.attr));a!==
512
+ void 0&&(c[d.field??d.attr]=a)}o==="paragraph"&&Ks(c,$e(e,"pagination"));const l=Hl[o];if(l)for(const[d,a]of Object.entries(l))c[d]===void 0&&(c[d]=a);switch(i.children){case"text":c.children=$l(e);break;case"\
513
+ rawtext":{const d=ri(e);c.content=d?d.toString():"";break}case"blocks":{const d=[];for(const a of e.toArray())if(Hn(a)){const h=Ke(a,t);h&&d.push(h)}c.children=d;break}case"list-items":{const d=[];for(const a of e.
514
+ toArray())if(Hn(a)&&a.nodeName==="list-item"){const h=Ke(a,t);h&&d.push(h)}c.children=d;break}case"table-rows":{const d=[];for(const a of e.toArray())if(Hn(a)&&a.nodeName==="table-row"){const h=Ke(a,t);
515
+ h&&d.push(h)}c.children=d,c.columnWidths===void 0&&(c.columnWidths=[]);break}}return(o==="paragraph"||i.children==="text")&&Kl(c,t),c}function Yl(e){return!!e?.children.some(t=>t.type==="text"&&t.text.
516
+ trim()!=="")}function Zl(e){const t=e.children,n=[2,1,0].find(s=>Yl(t[s]))??-1;if(n===-1)return;const r=[];for(let s=0;s<=n;s++){s>0&&r.push({type:"text",text:" "});for(const i of t[s]?.children??[])i.
517
+ type==="text"&&i.text&&r.push(i)}return{type:"paragraph",id:e.id?`${e.id}-zone`:we(),children:r}}function Ql(e){const t={},n={};for(const r of e){if(r.type!=="header-footer"||r.sectionIndex!==void 0)continue;
518
+ const s=Zl(r);if(!s)continue;const i=r.side==="header"?t:n;i[r.slot]=[s]}return{...Object.keys(t).length>0?{headers:t}:{},...Object.keys(n).length>0?{footers:n}:{}}}const ta=["decimal","lowerRoman","u\
519
+ pperRoman"];function ii(e){return typeof e=="string"&&ta.includes(e)}const ea=["top","right","bottom","left"],na=["single","double","dotted","dashed"];function oi(e){if(e===null||e==="")return null;if(e===
520
+ void 0)return;if(typeof e=="string")try{e=JSON.parse(e)}catch{return}if(!e||typeof e!="object"||Array.isArray(e))return;const t=e,n={offsetFrom:t.offsetFrom==="page"?"page":"text",display:t.display===
521
+ "firstPage"||t.display==="notFirstPage"?t.display:"allPages",zOrder:t.zOrder==="back"?"back":"front"};for(const r of ea){const s=t[r];if(s!=null){if(!na.includes(s.style)||typeof s.color!="string"||!/^#[0-9a-f]{6}$/i.
522
+ test(s.color)||typeof s.widthPt!="number"||!Number.isFinite(s.widthPt)||s.widthPt<.25||s.widthPt>12||typeof s.spacePt!="number"||!Number.isFinite(s.spacePt)||s.spacePt<0||s.spacePt>31)return;n[r]={style:s.
523
+ style,color:s.color.toLowerCase(),widthPt:s.widthPt,spacePt:s.spacePt}}}return n}const Se=(e,t,n)=>typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n?e:void 0;function qn(e){let t=e;if(typeof e=="stri\
524
+ ng"){const n=e.trim();if(n==="")return null;try{t=JSON.parse(n)}catch{return null}}return!t||typeof t!="object"||Array.isArray(t)?null:t}function ra(e){const t=qn(e);if(!t)return null;const n=typeof t.
525
+ countBy=="number"&&Number.isFinite(t.countBy)&&t.countBy>=1?Math.round(t.countBy):1,r=typeof t.start=="number"&&Number.isFinite(t.start)&&t.start>=1?Math.round(t.start):1,s=t.restart==="newSection"||t.
526
+ restart==="continuous"?t.restart:"newPage",i=typeof t.distancePx=="number"&&Number.isFinite(t.distancePx)&&t.distancePx>=0?t.distancePx:void 0;return{countBy:n,start:r,restart:s,...i!==void 0?{distancePx:i}:
527
+ {}}}function ci(e){const t=qn(e);if(!t)return null;const n=Se(t.rows,1,200),r=Se(t.pitchPx,8,96);if(n===void 0||r===void 0)return null;const s=Se(t.firstBaselinePx,0,2e3),i=Se(t.distancePx,0,400),o=typeof t.
528
+ fontFamily=="string"&&t.fontFamily.trim()!==""&&t.fontFamily.length<=200?t.fontFamily.trim():void 0,c=Se(t.fontSizePx,4,96);return{rows:Math.round(n),pitchPx:r,...s!==void 0?{firstBaselinePx:s}:{},...i!==
529
+ void 0?{distancePx:i}:{},...o!==void 0?{fontFamily:o}:{},...c!==void 0?{fontSizePx:c}:{}}}function sa(e){const t=qn(e);return t?ci({rows:t.gridLines,pitchPx:t.gridPitchPx,fontFamily:t.fontFamily}):null}
530
+ const ia=1,w={pageBorders:"pageBorders",pageSize:"pageSize",orientation:"pageOrientation",marginPx:"pageMarginPx",marginTopPx:"pageMarginTopPx",marginRightPx:"pageMarginRightPx",marginBottomPx:"pageMa\
531
+ rginBottomPx",marginLeftPx:"pageMarginLeftPx",indentStepPx:"indentStepPx",blockSpacingPx:"blockSpacingPx",showPageNumbers:"showPageNumbers",pageNumberPosition:"pageNumberPosition",pageNumberStart:"pag\
532
+ eNumberStart",pageNumberFormat:"pageNumberFormat",pageNumberRestart:"pageNumberRestart",paragraphIndentStorageVersion:"paragraphIndentStorageVersion",hyphenationEnabled:"hyphenationEnabled",lineNumbering:"\
533
+ lineNumbering",pleadingGrid:"pleadingGrid",columnCount:"columnCount",columnGapTwips:"columnGapTwips",oxmlSectPr:"oxmlSectPr"},oa=["top-left","top-right","bottom-left","bottom-right"];function li(e){return typeof e==
534
+ "string"&&oa.includes(e)}const ai={letter:{width:8.5,height:11},tabloid:{width:11,height:17},legal:{width:8.5,height:14},statement:{width:5.5,height:8.5},executive:{width:7.25,height:10.5},folio:{width:8.5,
535
+ height:13},a3:{width:11.6929,height:16.5354},a4:{width:8.2677,height:11.6929},a5:{width:5.8268,height:8.2677},b4:{width:9.8425,height:13.8976},b5:{width:6.9291,height:9.8425}};Object.entries(ai).map(([
536
+ e,t])=>({pageSize:e,width:Math.min(t.width,t.height),height:Math.max(t.width,t.height)}));function di(e){return typeof e=="string"&&Object.prototype.hasOwnProperty.call(ai,e)}const ca=0,la=3*Zt,aa=.125*
537
+ Zt,da=2*Zt,ha=0,ua=2*Zt,ga=12,fa=1,pa=99999,ot={pageSize:"letter",orientation:"portrait",marginLeftPx:jl,indentStepPx:Gn,blockSpacingPx:ga,pageNumberPosition:"top-right",pageNumberStart:1,pageNumberFormat:"\
538
+ decimal",columnCount:1,columnGapTwips:720};function Qt(e,t,n){return Math.max(t,Math.min(n,e))}function _e(e){return typeof e!="number"||!Number.isFinite(e)?ot.marginLeftPx:Qt(e,ca,la)}function ma(e){
539
+ return typeof e!="number"||!Number.isFinite(e)?ot.indentStepPx:Qt(e,aa,da)}function ba(e){return typeof e!="number"||!Number.isFinite(e)?ot.blockSpacingPx:Qt(e,ha,ua)}function ya(e){return li(e)?e:ot.
540
+ pageNumberPosition}function wa(e){return typeof e!="number"||!Number.isFinite(e)?ot.pageNumberStart:Qt(Math.round(e),fa,pa)}function ka(e){return typeof e!="number"||!Number.isFinite(e)?ot.columnCount:
541
+ Qt(Math.round(e),1,12)}function Sa(e){return typeof e!="number"||!Number.isFinite(e)?ot.columnGapTwips:Qt(Math.round(e),0,14400)}function $n(e){const t=e?.pageSize&&di(e.pageSize)?e.pageSize:ot.pageSize,
542
+ n=e?.orientation==="landscape"||e?.orientation==="portrait"?e.orientation:ot.orientation,r=_e(e?.marginPx);return{pageSize:t,orientation:n,pageBorders:oi(e?.pageBorders),marginTopPx:_e(e?.marginTopPx??
543
+ r),marginRightPx:_e(e?.marginRightPx??r),marginBottomPx:_e(e?.marginBottomPx??r),marginLeftPx:_e(e?.marginLeftPx??r),indentStepPx:ma(e?.indentStepPx),blockSpacingPx:ba(e?.blockSpacingPx),showPageNumbers:e?.
544
+ showPageNumbers===!0,pageNumberPosition:ya(e?.pageNumberPosition),pageNumberStart:wa(e?.pageNumberStart),pageNumberFormat:ii(e?.pageNumberFormat)?e.pageNumberFormat:ot.pageNumberFormat,...e?.pageNumberRestart===
545
+ !0?{pageNumberRestart:!0}:{},noteMode:e?.noteMode==="endnotes"?"endnotes":"footnotes",columnCount:ka(e?.columnCount),columnGapTwips:Sa(e?.columnGapTwips),hyphenationEnabled:e?.hyphenationEnabled===!0,
546
+ ...(()=>{const s=e?.lineNumbering,i=e?.pleadingGrid,o=sa(s),c=i!==void 0?ci(i):o;return{lineNumbering:o||c?null:ra(s),pleadingGrid:c}})(),...(()=>{const s=e?.oxmlSectPr;return typeof s=="string"&&s?{oxmlSectPr:s}:
547
+ {}})()}}const _a=[w.pageBorders,w.pageSize,w.orientation,w.marginTopPx,w.marginRightPx,w.marginBottomPx,w.marginLeftPx,w.marginPx,w.indentStepPx,w.blockSpacingPx,w.showPageNumbers,w.pageNumberPosition,
548
+ w.pageNumberStart,w.pageNumberFormat,w.pageNumberRestart,w.hyphenationEnabled,w.lineNumbering,w.pleadingGrid,w.columnCount,w.columnGapTwips,w.oxmlSectPr];function va(e){if(!_a.some(Z=>e.has(Z)))return;
549
+ const t=e.get(w.pageSize),n=e.get(w.orientation),r=e.get(w.marginTopPx),s=e.get(w.marginRightPx),i=e.get(w.marginBottomPx),o=e.get(w.marginLeftPx),c=e.get(w.marginPx),l=e.get(w.indentStepPx),d=e.get(w.
550
+ blockSpacingPx),a=e.get(w.showPageNumbers),h=e.get(w.pageNumberPosition),u=e.get(w.pageNumberStart),g=e.get(w.hyphenationEnabled),f=e.get(w.lineNumbering),p=e.get(w.pleadingGrid),_=e.get(w.columnCount),
551
+ k=e.get(w.columnGapTwips),b=e.get(w.oxmlSectPr),M=di(t)?t:void 0;return $n({pageSize:M,orientation:n==="portrait"||n==="landscape"?n:void 0,marginTopPx:typeof r=="number"?r:void 0,marginRightPx:typeof s==
552
+ "number"?s:void 0,marginBottomPx:typeof i=="number"?i:void 0,marginLeftPx:typeof o=="number"?o:void 0,marginPx:typeof c=="number"?c:void 0,indentStepPx:typeof l=="number"?l:void 0,blockSpacingPx:typeof d==
553
+ "number"?d:void 0,showPageNumbers:typeof a=="boolean"?a:void 0,pageNumberPosition:li(h)?h:void 0,pageNumberStart:typeof u=="number"?u:void 0,pageNumberFormat:ii(e.get(w.pageNumberFormat))?e.get(w.pageNumberFormat):
554
+ void 0,pageNumberRestart:e.get(w.pageNumberRestart)===!0?!0:void 0,hyphenationEnabled:typeof g=="boolean"?g:void 0,pageBorders:oi(e.get(w.pageBorders)),lineNumbering:typeof f=="string"?f:void 0,pleadingGrid:typeof p==
555
+ "string"?p:void 0,columnCount:typeof _=="number"?_:void 0,columnGapTwips:typeof k=="number"?k:void 0,oxmlSectPr:typeof b=="string"&&b?b:void 0})}function xa(e,t){return typeof e=="object"&&e!==null&&e.
556
+ constructor?.name===t}function Kn(e){return e instanceof st||xa(e,"YXmlElement")&&typeof e.nodeName=="string"&&typeof e.getAttribute=="function"&&typeof e.setAttribute=="function"&&typeof e.get=="func\
557
+ tion"&&typeof e.length=="number"}function Ca(e){return e.get(w.paragraphIndentStorageVersion)===ia}function Ea(e){return e.share.has("paragraphs")?e.getArray("paragraphs").length>0:!1}function Aa(e){return e.
558
+ share.has("content")?e.getXmlFragment("content").length>0:!1}function Da(e){return!!(Aa(e)||Ea(e))}const hi={indentStepPx:$n(void 0).indentStepPx,storedAsUnits:!1};function ui(e,t,n=!1){return ei(e,{indentStepPx:t.
559
+ indentStepPx,storedAsUnits:t.storedAsUnits,firstLine:n})}function gi(e){const t=e.getMap("metadata"),n=t?.get("title"),r=t?.get("pageless"),s=va(t),i={indentStepPx:$n(s).indentStepPx,storedAsUnits:Ca(
560
+ t)},o=e.getXmlFragment("content");let c;if(o.length>0){c=[];for(const C of o.toArray())if(Kn(C)){const v=Yn(C,i);v&&c.push(v)}}else{const C=e.getArray("paragraphs"),v=t?.get("defaultFontFamily");c=[],
561
+ C.forEach(xt=>{const Q=ve(xt,v,i);Q&&c.push(Q)})}const l={type:"doc",children:c};n&&(l.title=n),r!==void 0&&(l.pageless=r),s&&(l.pageLayout=s);const d=t?.get("coreProperties");d&&typeof d=="object"&&Object.
562
+ keys(d).length>0&&(l.coreProperties={...d});const a=t?.get("fontSubstitutes");a&&typeof a=="object"&&Object.keys(a).length>0&&(l.fontSubstitutes={...a},Ml(l.fontSubstitutes));const h=e.getXmlFragment(
563
+ "chrome"),u=[];for(const C of h.toArray())if(Kn(C)){const v=Yn(C,i);v&&v.type==="header-footer"&&u.push(v)}u.length>0&&(l.chrome=u);const g=e.getXmlFragment("notes"),f=[];for(const C of g.toArray())if(Kn(
564
+ C)){const v=Yn(C,i);v&&v.type==="footnote"&&f.push(v)}const p=l.children.filter(C=>C.type==="footnote");p.length>0&&(l.children=l.children.filter(C=>C.type!=="footnote"),f.push(...p)),f.length>0&&(l.notes=
565
+ f,Dl(l));const _=Ql(u),k=t?.get("headers"),b=t?.get("footers"),M=_.headers??(k&&Object.keys(k).length>0?k:void 0),Z=_.footers??(b&&Object.keys(b).length>0?b:void 0);M&&(l.headers=M),Z&&(l.footers=Z);const xe=e.
566
+ getMap("comments");if(xe.size>0){const C=[];xe.forEach(v=>{v&&typeof v=="object"&&C.push(v)}),C.length>0&&(C.sort((v,xt)=>(v.createdAt??"").localeCompare(xt.createdAt??"")),l.comments=C)}const te=e.getMap(
567
+ "sdt-wrappers");if(te.size>0){const C=[];if(te.forEach(v=>{v&&typeof v=="object"&&C.push(v)}),C.length>0){const v=new Map;l.children.forEach((Q,Qe)=>{Q.id&&v.set(Q.id,Qe)});const xt=Q=>Q.blockIds?.[0]??
568
+ Q.startBlockId??"";C.sort((Q,Qe)=>(v.get(xt(Q))??Number.MAX_SAFE_INTEGER)-(v.get(xt(Qe))??Number.MAX_SAFE_INTEGER)||Q.id.localeCompare(Qe.id)),l.sdtWrappers=C}}const ee=e.getMap("oxml-ranges");if(ee.size>
569
+ 0){const C=[];ee.forEach(v=>{v&&typeof v=="object"&&C.push(v)}),C.length>0&&(C.sort((v,xt)=>v.id.localeCompare(xt.id)),l.oxmlRanges=C)}const Vt=e.getMap("metadata").get("stylesXml");typeof Vt=="string"&&
570
+ Vt.length>0&&(l.stylesXml=Vt);const Bt=e.getMap("metadata").get("stylesheet");Bt&&typeof Bt=="object"&&Array.isArray(Bt.paragraphStyles)&&Bt.paragraphStyles.length>0&&(l.stylesheet=Bt);const zt=e.getMap(
571
+ "metadata").get("docxSource");zt&&typeof zt=="object"&&Array.isArray(zt.spans)&&(l.docxSource=zt);const Zn=e.getMap("metadata").get("watermark");typeof Zn=="string"&&Zn.length>0&&(l.watermark=Zn);const bi=gl(
572
+ e);return bi&&(l.chromeImages=bi),l}function Yn(e,t=hi){return Ke(e,t)}function ve(e,t,n=hi){const r=e.get("type")||"paragraph",s=e.get("id")||we();switch(r){case"page-break":const i={type:"page-break",
573
+ id:s};{const o=e.get("diffState"),c=e.get("suggestionId");(o==="insert"||o==="delete"||o==="equal")&&(i.diffState=o),typeof c=="string"&&(i.suggestionId=c)}return i;case"section-break":{const o={type:"\
574
+ section-break",id:s},c=e.get("layout");if(typeof c=="string")try{o.layout=JSON.parse(c)}catch{}const l=e.get("breakType");(l==="nextPage"||l==="continuous"||l==="evenPage"||l==="oddPage")&&(o.breakType=
575
+ l);const d=e.get("diffState"),a=e.get("suggestionId");return(d==="insert"||d==="delete"||d==="equal")&&(o.diffState=d),typeof a=="string"&&(o.suggestionId=a),o}case"toc":{const o={type:"toc",id:s},c=e.
576
+ get("levels");typeof c=="number"&&c>=1&&c<=6&&(o.levels=c);const l=e.get("instr");typeof l=="string"&&l!==""&&(o.instr=l);const d=e.get("direction"),a=e.get("align");(d==="rtl"||d==="ltr")&&(o.direction=
577
+ d),(a==="left"||a==="center"||a==="right"||a==="justify")&&(o.align=a);const h=e.get("fontFamily");typeof h=="string"&&h!==""&&(o.fontFamily=h);const u=e.get("fontSize");typeof u=="number"&&u>0&&(o.fontSize=
578
+ u);const g=e.get("color");typeof g=="string"&&g!==""&&(o.color=g);const f=e.get("diffState"),p=e.get("suggestionId");return(f==="insert"||f==="delete"||f==="equal")&&(o.diffState=f),typeof p=="string"&&
579
+ (o.suggestionId=p),o}case"placeholder":return{type:"placeholder",id:s,height:e.get("height")||100};case"image":{const o={type:"image",id:s,src:e.get("src")||"",sourceUrl:e.get("sourceUrl")||void 0,width:e.
580
+ get("width")||200,height:e.get("height")||200,alt:e.get("alt")||void 0,align:e.get("align")||void 0},c=e.get("diffState"),l=e.get("suggestionId");(c==="insert"||c==="delete"||c==="equal")&&(o.diffState=
581
+ c),typeof l=="string"&&(o.suggestionId=l);const d=e.get("uploading");d!==void 0&&(o.uploading=d);const a=e.get("tempId");a&&(o.tempId=a);const h=e.get("originalFormat");(h==="emf"||h==="wmf")&&(o.originalFormat=
582
+ h);const u=e.get("originalDataUrl");typeof u=="string"&&u&&(o.originalDataUrl=u);const g=e.get("anchorXml");return typeof g=="string"&&g&&(o.anchorXml=g),o}case"list":{const o=e.get("items"),c=[];o&&o.
583
+ forEach(u=>{const g=Pa(u);g&&c.push(g)});const l={type:"list",id:s,variant:e.get("variant")||"unordered",children:c},d=e.get("startNumber");d!==void 0&&(l.startNumber=d);const a=e.get("numberingChainI\
584
+ d");a&&(l.numberingChainId=a);const h=e.get("numberingFormat");return h&&(l.numberingFormat=h),l}case"footnote":{const o=e.get("children"),c=[];o&&o.forEach(d=>{const a=ve(d,t,n);a&&c.push(a)});const l={
585
+ type:"footnote",id:s,children:c};return e.get("noteKind")==="endnote"&&(l.noteKind="endnote"),l}case"container":{const o=e.get("children"),c=[];o&&o.forEach(h=>{const u=ve(h,t,n);u&&c.push(u)});const l={
586
+ type:"container",id:s,children:c},d=e.get("borderColor");d&&(l.borderColor=d);const a=e.get("padding");return typeof a=="number"&&(l.padding=a),l}case"table":{const o=e.get("children"),c=[];o&&o.forEach(
587
+ b=>{const M=b.get("id")||we(),Z=b.get("children"),xe=[];Z&&Z.forEach(Bt=>{const zt=ve(Bt,t,n);zt&&xe.push(zt)});const te={type:"table-row",id:M,children:xe},ee=b.get("oxmlAttrs");typeof ee=="string"&&
588
+ ee&&(te.oxmlAttrs=ee);const Vt=b.get("oxmlTrPr");typeof Vt=="string"&&Vt&&(te.oxmlTrPr=Vt),c.push(te)});const l=e.get("columnWidths")||[],d={type:"table",id:s,children:c,columnWidths:l},a=e.get("table\
589
+ Width"),h=e.get("align"),u=e.get("borderColor"),g=e.get("borderWidth"),f=e.get("borders"),p=e.get("cellPadding"),_=e.get("hasHeader");a!==void 0&&(d.tableWidth=a),(h==="left"||h==="center"||h==="right")&&
590
+ (d.align=h),u&&(d.borderColor=u),g!==void 0&&(d.borderWidth=g),typeof f=="string"&&f&&(d.borders=f),p!==void 0&&(d.cellPadding=p),_!==void 0&&(d.hasHeader=_);const k=e.get("oxmlTblPr");return typeof k==
591
+ "string"&&k&&(d.oxmlTblPr=k),d}case"table-cell":{const o=e.get("children"),c=[];o&&o.forEach(_=>{const k=ve(_,t,n);k&&c.push(k)});const l={type:"table-cell",id:s,children:c},d=e.get("verticalAlign"),a=e.
592
+ get("backgroundColor");d&&(l.verticalAlign=d),a&&(l.backgroundColor=a);const h=e.get("borders"),u=e.get("padding");typeof h=="string"&&h&&(l.borders=h),typeof u=="string"&&u&&(l.padding=u);const g=Number(
593
+ e.get("colSpan")),f=Number(e.get("rowSpan"));Number.isFinite(g)&&g>1&&(l.colSpan=g),Number.isFinite(f)&&f>1&&(l.rowSpan=f);const p=e.get("oxmlTcPr");return typeof p=="string"&&p&&(l.oxmlTcPr=p),l}case"\
594
+ code":{const o=e.get("renderDiagram"),c=e.get("showDiagramSource"),l={type:"code",id:s,content:e.get("content")||"",language:e.get("language")||void 0,renderDiagram:typeof o=="boolean"?o:void 0,showDiagramSource:typeof c==
595
+ "boolean"?c:void 0},d=e.get("diffState"),a=e.get("suggestionId");return(d==="insert"||d==="delete"||d==="equal")&&(l.diffState=d),typeof a=="string"&&(l.suggestionId=a),l}case"math":{const o=e.get("di\
596
+ splayMode")||"block",c={type:"math",id:s,content:e.get("content")||"",displayMode:o},l=e.get("align");(l==="left"||l==="center"||l==="right"||l==="justify")&&(c.align=l);const d=e.get("diffState"),a=e.
597
+ get("suggestionId");return(d==="insert"||d==="delete"||d==="equal")&&(c.diffState=d),typeof a=="string"&&(c.suggestionId=a),e.get("showDiagramSource")===!0&&(c.showDiagramSource=!0),c}case"paragraph":default:{
598
+ const o={type:"paragraph",id:s,children:[]},c=e.get("heading"),l=e.get("align"),d=e.get("lineSpacing"),a=e.get("leftIndent"),h=e.get("firstLineIndent"),u=e.get("structuralSuggestionId"),g=e.get("struc\
599
+ turalSuggestionKind"),f=e.get("structuralSuggestionRole");c!==void 0&&(o.heading=c),l!==void 0&&(o.align=l),d!==void 0&&(o.lineSpacing=d),Ks(o,e.get("pagination"));{const b=e.get("styleId");typeof b==
600
+ "string"&&b&&(o.styleId=b)}{const b=e.get("direction");(b==="rtl"||b==="ltr")&&(o.direction=b)}{const b=e.get("tabStops");typeof b=="string"&&b&&(o.tabStops=b)}{const b=e.get("borders");typeof b=="str\
601
+ ing"&&b&&(o.borders=b)}{const b=e.get("shading");typeof b=="string"&&b&&(o.shading=b)}{const b=e.get("oxmlAttrs");typeof b=="string"&&b&&(o.oxmlAttrs=b);const M=e.get("oxmlPPr");typeof M=="string"&&M&&
602
+ (o.oxmlPPr=M)}typeof u=="string"&&(o.structuralSuggestionId=u),(g==="insert"||g==="delete"||g==="split"||g==="merge"||g==="change")&&(o.structuralSuggestionKind=g),(f==="before"||f==="after")&&(o.structuralSuggestionRole=
603
+ f);const p=ui(a,n);a===0?o.leftIndent=0:p!==void 0&&(o.leftIndent=p);const _=ui(h,n,!0);h===0?o.firstLineIndent=0:_!==void 0&&(o.firstLineIndent=_);const k=e.get("content");if(k){const b=fi(k);if(b.length>
604
+ 0)o.children=b;else{const M=e.get("_emptyTextMarks"),Z={type:"text",text:""};M&&Object.keys(M).length>0?Z.marks=M:Z.marks={fontFamily:ke},o.children=[Z]}}else o.children=[{type:"text",text:"",marks:{fontFamily:ke}}];
605
+ return t&&o.children.forEach(b=>{b.type==="text"&&(b.marks={fontFamily:t,...b.marks||{}})}),o}}}function Pa(e){if(!e)return null;const t={type:"list-item",id:e.get("id")||we(),children:[]},n=e.get("ch\
606
+ ecked");n!==void 0&&(t.checked=n);const r=e.get("indentLevel");typeof r=="number"&&r>0&&(t.indentLevel=r);for(const o of Jn){const c=e.get(o);typeof c=="number"&&Number.isFinite(c)&&c>=0&&(t[o]=c)}const s=e.
607
+ get("direction");(s==="rtl"||s==="ltr")&&(t.direction=s);const i=e.get("content");if(i){const o=fi(i);if(o.length>0)t.children=o;else{const c=e.get("_emptyTextMarks");t.children=[{type:"text",text:"",
608
+ marks:c||{fontFamily:ke}}]}}else t.children=[{type:"text",text:"",marks:{fontFamily:ke}}];return t}function fi(e){const t=[];return $s(e).forEach(n=>{if(typeof n.insert=="string"){const r=n.attributes||
609
+ {},s={type:"text",text:n.insert};s.marks=Zs(r),t.push(s)}}),Qs(t)}function jt(e,t){let n=e;for(let r=0;r<t.length;r++)n^=t.charCodeAt(r),n=Math.imul(n,16777619);return n>>>0}function pi(e,t){if(!e||typeof e!=
610
+ "object")return t;let n=t;if(typeof e.type=="string"&&(n=jt(n,e.type)),typeof e.text=="string"&&(n=jt(n,e.text)),typeof e.content=="string"&&(n=jt(n,e.content)),typeof e.language=="string"&&(n=jt(n,e.
611
+ language)),e.marks&&(n=jt(n,JSON.stringify(e.marks))),Array.isArray(e.children)){n=jt(n,"[");for(const r of e.children)n=pi(r,n);n=jt(n,"]")}return n>>>0}function Na(e){return pi(e,2166136261)}function Ye(e){
612
+ const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function Ze(e,t){try{Ir(e,t),Da(e)||mi(e,t)}catch{mi(e,t)}}function mi(e,t){const n=sl;if(typeof n.applyUpdateV2==
613
+ "function")try{n.applyUpdateV2(e,t)}catch(r){console.warn("[HistoryWorker] Failed to apply V2 update:",r)}}function Ia(e){const t=new rt({gc:!1});try{const n=Ye(e.snapshotB64);Ze(t,n);const r=e.uptoIndex<
614
+ 0?e.updatesB64.length:e.uptoIndex;for(let s=0;s<r&&s<e.updatesB64.length;s++)Ze(t,Ye(e.updatesB64[s]));return gi(t)}finally{t.destroy()}}function Ma(e){const t=new Set(e.candidateIds),n=[];let r=null;
615
+ for(const s of e.segments){const i=new rt({gc:!1});try{Ze(i,Ye(s.snapshotB64));for(let o=0;o<s.updatesB64.length;o++){Ze(i,Ye(s.updatesB64[o]));const c=s.startUpdateId+o;if(!t.has(c))continue;const l=Na(
616
+ gi(i));l!==r&&(r=l,n.push(c))}}finally{i.destroy()}}return n}self.onmessage=e=>{const t=e.data;try{if(t.kind==="filterDistinct"){const s=Ma(t),i={id:t.id,kind:"filterDistinct",success:!0,distinctIds:s};
617
+ self.postMessage(i);return}const n=Ia(t),r={id:t.id,success:!0,doc:n};self.postMessage(r)}catch(n){const r={id:t.id,kind:t.kind==="filterDistinct"?"filterDistinct":"materialize",success:!1,error:n instanceof
618
+ Error?n.message:String(n)};self.postMessage(r)}}})();