@financial-times/custom-code-component 1.9.1 → 1.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,1173 @@
1
- class d extends HTMLElement {
1
+ function w(t) {
2
+ this.listenerMap = [{}, {}], t && this.root(t), this.handle = w.prototype.handle.bind(this), this._removedListeners = [];
3
+ }
4
+ w.prototype.root = function(t) {
5
+ const e = this.listenerMap;
6
+ let n;
7
+ if (this.rootElement) {
8
+ for (n in e[1])
9
+ e[1].hasOwnProperty(n) && this.rootElement.removeEventListener(n, this.handle, !0);
10
+ for (n in e[0])
11
+ e[0].hasOwnProperty(n) && this.rootElement.removeEventListener(n, this.handle, !1);
12
+ }
13
+ if (!t || !t.addEventListener)
14
+ return this.rootElement && delete this.rootElement, this;
15
+ this.rootElement = t;
16
+ for (n in e[1])
17
+ e[1].hasOwnProperty(n) && this.rootElement.addEventListener(n, this.handle, !0);
18
+ for (n in e[0])
19
+ e[0].hasOwnProperty(n) && this.rootElement.addEventListener(n, this.handle, !1);
20
+ return this;
21
+ };
22
+ w.prototype.captureForType = function(t) {
23
+ return ["blur", "error", "focus", "load", "resize", "scroll"].indexOf(t) !== -1;
24
+ };
25
+ w.prototype.on = function(t, e, n, o) {
26
+ let r, i, a, c;
27
+ if (!t)
28
+ throw new TypeError("Invalid event type: " + t);
29
+ if (typeof e == "function" && (o = n, n = e, e = null), o === void 0 && (o = this.captureForType(t)), typeof n != "function")
30
+ throw new TypeError("Handler must be a type of Function");
31
+ return r = this.rootElement, i = this.listenerMap[o ? 1 : 0], i[t] || (r && r.addEventListener(t, this.handle, o), i[t] = []), e ? /^[a-z]+$/i.test(e) ? (c = e, a = kt) : /^#[a-z0-9\-_]+$/i.test(e) ? (c = e.slice(1), a = Ct) : (c = e, a = Element.prototype.matches) : (c = null, a = Ot.bind(this)), i[t].push({
32
+ selector: e,
33
+ handler: n,
34
+ matcher: a,
35
+ matcherParam: c
36
+ }), this;
37
+ };
38
+ w.prototype.off = function(t, e, n, o) {
39
+ let r, i, a, c, s;
40
+ if (typeof e == "function" && (o = n, n = e, e = null), o === void 0)
41
+ return this.off(t, e, n, !0), this.off(t, e, n, !1), this;
42
+ if (a = this.listenerMap[o ? 1 : 0], !t) {
43
+ for (s in a)
44
+ a.hasOwnProperty(s) && this.off(s, e, n);
45
+ return this;
46
+ }
47
+ if (c = a[t], !c || !c.length)
48
+ return this;
49
+ for (r = c.length - 1; r >= 0; r--)
50
+ i = c[r], (!e || e === i.selector) && (!n || n === i.handler) && (this._removedListeners.push(i), c.splice(r, 1));
51
+ return c.length || (delete a[t], this.rootElement && this.rootElement.removeEventListener(t, this.handle, o)), this;
52
+ };
53
+ w.prototype.handle = function(t) {
54
+ let e, n;
55
+ const o = t.type;
56
+ let r, i, a, c, s = [], f;
57
+ const l = "ftLabsDelegateIgnore";
58
+ if (t[l] === !0)
59
+ return;
60
+ switch (f = t.target, f.nodeType === 3 && (f = f.parentNode), f.correspondingUseElement && (f = f.correspondingUseElement), r = this.rootElement, i = t.eventPhase || (t.target !== t.currentTarget ? 3 : 2), i) {
61
+ case 1:
62
+ s = this.listenerMap[1][o];
63
+ break;
64
+ case 2:
65
+ this.listenerMap[0] && this.listenerMap[0][o] && (s = s.concat(this.listenerMap[0][o])), this.listenerMap[1] && this.listenerMap[1][o] && (s = s.concat(this.listenerMap[1][o]));
66
+ break;
67
+ case 3:
68
+ s = this.listenerMap[0][o];
69
+ break;
70
+ }
71
+ let u = [];
72
+ for (n = s.length; f && n; ) {
73
+ for (e = 0; e < n && (a = s[e], !!a); e++)
74
+ f.tagName && ["button", "input", "select", "textarea"].indexOf(f.tagName.toLowerCase()) > -1 && f.hasAttribute("disabled") ? u = [] : a.matcher.call(f, a.matcherParam, f) && u.push([t, f, a]);
75
+ if (f === r || (n = s.length, f = f.parentElement || f.parentNode, f instanceof HTMLDocument))
76
+ break;
77
+ }
78
+ let d;
79
+ for (e = 0; e < u.length; e++)
80
+ if (!(this._removedListeners.indexOf(u[e][2]) > -1) && (c = this.fire.apply(this, u[e]), c === !1)) {
81
+ u[e][0][l] = !0, u[e][0].preventDefault(), d = !1;
82
+ break;
83
+ }
84
+ return d;
85
+ };
86
+ w.prototype.fire = function(t, e, n) {
87
+ return n.handler.call(e, t, e);
88
+ };
89
+ function kt(t, e) {
90
+ return t.toLowerCase() === e.tagName.toLowerCase();
91
+ }
92
+ function Ot(t, e) {
93
+ return this.rootElement === window ? (
94
+ // Match the outer document (dispatched from document)
95
+ e === document || // The <html> element (dispatched from document.body or document.documentElement)
96
+ e === document.documentElement || // Or the window itself (dispatched from window)
97
+ e === window
98
+ ) : this.rootElement === e;
99
+ }
100
+ function Ct(t, e) {
101
+ return t === e.id;
102
+ }
103
+ w.prototype.destroy = function() {
104
+ this.off(), this.root();
105
+ };
106
+ const z = { config: {} };
107
+ function ot(t) {
108
+ if (t === void 0)
109
+ return t;
110
+ switch (Object.prototype.toString.call(t)) {
111
+ case "[object Object]":
112
+ return JSON.parse(JSON.stringify(t));
113
+ case "[object Array]":
114
+ return [].slice.call(t);
115
+ default:
116
+ return t;
117
+ }
118
+ }
119
+ function St(t, e) {
120
+ z[t] = ot(e);
121
+ }
122
+ function At(t) {
123
+ return ot(z[t]);
124
+ }
125
+ function G(t) {
126
+ delete z[t];
127
+ }
128
+ const C = St, h = At;
129
+ let P = 0;
130
+ const W = 4, N = 36, rt = Math.pow(N, W), Q = function(e, n) {
131
+ const o = "000000000" + e;
132
+ return o.substr(o.length - n);
133
+ }, B = function() {
134
+ return Q((Math.random() * rt << 0).toString(N), W);
135
+ }, it = () => (P = P < rt ? P : 0, P++, P - 1), p = function() {
136
+ const e = "c", n = (/* @__PURE__ */ new Date()).getTime().toString(N), o = p.fingerprint(), r = B() + B(), i = Q(it().toString(N), W);
137
+ return e + n + i + o + r;
138
+ };
139
+ p.slug = function() {
140
+ const e = (/* @__PURE__ */ new Date()).getTime().toString(36), n = p.fingerprint().slice(0, 1) + p.fingerprint().slice(-1), o = B().slice(-2), r = it().toString(36).slice(-4);
141
+ return e.slice(-2) + r + n + o;
142
+ };
143
+ p.globalCount = function() {
144
+ const e = function() {
145
+ let o = 0;
146
+ for (const r in window)
147
+ o++;
148
+ return o;
149
+ }();
150
+ return p.globalCount = () => e, e;
151
+ };
152
+ p.fingerprint = function() {
153
+ return Q((navigator.mimeTypes.length + navigator.userAgent.length).toString(36) + p.globalCount().toString(36), 4);
154
+ };
155
+ const Z = [];
156
+ function _(...t) {
157
+ if (h("config").test && window.console)
158
+ for (const e of t)
159
+ window.console.log(e);
160
+ }
161
+ function y(t, e = "undefined") {
162
+ return typeof t === e;
163
+ }
164
+ function m(t, e) {
165
+ e || (e = t, t = {});
166
+ let n, o, r;
167
+ for (n in e)
168
+ o = t[n], r = e[n], t !== r && typeof r < "u" && r !== null && (t[n] = o === Object(o) && !y(o, "function") ? m(o, r) : r);
169
+ return t;
170
+ }
171
+ function K(t) {
172
+ return window.encodeURIComponent ? window.encodeURIComponent(t) : window.escape(t);
173
+ }
174
+ function Pt(t) {
175
+ return window.decodeURIComponent ? window.decodeURIComponent(t) : window.unescape(t);
176
+ }
177
+ function X(t, e, n) {
178
+ t.addEventListener ? t.addEventListener(e, n, !1) : t.attachEvent("on" + e, n);
179
+ }
180
+ function v(t, e, n) {
181
+ n = n || {};
182
+ try {
183
+ window.dispatchEvent(new CustomEvent(t + "." + e, {
184
+ detail: n,
185
+ bubbles: !0
186
+ }));
187
+ } catch {
188
+ }
189
+ }
190
+ function _t() {
191
+ for (let t = 0; t < Z.length; t++)
192
+ Z[t]();
193
+ }
194
+ function tt(t) {
195
+ return document.cookie.match(t) && RegExp.$1 !== "" && RegExp.$1 !== "null" ? RegExp.$1 : null;
196
+ }
197
+ function $t(t, e) {
198
+ const n = {};
199
+ for (const o of e)
200
+ t[o] && (n[o] = t[o]);
201
+ return n;
202
+ }
203
+ function j(t) {
204
+ return typeof t == "string" ? t.trim() : t;
205
+ }
206
+ function $(t, e) {
207
+ for (const n in t)
208
+ e[n] ? console.warn(`You can't set a custom property called ${n}`) : e[n] = t[n];
209
+ }
210
+ function st(t) {
211
+ const e = /* @__PURE__ */ new WeakSet(), n = [];
212
+ function o(r, i) {
213
+ if (e.has(r)) {
214
+ n.push(i);
215
+ return;
216
+ }
217
+ if (r instanceof Object) {
218
+ e.add(r);
219
+ for (const [a, c] of Object.entries(r))
220
+ c instanceof Object && (Array.isArray(r) ? o(c, `${i}[${a}]`) : o(c, `${i}.${a}`));
221
+ }
222
+ }
223
+ return o(t, ""), n;
224
+ }
225
+ function at(t) {
226
+ const e = /* @__PURE__ */ new WeakSet();
227
+ function n(o) {
228
+ if (e.has(o))
229
+ return !0;
230
+ if (o instanceof Object) {
231
+ e.add(o);
232
+ for (const r of Object.values(o))
233
+ if (r instanceof Object && n(r))
234
+ return !0;
235
+ }
236
+ }
237
+ return !!n(
238
+ t
239
+ );
240
+ }
241
+ function H(t, e) {
242
+ if (t === e)
243
+ return !0;
244
+ if (t && e && typeof t == "object" && typeof e == "object") {
245
+ if (t.constructor !== e.constructor)
246
+ return !1;
247
+ if (Array.isArray(t)) {
248
+ const r = t.length;
249
+ if (r !== e.length)
250
+ return !1;
251
+ for (let i = r; i-- !== 0; )
252
+ if (!H(t[i], e[i]))
253
+ return !1;
254
+ return !0;
255
+ }
256
+ if (t.constructor === RegExp)
257
+ return t.source === e.source && t.flags === e.flags;
258
+ if (t.valueOf !== Object.prototype.valueOf)
259
+ return t.valueOf() === e.valueOf();
260
+ if (t.toString !== Object.prototype.toString)
261
+ return t.toString() === e.toString();
262
+ const n = Object.keys(t), o = n.length;
263
+ if (o !== Object.keys(e).length)
264
+ return !1;
265
+ for (let r = o; r-- !== 0; )
266
+ if (!Object.prototype.hasOwnProperty.call(e, n[r]))
267
+ return !1;
268
+ for (let r = o; r-- !== 0; ) {
269
+ const i = n[r];
270
+ if (!H(t[i], e[i]))
271
+ return !1;
272
+ }
273
+ return !0;
274
+ }
275
+ }
276
+ const A = function(t, e = {}) {
277
+ const n = "o-tracking";
278
+ if (typeof t != "string" || t === "") {
279
+ const s = new Error("You must specify a name for the store.");
280
+ throw v("oErrors", "log", {
281
+ error: s.message,
282
+ info: { module: "o-tracking" }
283
+ }), s;
284
+ }
285
+ this.config = Object.assign({}, e), this.data = null, this.storageKey = this.config.nameOverride ? this.config.nameOverride : [n, t].join("_"), this.storage = {
286
+ _type: "localStorage",
287
+ load: function(s) {
288
+ return window.localStorage.getItem(s);
289
+ },
290
+ save: function(s, f) {
291
+ return window.localStorage.setItem(s, f);
292
+ },
293
+ remove: function(s) {
294
+ return i(s), window.localStorage.removeItem(s);
295
+ }
296
+ };
297
+ function o(s) {
298
+ s = s + "=";
299
+ const f = window.document.cookie.split(";");
300
+ let l, u;
301
+ for (l = 0; l < f.length; l = l + 1)
302
+ if (u = f[l].replace(/^\s+|\s+$/g, ""), u.indexOf(s) === 0)
303
+ return Pt(u.substring(s.length, u.length));
304
+ return null;
305
+ }
306
+ function r(s, f, l) {
307
+ let u, d = "";
308
+ y(l, "number") && (u = /* @__PURE__ */ new Date(), u.setTime(u.getTime() + l), d = "expires=" + u.toUTCString() + ";");
309
+ const xt = K(s) + "=" + K(f) + ";" + d + "path=/;" + (e.domain ? "domain=." + e.domain + ";" : "");
310
+ window.document.cookie = xt;
311
+ }
312
+ function i(s) {
313
+ r(s, "", -1);
314
+ }
315
+ const a = this.storage.load(this.storageKey);
316
+ if (a)
317
+ try {
318
+ this.data = JSON.parse(a);
319
+ } catch (s) {
320
+ v("oErrors", "log", {
321
+ error: s.message,
322
+ module: "o-tracking"
323
+ }), this.data = a;
324
+ }
325
+ const c = o(this.storageKey);
326
+ if (c)
327
+ try {
328
+ if (this.storageKey === "spoor-id")
329
+ this.data = c;
330
+ else {
331
+ const s = JSON.parse(c);
332
+ this.data ? Object.assign(this.data, s) : this.data = s;
333
+ for (const f of Object.keys(s))
334
+ f !== "spoor-id" && i(f);
335
+ }
336
+ } catch (s) {
337
+ v("oErrors", "log", {
338
+ error: s.message,
339
+ module: "o-tracking"
340
+ }), this.data = a;
341
+ }
342
+ return this;
343
+ };
344
+ A.prototype.read = function() {
345
+ return this.data;
346
+ };
347
+ A.prototype.write = function(t) {
348
+ this.data = t;
349
+ let e;
350
+ if (typeof this.data == "string")
351
+ e = this.data;
352
+ else {
353
+ if (at(this.data)) {
354
+ const n = `o-tracking does not support circular references in the analytics data.
355
+ Please remove the circular references in the data.
356
+ Here are the paths in the data which are circular:
357
+ ` + JSON.stringify(st(this.data), void 0, 4);
358
+ throw new Error(n);
359
+ }
360
+ e = JSON.stringify(this.data);
361
+ }
362
+ return this.storage.save(this.storageKey, e), this;
363
+ };
364
+ A.prototype.destroy = function() {
365
+ return this.data = null, this.storage.remove(this.storageKey), this;
366
+ };
367
+ let O, F;
368
+ function Nt(t, e) {
369
+ const n = {
370
+ storage: "cookie",
371
+ name: "spoor-id",
372
+ nameOverride: "spoor-id",
373
+ value: null,
374
+ // Set the store cookie domain to .ft.com for ft.com and all its subdomains
375
+ domain: location.hostname.match(/^(?:.+\.)?ft\.com$/) ? "ft.com" : null
376
+ };
377
+ e && (n.domain = e), F = new A(n.name, n);
378
+ let o = F.read();
379
+ return o || (o = t), ct(o);
380
+ }
381
+ function ct(t) {
382
+ return O = t, O || (O = p()), F.write(O), O;
383
+ }
384
+ function Lt() {
385
+ return O;
386
+ }
387
+ let L;
388
+ const It = {
389
+ storage: "best",
390
+ name: "session",
391
+ expires: 30 * 60 * 1e3
392
+ // 30 minutes
393
+ };
394
+ function Dt(t) {
395
+ const e = /* @__PURE__ */ new Date();
396
+ e.setTime(e.getTime() + L.config.expires), L.write({
397
+ value: t,
398
+ expiry: e.valueOf()
399
+ });
400
+ }
401
+ function ft() {
402
+ const t = L.read();
403
+ let e, n = !1;
404
+ if (t) {
405
+ const o = (/* @__PURE__ */ new Date()).valueOf();
406
+ parseInt(t.expiry, 10) >= o ? e = t.value : (e = p(), n = !0);
407
+ }
408
+ return e || (e = p(), n = !0), Dt(e), {
409
+ id: e,
410
+ isNew: n
411
+ };
412
+ }
413
+ function Tt(t) {
414
+ y(t, "string") && (t = { name: t }), y(t) && (t = {});
415
+ const e = m(It, t);
416
+ return e.storage === "cookie" && t.name && (e.nameOverride = e.name), L = new A(e.name, e), ft();
417
+ }
418
+ function b(t) {
419
+ if (y(t)) {
420
+ const e = new Error("You must specify a name for the queue.");
421
+ throw v("oErrors", "log", {
422
+ error: e.message,
423
+ info: { module: "o-tracking" }
424
+ }), e;
425
+ }
426
+ return this.queue = [], this.storage = new A(t), this.storage.read() && (this.queue = this.storage.read()), this;
427
+ }
428
+ b.prototype.all = function() {
429
+ if (this.queue.length === 0)
430
+ return [];
431
+ const t = [];
432
+ for (let e = 0; e < this.queue.length; e = e + 1)
433
+ t.push(this.queue[e].item);
434
+ return t;
435
+ };
436
+ b.prototype.first = function() {
437
+ return this.queue.length === 0 ? null : this.queue[0].item;
438
+ };
439
+ b.prototype.last = function() {
440
+ return this.queue.length === 0 ? null : this.queue.slice(-1)[0].item;
441
+ };
442
+ b.prototype.add = function(t) {
443
+ const e = this;
444
+ let n;
445
+ function o(r) {
446
+ e.queue.push({
447
+ created_at: (/* @__PURE__ */ new Date()).valueOf(),
448
+ item: r
449
+ });
450
+ }
451
+ if (y(t, "object") && t.constructor.toString().match(/array/i))
452
+ for (n = 0; n < t.length; n = n + 1)
453
+ o(t[n]);
454
+ else
455
+ o(t);
456
+ return e;
457
+ };
458
+ b.prototype.replace = function(t) {
459
+ if (Array.isArray(t))
460
+ return this.queue = [], this.add(t).save(), this;
461
+ const e = new Error("Argument invalid, must be an array.");
462
+ throw v("oErrors", "log", {
463
+ error: e.message,
464
+ info: { module: "o-tracking" }
465
+ }), e;
466
+ };
467
+ b.prototype.shift = function() {
468
+ if (this.queue.length === 0)
469
+ return null;
470
+ const t = this.queue.shift().item;
471
+ return this.save(), t;
472
+ };
473
+ b.prototype.save = function() {
474
+ return this.storage.write(this.queue), this;
475
+ };
476
+ function Mt() {
477
+ const t = new window.XMLHttpRequest();
478
+ return {
479
+ name: "xhr",
480
+ send: function(e, n) {
481
+ t.open("POST", e, !0), t.withCredentials = !0, t.setRequestHeader("Content-type", "application/json"), t.send(n);
482
+ },
483
+ complete: function(e) {
484
+ t.onerror = function() {
485
+ e(this);
486
+ }, t.onload = function() {
487
+ t.status >= 200 && t.status < 300 ? e() : e("Incorrect response: " + t.status);
488
+ };
489
+ }
490
+ };
491
+ }
492
+ function Rt() {
493
+ let t, e;
494
+ const n = new Promise((o, r) => {
495
+ t = o, e = r;
496
+ });
497
+ return {
498
+ name: "sendBeacon",
499
+ send: function(o, r) {
500
+ navigator.sendBeacon(o, r) ? t() : e(new Error("Failed to send beacon event: " + r.toString()));
501
+ },
502
+ complete: function(o) {
503
+ o && n.then(o, o);
504
+ }
505
+ };
506
+ }
507
+ function jt() {
508
+ const t = new Image(1, 1);
509
+ return {
510
+ name: "image",
511
+ send: function(e, n) {
512
+ e = e.replace("https://spoor-api.ft.com/ingest", "https://spoor-api.ft.com/px.gif"), t.src = e + (e.indexOf("?") > -1 ? "&" : "?") + "data=" + K(n);
513
+ },
514
+ complete: function(e) {
515
+ t.addEventListener ? (t.addEventListener("error", e), t.addEventListener("load", () => e())) : (t.attachEvent("onerror", e), t.attachEvent("onload", () => e()));
516
+ }
517
+ };
518
+ }
519
+ const et = {};
520
+ function V(t) {
521
+ if (et.transport)
522
+ return et.transport;
523
+ switch (t) {
524
+ case "xhr":
525
+ return Mt;
526
+ case "sendBeacon":
527
+ return Rt;
528
+ case "image":
529
+ return jt;
530
+ default:
531
+ return;
532
+ }
533
+ }
534
+ let g;
535
+ function ut() {
536
+ return (h("config") || {}).queue === !0 ? !1 : !!navigator.sendBeacon;
537
+ }
538
+ function lt(t, e) {
539
+ const n = t.queueTime, o = (/* @__PURE__ */ new Date()).getTime() - n, r = ut() ? V("sendBeacon")() : window.XMLHttpRequest && "withCredentials" in new window.XMLHttpRequest() ? V("xhr")() : V("image")(), i = t.callback, a = h("config") && h("config").system || {}, c = m(a, {
540
+ version: h("version"),
541
+ // Version of the tracking client e.g. '1.2'
542
+ source: h("source"),
543
+ // Source of the tracking client e.g. 'o-tracking'
544
+ transport: r.name
545
+ // The transport method used.
546
+ });
547
+ if (h("config").test || h("config").test_data ? c.is_live = !1 : c.is_live = !0, t = m({ system: c }, t), o > 1e3 && o < 12 * 30 * 24 * 60 * 60 * 1e3 && (t.time = t.time || {}, t.time.offset = o), delete t.callback, delete t.type, delete t.queueTime, _("user_callback", i), _("PreSend", t), at(t)) {
548
+ const l = `o-tracking does not support circular references in the analytics data.
549
+ Please remove the circular references in the data.
550
+ Here are the paths in the data which are circular:
551
+ ` + JSON.stringify(st(t), void 0, 4);
552
+ throw new Error(l);
553
+ }
554
+ const s = JSON.stringify(t);
555
+ r.complete(function(l) {
556
+ y(i, "function") && (i.call(t), _("calling user_callback")), l ? (t.queueTime = n, g.add(t).save(), v("oErrors", "log", {
557
+ error: l.message,
558
+ info: { module: "o-tracking" }
559
+ })) : e && e();
560
+ });
561
+ let f = "https://spoor-api.ft.com/ingest";
562
+ t && t.category && t.action && (f += `?type=${t.category}:${t.action}`), r.send(f, s);
563
+ }
564
+ function Jt(t) {
565
+ t.queueTime = (/* @__PURE__ */ new Date()).getTime(), ut() ? lt(t) : g.add(t).save(), _("AddedToQueue", g);
566
+ }
567
+ function I(t = function() {
568
+ }) {
569
+ const e = g.all();
570
+ if (e.length > 200) {
571
+ const r = {};
572
+ e.forEach(function(i) {
573
+ const a = [i.category, i.action].join(":");
574
+ Object.prototype.hasOwnProperty.call(r, a) || (r[a] = 0), r[a] += 1;
575
+ }), g.replace([]), g.add({
576
+ category: "o-tracking",
577
+ action: "queue-bug",
578
+ context: {
579
+ url: document.URL,
580
+ queue_length: e.length,
581
+ counts: r,
582
+ storage: g.storage.storage._type
583
+ }
584
+ });
585
+ }
586
+ const n = function() {
587
+ I(), t();
588
+ }, o = g.shift();
589
+ return o ? lt(o, n) : t();
590
+ }
591
+ function Ut(t) {
592
+ Jt(t), I();
593
+ }
594
+ function Vt() {
595
+ return g = new b("requests"), X(window, "online", function() {
596
+ I();
597
+ }), I(), g;
598
+ }
599
+ let D;
600
+ function dt() {
601
+ return D = p(), D;
602
+ }
603
+ function ht() {
604
+ return D || dt(), D;
605
+ }
606
+ function qt(t, e = function() {
607
+ }) {
608
+ const n = ft(), o = {
609
+ callback: e,
610
+ context: {
611
+ id: t.id || p(),
612
+ // Use a supplied id or generate one for this request
613
+ root_id: ht()
614
+ },
615
+ user: {
616
+ ft_session: tt(/FTSession=([^;]+)/),
617
+ ft_session_s: tt(/FTSession_s=([^;]+)/)
618
+ },
619
+ device: {
620
+ spoor_session: n.id,
621
+ spoor_session_is_new: n.isNew,
622
+ spoor_id: Lt()
623
+ }
624
+ }, r = h("config") || {};
625
+ return r.context && m(o.context, r.context), r.user && m(o.user, r.user), r.device && m(o.device, r.device), m(o, t), _("Core.Track", o), Ut(o), o;
626
+ }
627
+ const x = {
628
+ setRootID: dt,
629
+ getRootID: ht,
630
+ track: qt
631
+ }, Bt = function() {
632
+ return {
633
+ category: "event",
634
+ action: "generic",
635
+ context: {}
636
+ };
637
+ };
638
+ function J(t, e) {
639
+ if (y(t.detail.category) || y(t.detail.action)) {
640
+ const r = "Missing category or action values";
641
+ throw v("oErrors", "log", {
642
+ error: r,
643
+ info: { module: "o-tracking" }
644
+ }), r;
645
+ }
646
+ const n = m(Bt(), {
647
+ category: t.detail.category,
648
+ action: t.detail.action,
649
+ context: t.detail
650
+ });
651
+ delete n.context.category, delete n.context.action;
652
+ const o = Kt(t);
653
+ o && (n.context.component_name = o.getAttribute("data-o-component"), n.context.component_id = n.context.component_id || Ht(o)), x.track(n, e);
654
+ }
655
+ function Kt(t) {
656
+ const e = t.target || t.srcElement;
657
+ if (e && e.getAttribute("data-o-component"))
658
+ return e;
659
+ }
660
+ function Ht(t) {
661
+ const e = Ft(t);
662
+ if (typeof e > "u")
663
+ return;
664
+ const n = e[0], o = function(a) {
665
+ const c = a.parentElement;
666
+ if (c) {
667
+ for (let s = 0; s < c.childNodes.length; s++)
668
+ if (c.childNodes[s] === n)
669
+ return s;
670
+ return -1;
671
+ } else
672
+ return 0;
673
+ }(n), r = e.reduceRight(function(i, a) {
674
+ if (!a.nodeName)
675
+ return i + " - " + a.constructor.name + `
676
+ `;
677
+ const c = a.nodeName.toLowerCase();
678
+ return c.indexOf("#") === 0 ? i + "<" + c + ">" : i + "<" + c + ' id="' + (a.id || "") + '">';
679
+ }, "");
680
+ return zt(r + "_siblingIndex=" + o);
681
+ }
682
+ function Ft(t) {
683
+ const e = [];
684
+ for (; t; )
685
+ e.push(t), t = t.parentElement;
686
+ return e;
687
+ }
688
+ function zt(t) {
689
+ let e = t.length, n = 1 ^ e, o = 0, r;
690
+ for (; e >= 4; )
691
+ r = t.charCodeAt(o) & 255 | (t.charCodeAt(++o) & 255) << 8 | (t.charCodeAt(++o) & 255) << 16 | (t.charCodeAt(++o) & 255) << 24, r = (r & 65535) * 1540483477 + (((r >>> 16) * 1540483477 & 65535) << 16), r ^= r >>> 24, r = (r & 65535) * 1540483477 + (((r >>> 16) * 1540483477 & 65535) << 16), n = (n & 65535) * 1540483477 + (((n >>> 16) * 1540483477 & 65535) << 16) ^ r, e -= 4, ++o;
692
+ switch (e) {
693
+ case 3:
694
+ n ^= (t.charCodeAt(o + 2) & 255) << 16;
695
+ break;
696
+ case 2:
697
+ n ^= (t.charCodeAt(o + 1) & 255) << 8;
698
+ break;
699
+ case 1:
700
+ n ^= t.charCodeAt(o) & 255, n = (n & 65535) * 1540483477 + (((n >>> 16) * 1540483477 & 65535) << 16);
701
+ break;
702
+ }
703
+ return n ^= n >>> 13, n = (n & 65535) * 1540483477 + (((n >>> 16) * 1540483477 & 65535) << 16), n ^= n >>> 15, n >>> 0;
704
+ }
705
+ const Wt = function() {
706
+ X(window, "oTracking.event", J);
707
+ };
708
+ J.init = Wt;
709
+ C("page_has_already_been_viewed", !1);
710
+ const Qt = function() {
711
+ return {
712
+ category: "page",
713
+ action: "view",
714
+ context: {
715
+ url: document.URL,
716
+ referrer: document.referrer
717
+ }
718
+ };
719
+ };
720
+ function U(t, e) {
721
+ t = m(Qt(), {
722
+ context: t
723
+ }), h("page_has_already_been_viewed") && x.setRootID(), C("page_has_already_been_viewed", !0), Xt(t) ? h("config").test && console.warn("A page event has already been sent for this page, refusing to send a duplicate page event.") : (x.track(t, e), _t());
724
+ }
725
+ let nt = {};
726
+ function Xt(t) {
727
+ const e = JSON.parse(JSON.stringify(t));
728
+ return delete e.context.id, delete e.context.root_id, H(nt, e) ? !0 : (nt = e, !1);
729
+ }
730
+ function Yt(t) {
731
+ U(t.detail);
732
+ }
733
+ const Gt = function() {
734
+ X(window, "oTracking.page", Yt);
735
+ };
736
+ U.init = Gt;
737
+ function E(t) {
738
+ this.listenerMap = [{}, {}], t && this.root(t), this.handle = E.prototype.handle.bind(this), this._removedListeners = [];
739
+ }
740
+ E.prototype.root = function(t) {
741
+ const e = this.listenerMap;
742
+ let n;
743
+ if (this.rootElement) {
744
+ for (n in e[1])
745
+ e[1].hasOwnProperty(n) && this.rootElement.removeEventListener(n, this.handle, !0);
746
+ for (n in e[0])
747
+ e[0].hasOwnProperty(n) && this.rootElement.removeEventListener(n, this.handle, !1);
748
+ }
749
+ if (!t || !t.addEventListener)
750
+ return this.rootElement && delete this.rootElement, this;
751
+ this.rootElement = t;
752
+ for (n in e[1])
753
+ e[1].hasOwnProperty(n) && this.rootElement.addEventListener(n, this.handle, !0);
754
+ for (n in e[0])
755
+ e[0].hasOwnProperty(n) && this.rootElement.addEventListener(n, this.handle, !1);
756
+ return this;
757
+ };
758
+ E.prototype.captureForType = function(t) {
759
+ return ["blur", "error", "focus", "load", "resize", "scroll"].indexOf(t) !== -1;
760
+ };
761
+ E.prototype.on = function(t, e, n, o) {
762
+ let r, i, a, c;
763
+ if (!t)
764
+ throw new TypeError("Invalid event type: " + t);
765
+ if (typeof e == "function" && (o = n, n = e, e = null), o === void 0 && (o = this.captureForType(t)), typeof n != "function")
766
+ throw new TypeError("Handler must be a type of Function");
767
+ return r = this.rootElement, i = this.listenerMap[o ? 1 : 0], i[t] || (r && r.addEventListener(t, this.handle, o), i[t] = []), e ? /^[a-z]+$/i.test(e) ? (c = e, a = Zt) : /^#[a-z0-9\-_]+$/i.test(e) ? (c = e.slice(1), a = ee) : (c = e, a = Element.prototype.matches) : (c = null, a = te.bind(this)), i[t].push({
768
+ selector: e,
769
+ handler: n,
770
+ matcher: a,
771
+ matcherParam: c
772
+ }), this;
773
+ };
774
+ E.prototype.off = function(t, e, n, o) {
775
+ let r, i, a, c, s;
776
+ if (typeof e == "function" && (o = n, n = e, e = null), o === void 0)
777
+ return this.off(t, e, n, !0), this.off(t, e, n, !1), this;
778
+ if (a = this.listenerMap[o ? 1 : 0], !t) {
779
+ for (s in a)
780
+ a.hasOwnProperty(s) && this.off(s, e, n);
781
+ return this;
782
+ }
783
+ if (c = a[t], !c || !c.length)
784
+ return this;
785
+ for (r = c.length - 1; r >= 0; r--)
786
+ i = c[r], (!e || e === i.selector) && (!n || n === i.handler) && (this._removedListeners.push(i), c.splice(r, 1));
787
+ return c.length || (delete a[t], this.rootElement && this.rootElement.removeEventListener(t, this.handle, o)), this;
788
+ };
789
+ E.prototype.handle = function(t) {
790
+ let e, n;
791
+ const o = t.type;
792
+ let r, i, a, c, s = [], f;
793
+ const l = "ftLabsDelegateIgnore";
794
+ if (t[l] === !0)
795
+ return;
796
+ switch (f = t.target, f.nodeType === 3 && (f = f.parentNode), f.correspondingUseElement && (f = f.correspondingUseElement), r = this.rootElement, i = t.eventPhase || (t.target !== t.currentTarget ? 3 : 2), i) {
797
+ case 1:
798
+ s = this.listenerMap[1][o];
799
+ break;
800
+ case 2:
801
+ this.listenerMap[0] && this.listenerMap[0][o] && (s = s.concat(this.listenerMap[0][o])), this.listenerMap[1] && this.listenerMap[1][o] && (s = s.concat(this.listenerMap[1][o]));
802
+ break;
803
+ case 3:
804
+ s = this.listenerMap[0][o];
805
+ break;
806
+ }
807
+ let u = [];
808
+ for (n = s.length; f && n; ) {
809
+ for (e = 0; e < n && (a = s[e], !!a); e++)
810
+ f.tagName && ["button", "input", "select", "textarea"].indexOf(f.tagName.toLowerCase()) > -1 && f.hasAttribute("disabled") ? u = [] : a.matcher.call(f, a.matcherParam, f) && u.push([t, f, a]);
811
+ if (f === r || (n = s.length, f = f.parentElement || f.parentNode, f instanceof HTMLDocument))
812
+ break;
813
+ }
814
+ let d;
815
+ for (e = 0; e < u.length; e++)
816
+ if (!(this._removedListeners.indexOf(u[e][2]) > -1) && (c = this.fire.apply(this, u[e]), c === !1)) {
817
+ u[e][0][l] = !0, u[e][0].preventDefault(), d = !1;
818
+ break;
819
+ }
820
+ return d;
821
+ };
822
+ E.prototype.fire = function(t, e, n) {
823
+ return n.handler.call(e, t, e);
824
+ };
825
+ function Zt(t, e) {
826
+ return t.toLowerCase() === e.tagName.toLowerCase();
827
+ }
828
+ function te(t, e) {
829
+ return this.rootElement === window ? (
830
+ // Match the outer document (dispatched from document)
831
+ e === document || // The <html> element (dispatched from document.body or document.documentElement)
832
+ e === document.documentElement || // Or the window itself (dispatched from window)
833
+ e === window
834
+ ) : this.rootElement === e;
835
+ }
836
+ function ee(t, e) {
837
+ return t === e.id;
838
+ }
839
+ E.prototype.destroy = function() {
840
+ this.off(), this.root();
841
+ };
842
+ const ne = (t, e, n) => {
843
+ const o = Array.from(t.querySelectorAll(n)), r = o.findIndex((i) => i === e);
844
+ if (r !== -1)
845
+ return {
846
+ siblings: o.length,
847
+ position: r
848
+ };
849
+ }, pt = [
850
+ "nodeName",
851
+ "className",
852
+ "id",
853
+ "href",
854
+ "text",
855
+ "role"
856
+ ], oe = (t) => {
857
+ const e = {};
858
+ for (const n of pt) {
859
+ const o = t[n] || t.getAttribute(n) || t.hasAttribute(n);
860
+ o !== void 0 && (typeof o == "boolean" ? e[n] = o : e[n] = j(o));
861
+ }
862
+ return e;
863
+ }, re = (t) => {
864
+ try {
865
+ const e = JSON.parse(t), n = Object.prototype.toString.call(e);
866
+ return [n === "[object Object]" || n === "[object Array]", e];
867
+ } catch {
868
+ return [!1, null];
869
+ }
870
+ }, ie = (t) => {
871
+ const [e, n] = re(t);
872
+ return e ? n : t;
873
+ }, se = (t, e) => (t.filter((n) => n.name.match(/^data-trackable|^data-o-|^aria-/i)).forEach((n) => {
874
+ e[n.name] = n.value;
875
+ }), e), ae = (t, e, n) => {
876
+ const o = {};
877
+ return n && pt.forEach((r) => {
878
+ typeof e[r] < "u" && r !== "id" && (o[r] = e[r]);
879
+ }), t.filter((r) => r.name.match(/^data-trackable-context-/i)).forEach((r) => {
880
+ o[r.name.replace("data-trackable-context-", "")] = ie(r.value);
881
+ }), o;
882
+ };
883
+ function mt(t) {
884
+ const e = document, n = t, o = n.getAttribute("data-trackable") ? `[data-trackable="${n.getAttribute("data-trackable")}"]` : n.nodeName, r = [], i = {};
885
+ for (; t && t !== e; ) {
886
+ const a = oe(t), c = Array.from(t.attributes);
887
+ let s = se(c, a);
888
+ s["data-trackable"] && (s = Object.assign(
889
+ s,
890
+ ne(t, n, o)
891
+ )), r.push(s);
892
+ const f = ae(c, a, t === n);
893
+ $(f, i), t = t.parentNode;
894
+ }
895
+ return { trace: r, customContext: i };
896
+ }
897
+ let q;
898
+ const ce = [
899
+ "ctrlKey",
900
+ "altKey",
901
+ "shiftKey",
902
+ "metaKey"
903
+ ], fe = (t) => {
904
+ const e = {};
905
+ for (const n of ce)
906
+ if (t[n])
907
+ try {
908
+ e[n] = j(t[n]);
909
+ } catch (o) {
910
+ console.log(o);
911
+ }
912
+ return e;
913
+ }, ue = (t) => (e, n) => {
914
+ if (n.getAttribute("data-o-tracking-do-not-track") === "true")
915
+ return;
916
+ const o = fe(e), { trace: r, customContext: i } = mt(n);
917
+ o.domPathTokens = r, o.url = window.document.location.href || null, o.source_id = x.getRootID(), $(i, o), t.context = o;
918
+ const a = m(h("config"), t);
919
+ x.track(a);
920
+ }, le = (t, e) => {
921
+ e = e || 'a, button, input, [role="button"]';
922
+ const n = {
923
+ action: "click",
924
+ category: t || "o-tracking"
925
+ };
926
+ q = q || new E(document.body), q.on("click", e, ue(n), !0);
927
+ const o = new b("clicks");
928
+ gt(o);
929
+ };
930
+ function gt(t) {
931
+ const e = t.shift();
932
+ e && x.track(e, () => gt(t));
933
+ }
934
+ const de = {
935
+ init: le
936
+ }, he = [
937
+ "componentContentId",
938
+ "type",
939
+ "subtype",
940
+ "component"
941
+ ], pe = (t, e, n) => {
942
+ const { trace: o, customContext: r } = mt(e);
943
+ let i;
944
+ if (n.getContextData) {
945
+ if (typeof n.getContextData != "function")
946
+ throw new Error("opts.getContextData is not a function");
947
+ const a = n.getContextData(e);
948
+ if (typeof a != "object")
949
+ throw new Error("opts.getContextData function should return {object}");
950
+ i = $t(a, he);
951
+ } else
952
+ i = {};
953
+ i.domPathTokens = o, i.url = window.document.location.href || null, $(r, i), t.context = i;
954
+ }, me = (t = {}) => {
955
+ if (!window.IntersectionObserver) {
956
+ console.warn('o-tracking: Unable to track component view events as "window.IntersectionObserver" is not supported.');
957
+ return;
958
+ }
959
+ const e = t.selector || "[data-o-tracking-view]", n = [...document.querySelectorAll(e)];
960
+ if (!n.length)
961
+ return;
962
+ function o(i) {
963
+ i.forEach((a) => {
964
+ if (a.isIntersecting || a.intersectionRatio > 0) {
965
+ const c = {
966
+ action: t.action || "view",
967
+ category: t.category || "component"
968
+ }, s = a.target;
969
+ pe(c, s, t), x.track(c), r.unobserve(s);
970
+ }
971
+ });
972
+ }
973
+ const r = new IntersectionObserver(o, { threshold: [1] });
974
+ n.forEach((i) => r.observe(i));
975
+ }, ge = {
976
+ init: me
977
+ }, ye = J.init, we = U.init, Y = "4.5.4", yt = "o-tracking";
978
+ function wt(t) {
979
+ let e = h("config") || {};
980
+ e = m(e, t), C("config", e), e.user && e.user.user_id && ct(e.user.user_id);
981
+ }
982
+ function be() {
983
+ k.initialised = !1, G("config"), G("page_sent");
984
+ }
985
+ function Ee() {
986
+ return "oTracking version " + Y;
987
+ }
988
+ function ve(t = {}) {
989
+ if (k.initialised)
990
+ return k;
991
+ if (!!bt() && (t = xe(t)), Object.keys(t).length === 0 && t.constructor === Object)
992
+ return null;
993
+ C("version", Y), C("source", yt), C("page_sent", !1);
994
+ const n = t ? t.cookieDomain : "";
995
+ return Nt("", n), wt(t), Tt(t.session), Vt(), ye(), we(), k.initialised = !0, k;
996
+ }
997
+ function bt() {
998
+ return document.querySelector("script[data-o-tracking-config]");
999
+ }
1000
+ function xe(t) {
1001
+ const e = bt();
1002
+ let n;
1003
+ if (e)
1004
+ n = e.textContent || e.innerText || e.innerHTML;
1005
+ else
1006
+ return !1;
1007
+ try {
1008
+ const o = JSON.parse(n);
1009
+ Object.assign(t, o);
1010
+ } catch (o) {
1011
+ const r = new Error('Invalid JSON configuration syntax, check validity for o-tracking configuration: "' + o.message + '"');
1012
+ throw v("oErrors", "log", {
1013
+ error: r.message,
1014
+ info: { module: "o-tracking" }
1015
+ }), r;
1016
+ }
1017
+ return t;
1018
+ }
1019
+ const k = {
1020
+ /**
1021
+ * The initialised state of the object.
1022
+ *
1023
+ * @type {boolean}
1024
+ */
1025
+ initialised: !1,
1026
+ version: Y,
1027
+ updateConfig: wt,
1028
+ source: yt,
1029
+ destroy: be,
1030
+ toString: Ee,
1031
+ init: ve,
1032
+ click: de,
1033
+ event: J,
1034
+ page: U,
1035
+ view: ge,
1036
+ getRootID: x.getRootID
1037
+ };
1038
+ function Et() {
1039
+ k.init(), document.removeEventListener("o.DOMContentLoaded", Et);
1040
+ }
1041
+ typeof document < "u" && document.addEventListener("o.DOMContentLoaded", Et);
1042
+ const ke = (t, e, n) => {
1043
+ const o = Array.from(t.querySelectorAll(n)), r = o.findIndex((i) => i === e);
1044
+ if (r !== -1)
1045
+ return {
1046
+ siblings: o.length,
1047
+ position: r
1048
+ };
1049
+ }, vt = [
1050
+ "nodeName",
1051
+ "className",
1052
+ "id",
1053
+ "href",
1054
+ "text",
1055
+ "role"
1056
+ ], Oe = (t) => {
1057
+ const e = {};
1058
+ for (const n of vt) {
1059
+ const o = t[n] || t.getAttribute(n) || t.hasAttribute(n);
1060
+ o !== void 0 && (typeof o == "boolean" ? e[n] = o : e[n] = j(o));
1061
+ }
1062
+ return e;
1063
+ }, Ce = (t) => {
1064
+ try {
1065
+ const e = JSON.parse(t), n = Object.prototype.toString.call(e);
1066
+ return [n === "[object Object]" || n === "[object Array]", e];
1067
+ } catch {
1068
+ return [!1, null];
1069
+ }
1070
+ }, Se = (t) => {
1071
+ const [e, n] = Ce(t);
1072
+ return e ? n : t;
1073
+ }, Ae = (t, e) => (t.filter(
1074
+ (n) => n.name.match(/^data-trackable|^data-o-|^aria-/i)
1075
+ ).forEach((n) => {
1076
+ e[n.name] = n.value;
1077
+ }), e), Pe = (t, e, n) => {
1078
+ const o = {};
1079
+ return n && vt.forEach((r) => {
1080
+ typeof e[r] < "u" && r !== "id" && (o[r] = e[r]);
1081
+ }), t.filter((r) => r.name.match(/^data-trackable-context-/i)).forEach((r) => {
1082
+ o[r.name.replace("data-trackable-context-", "")] = Se(r.value);
1083
+ }), o;
1084
+ };
1085
+ function _e(t, e) {
1086
+ const n = t, o = n.getAttribute("data-trackable") ? `[data-trackable="${n.getAttribute("data-trackable")}"]` : n.nodeName, r = [], i = {};
1087
+ for (; t && t !== e; ) {
1088
+ const a = Oe(t), c = Array.from(t.attributes);
1089
+ let s = Ae(c, a);
1090
+ s["data-trackable"] && (s = Object.assign(
1091
+ s,
1092
+ ke(t, n, o)
1093
+ )), r.push(s);
1094
+ const f = Pe(c, a, t === n);
1095
+ $(f, i), t = t.parentNode;
1096
+ }
1097
+ return { trace: r, customContext: i };
1098
+ }
1099
+ let S = "ccc-component", T = "interactive";
1100
+ const $e = ["ctrlKey", "altKey", "shiftKey", "metaKey"], Ne = (t) => {
1101
+ const e = {};
1102
+ for (const n of $e)
1103
+ if (t[n])
1104
+ try {
1105
+ e[n] = j(t[n]);
1106
+ } catch (o) {
1107
+ console.log(o);
1108
+ }
1109
+ return e;
1110
+ }, Le = (t, e) => (n, o) => {
1111
+ const r = Ne(n), { trace: i, customContext: a } = _e(o, e);
1112
+ r.custom = o.dataset && o.dataset.custom ? JSON.parse(o.dataset.custom) : null, r.domPathTokens = i, r.component = {
1113
+ id: S,
1114
+ name: S,
1115
+ type: "custom-code-component",
1116
+ subtype: T
1117
+ }, r.teamName = "djd", $(a, r), t.context = r, t.method = "ftCustomAnalytics", document.body.dispatchEvent(
1118
+ new CustomEvent("oTracking.event", {
1119
+ detail: t,
1120
+ bubbles: !0,
1121
+ composed: !0
1122
+ })
1123
+ );
1124
+ };
1125
+ function Ie(t, e) {
1126
+ const n = {
1127
+ category: "component",
1128
+ action: "act",
1129
+ context: {
1130
+ component: {
1131
+ id: S,
1132
+ name: S,
1133
+ type: "custom-code-component",
1134
+ subtype: T
1135
+ },
1136
+ teamName: "djd",
1137
+ trigger_action: t,
1138
+ custom: e
1139
+ },
1140
+ method: "ftCustomAnalytics"
1141
+ };
1142
+ document.body.dispatchEvent(
1143
+ new CustomEvent("oTracking.event", {
1144
+ detail: n,
1145
+ bubbles: !0,
1146
+ composed: !0
1147
+ })
1148
+ );
1149
+ }
1150
+ function De(t, e, n, o) {
1151
+ if (!M.isInitialised) {
1152
+ M.isInitialised = !0, t && (S = t.id || S, T = t.subtype || T), k.init({ queue: !0, test: !0 });
1153
+ const r = o || 'a, button, input, [role="button"]', i = {
1154
+ action: "click",
1155
+ category: n || "cta"
1156
+ }, a = e == null ? void 0 : e.querySelector("#component-root");
1157
+ e && new w(a).on(
1158
+ "click",
1159
+ r,
1160
+ Le(i, a),
1161
+ !0
1162
+ );
1163
+ }
1164
+ }
1165
+ const M = {
1166
+ init: De,
1167
+ isInitialised: !1,
1168
+ sendSpoorEvent: Ie
1169
+ };
1170
+ class Te extends HTMLElement {
2
1171
  constructor() {
3
1172
  super(...arguments), this.RESERVED_ATTRS = /* @__PURE__ */ new Set([
4
1173
  "iframe",
@@ -9,65 +1178,70 @@ class d extends HTMLElement {
9
1178
  "shadow-open",
10
1179
  "env",
11
1180
  "load-timeout"
12
- ]), this.unmount = (t) => {
1181
+ ]), this.unmount = (e) => {
13
1182
  }, this.channel = new MessageChannel();
14
1183
  }
15
1184
  async mount() {
16
1185
  var c;
17
1186
  if (!this.app)
18
1187
  throw new Error("CCC mounted without App");
19
- const t = this.shadowRoot ?? this.attachShadow({ mode: this.mode }), e = this.app, h = JSON.parse(this.getAttribute("data-component-props")), u = Object.fromEntries(
1188
+ const e = this.shadowRoot ?? this.attachShadow({ mode: this.mode }), n = this.app, o = JSON.parse(this.getAttribute("data-component-props")), r = Object.fromEntries(
20
1189
  [...this.attributes].filter((s) => !this.RESERVED_ATTRS.has(s.name)).map((s) => [s.name, s.value])
21
1190
  );
22
1191
  (c = this.shadowRoot) == null || c.replaceChildren();
23
- const { unmount: o, onmessage: r } = e(
24
- t,
25
- { ...u, data: h, port: this.channel.port2 },
1192
+ const { unmount: i, onmessage: a } = n(
1193
+ e,
1194
+ {
1195
+ ...r,
1196
+ data: o,
1197
+ port: this.channel.port2,
1198
+ tracking: M
1199
+ },
26
1200
  ...this.children
27
1201
  ) || {};
28
- o && (this.unmount = o), r && (this.onmessage = r);
1202
+ i && (this.unmount = i), a && (this.onmessage = a);
29
1203
  }
30
1204
  async connectedCallback() {
31
1205
  var s;
32
- const t = this.getAttribute("path"), e = this.getAttribute("version"), h = this.getAttribute("load-timeout") ?? 2e3, u = (s = this.getAttribute("env")) == null ? void 0 : s.toLowerCase().startsWith("d");
33
- if (!t)
1206
+ const e = this.getAttribute("path"), n = this.getAttribute("version"), o = this.getAttribute("load-timeout") ?? 2e3, r = (s = this.getAttribute("env")) == null ? void 0 : s.toLowerCase().startsWith("d");
1207
+ if (!e)
34
1208
  throw new Error(
35
1209
  "path attribute not specified in <custom-code-component>"
36
1210
  );
37
- const [o, r, c] = t.split("/").reverse();
38
- if (!(!o || !r || !c)) {
39
- this.source = u ? `http://localhost:5173/src/${o}/index.jsx` : `https://www.ft.com/__component/${c}/${r}${e ? `@${e}` : "@latest"}/${o}/${o}.js`;
1211
+ const [i, a, c] = e.split("/").reverse();
1212
+ if (!(!i || !a || !c)) {
1213
+ this.source = r ? `http://localhost:5173/src/${i}/index.jsx` : `https://www.ft.com/__component/${c}/${a}${n ? `@${n}` : "@latest"}/${i}/${i}.js`;
40
1214
  try {
41
- this.app = await new Promise((n, m) => {
42
- const p = setTimeout(() => {
1215
+ this.app = await new Promise((f, l) => {
1216
+ const u = setTimeout(() => {
43
1217
  this.dispatchEvent(
44
1218
  new CustomEvent("ccc-timeout", {
45
1219
  bubbles: !0,
46
1220
  cancelable: !0,
47
1221
  detail: {
48
- component: `${t}@${e}`,
1222
+ component: `${e}@${n}`,
49
1223
  source: this.source
50
1224
  }
51
1225
  })
52
1226
  ), this.dataset.cccError = "import-timeout", delete this.dataset.cccReady;
53
- }, Number(h));
1227
+ }, Number(o));
54
1228
  import(
55
1229
  /* webpackIgnore: true */
56
1230
  this.source
57
1231
  /* @vite-ignore */
58
- ).then(({ default: a }) => {
59
- if (a)
60
- clearTimeout(p), n(a);
1232
+ ).then(({ default: d }) => {
1233
+ if (d)
1234
+ clearTimeout(u), f(d);
61
1235
  else
62
- throw new i(
1236
+ throw new R(
63
1237
  "No component renderer default export found"
64
1238
  );
65
- }).catch((a) => m(new i(a)));
1239
+ }).catch((d) => l(new R(d)));
66
1240
  });
67
- } catch (n) {
1241
+ } catch (f) {
68
1242
  console.error(
69
- `<custom-code-component> error during import from ${t}@${e}`
70
- ), delete this.dataset.cccReady, this.dataset.cccError = "import-failure", this.dispatchEvent(new ErrorEvent("error", n)), console.error(n);
1243
+ `<custom-code-component> error during import from ${e}@${n}`
1244
+ ), delete this.dataset.cccReady, this.dataset.cccError = "import-failure", this.dispatchEvent(new ErrorEvent("error", f)), console.error(f);
71
1245
  return;
72
1246
  }
73
1247
  try {
@@ -76,36 +1250,49 @@ class d extends HTMLElement {
76
1250
  bubbles: !0,
77
1251
  cancelable: !0,
78
1252
  detail: {
79
- component: `${t}@${e}`,
1253
+ component: `${e}@${n}`,
80
1254
  source: this.source
81
1255
  }
82
1256
  })
83
1257
  ), this.dataset.cccReady = "true", delete this.dataset.cccError;
84
- } catch (n) {
1258
+ } catch (f) {
1259
+ console.info(
1260
+ `<custom-code-component> uncaught error during mount from ${e}@${n}`
1261
+ ), console.error(f), this.dispatchEvent(new ErrorEvent("error", f)), this.dataset.cccError = "mount-error", delete this.dataset.cccReady;
1262
+ }
1263
+ try {
1264
+ M.init(
1265
+ {
1266
+ id: this.getAttribute("path"),
1267
+ subtype: "interactive"
1268
+ },
1269
+ this.shadowRoot
1270
+ );
1271
+ } catch (f) {
85
1272
  console.info(
86
- `<custom-code-component> uncaught error during mount from ${t}@${e}`
87
- ), console.error(n), this.dispatchEvent(new ErrorEvent("error", n)), this.dataset.cccError = "mount-error", delete this.dataset.cccReady;
1273
+ `Error initialising tracking on <custom-code-component> ${e}@${n}`
1274
+ ), console.error(f);
88
1275
  }
89
1276
  }
90
1277
  }
91
1278
  disconnectedCallback() {
92
- const t = this.getAttribute("path");
93
- console.info(`<custom-code-component:${t}> disconnected`), typeof this.unmount == "function" && this.unmount();
1279
+ const e = this.getAttribute("path");
1280
+ console.info(`<custom-code-component:${e}> disconnected`), typeof this.unmount == "function" && this.unmount();
94
1281
  }
95
1282
  onmessage() {
96
1283
  }
97
1284
  // I'm honestly not sure what to do with this
98
- postMessage(t) {
99
- this.channel.port1.postMessage(t);
1285
+ postMessage(e) {
1286
+ this.channel.port1.postMessage(e);
100
1287
  }
101
1288
  }
102
- const l = () => customElements.define("custom-code-component", d);
103
- customElements && !customElements.get("custom-code-component") && l();
104
- class i extends Error {
105
- constructor(...t) {
106
- super(...t), Error.captureStackTrace && Error.captureStackTrace(this, i), this.name = "CCCImportError";
1289
+ const Me = () => customElements.define("custom-code-component", Te);
1290
+ customElements && !customElements.get("custom-code-component") && Me();
1291
+ class R extends Error {
1292
+ constructor(...e) {
1293
+ super(...e), Error.captureStackTrace && Error.captureStackTrace(this, R), this.name = "CCCImportError";
107
1294
  }
108
1295
  }
109
1296
  export {
110
- l as init
1297
+ Me as init
111
1298
  };