@editora/core 1.0.29 → 1.0.31

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.
@@ -1,7 +1,7 @@
1
- var pi = Object.defineProperty;
2
- var wi = (e, t, n) => t in e ? pi(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var oe = (e, t, n) => wi(e, typeof t != "symbol" ? t + "" : t, n);
4
- const $ = () => /* @__PURE__ */ new Map(), cn = (e) => {
1
+ var yi = Object.defineProperty;
2
+ var bi = (e, t, n) => t in e ? yi(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var oe = (e, t, n) => bi(e, typeof t != "symbol" ? t + "" : t, n);
4
+ const $ = () => /* @__PURE__ */ new Map(), ln = (e) => {
5
5
  const t = $();
6
6
  return e.forEach((n, s) => {
7
7
  t.set(s, n);
@@ -9,36 +9,36 @@ const $ = () => /* @__PURE__ */ new Map(), cn = (e) => {
9
9
  }, K = (e, t, n) => {
10
10
  let s = e.get(t);
11
11
  return s === void 0 && e.set(t, s = n()), s;
12
- }, mi = (e, t) => {
12
+ }, ki = (e, t) => {
13
13
  const n = [];
14
14
  for (const [s, r] of e)
15
15
  n.push(t(r, s));
16
16
  return n;
17
- }, yi = (e, t) => {
17
+ }, _i = (e, t) => {
18
18
  for (const [n, s] of e)
19
19
  if (t(s, n))
20
20
  return !0;
21
21
  return !1;
22
- }, it = () => /* @__PURE__ */ new Set(), Je = (e) => e[e.length - 1], bi = (e, t) => {
22
+ }, it = () => /* @__PURE__ */ new Set(), Ke = (e) => e[e.length - 1], Si = (e, t) => {
23
23
  for (let n = 0; n < t.length; n++)
24
24
  e.push(t[n]);
25
- }, q = Array.from, kn = (e, t) => {
25
+ }, q = Array.from, _n = (e, t) => {
26
26
  for (let n = 0; n < e.length; n++)
27
27
  if (!t(e[n], n, e))
28
28
  return !1;
29
29
  return !0;
30
- }, _n = (e, t) => {
30
+ }, Sn = (e, t) => {
31
31
  for (let n = 0; n < e.length; n++)
32
32
  if (t(e[n], n, e))
33
33
  return !0;
34
34
  return !1;
35
- }, ki = (e, t) => {
35
+ }, Ci = (e, t) => {
36
36
  const n = new Array(e);
37
37
  for (let s = 0; s < e; s++)
38
38
  n[s] = t(s, n);
39
39
  return n;
40
- }, Lt = Array.isArray;
41
- class Sn {
40
+ }, It = Array.isArray;
41
+ class Cn {
42
42
  constructor() {
43
43
  this._observers = $();
44
44
  }
@@ -100,7 +100,7 @@ class Sn {
100
100
  this._observers = $();
101
101
  }
102
102
  }
103
- class _i {
103
+ class Ei {
104
104
  constructor() {
105
105
  this._observers = $();
106
106
  }
@@ -145,60 +145,60 @@ class _i {
145
145
  this._observers = $();
146
146
  }
147
147
  }
148
- const z = Math.floor, he = Math.abs, Cn = (e, t) => e < t ? e : t, mt = (e, t) => e > t ? e : t, Si = Math.pow, Ms = (e) => e !== 0 ? e < 0 : 1 / e < 0, Zn = 1, ts = 2, Ke = 4, We = 8, zt = 32, X = 64, B = 128, ve = 31, ln = 63, ht = 127, Ci = 2147483647, we = Number.MAX_SAFE_INTEGER, es = Number.MIN_SAFE_INTEGER, Ei = Number.isInteger || ((e) => typeof e == "number" && isFinite(e) && z(e) === e), Us = String.fromCharCode, Di = (e) => e.toLowerCase(), Ai = /^\s*/g, Ti = (e) => e.replace(Ai, ""), xi = /([A-Z])/g, ns = (e, t) => Ti(e.replace(xi, (n) => `${t}${Di(n)}`)), Ii = (e) => {
148
+ const z = Math.floor, he = Math.abs, En = (e, t) => e < t ? e : t, mt = (e, t) => e > t ? e : t, Di = Math.pow, Rs = (e) => e !== 0 ? e < 0 : 1 / e < 0, ts = 1, es = 2, We = 4, Xe = 8, zt = 32, X = 64, B = 128, Oe = 31, an = 63, ht = 127, Ai = 2147483647, we = Number.MAX_SAFE_INTEGER, ns = Number.MIN_SAFE_INTEGER, Ti = Number.isInteger || ((e) => typeof e == "number" && isFinite(e) && z(e) === e), $s = String.fromCharCode, xi = (e) => e.toLowerCase(), Ii = /^\s*/g, Li = (e) => e.replace(Ii, ""), vi = /([A-Z])/g, ss = (e, t) => Li(e.replace(vi, (n) => `${t}${xi(n)}`)), Oi = (e) => {
149
149
  const t = unescape(encodeURIComponent(e)), n = t.length, s = new Uint8Array(n);
150
150
  for (let r = 0; r < n; r++)
151
151
  s[r] = /** @type {number} */
152
152
  t.codePointAt(r);
153
153
  return s;
154
- }, Yt = (
154
+ }, Pt = (
155
155
  /** @type {TextEncoder} */
156
156
  typeof TextEncoder != "undefined" ? new TextEncoder() : null
157
- ), Li = (e) => Yt.encode(e), Oi = Yt ? Li : Ii;
157
+ ), Ni = (e) => Pt.encode(e), Mi = Pt ? Ni : Oi;
158
158
  let jt = typeof TextDecoder == "undefined" ? null : new TextDecoder("utf-8", { fatal: !0, ignoreBOM: !0 });
159
159
  jt && jt.decode(new Uint8Array()).length === 1 && (jt = null);
160
- const vi = (e, t) => ki(t, () => e).join("");
160
+ const Ui = (e, t) => Ci(t, () => e).join("");
161
161
  class Zt {
162
162
  constructor() {
163
163
  this.cpos = 0, this.cbuf = new Uint8Array(100), this.bufs = [];
164
164
  }
165
165
  }
166
- const N = () => new Zt(), En = (e) => {
166
+ const N = () => new Zt(), Dn = (e) => {
167
167
  let t = e.cpos;
168
168
  for (let n = 0; n < e.bufs.length; n++)
169
169
  t += e.bufs[n].length;
170
170
  return t;
171
171
  }, C = (e) => {
172
- const t = new Uint8Array(En(e));
172
+ const t = new Uint8Array(Dn(e));
173
173
  let n = 0;
174
174
  for (let s = 0; s < e.bufs.length; s++) {
175
175
  const r = e.bufs[s];
176
176
  t.set(r, n), n += r.length;
177
177
  }
178
178
  return t.set(new Uint8Array(e.cbuf.buffer, 0, e.cpos), n), t;
179
- }, Ni = (e, t) => {
179
+ }, Ri = (e, t) => {
180
180
  const n = e.cbuf.length;
181
181
  n - e.cpos < t && (e.bufs.push(new Uint8Array(e.cbuf.buffer, 0, e.cpos)), e.cbuf = new Uint8Array(mt(n, t) * 2), e.cpos = 0);
182
182
  }, x = (e, t) => {
183
183
  const n = e.cbuf.length;
184
184
  e.cpos === n && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(n * 2), e.cpos = 0), e.cbuf[e.cpos++] = t;
185
- }, an = x, m = (e, t) => {
185
+ }, hn = x, m = (e, t) => {
186
186
  for (; t > ht; )
187
187
  x(e, B | ht & t), t = z(t / 128);
188
188
  x(e, ht & t);
189
- }, Dn = (e, t) => {
190
- const n = Ms(t);
191
- for (n && (t = -t), x(e, (t > ln ? B : 0) | (n ? X : 0) | ln & t), t = z(t / 64); t > 0; )
189
+ }, An = (e, t) => {
190
+ const n = Rs(t);
191
+ for (n && (t = -t), x(e, (t > an ? B : 0) | (n ? X : 0) | an & t), t = z(t / 64); t > 0; )
192
192
  x(e, (t > ht ? B : 0) | ht & t), t = z(t / 128);
193
- }, hn = new Uint8Array(3e4), Mi = hn.length / 3, Ui = (e, t) => {
194
- if (t.length < Mi) {
195
- const n = Yt.encodeInto(t, hn).written || 0;
193
+ }, un = new Uint8Array(3e4), $i = un.length / 3, Bi = (e, t) => {
194
+ if (t.length < $i) {
195
+ const n = Pt.encodeInto(t, un).written || 0;
196
196
  m(e, n);
197
197
  for (let s = 0; s < n; s++)
198
- x(e, hn[s]);
198
+ x(e, un[s]);
199
199
  } else
200
- E(e, Oi(t));
201
- }, Ri = (e, t) => {
200
+ E(e, Mi(t));
201
+ }, Fi = (e, t) => {
202
202
  const n = unescape(encodeURIComponent(t)), s = n.length;
203
203
  m(e, s);
204
204
  for (let r = 0; r < s; r++)
@@ -207,37 +207,37 @@ const N = () => new Zt(), En = (e) => {
207
207
  /** @type {number} */
208
208
  n.codePointAt(r)
209
209
  );
210
- }, ut = Yt && /** @type {any} */
211
- Yt.encodeInto ? Ui : Ri, Ne = (e, t) => {
212
- const n = e.cbuf.length, s = e.cpos, r = Cn(n - s, t.length), i = t.length - r;
210
+ }, ut = Pt && /** @type {any} */
211
+ Pt.encodeInto ? Bi : Fi, Ne = (e, t) => {
212
+ const n = e.cbuf.length, s = e.cpos, r = En(n - s, t.length), i = t.length - r;
213
213
  e.cbuf.set(t.subarray(0, r), s), e.cpos += r, i > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(mt(n * 2, i)), e.cbuf.set(t.subarray(r)), e.cpos = i);
214
214
  }, E = (e, t) => {
215
215
  m(e, t.byteLength), Ne(e, t);
216
- }, An = (e, t) => {
217
- Ni(e, t);
216
+ }, Tn = (e, t) => {
217
+ Ri(e, t);
218
218
  const n = new DataView(e.cbuf.buffer, e.cpos, t);
219
219
  return e.cpos += t, n;
220
- }, $i = (e, t) => An(e, 4).setFloat32(0, t, !1), Bi = (e, t) => An(e, 8).setFloat64(0, t, !1), Fi = (e, t) => (
220
+ }, Vi = (e, t) => Tn(e, 4).setFloat32(0, t, !1), ji = (e, t) => Tn(e, 8).setFloat64(0, t, !1), Hi = (e, t) => (
221
221
  /** @type {any} */
222
- An(e, 8).setBigInt64(0, t, !1)
223
- ), ss = new DataView(new ArrayBuffer(4)), Vi = (e) => (ss.setFloat32(0, e), ss.getFloat32(0) === e), Gt = (e, t) => {
222
+ Tn(e, 8).setBigInt64(0, t, !1)
223
+ ), rs = new DataView(new ArrayBuffer(4)), zi = (e) => (rs.setFloat32(0, e), rs.getFloat32(0) === e), Yt = (e, t) => {
224
224
  switch (typeof t) {
225
225
  case "string":
226
226
  x(e, 119), ut(e, t);
227
227
  break;
228
228
  case "number":
229
- Ei(t) && he(t) <= Ci ? (x(e, 125), Dn(e, t)) : Vi(t) ? (x(e, 124), $i(e, t)) : (x(e, 123), Bi(e, t));
229
+ Ti(t) && he(t) <= Ai ? (x(e, 125), An(e, t)) : zi(t) ? (x(e, 124), Vi(e, t)) : (x(e, 123), ji(e, t));
230
230
  break;
231
231
  case "bigint":
232
- x(e, 122), Fi(e, t);
232
+ x(e, 122), Hi(e, t);
233
233
  break;
234
234
  case "object":
235
235
  if (t === null)
236
236
  x(e, 126);
237
- else if (Lt(t)) {
237
+ else if (It(t)) {
238
238
  x(e, 117), m(e, t.length);
239
239
  for (let n = 0; n < t.length; n++)
240
- Gt(e, t[n]);
240
+ Yt(e, t[n]);
241
241
  } else if (t instanceof Uint8Array)
242
242
  x(e, 116), E(e, t);
243
243
  else {
@@ -246,7 +246,7 @@ Yt.encodeInto ? Ui : Ri, Ne = (e, t) => {
246
246
  m(e, n.length);
247
247
  for (let s = 0; s < n.length; s++) {
248
248
  const r = n[s];
249
- ut(e, r), Gt(e, t[r]);
249
+ ut(e, r), Yt(e, t[r]);
250
250
  }
251
251
  }
252
252
  break;
@@ -257,7 +257,7 @@ Yt.encodeInto ? Ui : Ri, Ne = (e, t) => {
257
257
  x(e, 127);
258
258
  }
259
259
  };
260
- class rs extends Zt {
260
+ class is extends Zt {
261
261
  /**
262
262
  * @param {function(Encoder, T):void} writer
263
263
  */
@@ -271,8 +271,8 @@ class rs extends Zt {
271
271
  this.s === t ? this.count++ : (this.count > 0 && m(this, this.count - 1), this.count = 1, this.w(this, t), this.s = t);
272
272
  }
273
273
  }
274
- const is = (e) => {
275
- e.count > 0 && (Dn(e.encoder, e.count === 1 ? e.s : -e.s), e.count > 1 && m(e.encoder, e.count - 2));
274
+ const os = (e) => {
275
+ e.count > 0 && (An(e.encoder, e.count === 1 ? e.s : -e.s), e.count > 1 && m(e.encoder, e.count - 2));
276
276
  };
277
277
  class ue {
278
278
  constructor() {
@@ -282,7 +282,7 @@ class ue {
282
282
  * @param {number} v
283
283
  */
284
284
  write(t) {
285
- this.s === t ? this.count++ : (is(this), this.count = 1, this.s = t);
285
+ this.s === t ? this.count++ : (os(this), this.count = 1, this.s = t);
286
286
  }
287
287
  /**
288
288
  * Flush the encoded state and transform this to a Uint8Array.
@@ -290,16 +290,16 @@ class ue {
290
290
  * Note that this should only be called once.
291
291
  */
292
292
  toUint8Array() {
293
- return is(this), C(this.encoder);
293
+ return os(this), C(this.encoder);
294
294
  }
295
295
  }
296
- const os = (e) => {
296
+ const cs = (e) => {
297
297
  if (e.count > 0) {
298
298
  const t = e.diff * 2 + (e.count === 1 ? 0 : 1);
299
- Dn(e.encoder, t), e.count > 1 && m(e.encoder, e.count - 2);
299
+ An(e.encoder, t), e.count > 1 && m(e.encoder, e.count - 2);
300
300
  }
301
301
  };
302
- class Xe {
302
+ class qe {
303
303
  constructor() {
304
304
  this.encoder = new Zt(), this.s = 0, this.count = 0, this.diff = 0;
305
305
  }
@@ -307,7 +307,7 @@ class Xe {
307
307
  * @param {number} v
308
308
  */
309
309
  write(t) {
310
- this.diff === t - this.s ? (this.s = t, this.count++) : (os(this), this.count = 1, this.diff = t - this.s, this.s = t);
310
+ this.diff === t - this.s ? (this.s = t, this.count++) : (cs(this), this.count = 1, this.diff = t - this.s, this.s = t);
311
311
  }
312
312
  /**
313
313
  * Flush the encoded state and transform this to a Uint8Array.
@@ -315,10 +315,10 @@ class Xe {
315
315
  * Note that this should only be called once.
316
316
  */
317
317
  toUint8Array() {
318
- return os(this), C(this.encoder);
318
+ return cs(this), C(this.encoder);
319
319
  }
320
320
  }
321
- class ji {
321
+ class Pi {
322
322
  constructor() {
323
323
  this.sarr = [], this.s = "", this.lensE = new ue();
324
324
  }
@@ -333,15 +333,15 @@ class ji {
333
333
  return this.sarr.push(this.s), this.s = "", ut(t, this.sarr.join("")), Ne(t, this.lensE.toUint8Array()), C(t);
334
334
  }
335
335
  }
336
- const G = (e) => new Error(e), H = () => {
337
- throw G("Method unimplemented");
336
+ const Y = (e) => new Error(e), H = () => {
337
+ throw Y("Method unimplemented");
338
338
  }, j = () => {
339
- throw G("Unexpected case");
340
- }, Me = G("Unexpected end of array"), Rs = G("Integer out of Range"), Hi = (e, t, n) => {
339
+ throw Y("Unexpected case");
340
+ }, Me = Y("Unexpected end of array"), Bs = Y("Integer out of Range"), Yi = (e, t, n) => {
341
341
  if (t < 0 || n < 0 || t + n > e.length)
342
342
  throw Me;
343
343
  return new Uint8Array(e.buffer, e.byteOffset + t, n);
344
- }, zi = (e, t, n) => {
344
+ }, Gi = (e, t, n) => {
345
345
  if (t < 0 || n < 0 || t + n > e.length)
346
346
  throw Me;
347
347
  return new DataView(e.buffer, e.byteOffset + t, n);
@@ -354,10 +354,10 @@ class Ue {
354
354
  this.arr = t, this.pos = 0;
355
355
  }
356
356
  }
357
- const lt = (e) => new Ue(e), Yi = (e) => e.pos !== e.arr.length, Gi = (e, t) => {
358
- const n = Hi(e.arr, e.pos, t);
357
+ const lt = (e) => new Ue(e), Ji = (e) => e.pos !== e.arr.length, Ki = (e, t) => {
358
+ const n = Yi(e.arr, e.pos, t);
359
359
  return e.pos += t, n;
360
- }, v = (e) => Gi(e, b(e)), Ot = (e) => e.arr[e.pos++], b = (e) => {
360
+ }, O = (e) => Ki(e, b(e)), Lt = (e) => e.arr[e.pos++], b = (e) => {
361
361
  let t = 0, n = 1;
362
362
  const s = e.arr.length;
363
363
  for (; e.pos < s; ) {
@@ -365,11 +365,11 @@ const lt = (e) => new Ue(e), Yi = (e) => e.pos !== e.arr.length, Gi = (e, t) =>
365
365
  if (t = t + (r & ht) * n, n *= 128, r < B)
366
366
  return t;
367
367
  if (t > we)
368
- throw Rs;
368
+ throw Bs;
369
369
  }
370
370
  throw Me;
371
- }, Tn = (e) => {
372
- let t = e.arr[e.pos++], n = t & ln, s = 64;
371
+ }, xn = (e) => {
372
+ let t = e.arr[e.pos++], n = t & an, s = 64;
373
373
  const r = (t & X) > 0 ? -1 : 1;
374
374
  if ((t & B) === 0)
375
375
  return r * n;
@@ -378,18 +378,18 @@ const lt = (e) => new Ue(e), Yi = (e) => e.pos !== e.arr.length, Gi = (e, t) =>
378
378
  if (t = e.arr[e.pos++], n = n + (t & ht) * s, s *= 128, t < B)
379
379
  return r * n;
380
380
  if (n > we)
381
- throw Rs;
381
+ throw Bs;
382
382
  }
383
383
  throw Me;
384
- }, Pi = (e) => {
384
+ }, Wi = (e) => {
385
385
  let t = b(e);
386
386
  if (t === 0)
387
387
  return "";
388
388
  {
389
- let n = String.fromCodePoint(Ot(e));
389
+ let n = String.fromCodePoint(Lt(e));
390
390
  if (--t < 100)
391
391
  for (; t--; )
392
- n += String.fromCodePoint(Ot(e));
392
+ n += String.fromCodePoint(Lt(e));
393
393
  else
394
394
  for (; t > 0; ) {
395
395
  const s = t < 1e4 ? t : 1e4, r = e.arr.subarray(e.pos, e.pos + s);
@@ -401,28 +401,28 @@ const lt = (e) => new Ue(e), Yi = (e) => e.pos !== e.arr.length, Gi = (e, t) =>
401
401
  }
402
402
  return decodeURIComponent(escape(n));
403
403
  }
404
- }, Ji = (e) => (
404
+ }, Xi = (e) => (
405
405
  /** @type any */
406
- jt.decode(v(e))
407
- ), rt = jt ? Ji : Pi, xn = (e, t) => {
408
- const n = zi(e.arr, e.pos, t);
406
+ jt.decode(O(e))
407
+ ), rt = jt ? Xi : Wi, In = (e, t) => {
408
+ const n = Gi(e.arr, e.pos, t);
409
409
  return e.pos += t, n;
410
- }, Ki = (e) => xn(e, 4).getFloat32(0, !1), Wi = (e) => xn(e, 8).getFloat64(0, !1), Xi = (e) => (
410
+ }, qi = (e) => In(e, 4).getFloat32(0, !1), Qi = (e) => In(e, 8).getFloat64(0, !1), Zi = (e) => (
411
411
  /** @type {any} */
412
- xn(e, 8).getBigInt64(0, !1)
413
- ), qi = [
412
+ In(e, 8).getBigInt64(0, !1)
413
+ ), to = [
414
414
  (e) => {
415
415
  },
416
416
  // CASE 127: undefined
417
417
  (e) => null,
418
418
  // CASE 126: null
419
- Tn,
419
+ xn,
420
420
  // CASE 125: integer
421
- Ki,
421
+ qi,
422
422
  // CASE 124: float32
423
- Wi,
423
+ Qi,
424
424
  // CASE 123: float64
425
- Xi,
425
+ Zi,
426
426
  // CASE 122: bigint
427
427
  (e) => !1,
428
428
  // CASE 121: boolean (false)
@@ -434,20 +434,20 @@ const lt = (e) => new Ue(e), Yi = (e) => e.pos !== e.arr.length, Gi = (e, t) =>
434
434
  const t = b(e), n = {};
435
435
  for (let s = 0; s < t; s++) {
436
436
  const r = rt(e);
437
- n[r] = Pt(e);
437
+ n[r] = Gt(e);
438
438
  }
439
439
  return n;
440
440
  },
441
441
  (e) => {
442
442
  const t = b(e), n = [];
443
443
  for (let s = 0; s < t; s++)
444
- n.push(Pt(e));
444
+ n.push(Gt(e));
445
445
  return n;
446
446
  },
447
- v
447
+ O
448
448
  // CASE 116: Uint8Array
449
- ], Pt = (e) => qi[127 - Ot(e)](e);
450
- class cs extends Ue {
449
+ ], Gt = (e) => to[127 - Lt(e)](e);
450
+ class ls extends Ue {
451
451
  /**
452
452
  * @param {Uint8Array} uint8Array
453
453
  * @param {function(Decoder):T} reader
@@ -456,7 +456,7 @@ class cs extends Ue {
456
456
  super(t), this.reader = n, this.s = null, this.count = 0;
457
457
  }
458
458
  read() {
459
- return this.count === 0 && (this.s = this.reader(this), Yi(this) ? this.count = b(this) + 1 : this.count = -1), this.count--, /** @type {T} */
459
+ return this.count === 0 && (this.s = this.reader(this), Ji(this) ? this.count = b(this) + 1 : this.count = -1), this.count--, /** @type {T} */
460
460
  this.s;
461
461
  }
462
462
  }
@@ -469,15 +469,15 @@ class de extends Ue {
469
469
  }
470
470
  read() {
471
471
  if (this.count === 0) {
472
- this.s = Tn(this);
473
- const t = Ms(this.s);
472
+ this.s = xn(this);
473
+ const t = Rs(this.s);
474
474
  this.count = 1, t && (this.s = -this.s, this.count = b(this) + 2);
475
475
  }
476
476
  return this.count--, /** @type {number} */
477
477
  this.s;
478
478
  }
479
479
  }
480
- class qe extends Ue {
480
+ class Qe extends Ue {
481
481
  /**
482
482
  * @param {Uint8Array} uint8Array
483
483
  */
@@ -489,13 +489,13 @@ class qe extends Ue {
489
489
  */
490
490
  read() {
491
491
  if (this.count === 0) {
492
- const t = Tn(this), n = t & 1;
492
+ const t = xn(this), n = t & 1;
493
493
  this.diff = z(t / 2), this.count = 1, n && (this.count = b(this) + 2);
494
494
  }
495
495
  return this.s += this.diff, this.count--, this.s;
496
496
  }
497
497
  }
498
- class Qi {
498
+ class eo {
499
499
  /**
500
500
  * @param {Uint8Array} uint8Array
501
501
  */
@@ -510,17 +510,17 @@ class Qi {
510
510
  return this.spos = t, n;
511
511
  }
512
512
  }
513
- const Zi = crypto.getRandomValues.bind(crypto), $s = () => Zi(new Uint32Array(1))[0], to = "10000000-1000-4000-8000" + -1e11, eo = () => to.replace(
513
+ const no = crypto.getRandomValues.bind(crypto), Fs = () => no(new Uint32Array(1))[0], so = "10000000-1000-4000-8000" + -1e11, ro = () => so.replace(
514
514
  /[018]/g,
515
515
  /** @param {number} c */
516
- (e) => (e ^ $s() & 15 >> e / 4).toString(16)
517
- ), ot = Date.now, ls = (e) => (
516
+ (e) => (e ^ Fs() & 15 >> e / 4).toString(16)
517
+ ), ot = Date.now, as = (e) => (
518
518
  /** @type {Promise<T>} */
519
519
  new Promise(e)
520
520
  );
521
521
  Promise.all.bind(Promise);
522
- const as = (e) => e === void 0 ? null : e;
523
- class no {
522
+ const hs = (e) => e === void 0 ? null : e;
523
+ class io {
524
524
  constructor() {
525
525
  this.map = /* @__PURE__ */ new Map();
526
526
  }
@@ -538,31 +538,31 @@ class no {
538
538
  return this.map.get(t);
539
539
  }
540
540
  }
541
- let Bs = new no(), In = !0;
541
+ let Vs = new io(), Ln = !0;
542
542
  try {
543
- typeof localStorage != "undefined" && localStorage && (Bs = localStorage, In = !1);
543
+ typeof localStorage != "undefined" && localStorage && (Vs = localStorage, Ln = !1);
544
544
  } catch (e) {
545
545
  }
546
- const Fs = Bs, so = (e) => In || addEventListener(
546
+ const js = Vs, oo = (e) => Ln || addEventListener(
547
547
  "storage",
548
548
  /** @type {any} */
549
549
  e
550
- ), ro = (e) => In || removeEventListener(
550
+ ), co = (e) => Ln || removeEventListener(
551
551
  "storage",
552
552
  /** @type {any} */
553
553
  e
554
- ), Jt = /* @__PURE__ */ Symbol("Equality"), Vs = (e, t) => {
554
+ ), Jt = /* @__PURE__ */ Symbol("Equality"), Hs = (e, t) => {
555
555
  var n;
556
556
  return e === t || !!((n = e == null ? void 0 : e[Jt]) != null && n.call(e, t)) || !1;
557
- }, io = (e) => typeof e == "object", oo = Object.assign, co = Object.keys, lo = (e, t) => {
557
+ }, lo = (e) => typeof e == "object", ao = Object.assign, ho = Object.keys, uo = (e, t) => {
558
558
  for (const n in e)
559
559
  t(e[n], n);
560
- }, ao = (e, t) => {
560
+ }, fo = (e, t) => {
561
561
  const n = [];
562
562
  for (const s in e)
563
563
  n.push(t(e[s], s));
564
564
  return n;
565
- }, me = (e) => co(e).length, ho = (e) => {
565
+ }, me = (e) => ho(e).length, go = (e) => {
566
566
  for (const t in e)
567
567
  return !1;
568
568
  return !0;
@@ -571,12 +571,12 @@ const Fs = Bs, so = (e) => In || addEventListener(
571
571
  if (!t(e[n], n))
572
572
  return !1;
573
573
  return !0;
574
- }, Ln = (e, t) => Object.prototype.hasOwnProperty.call(e, t), uo = (e, t) => e === t || me(e) === me(t) && te(e, (n, s) => (n !== void 0 || Ln(t, s)) && Vs(t[s], n)), fo = Object.freeze, js = (e) => {
574
+ }, vn = (e, t) => Object.prototype.hasOwnProperty.call(e, t), po = (e, t) => e === t || me(e) === me(t) && te(e, (n, s) => (n !== void 0 || vn(t, s)) && Hs(t[s], n)), wo = Object.freeze, zs = (e) => {
575
575
  for (const t in e) {
576
576
  const n = e[t];
577
- (typeof n == "object" || typeof n == "function") && js(e[t]);
577
+ (typeof n == "object" || typeof n == "function") && zs(e[t]);
578
578
  }
579
- return fo(e);
579
+ return wo(e);
580
580
  }, On = (e, t, n = 0) => {
581
581
  try {
582
582
  for (; n < e.length; n++)
@@ -584,7 +584,7 @@ const Fs = Bs, so = (e) => In || addEventListener(
584
584
  } finally {
585
585
  n < e.length && On(e, t, n + 1);
586
586
  }
587
- }, go = (e) => e, Dt = (e, t) => {
587
+ }, mo = (e) => e, Et = (e, t) => {
588
588
  if (e === t)
589
589
  return !0;
590
590
  if (e == null || t == null || e.constructor !== t.constructor && (e.constructor || Object) !== (t.constructor || Object))
@@ -615,7 +615,7 @@ const Fs = Bs, so = (e) => In || addEventListener(
615
615
  if (e.size !== t.size)
616
616
  return !1;
617
617
  for (const n of e.keys())
618
- if (!t.has(n) || !Dt(e.get(n), t.get(n)))
618
+ if (!t.has(n) || !Et(e.get(n), t.get(n)))
619
619
  return !1;
620
620
  break;
621
621
  }
@@ -624,58 +624,58 @@ const Fs = Bs, so = (e) => In || addEventListener(
624
624
  if (me(e) !== me(t))
625
625
  return !1;
626
626
  for (const n in e)
627
- if (!Ln(e, n) || !Dt(e[n], t[n]))
627
+ if (!vn(e, n) || !Et(e[n], t[n]))
628
628
  return !1;
629
629
  break;
630
630
  case Array:
631
631
  if (e.length !== t.length)
632
632
  return !1;
633
633
  for (let n = 0; n < e.length; n++)
634
- if (!Dt(e[n], t[n]))
634
+ if (!Et(e[n], t[n]))
635
635
  return !1;
636
636
  break;
637
637
  default:
638
638
  return !1;
639
639
  }
640
640
  return !0;
641
- }, po = (e, t) => t.includes(e);
642
- var Hs = {};
643
- const ct = typeof process != "undefined" && process.release && /node|io\.js/.test(process.release.name) && Object.prototype.toString.call(typeof process != "undefined" ? process : 0) === "[object process]", zs = typeof window != "undefined" && typeof document != "undefined" && !ct;
644
- let Y;
645
- const wo = () => {
646
- if (Y === void 0)
641
+ }, yo = (e, t) => t.includes(e);
642
+ var Ps = {};
643
+ const ct = typeof process != "undefined" && process.release && /node|io\.js/.test(process.release.name) && Object.prototype.toString.call(typeof process != "undefined" ? process : 0) === "[object process]", Ys = typeof window != "undefined" && typeof document != "undefined" && !ct;
644
+ let P;
645
+ const bo = () => {
646
+ if (P === void 0)
647
647
  if (ct) {
648
- Y = $();
648
+ P = $();
649
649
  const e = process.argv;
650
650
  let t = null;
651
651
  for (let n = 0; n < e.length; n++) {
652
652
  const s = e[n];
653
- s[0] === "-" ? (t !== null && Y.set(t, ""), t = s) : t !== null && (Y.set(t, s), t = null);
653
+ s[0] === "-" ? (t !== null && P.set(t, ""), t = s) : t !== null && (P.set(t, s), t = null);
654
654
  }
655
- t !== null && Y.set(t, "");
656
- } else typeof location == "object" ? (Y = $(), (location.search || "?").slice(1).split("&").forEach((e) => {
655
+ t !== null && P.set(t, "");
656
+ } else typeof location == "object" ? (P = $(), (location.search || "?").slice(1).split("&").forEach((e) => {
657
657
  if (e.length !== 0) {
658
658
  const [t, n] = e.split("=");
659
- Y.set(`--${ns(t, "-")}`, n), Y.set(`-${ns(t, "-")}`, n);
659
+ P.set(`--${ss(t, "-")}`, n), P.set(`-${ss(t, "-")}`, n);
660
660
  }
661
- })) : Y = $();
662
- return Y;
663
- }, un = (e) => wo().has(e), ye = (e) => as(ct ? Hs[e.toUpperCase().replaceAll("-", "_")] : Fs.getItem(e)), Ys = (e) => un("--" + e) || ye(e) !== null, mo = Ys("production"), yo = ct && po(Hs.FORCE_COLOR, ["true", "1", "2"]), bo = yo || !un("--no-colors") && // @todo deprecate --no-colors
664
- !Ys("no-color") && (!ct || process.stdout.isTTY) && (!ct || un("--color") || ye("COLORTERM") !== null || (ye("TERM") || "").includes("color")), Gs = (e) => new Uint8Array(e), ko = (e) => new Uint8Array(e), _o = (e) => {
661
+ })) : P = $();
662
+ return P;
663
+ }, dn = (e) => bo().has(e), ye = (e) => hs(ct ? Ps[e.toUpperCase().replaceAll("-", "_")] : js.getItem(e)), Gs = (e) => dn("--" + e) || ye(e) !== null, ko = Gs("production"), _o = ct && yo(Ps.FORCE_COLOR, ["true", "1", "2"]), So = _o || !dn("--no-colors") && // @todo deprecate --no-colors
664
+ !Gs("no-color") && (!ct || process.stdout.isTTY) && (!ct || dn("--color") || ye("COLORTERM") !== null || (ye("TERM") || "").includes("color")), Js = (e) => new Uint8Array(e), Co = (e) => new Uint8Array(e), Eo = (e) => {
665
665
  let t = "";
666
666
  for (let n = 0; n < e.byteLength; n++)
667
- t += Us(e[n]);
667
+ t += $s(e[n]);
668
668
  return btoa(t);
669
- }, So = (e) => Buffer.from(e.buffer, e.byteOffset, e.byteLength).toString("base64"), Co = (e) => {
670
- const t = atob(e), n = Gs(t.length);
669
+ }, Do = (e) => Buffer.from(e.buffer, e.byteOffset, e.byteLength).toString("base64"), Ao = (e) => {
670
+ const t = atob(e), n = Js(t.length);
671
671
  for (let s = 0; s < t.length; s++)
672
672
  n[s] = t.charCodeAt(s);
673
673
  return n;
674
- }, Eo = (e) => new Uint8Array(Buffer.from(e, "base64")), Do = zs ? _o : So, Ao = zs ? Co : Eo, To = (e) => {
675
- const t = Gs(e.byteLength);
674
+ }, To = (e) => new Uint8Array(Buffer.from(e, "base64")), xo = Ys ? Eo : Do, Io = Ys ? Ao : To, Lo = (e) => {
675
+ const t = Js(e.byteLength);
676
676
  return t.set(e), t;
677
677
  };
678
- class xo {
678
+ class vo {
679
679
  /**
680
680
  * @param {L} left
681
681
  * @param {R} right
@@ -684,14 +684,14 @@ class xo {
684
684
  this.left = t, this.right = n;
685
685
  }
686
686
  }
687
- const W = (e, t) => new xo(e, t), hs = (e) => e.next() >= 0.5, Qe = (e, t, n) => z(e.next() * (n + 1 - t) + t), Ps = (e, t, n) => z(e.next() * (n + 1 - t) + t), vn = (e, t, n) => Ps(e, t, n), Io = (e) => Us(vn(e, 97, 122)), Lo = (e, t = 0, n = 20) => {
688
- const s = vn(e, t, n);
687
+ const W = (e, t) => new vo(e, t), us = (e) => e.next() >= 0.5, Ze = (e, t, n) => z(e.next() * (n + 1 - t) + t), Ks = (e, t, n) => z(e.next() * (n + 1 - t) + t), Nn = (e, t, n) => Ks(e, t, n), Oo = (e) => $s(Nn(e, 97, 122)), No = (e, t = 0, n = 20) => {
688
+ const s = Nn(e, t, n);
689
689
  let r = "";
690
690
  for (let i = 0; i < s; i++)
691
- r += Io(e);
691
+ r += Oo(e);
692
692
  return r;
693
- }, Ze = (e, t) => t[vn(e, 0, t.length - 1)], Oo = /* @__PURE__ */ Symbol("0schema");
694
- class vo {
693
+ }, tn = (e, t) => t[Nn(e, 0, t.length - 1)], Mo = /* @__PURE__ */ Symbol("0schema");
694
+ class Uo {
695
695
  constructor() {
696
696
  this._rerrs = [];
697
697
  }
@@ -708,18 +708,18 @@ class vo {
708
708
  const t = [];
709
709
  for (let n = this._rerrs.length - 1; n > 0; n--) {
710
710
  const s = this._rerrs[n];
711
- t.push(vi(" ", (this._rerrs.length - n) * 2) + `${s.path != null ? `[${s.path}] ` : ""}${s.has} doesn't match ${s.expected}. ${s.message}`);
711
+ t.push(Ui(" ", (this._rerrs.length - n) * 2) + `${s.path != null ? `[${s.path}] ` : ""}${s.has} doesn't match ${s.expected}. ${s.message}`);
712
712
  }
713
713
  return t.join(`
714
714
  `);
715
715
  }
716
716
  }
717
- const dn = (e, t) => e === t ? !0 : e == null || t == null || e.constructor !== t.constructor ? !1 : e[Jt] ? Vs(e, t) : Lt(e) ? kn(
717
+ const fn = (e, t) => e === t ? !0 : e == null || t == null || e.constructor !== t.constructor ? !1 : e[Jt] ? Hs(e, t) : It(e) ? _n(
718
718
  e,
719
- (n) => _n(t, (s) => dn(n, s))
720
- ) : io(e) ? te(
719
+ (n) => Sn(t, (s) => fn(n, s))
720
+ ) : lo(e) ? te(
721
721
  e,
722
- (n, s) => dn(n, t[s])
722
+ (n, s) => fn(n, t[s])
723
723
  ) : !1;
724
724
  class U {
725
725
  /**
@@ -734,7 +734,7 @@ class U {
734
734
  ];
735
735
  return (
736
736
  /** @type {typeof Schema<any>} */
737
- this.constructor._dilutes && ([s, n] = [n, s]), dn(n, s)
737
+ this.constructor._dilutes && ([s, n] = [n, s]), fn(n, s)
738
738
  );
739
739
  }
740
740
  /**
@@ -743,9 +743,9 @@ class U {
743
743
  * @param {Schema<any>} other
744
744
  */
745
745
  equals(t) {
746
- return this.constructor === t.constructor && Dt(this.shape, t.shape);
746
+ return this.constructor === t.constructor && Et(this.shape, t.shape);
747
747
  }
748
- [Oo]() {
748
+ [Mo]() {
749
749
  return !0;
750
750
  }
751
751
  /**
@@ -784,13 +784,13 @@ class U {
784
784
  * @type {Schema<T?>}
785
785
  */
786
786
  get nullable() {
787
- return $t(this, Ve);
787
+ return Rt(this, Ve);
788
788
  }
789
789
  /**
790
790
  * @type {$Optional<Schema<T>>}
791
791
  */
792
792
  get optional() {
793
- return new Ws(
793
+ return new qs(
794
794
  /** @type {Schema<T>} */
795
795
  this
796
796
  );
@@ -808,7 +808,7 @@ class U {
808
808
  * @return {Extract<OO, T> extends never ? T : (OO extends Array<never> ? T : Extract<OO,T>)}
809
809
  */
810
810
  cast(t) {
811
- return us(t, this), /** @type {any} */
811
+ return ds(t, this), /** @type {any} */
812
812
  t;
813
813
  }
814
814
  /**
@@ -831,7 +831,7 @@ class U {
831
831
  * @return {o extends T ? T : never}
832
832
  */
833
833
  expect(t) {
834
- return us(t, this), t;
834
+ return ds(t, this), t;
835
835
  }
836
836
  }
837
837
  // this.shape must not be defined on Schema. Otherwise typecheck on metatypes (e.g. $$object) won't work as expected anymore
@@ -841,7 +841,7 @@ class U {
841
841
  * @protected
842
842
  */
843
843
  oe(U, "_dilutes", !1);
844
- class Nn extends U {
844
+ class Mn extends U {
845
845
  /**
846
846
  * @param {C} c
847
847
  * @param {((o:Instance<C>)=>boolean)|null} check
@@ -859,9 +859,9 @@ class Nn extends U {
859
859
  return !s && (n == null || n.extend(null, this.shape.name, t == null ? void 0 : t.constructor.name, (t == null ? void 0 : t.constructor) !== this.shape ? "Constructor match failed" : "Check failed")), s;
860
860
  }
861
861
  }
862
- const D = (e, t = null) => new Nn(e, t);
863
- D(Nn);
864
- class Mn extends U {
862
+ const D = (e, t = null) => new Mn(e, t);
863
+ D(Mn);
864
+ class Un extends U {
865
865
  /**
866
866
  * @param {(o:any) => boolean} check
867
867
  */
@@ -878,8 +878,8 @@ class Mn extends U {
878
878
  return !s && (n == null || n.extend(null, "custom prop", t == null ? void 0 : t.constructor.name, "failed to check custom prop")), s;
879
879
  }
880
880
  }
881
- const L = (e) => new Mn(e);
882
- D(Mn);
881
+ const L = (e) => new Un(e);
882
+ D(Un);
883
883
  class Re extends U {
884
884
  /**
885
885
  * @param {Array<T>} literals
@@ -898,32 +898,32 @@ class Re extends U {
898
898
  return !s && (n == null || n.extend(null, this.shape.join(" | "), t.toString())), s;
899
899
  }
900
900
  }
901
- const $e = (...e) => new Re(e), Js = D(Re), No = (
901
+ const $e = (...e) => new Re(e), Ws = D(Re), Ro = (
902
902
  /** @type {any} */
903
903
  RegExp.escape || /** @type {(str:string) => string} */
904
904
  ((e) => e.replace(/[().|&,$^[\]]/g, (t) => "\\" + t))
905
- ), Ks = (e) => {
905
+ ), Xs = (e) => {
906
906
  if (vt.check(e))
907
- return [No(e)];
908
- if (Js.check(e))
907
+ return [Ro(e)];
908
+ if (Ws.check(e))
909
909
  return (
910
910
  /** @type {Array<string|number>} */
911
911
  e.shape.map((t) => t + "")
912
912
  );
913
- if (rr.check(e))
913
+ if (or.check(e))
914
914
  return ["[+-]?\\d+.?\\d*"];
915
- if (ir.check(e))
915
+ if (cr.check(e))
916
916
  return [".*"];
917
917
  if (ke.check(e))
918
- return e.shape.map(Ks).flat(1);
918
+ return e.shape.map(Xs).flat(1);
919
919
  j();
920
920
  };
921
- class Mo extends U {
921
+ class $o extends U {
922
922
  /**
923
923
  * @param {T} shape
924
924
  */
925
925
  constructor(t) {
926
- super(), this.shape = t, this._r = new RegExp("^" + t.map(Ks).map((n) => `(${n.join("|")})`).join("") + "$");
926
+ super(), this.shape = t, this._r = new RegExp("^" + t.map(Xs).map((n) => `(${n.join("|")})`).join("") + "$");
927
927
  }
928
928
  /**
929
929
  * @param {any} o
@@ -935,9 +935,9 @@ class Mo extends U {
935
935
  return !s && (n == null || n.extend(null, this._r.toString(), t.toString(), "String doesn't match string template.")), s;
936
936
  }
937
937
  }
938
- D(Mo);
939
- const Uo = /* @__PURE__ */ Symbol("optional");
940
- class Ws extends U {
938
+ D($o);
939
+ const Bo = /* @__PURE__ */ Symbol("optional");
940
+ class qs extends U {
941
941
  /**
942
942
  * @param {S} shape
943
943
  */
@@ -953,12 +953,12 @@ class Ws extends U {
953
953
  const s = t === void 0 || this.shape.check(t);
954
954
  return !s && (n == null || n.extend(null, "undefined (optional)", "()")), s;
955
955
  }
956
- get [Uo]() {
956
+ get [Bo]() {
957
957
  return !0;
958
958
  }
959
959
  }
960
- const Ro = D(Ws);
961
- class $o extends U {
960
+ const Fo = D(qs);
961
+ class Vo extends U {
962
962
  /**
963
963
  * @param {any} _o
964
964
  * @param {ValidationError} [err]
@@ -968,8 +968,8 @@ class $o extends U {
968
968
  return n == null || n.extend(null, "never", typeof t), !1;
969
969
  }
970
970
  }
971
- D($o);
972
- const Oe = class Oe extends U {
971
+ D(Vo);
972
+ const ve = class ve extends U {
973
973
  /**
974
974
  * @param {S} shape
975
975
  * @param {boolean} partial
@@ -981,7 +981,7 @@ const Oe = class Oe extends U {
981
981
  * @type {Schema<Partial<$ObjectToType<S>>>}
982
982
  */
983
983
  get partial() {
984
- return new Oe(this.shape, !0);
984
+ return new ve(this.shape, !0);
985
985
  }
986
986
  /**
987
987
  * @param {any} o
@@ -990,18 +990,18 @@ const Oe = class Oe extends U {
990
990
  */
991
991
  check(t, n) {
992
992
  return t == null ? (n == null || n.extend(null, "object", "null"), !1) : te(this.shape, (s, r) => {
993
- const i = this._isPartial && !Ln(t, r) || s.check(t[r], n);
993
+ const i = this._isPartial && !vn(t, r) || s.check(t[r], n);
994
994
  return !i && (n == null || n.extend(r.toString(), s.toString(), typeof t[r], "Object property does not match")), i;
995
995
  });
996
996
  }
997
997
  };
998
- oe(Oe, "_dilutes", !0);
999
- let be = Oe;
1000
- const Bo = (e) => (
998
+ oe(ve, "_dilutes", !0);
999
+ let be = ve;
1000
+ const jo = (e) => (
1001
1001
  /** @type {any} */
1002
1002
  new be(e)
1003
- ), Fo = D(be), Vo = L((e) => e != null && (e.constructor === Object || e.constructor == null));
1004
- class Xs extends U {
1003
+ ), Ho = D(be), zo = L((e) => e != null && (e.constructor === Object || e.constructor == null));
1004
+ class Qs extends U {
1005
1005
  /**
1006
1006
  * @param {Keys} keys
1007
1007
  * @param {Values} values
@@ -1024,8 +1024,8 @@ class Xs extends U {
1024
1024
  });
1025
1025
  }
1026
1026
  }
1027
- const qs = (e, t) => new Xs(e, t), jo = D(Xs);
1028
- class Qs extends U {
1027
+ const Zs = (e, t) => new Qs(e, t), Po = D(Qs);
1028
+ class tr extends U {
1029
1029
  /**
1030
1030
  * @param {S} shape
1031
1031
  */
@@ -1047,9 +1047,9 @@ class Qs extends U {
1047
1047
  });
1048
1048
  }
1049
1049
  }
1050
- const Ho = (...e) => new Qs(e);
1051
- D(Qs);
1052
- class Zs extends U {
1050
+ const Yo = (...e) => new tr(e);
1051
+ D(tr);
1052
+ class er extends U {
1053
1053
  /**
1054
1054
  * @param {Array<S>} v
1055
1055
  */
@@ -1062,12 +1062,12 @@ class Zs extends U {
1062
1062
  * @return {o is Array<S extends Schema<infer T> ? T : never>} o
1063
1063
  */
1064
1064
  check(t, n) {
1065
- const s = Lt(t) && kn(t, (r) => this.shape.check(r));
1065
+ const s = It(t) && _n(t, (r) => this.shape.check(r));
1066
1066
  return !s && (n == null || n.extend(null, "Array", "")), s;
1067
1067
  }
1068
1068
  }
1069
- const tr = (...e) => new Zs(e), zo = D(Zs), Yo = L((e) => Lt(e));
1070
- class er extends U {
1069
+ const nr = (...e) => new er(e), Go = D(er), Jo = L((e) => It(e));
1070
+ class sr extends U {
1071
1071
  /**
1072
1072
  * @param {new (...args:any) => T} constructor
1073
1073
  * @param {((o:T) => boolean)|null} check
@@ -1085,15 +1085,15 @@ class er extends U {
1085
1085
  return !s && (n == null || n.extend(null, this.shape.name, t == null ? void 0 : t.constructor.name)), s;
1086
1086
  }
1087
1087
  }
1088
- const Go = (e, t = null) => new er(e, t);
1089
- D(er);
1090
- const Po = Go(U);
1091
- class Jo extends U {
1088
+ const Ko = (e, t = null) => new sr(e, t);
1089
+ D(sr);
1090
+ const Wo = Ko(U);
1091
+ class Xo extends U {
1092
1092
  /**
1093
1093
  * @param {Args} args
1094
1094
  */
1095
1095
  constructor(t) {
1096
- super(), this.len = t.length - 1, this.args = Ho(...t.slice(-1)), this.res = t[this.len];
1096
+ super(), this.len = t.length - 1, this.args = Yo(...t.slice(-1)), this.res = t[this.len];
1097
1097
  }
1098
1098
  /**
1099
1099
  * @param {any} f
@@ -1105,8 +1105,8 @@ class Jo extends U {
1105
1105
  return !s && (n == null || n.extend(null, "function", typeof t)), s;
1106
1106
  }
1107
1107
  }
1108
- const Ko = D(Jo), Wo = L((e) => typeof e == "function");
1109
- class Xo extends U {
1108
+ const qo = D(Xo), Qo = L((e) => typeof e == "function");
1109
+ class Zo extends U {
1110
1110
  /**
1111
1111
  * @param {T} v
1112
1112
  */
@@ -1119,11 +1119,11 @@ class Xo extends U {
1119
1119
  * @return {o is Intersect<UnwrapArray<T>>}
1120
1120
  */
1121
1121
  check(t, n) {
1122
- const s = kn(this.shape, (r) => r.check(t, n));
1122
+ const s = _n(this.shape, (r) => r.check(t, n));
1123
1123
  return !s && (n == null || n.extend(null, "Intersectinon", typeof t)), s;
1124
1124
  }
1125
1125
  }
1126
- D(Xo, (e) => e.shape.length > 0);
1126
+ D(Zo, (e) => e.shape.length > 0);
1127
1127
  class Be extends U {
1128
1128
  /**
1129
1129
  * @param {Array<Schema<S>>} v
@@ -1137,77 +1137,77 @@ class Be extends U {
1137
1137
  * @return {o is S}
1138
1138
  */
1139
1139
  check(t, n) {
1140
- const s = _n(this.shape, (r) => r.check(t, n));
1140
+ const s = Sn(this.shape, (r) => r.check(t, n));
1141
1141
  return n == null || n.extend(null, "Union", typeof t), s;
1142
1142
  }
1143
1143
  }
1144
1144
  oe(Be, "_dilutes", !0);
1145
- const $t = (...e) => e.findIndex((t) => ke.check(t)) >= 0 ? $t(...e.map((t) => Kt(t)).map((t) => ke.check(t) ? t.shape : [t]).flat(1)) : e.length === 1 ? e[0] : new Be(e), ke = (
1145
+ const Rt = (...e) => e.findIndex((t) => ke.check(t)) >= 0 ? Rt(...e.map((t) => Kt(t)).map((t) => ke.check(t) ? t.shape : [t]).flat(1)) : e.length === 1 ? e[0] : new Be(e), ke = (
1146
1146
  /** @type {Schema<$Union<any>>} */
1147
1147
  D(Be)
1148
- ), nr = () => !0, _e = L(nr), qo = (
1148
+ ), rr = () => !0, _e = L(rr), tc = (
1149
1149
  /** @type {Schema<Schema<any>>} */
1150
- D(Mn, (e) => e.shape === nr)
1151
- ), Un = L((e) => typeof e == "bigint"), Qo = (
1150
+ D(Un, (e) => e.shape === rr)
1151
+ ), Rn = L((e) => typeof e == "bigint"), ec = (
1152
1152
  /** @type {Schema<Schema<BigInt>>} */
1153
- L((e) => e === Un)
1154
- ), sr = L((e) => typeof e == "symbol");
1155
- L((e) => e === sr);
1156
- const At = L((e) => typeof e == "number"), rr = (
1153
+ L((e) => e === Rn)
1154
+ ), ir = L((e) => typeof e == "symbol");
1155
+ L((e) => e === ir);
1156
+ const Dt = L((e) => typeof e == "number"), or = (
1157
1157
  /** @type {Schema<Schema<number>>} */
1158
- L((e) => e === At)
1159
- ), vt = L((e) => typeof e == "string"), ir = (
1158
+ L((e) => e === Dt)
1159
+ ), vt = L((e) => typeof e == "string"), cr = (
1160
1160
  /** @type {Schema<Schema<string>>} */
1161
1161
  L((e) => e === vt)
1162
- ), Fe = L((e) => typeof e == "boolean"), Zo = (
1162
+ ), Fe = L((e) => typeof e == "boolean"), nc = (
1163
1163
  /** @type {Schema<Schema<Boolean>>} */
1164
1164
  L((e) => e === Fe)
1165
- ), or = $e(void 0);
1165
+ ), lr = $e(void 0);
1166
1166
  D(Re, (e) => e.shape.length === 1 && e.shape[0] === void 0);
1167
1167
  $e(void 0);
1168
- const Ve = $e(null), tc = (
1168
+ const Ve = $e(null), sc = (
1169
1169
  /** @type {Schema<Schema<null>>} */
1170
1170
  D(Re, (e) => e.shape.length === 1 && e.shape[0] === null)
1171
1171
  );
1172
1172
  D(Uint8Array);
1173
- D(Nn, (e) => e.shape === Uint8Array);
1174
- const ec = $t(At, vt, Ve, or, Un, Fe, sr);
1173
+ D(Mn, (e) => e.shape === Uint8Array);
1174
+ const rc = Rt(Dt, vt, Ve, lr, Rn, Fe, ir);
1175
1175
  (() => {
1176
1176
  const e = (
1177
1177
  /** @type {$Array<$any>} */
1178
- tr(_e)
1178
+ nr(_e)
1179
1179
  ), t = (
1180
1180
  /** @type {$Record<$string,$any>} */
1181
- qs(vt, _e)
1182
- ), n = $t(At, vt, Ve, Fe, e, t);
1181
+ Zs(vt, _e)
1182
+ ), n = Rt(Dt, vt, Ve, Fe, e, t);
1183
1183
  return e.shape = n, t.shape.values = n, n;
1184
1184
  })();
1185
1185
  const Kt = (e) => {
1186
- if (Po.check(e))
1186
+ if (Wo.check(e))
1187
1187
  return (
1188
1188
  /** @type {any} */
1189
1189
  e
1190
1190
  );
1191
- if (Vo.check(e)) {
1191
+ if (zo.check(e)) {
1192
1192
  const t = {};
1193
1193
  for (const n in e)
1194
1194
  t[n] = Kt(e[n]);
1195
1195
  return (
1196
1196
  /** @type {any} */
1197
- Bo(t)
1197
+ jo(t)
1198
1198
  );
1199
1199
  } else {
1200
- if (Yo.check(e))
1200
+ if (Jo.check(e))
1201
1201
  return (
1202
1202
  /** @type {any} */
1203
- $t(...e.map(Kt))
1203
+ Rt(...e.map(Kt))
1204
1204
  );
1205
- if (ec.check(e))
1205
+ if (rc.check(e))
1206
1206
  return (
1207
1207
  /** @type {any} */
1208
1208
  $e(e)
1209
1209
  );
1210
- if (Wo.check(e))
1210
+ if (Qo.check(e))
1211
1211
  return (
1212
1212
  /** @type {any} */
1213
1213
  D(
@@ -1217,14 +1217,14 @@ const Kt = (e) => {
1217
1217
  );
1218
1218
  }
1219
1219
  j();
1220
- }, us = mo ? () => {
1220
+ }, ds = ko ? () => {
1221
1221
  } : (e, t) => {
1222
- const n = new vo();
1222
+ const n = new Uo();
1223
1223
  if (!t.check(e, n))
1224
- throw G(`Expected value to be of type ${t.constructor.name}.
1224
+ throw Y(`Expected value to be of type ${t.constructor.name}.
1225
1225
  ${n.toString()}`);
1226
1226
  };
1227
- class nc {
1227
+ class ic {
1228
1228
  /**
1229
1229
  * @param {Schema<State>} [$state]
1230
1230
  */
@@ -1262,70 +1262,70 @@ class nc {
1262
1262
  if (r.if.check(t))
1263
1263
  return r.h(t, n);
1264
1264
  }
1265
- throw G("Unhandled pattern");
1265
+ throw Y("Unhandled pattern");
1266
1266
  }
1267
1267
  );
1268
1268
  }
1269
1269
  }
1270
- const sc = (e) => new nc(
1270
+ const oc = (e) => new ic(
1271
1271
  /** @type {any} */
1272
1272
  e
1273
- ), cr = (
1273
+ ), ar = (
1274
1274
  /** @type {any} */
1275
- sc(
1275
+ oc(
1276
1276
  /** @type {Schema<prng.PRNG>} */
1277
1277
  _e
1278
- ).if(rr, (e, t) => Qe(t, es, we)).if(ir, (e, t) => Lo(t)).if(Zo, (e, t) => hs(t)).if(Qo, (e, t) => BigInt(Qe(t, es, we))).if(ke, (e, t) => _t(t, Ze(t, e.shape))).if(Fo, (e, t) => {
1278
+ ).if(or, (e, t) => Ze(t, ns, we)).if(cr, (e, t) => No(t)).if(nc, (e, t) => us(t)).if(ec, (e, t) => BigInt(Ze(t, ns, we))).if(ke, (e, t) => kt(t, tn(t, e.shape))).if(Ho, (e, t) => {
1279
1279
  const n = {};
1280
1280
  for (const s in e.shape) {
1281
1281
  let r = e.shape[s];
1282
- if (Ro.check(r)) {
1283
- if (hs(t))
1282
+ if (Fo.check(r)) {
1283
+ if (us(t))
1284
1284
  continue;
1285
1285
  r = r.shape;
1286
1286
  }
1287
- n[s] = cr(r, t);
1287
+ n[s] = ar(r, t);
1288
1288
  }
1289
1289
  return n;
1290
- }).if(zo, (e, t) => {
1291
- const n = [], s = Ps(t, 0, 42);
1290
+ }).if(Go, (e, t) => {
1291
+ const n = [], s = Ks(t, 0, 42);
1292
1292
  for (let r = 0; r < s; r++)
1293
- n.push(_t(t, e.shape));
1293
+ n.push(kt(t, e.shape));
1294
1294
  return n;
1295
- }).if(Js, (e, t) => Ze(t, e.shape)).if(tc, (e, t) => null).if(Ko, (e, t) => {
1296
- const n = _t(t, e.res);
1295
+ }).if(Ws, (e, t) => tn(t, e.shape)).if(sc, (e, t) => null).if(qo, (e, t) => {
1296
+ const n = kt(t, e.res);
1297
1297
  return () => n;
1298
- }).if(qo, (e, t) => _t(t, Ze(t, [
1299
- At,
1298
+ }).if(tc, (e, t) => kt(t, tn(t, [
1299
+ Dt,
1300
1300
  vt,
1301
1301
  Ve,
1302
- or,
1303
- Un,
1302
+ lr,
1303
+ Rn,
1304
1304
  Fe,
1305
- tr(At),
1306
- qs($t("a", "b", "c"), At)
1307
- ]))).if(jo, (e, t) => {
1308
- const n = {}, s = Qe(t, 0, 3);
1305
+ nr(Dt),
1306
+ Zs(Rt("a", "b", "c"), Dt)
1307
+ ]))).if(Po, (e, t) => {
1308
+ const n = {}, s = Ze(t, 0, 3);
1309
1309
  for (let r = 0; r < s; r++) {
1310
- const i = _t(t, e.shape.keys), o = _t(t, e.shape.values);
1310
+ const i = kt(t, e.shape.keys), o = kt(t, e.shape.values);
1311
1311
  n[i] = o;
1312
1312
  }
1313
1313
  return n;
1314
1314
  }).done()
1315
- ), _t = (e, t) => (
1315
+ ), kt = (e, t) => (
1316
1316
  /** @type {any} */
1317
- cr(Kt(t), e)
1317
+ ar(Kt(t), e)
1318
1318
  ), je = (
1319
1319
  /** @type {Document} */
1320
1320
  typeof document != "undefined" ? document : {}
1321
1321
  );
1322
- L((e) => e.nodeType === lc);
1322
+ L((e) => e.nodeType === uc);
1323
1323
  typeof DOMParser != "undefined" && new DOMParser();
1324
- L((e) => e.nodeType === ic);
1325
- L((e) => e.nodeType === oc);
1326
- const rc = (e) => mi(e, (t, n) => `${n}:${t};`).join(""), ic = je.ELEMENT_NODE, oc = je.TEXT_NODE, cc = je.DOCUMENT_NODE, lc = je.DOCUMENT_FRAGMENT_NODE;
1327
- L((e) => e.nodeType === cc);
1328
- const tt = Symbol, lr = tt(), ar = tt(), ac = tt(), hc = tt(), uc = tt(), hr = tt(), dc = tt(), Rn = tt(), fc = tt(), gc = (e) => {
1324
+ L((e) => e.nodeType === lc);
1325
+ L((e) => e.nodeType === ac);
1326
+ const cc = (e) => ki(e, (t, n) => `${n}:${t};`).join(""), lc = je.ELEMENT_NODE, ac = je.TEXT_NODE, hc = je.DOCUMENT_NODE, uc = je.DOCUMENT_FRAGMENT_NODE;
1327
+ L((e) => e.nodeType === hc);
1328
+ const tt = Symbol, hr = tt(), ur = tt(), dc = tt(), fc = tt(), gc = tt(), dr = tt(), pc = tt(), $n = tt(), wc = tt(), mc = (e) => {
1329
1329
  var r;
1330
1330
  e.length === 1 && ((r = e[0]) == null ? void 0 : r.constructor) === Function && (e = /** @type {Array<string|Symbol|Object|number>} */
1331
1331
  /** @type {[function]} */
@@ -1346,18 +1346,18 @@ const tt = Symbol, lr = tt(), ar = tt(), ac = tt(), hc = tt(), uc = tt(), hr = t
1346
1346
  i instanceof Symbol || n.push(i);
1347
1347
  }
1348
1348
  return n;
1349
- }, pc = {
1350
- [lr]: W("font-weight", "bold"),
1351
- [ar]: W("font-weight", "normal"),
1352
- [ac]: W("color", "blue"),
1353
- [uc]: W("color", "green"),
1354
- [hc]: W("color", "grey"),
1355
- [hr]: W("color", "red"),
1356
- [dc]: W("color", "purple"),
1357
- [Rn]: W("color", "orange"),
1349
+ }, yc = {
1350
+ [hr]: W("font-weight", "bold"),
1351
+ [ur]: W("font-weight", "normal"),
1352
+ [dc]: W("color", "blue"),
1353
+ [gc]: W("color", "green"),
1354
+ [fc]: W("color", "grey"),
1355
+ [dr]: W("color", "red"),
1356
+ [pc]: W("color", "purple"),
1357
+ [$n]: W("color", "orange"),
1358
1358
  // not well supported in chrome when debugging node with inspector - TODO: deprecate
1359
- [fc]: W("color", "black")
1360
- }, wc = (e) => {
1359
+ [wc]: W("color", "black")
1360
+ }, bc = (e) => {
1361
1361
  var o;
1362
1362
  e.length === 1 && ((o = e[0]) == null ? void 0 : o.constructor) === Function && (e = /** @type {Array<string|Symbol|Object|number>} */
1363
1363
  /** @type {[function]} */
@@ -1365,14 +1365,14 @@ const tt = Symbol, lr = tt(), ar = tt(), ac = tt(), hc = tt(), uc = tt(), hr = t
1365
1365
  const t = [], n = [], s = $();
1366
1366
  let r = [], i = 0;
1367
1367
  for (; i < e.length; i++) {
1368
- const c = e[i], l = pc[c];
1368
+ const c = e[i], l = yc[c];
1369
1369
  if (l !== void 0)
1370
1370
  s.set(l.left, l.right);
1371
1371
  else {
1372
1372
  if (c === void 0)
1373
1373
  break;
1374
1374
  if (c.constructor === String || c.constructor === Number) {
1375
- const a = rc(s);
1375
+ const a = cc(s);
1376
1376
  i > 0 || a.length > 0 ? (t.push("%c" + c), n.push(a)) : t.push(c);
1377
1377
  } else
1378
1378
  break;
@@ -1383,11 +1383,11 @@ const tt = Symbol, lr = tt(), ar = tt(), ac = tt(), hc = tt(), uc = tt(), hr = t
1383
1383
  c instanceof Symbol || r.push(c);
1384
1384
  }
1385
1385
  return r;
1386
- }, ur = bo ? wc : gc, mc = (...e) => {
1387
- console.log(...ur(e)), fr.forEach((t) => t.print(e));
1388
- }, dr = (...e) => {
1389
- console.warn(...ur(e)), e.unshift(Rn), fr.forEach((t) => t.print(e));
1390
- }, fr = it(), gr = (e) => ({
1386
+ }, fr = So ? bc : mc, kc = (...e) => {
1387
+ console.log(...fr(e)), pr.forEach((t) => t.print(e));
1388
+ }, gr = (...e) => {
1389
+ console.warn(...fr(e)), e.unshift($n), pr.forEach((t) => t.print(e));
1390
+ }, pr = it(), wr = (e) => ({
1391
1391
  /**
1392
1392
  * @return {IterableIterator<T>}
1393
1393
  */
@@ -1396,13 +1396,13 @@ const tt = Symbol, lr = tt(), ar = tt(), ac = tt(), hc = tt(), uc = tt(), hr = t
1396
1396
  },
1397
1397
  // @ts-ignore
1398
1398
  next: e
1399
- }), yc = (e, t) => gr(() => {
1399
+ }), _c = (e, t) => wr(() => {
1400
1400
  let n;
1401
1401
  do
1402
1402
  n = e.next();
1403
1403
  while (!n.done && !t(n.value));
1404
1404
  return n;
1405
- }), tn = (e, t) => gr(() => {
1405
+ }), en = (e, t) => wr(() => {
1406
1406
  const { done: n, value: s } = e.next();
1407
1407
  return { done: n, value: n ? void 0 : t(s) };
1408
1408
  });
@@ -1415,12 +1415,12 @@ class He {
1415
1415
  this.clock = t, this.len = n;
1416
1416
  }
1417
1417
  }
1418
- class Bt {
1418
+ class $t {
1419
1419
  constructor() {
1420
1420
  this.clients = /* @__PURE__ */ new Map();
1421
1421
  }
1422
1422
  }
1423
- const Nt = (e, t, n) => t.clients.forEach((s, r) => {
1423
+ const Ot = (e, t, n) => t.clients.forEach((s, r) => {
1424
1424
  const i = (
1425
1425
  /** @type {Array<GC|Item>} */
1426
1426
  e.doc.store.clients.get(r)
@@ -1428,9 +1428,9 @@ const Nt = (e, t, n) => t.clients.forEach((s, r) => {
1428
1428
  if (i != null) {
1429
1429
  const o = i[i.length - 1], c = o.id.clock + o.length;
1430
1430
  for (let l = 0, a = s[l]; l < s.length && a.clock < c; a = s[++l])
1431
- Ar(e, i, a.clock, a.len, n);
1431
+ xr(e, i, a.clock, a.len, n);
1432
1432
  }
1433
- }), bc = (e, t) => {
1433
+ }), Sc = (e, t) => {
1434
1434
  let n = 0, s = e.length - 1;
1435
1435
  for (; n <= s; ) {
1436
1436
  const r = z((n + s) / 2), i = e[r], o = i.clock;
@@ -1444,8 +1444,8 @@ const Nt = (e, t, n) => t.clients.forEach((s, r) => {
1444
1444
  return null;
1445
1445
  }, ee = (e, t) => {
1446
1446
  const n = e.clients.get(t.client);
1447
- return n !== void 0 && bc(n, t.clock) !== null;
1448
- }, $n = (e) => {
1447
+ return n !== void 0 && Sc(n, t.clock) !== null;
1448
+ }, Bn = (e) => {
1449
1449
  e.clients.forEach((t) => {
1450
1450
  t.sort((r, i) => r.clock - i.clock);
1451
1451
  let n, s;
@@ -1455,25 +1455,25 @@ const Nt = (e, t, n) => t.clients.forEach((s, r) => {
1455
1455
  }
1456
1456
  t.length = s;
1457
1457
  });
1458
- }, fn = (e) => {
1459
- const t = new Bt();
1458
+ }, gn = (e) => {
1459
+ const t = new $t();
1460
1460
  for (let n = 0; n < e.length; n++)
1461
1461
  e[n].clients.forEach((s, r) => {
1462
1462
  if (!t.clients.has(r)) {
1463
1463
  const i = s.slice();
1464
1464
  for (let o = n + 1; o < e.length; o++)
1465
- bi(i, e[o].clients.get(r) || []);
1465
+ Si(i, e[o].clients.get(r) || []);
1466
1466
  t.clients.set(r, i);
1467
1467
  }
1468
1468
  });
1469
- return $n(t), t;
1469
+ return Bn(t), t;
1470
1470
  }, Wt = (e, t, n, s) => {
1471
1471
  K(e.clients, t, () => (
1472
1472
  /** @type {Array<DeleteItem>} */
1473
1473
  []
1474
1474
  )).push(new He(n, s));
1475
- }, kc = () => new Bt(), _c = (e) => {
1476
- const t = kc();
1475
+ }, Cc = () => new $t(), Ec = (e) => {
1476
+ const t = Cc();
1477
1477
  return e.clients.forEach((n, s) => {
1478
1478
  const r = [];
1479
1479
  for (let i = 0; i < n.length; i++) {
@@ -1489,7 +1489,7 @@ const Nt = (e, t, n) => t.clients.forEach((s, r) => {
1489
1489
  }
1490
1490
  r.length > 0 && t.clients.set(s, r);
1491
1491
  }), t;
1492
- }, Ft = (e, t) => {
1492
+ }, Bt = (e, t) => {
1493
1493
  m(e.restEncoder, t.clients.size), q(t.clients.entries()).sort((n, s) => s[0] - n[0]).forEach(([n, s]) => {
1494
1494
  e.resetDsCurVal(), m(e.restEncoder, n);
1495
1495
  const r = s.length;
@@ -1499,8 +1499,8 @@ const Nt = (e, t, n) => t.clients.forEach((s, r) => {
1499
1499
  e.writeDsClock(o.clock), e.writeDsLen(o.len);
1500
1500
  }
1501
1501
  });
1502
- }, Bn = (e) => {
1503
- const t = new Bt(), n = b(e.restDecoder);
1502
+ }, Fn = (e) => {
1503
+ const t = new $t(), n = b(e.restDecoder);
1504
1504
  for (let s = 0; s < n; s++) {
1505
1505
  e.resetDsCurVal();
1506
1506
  const r = b(e.restDecoder), i = b(e.restDecoder);
@@ -1514,8 +1514,8 @@ const Nt = (e, t, n) => t.clients.forEach((s, r) => {
1514
1514
  }
1515
1515
  }
1516
1516
  return t;
1517
- }, ds = (e, t, n) => {
1518
- const s = new Bt(), r = b(e.restDecoder);
1517
+ }, fs = (e, t, n) => {
1518
+ const s = new $t(), r = b(e.restDecoder);
1519
1519
  for (let i = 0; i < r; i++) {
1520
1520
  e.resetDsCurVal();
1521
1521
  const o = b(e.restDecoder), c = b(e.restDecoder), l = n.clients.get(o) || [], a = A(n, o);
@@ -1523,7 +1523,7 @@ const Nt = (e, t, n) => t.clients.forEach((s, r) => {
1523
1523
  const d = e.readDsClock(), u = d + e.readDsLen();
1524
1524
  if (d < a) {
1525
1525
  a < u && Wt(s, o, a, u - a);
1526
- let f = P(l, d), g = l[f];
1526
+ let f = G(l, d), g = l[f];
1527
1527
  for (!g.deleted && g.id.clock < d && (l.splice(f + 1, 0, xe(t, g, d - g.id.clock)), f++); f < l.length && (g = l[f++], g.id.clock < u); )
1528
1528
  g.deleted || (u < g.id.clock + g.length && l.splice(f, 0, xe(t, g, u - g.id.clock)), g.delete(t));
1529
1529
  } else
@@ -1532,21 +1532,21 @@ const Nt = (e, t, n) => t.clients.forEach((s, r) => {
1532
1532
  }
1533
1533
  if (s.clients.size > 0) {
1534
1534
  const i = new dt();
1535
- return m(i.restEncoder, 0), Ft(i, s), i.toUint8Array();
1535
+ return m(i.restEncoder, 0), Bt(i, s), i.toUint8Array();
1536
1536
  }
1537
1537
  return null;
1538
- }, pr = $s;
1539
- class yt extends Sn {
1538
+ }, mr = Fs;
1539
+ class yt extends Cn {
1540
1540
  /**
1541
1541
  * @param {DocOpts} opts configuration
1542
1542
  */
1543
- constructor({ guid: t = eo(), collectionid: n = null, gc: s = !0, gcFilter: r = () => !0, meta: i = null, autoLoad: o = !1, shouldLoad: c = !0 } = {}) {
1544
- super(), this.gc = s, this.gcFilter = r, this.clientID = pr(), this.guid = t, this.collectionid = n, this.share = /* @__PURE__ */ new Map(), this.store = new Er(), 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.isDestroyed = !1, this.whenLoaded = ls((a) => {
1543
+ constructor({ guid: t = ro(), collectionid: n = null, gc: s = !0, gcFilter: r = () => !0, meta: i = null, autoLoad: o = !1, shouldLoad: c = !0 } = {}) {
1544
+ super(), this.gc = s, this.gcFilter = r, this.clientID = mr(), this.guid = t, this.collectionid = n, this.share = /* @__PURE__ */ new Map(), this.store = new Ar(), 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.isDestroyed = !1, this.whenLoaded = as((a) => {
1545
1545
  this.on("load", () => {
1546
1546
  this.isLoaded = !0, a(this);
1547
1547
  });
1548
1548
  });
1549
- const l = () => ls((a) => {
1549
+ const l = () => as((a) => {
1550
1550
  const h = (d) => {
1551
1551
  (d === void 0 || d === !0) && (this.off("sync", h), a());
1552
1552
  };
@@ -1663,7 +1663,7 @@ class yt extends Sn {
1663
1663
  getArray(t = "") {
1664
1664
  return (
1665
1665
  /** @type {YArray<T>} */
1666
- this.get(t, xt)
1666
+ this.get(t, Tt)
1667
1667
  );
1668
1668
  }
1669
1669
  /**
@@ -1673,7 +1673,7 @@ class yt extends Sn {
1673
1673
  * @public
1674
1674
  */
1675
1675
  getText(t = "") {
1676
- return this.get(t, Rt);
1676
+ return this.get(t, Ut);
1677
1677
  }
1678
1678
  /**
1679
1679
  * @template T
@@ -1685,7 +1685,7 @@ class yt extends Sn {
1685
1685
  getMap(t = "") {
1686
1686
  return (
1687
1687
  /** @type {YMap<T>} */
1688
- this.get(t, Ut)
1688
+ this.get(t, Mt)
1689
1689
  );
1690
1690
  }
1691
1691
  /**
@@ -1749,7 +1749,7 @@ class yt extends Sn {
1749
1749
  this.emit("destroyed", [!0]), this.emit("destroy", [this]), super.destroy();
1750
1750
  }
1751
1751
  }
1752
- class wr {
1752
+ class yr {
1753
1753
  /**
1754
1754
  * @param {decoding.Decoder} decoder
1755
1755
  */
@@ -1771,7 +1771,7 @@ class wr {
1771
1771
  return b(this.restDecoder);
1772
1772
  }
1773
1773
  }
1774
- class mr extends wr {
1774
+ class br extends yr {
1775
1775
  /**
1776
1776
  * @return {ID}
1777
1777
  */
@@ -1795,7 +1795,7 @@ class mr extends wr {
1795
1795
  * @return {number} info An unsigned 8-bit integer
1796
1796
  */
1797
1797
  readInfo() {
1798
- return Ot(this.restDecoder);
1798
+ return Lt(this.restDecoder);
1799
1799
  }
1800
1800
  /**
1801
1801
  * @return {string}
@@ -1827,13 +1827,13 @@ class mr extends wr {
1827
1827
  * @return {any}
1828
1828
  */
1829
1829
  readAny() {
1830
- return Pt(this.restDecoder);
1830
+ return Gt(this.restDecoder);
1831
1831
  }
1832
1832
  /**
1833
1833
  * @return {Uint8Array}
1834
1834
  */
1835
1835
  readBuf() {
1836
- return To(v(this.restDecoder));
1836
+ return Lo(O(this.restDecoder));
1837
1837
  }
1838
1838
  /**
1839
1839
  * Legacy implementation uses JSON parse. We use any-decoding in v2.
@@ -1850,7 +1850,7 @@ class mr extends wr {
1850
1850
  return rt(this.restDecoder);
1851
1851
  }
1852
1852
  }
1853
- class Sc {
1853
+ class Dc {
1854
1854
  /**
1855
1855
  * @param {decoding.Decoder} decoder
1856
1856
  */
@@ -1874,24 +1874,24 @@ class Sc {
1874
1874
  return this.dsCurrVal += t, t;
1875
1875
  }
1876
1876
  }
1877
- class Mt extends Sc {
1877
+ class Nt extends Dc {
1878
1878
  /**
1879
1879
  * @param {decoding.Decoder} decoder
1880
1880
  */
1881
1881
  constructor(t) {
1882
- super(t), this.keys = [], b(t), this.keyClockDecoder = new qe(v(t)), this.clientDecoder = new de(v(t)), this.leftClockDecoder = new qe(v(t)), this.rightClockDecoder = new qe(v(t)), this.infoDecoder = new cs(v(t), Ot), this.stringDecoder = new Qi(v(t)), this.parentInfoDecoder = new cs(v(t), Ot), this.typeRefDecoder = new de(v(t)), this.lenDecoder = new de(v(t));
1882
+ super(t), this.keys = [], b(t), this.keyClockDecoder = new Qe(O(t)), this.clientDecoder = new de(O(t)), this.leftClockDecoder = new Qe(O(t)), this.rightClockDecoder = new Qe(O(t)), this.infoDecoder = new ls(O(t), Lt), this.stringDecoder = new eo(O(t)), this.parentInfoDecoder = new ls(O(t), Lt), this.typeRefDecoder = new de(O(t)), this.lenDecoder = new de(O(t));
1883
1883
  }
1884
1884
  /**
1885
1885
  * @return {ID}
1886
1886
  */
1887
1887
  readLeftID() {
1888
- return new Tt(this.clientDecoder.read(), this.leftClockDecoder.read());
1888
+ return new At(this.clientDecoder.read(), this.leftClockDecoder.read());
1889
1889
  }
1890
1890
  /**
1891
1891
  * @return {ID}
1892
1892
  */
1893
1893
  readRightID() {
1894
- return new Tt(this.clientDecoder.read(), this.rightClockDecoder.read());
1894
+ return new At(this.clientDecoder.read(), this.rightClockDecoder.read());
1895
1895
  }
1896
1896
  /**
1897
1897
  * Read the next client id.
@@ -1939,13 +1939,13 @@ class Mt extends Sc {
1939
1939
  * @return {any}
1940
1940
  */
1941
1941
  readAny() {
1942
- return Pt(this.restDecoder);
1942
+ return Gt(this.restDecoder);
1943
1943
  }
1944
1944
  /**
1945
1945
  * @return {Uint8Array}
1946
1946
  */
1947
1947
  readBuf() {
1948
- return v(this.restDecoder);
1948
+ return O(this.restDecoder);
1949
1949
  }
1950
1950
  /**
1951
1951
  * This is mainly here for legacy purposes.
@@ -1955,7 +1955,7 @@ class Mt extends Sc {
1955
1955
  * @return {any}
1956
1956
  */
1957
1957
  readJSON() {
1958
- return Pt(this.restDecoder);
1958
+ return Gt(this.restDecoder);
1959
1959
  }
1960
1960
  /**
1961
1961
  * @return {string}
@@ -1970,7 +1970,7 @@ class Mt extends Sc {
1970
1970
  }
1971
1971
  }
1972
1972
  }
1973
- class yr {
1973
+ class kr {
1974
1974
  constructor() {
1975
1975
  this.restEncoder = N();
1976
1976
  }
@@ -1992,7 +1992,7 @@ class yr {
1992
1992
  m(this.restEncoder, t);
1993
1993
  }
1994
1994
  }
1995
- class ne extends yr {
1995
+ class ne extends kr {
1996
1996
  /**
1997
1997
  * @param {ID} id
1998
1998
  */
@@ -2016,7 +2016,7 @@ class ne extends yr {
2016
2016
  * @param {number} info An unsigned 8-bit integer
2017
2017
  */
2018
2018
  writeInfo(t) {
2019
- an(this.restEncoder, t);
2019
+ hn(this.restEncoder, t);
2020
2020
  }
2021
2021
  /**
2022
2022
  * @param {string} s
@@ -2048,7 +2048,7 @@ class ne extends yr {
2048
2048
  * @param {any} any
2049
2049
  */
2050
2050
  writeAny(t) {
2051
- Gt(this.restEncoder, t);
2051
+ Yt(this.restEncoder, t);
2052
2052
  }
2053
2053
  /**
2054
2054
  * @param {Uint8Array} buf
@@ -2069,7 +2069,7 @@ class ne extends yr {
2069
2069
  ut(this.restEncoder, t);
2070
2070
  }
2071
2071
  }
2072
- class br {
2072
+ class _r {
2073
2073
  constructor() {
2074
2074
  this.restEncoder = N(), this.dsCurrVal = 0;
2075
2075
  }
@@ -2093,9 +2093,9 @@ class br {
2093
2093
  t === 0 && j(), m(this.restEncoder, t - 1), this.dsCurrVal += t;
2094
2094
  }
2095
2095
  }
2096
- class dt extends br {
2096
+ class dt extends _r {
2097
2097
  constructor() {
2098
- super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new Xe(), this.clientEncoder = new ue(), this.leftClockEncoder = new Xe(), this.rightClockEncoder = new Xe(), this.infoEncoder = new rs(an), this.stringEncoder = new ji(), this.parentInfoEncoder = new rs(an), this.typeRefEncoder = new ue(), this.lenEncoder = new ue();
2098
+ super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new qe(), this.clientEncoder = new ue(), this.leftClockEncoder = new qe(), this.rightClockEncoder = new qe(), this.infoEncoder = new is(hn), this.stringEncoder = new Pi(), this.parentInfoEncoder = new is(hn), this.typeRefEncoder = new ue(), this.lenEncoder = new ue();
2099
2099
  }
2100
2100
  toUint8Array() {
2101
2101
  const t = N();
@@ -2155,7 +2155,7 @@ class dt extends br {
2155
2155
  * @param {any} any
2156
2156
  */
2157
2157
  writeAny(t) {
2158
- Gt(this.restEncoder, t);
2158
+ Yt(this.restEncoder, t);
2159
2159
  }
2160
2160
  /**
2161
2161
  * @param {Uint8Array} buf
@@ -2171,7 +2171,7 @@ class dt extends br {
2171
2171
  * @param {any} embed
2172
2172
  */
2173
2173
  writeJSON(t) {
2174
- Gt(this.restEncoder, t);
2174
+ Yt(this.restEncoder, t);
2175
2175
  }
2176
2176
  /**
2177
2177
  * Property keys are often reused. For example, in y-prosemirror the key `bold` might
@@ -2186,22 +2186,22 @@ class dt extends br {
2186
2186
  n === void 0 ? (this.keyClockEncoder.write(this.keyClock++), this.stringEncoder.write(t)) : this.keyClockEncoder.write(n);
2187
2187
  }
2188
2188
  }
2189
- const Cc = (e, t, n, s) => {
2189
+ const Ac = (e, t, n, s) => {
2190
2190
  s = mt(s, t[0].id.clock);
2191
- const r = P(t, s);
2191
+ const r = G(t, s);
2192
2192
  m(e.restEncoder, t.length - r), e.writeClient(n), m(e.restEncoder, s);
2193
2193
  const i = t[r];
2194
2194
  i.write(e, s - i.id.clock);
2195
2195
  for (let o = r + 1; o < t.length; o++)
2196
2196
  t[o].write(e, 0);
2197
- }, Fn = (e, t, n) => {
2197
+ }, Vn = (e, t, n) => {
2198
2198
  const s = /* @__PURE__ */ new Map();
2199
2199
  n.forEach((r, i) => {
2200
2200
  A(t, i) > r && s.set(i, r);
2201
2201
  }), ze(t).forEach((r, i) => {
2202
2202
  n.has(i) || s.set(i, 0);
2203
2203
  }), m(e.restEncoder, s.size), q(s.entries()).sort((r, i) => i[0] - r[0]).forEach(([r, i]) => {
2204
- Cc(
2204
+ Ac(
2205
2205
  e,
2206
2206
  /** @type {Array<GC|Item>} */
2207
2207
  t.clients.get(r),
@@ -2209,7 +2209,7 @@ const Cc = (e, t, n, s) => {
2209
2209
  i
2210
2210
  );
2211
2211
  });
2212
- }, Ec = (e, t) => {
2212
+ }, Tc = (e, t) => {
2213
2213
  const n = $(), s = b(e.restDecoder);
2214
2214
  for (let r = 0; r < s; r++) {
2215
2215
  const i = b(e.restDecoder), o = new Array(i), c = e.readClient();
@@ -2217,7 +2217,7 @@ const Cc = (e, t, n, s) => {
2217
2217
  n.set(c, { i: 0, refs: o });
2218
2218
  for (let a = 0; a < i; a++) {
2219
2219
  const h = e.readInfo();
2220
- switch (ve & h) {
2220
+ switch (Oe & h) {
2221
2221
  case 0: {
2222
2222
  const d = e.readLen();
2223
2223
  o[a] = new F(k(c, l), d), l += d;
@@ -2243,7 +2243,7 @@ const Cc = (e, t, n, s) => {
2243
2243
  // parent
2244
2244
  d && (h & zt) === zt ? e.readString() : null,
2245
2245
  // parentSub
2246
- Pr(e, h)
2246
+ Kr(e, h)
2247
2247
  // item content
2248
2248
  );
2249
2249
  o[a] = u, l += u.length;
@@ -2252,7 +2252,7 @@ const Cc = (e, t, n, s) => {
2252
2252
  }
2253
2253
  }
2254
2254
  return n;
2255
- }, Dc = (e, t, n) => {
2255
+ }, xc = (e, t, n) => {
2256
2256
  const s = [];
2257
2257
  let r = q(n.keys()).sort((f, g) => f - g);
2258
2258
  if (r.length === 0)
@@ -2275,7 +2275,7 @@ const Cc = (e, t, n, s) => {
2275
2275
  let o = i();
2276
2276
  if (o === null)
2277
2277
  return null;
2278
- const c = new Er(), l = /* @__PURE__ */ new Map(), a = (f, g) => {
2278
+ const c = new Ar(), l = /* @__PURE__ */ new Map(), a = (f, g) => {
2279
2279
  const w = l.get(f);
2280
2280
  (w == null || w > g) && l.set(f, g);
2281
2281
  };
@@ -2334,13 +2334,13 @@ const Cc = (e, t, n, s) => {
2334
2334
  }
2335
2335
  if (c.clients.size > 0) {
2336
2336
  const f = new dt();
2337
- return Fn(f, c, /* @__PURE__ */ new Map()), m(f.restEncoder, 0), { missing: l, update: f.toUint8Array() };
2337
+ return Vn(f, c, /* @__PURE__ */ new Map()), m(f.restEncoder, 0), { missing: l, update: f.toUint8Array() };
2338
2338
  }
2339
2339
  return null;
2340
- }, Ac = (e, t) => Fn(e, t.doc.store, t.beforeState), Tc = (e, t, n, s = new Mt(e)) => _(t, (r) => {
2340
+ }, Ic = (e, t) => Vn(e, t.doc.store, t.beforeState), Lc = (e, t, n, s = new Nt(e)) => _(t, (r) => {
2341
2341
  r.local = !1;
2342
2342
  let i = !1;
2343
- const o = r.doc, c = o.store, l = Ec(s, o), a = Dc(r, c, l), h = c.pendingStructs;
2343
+ const o = r.doc, c = o.store, l = Tc(s, o), a = xc(r, c, l), h = c.pendingStructs;
2344
2344
  if (h) {
2345
2345
  for (const [u, f] of h.missing)
2346
2346
  if (f < A(c, u)) {
@@ -2356,11 +2356,11 @@ const Cc = (e, t, n, s) => {
2356
2356
  }
2357
2357
  } else
2358
2358
  c.pendingStructs = a;
2359
- const d = ds(s, r, c);
2359
+ const d = fs(s, r, c);
2360
2360
  if (c.pendingDs) {
2361
- const u = new Mt(lt(c.pendingDs));
2361
+ const u = new Nt(lt(c.pendingDs));
2362
2362
  b(u.restDecoder);
2363
- const f = ds(u, r, c);
2363
+ const f = fs(u, r, c);
2364
2364
  d && f ? c.pendingDs = Ce([d, f]) : c.pendingDs = d || f;
2365
2365
  } else
2366
2366
  c.pendingDs = d;
@@ -2369,44 +2369,44 @@ const Cc = (e, t, n, s) => {
2369
2369
  /** @type {{update: Uint8Array}} */
2370
2370
  c.pendingStructs.update
2371
2371
  );
2372
- c.pendingStructs = null, kr(r.doc, u);
2372
+ c.pendingStructs = null, Sr(r.doc, u);
2373
2373
  }
2374
- }, n, !1), kr = (e, t, n, s = Mt) => {
2374
+ }, n, !1), Sr = (e, t, n, s = Nt) => {
2375
2375
  const r = lt(t);
2376
- Tc(r, e, n, new s(r));
2377
- }, xc = (e, t, n) => kr(e, t, n, mr), Ic = (e, t, n = /* @__PURE__ */ new Map()) => {
2378
- Fn(e, t.store, n), Ft(e, _c(t.store));
2379
- }, Lc = (e, t = new Uint8Array([0]), n = new dt()) => {
2380
- const s = _r(t);
2381
- Ic(n, e, s);
2376
+ Lc(r, e, n, new s(r));
2377
+ }, vc = (e, t, n) => Sr(e, t, n, br), Oc = (e, t, n = /* @__PURE__ */ new Map()) => {
2378
+ Vn(e, t.store, n), Bt(e, Ec(t.store));
2379
+ }, Nc = (e, t = new Uint8Array([0]), n = new dt()) => {
2380
+ const s = Cr(t);
2381
+ Oc(n, e, s);
2382
2382
  const r = [n.toUint8Array()];
2383
- if (e.store.pendingDs && r.push(e.store.pendingDs), e.store.pendingStructs && r.push(Kc(e.store.pendingStructs.update, t)), r.length > 1) {
2383
+ if (e.store.pendingDs && r.push(e.store.pendingDs), e.store.pendingStructs && r.push(qc(e.store.pendingStructs.update, t)), r.length > 1) {
2384
2384
  if (n.constructor === ne)
2385
- return Pc(r.map((i, o) => o === 0 ? i : Xc(i)));
2385
+ return Wc(r.map((i, o) => o === 0 ? i : Zc(i)));
2386
2386
  if (n.constructor === dt)
2387
2387
  return Ce(r);
2388
2388
  }
2389
2389
  return r[0];
2390
- }, Oc = (e, t) => Lc(e, t, new ne()), vc = (e) => {
2390
+ }, Mc = (e, t) => Nc(e, t, new ne()), Uc = (e) => {
2391
2391
  const t = /* @__PURE__ */ new Map(), n = b(e.restDecoder);
2392
2392
  for (let s = 0; s < n; s++) {
2393
2393
  const r = b(e.restDecoder), i = b(e.restDecoder);
2394
2394
  t.set(r, i);
2395
2395
  }
2396
2396
  return t;
2397
- }, _r = (e) => vc(new wr(lt(e))), Sr = (e, t) => (m(e.restEncoder, t.size), q(t.entries()).sort((n, s) => s[0] - n[0]).forEach(([n, s]) => {
2397
+ }, Cr = (e) => Uc(new yr(lt(e))), Er = (e, t) => (m(e.restEncoder, t.size), q(t.entries()).sort((n, s) => s[0] - n[0]).forEach(([n, s]) => {
2398
2398
  m(e.restEncoder, n), m(e.restEncoder, s);
2399
- }), e), Nc = (e, t) => Sr(e, ze(t.store)), Mc = (e, t = new br()) => (e instanceof Map ? Sr(t, e) : Nc(t, e), t.toUint8Array()), Uc = (e) => Mc(e, new yr());
2400
- class Rc {
2399
+ }), e), Rc = (e, t) => Er(e, ze(t.store)), $c = (e, t = new _r()) => (e instanceof Map ? Er(t, e) : Rc(t, e), t.toUint8Array()), Bc = (e) => $c(e, new kr());
2400
+ class Fc {
2401
2401
  constructor() {
2402
2402
  this.l = [];
2403
2403
  }
2404
2404
  }
2405
- const fs = () => new Rc(), gs = (e, t) => e.l.push(t), ps = (e, t) => {
2405
+ const gs = () => new Fc(), ps = (e, t) => e.l.push(t), ws = (e, t) => {
2406
2406
  const n = e.l, s = n.length;
2407
2407
  e.l = n.filter((r) => t !== r), s === e.l.length && console.error("[yjs] Tried to remove event handler that doesn't exist.");
2408
- }, Cr = (e, t, n) => On(e.l, [t, n]);
2409
- class Tt {
2408
+ }, Dr = (e, t, n) => On(e.l, [t, n]);
2409
+ class At {
2410
2410
  /**
2411
2411
  * @param {number} client client id
2412
2412
  * @param {number} clock unique per client id, continuous number
@@ -2415,7 +2415,7 @@ class Tt {
2415
2415
  this.client = t, this.clock = n;
2416
2416
  }
2417
2417
  }
2418
- const ce = (e, t) => e === t || e !== null && t !== null && e.client === t.client && e.clock === t.clock, k = (e, t) => new Tt(e, t), $c = (e) => {
2418
+ const ce = (e, t) => e === t || e !== null && t !== null && e.client === t.client && e.clock === t.clock, k = (e, t) => new At(e, t), Vc = (e) => {
2419
2419
  for (const [t, n] of e.doc.share.entries())
2420
2420
  if (n === e)
2421
2421
  return t;
@@ -2428,14 +2428,14 @@ const ce = (e, t) => e === t || e !== null && t !== null && e.client === t.clien
2428
2428
  t.parent._item;
2429
2429
  }
2430
2430
  return !1;
2431
- }, St = (e, t) => t === void 0 ? !e.deleted : t.sv.has(e.id.client) && (t.sv.get(e.id.client) || 0) > e.id.clock && !ee(t.ds, e.id), gn = (e, t) => {
2432
- const n = K(e.meta, gn, it), s = e.doc.store;
2431
+ }, _t = (e, t) => t === void 0 ? !e.deleted : t.sv.has(e.id.client) && (t.sv.get(e.id.client) || 0) > e.id.clock && !ee(t.ds, e.id), pn = (e, t) => {
2432
+ const n = K(e.meta, pn, it), s = e.doc.store;
2433
2433
  n.has(t) || (t.sv.forEach((r, i) => {
2434
2434
  r < A(s, i) && R(e, k(i, r));
2435
- }), Nt(e, t.ds, (r) => {
2435
+ }), Ot(e, t.ds, (r) => {
2436
2436
  }), n.add(t));
2437
2437
  };
2438
- class Er {
2438
+ class Ar {
2439
2439
  constructor() {
2440
2440
  this.clients = /* @__PURE__ */ new Map(), this.pendingStructs = null, this.pendingDs = null;
2441
2441
  }
@@ -2452,7 +2452,7 @@ const ze = (e) => {
2452
2452
  return 0;
2453
2453
  const s = n[n.length - 1];
2454
2454
  return s.id.clock + s.length;
2455
- }, Dr = (e, t) => {
2455
+ }, Tr = (e, t) => {
2456
2456
  let n = e.clients.get(t.id.client);
2457
2457
  if (n === void 0)
2458
2458
  n = [], e.clients.set(t.id.client, n);
@@ -2462,7 +2462,7 @@ const ze = (e) => {
2462
2462
  throw j();
2463
2463
  }
2464
2464
  n.push(t);
2465
- }, P = (e, t) => {
2465
+ }, G = (e, t) => {
2466
2466
  let n = 0, s = e.length - 1, r = e[s], i = r.id.clock;
2467
2467
  if (i === t)
2468
2468
  return s;
@@ -2477,50 +2477,50 @@ const ze = (e) => {
2477
2477
  o = z((n + s) / 2);
2478
2478
  }
2479
2479
  throw j();
2480
- }, Bc = (e, t) => {
2480
+ }, jc = (e, t) => {
2481
2481
  const n = e.clients.get(t.client);
2482
- return n[P(n, t.clock)];
2482
+ return n[G(n, t.clock)];
2483
2483
  }, fe = (
2484
2484
  /** @type {function(StructStore,ID):Item} */
2485
- Bc
2486
- ), pn = (e, t, n) => {
2487
- const s = P(t, n), r = t[s];
2485
+ jc
2486
+ ), wn = (e, t, n) => {
2487
+ const s = G(t, n), r = t[s];
2488
2488
  return r.id.clock < n && r instanceof S ? (t.splice(s + 1, 0, xe(e, r, n - r.id.clock)), s + 1) : s;
2489
2489
  }, R = (e, t) => {
2490
2490
  const n = (
2491
2491
  /** @type {Array<Item>} */
2492
2492
  e.doc.store.clients.get(t.client)
2493
2493
  );
2494
- return n[pn(e, n, t.clock)];
2495
- }, ws = (e, t, n) => {
2496
- const s = t.clients.get(n.client), r = P(s, n.clock), i = s[r];
2494
+ return n[wn(e, n, t.clock)];
2495
+ }, ms = (e, t, n) => {
2496
+ const s = t.clients.get(n.client), r = G(s, n.clock), i = s[r];
2497
2497
  return n.clock !== i.id.clock + i.length - 1 && i.constructor !== F && s.splice(r + 1, 0, xe(e, i, n.clock - i.id.clock + 1)), i;
2498
- }, Fc = (e, t, n) => {
2498
+ }, Hc = (e, t, n) => {
2499
2499
  const s = (
2500
2500
  /** @type {Array<GC|Item>} */
2501
2501
  e.clients.get(t.id.client)
2502
2502
  );
2503
- s[P(s, t.id.clock)] = n;
2504
- }, Ar = (e, t, n, s, r) => {
2503
+ s[G(s, t.id.clock)] = n;
2504
+ }, xr = (e, t, n, s, r) => {
2505
2505
  if (s === 0)
2506
2506
  return;
2507
2507
  const i = n + s;
2508
- let o = pn(e, t, n), c;
2508
+ let o = wn(e, t, n), c;
2509
2509
  do
2510
- c = t[o++], i < c.id.clock + c.length && pn(e, t, i), r(c);
2510
+ c = t[o++], i < c.id.clock + c.length && wn(e, t, i), r(c);
2511
2511
  while (o < t.length && t[o].id.clock < i);
2512
2512
  };
2513
- class Vc {
2513
+ class zc {
2514
2514
  /**
2515
2515
  * @param {Doc} doc
2516
2516
  * @param {any} origin
2517
2517
  * @param {boolean} local
2518
2518
  */
2519
2519
  constructor(t, n, s) {
2520
- this.doc = t, this.deleteSet = new Bt(), this.beforeState = ze(t.store), this.afterState = /* @__PURE__ */ new Map(), this.changed = /* @__PURE__ */ new Map(), this.changedParentTypes = /* @__PURE__ */ new Map(), this._mergeStructs = [], this.origin = n, 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;
2520
+ this.doc = t, this.deleteSet = new $t(), this.beforeState = ze(t.store), this.afterState = /* @__PURE__ */ new Map(), this.changed = /* @__PURE__ */ new Map(), this.changedParentTypes = /* @__PURE__ */ new Map(), this._mergeStructs = [], this.origin = n, 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;
2521
2521
  }
2522
2522
  }
2523
- const ms = (e, t) => t.deleteSet.clients.size === 0 && !yi(t.afterState, (n, s) => t.beforeState.get(s) !== n) ? !1 : ($n(t.deleteSet), Ac(e, t), Ft(e, t.deleteSet), !0), ys = (e, t, n) => {
2523
+ const ys = (e, t) => t.deleteSet.clients.size === 0 && !_i(t.afterState, (n, s) => t.beforeState.get(s) !== n) ? !1 : (Bn(t.deleteSet), Ic(e, t), Bt(e, t.deleteSet), !0), bs = (e, t, n) => {
2524
2524
  const s = t._item;
2525
2525
  (s === null || s.id.clock < (e.beforeState.get(s.id.client) || 0) && !s.deleted) && K(e.changed, t, it).add(n);
2526
2526
  }, ge = (e, t) => {
@@ -2539,7 +2539,7 @@ const ms = (e, t) => t.deleteSet.clients.size === 0 && !yi(t.afterState, (n, s)
2539
2539
  }
2540
2540
  const i = t - r;
2541
2541
  return i && e.splice(t + 1 - i, i), i;
2542
- }, jc = (e, t, n) => {
2542
+ }, Pc = (e, t, n) => {
2543
2543
  for (const [s, r] of e.clients.entries()) {
2544
2544
  const i = (
2545
2545
  /** @type {Array<GC|Item>} */
@@ -2547,7 +2547,7 @@ const ms = (e, t) => t.deleteSet.clients.size === 0 && !yi(t.afterState, (n, s)
2547
2547
  );
2548
2548
  for (let o = r.length - 1; o >= 0; o--) {
2549
2549
  const c = r[o], l = c.clock + c.len;
2550
- for (let a = P(i, c.clock), h = i[a]; a < i.length && h.id.clock < l; h = i[++a]) {
2550
+ for (let a = G(i, c.clock), h = i[a]; a < i.length && h.id.clock < l; h = i[++a]) {
2551
2551
  const d = i[a];
2552
2552
  if (c.clock + c.len <= d.id.clock)
2553
2553
  break;
@@ -2555,23 +2555,23 @@ const ms = (e, t) => t.deleteSet.clients.size === 0 && !yi(t.afterState, (n, s)
2555
2555
  }
2556
2556
  }
2557
2557
  }
2558
- }, Hc = (e, t) => {
2558
+ }, Yc = (e, t) => {
2559
2559
  e.clients.forEach((n, s) => {
2560
2560
  const r = (
2561
2561
  /** @type {Array<GC|Item>} */
2562
2562
  t.clients.get(s)
2563
2563
  );
2564
2564
  for (let i = n.length - 1; i >= 0; i--) {
2565
- const o = n[i], c = Cn(r.length - 1, 1 + P(r, o.clock + o.len - 1));
2565
+ const o = n[i], c = En(r.length - 1, 1 + G(r, o.clock + o.len - 1));
2566
2566
  for (let l = c, a = r[l]; l > 0 && a.id.clock >= o.clock; a = r[l])
2567
2567
  l -= 1 + ge(r, l);
2568
2568
  }
2569
2569
  });
2570
- }, Tr = (e, t) => {
2570
+ }, Ir = (e, t) => {
2571
2571
  if (t < e.length) {
2572
2572
  const n = e[t], s = n.doc, r = s.store, i = n.deleteSet, o = n._mergeStructs;
2573
2573
  try {
2574
- $n(i), n.afterState = ze(n.doc.store), s.emit("beforeObserverCalls", [n, s]);
2574
+ Bn(i), n.afterState = ze(n.doc.store), s.emit("beforeObserverCalls", [n, s]);
2575
2575
  const c = [];
2576
2576
  n.changed.forEach(
2577
2577
  (l, a) => c.push(() => {
@@ -2584,20 +2584,20 @@ const ms = (e, t) => t.deleteSet.clients.size === 0 && !yi(t.afterState, (n, s)
2584
2584
  (h) => h.target._item === null || !h.target._item.deleted
2585
2585
  ), l.forEach((h) => {
2586
2586
  h.currentTarget = a, h._path = null;
2587
- }), l.sort((h, d) => h.path.length - d.path.length), Cr(a._dEH, l, n);
2587
+ }), l.sort((h, d) => h.path.length - d.path.length), Dr(a._dEH, l, n);
2588
2588
  });
2589
2589
  }), c.push(() => s.emit("afterTransaction", [n, s])), c.push(() => {
2590
- n._needFormattingCleanup && hl(n);
2590
+ n._needFormattingCleanup && fl(n);
2591
2591
  });
2592
2592
  }), On(c, []);
2593
2593
  } finally {
2594
- s.gc && jc(i, r, s.gcFilter), Hc(i, r), n.afterState.forEach((h, d) => {
2594
+ s.gc && Pc(i, r, s.gcFilter), Yc(i, r), n.afterState.forEach((h, d) => {
2595
2595
  const u = n.beforeState.get(d) || 0;
2596
2596
  if (u !== h) {
2597
2597
  const f = (
2598
2598
  /** @type {Array<GC|Item>} */
2599
2599
  r.clients.get(d)
2600
- ), g = mt(P(f, u), 1);
2600
+ ), g = mt(G(f, u), 1);
2601
2601
  for (let w = f.length - 1; w >= g; )
2602
2602
  w -= 1 + ge(f, w);
2603
2603
  }
@@ -2606,38 +2606,38 @@ const ms = (e, t) => t.deleteSet.clients.size === 0 && !yi(t.afterState, (n, s)
2606
2606
  const { client: d, clock: u } = o[h].id, f = (
2607
2607
  /** @type {Array<GC|Item>} */
2608
2608
  r.clients.get(d)
2609
- ), g = P(f, u);
2609
+ ), g = G(f, u);
2610
2610
  g + 1 < f.length && ge(f, g + 1) > 1 || g > 0 && ge(f, g);
2611
2611
  }
2612
- if (!n.local && n.afterState.get(s.clientID) !== n.beforeState.get(s.clientID) && (mc(Rn, lr, "[yjs] ", ar, hr, "Changed the client-id because another client seems to be using it."), s.clientID = pr()), s.emit("afterTransactionCleanup", [n, s]), s._observers.has("update")) {
2612
+ if (!n.local && n.afterState.get(s.clientID) !== n.beforeState.get(s.clientID) && (kc($n, hr, "[yjs] ", ur, dr, "Changed the client-id because another client seems to be using it."), s.clientID = mr()), s.emit("afterTransactionCleanup", [n, s]), s._observers.has("update")) {
2613
2613
  const h = new ne();
2614
- ms(h, n) && s.emit("update", [h.toUint8Array(), n.origin, s, n]);
2614
+ ys(h, n) && s.emit("update", [h.toUint8Array(), n.origin, s, n]);
2615
2615
  }
2616
2616
  if (s._observers.has("updateV2")) {
2617
2617
  const h = new dt();
2618
- ms(h, n) && s.emit("updateV2", [h.toUint8Array(), n.origin, s, n]);
2618
+ ys(h, n) && s.emit("updateV2", [h.toUint8Array(), n.origin, s, n]);
2619
2619
  }
2620
2620
  const { subdocsAdded: c, subdocsLoaded: l, subdocsRemoved: a } = n;
2621
2621
  (c.size > 0 || a.size > 0 || l.size > 0) && (c.forEach((h) => {
2622
2622
  h.clientID = s.clientID, h.collectionid == null && (h.collectionid = s.collectionid), s.subdocs.add(h);
2623
- }), a.forEach((h) => s.subdocs.delete(h)), s.emit("subdocs", [{ loaded: l, added: c, removed: a }, s, n]), a.forEach((h) => h.destroy())), e.length <= t + 1 ? (s._transactionCleanups = [], s.emit("afterAllTransactions", [s, e])) : Tr(e, t + 1);
2623
+ }), a.forEach((h) => s.subdocs.delete(h)), s.emit("subdocs", [{ loaded: l, added: c, removed: a }, s, n]), a.forEach((h) => h.destroy())), e.length <= t + 1 ? (s._transactionCleanups = [], s.emit("afterAllTransactions", [s, e])) : Ir(e, t + 1);
2624
2624
  }
2625
2625
  }
2626
2626
  }, _ = (e, t, n = null, s = !0) => {
2627
2627
  const r = e._transactionCleanups;
2628
2628
  let i = !1, o = null;
2629
- e._transaction === null && (i = !0, e._transaction = new Vc(e, n, s), r.push(e._transaction), r.length === 1 && e.emit("beforeAllTransactions", [e]), e.emit("beforeTransaction", [e._transaction, e]));
2629
+ e._transaction === null && (i = !0, e._transaction = new zc(e, n, s), r.push(e._transaction), r.length === 1 && e.emit("beforeAllTransactions", [e]), e.emit("beforeTransaction", [e._transaction, e]));
2630
2630
  try {
2631
2631
  o = t(e._transaction);
2632
2632
  } finally {
2633
2633
  if (i) {
2634
2634
  const c = e._transaction === r[0];
2635
- e._transaction = null, c && Tr(r, 0);
2635
+ e._transaction = null, c && Ir(r, 0);
2636
2636
  }
2637
2637
  }
2638
2638
  return o;
2639
2639
  };
2640
- class zc {
2640
+ class Gc {
2641
2641
  /**
2642
2642
  * @param {DeleteSet} deletions
2643
2643
  * @param {DeleteSet} insertions
@@ -2646,15 +2646,15 @@ class zc {
2646
2646
  this.insertions = n, this.deletions = t, this.meta = /* @__PURE__ */ new Map();
2647
2647
  }
2648
2648
  }
2649
- const bs = (e, t, n) => {
2650
- Nt(e, n.deletions, (s) => {
2649
+ const ks = (e, t, n) => {
2650
+ Ot(e, n.deletions, (s) => {
2651
2651
  s instanceof S && t.scope.some((r) => r === e.doc || Se(
2652
2652
  /** @type {AbstractType<any>} */
2653
2653
  r,
2654
2654
  s
2655
- )) && Jn(s, !1);
2655
+ )) && Kn(s, !1);
2656
2656
  });
2657
- }, ks = (e, t, n) => {
2657
+ }, _s = (e, t, n) => {
2658
2658
  let s = null;
2659
2659
  const r = e.doc, i = e.scope;
2660
2660
  _(r, (c) => {
@@ -2664,10 +2664,10 @@ const bs = (e, t, n) => {
2664
2664
  t.pop()
2665
2665
  ), h = /* @__PURE__ */ new Set(), d = [];
2666
2666
  let u = !1;
2667
- Nt(c, a.insertions, (f) => {
2667
+ Ot(c, a.insertions, (f) => {
2668
2668
  if (f instanceof S) {
2669
2669
  if (f.redone !== null) {
2670
- let { item: g, diff: w } = $l(l, f.id);
2670
+ let { item: g, diff: w } = Vl(l, f.id);
2671
2671
  w > 0 && (g = R(c, k(g.id.client, g.id.clock + w))), f = g;
2672
2672
  }
2673
2673
  !f.deleted && i.some((g) => g === c.doc || Se(
@@ -2677,7 +2677,7 @@ const bs = (e, t, n) => {
2677
2677
  f
2678
2678
  )) && d.push(f);
2679
2679
  }
2680
- }), Nt(c, a.deletions, (f) => {
2680
+ }), Ot(c, a.deletions, (f) => {
2681
2681
  f instanceof S && i.some((g) => g === c.doc || Se(
2682
2682
  /** @type {AbstractType<any>} */
2683
2683
  g,
@@ -2685,7 +2685,7 @@ const bs = (e, t, n) => {
2685
2685
  )) && // Never redo structs in stackItem.insertions because they were created and deleted in the same capture interval.
2686
2686
  !ee(a.insertions, f.id) && h.add(f);
2687
2687
  }), h.forEach((f) => {
2688
- u = Gr(c, f, h, a.insertions, e.ignoreRemoteMapChanges, e) !== null || u;
2688
+ u = Jr(c, f, h, a.insertions, e.ignoreRemoteMapChanges, e) !== null || u;
2689
2689
  });
2690
2690
  for (let f = d.length - 1; f >= 0; f--) {
2691
2691
  const g = d[f];
@@ -2704,7 +2704,7 @@ const bs = (e, t, n) => {
2704
2704
  }
2705
2705
  return o;
2706
2706
  };
2707
- class Yc extends Sn {
2707
+ class Jc extends Cn {
2708
2708
  /**
2709
2709
  * @param {Doc|AbstractType<any>|Array<AbstractType<any>>} typeScope Limits the scope of the UndoManager. If this is set to a ydoc instance, all changes on that ydoc will be undone. If set to a specific type, only changes on that type or its children will be undone. Also accepts an array of types.
2710
2710
  * @param {UndoManagerOptions} options
@@ -2717,7 +2717,7 @@ class Yc extends Sn {
2717
2717
  ignoreRemoteMapChanges: o = !1,
2718
2718
  doc: c = (
2719
2719
  /** @type {Doc} */
2720
- Lt(t) ? t[0].doc : t instanceof yt ? t : t.doc
2720
+ It(t) ? t[0].doc : t instanceof yt ? t : t.doc
2721
2721
  )
2722
2722
  } = {}) {
2723
2723
  super(), this.scope = [], this.doc = c, this.addToScope(t), this.deleteFilter = r, i.add(this), this.trackedOrigins = i, this.captureTransaction = s, this.undoStack = [], this.redoStack = [], this.undoing = !1, this.redoing = !1, this.currStackItem = null, this.lastChange = 0, this.ignoreRemoteMapChanges = o, this.captureTimeout = n, this.afterTransactionHandler = (l) => {
@@ -2728,19 +2728,19 @@ class Yc extends Sn {
2728
2728
  return;
2729
2729
  const a = this.undoing, h = this.redoing, d = a ? this.redoStack : this.undoStack;
2730
2730
  a ? this.stopCapturing() : h || this.clear(!1, !0);
2731
- const u = new Bt();
2731
+ const u = new $t();
2732
2732
  l.afterState.forEach((p, y) => {
2733
- const O = l.beforeState.get(y) || 0, kt = p - O;
2734
- kt > 0 && Wt(u, y, O, kt);
2733
+ const v = l.beforeState.get(y) || 0, Vt = p - v;
2734
+ Vt > 0 && Wt(u, y, v, Vt);
2735
2735
  });
2736
2736
  const f = ot();
2737
2737
  let g = !1;
2738
2738
  if (this.lastChange > 0 && f - this.lastChange < this.captureTimeout && d.length > 0 && !a && !h) {
2739
2739
  const p = d[d.length - 1];
2740
- p.deletions = fn([p.deletions, l.deleteSet]), p.insertions = fn([p.insertions, u]);
2740
+ p.deletions = gn([p.deletions, l.deleteSet]), p.insertions = gn([p.insertions, u]);
2741
2741
  } else
2742
- d.push(new zc(l.deleteSet, u)), g = !0;
2743
- !a && !h && (this.lastChange = f), Nt(
2742
+ d.push(new Gc(l.deleteSet, u)), g = !0;
2743
+ !a && !h && (this.lastChange = f), Ot(
2744
2744
  l,
2745
2745
  l.deleteSet,
2746
2746
  /** @param {Item|GC} item */
@@ -2749,7 +2749,7 @@ class Yc extends Sn {
2749
2749
  /** @type {AbstractType<any>} */
2750
2750
  y,
2751
2751
  p
2752
- )) && Jn(p, !0);
2752
+ )) && Kn(p, !0);
2753
2753
  }
2754
2754
  );
2755
2755
  const w = [{ stackItem: d[d.length - 1], origin: l.origin, type: a ? "redo" : "undo", changedParentTypes: l.changedParentTypes }, this];
@@ -2763,8 +2763,8 @@ class Yc extends Sn {
2763
2763
  */
2764
2764
  addToScope(t) {
2765
2765
  const n = new Set(this.scope);
2766
- t = Lt(t) ? t : [t], t.forEach((s) => {
2767
- n.has(s) || (n.add(s), (s instanceof I ? s.doc !== this.doc : s !== this.doc) && dr("[yjs#509] Not same Y.Doc"), this.scope.push(s));
2766
+ t = It(t) ? t : [t], t.forEach((s) => {
2767
+ n.has(s) || (n.add(s), (s instanceof I ? s.doc !== this.doc : s !== this.doc) && gr("[yjs#509] Not same Y.Doc"), this.scope.push(s));
2768
2768
  });
2769
2769
  }
2770
2770
  /**
@@ -2781,7 +2781,7 @@ class Yc extends Sn {
2781
2781
  }
2782
2782
  clear(t = !0, n = !0) {
2783
2783
  (t && this.canUndo() || n && this.canRedo()) && this.doc.transact((s) => {
2784
- t && (this.undoStack.forEach((r) => bs(s, this, r)), this.undoStack = []), n && (this.redoStack.forEach((r) => bs(s, this, r)), this.redoStack = []), this.emit("stack-cleared", [{ undoStackCleared: t, redoStackCleared: n }]);
2784
+ t && (this.undoStack.forEach((r) => ks(s, this, r)), this.undoStack = []), n && (this.redoStack.forEach((r) => ks(s, this, r)), this.redoStack = []), this.emit("stack-cleared", [{ undoStackCleared: t, redoStackCleared: n }]);
2785
2785
  });
2786
2786
  }
2787
2787
  /**
@@ -2816,7 +2816,7 @@ class Yc extends Sn {
2816
2816
  this.undoing = !0;
2817
2817
  let t;
2818
2818
  try {
2819
- t = ks(this, this.undoStack, "undo");
2819
+ t = _s(this, this.undoStack, "undo");
2820
2820
  } finally {
2821
2821
  this.undoing = !1;
2822
2822
  }
@@ -2831,7 +2831,7 @@ class Yc extends Sn {
2831
2831
  this.redoing = !0;
2832
2832
  let t;
2833
2833
  try {
2834
- t = ks(this, this.redoStack, "redo");
2834
+ t = _s(this, this.redoStack, "redo");
2835
2835
  } finally {
2836
2836
  this.redoing = !1;
2837
2837
  }
@@ -2857,7 +2857,7 @@ class Yc extends Sn {
2857
2857
  this.trackedOrigins.delete(this), this.doc.off("afterTransaction", this.afterTransactionHandler), this.doc.off("destroy", this.destroy), super.destroy();
2858
2858
  }
2859
2859
  }
2860
- function* Gc(e) {
2860
+ function* Kc(e) {
2861
2861
  const t = b(e.restDecoder);
2862
2862
  for (let n = 0; n < t; n++) {
2863
2863
  const s = b(e.restDecoder), r = e.readClient();
@@ -2867,7 +2867,7 @@ function* Gc(e) {
2867
2867
  if (c === 10) {
2868
2868
  const l = b(e.restDecoder);
2869
2869
  yield new V(k(r, i), l), i += l;
2870
- } else if ((ve & c) !== 0) {
2870
+ } else if ((Oe & c) !== 0) {
2871
2871
  const l = (c & (X | B)) === 0, a = new S(
2872
2872
  k(r, i),
2873
2873
  null,
@@ -2883,7 +2883,7 @@ function* Gc(e) {
2883
2883
  // parent
2884
2884
  l && (c & zt) === zt ? e.readString() : null,
2885
2885
  // parentSub
2886
- Pr(e, c)
2886
+ Kr(e, c)
2887
2887
  // item content
2888
2888
  );
2889
2889
  yield a, i += a.length;
@@ -2894,13 +2894,13 @@ function* Gc(e) {
2894
2894
  }
2895
2895
  }
2896
2896
  }
2897
- class Vn {
2897
+ class jn {
2898
2898
  /**
2899
2899
  * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
2900
2900
  * @param {boolean} filterSkips
2901
2901
  */
2902
2902
  constructor(t, n) {
2903
- this.gen = Gc(t), this.curr = null, this.done = !1, this.filterSkips = n, this.next();
2903
+ this.gen = Kc(t), this.curr = null, this.done = !1, this.filterSkips = n, this.next();
2904
2904
  }
2905
2905
  /**
2906
2906
  * @return {Item | GC | Skip |null}
@@ -2912,7 +2912,7 @@ class Vn {
2912
2912
  return this.curr;
2913
2913
  }
2914
2914
  }
2915
- class jn {
2915
+ class Hn {
2916
2916
  /**
2917
2917
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
2918
2918
  */
@@ -2920,7 +2920,7 @@ class jn {
2920
2920
  this.currClient = 0, this.startClock = 0, this.written = 0, this.encoder = t, this.clientStructs = [];
2921
2921
  }
2922
2922
  }
2923
- const Pc = (e) => Ce(e, mr, ne), Jc = (e, t) => {
2923
+ const Wc = (e) => Ce(e, br, ne), Xc = (e, t) => {
2924
2924
  if (e.constructor === F) {
2925
2925
  const { client: n, clock: s } = e.id;
2926
2926
  return new F(k(n, s + t), e.length - t);
@@ -2943,12 +2943,12 @@ const Pc = (e) => Ce(e, mr, ne), Jc = (e, t) => {
2943
2943
  n.content.splice(t)
2944
2944
  );
2945
2945
  }
2946
- }, Ce = (e, t = Mt, n = dt) => {
2946
+ }, Ce = (e, t = Nt, n = dt) => {
2947
2947
  if (e.length === 1)
2948
2948
  return e[0];
2949
2949
  const s = e.map((h) => new t(lt(h)));
2950
- let r = s.map((h) => new Vn(h, !0)), i = null;
2951
- const o = new n(), c = new jn(o);
2950
+ let r = s.map((h) => new jn(h, !0)), i = null;
2951
+ const o = new n(), c = new Hn(o);
2952
2952
  for (; r = r.filter((u) => u.curr !== null), r.sort(
2953
2953
  /** @type {function(any,any):number} */
2954
2954
  (u, f) => {
@@ -2986,7 +2986,7 @@ const Pc = (e) => Ce(e, mr, ne), Jc = (e, t) => {
2986
2986
  }
2987
2987
  else {
2988
2988
  const g = i.struct.id.clock + i.struct.length - u.id.clock;
2989
- g > 0 && (i.struct.constructor === V ? i.struct.length -= g : u = Jc(u, g)), i.struct.mergeWith(
2989
+ g > 0 && (i.struct.constructor === V ? i.struct.length -= g : u = Xc(u, g)), i.struct.mergeWith(
2990
2990
  /** @type {any} */
2991
2991
  u
2992
2992
  ) || (nt(c, i.struct, i.offset), i = { struct: u, offset: 0 }, h.next());
@@ -2999,11 +2999,11 @@ const Pc = (e) => Ce(e, mr, ne), Jc = (e, t) => {
2999
2999
  for (let u = h.curr; u !== null && u.id.client === d && u.id.clock === i.struct.id.clock + i.struct.length && u.constructor !== V; u = h.next())
3000
3000
  nt(c, i.struct, i.offset), i = { struct: u, offset: 0 };
3001
3001
  }
3002
- i !== null && (nt(c, i.struct, i.offset), i = null), Hn(c);
3003
- const l = s.map((h) => Bn(h)), a = fn(l);
3004
- return Ft(o, a), o.toUint8Array();
3005
- }, Kc = (e, t, n = Mt, s = dt) => {
3006
- const r = _r(t), i = new s(), o = new jn(i), c = new n(lt(e)), l = new Vn(c, !1);
3002
+ i !== null && (nt(c, i.struct, i.offset), i = null), zn(c);
3003
+ const l = s.map((h) => Fn(h)), a = gn(l);
3004
+ return Bt(o, a), o.toUint8Array();
3005
+ }, qc = (e, t, n = Nt, s = dt) => {
3006
+ const r = Cr(t), i = new s(), o = new Hn(i), c = new n(lt(e)), l = new jn(c, !1);
3007
3007
  for (; l.curr; ) {
3008
3008
  const h = l.curr, d = h.id.client, u = r.get(d) || 0;
3009
3009
  if (l.curr.constructor === V) {
@@ -3017,30 +3017,30 @@ const Pc = (e) => Ce(e, mr, ne), Jc = (e, t) => {
3017
3017
  for (; l.curr && l.curr.id.client === d && l.curr.id.clock + l.curr.length <= u; )
3018
3018
  l.next();
3019
3019
  }
3020
- Hn(o);
3021
- const a = Bn(c);
3022
- return Ft(i, a), i.toUint8Array();
3023
- }, xr = (e) => {
3020
+ zn(o);
3021
+ const a = Fn(c);
3022
+ return Bt(i, a), i.toUint8Array();
3023
+ }, Lr = (e) => {
3024
3024
  e.written > 0 && (e.clientStructs.push({ written: e.written, restEncoder: C(e.encoder.restEncoder) }), e.encoder.restEncoder = N(), e.written = 0);
3025
3025
  }, nt = (e, t, n) => {
3026
- e.written > 0 && e.currClient !== t.id.client && xr(e), e.written === 0 && (e.currClient = t.id.client, e.encoder.writeClient(t.id.client), m(e.encoder.restEncoder, t.id.clock + n)), t.write(e.encoder, n), e.written++;
3027
- }, Hn = (e) => {
3028
- xr(e);
3026
+ e.written > 0 && e.currClient !== t.id.client && Lr(e), e.written === 0 && (e.currClient = t.id.client, e.encoder.writeClient(t.id.client), m(e.encoder.restEncoder, t.id.clock + n)), t.write(e.encoder, n), e.written++;
3027
+ }, zn = (e) => {
3028
+ Lr(e);
3029
3029
  const t = e.encoder.restEncoder;
3030
3030
  m(t, e.clientStructs.length);
3031
3031
  for (let n = 0; n < e.clientStructs.length; n++) {
3032
3032
  const s = e.clientStructs[n];
3033
3033
  m(t, s.written), Ne(t, s.restEncoder);
3034
3034
  }
3035
- }, Wc = (e, t, n, s) => {
3036
- const r = new n(lt(e)), i = new Vn(r, !1), o = new s(), c = new jn(o);
3035
+ }, Qc = (e, t, n, s) => {
3036
+ const r = new n(lt(e)), i = new jn(r, !1), o = new s(), c = new Hn(o);
3037
3037
  for (let a = i.curr; a !== null; a = i.next())
3038
3038
  nt(c, t(a), 0);
3039
- Hn(c);
3040
- const l = Bn(r);
3041
- return Ft(o, l), o.toUint8Array();
3042
- }, Xc = (e) => Wc(e, go, Mt, ne), _s = "You must not compute changes after the event-handler fired.";
3043
- class Ye {
3039
+ zn(c);
3040
+ const l = Fn(r);
3041
+ return Bt(o, l), o.toUint8Array();
3042
+ }, Zc = (e) => Qc(e, mo, Nt, ne), Ss = "You must not compute changes after the event-handler fired.";
3043
+ class Pe {
3044
3044
  /**
3045
3045
  * @param {T} target The changed type.
3046
3046
  * @param {Transaction} transaction
@@ -3062,7 +3062,7 @@ class Ye {
3062
3062
  * type === event.target // => true
3063
3063
  */
3064
3064
  get path() {
3065
- return this._path || (this._path = qc(this.currentTarget, this.target));
3065
+ return this._path || (this._path = tl(this.currentTarget, this.target));
3066
3066
  }
3067
3067
  /**
3068
3068
  * Check if a struct is deleted by this event.
@@ -3081,7 +3081,7 @@ class Ye {
3081
3081
  get keys() {
3082
3082
  if (this._keys === null) {
3083
3083
  if (this.transaction.doc._transactionCleanups.length === 0)
3084
- throw G(_s);
3084
+ throw Y(Ss);
3085
3085
  const t = /* @__PURE__ */ new Map(), n = this.target;
3086
3086
  /** @type Set<string|null> */
3087
3087
  this.transaction.changed.get(n).forEach((r) => {
@@ -3097,13 +3097,13 @@ class Ye {
3097
3097
  l = l.left;
3098
3098
  if (this.deletes(i))
3099
3099
  if (l !== null && this.deletes(l))
3100
- o = "delete", c = Je(l.content.getContent());
3100
+ o = "delete", c = Ke(l.content.getContent());
3101
3101
  else
3102
3102
  return;
3103
3103
  else
3104
- l !== null && this.deletes(l) ? (o = "update", c = Je(l.content.getContent())) : (o = "add", c = void 0);
3104
+ l !== null && this.deletes(l) ? (o = "update", c = Ke(l.content.getContent())) : (o = "add", c = void 0);
3105
3105
  } else if (this.deletes(i))
3106
- o = "delete", c = Je(
3106
+ o = "delete", c = Ke(
3107
3107
  /** @type {Item} */
3108
3108
  i.content.getContent()
3109
3109
  );
@@ -3149,7 +3149,7 @@ class Ye {
3149
3149
  let t = this._changes;
3150
3150
  if (t === null) {
3151
3151
  if (this.transaction.doc._transactionCleanups.length === 0)
3152
- throw G(_s);
3152
+ throw Y(Ss);
3153
3153
  const n = this.target, s = it(), r = it(), i = [];
3154
3154
  if (t = {
3155
3155
  added: s,
@@ -3174,7 +3174,7 @@ class Ye {
3174
3174
  );
3175
3175
  }
3176
3176
  }
3177
- const qc = (e, t) => {
3177
+ const tl = (e, t) => {
3178
3178
  const n = [];
3179
3179
  for (; t._item !== null && t !== e; ) {
3180
3180
  if (t._item.parentSub !== null)
@@ -3193,36 +3193,36 @@ const qc = (e, t) => {
3193
3193
  }
3194
3194
  return n;
3195
3195
  }, M = () => {
3196
- dr("Invalid access: Add Yjs type to a document before reading data.");
3197
- }, Ir = 80;
3198
- let zn = 0;
3199
- class Qc {
3196
+ gr("Invalid access: Add Yjs type to a document before reading data.");
3197
+ }, vr = 80;
3198
+ let Pn = 0;
3199
+ class el {
3200
3200
  /**
3201
3201
  * @param {Item} p
3202
3202
  * @param {number} index
3203
3203
  */
3204
3204
  constructor(t, n) {
3205
- t.marker = !0, this.p = t, this.index = n, this.timestamp = zn++;
3205
+ t.marker = !0, this.p = t, this.index = n, this.timestamp = Pn++;
3206
3206
  }
3207
3207
  }
3208
- const Zc = (e) => {
3209
- e.timestamp = zn++;
3210
- }, Lr = (e, t, n) => {
3211
- e.p.marker = !1, e.p = t, t.marker = !0, e.index = n, e.timestamp = zn++;
3212
- }, tl = (e, t, n) => {
3213
- if (e.length >= Ir) {
3208
+ const nl = (e) => {
3209
+ e.timestamp = Pn++;
3210
+ }, Or = (e, t, n) => {
3211
+ e.p.marker = !1, e.p = t, t.marker = !0, e.index = n, e.timestamp = Pn++;
3212
+ }, sl = (e, t, n) => {
3213
+ if (e.length >= vr) {
3214
3214
  const s = e.reduce((r, i) => r.timestamp < i.timestamp ? r : i);
3215
- return Lr(s, t, n), s;
3215
+ return Or(s, t, n), s;
3216
3216
  } else {
3217
- const s = new Qc(t, n);
3217
+ const s = new el(t, n);
3218
3218
  return e.push(s), s;
3219
3219
  }
3220
- }, Ge = (e, t) => {
3220
+ }, Ye = (e, t) => {
3221
3221
  if (e._start === null || t === 0 || e._searchMarker === null)
3222
3222
  return null;
3223
3223
  const n = e._searchMarker.length === 0 ? null : e._searchMarker.reduce((i, o) => he(t - i.index) < he(t - o.index) ? i : o);
3224
3224
  let s = e._start, r = 0;
3225
- for (n !== null && (s = n.p, r = n.index, Zc(n)); s.right !== null && r < t; ) {
3225
+ for (n !== null && (s = n.p, r = n.index, nl(n)); s.right !== null && r < t; ) {
3226
3226
  if (!s.deleted && s.countable) {
3227
3227
  if (t < r + s.length)
3228
3228
  break;
@@ -3235,7 +3235,7 @@ const Zc = (e) => {
3235
3235
  for (; s.left !== null && s.left.id.client === s.id.client && s.left.id.clock + s.left.length === s.id.clock; )
3236
3236
  s = s.left, !s.deleted && s.countable && (r -= s.length);
3237
3237
  return n !== null && he(n.index - r) < /** @type {YText|YArray<any>} */
3238
- s.parent.length / Ir ? (Lr(n, s, r), n) : tl(e._searchMarker, s, r);
3238
+ s.parent.length / vr ? (Or(n, s, r), n) : sl(e._searchMarker, s, r);
3239
3239
  }, Xt = (e, t, n) => {
3240
3240
  for (let s = e.length - 1; s >= 0; s--) {
3241
3241
  const r = e[s];
@@ -3251,16 +3251,16 @@ const Zc = (e) => {
3251
3251
  }
3252
3252
  (t < r.index || n > 0 && t === r.index) && (r.index = mt(t, r.index + n));
3253
3253
  }
3254
- }, Pe = (e, t, n) => {
3254
+ }, Ge = (e, t, n) => {
3255
3255
  const s = e, r = t.changedParentTypes;
3256
3256
  for (; K(r, e, () => []).push(n), e._item !== null; )
3257
3257
  e = /** @type {AbstractType<any>} */
3258
3258
  e._item.parent;
3259
- Cr(s._eH, n, t);
3259
+ Dr(s._eH, n, t);
3260
3260
  };
3261
3261
  class I {
3262
3262
  constructor() {
3263
- this._item = null, this._map = /* @__PURE__ */ new Map(), this._start = null, this.doc = null, this._length = 0, this._eH = fs(), this._dEH = fs(), this._searchMarker = null;
3263
+ this._item = null, this._map = /* @__PURE__ */ new Map(), this._start = null, this.doc = null, this._length = 0, this._eH = gs(), this._dEH = gs(), this._searchMarker = null;
3264
3264
  }
3265
3265
  /**
3266
3266
  * @return {AbstractType<any>|null}
@@ -3330,7 +3330,7 @@ class I {
3330
3330
  * @param {function(EventType, Transaction):void} f Observer function
3331
3331
  */
3332
3332
  observe(t) {
3333
- gs(this._eH, t);
3333
+ ps(this._eH, t);
3334
3334
  }
3335
3335
  /**
3336
3336
  * Observe all events that are created by this type and its children.
@@ -3338,7 +3338,7 @@ class I {
3338
3338
  * @param {function(Array<YEvent<any>>,Transaction):void} f Observer function
3339
3339
  */
3340
3340
  observeDeep(t) {
3341
- gs(this._dEH, t);
3341
+ ps(this._dEH, t);
3342
3342
  }
3343
3343
  /**
3344
3344
  * Unregister an observer function.
@@ -3346,7 +3346,7 @@ class I {
3346
3346
  * @param {function(EventType,Transaction):void} f Observer function
3347
3347
  */
3348
3348
  unobserve(t) {
3349
- ps(this._eH, t);
3349
+ ws(this._eH, t);
3350
3350
  }
3351
3351
  /**
3352
3352
  * Unregister an observer function.
@@ -3354,7 +3354,7 @@ class I {
3354
3354
  * @param {function(Array<YEvent<any>>,Transaction):void} f Observer function
3355
3355
  */
3356
3356
  unobserveDeep(t) {
3357
- ps(this._dEH, t);
3357
+ ws(this._dEH, t);
3358
3358
  }
3359
3359
  /**
3360
3360
  * @abstract
@@ -3363,7 +3363,7 @@ class I {
3363
3363
  toJSON() {
3364
3364
  }
3365
3365
  }
3366
- const Or = (e, t, n) => {
3366
+ const Nr = (e, t, n) => {
3367
3367
  var o;
3368
3368
  (o = e.doc) != null || M(), t < 0 && (t = e._length + t), n < 0 && (n = e._length + n);
3369
3369
  let s = n - t;
@@ -3383,7 +3383,7 @@ const Or = (e, t, n) => {
3383
3383
  i = i.right;
3384
3384
  }
3385
3385
  return r;
3386
- }, vr = (e) => {
3386
+ }, Mr = (e) => {
3387
3387
  var s;
3388
3388
  (s = e.doc) != null || M();
3389
3389
  const t = [];
@@ -3408,12 +3408,12 @@ const Or = (e, t, n) => {
3408
3408
  }
3409
3409
  s = s.right;
3410
3410
  }
3411
- }, Nr = (e, t) => {
3411
+ }, Ur = (e, t) => {
3412
3412
  const n = [];
3413
3413
  return qt(e, (s, r) => {
3414
3414
  n.push(t(s, r, e));
3415
3415
  }), n;
3416
- }, el = (e) => {
3416
+ }, rl = (e) => {
3417
3417
  let t = e._start, n = null, s = 0;
3418
3418
  return {
3419
3419
  [Symbol.iterator]() {
@@ -3437,10 +3437,10 @@ const Or = (e, t, n) => {
3437
3437
  };
3438
3438
  }
3439
3439
  };
3440
- }, Mr = (e, t) => {
3440
+ }, Rr = (e, t) => {
3441
3441
  var r;
3442
3442
  (r = e.doc) != null || M();
3443
- const n = Ge(e, t);
3443
+ const n = Ye(e, t);
3444
3444
  let s = e._start;
3445
3445
  for (n !== null && (s = n.p, t -= n.index); s !== null; s = s.right)
3446
3446
  if (!s.deleted && s.countable) {
@@ -3490,12 +3490,12 @@ const Or = (e, t, n) => {
3490
3490
  }
3491
3491
  }
3492
3492
  }), h();
3493
- }, Ur = () => G("Length exceeded!"), Rr = (e, t, n, s) => {
3493
+ }, $r = () => Y("Length exceeded!"), Br = (e, t, n, s) => {
3494
3494
  if (n > t._length)
3495
- throw Ur();
3495
+ throw $r();
3496
3496
  if (n === 0)
3497
3497
  return t._searchMarker && Xt(t._searchMarker, n, s.length), Ee(e, t, null, s);
3498
- const r = n, i = Ge(t, n);
3498
+ const r = n, i = Ye(t, n);
3499
3499
  let o = t._start;
3500
3500
  for (i !== null && (o = i.p, n -= i.index, n === 0 && (o = o.prev, n += o && o.countable && !o.deleted ? o.length : 0)); o !== null; o = o.right)
3501
3501
  if (!o.deleted && o.countable) {
@@ -3506,23 +3506,23 @@ const Or = (e, t, n) => {
3506
3506
  n -= o.length;
3507
3507
  }
3508
3508
  return t._searchMarker && Xt(t._searchMarker, r, s.length), Ee(e, t, o, s);
3509
- }, nl = (e, t, n) => {
3509
+ }, il = (e, t, n) => {
3510
3510
  let r = (t._searchMarker || []).reduce((i, o) => o.index > i.index ? o : i, { index: 0, p: t._start }).p;
3511
3511
  if (r)
3512
3512
  for (; r.right; )
3513
3513
  r = r.right;
3514
3514
  return Ee(e, t, r, n);
3515
- }, $r = (e, t, n, s) => {
3515
+ }, Fr = (e, t, n, s) => {
3516
3516
  if (s === 0)
3517
3517
  return;
3518
- const r = n, i = s, o = Ge(t, n);
3518
+ const r = n, i = s, o = Ye(t, n);
3519
3519
  let c = t._start;
3520
3520
  for (o !== null && (c = o.p, n -= o.index); c !== null && n > 0; c = c.right)
3521
3521
  !c.deleted && c.countable && (n < c.length && R(e, k(c.id.client, c.id.clock + n)), n -= c.length);
3522
3522
  for (; s > 0 && c !== null; )
3523
3523
  c.deleted || (s < c.length && R(e, k(c.id.client, c.id.clock + s)), c.delete(e), s -= c.length), c = c.right;
3524
3524
  if (s > 0)
3525
- throw Ur();
3525
+ throw $r();
3526
3526
  t._searchMarker && Xt(
3527
3527
  t._searchMarker,
3528
3528
  r,
@@ -3572,36 +3572,36 @@ const Or = (e, t, n) => {
3572
3572
  (s = e.doc) != null || M();
3573
3573
  const n = e._map.get(t);
3574
3574
  return n !== void 0 && !n.deleted ? n.content.getContent()[n.length - 1] : void 0;
3575
- }, Br = (e) => {
3575
+ }, Vr = (e) => {
3576
3576
  var n;
3577
3577
  const t = {};
3578
3578
  return (n = e.doc) != null || M(), e._map.forEach((s, r) => {
3579
3579
  s.deleted || (t[r] = s.content.getContent()[s.length - 1]);
3580
3580
  }), t;
3581
- }, Fr = (e, t) => {
3581
+ }, jr = (e, t) => {
3582
3582
  var s;
3583
3583
  (s = e.doc) != null || M();
3584
3584
  const n = e._map.get(t);
3585
3585
  return n !== void 0 && !n.deleted;
3586
- }, sl = (e, t) => {
3586
+ }, ol = (e, t) => {
3587
3587
  const n = {};
3588
3588
  return e._map.forEach((s, r) => {
3589
3589
  let i = s;
3590
3590
  for (; i !== null && (!t.sv.has(i.id.client) || i.id.clock >= (t.sv.get(i.id.client) || 0)); )
3591
3591
  i = i.left;
3592
- i !== null && St(i, t) && (n[r] = i.content.getContent()[i.length - 1]);
3592
+ i !== null && _t(i, t) && (n[r] = i.content.getContent()[i.length - 1]);
3593
3593
  }), n;
3594
3594
  }, le = (e) => {
3595
3595
  var t;
3596
- return (t = e.doc) != null || M(), yc(
3596
+ return (t = e.doc) != null || M(), _c(
3597
3597
  e._map.entries(),
3598
3598
  /** @param {any} entry */
3599
3599
  (n) => !n[1].deleted
3600
3600
  );
3601
3601
  };
3602
- class rl extends Ye {
3602
+ class cl extends Pe {
3603
3603
  }
3604
- class xt extends I {
3604
+ class Tt extends I {
3605
3605
  constructor() {
3606
3606
  super(), this._prelimContent = [], this._searchMarker = [];
3607
3607
  }
@@ -3612,7 +3612,7 @@ class xt extends I {
3612
3612
  * @return {YArray<T>}
3613
3613
  */
3614
3614
  static from(t) {
3615
- const n = new xt();
3615
+ const n = new Tt();
3616
3616
  return n.push(t), n;
3617
3617
  }
3618
3618
  /**
@@ -3636,7 +3636,7 @@ class xt extends I {
3636
3636
  * @return {YArray<T>}
3637
3637
  */
3638
3638
  _copy() {
3639
- return new xt();
3639
+ return new Tt();
3640
3640
  }
3641
3641
  /**
3642
3642
  * Makes a copy of this data type that can be included somewhere else.
@@ -3646,7 +3646,7 @@ class xt extends I {
3646
3646
  * @return {YArray<T>}
3647
3647
  */
3648
3648
  clone() {
3649
- const t = new xt();
3649
+ const t = new Tt();
3650
3650
  return t.insert(0, this.toArray().map(
3651
3651
  (n) => n instanceof I ? (
3652
3652
  /** @type {typeof el} */
@@ -3665,7 +3665,7 @@ class xt extends I {
3665
3665
  * @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
3666
3666
  */
3667
3667
  _callObserver(t, n) {
3668
- super._callObserver(t, n), Pe(this, t, new rl(this, t));
3668
+ super._callObserver(t, n), Ge(this, t, new cl(this, t));
3669
3669
  }
3670
3670
  /**
3671
3671
  * Inserts new content at an index.
@@ -3685,7 +3685,7 @@ class xt extends I {
3685
3685
  */
3686
3686
  insert(t, n) {
3687
3687
  this.doc !== null ? _(this.doc, (s) => {
3688
- Rr(
3688
+ Br(
3689
3689
  s,
3690
3690
  this,
3691
3691
  t,
@@ -3703,7 +3703,7 @@ class xt extends I {
3703
3703
  */
3704
3704
  push(t) {
3705
3705
  this.doc !== null ? _(this.doc, (n) => {
3706
- nl(
3706
+ il(
3707
3707
  n,
3708
3708
  this,
3709
3709
  /** @type {any} */
@@ -3727,7 +3727,7 @@ class xt extends I {
3727
3727
  */
3728
3728
  delete(t, n = 1) {
3729
3729
  this.doc !== null ? _(this.doc, (s) => {
3730
- $r(s, this, t, n);
3730
+ Fr(s, this, t, n);
3731
3731
  }) : this._prelimContent.splice(t, n);
3732
3732
  }
3733
3733
  /**
@@ -3737,7 +3737,7 @@ class xt extends I {
3737
3737
  * @return {T}
3738
3738
  */
3739
3739
  get(t) {
3740
- return Mr(this, t);
3740
+ return Rr(this, t);
3741
3741
  }
3742
3742
  /**
3743
3743
  * Transforms this YArray to a JavaScript Array.
@@ -3745,7 +3745,7 @@ class xt extends I {
3745
3745
  * @return {Array<T>}
3746
3746
  */
3747
3747
  toArray() {
3748
- return vr(this);
3748
+ return Mr(this);
3749
3749
  }
3750
3750
  /**
3751
3751
  * Returns a portion of this YArray into a JavaScript Array selected
@@ -3756,7 +3756,7 @@ class xt extends I {
3756
3756
  * @return {Array<T>}
3757
3757
  */
3758
3758
  slice(t = 0, n = this.length) {
3759
- return Or(this, t, n);
3759
+ return Nr(this, t, n);
3760
3760
  }
3761
3761
  /**
3762
3762
  * Transforms this Shared Type to a JSON object.
@@ -3776,7 +3776,7 @@ class xt extends I {
3776
3776
  * callback function
3777
3777
  */
3778
3778
  map(t) {
3779
- return Nr(
3779
+ return Ur(
3780
3780
  this,
3781
3781
  /** @type {any} */
3782
3782
  t
@@ -3794,17 +3794,17 @@ class xt extends I {
3794
3794
  * @return {IterableIterator<T>}
3795
3795
  */
3796
3796
  [Symbol.iterator]() {
3797
- return el(this);
3797
+ return rl(this);
3798
3798
  }
3799
3799
  /**
3800
3800
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
3801
3801
  */
3802
3802
  _write(t) {
3803
- t.writeTypeRef(Il);
3803
+ t.writeTypeRef(Ol);
3804
3804
  }
3805
3805
  }
3806
- const il = (e) => new xt();
3807
- class ol extends Ye {
3806
+ const ll = (e) => new Tt();
3807
+ class al extends Pe {
3808
3808
  /**
3809
3809
  * @param {YMap<T>} ymap The YArray that changed.
3810
3810
  * @param {Transaction} transaction
@@ -3814,7 +3814,7 @@ class ol extends Ye {
3814
3814
  super(t, n), this.keysChanged = s;
3815
3815
  }
3816
3816
  }
3817
- class Ut extends I {
3817
+ class Mt extends I {
3818
3818
  /**
3819
3819
  *
3820
3820
  * @param {Iterable<readonly [string, any]>=} entries - an optional iterable to initialize the YMap
@@ -3841,7 +3841,7 @@ class Ut extends I {
3841
3841
  * @return {YMap<MapType>}
3842
3842
  */
3843
3843
  _copy() {
3844
- return new Ut();
3844
+ return new Mt();
3845
3845
  }
3846
3846
  /**
3847
3847
  * Makes a copy of this data type that can be included somewhere else.
@@ -3851,7 +3851,7 @@ class Ut extends I {
3851
3851
  * @return {YMap<MapType>}
3852
3852
  */
3853
3853
  clone() {
3854
- const t = new Ut();
3854
+ const t = new Mt();
3855
3855
  return this.forEach((n, s) => {
3856
3856
  t.set(s, n instanceof I ? (
3857
3857
  /** @type {typeof value} */
@@ -3866,7 +3866,7 @@ class Ut extends I {
3866
3866
  * @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
3867
3867
  */
3868
3868
  _callObserver(t, n) {
3869
- Pe(this, t, new ol(this, t, n));
3869
+ Ge(this, t, new al(this, t, n));
3870
3870
  }
3871
3871
  /**
3872
3872
  * Transforms this Shared Type to a JSON object.
@@ -3898,7 +3898,7 @@ class Ut extends I {
3898
3898
  * @return {IterableIterator<string>}
3899
3899
  */
3900
3900
  keys() {
3901
- return tn(
3901
+ return en(
3902
3902
  le(this),
3903
3903
  /** @param {any} v */
3904
3904
  (t) => t[0]
@@ -3910,7 +3910,7 @@ class Ut extends I {
3910
3910
  * @return {IterableIterator<MapType>}
3911
3911
  */
3912
3912
  values() {
3913
- return tn(
3913
+ return en(
3914
3914
  le(this),
3915
3915
  /** @param {any} v */
3916
3916
  (t) => t[1].content.getContent()[t[1].length - 1]
@@ -3922,7 +3922,7 @@ class Ut extends I {
3922
3922
  * @return {IterableIterator<[string, MapType]>}
3923
3923
  */
3924
3924
  entries() {
3925
- return tn(
3925
+ return en(
3926
3926
  le(this),
3927
3927
  /** @param {any} v */
3928
3928
  (t) => (
@@ -3998,7 +3998,7 @@ class Ut extends I {
3998
3998
  * @return {boolean}
3999
3999
  */
4000
4000
  has(t) {
4001
- return Fr(this, t);
4001
+ return jr(this, t);
4002
4002
  }
4003
4003
  /**
4004
4004
  * Removes all elements from this YMap.
@@ -4014,11 +4014,11 @@ class Ut extends I {
4014
4014
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
4015
4015
  */
4016
4016
  _write(t) {
4017
- t.writeTypeRef(Ll);
4017
+ t.writeTypeRef(Nl);
4018
4018
  }
4019
4019
  }
4020
- const cl = (e) => new Ut(), st = (e, t) => e === t || typeof e == "object" && typeof t == "object" && e && t && uo(e, t);
4021
- class wn {
4020
+ const hl = (e) => new Mt(), st = (e, t) => e === t || typeof e == "object" && typeof t == "object" && e && t && po(e, t);
4021
+ class mn {
4022
4022
  /**
4023
4023
  * @param {Item|null} left
4024
4024
  * @param {Item|null} right
@@ -4032,31 +4032,31 @@ class wn {
4032
4032
  * Only call this if you know that this.right is defined
4033
4033
  */
4034
4034
  forward() {
4035
- this.right === null && j(), this.right.content.constructor === T ? this.right.deleted || Vt(
4035
+ this.right === null && j(), this.right.content.constructor === T ? this.right.deleted || Ft(
4036
4036
  this.currentAttributes,
4037
4037
  /** @type {ContentFormat} */
4038
4038
  this.right.content
4039
4039
  ) : this.right.deleted || (this.index += this.right.length), this.left = this.right, this.right = this.right.right;
4040
4040
  }
4041
4041
  }
4042
- const Ss = (e, t, n) => {
4042
+ const Cs = (e, t, n) => {
4043
4043
  for (; t.right !== null && n > 0; )
4044
- t.right.content.constructor === T ? t.right.deleted || Vt(
4044
+ t.right.content.constructor === T ? t.right.deleted || Ft(
4045
4045
  t.currentAttributes,
4046
4046
  /** @type {ContentFormat} */
4047
4047
  t.right.content
4048
4048
  ) : t.right.deleted || (n < t.right.length && R(e, k(t.right.id.client, t.right.id.clock + n)), t.index += t.right.length, n -= t.right.length), t.left = t.right, t.right = t.right.right;
4049
4049
  return t;
4050
4050
  }, ae = (e, t, n, s) => {
4051
- const r = /* @__PURE__ */ new Map(), i = s ? Ge(t, n) : null;
4051
+ const r = /* @__PURE__ */ new Map(), i = s ? Ye(t, n) : null;
4052
4052
  if (i) {
4053
- const o = new wn(i.p.left, i.p, i.index, r);
4054
- return Ss(e, o, n - i.index);
4053
+ const o = new mn(i.p.left, i.p, i.index, r);
4054
+ return Cs(e, o, n - i.index);
4055
4055
  } else {
4056
- const o = new wn(null, t._start, 0, r);
4057
- return Ss(e, o, n);
4056
+ const o = new mn(null, t._start, 0, r);
4057
+ return Cs(e, o, n);
4058
4058
  }
4059
- }, Vr = (e, t, n, s) => {
4059
+ }, Hr = (e, t, n, s) => {
4060
4060
  for (; n.right !== null && (n.right.deleted === !0 || n.right.content.constructor === T && st(
4061
4061
  s.get(
4062
4062
  /** @type {ContentFormat} */
@@ -4074,10 +4074,10 @@ const Ss = (e, t, n) => {
4074
4074
  const l = n.left, a = n.right, h = new S(k(i, A(r.store, i)), l, l && l.lastId, a, a && a.id, t, null, new T(c, o));
4075
4075
  h.integrate(e, 0), n.right = h, n.forward();
4076
4076
  });
4077
- }, Vt = (e, t) => {
4077
+ }, Ft = (e, t) => {
4078
4078
  const { key: n, value: s } = t;
4079
4079
  s === null ? e.delete(n) : e.set(n, s);
4080
- }, jr = (e, t) => {
4080
+ }, zr = (e, t) => {
4081
4081
  var n;
4082
4082
  for (; e.right !== null; ) {
4083
4083
  if (!(e.right.deleted || e.right.content.constructor === T && st(
@@ -4090,7 +4090,7 @@ const Ss = (e, t, n) => {
4090
4090
  ))) break;
4091
4091
  e.forward();
4092
4092
  }
4093
- }, Hr = (e, t, n, s) => {
4093
+ }, Pr = (e, t, n, s) => {
4094
4094
  var c;
4095
4095
  const r = e.doc, i = r.clientID, o = /* @__PURE__ */ new Map();
4096
4096
  for (const l in s) {
@@ -4102,22 +4102,22 @@ const Ss = (e, t, n) => {
4102
4102
  }
4103
4103
  }
4104
4104
  return o;
4105
- }, en = (e, t, n, s, r) => {
4105
+ }, nn = (e, t, n, s, r) => {
4106
4106
  n.currentAttributes.forEach((u, f) => {
4107
4107
  r[f] === void 0 && (r[f] = null);
4108
4108
  });
4109
4109
  const i = e.doc, o = i.clientID;
4110
- jr(n, r);
4111
- const c = Hr(e, t, n, r), l = s.constructor === String ? new J(
4110
+ zr(n, r);
4111
+ const c = Pr(e, t, n, r), l = s.constructor === String ? new J(
4112
4112
  /** @type {string} */
4113
4113
  s
4114
4114
  ) : s instanceof I ? new et(s) : new bt(s);
4115
4115
  let { left: a, right: h, index: d } = n;
4116
- t._searchMarker && Xt(t._searchMarker, n.index, l.getLength()), h = new S(k(o, A(i.store, o)), a, a && a.lastId, h, h && h.id, t, null, l), h.integrate(e, 0), n.right = h, n.index = d, n.forward(), Vr(e, t, n, c);
4117
- }, Cs = (e, t, n, s, r) => {
4116
+ t._searchMarker && Xt(t._searchMarker, n.index, l.getLength()), h = new S(k(o, A(i.store, o)), a, a && a.lastId, h, h && h.id, t, null, l), h.integrate(e, 0), n.right = h, n.index = d, n.forward(), Hr(e, t, n, c);
4117
+ }, Es = (e, t, n, s, r) => {
4118
4118
  const i = e.doc, o = i.clientID;
4119
- jr(n, r);
4120
- const c = Hr(e, t, n, r);
4119
+ zr(n, r);
4120
+ const c = Pr(e, t, n, r);
4121
4121
  t: for (; n.right !== null && (s > 0 || c.size > 0 && (n.right.deleted || n.right.content.constructor === T)); ) {
4122
4122
  if (!n.right.deleted)
4123
4123
  switch (n.right.content.constructor) {
@@ -4152,8 +4152,8 @@ const Ss = (e, t, n) => {
4152
4152
  `;
4153
4153
  n.right = new S(k(o, A(i.store, o)), n.left, n.left && n.left.lastId, n.right, n.right && n.right.id, t, null, new J(l)), n.right.integrate(e, 0), n.forward();
4154
4154
  }
4155
- Vr(e, t, n, c);
4156
- }, zr = (e, t, n, s, r) => {
4155
+ Hr(e, t, n, c);
4156
+ }, Yr = (e, t, n, s, r) => {
4157
4157
  var a, h;
4158
4158
  let i = t;
4159
4159
  const o = $();
@@ -4176,7 +4176,7 @@ const Ss = (e, t, n) => {
4176
4176
  /** @type {ContentFormat} */
4177
4177
  d
4178
4178
  ), g = (a = s.get(u)) != null ? a : null;
4179
- (o.get(u) !== d || g === f) && (t.delete(e), c++, !l && ((h = r.get(u)) != null ? h : null) === f && g !== f && (g === null ? r.delete(u) : r.set(u, g))), !l && !t.deleted && Vt(
4179
+ (o.get(u) !== d || g === f) && (t.delete(e), c++, !l && ((h = r.get(u)) != null ? h : null) === f && g !== f && (g === null ? r.delete(u) : r.set(u, g))), !l && !t.deleted && Ft(
4180
4180
  r,
4181
4181
  /** @type {ContentFormat} */
4182
4182
  d
@@ -4187,7 +4187,7 @@ const Ss = (e, t, n) => {
4187
4187
  t.right;
4188
4188
  }
4189
4189
  return c;
4190
- }, ll = (e, t) => {
4190
+ }, ul = (e, t) => {
4191
4191
  for (; t && t.right && (t.right.deleted || !t.right.countable); )
4192
4192
  t = t.right;
4193
4193
  const n = /* @__PURE__ */ new Set();
@@ -4201,7 +4201,7 @@ const Ss = (e, t, n) => {
4201
4201
  }
4202
4202
  t = t.left;
4203
4203
  }
4204
- }, al = (e) => {
4204
+ }, dl = (e) => {
4205
4205
  let t = 0;
4206
4206
  return _(
4207
4207
  /** @type {Doc} */
@@ -4211,20 +4211,20 @@ const Ss = (e, t, n) => {
4211
4211
  /** @type {Item} */
4212
4212
  e._start
4213
4213
  ), r = e._start, i = $();
4214
- const o = cn(i);
4214
+ const o = ln(i);
4215
4215
  for (; r; )
4216
- r.deleted === !1 && (r.content.constructor === T ? Vt(
4216
+ r.deleted === !1 && (r.content.constructor === T ? Ft(
4217
4217
  o,
4218
4218
  /** @type {ContentFormat} */
4219
4219
  r.content
4220
- ) : (t += zr(n, s, r, i, o), i = cn(o), s = r)), r = r.right;
4220
+ ) : (t += Yr(n, s, r, i, o), i = ln(o), s = r)), r = r.right;
4221
4221
  }
4222
4222
  ), t;
4223
- }, hl = (e) => {
4223
+ }, fl = (e) => {
4224
4224
  const t = /* @__PURE__ */ new Set(), n = e.doc;
4225
4225
  for (const [s, r] of e.afterState.entries()) {
4226
4226
  const i = e.beforeState.get(s) || 0;
4227
- r !== i && Ar(
4227
+ r !== i && xr(
4228
4228
  e,
4229
4229
  /** @type {Array<Item|GC>} */
4230
4230
  n.store.clients.get(s),
@@ -4240,7 +4240,7 @@ const Ss = (e, t, n) => {
4240
4240
  );
4241
4241
  }
4242
4242
  _(n, (s) => {
4243
- Nt(e, e.deleteSet, (r) => {
4243
+ Ot(e, e.deleteSet, (r) => {
4244
4244
  if (r instanceof F || !/** @type {YText} */
4245
4245
  r.parent._hasFormatting || t.has(
4246
4246
  /** @type {YText} */
@@ -4251,13 +4251,13 @@ const Ss = (e, t, n) => {
4251
4251
  /** @type {YText} */
4252
4252
  r.parent
4253
4253
  );
4254
- r.content.constructor === T ? t.add(i) : ll(s, r);
4254
+ r.content.constructor === T ? t.add(i) : ul(s, r);
4255
4255
  });
4256
4256
  for (const r of t)
4257
- al(r);
4257
+ dl(r);
4258
4258
  });
4259
- }, Es = (e, t, n) => {
4260
- const s = n, r = cn(t.currentAttributes), i = t.right;
4259
+ }, Ds = (e, t, n) => {
4260
+ const s = n, r = ln(t.currentAttributes), i = t.right;
4261
4261
  for (; n > 0 && t.right !== null; ) {
4262
4262
  if (t.right.deleted === !1)
4263
4263
  switch (t.right.content.constructor) {
@@ -4269,7 +4269,7 @@ const Ss = (e, t, n) => {
4269
4269
  }
4270
4270
  t.forward();
4271
4271
  }
4272
- i && zr(e, i, t.right, r, t.currentAttributes);
4272
+ i && Yr(e, i, t.right, r, t.currentAttributes);
4273
4273
  const o = (
4274
4274
  /** @type {AbstractType<any>} */
4275
4275
  /** @type {Item} */
@@ -4277,7 +4277,7 @@ const Ss = (e, t, n) => {
4277
4277
  );
4278
4278
  return o._searchMarker && Xt(o._searchMarker, t.index, -s + n), t;
4279
4279
  };
4280
- class ul extends Ye {
4280
+ class gl extends Pe {
4281
4281
  /**
4282
4282
  * @param {YText} ytext
4283
4283
  * @param {Transaction} transaction
@@ -4334,12 +4334,12 @@ class ul extends Ye {
4334
4334
  d > 0 && (p = { delete: d }), d = 0;
4335
4335
  break;
4336
4336
  case "insert":
4337
- (typeof a == "object" || a.length > 0) && (p = { insert: a }, r.size > 0 && (p.attributes = {}, r.forEach((y, O) => {
4338
- y !== null && (p.attributes[O] = y);
4337
+ (typeof a == "object" || a.length > 0) && (p = { insert: a }, r.size > 0 && (p.attributes = {}, r.forEach((y, v) => {
4338
+ y !== null && (p.attributes[v] = y);
4339
4339
  }))), a = "";
4340
4340
  break;
4341
4341
  case "retain":
4342
- h > 0 && (p = { retain: h }, ho(l) || (p.attributes = oo({}, l))), h = 0;
4342
+ h > 0 && (p = { retain: h }, go(l) || (p.attributes = ao({}, l))), h = 0;
4343
4343
  break;
4344
4344
  }
4345
4345
  p && n.push(p), c = null;
@@ -4362,19 +4362,19 @@ class ul extends Ye {
4362
4362
  );
4363
4363
  if (this.adds(o)) {
4364
4364
  if (!this.deletes(o)) {
4365
- const O = (f = r.get(p)) != null ? f : null;
4366
- st(O, y) ? y !== null && o.delete(s) : (c === "retain" && u(), st(y, (g = i.get(p)) != null ? g : null) ? delete l[p] : l[p] = y);
4365
+ const v = (f = r.get(p)) != null ? f : null;
4366
+ st(v, y) ? y !== null && o.delete(s) : (c === "retain" && u(), st(y, (g = i.get(p)) != null ? g : null) ? delete l[p] : l[p] = y);
4367
4367
  }
4368
4368
  } else if (this.deletes(o)) {
4369
4369
  i.set(p, y);
4370
- const O = (w = r.get(p)) != null ? w : null;
4371
- st(O, y) || (c === "retain" && u(), l[p] = O);
4370
+ const v = (w = r.get(p)) != null ? w : null;
4371
+ st(v, y) || (c === "retain" && u(), l[p] = v);
4372
4372
  } else if (!o.deleted) {
4373
4373
  i.set(p, y);
4374
- const O = l[p];
4375
- O !== void 0 && (st(O, y) ? O !== null && o.delete(s) : (c === "retain" && u(), y === null ? delete l[p] : l[p] = y));
4374
+ const v = l[p];
4375
+ v !== void 0 && (st(v, y) ? v !== null && o.delete(s) : (c === "retain" && u(), y === null ? delete l[p] : l[p] = y));
4376
4376
  }
4377
- o.deleted || (c === "insert" && u(), Vt(
4377
+ o.deleted || (c === "insert" && u(), Ft(
4378
4378
  r,
4379
4379
  /** @type {ContentFormat} */
4380
4380
  o.content
@@ -4399,7 +4399,7 @@ class ul extends Ye {
4399
4399
  );
4400
4400
  }
4401
4401
  }
4402
- class Rt extends I {
4402
+ class Ut extends I {
4403
4403
  /**
4404
4404
  * @param {String} [string] The initial value of the YText.
4405
4405
  */
@@ -4429,7 +4429,7 @@ class Rt extends I {
4429
4429
  this._pending = null;
4430
4430
  }
4431
4431
  _copy() {
4432
- return new Rt();
4432
+ return new Ut();
4433
4433
  }
4434
4434
  /**
4435
4435
  * Makes a copy of this data type that can be included somewhere else.
@@ -4439,7 +4439,7 @@ class Rt extends I {
4439
4439
  * @return {YText}
4440
4440
  */
4441
4441
  clone() {
4442
- const t = new Rt();
4442
+ const t = new Ut();
4443
4443
  return t.applyDelta(this.toDelta()), t;
4444
4444
  }
4445
4445
  /**
@@ -4450,8 +4450,8 @@ class Rt extends I {
4450
4450
  */
4451
4451
  _callObserver(t, n) {
4452
4452
  super._callObserver(t, n);
4453
- const s = new ul(this, t, n);
4454
- Pe(this, t, s), !t.local && this._hasFormatting && (t._needFormattingCleanup = !0);
4453
+ const s = new gl(this, t, n);
4454
+ Ge(this, t, s), !t.local && this._hasFormatting && (t._needFormattingCleanup = !0);
4455
4455
  }
4456
4456
  /**
4457
4457
  * Returns the unformatted string representation of this YText type.
@@ -4488,14 +4488,14 @@ class Rt extends I {
4488
4488
  */
4489
4489
  applyDelta(t, { sanitize: n = !0 } = {}) {
4490
4490
  this.doc !== null ? _(this.doc, (s) => {
4491
- const r = new wn(null, this._start, 0, /* @__PURE__ */ new Map());
4491
+ const r = new mn(null, this._start, 0, /* @__PURE__ */ new Map());
4492
4492
  for (let i = 0; i < t.length; i++) {
4493
4493
  const o = t[i];
4494
4494
  if (o.insert !== void 0) {
4495
4495
  const c = !n && typeof o.insert == "string" && i === t.length - 1 && r.right === null && o.insert.slice(-1) === `
4496
4496
  ` ? o.insert.slice(0, -1) : o.insert;
4497
- (typeof c != "string" || c.length > 0) && en(s, this, r, c, o.attributes || {});
4498
- } else o.retain !== void 0 ? Cs(s, this, r, o.retain, o.attributes || {}) : o.delete !== void 0 && Es(s, r, o.delete);
4497
+ (typeof c != "string" || c.length > 0) && nn(s, this, r, c, o.attributes || {});
4498
+ } else o.retain !== void 0 ? Es(s, this, r, o.retain, o.attributes || {}) : o.delete !== void 0 && Ds(s, r, o.delete);
4499
4499
  }
4500
4500
  }) : this._pending.push(() => this.applyDelta(t));
4501
4501
  }
@@ -4530,11 +4530,11 @@ class Rt extends I {
4530
4530
  }
4531
4531
  const h = () => {
4532
4532
  for (; l !== null; ) {
4533
- if (St(l, t) || n !== void 0 && St(l, n))
4533
+ if (_t(l, t) || n !== void 0 && _t(l, n))
4534
4534
  switch (l.content.constructor) {
4535
4535
  case J: {
4536
4536
  const u = i.get("ychange");
4537
- 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" })) : n !== void 0 && !St(l, n) ? (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} */
4537
+ t !== void 0 && !_t(l, t) ? (u === void 0 || u.user !== l.id.client || u.type !== "removed") && (a(), i.set("ychange", s ? s("removed", l.id) : { type: "removed" })) : n !== void 0 && !_t(l, n) ? (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} */
4538
4538
  l.content.str;
4539
4539
  break;
4540
4540
  }
@@ -4557,7 +4557,7 @@ class Rt extends I {
4557
4557
  break;
4558
4558
  }
4559
4559
  case T:
4560
- St(l, t) && (a(), Vt(
4560
+ _t(l, t) && (a(), Ft(
4561
4561
  i,
4562
4562
  /** @type {ContentFormat} */
4563
4563
  l.content
@@ -4569,7 +4569,7 @@ class Rt extends I {
4569
4569
  a();
4570
4570
  };
4571
4571
  return t || n ? _(o, (u) => {
4572
- t && gn(u, t), n && gn(u, n), h();
4572
+ t && pn(u, t), n && pn(u, n), h();
4573
4573
  }, "cleanup") : h(), r;
4574
4574
  }
4575
4575
  /**
@@ -4590,7 +4590,7 @@ class Rt extends I {
4590
4590
  const o = ae(i, this, t, !s);
4591
4591
  s || (s = {}, o.currentAttributes.forEach((c, l) => {
4592
4592
  s[l] = c;
4593
- })), en(i, this, o, n, s);
4593
+ })), nn(i, this, o, n, s);
4594
4594
  }) : this._pending.push(() => this.insert(t, n, s));
4595
4595
  }
4596
4596
  /**
@@ -4607,7 +4607,7 @@ class Rt extends I {
4607
4607
  const r = this.doc;
4608
4608
  r !== null ? _(r, (i) => {
4609
4609
  const o = ae(i, this, t, !s);
4610
- en(i, this, o, n, s || {});
4610
+ nn(i, this, o, n, s || {});
4611
4611
  }) : this._pending.push(() => this.insertEmbed(t, n, s || {}));
4612
4612
  }
4613
4613
  /**
@@ -4623,7 +4623,7 @@ class Rt extends I {
4623
4623
  return;
4624
4624
  const s = this.doc;
4625
4625
  s !== null ? _(s, (r) => {
4626
- Es(r, ae(r, this, t, !0), n);
4626
+ Ds(r, ae(r, this, t, !0), n);
4627
4627
  }) : this._pending.push(() => this.delete(t, n));
4628
4628
  }
4629
4629
  /**
@@ -4642,7 +4642,7 @@ class Rt extends I {
4642
4642
  const r = this.doc;
4643
4643
  r !== null ? _(r, (i) => {
4644
4644
  const o = ae(i, this, t, !1);
4645
- o.right !== null && Cs(i, this, o, n, s);
4645
+ o.right !== null && Es(i, this, o, n, s);
4646
4646
  }) : this._pending.push(() => this.format(t, n, s));
4647
4647
  }
4648
4648
  /**
@@ -4701,17 +4701,17 @@ class Rt extends I {
4701
4701
  * @public
4702
4702
  */
4703
4703
  getAttributes() {
4704
- return Br(this);
4704
+ return Vr(this);
4705
4705
  }
4706
4706
  /**
4707
4707
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
4708
4708
  */
4709
4709
  _write(t) {
4710
- t.writeTypeRef(Ol);
4710
+ t.writeTypeRef(Ml);
4711
4711
  }
4712
4712
  }
4713
- const dl = (e) => new Rt();
4714
- class nn {
4713
+ const pl = (e) => new Ut();
4714
+ class sn {
4715
4715
  /**
4716
4716
  * @param {YXmlFragment | YXmlElement} root
4717
4717
  * @param {function(AbstractType<any>):boolean} [f]
@@ -4822,7 +4822,7 @@ class ft extends I {
4822
4822
  * @public
4823
4823
  */
4824
4824
  createTreeWalker(t) {
4825
- return new nn(this, t);
4825
+ return new sn(this, t);
4826
4826
  }
4827
4827
  /**
4828
4828
  * Returns the first YXmlElement that matches the query.
@@ -4841,7 +4841,7 @@ class ft extends I {
4841
4841
  */
4842
4842
  querySelector(t) {
4843
4843
  t = t.toUpperCase();
4844
- const s = new nn(this, (r) => r.nodeName && r.nodeName.toUpperCase() === t).next();
4844
+ const s = new sn(this, (r) => r.nodeName && r.nodeName.toUpperCase() === t).next();
4845
4845
  return s.done ? null : s.value;
4846
4846
  }
4847
4847
  /**
@@ -4856,7 +4856,7 @@ class ft extends I {
4856
4856
  * @public
4857
4857
  */
4858
4858
  querySelectorAll(t) {
4859
- return t = t.toUpperCase(), q(new nn(this, (n) => n.nodeName && n.nodeName.toUpperCase() === t));
4859
+ return t = t.toUpperCase(), q(new sn(this, (n) => n.nodeName && n.nodeName.toUpperCase() === t));
4860
4860
  }
4861
4861
  /**
4862
4862
  * Creates YXmlEvent and calls observers.
@@ -4865,7 +4865,7 @@ class ft extends I {
4865
4865
  * @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
4866
4866
  */
4867
4867
  _callObserver(t, n) {
4868
- Pe(this, t, new pl(this, n, t));
4868
+ Ge(this, t, new yl(this, n, t));
4869
4869
  }
4870
4870
  /**
4871
4871
  * Get the string representation of all the children of this YXmlFragment.
@@ -4873,7 +4873,7 @@ class ft extends I {
4873
4873
  * @return {string} The string representation of all children.
4874
4874
  */
4875
4875
  toString() {
4876
- return Nr(this, (t) => t.toString()).join("");
4876
+ return Ur(this, (t) => t.toString()).join("");
4877
4877
  }
4878
4878
  /**
4879
4879
  * @return {string}
@@ -4914,7 +4914,7 @@ class ft extends I {
4914
4914
  */
4915
4915
  insert(t, n) {
4916
4916
  this.doc !== null ? _(this.doc, (s) => {
4917
- Rr(s, this, t, n);
4917
+ Br(s, this, t, n);
4918
4918
  }) : this._prelimContent.splice(t, 0, ...n);
4919
4919
  }
4920
4920
  /**
@@ -4939,7 +4939,7 @@ class ft extends I {
4939
4939
  this._prelimContent
4940
4940
  ), r = t === null ? 0 : s.findIndex((i) => i === t) + 1;
4941
4941
  if (r === 0 && t !== null)
4942
- throw G("Reference item not found");
4942
+ throw Y("Reference item not found");
4943
4943
  s.splice(r, 0, ...n);
4944
4944
  }
4945
4945
  }
@@ -4951,7 +4951,7 @@ class ft extends I {
4951
4951
  */
4952
4952
  delete(t, n = 1) {
4953
4953
  this.doc !== null ? _(this.doc, (s) => {
4954
- $r(s, this, t, n);
4954
+ Fr(s, this, t, n);
4955
4955
  }) : this._prelimContent.splice(t, n);
4956
4956
  }
4957
4957
  /**
@@ -4960,7 +4960,7 @@ class ft extends I {
4960
4960
  * @return {Array<YXmlElement|YXmlText|YXmlHook>}
4961
4961
  */
4962
4962
  toArray() {
4963
- return vr(this);
4963
+ return Mr(this);
4964
4964
  }
4965
4965
  /**
4966
4966
  * Appends content to this YArray.
@@ -4985,7 +4985,7 @@ class ft extends I {
4985
4985
  * @return {YXmlElement|YXmlText}
4986
4986
  */
4987
4987
  get(t) {
4988
- return Mr(this, t);
4988
+ return Rr(this, t);
4989
4989
  }
4990
4990
  /**
4991
4991
  * Returns a portion of this YXmlFragment into a JavaScript Array selected
@@ -4996,7 +4996,7 @@ class ft extends I {
4996
4996
  * @return {Array<YXmlElement|YXmlText>}
4997
4997
  */
4998
4998
  slice(t = 0, n = this.length) {
4999
- return Or(this, t, n);
4999
+ return Nr(this, t, n);
5000
5000
  }
5001
5001
  /**
5002
5002
  * Executes a provided function on once on every child element.
@@ -5015,10 +5015,10 @@ class ft extends I {
5015
5015
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
5016
5016
  */
5017
5017
  _write(t) {
5018
- t.writeTypeRef(Nl);
5018
+ t.writeTypeRef(Rl);
5019
5019
  }
5020
5020
  }
5021
- const fl = (e) => new ft();
5021
+ const wl = (e) => new ft();
5022
5022
  class Q extends ft {
5023
5023
  constructor(t = "UNDEFINED") {
5024
5024
  super(), this.nodeName = t, this._prelimAttrs = /* @__PURE__ */ new Map();
@@ -5077,7 +5077,7 @@ class Q extends ft {
5077
5077
  */
5078
5078
  clone() {
5079
5079
  const t = new Q(this.nodeName), n = this.getAttributes();
5080
- return lo(n, (s, r) => {
5080
+ return uo(n, (s, r) => {
5081
5081
  t.setAttribute(
5082
5082
  r,
5083
5083
  /** @type {any} */
@@ -5162,7 +5162,7 @@ class Q extends ft {
5162
5162
  hasAttribute(t) {
5163
5163
  return (
5164
5164
  /** @type {any} */
5165
- Fr(this, t)
5165
+ jr(this, t)
5166
5166
  );
5167
5167
  }
5168
5168
  /**
@@ -5176,7 +5176,7 @@ class Q extends ft {
5176
5176
  getAttributes(t) {
5177
5177
  return (
5178
5178
  /** @type {any} */
5179
- t ? sl(this, t) : Br(this)
5179
+ t ? ol(this, t) : Vr(this)
5180
5180
  );
5181
5181
  }
5182
5182
  /**
@@ -5213,11 +5213,11 @@ class Q extends ft {
5213
5213
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
5214
5214
  */
5215
5215
  _write(t) {
5216
- t.writeTypeRef(vl), t.writeKey(this.nodeName);
5216
+ t.writeTypeRef(Ul), t.writeKey(this.nodeName);
5217
5217
  }
5218
5218
  }
5219
- const gl = (e) => new Q(e.readKey());
5220
- class pl extends Ye {
5219
+ const ml = (e) => new Q(e.readKey());
5220
+ class yl extends Pe {
5221
5221
  /**
5222
5222
  * @param {YXmlElement|YXmlText|YXmlFragment} target The target on which the event is created.
5223
5223
  * @param {Set<string|null>} subs The set of changed attributes. `null` is included if the
@@ -5231,7 +5231,7 @@ class pl extends Ye {
5231
5231
  });
5232
5232
  }
5233
5233
  }
5234
- class Ae extends Ut {
5234
+ class Ae extends Mt {
5235
5235
  /**
5236
5236
  * @param {string} hookName nodeName of the Dom Node.
5237
5237
  */
@@ -5286,11 +5286,11 @@ class Ae extends Ut {
5286
5286
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
5287
5287
  */
5288
5288
  _write(t) {
5289
- t.writeTypeRef(Ml), t.writeKey(this.hookName);
5289
+ t.writeTypeRef($l), t.writeKey(this.hookName);
5290
5290
  }
5291
5291
  }
5292
- const wl = (e) => new Ae(e.readKey());
5293
- class Z extends Rt {
5292
+ const bl = (e) => new Ae(e.readKey());
5293
+ class Z extends Ut {
5294
5294
  /**
5295
5295
  * @type {YXmlElement|YXmlText|null}
5296
5296
  */
@@ -5382,11 +5382,11 @@ class Z extends Rt {
5382
5382
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
5383
5383
  */
5384
5384
  _write(t) {
5385
- t.writeTypeRef(Ul);
5385
+ t.writeTypeRef(Bl);
5386
5386
  }
5387
5387
  }
5388
- const ml = (e) => new Z();
5389
- class Pn {
5388
+ const kl = (e) => new Z();
5389
+ class Jn {
5390
5390
  /**
5391
5391
  * @param {ID} id
5392
5392
  * @param {number} length
@@ -5426,8 +5426,8 @@ class Pn {
5426
5426
  throw H();
5427
5427
  }
5428
5428
  }
5429
- const yl = 0;
5430
- class F extends Pn {
5429
+ const _l = 0;
5430
+ class F extends Jn {
5431
5431
  get deleted() {
5432
5432
  return !0;
5433
5433
  }
@@ -5445,14 +5445,14 @@ class F extends Pn {
5445
5445
  * @param {number} offset
5446
5446
  */
5447
5447
  integrate(t, n) {
5448
- n > 0 && (this.id.clock += n, this.length -= n), Dr(t.doc.store, this);
5448
+ n > 0 && (this.id.clock += n, this.length -= n), Tr(t.doc.store, this);
5449
5449
  }
5450
5450
  /**
5451
5451
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
5452
5452
  * @param {number} offset
5453
5453
  */
5454
5454
  write(t, n) {
5455
- t.writeInfo(yl), t.writeLen(this.length - n);
5455
+ t.writeInfo(_l), t.writeLen(this.length - n);
5456
5456
  }
5457
5457
  /**
5458
5458
  * @param {Transaction} transaction
@@ -5538,7 +5538,7 @@ class se {
5538
5538
  return 3;
5539
5539
  }
5540
5540
  }
5541
- const bl = (e) => new se(e.readBuf());
5541
+ const Sl = (e) => new se(e.readBuf());
5542
5542
  class Qt {
5543
5543
  /**
5544
5544
  * @param {number} len
@@ -5616,7 +5616,7 @@ class Qt {
5616
5616
  return 1;
5617
5617
  }
5618
5618
  }
5619
- const kl = (e) => new Qt(e.readLen()), Yr = (e, t) => new yt({ guid: e, ...t, shouldLoad: t.shouldLoad || t.autoLoad || !1 });
5619
+ const Cl = (e) => new Qt(e.readLen()), Gr = (e, t) => new yt({ guid: e, ...t, shouldLoad: t.shouldLoad || t.autoLoad || !1 });
5620
5620
  class re {
5621
5621
  /**
5622
5622
  * @param {Doc} doc
@@ -5648,7 +5648,7 @@ class re {
5648
5648
  * @return {ContentDoc}
5649
5649
  */
5650
5650
  copy() {
5651
- return new re(Yr(this.doc.guid, this.opts));
5651
+ return new re(Gr(this.doc.guid, this.opts));
5652
5652
  }
5653
5653
  /**
5654
5654
  * @param {number} offset
@@ -5696,7 +5696,7 @@ class re {
5696
5696
  return 9;
5697
5697
  }
5698
5698
  }
5699
- const _l = (e) => new re(Yr(e.readString(), e.readAny()));
5699
+ const El = (e) => new re(Gr(e.readString(), e.readAny()));
5700
5700
  class bt {
5701
5701
  /**
5702
5702
  * @param {Object} embed
@@ -5772,7 +5772,7 @@ class bt {
5772
5772
  return 5;
5773
5773
  }
5774
5774
  }
5775
- const Sl = (e) => new bt(e.readJSON());
5775
+ const Dl = (e) => new bt(e.readJSON());
5776
5776
  class T {
5777
5777
  /**
5778
5778
  * @param {string} key
@@ -5854,7 +5854,7 @@ class T {
5854
5854
  return 6;
5855
5855
  }
5856
5856
  }
5857
- const Cl = (e) => new T(e.readKey(), e.readJSON());
5857
+ const Al = (e) => new T(e.readKey(), e.readJSON());
5858
5858
  class Te {
5859
5859
  /**
5860
5860
  * @param {Array<any>} arr
@@ -5936,20 +5936,20 @@ class Te {
5936
5936
  return 2;
5937
5937
  }
5938
5938
  }
5939
- const El = (e) => {
5939
+ const Tl = (e) => {
5940
5940
  const t = e.readLen(), n = [];
5941
5941
  for (let s = 0; s < t; s++) {
5942
5942
  const r = e.readString();
5943
5943
  r === "undefined" ? n.push(void 0) : n.push(JSON.parse(r));
5944
5944
  }
5945
5945
  return new Te(n);
5946
- }, Dl = ye("node_env") === "development";
5946
+ }, xl = ye("node_env") === "development";
5947
5947
  class gt {
5948
5948
  /**
5949
5949
  * @param {Array<any>} arr
5950
5950
  */
5951
5951
  constructor(t) {
5952
- this.arr = t, Dl && js(t);
5952
+ this.arr = t, xl && zs(t);
5953
5953
  }
5954
5954
  /**
5955
5955
  * @return {number}
@@ -6025,7 +6025,7 @@ class gt {
6025
6025
  return 8;
6026
6026
  }
6027
6027
  }
6028
- const Al = (e) => {
6028
+ const Il = (e) => {
6029
6029
  const t = e.readLen(), n = [];
6030
6030
  for (let s = 0; s < t; s++)
6031
6031
  n.push(e.readAny());
@@ -6109,15 +6109,15 @@ class J {
6109
6109
  return 4;
6110
6110
  }
6111
6111
  }
6112
- const Tl = (e) => new J(e.readString()), xl = [
6113
- il,
6114
- cl,
6115
- dl,
6116
- gl,
6117
- fl,
6112
+ const Ll = (e) => new J(e.readString()), vl = [
6113
+ ll,
6114
+ hl,
6115
+ pl,
6116
+ ml,
6118
6117
  wl,
6119
- ml
6120
- ], Il = 0, Ll = 1, Ol = 2, vl = 3, Nl = 4, Ml = 5, Ul = 6;
6118
+ bl,
6119
+ kl
6120
+ ], Ol = 0, Nl = 1, Ml = 2, Ul = 3, Rl = 4, $l = 5, Bl = 6;
6121
6121
  class et {
6122
6122
  /**
6123
6123
  * @param {AbstractType<any>} type
@@ -6210,7 +6210,7 @@ class et {
6210
6210
  return 7;
6211
6211
  }
6212
6212
  }
6213
- const Rl = (e) => new et(xl[e.readTypeRef()](e)), $l = (e, t) => {
6213
+ const Fl = (e) => new et(vl[e.readTypeRef()](e)), Vl = (e, t) => {
6214
6214
  let n = t, s = 0, r;
6215
6215
  do
6216
6216
  s > 0 && (n = k(n.client, n.clock + s)), r = fe(e, n), s = n.clock - r.id.clock, n = r.redone;
@@ -6219,7 +6219,7 @@ const Rl = (e) => new et(xl[e.readTypeRef()](e)), $l = (e, t) => {
6219
6219
  item: r,
6220
6220
  diff: s
6221
6221
  };
6222
- }, Jn = (e, t) => {
6222
+ }, Kn = (e, t) => {
6223
6223
  for (; e !== null && e.keep !== t; )
6224
6224
  e.keep = t, e = /** @type {AbstractType<any>} */
6225
6225
  e.parent._item;
@@ -6235,11 +6235,11 @@ const Rl = (e) => new et(xl[e.readTypeRef()](e)), $l = (e, t) => {
6235
6235
  t.content.splice(n)
6236
6236
  );
6237
6237
  return t.deleted && i.markDeleted(), t.keep && (i.keep = !0), t.redone !== null && (i.redone = k(t.redone.client, t.redone.clock + n)), t.right = i, i.right !== null && (i.right.left = i), e._mergeStructs.push(i), i.parentSub !== null && i.right === null && i.parent._map.set(i.parentSub, i), t.length = n, i;
6238
- }, Ds = (e, t) => _n(
6238
+ }, As = (e, t) => Sn(
6239
6239
  e,
6240
6240
  /** @param {StackItem} s */
6241
6241
  (n) => ee(n.deletions, t)
6242
- ), Gr = (e, t, n, s, r, i) => {
6242
+ ), Jr = (e, t, n, s, r, i) => {
6243
6243
  const o = e.doc, c = o.store, l = o.clientID, a = t.redone;
6244
6244
  if (a !== null)
6245
6245
  return R(e, a);
@@ -6248,7 +6248,7 @@ const Rl = (e) => new et(xl[e.readTypeRef()](e)), $l = (e, t) => {
6248
6248
  t.parent._item
6249
6249
  ), d = null, u;
6250
6250
  if (h !== null && h.deleted === !0) {
6251
- if (h.redone === null && (!n.has(h) || Gr(e, h, n, s, r, i) === null))
6251
+ if (h.redone === null && (!n.has(h) || Jr(e, h, n, s, r, i) === null))
6252
6252
  return null;
6253
6253
  for (; h.redone !== null; )
6254
6254
  h = R(e, h.redone);
@@ -6287,7 +6287,7 @@ const Rl = (e) => new et(xl[e.readTypeRef()](e)), $l = (e, t) => {
6287
6287
  }
6288
6288
  } else {
6289
6289
  if (u = null, t.right && !r) {
6290
- for (d = t; d !== null && d.right !== null && (d.right.redone || ee(s, d.right.id) || Ds(i.undoStack, d.right.id) || Ds(i.redoStack, d.right.id)); )
6290
+ for (d = t; d !== null && d.right !== null && (d.right.redone || ee(s, d.right.id) || As(i.undoStack, d.right.id) || As(i.redoStack, d.right.id)); )
6291
6291
  for (d = d.right; d.redone; ) d = R(e, d.redone);
6292
6292
  if (d && d.right !== null)
6293
6293
  return null;
@@ -6306,9 +6306,9 @@ const Rl = (e) => new et(xl[e.readTypeRef()](e)), $l = (e, t) => {
6306
6306
  t.parentSub,
6307
6307
  t.content.copy()
6308
6308
  );
6309
- return t.redone = w, Jn(p, !0), p.integrate(e, 0), p;
6309
+ return t.redone = w, Kn(p, !0), p.integrate(e, 0), p;
6310
6310
  };
6311
- class S extends Pn {
6311
+ class S extends Jn {
6312
6312
  /**
6313
6313
  * @param {ID} id
6314
6314
  * @param {Item | null} left
@@ -6320,7 +6320,7 @@ class S extends Pn {
6320
6320
  * @param {AbstractContent} content
6321
6321
  */
6322
6322
  constructor(t, n, s, r, i, o, c, l) {
6323
- super(t, l.getLength()), this.origin = s, this.left = n, this.right = r, this.rightOrigin = i, this.parent = o, this.parentSub = c, this.redone = null, this.content = l, this.info = this.content.isCountable() ? ts : 0;
6323
+ super(t, l.getLength()), this.origin = s, this.left = n, this.right = r, this.rightOrigin = i, this.parent = o, this.parentSub = c, this.redone = null, this.content = l, this.info = this.content.isCountable() ? es : 0;
6324
6324
  }
6325
6325
  /**
6326
6326
  * This is used to mark the item as an indexed fast-search marker
@@ -6328,35 +6328,35 @@ class S extends Pn {
6328
6328
  * @type {boolean}
6329
6329
  */
6330
6330
  set marker(t) {
6331
- (this.info & We) > 0 !== t && (this.info ^= We);
6331
+ (this.info & Xe) > 0 !== t && (this.info ^= Xe);
6332
6332
  }
6333
6333
  get marker() {
6334
- return (this.info & We) > 0;
6334
+ return (this.info & Xe) > 0;
6335
6335
  }
6336
6336
  /**
6337
6337
  * If true, do not garbage collect this Item.
6338
6338
  */
6339
6339
  get keep() {
6340
- return (this.info & Zn) > 0;
6340
+ return (this.info & ts) > 0;
6341
6341
  }
6342
6342
  set keep(t) {
6343
- this.keep !== t && (this.info ^= Zn);
6343
+ this.keep !== t && (this.info ^= ts);
6344
6344
  }
6345
6345
  get countable() {
6346
- return (this.info & ts) > 0;
6346
+ return (this.info & es) > 0;
6347
6347
  }
6348
6348
  /**
6349
6349
  * Whether this item was deleted or not.
6350
6350
  * @type {Boolean}
6351
6351
  */
6352
6352
  get deleted() {
6353
- return (this.info & Ke) > 0;
6353
+ return (this.info & We) > 0;
6354
6354
  }
6355
6355
  set deleted(t) {
6356
- this.deleted !== t && (this.info ^= Ke);
6356
+ this.deleted !== t && (this.info ^= We);
6357
6357
  }
6358
6358
  markDeleted() {
6359
- this.info |= Ke;
6359
+ this.info |= We;
6360
6360
  }
6361
6361
  /**
6362
6362
  * Return the creator clientID of the missing op or define missing items and return null.
@@ -6370,13 +6370,13 @@ class S extends Pn {
6370
6370
  return this.origin.client;
6371
6371
  if (this.rightOrigin && this.rightOrigin.client !== this.id.client && this.rightOrigin.clock >= A(n, this.rightOrigin.client))
6372
6372
  return this.rightOrigin.client;
6373
- if (this.parent && this.parent.constructor === Tt && this.id.client !== this.parent.client && this.parent.clock >= A(n, this.parent.client))
6373
+ if (this.parent && this.parent.constructor === At && this.id.client !== this.parent.client && this.parent.clock >= A(n, this.parent.client))
6374
6374
  return this.parent.client;
6375
- if (this.origin && (this.left = ws(t, n, this.origin), this.origin = this.left.lastId), this.rightOrigin && (this.right = R(t, this.rightOrigin), this.rightOrigin = this.right.id), this.left && this.left.constructor === F || this.right && this.right.constructor === F)
6375
+ if (this.origin && (this.left = ms(t, n, this.origin), this.origin = this.left.lastId), this.rightOrigin && (this.right = R(t, this.rightOrigin), this.rightOrigin = this.right.id), this.left && this.left.constructor === F || this.right && this.right.constructor === F)
6376
6376
  this.parent = null;
6377
6377
  else if (!this.parent)
6378
6378
  this.left && this.left.constructor === S ? (this.parent = this.left.parent, this.parentSub = this.left.parentSub) : this.right && this.right.constructor === S && (this.parent = this.right.parent, this.parentSub = this.right.parentSub);
6379
- else if (this.parent.constructor === Tt) {
6379
+ else if (this.parent.constructor === At) {
6380
6380
  const s = fe(n, this.parent);
6381
6381
  s.constructor === F ? this.parent = null : this.parent = /** @type {ContentType} */
6382
6382
  s.content.type;
@@ -6388,7 +6388,7 @@ class S extends Pn {
6388
6388
  * @param {number} offset
6389
6389
  */
6390
6390
  integrate(t, n) {
6391
- if (n > 0 && (this.id.clock += n, this.left = ws(t, t.doc.store, k(this.id.client, this.id.clock - 1)), this.origin = this.left.lastId, this.content = this.content.splice(n), this.length -= n), this.parent) {
6391
+ if (n > 0 && (this.id.clock += n, this.left = ms(t, t.doc.store, k(this.id.client, this.id.clock - 1)), this.origin = this.left.lastId, this.content = this.content.splice(n), this.length -= n), this.parent) {
6392
6392
  if (!this.left && (!this.right || this.right.left !== null) || this.left && this.left.right !== this.right) {
6393
6393
  let s = this.left, r;
6394
6394
  if (s !== null)
@@ -6429,7 +6429,7 @@ class S extends Pn {
6429
6429
  this.parent._start, this.parent._start = this;
6430
6430
  this.right = s;
6431
6431
  }
6432
- 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), Dr(t.doc.store, this), this.content.integrate(t, this), ys(
6432
+ 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), Tr(t.doc.store, this), this.content.integrate(t, this), bs(
6433
6433
  t,
6434
6434
  /** @type {AbstractType<any>} */
6435
6435
  this.parent,
@@ -6493,7 +6493,7 @@ class S extends Pn {
6493
6493
  /** @type {AbstractType<any>} */
6494
6494
  this.parent
6495
6495
  );
6496
- this.countable && this.parentSub === null && (n._length -= this.length), this.markDeleted(), Wt(t.deleteSet, this.id.client, this.id.clock, this.length), ys(t, n, this.parentSub), this.content.delete(t);
6496
+ this.countable && this.parentSub === null && (n._length -= this.length), this.markDeleted(), Wt(t.deleteSet, this.id.client, this.id.clock, this.length), bs(t, n, this.parentSub), this.content.delete(t);
6497
6497
  }
6498
6498
  }
6499
6499
  /**
@@ -6503,7 +6503,7 @@ class S extends Pn {
6503
6503
  gc(t, n) {
6504
6504
  if (!this.deleted)
6505
6505
  throw j();
6506
- this.content.gc(t), n ? Fc(t, this, new F(this.id, this.length)) : this.content = new Qt(this.length);
6506
+ this.content.gc(t), n ? Hc(t, this, new F(this.id, this.length)) : this.content = new Qt(this.length);
6507
6507
  }
6508
6508
  /**
6509
6509
  * Transform the properties of this type to binary and write it to an
@@ -6515,7 +6515,7 @@ class S extends Pn {
6515
6515
  * @param {number} offset
6516
6516
  */
6517
6517
  write(t, n) {
6518
- const s = n > 0 ? k(this.id.client, this.id.clock + n - 1) : this.origin, r = this.rightOrigin, i = this.parentSub, o = this.content.getRef() & ve | (s === null ? 0 : B) | // origin is defined
6518
+ const s = n > 0 ? k(this.id.client, this.id.clock + n - 1) : this.origin, r = this.rightOrigin, i = this.parentSub, o = this.content.getRef() & Oe | (s === null ? 0 : B) | // origin is defined
6519
6519
  (r === null ? 0 : X) | // right origin is defined
6520
6520
  (i === null ? 0 : zt);
6521
6521
  if (t.writeInfo(o), s !== null && t.writeLeftID(s), r !== null && t.writeRightID(r), s === null && r === null) {
@@ -6526,45 +6526,45 @@ class S extends Pn {
6526
6526
  if (c._item !== void 0) {
6527
6527
  const l = c._item;
6528
6528
  if (l === null) {
6529
- const a = $c(c);
6529
+ const a = Vc(c);
6530
6530
  t.writeParentInfo(!0), t.writeString(a);
6531
6531
  } else
6532
6532
  t.writeParentInfo(!1), t.writeLeftID(l.id);
6533
- } else c.constructor === String ? (t.writeParentInfo(!0), t.writeString(c)) : c.constructor === Tt ? (t.writeParentInfo(!1), t.writeLeftID(c)) : j();
6533
+ } else c.constructor === String ? (t.writeParentInfo(!0), t.writeString(c)) : c.constructor === At ? (t.writeParentInfo(!1), t.writeLeftID(c)) : j();
6534
6534
  i !== null && t.writeString(i);
6535
6535
  }
6536
6536
  this.content.write(t, n);
6537
6537
  }
6538
6538
  }
6539
- const Pr = (e, t) => Bl[t & ve](e), Bl = [
6539
+ const Kr = (e, t) => jl[t & Oe](e), jl = [
6540
6540
  () => {
6541
6541
  j();
6542
6542
  },
6543
6543
  // GC is not ItemContent
6544
- kl,
6544
+ Cl,
6545
6545
  // 1
6546
- El,
6546
+ Tl,
6547
6547
  // 2
6548
- bl,
6548
+ Sl,
6549
6549
  // 3
6550
- Tl,
6550
+ Ll,
6551
6551
  // 4
6552
- Sl,
6552
+ Dl,
6553
6553
  // 5
6554
- Cl,
6554
+ Al,
6555
6555
  // 6
6556
- Rl,
6556
+ Fl,
6557
6557
  // 7
6558
- Al,
6558
+ Il,
6559
6559
  // 8
6560
- _l,
6560
+ El,
6561
6561
  // 9
6562
6562
  () => {
6563
6563
  j();
6564
6564
  }
6565
6565
  // 10 - Skip is not ItemContent
6566
- ], Fl = 10;
6567
- class V extends Pn {
6566
+ ], Hl = 10;
6567
+ class V extends Jn {
6568
6568
  get deleted() {
6569
6569
  return !0;
6570
6570
  }
@@ -6589,7 +6589,7 @@ class V extends Pn {
6589
6589
  * @param {number} offset
6590
6590
  */
6591
6591
  write(t, n) {
6592
- t.writeInfo(Fl), m(t.restEncoder, this.length - n);
6592
+ t.writeInfo(Hl), m(t.restEncoder, this.length - n);
6593
6593
  }
6594
6594
  /**
6595
6595
  * @param {Transaction} transaction
@@ -6600,79 +6600,79 @@ class V extends Pn {
6600
6600
  return null;
6601
6601
  }
6602
6602
  }
6603
- const Jr = (
6603
+ const Wr = (
6604
6604
  /** @type {any} */
6605
6605
  typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof globalThis != "undefined" ? globalThis : {}
6606
- ), Kr = "__ $YJS$ __";
6607
- Jr[Kr] === !0 && console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");
6608
- Jr[Kr] = !0;
6609
- const Wr = /* @__PURE__ */ new Map();
6610
- class Vl {
6606
+ ), Xr = "__ $YJS$ __";
6607
+ Wr[Xr] === !0 && console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");
6608
+ Wr[Xr] = !0;
6609
+ const qr = /* @__PURE__ */ new Map();
6610
+ class zl {
6611
6611
  /**
6612
6612
  * @param {string} room
6613
6613
  */
6614
6614
  constructor(t) {
6615
- this.room = t, this.onmessage = null, this._onChange = (n) => n.key === t && this.onmessage !== null && this.onmessage({ data: Ao(n.newValue || "") }), so(this._onChange);
6615
+ this.room = t, this.onmessage = null, this._onChange = (n) => n.key === t && this.onmessage !== null && this.onmessage({ data: Io(n.newValue || "") }), oo(this._onChange);
6616
6616
  }
6617
6617
  /**
6618
6618
  * @param {ArrayBuffer} buf
6619
6619
  */
6620
6620
  postMessage(t) {
6621
- Fs.setItem(this.room, Do(ko(t)));
6621
+ js.setItem(this.room, xo(Co(t)));
6622
6622
  }
6623
6623
  close() {
6624
- ro(this._onChange);
6624
+ co(this._onChange);
6625
6625
  }
6626
6626
  }
6627
- const jl = typeof BroadcastChannel == "undefined" ? Vl : BroadcastChannel, Kn = (e) => K(Wr, e, () => {
6628
- const t = it(), n = new jl(e);
6627
+ const Pl = typeof BroadcastChannel == "undefined" ? zl : BroadcastChannel, Wn = (e) => K(qr, e, () => {
6628
+ const t = it(), n = new Pl(e);
6629
6629
  return n.onmessage = (s) => t.forEach((r) => r(s.data, "broadcastchannel")), {
6630
6630
  bc: n,
6631
6631
  subs: t
6632
6632
  };
6633
- }), Hl = (e, t) => (Kn(e).subs.add(t), t), zl = (e, t) => {
6634
- const n = Kn(e), s = n.subs.delete(t);
6635
- return s && n.subs.size === 0 && (n.bc.close(), Wr.delete(e)), s;
6636
- }, Ct = (e, t, n = null) => {
6637
- const s = Kn(e);
6633
+ }), Yl = (e, t) => (Wn(e).subs.add(t), t), Gl = (e, t) => {
6634
+ const n = Wn(e), s = n.subs.delete(t);
6635
+ return s && n.subs.size === 0 && (n.bc.close(), qr.delete(e)), s;
6636
+ }, St = (e, t, n = null) => {
6637
+ const s = Wn(e);
6638
6638
  s.bc.postMessage(t), s.subs.forEach((r) => r(t, n));
6639
- }, Xr = 0, Wn = 1, qr = 2, mn = (e, t) => {
6640
- m(e, Xr);
6641
- const n = Uc(t);
6639
+ }, Qr = 0, Xn = 1, Zr = 2, yn = (e, t) => {
6640
+ m(e, Qr);
6641
+ const n = Bc(t);
6642
6642
  E(e, n);
6643
- }, Qr = (e, t, n) => {
6644
- m(e, Wn), E(e, Oc(t, n));
6645
- }, Yl = (e, t, n) => Qr(t, n, v(e)), Zr = (e, t, n, s) => {
6643
+ }, ti = (e, t, n) => {
6644
+ m(e, Xn), E(e, Mc(t, n));
6645
+ }, Jl = (e, t, n) => ti(t, n, O(e)), ei = (e, t, n, s) => {
6646
6646
  try {
6647
- xc(t, v(e), n);
6647
+ vc(t, O(e), n);
6648
6648
  } catch (r) {
6649
6649
  s != null && s(
6650
6650
  /** @type {Error} */
6651
6651
  r
6652
6652
  ), console.error("Caught error while handling a Yjs update", r);
6653
6653
  }
6654
- }, Gl = (e, t) => {
6655
- m(e, qr), E(e, t);
6656
- }, Pl = Zr, Jl = (e, t, n, s, r) => {
6654
+ }, Kl = (e, t) => {
6655
+ m(e, Zr), E(e, t);
6656
+ }, Wl = ei, Xl = (e, t, n, s, r) => {
6657
6657
  const i = b(e);
6658
6658
  switch (i) {
6659
- case Xr:
6660
- Yl(e, t, n);
6659
+ case Qr:
6660
+ Jl(e, t, n);
6661
6661
  break;
6662
- case Wn:
6663
- Zr(e, n, s, r);
6662
+ case Xn:
6663
+ ei(e, n, s, r);
6664
6664
  break;
6665
- case qr:
6666
- Pl(e, n, s, r);
6665
+ case Zr:
6666
+ Wl(e, n, s, r);
6667
6667
  break;
6668
6668
  default:
6669
6669
  throw new Error("Unknown message type");
6670
6670
  }
6671
6671
  return i;
6672
- }, Kl = 0, Wl = (e, t, n) => {
6673
- b(e) === Kl && n(t, rt(e));
6674
- }, sn = 3e4;
6675
- class Xl extends _i {
6672
+ }, ql = 0, Ql = (e, t, n) => {
6673
+ b(e) === ql && n(t, rt(e));
6674
+ }, rn = 3e4;
6675
+ class Zl extends Ei {
6676
6676
  /**
6677
6677
  * @param {Y.Doc} doc
6678
6678
  */
@@ -6680,13 +6680,13 @@ class Xl extends _i {
6680
6680
  super(), this.doc = t, this.clientID = t.clientID, this.states = /* @__PURE__ */ new Map(), this.meta = /* @__PURE__ */ new Map(), this._checkInterval = /** @type {any} */
6681
6681
  setInterval(() => {
6682
6682
  const n = ot();
6683
- this.getLocalState() !== null && sn / 2 <= n - /** @type {{lastUpdated:number}} */
6683
+ this.getLocalState() !== null && rn / 2 <= n - /** @type {{lastUpdated:number}} */
6684
6684
  this.meta.get(this.clientID).lastUpdated && this.setLocalState(this.getLocalState());
6685
6685
  const s = [];
6686
6686
  this.meta.forEach((r, i) => {
6687
- i !== this.clientID && sn <= n - r.lastUpdated && this.states.has(i) && s.push(i);
6688
- }), s.length > 0 && Xn(this, s, "timeout");
6689
- }, z(sn / 10)), t.on("destroy", () => {
6687
+ i !== this.clientID && rn <= n - r.lastUpdated && this.states.has(i) && s.push(i);
6688
+ }), s.length > 0 && qn(this, s, "timeout");
6689
+ }, z(rn / 10)), t.on("destroy", () => {
6690
6690
  this.destroy();
6691
6691
  }), this.setLocalState({});
6692
6692
  }
@@ -6709,7 +6709,7 @@ class Xl extends _i {
6709
6709
  lastUpdated: ot()
6710
6710
  });
6711
6711
  const o = [], c = [], l = [], a = [];
6712
- t === null ? a.push(n) : i == null ? t != null && o.push(n) : (c.push(n), Dt(i, t) || l.push(n)), (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"]);
6712
+ t === null ? a.push(n) : i == null ? t != null && o.push(n) : (c.push(n), Et(i, t) || l.push(n)), (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"]);
6713
6713
  }
6714
6714
  /**
6715
6715
  * @param {string} field
@@ -6729,7 +6729,7 @@ class Xl extends _i {
6729
6729
  return this.states;
6730
6730
  }
6731
6731
  }
6732
- const Xn = (e, t, n) => {
6732
+ const qn = (e, t, n) => {
6733
6733
  const s = [];
6734
6734
  for (let r = 0; r < t.length; r++) {
6735
6735
  const i = t[r];
@@ -6759,7 +6759,7 @@ const Xn = (e, t, n) => {
6759
6759
  m(r, o), m(r, l), ut(r, JSON.stringify(c));
6760
6760
  }
6761
6761
  return C(r);
6762
- }, ql = (e, t, n) => {
6762
+ }, ta = (e, t, n) => {
6763
6763
  const s = lt(t), r = ot(), i = [], o = [], c = [], l = [], a = b(s);
6764
6764
  for (let h = 0; h < a; h++) {
6765
6765
  const d = b(s);
@@ -6768,7 +6768,7 @@ const Xn = (e, t, n) => {
6768
6768
  (p < u || p === u && f === null && e.states.has(d)) && (f === null ? d === e.clientID && e.getLocalState() != null ? u++ : e.states.delete(d) : e.states.set(d, f), e.meta.set(d, {
6769
6769
  clock: u,
6770
6770
  lastUpdated: r
6771
- }), g === void 0 && f !== null ? i.push(d) : g !== void 0 && f === null ? l.push(d) : f !== null && (Dt(f, w) || c.push(d), o.push(d)));
6771
+ }), g === void 0 && f !== null ? i.push(d) : g !== void 0 && f === null ? l.push(d) : f !== null && (Et(f, w) || c.push(d), o.push(d)));
6772
6772
  }
6773
6773
  (i.length > 0 || c.length > 0 || l.length > 0) && e.emit("change", [{
6774
6774
  added: i,
@@ -6779,19 +6779,19 @@ const Xn = (e, t, n) => {
6779
6779
  updated: o,
6780
6780
  removed: l
6781
6781
  }, n]);
6782
- }, Ql = (e) => ao(e, (t, n) => `${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&"), at = 0, ti = 3, It = 1, Zl = 2, ie = [];
6782
+ }, ea = (e) => fo(e, (t, n) => `${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&"), at = 0, ni = 3, xt = 1, na = 2, ie = [];
6783
6783
  ie[at] = (e, t, n, s, r) => {
6784
6784
  m(e, at);
6785
- const i = Jl(
6785
+ const i = Xl(
6786
6786
  t,
6787
6787
  e,
6788
6788
  n.doc,
6789
6789
  n
6790
6790
  );
6791
- s && i === Wn && !n.synced && (n.synced = !0);
6791
+ s && i === Xn && !n.synced && (n.synced = !0);
6792
6792
  };
6793
- ie[ti] = (e, t, n, s, r) => {
6794
- m(e, It), E(
6793
+ ie[ni] = (e, t, n, s, r) => {
6794
+ m(e, xt), E(
6795
6795
  e,
6796
6796
  Ht(
6797
6797
  n.awareness,
@@ -6799,26 +6799,26 @@ ie[ti] = (e, t, n, s, r) => {
6799
6799
  )
6800
6800
  );
6801
6801
  };
6802
- ie[It] = (e, t, n, s, r) => {
6803
- ql(
6802
+ ie[xt] = (e, t, n, s, r) => {
6803
+ ta(
6804
6804
  n.awareness,
6805
- v(t),
6805
+ O(t),
6806
6806
  n
6807
6807
  );
6808
6808
  };
6809
- ie[Zl] = (e, t, n, s, r) => {
6810
- Wl(
6809
+ ie[na] = (e, t, n, s, r) => {
6810
+ Ql(
6811
6811
  t,
6812
6812
  n.doc,
6813
- (i, o) => ta(n, o)
6813
+ (i, o) => sa(n, o)
6814
6814
  );
6815
6815
  };
6816
- const As = 3e4, ta = (e, t) => console.warn(`Permission denied to access ${e.url}.
6817
- ${t}`), ei = (e, t, n) => {
6816
+ const Ts = 3e4, sa = (e, t) => console.warn(`Permission denied to access ${e.url}.
6817
+ ${t}`), si = (e, t, n) => {
6818
6818
  const s = lt(t), r = N(), i = b(s), o = e.messageHandlers[i];
6819
6819
  return /** @type {any} */ o ? o(r, s, e, n, i) : console.error("Unable to compute message"), r;
6820
- }, yn = (e, t, n) => {
6821
- t === e.ws && (e.emit("connection-close", [n, e]), e.ws = null, t.close(), e.wsconnecting = !1, e.wsconnected ? (e.wsconnected = !1, e.synced = !1, Xn(
6820
+ }, bn = (e, t, n) => {
6821
+ t === e.ws && (e.emit("connection-close", [n, e]), e.ws = null, t.close(), e.wsconnecting = !1, e.wsconnected ? (e.wsconnected = !1, e.synced = !1, qn(
6822
6822
  e.awareness,
6823
6823
  Array.from(e.awareness.getStates().keys()).filter(
6824
6824
  (s) => s !== e.doc.clientID
@@ -6827,32 +6827,32 @@ ${t}`), ei = (e, t, n) => {
6827
6827
  ), e.emit("status", [{
6828
6828
  status: "disconnected"
6829
6829
  }])) : e.wsUnsuccessfulReconnects++, setTimeout(
6830
- ni,
6831
- Cn(
6832
- Si(2, e.wsUnsuccessfulReconnects) * 100,
6830
+ ri,
6831
+ En(
6832
+ Di(2, e.wsUnsuccessfulReconnects) * 100,
6833
6833
  e.maxBackoffTime
6834
6834
  ),
6835
6835
  e
6836
6836
  ));
6837
- }, ni = (e) => {
6837
+ }, ri = (e) => {
6838
6838
  if (e.shouldConnect && e.ws === null) {
6839
6839
  const t = new e._WS(e.url, e.protocols);
6840
6840
  t.binaryType = "arraybuffer", e.ws = t, e.wsconnecting = !0, e.wsconnected = !1, e.synced = !1, t.onmessage = (n) => {
6841
6841
  e.wsLastMessageReceived = ot();
6842
- const s = ei(e, new Uint8Array(n.data), !0);
6843
- En(s) > 1 && t.send(C(s));
6842
+ const s = si(e, new Uint8Array(n.data), !0);
6843
+ Dn(s) > 1 && t.send(C(s));
6844
6844
  }, t.onerror = (n) => {
6845
6845
  e.emit("connection-error", [n, e]);
6846
6846
  }, t.onclose = (n) => {
6847
- yn(e, t, n);
6847
+ bn(e, t, n);
6848
6848
  }, t.onopen = () => {
6849
6849
  e.wsLastMessageReceived = ot(), e.wsconnecting = !1, e.wsconnected = !0, e.wsUnsuccessfulReconnects = 0, e.emit("status", [{
6850
6850
  status: "connected"
6851
6851
  }]);
6852
6852
  const n = N();
6853
- if (m(n, at), mn(n, e.doc), t.send(C(n)), e.awareness.getLocalState() !== null) {
6853
+ if (m(n, at), yn(n, e.doc), t.send(C(n)), e.awareness.getLocalState() !== null) {
6854
6854
  const s = N();
6855
- m(s, It), E(
6855
+ m(s, xt), E(
6856
6856
  s,
6857
6857
  Ht(e.awareness, [
6858
6858
  e.doc.clientID
@@ -6863,11 +6863,11 @@ ${t}`), ei = (e, t, n) => {
6863
6863
  status: "connecting"
6864
6864
  }]);
6865
6865
  }
6866
- }, rn = (e, t) => {
6866
+ }, on = (e, t) => {
6867
6867
  const n = e.ws;
6868
- e.wsconnected && n && n.readyState === n.OPEN && n.send(t), e.bcconnected && Ct(e.bcChannel, t, e);
6868
+ e.wsconnected && n && n.readyState === n.OPEN && n.send(t), e.bcconnected && St(e.bcChannel, t, e);
6869
6869
  };
6870
- class ea extends Sn {
6870
+ class ra extends Cn {
6871
6871
  /**
6872
6872
  * @param {string} serverUrl
6873
6873
  * @param {string} roomname
@@ -6884,7 +6884,7 @@ class ea extends Sn {
6884
6884
  */
6885
6885
  constructor(t, n, s, {
6886
6886
  connect: r = !0,
6887
- awareness: i = new Xl(s),
6887
+ awareness: i = new Zl(s),
6888
6888
  params: o = {},
6889
6889
  protocols: c = [],
6890
6890
  WebSocketPolyfill: l = WebSocket,
@@ -6898,42 +6898,42 @@ class ea extends Sn {
6898
6898
  setInterval(() => {
6899
6899
  if (this.ws && this.ws.readyState === WebSocket.OPEN) {
6900
6900
  const u = N();
6901
- m(u, at), mn(u, s), this.ws.send(C(u));
6901
+ m(u, at), yn(u, s), this.ws.send(C(u));
6902
6902
  }
6903
6903
  }, a)), this._bcSubscriber = (u, f) => {
6904
6904
  if (f !== this) {
6905
- const g = ei(this, new Uint8Array(u), !1);
6906
- En(g) > 1 && Ct(this.bcChannel, C(g), this);
6905
+ const g = si(this, new Uint8Array(u), !1);
6906
+ Dn(g) > 1 && St(this.bcChannel, C(g), this);
6907
6907
  }
6908
6908
  }, this._updateHandler = (u, f) => {
6909
6909
  if (f !== this) {
6910
6910
  const g = N();
6911
- m(g, at), Gl(g, u), rn(this, C(g));
6911
+ m(g, at), Kl(g, u), on(this, C(g));
6912
6912
  }
6913
6913
  }, this.doc.on("update", this._updateHandler), this._awarenessUpdateHandler = ({ added: u, updated: f, removed: g }, w) => {
6914
6914
  const p = u.concat(f).concat(g), y = N();
6915
- m(y, It), E(
6915
+ m(y, xt), E(
6916
6916
  y,
6917
6917
  Ht(i, p)
6918
- ), rn(this, C(y));
6918
+ ), on(this, C(y));
6919
6919
  }, this._exitHandler = () => {
6920
- Xn(
6920
+ qn(
6921
6921
  this.awareness,
6922
6922
  [s.clientID],
6923
6923
  "app closed"
6924
6924
  );
6925
6925
  }, ct && typeof process != "undefined" && process.on("exit", this._exitHandler), i.on("update", this._awarenessUpdateHandler), this._checkInterval = /** @type {any} */
6926
6926
  setInterval(() => {
6927
- this.wsconnected && As < ot() - this.wsLastMessageReceived && yn(
6927
+ this.wsconnected && Ts < ot() - this.wsLastMessageReceived && bn(
6928
6928
  this,
6929
6929
  /** @type {WebSocket} */
6930
6930
  this.ws,
6931
6931
  null
6932
6932
  );
6933
- }, As / 10), r && this.connect();
6933
+ }, Ts / 10), r && this.connect();
6934
6934
  }
6935
6935
  get url() {
6936
- const t = Ql(this.params);
6936
+ const t = ea(this.params);
6937
6937
  return this.serverUrl + "/" + this.roomname + (t.length === 0 ? "" : "?" + t);
6938
6938
  }
6939
6939
  /**
@@ -6951,24 +6951,24 @@ class ea extends Sn {
6951
6951
  connectBc() {
6952
6952
  if (this.disableBc)
6953
6953
  return;
6954
- this.bcconnected || (Hl(this.bcChannel, this._bcSubscriber), this.bcconnected = !0);
6954
+ this.bcconnected || (Yl(this.bcChannel, this._bcSubscriber), this.bcconnected = !0);
6955
6955
  const t = N();
6956
- m(t, at), mn(t, this.doc), Ct(this.bcChannel, C(t), this);
6956
+ m(t, at), yn(t, this.doc), St(this.bcChannel, C(t), this);
6957
6957
  const n = N();
6958
- m(n, at), Qr(n, this.doc), Ct(this.bcChannel, C(n), this);
6958
+ m(n, at), ti(n, this.doc), St(this.bcChannel, C(n), this);
6959
6959
  const s = N();
6960
- m(s, ti), Ct(
6960
+ m(s, ni), St(
6961
6961
  this.bcChannel,
6962
6962
  C(s),
6963
6963
  this
6964
6964
  );
6965
6965
  const r = N();
6966
- m(r, It), E(
6966
+ m(r, xt), E(
6967
6967
  r,
6968
6968
  Ht(this.awareness, [
6969
6969
  this.doc.clientID
6970
6970
  ])
6971
- ), Ct(
6971
+ ), St(
6972
6972
  this.bcChannel,
6973
6973
  C(r),
6974
6974
  this
@@ -6976,21 +6976,21 @@ class ea extends Sn {
6976
6976
  }
6977
6977
  disconnectBc() {
6978
6978
  const t = N();
6979
- m(t, It), E(
6979
+ m(t, xt), E(
6980
6980
  t,
6981
6981
  Ht(this.awareness, [
6982
6982
  this.doc.clientID
6983
6983
  ], /* @__PURE__ */ new Map())
6984
- ), rn(this, C(t)), this.bcconnected && (zl(this.bcChannel, this._bcSubscriber), this.bcconnected = !1);
6984
+ ), on(this, C(t)), this.bcconnected && (Gl(this.bcChannel, this._bcSubscriber), this.bcconnected = !1);
6985
6985
  }
6986
6986
  disconnect() {
6987
- this.shouldConnect = !1, this.disconnectBc(), this.ws !== null && yn(this, this.ws, null);
6987
+ this.shouldConnect = !1, this.disconnectBc(), this.ws !== null && bn(this, this.ws, null);
6988
6988
  }
6989
6989
  connect() {
6990
- this.shouldConnect = !0, !this.wsconnected && this.ws === null && (ni(this), this.connectBc());
6990
+ this.shouldConnect = !0, !this.wsconnected && this.ws === null && (ri(this), this.connectBc());
6991
6991
  }
6992
6992
  }
6993
- const si = "data-collab-blocked", ri = /^[a-z][a-z0-9-]*$/, na = /^[a-z_:][-a-z0-9_:.]*$/i, sa = /* @__PURE__ */ new Set([
6993
+ const ii = "data-collab-blocked", oi = /^[a-z][a-z0-9-]*$/, ia = /^[a-z_:][-a-z0-9_:.]*$/i, oa = /* @__PURE__ */ new Set([
6994
6994
  "script",
6995
6995
  "style",
6996
6996
  "iframe",
@@ -7005,7 +7005,7 @@ const si = "data-collab-blocked", ri = /^[a-z][a-z0-9-]*$/, na = /^[a-z_:][-a-z0
7005
7005
  "noscript",
7006
7006
  "template",
7007
7007
  "portal"
7008
- ]), ra = /* @__PURE__ */ new Set([
7008
+ ]), ca = /* @__PURE__ */ new Set([
7009
7009
  "href",
7010
7010
  "src",
7011
7011
  "xlink:href",
@@ -7022,12 +7022,12 @@ const si = "data-collab-blocked", ri = /^[a-z][a-z0-9-]*$/, na = /^[a-z_:][-a-z0
7022
7022
  "usemap",
7023
7023
  "lowsrc",
7024
7024
  "dynsrc"
7025
- ]), ia = /^data:image\/(?:png|gif|jpe?g|webp|avif|bmp|x-icon);/, oa = new RegExp("[\\u0000-\\u0020\\u007f-\\u009f\\u00ad\\u200b-\\u200f\\u2028\\u2029\\ufeff]", "g");
7026
- function ca(e) {
7027
- const t = e.replace(oa, "").toLowerCase();
7028
- return /^(?:javascript|vbscript|livescript|mocha):/.test(t) ? !1 : t.startsWith("data:") ? ia.test(t) : !0;
7025
+ ]), la = /^data:image\/(?:png|gif|jpe?g|webp|avif|bmp|x-icon);/, aa = new RegExp("[\\u0000-\\u0020\\u007f-\\u009f\\u00ad\\u200b-\\u200f\\u2028\\u2029\\ufeff]", "g");
7026
+ function ha(e) {
7027
+ const t = e.replace(aa, "").toLowerCase();
7028
+ return /^(?:javascript|vbscript|livescript|mocha):/.test(t) ? !1 : t.startsWith("data:") ? la.test(t) : !0;
7029
7029
  }
7030
- function la(e) {
7030
+ function ua(e) {
7031
7031
  var n;
7032
7032
  if (!("data-editora-embed" in e)) return !1;
7033
7033
  const t = (n = e.src) == null ? void 0 : n.trim();
@@ -7039,29 +7039,29 @@ function la(e) {
7039
7039
  return !1;
7040
7040
  }
7041
7041
  }
7042
- function aa(e, t) {
7042
+ function da(e, t) {
7043
7043
  const n = e.toLowerCase();
7044
- return ri.test(n) ? n === "iframe" ? !la(t) : sa.has(n) : !0;
7044
+ return oi.test(n) ? n === "iframe" ? !ua(t) : oa.has(n) : !0;
7045
7045
  }
7046
- function ii(e, t) {
7047
- if (!na.test(e)) return !1;
7046
+ function ci(e, t) {
7047
+ if (!ia.test(e)) return !1;
7048
7048
  const n = e.toLowerCase();
7049
- return n.startsWith("on") || n === "srcdoc" ? !1 : ra.has(n) ? ca(String(t)) : !0;
7049
+ return n.startsWith("on") || n === "srcdoc" ? !1 : ca.has(n) ? ha(String(t)) : !0;
7050
7050
  }
7051
- function ha(e, t) {
7051
+ function fa(e, t) {
7052
7052
  const n = e.createElement("span");
7053
- return n.setAttribute(si, ri.test(t.toLowerCase()) ? t.toLowerCase().slice(0, 32) : "invalid"), n.hidden = !0, n;
7053
+ return n.setAttribute(ii, oi.test(t.toLowerCase()) ? t.toLowerCase().slice(0, 32) : "invalid"), n.hidden = !0, n;
7054
7054
  }
7055
7055
  function Ie(e) {
7056
- return e.nodeType === Node.ELEMENT_NODE && e.hasAttribute(si);
7056
+ return e.nodeType === Node.ELEMENT_NODE && e.hasAttribute(ii);
7057
7057
  }
7058
- function ua(e) {
7058
+ function ga(e) {
7059
7059
  return e instanceof Z || e instanceof Q;
7060
7060
  }
7061
- function qn(e) {
7062
- return e.toArray().filter(ua);
7061
+ function Qn(e) {
7062
+ return e.toArray().filter(ga);
7063
7063
  }
7064
- function da(e, t) {
7064
+ function pa(e, t) {
7065
7065
  if (e === t) return null;
7066
7066
  let n = 0;
7067
7067
  const s = Math.min(e.length, t.length);
@@ -7075,75 +7075,75 @@ function da(e, t) {
7075
7075
  insertText: t.slice(n, t.length - r)
7076
7076
  };
7077
7077
  }
7078
- function fa(e) {
7078
+ function wa(e) {
7079
7079
  const t = new Q(e.tagName.toLowerCase());
7080
7080
  for (const s of Array.from(e.attributes))
7081
7081
  t.setAttribute(s.name, s.value);
7082
- const n = oi(e.childNodes);
7082
+ const n = li(e.childNodes);
7083
7083
  return n.length && t.insert(0, n), t;
7084
7084
  }
7085
- function oi(e) {
7085
+ function li(e) {
7086
7086
  var n;
7087
7087
  const t = [];
7088
7088
  for (const s of Array.from(e))
7089
- s.nodeType === Node.TEXT_NODE ? t.push(new Z((n = s.textContent) != null ? n : "")) : s.nodeType === Node.ELEMENT_NODE && t.push(fa(s));
7089
+ s.nodeType === Node.TEXT_NODE ? t.push(new Z((n = s.textContent) != null ? n : "")) : s.nodeType === Node.ELEMENT_NODE && t.push(wa(s));
7090
7090
  return t;
7091
7091
  }
7092
- function ci(e) {
7093
- return aa(e.nodeName, e.getAttributes());
7092
+ function ai(e) {
7093
+ return da(e.nodeName, e.getAttributes());
7094
7094
  }
7095
- function ga(e, t) {
7096
- if (ci(e)) return ha(t, e.nodeName);
7095
+ function ma(e, t) {
7096
+ if (ai(e)) return fa(t, e.nodeName);
7097
7097
  const n = t.createElement(e.nodeName);
7098
7098
  for (const [s, r] of Object.entries(e.getAttributes()))
7099
- ii(s, r) && n.setAttribute(s, r);
7100
- for (const s of qn(e))
7101
- n.appendChild(li(s, t));
7099
+ ci(s, r) && n.setAttribute(s, r);
7100
+ for (const s of Qn(e))
7101
+ n.appendChild(hi(s, t));
7102
7102
  return n;
7103
7103
  }
7104
- function li(e, t) {
7105
- return e instanceof Z ? t.createTextNode(e.toString()) : ga(e, t);
7104
+ function hi(e, t) {
7105
+ return e instanceof Z ? t.createTextNode(e.toString()) : ma(e, t);
7106
7106
  }
7107
- function ai(e, t) {
7108
- return ci(t) ? Ie(e) : !Ie(e) && e.tagName.toLowerCase() === t.nodeName.toLowerCase();
7107
+ function ui(e, t) {
7108
+ return ai(t) ? Ie(e) : !Ie(e) && e.tagName.toLowerCase() === t.nodeName.toLowerCase();
7109
7109
  }
7110
- function bn(e, t) {
7110
+ function kn(e, t) {
7111
7111
  var o;
7112
7112
  const n = Array.from(t.childNodes).filter(
7113
7113
  (c) => c.nodeType === Node.TEXT_NODE || c.nodeType === Node.ELEMENT_NODE
7114
- ), s = qn(e), r = Math.min(n.length, s.length);
7114
+ ), s = Qn(e), r = Math.min(n.length, s.length);
7115
7115
  let i = 0;
7116
7116
  for (; i < r; i++) {
7117
7117
  const c = n[i], l = s[i];
7118
7118
  if (c.nodeType === Node.TEXT_NODE) {
7119
7119
  if (l instanceof Z) {
7120
- const a = da(l.toString(), (o = c.textContent) != null ? o : "");
7120
+ const a = pa(l.toString(), (o = c.textContent) != null ? o : "");
7121
7121
  a && (a.deleteCount > 0 && l.delete(a.start, a.deleteCount), a.insertText && l.insert(a.start, a.insertText));
7122
7122
  continue;
7123
7123
  }
7124
7124
  break;
7125
7125
  }
7126
- if (l instanceof Q && ai(c, l)) {
7126
+ if (l instanceof Q && ui(c, l)) {
7127
7127
  if (Ie(c)) continue;
7128
- pa(l, c), bn(l, c);
7128
+ ya(l, c), kn(l, c);
7129
7129
  continue;
7130
7130
  }
7131
7131
  break;
7132
7132
  }
7133
7133
  if (i < s.length && e.delete(i, s.length - i), i < n.length) {
7134
- const c = oi(n.slice(i));
7134
+ const c = li(n.slice(i));
7135
7135
  c.length && e.insert(i, c);
7136
7136
  }
7137
7137
  }
7138
- function pa(e, t) {
7138
+ function ya(e, t) {
7139
7139
  const n = e.getAttributes(), s = new Set(Array.from(t.attributes).map((r) => r.name));
7140
7140
  for (const r of Object.keys(n))
7141
7141
  s.has(r) || e.removeAttribute(r);
7142
7142
  for (const r of Array.from(t.attributes))
7143
7143
  n[r.name] !== r.value && e.setAttribute(r.name, r.value);
7144
7144
  }
7145
- function hi(e, t, n) {
7146
- const s = qn(t), r = Array.from(e.childNodes).filter(
7145
+ function di(e, t, n) {
7146
+ const s = Qn(t), r = Array.from(e.childNodes).filter(
7147
7147
  (c) => c.nodeType === Node.TEXT_NODE || c.nodeType === Node.ELEMENT_NODE
7148
7148
  ), i = Math.min(s.length, r.length);
7149
7149
  let o = 0;
@@ -7157,9 +7157,9 @@ function hi(e, t, n) {
7157
7157
  }
7158
7158
  break;
7159
7159
  }
7160
- if (l.nodeType === Node.ELEMENT_NODE && ai(l, c)) {
7160
+ if (l.nodeType === Node.ELEMENT_NODE && ui(l, c)) {
7161
7161
  if (Ie(l)) continue;
7162
- wa(l, c), hi(l, c, n);
7162
+ ba(l, c), di(l, c, n);
7163
7163
  continue;
7164
7164
  }
7165
7165
  break;
@@ -7167,29 +7167,29 @@ function hi(e, t, n) {
7167
7167
  for (let c = r.length - 1; c >= o; c--)
7168
7168
  e.removeChild(r[c]);
7169
7169
  for (let c = o; c < s.length; c++)
7170
- e.appendChild(li(s[c], n));
7170
+ e.appendChild(hi(s[c], n));
7171
7171
  }
7172
- function wa(e, t) {
7172
+ function ba(e, t) {
7173
7173
  const n = t.getAttributes(), s = new Set(Array.from(e.attributes).map((r) => r.name));
7174
7174
  for (const r of s)
7175
7175
  r in n || e.removeAttribute(r);
7176
7176
  for (const [r, i] of Object.entries(n)) {
7177
- if (!ii(r, i)) {
7177
+ if (!ci(r, i)) {
7178
7178
  e.removeAttribute(r);
7179
7179
  continue;
7180
7180
  }
7181
7181
  e.getAttribute(r) !== i && e.setAttribute(r, i);
7182
7182
  }
7183
7183
  }
7184
- class ma {
7184
+ class ka {
7185
7185
  constructor(t, n, s) {
7186
7186
  this.root = t, this.doc = n, this.fragment = s, this.pending = !1, this.destroyed = !1, this.onFragmentChange = (r, i) => {
7187
7187
  i.origin !== this && this.applyRemoteToDom();
7188
- }, this.observer = new MutationObserver(() => this.scheduleLocalSync()), this.fragment.length === 0 && this.root.childNodes.length > 0 ? this.doc.transact(() => bn(this.fragment, this.root), this) : this.applyRemoteToDom(), this.observer.observe(this.root, { childList: !0, characterData: !0, subtree: !0, attributes: !0 }), this.fragment.observeDeep(this.onFragmentChange);
7188
+ }, this.observer = new MutationObserver(() => this.scheduleLocalSync()), this.fragment.length === 0 && this.root.childNodes.length > 0 ? this.doc.transact(() => kn(this.fragment, this.root), this) : this.applyRemoteToDom(), this.observer.observe(this.root, { childList: !0, characterData: !0, subtree: !0, attributes: !0 }), this.fragment.observeDeep(this.onFragmentChange);
7189
7189
  }
7190
7190
  scheduleLocalSync() {
7191
7191
  this.pending || (this.pending = !0, queueMicrotask(() => {
7192
- this.pending = !1, !this.destroyed && this.doc.transact(() => bn(this.fragment, this.root), this);
7192
+ this.pending = !1, !this.destroyed && this.doc.transact(() => kn(this.fragment, this.root), this);
7193
7193
  }));
7194
7194
  }
7195
7195
  applyRemoteToDom() {
@@ -7197,7 +7197,7 @@ class ma {
7197
7197
  const t = this.captureSelection();
7198
7198
  this.observer.disconnect(), this.root.dispatchEvent(new CustomEvent("provenance:expect", { detail: { kind: "collaborator", timeoutMs: 1e3 }, bubbles: !0 }));
7199
7199
  try {
7200
- hi(this.root, this.fragment, this.root.ownerDocument), this.root.dispatchEvent(new Event("input", { bubbles: !0, composed: !0 }));
7200
+ di(this.root, this.fragment, this.root.ownerDocument), this.root.dispatchEvent(new Event("input", { bubbles: !0, composed: !0 }));
7201
7201
  } finally {
7202
7202
  this.observer.observe(this.root, { childList: !0, characterData: !0, subtree: !0, attributes: !0 });
7203
7203
  }
@@ -7247,11 +7247,11 @@ class ma {
7247
7247
  this.destroyed = !0, this.observer.disconnect(), this.fragment.unobserveDeep(this.onFragmentChange);
7248
7248
  }
7249
7249
  }
7250
- const Ts = "editora-collaboration-cursor-styles";
7251
- function ya() {
7252
- if (typeof document == "undefined" || document.getElementById(Ts)) return;
7250
+ const xs = "editora-collaboration-cursor-styles";
7251
+ function _a() {
7252
+ if (typeof document == "undefined" || document.getElementById(xs)) return;
7253
7253
  const e = document.createElement("style");
7254
- e.id = Ts, e.textContent = `
7254
+ e.id = xs, e.textContent = `
7255
7255
  .editora-collab-caret {
7256
7256
  position: fixed;
7257
7257
  width: 2px;
@@ -7280,31 +7280,31 @@ function ya() {
7280
7280
  }
7281
7281
  `, document.head.appendChild(e);
7282
7282
  }
7283
- const ba = /^(?:#[0-9a-f]{3,8}|[a-z]{3,20}|(?:rgb|hsl)a?\([\d\s.,%/-]+\))$/i, ka = "#64748b";
7284
- function ui(e) {
7283
+ const Sa = /^(?:#[0-9a-f]{3,8}|[a-z]{3,20}|(?:rgb|hsl)a?\([\d\s.,%/-]+\))$/i, Ca = "#64748b";
7284
+ function fi(e) {
7285
7285
  if (!e || typeof e != "object") return null;
7286
7286
  const { name: t, color: n } = e;
7287
7287
  return typeof t != "string" || t.length === 0 ? null : {
7288
7288
  name: t.slice(0, 64),
7289
- color: typeof n == "string" && ba.test(n.trim()) ? n.trim() : ka
7289
+ color: typeof n == "string" && Sa.test(n.trim()) ? n.trim() : Ca
7290
7290
  };
7291
7291
  }
7292
- function xs(e) {
7292
+ function Is(e) {
7293
7293
  return Array.isArray(e) && e.length <= 256 && e.every((t) => Number.isInteger(t) && t >= 0);
7294
7294
  }
7295
- function _a(e) {
7295
+ function Ea(e) {
7296
7296
  if (!e || typeof e != "object") return null;
7297
7297
  const t = e;
7298
- if (!xs(t.anchorPath)) return null;
7298
+ if (!Is(t.anchorPath)) return null;
7299
7299
  const n = (s) => typeof s == "number" && Number.isFinite(s) && s >= 0 ? Math.floor(s) : 0;
7300
7300
  return {
7301
7301
  anchorPath: t.anchorPath,
7302
7302
  anchorOffset: n(t.anchorOffset),
7303
- focusPath: xs(t.focusPath) ? t.focusPath : void 0,
7303
+ focusPath: Is(t.focusPath) ? t.focusPath : void 0,
7304
7304
  focusOffset: n(t.focusOffset)
7305
7305
  };
7306
7306
  }
7307
- function Is(e, t) {
7307
+ function Ls(e, t) {
7308
7308
  let n = e;
7309
7309
  for (const s of t) {
7310
7310
  const r = n.childNodes[s];
@@ -7313,7 +7313,7 @@ function Is(e, t) {
7313
7313
  }
7314
7314
  return n;
7315
7315
  }
7316
- function Ls(e, t, n) {
7316
+ function vs(e, t, n) {
7317
7317
  if (!e.contains(t)) return null;
7318
7318
  const s = [];
7319
7319
  let r = t;
@@ -7324,9 +7324,9 @@ function Ls(e, t, n) {
7324
7324
  }
7325
7325
  return { path: s, offset: n };
7326
7326
  }
7327
- class Sa {
7327
+ class Da {
7328
7328
  constructor(t, n, s) {
7329
- this.root = t, this.awareness = n, this.user = s, this.caretElements = /* @__PURE__ */ new Map(), this.pendingBroadcast = !1, this.onSelectionChange = () => this.scheduleBroadcast(), this.onAwarenessChange = () => this.renderRemoteCursors(), this.onViewportChange = () => this.renderRemoteCursors(), ya(), this.awareness.setLocalStateField("user", this.user), document.addEventListener("selectionchange", this.onSelectionChange), this.awareness.on("change", this.onAwarenessChange), window.addEventListener("scroll", this.onViewportChange, !0), window.addEventListener("resize", this.onViewportChange);
7329
+ this.root = t, this.awareness = n, this.user = s, this.caretElements = /* @__PURE__ */ new Map(), this.pendingBroadcast = !1, this.onSelectionChange = () => this.scheduleBroadcast(), this.onAwarenessChange = () => this.renderRemoteCursors(), this.onViewportChange = () => this.renderRemoteCursors(), _a(), this.awareness.setLocalStateField("user", this.user), document.addEventListener("selectionchange", this.onSelectionChange), this.awareness.on("change", this.onAwarenessChange), window.addEventListener("scroll", this.onViewportChange, !0), window.addEventListener("resize", this.onViewportChange);
7330
7330
  }
7331
7331
  scheduleBroadcast() {
7332
7332
  this.pendingBroadcast || (this.pendingBroadcast = !0, queueMicrotask(() => {
@@ -7343,7 +7343,7 @@ class Sa {
7343
7343
  this.awareness.setLocalStateField("cursor", null);
7344
7344
  return;
7345
7345
  }
7346
- const n = Ls(this.root, t.anchorNode, t.anchorOffset), s = Ls(this.root, t.focusNode, t.focusOffset);
7346
+ const n = vs(this.root, t.anchorNode, t.anchorOffset), s = vs(this.root, t.focusNode, t.focusOffset);
7347
7347
  if (!n || !s) return;
7348
7348
  const r = {
7349
7349
  anchorPath: n.path,
@@ -7357,7 +7357,7 @@ class Sa {
7357
7357
  const t = this.awareness.getStates(), n = /* @__PURE__ */ new Set();
7358
7358
  t.forEach((s, r) => {
7359
7359
  if (r === this.awareness.clientID) return;
7360
- const i = ui(s == null ? void 0 : s.user), o = _a(s == null ? void 0 : s.cursor);
7360
+ const i = fi(s == null ? void 0 : s.user), o = Ea(s == null ? void 0 : s.cursor);
7361
7361
  if (!i || !o) {
7362
7362
  this.removeCursor(r);
7363
7363
  return;
@@ -7369,7 +7369,7 @@ class Sa {
7369
7369
  }
7370
7370
  renderCursor(t, n, s) {
7371
7371
  var c, l, a;
7372
- const r = Is(this.root, s.anchorPath);
7372
+ const r = Ls(this.root, s.anchorPath);
7373
7373
  if (!r) {
7374
7374
  this.removeCursor(t);
7375
7375
  return;
@@ -7390,7 +7390,7 @@ class Sa {
7390
7390
  h.setStart(r, d), h.setEnd(r, d);
7391
7391
  const u = h.getBoundingClientRect();
7392
7392
  if (i.caret.style.top = `${u.top}px`, i.caret.style.left = `${u.left}px`, i.caret.style.height = `${u.height || 16}px`, s.focusPath) {
7393
- const f = Is(this.root, s.focusPath);
7393
+ const f = Ls(this.root, s.focusPath);
7394
7394
  if (f) {
7395
7395
  const g = Math.min((l = s.focusOffset) != null ? l : 0, ((a = f.textContent) != null ? a : "").length), w = document.createRange();
7396
7396
  w.setStart(r, d), w.setEnd(f, g);
@@ -7412,50 +7412,68 @@ class Sa {
7412
7412
  for (const t of Array.from(this.caretElements.keys())) this.removeCursor(t);
7413
7413
  }
7414
7414
  }
7415
- const Ca = "editora-content", di = "wss://demos.yjs.dev", Ea = "editora-default-room", Os = ["#f97316", "#0ea5e9", "#22c55e", "#a855f7", "#ec4899", "#eab308", "#14b8a6", "#ef4444"], pt = /* @__PURE__ */ new WeakMap(), Qn = /* @__PURE__ */ new Set(), wt = /* @__PURE__ */ new Set(), Le = /* @__PURE__ */ new Map();
7416
- let vs = !1;
7417
- function Da(e) {
7418
- vs || (vs = !0, console.warn(
7419
- `[@editora/collaboration] No websocketUrl was provided, so room "${e}" is syncing through the public demo server (${di}); anyone who knows the room name can read and edit this document. Pass your own y-websocket server via the websocketUrl option (or a provider) for real use.`
7415
+ const Aa = "editora-content", gi = "wss://demos.yjs.dev", Ta = "demos.yjs.dev", xa = "editora-default-room", Os = ["#f97316", "#0ea5e9", "#22c55e", "#a855f7", "#ec4899", "#eab308", "#14b8a6", "#ef4444"], pt = /* @__PURE__ */ new WeakMap(), Zn = /* @__PURE__ */ new Set(), wt = /* @__PURE__ */ new Set(), Le = /* @__PURE__ */ new Map();
7416
+ let Ns = !1, Ms = !1;
7417
+ function Ia(e, t) {
7418
+ Ns || (Ns = !0, console.warn(
7419
+ `[@editora/collaboration] Room "${e}" is syncing through the public demo server (${t}); anyone who knows the room name can read and edit this document. Use it for demos only: pass your own y-websocket server via the websocketUrl option (or a provider) for real use.`
7420
+ ));
7421
+ }
7422
+ function La(e) {
7423
+ try {
7424
+ return new URL(e).hostname === Ta;
7425
+ } catch (t) {
7426
+ return !1;
7427
+ }
7428
+ }
7429
+ function pi(e) {
7430
+ return (typeof e.websocketUrl == "string" ? e.websocketUrl.trim() : "") || void 0;
7431
+ }
7432
+ function va(e) {
7433
+ return e.provider || pi(e) ? !0 : e.allowPublicDemoServer === !0;
7434
+ }
7435
+ function Oa() {
7436
+ Ms || (Ms = !0, console.warn(
7437
+ `[@editora/collaboration] Not connecting: no websocketUrl or provider was configured. This plugin used to fall back to the public Yjs demo server (${gi}), where anyone who knows the room name can read and edit the document, so it now stays off until you pass your own y-websocket server via the websocketUrl option (or a provider). For a throwaway demo only, set allowPublicDemoServer: true.`
7420
7438
  ));
7421
7439
  }
7422
- function Ns() {
7440
+ function Us() {
7423
7441
  const e = Math.floor(Math.random() * 1e4);
7424
7442
  return {
7425
7443
  name: `Guest ${e}`,
7426
7444
  color: Os[e % Os.length]
7427
7445
  };
7428
7446
  }
7429
- let Aa = 1;
7430
- const Et = [], fi = ".rte-content, .editora-content, [contenteditable]";
7431
- let on = null;
7432
- function Ta(e) {
7433
- return e.matches(fi);
7447
+ let Na = 1;
7448
+ const Ct = [], wi = ".rte-content, .editora-content, [contenteditable]";
7449
+ let cn = null;
7450
+ function Ma(e) {
7451
+ return e.matches(wi);
7434
7452
  }
7435
- function xa(e) {
7453
+ function Ua(e) {
7436
7454
  const t = [];
7437
- return e instanceof HTMLElement && Ta(e) && !pt.has(e) && !wt.has(e) && t.push(e), e.querySelectorAll(fi).forEach((n) => {
7455
+ return e instanceof HTMLElement && Ma(e) && !pt.has(e) && !wt.has(e) && t.push(e), e.querySelectorAll(wi).forEach((n) => {
7438
7456
  n instanceof HTMLElement && !pt.has(n) && !wt.has(n) && t.push(n);
7439
7457
  }), t;
7440
7458
  }
7441
- function gi() {
7442
- if (Et.length === 0 || typeof document == "undefined") return;
7443
- const e = xa(document.body);
7459
+ function mi() {
7460
+ if (Ct.length === 0 || typeof document == "undefined") return;
7461
+ const e = Ua(document.body);
7444
7462
  for (const t of e) {
7445
- const n = Et.find((s) => !s.claimed);
7463
+ const n = Ct.find((s) => !s.claimed);
7446
7464
  if (!n) break;
7447
- n.claimed = !0, Na(t, n.options);
7465
+ n.claimed = !0, Va(t, n.options);
7448
7466
  }
7449
- for (; Et.length && Et[0].claimed; ) Et.shift();
7467
+ for (; Ct.length && Ct[0].claimed; ) Ct.shift();
7450
7468
  }
7451
- function Ia() {
7452
- on || typeof document == "undefined" || typeof MutationObserver == "undefined" || (on = new MutationObserver(() => gi()), on.observe(document.body, { childList: !0, subtree: !0 }));
7469
+ function Ra() {
7470
+ cn || typeof document == "undefined" || typeof MutationObserver == "undefined" || (cn = new MutationObserver(() => mi()), cn.observe(document.body, { childList: !0, subtree: !0 }));
7453
7471
  }
7454
- function La(e) {
7455
- const t = { id: Aa++, options: e, claimed: !1 };
7456
- return Et.push(t), Ia(), gi(), t;
7472
+ function $a(e) {
7473
+ const t = { id: Na++, options: e, claimed: !1 };
7474
+ return Ct.push(t), Ra(), mi(), t;
7457
7475
  }
7458
- function Oa() {
7476
+ function Ba() {
7459
7477
  const e = "editora-collaboration-presence-styles";
7460
7478
  if (typeof document == "undefined" || document.getElementById(e)) return;
7461
7479
  const t = document.createElement("style");
@@ -7496,8 +7514,8 @@ function Oa() {
7496
7514
  }
7497
7515
  `, document.head.appendChild(t);
7498
7516
  }
7499
- function va() {
7500
- Oa();
7517
+ function Fa() {
7518
+ Ba();
7501
7519
  const e = document.createElement("div");
7502
7520
  e.className = "editora-collab-presence";
7503
7521
  const t = document.createElement("span");
@@ -7512,35 +7530,35 @@ function pe(e, t, n) {
7512
7530
  if (!r) return;
7513
7531
  r.innerHTML = "", n.getStates().forEach((o, c) => {
7514
7532
  if (c === n.clientID) return;
7515
- const l = ui(o == null ? void 0 : o.user);
7533
+ const l = fi(o == null ? void 0 : o.user);
7516
7534
  if (!l) return;
7517
7535
  const a = document.createElement("span");
7518
7536
  a.className = "editora-collab-presence__avatar", a.style.backgroundColor = l.color, a.title = l.name, a.textContent = Array.from(l.name)[0].toUpperCase(), r.appendChild(a);
7519
7537
  });
7520
7538
  }
7521
- function Na(e, t) {
7522
- var u, f, g, w, p, y, O;
7539
+ function Va(e, t) {
7540
+ var f, g, w, p, y, v, Vt;
7523
7541
  if (pt.has(e) || wt.has(e)) return;
7524
7542
  wt.add(e);
7525
- const n = (g = (f = t.doc) != null ? f : (u = t.provider) == null ? void 0 : u.doc) != null ? g : new yt(), s = !t.doc && !t.provider, r = typeof t.roomName == "function" ? t.roomName(e) : t.roomName || e.id || Ea, i = !t.provider;
7526
- i && !t.websocketUrl && Da(r);
7527
- const o = (p = t.provider) != null ? p : new ea((w = t.websocketUrl) != null ? w : di, r, n), c = {
7528
- name: (y = t.userName) != null ? y : Ns().name,
7529
- color: (O = t.userColor) != null ? O : Ns().color
7530
- }, l = va();
7531
- e.insertAdjacentElement("beforebegin", l), pe(l, "connecting", o.awareness);
7532
- const a = ({ status: kt }) => pe(l, kt, o.awareness), h = () => pe(l, o.wsconnected ? "connected" : "connecting", o.awareness);
7533
- o.on("status", a), o.awareness.on("change", h);
7534
- const d = (kt) => {
7535
- kt && (o.off("sync", d), Le.delete(e), Ma(e, n, o, i, s, c, l, a, h));
7543
+ const n = (w = (g = t.doc) != null ? g : (f = t.provider) == null ? void 0 : f.doc) != null ? w : new yt(), s = !t.doc && !t.provider, r = typeof t.roomName == "function" ? t.roomName(e) : t.roomName || e.id || xa, i = !t.provider, o = (p = pi(t)) != null ? p : gi;
7544
+ i && La(o) && Ia(r, o);
7545
+ const c = (y = t.provider) != null ? y : new ra(o, r, n), l = {
7546
+ name: (v = t.userName) != null ? v : Us().name,
7547
+ color: (Vt = t.userColor) != null ? Vt : Us().color
7548
+ }, a = Fa();
7549
+ e.insertAdjacentElement("beforebegin", a), pe(a, "connecting", c.awareness);
7550
+ const h = ({ status: Je }) => pe(a, Je, c.awareness), d = () => pe(a, c.wsconnected ? "connected" : "connecting", c.awareness);
7551
+ c.on("status", h), c.awareness.on("change", d);
7552
+ const u = (Je) => {
7553
+ Je && (c.off("sync", u), Le.delete(e), ja(e, n, c, i, s, l, a, h, d));
7536
7554
  };
7537
7555
  Le.set(e, () => {
7538
- o.off("sync", d), o.off("status", a), o.awareness.off("change", h), l.remove(), i && o.destroy(), s && n.destroy();
7539
- }), o.synced ? d(!0) : o.on("sync", d);
7556
+ c.off("sync", u), c.off("status", h), c.awareness.off("change", d), a.remove(), i && c.destroy(), s && n.destroy();
7557
+ }), c.synced ? u(!0) : c.on("sync", u);
7540
7558
  }
7541
- function Ma(e, t, n, s, r, i, o, c, l) {
7559
+ function ja(e, t, n, s, r, i, o, c, l) {
7542
7560
  if (wt.delete(e), pt.has(e)) return;
7543
- const a = t.getXmlFragment(Ca), h = new ma(e, t, a), d = new Sa(e, n.awareness, i), u = new Yc(a, { trackedOrigins: /* @__PURE__ */ new Set([h]) });
7561
+ const a = t.getXmlFragment(Aa), h = new ka(e, t, a), d = new Da(e, n.awareness, i), u = new Jc(a, { trackedOrigins: /* @__PURE__ */ new Set([h]) });
7544
7562
  pe(o, n.wsconnected ? "connected" : "connecting", n.awareness);
7545
7563
  const f = (w) => {
7546
7564
  (w.metaKey || w.ctrlKey) && (w.key.toLowerCase() === "z" && !w.shiftKey ? (w.preventDefault(), w.stopImmediatePropagation(), u.undo()) : (w.key.toLowerCase() === "z" && w.shiftKey || w.key.toLowerCase() === "y") && (w.preventDefault(), w.stopImmediatePropagation(), u.redo()));
@@ -7549,31 +7567,38 @@ function Ma(e, t, n, s, r, i, o, c, l) {
7549
7567
  const g = () => {
7550
7568
  e.removeEventListener("keydown", f, { capture: !0 }), n.off("status", c), n.awareness.off("change", l), o.remove(), d.destroy();
7551
7569
  };
7552
- pt.set(e, { doc: t, provider: n, ownsProvider: s, ownsDoc: r, binding: h, undoManager: u, cursorCleanup: g, connectionIndicator: o }), Qn.add(e);
7570
+ pt.set(e, { doc: t, provider: n, ownsProvider: s, ownsDoc: r, binding: h, undoManager: u, cursorCleanup: g, connectionIndicator: o }), Zn.add(e);
7553
7571
  }
7554
- function Ua(e) {
7572
+ function Ha(e) {
7555
7573
  const t = Le.get(e);
7556
7574
  t && (t(), Le.delete(e), wt.delete(e));
7557
7575
  const n = pt.get(e);
7558
- n && (n.cursorCleanup(), n.binding.destroy(), n.undoManager.destroy(), n.ownsProvider && n.provider.destroy(), n.ownsDoc && n.doc.destroy(), pt.delete(e), Qn.delete(e));
7576
+ n && (n.cursorCleanup(), n.binding.destroy(), n.undoManager.destroy(), n.ownsProvider && n.provider.destroy(), n.ownsDoc && n.doc.destroy(), pt.delete(e), Zn.delete(e));
7559
7577
  }
7560
- const $a = (e = {}) => {
7578
+ const Pa = (e = {}) => {
7561
7579
  let t = !1;
7562
7580
  const n = {
7563
7581
  name: "collaboration",
7564
7582
  init: () => {
7565
- var s;
7566
- t || (t = !0, La({ ...e, ...(s = n.__pluginConfig) != null ? s : {} }));
7583
+ var r;
7584
+ if (t) return;
7585
+ t = !0;
7586
+ const s = { ...e, ...(r = n.__pluginConfig) != null ? r : {} };
7587
+ if (!va(s)) {
7588
+ Oa();
7589
+ return;
7590
+ }
7591
+ $a(s);
7567
7592
  },
7568
7593
  commands: {},
7569
7594
  destroy: () => {
7570
- const s = /* @__PURE__ */ new Set([...Qn, ...wt]);
7571
- Array.from(s).forEach((r) => Ua(r));
7595
+ const s = /* @__PURE__ */ new Set([...Zn, ...wt]);
7596
+ Array.from(s).forEach((r) => Ha(r));
7572
7597
  }
7573
7598
  };
7574
7599
  return n;
7575
7600
  };
7576
7601
  export {
7577
- $a as CollaborationPlugin
7602
+ Pa as CollaborationPlugin
7578
7603
  };
7579
- //# sourceMappingURL=CollaborationPlugin.native-B2AsCMfm.mjs.map
7604
+ //# sourceMappingURL=CollaborationPlugin.native-B9aiC2s7.mjs.map