@vouchfor/embeds 0.0.0-experiment.a91d11e → 0.0.0-experiment.a965a35

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.
Files changed (42) hide show
  1. package/dist/es/embeds.js +905 -1379
  2. package/dist/es/embeds.js.map +1 -1
  3. package/dist/es/src/components/DialogEmbed/DialogOverlay.d.ts +20 -0
  4. package/dist/es/src/components/DialogEmbed/DialogPortal.d.ts +36 -0
  5. package/dist/es/src/components/DialogEmbed/index.d.ts +37 -0
  6. package/dist/es/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +16 -0
  7. package/dist/es/src/components/PlayerEmbed/controllers/fetcher.d.ts +15 -0
  8. package/dist/es/src/components/PlayerEmbed/controllers/tracking/index.d.ts +37 -0
  9. package/dist/es/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +18 -0
  10. package/dist/es/src/components/PlayerEmbed/index.d.ts +74 -0
  11. package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +5 -0
  12. package/dist/es/src/components/PlayerEmbed/tests/media-data.d.ts +19 -0
  13. package/dist/es/src/index.d.ts +2 -0
  14. package/dist/iife/dialog-embed/embed.iife.js +4078 -0
  15. package/dist/iife/dialog-embed/embed.iife.js.map +1 -0
  16. package/dist/iife/embeds.iife.js +3082 -438
  17. package/dist/iife/embeds.iife.js.map +1 -1
  18. package/dist/iife/player-embed/embed.iife.js +3940 -0
  19. package/dist/iife/player-embed/embed.iife.js.map +1 -0
  20. package/package.json +49 -35
  21. package/src/components/DialogEmbed/Dialog.stories.ts +91 -0
  22. package/src/components/DialogEmbed/DialogOverlay.ts +131 -0
  23. package/src/components/DialogEmbed/DialogPortal.ts +126 -0
  24. package/src/components/DialogEmbed/index.ts +97 -0
  25. package/src/components/PlayerEmbed/MultiEmbed.stories.ts +135 -0
  26. package/src/components/{Embed/Embed.stories.ts → PlayerEmbed/PlayerEmbed.stories.ts} +42 -15
  27. package/src/components/{Embed → PlayerEmbed}/controllers/event-forwarder.ts +6 -5
  28. package/src/components/{Embed → PlayerEmbed}/controllers/fetcher.ts +36 -17
  29. package/src/components/PlayerEmbed/controllers/tracking/index.ts +224 -0
  30. package/src/components/PlayerEmbed/controllers/tracking/utils.ts +95 -0
  31. package/src/components/{Embed → PlayerEmbed}/index.ts +100 -40
  32. package/src/components/PlayerEmbed/tests/PlayerEmbed.spec.ts +87 -0
  33. package/src/components/PlayerEmbed/tests/data.ts +227 -0
  34. package/src/components/PlayerEmbed/tests/media-data.ts +22 -0
  35. package/src/index.ts +2 -1
  36. package/dist/es/components/Embed/controllers/fetcher.d.ts +0 -13
  37. package/dist/es/components/Embed/controllers/tracking.d.ts +0 -29
  38. package/dist/es/components/Embed/index.d.ts +0 -66
  39. package/dist/es/index.d.ts +0 -1
  40. package/src/components/Embed/controllers/tracking.ts +0 -268
  41. /package/dist/es/{utils → src/utils}/env.d.ts +0 -0
  42. /package/dist/es/{utils → src/utils}/events.d.ts +0 -0
package/dist/es/embeds.js CHANGED
@@ -1,1346 +1,449 @@
1
- import { property as v, state as zt, customElement as he } from "lit/decorators.js";
2
- import { ifDefined as ft } from "lit/directives/if-defined.js";
3
- import { createRef as jt, ref as Bt } from "lit/directives/ref.js";
4
- import { Task as ae } from "@lit/task";
5
- import { v4 as P } from "uuid";
1
+ import { css, LitElement, html } from "lit";
2
+ import { property, state, customElement } from "lit/decorators.js";
3
+ import { ifDefined } from "lit/directives/if-defined.js";
4
+ import { createRef, ref } from "lit/directives/ref.js";
5
+ import { Task } from "@lit/task";
6
+ import { v4 } from "uuid";
7
+ import { TEMPLATE_VERSION } from "@vouchfor/canvas-video";
6
8
  import "@vouchfor/media-player";
