pptx-svelte-viewer 0.1.3 → 0.3.0

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.
@@ -0,0 +1,3473 @@
1
+ var T = () => /* @__PURE__ */ new Map(), me = (e) => {
2
+ const t = T();
3
+ return e.forEach((r, n) => {
4
+ t.set(n, r);
5
+ }), t;
6
+ }, J = (e, t, r) => {
7
+ let n = e.get(t);
8
+ return n === void 0 && e.set(t, n = r()), n;
9
+ }, ms = (e, t) => {
10
+ const r = [];
11
+ for (const [n, s] of e) r.push(t(s, n));
12
+ return r;
13
+ }, ys = (e, t) => {
14
+ for (const [r, n] of e) if (t(n, r)) return !0;
15
+ return !1;
16
+ }, K = () => /* @__PURE__ */ new Set(), ce = (e) => e[e.length - 1], ks = (e, t) => {
17
+ for (let r = 0; r < t.length; r++) e.push(t[r]);
18
+ }, Y = Array.from, Re = (e, t) => {
19
+ for (let r = 0; r < e.length; r++) if (!t(e[r], r, e)) return !1;
20
+ return !0;
21
+ }, Rr = (e, t) => {
22
+ for (let r = 0; r < e.length; r++) if (t(e[r], r, e)) return !0;
23
+ return !1;
24
+ }, _s = (e, t) => {
25
+ const r = new Array(e);
26
+ for (let n = 0; n < e; n++) r[n] = t(n, r);
27
+ return r;
28
+ }, zt = Array.isArray, bs = class {
29
+ constructor() {
30
+ this._observers = T();
31
+ }
32
+ on(e, t) {
33
+ return J(this._observers, e, K).add(t), t;
34
+ }
35
+ once(e, t) {
36
+ const r = (...n) => {
37
+ this.off(e, r), t(...n);
38
+ };
39
+ this.on(e, r);
40
+ }
41
+ off(e, t) {
42
+ const r = this._observers.get(e);
43
+ r !== void 0 && (r.delete(t), r.size === 0 && this._observers.delete(e));
44
+ }
45
+ emit(e, t) {
46
+ return Y((this._observers.get(e) || T()).values()).forEach((r) => r(...t));
47
+ }
48
+ destroy() {
49
+ this._observers = T();
50
+ }
51
+ }, Ho = class {
52
+ constructor() {
53
+ this._observers = T();
54
+ }
55
+ on(e, t) {
56
+ J(this._observers, e, K).add(t);
57
+ }
58
+ once(e, t) {
59
+ const r = (...n) => {
60
+ this.off(e, r), t(...n);
61
+ };
62
+ this.on(e, r);
63
+ }
64
+ off(e, t) {
65
+ const r = this._observers.get(e);
66
+ r !== void 0 && (r.delete(t), r.size === 0 && this._observers.delete(e));
67
+ }
68
+ emit(e, t) {
69
+ return Y((this._observers.get(e) || T()).values()).forEach((r) => r(...t));
70
+ }
71
+ destroy() {
72
+ this._observers = T();
73
+ }
74
+ }, B = Math.floor, xt = Math.abs, zo = Math.log10, Br = (e, t) => e < t ? e : t, Z = (e, t) => e > t ? e : t, Ko = Number.isNaN, Wo = Math.pow, Vr = (e) => e !== 0 ? e < 0 : 1 / e < 0, Fr = Date.now, V = (e) => new Error(e), M = () => {
75
+ throw V("Method unimplemented");
76
+ }, N = () => {
77
+ throw V("Unexpected case");
78
+ };
79
+ var Ss = 1 << 17, Cs = 1 << 18, Es = 1 << 19, Ds = 1 << 20, As = 1 << 21, Is = 1 << 22, Ts = 1 << 23, Os = 1 << 24, xs = 1 << 25, Ls = 1 << 26, $s = 1 << 27, Ns = 1 << 28, Ms = 1 << 29, Us = 1 << 30;
80
+ var qo = Ss - 1, Zo = Cs - 1, Qo = Es - 1, Po = Ds - 1, tc = As - 1, ec = Is - 1, rc = Ts - 1, nc = Os - 1, sc = xs - 1, ic = Ls - 1, lc = $s - 1, oc = Ns - 1, cc = Ms - 1, ac = Us - 1;
81
+ var hc = crypto.subtle, Rs = crypto.getRandomValues.bind(crypto), uc = Math.random, jr = () => Rs(/* @__PURE__ */ new Uint32Array(1))[0], Bs = "10000000-1000-4000-8000-100000000000", Vs = () => Bs.replace(/[018]/g, (e) => (e ^ jr() & 15 >> e / 4).toString(16)), Rt = Number.MAX_SAFE_INTEGER, fr = Number.MIN_SAFE_INTEGER, Fs = Number.isInteger || ((e) => typeof e == "number" && isFinite(e) && B(e) === e), dc = Number.isNaN, fc = Number.parseInt, Be = String.fromCharCode, gc = String.fromCodePoint, pc = Be(65535), js = (e) => e.toLowerCase(), Ys = /^\s*/g, Js = (e) => e.replace(Ys, ""), Xs = /([A-Z])/g, gr = (e, t) => Js(e.replace(Xs, (r) => `${t}${js(r)}`)), Gs = (e) => {
82
+ const t = unescape(encodeURIComponent(e)), r = t.length, n = new Uint8Array(r);
83
+ for (let s = 0; s < r; s++) n[s] = t.codePointAt(s);
84
+ return n;
85
+ }, pt = typeof TextEncoder < "u" ? new TextEncoder() : null, Hs = (e) => pt.encode(e), zs = pt ? Hs : Gs, gt = typeof TextDecoder > "u" ? null : new TextDecoder("utf-8", {
86
+ fatal: !0,
87
+ ignoreBOM: !0
88
+ });
89
+ gt && gt.decode(/* @__PURE__ */ new Uint8Array()).length === 1 && (gt = null);
90
+ var Ks = (e, t) => _s(t, () => e).join(""), St = class {
91
+ constructor() {
92
+ this.cpos = 0, this.cbuf = /* @__PURE__ */ new Uint8Array(100), this.bufs = [];
93
+ }
94
+ }, Kt = () => new St(), Ws = (e) => {
95
+ let t = e.cpos;
96
+ for (let r = 0; r < e.bufs.length; r++) t += e.bufs[r].length;
97
+ return t;
98
+ }, R = (e) => {
99
+ const t = new Uint8Array(Ws(e));
100
+ let r = 0;
101
+ for (let n = 0; n < e.bufs.length; n++) {
102
+ const s = e.bufs[n];
103
+ t.set(s, r), r += s.length;
104
+ }
105
+ return t.set(new Uint8Array(e.cbuf.buffer, 0, e.cpos), r), t;
106
+ }, qs = (e, t) => {
107
+ const r = e.cbuf.length;
108
+ r - e.cpos < t && (e.bufs.push(new Uint8Array(e.cbuf.buffer, 0, e.cpos)), e.cbuf = new Uint8Array(Z(r, t) * 2), e.cpos = 0);
109
+ }, _ = (e, t) => {
110
+ const r = e.cbuf.length;
111
+ e.cpos === r && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(r * 2), e.cpos = 0), e.cbuf[e.cpos++] = t;
112
+ }, ye = _, v = (e, t) => {
113
+ for (; t > 127; )
114
+ _(e, 128 | 127 & t), t = B(t / 128);
115
+ _(e, 127 & t);
116
+ }, Ve = (e, t) => {
117
+ const r = Vr(t);
118
+ for (r && (t = -t), _(e, (t > 63 ? 128 : 0) | (r ? 64 : 0) | 63 & t), t = B(t / 64); t > 0; )
119
+ _(e, (t > 127 ? 128 : 0) | 127 & t), t = B(t / 128);
120
+ }, ke = /* @__PURE__ */ new Uint8Array(3e4), Zs = ke.length / 3, Qs = (e, t) => {
121
+ if (t.length < Zs) {
122
+ const r = pt.encodeInto(t, ke).written || 0;
123
+ v(e, r);
124
+ for (let n = 0; n < r; n++) _(e, ke[n]);
125
+ } else O(e, zs(t));
126
+ }, Ps = (e, t) => {
127
+ const r = unescape(encodeURIComponent(t)), n = r.length;
128
+ v(e, n);
129
+ for (let s = 0; s < n; s++) _(e, r.codePointAt(s));
130
+ }, rt = pt && pt.encodeInto ? Qs : Ps, Wt = (e, t) => {
131
+ const r = e.cbuf.length, n = e.cpos, s = Br(r - n, t.length), i = t.length - s;
132
+ e.cbuf.set(t.subarray(0, s), n), e.cpos += s, i > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(Z(r * 2, i)), e.cbuf.set(t.subarray(s)), e.cpos = i);
133
+ }, O = (e, t) => {
134
+ v(e, t.byteLength), Wt(e, t);
135
+ }, Fe = (e, t) => {
136
+ qs(e, t);
137
+ const r = new DataView(e.cbuf.buffer, e.cpos, t);
138
+ return e.cpos += t, r;
139
+ }, ti = (e, t) => Fe(e, 4).setFloat32(0, t, !1), ei = (e, t) => Fe(e, 8).setFloat64(0, t, !1), ri = (e, t) => Fe(e, 8).setBigInt64(0, t, !1), pr = /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(4)), ni = (e) => (pr.setFloat32(0, e), pr.getFloat32(0) === e), vt = (e, t) => {
140
+ switch (typeof t) {
141
+ case "string":
142
+ _(e, 119), rt(e, t);
143
+ break;
144
+ case "number":
145
+ Fs(t) && xt(t) <= 2147483647 ? (_(e, 125), Ve(e, t)) : ni(t) ? (_(e, 124), ti(e, t)) : (_(e, 123), ei(e, t));
146
+ break;
147
+ case "bigint":
148
+ _(e, 122), ri(e, t);
149
+ break;
150
+ case "object":
151
+ if (t === null) _(e, 126);
152
+ else if (zt(t)) {
153
+ _(e, 117), v(e, t.length);
154
+ for (let r = 0; r < t.length; r++) vt(e, t[r]);
155
+ } else if (t instanceof Uint8Array)
156
+ _(e, 116), O(e, t);
157
+ else {
158
+ _(e, 118);
159
+ const r = Object.keys(t);
160
+ v(e, r.length);
161
+ for (let n = 0; n < r.length; n++) {
162
+ const s = r[n];
163
+ rt(e, s), vt(e, t[s]);
164
+ }
165
+ }
166
+ break;
167
+ case "boolean":
168
+ _(e, t ? 120 : 121);
169
+ break;
170
+ default:
171
+ _(e, 127);
172
+ }
173
+ }, vr = class extends St {
174
+ constructor(e) {
175
+ super(), this.w = e, this.s = null, this.count = 0;
176
+ }
177
+ write(e) {
178
+ this.s === e ? this.count++ : (this.count > 0 && v(this, this.count - 1), this.count = 1, this.w(this, e), this.s = e);
179
+ }
180
+ }, wr = (e) => {
181
+ e.count > 0 && (Ve(e.encoder, e.count === 1 ? e.s : -e.s), e.count > 1 && v(e.encoder, e.count - 2));
182
+ }, Lt = class {
183
+ constructor() {
184
+ this.encoder = new St(), this.s = 0, this.count = 0;
185
+ }
186
+ write(e) {
187
+ this.s === e ? this.count++ : (wr(this), this.count = 1, this.s = e);
188
+ }
189
+ toUint8Array() {
190
+ return wr(this), R(this.encoder);
191
+ }
192
+ }, mr = (e) => {
193
+ if (e.count > 0) {
194
+ const t = e.diff * 2 + (e.count === 1 ? 0 : 1);
195
+ Ve(e.encoder, t), e.count > 1 && v(e.encoder, e.count - 2);
196
+ }
197
+ }, ae = class {
198
+ constructor() {
199
+ this.encoder = new St(), this.s = 0, this.count = 0, this.diff = 0;
200
+ }
201
+ write(e) {
202
+ this.diff === e - this.s ? (this.s = e, this.count++) : (mr(this), this.count = 1, this.diff = e - this.s, this.s = e);
203
+ }
204
+ toUint8Array() {
205
+ return mr(this), R(this.encoder);
206
+ }
207
+ }, si = class {
208
+ constructor() {
209
+ this.sarr = [], this.s = "", this.lensE = new Lt();
210
+ }
211
+ write(e) {
212
+ this.s += e, this.s.length > 19 && (this.sarr.push(this.s), this.s = ""), this.lensE.write(e.length);
213
+ }
214
+ toUint8Array() {
215
+ const e = new St();
216
+ return this.sarr.push(this.s), this.s = "", rt(e, this.sarr.join("")), Wt(e, this.lensE.toUint8Array()), R(e);
217
+ }
218
+ }, Yr = V("Unexpected end of array"), Jr = V("Integer out of Range"), qt = class {
219
+ constructor(e) {
220
+ this.arr = e, this.pos = 0;
221
+ }
222
+ }, ht = (e) => new qt(e), ii = (e) => e.pos !== e.arr.length, li = (e, t) => {
223
+ const r = new Uint8Array(e.arr.buffer, e.pos + e.arr.byteOffset, t);
224
+ return e.pos += t, r;
225
+ }, x = (e) => li(e, p(e)), lt = (e) => e.arr[e.pos++], p = (e) => {
226
+ let t = 0, r = 1;
227
+ const n = e.arr.length;
228
+ for (; e.pos < n; ) {
229
+ const s = e.arr[e.pos++];
230
+ if (t = t + (s & 127) * r, r *= 128, s < 128) return t;
231
+ if (t > Rt) throw Jr;
232
+ }
233
+ throw Yr;
234
+ }, je = (e) => {
235
+ let t = e.arr[e.pos++], r = t & 63, n = 64;
236
+ const s = (t & 64) > 0 ? -1 : 1;
237
+ if ((t & 128) === 0) return s * r;
238
+ const i = e.arr.length;
239
+ for (; e.pos < i; ) {
240
+ if (t = e.arr[e.pos++], r = r + (t & 127) * n, n *= 128, t < 128) return s * r;
241
+ if (r > Rt) throw Jr;
242
+ }
243
+ throw Yr;
244
+ }, oi = (e) => {
245
+ let t = p(e);
246
+ if (t === 0) return "";
247
+ {
248
+ let r = String.fromCodePoint(lt(e));
249
+ if (--t < 100) for (; t--; ) r += String.fromCodePoint(lt(e));
250
+ else for (; t > 0; ) {
251
+ const n = t < 1e4 ? t : 1e4, s = e.arr.subarray(e.pos, e.pos + n);
252
+ e.pos += n, r += String.fromCodePoint.apply(null, s), t -= n;
253
+ }
254
+ return decodeURIComponent(escape(r));
255
+ }
256
+ }, ci = (e) => gt.decode(x(e)), nt = gt ? ci : oi, Ye = (e, t) => {
257
+ const r = new DataView(e.arr.buffer, e.arr.byteOffset + e.pos, t);
258
+ return e.pos += t, r;
259
+ }, ai = (e) => Ye(e, 4).getFloat32(0, !1), hi = (e) => Ye(e, 8).getFloat64(0, !1), ui = (e) => Ye(e, 8).getBigInt64(0, !1), di = [
260
+ (e) => {
261
+ },
262
+ (e) => null,
263
+ je,
264
+ ai,
265
+ hi,
266
+ ui,
267
+ (e) => !1,
268
+ (e) => !0,
269
+ nt,
270
+ (e) => {
271
+ const t = p(e), r = {};
272
+ for (let n = 0; n < t; n++) {
273
+ const s = nt(e);
274
+ r[s] = wt(e);
275
+ }
276
+ return r;
277
+ },
278
+ (e) => {
279
+ const t = p(e), r = [];
280
+ for (let n = 0; n < t; n++) r.push(wt(e));
281
+ return r;
282
+ },
283
+ x
284
+ ], wt = (e) => di[127 - lt(e)](e), yr = class extends qt {
285
+ constructor(e, t) {
286
+ super(e), this.reader = t, this.s = null, this.count = 0;
287
+ }
288
+ read() {
289
+ return this.count === 0 && (this.s = this.reader(this), ii(this) ? this.count = p(this) + 1 : this.count = -1), this.count--, this.s;
290
+ }
291
+ }, $t = class extends qt {
292
+ constructor(e) {
293
+ super(e), this.s = 0, this.count = 0;
294
+ }
295
+ read() {
296
+ if (this.count === 0) {
297
+ this.s = je(this);
298
+ const e = Vr(this.s);
299
+ this.count = 1, e && (this.s = -this.s, this.count = p(this) + 2);
300
+ }
301
+ return this.count--, this.s;
302
+ }
303
+ }, he = class extends qt {
304
+ constructor(e) {
305
+ super(e), this.s = 0, this.count = 0, this.diff = 0;
306
+ }
307
+ read() {
308
+ if (this.count === 0) {
309
+ const e = je(this), t = e & 1;
310
+ this.diff = B(e / 2), this.count = 1, t && (this.count = p(this) + 2);
311
+ }
312
+ return this.s += this.diff, this.count--, this.s;
313
+ }
314
+ }, fi = class {
315
+ constructor(e) {
316
+ this.decoder = new $t(e), this.str = nt(this.decoder), this.spos = 0;
317
+ }
318
+ read() {
319
+ const e = this.spos + this.decoder.read(), t = this.str.slice(this.spos, e);
320
+ return this.spos = e, t;
321
+ }
322
+ }, kr = (e) => e === void 0 ? null : e, gi = class {
323
+ constructor() {
324
+ this.map = /* @__PURE__ */ new Map();
325
+ }
326
+ setItem(e, t) {
327
+ this.map.set(e, t);
328
+ }
329
+ getItem(e) {
330
+ return this.map.get(e);
331
+ }
332
+ }, Xr = new gi(), Je = !0;
333
+ try {
334
+ typeof localStorage < "u" && localStorage && (Xr = localStorage, Je = !1);
335
+ } catch {
336
+ }
337
+ var pi = Xr, vc = (e) => Je || addEventListener("storage", e), wc = (e) => Je || removeEventListener("storage", e), mt = /* @__PURE__ */ Symbol("Equality"), Gr = (e, t) => e === t || !!e?.[mt]?.(t) || !1, vi = (e) => typeof e == "object", wi = Object.assign, mi = Object.keys, yi = (e, t) => {
338
+ for (const r in e) t(e[r], r);
339
+ }, mc = (e, t) => {
340
+ const r = [];
341
+ for (const n in e) r.push(t(e[n], n));
342
+ return r;
343
+ }, Bt = (e) => mi(e).length, ki = (e) => {
344
+ for (const t in e) return !1;
345
+ return !0;
346
+ }, Ct = (e, t) => {
347
+ for (const r in e) if (!t(e[r], r)) return !1;
348
+ return !0;
349
+ }, Xe = (e, t) => Object.prototype.hasOwnProperty.call(e, t), _i = (e, t) => e === t || Bt(e) === Bt(t) && Ct(e, (r, n) => (r !== void 0 || Xe(t, n)) && Gr(t[n], r)), bi = Object.freeze, Hr = (e) => {
350
+ for (const t in e) {
351
+ const r = e[t];
352
+ (typeof r == "object" || typeof r == "function") && Hr(e[t]);
353
+ }
354
+ return bi(e);
355
+ }, Ge = (e, t, r = 0) => {
356
+ try {
357
+ for (; r < e.length; r++) e[r](...t);
358
+ } finally {
359
+ r < e.length && Ge(e, t, r + 1);
360
+ }
361
+ }, Si = () => {
362
+ }, Ci = (e) => e, Nt = (e, t) => {
363
+ if (e === t) return !0;
364
+ if (e == null || t == null || e.constructor !== t.constructor && (e.constructor || Object) !== (t.constructor || Object)) return !1;
365
+ if (e[mt] != null) return e[mt](t);
366
+ switch (e.constructor) {
367
+ case ArrayBuffer:
368
+ e = new Uint8Array(e), t = new Uint8Array(t);
369
+ case Uint8Array:
370
+ if (e.byteLength !== t.byteLength) return !1;
371
+ for (let r = 0; r < e.length; r++) if (e[r] !== t[r]) return !1;
372
+ break;
373
+ case Set:
374
+ if (e.size !== t.size) return !1;
375
+ for (const r of e) if (!t.has(r)) return !1;
376
+ break;
377
+ case Map:
378
+ if (e.size !== t.size) return !1;
379
+ for (const r of e.keys()) if (!t.has(r) || !Nt(e.get(r), t.get(r))) return !1;
380
+ break;
381
+ case void 0:
382
+ case Object:
383
+ if (Bt(e) !== Bt(t)) return !1;
384
+ for (const r in e) if (!Xe(e, r) || !Nt(e[r], t[r])) return !1;
385
+ break;
386
+ case Array:
387
+ if (e.length !== t.length) return !1;
388
+ for (let r = 0; r < e.length; r++) if (!Nt(e[r], t[r])) return !1;
389
+ break;
390
+ default:
391
+ return !1;
392
+ }
393
+ return !0;
394
+ }, Ei = (e, t) => t.includes(e), ot = typeof process < "u" && process.release && /node|io\.js/.test(process.release.name) && Object.prototype.toString.call(typeof process < "u" ? process : 0) === "[object process]", zr = typeof window < "u" && typeof document < "u" && !ot, yc = typeof navigator < "u" ? /Mac/.test(navigator.platform) : !1, U, Di = [], Ai = () => {
395
+ if (U === void 0) if (ot) {
396
+ U = T();
397
+ const e = process.argv;
398
+ let t = null;
399
+ for (let r = 0; r < e.length; r++) {
400
+ const n = e[r];
401
+ n[0] === "-" ? (t !== null && U.set(t, ""), t = n) : t !== null ? (U.set(t, n), t = null) : Di.push(n);
402
+ }
403
+ t !== null && U.set(t, "");
404
+ } else typeof location == "object" ? (U = T(), (location.search || "?").slice(1).split("&").forEach((e) => {
405
+ if (e.length !== 0) {
406
+ const [t, r] = e.split("=");
407
+ U.set(`--${gr(t, "-")}`, r), U.set(`-${gr(t, "-")}`, r);
408
+ }
409
+ })) : U = T();
410
+ return U;
411
+ }, _e = (e) => Ai().has(e), yt = (e) => kr(ot ? process.env[e.toUpperCase().replaceAll("-", "_")] : pi.getItem(e)), Kr = (e) => _e("--" + e) || yt(e) !== null, Ii = Kr("production"), Ti = ot && Ei(process.env.FORCE_COLOR, [
412
+ "true",
413
+ "1",
414
+ "2"
415
+ ]), Oi = Ti || !_e("--no-colors") && !Kr("no-color") && (!ot || process.stdout.isTTY) && (!ot || _e("--color") || yt("COLORTERM") !== null || (yt("TERM") || "").includes("color")), xi = class {
416
+ constructor(e, t) {
417
+ this.left = e, this.right = t;
418
+ }
419
+ }, j = (e, t) => new xi(e, t), Wr = (e) => new Uint8Array(e), Li = (e, t, r) => new Uint8Array(e, t, r), kc = (e) => new Uint8Array(e), $i = (e) => {
420
+ let t = "";
421
+ for (let r = 0; r < e.byteLength; r++) t += Be(e[r]);
422
+ return btoa(t);
423
+ }, Ni = (e) => Buffer.from(e.buffer, e.byteOffset, e.byteLength).toString("base64"), Mi = (e) => {
424
+ const t = atob(e), r = Wr(t.length);
425
+ for (let n = 0; n < t.length; n++) r[n] = t.charCodeAt(n);
426
+ return r;
427
+ }, Ui = (e) => {
428
+ const t = Buffer.from(e, "base64");
429
+ return Li(t.buffer, t.byteOffset, t.byteLength);
430
+ }, _c = zr ? $i : Ni, bc = zr ? Mi : Ui, Ri = (e) => {
431
+ const t = Wr(e.byteLength);
432
+ return t.set(e), t;
433
+ }, _r = (e) => e.next() >= 0.5, ue = (e, t, r) => B(e.next() * (r + 1 - t) + t), qr = (e, t, r) => B(e.next() * (r + 1 - t) + t), He = (e, t, r) => qr(e, t, r), Bi = (e) => Be(He(e, 97, 122)), Vi = (e, t = 0, r = 20) => {
434
+ const n = He(e, t, r);
435
+ let s = "";
436
+ for (let i = 0; i < n; i++) s += Bi(e);
437
+ return s;
438
+ }, de = (e, t) => t[He(e, 0, t.length - 1)], Fi = /* @__PURE__ */ Symbol("0schema"), ji = class {
439
+ constructor() {
440
+ this._rerrs = [];
441
+ }
442
+ extend(e, t, r, n = null) {
443
+ this._rerrs.push({
444
+ path: e,
445
+ expected: t,
446
+ has: r,
447
+ message: n
448
+ });
449
+ }
450
+ toString() {
451
+ const e = [];
452
+ for (let t = this._rerrs.length - 1; t > 0; t--) {
453
+ const r = this._rerrs[t];
454
+ e.push(Ks(" ", (this._rerrs.length - t) * 2) + `${r.path != null ? `[${r.path}] ` : ""}${r.has} doesn't match ${r.expected}. ${r.message}`);
455
+ }
456
+ return e.join(`
457
+ `);
458
+ }
459
+ }, be = (e, t) => e === t ? !0 : e == null || t == null || e.constructor !== t.constructor ? !1 : e[mt] ? Gr(e, t) : zt(e) ? Re(e, (r) => Rr(t, (n) => be(r, n))) : vi(e) ? Ct(e, (r, n) => be(r, t[n])) : !1, I = class {
460
+ static _dilutes = !1;
461
+ extends(e) {
462
+ let [t, r] = [this.shape, e.shape];
463
+ return this.constructor._dilutes && ([r, t] = [t, r]), be(t, r);
464
+ }
465
+ equals(e) {
466
+ return this.constructor === e.constructor && Nt(this.shape, e.shape);
467
+ }
468
+ [Fi]() {
469
+ return !0;
470
+ }
471
+ [mt](e) {
472
+ return this.equals(e);
473
+ }
474
+ validate(e) {
475
+ return this.check(e);
476
+ }
477
+ /* c8 ignore start */
478
+ check(e, t) {
479
+ M();
480
+ }
481
+ /* c8 ignore stop */
482
+ get nullable() {
483
+ return ut(this, te);
484
+ }
485
+ get optional() {
486
+ return new Pr(this);
487
+ }
488
+ cast(e) {
489
+ return br(e, this), e;
490
+ }
491
+ expect(e) {
492
+ return br(e, this), e;
493
+ }
494
+ }, ze = class extends I {
495
+ constructor(e, t) {
496
+ super(), this.shape = e, this._c = t;
497
+ }
498
+ check(e, t = void 0) {
499
+ const r = e?.constructor === this.shape && (this._c == null || this._c(e));
500
+ return !r && t?.extend(null, this.shape.name, e?.constructor.name, e?.constructor !== this.shape ? "Constructor match failed" : "Check failed"), r;
501
+ }
502
+ }, k = (e, t = null) => new ze(e, t), Sc = k(ze), Ke = class extends I {
503
+ constructor(e) {
504
+ super(), this.shape = e;
505
+ }
506
+ check(e, t) {
507
+ const r = this.shape(e);
508
+ return !r && t?.extend(null, "custom prop", e?.constructor.name, "failed to check custom prop"), r;
509
+ }
510
+ }, S = (e) => new Ke(e), Cc = k(Ke), Zt = class extends I {
511
+ constructor(e) {
512
+ super(), this.shape = e;
513
+ }
514
+ check(e, t) {
515
+ const r = this.shape.some((n) => n === e);
516
+ return !r && t?.extend(null, this.shape.join(" | "), e.toString()), r;
517
+ }
518
+ }, Qt = (...e) => new Zt(e), Zr = k(Zt), Yi = RegExp.escape || ((e) => e.replace(/[().|&,$^[\]]/g, (t) => "\\" + t)), Qr = (e) => {
519
+ if (ct.check(e)) return [Yi(e)];
520
+ if (Zr.check(e)) return e.shape.map((t) => t + "");
521
+ if (dn.check(e)) return ["[+-]?\\d+.?\\d*"];
522
+ if (fn.check(e)) return [".*"];
523
+ if (Vt.check(e)) return e.shape.map(Qr).flat(1);
524
+ N();
525
+ }, Ji = class extends I {
526
+ constructor(e) {
527
+ super(), this.shape = e, this._r = new RegExp("^" + e.map(Qr).map((t) => `(${t.join("|")})`).join("") + "$");
528
+ }
529
+ check(e, t) {
530
+ const r = this._r.exec(e) != null;
531
+ return !r && t?.extend(null, this._r.toString(), e.toString(), "String doesn't match string template."), r;
532
+ }
533
+ }, Ec = k(Ji), Xi = /* @__PURE__ */ Symbol("optional"), Pr = class extends I {
534
+ constructor(e) {
535
+ super(), this.shape = e;
536
+ }
537
+ check(e, t) {
538
+ const r = e === void 0 || this.shape.check(e);
539
+ return !r && t?.extend(null, "undefined (optional)", "()"), r;
540
+ }
541
+ get [Xi]() {
542
+ return !0;
543
+ }
544
+ }, Gi = k(Pr), tn = class extends I {
545
+ check(e, t) {
546
+ return t?.extend(null, "never", typeof e), !1;
547
+ }
548
+ }, Dc = new tn(), Ac = k(tn), en = class rn extends I {
549
+ constructor(t, r = !1) {
550
+ super(), this.shape = t, this._isPartial = r;
551
+ }
552
+ static _dilutes = !0;
553
+ get partial() {
554
+ return new rn(this.shape, !0);
555
+ }
556
+ check(t, r) {
557
+ return t == null ? (r?.extend(null, "object", "null"), !1) : Ct(this.shape, (n, s) => {
558
+ const i = this._isPartial && !Xe(t, s) || n.check(t[s], r);
559
+ return !i && r?.extend(s.toString(), n.toString(), typeof t[s], "Object property does not match"), i;
560
+ });
561
+ }
562
+ }, Hi = (e) => new en(e), zi = k(en), Ki = S((e) => e != null && (e.constructor === Object || e.constructor == null)), nn = class extends I {
563
+ constructor(e, t) {
564
+ super(), this.shape = {
565
+ keys: e,
566
+ values: t
567
+ };
568
+ }
569
+ check(e, t) {
570
+ return e != null && Ct(e, (r, n) => {
571
+ const s = this.shape.keys.check(n, t);
572
+ return !s && t?.extend(n + "", "Record", typeof e, s ? "Key doesn't match schema" : "Value doesn't match value"), s && this.shape.values.check(r, t);
573
+ });
574
+ }
575
+ }, sn = (e, t) => new nn(e, t), Wi = k(nn), ln = class extends I {
576
+ constructor(e) {
577
+ super(), this.shape = e;
578
+ }
579
+ check(e, t) {
580
+ return e != null && Ct(this.shape, (r, n) => {
581
+ const s = r.check(e[n], t);
582
+ return !s && t?.extend(n.toString(), "Tuple", typeof r), s;
583
+ });
584
+ }
585
+ }, qi = (...e) => new ln(e), Ic = k(ln), on = class extends I {
586
+ constructor(e) {
587
+ super(), this.shape = e.length === 1 ? e[0] : new We(e);
588
+ }
589
+ check(e, t) {
590
+ const r = zt(e) && Re(e, (n) => this.shape.check(n));
591
+ return !r && t?.extend(null, "Array", ""), r;
592
+ }
593
+ }, cn = (...e) => new on(e), Zi = k(on), Qi = S((e) => zt(e)), an = class extends I {
594
+ constructor(e, t) {
595
+ super(), this.shape = e, this._c = t;
596
+ }
597
+ check(e, t) {
598
+ const r = e instanceof this.shape && (this._c == null || this._c(e));
599
+ return !r && t?.extend(null, this.shape.name, e?.constructor.name), r;
600
+ }
601
+ }, Pi = (e, t = null) => new an(e, t), Tc = k(an), tl = Pi(I), el = class extends I {
602
+ constructor(e) {
603
+ super(), this.len = e.length - 1, this.args = qi(...e.slice(-1)), this.res = e[this.len];
604
+ }
605
+ check(e, t) {
606
+ const r = e.constructor === Function && e.length <= this.len;
607
+ return !r && t?.extend(null, "function", typeof e), r;
608
+ }
609
+ }, rl = k(el), nl = S((e) => typeof e == "function"), sl = class extends I {
610
+ constructor(e) {
611
+ super(), this.shape = e;
612
+ }
613
+ check(e, t) {
614
+ const r = Re(this.shape, (n) => n.check(e, t));
615
+ return !r && t?.extend(null, "Intersectinon", typeof e), r;
616
+ }
617
+ }, Oc = k(sl, (e) => e.shape.length > 0), We = class extends I {
618
+ static _dilutes = !0;
619
+ constructor(e) {
620
+ super(), this.shape = e;
621
+ }
622
+ check(e, t) {
623
+ const r = Rr(this.shape, (n) => n.check(e, t));
624
+ return t?.extend(null, "Union", typeof e), r;
625
+ }
626
+ }, ut = (...e) => e.findIndex((t) => Vt.check(t)) >= 0 ? ut(...e.map((t) => kt(t)).map((t) => Vt.check(t) ? t.shape : [t]).flat(1)) : e.length === 1 ? e[0] : new We(e), Vt = k(We), hn = () => !0, Ft = S(hn), il = k(Ke, (e) => e.shape === hn), qe = S((e) => typeof e == "bigint"), ll = S((e) => e === qe), un = S((e) => typeof e == "symbol"), xc = S((e) => e === un), st = S((e) => typeof e == "number"), dn = S((e) => e === st), ct = S((e) => typeof e == "string"), fn = S((e) => e === ct), Pt = S((e) => typeof e == "boolean"), ol = S((e) => e === Pt), gn = Qt(void 0), Lc = k(Zt, (e) => e.shape.length === 1 && e.shape[0] === void 0), $c = Qt(void 0), te = Qt(null), cl = k(Zt, (e) => e.shape.length === 1 && e.shape[0] === null), Nc = k(Uint8Array), Mc = k(ze, (e) => e.shape === Uint8Array), al = ut(st, ct, te, gn, qe, Pt, un), Uc = (() => {
627
+ const e = cn(Ft), t = sn(ct, Ft), r = ut(st, ct, te, Pt, e, t);
628
+ return e.shape = r, t.shape.values = r, r;
629
+ })(), kt = (e) => {
630
+ if (tl.check(e)) return e;
631
+ if (Ki.check(e)) {
632
+ const t = {};
633
+ for (const r in e) t[r] = kt(e[r]);
634
+ return Hi(t);
635
+ } else {
636
+ if (Qi.check(e)) return ut(...e.map(kt));
637
+ if (al.check(e)) return Qt(e);
638
+ if (nl.check(e)) return k(e);
639
+ }
640
+ N();
641
+ }, br = Ii ? () => {
642
+ } : (e, t) => {
643
+ const r = new ji();
644
+ if (!t.check(e, r)) throw V(`Expected value to be of type ${t.constructor.name}.
645
+ ${r.toString()}`);
646
+ }, hl = class {
647
+ constructor(e) {
648
+ this.patterns = [], this.$state = e;
649
+ }
650
+ if(e, t) {
651
+ return this.patterns.push({
652
+ if: kt(e),
653
+ h: t
654
+ }), this;
655
+ }
656
+ else(e) {
657
+ return this.if(Ft, e);
658
+ }
659
+ done() {
660
+ return (e, t) => {
661
+ for (let r = 0; r < this.patterns.length; r++) {
662
+ const n = this.patterns[r];
663
+ if (n.if.check(e)) return n.h(e, t);
664
+ }
665
+ throw V("Unhandled pattern");
666
+ };
667
+ }
668
+ }, ul = (e) => new hl(e), pn = ul(Ft).if(dn, (e, t) => ue(t, fr, Rt)).if(fn, (e, t) => Vi(t)).if(ol, (e, t) => _r(t)).if(ll, (e, t) => BigInt(ue(t, fr, Rt))).if(Vt, (e, t) => tt(t, de(t, e.shape))).if(zi, (e, t) => {
669
+ const r = {};
670
+ for (const n in e.shape) {
671
+ let s = e.shape[n];
672
+ if (Gi.check(s)) {
673
+ if (_r(t)) continue;
674
+ s = s.shape;
675
+ }
676
+ r[n] = pn(s, t);
677
+ }
678
+ return r;
679
+ }).if(Zi, (e, t) => {
680
+ const r = [], n = qr(t, 0, 42);
681
+ for (let s = 0; s < n; s++) r.push(tt(t, e.shape));
682
+ return r;
683
+ }).if(Zr, (e, t) => de(t, e.shape)).if(cl, (e, t) => null).if(rl, (e, t) => {
684
+ const r = tt(t, e.res);
685
+ return () => r;
686
+ }).if(il, (e, t) => tt(t, de(t, [
687
+ st,
688
+ ct,
689
+ te,
690
+ gn,
691
+ qe,
692
+ Pt,
693
+ cn(st),
694
+ sn(ut("a", "b", "c"), st)
695
+ ]))).if(Wi, (e, t) => {
696
+ const r = {}, n = ue(t, 0, 3);
697
+ for (let s = 0; s < n; s++) {
698
+ const i = tt(t, e.shape.keys);
699
+ r[i] = tt(t, e.shape.values);
700
+ }
701
+ return r;
702
+ }).done(), tt = (e, t) => pn(kt(t), e), Q = typeof document < "u" ? document : {}, Rc = S((e) => e.nodeType === vl), Bc = typeof DOMParser < "u" ? new DOMParser() : null, Vc = S((e) => e.nodeType === fl), Fc = S((e) => e.nodeType === gl), dl = (e) => ms(e, (t, r) => `${r}:${t};`).join(""), fl = Q.ELEMENT_NODE, gl = Q.TEXT_NODE, jc = Q.CDATA_SECTION_NODE, Yc = Q.COMMENT_NODE, pl = Q.DOCUMENT_NODE, Jc = Q.DOCUMENT_TYPE_NODE, vl = Q.DOCUMENT_FRAGMENT_NODE, Xc = S((e) => e.nodeType === pl), wl = JSON.stringify, X = Symbol, vn = X(), wn = X(), mn = X(), ml = X(), yn = X(), kn = X(), _n = X(), ee = X(), bn = X(), yl = (e) => {
703
+ e.length === 1 && e[0]?.constructor === Function && (e = e[0]());
704
+ const t = [], r = [];
705
+ let n = 0;
706
+ for (; n < e.length; n++) {
707
+ const s = e[n];
708
+ if (s === void 0) break;
709
+ if (s.constructor === String || s.constructor === Number) t.push(s);
710
+ else if (s.constructor === Object) break;
711
+ }
712
+ for (n > 0 && r.push(t.join("")); n < e.length; n++) {
713
+ const s = e[n];
714
+ s instanceof Symbol || r.push(s);
715
+ }
716
+ return r;
717
+ }, Sr = [
718
+ yn,
719
+ _n,
720
+ ee,
721
+ mn
722
+ ], fe = 0, Cr = Fr(), kl = (e, t) => {
723
+ const r = Sr[fe], n = yt("log"), s = n !== null && (n === "*" || n === "true" || new RegExp(n, "gi").test(t));
724
+ return fe = (fe + 1) % Sr.length, t += ": ", s ? (...i) => {
725
+ i.length === 1 && i[0]?.constructor === Function && (i = i[0]());
726
+ const l = Fr(), o = l - Cr;
727
+ Cr = l, e(r, t, bn, ...i.map((c) => {
728
+ switch (c != null && c.constructor === Uint8Array && (c = Array.from(c)), typeof c) {
729
+ case "string":
730
+ case "symbol":
731
+ return c;
732
+ default:
733
+ return wl(c);
734
+ }
735
+ }), r, " +" + o + "ms");
736
+ } : Si;
737
+ }, _l = {
738
+ [vn]: j("font-weight", "bold"),
739
+ [wn]: j("font-weight", "normal"),
740
+ [mn]: j("color", "blue"),
741
+ [yn]: j("color", "green"),
742
+ [ml]: j("color", "grey"),
743
+ [kn]: j("color", "red"),
744
+ [_n]: j("color", "purple"),
745
+ [ee]: j("color", "orange"),
746
+ [bn]: j("color", "black")
747
+ }, bl = (e) => {
748
+ e.length === 1 && e[0]?.constructor === Function && (e = e[0]());
749
+ const t = [], r = [], n = T();
750
+ let s = [], i = 0;
751
+ for (; i < e.length; i++) {
752
+ const l = e[i], o = _l[l];
753
+ if (o !== void 0) n.set(o.left, o.right);
754
+ else {
755
+ if (l === void 0) break;
756
+ if (l.constructor === String || l.constructor === Number) {
757
+ const c = dl(n);
758
+ i > 0 || c.length > 0 ? (t.push("%c" + l), r.push(c)) : t.push(l);
759
+ } else break;
760
+ }
761
+ }
762
+ for (i > 0 && (s = r, s.unshift(t.join(""))); i < e.length; i++) {
763
+ const l = e[i];
764
+ l instanceof Symbol || s.push(l);
765
+ }
766
+ return s;
767
+ }, Sn = Oi ? bl : yl, Cn = (...e) => {
768
+ console.log(...Sn(e)), En.forEach((t) => t.print(e));
769
+ }, Sl = (...e) => {
770
+ console.warn(...Sn(e)), e.unshift(ee), En.forEach((t) => t.print(e));
771
+ }, En = K(), Gc = (e) => kl(Cn, e), Er = (e) => new Promise(e), Hc = Promise.all.bind(Promise), zc = (e) => Promise.reject(e), Kc = (e) => Promise.resolve(e), Dn = (e) => ({
772
+ [Symbol.iterator]() {
773
+ return this;
774
+ },
775
+ next: e
776
+ }), Cl = (e, t) => Dn(() => {
777
+ let r;
778
+ do
779
+ r = e.next();
780
+ while (!r.done && !t(r.value));
781
+ return r;
782
+ }), ge = (e, t) => Dn(() => {
783
+ const { done: r, value: n } = e.next();
784
+ return {
785
+ done: r,
786
+ value: r ? void 0 : t(n)
787
+ };
788
+ }), re = class {
789
+ constructor(e, t) {
790
+ this.clock = e, this.len = t;
791
+ }
792
+ }, Et = class {
793
+ constructor() {
794
+ this.clients = /* @__PURE__ */ new Map();
795
+ }
796
+ }, An = (e, t, r) => t.clients.forEach((n, s) => {
797
+ const i = e.doc.store.clients.get(s);
798
+ if (i != null) {
799
+ const l = i[i.length - 1], o = l.id.clock + l.length;
800
+ for (let c = 0, h = n[c]; c < n.length && h.clock < o; h = n[++c]) Yn(e, i, h.clock, h.len, r);
801
+ }
802
+ }), El = (e, t) => {
803
+ let r = 0, n = e.length - 1;
804
+ for (; r <= n; ) {
805
+ const s = B((r + n) / 2), i = e[s], l = i.clock;
806
+ if (l <= t) {
807
+ if (t < l + i.len) return s;
808
+ r = s + 1;
809
+ } else n = s - 1;
810
+ }
811
+ return null;
812
+ }, In = (e, t) => {
813
+ const r = e.clients.get(t.client);
814
+ return r !== void 0 && El(r, t.clock) !== null;
815
+ }, Ze = (e) => {
816
+ e.clients.forEach((t) => {
817
+ t.sort((s, i) => s.clock - i.clock);
818
+ let r, n;
819
+ for (r = 1, n = 1; r < t.length; r++) {
820
+ const s = t[n - 1], i = t[r];
821
+ s.clock + s.len >= i.clock ? t[n - 1] = new re(s.clock, Z(s.len, i.clock + i.len - s.clock)) : (n < r && (t[n] = i), n++);
822
+ }
823
+ t.length = n;
824
+ });
825
+ }, Dl = (e) => {
826
+ const t = new Et();
827
+ for (let r = 0; r < e.length; r++) e[r].clients.forEach((n, s) => {
828
+ if (!t.clients.has(s)) {
829
+ const i = n.slice();
830
+ for (let l = r + 1; l < e.length; l++) ks(i, e[l].clients.get(s) || []);
831
+ t.clients.set(s, i);
832
+ }
833
+ });
834
+ return Ze(t), t;
835
+ }, jt = (e, t, r, n) => {
836
+ J(e.clients, t, () => []).push(new re(r, n));
837
+ }, Tn = () => new Et(), Al = (e) => {
838
+ const t = Tn();
839
+ return e.clients.forEach((r, n) => {
840
+ const s = [];
841
+ for (let i = 0; i < r.length; i++) {
842
+ const l = r[i];
843
+ if (l.deleted) {
844
+ const o = l.id.clock;
845
+ let c = l.length;
846
+ if (i + 1 < r.length) for (let h = r[i + 1]; i + 1 < r.length && h.deleted; h = r[++i + 1]) c += h.length;
847
+ s.push(new re(o, c));
848
+ }
849
+ }
850
+ s.length > 0 && t.clients.set(n, s);
851
+ }), t;
852
+ }, dt = (e, t) => {
853
+ v(e.restEncoder, t.clients.size), Y(t.clients.entries()).sort((r, n) => n[0] - r[0]).forEach(([r, n]) => {
854
+ e.resetDsCurVal(), v(e.restEncoder, r);
855
+ const s = n.length;
856
+ v(e.restEncoder, s);
857
+ for (let i = 0; i < s; i++) {
858
+ const l = n[i];
859
+ e.writeDsClock(l.clock), e.writeDsLen(l.len);
860
+ }
861
+ });
862
+ }, Qe = (e) => {
863
+ const t = new Et(), r = p(e.restDecoder);
864
+ for (let n = 0; n < r; n++) {
865
+ e.resetDsCurVal();
866
+ const s = p(e.restDecoder), i = p(e.restDecoder);
867
+ if (i > 0) {
868
+ const l = J(t.clients, s, () => []);
869
+ for (let o = 0; o < i; o++) l.push(new re(e.readDsClock(), e.readDsLen()));
870
+ }
871
+ }
872
+ return t;
873
+ }, Dr = (e, t, r) => {
874
+ const n = new Et(), s = p(e.restDecoder);
875
+ for (let i = 0; i < s; i++) {
876
+ e.resetDsCurVal();
877
+ const l = p(e.restDecoder), o = p(e.restDecoder), c = r.clients.get(l) || [], h = b(r, l);
878
+ for (let a = 0; a < o; a++) {
879
+ const d = e.readDsClock(), u = d + e.readDsLen();
880
+ if (d < h) {
881
+ h < u && jt(n, l, h, u - h);
882
+ let f = F(c, d), g = c[f];
883
+ for (!g.deleted && g.id.clock < d && (c.splice(f + 1, 0, Ht(t, g, d - g.id.clock)), f++); f < c.length && (g = c[f++], g.id.clock < u); )
884
+ g.deleted || (u < g.id.clock + g.length && c.splice(f, 0, Ht(t, g, u - g.id.clock)), g.delete(t));
885
+ } else jt(n, l, d, u - d);
886
+ }
887
+ }
888
+ if (n.clients.size > 0) {
889
+ const i = new W();
890
+ return v(i.restEncoder, 0), dt(i, n), i.toUint8Array();
891
+ }
892
+ return null;
893
+ }, On = jr, Pe = class xn extends bs {
894
+ constructor({ guid: t = Vs(), collectionid: r = null, gc: n = !0, gcFilter: s = () => !0, meta: i = null, autoLoad: l = !1, shouldLoad: o = !0 } = {}) {
895
+ super(), this.gc = n, this.gcFilter = s, this.clientID = On(), this.guid = t, this.collectionid = r, this.share = /* @__PURE__ */ new Map(), this.store = new Fn(), this._transaction = null, this._transactionCleanups = [], this.subdocs = /* @__PURE__ */ new Set(), this._item = null, this.shouldLoad = o, this.autoLoad = l, this.meta = i, this.isLoaded = !1, this.isSynced = !1, this.isDestroyed = !1, this.whenLoaded = Er((h) => {
896
+ this.on("load", () => {
897
+ this.isLoaded = !0, h(this);
898
+ });
899
+ });
900
+ const c = () => Er((h) => {
901
+ const a = (d) => {
902
+ (d === void 0 || d === !0) && (this.off("sync", a), h());
903
+ };
904
+ this.on("sync", a);
905
+ });
906
+ this.on("sync", (h) => {
907
+ h === !1 && this.isSynced && (this.whenSynced = c()), this.isSynced = h === void 0 || h === !0, this.isSynced && !this.isLoaded && this.emit("load", [this]);
908
+ }), this.whenSynced = c();
909
+ }
910
+ load() {
911
+ const t = this._item;
912
+ t !== null && !this.shouldLoad && m(t.parent.doc, (r) => {
913
+ r.subdocsLoaded.add(this);
914
+ }, null, !0), this.shouldLoad = !0;
915
+ }
916
+ getSubdocs() {
917
+ return this.subdocs;
918
+ }
919
+ getSubdocGuids() {
920
+ return new Set(Y(this.subdocs).map((t) => t.guid));
921
+ }
922
+ transact(t, r = null) {
923
+ return m(this, t, r);
924
+ }
925
+ get(t, r = C) {
926
+ const n = J(this.share, t, () => {
927
+ const i = new r();
928
+ return i._integrate(this, null), i;
929
+ }), s = n.constructor;
930
+ if (r !== C && s !== r) if (s === C) {
931
+ const i = new r();
932
+ i._map = n._map, n._map.forEach((l) => {
933
+ for (; l !== null; l = l.left) l.parent = i;
934
+ }), i._start = n._start;
935
+ for (let l = i._start; l !== null; l = l.right) l.parent = i;
936
+ return i._length = n._length, this.share.set(t, i), i._integrate(this, null), i;
937
+ } else throw new Error(`Type with the name ${t} has already been defined with a different constructor`);
938
+ return n;
939
+ }
940
+ getArray(t = "") {
941
+ return this.get(t, rs);
942
+ }
943
+ getText(t = "") {
944
+ return this.get(t, cr);
945
+ }
946
+ getMap(t = "") {
947
+ return this.get(t, or);
948
+ }
949
+ getXmlElement(t = "") {
950
+ return this.get(t, ar);
951
+ }
952
+ getXmlFragment(t = "") {
953
+ return this.get(t, oe);
954
+ }
955
+ toJSON() {
956
+ const t = {};
957
+ return this.share.forEach((r, n) => {
958
+ t[n] = r.toJSON();
959
+ }), t;
960
+ }
961
+ destroy() {
962
+ this.isDestroyed = !0, Y(this.subdocs).forEach((r) => r.destroy());
963
+ const t = this._item;
964
+ if (t !== null) {
965
+ this._item = null;
966
+ const r = t.content;
967
+ r.doc = new xn({
968
+ guid: this.guid,
969
+ ...r.opts,
970
+ shouldLoad: !1
971
+ }), r.doc._item = t, m(t.parent.doc, (n) => {
972
+ const s = r.doc;
973
+ t.deleted || n.subdocsAdded.add(s), n.subdocsRemoved.add(this);
974
+ }, null, !0);
975
+ }
976
+ this.emit("destroyed", [!0]), this.emit("destroy", [this]), super.destroy();
977
+ }
978
+ }, Ln = class {
979
+ constructor(e) {
980
+ this.restDecoder = e;
981
+ }
982
+ resetDsCurVal() {
983
+ }
984
+ readDsClock() {
985
+ return p(this.restDecoder);
986
+ }
987
+ readDsLen() {
988
+ return p(this.restDecoder);
989
+ }
990
+ }, $n = class extends Ln {
991
+ readLeftID() {
992
+ return w(p(this.restDecoder), p(this.restDecoder));
993
+ }
994
+ readRightID() {
995
+ return w(p(this.restDecoder), p(this.restDecoder));
996
+ }
997
+ readClient() {
998
+ return p(this.restDecoder);
999
+ }
1000
+ readInfo() {
1001
+ return lt(this.restDecoder);
1002
+ }
1003
+ readString() {
1004
+ return nt(this.restDecoder);
1005
+ }
1006
+ readParentInfo() {
1007
+ return p(this.restDecoder) === 1;
1008
+ }
1009
+ readTypeRef() {
1010
+ return p(this.restDecoder);
1011
+ }
1012
+ readLen() {
1013
+ return p(this.restDecoder);
1014
+ }
1015
+ readAny() {
1016
+ return wt(this.restDecoder);
1017
+ }
1018
+ readBuf() {
1019
+ return Ri(x(this.restDecoder));
1020
+ }
1021
+ readJSON() {
1022
+ return JSON.parse(nt(this.restDecoder));
1023
+ }
1024
+ readKey() {
1025
+ return nt(this.restDecoder);
1026
+ }
1027
+ }, Il = class {
1028
+ constructor(e) {
1029
+ this.dsCurrVal = 0, this.restDecoder = e;
1030
+ }
1031
+ resetDsCurVal() {
1032
+ this.dsCurrVal = 0;
1033
+ }
1034
+ readDsClock() {
1035
+ return this.dsCurrVal += p(this.restDecoder), this.dsCurrVal;
1036
+ }
1037
+ readDsLen() {
1038
+ const e = p(this.restDecoder) + 1;
1039
+ return this.dsCurrVal += e, e;
1040
+ }
1041
+ }, at = class extends Il {
1042
+ constructor(e) {
1043
+ super(e), this.keys = [], p(e), this.keyClockDecoder = new he(x(e)), this.clientDecoder = new $t(x(e)), this.leftClockDecoder = new he(x(e)), this.rightClockDecoder = new he(x(e)), this.infoDecoder = new yr(x(e), lt), this.stringDecoder = new fi(x(e)), this.parentInfoDecoder = new yr(x(e), lt), this.typeRefDecoder = new $t(x(e)), this.lenDecoder = new $t(x(e));
1044
+ }
1045
+ readLeftID() {
1046
+ return new it(this.clientDecoder.read(), this.leftClockDecoder.read());
1047
+ }
1048
+ readRightID() {
1049
+ return new it(this.clientDecoder.read(), this.rightClockDecoder.read());
1050
+ }
1051
+ readClient() {
1052
+ return this.clientDecoder.read();
1053
+ }
1054
+ readInfo() {
1055
+ return this.infoDecoder.read();
1056
+ }
1057
+ readString() {
1058
+ return this.stringDecoder.read();
1059
+ }
1060
+ readParentInfo() {
1061
+ return this.parentInfoDecoder.read() === 1;
1062
+ }
1063
+ readTypeRef() {
1064
+ return this.typeRefDecoder.read();
1065
+ }
1066
+ readLen() {
1067
+ return this.lenDecoder.read();
1068
+ }
1069
+ readAny() {
1070
+ return wt(this.restDecoder);
1071
+ }
1072
+ readBuf() {
1073
+ return x(this.restDecoder);
1074
+ }
1075
+ readJSON() {
1076
+ return wt(this.restDecoder);
1077
+ }
1078
+ readKey() {
1079
+ const e = this.keyClockDecoder.read();
1080
+ if (e < this.keys.length) return this.keys[e];
1081
+ {
1082
+ const t = this.stringDecoder.read();
1083
+ return this.keys.push(t), t;
1084
+ }
1085
+ }
1086
+ }, Nn = class {
1087
+ constructor() {
1088
+ this.restEncoder = Kt();
1089
+ }
1090
+ toUint8Array() {
1091
+ return R(this.restEncoder);
1092
+ }
1093
+ resetDsCurVal() {
1094
+ }
1095
+ writeDsClock(e) {
1096
+ v(this.restEncoder, e);
1097
+ }
1098
+ writeDsLen(e) {
1099
+ v(this.restEncoder, e);
1100
+ }
1101
+ }, Dt = class extends Nn {
1102
+ writeLeftID(e) {
1103
+ v(this.restEncoder, e.client), v(this.restEncoder, e.clock);
1104
+ }
1105
+ writeRightID(e) {
1106
+ v(this.restEncoder, e.client), v(this.restEncoder, e.clock);
1107
+ }
1108
+ writeClient(e) {
1109
+ v(this.restEncoder, e);
1110
+ }
1111
+ writeInfo(e) {
1112
+ ye(this.restEncoder, e);
1113
+ }
1114
+ writeString(e) {
1115
+ rt(this.restEncoder, e);
1116
+ }
1117
+ writeParentInfo(e) {
1118
+ v(this.restEncoder, e ? 1 : 0);
1119
+ }
1120
+ writeTypeRef(e) {
1121
+ v(this.restEncoder, e);
1122
+ }
1123
+ writeLen(e) {
1124
+ v(this.restEncoder, e);
1125
+ }
1126
+ writeAny(e) {
1127
+ vt(this.restEncoder, e);
1128
+ }
1129
+ writeBuf(e) {
1130
+ O(this.restEncoder, e);
1131
+ }
1132
+ writeJSON(e) {
1133
+ rt(this.restEncoder, JSON.stringify(e));
1134
+ }
1135
+ writeKey(e) {
1136
+ rt(this.restEncoder, e);
1137
+ }
1138
+ }, Mn = class {
1139
+ constructor() {
1140
+ this.restEncoder = Kt(), this.dsCurrVal = 0;
1141
+ }
1142
+ toUint8Array() {
1143
+ return R(this.restEncoder);
1144
+ }
1145
+ resetDsCurVal() {
1146
+ this.dsCurrVal = 0;
1147
+ }
1148
+ writeDsClock(e) {
1149
+ const t = e - this.dsCurrVal;
1150
+ this.dsCurrVal = e, v(this.restEncoder, t);
1151
+ }
1152
+ writeDsLen(e) {
1153
+ e === 0 && N(), v(this.restEncoder, e - 1), this.dsCurrVal += e;
1154
+ }
1155
+ }, W = class extends Mn {
1156
+ constructor() {
1157
+ super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new ae(), this.clientEncoder = new Lt(), this.leftClockEncoder = new ae(), this.rightClockEncoder = new ae(), this.infoEncoder = new vr(ye), this.stringEncoder = new si(), this.parentInfoEncoder = new vr(ye), this.typeRefEncoder = new Lt(), this.lenEncoder = new Lt();
1158
+ }
1159
+ toUint8Array() {
1160
+ const e = Kt();
1161
+ return v(e, 0), O(e, this.keyClockEncoder.toUint8Array()), O(e, this.clientEncoder.toUint8Array()), O(e, this.leftClockEncoder.toUint8Array()), O(e, this.rightClockEncoder.toUint8Array()), O(e, R(this.infoEncoder)), O(e, this.stringEncoder.toUint8Array()), O(e, R(this.parentInfoEncoder)), O(e, this.typeRefEncoder.toUint8Array()), O(e, this.lenEncoder.toUint8Array()), Wt(e, R(this.restEncoder)), R(e);
1162
+ }
1163
+ writeLeftID(e) {
1164
+ this.clientEncoder.write(e.client), this.leftClockEncoder.write(e.clock);
1165
+ }
1166
+ writeRightID(e) {
1167
+ this.clientEncoder.write(e.client), this.rightClockEncoder.write(e.clock);
1168
+ }
1169
+ writeClient(e) {
1170
+ this.clientEncoder.write(e);
1171
+ }
1172
+ writeInfo(e) {
1173
+ this.infoEncoder.write(e);
1174
+ }
1175
+ writeString(e) {
1176
+ this.stringEncoder.write(e);
1177
+ }
1178
+ writeParentInfo(e) {
1179
+ this.parentInfoEncoder.write(e ? 1 : 0);
1180
+ }
1181
+ writeTypeRef(e) {
1182
+ this.typeRefEncoder.write(e);
1183
+ }
1184
+ writeLen(e) {
1185
+ this.lenEncoder.write(e);
1186
+ }
1187
+ writeAny(e) {
1188
+ vt(this.restEncoder, e);
1189
+ }
1190
+ writeBuf(e) {
1191
+ O(this.restEncoder, e);
1192
+ }
1193
+ writeJSON(e) {
1194
+ vt(this.restEncoder, e);
1195
+ }
1196
+ writeKey(e) {
1197
+ const t = this.keyMap.get(e);
1198
+ t === void 0 ? (this.keyClockEncoder.write(this.keyClock++), this.stringEncoder.write(e)) : this.keyClockEncoder.write(t);
1199
+ }
1200
+ }, Tl = (e, t, r, n) => {
1201
+ n = Z(n, t[0].id.clock);
1202
+ const s = F(t, n);
1203
+ v(e.restEncoder, t.length - s), e.writeClient(r), v(e.restEncoder, n);
1204
+ const i = t[s];
1205
+ i.write(e, n - i.id.clock);
1206
+ for (let l = s + 1; l < t.length; l++) t[l].write(e, 0);
1207
+ }, tr = (e, t, r) => {
1208
+ const n = /* @__PURE__ */ new Map();
1209
+ r.forEach((s, i) => {
1210
+ b(t, i) > s && n.set(i, s);
1211
+ }), ne(t).forEach((s, i) => {
1212
+ r.has(i) || n.set(i, 0);
1213
+ }), v(e.restEncoder, n.size), Y(n.entries()).sort((s, i) => i[0] - s[0]).forEach(([s, i]) => {
1214
+ Tl(e, t.clients.get(s), s, i);
1215
+ });
1216
+ }, Ol = (e, t) => {
1217
+ const r = T(), n = p(e.restDecoder);
1218
+ for (let s = 0; s < n; s++) {
1219
+ const i = p(e.restDecoder), l = new Array(i), o = e.readClient();
1220
+ let c = p(e.restDecoder);
1221
+ r.set(o, {
1222
+ i: 0,
1223
+ refs: l
1224
+ });
1225
+ for (let h = 0; h < i; h++) {
1226
+ const a = e.readInfo();
1227
+ switch (31 & a) {
1228
+ case 0: {
1229
+ const d = e.readLen();
1230
+ l[h] = new L(w(o, c), d), c += d;
1231
+ break;
1232
+ }
1233
+ case 10: {
1234
+ const d = p(e.restDecoder);
1235
+ l[h] = new $(w(o, c), d), c += d;
1236
+ break;
1237
+ }
1238
+ default: {
1239
+ const d = (a & 192) === 0, u = new D(w(o, c), null, (a & 128) === 128 ? e.readLeftID() : null, null, (a & 64) === 64 ? e.readRightID() : null, d ? e.readParentInfo() ? t.get(e.readString()) : e.readLeftID() : null, d && (a & 32) === 32 ? e.readString() : null, gs(e, a));
1240
+ l[h] = u, c += u.length;
1241
+ }
1242
+ }
1243
+ }
1244
+ }
1245
+ return r;
1246
+ }, xl = (e, t, r) => {
1247
+ const n = [];
1248
+ let s = Y(r.keys()).sort((f, g) => f - g);
1249
+ if (s.length === 0) return null;
1250
+ const i = () => {
1251
+ if (s.length === 0) return null;
1252
+ let f = r.get(s[s.length - 1]);
1253
+ for (; f.refs.length === f.i; )
1254
+ if (s.pop(), s.length > 0) f = r.get(s[s.length - 1]);
1255
+ else return null;
1256
+ return f;
1257
+ };
1258
+ let l = i();
1259
+ if (l === null) return null;
1260
+ const o = new Fn(), c = /* @__PURE__ */ new Map(), h = (f, g) => {
1261
+ const y = c.get(f);
1262
+ (y == null || y > g) && c.set(f, g);
1263
+ };
1264
+ let a = l.refs[l.i++];
1265
+ const d = /* @__PURE__ */ new Map(), u = () => {
1266
+ for (const f of n) {
1267
+ const g = f.id.client, y = r.get(g);
1268
+ y ? (y.i--, o.clients.set(g, y.refs.slice(y.i)), r.delete(g), y.i = 0, y.refs = []) : o.clients.set(g, [f]), s = s.filter((ws) => ws !== g);
1269
+ }
1270
+ n.length = 0;
1271
+ };
1272
+ for (; ; ) {
1273
+ if (a.constructor !== $) {
1274
+ const f = J(d, a.id.client, () => b(t, a.id.client)) - a.id.clock;
1275
+ if (f < 0)
1276
+ n.push(a), h(a.id.client, a.id.clock - 1), u();
1277
+ else {
1278
+ const g = a.getMissing(e, t);
1279
+ if (g !== null) {
1280
+ n.push(a);
1281
+ const y = r.get(g) || {
1282
+ refs: [],
1283
+ i: 0
1284
+ };
1285
+ if (y.refs.length === y.i)
1286
+ h(g, b(t, g)), u();
1287
+ else {
1288
+ a = y.refs[y.i++];
1289
+ continue;
1290
+ }
1291
+ } else (f === 0 || f < a.length) && (a.integrate(e, f), d.set(a.id.client, a.id.clock + a.length));
1292
+ }
1293
+ }
1294
+ if (n.length > 0) a = n.pop();
1295
+ else if (l !== null && l.i < l.refs.length) a = l.refs[l.i++];
1296
+ else {
1297
+ if (l = i(), l === null) break;
1298
+ a = l.refs[l.i++];
1299
+ }
1300
+ }
1301
+ if (o.clients.size > 0) {
1302
+ const f = new W();
1303
+ return tr(f, o, /* @__PURE__ */ new Map()), v(f.restEncoder, 0), {
1304
+ missing: c,
1305
+ update: f.toUint8Array()
1306
+ };
1307
+ }
1308
+ return null;
1309
+ }, Ll = (e, t) => tr(e, t.doc.store, t.beforeState), $l = (e, t, r, n = new at(e)) => m(t, (s) => {
1310
+ s.local = !1;
1311
+ let i = !1;
1312
+ const l = s.doc, o = l.store, c = Ol(n, l), h = xl(s, o, c), a = o.pendingStructs;
1313
+ if (a) {
1314
+ for (const [u, f] of a.missing) if (f < b(o, u)) {
1315
+ i = !0;
1316
+ break;
1317
+ }
1318
+ if (h) {
1319
+ for (const [u, f] of h.missing) {
1320
+ const g = a.missing.get(u);
1321
+ (g == null || g > f) && a.missing.set(u, f);
1322
+ }
1323
+ a.update = Yt([a.update, h.update]);
1324
+ }
1325
+ } else o.pendingStructs = h;
1326
+ const d = Dr(n, s, o);
1327
+ if (o.pendingDs) {
1328
+ const u = new at(ht(o.pendingDs));
1329
+ p(u.restDecoder);
1330
+ const f = Dr(u, s, o);
1331
+ d && f ? o.pendingDs = Yt([d, f]) : o.pendingDs = d || f;
1332
+ } else o.pendingDs = d;
1333
+ if (i) {
1334
+ const u = o.pendingStructs.update;
1335
+ o.pendingStructs = null, Un(s.doc, u);
1336
+ }
1337
+ }, r, !1), Un = (e, t, r, n = at) => {
1338
+ const s = ht(t);
1339
+ $l(s, e, r, new n(s));
1340
+ }, Wc = (e, t, r) => Un(e, t, r, $n), Nl = (e, t, r = /* @__PURE__ */ new Map()) => {
1341
+ tr(e, t.store, r), dt(e, Al(t.store));
1342
+ }, Ml = (e, t = new Uint8Array([0]), r = new W()) => {
1343
+ const n = Rn(t);
1344
+ Nl(r, e, n);
1345
+ const s = [r.toUint8Array()];
1346
+ if (e.store.pendingDs && s.push(e.store.pendingDs), e.store.pendingStructs && s.push(Zl(e.store.pendingStructs.update, t)), s.length > 1) {
1347
+ if (r.constructor === Dt) return Wl(s.map((i, l) => l === 0 ? i : Pl(i)));
1348
+ if (r.constructor === W) return Yt(s);
1349
+ }
1350
+ return s[0];
1351
+ }, qc = (e, t) => Ml(e, t, new Dt()), Ul = (e) => {
1352
+ const t = /* @__PURE__ */ new Map(), r = p(e.restDecoder);
1353
+ for (let n = 0; n < r; n++) {
1354
+ const s = p(e.restDecoder), i = p(e.restDecoder);
1355
+ t.set(s, i);
1356
+ }
1357
+ return t;
1358
+ }, Rn = (e) => Ul(new Ln(ht(e))), Bn = (e, t) => (v(e.restEncoder, t.size), Y(t.entries()).sort((r, n) => n[0] - r[0]).forEach(([r, n]) => {
1359
+ v(e.restEncoder, r), v(e.restEncoder, n);
1360
+ }), e), Rl = (e, t) => Bn(e, ne(t.store)), Bl = (e, t = new Mn()) => (e instanceof Map ? Bn(t, e) : Rl(t, e), t.toUint8Array()), Zc = (e) => Bl(e, new Nn()), Vl = class {
1361
+ constructor() {
1362
+ this.l = [];
1363
+ }
1364
+ }, Ar = () => new Vl(), Ir = (e, t) => e.l.push(t), Tr = (e, t) => {
1365
+ const r = e.l, n = r.length;
1366
+ e.l = r.filter((s) => t !== s), n === e.l.length && console.error("[yjs] Tried to remove event handler that doesn't exist.");
1367
+ }, Vn = (e, t, r) => Ge(e.l, [t, r]), it = class {
1368
+ constructor(e, t) {
1369
+ this.client = e, this.clock = t;
1370
+ }
1371
+ }, It = (e, t) => e === t || e !== null && t !== null && e.client === t.client && e.clock === t.clock, w = (e, t) => new it(e, t), Fl = (e) => {
1372
+ for (const [t, r] of e.doc.share.entries()) if (r === e) return t;
1373
+ throw N();
1374
+ }, jl = class {
1375
+ constructor(e, t) {
1376
+ this.ds = e, this.sv = t;
1377
+ }
1378
+ }, Yl = (e, t) => new jl(e, t), Qc = Yl(Tn(), /* @__PURE__ */ new Map()), et = (e, t) => t === void 0 ? !e.deleted : t.sv.has(e.id.client) && (t.sv.get(e.id.client) || 0) > e.id.clock && !In(t.ds, e.id), Se = (e, t) => {
1379
+ const r = J(e.meta, Se, K), n = e.doc.store;
1380
+ r.has(t) || (t.sv.forEach((s, i) => {
1381
+ s < b(n, i) && z(e, w(i, s));
1382
+ }), An(e, t.ds, (s) => {
1383
+ }), r.add(t));
1384
+ }, Fn = class {
1385
+ constructor() {
1386
+ this.clients = /* @__PURE__ */ new Map(), this.pendingStructs = null, this.pendingDs = null;
1387
+ }
1388
+ }, ne = (e) => {
1389
+ const t = /* @__PURE__ */ new Map();
1390
+ return e.clients.forEach((r, n) => {
1391
+ const s = r[r.length - 1];
1392
+ t.set(n, s.id.clock + s.length);
1393
+ }), t;
1394
+ }, b = (e, t) => {
1395
+ const r = e.clients.get(t);
1396
+ if (r === void 0) return 0;
1397
+ const n = r[r.length - 1];
1398
+ return n.id.clock + n.length;
1399
+ }, jn = (e, t) => {
1400
+ let r = e.clients.get(t.id.client);
1401
+ if (r === void 0)
1402
+ r = [], e.clients.set(t.id.client, r);
1403
+ else {
1404
+ const n = r[r.length - 1];
1405
+ if (n.id.clock + n.length !== t.id.clock) throw N();
1406
+ }
1407
+ r.push(t);
1408
+ }, F = (e, t) => {
1409
+ let r = 0, n = e.length - 1, s = e[n], i = s.id.clock;
1410
+ if (i === t) return n;
1411
+ let l = B(t / (i + s.length - 1) * n);
1412
+ for (; r <= n; ) {
1413
+ if (s = e[l], i = s.id.clock, i <= t) {
1414
+ if (t < i + s.length) return l;
1415
+ r = l + 1;
1416
+ } else n = l - 1;
1417
+ l = B((r + n) / 2);
1418
+ }
1419
+ throw N();
1420
+ }, Jl = (e, t) => {
1421
+ const r = e.clients.get(t.client);
1422
+ return r[F(r, t.clock)];
1423
+ }, pe = Jl, Ce = (e, t, r) => {
1424
+ const n = F(t, r), s = t[n];
1425
+ return s.id.clock < r && s instanceof D ? (t.splice(n + 1, 0, Ht(e, s, r - s.id.clock)), n + 1) : n;
1426
+ }, z = (e, t) => {
1427
+ const r = e.doc.store.clients.get(t.client);
1428
+ return r[Ce(e, r, t.clock)];
1429
+ }, Or = (e, t, r) => {
1430
+ const n = t.clients.get(r.client), s = F(n, r.clock), i = n[s];
1431
+ return r.clock !== i.id.clock + i.length - 1 && i.constructor !== L && n.splice(s + 1, 0, Ht(e, i, r.clock - i.id.clock + 1)), i;
1432
+ }, Xl = (e, t, r) => {
1433
+ const n = e.clients.get(t.id.client);
1434
+ n[F(n, t.id.clock)] = r;
1435
+ }, Yn = (e, t, r, n, s) => {
1436
+ if (n === 0) return;
1437
+ const i = r + n;
1438
+ let l = Ce(e, t, r), o;
1439
+ do
1440
+ o = t[l++], i < o.id.clock + o.length && Ce(e, t, i), s(o);
1441
+ while (l < t.length && t[l].id.clock < i);
1442
+ }, Gl = class {
1443
+ constructor(e, t, r) {
1444
+ this.doc = e, this.deleteSet = new Et(), this.beforeState = ne(e.store), this.afterState = /* @__PURE__ */ new Map(), this.changed = /* @__PURE__ */ new Map(), this.changedParentTypes = /* @__PURE__ */ new Map(), this._mergeStructs = [], this.origin = t, this.meta = /* @__PURE__ */ new Map(), this.local = r, this.subdocsAdded = /* @__PURE__ */ new Set(), this.subdocsRemoved = /* @__PURE__ */ new Set(), this.subdocsLoaded = /* @__PURE__ */ new Set(), this._needFormattingCleanup = !1;
1445
+ }
1446
+ }, xr = (e, t) => t.deleteSet.clients.size === 0 && !ys(t.afterState, (r, n) => t.beforeState.get(n) !== r) ? !1 : (Ze(t.deleteSet), Ll(e, t), dt(e, t.deleteSet), !0), Lr = (e, t, r) => {
1447
+ const n = t._item;
1448
+ (n === null || n.id.clock < (e.beforeState.get(n.id.client) || 0) && !n.deleted) && J(e.changed, t, K).add(r);
1449
+ }, Mt = (e, t) => {
1450
+ let r = e[t], n = e[t - 1], s = t;
1451
+ for (; s > 0; r = n, n = e[--s - 1]) {
1452
+ if (n.deleted === r.deleted && n.constructor === r.constructor && n.mergeWith(r)) {
1453
+ r instanceof D && r.parentSub !== null && r.parent._map.get(r.parentSub) === r && r.parent._map.set(r.parentSub, n);
1454
+ continue;
1455
+ }
1456
+ break;
1457
+ }
1458
+ const i = t - s;
1459
+ return i && e.splice(t + 1 - i, i), i;
1460
+ }, Hl = (e, t, r) => {
1461
+ for (const [n, s] of e.clients.entries()) {
1462
+ const i = t.clients.get(n);
1463
+ for (let l = s.length - 1; l >= 0; l--) {
1464
+ const o = s[l], c = o.clock + o.len;
1465
+ for (let h = F(i, o.clock), a = i[h]; h < i.length && a.id.clock < c; a = i[++h]) {
1466
+ const d = i[h];
1467
+ if (o.clock + o.len <= d.id.clock) break;
1468
+ d instanceof D && d.deleted && !d.keep && r(d) && d.gc(t, !1);
1469
+ }
1470
+ }
1471
+ }
1472
+ }, zl = (e, t) => {
1473
+ e.clients.forEach((r, n) => {
1474
+ const s = t.clients.get(n);
1475
+ for (let i = r.length - 1; i >= 0; i--) {
1476
+ const l = r[i], o = Br(s.length - 1, 1 + F(s, l.clock + l.len - 1));
1477
+ for (let c = o, h = s[c]; c > 0 && h.id.clock >= l.clock; h = s[c]) c -= 1 + Mt(s, c);
1478
+ }
1479
+ });
1480
+ }, Jn = (e, t) => {
1481
+ if (t < e.length) {
1482
+ const r = e[t], n = r.doc, s = n.store, i = r.deleteSet, l = r._mergeStructs;
1483
+ try {
1484
+ Ze(i), r.afterState = ne(r.doc.store), n.emit("beforeObserverCalls", [r, n]);
1485
+ const o = [];
1486
+ r.changed.forEach((c, h) => o.push(() => {
1487
+ (h._item === null || !h._item.deleted) && h._callObserver(r, c);
1488
+ })), o.push(() => {
1489
+ r.changedParentTypes.forEach((c, h) => {
1490
+ h._dEH.l.length > 0 && (h._item === null || !h._item.deleted) && (c = c.filter((a) => a.target._item === null || !a.target._item.deleted), c.forEach((a) => {
1491
+ a.currentTarget = h, a._path = null;
1492
+ }), c.sort((a, d) => a.path.length - d.path.length), o.push(() => {
1493
+ Vn(h._dEH, c, r);
1494
+ }));
1495
+ }), o.push(() => n.emit("afterTransaction", [r, n])), o.push(() => {
1496
+ r._needFormattingCleanup && go(r);
1497
+ });
1498
+ }), Ge(o, []);
1499
+ } finally {
1500
+ n.gc && Hl(i, s, n.gcFilter), zl(i, s), r.afterState.forEach((a, d) => {
1501
+ const u = r.beforeState.get(d) || 0;
1502
+ if (u !== a) {
1503
+ const f = s.clients.get(d), g = Z(F(f, u), 1);
1504
+ for (let y = f.length - 1; y >= g; ) y -= 1 + Mt(f, y);
1505
+ }
1506
+ });
1507
+ for (let a = l.length - 1; a >= 0; a--) {
1508
+ const { client: d, clock: u } = l[a].id, f = s.clients.get(d), g = F(f, u);
1509
+ g + 1 < f.length && Mt(f, g + 1) > 1 || g > 0 && Mt(f, g);
1510
+ }
1511
+ if (!r.local && r.afterState.get(n.clientID) !== r.beforeState.get(n.clientID) && (Cn(ee, vn, "[yjs] ", wn, kn, "Changed the client-id because another client seems to be using it."), n.clientID = On()), n.emit("afterTransactionCleanup", [r, n]), n._observers.has("update")) {
1512
+ const a = new Dt();
1513
+ xr(a, r) && n.emit("update", [
1514
+ a.toUint8Array(),
1515
+ r.origin,
1516
+ n,
1517
+ r
1518
+ ]);
1519
+ }
1520
+ if (n._observers.has("updateV2")) {
1521
+ const a = new W();
1522
+ xr(a, r) && n.emit("updateV2", [
1523
+ a.toUint8Array(),
1524
+ r.origin,
1525
+ n,
1526
+ r
1527
+ ]);
1528
+ }
1529
+ const { subdocsAdded: o, subdocsLoaded: c, subdocsRemoved: h } = r;
1530
+ (o.size > 0 || h.size > 0 || c.size > 0) && (o.forEach((a) => {
1531
+ a.clientID = n.clientID, a.collectionid == null && (a.collectionid = n.collectionid), n.subdocs.add(a);
1532
+ }), h.forEach((a) => n.subdocs.delete(a)), n.emit("subdocs", [
1533
+ {
1534
+ loaded: c,
1535
+ added: o,
1536
+ removed: h
1537
+ },
1538
+ n,
1539
+ r
1540
+ ]), h.forEach((a) => a.destroy())), e.length <= t + 1 ? (n._transactionCleanups = [], n.emit("afterAllTransactions", [n, e])) : Jn(e, t + 1);
1541
+ }
1542
+ }
1543
+ }, m = (e, t, r = null, n = !0) => {
1544
+ const s = e._transactionCleanups;
1545
+ let i = !1, l = null;
1546
+ e._transaction === null && (i = !0, e._transaction = new Gl(e, r, n), s.push(e._transaction), s.length === 1 && e.emit("beforeAllTransactions", [e]), e.emit("beforeTransaction", [e._transaction, e]));
1547
+ try {
1548
+ l = t(e._transaction);
1549
+ } finally {
1550
+ if (i) {
1551
+ const o = e._transaction === s[0];
1552
+ e._transaction = null, o && Jn(s, 0);
1553
+ }
1554
+ }
1555
+ return l;
1556
+ };
1557
+ function* Kl(e) {
1558
+ const t = p(e.restDecoder);
1559
+ for (let r = 0; r < t; r++) {
1560
+ const n = p(e.restDecoder), s = e.readClient();
1561
+ let i = p(e.restDecoder);
1562
+ for (let l = 0; l < n; l++) {
1563
+ const o = e.readInfo();
1564
+ if (o === 10) {
1565
+ const c = p(e.restDecoder);
1566
+ yield new $(w(s, i), c), i += c;
1567
+ } else if ((31 & o) !== 0) {
1568
+ const c = (o & 192) === 0, h = new D(w(s, i), null, (o & 128) === 128 ? e.readLeftID() : null, null, (o & 64) === 64 ? e.readRightID() : null, c ? e.readParentInfo() ? e.readString() : e.readLeftID() : null, c && (o & 32) === 32 ? e.readString() : null, gs(e, o));
1569
+ yield h, i += h.length;
1570
+ } else {
1571
+ const c = e.readLen();
1572
+ yield new L(w(s, i), c), i += c;
1573
+ }
1574
+ }
1575
+ }
1576
+ }
1577
+ var er = class {
1578
+ constructor(e, t) {
1579
+ this.gen = Kl(e), this.curr = null, this.done = !1, this.filterSkips = t, this.next();
1580
+ }
1581
+ next() {
1582
+ do
1583
+ this.curr = this.gen.next().value || null;
1584
+ while (this.filterSkips && this.curr !== null && this.curr.constructor === $);
1585
+ return this.curr;
1586
+ }
1587
+ }, rr = class {
1588
+ constructor(e) {
1589
+ this.currClient = 0, this.startClock = 0, this.written = 0, this.encoder = e, this.clientStructs = [];
1590
+ }
1591
+ }, Wl = (e) => Yt(e, $n, Dt), ql = (e, t) => {
1592
+ if (e.constructor === L) {
1593
+ const { client: r, clock: n } = e.id;
1594
+ return new L(w(r, n + t), e.length - t);
1595
+ } else if (e.constructor === $) {
1596
+ const { client: r, clock: n } = e.id;
1597
+ return new $(w(r, n + t), e.length - t);
1598
+ } else {
1599
+ const r = e, { client: n, clock: s } = r.id;
1600
+ return new D(w(n, s + t), null, w(n, s + t - 1), null, r.rightOrigin, r.parent, r.parentSub, r.content.splice(t));
1601
+ }
1602
+ }, Yt = (e, t = at, r = W) => {
1603
+ if (e.length === 1) return e[0];
1604
+ const n = e.map((a) => new t(ht(a)));
1605
+ let s = n.map((a) => new er(a, !0)), i = null;
1606
+ const l = new r(), o = new rr(l);
1607
+ for (; s = s.filter((u) => u.curr !== null), s.sort((u, f) => {
1608
+ if (u.curr.id.client === f.curr.id.client) {
1609
+ const g = u.curr.id.clock - f.curr.id.clock;
1610
+ return g === 0 ? u.curr.constructor === f.curr.constructor ? 0 : u.curr.constructor === $ ? 1 : -1 : g;
1611
+ } else return f.curr.id.client - u.curr.id.client;
1612
+ }), s.length !== 0; ) {
1613
+ const a = s[0], d = a.curr.id.client;
1614
+ if (i !== null) {
1615
+ let u = a.curr, f = !1;
1616
+ for (; u !== null && u.id.clock + u.length <= i.struct.id.clock + i.struct.length && u.id.client >= i.struct.id.client; )
1617
+ u = a.next(), f = !0;
1618
+ if (u === null || u.id.client !== d || f && u.id.clock > i.struct.id.clock + i.struct.length) continue;
1619
+ if (d !== i.struct.id.client)
1620
+ G(o, i.struct, i.offset), i = {
1621
+ struct: u,
1622
+ offset: 0
1623
+ }, a.next();
1624
+ else if (i.struct.id.clock + i.struct.length < u.id.clock) if (i.struct.constructor === $) i.struct.length = u.id.clock + u.length - i.struct.id.clock;
1625
+ else {
1626
+ G(o, i.struct, i.offset);
1627
+ const g = u.id.clock - i.struct.id.clock - i.struct.length;
1628
+ i = {
1629
+ struct: new $(w(d, i.struct.id.clock + i.struct.length), g),
1630
+ offset: 0
1631
+ };
1632
+ }
1633
+ else {
1634
+ const g = i.struct.id.clock + i.struct.length - u.id.clock;
1635
+ g > 0 && (i.struct.constructor === $ ? i.struct.length -= g : u = ql(u, g)), i.struct.mergeWith(u) || (G(o, i.struct, i.offset), i = {
1636
+ struct: u,
1637
+ offset: 0
1638
+ }, a.next());
1639
+ }
1640
+ } else
1641
+ i = {
1642
+ struct: a.curr,
1643
+ offset: 0
1644
+ }, a.next();
1645
+ for (let u = a.curr; u !== null && u.id.client === d && u.id.clock === i.struct.id.clock + i.struct.length && u.constructor !== $; u = a.next())
1646
+ G(o, i.struct, i.offset), i = {
1647
+ struct: u,
1648
+ offset: 0
1649
+ };
1650
+ }
1651
+ i !== null && (G(o, i.struct, i.offset), i = null), nr(o);
1652
+ const c = n.map((a) => Qe(a)), h = Dl(c);
1653
+ return dt(l, h), l.toUint8Array();
1654
+ }, Zl = (e, t, r = at, n = W) => {
1655
+ const s = Rn(t), i = new n(), l = new rr(i), o = new r(ht(e)), c = new er(o, !1);
1656
+ for (; c.curr; ) {
1657
+ const a = c.curr, d = a.id.client, u = s.get(d) || 0;
1658
+ if (c.curr.constructor === $) {
1659
+ c.next();
1660
+ continue;
1661
+ }
1662
+ if (a.id.clock + a.length > u)
1663
+ for (G(l, a, Z(u - a.id.clock, 0)), c.next(); c.curr && c.curr.id.client === d; )
1664
+ G(l, c.curr, 0), c.next();
1665
+ else for (; c.curr && c.curr.id.client === d && c.curr.id.clock + c.curr.length <= u; ) c.next();
1666
+ }
1667
+ nr(l);
1668
+ const h = Qe(o);
1669
+ return dt(i, h), i.toUint8Array();
1670
+ }, Xn = (e) => {
1671
+ e.written > 0 && (e.clientStructs.push({
1672
+ written: e.written,
1673
+ restEncoder: R(e.encoder.restEncoder)
1674
+ }), e.encoder.restEncoder = Kt(), e.written = 0);
1675
+ }, G = (e, t, r) => {
1676
+ e.written > 0 && e.currClient !== t.id.client && Xn(e), e.written === 0 && (e.currClient = t.id.client, e.encoder.writeClient(t.id.client), v(e.encoder.restEncoder, t.id.clock + r)), t.write(e.encoder, r), e.written++;
1677
+ }, nr = (e) => {
1678
+ Xn(e);
1679
+ const t = e.encoder.restEncoder;
1680
+ v(t, e.clientStructs.length);
1681
+ for (let r = 0; r < e.clientStructs.length; r++) {
1682
+ const n = e.clientStructs[r];
1683
+ v(t, n.written), Wt(t, n.restEncoder);
1684
+ }
1685
+ }, Ql = (e, t, r, n) => {
1686
+ const s = new r(ht(e)), i = new er(s, !1), l = new n(), o = new rr(l);
1687
+ for (let h = i.curr; h !== null; h = i.next()) G(o, t(h), 0);
1688
+ nr(o);
1689
+ const c = Qe(s);
1690
+ return dt(l, c), l.toUint8Array();
1691
+ }, Pl = (e) => Ql(e, Ci, at, Dt), $r = "You must not compute changes after the event-handler fired.", se = class {
1692
+ constructor(e, t) {
1693
+ this.target = e, this.currentTarget = e, this.transaction = t, this._changes = null, this._keys = null, this._delta = null, this._path = null;
1694
+ }
1695
+ get path() {
1696
+ return this._path || (this._path = to(this.currentTarget, this.target));
1697
+ }
1698
+ deletes(e) {
1699
+ return In(this.transaction.deleteSet, e.id);
1700
+ }
1701
+ get keys() {
1702
+ if (this._keys === null) {
1703
+ if (this.transaction.doc._transactionCleanups.length === 0) throw V($r);
1704
+ const e = /* @__PURE__ */ new Map(), t = this.target;
1705
+ this.transaction.changed.get(t).forEach((r) => {
1706
+ if (r !== null) {
1707
+ const n = t._map.get(r);
1708
+ let s, i;
1709
+ if (this.adds(n)) {
1710
+ let l = n.left;
1711
+ for (; l !== null && this.adds(l); ) l = l.left;
1712
+ if (this.deletes(n)) if (l !== null && this.deletes(l))
1713
+ s = "delete", i = ce(l.content.getContent());
1714
+ else return;
1715
+ else l !== null && this.deletes(l) ? (s = "update", i = ce(l.content.getContent())) : (s = "add", i = void 0);
1716
+ } else if (this.deletes(n))
1717
+ s = "delete", i = ce(n.content.getContent());
1718
+ else return;
1719
+ e.set(r, {
1720
+ action: s,
1721
+ oldValue: i
1722
+ });
1723
+ }
1724
+ }), this._keys = e;
1725
+ }
1726
+ return this._keys;
1727
+ }
1728
+ get delta() {
1729
+ return this.changes.delta;
1730
+ }
1731
+ adds(e) {
1732
+ return e.id.clock >= (this.transaction.beforeState.get(e.id.client) || 0);
1733
+ }
1734
+ get changes() {
1735
+ let e = this._changes;
1736
+ if (e === null) {
1737
+ if (this.transaction.doc._transactionCleanups.length === 0) throw V($r);
1738
+ const t = this.target, r = K(), n = K(), s = [];
1739
+ if (e = {
1740
+ added: r,
1741
+ deleted: n,
1742
+ delta: s,
1743
+ keys: this.keys
1744
+ }, this.transaction.changed.get(t).has(null)) {
1745
+ let i = null;
1746
+ const l = () => {
1747
+ i && s.push(i);
1748
+ };
1749
+ for (let o = t._start; o !== null; o = o.right) o.deleted ? this.deletes(o) && !this.adds(o) && ((i === null || i.delete === void 0) && (l(), i = { delete: 0 }), i.delete += o.length, n.add(o)) : this.adds(o) ? ((i === null || i.insert === void 0) && (l(), i = { insert: [] }), i.insert = i.insert.concat(o.content.getContent()), r.add(o)) : ((i === null || i.retain === void 0) && (l(), i = { retain: 0 }), i.retain += o.length);
1750
+ i !== null && i.retain === void 0 && l();
1751
+ }
1752
+ this._changes = e;
1753
+ }
1754
+ return e;
1755
+ }
1756
+ }, to = (e, t) => {
1757
+ const r = [];
1758
+ for (; t._item !== null && t !== e; ) {
1759
+ if (t._item.parentSub !== null) r.unshift(t._item.parentSub);
1760
+ else {
1761
+ let n = 0, s = t._item.parent._start;
1762
+ for (; s !== t._item && s !== null; )
1763
+ !s.deleted && s.countable && (n += s.length), s = s.right;
1764
+ r.unshift(n);
1765
+ }
1766
+ t = t._item.parent;
1767
+ }
1768
+ return r;
1769
+ }, A = () => {
1770
+ Sl("Invalid access: Add Yjs type to a document before reading data.");
1771
+ }, Gn = 80, sr = 0, eo = class {
1772
+ constructor(e, t) {
1773
+ e.marker = !0, this.p = e, this.index = t, this.timestamp = sr++;
1774
+ }
1775
+ }, ro = (e) => {
1776
+ e.timestamp = sr++;
1777
+ }, Hn = (e, t, r) => {
1778
+ e.p.marker = !1, e.p = t, t.marker = !0, e.index = r, e.timestamp = sr++;
1779
+ }, no = (e, t, r) => {
1780
+ if (e.length >= Gn) {
1781
+ const n = e.reduce((s, i) => s.timestamp < i.timestamp ? s : i);
1782
+ return Hn(n, t, r), n;
1783
+ } else {
1784
+ const n = new eo(t, r);
1785
+ return e.push(n), n;
1786
+ }
1787
+ }, ie = (e, t) => {
1788
+ if (e._start === null || t === 0 || e._searchMarker === null) return null;
1789
+ const r = e._searchMarker.length === 0 ? null : e._searchMarker.reduce((i, l) => xt(t - i.index) < xt(t - l.index) ? i : l);
1790
+ let n = e._start, s = 0;
1791
+ for (r !== null && (n = r.p, s = r.index, ro(r)); n.right !== null && s < t; ) {
1792
+ if (!n.deleted && n.countable) {
1793
+ if (t < s + n.length) break;
1794
+ s += n.length;
1795
+ }
1796
+ n = n.right;
1797
+ }
1798
+ for (; n.left !== null && s > t; )
1799
+ n = n.left, !n.deleted && n.countable && (s -= n.length);
1800
+ for (; n.left !== null && n.left.id.client === n.id.client && n.left.id.clock + n.left.length === n.id.clock; )
1801
+ n = n.left, !n.deleted && n.countable && (s -= n.length);
1802
+ return r !== null && xt(r.index - s) < n.parent.length / Gn ? (Hn(r, n, s), r) : no(e._searchMarker, n, s);
1803
+ }, _t = (e, t, r) => {
1804
+ for (let n = e.length - 1; n >= 0; n--) {
1805
+ const s = e[n];
1806
+ if (r > 0) {
1807
+ let i = s.p;
1808
+ for (i.marker = !1; i && (i.deleted || !i.countable); )
1809
+ i = i.left, i && !i.deleted && i.countable && (s.index -= i.length);
1810
+ if (i === null || i.marker === !0) {
1811
+ e.splice(n, 1);
1812
+ continue;
1813
+ }
1814
+ s.p = i, i.marker = !0;
1815
+ }
1816
+ (t < s.index || r > 0 && t === s.index) && (s.index = Z(t, s.index + r));
1817
+ }
1818
+ }, le = (e, t, r) => {
1819
+ const n = e, s = t.changedParentTypes;
1820
+ for (; J(s, e, () => []).push(r), e._item !== null; )
1821
+ e = e._item.parent;
1822
+ Vn(n._eH, r, t);
1823
+ }, C = class {
1824
+ constructor() {
1825
+ this._item = null, this._map = /* @__PURE__ */ new Map(), this._start = null, this.doc = null, this._length = 0, this._eH = Ar(), this._dEH = Ar(), this._searchMarker = null;
1826
+ }
1827
+ get parent() {
1828
+ return this._item ? this._item.parent : null;
1829
+ }
1830
+ _integrate(e, t) {
1831
+ this.doc = e, this._item = t;
1832
+ }
1833
+ _copy() {
1834
+ throw M();
1835
+ }
1836
+ clone() {
1837
+ throw M();
1838
+ }
1839
+ _write(e) {
1840
+ }
1841
+ get _first() {
1842
+ let e = this._start;
1843
+ for (; e !== null && e.deleted; ) e = e.right;
1844
+ return e;
1845
+ }
1846
+ _callObserver(e, t) {
1847
+ !e.local && this._searchMarker && (this._searchMarker.length = 0);
1848
+ }
1849
+ observe(e) {
1850
+ Ir(this._eH, e);
1851
+ }
1852
+ observeDeep(e) {
1853
+ Ir(this._dEH, e);
1854
+ }
1855
+ unobserve(e) {
1856
+ Tr(this._eH, e);
1857
+ }
1858
+ unobserveDeep(e) {
1859
+ Tr(this._dEH, e);
1860
+ }
1861
+ toJSON() {
1862
+ }
1863
+ }, zn = (e, t, r) => {
1864
+ e.doc ?? A(), t < 0 && (t = e._length + t), r < 0 && (r = e._length + r);
1865
+ let n = r - t;
1866
+ const s = [];
1867
+ let i = e._start;
1868
+ for (; i !== null && n > 0; ) {
1869
+ if (i.countable && !i.deleted) {
1870
+ const l = i.content.getContent();
1871
+ if (l.length <= t) t -= l.length;
1872
+ else {
1873
+ for (let o = t; o < l.length && n > 0; o++)
1874
+ s.push(l[o]), n--;
1875
+ t = 0;
1876
+ }
1877
+ }
1878
+ i = i.right;
1879
+ }
1880
+ return s;
1881
+ }, Kn = (e) => {
1882
+ e.doc ?? A();
1883
+ const t = [];
1884
+ let r = e._start;
1885
+ for (; r !== null; ) {
1886
+ if (r.countable && !r.deleted) {
1887
+ const n = r.content.getContent();
1888
+ for (let s = 0; s < n.length; s++) t.push(n[s]);
1889
+ }
1890
+ r = r.right;
1891
+ }
1892
+ return t;
1893
+ }, bt = (e, t) => {
1894
+ let r = 0, n = e._start;
1895
+ for (e.doc ?? A(); n !== null; ) {
1896
+ if (n.countable && !n.deleted) {
1897
+ const s = n.content.getContent();
1898
+ for (let i = 0; i < s.length; i++) t(s[i], r++, e);
1899
+ }
1900
+ n = n.right;
1901
+ }
1902
+ }, Wn = (e, t) => {
1903
+ const r = [];
1904
+ return bt(e, (n, s) => {
1905
+ r.push(t(n, s, e));
1906
+ }), r;
1907
+ }, so = (e) => {
1908
+ let t = e._start, r = null, n = 0;
1909
+ return {
1910
+ [Symbol.iterator]() {
1911
+ return this;
1912
+ },
1913
+ next: () => {
1914
+ if (r === null) {
1915
+ for (; t !== null && t.deleted; ) t = t.right;
1916
+ if (t === null) return {
1917
+ done: !0,
1918
+ value: void 0
1919
+ };
1920
+ r = t.content.getContent(), n = 0, t = t.right;
1921
+ }
1922
+ const s = r[n++];
1923
+ return r.length <= n && (r = null), {
1924
+ done: !1,
1925
+ value: s
1926
+ };
1927
+ }
1928
+ };
1929
+ }, qn = (e, t) => {
1930
+ e.doc ?? A();
1931
+ const r = ie(e, t);
1932
+ let n = e._start;
1933
+ for (r !== null && (n = r.p, t -= r.index); n !== null; n = n.right) if (!n.deleted && n.countable) {
1934
+ if (t < n.length) return n.content.getContent()[t];
1935
+ t -= n.length;
1936
+ }
1937
+ }, Jt = (e, t, r, n) => {
1938
+ let s = r;
1939
+ const i = e.doc, l = i.clientID, o = i.store, c = r === null ? t._start : r.right;
1940
+ let h = [];
1941
+ const a = () => {
1942
+ h.length > 0 && (s = new D(w(l, b(o, l)), s, s && s.lastId, c, c && c.id, t, null, new Gt(h)), s.integrate(e, 0), h = []);
1943
+ };
1944
+ n.forEach((d) => {
1945
+ if (d === null) h.push(d);
1946
+ else switch (d.constructor) {
1947
+ case Number:
1948
+ case Object:
1949
+ case Boolean:
1950
+ case Array:
1951
+ case String:
1952
+ h.push(d);
1953
+ break;
1954
+ default:
1955
+ switch (a(), d.constructor) {
1956
+ case Uint8Array:
1957
+ case ArrayBuffer:
1958
+ s = new D(w(l, b(o, l)), s, s && s.lastId, c, c && c.id, t, null, new ur(new Uint8Array(d))), s.integrate(e, 0);
1959
+ break;
1960
+ case Pe:
1961
+ s = new D(w(l, b(o, l)), s, s && s.lastId, c, c && c.id, t, null, new dr(d)), s.integrate(e, 0);
1962
+ break;
1963
+ default:
1964
+ if (d instanceof C)
1965
+ s = new D(w(l, b(o, l)), s, s && s.lastId, c, c && c.id, t, null, new P(d)), s.integrate(e, 0);
1966
+ else throw new Error("Unexpected content type in insert operation");
1967
+ }
1968
+ }
1969
+ }), a();
1970
+ }, Zn = () => V("Length exceeded!"), Qn = (e, t, r, n) => {
1971
+ if (r > t._length) throw Zn();
1972
+ if (r === 0)
1973
+ return t._searchMarker && _t(t._searchMarker, r, n.length), Jt(e, t, null, n);
1974
+ const s = r, i = ie(t, r);
1975
+ let l = t._start;
1976
+ for (i !== null && (l = i.p, r -= i.index, r === 0 && (l = l.prev, r += l && l.countable && !l.deleted ? l.length : 0)); l !== null; l = l.right) if (!l.deleted && l.countable) {
1977
+ if (r <= l.length) {
1978
+ r < l.length && z(e, w(l.id.client, l.id.clock + r));
1979
+ break;
1980
+ }
1981
+ r -= l.length;
1982
+ }
1983
+ return t._searchMarker && _t(t._searchMarker, s, n.length), Jt(e, t, l, n);
1984
+ }, io = (e, t, r) => {
1985
+ let n = (t._searchMarker || []).reduce((s, i) => i.index > s.index ? i : s, {
1986
+ index: 0,
1987
+ p: t._start
1988
+ }).p;
1989
+ if (n) for (; n.right; ) n = n.right;
1990
+ return Jt(e, t, n, r);
1991
+ }, Pn = (e, t, r, n) => {
1992
+ if (n === 0) return;
1993
+ const s = r, i = n, l = ie(t, r);
1994
+ let o = t._start;
1995
+ for (l !== null && (o = l.p, r -= l.index); o !== null && r > 0; o = o.right) !o.deleted && o.countable && (r < o.length && z(e, w(o.id.client, o.id.clock + r)), r -= o.length);
1996
+ for (; n > 0 && o !== null; )
1997
+ o.deleted || (n < o.length && z(e, w(o.id.client, o.id.clock + n)), o.delete(e), n -= o.length), o = o.right;
1998
+ if (n > 0) throw Zn();
1999
+ t._searchMarker && _t(t._searchMarker, s, -i + n);
2000
+ }, Xt = (e, t, r) => {
2001
+ const n = t._map.get(r);
2002
+ n !== void 0 && n.delete(e);
2003
+ }, ir = (e, t, r, n) => {
2004
+ const s = t._map.get(r) || null, i = e.doc, l = i.clientID;
2005
+ let o;
2006
+ if (n == null) o = new Gt([n]);
2007
+ else switch (n.constructor) {
2008
+ case Number:
2009
+ case Object:
2010
+ case Boolean:
2011
+ case Array:
2012
+ case String:
2013
+ case Date:
2014
+ case BigInt:
2015
+ o = new Gt([n]);
2016
+ break;
2017
+ case Uint8Array:
2018
+ o = new ur(n);
2019
+ break;
2020
+ case Pe:
2021
+ o = new dr(n);
2022
+ break;
2023
+ default:
2024
+ if (n instanceof C) o = new P(n);
2025
+ else throw new Error("Unexpected content type");
2026
+ }
2027
+ new D(w(l, b(i.store, l)), s, s && s.lastId, null, null, t, r, o).integrate(e, 0);
2028
+ }, lr = (e, t) => {
2029
+ e.doc ?? A();
2030
+ const r = e._map.get(t);
2031
+ return r !== void 0 && !r.deleted ? r.content.getContent()[r.length - 1] : void 0;
2032
+ }, ts = (e) => {
2033
+ const t = {};
2034
+ return e.doc ?? A(), e._map.forEach((r, n) => {
2035
+ r.deleted || (t[n] = r.content.getContent()[r.length - 1]);
2036
+ }), t;
2037
+ }, es = (e, t) => {
2038
+ e.doc ?? A();
2039
+ const r = e._map.get(t);
2040
+ return r !== void 0 && !r.deleted;
2041
+ }, lo = (e, t) => {
2042
+ const r = {};
2043
+ return e._map.forEach((n, s) => {
2044
+ let i = n;
2045
+ for (; i !== null && (!t.sv.has(i.id.client) || i.id.clock >= (t.sv.get(i.id.client) || 0)); ) i = i.left;
2046
+ i !== null && et(i, t) && (r[s] = i.content.getContent()[i.length - 1]);
2047
+ }), r;
2048
+ }, Tt = (e) => (e.doc ?? A(), Cl(e._map.entries(), (t) => !t[1].deleted)), oo = class extends se {
2049
+ }, rs = class Ut extends C {
2050
+ constructor() {
2051
+ super(), this._prelimContent = [], this._searchMarker = [];
2052
+ }
2053
+ static from(t) {
2054
+ const r = new Ut();
2055
+ return r.push(t), r;
2056
+ }
2057
+ _integrate(t, r) {
2058
+ super._integrate(t, r), this.insert(0, this._prelimContent), this._prelimContent = null;
2059
+ }
2060
+ _copy() {
2061
+ return new Ut();
2062
+ }
2063
+ clone() {
2064
+ const t = new Ut();
2065
+ return t.insert(0, this.toArray().map((r) => r instanceof C ? r.clone() : r)), t;
2066
+ }
2067
+ get length() {
2068
+ return this.doc ?? A(), this._length;
2069
+ }
2070
+ _callObserver(t, r) {
2071
+ super._callObserver(t, r), le(this, t, new oo(this, t));
2072
+ }
2073
+ insert(t, r) {
2074
+ this.doc !== null ? m(this.doc, (n) => {
2075
+ Qn(n, this, t, r);
2076
+ }) : this._prelimContent.splice(t, 0, ...r);
2077
+ }
2078
+ push(t) {
2079
+ this.doc !== null ? m(this.doc, (r) => {
2080
+ io(r, this, t);
2081
+ }) : this._prelimContent.push(...t);
2082
+ }
2083
+ unshift(t) {
2084
+ this.insert(0, t);
2085
+ }
2086
+ delete(t, r = 1) {
2087
+ this.doc !== null ? m(this.doc, (n) => {
2088
+ Pn(n, this, t, r);
2089
+ }) : this._prelimContent.splice(t, r);
2090
+ }
2091
+ get(t) {
2092
+ return qn(this, t);
2093
+ }
2094
+ toArray() {
2095
+ return Kn(this);
2096
+ }
2097
+ slice(t = 0, r = this.length) {
2098
+ return zn(this, t, r);
2099
+ }
2100
+ toJSON() {
2101
+ return this.map((t) => t instanceof C ? t.toJSON() : t);
2102
+ }
2103
+ map(t) {
2104
+ return Wn(this, t);
2105
+ }
2106
+ forEach(t) {
2107
+ bt(this, t);
2108
+ }
2109
+ [Symbol.iterator]() {
2110
+ return so(this);
2111
+ }
2112
+ _write(t) {
2113
+ t.writeTypeRef(Uo);
2114
+ }
2115
+ }, co = (e) => new rs(), ao = class extends se {
2116
+ constructor(e, t, r) {
2117
+ super(e, t), this.keysChanged = r;
2118
+ }
2119
+ }, or = class Ee extends C {
2120
+ constructor(t) {
2121
+ super(), this._prelimContent = null, t === void 0 ? this._prelimContent = /* @__PURE__ */ new Map() : this._prelimContent = new Map(t);
2122
+ }
2123
+ _integrate(t, r) {
2124
+ super._integrate(t, r), this._prelimContent.forEach((n, s) => {
2125
+ this.set(s, n);
2126
+ }), this._prelimContent = null;
2127
+ }
2128
+ _copy() {
2129
+ return new Ee();
2130
+ }
2131
+ clone() {
2132
+ const t = new Ee();
2133
+ return this.forEach((r, n) => {
2134
+ t.set(n, r instanceof C ? r.clone() : r);
2135
+ }), t;
2136
+ }
2137
+ _callObserver(t, r) {
2138
+ le(this, t, new ao(this, t, r));
2139
+ }
2140
+ toJSON() {
2141
+ this.doc ?? A();
2142
+ const t = {};
2143
+ return this._map.forEach((r, n) => {
2144
+ if (!r.deleted) {
2145
+ const s = r.content.getContent()[r.length - 1];
2146
+ t[n] = s instanceof C ? s.toJSON() : s;
2147
+ }
2148
+ }), t;
2149
+ }
2150
+ get size() {
2151
+ return [...Tt(this)].length;
2152
+ }
2153
+ keys() {
2154
+ return ge(Tt(this), (t) => t[0]);
2155
+ }
2156
+ values() {
2157
+ return ge(Tt(this), (t) => t[1].content.getContent()[t[1].length - 1]);
2158
+ }
2159
+ entries() {
2160
+ return ge(Tt(this), (t) => [t[0], t[1].content.getContent()[t[1].length - 1]]);
2161
+ }
2162
+ forEach(t) {
2163
+ this.doc ?? A(), this._map.forEach((r, n) => {
2164
+ r.deleted || t(r.content.getContent()[r.length - 1], n, this);
2165
+ });
2166
+ }
2167
+ [Symbol.iterator]() {
2168
+ return this.entries();
2169
+ }
2170
+ delete(t) {
2171
+ this.doc !== null ? m(this.doc, (r) => {
2172
+ Xt(r, this, t);
2173
+ }) : this._prelimContent.delete(t);
2174
+ }
2175
+ set(t, r) {
2176
+ return this.doc !== null ? m(this.doc, (n) => {
2177
+ ir(n, this, t, r);
2178
+ }) : this._prelimContent.set(t, r), r;
2179
+ }
2180
+ get(t) {
2181
+ return lr(this, t);
2182
+ }
2183
+ has(t) {
2184
+ return es(this, t);
2185
+ }
2186
+ clear() {
2187
+ this.doc !== null ? m(this.doc, (t) => {
2188
+ this.forEach(function(r, n, s) {
2189
+ Xt(t, s, n);
2190
+ });
2191
+ }) : this._prelimContent.clear();
2192
+ }
2193
+ _write(t) {
2194
+ t.writeTypeRef(Ro);
2195
+ }
2196
+ }, ho = (e) => new or(), H = (e, t) => e === t || typeof e == "object" && typeof t == "object" && e && t && _i(e, t), De = class {
2197
+ constructor(e, t, r, n) {
2198
+ this.left = e, this.right = t, this.index = r, this.currentAttributes = n;
2199
+ }
2200
+ forward() {
2201
+ this.right === null && N(), this.right.content.constructor === E ? this.right.deleted || ft(this.currentAttributes, this.right.content) : this.right.deleted || (this.index += this.right.length), this.left = this.right, this.right = this.right.right;
2202
+ }
2203
+ }, Nr = (e, t, r) => {
2204
+ for (; t.right !== null && r > 0; )
2205
+ t.right.content.constructor === E ? t.right.deleted || ft(t.currentAttributes, t.right.content) : t.right.deleted || (r < t.right.length && z(e, w(t.right.id.client, t.right.id.clock + r)), t.index += t.right.length, r -= t.right.length), t.left = t.right, t.right = t.right.right;
2206
+ return t;
2207
+ }, Ot = (e, t, r, n) => {
2208
+ const s = /* @__PURE__ */ new Map(), i = n ? ie(t, r) : null;
2209
+ if (i) {
2210
+ const l = new De(i.p.left, i.p, i.index, s);
2211
+ return Nr(e, l, r - i.index);
2212
+ } else {
2213
+ const l = new De(null, t._start, 0, s);
2214
+ return Nr(e, l, r);
2215
+ }
2216
+ }, ns = (e, t, r, n) => {
2217
+ for (; r.right !== null && (r.right.deleted === !0 || r.right.content.constructor === E && H(n.get(r.right.content.key), r.right.content.value)); )
2218
+ r.right.deleted || n.delete(r.right.content.key), r.forward();
2219
+ const s = e.doc, i = s.clientID;
2220
+ n.forEach((l, o) => {
2221
+ const c = r.left, h = r.right, a = new D(w(i, b(s.store, i)), c, c && c.lastId, h, h && h.id, t, null, new E(o, l));
2222
+ a.integrate(e, 0), r.right = a, r.forward();
2223
+ });
2224
+ }, ft = (e, t) => {
2225
+ const { key: r, value: n } = t;
2226
+ n === null ? e.delete(r) : e.set(r, n);
2227
+ }, ss = (e, t) => {
2228
+ for (; e.right !== null; ) {
2229
+ if (!(e.right.deleted || e.right.content.constructor === E && H(t[e.right.content.key] ?? null, e.right.content.value))) break;
2230
+ e.forward();
2231
+ }
2232
+ }, is = (e, t, r, n) => {
2233
+ const s = e.doc, i = s.clientID, l = /* @__PURE__ */ new Map();
2234
+ for (const o in n) {
2235
+ const c = n[o], h = r.currentAttributes.get(o) ?? null;
2236
+ if (!H(h, c)) {
2237
+ l.set(o, h);
2238
+ const { left: a, right: d } = r;
2239
+ r.right = new D(w(i, b(s.store, i)), a, a && a.lastId, d, d && d.id, t, null, new E(o, c)), r.right.integrate(e, 0), r.forward();
2240
+ }
2241
+ }
2242
+ return l;
2243
+ }, ve = (e, t, r, n, s) => {
2244
+ r.currentAttributes.forEach((u, f) => {
2245
+ s[f] === void 0 && (s[f] = null);
2246
+ });
2247
+ const i = e.doc, l = i.clientID;
2248
+ ss(r, s);
2249
+ const o = is(e, t, r, s), c = n.constructor === String ? new q(n) : n instanceof C ? new P(n) : new At(n);
2250
+ let { left: h, right: a, index: d } = r;
2251
+ t._searchMarker && _t(t._searchMarker, r.index, c.getLength()), a = new D(w(l, b(i.store, l)), h, h && h.lastId, a, a && a.id, t, null, c), a.integrate(e, 0), r.right = a, r.index = d, r.forward(), ns(e, t, r, o);
2252
+ }, Mr = (e, t, r, n, s) => {
2253
+ const i = e.doc, l = i.clientID;
2254
+ ss(r, s);
2255
+ const o = is(e, t, r, s);
2256
+ t: for (; r.right !== null && (n > 0 || o.size > 0 && (r.right.deleted || r.right.content.constructor === E)); ) {
2257
+ if (!r.right.deleted) switch (r.right.content.constructor) {
2258
+ case E: {
2259
+ const { key: c, value: h } = r.right.content, a = s[c];
2260
+ if (a !== void 0) {
2261
+ if (H(a, h)) o.delete(c);
2262
+ else {
2263
+ if (n === 0) break t;
2264
+ o.set(c, h);
2265
+ }
2266
+ r.right.delete(e);
2267
+ } else r.currentAttributes.set(c, h);
2268
+ break;
2269
+ }
2270
+ default:
2271
+ n < r.right.length && z(e, w(r.right.id.client, r.right.id.clock + n)), n -= r.right.length;
2272
+ break;
2273
+ }
2274
+ r.forward();
2275
+ }
2276
+ if (n > 0) {
2277
+ let c = "";
2278
+ for (; n > 0; n--) c += `
2279
+ `;
2280
+ r.right = new D(w(l, b(i.store, l)), r.left, r.left && r.left.lastId, r.right, r.right && r.right.id, t, null, new q(c)), r.right.integrate(e, 0), r.forward();
2281
+ }
2282
+ ns(e, t, r, o);
2283
+ }, ls = (e, t, r, n, s) => {
2284
+ let i = t;
2285
+ const l = T();
2286
+ for (; i && (!i.countable || i.deleted); ) {
2287
+ if (!i.deleted && i.content.constructor === E) {
2288
+ const h = i.content;
2289
+ l.set(h.key, h);
2290
+ }
2291
+ i = i.right;
2292
+ }
2293
+ let o = 0, c = !1;
2294
+ for (; t !== i; ) {
2295
+ if (r === t && (c = !0), !t.deleted) {
2296
+ const h = t.content;
2297
+ if (h.constructor === E) {
2298
+ const { key: a, value: d } = h, u = n.get(a) ?? null;
2299
+ (l.get(a) !== h || u === d) && (t.delete(e), o++, !c && (s.get(a) ?? null) === d && u !== d && (u === null ? s.delete(a) : s.set(a, u))), !c && !t.deleted && ft(s, h);
2300
+ }
2301
+ }
2302
+ t = t.right;
2303
+ }
2304
+ return o;
2305
+ }, uo = (e, t) => {
2306
+ for (; t && t.right && (t.right.deleted || !t.right.countable); ) t = t.right;
2307
+ const r = /* @__PURE__ */ new Set();
2308
+ for (; t && (t.deleted || !t.countable); ) {
2309
+ if (!t.deleted && t.content.constructor === E) {
2310
+ const n = t.content.key;
2311
+ r.has(n) ? t.delete(e) : r.add(n);
2312
+ }
2313
+ t = t.left;
2314
+ }
2315
+ }, fo = (e) => {
2316
+ let t = 0;
2317
+ return m(e.doc, (r) => {
2318
+ let n = e._start, s = e._start, i = T();
2319
+ const l = me(i);
2320
+ for (; s; )
2321
+ s.deleted === !1 && (s.content.constructor === E ? ft(l, s.content) : (t += ls(r, n, s, i, l), i = me(l), n = s)), s = s.right;
2322
+ }), t;
2323
+ }, go = (e) => {
2324
+ const t = /* @__PURE__ */ new Set(), r = e.doc;
2325
+ for (const [n, s] of e.afterState.entries()) {
2326
+ const i = e.beforeState.get(n) || 0;
2327
+ s !== i && Yn(e, r.store.clients.get(n), i, s, (l) => {
2328
+ !l.deleted && l.content.constructor === E && l.constructor !== L && t.add(l.parent);
2329
+ });
2330
+ }
2331
+ m(r, (n) => {
2332
+ An(e, e.deleteSet, (s) => {
2333
+ if (s instanceof L || !s.parent._hasFormatting || t.has(s.parent)) return;
2334
+ const i = s.parent;
2335
+ s.content.constructor === E ? t.add(i) : uo(n, s);
2336
+ });
2337
+ for (const s of t) fo(s);
2338
+ });
2339
+ }, Ur = (e, t, r) => {
2340
+ const n = r, s = me(t.currentAttributes), i = t.right;
2341
+ for (; r > 0 && t.right !== null; ) {
2342
+ if (t.right.deleted === !1) switch (t.right.content.constructor) {
2343
+ case P:
2344
+ case At:
2345
+ case q:
2346
+ r < t.right.length && z(e, w(t.right.id.client, t.right.id.clock + r)), r -= t.right.length, t.right.delete(e);
2347
+ break;
2348
+ }
2349
+ t.forward();
2350
+ }
2351
+ i && ls(e, i, t.right, s, t.currentAttributes);
2352
+ const l = (t.left || t.right).parent;
2353
+ return l._searchMarker && _t(l._searchMarker, t.index, -n + r), t;
2354
+ }, po = class extends se {
2355
+ constructor(e, t, r) {
2356
+ super(e, t), this.childListChanged = !1, this.keysChanged = /* @__PURE__ */ new Set(), r.forEach((n) => {
2357
+ n === null ? this.childListChanged = !0 : this.keysChanged.add(n);
2358
+ });
2359
+ }
2360
+ get changes() {
2361
+ if (this._changes === null) {
2362
+ const e = {
2363
+ keys: this.keys,
2364
+ delta: this.delta,
2365
+ added: /* @__PURE__ */ new Set(),
2366
+ deleted: /* @__PURE__ */ new Set()
2367
+ };
2368
+ this._changes = e;
2369
+ }
2370
+ return this._changes;
2371
+ }
2372
+ get delta() {
2373
+ if (this._delta === null) {
2374
+ const e = this.target.doc, t = [];
2375
+ m(e, (r) => {
2376
+ const n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
2377
+ let i = this.target._start, l = null;
2378
+ const o = {};
2379
+ let c = "", h = 0, a = 0;
2380
+ const d = () => {
2381
+ if (l !== null) {
2382
+ let u = null;
2383
+ switch (l) {
2384
+ case "delete":
2385
+ a > 0 && (u = { delete: a }), a = 0;
2386
+ break;
2387
+ case "insert":
2388
+ (typeof c == "object" || c.length > 0) && (u = { insert: c }, n.size > 0 && (u.attributes = {}, n.forEach((f, g) => {
2389
+ f !== null && (u.attributes[g] = f);
2390
+ }))), c = "";
2391
+ break;
2392
+ case "retain":
2393
+ h > 0 && (u = { retain: h }, ki(o) || (u.attributes = wi({}, o))), h = 0;
2394
+ break;
2395
+ }
2396
+ u && t.push(u), l = null;
2397
+ }
2398
+ };
2399
+ for (; i !== null; ) {
2400
+ switch (i.content.constructor) {
2401
+ case P:
2402
+ case At:
2403
+ this.adds(i) ? this.deletes(i) || (d(), l = "insert", c = i.content.getContent()[0], d()) : this.deletes(i) ? (l !== "delete" && (d(), l = "delete"), a += 1) : i.deleted || (l !== "retain" && (d(), l = "retain"), h += 1);
2404
+ break;
2405
+ case q:
2406
+ this.adds(i) ? this.deletes(i) || (l !== "insert" && (d(), l = "insert"), c += i.content.str) : this.deletes(i) ? (l !== "delete" && (d(), l = "delete"), a += i.length) : i.deleted || (l !== "retain" && (d(), l = "retain"), h += i.length);
2407
+ break;
2408
+ case E: {
2409
+ const { key: u, value: f } = i.content;
2410
+ if (this.adds(i)) {
2411
+ if (!this.deletes(i)) {
2412
+ const g = n.get(u) ?? null;
2413
+ H(g, f) ? f !== null && i.delete(r) : (l === "retain" && d(), H(f, s.get(u) ?? null) ? delete o[u] : o[u] = f);
2414
+ }
2415
+ } else if (this.deletes(i)) {
2416
+ s.set(u, f);
2417
+ const g = n.get(u) ?? null;
2418
+ H(g, f) || (l === "retain" && d(), o[u] = g);
2419
+ } else if (!i.deleted) {
2420
+ s.set(u, f);
2421
+ const g = o[u];
2422
+ g !== void 0 && (H(g, f) ? g !== null && i.delete(r) : (l === "retain" && d(), f === null ? delete o[u] : o[u] = f));
2423
+ }
2424
+ i.deleted || (l === "insert" && d(), ft(n, i.content));
2425
+ break;
2426
+ }
2427
+ }
2428
+ i = i.right;
2429
+ }
2430
+ for (d(); t.length > 0; ) {
2431
+ const u = t[t.length - 1];
2432
+ if (u.retain !== void 0 && u.attributes === void 0) t.pop();
2433
+ else break;
2434
+ }
2435
+ }), this._delta = t;
2436
+ }
2437
+ return this._delta;
2438
+ }
2439
+ }, cr = class Ae extends C {
2440
+ constructor(t) {
2441
+ super(), this._pending = t !== void 0 ? [() => this.insert(0, t)] : [], this._searchMarker = [], this._hasFormatting = !1;
2442
+ }
2443
+ get length() {
2444
+ return this.doc ?? A(), this._length;
2445
+ }
2446
+ _integrate(t, r) {
2447
+ super._integrate(t, r);
2448
+ try {
2449
+ this._pending.forEach((n) => n());
2450
+ } catch (n) {
2451
+ console.error(n);
2452
+ }
2453
+ this._pending = null;
2454
+ }
2455
+ _copy() {
2456
+ return new Ae();
2457
+ }
2458
+ clone() {
2459
+ const t = new Ae();
2460
+ return t.applyDelta(this.toDelta()), t;
2461
+ }
2462
+ _callObserver(t, r) {
2463
+ super._callObserver(t, r);
2464
+ const n = new po(this, t, r);
2465
+ le(this, t, n), !t.local && this._hasFormatting && (t._needFormattingCleanup = !0);
2466
+ }
2467
+ toString() {
2468
+ this.doc ?? A();
2469
+ let t = "", r = this._start;
2470
+ for (; r !== null; )
2471
+ !r.deleted && r.countable && r.content.constructor === q && (t += r.content.str), r = r.right;
2472
+ return t;
2473
+ }
2474
+ toJSON() {
2475
+ return this.toString();
2476
+ }
2477
+ applyDelta(t, { sanitize: r = !0 } = {}) {
2478
+ this.doc !== null ? m(this.doc, (n) => {
2479
+ const s = new De(null, this._start, 0, /* @__PURE__ */ new Map());
2480
+ for (let i = 0; i < t.length; i++) {
2481
+ const l = t[i];
2482
+ if (l.insert !== void 0) {
2483
+ const o = !r && typeof l.insert == "string" && i === t.length - 1 && s.right === null && l.insert.slice(-1) === `
2484
+ ` ? l.insert.slice(0, -1) : l.insert;
2485
+ (typeof o != "string" || o.length > 0) && ve(n, this, s, o, l.attributes || {});
2486
+ } else l.retain !== void 0 ? Mr(n, this, s, l.retain, l.attributes || {}) : l.delete !== void 0 && Ur(n, s, l.delete);
2487
+ }
2488
+ }) : this._pending.push(() => this.applyDelta(t));
2489
+ }
2490
+ toDelta(t, r, n) {
2491
+ this.doc ?? A();
2492
+ const s = [], i = /* @__PURE__ */ new Map(), l = this.doc;
2493
+ let o = "", c = this._start;
2494
+ function h() {
2495
+ if (o.length > 0) {
2496
+ const d = {};
2497
+ let u = !1;
2498
+ i.forEach((g, y) => {
2499
+ u = !0, d[y] = g;
2500
+ });
2501
+ const f = { insert: o };
2502
+ u && (f.attributes = d), s.push(f), o = "";
2503
+ }
2504
+ }
2505
+ const a = () => {
2506
+ for (; c !== null; ) {
2507
+ if (et(c, t) || r !== void 0 && et(c, r)) switch (c.content.constructor) {
2508
+ case q: {
2509
+ const d = i.get("ychange");
2510
+ t !== void 0 && !et(c, t) ? (d === void 0 || d.user !== c.id.client || d.type !== "removed") && (h(), i.set("ychange", n ? n("removed", c.id) : { type: "removed" })) : r !== void 0 && !et(c, r) ? (d === void 0 || d.user !== c.id.client || d.type !== "added") && (h(), i.set("ychange", n ? n("added", c.id) : { type: "added" })) : d !== void 0 && (h(), i.delete("ychange")), o += c.content.str;
2511
+ break;
2512
+ }
2513
+ case P:
2514
+ case At: {
2515
+ h();
2516
+ const d = { insert: c.content.getContent()[0] };
2517
+ if (i.size > 0) {
2518
+ const u = {};
2519
+ d.attributes = u, i.forEach((f, g) => {
2520
+ u[g] = f;
2521
+ });
2522
+ }
2523
+ s.push(d);
2524
+ break;
2525
+ }
2526
+ case E:
2527
+ et(c, t) && (h(), ft(i, c.content));
2528
+ break;
2529
+ }
2530
+ c = c.right;
2531
+ }
2532
+ h();
2533
+ };
2534
+ return t || r ? m(l, (d) => {
2535
+ t && Se(d, t), r && Se(d, r), a();
2536
+ }, "cleanup") : a(), s;
2537
+ }
2538
+ insert(t, r, n) {
2539
+ if (r.length <= 0) return;
2540
+ const s = this.doc;
2541
+ s !== null ? m(s, (i) => {
2542
+ const l = Ot(i, this, t, !n);
2543
+ n || (n = {}, l.currentAttributes.forEach((o, c) => {
2544
+ n[c] = o;
2545
+ })), ve(i, this, l, r, n);
2546
+ }) : this._pending.push(() => this.insert(t, r, n));
2547
+ }
2548
+ insertEmbed(t, r, n) {
2549
+ const s = this.doc;
2550
+ s !== null ? m(s, (i) => {
2551
+ const l = Ot(i, this, t, !n);
2552
+ ve(i, this, l, r, n || {});
2553
+ }) : this._pending.push(() => this.insertEmbed(t, r, n || {}));
2554
+ }
2555
+ delete(t, r) {
2556
+ if (r === 0) return;
2557
+ const n = this.doc;
2558
+ n !== null ? m(n, (s) => {
2559
+ Ur(s, Ot(s, this, t, !0), r);
2560
+ }) : this._pending.push(() => this.delete(t, r));
2561
+ }
2562
+ format(t, r, n) {
2563
+ if (r === 0) return;
2564
+ const s = this.doc;
2565
+ s !== null ? m(s, (i) => {
2566
+ const l = Ot(i, this, t, !1);
2567
+ l.right !== null && Mr(i, this, l, r, n);
2568
+ }) : this._pending.push(() => this.format(t, r, n));
2569
+ }
2570
+ removeAttribute(t) {
2571
+ this.doc !== null ? m(this.doc, (r) => {
2572
+ Xt(r, this, t);
2573
+ }) : this._pending.push(() => this.removeAttribute(t));
2574
+ }
2575
+ setAttribute(t, r) {
2576
+ this.doc !== null ? m(this.doc, (n) => {
2577
+ ir(n, this, t, r);
2578
+ }) : this._pending.push(() => this.setAttribute(t, r));
2579
+ }
2580
+ getAttribute(t) {
2581
+ return lr(this, t);
2582
+ }
2583
+ getAttributes() {
2584
+ return ts(this);
2585
+ }
2586
+ _write(t) {
2587
+ t.writeTypeRef(Bo);
2588
+ }
2589
+ }, vo = (e) => new cr(), we = class {
2590
+ constructor(e, t = () => !0) {
2591
+ this._filter = t, this._root = e, this._currentNode = e._start, this._firstCall = !0, e.doc ?? A();
2592
+ }
2593
+ [Symbol.iterator]() {
2594
+ return this;
2595
+ }
2596
+ next() {
2597
+ let e = this._currentNode, t = e && e.content && e.content.type;
2598
+ if (e !== null && (!this._firstCall || e.deleted || !this._filter(t))) do
2599
+ if (t = e.content.type, !e.deleted && (t.constructor === ar || t.constructor === oe) && t._start !== null) e = t._start;
2600
+ else for (; e !== null; ) {
2601
+ const r = e.next;
2602
+ if (r !== null) {
2603
+ e = r;
2604
+ break;
2605
+ } else e.parent === this._root ? e = null : e = e.parent._item;
2606
+ }
2607
+ while (e !== null && (e.deleted || !this._filter(e.content.type)));
2608
+ return this._firstCall = !1, e === null ? {
2609
+ value: void 0,
2610
+ done: !0
2611
+ } : (this._currentNode = e, {
2612
+ value: e.content.type,
2613
+ done: !1
2614
+ });
2615
+ }
2616
+ }, oe = class Ie extends C {
2617
+ constructor() {
2618
+ super(), this._prelimContent = [];
2619
+ }
2620
+ get firstChild() {
2621
+ const t = this._first;
2622
+ return t ? t.content.getContent()[0] : null;
2623
+ }
2624
+ _integrate(t, r) {
2625
+ super._integrate(t, r), this.insert(0, this._prelimContent), this._prelimContent = null;
2626
+ }
2627
+ _copy() {
2628
+ return new Ie();
2629
+ }
2630
+ clone() {
2631
+ const t = new Ie();
2632
+ return t.insert(0, this.toArray().map((r) => r instanceof C ? r.clone() : r)), t;
2633
+ }
2634
+ get length() {
2635
+ return this.doc ?? A(), this._prelimContent === null ? this._length : this._prelimContent.length;
2636
+ }
2637
+ createTreeWalker(t) {
2638
+ return new we(this, t);
2639
+ }
2640
+ querySelector(t) {
2641
+ t = t.toUpperCase();
2642
+ const r = new we(this, (n) => n.nodeName && n.nodeName.toUpperCase() === t).next();
2643
+ return r.done ? null : r.value;
2644
+ }
2645
+ querySelectorAll(t) {
2646
+ return t = t.toUpperCase(), Y(new we(this, (r) => r.nodeName && r.nodeName.toUpperCase() === t));
2647
+ }
2648
+ _callObserver(t, r) {
2649
+ le(this, t, new yo(this, r, t));
2650
+ }
2651
+ toString() {
2652
+ return Wn(this, (t) => t.toString()).join("");
2653
+ }
2654
+ toJSON() {
2655
+ return this.toString();
2656
+ }
2657
+ toDOM(t = document, r = {}, n) {
2658
+ const s = t.createDocumentFragment();
2659
+ return n !== void 0 && n._createAssociation(s, this), bt(this, (i) => {
2660
+ s.insertBefore(i.toDOM(t, r, n), null);
2661
+ }), s;
2662
+ }
2663
+ insert(t, r) {
2664
+ this.doc !== null ? m(this.doc, (n) => {
2665
+ Qn(n, this, t, r);
2666
+ }) : this._prelimContent.splice(t, 0, ...r);
2667
+ }
2668
+ insertAfter(t, r) {
2669
+ if (this.doc !== null) m(this.doc, (n) => {
2670
+ const s = t && t instanceof C ? t._item : t;
2671
+ Jt(n, this, s, r);
2672
+ });
2673
+ else {
2674
+ const n = this._prelimContent, s = t === null ? 0 : n.findIndex((i) => i === t) + 1;
2675
+ if (s === 0 && t !== null) throw V("Reference item not found");
2676
+ n.splice(s, 0, ...r);
2677
+ }
2678
+ }
2679
+ delete(t, r = 1) {
2680
+ this.doc !== null ? m(this.doc, (n) => {
2681
+ Pn(n, this, t, r);
2682
+ }) : this._prelimContent.splice(t, r);
2683
+ }
2684
+ toArray() {
2685
+ return Kn(this);
2686
+ }
2687
+ push(t) {
2688
+ this.insert(this.length, t);
2689
+ }
2690
+ unshift(t) {
2691
+ this.insert(0, t);
2692
+ }
2693
+ get(t) {
2694
+ return qn(this, t);
2695
+ }
2696
+ slice(t = 0, r = this.length) {
2697
+ return zn(this, t, r);
2698
+ }
2699
+ forEach(t) {
2700
+ bt(this, t);
2701
+ }
2702
+ _write(t) {
2703
+ t.writeTypeRef(Fo);
2704
+ }
2705
+ }, wo = (e) => new oe(), ar = class Te extends oe {
2706
+ constructor(t = "UNDEFINED") {
2707
+ super(), this.nodeName = t, this._prelimAttrs = /* @__PURE__ */ new Map();
2708
+ }
2709
+ get nextSibling() {
2710
+ const t = this._item ? this._item.next : null;
2711
+ return t ? t.content.type : null;
2712
+ }
2713
+ get prevSibling() {
2714
+ const t = this._item ? this._item.prev : null;
2715
+ return t ? t.content.type : null;
2716
+ }
2717
+ _integrate(t, r) {
2718
+ super._integrate(t, r), this._prelimAttrs.forEach((n, s) => {
2719
+ this.setAttribute(s, n);
2720
+ }), this._prelimAttrs = null;
2721
+ }
2722
+ _copy() {
2723
+ return new Te(this.nodeName);
2724
+ }
2725
+ clone() {
2726
+ const t = new Te(this.nodeName), r = this.getAttributes();
2727
+ return yi(r, (n, s) => {
2728
+ t.setAttribute(s, n);
2729
+ }), t.insert(0, this.toArray().map((n) => n instanceof C ? n.clone() : n)), t;
2730
+ }
2731
+ toString() {
2732
+ const t = this.getAttributes(), r = [], n = [];
2733
+ for (const l in t) n.push(l);
2734
+ n.sort();
2735
+ const s = n.length;
2736
+ for (let l = 0; l < s; l++) {
2737
+ const o = n[l];
2738
+ r.push(o + '="' + t[o] + '"');
2739
+ }
2740
+ const i = this.nodeName.toLocaleLowerCase();
2741
+ return `<${i}${r.length > 0 ? " " + r.join(" ") : ""}>${super.toString()}</${i}>`;
2742
+ }
2743
+ removeAttribute(t) {
2744
+ this.doc !== null ? m(this.doc, (r) => {
2745
+ Xt(r, this, t);
2746
+ }) : this._prelimAttrs.delete(t);
2747
+ }
2748
+ setAttribute(t, r) {
2749
+ this.doc !== null ? m(this.doc, (n) => {
2750
+ ir(n, this, t, r);
2751
+ }) : this._prelimAttrs.set(t, r);
2752
+ }
2753
+ getAttribute(t) {
2754
+ return lr(this, t);
2755
+ }
2756
+ hasAttribute(t) {
2757
+ return es(this, t);
2758
+ }
2759
+ getAttributes(t) {
2760
+ return t ? lo(this, t) : ts(this);
2761
+ }
2762
+ toDOM(t = document, r = {}, n) {
2763
+ const s = t.createElement(this.nodeName), i = this.getAttributes();
2764
+ for (const l in i) {
2765
+ const o = i[l];
2766
+ typeof o == "string" && s.setAttribute(l, o);
2767
+ }
2768
+ return bt(this, (l) => {
2769
+ s.appendChild(l.toDOM(t, r, n));
2770
+ }), n !== void 0 && n._createAssociation(s, this), s;
2771
+ }
2772
+ _write(t) {
2773
+ t.writeTypeRef(Vo), t.writeKey(this.nodeName);
2774
+ }
2775
+ }, mo = (e) => new ar(e.readKey()), yo = class extends se {
2776
+ constructor(e, t, r) {
2777
+ super(e, r), this.childListChanged = !1, this.attributesChanged = /* @__PURE__ */ new Set(), t.forEach((n) => {
2778
+ n === null ? this.childListChanged = !0 : this.attributesChanged.add(n);
2779
+ });
2780
+ }
2781
+ }, ko = class Oe extends or {
2782
+ constructor(t) {
2783
+ super(), this.hookName = t;
2784
+ }
2785
+ _copy() {
2786
+ return new Oe(this.hookName);
2787
+ }
2788
+ clone() {
2789
+ const t = new Oe(this.hookName);
2790
+ return this.forEach((r, n) => {
2791
+ t.set(n, r);
2792
+ }), t;
2793
+ }
2794
+ toDOM(t = document, r = {}, n) {
2795
+ const s = r[this.hookName];
2796
+ let i;
2797
+ return s !== void 0 ? i = s.createDom(this) : i = document.createElement(this.hookName), i.setAttribute("data-yjs-hook", this.hookName), n !== void 0 && n._createAssociation(i, this), i;
2798
+ }
2799
+ _write(t) {
2800
+ t.writeTypeRef(jo), t.writeKey(this.hookName);
2801
+ }
2802
+ }, _o = (e) => new ko(e.readKey()), bo = class xe extends cr {
2803
+ get nextSibling() {
2804
+ const t = this._item ? this._item.next : null;
2805
+ return t ? t.content.type : null;
2806
+ }
2807
+ get prevSibling() {
2808
+ const t = this._item ? this._item.prev : null;
2809
+ return t ? t.content.type : null;
2810
+ }
2811
+ _copy() {
2812
+ return new xe();
2813
+ }
2814
+ clone() {
2815
+ const t = new xe();
2816
+ return t.applyDelta(this.toDelta()), t;
2817
+ }
2818
+ toDOM(t = document, r, n) {
2819
+ const s = t.createTextNode(this.toString());
2820
+ return n !== void 0 && n._createAssociation(s, this), s;
2821
+ }
2822
+ toString() {
2823
+ return this.toDelta().map((t) => {
2824
+ const r = [];
2825
+ for (const s in t.attributes) {
2826
+ const i = [];
2827
+ for (const l in t.attributes[s]) i.push({
2828
+ key: l,
2829
+ value: t.attributes[s][l]
2830
+ });
2831
+ i.sort((l, o) => l.key < o.key ? -1 : 1), r.push({
2832
+ nodeName: s,
2833
+ attrs: i
2834
+ });
2835
+ }
2836
+ r.sort((s, i) => s.nodeName < i.nodeName ? -1 : 1);
2837
+ let n = "";
2838
+ for (let s = 0; s < r.length; s++) {
2839
+ const i = r[s];
2840
+ n += `<${i.nodeName}`;
2841
+ for (let l = 0; l < i.attrs.length; l++) {
2842
+ const o = i.attrs[l];
2843
+ n += ` ${o.key}="${o.value}"`;
2844
+ }
2845
+ n += ">";
2846
+ }
2847
+ n += t.insert;
2848
+ for (let s = r.length - 1; s >= 0; s--) n += `</${r[s].nodeName}>`;
2849
+ return n;
2850
+ }).join("");
2851
+ }
2852
+ toJSON() {
2853
+ return this.toString();
2854
+ }
2855
+ _write(t) {
2856
+ t.writeTypeRef(Yo);
2857
+ }
2858
+ }, So = (e) => new bo(), hr = class {
2859
+ constructor(e, t) {
2860
+ this.id = e, this.length = t;
2861
+ }
2862
+ get deleted() {
2863
+ throw M();
2864
+ }
2865
+ mergeWith(e) {
2866
+ return !1;
2867
+ }
2868
+ write(e, t, r) {
2869
+ throw M();
2870
+ }
2871
+ integrate(e, t) {
2872
+ throw M();
2873
+ }
2874
+ }, Co = 0, L = class extends hr {
2875
+ get deleted() {
2876
+ return !0;
2877
+ }
2878
+ delete() {
2879
+ }
2880
+ mergeWith(e) {
2881
+ return this.constructor !== e.constructor ? !1 : (this.length += e.length, !0);
2882
+ }
2883
+ integrate(e, t) {
2884
+ t > 0 && (this.id.clock += t, this.length -= t), jn(e.doc.store, this);
2885
+ }
2886
+ write(e, t) {
2887
+ e.writeInfo(Co), e.writeLen(this.length - t);
2888
+ }
2889
+ getMissing(e, t) {
2890
+ return null;
2891
+ }
2892
+ }, ur = class os {
2893
+ constructor(t) {
2894
+ this.content = t;
2895
+ }
2896
+ getLength() {
2897
+ return 1;
2898
+ }
2899
+ getContent() {
2900
+ return [this.content];
2901
+ }
2902
+ isCountable() {
2903
+ return !0;
2904
+ }
2905
+ copy() {
2906
+ return new os(this.content);
2907
+ }
2908
+ splice(t) {
2909
+ throw M();
2910
+ }
2911
+ mergeWith(t) {
2912
+ return !1;
2913
+ }
2914
+ integrate(t, r) {
2915
+ }
2916
+ delete(t) {
2917
+ }
2918
+ gc(t) {
2919
+ }
2920
+ write(t, r) {
2921
+ t.writeBuf(this.content);
2922
+ }
2923
+ getRef() {
2924
+ return 3;
2925
+ }
2926
+ }, Eo = (e) => new ur(e.readBuf()), cs = class Le {
2927
+ constructor(t) {
2928
+ this.len = t;
2929
+ }
2930
+ getLength() {
2931
+ return this.len;
2932
+ }
2933
+ getContent() {
2934
+ return [];
2935
+ }
2936
+ isCountable() {
2937
+ return !1;
2938
+ }
2939
+ copy() {
2940
+ return new Le(this.len);
2941
+ }
2942
+ splice(t) {
2943
+ const r = new Le(this.len - t);
2944
+ return this.len = t, r;
2945
+ }
2946
+ mergeWith(t) {
2947
+ return this.len += t.len, !0;
2948
+ }
2949
+ integrate(t, r) {
2950
+ jt(t.deleteSet, r.id.client, r.id.clock, this.len), r.markDeleted();
2951
+ }
2952
+ delete(t) {
2953
+ }
2954
+ gc(t) {
2955
+ }
2956
+ write(t, r) {
2957
+ t.writeLen(this.len - r);
2958
+ }
2959
+ getRef() {
2960
+ return 1;
2961
+ }
2962
+ }, Do = (e) => new cs(e.readLen()), as = (e, t) => new Pe({
2963
+ guid: e,
2964
+ ...t,
2965
+ shouldLoad: t.shouldLoad || t.autoLoad || !1
2966
+ }), dr = class hs {
2967
+ constructor(t) {
2968
+ t._item && console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."), this.doc = t;
2969
+ const r = {};
2970
+ this.opts = r, t.gc || (r.gc = !1), t.autoLoad && (r.autoLoad = !0), t.meta !== null && (r.meta = t.meta);
2971
+ }
2972
+ getLength() {
2973
+ return 1;
2974
+ }
2975
+ getContent() {
2976
+ return [this.doc];
2977
+ }
2978
+ isCountable() {
2979
+ return !0;
2980
+ }
2981
+ copy() {
2982
+ return new hs(as(this.doc.guid, this.opts));
2983
+ }
2984
+ splice(t) {
2985
+ throw M();
2986
+ }
2987
+ mergeWith(t) {
2988
+ return !1;
2989
+ }
2990
+ integrate(t, r) {
2991
+ this.doc._item = r, t.subdocsAdded.add(this.doc), this.doc.shouldLoad && t.subdocsLoaded.add(this.doc);
2992
+ }
2993
+ delete(t) {
2994
+ t.subdocsAdded.has(this.doc) ? t.subdocsAdded.delete(this.doc) : t.subdocsRemoved.add(this.doc);
2995
+ }
2996
+ gc(t) {
2997
+ }
2998
+ write(t, r) {
2999
+ t.writeString(this.doc.guid), t.writeAny(this.opts);
3000
+ }
3001
+ getRef() {
3002
+ return 9;
3003
+ }
3004
+ }, Ao = (e) => new dr(as(e.readString(), e.readAny())), At = class us {
3005
+ constructor(t) {
3006
+ this.embed = t;
3007
+ }
3008
+ getLength() {
3009
+ return 1;
3010
+ }
3011
+ getContent() {
3012
+ return [this.embed];
3013
+ }
3014
+ isCountable() {
3015
+ return !0;
3016
+ }
3017
+ copy() {
3018
+ return new us(this.embed);
3019
+ }
3020
+ splice(t) {
3021
+ throw M();
3022
+ }
3023
+ mergeWith(t) {
3024
+ return !1;
3025
+ }
3026
+ integrate(t, r) {
3027
+ }
3028
+ delete(t) {
3029
+ }
3030
+ gc(t) {
3031
+ }
3032
+ write(t, r) {
3033
+ t.writeJSON(this.embed);
3034
+ }
3035
+ getRef() {
3036
+ return 5;
3037
+ }
3038
+ }, Io = (e) => new At(e.readJSON()), E = class ds {
3039
+ constructor(t, r) {
3040
+ this.key = t, this.value = r;
3041
+ }
3042
+ getLength() {
3043
+ return 1;
3044
+ }
3045
+ getContent() {
3046
+ return [];
3047
+ }
3048
+ isCountable() {
3049
+ return !1;
3050
+ }
3051
+ copy() {
3052
+ return new ds(this.key, this.value);
3053
+ }
3054
+ splice(t) {
3055
+ throw M();
3056
+ }
3057
+ mergeWith(t) {
3058
+ return !1;
3059
+ }
3060
+ integrate(t, r) {
3061
+ const n = r.parent;
3062
+ n._searchMarker = null, n._hasFormatting = !0;
3063
+ }
3064
+ delete(t) {
3065
+ }
3066
+ gc(t) {
3067
+ }
3068
+ write(t, r) {
3069
+ t.writeKey(this.key), t.writeJSON(this.value);
3070
+ }
3071
+ getRef() {
3072
+ return 6;
3073
+ }
3074
+ }, To = (e) => new E(e.readKey(), e.readJSON()), Oo = class $e {
3075
+ constructor(t) {
3076
+ this.arr = t;
3077
+ }
3078
+ getLength() {
3079
+ return this.arr.length;
3080
+ }
3081
+ getContent() {
3082
+ return this.arr;
3083
+ }
3084
+ isCountable() {
3085
+ return !0;
3086
+ }
3087
+ copy() {
3088
+ return new $e(this.arr);
3089
+ }
3090
+ splice(t) {
3091
+ const r = new $e(this.arr.slice(t));
3092
+ return this.arr = this.arr.slice(0, t), r;
3093
+ }
3094
+ mergeWith(t) {
3095
+ return this.arr = this.arr.concat(t.arr), !0;
3096
+ }
3097
+ integrate(t, r) {
3098
+ }
3099
+ delete(t) {
3100
+ }
3101
+ gc(t) {
3102
+ }
3103
+ write(t, r) {
3104
+ const n = this.arr.length;
3105
+ t.writeLen(n - r);
3106
+ for (let s = r; s < n; s++) {
3107
+ const i = this.arr[s];
3108
+ t.writeString(i === void 0 ? "undefined" : JSON.stringify(i));
3109
+ }
3110
+ }
3111
+ getRef() {
3112
+ return 2;
3113
+ }
3114
+ }, xo = (e) => {
3115
+ const t = e.readLen(), r = [];
3116
+ for (let n = 0; n < t; n++) {
3117
+ const s = e.readString();
3118
+ s === "undefined" ? r.push(void 0) : r.push(JSON.parse(s));
3119
+ }
3120
+ return new Oo(r);
3121
+ }, Lo = yt("node_env") === "development", Gt = class Ne {
3122
+ constructor(t) {
3123
+ this.arr = t, Lo && Hr(t);
3124
+ }
3125
+ getLength() {
3126
+ return this.arr.length;
3127
+ }
3128
+ getContent() {
3129
+ return this.arr;
3130
+ }
3131
+ isCountable() {
3132
+ return !0;
3133
+ }
3134
+ copy() {
3135
+ return new Ne(this.arr);
3136
+ }
3137
+ splice(t) {
3138
+ const r = new Ne(this.arr.slice(t));
3139
+ return this.arr = this.arr.slice(0, t), r;
3140
+ }
3141
+ mergeWith(t) {
3142
+ return this.arr = this.arr.concat(t.arr), !0;
3143
+ }
3144
+ integrate(t, r) {
3145
+ }
3146
+ delete(t) {
3147
+ }
3148
+ gc(t) {
3149
+ }
3150
+ write(t, r) {
3151
+ const n = this.arr.length;
3152
+ t.writeLen(n - r);
3153
+ for (let s = r; s < n; s++) {
3154
+ const i = this.arr[s];
3155
+ t.writeAny(i);
3156
+ }
3157
+ }
3158
+ getRef() {
3159
+ return 8;
3160
+ }
3161
+ }, $o = (e) => {
3162
+ const t = e.readLen(), r = [];
3163
+ for (let n = 0; n < t; n++) r.push(e.readAny());
3164
+ return new Gt(r);
3165
+ }, q = class Me {
3166
+ constructor(t) {
3167
+ this.str = t;
3168
+ }
3169
+ getLength() {
3170
+ return this.str.length;
3171
+ }
3172
+ getContent() {
3173
+ return this.str.split("");
3174
+ }
3175
+ isCountable() {
3176
+ return !0;
3177
+ }
3178
+ copy() {
3179
+ return new Me(this.str);
3180
+ }
3181
+ splice(t) {
3182
+ const r = new Me(this.str.slice(t));
3183
+ this.str = this.str.slice(0, t);
3184
+ const n = this.str.charCodeAt(t - 1);
3185
+ return n >= 55296 && n <= 56319 && (this.str = this.str.slice(0, t - 1) + "�", r.str = "�" + r.str.slice(1)), r;
3186
+ }
3187
+ mergeWith(t) {
3188
+ return this.str += t.str, !0;
3189
+ }
3190
+ integrate(t, r) {
3191
+ }
3192
+ delete(t) {
3193
+ }
3194
+ gc(t) {
3195
+ }
3196
+ write(t, r) {
3197
+ t.writeString(r === 0 ? this.str : this.str.slice(r));
3198
+ }
3199
+ getRef() {
3200
+ return 4;
3201
+ }
3202
+ }, No = (e) => new q(e.readString()), Mo = [
3203
+ co,
3204
+ ho,
3205
+ vo,
3206
+ mo,
3207
+ wo,
3208
+ _o,
3209
+ So
3210
+ ], Uo = 0, Ro = 1, Bo = 2, Vo = 3, Fo = 4, jo = 5, Yo = 6, P = class fs {
3211
+ constructor(t) {
3212
+ this.type = t;
3213
+ }
3214
+ getLength() {
3215
+ return 1;
3216
+ }
3217
+ getContent() {
3218
+ return [this.type];
3219
+ }
3220
+ isCountable() {
3221
+ return !0;
3222
+ }
3223
+ copy() {
3224
+ return new fs(this.type._copy());
3225
+ }
3226
+ splice(t) {
3227
+ throw M();
3228
+ }
3229
+ mergeWith(t) {
3230
+ return !1;
3231
+ }
3232
+ integrate(t, r) {
3233
+ this.type._integrate(t.doc, r);
3234
+ }
3235
+ delete(t) {
3236
+ let r = this.type._start;
3237
+ for (; r !== null; )
3238
+ r.deleted ? r.id.clock < (t.beforeState.get(r.id.client) || 0) && t._mergeStructs.push(r) : r.delete(t), r = r.right;
3239
+ this.type._map.forEach((n) => {
3240
+ n.deleted ? n.id.clock < (t.beforeState.get(n.id.client) || 0) && t._mergeStructs.push(n) : n.delete(t);
3241
+ }), t.changed.delete(this.type);
3242
+ }
3243
+ gc(t) {
3244
+ let r = this.type._start;
3245
+ for (; r !== null; )
3246
+ r.gc(t, !0), r = r.right;
3247
+ this.type._start = null, this.type._map.forEach((n) => {
3248
+ for (; n !== null; )
3249
+ n.gc(t, !0), n = n.left;
3250
+ }), this.type._map = /* @__PURE__ */ new Map();
3251
+ }
3252
+ write(t, r) {
3253
+ this.type._write(t);
3254
+ }
3255
+ getRef() {
3256
+ return 7;
3257
+ }
3258
+ }, Jo = (e) => new P(Mo[e.readTypeRef()](e)), Ht = (e, t, r) => {
3259
+ const { client: n, clock: s } = t.id, i = new D(w(n, s + r), t, w(n, s + r - 1), t.right, t.rightOrigin, t.parent, t.parentSub, t.content.splice(r));
3260
+ return t.deleted && i.markDeleted(), t.keep && (i.keep = !0), t.redone !== null && (i.redone = w(t.redone.client, t.redone.clock + r)), 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 = r, i;
3261
+ }, D = class Ue extends hr {
3262
+ constructor(t, r, n, s, i, l, o, c) {
3263
+ super(t, c.getLength()), this.origin = n, this.left = r, this.right = s, this.rightOrigin = i, this.parent = l, this.parentSub = o, this.redone = null, this.content = c, this.info = this.content.isCountable() ? 2 : 0;
3264
+ }
3265
+ set marker(t) {
3266
+ (this.info & 8) > 0 !== t && (this.info ^= 8);
3267
+ }
3268
+ get marker() {
3269
+ return (this.info & 8) > 0;
3270
+ }
3271
+ get keep() {
3272
+ return (this.info & 1) > 0;
3273
+ }
3274
+ set keep(t) {
3275
+ this.keep !== t && (this.info ^= 1);
3276
+ }
3277
+ get countable() {
3278
+ return (this.info & 2) > 0;
3279
+ }
3280
+ get deleted() {
3281
+ return (this.info & 4) > 0;
3282
+ }
3283
+ set deleted(t) {
3284
+ this.deleted !== t && (this.info ^= 4);
3285
+ }
3286
+ markDeleted() {
3287
+ this.info |= 4;
3288
+ }
3289
+ getMissing(t, r) {
3290
+ if (this.origin && this.origin.client !== this.id.client && this.origin.clock >= b(r, this.origin.client)) return this.origin.client;
3291
+ if (this.rightOrigin && this.rightOrigin.client !== this.id.client && this.rightOrigin.clock >= b(r, this.rightOrigin.client)) return this.rightOrigin.client;
3292
+ if (this.parent && this.parent.constructor === it && this.id.client !== this.parent.client && this.parent.clock >= b(r, this.parent.client)) return this.parent.client;
3293
+ if (this.origin && (this.left = Or(t, r, this.origin), this.origin = this.left.lastId), this.rightOrigin && (this.right = z(t, this.rightOrigin), this.rightOrigin = this.right.id), this.left && this.left.constructor === L || this.right && this.right.constructor === L) this.parent = null;
3294
+ else if (!this.parent)
3295
+ this.left && this.left.constructor === Ue ? (this.parent = this.left.parent, this.parentSub = this.left.parentSub) : this.right && this.right.constructor === Ue && (this.parent = this.right.parent, this.parentSub = this.right.parentSub);
3296
+ else if (this.parent.constructor === it) {
3297
+ const n = pe(r, this.parent);
3298
+ n.constructor === L ? this.parent = null : this.parent = n.content.type;
3299
+ }
3300
+ return null;
3301
+ }
3302
+ integrate(t, r) {
3303
+ if (r > 0 && (this.id.clock += r, this.left = Or(t, t.doc.store, w(this.id.client, this.id.clock - 1)), this.origin = this.left.lastId, this.content = this.content.splice(r), this.length -= r), this.parent) {
3304
+ if (!this.left && (!this.right || this.right.left !== null) || this.left && this.left.right !== this.right) {
3305
+ let n = this.left, s;
3306
+ if (n !== null) s = n.right;
3307
+ else if (this.parentSub !== null)
3308
+ for (s = this.parent._map.get(this.parentSub) || null; s !== null && s.left !== null; ) s = s.left;
3309
+ else s = this.parent._start;
3310
+ const i = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set();
3311
+ for (; s !== null && s !== this.right; ) {
3312
+ if (l.add(s), i.add(s), It(this.origin, s.origin)) {
3313
+ if (s.id.client < this.id.client)
3314
+ n = s, i.clear();
3315
+ else if (It(this.rightOrigin, s.rightOrigin)) break;
3316
+ } else if (s.origin !== null && l.has(pe(t.doc.store, s.origin)))
3317
+ i.has(pe(t.doc.store, s.origin)) || (n = s, i.clear());
3318
+ else break;
3319
+ s = s.right;
3320
+ }
3321
+ this.left = n;
3322
+ }
3323
+ if (this.left !== null) {
3324
+ const n = this.left.right;
3325
+ this.right = n, this.left.right = this;
3326
+ } else {
3327
+ let n;
3328
+ if (this.parentSub !== null)
3329
+ for (n = this.parent._map.get(this.parentSub) || null; n !== null && n.left !== null; ) n = n.left;
3330
+ else
3331
+ n = this.parent._start, this.parent._start = this;
3332
+ this.right = n;
3333
+ }
3334
+ this.right !== null ? this.right.left = this : this.parentSub !== null && (this.parent._map.set(this.parentSub, this), this.left !== null && this.left.delete(t)), this.parentSub === null && this.countable && !this.deleted && (this.parent._length += this.length), jn(t.doc.store, this), this.content.integrate(t, this), Lr(t, this.parent, this.parentSub), (this.parent._item !== null && this.parent._item.deleted || this.parentSub !== null && this.right !== null) && this.delete(t);
3335
+ } else new L(this.id, this.length).integrate(t, 0);
3336
+ }
3337
+ get next() {
3338
+ let t = this.right;
3339
+ for (; t !== null && t.deleted; ) t = t.right;
3340
+ return t;
3341
+ }
3342
+ get prev() {
3343
+ let t = this.left;
3344
+ for (; t !== null && t.deleted; ) t = t.left;
3345
+ return t;
3346
+ }
3347
+ get lastId() {
3348
+ return this.length === 1 ? this.id : w(this.id.client, this.id.clock + this.length - 1);
3349
+ }
3350
+ mergeWith(t) {
3351
+ if (this.constructor === t.constructor && It(t.origin, this.lastId) && this.right === t && It(this.rightOrigin, t.rightOrigin) && this.id.client === t.id.client && this.id.clock + this.length === t.id.clock && this.deleted === t.deleted && this.redone === null && t.redone === null && this.content.constructor === t.content.constructor && this.content.mergeWith(t.content)) {
3352
+ const r = this.parent._searchMarker;
3353
+ return r && r.forEach((n) => {
3354
+ n.p === t && (n.p = this, !this.deleted && this.countable && (n.index -= this.length));
3355
+ }), t.keep && (this.keep = !0), this.right = t.right, this.right !== null && (this.right.left = this), this.length += t.length, !0;
3356
+ }
3357
+ return !1;
3358
+ }
3359
+ delete(t) {
3360
+ if (!this.deleted) {
3361
+ const r = this.parent;
3362
+ this.countable && this.parentSub === null && (r._length -= this.length), this.markDeleted(), jt(t.deleteSet, this.id.client, this.id.clock, this.length), Lr(t, r, this.parentSub), this.content.delete(t);
3363
+ }
3364
+ }
3365
+ gc(t, r) {
3366
+ if (!this.deleted) throw N();
3367
+ this.content.gc(t), r ? Xl(t, this, new L(this.id, this.length)) : this.content = new cs(this.length);
3368
+ }
3369
+ write(t, r) {
3370
+ const n = r > 0 ? w(this.id.client, this.id.clock + r - 1) : this.origin, s = this.rightOrigin, i = this.parentSub, l = this.content.getRef() & 31 | (n === null ? 0 : 128) | (s === null ? 0 : 64) | (i === null ? 0 : 32);
3371
+ if (t.writeInfo(l), n !== null && t.writeLeftID(n), s !== null && t.writeRightID(s), n === null && s === null) {
3372
+ const o = this.parent;
3373
+ if (o._item !== void 0) {
3374
+ const c = o._item;
3375
+ if (c === null) {
3376
+ const h = Fl(o);
3377
+ t.writeParentInfo(!0), t.writeString(h);
3378
+ } else
3379
+ t.writeParentInfo(!1), t.writeLeftID(c.id);
3380
+ } else o.constructor === String ? (t.writeParentInfo(!0), t.writeString(o)) : o.constructor === it ? (t.writeParentInfo(!1), t.writeLeftID(o)) : N();
3381
+ i !== null && t.writeString(i);
3382
+ }
3383
+ this.content.write(t, r);
3384
+ }
3385
+ }, gs = (e, t) => Xo[t & 31](e), Xo = [
3386
+ () => {
3387
+ N();
3388
+ },
3389
+ Do,
3390
+ xo,
3391
+ Eo,
3392
+ No,
3393
+ Io,
3394
+ To,
3395
+ Jo,
3396
+ $o,
3397
+ Ao,
3398
+ () => {
3399
+ N();
3400
+ }
3401
+ ], Go = 10, $ = class extends hr {
3402
+ get deleted() {
3403
+ return !0;
3404
+ }
3405
+ delete() {
3406
+ }
3407
+ mergeWith(e) {
3408
+ return this.constructor !== e.constructor ? !1 : (this.length += e.length, !0);
3409
+ }
3410
+ integrate(e, t) {
3411
+ N();
3412
+ }
3413
+ write(e, t) {
3414
+ e.writeInfo(Go), v(e.restEncoder, this.length - t);
3415
+ }
3416
+ getMissing(e, t) {
3417
+ return null;
3418
+ }
3419
+ }, ps = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : {}, vs = "__ $YJS$ __";
3420
+ ps[vs] === !0 && console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");
3421
+ ps[vs] = !0;
3422
+ export {
3423
+ O as A,
3424
+ rs as Array,
3425
+ Ho as B,
3426
+ Kt as C,
3427
+ ye as D,
3428
+ Pe as Doc,
3429
+ vt as E,
3430
+ Fr as F,
3431
+ K as H,
3432
+ B as I,
3433
+ zo as L,
3434
+ uc as M,
3435
+ or as Map,
3436
+ Vs as N,
3437
+ rt as O,
3438
+ V as P,
3439
+ Br as R,
3440
+ x as S,
3441
+ R as T,
3442
+ cr as Text,
3443
+ J as U,
3444
+ bs as V,
3445
+ ht as _,
3446
+ ml as a,
3447
+ Wc as applyUpdate,
3448
+ nt as b,
3449
+ kc as c,
3450
+ ot as d,
3451
+ qc as encodeStateAsUpdate,
3452
+ Zc as encodeStateVector,
3453
+ Nt as f,
3454
+ pi as g,
3455
+ vc as h,
3456
+ vn as i,
3457
+ zs as j,
3458
+ v as k,
3459
+ bc as l,
3460
+ wc as m,
3461
+ Kc as n,
3462
+ wn as o,
3463
+ mc as p,
3464
+ Gc as r,
3465
+ bn as s,
3466
+ zc as t,
3467
+ _c as u,
3468
+ wt as v,
3469
+ Ws as w,
3470
+ p as x,
3471
+ lt as y,
3472
+ Wo as z
3473
+ };