playhtml 0.1.2 → 0.1.3

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.
@@ -6,13 +6,13 @@ const T = () => /* @__PURE__ */ new Map(), Ce = (n) => {
6
6
  return n.forEach((e, s) => {
7
7
  t.set(s, e);
8
8
  }), t;
9
- }, Y = (n, t, e) => {
9
+ }, K = (n, t, e) => {
10
10
  let s = n.get(t);
11
11
  return s === void 0 && n.set(t, s = e()), s;
12
12
  }, Vs = (n, t) => {
13
13
  const e = [];
14
- for (const [s, r] of n)
15
- e.push(t(r, s));
14
+ for (const [s, i] of n)
15
+ e.push(t(i, s));
16
16
  return e;
17
17
  }, Bs = (n, t) => {
18
18
  for (const [e, s] of n)
@@ -22,16 +22,16 @@ const T = () => /* @__PURE__ */ new Map(), Ce = (n) => {
22
22
  }, nt = () => /* @__PURE__ */ new Set(), ue = (n) => n[n.length - 1], Fs = (n, t) => {
23
23
  for (let e = 0; e < t.length; e++)
24
24
  n.push(t[e]);
25
- }, K = Array.from, $s = Array.isArray, js = String.fromCharCode, Ys = (n) => n.toLowerCase(), Xs = /^\s*/g, Js = (n) => n.replace(Xs, ""), Gs = /([A-Z])/g, rn = (n, t) => Js(n.replace(Gs, (e) => `${t}${Ys(e)}`)), Ws = (n) => {
25
+ }, z = Array.from, $s = Array.isArray, js = String.fromCharCode, Ks = (n) => n.toLowerCase(), Ys = /^\s*/g, Xs = (n) => n.replace(Ys, ""), Js = /([A-Z])/g, rn = (n, t) => Xs(n.replace(Js, (e) => `${t}${Ks(e)}`)), Gs = (n) => {
26
26
  const t = unescape(encodeURIComponent(n)), e = t.length, s = new Uint8Array(e);
27
- for (let r = 0; r < e; r++)
28
- s[r] = /** @type {number} */
29
- t.codePointAt(r);
27
+ for (let i = 0; i < e; i++)
28
+ s[i] = /** @type {number} */
29
+ t.codePointAt(i);
30
30
  return s;
31
- }, It = (
31
+ }, At = (
32
32
  /** @type {TextEncoder} */
33
33
  typeof TextEncoder < "u" ? new TextEncoder() : null
34
- ), zs = (n) => It.encode(n), Ks = It ? zs : Ws;
34
+ ), Ws = (n) => At.encode(n), zs = At ? Ws : Gs;
35
35
  let Ct = typeof TextDecoder > "u" ? null : new TextDecoder("utf-8", { fatal: !0, ignoreBOM: !0 });
36
36
  Ct && Ct.decode(new Uint8Array()).length === 1 && (Ct = null);
37
37
  const on = (n) => n === void 0 ? null : n;
@@ -66,33 +66,33 @@ const vn = Un, Qs = (n) => Oe || addEventListener(
66
66
  "storage",
67
67
  /** @type {any} */
68
68
  n
69
- ), Ps = Object.assign, tr = Object.keys, er = (n, t) => {
69
+ ), Ps = Object.assign, ti = Object.keys, ei = (n, t) => {
70
70
  for (const e in n)
71
71
  t(n[e], e);
72
- }, nr = (n, t) => {
72
+ }, ni = (n, t) => {
73
73
  const e = [];
74
74
  for (const s in n)
75
75
  e.push(t(n[s], s));
76
76
  return e;
77
- }, zt = (n) => tr(n).length, sr = (n) => {
77
+ }, Wt = (n) => ti(n).length, si = (n) => {
78
78
  for (const t in n)
79
79
  return !1;
80
80
  return !0;
81
- }, rr = (n, t) => {
81
+ }, ii = (n, t) => {
82
82
  for (const e in n)
83
83
  if (!t(n[e], e))
84
84
  return !1;
85
85
  return !0;
86
- }, On = (n, t) => Object.prototype.hasOwnProperty.call(n, t), ir = (n, t) => n === t || zt(n) === zt(t) && rr(n, (e, s) => (e !== void 0 || On(t, s)) && t[s] === e), Te = (n, t, e = 0) => {
86
+ }, On = (n, t) => Object.prototype.hasOwnProperty.call(n, t), ri = (n, t) => n === t || Wt(n) === Wt(t) && ii(n, (e, s) => (e !== void 0 || On(t, s)) && t[s] === e), Te = (n, t, e = 0) => {
87
87
  try {
88
88
  for (; e < n.length; e++)
89
89
  n[e](...t);
90
90
  } finally {
91
91
  e < n.length && Te(n, t, e + 1);
92
92
  }
93
- }, or = (n) => n, cr = (n, t) => n === t, Dt = (n, t) => {
93
+ }, oi = (n) => n, li = (n, t) => n === t, Dt = (n, t) => {
94
94
  if (n == null || t == null)
95
- return cr(n, t);
95
+ return li(n, t);
96
96
  if (n.constructor !== t.constructor)
97
97
  return !1;
98
98
  if (n === t)
@@ -125,7 +125,7 @@ const vn = Un, Qs = (n) => Oe || addEventListener(
125
125
  break;
126
126
  }
127
127
  case Object:
128
- if (zt(n) !== zt(t))
128
+ if (Wt(n) !== Wt(t))
129
129
  return !1;
130
130
  for (const e in n)
131
131
  if (!On(n, e) || !Dt(n[e], t[e]))
@@ -142,9 +142,9 @@ const vn = Un, Qs = (n) => Oe || addEventListener(
142
142
  return !1;
143
143
  }
144
144
  return !0;
145
- }, lr = (n, t) => t.includes(n), ft = typeof process < "u" && process.release && /node|io\.js/.test(process.release.name), Tn = typeof window < "u" && typeof document < "u" && !ft;
145
+ }, ci = (n, t) => t.includes(n), ft = typeof process < "u" && process.release && /node|io\.js/.test(process.release.name), Tn = typeof window < "u" && typeof document < "u" && !ft;
146
146
  let R;
147
- const hr = () => {
147
+ const hi = () => {
148
148
  if (R === void 0)
149
149
  if (ft) {
150
150
  R = T();
@@ -163,9 +163,9 @@ const hr = () => {
163
163
  }
164
164
  })) : R = T();
165
165
  return R;