7
- /**
8
- * @license
9
- * Copyright 2019 Google LLC
10
- * SPDX-License-Identifier: BSD-3-Clause
11
- */
12
- const G = globalThis, _t = G.ShadowRoot && (G.ShadyCSS === void 0 || G.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, Wt = Symbol(), gt = /* @__PURE__ */ new WeakMap();
13
- let le = class {
14
- constructor(t, e, i) {
15
- if (this._$cssResult$ = !0, i !== Wt)
16
- throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
17
- this.cssText = t, this.t = e;
18
- }
19
- get styleSheet() {
20
- let t = this.o;
21
- const e = this.t;
22
- if (_t && t === void 0) {
23
- const i = e !== void 0 && e.length === 1;
24
- i && (t = gt.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), i && gt.set(e, t));
25
- }
26
- return t;
27
- }
28
- toString() {
29
- return this.cssText;
30
- }
31
- };
32
- const ce = (r) => new le(typeof r == "string" ? r : r + "", void 0, Wt), de = (r, t) => {
33
- if (_t)
34
- r.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
35
- else
36
- for (const e of t) {
37
- const i = document.createElement("style"), s = G.litNonce;
38
- s !== void 0 && i.setAttribute("nonce", s), i.textContent = e.cssText, r.appendChild(i);
39
- }
40
- }, vt = _t ? (r) => r : (r) => r instanceof CSSStyleSheet ? ((t) => {
41
- let e = "";
42
- for (const i of t.cssRules)
43
- e += i.cssText;
44
- return ce(e);
45
- })(r) : r;
46
- /**
47
- * @license
48
- * Copyright 2017 Google LLC
49
- * SPDX-License-Identifier: BSD-3-Clause
50
- */
51
- const { is: pe, defineProperty: ue, getOwnPropertyDescriptor: _e, getOwnPropertyNames: $e, getOwnPropertySymbols: me, getPrototypeOf: fe } = Object, E = globalThis, yt = E.trustedTypes, ge = yt ? yt.emptyScript : "", rt = E.reactiveElementPolyfillSupport, I = (r, t) => r, dt = { toAttribute(r, t) {
52
- switch (t) {
53
- case Boolean:
54
- r = r ? ge : null;
55
- break;
56
- case Object:
57
- case Array:
58
- r = r == null ? r : JSON.stringify(r);
59
- }
60
- return r;
61
- }, fromAttribute(r, t) {
62
- let e = r;
63
- switch (t) {
64
- case Boolean:
65
- e = r !== null;
66
- break;
67
- case Number:
68
- e = r === null ? null : Number(r);
69
- break;
70
- case Object:
71
- case Array:
72
- try {
73
- e = JSON.parse(r);
74
- } catch {
75
- e = null;
76
- }
77
- }
78
- return e;
79
- } }, qt = (r, t) => !pe(r, t), At = { attribute: !0, type: String, converter: dt, reflect: !1, hasChanged: qt };
80
- Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), E.litPropertyMetadata ?? (E.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
81
- let L = class extends HTMLElement {
82
- static addInitializer(t) {
83
- this._$Ei(), (this.l ?? (this.l = [])).push(t);
84
- }
85
- static get observedAttributes() {
86
- return this.finalize(), this._$Eh && [...this._$Eh.keys()];
87
- }
88
- static createProperty(t, e = At) {
89
- if (e.state && (e.attribute = !1), this._$Ei(), this.elementProperties.set(t, e), !e.noAccessor) {
90
- const i = Symbol(), s = this.getPropertyDescriptor(t, i, e);
91
- s !== void 0 && ue(this.prototype, t, s);
92
- }
93
- }
94
- static getPropertyDescriptor(t, e, i) {
95
- const { get: s, set: n } = _e(this.prototype, t) ?? { get() {
96
- return this[e];
97
- }, set(o) {
98
- this[e] = o;
99
- } };
100
- return { get() {
101
- return s == null ? void 0 : s.call(this);
102
- }, set(o) {
103
- const a = s == null ? void 0 : s.call(this);
104
- n.call(this, o), this.requestUpdate(t, a, i);
105
- }, configurable: !0, enumerable: !0 };
106
- }
107
- static getPropertyOptions(t) {
108
- return this.elementProperties.get(t) ?? At;
109
- }
110
- static _$Ei() {
111
- if (this.hasOwnProperty(I("elementProperties")))
112
- return;
113
- const t = fe(this);
114
- t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
115
- }
116
- static finalize() {
117
- if (this.hasOwnProperty(I("finalized")))
118
- return;
119
- if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(I("properties"))) {
120
- const e = this.properties, i = [...$e(e), ...me(e)];
121
- for (const s of i)
122
- this.createProperty(s, e[s]);
123
- }
124
- const t = this[Symbol.metadata];
125
- if (t !== null) {
126
- const e = litPropertyMetadata.get(t);
127
- if (e !== void 0)
128
- for (const [i, s] of e)
129
- this.elementProperties.set(i, s);
130
- }
131
- this._$Eh = /* @__PURE__ */ new Map();
132
- for (const [e, i] of this.elementProperties) {
133
- const s = this._$Eu(e, i);
134
- s !== void 0 && this._$Eh.set(s, e);
135
- }
136
- this.elementStyles = this.finalizeStyles(this.styles);
137
- }
138
- static finalizeStyles(t) {
139
- const e = [];
140
- if (Array.isArray(t)) {
141
- const i = new Set(t.flat(1 / 0).reverse());
142
- for (const s of i)
143
- e.unshift(vt(s));
144
- } else
145
- t !== void 0 && e.push(vt(t));
146
- return e;
147
- }
148
- static _$Eu(t, e) {
149
- const i = e.attribute;
150
- return i === !1 ? void 0 : typeof i == "string" ? i : typeof t == "string" ? t.toLowerCase() : void 0;
151
- }
152
- constructor() {
153
- super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
154
- }
155
- _$Ev() {
156
- var t;
157
- this._$Eg = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$ES(), this.requestUpdate(), (t = this.constructor.l) == null || t.forEach((e) => e(this));
158
- }
159
- addController(t) {
160
- var e;
161
- (this._$E_ ?? (this._$E_ = /* @__PURE__ */ new Set())).add(t), this.renderRoot !== void 0 && this.isConnected && ((e = t.hostConnected) == null || e.call(t));
162
- }
163
- removeController(t) {
164
- var e;
165
- (e = this._$E_) == null || e.delete(t);
166
- }
167
- _$ES() {
168
- const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
169
- for (const i of e.keys())
170
- this.hasOwnProperty(i) && (t.set(i, this[i]), delete this[i]);
171
- t.size > 0 && (this._$Ep = t);
172
- }
173
- createRenderRoot() {
174
- const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
175
- return de(t, this.constructor.elementStyles), t;
176
- }
177
- connectedCallback() {
178
- var t;
179
- this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$E_) == null || t.forEach((e) => {
180
- var i;
181
- return (i = e.hostConnected) == null ? void 0 : i.call(e);
182
- });
183
- }
184
- enableUpdating(t) {
185
- }
186
- disconnectedCallback() {
187
- var t;
188
- (t = this._$E_) == null || t.forEach((e) => {
189
- var i;
190
- return (i = e.hostDisconnected) == null ? void 0 : i.call(e);
191
- });
192
- }
193
- attributeChangedCallback(t, e, i) {
194
- this._$AK(t, i);
195
- }
196
- _$EO(t, e) {
197
- var n;
198
- const i = this.constructor.elementProperties.get(t), s = this.constructor._$Eu(t, i);
199
- if (s !== void 0 && i.reflect === !0) {
200
- const o = (((n = i.converter) == null ? void 0 : n.toAttribute) !== void 0 ? i.converter : dt).toAttribute(e, i.type);
201
- this._$Em = t, o == null ? this.removeAttribute(s) : this.setAttribute(s, o), this._$Em = null;
202
- }
203
- }
204
- _$AK(t, e) {
205
- var n;
206
- const i = this.constructor, s = i._$Eh.get(t);
207
- if (s !== void 0 && this._$Em !== s) {
208
- const o = i.getPropertyOptions(s), a = typeof o.converter == "function" ? { fromAttribute: o.converter } : ((n = o.converter) == null ? void 0 : n.fromAttribute) !== void 0 ? o.converter : dt;
209
- this._$Em = s, this[s] = a.fromAttribute(e, o.type), this._$Em = null;
210
- }
211
- }
212
- requestUpdate(t, e, i, s = !1, n) {
213
- if (t !== void 0) {
214
- if (i ?? (i = this.constructor.getPropertyOptions(t)), !(i.hasChanged ?? qt)(s ? n : this[t], e))
215
- return;
216
- this.C(t, e, i);
217
- }
218
- this.isUpdatePending === !1 && (this._$Eg = this._$EP());
219
- }
220
- C(t, e, i) {
221
- this._$AL.has(t) || this._$AL.set(t, e), i.reflect === !0 && this._$Em !== t && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(t);
222
- }
223
- async _$EP() {
224
- this.isUpdatePending = !0;
225
- try {
226
- await this._$Eg;
227
- } catch (e) {
228
- Promise.reject(e);
229
- }
230
- const t = this.scheduleUpdate();
231
- return t != null && await t, !this.isUpdatePending;
232
- }
233
- scheduleUpdate() {
234
- return this.performUpdate();
235
- }
236
- performUpdate() {
237
- var i;
238
- if (!this.isUpdatePending)
239
- return;
240
- if (!this.hasUpdated) {
241
- if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
242
- for (const [n, o] of this._$Ep)
243
- this[n] = o;
244
- this._$Ep = void 0;
245
- }
246
- const s = this.constructor.elementProperties;
247
- if (s.size > 0)
248
- for (const [n, o] of s)
249
- o.wrapped !== !0 || this._$AL.has(n) || this[n] === void 0 || this.C(n, this[n], o);
250
- }
251
- let t = !1;
252
- const e = this._$AL;
253
- try {
254
- t = this.shouldUpdate(e), t ? (this.willUpdate(e), (i = this._$E_) == null || i.forEach((s) => {
255
- var n;
256
- return (n = s.hostUpdate) == null ? void 0 : n.call(s);
257
- }), this.update(e)) : this._$ET();
258
- } catch (s) {
259
- throw t = !1, this._$ET(), s;
260
- }
261
- t && this._$AE(e);
262
- }
263
- willUpdate(t) {
264
- }
265
- _$AE(t) {
266
- var e;
267
- (e = this._$E_) == null || e.forEach((i) => {
268
- var s;
269
- return (s = i.hostUpdated) == null ? void 0 : s.call(i);
270
- }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
271
- }
272
- _$ET() {
273
- this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
274
- }
275
- get updateComplete() {
276
- return this.getUpdateComplete();
277
- }
278
- getUpdateComplete() {
279
- return this._$Eg;
280
- }
281
- shouldUpdate(t) {
282
- return !0;
283
- }
284
- update(t) {
285
- this._$Ej && (this._$Ej = this._$Ej.forEach((e) => this._$EO(e, this[e]))), this._$ET();
286
- }
287
- updated(t) {
288
- }
289
- firstUpdated(t) {
290
- }
291
- };
292
- L.elementStyles = [], L.shadowRootOptions = { mode: "open" }, L[I("elementProperties")] = /* @__PURE__ */ new Map(), L[I("finalized")] = /* @__PURE__ */ new Map(), rt == null || rt({ ReactiveElement: L }), (E.reactiveElementVersions ?? (E.reactiveElementVersions = [])).push("2.0.2");
293
- /**
294
- * @license
295
- * Copyright 2017 Google LLC
296
- * SPDX-License-Identifier: BSD-3-Clause
297
- */
298
- const V = globalThis, Y = V.trustedTypes, Et = Y ? Y.createPolicy("lit-html", { createHTML: (r) => r }) : void 0, Xt = "$lit$", y = `lit$${(Math.random() + "").slice(9)}$`, Kt = "?" + y, ve = `<${Kt}>`, U = document, Q = () => U.createComment(""), B = (r) => r === null || typeof r != "object" && typeof r != "function", Jt = Array.isArray, ye = (r) => Jt(r) || typeof (r == null ? void 0 : r[Symbol.iterator]) == "function", nt = `[
299
- \f\r]`, M = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, St = /-->/g, bt = />/g, b = RegExp(`>|${nt}(?:([^\\s"'>=/]+)(${nt}*=${nt}*(?:[^
300
- \f\r"'\`<>=]|("|')|))|$)`, "g"), wt = /'/g, Pt = /"/g, Ft = /^(?:script|style|textarea|title)$/i, W = Symbol.for("lit-noChange"), _ = Symbol.for("lit-nothing"), Ct = /* @__PURE__ */ new WeakMap(), C = U.createTreeWalker(U, 129);
301
- function Gt(r, t) {
302
- if (!Array.isArray(r) || !r.hasOwnProperty("raw"))
303
- throw Error("invalid template strings array");
304
- return Et !== void 0 ? Et.createHTML(t) : t;
305
- }
306
- const Ae = (r, t) => {
307
- const e = r.length - 1, i = [];
308
- let s, n = t === 2 ? "<svg>" : "", o = M;
309
- for (let a = 0; a < e; a++) {
310
- const h = r[a];
311
- let c, d, l = -1, p = 0;
312
- for (; p < h.length && (o.lastIndex = p, d = o.exec(h), d !== null); )
313
- p = o.lastIndex, o === M ? d[1] === "!--" ? o = St : d[1] !== void 0 ? o = bt : d[2] !== void 0 ? (Ft.test(d[2]) && (s = RegExp("</" + d[2], "g")), o = b) : d[3] !== void 0 && (o = b) : o === b ? d[0] === ">" ? (o = s ?? M, l = -1) : d[1] === void 0 ? l = -2 : (l = o.lastIndex - d[2].length, c = d[1], o = d[3] === void 0 ? b : d[3] === '"' ? Pt : wt) : o === Pt || o === wt ? o = b : o === St || o === bt ? o = M : (o = b, s = void 0);
314
- const u = o === b && r[a + 1].startsWith("/>") ? " " : "";
315
- n += o === M ? h + ve : l >= 0 ? (i.push(c), h.slice(0, l) + Xt + h.slice(l) + y + u) : h + y + (l === -2 ? a : u);
316
- }
317
- return [Gt(r, n + (r[e] || "<?>") + (t === 2 ? "</svg>" : "")), i];
318
- };
319
- let pt = class Zt {
320
- constructor({ strings: t, _$litType$: e }, i) {
321
- let s;
322
- this.parts = [];
323
- let n = 0, o = 0;
324
- const a = t.length - 1, h = this.parts, [c, d] = Ae(t, e);
325
- if (this.el = Zt.createElement(c, i), C.currentNode = this.el.content, e === 2) {
326
- const l = this.el.content.firstChild;
327
- l.replaceWith(...l.childNodes);
328
- }
329
- for (; (s = C.nextNode()) !== null && h.length < a; ) {
330
- if (s.nodeType === 1) {
331
- if (s.hasAttributes())
332
- for (const l of s.getAttributeNames())
333
- if (l.endsWith(Xt)) {
334
- const p = d[o++], u = s.getAttribute(l).split(y), g = /([.?@])?(.*)/.exec(p);
335
- h.push({ type: 1, index: n, name: g[2], strings: u, ctor: g[1] === "." ? Se : g[1] === "?" ? be : g[1] === "@" ? we : it }), s.removeAttribute(l);
336
- } else
337
- l.startsWith(y) && (h.push({ type: 6, index: n }), s.removeAttribute(l));
338
- if (Ft.test(s.tagName)) {
339
- const l = s.textContent.split(y), p = l.length - 1;
340
- if (p > 0) {
341
- s.textContent = Y ? Y.emptyScript : "";
342
- for (let u = 0; u < p; u++)
343
- s.append(l[u], Q()), C.nextNode(), h.push({ type: 2, index: ++n });
344
- s.append(l[p], Q());
345
- }
346
- }
347
- } else if (s.nodeType === 8)
348
- if (s.data === Kt)
349
- h.push({ type: 2, index: n });
350
- else {
351
- let l = -1;
352
- for (; (l = s.data.indexOf(y, l + 1)) !== -1; )
353
- h.push({ type: 7, index: n }), l += y.length - 1;
354
- }
355
- n++;
356
- }
357
- }
358
- static createElement(t, e) {
359
- const i = U.createElement("template");
360
- return i.innerHTML = t, i;
361
- }
362
- };
363
- function H(r, t, e = r, i) {
364
- var o, a;
365
- if (t === W)
366
- return t;
367
- let s = i !== void 0 ? (o = e._$Co) == null ? void 0 : o[i] : e._$Cl;
368
- const n = B(t) ? void 0 : t._$litDirective$;
369
- return (s == null ? void 0 : s.constructor) !== n && ((a = s == null ? void 0 : s._$AO) == null || a.call(s, !1), n === void 0 ? s = void 0 : (s = new n(r), s._$AT(r, e, i)), i !== void 0 ? (e._$Co ?? (e._$Co = []))[i] = s : e._$Cl = s), s !== void 0 && (t = H(r, s._$AS(r, t.values), s, i)), t;
370
- }
371
- let Ee = class {
372
- constructor(t, e) {
373
- this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
374
- }
375
- get parentNode() {
376
- return this._$AM.parentNode;
377
- }
378
- get _$AU() {
379
- return this._$AM._$AU;
380
- }
381
- u(t) {
382
- const { el: { content: e }, parts: i } = this._$AD, s = ((t == null ? void 0 : t.creationScope) ?? U).importNode(e, !0);
383
- C.currentNode = s;
384
- let n = C.nextNode(), o = 0, a = 0, h = i[0];
385
- for (; h !== void 0; ) {
386
- if (o === h.index) {
387
- let c;
388
- h.type === 2 ? c = new Yt(n, n.nextSibling, this, t) : h.type === 1 ? c = new h.ctor(n, h.name, h.strings, this, t) : h.type === 6 && (c = new Pe(n, this, t)), this._$AV.push(c), h = i[++a];
389
- }
390
- o !== (h == null ? void 0 : h.index) && (n = C.nextNode(), o++);
391
- }
392
- return C.currentNode = U, s;
393
- }
394
- p(t) {
395
- let e = 0;
396
- for (const i of this._$AV)
397
- i !== void 0 && (i.strings !== void 0 ? (i._$AI(t, i, e), e += i.strings.length - 2) : i._$AI(t[e])), e++;
398
- }
399
- }, Yt = class Qt {
400
- get _$AU() {
401
- var t;
402
- return ((t = this._$AM) == null ? void 0 : t._$AU) ?? this._$Cv;
403
- }
404
- constructor(t, e, i, s) {
405
- this.type = 2, this._$AH = _, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = i, this.options = s, this._$Cv = (s == null ? void 0 : s.isConnected) ?? !0;
406
- }
407
- get parentNode() {
408
- let t = this._$AA.parentNode;
409
- const e = this._$AM;
410
- return e !== void 0 && (t == null ? void 0 : t.nodeType) === 11 && (t = e.parentNode), t;
411
- }
412
- get startNode() {
413
- return this._$AA;
414
- }
415
- get endNode() {
416
- return this._$AB;
417
- }
418
- _$AI(t, e = this) {
419
- t = H(this, t, e), B(t) ? t === _ || t == null || t === "" ? (this._$AH !== _ && this._$AR(), this._$AH = _) : t !== this._$AH && t !== W && this._(t) : t._$litType$ !== void 0 ? this.g(t) : t.nodeType !== void 0 ? this.$(t) : ye(t) ? this.T(t) : this._(t);
420
- }
421
- k(t) {
422
- return this._$AA.parentNode.insertBefore(t, this._$AB);
423
- }
424
- $(t) {
425
- this._$AH !== t && (this._$AR(), this._$AH = this.k(t));
426
- }
427
- _(t) {
428
- this._$AH !== _ && B(this._$AH) ? this._$AA.nextSibling.data = t : this.$(U.createTextNode(t)), this._$AH = t;
429
- }
430
- g(t) {
431
- var n;
432
- const { values: e, _$litType$: i } = t, s = typeof i == "number" ? this._$AC(t) : (i.el === void 0 && (i.el = pt.createElement(Gt(i.h, i.h[0]), this.options)), i);
433
- if (((n = this._$AH) == null ? void 0 : n._$AD) === s)
434
- this._$AH.p(e);
435
- else {
436
- const o = new Ee(s, this), a = o.u(this.options);
437
- o.p(e), this.$(a), this._$AH = o;
438
- }
439
- }
440
- _$AC(t) {
441
- let e = Ct.get(t.strings);
442
- return e === void 0 && Ct.set(t.strings, e = new pt(t)), e;
443
- }
444
- T(t) {
445
- Jt(this._$AH) || (this._$AH = [], this._$AR());
446
- const e = this._$AH;
447
- let i, s = 0;
448
- for (const n of t)
449
- s === e.length ? e.push(i = new Qt(this.k(Q()), this.k(Q()), this, this.options)) : i = e[s], i._$AI(n), s++;
450
- s < e.length && (this._$AR(i && i._$AB.nextSibling, s), e.length = s);
451
- }
452
- _$AR(t = this._$AA.nextSibling, e) {
453
- var i;
454
- for ((i = this._$AP) == null ? void 0 : i.call(this, !1, !0, e); t && t !== this._$AB; ) {
455
- const s = t.nextSibling;
456
- t.remove(), t = s;
457
- }
458
- }
459
- setConnected(t) {
460
- var e;
461
- this._$AM === void 0 && (this._$Cv = t, (e = this._$AP) == null || e.call(this, t));
462
- }
463
- }, it = class {
464
- get tagName() {
465
- return this.element.tagName;
466
- }
467
- get _$AU() {
468
- return this._$AM._$AU;
469
- }
470
- constructor(t, e, i, s, n) {
471
- this.type = 1, this._$AH = _, this._$AN = void 0, this.element = t, this.name = e, this._$AM = s, this.options = n, i.length > 2 || i[0] !== "" || i[1] !== "" ? (this._$AH = Array(i.length - 1).fill(new String()), this.strings = i) : this._$AH = _;
472
- }
473
- _$AI(t, e = this, i, s) {
474
- const n = this.strings;
475
- let o = !1;
476
- if (n === void 0)
477
- t = H(this, t, e, 0), o = !B(t) || t !== this._$AH && t !== W, o && (this._$AH = t);
478
- else {
479
- const a = t;
480
- let h, c;
481
- for (t = n[0], h = 0; h < n.length - 1; h++)
482
- c = H(this, a[i + h], e, h), c === W && (c = this._$AH[h]), o || (o = !B(c) || c !== this._$AH[h]), c === _ ? t = _ : t !== _ && (t += (c ?? "") + n[h + 1]), this._$AH[h] = c;
483
- }
484
- o && !s && this.O(t);
485
- }
486
- O(t) {
487
- t === _ ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
488
- }
489
- }, Se = class extends it {
490
- constructor() {
491
- super(...arguments), this.type = 3;
492
- }
493
- O(t) {
494
- this.element[this.name] = t === _ ? void 0 : t;
495
- }
496
- }, be = class extends it {
497
- constructor() {
498
- super(...arguments), this.type = 4;
499
- }
500
- O(t) {
501
- this.element.toggleAttribute(this.name, !!t && t !== _);
502
- }
503
- }, we = class extends it {
504
- constructor(t, e, i, s, n) {
505
- super(t, e, i, s, n), this.type = 5;
506
- }
507
- _$AI(t, e = this) {
508
- if ((t = H(this, t, e, 0) ?? _) === W)
509
- return;
510
- const i = this._$AH, s = t === _ && i !== _ || t.capture !== i.capture || t.once !== i.once || t.passive !== i.passive, n = t !== _ && (i === _ || s);
511
- s && this.element.removeEventListener(this.name, this, i), n && this.element.addEventListener(this.name, this, t), this._$AH = t;
512
- }
513
- handleEvent(t) {
514
- var e;
515
- typeof this._$AH == "function" ? this._$AH.call(((e = this.options) == null ? void 0 : e.host) ?? this.element, t) : this._$AH.handleEvent(t);
516
- }
517
- }, Pe = class {
518
- constructor(t, e, i) {
519
- this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = i;
520
- }
521
- get _$AU() {
522
- return this._$AM._$AU;
523
- }
524
- _$AI(t) {
525
- H(this, t);
526
- }
527
- };
528
- const ot = V.litHtmlPolyfillSupport;
529
- ot == null || ot(pt, Yt), (V.litHtmlVersions ?? (V.litHtmlVersions = [])).push("3.1.0");
530
- /**
531
- * @license
532
- * Copyright 2019 Google LLC
533
- * SPDX-License-Identifier: BSD-3-Clause
534
- */
535
- const Z = globalThis, $t = Z.ShadowRoot && (Z.ShadyCSS === void 0 || Z.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, te = Symbol(), Tt = /* @__PURE__ */ new WeakMap();
536
- let Ce = class {
537
- constructor(t, e, i) {
538
- if (this._$cssResult$ = !0, i !== te)
539
- throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
540
- this.cssText = t, this.t = e;
541
- }
542
- get styleSheet() {
543
- let t = this.o;
544
- const e = this.t;
545
- if ($t && t === void 0) {
546
- const i = e !== void 0 && e.length === 1;
547
- i && (t = Tt.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), i && Tt.set(e, t));
548
- }
549
- return t;
550
- }
551
- toString() {
552
- return this.cssText;
553
- }
554
- };
555
- const Te = (r) => new Ce(typeof r == "string" ? r : r + "", void 0, te), Ue = (r, t) => {
556
- if ($t)
557
- r.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
558
- else
559
- for (const e of t) {
560
- const i = document.createElement("style"), s = Z.litNonce;
561
- s !== void 0 && i.setAttribute("nonce", s), i.textContent = e.cssText, r.appendChild(i);
562
- }
563
- }, Ut = $t ? (r) => r : (r) => r instanceof CSSStyleSheet ? ((t) => {
564
- let e = "";
565
- for (const i of t.cssRules)
566
- e += i.cssText;
567
- return Te(e);
568
- })(r) : r;
569
- /**
570
- * @license
571
- * Copyright 2017 Google LLC
572
- * SPDX-License-Identifier: BSD-3-Clause
573
- */
574
- const { is: Re, defineProperty: xe, getOwnPropertyDescriptor: He, getOwnPropertyNames: Oe, getOwnPropertySymbols: Ne, getPrototypeOf: Le } = Object, S = globalThis, Rt = S.trustedTypes, Me = Rt ? Rt.emptyScript : "", ht = S.reactiveElementPolyfillSupport, D = (r, t) => r, ut = { toAttribute(r, t) {
575
- switch (t) {
576
- case Boolean:
577
- r = r ? Me : null;
578
- break;
579
- case Object:
580
- case Array:
581
- r = r == null ? r : JSON.stringify(r);
582
- }
583
- return r;
584
- }, fromAttribute(r, t) {
585
- let e = r;
586
- switch (t) {
587
- case Boolean:
588
- e = r !== null;
589
- break;
590
- case Number:
591
- e = r === null ? null : Number(r);
592
- break;
593
- case Object:
594
- case Array:
595
- try {
596
- e = JSON.parse(r);
597
- } catch {
598
- e = null;
599
- }
600
- }
601
- return e;
602
- } }, ee = (r, t) => !Re(r, t), xt = { attribute: !0, type: String, converter: ut, reflect: !1, hasChanged: ee };
603
- Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), S.litPropertyMetadata ?? (S.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
604
- class x extends HTMLElement {
605
- static addInitializer(t) {
606
- this._$Ei(), (this.l ?? (this.l = [])).push(t);
607
- }
608
- static get observedAttributes() {
609
- return this.finalize(), this._$Eh && [...this._$Eh.keys()];
610
- }
611
- static createProperty(t, e = xt) {
612
- if (e.state && (e.attribute = !1), this._$Ei(), this.elementProperties.set(t, e), !e.noAccessor) {
613
- const i = Symbol(), s = this.getPropertyDescriptor(t, i, e);
614
- s !== void 0 && xe(this.prototype, t, s);
615
- }
616
- }
617
- static getPropertyDescriptor(t, e, i) {
618
- const { get: s, set: n } = He(this.prototype, t) ?? { get() {
619
- return this[e];
620
- }, set(o) {
621
- this[e] = o;
622
- } };
623
- return { get() {
624
- return s == null ? void 0 : s.call(this);
625
- }, set(o) {
626
- const a = s == null ? void 0 : s.call(this);
627
- n.call(this, o), this.requestUpdate(t, a, i);
628
- }, configurable: !0, enumerable: !0 };
629
- }
630
- static getPropertyOptions(t) {
631
- return this.elementProperties.get(t) ?? xt;
632
- }
633
- static _$Ei() {
634
- if (this.hasOwnProperty(D("elementProperties")))
635
- return;
636
- const t = Le(this);
637
- t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
638
- }
639
- static finalize() {
640
- if (this.hasOwnProperty(D("finalized")))
641
- return;
642
- if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(D("properties"))) {
643
- const e = this.properties, i = [...Oe(e), ...Ne(e)];
644
- for (const s of i)
645
- this.createProperty(s, e[s]);
646
- }
647
- const t = this[Symbol.metadata];
648
- if (t !== null) {
649
- const e = litPropertyMetadata.get(t);
650
- if (e !== void 0)
651
- for (const [i, s] of e)
652
- this.elementProperties.set(i, s);
653
- }
654
- this._$Eh = /* @__PURE__ */ new Map();
655
- for (const [e, i] of this.elementProperties) {
656
- const s = this._$Eu(e, i);
657
- s !== void 0 && this._$Eh.set(s, e);
658
- }
659
- this.elementStyles = this.finalizeStyles(this.styles);
660
- }
661
- static finalizeStyles(t) {
662
- const e = [];
663
- if (Array.isArray(t)) {
664
- const i = new Set(t.flat(1 / 0).reverse());
665
- for (const s of i)
666
- e.unshift(Ut(s));
667
- } else
668
- t !== void 0 && e.push(Ut(t));
669
- return e;
670
- }
671
- static _$Eu(t, e) {
672
- const i = e.attribute;
673
- return i === !1 ? void 0 : typeof i == "string" ? i : typeof t == "string" ? t.toLowerCase() : void 0;
674
- }
675
- constructor() {
676
- super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
677
- }
678
- _$Ev() {
679
- var t;
680
- this._$Eg = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$ES(), this.requestUpdate(), (t = this.constructor.l) == null || t.forEach((e) => e(this));
681
- }
682
- addController(t) {
683
- var e;
684
- (this._$E_ ?? (this._$E_ = /* @__PURE__ */ new Set())).add(t), this.renderRoot !== void 0 && this.isConnected && ((e = t.hostConnected) == null || e.call(t));
685
- }
686
- removeController(t) {
687
- var e;
688
- (e = this._$E_) == null || e.delete(t);
689
- }
690
- _$ES() {
691
- const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
692
- for (const i of e.keys())
693
- this.hasOwnProperty(i) && (t.set(i, this[i]), delete this[i]);
694
- t.size > 0 && (this._$Ep = t);
695
- }
696
- createRenderRoot() {
697
- const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
698
- return Ue(t, this.constructor.elementStyles), t;
699
- }
700
- connectedCallback() {
701
- var t;
702
- this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$E_) == null || t.forEach((e) => {
703
- var i;
704
- return (i = e.hostConnected) == null ? void 0 : i.call(e);
705
- });
706
- }
707
- enableUpdating(t) {
708
- }
709
- disconnectedCallback() {
710
- var t;
711
- (t = this._$E_) == null || t.forEach((e) => {
712
- var i;
713
- return (i = e.hostDisconnected) == null ? void 0 : i.call(e);
714
- });
715
- }
716
- attributeChangedCallback(t, e, i) {
717
- this._$AK(t, i);
718
- }
719
- _$EO(t, e) {
720
- var n;
721
- const i = this.constructor.elementProperties.get(t), s = this.constructor._$Eu(t, i);
722
- if (s !== void 0 && i.reflect === !0) {
723
- const o = (((n = i.converter) == null ? void 0 : n.toAttribute) !== void 0 ? i.converter : ut).toAttribute(e, i.type);
724
- this._$Em = t, o == null ? this.removeAttribute(s) : this.setAttribute(s, o), this._$Em = null;
725
- }
726
- }
727
- _$AK(t, e) {
728
- var n;
729
- const i = this.constructor, s = i._$Eh.get(t);
730
- if (s !== void 0 && this._$Em !== s) {
731
- const o = i.getPropertyOptions(s), a = typeof o.converter == "function" ? { fromAttribute: o.converter } : ((n = o.converter) == null ? void 0 : n.fromAttribute) !== void 0 ? o.converter : ut;
732
- this._$Em = s, this[s] = a.fromAttribute(e, o.type), this._$Em = null;
733
- }
734
- }
735
- requestUpdate(t, e, i, s = !1, n) {
736
- if (t !== void 0) {
737
- if (i ?? (i = this.constructor.getPropertyOptions(t)), !(i.hasChanged ?? ee)(s ? n : this[t], e))
738
- return;
739
- this.C(t, e, i);
740
- }
741
- this.isUpdatePending === !1 && (this._$Eg = this._$EP());
742
- }
743
- C(t, e, i) {
744
- this._$AL.has(t) || this._$AL.set(t, e), i.reflect === !0 && this._$Em !== t && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(t);
745
- }
746
- async _$EP() {
747
- this.isUpdatePending = !0;
748
- try {
749
- await this._$Eg;
750
- } catch (e) {
751
- Promise.reject(e);
752
- }
753
- const t = this.scheduleUpdate();
754
- return t != null && await t, !this.isUpdatePending;
755
- }
756
- scheduleUpdate() {
757
- return this.performUpdate();
758
- }
759
- performUpdate() {
760
- var i;
761
- if (!this.isUpdatePending)
762
- return;
763
- if (!this.hasUpdated) {
764
- if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
765
- for (const [n, o] of this._$Ep)
766
- this[n] = o;
767
- this._$Ep = void 0;
768
- }
769
- const s = this.constructor.elementProperties;
770
- if (s.size > 0)
771
- for (const [n, o] of s)
772
- o.wrapped !== !0 || this._$AL.has(n) || this[n] === void 0 || this.C(n, this[n], o);
773
- }
774
- let t = !1;
775
- const e = this._$AL;
776
- try {
777
- t = this.shouldUpdate(e), t ? (this.willUpdate(e), (i = this._$E_) == null || i.forEach((s) => {
778
- var n;
779
- return (n = s.hostUpdate) == null ? void 0 : n.call(s);
780
- }), this.update(e)) : this._$ET();
781
- } catch (s) {
782
- throw t = !1, this._$ET(), s;
783
- }
784
- t && this._$AE(e);
785
- }
786
- willUpdate(t) {
787
- }
788
- _$AE(t) {
789
- var e;
790
- (e = this._$E_) == null || e.forEach((i) => {
791
- var s;
792
- return (s = i.hostUpdated) == null ? void 0 : s.call(i);
793
- }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
794
- }
795
- _$ET() {
796
- this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
797
- }
798
- get updateComplete() {
799
- return this.getUpdateComplete();
800
- }
801
- getUpdateComplete() {
802
- return this._$Eg;
803
- }
804
- shouldUpdate(t) {
805
- return !0;
806
- }
807
- update(t) {
808
- this._$Ej && (this._$Ej = this._$Ej.forEach((e) => this._$EO(e, this[e]))), this._$ET();
809
- }
810
- updated(t) {
811
- }
812
- firstUpdated(t) {
813
- }
814
- }
815
- x.elementStyles = [], x.shadowRootOptions = { mode: "open" }, x[D("elementProperties")] = /* @__PURE__ */ new Map(), x[D("finalized")] = /* @__PURE__ */ new Map(), ht == null || ht({ ReactiveElement: x }), (S.reactiveElementVersions ?? (S.reactiveElementVersions = [])).push("2.0.2");
816
- /**
817
- * @license
818
- * Copyright 2017 Google LLC
819
- * SPDX-License-Identifier: BSD-3-Clause
820
- */
821
- const z = globalThis, tt = z.trustedTypes, Ht = tt ? tt.createPolicy("lit-html", { createHTML: (r) => r }) : void 0, ie = "$lit$", A = `lit$${(Math.random() + "").slice(9)}$`, se = "?" + A, ke = `<${se}>`, R = document, q = () => R.createComment(""), X = (r) => r === null || typeof r != "object" && typeof r != "function", re = Array.isArray, Ie = (r) => re(r) || typeof (r == null ? void 0 : r[Symbol.iterator]) == "function", at = `[
822
- \f\r]`, k = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, Ot = /-->/g, Nt = />/g, w = RegExp(`>|${at}(?:([^\\s"'>=/]+)(${at}*=${at}*(?:[^
823
- \f\r"'\`<>=]|("|')|))|$)`, "g"), Lt = /'/g, Mt = /"/g, ne = /^(?:script|style|textarea|title)$/i, Ve = (r) => (t, ...e) => ({ _$litType$: r, strings: t, values: e }), De = Ve(1), O = Symbol.for("lit-noChange"), $ = Symbol.for("lit-nothing"), kt = /* @__PURE__ */ new WeakMap(), T = R.createTreeWalker(R, 129);
824
- function oe(r, t) {
825
- if (!Array.isArray(r) || !r.hasOwnProperty("raw"))
826
- throw Error("invalid template strings array");
827
- return Ht !== void 0 ? Ht.createHTML(t) : t;
828
- }
829
- const ze = (r, t) => {
830
- const e = r.length - 1, i = [];
831
- let s, n = t === 2 ? "<svg>" : "", o = k;
832
- for (let a = 0; a < e; a++) {
833
- const h = r[a];
834
- let c, d, l = -1, p = 0;
835
- for (; p < h.length && (o.lastIndex = p, d = o.exec(h), d !== null); )
836
- p = o.lastIndex, o === k ? d[1] === "!--" ? o = Ot : d[1] !== void 0 ? o = Nt : d[2] !== void 0 ? (ne.test(d[2]) && (s = RegExp("</" + d[2], "g")), o = w) : d[3] !== void 0 && (o = w) : o === w ? d[0] === ">" ? (o = s ?? k, l = -1) : d[1] === void 0 ? l = -2 : (l = o.lastIndex - d[2].length, c = d[1], o = d[3] === void 0 ? w : d[3] === '"' ? Mt : Lt) : o === Mt || o === Lt ? o = w : o === Ot || o === Nt ? o = k : (o = w, s = void 0);
837
- const u = o === w && r[a + 1].startsWith("/>") ? " " : "";
838
- n += o === k ? h + ke : l >= 0 ? (i.push(c), h.slice(0, l) + ie + h.slice(l) + A + u) : h + A + (l === -2 ? a : u);
839
- }
840
- return [oe(r, n + (r[e] || "<?>") + (t === 2 ? "</svg>" : "")), i];
841
- };
842
- class K {
843
- constructor({ strings: t, _$litType$: e }, i) {
844
- let s;
845
- this.parts = [];
846
- let n = 0, o = 0;
847
- const a = t.length - 1, h = this.parts, [c, d] = ze(t, e);
848
- if (this.el = K.createElement(c, i), T.currentNode = this.el.content, e === 2) {
849
- const l = this.el.content.firstChild;
850
- l.replaceWith(...l.childNodes);
851
- }
852
- for (; (s = T.nextNode()) !== null && h.length < a; ) {
853
- if (s.nodeType === 1) {
854
- if (s.hasAttributes())
855
- for (const l of s.getAttributeNames())
856
- if (l.endsWith(ie)) {
857
- const p = d[o++], u = s.getAttribute(l).split(A), g = /([.?@])?(.*)/.exec(p);
858
- h.push({ type: 1, index: n, name: g[2], strings: u, ctor: g[1] === "." ? Be : g[1] === "?" ? We : g[1] === "@" ? qe : st }), s.removeAttribute(l);
859
- } else
860
- l.startsWith(A) && (h.push({ type: 6, index: n }), s.removeAttribute(l));
861
- if (ne.test(s.tagName)) {
862
- const l = s.textContent.split(A), p = l.length - 1;
863
- if (p > 0) {
864
- s.textContent = tt ? tt.emptyScript : "";
865
- for (let u = 0; u < p; u++)
866
- s.append(l[u], q()), T.nextNode(), h.push({ type: 2, index: ++n });
867
- s.append(l[p], q());
868
- }
869
- }
870
- } else if (s.nodeType === 8)
871
- if (s.data === se)
872
- h.push({ type: 2, index: n });
873
- else {
874
- let l = -1;
875
- for (; (l = s.data.indexOf(A, l + 1)) !== -1; )
876
- h.push({ type: 7, index: n }), l += A.length - 1;
877
- }
878
- n++;
879
- }
880
- }
881
- static createElement(t, e) {
882
- const i = R.createElement("template");
883
- return i.innerHTML = t, i;
884
- }
885
- }
886
- function N(r, t, e = r, i) {
887
- var o, a;
888
- if (t === O)
889
- return t;
890
- let s = i !== void 0 ? (o = e._$Co) == null ? void 0 : o[i] : e._$Cl;
891
- const n = X(t) ? void 0 : t._$litDirective$;
892
- return (s == null ? void 0 : s.constructor) !== n && ((a = s == null ? void 0 : s._$AO) == null || a.call(s, !1), n === void 0 ? s = void 0 : (s = new n(r), s._$AT(r, e, i)), i !== void 0 ? (e._$Co ?? (e._$Co = []))[i] = s : e._$Cl = s), s !== void 0 && (t = N(r, s._$AS(r, t.values), s, i)), t;
893
- }
894
- class je {
895
- constructor(t, e) {
896
- this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
897
- }
898
- get parentNode() {
899
- return this._$AM.parentNode;
900
- }
901
- get _$AU() {
902
- return this._$AM._$AU;
903
- }
904
- u(t) {
905
- const { el: { content: e }, parts: i } = this._$AD, s = ((t == null ? void 0 : t.creationScope) ?? R).importNode(e, !0);
906
- T.currentNode = s;
907
- let n = T.nextNode(), o = 0, a = 0, h = i[0];
908
- for (; h !== void 0; ) {
909
- if (o === h.index) {
910
- let c;
911
- h.type === 2 ? c = new J(n, n.nextSibling, this, t) : h.type === 1 ? c = new h.ctor(n, h.name, h.strings, this, t) : h.type === 6 && (c = new Xe(n, this, t)), this._$AV.push(c), h = i[++a];
912
- }
913
- o !== (h == null ? void 0 : h.index) && (n = T.nextNode(), o++);
914
- }
915
- return T.currentNode = R, s;
916
- }
917
- p(t) {
918
- let e = 0;
919
- for (const i of this._$AV)
920
- i !== void 0 && (i.strings !== void 0 ? (i._$AI(t, i, e), e += i.strings.length - 2) : i._$AI(t[e])), e++;
921
- }
922
- }
923
- class J {
924
- get _$AU() {
925
- var t;
926
- return ((t = this._$AM) == null ? void 0 : t._$AU) ?? this._$Cv;
927
- }
928
- constructor(t, e, i, s) {
929
- this.type = 2, this._$AH = $, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = i, this.options = s, this._$Cv = (s == null ? void 0 : s.isConnected) ?? !0;
930
- }
931
- get parentNode() {
932
- let t = this._$AA.parentNode;
933
- const e = this._$AM;
934
- return e !== void 0 && (t == null ? void 0 : t.nodeType) === 11 && (t = e.parentNode), t;
935
- }
936
- get startNode() {
937
- return this._$AA;
938
- }
939
- get endNode() {
940
- return this._$AB;
941
- }
942
- _$AI(t, e = this) {
943
- t = N(this, t, e), X(t) ? t === $ || t == null || t === "" ? (this._$AH !== $ && this._$AR(), this._$AH = $) : t !== this._$AH && t !== O && this._(t) : t._$litType$ !== void 0 ? this.g(t) : t.nodeType !== void 0 ? this.$(t) : Ie(t) ? this.T(t) : this._(t);
944
- }
945
- k(t) {
946
- return this._$AA.parentNode.insertBefore(t, this._$AB);
947
- }
948
- $(t) {
949
- this._$AH !== t && (this._$AR(), this._$AH = this.k(t));
950
- }
951
- _(t) {
952
- this._$AH !== $ && X(this._$AH) ? this._$AA.nextSibling.data = t : this.$(R.createTextNode(t)), this._$AH = t;
953
- }
954
- g(t) {
955
- var n;
956
- const { values: e, _$litType$: i } = t, s = typeof i == "number" ? this._$AC(t) : (i.el === void 0 && (i.el = K.createElement(oe(i.h, i.h[0]), this.options)), i);
957
- if (((n = this._$AH) == null ? void 0 : n._$AD) === s)
958
- this._$AH.p(e);
959
- else {
960
- const o = new je(s, this), a = o.u(this.options);
961
- o.p(e), this.$(a), this._$AH = o;
962
- }
963
- }
964
- _$AC(t) {
965
- let e = kt.get(t.strings);
966
- return e === void 0 && kt.set(t.strings, e = new K(t)), e;
967
- }
968
- T(t) {
969
- re(this._$AH) || (this._$AH = [], this._$AR());
970
- const e = this._$AH;
971
- let i, s = 0;
972
- for (const n of t)
973
- s === e.length ? e.push(i = new J(this.k(q()), this.k(q()), this, this.options)) : i = e[s], i._$AI(n), s++;
974
- s < e.length && (this._$AR(i && i._$AB.nextSibling, s), e.length = s);
975
- }
976
- _$AR(t = this._$AA.nextSibling, e) {
977
- var i;
978
- for ((i = this._$AP) == null ? void 0 : i.call(this, !1, !0, e); t && t !== this._$AB; ) {
979
- const s = t.nextSibling;
980
- t.remove(), t = s;
981
- }
982
- }
983
- setConnected(t) {
984
- var e;
985
- this._$AM === void 0 && (this._$Cv = t, (e = this._$AP) == null || e.call(this, t));
986
- }
987
- }
988
- class st {
989
- get tagName() {
990
- return this.element.tagName;
991
- }
992
- get _$AU() {
993
- return this._$AM._$AU;
994
- }
995
- constructor(t, e, i, s, n) {
996
- this.type = 1, this._$AH = $, this._$AN = void 0, this.element = t, this.name = e, this._$AM = s, this.options = n, i.length > 2 || i[0] !== "" || i[1] !== "" ? (this._$AH = Array(i.length - 1).fill(new String()), this.strings = i) : this._$AH = $;
997
- }
998
- _$AI(t, e = this, i, s) {
999
- const n = this.strings;
1000
- let o = !1;
1001
- if (n === void 0)
1002
- t = N(this, t, e, 0), o = !X(t) || t !== this._$AH && t !== O, o && (this._$AH = t);
1003
- else {
1004
- const a = t;
1005
- let h, c;
1006
- for (t = n[0], h = 0; h < n.length - 1; h++)
1007
- c = N(this, a[i + h], e, h), c === O && (c = this._$AH[h]), o || (o = !X(c) || c !== this._$AH[h]), c === $ ? t = $ : t !== $ && (t += (c ?? "") + n[h + 1]), this._$AH[h] = c;
1008
- }
1009
- o && !s && this.O(t);
1010
- }
1011
- O(t) {
1012
- t === $ ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
1013
- }
1014
- }
1015
- class Be extends st {
1016
- constructor() {
1017
- super(...arguments), this.type = 3;
1018
- }
1019
- O(t) {
1020
- this.element[this.name] = t === $ ? void 0 : t;
1021
- }
1022
- }
1023
- class We extends st {
1024
- constructor() {
1025
- super(...arguments), this.type = 4;
1026
- }
1027
- O(t) {
1028
- this.element.toggleAttribute(this.name, !!t && t !== $);
1029
- }
1030
- }
1031
- class qe extends st {
1032
- constructor(t, e, i, s, n) {
1033
- super(t, e, i, s, n), this.type = 5;
1034
- }
1035
- _$AI(t, e = this) {
1036
- if ((t = N(this, t, e, 0) ?? $) === O)
1037
- return;
1038
- const i = this._$AH, s = t === $ && i !== $ || t.capture !== i.capture || t.once !== i.once || t.passive !== i.passive, n = t !== $ && (i === $ || s);
1039
- s && this.element.removeEventListener(this.name, this, i), n && this.element.addEventListener(this.name, this, t), this._$AH = t;
1040
- }
1041
- handleEvent(t) {
1042
- var e;
1043
- typeof this._$AH == "function" ? this._$AH.call(((e = this.options) == null ? void 0 : e.host) ?? this.element, t) : this._$AH.handleEvent(t);
1044
- }
1045
- }
1046
- class Xe {
1047
- constructor(t, e, i) {
1048
- this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = i;
1049
- }
1050
- get _$AU() {
1051
- return this._$AM._$AU;
1052
- }
1053
- _$AI(t) {
1054
- N(this, t);
1055
- }
1056
- }
1057
- const lt = z.litHtmlPolyfillSupport;
1058
- lt == null || lt(K, J), (z.litHtmlVersions ?? (z.litHtmlVersions = [])).push("3.1.0");
1059
- const Ke = (r, t, e) => {
1060
- const i = (e == null ? void 0 : e.renderBefore) ?? t;
1061
- let s = i._$litPart$;
1062
- if (s === void 0) {
1063
- const n = (e == null ? void 0 : e.renderBefore) ?? null;
1064
- i._$litPart$ = s = new J(t.insertBefore(q(), n), n, void 0, e ?? {});
1065
- }
1066
- return s._$AI(r), s;
1067
- };
1068
- /**
1069
- * @license
1070
- * Copyright 2017 Google LLC
1071
- * SPDX-License-Identifier: BSD-3-Clause
1072
- */
1073
- class j extends x {
1074
- constructor() {
1075
- super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
1076
- }
1077
- createRenderRoot() {
1078
- var e;
1079
- const t = super.createRenderRoot();
1080
- return (e = this.renderOptions).renderBefore ?? (e.renderBefore = t.firstChild), t;
1081
- }
1082
- update(t) {
1083
- const e = this.render();
1084
- this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = Ke(e, this.renderRoot, this.renderOptions);
1085
- }
1086
- connectedCallback() {
1087
- var t;
1088
- super.connectedCallback(), (t = this._$Do) == null || t.setConnected(!0);
1089
- }
1090
- disconnectedCallback() {
1091
- var t;
1092
- super.disconnectedCallback(), (t = this._$Do) == null || t.setConnected(!1);
1093
- }
1094
- render() {
1095
- return O;
1096
- }
1097
- }
1098
- var Dt;
1099
- j._$litElement$ = !0, j.finalized = !0, (Dt = globalThis.litElementHydrateSupport) == null || Dt.call(globalThis, { LitElement: j });
1100
- const ct = globalThis.litElementPolyfillSupport;
1101
- ct == null || ct({ LitElement: j });
1102
- (globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.0.2");
1103
- function Je(r, t, e) {
1104
- function i(s) {
1105
- e.dispatchEvent(new CustomEvent(s.type, s));
1106
- }
1107
- return t.addEventListener(r, i), () => {
1108
- t.removeEventListener(r, i);
9
+ import { styleMap } from "lit/directives/style-map.js";
10
+ import { classMap } from "lit/directives/class-map.js";
11
+ import "@a11y/focus-trap";
12
+ function forwardEvent(type, fromElement, toElement) {
13
+ function forwarder(event) {
14
+ toElement.dispatchEvent(new CustomEvent(event.type, event));
15
+ }
16
+ fromElement.addEventListener(type, forwarder);
17
+ return () => {
18
+ fromElement.removeEventListener(type, forwarder);
1109
19
  };
1110
20
  }
1111
- class Fe {
1112
- constructor(t, e) {
1113
- this._events = [], this._cleanup = [], this._forwardElementRef = jt(), this.host = t, this._events = e, t.addController(this);
21
+ class EventForwardController {
22
+ constructor(host, events) {
23
+ this._events = [];
24
+ this._cleanup = [];
25
+ this._forwardElementRef = createRef();
26
+ this.host = host;
27
+ this._events = events;
28
+ host.addController(this);
1114
29
  }
1115
30
  register() {
1116
- return Bt(this._forwardElementRef);
31
+ return ref(this._forwardElementRef);
1117
32
  }
1118
33
  hostConnected() {
1119
34
  requestAnimationFrame(() => {
1120
- this._events.forEach((t) => {
1121
- this._forwardElementRef.value && this._cleanup.push(Je(t, this._forwardElementRef.value, this.host));
35
+ this._events.forEach((event) => {
36
+ if (this._forwardElementRef.value) {
37
+ this._cleanup.push(forwardEvent(event, this._forwardElementRef.value, this.host));
38
+ }
1122
39
  });
1123
40
  });
1124
41
  }
1125
42
  hostDisconnected() {
1126
- this._cleanup.forEach((t) => {
1127
- t();
1128
- }), this._cleanup = [];
43
+ this._cleanup.forEach((fn) => {
44
+ fn();
45
+ });
46
+ this._cleanup = [];
1129
47
  }
1130
48
  }
1131
- const It = "https://d2rxhdlm2q91uk.cloudfront.net", Ge = "https://d1ix11aj5kfygl.cloudfront.net", Ze = "https://d157jlwnudd93d.cloudfront.net", Vt = "https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev", Ye = "https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging", Qe = "https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod", ti = "http://localhost:6060/v2", ei = "https://embed-dev.vouchfor.com/v2", ii = "https://embed-staging.vouchfor.com/v2", si = "https://embed.vouchfor.com/v2";
1132
- function et(r) {
1133
- if (!["local", "dev", "staging", "prod"].includes(r))
1134
- throw new Error(`Unknown environment: ${r}`);
1135
- if (r === "local")
49
+ const devVideoUrl = "https://d2rxhdlm2q91uk.cloudfront.net";
50
+ const stagingVideoUrl = "https://d1ix11aj5kfygl.cloudfront.net";
51
+ const prodVideoUrl = "https://d157jlwnudd93d.cloudfront.net";
52
+ const devPublicApiUrl = "https://bshyfw4h5a.execute-api.ap-southeast-2.amazonaws.com/dev";
53
+ const stagingPublicApiUrl = "https://gyzw7rpbq3.execute-api.ap-southeast-2.amazonaws.com/staging";
54
+ const prodPublicApiUrl = "https://vfcjuim1l3.execute-api.ap-southeast-2.amazonaws.com/prod";
55
+ const localEmbedApiUrl = "http://localhost:6060/v2";
56
+ const devEmbedApiUrl = "https://embed-dev.vouchfor.com/v2";
57
+ const stagingEmbedApiUrl = "https://embed-staging.vouchfor.com/v2";
58
+ const prodEmbedApiUrl = "https://embed.vouchfor.com/v2";
59
+ function getEnvUrls(env) {
60
+ if (!["local", "dev", "staging", "prod"].includes(env)) {
61
+ throw new Error(`Unknown environment: ${env}`);
62
+ }
63
+ if (env === "local") {
1136
64
  return {
1137
- videoUrl: It,
1138
- publicApiUrl: Vt,
1139
- embedApiUrl: ti
65
+ videoUrl: devVideoUrl,
66
+ publicApiUrl: devPublicApiUrl,
67
+ embedApiUrl: localEmbedApiUrl
1140
68
  };
1141
- if (r === "dev")
69
+ }
70
+ if (env === "dev") {
1142
71
  return {
1143
- videoUrl: It,
1144
- publicApiUrl: Vt,
1145
- embedApiUrl: ei
72
+ videoUrl: devVideoUrl,
73
+ publicApiUrl: devPublicApiUrl,
74
+ embedApiUrl: devEmbedApiUrl
1146
75
  };
1147
- if (r === "staging")
76
+ }
77
+ if (env === "staging") {
1148
78
  return {
1149
- videoUrl: Ge,
1150
- publicApiUrl: Ye,
1151
- embedApiUrl: ii
79
+ videoUrl: stagingVideoUrl,
80
+ publicApiUrl: stagingPublicApiUrl,
81
+ embedApiUrl: stagingEmbedApiUrl
1152
82
  };
1153
- if (r === "prod")
83
+ }
84
+ if (env === "prod") {
1154
85
  return {
1155
- videoUrl: Ze,
1156
- publicApiUrl: Qe,
1157
- embedApiUrl: si
86
+ videoUrl: prodVideoUrl,
87
+ publicApiUrl: prodPublicApiUrl,
88
+ embedApiUrl: prodEmbedApiUrl
1158
89
  };
90
+ }
1159
91
  }
1160
- class ri {
1161
- constructor(t) {
1162
- this._fetching = !1, this.getVouch = async (e, i, s) => {
1163
- var d;
1164
- const { embedApiUrl: n } = et(e), o = P(), a = await fetch(`${n}/vouches/${s}`, {
1165
- method: "GET",
1166
- headers: [
1167
- ["X-Api-Key", i],
1168
- ["X-Cache-Check", o]
1169
- ]
1170
- }), h = await a.json();
1171
- this.host.dispatchEvent(new CustomEvent("vouch:loaded", { detail: s }));
1172
- const c = (d = a == null ? void 0 : a.headers) == null ? void 0 : d.get("X-Cache-Check");
1173
- return c && c !== o && fetch(`${n}/vouches/${s}`, {
1174
- method: "GET",
1175
- headers: [
1176
- ["X-Api-Key", i],
1177
- ["Cache-Control", "max-age=0"]
1178
- ]
1179
- }), h;
1180
- }, this.getTemplate = async (e, i, s) => {
1181
- var d;
1182
- const { embedApiUrl: n } = et(e), o = P(), a = await fetch(`${n}/templates/${s}`, {
92
+ class FetcherController {
93
+ constructor(host) {
94
+ this._fetching = false;
95
+ this.getVouch = async (env, apiKey, vouchId) => {
96
+ var _a;
97
+ const { embedApiUrl } = getEnvUrls(env);
98
+ const cacheCheck = v4();
99
+ const res = await fetch(`${embedApiUrl}/vouches/${vouchId}`, {
1183
100
  method: "GET",
1184
101
  headers: [
1185
- ["X-Api-Key", i],
1186
- ["X-Cache-Check", o]
102
+ ["X-Api-Key", apiKey],
103
+ ["X-Cache-Check", cacheCheck]
1187
104
  ]
1188
- }), h = await a.json(), c = (d = a == null ? void 0 : a.headers) == null ? void 0 : d.get("X-Cache-Check");
1189
- return c && c !== o && fetch(`${n}/templates/${s}`, {
105
+ });
106
+ const vouch = await res.json();
107
+ this.host.dispatchEvent(new CustomEvent("vouch:loaded", { detail: vouch == null ? void 0 : vouch.id }));
108
+ const resCacheCheck = (_a = res == null ? void 0 : res.headers) == null ? void 0 : _a.get("X-Cache-Check");
109
+ if (resCacheCheck !== cacheCheck) {
110
+ fetch(`${embedApiUrl}/vouches/${vouchId}`, {
111
+ method: "GET",
112
+ headers: [
113
+ ["X-Api-Key", apiKey],
114
+ ["Cache-Control", "max-age=0"]
115
+ ]
116
+ });
117
+ }
118
+ return vouch;
119
+ };
120
+ this.getTemplate = async (env, apiKey, templateId) => {
121
+ var _a;
122
+ const { embedApiUrl } = getEnvUrls(env);
123
+ const cacheCheck = v4();
124
+ const res = await fetch(`${embedApiUrl}/templates/${templateId}`, {
1190
125
  method: "GET",
1191
126
  headers: [
1192
- ["X-Api-Key", i],
1193
- ["Cache-Control", "max-age=0"]
127
+ ["X-Api-Key", apiKey],
128
+ ["X-Cache-Check", cacheCheck]
1194
129
  ]
1195
- }), h;
1196
- }, this.host = t, new ae(
130
+ });
131
+ const template = await res.json();
132
+ const resCacheCheck = (_a = res == null ? void 0 : res.headers) == null ? void 0 : _a.get("X-Cache-Check");
133
+ if (resCacheCheck !== cacheCheck) {
134
+ fetch(`${embedApiUrl}/templates/${templateId}`, {
135
+ method: "GET",
136
+ headers: [
137
+ ["X-Api-Key", apiKey],
138
+ ["Cache-Control", "max-age=0"]
139
+ ]
140
+ });
141
+ }
142
+ return template;
143
+ };
144
+ this.host = host;
145
+ new Task(
1197
146
  this.host,
1198
- async ([e, i, s, n, o]) => {
1199
- var a, h, c, d;
147
+ async ([env, apiKey, data, vouchId, templateId]) => {
148
+ var _a, _b, _c, _d;
1200
149
  try {
1201
- if (t.vouch = void 0, t.template = void 0, s) {
1202
- let l;
1203
- o && (this.fetching = !0, l = await this.getTemplate(e, i, o)), t.vouch = s, t.template = l ?? ((h = (a = s == null ? void 0 : s.settings) == null ? void 0 : a.template) == null ? void 0 : h.instance);
1204
- } else if (n) {
1205
- this.fetching = !0;
1206
- const [l, p] = await Promise.all([
1207
- this.getVouch(e, i, n),
1208
- o ? this.getTemplate(e, i, o) : null
150
+ host.vouch = void 0;
151
+ host.template = void 0;
152
+ if (data) {
153
+ let template;
154
+ if (templateId) {
155
+ this.fetching = true;
156
+ template = await this.getTemplate(env, apiKey, templateId);
157
+ }
158
+ this._vouch = data;
159
+ host.template = template ?? ((_b = (_a = data == null ? void 0 : data.settings) == null ? void 0 : _a.template) == null ? void 0 : _b.instance);
160
+ } else if (vouchId) {
161
+ this.fetching = true;
162
+ const [vouch, template] = await Promise.all([
163
+ this.getVouch(env, apiKey, vouchId),
164
+ templateId ? this.getTemplate(env, apiKey, templateId) : null
1209
165
  ]);
1210
- t.vouch = l, t.template = p ?? ((d = (c = l == null ? void 0 : l.settings) == null ? void 0 : c.template) == null ? void 0 : d.instance);
166
+ this._vouch = vouch;
167
+ host.template = template ?? ((_d = (_c = vouch == null ? void 0 : vouch.settings) == null ? void 0 : _c.template) == null ? void 0 : _d.instance);
1211
168
  }
1212
169
  } finally {
1213
- this.fetching = !1;
170
+ this.fetching = false;
1214
171
  }
1215
172
  },
1216
- () => [t.env, t.apiKey, t.data, t.vouchId, t.templateId]
173
+ () => [host.env, host.apiKey, host.data, host.vouchId, host.templateId]
174
+ );
175
+ new Task(
176
+ this.host,
177
+ ([vouch, questions]) => {
178
+ host.vouch = vouch ? {
179
+ ...vouch,
180
+ questions: {
181
+ items: vouch == null ? void 0 : vouch.questions.items.filter((_, index) => !(questions == null ? void 0 : questions.length) || (questions == null ? void 0 : questions.includes(index + 1)))
182
+ }
183
+ } : void 0;
184
+ },
185
+ () => [this._vouch, host.questions]
1217
186
  );
1218
187
  }
1219
- set fetching(t) {
1220
- this._fetching !== t && (this._fetching = t, this.host.requestUpdate());
188
+ set fetching(value) {
189
+ if (this._fetching !== value) {
190
+ this._fetching = value;
191
+ this.host.requestUpdate();
192
+ }
1221
193
  }
1222
194
  get fetching() {
1223
195
  return this._fetching;
1224
196
  }
1225
197
  }
1226
- const ni = 10;
1227
- class oi {
1228
- constructor(t) {
1229
- this._tabId = void 0, this._clientId = void 0, this._visitorId = void 0, this._hasPlayed = !1, this._hasLoaded = {}, this._answersViewed = {}, this._streamStartTime = {}, this._streamLatestTime = {}, this._currentlyPlayingVideo = null, this._createVisitor = (e) => {
1230
- var s, n;
1231
- const { publicApiUrl: i } = et(this.host.env);
1232
- return (n = (s = window.localStorage) == null ? void 0 : s.setItem) == null || n.call(s, "vouch-uid-visitor", e), navigator.sendBeacon(`${i}/api/visitor`, JSON.stringify({ visitorId: e })), e;
1233
- }, this._getReportingMetadata = () => {
1234
- var n, o;
1235
- const [e, i] = ((o = (n = Intl.DateTimeFormat().resolvedOptions().timeZone) == null ? void 0 : n.split) == null ? void 0 : o.call(n, "/")) ?? [], s = {};
1236
- return [...new URLSearchParams(location.search).entries()].forEach(([a, h]) => {
1237
- if (/utm/.test(a)) {
1238
- const c = a.toLowerCase().replace(/[-_][a-z0-9]/g, (d) => d.slice(-1).toUpperCase());
1239
- s[c] = h;
198
+ const version = "0.0.0-experiment.a965a35";
199
+ const packageJson = {
200
+ version
201
+ };
202
+ function createVisitor(env) {
203
+ const { publicApiUrl } = getEnvUrls(env);
204
+ const visitorId = v4();
205
+ navigator.sendBeacon(`${publicApiUrl}/api/visitor`, JSON.stringify({ visitorId }));
206
+ return visitorId;
207
+ }
208
+ function getUids(env) {
209
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
210
+ if (typeof window === "undefined") {
211
+ return {
212
+ client: null,
213
+ tab: null,
214
+ request: v4()
215
+ };
216
+ }
217
+ let visitorId = (_b = (_a = window.localStorage) == null ? void 0 : _a.getItem) == null ? void 0 : _b.call(_a, "vouch-uid-visitor");
218
+ let clientId = (_d = (_c = window.localStorage) == null ? void 0 : _c.getItem) == null ? void 0 : _d.call(_c, "vouch-uid-client");
219
+ let tabId = (_f = (_e = window.sessionStorage) == null ? void 0 : _e.getItem) == null ? void 0 : _f.call(_e, "vouch-uid-tab");
220
+ const requestId = v4();
221
+ if (!visitorId) {
222
+ visitorId = createVisitor(env);
223
+ (_h = (_g = window.localStorage) == null ? void 0 : _g.setItem) == null ? void 0 : _h.call(_g, "vouch-uid-visitor", visitorId);
224
+ }
225
+ if (!clientId) {
226
+ clientId = v4();
227
+ (_j = (_i = window.localStorage) == null ? void 0 : _i.setItem) == null ? void 0 : _j.call(_i, "vouch-uid-client", clientId);
228
+ }
229
+ if (!tabId) {
230
+ tabId = v4();
231
+ (_l = (_k = window.sessionStorage) == null ? void 0 : _k.setItem) == null ? void 0 : _l.call(_k, "vouch-uid-tab", tabId);
232
+ }
233
+ return {
234
+ client: clientId,
235
+ tab: tabId,
236
+ request: requestId,
237
+ visitor: visitorId
238
+ };
239
+ }
240
+ function findVouchId(payload, vouch) {
241
+ if (payload && "vouchId" in payload) {
242
+ return payload.vouchId;
243
+ }
244
+ return (vouch == null ? void 0 : vouch.id) ?? null;
245
+ }
246
+ function getReportingMetadata(source = "embedded_player") {
247
+ var _a, _b;
248
+ const [country, region] = ((_b = (_a = Intl.DateTimeFormat().resolvedOptions().timeZone) == null ? void 0 : _a.split) == null ? void 0 : _b.call(_a, "/")) ?? [];
249
+ const utmParams = {};
250
+ [...new URLSearchParams(location.search).entries()].forEach(([key, value]) => {
251
+ if (/utm/.test(key)) {
252
+ const param = key.toLowerCase().replace(/[-_][a-z0-9]/g, (group) => group.slice(-1).toUpperCase());
253
+ utmParams[param] = value;
254
+ }
255
+ });
256
+ return {
257
+ source,
258
+ time: /* @__PURE__ */ new Date(),
259
+ region,
260
+ country,
261
+ screenHeight: window.screen.height,
262
+ screenWidth: window.screen.width,
263
+ referrer: document.referrer,
264
+ currentUrl: location.href,
265
+ embedType: "media-player-embed",
266
+ embedVersion: packageJson.version,
267
+ templateVersion: TEMPLATE_VERSION,
268
+ ...utmParams
269
+ };
270
+ }
271
+ const MINIMUM_SEND_THRESHOLD = 1;
272
+ class TrackingController {
273
+ constructor(host) {
274
+ this._batchedEvents = [];
275
+ this._hasPlayed = false;
276
+ this._hasLoaded = {};
277
+ this._answersViewed = {};
278
+ this._streamStartTime = {};
279
+ this._streamLatestTime = {};
280
+ this._currentlyPlayingVideo = null;
281
+ this._createTrackingEvent = (event, payload) => {
282
+ const vouchId = findVouchId(payload, this.host.vouch);
283
+ if (!vouchId || this.host.disableTracking) {
284
+ return;
285
+ }
286
+ this._batchedEvents.push({
287
+ event,
288
+ payload: {
289
+ ...payload,
290
+ vouchId,
291
+ time: (/* @__PURE__ */ new Date()).toISOString()
1240
292
  }
1241
- }), {
1242
- source: this.host.trackingSource,
1243
- time: /* @__PURE__ */ new Date(),
1244
- region: i,
1245
- country: e,
1246
- screenHeight: window.screen.height,
1247
- screenWidth: window.screen.width,
1248
- referrer: document.referrer,
1249
- currentUrl: location.href,
1250
- ...s
1251
- };
1252
- }, this._sendTrackingEvent = (e, i) => {
1253
- if (!this._findVouchId() || this.host.disableTracking)
293
+ });
294
+ };
295
+ this._sendTrackingEvent = () => {
296
+ if (this._batchedEvents.length <= 0) {
1254
297
  return;
1255
- const { publicApiUrl: n } = et(this.host.env), { client: o, tab: a, request: h, visitor: c } = this._getUids();
298
+ }
299
+ const { publicApiUrl } = getEnvUrls(this.host.env);
300
+ const { client, tab, request, visitor } = getUids(this.host.env);
1256
301
  navigator.sendBeacon(
1257
- `${n}/api/events`,
302
+ `${publicApiUrl}/api/batchevents`,
1258
303
  JSON.stringify({
1259
- event: e,
1260
- payload: i,
304
+ payload: {
305
+ events: this._batchedEvents
306
+ },
1261
307
  context: {
1262
- "x-uid-client": o,
1263
- "x-uid-tab": a,
1264
- "x-uid-request": h,
1265
- "x-uid-visitor": c,
1266
- "x-reporting-metadata": this._getReportingMetadata()
308
+ "x-uid-client": client,
309
+ "x-uid-tab": tab,
310
+ "x-uid-request": request,
311
+ "x-uid-visitor": visitor,
312
+ "x-reporting-metadata": getReportingMetadata(this.host.trackingSource)
1267
313
  }
1268
314
  })
1269
315
  );
1270
- }, this._handleVouchLoaded = ({ detail: e }) => {
1271
- e && (this._hasLoaded[e] || (this._sendTrackingEvent("VOUCH_LOADED"), this._hasLoaded[e] = !0));
1272
- }, this._handlePlay = () => {
1273
- this._hasPlayed || (this._sendTrackingEvent("VIDEO_PLAYED", {
1274
- streamStart: this.host.currentTime
1275
- }), this._hasPlayed = !0);
1276
- }, this._handleVideoPlay = ({ detail: { id: e, key: i, node: s } }) => {
1277
- this._answersViewed[i] || (this._sendTrackingEvent("VOUCH_RESPONSE_VIEWED", {
1278
- answerId: e
1279
- }), this._answersViewed[i] = !0), this._streamStartTime[i] = s.currentTime, this._streamLatestTime[i] = s.currentTime;
1280
- }, this._handleVideoTimeUpdate = ({ detail: { id: e, key: i, node: s } }) => {
1281
- var n, o;
1282
- this.host.paused || (this._currentlyPlayingVideo = { id: e, key: i, node: s }, this._streamLatestTime[i] = s.currentTime), !s.paused && !this.host.paused && // Only fire the video seeked event when this video is the active one
1283
- e === ((o = (n = this.host.scene) == null ? void 0 : n.video) == null ? void 0 : o.id) && // Throttle the frequency that we send streamed events while playing
1284
- this._streamLatestTime[i] - this._streamStartTime[i] > ni && (this._sendTrackingEvent("VIDEO_STREAMED", {
1285
- answerId: e,
1286
- streamStart: this._streamStartTime[i],
1287
- streamEnd: this._streamLatestTime[i]
1288
- }), this._streamStartTime[i] = s.currentTime);
1289
- }, this._handleVideoPause = ({ detail: { id: e, key: i } }) => {
1290
- this._streamLatestTime[i] > this._streamStartTime[i] && this._sendTrackingEvent("VIDEO_STREAMED", {
1291
- answerId: e,
1292
- streamStart: this._streamStartTime[i],
1293
- streamEnd: this._streamLatestTime[i]
1294
- }), this._currentlyPlayingVideo = null, delete this._streamStartTime[i], delete this._streamLatestTime[i];
1295
- }, this.host = t, t.addController(this);
1296
- }
1297
- _findVouchId() {
1298
- if (this.host.vouch)
1299
- return "uuid" in this.host.vouch ? this.host.vouch.uuid : this.host.vouch.id;
1300
- }
1301
- _getUids() {
1302
- var n, o, a, h, c, d, l, p, u, g, F, mt;
1303
- if (typeof window > "u")
1304
- return {
1305
- client: null,
1306
- tab: null,
1307
- request: P()
1308
- };
1309
- const t = this._visitorId || ((o = (n = window.localStorage) == null ? void 0 : n.getItem) == null ? void 0 : o.call(n, "vouch-uid-visitor")) || this._createVisitor(P()), e = this._clientId || ((h = (a = window.localStorage) == null ? void 0 : a.getItem) == null ? void 0 : h.call(a, "vouch-uid-client")) || P(), i = this._tabId || ((d = (c = window.sessionStorage) == null ? void 0 : c.getItem) == null ? void 0 : d.call(c, "vouch-uid-tab")) || P(), s = P();
1310
- return t !== this._visitorId && (this._visitorId = t, (p = (l = window.localStorage) == null ? void 0 : l.setItem) == null || p.call(l, "vouch-uid-visitor", t)), e !== this._clientId && (this._clientId = e, (g = (u = window.localStorage) == null ? void 0 : u.setItem) == null || g.call(u, "vouch-uid-client", e)), i !== this._tabId && (this._tabId = i, (mt = (F = window.sessionStorage) == null ? void 0 : F.setItem) == null || mt.call(F, "vouch-uid-tab", i)), {
1311
- client: e,
1312
- tab: i,
1313
- request: s,
1314
- visitor: t
316
+ this._batchedEvents = [];
317
+ };
318
+ this._streamEnded = () => {
319
+ if (this._currentlyPlayingVideo) {
320
+ const { id, key } = this._currentlyPlayingVideo;
321
+ if (this._streamLatestTime[key] > this._streamStartTime[key] + MINIMUM_SEND_THRESHOLD) {
322
+ this._createTrackingEvent("VIDEO_STREAMED", {
323
+ answerId: id,
324
+ streamStart: this._streamStartTime[key],
325
+ streamEnd: this._streamLatestTime[key]
326
+ });
327
+ }
328
+ delete this._streamStartTime[key];
329
+ delete this._streamLatestTime[key];
330
+ }
331
+ };
332
+ this._handleVouchLoaded = ({ detail: vouchId }) => {
333
+ if (!vouchId) {
334
+ return;
335
+ }
336
+ if (!this._hasLoaded[vouchId]) {
337
+ this._createTrackingEvent("VOUCH_LOADED", { vouchId });
338
+ this._hasLoaded[vouchId] = true;
339
+ }
340
+ };
341
+ this._handlePlay = () => {
342
+ if (!this._hasPlayed) {
343
+ this._createTrackingEvent("VIDEO_PLAYED", {
344
+ streamStart: this.host.currentTime
345
+ });
346
+ this._hasPlayed = true;
347
+ }
348
+ };
349
+ this._handleVideoPlay = ({ detail: { id, key } }) => {
350
+ if (!this._answersViewed[key]) {
351
+ this._createTrackingEvent("VOUCH_RESPONSE_VIEWED", {
352
+ answerId: id
353
+ });
354
+ this._answersViewed[key] = true;
355
+ }
356
+ };
357
+ this._handleVideoTimeUpdate = ({ detail: { id, key, node } }) => {
358
+ if (
359
+ // We only want to count any time that the video is actually playing
360
+ !this.host.paused
361
+ ) {
362
+ this._currentlyPlayingVideo = { id, key, node };
363
+ this._streamLatestTime[key] = node.currentTime;
364
+ if (!this._streamStartTime[key]) {
365
+ this._streamStartTime[key] = node.currentTime;
366
+ this._streamLatestTime[key] = node.currentTime;
367
+ }
368
+ }
1315
369
  };
370
+ this._handleVideoPause = ({ detail: { id, key } }) => {
371
+ if (this._streamLatestTime[key] > this._streamStartTime[key] + MINIMUM_SEND_THRESHOLD) {
372
+ this._createTrackingEvent("VIDEO_STREAMED", {
373
+ answerId: id,
374
+ streamStart: this._streamStartTime[key],
375
+ streamEnd: this._streamLatestTime[key]
376
+ });
377
+ }
378
+ delete this._streamStartTime[key];
379
+ delete this._streamLatestTime[key];
380
+ };
381
+ this._pageUnloading = () => {
382
+ this._streamEnded();
383
+ this._sendTrackingEvent();
384
+ };
385
+ this._handleVisibilityChange = () => {
386
+ if (document.visibilityState === "hidden") {
387
+ this._pageUnloading();
388
+ }
389
+ };
390
+ this._handlePageHide = () => {
391
+ this._pageUnloading();
392
+ };
393
+ this.host = host;
394
+ host.addController(this);
1316
395
  }
1317
396
  hostConnected() {
1318
397
  requestAnimationFrame(() => {
1319
- var t, e, i, s;
1320
- this.host.addEventListener("vouch:loaded", this._handleVouchLoaded), (t = this.host.mediaPlayer) == null || t.addEventListener("play", this._handlePlay), (e = this.host.mediaPlayer) == null || e.addEventListener("video:play", this._handleVideoPlay), (i = this.host.mediaPlayer) == null || i.addEventListener("video:pause", this._handleVideoPause), (s = this.host.mediaPlayer) == null || s.addEventListener("video:timeupdate", this._handleVideoTimeUpdate);
398
+ var _a, _b, _c, _d;
399
+ if ("onvisibilitychange" in document) {
400
+ document.addEventListener("visibilitychange", this._handleVisibilityChange);
401
+ } else {
402
+ window.addEventListener("pagehide", this._handlePageHide);
403
+ }
404
+ this.host.addEventListener("vouch:loaded", this._handleVouchLoaded);
405
+ (_a = this.host.mediaPlayer) == null ? void 0 : _a.addEventListener("play", this._handlePlay);
406
+ (_b = this.host.mediaPlayer) == null ? void 0 : _b.addEventListener("video:play", this._handleVideoPlay);
407
+ (_c = this.host.mediaPlayer) == null ? void 0 : _c.addEventListener("video:pause", this._handleVideoPause);
408
+ (_d = this.host.mediaPlayer) == null ? void 0 : _d.addEventListener("video:timeupdate", this._handleVideoTimeUpdate);
1321
409
  });
1322
410
  }
1323
411
  hostDisconnected() {
1324
- var t, e, i, s;
1325
- if (this._currentlyPlayingVideo) {
1326
- const { id: n, key: o } = this._currentlyPlayingVideo;
1327
- this._streamLatestTime[o] > this._streamStartTime[o] && this._sendTrackingEvent("VIDEO_STREAMED", {
1328
- answerId: n,
1329
- streamStart: this._streamStartTime[o],
1330
- streamEnd: this._streamLatestTime[o]
1331
- });
412
+ var _a, _b, _c, _d;
413
+ this._pageUnloading();
414
+ if ("onvisibilitychange" in document) {
415
+ document.removeEventListener("visibilitychange", this._handleVisibilityChange);
416
+ } else {
417
+ window.removeEventListener("pagehide", this._handlePageHide);
1332
418
  }
1333
- this.host.removeEventListener("vouch:loaded", this._handleVouchLoaded), (t = this.host.mediaPlayer) == null || t.removeEventListener("play", this._handlePlay), (e = this.host.mediaPlayer) == null || e.removeEventListener("video:play", this._handleVideoPlay), (i = this.host.mediaPlayer) == null || i.removeEventListener("video:pause", this._handleVideoPause), (s = this.host.mediaPlayer) == null || s.removeEventListener("video:timeupdate", this._handleVideoTimeUpdate);
419
+ this.host.removeEventListener("vouch:loaded", this._handleVouchLoaded);
420
+ (_a = this.host.mediaPlayer) == null ? void 0 : _a.removeEventListener("play", this._handlePlay);
421
+ (_b = this.host.mediaPlayer) == null ? void 0 : _b.removeEventListener("video:play", this._handleVideoPlay);
422
+ (_c = this.host.mediaPlayer) == null ? void 0 : _c.removeEventListener("video:pause", this._handleVideoPause);
423
+ (_d = this.host.mediaPlayer) == null ? void 0 : _d.removeEventListener("video:timeupdate", this._handleVideoTimeUpdate);
1334
424
  }
1335
425
  }
1336
- var hi = Object.defineProperty, ai = Object.getOwnPropertyDescriptor, f = (r, t, e, i) => {
1337
- for (var s = i > 1 ? void 0 : i ? ai(t, e) : t, n = r.length - 1, o; n >= 0; n--)
1338
- (o = r[n]) && (s = (i ? o(t, e, s) : o(s)) || s);
1339
- return i && s && hi(t, e, s), s;
426
+ var __defProp$3 = Object.defineProperty;
427
+ var __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor;
428
+ var __decorateClass$3 = (decorators, target, key, kind) => {
429
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target;
430
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
431
+ if (decorator = decorators[i])
432
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
433
+ if (kind && result) __defProp$3(target, key, result);
434
+ return result;
1340
435
  };
1341
- let m = class extends j {
436
+ let PlayerEmbed = class extends LitElement {
1342
437
  constructor() {
1343
- super(...arguments), this._mediaPlayerRef = jt(), this.env = "prod", this.apiKey = "", this.disableTracking = !1, this.trackingSource = "embed", this.preload = "auto", this.autoplay = !1, this.aspectRatio = 0, this.eventController = new Fe(this, [
438
+ super(...arguments);
439
+ this.env = "prod";
440
+ this.apiKey = "";
441
+ this.disableTracking = false;
442
+ this.trackingSource = "embedded_player";
443
+ this.preload = "auto";
444
+ this.autoplay = false;
445
+ this.aspectRatio = 0;
446
+ this.eventController = new EventForwardController(this, [
1344
447
  "durationchange",
1345
448
  "ended",
1346
449
  "error",
@@ -1351,10 +454,12 @@ let m = class extends j {
1351
454
  "playing",
1352
455
  "ratechange",
1353
456
  "scenechange",
457
+ "scenesupdate",
1354
458
  "seeking",
1355
459
  "seeked",
1356
460
  "timeupdate",
1357
461
  "volumechange",
462
+ "processing",
1358
463
  "waiting",
1359
464
  "video:loadeddata",
1360
465
  "video:seeking",
@@ -1366,149 +471,570 @@ let m = class extends j {
1366
471
  "video:timeupdate",
1367
472
  "video:ended",
1368
473
  "video:error"
1369
- ]), this._fetcherController = new ri(this), this._trackingController = new oi(this);
474
+ ]);
475
+ this._fetcherController = new FetcherController(this);
476
+ this._trackingController = new TrackingController(this);
477
+ this._mediaPlayerRef = createRef();
1370
478
  }
1371
479
  get fetching() {
1372
480
  return this._fetcherController.fetching;
1373
481
  }
1374
482
  get waiting() {
1375
- var r;
1376
- return (r = this._mediaPlayerRef.value) == null ? void 0 : r.waiting;
483
+ var _a;
484
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.waiting;
485
+ }
486
+ get initialised() {
487
+ var _a;
488
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.initialised;
1377
489
  }
1378
490
  get seeking() {
1379
- var r;
1380
- return (r = this._mediaPlayerRef.value) == null ? void 0 : r.seeking;
491
+ var _a;
492
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.seeking;
1381
493
  }
1382
494
  get paused() {
1383
- var r;
1384
- return (r = this._mediaPlayerRef.value) == null ? void 0 : r.paused;
495
+ var _a;
496
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.paused;
1385
497
  }
1386
498
  get captions() {
1387
- var r;
1388
- return (r = this._mediaPlayerRef.value) == null ? void 0 : r.captions;
499
+ var _a;
500
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.captions;
1389
501
  }
1390
502
  get fullscreen() {
1391
- var r;
1392
- return (r = this._mediaPlayerRef.value) == null ? void 0 : r.fullscreen;
503
+ var _a;
504
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.fullscreen;
1393
505
  }
1394
506
  get duration() {
1395
- var r;
1396
- return (r = this._mediaPlayerRef.value) == null ? void 0 : r.duration;
507
+ var _a;
508
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.duration;
1397
509
  }
1398
- set currentTime(r) {
1399
- this._mediaPlayerRef.value && (this._mediaPlayerRef.value.currentTime = r);
510
+ set currentTime(value) {
511
+ if (this._mediaPlayerRef.value) {
512
+ this._mediaPlayerRef.value.currentTime = value;
513
+ }
1400
514
  }
1401
515
  get currentTime() {
1402
- var r;
1403
- return ((r = this._mediaPlayerRef.value) == null ? void 0 : r.currentTime) ?? 0;
516
+ var _a;
517
+ return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.currentTime) ?? 0;
1404
518
  }
1405
- set playbackRate(r) {
1406
- this._mediaPlayerRef.value && (this._mediaPlayerRef.value.playbackRate = r);
519
+ set playbackRate(value) {
520
+ if (this._mediaPlayerRef.value) {
521
+ this._mediaPlayerRef.value.playbackRate = value;
522
+ }
1407
523
  }
1408
524
  get playbackRate() {
1409
- var r;
1410
- return ((r = this._mediaPlayerRef.value) == null ? void 0 : r.playbackRate) ?? 1;
525
+ var _a;
526
+ return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.playbackRate) ?? 1;
1411
527
  }
1412
- set volume(r) {
1413
- this._mediaPlayerRef.value && (this._mediaPlayerRef.value.volume = r);
528
+ set volume(value) {
529
+ if (this._mediaPlayerRef.value) {
530
+ this._mediaPlayerRef.value.volume = value;
531
+ }
1414
532
  }
1415
533
  get volume() {
1416
- var r;
1417
- return ((r = this._mediaPlayerRef.value) == null ? void 0 : r.volume) ?? 1;
534
+ var _a;
535
+ return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.volume) ?? 1;
1418
536
  }
1419
- set muted(r) {
1420
- this._mediaPlayerRef.value && (this._mediaPlayerRef.value.muted = r);
537
+ set muted(value) {
538
+ if (this._mediaPlayerRef.value) {
539
+ this._mediaPlayerRef.value.muted = value;
540
+ }
1421
541
  }
1422
542
  get muted() {
1423
- var r;
1424
- return ((r = this._mediaPlayerRef.value) == null ? void 0 : r.muted) ?? !1;
1425
- }
1426
- get scene() {
1427
- var r;
1428
- return ((r = this._mediaPlayerRef.value) == null ? void 0 : r.scene) ?? null;
1429
- }
1430
- get scenes() {
1431
- var r;
1432
- return ((r = this._mediaPlayerRef.value) == null ? void 0 : r.scenes) ?? [];
1433
- }
1434
- get videoState() {
1435
- var r;
1436
- return (r = this._mediaPlayerRef.value) == null ? void 0 : r.videoState;
543
+ var _a;
544
+ return ((_a = this._mediaPlayerRef.value) == null ? void 0 : _a.muted) ?? false;
545
+ }
546
+ // get scene(): Scene | null {
547
+ // return this._mediaPlayerRef.value?.scene ?? null;
548
+ // }
549
+ // get scenes(): Scene[] {
550
+ // return this._mediaPlayerRef.value?.scenes ?? [];
551
+ // }
552
+ // get sceneConfig(): Scenes | null {
553
+ // return this._mediaPlayerRef.value?.sceneConfig ?? null;
554
+ // }
555
+ get mediaState() {
556
+ var _a;
557
+ return (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.mediaState;
1437
558
  }
1438
559
  get mediaPlayer() {
1439
560
  return this._mediaPlayerRef.value;
1440
561
  }
1441
562
  play() {
1442
- var r;
1443
- (r = this._mediaPlayerRef.value) == null || r.play();
563
+ var _a;
564
+ (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.play();
1444
565
  }
1445
566
  pause() {
1446
- var r;
1447
- (r = this._mediaPlayerRef.value) == null || r.pause();
567
+ var _a;
568
+ (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.pause();
569
+ }
570
+ reset(time = 0, play = false) {
571
+ var _a;
572
+ (_a = this._mediaPlayerRef.value) == null ? void 0 : _a.reset(time, play);
573
+ }
574
+ // setScene(index: number) {
575
+ // this._mediaPlayerRef.value?.setScene(index);
576
+ // }
577
+ _renderStyles() {
578
+ if (!this.aspectRatio) {
579
+ return html`
580
+ <style>
581
+ :host {
582
+ width: 100%;
583
+ height: 100%;
584
+ }
585
+ </style>
586
+ `;
587
+ }
588
+ if (typeof this.aspectRatio === "number") {
589
+ return html`
590
+ <style>
591
+ :host {
592
+ aspect-ratio: ${this.aspectRatio};
593
+ }
594
+ </style>
595
+ `;
596
+ }
597
+ return null;
1448
598
  }
1449
- setScene(r) {
1450
- var t;
1451
- (t = this._mediaPlayerRef.value) == null || t.setScene(r);
599
+ willUpdate(changedProperties) {
600
+ if (changedProperties.has("vouchId") && this.vouchId !== changedProperties.get("vouchId")) {
601
+ this.reset(0, false);
602
+ }
1452
603
  }
1453
604
  render() {
1454
- return De`
1455
- <vmp-new-media-player
1456
- ${Bt(this._mediaPlayerRef)}
605
+ return html`
606
+ ${this._renderStyles()}
607
+ <vmp-media-player
608
+ ${ref(this._mediaPlayerRef)}
1457
609
  ${this.eventController.register()}
1458
610
  ?autoplay=${this.autoplay}
1459
611
  ?loading=${this.fetching}
1460
- .data=${this.vouch}
1461
- .template=${this.template}
1462
- aspectRatio=${ft(this.aspectRatio)}
1463
- preload=${ft(this.preload)}
612
+ aspectRatio=${ifDefined(this.aspectRatio)}
613
+ preload=${ifDefined(this.preload)}
614
+ language=${ifDefined(this.language)}
1464
615
  .controls=${this.controls}
1465
- ></vmp-new-media-player>
616
+ ></vmp-media-player>
1466
617
  `;
1467
618
  }
1468
619
  };
1469
- f([
1470
- v({ type: Object, attribute: "data" })
1471
- ], m.prototype, "data", 2);
1472
- f([
1473
- v({ type: String })
1474
- ], m.prototype, "vouchId", 2);
1475
- f([
1476
- v({ type: String })
1477
- ], m.prototype, "templateId", 2);
1478
- f([
1479
- v({ type: String })
1480
- ], m.prototype, "env", 2);
1481
- f([
1482
- v({ type: String })
1483
- ], m.prototype, "apiKey", 2);
1484
- f([
1485
- v({ type: Boolean })
1486
- ], m.prototype, "disableTracking", 2);
1487
- f([
1488
- v({ type: String })
1489
- ], m.prototype, "trackingSource", 2);
1490
- f([
1491
- v({ type: Array })
1492
- ], m.prototype, "controls", 2);
1493
- f([
1494
- v({ type: String })
1495
- ], m.prototype, "preload", 2);
1496
- f([
1497
- v({ type: Boolean })
1498
- ], m.prototype, "autoplay", 2);
1499
- f([
1500
- v({ type: Number })
1501
- ], m.prototype, "aspectRatio", 2);
1502
- f([
1503
- zt()
1504
- ], m.prototype, "vouch", 2);
1505
- f([
1506
- zt()
1507
- ], m.prototype, "template", 2);
1508
- m = f([
1509
- he("vouch-embed")
1510
- ], m);
620
+ PlayerEmbed.styles = [
621
+ css`
622
+ :host {
623
+ display: flex;
624
+ }
625
+ `
626
+ ];
627
+ __decorateClass$3([
628
+ property({ type: Object })
629
+ ], PlayerEmbed.prototype, "data", 2);
630
+ __decorateClass$3([
631
+ property({ type: String })
632
+ ], PlayerEmbed.prototype, "vouchId", 2);
633
+ __decorateClass$3([
634
+ property({ type: String })
635
+ ], PlayerEmbed.prototype, "templateId", 2);
636
+ __decorateClass$3([
637
+ property({ type: Array })
638
+ ], PlayerEmbed.prototype, "questions", 2);
639
+ __decorateClass$3([
640
+ property({ type: String })
641
+ ], PlayerEmbed.prototype, "env", 2);
642
+ __decorateClass$3([
643
+ property({ type: String })
644
+ ], PlayerEmbed.prototype, "apiKey", 2);
645
+ __decorateClass$3([
646
+ property({ type: Boolean })
647
+ ], PlayerEmbed.prototype, "disableTracking", 2);
648
+ __decorateClass$3([
649
+ property({ type: String })
650
+ ], PlayerEmbed.prototype, "trackingSource", 2);
651
+ __decorateClass$3([
652
+ property({ type: Array })
653
+ ], PlayerEmbed.prototype, "controls", 2);
654
+ __decorateClass$3([
655
+ property({ type: String })
656
+ ], PlayerEmbed.prototype, "preload", 2);
657
+ __decorateClass$3([
658
+ property({ type: Boolean })
659
+ ], PlayerEmbed.prototype, "autoplay", 2);
660
+ __decorateClass$3([
661
+ property({ type: Number })
662
+ ], PlayerEmbed.prototype, "aspectRatio", 2);
663
+ __decorateClass$3([
664
+ property({ type: String })
665
+ ], PlayerEmbed.prototype, "language", 2);
666
+ __decorateClass$3([
667
+ state()
668
+ ], PlayerEmbed.prototype, "vouch", 2);
669
+ __decorateClass$3([
670
+ state()
671
+ ], PlayerEmbed.prototype, "template", 2);
672
+ PlayerEmbed = __decorateClass$3([
673
+ customElement("vouch-embed-player")
674
+ ], PlayerEmbed);
675
+ var __defProp$2 = Object.defineProperty;
676
+ var __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor;
677
+ var __decorateClass$2 = (decorators, target, key, kind) => {
678
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target;
679
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
680
+ if (decorator = decorators[i])
681
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
682
+ if (kind && result) __defProp$2(target, key, result);
683
+ return result;
684
+ };
685
+ let DialogOverlay = class extends LitElement {
686
+ constructor() {
687
+ super(...arguments);
688
+ this.open = false;
689
+ this.aspectRatio = 0;
690
+ }
691
+ render() {
692
+ return html`
693
+ <div
694
+ class=${classMap({
695
+ container: true,
696
+ hidden: !this.open
697
+ })}
698
+ >
699
+ <div
700
+ class="background"
701
+ @click=${() => this.dispatchEvent(new CustomEvent("overlay:click", { bubbles: true, composed: true }))}
702
+ ></div>
703
+ <focus-trap>
704
+ <div
705
+ class=${classMap({
706
+ "video-frame": true,
707
+ grow: this.aspectRatio === 0
708
+ })}
709
+ style=${styleMap({
710
+ aspectRatio: this.aspectRatio
711
+ })}
712
+ >
713
+ <slot></slot>
714
+ <vmp-icon-button
715
+ icon="close"
716
+ rounded="full"
717
+ weight="heavy"
718
+ @click=${() => this.dispatchEvent(new CustomEvent("close:click", { bubbles: true, composed: true }))}
719
+ ></vmp-icon-button>
720
+ </div>
721
+ </focus-trap>
722
+ </div>
723
+ `;
724
+ }
725
+ };
726
+ DialogOverlay.styles = [
727
+ css`
728
+ :host {
729
+ --vouch-media-player-border-radius: var(--vu-media-player-border-radius, 12px);
730
+ --overlay-background-color: var(--vu-overlay-background-color, black);
731
+ --overlay-background-opacity: var(--vu-overlay-background-opacity, 0.4);
732
+
733
+ --dialog-width: var(--vu-dialog-width, 890px);
734
+ --dialog-height: var(--vu-dialog-height, 500px);
735
+ }
736
+
737
+ .container {
738
+ position: fixed;
739
+ display: flex;
740
+ inset: 0;
741
+ opacity: 1;
742
+ z-index: 2147483647;
743
+ align-items: center;
744
+ justify-content: center;
745
+ transition: opacity 100ms ease-in;
746
+ }
747
+
748
+ .hidden {
749
+ opacity: 0;
750
+ pointer-events: none;
751
+ }
752
+
753
+ .background {
754
+ position: absolute;
755
+ inset: 0;
756
+ opacity: var(--overlay-background-opacity);
757
+ background-color: var(--overlay-background-color);
758
+ }
759
+
760
+ focus-trap {
761
+ display: flex;
762
+ align-items: center;
763
+ justify-content: center;
764
+ margin: 40px;
765
+ width: var(--dialog-width);
766
+ height: var(--dialog-height);
767
+ max-width: calc(100% - 80px);
768
+ max-height: calc(100% - 80px);
769
+ }
770
+
771
+ .video-frame {
772
+ position: relative;
773
+ display: flex;
774
+ align-items: center;
775
+ justify-content: center;
776
+ max-width: 100%;
777
+ max-height: 100%;
778
+ }
779
+
780
+ .video-frame.grow {
781
+ width: 100%;
782
+ height: 100%;
783
+ }
784
+
785
+ vmp-icon-button {
786
+ position: absolute;
787
+ top: 0;
788
+ right: 0;
789
+ margin: 10px;
790
+ }
791
+ `
792
+ ];
793
+ __decorateClass$2([
794
+ property({ type: Boolean })
795
+ ], DialogOverlay.prototype, "open", 2);
796
+ __decorateClass$2([
797
+ property({ type: Number })
798
+ ], DialogOverlay.prototype, "aspectRatio", 2);
799
+ DialogOverlay = __decorateClass$2([
800
+ customElement("vouch-embed-dialog-overlay")
801
+ ], DialogOverlay);
802
+ var __defProp$1 = Object.defineProperty;
803
+ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
804
+ var __decorateClass$1 = (decorators, target, key, kind) => {
805
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target;
806
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
807
+ if (decorator = decorators[i])
808
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
809
+ if (kind && result) __defProp$1(target, key, result);
810
+ return result;
811
+ };
812
+ let DialogPortal = class extends LitElement {
813
+ constructor() {
814
+ super(...arguments);
815
+ this.env = "prod";
816
+ this.apiKey = "";
817
+ this.disableTracking = false;
818
+ this.trackingSource = "embedded_player";
819
+ this.preload = "none";
820
+ this.disableAutoplay = false;
821
+ this.aspectRatio = 0;
822
+ this._mediaPlayerRef = createRef();
823
+ this.open = false;
824
+ this._handleToggle = ({ detail }) => {
825
+ var _a, _b, _c;
826
+ if (this.id === detail) {
827
+ this.open = !this.open;
828
+ if (this.open) {
829
+ if (!this.disableAutoplay && ((_a = this._mediaPlayerRef) == null ? void 0 : _a.value)) {
830
+ this._mediaPlayerRef.value.muted = false;
831
+ this._mediaPlayerRef.value.play();
832
+ }
833
+ } else {
834
+ (_c = (_b = this._mediaPlayerRef) == null ? void 0 : _b.value) == null ? void 0 : _c.pause();
835
+ }
836
+ }
837
+ };
838
+ this._handleClose = () => {
839
+ var _a, _b;
840
+ this.open = false;
841
+ (_b = (_a = this._mediaPlayerRef) == null ? void 0 : _a.value) == null ? void 0 : _b.pause();
842
+ };
843
+ this._handleDocumentKeyUp = (e) => {
844
+ if (e.key === "Escape") {
845
+ this._handleClose();
846
+ }
847
+ };
848
+ }
849
+ connectedCallback() {
850
+ super.connectedCallback();
851
+ document.addEventListener("dialogembed:click", this._handleToggle);
852
+ document.addEventListener("keyup", this._handleDocumentKeyUp);
853
+ document.addEventListener("close:click", this._handleClose);
854
+ document.addEventListener("overlay:click", this._handleClose);
855
+ }
856
+ disconnectedCallback() {
857
+ super.disconnectedCallback();
858
+ document.removeEventListener("dialogembed:click", this._handleToggle);
859
+ document.removeEventListener("keyup", this._handleDocumentKeyUp);
860
+ document.removeEventListener("close:click", this._handleClose);
861
+ document.removeEventListener("overlay:click", this._handleClose);
862
+ }
863
+ createRenderRoot() {
864
+ const newNode = document.createElement("div");
865
+ document.body.appendChild(newNode);
866
+ return newNode;
867
+ }
868
+ render() {
869
+ return html`
870
+ <vouch-embed-dialog-overlay ?open=${this.open} aspectRatio=${this.aspectRatio}>
871
+ <vouch-embed-player
872
+ ${ref(this._mediaPlayerRef)}
873
+ style=${styleMap({
874
+ maxWidth: "100%",
875
+ maxHeight: "100%"
876
+ })}
877
+ ?autoplay=${false}
878
+ vouchId=${ifDefined(this.vouchId)}
879
+ templateId=${ifDefined(this.templateId)}
880
+ .questions=${this.questions}
881
+ .controls=${this.controls}
882
+ env=${ifDefined(this.env)}
883
+ apiKey=${ifDefined(this.apiKey)}
884
+ ?disableTracking=${this.disableTracking}
885
+ trackingSource=${ifDefined(this.trackingSource)}
886
+ preload=${ifDefined(this.preload)}
887
+ aspectRatio=${this.aspectRatio}
888
+ ></vouch-embed-player>
889
+ </vouch-embed-dialog-overlay>
890
+ `;
891
+ }
892
+ };
893
+ __decorateClass$1([
894
+ property({ type: String })
895
+ ], DialogPortal.prototype, "vouchId", 2);
896
+ __decorateClass$1([
897
+ property({ type: String })
898
+ ], DialogPortal.prototype, "templateId", 2);
899
+ __decorateClass$1([
900
+ property({ type: Array })
901
+ ], DialogPortal.prototype, "questions", 2);
902
+ __decorateClass$1([
903
+ property({ type: String })
904
+ ], DialogPortal.prototype, "env", 2);
905
+ __decorateClass$1([
906
+ property({ type: String })
907
+ ], DialogPortal.prototype, "apiKey", 2);
908
+ __decorateClass$1([
909
+ property({ type: Boolean })
910
+ ], DialogPortal.prototype, "disableTracking", 2);
911
+ __decorateClass$1([
912
+ property({ type: String })
913
+ ], DialogPortal.prototype, "trackingSource", 2);
914
+ __decorateClass$1([
915
+ property({ type: Array })
916
+ ], DialogPortal.prototype, "controls", 2);
917
+ __decorateClass$1([
918
+ property({ type: String })
919
+ ], DialogPortal.prototype, "preload", 2);
920
+ __decorateClass$1([
921
+ property({ type: Boolean })
922
+ ], DialogPortal.prototype, "disableAutoplay", 2);
923
+ __decorateClass$1([
924
+ property({ type: Number })
925
+ ], DialogPortal.prototype, "aspectRatio", 2);
926
+ __decorateClass$1([
927
+ state()
928
+ ], DialogPortal.prototype, "open", 2);
929
+ DialogPortal = __decorateClass$1([
930
+ customElement("vouch-embed-dialog-portal")
931
+ ], DialogPortal);
932
+ var __defProp = Object.defineProperty;
933
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
934
+ var __decorateClass = (decorators, target, key, kind) => {
935
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
936
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
937
+ if (decorator = decorators[i])
938
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
939
+ if (kind && result) __defProp(target, key, result);
940
+ return result;
941
+ };
942
+ let DialogEmbed = class extends LitElement {
943
+ constructor() {
944
+ super(...arguments);
945
+ this.env = "prod";
946
+ this.apiKey = "";
947
+ this.disableTracking = false;
948
+ this.trackingSource = "embedded_player";
949
+ this.preload = "none";
950
+ this.disableAutoplay = false;
951
+ this.aspectRatio = 0;
952
+ this._id = v4();
953
+ this._handleRootClick = () => {
954
+ this.dispatchEvent(new CustomEvent("dialogembed:click", { detail: this._id, bubbles: true, composed: true }));
955
+ };
956
+ }
957
+ connectedCallback() {
958
+ super.connectedCallback();
959
+ this.addEventListener("click", this._handleRootClick);
960
+ }
961
+ disconnectedCallback() {
962
+ super.disconnectedCallback();
963
+ this.removeEventListener("click", this._handleRootClick);
964
+ }
965
+ render() {
966
+ return html`
967
+ <slot>
968
+ <vmp-button size="large">Play</vmp-button>
969
+ </slot>
970
+ <vouch-embed-dialog-portal
971
+ id=${this._id}
972
+ ?autoplay=${false}
973
+ vouchId=${ifDefined(this.vouchId)}
974
+ templateId=${ifDefined(this.templateId)}
975
+ .questions=${this.questions}
976
+ .controls=${this.controls}
977
+ env=${ifDefined(this.env)}
978
+ apiKey=${ifDefined(this.apiKey)}
979
+ ?disableTracking=${this.disableTracking}
980
+ trackingSource=${ifDefined(this.trackingSource)}
981
+ preload=${ifDefined(this.preload)}
982
+ aspectRatio=${this.aspectRatio}
983
+ ></vouch-embed-dialog-portal>
984
+ `;
985
+ }
986
+ };
987
+ DialogEmbed.styles = [
988
+ css`
989
+ :host {
990
+ --vu-button-padding: 10px 20px;
991
+ --vu-button-background: #287179;
992
+ --vu-button-background-hover: #4faab2;
993
+
994
+ display: flex;
995
+ width: fit-content;
996
+ height: fit-content;
997
+ }
998
+ `
999
+ ];
1000
+ __decorateClass([
1001
+ property({ type: String })
1002
+ ], DialogEmbed.prototype, "vouchId", 2);
1003
+ __decorateClass([
1004
+ property({ type: String })
1005
+ ], DialogEmbed.prototype, "templateId", 2);
1006
+ __decorateClass([
1007
+ property({ type: Array })
1008
+ ], DialogEmbed.prototype, "questions", 2);
1009
+ __decorateClass([
1010
+ property({ type: String })
1011
+ ], DialogEmbed.prototype, "env", 2);
1012
+ __decorateClass([
1013
+ property({ type: String })
1014
+ ], DialogEmbed.prototype, "apiKey", 2);
1015
+ __decorateClass([
1016
+ property({ type: Boolean })
1017
+ ], DialogEmbed.prototype, "disableTracking", 2);
1018
+ __decorateClass([
1019
+ property({ type: String })
1020
+ ], DialogEmbed.prototype, "trackingSource", 2);
1021
+ __decorateClass([
1022
+ property({ type: Array })
1023
+ ], DialogEmbed.prototype, "controls", 2);
1024
+ __decorateClass([
1025
+ property({ type: String })
1026
+ ], DialogEmbed.prototype, "preload", 2);
1027
+ __decorateClass([
1028
+ property({ type: Boolean })
1029
+ ], DialogEmbed.prototype, "disableAutoplay", 2);
1030
+ __decorateClass([
1031
+ property({ type: Number })
1032
+ ], DialogEmbed.prototype, "aspectRatio", 2);
1033
+ DialogEmbed = __decorateClass([
1034
+ customElement("vouch-embed-dialog")
1035
+ ], DialogEmbed);
1511
1036
  export {
1512
- m as Embed
1037
+ DialogEmbed,
1038
+ PlayerEmbed
1513
1039
  };
1514
1040
  //# sourceMappingURL=embeds.js.map