playhtml 2.0.4 → 2.0.5

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,41 +1,87 @@
1
- var li = Object.defineProperty;
2
- var hi = (t, e, s) => e in t ? li(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
- var b = (t, e, s) => (hi(t, typeof e != "symbol" ? e + "" : e, s), s);
4
- const O = () => /* @__PURE__ */ new Map(), Nt = (t) => {
1
+ var di = Object.defineProperty;
2
+ var fi = (t, e, s) => e in t ? di(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
3
+ var b = (t, e, s) => (fi(t, typeof e != "symbol" ? e + "" : e, s), s);
4
+ const O = () => /* @__PURE__ */ new Map(), Rt = (t) => {
5
5
  const e = O();
6
6
  return t.forEach((s, n) => {
7
7
  e.set(n, s);
8
8
  }), e;
9
- }, G = (t, e, s) => {
9
+ }, W = (t, e, s) => {
10
10
  let n = t.get(e);
11
11
  return n === void 0 && t.set(e, n = s()), n;
12
- }, ui = (t, e) => {
12
+ }, gi = (t, e) => {
13
13
  const s = [];
14
14
  for (const [n, i] of t)
15
15
  s.push(e(i, n));
16
16
  return s;
17
- }, di = (t, e) => {
17
+ }, pi = (t, e) => {
18
18
  for (const [s, n] of t)
19
19
  if (e(n, s))
20
20
  return !0;
21
21
  return !1;
22
- }, le = () => /* @__PURE__ */ new Set(), Et = (t) => t[t.length - 1], fi = (t, e) => {
22
+ }, le = () => /* @__PURE__ */ new Set(), Et = (t) => t[t.length - 1], ki = (t, e) => {
23
23
  for (let s = 0; s < e.length; s++)
24
24
  t.push(e[s]);
25
- }, se = Array.from, gi = Array.isArray, pi = String.fromCharCode, ki = (t) => t.toLowerCase(), mi = /^\s*/g, bi = (t) => t.replace(mi, ""), wi = /([A-Z])/g, Ss = (t, e) => bi(t.replace(wi, (s) => `${e}${ki(s)}`)), yi = (t) => {
25
+ }, se = Array.from, mi = Array.isArray;
26
+ class pt {
27
+ constructor() {
28
+ this._observers = O();
29
+ }
30
+ /**
31
+ * @param {N} name
32
+ * @param {function} f
33
+ */
34
+ on(e, s) {
35
+ W(this._observers, e, le).add(s);
36
+ }
37
+ /**
38
+ * @param {N} name
39
+ * @param {function} f
40
+ */
41
+ once(e, s) {
42
+ const n = (...i) => {
43
+ this.off(e, n), s(...i);
44
+ };
45
+ this.on(e, n);
46
+ }
47
+ /**
48
+ * @param {N} name
49
+ * @param {function} f
50
+ */
51
+ off(e, s) {
52
+ const n = this._observers.get(e);
53
+ n !== void 0 && (n.delete(s), n.size === 0 && this._observers.delete(e));
54
+ }
55
+ /**
56
+ * Emit a named event. All registered event listeners that listen to the
57
+ * specified name will receive the event.
58
+ *
59
+ * @todo This should catch exceptions
60
+ *
61
+ * @param {N} name The event name.
62
+ * @param {Array<any>} args The arguments that are applied to the event listener.
63
+ */
64
+ emit(e, s) {
65
+ return se((this._observers.get(e) || O()).values()).forEach((n) => n(...s));
66
+ }
67
+ destroy() {
68
+ this._observers = O();
69
+ }
70
+ }
71
+ const X = Math.floor, st = Math.abs, Wt = (t, e) => t < e ? t : e, pe = (t, e) => t > e ? t : e, bi = Math.pow, Ws = (t) => t !== 0 ? t < 0 : 1 / t < 0, wi = String.fromCharCode, yi = (t) => t.toLowerCase(), _i = /^\s*/g, Si = (t) => t.replace(_i, ""), Di = /([A-Z])/g, Es = (t, e) => Si(t.replace(Di, (s) => `${e}${yi(s)}`)), Ei = (t) => {
26
72
  const e = unescape(encodeURIComponent(t)), s = e.length, n = new Uint8Array(s);
27
73
  for (let i = 0; i < s; i++)
28
74
  n[i] = /** @type {number} */
29
75
  e.codePointAt(i);
30
76
  return n;
31
- }, Be = (
77
+ }, Ne = (
32
78
  /** @type {TextEncoder} */
33
79
  typeof TextEncoder < "u" ? new TextEncoder() : null
34
- ), _i = (t) => Be.encode(t), Si = Be ? _i : yi;
35
- let Oe = typeof TextDecoder > "u" ? null : new TextDecoder("utf-8", { fatal: !0, ignoreBOM: !0 });
36
- Oe && Oe.decode(new Uint8Array()).length === 1 && (Oe = null);
37
- const Ds = (t) => t === void 0 ? null : t;
38
- class Di {
80
+ ), Ci = (t) => Ne.encode(t), vi = Ne ? Ci : Ei;
81
+ let ze = typeof TextDecoder > "u" ? null : new TextDecoder("utf-8", { fatal: !0, ignoreBOM: !0 });
82
+ ze && ze.decode(new Uint8Array()).length === 1 && (ze = null);
83
+ const Cs = (t) => t === void 0 ? null : t;
84
+ class xi {
39
85
  constructor() {
40
86
  this.map = /* @__PURE__ */ new Map();
41
87
  }
@@ -53,46 +99,46 @@ class Di {
53
99
  return this.map.get(e);
54
100
  }
55
101
  }
56
- let Js = new Di(), Gt = !0;
102
+ let Ps = new xi(), Pt = !0;
57
103
  try {
58
- typeof localStorage < "u" && (Js = localStorage, Gt = !1);
104
+ typeof localStorage < "u" && (Ps = localStorage, Pt = !1);
59
105
  } catch {
60
106
  }
61
- const Xs = Js, Ci = (t) => Gt || addEventListener(
107
+ const Qs = Ps, Ai = (t) => Pt || addEventListener(
62
108
  "storage",
63
109
  /** @type {any} */
64
110
  t
65
- ), Ei = (t) => Gt || removeEventListener(
111
+ ), Ii = (t) => Pt || removeEventListener(
66
112
  "storage",
67
113
  /** @type {any} */
68
114
  t
69
- ), vi = Object.assign, xi = Object.keys, Ai = (t, e) => {
115
+ ), Li = Object.assign, ji = Object.keys, Mi = (t, e) => {
70
116
  for (const s in t)
71
117
  e(t[s], s);
72
- }, Ii = (t, e) => {
118
+ }, Ti = (t, e) => {
73
119
  const s = [];
74
120
  for (const n in t)
75
121
  s.push(e(t[n], n));
76
122
  return s;
77
- }, ct = (t) => xi(t).length, Li = (t) => {
123
+ }, ot = (t) => ji(t).length, Ui = (t) => {
78
124
  for (const e in t)
79
125
  return !1;
80
126
  return !0;
81
- }, ji = (t, e) => {
127
+ }, zi = (t, e) => {
82
128
  for (const s in t)
83
129
  if (!e(t[s], s))
84
130
  return !1;
85
131
  return !0;
86
- }, Gs = (t, e) => Object.prototype.hasOwnProperty.call(t, e), Mi = (t, e) => t === e || ct(t) === ct(e) && ji(t, (s, n) => (s !== void 0 || Gs(e, n)) && e[n] === s), Wt = (t, e, s = 0) => {
132
+ }, Zs = (t, e) => Object.prototype.hasOwnProperty.call(t, e), Oi = (t, e) => t === e || ot(t) === ot(e) && zi(t, (s, n) => (s !== void 0 || Zs(e, n)) && e[n] === s), Qt = (t, e, s = 0) => {
87
133
  try {
88
134
  for (; s < t.length; s++)
89
135
  t[s](...e);
90
136
  } finally {
91
- s < t.length && Wt(t, e, s + 1);
137
+ s < t.length && Qt(t, e, s + 1);
92
138
  }
93
- }, Ui = (t) => t, Ti = (t, e) => t === e, Re = (t, e) => {
139
+ }, Ri = (t) => t, Ni = (t, e) => t === e, Oe = (t, e) => {
94
140
  if (t == null || e == null)
95
- return Ti(t, e);
141
+ return Ni(t, e);
96
142
  if (t.constructor !== e.constructor)
97
143
  return !1;
98
144
  if (t === e)
@@ -120,31 +166,31 @@ const Xs = Js, Ci = (t) => Gt || addEventListener(
120
166
  if (t.size !== e.size)
121
167
  return !1;
122
168
  for (const s of t.keys())
123
- if (!e.has(s) || !Re(t.get(s), e.get(s)))
169
+ if (!e.has(s) || !Oe(t.get(s), e.get(s)))
124
170
  return !1;
125
171
  break;
126
172
  }
127
173
  case Object:
128
- if (ct(t) !== ct(e))
174
+ if (ot(t) !== ot(e))
129
175
  return !1;
130
176
  for (const s in t)
131
- if (!Gs(t, s) || !Re(t[s], e[s]))
177
+ if (!Zs(t, s) || !Oe(t[s], e[s]))
132
178
  return !1;
133
179
  break;
134
180
  case Array:
135
181
  if (t.length !== e.length)
136
182
  return !1;
137
183
  for (let s = 0; s < t.length; s++)
138
- if (!Re(t[s], e[s]))
184
+ if (!Oe(t[s], e[s]))
139
185
  return !1;
140
186
  break;
141
187
  default:
142
188
  return !1;
143
189
  }
144
190
  return !0;
145
- }, zi = (t, e) => e.includes(t), De = typeof process < "u" && process.release && /node|io\.js/.test(process.release.name), Ws = typeof window < "u" && typeof document < "u" && !De;
191
+ }, Bi = (t, e) => e.includes(t), De = typeof process < "u" && process.release && /node|io\.js/.test(process.release.name), en = typeof window < "u" && typeof document < "u" && !De;
146
192
  let R;
147
- const Oi = () => {
193
+ const Fi = () => {
148
194
  if (R === void 0)
149
195
  if (De) {
150
196
  R = O();
@@ -159,184 +205,18 @@ const Oi = () => {
159
205
  typeof location == "object" ? (R = O(), (location.search || "?").slice(1).split("&").forEach((t) => {
160
206
  if (t.length !== 0) {
161
207
  const [e, s] = t.split("=");
162
- R.set(`--${Ss(e, "-")}`, s), R.set(`-${Ss(e, "-")}`, s);
208
+ R.set(`--${Es(e, "-")}`, s), R.set(`-${Es(e, "-")}`, s);
163
209
  }
164
210
  })) : R = O();
165
211
  return R;
166
- }, Bt = (t) => Oi().has(t), Ft = (t) => Ds(De ? process.env[t.toUpperCase()] : Xs.getItem(t)), Ri = (t) => Bt("--" + t) || Ft(t) !== null;
167
- Ri("production");
168
- const Cs = De && zi(process.env.FORCE_COLOR, ["true", "1", "2"]), Ni = !Bt("no-colors") && (!De || process.stdout.isTTY || Cs) && (!De || Bt("color") || Cs || Ft("COLORTERM") !== null || (Ft("TERM") || "").includes("color")), J = Math.floor, nt = Math.abs, Pt = (t, e) => t < e ? t : e, pe = (t, e) => t > e ? t : e, Bi = Math.pow, Ps = (t) => t !== 0 ? t < 0 : 1 / t < 0, Es = 1, vs = 2, vt = 4, xt = 8, Fe = 32, K = 64, U = 128, kt = 31, Ht = 63, ce = 127, Fi = 2147483647, Qs = Number.MAX_SAFE_INTEGER, Hi = Number.isInteger || ((t) => typeof t == "number" && isFinite(t) && J(t) === t);
169
- class Je {
170
- constructor() {
171
- this.cpos = 0, this.cbuf = new Uint8Array(100), this.bufs = [];
172
- }
173
- }
174
- const I = () => new Je(), Qt = (t) => {
175
- let e = t.cpos;
176
- for (let s = 0; s < t.bufs.length; s++)
177
- e += t.bufs[s].length;
178
- return e;
179
- }, _ = (t) => {
180
- const e = new Uint8Array(Qt(t));
181
- let s = 0;
182
- for (let n = 0; n < t.bufs.length; n++) {
183
- const i = t.bufs[n];
184
- e.set(i, s), s += i.length;
185
- }
186
- return e.set(ns(t.cbuf.buffer, 0, t.cpos), s), e;
187
- }, Vi = (t, e) => {
188
- const s = t.cbuf.length;
189
- s - t.cpos < e && (t.bufs.push(ns(t.cbuf.buffer, 0, t.cpos)), t.cbuf = new Uint8Array(pe(s, e) * 2), t.cpos = 0);
190
- }, E = (t, e) => {
191
- const s = t.cbuf.length;
192
- t.cpos === s && (t.bufs.push(t.cbuf), t.cbuf = new Uint8Array(s * 2), t.cpos = 0), t.cbuf[t.cpos++] = e;
193
- }, Vt = E, p = (t, e) => {
194
- for (; e > ce; )
195
- E(t, U | ce & e), e = J(e / 128);
196
- E(t, ce & e);
197
- }, Zt = (t, e) => {
198
- const s = Ps(e);
199
- for (s && (e = -e), E(t, (e > Ht ? U : 0) | (s ? K : 0) | Ht & e), e = J(e / 64); e > 0; )
200
- E(t, (e > ce ? U : 0) | ce & e), e = J(e / 128);
201
- }, $t = new Uint8Array(3e4), $i = $t.length / 3, qi = (t, e) => {
202
- if (e.length < $i) {
203
- const s = Be.encodeInto(e, $t).written || 0;
204
- p(t, s);
205
- for (let n = 0; n < s; n++)
206
- E(t, $t[n]);
207
- } else
208
- S(t, Si(e));
209
- }, Ki = (t, e) => {
210
- const s = unescape(encodeURIComponent(e)), n = s.length;
211
- p(t, n);
212
- for (let i = 0; i < n; i++)
213
- E(
214
- t,
215
- /** @type {number} */
216
- s.codePointAt(i)
217
- );
218
- }, ae = Be && /** @type {any} */
219
- Be.encodeInto ? qi : Ki, mt = (t, e) => {
220
- const s = t.cbuf.length, n = t.cpos, i = Pt(s - n, e.length), r = e.length - i;
221
- t.cbuf.set(e.subarray(0, i), n), t.cpos += i, r > 0 && (t.bufs.push(t.cbuf), t.cbuf = new Uint8Array(pe(s * 2, r)), t.cbuf.set(e.subarray(i)), t.cpos = r);
222
- }, S = (t, e) => {
223
- p(t, e.byteLength), mt(t, e);
224
- }, es = (t, e) => {
225
- Vi(t, e);
226
- const s = new DataView(t.cbuf.buffer, t.cpos, e);
227
- return t.cpos += e, s;
228
- }, Yi = (t, e) => es(t, 4).setFloat32(0, e, !1), Ji = (t, e) => es(t, 8).setFloat64(0, e, !1), Xi = (t, e) => (
229
- /** @type {any} */
230
- es(t, 8).setBigInt64(0, e, !1)
231
- ), xs = new DataView(new ArrayBuffer(4)), Gi = (t) => (xs.setFloat32(0, t), xs.getFloat32(0) === t), He = (t, e) => {
232
- switch (typeof e) {
233
- case "string":
234
- E(t, 119), ae(t, e);
235
- break;
236
- case "number":
237
- Hi(e) && nt(e) <= Fi ? (E(t, 125), Zt(t, e)) : Gi(e) ? (E(t, 124), Yi(t, e)) : (E(t, 123), Ji(t, e));
238
- break;
239
- case "bigint":
240
- E(t, 122), Xi(t, e);
241
- break;
242
- case "object":
243
- if (e === null)
244
- E(t, 126);
245
- else if (gi(e)) {
246
- E(t, 117), p(t, e.length);
247
- for (let s = 0; s < e.length; s++)
248
- He(t, e[s]);
249
- } else if (e instanceof Uint8Array)
250
- E(t, 116), S(t, e);
251
- else {
252
- E(t, 118);
253
- const s = Object.keys(e);
254
- p(t, s.length);
255
- for (let n = 0; n < s.length; n++) {
256
- const i = s[n];
257
- ae(t, i), He(t, e[i]);
258
- }
259
- }
260
- break;
261
- case "boolean":
262
- E(t, e ? 120 : 121);
263
- break;
264
- default:
265
- E(t, 127);
266
- }
267
- };
268
- class As extends Je {
269
- /**
270
- * @param {function(Encoder, T):void} writer
271
- */
272
- constructor(e) {
273
- super(), this.w = e, this.s = null, this.count = 0;
274
- }
275
- /**
276
- * @param {T} v
277
- */
278
- write(e) {
279
- this.s === e ? this.count++ : (this.count > 0 && p(this, this.count - 1), this.count = 1, this.w(this, e), this.s = e);
280
- }
281
- }
282
- const Is = (t) => {
283
- t.count > 0 && (Zt(t.encoder, t.count === 1 ? t.s : -t.s), t.count > 1 && p(t.encoder, t.count - 2));
284
- };
285
- class it {
286
- constructor() {
287
- this.encoder = new Je(), this.s = 0, this.count = 0;
288
- }
289
- /**
290
- * @param {number} v
291
- */
292
- write(e) {
293
- this.s === e ? this.count++ : (Is(this), this.count = 1, this.s = e);
294
- }
295
- toUint8Array() {
296
- return Is(this), _(this.encoder);
297
- }
298
- }
299
- const Ls = (t) => {
300
- if (t.count > 0) {
301
- const e = t.diff * 2 + (t.count === 1 ? 0 : 1);
302
- Zt(t.encoder, e), t.count > 1 && p(t.encoder, t.count - 2);
303
- }
304
- };
305
- class At {
306
- constructor() {
307
- this.encoder = new Je(), this.s = 0, this.count = 0, this.diff = 0;
308
- }
309
- /**
310
- * @param {number} v
311
- */
312
- write(e) {
313
- this.diff === e - this.s ? (this.s = e, this.count++) : (Ls(this), this.count = 1, this.diff = e - this.s, this.s = e);
314
- }
315
- toUint8Array() {
316
- return Ls(this), _(this.encoder);
317
- }
318
- }
319
- class Wi {
320
- constructor() {
321
- this.sarr = [], this.s = "", this.lensE = new it();
322
- }
323
- /**
324
- * @param {string} string
325
- */
326
- write(e) {
327
- this.s += e, this.s.length > 19 && (this.sarr.push(this.s), this.s = ""), this.lensE.write(e.length);
328
- }
329
- toUint8Array() {
330
- const e = new Je();
331
- return this.sarr.push(this.s), this.s = "", ae(e, this.sarr.join("")), mt(e, this.lensE.toUint8Array()), _(e);
332
- }
333
- }
334
- const X = (t) => new Error(t), N = () => {
335
- throw X("Method unimplemented");
336
- }, F = () => {
337
- throw X("Unexpected case");
338
- }, Zs = X("Unexpected end of array"), en = X("Integer out of Range");
339
- class bt {
212
+ }, Nt = (t) => Fi().has(t), Bt = (t) => Cs(De ? process.env[t.toUpperCase()] : Qs.getItem(t)), Hi = (t) => Nt("--" + t) || Bt(t) !== null;
213
+ Hi("production");
214
+ const vs = De && Bi(process.env.FORCE_COLOR, ["true", "1", "2"]), Vi = !Nt("no-colors") && (!De || process.stdout.isTTY || vs) && (!De || Nt("color") || vs || Bt("COLORTERM") !== null || (Bt("TERM") || "").includes("color")), xs = 1, As = 2, Ct = 4, vt = 8, Be = 32, Y = 64, T = 128, kt = 31, Ft = 63, ce = 127, $i = 2147483647, tn = Number.MAX_SAFE_INTEGER, qi = Number.isInteger || ((t) => typeof t == "number" && isFinite(t) && X(t) === t), G = (t) => new Error(t), N = () => {
215
+ throw G("Method unimplemented");
216
+ }, H = () => {
217
+ throw G("Unexpected case");
218
+ }, sn = G("Unexpected end of array"), nn = G("Integer out of Range");
219
+ class mt {
340
220
  /**
341
221
  * @param {Uint8Array} uint8Array Binary data to decode
342
222
  */
@@ -344,42 +224,42 @@ class bt {
344
224
  this.arr = e, this.pos = 0;
345
225
  }
346
226
  }
347
- const ie = (t) => new bt(t), Pi = (t) => t.pos !== t.arr.length, Qi = (t, e) => {
348
- const s = ns(t.arr.buffer, t.pos + t.arr.byteOffset, e);
227
+ const ie = (t) => new mt(t), Ki = (t) => t.pos !== t.arr.length, Yi = (t, e) => {
228
+ const s = ts(t.arr.buffer, t.pos + t.arr.byteOffset, e);
349
229
  return t.pos += e, s;
350
- }, A = (t) => Qi(t, k(t)), Ce = (t) => t.arr[t.pos++], k = (t) => {
230
+ }, A = (t) => Yi(t, k(t)), Ee = (t) => t.arr[t.pos++], k = (t) => {
351
231
  let e = 0, s = 1;
352
232
  const n = t.arr.length;
353
233
  for (; t.pos < n; ) {
354
234
  const i = t.arr[t.pos++];
355
- if (e = e + (i & ce) * s, s *= 128, i < U)
235
+ if (e = e + (i & ce) * s, s *= 128, i < T)
356
236
  return e;
357
- if (e > Qs)
358
- throw en;
359
- }
360
- throw Zs;
361
- }, ts = (t) => {
362
- let e = t.arr[t.pos++], s = e & Ht, n = 64;
363
- const i = (e & K) > 0 ? -1 : 1;
364
- if (!(e & U))
237
+ if (e > tn)
238
+ throw nn;
239
+ }
240
+ throw sn;
241
+ }, Zt = (t) => {
242
+ let e = t.arr[t.pos++], s = e & Ft, n = 64;
243
+ const i = (e & Y) > 0 ? -1 : 1;
244
+ if (!(e & T))
365
245
  return i * s;
366
246
  const r = t.arr.length;
367
247
  for (; t.pos < r; ) {
368
- if (e = t.arr[t.pos++], s = s + (e & ce) * n, n *= 128, e < U)
248
+ if (e = t.arr[t.pos++], s = s + (e & ce) * n, n *= 128, e < T)
369
249
  return i * s;
370
- if (s > Qs)
371
- throw en;
250
+ if (s > tn)
251
+ throw nn;
372
252
  }
373
- throw Zs;
374
- }, Zi = (t) => {
253
+ throw sn;
254
+ }, Ji = (t) => {
375
255
  let e = k(t);
376
256
  if (e === 0)
377
257
  return "";
378
258
  {
379
- let s = String.fromCodePoint(Ce(t));
259
+ let s = String.fromCodePoint(Ee(t));
380
260
  if (--e < 100)
381
261
  for (; e--; )
382
- s += String.fromCodePoint(Ce(t));
262
+ s += String.fromCodePoint(Ee(t));
383
263
  else
384
264
  for (; e > 0; ) {
385
265
  const n = e < 1e4 ? e : 1e4, i = t.arr.subarray(t.pos, t.pos + n);
@@ -391,53 +271,53 @@ const ie = (t) => new bt(t), Pi = (t) => t.pos !== t.arr.length, Qi = (t, e) =>
391
271
  }
392
272
  return decodeURIComponent(escape(s));
393
273
  }
394
- }, er = (t) => (
274
+ }, Xi = (t) => (
395
275
  /** @type any */
396
- Oe.decode(A(t))
397
- ), ee = Oe ? er : Zi, ss = (t, e) => {
276
+ ze.decode(A(t))
277
+ ), te = ze ? Xi : Ji, es = (t, e) => {
398
278
  const s = new DataView(t.arr.buffer, t.arr.byteOffset + t.pos, e);
399
279
  return t.pos += e, s;
400
- }, tr = (t) => ss(t, 4).getFloat32(0, !1), sr = (t) => ss(t, 8).getFloat64(0, !1), nr = (t) => (
280
+ }, Gi = (t) => es(t, 4).getFloat32(0, !1), Wi = (t) => es(t, 8).getFloat64(0, !1), Pi = (t) => (
401
281
  /** @type {any} */
402
- ss(t, 8).getBigInt64(0, !1)
403
- ), ir = [
282
+ es(t, 8).getBigInt64(0, !1)
283
+ ), Qi = [
404
284
  (t) => {
405
285
  },
406
286
  // CASE 127: undefined
407
287
  (t) => null,
408
288
  // CASE 126: null
409
- ts,
289
+ Zt,
410
290
  // CASE 125: integer
411
- tr,
291
+ Gi,
412
292
  // CASE 124: float32
413
- sr,
293
+ Wi,
414
294
  // CASE 123: float64
415
- nr,
295
+ Pi,
416
296
  // CASE 122: bigint
417
297
  (t) => !1,
418
298
  // CASE 121: boolean (false)
419
299
  (t) => !0,
420
300
  // CASE 120: boolean (true)
421
- ee,
301
+ te,
422
302
  // CASE 119: string
423
303
  (t) => {
424
304
  const e = k(t), s = {};
425
305
  for (let n = 0; n < e; n++) {
426
- const i = ee(t);
427
- s[i] = Ve(t);
306
+ const i = te(t);
307
+ s[i] = Fe(t);
428
308
  }
429
309
  return s;
430
310
  },
431
311
  (t) => {
432
312
  const e = k(t), s = [];
433
313
  for (let n = 0; n < e; n++)
434
- s.push(Ve(t));
314
+ s.push(Fe(t));
435
315
  return s;
436
316
  },
437
317
  A
438
318
  // CASE 116: Uint8Array
439
- ], Ve = (t) => ir[127 - Ce(t)](t);
440
- class js extends bt {
319
+ ], Fe = (t) => Qi[127 - Ee(t)](t);
320
+ class Is extends mt {
441
321
  /**
442
322
  * @param {Uint8Array} uint8Array
443
323
  * @param {function(Decoder):T} reader
@@ -446,11 +326,11 @@ class js extends bt {
446
326
  super(e), this.reader = s, this.s = null, this.count = 0;
447
327
  }
448
328
  read() {
449
- return this.count === 0 && (this.s = this.reader(this), Pi(this) ? this.count = k(this) + 1 : this.count = -1), this.count--, /** @type {T} */
329
+ return this.count === 0 && (this.s = this.reader(this), Ki(this) ? this.count = k(this) + 1 : this.count = -1), this.count--, /** @type {T} */
450
330
  this.s;
451
331
  }
452
332
  }
453
- class rt extends bt {
333
+ class nt extends mt {
454
334
  /**
455
335
  * @param {Uint8Array} uint8Array
456
336
  */
@@ -459,15 +339,15 @@ class rt extends bt {
459
339
  }
460
340
  read() {
461
341
  if (this.count === 0) {
462
- this.s = ts(this);
463
- const e = Ps(this.s);
342
+ this.s = Zt(this);
343
+ const e = Ws(this.s);
464
344
  this.count = 1, e && (this.s = -this.s, this.count = k(this) + 2);
465
345
  }
466
346
  return this.count--, /** @type {number} */
467
347
  this.s;
468
348
  }
469
349
  }
470
- class It extends bt {
350
+ class xt extends mt {
471
351
  /**
472
352
  * @param {Uint8Array} uint8Array
473
353
  */
@@ -479,18 +359,18 @@ class It extends bt {
479
359
  */
480
360
  read() {
481
361
  if (this.count === 0) {
482
- const e = ts(this), s = e & 1;
483
- this.diff = J(e / 2), this.count = 1, s && (this.count = k(this) + 2);
362
+ const e = Zt(this), s = e & 1;
363
+ this.diff = X(e / 2), this.count = 1, s && (this.count = k(this) + 2);
484
364
  }
485
365
  return this.s += this.diff, this.count--, this.s;
486
366
  }
487
367
  }
488
- class rr {
368
+ class Zi {
489
369
  /**
490
370
  * @param {Uint8Array} uint8Array
491
371
  */
492
372
  constructor(e) {
493
- this.decoder = new rt(e), this.str = ee(this.decoder), this.spos = 0;
373
+ this.decoder = new nt(e), this.str = te(this.decoder), this.spos = 0;
494
374
  }
495
375
  /**
496
376
  * @return {string}
@@ -500,108 +380,198 @@ class rr {
500
380
  return this.spos = e, s;
501
381
  }
502
382
  }
503
- const tn = (t) => new Uint8Array(t), ns = (t, e, s) => new Uint8Array(t, e, s), or = (t) => new Uint8Array(t), cr = (t) => {
383
+ const rn = (t) => new Uint8Array(t), ts = (t, e, s) => new Uint8Array(t, e, s), er = (t) => new Uint8Array(t), tr = (t) => {
504
384
  let e = "";
505
385
  for (let s = 0; s < t.byteLength; s++)
506
- e += pi(t[s]);
386
+ e += wi(t[s]);
507
387
  return btoa(e);
508
- }, ar = (t) => Buffer.from(t.buffer, t.byteOffset, t.byteLength).toString("base64"), lr = (t) => {
509
- const e = atob(t), s = tn(e.length);
388
+ }, sr = (t) => Buffer.from(t.buffer, t.byteOffset, t.byteLength).toString("base64"), nr = (t) => {
389
+ const e = atob(t), s = rn(e.length);
510
390
  for (let n = 0; n < e.length; n++)
511
391
  s[n] = e.charCodeAt(n);
512
392
  return s;
513
- }, hr = (t) => {
393
+ }, ir = (t) => {
514
394
  const e = Buffer.from(t, "base64");
515
395
  return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
516
- }, ur = Ws ? cr : ar, dr = Ws ? lr : hr, fr = (t) => {
517
- const e = tn(t.byteLength);
396
+ }, rr = en ? tr : sr, or = en ? nr : ir, cr = (t) => {
397
+ const e = rn(t.byteLength);
518
398
  return e.set(t), e;
519
- }, sn = /* @__PURE__ */ new Map();
520
- class gr {
399
+ };
400
+ class Ye {
401
+ constructor() {
402
+ this.cpos = 0, this.cbuf = new Uint8Array(100), this.bufs = [];
403
+ }
404
+ }
405
+ const I = () => new Ye(), ss = (t) => {
406
+ let e = t.cpos;
407
+ for (let s = 0; s < t.bufs.length; s++)
408
+ e += t.bufs[s].length;
409
+ return e;
410
+ }, _ = (t) => {
411
+ const e = new Uint8Array(ss(t));
412
+ let s = 0;
413
+ for (let n = 0; n < t.bufs.length; n++) {
414
+ const i = t.bufs[n];
415
+ e.set(i, s), s += i.length;
416
+ }
417
+ return e.set(ts(t.cbuf.buffer, 0, t.cpos), s), e;
418
+ }, ar = (t, e) => {
419
+ const s = t.cbuf.length;
420
+ s - t.cpos < e && (t.bufs.push(ts(t.cbuf.buffer, 0, t.cpos)), t.cbuf = new Uint8Array(pe(s, e) * 2), t.cpos = 0);
421
+ }, C = (t, e) => {
422
+ const s = t.cbuf.length;
423
+ t.cpos === s && (t.bufs.push(t.cbuf), t.cbuf = new Uint8Array(s * 2), t.cpos = 0), t.cbuf[t.cpos++] = e;
424
+ }, Ht = C, p = (t, e) => {
425
+ for (; e > ce; )
426
+ C(t, T | ce & e), e = X(e / 128);
427
+ C(t, ce & e);
428
+ }, ns = (t, e) => {
429
+ const s = Ws(e);
430
+ for (s && (e = -e), C(t, (e > Ft ? T : 0) | (s ? Y : 0) | Ft & e), e = X(e / 64); e > 0; )
431
+ C(t, (e > ce ? T : 0) | ce & e), e = X(e / 128);
432
+ }, Vt = new Uint8Array(3e4), lr = Vt.length / 3, hr = (t, e) => {
433
+ if (e.length < lr) {
434
+ const s = Ne.encodeInto(e, Vt).written || 0;
435
+ p(t, s);
436
+ for (let n = 0; n < s; n++)
437
+ C(t, Vt[n]);
438
+ } else
439
+ S(t, vi(e));
440
+ }, ur = (t, e) => {
441
+ const s = unescape(encodeURIComponent(e)), n = s.length;
442
+ p(t, n);
443
+ for (let i = 0; i < n; i++)
444
+ C(
445
+ t,
446
+ /** @type {number} */
447
+ s.codePointAt(i)
448
+ );
449
+ }, ae = Ne && /** @type {any} */
450
+ Ne.encodeInto ? hr : ur, bt = (t, e) => {
451
+ const s = t.cbuf.length, n = t.cpos, i = Wt(s - n, e.length), r = e.length - i;
452
+ t.cbuf.set(e.subarray(0, i), n), t.cpos += i, r > 0 && (t.bufs.push(t.cbuf), t.cbuf = new Uint8Array(pe(s * 2, r)), t.cbuf.set(e.subarray(i)), t.cpos = r);
453
+ }, S = (t, e) => {
454
+ p(t, e.byteLength), bt(t, e);
455
+ }, is = (t, e) => {
456
+ ar(t, e);
457
+ const s = new DataView(t.cbuf.buffer, t.cpos, e);
458
+ return t.cpos += e, s;
459
+ }, dr = (t, e) => is(t, 4).setFloat32(0, e, !1), fr = (t, e) => is(t, 8).setFloat64(0, e, !1), gr = (t, e) => (
460
+ /** @type {any} */
461
+ is(t, 8).setBigInt64(0, e, !1)
462
+ ), Ls = new DataView(new ArrayBuffer(4)), pr = (t) => (Ls.setFloat32(0, t), Ls.getFloat32(0) === t), He = (t, e) => {
463
+ switch (typeof e) {
464
+ case "string":
465
+ C(t, 119), ae(t, e);
466
+ break;
467
+ case "number":
468
+ qi(e) && st(e) <= $i ? (C(t, 125), ns(t, e)) : pr(e) ? (C(t, 124), dr(t, e)) : (C(t, 123), fr(t, e));
469
+ break;
470
+ case "bigint":
471
+ C(t, 122), gr(t, e);
472
+ break;
473
+ case "object":
474
+ if (e === null)
475
+ C(t, 126);
476
+ else if (mi(e)) {
477
+ C(t, 117), p(t, e.length);
478
+ for (let s = 0; s < e.length; s++)
479
+ He(t, e[s]);
480
+ } else if (e instanceof Uint8Array)
481
+ C(t, 116), S(t, e);
482
+ else {
483
+ C(t, 118);
484
+ const s = Object.keys(e);
485
+ p(t, s.length);
486
+ for (let n = 0; n < s.length; n++) {
487
+ const i = s[n];
488
+ ae(t, i), He(t, e[i]);
489
+ }
490
+ }
491
+ break;
492
+ case "boolean":
493
+ C(t, e ? 120 : 121);
494
+ break;
495
+ default:
496
+ C(t, 127);
497
+ }
498
+ };
499
+ class js extends Ye {
521
500
  /**
522
- * @param {string} room
501
+ * @param {function(Encoder, T):void} writer
523
502
  */
524
503
  constructor(e) {
525
- this.room = e, this.onmessage = null, this._onChange = (s) => s.key === e && this.onmessage !== null && this.onmessage({ data: dr(s.newValue || "") }), Ci(this._onChange);
504
+ super(), this.w = e, this.s = null, this.count = 0;
526
505
  }
527
506
  /**
528
- * @param {ArrayBuffer} buf
507
+ * @param {T} v
529
508
  */
530
- postMessage(e) {
531
- Xs.setItem(this.room, ur(or(e)));
532
- }
533
- close() {
534
- Ei(this._onChange);
509
+ write(e) {
510
+ this.s === e ? this.count++ : (this.count > 0 && p(this, this.count - 1), this.count = 1, this.w(this, e), this.s = e);
535
511
  }
536
512
  }
537
- const pr = typeof BroadcastChannel > "u" ? gr : BroadcastChannel, is = (t) => G(sn, t, () => {
538
- const e = le(), s = new pr(t);
539
- return s.onmessage = (n) => e.forEach((i) => i(n.data, "broadcastchannel")), {
540
- bc: s,
541
- subs: e
542
- };
543
- }), kr = (t, e) => (is(t).subs.add(e), e), mr = (t, e) => {
544
- const s = is(t), n = s.subs.delete(e);
545
- return n && s.subs.size === 0 && (s.bc.close(), sn.delete(t)), n;
546
- }, be = (t, e, s = null) => {
547
- const n = is(t);
548
- n.bc.postMessage(e), n.subs.forEach((i) => i(e, s));
549
- }, he = Date.now;
550
- class wt {
513
+ const Ms = (t) => {
514
+ t.count > 0 && (ns(t.encoder, t.count === 1 ? t.s : -t.s), t.count > 1 && p(t.encoder, t.count - 2));
515
+ };
516
+ class it {
551
517
  constructor() {
552
- this._observers = O();
518
+ this.encoder = new Ye(), this.s = 0, this.count = 0;
553
519
  }
554
520
  /**
555
- * @param {N} name
556
- * @param {function} f
521
+ * @param {number} v
557
522
  */
558
- on(e, s) {
559
- G(this._observers, e, le).add(s);
523
+ write(e) {
524
+ this.s === e ? this.count++ : (Ms(this), this.count = 1, this.s = e);
560
525
  }
561
- /**
562
- * @param {N} name
563
- * @param {function} f
564
- */
565
- once(e, s) {
566
- const n = (...i) => {
567
- this.off(e, n), s(...i);
568
- };
569
- this.on(e, n);
526
+ toUint8Array() {
527
+ return Ms(this), _(this.encoder);
528
+ }
529
+ }
530
+ const Ts = (t) => {
531
+ if (t.count > 0) {
532
+ const e = t.diff * 2 + (t.count === 1 ? 0 : 1);
533
+ ns(t.encoder, e), t.count > 1 && p(t.encoder, t.count - 2);
534
+ }
535
+ };
536
+ class At {
537
+ constructor() {
538
+ this.encoder = new Ye(), this.s = 0, this.count = 0, this.diff = 0;
570
539
  }
571
540
  /**
572
- * @param {N} name
573
- * @param {function} f
541
+ * @param {number} v
574
542
  */
575
- off(e, s) {
576
- const n = this._observers.get(e);
577
- n !== void 0 && (n.delete(s), n.size === 0 && this._observers.delete(e));
543
+ write(e) {
544
+ this.diff === e - this.s ? (this.s = e, this.count++) : (Ts(this), this.count = 1, this.diff = e - this.s, this.s = e);
545
+ }
546
+ toUint8Array() {
547
+ return Ts(this), _(this.encoder);
548
+ }
549
+ }
550
+ class kr {
551
+ constructor() {
552
+ this.sarr = [], this.s = "", this.lensE = new it();
578
553
  }
579
554
  /**
580
- * Emit a named event. All registered event listeners that listen to the
581
- * specified name will receive the event.
582
- *
583
- * @todo This should catch exceptions
584
- *
585
- * @param {N} name The event name.
586
- * @param {Array<any>} args The arguments that are applied to the event listener.
555
+ * @param {string} string
587
556
  */
588
- emit(e, s) {
589
- return se((this._observers.get(e) || O()).values()).forEach((n) => n(...s));
557
+ write(e) {
558
+ this.s += e, this.s.length > 19 && (this.sarr.push(this.s), this.s = ""), this.lensE.write(e.length);
590
559
  }
591
- destroy() {
592
- this._observers = O();
560
+ toUint8Array() {
561
+ const e = new Ye();
562
+ return this.sarr.push(this.s), this.s = "", ae(e, this.sarr.join("")), bt(e, this.lensE.toUint8Array()), _(e);
593
563
  }
594
564
  }
595
- const br = crypto.getRandomValues.bind(crypto), nn = () => br(new Uint32Array(1))[0], wr = [1e7] + -1e3 + -4e3 + -8e3 + -1e11, yr = () => wr.replace(
565
+ const mr = crypto.getRandomValues.bind(crypto), on = () => mr(new Uint32Array(1))[0], br = [1e7] + -1e3 + -4e3 + -8e3 + -1e11, wr = () => br.replace(
596
566
  /[018]/g,
597
567
  /** @param {number} c */
598
- (t) => (t ^ nn() & 15 >> t / 4).toString(16)
599
- ), Ee = (t) => (
568
+ (t) => (t ^ on() & 15 >> t / 4).toString(16)
569
+ ), he = Date.now, Ce = (t) => (
600
570
  /** @type {Promise<T>} */
601
571
  new Promise(t)
602
572
  );
603
573
  Promise.all.bind(Promise);
604
- class _r {
574
+ class yr {
605
575
  /**
606
576
  * @param {L} left
607
577
  * @param {R} right
@@ -610,9 +580,9 @@ class _r {
610
580
  this.left = e, this.right = s;
611
581
  }
612
582
  }
613
- const $ = (t, e) => new _r(t, e);
583
+ const q = (t, e) => new yr(t, e);
614
584
  typeof DOMParser < "u" && new DOMParser();
615
- const Sr = (t) => ui(t, (e, s) => `${s}:${e};`).join(""), W = Symbol, rn = W(), on = W(), Dr = W(), Cr = W(), Er = W(), cn = W(), vr = W(), an = W(), xr = W(), Ar = (t) => {
585
+ const _r = (t) => gi(t, (e, s) => `${s}:${e};`).join(""), P = Symbol, cn = P(), an = P(), Sr = P(), Dr = P(), Er = P(), ln = P(), Cr = P(), hn = P(), vr = P(), xr = (t) => {
616
586
  const e = [];
617
587
  let s = 0;
618
588
  for (; s < t.length; s++) {
@@ -620,26 +590,26 @@ const Sr = (t) => ui(t, (e, s) => `${s}:${e};`).join(""), W = Symbol, rn = W(),
620
590
  n.constructor === String || n.constructor === Number || n.constructor === Object && e.push(JSON.stringify(n));
621
591
  }
622
592
  return e;
623
- }, Ir = {
624
- [rn]: $("font-weight", "bold"),
625
- [on]: $("font-weight", "normal"),
626
- [Dr]: $("color", "blue"),
627
- [Er]: $("color", "green"),
628
- [Cr]: $("color", "grey"),
629
- [cn]: $("color", "red"),
630
- [vr]: $("color", "purple"),
631
- [an]: $("color", "orange"),
593
+ }, Ar = {
594
+ [cn]: q("font-weight", "bold"),
595
+ [an]: q("font-weight", "normal"),
596
+ [Sr]: q("color", "blue"),
597
+ [Er]: q("color", "green"),
598
+ [Dr]: q("color", "grey"),
599
+ [ln]: q("color", "red"),
600
+ [Cr]: q("color", "purple"),
601
+ [hn]: q("color", "orange"),
632
602
  // not well supported in chrome when debugging node with inspector - TODO: deprecate
633
- [xr]: $("color", "black")
634
- }, Lr = (t) => {
603
+ [vr]: q("color", "black")
604
+ }, Ir = (t) => {
635
605
  const e = [], s = [], n = O();
636
606
  let i = [], r = 0;
637
607
  for (; r < t.length; r++) {
638
- const o = t[r], c = Ir[o];
608
+ const o = t[r], c = Ar[o];
639
609
  if (c !== void 0)
640
610
  n.set(c.left, c.right);
641
611
  else if (o.constructor === String || o.constructor === Number) {
642
- const a = Sr(n);
612
+ const a = _r(n);
643
613
  r > 0 || a.length > 0 ? (e.push("%c" + o), s.push(a)) : e.push(o);
644
614
  } else
645
615
  break;
@@ -649,9 +619,9 @@ const Sr = (t) => ui(t, (e, s) => `${s}:${e};`).join(""), W = Symbol, rn = W(),
649
619
  o instanceof Symbol || i.push(o);
650
620
  }
651
621
  return i;
652
- }, jr = Ni ? Lr : Ar, Mr = (...t) => {
653
- console.log(...jr(t)), Ur.forEach((e) => e.print(t));
654
- }, Ur = le(), ln = (t) => ({
622
+ }, Lr = Vi ? Ir : xr, jr = (...t) => {
623
+ console.log(...Lr(t)), Mr.forEach((e) => e.print(t));
624
+ }, Mr = le(), un = (t) => ({
655
625
  /**
656
626
  * @return {IterableIterator<T>}
657
627
  */
@@ -660,13 +630,13 @@ const Sr = (t) => ui(t, (e, s) => `${s}:${e};`).join(""), W = Symbol, rn = W(),
660
630
  },
661
631
  // @ts-ignore
662
632
  next: t
663
- }), Tr = (t, e) => ln(() => {
633
+ }), Tr = (t, e) => un(() => {
664
634
  let s;
665
635
  do
666
636
  s = t.next();
667
637
  while (!s.done && !e(s.value));
668
638
  return s;
669
- }), Lt = (t, e) => ln(() => {
639
+ }), It = (t, e) => un(() => {
670
640
  const { done: s, value: n } = t.next();
671
641
  return { done: s, value: s ? void 0 : e(n) };
672
642
  });
@@ -679,24 +649,24 @@ class rs {
679
649
  this.clock = e, this.len = s;
680
650
  }
681
651
  }
682
- class Xe {
652
+ class Je {
683
653
  constructor() {
684
654
  this.clients = /* @__PURE__ */ new Map();
685
655
  }
686
656
  }
687
- const hn = (t, e, s) => e.clients.forEach((n, i) => {
657
+ const dn = (t, e, s) => e.clients.forEach((n, i) => {
688
658
  const r = (
689
659
  /** @type {Array<GC|Item>} */
690
660
  t.doc.store.clients.get(i)
691
661
  );
692
662
  for (let o = 0; o < n.length; o++) {
693
663
  const c = n[o];
694
- Cn(t, r, c.clock, c.len, s);
664
+ vn(t, r, c.clock, c.len, s);
695
665
  }
696
- }), zr = (t, e) => {
666
+ }), Ur = (t, e) => {
697
667
  let s = 0, n = t.length - 1;
698
668
  for (; s <= n; ) {
699
- const i = J((s + n) / 2), r = t[i], o = r.clock;
669
+ const i = X((s + n) / 2), r = t[i], o = r.clock;
700
670
  if (o <= e) {
701
671
  if (e < o + r.len)
702
672
  return i;
@@ -705,9 +675,9 @@ const hn = (t, e, s) => e.clients.forEach((n, i) => {
705
675
  n = i - 1;
706
676
  }
707
677
  return null;
708
- }, un = (t, e) => {
678
+ }, fn = (t, e) => {
709
679
  const s = t.clients.get(e.client);
710
- return s !== void 0 && zr(s, e.clock) !== null;
680
+ return s !== void 0 && Ur(s, e.clock) !== null;
711
681
  }, os = (t) => {
712
682
  t.clients.forEach((e) => {
713
683
  e.sort((i, r) => i.clock - r.clock);
@@ -718,25 +688,25 @@ const hn = (t, e, s) => e.clients.forEach((n, i) => {
718
688
  }
719
689
  e.length = n;
720
690
  });
721
- }, Or = (t) => {
722
- const e = new Xe();
691
+ }, zr = (t) => {
692
+ const e = new Je();
723
693
  for (let s = 0; s < t.length; s++)
724
694
  t[s].clients.forEach((n, i) => {
725
695
  if (!e.clients.has(i)) {
726
696
  const r = n.slice();
727
697
  for (let o = s + 1; o < t.length; o++)
728
- fi(r, t[o].clients.get(i) || []);
698
+ ki(r, t[o].clients.get(i) || []);
729
699
  e.clients.set(i, r);
730
700
  }
731
701
  });
732
702
  return os(e), e;
733
- }, at = (t, e, s, n) => {
734
- G(t.clients, e, () => (
703
+ }, ct = (t, e, s, n) => {
704
+ W(t.clients, e, () => (
735
705
  /** @type {Array<DeleteItem>} */
736
706
  []
737
707
  )).push(new rs(s, n));
738
- }, Rr = () => new Xe(), Nr = (t) => {
739
- const e = Rr();
708
+ }, Or = () => new Je(), Rr = (t) => {
709
+ const e = Or();
740
710
  return t.clients.forEach((s, n) => {
741
711
  const i = [];
742
712
  for (let r = 0; r < s.length; r++) {
@@ -763,12 +733,12 @@ const hn = (t, e, s) => e.clients.forEach((n, i) => {
763
733
  }
764
734
  });
765
735
  }, cs = (t) => {
766
- const e = new Xe(), s = k(t.restDecoder);
736
+ const e = new Je(), s = k(t.restDecoder);
767
737
  for (let n = 0; n < s; n++) {
768
738
  t.resetDsCurVal();
769
739
  const i = k(t.restDecoder), r = k(t.restDecoder);
770
740
  if (r > 0) {
771
- const o = G(e.clients, i, () => (
741
+ const o = W(e.clients, i, () => (
772
742
  /** @type {Array<DeleteItem>} */
773
743
  []
774
744
  ));
@@ -777,20 +747,20 @@ const hn = (t, e, s) => e.clients.forEach((n, i) => {
777
747
  }
778
748
  }
779
749
  return e;
780
- }, Ms = (t, e, s) => {
781
- const n = new Xe(), i = k(t.restDecoder);
750
+ }, Us = (t, e, s) => {
751
+ const n = new Je(), i = k(t.restDecoder);
782
752
  for (let r = 0; r < i; r++) {
783
753
  t.resetDsCurVal();
784
754
  const o = k(t.restDecoder), c = k(t.restDecoder), a = s.clients.get(o) || [], l = v(s, o);
785
755
  for (let h = 0; h < c; h++) {
786
756
  const u = t.readDsClock(), d = u + t.readDsLen();
787
757
  if (u < l) {
788
- l < d && at(n, o, l, d - l);
789
- let f = H(a, u), g = a[f];
790
- for (!g.deleted && g.id.clock < u && (a.splice(f + 1, 0, pt(e, g, u - g.id.clock)), f++); f < a.length && (g = a[f++], g.id.clock < d); )
791
- g.deleted || (d < g.id.clock + g.length && a.splice(f, 0, pt(e, g, d - g.id.clock)), g.delete(e));
758
+ l < d && ct(n, o, l, d - l);
759
+ let f = V(a, u), g = a[f];
760
+ for (!g.deleted && g.id.clock < u && (a.splice(f + 1, 0, gt(e, g, u - g.id.clock)), f++); f < a.length && (g = a[f++], g.id.clock < d); )
761
+ g.deleted || (d < g.id.clock + g.length && a.splice(f, 0, gt(e, g, d - g.id.clock)), g.delete(e));
792
762
  } else
793
- at(n, o, u, d - u);
763
+ ct(n, o, u, d - u);
794
764
  }
795
765
  }
796
766
  if (n.clients.size > 0) {
@@ -798,18 +768,18 @@ const hn = (t, e, s) => e.clients.forEach((n, i) => {
798
768
  return p(r.restEncoder, 0), Ae(r, n), r.toUint8Array();
799
769
  }
800
770
  return null;
801
- }, dn = nn;
802
- class Ie extends wt {
771
+ }, gn = on;
772
+ class ke extends pt {
803
773
  /**
804
774
  * @param {DocOpts} opts configuration
805
775
  */
806
- constructor({ guid: e = yr(), collectionid: s = null, gc: n = !0, gcFilter: i = () => !0, meta: r = null, autoLoad: o = !1, shouldLoad: c = !0 } = {}) {
807
- super(), this.gc = n, this.gcFilter = i, this.clientID = dn(), this.guid = e, this.collectionid = s, this.share = /* @__PURE__ */ new Map(), this.store = new Sn(), this._transaction = null, this._transactionCleanups = [], this.subdocs = /* @__PURE__ */ new Set(), this._item = null, this.shouldLoad = c, this.autoLoad = o, this.meta = r, this.isLoaded = !1, this.isSynced = !1, this.whenLoaded = Ee((l) => {
776
+ constructor({ guid: e = wr(), collectionid: s = null, gc: n = !0, gcFilter: i = () => !0, meta: r = null, autoLoad: o = !1, shouldLoad: c = !0 } = {}) {
777
+ super(), this.gc = n, this.gcFilter = i, this.clientID = gn(), this.guid = e, this.collectionid = s, this.share = /* @__PURE__ */ new Map(), this.store = new En(), this._transaction = null, this._transactionCleanups = [], this.subdocs = /* @__PURE__ */ new Set(), this._item = null, this.shouldLoad = c, this.autoLoad = o, this.meta = r, this.isLoaded = !1, this.isSynced = !1, this.whenLoaded = Ce((l) => {
808
778
  this.on("load", () => {
809
779
  this.isLoaded = !0, l(this);
810
780
  });
811
781
  });
812
- const a = () => Ee((l) => {
782
+ const a = () => Ce((l) => {
813
783
  const h = (u) => {
814
784
  (u === void 0 || u === !0) && (this.off("sync", h), l());
815
785
  };
@@ -887,7 +857,7 @@ class Ie extends wt {
887
857
  * @public
888
858
  */
889
859
  get(e, s = x) {
890
- const n = G(this.share, e, () => {
860
+ const n = W(this.share, e, () => {
891
861
  const r = new s();
892
862
  return r._integrate(this, null), r;
893
863
  }), i = n.constructor;
@@ -916,7 +886,7 @@ class Ie extends wt {
916
886
  * @public
917
887
  */
918
888
  getArray(e = "") {
919
- return this.get(e, ye);
889
+ return this.get(e, _e);
920
890
  }
921
891
  /**
922
892
  * @param {string} [name]
@@ -972,7 +942,7 @@ class Ie extends wt {
972
942
  /** @type {ContentDoc} */
973
943
  e.content
974
944
  );
975
- s.doc = new Ie({ guid: this.guid, ...s.opts, shouldLoad: !1 }), s.doc._item = e, y(
945
+ s.doc = new ke({ guid: this.guid, ...s.opts, shouldLoad: !1 }), s.doc._item = e, y(
976
946
  /** @type {any} */
977
947
  e.parent.doc,
978
948
  (n) => {
@@ -1000,7 +970,7 @@ class Ie extends wt {
1000
970
  super.off(e, s);
1001
971
  }
1002
972
  }
1003
- class fn {
973
+ class pn {
1004
974
  /**
1005
975
  * @param {decoding.Decoder} decoder
1006
976
  */
@@ -1022,7 +992,7 @@ class fn {
1022
992
  return k(this.restDecoder);
1023
993
  }
1024
994
  }
1025
- class gn extends fn {
995
+ class kn extends pn {
1026
996
  /**
1027
997
  * @return {ID}
1028
998
  */
@@ -1046,13 +1016,13 @@ class gn extends fn {
1046
1016
  * @return {number} info An unsigned 8-bit integer
1047
1017
  */
1048
1018
  readInfo() {
1049
- return Ce(this.restDecoder);
1019
+ return Ee(this.restDecoder);
1050
1020
  }
1051
1021
  /**
1052
1022
  * @return {string}
1053
1023
  */
1054
1024
  readString() {
1055
- return ee(this.restDecoder);
1025
+ return te(this.restDecoder);
1056
1026
  }
1057
1027
  /**
1058
1028
  * @return {boolean} isKey
@@ -1078,13 +1048,13 @@ class gn extends fn {
1078
1048
  * @return {any}
1079
1049
  */
1080
1050
  readAny() {
1081
- return Ve(this.restDecoder);
1051
+ return Fe(this.restDecoder);
1082
1052
  }
1083
1053
  /**
1084
1054
  * @return {Uint8Array}
1085
1055
  */
1086
1056
  readBuf() {
1087
- return fr(A(this.restDecoder));
1057
+ return cr(A(this.restDecoder));
1088
1058
  }
1089
1059
  /**
1090
1060
  * Legacy implementation uses JSON parse. We use any-decoding in v2.
@@ -1092,16 +1062,16 @@ class gn extends fn {
1092
1062
  * @return {any}
1093
1063
  */
1094
1064
  readJSON() {
1095
- return JSON.parse(ee(this.restDecoder));
1065
+ return JSON.parse(te(this.restDecoder));
1096
1066
  }
1097
1067
  /**
1098
1068
  * @return {string}
1099
1069
  */
1100
1070
  readKey() {
1101
- return ee(this.restDecoder);
1071
+ return te(this.restDecoder);
1102
1072
  }
1103
1073
  }
1104
- class Br {
1074
+ class Nr {
1105
1075
  /**
1106
1076
  * @param {decoding.Decoder} decoder
1107
1077
  */
@@ -1125,24 +1095,24 @@ class Br {
1125
1095
  return this.dsCurrVal += e, e;
1126
1096
  }
1127
1097
  }
1128
- class ve extends Br {
1098
+ class ve extends Nr {
1129
1099
  /**
1130
1100
  * @param {decoding.Decoder} decoder
1131
1101
  */
1132
1102
  constructor(e) {
1133
- super(e), this.keys = [], k(e), this.keyClockDecoder = new It(A(e)), this.clientDecoder = new rt(A(e)), this.leftClockDecoder = new It(A(e)), this.rightClockDecoder = new It(A(e)), this.infoDecoder = new js(A(e), Ce), this.stringDecoder = new rr(A(e)), this.parentInfoDecoder = new js(A(e), Ce), this.typeRefDecoder = new rt(A(e)), this.lenDecoder = new rt(A(e));
1103
+ super(e), this.keys = [], k(e), this.keyClockDecoder = new xt(A(e)), this.clientDecoder = new nt(A(e)), this.leftClockDecoder = new xt(A(e)), this.rightClockDecoder = new xt(A(e)), this.infoDecoder = new Is(A(e), Ee), this.stringDecoder = new Zi(A(e)), this.parentInfoDecoder = new Is(A(e), Ee), this.typeRefDecoder = new nt(A(e)), this.lenDecoder = new nt(A(e));
1134
1104
  }
1135
1105
  /**
1136
1106
  * @return {ID}
1137
1107
  */
1138
1108
  readLeftID() {
1139
- return new we(this.clientDecoder.read(), this.leftClockDecoder.read());
1109
+ return new ye(this.clientDecoder.read(), this.leftClockDecoder.read());
1140
1110
  }
1141
1111
  /**
1142
1112
  * @return {ID}
1143
1113
  */
1144
1114
  readRightID() {
1145
- return new we(this.clientDecoder.read(), this.rightClockDecoder.read());
1115
+ return new ye(this.clientDecoder.read(), this.rightClockDecoder.read());
1146
1116
  }
1147
1117
  /**
1148
1118
  * Read the next client id.
@@ -1190,7 +1160,7 @@ class ve extends Br {
1190
1160
  * @return {any}
1191
1161
  */
1192
1162
  readAny() {
1193
- return Ve(this.restDecoder);
1163
+ return Fe(this.restDecoder);
1194
1164
  }
1195
1165
  /**
1196
1166
  * @return {Uint8Array}
@@ -1206,7 +1176,7 @@ class ve extends Br {
1206
1176
  * @return {any}
1207
1177
  */
1208
1178
  readJSON() {
1209
- return Ve(this.restDecoder);
1179
+ return Fe(this.restDecoder);
1210
1180
  }
1211
1181
  /**
1212
1182
  * @return {string}
@@ -1221,7 +1191,7 @@ class ve extends Br {
1221
1191
  }
1222
1192
  }
1223
1193
  }
1224
- class pn {
1194
+ class mn {
1225
1195
  constructor() {
1226
1196
  this.restEncoder = I();
1227
1197
  }
@@ -1243,7 +1213,7 @@ class pn {
1243
1213
  p(this.restEncoder, e);
1244
1214
  }
1245
1215
  }
1246
- class Ge extends pn {
1216
+ class Xe extends mn {
1247
1217
  /**
1248
1218
  * @param {ID} id
1249
1219
  */
@@ -1267,7 +1237,7 @@ class Ge extends pn {
1267
1237
  * @param {number} info An unsigned 8-bit integer
1268
1238
  */
1269
1239
  writeInfo(e) {
1270
- Vt(this.restEncoder, e);
1240
+ Ht(this.restEncoder, e);
1271
1241
  }
1272
1242
  /**
1273
1243
  * @param {string} s
@@ -1320,7 +1290,7 @@ class Ge extends pn {
1320
1290
  ae(this.restEncoder, e);
1321
1291
  }
1322
1292
  }
1323
- class kn {
1293
+ class bn {
1324
1294
  constructor() {
1325
1295
  this.restEncoder = I(), this.dsCurrVal = 0;
1326
1296
  }
@@ -1341,16 +1311,16 @@ class kn {
1341
1311
  * @param {number} len
1342
1312
  */
1343
1313
  writeDsLen(e) {
1344
- e === 0 && F(), p(this.restEncoder, e - 1), this.dsCurrVal += e;
1314
+ e === 0 && H(), p(this.restEncoder, e - 1), this.dsCurrVal += e;
1345
1315
  }
1346
1316
  }
1347
- class ue extends kn {
1317
+ class ue extends bn {
1348
1318
  constructor() {
1349
- super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new At(), this.clientEncoder = new it(), this.leftClockEncoder = new At(), this.rightClockEncoder = new At(), this.infoEncoder = new As(Vt), this.stringEncoder = new Wi(), this.parentInfoEncoder = new As(Vt), this.typeRefEncoder = new it(), this.lenEncoder = new it();
1319
+ super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new At(), this.clientEncoder = new it(), this.leftClockEncoder = new At(), this.rightClockEncoder = new At(), this.infoEncoder = new js(Ht), this.stringEncoder = new kr(), this.parentInfoEncoder = new js(Ht), this.typeRefEncoder = new it(), this.lenEncoder = new it();
1350
1320
  }
1351
1321
  toUint8Array() {
1352
1322
  const e = I();
1353
- return p(e, 0), S(e, this.keyClockEncoder.toUint8Array()), S(e, this.clientEncoder.toUint8Array()), S(e, this.leftClockEncoder.toUint8Array()), S(e, this.rightClockEncoder.toUint8Array()), S(e, _(this.infoEncoder)), S(e, this.stringEncoder.toUint8Array()), S(e, _(this.parentInfoEncoder)), S(e, this.typeRefEncoder.toUint8Array()), S(e, this.lenEncoder.toUint8Array()), mt(e, _(this.restEncoder)), _(e);
1323
+ return p(e, 0), S(e, this.keyClockEncoder.toUint8Array()), S(e, this.clientEncoder.toUint8Array()), S(e, this.leftClockEncoder.toUint8Array()), S(e, this.rightClockEncoder.toUint8Array()), S(e, _(this.infoEncoder)), S(e, this.stringEncoder.toUint8Array()), S(e, _(this.parentInfoEncoder)), S(e, this.typeRefEncoder.toUint8Array()), S(e, this.lenEncoder.toUint8Array()), bt(e, _(this.restEncoder)), _(e);
1354
1324
  }
1355
1325
  /**
1356
1326
  * @param {ID} id
@@ -1437,9 +1407,9 @@ class ue extends kn {
1437
1407
  s === void 0 ? (this.keyClockEncoder.write(this.keyClock++), this.stringEncoder.write(e)) : this.keyClockEncoder.write(s);
1438
1408
  }
1439
1409
  }
1440
- const Fr = (t, e, s, n) => {
1410
+ const Br = (t, e, s, n) => {
1441
1411
  n = pe(n, e[0].id.clock);
1442
- const i = H(e, n);
1412
+ const i = V(e, n);
1443
1413
  p(t.restEncoder, e.length - i), t.writeClient(s), p(t.restEncoder, n);
1444
1414
  const r = e[i];
1445
1415
  r.write(t, n - r.id.clock);
@@ -1449,10 +1419,10 @@ const Fr = (t, e, s, n) => {
1449
1419
  const n = /* @__PURE__ */ new Map();
1450
1420
  s.forEach((i, r) => {
1451
1421
  v(e, r) > i && n.set(r, i);
1452
- }), yt(e).forEach((i, r) => {
1422
+ }), wt(e).forEach((i, r) => {
1453
1423
  s.has(r) || n.set(r, 0);
1454
1424
  }), p(t.restEncoder, n.size), se(n.entries()).sort((i, r) => r[0] - i[0]).forEach(([i, r]) => {
1455
- Fr(
1425
+ Br(
1456
1426
  t,
1457
1427
  /** @type {Array<GC|Item>} */
1458
1428
  e.clients.get(i),
@@ -1460,7 +1430,7 @@ const Fr = (t, e, s, n) => {
1460
1430
  r
1461
1431
  );
1462
1432
  });
1463
- }, Hr = (t, e) => {
1433
+ }, Fr = (t, e) => {
1464
1434
  const s = O(), n = k(t.restDecoder);
1465
1435
  for (let i = 0; i < n; i++) {
1466
1436
  const r = k(t.restDecoder), o = new Array(r), c = t.readClient();
@@ -1471,7 +1441,7 @@ const Fr = (t, e, s, n) => {
1471
1441
  switch (kt & h) {
1472
1442
  case 0: {
1473
1443
  const u = t.readLen();
1474
- o[l] = new T(w(c, a), u), a += u;
1444
+ o[l] = new U(w(c, a), u), a += u;
1475
1445
  break;
1476
1446
  }
1477
1447
  case 10: {
@@ -1480,21 +1450,21 @@ const Fr = (t, e, s, n) => {
1480
1450
  break;
1481
1451
  }
1482
1452
  default: {
1483
- const u = (h & (K | U)) === 0, d = new D(
1453
+ const u = (h & (Y | T)) === 0, d = new D(
1484
1454
  w(c, a),
1485
1455
  null,
1486
1456
  // leftd
1487
- (h & U) === U ? t.readLeftID() : null,
1457
+ (h & T) === T ? t.readLeftID() : null,
1488
1458
  // origin
1489
1459
  null,
1490
1460
  // right
1491
- (h & K) === K ? t.readRightID() : null,
1461
+ (h & Y) === Y ? t.readRightID() : null,
1492
1462
  // right origin
1493
1463
  u ? t.readParentInfo() ? e.get(t.readString()) : t.readLeftID() : null,
1494
1464
  // parent
1495
- u && (h & Fe) === Fe ? t.readString() : null,
1465
+ u && (h & Be) === Be ? t.readString() : null,
1496
1466
  // parentSub
1497
- $n(t, h)
1467
+ Kn(t, h)
1498
1468
  // item content
1499
1469
  );
1500
1470
  o[l] = d, a += d.length;
@@ -1503,7 +1473,7 @@ const Fr = (t, e, s, n) => {
1503
1473
  }
1504
1474
  }
1505
1475
  return s;
1506
- }, Vr = (t, e, s) => {
1476
+ }, Hr = (t, e, s) => {
1507
1477
  const n = [];
1508
1478
  let i = se(s.keys()).sort((f, g) => f - g);
1509
1479
  if (i.length === 0)
@@ -1526,7 +1496,7 @@ const Fr = (t, e, s, n) => {
1526
1496
  let o = r();
1527
1497
  if (o === null && n.length === 0)
1528
1498
  return null;
1529
- const c = new Sn(), a = /* @__PURE__ */ new Map(), l = (f, g) => {
1499
+ const c = new En(), a = /* @__PURE__ */ new Map(), l = (f, g) => {
1530
1500
  const m = a.get(f);
1531
1501
  (m == null || m > g) && a.set(f, g);
1532
1502
  };
@@ -1546,7 +1516,7 @@ const Fr = (t, e, s, n) => {
1546
1516
  };
1547
1517
  for (; ; ) {
1548
1518
  if (h.constructor !== z) {
1549
- const g = G(u, h.id.client, () => v(e, h.id.client)) - h.id.clock;
1519
+ const g = W(u, h.id.client, () => v(e, h.id.client)) - h.id.clock;
1550
1520
  if (g < 0)
1551
1521
  n.push(h), l(h.id.client, h.id.clock - 1), d();
1552
1522
  else {
@@ -1589,10 +1559,10 @@ const Fr = (t, e, s, n) => {
1589
1559
  return as(f, c, /* @__PURE__ */ new Map()), p(f.restEncoder, 0), { missing: a, update: f.toUint8Array() };
1590
1560
  }
1591
1561
  return null;
1592
- }, $r = (t, e) => as(t, e.doc.store, e.beforeState), qr = (t, e, s, n = new ve(t)) => y(e, (i) => {
1562
+ }, Vr = (t, e) => as(t, e.doc.store, e.beforeState), $r = (t, e, s, n = new ve(t)) => y(e, (i) => {
1593
1563
  i.local = !1;
1594
1564
  let r = !1;
1595
- const o = i.doc, c = o.store, a = Hr(n, o), l = Vr(i, c, a), h = c.pendingStructs;
1565
+ const o = i.doc, c = o.store, a = Fr(n, o), l = Hr(i, c, a), h = c.pendingStructs;
1596
1566
  if (h) {
1597
1567
  for (const [d, f] of h.missing)
1598
1568
  if (f < v(c, d)) {
@@ -1604,16 +1574,16 @@ const Fr = (t, e, s, n) => {
1604
1574
  const g = h.missing.get(d);
1605
1575
  (g == null || g > f) && h.missing.set(d, f);
1606
1576
  }
1607
- h.update = lt([h.update, l.update]);
1577
+ h.update = at([h.update, l.update]);
1608
1578
  }
1609
1579
  } else
1610
1580
  c.pendingStructs = l;
1611
- const u = Ms(n, i, c);
1581
+ const u = Us(n, i, c);
1612
1582
  if (c.pendingDs) {
1613
1583
  const d = new ve(ie(c.pendingDs));
1614
1584
  k(d.restDecoder);
1615
- const f = Ms(d, i, c);
1616
- u && f ? c.pendingDs = lt([u, f]) : c.pendingDs = u || f;
1585
+ const f = Us(d, i, c);
1586
+ u && f ? c.pendingDs = at([u, f]) : c.pendingDs = u || f;
1617
1587
  } else
1618
1588
  c.pendingDs = u;
1619
1589
  if (r) {
@@ -1621,44 +1591,44 @@ const Fr = (t, e, s, n) => {
1621
1591
  /** @type {{update: Uint8Array}} */
1622
1592
  c.pendingStructs.update
1623
1593
  );
1624
- c.pendingStructs = null, mn(i.doc, d);
1594
+ c.pendingStructs = null, wn(i.doc, d);
1625
1595
  }
1626
- }, s, !1), mn = (t, e, s, n = ve) => {
1596
+ }, s, !1), wn = (t, e, s, n = ve) => {
1627
1597
  const i = ie(e);
1628
- qr(i, t, s, new n(i));
1629
- }, bn = (t, e, s) => mn(t, e, s, gn), Kr = (t, e, s = /* @__PURE__ */ new Map()) => {
1630
- as(t, e.store, s), Ae(t, Nr(e.store));
1631
- }, Yr = (t, e = new Uint8Array([0]), s = new ue()) => {
1632
- const n = wn(e);
1633
- Kr(s, t, n);
1598
+ $r(i, t, s, new n(i));
1599
+ }, yn = (t, e, s) => wn(t, e, s, kn), qr = (t, e, s = /* @__PURE__ */ new Map()) => {
1600
+ as(t, e.store, s), Ae(t, Rr(e.store));
1601
+ }, Kr = (t, e = new Uint8Array([0]), s = new ue()) => {
1602
+ const n = _n(e);
1603
+ qr(s, t, n);
1634
1604
  const i = [s.toUint8Array()];
1635
- if (t.store.pendingDs && i.push(t.store.pendingDs), t.store.pendingStructs && i.push(co(t.store.pendingStructs.update, e)), i.length > 1) {
1636
- if (s.constructor === Ge)
1637
- return ro(i.map((r, o) => o === 0 ? r : lo(r)));
1605
+ if (t.store.pendingDs && i.push(t.store.pendingDs), t.store.pendingStructs && i.push(oo(t.store.pendingStructs.update, e)), i.length > 1) {
1606
+ if (s.constructor === Xe)
1607
+ return io(i.map((r, o) => o === 0 ? r : ao(r)));
1638
1608
  if (s.constructor === ue)
1639
- return lt(i);
1609
+ return at(i);
1640
1610
  }
1641
1611
  return i[0];
1642
- }, ls = (t, e) => Yr(t, e, new Ge()), Jr = (t) => {
1612
+ }, ls = (t, e) => Kr(t, e, new Xe()), Yr = (t) => {
1643
1613
  const e = /* @__PURE__ */ new Map(), s = k(t.restDecoder);
1644
1614
  for (let n = 0; n < s; n++) {
1645
1615
  const i = k(t.restDecoder), r = k(t.restDecoder);
1646
1616
  e.set(i, r);
1647
1617
  }
1648
1618
  return e;
1649
- }, wn = (t) => Jr(new fn(ie(t))), yn = (t, e) => (p(t.restEncoder, e.size), se(e.entries()).sort((s, n) => n[0] - s[0]).forEach(([s, n]) => {
1619
+ }, _n = (t) => Yr(new pn(ie(t))), Sn = (t, e) => (p(t.restEncoder, e.size), se(e.entries()).sort((s, n) => n[0] - s[0]).forEach(([s, n]) => {
1650
1620
  p(t.restEncoder, s), p(t.restEncoder, n);
1651
- }), t), Xr = (t, e) => yn(t, yt(e.store)), Gr = (t, e = new kn()) => (t instanceof Map ? yn(e, t) : Xr(e, t), e.toUint8Array()), Wr = (t) => Gr(t, new pn());
1652
- class Pr {
1621
+ }), t), Jr = (t, e) => Sn(t, wt(e.store)), Xr = (t, e = new bn()) => (t instanceof Map ? Sn(e, t) : Jr(e, t), e.toUint8Array()), Gr = (t) => Xr(t, new mn());
1622
+ class Wr {
1653
1623
  constructor() {
1654
1624
  this.l = [];
1655
1625
  }
1656
1626
  }
1657
- const Us = () => new Pr(), Ts = (t, e) => t.l.push(e), zs = (t, e) => {
1627
+ const zs = () => new Wr(), Os = (t, e) => t.l.push(e), Rs = (t, e) => {
1658
1628
  const s = t.l, n = s.length;
1659
1629
  t.l = s.filter((i) => e !== i), n === t.l.length && console.error("[yjs] Tried to remove event handler that doesn't exist.");
1660
- }, _n = (t, e, s) => Wt(t.l, [e, s]);
1661
- class we {
1630
+ }, Dn = (t, e, s) => Qt(t.l, [e, s]);
1631
+ class ye {
1662
1632
  /**
1663
1633
  * @param {number} client client id
1664
1634
  * @param {number} clock unique per client id, continuous number
@@ -1667,24 +1637,24 @@ class we {
1667
1637
  this.client = e, this.clock = s;
1668
1638
  }
1669
1639
  }
1670
- const Ze = (t, e) => t === e || t !== null && e !== null && t.client === e.client && t.clock === e.clock, w = (t, e) => new we(t, e), Qr = (t) => {
1640
+ const Qe = (t, e) => t === e || t !== null && e !== null && t.client === e.client && t.clock === e.clock, w = (t, e) => new ye(t, e), Pr = (t) => {
1671
1641
  for (const [e, s] of t.doc.share.entries())
1672
1642
  if (s === t)
1673
1643
  return e;
1674
- throw F();
1675
- }, Te = (t, e) => e === void 0 ? !t.deleted : e.sv.has(t.id.client) && (e.sv.get(t.id.client) || 0) > t.id.clock && !un(e.ds, t.id), qt = (t, e) => {
1676
- const s = G(t.meta, qt, le), n = t.doc.store;
1644
+ throw H();
1645
+ }, Te = (t, e) => e === void 0 ? !t.deleted : e.sv.has(t.id.client) && (e.sv.get(t.id.client) || 0) > t.id.clock && !fn(e.ds, t.id), $t = (t, e) => {
1646
+ const s = W(t.meta, $t, le), n = t.doc.store;
1677
1647
  s.has(e) || (e.sv.forEach((i, r) => {
1678
1648
  i < v(n, r) && ne(t, w(r, i));
1679
- }), hn(t, e.ds, (i) => {
1649
+ }), dn(t, e.ds, (i) => {
1680
1650
  }), s.add(e));
1681
1651
  };
1682
- class Sn {
1652
+ class En {
1683
1653
  constructor() {
1684
1654
  this.clients = /* @__PURE__ */ new Map(), this.pendingStructs = null, this.pendingDs = null;
1685
1655
  }
1686
1656
  }
1687
- const yt = (t) => {
1657
+ const wt = (t) => {
1688
1658
  const e = /* @__PURE__ */ new Map();
1689
1659
  return t.clients.forEach((s, n) => {
1690
1660
  const i = s[s.length - 1];
@@ -1696,21 +1666,21 @@ const yt = (t) => {
1696
1666
  return 0;
1697
1667
  const n = s[s.length - 1];
1698
1668
  return n.id.clock + n.length;
1699
- }, Dn = (t, e) => {
1669
+ }, Cn = (t, e) => {
1700
1670
  let s = t.clients.get(e.id.client);
1701
1671
  if (s === void 0)
1702
1672
  s = [], t.clients.set(e.id.client, s);
1703
1673
  else {
1704
1674
  const n = s[s.length - 1];
1705
1675
  if (n.id.clock + n.length !== e.id.clock)
1706
- throw F();
1676
+ throw H();
1707
1677
  }
1708
1678
  s.push(e);
1709
- }, H = (t, e) => {
1679
+ }, V = (t, e) => {
1710
1680
  let s = 0, n = t.length - 1, i = t[n], r = i.id.clock;
1711
1681
  if (r === e)
1712
1682
  return n;
1713
- let o = J(e / (r + i.length - 1) * n);
1683
+ let o = X(e / (r + i.length - 1) * n);
1714
1684
  for (; s <= n; ) {
1715
1685
  if (i = t[o], r = i.id.clock, r <= e) {
1716
1686
  if (e < r + i.length)
@@ -1718,56 +1688,56 @@ const yt = (t) => {
1718
1688
  s = o + 1;
1719
1689
  } else
1720
1690
  n = o - 1;
1721
- o = J((s + n) / 2);
1691
+ o = X((s + n) / 2);
1722
1692
  }
1723
- throw F();
1724
- }, Zr = (t, e) => {
1693
+ throw H();
1694
+ }, Qr = (t, e) => {
1725
1695
  const s = t.clients.get(e.client);
1726
- return s[H(s, e.clock)];
1727
- }, jt = (
1696
+ return s[V(s, e.clock)];
1697
+ }, Lt = (
1728
1698
  /** @type {function(StructStore,ID):Item} */
1729
- Zr
1730
- ), Kt = (t, e, s) => {
1731
- const n = H(e, s), i = e[n];
1732
- return i.id.clock < s && i instanceof D ? (e.splice(n + 1, 0, pt(t, i, s - i.id.clock)), n + 1) : n;
1699
+ Qr
1700
+ ), qt = (t, e, s) => {
1701
+ const n = V(e, s), i = e[n];
1702
+ return i.id.clock < s && i instanceof D ? (e.splice(n + 1, 0, gt(t, i, s - i.id.clock)), n + 1) : n;
1733
1703
  }, ne = (t, e) => {
1734
1704
  const s = (
1735
1705
  /** @type {Array<Item>} */
1736
1706
  t.doc.store.clients.get(e.client)
1737
1707
  );
1738
- return s[Kt(t, s, e.clock)];
1739
- }, Os = (t, e, s) => {
1740
- const n = e.clients.get(s.client), i = H(n, s.clock), r = n[i];
1741
- return s.clock !== r.id.clock + r.length - 1 && r.constructor !== T && n.splice(i + 1, 0, pt(t, r, s.clock - r.id.clock + 1)), r;
1742
- }, eo = (t, e, s) => {
1708
+ return s[qt(t, s, e.clock)];
1709
+ }, Ns = (t, e, s) => {
1710
+ const n = e.clients.get(s.client), i = V(n, s.clock), r = n[i];
1711
+ return s.clock !== r.id.clock + r.length - 1 && r.constructor !== U && n.splice(i + 1, 0, gt(t, r, s.clock - r.id.clock + 1)), r;
1712
+ }, Zr = (t, e, s) => {
1743
1713
  const n = (
1744
1714
  /** @type {Array<GC|Item>} */
1745
1715
  t.clients.get(e.id.client)
1746
1716
  );
1747
- n[H(n, e.id.clock)] = s;
1748
- }, Cn = (t, e, s, n, i) => {
1717
+ n[V(n, e.id.clock)] = s;
1718
+ }, vn = (t, e, s, n, i) => {
1749
1719
  if (n === 0)
1750
1720
  return;
1751
1721
  const r = s + n;
1752
- let o = Kt(t, e, s), c;
1722
+ let o = qt(t, e, s), c;
1753
1723
  do
1754
- c = e[o++], r < c.id.clock + c.length && Kt(t, e, r), i(c);
1724
+ c = e[o++], r < c.id.clock + c.length && qt(t, e, r), i(c);
1755
1725
  while (o < e.length && e[o].id.clock < r);
1756
1726
  };
1757
- class to {
1727
+ class eo {
1758
1728
  /**
1759
1729
  * @param {Doc} doc
1760
1730
  * @param {any} origin
1761
1731
  * @param {boolean} local
1762
1732
  */
1763
1733
  constructor(e, s, n) {
1764
- this.doc = e, this.deleteSet = new Xe(), this.beforeState = yt(e.store), this.afterState = /* @__PURE__ */ new Map(), this.changed = /* @__PURE__ */ new Map(), this.changedParentTypes = /* @__PURE__ */ new Map(), this._mergeStructs = [], this.origin = s, this.meta = /* @__PURE__ */ new Map(), this.local = n, this.subdocsAdded = /* @__PURE__ */ new Set(), this.subdocsRemoved = /* @__PURE__ */ new Set(), this.subdocsLoaded = /* @__PURE__ */ new Set(), this._needFormattingCleanup = !1;
1734
+ this.doc = e, this.deleteSet = new Je(), this.beforeState = wt(e.store), this.afterState = /* @__PURE__ */ new Map(), this.changed = /* @__PURE__ */ new Map(), this.changedParentTypes = /* @__PURE__ */ new Map(), this._mergeStructs = [], this.origin = s, this.meta = /* @__PURE__ */ new Map(), this.local = n, this.subdocsAdded = /* @__PURE__ */ new Set(), this.subdocsRemoved = /* @__PURE__ */ new Set(), this.subdocsLoaded = /* @__PURE__ */ new Set(), this._needFormattingCleanup = !1;
1765
1735
  }
1766
1736
  }
1767
- const Rs = (t, e) => e.deleteSet.clients.size === 0 && !di(e.afterState, (s, n) => e.beforeState.get(n) !== s) ? !1 : (os(e.deleteSet), $r(t, e), Ae(t, e.deleteSet), !0), Ns = (t, e, s) => {
1737
+ const Bs = (t, e) => e.deleteSet.clients.size === 0 && !pi(e.afterState, (s, n) => e.beforeState.get(n) !== s) ? !1 : (os(e.deleteSet), Vr(t, e), Ae(t, e.deleteSet), !0), Fs = (t, e, s) => {
1768
1738
  const n = e._item;
1769
- (n === null || n.id.clock < (t.beforeState.get(n.id.client) || 0) && !n.deleted) && G(t.changed, e, le).add(s);
1770
- }, ot = (t, e) => {
1739
+ (n === null || n.id.clock < (t.beforeState.get(n.id.client) || 0) && !n.deleted) && W(t.changed, e, le).add(s);
1740
+ }, rt = (t, e) => {
1771
1741
  let s = t[e], n = t[e - 1], i = e;
1772
1742
  for (; i > 0; s = n, n = t[--i - 1]) {
1773
1743
  if (n.deleted === s.deleted && n.constructor === s.constructor && n.mergeWith(s)) {
@@ -1783,7 +1753,7 @@ const Rs = (t, e) => e.deleteSet.clients.size === 0 && !di(e.afterState, (s, n)
1783
1753
  }
1784
1754
  const r = e - i;
1785
1755
  return r && t.splice(e + 1 - r, r), r;
1786
- }, so = (t, e, s) => {
1756
+ }, to = (t, e, s) => {
1787
1757
  for (const [n, i] of t.clients.entries()) {
1788
1758
  const r = (
1789
1759
  /** @type {Array<GC|Item>} */
@@ -1791,7 +1761,7 @@ const Rs = (t, e) => e.deleteSet.clients.size === 0 && !di(e.afterState, (s, n)
1791
1761
  );
1792
1762
  for (let o = i.length - 1; o >= 0; o--) {
1793
1763
  const c = i[o], a = c.clock + c.len;
1794
- for (let l = H(r, c.clock), h = r[l]; l < r.length && h.id.clock < a; h = r[++l]) {
1764
+ for (let l = V(r, c.clock), h = r[l]; l < r.length && h.id.clock < a; h = r[++l]) {
1795
1765
  const u = r[l];
1796
1766
  if (c.clock + c.len <= u.id.clock)
1797
1767
  break;
@@ -1799,23 +1769,23 @@ const Rs = (t, e) => e.deleteSet.clients.size === 0 && !di(e.afterState, (s, n)
1799
1769
  }
1800
1770
  }
1801
1771
  }
1802
- }, no = (t, e) => {
1772
+ }, so = (t, e) => {
1803
1773
  t.clients.forEach((s, n) => {
1804
1774
  const i = (
1805
1775
  /** @type {Array<GC|Item>} */
1806
1776
  e.clients.get(n)
1807
1777
  );
1808
1778
  for (let r = s.length - 1; r >= 0; r--) {
1809
- const o = s[r], c = Pt(i.length - 1, 1 + H(i, o.clock + o.len - 1));
1779
+ const o = s[r], c = Wt(i.length - 1, 1 + V(i, o.clock + o.len - 1));
1810
1780
  for (let a = c, l = i[a]; a > 0 && l.id.clock >= o.clock; l = i[a])
1811
- a -= 1 + ot(i, a);
1781
+ a -= 1 + rt(i, a);
1812
1782
  }
1813
1783
  });
1814
- }, En = (t, e) => {
1784
+ }, xn = (t, e) => {
1815
1785
  if (e < t.length) {
1816
1786
  const s = t[e], n = s.doc, i = n.store, r = s.deleteSet, o = s._mergeStructs;
1817
1787
  try {
1818
- os(r), s.afterState = yt(s.doc.store), n.emit("beforeObserverCalls", [s, n]);
1788
+ os(r), s.afterState = wt(s.doc.store), n.emit("beforeObserverCalls", [s, n]);
1819
1789
  const c = [];
1820
1790
  s.changed.forEach(
1821
1791
  (a, l) => c.push(() => {
@@ -1827,57 +1797,57 @@ const Rs = (t, e) => e.deleteSet.clients.size === 0 && !di(e.afterState, (s, n)
1827
1797
  (h) => h.target._item === null || !h.target._item.deleted
1828
1798
  ), a.forEach((h) => {
1829
1799
  h.currentTarget = l, h._path = null;
1830
- }), a.sort((h, u) => h.path.length - u.path.length), _n(l._dEH, a, s));
1800
+ }), a.sort((h, u) => h.path.length - u.path.length), Dn(l._dEH, a, s));
1831
1801
  });
1832
- }), c.push(() => n.emit("afterTransaction", [s, n])), Wt(c, []), s._needFormattingCleanup && Do(s);
1802
+ }), c.push(() => n.emit("afterTransaction", [s, n])), Qt(c, []), s._needFormattingCleanup && So(s);
1833
1803
  } finally {
1834
- n.gc && so(r, i, n.gcFilter), no(r, i), s.afterState.forEach((h, u) => {
1804
+ n.gc && to(r, i, n.gcFilter), so(r, i), s.afterState.forEach((h, u) => {
1835
1805
  const d = s.beforeState.get(u) || 0;
1836
1806
  if (d !== h) {
1837
1807
  const f = (
1838
1808
  /** @type {Array<GC|Item>} */
1839
1809
  i.clients.get(u)
1840
- ), g = pe(H(f, d), 1);
1810
+ ), g = pe(V(f, d), 1);
1841
1811
  for (let m = f.length - 1; m >= g; )
1842
- m -= 1 + ot(f, m);
1812
+ m -= 1 + rt(f, m);
1843
1813
  }
1844
1814
  });
1845
1815
  for (let h = o.length - 1; h >= 0; h--) {
1846
1816
  const { client: u, clock: d } = o[h].id, f = (
1847
1817
  /** @type {Array<GC|Item>} */
1848
1818
  i.clients.get(u)
1849
- ), g = H(f, d);
1850
- g + 1 < f.length && ot(f, g + 1) > 1 || g > 0 && ot(f, g);
1819
+ ), g = V(f, d);
1820
+ g + 1 < f.length && rt(f, g + 1) > 1 || g > 0 && rt(f, g);
1851
1821
  }
1852
- if (!s.local && s.afterState.get(n.clientID) !== s.beforeState.get(n.clientID) && (Mr(an, rn, "[yjs] ", on, cn, "Changed the client-id because another client seems to be using it."), n.clientID = dn()), n.emit("afterTransactionCleanup", [s, n]), n._observers.has("update")) {
1853
- const h = new Ge();
1854
- Rs(h, s) && n.emit("update", [h.toUint8Array(), s.origin, n, s]);
1822
+ if (!s.local && s.afterState.get(n.clientID) !== s.beforeState.get(n.clientID) && (jr(hn, cn, "[yjs] ", an, ln, "Changed the client-id because another client seems to be using it."), n.clientID = gn()), n.emit("afterTransactionCleanup", [s, n]), n._observers.has("update")) {
1823
+ const h = new Xe();
1824
+ Bs(h, s) && n.emit("update", [h.toUint8Array(), s.origin, n, s]);
1855
1825
  }
1856
1826
  if (n._observers.has("updateV2")) {
1857
1827
  const h = new ue();
1858
- Rs(h, s) && n.emit("updateV2", [h.toUint8Array(), s.origin, n, s]);
1828
+ Bs(h, s) && n.emit("updateV2", [h.toUint8Array(), s.origin, n, s]);
1859
1829
  }
1860
1830
  const { subdocsAdded: c, subdocsLoaded: a, subdocsRemoved: l } = s;
1861
1831
  (c.size > 0 || l.size > 0 || a.size > 0) && (c.forEach((h) => {
1862
1832
  h.clientID = n.clientID, h.collectionid == null && (h.collectionid = n.collectionid), n.subdocs.add(h);
1863
- }), l.forEach((h) => n.subdocs.delete(h)), n.emit("subdocs", [{ loaded: a, added: c, removed: l }, n, s]), l.forEach((h) => h.destroy())), t.length <= e + 1 ? (n._transactionCleanups = [], n.emit("afterAllTransactions", [n, t])) : En(t, e + 1);
1833
+ }), l.forEach((h) => n.subdocs.delete(h)), n.emit("subdocs", [{ loaded: a, added: c, removed: l }, n, s]), l.forEach((h) => h.destroy())), t.length <= e + 1 ? (n._transactionCleanups = [], n.emit("afterAllTransactions", [n, t])) : xn(t, e + 1);
1864
1834
  }
1865
1835
  }
1866
1836
  }, y = (t, e, s = null, n = !0) => {
1867
1837
  const i = t._transactionCleanups;
1868
1838
  let r = !1, o = null;
1869
- t._transaction === null && (r = !0, t._transaction = new to(t, s, n), i.push(t._transaction), i.length === 1 && t.emit("beforeAllTransactions", [t]), t.emit("beforeTransaction", [t._transaction, t]));
1839
+ t._transaction === null && (r = !0, t._transaction = new eo(t, s, n), i.push(t._transaction), i.length === 1 && t.emit("beforeAllTransactions", [t]), t.emit("beforeTransaction", [t._transaction, t]));
1870
1840
  try {
1871
1841
  o = e(t._transaction);
1872
1842
  } finally {
1873
1843
  if (r) {
1874
1844
  const c = t._transaction === i[0];
1875
- t._transaction = null, c && En(i, 0);
1845
+ t._transaction = null, c && xn(i, 0);
1876
1846
  }
1877
1847
  }
1878
1848
  return o;
1879
1849
  };
1880
- function* io(t) {
1850
+ function* no(t) {
1881
1851
  const e = k(t.restDecoder);
1882
1852
  for (let s = 0; s < e; s++) {
1883
1853
  const n = k(t.restDecoder), i = t.readClient();
@@ -1888,28 +1858,28 @@ function* io(t) {
1888
1858
  const a = k(t.restDecoder);
1889
1859
  yield new z(w(i, r), a), r += a;
1890
1860
  } else if (kt & c) {
1891
- const a = (c & (K | U)) === 0, l = new D(
1861
+ const a = (c & (Y | T)) === 0, l = new D(
1892
1862
  w(i, r),
1893
1863
  null,
1894
1864
  // left
1895
- (c & U) === U ? t.readLeftID() : null,
1865
+ (c & T) === T ? t.readLeftID() : null,
1896
1866
  // origin
1897
1867
  null,
1898
1868
  // right
1899
- (c & K) === K ? t.readRightID() : null,
1869
+ (c & Y) === Y ? t.readRightID() : null,
1900
1870
  // right origin
1901
1871
  // @ts-ignore Force writing a string here.
1902
1872
  a ? t.readParentInfo() ? t.readString() : t.readLeftID() : null,
1903
1873
  // parent
1904
- a && (c & Fe) === Fe ? t.readString() : null,
1874
+ a && (c & Be) === Be ? t.readString() : null,
1905
1875
  // parentSub
1906
- $n(t, c)
1876
+ Kn(t, c)
1907
1877
  // item content
1908
1878
  );
1909
1879
  yield l, r += l.length;
1910
1880
  } else {
1911
1881
  const a = t.readLen();
1912
- yield new T(w(i, r), a), r += a;
1882
+ yield new U(w(i, r), a), r += a;
1913
1883
  }
1914
1884
  }
1915
1885
  }
@@ -1920,7 +1890,7 @@ class hs {
1920
1890
  * @param {boolean} filterSkips
1921
1891
  */
1922
1892
  constructor(e, s) {
1923
- this.gen = io(e), this.curr = null, this.done = !1, this.filterSkips = s, this.next();
1893
+ this.gen = no(e), this.curr = null, this.done = !1, this.filterSkips = s, this.next();
1924
1894
  }
1925
1895
  /**
1926
1896
  * @return {Item | GC | Skip |null}
@@ -1940,10 +1910,10 @@ class us {
1940
1910
  this.currClient = 0, this.startClock = 0, this.written = 0, this.encoder = e, this.clientStructs = [];
1941
1911
  }
1942
1912
  }
1943
- const ro = (t) => lt(t, gn, Ge), oo = (t, e) => {
1944
- if (t.constructor === T) {
1913
+ const io = (t) => at(t, kn, Xe), ro = (t, e) => {
1914
+ if (t.constructor === U) {
1945
1915
  const { client: s, clock: n } = t.id;
1946
- return new T(w(s, n + e), t.length - e);
1916
+ return new U(w(s, n + e), t.length - e);
1947
1917
  } else if (t.constructor === z) {
1948
1918
  const { client: s, clock: n } = t.id;
1949
1919
  return new z(w(s, n + e), t.length - e);
@@ -1963,7 +1933,7 @@ const ro = (t) => lt(t, gn, Ge), oo = (t, e) => {
1963
1933
  s.content.splice(e)
1964
1934
  );
1965
1935
  }
1966
- }, lt = (t, e = ve, s = ue) => {
1936
+ }, at = (t, e = ve, s = ue) => {
1967
1937
  if (t.length === 1)
1968
1938
  return t[0];
1969
1939
  const n = t.map((h) => new e(ie(h)));
@@ -1995,21 +1965,21 @@ const ro = (t) => lt(t, gn, Ge), oo = (t, e) => {
1995
1965
  f && d.id.clock > r.struct.id.clock + r.struct.length)
1996
1966
  continue;
1997
1967
  if (u !== r.struct.id.client)
1998
- Q(c, r.struct, r.offset), r = { struct: d, offset: 0 }, h.next();
1968
+ Z(c, r.struct, r.offset), r = { struct: d, offset: 0 }, h.next();
1999
1969
  else if (r.struct.id.clock + r.struct.length < d.id.clock)
2000
1970
  if (r.struct.constructor === z)
2001
1971
  r.struct.length = d.id.clock + d.length - r.struct.id.clock;
2002
1972
  else {
2003
- Q(c, r.struct, r.offset);
1973
+ Z(c, r.struct, r.offset);
2004
1974
  const g = d.id.clock - r.struct.id.clock - r.struct.length;
2005
1975
  r = { struct: new z(w(u, r.struct.id.clock + r.struct.length), g), offset: 0 };
2006
1976
  }
2007
1977
  else {
2008
1978
  const g = r.struct.id.clock + r.struct.length - d.id.clock;
2009
- g > 0 && (r.struct.constructor === z ? r.struct.length -= g : d = oo(d, g)), r.struct.mergeWith(
1979
+ g > 0 && (r.struct.constructor === z ? r.struct.length -= g : d = ro(d, g)), r.struct.mergeWith(
2010
1980
  /** @type {any} */
2011
1981
  d
2012
- ) || (Q(c, r.struct, r.offset), r = { struct: d, offset: 0 }, h.next());
1982
+ ) || (Z(c, r.struct, r.offset), r = { struct: d, offset: 0 }, h.next());
2013
1983
  }
2014
1984
  } else
2015
1985
  r = { struct: (
@@ -2017,13 +1987,13 @@ const ro = (t) => lt(t, gn, Ge), oo = (t, e) => {
2017
1987
  h.curr
2018
1988
  ), offset: 0 }, h.next();
2019
1989
  for (let d = h.curr; d !== null && d.id.client === u && d.id.clock === r.struct.id.clock + r.struct.length && d.constructor !== z; d = h.next())
2020
- Q(c, r.struct, r.offset), r = { struct: d, offset: 0 };
1990
+ Z(c, r.struct, r.offset), r = { struct: d, offset: 0 };
2021
1991
  }
2022
- r !== null && (Q(c, r.struct, r.offset), r = null), ds(c);
2023
- const a = n.map((h) => cs(h)), l = Or(a);
1992
+ r !== null && (Z(c, r.struct, r.offset), r = null), ds(c);
1993
+ const a = n.map((h) => cs(h)), l = zr(a);
2024
1994
  return Ae(o, l), o.toUint8Array();
2025
- }, co = (t, e, s = ve, n = ue) => {
2026
- const i = wn(e), r = new n(), o = new us(r), c = new s(ie(t)), a = new hs(c, !1);
1995
+ }, oo = (t, e, s = ve, n = ue) => {
1996
+ const i = _n(e), r = new n(), o = new us(r), c = new s(ie(t)), a = new hs(c, !1);
2027
1997
  for (; a.curr; ) {
2028
1998
  const h = a.curr, u = h.id.client, d = i.get(u) || 0;
2029
1999
  if (a.curr.constructor === z) {
@@ -2031,8 +2001,8 @@ const ro = (t) => lt(t, gn, Ge), oo = (t, e) => {
2031
2001
  continue;
2032
2002
  }
2033
2003
  if (h.id.clock + h.length > d)
2034
- for (Q(o, h, pe(d - h.id.clock, 0)), a.next(); a.curr && a.curr.id.client === u; )
2035
- Q(o, a.curr, 0), a.next();
2004
+ for (Z(o, h, pe(d - h.id.clock, 0)), a.next(); a.curr && a.curr.id.client === u; )
2005
+ Z(o, a.curr, 0), a.next();
2036
2006
  else
2037
2007
  for (; a.curr && a.curr.id.client === u && a.curr.id.clock + a.curr.length <= d; )
2038
2008
  a.next();
@@ -2040,27 +2010,27 @@ const ro = (t) => lt(t, gn, Ge), oo = (t, e) => {
2040
2010
  ds(o);
2041
2011
  const l = cs(c);
2042
2012
  return Ae(r, l), r.toUint8Array();
2043
- }, vn = (t) => {
2013
+ }, An = (t) => {
2044
2014
  t.written > 0 && (t.clientStructs.push({ written: t.written, restEncoder: _(t.encoder.restEncoder) }), t.encoder.restEncoder = I(), t.written = 0);
2045
- }, Q = (t, e, s) => {
2046
- t.written > 0 && t.currClient !== e.id.client && vn(t), t.written === 0 && (t.currClient = e.id.client, t.encoder.writeClient(e.id.client), p(t.encoder.restEncoder, e.id.clock + s)), e.write(t.encoder, s), t.written++;
2015
+ }, Z = (t, e, s) => {
2016
+ t.written > 0 && t.currClient !== e.id.client && An(t), t.written === 0 && (t.currClient = e.id.client, t.encoder.writeClient(e.id.client), p(t.encoder.restEncoder, e.id.clock + s)), e.write(t.encoder, s), t.written++;
2047
2017
  }, ds = (t) => {
2048
- vn(t);
2018
+ An(t);
2049
2019
  const e = t.encoder.restEncoder;
2050
2020
  p(e, t.clientStructs.length);
2051
2021
  for (let s = 0; s < t.clientStructs.length; s++) {
2052
2022
  const n = t.clientStructs[s];
2053
- p(e, n.written), mt(e, n.restEncoder);
2023
+ p(e, n.written), bt(e, n.restEncoder);
2054
2024
  }
2055
- }, ao = (t, e, s, n) => {
2025
+ }, co = (t, e, s, n) => {
2056
2026
  const i = new s(ie(t)), r = new hs(i, !1), o = new n(), c = new us(o);
2057
2027
  for (let l = r.curr; l !== null; l = r.next())
2058
- Q(c, e(l), 0);
2028
+ Z(c, e(l), 0);
2059
2029
  ds(c);
2060
2030
  const a = cs(i);
2061
2031
  return Ae(o, a), o.toUint8Array();
2062
- }, lo = (t) => ao(t, Ui, ve, Ge), Bs = "You must not compute changes after the event-handler fired.";
2063
- class _t {
2032
+ }, ao = (t) => co(t, Ri, ve, Xe), Hs = "You must not compute changes after the event-handler fired.";
2033
+ class yt {
2064
2034
  /**
2065
2035
  * @param {T} target The changed type.
2066
2036
  * @param {Transaction} transaction
@@ -2082,7 +2052,7 @@ class _t {
2082
2052
  * type === event.target // => true
2083
2053
  */
2084
2054
  get path() {
2085
- return this._path || (this._path = ho(this.currentTarget, this.target));
2055
+ return this._path || (this._path = lo(this.currentTarget, this.target));
2086
2056
  }
2087
2057
  /**
2088
2058
  * Check if a struct is deleted by this event.
@@ -2093,7 +2063,7 @@ class _t {
2093
2063
  * @return {boolean}
2094
2064
  */
2095
2065
  deletes(e) {
2096
- return un(this.transaction.deleteSet, e.id);
2066
+ return fn(this.transaction.deleteSet, e.id);
2097
2067
  }
2098
2068
  /**
2099
2069
  * @type {Map<string, { action: 'add' | 'update' | 'delete', oldValue: any, newValue: any }>}
@@ -2101,7 +2071,7 @@ class _t {
2101
2071
  get keys() {
2102
2072
  if (this._keys === null) {
2103
2073
  if (this.transaction.doc._transactionCleanups.length === 0)
2104
- throw X(Bs);
2074
+ throw G(Hs);
2105
2075
  const e = /* @__PURE__ */ new Map(), s = this.target;
2106
2076
  /** @type Set<string|null> */
2107
2077
  this.transaction.changed.get(s).forEach((i) => {
@@ -2169,7 +2139,7 @@ class _t {
2169
2139
  let e = this._changes;
2170
2140
  if (e === null) {
2171
2141
  if (this.transaction.doc._transactionCleanups.length === 0)
2172
- throw X(Bs);
2142
+ throw G(Hs);
2173
2143
  const s = this.target, n = le(), i = le(), r = [];
2174
2144
  if (e = {
2175
2145
  added: n,
@@ -2194,7 +2164,7 @@ class _t {
2194
2164
  );
2195
2165
  }
2196
2166
  }
2197
- const ho = (t, e) => {
2167
+ const lo = (t, e) => {
2198
2168
  const s = [];
2199
2169
  for (; e._item !== null && e !== t; ) {
2200
2170
  if (e._item.parentSub !== null)
@@ -2212,9 +2182,9 @@ const ho = (t, e) => {
2212
2182
  e._item.parent;
2213
2183
  }
2214
2184
  return s;
2215
- }, xn = 80;
2185
+ }, In = 80;
2216
2186
  let fs = 0;
2217
- class uo {
2187
+ class ho {
2218
2188
  /**
2219
2189
  * @param {Item} p
2220
2190
  * @param {number} index
@@ -2223,24 +2193,24 @@ class uo {
2223
2193
  e.marker = !0, this.p = e, this.index = s, this.timestamp = fs++;
2224
2194
  }
2225
2195
  }
2226
- const fo = (t) => {
2196
+ const uo = (t) => {
2227
2197
  t.timestamp = fs++;
2228
- }, An = (t, e, s) => {
2198
+ }, Ln = (t, e, s) => {
2229
2199
  t.p.marker = !1, t.p = e, e.marker = !0, t.index = s, t.timestamp = fs++;
2230
- }, go = (t, e, s) => {
2231
- if (t.length >= xn) {
2200
+ }, fo = (t, e, s) => {
2201
+ if (t.length >= In) {
2232
2202
  const n = t.reduce((i, r) => i.timestamp < r.timestamp ? i : r);
2233
- return An(n, e, s), n;
2203
+ return Ln(n, e, s), n;
2234
2204
  } else {
2235
- const n = new uo(e, s);
2205
+ const n = new ho(e, s);
2236
2206
  return t.push(n), n;
2237
2207
  }
2238
- }, St = (t, e) => {
2208
+ }, _t = (t, e) => {
2239
2209
  if (t._start === null || e === 0 || t._searchMarker === null)
2240
2210
  return null;
2241
- const s = t._searchMarker.length === 0 ? null : t._searchMarker.reduce((r, o) => nt(e - r.index) < nt(e - o.index) ? r : o);
2211
+ const s = t._searchMarker.length === 0 ? null : t._searchMarker.reduce((r, o) => st(e - r.index) < st(e - o.index) ? r : o);
2242
2212
  let n = t._start, i = 0;
2243
- for (s !== null && (n = s.p, i = s.index, fo(s)); n.right !== null && i < e; ) {
2213
+ for (s !== null && (n = s.p, i = s.index, uo(s)); n.right !== null && i < e; ) {
2244
2214
  if (!n.deleted && n.countable) {
2245
2215
  if (e < i + n.length)
2246
2216
  break;
@@ -2252,9 +2222,9 @@ const fo = (t) => {
2252
2222
  n = n.left, !n.deleted && n.countable && (i -= n.length);
2253
2223
  for (; n.left !== null && n.left.id.client === n.id.client && n.left.id.clock + n.left.length === n.id.clock; )
2254
2224
  n = n.left, !n.deleted && n.countable && (i -= n.length);
2255
- return s !== null && nt(s.index - i) < /** @type {YText|YArray<any>} */
2256
- n.parent.length / xn ? (An(s, n, i), s) : go(t._searchMarker, n, i);
2257
- }, $e = (t, e, s) => {
2225
+ return s !== null && st(s.index - i) < /** @type {YText|YArray<any>} */
2226
+ n.parent.length / In ? (Ln(s, n, i), s) : fo(t._searchMarker, n, i);
2227
+ }, Ve = (t, e, s) => {
2258
2228
  for (let n = t.length - 1; n >= 0; n--) {
2259
2229
  const i = t[n];
2260
2230
  if (s > 0) {
@@ -2269,16 +2239,16 @@ const fo = (t) => {
2269
2239
  }
2270
2240
  (e < i.index || s > 0 && e === i.index) && (i.index = pe(e, i.index + s));
2271
2241
  }
2272
- }, Dt = (t, e, s) => {
2242
+ }, St = (t, e, s) => {
2273
2243
  const n = t, i = e.changedParentTypes;
2274
- for (; G(i, t, () => []).push(s), t._item !== null; )
2244
+ for (; W(i, t, () => []).push(s), t._item !== null; )
2275
2245
  t = /** @type {AbstractType<any>} */
2276
2246
  t._item.parent;
2277
- _n(n._eH, s, e);
2247
+ Dn(n._eH, s, e);
2278
2248
  };
2279
2249
  class x {
2280
2250
  constructor() {
2281
- this._item = null, this._map = /* @__PURE__ */ new Map(), this._start = null, this.doc = null, this._length = 0, this._eH = Us(), this._dEH = Us(), this._searchMarker = null;
2251
+ this._item = null, this._map = /* @__PURE__ */ new Map(), this._start = null, this.doc = null, this._length = 0, this._eH = zs(), this._dEH = zs(), this._searchMarker = null;
2282
2252
  }
2283
2253
  /**
2284
2254
  * @return {AbstractType<any>|null}
@@ -2344,7 +2314,7 @@ class x {
2344
2314
  * @param {function(EventType, Transaction):void} f Observer function
2345
2315
  */
2346
2316
  observe(e) {
2347
- Ts(this._eH, e);
2317
+ Os(this._eH, e);
2348
2318
  }
2349
2319
  /**
2350
2320
  * Observe all events that are created by this type and its children.
@@ -2352,7 +2322,7 @@ class x {
2352
2322
  * @param {function(Array<YEvent<any>>,Transaction):void} f Observer function
2353
2323
  */
2354
2324
  observeDeep(e) {
2355
- Ts(this._dEH, e);
2325
+ Os(this._dEH, e);
2356
2326
  }
2357
2327
  /**
2358
2328
  * Unregister an observer function.
@@ -2360,7 +2330,7 @@ class x {
2360
2330
  * @param {function(EventType,Transaction):void} f Observer function
2361
2331
  */
2362
2332
  unobserve(e) {
2363
- zs(this._eH, e);
2333
+ Rs(this._eH, e);
2364
2334
  }
2365
2335
  /**
2366
2336
  * Unregister an observer function.
@@ -2368,7 +2338,7 @@ class x {
2368
2338
  * @param {function(Array<YEvent<any>>,Transaction):void} f Observer function
2369
2339
  */
2370
2340
  unobserveDeep(e) {
2371
- zs(this._dEH, e);
2341
+ Rs(this._dEH, e);
2372
2342
  }
2373
2343
  /**
2374
2344
  * @abstract
@@ -2377,7 +2347,7 @@ class x {
2377
2347
  toJSON() {
2378
2348
  }
2379
2349
  }
2380
- const In = (t, e, s) => {
2350
+ const jn = (t, e, s) => {
2381
2351
  e < 0 && (e = t._length + e), s < 0 && (s = t._length + s);
2382
2352
  let n = s - e;
2383
2353
  const i = [];
@@ -2396,7 +2366,7 @@ const In = (t, e, s) => {
2396
2366
  r = r.right;
2397
2367
  }
2398
2368
  return i;
2399
- }, Ln = (t) => {
2369
+ }, Mn = (t) => {
2400
2370
  const e = [];
2401
2371
  let s = t._start;
2402
2372
  for (; s !== null; ) {
@@ -2408,7 +2378,7 @@ const In = (t, e, s) => {
2408
2378
  s = s.right;
2409
2379
  }
2410
2380
  return e;
2411
- }, qe = (t, e) => {
2381
+ }, $e = (t, e) => {
2412
2382
  let s = 0, n = t._start;
2413
2383
  for (; n !== null; ) {
2414
2384
  if (n.countable && !n.deleted) {
@@ -2418,12 +2388,12 @@ const In = (t, e, s) => {
2418
2388
  }
2419
2389
  n = n.right;
2420
2390
  }
2421
- }, jn = (t, e) => {
2391
+ }, Tn = (t, e) => {
2422
2392
  const s = [];
2423
- return qe(t, (n, i) => {
2393
+ return $e(t, (n, i) => {
2424
2394
  s.push(e(n, i, t));
2425
2395
  }), s;
2426
- }, po = (t) => {
2396
+ }, go = (t) => {
2427
2397
  let e = t._start, s = null, n = 0;
2428
2398
  return {
2429
2399
  [Symbol.iterator]() {
@@ -2447,8 +2417,8 @@ const In = (t, e, s) => {
2447
2417
  };
2448
2418
  }
2449
2419
  };
2450
- }, Mn = (t, e) => {
2451
- const s = St(t, e);
2420
+ }, Un = (t, e) => {
2421
+ const s = _t(t, e);
2452
2422
  let n = t._start;
2453
2423
  for (s !== null && (n = s.p, e -= s.index); n !== null; n = n.right)
2454
2424
  if (!n.deleted && n.countable) {
@@ -2456,7 +2426,7 @@ const In = (t, e, s) => {
2456
2426
  return n.content.getContent()[e];
2457
2427
  e -= n.length;
2458
2428
  }
2459
- }, ht = (t, e, s, n) => {
2429
+ }, lt = (t, e, s, n) => {
2460
2430
  let i = s;
2461
2431
  const r = t.doc, o = r.clientID, c = r.store, a = s === null ? e._start : s.right;
2462
2432
  let l = [];
@@ -2479,31 +2449,31 @@ const In = (t, e, s) => {
2479
2449
  switch (h(), u.constructor) {
2480
2450
  case Uint8Array:
2481
2451
  case ArrayBuffer:
2482
- i = new D(w(o, v(c, o)), i, i && i.lastId, a, a && a.id, e, null, new We(new Uint8Array(
2452
+ i = new D(w(o, v(c, o)), i, i && i.lastId, a, a && a.id, e, null, new Ge(new Uint8Array(
2483
2453
  /** @type {Uint8Array} */
2484
2454
  u
2485
2455
  ))), i.integrate(t, 0);
2486
2456
  break;
2487
- case Ie:
2488
- i = new D(w(o, v(c, o)), i, i && i.lastId, a, a && a.id, e, null, new Pe(
2457
+ case ke:
2458
+ i = new D(w(o, v(c, o)), i, i && i.lastId, a, a && a.id, e, null, new We(
2489
2459
  /** @type {Doc} */
2490
2460
  u
2491
2461
  )), i.integrate(t, 0);
2492
2462
  break;
2493
2463
  default:
2494
2464
  if (u instanceof x)
2495
- i = new D(w(o, v(c, o)), i, i && i.lastId, a, a && a.id, e, null, new P(u)), i.integrate(t, 0);
2465
+ i = new D(w(o, v(c, o)), i, i && i.lastId, a, a && a.id, e, null, new Q(u)), i.integrate(t, 0);
2496
2466
  else
2497
2467
  throw new Error("Unexpected content type in insert operation");
2498
2468
  }
2499
2469
  }
2500
2470
  }), h();
2501
- }, Un = X("Length exceeded!"), Tn = (t, e, s, n) => {
2471
+ }, zn = G("Length exceeded!"), On = (t, e, s, n) => {
2502
2472
  if (s > e._length)
2503
- throw Un;
2473
+ throw zn;
2504
2474
  if (s === 0)
2505
- return e._searchMarker && $e(e._searchMarker, s, n.length), ht(t, e, null, n);
2506
- const i = s, r = St(e, s);
2475
+ return e._searchMarker && Ve(e._searchMarker, s, n.length), lt(t, e, null, n);
2476
+ const i = s, r = _t(e, s);
2507
2477
  let o = e._start;
2508
2478
  for (r !== null && (o = r.p, s -= r.index, s === 0 && (o = o.prev, s += o && o.countable && !o.deleted ? o.length : 0)); o !== null; o = o.right)
2509
2479
  if (!o.deleted && o.countable) {
@@ -2513,31 +2483,31 @@ const In = (t, e, s) => {
2513
2483
  }
2514
2484
  s -= o.length;
2515
2485
  }
2516
- return e._searchMarker && $e(e._searchMarker, i, n.length), ht(t, e, o, n);
2517
- }, ko = (t, e, s) => {
2486
+ return e._searchMarker && Ve(e._searchMarker, i, n.length), lt(t, e, o, n);
2487
+ }, po = (t, e, s) => {
2518
2488
  let i = (e._searchMarker || []).reduce((r, o) => o.index > r.index ? o : r, { index: 0, p: e._start }).p;
2519
2489
  if (i)
2520
2490
  for (; i.right; )
2521
2491
  i = i.right;
2522
- return ht(t, e, i, s);
2523
- }, zn = (t, e, s, n) => {
2492
+ return lt(t, e, i, s);
2493
+ }, Rn = (t, e, s, n) => {
2524
2494
  if (n === 0)
2525
2495
  return;
2526
- const i = s, r = n, o = St(e, s);
2496
+ const i = s, r = n, o = _t(e, s);
2527
2497
  let c = e._start;
2528
2498
  for (o !== null && (c = o.p, s -= o.index); c !== null && s > 0; c = c.right)
2529
2499
  !c.deleted && c.countable && (s < c.length && ne(t, w(c.id.client, c.id.clock + s)), s -= c.length);
2530
2500
  for (; n > 0 && c !== null; )
2531
2501
  c.deleted || (n < c.length && ne(t, w(c.id.client, c.id.clock + n)), c.delete(t), n -= c.length), c = c.right;
2532
2502
  if (n > 0)
2533
- throw Un;
2534
- e._searchMarker && $e(
2503
+ throw zn;
2504
+ e._searchMarker && Ve(
2535
2505
  e._searchMarker,
2536
2506
  i,
2537
2507
  -r + n
2538
2508
  /* in case we remove the above exception */
2539
2509
  );
2540
- }, ut = (t, e, s) => {
2510
+ }, ht = (t, e, s) => {
2541
2511
  const n = e._map.get(s);
2542
2512
  n !== void 0 && n.delete(t);
2543
2513
  }, gs = (t, e, s, n) => {
@@ -2555,20 +2525,20 @@ const In = (t, e, s) => {
2555
2525
  c = new ge([n]);
2556
2526
  break;
2557
2527
  case Uint8Array:
2558
- c = new We(
2528
+ c = new Ge(
2559
2529
  /** @type {Uint8Array} */
2560
2530
  n
2561
2531
  );
2562
2532
  break;
2563
- case Ie:
2564
- c = new Pe(
2533
+ case ke:
2534
+ c = new We(
2565
2535
  /** @type {Doc} */
2566
2536
  n
2567
2537
  );
2568
2538
  break;
2569
2539
  default:
2570
2540
  if (n instanceof x)
2571
- c = new P(n);
2541
+ c = new Q(n);
2572
2542
  else
2573
2543
  throw new Error("Unexpected content type");
2574
2544
  }
@@ -2576,20 +2546,20 @@ const In = (t, e, s) => {
2576
2546
  }, ps = (t, e) => {
2577
2547
  const s = t._map.get(e);
2578
2548
  return s !== void 0 && !s.deleted ? s.content.getContent()[s.length - 1] : void 0;
2579
- }, On = (t) => {
2549
+ }, Nn = (t) => {
2580
2550
  const e = {};
2581
2551
  return t._map.forEach((s, n) => {
2582
2552
  s.deleted || (e[n] = s.content.getContent()[s.length - 1]);
2583
2553
  }), e;
2584
- }, Rn = (t, e) => {
2554
+ }, Bn = (t, e) => {
2585
2555
  const s = t._map.get(e);
2586
2556
  return s !== void 0 && !s.deleted;
2587
- }, et = (t) => Tr(
2557
+ }, Ze = (t) => Tr(
2588
2558
  t.entries(),
2589
2559
  /** @param {any} entry */
2590
2560
  (e) => !e[1].deleted
2591
2561
  );
2592
- class mo extends _t {
2562
+ class ko extends yt {
2593
2563
  /**
2594
2564
  * @param {YArray<T>} yarray The changed type
2595
2565
  * @param {Transaction} transaction The transaction object
@@ -2598,7 +2568,7 @@ class mo extends _t {
2598
2568
  super(e, s), this._transaction = s;
2599
2569
  }
2600
2570
  }
2601
- class ye extends x {
2571
+ class _e extends x {
2602
2572
  constructor() {
2603
2573
  super(), this._prelimContent = [], this._searchMarker = [];
2604
2574
  }
@@ -2609,7 +2579,7 @@ class ye extends x {
2609
2579
  * @return {YArray<T>}
2610
2580
  */
2611
2581
  static from(e) {
2612
- const s = new ye();
2582
+ const s = new _e();
2613
2583
  return s.push(e), s;
2614
2584
  }
2615
2585
  /**
@@ -2633,13 +2603,13 @@ class ye extends x {
2633
2603
  * @return {YArray<T>}
2634
2604
  */
2635
2605
  _copy() {
2636
- return new ye();
2606
+ return new _e();
2637
2607
  }
2638
2608
  /**
2639
2609
  * @return {YArray<T>}
2640
2610
  */
2641
2611
  clone() {
2642
- const e = new ye();
2612
+ const e = new _e();
2643
2613
  return e.insert(0, this.toArray().map(
2644
2614
  (s) => s instanceof x ? (
2645
2615
  /** @type {typeof el} */
@@ -2657,7 +2627,7 @@ class ye extends x {
2657
2627
  * @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
2658
2628
  */
2659
2629
  _callObserver(e, s) {
2660
- super._callObserver(e, s), Dt(this, e, new mo(this, e));
2630
+ super._callObserver(e, s), St(this, e, new ko(this, e));
2661
2631
  }
2662
2632
  /**
2663
2633
  * Inserts new content at an index.
@@ -2677,7 +2647,7 @@ class ye extends x {
2677
2647
  */
2678
2648
  insert(e, s) {
2679
2649
  this.doc !== null ? y(this.doc, (n) => {
2680
- Tn(
2650
+ On(
2681
2651
  n,
2682
2652
  this,
2683
2653
  e,
@@ -2695,7 +2665,7 @@ class ye extends x {
2695
2665
  */
2696
2666
  push(e) {
2697
2667
  this.doc !== null ? y(this.doc, (s) => {
2698
- ko(
2668
+ po(
2699
2669
  s,
2700
2670
  this,
2701
2671
  /** @type {any} */
@@ -2719,7 +2689,7 @@ class ye extends x {
2719
2689
  */
2720
2690
  delete(e, s = 1) {
2721
2691
  this.doc !== null ? y(this.doc, (n) => {
2722
- zn(n, this, e, s);
2692
+ Rn(n, this, e, s);
2723
2693
  }) : this._prelimContent.splice(e, s);
2724
2694
  }
2725
2695
  /**
@@ -2729,7 +2699,7 @@ class ye extends x {
2729
2699
  * @return {T}
2730
2700
  */
2731
2701
  get(e) {
2732
- return Mn(this, e);
2702
+ return Un(this, e);
2733
2703
  }
2734
2704
  /**
2735
2705
  * Transforms this YArray to a JavaScript Array.
@@ -2737,7 +2707,7 @@ class ye extends x {
2737
2707
  * @return {Array<T>}
2738
2708
  */
2739
2709
  toArray() {
2740
- return Ln(this);
2710
+ return Mn(this);
2741
2711
  }
2742
2712
  /**
2743
2713
  * Transforms this YArray to a JavaScript Array.
@@ -2747,7 +2717,7 @@ class ye extends x {
2747
2717
  * @return {Array<T>}
2748
2718
  */
2749
2719
  slice(e = 0, s = this.length) {
2750
- return In(this, e, s);
2720
+ return jn(this, e, s);
2751
2721
  }
2752
2722
  /**
2753
2723
  * Transforms this Shared Type to a JSON object.
@@ -2767,7 +2737,7 @@ class ye extends x {
2767
2737
  * callback function
2768
2738
  */
2769
2739
  map(e) {
2770
- return jn(
2740
+ return Tn(
2771
2741
  this,
2772
2742
  /** @type {any} */
2773
2743
  e
@@ -2779,23 +2749,23 @@ class ye extends x {
2779
2749
  * @param {function(T,number,YArray<T>):void} f A function to execute on every element of this YArray.
2780
2750
  */
2781
2751
  forEach(e) {
2782
- qe(this, e);
2752
+ $e(this, e);
2783
2753
  }
2784
2754
  /**
2785
2755
  * @return {IterableIterator<T>}
2786
2756
  */
2787
2757
  [Symbol.iterator]() {
2788
- return po(this);
2758
+ return go(this);
2789
2759
  }
2790
2760
  /**
2791
2761
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
2792
2762
  */
2793
2763
  _write(e) {
2794
- e.writeTypeRef(Ho);
2764
+ e.writeTypeRef(Fo);
2795
2765
  }
2796
2766
  }
2797
- const bo = (t) => new ye();
2798
- class wo extends _t {
2767
+ const mo = (t) => new _e();
2768
+ class bo extends yt {
2799
2769
  /**
2800
2770
  * @param {YMap<T>} ymap The YArray that changed.
2801
2771
  * @param {Transaction} transaction
@@ -2853,7 +2823,7 @@ class de extends x {
2853
2823
  * @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
2854
2824
  */
2855
2825
  _callObserver(e, s) {
2856
- Dt(this, e, new wo(this, e, s));
2826
+ St(this, e, new bo(this, e, s));
2857
2827
  }
2858
2828
  /**
2859
2829
  * Transforms this Shared Type to a JSON object.
@@ -2875,7 +2845,7 @@ class de extends x {
2875
2845
  * @return {number}
2876
2846
  */
2877
2847
  get size() {
2878
- return [...et(this._map)].length;
2848
+ return [...Ze(this._map)].length;
2879
2849
  }
2880
2850
  /**
2881
2851
  * Returns the keys for each element in the YMap Type.
@@ -2883,8 +2853,8 @@ class de extends x {
2883
2853
  * @return {IterableIterator<string>}
2884
2854
  */
2885
2855
  keys() {
2886
- return Lt(
2887
- et(this._map),
2856
+ return It(
2857
+ Ze(this._map),
2888
2858
  /** @param {any} v */
2889
2859
  (e) => e[0]
2890
2860
  );
@@ -2895,8 +2865,8 @@ class de extends x {
2895
2865
  * @return {IterableIterator<any>}
2896
2866
  */
2897
2867
  values() {
2898
- return Lt(
2899
- et(this._map),
2868
+ return It(
2869
+ Ze(this._map),
2900
2870
  /** @param {any} v */
2901
2871
  (e) => e[1].content.getContent()[e[1].length - 1]
2902
2872
  );
@@ -2907,8 +2877,8 @@ class de extends x {
2907
2877
  * @return {IterableIterator<any>}
2908
2878
  */
2909
2879
  entries() {
2910
- return Lt(
2911
- et(this._map),
2880
+ return It(
2881
+ Ze(this._map),
2912
2882
  /** @param {any} v */
2913
2883
  (e) => [e[0], e[1].content.getContent()[e[1].length - 1]]
2914
2884
  );
@@ -2938,7 +2908,7 @@ class de extends x {
2938
2908
  */
2939
2909
  delete(e) {
2940
2910
  this.doc !== null ? y(this.doc, (s) => {
2941
- ut(s, this, e);
2911
+ ht(s, this, e);
2942
2912
  }) : this._prelimContent.delete(e);
2943
2913
  }
2944
2914
  /**
@@ -2979,7 +2949,7 @@ class de extends x {
2979
2949
  * @return {boolean}
2980
2950
  */
2981
2951
  has(e) {
2982
- return Rn(this, e);
2952
+ return Bn(this, e);
2983
2953
  }
2984
2954
  /**
2985
2955
  * Removes all elements from this YMap.
@@ -2987,7 +2957,7 @@ class de extends x {
2987
2957
  clear() {
2988
2958
  this.doc !== null ? y(this.doc, (e) => {
2989
2959
  this.forEach(function(s, n, i) {
2990
- ut(e, i, n);
2960
+ ht(e, i, n);
2991
2961
  });
2992
2962
  }) : this._prelimContent.clear();
2993
2963
  }
@@ -2995,11 +2965,11 @@ class de extends x {
2995
2965
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
2996
2966
  */
2997
2967
  _write(e) {
2998
- e.writeTypeRef(Vo);
2968
+ e.writeTypeRef(Ho);
2999
2969
  }
3000
2970
  }
3001
- const yo = (t) => new de(), Z = (t, e) => t === e || typeof t == "object" && typeof e == "object" && t && e && Mi(t, e);
3002
- class Yt {
2971
+ const wo = (t) => new de(), ee = (t, e) => t === e || typeof t == "object" && typeof e == "object" && t && e && Oi(t, e);
2972
+ class Kt {
3003
2973
  /**
3004
2974
  * @param {Item|null} left
3005
2975
  * @param {Item|null} right
@@ -3013,9 +2983,9 @@ class Yt {
3013
2983
  * Only call this if you know that this.right is defined
3014
2984
  */
3015
2985
  forward() {
3016
- switch (this.right === null && F(), this.right.content.constructor) {
3017
- case C:
3018
- this.right.deleted || Le(
2986
+ switch (this.right === null && H(), this.right.content.constructor) {
2987
+ case E:
2988
+ this.right.deleted || Ie(
3019
2989
  this.currentAttributes,
3020
2990
  /** @type {ContentFormat} */
3021
2991
  this.right.content
@@ -3028,11 +2998,11 @@ class Yt {
3028
2998
  this.left = this.right, this.right = this.right.right;
3029
2999
  }
3030
3000
  }
3031
- const Fs = (t, e, s) => {
3001
+ const Vs = (t, e, s) => {
3032
3002
  for (; e.right !== null && s > 0; ) {
3033
3003
  switch (e.right.content.constructor) {
3034
- case C:
3035
- e.right.deleted || Le(
3004
+ case E:
3005
+ e.right.deleted || Ie(
3036
3006
  e.currentAttributes,
3037
3007
  /** @type {ContentFormat} */
3038
3008
  e.right.content
@@ -3045,17 +3015,17 @@ const Fs = (t, e, s) => {
3045
3015
  e.left = e.right, e.right = e.right.right;
3046
3016
  }
3047
3017
  return e;
3048
- }, tt = (t, e, s) => {
3049
- const n = /* @__PURE__ */ new Map(), i = St(e, s);
3018
+ }, et = (t, e, s) => {
3019
+ const n = /* @__PURE__ */ new Map(), i = _t(e, s);
3050
3020
  if (i) {
3051
- const r = new Yt(i.p.left, i.p, i.index, n);
3052
- return Fs(t, r, s - i.index);
3021
+ const r = new Kt(i.p.left, i.p, i.index, n);
3022
+ return Vs(t, r, s - i.index);
3053
3023
  } else {
3054
- const r = new Yt(null, e._start, 0, n);
3055
- return Fs(t, r, s);
3024
+ const r = new Kt(null, e._start, 0, n);
3025
+ return Vs(t, r, s);
3056
3026
  }
3057
- }, Nn = (t, e, s, n) => {
3058
- for (; s.right !== null && (s.right.deleted === !0 || s.right.content.constructor === C && Z(
3027
+ }, Fn = (t, e, s, n) => {
3028
+ for (; s.right !== null && (s.right.deleted === !0 || s.right.content.constructor === E && ee(
3059
3029
  n.get(
3060
3030
  /** @type {ContentFormat} */
3061
3031
  s.right.content.key
@@ -3069,15 +3039,15 @@ const Fs = (t, e, s) => {
3069
3039
  ), s.forward();
3070
3040
  const i = t.doc, r = i.clientID;
3071
3041
  n.forEach((o, c) => {
3072
- const a = s.left, l = s.right, h = new D(w(r, v(i.store, r)), a, a && a.lastId, l, l && l.id, e, null, new C(c, o));
3042
+ const a = s.left, l = s.right, h = new D(w(r, v(i.store, r)), a, a && a.lastId, l, l && l.id, e, null, new E(c, o));
3073
3043
  h.integrate(t, 0), s.right = h, s.forward();
3074
3044
  });
3075
- }, Le = (t, e) => {
3045
+ }, Ie = (t, e) => {
3076
3046
  const { key: s, value: n } = e;
3077
3047
  n === null ? t.delete(s) : t.set(s, n);
3078
- }, Bn = (t, e) => {
3048
+ }, Hn = (t, e) => {
3079
3049
  for (; t.right !== null; ) {
3080
- if (!(t.right.deleted || t.right.content.constructor === C && Z(
3050
+ if (!(t.right.deleted || t.right.content.constructor === E && ee(
3081
3051
  e[
3082
3052
  /** @type {ContentFormat} */
3083
3053
  t.right.content.key
@@ -3088,44 +3058,44 @@ const Fs = (t, e, s) => {
3088
3058
  break;
3089
3059
  t.forward();
3090
3060
  }
3091
- }, Fn = (t, e, s, n) => {
3061
+ }, Vn = (t, e, s, n) => {
3092
3062
  const i = t.doc, r = i.clientID, o = /* @__PURE__ */ new Map();
3093
3063
  for (const c in n) {
3094
3064
  const a = n[c], l = s.currentAttributes.get(c) || null;
3095
- if (!Z(l, a)) {
3065
+ if (!ee(l, a)) {
3096
3066
  o.set(c, l);
3097
3067
  const { left: h, right: u } = s;
3098
- s.right = new D(w(r, v(i.store, r)), h, h && h.lastId, u, u && u.id, e, null, new C(c, a)), s.right.integrate(t, 0), s.forward();
3068
+ s.right = new D(w(r, v(i.store, r)), h, h && h.lastId, u, u && u.id, e, null, new E(c, a)), s.right.integrate(t, 0), s.forward();
3099
3069
  }
3100
3070
  }
3101
3071
  return o;
3102
- }, Mt = (t, e, s, n, i) => {
3072
+ }, jt = (t, e, s, n, i) => {
3103
3073
  s.currentAttributes.forEach((d, f) => {
3104
3074
  i[f] === void 0 && (i[f] = null);
3105
3075
  });
3106
3076
  const r = t.doc, o = r.clientID;
3107
- Bn(s, i);
3108
- const c = Fn(t, e, s, i), a = n.constructor === String ? new V(
3077
+ Hn(s, i);
3078
+ const c = Vn(t, e, s, i), a = n.constructor === String ? new $(
3109
3079
  /** @type {string} */
3110
3080
  n
3111
- ) : n instanceof x ? new P(n) : new ke(n);
3081
+ ) : n instanceof x ? new Q(n) : new me(n);
3112
3082
  let { left: l, right: h, index: u } = s;
3113
- e._searchMarker && $e(e._searchMarker, s.index, a.getLength()), h = new D(w(o, v(r.store, o)), l, l && l.lastId, h, h && h.id, e, null, a), h.integrate(t, 0), s.right = h, s.index = u, s.forward(), Nn(t, e, s, c);
3114
- }, Hs = (t, e, s, n, i) => {
3083
+ e._searchMarker && Ve(e._searchMarker, s.index, a.getLength()), h = new D(w(o, v(r.store, o)), l, l && l.lastId, h, h && h.id, e, null, a), h.integrate(t, 0), s.right = h, s.index = u, s.forward(), Fn(t, e, s, c);
3084
+ }, $s = (t, e, s, n, i) => {
3115
3085
  const r = t.doc, o = r.clientID;
3116
- Bn(s, i);
3117
- const c = Fn(t, e, s, i);
3086
+ Hn(s, i);
3087
+ const c = Vn(t, e, s, i);
3118
3088
  e:
3119
- for (; s.right !== null && (n > 0 || c.size > 0 && (s.right.deleted || s.right.content.constructor === C)); ) {
3089
+ for (; s.right !== null && (n > 0 || c.size > 0 && (s.right.deleted || s.right.content.constructor === E)); ) {
3120
3090
  if (!s.right.deleted)
3121
3091
  switch (s.right.content.constructor) {
3122
- case C: {
3092
+ case E: {
3123
3093
  const { key: a, value: l } = (
3124
3094
  /** @type {ContentFormat} */
3125
3095
  s.right.content
3126
3096
  ), h = i[a];
3127
3097
  if (h !== void 0) {
3128
- if (Z(h, l))
3098
+ if (ee(h, l))
3129
3099
  c.delete(a);
3130
3100
  else {
3131
3101
  if (n === 0)
@@ -3148,14 +3118,14 @@ const Fs = (t, e, s) => {
3148
3118
  for (; n > 0; n--)
3149
3119
  a += `
3150
3120
  `;
3151
- s.right = new D(w(o, v(r.store, o)), s.left, s.left && s.left.lastId, s.right, s.right && s.right.id, e, null, new V(a)), s.right.integrate(t, 0), s.forward();
3121
+ s.right = new D(w(o, v(r.store, o)), s.left, s.left && s.left.lastId, s.right, s.right && s.right.id, e, null, new $(a)), s.right.integrate(t, 0), s.forward();
3152
3122
  }
3153
- Nn(t, e, s, c);
3154
- }, Hn = (t, e, s, n, i) => {
3123
+ Fn(t, e, s, c);
3124
+ }, $n = (t, e, s, n, i) => {
3155
3125
  let r = e;
3156
3126
  const o = O();
3157
3127
  for (; r && (!r.countable || r.deleted); ) {
3158
- if (!r.deleted && r.content.constructor === C) {
3128
+ if (!r.deleted && r.content.constructor === E) {
3159
3129
  const l = (
3160
3130
  /** @type {ContentFormat} */
3161
3131
  r.content
@@ -3169,12 +3139,12 @@ const Fs = (t, e, s) => {
3169
3139
  if (s === e && (a = !0), !e.deleted) {
3170
3140
  const l = e.content;
3171
3141
  switch (l.constructor) {
3172
- case C: {
3142
+ case E: {
3173
3143
  const { key: h, value: u } = (
3174
3144
  /** @type {ContentFormat} */
3175
3145
  l
3176
3146
  ), d = n.get(h) || null;
3177
- (o.get(h) !== l || d === u) && (e.delete(t), c++, !a && (i.get(h) || null) === u && d !== u && (d === null ? i.delete(h) : i.set(h, d))), !a && !e.deleted && Le(
3147
+ (o.get(h) !== l || d === u) && (e.delete(t), c++, !a && (i.get(h) || null) === u && d !== u && (d === null ? i.delete(h) : i.set(h, d))), !a && !e.deleted && Ie(
3178
3148
  i,
3179
3149
  /** @type {ContentFormat} */
3180
3150
  l
@@ -3187,12 +3157,12 @@ const Fs = (t, e, s) => {
3187
3157
  e.right;
3188
3158
  }
3189
3159
  return c;
3190
- }, _o = (t, e) => {
3160
+ }, yo = (t, e) => {
3191
3161
  for (; e && e.right && (e.right.deleted || !e.right.countable); )
3192
3162
  e = e.right;
3193
3163
  const s = /* @__PURE__ */ new Set();
3194
3164
  for (; e && (e.deleted || !e.countable); ) {
3195
- if (!e.deleted && e.content.constructor === C) {
3165
+ if (!e.deleted && e.content.constructor === E) {
3196
3166
  const n = (
3197
3167
  /** @type {ContentFormat} */
3198
3168
  e.content.key
@@ -3201,7 +3171,7 @@ const Fs = (t, e, s) => {
3201
3171
  }
3202
3172
  e = e.left;
3203
3173
  }
3204
- }, So = (t) => {
3174
+ }, _o = (t) => {
3205
3175
  let e = 0;
3206
3176
  return y(
3207
3177
  /** @type {Doc} */
@@ -3211,30 +3181,30 @@ const Fs = (t, e, s) => {
3211
3181
  /** @type {Item} */
3212
3182
  t._start
3213
3183
  ), i = t._start, r = O();
3214
- const o = Nt(r);
3184
+ const o = Rt(r);
3215
3185
  for (; i; ) {
3216
3186
  if (i.deleted === !1)
3217
3187
  switch (i.content.constructor) {
3218
- case C:
3219
- Le(
3188
+ case E:
3189
+ Ie(
3220
3190
  o,
3221
3191
  /** @type {ContentFormat} */
3222
3192
  i.content
3223
3193
  );
3224
3194
  break;
3225
3195
  default:
3226
- e += Hn(s, n, i, r, o), r = Nt(o), n = i;
3196
+ e += $n(s, n, i, r, o), r = Rt(o), n = i;
3227
3197
  break;
3228
3198
  }
3229
3199
  i = i.right;
3230
3200
  }
3231
3201
  }
3232
3202
  ), e;
3233
- }, Do = (t) => {
3203
+ }, So = (t) => {
3234
3204
  const e = /* @__PURE__ */ new Set(), s = t.doc;
3235
3205
  for (const [n, i] of t.afterState.entries()) {
3236
3206
  const r = t.beforeState.get(n) || 0;
3237
- i !== r && Cn(
3207
+ i !== r && vn(
3238
3208
  t,
3239
3209
  /** @type {Array<Item|GC>} */
3240
3210
  s.store.clients.get(n),
@@ -3242,7 +3212,7 @@ const Fs = (t, e, s) => {
3242
3212
  i,
3243
3213
  (o) => {
3244
3214
  !o.deleted && /** @type {Item} */
3245
- o.content.constructor === C && o.constructor !== T && e.add(
3215
+ o.content.constructor === E && o.constructor !== U && e.add(
3246
3216
  /** @type {any} */
3247
3217
  o.parent
3248
3218
  );
@@ -3250,8 +3220,8 @@ const Fs = (t, e, s) => {
3250
3220
  );
3251
3221
  }
3252
3222
  y(s, (n) => {
3253
- hn(t, t.deleteSet, (i) => {
3254
- if (i instanceof T || !/** @type {YText} */
3223
+ dn(t, t.deleteSet, (i) => {
3224
+ if (i instanceof U || !/** @type {YText} */
3255
3225
  i.parent._hasFormatting || e.has(
3256
3226
  /** @type {YText} */
3257
3227
  i.parent
@@ -3261,33 +3231,33 @@ const Fs = (t, e, s) => {
3261
3231
  /** @type {YText} */
3262
3232
  i.parent
3263
3233
  );
3264
- i.content.constructor === C ? e.add(r) : _o(n, i);
3234
+ i.content.constructor === E ? e.add(r) : yo(n, i);
3265
3235
  });
3266
3236
  for (const i of e)
3267
- So(i);
3237
+ _o(i);
3268
3238
  });
3269
- }, Vs = (t, e, s) => {
3270
- const n = s, i = Nt(e.currentAttributes), r = e.right;
3239
+ }, qs = (t, e, s) => {
3240
+ const n = s, i = Rt(e.currentAttributes), r = e.right;
3271
3241
  for (; s > 0 && e.right !== null; ) {
3272
3242
  if (e.right.deleted === !1)
3273
3243
  switch (e.right.content.constructor) {
3274
- case P:
3275
- case ke:
3276
- case V:
3244
+ case Q:
3245
+ case me:
3246
+ case $:
3277
3247
  s < e.right.length && ne(t, w(e.right.id.client, e.right.id.clock + s)), s -= e.right.length, e.right.delete(t);
3278
3248
  break;
3279
3249
  }
3280
3250
  e.forward();
3281
3251
  }
3282
- r && Hn(t, r, e.right, i, e.currentAttributes);
3252
+ r && $n(t, r, e.right, i, e.currentAttributes);
3283
3253
  const o = (
3284
3254
  /** @type {AbstractType<any>} */
3285
3255
  /** @type {Item} */
3286
3256
  (e.left || e.right).parent
3287
3257
  );
3288
- return o._searchMarker && $e(o._searchMarker, e.index, -n + s), e;
3258
+ return o._searchMarker && Ve(o._searchMarker, e.index, -n + s), e;
3289
3259
  };
3290
- class Co extends _t {
3260
+ class Do extends yt {
3291
3261
  /**
3292
3262
  * @param {YText} ytext
3293
3263
  * @param {Transaction} transaction
@@ -3348,7 +3318,7 @@ class Co extends _t {
3348
3318
  }))), l = "";
3349
3319
  break;
3350
3320
  case "retain":
3351
- h > 0 && (f = { retain: h }, Li(a) || (f.attributes = vi({}, a))), h = 0;
3321
+ h > 0 && (f = { retain: h }, Ui(a) || (f.attributes = Li({}, a))), h = 0;
3352
3322
  break;
3353
3323
  }
3354
3324
  f && s.push(f), c = null;
@@ -3356,15 +3326,15 @@ class Co extends _t {
3356
3326
  };
3357
3327
  for (; o !== null; ) {
3358
3328
  switch (o.content.constructor) {
3359
- case P:
3360
- case ke:
3329
+ case Q:
3330
+ case me:
3361
3331
  this.adds(o) ? this.deletes(o) || (d(), c = "insert", l = o.content.getContent()[0], d()) : this.deletes(o) ? (c !== "delete" && (d(), c = "delete"), u += 1) : o.deleted || (c !== "retain" && (d(), c = "retain"), h += 1);
3362
3332
  break;
3363
- case V:
3333
+ case $:
3364
3334
  this.adds(o) ? this.deletes(o) || (c !== "insert" && (d(), c = "insert"), l += /** @type {ContentString} */
3365
3335
  o.content.str) : this.deletes(o) ? (c !== "delete" && (d(), c = "delete"), u += o.length) : o.deleted || (c !== "retain" && (d(), c = "retain"), h += o.length);
3366
3336
  break;
3367
- case C: {
3337
+ case E: {
3368
3338
  const { key: f, value: g } = (
3369
3339
  /** @type {ContentFormat} */
3370
3340
  o.content
@@ -3372,18 +3342,18 @@ class Co extends _t {
3372
3342
  if (this.adds(o)) {
3373
3343
  if (!this.deletes(o)) {
3374
3344
  const m = i.get(f) || null;
3375
- Z(m, g) ? g !== null && o.delete(n) : (c === "retain" && d(), Z(g, r.get(f) || null) ? delete a[f] : a[f] = g);
3345
+ ee(m, g) ? g !== null && o.delete(n) : (c === "retain" && d(), ee(g, r.get(f) || null) ? delete a[f] : a[f] = g);
3376
3346
  }
3377
3347
  } else if (this.deletes(o)) {
3378
3348
  r.set(f, g);
3379
3349
  const m = i.get(f) || null;
3380
- Z(m, g) || (c === "retain" && d(), a[f] = m);
3350
+ ee(m, g) || (c === "retain" && d(), a[f] = m);
3381
3351
  } else if (!o.deleted) {
3382
3352
  r.set(f, g);
3383
3353
  const m = a[f];
3384
- m !== void 0 && (Z(m, g) ? m !== null && o.delete(n) : (c === "retain" && d(), g === null ? delete a[f] : a[f] = g));
3354
+ m !== void 0 && (ee(m, g) ? m !== null && o.delete(n) : (c === "retain" && d(), g === null ? delete a[f] : a[f] = g));
3385
3355
  }
3386
- o.deleted || (c === "insert" && d(), Le(
3356
+ o.deleted || (c === "insert" && d(), Ie(
3387
3357
  i,
3388
3358
  /** @type {ContentFormat} */
3389
3359
  o.content
@@ -3454,8 +3424,8 @@ class xe extends x {
3454
3424
  */
3455
3425
  _callObserver(e, s) {
3456
3426
  super._callObserver(e, s);
3457
- const n = new Co(this, e, s);
3458
- Dt(this, e, n), !e.local && this._hasFormatting && (e._needFormattingCleanup = !0);
3427
+ const n = new Do(this, e, s);
3428
+ St(this, e, n), !e.local && this._hasFormatting && (e._needFormattingCleanup = !0);
3459
3429
  }
3460
3430
  /**
3461
3431
  * Returns the unformatted string representation of this YText type.
@@ -3465,7 +3435,7 @@ class xe extends x {
3465
3435
  toString() {
3466
3436
  let e = "", s = this._start;
3467
3437
  for (; s !== null; )
3468
- !s.deleted && s.countable && s.content.constructor === V && (e += /** @type {ContentString} */
3438
+ !s.deleted && s.countable && s.content.constructor === $ && (e += /** @type {ContentString} */
3469
3439
  s.content.str), s = s.right;
3470
3440
  return e;
3471
3441
  }
@@ -3490,15 +3460,15 @@ class xe extends x {
3490
3460
  */
3491
3461
  applyDelta(e, { sanitize: s = !0 } = {}) {
3492
3462
  this.doc !== null ? y(this.doc, (n) => {
3493
- const i = new Yt(null, this._start, 0, /* @__PURE__ */ new Map());
3463
+ const i = new Kt(null, this._start, 0, /* @__PURE__ */ new Map());
3494
3464
  for (let r = 0; r < e.length; r++) {
3495
3465
  const o = e[r];
3496
3466
  if (o.insert !== void 0) {
3497
3467
  const c = !s && typeof o.insert == "string" && r === e.length - 1 && i.right === null && o.insert.slice(-1) === `
3498
3468
  ` ? o.insert.slice(0, -1) : o.insert;
3499
- (typeof c != "string" || c.length > 0) && Mt(n, this, i, c, o.attributes || {});
3469
+ (typeof c != "string" || c.length > 0) && jt(n, this, i, c, o.attributes || {});
3500
3470
  } else
3501
- o.retain !== void 0 ? Hs(n, this, i, o.retain, o.attributes || {}) : o.delete !== void 0 && Vs(n, i, o.delete);
3471
+ o.retain !== void 0 ? $s(n, this, i, o.retain, o.attributes || {}) : o.delete !== void 0 && qs(n, i, o.delete);
3502
3472
  }
3503
3473
  }) : this._pending.push(() => this.applyDelta(e));
3504
3474
  }
@@ -3533,14 +3503,14 @@ class xe extends x {
3533
3503
  for (; a !== null; ) {
3534
3504
  if (Te(a, e) || s !== void 0 && Te(a, s))
3535
3505
  switch (a.content.constructor) {
3536
- case V: {
3506
+ case $: {
3537
3507
  const u = r.get("ychange");
3538
3508
  e !== void 0 && !Te(a, e) ? (u === void 0 || u.user !== a.id.client || u.type !== "removed") && (l(), r.set("ychange", n ? n("removed", a.id) : { type: "removed" })) : s !== void 0 && !Te(a, s) ? (u === void 0 || u.user !== a.id.client || u.type !== "added") && (l(), r.set("ychange", n ? n("added", a.id) : { type: "added" })) : u !== void 0 && (l(), r.delete("ychange")), c += /** @type {ContentString} */
3539
3509
  a.content.str;
3540
3510
  break;
3541
3511
  }
3542
- case P:
3543
- case ke: {
3512
+ case Q:
3513
+ case me: {
3544
3514
  l();
3545
3515
  const u = {
3546
3516
  insert: a.content.getContent()[0]
@@ -3557,8 +3527,8 @@ class xe extends x {
3557
3527
  i.push(u);
3558
3528
  break;
3559
3529
  }
3560
- case C:
3561
- Te(a, e) && (l(), Le(
3530
+ case E:
3531
+ Te(a, e) && (l(), Ie(
3562
3532
  r,
3563
3533
  /** @type {ContentFormat} */
3564
3534
  a.content
@@ -3570,7 +3540,7 @@ class xe extends x {
3570
3540
  l();
3571
3541
  };
3572
3542
  return e || s ? y(o, (u) => {
3573
- e && qt(u, e), s && qt(u, s), h();
3543
+ e && $t(u, e), s && $t(u, s), h();
3574
3544
  }, "cleanup") : h(), i;
3575
3545
  }
3576
3546
  /**
@@ -3588,10 +3558,10 @@ class xe extends x {
3588
3558
  return;
3589
3559
  const i = this.doc;
3590
3560
  i !== null ? y(i, (r) => {
3591
- const o = tt(r, this, e);
3561
+ const o = et(r, this, e);
3592
3562
  n || (n = {}, o.currentAttributes.forEach((c, a) => {
3593
3563
  n[a] = c;
3594
- })), Mt(r, this, o, s, n);
3564
+ })), jt(r, this, o, s, n);
3595
3565
  }) : this._pending.push(() => this.insert(e, s, n));
3596
3566
  }
3597
3567
  /**
@@ -3607,8 +3577,8 @@ class xe extends x {
3607
3577
  insertEmbed(e, s, n = {}) {
3608
3578
  const i = this.doc;
3609
3579
  i !== null ? y(i, (r) => {
3610
- const o = tt(r, this, e);
3611
- Mt(r, this, o, s, n);
3580
+ const o = et(r, this, e);
3581
+ jt(r, this, o, s, n);
3612
3582
  }) : this._pending.push(() => this.insertEmbed(e, s, n));
3613
3583
  }
3614
3584
  /**
@@ -3624,7 +3594,7 @@ class xe extends x {
3624
3594
  return;
3625
3595
  const n = this.doc;
3626
3596
  n !== null ? y(n, (i) => {
3627
- Vs(i, tt(i, this, e), s);
3597
+ qs(i, et(i, this, e), s);
3628
3598
  }) : this._pending.push(() => this.delete(e, s));
3629
3599
  }
3630
3600
  /**
@@ -3642,8 +3612,8 @@ class xe extends x {
3642
3612
  return;
3643
3613
  const i = this.doc;
3644
3614
  i !== null ? y(i, (r) => {
3645
- const o = tt(r, this, e);
3646
- o.right !== null && Hs(r, this, o, s, n);
3615
+ const o = et(r, this, e);
3616
+ o.right !== null && $s(r, this, o, s, n);
3647
3617
  }) : this._pending.push(() => this.format(e, s, n));
3648
3618
  }
3649
3619
  /**
@@ -3657,7 +3627,7 @@ class xe extends x {
3657
3627
  */
3658
3628
  removeAttribute(e) {
3659
3629
  this.doc !== null ? y(this.doc, (s) => {
3660
- ut(s, this, e);
3630
+ ht(s, this, e);
3661
3631
  }) : this._pending.push(() => this.removeAttribute(e));
3662
3632
  }
3663
3633
  /**
@@ -3702,17 +3672,17 @@ class xe extends x {
3702
3672
  * @public
3703
3673
  */
3704
3674
  getAttributes() {
3705
- return On(this);
3675
+ return Nn(this);
3706
3676
  }
3707
3677
  /**
3708
3678
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
3709
3679
  */
3710
3680
  _write(e) {
3711
- e.writeTypeRef($o);
3681
+ e.writeTypeRef(Vo);
3712
3682
  }
3713
3683
  }
3714
3684
  const Eo = (t) => new xe();
3715
- class Ut {
3685
+ class Mt {
3716
3686
  /**
3717
3687
  * @param {YXmlFragment | YXmlElement} root
3718
3688
  * @param {function(AbstractType<any>):boolean} [f]
@@ -3737,7 +3707,7 @@ class Ut {
3737
3707
  if (e !== null && (!this._firstCall || e.deleted || !this._filter(s)))
3738
3708
  do
3739
3709
  if (s = /** @type {any} */
3740
- e.content.type, !e.deleted && (s.constructor === Ke || s.constructor === fe) && s._start !== null)
3710
+ e.content.type, !e.deleted && (s.constructor === qe || s.constructor === fe) && s._start !== null)
3741
3711
  e = s._start;
3742
3712
  else
3743
3713
  for (; e !== null; )
@@ -3816,7 +3786,7 @@ class fe extends x {
3816
3786
  * @public
3817
3787
  */
3818
3788
  createTreeWalker(e) {
3819
- return new Ut(this, e);
3789
+ return new Mt(this, e);
3820
3790
  }
3821
3791
  /**
3822
3792
  * Returns the first YXmlElement that matches the query.
@@ -3835,7 +3805,7 @@ class fe extends x {
3835
3805
  */
3836
3806
  querySelector(e) {
3837
3807
  e = e.toUpperCase();
3838
- const n = new Ut(this, (i) => i.nodeName && i.nodeName.toUpperCase() === e).next();
3808
+ const n = new Mt(this, (i) => i.nodeName && i.nodeName.toUpperCase() === e).next();
3839
3809
  return n.done ? null : n.value;
3840
3810
  }
3841
3811
  /**
@@ -3850,7 +3820,7 @@ class fe extends x {
3850
3820
  * @public
3851
3821
  */
3852
3822
  querySelectorAll(e) {
3853
- return e = e.toUpperCase(), se(new Ut(this, (s) => s.nodeName && s.nodeName.toUpperCase() === e));
3823
+ return e = e.toUpperCase(), se(new Mt(this, (s) => s.nodeName && s.nodeName.toUpperCase() === e));
3854
3824
  }
3855
3825
  /**
3856
3826
  * Creates YXmlEvent and calls observers.
@@ -3859,7 +3829,7 @@ class fe extends x {
3859
3829
  * @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
3860
3830
  */
3861
3831
  _callObserver(e, s) {
3862
- Dt(this, e, new Ao(this, s, e));
3832
+ St(this, e, new xo(this, s, e));
3863
3833
  }
3864
3834
  /**
3865
3835
  * Get the string representation of all the children of this YXmlFragment.
@@ -3867,7 +3837,7 @@ class fe extends x {
3867
3837
  * @return {string} The string representation of all children.
3868
3838
  */
3869
3839
  toString() {
3870
- return jn(this, (e) => e.toString()).join("");
3840
+ return Tn(this, (e) => e.toString()).join("");
3871
3841
  }
3872
3842
  /**
3873
3843
  * @return {string}
@@ -3892,7 +3862,7 @@ class fe extends x {
3892
3862
  */
3893
3863
  toDOM(e = document, s = {}, n) {
3894
3864
  const i = e.createDocumentFragment();
3895
- return n !== void 0 && n._createAssociation(i, this), qe(this, (r) => {
3865
+ return n !== void 0 && n._createAssociation(i, this), $e(this, (r) => {
3896
3866
  i.insertBefore(r.toDOM(e, s, n), null);
3897
3867
  }), i;
3898
3868
  }
@@ -3908,7 +3878,7 @@ class fe extends x {
3908
3878
  */
3909
3879
  insert(e, s) {
3910
3880
  this.doc !== null ? y(this.doc, (n) => {
3911
- Tn(n, this, e, s);
3881
+ On(n, this, e, s);
3912
3882
  }) : this._prelimContent.splice(e, 0, ...s);
3913
3883
  }
3914
3884
  /**
@@ -3925,7 +3895,7 @@ class fe extends x {
3925
3895
  if (this.doc !== null)
3926
3896
  y(this.doc, (n) => {
3927
3897
  const i = e && e instanceof x ? e._item : e;
3928
- ht(n, this, i, s);
3898
+ lt(n, this, i, s);
3929
3899
  });
3930
3900
  else {
3931
3901
  const n = (
@@ -3933,7 +3903,7 @@ class fe extends x {
3933
3903
  this._prelimContent
3934
3904
  ), i = e === null ? 0 : n.findIndex((r) => r === e) + 1;
3935
3905
  if (i === 0 && e !== null)
3936
- throw X("Reference item not found");
3906
+ throw G("Reference item not found");
3937
3907
  n.splice(i, 0, ...s);
3938
3908
  }
3939
3909
  }
@@ -3945,7 +3915,7 @@ class fe extends x {
3945
3915
  */
3946
3916
  delete(e, s = 1) {
3947
3917
  this.doc !== null ? y(this.doc, (n) => {
3948
- zn(n, this, e, s);
3918
+ Rn(n, this, e, s);
3949
3919
  }) : this._prelimContent.splice(e, s);
3950
3920
  }
3951
3921
  /**
@@ -3954,7 +3924,7 @@ class fe extends x {
3954
3924
  * @return {Array<YXmlElement|YXmlText|YXmlHook>}
3955
3925
  */
3956
3926
  toArray() {
3957
- return Ln(this);
3927
+ return Mn(this);
3958
3928
  }
3959
3929
  /**
3960
3930
  * Appends content to this YArray.
@@ -3979,7 +3949,7 @@ class fe extends x {
3979
3949
  * @return {YXmlElement|YXmlText}
3980
3950
  */
3981
3951
  get(e) {
3982
- return Mn(this, e);
3952
+ return Un(this, e);
3983
3953
  }
3984
3954
  /**
3985
3955
  * Transforms this YArray to a JavaScript Array.
@@ -3989,7 +3959,7 @@ class fe extends x {
3989
3959
  * @return {Array<YXmlElement|YXmlText>}
3990
3960
  */
3991
3961
  slice(e = 0, s = this.length) {
3992
- return In(this, e, s);
3962
+ return jn(this, e, s);
3993
3963
  }
3994
3964
  /**
3995
3965
  * Executes a provided function on once on overy child element.
@@ -3997,7 +3967,7 @@ class fe extends x {
3997
3967
  * @param {function(YXmlElement|YXmlText,number, typeof self):void} f A function to execute on every element of this YArray.
3998
3968
  */
3999
3969
  forEach(e) {
4000
- qe(this, e);
3970
+ $e(this, e);
4001
3971
  }
4002
3972
  /**
4003
3973
  * Transform the properties of this type to binary and write it to an
@@ -4008,11 +3978,11 @@ class fe extends x {
4008
3978
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
4009
3979
  */
4010
3980
  _write(e) {
4011
- e.writeTypeRef(Ko);
3981
+ e.writeTypeRef(qo);
4012
3982
  }
4013
3983
  }
4014
- const vo = (t) => new fe();
4015
- class Ke extends fe {
3984
+ const Co = (t) => new fe();
3985
+ class qe extends fe {
4016
3986
  constructor(e = "UNDEFINED") {
4017
3987
  super(), this.nodeName = e, this._prelimAttrs = /* @__PURE__ */ new Map();
4018
3988
  }
@@ -4060,14 +4030,14 @@ class Ke extends fe {
4060
4030
  * @return {YXmlElement}
4061
4031
  */
4062
4032
  _copy() {
4063
- return new Ke(this.nodeName);
4033
+ return new qe(this.nodeName);
4064
4034
  }
4065
4035
  /**
4066
4036
  * @return {YXmlElement<KV>}
4067
4037
  */
4068
4038
  clone() {
4069
- const e = new Ke(this.nodeName), s = this.getAttributes();
4070
- return Ai(s, (n, i) => {
4039
+ const e = new qe(this.nodeName), s = this.getAttributes();
4040
+ return Mi(s, (n, i) => {
4071
4041
  typeof n == "string" && e.setAttribute(i, n);
4072
4042
  }), e.insert(0, this.toArray().map((n) => n instanceof x ? n.clone() : n)), e;
4073
4043
  }
@@ -4102,7 +4072,7 @@ class Ke extends fe {
4102
4072
  */
4103
4073
  removeAttribute(e) {
4104
4074
  this.doc !== null ? y(this.doc, (s) => {
4105
- ut(s, this, e);
4075
+ ht(s, this, e);
4106
4076
  }) : this._prelimAttrs.delete(e);
4107
4077
  }
4108
4078
  /**
@@ -4148,7 +4118,7 @@ class Ke extends fe {
4148
4118
  hasAttribute(e) {
4149
4119
  return (
4150
4120
  /** @type {any} */
4151
- Rn(this, e)
4121
+ Bn(this, e)
4152
4122
  );
4153
4123
  }
4154
4124
  /**
@@ -4161,7 +4131,7 @@ class Ke extends fe {
4161
4131
  getAttributes() {
4162
4132
  return (
4163
4133
  /** @type {any} */
4164
- On(this)
4134
+ Nn(this)
4165
4135
  );
4166
4136
  }
4167
4137
  /**
@@ -4185,7 +4155,7 @@ class Ke extends fe {
4185
4155
  const c = r[o];
4186
4156
  typeof c == "string" && i.setAttribute(o, c);
4187
4157
  }
4188
- return qe(this, (o) => {
4158
+ return $e(this, (o) => {
4189
4159
  i.appendChild(o.toDOM(e, s, n));
4190
4160
  }), n !== void 0 && n._createAssociation(i, this), i;
4191
4161
  }
@@ -4198,11 +4168,11 @@ class Ke extends fe {
4198
4168
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
4199
4169
  */
4200
4170
  _write(e) {
4201
- e.writeTypeRef(qo), e.writeKey(this.nodeName);
4171
+ e.writeTypeRef($o), e.writeKey(this.nodeName);
4202
4172
  }
4203
4173
  }
4204
- const xo = (t) => new Ke(t.readKey());
4205
- class Ao extends _t {
4174
+ const vo = (t) => new qe(t.readKey());
4175
+ class xo extends yt {
4206
4176
  /**
4207
4177
  * @param {YXmlElement|YXmlText|YXmlFragment} target The target on which the event is created.
4208
4178
  * @param {Set<string|null>} subs The set of changed attributes. `null` is included if the
@@ -4216,7 +4186,7 @@ class Ao extends _t {
4216
4186
  });
4217
4187
  }
4218
4188
  }
4219
- class dt extends de {
4189
+ class ut extends de {
4220
4190
  /**
4221
4191
  * @param {string} hookName nodeName of the Dom Node.
4222
4192
  */
@@ -4227,13 +4197,13 @@ class dt extends de {
4227
4197
  * Creates an Item with the same effect as this Item (without position effect)
4228
4198
  */
4229
4199
  _copy() {
4230
- return new dt(this.hookName);
4200
+ return new ut(this.hookName);
4231
4201
  }
4232
4202
  /**
4233
4203
  * @return {YXmlHook}
4234
4204
  */
4235
4205
  clone() {
4236
- const e = new dt(this.hookName);
4206
+ const e = new ut(this.hookName);
4237
4207
  return this.forEach((s, n) => {
4238
4208
  e.set(n, s);
4239
4209
  }), e;
@@ -4267,11 +4237,11 @@ class dt extends de {
4267
4237
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
4268
4238
  */
4269
4239
  _write(e) {
4270
- e.writeTypeRef(Yo), e.writeKey(this.hookName);
4240
+ e.writeTypeRef(Ko), e.writeKey(this.hookName);
4271
4241
  }
4272
4242
  }
4273
- const Io = (t) => new dt(t.readKey());
4274
- class ft extends xe {
4243
+ const Ao = (t) => new ut(t.readKey());
4244
+ class dt extends xe {
4275
4245
  /**
4276
4246
  * @type {YXmlElement|YXmlText|null}
4277
4247
  */
@@ -4295,13 +4265,13 @@ class ft extends xe {
4295
4265
  ) : null;
4296
4266
  }
4297
4267
  _copy() {
4298
- return new ft();
4268
+ return new dt();
4299
4269
  }
4300
4270
  /**
4301
4271
  * @return {YXmlText}
4302
4272
  */
4303
4273
  clone() {
4304
- const e = new ft();
4274
+ const e = new dt();
4305
4275
  return e.applyDelta(this.toDelta()), e;
4306
4276
  }
4307
4277
  /**
@@ -4359,10 +4329,10 @@ class ft extends xe {
4359
4329
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
4360
4330
  */
4361
4331
  _write(e) {
4362
- e.writeTypeRef(Jo);
4332
+ e.writeTypeRef(Yo);
4363
4333
  }
4364
4334
  }
4365
- const Lo = (t) => new ft();
4335
+ const Io = (t) => new dt();
4366
4336
  class ks {
4367
4337
  /**
4368
4338
  * @param {ID} id
@@ -4403,8 +4373,8 @@ class ks {
4403
4373
  throw N();
4404
4374
  }
4405
4375
  }
4406
- const jo = 0;
4407
- class T extends ks {
4376
+ const Lo = 0;
4377
+ class U extends ks {
4408
4378
  get deleted() {
4409
4379
  return !0;
4410
4380
  }
@@ -4422,14 +4392,14 @@ class T extends ks {
4422
4392
  * @param {number} offset
4423
4393
  */
4424
4394
  integrate(e, s) {
4425
- s > 0 && (this.id.clock += s, this.length -= s), Dn(e.doc.store, this);
4395
+ s > 0 && (this.id.clock += s, this.length -= s), Cn(e.doc.store, this);
4426
4396
  }
4427
4397
  /**
4428
4398
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
4429
4399
  * @param {number} offset
4430
4400
  */
4431
4401
  write(e, s) {
4432
- e.writeInfo(jo), e.writeLen(this.length - s);
4402
+ e.writeInfo(Lo), e.writeLen(this.length - s);
4433
4403
  }
4434
4404
  /**
4435
4405
  * @param {Transaction} transaction
@@ -4440,7 +4410,7 @@ class T extends ks {
4440
4410
  return null;
4441
4411
  }
4442
4412
  }
4443
- class We {
4413
+ class Ge {
4444
4414
  /**
4445
4415
  * @param {Uint8Array} content
4446
4416
  */
@@ -4469,7 +4439,7 @@ class We {
4469
4439
  * @return {ContentBinary}
4470
4440
  */
4471
4441
  copy() {
4472
- return new We(this.content);
4442
+ return new Ge(this.content);
4473
4443
  }
4474
4444
  /**
4475
4445
  * @param {number} offset
@@ -4515,8 +4485,8 @@ class We {
4515
4485
  return 3;
4516
4486
  }
4517
4487
  }
4518
- const Mo = (t) => new We(t.readBuf());
4519
- class Ye {
4488
+ const jo = (t) => new Ge(t.readBuf());
4489
+ class Ke {
4520
4490
  /**
4521
4491
  * @param {number} len
4522
4492
  */
@@ -4545,14 +4515,14 @@ class Ye {
4545
4515
  * @return {ContentDeleted}
4546
4516
  */
4547
4517
  copy() {
4548
- return new Ye(this.len);
4518
+ return new Ke(this.len);
4549
4519
  }
4550
4520
  /**
4551
4521
  * @param {number} offset
4552
4522
  * @return {ContentDeleted}
4553
4523
  */
4554
4524
  splice(e) {
4555
- const s = new Ye(this.len - e);
4525
+ const s = new Ke(this.len - e);
4556
4526
  return this.len = e, s;
4557
4527
  }
4558
4528
  /**
@@ -4567,7 +4537,7 @@ class Ye {
4567
4537
  * @param {Item} item
4568
4538
  */
4569
4539
  integrate(e, s) {
4570
- at(e.deleteSet, s.id.client, s.id.clock, this.len), s.markDeleted();
4540
+ ct(e.deleteSet, s.id.client, s.id.clock, this.len), s.markDeleted();
4571
4541
  }
4572
4542
  /**
4573
4543
  * @param {Transaction} transaction
@@ -4593,8 +4563,8 @@ class Ye {
4593
4563
  return 1;
4594
4564
  }
4595
4565
  }
4596
- const Uo = (t) => new Ye(t.readLen()), Vn = (t, e) => new Ie({ guid: t, ...e, shouldLoad: e.shouldLoad || e.autoLoad || !1 });
4597
- class Pe {
4566
+ const Mo = (t) => new Ke(t.readLen()), qn = (t, e) => new ke({ guid: t, ...e, shouldLoad: e.shouldLoad || e.autoLoad || !1 });
4567
+ class We {
4598
4568
  /**
4599
4569
  * @param {Doc} doc
4600
4570
  */
@@ -4625,7 +4595,7 @@ class Pe {
4625
4595
  * @return {ContentDoc}
4626
4596
  */
4627
4597
  copy() {
4628
- return new Pe(Vn(this.doc.guid, this.opts));
4598
+ return new We(qn(this.doc.guid, this.opts));
4629
4599
  }
4630
4600
  /**
4631
4601
  * @param {number} offset
@@ -4673,8 +4643,8 @@ class Pe {
4673
4643
  return 9;
4674
4644
  }
4675
4645
  }
4676
- const To = (t) => new Pe(Vn(t.readString(), t.readAny()));
4677
- class ke {
4646
+ const To = (t) => new We(qn(t.readString(), t.readAny()));
4647
+ class me {
4678
4648
  /**
4679
4649
  * @param {Object} embed
4680
4650
  */
@@ -4703,7 +4673,7 @@ class ke {
4703
4673
  * @return {ContentEmbed}
4704
4674
  */
4705
4675
  copy() {
4706
- return new ke(this.embed);
4676
+ return new me(this.embed);
4707
4677
  }
4708
4678
  /**
4709
4679
  * @param {number} offset
@@ -4749,8 +4719,8 @@ class ke {
4749
4719
  return 5;
4750
4720
  }
4751
4721
  }
4752
- const zo = (t) => new ke(t.readJSON());
4753
- class C {
4722
+ const Uo = (t) => new me(t.readJSON());
4723
+ class E {
4754
4724
  /**
4755
4725
  * @param {string} key
4756
4726
  * @param {Object} value
@@ -4780,7 +4750,7 @@ class C {
4780
4750
  * @return {ContentFormat}
4781
4751
  */
4782
4752
  copy() {
4783
- return new C(this.key, this.value);
4753
+ return new E(this.key, this.value);
4784
4754
  }
4785
4755
  /**
4786
4756
  * @param {number} _offset
@@ -4831,8 +4801,8 @@ class C {
4831
4801
  return 6;
4832
4802
  }
4833
4803
  }
4834
- const Oo = (t) => new C(t.readKey(), t.readJSON());
4835
- class gt {
4804
+ const zo = (t) => new E(t.readKey(), t.readJSON());
4805
+ class ft {
4836
4806
  /**
4837
4807
  * @param {Array<any>} arr
4838
4808
  */
@@ -4861,14 +4831,14 @@ class gt {
4861
4831
  * @return {ContentJSON}
4862
4832
  */
4863
4833
  copy() {
4864
- return new gt(this.arr);
4834
+ return new ft(this.arr);
4865
4835
  }
4866
4836
  /**
4867
4837
  * @param {number} offset
4868
4838
  * @return {ContentJSON}
4869
4839
  */
4870
4840
  splice(e) {
4871
- const s = new gt(this.arr.slice(e));
4841
+ const s = new ft(this.arr.slice(e));
4872
4842
  return this.arr = this.arr.slice(0, e), s;
4873
4843
  }
4874
4844
  /**
@@ -4913,13 +4883,13 @@ class gt {
4913
4883
  return 2;
4914
4884
  }
4915
4885
  }
4916
- const Ro = (t) => {
4886
+ const Oo = (t) => {
4917
4887
  const e = t.readLen(), s = [];
4918
4888
  for (let n = 0; n < e; n++) {
4919
4889
  const i = t.readString();
4920
4890
  i === "undefined" ? s.push(void 0) : s.push(JSON.parse(i));
4921
4891
  }
4922
- return new gt(s);
4892
+ return new ft(s);
4923
4893
  };
4924
4894
  class ge {
4925
4895
  /**
@@ -5002,13 +4972,13 @@ class ge {
5002
4972
  return 8;
5003
4973
  }
5004
4974
  }
5005
- const No = (t) => {
4975
+ const Ro = (t) => {
5006
4976
  const e = t.readLen(), s = [];
5007
4977
  for (let n = 0; n < e; n++)
5008
4978
  s.push(t.readAny());
5009
4979
  return new ge(s);
5010
4980
  };
5011
- class V {
4981
+ class $ {
5012
4982
  /**
5013
4983
  * @param {string} str
5014
4984
  */
@@ -5037,14 +5007,14 @@ class V {
5037
5007
  * @return {ContentString}
5038
5008
  */
5039
5009
  copy() {
5040
- return new V(this.str);
5010
+ return new $(this.str);
5041
5011
  }
5042
5012
  /**
5043
5013
  * @param {number} offset
5044
5014
  * @return {ContentString}
5045
5015
  */
5046
5016
  splice(e) {
5047
- const s = new V(this.str.slice(e));
5017
+ const s = new $(this.str.slice(e));
5048
5018
  this.str = this.str.slice(0, e);
5049
5019
  const n = this.str.charCodeAt(e - 1);
5050
5020
  return n >= 55296 && n <= 56319 && (this.str = this.str.slice(0, e - 1) + "�", s.str = "�" + s.str.slice(1)), s;
@@ -5086,16 +5056,16 @@ class V {
5086
5056
  return 4;
5087
5057
  }
5088
5058
  }
5089
- const Bo = (t) => new V(t.readString()), Fo = [
5090
- bo,
5091
- yo,
5059
+ const No = (t) => new $(t.readString()), Bo = [
5060
+ mo,
5061
+ wo,
5092
5062
  Eo,
5093
- xo,
5094
5063
  vo,
5095
- Io,
5096
- Lo
5097
- ], Ho = 0, Vo = 1, $o = 2, qo = 3, Ko = 4, Yo = 5, Jo = 6;
5098
- class P {
5064
+ Co,
5065
+ Ao,
5066
+ Io
5067
+ ], Fo = 0, Ho = 1, Vo = 2, $o = 3, qo = 4, Ko = 5, Yo = 6;
5068
+ class Q {
5099
5069
  /**
5100
5070
  * @param {AbstractType<any>} type
5101
5071
  */
@@ -5124,7 +5094,7 @@ class P {
5124
5094
  * @return {ContentType}
5125
5095
  */
5126
5096
  copy() {
5127
- return new P(this.type._copy());
5097
+ return new Q(this.type._copy());
5128
5098
  }
5129
5099
  /**
5130
5100
  * @param {number} offset
@@ -5187,7 +5157,7 @@ class P {
5187
5157
  return 7;
5188
5158
  }
5189
5159
  }
5190
- const Xo = (t) => new P(Fo[t.readTypeRef()](t)), pt = (t, e, s) => {
5160
+ const Jo = (t) => new Q(Bo[t.readTypeRef()](t)), gt = (t, e, s) => {
5191
5161
  const { client: n, clock: i } = e.id, r = new D(
5192
5162
  w(n, i + s),
5193
5163
  e,
@@ -5212,7 +5182,7 @@ class D extends ks {
5212
5182
  * @param {AbstractContent} content
5213
5183
  */
5214
5184
  constructor(e, s, n, i, r, o, c, a) {
5215
- super(e, a.getLength()), this.origin = n, this.left = s, this.right = i, this.rightOrigin = r, this.parent = o, this.parentSub = c, this.redone = null, this.content = a, this.info = this.content.isCountable() ? vs : 0;
5185
+ super(e, a.getLength()), this.origin = n, this.left = s, this.right = i, this.rightOrigin = r, this.parent = o, this.parentSub = c, this.redone = null, this.content = a, this.info = this.content.isCountable() ? As : 0;
5216
5186
  }
5217
5187
  /**
5218
5188
  * This is used to mark the item as an indexed fast-search marker
@@ -5220,35 +5190,35 @@ class D extends ks {
5220
5190
  * @type {boolean}
5221
5191
  */
5222
5192
  set marker(e) {
5223
- (this.info & xt) > 0 !== e && (this.info ^= xt);
5193
+ (this.info & vt) > 0 !== e && (this.info ^= vt);
5224
5194
  }
5225
5195
  get marker() {
5226
- return (this.info & xt) > 0;
5196
+ return (this.info & vt) > 0;
5227
5197
  }
5228
5198
  /**
5229
5199
  * If true, do not garbage collect this Item.
5230
5200
  */
5231
5201
  get keep() {
5232
- return (this.info & Es) > 0;
5202
+ return (this.info & xs) > 0;
5233
5203
  }
5234
5204
  set keep(e) {
5235
- this.keep !== e && (this.info ^= Es);
5205
+ this.keep !== e && (this.info ^= xs);
5236
5206
  }
5237
5207
  get countable() {
5238
- return (this.info & vs) > 0;
5208
+ return (this.info & As) > 0;
5239
5209
  }
5240
5210
  /**
5241
5211
  * Whether this item was deleted or not.
5242
5212
  * @type {Boolean}
5243
5213
  */
5244
5214
  get deleted() {
5245
- return (this.info & vt) > 0;
5215
+ return (this.info & Ct) > 0;
5246
5216
  }
5247
5217
  set deleted(e) {
5248
- this.deleted !== e && (this.info ^= vt);
5218
+ this.deleted !== e && (this.info ^= Ct);
5249
5219
  }
5250
5220
  markDeleted() {
5251
- this.info |= vt;
5221
+ this.info |= Ct;
5252
5222
  }
5253
5223
  /**
5254
5224
  * Return the creator clientID of the missing op or define missing items and return null.
@@ -5262,13 +5232,13 @@ class D extends ks {
5262
5232
  return this.origin.client;
5263
5233
  if (this.rightOrigin && this.rightOrigin.client !== this.id.client && this.rightOrigin.clock >= v(s, this.rightOrigin.client))
5264
5234
  return this.rightOrigin.client;
5265
- if (this.parent && this.parent.constructor === we && this.id.client !== this.parent.client && this.parent.clock >= v(s, this.parent.client))
5235
+ if (this.parent && this.parent.constructor === ye && this.id.client !== this.parent.client && this.parent.clock >= v(s, this.parent.client))
5266
5236
  return this.parent.client;
5267
- if (this.origin && (this.left = Os(e, s, this.origin), this.origin = this.left.lastId), this.rightOrigin && (this.right = ne(e, this.rightOrigin), this.rightOrigin = this.right.id), (this.left && this.left.constructor === T || this.right && this.right.constructor === T) && (this.parent = null), !this.parent)
5237
+ if (this.origin && (this.left = Ns(e, s, this.origin), this.origin = this.left.lastId), this.rightOrigin && (this.right = ne(e, this.rightOrigin), this.rightOrigin = this.right.id), (this.left && this.left.constructor === U || this.right && this.right.constructor === U) && (this.parent = null), !this.parent)
5268
5238
  this.left && this.left.constructor === D && (this.parent = this.left.parent, this.parentSub = this.left.parentSub), this.right && this.right.constructor === D && (this.parent = this.right.parent, this.parentSub = this.right.parentSub);
5269
- else if (this.parent.constructor === we) {
5270
- const n = jt(s, this.parent);
5271
- n.constructor === T ? this.parent = null : this.parent = /** @type {ContentType} */
5239
+ else if (this.parent.constructor === ye) {
5240
+ const n = Lt(s, this.parent);
5241
+ n.constructor === U ? this.parent = null : this.parent = /** @type {ContentType} */
5272
5242
  n.content.type;
5273
5243
  }
5274
5244
  return null;
@@ -5278,7 +5248,7 @@ class D extends ks {
5278
5248
  * @param {number} offset
5279
5249
  */
5280
5250
  integrate(e, s) {
5281
- if (s > 0 && (this.id.clock += s, this.left = Os(e, e.doc.store, w(this.id.client, this.id.clock - 1)), this.origin = this.left.lastId, this.content = this.content.splice(s), this.length -= s), this.parent) {
5251
+ if (s > 0 && (this.id.clock += s, this.left = Ns(e, e.doc.store, w(this.id.client, this.id.clock - 1)), this.origin = this.left.lastId, this.content = this.content.splice(s), this.length -= s), this.parent) {
5282
5252
  if (!this.left && (!this.right || this.right.left !== null) || this.left && this.left.right !== this.right) {
5283
5253
  let n = this.left, i;
5284
5254
  if (n !== null)
@@ -5292,13 +5262,13 @@ class D extends ks {
5292
5262
  this.parent._start;
5293
5263
  const r = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
5294
5264
  for (; i !== null && i !== this.right; ) {
5295
- if (o.add(i), r.add(i), Ze(this.origin, i.origin)) {
5265
+ if (o.add(i), r.add(i), Qe(this.origin, i.origin)) {
5296
5266
  if (i.id.client < this.id.client)
5297
5267
  n = i, r.clear();
5298
- else if (Ze(this.rightOrigin, i.rightOrigin))
5268
+ else if (Qe(this.rightOrigin, i.rightOrigin))
5299
5269
  break;
5300
- } else if (i.origin !== null && o.has(jt(e.doc.store, i.origin)))
5301
- r.has(jt(e.doc.store, i.origin)) || (n = i, r.clear());
5270
+ } else if (i.origin !== null && o.has(Lt(e.doc.store, i.origin)))
5271
+ r.has(Lt(e.doc.store, i.origin)) || (n = i, r.clear());
5302
5272
  else
5303
5273
  break;
5304
5274
  i = i.right;
@@ -5319,7 +5289,7 @@ class D extends ks {
5319
5289
  this.parent._start, this.parent._start = this;
5320
5290
  this.right = n;
5321
5291
  }
5322
- this.right !== null ? this.right.left = this : this.parentSub !== null && (this.parent._map.set(this.parentSub, this), this.left !== null && this.left.delete(e)), this.parentSub === null && this.countable && !this.deleted && (this.parent._length += this.length), Dn(e.doc.store, this), this.content.integrate(e, this), Ns(
5292
+ this.right !== null ? this.right.left = this : this.parentSub !== null && (this.parent._map.set(this.parentSub, this), this.left !== null && this.left.delete(e)), this.parentSub === null && this.countable && !this.deleted && (this.parent._length += this.length), Cn(e.doc.store, this), this.content.integrate(e, this), Fs(
5323
5293
  e,
5324
5294
  /** @type {AbstractType<any>} */
5325
5295
  this.parent,
@@ -5328,7 +5298,7 @@ class D extends ks {
5328
5298
  (this.parent._item !== null && /** @type {AbstractType<any>} */
5329
5299
  this.parent._item.deleted || this.parentSub !== null && this.right !== null) && this.delete(e);
5330
5300
  } else
5331
- new T(this.id, this.length).integrate(e, 0);
5301
+ new U(this.id, this.length).integrate(e, 0);
5332
5302
  }
5333
5303
  /**
5334
5304
  * Returns the next non-deleted item
@@ -5361,7 +5331,7 @@ class D extends ks {
5361
5331
  * @return {boolean}
5362
5332
  */
5363
5333
  mergeWith(e) {
5364
- if (this.constructor === e.constructor && Ze(e.origin, this.lastId) && this.right === e && Ze(this.rightOrigin, e.rightOrigin) && this.id.client === e.id.client && this.id.clock + this.length === e.id.clock && this.deleted === e.deleted && this.redone === null && e.redone === null && this.content.constructor === e.content.constructor && this.content.mergeWith(e.content)) {
5334
+ if (this.constructor === e.constructor && Qe(e.origin, this.lastId) && this.right === e && Qe(this.rightOrigin, e.rightOrigin) && this.id.client === e.id.client && this.id.clock + this.length === e.id.clock && this.deleted === e.deleted && this.redone === null && e.redone === null && this.content.constructor === e.content.constructor && this.content.mergeWith(e.content)) {
5365
5335
  const s = (
5366
5336
  /** @type {AbstractType<any>} */
5367
5337
  this.parent._searchMarker
@@ -5383,7 +5353,7 @@ class D extends ks {
5383
5353
  /** @type {AbstractType<any>} */
5384
5354
  this.parent
5385
5355
  );
5386
- this.countable && this.parentSub === null && (s._length -= this.length), this.markDeleted(), at(e.deleteSet, this.id.client, this.id.clock, this.length), Ns(e, s, this.parentSub), this.content.delete(e);
5356
+ this.countable && this.parentSub === null && (s._length -= this.length), this.markDeleted(), ct(e.deleteSet, this.id.client, this.id.clock, this.length), Fs(e, s, this.parentSub), this.content.delete(e);
5387
5357
  }
5388
5358
  }
5389
5359
  /**
@@ -5392,8 +5362,8 @@ class D extends ks {
5392
5362
  */
5393
5363
  gc(e, s) {
5394
5364
  if (!this.deleted)
5395
- throw F();
5396
- this.content.gc(e), s ? eo(e, this, new T(this.id, this.length)) : this.content = new Ye(this.length);
5365
+ throw H();
5366
+ this.content.gc(e), s ? Zr(e, this, new U(this.id, this.length)) : this.content = new Ke(this.length);
5397
5367
  }
5398
5368
  /**
5399
5369
  * Transform the properties of this type to binary and write it to an
@@ -5405,9 +5375,9 @@ class D extends ks {
5405
5375
  * @param {number} offset
5406
5376
  */
5407
5377
  write(e, s) {
5408
- const n = s > 0 ? w(this.id.client, this.id.clock + s - 1) : this.origin, i = this.rightOrigin, r = this.parentSub, o = this.content.getRef() & kt | (n === null ? 0 : U) | // origin is defined
5409
- (i === null ? 0 : K) | // right origin is defined
5410
- (r === null ? 0 : Fe);
5378
+ const n = s > 0 ? w(this.id.client, this.id.clock + s - 1) : this.origin, i = this.rightOrigin, r = this.parentSub, o = this.content.getRef() & kt | (n === null ? 0 : T) | // origin is defined
5379
+ (i === null ? 0 : Y) | // right origin is defined
5380
+ (r === null ? 0 : Be);
5411
5381
  if (e.writeInfo(o), n !== null && e.writeLeftID(n), i !== null && e.writeRightID(i), n === null && i === null) {
5412
5382
  const c = (
5413
5383
  /** @type {AbstractType<any>} */
@@ -5416,45 +5386,45 @@ class D extends ks {
5416
5386
  if (c._item !== void 0) {
5417
5387
  const a = c._item;
5418
5388
  if (a === null) {
5419
- const l = Qr(c);
5389
+ const l = Pr(c);
5420
5390
  e.writeParentInfo(!0), e.writeString(l);
5421
5391
  } else
5422
5392
  e.writeParentInfo(!1), e.writeLeftID(a.id);
5423
5393
  } else
5424
- c.constructor === String ? (e.writeParentInfo(!0), e.writeString(c)) : c.constructor === we ? (e.writeParentInfo(!1), e.writeLeftID(c)) : F();
5394
+ c.constructor === String ? (e.writeParentInfo(!0), e.writeString(c)) : c.constructor === ye ? (e.writeParentInfo(!1), e.writeLeftID(c)) : H();
5425
5395
  r !== null && e.writeString(r);
5426
5396
  }
5427
5397
  this.content.write(e, s);
5428
5398
  }
5429
5399
  }
5430
- const $n = (t, e) => Go[e & kt](t), Go = [
5400
+ const Kn = (t, e) => Xo[e & kt](t), Xo = [
5431
5401
  () => {
5432
- F();
5402
+ H();
5433
5403
  },
5434
5404
  // GC is not ItemContent
5435
- Uo,
5405
+ Mo,
5436
5406
  // 1
5437
- Ro,
5407
+ Oo,
5438
5408
  // 2
5439
- Mo,
5409
+ jo,
5440
5410
  // 3
5441
- Bo,
5411
+ No,
5442
5412
  // 4
5443
- zo,
5413
+ Uo,
5444
5414
  // 5
5445
- Oo,
5415
+ zo,
5446
5416
  // 6
5447
- Xo,
5417
+ Jo,
5448
5418
  // 7
5449
- No,
5419
+ Ro,
5450
5420
  // 8
5451
5421
  To,
5452
5422
  // 9
5453
5423
  () => {
5454
- F();
5424
+ H();
5455
5425
  }
5456
5426
  // 10 - Skip is not ItemContent
5457
- ], Wo = 10;
5427
+ ], Go = 10;
5458
5428
  class z extends ks {
5459
5429
  get deleted() {
5460
5430
  return !0;
@@ -5473,14 +5443,14 @@ class z extends ks {
5473
5443
  * @param {number} offset
5474
5444
  */
5475
5445
  integrate(e, s) {
5476
- F();
5446
+ H();
5477
5447
  }
5478
5448
  /**
5479
5449
  * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
5480
5450
  * @param {number} offset
5481
5451
  */
5482
5452
  write(e, s) {
5483
- e.writeInfo(Wo), p(e.restEncoder, this.length - s);
5453
+ e.writeInfo(Go), p(e.restEncoder, this.length - s);
5484
5454
  }
5485
5455
  /**
5486
5456
  * @param {Transaction} transaction
@@ -5491,49 +5461,79 @@ class z extends ks {
5491
5461
  return null;
5492
5462
  }
5493
5463
  }
5494
- const qn = (
5464
+ const Yn = (
5495
5465
  /** @type {any} */
5496
5466
  typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : {}
5497
- ), Kn = "__ $YJS$ __";
5498
- qn[Kn] === !0 && console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");
5499
- qn[Kn] = !0;
5500
- const Yn = 0, ms = 1, Jn = 2, Jt = (t, e) => {
5501
- p(t, Yn);
5502
- const s = Wr(e);
5467
+ ), Jn = "__ $YJS$ __";
5468
+ Yn[Jn] === !0 && console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");
5469
+ Yn[Jn] = !0;
5470
+ const Xn = /* @__PURE__ */ new Map();
5471
+ class Wo {
5472
+ /**
5473
+ * @param {string} room
5474
+ */
5475
+ constructor(e) {
5476
+ this.room = e, this.onmessage = null, this._onChange = (s) => s.key === e && this.onmessage !== null && this.onmessage({ data: or(s.newValue || "") }), Ai(this._onChange);
5477
+ }
5478
+ /**
5479
+ * @param {ArrayBuffer} buf
5480
+ */
5481
+ postMessage(e) {
5482
+ Qs.setItem(this.room, rr(er(e)));
5483
+ }
5484
+ close() {
5485
+ Ii(this._onChange);
5486
+ }
5487
+ }
5488
+ const Po = typeof BroadcastChannel > "u" ? Wo : BroadcastChannel, ms = (t) => W(Xn, t, () => {
5489
+ const e = le(), s = new Po(t);
5490
+ return s.onmessage = (n) => e.forEach((i) => i(n.data, "broadcastchannel")), {
5491
+ bc: s,
5492
+ subs: e
5493
+ };
5494
+ }), Qo = (t, e) => (ms(t).subs.add(e), e), Zo = (t, e) => {
5495
+ const s = ms(t), n = s.subs.delete(e);
5496
+ return n && s.subs.size === 0 && (s.bc.close(), Xn.delete(t)), n;
5497
+ }, we = (t, e, s = null) => {
5498
+ const n = ms(t);
5499
+ n.bc.postMessage(e), n.subs.forEach((i) => i(e, s));
5500
+ }, Gn = 0, bs = 1, Wn = 2, Yt = (t, e) => {
5501
+ p(t, Gn);
5502
+ const s = Gr(e);
5503
5503
  S(t, s);
5504
- }, Xn = (t, e, s) => {
5505
- p(t, ms), S(t, ls(e, s));
5506
- }, Po = (t, e, s) => Xn(e, s, A(t)), Gn = (t, e, s) => {
5504
+ }, Pn = (t, e, s) => {
5505
+ p(t, bs), S(t, ls(e, s));
5506
+ }, ec = (t, e, s) => Pn(e, s, A(t)), Qn = (t, e, s) => {
5507
5507
  try {
5508
- bn(e, A(t), s);
5508
+ yn(e, A(t), s);
5509
5509
  } catch (n) {
5510
5510
  console.error("Caught error while handling a Yjs update", n);
5511
5511
  }
5512
- }, Qo = (t, e) => {
5513
- p(t, Jn), S(t, e);
5514
- }, Zo = Gn, ec = (t, e, s, n) => {
5512
+ }, tc = (t, e) => {
5513
+ p(t, Wn), S(t, e);
5514
+ }, sc = Qn, nc = (t, e, s, n) => {
5515
5515
  const i = k(t);
5516
5516
  switch (i) {
5517
- case Yn:
5518
- Po(t, e, s);
5517
+ case Gn:
5518
+ ec(t, e, s);
5519
5519
  break;
5520
- case ms:
5521
- Gn(t, s, n);
5520
+ case bs:
5521
+ Qn(t, s, n);
5522
5522
  break;
5523
- case Jn:
5524
- Zo(t, s, n);
5523
+ case Wn:
5524
+ sc(t, s, n);
5525
5525
  break;
5526
5526
  default:
5527
5527
  throw new Error("Unknown message type");
5528
5528
  }
5529
5529
  return i;
5530
- }, tc = 0, sc = (t, e, s) => {
5530
+ }, ic = 0, rc = (t, e, s) => {
5531
5531
  switch (k(t)) {
5532
- case tc:
5533
- s(e, ee(t));
5532
+ case ic:
5533
+ s(e, te(t));
5534
5534
  }
5535
5535
  }, Tt = 3e4;
5536
- class nc extends wt {
5536
+ class oc extends pt {
5537
5537
  /**
5538
5538
  * @param {Y.Doc} doc
5539
5539
  */
@@ -5546,8 +5546,8 @@ class nc extends wt {
5546
5546
  const n = [];
5547
5547
  this.meta.forEach((i, r) => {
5548
5548
  r !== this.clientID && Tt <= s - i.lastUpdated && this.states.has(r) && n.push(r);
5549
- }), n.length > 0 && bs(this, n, "timeout");
5550
- }, J(Tt / 10)), e.on("destroy", () => {
5549
+ }), n.length > 0 && ws(this, n, "timeout");
5550
+ }, X(Tt / 10)), e.on("destroy", () => {
5551
5551
  this.destroy();
5552
5552
  }), this.setLocalState({});
5553
5553
  }
@@ -5570,7 +5570,7 @@ class nc extends wt {
5570
5570
  lastUpdated: he()
5571
5571
  });
5572
5572
  const o = [], c = [], a = [], l = [];
5573
- e === null ? l.push(s) : r == null ? e != null && o.push(s) : (c.push(s), Re(r, e) || a.push(s)), (o.length > 0 || a.length > 0 || l.length > 0) && this.emit("change", [{ added: o, updated: a, removed: l }, "local"]), this.emit("update", [{ added: o, updated: c, removed: l }, "local"]);
5573
+ e === null ? l.push(s) : r == null ? e != null && o.push(s) : (c.push(s), Oe(r, e) || a.push(s)), (o.length > 0 || a.length > 0 || l.length > 0) && this.emit("change", [{ added: o, updated: a, removed: l }, "local"]), this.emit("update", [{ added: o, updated: c, removed: l }, "local"]);
5574
5574
  }
5575
5575
  /**
5576
5576
  * @param {string} field
@@ -5590,7 +5590,7 @@ class nc extends wt {
5590
5590
  return this.states;
5591
5591
  }
5592
5592
  }
5593
- const bs = (t, e, s) => {
5593
+ const ws = (t, e, s) => {
5594
5594
  const n = [];
5595
5595
  for (let i = 0; i < e.length; i++) {
5596
5596
  const r = e[i];
@@ -5609,7 +5609,7 @@ const bs = (t, e, s) => {
5609
5609
  }
5610
5610
  }
5611
5611
  n.length > 0 && (t.emit("change", [{ added: [], updated: [], removed: n }, s]), t.emit("update", [{ added: [], updated: [], removed: n }, s]));
5612
- }, Ne = (t, e, s = t.states) => {
5612
+ }, Re = (t, e, s = t.states) => {
5613
5613
  const n = e.length, i = I();
5614
5614
  p(i, n);
5615
5615
  for (let r = 0; r < n; r++) {
@@ -5620,16 +5620,16 @@ const bs = (t, e, s) => {
5620
5620
  p(i, o), p(i, a), ae(i, JSON.stringify(c));
5621
5621
  }
5622
5622
  return _(i);
5623
- }, ic = (t, e, s) => {
5623
+ }, cc = (t, e, s) => {
5624
5624
  const n = ie(e), i = he(), r = [], o = [], c = [], a = [], l = k(n);
5625
5625
  for (let h = 0; h < l; h++) {
5626
5626
  const u = k(n);
5627
5627
  let d = k(n);
5628
- const f = JSON.parse(ee(n)), g = t.meta.get(u), m = t.states.get(u), L = g === void 0 ? 0 : g.clock;
5628
+ const f = JSON.parse(te(n)), g = t.meta.get(u), m = t.states.get(u), L = g === void 0 ? 0 : g.clock;
5629
5629
  (L < d || L === d && f === null && t.states.has(u)) && (f === null ? u === t.clientID && t.getLocalState() != null ? d++ : t.states.delete(u) : t.states.set(u, f), t.meta.set(u, {
5630
5630
  clock: d,
5631
5631
  lastUpdated: i
5632
- }), g === void 0 && f !== null ? r.push(u) : g !== void 0 && f === null ? a.push(u) : f !== null && (Re(f, m) || c.push(u), o.push(u)));
5632
+ }), g === void 0 && f !== null ? r.push(u) : g !== void 0 && f === null ? a.push(u) : f !== null && (Oe(f, m) || c.push(u), o.push(u)));
5633
5633
  }
5634
5634
  (r.length > 0 || c.length > 0 || a.length > 0) && t.emit("change", [{
5635
5635
  added: r,
@@ -5640,56 +5640,63 @@ const bs = (t, e, s) => {
5640
5640
  updated: o,
5641
5641
  removed: a
5642
5642
  }, s]);
5643
- }, rc = (t) => Ii(t, (e, s) => `${encodeURIComponent(s)}=${encodeURIComponent(e)}`).join("&");
5644
- var oe = 0, Wn = 3, _e = 1, oc = 2;
5645
- function cc(t, e) {
5643
+ }, ac = (t) => Ti(t, (e, s) => `${encodeURIComponent(s)}=${encodeURIComponent(e)}`).join("&");
5644
+ var oe = 0, Zn = 3, Se = 1, lc = 2, Ks = {
5645
+ CONNECTING: 0,
5646
+ OPEN: 1,
5647
+ CLOSING: 2,
5648
+ CLOSED: 3
5649
+ };
5650
+ WebSocket.OPEN === void 0 && (Object.assign(WebSocket, Ks), Object.assign(WebSocket.prototype, Ks));
5651
+ var hc = typeof window > "u";
5652
+ function uc(t, e) {
5646
5653
  if (!t)
5647
5654
  throw new Error(e);
5648
5655
  }
5649
- var Qe = [];
5650
- Qe[oe] = (t, e, s, n, i) => {
5656
+ var Pe = [];
5657
+ Pe[oe] = (t, e, s, n, i) => {
5651
5658
  p(t, oe);
5652
- const r = ec(
5659
+ const r = nc(
5653
5660
  e,
5654
5661
  t,
5655
5662
  s.doc,
5656
5663
  s
5657
5664
  );
5658
- n && r === ms && !s.synced && (s.synced = !0);
5665
+ n && r === bs && !s.synced && (s.synced = !0);
5659
5666
  };
5660
- Qe[Wn] = (t, e, s, n, i) => {
5661
- p(t, _e), S(
5667
+ Pe[Zn] = (t, e, s, n, i) => {
5668
+ p(t, Se), S(
5662
5669
  t,
5663
- Ne(
5670
+ Re(
5664
5671
  s.awareness,
5665
5672
  Array.from(s.awareness.getStates().keys())
5666
5673
  )
5667
5674
  );
5668
5675
  };
5669
- Qe[_e] = (t, e, s, n, i) => {
5670
- ic(
5676
+ Pe[Se] = (t, e, s, n, i) => {
5677
+ cc(
5671
5678
  s.awareness,
5672
5679
  A(e),
5673
5680
  s
5674
5681
  );
5675
5682
  };
5676
- Qe[oc] = (t, e, s, n, i) => {
5677
- sc(
5683
+ Pe[lc] = (t, e, s, n, i) => {
5684
+ rc(
5678
5685
  e,
5679
5686
  s.doc,
5680
- (r, o) => ac(s, o)
5687
+ (r, o) => dc(s, o)
5681
5688
  );
5682
5689
  };
5683
- var $s = 3e4;
5684
- function ac(t, e) {
5690
+ var Ys = 3e4;
5691
+ function dc(t, e) {
5685
5692
  console.warn(`Permission denied to access ${t.url}.
5686
5693
  ${e}`);
5687
5694
  }
5688
- function Pn(t, e, s) {
5695
+ function ei(t, e, s) {
5689
5696
  const n = ie(e), i = I(), r = k(n), o = t.messageHandlers[r];
5690
5697
  return /** @type {any} */ o ? o(i, n, t, s, r) : console.error("Unable to compute message"), i;
5691
5698
  }
5692
- function Qn(t) {
5699
+ function ti(t) {
5693
5700
  if (t.shouldConnect && t.ws === null) {
5694
5701
  const e = new t._WS(t.url);
5695
5702
  e.binaryType = "arraybuffer", t.ws = e, t.wsconnecting = !0, t.wsconnected = !1, t.synced = !1, e.onmessage = (s) => {
@@ -5698,12 +5705,12 @@ function Qn(t) {
5698
5705
  return;
5699
5706
  }
5700
5707
  t.wsLastMessageReceived = he();
5701
- const n = Pn(t, new Uint8Array(s.data), !0);
5702
- Qt(n) > 1 && e.send(_(n));
5708
+ const n = ei(t, new Uint8Array(s.data), !0);
5709
+ ss(n) > 1 && e.send(_(n));
5703
5710
  }, e.onerror = (s) => {
5704
5711
  t.emit("connection-error", [s, t]);
5705
5712
  }, e.onclose = (s) => {
5706
- t.emit("connection-close", [s, t]), t.ws = null, t.wsconnecting = !1, t.wsconnected ? (t.wsconnected = !1, t.synced = !1, bs(
5713
+ t.emit("connection-close", [s, t]), t.ws = null, t.wsconnecting = !1, t.wsconnected ? (t.wsconnected = !1, t.synced = !1, ws(
5707
5714
  t.awareness,
5708
5715
  Array.from(t.awareness.getStates().keys()).filter(
5709
5716
  (n) => n !== t.doc.clientID
@@ -5714,9 +5721,9 @@ function Qn(t) {
5714
5721
  status: "disconnected"
5715
5722
  }
5716
5723
  ])) : t.wsUnsuccessfulReconnects++, setTimeout(
5717
- Qn,
5718
- Pt(
5719
- Bi(2, t.wsUnsuccessfulReconnects) * 100,
5724
+ ti,
5725
+ Wt(
5726
+ bi(2, t.wsUnsuccessfulReconnects) * 100,
5720
5727
  t.maxBackoffTime
5721
5728
  ),
5722
5729
  t
@@ -5728,11 +5735,11 @@ function Qn(t) {
5728
5735
  }
5729
5736
  ]);
5730
5737
  const s = I();
5731
- if (p(s, oe), Jt(s, t.doc), e.send(_(s)), t.awareness.getLocalState() !== null) {
5738
+ if (p(s, oe), Yt(s, t.doc), e.send(_(s)), t.awareness.getLocalState() !== null) {
5732
5739
  const n = I();
5733
- p(n, _e), S(
5740
+ p(n, Se), S(
5734
5741
  n,
5735
- Ne(t.awareness, [
5742
+ Re(t.awareness, [
5736
5743
  t.doc.clientID
5737
5744
  ])
5738
5745
  ), e.send(_(n));
@@ -5744,14 +5751,14 @@ function Qn(t) {
5744
5751
  ]);
5745
5752
  }
5746
5753
  }
5747
- function zt(t, e) {
5754
+ function Ut(t, e) {
5748
5755
  const s = t.ws;
5749
- t.wsconnected && s && s.readyState === s.OPEN && s.send(e), t.bcconnected && be(t.bcChannel, e, t);
5756
+ t.wsconnected && s && s.readyState === s.OPEN && s.send(e), t.bcconnected && we(t.bcChannel, e, t);
5750
5757
  }
5751
- var lc = class extends wt {
5758
+ var fc = class extends pt {
5752
5759
  constructor(e, s, n, {
5753
5760
  connect: i = !0,
5754
- awareness: r = new nc(n),
5761
+ awareness: r = new oc(n),
5755
5762
  params: o = {},
5756
5763
  WebSocketPolyfill: c = WebSocket,
5757
5764
  // Optionally provide a WebSocket polyfill
@@ -5759,7 +5766,7 @@ var lc = class extends wt {
5759
5766
  // Request server state every `resyncInterval` milliseconds
5760
5767
  maxBackoffTime: l = 2500,
5761
5768
  // Maximum amount of time to wait before trying to reconnect (we try to reconnect using exponential backoff)
5762
- disableBc: h = !1
5769
+ disableBc: h = hc
5763
5770
  // Disable cross-tab BroadcastChannel communication
5764
5771
  } = {}) {
5765
5772
  super();
@@ -5789,39 +5796,39 @@ var lc = class extends wt {
5789
5796
  b(this, "_checkInterval");
5790
5797
  for (; e[e.length - 1] === "/"; )
5791
5798
  e = e.slice(0, e.length - 1);
5792
- const u = rc(o);
5793
- this.maxBackoffTime = l, this.bcChannel = e + "/" + s, this.url = e + "/" + s + (u.length === 0 ? "" : "?" + u), this.roomname = s, this.doc = n, this._WS = c, this.awareness = r, this.wsconnected = !1, this.wsconnecting = !1, this.bcconnected = !1, this.disableBc = h, this.wsUnsuccessfulReconnects = 0, this.messageHandlers = Qe.slice(), this._synced = !1, this.ws = null, this.wsLastMessageReceived = 0, this.shouldConnect = i, this._resyncInterval = 0, a > 0 && (this._resyncInterval = /** @type {any} */
5799
+ const u = ac(o);
5800
+ this.maxBackoffTime = l, this.bcChannel = e + "/" + s, this.url = e + "/" + s + (u.length === 0 ? "" : "?" + u), this.roomname = s, this.doc = n, this._WS = c, this.awareness = r, this.wsconnected = !1, this.wsconnecting = !1, this.bcconnected = !1, this.disableBc = h, this.wsUnsuccessfulReconnects = 0, this.messageHandlers = Pe.slice(), this._synced = !1, this.ws = null, this.wsLastMessageReceived = 0, this.shouldConnect = i, this._resyncInterval = 0, a > 0 && (this._resyncInterval = /** @type {any} */
5794
5801
  setInterval(() => {
5795
5802
  if (this.ws && this.ws.readyState === WebSocket.OPEN) {
5796
5803
  const d = I();
5797
- p(d, oe), Jt(d, n), this.ws.send(_(d));
5804
+ p(d, oe), Yt(d, n), this.ws.send(_(d));
5798
5805
  }
5799
5806
  }, a)), this._bcSubscriber = (d, f) => {
5800
5807
  if (f !== this) {
5801
- const g = Pn(this, new Uint8Array(d), !1);
5802
- Qt(g) > 1 && be(this.bcChannel, _(g), this);
5808
+ const g = ei(this, new Uint8Array(d), !1);
5809
+ ss(g) > 1 && we(this.bcChannel, _(g), this);
5803
5810
  }
5804
5811
  }, this._updateHandler = (d, f) => {
5805
5812
  if (f !== this) {
5806
5813
  const g = I();
5807
- p(g, oe), Qo(g, d), zt(this, _(g));
5814
+ p(g, oe), tc(g, d), Ut(this, _(g));
5808
5815
  }
5809
5816
  }, this.doc.on("update", this._updateHandler), this._awarenessUpdateHandler = ({ added: d, updated: f, removed: g }, m) => {
5810
- const L = d.concat(f).concat(g), je = I();
5811
- p(je, _e), S(
5812
- je,
5813
- Ne(r, L)
5814
- ), zt(this, _(je));
5817
+ const L = d.concat(f).concat(g), Le = I();
5818
+ p(Le, Se), S(
5819
+ Le,
5820
+ Re(r, L)
5821
+ ), Ut(this, _(Le));
5815
5822
  }, this._unloadHandler = () => {
5816
- bs(
5823
+ ws(
5817
5824
  this.awareness,
5818
5825
  [n.clientID],
5819
5826
  "window unload"
5820
5827
  );
5821
5828
  }, typeof window < "u" ? window.addEventListener("unload", this._unloadHandler) : typeof process < "u" && process.on("exit", this._unloadHandler), r.on("update", this._awarenessUpdateHandler), this._checkInterval = /** @type {any} */
5822
5829
  setInterval(() => {
5823
- this.wsconnected && $s < he() - this.wsLastMessageReceived && (cc(this.ws !== null, "ws must not be null"), this.ws.close());
5824
- }, $s / 10), i && this.connect();
5830
+ this.wsconnected && Ys < he() - this.wsLastMessageReceived && (uc(this.ws !== null, "ws must not be null"), this.ws.close());
5831
+ }, Ys / 10), i && this.connect();
5825
5832
  }
5826
5833
  /**
5827
5834
  * @type {boolean}
@@ -5838,24 +5845,24 @@ var lc = class extends wt {
5838
5845
  connectBc() {
5839
5846
  if (this.disableBc)
5840
5847
  return;
5841
- this.bcconnected || (kr(this.bcChannel, this._bcSubscriber), this.bcconnected = !0);
5848
+ this.bcconnected || (Qo(this.bcChannel, this._bcSubscriber), this.bcconnected = !0);
5842
5849
  const e = I();
5843
- p(e, oe), Jt(e, this.doc), be(this.bcChannel, _(e), this);
5850
+ p(e, oe), Yt(e, this.doc), we(this.bcChannel, _(e), this);
5844
5851
  const s = I();
5845
- p(s, oe), Xn(s, this.doc), be(this.bcChannel, _(s), this);
5852
+ p(s, oe), Pn(s, this.doc), we(this.bcChannel, _(s), this);
5846
5853
  const n = I();
5847
- p(n, Wn), be(
5854
+ p(n, Zn), we(
5848
5855
  this.bcChannel,
5849
5856
  _(n),
5850
5857
  this
5851
5858
  );
5852
5859
  const i = I();
5853
- p(i, _e), S(
5860
+ p(i, Se), S(
5854
5861
  i,
5855
- Ne(this.awareness, [
5862
+ Re(this.awareness, [
5856
5863
  this.doc.clientID
5857
5864
  ])
5858
- ), be(
5865
+ ), we(
5859
5866
  this.bcChannel,
5860
5867
  _(i),
5861
5868
  this
@@ -5863,23 +5870,23 @@ var lc = class extends wt {
5863
5870
  }
5864
5871
  disconnectBc() {
5865
5872
  const e = I();
5866
- p(e, _e), S(
5873
+ p(e, Se), S(
5867
5874
  e,
5868
- Ne(
5875
+ Re(
5869
5876
  this.awareness,
5870
5877
  [this.doc.clientID],
5871
5878
  /* @__PURE__ */ new Map()
5872
5879
  )
5873
- ), zt(this, _(e)), this.bcconnected && (mr(this.bcChannel, this._bcSubscriber), this.bcconnected = !1);
5880
+ ), Ut(this, _(e)), this.bcconnected && (Zo(this.bcChannel, this._bcSubscriber), this.bcconnected = !1);
5874
5881
  }
5875
5882
  disconnect() {
5876
5883
  this.shouldConnect = !1, this.disconnectBc(), this.ws !== null && this.ws.close();
5877
5884
  }
5878
5885
  connect() {
5879
- this.shouldConnect = !0, !this.wsconnected && this.ws === null && (Qn(this), this.connectBc());
5886
+ this.shouldConnect = !0, !this.wsconnected && this.ws === null && (ti(this), this.connectBc());
5880
5887
  }
5881
5888
  };
5882
- function qs() {
5889
+ function gc() {
5883
5890
  if (crypto.randomUUID)
5884
5891
  return crypto.randomUUID();
5885
5892
  let t = (/* @__PURE__ */ new Date()).getTime(), e = typeof performance < "u" && performance.now && performance.now() * 1e3 || 0;
@@ -5888,91 +5895,101 @@ function qs() {
5888
5895
  return t > 0 ? (n = (t + n) % 16 | 0, t = Math.floor(t / 16)) : (n = (e + n) % 16 | 0, e = Math.floor(e / 16)), (s === "x" ? n : n & 3 | 8).toString(16);
5889
5896
  });
5890
5897
  }
5891
- var hc = class extends lc {
5892
- constructor(t, e, s, n = {}) {
5893
- const i = `${t.startsWith("localhost:") || t.startsWith("127.0.0.1:") ? "ws" : "wss"}://${t}/party`;
5894
- n.params === void 0 ? n.params = {
5895
- _pk: qs()
5896
- } : n.params._pk = qs(), super(i, e, s, n);
5898
+ function Js(t, e, s) {
5899
+ if (typeof t !== s)
5900
+ throw new Error(
5901
+ `Invalid "${e}" parameter provided to YPartyKitProvider. Expected: ${s}, received: ${t}`
5902
+ );
5903
+ }
5904
+ var pc = class extends fc {
5905
+ constructor(e, s, n, i = {}) {
5906
+ Js(e, "host", "string"), Js(s, "room", "string"), e = e.replace(/^(http|https|ws|wss):\/\//, "");
5907
+ const r = `${e.startsWith("localhost:") || e.startsWith("127.0.0.1:") ? "ws" : "wss"}://${e}${i.party ? `/parties/${i.party}` : "/party"}`, o = gc();
5908
+ i.params === void 0 ? i.params = {
5909
+ _pk: o
5910
+ } : i.params._pk = o;
5911
+ super(r, s, n ?? new ke(), i);
5912
+ b(this, "id");
5913
+ this.id = o;
5897
5914
  }
5898
5915
  };
5899
- const me = (t) => Ee((e, s) => {
5916
+ const be = (t) => Ce((e, s) => {
5900
5917
  t.onerror = (n) => s(new Error(n.target.error)), t.onsuccess = (n) => e(n.target.result);
5901
- }), uc = (t, e) => Ee((s, n) => {
5918
+ }), kc = (t, e) => Ce((s, n) => {
5902
5919
  const i = indexedDB.open(t);
5903
- i.onupgradeneeded = (r) => e(r.target.result), i.onerror = (r) => n(X(r.target.error)), i.onsuccess = (r) => {
5920
+ i.onupgradeneeded = (r) => e(r.target.result), i.onerror = (r) => n(G(r.target.error)), i.onsuccess = (r) => {
5904
5921
  const o = r.target.result;
5905
5922
  o.onversionchange = () => {
5906
5923
  o.close();
5907
5924
  }, typeof addEventListener < "u" && addEventListener("unload", () => o.close()), s(o);
5908
5925
  };
5909
- }), dc = (t) => me(indexedDB.deleteDatabase(t)), fc = (t, e) => e.forEach(
5926
+ }), mc = (t) => be(indexedDB.deleteDatabase(t)), bc = (t, e) => e.forEach(
5910
5927
  (s) => (
5911
5928
  // @ts-ignore
5912
5929
  t.createObjectStore.apply(t, s)
5913
5930
  )
5914
- ), ze = (t, e, s = "readwrite") => {
5931
+ ), Ue = (t, e, s = "readwrite") => {
5915
5932
  const n = t.transaction(e, s);
5916
- return e.map((i) => _c(n, i));
5917
- }, Zn = (t, e) => me(t.count(e)), gc = (t, e) => me(t.get(e)), ei = (t, e) => me(t.delete(e)), pc = (t, e, s) => me(t.put(e, s)), Xt = (t, e) => me(t.add(e)), kc = (t, e, s) => me(t.getAll(e, s)), mc = (t, e, s) => {
5933
+ return e.map((i) => vc(n, i));
5934
+ }, si = (t, e) => be(t.count(e)), wc = (t, e) => be(t.get(e)), ni = (t, e) => be(t.delete(e)), yc = (t, e, s) => be(t.put(e, s)), Jt = (t, e) => be(t.add(e)), _c = (t, e, s) => be(t.getAll(e, s)), Sc = (t, e, s) => {
5918
5935
  let n = null;
5919
- return yc(t, e, (i) => (n = i, !1), s).then(() => n);
5920
- }, bc = (t, e = null) => mc(t, e, "prev"), wc = (t, e) => Ee((s, n) => {
5936
+ return Cc(t, e, (i) => (n = i, !1), s).then(() => n);
5937
+ }, Dc = (t, e = null) => Sc(t, e, "prev"), Ec = (t, e) => Ce((s, n) => {
5921
5938
  t.onerror = n, t.onsuccess = async (i) => {
5922
5939
  const r = i.target.result;
5923
5940
  if (r === null || await e(r) === !1)
5924
5941
  return s();
5925
5942
  r.continue();
5926
5943
  };
5927
- }), yc = (t, e, s, n = "next") => wc(t.openKeyCursor(e, n), (i) => s(i.key)), _c = (t, e) => t.objectStore(e), Sc = (t, e) => IDBKeyRange.upperBound(t, e), Dc = (t, e) => IDBKeyRange.lowerBound(t, e), Ot = "custom", ti = "updates", si = 500, ni = (t, e = () => {
5944
+ }), Cc = (t, e, s, n = "next") => Ec(t.openKeyCursor(e, n), (i) => s(i.key)), vc = (t, e) => t.objectStore(e), xc = (t, e) => IDBKeyRange.upperBound(t, e), Ac = (t, e) => IDBKeyRange.lowerBound(t, e), zt = "custom", ii = "updates", ri = 500, oi = (t, e = () => {
5928
5945
  }, s = () => {
5929
5946
  }) => {
5930
- const [n] = ze(
5947
+ const [n] = Ue(
5931
5948
  /** @type {IDBDatabase} */
5932
5949
  t.db,
5933
- [ti]
5950
+ [ii]
5934
5951
  );
5935
- return kc(n, Dc(t._dbref, !1)).then((i) => {
5952
+ return _c(n, Ac(t._dbref, !1)).then((i) => {
5936
5953
  t._destroyed || (e(n), y(t.doc, () => {
5937
- i.forEach((r) => bn(t.doc, r));
5954
+ i.forEach((r) => yn(t.doc, r));
5938
5955
  }, t, !1), s(n));
5939
- }).then(() => bc(n).then((i) => {
5956
+ }).then(() => Dc(n).then((i) => {
5940
5957
  t._dbref = i + 1;
5941
- })).then(() => Zn(n).then((i) => {
5958
+ })).then(() => si(n).then((i) => {
5942
5959
  t._dbsize = i;
5943
5960
  })).then(() => n);
5944
- }, Cc = (t, e = !0) => ni(t).then((s) => {
5945
- (e || t._dbsize >= si) && Xt(s, ls(t.doc)).then(() => ei(s, Sc(t._dbref, !0))).then(() => Zn(s).then((n) => {
5961
+ }, Ic = (t, e = !0) => oi(t).then((s) => {
5962
+ (e || t._dbsize >= ri) && Jt(s, ls(t.doc)).then(() => ni(s, xc(t._dbref, !0))).then(() => si(s).then((n) => {
5946
5963
  t._dbsize = n;
5947
5964
  }));
5948
5965
  });
5949
- class Ec extends wt {
5966
+ class Lc extends pt {
5950
5967
  /**
5951
5968
  * @param {string} name
5952
5969
  * @param {Y.Doc} doc
5953
5970
  */
5954
5971
  constructor(e, s) {
5955
- super(), this.doc = s, this.name = e, this._dbref = 0, this._dbsize = 0, this._destroyed = !1, this.db = null, this.synced = !1, this._db = uc(
5972
+ super(), this.doc = s, this.name = e, this._dbref = 0, this._dbsize = 0, this._destroyed = !1, this.db = null, this.synced = !1, this._db = kc(
5956
5973
  e,
5957
- (n) => fc(n, [
5974
+ (n) => bc(n, [
5958
5975
  ["updates", { autoIncrement: !0 }],
5959
5976
  ["custom"]
5960
5977
  ])
5961
- ), this.whenSynced = Ee((n) => this.on("synced", () => n(this))), this._db.then((n) => {
5962
- this.db = n, ni(this, (o) => Xt(o, ls(s)), () => {
5978
+ ), this.whenSynced = Ce((n) => this.on("synced", () => n(this))), this._db.then((n) => {
5979
+ this.db = n, oi(this, (o) => Jt(o, ls(s)), () => {
5963
5980
  if (this._destroyed)
5964
5981
  return this;
5965
5982
  this.synced = !0, this.emit("synced", [this]);
5966
5983
  });
5967
5984
  }), this._storeTimeout = 1e3, this._storeTimeoutId = null, this._storeUpdate = (n, i) => {
5968
5985
  if (this.db && i !== this) {
5969
- const [r] = ze(
5986
+ const [r] = Ue(
5970
5987
  /** @type {IDBDatabase} */
5971
5988
  this.db,
5972
- [ti]
5989
+ [ii]
5973
5990
  );
5974
- Xt(r, n), ++this._dbsize >= si && (this._storeTimeoutId !== null && clearTimeout(this._storeTimeoutId), this._storeTimeoutId = setTimeout(() => {
5975
- Cc(this, !1), this._storeTimeoutId = null;
5991
+ Jt(r, n), ++this._dbsize >= ri && (this._storeTimeoutId !== null && clearTimeout(this._storeTimeoutId), this._storeTimeoutId = setTimeout(() => {
5992
+ Ic(this, !1), this._storeTimeoutId = null;
5976
5993
  }, this._storeTimeout));
5977
5994
  }
5978
5995
  }, s.on("update", this._storeUpdate), this.destroy = this.destroy.bind(this), s.on("destroy", this.destroy);
@@ -5989,7 +6006,7 @@ class Ec extends wt {
5989
6006
  */
5990
6007
  clearData() {
5991
6008
  return this.destroy().then(() => {
5992
- dc(this.name);
6009
+ mc(this.name);
5993
6010
  });
5994
6011
  }
5995
6012
  /**
@@ -5998,8 +6015,8 @@ class Ec extends wt {
5998
6015
  */
5999
6016
  get(e) {
6000
6017
  return this._db.then((s) => {
6001
- const [n] = ze(s, [Ot], "readonly");
6002
- return gc(n, e);
6018
+ const [n] = Ue(s, [zt], "readonly");
6019
+ return wc(n, e);
6003
6020
  });
6004
6021
  }
6005
6022
  /**
@@ -6009,8 +6026,8 @@ class Ec extends wt {
6009
6026
  */
6010
6027
  set(e, s) {
6011
6028
  return this._db.then((n) => {
6012
- const [i] = ze(n, [Ot]);
6013
- return pc(i, s, e);
6029
+ const [i] = Ue(n, [zt]);
6030
+ return yc(i, s, e);
6014
6031
  });
6015
6032
  }
6016
6033
  /**
@@ -6019,29 +6036,29 @@ class Ec extends wt {
6019
6036
  */
6020
6037
  del(e) {
6021
6038
  return this._db.then((s) => {
6022
- const [n] = ze(s, [Ot]);
6023
- return ei(n, e);
6039
+ const [n] = Ue(s, [zt]);
6040
+ return ni(n, e);
6024
6041
  });
6025
6042
  }
6026
6043
  }
6027
6044
  var M = /* @__PURE__ */ ((t) => (t.CanPlay = "can-play", t.CanMove = "can-move", t.CanSpin = "can-spin", t.CanGrow = "can-grow", t.CanToggle = "can-toggle", t.CanDuplicate = "can-duplicate", t.CanPost = "can-post", t))(M || {});
6028
- function vc(t) {
6045
+ function jc(t) {
6029
6046
  return t.id;
6030
6047
  }
6031
- function ii(t) {
6048
+ function ci(t) {
6032
6049
  return document.getElementById(t);
6033
6050
  }
6034
- const xc = {
6051
+ const Mc = {
6035
6052
  ctrlKey: "Control",
6036
6053
  altKey: "Alt",
6037
6054
  shiftKey: "Shift",
6038
6055
  metaKey: "Meta"
6039
- }, Ac = "can-duplicate-to";
6040
- var q = /* @__PURE__ */ ((t) => (t.CanPlay = "can-play", t.CanMove = "can-move", t.CanSpin = "can-spin", t.CanGrow = "can-grow", t.CanToggle = "can-toggle", t.CanDuplicate = "can-duplicate", t.CanPost = "can-post", t))(q || {});
6041
- function Ic(t) {
6056
+ }, Tc = "can-duplicate-to";
6057
+ var K = /* @__PURE__ */ ((t) => (t.CanPlay = "can-play", t.CanMove = "can-move", t.CanSpin = "can-spin", t.CanGrow = "can-grow", t.CanToggle = "can-toggle", t.CanDuplicate = "can-duplicate", t.CanPost = "can-post", t))(K || {});
6058
+ function Uc(t) {
6042
6059
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
6043
6060
  }
6044
- const Lc = [
6061
+ const zc = [
6045
6062
  "2 girls 1 cup",
6046
6063
  "2g1c",
6047
6064
  "4r5e",
@@ -8867,55 +8884,55 @@ const Lc = [
8867
8884
  "zoophilia",
8868
8885
  "🖕"
8869
8886
  ];
8870
- var jc = Lc;
8871
- const Mc = /* @__PURE__ */ Ic(jc), Uc = (t, e = 300) => {
8887
+ var Oc = zc;
8888
+ const Rc = /* @__PURE__ */ Uc(Oc), Nc = (t, e = 300) => {
8872
8889
  let s;
8873
8890
  return function(...n) {
8874
8891
  clearTimeout(s), s = setTimeout(() => t.apply(this, n), e);
8875
8892
  };
8876
- }, ri = `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='44' height='53' viewport='0 0 100 100' style='fill:black;font-size:26px;'><text y='40%'>🚿</text></svg>")
8893
+ }, ai = `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='44' height='53' viewport='0 0 100 100' style='fill:black;font-size:26px;'><text y='40%'>🚿</text></svg>")
8877
8894
  16 0,
8878
- auto`, Tc = `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='48' viewport='0 0 100 100' style='fill:black;font-size:24px;'><text y='50%'>✂️</text></svg>") 16 0,auto`;
8879
- function Ks(t, { getData: e, getElement: s, getLocalData: n, setLocalData: i }) {
8895
+ auto`, Bc = `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='48' viewport='0 0 100 100' style='fill:black;font-size:24px;'><text y='50%'>✂️</text></svg>") 16 0,auto`;
8896
+ function Xs(t, { getData: e, getElement: s, getLocalData: n, setLocalData: i }) {
8880
8897
  const r = e(), o = n(), c = s();
8881
8898
  if (o.isHovering = !0, t.altKey) {
8882
8899
  if (r.scale <= 0.5) {
8883
8900
  c.style.cursor = "not-allowed";
8884
8901
  return;
8885
8902
  }
8886
- c.style.cursor = Tc;
8903
+ c.style.cursor = Bc;
8887
8904
  } else {
8888
8905
  if (r.scale >= r.maxScale) {
8889
8906
  c.style.cursor = "not-allowed";
8890
8907
  return;
8891
8908
  }
8892
- c.style.cursor = ri;
8909
+ c.style.cursor = ai;
8893
8910
  }
8894
8911
  i(o);
8895
8912
  }
8896
- function st(t) {
8913
+ function tt(t) {
8897
8914
  if ("touches" in t) {
8898
8915
  const { clientX: e, clientY: s } = t.touches[0];
8899
8916
  return { clientX: e, clientY: s };
8900
8917
  }
8901
8918
  return { clientX: t.clientX, clientY: t.clientY };
8902
8919
  }
8903
- const oi = {
8904
- [q.CanMove]: {
8920
+ const li = {
8921
+ [K.CanMove]: {
8905
8922
  defaultData: { x: 0, y: 0 },
8906
8923
  defaultLocalData: { startMouseX: 0, startMouseY: 0 },
8907
8924
  updateElement: ({ element: t, data: e }) => {
8908
8925
  t.style.transform = `translate(${e.x}px, ${e.y}px)`;
8909
8926
  },
8910
8927
  onDragStart: (t, { setLocalData: e }) => {
8911
- const { clientX: s, clientY: n } = st(t);
8928
+ const { clientX: s, clientY: n } = tt(t);
8912
8929
  e({
8913
8930
  startMouseX: s,
8914
8931
  startMouseY: n
8915
8932
  });
8916
8933
  },
8917
8934
  onDrag: (t, { data: e, localData: s, setData: n, setLocalData: i, element: r }) => {
8918
- const { clientX: o, clientY: c } = st(t), { top: a, left: l, bottom: h, right: u } = r.getBoundingClientRect();
8935
+ const { clientX: o, clientY: c } = tt(t), { top: a, left: l, bottom: h, right: u } = r.getBoundingClientRect();
8919
8936
  u > window.outerWidth && o > s.startMouseX || h > window.innerHeight && c > s.startMouseY || l < 0 && o < s.startMouseX || a < 0 && c < s.startMouseY || (n({
8920
8937
  x: e.x + o - s.startMouseX,
8921
8938
  y: e.y + c - s.startMouseY
@@ -8923,26 +8940,26 @@ const oi = {
8923
8940
  },
8924
8941
  resetShortcut: "shiftKey"
8925
8942
  },
8926
- [q.CanSpin]: {
8943
+ [K.CanSpin]: {
8927
8944
  defaultData: { rotation: 0 },
8928
8945
  defaultLocalData: { startMouseX: 0 },
8929
8946
  updateElement: ({ element: t, data: e }) => {
8930
8947
  t.style.transform = `rotate(${e.rotation}deg)`;
8931
8948
  },
8932
8949
  onDragStart: (t, { setLocalData: e }) => {
8933
- const { clientX: s } = st(t);
8950
+ const { clientX: s } = tt(t);
8934
8951
  e({
8935
8952
  startMouseX: s
8936
8953
  });
8937
8954
  },
8938
8955
  onDrag: (t, { data: e, localData: s, setData: n, setLocalData: i }) => {
8939
- const { clientX: r } = st(t);
8956
+ const { clientX: r } = tt(t);
8940
8957
  let o = Math.abs(r - s.startMouseX) * 2, c = e.rotation;
8941
8958
  r > s.startMouseX ? c += o : r < s.startMouseX && (c -= o), n({ rotation: c }), i({ startMouseX: r });
8942
8959
  },
8943
8960
  resetShortcut: "shiftKey"
8944
8961
  },
8945
- [q.CanToggle]: {
8962
+ [K.CanToggle]: {
8946
8963
  defaultData: !1,
8947
8964
  updateElement: ({ element: t, data: e }) => {
8948
8965
  t.classList.toggle("clicked", e);
@@ -8952,7 +8969,7 @@ const oi = {
8952
8969
  },
8953
8970
  resetShortcut: "shiftKey"
8954
8971
  },
8955
- [q.CanGrow]: {
8972
+ [K.CanGrow]: {
8956
8973
  defaultData: { scale: 1 },
8957
8974
  defaultLocalData: { maxScale: 2, isHovering: !1 },
8958
8975
  updateElement: ({ element: t, data: e }) => {
@@ -8965,7 +8982,7 @@ const oi = {
8965
8982
  return;
8966
8983
  r -= 0.1;
8967
8984
  } else {
8968
- if (s.style.cursor = ri, e.scale >= i.maxScale)
8985
+ if (s.style.cursor = ai, e.scale >= i.maxScale)
8969
8986
  return;
8970
8987
  r += 0.1;
8971
8988
  }
@@ -8973,8 +8990,8 @@ const oi = {
8973
8990
  },
8974
8991
  additionalSetup: (t) => {
8975
8992
  t.getElement().addEventListener("mouseenter", (e) => {
8976
- Ks(e, t);
8977
- const s = (n) => Ks(n, t);
8993
+ Xs(e, t);
8994
+ const s = (n) => Xs(n, t);
8978
8995
  document.addEventListener("keydown", s), document.addEventListener("keyup", s), t.getElement().addEventListener("mouseleave", (n) => {
8979
8996
  document.removeEventListener("keydown", s), document.removeEventListener("keyup", s);
8980
8997
  });
@@ -8983,7 +9000,7 @@ const oi = {
8983
9000
  resetShortcut: "shiftKey"
8984
9001
  },
8985
9002
  // TODO: remove this and make it a can-play element. this has too many dependencies to be a part of the core
8986
- [q.CanPost]: {
9003
+ [K.CanPost]: {
8987
9004
  defaultData: [],
8988
9005
  defaultLocalData: { addedEntries: /* @__PURE__ */ new Set() },
8989
9006
  updateElement: ({
@@ -8993,7 +9010,7 @@ const oi = {
8993
9010
  }) => {
8994
9011
  const n = t.filter(
8995
9012
  (r) => !e.has(r.id)
8996
- ), i = ii("guestbookMessages");
9013
+ ), i = ci("guestbookMessages");
8997
9014
  n.forEach((r) => {
8998
9015
  const o = document.createElement("div");
8999
9016
  o.classList.add("guestbook-entry");
@@ -9017,7 +9034,7 @@ const oi = {
9017
9034
  const a = Object.fromEntries(o.entries());
9018
9035
  if (!a.name)
9019
9036
  return c(), !1;
9020
- if (Mc.some((u) => {
9037
+ if (Rc.some((u) => {
9021
9038
  const d = new RegExp(`\\b${u}\\b`, "gi");
9022
9039
  return d.test(a.message) || d.test(a.name);
9023
9040
  }))
@@ -9036,12 +9053,12 @@ const oi = {
9036
9053
  // TODO: add ability to add max # of duplicates
9037
9054
  // TODO: add lifespan to automatically prune
9038
9055
  // TODO: add limit per person / per timeframe.
9039
- [q.CanDuplicate]: {
9056
+ [K.CanDuplicate]: {
9040
9057
  defaultData: [],
9041
9058
  defaultLocalData: [],
9042
9059
  updateElement: ({ data: t, localData: e, setLocalData: s, element: n }) => {
9043
9060
  var h;
9044
- const i = n.getAttribute(q.CanDuplicate), r = document.getElementById(i);
9061
+ const i = n.getAttribute(K.CanDuplicate), r = document.getElementById(i);
9045
9062
  let o = document.getElementById((h = e.slice(-1)) == null ? void 0 : h[0]) ?? null;
9046
9063
  if (!r) {
9047
9064
  console.error(
@@ -9049,7 +9066,7 @@ const oi = {
9049
9066
  );
9050
9067
  return;
9051
9068
  }
9052
- const c = n.getAttribute(Ac);
9069
+ const c = n.getAttribute(Tc);
9053
9070
  function a(u) {
9054
9071
  if (c) {
9055
9072
  const d = document.getElementById(c) || document.querySelector(c);
@@ -9073,12 +9090,12 @@ const oi = {
9073
9090
  s(e);
9074
9091
  },
9075
9092
  onClick: (t, { data: e, element: s, setData: n }) => {
9076
- const r = s.getAttribute(q.CanDuplicate) + "-" + Math.random().toString(36).substr(2, 9);
9093
+ const r = s.getAttribute(K.CanDuplicate) + "-" + Math.random().toString(36).substr(2, 9);
9077
9094
  n([...e, r]);
9078
9095
  }
9079
9096
  }
9080
9097
  };
9081
- class zc {
9098
+ class Fc {
9082
9099
  constructor({
9083
9100
  element: e,
9084
9101
  onChange: s,
@@ -9096,7 +9113,7 @@ class zc {
9096
9113
  additionalSetup: g,
9097
9114
  resetShortcut: m,
9098
9115
  debounceMs: L,
9099
- triggerAwarenessUpdate: je
9116
+ triggerAwarenessUpdate: Le
9100
9117
  }) {
9101
9118
  b(this, "defaultData");
9102
9119
  b(this, "localData");
@@ -9113,29 +9130,29 @@ class zc {
9113
9130
  b(this, "updateElement");
9114
9131
  b(this, "updateElementAwareness");
9115
9132
  b(this, "triggerAwarenessUpdate");
9116
- this.element = e, this.defaultData = i instanceof Function ? i(e) : i, this.localData = r instanceof Function ? r(e) : r, this.triggerAwarenessUpdate = je, this.onChange = s, this.resetShortcut = m, this.debouncedOnChange = Uc(this.onChange, L), this.onAwarenessChange = n, this.updateElement = l, this.updateElementAwareness = h;
9117
- const ys = c === void 0 ? this.defaultData : c;
9133
+ this.element = e, this.defaultData = i instanceof Function ? i(e) : i, this.localData = r instanceof Function ? r(e) : r, this.triggerAwarenessUpdate = Le, this.onChange = s, this.resetShortcut = m, this.debouncedOnChange = Nc(this.onChange, L), this.onAwarenessChange = n, this.updateElement = l, this.updateElementAwareness = h;
9134
+ const Ss = c === void 0 ? this.defaultData : c;
9118
9135
  a !== void 0 && (this.__awareness = a);
9119
- const _s = o instanceof Function ? o(e) : o;
9120
- _s !== void 0 && this.setLocalAwareness(_s), this._data = ys, this.__data = ys, u && e.addEventListener("click", (j) => {
9136
+ const Ds = o instanceof Function ? o(e) : o;
9137
+ Ds !== void 0 && this.setLocalAwareness(Ds), this._data = Ss, this.__data = Ss, u && e.addEventListener("click", (j) => {
9121
9138
  u(j, this.getEventHandlerData());
9122
9139
  }), d && (e.addEventListener("touchstart", (j) => {
9123
9140
  j.preventDefault(), f && f(j, this.getEventHandlerData());
9124
- const Me = (re) => {
9141
+ const je = (re) => {
9125
9142
  re.preventDefault(), d(re, this.getEventHandlerData());
9126
- }, Ue = (re) => {
9127
- document.removeEventListener("touchmove", Me), document.removeEventListener("touchend", Ue);
9143
+ }, Me = (re) => {
9144
+ document.removeEventListener("touchmove", je), document.removeEventListener("touchend", Me);
9128
9145
  };
9129
- document.addEventListener("touchmove", Me), document.addEventListener("touchend", Ue);
9146
+ document.addEventListener("touchmove", je), document.addEventListener("touchend", Me);
9130
9147
  }), e.addEventListener("mousedown", (j) => {
9131
9148
  f && f(j, this.getEventHandlerData());
9132
- const Me = (re) => {
9149
+ const je = (re) => {
9133
9150
  re.preventDefault(), d(re, this.getEventHandlerData());
9134
- }, Ue = (re) => {
9135
- document.removeEventListener("mousemove", Me), document.removeEventListener("mouseup", Ue);
9151
+ }, Me = (re) => {
9152
+ document.removeEventListener("mousemove", je), document.removeEventListener("mouseup", Me);
9136
9153
  };
9137
- document.addEventListener("mousemove", Me), document.addEventListener("mouseup", Ue);
9138
- })), g && g(this.getSetupData()), m && (e.title || (e.title = `Hold down the ${xc[m]} key while clicking to reset.`), e.reset = this.reset, e.addEventListener("click", (j) => {
9154
+ document.addEventListener("mousemove", je), document.addEventListener("mouseup", Me);
9155
+ })), g && g(this.getSetupData()), m && (e.title || (e.title = `Hold down the ${Mc[m]} key while clicking to reset.`), e.reset = this.reset, e.addEventListener("click", (j) => {
9139
9156
  switch (m) {
9140
9157
  case "ctrlKey":
9141
9158
  if (!j.ctrlKey)
@@ -9226,14 +9243,16 @@ class zc {
9226
9243
  this.setData(this.defaultData);
9227
9244
  }
9228
9245
  }
9229
- const Oc = "playhtml.spencerc99.partykit.dev", Rt = new Ie(), Rc = window.location.href;
9230
- let Y, B, te;
9231
- const Ys = /* @__PURE__ */ new Map();
9232
- function ci({
9233
- room: t = Rc,
9234
- host: e = Oc
9246
+ const Hc = "playhtml.spencerc99.partykit.dev", Ot = new ke(), Vc = window.location.href;
9247
+ let J, B, F;
9248
+ const Gs = /* @__PURE__ */ new Map();
9249
+ let ys = !1, Xt = !0;
9250
+ function hi({
9251
+ // TODO: if it is a localhost url, need to make some deterministic way to connect to the same room.
9252
+ room: t = Vc,
9253
+ host: e = Hc
9235
9254
  } = {}) {
9236
- if (!Se.firstSetup) {
9255
+ if (!Xt) {
9237
9256
  console.error("playhtml already set up!");
9238
9257
  return;
9239
9258
  }
@@ -9245,46 +9264,46 @@ function ci({
9245
9264
  ࿂࿂࿂࿂ https://playhtml.fun ࿂࿂࿂࿂
9246
9265
  ࿂࿂࿂࿂ ࿂ ࿂ ࿂ ࿂ ࿂࿂࿂࿂
9247
9266
  ࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂`
9248
- ), Y = new hc(s, t, Rt), B = Rt.getMap("playhtml-global"), te = /* @__PURE__ */ new Map(), new Ec(t, Rt), Se.globalData = B, Se.elementHandlers = te, Y.on("sync", (n) => {
9249
- n || console.error("Issue connecting to yjs..."), Vc();
9250
- }), Y;
9267
+ ), J = new pc(s, t, Ot), B = Ot.getMap("playhtml-global"), F = /* @__PURE__ */ new Map(), new Lc(t, Ot), Gt.globalData = B, Gt.elementHandlers = F, J.on("sync", (n) => {
9268
+ n || console.error("Issue connecting to yjs..."), ys = !0, Jc();
9269
+ }), J;
9251
9270
  }
9252
9271
  setTimeout(() => {
9253
- Y || (console.error(
9272
+ J || (console.error(
9254
9273
  "You are using a deprecated version of playhtml. Please call `playhtml.init()` explicitly rather than just importing the library. Refer to https://github.com/spencerc99/playhtml#usage for reference."
9255
- ), ci());
9274
+ ), hi());
9256
9275
  }, 3e3);
9257
- function Nc(t, e) {
9258
- const s = Y.awareness.getLocalState();
9276
+ function $c(t, e) {
9277
+ const s = J.awareness.getLocalState();
9259
9278
  return ((s == null ? void 0 : s[t]) ?? {})[e];
9260
9279
  }
9261
- function ws(t) {
9280
+ function _s(t) {
9262
9281
  return t instanceof HTMLElement;
9263
9282
  }
9264
- function Bc(t, e, s, n) {
9283
+ function qc(t, e, s, n) {
9265
9284
  const i = B.get(e), r = {
9266
9285
  ...s,
9267
9286
  data: i.get(n) ?? s.defaultData,
9268
- awareness: Nc(e, n) ?? s.myDefaultAwareness !== void 0 ? [s.myDefaultAwareness] : void 0,
9287
+ awareness: $c(e, n) ?? s.myDefaultAwareness !== void 0 ? [s.myDefaultAwareness] : void 0,
9269
9288
  element: t,
9270
9289
  onChange: (o) => {
9271
9290
  i.get(n) !== o && i.set(n, o);
9272
9291
  },
9273
9292
  onAwarenessChange: (o) => {
9274
9293
  var a;
9275
- const c = ((a = Y.awareness.getLocalState()) == null ? void 0 : a[e]) || {};
9276
- c[n] !== o && (c[n] = o, Y.awareness.setLocalStateField(e, c));
9294
+ const c = ((a = J.awareness.getLocalState()) == null ? void 0 : a[e]) || {};
9295
+ c[n] !== o && (c[n] = o, J.awareness.setLocalStateField(e, c));
9277
9296
  },
9278
9297
  triggerAwarenessUpdate: () => {
9279
- ai();
9298
+ ui();
9280
9299
  }
9281
9300
  };
9282
- return new zc(r);
9301
+ return new Fc(r);
9283
9302
  }
9284
- function Fc(t) {
9303
+ function Kc(t) {
9285
9304
  return t.defaultData !== void 0 && t.updateElement !== void 0;
9286
9305
  }
9287
- function Hc(t, e) {
9306
+ function Yc(t, e) {
9288
9307
  if (t === M.CanPlay) {
9289
9308
  const s = e;
9290
9309
  return {
@@ -9301,19 +9320,19 @@ function Hc(t, e) {
9301
9320
  debounceMs: s.debounceMs
9302
9321
  };
9303
9322
  }
9304
- return oi[t];
9323
+ return li[t];
9305
9324
  }
9306
- function ai() {
9325
+ function ui() {
9307
9326
  const t = /* @__PURE__ */ new Map();
9308
9327
  function e(s, n, i, r) {
9309
9328
  t.has(s) || t.set(s, /* @__PURE__ */ new Map());
9310
9329
  const o = t.get(s);
9311
9330
  o.has(n) || o.set(n, /* @__PURE__ */ new Map()), o.get(n).set(i, r);
9312
9331
  }
9313
- Y.awareness.getStates().forEach((s, n) => {
9332
+ J.awareness.getStates().forEach((s, n) => {
9314
9333
  var i;
9315
9334
  for (const [r, o] of Object.entries(s)) {
9316
- const c = te.get(r);
9335
+ const c = F.get(r);
9317
9336
  if (c)
9318
9337
  for (const [a, l] of c) {
9319
9338
  if (!(a in o))
@@ -9328,7 +9347,7 @@ function ai() {
9328
9347
  }
9329
9348
  }
9330
9349
  for (const [r, o] of t) {
9331
- const c = te.get(r);
9350
+ const c = F.get(r);
9332
9351
  if (c)
9333
9352
  for (const [a, l] of c) {
9334
9353
  const h = (i = o.get(a)) == null ? void 0 : i.values();
@@ -9340,48 +9359,48 @@ function ai() {
9340
9359
  }
9341
9360
  });
9342
9361
  }
9343
- function Vc() {
9362
+ function Jc() {
9344
9363
  console.log("[PLAYHTML]: Setting up elements... Time to have some fun 🛝");
9345
9364
  for (const t of Object.values(M)) {
9346
9365
  const e = Array.from(
9347
9366
  document.querySelectorAll(`[${t}]`)
9348
- ).filter(ws);
9367
+ ).filter(_s);
9349
9368
  if (e.length)
9350
9369
  for (let s = 0; s < e.length; s++) {
9351
9370
  const n = e[s];
9352
- Ct(n, t);
9371
+ Dt(n, t);
9353
9372
  }
9354
9373
  }
9355
- Se.firstSetup && (B.observe((t) => {
9374
+ Xt && (B.observe((t) => {
9356
9375
  t.changes.keys.forEach((e, s) => {
9357
9376
  e.action === "add" && B.set(s, B.get(s));
9358
9377
  });
9359
- }), Y.awareness.on("change", () => ai()), Se.firstSetup = !1);
9378
+ }), J.awareness.on("change", () => ui()), Xt = !1);
9360
9379
  }
9361
- const Se = {
9362
- init: ci,
9363
- setupPlayElement: Kc,
9364
- setupPlayElementForTag: Ct,
9380
+ const Gt = {
9381
+ init: hi,
9382
+ setupPlayElement: Wc,
9383
+ removePlayElement: Pc,
9384
+ setupPlayElementForTag: Dt,
9365
9385
  globalData: void 0,
9366
- elementHandlers: void 0,
9367
- firstSetup: !0
9386
+ elementHandlers: void 0
9368
9387
  };
9369
- window.playhtml = Se;
9370
- function $c(t) {
9371
- if (te.has(t))
9388
+ window.playhtml = Gt;
9389
+ function Xc(t) {
9390
+ if (F.has(t) || !ys)
9372
9391
  return;
9373
- te.set(t, /* @__PURE__ */ new Map()), t !== M.CanPlay && oi[t], B.get(t) || B.set(t, new de());
9392
+ F.set(t, /* @__PURE__ */ new Map()), t !== M.CanPlay && li[t], B.get(t) || B.set(t, new de());
9374
9393
  const e = B.get(t);
9375
9394
  e.observe((s) => {
9376
9395
  s.changes.keys.forEach((n, i) => {
9377
- const r = te.get(t);
9396
+ const r = F.get(t);
9378
9397
  if (n.action === "add") {
9379
- const o = ii(i);
9380
- if (!ws(o)) {
9398
+ const o = ci(i);
9399
+ if (!_s(o)) {
9381
9400
  console.log(`Element ${i} not an HTML element. Ignoring.`);
9382
9401
  return;
9383
9402
  }
9384
- Ct(o, t);
9403
+ Dt(o, t);
9385
9404
  } else if (n.action === "update") {
9386
9405
  const o = r.get(i);
9387
9406
  o.__data = e.get(i);
@@ -9390,7 +9409,7 @@ function $c(t) {
9390
9409
  });
9391
9410
  });
9392
9411
  }
9393
- function qc(t, e) {
9412
+ function Gc(t, e) {
9394
9413
  const s = t.getAttribute(e);
9395
9414
  switch (e) {
9396
9415
  case M.CanPlay:
@@ -9408,40 +9427,40 @@ function qc(t, e) {
9408
9427
  return console.error(`Unhandled tag found in validation: ${e}`), !1;
9409
9428
  }
9410
9429
  }
9411
- function Ct(t, e) {
9430
+ function Dt(t, e) {
9412
9431
  var c;
9413
- if (!qc(t, e))
9432
+ if (!Gc(t, e) || !ys)
9414
9433
  return;
9415
9434
  if (!t.id) {
9416
9435
  const a = t.getAttribute("selector-id");
9417
9436
  if (a) {
9418
- const l = Ys.get(a) ?? 0;
9419
- t.id = btoa(`${e}-${a}-${l}`), Ys.set(a, l + 1);
9437
+ const l = Gs.get(a) ?? 0;
9438
+ t.id = btoa(`${e}-${a}-${l}`), Gs.set(a, l + 1);
9420
9439
  } else
9421
9440
  t.id = btoa(`${e}-${t.innerHTML}}`);
9422
9441
  }
9423
- const s = vc(t);
9442
+ const s = jc(t);
9424
9443
  if (!s) {
9425
9444
  console.error(
9426
9445
  `Element ${t} does not have an acceptable ID. Please add an ID to the element to register it as a playhtml element.`
9427
9446
  );
9428
9447
  return;
9429
9448
  }
9430
- $c(e);
9431
- const n = te.get(e);
9449
+ Xc(e);
9450
+ const n = F.get(e);
9432
9451
  if (n.has(s))
9433
9452
  return;
9434
- const i = Hc(
9453
+ const i = Yc(
9435
9454
  e,
9436
9455
  t
9437
9456
  );
9438
- if (!Fc(i)) {
9457
+ if (!Kc(i)) {
9439
9458
  console.error(
9440
9459
  `Element ${s} does not have proper info to initial a playhtml element. Please refer to https://github.com/spencerc99/playhtml#can-play for troubleshooting help.`
9441
9460
  );
9442
9461
  return;
9443
9462
  }
9444
- const r = B.get(e), o = Bc(
9463
+ const r = B.get(e), o = qc(
9445
9464
  t,
9446
9465
  e,
9447
9466
  i,
@@ -9449,14 +9468,21 @@ function Ct(t, e) {
9449
9468
  );
9450
9469
  n.set(s, o), r.get(s) === void 0 && i.defaultData !== void 0 && r.set(s, i.defaultData), (c = o.triggerAwarenessUpdate) == null || c.call(o), t.classList.add("__playhtml-element"), t.classList.add(`__playhtml-${e}`), t.style.setProperty("--jiggle-delay", `${Math.random() * 1}s;}`);
9451
9470
  }
9452
- function Kc(t) {
9453
- if (!ws(t)) {
9471
+ function Wc(t) {
9472
+ if (!_s(t)) {
9454
9473
  console.log(`Element ${t.id} not an HTML element. Ignoring.`);
9455
9474
  return;
9456
9475
  }
9457
9476
  for (const e of Object.values(M))
9458
- t.hasAttribute(e) && Ct(t, e);
9477
+ t.hasAttribute(e) && Dt(t, e);
9478
+ }
9479
+ function Pc(t) {
9480
+ if (!(!t || !t.id))
9481
+ for (const e of Object.keys(F)) {
9482
+ const s = F.get(e);
9483
+ s.has(t.id) && s.delete(t.id);
9484
+ }
9459
9485
  }
9460
9486
  export {
9461
- Se as playhtml
9487
+ Gt as playhtml
9462
9488
  };