@epigraph/epigraph-std-lib 5.0.0-alpha.13 → 5.0.0-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +68 -68
  2. package/dist/Epigraph/epigraph.cjs +1 -1
  3. package/dist/Epigraph/epigraph.js +126 -94
  4. package/dist/Epigraph/epigraphBaseSolutions.cjs +1 -1
  5. package/dist/Epigraph/epigraphBaseSolutions.js +68 -60
  6. package/dist/EpigraphLibs/EpigraphAnalytics/epigraphAnalytics.cjs +16 -1
  7. package/dist/EpigraphLibs/EpigraphAnalytics/epigraphAnalytics.d.ts +2 -0
  8. package/dist/EpigraphLibs/EpigraphAnalytics/epigraphAnalytics.js +1057 -2
  9. package/dist/EpigraphLibs/EpigraphAnalytics/plugins/ga4-analytics-plugin.d.ts +11 -6
  10. package/dist/EpigraphLibs/EpigraphAnalytics/plugins/nexus-solutions-analytics-plugin.d.ts +50 -0
  11. package/dist/EpigraphLibs/EpigraphLogger/epigraphLogger.cjs +1 -1
  12. package/dist/EpigraphLibs/EpigraphLogger/epigraphLogger.js +198 -74
  13. package/dist/EpigraphLibs/EpigraphNexusApi/epigraphNexusApi.cjs +1 -1
  14. package/dist/EpigraphLibs/EpigraphNexusApi/epigraphNexusApi.js +425 -197
  15. package/dist/EpigraphLibs/EpigraphQrCodeGenerator/epigraphQrCodeGenerator.cjs +7 -1
  16. package/dist/EpigraphLibs/EpigraphQrCodeGenerator/epigraphQrCodeGenerator.js +78 -2
  17. package/dist/EpigraphLibs/EpigraphResultFactory/epigraphResultFactory.cjs +1 -1
  18. package/dist/EpigraphLibs/EpigraphResultFactory/epigraphResultFactory.js +26 -24
  19. package/dist/EpigraphLibs/EpigraphUnitsConverter/epigraphUnitsConverter.cjs +1 -1
  20. package/dist/EpigraphLibs/EpigraphUnitsConverter/epigraphUnitsConverter.js +88 -2
  21. package/dist/EpigraphLibs/EpigraphUrlProcessor/epigraphUrlProcessor.cjs +1 -1
  22. package/dist/EpigraphLibs/EpigraphUrlProcessor/epigraphUrlProcessor.js +75 -44
  23. package/dist/enums-1vqWxJ0i.cjs +1 -0
  24. package/dist/enums-CvOTKyNu.js +5 -0
  25. package/dist/epigraph-std-lib.cjs +1 -1
  26. package/dist/epigraph-std-lib.js +74 -11
  27. package/dist/lit-element-C3moVMGu.js +524 -0
  28. package/dist/lit-element-CYaaFRfk.cjs +19 -0
  29. package/package.json +40 -40
  30. package/dist/enums-BSSe4NAs.js +0 -8
  31. package/dist/enums-PfFMiIoe.cjs +0 -1
  32. package/dist/epigraphAnalytics-CF9Czp8C.js +0 -722
  33. package/dist/epigraphAnalytics-H3EZRDUh.cjs +0 -1
  34. package/dist/epigraphQrCodeGenerator-BXUNL2XK.js +0 -54
  35. package/dist/epigraphQrCodeGenerator-F2eLrPC_.cjs +0 -7
  36. package/dist/epigraphUnitsConverter-CwpmWl7p.cjs +0 -1
  37. package/dist/epigraphUnitsConverter-DsX4Rmsp.js +0 -66
  38. package/dist/lit--5TUYSGn.js +0 -508
  39. package/dist/lit-DZtv4Pds.cjs +0 -2