166
- }, De = (n) => hr().has(n), Ee = (n) => on(ft ? process.env[n.toUpperCase()] : vn.getItem(n)), ar = (n) => De("--" + n) || Ee(n) !== null;
167
- ar("production");
168
- const cn = ft && lr(process.env.FORCE_COLOR, ["true", "1", "2"]), ur = !De("no-colors") && (!ft || process.stdout.isTTY || cn) && (!ft || De("color") || cn || Ee("COLORTERM") !== null || (Ee("TERM") || "").includes("color")), j = Math.floor, Yt = Math.abs, Re = (n, t) => n < t ? n : t, ct = (n, t) => n > t ? n : t, dr = Math.pow, Rn = (n) => n !== 0 ? n < 0 : 1 / n < 0, ln = 1, hn = 2, de = 4, fe = 8, At = 32, $ = 64, M = 128, se = 31, Ie = 63, tt = 127, fr = 2147483647, Nn = Number.MAX_SAFE_INTEGER, gr = Number.isInteger || ((n) => typeof n == "number" && isFinite(n) && j(n) === n);
166
+ }, De = (n) => hi().has(n), Ee = (n) => on(ft ? process.env[n.toUpperCase()] : vn.getItem(n)), ai = (n) => De("--" + n) || Ee(n) !== null;
167
+ ai("production");
168
+ const ln = ft && ci(process.env.FORCE_COLOR, ["true", "1", "2"]), ui = !De("no-colors") && (!ft || process.stdout.isTTY || ln) && (!ft || De("color") || ln || Ee("COLORTERM") !== null || (Ee("TERM") || "").includes("color")), j = Math.floor, Kt = Math.abs, Re = (n, t) => n < t ? n : t, lt = (n, t) => n > t ? n : t, di = Math.pow, Rn = (n) => n !== 0 ? n < 0 : 1 / n < 0, cn = 1, hn = 2, de = 4, fe = 8, It = 32, $ = 64, M = 128, se = 31, Ae = 63, tt = 127, fi = 2147483647, Nn = Number.MAX_SAFE_INTEGER, gi = Number.isInteger || ((n) => typeof n == "number" && isFinite(n) && j(n) === n);
169
169
  class Tt {
170
170
  constructor() {
171
171
  this.cpos = 0, this.cbuf = new Uint8Array(100), this.bufs = [];
@@ -180,64 +180,64 @@ const x = () => new Tt(), Ne = (n) => {
180
180
  const t = new Uint8Array(Ne(n));
181
181
  let e = 0;
182
182
  for (let s = 0; s < n.bufs.length; s++) {
183
- const r = n.bufs[s];
184
- t.set(r, e), e += r.length;
183
+ const i = n.bufs[s];
184
+ t.set(i, e), e += i.length;
185
185
  }
186
186
  return t.set($e(n.cbuf.buffer, 0, n.cpos), e), t;
187
- }, pr = (n, t) => {
187
+ }, pi = (n, t) => {
188
188
  const e = n.cbuf.length;
189
- e - n.cpos < t && (n.bufs.push($e(n.cbuf.buffer, 0, n.cpos)), n.cbuf = new Uint8Array(ct(e, t) * 2), n.cpos = 0);
189
+ e - n.cpos < t && (n.bufs.push($e(n.cbuf.buffer, 0, n.cpos)), n.cbuf = new Uint8Array(lt(e, t) * 2), n.cpos = 0);
190
190
  }, E = (n, t) => {
191
191
  const e = n.cbuf.length;
192
192
  n.cpos === e && (n.bufs.push(n.cbuf), n.cbuf = new Uint8Array(e * 2), n.cpos = 0), n.cbuf[n.cpos++] = t;
193
- }, Ae = E, p = (n, t) => {
193
+ }, Ie = E, p = (n, t) => {
194
194
  for (; t > tt; )
195
195
  E(n, M | tt & t), t = j(t / 128);
196
196
  E(n, tt & t);
197
197
  }, He = (n, t) => {
198
198
  const e = Rn(t);
199
- for (e && (t = -t), E(n, (t > Ie ? M : 0) | (e ? $ : 0) | Ie & t), t = j(t / 64); t > 0; )
199
+ for (e && (t = -t), E(n, (t > Ae ? M : 0) | (e ? $ : 0) | Ae & t), t = j(t / 64); t > 0; )
200
200
  E(n, (t > tt ? M : 0) | tt & t), t = j(t / 128);
201
- }, Le = new Uint8Array(3e4), wr = Le.length / 3, mr = (n, t) => {
202
- if (t.length < wr) {
203
- const e = It.encodeInto(t, Le).written || 0;
201
+ }, Le = new Uint8Array(3e4), wi = Le.length / 3, mi = (n, t) => {
202
+ if (t.length < wi) {
203
+ const e = At.encodeInto(t, Le).written || 0;
204
204
  p(n, e);
205
205
  for (let s = 0; s < e; s++)
206
206
  E(n, Le[s]);
207
207
  } else
208
- S(n, Ks(t));
209
- }, yr = (n, t) => {
208
+ S(n, zs(t));
209
+ }, yi = (n, t) => {
210
210
  const e = unescape(encodeURIComponent(t)), s = e.length;
211
211
  p(n, s);
212
- for (let r = 0; r < s; r++)
212
+ for (let i = 0; i < s; i++)
213
213
  E(
214
214
  n,
215
215
  /** @type {number} */
216
- e.codePointAt(r)
216
+ e.codePointAt(i)
217
217
  );
218
- }, et = It && /** @type {any} */
219
- It.encodeInto ? mr : yr, re = (n, t) => {
220
- const e = n.cbuf.length, s = n.cpos, r = Re(e - s, t.length), i = t.length - r;
221
- n.cbuf.set(t.subarray(0, r), s), n.cpos += r, i > 0 && (n.bufs.push(n.cbuf), n.cbuf = new Uint8Array(ct(e * 2, i)), n.cbuf.set(t.subarray(r)), n.cpos = i);
218
+ }, et = At && /** @type {any} */
219
+ At.encodeInto ? mi : yi, ie = (n, t) => {
220
+ const e = n.cbuf.length, s = n.cpos, i = Re(e - s, t.length), r = t.length - i;
221
+ n.cbuf.set(t.subarray(0, i), s), n.cpos += i, r > 0 && (n.bufs.push(n.cbuf), n.cbuf = new Uint8Array(lt(e * 2, r)), n.cbuf.set(t.subarray(i)), n.cpos = r);
222
222
  }, S = (n, t) => {
223
- p(n, t.byteLength), re(n, t);
223
+ p(n, t.byteLength), ie(n, t);
224
224
  }, Ve = (n, t) => {
225
- pr(n, t);
225
+ pi(n, t);
226
226
  const e = new DataView(n.cbuf.buffer, n.cpos, t);
227
227
  return n.cpos += t, e;
228
- }, kr = (n, t) => Ve(n, 4).setFloat32(0, t, !1), br = (n, t) => Ve(n, 8).setFloat64(0, t, !1), _r = (n, t) => (
228
+ }, ki = (n, t) => Ve(n, 4).setFloat32(0, t, !1), bi = (n, t) => Ve(n, 8).setFloat64(0, t, !1), _i = (n, t) => (
229
229
  /** @type {any} */
230
230
  Ve(n, 8).setBigInt64(0, t, !1)
231
- ), an = new DataView(new ArrayBuffer(4)), Sr = (n) => (an.setFloat32(0, n), an.getFloat32(0) === n), Lt = (n, t) => {
231
+ ), an = new DataView(new ArrayBuffer(4)), Si = (n) => (an.setFloat32(0, n), an.getFloat32(0) === n), Lt = (n, t) => {
232
232
  switch (typeof t) {
233
233
  case "string":
234
234
  E(n, 119), et(n, t);
235
235
  break;
236
236
  case "number":
237
- gr(t) && Yt(t) <= fr ? (E(n, 125), He(n, t)) : Sr(t) ? (E(n, 124), kr(n, t)) : (E(n, 123), br(n, t));
237
+ gi(t) && Kt(t) <= fi ? (E(n, 125), He(n, t)) : Si(t) ? (E(n, 124), ki(n, t)) : (E(n, 123), bi(n, t));
238
238
  break;
239
239
  case "bigint":
240
- E(n, 122), _r(n, t);
240
+ E(n, 122), _i(n, t);
241
241
  break;
242
242
  case "object":
243
243
  if (t === null)
@@ -253,8 +253,8 @@ It.encodeInto ? mr : yr, re = (n, t) => {
253
253
  const e = Object.keys(t);
254
254
  p(n, e.length);
255
255
  for (let s = 0; s < e.length; s++) {
256
- const r = e[s];
257
- et(n, r), Lt(n, t[r]);
256
+ const i = e[s];
257
+ et(n, i), Lt(n, t[i]);
258
258
  }
259
259
  }
260
260
  break;
@@ -282,7 +282,7 @@ class un extends Tt {
282
282
  const dn = (n) => {
283
283
  n.count > 0 && (He(n.encoder, n.count === 1 ? n.s : -n.s), n.count > 1 && p(n.encoder, n.count - 2));
284
284
  };
285
- class Xt {
285
+ class Yt {
286
286
  constructor() {
287
287
  this.encoder = new Tt(), this.s = 0, this.count = 0;
288
288
  }
@@ -316,9 +316,9 @@ class ge {
316
316
  return fn(this), _(this.encoder);
317
317
  }
318
318
  }
319
- class Cr {
319
+ class Ci {
320
320
  constructor() {
321
- this.sarr = [], this.s = "", this.lensE = new Xt();
321
+ this.sarr = [], this.s = "", this.lensE = new Yt();
322
322
  }
323
323
  /**
324
324
  * @param {string} string
@@ -328,7 +328,7 @@ class Cr {
328
328
  }
329
329
  toUint8Array() {
330
330
  const t = new Tt();
331
- return this.sarr.push(this.s), this.s = "", et(t, this.sarr.join("")), re(t, this.lensE.toUint8Array()), _(t);
331
+ return this.sarr.push(this.s), this.s = "", et(t, this.sarr.join("")), ie(t, this.lensE.toUint8Array()), _(t);
332
332
  }
333
333
  }
334
334
  const yt = (n) => new Error(n), N = () => {
@@ -336,7 +336,7 @@ const yt = (n) => new Error(n), N = () => {
336
336
  }, H = () => {
337
337
  throw yt("Unexpected case");
338
338
  }, Hn = yt("Unexpected end of array"), Vn = yt("Integer out of Range");
339
- class ie {
339
+ class re {
340
340
  /**
341
341
  * @param {Uint8Array} uint8Array Binary data to decode
342
342
  */
@@ -344,34 +344,34 @@ class ie {
344
344
  this.arr = t, this.pos = 0;
345
345
  }
346
346
  }
347
- const Q = (n) => new ie(n), Dr = (n) => n.pos !== n.arr.length, Er = (n, t) => {
347
+ const Q = (n) => new re(n), Di = (n) => n.pos !== n.arr.length, Ei = (n, t) => {
348
348
  const e = $e(n.arr.buffer, n.pos + n.arr.byteOffset, t);
349
349
  return n.pos += t, e;
350
- }, L = (n) => Er(n, w(n)), gt = (n) => n.arr[n.pos++], w = (n) => {
350
+ }, L = (n) => Ei(n, w(n)), gt = (n) => n.arr[n.pos++], w = (n) => {
351
351
  let t = 0, e = 1;
352
352
  const s = n.arr.length;
353
353
  for (; n.pos < s; ) {
354
- const r = n.arr[n.pos++];
355
- if (t = t + (r & tt) * e, e *= 128, r < M)
354
+ const i = n.arr[n.pos++];
355
+ if (t = t + (i & tt) * e, e *= 128, i < M)
356
356
  return t;
357
357
  if (t > Nn)
358
358
  throw Vn;
359
359
  }
360
360
  throw Hn;
361
361
  }, Be = (n) => {
362
- let t = n.arr[n.pos++], e = t & Ie, s = 64;
363
- const r = (t & $) > 0 ? -1 : 1;
362
+ let t = n.arr[n.pos++], e = t & Ae, s = 64;
363
+ const i = (t & $) > 0 ? -1 : 1;
364
364
  if (!(t & M))
365
- return r * e;
366
- const i = n.arr.length;
367
- for (; n.pos < i; ) {
365
+ return i * e;
366
+ const r = n.arr.length;
367
+ for (; n.pos < r; ) {
368
368
  if (t = n.arr[n.pos++], e = e + (t & tt) * s, s *= 128, t < M)
369
- return r * e;
369
+ return i * e;
370
370
  if (e > Nn)
371
371
  throw Vn;
372
372
  }
373
373
  throw Hn;
374
- }, Ir = (n) => {
374
+ }, Ai = (n) => {
375
375
  let t = w(n);
376
376
  if (t === 0)
377
377
  return "";
@@ -382,25 +382,25 @@ const Q = (n) => new ie(n), Dr = (n) => n.pos !== n.arr.length, Er = (n, t) => {
382
382
  e += String.fromCodePoint(gt(n));
383
383
  else
384
384
  for (; t > 0; ) {
385
- const s = t < 1e4 ? t : 1e4, r = n.arr.subarray(n.pos, n.pos + s);
385
+ const s = t < 1e4 ? t : 1e4, i = n.arr.subarray(n.pos, n.pos + s);
386
386
  n.pos += s, e += String.fromCodePoint.apply(
387
387
  null,
388
388
  /** @type {any} */
389
- r
389
+ i
390
390
  ), t -= s;
391
391
  }
392
392
  return decodeURIComponent(escape(e));
393
393
  }
394
- }, Ar = (n) => (
394
+ }, Ii = (n) => (
395
395
  /** @type any */
396
396
  Ct.decode(L(n))
397
- ), z = Ct ? Ar : Ir, Fe = (n, t) => {
397
+ ), W = Ct ? Ii : Ai, Fe = (n, t) => {
398
398
  const e = new DataView(n.arr.buffer, n.arr.byteOffset + n.pos, t);
399
399
  return n.pos += t, e;
400
- }, Lr = (n) => Fe(n, 4).getFloat32(0, !1), xr = (n) => Fe(n, 8).getFloat64(0, !1), Mr = (n) => (
400
+ }, Li = (n) => Fe(n, 4).getFloat32(0, !1), xi = (n) => Fe(n, 8).getFloat64(0, !1), Mi = (n) => (
401
401
  /** @type {any} */
402
402
  Fe(n, 8).getBigInt64(0, !1)
403
- ), Ur = [
403
+ ), Ui = [
404
404
  (n) => {
405
405
  },
406
406
  // CASE 127: undefined
@@ -408,23 +408,23 @@ const Q = (n) => new ie(n), Dr = (n) => n.pos !== n.arr.length, Er = (n, t) => {
408
408
  // CASE 126: null
409
409
  Be,
410
410
  // CASE 125: integer
411
- Lr,
411
+ Li,
412
412
  // CASE 124: float32
413
- xr,
413
+ xi,
414
414
  // CASE 123: float64
415
- Mr,
415
+ Mi,
416
416
  // CASE 122: bigint
417
417
  (n) => !1,
418
418
  // CASE 121: boolean (false)
419
419
  (n) => !0,
420
420
  // CASE 120: boolean (true)
421
- z,
421
+ W,
422
422
  // CASE 119: string
423
423
  (n) => {
424
424
  const t = w(n), e = {};
425
425
  for (let s = 0; s < t; s++) {
426
- const r = z(n);
427
- e[r] = xt(n);
426
+ const i = W(n);
427
+ e[i] = xt(n);
428
428
  }
429
429
  return e;
430
430
  },
@@ -436,8 +436,8 @@ const Q = (n) => new ie(n), Dr = (n) => n.pos !== n.arr.length, Er = (n, t) => {
436
436
  },
437
437
  L
438
438
  // CASE 116: Uint8Array
439
- ], xt = (n) => Ur[127 - gt(n)](n);
440
- class gn extends ie {
439
+ ], xt = (n) => Ui[127 - gt(n)](n);
440
+ class gn extends re {
441
441
  /**
442
442
  * @param {Uint8Array} uint8Array
443
443
  * @param {function(Decoder):T} reader
@@ -446,11 +446,11 @@ class gn extends ie {
446
446
  super(t), this.reader = e, this.s = null, this.count = 0;
447
447
  }
448
448
  read() {
449
- return this.count === 0 && (this.s = this.reader(this), Dr(this) ? this.count = w(this) + 1 : this.count = -1), this.count--, /** @type {T} */
449
+ return this.count === 0 && (this.s = this.reader(this), Di(this) ? this.count = w(this) + 1 : this.count = -1), this.count--, /** @type {T} */
450
450
  this.s;
451
451
  }
452
452
  }
453
- class Jt extends ie {
453
+ class Xt extends re {
454
454
  /**
455
455
  * @param {Uint8Array} uint8Array
456
456
  */
@@ -467,7 +467,7 @@ class Jt extends ie {
467
467
  this.s;
468
468
  }
469
469
  }
470
- class pe extends ie {
470
+ class pe extends re {
471
471
  /**
472
472
  * @param {Uint8Array} uint8Array
473
473
  */
@@ -485,12 +485,12 @@ class pe extends ie {
485
485
  return this.s += this.diff, this.count--, this.s;
486
486
  }
487
487
  }
488
- class vr {
488
+ class vi {
489
489
  /**
490
490
  * @param {Uint8Array} uint8Array
491
491
  */
492
492
  constructor(t) {
493
- this.decoder = new Jt(t), this.str = z(this.decoder), this.spos = 0;
493
+ this.decoder = new Xt(t), this.str = W(this.decoder), this.spos = 0;
494
494
  }
495
495
  /**
496
496
  * @return {string}
@@ -500,54 +500,54 @@ class vr {
500
500
  return this.spos = t, e;
501
501
  }
502
502
  }
503
- const Bn = (n) => new Uint8Array(n), $e = (n, t, e) => new Uint8Array(n, t, e), Or = (n) => new Uint8Array(n), Tr = (n) => {
503
+ const Bn = (n) => new Uint8Array(n), $e = (n, t, e) => new Uint8Array(n, t, e), Oi = (n) => new Uint8Array(n), Ti = (n) => {
504
504
  let t = "";
505
505
  for (let e = 0; e < n.byteLength; e++)
506
506
  t += js(n[e]);
507
507
  return btoa(t);
508
- }, Rr = (n) => Buffer.from(n.buffer, n.byteOffset, n.byteLength).toString("base64"), Nr = (n) => {
508
+ }, Ri = (n) => Buffer.from(n.buffer, n.byteOffset, n.byteLength).toString("base64"), Ni = (n) => {
509
509
  const t = atob(n), e = Bn(t.length);
510
510
  for (let s = 0; s < t.length; s++)
511
511
  e[s] = t.charCodeAt(s);
512
512
  return e;
513
- }, Hr = (n) => {
513
+ }, Hi = (n) => {
514
514
  const t = Buffer.from(n, "base64");
515
515
  return new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
516
- }, Vr = Tn ? Tr : Rr, Br = Tn ? Nr : Hr, Fr = (n) => {
516
+ }, Vi = Tn ? Ti : Ri, Bi = Tn ? Ni : Hi, Fi = (n) => {
517
517
  const t = Bn(n.byteLength);
518
518
  return t.set(n), t;
519
519
  }, Fn = /* @__PURE__ */ new Map();
520
- class $r {
520
+ class $i {
521
521
  /**
522
522
  * @param {string} room
523
523
  */
524
524
  constructor(t) {
525
- this.room = t, this.onmessage = null, this._onChange = (e) => e.key === t && this.onmessage !== null && this.onmessage({ data: Br(e.newValue || "") }), Qs(this._onChange);
525
+ this.room = t, this.onmessage = null, this._onChange = (e) => e.key === t && this.onmessage !== null && this.onmessage({ data: Bi(e.newValue || "") }), Qs(this._onChange);
526
526
  }
527
527
  /**
528
528
  * @param {ArrayBuffer} buf
529
529
  */
530
530
  postMessage(t) {
531
- vn.setItem(this.room, Vr(Or(t)));
531
+ vn.setItem(this.room, Vi(Oi(t)));
532
532
  }
533
533
  close() {
534
534
  Zs(this._onChange);
535
535
  }
536
536
  }
537
- const jr = typeof BroadcastChannel > "u" ? $r : BroadcastChannel, je = (n) => Y(Fn, n, () => {
538
- const t = nt(), e = new jr(n);
539
- return e.onmessage = (s) => t.forEach((r) => r(s.data, "broadcastchannel")), {
537
+ const ji = typeof BroadcastChannel > "u" ? $i : BroadcastChannel, je = (n) => K(Fn, n, () => {
538
+ const t = nt(), e = new ji(n);
539
+ return e.onmessage = (s) => t.forEach((i) => i(s.data, "broadcastchannel")), {
540
540
  bc: e,
541
541
  subs: t
542
542
  };
543
- }), Yr = (n, t) => (je(n).subs.add(t), t), Xr = (n, t) => {
543
+ }), Ki = (n, t) => (je(n).subs.add(t), t), Yi = (n, t) => {
544
544
  const e = je(n), s = e.subs.delete(t);
545
545
  return s && e.subs.size === 0 && (e.bc.close(), Fn.delete(n)), s;
546
546
  }, ht = (n, t, e = null) => {
547
547
  const s = je(n);
548
- s.bc.postMessage(t), s.subs.forEach((r) => r(t, e));
548
+ s.bc.postMessage(t), s.subs.forEach((i) => i(t, e));
549
549
  }, st = Date.now;
550
- class Ye {
550
+ class Ke {
551
551
  constructor() {
552
552
  this._observers = T();
553
553
  }
@@ -556,15 +556,15 @@ class Ye {
556
556
  * @param {function} f
557
557
  */
558
558
  on(t, e) {
559
- Y(this._observers, t, nt).add(e);
559
+ K(this._observers, t, nt).add(e);
560
560
  }
561
561
  /**
562
562
  * @param {N} name
563
563
  * @param {function} f
564
564
  */
565
565
  once(t, e) {
566
- const s = (...r) => {
567
- this.off(t, s), e(...r);
566
+ const s = (...i) => {
567
+ this.off(t, s), e(...i);
568
568
  };
569
569
  this.on(t, s);
570
570
  }
@@ -586,13 +586,13 @@ class Ye {
586
586
  * @param {Array<any>} args The arguments that are applied to the event listener.
587
587
  */
588
588
  emit(t, e) {
589
- return K((this._observers.get(t) || T()).values()).forEach((s) => s(...e));
589
+ return z((this._observers.get(t) || T()).values()).forEach((s) => s(...e));
590
590
  }
591
591
  destroy() {
592
592
  this._observers = T();
593
593
  }
594
594
  }
595
- const Jr = crypto.getRandomValues.bind(crypto), $n = () => Jr(new Uint32Array(1))[0], Gr = [1e7] + -1e3 + -4e3 + -8e3 + -1e11, Wr = () => Gr.replace(
595
+ const Xi = crypto.getRandomValues.bind(crypto), $n = () => Xi(new Uint32Array(1))[0], Ji = [1e7] + -1e3 + -4e3 + -8e3 + -1e11, Gi = () => Ji.replace(
596
596
  /[018]/g,
597
597
  /** @param {number} c */
598
598
  (n) => (n ^ $n() & 15 >> n / 4).toString(16)
@@ -601,7 +601,7 @@ const Jr = crypto.getRandomValues.bind(crypto), $n = () => Jr(new Uint32Array(1)
601
601
  new Promise(n)
602
602
  );
603
603
  Promise.all.bind(Promise);
604
- class zr {
604
+ class Wi {
605
605
  /**
606
606
  * @param {L} left
607
607
  * @param {R} right
@@ -610,9 +610,9 @@ class zr {
610
610
  this.left = t, this.right = e;
611
611
  }
612
612
  }
613
- const F = (n, t) => new zr(n, t);
613
+ const F = (n, t) => new Wi(n, t);
614
614
  typeof DOMParser < "u" && new DOMParser();
615
- const Kr = (n) => Vs(n, (t, e) => `${e}:${t};`).join(""), X = Symbol, jn = X(), Yn = X(), qr = X(), Qr = X(), Zr = X(), Xn = X(), Pr = X(), Jn = X(), ti = X(), ei = (n) => {
615
+ const zi = (n) => Vs(n, (t, e) => `${e}:${t};`).join(""), Y = Symbol, jn = Y(), Kn = Y(), qi = Y(), Qi = Y(), Zi = Y(), Yn = Y(), Pi = Y(), Xn = Y(), tr = Y(), er = (n) => {
616
616
  const t = [];
617
617
  let e = 0;
618
618
  for (; e < n.length; e++) {
@@ -620,38 +620,38 @@ const Kr = (n) => Vs(n, (t, e) => `${e}:${t};`).join(""), X = Symbol, jn = X(),
620
620
  s.constructor === String || s.constructor === Number || s.constructor === Object && t.push(JSON.stringify(s));
621
621
  }
622
622
  return t;
623
- }, ni = {
623
+ }, nr = {
624
624
  [jn]: F("font-weight", "bold"),
625
- [Yn]: F("font-weight", "normal"),
626
- [qr]: F("color", "blue"),
627
- [Zr]: F("color", "green"),
628
- [Qr]: F("color", "grey"),
629
- [Xn]: F("color", "red"),
630
- [Pr]: F("color", "purple"),
631
- [Jn]: F("color", "orange"),
625
+ [Kn]: F("font-weight", "normal"),
626
+ [qi]: F("color", "blue"),
627
+ [Zi]: F("color", "green"),
628
+ [Qi]: F("color", "grey"),
629
+ [Yn]: F("color", "red"),
630
+ [Pi]: F("color", "purple"),
631
+ [Xn]: F("color", "orange"),
632
632
  // not well supported in chrome when debugging node with inspector - TODO: deprecate
633
- [ti]: F("color", "black")
634
- }, si = (n) => {
633
+ [tr]: F("color", "black")
634
+ }, sr = (n) => {
635
635
  const t = [], e = [], s = T();
636
- let r = [], i = 0;
637
- for (; i < n.length; i++) {
638
- const o = n[i], c = ni[o];
639
- if (c !== void 0)
640
- s.set(c.left, c.right);
636
+ let i = [], r = 0;
637
+ for (; r < n.length; r++) {
638
+ const o = n[r], l = nr[o];
639
+ if (l !== void 0)
640
+ s.set(l.left, l.right);
641
641
  else if (o.constructor === String || o.constructor === Number) {
642
- const l = Kr(s);
643
- i > 0 || l.length > 0 ? (t.push("%c" + o), e.push(l)) : t.push(o);
642
+ const c = zi(s);
643
+ r > 0 || c.length > 0 ? (t.push("%c" + o), e.push(c)) : t.push(o);
644
644
  } else
645
645
  break;
646
646
  }
647
- for (i > 0 && (r = e, r.unshift(t.join(""))); i < n.length; i++) {
648
- const o = n[i];
649
- o instanceof Symbol || r.push(o);
647
+ for (r > 0 && (i = e, i.unshift(t.join(""))); r < n.length; r++) {
648
+ const o = n[r];
649
+ o instanceof Symbol || i.push(o);
650
650
  }
651
- return r;
652
- }, ri = ur ? si : ei, ii = (...n) => {
653
- console.log(...ri(n)), oi.forEach((t) => t.print(n));
654
- }, oi = nt(), Gn = (n) => ({
651
+ return i;
652
+ }, ir = ui ? sr : er, rr = (...n) => {
653
+ console.log(...ir(n)), or.forEach((t) => t.print(n));
654
+ }, or = nt(), Jn = (n) => ({
655
655
  /**
656
656
  * @return {IterableIterator<T>}
657
657
  */
@@ -660,17 +660,17 @@ const Kr = (n) => Vs(n, (t, e) => `${e}:${t};`).join(""), X = Symbol, jn = X(),
660
660
  },
661
661
  // @ts-ignore
662
662
  next: n
663
- }), ci = (n, t) => Gn(() => {
663
+ }), lr = (n, t) => Jn(() => {
664
664
  let e;
665
665
  do
666
666
  e = n.next();
667
667
  while (!e.done && !t(e.value));
668
668
  return e;
669
- }), we = (n, t) => Gn(() => {
669
+ }), we = (n, t) => Jn(() => {
670
670
  const { done: e, value: s } = n.next();
671
671
  return { done: e, value: e ? void 0 : t(s) };
672
672
  });
673
- class Xe {
673
+ class Ye {
674
674
  /**
675
675
  * @param {number} clock
676
676
  * @param {number} len
@@ -684,140 +684,140 @@ class Rt {
684
684
  this.clients = /* @__PURE__ */ new Map();
685
685
  }
686
686
  }
687
- const Wn = (n, t, e) => t.clients.forEach((s, r) => {
688
- const i = (
687
+ const Gn = (n, t, e) => t.clients.forEach((s, i) => {
688
+ const r = (
689
689
  /** @type {Array<GC|Item>} */
690
- n.doc.store.clients.get(r)
690
+ n.doc.store.clients.get(i)
691
691
  );
692
692
  for (let o = 0; o < s.length; o++) {
693
- const c = s[o];
694
- os(n, i, c.clock, c.len, e);
693
+ const l = s[o];
694
+ os(n, r, l.clock, l.len, e);
695
695
  }
696
- }), li = (n, t) => {
696
+ }), cr = (n, t) => {
697
697
  let e = 0, s = n.length - 1;
698
698
  for (; e <= s; ) {
699
- const r = j((e + s) / 2), i = n[r], o = i.clock;
699
+ const i = j((e + s) / 2), r = n[i], o = r.clock;
700
700
  if (o <= t) {
701
- if (t < o + i.len)
702
- return r;
703
- e = r + 1;
701
+ if (t < o + r.len)
702
+ return i;
703
+ e = i + 1;
704
704
  } else
705
- s = r - 1;
705
+ s = i - 1;
706
706
  }
707
707
  return null;
708
- }, zn = (n, t) => {
708
+ }, Wn = (n, t) => {
709
709
  const e = n.clients.get(t.client);
710
- return e !== void 0 && li(e, t.clock) !== null;
711
- }, Je = (n) => {
710
+ return e !== void 0 && cr(e, t.clock) !== null;
711
+ }, Xe = (n) => {
712
712
  n.clients.forEach((t) => {
713
- t.sort((r, i) => r.clock - i.clock);
713
+ t.sort((i, r) => i.clock - r.clock);
714
714
  let e, s;
715
715
  for (e = 1, s = 1; e < t.length; e++) {
716
- const r = t[s - 1], i = t[e];
717
- r.clock + r.len >= i.clock ? r.len = ct(r.len, i.clock + i.len - r.clock) : (s < e && (t[s] = i), s++);
716
+ const i = t[s - 1], r = t[e];
717
+ i.clock + i.len >= r.clock ? i.len = lt(i.len, r.clock + r.len - i.clock) : (s < e && (t[s] = r), s++);
718
718
  }
719
719
  t.length = s;
720
720
  });
721
- }, hi = (n) => {
721
+ }, hr = (n) => {
722
722
  const t = new Rt();
723
723
  for (let e = 0; e < n.length; e++)
724
- n[e].clients.forEach((s, r) => {
725
- if (!t.clients.has(r)) {
726
- const i = s.slice();
724
+ n[e].clients.forEach((s, i) => {
725
+ if (!t.clients.has(i)) {
726
+ const r = s.slice();
727
727
  for (let o = e + 1; o < n.length; o++)
728
- Fs(i, n[o].clients.get(r) || []);
729
- t.clients.set(r, i);
728
+ Fs(r, n[o].clients.get(i) || []);
729
+ t.clients.set(i, r);
730
730
  }
731
731
  });
732
- return Je(t), t;
733
- }, Kt = (n, t, e, s) => {
734
- Y(n.clients, t, () => (
732
+ return Xe(t), t;
733
+ }, zt = (n, t, e, s) => {
734
+ K(n.clients, t, () => (
735
735
  /** @type {Array<DeleteItem>} */
736
736
  []
737
- )).push(new Xe(e, s));
738
- }, ai = () => new Rt(), ui = (n) => {
739
- const t = ai();
737
+ )).push(new Ye(e, s));
738
+ }, ar = () => new Rt(), ur = (n) => {
739
+ const t = ar();
740
740
  return n.clients.forEach((e, s) => {
741
- const r = [];
742
- for (let i = 0; i < e.length; i++) {
743
- const o = e[i];
741
+ const i = [];
742
+ for (let r = 0; r < e.length; r++) {
743
+ const o = e[r];
744
744
  if (o.deleted) {
745
- const c = o.id.clock;
746
- let l = o.length;
747
- if (i + 1 < e.length)
748
- for (let a = e[i + 1]; i + 1 < e.length && a.deleted; a = e[++i + 1])
749
- l += a.length;
750
- r.push(new Xe(c, l));
745
+ const l = o.id.clock;
746
+ let c = o.length;
747
+ if (r + 1 < e.length)
748
+ for (let a = e[r + 1]; r + 1 < e.length && a.deleted; a = e[++r + 1])
749
+ c += a.length;
750
+ i.push(new Ye(l, c));
751
751
  }
752
752
  }
753
- r.length > 0 && t.clients.set(s, r);
753
+ i.length > 0 && t.clients.set(s, i);
754
754
  }), t;
755
755
  }, kt = (n, t) => {
756
- p(n.restEncoder, t.clients.size), K(t.clients.entries()).sort((e, s) => s[0] - e[0]).forEach(([e, s]) => {
756
+ p(n.restEncoder, t.clients.size), z(t.clients.entries()).sort((e, s) => s[0] - e[0]).forEach(([e, s]) => {
757
757
  n.resetDsCurVal(), p(n.restEncoder, e);
758
- const r = s.length;
759
- p(n.restEncoder, r);
760
- for (let i = 0; i < r; i++) {
761
- const o = s[i];
758
+ const i = s.length;
759
+ p(n.restEncoder, i);
760
+ for (let r = 0; r < i; r++) {
761
+ const o = s[r];
762
762
  n.writeDsClock(o.clock), n.writeDsLen(o.len);
763
763
  }
764
764
  });
765
- }, Ge = (n) => {
765
+ }, Je = (n) => {
766
766
  const t = new Rt(), e = w(n.restDecoder);
767
767
  for (let s = 0; s < e; s++) {
768
768
  n.resetDsCurVal();
769
- const r = w(n.restDecoder), i = w(n.restDecoder);
770
- if (i > 0) {
771
- const o = Y(t.clients, r, () => (
769
+ const i = w(n.restDecoder), r = w(n.restDecoder);
770
+ if (r > 0) {
771
+ const o = K(t.clients, i, () => (
772
772
  /** @type {Array<DeleteItem>} */
773
773
  []
774
774
  ));
775
- for (let c = 0; c < i; c++)
776
- o.push(new Xe(n.readDsClock(), n.readDsLen()));
775
+ for (let l = 0; l < r; l++)
776
+ o.push(new Ye(n.readDsClock(), n.readDsLen()));
777
777
  }
778
778
  }
779
779
  return t;
780
780
  }, wn = (n, t, e) => {
781
- const s = new Rt(), r = w(n.restDecoder);
782
- for (let i = 0; i < r; i++) {
781
+ const s = new Rt(), i = w(n.restDecoder);
782
+ for (let r = 0; r < i; r++) {
783
783
  n.resetDsCurVal();
784
- const o = w(n.restDecoder), c = w(n.restDecoder), l = e.clients.get(o) || [], a = I(e, o);
785
- for (let h = 0; h < c; h++) {
784
+ const o = w(n.restDecoder), l = w(n.restDecoder), c = e.clients.get(o) || [], a = A(e, o);
785
+ for (let h = 0; h < l; h++) {
786
786
  const u = n.readDsClock(), d = u + n.readDsLen();
787
787
  if (u < a) {
788
- a < d && Kt(s, o, a, d - a);
789
- let f = V(l, u), g = l[f];
790
- for (!g.deleted && g.id.clock < u && (l.splice(f + 1, 0, ne(t, g, u - g.id.clock)), f++); f < l.length && (g = l[f++], g.id.clock < d); )
791
- g.deleted || (d < g.id.clock + g.length && l.splice(f, 0, ne(t, g, d - g.id.clock)), g.delete(t));
788
+ a < d && zt(s, o, a, d - a);
789
+ let f = V(c, u), g = c[f];
790
+ for (!g.deleted && g.id.clock < u && (c.splice(f + 1, 0, ne(t, g, u - g.id.clock)), f++); f < c.length && (g = c[f++], g.id.clock < d); )
791
+ g.deleted || (d < g.id.clock + g.length && c.splice(f, 0, ne(t, g, d - g.id.clock)), g.delete(t));
792
792
  } else
793
- Kt(s, o, u, d - u);
793
+ zt(s, o, u, d - u);
794
794
  }
795
795
  }
796
796
  if (s.clients.size > 0) {
797
- const i = new rt();
798
- return p(i.restEncoder, 0), kt(i, s), i.toUint8Array();
797
+ const r = new it();
798
+ return p(r.restEncoder, 0), kt(r, s), r.toUint8Array();
799
799
  }
800
800
  return null;
801
- }, Kn = $n;
802
- class bt extends Ye {
801
+ }, zn = $n;
802
+ class bt extends Ke {
803
803
  /**
804
804
  * @param {DocOpts} opts configuration
805
805
  */
806
- constructor({ guid: t = Wr(), collectionid: e = null, gc: s = !0, gcFilter: r = () => !0, meta: i = null, autoLoad: o = !1, shouldLoad: c = !0 } = {}) {
807
- super(), this.gc = s, this.gcFilter = r, this.clientID = Kn(), this.guid = t, this.collectionid = e, this.share = /* @__PURE__ */ new Map(), this.store = new rs(), this._transaction = null, this._transactionCleanups = [], this.subdocs = /* @__PURE__ */ new Set(), this._item = null, this.shouldLoad = c, this.autoLoad = o, this.meta = i, this.isLoaded = !1, this.isSynced = !1, this.whenLoaded = pn((a) => {
806
+ constructor({ guid: t = Gi(), collectionid: e = null, gc: s = !0, gcFilter: i = () => !0, meta: r = null, autoLoad: o = !1, shouldLoad: l = !0 } = {}) {
807
+ super(), this.gc = s, this.gcFilter = i, this.clientID = zn(), this.guid = t, this.collectionid = e, this.share = /* @__PURE__ */ new Map(), this.store = new is(), this._transaction = null, this._transactionCleanups = [], this.subdocs = /* @__PURE__ */ new Set(), this._item = null, this.shouldLoad = l, this.autoLoad = o, this.meta = r, this.isLoaded = !1, this.isSynced = !1, this.whenLoaded = pn((a) => {
808
808
  this.on("load", () => {
809
809
  this.isLoaded = !0, a(this);
810
810
  });
811
811
  });
812
- const l = () => pn((a) => {
812
+ const c = () => pn((a) => {
813
813
  const h = (u) => {
814
814
  (u === void 0 || u === !0) && (this.off("sync", h), a());
815
815
  };
816
816
  this.on("sync", h);
817
817
  });
818
818
  this.on("sync", (a) => {
819
- a === !1 && this.isSynced && (this.whenSynced = l()), this.isSynced = a === void 0 || a === !0, this.isLoaded || this.emit("load", []);
820
- }), this.whenSynced = l();
819
+ a === !1 && this.isSynced && (this.whenSynced = c()), this.isSynced = a === void 0 || a === !0, this.isLoaded || this.emit("load", []);
820
+ }), this.whenSynced = c();
821
821
  }
822
822
  /**
823
823
  * Notify the parent document that you request to load data into this subdocument (if it is a subdocument).
@@ -842,7 +842,7 @@ class bt extends Ye {
842
842
  return this.subdocs;
843
843
  }
844
844
  getSubdocGuids() {
845
- return new Set(K(this.subdocs).map((t) => t.guid));
845
+ return new Set(z(this.subdocs).map((t) => t.guid));
846
846
  }
847
847
  /**
848
848
  * Changes that happen inside of a transaction are bundled. This means that
@@ -886,24 +886,24 @@ class bt extends Ye {
886
886
  *
887
887
  * @public
888
888
  */
889
- get(t, e = A) {
890
- const s = Y(this.share, t, () => {
891
- const i = new e();
892
- return i._integrate(this, null), i;
893
- }), r = s.constructor;
894
- if (e !== A && r !== e)
895
- if (r === A) {
896
- const i = new e();
897
- i._map = s._map, s._map.forEach(
889
+ get(t, e = I) {
890
+ const s = K(this.share, t, () => {
891
+ const r = new e();
892
+ return r._integrate(this, null), r;
893
+ }), i = s.constructor;
894
+ if (e !== I && i !== e)
895
+ if (i === I) {
896
+ const r = new e();
897
+ r._map = s._map, s._map.forEach(
898
898
  /** @param {Item?} n */
899
899
  (o) => {
900
900
  for (; o !== null; o = o.left)
901
- o.parent = i;
901
+ o.parent = r;
902
902
  }
903
- ), i._start = s._start;
904
- for (let o = i._start; o !== null; o = o.right)
905
- o.parent = i;
906
- return i._length = s._length, this.share.set(t, i), i._integrate(this, null), i;
903
+ ), r._start = s._start;
904
+ for (let o = r._start; o !== null; o = o.right)
905
+ o.parent = r;
906
+ return r._length = s._length, this.share.set(t, r), r._integrate(this, null), r;
907
907
  } else
908
908
  throw new Error(`Type with the name ${t} has already been defined with a different constructor`);
909
909
  return s;
@@ -944,7 +944,7 @@ class bt extends Ye {
944
944
  * @public
945
945
  */
946
946
  getXmlFragment(t = "") {
947
- return this.get(t, it);
947
+ return this.get(t, rt);
948
948
  }
949
949
  /**
950
950
  * Converts the entire document into a js object, recursively traversing each yjs type
@@ -964,7 +964,7 @@ class bt extends Ye {
964
964
  * Emit `destroy` event and unregister all event handlers.
965
965
  */
966
966
  destroy() {
967
- K(this.subdocs).forEach((e) => e.destroy());
967
+ z(this.subdocs).forEach((e) => e.destroy());
968
968
  const t = this._item;
969
969
  if (t !== null) {
970
970
  this._item = null;
@@ -976,8 +976,8 @@ class bt extends Ye {
976
976
  /** @type {any} */
977
977
  t.parent.doc,
978
978
  (s) => {
979
- const r = e.doc;
980
- t.deleted || s.subdocsAdded.add(r), s.subdocsRemoved.add(this);
979
+ const i = e.doc;
980
+ t.deleted || s.subdocsAdded.add(i), s.subdocsRemoved.add(this);
981
981
  },
982
982
  null,
983
983
  !0
@@ -1052,7 +1052,7 @@ class Qn extends qn {
1052
1052
  * @return {string}
1053
1053
  */
1054
1054
  readString() {
1055
- return z(this.restDecoder);
1055
+ return W(this.restDecoder);
1056
1056
  }
1057
1057
  /**
1058
1058
  * @return {boolean} isKey
@@ -1084,7 +1084,7 @@ class Qn extends qn {
1084
1084
  * @return {Uint8Array}
1085
1085
  */
1086
1086
  readBuf() {
1087
- return Fr(L(this.restDecoder));
1087
+ return Fi(L(this.restDecoder));
1088
1088
  }
1089
1089
  /**
1090
1090
  * Legacy implementation uses JSON parse. We use any-decoding in v2.
@@ -1092,16 +1092,16 @@ class Qn extends qn {
1092
1092
  * @return {any}
1093
1093
  */
1094
1094
  readJSON() {
1095
- return JSON.parse(z(this.restDecoder));
1095
+ return JSON.parse(W(this.restDecoder));
1096
1096
  }
1097
1097
  /**
1098
1098
  * @return {string}
1099
1099
  */
1100
1100
  readKey() {
1101
- return z(this.restDecoder);
1101
+ return W(this.restDecoder);
1102
1102
  }
1103
1103
  }
1104
- class di {
1104
+ class dr {
1105
1105
  /**
1106
1106
  * @param {decoding.Decoder} decoder
1107
1107
  */
@@ -1125,12 +1125,12 @@ class di {
1125
1125
  return this.dsCurrVal += t, t;
1126
1126
  }
1127
1127
  }
1128
- class pt extends di {
1128
+ class pt extends dr {
1129
1129
  /**
1130
1130
  * @param {decoding.Decoder} decoder
1131
1131
  */
1132
1132
  constructor(t) {
1133
- super(t), this.keys = [], w(t), this.keyClockDecoder = new pe(L(t)), this.clientDecoder = new Jt(L(t)), this.leftClockDecoder = new pe(L(t)), this.rightClockDecoder = new pe(L(t)), this.infoDecoder = new gn(L(t), gt), this.stringDecoder = new vr(L(t)), this.parentInfoDecoder = new gn(L(t), gt), this.typeRefDecoder = new Jt(L(t)), this.lenDecoder = new Jt(L(t));
1133
+ super(t), this.keys = [], w(t), this.keyClockDecoder = new pe(L(t)), this.clientDecoder = new Xt(L(t)), this.leftClockDecoder = new pe(L(t)), this.rightClockDecoder = new pe(L(t)), this.infoDecoder = new gn(L(t), gt), this.stringDecoder = new vi(L(t)), this.parentInfoDecoder = new gn(L(t), gt), this.typeRefDecoder = new Xt(L(t)), this.lenDecoder = new Xt(L(t));
1134
1134
  }
1135
1135
  /**
1136
1136
  * @return {ID}
@@ -1267,7 +1267,7 @@ class Nt extends Zn {
1267
1267
  * @param {number} info An unsigned 8-bit integer
1268
1268
  */
1269
1269
  writeInfo(t) {
1270
- Ae(this.restEncoder, t);
1270
+ Ie(this.restEncoder, t);
1271
1271
  }
1272
1272
  /**
1273
1273
  * @param {string} s
@@ -1344,13 +1344,13 @@ class Pn {
1344
1344
  t === 0 && H(), p(this.restEncoder, t - 1), this.dsCurrVal += t;
1345
1345
  }
1346
1346
  }
1347
- class rt extends Pn {
1347
+ class it extends Pn {
1348
1348
  constructor() {
1349
- super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new ge(), this.clientEncoder = new Xt(), this.leftClockEncoder = new ge(), this.rightClockEncoder = new ge(), this.infoEncoder = new un(Ae), this.stringEncoder = new Cr(), this.parentInfoEncoder = new un(Ae), this.typeRefEncoder = new Xt(), this.lenEncoder = new Xt();
1349
+ super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new ge(), this.clientEncoder = new Yt(), this.leftClockEncoder = new ge(), this.rightClockEncoder = new ge(), this.infoEncoder = new un(Ie), this.stringEncoder = new Ci(), this.parentInfoEncoder = new un(Ie), this.typeRefEncoder = new Yt(), this.lenEncoder = new Yt();
1350
1350
  }
1351
1351
  toUint8Array() {
1352
1352
  const t = x();
1353
- return p(t, 0), S(t, this.keyClockEncoder.toUint8Array()), S(t, this.clientEncoder.toUint8Array()), S(t, this.leftClockEncoder.toUint8Array()), S(t, this.rightClockEncoder.toUint8Array()), S(t, _(this.infoEncoder)), S(t, this.stringEncoder.toUint8Array()), S(t, _(this.parentInfoEncoder)), S(t, this.typeRefEncoder.toUint8Array()), S(t, this.lenEncoder.toUint8Array()), re(t, _(this.restEncoder)), _(t);
1353
+ return p(t, 0), S(t, this.keyClockEncoder.toUint8Array()), S(t, this.clientEncoder.toUint8Array()), S(t, this.leftClockEncoder.toUint8Array()), S(t, this.rightClockEncoder.toUint8Array()), S(t, _(this.infoEncoder)), S(t, this.stringEncoder.toUint8Array()), S(t, _(this.parentInfoEncoder)), S(t, this.typeRefEncoder.toUint8Array()), S(t, this.lenEncoder.toUint8Array()), ie(t, _(this.restEncoder)), _(t);
1354
1354
  }
1355
1355
  /**
1356
1356
  * @param {ID} id
@@ -1437,51 +1437,51 @@ class rt extends Pn {
1437
1437
  e === void 0 ? (this.keyClockEncoder.write(this.keyClock++), this.stringEncoder.write(t)) : this.keyClockEncoder.write(e);
1438
1438
  }
1439
1439
  }
1440
- const fi = (n, t, e, s) => {
1441
- s = ct(s, t[0].id.clock);
1442
- const r = V(t, s);
1443
- p(n.restEncoder, t.length - r), n.writeClient(e), p(n.restEncoder, s);
1444
- const i = t[r];
1445
- i.write(n, s - i.id.clock);
1446
- for (let o = r + 1; o < t.length; o++)
1440
+ const fr = (n, t, e, s) => {
1441
+ s = lt(s, t[0].id.clock);
1442
+ const i = V(t, s);
1443
+ p(n.restEncoder, t.length - i), n.writeClient(e), p(n.restEncoder, s);
1444
+ const r = t[i];
1445
+ r.write(n, s - r.id.clock);
1446
+ for (let o = i + 1; o < t.length; o++)
1447
1447
  t[o].write(n, 0);
1448
- }, We = (n, t, e) => {
1448
+ }, Ge = (n, t, e) => {
1449
1449
  const s = /* @__PURE__ */ new Map();
1450
- e.forEach((r, i) => {
1451
- I(t, i) > r && s.set(i, r);
1452
- }), oe(t).forEach((r, i) => {
1453
- e.has(i) || s.set(i, 0);
1454
- }), p(n.restEncoder, s.size), K(s.entries()).sort((r, i) => i[0] - r[0]).forEach(([r, i]) => {
1455
- fi(
1450
+ e.forEach((i, r) => {
1451
+ A(t, r) > i && s.set(r, i);
1452
+ }), oe(t).forEach((i, r) => {
1453
+ e.has(r) || s.set(r, 0);
1454
+ }), p(n.restEncoder, s.size), z(s.entries()).sort((i, r) => r[0] - i[0]).forEach(([i, r]) => {
1455
+ fr(
1456
1456
  n,
1457
1457
  /** @type {Array<GC|Item>} */
1458
- t.clients.get(r),
1459
- r,
1460
- i
1458
+ t.clients.get(i),
1459
+ i,
1460
+ r
1461
1461
  );
1462
1462
  });
1463
- }, gi = (n, t) => {
1463
+ }, gr = (n, t) => {
1464
1464
  const e = T(), s = w(n.restDecoder);
1465
- for (let r = 0; r < s; r++) {
1466
- const i = w(n.restDecoder), o = new Array(i), c = n.readClient();
1467
- let l = w(n.restDecoder);
1468
- e.set(c, { i: 0, refs: o });
1469
- for (let a = 0; a < i; a++) {
1465
+ for (let i = 0; i < s; i++) {
1466
+ const r = w(n.restDecoder), o = new Array(r), l = n.readClient();
1467
+ let c = w(n.restDecoder);
1468
+ e.set(l, { i: 0, refs: o });
1469
+ for (let a = 0; a < r; a++) {
1470
1470
  const h = n.readInfo();
1471
1471
  switch (se & h) {
1472
1472
  case 0: {
1473
1473
  const u = n.readLen();
1474
- o[a] = new U(k(c, l), u), l += u;
1474
+ o[a] = new U(k(l, c), u), c += u;
1475
1475
  break;
1476
1476
  }
1477
1477
  case 10: {
1478
1478
  const u = w(n.restDecoder);
1479
- o[a] = new v(k(c, l), u), l += u;
1479
+ o[a] = new v(k(l, c), u), c += u;
1480
1480
  break;
1481
1481
  }
1482
1482
  default: {
1483
1483
  const u = (h & ($ | M)) === 0, d = new C(
1484
- k(c, l),
1484
+ k(l, c),
1485
1485
  null,
1486
1486
  // leftd
1487
1487
  (h & M) === M ? n.readLeftID() : null,
@@ -1492,43 +1492,43 @@ const fi = (n, t, e, s) => {
1492
1492
  // right origin
1493
1493
  u ? n.readParentInfo() ? t.get(n.readString()) : n.readLeftID() : null,
1494
1494
  // parent
1495
- u && (h & At) === At ? n.readString() : null,
1495
+ u && (h & It) === It ? n.readString() : null,
1496
1496
  // parentSub
1497
1497
  Es(n, h)
1498
1498
  // item content
1499
1499
  );
1500
- o[a] = d, l += d.length;
1500
+ o[a] = d, c += d.length;
1501
1501
  }
1502
1502
  }
1503
1503
  }
1504
1504
  }
1505
1505
  return e;
1506
- }, pi = (n, t, e) => {
1506
+ }, pr = (n, t, e) => {
1507
1507
  const s = [];
1508
- let r = K(e.keys()).sort((f, g) => f - g);
1509
- if (r.length === 0)
1508
+ let i = z(e.keys()).sort((f, g) => f - g);
1509
+ if (i.length === 0)
1510
1510
  return null;
1511
- const i = () => {
1512
- if (r.length === 0)
1511
+ const r = () => {
1512
+ if (i.length === 0)
1513
1513
  return null;
1514
1514
  let f = (
1515
1515
  /** @type {{i:number,refs:Array<GC|Item>}} */
1516
- e.get(r[r.length - 1])
1516
+ e.get(i[i.length - 1])
1517
1517
  );
1518
1518
  for (; f.refs.length === f.i; )
1519
- if (r.pop(), r.length > 0)
1519
+ if (i.pop(), i.length > 0)
1520
1520
  f = /** @type {{i:number,refs:Array<GC|Item>}} */
1521
- e.get(r[r.length - 1]);
1521
+ e.get(i[i.length - 1]);
1522
1522
  else
1523
1523
  return null;
1524
1524
  return f;
1525
1525
  };
1526
- let o = i();
1526
+ let o = r();
1527
1527
  if (o === null && s.length === 0)
1528
1528
  return null;
1529
- const c = new rs(), l = /* @__PURE__ */ new Map(), a = (f, g) => {
1530
- const y = l.get(f);
1531
- (y == null || y > g) && l.set(f, g);
1529
+ const l = new is(), c = /* @__PURE__ */ new Map(), a = (f, g) => {
1530
+ const y = c.get(f);
1531
+ (y == null || y > g) && c.set(f, g);
1532
1532
  };
1533
1533
  let h = (
1534
1534
  /** @type {any} */
@@ -1540,13 +1540,13 @@ const fi = (n, t, e, s) => {
1540
1540
  const u = /* @__PURE__ */ new Map(), d = () => {
1541
1541
  for (const f of s) {
1542
1542
  const g = f.id.client, y = e.get(g);
1543
- y ? (y.i--, c.clients.set(g, y.refs.slice(y.i)), e.delete(g), y.i = 0, y.refs = []) : c.clients.set(g, [f]), r = r.filter((O) => O !== g);
1543
+ y ? (y.i--, l.clients.set(g, y.refs.slice(y.i)), e.delete(g), y.i = 0, y.refs = []) : l.clients.set(g, [f]), i = i.filter((O) => O !== g);
1544
1544
  }
1545
1545
  s.length = 0;
1546
1546
  };
1547
1547
  for (; ; ) {
1548
1548
  if (h.constructor !== v) {
1549
- const g = Y(u, h.id.client, () => I(t, h.id.client)) - h.id.clock;
1549
+ const g = K(u, h.id.client, () => A(t, h.id.client)) - h.id.clock;
1550
1550
  if (g < 0)
1551
1551
  s.push(h), a(h.id.client, h.id.clock - 1), d();
1552
1552
  else {
@@ -1561,7 +1561,7 @@ const fi = (n, t, e, s) => {
1561
1561
  a(
1562
1562
  /** @type {number} */
1563
1563
  y,
1564
- I(t, y)
1564
+ A(t, y)
1565
1565
  ), d();
1566
1566
  else {
1567
1567
  h = O.refs[O.i++];
@@ -1578,25 +1578,25 @@ const fi = (n, t, e, s) => {
1578
1578
  h = /** @type {GC|Item} */
1579
1579
  o.refs[o.i++];
1580
1580
  else {
1581
- if (o = i(), o === null)
1581
+ if (o = r(), o === null)
1582
1582
  break;
1583
1583
  h = /** @type {GC|Item} */
1584
1584
  o.refs[o.i++];
1585
1585
  }
1586
1586
  }
1587
- if (c.clients.size > 0) {
1588
- const f = new rt();
1589
- return We(f, c, /* @__PURE__ */ new Map()), p(f.restEncoder, 0), { missing: l, update: f.toUint8Array() };
1587
+ if (l.clients.size > 0) {
1588
+ const f = new it();
1589
+ return Ge(f, l, /* @__PURE__ */ new Map()), p(f.restEncoder, 0), { missing: c, update: f.toUint8Array() };
1590
1590
  }
1591
1591
  return null;
1592
- }, wi = (n, t) => We(n, t.doc.store, t.beforeState), mi = (n, t, e, s = new pt(n)) => b(t, (r) => {
1593
- r.local = !1;
1594
- let i = !1;
1595
- const o = r.doc, c = o.store, l = gi(s, o), a = pi(r, c, l), h = c.pendingStructs;
1592
+ }, wr = (n, t) => Ge(n, t.doc.store, t.beforeState), mr = (n, t, e, s = new pt(n)) => b(t, (i) => {
1593
+ i.local = !1;
1594
+ let r = !1;
1595
+ const o = i.doc, l = o.store, c = gr(s, o), a = pr(i, l, c), h = l.pendingStructs;
1596
1596
  if (h) {
1597
1597
  for (const [d, f] of h.missing)
1598
- if (f < I(c, d)) {
1599
- i = !0;
1598
+ if (f < A(l, d)) {
1599
+ r = !0;
1600
1600
  break;
1601
1601
  }
1602
1602
  if (a) {
@@ -1607,56 +1607,56 @@ const fi = (n, t, e, s) => {
1607
1607
  h.update = qt([h.update, a.update]);
1608
1608
  }
1609
1609
  } else
1610
- c.pendingStructs = a;
1611
- const u = wn(s, r, c);
1612
- if (c.pendingDs) {
1613
- const d = new pt(Q(c.pendingDs));
1610
+ l.pendingStructs = a;
1611
+ const u = wn(s, i, l);
1612
+ if (l.pendingDs) {
1613
+ const d = new pt(Q(l.pendingDs));
1614
1614
  w(d.restDecoder);
1615
- const f = wn(d, r, c);
1616
- u && f ? c.pendingDs = qt([u, f]) : c.pendingDs = u || f;
1615
+ const f = wn(d, i, l);
1616
+ u && f ? l.pendingDs = qt([u, f]) : l.pendingDs = u || f;
1617
1617
  } else
1618
- c.pendingDs = u;
1619
- if (i) {
1618
+ l.pendingDs = u;
1619
+ if (r) {
1620
1620
  const d = (
1621
1621
  /** @type {{update: Uint8Array}} */
1622
- c.pendingStructs.update
1622
+ l.pendingStructs.update
1623
1623
  );
1624
- c.pendingStructs = null, ts(r.doc, d);
1624
+ l.pendingStructs = null, ts(i.doc, d);
1625
1625
  }
1626
1626
  }, e, !1), ts = (n, t, e, s = pt) => {
1627
- const r = Q(t);
1628
- mi(r, n, e, new s(r));
1629
- }, yi = (n, t, e) => ts(n, t, e, Qn), ki = (n, t, e = /* @__PURE__ */ new Map()) => {
1630
- We(n, t.store, e), kt(n, ui(t.store));
1631
- }, bi = (n, t = new Uint8Array([0]), e = new rt()) => {
1627
+ const i = Q(t);
1628
+ mr(i, n, e, new s(i));
1629
+ }, yr = (n, t, e) => ts(n, t, e, Qn), kr = (n, t, e = /* @__PURE__ */ new Map()) => {
1630
+ Ge(n, t.store, e), kt(n, ur(t.store));
1631
+ }, br = (n, t = new Uint8Array([0]), e = new it()) => {
1632
1632
  const s = es(t);
1633
- ki(e, n, s);
1634
- const r = [e.toUint8Array()];
1635
- if (n.store.pendingDs && r.push(n.store.pendingDs), n.store.pendingStructs && r.push(Ni(n.store.pendingStructs.update, t)), r.length > 1) {
1633
+ kr(e, n, s);
1634
+ const i = [e.toUint8Array()];
1635
+ if (n.store.pendingDs && i.push(n.store.pendingDs), n.store.pendingStructs && i.push(Nr(n.store.pendingStructs.update, t)), i.length > 1) {
1636
1636
  if (e.constructor === Nt)
1637
- return Ti(r.map((i, o) => o === 0 ? i : Vi(i)));
1638
- if (e.constructor === rt)
1639
- return qt(r);
1637
+ return Tr(i.map((r, o) => o === 0 ? r : Vr(r)));
1638
+ if (e.constructor === it)
1639
+ return qt(i);
1640
1640
  }
1641
- return r[0];
1642
- }, _i = (n, t) => bi(n, t, new Nt()), Si = (n) => {
1641
+ return i[0];
1642
+ }, _r = (n, t) => br(n, t, new Nt()), Sr = (n) => {
1643
1643
  const t = /* @__PURE__ */ new Map(), e = w(n.restDecoder);
1644
1644
  for (let s = 0; s < e; s++) {
1645
- const r = w(n.restDecoder), i = w(n.restDecoder);
1646
- t.set(r, i);
1645
+ const i = w(n.restDecoder), r = w(n.restDecoder);
1646
+ t.set(i, r);
1647
1647
  }
1648
1648
  return t;
1649
- }, es = (n) => Si(new qn(Q(n))), ns = (n, t) => (p(n.restEncoder, t.size), K(t.entries()).sort((e, s) => s[0] - e[0]).forEach(([e, s]) => {
1649
+ }, es = (n) => Sr(new qn(Q(n))), ns = (n, t) => (p(n.restEncoder, t.size), z(t.entries()).sort((e, s) => s[0] - e[0]).forEach(([e, s]) => {
1650
1650
  p(n.restEncoder, e), p(n.restEncoder, s);
1651
- }), n), Ci = (n, t) => ns(n, oe(t.store)), Di = (n, t = new Pn()) => (n instanceof Map ? ns(t, n) : Ci(t, n), t.toUint8Array()), Ei = (n) => Di(n, new Zn());
1652
- class Ii {
1651
+ }), n), Cr = (n, t) => ns(n, oe(t.store)), Dr = (n, t = new Pn()) => (n instanceof Map ? ns(t, n) : Cr(t, n), t.toUint8Array()), Er = (n) => Dr(n, new Zn());
1652
+ class Ar {
1653
1653
  constructor() {
1654
1654
  this.l = [];
1655
1655
  }
1656
1656
  }
1657
- const mn = () => new Ii(), yn = (n, t) => n.l.push(t), kn = (n, t) => {
1657
+ const mn = () => new Ar(), yn = (n, t) => n.l.push(t), kn = (n, t) => {
1658
1658
  const e = n.l, s = e.length;
1659
- n.l = e.filter((r) => t !== r), s === n.l.length && console.error("[yjs] Tried to remove event handler that doesn't exist.");
1659
+ n.l = e.filter((i) => t !== i), s === n.l.length && console.error("[yjs] Tried to remove event handler that doesn't exist.");
1660
1660
  }, ss = (n, t, e) => Te(n.l, [t, e]);
1661
1661
  class at {
1662
1662
  /**
@@ -1667,19 +1667,19 @@ class at {
1667
1667
  this.client = t, this.clock = e;
1668
1668
  }
1669
1669
  }
1670
- const Ft = (n, t) => n === t || n !== null && t !== null && n.client === t.client && n.clock === t.clock, k = (n, t) => new at(n, t), Ai = (n) => {
1670
+ const Ft = (n, t) => n === t || n !== null && t !== null && n.client === t.client && n.clock === t.clock, k = (n, t) => new at(n, t), Ir = (n) => {
1671
1671
  for (const [t, e] of n.doc.share.entries())
1672
1672
  if (e === n)
1673
1673
  return t;
1674
1674
  throw H();
1675
- }, St = (n, t) => t === void 0 ? !n.deleted : t.sv.has(n.id.client) && (t.sv.get(n.id.client) || 0) > n.id.clock && !zn(t.ds, n.id), xe = (n, t) => {
1676
- const e = Y(n.meta, xe, nt), s = n.doc.store;
1677
- e.has(t) || (t.sv.forEach((r, i) => {
1678
- r < I(s, i) && q(n, k(i, r));
1679
- }), Wn(n, t.ds, (r) => {
1675
+ }, St = (n, t) => t === void 0 ? !n.deleted : t.sv.has(n.id.client) && (t.sv.get(n.id.client) || 0) > n.id.clock && !Wn(t.ds, n.id), xe = (n, t) => {
1676
+ const e = K(n.meta, xe, nt), s = n.doc.store;
1677
+ e.has(t) || (t.sv.forEach((i, r) => {
1678
+ i < A(s, r) && q(n, k(r, i));
1679
+ }), Gn(n, t.ds, (i) => {
1680
1680
  }), e.add(t));
1681
1681
  };
1682
- class rs {
1682
+ class is {
1683
1683
  constructor() {
1684
1684
  this.clients = /* @__PURE__ */ new Map(), this.pendingStructs = null, this.pendingDs = null;
1685
1685
  }
@@ -1687,16 +1687,16 @@ class rs {
1687
1687
  const oe = (n) => {
1688
1688
  const t = /* @__PURE__ */ new Map();
1689
1689
  return n.clients.forEach((e, s) => {
1690
- const r = e[e.length - 1];
1691
- t.set(s, r.id.clock + r.length);
1690
+ const i = e[e.length - 1];
1691
+ t.set(s, i.id.clock + i.length);
1692
1692
  }), t;
1693
- }, I = (n, t) => {
1693
+ }, A = (n, t) => {
1694
1694
  const e = n.clients.get(t);
1695
1695
  if (e === void 0)
1696
1696
  return 0;
1697
1697
  const s = e[e.length - 1];
1698
1698
  return s.id.clock + s.length;
1699
- }, is = (n, t) => {
1699
+ }, rs = (n, t) => {
1700
1700
  let e = n.clients.get(t.id.client);
1701
1701
  if (e === void 0)
1702
1702
  e = [], n.clients.set(t.id.client, e);
@@ -1707,13 +1707,13 @@ const oe = (n) => {
1707
1707
  }
1708
1708
  e.push(t);
1709
1709
  }, V = (n, t) => {
1710
- let e = 0, s = n.length - 1, r = n[s], i = r.id.clock;
1711
- if (i === t)
1710
+ let e = 0, s = n.length - 1, i = n[s], r = i.id.clock;
1711
+ if (r === t)
1712
1712
  return s;
1713
- let o = j(t / (i + r.length - 1) * s);
1713
+ let o = j(t / (r + i.length - 1) * s);
1714
1714
  for (; e <= s; ) {
1715
- if (r = n[o], i = r.id.clock, i <= t) {
1716
- if (t < i + r.length)
1715
+ if (i = n[o], r = i.id.clock, r <= t) {
1716
+ if (t < r + i.length)
1717
1717
  return o;
1718
1718
  e = o + 1;
1719
1719
  } else
@@ -1721,15 +1721,15 @@ const oe = (n) => {
1721
1721
  o = j((e + s) / 2);
1722
1722
  }
1723
1723
  throw H();
1724
- }, Li = (n, t) => {
1724
+ }, Lr = (n, t) => {
1725
1725
  const e = n.clients.get(t.client);
1726
1726
  return e[V(e, t.clock)];
1727
1727
  }, me = (
1728
1728
  /** @type {function(StructStore,ID):Item} */
1729
- Li
1729
+ Lr
1730
1730
  ), Me = (n, t, e) => {
1731
- const s = V(t, e), r = t[s];
1732
- return r.id.clock < e && r instanceof C ? (t.splice(s + 1, 0, ne(n, r, e - r.id.clock)), s + 1) : s;
1731
+ const s = V(t, e), i = t[s];
1732
+ return i.id.clock < e && i instanceof C ? (t.splice(s + 1, 0, ne(n, i, e - i.id.clock)), s + 1) : s;
1733
1733
  }, q = (n, t) => {
1734
1734
  const e = (
1735
1735
  /** @type {Array<Item>} */
@@ -1737,24 +1737,24 @@ const oe = (n) => {
1737
1737
  );
1738
1738
  return e[Me(n, e, t.clock)];
1739
1739
  }, bn = (n, t, e) => {
1740
- const s = t.clients.get(e.client), r = V(s, e.clock), i = s[r];
1741
- return e.clock !== i.id.clock + i.length - 1 && i.constructor !== U && s.splice(r + 1, 0, ne(n, i, e.clock - i.id.clock + 1)), i;
1742
- }, xi = (n, t, e) => {
1740
+ const s = t.clients.get(e.client), i = V(s, e.clock), r = s[i];
1741
+ return e.clock !== r.id.clock + r.length - 1 && r.constructor !== U && s.splice(i + 1, 0, ne(n, r, e.clock - r.id.clock + 1)), r;
1742
+ }, xr = (n, t, e) => {
1743
1743
  const s = (
1744
1744
  /** @type {Array<GC|Item>} */
1745
1745
  n.clients.get(t.id.client)
1746
1746
  );
1747
1747
  s[V(s, t.id.clock)] = e;
1748
- }, os = (n, t, e, s, r) => {
1748
+ }, os = (n, t, e, s, i) => {
1749
1749
  if (s === 0)
1750
1750
  return;
1751
- const i = e + s;
1752
- let o = Me(n, t, e), c;
1751
+ const r = e + s;
1752
+ let o = Me(n, t, e), l;
1753
1753
  do
1754
- c = t[o++], i < c.id.clock + c.length && Me(n, t, i), r(c);
1755
- while (o < t.length && t[o].id.clock < i);
1754
+ l = t[o++], r < l.id.clock + l.length && Me(n, t, r), i(l);
1755
+ while (o < t.length && t[o].id.clock < r);
1756
1756
  };
1757
- class Mi {
1757
+ class Mr {
1758
1758
  /**
1759
1759
  * @param {Doc} doc
1760
1760
  * @param {any} origin
@@ -1764,10 +1764,10 @@ class Mi {
1764
1764
  this.doc = t, this.deleteSet = new Rt(), this.beforeState = oe(t.store), this.afterState = /* @__PURE__ */ new Map(), this.changed = /* @__PURE__ */ new Map(), this.changedParentTypes = /* @__PURE__ */ new Map(), this._mergeStructs = [], this.origin = e, this.meta = /* @__PURE__ */ new Map(), this.local = s, this.subdocsAdded = /* @__PURE__ */ new Set(), this.subdocsRemoved = /* @__PURE__ */ new Set(), this.subdocsLoaded = /* @__PURE__ */ new Set(), this._needFormattingCleanup = !1;
1765
1765
  }
1766
1766
  }
1767
- const _n = (n, t) => t.deleteSet.clients.size === 0 && !Bs(t.afterState, (e, s) => t.beforeState.get(s) !== e) ? !1 : (Je(t.deleteSet), wi(n, t), kt(n, t.deleteSet), !0), Sn = (n, t, e) => {
1767
+ const _n = (n, t) => t.deleteSet.clients.size === 0 && !Bs(t.afterState, (e, s) => t.beforeState.get(s) !== e) ? !1 : (Xe(t.deleteSet), wr(n, t), kt(n, t.deleteSet), !0), Sn = (n, t, e) => {
1768
1768
  const s = t._item;
1769
- (s === null || s.id.clock < (n.beforeState.get(s.id.client) || 0) && !s.deleted) && Y(n.changed, t, nt).add(e);
1770
- }, Gt = (n, t) => {
1769
+ (s === null || s.id.clock < (n.beforeState.get(s.id.client) || 0) && !s.deleted) && K(n.changed, t, nt).add(e);
1770
+ }, Jt = (n, t) => {
1771
1771
  const e = n[t - 1], s = n[t];
1772
1772
  e.deleted === s.deleted && e.constructor === s.constructor && e.mergeWith(s) && (n.splice(t, 1), s instanceof C && s.parentSub !== null && /** @type {AbstractType<any>} */
1773
1773
  s.parent._map.get(s.parentSub) === s && s.parent._map.set(
@@ -1775,144 +1775,144 @@ const _n = (n, t) => t.deleteSet.clients.size === 0 && !Bs(t.afterState, (e, s)
1775
1775
  /** @type {Item} */
1776
1776
  e
1777
1777
  ));
1778
- }, Ui = (n, t, e) => {
1779
- for (const [s, r] of n.clients.entries()) {
1780
- const i = (
1778
+ }, Ur = (n, t, e) => {
1779
+ for (const [s, i] of n.clients.entries()) {
1780
+ const r = (
1781
1781
  /** @type {Array<GC|Item>} */
1782
1782
  t.clients.get(s)
1783
1783
  );
1784
- for (let o = r.length - 1; o >= 0; o--) {
1785
- const c = r[o], l = c.clock + c.len;
1786
- for (let a = V(i, c.clock), h = i[a]; a < i.length && h.id.clock < l; h = i[++a]) {
1787
- const u = i[a];
1788
- if (c.clock + c.len <= u.id.clock)
1784
+ for (let o = i.length - 1; o >= 0; o--) {
1785
+ const l = i[o], c = l.clock + l.len;
1786
+ for (let a = V(r, l.clock), h = r[a]; a < r.length && h.id.clock < c; h = r[++a]) {
1787
+ const u = r[a];
1788
+ if (l.clock + l.len <= u.id.clock)
1789
1789
  break;
1790
1790
  u instanceof C && u.deleted && !u.keep && e(u) && u.gc(t, !1);
1791
1791
  }
1792
1792
  }
1793
1793
  }
1794
- }, vi = (n, t) => {
1794
+ }, vr = (n, t) => {
1795
1795
  n.clients.forEach((e, s) => {
1796
- const r = (
1796
+ const i = (
1797
1797
  /** @type {Array<GC|Item>} */
1798
1798
  t.clients.get(s)
1799
1799
  );
1800
- for (let i = e.length - 1; i >= 0; i--) {
1801
- const o = e[i], c = Re(r.length - 1, 1 + V(r, o.clock + o.len - 1));
1802
- for (let l = c, a = r[l]; l > 0 && a.id.clock >= o.clock; a = r[--l])
1803
- Gt(r, l);
1800
+ for (let r = e.length - 1; r >= 0; r--) {
1801
+ const o = e[r], l = Re(i.length - 1, 1 + V(i, o.clock + o.len - 1));
1802
+ for (let c = l, a = i[c]; c > 0 && a.id.clock >= o.clock; a = i[--c])
1803
+ Jt(i, c);
1804
1804
  }
1805
1805
  });
1806
- }, cs = (n, t) => {
1806
+ }, ls = (n, t) => {
1807
1807
  if (t < n.length) {
1808
- const e = n[t], s = e.doc, r = s.store, i = e.deleteSet, o = e._mergeStructs;
1808
+ const e = n[t], s = e.doc, i = s.store, r = e.deleteSet, o = e._mergeStructs;
1809
1809
  try {
1810
- Je(i), e.afterState = oe(e.doc.store), s.emit("beforeObserverCalls", [e, s]);
1811
- const c = [];
1810
+ Xe(r), e.afterState = oe(e.doc.store), s.emit("beforeObserverCalls", [e, s]);
1811
+ const l = [];
1812
1812
  e.changed.forEach(
1813
- (l, a) => c.push(() => {
1814
- (a._item === null || !a._item.deleted) && a._callObserver(e, l);
1813
+ (c, a) => l.push(() => {
1814
+ (a._item === null || !a._item.deleted) && a._callObserver(e, c);
1815
1815
  })
1816
- ), c.push(() => {
1817
- e.changedParentTypes.forEach((l, a) => {
1818
- a._dEH.l.length > 0 && (a._item === null || !a._item.deleted) && (l = l.filter(
1816
+ ), l.push(() => {
1817
+ e.changedParentTypes.forEach((c, a) => {
1818
+ a._dEH.l.length > 0 && (a._item === null || !a._item.deleted) && (c = c.filter(
1819
1819
  (h) => h.target._item === null || !h.target._item.deleted
1820
- ), l.forEach((h) => {
1820
+ ), c.forEach((h) => {
1821
1821
  h.currentTarget = a, h._path = null;
1822
- }), l.sort((h, u) => h.path.length - u.path.length), ss(a._dEH, l, e));
1822
+ }), c.sort((h, u) => h.path.length - u.path.length), ss(a._dEH, c, e));
1823
1823
  });
1824
- }), c.push(() => s.emit("afterTransaction", [e, s])), Te(c, []), e._needFormattingCleanup && Qi(e);
1824
+ }), l.push(() => s.emit("afterTransaction", [e, s])), Te(l, []), e._needFormattingCleanup && Qr(e);
1825
1825
  } finally {
1826
- s.gc && Ui(i, r, s.gcFilter), vi(i, r), e.afterState.forEach((h, u) => {
1826
+ s.gc && Ur(r, i, s.gcFilter), vr(r, i), e.afterState.forEach((h, u) => {
1827
1827
  const d = e.beforeState.get(u) || 0;
1828
1828
  if (d !== h) {
1829
1829
  const f = (
1830
1830
  /** @type {Array<GC|Item>} */
1831
- r.clients.get(u)
1832
- ), g = ct(V(f, d), 1);
1831
+ i.clients.get(u)
1832
+ ), g = lt(V(f, d), 1);
1833
1833
  for (let y = f.length - 1; y >= g; y--)
1834
- Gt(f, y);
1834
+ Jt(f, y);
1835
1835
  }
1836
1836
  });
1837
1837
  for (let h = 0; h < o.length; h++) {
1838
1838
  const { client: u, clock: d } = o[h].id, f = (
1839
1839
  /** @type {Array<GC|Item>} */
1840
- r.clients.get(u)
1840
+ i.clients.get(u)
1841
1841
  ), g = V(f, d);
1842
- g + 1 < f.length && Gt(f, g + 1), g > 0 && Gt(f, g);
1842
+ g + 1 < f.length && Jt(f, g + 1), g > 0 && Jt(f, g);
1843
1843
  }
1844
- if (!e.local && e.afterState.get(s.clientID) !== e.beforeState.get(s.clientID) && (ii(Jn, jn, "[yjs] ", Yn, Xn, "Changed the client-id because another client seems to be using it."), s.clientID = Kn()), s.emit("afterTransactionCleanup", [e, s]), s._observers.has("update")) {
1844
+ if (!e.local && e.afterState.get(s.clientID) !== e.beforeState.get(s.clientID) && (rr(Xn, jn, "[yjs] ", Kn, Yn, "Changed the client-id because another client seems to be using it."), s.clientID = zn()), s.emit("afterTransactionCleanup", [e, s]), s._observers.has("update")) {
1845
1845
  const h = new Nt();
1846
1846
  _n(h, e) && s.emit("update", [h.toUint8Array(), e.origin, s, e]);
1847
1847
  }
1848
1848
  if (s._observers.has("updateV2")) {
1849
- const h = new rt();
1849
+ const h = new it();
1850
1850
  _n(h, e) && s.emit("updateV2", [h.toUint8Array(), e.origin, s, e]);
1851
1851
  }
1852
- const { subdocsAdded: c, subdocsLoaded: l, subdocsRemoved: a } = e;
1853
- (c.size > 0 || a.size > 0 || l.size > 0) && (c.forEach((h) => {
1852
+ const { subdocsAdded: l, subdocsLoaded: c, subdocsRemoved: a } = e;
1853
+ (l.size > 0 || a.size > 0 || c.size > 0) && (l.forEach((h) => {
1854
1854
  h.clientID = s.clientID, h.collectionid == null && (h.collectionid = s.collectionid), s.subdocs.add(h);
1855
- }), a.forEach((h) => s.subdocs.delete(h)), s.emit("subdocs", [{ loaded: l, added: c, removed: a }, s, e]), a.forEach((h) => h.destroy())), n.length <= t + 1 ? (s._transactionCleanups = [], s.emit("afterAllTransactions", [s, n])) : cs(n, t + 1);
1855
+ }), a.forEach((h) => s.subdocs.delete(h)), s.emit("subdocs", [{ loaded: c, added: l, removed: a }, s, e]), a.forEach((h) => h.destroy())), n.length <= t + 1 ? (s._transactionCleanups = [], s.emit("afterAllTransactions", [s, n])) : ls(n, t + 1);
1856
1856
  }
1857
1857
  }
1858
1858
  }, b = (n, t, e = null, s = !0) => {
1859
- const r = n._transactionCleanups;
1860
- let i = !1, o = null;
1861
- n._transaction === null && (i = !0, n._transaction = new Mi(n, e, s), r.push(n._transaction), r.length === 1 && n.emit("beforeAllTransactions", [n]), n.emit("beforeTransaction", [n._transaction, n]));
1859
+ const i = n._transactionCleanups;
1860
+ let r = !1, o = null;
1861
+ n._transaction === null && (r = !0, n._transaction = new Mr(n, e, s), i.push(n._transaction), i.length === 1 && n.emit("beforeAllTransactions", [n]), n.emit("beforeTransaction", [n._transaction, n]));
1862
1862
  try {
1863
1863
  o = t(n._transaction);
1864
1864
  } finally {
1865
- if (i) {
1866
- const c = n._transaction === r[0];
1867
- n._transaction = null, c && cs(r, 0);
1865
+ if (r) {
1866
+ const l = n._transaction === i[0];
1867
+ n._transaction = null, l && ls(i, 0);
1868
1868
  }
1869
1869
  }
1870
1870
  return o;
1871
1871
  };
1872
- function* Oi(n) {
1872
+ function* Or(n) {
1873
1873
  const t = w(n.restDecoder);
1874
1874
  for (let e = 0; e < t; e++) {
1875
- const s = w(n.restDecoder), r = n.readClient();
1876
- let i = w(n.restDecoder);
1875
+ const s = w(n.restDecoder), i = n.readClient();
1876
+ let r = w(n.restDecoder);
1877
1877
  for (let o = 0; o < s; o++) {
1878
- const c = n.readInfo();
1879
- if (c === 10) {
1880
- const l = w(n.restDecoder);
1881
- yield new v(k(r, i), l), i += l;
1882
- } else if (se & c) {
1883
- const l = (c & ($ | M)) === 0, a = new C(
1884
- k(r, i),
1878
+ const l = n.readInfo();
1879
+ if (l === 10) {
1880
+ const c = w(n.restDecoder);
1881
+ yield new v(k(i, r), c), r += c;
1882
+ } else if (se & l) {
1883
+ const c = (l & ($ | M)) === 0, a = new C(
1884
+ k(i, r),
1885
1885
  null,
1886
1886
  // left
1887
- (c & M) === M ? n.readLeftID() : null,
1887
+ (l & M) === M ? n.readLeftID() : null,
1888
1888
  // origin
1889
1889
  null,
1890
1890
  // right
1891
- (c & $) === $ ? n.readRightID() : null,
1891
+ (l & $) === $ ? n.readRightID() : null,
1892
1892
  // right origin
1893
1893
  // @ts-ignore Force writing a string here.
1894
- l ? n.readParentInfo() ? n.readString() : n.readLeftID() : null,
1894
+ c ? n.readParentInfo() ? n.readString() : n.readLeftID() : null,
1895
1895
  // parent
1896
- l && (c & At) === At ? n.readString() : null,
1896
+ c && (l & It) === It ? n.readString() : null,
1897
1897
  // parentSub
1898
- Es(n, c)
1898
+ Es(n, l)
1899
1899
  // item content
1900
1900
  );
1901
- yield a, i += a.length;
1901
+ yield a, r += a.length;
1902
1902
  } else {
1903
- const l = n.readLen();
1904
- yield new U(k(r, i), l), i += l;
1903
+ const c = n.readLen();
1904
+ yield new U(k(i, r), c), r += c;
1905
1905
  }
1906
1906
  }
1907
1907
  }
1908
1908
  }
1909
- class ze {
1909
+ class We {
1910
1910
  /**
1911
1911
  * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
1912
1912
  * @param {boolean} filterSkips
1913
1913
  */
1914
1914
  constructor(t, e) {
1915
- this.gen = Oi(t), this.curr = null, this.done = !1, this.filterSkips = e, this.next();
1915
+ this.gen = Or(t), this.curr = null, this.done = !1, this.filterSkips = e, this.next();
1916
1916
  }
1917
1917
  /**
1918
1918
  * @return {Item | GC | Skip |null}
@@ -1924,7 +1924,7 @@ class ze {
1924
1924
  return this.curr;
1925
1925
  }
1926
1926
  }
1927
- class Ke {
1927
+ class ze {
1928
1928
  /**
1929
1929
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
1930
1930
  */
@@ -1932,7 +1932,7 @@ class Ke {
1932
1932
  this.currClient = 0, this.startClock = 0, this.written = 0, this.encoder = t, this.clientStructs = [];
1933
1933
  }
1934
1934
  }
1935
- const Ti = (n) => qt(n, Qn, Nt), Ri = (n, t) => {
1935
+ const Tr = (n) => qt(n, Qn, Nt), Rr = (n, t) => {
1936
1936
  if (n.constructor === U) {
1937
1937
  const { client: e, clock: s } = n.id;
1938
1938
  return new U(k(e, s + t), n.length - t);
@@ -1943,11 +1943,11 @@ const Ti = (n) => qt(n, Qn, Nt), Ri = (n, t) => {
1943
1943
  const e = (
1944
1944
  /** @type {Item} */
1945
1945
  n
1946
- ), { client: s, clock: r } = e.id;
1946
+ ), { client: s, clock: i } = e.id;
1947
1947
  return new C(
1948
- k(s, r + t),
1948
+ k(s, i + t),
1949
1949
  null,
1950
- k(s, r + t - 1),
1950
+ k(s, i + t - 1),
1951
1951
  null,
1952
1952
  e.rightOrigin,
1953
1953
  e.parent,
@@ -1955,13 +1955,13 @@ const Ti = (n) => qt(n, Qn, Nt), Ri = (n, t) => {
1955
1955
  e.content.splice(t)
1956
1956
  );
1957
1957
  }
1958
- }, qt = (n, t = pt, e = rt) => {
1958
+ }, qt = (n, t = pt, e = it) => {
1959
1959
  if (n.length === 1)
1960
1960
  return n[0];
1961
1961
  const s = n.map((h) => new t(Q(h)));
1962
- let r = s.map((h) => new ze(h, !0)), i = null;
1963
- const o = new e(), c = new Ke(o);
1964
- for (; r = r.filter((d) => d.curr !== null), r.sort(
1962
+ let i = s.map((h) => new We(h, !0)), r = null;
1963
+ const o = new e(), l = new ze(o);
1964
+ for (; i = i.filter((d) => d.curr !== null), i.sort(
1965
1965
  /** @type {function(any,any):number} */
1966
1966
  (d, f) => {
1967
1967
  if (d.curr.id.client === f.curr.id.client) {
@@ -1970,89 +1970,89 @@ const Ti = (n) => qt(n, Qn, Nt), Ri = (n, t) => {
1970
1970
  } else
1971
1971
  return f.curr.id.client - d.curr.id.client;
1972
1972
  }
1973
- ), r.length !== 0; ) {
1974
- const h = r[0], u = (
1973
+ ), i.length !== 0; ) {
1974
+ const h = i[0], u = (
1975
1975
  /** @type {Item | GC} */
1976
1976
  h.curr.id.client
1977
1977
  );
1978
- if (i !== null) {
1978
+ if (r !== null) {
1979
1979
  let d = (
1980
1980
  /** @type {Item | GC | null} */
1981
1981
  h.curr
1982
1982
  ), f = !1;
1983
- for (; d !== null && d.id.clock + d.length <= i.struct.id.clock + i.struct.length && d.id.client >= i.struct.id.client; )
1983
+ for (; d !== null && d.id.clock + d.length <= r.struct.id.clock + r.struct.length && d.id.client >= r.struct.id.client; )
1984
1984
  d = h.next(), f = !0;
1985
1985
  if (d === null || // current decoder is empty
1986
1986
  d.id.client !== u || // check whether there is another decoder that has has updates from `firstClient`
1987
- f && d.id.clock > i.struct.id.clock + i.struct.length)
1987
+ f && d.id.clock > r.struct.id.clock + r.struct.length)
1988
1988
  continue;
1989
- if (u !== i.struct.id.client)
1990
- G(c, i.struct, i.offset), i = { struct: d, offset: 0 }, h.next();
1991
- else if (i.struct.id.clock + i.struct.length < d.id.clock)
1992
- if (i.struct.constructor === v)
1993
- i.struct.length = d.id.clock + d.length - i.struct.id.clock;
1989
+ if (u !== r.struct.id.client)
1990
+ J(l, r.struct, r.offset), r = { struct: d, offset: 0 }, h.next();
1991
+ else if (r.struct.id.clock + r.struct.length < d.id.clock)
1992
+ if (r.struct.constructor === v)
1993
+ r.struct.length = d.id.clock + d.length - r.struct.id.clock;
1994
1994
  else {
1995
- G(c, i.struct, i.offset);
1996
- const g = d.id.clock - i.struct.id.clock - i.struct.length;
1997
- i = { struct: new v(k(u, i.struct.id.clock + i.struct.length), g), offset: 0 };
1995
+ J(l, r.struct, r.offset);
1996
+ const g = d.id.clock - r.struct.id.clock - r.struct.length;
1997
+ r = { struct: new v(k(u, r.struct.id.clock + r.struct.length), g), offset: 0 };
1998
1998
  }
1999
1999
  else {
2000
- const g = i.struct.id.clock + i.struct.length - d.id.clock;
2001
- g > 0 && (i.struct.constructor === v ? i.struct.length -= g : d = Ri(d, g)), i.struct.mergeWith(
2000
+ const g = r.struct.id.clock + r.struct.length - d.id.clock;
2001
+ g > 0 && (r.struct.constructor === v ? r.struct.length -= g : d = Rr(d, g)), r.struct.mergeWith(
2002
2002
  /** @type {any} */
2003
2003
  d
2004
- ) || (G(c, i.struct, i.offset), i = { struct: d, offset: 0 }, h.next());
2004
+ ) || (J(l, r.struct, r.offset), r = { struct: d, offset: 0 }, h.next());
2005
2005
  }
2006
2006
  } else
2007
- i = { struct: (
2007
+ r = { struct: (
2008
2008
  /** @type {Item | GC} */
2009
2009
  h.curr
2010
2010
  ), offset: 0 }, h.next();
2011
- for (let d = h.curr; d !== null && d.id.client === u && d.id.clock === i.struct.id.clock + i.struct.length && d.constructor !== v; d = h.next())
2012
- G(c, i.struct, i.offset), i = { struct: d, offset: 0 };
2011
+ for (let d = h.curr; d !== null && d.id.client === u && d.id.clock === r.struct.id.clock + r.struct.length && d.constructor !== v; d = h.next())
2012
+ J(l, r.struct, r.offset), r = { struct: d, offset: 0 };
2013
2013
  }
2014
- i !== null && (G(c, i.struct, i.offset), i = null), qe(c);
2015
- const l = s.map((h) => Ge(h)), a = hi(l);
2014
+ r !== null && (J(l, r.struct, r.offset), r = null), qe(l);
2015
+ const c = s.map((h) => Je(h)), a = hr(c);
2016
2016
  return kt(o, a), o.toUint8Array();
2017
- }, Ni = (n, t, e = pt, s = rt) => {
2018
- const r = es(t), i = new s(), o = new Ke(i), c = new e(Q(n)), l = new ze(c, !1);
2019
- for (; l.curr; ) {
2020
- const h = l.curr, u = h.id.client, d = r.get(u) || 0;
2021
- if (l.curr.constructor === v) {
2022
- l.next();
2017
+ }, Nr = (n, t, e = pt, s = it) => {
2018
+ const i = es(t), r = new s(), o = new ze(r), l = new e(Q(n)), c = new We(l, !1);
2019
+ for (; c.curr; ) {
2020
+ const h = c.curr, u = h.id.client, d = i.get(u) || 0;
2021
+ if (c.curr.constructor === v) {
2022
+ c.next();
2023
2023
  continue;
2024
2024
  }
2025
2025
  if (h.id.clock + h.length > d)
2026
- for (G(o, h, ct(d - h.id.clock, 0)), l.next(); l.curr && l.curr.id.client === u; )
2027
- G(o, l.curr, 0), l.next();
2026
+ for (J(o, h, lt(d - h.id.clock, 0)), c.next(); c.curr && c.curr.id.client === u; )
2027
+ J(o, c.curr, 0), c.next();
2028
2028
  else
2029
- for (; l.curr && l.curr.id.client === u && l.curr.id.clock + l.curr.length <= d; )
2030
- l.next();
2029
+ for (; c.curr && c.curr.id.client === u && c.curr.id.clock + c.curr.length <= d; )
2030
+ c.next();
2031
2031
  }
2032
2032
  qe(o);
2033
- const a = Ge(c);
2034
- return kt(i, a), i.toUint8Array();
2035
- }, ls = (n) => {
2033
+ const a = Je(l);
2034
+ return kt(r, a), r.toUint8Array();
2035
+ }, cs = (n) => {
2036
2036
  n.written > 0 && (n.clientStructs.push({ written: n.written, restEncoder: _(n.encoder.restEncoder) }), n.encoder.restEncoder = x(), n.written = 0);
2037
- }, G = (n, t, e) => {
2038
- n.written > 0 && n.currClient !== t.id.client && ls(n), n.written === 0 && (n.currClient = t.id.client, n.encoder.writeClient(t.id.client), p(n.encoder.restEncoder, t.id.clock + e)), t.write(n.encoder, e), n.written++;
2037
+ }, J = (n, t, e) => {
2038
+ n.written > 0 && n.currClient !== t.id.client && cs(n), n.written === 0 && (n.currClient = t.id.client, n.encoder.writeClient(t.id.client), p(n.encoder.restEncoder, t.id.clock + e)), t.write(n.encoder, e), n.written++;
2039
2039
  }, qe = (n) => {
2040
- ls(n);
2040
+ cs(n);
2041
2041
  const t = n.encoder.restEncoder;
2042
2042
  p(t, n.clientStructs.length);
2043
2043
  for (let e = 0; e < n.clientStructs.length; e++) {
2044
2044
  const s = n.clientStructs[e];
2045
- p(t, s.written), re(t, s.restEncoder);
2046
- }
2047
- }, Hi = (n, t, e, s) => {
2048
- const r = new e(Q(n)), i = new ze(r, !1), o = new s(), c = new Ke(o);
2049
- for (let a = i.curr; a !== null; a = i.next())
2050
- G(c, t(a), 0);
2051
- qe(c);
2052
- const l = Ge(r);
2053
- return kt(o, l), o.toUint8Array();
2054
- }, Vi = (n) => Hi(n, or, pt, Nt);
2055
- class ce {
2045
+ p(t, s.written), ie(t, s.restEncoder);
2046
+ }
2047
+ }, Hr = (n, t, e, s) => {
2048
+ const i = new e(Q(n)), r = new We(i, !1), o = new s(), l = new ze(o);
2049
+ for (let a = r.curr; a !== null; a = r.next())
2050
+ J(l, t(a), 0);
2051
+ qe(l);
2052
+ const c = Je(i);
2053
+ return kt(o, c), o.toUint8Array();
2054
+ }, Vr = (n) => Hr(n, oi, pt, Nt);
2055
+ class le {
2056
2056
  /**
2057
2057
  * @param {T} target The changed type.
2058
2058
  * @param {Transaction} transaction
@@ -2074,7 +2074,7 @@ class ce {
2074
2074
  * type === event.target // => true
2075
2075
  */
2076
2076
  get path() {
2077
- return this._path || (this._path = Bi(this.currentTarget, this.target));
2077
+ return this._path || (this._path = Br(this.currentTarget, this.target));
2078
2078
  }
2079
2079
  /**
2080
2080
  * Check if a struct is deleted by this event.
@@ -2085,7 +2085,7 @@ class ce {
2085
2085
  * @return {boolean}
2086
2086
  */
2087
2087
  deletes(t) {
2088
- return zn(this.transaction.deleteSet, t.id);
2088
+ return Wn(this.transaction.deleteSet, t.id);
2089
2089
  }
2090
2090
  /**
2091
2091
  * @type {Map<string, { action: 'add' | 'update' | 'delete', oldValue: any, newValue: any }>}
@@ -2094,32 +2094,32 @@ class ce {
2094
2094
  if (this._keys === null) {
2095
2095
  const t = /* @__PURE__ */ new Map(), e = this.target;
2096
2096
  /** @type Set<string|null> */
2097
- this.transaction.changed.get(e).forEach((r) => {
2098
- if (r !== null) {
2099
- const i = (
2097
+ this.transaction.changed.get(e).forEach((i) => {
2098
+ if (i !== null) {
2099
+ const r = (
2100
2100
  /** @type {Item} */
2101
- e._map.get(r)
2101
+ e._map.get(i)
2102
2102
  );
2103
- let o, c;
2104
- if (this.adds(i)) {
2105
- let l = i.left;
2106
- for (; l !== null && this.adds(l); )
2107
- l = l.left;
2108
- if (this.deletes(i))
2109
- if (l !== null && this.deletes(l))
2110
- o = "delete", c = ue(l.content.getContent());
2103
+ let o, l;
2104
+ if (this.adds(r)) {
2105
+ let c = r.left;
2106
+ for (; c !== null && this.adds(c); )
2107
+ c = c.left;
2108
+ if (this.deletes(r))
2109
+ if (c !== null && this.deletes(c))
2110
+ o = "delete", l = ue(c.content.getContent());
2111
2111
  else
2112
2112
  return;
2113
2113
  else
2114
- l !== null && this.deletes(l) ? (o = "update", c = ue(l.content.getContent())) : (o = "add", c = void 0);
2115
- } else if (this.deletes(i))
2116
- o = "delete", c = ue(
2114
+ c !== null && this.deletes(c) ? (o = "update", l = ue(c.content.getContent())) : (o = "add", l = void 0);
2115
+ } else if (this.deletes(r))
2116
+ o = "delete", l = ue(
2117
2117
  /** @type {Item} */
2118
- i.content.getContent()
2118
+ r.content.getContent()
2119
2119
  );
2120
2120
  else
2121
2121
  return;
2122
- t.set(r, { action: o, oldValue: c });
2122
+ t.set(i, { action: o, oldValue: l });
2123
2123
  }
2124
2124
  }), this._keys = t;
2125
2125
  }
@@ -2158,21 +2158,21 @@ class ce {
2158
2158
  get changes() {
2159
2159
  let t = this._changes;
2160
2160
  if (t === null) {
2161
- const e = this.target, s = nt(), r = nt(), i = [];
2161
+ const e = this.target, s = nt(), i = nt(), r = [];
2162
2162
  if (t = {
2163
2163
  added: s,
2164
- deleted: r,
2165
- delta: i,
2164
+ deleted: i,
2165
+ delta: r,
2166
2166
  keys: this.keys
2167
2167
  }, /** @type Set<string|null> */
2168
2168
  this.transaction.changed.get(e).has(null)) {
2169
- let c = null;
2170
- const l = () => {
2171
- c && i.push(c);
2169
+ let l = null;
2170
+ const c = () => {
2171
+ l && r.push(l);
2172
2172
  };
2173
2173
  for (let a = e._start; a !== null; a = a.right)
2174
- a.deleted ? this.deletes(a) && !this.adds(a) && ((c === null || c.delete === void 0) && (l(), c = { delete: 0 }), c.delete += a.length, r.add(a)) : this.adds(a) ? ((c === null || c.insert === void 0) && (l(), c = { insert: [] }), c.insert = c.insert.concat(a.content.getContent()), s.add(a)) : ((c === null || c.retain === void 0) && (l(), c = { retain: 0 }), c.retain += a.length);
2175
- c !== null && c.retain === void 0 && l();
2174
+ a.deleted ? this.deletes(a) && !this.adds(a) && ((l === null || l.delete === void 0) && (c(), l = { delete: 0 }), l.delete += a.length, i.add(a)) : this.adds(a) ? ((l === null || l.insert === void 0) && (c(), l = { insert: [] }), l.insert = l.insert.concat(a.content.getContent()), s.add(a)) : ((l === null || l.retain === void 0) && (c(), l = { retain: 0 }), l.retain += a.length);
2175
+ l !== null && l.retain === void 0 && c();
2176
2176
  }
2177
2177
  this._changes = t;
2178
2178
  }
@@ -2182,18 +2182,18 @@ class ce {
2182
2182
  );
2183
2183
  }
2184
2184
  }
2185
- const Bi = (n, t) => {
2185
+ const Br = (n, t) => {
2186
2186
  const e = [];
2187
2187
  for (; t._item !== null && t !== n; ) {
2188
2188
  if (t._item.parentSub !== null)
2189
2189
  e.unshift(t._item.parentSub);
2190
2190
  else {
2191
- let s = 0, r = (
2191
+ let s = 0, i = (
2192
2192
  /** @type {AbstractType<any>} */
2193
2193
  t._item.parent._start
2194
2194
  );
2195
- for (; r !== t._item && r !== null; )
2196
- r.deleted || s++, r = r.right;
2195
+ for (; i !== t._item && i !== null; )
2196
+ i.deleted || s++, i = i.right;
2197
2197
  e.unshift(s);
2198
2198
  }
2199
2199
  t = /** @type {AbstractType<any>} */
@@ -2202,7 +2202,7 @@ const Bi = (n, t) => {
2202
2202
  return e;
2203
2203
  }, hs = 80;
2204
2204
  let Qe = 0;
2205
- class Fi {
2205
+ class Fr {
2206
2206
  /**
2207
2207
  * @param {Item} p
2208
2208
  * @param {number} index
@@ -2211,60 +2211,60 @@ class Fi {
2211
2211
  t.marker = !0, this.p = t, this.index = e, this.timestamp = Qe++;
2212
2212
  }
2213
2213
  }
2214
- const $i = (n) => {
2214
+ const $r = (n) => {
2215
2215
  n.timestamp = Qe++;
2216
2216
  }, as = (n, t, e) => {
2217
2217
  n.p.marker = !1, n.p = t, t.marker = !0, n.index = e, n.timestamp = Qe++;
2218
- }, ji = (n, t, e) => {
2218
+ }, jr = (n, t, e) => {
2219
2219
  if (n.length >= hs) {
2220
- const s = n.reduce((r, i) => r.timestamp < i.timestamp ? r : i);
2220
+ const s = n.reduce((i, r) => i.timestamp < r.timestamp ? i : r);
2221
2221
  return as(s, t, e), s;
2222
2222
  } else {
2223
- const s = new Fi(t, e);
2223
+ const s = new Fr(t, e);
2224
2224
  return n.push(s), s;
2225
2225
  }
2226
- }, le = (n, t) => {
2226
+ }, ce = (n, t) => {
2227
2227
  if (n._start === null || t === 0 || n._searchMarker === null)
2228
2228
  return null;
2229
- const e = n._searchMarker.length === 0 ? null : n._searchMarker.reduce((i, o) => Yt(t - i.index) < Yt(t - o.index) ? i : o);
2230
- let s = n._start, r = 0;
2231
- for (e !== null && (s = e.p, r = e.index, $i(e)); s.right !== null && r < t; ) {
2229
+ const e = n._searchMarker.length === 0 ? null : n._searchMarker.reduce((r, o) => Kt(t - r.index) < Kt(t - o.index) ? r : o);
2230
+ let s = n._start, i = 0;
2231
+ for (e !== null && (s = e.p, i = e.index, $r(e)); s.right !== null && i < t; ) {
2232
2232
  if (!s.deleted && s.countable) {
2233
- if (t < r + s.length)
2233
+ if (t < i + s.length)
2234
2234
  break;
2235
- r += s.length;
2235
+ i += s.length;
2236
2236
  }
2237
2237
  s = s.right;
2238
2238
  }
2239
- for (; s.left !== null && r > t; )
2240
- s = s.left, !s.deleted && s.countable && (r -= s.length);
2239
+ for (; s.left !== null && i > t; )
2240
+ s = s.left, !s.deleted && s.countable && (i -= s.length);
2241
2241
  for (; s.left !== null && s.left.id.client === s.id.client && s.left.id.clock + s.left.length === s.id.clock; )
2242
- s = s.left, !s.deleted && s.countable && (r -= s.length);
2243
- return e !== null && Yt(e.index - r) < /** @type {YText|YArray<any>} */
2244
- s.parent.length / hs ? (as(e, s, r), e) : ji(n._searchMarker, s, r);
2242
+ s = s.left, !s.deleted && s.countable && (i -= s.length);
2243
+ return e !== null && Kt(e.index - i) < /** @type {YText|YArray<any>} */
2244
+ s.parent.length / hs ? (as(e, s, i), e) : jr(n._searchMarker, s, i);
2245
2245
  }, Mt = (n, t, e) => {
2246
2246
  for (let s = n.length - 1; s >= 0; s--) {
2247
- const r = n[s];
2247
+ const i = n[s];
2248
2248
  if (e > 0) {
2249
- let i = r.p;
2250
- for (i.marker = !1; i && (i.deleted || !i.countable); )
2251
- i = i.left, i && !i.deleted && i.countable && (r.index -= i.length);
2252
- if (i === null || i.marker === !0) {
2249
+ let r = i.p;
2250
+ for (r.marker = !1; r && (r.deleted || !r.countable); )
2251
+ r = r.left, r && !r.deleted && r.countable && (i.index -= r.length);
2252
+ if (r === null || r.marker === !0) {
2253
2253
  n.splice(s, 1);
2254
2254
  continue;
2255
2255
  }
2256
- r.p = i, i.marker = !0;
2256
+ i.p = r, r.marker = !0;
2257
2257
  }
2258
- (t < r.index || e > 0 && t === r.index) && (r.index = ct(t, r.index + e));
2258
+ (t < i.index || e > 0 && t === i.index) && (i.index = lt(t, i.index + e));
2259
2259
  }
2260
2260
  }, he = (n, t, e) => {
2261
- const s = n, r = t.changedParentTypes;
2262
- for (; Y(r, n, () => []).push(e), n._item !== null; )
2261
+ const s = n, i = t.changedParentTypes;
2262
+ for (; K(i, n, () => []).push(e), n._item !== null; )
2263
2263
  n = /** @type {AbstractType<any>} */
2264
2264
  n._item.parent;
2265
2265
  ss(s._eH, e, t);
2266
2266
  };
2267
- class A {
2267
+ class I {
2268
2268
  constructor() {
2269
2269
  this._item = null, this._map = /* @__PURE__ */ new Map(), this._start = null, this.doc = null, this._length = 0, this._eH = mn(), this._dEH = mn(), this._searchMarker = null;
2270
2270
  }
@@ -2368,30 +2368,30 @@ class A {
2368
2368
  const us = (n, t, e) => {
2369
2369
  t < 0 && (t = n._length + t), e < 0 && (e = n._length + e);
2370
2370
  let s = e - t;
2371
- const r = [];
2372
- let i = n._start;
2373
- for (; i !== null && s > 0; ) {
2374
- if (i.countable && !i.deleted) {
2375
- const o = i.content.getContent();
2371
+ const i = [];
2372
+ let r = n._start;
2373
+ for (; r !== null && s > 0; ) {
2374
+ if (r.countable && !r.deleted) {
2375
+ const o = r.content.getContent();
2376
2376
  if (o.length <= t)
2377
2377
  t -= o.length;
2378
2378
  else {
2379
- for (let c = t; c < o.length && s > 0; c++)
2380
- r.push(o[c]), s--;
2379
+ for (let l = t; l < o.length && s > 0; l++)
2380
+ i.push(o[l]), s--;
2381
2381
  t = 0;
2382
2382
  }
2383
2383
  }
2384
- i = i.right;
2384
+ r = r.right;
2385
2385
  }
2386
- return r;
2386
+ return i;
2387
2387
  }, ds = (n) => {
2388
2388
  const t = [];
2389
2389
  let e = n._start;
2390
2390
  for (; e !== null; ) {
2391
2391
  if (e.countable && !e.deleted) {
2392
2392
  const s = e.content.getContent();
2393
- for (let r = 0; r < s.length; r++)
2394
- t.push(s[r]);
2393
+ for (let i = 0; i < s.length; i++)
2394
+ t.push(s[i]);
2395
2395
  }
2396
2396
  e = e.right;
2397
2397
  }
@@ -2400,18 +2400,18 @@ const us = (n, t, e) => {
2400
2400
  let e = 0, s = n._start;
2401
2401
  for (; s !== null; ) {
2402
2402
  if (s.countable && !s.deleted) {
2403
- const r = s.content.getContent();
2404
- for (let i = 0; i < r.length; i++)
2405
- t(r[i], e++, n);
2403
+ const i = s.content.getContent();
2404
+ for (let r = 0; r < i.length; r++)
2405
+ t(i[r], e++, n);
2406
2406
  }
2407
2407
  s = s.right;
2408
2408
  }
2409
2409
  }, fs = (n, t) => {
2410
2410
  const e = [];
2411
- return Ut(n, (s, r) => {
2412
- e.push(t(s, r, n));
2411
+ return Ut(n, (s, i) => {
2412
+ e.push(t(s, i, n));
2413
2413
  }), e;
2414
- }, Yi = (n) => {
2414
+ }, Kr = (n) => {
2415
2415
  let t = n._start, e = null, s = 0;
2416
2416
  return {
2417
2417
  [Symbol.iterator]() {
@@ -2428,15 +2428,15 @@ const us = (n, t, e) => {
2428
2428
  };
2429
2429
  e = t.content.getContent(), s = 0, t = t.right;
2430
2430
  }
2431
- const r = e[s++];
2431
+ const i = e[s++];
2432
2432
  return e.length <= s && (e = null), {
2433
2433
  done: !1,
2434
- value: r
2434
+ value: i
2435
2435
  };
2436
2436
  }
2437
2437
  };
2438
2438
  }, gs = (n, t) => {
2439
- const e = le(n, t);
2439
+ const e = ce(n, t);
2440
2440
  let s = n._start;
2441
2441
  for (e !== null && (s = e.p, t -= e.index); s !== null; s = s.right)
2442
2442
  if (!s.deleted && s.countable) {
@@ -2445,11 +2445,11 @@ const us = (n, t, e) => {
2445
2445
  t -= s.length;
2446
2446
  }
2447
2447
  }, Qt = (n, t, e, s) => {
2448
- let r = e;
2449
- const i = n.doc, o = i.clientID, c = i.store, l = e === null ? t._start : e.right;
2448
+ let i = e;
2449
+ const r = n.doc, o = r.clientID, l = r.store, c = e === null ? t._start : e.right;
2450
2450
  let a = [];
2451
2451
  const h = () => {
2452
- a.length > 0 && (r = new C(k(o, I(c, o)), r, r && r.lastId, l, l && l.id, t, null, new ot(a)), r.integrate(n, 0), a = []);
2452
+ a.length > 0 && (i = new C(k(o, A(l, o)), i, i && i.lastId, c, c && c.id, t, null, new ot(a)), i.integrate(n, 0), a = []);
2453
2453
  };
2454
2454
  s.forEach((u) => {
2455
2455
  if (u === null)
@@ -2467,20 +2467,20 @@ const us = (n, t, e) => {
2467
2467
  switch (h(), u.constructor) {
2468
2468
  case Uint8Array:
2469
2469
  case ArrayBuffer:
2470
- r = new C(k(o, I(c, o)), r, r && r.lastId, l, l && l.id, t, null, new Ht(new Uint8Array(
2470
+ i = new C(k(o, A(l, o)), i, i && i.lastId, c, c && c.id, t, null, new Ht(new Uint8Array(
2471
2471
  /** @type {Uint8Array} */
2472
2472
  u
2473
- ))), r.integrate(n, 0);
2473
+ ))), i.integrate(n, 0);
2474
2474
  break;
2475
2475
  case bt:
2476
- r = new C(k(o, I(c, o)), r, r && r.lastId, l, l && l.id, t, null, new Vt(
2476
+ i = new C(k(o, A(l, o)), i, i && i.lastId, c, c && c.id, t, null, new Vt(
2477
2477
  /** @type {Doc} */
2478
2478
  u
2479
- )), r.integrate(n, 0);
2479
+ )), i.integrate(n, 0);
2480
2480
  break;
2481
2481
  default:
2482
- if (u instanceof A)
2483
- r = new C(k(o, I(c, o)), r, r && r.lastId, l, l && l.id, t, null, new J(u)), r.integrate(n, 0);
2482
+ if (u instanceof I)
2483
+ i = new C(k(o, A(l, o)), i, i && i.lastId, c, c && c.id, t, null, new X(u)), i.integrate(n, 0);
2484
2484
  else
2485
2485
  throw new Error("Unexpected content type in insert operation");
2486
2486
  }
@@ -2491,9 +2491,9 @@ const us = (n, t, e) => {
2491
2491
  throw ps;
2492
2492
  if (e === 0)
2493
2493
  return t._searchMarker && Mt(t._searchMarker, e, s.length), Qt(n, t, null, s);
2494
- const r = e, i = le(t, e);
2494
+ const i = e, r = ce(t, e);
2495
2495
  let o = t._start;
2496
- for (i !== null && (o = i.p, e -= i.index, e === 0 && (o = o.prev, e += o && o.countable && !o.deleted ? o.length : 0)); o !== null; o = o.right)
2496
+ for (r !== null && (o = r.p, e -= r.index, e === 0 && (o = o.prev, e += o && o.countable && !o.deleted ? o.length : 0)); o !== null; o = o.right)
2497
2497
  if (!o.deleted && o.countable) {
2498
2498
  if (e <= o.length) {
2499
2499
  e < o.length && q(n, k(o.id.client, o.id.clock + e));
@@ -2501,38 +2501,38 @@ const us = (n, t, e) => {
2501
2501
  }
2502
2502
  e -= o.length;
2503
2503
  }
2504
- return t._searchMarker && Mt(t._searchMarker, r, s.length), Qt(n, t, o, s);
2505
- }, Xi = (n, t, e) => {
2506
- let r = (t._searchMarker || []).reduce((i, o) => o.index > i.index ? o : i, { index: 0, p: t._start }).p;
2507
- if (r)
2508
- for (; r.right; )
2509
- r = r.right;
2510
- return Qt(n, t, r, e);
2504
+ return t._searchMarker && Mt(t._searchMarker, i, s.length), Qt(n, t, o, s);
2505
+ }, Yr = (n, t, e) => {
2506
+ let i = (t._searchMarker || []).reduce((r, o) => o.index > r.index ? o : r, { index: 0, p: t._start }).p;
2507
+ if (i)
2508
+ for (; i.right; )
2509
+ i = i.right;
2510
+ return Qt(n, t, i, e);
2511
2511
  }, ms = (n, t, e, s) => {
2512
2512
  if (s === 0)
2513
2513
  return;
2514
- const r = e, i = s, o = le(t, e);
2515
- let c = t._start;
2516
- for (o !== null && (c = o.p, e -= o.index); c !== null && e > 0; c = c.right)
2517
- !c.deleted && c.countable && (e < c.length && q(n, k(c.id.client, c.id.clock + e)), e -= c.length);
2518
- for (; s > 0 && c !== null; )
2519
- c.deleted || (s < c.length && q(n, k(c.id.client, c.id.clock + s)), c.delete(n), s -= c.length), c = c.right;
2514
+ const i = e, r = s, o = ce(t, e);
2515
+ let l = t._start;
2516
+ for (o !== null && (l = o.p, e -= o.index); l !== null && e > 0; l = l.right)
2517
+ !l.deleted && l.countable && (e < l.length && q(n, k(l.id.client, l.id.clock + e)), e -= l.length);
2518
+ for (; s > 0 && l !== null; )
2519
+ l.deleted || (s < l.length && q(n, k(l.id.client, l.id.clock + s)), l.delete(n), s -= l.length), l = l.right;
2520
2520
  if (s > 0)
2521
2521
  throw ps;
2522
2522
  t._searchMarker && Mt(
2523
2523
  t._searchMarker,
2524
- r,
2525
- -i + s
2524
+ i,
2525
+ -r + s
2526
2526
  /* in case we remove the above exception */
2527
2527
  );
2528
2528
  }, Zt = (n, t, e) => {
2529
2529
  const s = t._map.get(e);
2530
2530
  s !== void 0 && s.delete(n);
2531
2531
  }, Ze = (n, t, e, s) => {
2532
- const r = t._map.get(e) || null, i = n.doc, o = i.clientID;
2533
- let c;
2532
+ const i = t._map.get(e) || null, r = n.doc, o = r.clientID;
2533
+ let l;
2534
2534
  if (s == null)
2535
- c = new ot([s]);
2535
+ l = new ot([s]);
2536
2536
  else
2537
2537
  switch (s.constructor) {
2538
2538
  case Number:
@@ -2540,27 +2540,27 @@ const us = (n, t, e) => {
2540
2540
  case Boolean:
2541
2541
  case Array:
2542
2542
  case String:
2543
- c = new ot([s]);
2543
+ l = new ot([s]);
2544
2544
  break;
2545
2545
  case Uint8Array:
2546
- c = new Ht(
2546
+ l = new Ht(
2547
2547
  /** @type {Uint8Array} */
2548
2548
  s
2549
2549
  );
2550
2550
  break;
2551
2551
  case bt:
2552
- c = new Vt(
2552
+ l = new Vt(
2553
2553
  /** @type {Doc} */
2554
2554
  s
2555
2555
  );
2556
2556
  break;
2557
2557
  default:
2558
- if (s instanceof A)
2559
- c = new J(s);
2558
+ if (s instanceof I)
2559
+ l = new X(s);
2560
2560
  else
2561
2561
  throw new Error("Unexpected content type");
2562
2562
  }
2563
- new C(k(o, I(i.store, o)), r, r && r.lastId, null, null, t, e, c).integrate(n, 0);
2563
+ new C(k(o, A(r.store, o)), i, i && i.lastId, null, null, t, e, l).integrate(n, 0);
2564
2564
  }, Pe = (n, t) => {
2565
2565
  const e = n._map.get(t);
2566
2566
  return e !== void 0 && !e.deleted ? e.content.getContent()[e.length - 1] : void 0;
@@ -2572,12 +2572,12 @@ const us = (n, t, e) => {
2572
2572
  }, ks = (n, t) => {
2573
2573
  const e = n._map.get(t);
2574
2574
  return e !== void 0 && !e.deleted;
2575
- }, $t = (n) => ci(
2575
+ }, $t = (n) => lr(
2576
2576
  n.entries(),
2577
2577
  /** @param {any} entry */
2578
2578
  (t) => !t[1].deleted
2579
2579
  );
2580
- class Ji extends ce {
2580
+ class Xr extends le {
2581
2581
  /**
2582
2582
  * @param {YArray<T>} yarray The changed type
2583
2583
  * @param {Transaction} transaction The transaction object
@@ -2586,7 +2586,7 @@ class Ji extends ce {
2586
2586
  super(t, e), this._transaction = e;
2587
2587
  }
2588
2588
  }
2589
- class ut extends A {
2589
+ class ut extends I {
2590
2590
  constructor() {
2591
2591
  super(), this._prelimContent = [], this._searchMarker = [];
2592
2592
  }
@@ -2629,7 +2629,7 @@ class ut extends A {
2629
2629
  clone() {
2630
2630
  const t = new ut();
2631
2631
  return t.insert(0, this.toArray().map(
2632
- (e) => e instanceof A ? (
2632
+ (e) => e instanceof I ? (
2633
2633
  /** @type {typeof el} */
2634
2634
  e.clone()
2635
2635
  ) : e
@@ -2645,7 +2645,7 @@ class ut extends A {
2645
2645
  * @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
2646
2646
  */
2647
2647
  _callObserver(t, e) {
2648
- super._callObserver(t, e), he(this, t, new Ji(this, t));
2648
+ super._callObserver(t, e), he(this, t, new Xr(this, t));
2649
2649
  }
2650
2650
  /**
2651
2651
  * Inserts new content at an index.
@@ -2683,7 +2683,7 @@ class ut extends A {
2683
2683
  */
2684
2684
  push(t) {
2685
2685
  this.doc !== null ? b(this.doc, (e) => {
2686
- Xi(
2686
+ Yr(
2687
2687
  e,
2688
2688
  this,
2689
2689
  /** @type {any} */
@@ -2743,7 +2743,7 @@ class ut extends A {
2743
2743
  * @return {Array<any>}
2744
2744
  */
2745
2745
  toJSON() {
2746
- return this.map((t) => t instanceof A ? t.toJSON() : t);
2746
+ return this.map((t) => t instanceof I ? t.toJSON() : t);
2747
2747
  }
2748
2748
  /**
2749
2749
  * Returns an Array with the result of calling a provided function on every
@@ -2773,7 +2773,7 @@ class ut extends A {
2773
2773
  * @return {IterableIterator<T>}
2774
2774
  */
2775
2775
  [Symbol.iterator]() {
2776
- return Yi(this);
2776
+ return Kr(this);
2777
2777
  }
2778
2778
  /**
2779
2779
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
@@ -2782,8 +2782,8 @@ class ut extends A {
2782
2782
  t.writeTypeRef(wo);
2783
2783
  }
2784
2784
  }
2785
- const Gi = (n) => new ut();
2786
- class Wi extends ce {
2785
+ const Jr = (n) => new ut();
2786
+ class Gr extends le {
2787
2787
  /**
2788
2788
  * @param {YMap<T>} ymap The YArray that changed.
2789
2789
  * @param {Transaction} transaction
@@ -2793,7 +2793,7 @@ class Wi extends ce {
2793
2793
  super(t, e), this.keysChanged = s;
2794
2794
  }
2795
2795
  }
2796
- class wt extends A {
2796
+ class wt extends I {
2797
2797
  /**
2798
2798
  *
2799
2799
  * @param {Iterable<readonly [string, any]>=} entries - an optional iterable to initialize the YMap
@@ -2812,8 +2812,8 @@ class wt extends A {
2812
2812
  * @param {Item} item
2813
2813
  */
2814
2814
  _integrate(t, e) {
2815
- super._integrate(t, e), this._prelimContent.forEach((s, r) => {
2816
- this.set(r, s);
2815
+ super._integrate(t, e), this._prelimContent.forEach((s, i) => {
2816
+ this.set(i, s);
2817
2817
  }), this._prelimContent = null;
2818
2818
  }
2819
2819
  /**
@@ -2828,7 +2828,7 @@ class wt extends A {
2828
2828
  clone() {
2829
2829
  const t = new wt();
2830
2830
  return this.forEach((e, s) => {
2831
- t.set(s, e instanceof A ? (
2831
+ t.set(s, e instanceof I ? (
2832
2832
  /** @type {typeof value} */
2833
2833
  e.clone()
2834
2834
  ) : e);
@@ -2841,7 +2841,7 @@ class wt extends A {
2841
2841
  * @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
2842
2842
  */
2843
2843
  _callObserver(t, e) {
2844
- he(this, t, new Wi(this, t, e));
2844
+ he(this, t, new Gr(this, t, e));
2845
2845
  }
2846
2846
  /**
2847
2847
  * Transforms this Shared Type to a JSON object.
@@ -2852,8 +2852,8 @@ class wt extends A {
2852
2852
  const t = {};
2853
2853
  return this._map.forEach((e, s) => {
2854
2854
  if (!e.deleted) {
2855
- const r = e.content.getContent()[e.length - 1];
2856
- t[s] = r instanceof A ? r.toJSON() : r;
2855
+ const i = e.content.getContent()[e.length - 1];
2856
+ t[s] = i instanceof I ? i.toJSON() : i;
2857
2857
  }
2858
2858
  }), t;
2859
2859
  }
@@ -2974,8 +2974,8 @@ class wt extends A {
2974
2974
  */
2975
2975
  clear() {
2976
2976
  this.doc !== null ? b(this.doc, (t) => {
2977
- this.forEach(function(e, s, r) {
2978
- Zt(t, r, s);
2977
+ this.forEach(function(e, s, i) {
2978
+ Zt(t, i, s);
2979
2979
  });
2980
2980
  }) : this._prelimContent.clear();
2981
2981
  }
@@ -2986,7 +2986,7 @@ class wt extends A {
2986
2986
  t.writeTypeRef(mo);
2987
2987
  }
2988
2988
  }
2989
- const zi = (n) => new wt(), W = (n, t) => n === t || typeof n == "object" && typeof t == "object" && n && t && ir(n, t);
2989
+ const Wr = (n) => new wt(), G = (n, t) => n === t || typeof n == "object" && typeof t == "object" && n && t && ri(n, t);
2990
2990
  class Ue {
2991
2991
  /**
2992
2992
  * @param {Item|null} left
@@ -2994,8 +2994,8 @@ class Ue {
2994
2994
  * @param {number} index
2995
2995
  * @param {Map<string,any>} currentAttributes
2996
2996
  */
2997
- constructor(t, e, s, r) {
2998
- this.left = t, this.right = e, this.index = s, this.currentAttributes = r;
2997
+ constructor(t, e, s, i) {
2998
+ this.left = t, this.right = e, this.index = s, this.currentAttributes = i;
2999
2999
  }
3000
3000
  /**
3001
3001
  * Only call this if you know that this.right is defined
@@ -3034,16 +3034,16 @@ const Cn = (n, t, e) => {
3034
3034
  }
3035
3035
  return t;
3036
3036
  }, jt = (n, t, e) => {
3037
- const s = /* @__PURE__ */ new Map(), r = le(t, e);
3038
- if (r) {
3039
- const i = new Ue(r.p.left, r.p, r.index, s);
3040
- return Cn(n, i, e - r.index);
3037
+ const s = /* @__PURE__ */ new Map(), i = ce(t, e);
3038
+ if (i) {
3039
+ const r = new Ue(i.p.left, i.p, i.index, s);
3040
+ return Cn(n, r, e - i.index);
3041
3041
  } else {
3042
- const i = new Ue(null, t._start, 0, s);
3043
- return Cn(n, i, e);
3042
+ const r = new Ue(null, t._start, 0, s);
3043
+ return Cn(n, r, e);
3044
3044
  }
3045
3045
  }, bs = (n, t, e, s) => {
3046
- for (; e.right !== null && (e.right.deleted === !0 || e.right.content.constructor === D && W(
3046
+ for (; e.right !== null && (e.right.deleted === !0 || e.right.content.constructor === D && G(
3047
3047
  s.get(
3048
3048
  /** @type {ContentFormat} */
3049
3049
  e.right.content.key
@@ -3055,9 +3055,9 @@ const Cn = (n, t, e) => {
3055
3055
  /** @type {ContentFormat} */
3056
3056
  e.right.content.key
3057
3057
  ), e.forward();
3058
- const r = n.doc, i = r.clientID;
3059
- s.forEach((o, c) => {
3060
- const l = e.left, a = e.right, h = new C(k(i, I(r.store, i)), l, l && l.lastId, a, a && a.id, t, null, new D(c, o));
3058
+ const i = n.doc, r = i.clientID;
3059
+ s.forEach((o, l) => {
3060
+ const c = e.left, a = e.right, h = new C(k(r, A(i.store, r)), c, c && c.lastId, a, a && a.id, t, null, new D(l, o));
3061
3061
  h.integrate(n, 0), e.right = h, e.forward();
3062
3062
  });
3063
3063
  }, _t = (n, t) => {
@@ -3065,7 +3065,7 @@ const Cn = (n, t, e) => {
3065
3065
  s === null ? n.delete(e) : n.set(e, s);
3066
3066
  }, _s = (n, t) => {
3067
3067
  for (; n.right !== null; ) {
3068
- if (!(n.right.deleted || n.right.content.constructor === D && W(
3068
+ if (!(n.right.deleted || n.right.content.constructor === D && G(
3069
3069
  t[
3070
3070
  /** @type {ContentFormat} */
3071
3071
  n.right.content.key
@@ -3077,52 +3077,52 @@ const Cn = (n, t, e) => {
3077
3077
  n.forward();
3078
3078
  }
3079
3079
  }, Ss = (n, t, e, s) => {
3080
- const r = n.doc, i = r.clientID, o = /* @__PURE__ */ new Map();
3081
- for (const c in s) {
3082
- const l = s[c], a = e.currentAttributes.get(c) || null;
3083
- if (!W(a, l)) {
3084
- o.set(c, a);
3080
+ const i = n.doc, r = i.clientID, o = /* @__PURE__ */ new Map();
3081
+ for (const l in s) {
3082
+ const c = s[l], a = e.currentAttributes.get(l) || null;
3083
+ if (!G(a, c)) {
3084
+ o.set(l, a);
3085
3085
  const { left: h, right: u } = e;
3086
- e.right = new C(k(i, I(r.store, i)), h, h && h.lastId, u, u && u.id, t, null, new D(c, l)), e.right.integrate(n, 0), e.forward();
3086
+ e.right = new C(k(r, A(i.store, r)), h, h && h.lastId, u, u && u.id, t, null, new D(l, c)), e.right.integrate(n, 0), e.forward();
3087
3087
  }
3088
3088
  }
3089
3089
  return o;
3090
- }, ye = (n, t, e, s, r) => {
3090
+ }, ye = (n, t, e, s, i) => {
3091
3091
  e.currentAttributes.forEach((d, f) => {
3092
- r[f] === void 0 && (r[f] = null);
3092
+ i[f] === void 0 && (i[f] = null);
3093
3093
  });
3094
- const i = n.doc, o = i.clientID;
3095
- _s(e, r);
3096
- const c = Ss(n, t, e, r), l = s.constructor === String ? new B(
3094
+ const r = n.doc, o = r.clientID;
3095
+ _s(e, i);
3096
+ const l = Ss(n, t, e, i), c = s.constructor === String ? new B(
3097
3097
  /** @type {string} */
3098
3098
  s
3099
- ) : s instanceof A ? new J(s) : new lt(s);
3099
+ ) : s instanceof I ? new X(s) : new ct(s);
3100
3100
  let { left: a, right: h, index: u } = e;
3101
- t._searchMarker && Mt(t._searchMarker, e.index, l.getLength()), h = new C(k(o, I(i.store, o)), a, a && a.lastId, h, h && h.id, t, null, l), h.integrate(n, 0), e.right = h, e.index = u, e.forward(), bs(n, t, e, c);
3102
- }, Dn = (n, t, e, s, r) => {
3103
- const i = n.doc, o = i.clientID;
3104
- _s(e, r);
3105
- const c = Ss(n, t, e, r);
3101
+ t._searchMarker && Mt(t._searchMarker, e.index, c.getLength()), h = new C(k(o, A(r.store, o)), a, a && a.lastId, h, h && h.id, t, null, c), h.integrate(n, 0), e.right = h, e.index = u, e.forward(), bs(n, t, e, l);
3102
+ }, Dn = (n, t, e, s, i) => {
3103
+ const r = n.doc, o = r.clientID;
3104
+ _s(e, i);
3105
+ const l = Ss(n, t, e, i);
3106
3106
  t:
3107
- for (; e.right !== null && (s > 0 || c.size > 0 && (e.right.deleted || e.right.content.constructor === D)); ) {
3107
+ for (; e.right !== null && (s > 0 || l.size > 0 && (e.right.deleted || e.right.content.constructor === D)); ) {
3108
3108
  if (!e.right.deleted)
3109
3109
  switch (e.right.content.constructor) {
3110
3110
  case D: {
3111
- const { key: l, value: a } = (
3111
+ const { key: c, value: a } = (
3112
3112
  /** @type {ContentFormat} */
3113
3113
  e.right.content
3114
- ), h = r[l];
3114
+ ), h = i[c];
3115
3115
  if (h !== void 0) {
3116
- if (W(h, a))
3117
- c.delete(l);
3116
+ if (G(h, a))
3117
+ l.delete(c);
3118
3118
  else {
3119
3119
  if (s === 0)
3120
3120
  break t;
3121
- c.set(l, a);
3121
+ l.set(c, a);
3122
3122
  }
3123
3123
  e.right.delete(n);
3124
3124
  } else
3125
- e.currentAttributes.set(l, a);
3125
+ e.currentAttributes.set(c, a);
3126
3126
  break;
3127
3127
  }
3128
3128
  default:
@@ -3132,29 +3132,29 @@ const Cn = (n, t, e) => {
3132
3132
  e.forward();
3133
3133
  }
3134
3134
  if (s > 0) {
3135
- let l = "";
3135
+ let c = "";
3136
3136
  for (; s > 0; s--)
3137
- l += `
3137
+ c += `
3138
3138
  `;
3139
- e.right = new C(k(o, I(i.store, o)), e.left, e.left && e.left.lastId, e.right, e.right && e.right.id, t, null, new B(l)), e.right.integrate(n, 0), e.forward();
3139
+ e.right = new C(k(o, A(r.store, o)), e.left, e.left && e.left.lastId, e.right, e.right && e.right.id, t, null, new B(c)), e.right.integrate(n, 0), e.forward();
3140
3140
  }
3141
- bs(n, t, e, c);
3142
- }, Cs = (n, t, e, s, r) => {
3143
- let i = t;
3141
+ bs(n, t, e, l);
3142
+ }, Cs = (n, t, e, s, i) => {
3143
+ let r = t;
3144
3144
  const o = T();
3145
- for (; i && (!i.countable || i.deleted); ) {
3146
- if (!i.deleted && i.content.constructor === D) {
3145
+ for (; r && (!r.countable || r.deleted); ) {
3146
+ if (!r.deleted && r.content.constructor === D) {
3147
3147
  const a = (
3148
3148
  /** @type {ContentFormat} */
3149
- i.content
3149
+ r.content
3150
3150
  );
3151
3151
  o.set(a.key, a);
3152
3152
  }
3153
- i = i.right;
3153
+ r = r.right;
3154
3154
  }
3155
- let c = 0, l = !1;
3156
- for (; t !== i; ) {
3157
- if (e === t && (l = !0), !t.deleted) {
3155
+ let l = 0, c = !1;
3156
+ for (; t !== r; ) {
3157
+ if (e === t && (c = !0), !t.deleted) {
3158
3158
  const a = t.content;
3159
3159
  switch (a.constructor) {
3160
3160
  case D: {
@@ -3162,8 +3162,8 @@ const Cn = (n, t, e) => {
3162
3162
  /** @type {ContentFormat} */
3163
3163
  a
3164
3164
  ), d = s.get(h) || null;
3165
- (o.get(h) !== a || d === u) && (t.delete(n), c++, !l && (r.get(h) || null) === u && d !== u && (d === null ? r.delete(h) : r.set(h, d))), !l && !t.deleted && _t(
3166
- r,
3165
+ (o.get(h) !== a || d === u) && (t.delete(n), l++, !c && (i.get(h) || null) === u && d !== u && (d === null ? i.delete(h) : i.set(h, d))), !c && !t.deleted && _t(
3166
+ i,
3167
3167
  /** @type {ContentFormat} */
3168
3168
  a
3169
3169
  );
@@ -3174,8 +3174,8 @@ const Cn = (n, t, e) => {
3174
3174
  t = /** @type {Item} */
3175
3175
  t.right;
3176
3176
  }
3177
- return c;
3178
- }, Ki = (n, t) => {
3177
+ return l;
3178
+ }, zr = (n, t) => {
3179
3179
  for (; t && t.right && (t.right.deleted || !t.right.countable); )
3180
3180
  t = t.right;
3181
3181
  const e = /* @__PURE__ */ new Set();
@@ -3189,7 +3189,7 @@ const Cn = (n, t, e) => {
3189
3189
  }
3190
3190
  t = t.left;
3191
3191
  }
3192
- }, qi = (n) => {
3192
+ }, qr = (n) => {
3193
3193
  let t = 0;
3194
3194
  return b(
3195
3195
  /** @type {Doc} */
@@ -3198,36 +3198,36 @@ const Cn = (n, t, e) => {
3198
3198
  let s = (
3199
3199
  /** @type {Item} */
3200
3200
  n._start
3201
- ), r = n._start, i = T();
3202
- const o = Ce(i);
3203
- for (; r; ) {
3204
- if (r.deleted === !1)
3205
- switch (r.content.constructor) {
3201
+ ), i = n._start, r = T();
3202
+ const o = Ce(r);
3203
+ for (; i; ) {
3204
+ if (i.deleted === !1)
3205
+ switch (i.content.constructor) {
3206
3206
  case D:
3207
3207
  _t(
3208
3208
  o,
3209
3209
  /** @type {ContentFormat} */
3210
- r.content
3210
+ i.content
3211
3211
  );
3212
3212
  break;
3213
3213
  default:
3214
- t += Cs(e, s, r, i, o), i = Ce(o), s = r;
3214
+ t += Cs(e, s, i, r, o), r = Ce(o), s = i;
3215
3215
  break;
3216
3216
  }
3217
- r = r.right;
3217
+ i = i.right;
3218
3218
  }
3219
3219
  }
3220
3220
  ), t;
3221
- }, Qi = (n) => {
3221
+ }, Qr = (n) => {
3222
3222
  const t = /* @__PURE__ */ new Set(), e = n.doc;
3223
- for (const [s, r] of n.afterState.entries()) {
3224
- const i = n.beforeState.get(s) || 0;
3225
- r !== i && os(
3223
+ for (const [s, i] of n.afterState.entries()) {
3224
+ const r = n.beforeState.get(s) || 0;
3225
+ i !== r && os(
3226
3226
  n,
3227
3227
  /** @type {Array<Item|GC>} */
3228
3228
  e.store.clients.get(s),
3229
- i,
3230
3229
  r,
3230
+ i,
3231
3231
  (o) => {
3232
3232
  !o.deleted && /** @type {Item} */
3233
3233
  o.content.constructor === D && o.constructor !== U && t.add(
@@ -3238,36 +3238,36 @@ const Cn = (n, t, e) => {
3238
3238
  );
3239
3239
  }
3240
3240
  b(e, (s) => {
3241
- Wn(n, n.deleteSet, (r) => {
3242
- if (r instanceof U || !/** @type {YText} */
3243
- r.parent._hasFormatting || t.has(
3241
+ Gn(n, n.deleteSet, (i) => {
3242
+ if (i instanceof U || !/** @type {YText} */
3243
+ i.parent._hasFormatting || t.has(
3244
3244
  /** @type {YText} */
3245
- r.parent
3245
+ i.parent
3246
3246
  ))
3247
3247
  return;
3248
- const i = (
3248
+ const r = (
3249
3249
  /** @type {YText} */
3250
- r.parent
3250
+ i.parent
3251
3251
  );
3252
- r.content.constructor === D ? t.add(i) : Ki(s, r);
3252
+ i.content.constructor === D ? t.add(r) : zr(s, i);
3253
3253
  });
3254
- for (const r of t)
3255
- qi(r);
3254
+ for (const i of t)
3255
+ qr(i);
3256
3256
  });
3257
3257
  }, En = (n, t, e) => {
3258
- const s = e, r = Ce(t.currentAttributes), i = t.right;
3258
+ const s = e, i = Ce(t.currentAttributes), r = t.right;
3259
3259
  for (; e > 0 && t.right !== null; ) {
3260
3260
  if (t.right.deleted === !1)
3261
3261
  switch (t.right.content.constructor) {
3262
- case J:
3263
- case lt:
3262
+ case X:
3263
+ case ct:
3264
3264
  case B:
3265
3265
  e < t.right.length && q(n, k(t.right.id.client, t.right.id.clock + e)), e -= t.right.length, t.right.delete(n);
3266
3266
  break;
3267
3267
  }
3268
3268
  t.forward();
3269
3269
  }
3270
- i && Cs(n, i, t.right, r, t.currentAttributes);
3270
+ r && Cs(n, r, t.right, i, t.currentAttributes);
3271
3271
  const o = (
3272
3272
  /** @type {AbstractType<any>} */
3273
3273
  /** @type {Item} */
@@ -3275,15 +3275,15 @@ const Cn = (n, t, e) => {
3275
3275
  );
3276
3276
  return o._searchMarker && Mt(o._searchMarker, t.index, -s + e), t;
3277
3277
  };
3278
- class Zi extends ce {
3278
+ class Zr extends le {
3279
3279
  /**
3280
3280
  * @param {YText} ytext
3281
3281
  * @param {Transaction} transaction
3282
3282
  * @param {Set<any>} subs The keys that changed
3283
3283
  */
3284
3284
  constructor(t, e, s) {
3285
- super(t, e), this.childListChanged = !1, this.keysChanged = /* @__PURE__ */ new Set(), s.forEach((r) => {
3286
- r === null ? this.childListChanged = !0 : this.keysChanged.add(r);
3285
+ super(t, e), this.childListChanged = !1, this.keysChanged = /* @__PURE__ */ new Set(), s.forEach((i) => {
3286
+ i === null ? this.childListChanged = !0 : this.keysChanged.add(i);
3287
3287
  });
3288
3288
  }
3289
3289
  /**
@@ -3319,38 +3319,38 @@ class Zi extends ce {
3319
3319
  this.target.doc
3320
3320
  ), e = [];
3321
3321
  b(t, (s) => {
3322
- const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
3323
- let o = this.target._start, c = null;
3324
- const l = {};
3322
+ const i = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
3323
+ let o = this.target._start, l = null;
3324
+ const c = {};
3325
3325
  let a = "", h = 0, u = 0;
3326
3326
  const d = () => {
3327
- if (c !== null) {
3327
+ if (l !== null) {
3328
3328
  let f = null;
3329
- switch (c) {
3329
+ switch (l) {
3330
3330
  case "delete":
3331
3331
  u > 0 && (f = { delete: u }), u = 0;
3332
3332
  break;
3333
3333
  case "insert":
3334
- (typeof a == "object" || a.length > 0) && (f = { insert: a }, r.size > 0 && (f.attributes = {}, r.forEach((g, y) => {
3334
+ (typeof a == "object" || a.length > 0) && (f = { insert: a }, i.size > 0 && (f.attributes = {}, i.forEach((g, y) => {
3335
3335
  g !== null && (f.attributes[y] = g);
3336
3336
  }))), a = "";
3337
3337
  break;
3338
3338
  case "retain":
3339
- h > 0 && (f = { retain: h }, sr(l) || (f.attributes = Ps({}, l))), h = 0;
3339
+ h > 0 && (f = { retain: h }, si(c) || (f.attributes = Ps({}, c))), h = 0;
3340
3340
  break;
3341
3341
  }
3342
- f && e.push(f), c = null;
3342
+ f && e.push(f), l = null;
3343
3343
  }
3344
3344
  };
3345
3345
  for (; o !== null; ) {
3346
3346
  switch (o.content.constructor) {
3347
- case J:
3348
- case lt:
3349
- this.adds(o) ? this.deletes(o) || (d(), c = "insert", a = o.content.getContent()[0], d()) : this.deletes(o) ? (c !== "delete" && (d(), c = "delete"), u += 1) : o.deleted || (c !== "retain" && (d(), c = "retain"), h += 1);
3347
+ case X:
3348
+ case ct:
3349
+ this.adds(o) ? this.deletes(o) || (d(), l = "insert", a = o.content.getContent()[0], d()) : this.deletes(o) ? (l !== "delete" && (d(), l = "delete"), u += 1) : o.deleted || (l !== "retain" && (d(), l = "retain"), h += 1);
3350
3350
  break;
3351
3351
  case B:
3352
- this.adds(o) ? this.deletes(o) || (c !== "insert" && (d(), c = "insert"), a += /** @type {ContentString} */
3353
- o.content.str) : this.deletes(o) ? (c !== "delete" && (d(), c = "delete"), u += o.length) : o.deleted || (c !== "retain" && (d(), c = "retain"), h += o.length);
3352
+ this.adds(o) ? this.deletes(o) || (l !== "insert" && (d(), l = "insert"), a += /** @type {ContentString} */
3353
+ o.content.str) : this.deletes(o) ? (l !== "delete" && (d(), l = "delete"), u += o.length) : o.deleted || (l !== "retain" && (d(), l = "retain"), h += o.length);
3354
3354
  break;
3355
3355
  case D: {
3356
3356
  const { key: f, value: g } = (
@@ -3359,20 +3359,20 @@ class Zi extends ce {
3359
3359
  );
3360
3360
  if (this.adds(o)) {
3361
3361
  if (!this.deletes(o)) {
3362
- const y = r.get(f) || null;
3363
- W(y, g) ? g !== null && o.delete(s) : (c === "retain" && d(), W(g, i.get(f) || null) ? delete l[f] : l[f] = g);
3362
+ const y = i.get(f) || null;
3363
+ G(y, g) ? g !== null && o.delete(s) : (l === "retain" && d(), G(g, r.get(f) || null) ? delete c[f] : c[f] = g);
3364
3364
  }
3365
3365
  } else if (this.deletes(o)) {
3366
- i.set(f, g);
3367
- const y = r.get(f) || null;
3368
- W(y, g) || (c === "retain" && d(), l[f] = y);
3366
+ r.set(f, g);
3367
+ const y = i.get(f) || null;
3368
+ G(y, g) || (l === "retain" && d(), c[f] = y);
3369
3369
  } else if (!o.deleted) {
3370
- i.set(f, g);
3371
- const y = l[f];
3372
- y !== void 0 && (W(y, g) ? y !== null && o.delete(s) : (c === "retain" && d(), g === null ? delete l[f] : l[f] = g));
3370
+ r.set(f, g);
3371
+ const y = c[f];
3372
+ y !== void 0 && (G(y, g) ? y !== null && o.delete(s) : (l === "retain" && d(), g === null ? delete c[f] : c[f] = g));
3373
3373
  }
3374
- o.deleted || (c === "insert" && d(), _t(
3375
- r,
3374
+ o.deleted || (l === "insert" && d(), _t(
3375
+ i,
3376
3376
  /** @type {ContentFormat} */
3377
3377
  o.content
3378
3378
  ));
@@ -3396,7 +3396,7 @@ class Zi extends ce {
3396
3396
  );
3397
3397
  }
3398
3398
  }
3399
- class mt extends A {
3399
+ class mt extends I {
3400
3400
  /**
3401
3401
  * @param {String} [string] The initial value of the YText.
3402
3402
  */
@@ -3442,7 +3442,7 @@ class mt extends A {
3442
3442
  */
3443
3443
  _callObserver(t, e) {
3444
3444
  super._callObserver(t, e);
3445
- const s = new Zi(this, t, e);
3445
+ const s = new Zr(this, t, e);
3446
3446
  he(this, t, s), !t.local && this._hasFormatting && (t._needFormattingCleanup = !0);
3447
3447
  }
3448
3448
  /**
@@ -3478,15 +3478,15 @@ class mt extends A {
3478
3478
  */
3479
3479
  applyDelta(t, { sanitize: e = !0 } = {}) {
3480
3480
  this.doc !== null ? b(this.doc, (s) => {
3481
- const r = new Ue(null, this._start, 0, /* @__PURE__ */ new Map());
3482
- for (let i = 0; i < t.length; i++) {
3483
- const o = t[i];
3481
+ const i = new Ue(null, this._start, 0, /* @__PURE__ */ new Map());
3482
+ for (let r = 0; r < t.length; r++) {
3483
+ const o = t[r];
3484
3484
  if (o.insert !== void 0) {
3485
- const c = !e && typeof o.insert == "string" && i === t.length - 1 && r.right === null && o.insert.slice(-1) === `
3485
+ const l = !e && typeof o.insert == "string" && r === t.length - 1 && i.right === null && o.insert.slice(-1) === `
3486
3486
  ` ? o.insert.slice(0, -1) : o.insert;
3487
- (typeof c != "string" || c.length > 0) && ye(s, this, r, c, o.attributes || {});
3487
+ (typeof l != "string" || l.length > 0) && ye(s, this, i, l, o.attributes || {});
3488
3488
  } else
3489
- o.retain !== void 0 ? Dn(s, this, r, o.retain, o.attributes || {}) : o.delete !== void 0 && En(s, r, o.delete);
3489
+ o.retain !== void 0 ? Dn(s, this, i, o.retain, o.attributes || {}) : o.delete !== void 0 && En(s, i, o.delete);
3490
3490
  }
3491
3491
  }) : this._pending.push(() => this.applyDelta(t));
3492
3492
  }
@@ -3501,65 +3501,65 @@ class mt extends A {
3501
3501
  * @public
3502
3502
  */
3503
3503
  toDelta(t, e, s) {
3504
- const r = [], i = /* @__PURE__ */ new Map(), o = (
3504
+ const i = [], r = /* @__PURE__ */ new Map(), o = (
3505
3505
  /** @type {Doc} */
3506
3506
  this.doc
3507
3507
  );
3508
- let c = "", l = this._start;
3508
+ let l = "", c = this._start;
3509
3509
  function a() {
3510
- if (c.length > 0) {
3510
+ if (l.length > 0) {
3511
3511
  const u = {};
3512
3512
  let d = !1;
3513
- i.forEach((g, y) => {
3513
+ r.forEach((g, y) => {
3514
3514
  d = !0, u[y] = g;
3515
3515
  });
3516
- const f = { insert: c };
3517
- d && (f.attributes = u), r.push(f), c = "";
3516
+ const f = { insert: l };
3517
+ d && (f.attributes = u), i.push(f), l = "";
3518
3518
  }
3519
3519
  }
3520
3520
  const h = () => {
3521
- for (; l !== null; ) {
3522
- if (St(l, t) || e !== void 0 && St(l, e))
3523
- switch (l.content.constructor) {
3521
+ for (; c !== null; ) {
3522
+ if (St(c, t) || e !== void 0 && St(c, e))
3523
+ switch (c.content.constructor) {
3524
3524
  case B: {
3525
- const u = i.get("ychange");
3526
- t !== void 0 && !St(l, t) ? (u === void 0 || u.user !== l.id.client || u.type !== "removed") && (a(), i.set("ychange", s ? s("removed", l.id) : { type: "removed" })) : e !== void 0 && !St(l, e) ? (u === void 0 || u.user !== l.id.client || u.type !== "added") && (a(), i.set("ychange", s ? s("added", l.id) : { type: "added" })) : u !== void 0 && (a(), i.delete("ychange")), c += /** @type {ContentString} */
3527
- l.content.str;
3525
+ const u = r.get("ychange");
3526
+ t !== void 0 && !St(c, t) ? (u === void 0 || u.user !== c.id.client || u.type !== "removed") && (a(), r.set("ychange", s ? s("removed", c.id) : { type: "removed" })) : e !== void 0 && !St(c, e) ? (u === void 0 || u.user !== c.id.client || u.type !== "added") && (a(), r.set("ychange", s ? s("added", c.id) : { type: "added" })) : u !== void 0 && (a(), r.delete("ychange")), l += /** @type {ContentString} */
3527
+ c.content.str;
3528
3528
  break;
3529
3529
  }
3530
- case J:
3531
- case lt: {
3530
+ case X:
3531
+ case ct: {
3532
3532
  a();
3533
3533
  const u = {
3534
- insert: l.content.getContent()[0]
3534
+ insert: c.content.getContent()[0]
3535
3535
  };
3536
- if (i.size > 0) {
3536
+ if (r.size > 0) {
3537
3537
  const d = (
3538
3538
  /** @type {Object<string,any>} */
3539
3539
  {}
3540
3540
  );
3541
- u.attributes = d, i.forEach((f, g) => {
3541
+ u.attributes = d, r.forEach((f, g) => {
3542
3542
  d[g] = f;
3543
3543
  });
3544
3544
  }
3545
- r.push(u);
3545
+ i.push(u);
3546
3546
  break;
3547
3547
  }
3548
3548
  case D:
3549
- St(l, t) && (a(), _t(
3550
- i,
3549
+ St(c, t) && (a(), _t(
3550
+ r,
3551
3551
  /** @type {ContentFormat} */
3552
- l.content
3552
+ c.content
3553
3553
  ));
3554
3554
  break;
3555
3555
  }
3556
- l = l.right;
3556
+ c = c.right;
3557
3557
  }
3558
3558
  a();
3559
3559
  };
3560
3560
  return t || e ? b(o, (u) => {
3561
3561
  t && xe(u, t), e && xe(u, e), h();
3562
- }, "cleanup") : h(), r;
3562
+ }, "cleanup") : h(), i;
3563
3563
  }
3564
3564
  /**
3565
3565
  * Insert text at a given index.
@@ -3574,12 +3574,12 @@ class mt extends A {
3574
3574
  insert(t, e, s) {
3575
3575
  if (e.length <= 0)
3576
3576
  return;
3577
- const r = this.doc;
3578
- r !== null ? b(r, (i) => {
3579
- const o = jt(i, this, t);
3580
- s || (s = {}, o.currentAttributes.forEach((c, l) => {
3581
- s[l] = c;
3582
- })), ye(i, this, o, e, s);
3577
+ const i = this.doc;
3578
+ i !== null ? b(i, (r) => {
3579
+ const o = jt(r, this, t);
3580
+ s || (s = {}, o.currentAttributes.forEach((l, c) => {
3581
+ s[c] = l;
3582
+ })), ye(r, this, o, e, s);
3583
3583
  }) : this._pending.push(() => this.insert(t, e, s));
3584
3584
  }
3585
3585
  /**
@@ -3593,10 +3593,10 @@ class mt extends A {
3593
3593
  * @public
3594
3594
  */
3595
3595
  insertEmbed(t, e, s = {}) {
3596
- const r = this.doc;
3597
- r !== null ? b(r, (i) => {
3598
- const o = jt(i, this, t);
3599
- ye(i, this, o, e, s);
3596
+ const i = this.doc;
3597
+ i !== null ? b(i, (r) => {
3598
+ const o = jt(r, this, t);
3599
+ ye(r, this, o, e, s);
3600
3600
  }) : this._pending.push(() => this.insertEmbed(t, e, s));
3601
3601
  }
3602
3602
  /**
@@ -3611,8 +3611,8 @@ class mt extends A {
3611
3611
  if (e === 0)
3612
3612
  return;
3613
3613
  const s = this.doc;
3614
- s !== null ? b(s, (r) => {
3615
- En(r, jt(r, this, t), e);
3614
+ s !== null ? b(s, (i) => {
3615
+ En(i, jt(i, this, t), e);
3616
3616
  }) : this._pending.push(() => this.delete(t, e));
3617
3617
  }
3618
3618
  /**
@@ -3628,10 +3628,10 @@ class mt extends A {
3628
3628
  format(t, e, s) {
3629
3629
  if (e === 0)
3630
3630
  return;
3631
- const r = this.doc;
3632
- r !== null ? b(r, (i) => {
3633
- const o = jt(i, this, t);
3634
- o.right !== null && Dn(i, this, o, e, s);
3631
+ const i = this.doc;
3632
+ i !== null ? b(i, (r) => {
3633
+ const o = jt(r, this, t);
3634
+ o.right !== null && Dn(r, this, o, e, s);
3635
3635
  }) : this._pending.push(() => this.format(t, e, s));
3636
3636
  }
3637
3637
  /**
@@ -3699,7 +3699,7 @@ class mt extends A {
3699
3699
  t.writeTypeRef(yo);
3700
3700
  }
3701
3701
  }
3702
- const Pi = (n) => new mt();
3702
+ const Pr = (n) => new mt();
3703
3703
  class ke {
3704
3704
  /**
3705
3705
  * @param {YXmlFragment | YXmlElement} root
@@ -3725,7 +3725,7 @@ class ke {
3725
3725
  if (t !== null && (!this._firstCall || t.deleted || !this._filter(e)))
3726
3726
  do
3727
3727
  if (e = /** @type {any} */
3728
- t.content.type, !t.deleted && (e.constructor === vt || e.constructor === it) && e._start !== null)
3728
+ t.content.type, !t.deleted && (e.constructor === vt || e.constructor === rt) && e._start !== null)
3729
3729
  t = e._start;
3730
3730
  else
3731
3731
  for (; t !== null; )
@@ -3745,7 +3745,7 @@ class ke {
3745
3745
  ), done: !1 });
3746
3746
  }
3747
3747
  }
3748
- class it extends A {
3748
+ class rt extends I {
3749
3749
  constructor() {
3750
3750
  super(), this._prelimContent = [];
3751
3751
  }
@@ -3774,14 +3774,14 @@ class it extends A {
3774
3774
  ), this._prelimContent = null;
3775
3775
  }
3776
3776
  _copy() {
3777
- return new it();
3777
+ return new rt();
3778
3778
  }
3779
3779
  /**
3780
3780
  * @return {YXmlFragment}
3781
3781
  */
3782
3782
  clone() {
3783
- const t = new it();
3784
- return t.insert(0, this.toArray().map((e) => e instanceof A ? e.clone() : e)), t;
3783
+ const t = new rt();
3784
+ return t.insert(0, this.toArray().map((e) => e instanceof I ? e.clone() : e)), t;
3785
3785
  }
3786
3786
  get length() {
3787
3787
  return this._prelimContent === null ? this._length : this._prelimContent.length;
@@ -3823,7 +3823,7 @@ class it extends A {
3823
3823
  */
3824
3824
  querySelector(t) {
3825
3825
  t = t.toUpperCase();
3826
- const s = new ke(this, (r) => r.nodeName && r.nodeName.toUpperCase() === t).next();
3826
+ const s = new ke(this, (i) => i.nodeName && i.nodeName.toUpperCase() === t).next();
3827
3827
  return s.done ? null : s.value;
3828
3828
  }
3829
3829
  /**
@@ -3838,7 +3838,7 @@ class it extends A {
3838
3838
  * @public
3839
3839
  */
3840
3840
  querySelectorAll(t) {
3841
- return t = t.toUpperCase(), K(new ke(this, (e) => e.nodeName && e.nodeName.toUpperCase() === t));
3841
+ return t = t.toUpperCase(), z(new ke(this, (e) => e.nodeName && e.nodeName.toUpperCase() === t));
3842
3842
  }
3843
3843
  /**
3844
3844
  * Creates YXmlEvent and calls observers.
@@ -3879,10 +3879,10 @@ class it extends A {
3879
3879
  * @public
3880
3880
  */
3881
3881
  toDOM(t = document, e = {}, s) {
3882
- const r = t.createDocumentFragment();
3883
- return s !== void 0 && s._createAssociation(r, this), Ut(this, (i) => {
3884
- r.insertBefore(i.toDOM(t, e, s), null);
3885
- }), r;
3882
+ const i = t.createDocumentFragment();
3883
+ return s !== void 0 && s._createAssociation(i, this), Ut(this, (r) => {
3884
+ i.insertBefore(r.toDOM(t, e, s), null);
3885
+ }), i;
3886
3886
  }
3887
3887
  /**
3888
3888
  * Inserts new content at an index.
@@ -3912,17 +3912,17 @@ class it extends A {
3912
3912
  insertAfter(t, e) {
3913
3913
  if (this.doc !== null)
3914
3914
  b(this.doc, (s) => {
3915
- const r = t && t instanceof A ? t._item : t;
3916
- Qt(s, this, r, e);
3915
+ const i = t && t instanceof I ? t._item : t;
3916
+ Qt(s, this, i, e);
3917
3917
  });
3918
3918
  else {
3919
3919
  const s = (
3920
3920
  /** @type {Array<any>} */
3921
3921
  this._prelimContent
3922
- ), r = t === null ? 0 : s.findIndex((i) => i === t) + 1;
3923
- if (r === 0 && t !== null)
3922
+ ), i = t === null ? 0 : s.findIndex((r) => r === t) + 1;
3923
+ if (i === 0 && t !== null)
3924
3924
  throw yt("Reference item not found");
3925
- s.splice(r, 0, ...e);
3925
+ s.splice(i, 0, ...e);
3926
3926
  }
3927
3927
  }
3928
3928
  /**
@@ -3999,8 +3999,8 @@ class it extends A {
3999
3999
  t.writeTypeRef(bo);
4000
4000
  }
4001
4001
  }
4002
- const to = (n) => new it();
4003
- class vt extends it {
4002
+ const to = (n) => new rt();
4003
+ class vt extends rt {
4004
4004
  constructor(t = "UNDEFINED") {
4005
4005
  super(), this.nodeName = t, this._prelimAttrs = /* @__PURE__ */ new Map();
4006
4006
  }
@@ -4038,8 +4038,8 @@ class vt extends it {
4038
4038
  */
4039
4039
  _integrate(t, e) {
4040
4040
  super._integrate(t, e), /** @type {Map<string, any>} */
4041
- this._prelimAttrs.forEach((s, r) => {
4042
- this.setAttribute(r, s);
4041
+ this._prelimAttrs.forEach((s, i) => {
4042
+ this.setAttribute(i, s);
4043
4043
  }), this._prelimAttrs = null;
4044
4044
  }
4045
4045
  /**
@@ -4055,9 +4055,9 @@ class vt extends it {
4055
4055
  */
4056
4056
  clone() {
4057
4057
  const t = new vt(this.nodeName), e = this.getAttributes();
4058
- return er(e, (s, r) => {
4059
- typeof s == "string" && t.setAttribute(r, s);
4060
- }), t.insert(0, this.toArray().map((s) => s instanceof A ? s.clone() : s)), t;
4058
+ return ei(e, (s, i) => {
4059
+ typeof s == "string" && t.setAttribute(i, s);
4060
+ }), t.insert(0, this.toArray().map((s) => s instanceof I ? s.clone() : s)), t;
4061
4061
  }
4062
4062
  /**
4063
4063
  * Returns the XML serialization of this YXmlElement.
@@ -4070,16 +4070,16 @@ class vt extends it {
4070
4070
  */
4071
4071
  toString() {
4072
4072
  const t = this.getAttributes(), e = [], s = [];
4073
- for (const c in t)
4074
- s.push(c);
4073
+ for (const l in t)
4074
+ s.push(l);
4075
4075
  s.sort();
4076
- const r = s.length;
4077
- for (let c = 0; c < r; c++) {
4078
- const l = s[c];
4079
- e.push(l + '="' + t[l] + '"');
4076
+ const i = s.length;
4077
+ for (let l = 0; l < i; l++) {
4078
+ const c = s[l];
4079
+ e.push(c + '="' + t[c] + '"');
4080
4080
  }
4081
- const i = this.nodeName.toLocaleLowerCase(), o = e.length > 0 ? " " + e.join(" ") : "";
4082
- return `<${i}${o}>${super.toString()}</${i}>`;
4081
+ const r = this.nodeName.toLocaleLowerCase(), o = e.length > 0 ? " " + e.join(" ") : "";
4082
+ return `<${r}${o}>${super.toString()}</${r}>`;
4083
4083
  }
4084
4084
  /**
4085
4085
  * Removes an attribute from this YXmlElement.
@@ -4168,14 +4168,14 @@ class vt extends it {
4168
4168
  * @public
4169
4169
  */
4170
4170
  toDOM(t = document, e = {}, s) {
4171
- const r = t.createElement(this.nodeName), i = this.getAttributes();
4172
- for (const o in i) {
4173
- const c = i[o];
4174
- typeof c == "string" && r.setAttribute(o, c);
4171
+ const i = t.createElement(this.nodeName), r = this.getAttributes();
4172
+ for (const o in r) {
4173
+ const l = r[o];
4174
+ typeof l == "string" && i.setAttribute(o, l);
4175
4175
  }
4176
4176
  return Ut(this, (o) => {
4177
- r.appendChild(o.toDOM(t, e, s));
4178
- }), s !== void 0 && s._createAssociation(r, this), r;
4177
+ i.appendChild(o.toDOM(t, e, s));
4178
+ }), s !== void 0 && s._createAssociation(i, this), i;
4179
4179
  }
4180
4180
  /**
4181
4181
  * Transform the properties of this type to binary and write it to an
@@ -4190,7 +4190,7 @@ class vt extends it {
4190
4190
  }
4191
4191
  }
4192
4192
  const eo = (n) => new vt(n.readKey());
4193
- class no extends ce {
4193
+ class no extends le {
4194
4194
  /**
4195
4195
  * @param {YXmlElement|YXmlText|YXmlFragment} target The target on which the event is created.
4196
4196
  * @param {Set<string|null>} subs The set of changed attributes. `null` is included if the
@@ -4199,8 +4199,8 @@ class no extends ce {
4199
4199
  * change was created.
4200
4200
  */
4201
4201
  constructor(t, e, s) {
4202
- super(t, s), this.childListChanged = !1, this.attributesChanged = /* @__PURE__ */ new Set(), e.forEach((r) => {
4203
- r === null ? this.childListChanged = !0 : this.attributesChanged.add(r);
4202
+ super(t, s), this.childListChanged = !1, this.attributesChanged = /* @__PURE__ */ new Set(), e.forEach((i) => {
4203
+ i === null ? this.childListChanged = !0 : this.attributesChanged.add(i);
4204
4204
  });
4205
4205
  }
4206
4206
  }
@@ -4242,9 +4242,9 @@ class Pt extends wt {
4242
4242
  * @public
4243
4243
  */
4244
4244
  toDOM(t = document, e = {}, s) {
4245
- const r = e[this.hookName];
4246
- let i;
4247
- return r !== void 0 ? i = r.createDom(this) : i = document.createElement(this.hookName), i.setAttribute("data-yjs-hook", this.hookName), s !== void 0 && s._createAssociation(i, this), i;
4245
+ const i = e[this.hookName];
4246
+ let r;
4247
+ return i !== void 0 ? r = i.createDom(this) : r = document.createElement(this.hookName), r.setAttribute("data-yjs-hook", this.hookName), s !== void 0 && s._createAssociation(r, this), r;
4248
4248
  }
4249
4249
  /**
4250
4250
  * Transform the properties of this type to binary and write it to an
@@ -4308,32 +4308,32 @@ class te extends mt {
4308
4308
  * @public
4309
4309
  */
4310
4310
  toDOM(t = document, e, s) {
4311
- const r = t.createTextNode(this.toString());
4312
- return s !== void 0 && s._createAssociation(r, this), r;
4311
+ const i = t.createTextNode(this.toString());
4312
+ return s !== void 0 && s._createAssociation(i, this), i;
4313
4313
  }
4314
4314
  toString() {
4315
4315
  return this.toDelta().map((t) => {
4316
4316
  const e = [];
4317
- for (const r in t.attributes) {
4318
- const i = [];
4319
- for (const o in t.attributes[r])
4320
- i.push({ key: o, value: t.attributes[r][o] });
4321
- i.sort((o, c) => o.key < c.key ? -1 : 1), e.push({ nodeName: r, attrs: i });
4317
+ for (const i in t.attributes) {
4318
+ const r = [];
4319
+ for (const o in t.attributes[i])
4320
+ r.push({ key: o, value: t.attributes[i][o] });
4321
+ r.sort((o, l) => o.key < l.key ? -1 : 1), e.push({ nodeName: i, attrs: r });
4322
4322
  }
4323
- e.sort((r, i) => r.nodeName < i.nodeName ? -1 : 1);
4323
+ e.sort((i, r) => i.nodeName < r.nodeName ? -1 : 1);
4324
4324
  let s = "";
4325
- for (let r = 0; r < e.length; r++) {
4326
- const i = e[r];
4327
- s += `<${i.nodeName}`;
4328
- for (let o = 0; o < i.attrs.length; o++) {
4329
- const c = i.attrs[o];
4330
- s += ` ${c.key}="${c.value}"`;
4325
+ for (let i = 0; i < e.length; i++) {
4326
+ const r = e[i];
4327
+ s += `<${r.nodeName}`;
4328
+ for (let o = 0; o < r.attrs.length; o++) {
4329
+ const l = r.attrs[o];
4330
+ s += ` ${l.key}="${l.value}"`;
4331
4331
  }
4332
4332
  s += ">";
4333
4333
  }
4334
4334
  s += t.insert;
4335
- for (let r = e.length - 1; r >= 0; r--)
4336
- s += `</${e[r].nodeName}>`;
4335
+ for (let i = e.length - 1; i >= 0; i--)
4336
+ s += `</${e[i].nodeName}>`;
4337
4337
  return s;
4338
4338
  }).join("");
4339
4339
  }
@@ -4350,7 +4350,7 @@ class te extends mt {
4350
4350
  t.writeTypeRef(So);
4351
4351
  }
4352
4352
  }
4353
- const ro = (n) => new te();
4353
+ const io = (n) => new te();
4354
4354
  class tn {
4355
4355
  /**
4356
4356
  * @param {ID} id
@@ -4391,7 +4391,7 @@ class tn {
4391
4391
  throw N();
4392
4392
  }
4393
4393
  }
4394
- const io = 0;
4394
+ const ro = 0;
4395
4395
  class U extends tn {
4396
4396
  get deleted() {
4397
4397
  return !0;
@@ -4410,14 +4410,14 @@ class U extends tn {
4410
4410
  * @param {number} offset
4411
4411
  */
4412
4412
  integrate(t, e) {
4413
- e > 0 && (this.id.clock += e, this.length -= e), is(t.doc.store, this);
4413
+ e > 0 && (this.id.clock += e, this.length -= e), rs(t.doc.store, this);
4414
4414
  }
4415
4415
  /**
4416
4416
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
4417
4417
  * @param {number} offset
4418
4418
  */
4419
4419
  write(t, e) {
4420
- t.writeInfo(io), t.writeLen(this.length - e);
4420
+ t.writeInfo(ro), t.writeLen(this.length - e);
4421
4421
  }
4422
4422
  /**
4423
4423
  * @param {Transaction} transaction
@@ -4555,7 +4555,7 @@ class Ot {
4555
4555
  * @param {Item} item
4556
4556
  */
4557
4557
  integrate(t, e) {
4558
- Kt(t.deleteSet, e.id.client, e.id.clock, this.len), e.markDeleted();
4558
+ zt(t.deleteSet, e.id.client, e.id.clock, this.len), e.markDeleted();
4559
4559
  }
4560
4560
  /**
4561
4561
  * @param {Transaction} transaction
@@ -4581,7 +4581,7 @@ class Ot {
4581
4581
  return 1;
4582
4582
  }
4583
4583
  }
4584
- const co = (n) => new Ot(n.readLen()), Ds = (n, t) => new bt({ guid: n, ...t, shouldLoad: t.shouldLoad || t.autoLoad || !1 });
4584
+ const lo = (n) => new Ot(n.readLen()), Ds = (n, t) => new bt({ guid: n, ...t, shouldLoad: t.shouldLoad || t.autoLoad || !1 });
4585
4585
  class Vt {
4586
4586
  /**
4587
4587
  * @param {Doc} doc
@@ -4661,8 +4661,8 @@ class Vt {
4661
4661
  return 9;
4662
4662
  }
4663
4663
  }
4664
- const lo = (n) => new Vt(Ds(n.readString(), n.readAny()));
4665
- class lt {
4664
+ const co = (n) => new Vt(Ds(n.readString(), n.readAny()));
4665
+ class ct {
4666
4666
  /**
4667
4667
  * @param {Object} embed
4668
4668
  */
@@ -4691,7 +4691,7 @@ class lt {
4691
4691
  * @return {ContentEmbed}
4692
4692
  */
4693
4693
  copy() {
4694
- return new lt(this.embed);
4694
+ return new ct(this.embed);
4695
4695
  }
4696
4696
  /**
4697
4697
  * @param {number} offset
@@ -4737,7 +4737,7 @@ class lt {
4737
4737
  return 5;
4738
4738
  }
4739
4739
  }
4740
- const ho = (n) => new lt(n.readJSON());
4740
+ const ho = (n) => new ct(n.readJSON());
4741
4741
  class D {
4742
4742
  /**
4743
4743
  * @param {string} key
@@ -4889,9 +4889,9 @@ class ee {
4889
4889
  write(t, e) {
4890
4890
  const s = this.arr.length;
4891
4891
  t.writeLen(s - e);
4892
- for (let r = e; r < s; r++) {
4893
- const i = this.arr[r];
4894
- t.writeString(i === void 0 ? "undefined" : JSON.stringify(i));
4892
+ for (let i = e; i < s; i++) {
4893
+ const r = this.arr[i];
4894
+ t.writeString(r === void 0 ? "undefined" : JSON.stringify(r));
4895
4895
  }
4896
4896
  }
4897
4897
  /**
@@ -4904,8 +4904,8 @@ class ee {
4904
4904
  const uo = (n) => {
4905
4905
  const t = n.readLen(), e = [];
4906
4906
  for (let s = 0; s < t; s++) {
4907
- const r = n.readString();
4908
- r === "undefined" ? e.push(void 0) : e.push(JSON.parse(r));
4907
+ const i = n.readString();
4908
+ i === "undefined" ? e.push(void 0) : e.push(JSON.parse(i));
4909
4909
  }
4910
4910
  return new ee(e);
4911
4911
  };
@@ -4978,9 +4978,9 @@ class ot {
4978
4978
  write(t, e) {
4979
4979
  const s = this.arr.length;
4980
4980
  t.writeLen(s - e);
4981
- for (let r = e; r < s; r++) {
4982
- const i = this.arr[r];
4983
- t.writeAny(i);
4981
+ for (let i = e; i < s; i++) {
4982
+ const r = this.arr[i];
4983
+ t.writeAny(r);
4984
4984
  }
4985
4985
  }
4986
4986
  /**
@@ -5075,15 +5075,15 @@ class B {
5075
5075
  }
5076
5076
  }
5077
5077
  const go = (n) => new B(n.readString()), po = [
5078
- Gi,
5079
- zi,
5080
- Pi,
5078
+ Jr,
5079
+ Wr,
5080
+ Pr,
5081
5081
  eo,
5082
5082
  to,
5083
5083
  so,
5084
- ro
5084
+ io
5085
5085
  ], wo = 0, mo = 1, yo = 2, ko = 3, bo = 4, _o = 5, So = 6;
5086
- class J {
5086
+ class X {
5087
5087
  /**
5088
5088
  * @param {AbstractType<any>} type
5089
5089
  */
@@ -5112,7 +5112,7 @@ class J {
5112
5112
  * @return {ContentType}
5113
5113
  */
5114
5114
  copy() {
5115
- return new J(this.type._copy());
5115
+ return new X(this.type._copy());
5116
5116
  }
5117
5117
  /**
5118
5118
  * @param {number} offset
@@ -5175,18 +5175,18 @@ class J {
5175
5175
  return 7;
5176
5176
  }
5177
5177
  }
5178
- const Co = (n) => new J(po[n.readTypeRef()](n)), ne = (n, t, e) => {
5179
- const { client: s, clock: r } = t.id, i = new C(
5180
- k(s, r + e),
5178
+ const Co = (n) => new X(po[n.readTypeRef()](n)), ne = (n, t, e) => {
5179
+ const { client: s, clock: i } = t.id, r = new C(
5180
+ k(s, i + e),
5181
5181
  t,
5182
- k(s, r + e - 1),
5182
+ k(s, i + e - 1),
5183
5183
  t.right,
5184
5184
  t.rightOrigin,
5185
5185
  t.parent,
5186
5186
  t.parentSub,
5187
5187
  t.content.splice(e)
5188
5188
  );
5189
- return t.deleted && i.markDeleted(), t.keep && (i.keep = !0), t.redone !== null && (i.redone = k(t.redone.client, t.redone.clock + e)), t.right = i, i.right !== null && (i.right.left = i), n._mergeStructs.push(i), i.parentSub !== null && i.right === null && i.parent._map.set(i.parentSub, i), t.length = e, i;
5189
+ return t.deleted && r.markDeleted(), t.keep && (r.keep = !0), t.redone !== null && (r.redone = k(t.redone.client, t.redone.clock + e)), t.right = r, r.right !== null && (r.right.left = r), n._mergeStructs.push(r), r.parentSub !== null && r.right === null && r.parent._map.set(r.parentSub, r), t.length = e, r;
5190
5190
  };
5191
5191
  class C extends tn {
5192
5192
  /**
@@ -5199,8 +5199,8 @@ class C extends tn {
5199
5199
  * @param {string | null} parentSub
5200
5200
  * @param {AbstractContent} content
5201
5201
  */
5202
- constructor(t, e, s, r, i, o, c, l) {
5203
- super(t, l.getLength()), this.origin = s, this.left = e, this.right = r, this.rightOrigin = i, this.parent = o, this.parentSub = c, this.redone = null, this.content = l, this.info = this.content.isCountable() ? hn : 0;
5202
+ constructor(t, e, s, i, r, o, l, c) {
5203
+ super(t, c.getLength()), this.origin = s, this.left = e, this.right = i, this.rightOrigin = r, this.parent = o, this.parentSub = l, this.redone = null, this.content = c, this.info = this.content.isCountable() ? hn : 0;
5204
5204
  }
5205
5205
  /**
5206
5206
  * This is used to mark the item as an indexed fast-search marker
@@ -5217,10 +5217,10 @@ class C extends tn {
5217
5217
  * If true, do not garbage collect this Item.
5218
5218
  */
5219
5219
  get keep() {
5220
- return (this.info & ln) > 0;
5220
+ return (this.info & cn) > 0;
5221
5221
  }
5222
5222
  set keep(t) {
5223
- this.keep !== t && (this.info ^= ln);
5223
+ this.keep !== t && (this.info ^= cn);
5224
5224
  }
5225
5225
  get countable() {
5226
5226
  return (this.info & hn) > 0;
@@ -5246,11 +5246,11 @@ class C extends tn {
5246
5246
  * @return {null | number}
5247
5247
  */
5248
5248
  getMissing(t, e) {
5249
- if (this.origin && this.origin.client !== this.id.client && this.origin.clock >= I(e, this.origin.client))
5249
+ if (this.origin && this.origin.client !== this.id.client && this.origin.clock >= A(e, this.origin.client))
5250
5250
  return this.origin.client;
5251
- if (this.rightOrigin && this.rightOrigin.client !== this.id.client && this.rightOrigin.clock >= I(e, this.rightOrigin.client))
5251
+ if (this.rightOrigin && this.rightOrigin.client !== this.id.client && this.rightOrigin.clock >= A(e, this.rightOrigin.client))
5252
5252
  return this.rightOrigin.client;
5253
- if (this.parent && this.parent.constructor === at && this.id.client !== this.parent.client && this.parent.clock >= I(e, this.parent.client))
5253
+ if (this.parent && this.parent.constructor === at && this.id.client !== this.parent.client && this.parent.clock >= A(e, this.parent.client))
5254
5254
  return this.parent.client;
5255
5255
  if (this.origin && (this.left = bn(t, e, this.origin), this.origin = this.left.lastId), this.rightOrigin && (this.right = q(t, this.rightOrigin), this.rightOrigin = this.right.id), (this.left && this.left.constructor === U || this.right && this.right.constructor === U) && (this.parent = null), !this.parent)
5256
5256
  this.left && this.left.constructor === C && (this.parent = this.left.parent, this.parentSub = this.left.parentSub), this.right && this.right.constructor === C && (this.parent = this.right.parent, this.parentSub = this.right.parentSub);
@@ -5268,28 +5268,28 @@ class C extends tn {
5268
5268
  integrate(t, e) {
5269
5269
  if (e > 0 && (this.id.clock += e, this.left = bn(t, t.doc.store, k(this.id.client, this.id.clock - 1)), this.origin = this.left.lastId, this.content = this.content.splice(e), this.length -= e), this.parent) {
5270
5270
  if (!this.left && (!this.right || this.right.left !== null) || this.left && this.left.right !== this.right) {
5271
- let s = this.left, r;
5271
+ let s = this.left, i;
5272
5272
  if (s !== null)
5273
- r = s.right;
5273
+ i = s.right;
5274
5274
  else if (this.parentSub !== null)
5275
- for (r = /** @type {AbstractType<any>} */
5276
- this.parent._map.get(this.parentSub) || null; r !== null && r.left !== null; )
5277
- r = r.left;
5275
+ for (i = /** @type {AbstractType<any>} */
5276
+ this.parent._map.get(this.parentSub) || null; i !== null && i.left !== null; )
5277
+ i = i.left;
5278
5278
  else
5279
- r = /** @type {AbstractType<any>} */
5279
+ i = /** @type {AbstractType<any>} */
5280
5280
  this.parent._start;
5281
- const i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
5282
- for (; r !== null && r !== this.right; ) {
5283
- if (o.add(r), i.add(r), Ft(this.origin, r.origin)) {
5284
- if (r.id.client < this.id.client)
5285
- s = r, i.clear();
5286
- else if (Ft(this.rightOrigin, r.rightOrigin))
5281
+ const r = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
5282
+ for (; i !== null && i !== this.right; ) {
5283
+ if (o.add(i), r.add(i), Ft(this.origin, i.origin)) {
5284
+ if (i.id.client < this.id.client)
5285
+ s = i, r.clear();
5286
+ else if (Ft(this.rightOrigin, i.rightOrigin))
5287
5287
  break;
5288
- } else if (r.origin !== null && o.has(me(t.doc.store, r.origin)))
5289
- i.has(me(t.doc.store, r.origin)) || (s = r, i.clear());
5288
+ } else if (i.origin !== null && o.has(me(t.doc.store, i.origin)))
5289
+ r.has(me(t.doc.store, i.origin)) || (s = i, r.clear());
5290
5290
  else
5291
5291
  break;
5292
- r = r.right;
5292
+ i = i.right;
5293
5293
  }
5294
5294
  this.left = s;
5295
5295
  }
@@ -5307,7 +5307,7 @@ class C extends tn {
5307
5307
  this.parent._start, this.parent._start = this;
5308
5308
  this.right = s;
5309
5309
  }
5310
- 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), is(t.doc.store, this), this.content.integrate(t, this), Sn(
5310
+ 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), rs(t.doc.store, this), this.content.integrate(t, this), Sn(
5311
5311
  t,
5312
5312
  /** @type {AbstractType<any>} */
5313
5313
  this.parent,
@@ -5371,7 +5371,7 @@ class C extends tn {
5371
5371
  /** @type {AbstractType<any>} */
5372
5372
  this.parent
5373
5373
  );
5374
- this.countable && this.parentSub === null && (e._length -= this.length), this.markDeleted(), Kt(t.deleteSet, this.id.client, this.id.clock, this.length), Sn(t, e, this.parentSub), this.content.delete(t);
5374
+ this.countable && this.parentSub === null && (e._length -= this.length), this.markDeleted(), zt(t.deleteSet, this.id.client, this.id.clock, this.length), Sn(t, e, this.parentSub), this.content.delete(t);
5375
5375
  }
5376
5376
  }
5377
5377
  /**
@@ -5381,7 +5381,7 @@ class C extends tn {
5381
5381
  gc(t, e) {
5382
5382
  if (!this.deleted)
5383
5383
  throw H();
5384
- this.content.gc(t), e ? xi(t, this, new U(this.id, this.length)) : this.content = new Ot(this.length);
5384
+ this.content.gc(t), e ? xr(t, this, new U(this.id, this.length)) : this.content = new Ot(this.length);
5385
5385
  }
5386
5386
  /**
5387
5387
  * Transform the properties of this type to binary and write it to an
@@ -5393,24 +5393,24 @@ class C extends tn {
5393
5393
  * @param {number} offset
5394
5394
  */
5395
5395
  write(t, e) {
5396
- const s = e > 0 ? k(this.id.client, this.id.clock + e - 1) : this.origin, r = this.rightOrigin, i = this.parentSub, o = this.content.getRef() & se | (s === null ? 0 : M) | // origin is defined
5397
- (r === null ? 0 : $) | // right origin is defined
5398
- (i === null ? 0 : At);
5399
- if (t.writeInfo(o), s !== null && t.writeLeftID(s), r !== null && t.writeRightID(r), s === null && r === null) {
5400
- const c = (
5396
+ const s = e > 0 ? k(this.id.client, this.id.clock + e - 1) : this.origin, i = this.rightOrigin, r = this.parentSub, o = this.content.getRef() & se | (s === null ? 0 : M) | // origin is defined
5397
+ (i === null ? 0 : $) | // right origin is defined
5398
+ (r === null ? 0 : It);
5399
+ if (t.writeInfo(o), s !== null && t.writeLeftID(s), i !== null && t.writeRightID(i), s === null && i === null) {
5400
+ const l = (
5401
5401
  /** @type {AbstractType<any>} */
5402
5402
  this.parent
5403
5403
  );
5404
- if (c._item !== void 0) {
5405
- const l = c._item;
5406
- if (l === null) {
5407
- const a = Ai(c);
5404
+ if (l._item !== void 0) {
5405
+ const c = l._item;
5406
+ if (c === null) {
5407
+ const a = Ir(l);
5408
5408
  t.writeParentInfo(!0), t.writeString(a);
5409
5409
  } else
5410
- t.writeParentInfo(!1), t.writeLeftID(l.id);
5410
+ t.writeParentInfo(!1), t.writeLeftID(c.id);
5411
5411
  } else
5412
- c.constructor === String ? (t.writeParentInfo(!0), t.writeString(c)) : c.constructor === at ? (t.writeParentInfo(!1), t.writeLeftID(c)) : H();
5413
- i !== null && t.writeString(i);
5412
+ l.constructor === String ? (t.writeParentInfo(!0), t.writeString(l)) : l.constructor === at ? (t.writeParentInfo(!1), t.writeLeftID(l)) : H();
5413
+ r !== null && t.writeString(r);
5414
5414
  }
5415
5415
  this.content.write(t, e);
5416
5416
  }
@@ -5420,7 +5420,7 @@ const Es = (n, t) => Do[t & se](n), Do = [
5420
5420
  H();
5421
5421
  },
5422
5422
  // GC is not ItemContent
5423
- co,
5423
+ lo,
5424
5424
  // 1
5425
5425
  uo,
5426
5426
  // 2
@@ -5436,7 +5436,7 @@ const Es = (n, t) => Do[t & se](n), Do = [
5436
5436
  // 7
5437
5437
  fo,
5438
5438
  // 8
5439
- lo,
5439
+ co,
5440
5440
  // 9
5441
5441
  () => {
5442
5442
  H();
@@ -5479,31 +5479,31 @@ class v extends tn {
5479
5479
  return null;
5480
5480
  }
5481
5481
  }
5482
- const Is = (
5482
+ const As = (
5483
5483
  /** @type {any} */
5484
5484
  typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : {}
5485
- ), As = "__ $YJS$ __";
5486
- Is[As] === !0 && console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");
5487
- Is[As] = !0;
5485
+ ), Is = "__ $YJS$ __";
5486
+ As[Is] === !0 && console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");
5487
+ As[Is] = !0;
5488
5488
  const Ls = 0, en = 1, xs = 2, ve = (n, t) => {
5489
5489
  p(n, Ls);
5490
- const e = Ei(t);
5490
+ const e = Er(t);
5491
5491
  S(n, e);
5492
5492
  }, Ms = (n, t, e) => {
5493
- p(n, en), S(n, _i(t, e));
5494
- }, Io = (n, t, e) => Ms(t, e, L(n)), Us = (n, t, e) => {
5493
+ p(n, en), S(n, _r(t, e));
5494
+ }, Ao = (n, t, e) => Ms(t, e, L(n)), Us = (n, t, e) => {
5495
5495
  try {
5496
- yi(t, L(n), e);
5496
+ yr(t, L(n), e);
5497
5497
  } catch (s) {
5498
5498
  console.error("Caught error while handling a Yjs update", s);
5499
5499
  }
5500
- }, Ao = (n, t) => {
5500
+ }, Io = (n, t) => {
5501
5501
  p(n, xs), S(n, t);
5502
5502
  }, Lo = Us, xo = (n, t, e, s) => {
5503
- const r = w(n);
5504
- switch (r) {
5503
+ const i = w(n);
5504
+ switch (i) {
5505
5505
  case Ls:
5506
- Io(n, t, e);
5506
+ Ao(n, t, e);
5507
5507
  break;
5508
5508
  case en:
5509
5509
  Us(n, e, s);
@@ -5514,14 +5514,14 @@ const Ls = 0, en = 1, xs = 2, ve = (n, t) => {
5514
5514
  default:
5515
5515
  throw new Error("Unknown message type");
5516
5516
  }
5517
- return r;
5517
+ return i;
5518
5518
  }, Mo = 0, Uo = (n, t, e) => {
5519
5519
  switch (w(n)) {
5520
5520
  case Mo:
5521
- e(t, z(n));
5521
+ e(t, W(n));
5522
5522
  }
5523
5523
  }, be = 3e4;
5524
- class vo extends Ye {
5524
+ class vo extends Ke {
5525
5525
  /**
5526
5526
  * @param {Y.Doc} doc
5527
5527
  */
@@ -5532,8 +5532,8 @@ class vo extends Ye {
5532
5532
  this.getLocalState() !== null && be / 2 <= e - /** @type {{lastUpdated:number}} */
5533
5533
  this.meta.get(this.clientID).lastUpdated && this.setLocalState(this.getLocalState());
5534
5534
  const s = [];
5535
- this.meta.forEach((r, i) => {
5536
- i !== this.clientID && be <= e - r.lastUpdated && this.states.has(i) && s.push(i);
5535
+ this.meta.forEach((i, r) => {
5536
+ r !== this.clientID && be <= e - i.lastUpdated && this.states.has(r) && s.push(r);
5537
5537
  }), s.length > 0 && nn(this, s, "timeout");
5538
5538
  }, j(be / 10)), t.on("destroy", () => {
5539
5539
  this.destroy();
@@ -5552,13 +5552,13 @@ class vo extends Ye {
5552
5552
  * @param {Object<string,any>|null} state
5553
5553
  */
5554
5554
  setLocalState(t) {
5555
- const e = this.clientID, s = this.meta.get(e), r = s === void 0 ? 0 : s.clock + 1, i = this.states.get(e);
5555
+ const e = this.clientID, s = this.meta.get(e), i = s === void 0 ? 0 : s.clock + 1, r = this.states.get(e);
5556
5556
  t === null ? this.states.delete(e) : this.states.set(e, t), this.meta.set(e, {
5557
- clock: r,
5557
+ clock: i,
5558
5558
  lastUpdated: st()
5559
5559
  });
5560
- const o = [], c = [], l = [], a = [];
5561
- t === null ? a.push(e) : i == null ? t != null && o.push(e) : (c.push(e), Dt(i, t) || l.push(e)), (o.length > 0 || l.length > 0 || a.length > 0) && this.emit("change", [{ added: o, updated: l, removed: a }, "local"]), this.emit("update", [{ added: o, updated: c, removed: a }, "local"]);
5560
+ const o = [], l = [], c = [], a = [];
5561
+ t === null ? a.push(e) : r == null ? t != null && o.push(e) : (l.push(e), Dt(r, t) || c.push(e)), (o.length > 0 || c.length > 0 || a.length > 0) && this.emit("change", [{ added: o, updated: c, removed: a }, "local"]), this.emit("update", [{ added: o, updated: l, removed: a }, "local"]);
5562
5562
  }
5563
5563
  /**
5564
5564
  * @param {string} field
@@ -5580,72 +5580,72 @@ class vo extends Ye {
5580
5580
  }
5581
5581
  const nn = (n, t, e) => {
5582
5582
  const s = [];
5583
- for (let r = 0; r < t.length; r++) {
5584
- const i = t[r];
5585
- if (n.states.has(i)) {
5586
- if (n.states.delete(i), i === n.clientID) {
5583
+ for (let i = 0; i < t.length; i++) {
5584
+ const r = t[i];
5585
+ if (n.states.has(r)) {
5586
+ if (n.states.delete(r), r === n.clientID) {
5587
5587
  const o = (
5588
5588
  /** @type {MetaClientState} */
5589
- n.meta.get(i)
5589
+ n.meta.get(r)
5590
5590
  );
5591
- n.meta.set(i, {
5591
+ n.meta.set(r, {
5592
5592
  clock: o.clock + 1,
5593
5593
  lastUpdated: st()
5594
5594
  });
5595
5595
  }
5596
- s.push(i);
5596
+ s.push(r);
5597
5597
  }
5598
5598
  }
5599
5599
  s.length > 0 && (n.emit("change", [{ added: [], updated: [], removed: s }, e]), n.emit("update", [{ added: [], updated: [], removed: s }, e]));
5600
5600
  }, Et = (n, t, e = n.states) => {
5601
- const s = t.length, r = x();
5602
- p(r, s);
5603
- for (let i = 0; i < s; i++) {
5604
- const o = t[i], c = e.get(o) || null, l = (
5601
+ const s = t.length, i = x();
5602
+ p(i, s);
5603
+ for (let r = 0; r < s; r++) {
5604
+ const o = t[r], l = e.get(o) || null, c = (
5605
5605
  /** @type {MetaClientState} */
5606
5606
  n.meta.get(o).clock
5607
5607
  );
5608
- p(r, o), p(r, l), et(r, JSON.stringify(c));
5608
+ p(i, o), p(i, c), et(i, JSON.stringify(l));
5609
5609
  }
5610
- return _(r);
5610
+ return _(i);
5611
5611
  }, Oo = (n, t, e) => {
5612
- const s = Q(t), r = st(), i = [], o = [], c = [], l = [], a = w(s);
5612
+ const s = Q(t), i = st(), r = [], o = [], l = [], c = [], a = w(s);
5613
5613
  for (let h = 0; h < a; h++) {
5614
5614
  const u = w(s);
5615
5615
  let d = w(s);
5616
- const f = JSON.parse(z(s)), g = n.meta.get(u), y = n.states.get(u), O = g === void 0 ? 0 : g.clock;
5616
+ const f = JSON.parse(W(s)), g = n.meta.get(u), y = n.states.get(u), O = g === void 0 ? 0 : g.clock;
5617
5617
  (O < d || O === d && f === null && n.states.has(u)) && (f === null ? u === n.clientID && n.getLocalState() != null ? d++ : n.states.delete(u) : n.states.set(u, f), n.meta.set(u, {
5618
5618
  clock: d,
5619
- lastUpdated: r
5620
- }), g === void 0 && f !== null ? i.push(u) : g !== void 0 && f === null ? l.push(u) : f !== null && (Dt(f, y) || c.push(u), o.push(u)));
5621
- }
5622
- (i.length > 0 || c.length > 0 || l.length > 0) && n.emit("change", [{
5623
- added: i,
5624
- updated: c,
5625
- removed: l
5626
- }, e]), (i.length > 0 || o.length > 0 || l.length > 0) && n.emit("update", [{
5627
- added: i,
5619
+ lastUpdated: i
5620
+ }), g === void 0 && f !== null ? r.push(u) : g !== void 0 && f === null ? c.push(u) : f !== null && (Dt(f, y) || l.push(u), o.push(u)));
5621
+ }
5622
+ (r.length > 0 || l.length > 0 || c.length > 0) && n.emit("change", [{
5623
+ added: r,
5624
+ updated: l,
5625
+ removed: c
5626
+ }, e]), (r.length > 0 || o.length > 0 || c.length > 0) && n.emit("update", [{
5627
+ added: r,
5628
5628
  updated: o,
5629
- removed: l
5629
+ removed: c
5630
5630
  }, e]);
5631
- }, To = (n) => nr(n, (t, e) => `${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&");
5631
+ }, To = (n) => ni(n, (t, e) => `${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&");
5632
5632
  var P = 0, vs = 3, dt = 1, Ro = 2;
5633
5633
  function No(n, t) {
5634
5634
  if (!n)
5635
5635
  throw new Error(t);
5636
5636
  }
5637
5637
  var Bt = [];
5638
- Bt[P] = (n, t, e, s, r) => {
5638
+ Bt[P] = (n, t, e, s, i) => {
5639
5639
  p(n, P);
5640
- const i = xo(
5640
+ const r = xo(
5641
5641
  t,
5642
5642
  n,
5643
5643
  e.doc,
5644
5644
  e
5645
5645
  );
5646
- s && i === en && !e.synced && (e.synced = !0);
5646
+ s && r === en && !e.synced && (e.synced = !0);
5647
5647
  };
5648
- Bt[vs] = (n, t, e, s, r) => {
5648
+ Bt[vs] = (n, t, e, s, i) => {
5649
5649
  p(n, dt), S(
5650
5650
  n,
5651
5651
  Et(
@@ -5654,28 +5654,28 @@ Bt[vs] = (n, t, e, s, r) => {
5654
5654
  )
5655
5655
  );
5656
5656
  };
5657
- Bt[dt] = (n, t, e, s, r) => {
5657
+ Bt[dt] = (n, t, e, s, i) => {
5658
5658
  Oo(
5659
5659
  e.awareness,
5660
5660
  L(t),
5661
5661
  e
5662
5662
  );
5663
5663
  };
5664
- Bt[Ro] = (n, t, e, s, r) => {
5664
+ Bt[Ro] = (n, t, e, s, i) => {
5665
5665
  Uo(
5666
5666
  t,
5667
5667
  e.doc,
5668
- (i, o) => Ho(e, o)
5668
+ (r, o) => Ho(e, o)
5669
5669
  );
5670
5670
  };
5671
- var In = 3e4;
5671
+ var An = 3e4;
5672
5672
  function Ho(n, t) {
5673
5673
  console.warn(`Permission denied to access ${n.url}.
5674
5674
  ${t}`);
5675
5675
  }
5676
5676
  function Os(n, t, e) {
5677
- const s = Q(t), r = x(), i = w(s), o = n.messageHandlers[i];
5678
- return /** @type {any} */ o ? o(r, s, n, e, i) : console.error("Unable to compute message"), r;
5677
+ const s = Q(t), i = x(), r = w(s), o = n.messageHandlers[r];
5678
+ return /** @type {any} */ o ? o(i, s, n, e, r) : console.error("Unable to compute message"), i;
5679
5679
  }
5680
5680
  function Ts(n) {
5681
5681
  if (n.shouldConnect && n.ws === null) {
@@ -5704,7 +5704,7 @@ function Ts(n) {
5704
5704
  ])) : n.wsUnsuccessfulReconnects++, setTimeout(
5705
5705
  Ts,
5706
5706
  Re(
5707
- dr(2, n.wsUnsuccessfulReconnects) * 100,
5707
+ di(2, n.wsUnsuccessfulReconnects) * 100,
5708
5708
  n.maxBackoffTime
5709
5709
  ),
5710
5710
  n
@@ -5736,14 +5736,14 @@ function _e(n, t) {
5736
5736
  const e = n.ws;
5737
5737
  n.wsconnected && e && e.readyState === e.OPEN && e.send(t), n.bcconnected && ht(n.bcChannel, t, n);
5738
5738
  }
5739
- var Vo = class extends Ye {
5739
+ var Vo = class extends Ke {
5740
5740
  constructor(t, e, s, {
5741
- connect: r = !0,
5742
- awareness: i = new vo(s),
5741
+ connect: i = !0,
5742
+ awareness: r = new vo(s),
5743
5743
  params: o = {},
5744
- WebSocketPolyfill: c = WebSocket,
5744
+ WebSocketPolyfill: l = WebSocket,
5745
5745
  // Optionally provide a WebSocket polyfill
5746
- resyncInterval: l = -1,
5746
+ resyncInterval: c = -1,
5747
5747
  // Request server state every `resyncInterval` milliseconds
5748
5748
  maxBackoffTime: a = 2500,
5749
5749
  // Maximum amount of time to wait before trying to reconnect (we try to reconnect using exponential backoff)
@@ -5778,13 +5778,13 @@ var Vo = class extends Ye {
5778
5778
  for (; t[t.length - 1] === "/"; )
5779
5779
  t = t.slice(0, t.length - 1);
5780
5780
  const u = To(o);
5781
- this.maxBackoffTime = a, this.bcChannel = t + "/" + e, this.url = t + "/" + e + (u.length === 0 ? "" : "?" + u), this.roomname = e, this.doc = s, this._WS = c, this.awareness = i, this.wsconnected = !1, this.wsconnecting = !1, this.bcconnected = !1, this.disableBc = h, this.wsUnsuccessfulReconnects = 0, this.messageHandlers = Bt.slice(), this._synced = !1, this.ws = null, this.wsLastMessageReceived = 0, this.shouldConnect = r, this._resyncInterval = 0, l > 0 && (this._resyncInterval = /** @type {any} */
5781
+ this.maxBackoffTime = a, this.bcChannel = t + "/" + e, this.url = t + "/" + e + (u.length === 0 ? "" : "?" + u), this.roomname = e, this.doc = s, this._WS = l, this.awareness = r, this.wsconnected = !1, this.wsconnecting = !1, this.bcconnected = !1, this.disableBc = h, this.wsUnsuccessfulReconnects = 0, this.messageHandlers = Bt.slice(), this._synced = !1, this.ws = null, this.wsLastMessageReceived = 0, this.shouldConnect = i, this._resyncInterval = 0, c > 0 && (this._resyncInterval = /** @type {any} */
5782
5782
  setInterval(() => {
5783
5783
  if (this.ws && this.ws.readyState === WebSocket.OPEN) {
5784
5784
  const d = x();
5785
5785
  p(d, P), ve(d, s), this.ws.send(_(d));
5786
5786
  }
5787
- }, l)), this._bcSubscriber = (d, f) => {
5787
+ }, c)), this._bcSubscriber = (d, f) => {
5788
5788
  if (f !== this) {
5789
5789
  const g = Os(this, new Uint8Array(d), !1);
5790
5790
  Ne(g) > 1 && ht(this.bcChannel, _(g), this);
@@ -5792,13 +5792,13 @@ var Vo = class extends Ye {
5792
5792
  }, this._updateHandler = (d, f) => {
5793
5793
  if (f !== this) {
5794
5794
  const g = x();
5795
- p(g, P), Ao(g, d), _e(this, _(g));
5795
+ p(g, P), Io(g, d), _e(this, _(g));
5796
5796
  }
5797
5797
  }, this.doc.on("update", this._updateHandler), this._awarenessUpdateHandler = ({ added: d, updated: f, removed: g }, y) => {
5798
5798
  const O = d.concat(f).concat(g), ae = x();
5799
5799
  p(ae, dt), S(
5800
5800
  ae,
5801
- Et(i, O)
5801
+ Et(r, O)
5802
5802
  ), _e(this, _(ae));
5803
5803
  }, this._unloadHandler = () => {
5804
5804
  nn(
@@ -5806,10 +5806,10 @@ var Vo = class extends Ye {
5806
5806
  [s.clientID],
5807
5807
  "window unload"
5808
5808
  );
5809
- }, typeof window < "u" ? window.addEventListener("unload", this._unloadHandler) : typeof process < "u" && process.on("exit", this._unloadHandler), i.on("update", this._awarenessUpdateHandler), this._checkInterval = /** @type {any} */
5809
+ }, typeof window < "u" ? window.addEventListener("unload", this._unloadHandler) : typeof process < "u" && process.on("exit", this._unloadHandler), r.on("update", this._awarenessUpdateHandler), this._checkInterval = /** @type {any} */
5810
5810
  setInterval(() => {
5811
- this.wsconnected && In < st() - this.wsLastMessageReceived && (No(this.ws !== null, "ws must not be null"), this.ws.close());
5812
- }, In / 10), r && this.connect();
5811
+ this.wsconnected && An < st() - this.wsLastMessageReceived && (No(this.ws !== null, "ws must not be null"), this.ws.close());
5812
+ }, An / 10), i && this.connect();
5813
5813
  }
5814
5814
  /**
5815
5815
  * @type {boolean}
@@ -5826,7 +5826,7 @@ var Vo = class extends Ye {
5826
5826
  connectBc() {
5827
5827
  if (this.disableBc)
5828
5828
  return;
5829
- this.bcconnected || (Yr(this.bcChannel, this._bcSubscriber), this.bcconnected = !0);
5829
+ this.bcconnected || (Ki(this.bcChannel, this._bcSubscriber), this.bcconnected = !0);
5830
5830
  const t = x();
5831
5831
  p(t, P), ve(t, this.doc), ht(this.bcChannel, _(t), this);
5832
5832
  const e = x();
@@ -5837,15 +5837,15 @@ var Vo = class extends Ye {
5837
5837
  _(s),
5838
5838
  this
5839
5839
  );
5840
- const r = x();
5841
- p(r, dt), S(
5842
- r,
5840
+ const i = x();
5841
+ p(i, dt), S(
5842
+ i,
5843
5843
  Et(this.awareness, [
5844
5844
  this.doc.clientID
5845
5845
  ])
5846
5846
  ), ht(
5847
5847
  this.bcChannel,
5848
- _(r),
5848
+ _(i),
5849
5849
  this
5850
5850
  );
5851
5851
  }
@@ -5858,7 +5858,7 @@ var Vo = class extends Ye {
5858
5858
  [this.doc.clientID],
5859
5859
  /* @__PURE__ */ new Map()
5860
5860
  )
5861
- ), _e(this, _(t)), this.bcconnected && (Xr(this.bcChannel, this._bcSubscriber), this.bcconnected = !1);
5861
+ ), _e(this, _(t)), this.bcconnected && (Yi(this.bcChannel, this._bcSubscriber), this.bcconnected = !1);
5862
5862
  }
5863
5863
  disconnect() {
5864
5864
  this.shouldConnect = !1, this.disconnectBc(), this.ws !== null && this.ws.close();
@@ -5867,7 +5867,7 @@ var Vo = class extends Ye {
5867
5867
  this.shouldConnect = !0, !this.wsconnected && this.ws === null && (Ts(this), this.connectBc());
5868
5868
  }
5869
5869
  };
5870
- function An() {
5870
+ function In() {
5871
5871
  if (crypto.randomUUID)
5872
5872
  return crypto.randomUUID();
5873
5873
  let n = (/* @__PURE__ */ new Date()).getTime(), t = typeof performance < "u" && performance.now && performance.now() * 1e3 || 0;
@@ -5878,41 +5878,74 @@ function An() {
5878
5878
  }
5879
5879
  var Bo = class extends Vo {
5880
5880
  constructor(n, t, e, s = {}) {
5881
- const r = `${n.startsWith("localhost:") || n.startsWith("127.0.0.1:") ? "ws" : "wss"}://${n}/party`;
5881
+ const i = `${n.startsWith("localhost:") || n.startsWith("127.0.0.1:") ? "ws" : "wss"}://${n}/party`;
5882
5882
  s.params === void 0 ? s.params = {
5883
- _pk: An()
5884
- } : s.params._pk = An(), super(r, t, e, s);
5883
+ _pk: In()
5884
+ } : s.params._pk = In(), super(i, t, e, s);
5885
5885
  }
5886
5886
  };
5887
5887
  var Z = /* @__PURE__ */ ((n) => (n.CanMove = "can-move", n.CanSpin = "can-spin", n.CanGrow = "can-grow", n))(Z || {});
5888
- const Fo = (n, t = 300) => {
5889
- let e;
5890
- return function(...s) {
5891
- clearTimeout(e), e = setTimeout(() => n.apply(this, s), t);
5892
- };
5888
+ const Fo = {
5889
+ ctrlKey: "Control",
5890
+ altKey: "Alt",
5891
+ shiftKey: "Shift",
5892
+ metaKey: "Meta"
5893
5893
  };
5894
5894
  class sn {
5895
- // TODO: fix this optional thing
5896
- constructor(t, e, s) {
5895
+ constructor(t, e, s, i) {
5897
5896
  m(this, "element");
5898
5897
  m(this, "_data");
5899
5898
  m(this, "onChange");
5900
5899
  m(this, "debouncedOnChange");
5901
- this.element = t, this.onChange = s, this.debouncedOnChange = Fo(this.onChange, 25), this._data = e, this.data = e;
5900
+ m(this, "resetShortcut");
5901
+ this.element = t, this.onChange = s, this.resetShortcut = i, this.debouncedOnChange = this.onChange, this._data = e, this.data = e, i && (t.title || (t.title = `Hold down the ${Fo[i]} key while clicking to reset.`), t.addEventListener("click", (r) => {
5902
+ switch (i) {
5903
+ case "ctrlKey":
5904
+ if (!r.ctrlKey)
5905
+ return;
5906
+ break;
5907
+ case "altKey":
5908
+ if (!r.altKey)
5909
+ return;
5910
+ break;
5911
+ case "shiftKey":
5912
+ if (!r.shiftKey)
5913
+ return;
5914
+ break;
5915
+ case "metaKey":
5916
+ if (!r.metaKey)
5917
+ return;
5918
+ break;
5919
+ default:
5920
+ return;
5921
+ }
5922
+ this.reset();
5923
+ }));
5902
5924
  }
5903
5925
  get data() {
5904
5926
  return this._data;
5905
5927
  }
5928
+ /**
5929
+ * Updates the internal state with the given data and handles all the downstream effects
5930
+ * (e.g. calling `updateElement` and `onChange`)
5931
+ */
5906
5932
  set data(t) {
5907
5933
  this._data = t, this.updateElement(t), this.debouncedOnChange(t);
5908
5934
  }
5935
+ /**
5936
+ * Resets the element to its default state.
5937
+ */
5938
+ reset() {
5939
+ this.data = this.initialData;
5940
+ }
5909
5941
  }
5910
5942
  class Ln extends sn {
5911
- constructor(e, s = 0, r) {
5912
- super(e, s, r);
5943
+ constructor(e, s = 0, i) {
5944
+ super(e, s, i, "shiftKey");
5913
5945
  m(this, "isDown");
5914
5946
  m(this, "startX");
5915
- this.isDown = !1, this.startX = 0, this.element.addEventListener("mousedown", (i) => this.mouseDownHandler(i)), document.addEventListener("mousemove", (i) => this.mouseMoveHandler(i)), document.addEventListener("mouseup", (i) => this.mouseUpHandler(i));
5947
+ m(this, "initialData", 0);
5948
+ this.isDown = !1, this.startX = 0, this.element.addEventListener("mousedown", (r) => this.mouseDownHandler(r)), document.addEventListener("mousemove", (r) => this.mouseMoveHandler(r)), document.addEventListener("mouseup", (r) => this.mouseUpHandler(r));
5916
5949
  }
5917
5950
  updateElement(e) {
5918
5951
  this.element.style.transform = `rotate(${e}deg)`;
@@ -5932,12 +5965,16 @@ class Ln extends sn {
5932
5965
  }
5933
5966
  }
5934
5967
  class xn extends sn {
5935
- constructor(e, s = { x: 0, y: 0 }, r) {
5936
- super(e, s, r);
5968
+ constructor(e, s = { x: 0, y: 0 }, i) {
5969
+ super(e, s, i, "shiftKey");
5970
+ m(this, "initialData", { x: 0, y: 0 });
5937
5971
  m(this, "isDown");
5938
5972
  m(this, "startMouseX");
5939
5973
  m(this, "startMouseY");
5940
- this.isDown = !1, this.startMouseX = 0, this.startMouseY = 0, this.element.addEventListener("mousedown", (i) => this.mouseDownHandler(i)), document.addEventListener("mousemove", (i) => this.mouseMoveHandler(i)), document.addEventListener("mouseup", (i) => this.mouseUpHandler(i));
5974
+ this.isDown = !1, this.startMouseX = 0, this.startMouseY = 0, this.updateDisplay(), this.element.addEventListener("mousedown", (r) => this.mouseDownHandler(r)), document.addEventListener("mousemove", (r) => this.mouseMoveHandler(r)), document.addEventListener("mouseup", (r) => this.mouseUpHandler(r));
5975
+ }
5976
+ updateDisplay() {
5977
+ this.element.style.display === "inline" && (this.element.style.display = "inline-block");
5941
5978
  }
5942
5979
  updateElement({ x: e, y: s }) {
5943
5980
  this.element.style.transform = `translate(${e}px, ${s}px)`;
@@ -5956,15 +5993,16 @@ class xn extends sn {
5956
5993
  }
5957
5994
  }
5958
5995
  class Mn extends sn {
5959
- constructor(e, s = 1, r, i = 2) {
5960
- super(e, s, r);
5996
+ constructor(e, s = 1, i, r = 2) {
5997
+ super(e, s, i, "shiftKey");
5998
+ m(this, "initialData", 1);
5961
5999
  m(this, "maxScale");
5962
6000
  m(this, "originalCursor", `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='44' height='53' viewport='0 0 100 100' style='fill:black;font-size:26px;'><text y='40%'>🚿</text></svg>")
5963
6001
  16 0,
5964
6002
  auto`);
5965
6003
  m(this, "cutCursor", `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='48' viewport='0 0 100 100' style='fill:black;font-size:24px;'><text y='50%'>✂️</text></svg>") 16 0,auto`);
5966
6004
  m(this, "isHovering", !1);
5967
- this.maxScale = i, e.addEventListener("mouseenter", (o) => this.mouseOverHandler(o)), e.addEventListener("mouseout", (o) => {
6005
+ this.maxScale = r, e.addEventListener("mouseenter", (o) => this.mouseOverHandler(o)), e.addEventListener("mouseout", (o) => {
5968
6006
  this.isHovering = !1;
5969
6007
  }), e.addEventListener("click", (o) => this.clickHandler(o)), document.addEventListener("keydown", (o) => {
5970
6008
  this.isHovering && this.mouseOverHandler(o);
@@ -6002,7 +6040,7 @@ class Mn extends sn {
6002
6040
  }
6003
6041
  }
6004
6042
  }
6005
- const $o = typeof PARTYKIT_HOST > "u" ? "localhost:1999" : PARTYKIT_HOST, Wt = new bt(), Rs = new Bo($o, "yjs-demo", Wt, {
6043
+ const $o = typeof PARTYKIT_HOST > "u" ? "localhost:1999" : PARTYKIT_HOST, Gt = new bt(), Rs = new Bo($o, window.location.href, Gt, {
6006
6044
  connect: !1
6007
6045
  });
6008
6046
  Rs.connect();
@@ -6011,123 +6049,126 @@ function Se(n) {
6011
6049
  }
6012
6050
  const jo = {
6013
6051
  [Z.CanMove]: (n) => {
6014
- const t = Wt.getMap(Z.CanMove), e = /* @__PURE__ */ new Map();
6015
- function s(r, i) {
6016
- const o = t.get(r) || { x: 0, y: 0 };
6017
- o.x === i.x && o.y === i.y || t.set(r, i);
6052
+ const t = Gt.getMap(Z.CanMove), e = /* @__PURE__ */ new Map();
6053
+ function s(i, r) {
6054
+ const o = t.get(i) || { x: 0, y: 0 };
6055
+ o.x === r.x && o.y === r.y || t.set(i, r);
6018
6056
  }
6019
- for (const r of n) {
6020
- const i = Se(r), o = t.get(i);
6057
+ for (const i of n) {
6058
+ const r = Se(i), o = t.get(r);
6021
6059
  e.set(
6022
- i,
6060
+ r,
6023
6061
  new xn(
6024
- r,
6062
+ i,
6025
6063
  o,
6026
- (c) => s(i, c)
6064
+ (l) => s(r, l)
6027
6065
  )
6028
6066
  );
6029
6067
  }
6030
- t.observe((r) => {
6031
- r.changes.keys.forEach((i, o) => {
6032
- if (i.action === "add")
6068
+ t.observe((i) => {
6069
+ i.changes.keys.forEach((r, o) => {
6070
+ if (r.action === "add")
6033
6071
  e.set(
6034
6072
  o,
6035
6073
  new xn(
6036
6074
  n[0],
6037
6075
  t.get(o),
6038
- (c) => s(o, c)
6076
+ (l) => s(o, l)
6039
6077
  )
6040
6078
  );
6041
- else if (i.action === "update") {
6042
- const c = e.get(o);
6043
- c.data = t.get(o);
6079
+ else if (r.action === "update") {
6080
+ const l = e.get(o);
6081
+ l.data = t.get(o);
6044
6082
  }
6045
6083
  });
6046
6084
  });
6047
6085
  },
6048
6086
  [Z.CanSpin]: (n) => {
6049
- const t = Wt.getMap(Z.CanSpin), e = /* @__PURE__ */ new Map();
6050
- function s(r, i) {
6051
- t.get(r) !== i && t.set(r, i);
6087
+ const t = Gt.getMap(Z.CanSpin), e = /* @__PURE__ */ new Map();
6088
+ function s(i, r) {
6089
+ t.get(i) !== r && t.set(i, r);
6052
6090
  }
6053
- for (const r of n) {
6054
- const i = Se(r), o = t.get(i) || 0;
6091
+ for (const i of n) {
6092
+ const r = Se(i), o = t.get(r) || 0;
6055
6093
  e.set(
6056
- i,
6094
+ r,
6057
6095
  new Ln(
6058
- r,
6096
+ i,
6059
6097
  o,
6060
- (c) => s(i, c)
6098
+ (l) => s(r, l)
6061
6099
  )
6062
6100
  );
6063
6101
  }
6064
- t.observe((r) => {
6065
- r.changes.keys.forEach((i, o) => {
6066
- if (i.action === "add")
6102
+ t.observe((i) => {
6103
+ i.changes.keys.forEach((r, o) => {
6104
+ if (r.action === "add")
6067
6105
  e.set(
6068
6106
  o,
6069
6107
  new Ln(
6070
6108
  n[0],
6071
6109
  t.get(o),
6072
- (c) => s(o, c)
6110
+ (l) => s(o, l)
6073
6111
  )
6074
6112
  );
6075
- else if (i.action === "update") {
6076
- const c = e.get(o);
6077
- c.data = t.get(o);
6113
+ else if (r.action === "update") {
6114
+ const l = e.get(o);
6115
+ l.data = t.get(o);
6078
6116
  }
6079
6117
  });
6080
6118
  });
6081
6119
  },
6082
6120
  [Z.CanGrow]: (n) => {
6083
- const t = Wt.getMap(Z.CanGrow), e = /* @__PURE__ */ new Map();
6084
- function s(r, i) {
6085
- t.get(r) !== i && t.set(r, i);
6121
+ const t = Gt.getMap(Z.CanGrow), e = /* @__PURE__ */ new Map();
6122
+ function s(i, r) {
6123
+ t.get(i) !== r && t.set(i, r);
6086
6124
  }
6087
- for (const r of n) {
6088
- const i = Se(r), o = t.get(i);
6125
+ for (const i of n) {
6126
+ const r = Se(i), o = t.get(r);
6089
6127
  e.set(
6090
- i,
6128
+ r,
6091
6129
  new Mn(
6092
- r,
6130
+ i,
6093
6131
  o,
6094
- (c) => s(i, c)
6132
+ (l) => s(r, l)
6095
6133
  )
6096
6134
  );
6097
6135
  }
6098
- t.observe((r) => {
6099
- r.changes.keys.forEach((i, o) => {
6100
- if (i.action === "add")
6136
+ t.observe((i) => {
6137
+ i.changes.keys.forEach((r, o) => {
6138
+ if (r.action === "add")
6101
6139
  e.set(
6102
6140
  o,
6103
6141
  new Mn(
6104
6142
  n[0],
6105
6143
  t.get(o),
6106
- (c) => s(o, c)
6144
+ (l) => s(o, l)
6107
6145
  )
6108
6146
  );
6109
- else if (i.action === "update") {
6110
- const c = e.get(o);
6111
- c.data = t.get(o);
6147
+ else if (r.action === "update") {
6148
+ const l = e.get(o);
6149
+ l.data = t.get(o);
6112
6150
  }
6113
6151
  });
6114
6152
  });
6115
6153
  }
6116
6154
  };
6117
6155
  Rs.on("sync", (n) => {
6118
- n || console.error("Issue connecting to yjs...");
6119
- for (const [t, e] of Object.entries(jo)) {
6120
- const s = Array.from(
6121
- document.querySelectorAll(`[${t}]`)
6122
- ).filter(Yo);
6123
- e(s), s.forEach((r) => {
6124
- r.classList.add("__playhtml-element"), r.classList.add(`__playhtml-${t}`);
6125
- });
6126
- }
6156
+ n || console.error("Issue connecting to yjs..."), Yo();
6127
6157
  });
6128
- function Yo(n) {
6158
+ function Ko(n) {
6129
6159
  return n instanceof HTMLElement;
6130
6160
  }
6161
+ function Yo() {
6162
+ for (const [n, t] of Object.entries(jo)) {
6163
+ const e = Array.from(
6164
+ document.querySelectorAll(`[${n}]`)
6165
+ ).filter(Ko);
6166
+ t(e), e.forEach((s) => {
6167
+ s.classList.add("__playhtml-element"), s.classList.add(`__playhtml-${n}`);
6168
+ });
6169
+ }
6170
+ }
6131
6171
  export {
6132
- jo as TagData
6172
+ jo as TagData,
6173
+ Yo as setupElements
6133
6174
  };