@financial-times/custom-code-component 1.9.2 → 1.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,1186 @@
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 = Et) : /^#[a-z0-9\-_]+$/i.test(e) ? (c = e.slice(1), a = xt) : (c = e, a = Element.prototype.matches) : (c = null, a = vt.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 = [], u;
57
+ const l = "ftLabsDelegateIgnore";
58
+ if (t[l] === !0)
59
+ return;
60
+ switch (u = t.target, u.nodeType === 3 && (u = u.parentNode), u.correspondingUseElement && (u = u.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 f = [];
72
+ for (n = s.length; u && n; ) {
73
+ for (e = 0; e < n && (a = s[e], !!a); e++)
74
+ u.tagName && ["button", "input", "select", "textarea"].indexOf(u.tagName.toLowerCase()) > -1 && u.hasAttribute("disabled") ? f = [] : a.matcher.call(u, a.matcherParam, u) && f.push([t, u, a]);
75
+ if (u === r || (n = s.length, u = u.parentElement || u.parentNode, u instanceof HTMLDocument))
76
+ break;
77
+ }
78
+ let d;
79
+ for (e = 0; e < f.length; e++)
80
+ if (!(this._removedListeners.indexOf(f[e][2]) > -1) && (c = this.fire.apply(this, f[e]), c === !1)) {
81
+ f[e][0][l] = !0, f[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 Et(t, e) {
90
+ return t.toLowerCase() === e.tagName.toLowerCase();
91
+ }
92
+ function vt(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 xt(t, e) {
101
+ return t === e.id;
102
+ }
103
+ w.prototype.destroy = function() {
104
+ this.off(), this.root();
105
+ };
106
+ const K = { config: {} };
107
+ function tt(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 kt(t, e) {
120
+ K[t] = tt(e);
121
+ }
122
+ function Ot(t) {
123
+ return tt(K[t]);
124
+ }
125
+ function Q(t) {
126
+ delete K[t];
127
+ }
128
+ const C = kt, h = Ot;
129
+ let A = 0;
130
+ const H = 4, _ = 36, et = Math.pow(_, H), F = function(e, n) {
131
+ const o = "000000000" + e;
132
+ return o.substr(o.length - n);
133
+ }, U = function() {
134
+ return F((Math.random() * et << 0).toString(_), H);
135
+ }, nt = () => (A = A < et ? A : 0, A++, A - 1), p = function() {
136
+ const e = "c", n = (/* @__PURE__ */ new Date()).getTime().toString(_), o = p.fingerprint(), r = U() + U(), i = F(nt().toString(_), H);
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 = U().slice(-2), r = nt().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 F((navigator.mimeTypes.length + navigator.userAgent.length).toString(36) + p.globalCount().toString(36), 4);
154
+ };
155
+ const X = [];
156
+ function P(...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 V(t) {
172
+ return window.encodeURIComponent ? window.encodeURIComponent(t) : window.escape(t);
173
+ }
174
+ function Ct(t) {
175
+ return window.decodeURIComponent ? window.decodeURIComponent(t) : window.unescape(t);
176
+ }
177
+ function z(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 St() {
191
+ for (let t = 0; t < X.length; t++)
192
+ X[t]();
193
+ }
194
+ function Y(t) {
195
+ return document.cookie.match(t) && RegExp.$1 !== "" && RegExp.$1 !== "null" ? RegExp.$1 : null;
196
+ }
197
+ function At(t, e) {
198
+ const n = {};
199
+ for (const o of e)
200
+ t[o] && (n[o] = t[o]);
201
+ return n;
202
+ }
203
+ function R(t) {
204
+ return typeof t == "string" ? t.trim() : t;
205
+ }
206
+ function N(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 ot(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 rt(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 q(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 (!q(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 (!q(t[i], e[i]))
271
+ return !1;
272
+ }
273
+ return !0;
274
+ }
275
+ }
276
+ const S = 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, u) {
291
+ return window.localStorage.setItem(s, u);
292
+ },
293
+ remove: function(s) {
294
+ return i(s), window.localStorage.removeItem(s);
295
+ }
296
+ };
297
+ function o(s) {
298
+ s = s + "=";
299
+ const u = window.document.cookie.split(";");
300
+ let l, f;
301
+ for (l = 0; l < u.length; l = l + 1)
302
+ if (f = u[l].replace(/^\s+|\s+$/g, ""), f.indexOf(s) === 0)
303
+ return Ct(f.substring(s.length, f.length));
304
+ return null;
305
+ }
306
+ function r(s, u, l) {
307
+ let f, d = "";
308
+ y(l, "number") && (f = /* @__PURE__ */ new Date(), f.setTime(f.getTime() + l), d = "expires=" + f.toUTCString() + ";");
309
+ const bt = V(s) + "=" + V(u) + ";" + d + "path=/;" + (e.domain ? "domain=." + e.domain + ";" : "");
310
+ window.document.cookie = bt;
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 u of Object.keys(s))
334
+ u !== "spoor-id" && i(u);
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
+ S.prototype.read = function() {
345
+ return this.data;
346
+ };
347
+ S.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 (rt(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(ot(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
+ S.prototype.destroy = function() {
365
+ return this.data = null, this.storage.remove(this.storageKey), this;
366
+ };
367
+ let O, B;
368
+ function Pt(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), B = new S(n.name, n);
378
+ let o = B.read();
379
+ return o || (o = t), it(o);
380
+ }
381
+ function it(t) {
382
+ return O = t, O || (O = p()), B.write(O), O;
383
+ }
384
+ function Nt() {
385
+ return O;
386
+ }
387
+ let $;
388
+ const _t = {
389
+ storage: "best",
390
+ name: "session",
391
+ expires: 30 * 60 * 1e3
392
+ // 30 minutes
393
+ };
394
+ function $t(t) {
395
+ const e = /* @__PURE__ */ new Date();
396
+ e.setTime(e.getTime() + $.config.expires), $.write({
397
+ value: t,
398
+ expiry: e.valueOf()
399
+ });
400
+ }
401
+ function st() {
402
+ const t = $.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), $t(e), {
409
+ id: e,
410
+ isNew: n
411
+ };
412
+ }
413
+ function Lt(t) {
414
+ y(t, "string") && (t = { name: t }), y(t) && (t = {});
415
+ const e = m(_t, t);
416
+ return e.storage === "cookie" && t.name && (e.nameOverride = e.name), $ = new S(e.name, e), st();
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 S(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 It() {
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 Dt() {
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 Rt() {
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=" + V(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 G = {};
520
+ function j(t) {
521
+ if (G.transport)
522
+ return G.transport;
523
+ switch (t) {
524
+ case "xhr":
525
+ return It;
526
+ case "sendBeacon":
527
+ return Dt;
528
+ case "image":
529
+ return Rt;
530
+ default:
531
+ return;
532
+ }
533
+ }
534
+ let g;
535
+ function at() {
536
+ return (h("config") || {}).queue === !0 ? !1 : !!navigator.sendBeacon;
537
+ }
538
+ function ct(t, e) {
539
+ const n = t.queueTime, o = (/* @__PURE__ */ new Date()).getTime() - n, r = at() ? j("sendBeacon")() : window.XMLHttpRequest && "withCredentials" in new window.XMLHttpRequest() ? j("xhr")() : j("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, P("user_callback", i), P("PreSend", t), rt(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(ot(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), P("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 u = "https://spoor-api.ft.com/ingest";
562
+ t && t.category && t.action && (u += `?type=${t.category}:${t.action}`), r.send(u, s);
563
+ }
564
+ function Mt(t) {
565
+ t.queueTime = (/* @__PURE__ */ new Date()).getTime(), at() ? ct(t) : g.add(t).save(), P("AddedToQueue", g);
566
+ }
567
+ function L(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
+ L(), t();
588
+ }, o = g.shift();
589
+ return o ? ct(o, n) : t();
590
+ }
591
+ function Tt(t) {
592
+ Mt(t), L();
593
+ }
594
+ function jt() {
595
+ return g = new b("requests"), z(window, "online", function() {
596
+ L();
597
+ }), L(), g;
598
+ }
599
+ let I;
600
+ function ut() {
601
+ return I = p(), I;
602
+ }
603
+ function ft() {
604
+ return I || ut(), I;
605
+ }
606
+ function Jt(t, e = function() {
607
+ }) {
608
+ const n = st(), 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: ft()
614
+ },
615
+ user: {
616
+ ft_session: Y(/FTSession=([^;]+)/),
617
+ ft_session_s: Y(/FTSession_s=([^;]+)/)
618
+ },
619
+ device: {
620
+ spoor_session: n.id,
621
+ spoor_session_is_new: n.isNew,
622
+ spoor_id: Nt()
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), P("Core.Track", o), Tt(o), o;
626
+ }
627
+ const x = {
628
+ setRootID: ut,
629
+ getRootID: ft,
630
+ track: Jt
631
+ }, Ut = function() {
632
+ return {
633
+ category: "event",
634
+ action: "generic",
635
+ context: {}
636
+ };
637
+ };
638
+ function M(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(Ut(), {
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 = Vt(t);
653
+ o && (n.context.component_name = o.getAttribute("data-o-component"), n.context.component_id = n.context.component_id || qt(o)), x.track(n, e);
654
+ }
655
+ function Vt(t) {
656
+ const e = t.target || t.srcElement;
657
+ if (e && e.getAttribute("data-o-component"))
658
+ return e;
659
+ }
660
+ function qt(t) {
661
+ const e = Bt(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 Kt(r + "_siblingIndex=" + o);
681
+ }
682
+ function Bt(t) {
683
+ const e = [];
684
+ for (; t; )
685
+ e.push(t), t = t.parentElement;
686
+ return e;
687
+ }
688
+ function Kt(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 Ht = function() {
706
+ z(window, "oTracking.event", M);
707
+ };
708
+ M.init = Ht;
709
+ C("page_has_already_been_viewed", !1);
710
+ const Ft = function() {
711
+ return {
712
+ category: "page",
713
+ action: "view",
714
+ context: {
715
+ url: document.URL,
716
+ referrer: document.referrer
717
+ }
718
+ };
719
+ };
720
+ function T(t, e) {
721
+ t = m(Ft(), {
722
+ context: t
723
+ }), h("page_has_already_been_viewed") && x.setRootID(), C("page_has_already_been_viewed", !0), zt(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), St());
724
+ }
725
+ let Z = {};
726
+ function zt(t) {
727
+ const e = JSON.parse(JSON.stringify(t));
728
+ return delete e.context.id, delete e.context.root_id, q(Z, e) ? !0 : (Z = e, !1);
729
+ }
730
+ function Wt(t) {
731
+ T(t.detail);
732
+ }
733
+ const Qt = function() {
734
+ z(window, "oTracking.page", Wt);
735
+ };
736
+ T.init = Qt;
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 = Xt) : /^#[a-z0-9\-_]+$/i.test(e) ? (c = e.slice(1), a = Gt) : (c = e, a = Element.prototype.matches) : (c = null, a = Yt.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 = [], u;
793
+ const l = "ftLabsDelegateIgnore";
794
+ if (t[l] === !0)
795
+ return;
796
+ switch (u = t.target, u.nodeType === 3 && (u = u.parentNode), u.correspondingUseElement && (u = u.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 f = [];
808
+ for (n = s.length; u && n; ) {
809
+ for (e = 0; e < n && (a = s[e], !!a); e++)
810
+ u.tagName && ["button", "input", "select", "textarea"].indexOf(u.tagName.toLowerCase()) > -1 && u.hasAttribute("disabled") ? f = [] : a.matcher.call(u, a.matcherParam, u) && f.push([t, u, a]);
811
+ if (u === r || (n = s.length, u = u.parentElement || u.parentNode, u instanceof HTMLDocument))
812
+ break;
813
+ }
814
+ let d;
815
+ for (e = 0; e < f.length; e++)
816
+ if (!(this._removedListeners.indexOf(f[e][2]) > -1) && (c = this.fire.apply(this, f[e]), c === !1)) {
817
+ f[e][0][l] = !0, f[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 Xt(t, e) {
826
+ return t.toLowerCase() === e.tagName.toLowerCase();
827
+ }
828
+ function Yt(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 Gt(t, e) {
837
+ return t === e.id;
838
+ }
839
+ E.prototype.destroy = function() {
840
+ this.off(), this.root();
841
+ };
842
+ const Zt = (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
+ }, lt = [
850
+ "nodeName",
851
+ "className",
852
+ "id",
853
+ "href",
854
+ "text",
855
+ "role"
856
+ ], te = (t) => {
857
+ const e = {};
858
+ for (const n of lt) {
859
+ const o = t[n] || t.getAttribute(n) || t.hasAttribute(n);
860
+ o !== void 0 && (typeof o == "boolean" ? e[n] = o : e[n] = R(o));
861
+ }
862
+ return e;
863
+ }, ee = (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
+ }, ne = (t) => {
871
+ const [e, n] = ee(t);
872
+ return e ? n : t;
873
+ }, oe = (t, e) => (t.filter((n) => n.name.match(/^data-trackable|^data-o-|^aria-/i)).forEach((n) => {
874
+ e[n.name] = n.value;
875
+ }), e), re = (t, e, n) => {
876
+ const o = {};
877
+ return n && lt.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-", "")] = ne(r.value);
881
+ }), o;
882
+ };
883
+ function dt(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 = te(t), c = Array.from(t.attributes);
887
+ let s = oe(c, a);
888
+ s["data-trackable"] && (s = Object.assign(
889
+ s,
890
+ Zt(t, n, o)
891
+ )), r.push(s);
892
+ const u = re(c, a, t === n);
893
+ N(u, i), t = t.parentNode;
894
+ }
895
+ return { trace: r, customContext: i };
896
+ }
897
+ let J;
898
+ const ie = [
899
+ "ctrlKey",
900
+ "altKey",
901
+ "shiftKey",
902
+ "metaKey"
903
+ ], se = (t) => {
904
+ const e = {};
905
+ for (const n of ie)
906
+ if (t[n])
907
+ try {
908
+ e[n] = R(t[n]);
909
+ } catch (o) {
910
+ console.log(o);
911
+ }
912
+ return e;
913
+ }, ae = (t) => (e, n) => {
914
+ if (n.getAttribute("data-o-tracking-do-not-track") === "true")
915
+ return;
916
+ const o = se(e), { trace: r, customContext: i } = dt(n);
917
+ o.domPathTokens = r, o.url = window.document.location.href || null, o.source_id = x.getRootID(), N(i, o), t.context = o;
918
+ const a = m(h("config"), t);
919
+ x.track(a);
920
+ }, ce = (t, e) => {
921
+ e = e || 'a, button, input, [role="button"]';
922
+ const n = {
923
+ action: "click",
924
+ category: t || "o-tracking"
925
+ };
926
+ J = J || new E(document.body), J.on("click", e, ae(n), !0);
927
+ const o = new b("clicks");
928
+ ht(o);
929
+ };
930
+ function ht(t) {
931
+ const e = t.shift();
932
+ e && x.track(e, () => ht(t));
933
+ }
934
+ const ue = {
935
+ init: ce
936
+ }, fe = [
937
+ "componentContentId",
938
+ "type",
939
+ "subtype",
940
+ "component"
941
+ ], le = (t, e, n) => {
942
+ const { trace: o, customContext: r } = dt(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 = At(a, fe);
951
+ } else
952
+ i = {};
953
+ i.domPathTokens = o, i.url = window.document.location.href || null, N(r, i), t.context = i;
954
+ }, de = (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
+ le(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
+ }, he = {
976
+ init: de
977
+ }, pe = M.init, me = T.init, W = "4.5.4", pt = "o-tracking";
978
+ function mt(t) {
979
+ let e = h("config") || {};
980
+ e = m(e, t), C("config", e), e.user && e.user.user_id && it(e.user.user_id);
981
+ }
982
+ function ge() {
983
+ k.initialised = !1, Q("config"), Q("page_sent");
984
+ }
985
+ function ye() {
986
+ return "oTracking version " + W;
987
+ }
988
+ function we(t = {}) {
989
+ if (k.initialised)
990
+ return k;
991
+ if (!!gt() && (t = be(t)), Object.keys(t).length === 0 && t.constructor === Object)
992
+ return null;
993
+ C("version", W), C("source", pt), C("page_sent", !1);
994
+ const n = t ? t.cookieDomain : "";
995
+ return Pt("", n), mt(t), Lt(t.session), jt(), pe(), me(), k.initialised = !0, k;
996
+ }
997
+ function gt() {
998
+ return document.querySelector("script[data-o-tracking-config]");
999
+ }
1000
+ function be(t) {
1001
+ const e = gt();
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: W,
1027
+ updateConfig: mt,
1028
+ source: pt,
1029
+ destroy: ge,
1030
+ toString: ye,
1031
+ init: we,
1032
+ click: ue,
1033
+ event: M,
1034
+ page: T,
1035
+ view: he,
1036
+ getRootID: x.getRootID
1037
+ };
1038
+ function yt() {
1039
+ k.init(), document.removeEventListener("o.DOMContentLoaded", yt);
1040
+ }
1041
+ typeof document < "u" && document.addEventListener("o.DOMContentLoaded", yt);
1042
+ const Ee = (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
+ }, wt = [
1050
+ "nodeName",
1051
+ "className",
1052
+ "id",
1053
+ "href",
1054
+ "text",
1055
+ "role"
1056
+ ], ve = (t) => {
1057
+ const e = {};
1058
+ for (const n of wt) {
1059
+ const o = t[n] || t.getAttribute(n) || t.hasAttribute(n);
1060
+ o !== void 0 && (typeof o == "boolean" ? e[n] = o : e[n] = R(o));
1061
+ }
1062
+ return e;
1063
+ }, xe = (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
+ }, ke = (t) => {
1071
+ const [e, n] = xe(t);
1072
+ return e ? n : t;
1073
+ }, Oe = (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), Ce = (t, e, n) => {
1078
+ const o = {};
1079
+ return n && wt.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-", "")] = ke(r.value);
1083
+ }), o;
1084
+ };
1085
+ function Se(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 = ve(t), c = Array.from(t.attributes);
1089
+ let s = Oe(c, a);
1090
+ s["data-trackable"] && (s = Object.assign(
1091
+ s,
1092
+ Ee(t, n, o)
1093
+ )), r.push(s);
1094
+ const u = Ce(c, a, t === n);
1095
+ N(u, i), t = t.parentNode;
1096
+ }
1097
+ return { trace: r, customContext: i };
1098
+ }
1099
+ const Ae = ["ctrlKey", "altKey", "shiftKey", "metaKey"];
1100
+ class Pe {
1101
+ constructor({
1102
+ id: e = "ccc-component",
1103
+ subtype: n = "interactive",
1104
+ teamName: o = "djd",
1105
+ shadowRoot: r = null,
1106
+ category: i = "cta",
1107
+ elements: a = 'a, button, input, [role="button"]'
1108
+ } = {}) {
1109
+ this.cccName = e, this.subtype = n, this.teamName = o, this.shadowRoot = r, this.category = i, this.elements = a, this.isInitialised = !1;
1110
+ }
1111
+ // Get properties for the event (as opposed to properties of the clicked element)
1112
+ getEventProperties(e) {
1113
+ const n = {};
1114
+ for (const o of Ae)
1115
+ if (e[o])
1116
+ try {
1117
+ n[o] = R(e[o]);
1118
+ } catch (r) {
1119
+ console.log(r);
1120
+ }
1121
+ return n;
1122
+ }
1123
+ // Controller for handling click events
1124
+ handleClickEvent(e, n) {
1125
+ return (o, r) => {
1126
+ const i = this.getEventProperties(o), { trace: a, customContext: c } = Se(r, n);
1127
+ i.custom = r.dataset && r.dataset.custom ? JSON.parse(r.dataset.custom) : null, i.domPathTokens = a, i.component = {
1128
+ id: this.cccName,
1129
+ name: this.cccName,
1130
+ type: "custom-code-component",
1131
+ subtype: this.subtype
1132
+ }, i.teamName = this.teamName, N(c, i), e.context = i, e.method = "ftCustomAnalytics", document.body.dispatchEvent(
1133
+ new CustomEvent("oTracking.event", {
1134
+ detail: e,
1135
+ bubbles: !0,
1136
+ composed: !0
1137
+ })
1138
+ );
1139
+ };
1140
+ }
1141
+ sendSpoorEvent(e, n) {
1142
+ const o = {
1143
+ category: "component",
1144
+ action: "act",
1145
+ context: {
1146
+ component: {
1147
+ id: this.cccName,
1148
+ name: this.cccName,
1149
+ type: "custom-code-component",
1150
+ subtype: this.subtype
1151
+ },
1152
+ teamName: this.teamName,
1153
+ trigger_action: e,
1154
+ custom: n
1155
+ },
1156
+ method: "ftCustomAnalytics"
1157
+ };
1158
+ document.body.dispatchEvent(
1159
+ new CustomEvent("oTracking.event", {
1160
+ detail: o,
1161
+ bubbles: !0,
1162
+ composed: !0
1163
+ })
1164
+ );
1165
+ }
1166
+ init() {
1167
+ var e;
1168
+ if (!this.isInitialised) {
1169
+ this.isInitialised = !0, k.init({ queue: !0, test: !0 });
1170
+ const n = {
1171
+ action: "click",
1172
+ category: this.category
1173
+ }, o = (e = this.shadowRoot) == null ? void 0 : e.querySelector("#component-root");
1174
+ this.shadowRoot && new w(o).on(
1175
+ "click",
1176
+ this.elements,
1177
+ this.handleClickEvent(n, o),
1178
+ !0
1179
+ );
1180
+ }
1181
+ }
1182
+ }
1183
+ class Ne extends HTMLElement {
2
1184
  constructor() {
3
1185
  super(...arguments), this.RESERVED_ATTRS = /* @__PURE__ */ new Set([
4
1186
  "iframe",
@@ -9,65 +1191,75 @@ class d extends HTMLElement {
9
1191
  "shadow-open",
10
1192
  "env",
11
1193
  "load-timeout"
12
- ]), this.unmount = (t) => {
1194
+ ]), this.unmount = (e) => {
13
1195
  }, this.channel = new MessageChannel();
14
1196
  }
15
1197
  async mount() {
16
1198
  var c;
17
1199
  if (!this.app)
18
1200
  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(
1201
+ const e = this.shadowRoot ?? this.attachShadow({ mode: this.mode }), n = this.app, o = JSON.parse(this.getAttribute("data-component-props")), r = Object.fromEntries(
20
1202
  [...this.attributes].filter((s) => !this.RESERVED_ATTRS.has(s.name)).map((s) => [s.name, s.value])
21
1203
  );
22
- (c = this.shadowRoot) == null || c.replaceChildren();
23
- const { unmount: o, onmessage: r } = e(
24
- t,
25
- { ...u, data: h, port: this.channel.port2 },
1204
+ (c = this.shadowRoot) == null || c.replaceChildren(), this.tracking = new Pe({
1205
+ id: `${this.getAttribute("path")}@${this.getAttribute("version")}`,
1206
+ subtype: "interactive",
1207
+ teamName: "djd",
1208
+ shadowRoot: this.shadowRoot
1209
+ });
1210
+ const { unmount: i, onmessage: a } = n(
1211
+ e,
1212
+ {
1213
+ ...r,
1214
+ data: o,
1215
+ port: this.channel.port2,
1216
+ tracking: this.tracking
1217
+ },
26
1218
  ...this.children
27
1219
  ) || {};
28
- o && (this.unmount = o), r && (this.onmessage = r);
1220
+ i && (this.unmount = i), a && (this.onmessage = a);
29
1221
  }
30
1222
  async connectedCallback() {
31
1223
  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)
1224
+ 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");
1225
+ if (!e)
34
1226
  throw new Error(
35
1227
  "path attribute not specified in <custom-code-component>"
36
1228
  );
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`;
1229
+ const [i, a, c] = e.split("/").reverse();
1230
+ if (!(!i || !a || !c)) {
1231
+ this.source = r ? `http://localhost:5173/src/${i}/index.jsx` : `https://www.ft.com/__component/${c}/${a}${n ? `@${n}` : "@latest"}/${i}/${i}.js`;
40
1232
  try {
41
- this.app = await new Promise((n, m) => {
42
- const p = setTimeout(() => {
1233
+ this.app = await new Promise((u, l) => {
1234
+ const f = setTimeout(() => {
43
1235
  this.dispatchEvent(
44
1236
  new CustomEvent("ccc-timeout", {
45
1237
  bubbles: !0,
46
1238
  cancelable: !0,
47
1239
  detail: {
48
- component: `${t}@${e}`,
1240
+ component: `${e}@${n}`,
49
1241
  source: this.source
50
1242
  }
51
1243
  })
52
1244
  ), this.dataset.cccError = "import-timeout", delete this.dataset.cccReady;
53
- }, Number(h));
1245
+ }, Number(o));
54
1246
  import(
55
1247
  /* webpackIgnore: true */
56
1248
  this.source
57
1249
  /* @vite-ignore */
58
- ).then(({ default: a }) => {
59
- if (a)
60
- clearTimeout(p), n(a);
1250
+ ).then(({ default: d }) => {
1251
+ if (d)
1252
+ clearTimeout(f), u(d);
61
1253
  else
62
- throw new i(
1254
+ throw new D(
63
1255
  "No component renderer default export found"
64
1256
  );
65
- }).catch((a) => m(new i(a)));
1257
+ }).catch((d) => l(new D(d)));
66
1258
  });
67
- } catch (n) {
1259
+ } catch (u) {
68
1260
  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);
1261
+ `<custom-code-component> error during import from ${e}@${n}`
1262
+ ), delete this.dataset.cccReady, this.dataset.cccError = "import-failure", this.dispatchEvent(new ErrorEvent("error", u)), console.error(u);
71
1263
  return;
72
1264
  }
73
1265
  try {
@@ -76,36 +1268,43 @@ class d extends HTMLElement {
76
1268
  bubbles: !0,
77
1269
  cancelable: !0,
78
1270
  detail: {
79
- component: `${t}@${e}`,
1271
+ component: `${e}@${n}`,
80
1272
  source: this.source
81
1273
  }
82
1274
  })
83
1275
  ), this.dataset.cccReady = "true", delete this.dataset.cccError;
84
- } catch (n) {
1276
+ } catch (u) {
1277
+ console.info(
1278
+ `<custom-code-component> uncaught error during mount from ${e}@${n}`
1279
+ ), console.error(u), this.dispatchEvent(new ErrorEvent("error", u)), this.dataset.cccError = "mount-error", delete this.dataset.cccReady;
1280
+ }
1281
+ try {
1282
+ this.tracking.init();
1283
+ } catch (u) {
85
1284
  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;
1285
+ `Error initialising tracking on <custom-code-component> ${e}@${n}`
1286
+ ), console.error(u);
88
1287
  }
89
1288
  }
90
1289
  }
91
1290
  disconnectedCallback() {
92
- const t = this.getAttribute("path");
93
- console.info(`<custom-code-component:${t}> disconnected`), typeof this.unmount == "function" && this.unmount();
1291
+ const e = this.getAttribute("path");
1292
+ console.info(`<custom-code-component:${e}> disconnected`), typeof this.unmount == "function" && this.unmount();
94
1293
  }
95
1294
  onmessage() {
96
1295
  }
97
1296
  // I'm honestly not sure what to do with this
98
- postMessage(t) {
99
- this.channel.port1.postMessage(t);
1297
+ postMessage(e) {
1298
+ this.channel.port1.postMessage(e);
100
1299
  }
101
1300
  }
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";
1301
+ const _e = () => customElements.define("custom-code-component", Ne);
1302
+ customElements && !customElements.get("custom-code-component") && _e();
1303
+ class D extends Error {
1304
+ constructor(...e) {
1305
+ super(...e), Error.captureStackTrace && Error.captureStackTrace(this, D), this.name = "CCCImportError";
107
1306
  }
108
1307
  }
109
1308
  export {
110
- l as init
1309
+ _e as init
111
1310
  };