@@ -1,2 +1,1057 @@
1
- import { A as e, C as t, D as n, E as r, F as i, I as a, L as o, M as s, N as c, O as l, P as u, R as d, S as f, T as p, _ as m, a as h, b as g, c as _, d as v, f as y, g as b, h as x, i as S, j as C, k as w, l as T, m as E, n as D, o as O, p as k, r as A, s as j, t as M, u as N, v as P, w as F, x as I, y as L } from "../../epigraphAnalytics-CF9Czp8C.js";
2
- export { D as ACTION_PERFORMED, A as BUTTON_TYPE, S as CONTENT_TYPES, h as CURRENCY, i as ConsentPluginNames, O as EpigraphAddToFavouritesEvent, M as EpigraphAnalytics, j as EpigraphArRequestedEvent, _ as EpigraphButtonClickEvent, T as EpigraphChangeRateEvent, N as EpigraphCheckoutEvent, v as EpigraphCompletionRateEvent, y as EpigraphContentSharedEvent, k as EpigraphConversionEvent, E as EpigraphCustomEvent, x as EpigraphEngagementRateEvent, b as EpigraphItemAddedEvent, m as EpigraphItemMovedEvent, P as EpigraphItemRemovedEvent, L as EpigraphKeyboardInteractionEvent, g as EpigraphModuleClosedEvent, I as EpigraphModuleFailedEvent, f as EpigraphModuleLoadingEvent, t as EpigraphModuleReadyEvent, F as EpigraphPanelClosedEvent, p as EpigraphPanelOpenedEvent, r as EpigraphSupportDetectedEvent, n as EpigraphTouchInteractionEvent, l as EpigraphVariantChangedEvent, d as GA4AnalyticsPlugin, w as MODULE_FAILED_ERRORS, o as NexusAnalyticsPlugin, a as OneTrustConsentPlugin, e as PANEL_TYPE, C as SHARE_DESTINATIONS, s as SUPPORT_TYPE, c as TRIGGER_SOURCE, u as VARIANT_CHANGE_TYPES };
1
+ import { N as A } from "../../enums-CvOTKyNu.js";
2
+ var o = /* @__PURE__ */ ((e) => (e.UNAVAILABLE = "unavailable", e.AVAILABLE = "available", e.RESTRICTED = "restricted", e))(o || {});
3
+ const I = Symbol("data"), p = Symbol("next"), G = class C {
4
+ constructor(t) {
5
+ this[I] = t, this[p] = null;
6
+ }
7
+ get data() {
8
+ return this[I];
9
+ }
10
+ set next(t) {
11
+ if (!(t instanceof C) && t !== null)
12
+ throw new Error(
13
+ "This node is not an instance of the custom class 'Node'."
14
+ );
15
+ this[p] = t;
16
+ }
17
+ get next() {
18
+ return this[p];
19
+ }
20
+ };
21
+ let N = G;
22
+ const g = Symbol("head");
23
+ class M {
24
+ constructor() {
25
+ this[g] = null;
26
+ }
27
+ set head(t) {
28
+ this[g] = t;
29
+ }
30
+ get head() {
31
+ return this[g];
32
+ }
33
+ addToTail(t) {
34
+ let i = this.head;
35
+ if (i) {
36
+ for (; i.next !== null; )
37
+ i = i?.next;
38
+ return i.next = new N(t);
39
+ }
40
+ return this.head = new N(t);
41
+ }
42
+ removeHead() {
43
+ const t = this.head;
44
+ if (t)
45
+ return this.head = t.next, t.data;
46
+ }
47
+ }
48
+ const y = Symbol("queue"), l = Symbol("size");
49
+ class v {
50
+ constructor() {
51
+ this[y] = new M(), this[l] = 0;
52
+ }
53
+ get queue() {
54
+ return this[y];
55
+ }
56
+ get size() {
57
+ return this[l];
58
+ }
59
+ enqueue(t) {
60
+ this.queue.addToTail(t), this[l]++;
61
+ }
62
+ dequeue() {
63
+ const t = this.queue.removeHead();
64
+ return this[l]--, t;
65
+ }
66
+ }
67
+ class u {
68
+ static {
69
+ this.NOTIFICATION_NAME = "epg-notification";
70
+ }
71
+ static {
72
+ this.ACTION_SEND_EVENT = "send-event";
73
+ }
74
+ static {
75
+ this.ACTION_INITIALIZED = "initialized";
76
+ }
77
+ static {
78
+ this.ACTION_FAILED_INITIALIZATION = "initialization-failed";
79
+ }
80
+ constructor(t, i, s, n, a, h) {
81
+ this._pluginName = t, this._trackingId = i, this._experienceId = s, this._solution = n, this._initializer = a, this._status = h;
82
+ }
83
+ updateStatus(t) {
84
+ this._status = t;
85
+ }
86
+ updateInitializer(t) {
87
+ this._initializer = t;
88
+ }
89
+ notify(t, i) {
90
+ const s = {
91
+ pluginName: this._pluginName,
92
+ trackingId: this._trackingId,
93
+ experienceId: this._experienceId,
94
+ solution: this._solution,
95
+ initializer: this._initializer,
96
+ status: this._status,
97
+ action: t,
98
+ eventDetails: i
99
+ };
100
+ window.dispatchEvent(new CustomEvent("epg-notification", { detail: s }));
101
+ }
102
+ }
103
+ class $ {
104
+ constructor({
105
+ trackingID: t,
106
+ experienceID: i,
107
+ solution: s,
108
+ verboseLogging: n = !1
109
+ }) {
110
+ this.__status = o.UNAVAILABLE, this.__sentEventCount = 0, this.__initializationAttempts = 0, this.__lastInitializationAttempt = performance.now(), this.__maxInitializationAttempts = 10, this.__initializationRetryDelay = 2e3, this.__isInitialized = !1, this.__initializationMethod = "NONE", this.__nexusFailureReported = !1, this.name = this.pluginName = "GA4-PLUGIN", this.trackingID = t, this.experienceID = i, this.solution = s, this.verboseLogging = n, this.__queue = new v(), this.__epigraphNotifier = new u(
111
+ this.pluginName,
112
+ this.pluginName,
113
+ this.experienceID,
114
+ this.solution,
115
+ this.__initializationMethod,
116
+ this.__status
117
+ ), this.initializePlugin();
118
+ }
119
+ setTrackingID(t) {
120
+ if (!t)
121
+ return;
122
+ const i = this.trackingID !== t;
123
+ this.trackingID = t, i && this.__isInitialized && (this.resetInitialization(), this.initializePlugin());
124
+ }
125
+ setExperienceID(t) {
126
+ this.experienceID = t;
127
+ }
128
+ setSolution(t) {
129
+ this.solution = t;
130
+ }
131
+ getStatus() {
132
+ return this.__status;
133
+ }
134
+ setStatus(t) {
135
+ this.__status = t, this.__epigraphNotifier.updateStatus(t);
136
+ }
137
+ getPendingEventCount() {
138
+ return this.__queue.size;
139
+ }
140
+ getSentEventCount() {
141
+ return this.__sentEventCount;
142
+ }
143
+ getTotalEventCount() {
144
+ return this.getPendingEventCount() + this.getSentEventCount();
145
+ }
146
+ /**
147
+ * Returns a unique plugin identifier so that tracking ID's can be the same across multiple plugins.
148
+ */
149
+ getUniquePluginIdentifier() {
150
+ return `${this.name}-${this.trackingID}`;
151
+ }
152
+ setupPlugin() {
153
+ this.__isInitialized && this.dataLayer !== void 0 && this.dequeueAndSendEvents();
154
+ }
155
+ /**
156
+ * This function will send an Event to Google Analytics 4.
157
+ *
158
+ * @param analyticsEvent
159
+ * @param consent boolean Whether consent is granted
160
+ */
161
+ async sendEvent(t, i) {
162
+ if (this.__queue.enqueue(t), !i) {
163
+ this.__status = o.RESTRICTED;
164
+ return;
165
+ }
166
+ if (!this.__isInitialized) {
167
+ this.logger("Cannot send analytics event: dataLayer not defined or plugin not initialized.");
168
+ return;
169
+ }
170
+ try {
171
+ await this.dequeueAndSendEvents();
172
+ } catch (s) {
173
+ this.logger(s), await this.reportFailureToNexus("EVENT_SEND_ERROR", s?.toString() || "Unknown error");
174
+ }
175
+ }
176
+ resetInitialization() {
177
+ this.__isInitialized = !1, this.__status = o.UNAVAILABLE, this.dataLayer = void 0, this.dataLayerName = void 0, this.__initializationMethod = "NONE", this.__initializationAttempts = 0, this.__nexusFailureReported = !1, this.__epigraphNotifier.updateStatus(this.__status);
178
+ }
179
+ initializePlugin() {
180
+ if (this.__isInitialized)
181
+ return;
182
+ if (this.__initializationAttempts >= this.__maxInitializationAttempts) {
183
+ this.__nexusFailureReported || (this.reportFailureToNexus("MAX_INITIALIZATION_ATTEMPTS", "Maximum initialization attempts reached"), this.__nexusFailureReported = !0, this.__epigraphNotifier.notify(u.ACTION_FAILED_INITIALIZATION, {}));
184
+ return;
185
+ }
186
+ const t = performance.now();
187
+ if (this.__initializationAttempts > 0 && t - this.__lastInitializationAttempt < this.__initializationRetryDelay)
188
+ return;
189
+ this.__lastInitializationAttempt = t, this.__initializationAttempts++;
190
+ const i = this.detectAndSetupAnalytics();
191
+ i.success ? (this.__isInitialized = !0, this.__status = o.AVAILABLE, this.__initializationMethod = i.method, this.dataLayerName = i.dataLayerName, this.dataLayer = window[this.dataLayerName], this.logger(`Successfully initialized ${i.method} with dataLayer: ${this.dataLayerName}`), this.__epigraphNotifier.notify(u.ACTION_INITIALIZED, {}), this.__queue.size > 0 && this.dequeueAndSendEvents()) : (this.logger(`Initialization attempt ${this.__initializationAttempts} failed: ${i.error}`), this.__initializationAttempts < this.__maxInitializationAttempts && setTimeout(() => {
192
+ this.initializePlugin();
193
+ }, this.__initializationRetryDelay));
194
+ }
195
+ detectAndSetupAnalytics() {
196
+ const t = this.detectGTM();
197
+ if (t)
198
+ return this.logger(`GTM detected with container ID: ${t.containerId}`), this.__epigraphNotifier.updateInitializer("GTM"), {
199
+ success: !0,
200
+ method: "GTM",
201
+ dataLayerName: t.dataLayerName
202
+ };
203
+ const i = this.findGA4Info(this.trackingID);
204
+ if (i) {
205
+ const s = i.l || "dataLayer";
206
+ return this.logger(`GA4 script found, setting up with dataLayer: ${s}`), this.__epigraphNotifier.updateInitializer("GA4"), {
207
+ success: !0,
208
+ method: "GA4",
209
+ dataLayerName: s
210
+ };
211
+ }
212
+ return {
213
+ success: !1,
214
+ method: "NONE",
215
+ dataLayerName: "dataLayer",
216
+ error: "No analytics setup found and unable to create one"
217
+ };
218
+ }
219
+ detectGTM() {
220
+ const t = document.querySelectorAll('script[src*="googletagmanager.com/gtm"]');
221
+ for (const i of Array.from(t)) {
222
+ const s = i.getAttribute("src");
223
+ if (s) {
224
+ const n = s.match(/gtm\.js\?id=([^&]+)/);
225
+ if (n && n.length > 0) {
226
+ const a = s.match(/&l=([^&]+)/), h = a ? a[1] : "dataLayer";
227
+ return {
228
+ containerId: n[1],
229
+ dataLayerName: h
230
+ };
231
+ }
232
+ }
233
+ }
234
+ return null;
235
+ }
236
+ /**
237
+ * Send all events that are in the queue
238
+ * @private
239
+ */
240
+ async dequeueAndSendEvents() {
241
+ if (!this.__isInitialized || !this.dataLayer)
242
+ return;
243
+ let t = this.__queue.size;
244
+ for (let i = 0; i < t; i++) {
245
+ const s = this.__queue.dequeue();
246
+ try {
247
+ this.__initializationMethod === "GTM" ? (this.sendGTMEvent(s), this.__sentEventCount++, this.logger(`Analytics event successfully sent via ${this.__initializationMethod}: ${s.eventName}`)) : this.__initializationMethod === "GA4" ? (this.sendGA4Event(s), this.__sentEventCount++, this.logger(`Analytics event successfully sent via ${this.__initializationMethod}: ${s.eventName}`)) : this.__queue.enqueue(s);
248
+ } catch (n) {
249
+ this.logger(`Error sending event ${s.eventName}: ${n}`), this.__queue.enqueue(s);
250
+ }
251
+ }
252
+ }
253
+ /**
254
+ * Send events to GTM based GA4
255
+ * @param event
256
+ * @private
257
+ */
258
+ async sendGTMEvent(t) {
259
+ let i = t.getGTMParameters(this.solution, this.experienceID, this.trackingID);
260
+ const s = i;
261
+ this.isValidPayload(i) || (i = await this.convertGTMParametersToEpgEventTag(t.eventName, i)), this.dataLayer && (this.dataLayer.push(i), this.__epigraphNotifier.notify(u.ACTION_SEND_EVENT, s));
262
+ }
263
+ /**
264
+ * Send events to GA4 via Google Analytics 4.
265
+ * @param event
266
+ * @private
267
+ */
268
+ async sendGA4Event(t) {
269
+ let i = t.getGa4Parameters(this.solution, this.experienceID, this.trackingID);
270
+ const s = i;
271
+ this.isValidPayload(i) || (i = await this.convertGA4ParametersToEpgEventTag(i)), window.gtag("event", t.eventName, i), this.__epigraphNotifier.notify(u.ACTION_SEND_EVENT, s);
272
+ }
273
+ /**
274
+ * Validates a payload by checking its parameter count and the constraints of parameter names and values.
275
+ * See docs here for requirements: https://support.google.com/analytics/answer/9267744?hl=en
276
+ *
277
+ * @param {Record<string, unknown>} parameterPayload - An object containing the parameters to validate.
278
+ * The keys represent parameter names and the values represent parameter values.
279
+ * @return {boolean} Returns true if the payload meets the validation criteria; false otherwise.
280
+ */
281
+ isValidPayload(t) {
282
+ if (Object.keys(t).length >= 25)
283
+ return !1;
284
+ for (const [n, a] of Object.entries(t))
285
+ if (n !== "items" && (n.length > 40 || String(a).length > 100))
286
+ return !1;
287
+ return !0;
288
+ }
289
+ /**
290
+ * Converts the given GTM parameters to an EPG event tag, sending specific parameter payloads
291
+ * for processing and returning the formatted result. Falls back to the original payload in case of errors.
292
+ *
293
+ * @param {string} eventName - The event name associated with the EPG event tag being processed.
294
+ * @param {Record<string, unknown>} parameterPayload - A key-value pair object containing the parameters to be converted.
295
+ * @return {Promise<Record<string, unknown>>} A promise that resolves to an object containing the event name and the generated EPG event tag, or the original payload upon failure.
296
+ */
297
+ async convertGTMParametersToEpgEventTag(t, i) {
298
+ try {
299
+ let s = await this.sendGA4LongParameters(i);
300
+ return {
301
+ event: t,
302
+ epg_event_tag: s,
303
+ send_to: this.trackingID
304
+ };
305
+ } catch {
306
+ return i;
307
+ }
308
+ }
309
+ /**
310
+ * Converts GA4 parameters into an EPG event tag.
311
+ *
312
+ * @param {Record<string, unknown>} parameterPayload - The GA4 parameters to be converted.
313
+ * @return {Promise<Record<string, any>>} A promise resolving to an object containing the EPG event tag or the original payload if the conversion fails.
314
+ */
315
+ async convertGA4ParametersToEpgEventTag(t) {
316
+ try {
317
+ return {
318
+ epg_event_tag: await this.sendGA4LongParameters(t),
319
+ send_to: this.trackingID
320
+ };
321
+ } catch {
322
+ return t;
323
+ }
324
+ }
325
+ /**
326
+ * Checks if verboseLogging is enabled, then logs the error
327
+ * @param err
328
+ */
329
+ logger(t) {
330
+ this.verboseLogging && console.warn(t);
331
+ }
332
+ async sendGA4LongParameters(t) {
333
+ const i = "https://api.myepigraph.com/api/analytics/ga4/custom", s = { parameters: t };
334
+ try {
335
+ const n = await fetch(i, {
336
+ method: "POST",
337
+ // Assuming it's a POST request, adjust if necessary
338
+ headers: {
339
+ "Content-Type": "application/json",
340
+ Accept: "application/json"
341
+ },
342
+ body: JSON.stringify(s)
343
+ });
344
+ return n.ok ? (await n.json())?.id ?? "" : "";
345
+ } catch {
346
+ return "";
347
+ }
348
+ }
349
+ async reportFailureToNexus(t, i) {
350
+ try {
351
+ const s = {
352
+ plugin: "GA4",
353
+ trackingId: this.trackingID,
354
+ solution: this.solution,
355
+ experienceId: this.experienceID,
356
+ failureType: t,
357
+ errorMessage: i,
358
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
359
+ url: window.location.href,
360
+ userAgent: navigator.userAgent
361
+ };
362
+ this.logger(`Failure reported to Nexus: ${JSON.stringify(s)}`);
363
+ } catch (s) {
364
+ this.logger(`Error reporting failure to Nexus: ${s}`);
365
+ }
366
+ }
367
+ findGA4Info(t) {
368
+ if (window.google_tag_manager && window.google_tag_manager[t]) {
369
+ const s = window.google_tag_manager[t];
370
+ if (s && s.dataLayerName)
371
+ return {
372
+ fullSrc: "",
373
+ id: t,
374
+ l: s.dataLayerName
375
+ };
376
+ }
377
+ const i = document.querySelectorAll("script[src]");
378
+ for (const s of i) {
379
+ const n = s.getAttribute("src");
380
+ if (n && n.includes(t)) {
381
+ const a = new URL(n, location.href), h = Object.fromEntries(a.searchParams.entries());
382
+ return {
383
+ fullSrc: a.href,
384
+ id: h.id || void 0,
385
+ l: h.l || void 0
386
+ };
387
+ }
388
+ }
389
+ return null;
390
+ }
391
+ }
392
+ class V {
393
+ constructor({
394
+ trackingID: t,
395
+ experienceID: i,
396
+ solution: s,
397
+ sessionId: n,
398
+ xPath: a,
399
+ verboseLogging: h = !1,
400
+ baseUrl: _ = A.PRODUCTION
401
+ }) {
402
+ this.__status = o.UNAVAILABLE, this.__sentEventCount = 0, this.sessionId = n, this.xPath = a, this.name = this.pluginName = "NEXUS-PLUGIN", this.trackingID = t, this.experienceID = i, this.solution = s, this.verboseLogging = h, this.__queue = new v(), this.url = `${_}analytics/event`, this.__status = o.AVAILABLE, this.__epigraphNotifier = new u(
403
+ this.pluginName,
404
+ this.trackingID,
405
+ this.experienceID,
406
+ this.solution,
407
+ "NEXUS",
408
+ this.__status
409
+ ), this.__epigraphNotifier.notify(u.ACTION_INITIALIZED, {});
410
+ }
411
+ getStatus() {
412
+ return this.__status;
413
+ }
414
+ setStatus(t) {
415
+ this.__status = t, this.__epigraphNotifier.updateStatus(t);
416
+ }
417
+ getPendingEventCount() {
418
+ return this.__queue.size;
419
+ }
420
+ getSentEventCount() {
421
+ return this.__sentEventCount;
422
+ }
423
+ getTotalEventCount() {
424
+ return this.getPendingEventCount() + this.getSentEventCount();
425
+ }
426
+ getUniquePluginIdentifier() {
427
+ return this.name + "-" + this.trackingID;
428
+ }
429
+ setupPlugin() {
430
+ }
431
+ async sendEvent(t, i) {
432
+ if (this.__queue.enqueue(t), !i) {
433
+ this.__status = o.RESTRICTED, this.__epigraphNotifier.updateStatus(this.__status);
434
+ return;
435
+ }
436
+ await this.dequeueAndSendEvents();
437
+ }
438
+ async dequeueAndSendEvents() {
439
+ for (let t = 0; t < this.__queue.size; t++) {
440
+ const i = this.__queue.dequeue(), s = {
441
+ send_to: this.trackingID,
442
+ experience_id: this.experienceID,
443
+ solution: this.solution,
444
+ event: i.eventName,
445
+ parameters: i.getNexusParameters()
446
+ };
447
+ try {
448
+ return (await fetch(this.url, {
449
+ method: "POST",
450
+ // Assuming it's a POST request, adjust if necessary
451
+ headers: {
452
+ "Content-Type": "application/json",
453
+ Accept: "application/json",
454
+ "EPG-SESSION-ID": this.sessionId,
455
+ "EPG-XPATH": this.xPath,
456
+ Origin: typeof window < "u" ? window.location.origin : ""
457
+ },
458
+ body: JSON.stringify(s)
459
+ })).ok && this.__epigraphNotifier.notify(u.ACTION_SEND_EVENT, s), "";
460
+ } catch {
461
+ return "";
462
+ }
463
+ this.__sentEventCount++;
464
+ }
465
+ return "";
466
+ }
467
+ }
468
+ class U {
469
+ constructor({
470
+ productId: t,
471
+ identifier: i,
472
+ identifierType: s,
473
+ experienceType: n,
474
+ renderMode: a = "geo",
475
+ sessionId: h,
476
+ xPath: _,
477
+ solution: z = "",
478
+ verboseLogging: R = !1,
479
+ baseUrl: q = A.PRODUCTION
480
+ }) {
481
+ if (this.experienceID = "", this.__status = o.UNAVAILABLE, this.__sentEventCount = 0, t <= 0)
482
+ throw new Error("NexusSolutionsAnalyticsPlugin requires a valid productId greater than 0.");
483
+ this.sessionId = h, this.xPath = _, this.name = this.pluginName = "NEXUS-SOLUTIONS-PLUGIN", this.verboseLogging = R, this.__queue = new v(), this.productId = t, this.identifier = i, this.identifierType = s, this.experienceType = n, this.renderMode = a, this.solution = z, this.trackingID = String(t), this.url = `${q}analytics/event`, this.__status = o.AVAILABLE, this.__epigraphNotifier = new u(
484
+ this.pluginName,
485
+ this.trackingID,
486
+ `${i}@${s}`,
487
+ this.solution,
488
+ "NEXUS-SOLUTIONS",
489
+ this.__status
490
+ ), this.__epigraphNotifier.notify(u.ACTION_INITIALIZED, {});
491
+ }
492
+ setProductId(t) {
493
+ t <= 0 || (this.productId = t, this.trackingID = String(t));
494
+ }
495
+ setIdentifier(t) {
496
+ this.identifier = t;
497
+ }
498
+ setIdentifierType(t) {
499
+ this.identifierType = t;
500
+ }
501
+ setExperienceType(t) {
502
+ this.experienceType = t;
503
+ }
504
+ setRenderMode(t) {
505
+ this.renderMode = t;
506
+ }
507
+ getStatus() {
508
+ return this.__status;
509
+ }
510
+ setStatus(t) {
511
+ this.__status = t, this.__epigraphNotifier.updateStatus(t);
512
+ }
513
+ getPendingEventCount() {
514
+ return this.__queue.size;
515
+ }
516
+ getSentEventCount() {
517
+ return this.__sentEventCount;
518
+ }
519
+ getTotalEventCount() {
520
+ return this.getPendingEventCount() + this.getSentEventCount();
521
+ }
522
+ getUniquePluginIdentifier() {
523
+ return `${this.name}-${this.sessionId}`;
524
+ }
525
+ setupPlugin() {
526
+ }
527
+ async sendEvent(t, i) {
528
+ if (this.__queue.enqueue(t), !i) {
529
+ this.__status = o.RESTRICTED, this.__epigraphNotifier.updateStatus(this.__status);
530
+ return;
531
+ }
532
+ await this.dequeueAndSendEvents();
533
+ }
534
+ async dequeueAndSendEvents() {
535
+ for (; this.__queue.size > 0; ) {
536
+ const t = this.__queue.dequeue(), i = {
537
+ action: t.eventName,
538
+ product_id: this.productId,
539
+ identifier: this.identifier,
540
+ identifier_type: this.identifierType,
541
+ experience_type: this.experienceType,
542
+ render_mode: this.renderMode,
543
+ parameters: t.getNexusParameters()
544
+ };
545
+ try {
546
+ (await fetch(this.url, {
547
+ method: "POST",
548
+ headers: {
549
+ "Content-Type": "application/json",
550
+ Accept: "application/json",
551
+ "EPG-SESSION-ID": this.sessionId,
552
+ "EPG-XPATH": this.xPath,
553
+ Origin: typeof window < "u" ? window.location.origin : ""
554
+ },
555
+ body: JSON.stringify(i)
556
+ })).ok && (this.__sentEventCount++, this.__epigraphNotifier.notify(u.ACTION_SEND_EVENT, i));
557
+ } catch {
558
+ return;
559
+ }
560
+ }
561
+ }
562
+ }
563
+ class b {
564
+ constructor(t) {
565
+ this.consentSet = !1, this.consent = !1, this.pluginName = "OneTrustConsentPlugin", this.consentIdentifier = t, this.consent = !1, this.addConsentChangedListener();
566
+ }
567
+ /**
568
+ * Checks to see if the user has consented. If this is false, it will block all analytics
569
+ */
570
+ hasConsent() {
571
+ if (this.consentSet)
572
+ return this.consent;
573
+ if (window.OnetrustActiveGroups !== void 0) {
574
+ let t = window.OnetrustActiveGroups;
575
+ t !== void 0 && t.split(",").forEach((s) => {
576
+ s === this.consentIdentifier && (this.consent = !0, this.consentSet = !0);
577
+ });
578
+ }
579
+ return this.consent;
580
+ }
581
+ addConsentChangedListener() {
582
+ window.addEventListener("load", () => {
583
+ this.hasConsent(), window.OneTrust !== void 0 && typeof window.OneTrust == "object" && window.OneTrust.OnConsentChanged(() => {
584
+ this.consentSet = !1, this.hasConsent();
585
+ });
586
+ });
587
+ }
588
+ }
589
+ var S = /* @__PURE__ */ ((e) => (e.OneTrust = "onetrust", e))(S || {});
590
+ class r {
591
+ constructor({
592
+ eventName: t,
593
+ interactiveEvent: i,
594
+ customParameters: s
595
+ }) {
596
+ this.eventName = t, this.interactiveEvent = i, this.customParameters = s;
597
+ }
598
+ getGa4Parameters(t, i, s) {
599
+ let n = {
600
+ solution: t,
601
+ experience_id: i,
602
+ interactive_event: this.interactiveEvent,
603
+ send_to: s
604
+ };
605
+ return n = Object.assign(n, JSON.parse(JSON.stringify(this.customParameters))), n;
606
+ }
607
+ getGTMParameters(t, i, s) {
608
+ let n = {
609
+ solution: t,
610
+ experience_id: i,
611
+ event: this.eventName,
612
+ interactive_event: this.interactiveEvent,
613
+ send_to: s
614
+ };
615
+ return n = Object.assign(n, JSON.parse(JSON.stringify(this.customParameters))), n;
616
+ }
617
+ getNexusParameters() {
618
+ let t = {
619
+ interactive_event: this.interactiveEvent
620
+ };
621
+ return t = Object.assign(t, JSON.parse(JSON.stringify(this.customParameters))), t;
622
+ }
623
+ }
624
+ var O = /* @__PURE__ */ ((e) => (e.VARIANT = "variant", e.CATEGORY_VARIANT = "category_variant", e.GEOMETRY = "geometry", e.CATEGORY_GEOMETRY = "category_geometry", e.GLOBAL = "global", e))(O || {}), m = /* @__PURE__ */ ((e) => (e.AR = "ar", e.QR = "qr", e.INFO = "info", e.INSTRUCTIONS = "instructions", e.DOWNLOAD = "download", e.PREVIEW_CART = "preview_cart", e.HOTSPOT_PANEL = "hotspot_panel", e.SHARE_MODAL = "share_modal", e.RESTART_MODAL = "restart_modal", e.REMOVE_MODAL = "remove_modal", e.LOAD_PRECONFIG_MODAL = "load_preconfig_modal", e.MOVE_MODAL = "move_modal", e.OUT_OF_STOCK_MODAL = "out_of_stock_modal", e))(m || {}), w = /* @__PURE__ */ ((e) => (e.NETWORK = "network", e.EXPERIENCE_CONFIG_ERROR = "experience-config-error", e.SCENE_LOAD_ERROR = "scene-load-error", e.INITIAL_SCENE_LOAD_ERROR = "initial-scene-load-error", e.AUTHENTICATION_FAILED = "authentication-failed", e))(w || {}), E = /* @__PURE__ */ ((e) => (e.AUTO = "auto", e.BUTTON = "button", e.HOTSPOT = "hotspot", e.GESTURE = "gesture", e))(E || {}), d = /* @__PURE__ */ ((e) => (e.USD = "USD", e.EUR = "EUR", e.GBP = "GBP", e.CAD = "CAD", e))(d || {}), L = /* @__PURE__ */ ((e) => (e.AR = "ar", e.QR = "qr", e.AR_WEBGL2 = "ar-webgl2", e.QR_WEBGL2 = "qr-webgl2", e))(L || {}), T = /* @__PURE__ */ ((e) => (e.AR_VIEW = "ar_view", e.DIMENSION_TOGGLE = "dimension_toggle", e.HOTSPOTS_TOGGLE = "hotspots_toggle", e.HELP_TOGGLE = "help_toggle", e.UTILITY_MENU_TOGGLE = "utility_menu_toggle", e.HOTSPOT_ENTER = "hotspot_enter", e.HOTSPOT_EXIT = "hotspot_exit", e.SHARE = "share", e.PDF_DOWNLOAD = "pdf_download", e.COPY = "copy", e.RESTART = "restart", e.INSTRUCTIONS_SHOW = "show_instructions", e.REVIEW_CART = "review_cart", e.SHOP_NOW = "shop_now", e.SUB_CATEGORY = "sub_category", e.NEXT_STEP = "next_step", e.PREVIOUS_STEP = "previous_step", e))(T || {}), f = /* @__PURE__ */ ((e) => (e.ZOOM = "zoom", e.ROTATE = "rotate", e.PAN = "pan", e))(f || {}), x = /* @__PURE__ */ ((e) => (e.CONFIGURATION = "configuration", e.SCENE = "scene", e.PRODUCT = "product", e))(x || {}), P = /* @__PURE__ */ ((e) => (e.FACEBOOK = "facebook", e.TWITTER = "twitter", e.EMAIL = "email", e.COPY_LINK = "copy_link", e.WHATSAPP = "whatsapp", e.LINKEDIN = "linkedin", e))(P || {});
625
+ class F extends r {
626
+ constructor(t) {
627
+ super({
628
+ eventName: "epigraph_ar_requested",
629
+ interactiveEvent: !0,
630
+ customParameters: {
631
+ items: t
632
+ }
633
+ });
634
+ }
635
+ }
636
+ class j extends r {
637
+ constructor(t) {
638
+ super({
639
+ eventName: "epigraph_module_loading",
640
+ interactiveEvent: !1,
641
+ customParameters: {
642
+ is_pre_config: t
643
+ }
644
+ });
645
+ }
646
+ }
647
+ class W extends r {
648
+ constructor(t, i) {
649
+ super({
650
+ eventName: "epigraph_module_ready",
651
+ interactiveEvent: !1,
652
+ customParameters: {
653
+ is_pre_config: t,
654
+ load_time_ms: i
655
+ }
656
+ });
657
+ }
658
+ }
659
+ class J extends r {
660
+ static {
661
+ this.MODULE_FAILED_ERRORS = w;
662
+ }
663
+ constructor(t, i, s) {
664
+ super({
665
+ eventName: "epigraph_module_failed",
666
+ interactiveEvent: !1,
667
+ customParameters: {
668
+ is_pre_config: t,
669
+ load_time_ms: i,
670
+ error_type: s
671
+ }
672
+ });
673
+ }
674
+ }
675
+ class X extends r {
676
+ constructor(t) {
677
+ super({
678
+ eventName: "epigraph_module_closed",
679
+ interactiveEvent: !0,
680
+ customParameters: {
681
+ items: t
682
+ }
683
+ });
684
+ }
685
+ }
686
+ class H extends r {
687
+ static {
688
+ this.SUPPORT_TYPE = L;
689
+ }
690
+ constructor(t) {
691
+ super({
692
+ eventName: "epigraph_support_detected",
693
+ interactiveEvent: !1,
694
+ customParameters: {
695
+ support_type: t
696
+ }
697
+ });
698
+ }
699
+ }
700
+ class K extends r {
701
+ static {
702
+ this.BUTTON_TYPE = T;
703
+ }
704
+ constructor(t, i) {
705
+ super({
706
+ eventName: "epigraph_button_click",
707
+ interactiveEvent: !0,
708
+ customParameters: {
709
+ button_type: t,
710
+ button_name: i
711
+ }
712
+ });
713
+ }
714
+ }
715
+ class Z extends r {
716
+ static {
717
+ this.PANEL_TYPE = m;
718
+ }
719
+ static {
720
+ this.TRIGGER_SOURCE = E;
721
+ }
722
+ constructor(t, i, s, n) {
723
+ super({
724
+ eventName: "epigraph_panel_opened",
725
+ interactiveEvent: t,
726
+ customParameters: {
727
+ items: n,
728
+ panel_type: i,
729
+ trigger_source: s
730
+ }
731
+ });
732
+ }
733
+ }
734
+ class B extends r {
735
+ static {
736
+ this.PANEL_TYPE = m;
737
+ }
738
+ static {
739
+ this.TRIGGER_SOURCE = E;
740
+ }
741
+ constructor(t, i, s, n) {
742
+ super({
743
+ eventName: "epigraph_panel_closed",
744
+ interactiveEvent: t,
745
+ customParameters: {
746
+ items: n,
747
+ panel_type: i,
748
+ trigger_source: s
749
+ }
750
+ });
751
+ }
752
+ }
753
+ class Q extends r {
754
+ constructor(t) {
755
+ super({
756
+ eventName: "epigraph_add_to_favourites",
757
+ interactiveEvent: !0,
758
+ customParameters: {
759
+ items: t
760
+ }
761
+ });
762
+ }
763
+ }
764
+ class Y extends r {
765
+ static {
766
+ this.ACTION_PERFORMED = f;
767
+ }
768
+ constructor(t) {
769
+ super({
770
+ eventName: "epigraph_keyboard_interaction",
771
+ interactiveEvent: !0,
772
+ customParameters: {
773
+ action_performed: t
774
+ }
775
+ });
776
+ }
777
+ }
778
+ class tt extends r {
779
+ static {
780
+ this.INTERACTION_TYPE = f;
781
+ }
782
+ constructor(t) {
783
+ super({
784
+ eventName: "epigraph_touch_interaction",
785
+ interactiveEvent: !0,
786
+ customParameters: {
787
+ interaction_type: t
788
+ }
789
+ });
790
+ }
791
+ }
792
+ class et extends r {
793
+ static {
794
+ this.CURRENCY = d;
795
+ }
796
+ constructor(t, i, s, n, a) {
797
+ super({
798
+ eventName: "epigraph_item_added",
799
+ interactiveEvent: t,
800
+ customParameters: {
801
+ items: a,
802
+ value: i,
803
+ currency: s,
804
+ quantity: n
805
+ }
806
+ });
807
+ }
808
+ }
809
+ class it extends r {
810
+ constructor(t) {
811
+ super({
812
+ eventName: "epigraph_item_moved",
813
+ interactiveEvent: !0,
814
+ customParameters: {
815
+ items: t
816
+ }
817
+ });
818
+ }
819
+ }
820
+ class st extends r {
821
+ static {
822
+ this.CURRENCY = d;
823
+ }
824
+ constructor(t, i, s, n) {
825
+ super({
826
+ eventName: "epigraph_item_removed",
827
+ interactiveEvent: !0,
828
+ customParameters: {
829
+ items: n,
830
+ value: t,
831
+ currency: i,
832
+ quantity: s
833
+ }
834
+ });
835
+ }
836
+ }
837
+ class nt extends r {
838
+ static {
839
+ this.VARIANT_CHANGE_TYPES = O;
840
+ }
841
+ constructor(t, i) {
842
+ super({
843
+ eventName: "epigraph_variant_changed",
844
+ interactiveEvent: !0,
845
+ customParameters: {
846
+ items: i,
847
+ change_type: t
848
+ }
849
+ });
850
+ }
851
+ }
852
+ class rt extends r {
853
+ static {
854
+ this.CONTENT_TYPES = x;
855
+ }
856
+ static {
857
+ this.SHARE_DESTINATIONS = P;
858
+ }
859
+ constructor(t, i, s) {
860
+ super({
861
+ eventName: "epigraph_content_shared",
862
+ interactiveEvent: !0,
863
+ customParameters: {
864
+ items: s,
865
+ content_type: t,
866
+ share_destination: i
867
+ }
868
+ });
869
+ }
870
+ }
871
+ class at extends r {
872
+ static {
873
+ this.CURRENCY = d;
874
+ }
875
+ constructor(t, i, s) {
876
+ super({
877
+ eventName: "epigraph_checkout",
878
+ interactiveEvent: !0,
879
+ customParameters: {
880
+ items: s,
881
+ value: t,
882
+ currency: i
883
+ }
884
+ });
885
+ }
886
+ }
887
+ class ot extends r {
888
+ static {
889
+ this.CURRENCY = d;
890
+ }
891
+ constructor(t, i, s) {
892
+ super({
893
+ eventName: "epigraph_conversion",
894
+ interactiveEvent: !0,
895
+ customParameters: {
896
+ items: s,
897
+ value: t,
898
+ currency: i
899
+ }
900
+ });
901
+ }
902
+ }
903
+ class ut extends r {
904
+ constructor(t) {
905
+ super({
906
+ eventName: "epigraph_changeRate",
907
+ interactiveEvent: !1,
908
+ customParameters: {
909
+ value: t
910
+ }
911
+ });
912
+ }
913
+ }
914
+ class ht extends r {
915
+ constructor(t) {
916
+ super({
917
+ eventName: "epigraph_completionRate",
918
+ interactiveEvent: !1,
919
+ customParameters: {
920
+ value: t
921
+ }
922
+ });
923
+ }
924
+ }
925
+ class ct extends r {
926
+ constructor(t) {
927
+ super({
928
+ eventName: "epigraph_engagementRate",
929
+ interactiveEvent: !1,
930
+ customParameters: {
931
+ value: t
932
+ }
933
+ });
934
+ }
935
+ }
936
+ class dt extends r {
937
+ constructor(t, i, s) {
938
+ super({
939
+ eventName: t,
940
+ interactiveEvent: i,
941
+ customParameters: s
942
+ });
943
+ }
944
+ }
945
+ /**
946
+ * @license
947
+ * Copyright (c) 2023 Epigraph LLC. All Rights Reserved.
948
+ *
949
+ * Licensed under the Apache License, Version 2.0 (the 'License');
950
+ * you may not use this file except in compliance with the License.
951
+ * You may obtain a copy of the License at
952
+ *
953
+ * http://www.apache.org/licenses/LICENSE-2.0
954
+ *
955
+ * Unless required by applicable law or agreed to in writing, software
956
+ * distributed under the License is distributed on an 'AS IS' BASIS,
957
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
958
+ * See the License for the specific language governing permissions and
959
+ * limitations under the License.
960
+ */
961
+ var D;
962
+ const c = Symbol("analyticsPluginsMap");
963
+ D = c;
964
+ class lt {
965
+ constructor(t, i) {
966
+ this[D] = /* @__PURE__ */ new Map(), this.__consentPlugin = null, t && i && (this.__consentPlugin = this.buildConsentPlugin(t, i)), window.addEventListener("epigraphAnalyticsConsentChange", this.__onConsentChangeFromEvent);
967
+ }
968
+ __onConsentChangeFromEvent(t) {
969
+ let i = t;
970
+ this.__overrideConsent = i.detail.hasConsent;
971
+ for (const s of this[c].values())
972
+ this.__hasConsent() || s.setStatus(o.RESTRICTED);
973
+ }
974
+ /**
975
+ * Epigraph Analytics uses plugins to send events to multiple trackers at a time. You can create a customer tracker
976
+ * by implementing the IAnalyticsPlugin and then adding it via this function. This will also hold only a single
977
+ * instance of a plugin with a given Tracking Identifier.
978
+ *
979
+ * @param plugin
980
+ */
981
+ addEventPlugin(t) {
982
+ this[c].has(t.getUniquePluginIdentifier()) || (this[c].set(
983
+ t.getUniquePluginIdentifier(),
984
+ t
985
+ ), t.setupPlugin());
986
+ }
987
+ /**
988
+ * Resolves session consent by prioritizing this._overrideConsent and if not found,
989
+ * getting the value from the consent plugin, if available.
990
+ *
991
+ * @returns {boolean} Whether the session has consent to track analytics or not.
992
+ */
993
+ __hasConsent() {
994
+ let t = !0;
995
+ return this.__overrideConsent !== void 0 ? (t = this.__overrideConsent, t) : (this.__consentPlugin && (t = this.__consentPlugin.hasConsent()), t);
996
+ }
997
+ /**
998
+ * Send an Event to all plugins
999
+ *
1000
+ * @param eventData
1001
+ */
1002
+ sendEvent(t) {
1003
+ this[c].forEach((i) => {
1004
+ i.sendEvent(t, this.__hasConsent());
1005
+ });
1006
+ }
1007
+ /**
1008
+ * Returns an IConsentPlugin if something is passed to it. Returns null if we can't find the plugin named.
1009
+ * @param consentPluginName
1010
+ * @param consentIdentifier
1011
+ * @private
1012
+ */
1013
+ buildConsentPlugin(t, i) {
1014
+ return t.toLowerCase() === S.OneTrust.toLowerCase() ? new b(i) : null;
1015
+ }
1016
+ }
1017
+ export {
1018
+ f as ACTION_PERFORMED,
1019
+ T as BUTTON_TYPE,
1020
+ x as CONTENT_TYPES,
1021
+ d as CURRENCY,
1022
+ S as ConsentPluginNames,
1023
+ Q as EpigraphAddToFavouritesEvent,
1024
+ lt as EpigraphAnalytics,
1025
+ F as EpigraphArRequestedEvent,
1026
+ K as EpigraphButtonClickEvent,
1027
+ ut as EpigraphChangeRateEvent,
1028
+ at as EpigraphCheckoutEvent,
1029
+ ht as EpigraphCompletionRateEvent,
1030
+ rt as EpigraphContentSharedEvent,
1031
+ ot as EpigraphConversionEvent,
1032
+ dt as EpigraphCustomEvent,
1033
+ ct as EpigraphEngagementRateEvent,
1034
+ et as EpigraphItemAddedEvent,
1035
+ it as EpigraphItemMovedEvent,
1036
+ st as EpigraphItemRemovedEvent,
1037
+ Y as EpigraphKeyboardInteractionEvent,
1038
+ X as EpigraphModuleClosedEvent,
1039
+ J as EpigraphModuleFailedEvent,
1040
+ j as EpigraphModuleLoadingEvent,
1041
+ W as EpigraphModuleReadyEvent,
1042
+ B as EpigraphPanelClosedEvent,
1043
+ Z as EpigraphPanelOpenedEvent,
1044
+ H as EpigraphSupportDetectedEvent,
1045
+ tt as EpigraphTouchInteractionEvent,
1046
+ nt as EpigraphVariantChangedEvent,
1047
+ $ as GA4AnalyticsPlugin,
1048
+ w as MODULE_FAILED_ERRORS,
1049
+ V as NexusAnalyticsPlugin,
1050
+ U as NexusSolutionsAnalyticsPlugin,
1051
+ b as OneTrustConsentPlugin,
1052
+ m as PANEL_TYPE,
1053
+ P as SHARE_DESTINATIONS,
1054
+ L as SUPPORT_TYPE,
1055
+ E as TRIGGER_SOURCE,
1056
+ O as VARIANT_CHANGE_TYPES
1057
+ };