@financial-times/custom-code-component 1.9.8 → 1.10.0
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.
- package/dist/custom-code-component.js +235 -1163
- package/package.json +4 -2
- package/src/custom-code-component.ts +6 -2
- package/src/tracking.ts +0 -3
|
@@ -1,1146 +1,217 @@
|
|
|
1
|
-
function
|
|
2
|
-
this.listenerMap = [{}, {}],
|
|
1
|
+
function d(o) {
|
|
2
|
+
this.listenerMap = [{}, {}], o && this.root(o), this.handle = d.prototype.handle.bind(this), this._removedListeners = [];
|
|
3
3
|
}
|
|
4
|
-
|
|
5
|
-
const
|
|
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, s, 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, s = Et) : /^#[a-z0-9\-_]+$/i.test(e) ? (c = e.slice(1), s = xt) : (c = e, s = Element.prototype.matches) : (c = null, s = vt.bind(this)), i[t].push({
|
|
32
|
-
selector: e,
|
|
33
|
-
handler: n,
|
|
34
|
-
matcher: s,
|
|
35
|
-
matcherParam: c
|
|
36
|
-
}), this;
|
|
37
|
-
};
|
|
38
|
-
w.prototype.off = function(t, e, n, o) {
|
|
39
|
-
let r, i, s, c, a;
|
|
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 (s = this.listenerMap[o ? 1 : 0], !t) {
|
|
43
|
-
for (a in s)
|
|
44
|
-
s.hasOwnProperty(a) && this.off(a, e, n);
|
|
45
|
-
return this;
|
|
46
|
-
}
|
|
47
|
-
if (c = s[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 s[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, s, c, a = [], 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
|
-
a = this.listenerMap[1][o];
|
|
63
|
-
break;
|
|
64
|
-
case 2:
|
|
65
|
-
this.listenerMap[0] && this.listenerMap[0][o] && (a = a.concat(this.listenerMap[0][o])), this.listenerMap[1] && this.listenerMap[1][o] && (a = a.concat(this.listenerMap[1][o]));
|
|
66
|
-
break;
|
|
67
|
-
case 3:
|
|
68
|
-
a = this.listenerMap[0][o];
|
|
69
|
-
break;
|
|
70
|
-
}
|
|
71
|
-
let f = [];
|
|
72
|
-
for (n = a.length; u && n; ) {
|
|
73
|
-
for (e = 0; e < n && (s = a[e], !!s); e++)
|
|
74
|
-
u.tagName && ["button", "input", "select", "textarea"].indexOf(u.tagName.toLowerCase()) > -1 && u.hasAttribute("disabled") ? f = [] : s.matcher.call(u, s.matcherParam, u) && f.push([t, u, s]);
|
|
75
|
-
if (u === r || (n = a.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, N = 36, et = Math.pow(N, 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(N), H);
|
|
135
|
-
}, nt = () => (A = A < et ? A : 0, A++, A - 1), p = function() {
|
|
136
|
-
const e = "c", n = (/* @__PURE__ */ new Date()).getTime().toString(N), o = p.fingerprint(), r = U() + U(), i = F(nt().toString(N), 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 _(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 [s, c] of Object.entries(r))
|
|
220
|
-
c instanceof Object && (Array.isArray(r) ? o(c, `${i}[${s}]`) : o(c, `${i}.${s}`));
|
|
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 a = new Error("You must specify a name for the store.");
|
|
280
|
-
throw v("oErrors", "log", {
|
|
281
|
-
error: a.message,
|
|
282
|
-
info: { module: "o-tracking" }
|
|
283
|
-
}), a;
|
|
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(a) {
|
|
288
|
-
return window.localStorage.getItem(a);
|
|
289
|
-
},
|
|
290
|
-
save: function(a, u) {
|
|
291
|
-
return window.localStorage.setItem(a, u);
|
|
292
|
-
},
|
|
293
|
-
remove: function(a) {
|
|
294
|
-
return i(a), window.localStorage.removeItem(a);
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
|
-
function o(a) {
|
|
298
|
-
a = a + "=";
|
|
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(a) === 0)
|
|
303
|
-
return Ct(f.substring(a.length, f.length));
|
|
304
|
-
return null;
|
|
305
|
-
}
|
|
306
|
-
function r(a, 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(a) + "=" + V(u) + ";" + d + "path=/;" + (e.domain ? "domain=." + e.domain + ";" : "");
|
|
310
|
-
window.document.cookie = bt;
|
|
311
|
-
}
|
|
312
|
-
function i(a) {
|
|
313
|
-
r(a, "", -1);
|
|
314
|
-
}
|
|
315
|
-
const s = this.storage.load(this.storageKey);
|
|
316
|
-
if (s)
|
|
317
|
-
try {
|
|
318
|
-
this.data = JSON.parse(s);
|
|
319
|
-
} catch (a) {
|
|
320
|
-
v("oErrors", "log", {
|
|
321
|
-
error: a.message,
|
|
322
|
-
module: "o-tracking"
|
|
323
|
-
}), this.data = s;
|
|
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 a = JSON.parse(c);
|
|
332
|
-
this.data ? Object.assign(this.data, a) : this.data = a;
|
|
333
|
-
for (const u of Object.keys(a))
|
|
334
|
-
u !== "spoor-id" && i(u);
|
|
335
|
-
}
|
|
336
|
-
} catch (a) {
|
|
337
|
-
v("oErrors", "log", {
|
|
338
|
-
error: a.message,
|
|
339
|
-
module: "o-tracking"
|
|
340
|
-
}), this.data = s;
|
|
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;
|
|
4
|
+
d.prototype.root = function(o) {
|
|
5
|
+
const t = this.listenerMap;
|
|
349
6
|
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 _t() {
|
|
385
|
-
return O;
|
|
386
|
-
}
|
|
387
|
-
let $;
|
|
388
|
-
const Nt = {
|
|
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 It(t) {
|
|
414
|
-
y(t, "string") && (t = { name: t }), y(t) && (t = {});
|
|
415
|
-
const e = m(Nt, 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 Lt() {
|
|
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 Lt;
|
|
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, s = h("config") && h("config").system || {}, c = m(s, {
|
|
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 a = 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, a);
|
|
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 I(t = function() {
|
|
568
|
-
}) {
|
|
569
|
-
const e = g.all();
|
|
570
|
-
if (e.length > 200) {
|
|
571
|
-
const r = {};
|
|
572
|
-
e.forEach(function(i) {
|
|
573
|
-
const s = [i.category, i.action].join(":");
|
|
574
|
-
Object.prototype.hasOwnProperty.call(r, s) || (r[s] = 0), r[s] += 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 ? ct(o, n) : t();
|
|
590
|
-
}
|
|
591
|
-
function Tt(t) {
|
|
592
|
-
Mt(t), I();
|
|
593
|
-
}
|
|
594
|
-
function jt() {
|
|
595
|
-
return g = new b("requests"), z(window, "online", function() {
|
|
596
|
-
I();
|
|
597
|
-
}), I(), g;
|
|
598
|
-
}
|
|
599
|
-
let L;
|
|
600
|
-
function ut() {
|
|
601
|
-
return L = p(), L;
|
|
602
|
-
}
|
|
603
|
-
function ft() {
|
|
604
|
-
return L || ut(), L;
|
|
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: _t()
|
|
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(s) {
|
|
665
|
-
const c = s.parentElement;
|
|
666
|
-
if (c) {
|
|
667
|
-
for (let a = 0; a < c.childNodes.length; a++)
|
|
668
|
-
if (c.childNodes[a] === n)
|
|
669
|
-
return a;
|
|
670
|
-
return -1;
|
|
671
|
-
} else
|
|
672
|
-
return 0;
|
|
673
|
-
}(n), r = e.reduceRight(function(i, s) {
|
|
674
|
-
if (!s.nodeName)
|
|
675
|
-
return i + " - " + s.constructor.name + `
|
|
676
|
-
`;
|
|
677
|
-
const c = s.nodeName.toLowerCase();
|
|
678
|
-
return c.indexOf("#") === 0 ? i + "<" + c + ">" : i + "<" + c + ' id="' + (s.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
7
|
if (this.rootElement) {
|
|
744
|
-
for (
|
|
745
|
-
|
|
746
|
-
for (
|
|
747
|
-
|
|
8
|
+
for (e in t[1])
|
|
9
|
+
t[1].hasOwnProperty(e) && this.rootElement.removeEventListener(e, this.handle, !0);
|
|
10
|
+
for (e in t[0])
|
|
11
|
+
t[0].hasOwnProperty(e) && this.rootElement.removeEventListener(e, this.handle, !1);
|
|
748
12
|
}
|
|
749
|
-
if (!
|
|
13
|
+
if (!o || !o.addEventListener)
|
|
750
14
|
return this.rootElement && delete this.rootElement, this;
|
|
751
|
-
this.rootElement =
|
|
752
|
-
for (
|
|
753
|
-
|
|
754
|
-
for (
|
|
755
|
-
|
|
15
|
+
this.rootElement = o;
|
|
16
|
+
for (e in t[1])
|
|
17
|
+
t[1].hasOwnProperty(e) && this.rootElement.addEventListener(e, this.handle, !0);
|
|
18
|
+
for (e in t[0])
|
|
19
|
+
t[0].hasOwnProperty(e) && this.rootElement.addEventListener(e, this.handle, !1);
|
|
756
20
|
return this;
|
|
757
21
|
};
|
|
758
|
-
|
|
759
|
-
return ["blur", "error", "focus", "load", "resize", "scroll"].indexOf(
|
|
22
|
+
d.prototype.captureForType = function(o) {
|
|
23
|
+
return ["blur", "error", "focus", "load", "resize", "scroll"].indexOf(o) !== -1;
|
|
760
24
|
};
|
|
761
|
-
|
|
762
|
-
let
|
|
763
|
-
if (!
|
|
764
|
-
throw new TypeError("Invalid event type: " +
|
|
765
|
-
if (typeof
|
|
25
|
+
d.prototype.on = function(o, t, e, n) {
|
|
26
|
+
let s, i, a, r;
|
|
27
|
+
if (!o)
|
|
28
|
+
throw new TypeError("Invalid event type: " + o);
|
|
29
|
+
if (typeof t == "function" && (n = e, e = t, t = null), n === void 0 && (n = this.captureForType(o)), typeof e != "function")
|
|
766
30
|
throw new TypeError("Handler must be a type of Function");
|
|
767
|
-
return
|
|
768
|
-
selector:
|
|
769
|
-
handler:
|
|
770
|
-
matcher:
|
|
771
|
-
matcherParam:
|
|
31
|
+
return s = this.rootElement, i = this.listenerMap[n ? 1 : 0], i[o] || (s && s.addEventListener(o, this.handle, n), i[o] = []), t ? /^[a-z]+$/i.test(t) ? (r = t, a = y) : /^#[a-z0-9\-_]+$/i.test(t) ? (r = t.slice(1), a = v) : (r = t, a = Element.prototype.matches) : (r = null, a = w.bind(this)), i[o].push({
|
|
32
|
+
selector: t,
|
|
33
|
+
handler: e,
|
|
34
|
+
matcher: a,
|
|
35
|
+
matcherParam: r
|
|
772
36
|
}), this;
|
|
773
37
|
};
|
|
774
|
-
|
|
775
|
-
let
|
|
776
|
-
if (typeof
|
|
777
|
-
return this.off(t, e,
|
|
778
|
-
if (
|
|
779
|
-
for (
|
|
780
|
-
|
|
38
|
+
d.prototype.off = function(o, t, e, n) {
|
|
39
|
+
let s, i, a, r, h;
|
|
40
|
+
if (typeof t == "function" && (n = e, e = t, t = null), n === void 0)
|
|
41
|
+
return this.off(o, t, e, !0), this.off(o, t, e, !1), this;
|
|
42
|
+
if (a = this.listenerMap[n ? 1 : 0], !o) {
|
|
43
|
+
for (h in a)
|
|
44
|
+
a.hasOwnProperty(h) && this.off(h, t, e);
|
|
781
45
|
return this;
|
|
782
46
|
}
|
|
783
|
-
if (
|
|
47
|
+
if (r = a[o], !r || !r.length)
|
|
784
48
|
return this;
|
|
785
|
-
for (
|
|
786
|
-
i =
|
|
787
|
-
return
|
|
49
|
+
for (s = r.length - 1; s >= 0; s--)
|
|
50
|
+
i = r[s], (!t || t === i.selector) && (!e || e === i.handler) && (this._removedListeners.push(i), r.splice(s, 1));
|
|
51
|
+
return r.length || (delete a[o], this.rootElement && this.rootElement.removeEventListener(o, this.handle, n)), this;
|
|
788
52
|
};
|
|
789
|
-
|
|
790
|
-
let
|
|
791
|
-
const
|
|
792
|
-
let
|
|
53
|
+
d.prototype.handle = function(o) {
|
|
54
|
+
let t, e;
|
|
55
|
+
const n = o.type;
|
|
56
|
+
let s, i, a, r, h = [], c;
|
|
793
57
|
const l = "ftLabsDelegateIgnore";
|
|
794
|
-
if (
|
|
58
|
+
if (o[l] === !0)
|
|
795
59
|
return;
|
|
796
|
-
switch (
|
|
60
|
+
switch (c = o.target, c.nodeType === 3 && (c = c.parentNode), c.correspondingUseElement && (c = c.correspondingUseElement), s = this.rootElement, i = o.eventPhase || (o.target !== o.currentTarget ? 3 : 2), i) {
|
|
797
61
|
case 1:
|
|
798
|
-
|
|
62
|
+
h = this.listenerMap[1][n];
|
|
799
63
|
break;
|
|
800
64
|
case 2:
|
|
801
|
-
this.listenerMap[0] && this.listenerMap[0][
|
|
65
|
+
this.listenerMap[0] && this.listenerMap[0][n] && (h = h.concat(this.listenerMap[0][n])), this.listenerMap[1] && this.listenerMap[1][n] && (h = h.concat(this.listenerMap[1][n]));
|
|
802
66
|
break;
|
|
803
67
|
case 3:
|
|
804
|
-
|
|
68
|
+
h = this.listenerMap[0][n];
|
|
805
69
|
break;
|
|
806
70
|
}
|
|
807
|
-
let
|
|
808
|
-
for (
|
|
809
|
-
for (
|
|
810
|
-
|
|
811
|
-
if (
|
|
71
|
+
let u = [];
|
|
72
|
+
for (e = h.length; c && e; ) {
|
|
73
|
+
for (t = 0; t < e && (a = h[t], !!a); t++)
|
|
74
|
+
c.tagName && ["button", "input", "select", "textarea"].indexOf(c.tagName.toLowerCase()) > -1 && c.hasAttribute("disabled") ? u = [] : a.matcher.call(c, a.matcherParam, c) && u.push([o, c, a]);
|
|
75
|
+
if (c === s || (e = h.length, c = c.parentElement || c.parentNode, c instanceof HTMLDocument))
|
|
812
76
|
break;
|
|
813
77
|
}
|
|
814
|
-
let
|
|
815
|
-
for (
|
|
816
|
-
if (!(this._removedListeners.indexOf(
|
|
817
|
-
|
|
78
|
+
let m;
|
|
79
|
+
for (t = 0; t < u.length; t++)
|
|
80
|
+
if (!(this._removedListeners.indexOf(u[t][2]) > -1) && (r = this.fire.apply(this, u[t]), r === !1)) {
|
|
81
|
+
u[t][0][l] = !0, u[t][0].preventDefault(), m = !1;
|
|
818
82
|
break;
|
|
819
83
|
}
|
|
820
|
-
return
|
|
84
|
+
return m;
|
|
821
85
|
};
|
|
822
|
-
|
|
823
|
-
return
|
|
86
|
+
d.prototype.fire = function(o, t, e) {
|
|
87
|
+
return e.handler.call(t, o, t);
|
|
824
88
|
};
|
|
825
|
-
function
|
|
826
|
-
return
|
|
89
|
+
function y(o, t) {
|
|
90
|
+
return o.toLowerCase() === t.tagName.toLowerCase();
|
|
827
91
|
}
|
|
828
|
-
function
|
|
92
|
+
function w(o, t) {
|
|
829
93
|
return this.rootElement === window ? (
|
|
830
94
|
// Match the outer document (dispatched from document)
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
) : this.rootElement ===
|
|
95
|
+
t === document || // The <html> element (dispatched from document.body or document.documentElement)
|
|
96
|
+
t === document.documentElement || // Or the window itself (dispatched from window)
|
|
97
|
+
t === window
|
|
98
|
+
) : this.rootElement === t;
|
|
835
99
|
}
|
|
836
|
-
function
|
|
837
|
-
return
|
|
100
|
+
function v(o, t) {
|
|
101
|
+
return o === t.id;
|
|
838
102
|
}
|
|
839
|
-
|
|
103
|
+
d.prototype.destroy = function() {
|
|
840
104
|
this.off(), this.root();
|
|
841
105
|
};
|
|
842
|
-
|
|
843
|
-
|
|
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 s = te(t), c = Array.from(t.attributes);
|
|
887
|
-
let a = oe(c, s);
|
|
888
|
-
a["data-trackable"] && (a = Object.assign(
|
|
889
|
-
a,
|
|
890
|
-
Zt(t, n, o)
|
|
891
|
-
)), r.push(a);
|
|
892
|
-
const u = re(c, s, t === n);
|
|
893
|
-
_(u, i), t = t.parentNode;
|
|
894
|
-
}
|
|
895
|
-
return { trace: r, customContext: i };
|
|
106
|
+
function g(o) {
|
|
107
|
+
return typeof o == "string" ? o.trim() : o;
|
|
896
108
|
}
|
|
897
|
-
|
|
898
|
-
const
|
|
899
|
-
|
|
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(), _(i, o), t.context = o;
|
|
918
|
-
const s = m(h("config"), t);
|
|
919
|
-
x.track(s);
|
|
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 s = n.getContextData(e);
|
|
948
|
-
if (typeof s != "object")
|
|
949
|
-
throw new Error("opts.getContextData function should return {object}");
|
|
950
|
-
i = At(s, fe);
|
|
951
|
-
} else
|
|
952
|
-
i = {};
|
|
953
|
-
i.domPathTokens = o, i.url = window.document.location.href || null, _(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((s) => {
|
|
964
|
-
if (s.isIntersecting || s.intersectionRatio > 0) {
|
|
965
|
-
const c = {
|
|
966
|
-
action: t.action || "view",
|
|
967
|
-
category: t.category || "component"
|
|
968
|
-
}, a = s.target;
|
|
969
|
-
le(c, a, t), x.track(c), r.unobserve(a);
|
|
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);
|
|
109
|
+
function b(o, t) {
|
|
110
|
+
for (const e in o)
|
|
111
|
+
t[e] ? console.warn(`You can't set a custom property called ${e}`) : t[e] = o[e];
|
|
981
112
|
}
|
|
982
|
-
|
|
983
|
-
|
|
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), It(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)
|
|
113
|
+
const k = (o, t, e) => {
|
|
114
|
+
const n = Array.from(o.querySelectorAll(e)), s = n.findIndex((i) => i === t);
|
|
115
|
+
if (s !== -1)
|
|
1045
116
|
return {
|
|
1046
|
-
siblings:
|
|
1047
|
-
position:
|
|
117
|
+
siblings: n.length,
|
|
118
|
+
position: s
|
|
1048
119
|
};
|
|
1049
|
-
},
|
|
120
|
+
}, E = [
|
|
1050
121
|
"nodeName",
|
|
1051
122
|
"className",
|
|
1052
123
|
"id",
|
|
1053
124
|
"href",
|
|
1054
125
|
"text",
|
|
1055
126
|
"role"
|
|
1056
|
-
],
|
|
1057
|
-
const
|
|
1058
|
-
for (const
|
|
1059
|
-
const
|
|
1060
|
-
|
|
127
|
+
], A = (o) => {
|
|
128
|
+
const t = {};
|
|
129
|
+
for (const e of E) {
|
|
130
|
+
const n = o[e] || o.getAttribute(e) || o.hasAttribute(e);
|
|
131
|
+
n !== void 0 && (typeof n == "boolean" ? t[e] = n : t[e] = g(n));
|
|
1061
132
|
}
|
|
1062
|
-
return
|
|
1063
|
-
},
|
|
133
|
+
return t;
|
|
134
|
+
}, N = (o) => {
|
|
1064
135
|
try {
|
|
1065
|
-
const
|
|
1066
|
-
return [
|
|
136
|
+
const t = JSON.parse(o), e = Object.prototype.toString.call(t);
|
|
137
|
+
return [e === "[object Object]" || e === "[object Array]", t];
|
|
1067
138
|
} catch {
|
|
1068
139
|
return [!1, null];
|
|
1069
140
|
}
|
|
1070
|
-
},
|
|
1071
|
-
const [
|
|
1072
|
-
return
|
|
1073
|
-
},
|
|
1074
|
-
(
|
|
1075
|
-
).forEach((
|
|
1076
|
-
e
|
|
1077
|
-
}),
|
|
1078
|
-
const
|
|
1079
|
-
return
|
|
1080
|
-
typeof
|
|
1081
|
-
}),
|
|
1082
|
-
|
|
1083
|
-
}),
|
|
1084
|
-
};
|
|
1085
|
-
function
|
|
1086
|
-
const
|
|
1087
|
-
for (;
|
|
1088
|
-
const
|
|
1089
|
-
let
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
)),
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1096
|
-
}
|
|
1097
|
-
return { trace:
|
|
1098
|
-
}
|
|
1099
|
-
const
|
|
1100
|
-
class
|
|
141
|
+
}, P = (o) => {
|
|
142
|
+
const [t, e] = N(o);
|
|
143
|
+
return t ? e : o;
|
|
144
|
+
}, $ = (o, t) => (o.filter(
|
|
145
|
+
(e) => e.name.match(/^data-trackable|^data-o-|^aria-/i)
|
|
146
|
+
).forEach((e) => {
|
|
147
|
+
t[e.name] = e.value;
|
|
148
|
+
}), t), x = (o, t, e) => {
|
|
149
|
+
const n = {};
|
|
150
|
+
return e && E.forEach((s) => {
|
|
151
|
+
typeof t[s] < "u" && s !== "id" && (n[s] = t[s]);
|
|
152
|
+
}), o.filter((s) => s.name.match(/^data-trackable-context-/i)).forEach((s) => {
|
|
153
|
+
n[s.name.replace("data-trackable-context-", "")] = P(s.value);
|
|
154
|
+
}), n;
|
|
155
|
+
};
|
|
156
|
+
function C(o, t) {
|
|
157
|
+
const e = o, n = e.getAttribute("data-trackable") ? `[data-trackable="${e.getAttribute("data-trackable")}"]` : e.nodeName, s = [], i = {};
|
|
158
|
+
for (; o && o !== t; ) {
|
|
159
|
+
const a = A(o), r = Array.from(o.attributes);
|
|
160
|
+
let h = $(r, a);
|
|
161
|
+
h["data-trackable"] && (h = Object.assign(
|
|
162
|
+
h,
|
|
163
|
+
k(o, e, n)
|
|
164
|
+
)), s.push(h);
|
|
165
|
+
const c = x(r, a, o === e);
|
|
166
|
+
b(c, i), o = o.parentNode;
|
|
167
|
+
}
|
|
168
|
+
return { trace: s, customContext: i };
|
|
169
|
+
}
|
|
170
|
+
const L = ["ctrlKey", "altKey", "shiftKey", "metaKey"];
|
|
171
|
+
class M {
|
|
1101
172
|
constructor({
|
|
1102
|
-
id:
|
|
1103
|
-
name:
|
|
1104
|
-
subtype:
|
|
1105
|
-
teamName:
|
|
173
|
+
id: t = "00000000-0000-0000-0000-000000000000",
|
|
174
|
+
name: e = "ccc-component",
|
|
175
|
+
subtype: n = "interactive",
|
|
176
|
+
teamName: s = "djd",
|
|
1106
177
|
shadowRoot: i = null,
|
|
1107
|
-
category:
|
|
1108
|
-
elements:
|
|
178
|
+
category: a = "cta",
|
|
179
|
+
elements: r = 'a, button, input, [role="button"]'
|
|
1109
180
|
}) {
|
|
1110
|
-
this.cccId =
|
|
181
|
+
this.cccId = t, this.cccName = e, this.subtype = n, this.teamName = s, this.shadowRoot = i, this.category = a, this.elements = r, this.isInitialised = !1;
|
|
1111
182
|
}
|
|
1112
183
|
// Get properties for the event (as opposed to properties of the clicked element)
|
|
1113
|
-
getEventProperties(
|
|
1114
|
-
const
|
|
1115
|
-
for (const
|
|
1116
|
-
if (
|
|
184
|
+
getEventProperties(t) {
|
|
185
|
+
const e = {};
|
|
186
|
+
for (const n of L)
|
|
187
|
+
if (t[n])
|
|
1117
188
|
try {
|
|
1118
|
-
n
|
|
1119
|
-
} catch (
|
|
1120
|
-
console.log(
|
|
189
|
+
e[n] = g(t[n]);
|
|
190
|
+
} catch (s) {
|
|
191
|
+
console.log(s);
|
|
1121
192
|
}
|
|
1122
|
-
return
|
|
193
|
+
return e;
|
|
1123
194
|
}
|
|
1124
195
|
// Controller for handling click events
|
|
1125
|
-
handleClickEvent(
|
|
1126
|
-
return (
|
|
1127
|
-
const i = this.getEventProperties(
|
|
1128
|
-
i.custom =
|
|
196
|
+
handleClickEvent(t, e) {
|
|
197
|
+
return (n, s) => {
|
|
198
|
+
const i = this.getEventProperties(n), { trace: a, customContext: r } = C(s, e);
|
|
199
|
+
i.custom = s.dataset && s.dataset.custom ? JSON.parse(s.dataset.custom) : null, i.domPathTokens = a, i.component = {
|
|
1129
200
|
id: this.cccId,
|
|
1130
201
|
name: this.cccName,
|
|
1131
202
|
type: "custom-code-component",
|
|
1132
203
|
subtype: this.subtype
|
|
1133
|
-
}, i.teamName = this.teamName,
|
|
204
|
+
}, i.teamName = this.teamName, b(r, i), t.context = i, t.method = "ftCustomAnalytics", document.body.dispatchEvent(
|
|
1134
205
|
new CustomEvent("oTracking.event", {
|
|
1135
|
-
detail:
|
|
206
|
+
detail: t,
|
|
1136
207
|
bubbles: !0,
|
|
1137
208
|
composed: !0
|
|
1138
209
|
})
|
|
1139
210
|
);
|
|
1140
211
|
};
|
|
1141
212
|
}
|
|
1142
|
-
sendSpoorEvent(
|
|
1143
|
-
const
|
|
213
|
+
sendSpoorEvent(t, e) {
|
|
214
|
+
const n = {
|
|
1144
215
|
category: "component",
|
|
1145
216
|
action: "act",
|
|
1146
217
|
context: {
|
|
@@ -1151,37 +222,37 @@ class Pe {
|
|
|
1151
222
|
subtype: this.subtype
|
|
1152
223
|
},
|
|
1153
224
|
teamName: this.teamName,
|
|
1154
|
-
trigger_action:
|
|
1155
|
-
custom:
|
|
225
|
+
trigger_action: t,
|
|
226
|
+
custom: e
|
|
1156
227
|
},
|
|
1157
228
|
method: "ftCustomAnalytics"
|
|
1158
229
|
};
|
|
1159
230
|
document.body.dispatchEvent(
|
|
1160
231
|
new CustomEvent("oTracking.event", {
|
|
1161
|
-
detail:
|
|
232
|
+
detail: n,
|
|
1162
233
|
bubbles: !0,
|
|
1163
234
|
composed: !0
|
|
1164
235
|
})
|
|
1165
236
|
);
|
|
1166
237
|
}
|
|
1167
|
-
init(
|
|
1168
|
-
var
|
|
238
|
+
init(t) {
|
|
239
|
+
var e;
|
|
1169
240
|
if (!this.isInitialised) {
|
|
1170
|
-
this.isInitialised = !0, this.cccId =
|
|
1171
|
-
const
|
|
241
|
+
this.isInitialised = !0, this.cccId = t || this.cccId;
|
|
242
|
+
const n = {
|
|
1172
243
|
action: "click",
|
|
1173
244
|
category: this.category
|
|
1174
|
-
},
|
|
1175
|
-
this.shadowRoot && new
|
|
245
|
+
}, s = (e = this.shadowRoot) == null ? void 0 : e.querySelector("[data-component-root]");
|
|
246
|
+
this.shadowRoot && new d(s).on(
|
|
1176
247
|
"click",
|
|
1177
248
|
this.elements,
|
|
1178
|
-
this.handleClickEvent(
|
|
249
|
+
this.handleClickEvent(n, s),
|
|
1179
250
|
!0
|
|
1180
251
|
);
|
|
1181
252
|
}
|
|
1182
253
|
}
|
|
1183
254
|
}
|
|
1184
|
-
class
|
|
255
|
+
class O extends HTMLElement {
|
|
1185
256
|
constructor() {
|
|
1186
257
|
super(...arguments), this.RESERVED_ATTRS = /* @__PURE__ */ new Set([
|
|
1187
258
|
"iframe",
|
|
@@ -1192,119 +263,120 @@ class _e extends HTMLElement {
|
|
|
1192
263
|
"shadow-open",
|
|
1193
264
|
"env",
|
|
1194
265
|
"load-timeout"
|
|
1195
|
-
]), this.unmount = (
|
|
266
|
+
]), this.unmount = (t) => {
|
|
1196
267
|
}, this.channel = new MessageChannel();
|
|
1197
268
|
}
|
|
1198
269
|
async mount() {
|
|
1199
270
|
if (!this.app)
|
|
1200
271
|
throw new Error("CCC mounted without App");
|
|
1201
|
-
const
|
|
1202
|
-
[...this.attributes].filter((
|
|
272
|
+
const t = this.shadowRoot ?? this.attachShadow({ mode: this.mode }), e = this.app, n = JSON.parse(this.getAttribute("data-component-props")), s = Object.fromEntries(
|
|
273
|
+
[...this.attributes].filter((r) => !this.RESERVED_ATTRS.has(r.name)).map((r) => [r.name, r.value])
|
|
1203
274
|
);
|
|
1204
|
-
this.tracking = new
|
|
275
|
+
this.tracking = new M({
|
|
1205
276
|
name: `${this.getAttribute("path")}@${this.getAttribute("version")}`,
|
|
1206
277
|
subtype: "interactive",
|
|
1207
278
|
teamName: "djd",
|
|
1208
279
|
shadowRoot: this.shadowRoot
|
|
1209
280
|
});
|
|
1210
|
-
const { unmount: i, onmessage:
|
|
1211
|
-
|
|
281
|
+
const { unmount: i, onmessage: a } = e(
|
|
282
|
+
t,
|
|
1212
283
|
{
|
|
1213
|
-
...
|
|
1214
|
-
data:
|
|
284
|
+
...s,
|
|
285
|
+
data: n,
|
|
1215
286
|
port: this.channel.port2,
|
|
1216
287
|
tracking: this.tracking
|
|
1217
288
|
},
|
|
1218
289
|
...this.children
|
|
1219
290
|
) || {};
|
|
1220
|
-
i && (this.unmount = i),
|
|
291
|
+
i && (this.unmount = i), a && (this.onmessage = a);
|
|
1221
292
|
}
|
|
1222
293
|
async connectedCallback() {
|
|
1223
|
-
var
|
|
1224
|
-
const
|
|
1225
|
-
if (!
|
|
294
|
+
var c;
|
|
295
|
+
const t = this.getAttribute("path"), e = this.getAttribute("version"), n = this.getAttribute("load-timeout") ?? 2e3, s = (c = this.getAttribute("env")) == null ? void 0 : c.toLowerCase().startsWith("d");
|
|
296
|
+
if (!t)
|
|
1226
297
|
throw new Error(
|
|
1227
298
|
"path attribute not specified in <custom-code-component>"
|
|
1228
299
|
);
|
|
1229
|
-
const [i,
|
|
1230
|
-
if (!
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
import
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
}
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
300
|
+
const [i, a, r] = t.split("/").reverse();
|
|
301
|
+
if (!i || !a || !r)
|
|
302
|
+
return;
|
|
303
|
+
const h = this.getAttribute("id");
|
|
304
|
+
this.source = s ? `http://localhost:5173/src/${i}/index.jsx?id=${h}` : `https://www.ft.com/__component/${r}/${a}${e ? `@${e}` : "@latest"}/${i}/${i}.js?id=${h}`;
|
|
305
|
+
try {
|
|
306
|
+
this.app = await new Promise((l, u) => {
|
|
307
|
+
const m = setTimeout(() => {
|
|
308
|
+
this.dispatchEvent(
|
|
309
|
+
new CustomEvent("ccc-timeout", {
|
|
310
|
+
bubbles: !0,
|
|
311
|
+
cancelable: !0,
|
|
312
|
+
detail: {
|
|
313
|
+
component: `${t}@${e}`,
|
|
314
|
+
source: this.source
|
|
315
|
+
}
|
|
316
|
+
})
|
|
317
|
+
), this.dataset.cccError = "import-timeout", delete this.dataset.cccReady;
|
|
318
|
+
}, Number(n));
|
|
319
|
+
import(
|
|
320
|
+
/* webpackIgnore: true */
|
|
321
|
+
this.source
|
|
322
|
+
/* @vite-ignore */
|
|
323
|
+
).then(({ default: p }) => {
|
|
324
|
+
if (p)
|
|
325
|
+
clearTimeout(m), l(p);
|
|
326
|
+
else
|
|
327
|
+
throw new f(
|
|
328
|
+
"No component renderer default export found"
|
|
329
|
+
);
|
|
330
|
+
}).catch((p) => u(new f(p)));
|
|
331
|
+
});
|
|
332
|
+
} catch (l) {
|
|
333
|
+
console.error(
|
|
334
|
+
`<custom-code-component> error during import from ${t}@${e}`
|
|
335
|
+
), delete this.dataset.cccReady, this.dataset.cccError = "import-failure", this.dispatchEvent(new ErrorEvent("error", l)), console.error(l);
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
try {
|
|
339
|
+
this.mode = this.getAttribute("shadow-open") == "false" ? "closed" : "open", await this.mount(), this.dispatchEvent(
|
|
340
|
+
new CustomEvent("ccc-connected", {
|
|
341
|
+
bubbles: !0,
|
|
342
|
+
cancelable: !0,
|
|
343
|
+
detail: {
|
|
344
|
+
component: `${t}@${e}`,
|
|
345
|
+
source: this.source
|
|
346
|
+
}
|
|
347
|
+
})
|
|
348
|
+
), this.dataset.cccReady = "true", delete this.dataset.cccError;
|
|
349
|
+
} catch (l) {
|
|
350
|
+
console.info(
|
|
351
|
+
`<custom-code-component> uncaught error during mount from ${t}@${e}`
|
|
352
|
+
), console.error(l), this.dispatchEvent(new ErrorEvent("error", l)), this.dataset.cccError = "mount-error", delete this.dataset.cccReady;
|
|
353
|
+
}
|
|
354
|
+
try {
|
|
355
|
+
this.tracking.init(this.id);
|
|
356
|
+
} catch (l) {
|
|
357
|
+
console.info(
|
|
358
|
+
`Error initialising tracking on <custom-code-component> ${t}@${e}`
|
|
359
|
+
), console.error(l);
|
|
1288
360
|
}
|
|
1289
361
|
}
|
|
1290
362
|
disconnectedCallback() {
|
|
1291
|
-
const
|
|
1292
|
-
console.info(`<custom-code-component:${
|
|
363
|
+
const t = this.getAttribute("path");
|
|
364
|
+
console.info(`<custom-code-component:${t}> disconnected`), typeof this.unmount == "function" && this.unmount();
|
|
1293
365
|
}
|
|
1294
366
|
onmessage() {
|
|
1295
367
|
}
|
|
1296
368
|
// I'm honestly not sure what to do with this
|
|
1297
|
-
postMessage(
|
|
1298
|
-
this.channel.port1.postMessage(
|
|
369
|
+
postMessage(t) {
|
|
370
|
+
this.channel.port1.postMessage(t);
|
|
1299
371
|
}
|
|
1300
372
|
}
|
|
1301
|
-
const
|
|
1302
|
-
customElements && !customElements.get("custom-code-component") &&
|
|
1303
|
-
class
|
|
1304
|
-
constructor(...
|
|
1305
|
-
super(...
|
|
373
|
+
const R = () => customElements.define("custom-code-component", O);
|
|
374
|
+
customElements && !customElements.get("custom-code-component") && R();
|
|
375
|
+
class f extends Error {
|
|
376
|
+
constructor(...t) {
|
|
377
|
+
super(...t), Error.captureStackTrace && Error.captureStackTrace(this, f), this.name = "CCCImportError";
|
|
1306
378
|
}
|
|
1307
379
|
}
|
|
1308
380
|
export {
|
|
1309
|
-
|
|
381
|
+
R as init
|
|
1310
382
|
};
|