zar 0.4.4 → 0.5.1

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/zar.es.js CHANGED
@@ -1,2084 +1,710 @@
1
- var __async = (__this, __arguments, generator) => {
2
- return new Promise((resolve, reject) => {
3
- var fulfilled = (value) => {
4
- try {
5
- step(generator.next(value));
6
- } catch (e2) {
7
- reject(e2);
8
- }
9
- };
10
- var rejected = (value) => {
11
- try {
12
- step(generator.throw(value));
13
- } catch (e2) {
14
- reject(e2);
15
- }
16
- };
17
- var step = (x2) => x2.done ? resolve(x2.value) : Promise.resolve(x2.value).then(fulfilled, rejected);
18
- step((generator = generator.apply(__this, __arguments)).next());
19
- });
20
- };
21
- function i$3(t2, e2, l2, n2, r2) {
22
- for (e2 = e2.split ? e2.split(".") : e2, n2 = 0; n2 < e2.length; n2++)
23
- t2 = t2 ? t2[e2[n2]] : r2;
24
- return t2 === r2 ? l2 : t2;
25
- }
26
- var e = "undefined", o$2 = "object", g$1 = "any", m$1 = "*", j$1 = "__", F$2 = typeof process != "undefined" ? process : {};
27
- F$2.env && F$2.env.NODE_ENV || "";
28
- var $$1 = typeof window != "undefined";
29
- F$2.versions != null && F$2.versions.node != null;
30
- typeof Deno != "undefined" && Deno.core !== void 0;
31
- $$1 && window.name === "nodejs" || typeof navigator != "undefined" && (navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom"));
32
- function M$1(n2, t2) {
33
- return t2.charAt(0)[n2]() + t2.slice(1);
34
- }
35
- var U$1 = M$1.bind(null, "toUpperCase"), H$1 = M$1.bind(null, "toLowerCase");
36
- function J$2(n2) {
37
- return Y$1(n2) ? U$1("null") : typeof n2 == "object" ? yn(n2) : Object.prototype.toString.call(n2).slice(8, -1);
38
- }
39
- function R$1(n2, t2) {
40
- t2 === void 0 && (t2 = true);
41
- var e2 = J$2(n2);
42
- return t2 ? H$1(e2) : e2;
43
- }
44
- function V$1(n2, t2) {
45
- return typeof t2 === n2;
46
- }
47
- var W$1 = V$1.bind(null, "function"), q$1 = V$1.bind(null, "string"), I$2 = V$1.bind(null, "undefined");
48
- var Q$1 = V$1.bind(null, "boolean");
49
- V$1.bind(null, "symbol");
50
- function Y$1(n2) {
51
- return n2 === null;
52
- }
53
- function nn(n2) {
54
- return R$1(n2) === "number" && !isNaN(n2);
55
- }
56
- function rn(n2) {
57
- return R$1(n2) === "array";
58
- }
59
- function on(n2) {
60
- if (!un(n2))
61
- return false;
62
- for (var t2 = n2; Object.getPrototypeOf(t2) !== null; )
63
- t2 = Object.getPrototypeOf(t2);
64
- return Object.getPrototypeOf(n2) === t2;
65
- }
66
- function un(n2) {
67
- return n2 && (typeof n2 == "object" || n2 !== null);
68
- }
69
- function yn(n2) {
70
- return W$1(n2.constructor) ? n2.constructor.name : null;
71
- }
72
- function hn(n2) {
73
- return n2 instanceof Error || q$1(n2.message) && n2.constructor && nn(n2.constructor.stackTraceLimit);
74
- }
75
- function On(n2, t2) {
76
- if (typeof t2 != "object" || Y$1(t2))
77
- return false;
78
- if (t2 instanceof n2)
79
- return true;
80
- var e2 = R$1(new n2(""));
81
- if (hn(t2))
82
- for (; t2; ) {
83
- if (R$1(t2) === e2)
84
- return true;
85
- t2 = Object.getPrototypeOf(t2);
86
- }
87
- return false;
88
- }
89
- On.bind(null, TypeError);
90
- On.bind(null, SyntaxError);
91
- function $n(n2, t2) {
92
- var e2 = n2 instanceof Element || n2 instanceof HTMLDocument;
93
- return e2 && t2 ? Tn(n2, t2) : e2;
94
- }
95
- function Tn(n2, t2) {
96
- return t2 === void 0 && (t2 = ""), n2 && n2.nodeName === t2.toUpperCase();
97
- }
98
- function _n(n2) {
99
- var t2 = [].slice.call(arguments, 1);
100
- return function() {
101
- return n2.apply(void 0, [].slice.call(arguments).concat(t2));
102
- };
103
- }
104
- _n($n, "form");
105
- _n($n, "button");
106
- _n($n, "input");
107
- _n($n, "select");
108
- function n$1(e2) {
109
- try {
110
- return decodeURIComponent(e2.replace(/\+/g, " "));
111
- } catch (e3) {
112
- return null;
113
- }
114
- }
115
- function o$1() {
116
- if ($$1) {
117
- var r2 = navigator, t2 = r2.languages;
118
- return r2.userLanguage || (t2 && t2.length ? t2[0] : r2.language);
119
- }
120
- }
121
- function a$3() {
122
- try {
123
- return Intl.DateTimeFormat().resolvedOptions().timeZone;
124
- } catch (e2) {
125
- }
126
- }
127
- function s(r2) {
128
- return function(e2) {
129
- for (var r3, t2 = /* @__PURE__ */ Object.create(null), o2 = /([^&=]+)=?([^&]*)/g; r3 = o2.exec(e2); ) {
130
- var a2 = n$1(r3[1]), i2 = n$1(r3[2]);
131
- a2.substring(a2.length - 2) === "[]" ? (t2[a2 = a2.substring(0, a2.length - 2)] || (t2[a2] = [])).push(i2) : t2[a2] = i2 === "" || i2;
132
- }
133
- for (var u2 in t2) {
134
- var c2 = u2.split("[");
135
- c2.length > 1 && (m(t2, c2.map(function(e3) {
136
- return e3.replace(/[?[\]\\ ]/g, "");
137
- }), t2[u2]), delete t2[u2]);
138
- }
139
- return t2;
140
- }(function(r3) {
141
- if (r3) {
142
- var t2 = r3.match(/\?(.*)/);
143
- return t2 && t2[1] ? t2[1].split("#")[0] : "";
144
- }
145
- return $$1 && window.location.search.substring(1);
146
- }(r2));
147
- }
148
- function m(e2, r2, t2) {
149
- for (var n2 = r2.length - 1, o2 = 0; o2 < n2; ++o2) {
150
- var a2 = r2[o2];
151
- if (a2 === "__proto__" || a2 === "constructor")
152
- break;
153
- a2 in e2 || (e2[a2] = {}), e2 = e2[a2];
154
- }
155
- e2[r2[n2]] = t2;
156
- }
157
- function y$1() {
158
- for (var e2 = "", r2 = 0, t2 = 4294967295 * Math.random() | 0; r2++ < 36; ) {
159
- var n2 = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[r2 - 1], o2 = 15 & t2;
160
- e2 += n2 == "-" || n2 == "4" ? n2 : (n2 == "x" ? o2 : 3 & o2 | 8).toString(16), t2 = r2 % 8 == 0 ? 4294967295 * Math.random() | 0 : t2 >> 4;
161
- }
162
- return e2;
163
- }
164
- var l = "global", o = j$1 + "global" + j$1, n = typeof self === o$2 && self.self === self && self || typeof global === o$2 && global.global === global && global || void 0;
165
- function a$2(t2) {
166
- return n[o][t2];
167
- }
168
- function f(t2, e2) {
169
- return n[o][t2] = e2;
170
- }
171
- function i$2(t2) {
172
- delete n[o][t2];
173
- }
174
- function u$1(t2, e2, r2) {
175
- var l2;
176
- try {
177
- if (b$2(t2)) {
178
- var o2 = window[t2];
179
- l2 = o2[e2].bind(o2);
180
- }
181
- } catch (t3) {
182
- }
183
- return l2 || r2;
184
- }
185
- n[o] || (n[o] = {});
186
- var c$1 = {};
187
- function b$2(t2) {
188
- if (typeof c$1[t2] !== e)
189
- return c$1[t2];
190
- try {
191
- var e$1 = window[t2];
192
- e$1.setItem(e, e), e$1.removeItem(e);
193
- } catch (e2) {
194
- return c$1[t2] = false;
195
- }
196
- return c$1[t2] = true;
197
- }
198
- function v() {
199
- return v = Object.assign || function(e2) {
200
- for (var n2 = 1; n2 < arguments.length; n2++) {
201
- var t2 = arguments[n2];
202
- for (var r2 in t2)
203
- Object.prototype.hasOwnProperty.call(t2, r2) && (e2[r2] = t2[r2]);
204
- }
205
- return e2;
206
- }, v.apply(this, arguments);
207
- }
208
- var y = "function", b$1 = "undefined", I$1 = "@@redux/" + Math.random().toString(36), w = /* @__PURE__ */ function() {
209
- return typeof Symbol === y && Symbol.observable || "@@observable";
210
- }(), E$1 = " != " + y;
211
- function P(e2, n2, t2) {
212
- var r2;
213
- if (typeof n2 === y && typeof t2 === b$1 && (t2 = n2, n2 = void 0), typeof t2 !== b$1) {
214
- if (typeof t2 !== y)
215
- throw new Error("enhancer" + E$1);
216
- return t2(P)(e2, n2);
217
- }
218
- if (typeof e2 !== y)
219
- throw new Error("reducer" + E$1);
220
- var i2 = e2, a2 = n2, o2 = [], u2 = o2, c2 = false;
221
- function s2() {
222
- u2 === o2 && (u2 = o2.slice());
223
- }
224
- function f2() {
225
- return a2;
226
- }
227
- function d2(e3) {
228
- if (typeof e3 !== y)
229
- throw new Error("Listener" + E$1);
230
- var n3 = true;
231
- return s2(), u2.push(e3), function() {
232
- if (n3) {
233
- n3 = false, s2();
234
- var t3 = u2.indexOf(e3);
235
- u2.splice(t3, 1);
236
- }
237
- };
238
- }
239
- function p(e3) {
240
- if (!on(e3))
241
- throw new Error("Act != obj");
242
- if (typeof e3.type === b$1)
243
- throw new Error("ActType " + b$1);
244
- if (c2)
245
- throw new Error("Dispatch in reducer");
1
+ var f = (t, e, n) => new Promise((r, a) => {
2
+ var i = (c) => {
246
3
  try {
247
- c2 = true, a2 = i2(a2, e3);
248
- } finally {
249
- c2 = false;
4
+ u(n.next(c));
5
+ } catch (s) {
6
+ a(s);
250
7
  }
251
- for (var n3 = o2 = u2, t3 = 0; t3 < n3.length; t3++)
252
- (0, n3[t3])();
253
- return e3;
254
- }
255
- return p({ type: "@@redux/INIT" }), (r2 = { dispatch: p, subscribe: d2, getState: f2, replaceReducer: function(e3) {
256
- if (typeof e3 !== y)
257
- throw new Error("next reducer" + E$1);
258
- i2 = e3, p({ type: "@@redux/INIT" });
259
- } })[w] = function() {
260
- var e3, n3 = d2;
261
- return (e3 = { subscribe: function(e4) {
262
- if (typeof e4 != "object")
263
- throw new TypeError("Observer != obj");
264
- function t3() {
265
- e4.next && e4.next(f2());
266
- }
267
- return t3(), { unsubscribe: n3(t3) };
268
- } })[w] = function() {
269
- return this;
270
- }, e3;
271
- }, r2;
272
- }
273
- function S(e2, n2) {
274
- var t2 = n2 && n2.type;
275
- return "action " + (t2 && t2.toString() || "?") + "reducer " + e2 + " returns " + b$1;
276
- }
277
- function N$1() {
278
- var e2 = [].slice.call(arguments);
279
- return e2.length === 0 ? function(e3) {
280
- return e3;
281
- } : e2.length === 1 ? e2[0] : e2.reduce(function(e3, n2) {
282
- return function() {
283
- return e3(n2.apply(void 0, [].slice.call(arguments)));
284
- };
285
- });
286
- }
287
- function O$1() {
288
- var e2 = arguments;
289
- return function(n2) {
290
- return function(t2, r2, i2) {
291
- var a2, o2 = n2(t2, r2, i2), u2 = o2.dispatch, c2 = { getState: o2.getState, dispatch: function(e3) {
292
- return u2(e3);
293
- } };
294
- return a2 = [].slice.call(e2).map(function(e3) {
295
- return e3(c2);
296
- }), v({}, o2, { dispatch: u2 = N$1.apply(void 0, a2)(o2.dispatch) });
297
- };
298
- };
299
- }
300
- var A$1 = j$1 + "anon_id", _ = j$1 + "user_id", x$1 = j$1 + "user_traits", j = "userId", T = "anonymousId", z = ["bootstrap", "params", "campaign", "initializeStart", "initialize", "initializeEnd", "ready", "resetStart", "reset", "resetEnd", "pageStart", "page", "pageEnd", "pageAborted", "trackStart", "track", "trackEnd", "trackAborted", "identifyStart", "identify", "identifyEnd", "identifyAborted", "userIdChanged", "registerPlugins", "enablePlugin", "disablePlugin", "online", "offline", "setItemStart", "setItem", "setItemEnd", "setItemAborted", "removeItemStart", "removeItem", "removeItemEnd", "removeItemAborted"], M = ["name", "EVENTS", "config", "loaded"], q = z.reduce(function(e2, n2) {
301
- return e2[n2] = n2, e2;
302
- }, { registerPluginType: function(e2) {
303
- return "registerPlugin:" + e2;
304
- }, pluginReadyType: function(e2) {
305
- return "ready:" + e2;
306
- } }), U = /^utm_/, V = /^an_prop_/, L$1 = /^an_trait_/;
307
- function C$1(e2) {
308
- var n2 = e2.storage.setItem;
309
- return function(t2) {
310
- return function(r2) {
311
- return function(i2) {
312
- if (i2.type === q.bootstrap) {
313
- var a2 = i2.params, o2 = i2.user, u2 = i2.persistedUser, c2 = i2.initialUser, s2 = u2.userId === o2.userId;
314
- u2.anonymousId !== o2.anonymousId && n2(A$1, o2.anonymousId), s2 || n2(_, o2.userId), c2.traits && n2(x$1, v({}, s2 && u2.traits ? u2.traits : {}, c2.traits));
315
- var l2 = Object.keys(i2.params);
316
- if (l2.length) {
317
- var f2 = a2.an_uid, d2 = a2.an_event, p = l2.reduce(function(e3, n3) {
318
- if (n3.match(U) || n3.match(/^(d|g)clid/)) {
319
- var t3 = n3.replace(U, "");
320
- e3.campaign[t3 === "campaign" ? "name" : t3] = a2[n3];
321
- }
322
- return n3.match(V) && (e3.props[n3.replace(V, "")] = a2[n3]), n3.match(L$1) && (e3.traits[n3.replace(L$1, "")] = a2[n3]), e3;
323
- }, { campaign: {}, props: {}, traits: {} });
324
- t2.dispatch(v({ type: q.params, raw: a2 }, p, f2 ? { userId: f2 } : {})), f2 && setTimeout(function() {
325
- return e2.identify(f2, p.traits);
326
- }, 0), d2 && setTimeout(function() {
327
- return e2.track(d2, p.props);
328
- }, 0), Object.keys(p.campaign).length && t2.dispatch({ type: q.campaign, campaign: p.campaign });
329
- }
330
- }
331
- return r2(i2);
332
- };
333
- };
8
+ }, o = (c) => {
9
+ try {
10
+ u(n.throw(c));
11
+ } catch (s) {
12
+ a(s);
13
+ }
14
+ }, u = (c) => c.done ? r(c.value) : Promise.resolve(c.value).then(i, o);
15
+ u((n = n.apply(t, e)).next());
16
+ });
17
+ function H({ app: t, plugins: e = [] } = {}) {
18
+ const n = {
19
+ app: t,
20
+ plugins: {},
21
+ page: (r = {}) => Q(n, r),
22
+ track: (r, a = {}, i) => X(
23
+ n,
24
+ i ? { event: r, properties: a, options: i } : { event: r, properties: a }
25
+ ),
26
+ reset: (...r) => f(this, null, function* () {
27
+ return K(n, ...r);
28
+ })
334
29
  };
335
- }
336
- function R(e2) {
337
- return function(n2, t2) {
338
- if (n2 === void 0 && (n2 = {}), t2 === void 0 && (t2 = {}), t2.type === q.setItemEnd) {
339
- if (t2.key === A$1)
340
- return v({}, n2, { anonymousId: t2.value });
341
- if (t2.key === _)
342
- return v({}, n2, { userId: t2.value });
343
- }
344
- switch (t2.type) {
345
- case q.identify:
346
- return Object.assign({}, n2, { userId: t2.userId, traits: v({}, n2.traits, t2.traits) });
347
- case q.reset:
348
- return [_, A$1, x$1].forEach(function(n3) {
349
- e2.removeItem(n3);
350
- }), Object.assign({}, n2, { userId: null, anonymousId: null, traits: {} });
351
- default:
352
- return n2;
353
- }
30
+ return e.forEach((r) => {
31
+ !r || !r.name || (r.instance = n, r.methods && Object.keys(r.methods).forEach((a) => {
32
+ const i = r.methods[a];
33
+ if (typeof i == "function") {
34
+ const o = i.bind(r);
35
+ r.methods[a] = o, r[a] = o;
36
+ }
37
+ }), n.plugins[r.name] = r);
38
+ }), e.forEach((r) => {
39
+ try {
40
+ r.initialize && r.initialize({ config: r.config, instance: n });
41
+ } catch (a) {
42
+ }
43
+ }), n;
44
+ }
45
+ const V = /#.*$/;
46
+ function W() {
47
+ return typeof window == "undefined" ? "" : window.location.href.replace(V, "");
48
+ }
49
+ function j(t = {}) {
50
+ if (typeof window == "undefined" || typeof document == "undefined")
51
+ return t;
52
+ const { title: e, referrer: n } = document, { innerWidth: r, innerHeight: a } = window, i = W(), o = {
53
+ title: e,
54
+ url: i,
55
+ width: r,
56
+ height: a
354
57
  };
58
+ return n && n !== "" && (o.referrer = n), Object.assign({}, o, t);
355
59
  }
356
- function $(e2) {
357
- return { userId: e2.getItem(_), anonymousId: e2.getItem(A$1), traits: e2.getItem(x$1) };
358
- }
359
- var D = function(e2) {
360
- return j$1 + "TEMP" + j$1 + e2;
361
- };
362
- function B(n2) {
363
- var t2 = n2.storage, r2 = t2.setItem, i2 = t2.removeItem, a2 = t2.getItem;
364
- return function(n3) {
365
- return function(t3) {
366
- return function(u2) {
367
- var c2 = u2.userId, s2 = u2.traits, l2 = u2.options;
368
- if (u2.type === q.reset && ([_, x$1, A$1].forEach(function(e2) {
369
- i2(e2);
370
- }), [j, T, "traits"].forEach(function(e2) {
371
- i$2(D(e2));
372
- })), u2.type === q.identify) {
373
- a2(A$1) || r2(A$1, y$1());
374
- var f2 = a2(_), d2 = a2(x$1) || {};
375
- f2 && f2 !== c2 && n3.dispatch({ type: q.userIdChanged, old: { userId: f2, traits: d2 }, new: { userId: c2, traits: s2 }, options: l2 }), c2 && r2(_, c2), s2 && r2(x$1, v({}, d2, s2));
60
+ function Q(n) {
61
+ return f(this, arguments, function* (t, e = {}) {
62
+ e.type || (e.type = "page"), e.properties = j(e.properties || {}), Object.values(t.plugins).forEach((r) => {
63
+ if (typeof r.pageStart == "function")
64
+ try {
65
+ const a = r.pageStart({ payload: e, config: r.config, instance: t });
66
+ a && (e = a);
67
+ } catch (a) {
376
68
  }
377
- return t3(u2);
378
- };
379
- };
380
- };
381
- }
382
- var X = {};
383
- function J$1(e2, n2) {
384
- X[e2] && W$1(X[e2]) && (X[e2](n2), delete X[e2]);
385
- }
386
- function W(e2, n2, t2) {
387
- return new Promise(function(r2, i2) {
388
- return n2() ? r2(e2) : t2 < 1 ? i2(v({}, e2, { queue: true })) : new Promise(function(e3) {
389
- return setTimeout(e3, 10);
390
- }).then(function(a2) {
391
- return W(e2, n2, t2 - 10).then(r2, i2);
392
69
  });
393
- });
394
- }
395
- function H(e2, n2, t2) {
396
- var r2 = n2(), i2 = e2.getState(), a2 = i2.plugins, o2 = i2.queue, u2 = i2.user;
397
- if (!i2.context.offline && o2 && o2.actions && o2.actions.length) {
398
- var c2 = o2.actions.reduce(function(e3, n3, t3) {
399
- return a2[n3.plugin].loaded ? (e3.process.push(n3), e3.processIndex.push(t3)) : (e3.requeue.push(n3), e3.requeueIndex.push(t3)), e3;
400
- }, { processIndex: [], process: [], requeue: [], requeueIndex: [] });
401
- if (c2.processIndex && c2.processIndex.length) {
402
- c2.processIndex.forEach(function(n3) {
403
- var i3 = o2.actions[n3], c3 = i3.plugin, s3 = i3.payload.type, l2 = r2[c3][s3];
404
- if (l2 && W$1(l2)) {
405
- var f2 = function(e3, n4) {
406
- return e3 === void 0 && (e3 = {}), n4 === void 0 && (n4 = {}), [j, T].reduce(function(t3, r3) {
407
- return e3.hasOwnProperty(r3) && n4[r3] && n4[r3] !== e3[r3] && (t3[r3] = n4[r3]), t3;
408
- }, e3);
409
- }(i3.payload, u2);
410
- l2({ payload: f2, config: a2[c3].config, instance: t2 });
411
- var p = s3 + ":" + c3;
412
- e2.dispatch(v({}, f2, { type: p, _: { called: p, from: "queueDrain" } }));
70
+ for (const r of Object.values(t.plugins))
71
+ if (typeof r.page == "function")
72
+ try {
73
+ yield r.page({ payload: e, options: {}, instance: t, config: r.config });
74
+ } catch (a) {
413
75
  }
414
- });
415
- var s2 = o2.actions.filter(function(e3, n3) {
416
- return !~c2.processIndex.indexOf(n3);
417
- });
418
- o2.actions = s2;
419
- }
420
- }
76
+ return e;
77
+ });
421
78
  }
422
- var F$1 = function(e2) {
423
- var n2 = e2.data, t2 = e2.action, r2 = e2.instance, i2 = e2.state, a2 = e2.allPlugins, o2 = e2.allMatches, u2 = e2.store, c2 = e2.EVENTS;
424
- try {
425
- var s2 = i2.plugins, f2 = i2.context, p = t2.type, m2 = p.match(G$1), g2 = n2.exact.map(function(e3) {
426
- return e3.pluginName;
427
- });
428
- m2 && (g2 = o2.during.map(function(e3) {
429
- return e3.pluginName;
430
- }));
431
- var h2 = function(e3, n3) {
432
- return function(t3, r3, i3) {
433
- var a3 = r3.config, o3 = r3.name, u3 = o3 + "." + t3.type;
434
- i3 && (u3 = i3.event);
435
- var c3 = t3.type.match(G$1) ? function(e4, n4, t4, r4, i4) {
436
- return function(a4, o4) {
437
- var u4 = r4 ? r4.name : e4, c4 = o4 && ie(o4) ? o4 : t4;
438
- if (r4 && (!(c4 = o4 && ie(o4) ? o4 : [e4]).includes(e4) || c4.length !== 1))
439
- throw new Error("Method " + n4 + " can only abort " + e4 + " plugin. " + JSON.stringify(c4) + " input valid");
440
- return v({}, i4, { abort: { reason: a4, plugins: c4, caller: n4, _: u4 } });
441
- };
442
- }(o3, u3, n3, i3, t3) : function(e4, n4) {
443
- return function() {
444
- throw new Error(e4.type + " action not cancellable. Remove abort in " + n4);
445
- };
446
- }(t3, u3);
447
- return { payload: ue(t3), instance: e3, config: a3 || {}, abort: c3 };
448
- };
449
- }(r2, g2), y2 = n2.exact.reduce(function(e3, n3) {
450
- var t3 = n3.pluginName, r3 = n3.methodName, i3 = false;
451
- return r3.match(/^initialize/) || r3.match(/^reset/) || (i3 = !s2[t3].loaded), f2.offline && r3.match(/^(page|track|identify)/) && (i3 = true), e3["" + t3] = i3, e3;
452
- }, {});
453
- return Promise.resolve(n2.exact.reduce(function(e3, i3, o3) {
454
- var u3 = i3.pluginName;
455
- return Promise.resolve(e3).then(function(e4) {
456
- function i4() {
457
- return Promise.resolve(e4);
458
- }
459
- var o4 = function() {
460
- if (n2.namespaced && n2.namespaced[u3])
461
- return Promise.resolve(n2.namespaced[u3].reduce(function(e5, n3, t3) {
462
- return Promise.resolve(e5).then(function(e6) {
463
- return n3.method && W$1(n3.method) ? (function(e7, n4) {
464
- var t5 = oe(e7);
465
- if (t5 && t5.name === n4) {
466
- var r3 = oe(t5.method);
467
- throw new Error([n4 + " plugin is calling method " + e7, "Plugins cant call self", "Use " + t5.method + " " + (r3 ? "or " + r3.method : "") + " in " + n4 + " plugin insteadof " + e7].join("\n"));
468
- }
469
- }(n3.methodName, n3.pluginName), Promise.resolve(n3.method({ payload: e6, instance: r2, abort: (t4 = e6, i5 = u3, o5 = n3.pluginName, function(e7, n4) {
470
- return v({}, t4, { abort: { reason: e7, plugins: n4 || [i5], caller: p, from: o5 || i5 } });
471
- }), config: Z(n3.pluginName, s2, a2), plugins: s2 })).then(function(n4) {
472
- var t5 = on(n4) ? n4 : {};
473
- return Promise.resolve(v({}, e6, t5));
474
- })) : e6;
475
- var t4, i5, o5;
476
- });
477
- }, Promise.resolve(t2))).then(function(n3) {
478
- e4[u3] = n3;
479
- });
480
- e4[u3] = t2;
481
- }();
482
- return o4 && o4.then ? o4.then(i4) : i4();
483
- });
484
- }, Promise.resolve({}))).then(function(e3) {
485
- return Promise.resolve(n2.exact.reduce(function(t3, i3, o3) {
79
+ function X(n) {
80
+ return f(this, arguments, function* (t, e = {}) {
81
+ e.type || (e.type = "track");
82
+ const r = j(), a = e.properties || {};
83
+ a.url === void 0 && (a.url = r.url), a.referrer === void 0 && r.referrer !== void 0 && (a.referrer = r.referrer), e.properties = a;
84
+ const i = e.options || {}, o = i && typeof i.plugins == "object" ? i.plugins : null, u = (c) => o && o[c.name] === !1;
85
+ Object.values(t.plugins).forEach((c) => {
86
+ if (!u(c) && typeof c.trackStart == "function")
486
87
  try {
487
- var c3 = n2.exact.length === o3 + 1, f3 = i3.pluginName, d2 = a2[f3];
488
- return Promise.resolve(t3).then(function(n3) {
489
- var t4 = e3[f3] ? e3[f3] : {};
490
- if (m2 && (t4 = n3), te(t4, f3))
491
- return Y({ data: t4, method: p, instance: r2, pluginName: f3, store: u2 }), Promise.resolve(n3);
492
- if (te(n3, f3))
493
- return c3 && Y({ data: n3, method: p, instance: r2, store: u2 }), Promise.resolve(n3);
494
- if (y2.hasOwnProperty(f3) && y2[f3] === true)
495
- return u2.dispatch({ type: "queue", plugin: f3, payload: t4, _: { called: "queue", from: "queueMechanism" } }), Promise.resolve(n3);
496
- var i4 = h2(e3[f3], a2[f3]);
497
- return Promise.resolve(d2[p]({ abort: i4.abort, payload: t4, instance: r2, config: Z(f3, s2, a2), plugins: s2 })).then(function(i5) {
498
- var a3 = on(i5) ? i5 : {}, o4 = v({}, n3, a3), c4 = e3[f3];
499
- if (te(c4, f3))
500
- Y({ data: c4, method: p, instance: r2, pluginName: f3, store: u2 });
501
- else {
502
- var s3 = p + ":" + f3;
503
- (s3.match(/:/g) || []).length < 2 && !p.match(K) && !p.match(Q) && r2.dispatch(v({}, m2 ? o4 : t4, { type: s3, _: { called: s3, from: "submethod" } }));
504
- }
505
- return Promise.resolve(o4);
506
- });
88
+ const s = c.trackStart({
89
+ payload: e,
90
+ options: i,
91
+ config: c.config,
92
+ instance: t
507
93
  });
508
- } catch (e4) {
509
- return Promise.reject(e4);
510
- }
511
- }, Promise.resolve(t2))).then(function(e4) {
512
- if (!(p.match(G$1) || p.match(/^registerPlugin/) || p.match(Q) || p.match(K) || p.match(/^params/) || p.match(/^userIdChanged/))) {
513
- if (c2.plugins.includes(p), e4._ && e4._.originalAction === p)
514
- return e4;
515
- var t3 = v({}, e4, { _: { originalAction: e4.type, called: e4.type, from: "engineEnd" } });
516
- re(e4, n2.exact.length) && !p.match(/End$/) && (t3 = v({}, t3, { type: e4.type + "Aborted" })), u2.dispatch(t3);
94
+ s && (e = s);
95
+ } catch (s) {
517
96
  }
518
- return e4;
519
- });
520
97
  });
521
- } catch (e3) {
522
- return Promise.reject(e3);
523
- }
524
- }, G$1 = /Start$/, K = /^bootstrap/, Q = /^ready/;
525
- function Y(e2) {
526
- var n2 = e2.pluginName, t2 = e2.method + "Aborted" + (n2 ? ":" + n2 : "");
527
- e2.store.dispatch(v({}, e2.data, { type: t2, _: { called: t2, from: "abort" } }));
528
- }
529
- function Z(e2, n2, t2) {
530
- var r2 = n2[e2] || t2[e2];
531
- return r2 && r2.config ? r2.config : {};
532
- }
533
- function ee(e2, n2) {
534
- return n2.reduce(function(n3, t2) {
535
- return t2[e2] ? n3.concat({ methodName: e2, pluginName: t2.name, method: t2[e2] }) : n3;
536
- }, []);
537
- }
538
- function ne(e2, n2) {
539
- var t2 = e2.replace(G$1, ""), r2 = n2 ? ":" + n2 : "";
540
- return ["" + e2 + r2, "" + t2 + r2, t2 + "End" + r2];
541
- }
542
- function te(e2, n2) {
543
- var t2 = e2.abort;
544
- return !!t2 && (t2 === true || ae(t2, n2) || t2 && ae(t2.plugins, n2));
545
- }
546
- function re(e2, n2) {
547
- var t2 = e2.abort;
548
- if (!t2)
549
- return false;
550
- if (t2 === true || q$1(t2))
551
- return true;
552
- var r2 = t2.plugins;
553
- return ie(t2) && t2.length === n2 || ie(r2) && r2.length === n2;
554
- }
555
- function ie(e2) {
556
- return Array.isArray(e2);
557
- }
558
- function ae(e2, n2) {
559
- return !(!e2 || !ie(e2)) && e2.includes(n2);
560
- }
561
- function oe(e2) {
562
- var n2 = e2.match(/(.*):(.*)/);
563
- return !!n2 && { method: n2[1], name: n2[2] };
564
- }
565
- function ue(e2) {
566
- return Object.keys(e2).reduce(function(n2, t2) {
567
- return t2 === "type" || (n2[t2] = on(e2[t2]) ? Object.assign({}, e2[t2]) : e2[t2]), n2;
568
- }, {});
569
- }
570
- function ce(e2, n2, t2) {
571
- var r2 = {};
572
- return function(i2) {
573
- return function(a2) {
574
- return function(o2) {
98
+ for (const c of Object.values(t.plugins))
99
+ if (!u(c) && typeof c.track == "function")
575
100
  try {
576
- var u2, c2 = function(e3) {
577
- return u2 ? e3 : a2(f2);
578
- }, s2 = o2.type, l2 = o2.plugins, f2 = o2;
579
- if (o2.abort)
580
- return Promise.resolve(a2(o2));
581
- if (s2 === q.enablePlugin && i2.dispatch({ type: q.initializeStart, plugins: l2, disabled: [], fromEnable: true, meta: o2.meta }), s2 === q.disablePlugin && setTimeout(function() {
582
- return J$1(o2.meta.rid, { payload: o2 });
583
- }, 0), s2 === q.initializeEnd) {
584
- var m2 = n2(), g2 = Object.keys(m2), h2 = g2.filter(function(e3) {
585
- return l2.includes(e3);
586
- }).map(function(e3) {
587
- return m2[e3];
588
- }), y2 = [], b2 = [], I2 = o2.disabled, w2 = h2.map(function(e3) {
589
- var n3 = e3.name;
590
- return W(e3, e3.loaded, 1e4).then(function(t3) {
591
- return r2[n3] || (i2.dispatch({ type: q.pluginReadyType(n3), name: n3, events: Object.keys(e3).filter(function(e4) {
592
- return !M.includes(e4);
593
- }) }), r2[n3] = true), y2 = y2.concat(n3), e3;
594
- }).catch(function(e4) {
595
- if (e4 instanceof Error)
596
- throw new Error(e4);
597
- return b2 = b2.concat(e4.name), e4;
598
- });
599
- });
600
- Promise.all(w2).then(function(e3) {
601
- var n3 = { plugins: y2, failed: b2, disabled: I2 };
602
- setTimeout(function() {
603
- g2.length === w2.length + I2.length && i2.dispatch(v({}, { type: q.ready }, n3));
604
- }, 0);
605
- });
606
- }
607
- var E2 = function() {
608
- if (s2 !== q.bootstrap)
609
- return /^ready:([^:]*)$/.test(s2) && setTimeout(function() {
610
- return H(i2, n2, e2);
611
- }, 0), Promise.resolve(function(e3, n3, t3, r3, i3) {
612
- try {
613
- var a3 = W$1(n3) ? n3() : n3, o3 = e3.type, u3 = o3.replace(G$1, "");
614
- if (e3._ && e3._.called)
615
- return Promise.resolve(e3);
616
- var c3 = t3.getState(), s3 = (m3 = a3, (g3 = c3.plugins) === void 0 && (g3 = {}), (h3 = e3.options) === void 0 && (h3 = {}), Object.keys(m3).filter(function(e4) {
617
- var n4 = h3.plugins || {};
618
- return Q$1(n4[e4]) ? n4[e4] : n4.all !== false && (!g3[e4] || g3[e4].enabled !== false);
619
- }).map(function(e4) {
620
- return m3[e4];
621
- }));
622
- o3 === q.initializeStart && e3.fromEnable && (s3 = Object.keys(c3.plugins).filter(function(n4) {
623
- var t4 = c3.plugins[n4];
624
- return e3.plugins.includes(n4) && !t4.initialized;
625
- }).map(function(e4) {
626
- return a3[e4];
627
- }));
628
- var l3 = s3.map(function(e4) {
629
- return e4.name;
630
- }), f3 = function(e4, n4, t4) {
631
- var r4 = ne(e4).map(function(e5) {
632
- return ee(e5, n4);
633
- });
634
- return n4.reduce(function(t5, r5) {
635
- var i4 = r5.name, a4 = ne(e4, i4).map(function(e5) {
636
- return ee(e5, n4);
637
- }), o4 = a4[0], u4 = a4[1], c4 = a4[2];
638
- return o4.length && (t5.beforeNS[i4] = o4), u4.length && (t5.duringNS[i4] = u4), c4.length && (t5.afterNS[i4] = c4), t5;
639
- }, { before: r4[0], beforeNS: {}, during: r4[1], duringNS: {}, after: r4[2], afterNS: {} });
640
- }(o3, s3);
641
- return Promise.resolve(F$1({ action: e3, data: { exact: f3.before, namespaced: f3.beforeNS }, state: c3, allPlugins: a3, allMatches: f3, instance: t3, store: r3, EVENTS: i3 })).then(function(e4) {
642
- function n4() {
643
- var n5 = function() {
644
- if (o3.match(G$1))
645
- return Promise.resolve(F$1({ action: v({}, s4, { type: u3 + "End" }), data: { exact: f3.after, namespaced: f3.afterNS }, state: c3, allPlugins: a3, allMatches: f3, instance: t3, store: r3, EVENTS: i3 })).then(function(e5) {
646
- e5.meta && e5.meta.hasCallback && J$1(e5.meta.rid, { payload: e5 });
647
- });
648
- }();
649
- return n5 && n5.then ? n5.then(function() {
650
- return e4;
651
- }) : e4;
652
- }
653
- if (re(e4, l3.length))
654
- return e4;
655
- var s4, d2 = function() {
656
- if (o3 !== u3)
657
- return Promise.resolve(F$1({ action: v({}, e4, { type: u3 }), data: { exact: f3.during, namespaced: f3.duringNS }, state: c3, allPlugins: a3, allMatches: f3, instance: t3, store: r3, EVENTS: i3 })).then(function(e5) {
658
- s4 = e5;
659
- });
660
- s4 = e4;
661
- }();
662
- return d2 && d2.then ? d2.then(n4) : n4();
663
- });
664
- } catch (e4) {
665
- return Promise.reject(e4);
666
- }
667
- var m3, g3, h3;
668
- }(o2, n2, e2, i2, t2)).then(function(e3) {
669
- var n3 = a2(e3);
670
- return u2 = 1, n3;
671
- });
672
- }();
673
- return Promise.resolve(E2 && E2.then ? E2.then(c2) : c2(E2));
674
- } catch (e3) {
675
- return Promise.reject(e3);
676
- }
677
- };
678
- };
679
- };
680
- }
681
- function se(e2) {
682
- return function(n2) {
683
- return function(n3) {
684
- return function(t2) {
685
- var r2 = t2.type, i2 = t2.key, a2 = t2.value, o2 = t2.options;
686
- if (r2 === q.setItem || r2 === q.removeItem) {
687
- if (t2.abort)
688
- return n3(t2);
689
- r2 === q.setItem ? e2.setItem(i2, a2, o2) : e2.removeItem(i2, o2);
101
+ yield c.track({ payload: e, options: i, instance: t, config: c.config });
102
+ } catch (s) {
690
103
  }
691
- return n3(t2);
692
- };
693
- };
694
- };
695
- }
696
- var le = function() {
697
- var e2 = this;
698
- this.before = [], this.after = [], this.addMiddleware = function(n2, t2) {
699
- e2[t2] = e2[t2].concat(n2);
700
- }, this.removeMiddleware = function(n2, t2) {
701
- var r2 = e2[t2].findIndex(function(e3) {
702
- return e3 === n2;
703
- });
704
- r2 !== -1 && (e2[t2] = [].concat(e2[t2].slice(0, r2), e2[t2].slice(r2 + 1)));
705
- }, this.dynamicMiddlewares = function(n2) {
706
- return function(t2) {
707
- return function(r2) {
708
- return function(i2) {
709
- var a2 = { getState: t2.getState, dispatch: function(e3) {
710
- return t2.dispatch(e3);
711
- } }, o2 = e2[n2].map(function(e3) {
712
- return e3(a2);
713
- });
714
- return N$1.apply(void 0, o2)(r2)(i2);
715
- };
716
- };
717
- };
718
- };
719
- };
720
- function fe(e2) {
721
- return function(n2, t2) {
722
- n2 === void 0 && (n2 = {});
723
- var r2 = {};
724
- if (t2.type === "initialize:aborted")
725
- return n2;
726
- if (/^registerPlugin:([^:]*)$/.test(t2.type)) {
727
- var i2 = de(t2.type, "registerPlugin"), a2 = e2()[i2];
728
- if (!a2 || !i2)
729
- return n2;
730
- var o2 = t2.enabled;
731
- return r2[i2] = { enabled: o2, initialized: !!o2 && Boolean(!a2.initialize), loaded: !!o2 && Boolean(a2.loaded()), config: a2.config || {} }, v({}, n2, r2);
732
- }
733
- if (/^initialize:([^:]*)$/.test(t2.type)) {
734
- var u2 = de(t2.type, q.initialize), c2 = e2()[u2];
735
- return c2 && u2 ? (r2[u2] = v({}, n2[u2], { initialized: true, loaded: Boolean(c2.loaded()) }), v({}, n2, r2)) : n2;
736
- }
737
- if (/^ready:([^:]*)$/.test(t2.type))
738
- return r2[t2.name] = v({}, n2[t2.name], { loaded: true }), v({}, n2, r2);
739
- switch (t2.type) {
740
- case q.disablePlugin:
741
- return v({}, n2, pe(t2.plugins, false, n2));
742
- case q.enablePlugin:
743
- return v({}, n2, pe(t2.plugins, true, n2));
744
- default:
745
- return n2;
746
- }
747
- };
748
- }
749
- function de(e2, n2) {
750
- return e2.substring(n2.length + 1, e2.length);
751
- }
752
- function pe(e2, n2, t2) {
753
- return e2.reduce(function(e3, r2) {
754
- return e3[r2] = v({}, t2[r2], { enabled: n2 }), e3;
755
- }, t2);
756
- }
757
- function me(e2) {
758
- try {
759
- return JSON.parse(JSON.stringify(e2));
760
- } catch (e3) {
761
- }
762
- return e2;
763
- }
764
- var ge = { last: {}, history: [] };
765
- function he(e2, n2) {
766
- e2 === void 0 && (e2 = ge);
767
- var t2 = n2.options, r2 = n2.meta;
768
- if (n2.type === q.track) {
769
- var i2 = me(v({ event: n2.event, properties: n2.properties }, Object.keys(t2).length && { options: t2 }, { meta: r2 }));
770
- return v({}, e2, { last: i2, history: e2.history.concat(i2) });
771
- }
772
- return e2;
773
- }
774
- var ve = { actions: [] };
775
- function ye(e2, n2) {
776
- e2 === void 0 && (e2 = ve);
777
- var t2 = n2.payload;
778
- switch (n2.type) {
779
- case "queue":
780
- var r2;
781
- return r2 = t2 && t2.type && t2.type === q.identify ? [n2].concat(e2.actions) : e2.actions.concat(n2), v({}, e2, { actions: r2 });
782
- case "dequeue":
783
- return [];
784
- default:
785
- return e2;
786
- }
787
- }
788
- var be = /#.*$/;
789
- function Ie(e2) {
790
- var n2 = /(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e2);
791
- return "/" + (n2 && n2[3] ? n2[3].split("?")[0].replace(be, "") : "");
792
- }
793
- var we, Ee, Pe, Se, Ne = function(e2) {
794
- if (e2 === void 0 && (e2 = {}), !$$1)
795
- return e2;
796
- var n2 = document, t2 = n2.title, r2 = n2.referrer, i2 = window, a2 = i2.location, o2 = i2.innerWidth, u2 = i2.innerHeight, c2 = a2.hash, s2 = a2.search, l2 = function(e3) {
797
- var n3 = function() {
798
- if ($$1) {
799
- for (var e4, n4 = document.getElementsByTagName("link"), t3 = 0; e4 = n4[t3]; t3++)
800
- if (e4.getAttribute("rel") === "canonical")
801
- return e4.getAttribute("href");
802
- }
803
- }();
804
- return n3 ? n3.match(/\?/) ? n3 : n3 + e3 : window.location.href.replace(be, "");
805
- }(s2), f2 = { title: t2, url: l2, path: Ie(l2), hash: c2, search: s2, width: o2, height: u2 };
806
- return r2 && r2 !== "" && (f2.referrer = r2), v({}, f2, e2);
807
- }, Oe = { last: {}, history: [] };
808
- function Ae(e2, n2) {
809
- e2 === void 0 && (e2 = Oe);
810
- var t2 = n2.options;
811
- if (n2.type === q.page) {
812
- var r2 = me(v({ properties: n2.properties, meta: n2.meta }, Object.keys(t2).length && { options: t2 }));
813
- return v({}, e2, { last: r2, history: e2.history.concat(r2) });
814
- }
815
- return e2;
816
- }
817
- we = function() {
818
- if (!$$1)
819
- return false;
820
- var e2 = navigator.appVersion;
821
- return ~e2.indexOf("Win") ? "Windows" : ~e2.indexOf("Mac") ? "MacOS" : ~e2.indexOf("X11") ? "UNIX" : ~e2.indexOf("Linux") ? "Linux" : "Unknown OS";
822
- }(), Ee = $$1 ? document.referrer : null, Pe = o$1(), Se = a$3();
823
- var _e = { initialized: false, sessionId: y$1(), app: null, version: null, debug: false, offline: !!$$1 && !navigator.onLine, os: { name: we }, userAgent: $$1 ? navigator.userAgent : "node", library: { name: "analytics", version: "0.11.0" }, timezone: Se, locale: Pe, campaign: {}, referrer: Ee };
824
- function xe(e2, n2) {
825
- e2 === void 0 && (e2 = _e);
826
- var t2 = e2.initialized, r2 = n2.campaign;
827
- switch (n2.type) {
828
- case q.campaign:
829
- return v({}, e2, { campaign: r2 });
830
- case q.offline:
831
- return v({}, e2, { offline: true });
832
- case q.online:
833
- return v({}, e2, { offline: false });
834
- default:
835
- return t2 ? e2 : v({}, _e, e2, { initialized: true });
836
- }
837
- }
838
- var ke = ["plugins", "reducers", "storage"];
839
- function je(e2, n2, t2) {
840
- if ($$1) {
841
- var r2 = window[(t2 ? "add" : "remove") + "EventListener"];
842
- e2.split(" ").forEach(function(e3) {
843
- r2(e3, n2);
844
- });
845
- }
846
- }
847
- function Te(e2) {
848
- var n2 = je.bind(null, "online offline", function(n3) {
849
- return Promise.resolve(!navigator.onLine).then(e2);
104
+ return e;
850
105
  });
851
- return n2(true), function(e3) {
852
- return n2(false);
853
- };
854
- }
855
- function ze() {
856
- return f("analytics", []), function(e2) {
857
- return function(n$12, t2, r2) {
858
- var i2 = e2(n$12, t2, r2), a2 = i2.dispatch;
859
- return Object.assign(i2, { dispatch: function(e3) {
860
- return n[o].analytics.push(e3.action || e3), a2(e3);
861
- } });
862
- };
863
- };
864
- }
865
- function Me(e2) {
866
- return function() {
867
- return N$1(N$1.apply(null, arguments), ze());
868
- };
869
- }
870
- function qe(e2) {
871
- return e2 ? rn(e2) ? e2 : [e2] : [];
872
- }
873
- function Ue(n2, t2, r2) {
874
- n2 === void 0 && (n2 = {});
875
- var i2, a2, o2 = y$1();
876
- return t2 && (X[o2] = (i2 = t2, a2 = function(e2) {
877
- for (var n3, t3 = e2 || Array.prototype.slice.call(arguments), r3 = 0; r3 < t3.length; r3++)
878
- if (W$1(t3[r3])) {
879
- n3 = t3[r3];
880
- break;
881
- }
882
- return n3;
883
- }(r2), function(e2) {
884
- a2 && a2(e2), i2(e2);
885
- })), v({}, n2, { rid: o2, ts: new Date().getTime() }, t2 ? { hasCallback: true } : {});
886
106
  }
887
- function Ve(n2) {
888
- n2 === void 0 && (n2 = {});
889
- var t2 = n2.reducers || {}, c2 = n2.initialUser || {}, s$1 = (n2.plugins || []).reduce(function(e2, n3) {
890
- if (W$1(n3))
891
- return e2.middlewares = e2.middlewares.concat(n3), e2;
892
- if (n3.NAMESPACE && (n3.name = n3.NAMESPACE), !n3.name)
893
- throw new Error("https://lytics.dev/errors/1");
894
- var t3 = n3.EVENTS ? Object.keys(n3.EVENTS).map(function(e3) {
895
- return n3.EVENTS[e3];
896
- }) : [];
897
- e2.pluginEnabled[n3.name] = !(n3.enabled === false || n3.config && n3.config.enabled === false), delete n3.enabled, n3.methods && (e2.methods[n3.name] = Object.keys(n3.methods).reduce(function(e3, t4) {
898
- var r3;
899
- return e3[t4] = (r3 = n3.methods[t4], function() {
900
- for (var e4 = Array.prototype.slice.call(arguments), n4 = new Array(r3.length), t5 = 0; t5 < e4.length; t5++)
901
- n4[t5] = e4[t5];
902
- return n4[n4.length] = K2, r3.apply({ instance: K2 }, n4);
903
- }), e3;
904
- }, {}), delete n3.methods);
905
- var r2 = Object.keys(n3).concat(t3), i2 = new Set(e2.events.concat(r2));
906
- if (e2.events = Array.from(i2), e2.pluginsArray = e2.pluginsArray.concat(n3), e2.plugins[n3.name])
907
- throw new Error(n3.name + "AlreadyLoaded");
908
- return e2.plugins[n3.name] = n3, e2.plugins[n3.name].loaded || (e2.plugins[n3.name].loaded = function() {
909
- return true;
910
- }), e2;
911
- }, { plugins: {}, pluginEnabled: {}, methods: {}, pluginsArray: [], middlewares: [], events: [] }), f$1 = n2.storage ? n2.storage : { getItem: a$2, setItem: f, removeItem: i$2 }, p = function(e2) {
912
- return function(n3, t3, r2) {
913
- return t3.getState("user")[n3] || (r2 && on(r2) && r2[n3] ? r2[n3] : $(e2)[n3] || a$2(D(n3)) || null);
914
- };
915
- }(f$1), h2 = s$1.plugins, w2 = s$1.events.filter(function(e2) {
916
- return !M.includes(e2);
917
- }).sort(), E2 = new Set(w2.concat(z).filter(function(e2) {
918
- return !M.includes(e2);
919
- })), _2 = Array.from(E2).sort(), x2 = function() {
920
- return h2;
921
- }, k2 = new le(), U2 = k2.addMiddleware, V2 = k2.removeMiddleware, L2 = k2.dynamicMiddlewares, X2 = function() {
922
- throw new Error("Abort disabled inListener");
923
- }, J2 = s(), W2 = $(f$1), F2 = v({}, W2, c2, J2.an_uid ? { userId: J2.an_uid } : {}, J2.an_aid ? { anonymousId: J2.an_aid } : {});
924
- F2.anonymousId || (F2.anonymousId = y$1());
925
- var G2 = v({ enable: function(e2, n3) {
926
- return new Promise(function(t3) {
927
- oe2.dispatch({ type: q.enablePlugin, plugins: qe(e2), _: { originalAction: q.enablePlugin } }, t3, [n3]);
928
- });
929
- }, disable: function(e2, n3) {
930
- return new Promise(function(t3) {
931
- oe2.dispatch({ type: q.disablePlugin, plugins: qe(e2), _: { originalAction: q.disablePlugin } }, t3, [n3]);
932
- });
933
- } }, s$1.methods), K2 = { identify: function(e2, n3, t3, r2) {
934
- try {
935
- var i2 = q$1(e2) ? e2 : null, a2 = on(e2) ? e2 : n3, o2 = t3 || {}, c3 = K2.user();
936
- f(D(j), i2);
937
- var s2 = i2 || a2.userId || p(j, K2, a2);
938
- return Promise.resolve(new Promise(function(e3) {
939
- oe2.dispatch(v({ type: q.identifyStart, userId: s2, traits: a2 || {}, options: o2, anonymousId: c3.anonymousId }, c3.id && c3.id !== i2 && { previousId: c3.id }), e3, [n3, t3, r2]);
940
- }));
941
- } catch (e3) {
942
- return Promise.reject(e3);
943
- }
944
- }, track: function(e2, n3, t3, r2) {
945
- try {
946
- var i2 = on(e2) ? e2.event : e2;
947
- if (!i2 || !q$1(i2))
948
- throw new Error("EventMissing");
949
- var a2 = on(e2) ? e2 : n3 || {}, o2 = on(t3) ? t3 : {};
950
- return Promise.resolve(new Promise(function(e3) {
951
- oe2.dispatch({ type: q.trackStart, event: i2, properties: a2, options: o2, userId: p(j, K2, n3), anonymousId: p(T, K2, n3) }, e3, [n3, t3, r2]);
952
- }));
953
- } catch (e3) {
954
- return Promise.reject(e3);
955
- }
956
- }, page: function(e2, n3, t3) {
957
- try {
958
- var r2 = on(e2) ? e2 : {}, i2 = on(n3) ? n3 : {};
959
- return Promise.resolve(new Promise(function(a2) {
960
- oe2.dispatch({ type: q.pageStart, properties: Ne(r2), options: i2, userId: p(j, K2, r2), anonymousId: p(T, K2, r2) }, a2, [e2, n3, t3]);
961
- }));
962
- } catch (e3) {
963
- return Promise.reject(e3);
964
- }
965
- }, user: function(e2) {
966
- if (e2 === j || e2 === "id")
967
- return p(j, K2);
968
- if (e2 === T || e2 === "anonId")
969
- return p(T, K2);
970
- var n3 = K2.getState("user");
971
- return e2 ? i$3(n3, e2) : n3;
972
- }, reset: function(e2) {
973
- return new Promise(function(n3) {
974
- oe2.dispatch({ type: q.resetStart }, n3, e2);
975
- });
976
- }, ready: function(e2) {
977
- return K2.on(q.ready, e2);
978
- }, on: function(e2, n3) {
979
- if (!e2 || !W$1(n3))
980
- return false;
981
- if (e2 === q.bootstrap)
982
- throw new Error(".on disabled for " + e2);
983
- var t3 = /Start$|Start:/;
984
- if (e2 === "*") {
985
- var r2 = function(e3) {
986
- return function(e4) {
987
- return function(r3) {
988
- return r3.type.match(t3) && n3({ payload: r3, instance: K2, plugins: h2 }), e4(r3);
989
- };
990
- };
991
- }, i2 = function(e3) {
992
- return function(e4) {
993
- return function(r3) {
994
- return r3.type.match(t3) || n3({ payload: r3, instance: K2, plugins: h2 }), e4(r3);
995
- };
996
- };
997
- };
998
- return U2(r2, Le), U2(i2, Ce), function() {
999
- V2(r2, Le), V2(i2, Ce);
1000
- };
1001
- }
1002
- var a2 = e2.match(t3) ? Le : Ce, o2 = function(t4) {
1003
- return function(t5) {
1004
- return function(r3) {
1005
- return r3.type === e2 && n3({ payload: r3, instance: K2, plugins: h2, abort: X2 }), t5(r3);
1006
- };
1007
- };
1008
- };
1009
- return U2(o2, a2), function() {
1010
- return V2(o2, a2);
1011
- };
1012
- }, once: function(e2, n3) {
1013
- if (!e2 || !W$1(n3))
1014
- return false;
1015
- if (e2 === q.bootstrap)
1016
- throw new Error(".once disabled for " + e2);
1017
- var t3 = K2.on(e2, function(e3) {
1018
- n3({ payload: e3.payload, instance: K2, plugins: h2, abort: X2 }), t3();
1019
- });
1020
- return t3;
1021
- }, getState: function(e2) {
1022
- var n3 = oe2.getState();
1023
- return e2 ? i$3(n3, e2) : Object.assign({}, n3);
1024
- }, dispatch: function(e2) {
1025
- var n3 = q$1(e2) ? { type: e2 } : e2;
1026
- if (z.includes(n3.type))
1027
- throw new Error("reserved action " + n3.type);
1028
- var t3 = v({}, n3, { _: v({ originalAction: n3.type }, e2._ || {}) });
1029
- oe2.dispatch(t3);
1030
- }, enablePlugin: G2.enable, disablePlugin: G2.disable, plugins: G2, storage: { getItem: f$1.getItem, setItem: function(e2, n3, t3) {
1031
- oe2.dispatch({ type: q.setItemStart, key: e2, value: n3, options: t3 });
1032
- }, removeItem: function(e2, n3) {
1033
- oe2.dispatch({ type: q.removeItemStart, key: e2, options: n3 });
1034
- } }, setAnonymousId: function(e2, n3) {
1035
- K2.storage.setItem(A$1, e2, n3);
1036
- }, events: { core: z, plugins: w2 } }, Q2 = s$1.middlewares.concat([function(e2) {
1037
- return function(e3) {
1038
- return function(n3) {
1039
- return n3.meta || (n3.meta = Ue()), e3(n3);
1040
- };
1041
- };
1042
- }, L2(Le), ce(K2, x2, { all: _2, plugins: w2 }), se(f$1), C$1(K2), B(K2), L2(Ce)]), Y2 = { context: xe, user: R(f$1), page: Ae, track: he, plugins: fe(x2), queue: ye }, Z2 = N$1, ee2 = N$1;
1043
- if ($$1 && n2.debug) {
1044
- var ne2 = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
1045
- ne2 && (Z2 = ne2({ trace: true, traceLimit: 25 })), ee2 = function() {
1046
- return arguments.length === 0 ? ze() : on(typeof arguments[0]) ? Me() : Me().apply(null, arguments);
1047
- };
1048
- }
1049
- var te2, re2 = function(e2) {
1050
- return Object.keys(e2).reduce(function(n3, t3) {
1051
- return ke.includes(t3) || (n3[t3] = e2[t3]), n3;
1052
- }, {});
1053
- }(n2), ie2 = s$1.pluginsArray.reduce(function(e2, n3) {
1054
- var t3 = n3.name, r2 = n3.config, i2 = n3.loaded, a2 = s$1.pluginEnabled[t3];
1055
- return e2[t3] = { enabled: a2, initialized: !!a2 && Boolean(!n3.initialize), loaded: Boolean(i2()), config: r2 || {} }, e2;
1056
- }, {}), ae2 = { context: re2, user: F2, plugins: ie2 }, oe2 = P(function(e2) {
1057
- for (var n3 = Object.keys(e2), t3 = {}, r2 = 0; r2 < n3.length; r2++) {
1058
- var i2 = n3[r2];
1059
- typeof e2[i2] === y && (t3[i2] = e2[i2]);
1060
- }
1061
- var a2, o2 = Object.keys(t3);
1062
- try {
1063
- !function(e3) {
1064
- Object.keys(e3).forEach(function(n4) {
1065
- var t4 = e3[n4];
1066
- if (typeof t4(void 0, { type: "@@redux/INIT" }) === b$1 || typeof t4(void 0, { type: I$1 }) === b$1)
1067
- throw new Error("reducer " + n4 + " " + b$1);
1068
- });
1069
- }(t3);
1070
- } catch (e3) {
1071
- a2 = e3;
1072
- }
1073
- return function(e3, n4) {
1074
- if (e3 === void 0 && (e3 = {}), a2)
1075
- throw a2;
1076
- for (var r3 = false, i3 = {}, u2 = 0; u2 < o2.length; u2++) {
1077
- var c3 = o2[u2], s2 = e3[c3], l2 = (0, t3[c3])(s2, n4);
1078
- if (typeof l2 === b$1) {
1079
- var f2 = S(c3, n4);
1080
- throw new Error(f2);
107
+ function K(t, ...e) {
108
+ return f(this, null, function* () {
109
+ for (const n of Object.values(t.plugins))
110
+ if (typeof n.reset == "function")
111
+ try {
112
+ yield n.reset(...e);
113
+ } catch (r) {
1081
114
  }
1082
- i3[c3] = l2, r3 = r3 || l2 !== s2;
1083
- }
1084
- return r3 ? i3 : e3;
1085
- };
1086
- }(v({}, Y2, t2)), ae2, ee2(Z2(O$1.apply(void 0, Q2))));
1087
- oe2.dispatch = (te2 = oe2.dispatch, function(e2, n3, t3) {
1088
- var r2 = v({}, e2, { meta: Ue(e2.meta, n3, qe(t3)) });
1089
- return te2.apply(null, [r2]);
1090
- });
1091
- var ue2 = Object.keys(h2);
1092
- oe2.dispatch({ type: q.bootstrap, plugins: ue2, config: re2, params: J2, user: F2, initialUser: c2, persistedUser: W2 });
1093
- var de2 = ue2.filter(function(e2) {
1094
- return s$1.pluginEnabled[e2];
1095
- }), pe2 = ue2.filter(function(e2) {
1096
- return !s$1.pluginEnabled[e2];
1097
115
  });
1098
- return oe2.dispatch({ type: q.registerPlugins, plugins: ue2, enabled: s$1.pluginEnabled }), s$1.pluginsArray.map(function(e2, n3) {
1099
- var t3 = e2.bootstrap, r2 = e2.config, i2 = e2.name;
1100
- t3 && W$1(t3) && t3({ instance: K2, config: r2, payload: e2 }), oe2.dispatch({ type: q.registerPluginType(i2), name: i2, enabled: s$1.pluginEnabled[i2], plugin: e2 }), s$1.pluginsArray.length === n3 + 1 && oe2.dispatch({ type: q.initializeStart, plugins: de2, disabled: pe2 });
1101
- }), Te(function(e2) {
1102
- oe2.dispatch({ type: e2 ? q.offline : q.online });
1103
- }), function(e2, n3, t3) {
1104
- setInterval(function() {
1105
- return H(e2, n3, t3);
1106
- }, 3e3);
1107
- }(oe2, x2, K2), K2;
1108
- }
1109
- var Le = "before", Ce = "after";
1110
- var t = "cookie", i$1 = a$1(), r$1 = d$1, c = d$1;
1111
- function u(o2) {
1112
- return i$1 ? d$1(o2, "", -1) : i$2(o2);
1113
- }
1114
- function a$1() {
1115
- if (i$1 !== void 0)
1116
- return i$1;
1117
- var e2 = "cookiecookie";
1118
- try {
1119
- d$1(e2, e2), i$1 = document.cookie.indexOf(e2) !== -1, u(e2);
1120
- } catch (e3) {
1121
- i$1 = false;
1122
- }
1123
- return i$1;
1124
- }
1125
- function d$1(e2, t2, r2, c2, u2, a2) {
1126
- if (typeof window != "undefined") {
1127
- var d2 = arguments.length > 1;
1128
- return i$1 === false && (d2 ? f(e2, t2) : a$2(e2)), d2 ? document.cookie = e2 + "=" + encodeURIComponent(t2) + (r2 ? "; expires=" + new Date(+new Date() + 1e3 * r2).toUTCString() + (c2 ? "; path=" + c2 : "") + (u2 ? "; domain=" + u2 : "") + (a2 ? "; secure" : "") : "") : decodeURIComponent((("; " + document.cookie).split("; " + e2 + "=")[1] || "").split(";")[0]);
1129
- }
1130
- }
1131
- var r = "localStorage", g = b$2.bind(null, "localStorage");
1132
- u$1("localStorage", "getItem", a$2);
1133
- u$1("localStorage", "setItem", f);
1134
- u$1("localStorage", "removeItem", i$2);
1135
- var a = "sessionStorage", i = b$2.bind(null, "sessionStorage");
1136
- u$1("sessionStorage", "getItem", a$2);
1137
- u$1("sessionStorage", "setItem", f);
1138
- u$1("sessionStorage", "removeItem", i$2);
1139
- function I(t2) {
1140
- var o2 = t2;
1141
- try {
1142
- if ((o2 = JSON.parse(t2)) === "true")
1143
- return true;
1144
- if (o2 === "false")
1145
- return false;
1146
- if (on(o2))
1147
- return o2;
1148
- parseFloat(o2) === o2 && (o2 = parseFloat(o2));
1149
- } catch (t3) {
1150
- }
1151
- if (o2 !== null && o2 !== "")
1152
- return o2;
1153
- }
1154
- var k = g(), O = i(), x = a$1();
1155
- function C(o2, e2) {
1156
- if (o2) {
1157
- var r2 = A(e2), a2 = !N(r2), i2 = d(r2) ? I(localStorage.getItem(o2)) : void 0;
1158
- if (a2 && !I$2(i2))
1159
- return i2;
1160
- var n2 = h(r2) ? I(r$1(o2)) : void 0;
1161
- if (a2 && n2)
1162
- return n2;
1163
- var l2 = E(r2) ? I(sessionStorage.getItem(o2)) : void 0;
1164
- if (a2 && l2)
1165
- return l2;
1166
- var u2 = a$2(o2);
1167
- return a2 ? u2 : { localStorage: i2, sessionStorage: l2, cookie: n2, global: u2 };
1168
- }
1169
- }
1170
- function L(r$2, a$12, l$1) {
1171
- if (r$2 && !I$2(a$12)) {
1172
- var u2 = {}, g2 = A(l$1), m2 = JSON.stringify(a$12), S2 = !N(g2);
1173
- return d(g2) && (u2[r] = F(r, a$12, I(localStorage.getItem(r$2))), localStorage.setItem(r$2, m2), S2) ? u2[r] : h(g2) && (u2[t] = F(t, a$12, I(r$1(r$2))), c(r$2, m2), S2) ? u2[t] : E(g2) && (u2[a] = F(a, a$12, I(sessionStorage.getItem(r$2))), sessionStorage.setItem(r$2, m2), S2) ? u2[a] : (u2[l] = F(l, a$12, a$2(r$2)), f(r$2, a$12), S2 ? u2[l] : u2);
1174
- }
1175
- }
1176
- function b(t$1, e2) {
1177
- if (t$1) {
1178
- var a$12 = A(e2), s2 = C(t$1, m$1), n2 = {};
1179
- return !I$2(s2.localStorage) && d(a$12) && (localStorage.removeItem(t$1), n2[r] = s2.localStorage), !I$2(s2.cookie) && h(a$12) && (u(t$1), n2[t] = s2.cookie), !I$2(s2.sessionStorage) && E(a$12) && (sessionStorage.removeItem(t$1), n2[a] = s2.sessionStorage), !I$2(s2.global) && G(a$12, l) && (i$2(t$1), n2[l] = s2.global), n2;
1180
- }
1181
- }
1182
- function A(t2) {
1183
- return t2 ? q$1(t2) ? t2 : t2.storage : g$1;
1184
- }
1185
- function d(t2) {
1186
- return k && G(t2, r);
1187
- }
1188
- function h(t$1) {
1189
- return x && G(t$1, t);
1190
- }
1191
- function E(t2) {
1192
- return O && G(t2, a);
1193
- }
1194
- function N(t2) {
1195
- return t2 === m$1 || t2 === "all";
1196
116
  }
1197
- function G(t2, o2) {
1198
- return t2 === g$1 || t2 === o2 || N(t2);
117
+ function Y(t, e, n, r, a, i, o) {
118
+ t.fbq || (a = t.fbq = function() {
119
+ a.callMethod ? a.callMethod.apply(a, arguments) : a.queue.push(arguments);
120
+ }, t._fbq || (t._fbq = a), a.push = a, a.loaded = !0, a.version = "2.0", a.queue = [], i = e.createElement(n), i.async = !0, i.src = r, o = e.getElementsByTagName(n)[0], o.parentNode.insertBefore(i, o));
1199
121
  }
1200
- function F(t2, o2, e2) {
1201
- return { location: t2, current: o2, previous: e2 };
122
+ function Z({ trackingId: t }) {
123
+ Y(
124
+ window,
125
+ document,
126
+ "script",
127
+ "https://connect.facebook.net/en_US/fbevents.js"
128
+ ), window.fbq("init", t);
1202
129
  }
1203
- var J = { setItem: L, getItem: C, removeItem: b };
1204
- function _defineProperty(obj, key, value) {
1205
- if (key in obj) {
1206
- Object.defineProperty(obj, key, {
1207
- value,
1208
- enumerable: true,
1209
- configurable: true,
1210
- writable: true
1211
- });
1212
- } else {
1213
- obj[key] = value;
1214
- }
1215
- return obj;
1216
- }
1217
- function ownKeys(object, enumerableOnly) {
1218
- var keys = Object.keys(object);
1219
- if (Object.getOwnPropertySymbols) {
1220
- var symbols = Object.getOwnPropertySymbols(object);
1221
- enumerableOnly && (symbols = symbols.filter(function(sym) {
1222
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1223
- })), keys.push.apply(keys, symbols);
1224
- }
1225
- return keys;
1226
- }
1227
- function _objectSpread2(target) {
1228
- for (var i2 = 1; i2 < arguments.length; i2++) {
1229
- var source = arguments[i2] != null ? arguments[i2] : {};
1230
- i2 % 2 ? ownKeys(Object(source), true).forEach(function(key) {
1231
- _defineProperty(target, key, source[key]);
1232
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
1233
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1234
- });
1235
- }
1236
- return target;
1237
- }
1238
- function analyticsLib() {
1239
- var opts = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1240
- var defaultSettings = {
1241
- storage: J
1242
- };
1243
- return Ve(_objectSpread2(_objectSpread2({}, defaultSettings), opts));
1244
- }
1245
- function facebookScriptInit(f2, b2, e2, v2, n2, t2, s2) {
1246
- if (f2.fbq)
1247
- return;
1248
- n2 = f2.fbq = function() {
1249
- n2.callMethod ? n2.callMethod.apply(n2, arguments) : n2.queue.push(arguments);
1250
- };
1251
- if (!f2._fbq)
1252
- f2._fbq = n2;
1253
- n2.push = n2;
1254
- n2.loaded = true;
1255
- n2.version = "2.0";
1256
- n2.queue = [];
1257
- t2 = b2.createElement(e2);
1258
- t2.async = true;
1259
- t2.src = v2;
1260
- s2 = b2.getElementsByTagName(e2)[0];
1261
- s2.parentNode.insertBefore(t2, s2);
1262
- }
1263
- function facebookInit({ trackingId }) {
1264
- facebookScriptInit(window, document, "script", "https://connect.facebook.net/en_US/fbevents.js");
1265
- window.fbq("init", trackingId);
1266
- }
1267
- function facebook(pluginConfig = {}) {
130
+ function tt(t = {}) {
1268
131
  return {
1269
132
  name: "facebook",
1270
- config: pluginConfig,
1271
- initialize: function({ config, instance }) {
1272
- if (!config.trackingId)
133
+ config: t,
134
+ initialize: function({ config: e, instance: n }) {
135
+ if (!e.trackingId)
1273
136
  throw new Error("No Facebook trackingId defined");
1274
- facebookInit({ trackingId: config.trackingId });
137
+ Z({ trackingId: e.trackingId });
1275
138
  },
1276
- page: function({ payload, config, instance }) {
139
+ page: function({ payload: e, config: n, instance: r }) {
1277
140
  window.fbq("track", "PageView");
1278
141
  },
1279
- track: function({ payload, config, instance }) {
1280
- window.fbq("trackCustom", payload.event, payload.properties);
142
+ track: function({ payload: e, config: n, instance: r }) {
143
+ window.fbq("trackCustom", e.event, e.properties);
1281
144
  },
1282
- identify: function({ payload, config }) {
145
+ identify: function({ payload: e, config: n }) {
1283
146
  },
1284
147
  loaded: function() {
1285
148
  return !!window.fbq;
1286
149
  }
1287
150
  };
1288
151
  }
1289
- function gtag() {
152
+ function h() {
1290
153
  window.dataLayer.push(arguments);
1291
154
  }
1292
- window.gtag = gtag;
1293
- function gtagInit({ trackingId, configParams = {}, setParams = {} }) {
1294
- var scriptId = "ga-gtag";
1295
- if (document.getElementById(scriptId))
1296
- return;
1297
- var head = document.head;
1298
- var script = document.createElement("script");
1299
- script.id = scriptId;
1300
- script.type = "text/javascript";
1301
- script.async = true;
1302
- script.src = "https://www.googletagmanager.com/gtag/js?id=" + trackingId;
1303
- head.insertBefore(script, head.firstChild);
1304
- window.dataLayer = window.dataLayer || [];
1305
- gtag("js", new Date());
1306
- if (setParams) {
1307
- gtag("set", setParams);
155
+ window.gtag = h;
156
+ function et({ trackingId: t, configParams: e = {}, setParams: n = {} }) {
157
+ var r = "ga-gtag";
158
+ if (!document.getElementById(r)) {
159
+ var a = document.head, i = document.createElement("script");
160
+ i.id = r, i.type = "text/javascript", i.async = !0, i.src = "https://www.googletagmanager.com/gtag/js?id=" + t, a.insertBefore(i, a.firstChild), window.dataLayer = window.dataLayer || [], h("js", /* @__PURE__ */ new Date()), n && h("set", n), h("config", t, e);
1308
161
  }
1309
- gtag("config", trackingId, configParams);
1310
162
  }
1311
- function googleAnalytics4(pluginConfig = {}) {
163
+ function rt(t = {}) {
1312
164
  return {
1313
165
  name: "google-analytics-4",
1314
- config: pluginConfig,
1315
- initialize: function({ config, instance }) {
1316
- if (!config.trackingId)
166
+ config: t,
167
+ initialize: function({ config: e, instance: n }) {
168
+ if (!e.trackingId)
1317
169
  throw new Error("No GA trackingId defined");
1318
- var configParams = {};
1319
- var setParams = {};
1320
- if (config.customDimensions) {
1321
- var customMap = {};
1322
- for (var i2 = 0; i2 < config.customDimensions.length; i2++) {
1323
- var customDim = config.customDimensions[i2];
1324
- configParams[customDim.name] = customDim.callback(instance, config);
1325
- customMap["dimension" + (i2 + 1)] = customDim.name;
170
+ var r = {}, a = {};
171
+ if (e.customDimensions) {
172
+ for (var i = {}, o = 0; o < e.customDimensions.length; o++) {
173
+ var u = e.customDimensions[o];
174
+ r[u.name] = u.callback(n, e), i["dimension" + (o + 1)] = u.name;
1326
175
  }
1327
- setParams["custom_map"] = customMap;
176
+ a.custom_map = i;
1328
177
  }
1329
- gtagInit({ trackingId: config.trackingId, configParams, setParams });
178
+ et({ trackingId: e.trackingId, configParams: r, setParams: a });
1330
179
  },
1331
- page: function({ payload, config, instance }) {
180
+ page: function({ payload: e, config: n, instance: r }) {
1332
181
  },
1333
- track: function({ payload, config, instance }) {
1334
- gtag("event", payload.event, payload.properties);
182
+ track: function({ payload: e, config: n, instance: r }) {
183
+ h("event", e.event, e.properties);
1335
184
  },
1336
- identify: function({ payload, config }) {
185
+ identify: function({ payload: e, config: n }) {
1337
186
  },
1338
187
  loaded: function() {
1339
188
  return !!window.gtag;
1340
189
  }
1341
190
  };
1342
191
  }
1343
- var urlParams = new URLSearchParams(window.location.search);
1344
- var DEBUG = urlParams.get("zdbg");
1345
- var zarGlobal = {};
1346
- const undef = "undefined";
1347
- function dbg() {
1348
- if (DEBUG != 1)
1349
- return;
1350
- console.debug(...arguments);
192
+ var nt = new URLSearchParams(window.location.search), at = nt.get("zdbg"), E = {};
193
+ const P = "undefined";
194
+ function w() {
195
+ at == 1 && console.debug(...arguments);
1351
196
  }
1352
- function warn(msg) {
1353
- console.warn(msg);
1354
- if (window.Rollbar) {
1355
- window.Rollbar.warning(msg);
1356
- }
197
+ function l(t) {
198
+ console.warn(t), window.Rollbar && window.Rollbar.warning(t);
1357
199
  }
1358
- function isFunc(value) {
1359
- return value && (Object.prototype.toString.call(value) === "[object Function]" || typeof value === "function" || value instanceof Function);
200
+ function it(t) {
201
+ return t && (Object.prototype.toString.call(t) === "[object Function]" || typeof t == "function" || t instanceof Function);
1360
202
  }
1361
- function isBot() {
203
+ function L() {
1362
204
  try {
1363
- var ua = navigator.userAgent || "";
1364
- var bots = new RegExp([
1365
- /bot/,
1366
- /spider/,
1367
- /crawl/,
1368
- /mediapartners/,
1369
- /Google-Read-Aloud/,
1370
- /semrush/
1371
- ].map((r2) => r2.source).join("|"), "i");
1372
- return bots.test(ua);
1373
- } catch (e2) {
1374
- return false;
1375
- }
1376
- }
1377
- function afterDOMContentLoaded(func) {
1378
- if (document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive") {
1379
- func();
1380
- } else {
1381
- window.addEventListener("DOMContentLoaded", func);
1382
- }
1383
- }
1384
- var supportsSessionStorage = hasSessionStorage();
1385
- function hasSessionStorage() {
1386
- if (typeof supportsSessionStorage !== undef) {
1387
- return supportsSessionStorage;
1388
- }
1389
- supportsSessionStorage = true;
205
+ var t = navigator.userAgent || "", e = new RegExp(
206
+ [
207
+ /bot/,
208
+ /spider/,
209
+ /crawl/,
210
+ /mediapartners/,
211
+ /Google-Read-Aloud/,
212
+ /semrush/
213
+ ].map((n) => n.source).join("|"),
214
+ "i"
215
+ );
216
+ return e.test(t);
217
+ } catch (n) {
218
+ return !1;
219
+ }
220
+ }
221
+ function ot(t) {
222
+ document.readyState === "complete" || document.readyState === "loaded" || document.readyState === "interactive" ? t() : window.addEventListener("DOMContentLoaded", t);
223
+ }
224
+ var g = ut();
225
+ function ut() {
226
+ if (typeof g !== P)
227
+ return g;
228
+ g = !0;
1390
229
  try {
1391
- sessionStorage.setItem(undef, undef);
1392
- sessionStorage.removeItem(undef);
1393
- } catch (e2) {
1394
- supportsSessionStorage = false;
230
+ sessionStorage.setItem(P, P), sessionStorage.removeItem(P);
231
+ } catch (t) {
232
+ g = !1;
1395
233
  }
1396
- return supportsSessionStorage;
234
+ return g;
1397
235
  }
1398
- function getSessionStorage(key) {
1399
- var value;
1400
- var globalValue = zarGlobal[key];
1401
- if (supportsSessionStorage) {
1402
- value = sessionStorage.getItem(key);
1403
- if (!value && globalValue) {
1404
- value = globalValue;
1405
- sessionStorage.setItem(key, value);
1406
- }
1407
- } else {
1408
- value = globalValue;
1409
- }
1410
- return value ? JSON.parse(value) : void 0;
236
+ function B(t) {
237
+ var e, n = E[t];
238
+ return g ? (e = sessionStorage.getItem(t), !e && n && (e = n, sessionStorage.setItem(t, e))) : e = n, e ? JSON.parse(e) : void 0;
1411
239
  }
1412
- function setSessionStorage(key, value) {
1413
- var value_str = JSON.stringify(value);
1414
- if (supportsSessionStorage) {
1415
- sessionStorage.setItem(key, value_str);
1416
- }
1417
- zarGlobal[key] = value_str;
1418
- }
1419
- function hasAdBlock() {
1420
- var fakeAd = document.createElement("div");
1421
- fakeAd.innerHTML = "&nbsp;";
1422
- fakeAd.className = "pub_300x250 pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links";
1423
- fakeAd.setAttribute("style", "width: 1px !important; height: 1px !important; position: absolute !important; left: -10000px !important; top: -1000px !important;");
1424
- try {
1425
- document.body.appendChild(fakeAd);
1426
- if (document.body.getAttribute("abp") !== null || fakeAd.offsetHeight === 0 || fakeAd.clientHeight === 0) {
1427
- return true;
1428
- }
1429
- if (typeof getComputedStyle !== "undefined") {
1430
- var css = window.getComputedStyle(fakeAd, null);
1431
- if (css && (css.getPropertyValue("display") === "none" || css.getPropertyValue("visibility") === "hidden")) {
1432
- return true;
1433
- }
1434
- }
1435
- document.body.removeChild(fakeAd);
1436
- } catch (e2) {
1437
- }
1438
- return false;
240
+ function ct(t, e) {
241
+ var n = JSON.stringify(e);
242
+ g && sessionStorage.setItem(t, n), E[t] = n;
1439
243
  }
1440
- function makeRequest({ method, url, data, json = true }) {
1441
- return new Promise(function(resolve, reject) {
1442
- var xhr = new XMLHttpRequest();
1443
- xhr.open(method, url);
1444
- xhr.withCredentials = true;
1445
- if (json) {
1446
- xhr.setRequestHeader("Accept", "application/json");
1447
- xhr.setRequestHeader("Content-Type", "application/json");
1448
- }
1449
- xhr.onload = function() {
1450
- if (this.status >= 200 && this.status < 300) {
1451
- if (json) {
1452
- resolve(JSON.parse(xhr.response));
1453
- } else {
1454
- resolve(xhr.response);
1455
- }
1456
- } else {
1457
- reject({
1458
- status: this.status,
1459
- message: xhr.statusText
1460
- });
1461
- }
1462
- };
1463
- xhr.onerror = function() {
1464
- reject({
244
+ function U({ method: t, url: e, data: n, json: r = !0 }) {
245
+ return new Promise(function(a, i) {
246
+ var o = new XMLHttpRequest();
247
+ o.open(t, e), o.withCredentials = !0, r && (o.setRequestHeader("Accept", "application/json"), o.setRequestHeader("Content-Type", "application/json")), o.onload = function() {
248
+ this.status >= 200 && this.status < 300 ? a(r ? JSON.parse(o.response) : o.response) : i({
249
+ status: this.status,
250
+ message: o.statusText
251
+ });
252
+ }, o.onerror = function() {
253
+ i({
1465
254
  status: this.status,
1466
255
  message: "Network Error"
1467
256
  });
1468
- };
1469
- if (data) {
1470
- xhr.send(data);
1471
- } else {
1472
- xhr.send();
1473
- }
257
+ }, n ? o.send(n) : o.send();
1474
258
  });
1475
259
  }
1476
- function formatParams(params) {
1477
- return "?" + Object.keys(params).map(function(key) {
1478
- return key + "=" + encodeURIComponent(params[key]);
260
+ function st(t) {
261
+ return "?" + Object.keys(t).map(function(e) {
262
+ return e + "=" + encodeURIComponent(t[e]);
1479
263
  }).join("&");
1480
264
  }
1481
- function postBeacon(_0) {
1482
- return __async(this, arguments, function* ({ url, data }) {
1483
- if (window && window.navigator && typeof window.navigator.sendBeacon === "function" && typeof window.Blob === "function") {
265
+ function ft(n) {
266
+ return f(this, arguments, function* ({ url: t, data: e }) {
267
+ if (window && window.navigator && typeof window.navigator.sendBeacon == "function" && typeof window.Blob == "function")
1484
268
  try {
1485
- const blob = new Blob([JSON.stringify(data)], { type: "text/plain; charset=UTF-8" });
1486
- if (window.navigator.sendBeacon(url, blob)) {
1487
- return true;
1488
- }
1489
- return false;
1490
- } catch (e2) {
1491
- warn("postBeacon:");
1492
- return false;
269
+ const r = new Blob([JSON.stringify(e)], {
270
+ type: "text/plain; charset=UTF-8"
271
+ });
272
+ return !!window.navigator.sendBeacon(t, r);
273
+ } catch (r) {
274
+ return l("postBeacon:"), !1;
1493
275
  }
1494
- }
1495
- return false;
276
+ return !1;
1496
277
  });
1497
278
  }
1498
- function httpGet(_0) {
1499
- return __async(this, arguments, function* ({ url, params = null, json = true }) {
1500
- var finalUrl = url;
1501
- if (params) {
1502
- finalUrl = finalUrl + formatParams(params);
1503
- }
1504
- return yield makeRequest({ method: "GET", url: finalUrl, json });
279
+ function lt(r) {
280
+ return f(this, arguments, function* ({ url: t, params: e = null, json: n = !0 }) {
281
+ var a = t;
282
+ return e && (a = a + st(e)), yield U({ method: "GET", url: a, json: n });
1505
283
  });
1506
284
  }
1507
- function httpPost(_0) {
1508
- return __async(this, arguments, function* ({ url, data, json = true, beacon = false }) {
1509
- var finalData = data;
1510
- if (json) {
1511
- finalData = JSON.stringify(finalData);
1512
- }
1513
- if (beacon) {
1514
- var res = yield postBeacon({ url, data });
1515
- if (res) {
285
+ function S(a) {
286
+ return f(this, arguments, function* ({ url: t, data: e, json: n = !0, beacon: r = !1 }) {
287
+ var i = e;
288
+ if (n && (i = JSON.stringify(i)), r) {
289
+ var o = yield ft({ url: t, data: e });
290
+ if (o)
1516
291
  return;
1517
- }
1518
- dbg("Beacon failed");
292
+ w("Beacon failed");
1519
293
  }
1520
- return yield makeRequest({ method: "POST", url, data: finalData, json });
294
+ return yield U({ method: "POST", url: t, data: i, json: n });
1521
295
  });
1522
296
  }
1523
- var VID_KEY = "__zar_vid";
1524
- var NUMBER_POOL_SUCCESS = "success";
1525
- var NUMBER_POOL_ERROR = "error";
1526
- var NUMBER_POOL_RENEWAL_TIME_MS = 30 * 1e3;
1527
- var getNumberFailureCount = 0;
1528
- var MAX_GET_NUMBER_FAILURES = 3;
1529
- var poolIntervals = {};
297
+ var z = "__zar_vid", C = "success", b = "error", dt = 30 * 1e3, N = 0, wt = 3, d = {};
1530
298
  window.zarPoolData = window.zarPoolData || null;
1531
- window.zarPoolDLObserverDone = window.zarPoolDLObserverDone || false;
299
+ window.zarPoolDLObserverDone = window.zarPoolDLObserverDone || !1;
1532
300
  window.zarPoolDataLayer = window.zarPoolDataLayer || [];
1533
- var numberOverlayMap = /* @__PURE__ */ new Map();
1534
- function generateVisitId() {
301
+ var v = /* @__PURE__ */ new Map();
302
+ function gt() {
1535
303
  return Date.now().toString(36) + "." + Math.random().toString(36).substring(2);
1536
304
  }
1537
- function initId(key, generator, getter, setter) {
1538
- var id;
1539
- var isNew = false;
1540
- var origReferrer = null;
1541
- var idObj = getter(key);
1542
- if (!idObj || !idObj.id) {
1543
- id = generator();
1544
- origReferrer = document.referrer;
1545
- isNew = true;
1546
- dbg("new ID for", key, "-", id);
1547
- } else {
1548
- id = idObj.id;
1549
- origReferrer = idObj.origReferrer;
1550
- }
1551
- var result = { id, t: Date.now(), origReferrer, isNew };
1552
- setter(key, result);
1553
- return result;
1554
- }
1555
- function initIDs() {
1556
- var vidResult = initId(VID_KEY, generateVisitId, getSessionStorage, setSessionStorage);
1557
- return { vid: vidResult };
1558
- }
1559
- function getDefaultApiUrl() {
305
+ function vt(t, e, n, r) {
306
+ var a, i = !1, o = null, u = n(t);
307
+ !u || !u.id ? (a = e(), o = document.referrer, i = !0, w("new ID for", t, "-", a)) : (a = u.id, o = u.origReferrer);
308
+ var c = { id: a, t: Date.now(), origReferrer: o, isNew: i };
309
+ return r(t, c), c;
310
+ }
311
+ function R() {
312
+ var t = vt(
313
+ z,
314
+ gt,
315
+ B,
316
+ ct
317
+ );
318
+ return { vid: t };
319
+ }
320
+ function q() {
1560
321
  return window.location.protocol + "://" + window.location.host + "/api/v2";
1561
322
  }
1562
- function getIDObj(key) {
1563
- return getSessionStorage(key);
323
+ function A(t) {
324
+ return B(t);
1564
325
  }
1565
- function getID(key) {
1566
- var obj = getIDObj(key);
1567
- return obj ? obj.id : null;
326
+ function M(t) {
327
+ var e = A(t);
328
+ return e ? e.id : null;
1568
329
  }
1569
- function getStorage() {
330
+ function m() {
1570
331
  return {
1571
- vid: getIDObj(VID_KEY)
332
+ vid: A(z)
1572
333
  };
1573
334
  }
1574
- function getIDs() {
335
+ function pt() {
1575
336
  return {
1576
- vid: getID(VID_KEY)
337
+ vid: M(z)
1577
338
  };
1578
339
  }
1579
- function extractPhoneNumber({ elem }) {
1580
- var numberText = null;
1581
- var number = null;
1582
- var href = null;
1583
- var regex = new RegExp("\\+?\\(?\\d*\\)? ?\\(?\\d+\\)?\\d*([\\s./-]?\\d{2,})+", "g");
1584
- if (elem.href && elem.href.startsWith("tel:")) {
1585
- href = elem.href;
1586
- }
1587
- var text = elem.innerText;
1588
- var html = elem.innerHTML;
1589
- var match = regex.exec(text);
1590
- if (match) {
1591
- numberText = match[0].trim();
1592
- number = numberText.replace("+", "").replace(/-/g, "").replace(/ /g, "").replace("(", "").replace(")", "").replace(/^1/, "");
1593
- }
1594
- return { text, html, numberText, href, number };
1595
- }
1596
- function overlayPhoneNumber({ elems, number, force = false }) {
1597
- var origNum;
1598
- var overlayNum = number;
1599
- if (!number.startsWith("+1")) {
1600
- overlayNum = "+1" + number;
1601
- }
1602
- for (var i2 = 0; i2 < elems.length; i2++) {
1603
- if (numberOverlayMap.has(elems[i2])) {
1604
- if (force) {
1605
- origNum = numberOverlayMap.get(elems[i2]);
1606
- } else {
1607
- dbg("element already in overlay map:", elems[i2]);
340
+ function _({ elem: t }) {
341
+ var e = null, n = null, r = null, a = new RegExp(
342
+ "\\+?\\(?\\d*\\)? ?\\(?\\d+\\)?\\d*([\\s./-]?\\d{2,})+",
343
+ "g"
344
+ );
345
+ t.href && t.href.startsWith("tel:") && (r = t.href);
346
+ var i = t.innerText, o = t.innerHTML, u = a.exec(i);
347
+ return u && (e = u[0].trim(), n = e.replace("+", "").replace(/-/g, "").replace(/ /g, "").replace("(", "").replace(")", "").replace(/^1/, "")), { text: i, html: o, numberText: e, href: r, number: n };
348
+ }
349
+ function O({ elems: t, number: e, force: n = !1 }) {
350
+ var r, a = e;
351
+ e.startsWith("+1") || (a = "+1" + e);
352
+ for (var i = 0; i < t.length; i++) {
353
+ if (v.has(t[i]))
354
+ if (n)
355
+ r = v.get(t[i]);
356
+ else {
357
+ w("element already in overlay map:", t[i]);
1608
358
  continue;
1609
359
  }
1610
- }
1611
- var elemNum = extractPhoneNumber({ elem: elems[i2] });
1612
- if (!origNum) {
1613
- origNum = elemNum;
1614
- } else if (!force && elemNum.number && origNum.number && origNum.number !== elemNum.number) {
1615
- warn("overlaying multiple numbers with a single number", origNum.number, elemNum.number);
1616
- }
1617
- dbg("overlaying", overlayNum, "on", elems[i2]);
1618
- if (!numberOverlayMap.has(elems[i2])) {
1619
- numberOverlayMap.set(elems[i2], elemNum);
1620
- }
1621
- if (elemNum.href) {
1622
- elems[i2].href = "tel:" + overlayNum;
1623
- }
1624
- if (elemNum.numberText) {
1625
- elems[i2].innerHTML = "";
1626
- if (elemNum.text) {
1627
- var overlay = overlayNum;
1628
- if (elemNum.numberText.indexOf("-") > -1) {
1629
- overlay = overlayNum.slice(2, 5) + "-" + overlayNum.slice(5, 8) + "-" + overlayNum.slice(8, 12);
1630
- }
1631
- if (elemNum.html.indexOf("<img") > -1) {
1632
- var numberHtml = elemNum.html.replace(elemNum.numberText, overlay);
1633
- elems[i2].innerHTML = numberHtml;
360
+ var o = _({ elem: t[i] });
361
+ if (r ? !n && o.number && r.number && r.number !== o.number && l(
362
+ "overlaying multiple numbers with a single number",
363
+ r.number,
364
+ o.number
365
+ ) : r = o, w("overlaying", a, "on", t[i]), v.has(t[i]) || v.set(t[i], o), o.href && (t[i].href = "tel:" + a), o.numberText)
366
+ if (t[i].innerHTML = "", o.text) {
367
+ var u = a;
368
+ if (o.numberText.indexOf("-") > -1 && (u = a.slice(2, 5) + "-" + a.slice(5, 8) + "-" + a.slice(8, 12)), o.html.indexOf("<img") > -1) {
369
+ var c = o.html.replace(o.numberText, u);
370
+ t[i].innerHTML = c;
1634
371
  } else {
1635
- var numberText = elemNum.text.replace(elemNum.numberText, overlay);
1636
- elems[i2].appendChild(document.createTextNode(numberText));
372
+ var s = o.text.replace(o.numberText, u);
373
+ t[i].appendChild(document.createTextNode(s));
1637
374
  }
1638
- } else {
1639
- elems[i2].appendChild(document.createTextNode(overlayNum));
1640
- }
1641
- } else {
1642
- dbg("no number text found:", elems[i2]);
1643
- }
1644
- }
1645
- }
1646
- function revertOverlayNumbers({ elems }) {
1647
- for (var i2 = 0; i2 < elems.length; i2++) {
1648
- if (numberOverlayMap.has(elems[i2])) {
1649
- var currentHTML = elems[i2].innerHTML;
1650
- var origElemData = numberOverlayMap.get(elems[i2]);
1651
- dbg("orig:", origElemData);
1652
- var origHTML = origElemData.html;
1653
- dbg("reverting", currentHTML, "to", origHTML);
1654
- elems[i2].innerHTML = origHTML;
1655
- if (origElemData.href) {
1656
- elems[i2].href = origElemData.href;
1657
- }
1658
- numberOverlayMap.delete(elems[i2]);
1659
- } else {
1660
- dbg("element not in map:", elems[i2]);
1661
- }
1662
- }
1663
- }
1664
- function clearPoolInterval(poolId) {
1665
- clearInterval(poolIntervals[poolId]);
1666
- delete poolIntervals[poolId];
1667
- }
1668
- function clearPoolIntervals() {
1669
- for (var poolId in poolIntervals) {
1670
- clearPoolInterval(poolId);
1671
- }
1672
- }
1673
- function getPoolNumber(_0) {
1674
- return __async(this, arguments, function* ({
1675
- poolId,
1676
- apiUrl,
1677
- number = null,
1678
- context = null
375
+ } else
376
+ t[i].appendChild(document.createTextNode(a));
377
+ else
378
+ w("no number text found:", t[i]);
379
+ }
380
+ }
381
+ function I({ elems: t }) {
382
+ for (var e = 0; e < t.length; e++)
383
+ if (v.has(t[e])) {
384
+ var n = t[e].innerHTML, r = v.get(t[e]);
385
+ w("orig:", r);
386
+ var a = r.html;
387
+ w("reverting", n, "to", a), a != null && a !== "" ? t[e].innerHTML = a : r.text !== void 0 && r.text !== null ? t[e].textContent = r.text : t[e].textContent = "", r.href && t[e].setAttribute("href", r.href), v.delete(t[e]);
388
+ } else
389
+ w("element not in map:", t[e]);
390
+ }
391
+ function J(t) {
392
+ clearInterval(d[t]), delete d[t];
393
+ }
394
+ function F() {
395
+ for (var t in d)
396
+ J(t);
397
+ }
398
+ function G(a) {
399
+ return f(this, arguments, function* ({
400
+ poolId: t,
401
+ apiUrl: e,
402
+ number: n = null,
403
+ context: r = null
1679
404
  }) {
1680
- var payload = {
1681
- pool_id: poolId,
1682
- number,
1683
- context,
405
+ var i = {
406
+ pool_id: t,
407
+ number: n,
408
+ context: r,
1684
409
  properties: {
1685
- zar: getStorage()
410
+ zar: m()
1686
411
  }
1687
- };
1688
- var resp = yield httpPost({ url: `${apiUrl}/number_pool`, data: payload });
1689
- return resp;
412
+ }, o = yield S({ url: `${e}/number_pool`, data: i });
413
+ return o;
1690
414
  });
1691
415
  }
1692
- function poolActive() {
1693
- return window.zarPoolData && window.zarPoolData.status === NUMBER_POOL_SUCCESS && window.zarPoolData.number;
416
+ function k() {
417
+ return window.zarPoolData && window.zarPoolData.status === C && window.zarPoolData.number;
1694
418
  }
1695
- function drainPoolDataLayer() {
1696
- if (!window.zarPoolDataLayer || !Array.isArray(window.zarPoolDataLayer) || window.zarPoolDataLayer.length === 0) {
419
+ function p() {
420
+ if (!window.zarPoolDataLayer || !Array.isArray(window.zarPoolDataLayer) || window.zarPoolDataLayer.length === 0)
1697
421
  return null;
1698
- }
1699
- var mergedObject = {};
1700
- for (var i2 = 0; i2 < window.zarPoolDataLayer.length; i2++) {
1701
- var obj = window.zarPoolDataLayer[i2];
1702
- for (var key in obj) {
1703
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
1704
- mergedObject[key] = obj[key];
1705
- }
1706
- }
1707
- }
1708
- window.zarPoolDataLayer.length = 0;
1709
- return mergedObject;
1710
- }
1711
- function updateTrackingNumberContext(_0) {
1712
- return __async(this, arguments, function* ({
1713
- apiUrl,
1714
- poolId,
1715
- number,
1716
- context
422
+ for (var t = {}, e = 0; e < window.zarPoolDataLayer.length; e++) {
423
+ var n = window.zarPoolDataLayer[e];
424
+ for (var r in n)
425
+ Object.prototype.hasOwnProperty.call(n, r) && (t[r] = n[r]);
426
+ }
427
+ return window.zarPoolDataLayer.length = 0, t;
428
+ }
429
+ function D(a) {
430
+ return f(this, arguments, function* ({
431
+ apiUrl: t,
432
+ poolId: e,
433
+ number: n,
434
+ context: r
1717
435
  }) {
1718
- if (!poolActive()) {
1719
- warn("no valid pool data, not updating context");
436
+ if (!k()) {
437
+ l("no valid pool data, not updating context");
1720
438
  return;
1721
439
  }
1722
- var payload = {
1723
- pool_id: poolId,
1724
- number,
1725
- context,
440
+ var i = {
441
+ pool_id: e,
442
+ number: n,
443
+ context: r,
1726
444
  properties: {
1727
- zar: getStorage()
445
+ zar: m()
1728
446
  }
1729
- };
1730
- var resp = yield httpPost({ url: `${apiUrl}/update_number`, data: payload });
1731
- return resp;
447
+ }, o = yield S({ url: `${t}/update_number`, data: i });
448
+ return o;
1732
449
  });
1733
450
  }
1734
- function getPoolStats(_0) {
1735
- return __async(this, arguments, function* ({ apiUrl, key = null, with_contexts = false }) {
1736
- var params = {
1737
- key,
1738
- with_contexts
1739
- };
1740
- var resp = yield httpGet({
1741
- url: `${apiUrl}/number_pool_stats`,
1742
- params
451
+ function bt(r) {
452
+ return f(this, arguments, function* ({ apiUrl: t, key: e = null, with_contexts: n = !1 }) {
453
+ var a = {
454
+ key: e,
455
+ with_contexts: n
456
+ }, i = yield lt({
457
+ url: `${t}/number_pool_stats`,
458
+ params: a
1743
459
  });
1744
- return resp;
460
+ return i;
1745
461
  });
1746
462
  }
1747
- function renewTrackingPool() {
1748
- return __async(this, arguments, function* ({
1749
- overlayElements,
1750
- apiUrl = getDefaultApiUrl(),
1751
- contextCallback = null
463
+ function ht() {
464
+ return f(this, arguments, function* ({
465
+ overlayElements: t,
466
+ apiUrl: e = q(),
467
+ contextCallback: n = null
1752
468
  } = {}) {
1753
- var context = drainPoolDataLayer() || {};
1754
- if (contextCallback) {
1755
- context = contextCallback(context) || {};
1756
- }
1757
- const poolId = window.zarPoolData.pool_id;
1758
- const number = window.zarPoolData.number;
469
+ var r = p() || {};
470
+ n && (r = n(r) || {});
471
+ const a = window.zarPoolData.pool_id, i = window.zarPoolData.number;
1759
472
  try {
1760
- var resp = yield getPoolNumber({ poolId, apiUrl, number, context });
1761
- } catch (e2) {
1762
- var msg = "error getting number: " + JSON.stringify(e2);
1763
- warn(msg);
1764
- getNumberFailureCount++;
1765
- if (getNumberFailureCount >= MAX_GET_NUMBER_FAILURES) {
1766
- warn("max failures, stopping pool");
1767
- clearPoolIntervals();
1768
- if (overlayElements) {
1769
- revertOverlayNumbers({ elems: overlayElements });
1770
- }
1771
- }
1772
- return { status: NUMBER_POOL_ERROR, msg };
1773
- }
1774
- if (resp.status === NUMBER_POOL_SUCCESS && resp.number) {
1775
- var force = false;
1776
- if (resp.number !== window.zarPoolData.number) {
1777
- warn("number changed from " + window.zarPoolData.number + " to " + resp.number);
1778
- window.zarPoolData.number = resp.number;
1779
- force = true;
1780
- }
1781
- if (overlayElements) {
1782
- overlayPhoneNumber({
1783
- elems: overlayElements,
1784
- number: resp.number,
1785
- force
1786
- });
1787
- }
1788
- } else {
1789
- if (overlayElements) {
1790
- revertOverlayNumbers({ elems: overlayElements });
1791
- }
1792
- if (poolIntervals[poolId]) {
1793
- clearInterval(poolIntervals[poolId]);
1794
- delete poolIntervals[poolId];
1795
- }
1796
- }
1797
- return resp;
473
+ var o = yield G({ poolId: a, apiUrl: e, number: i, context: r });
474
+ } catch (s) {
475
+ var u = "error getting number: " + JSON.stringify(s);
476
+ return l(u), N++, N >= wt && (l("max failures, stopping pool"), F(), t && I({ elems: t })), { status: b, msg: u };
477
+ }
478
+ if (o.status === C && o.number) {
479
+ var c = !1;
480
+ o.number !== window.zarPoolData.number && (l(
481
+ "number changed from " + window.zarPoolData.number + " to " + o.number
482
+ ), window.zarPoolData.number = o.number, c = !0), t && O({
483
+ elems: t,
484
+ number: o.number,
485
+ force: c
486
+ });
487
+ } else
488
+ t && I({ elems: t }), d[a] && (clearInterval(d[a]), delete d[a]);
489
+ return o;
1798
490
  });
1799
491
  }
1800
- function getPoolId(poolId) {
1801
- if (isFunc(poolId))
1802
- return poolId();
1803
- return poolId;
1804
- }
1805
- function initPoolDataLayerObserver(apiUrl) {
1806
- if (window.zarPoolDLObserverDone) {
1807
- return;
1808
- }
1809
- if (!poolActive()) {
1810
- return;
1811
- }
1812
- var originalPush = window.zarPoolDataLayer.push;
1813
- window.zarPoolDataLayer.push = function(...args) {
1814
- var result = originalPush.apply(this, args);
1815
- var context2 = drainPoolDataLayer();
1816
- if (!context2) {
1817
- return result;
1818
- }
1819
- updateTrackingNumberContext({
1820
- apiUrl,
1821
- poolId: window.zarPoolData.pool_id,
1822
- number: window.zarPoolData.number,
1823
- context: context2
1824
- });
1825
- return result;
1826
- };
1827
- var context = drainPoolDataLayer();
1828
- if (context) {
1829
- updateTrackingNumberContext({
1830
- apiUrl,
492
+ function x(t) {
493
+ return it(t) ? t() : t;
494
+ }
495
+ function mt(t) {
496
+ if (!window.zarPoolDLObserverDone && k()) {
497
+ var e = window.zarPoolDataLayer.push;
498
+ window.zarPoolDataLayer.push = function(...r) {
499
+ var a = e.apply(this, r), i = p();
500
+ return i && D({
501
+ apiUrl: t,
502
+ poolId: window.zarPoolData.pool_id,
503
+ number: window.zarPoolData.number,
504
+ context: i
505
+ }), a;
506
+ };
507
+ var n = p();
508
+ n && D({
509
+ apiUrl: t,
1831
510
  poolId: window.zarPoolData.pool_id,
1832
511
  number: window.zarPoolData.number,
1833
- context
1834
- });
1835
- }
1836
- window.zarPoolDLObserverDone = true;
1837
- }
1838
- function initTrackingPool() {
1839
- return __async(this, arguments, function* ({ poolData, poolConfig, apiUrl } = {}) {
1840
- var msg;
1841
- if (!poolConfig || !poolConfig.poolId || !poolConfig.overlayQuerySelector || !apiUrl) {
1842
- msg = "missing pool config: " + JSON.stringify(poolConfig);
1843
- warn(msg);
1844
- if (poolConfig.initCallback) {
1845
- poolConfig.initCallback({ status: NUMBER_POOL_ERROR, msg });
1846
- }
1847
- return poolIntervals;
1848
- }
1849
- var poolId = getPoolId(poolConfig.poolId);
1850
- if (!poolId) {
1851
- msg = "no pool ID";
1852
- warn(msg);
1853
- if (poolConfig.initCallback) {
1854
- poolConfig.initCallback({ status: NUMBER_POOL_ERROR, msg });
1855
- }
1856
- return poolIntervals;
1857
- }
1858
- if (!poolData) {
1859
- var context = drainPoolDataLayer() || {};
1860
- if (poolConfig.contextCallback) {
1861
- context = poolConfig.contextCallback(context) || {};
1862
- }
512
+ context: n
513
+ }), window.zarPoolDLObserverDone = !0;
514
+ }
515
+ }
516
+ function T() {
517
+ return f(this, arguments, function* ({ poolData: t, poolConfig: e, apiUrl: n } = {}) {
518
+ var r;
519
+ if (!e || !e.poolId || !e.overlayQuerySelector || !n)
520
+ return r = "missing pool config: " + JSON.stringify(e), l(r), e.initCallback && e.initCallback({ status: b, msg: r }), d;
521
+ var a = x(e.poolId);
522
+ if (!a)
523
+ return r = "no pool ID", l(r), e.initCallback && e.initCallback({ status: b, msg: r }), d;
524
+ if (!t) {
525
+ var i = p() || {};
526
+ e.contextCallback && (i = e.contextCallback(i) || {});
1863
527
  try {
1864
- poolData = yield getPoolNumber({ poolId, apiUrl, number: null, context });
1865
- } catch (e2) {
1866
- msg = "error getting number on init: " + JSON.stringify(e2);
1867
- warn(msg);
1868
- if (poolConfig.initCallback) {
1869
- poolConfig.initCallback({ status: NUMBER_POOL_ERROR, msg });
1870
- }
1871
- return poolIntervals;
528
+ t = yield G({ poolId: a, apiUrl: n, number: null, context: i });
529
+ } catch (o) {
530
+ return r = "error getting number on init: " + JSON.stringify(o), l(r), e.initCallback && e.initCallback({ status: b, msg: r }), d;
1872
531
  }
1873
532
  }
1874
- window.zarPoolData = poolData;
1875
- if (poolActive()) {
533
+ if (window.zarPoolData = t, k()) {
1876
534
  try {
1877
- initPoolDataLayerObserver(apiUrl);
1878
- } catch (e2) {
1879
- warn("data layer observer error: " + JSON.stringify(e2));
1880
- }
1881
- afterDOMContentLoaded(function() {
1882
- var overlayElements = document.querySelectorAll(poolConfig.overlayQuerySelector);
1883
- if (!overlayElements) {
1884
- var msg2 = "No elems found for:" + poolConfig.overlayQuerySelector;
1885
- warn(msg2);
1886
- if (poolConfig.initCallback) {
1887
- poolConfig.initCallback({ status: NUMBER_POOL_ERROR, msg: msg2 });
1888
- }
535
+ mt(n);
536
+ } catch (o) {
537
+ l("data layer observer error: " + JSON.stringify(o));
538
+ }
539
+ ot(function() {
540
+ var o = document.querySelectorAll(
541
+ e.overlayQuerySelector
542
+ );
543
+ if (!o) {
544
+ var u = "No elems found for:" + e.overlayQuerySelector;
545
+ l(u), e.initCallback && e.initCallback({ status: b, msg: u });
1889
546
  return;
1890
547
  }
1891
- overlayPhoneNumber({ elems: overlayElements, number: poolData.number });
1892
- var interval = setInterval(function() {
548
+ O({ elems: o, number: t.number });
549
+ var c = setInterval(function() {
1893
550
  try {
1894
- renewTrackingPool({
1895
- overlayElements,
1896
- apiUrl,
1897
- contextCallback: poolConfig.contextCallback
551
+ ht({
552
+ overlayElements: o,
553
+ apiUrl: n,
554
+ contextCallback: e.contextCallback
1898
555
  });
1899
- } catch (e2) {
1900
- var msg3 = "error on interval: " + JSON.stringify(e2);
1901
- warn(msg3);
556
+ } catch (y) {
557
+ var s = "error on interval: " + JSON.stringify(y);
558
+ l(s);
1902
559
  }
1903
- }, poolConfig.renewalInterval || NUMBER_POOL_RENEWAL_TIME_MS);
1904
- poolIntervals[poolData.pool_id] = interval;
1905
- if (poolConfig.initCallback) {
1906
- poolConfig.initCallback(poolData);
1907
- }
560
+ }, e.renewalInterval || dt);
561
+ d[t.pool_id] = c, e.initCallback && e.initCallback(t);
1908
562
  });
1909
563
  }
1910
- return poolIntervals;
564
+ return d;
1911
565
  });
1912
566
  }
1913
- function zar({ apiUrl, poolConfig }) {
1914
- initIDs();
1915
- return {
567
+ function yt({ apiUrl: t, poolConfig: e }) {
568
+ return R(), {
1916
569
  name: "zar",
1917
- config: { apiUrl, poolConfig },
1918
- initialize: function({ config }) {
570
+ config: { apiUrl: t, poolConfig: e },
571
+ initialize: function({ config: n }) {
1919
572
  },
1920
573
  loaded: function() {
1921
- return true;
574
+ return !0;
1922
575
  },
1923
- pageStart: function({ payload, config, instance }) {
1924
- payload.properties.zar = getStorage();
1925
- payload.properties.referrer = document.referrer;
1926
- payload.properties.is_bot = isBot();
1927
- if ("hash" in payload.properties) {
1928
- delete payload.properties["hash"];
1929
- }
1930
- if ("path" in payload.properties) {
1931
- delete payload.properties["path"];
1932
- }
1933
- if ("search" in payload.properties) {
1934
- delete payload.properties["search"];
1935
- }
576
+ pageStart: function({ payload: n, config: r, instance: a }) {
577
+ n.properties.zar = m(), n.properties.referrer = document.referrer, n.properties.is_bot = L();
1936
578
  try {
1937
- var pcfg = config.poolConfig;
1938
- if (pcfg && pcfg.poolId) {
1939
- payload.properties.pool_id = getPoolId(pcfg.poolId);
1940
- var context = drainPoolDataLayer() || {};
1941
- if (pcfg.contextCallback) {
1942
- payload.properties.pool_context = pcfg.contextCallback(context) || {};
1943
- }
579
+ var i = r.poolConfig;
580
+ if (i && i.poolId) {
581
+ n.properties.pool_id = x(i.poolId);
582
+ var o = p() || {};
583
+ i.contextCallback && (n.properties.pool_context = i.contextCallback(o) || {});
1944
584
  }
1945
- } catch (e2) {
1946
- warn("error getting pool id: " + JSON.stringify(e2));
585
+ } catch (u) {
586
+ l("error getting pool id: " + JSON.stringify(u));
1947
587
  }
1948
- return payload;
588
+ return n;
1949
589
  },
1950
- page: function(_0) {
1951
- return __async(this, arguments, function* ({ payload, options, instance, config }) {
1952
- dbg("page", payload, options, config);
1953
- var tries = 0;
1954
- var maxTries = 3;
1955
- var res;
1956
- while (tries < maxTries) {
590
+ page: function(o) {
591
+ return f(this, arguments, function* ({ payload: n, options: r, instance: a, config: i }) {
592
+ w("page", n, r, i);
593
+ for (var u = 0, c = 3, s; u < c; )
1957
594
  try {
1958
- res = yield httpPost({ url: `${config.apiUrl}/page`, data: payload });
595
+ s = yield S({ url: `${i.apiUrl}/page`, data: n });
1959
596
  break;
1960
- } catch (e2) {
1961
- tries++;
1962
- if (tries >= maxTries) {
1963
- warn("error posting page: " + JSON.stringify(e2));
1964
- throw e2;
1965
- }
1966
- yield new Promise((r2) => setTimeout(r2, 1e3));
597
+ } catch (y) {
598
+ if (u++, u >= c)
599
+ throw l("error posting page: " + JSON.stringify(y)), y;
600
+ yield new Promise(($) => setTimeout($, 1e3));
1967
601
  }
1968
- }
1969
- if (res && res.pool_data) {
1970
- initTrackingPool({
1971
- poolData: res.pool_data,
1972
- poolConfig: config.poolConfig,
1973
- apiUrl: config.apiUrl
1974
- });
1975
- }
602
+ s && s.pool_data && T({
603
+ poolData: s.pool_data,
604
+ poolConfig: i.poolConfig,
605
+ apiUrl: i.apiUrl
606
+ });
1976
607
  });
1977
608
  },
1978
- trackStart: function({ payload, config, instance }) {
1979
- payload.properties.zar = getStorage();
1980
- payload.properties.url = window.location.href;
1981
- payload.properties.referrer = document.referrer;
1982
- return payload;
609
+ trackStart: function({ payload: n, config: r, instance: a }) {
610
+ return n.properties.zar = m(), n.properties.url = window.location.href, n.properties.referrer = document.referrer, n;
1983
611
  },
1984
- track: function({ payload, options, instance, config }) {
1985
- dbg("track", payload);
1986
- httpPost({ url: `${config.apiUrl}/track`, data: payload, beacon: true });
612
+ track: function({ payload: n, options: r, instance: a, config: i }) {
613
+ w("track", n), S({ url: `${i.apiUrl}/track`, data: n, beacon: !0 });
1987
614
  },
1988
615
  methods: {
1989
616
  apiUrl() {
1990
- return apiUrl;
617
+ return t;
1991
618
  },
1992
619
  poolConfig() {
1993
- return poolConfig;
620
+ return e;
1994
621
  },
1995
622
  initIDs() {
1996
- return initIDs();
623
+ return R();
1997
624
  },
1998
625
  getIDs() {
1999
- return getIDs();
626
+ return pt();
2000
627
  },
2001
628
  getStorage() {
2002
- return getStorage();
629
+ return m();
2003
630
  },
2004
631
  getVID() {
2005
- return getID(VID_KEY);
2006
- },
2007
- hasAdBlock() {
2008
- return hasAdBlock();
632
+ return M(z);
2009
633
  },
2010
634
  isBot() {
2011
- return isBot();
635
+ return L();
2012
636
  },
2013
- initTrackingPool({ poolConfig: poolConfig2 }) {
2014
- var plugin = this.instance.plugins.zar;
2015
- return initTrackingPool({
637
+ initTrackingPool({ poolConfig: n }) {
638
+ var r = this.instance.plugins.zar;
639
+ return T({
2016
640
  poolData: null,
2017
- poolConfig: Object.assign(plugin.poolConfig(), poolConfig2 || {}),
2018
- apiUrl: plugin.apiUrl()
641
+ poolConfig: Object.assign(r.poolConfig(), n || {}),
642
+ apiUrl: r.apiUrl()
2019
643
  });
2020
644
  },
2021
- updateTrackingNumberContext({ number, context }) {
2022
- var plugin = this.instance.plugins.zar;
2023
- var poolConfig2 = plugin.poolConfig();
2024
- return updateTrackingNumberContext({
645
+ updateTrackingNumberContext({ number: n, context: r }) {
646
+ var a = this.instance.plugins.zar, i = a.poolConfig();
647
+ return D({
2025
648
  apiUrl: this.instance.plugins.zar.apiUrl(),
2026
- poolId: getPoolId(poolConfig2.poolId),
2027
- number,
2028
- context
649
+ poolId: x(i.poolId),
650
+ number: n,
651
+ context: r
2029
652
  });
2030
653
  },
2031
654
  getPoolIntervals() {
2032
- return poolIntervals;
655
+ return d;
2033
656
  },
2034
- clearPoolInterval({ poolId }) {
2035
- clearPoolInterval(poolId);
657
+ clearPoolInterval({ poolId: n }) {
658
+ J(n);
2036
659
  },
2037
660
  clearPoolIntervals() {
2038
- clearPoolIntervals();
661
+ F();
2039
662
  },
2040
- extractPhoneNumbers({ elems }) {
2041
- var res = [];
2042
- for (var i2 = 0; i2 < elems.length; i2++) {
2043
- var elemRes = extractPhoneNumber({ elem: elems[i2] });
2044
- res.push(elemRes);
663
+ extractPhoneNumbers({ elems: n }) {
664
+ for (var r = [], a = 0; a < n.length; a++) {
665
+ var i = _({ elem: n[a] });
666
+ r.push(i);
2045
667
  }
2046
- return res;
668
+ return r;
2047
669
  },
2048
- overlayPhoneNumber({ overlayElements, number }) {
2049
- overlayPhoneNumber({ elems: overlayElements, number });
670
+ overlayPhoneNumber({ overlayElements: n, number: r }) {
671
+ O({ elems: n, number: r });
2050
672
  },
2051
- revertOverlayNumbers({ overlayElements }) {
2052
- revertOverlayNumbers({ elems: overlayElements });
673
+ revertOverlayNumbers({ overlayElements: n }) {
674
+ I({ elems: n });
2053
675
  },
2054
- getPoolStats({ key = null, with_contexts = false }) {
2055
- return getPoolStats({
676
+ getPoolStats({ key: n = null, with_contexts: r = !1 }) {
677
+ return bt({
2056
678
  apiUrl: this.instance.plugins.zar.apiUrl(),
2057
- key,
2058
- with_contexts
679
+ key: n,
680
+ with_contexts: r
2059
681
  });
2060
682
  }
2061
683
  }
2062
684
  };
2063
685
  }
2064
- function init({
2065
- app,
2066
- ga4Config = null,
2067
- facebookConfig = null,
2068
- apiUrl = null,
2069
- poolConfig = null
686
+ function St({
687
+ app: t,
688
+ ga4Config: e = null,
689
+ facebookConfig: n = null,
690
+ apiUrl: r = null,
691
+ poolConfig: a = null
2070
692
  }) {
2071
- if (!apiUrl) {
2072
- apiUrl = getDefaultApiUrl();
2073
- }
2074
- var plugins = [zar({ apiUrl, poolConfig })];
2075
- if (ga4Config) {
2076
- plugins.push(googleAnalytics4(ga4Config));
2077
- }
2078
- if (facebookConfig) {
2079
- plugins.push(facebook(facebookConfig));
2080
- }
2081
- return analyticsLib({ app, plugins });
2082
- }
2083
- export { analyticsLib as Analytics, init, zar };
693
+ r || (r = q());
694
+ var i = [yt({ apiUrl: r, poolConfig: a })];
695
+ return e && i.push(rt(e)), n && i.push(tt(n)), H({ app: t, plugins: i });
696
+ }
697
+ const It = {
698
+ extractPhoneNumber: _,
699
+ overlayPhoneNumber: O,
700
+ revertOverlayNumbers: I,
701
+ drainPoolDataLayer: p,
702
+ getPoolId: x
703
+ };
704
+ export {
705
+ H as Analytics,
706
+ It as __test__,
707
+ St as init,
708
+ yt as zar
709
+ };
2084
710
  //# sourceMappingURL=zar.es.js.map