liveroom-client-element 0.0.3 → 0.0.4

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,3486 +0,0 @@
1
- var Ze = Object.defineProperty;
2
- var Ye = (n, s, t) => s in n ? Ze(n, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[s] = t;
3
- var g = (n, s, t) => (Ye(n, typeof s != "symbol" ? s + "" : s, t), t);
4
- /**
5
- * @license
6
- * Copyright 2019 Google LLC
7
- * SPDX-License-Identifier: BSD-3-Clause
8
- */
9
- const pt = window, Ut = pt.ShadowRoot && (pt.ShadyCSS === void 0 || pt.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, Dt = Symbol(), te = /* @__PURE__ */ new WeakMap();
10
- let ge = class {
11
- constructor(s, t, e) {
12
- if (this._$cssResult$ = !0, e !== Dt)
13
- throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
14
- this.cssText = s, this.t = t;
15
- }
16
- get styleSheet() {
17
- let s = this.o;
18
- const t = this.t;
19
- if (Ut && s === void 0) {
20
- const e = t !== void 0 && t.length === 1;
21
- e && (s = te.get(t)), s === void 0 && ((this.o = s = new CSSStyleSheet()).replaceSync(this.cssText), e && te.set(t, s));
22
- }
23
- return s;
24
- }
25
- toString() {
26
- return this.cssText;
27
- }
28
- };
29
- const Qe = (n) => new ge(typeof n == "string" ? n : n + "", void 0, Dt), ts = (n, ...s) => {
30
- const t = n.length === 1 ? n[0] : s.reduce((e, i, r) => e + ((o) => {
31
- if (o._$cssResult$ === !0)
32
- return o.cssText;
33
- if (typeof o == "number")
34
- return o;
35
- throw Error("Value passed to 'css' function must be a 'css' function result: " + o + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
36
- })(i) + n[r + 1], n[0]);
37
- return new ge(t, n, Dt);
38
- }, es = (n, s) => {
39
- Ut ? n.adoptedStyleSheets = s.map((t) => t instanceof CSSStyleSheet ? t : t.styleSheet) : s.forEach((t) => {
40
- const e = document.createElement("style"), i = pt.litNonce;
41
- i !== void 0 && e.setAttribute("nonce", i), e.textContent = t.cssText, n.appendChild(e);
42
- });
43
- }, ee = Ut ? (n) => n : (n) => n instanceof CSSStyleSheet ? ((s) => {
44
- let t = "";
45
- for (const e of s.cssRules)
46
- t += e.cssText;
47
- return Qe(t);
48
- })(n) : n;
49
- /**
50
- * @license
51
- * Copyright 2017 Google LLC
52
- * SPDX-License-Identifier: BSD-3-Clause
53
- */
54
- var $t;
55
- const ft = window, se = ft.trustedTypes, ss = se ? se.emptyScript : "", ne = ft.reactiveElementPolyfillSupport, Mt = { toAttribute(n, s) {
56
- switch (s) {
57
- case Boolean:
58
- n = n ? ss : null;
59
- break;
60
- case Object:
61
- case Array:
62
- n = n == null ? n : JSON.stringify(n);
63
- }
64
- return n;
65
- }, fromAttribute(n, s) {
66
- let t = n;
67
- switch (s) {
68
- case Boolean:
69
- t = n !== null;
70
- break;
71
- case Number:
72
- t = n === null ? null : Number(n);
73
- break;
74
- case Object:
75
- case Array:
76
- try {
77
- t = JSON.parse(n);
78
- } catch {
79
- t = null;
80
- }
81
- }
82
- return t;
83
- } }, ye = (n, s) => s !== n && (s == s || n == n), Ct = { attribute: !0, type: String, converter: Mt, reflect: !1, hasChanged: ye }, Rt = "finalized";
84
- let F = class extends HTMLElement {
85
- constructor() {
86
- super(), this._$Ei = /* @__PURE__ */ new Map(), this.isUpdatePending = !1, this.hasUpdated = !1, this._$El = null, this.u();
87
- }
88
- static addInitializer(s) {
89
- var t;
90
- this.finalize(), ((t = this.h) !== null && t !== void 0 ? t : this.h = []).push(s);
91
- }
92
- static get observedAttributes() {
93
- this.finalize();
94
- const s = [];
95
- return this.elementProperties.forEach((t, e) => {
96
- const i = this._$Ep(e, t);
97
- i !== void 0 && (this._$Ev.set(i, e), s.push(i));
98
- }), s;
99
- }
100
- static createProperty(s, t = Ct) {
101
- if (t.state && (t.attribute = !1), this.finalize(), this.elementProperties.set(s, t), !t.noAccessor && !this.prototype.hasOwnProperty(s)) {
102
- const e = typeof s == "symbol" ? Symbol() : "__" + s, i = this.getPropertyDescriptor(s, e, t);
103
- i !== void 0 && Object.defineProperty(this.prototype, s, i);
104
- }
105
- }
106
- static getPropertyDescriptor(s, t, e) {
107
- return { get() {
108
- return this[t];
109
- }, set(i) {
110
- const r = this[s];
111
- this[t] = i, this.requestUpdate(s, r, e);
112
- }, configurable: !0, enumerable: !0 };
113
- }
114
- static getPropertyOptions(s) {
115
- return this.elementProperties.get(s) || Ct;
116
- }
117
- static finalize() {
118
- if (this.hasOwnProperty(Rt))
119
- return !1;
120
- this[Rt] = !0;
121
- const s = Object.getPrototypeOf(this);
122
- if (s.finalize(), s.h !== void 0 && (this.h = [...s.h]), this.elementProperties = new Map(s.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) {
123
- const t = this.properties, e = [...Object.getOwnPropertyNames(t), ...Object.getOwnPropertySymbols(t)];
124
- for (const i of e)
125
- this.createProperty(i, t[i]);
126
- }
127
- return this.elementStyles = this.finalizeStyles(this.styles), !0;
128
- }
129
- static finalizeStyles(s) {
130
- const t = [];
131
- if (Array.isArray(s)) {
132
- const e = new Set(s.flat(1 / 0).reverse());
133
- for (const i of e)
134
- t.unshift(ee(i));
135
- } else
136
- s !== void 0 && t.push(ee(s));
137
- return t;
138
- }
139
- static _$Ep(s, t) {
140
- const e = t.attribute;
141
- return e === !1 ? void 0 : typeof e == "string" ? e : typeof s == "string" ? s.toLowerCase() : void 0;
142
- }
143
- u() {
144
- var s;
145
- this._$E_ = new Promise((t) => this.enableUpdating = t), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), (s = this.constructor.h) === null || s === void 0 || s.forEach((t) => t(this));
146
- }
147
- addController(s) {
148
- var t, e;
149
- ((t = this._$ES) !== null && t !== void 0 ? t : this._$ES = []).push(s), this.renderRoot !== void 0 && this.isConnected && ((e = s.hostConnected) === null || e === void 0 || e.call(s));
150
- }
151
- removeController(s) {
152
- var t;
153
- (t = this._$ES) === null || t === void 0 || t.splice(this._$ES.indexOf(s) >>> 0, 1);
154
- }
155
- _$Eg() {
156
- this.constructor.elementProperties.forEach((s, t) => {
157
- this.hasOwnProperty(t) && (this._$Ei.set(t, this[t]), delete this[t]);
158
- });
159
- }
160
- createRenderRoot() {
161
- var s;
162
- const t = (s = this.shadowRoot) !== null && s !== void 0 ? s : this.attachShadow(this.constructor.shadowRootOptions);
163
- return es(t, this.constructor.elementStyles), t;
164
- }
165
- connectedCallback() {
166
- var s;
167
- this.renderRoot === void 0 && (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (s = this._$ES) === null || s === void 0 || s.forEach((t) => {
168
- var e;
169
- return (e = t.hostConnected) === null || e === void 0 ? void 0 : e.call(t);
170
- });
171
- }
172
- enableUpdating(s) {
173
- }
174
- disconnectedCallback() {
175
- var s;
176
- (s = this._$ES) === null || s === void 0 || s.forEach((t) => {
177
- var e;
178
- return (e = t.hostDisconnected) === null || e === void 0 ? void 0 : e.call(t);
179
- });
180
- }
181
- attributeChangedCallback(s, t, e) {
182
- this._$AK(s, e);
183
- }
184
- _$EO(s, t, e = Ct) {
185
- var i;
186
- const r = this.constructor._$Ep(s, e);
187
- if (r !== void 0 && e.reflect === !0) {
188
- const o = (((i = e.converter) === null || i === void 0 ? void 0 : i.toAttribute) !== void 0 ? e.converter : Mt).toAttribute(t, e.type);
189
- this._$El = s, o == null ? this.removeAttribute(r) : this.setAttribute(r, o), this._$El = null;
190
- }
191
- }
192
- _$AK(s, t) {
193
- var e;
194
- const i = this.constructor, r = i._$Ev.get(s);
195
- if (r !== void 0 && this._$El !== r) {
196
- const o = i.getPropertyOptions(r), l = typeof o.converter == "function" ? { fromAttribute: o.converter } : ((e = o.converter) === null || e === void 0 ? void 0 : e.fromAttribute) !== void 0 ? o.converter : Mt;
197
- this._$El = r, this[r] = l.fromAttribute(t, o.type), this._$El = null;
198
- }
199
- }
200
- requestUpdate(s, t, e) {
201
- let i = !0;
202
- s !== void 0 && (((e = e || this.constructor.getPropertyOptions(s)).hasChanged || ye)(this[s], t) ? (this._$AL.has(s) || this._$AL.set(s, t), e.reflect === !0 && this._$El !== s && (this._$EC === void 0 && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(s, e))) : i = !1), !this.isUpdatePending && i && (this._$E_ = this._$Ej());
203
- }
204
- async _$Ej() {
205
- this.isUpdatePending = !0;
206
- try {
207
- await this._$E_;
208
- } catch (t) {
209
- Promise.reject(t);
210
- }
211
- const s = this.scheduleUpdate();
212
- return s != null && await s, !this.isUpdatePending;
213
- }
214
- scheduleUpdate() {
215
- return this.performUpdate();
216
- }
217
- performUpdate() {
218
- var s;
219
- if (!this.isUpdatePending)
220
- return;
221
- this.hasUpdated, this._$Ei && (this._$Ei.forEach((i, r) => this[r] = i), this._$Ei = void 0);
222
- let t = !1;
223
- const e = this._$AL;
224
- try {
225
- t = this.shouldUpdate(e), t ? (this.willUpdate(e), (s = this._$ES) === null || s === void 0 || s.forEach((i) => {
226
- var r;
227
- return (r = i.hostUpdate) === null || r === void 0 ? void 0 : r.call(i);
228
- }), this.update(e)) : this._$Ek();
229
- } catch (i) {
230
- throw t = !1, this._$Ek(), i;
231
- }
232
- t && this._$AE(e);
233
- }
234
- willUpdate(s) {
235
- }
236
- _$AE(s) {
237
- var t;
238
- (t = this._$ES) === null || t === void 0 || t.forEach((e) => {
239
- var i;
240
- return (i = e.hostUpdated) === null || i === void 0 ? void 0 : i.call(e);
241
- }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(s)), this.updated(s);
242
- }
243
- _$Ek() {
244
- this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
245
- }
246
- get updateComplete() {
247
- return this.getUpdateComplete();
248
- }
249
- getUpdateComplete() {
250
- return this._$E_;
251
- }
252
- shouldUpdate(s) {
253
- return !0;
254
- }
255
- update(s) {
256
- this._$EC !== void 0 && (this._$EC.forEach((t, e) => this._$EO(e, this[e], t)), this._$EC = void 0), this._$Ek();
257
- }
258
- updated(s) {
259
- }
260
- firstUpdated(s) {
261
- }
262
- };
263
- F[Rt] = !0, F.elementProperties = /* @__PURE__ */ new Map(), F.elementStyles = [], F.shadowRootOptions = { mode: "open" }, ne == null || ne({ ReactiveElement: F }), (($t = ft.reactiveElementVersions) !== null && $t !== void 0 ? $t : ft.reactiveElementVersions = []).push("1.6.2");
264
- /**
265
- * @license
266
- * Copyright 2017 Google LLC
267
- * SPDX-License-Identifier: BSD-3-Clause
268
- */
269
- var Tt;
270
- const vt = window, q = vt.trustedTypes, ie = q ? q.createPolicy("lit-html", { createHTML: (n) => n }) : void 0, Nt = "$lit$", I = `lit$${(Math.random() + "").slice(9)}$`, me = "?" + I, ns = `<${me}>`, z = document, nt = () => z.createComment(""), it = (n) => n === null || typeof n != "object" && typeof n != "function", _e = Array.isArray, is = (n) => _e(n) || typeof (n == null ? void 0 : n[Symbol.iterator]) == "function", kt = `[
271
- \f\r]`, Y = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, re = /-->/g, oe = />/g, V = RegExp(`>|${kt}(?:([^\\s"'>=/]+)(${kt}*=${kt}*(?:[^
272
- \f\r"'\`<>=]|("|')|))|$)`, "g"), ae = /'/g, he = /"/g, we = /^(?:script|style|textarea|title)$/i, rs = (n) => (s, ...t) => ({ _$litType$: n, strings: s, values: t }), le = rs(1), X = Symbol.for("lit-noChange"), S = Symbol.for("lit-nothing"), ce = /* @__PURE__ */ new WeakMap(), J = z.createTreeWalker(z, 129, null, !1);
273
- function be(n, s) {
274
- if (!Array.isArray(n) || !n.hasOwnProperty("raw"))
275
- throw Error("invalid template strings array");
276
- return ie !== void 0 ? ie.createHTML(s) : s;
277
- }
278
- const os = (n, s) => {
279
- const t = n.length - 1, e = [];
280
- let i, r = s === 2 ? "<svg>" : "", o = Y;
281
- for (let l = 0; l < t; l++) {
282
- const u = n[l];
283
- let d, _, w = -1, T = 0;
284
- for (; T < u.length && (o.lastIndex = T, _ = o.exec(u), _ !== null); )
285
- T = o.lastIndex, o === Y ? _[1] === "!--" ? o = re : _[1] !== void 0 ? o = oe : _[2] !== void 0 ? (we.test(_[2]) && (i = RegExp("</" + _[2], "g")), o = V) : _[3] !== void 0 && (o = V) : o === V ? _[0] === ">" ? (o = i ?? Y, w = -1) : _[1] === void 0 ? w = -2 : (w = o.lastIndex - _[2].length, d = _[1], o = _[3] === void 0 ? V : _[3] === '"' ? he : ae) : o === he || o === ae ? o = V : o === re || o === oe ? o = Y : (o = V, i = void 0);
286
- const O = o === V && n[l + 1].startsWith("/>") ? " " : "";
287
- r += o === Y ? u + ns : w >= 0 ? (e.push(d), u.slice(0, w) + Nt + u.slice(w) + I + O) : u + I + (w === -2 ? (e.push(void 0), l) : O);
288
- }
289
- return [be(n, r + (n[t] || "<?>") + (s === 2 ? "</svg>" : "")), e];
290
- };
291
- class rt {
292
- constructor({ strings: s, _$litType$: t }, e) {
293
- let i;
294
- this.parts = [];
295
- let r = 0, o = 0;
296
- const l = s.length - 1, u = this.parts, [d, _] = os(s, t);
297
- if (this.el = rt.createElement(d, e), J.currentNode = this.el.content, t === 2) {
298
- const w = this.el.content, T = w.firstChild;
299
- T.remove(), w.append(...T.childNodes);
300
- }
301
- for (; (i = J.nextNode()) !== null && u.length < l; ) {
302
- if (i.nodeType === 1) {
303
- if (i.hasAttributes()) {
304
- const w = [];
305
- for (const T of i.getAttributeNames())
306
- if (T.endsWith(Nt) || T.startsWith(I)) {
307
- const O = _[o++];
308
- if (w.push(T), O !== void 0) {
309
- const wt = i.getAttribute(O.toLowerCase() + Nt).split(I), H = /([.?@])?(.*)/.exec(O);
310
- u.push({ type: 1, index: r, name: H[2], strings: wt, ctor: H[1] === "." ? hs : H[1] === "?" ? cs : H[1] === "@" ? us : mt });
311
- } else
312
- u.push({ type: 6, index: r });
313
- }
314
- for (const T of w)
315
- i.removeAttribute(T);
316
- }
317
- if (we.test(i.tagName)) {
318
- const w = i.textContent.split(I), T = w.length - 1;
319
- if (T > 0) {
320
- i.textContent = q ? q.emptyScript : "";
321
- for (let O = 0; O < T; O++)
322
- i.append(w[O], nt()), J.nextNode(), u.push({ type: 2, index: ++r });
323
- i.append(w[T], nt());
324
- }
325
- }
326
- } else if (i.nodeType === 8)
327
- if (i.data === me)
328
- u.push({ type: 2, index: r });
329
- else {
330
- let w = -1;
331
- for (; (w = i.data.indexOf(I, w + 1)) !== -1; )
332
- u.push({ type: 7, index: r }), w += I.length - 1;
333
- }
334
- r++;
335
- }
336
- }
337
- static createElement(s, t) {
338
- const e = z.createElement("template");
339
- return e.innerHTML = s, e;
340
- }
341
- }
342
- function K(n, s, t = n, e) {
343
- var i, r, o, l;
344
- if (s === X)
345
- return s;
346
- let u = e !== void 0 ? (i = t._$Co) === null || i === void 0 ? void 0 : i[e] : t._$Cl;
347
- const d = it(s) ? void 0 : s._$litDirective$;
348
- return (u == null ? void 0 : u.constructor) !== d && ((r = u == null ? void 0 : u._$AO) === null || r === void 0 || r.call(u, !1), d === void 0 ? u = void 0 : (u = new d(n), u._$AT(n, t, e)), e !== void 0 ? ((o = (l = t)._$Co) !== null && o !== void 0 ? o : l._$Co = [])[e] = u : t._$Cl = u), u !== void 0 && (s = K(n, u._$AS(n, s.values), u, e)), s;
349
- }
350
- class as {
351
- constructor(s, t) {
352
- this._$AV = [], this._$AN = void 0, this._$AD = s, this._$AM = t;
353
- }
354
- get parentNode() {
355
- return this._$AM.parentNode;
356
- }
357
- get _$AU() {
358
- return this._$AM._$AU;
359
- }
360
- u(s) {
361
- var t;
362
- const { el: { content: e }, parts: i } = this._$AD, r = ((t = s == null ? void 0 : s.creationScope) !== null && t !== void 0 ? t : z).importNode(e, !0);
363
- J.currentNode = r;
364
- let o = J.nextNode(), l = 0, u = 0, d = i[0];
365
- for (; d !== void 0; ) {
366
- if (l === d.index) {
367
- let _;
368
- d.type === 2 ? _ = new at(o, o.nextSibling, this, s) : d.type === 1 ? _ = new d.ctor(o, d.name, d.strings, this, s) : d.type === 6 && (_ = new ps(o, this, s)), this._$AV.push(_), d = i[++u];
369
- }
370
- l !== (d == null ? void 0 : d.index) && (o = J.nextNode(), l++);
371
- }
372
- return J.currentNode = z, r;
373
- }
374
- v(s) {
375
- let t = 0;
376
- for (const e of this._$AV)
377
- e !== void 0 && (e.strings !== void 0 ? (e._$AI(s, e, t), t += e.strings.length - 2) : e._$AI(s[t])), t++;
378
- }
379
- }
380
- class at {
381
- constructor(s, t, e, i) {
382
- var r;
383
- this.type = 2, this._$AH = S, this._$AN = void 0, this._$AA = s, this._$AB = t, this._$AM = e, this.options = i, this._$Cp = (r = i == null ? void 0 : i.isConnected) === null || r === void 0 || r;
384
- }
385
- get _$AU() {
386
- var s, t;
387
- return (t = (s = this._$AM) === null || s === void 0 ? void 0 : s._$AU) !== null && t !== void 0 ? t : this._$Cp;
388
- }
389
- get parentNode() {
390
- let s = this._$AA.parentNode;
391
- const t = this._$AM;
392
- return t !== void 0 && (s == null ? void 0 : s.nodeType) === 11 && (s = t.parentNode), s;
393
- }
394
- get startNode() {
395
- return this._$AA;
396
- }
397
- get endNode() {
398
- return this._$AB;
399
- }
400
- _$AI(s, t = this) {
401
- s = K(this, s, t), it(s) ? s === S || s == null || s === "" ? (this._$AH !== S && this._$AR(), this._$AH = S) : s !== this._$AH && s !== X && this._(s) : s._$litType$ !== void 0 ? this.g(s) : s.nodeType !== void 0 ? this.$(s) : is(s) ? this.T(s) : this._(s);
402
- }
403
- k(s) {
404
- return this._$AA.parentNode.insertBefore(s, this._$AB);
405
- }
406
- $(s) {
407
- this._$AH !== s && (this._$AR(), this._$AH = this.k(s));
408
- }
409
- _(s) {
410
- this._$AH !== S && it(this._$AH) ? this._$AA.nextSibling.data = s : this.$(z.createTextNode(s)), this._$AH = s;
411
- }
412
- g(s) {
413
- var t;
414
- const { values: e, _$litType$: i } = s, r = typeof i == "number" ? this._$AC(s) : (i.el === void 0 && (i.el = rt.createElement(be(i.h, i.h[0]), this.options)), i);
415
- if (((t = this._$AH) === null || t === void 0 ? void 0 : t._$AD) === r)
416
- this._$AH.v(e);
417
- else {
418
- const o = new as(r, this), l = o.u(this.options);
419
- o.v(e), this.$(l), this._$AH = o;
420
- }
421
- }
422
- _$AC(s) {
423
- let t = ce.get(s.strings);
424
- return t === void 0 && ce.set(s.strings, t = new rt(s)), t;
425
- }
426
- T(s) {
427
- _e(this._$AH) || (this._$AH = [], this._$AR());
428
- const t = this._$AH;
429
- let e, i = 0;
430
- for (const r of s)
431
- i === t.length ? t.push(e = new at(this.k(nt()), this.k(nt()), this, this.options)) : e = t[i], e._$AI(r), i++;
432
- i < t.length && (this._$AR(e && e._$AB.nextSibling, i), t.length = i);
433
- }
434
- _$AR(s = this._$AA.nextSibling, t) {
435
- var e;
436
- for ((e = this._$AP) === null || e === void 0 || e.call(this, !1, !0, t); s && s !== this._$AB; ) {
437
- const i = s.nextSibling;
438
- s.remove(), s = i;
439
- }
440
- }
441
- setConnected(s) {
442
- var t;
443
- this._$AM === void 0 && (this._$Cp = s, (t = this._$AP) === null || t === void 0 || t.call(this, s));
444
- }
445
- }
446
- class mt {
447
- constructor(s, t, e, i, r) {
448
- this.type = 1, this._$AH = S, this._$AN = void 0, this.element = s, this.name = t, this._$AM = i, this.options = r, e.length > 2 || e[0] !== "" || e[1] !== "" ? (this._$AH = Array(e.length - 1).fill(new String()), this.strings = e) : this._$AH = S;
449
- }
450
- get tagName() {
451
- return this.element.tagName;
452
- }
453
- get _$AU() {
454
- return this._$AM._$AU;
455
- }
456
- _$AI(s, t = this, e, i) {
457
- const r = this.strings;
458
- let o = !1;
459
- if (r === void 0)
460
- s = K(this, s, t, 0), o = !it(s) || s !== this._$AH && s !== X, o && (this._$AH = s);
461
- else {
462
- const l = s;
463
- let u, d;
464
- for (s = r[0], u = 0; u < r.length - 1; u++)
465
- d = K(this, l[e + u], t, u), d === X && (d = this._$AH[u]), o || (o = !it(d) || d !== this._$AH[u]), d === S ? s = S : s !== S && (s += (d ?? "") + r[u + 1]), this._$AH[u] = d;
466
- }
467
- o && !i && this.j(s);
468
- }
469
- j(s) {
470
- s === S ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, s ?? "");
471
- }
472
- }
473
- class hs extends mt {
474
- constructor() {
475
- super(...arguments), this.type = 3;
476
- }
477
- j(s) {
478
- this.element[this.name] = s === S ? void 0 : s;
479
- }
480
- }
481
- const ls = q ? q.emptyScript : "";
482
- class cs extends mt {
483
- constructor() {
484
- super(...arguments), this.type = 4;
485
- }
486
- j(s) {
487
- s && s !== S ? this.element.setAttribute(this.name, ls) : this.element.removeAttribute(this.name);
488
- }
489
- }
490
- class us extends mt {
491
- constructor(s, t, e, i, r) {
492
- super(s, t, e, i, r), this.type = 5;
493
- }
494
- _$AI(s, t = this) {
495
- var e;
496
- if ((s = (e = K(this, s, t, 0)) !== null && e !== void 0 ? e : S) === X)
497
- return;
498
- const i = this._$AH, r = s === S && i !== S || s.capture !== i.capture || s.once !== i.once || s.passive !== i.passive, o = s !== S && (i === S || r);
499
- r && this.element.removeEventListener(this.name, this, i), o && this.element.addEventListener(this.name, this, s), this._$AH = s;
500
- }
501
- handleEvent(s) {
502
- var t, e;
503
- typeof this._$AH == "function" ? this._$AH.call((e = (t = this.options) === null || t === void 0 ? void 0 : t.host) !== null && e !== void 0 ? e : this.element, s) : this._$AH.handleEvent(s);
504
- }
505
- }
506
- class ps {
507
- constructor(s, t, e) {
508
- this.element = s, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = e;
509
- }
510
- get _$AU() {
511
- return this._$AM._$AU;
512
- }
513
- _$AI(s) {
514
- K(this, s);
515
- }
516
- }
517
- const ue = vt.litHtmlPolyfillSupport;
518
- ue == null || ue(rt, at), ((Tt = vt.litHtmlVersions) !== null && Tt !== void 0 ? Tt : vt.litHtmlVersions = []).push("2.7.5");
519
- const ds = (n, s, t) => {
520
- var e, i;
521
- const r = (e = t == null ? void 0 : t.renderBefore) !== null && e !== void 0 ? e : s;
522
- let o = r._$litPart$;
523
- if (o === void 0) {
524
- const l = (i = t == null ? void 0 : t.renderBefore) !== null && i !== void 0 ? i : null;
525
- r._$litPart$ = o = new at(s.insertBefore(nt(), l), l, void 0, t ?? {});
526
- }
527
- return o._$AI(n), o;
528
- };
529
- /**
530
- * @license
531
- * Copyright 2017 Google LLC
532
- * SPDX-License-Identifier: BSD-3-Clause
533
- */
534
- var xt, St;
535
- class tt extends F {
536
- constructor() {
537
- super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
538
- }
539
- createRenderRoot() {
540
- var s, t;
541
- const e = super.createRenderRoot();
542
- return (s = (t = this.renderOptions).renderBefore) !== null && s !== void 0 || (t.renderBefore = e.firstChild), e;
543
- }
544
- update(s) {
545
- const t = this.render();
546
- this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(s), this._$Do = ds(t, this.renderRoot, this.renderOptions);
547
- }
548
- connectedCallback() {
549
- var s;
550
- super.connectedCallback(), (s = this._$Do) === null || s === void 0 || s.setConnected(!0);
551
- }
552
- disconnectedCallback() {
553
- var s;
554
- super.disconnectedCallback(), (s = this._$Do) === null || s === void 0 || s.setConnected(!1);
555
- }
556
- render() {
557
- return X;
558
- }
559
- }
560
- tt.finalized = !0, tt._$litElement$ = !0, (xt = globalThis.litElementHydrateSupport) === null || xt === void 0 || xt.call(globalThis, { LitElement: tt });
561
- const pe = globalThis.litElementPolyfillSupport;
562
- pe == null || pe({ LitElement: tt });
563
- ((St = globalThis.litElementVersions) !== null && St !== void 0 ? St : globalThis.litElementVersions = []).push("3.3.2");
564
- /**
565
- * @license
566
- * Copyright 2017 Google LLC
567
- * SPDX-License-Identifier: BSD-3-Clause
568
- */
569
- const fs = (n) => (s) => typeof s == "function" ? ((t, e) => (customElements.define(t, e), e))(n, s) : ((t, e) => {
570
- const { kind: i, elements: r } = e;
571
- return { kind: i, elements: r, finisher(o) {
572
- customElements.define(t, o);
573
- } };
574
- })(n, s);
575
- /**
576
- * @license
577
- * Copyright 2017 Google LLC
578
- * SPDX-License-Identifier: BSD-3-Clause
579
- */
580
- const vs = (n, s) => s.kind === "method" && s.descriptor && !("value" in s.descriptor) ? { ...s, finisher(t) {
581
- t.createProperty(s.key, n);
582
- } } : { kind: "field", key: Symbol(), placement: "own", descriptor: {}, originalKey: s.key, initializer() {
583
- typeof s.initializer == "function" && (this[s.key] = s.initializer.call(this));
584
- }, finisher(t) {
585
- t.createProperty(s.key, n);
586
- } }, gs = (n, s, t) => {
587
- s.constructor.createProperty(t, n);
588
- };
589
- function It(n) {
590
- return (s, t) => t !== void 0 ? gs(n, s, t) : vs(n, s);
591
- }
592
- /**
593
- * @license
594
- * Copyright 2017 Google LLC
595
- * SPDX-License-Identifier: BSD-3-Clause
596
- */
597
- function Ae(n) {
598
- return It({ ...n, state: !0 });
599
- }
600
- /**
601
- * @license
602
- * Copyright 2021 Google LLC
603
- * SPDX-License-Identifier: BSD-3-Clause
604
- */
605
- var Ot;
606
- ((Ot = window.HTMLSlotElement) === null || Ot === void 0 ? void 0 : Ot.prototype.assignedElements) != null;
607
- const { isArray: ys } = Array, ms = Object.keys, ot = (n) => {
608
- if (!n)
609
- return n;
610
- if (ys(n)) {
611
- const s = [], t = n.length;
612
- for (let e = 0; e < t; e++)
613
- s.push(ot(n[e]));
614
- return s;
615
- } else if (typeof n == "object") {
616
- const s = ms(n), t = s.length, e = {};
617
- for (let i = 0; i < t; i++) {
618
- const r = s[i];
619
- e[r] = ot(n[r]);
620
- }
621
- return e;
622
- }
623
- return n;
624
- };
625
- class N {
626
- constructor(s) {
627
- g(this, "path");
628
- g(this, "from");
629
- this.path = s;
630
- }
631
- }
632
- const _s = /~1/g, ws = /~0/g, bs = /~/g, As = /\//g;
633
- function Es(n) {
634
- return n.indexOf("~") === -1 ? n : n.replace(_s, "/").replace(ws, "~");
635
- }
636
- function $s(n) {
637
- return n.indexOf("/") === -1 && n.indexOf("~") === -1 ? n : n.replace(bs, "~0").replace(As, "~1");
638
- }
639
- function Cs(n) {
640
- return n ? n.slice(1).split("/").map(Es) : [];
641
- }
642
- function $(n) {
643
- return Ts(n) ? "" : "/" + n.map((s) => $s(String(s))).join("/");
644
- }
645
- const b = (n) => typeof n == "string" ? Cs(n) : n, Ts = (n) => !n.length, ks = Object.prototype.hasOwnProperty;
646
- function xs(n, s) {
647
- return ks.call(n, s);
648
- }
649
- const { isArray: Ee } = Array, C = (n, s) => {
650
- const t = s.length;
651
- if (!t)
652
- return { val: n };
653
- let e, i;
654
- for (let o = 0; o < t; o++)
655
- if (e = n, i = s[o], Ee(e)) {
656
- const l = e.length;
657
- if (i === "-")
658
- i = l;
659
- else if (typeof i == "string") {
660
- const u = ~~i;
661
- if ("" + u !== i)
662
- throw new Error("INVALID_INDEX");
663
- if (i = u, i < 0)
664
- throw new Error("INVALID_INDEX");
665
- }
666
- n = e[i];
667
- } else if (typeof e == "object" && e)
668
- n = xs(e, i) ? e[i] : void 0;
669
- else
670
- throw new Error("NOT_FOUND");
671
- return { val: n, obj: e, key: i };
672
- }, ht = (n) => Ee(n.obj) && typeof n.key == "number", _t = (n) => typeof n.obj == "object" && typeof n.key == "string";
673
- class Vt extends N {
674
- constructor(t, e) {
675
- super(t);
676
- g(this, "value");
677
- this.value = e;
678
- }
679
- op() {
680
- return "add";
681
- }
682
- code() {
683
- return 0;
684
- }
685
- apply(t) {
686
- const { val: e, key: i, obj: r } = C(t, this.path), o = ot(this.value);
687
- if (!r)
688
- t = o;
689
- else if (typeof i == "string")
690
- r[i] = o;
691
- else {
692
- const l = r.length;
693
- if (i < l)
694
- r.splice(i, 0, o);
695
- else {
696
- if (i > l)
697
- throw new Error("INVALID_INDEX");
698
- r.push(o);
699
- }
700
- }
701
- return { doc: t, old: e };
702
- }
703
- toJson(t) {
704
- return {
705
- op: "add",
706
- path: $(this.path),
707
- value: this.value
708
- };
709
- }
710
- toCompact(t, e) {
711
- return [e ? "add" : 0, this.path, this.value];
712
- }
713
- encode(t) {
714
- t.encodeArrayHeader(3), t.writer.u8(0), t.encodeArray(this.path), t.encodeAny(this.value);
715
- }
716
- }
717
- class $e extends N {
718
- constructor(t, e) {
719
- super(t);
720
- g(this, "oldValue");
721
- this.oldValue = e;
722
- }
723
- op() {
724
- return "remove";
725
- }
726
- code() {
727
- return 1;
728
- }
729
- apply(t) {
730
- const e = C(t, this.path);
731
- if (e.val === void 0)
732
- throw new Error("NOT_FOUND");
733
- return _t(e) ? delete e.obj[e.key] : ht(e) ? e.val !== void 0 && e.obj.splice(e.key, 1) : t = null, { doc: t, old: e.val };
734
- }
735
- toJson(t) {
736
- const e = {
737
- op: "remove",
738
- path: $(this.path)
739
- };
740
- return this.oldValue !== void 0 && (e.oldValue = this.oldValue), e;
741
- }
742
- toCompact(t, e) {
743
- const i = e ? "remove" : 1;
744
- return this.oldValue === void 0 ? [i, this.path] : [i, this.path, this.oldValue];
745
- }
746
- encode(t, e) {
747
- const i = this.oldValue !== void 0;
748
- t.encodeArrayHeader(i ? 3 : 2), t.writer.u8(1), t.encodeArray(this.path), i && t.encodeAny(this.oldValue);
749
- }
750
- }
751
- class Ss extends N {
752
- constructor(t, e, i) {
753
- super(t);
754
- g(this, "value");
755
- g(this, "oldValue");
756
- this.value = e, this.oldValue = i;
757
- }
758
- op() {
759
- return "replace";
760
- }
761
- code() {
762
- return 2;
763
- }
764
- apply(t) {
765
- const e = C(t, this.path);
766
- if (e.val === void 0)
767
- throw new Error("NOT_FOUND");
768
- return _t(e) ? e.obj[e.key] = this.value : ht(e) ? e.obj[e.key] = this.value : t = this.value, { doc: t, old: e.val };
769
- }
770
- toJson(t) {
771
- const e = {
772
- op: "replace",
773
- path: $(this.path),
774
- value: this.value
775
- };
776
- return this.oldValue !== void 0 && (e.oldValue = this.oldValue), e;
777
- }
778
- toCompact(t, e) {
779
- const i = e ? "replace" : 2;
780
- return this.oldValue === void 0 ? [i, this.path, this.value] : [i, this.path, this.value, this.oldValue];
781
- }
782
- encode(t, e) {
783
- const i = this.oldValue !== void 0;
784
- t.encodeArrayHeader(i ? 4 : 3), t.writer.u8(2), t.encodeArray(this.path), t.encodeAny(this.value), i && t.encodeAny(this.oldValue);
785
- }
786
- }
787
- class Os extends N {
788
- constructor(t, e) {
789
- super(t);
790
- g(this, "from");
791
- this.from = e;
792
- }
793
- op() {
794
- return "move";
795
- }
796
- code() {
797
- return 4;
798
- }
799
- apply(t) {
800
- const e = new $e(b(this.from), void 0).apply(t);
801
- return new Vt(this.path, e.old).apply(e.doc);
802
- }
803
- toJson(t) {
804
- return {
805
- op: "move",
806
- path: $(this.path),
807
- from: $(this.from)
808
- };
809
- }
810
- toCompact(t, e) {
811
- return [e ? "move" : 4, this.path, this.from];
812
- }
813
- encode(t, e) {
814
- t.encodeArrayHeader(3), t.writer.u8(4), t.encodeArray(this.path), t.encodeArray(this.from);
815
- }
816
- }
817
- class js extends N {
818
- constructor(t, e) {
819
- super(t);
820
- g(this, "from");
821
- this.from = e;
822
- }
823
- op() {
824
- return "copy";
825
- }
826
- code() {
827
- return 3;
828
- }
829
- apply(t) {
830
- const { val: e } = C(t, this.from);
831
- if (e === void 0)
832
- throw new Error("NOT_FOUND");
833
- return new Vt(this.path, ot(e)).apply(t);
834
- }
835
- toJson(t) {
836
- return {
837
- op: "copy",
838
- path: $(this.path),
839
- from: $(this.from)
840
- };
841
- }
842
- toCompact(t, e) {
843
- return [e ? "copy" : 3, this.path, this.from];
844
- }
845
- encode(t, e) {
846
- t.encodeArrayHeader(3), t.writer.u8(3), t.encodeArray(this.path), t.encodeArray(this.from);
847
- }
848
- }
849
- class M extends N {
850
- apply(s) {
851
- if (!this.test(s))
852
- throw new Error("TEST");
853
- return { doc: s };
854
- }
855
- }
856
- const gt = (n, s) => {
857
- if (n === s)
858
- return !0;
859
- if (n && s && typeof n == "object" && typeof s == "object") {
860
- if (n.constructor !== s.constructor)
861
- return !1;
862
- let t, e, i;
863
- if (Array.isArray(n)) {
864
- if (t = n.length, t !== s.length)
865
- return !1;
866
- for (e = t; e-- !== 0; )
867
- if (!gt(n[e], s[e]))
868
- return !1;
869
- return !0;
870
- }
871
- if (i = Object.keys(n), t = i.length, t !== Object.keys(s).length)
872
- return !1;
873
- for (e = t; e-- !== 0; ) {
874
- const r = i[e];
875
- if (!gt(n[r], s[r]))
876
- return !1;
877
- }
878
- return !0;
879
- }
880
- return !1;
881
- };
882
- class Ms extends M {
883
- constructor(t, e, i) {
884
- super(t);
885
- g(this, "value");
886
- g(this, "not");
887
- this.value = e, this.not = i;
888
- }
889
- op() {
890
- return "test";
891
- }
892
- code() {
893
- return 5;
894
- }
895
- test(t) {
896
- const { val: e } = C(t, this.path);
897
- if (e === void 0)
898
- return !!this.not;
899
- const i = gt(e, this.value);
900
- return this.not ? !i : i;
901
- }
902
- toJson(t) {
903
- const e = {
904
- op: "test",
905
- path: $(t ? this.path.slice(t.path.length) : this.path),
906
- value: this.value
907
- };
908
- return this.not && (e.not = this.not), e;
909
- }
910
- toCompact(t, e) {
911
- const i = t ? this.path.slice(t.path.length) : this.path, r = e ? "test" : 5;
912
- return this.not ? [r, i, this.value, 1] : [r, i, this.value];
913
- }
914
- encode(t, e) {
915
- t.encodeArrayHeader(this.not ? 4 : 3), t.writer.u8(5), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeAny(this.value), this.not && t.writer.u8(1);
916
- }
917
- }
918
- class Rs extends N {
919
- constructor(s) {
920
- super(s);
921
- }
922
- op() {
923
- return "flip";
924
- }
925
- code() {
926
- return 8;
927
- }
928
- apply(s) {
929
- const t = C(s, this.path);
930
- return t.obj ? t.obj[t.key] = !t.val : s = !t.val, { doc: s, old: t.val };
931
- }
932
- toJson(s) {
933
- return {
934
- op: "flip",
935
- path: $(this.path)
936
- };
937
- }
938
- toCompact(s, t) {
939
- return [t ? "flip" : 8, this.path];
940
- }
941
- encode(s, t) {
942
- s.encodeArrayHeader(2), s.writer.u8(8), s.encodeArray(this.path);
943
- }
944
- }
945
- class Ns extends N {
946
- constructor(t, e) {
947
- super(t);
948
- g(this, "inc");
949
- this.inc = e;
950
- }
951
- op() {
952
- return "inc";
953
- }
954
- code() {
955
- return 9;
956
- }
957
- apply(t) {
958
- const e = C(t, this.path), i = this.inc + Number(e.val);
959
- return e.obj ? e.obj[e.key] = i : t = i, { doc: t, old: e.val };
960
- }
961
- toJson(t) {
962
- return {
963
- op: "inc",
964
- path: $(this.path),
965
- inc: this.inc
966
- };
967
- }
968
- toCompact(t, e) {
969
- return [e ? "inc" : 9, this.path, this.inc];
970
- }
971
- encode(t, e) {
972
- t.encodeArrayHeader(3), t.writer.u8(9), t.encodeArray(this.path), t.encodeNumber(this.inc);
973
- }
974
- }
975
- class Ps extends N {
976
- constructor(t, e, i) {
977
- super(t);
978
- g(this, "pos");
979
- g(this, "str");
980
- this.pos = e, this.str = i;
981
- }
982
- op() {
983
- return "str_ins";
984
- }
985
- code() {
986
- return 6;
987
- }
988
- apply(t) {
989
- const { val: e, key: i, obj: r } = C(t, this.path);
990
- if (typeof e != "string") {
991
- if (e !== void 0)
992
- throw new Error("NOT_A_STRING");
993
- if (this.pos !== 0)
994
- throw new Error("POS");
995
- }
996
- const o = typeof e == "string" ? e : "", l = Math.min(this.pos, o.length), u = o.slice(0, l), d = o.slice(l), _ = u + this.str + d;
997
- return r ? r[i] = _ : t = _, { doc: t, old: e };
998
- }
999
- toJson(t) {
1000
- return {
1001
- op: "str_ins",
1002
- path: $(this.path),
1003
- pos: this.pos,
1004
- str: this.str
1005
- };
1006
- }
1007
- toCompact(t, e) {
1008
- return [e ? "str_ins" : 6, this.path, this.pos, this.str];
1009
- }
1010
- encode(t, e) {
1011
- t.encodeArrayHeader(4), t.writer.u8(6), t.encodeArray(this.path), t.encodeNumber(this.pos), t.encodeString(this.str);
1012
- }
1013
- }
1014
- class Hs extends N {
1015
- constructor(t, e, i, r) {
1016
- super(t);
1017
- g(this, "pos");
1018
- g(this, "str");
1019
- g(this, "len");
1020
- this.pos = e, this.str = i, this.len = r;
1021
- }
1022
- op() {
1023
- return "str_del";
1024
- }
1025
- code() {
1026
- return 7;
1027
- }
1028
- deleteLength() {
1029
- return typeof this.str == "string" ? this.str.length : this.len;
1030
- }
1031
- apply(t) {
1032
- const { val: e, key: i, obj: r } = C(t, this.path);
1033
- if (typeof e != "string")
1034
- throw new Error("NOT_A_STRING");
1035
- const o = e.length, l = Math.min(this.pos, e.length), u = Math.min(l, o), d = this.str !== void 0 ? this.str.length : this.len, _ = Math.min(l + d, o), w = e.slice(0, u), T = e.substr(_), O = w + T;
1036
- return r ? r[i] = O : t = O, { doc: t, old: e };
1037
- }
1038
- toJson(t) {
1039
- return typeof this.str == "string" ? {
1040
- op: "str_del",
1041
- path: $(this.path),
1042
- pos: this.pos,
1043
- str: this.str
1044
- } : {
1045
- op: "str_del",
1046
- path: $(this.path),
1047
- pos: this.pos,
1048
- len: this.len
1049
- };
1050
- }
1051
- toCompact(t, e) {
1052
- const i = e ? "str_del" : 7;
1053
- return typeof this.str == "string" ? [i, this.path, this.pos, this.str] : [i, this.path, this.pos, 0, this.len];
1054
- }
1055
- encode(t, e) {
1056
- const i = typeof this.str == "string";
1057
- t.encodeArrayHeader(i ? 4 : 5), t.writer.u8(7), t.encodeArray(this.path), t.encodeNumber(this.pos), i ? t.encodeString(this.str) : (t.writer.u8(0), t.encodeNumber(this.len));
1058
- }
1059
- }
1060
- const { isArray: Ls } = Array, Pt = (n) => !!n && typeof n == "object" && typeof n.text == "string", Ht = (n) => !!n && typeof n == "object" && Ls(n.children), Us = (n, s) => {
1061
- const t = new RegExp(n, s ? "i" : void 0);
1062
- return (e) => t.test(e);
1063
- };
1064
- class Ds extends N {
1065
- constructor(t, e, i) {
1066
- super(t);
1067
- g(this, "pos");
1068
- g(this, "props");
1069
- this.pos = e, this.props = i;
1070
- }
1071
- op() {
1072
- return "split";
1073
- }
1074
- code() {
1075
- return 10;
1076
- }
1077
- apply(t) {
1078
- const e = C(t, this.path);
1079
- if (e.val === void 0)
1080
- throw new Error("NOT_FOUND");
1081
- const i = this.split(e.val);
1082
- return _t(e) ? e.obj[e.key] = i : ht(e) ? (e.obj[e.key] = i[0], e.obj.splice(e.key + 1, 0, i[1])) : t = i, { doc: t, old: e.val };
1083
- }
1084
- split(t) {
1085
- if (typeof t == "string") {
1086
- const { pos: e, props: i } = this, r = t.slice(0, e), o = t.slice(e);
1087
- return i ? [
1088
- {
1089
- ...i,
1090
- text: r
1091
- },
1092
- {
1093
- ...i,
1094
- text: o
1095
- }
1096
- ] : [r, o];
1097
- } else if (Pt(t)) {
1098
- const { pos: e, props: i } = this, r = t.text.slice(0, e), o = t.text.slice(e);
1099
- return [
1100
- {
1101
- ...t,
1102
- ...i,
1103
- text: r
1104
- },
1105
- {
1106
- ...t,
1107
- ...i,
1108
- text: o
1109
- }
1110
- ];
1111
- } else if (Ht(t)) {
1112
- const { pos: e, props: i } = this, r = t.children.slice(0, e), o = t.children.slice(e);
1113
- return [
1114
- {
1115
- ...t,
1116
- ...i,
1117
- children: r
1118
- },
1119
- {
1120
- ...t,
1121
- ...i,
1122
- children: o
1123
- }
1124
- ];
1125
- } else if (typeof t == "number") {
1126
- const { pos: e } = this;
1127
- return [e, t - e];
1128
- } else
1129
- return [t, t];
1130
- }
1131
- toJson(t) {
1132
- const e = {
1133
- op: "split",
1134
- path: $(this.path),
1135
- pos: this.pos
1136
- };
1137
- return this.props && (e.props = this.props), e;
1138
- }
1139
- toCompact(t, e) {
1140
- const i = e ? "split" : 10;
1141
- return this.props ? [i, this.path, this.pos, this.props] : [i, this.path, this.pos];
1142
- }
1143
- encode(t, e) {
1144
- t.encodeArrayHeader(this.props ? 4 : 3), t.writer.u8(10), t.encodeArray(this.path), t.encodeNumber(this.pos), this.props && t.encodeObject(this.props);
1145
- }
1146
- }
1147
- class Is extends N {
1148
- constructor(t, e, i) {
1149
- super(t);
1150
- g(this, "pos");
1151
- g(this, "props");
1152
- this.pos = e, this.props = i;
1153
- }
1154
- op() {
1155
- return "merge";
1156
- }
1157
- code() {
1158
- return 11;
1159
- }
1160
- apply(t) {
1161
- const e = C(t, this.path);
1162
- if (!ht(e))
1163
- throw new Error("INVALID_TARGET");
1164
- if (e.key <= 0)
1165
- throw new Error("INVALID_KEY");
1166
- const i = e.obj[e.key - 1], r = e.obj[e.key], o = this.merge(i, r);
1167
- return e.obj[e.key - 1] = o, e.obj.splice(e.key, 1), { doc: t, old: [i, r] };
1168
- }
1169
- merge(t, e) {
1170
- return typeof t == "string" && typeof e == "string" || typeof t == "number" && typeof e == "number" ? t + e : Pt(t) && Pt(e) ? { ...t, ...e, text: t.text + e.text } : Ht(t) && Ht(e) ? { ...t, ...e, children: [...t.children, ...e.children] } : [t, e];
1171
- }
1172
- toJson(t) {
1173
- const e = {
1174
- op: "merge",
1175
- path: $(this.path),
1176
- pos: this.pos
1177
- };
1178
- return this.props && (e.props = this.props), e;
1179
- }
1180
- toCompact(t, e) {
1181
- const i = e ? "merge" : 11;
1182
- return this.props ? [i, this.path, this.pos, this.props] : [i, this.path, this.pos];
1183
- }
1184
- encode(t, e) {
1185
- t.encodeArrayHeader(this.props ? 4 : 3), t.writer.u8(11), t.encodeArray(this.path), t.encodeNumber(this.pos), this.props && t.encodeAny(this.props);
1186
- }
1187
- }
1188
- const { isArray: Vs } = Array;
1189
- class Js extends N {
1190
- constructor(t, e, i) {
1191
- super(t);
1192
- g(this, "props");
1193
- g(this, "deleteNull");
1194
- this.props = e, this.deleteNull = i;
1195
- }
1196
- op() {
1197
- return "extend";
1198
- }
1199
- code() {
1200
- return 12;
1201
- }
1202
- apply(t) {
1203
- const e = C(t, this.path);
1204
- return ht(e) ? e.val !== void 0 && (e.obj[e.key] = this.extend(e.val)) : _t(e) ? e.obj[e.key] = this.extend(e.val) : t = this.extend(t), { doc: t };
1205
- }
1206
- extend(t) {
1207
- if (Vs(t) || typeof t != "object" || !t)
1208
- return t;
1209
- for (const [e, i] of Object.entries(this.props)) {
1210
- if (e === "__proto__")
1211
- throw new Error("NO_PROTO");
1212
- if (i === null && this.deleteNull) {
1213
- delete t[e];
1214
- continue;
1215
- }
1216
- t[e] = i;
1217
- }
1218
- return t;
1219
- }
1220
- toJson(t) {
1221
- const e = {
1222
- op: "extend",
1223
- path: $(this.path),
1224
- props: this.props
1225
- };
1226
- return this.deleteNull && (e.deleteNull = this.deleteNull), e;
1227
- }
1228
- toCompact(t, e) {
1229
- const i = e ? "extend" : 12;
1230
- return this.deleteNull ? [i, this.path, this.props, 1] : [i, this.path, this.props];
1231
- }
1232
- encode(t, e) {
1233
- const { deleteNull: i } = this;
1234
- t.encodeArrayHeader(i ? 4 : 3), t.writer.u8(12), t.encodeArray(this.path), t.encodeObject(this.props), i && t.writer.u8(1);
1235
- }
1236
- }
1237
- class zs extends M {
1238
- constructor(s) {
1239
- super(s);
1240
- }
1241
- op() {
1242
- return "defined";
1243
- }
1244
- code() {
1245
- return 31;
1246
- }
1247
- test(s) {
1248
- const { val: t } = C(s, this.path);
1249
- return t !== void 0;
1250
- }
1251
- toJson(s) {
1252
- return {
1253
- op: "defined",
1254
- path: $(s ? this.path.slice(s.path.length) : this.path)
1255
- };
1256
- }
1257
- toCompact(s, t) {
1258
- return [t ? "defined" : 31, s ? this.path.slice(s.path.length) : this.path];
1259
- }
1260
- encode(s, t) {
1261
- s.encodeArrayHeader(2), s.writer.u8(31), s.encodeArray(t ? this.path.slice(t.path.length) : this.path);
1262
- }
1263
- }
1264
- class Bs extends M {
1265
- constructor(s) {
1266
- super(s);
1267
- }
1268
- op() {
1269
- return "undefined";
1270
- }
1271
- code() {
1272
- return 38;
1273
- }
1274
- test(s) {
1275
- try {
1276
- const { val: t } = C(s, this.path);
1277
- return t === void 0;
1278
- } catch (t) {
1279
- if (t.message === "NOT_FOUND")
1280
- return !0;
1281
- throw t;
1282
- }
1283
- }
1284
- toJson(s) {
1285
- return {
1286
- op: "undefined",
1287
- path: $(s ? this.path.slice(s.path.length) : this.path)
1288
- };
1289
- }
1290
- toCompact(s, t) {
1291
- return [t ? "undefined" : 38, s ? this.path.slice(s.path.length) : this.path];
1292
- }
1293
- encode(s, t) {
1294
- s.encodeArrayHeader(2), s.writer.u8(38), s.encodeArray(t ? this.path.slice(t.path.length) : this.path);
1295
- }
1296
- }
1297
- const { isArray: Ws } = Array;
1298
- class Gs extends M {
1299
- constructor(t, e) {
1300
- super(t);
1301
- g(this, "type");
1302
- this.type = e;
1303
- }
1304
- op() {
1305
- return "test_type";
1306
- }
1307
- code() {
1308
- return 39;
1309
- }
1310
- test(t) {
1311
- const { val: e } = C(t, this.path);
1312
- return e === null ? this.type.indexOf("null") > -1 : Ws(e) ? this.type.indexOf("array") > -1 : this.type.indexOf(typeof e) > -1 || typeof e == "number" && e === Math.round(e) && this.type.indexOf("integer") > -1;
1313
- }
1314
- toJson(t) {
1315
- return {
1316
- op: "test_type",
1317
- path: $(t ? this.path.slice(t.path.length) : this.path),
1318
- type: this.type
1319
- };
1320
- }
1321
- toCompact(t, e) {
1322
- return [e ? "test_type" : 39, t ? this.path.slice(t.path.length) : this.path, this.type];
1323
- }
1324
- encode(t, e) {
1325
- t.encodeArrayHeader(3), t.writer.u8(39), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeArray(this.type);
1326
- }
1327
- }
1328
- class Fs extends M {
1329
- constructor(t, e, i, r) {
1330
- super(t);
1331
- g(this, "pos");
1332
- g(this, "str");
1333
- g(this, "not");
1334
- this.pos = e, this.str = i, this.not = r;
1335
- }
1336
- op() {
1337
- return "test_string";
1338
- }
1339
- code() {
1340
- return 40;
1341
- }
1342
- test(t) {
1343
- const { val: e } = C(t, this.path);
1344
- if (typeof e != "string")
1345
- return !1;
1346
- const i = e.length, r = Math.min(this.pos, i), o = Math.min(this.pos + this.str.length, i), l = e.substring(r, o) === this.str;
1347
- return this.not ? !l : l;
1348
- }
1349
- toJson(t) {
1350
- const e = {
1351
- op: "test_string",
1352
- path: $(t ? this.path.slice(t.path.length) : this.path),
1353
- pos: this.pos,
1354
- str: this.str
1355
- };
1356
- return this.not && (e.not = this.not), e;
1357
- }
1358
- toCompact(t, e) {
1359
- const i = e ? "test_string" : 40, r = t ? this.path.slice(t.path.length) : this.path;
1360
- return this.not ? [i, r, this.pos, this.str, 1] : [i, r, this.pos, this.str];
1361
- }
1362
- encode(t, e) {
1363
- t.encodeArrayHeader(this.not ? 5 : 4), t.writer.u8(40), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeNumber(this.pos), t.encodeString(this.str), this.not && t.writer.u8(1);
1364
- }
1365
- }
1366
- class qs extends M {
1367
- constructor(t, e, i) {
1368
- super(t);
1369
- g(this, "len");
1370
- g(this, "not");
1371
- this.len = e, this.not = i;
1372
- }
1373
- op() {
1374
- return "test_string_len";
1375
- }
1376
- code() {
1377
- return 41;
1378
- }
1379
- test(t) {
1380
- const { val: e } = C(t, this.path);
1381
- if (typeof e != "string")
1382
- return !1;
1383
- const r = e.length >= this.len;
1384
- return this.not ? !r : r;
1385
- }
1386
- toJson(t) {
1387
- const e = {
1388
- op: "test_string_len",
1389
- path: $(t ? this.path.slice(t.path.length) : this.path),
1390
- len: this.len
1391
- };
1392
- return this.not && (e.not = this.not), e;
1393
- }
1394
- toCompact(t, e) {
1395
- const i = e ? "test_string_len" : 41, r = t ? this.path.slice(t.path.length) : this.path;
1396
- return this.not ? [i, r, this.len, 1] : [i, r, this.len];
1397
- }
1398
- encode(t, e) {
1399
- t.encodeArrayHeader(this.not ? 4 : 3), t.writer.u8(41), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeNumber(this.len), this.not && t.writer.u8(1);
1400
- }
1401
- }
1402
- class Xs extends M {
1403
- constructor(t, e, i) {
1404
- super(t);
1405
- g(this, "value");
1406
- g(this, "ignore_case");
1407
- this.value = e, this.ignore_case = i;
1408
- }
1409
- op() {
1410
- return "contains";
1411
- }
1412
- code() {
1413
- return 30;
1414
- }
1415
- test(t) {
1416
- const { val: e } = C(t, this.path);
1417
- if (typeof e != "string")
1418
- return !1;
1419
- const i = this.ignore_case ? e.toLowerCase() : e, r = this.ignore_case ? this.value.toLowerCase() : this.value;
1420
- return i.indexOf(r) > -1;
1421
- }
1422
- toJson(t) {
1423
- const e = {
1424
- op: "contains",
1425
- path: $(t ? this.path.slice(t.path.length) : this.path),
1426
- value: this.value
1427
- };
1428
- return this.ignore_case && (e.ignore_case = this.ignore_case), e;
1429
- }
1430
- toCompact(t, e) {
1431
- const i = e ? "contains" : 30;
1432
- return this.ignore_case ? [i, t ? this.path.slice(t.path.length) : this.path, this.value, 1] : [i, t ? this.path.slice(t.path.length) : this.path, this.value];
1433
- }
1434
- encode(t, e) {
1435
- const i = this.ignore_case;
1436
- t.encodeArrayHeader(i ? 4 : 3), t.writer.u8(30), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeString(this.value), i && t.writer.u8(1);
1437
- }
1438
- }
1439
- class Ks extends M {
1440
- constructor(t, e, i) {
1441
- super(t);
1442
- g(this, "value");
1443
- g(this, "ignore_case");
1444
- this.value = e, this.ignore_case = i;
1445
- }
1446
- op() {
1447
- return "ends";
1448
- }
1449
- code() {
1450
- return 32;
1451
- }
1452
- test(t) {
1453
- const { val: e } = C(t, this.path);
1454
- if (typeof e != "string")
1455
- return !1;
1456
- const i = this.ignore_case ? e.toLowerCase() : e, r = this.ignore_case ? this.value.toLowerCase() : this.value;
1457
- return i.endsWith(r);
1458
- }
1459
- toJson(t) {
1460
- const e = {
1461
- op: "ends",
1462
- path: $(t ? this.path.slice(t.path.length) : this.path),
1463
- value: this.value
1464
- };
1465
- return this.ignore_case && (e.ignore_case = this.ignore_case), e;
1466
- }
1467
- toCompact(t, e) {
1468
- const i = e ? "ends" : 32;
1469
- return this.ignore_case ? [i, t ? this.path.slice(t.path.length) : this.path, this.value, 1] : [i, t ? this.path.slice(t.path.length) : this.path, this.value];
1470
- }
1471
- encode(t, e) {
1472
- const i = this.ignore_case;
1473
- t.encodeArrayHeader(i ? 4 : 3), t.writer.u8(32), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeString(this.value), i && t.writer.u8(1);
1474
- }
1475
- }
1476
- class Zs extends M {
1477
- constructor(t, e, i) {
1478
- super(t);
1479
- g(this, "value");
1480
- g(this, "ignore_case");
1481
- this.value = e, this.ignore_case = i;
1482
- }
1483
- op() {
1484
- return "starts";
1485
- }
1486
- code() {
1487
- return 37;
1488
- }
1489
- test(t) {
1490
- const { val: e } = C(t, this.path);
1491
- if (typeof e != "string")
1492
- return !1;
1493
- const i = this.ignore_case ? e.toLowerCase() : e, r = this.ignore_case ? this.value.toLowerCase() : this.value;
1494
- return i.startsWith(r);
1495
- }
1496
- toJson(t) {
1497
- const e = {
1498
- op: "starts",
1499
- path: $(t ? this.path.slice(t.path.length) : this.path),
1500
- value: this.value
1501
- };
1502
- return this.ignore_case && (e.ignore_case = this.ignore_case), e;
1503
- }
1504
- toCompact(t, e) {
1505
- const i = e ? "starts" : 37;
1506
- return this.ignore_case ? [i, t ? this.path.slice(t.path.length) : this.path, this.value, 1] : [i, t ? this.path.slice(t.path.length) : this.path, this.value];
1507
- }
1508
- encode(t, e) {
1509
- const i = this.ignore_case;
1510
- t.encodeArrayHeader(i ? 4 : 3), t.writer.u8(37), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeString(this.value), i && t.writer.u8(1);
1511
- }
1512
- }
1513
- class Ys extends M {
1514
- constructor(t, e) {
1515
- super(t);
1516
- g(this, "value");
1517
- this.value = e;
1518
- }
1519
- op() {
1520
- return "in";
1521
- }
1522
- code() {
1523
- return 33;
1524
- }
1525
- test(t) {
1526
- const { val: e } = C(t, this.path);
1527
- for (const i of this.value)
1528
- if (gt(e, i))
1529
- return !0;
1530
- return !1;
1531
- }
1532
- toJson(t) {
1533
- return {
1534
- op: "in",
1535
- path: $(t ? this.path.slice(t.path.length) : this.path),
1536
- value: this.value
1537
- };
1538
- }
1539
- toCompact(t, e) {
1540
- return [e ? "in" : 33, t ? this.path.slice(t.path.length) : this.path, this.value];
1541
- }
1542
- encode(t, e) {
1543
- t.encodeArrayHeader(3), t.writer.u8(33), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeArray(this.value);
1544
- }
1545
- }
1546
- class Qs extends M {
1547
- constructor(t, e) {
1548
- super(t);
1549
- g(this, "value");
1550
- this.value = e;
1551
- }
1552
- op() {
1553
- return "less";
1554
- }
1555
- code() {
1556
- return 34;
1557
- }
1558
- test(t) {
1559
- const { val: e } = C(t, this.path);
1560
- return typeof e != "number" ? !1 : e < this.value;
1561
- }
1562
- toJson(t) {
1563
- return {
1564
- op: "less",
1565
- path: $(t ? this.path.slice(t.path.length) : this.path),
1566
- value: this.value
1567
- };
1568
- }
1569
- toCompact(t, e) {
1570
- return [e ? "less" : 34, t ? this.path.slice(t.path.length) : this.path, this.value];
1571
- }
1572
- encode(t, e) {
1573
- t.encodeArrayHeader(3), t.writer.u8(34), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeNumber(this.value);
1574
- }
1575
- }
1576
- class tn extends M {
1577
- constructor(t, e) {
1578
- super(t);
1579
- g(this, "value");
1580
- this.value = e;
1581
- }
1582
- op() {
1583
- return "more";
1584
- }
1585
- code() {
1586
- return 36;
1587
- }
1588
- test(t) {
1589
- const { val: e } = C(t, this.path);
1590
- return typeof e != "number" ? !1 : e > this.value;
1591
- }
1592
- toJson(t) {
1593
- return {
1594
- op: "more",
1595
- path: $(t ? this.path.slice(t.path.length) : this.path),
1596
- value: this.value
1597
- };
1598
- }
1599
- toCompact(t, e) {
1600
- return [e ? "more" : 36, t ? this.path.slice(t.path.length) : this.path, this.value];
1601
- }
1602
- encode(t, e) {
1603
- t.encodeArrayHeader(3), t.writer.u8(36), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeNumber(this.value);
1604
- }
1605
- }
1606
- class Jt extends M {
1607
- constructor(t, e) {
1608
- super(t);
1609
- g(this, "ops");
1610
- this.ops = e;
1611
- }
1612
- }
1613
- class en extends Jt {
1614
- constructor(t, e) {
1615
- super(t, e);
1616
- g(this, "ops");
1617
- this.ops = e;
1618
- }
1619
- op() {
1620
- return "and";
1621
- }
1622
- code() {
1623
- return 43;
1624
- }
1625
- test(t) {
1626
- for (const e of this.ops)
1627
- if (!e.test(t))
1628
- return !1;
1629
- return !0;
1630
- }
1631
- toJson(t) {
1632
- return {
1633
- op: "and",
1634
- path: $(t ? this.path.slice(t.path.length) : this.path),
1635
- apply: this.ops.map((i) => i.toJson(this))
1636
- };
1637
- }
1638
- toCompact(t, e) {
1639
- return [
1640
- e ? "and" : 43,
1641
- t ? this.path.slice(t.path.length) : this.path,
1642
- this.ops.map((r) => r.toCompact(this, e))
1643
- ];
1644
- }
1645
- encode(t, e) {
1646
- const i = e ? this.path.slice(e.path.length) : this.path;
1647
- t.encodeArrayHeader(3), t.writer.u8(43), t.encodeArray(i);
1648
- const r = this.ops.length;
1649
- t.encodeArrayHeader(r);
1650
- for (let o = 0; o < r; o++)
1651
- this.ops[o].encode(t, this);
1652
- }
1653
- }
1654
- class sn extends Jt {
1655
- constructor(t, e) {
1656
- super(t, e);
1657
- g(this, "ops");
1658
- this.ops = e;
1659
- }
1660
- op() {
1661
- return "or";
1662
- }
1663
- code() {
1664
- return 45;
1665
- }
1666
- test(t) {
1667
- for (const e of this.ops)
1668
- if (e.test(t))
1669
- return !0;
1670
- return !1;
1671
- }
1672
- toJson(t) {
1673
- return {
1674
- op: "or",
1675
- path: $(t ? this.path.slice(t.path.length) : this.path),
1676
- apply: this.ops.map((i) => i.toJson(this))
1677
- };
1678
- }
1679
- toCompact(t, e) {
1680
- return [
1681
- e ? "or" : 45,
1682
- t ? this.path.slice(t.path.length) : this.path,
1683
- this.ops.map((r) => r.toCompact(this, e))
1684
- ];
1685
- }
1686
- encode(t, e) {
1687
- t.encodeArrayHeader(3), t.writer.u8(45), t.encodeArray(e ? this.path.slice(e.path.length) : this.path);
1688
- const i = this.ops.length;
1689
- t.encodeArrayHeader(i);
1690
- for (let r = 0; r < i; r++)
1691
- this.ops[r].encode(t, this);
1692
- }
1693
- }
1694
- class nn extends Jt {
1695
- constructor(t, e) {
1696
- super(t, e);
1697
- g(this, "ops");
1698
- this.ops = e;
1699
- }
1700
- op() {
1701
- return "not";
1702
- }
1703
- code() {
1704
- return 44;
1705
- }
1706
- test(t) {
1707
- for (const e of this.ops)
1708
- if (e.test(t))
1709
- return !1;
1710
- return !0;
1711
- }
1712
- toJson(t) {
1713
- return {
1714
- op: "not",
1715
- path: $(t ? this.path.slice(t.path.length) : this.path),
1716
- apply: this.ops.map((i) => i.toJson(this))
1717
- };
1718
- }
1719
- toCompact(t, e) {
1720
- return [
1721
- e ? "not" : 44,
1722
- t ? this.path.slice(t.path.length) : this.path,
1723
- this.ops.map((r) => r.toCompact(this, e))
1724
- ];
1725
- }
1726
- encode(t, e) {
1727
- t.encodeArrayHeader(3), t.writer.u8(44), t.encodeArray(e ? this.path.slice(e.path.length) : this.path);
1728
- const i = this.ops.length;
1729
- t.encodeArrayHeader(i);
1730
- for (let r = 0; r < i; r++)
1731
- this.ops[r].encode(t, this);
1732
- }
1733
- }
1734
- class rn extends M {
1735
- constructor(t, e, i, r) {
1736
- super(t);
1737
- g(this, "value");
1738
- g(this, "ignore_case");
1739
- g(this, "matcher");
1740
- this.value = e, this.ignore_case = i, this.matcher = r(e, i);
1741
- }
1742
- op() {
1743
- return "matches";
1744
- }
1745
- code() {
1746
- return 35;
1747
- }
1748
- test(t) {
1749
- const { val: e } = C(t, this.path);
1750
- return typeof e != "string" ? !1 : this.matcher(e);
1751
- }
1752
- toJson(t) {
1753
- const e = {
1754
- op: "matches",
1755
- path: $(t ? this.path.slice(t.path.length) : this.path),
1756
- value: this.value
1757
- };
1758
- return this.ignore_case && (e.ignore_case = this.ignore_case), e;
1759
- }
1760
- toCompact(t, e) {
1761
- const i = e ? "matches" : 35;
1762
- return this.ignore_case ? [i, t ? this.path.slice(t.path.length) : this.path, this.value, 1] : [i, t ? this.path.slice(t.path.length) : this.path, this.value];
1763
- }
1764
- encode(t, e) {
1765
- const i = this.ignore_case;
1766
- t.encodeArrayHeader(i ? 4 : 3), t.writer.u8(35), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeString(this.value), i && t.writer.u8(1);
1767
- }
1768
- }
1769
- const { isArray: on } = Array;
1770
- class an extends M {
1771
- constructor(t, e) {
1772
- super(t);
1773
- g(this, "value");
1774
- this.value = e;
1775
- }
1776
- op() {
1777
- return "type";
1778
- }
1779
- code() {
1780
- return 42;
1781
- }
1782
- test(t) {
1783
- const { val: e } = C(t, this.path);
1784
- return e === null ? this.value === "null" : on(e) ? this.value === "array" : typeof e === this.value || typeof e == "number" && e === Math.round(e) && this.value === "integer";
1785
- }
1786
- toJson(t) {
1787
- return {
1788
- op: "type",
1789
- path: $(t ? this.path.slice(t.path.length) : this.path),
1790
- value: this.value
1791
- };
1792
- }
1793
- toCompact(t, e) {
1794
- return [e ? "type" : 42, t ? this.path.slice(t.path.length) : this.path, this.value];
1795
- }
1796
- encode(t, e) {
1797
- t.encodeArrayHeader(3), t.writer.u8(42), t.encodeArray(e ? this.path.slice(e.path.length) : this.path), t.encodeString(this.value);
1798
- }
1799
- }
1800
- const hn = (n, s) => {
1801
- switch (n.op) {
1802
- case "add":
1803
- return new Vt(b(n.path), n.value);
1804
- case "remove":
1805
- return new $e(b(n.path), n.oldValue);
1806
- case "replace":
1807
- return new Ss(b(n.path), n.value, n.oldValue);
1808
- case "move":
1809
- return new Os(b(n.path), b(n.from));
1810
- case "copy":
1811
- return new js(b(n.path), b(n.from));
1812
- case "flip":
1813
- return new Rs(b(n.path));
1814
- case "inc":
1815
- return new Ns(b(n.path), n.inc);
1816
- case "str_ins":
1817
- return new Ps(b(n.path), n.pos, n.str);
1818
- case "str_del":
1819
- return new Hs(b(n.path), n.pos, n.str, n.len);
1820
- case "split":
1821
- return new Ds(b(n.path), n.pos, n.props || null);
1822
- case "merge":
1823
- return new Is(b(n.path), n.pos, n.props || null);
1824
- case "extend":
1825
- return new Js(b(n.path), n.props, !!n.deleteNull);
1826
- default:
1827
- return dt(n, s);
1828
- }
1829
- }, dt = (n, s) => {
1830
- switch (n.op) {
1831
- case "test":
1832
- return new Ms(b(n.path), n.value, !!n.not);
1833
- case "defined":
1834
- return new zs(b(n.path));
1835
- case "undefined":
1836
- return new Bs(b(n.path));
1837
- case "type":
1838
- return new an(b(n.path), n.value);
1839
- case "test_type":
1840
- return new Gs(b(n.path), n.type);
1841
- case "test_string":
1842
- return new Fs(b(n.path), n.pos, n.str, !!n.not);
1843
- case "test_string_len":
1844
- return new qs(b(n.path), n.len, !!n.not);
1845
- case "contains":
1846
- return new Xs(b(n.path), n.value, !!n.ignore_case);
1847
- case "ends":
1848
- return new Ks(b(n.path), n.value, !!n.ignore_case);
1849
- case "starts":
1850
- return new Zs(b(n.path), n.value, !!n.ignore_case);
1851
- case "matches":
1852
- return new rn(b(n.path), n.value, !!n.ignore_case, s.createMatcher || Us);
1853
- case "in":
1854
- return new Ys(b(n.path), n.value);
1855
- case "less":
1856
- return new Qs(b(n.path), n.value);
1857
- case "more":
1858
- return new tn(b(n.path), n.value);
1859
- case "and": {
1860
- const t = b(n.path);
1861
- return new en(t, n.apply.map((e) => dt({ ...e, path: [...t, ...b(e.path)] }, s)));
1862
- }
1863
- case "or": {
1864
- const t = b(n.path);
1865
- return new sn(t, n.apply.map((e) => dt({ ...e, path: [...t, ...b(e.path)] }, s)));
1866
- }
1867
- case "not": {
1868
- const t = b(n.path);
1869
- return new nn(t, n.apply.map((e) => dt({ ...e, path: [...t, ...b(e.path)] }, s)));
1870
- }
1871
- default:
1872
- throw new Error("OP_UNKNOWN");
1873
- }
1874
- };
1875
- function ln(n, s, t) {
1876
- t.mutate || (n = ot(n));
1877
- const e = [], i = s.length;
1878
- for (let r = 0; r < i; r++) {
1879
- const l = hn(s[r], t).apply(n);
1880
- n = l.doc, e.push(l);
1881
- }
1882
- return { doc: n, res: e };
1883
- }
1884
- var et = (n) => typeof n == "function" ? n : function() {
1885
- return n;
1886
- }, cn = typeof self < "u" ? self : null, Q = typeof window < "u" ? window : null, st = cn || Q || st, un = "2.0.0", P = { connecting: 0, open: 1, closing: 2, closed: 3 }, pn = 1e4, dn = 1e3, R = {
1887
- closed: "closed",
1888
- errored: "errored",
1889
- joined: "joined",
1890
- joining: "joining",
1891
- leaving: "leaving"
1892
- }, U = {
1893
- close: "phx_close",
1894
- error: "phx_error",
1895
- join: "phx_join",
1896
- reply: "phx_reply",
1897
- leave: "phx_leave"
1898
- }, Lt = {
1899
- longpoll: "longpoll",
1900
- websocket: "websocket"
1901
- }, fn = {
1902
- complete: 4
1903
- }, ct = class {
1904
- constructor(n, s, t, e) {
1905
- this.channel = n, this.event = s, this.payload = t || function() {
1906
- return {};
1907
- }, this.receivedResp = null, this.timeout = e, this.timeoutTimer = null, this.recHooks = [], this.sent = !1;
1908
- }
1909
- resend(n) {
1910
- this.timeout = n, this.reset(), this.send();
1911
- }
1912
- send() {
1913
- this.hasReceived("timeout") || (this.startTimeout(), this.sent = !0, this.channel.socket.push({
1914
- topic: this.channel.topic,
1915
- event: this.event,
1916
- payload: this.payload(),
1917
- ref: this.ref,
1918
- join_ref: this.channel.joinRef()
1919
- }));
1920
- }
1921
- receive(n, s) {
1922
- return this.hasReceived(n) && s(this.receivedResp.response), this.recHooks.push({ status: n, callback: s }), this;
1923
- }
1924
- reset() {
1925
- this.cancelRefEvent(), this.ref = null, this.refEvent = null, this.receivedResp = null, this.sent = !1;
1926
- }
1927
- matchReceive({ status: n, response: s, _ref: t }) {
1928
- this.recHooks.filter((e) => e.status === n).forEach((e) => e.callback(s));
1929
- }
1930
- cancelRefEvent() {
1931
- this.refEvent && this.channel.off(this.refEvent);
1932
- }
1933
- cancelTimeout() {
1934
- clearTimeout(this.timeoutTimer), this.timeoutTimer = null;
1935
- }
1936
- startTimeout() {
1937
- this.timeoutTimer && this.cancelTimeout(), this.ref = this.channel.socket.makeRef(), this.refEvent = this.channel.replyEventName(this.ref), this.channel.on(this.refEvent, (n) => {
1938
- this.cancelRefEvent(), this.cancelTimeout(), this.receivedResp = n, this.matchReceive(n);
1939
- }), this.timeoutTimer = setTimeout(() => {
1940
- this.trigger("timeout", {});
1941
- }, this.timeout);
1942
- }
1943
- hasReceived(n) {
1944
- return this.receivedResp && this.receivedResp.status === n;
1945
- }
1946
- trigger(n, s) {
1947
- this.channel.trigger(this.refEvent, { status: n, response: s });
1948
- }
1949
- }, Ce = class {
1950
- constructor(n, s) {
1951
- this.callback = n, this.timerCalc = s, this.timer = null, this.tries = 0;
1952
- }
1953
- reset() {
1954
- this.tries = 0, clearTimeout(this.timer);
1955
- }
1956
- scheduleTimeout() {
1957
- clearTimeout(this.timer), this.timer = setTimeout(() => {
1958
- this.tries = this.tries + 1, this.callback();
1959
- }, this.timerCalc(this.tries + 1));
1960
- }
1961
- }, vn = class {
1962
- constructor(n, s, t) {
1963
- this.state = R.closed, this.topic = n, this.params = et(s || {}), this.socket = t, this.bindings = [], this.bindingRef = 0, this.timeout = this.socket.timeout, this.joinedOnce = !1, this.joinPush = new ct(this, U.join, this.params, this.timeout), this.pushBuffer = [], this.stateChangeRefs = [], this.rejoinTimer = new Ce(() => {
1964
- this.socket.isConnected() && this.rejoin();
1965
- }, this.socket.rejoinAfterMs), this.stateChangeRefs.push(this.socket.onError(() => this.rejoinTimer.reset())), this.stateChangeRefs.push(this.socket.onOpen(() => {
1966
- this.rejoinTimer.reset(), this.isErrored() && this.rejoin();
1967
- })), this.joinPush.receive("ok", () => {
1968
- this.state = R.joined, this.rejoinTimer.reset(), this.pushBuffer.forEach((e) => e.send()), this.pushBuffer = [];
1969
- }), this.joinPush.receive("error", () => {
1970
- this.state = R.errored, this.socket.isConnected() && this.rejoinTimer.scheduleTimeout();
1971
- }), this.onClose(() => {
1972
- this.rejoinTimer.reset(), this.socket.hasLogger() && this.socket.log("channel", `close ${this.topic} ${this.joinRef()}`), this.state = R.closed, this.socket.remove(this);
1973
- }), this.onError((e) => {
1974
- this.socket.hasLogger() && this.socket.log("channel", `error ${this.topic}`, e), this.isJoining() && this.joinPush.reset(), this.state = R.errored, this.socket.isConnected() && this.rejoinTimer.scheduleTimeout();
1975
- }), this.joinPush.receive("timeout", () => {
1976
- this.socket.hasLogger() && this.socket.log("channel", `timeout ${this.topic} (${this.joinRef()})`, this.joinPush.timeout), new ct(this, U.leave, et({}), this.timeout).send(), this.state = R.errored, this.joinPush.reset(), this.socket.isConnected() && this.rejoinTimer.scheduleTimeout();
1977
- }), this.on(U.reply, (e, i) => {
1978
- this.trigger(this.replyEventName(i), e);
1979
- });
1980
- }
1981
- join(n = this.timeout) {
1982
- if (this.joinedOnce)
1983
- throw new Error("tried to join multiple times. 'join' can only be called a single time per channel instance");
1984
- return this.timeout = n, this.joinedOnce = !0, this.rejoin(), this.joinPush;
1985
- }
1986
- onClose(n) {
1987
- this.on(U.close, n);
1988
- }
1989
- onError(n) {
1990
- return this.on(U.error, (s) => n(s));
1991
- }
1992
- on(n, s) {
1993
- let t = this.bindingRef++;
1994
- return this.bindings.push({ event: n, ref: t, callback: s }), t;
1995
- }
1996
- off(n, s) {
1997
- this.bindings = this.bindings.filter((t) => !(t.event === n && (typeof s > "u" || s === t.ref)));
1998
- }
1999
- canPush() {
2000
- return this.socket.isConnected() && this.isJoined();
2001
- }
2002
- push(n, s, t = this.timeout) {
2003
- if (s = s || {}, !this.joinedOnce)
2004
- throw new Error(`tried to push '${n}' to '${this.topic}' before joining. Use channel.join() before pushing events`);
2005
- let e = new ct(this, n, function() {
2006
- return s;
2007
- }, t);
2008
- return this.canPush() ? e.send() : (e.startTimeout(), this.pushBuffer.push(e)), e;
2009
- }
2010
- leave(n = this.timeout) {
2011
- this.rejoinTimer.reset(), this.joinPush.cancelTimeout(), this.state = R.leaving;
2012
- let s = () => {
2013
- this.socket.hasLogger() && this.socket.log("channel", `leave ${this.topic}`), this.trigger(U.close, "leave");
2014
- }, t = new ct(this, U.leave, et({}), n);
2015
- return t.receive("ok", () => s()).receive("timeout", () => s()), t.send(), this.canPush() || t.trigger("ok", {}), t;
2016
- }
2017
- onMessage(n, s, t) {
2018
- return s;
2019
- }
2020
- isMember(n, s, t, e) {
2021
- return this.topic !== n ? !1 : e && e !== this.joinRef() ? (this.socket.hasLogger() && this.socket.log("channel", "dropping outdated message", { topic: n, event: s, payload: t, joinRef: e }), !1) : !0;
2022
- }
2023
- joinRef() {
2024
- return this.joinPush.ref;
2025
- }
2026
- rejoin(n = this.timeout) {
2027
- this.isLeaving() || (this.socket.leaveOpenTopic(this.topic), this.state = R.joining, this.joinPush.resend(n));
2028
- }
2029
- trigger(n, s, t, e) {
2030
- let i = this.onMessage(n, s, t, e);
2031
- if (s && !i)
2032
- throw new Error("channel onMessage callbacks must return the payload, modified or unmodified");
2033
- let r = this.bindings.filter((o) => o.event === n);
2034
- for (let o = 0; o < r.length; o++)
2035
- r[o].callback(i, t, e || this.joinRef());
2036
- }
2037
- replyEventName(n) {
2038
- return `chan_reply_${n}`;
2039
- }
2040
- isClosed() {
2041
- return this.state === R.closed;
2042
- }
2043
- isErrored() {
2044
- return this.state === R.errored;
2045
- }
2046
- isJoined() {
2047
- return this.state === R.joined;
2048
- }
2049
- isJoining() {
2050
- return this.state === R.joining;
2051
- }
2052
- isLeaving() {
2053
- return this.state === R.leaving;
2054
- }
2055
- }, yt = class {
2056
- static request(n, s, t, e, i, r, o) {
2057
- if (st.XDomainRequest) {
2058
- let l = new st.XDomainRequest();
2059
- return this.xdomainRequest(l, n, s, e, i, r, o);
2060
- } else {
2061
- let l = new st.XMLHttpRequest();
2062
- return this.xhrRequest(l, n, s, t, e, i, r, o);
2063
- }
2064
- }
2065
- static xdomainRequest(n, s, t, e, i, r, o) {
2066
- return n.timeout = i, n.open(s, t), n.onload = () => {
2067
- let l = this.parseJSON(n.responseText);
2068
- o && o(l);
2069
- }, r && (n.ontimeout = r), n.onprogress = () => {
2070
- }, n.send(e), n;
2071
- }
2072
- static xhrRequest(n, s, t, e, i, r, o, l) {
2073
- return n.open(s, t, !0), n.timeout = r, n.setRequestHeader("Content-Type", e), n.onerror = () => l && l(null), n.onreadystatechange = () => {
2074
- if (n.readyState === fn.complete && l) {
2075
- let u = this.parseJSON(n.responseText);
2076
- l(u);
2077
- }
2078
- }, o && (n.ontimeout = o), n.send(i), n;
2079
- }
2080
- static parseJSON(n) {
2081
- if (!n || n === "")
2082
- return null;
2083
- try {
2084
- return JSON.parse(n);
2085
- } catch {
2086
- return console && console.log("failed to parse JSON response", n), null;
2087
- }
2088
- }
2089
- static serialize(n, s) {
2090
- let t = [];
2091
- for (var e in n) {
2092
- if (!Object.prototype.hasOwnProperty.call(n, e))
2093
- continue;
2094
- let i = s ? `${s}[${e}]` : e, r = n[e];
2095
- typeof r == "object" ? t.push(this.serialize(r, i)) : t.push(encodeURIComponent(i) + "=" + encodeURIComponent(r));
2096
- }
2097
- return t.join("&");
2098
- }
2099
- static appendParams(n, s) {
2100
- if (Object.keys(s).length === 0)
2101
- return n;
2102
- let t = n.match(/\?/) ? "&" : "?";
2103
- return `${n}${t}${this.serialize(s)}`;
2104
- }
2105
- }, jt = class {
2106
- constructor(n) {
2107
- this.endPoint = null, this.token = null, this.skipHeartbeat = !0, this.reqs = /* @__PURE__ */ new Set(), this.onopen = function() {
2108
- }, this.onerror = function() {
2109
- }, this.onmessage = function() {
2110
- }, this.onclose = function() {
2111
- }, this.pollEndpoint = this.normalizeEndpoint(n), this.readyState = P.connecting, this.poll();
2112
- }
2113
- normalizeEndpoint(n) {
2114
- return n.replace("ws://", "http://").replace("wss://", "https://").replace(new RegExp("(.*)/" + Lt.websocket), "$1/" + Lt.longpoll);
2115
- }
2116
- endpointURL() {
2117
- return yt.appendParams(this.pollEndpoint, { token: this.token });
2118
- }
2119
- closeAndRetry(n, s, t) {
2120
- this.close(n, s, t), this.readyState = P.connecting;
2121
- }
2122
- ontimeout() {
2123
- this.onerror("timeout"), this.closeAndRetry(1005, "timeout", !1);
2124
- }
2125
- isActive() {
2126
- return this.readyState === P.open || this.readyState === P.connecting;
2127
- }
2128
- poll() {
2129
- this.ajax("GET", null, () => this.ontimeout(), (n) => {
2130
- if (n) {
2131
- var { status: s, token: t, messages: e } = n;
2132
- this.token = t;
2133
- } else
2134
- s = 0;
2135
- switch (s) {
2136
- case 200:
2137
- e.forEach((i) => {
2138
- setTimeout(() => this.onmessage({ data: i }), 0);
2139
- }), this.poll();
2140
- break;
2141
- case 204:
2142
- this.poll();
2143
- break;
2144
- case 410:
2145
- this.readyState = P.open, this.onopen({}), this.poll();
2146
- break;
2147
- case 403:
2148
- this.onerror(403), this.close(1008, "forbidden", !1);
2149
- break;
2150
- case 0:
2151
- case 500:
2152
- this.onerror(500), this.closeAndRetry(1011, "internal server error", 500);
2153
- break;
2154
- default:
2155
- throw new Error(`unhandled poll status ${s}`);
2156
- }
2157
- });
2158
- }
2159
- send(n) {
2160
- this.ajax("POST", n, () => this.onerror("timeout"), (s) => {
2161
- (!s || s.status !== 200) && (this.onerror(s && s.status), this.closeAndRetry(1011, "internal server error", !1));
2162
- });
2163
- }
2164
- close(n, s, t) {
2165
- for (let i of this.reqs)
2166
- i.abort();
2167
- this.readyState = P.closed;
2168
- let e = Object.assign({ code: 1e3, reason: void 0, wasClean: !0 }, { code: n, reason: s, wasClean: t });
2169
- typeof CloseEvent < "u" ? this.onclose(new CloseEvent("close", e)) : this.onclose(e);
2170
- }
2171
- ajax(n, s, t, e) {
2172
- let i, r = () => {
2173
- this.reqs.delete(i), t();
2174
- };
2175
- i = yt.request(n, this.endpointURL(), "application/json", s, this.timeout, r, (o) => {
2176
- this.reqs.delete(i), this.isActive() && e(o);
2177
- }), this.reqs.add(i);
2178
- }
2179
- }, ut = {
2180
- HEADER_LENGTH: 1,
2181
- META_LENGTH: 4,
2182
- KINDS: { push: 0, reply: 1, broadcast: 2 },
2183
- encode(n, s) {
2184
- if (n.payload.constructor === ArrayBuffer)
2185
- return s(this.binaryEncode(n));
2186
- {
2187
- let t = [n.join_ref, n.ref, n.topic, n.event, n.payload];
2188
- return s(JSON.stringify(t));
2189
- }
2190
- },
2191
- decode(n, s) {
2192
- if (n.constructor === ArrayBuffer)
2193
- return s(this.binaryDecode(n));
2194
- {
2195
- let [t, e, i, r, o] = JSON.parse(n);
2196
- return s({ join_ref: t, ref: e, topic: i, event: r, payload: o });
2197
- }
2198
- },
2199
- binaryEncode(n) {
2200
- let { join_ref: s, ref: t, event: e, topic: i, payload: r } = n, o = this.META_LENGTH + s.length + t.length + i.length + e.length, l = new ArrayBuffer(this.HEADER_LENGTH + o), u = new DataView(l), d = 0;
2201
- u.setUint8(d++, this.KINDS.push), u.setUint8(d++, s.length), u.setUint8(d++, t.length), u.setUint8(d++, i.length), u.setUint8(d++, e.length), Array.from(s, (w) => u.setUint8(d++, w.charCodeAt(0))), Array.from(t, (w) => u.setUint8(d++, w.charCodeAt(0))), Array.from(i, (w) => u.setUint8(d++, w.charCodeAt(0))), Array.from(e, (w) => u.setUint8(d++, w.charCodeAt(0)));
2202
- var _ = new Uint8Array(l.byteLength + r.byteLength);
2203
- return _.set(new Uint8Array(l), 0), _.set(new Uint8Array(r), l.byteLength), _.buffer;
2204
- },
2205
- binaryDecode(n) {
2206
- let s = new DataView(n), t = s.getUint8(0), e = new TextDecoder();
2207
- switch (t) {
2208
- case this.KINDS.push:
2209
- return this.decodePush(n, s, e);
2210
- case this.KINDS.reply:
2211
- return this.decodeReply(n, s, e);
2212
- case this.KINDS.broadcast:
2213
- return this.decodeBroadcast(n, s, e);
2214
- }
2215
- },
2216
- decodePush(n, s, t) {
2217
- let e = s.getUint8(1), i = s.getUint8(2), r = s.getUint8(3), o = this.HEADER_LENGTH + this.META_LENGTH - 1, l = t.decode(n.slice(o, o + e));
2218
- o = o + e;
2219
- let u = t.decode(n.slice(o, o + i));
2220
- o = o + i;
2221
- let d = t.decode(n.slice(o, o + r));
2222
- o = o + r;
2223
- let _ = n.slice(o, n.byteLength);
2224
- return { join_ref: l, ref: null, topic: u, event: d, payload: _ };
2225
- },
2226
- decodeReply(n, s, t) {
2227
- let e = s.getUint8(1), i = s.getUint8(2), r = s.getUint8(3), o = s.getUint8(4), l = this.HEADER_LENGTH + this.META_LENGTH, u = t.decode(n.slice(l, l + e));
2228
- l = l + e;
2229
- let d = t.decode(n.slice(l, l + i));
2230
- l = l + i;
2231
- let _ = t.decode(n.slice(l, l + r));
2232
- l = l + r;
2233
- let w = t.decode(n.slice(l, l + o));
2234
- l = l + o;
2235
- let T = n.slice(l, n.byteLength), O = { status: w, response: T };
2236
- return { join_ref: u, ref: d, topic: _, event: U.reply, payload: O };
2237
- },
2238
- decodeBroadcast(n, s, t) {
2239
- let e = s.getUint8(1), i = s.getUint8(2), r = this.HEADER_LENGTH + 2, o = t.decode(n.slice(r, r + e));
2240
- r = r + e;
2241
- let l = t.decode(n.slice(r, r + i));
2242
- r = r + i;
2243
- let u = n.slice(r, n.byteLength);
2244
- return { join_ref: null, ref: null, topic: o, event: l, payload: u };
2245
- }
2246
- }, gn = class {
2247
- constructor(n, s = {}) {
2248
- this.stateChangeCallbacks = { open: [], close: [], error: [], message: [] }, this.channels = [], this.sendBuffer = [], this.ref = 0, this.timeout = s.timeout || pn, this.transport = s.transport || st.WebSocket || jt, this.establishedConnections = 0, this.defaultEncoder = ut.encode.bind(ut), this.defaultDecoder = ut.decode.bind(ut), this.closeWasClean = !1, this.binaryType = s.binaryType || "arraybuffer", this.connectClock = 1, this.transport !== jt ? (this.encode = s.encode || this.defaultEncoder, this.decode = s.decode || this.defaultDecoder) : (this.encode = this.defaultEncoder, this.decode = this.defaultDecoder);
2249
- let t = null;
2250
- Q && Q.addEventListener && (Q.addEventListener("pagehide", (e) => {
2251
- this.conn && (this.disconnect(), t = this.connectClock);
2252
- }), Q.addEventListener("pageshow", (e) => {
2253
- t === this.connectClock && (t = null, this.connect());
2254
- })), this.heartbeatIntervalMs = s.heartbeatIntervalMs || 3e4, this.rejoinAfterMs = (e) => s.rejoinAfterMs ? s.rejoinAfterMs(e) : [1e3, 2e3, 5e3][e - 1] || 1e4, this.reconnectAfterMs = (e) => s.reconnectAfterMs ? s.reconnectAfterMs(e) : [10, 50, 100, 150, 200, 250, 500, 1e3, 2e3][e - 1] || 5e3, this.logger = s.logger || null, this.longpollerTimeout = s.longpollerTimeout || 2e4, this.params = et(s.params || {}), this.endPoint = `${n}/${Lt.websocket}`, this.vsn = s.vsn || un, this.heartbeatTimeoutTimer = null, this.heartbeatTimer = null, this.pendingHeartbeatRef = null, this.reconnectTimer = new Ce(() => {
2255
- this.teardown(() => this.connect());
2256
- }, this.reconnectAfterMs);
2257
- }
2258
- getLongPollTransport() {
2259
- return jt;
2260
- }
2261
- replaceTransport(n) {
2262
- this.connectClock++, this.closeWasClean = !0, this.reconnectTimer.reset(), this.sendBuffer = [], this.conn && (this.conn.close(), this.conn = null), this.transport = n;
2263
- }
2264
- protocol() {
2265
- return location.protocol.match(/^https/) ? "wss" : "ws";
2266
- }
2267
- endPointURL() {
2268
- let n = yt.appendParams(yt.appendParams(this.endPoint, this.params()), { vsn: this.vsn });
2269
- return n.charAt(0) !== "/" ? n : n.charAt(1) === "/" ? `${this.protocol()}:${n}` : `${this.protocol()}://${location.host}${n}`;
2270
- }
2271
- disconnect(n, s, t) {
2272
- this.connectClock++, this.closeWasClean = !0, this.reconnectTimer.reset(), this.teardown(n, s, t);
2273
- }
2274
- connect(n) {
2275
- n && (console && console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"), this.params = et(n)), !this.conn && (this.connectClock++, this.closeWasClean = !1, this.conn = new this.transport(this.endPointURL()), this.conn.binaryType = this.binaryType, this.conn.timeout = this.longpollerTimeout, this.conn.onopen = () => this.onConnOpen(), this.conn.onerror = (s) => this.onConnError(s), this.conn.onmessage = (s) => this.onConnMessage(s), this.conn.onclose = (s) => this.onConnClose(s));
2276
- }
2277
- log(n, s, t) {
2278
- this.logger(n, s, t);
2279
- }
2280
- hasLogger() {
2281
- return this.logger !== null;
2282
- }
2283
- onOpen(n) {
2284
- let s = this.makeRef();
2285
- return this.stateChangeCallbacks.open.push([s, n]), s;
2286
- }
2287
- onClose(n) {
2288
- let s = this.makeRef();
2289
- return this.stateChangeCallbacks.close.push([s, n]), s;
2290
- }
2291
- onError(n) {
2292
- let s = this.makeRef();
2293
- return this.stateChangeCallbacks.error.push([s, n]), s;
2294
- }
2295
- onMessage(n) {
2296
- let s = this.makeRef();
2297
- return this.stateChangeCallbacks.message.push([s, n]), s;
2298
- }
2299
- ping(n) {
2300
- if (!this.isConnected())
2301
- return !1;
2302
- let s = this.makeRef(), t = Date.now();
2303
- this.push({ topic: "phoenix", event: "heartbeat", payload: {}, ref: s });
2304
- let e = this.onMessage((i) => {
2305
- i.ref === s && (this.off([e]), n(Date.now() - t));
2306
- });
2307
- return !0;
2308
- }
2309
- clearHeartbeats() {
2310
- clearTimeout(this.heartbeatTimer), clearTimeout(this.heartbeatTimeoutTimer);
2311
- }
2312
- onConnOpen() {
2313
- this.hasLogger() && this.log("transport", `connected to ${this.endPointURL()}`), this.closeWasClean = !1, this.establishedConnections++, this.flushSendBuffer(), this.reconnectTimer.reset(), this.resetHeartbeat(), this.stateChangeCallbacks.open.forEach(([, n]) => n());
2314
- }
2315
- heartbeatTimeout() {
2316
- this.pendingHeartbeatRef && (this.pendingHeartbeatRef = null, this.hasLogger() && this.log("transport", "heartbeat timeout. Attempting to re-establish connection"), this.triggerChanError(), this.closeWasClean = !1, this.teardown(() => this.reconnectTimer.scheduleTimeout(), dn, "heartbeat timeout"));
2317
- }
2318
- resetHeartbeat() {
2319
- this.conn && this.conn.skipHeartbeat || (this.pendingHeartbeatRef = null, this.clearHeartbeats(), this.heartbeatTimer = setTimeout(() => this.sendHeartbeat(), this.heartbeatIntervalMs));
2320
- }
2321
- teardown(n, s, t) {
2322
- if (!this.conn)
2323
- return n && n();
2324
- this.waitForBufferDone(() => {
2325
- this.conn && (s ? this.conn.close(s, t || "") : this.conn.close()), this.waitForSocketClosed(() => {
2326
- this.conn && (this.conn.onopen = function() {
2327
- }, this.conn.onerror = function() {
2328
- }, this.conn.onmessage = function() {
2329
- }, this.conn.onclose = function() {
2330
- }, this.conn = null), n && n();
2331
- });
2332
- });
2333
- }
2334
- waitForBufferDone(n, s = 1) {
2335
- if (s === 5 || !this.conn || !this.conn.bufferedAmount) {
2336
- n();
2337
- return;
2338
- }
2339
- setTimeout(() => {
2340
- this.waitForBufferDone(n, s + 1);
2341
- }, 150 * s);
2342
- }
2343
- waitForSocketClosed(n, s = 1) {
2344
- if (s === 5 || !this.conn || this.conn.readyState === P.closed) {
2345
- n();
2346
- return;
2347
- }
2348
- setTimeout(() => {
2349
- this.waitForSocketClosed(n, s + 1);
2350
- }, 150 * s);
2351
- }
2352
- onConnClose(n) {
2353
- let s = n && n.code;
2354
- this.hasLogger() && this.log("transport", "close", n), this.triggerChanError(), this.clearHeartbeats(), !this.closeWasClean && s !== 1e3 && this.reconnectTimer.scheduleTimeout(), this.stateChangeCallbacks.close.forEach(([, t]) => t(n));
2355
- }
2356
- onConnError(n) {
2357
- this.hasLogger() && this.log("transport", n);
2358
- let s = this.transport, t = this.establishedConnections;
2359
- this.stateChangeCallbacks.error.forEach(([, e]) => {
2360
- e(n, s, t);
2361
- }), (s === this.transport || t > 0) && this.triggerChanError();
2362
- }
2363
- triggerChanError() {
2364
- this.channels.forEach((n) => {
2365
- n.isErrored() || n.isLeaving() || n.isClosed() || n.trigger(U.error);
2366
- });
2367
- }
2368
- connectionState() {
2369
- switch (this.conn && this.conn.readyState) {
2370
- case P.connecting:
2371
- return "connecting";
2372
- case P.open:
2373
- return "open";
2374
- case P.closing:
2375
- return "closing";
2376
- default:
2377
- return "closed";
2378
- }
2379
- }
2380
- isConnected() {
2381
- return this.connectionState() === "open";
2382
- }
2383
- remove(n) {
2384
- this.off(n.stateChangeRefs), this.channels = this.channels.filter((s) => s.joinRef() !== n.joinRef());
2385
- }
2386
- off(n) {
2387
- for (let s in this.stateChangeCallbacks)
2388
- this.stateChangeCallbacks[s] = this.stateChangeCallbacks[s].filter(([t]) => n.indexOf(t) === -1);
2389
- }
2390
- channel(n, s = {}) {
2391
- let t = new vn(n, s, this);
2392
- return this.channels.push(t), t;
2393
- }
2394
- push(n) {
2395
- if (this.hasLogger()) {
2396
- let { topic: s, event: t, payload: e, ref: i, join_ref: r } = n;
2397
- this.log("push", `${s} ${t} (${r}, ${i})`, e);
2398
- }
2399
- this.isConnected() ? this.encode(n, (s) => this.conn.send(s)) : this.sendBuffer.push(() => this.encode(n, (s) => this.conn.send(s)));
2400
- }
2401
- makeRef() {
2402
- let n = this.ref + 1;
2403
- return n === this.ref ? this.ref = 0 : this.ref = n, this.ref.toString();
2404
- }
2405
- sendHeartbeat() {
2406
- this.pendingHeartbeatRef && !this.isConnected() || (this.pendingHeartbeatRef = this.makeRef(), this.push({ topic: "phoenix", event: "heartbeat", payload: {}, ref: this.pendingHeartbeatRef }), this.heartbeatTimeoutTimer = setTimeout(() => this.heartbeatTimeout(), this.heartbeatIntervalMs));
2407
- }
2408
- flushSendBuffer() {
2409
- this.isConnected() && this.sendBuffer.length > 0 && (this.sendBuffer.forEach((n) => n()), this.sendBuffer = []);
2410
- }
2411
- onConnMessage(n) {
2412
- this.decode(n.data, (s) => {
2413
- let { topic: t, event: e, payload: i, ref: r, join_ref: o } = s;
2414
- r && r === this.pendingHeartbeatRef && (this.clearHeartbeats(), this.pendingHeartbeatRef = null, this.heartbeatTimer = setTimeout(() => this.sendHeartbeat(), this.heartbeatIntervalMs)), this.hasLogger() && this.log("receive", `${i.status || ""} ${t} ${e} ${r && "(" + r + ")" || ""}`, i);
2415
- for (let l = 0; l < this.channels.length; l++) {
2416
- const u = this.channels[l];
2417
- u.isMember(t, e, i, o) && u.trigger(e, i, r, o);
2418
- }
2419
- for (let l = 0; l < this.stateChangeCallbacks.message.length; l++) {
2420
- let [, u] = this.stateChangeCallbacks.message[l];
2421
- u(s);
2422
- }
2423
- });
2424
- }
2425
- leaveOpenTopic(n) {
2426
- let s = this.channels.find((t) => t.topic === n && (t.isJoined() || t.isJoining()));
2427
- s && (this.hasLogger() && this.log("transport", `leaving duplicate topic "${n}"`), s.leave());
2428
- }
2429
- };
2430
- class yn {
2431
- constructor(s) {
2432
- this.connected = !1, this.config = s, this.socket = new gn(this.config.url, { logger: (t, e, i) => {
2433
- console.log(`${t}: ${e}`, i);
2434
- } }), this.channel = this.socket.channel(this.config.topic, this.config.params), this.eventTarget = new EventTarget();
2435
- }
2436
- /** connect to socket and join channel. will do nothing if already connected */
2437
- connect() {
2438
- this.connected || (this.socket.onError((s) => this.emitError("socket error", s)), this.socket.connect(), this.channel.onError((s) => console.log("channel error", s)), this.channel.join().receive("ok", () => {
2439
- console.log("joined");
2440
- }).receive("error", (s) => {
2441
- this.emitError("channel join error", s);
2442
- }), this.channel.on("state:change", (s) => this.handleChange(s)), this.channel.on("state:patch", (s) => this.handlePatch(s)), this.connected = !0);
2443
- }
2444
- /** leave channel and disconnect from socket */
2445
- disconnect() {
2446
- this.channel && this.channel.leave(), this.socket.disconnect(), this.connected = !1;
2447
- }
2448
- /** for events that begin with 'livestate-', add a listener. For
2449
- * other events, additionally call `channel.on` to receive the event
2450
- * over the channel, which will then be dispatched.
2451
- */
2452
- addEventListener(s, t, e) {
2453
- var i;
2454
- this.eventTarget.addEventListener(s, t, e), s.startsWith("livestate-") || (i = this.channel) == null || i.on(s, (r) => {
2455
- this.eventTarget.dispatchEvent(new CustomEvent(s, { detail: r }));
2456
- });
2457
- }
2458
- removeEventListener(s, t, e) {
2459
- return this.eventTarget.removeEventListener(s, t, e);
2460
- }
2461
- /** @deprecated */
2462
- subscribe(s) {
2463
- this.addEventListener("livestate-change", s);
2464
- }
2465
- /** @deprecated */
2466
- unsubscribe(s) {
2467
- this.removeEventListener("livestate-change", s);
2468
- }
2469
- emitError(s, t) {
2470
- this.eventTarget.dispatchEvent(new CustomEvent("livestate-error", {
2471
- detail: {
2472
- kind: s,
2473
- error: t
2474
- }
2475
- }));
2476
- }
2477
- handleChange({ state: s, version: t }) {
2478
- this.state = s, this.stateVersion = t, this.eventTarget.dispatchEvent(new CustomEvent("livestate-change", {
2479
- detail: {
2480
- state: this.state,
2481
- version: this.stateVersion
2482
- }
2483
- }));
2484
- }
2485
- handlePatch({ patch: s, version: t }) {
2486
- if (this.eventTarget.dispatchEvent(new CustomEvent("livestate-patch", {
2487
- detail: { patch: s, version: t }
2488
- })), t === this.stateVersion + 1) {
2489
- const { doc: e, res: i } = ln(this.state, s, { mutate: !1 });
2490
- this.state = e, this.stateVersion = t, this.eventTarget.dispatchEvent(new CustomEvent("livestate-change", {
2491
- detail: {
2492
- state: this.state,
2493
- version: this.stateVersion
2494
- }
2495
- }));
2496
- } else
2497
- this.channel.push("lvs_refresh");
2498
- }
2499
- pushEvent(s, t) {
2500
- this.dispatchEvent(new CustomEvent(s, { detail: t }));
2501
- }
2502
- /** Pushes the event over the channel, adding the `lvs_evt:` prefix and using the CustomEvent
2503
- * detail property as the payload
2504
- */
2505
- dispatchEvent(s) {
2506
- return this.channel.push(`lvs_evt:${s.type}`, s.detail), !0;
2507
- }
2508
- pushCustomEvent(s) {
2509
- this.dispatchEvent(s);
2510
- }
2511
- }
2512
- const mn = (n, s, { properties: t, attributes: e, events: i }) => {
2513
- var r, o;
2514
- s.liveState !== n && (n.connect(), t == null || t.forEach((l) => _n(n, s, l)), e == null || e.forEach((l) => wn(n, s, l)), (r = i == null ? void 0 : i.send) == null || r.forEach((l) => An(n, s, l)), (o = i == null ? void 0 : i.receive) == null || o.forEach((l) => bn(n, s, l)), s.liveState = n);
2515
- }, _n = (n, s, t) => {
2516
- n.addEventListener("livestate-change", ({ detail: { state: e } }) => {
2517
- s[t] = e[t];
2518
- });
2519
- }, wn = (n, s, t) => {
2520
- n.addEventListener("livestate-change", ({ detail: { state: e } }) => {
2521
- s.setAttribute(t, e[t]);
2522
- });
2523
- }, bn = (n, s, t) => {
2524
- n.addEventListener(t, ({ detail: e }) => {
2525
- s.dispatchEvent(new CustomEvent(t, { detail: e }));
2526
- });
2527
- }, An = (n, s, t) => {
2528
- s.addEventListener(t, (e) => {
2529
- const { detail: i } = e;
2530
- n.dispatchEvent(new CustomEvent(t, { detail: i }));
2531
- });
2532
- };
2533
- Promise.resolve();
2534
- var de = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
2535
- /*! *****************************************************************************
2536
- Copyright (C) Microsoft. All rights reserved.
2537
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
2538
- this file except in compliance with the License. You may obtain a copy of the
2539
- License at http://www.apache.org/licenses/LICENSE-2.0
2540
-
2541
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2542
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
2543
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
2544
- MERCHANTABLITY OR NON-INFRINGEMENT.
2545
-
2546
- See the Apache Version 2.0 License for specific language governing permissions
2547
- and limitations under the License.
2548
- ***************************************************************************** */
2549
- var fe;
2550
- (function(n) {
2551
- (function(s) {
2552
- var t = typeof de == "object" ? de : typeof self == "object" ? self : typeof this == "object" ? this : Function("return this;")(), e = i(n);
2553
- typeof t.Reflect > "u" ? t.Reflect = n : e = i(t.Reflect, e), s(e);
2554
- function i(r, o) {
2555
- return function(l, u) {
2556
- typeof r[l] != "function" && Object.defineProperty(r, l, { configurable: !0, writable: !0, value: u }), o && o(l, u);
2557
- };
2558
- }
2559
- })(function(s) {
2560
- var t = Object.prototype.hasOwnProperty, e = typeof Symbol == "function", i = e && typeof Symbol.toPrimitive < "u" ? Symbol.toPrimitive : "@@toPrimitive", r = e && typeof Symbol.iterator < "u" ? Symbol.iterator : "@@iterator", o = typeof Object.create == "function", l = { __proto__: [] } instanceof Array, u = !o && !l, d = {
2561
- // create an object in dictionary mode (a.k.a. "slow" mode in v8)
2562
- create: o ? function() {
2563
- return Et(/* @__PURE__ */ Object.create(null));
2564
- } : l ? function() {
2565
- return Et({ __proto__: null });
2566
- } : function() {
2567
- return Et({});
2568
- },
2569
- has: u ? function(a, h) {
2570
- return t.call(a, h);
2571
- } : function(a, h) {
2572
- return h in a;
2573
- },
2574
- get: u ? function(a, h) {
2575
- return t.call(a, h) ? a[h] : void 0;
2576
- } : function(a, h) {
2577
- return a[h];
2578
- }
2579
- }, _ = Object.getPrototypeOf(Function), w = typeof process == "object" && process.env && process.env.REFLECT_METADATA_USE_MAP_POLYFILL === "true", T = !w && typeof Map == "function" && typeof Map.prototype.entries == "function" ? Map : qe(), O = !w && typeof Set == "function" && typeof Set.prototype.entries == "function" ? Set : Xe(), wt = !w && typeof WeakMap == "function" ? WeakMap : Ke(), H = new wt();
2580
- function Te(a, h, c, p) {
2581
- if (k(c)) {
2582
- if (!Kt(a))
2583
- throw new TypeError();
2584
- if (!Zt(h))
2585
- throw new TypeError();
2586
- return He(a, h);
2587
- } else {
2588
- if (!Kt(a))
2589
- throw new TypeError();
2590
- if (!x(h))
2591
- throw new TypeError();
2592
- if (!x(p) && !k(p) && !W(p))
2593
- throw new TypeError();
2594
- return W(p) && (p = void 0), c = L(c), Le(a, h, c, p);
2595
- }
2596
- }
2597
- s("decorate", Te);
2598
- function ke(a, h) {
2599
- function c(p, f) {
2600
- if (!x(p))
2601
- throw new TypeError();
2602
- if (!k(f) && !ze(f))
2603
- throw new TypeError();
2604
- Gt(a, h, p, f);
2605
- }
2606
- return c;
2607
- }
2608
- s("metadata", ke);
2609
- function xe(a, h, c, p) {
2610
- if (!x(c))
2611
- throw new TypeError();
2612
- return k(p) || (p = L(p)), Gt(a, h, c, p);
2613
- }
2614
- s("defineMetadata", xe);
2615
- function Se(a, h, c) {
2616
- if (!x(h))
2617
- throw new TypeError();
2618
- return k(c) || (c = L(c)), zt(a, h, c);
2619
- }
2620
- s("hasMetadata", Se);
2621
- function Oe(a, h, c) {
2622
- if (!x(h))
2623
- throw new TypeError();
2624
- return k(c) || (c = L(c)), bt(a, h, c);
2625
- }
2626
- s("hasOwnMetadata", Oe);
2627
- function je(a, h, c) {
2628
- if (!x(h))
2629
- throw new TypeError();
2630
- return k(c) || (c = L(c)), Bt(a, h, c);
2631
- }
2632
- s("getMetadata", je);
2633
- function Me(a, h, c) {
2634
- if (!x(h))
2635
- throw new TypeError();
2636
- return k(c) || (c = L(c)), Wt(a, h, c);
2637
- }
2638
- s("getOwnMetadata", Me);
2639
- function Re(a, h) {
2640
- if (!x(a))
2641
- throw new TypeError();
2642
- return k(h) || (h = L(h)), Ft(a, h);
2643
- }
2644
- s("getMetadataKeys", Re);
2645
- function Ne(a, h) {
2646
- if (!x(a))
2647
- throw new TypeError();
2648
- return k(h) || (h = L(h)), qt(a, h);
2649
- }
2650
- s("getOwnMetadataKeys", Ne);
2651
- function Pe(a, h, c) {
2652
- if (!x(h))
2653
- throw new TypeError();
2654
- k(c) || (c = L(c));
2655
- var p = Z(
2656
- h,
2657
- c,
2658
- /*Create*/
2659
- !1
2660
- );
2661
- if (k(p) || !p.delete(a))
2662
- return !1;
2663
- if (p.size > 0)
2664
- return !0;
2665
- var f = H.get(h);
2666
- return f.delete(c), f.size > 0 || H.delete(h), !0;
2667
- }
2668
- s("deleteMetadata", Pe);
2669
- function He(a, h) {
2670
- for (var c = a.length - 1; c >= 0; --c) {
2671
- var p = a[c], f = p(h);
2672
- if (!k(f) && !W(f)) {
2673
- if (!Zt(f))
2674
- throw new TypeError();
2675
- h = f;
2676
- }
2677
- }
2678
- return h;
2679
- }
2680
- function Le(a, h, c, p) {
2681
- for (var f = a.length - 1; f >= 0; --f) {
2682
- var j = a[f], y = j(h, c, p);
2683
- if (!k(y) && !W(y)) {
2684
- if (!x(y))
2685
- throw new TypeError();
2686
- p = y;
2687
- }
2688
- }
2689
- return p;
2690
- }
2691
- function Z(a, h, c) {
2692
- var p = H.get(a);
2693
- if (k(p)) {
2694
- if (!c)
2695
- return;
2696
- p = new T(), H.set(a, p);
2697
- }
2698
- var f = p.get(h);
2699
- if (k(f)) {
2700
- if (!c)
2701
- return;
2702
- f = new T(), p.set(h, f);
2703
- }
2704
- return f;
2705
- }
2706
- function zt(a, h, c) {
2707
- var p = bt(a, h, c);
2708
- if (p)
2709
- return !0;
2710
- var f = At(h);
2711
- return W(f) ? !1 : zt(a, f, c);
2712
- }
2713
- function bt(a, h, c) {
2714
- var p = Z(
2715
- h,
2716
- c,
2717
- /*Create*/
2718
- !1
2719
- );
2720
- return k(p) ? !1 : Ve(p.has(a));
2721
- }
2722
- function Bt(a, h, c) {
2723
- var p = bt(a, h, c);
2724
- if (p)
2725
- return Wt(a, h, c);
2726
- var f = At(h);
2727
- if (!W(f))
2728
- return Bt(a, f, c);
2729
- }
2730
- function Wt(a, h, c) {
2731
- var p = Z(
2732
- h,
2733
- c,
2734
- /*Create*/
2735
- !1
2736
- );
2737
- if (!k(p))
2738
- return p.get(a);
2739
- }
2740
- function Gt(a, h, c, p) {
2741
- var f = Z(
2742
- c,
2743
- p,
2744
- /*Create*/
2745
- !0
2746
- );
2747
- f.set(a, h);
2748
- }
2749
- function Ft(a, h) {
2750
- var c = qt(a, h), p = At(a);
2751
- if (p === null)
2752
- return c;
2753
- var f = Ft(p, h);
2754
- if (f.length <= 0)
2755
- return c;
2756
- if (c.length <= 0)
2757
- return f;
2758
- for (var j = new O(), y = [], m = 0, v = c; m < v.length; m++) {
2759
- var A = v[m], E = j.has(A);
2760
- E || (j.add(A), y.push(A));
2761
- }
2762
- for (var D = 0, Qt = f; D < Qt.length; D++) {
2763
- var A = Qt[D], E = j.has(A);
2764
- E || (j.add(A), y.push(A));
2765
- }
2766
- return y;
2767
- }
2768
- function qt(a, h) {
2769
- var c = [], p = Z(
2770
- a,
2771
- h,
2772
- /*Create*/
2773
- !1
2774
- );
2775
- if (k(p))
2776
- return c;
2777
- for (var f = p.keys(), j = Be(f), y = 0; ; ) {
2778
- var m = Ge(j);
2779
- if (!m)
2780
- return c.length = y, c;
2781
- var v = We(m);
2782
- try {
2783
- c[y] = v;
2784
- } catch (A) {
2785
- try {
2786
- Fe(j);
2787
- } finally {
2788
- throw A;
2789
- }
2790
- }
2791
- y++;
2792
- }
2793
- }
2794
- function Xt(a) {
2795
- if (a === null)
2796
- return 1;
2797
- switch (typeof a) {
2798
- case "undefined":
2799
- return 0;
2800
- case "boolean":
2801
- return 2;
2802
- case "string":
2803
- return 3;
2804
- case "symbol":
2805
- return 4;
2806
- case "number":
2807
- return 5;
2808
- case "object":
2809
- return a === null ? 1 : 6;
2810
- default:
2811
- return 6;
2812
- }
2813
- }
2814
- function k(a) {
2815
- return a === void 0;
2816
- }
2817
- function W(a) {
2818
- return a === null;
2819
- }
2820
- function Ue(a) {
2821
- return typeof a == "symbol";
2822
- }
2823
- function x(a) {
2824
- return typeof a == "object" ? a !== null : typeof a == "function";
2825
- }
2826
- function De(a, h) {
2827
- switch (Xt(a)) {
2828
- case 0:
2829
- return a;
2830
- case 1:
2831
- return a;
2832
- case 2:
2833
- return a;
2834
- case 3:
2835
- return a;
2836
- case 4:
2837
- return a;
2838
- case 5:
2839
- return a;
2840
- }
2841
- var c = h === 3 ? "string" : h === 5 ? "number" : "default", p = Yt(a, i);
2842
- if (p !== void 0) {
2843
- var f = p.call(a, c);
2844
- if (x(f))
2845
- throw new TypeError();
2846
- return f;
2847
- }
2848
- return Ie(a, c === "default" ? "number" : c);
2849
- }
2850
- function Ie(a, h) {
2851
- if (h === "string") {
2852
- var c = a.toString;
2853
- if (G(c)) {
2854
- var p = c.call(a);
2855
- if (!x(p))
2856
- return p;
2857
- }
2858
- var f = a.valueOf;
2859
- if (G(f)) {
2860
- var p = f.call(a);
2861
- if (!x(p))
2862
- return p;
2863
- }
2864
- } else {
2865
- var f = a.valueOf;
2866
- if (G(f)) {
2867
- var p = f.call(a);
2868
- if (!x(p))
2869
- return p;
2870
- }
2871
- var j = a.toString;
2872
- if (G(j)) {
2873
- var p = j.call(a);
2874
- if (!x(p))
2875
- return p;
2876
- }
2877
- }
2878
- throw new TypeError();
2879
- }
2880
- function Ve(a) {
2881
- return !!a;
2882
- }
2883
- function Je(a) {
2884
- return "" + a;
2885
- }
2886
- function L(a) {
2887
- var h = De(
2888
- a,
2889
- 3
2890
- /* String */
2891
- );
2892
- return Ue(h) ? h : Je(h);
2893
- }
2894
- function Kt(a) {
2895
- return Array.isArray ? Array.isArray(a) : a instanceof Object ? a instanceof Array : Object.prototype.toString.call(a) === "[object Array]";
2896
- }
2897
- function G(a) {
2898
- return typeof a == "function";
2899
- }
2900
- function Zt(a) {
2901
- return typeof a == "function";
2902
- }
2903
- function ze(a) {
2904
- switch (Xt(a)) {
2905
- case 3:
2906
- return !0;
2907
- case 4:
2908
- return !0;
2909
- default:
2910
- return !1;
2911
- }
2912
- }
2913
- function Yt(a, h) {
2914
- var c = a[h];
2915
- if (c != null) {
2916
- if (!G(c))
2917
- throw new TypeError();
2918
- return c;
2919
- }
2920
- }
2921
- function Be(a) {
2922
- var h = Yt(a, r);
2923
- if (!G(h))
2924
- throw new TypeError();
2925
- var c = h.call(a);
2926
- if (!x(c))
2927
- throw new TypeError();
2928
- return c;
2929
- }
2930
- function We(a) {
2931
- return a.value;
2932
- }
2933
- function Ge(a) {
2934
- var h = a.next();
2935
- return h.done ? !1 : h;
2936
- }
2937
- function Fe(a) {
2938
- var h = a.return;
2939
- h && h.call(a);
2940
- }
2941
- function At(a) {
2942
- var h = Object.getPrototypeOf(a);
2943
- if (typeof a != "function" || a === _ || h !== _)
2944
- return h;
2945
- var c = a.prototype, p = c && Object.getPrototypeOf(c);
2946
- if (p == null || p === Object.prototype)
2947
- return h;
2948
- var f = p.constructor;
2949
- return typeof f != "function" || f === a ? h : f;
2950
- }
2951
- function qe() {
2952
- var a = {}, h = [], c = (
2953
- /** @class */
2954
- function() {
2955
- function y(m, v, A) {
2956
- this._index = 0, this._keys = m, this._values = v, this._selector = A;
2957
- }
2958
- return y.prototype["@@iterator"] = function() {
2959
- return this;
2960
- }, y.prototype[r] = function() {
2961
- return this;
2962
- }, y.prototype.next = function() {
2963
- var m = this._index;
2964
- if (m >= 0 && m < this._keys.length) {
2965
- var v = this._selector(this._keys[m], this._values[m]);
2966
- return m + 1 >= this._keys.length ? (this._index = -1, this._keys = h, this._values = h) : this._index++, { value: v, done: !1 };
2967
- }
2968
- return { value: void 0, done: !0 };
2969
- }, y.prototype.throw = function(m) {
2970
- throw this._index >= 0 && (this._index = -1, this._keys = h, this._values = h), m;
2971
- }, y.prototype.return = function(m) {
2972
- return this._index >= 0 && (this._index = -1, this._keys = h, this._values = h), { value: m, done: !0 };
2973
- }, y;
2974
- }()
2975
- );
2976
- return (
2977
- /** @class */
2978
- function() {
2979
- function y() {
2980
- this._keys = [], this._values = [], this._cacheKey = a, this._cacheIndex = -2;
2981
- }
2982
- return Object.defineProperty(y.prototype, "size", {
2983
- get: function() {
2984
- return this._keys.length;
2985
- },
2986
- enumerable: !0,
2987
- configurable: !0
2988
- }), y.prototype.has = function(m) {
2989
- return this._find(
2990
- m,
2991
- /*insert*/
2992
- !1
2993
- ) >= 0;
2994
- }, y.prototype.get = function(m) {
2995
- var v = this._find(
2996
- m,
2997
- /*insert*/
2998
- !1
2999
- );
3000
- return v >= 0 ? this._values[v] : void 0;
3001
- }, y.prototype.set = function(m, v) {
3002
- var A = this._find(
3003
- m,
3004
- /*insert*/
3005
- !0
3006
- );
3007
- return this._values[A] = v, this;
3008
- }, y.prototype.delete = function(m) {
3009
- var v = this._find(
3010
- m,
3011
- /*insert*/
3012
- !1
3013
- );
3014
- if (v >= 0) {
3015
- for (var A = this._keys.length, E = v + 1; E < A; E++)
3016
- this._keys[E - 1] = this._keys[E], this._values[E - 1] = this._values[E];
3017
- return this._keys.length--, this._values.length--, m === this._cacheKey && (this._cacheKey = a, this._cacheIndex = -2), !0;
3018
- }
3019
- return !1;
3020
- }, y.prototype.clear = function() {
3021
- this._keys.length = 0, this._values.length = 0, this._cacheKey = a, this._cacheIndex = -2;
3022
- }, y.prototype.keys = function() {
3023
- return new c(this._keys, this._values, p);
3024
- }, y.prototype.values = function() {
3025
- return new c(this._keys, this._values, f);
3026
- }, y.prototype.entries = function() {
3027
- return new c(this._keys, this._values, j);
3028
- }, y.prototype["@@iterator"] = function() {
3029
- return this.entries();
3030
- }, y.prototype[r] = function() {
3031
- return this.entries();
3032
- }, y.prototype._find = function(m, v) {
3033
- return this._cacheKey !== m && (this._cacheIndex = this._keys.indexOf(this._cacheKey = m)), this._cacheIndex < 0 && v && (this._cacheIndex = this._keys.length, this._keys.push(m), this._values.push(void 0)), this._cacheIndex;
3034
- }, y;
3035
- }()
3036
- );
3037
- function p(y, m) {
3038
- return y;
3039
- }
3040
- function f(y, m) {
3041
- return m;
3042
- }
3043
- function j(y, m) {
3044
- return [y, m];
3045
- }
3046
- }
3047
- function Xe() {
3048
- return (
3049
- /** @class */
3050
- function() {
3051
- function a() {
3052
- this._map = new T();
3053
- }
3054
- return Object.defineProperty(a.prototype, "size", {
3055
- get: function() {
3056
- return this._map.size;
3057
- },
3058
- enumerable: !0,
3059
- configurable: !0
3060
- }), a.prototype.has = function(h) {
3061
- return this._map.has(h);
3062
- }, a.prototype.add = function(h) {
3063
- return this._map.set(h, h), this;
3064
- }, a.prototype.delete = function(h) {
3065
- return this._map.delete(h);
3066
- }, a.prototype.clear = function() {
3067
- this._map.clear();
3068
- }, a.prototype.keys = function() {
3069
- return this._map.keys();
3070
- }, a.prototype.values = function() {
3071
- return this._map.values();
3072
- }, a.prototype.entries = function() {
3073
- return this._map.entries();
3074
- }, a.prototype["@@iterator"] = function() {
3075
- return this.keys();
3076
- }, a.prototype[r] = function() {
3077
- return this.keys();
3078
- }, a;
3079
- }()
3080
- );
3081
- }
3082
- function Ke() {
3083
- var a = 16, h = d.create(), c = p();
3084
- return (
3085
- /** @class */
3086
- function() {
3087
- function v() {
3088
- this._key = p();
3089
- }
3090
- return v.prototype.has = function(A) {
3091
- var E = f(
3092
- A,
3093
- /*create*/
3094
- !1
3095
- );
3096
- return E !== void 0 ? d.has(E, this._key) : !1;
3097
- }, v.prototype.get = function(A) {
3098
- var E = f(
3099
- A,
3100
- /*create*/
3101
- !1
3102
- );
3103
- return E !== void 0 ? d.get(E, this._key) : void 0;
3104
- }, v.prototype.set = function(A, E) {
3105
- var D = f(
3106
- A,
3107
- /*create*/
3108
- !0
3109
- );
3110
- return D[this._key] = E, this;
3111
- }, v.prototype.delete = function(A) {
3112
- var E = f(
3113
- A,
3114
- /*create*/
3115
- !1
3116
- );
3117
- return E !== void 0 ? delete E[this._key] : !1;
3118
- }, v.prototype.clear = function() {
3119
- this._key = p();
3120
- }, v;
3121
- }()
3122
- );
3123
- function p() {
3124
- var v;
3125
- do
3126
- v = "@@WeakMap@@" + m();
3127
- while (d.has(h, v));
3128
- return h[v] = !0, v;
3129
- }
3130
- function f(v, A) {
3131
- if (!t.call(v, c)) {
3132
- if (!A)
3133
- return;
3134
- Object.defineProperty(v, c, { value: d.create() });
3135
- }
3136
- return v[c];
3137
- }
3138
- function j(v, A) {
3139
- for (var E = 0; E < A; ++E)
3140
- v[E] = Math.random() * 255 | 0;
3141
- return v;
3142
- }
3143
- function y(v) {
3144
- return typeof Uint8Array == "function" ? typeof crypto < "u" ? crypto.getRandomValues(new Uint8Array(v)) : typeof msCrypto < "u" ? msCrypto.getRandomValues(new Uint8Array(v)) : j(new Uint8Array(v), v) : j(new Array(v), v);
3145
- }
3146
- function m() {
3147
- var v = y(a);
3148
- v[6] = v[6] & 79 | 64, v[8] = v[8] & 191 | 128;
3149
- for (var A = "", E = 0; E < a; ++E) {
3150
- var D = v[E];
3151
- (E === 4 || E === 6 || E === 8) && (A += "-"), D < 16 && (A += "0"), A += D.toString(16).toLowerCase();
3152
- }
3153
- return A;
3154
- }
3155
- }
3156
- function Et(a) {
3157
- return a.__ = void 0, delete a.__, a;
3158
- }
3159
- });
3160
- })(fe || (fe = {}));
3161
- var En = Object.defineProperty, $n = Object.getOwnPropertyDescriptor, lt = (n, s, t, e) => {
3162
- for (var i = e > 1 ? void 0 : e ? $n(s, t) : s, r = n.length - 1, o; r >= 0; r--)
3163
- (o = n[r]) && (i = (e ? o(s, t, i) : o(i)) || i);
3164
- return e && i && En(s, t, i), i;
3165
- };
3166
- let B = class extends tt {
3167
- constructor() {
3168
- super(...arguments), this.users = {}, this._throttledDispatchMouseMove = Cn(
3169
- this._dispatchMouseMove.bind(this),
3170
- // 15 // 15ms throttle interval = ~66.6 fps
3171
- // 10 // 10ms throttle interval = 100 fps
3172
- 8
3173
- // 8ms throttle interval = 125 fps
3174
- );
3175
- }
3176
- render() {
3177
- var n, s;
3178
- return le`
3179
- <div id="users-container">
3180
- ${Object.values(this.users).map(
3181
- (t) => {
3182
- var e;
3183
- return le`
3184
- <div
3185
- id="user-${t.id}"
3186
- class="user"
3187
- data-isself="${t.id == ((e = this.me) == null ? void 0 : e.id)}"
3188
- style="--color: ${t.color}; --x: ${t.x}vw; --y: ${t.y}vh;"
3189
- >
3190
- <svg
3191
- width="23"
3192
- viewBox="0 0 27 24"
3193
- fill="currentColor"
3194
- aria-hidden="true"
3195
- xmlns="http://www.w3.org/2000/svg"
3196
- class="cursor"
3197
- >
3198
- <path
3199
- d="M2.2706 0.0593359L25.4277 8.05957H25.45926C25.65896 8.13153 25.83096 8.25952 25.95221 8.42653C26.07357 8.59354 26.13851 8.79166 26.13851 8.99459C26.13851 9.19751 26.07357 9.39564 25.95221 9.56265C25.83096 9.72966 25.65896 9.85765 25.45926 9.92962L15.3543 13.7698L11.3124 23.37C11.2344 23.5561 11.0994 23.7156 10.9248 23.828C10.7503 23.9402 10.5443 24.0002 10.3335 24C10.1172 24 9.9061 23.9365 9.7291 23.8184C9.552 23.7004 9.4176 23.5332 9.344 23.34L0.9233 1.33937C0.8555 1.16076 0.8426 0.967504 0.8861 0.782189C0.9297 0.596873 1.0278 0.427163 1.1691 0.292901C1.3105 0.158639 1.4891 0.0653762 1.6841 0.0240151C1.8792 -0.0173461 2.0826 -0.00509504 2.2706 0.0593359Z"
3200
- />
3201
- </svg>
3202
- <span class="name">${t.name}</span>
3203
- <div
3204
- class="halo"
3205
- data-show="${t.is_mouse_down || t.is_escape_key_down}"
3206
- />
3207
- </div>
3208
- `;
3209
- }
3210
- )}
3211
- </div>
3212
-
3213
- <div class="banner" style="--color: ${(n = this.me) == null ? void 0 : n.color}">
3214
- <div class="pills">
3215
- <div class="current_user">
3216
- <span class="colorpoint"></span>
3217
- <p class="name">${(s = this.me) == null ? void 0 : s.name}</p>
3218
- </div>
3219
-
3220
- <div class="other_users">
3221
- <span>${Object.values(this.users).length}</span>
3222
- <svg
3223
- viewBox="0 0 20 20"
3224
- fill="currentColor"
3225
- aria-hidden="true"
3226
- xmlns="http://www.w3.org/2000/svg"
3227
- >
3228
- <path
3229
- fill-rule="evenodd"
3230
- clip-rule="evenodd"
3231
- d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-5.5-2.5a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0zM10 12a5.99 5.99 0 00-4.793 2.39A6.483 6.483 0 0010 16.5a6.483 6.483 0 004.793-2.11A5.99 5.99 0 0010 12z"
3232
- />
3233
- </svg>
3234
- </div>
3235
- </div>
3236
- </div>
3237
- `;
3238
- }
3239
- connectedCallback() {
3240
- super.connectedCallback();
3241
- const n = new yn({
3242
- url: this.url,
3243
- topic: `liveroom-livestate:${this.room_id}`,
3244
- params: {
3245
- room_id: this.room_id,
3246
- current_url: window.origin,
3247
- inner_width: window.innerWidth,
3248
- inner_height: window.innerHeight
3249
- }
3250
- });
3251
- mn(n, this, {
3252
- properties: ["room_id", "me", "users"],
3253
- events: {
3254
- send: [
3255
- "mouse_move",
3256
- "mouse_down",
3257
- "mouse_up",
3258
- "key_down",
3259
- "key_up",
3260
- "window_resize"
3261
- ],
3262
- receive: []
3263
- }
3264
- }), this.liveState = n, window.addEventListener("mousemove", this._throttledDispatchMouseMove), window.addEventListener("mousedown", this._dispatchMouseDown.bind(this)), window.addEventListener("mouseup", this._dispatchMouseUp.bind(this)), window.addEventListener("keydown", this._dispatchKeyDown.bind(this)), window.addEventListener("keyup", this._dispatchKeyUp.bind(this)), window.addEventListener("resize", this._dispatchWindowResize.bind(this));
3265
- }
3266
- disconnectedCallback() {
3267
- window.removeEventListener("resize", this._dispatchWindowResize.bind(this)), window.removeEventListener("keyup", this._dispatchKeyUp.bind(this)), window.removeEventListener("keydown", this._dispatchKeyDown.bind(this)), window.removeEventListener("mouseup", this._dispatchMouseUp.bind(this)), window.removeEventListener("mousedown", this._dispatchMouseDown.bind(this)), window.removeEventListener("mousemove", this._throttledDispatchMouseMove), this.liveState && this.liveState.disconnect(), super.disconnectedCallback();
3268
- }
3269
- _dispatchMouseMove(n) {
3270
- this.me && this.dispatchEvent(
3271
- new CustomEvent("mouse_move", {
3272
- detail: {
3273
- user_id: this.me.id,
3274
- x: Number(n.pageX / window.innerWidth * 100).toFixed(2),
3275
- // in %
3276
- y: Number(n.pageY / window.innerHeight * 100).toFixed(2)
3277
- // in %
3278
- }
3279
- })
3280
- );
3281
- }
3282
- _dispatchMouseDown(n) {
3283
- this.me && this.dispatchEvent(
3284
- new CustomEvent("mouse_down", {
3285
- detail: {
3286
- user_id: this.me.id
3287
- }
3288
- })
3289
- );
3290
- }
3291
- _dispatchMouseUp(n) {
3292
- this.me && this.dispatchEvent(
3293
- new CustomEvent("mouse_up", {
3294
- detail: {
3295
- user_id: this.me.id
3296
- }
3297
- })
3298
- );
3299
- }
3300
- _dispatchKeyDown(n) {
3301
- !n.repeat && ve.includes(n.key) && this.me && this.dispatchEvent(
3302
- new CustomEvent("key_down", {
3303
- detail: {
3304
- key: n.key,
3305
- user_id: this.me.id
3306
- }
3307
- })
3308
- );
3309
- }
3310
- _dispatchKeyUp(n) {
3311
- ve.includes(n.key) && this.me && this.dispatchEvent(
3312
- new CustomEvent("key_up", {
3313
- detail: {
3314
- key: n.key,
3315
- user_id: this.me.id
3316
- }
3317
- })
3318
- );
3319
- }
3320
- _dispatchWindowResize(n) {
3321
- this.me && this.dispatchEvent(
3322
- new CustomEvent("window_resize", {
3323
- detail: {
3324
- inner_width: window.innerWidth,
3325
- inner_height: window.innerHeight,
3326
- user_id: this.me.id
3327
- }
3328
- })
3329
- );
3330
- }
3331
- };
3332
- B.styles = ts`
3333
- #users-container {
3334
- position: absolute;
3335
- inset: 0;
3336
- overflow: hidden;
3337
- pointer-events: none;
3338
- }
3339
-
3340
- .user {
3341
- z-index: 1000;
3342
- position: absolute;
3343
- top: 0;
3344
- left: 0;
3345
- user-select: none;
3346
- transform: translate(var(--x), var(--y));
3347
- }
3348
-
3349
- .user .cursor {
3350
- position: absolute;
3351
- top: 0;
3352
- left: 0;
3353
- color: var(--color);
3354
- transform-origin: top left;
3355
- transform: rotate(6deg);
3356
- }
3357
- .user[data-isself="true"] .cursor {
3358
- display: none;
3359
- }
3360
-
3361
- .user .name {
3362
- position: absolute;
3363
- top: 20px;
3364
- left: 16px;
3365
- padding: 4px 10px;
3366
- font-size: 14px;
3367
- line-height: 20px;
3368
- font-weight: 600;
3369
- color: black;
3370
- background-color: var(--color);
3371
- overflow: hidden;
3372
- text-overflow: ellipsis;
3373
- white-space: nowrap;
3374
- border-radius: 9999px;
3375
- // Tailwind 'shadow-sm'
3376
- box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
3377
- }
3378
- .user[data-isself="true"] .name {
3379
- display: none;
3380
- }
3381
-
3382
- .user .halo {
3383
- transform: scale(0);
3384
- z-index: -1;
3385
- position: absolute;
3386
- top: -60px;
3387
- left: -60px;
3388
- width: 120px;
3389
- height: 120px;
3390
- border-radius: 9999px;
3391
- background-color: var(--color);
3392
- opacity: 0.25;
3393
- transition: transform 0.15s ease-out;
3394
- // Tailwind 'shadow-sm'
3395
- box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
3396
- }
3397
- .user .halo[data-show="true"] {
3398
- transform: scale(1);
3399
- }
3400
-
3401
- .banner {
3402
- z-index: 1000;
3403
- position: fixed;
3404
- bottom: 12px;
3405
- inset-inline: 0;
3406
- display: flex;
3407
- justify-content: center;
3408
- justify-items: center;
3409
- }
3410
-
3411
- .banner .pills {
3412
- display: flex;
3413
- justify-content: between;
3414
- align-items: center;
3415
- gap: 36px;
3416
- padding: 3px 8px;
3417
- background-color: white;
3418
- border-radius: 9999px;
3419
- -webkit-user-select: none;
3420
- -moz-user-select: none;
3421
- user-select: none;
3422
- }
3423
-
3424
- .banner .pills .current_user {
3425
- display: flex;
3426
- justify-content: center;
3427
- align-items: center;
3428
- gap: 8px;
3429
- }
3430
- .banner .pills .current_user .colorpoint {
3431
- display: block;
3432
- width: 14px;
3433
- height: 14px;
3434
- border-radius: 100%;
3435
- background-color: var(--color);
3436
- }
3437
- .banner .pills .current_user .name {
3438
- margin: 0;
3439
- font-size: 14px;
3440
- font-weight: bold;
3441
- color: black;
3442
- }
3443
-
3444
- .banner .pills .other_users {
3445
- display: flex;
3446
- justify-content: center;
3447
- align-items: center;
3448
- gap: 4px;
3449
- color: gray;
3450
- }
3451
- .banner .pills .other_users span {
3452
- font-size: 14px;
3453
- font-weight: bold;
3454
- }
3455
- .banner .pills .other_users svg {
3456
- width: 18px;
3457
- opacity: 0.8;
3458
- }
3459
- `;
3460
- lt([
3461
- It({ attribute: "url" })
3462
- ], B.prototype, "url", 2);
3463
- lt([
3464
- It({ attribute: "room_id" })
3465
- ], B.prototype, "room_id", 2);
3466
- lt([
3467
- Ae()
3468
- ], B.prototype, "me", 2);
3469
- lt([
3470
- Ae()
3471
- ], B.prototype, "users", 2);
3472
- B = lt([
3473
- fs("liveroom-client-element")
3474
- ], B);
3475
- const ve = ["Escape"];
3476
- function Cn(n, s) {
3477
- let t = 0;
3478
- return function(...e) {
3479
- let i = Date.now();
3480
- if (i - t > s)
3481
- return t = i, n.apply(this, e);
3482
- };
3483
- }
3484
- export {
3485
- B as LiveroomClientElement
3486
- };