@streamlayer/react 1.19.0 → 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/lib/app/pause-ad.d.ts +38 -0
  2. package/lib/cjs/advertisement.js +38 -42
  3. package/lib/cjs/index-l-eyvmpL.js +5 -0
  4. package/lib/cjs/index2.js +3 -3
  5. package/lib/cjs/pause-ad.js +1 -0
  6. package/lib/cjs/provider.js +23 -23
  7. package/lib/cjs/useStreamLayerApp2.js +1 -1
  8. package/lib/cjs/vast-client.min-B0NUra1B.js +1 -0
  9. package/lib/classic/app/pause-ad.d.ts +38 -0
  10. package/lib/classic/cjs/advertisement.js +38 -42
  11. package/lib/classic/cjs/bet-pack.js +3 -3
  12. package/lib/classic/cjs/index-l-eyvmpL.js +5 -0
  13. package/lib/classic/cjs/pause-ad.js +1 -0
  14. package/lib/classic/cjs/provider.js +17 -17
  15. package/lib/classic/cjs/useStreamLayerApp2.js +1 -1
  16. package/lib/classic/cjs/vast-client.min-B0NUra1B.js +1 -0
  17. package/lib/classic/es/advertisement.js +10211 -15019
  18. package/lib/classic/es/bet-pack.js +291 -304
  19. package/lib/classic/es/index-l-eyvmpL.js +3758 -0
  20. package/lib/classic/es/index.js +3 -3
  21. package/lib/classic/es/notification.js +1 -1
  22. package/lib/classic/es/pause-ad.js +250 -0
  23. package/lib/classic/es/provider.js +6776 -6354
  24. package/lib/classic/es/useStreamLayerApp2.js +1 -1
  25. package/lib/classic/es/vast-client.min-B0NUra1B.js +1060 -0
  26. package/lib/dist/cjs/masters.js +22 -22
  27. package/lib/dist/es/masters.js +2815 -2828
  28. package/lib/es/advertisement.js +10211 -15019
  29. package/lib/es/index-l-eyvmpL.js +3758 -0
  30. package/lib/es/index.js +1 -1
  31. package/lib/es/index2.js +275 -288
  32. package/lib/es/masters2.js +1 -1
  33. package/lib/es/notification.js +53 -53
  34. package/lib/es/pause-ad.js +250 -0
  35. package/lib/es/provider.js +5871 -5414
  36. package/lib/es/useStreamLayerApp2.js +1 -1
  37. package/lib/es/vast-client.min-B0NUra1B.js +1060 -0
  38. package/package.json +24 -14
@@ -0,0 +1,1060 @@
1
+ function N() {
2
+ let a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
3
+ return { id: a.id || null, adId: a.adId || null, sequence: a.sequence || null, apiFramework: a.apiFramework || null, universalAdIds: [], creativeExtensions: [] };
4
+ }
5
+ const G = ["ADCATEGORIES", "ADCOUNT", "ADPLAYHEAD", "ADSERVINGID", "ADTYPE", "APIFRAMEWORKS", "APPBUNDLE", "ASSETURI", "BLOCKEDADCATEGORIES", "BREAKMAXADLENGTH", "BREAKMAXADS", "BREAKMAXDURATION", "BREAKMINADLENGTH", "BREAKMINDURATION", "BREAKPOSITION", "CLICKPOS", "CLICKTYPE", "CLIENTUA", "CONTENTID", "CONTENTPLAYHEAD", "CONTENTURI", "DEVICEIP", "DEVICEUA", "DOMAIN", "EXTENSIONS", "GDPRCONSENT", "IFA", "IFATYPE", "INVENTORYSTATE", "LATLONG", "LIMITADTRACKING", "MEDIAMIME", "MEDIAPLAYHEAD", "OMIDPARTNER", "PAGEURL", "PLACEMENTTYPE", "PLAYERCAPABILITIES", "PLAYERSIZE", "PLAYERSTATE", "PODSEQUENCE", "REGULATIONS", "SERVERSIDE", "SERVERUA", "TRANSACTIONID", "UNIVERSALADID", "VASTVERSIONS", "VERIFICATIONVENDORS"];
6
+ function w(a) {
7
+ let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
8
+ const r = [], s = M(a);
9
+ !e.ERRORCODE || t.isCustomCode || /^[0-9]{3}$/.test(e.ERRORCODE) || (e.ERRORCODE = 900), e.CACHEBUSTING = q(Math.round(1e8 * Math.random())), e.TIMESTAMP = (/* @__PURE__ */ new Date()).toISOString(), e.RANDOM = e.random = e.CACHEBUSTING;
10
+ for (const i in e) e[i] = j(e[i]);
11
+ for (const i in s) {
12
+ const o = s[i];
13
+ typeof o == "string" && r.push(B(o, e));
14
+ }
15
+ return r;
16
+ }
17
+ function B(a, e) {
18
+ const t = (a = L(a, e)).match(/[^[\]]+(?=])/g);
19
+ if (!t) return a;
20
+ let r = t.filter((s) => G.indexOf(s) > -1);
21
+ return r.length === 0 ? a : (r = r.reduce((s, i) => (s[i] = -1, s), {}), L(a, r));
22
+ }
23
+ function L(a, e) {
24
+ let t = a;
25
+ for (const r in e) {
26
+ const s = e[r];
27
+ t = t.replace(new RegExp("(?:\\[|%%)(".concat(r, ")(?:\\]|%%)"), "g"), s);
28
+ }
29
+ return t;
30
+ }
31
+ function M(a) {
32
+ return Array.isArray(a) ? a.map((e) => e && e.hasOwnProperty("url") ? e.url : e) : a;
33
+ }
34
+ function C(a) {
35
+ return /^(https?:\/\/|\/\/)/.test(a);
36
+ }
37
+ function U(a, e) {
38
+ for (let t = 0; t < e.length; t++) if (W(e[t], a)) return !0;
39
+ return !1;
40
+ }
41
+ function W(a, e) {
42
+ if (a && e) {
43
+ const t = Object.getOwnPropertyNames(a), r = Object.getOwnPropertyNames(e);
44
+ return t.length === r.length && a.id === e.id && a.url === e.url;
45
+ }
46
+ return !1;
47
+ }
48
+ function j(a) {
49
+ return encodeURIComponent(a).replace(/[!'()*]/g, (e) => "%".concat(e.charCodeAt(0).toString(16)));
50
+ }
51
+ function q(a) {
52
+ let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
53
+ return a.toString().padStart(e, "0");
54
+ }
55
+ const T = { track: function(a, e, t) {
56
+ w(a, e, t).forEach((r) => {
57
+ typeof window < "u" && window !== null && (new Image().src = r);
58
+ });
59
+ }, resolveURLTemplates: w, extractURLsFromTemplates: M, filterUrlTemplates: function(a) {
60
+ return a.reduce((e, t) => {
61
+ const r = t.url || t;
62
+ return C(r) ? e.validUrls.push(r) : e.invalidUrls.push(r), e;
63
+ }, { validUrls: [], invalidUrls: [] });
64
+ }, containsTemplateObject: U, isTemplateObjectEqual: W, encodeURIComponentRFC3986: j, replaceUrlMacros: B, isNumeric: function(a) {
65
+ return !isNaN(parseFloat(a)) && isFinite(a);
66
+ }, flatten: function a(e) {
67
+ return e.reduce((t, r) => t.concat(Array.isArray(r) ? a(r) : r), []);
68
+ }, joinArrayOfUniqueTemplateObjs: function() {
69
+ let a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
70
+ const t = Array.isArray(a) ? a : [], r = Array.isArray(e) ? e : [];
71
+ return t.concat(r).reduce((s, i) => (U(i, s) || s.push(i), s), []);
72
+ }, isValidTimeValue: function(a) {
73
+ return Number.isFinite(a) && a >= -2;
74
+ }, addLeadingZeros: q, isValidUrl: C, isBrowserEnvironment: function() {
75
+ return typeof window < "u";
76
+ }, formatMacrosValues: function(a) {
77
+ return typeof a != "object" ? a : JSON.stringify(a);
78
+ } };
79
+ function I(a) {
80
+ return ["true", "TRUE", "True", "1"].includes(a);
81
+ }
82
+ function Y(a) {
83
+ if (a == null) return -1;
84
+ if (T.isNumeric(a)) return parseInt(a);
85
+ const e = a.split(":");
86
+ if (e.length !== 3) return -1;
87
+ const t = e[2].split(".");
88
+ let r = parseInt(t[0]);
89
+ t.length === 2 && (r += parseFloat("0.".concat(t[1])));
90
+ const s = parseInt(60 * e[1]), i = parseInt(60 * e[0] * 60);
91
+ return isNaN(i) || isNaN(s) || isNaN(r) || s > 3600 || r > 60 ? -1 : i + s + r;
92
+ }
93
+ const l = { childByName: function(a, e) {
94
+ return Array.from(a.childNodes).find((t) => t.nodeName === e);
95
+ }, childrenByName: function(a, e) {
96
+ return Array.from(a.childNodes).filter((t) => t.nodeName === e);
97
+ }, resolveVastAdTagURI: function(a, e) {
98
+ if (!e) return a;
99
+ if (a.startsWith("//")) {
100
+ const { protocol: t } = location;
101
+ return "".concat(t).concat(a);
102
+ }
103
+ if (!a.includes("://")) {
104
+ const t = e.slice(0, e.lastIndexOf("/"));
105
+ return "".concat(t, "/").concat(a);
106
+ }
107
+ return a;
108
+ }, parseBoolean: I, parseNodeText: function(a) {
109
+ return a && (a.textContent || a.text || "").trim();
110
+ }, copyNodeAttribute: function(a, e, t) {
111
+ const r = e.getAttribute(a);
112
+ r && t.setAttribute(a, r);
113
+ }, parseAttributes: function(a) {
114
+ return Array.from(a.attributes).reduce((e, t) => (e[t.nodeName] = t.nodeValue, e), {});
115
+ }, parseDuration: Y, getStandAloneAds: function() {
116
+ return (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []).filter((a) => !parseInt(a.sequence, 10));
117
+ }, getSortedAdPods: function() {
118
+ return (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []).filter((a) => parseInt(a.sequence, 10)).sort((a, e) => a.sequence - e.sequence);
119
+ }, assignAttributes: function(a, e) {
120
+ a && Array.from(a).forEach((t) => {
121
+ let { nodeName: r, nodeValue: s } = t;
122
+ if (r && s && e.hasOwnProperty(r)) {
123
+ let i = s;
124
+ typeof e[r] == "boolean" && (i = I(i)), e[r] = i;
125
+ }
126
+ });
127
+ }, mergeWrapperAdData: function(a, e) {
128
+ var t;
129
+ a.errorURLTemplates = e.errorURLTemplates.concat(a.errorURLTemplates), a.impressionURLTemplates = e.impressionURLTemplates.concat(a.impressionURLTemplates), a.extensions = e.extensions.concat(a.extensions), e.viewableImpression.length > 0 && (a.viewableImpression = [...a.viewableImpression, ...e.viewableImpression]), a.followAdditionalWrappers = e.followAdditionalWrappers, a.allowMultipleAds = e.allowMultipleAds, a.fallbackOnNoAd = e.fallbackOnNoAd;
130
+ const r = (e.creatives || []).filter((n) => n && n.type === "companion"), s = r.reduce((n, c) => ((c.variations || []).forEach((u) => {
131
+ (u.companionClickTrackingURLTemplates || []).forEach((d) => {
132
+ T.containsTemplateObject(d, n) || n.push(d);
133
+ });
134
+ }), n), []);
135
+ a.creatives = r.concat(a.creatives);
136
+ const i = e.videoClickTrackingURLTemplates && e.videoClickTrackingURLTemplates.length, o = e.videoCustomClickURLTemplates && e.videoCustomClickURLTemplates.length;
137
+ if (a.creatives.forEach((n) => {
138
+ if (e.trackingEvents && e.trackingEvents[n.type]) for (const c in e.trackingEvents[n.type]) {
139
+ const u = e.trackingEvents[n.type][c];
140
+ Array.isArray(n.trackingEvents[c]) || (n.trackingEvents[c] = []), n.trackingEvents[c] = n.trackingEvents[c].concat(u);
141
+ }
142
+ n.type === "linear" && (i && (n.videoClickTrackingURLTemplates = n.videoClickTrackingURLTemplates.concat(e.videoClickTrackingURLTemplates)), o && (n.videoCustomClickURLTemplates = n.videoCustomClickURLTemplates.concat(e.videoCustomClickURLTemplates)), !e.videoClickThroughURLTemplate || n.videoClickThroughURLTemplate !== null && n.videoClickThroughURLTemplate !== void 0 || (n.videoClickThroughURLTemplate = e.videoClickThroughURLTemplate)), n.type === "companion" && s.length && (n.variations || []).forEach((c) => {
143
+ c.companionClickTrackingURLTemplates = T.joinArrayOfUniqueTemplateObjs(c.companionClickTrackingURLTemplates, s);
144
+ });
145
+ }), e.adVerifications && (a.adVerifications = a.adVerifications.concat(e.adVerifications)), e.blockedAdCategories && (a.blockedAdCategories = a.blockedAdCategories.concat(e.blockedAdCategories)), (t = e.creatives) !== null && t !== void 0 && t.length) {
146
+ const n = e.creatives.filter((c) => {
147
+ var u;
148
+ return ((u = c.icons) === null || u === void 0 ? void 0 : u.length) && !c.mediaFiles.length;
149
+ });
150
+ n.length && (a.creatives = a.creatives.concat(n));
151
+ }
152
+ } };
153
+ function Q(a, e) {
154
+ const t = function() {
155
+ let r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
156
+ const { id: s, adId: i, sequence: o, apiFramework: n } = N(r);
157
+ return { id: s, adId: i, sequence: o, apiFramework: n, type: "companion", required: null, variations: [] };
158
+ }(e);
159
+ return t.required = a.getAttribute("required") || null, t.variations = l.childrenByName(a, "Companion").map((r) => {
160
+ const s = function() {
161
+ let n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
162
+ return { id: n.id || null, adType: "companionAd", width: n.width || 0, height: n.height || 0, assetWidth: n.assetWidth || null, assetHeight: n.assetHeight || null, expandedWidth: n.expandedWidth || null, expandedHeight: n.expandedHeight || null, apiFramework: n.apiFramework || null, adSlotId: n.adSlotId || null, pxratio: n.pxratio || "1", renderingMode: n.renderingMode || "default", staticResources: [], htmlResources: [], iframeResources: [], adParameters: null, altText: null, companionClickThroughURLTemplate: null, companionClickTrackingURLTemplates: [], trackingEvents: {} };
163
+ }(l.parseAttributes(r));
164
+ s.htmlResources = l.childrenByName(r, "HTMLResource").reduce((n, c) => {
165
+ const u = l.parseNodeText(c);
166
+ return u ? n.concat(u) : n;
167
+ }, []), s.iframeResources = l.childrenByName(r, "IFrameResource").reduce((n, c) => {
168
+ const u = l.parseNodeText(c);
169
+ return u ? n.concat(u) : n;
170
+ }, []), s.staticResources = l.childrenByName(r, "StaticResource").reduce((n, c) => {
171
+ const u = l.parseNodeText(c);
172
+ return u ? n.concat({ url: u, creativeType: c.getAttribute("creativeType") || null }) : n;
173
+ }, []), s.altText = l.parseNodeText(l.childByName(r, "AltText")) || null;
174
+ const i = l.childByName(r, "TrackingEvents");
175
+ i && l.childrenByName(i, "Tracking").forEach((n) => {
176
+ const c = n.getAttribute("event"), u = l.parseNodeText(n);
177
+ c && u && (Array.isArray(s.trackingEvents[c]) || (s.trackingEvents[c] = []), s.trackingEvents[c].push(u));
178
+ }), s.companionClickTrackingURLTemplates = l.childrenByName(r, "CompanionClickTracking").map((n) => ({ id: n.getAttribute("id") || null, url: l.parseNodeText(n) })), s.companionClickThroughURLTemplate = l.parseNodeText(l.childByName(r, "CompanionClickThrough")) || null;
179
+ const o = l.childByName(r, "AdParameters");
180
+ return o && (s.adParameters = { value: l.parseNodeText(o), xmlEncoded: o.getAttribute("xmlEncoded") || null }), s;
181
+ }), t;
182
+ }
183
+ function X(a, e) {
184
+ let t;
185
+ const r = function() {
186
+ let c = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
187
+ const { id: u, adId: d, sequence: g, apiFramework: m } = N(c);
188
+ return { id: u, adId: d, sequence: g, apiFramework: m, type: "linear", duration: 0, skipDelay: null, mediaFiles: [], mezzanine: null, interactiveCreativeFile: null, closedCaptionFiles: [], videoClickThroughURLTemplate: null, videoClickTrackingURLTemplates: [], videoCustomClickURLTemplates: [], adParameters: null, icons: [], trackingEvents: {} };
189
+ }(e);
190
+ r.duration = l.parseDuration(l.parseNodeText(l.childByName(a, "Duration")));
191
+ const s = a.getAttribute("skipoffset");
192
+ if (s == null) r.skipDelay = null;
193
+ else if (s.charAt(s.length - 1) === "%" && r.duration !== -1) {
194
+ const c = parseInt(s, 10);
195
+ r.skipDelay = r.duration * (c / 100);
196
+ } else r.skipDelay = l.parseDuration(s);
197
+ const i = l.childByName(a, "VideoClicks");
198
+ if (i) {
199
+ const c = l.childByName(i, "ClickThrough");
200
+ r.videoClickThroughURLTemplate = c ? { id: c.getAttribute("id") || null, url: l.parseNodeText(c) } : null, l.childrenByName(i, "ClickTracking").forEach((u) => {
201
+ r.videoClickTrackingURLTemplates.push({ id: u.getAttribute("id") || null, url: l.parseNodeText(u) });
202
+ }), l.childrenByName(i, "CustomClick").forEach((u) => {
203
+ r.videoCustomClickURLTemplates.push({ id: u.getAttribute("id") || null, url: l.parseNodeText(u) });
204
+ });
205
+ }
206
+ const o = l.childByName(a, "AdParameters");
207
+ o && (r.adParameters = { value: l.parseNodeText(o), xmlEncoded: o.getAttribute("xmlEncoded") || null }), l.childrenByName(a, "TrackingEvents").forEach((c) => {
208
+ l.childrenByName(c, "Tracking").forEach((u) => {
209
+ let d = u.getAttribute("event");
210
+ const g = l.parseNodeText(u);
211
+ if (d && g) {
212
+ if (d === "progress") {
213
+ if (t = u.getAttribute("offset"), !t) return;
214
+ d = t.charAt(t.length - 1) === "%" ? "progress-".concat(t) : "progress-".concat(l.parseDuration(t));
215
+ }
216
+ Array.isArray(r.trackingEvents[d]) || (r.trackingEvents[d] = []), r.trackingEvents[d].push(g);
217
+ }
218
+ });
219
+ }), l.childrenByName(a, "MediaFiles").forEach((c) => {
220
+ l.childrenByName(c, "MediaFile").forEach((h) => {
221
+ r.mediaFiles.push(function(p) {
222
+ const v = { id: null, fileURL: null, fileSize: 0, deliveryType: "progressive", mimeType: null, mediaType: null, codec: null, bitrate: 0, minBitrate: 0, maxBitrate: 0, width: 0, height: 0, apiFramework: null, scalable: null, maintainAspectRatio: null };
223
+ v.id = p.getAttribute("id"), v.fileURL = l.parseNodeText(p), v.deliveryType = p.getAttribute("delivery"), v.codec = p.getAttribute("codec"), v.mimeType = p.getAttribute("type"), v.mediaType = p.getAttribute("mediaType") || "2D", v.apiFramework = p.getAttribute("apiFramework"), v.fileSize = parseInt(p.getAttribute("fileSize") || 0), v.bitrate = parseInt(p.getAttribute("bitrate") || 0), v.minBitrate = parseInt(p.getAttribute("minBitrate") || 0), v.maxBitrate = parseInt(p.getAttribute("maxBitrate") || 0), v.width = parseInt(p.getAttribute("width") || 0), v.height = parseInt(p.getAttribute("height") || 0);
224
+ const R = p.getAttribute("scalable");
225
+ R && typeof R == "string" && (v.scalable = l.parseBoolean(R));
226
+ const A = p.getAttribute("maintainAspectRatio");
227
+ return A && typeof A == "string" && (v.maintainAspectRatio = l.parseBoolean(A)), v;
228
+ }(h));
229
+ });
230
+ const u = l.childByName(c, "InteractiveCreativeFile");
231
+ u && (r.interactiveCreativeFile = function(h) {
232
+ const p = function() {
233
+ let v = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
234
+ return { type: v.type || null, apiFramework: v.apiFramework || null, variableDuration: l.parseBoolean(v.variableDuration), fileURL: null };
235
+ }(l.parseAttributes(h));
236
+ return p.fileURL = l.parseNodeText(h), p;
237
+ }(u));
238
+ const d = l.childByName(c, "ClosedCaptionFiles");
239
+ d && l.childrenByName(d, "ClosedCaptionFile").forEach((h) => {
240
+ const p = function() {
241
+ let v = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
242
+ return { type: v.type || null, language: v.language || null, fileURL: null };
243
+ }(l.parseAttributes(h));
244
+ p.fileURL = l.parseNodeText(h), r.closedCaptionFiles.push(p);
245
+ });
246
+ const g = l.childByName(c, "Mezzanine"), m = function(h, p) {
247
+ const v = {};
248
+ let R = !1;
249
+ return p.forEach((A) => {
250
+ h && h.getAttribute(A) ? v[A] = h.getAttribute(A) : R = !0;
251
+ }), R ? null : v;
252
+ }(g, ["delivery", "type", "width", "height"]);
253
+ if (m) {
254
+ const h = { id: null, fileURL: null, delivery: null, codec: null, type: null, width: 0, height: 0, fileSize: 0, mediaType: "2D" };
255
+ h.id = g.getAttribute("id"), h.fileURL = l.parseNodeText(g), h.delivery = m.delivery, h.codec = g.getAttribute("codec"), h.type = m.type, h.width = parseInt(m.width, 10), h.height = parseInt(m.height, 10), h.fileSize = parseInt(g.getAttribute("fileSize"), 10), h.mediaType = g.getAttribute("mediaType") || "2D", r.mezzanine = h;
256
+ }
257
+ });
258
+ const n = l.childByName(a, "Icons");
259
+ return n && l.childrenByName(n, "Icon").forEach((c) => {
260
+ r.icons.push(function(u) {
261
+ const d = { program: null, height: 0, width: 0, xPosition: 0, yPosition: 0, apiFramework: null, offset: null, duration: 0, type: null, staticResource: null, htmlResource: null, iframeResource: null, pxratio: "1", iconClickThroughURLTemplate: null, iconClickTrackingURLTemplates: [], iconViewTrackingURLTemplate: null, iconClickFallbackImages: [], altText: null, hoverText: null };
262
+ d.program = u.getAttribute("program"), d.height = parseInt(u.getAttribute("height") || 0), d.width = parseInt(u.getAttribute("width") || 0), d.xPosition = function(m) {
263
+ return ["left", "right"].indexOf(m) !== -1 ? m : parseInt(m || 0);
264
+ }(u.getAttribute("xPosition")), d.yPosition = function(m) {
265
+ return ["top", "bottom"].indexOf(m) !== -1 ? m : parseInt(m || 0);
266
+ }(u.getAttribute("yPosition")), d.apiFramework = u.getAttribute("apiFramework"), d.pxratio = u.getAttribute("pxratio") || "1", d.offset = l.parseDuration(u.getAttribute("offset")), d.duration = l.parseDuration(u.getAttribute("duration")), d.altText = u.getAttribute("altText"), d.hoverText = u.getAttribute("hoverText"), l.childrenByName(u, "HTMLResource").forEach((m) => {
267
+ d.type = m.getAttribute("creativeType") || "text/html", d.htmlResource = l.parseNodeText(m);
268
+ }), l.childrenByName(u, "IFrameResource").forEach((m) => {
269
+ d.type = m.getAttribute("creativeType") || 0, d.iframeResource = l.parseNodeText(m);
270
+ }), l.childrenByName(u, "StaticResource").forEach((m) => {
271
+ d.type = m.getAttribute("creativeType") || 0, d.staticResource = l.parseNodeText(m);
272
+ });
273
+ const g = l.childByName(u, "IconClicks");
274
+ if (g) {
275
+ d.iconClickThroughURLTemplate = l.parseNodeText(l.childByName(g, "IconClickThrough")), l.childrenByName(g, "IconClickTracking").forEach((h) => {
276
+ d.iconClickTrackingURLTemplates.push({ id: h.getAttribute("id") || null, url: l.parseNodeText(h) });
277
+ });
278
+ const m = l.childByName(g, "IconClickFallbackImages");
279
+ m && l.childrenByName(m, "IconClickFallbackImage").forEach((h) => {
280
+ d.iconClickFallbackImages.push({ url: l.parseNodeText(h) || null, width: h.getAttribute("width") || null, height: h.getAttribute("height") || null });
281
+ });
282
+ }
283
+ return d.iconViewTrackingURLTemplate = l.parseNodeText(l.childByName(u, "IconViewTracking")), d;
284
+ }(c));
285
+ }), r;
286
+ }
287
+ function Z(a, e) {
288
+ const t = function() {
289
+ let r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
290
+ const { id: s, adId: i, sequence: o, apiFramework: n } = N(r);
291
+ return { id: s, adId: i, sequence: o, apiFramework: n, type: "nonlinear", variations: [], trackingEvents: {} };
292
+ }(e);
293
+ return l.childrenByName(a, "TrackingEvents").forEach((r) => {
294
+ let s, i;
295
+ l.childrenByName(r, "Tracking").forEach((o) => {
296
+ s = o.getAttribute("event"), i = l.parseNodeText(o), s && i && (Array.isArray(t.trackingEvents[s]) || (t.trackingEvents[s] = []), t.trackingEvents[s].push(i));
297
+ });
298
+ }), l.childrenByName(a, "NonLinear").forEach((r) => {
299
+ const s = { id: null, width: 0, height: 0, expandedWidth: 0, expandedHeight: 0, scalable: !0, maintainAspectRatio: !0, minSuggestedDuration: 0, apiFramework: "static", adType: "nonLinearAd", type: null, staticResource: null, htmlResource: null, iframeResource: null, nonlinearClickThroughURLTemplate: null, nonlinearClickTrackingURLTemplates: [], adParameters: null };
300
+ s.id = r.getAttribute("id") || null, s.width = r.getAttribute("width"), s.height = r.getAttribute("height"), s.expandedWidth = r.getAttribute("expandedWidth"), s.expandedHeight = r.getAttribute("expandedHeight"), s.scalable = l.parseBoolean(r.getAttribute("scalable")), s.maintainAspectRatio = l.parseBoolean(r.getAttribute("maintainAspectRatio")), s.minSuggestedDuration = l.parseDuration(r.getAttribute("minSuggestedDuration")), s.apiFramework = r.getAttribute("apiFramework"), l.childrenByName(r, "HTMLResource").forEach((o) => {
301
+ s.type = o.getAttribute("creativeType") || "text/html", s.htmlResource = l.parseNodeText(o);
302
+ }), l.childrenByName(r, "IFrameResource").forEach((o) => {
303
+ s.type = o.getAttribute("creativeType") || 0, s.iframeResource = l.parseNodeText(o);
304
+ }), l.childrenByName(r, "StaticResource").forEach((o) => {
305
+ s.type = o.getAttribute("creativeType") || 0, s.staticResource = l.parseNodeText(o);
306
+ });
307
+ const i = l.childByName(r, "AdParameters");
308
+ i && (s.adParameters = { value: l.parseNodeText(i), xmlEncoded: i.getAttribute("xmlEncoded") || null }), s.nonlinearClickThroughURLTemplate = l.parseNodeText(l.childByName(r, "NonLinearClickThrough")), l.childrenByName(r, "NonLinearClickTracking").forEach((o) => {
309
+ s.nonlinearClickTrackingURLTemplates.push({ id: o.getAttribute("id") || null, url: l.parseNodeText(o) });
310
+ }), t.variations.push(s);
311
+ }), t;
312
+ }
313
+ function x(a) {
314
+ const e = [];
315
+ return a.forEach((t) => {
316
+ const r = K(t);
317
+ r && e.push(r);
318
+ }), e;
319
+ }
320
+ function K(a) {
321
+ if (a.nodeName === "#comment") return null;
322
+ const e = { name: null, value: null, attributes: {}, children: [] }, t = a.attributes, r = a.childNodes;
323
+ if (e.name = a.nodeName, a.attributes) {
324
+ for (const i in t) if (t.hasOwnProperty(i)) {
325
+ const o = t[i];
326
+ o.nodeName && o.nodeValue && (e.attributes[o.nodeName] = o.nodeValue);
327
+ }
328
+ }
329
+ for (const i in r) if (r.hasOwnProperty(i)) {
330
+ const o = K(r[i]);
331
+ o && e.children.push(o);
332
+ }
333
+ if (e.children.length === 0 || e.children.length === 1 && ["#cdata-section", "#text"].indexOf(e.children[0].name) >= 0) {
334
+ const i = l.parseNodeText(a);
335
+ i !== "" && (e.value = i), e.children = [];
336
+ }
337
+ return (s = e).value === null && Object.keys(s.attributes).length === 0 && s.children.length === 0 ? null : e;
338
+ var s;
339
+ }
340
+ function J(a) {
341
+ return a.getAttribute("AdID") || a.getAttribute("adID") || a.getAttribute("adId") || null;
342
+ }
343
+ const y = { Wrapper: { subElements: ["VASTAdTagURI", "Impression"] }, BlockedAdCategories: { attributes: ["authority"] }, InLine: { subElements: ["AdSystem", "AdTitle", "Impression", "AdServingId", "Creatives"] }, Category: { attributes: ["authority"] }, Pricing: { attributes: ["model", "currency"] }, Verification: { oneOfinLineResources: ["JavaScriptResource", "ExecutableResource"], attributes: ["vendor"] }, UniversalAdId: { attributes: ["idRegistry"] }, JavaScriptResource: { attributes: ["apiFramework", "browserOptional"] }, ExecutableResource: { attributes: ["apiFramework", "type"] }, Tracking: { attributes: ["event"] }, Creatives: { subElements: ["Creative"] }, Creative: { subElements: ["UniversalAdId"] }, Linear: { subElements: ["MediaFiles", "Duration"] }, MediaFiles: { subElements: ["MediaFile"] }, MediaFile: { attributes: ["delivery", "type", "width", "height"] }, Mezzanine: { attributes: ["delivery", "type", "width", "height"] }, NonLinear: { oneOfinLineResources: ["StaticResource", "IFrameResource", "HTMLResource"], attributes: ["width", "height"] }, Companion: { oneOfinLineResources: ["StaticResource", "IFrameResource", "HTMLResource"], attributes: ["width", "height"] }, StaticResource: { attributes: ["creativeType"] }, Icons: { subElements: ["Icon"] }, Icon: { oneOfinLineResources: ["StaticResource", "IFrameResource", "HTMLResource"] } };
344
+ function S(a, e) {
345
+ if (!y[a.nodeName] || !y[a.nodeName].attributes) return;
346
+ const t = y[a.nodeName].attributes.filter((r) => !a.getAttribute(r));
347
+ t.length > 0 && k({ name: a.nodeName, parentName: a.parentNode.nodeName, attributes: t }, e);
348
+ }
349
+ function V(a, e, t) {
350
+ const r = y[a.nodeName], s = !t && a.nodeName !== "Wrapper";
351
+ if (!(!r || s)) {
352
+ if (r.subElements) {
353
+ const i = r.subElements.filter((o) => !l.childByName(a, o));
354
+ i.length > 0 && k({ name: a.nodeName, parentName: a.parentNode.nodeName, subElements: i }, e);
355
+ }
356
+ !t || !r.oneOfinLineResources || r.oneOfinLineResources.some((i) => l.childByName(a, i)) || k({ name: a.nodeName, parentName: a.parentNode.nodeName, oneOfResources: r.oneOfinLineResources }, e);
357
+ }
358
+ }
359
+ function D(a) {
360
+ return a.children && a.children.length !== 0;
361
+ }
362
+ function k(a, e) {
363
+ let { name: t, parentName: r, attributes: s, subElements: i, oneOfResources: o } = a, n = "Element '".concat(t, "'");
364
+ n += s ? " missing required attribute(s) '".concat(s.join(", "), "' ") : i ? " missing required sub element(s) '".concat(i.join(", "), "' ") : o ? " must provide one of the following '".concat(o.join(", "), "' ") : " is empty", e("VAST-warning", { message: n, parentElement: r, specVersion: 4.1 });
365
+ }
366
+ const $ = { verifyRequiredValues: function a(e, t, r) {
367
+ if (e && e.nodeName) if (e.nodeName === "InLine" && (r = !0), S(e, t), D(e)) {
368
+ V(e, t, r);
369
+ for (let s = 0; s < e.children.length; s++) a(e.children[s], t, r);
370
+ } else l.parseNodeText(e).length === 0 && k({ name: e.nodeName, parentName: e.parentNode.nodeName }, t);
371
+ }, hasSubElements: D, emitMissingValueWarning: k, verifyRequiredAttributes: S, verifyRequiredSubElements: V };
372
+ function ee(a, e) {
373
+ let { allowMultipleAds: t, followAdditionalWrappers: r } = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
374
+ const s = Array.from(a.childNodes).filter((i) => {
375
+ const o = i.nodeName.toLowerCase();
376
+ return o === "inline" || r !== !1 && o === "wrapper";
377
+ });
378
+ for (const i of s) {
379
+ if (l.copyNodeAttribute("id", a, i), l.copyNodeAttribute("sequence", a, i), l.copyNodeAttribute("adType", a, i), i.nodeName === "Wrapper") return { ad: re(i, e), type: "WRAPPER" };
380
+ if (i.nodeName === "InLine") return { ad: te(i, e, { allowMultipleAds: t }), type: "INLINE" };
381
+ const o = i.nodeName.toLowerCase();
382
+ e("VAST-warning", { message: "<".concat(i.nodeName, o === "inline" ? "> must be written <InLine>" : "> must be written <Wrapper>"), wrongNode: i });
383
+ }
384
+ }
385
+ function te(a, e) {
386
+ let { allowMultipleAds: t } = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
387
+ return t === !1 && a.getAttribute("sequence") ? null : H(a, e);
388
+ }
389
+ function H(a, e) {
390
+ let t = [];
391
+ e && $.verifyRequiredValues(a, e);
392
+ const r = Array.from(a.childNodes), s = function() {
393
+ let i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
394
+ return { id: i.id || null, sequence: i.sequence || null, adType: i.adType || null, adServingId: null, categories: [], expires: null, viewableImpression: [], system: null, title: null, description: null, advertiser: null, pricing: null, survey: null, errorURLTemplates: [], impressionURLTemplates: [], creatives: [], extensions: [], adVerifications: [], blockedAdCategories: [], followAdditionalWrappers: !0, allowMultipleAds: !1, fallbackOnNoAd: null };
395
+ }(l.parseAttributes(a));
396
+ return r.forEach((i) => {
397
+ switch (i.nodeName) {
398
+ case "Error":
399
+ s.errorURLTemplates.push(l.parseNodeText(i));
400
+ break;
401
+ case "Impression":
402
+ s.impressionURLTemplates.push({ id: i.getAttribute("id") || null, url: l.parseNodeText(i) });
403
+ break;
404
+ case "Creatives":
405
+ s.creatives = function(o) {
406
+ const n = [];
407
+ return o.forEach((c) => {
408
+ const u = { id: c.getAttribute("id") || null, adId: J(c), sequence: c.getAttribute("sequence") || null, apiFramework: c.getAttribute("apiFramework") || null }, d = [];
409
+ let g;
410
+ l.childrenByName(c, "UniversalAdId").forEach((h) => {
411
+ const p = { idRegistry: h.getAttribute("idRegistry") || "unknown", value: l.parseNodeText(h) };
412
+ d.push(p);
413
+ });
414
+ const m = l.childByName(c, "CreativeExtensions");
415
+ m && (g = x(l.childrenByName(m, "CreativeExtension")));
416
+ for (const h in c.childNodes) {
417
+ const p = c.childNodes[h];
418
+ let v;
419
+ switch (p.nodeName) {
420
+ case "Linear":
421
+ v = X(p, u);
422
+ break;
423
+ case "NonLinearAds":
424
+ v = Z(p, u);
425
+ break;
426
+ case "CompanionAds":
427
+ v = Q(p, u);
428
+ }
429
+ v && (d && (v.universalAdIds = d), g && (v.creativeExtensions = g), n.push(v));
430
+ }
431
+ }), n;
432
+ }(l.childrenByName(i, "Creative"));
433
+ break;
434
+ case "Extensions": {
435
+ const o = l.childrenByName(i, "Extension");
436
+ s.extensions = x(o), s.adVerifications.length || (t = function(n) {
437
+ let c = null, u = [];
438
+ return n.some((d) => c = l.childByName(d, "AdVerifications")), c && (u = O(l.childrenByName(c, "Verification"))), u;
439
+ }(o));
440
+ break;
441
+ }
442
+ case "AdVerifications":
443
+ s.adVerifications = O(l.childrenByName(i, "Verification"));
444
+ break;
445
+ case "AdSystem":
446
+ s.system = { value: l.parseNodeText(i), version: i.getAttribute("version") || null };
447
+ break;
448
+ case "AdTitle":
449
+ s.title = l.parseNodeText(i);
450
+ break;
451
+ case "AdServingId":
452
+ s.adServingId = l.parseNodeText(i);
453
+ break;
454
+ case "Category":
455
+ s.categories.push({ authority: i.getAttribute("authority") || null, value: l.parseNodeText(i) });
456
+ break;
457
+ case "Expires":
458
+ s.expires = parseInt(l.parseNodeText(i), 10);
459
+ break;
460
+ case "ViewableImpression":
461
+ s.viewableImpression.push(function(o) {
462
+ const n = (c, u) => {
463
+ const d = l.parseNodeText(u);
464
+ return d && c.push(d), c;
465
+ };
466
+ return { id: o.getAttribute("id") || null, viewable: l.childrenByName(o, "Viewable").reduce(n, []), notViewable: l.childrenByName(o, "NotViewable").reduce(n, []), viewUndetermined: l.childrenByName(o, "ViewUndetermined").reduce(n, []) };
467
+ }(i));
468
+ break;
469
+ case "Description":
470
+ s.description = l.parseNodeText(i);
471
+ break;
472
+ case "Advertiser":
473
+ s.advertiser = { id: i.getAttribute("id") || null, value: l.parseNodeText(i) };
474
+ break;
475
+ case "Pricing":
476
+ s.pricing = { value: l.parseNodeText(i), model: i.getAttribute("model") || null, currency: i.getAttribute("currency") || null };
477
+ break;
478
+ case "Survey":
479
+ s.survey = { value: l.parseNodeText(i), type: i.getAttribute("type") || null };
480
+ break;
481
+ case "BlockedAdCategories":
482
+ s.blockedAdCategories.push({ authority: i.getAttribute("authority") || null, value: l.parseNodeText(i) });
483
+ }
484
+ }), t.length && (s.adVerifications = s.adVerifications.concat(t)), s;
485
+ }
486
+ function re(a, e) {
487
+ const t = H(a, e), r = a.getAttribute("followAdditionalWrappers"), s = a.getAttribute("allowMultipleAds"), i = a.getAttribute("fallbackOnNoAd");
488
+ t.followAdditionalWrappers = !r || l.parseBoolean(r), t.allowMultipleAds = !!s && l.parseBoolean(s), t.fallbackOnNoAd = i ? l.parseBoolean(i) : null;
489
+ let o = l.childByName(a, "VASTAdTagURI");
490
+ if (o ? t.nextWrapperURL = l.parseNodeText(o) : (o = l.childByName(a, "VASTAdTagURL"), o && (t.nextWrapperURL = l.parseNodeText(l.childByName(o, "URL")))), t.creatives.forEach((n) => {
491
+ if (["linear", "nonlinear"].includes(n.type)) {
492
+ if (n.trackingEvents) {
493
+ t.trackingEvents || (t.trackingEvents = {}), t.trackingEvents[n.type] || (t.trackingEvents[n.type] = {});
494
+ for (const c in n.trackingEvents) {
495
+ const u = n.trackingEvents[c];
496
+ Array.isArray(t.trackingEvents[n.type][c]) || (t.trackingEvents[n.type][c] = []), u.forEach((d) => {
497
+ t.trackingEvents[n.type][c].push(d);
498
+ });
499
+ }
500
+ }
501
+ n.videoClickTrackingURLTemplates && (Array.isArray(t.videoClickTrackingURLTemplates) || (t.videoClickTrackingURLTemplates = []), n.videoClickTrackingURLTemplates.forEach((c) => {
502
+ t.videoClickTrackingURLTemplates.push(c);
503
+ })), n.videoClickThroughURLTemplate && (t.videoClickThroughURLTemplate = n.videoClickThroughURLTemplate), n.videoCustomClickURLTemplates && (Array.isArray(t.videoCustomClickURLTemplates) || (t.videoCustomClickURLTemplates = []), n.videoCustomClickURLTemplates.forEach((c) => {
504
+ t.videoCustomClickURLTemplates.push(c);
505
+ }));
506
+ }
507
+ }), t.nextWrapperURL) return t;
508
+ }
509
+ function O(a) {
510
+ const e = [];
511
+ return a.forEach((t) => {
512
+ const r = { resource: null, vendor: null, browserOptional: !1, apiFramework: null, type: null, parameters: null, trackingEvents: {} }, s = Array.from(t.childNodes);
513
+ l.assignAttributes(t.attributes, r), s.forEach((o) => {
514
+ let { nodeName: n, textContent: c, attributes: u } = o;
515
+ switch (n) {
516
+ case "JavaScriptResource":
517
+ case "ExecutableResource":
518
+ r.resource = c.trim(), l.assignAttributes(u, r);
519
+ break;
520
+ case "VerificationParameters":
521
+ r.parameters = c.trim();
522
+ }
523
+ });
524
+ const i = l.childByName(t, "TrackingEvents");
525
+ i && l.childrenByName(i, "Tracking").forEach((o) => {
526
+ const n = o.getAttribute("event"), c = l.parseNodeText(o);
527
+ n && c && (Array.isArray(r.trackingEvents[n]) || (r.trackingEvents[n] = []), r.trackingEvents[n].push(c));
528
+ }), e.push(r);
529
+ }), e;
530
+ }
531
+ class _ {
532
+ constructor() {
533
+ this._handlers = [];
534
+ }
535
+ on(e, t) {
536
+ if (typeof t != "function") throw new TypeError("The handler argument must be of type Function. Received type ".concat(typeof t));
537
+ if (!e) throw new TypeError("The event argument must be of type String. Received type ".concat(typeof e));
538
+ return this._handlers.push({ event: e, handler: t }), this;
539
+ }
540
+ once(e, t) {
541
+ return this.on(e, function(r, s, i) {
542
+ const o = { fired: !1, wrapFn: void 0 };
543
+ function n() {
544
+ o.fired || (r.off(s, o.wrapFn), o.fired = !0, i.bind(r)(...arguments));
545
+ }
546
+ return o.wrapFn = n, n;
547
+ }(this, e, t));
548
+ }
549
+ off(e, t) {
550
+ return this._handlers = this._handlers.filter((r) => r.event !== e || r.handler !== t), this;
551
+ }
552
+ emit(e) {
553
+ for (var t = arguments.length, r = new Array(t > 1 ? t - 1 : 0), s = 1; s < t; s++) r[s - 1] = arguments[s];
554
+ let i = !1;
555
+ return this._handlers.forEach((o) => {
556
+ o.event === "*" && (i = !0, o.handler(e, ...r)), o.event === e && (i = !0, o.handler(...r));
557
+ }), i;
558
+ }
559
+ removeAllListeners(e) {
560
+ return e ? (this._handlers = this._handlers.filter((t) => t.event !== e), this) : (this._handlers = [], this);
561
+ }
562
+ listenerCount(e) {
563
+ return this._handlers.filter((t) => t.event === e).length;
564
+ }
565
+ listeners(e) {
566
+ return this._handlers.reduce((t, r) => (r.event === e && t.push(r.handler), t), []);
567
+ }
568
+ eventNames() {
569
+ return this._handlers.map((e) => e.event);
570
+ }
571
+ }
572
+ let F = 0, E = 0;
573
+ const z = (a, e) => {
574
+ !a || !e || a <= 0 || e <= 0 || (E = (E * F + 8 * a / e) / ++F);
575
+ }, ae = { ERRORCODE: 900, extensions: [] }, P = "VAST response version not supported";
576
+ class se extends _ {
577
+ constructor() {
578
+ let { fetcher: e } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
579
+ super(), this.maxWrapperDepth = null, this.rootErrorURLTemplates = [], this.errorURLTemplates = [], this.remainingAds = [], this.parsingOptions = {}, this.fetcher = e || null, this.keepFailedAdPod = !1;
580
+ }
581
+ trackVastError(e, t) {
582
+ for (var r = arguments.length, s = new Array(r > 2 ? r - 2 : 0), i = 2; i < r; i++) s[i - 2] = arguments[i];
583
+ this.emit("VAST-error", Object.assign({}, ae, t, ...s)), T.track(e, t);
584
+ }
585
+ getErrorURLTemplates() {
586
+ return this.rootErrorURLTemplates.concat(this.errorURLTemplates);
587
+ }
588
+ getEstimatedBitrate() {
589
+ return E;
590
+ }
591
+ initParsingStatus() {
592
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
593
+ this.maxWrapperDepth = e.wrapperLimit || 10, this.parsingOptions = { allowMultipleAds: e.allowMultipleAds }, this.keepFailedAdPod = e.keepFailedAdPod || !1, this.rootURL = "", this.resetParsingStatus(), z(e.byteLength, e.requestDuration);
594
+ }
595
+ resetParsingStatus() {
596
+ this.errorURLTemplates = [], this.rootErrorURLTemplates = [], this.vastVersion = null;
597
+ }
598
+ getRemainingAds(e) {
599
+ if (this.remainingAds.length === 0) return Promise.reject(new Error("No more ads are available for the given VAST"));
600
+ const t = e ? this.remainingAds : [this.remainingAds.shift()];
601
+ return this.errorURLTemplates = [], this.resolveAds(t, { wrapperDepth: 0, url: this.rootURL }).then((r) => this.buildVASTResponse(r));
602
+ }
603
+ parseVAST(e) {
604
+ let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
605
+ return this.initParsingStatus(t), t.isRootVAST = !0, this.parse(e, t).then((r) => this.buildVASTResponse(r));
606
+ }
607
+ buildVASTResponse(e) {
608
+ const t = function(r) {
609
+ let { ads: s, errorURLTemplates: i, version: o } = r;
610
+ return { ads: s || [], errorURLTemplates: i || [], version: o || null };
611
+ }({ ads: e, errorURLTemplates: this.getErrorURLTemplates(), version: this.vastVersion });
612
+ return this.completeWrapperResolving(t), t;
613
+ }
614
+ parseVastXml(e, t) {
615
+ let { isRootVAST: r = !1, url: s = null, wrapperDepth: i = 0, allowMultipleAds: o, followAdditionalWrappers: n } = t;
616
+ if (!e || !e.documentElement || e.documentElement.nodeName !== "VAST") {
617
+ var c;
618
+ this.emit("VAST-ad-parsed", { type: "ERROR", url: s, wrapperDepth: i });
619
+ const m = (e == null || (c = e.documentElement) === null || c === void 0 ? void 0 : c.nodeName) === "VideoAdServingTemplate";
620
+ throw new Error(m ? P : "Invalid VAST XMLDocument");
621
+ }
622
+ const u = [], d = e.documentElement.childNodes, g = e.documentElement.getAttribute("version");
623
+ r && g && (this.vastVersion = g);
624
+ for (const m in d) {
625
+ const h = d[m];
626
+ if (h.nodeName === "Error") {
627
+ const p = l.parseNodeText(h);
628
+ r ? this.rootErrorURLTemplates.push(p) : this.errorURLTemplates.push(p);
629
+ } else if (h.nodeName === "Ad") {
630
+ if (this.vastVersion && parseFloat(this.vastVersion) < 3) o = !0;
631
+ else if (o === !1 && u.length > 1) break;
632
+ const p = ee(h, this.emit.bind(this), { allowMultipleAds: o, followAdditionalWrappers: n });
633
+ p.ad ? (u.push(p.ad), this.emit("VAST-ad-parsed", { type: p.type, url: s, wrapperDepth: i, adIndex: u.length - 1, vastVersion: g })) : this.trackVastError(this.getErrorURLTemplates(), { ERRORCODE: 101 });
634
+ }
635
+ }
636
+ return u;
637
+ }
638
+ parse(e) {
639
+ let { url: t = null, resolveAll: r = !0, wrapperSequence: s = null, previousUrl: i = null, wrapperDepth: o = 0, isRootVAST: n = !1, followAdditionalWrappers: c, allowMultipleAds: u } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, d = [];
640
+ this.vastVersion && parseFloat(this.vastVersion) < 3 && n && (u = !0);
641
+ try {
642
+ d = this.parseVastXml(e, { isRootVAST: n, url: t, wrapperDepth: o, allowMultipleAds: u, followAdditionalWrappers: c });
643
+ } catch (g) {
644
+ return Promise.reject(g);
645
+ }
646
+ if (d.length === 1 && s != null && (d[0].sequence = s), r === !1) {
647
+ const g = l.getSortedAdPods(d), m = l.getStandAloneAds(d);
648
+ g.length ? d = g : m.length && (d = [m.shift()]), this.remainingAds = m;
649
+ }
650
+ return this.resolveAds(d, { wrapperDepth: o, previousUrl: i, url: t });
651
+ }
652
+ resolveAds() {
653
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], { wrapperDepth: t, previousUrl: r, url: s } = arguments.length > 1 ? arguments[1] : void 0;
654
+ const i = [];
655
+ return r = s, e.forEach((o) => {
656
+ const n = this.resolveWrappers(o, t, r);
657
+ i.push(n);
658
+ }), Promise.all(i).then((o) => T.flatten(o));
659
+ }
660
+ resolveWrappers(e, t, r) {
661
+ const s = { ...e };
662
+ return new Promise((i) => {
663
+ var o;
664
+ if (t++, !s.nextWrapperURL) return delete s.nextWrapperURL, i(s);
665
+ if (!this.fetcher) return s.VASTAdTagURI = s.nextWrapperURL, delete s.nextWrapperURL, i(s);
666
+ if (t >= this.maxWrapperDepth) return s.errorCode = 302, delete s.nextWrapperURL, i(s);
667
+ s.nextWrapperURL = l.resolveVastAdTagURI(s.nextWrapperURL, r);
668
+ const n = (o = this.parsingOptions.allowMultipleAds) !== null && o !== void 0 ? o : s.allowMultipleAds, c = s.sequence;
669
+ this.fetcher.fetchVAST({ url: s.nextWrapperURL, emitter: this.emit.bind(this), maxWrapperDepth: this.maxWrapperDepth }).then((u) => this.parse(u, { url: s.nextWrapperURL, previousUrl: r, wrapperSequence: c, wrapperDepth: t, followAdditionalWrappers: s.followAdditionalWrappers, allowMultipleAds: n }).then((d) => {
670
+ if (delete s.nextWrapperURL, d.length === 0) return s.creatives = [], i(s);
671
+ d.forEach((g) => {
672
+ g && l.mergeWrapperAdData(g, s);
673
+ }), i(d);
674
+ })).catch((u) => {
675
+ s.errorCode = u.message === P ? 102 : 301, s.errorMessage = u.message, i(s);
676
+ });
677
+ });
678
+ }
679
+ completeWrapperResolving(e) {
680
+ if (e.ads.length === 0) this.trackVastError(e.errorURLTemplates, { ERRORCODE: 303 });
681
+ else for (let t = e.ads.length - 1; t >= 0; t--) {
682
+ const r = e.ads[t], s = !r.creatives.some((i) => {
683
+ var o, n;
684
+ return ((o = i.mediaFiles) === null || o === void 0 ? void 0 : o.length) > 0 || ((n = i.variations) === null || n === void 0 ? void 0 : n.length) > 0;
685
+ });
686
+ !r.errorCode && !s || r.VASTAdTagURI || (this.trackVastError(r.errorURLTemplates.concat(e.errorURLTemplates), { ERRORCODE: r.errorCode || 303 }, { ERRORMESSAGE: r.errorMessage || "" }, { extensions: r.extensions }, { system: r.system }), this.keepFailedAdPod && r.sequence ? r.hasFailed = !0 : e.ads.splice(t, 1));
687
+ }
688
+ }
689
+ }
690
+ let f = null;
691
+ const ie = { data: {}, length: 0, getItem(a) {
692
+ return this.data[a];
693
+ }, setItem(a, e) {
694
+ this.data[a] = e, this.length = Object.keys(this.data).length;
695
+ }, removeItem(a) {
696
+ delete this.data[a], this.length = Object.keys(this.data).length;
697
+ }, clear() {
698
+ this.data = {}, this.length = 0;
699
+ } };
700
+ class ne {
701
+ constructor() {
702
+ this.storage = this.initStorage();
703
+ }
704
+ initStorage() {
705
+ if (f) return f;
706
+ try {
707
+ f = typeof window < "u" && window !== null ? window.localStorage || window.sessionStorage : null;
708
+ } catch {
709
+ f = null;
710
+ }
711
+ return f && !this.isStorageDisabled(f) || (f = ie, f.clear()), f;
712
+ }
713
+ isStorageDisabled(e) {
714
+ const t = "__VASTStorage__";
715
+ try {
716
+ if (e.setItem(t, t), e.getItem(t) !== t) return e.removeItem(t), !0;
717
+ } catch {
718
+ return !0;
719
+ }
720
+ return e.removeItem(t), !1;
721
+ }
722
+ getItem(e) {
723
+ return this.storage.getItem(e);
724
+ }
725
+ setItem(e, t) {
726
+ return this.storage.setItem(e, t);
727
+ }
728
+ removeItem(e) {
729
+ return this.storage.removeItem(e);
730
+ }
731
+ clear() {
732
+ return this.storage.clear();
733
+ }
734
+ }
735
+ const b = 12e4, oe = { get: async function(a, e) {
736
+ try {
737
+ const t = new AbortController(), r = setTimeout(() => {
738
+ throw t.abort(), new Error("URLHandler: Request timed out after ".concat(e.timeout || b, " ms (408)"));
739
+ }, e.timeout || b), s = await fetch(a, { ...e, signal: t.signal, credentials: e.withCredentials ? "include" : "omit" }).finally(() => {
740
+ clearTimeout(r);
741
+ }), i = function(o) {
742
+ return T.isBrowserEnvironment() && window.location.protocol === "https:" && o.url.includes("http://") ? "URLHandler: Cannot go from HTTPS to HTTP." : o.status === 200 && o.ok ? null : "URLHandler: ".concat(o.statusText, " (").concat(o.status, ")");
743
+ }(s);
744
+ return i ? { error: new Error(i), statusCode: s.status } : async function(o) {
745
+ const n = await o.text();
746
+ let c;
747
+ return c = T.isBrowserEnvironment() ? new DOMParser() : new (await import("./index-l-eyvmpL.js").then((u) => u.i)).DOMParser(), { xml: c.parseFromString(n, "text/xml"), details: { byteLength: n.length, statusCode: o.status, rawXml: n } };
748
+ }(s);
749
+ } catch (t) {
750
+ return { error: t, statusCode: t.name === "AbortError" ? 408 : null };
751
+ }
752
+ } };
753
+ class le {
754
+ constructor() {
755
+ this.URLTemplateFilters = [];
756
+ }
757
+ setOptions() {
758
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
759
+ this.urlHandler = e.urlHandler || e.urlhandler || oe, this.fetchingOptions = { ...e.fetchOptions, timeout: e.timeout || b, withCredentials: !!e.withCredentials };
760
+ }
761
+ addURLTemplateFilter(e) {
762
+ typeof e == "function" && this.URLTemplateFilters.push(e);
763
+ }
764
+ removeLastURLTemplateFilter() {
765
+ this.URLTemplateFilters.pop();
766
+ }
767
+ countURLTemplateFilters() {
768
+ return this.URLTemplateFilters.length;
769
+ }
770
+ clearURLTemplateFilters() {
771
+ this.URLTemplateFilters = [];
772
+ }
773
+ async fetchVAST(e) {
774
+ var t;
775
+ let { url: r, maxWrapperDepth: s, emitter: i, wrapperDepth: o = 0, previousUrl: n = null, wrapperAd: c = null } = e;
776
+ const u = Date.now();
777
+ this.URLTemplateFilters.forEach((m) => {
778
+ r = m(r);
779
+ }), i("VAST-resolving", { url: r, previousUrl: n, wrapperDepth: o, maxWrapperDepth: s, timeout: this.fetchingOptions.timeout, wrapperAd: c });
780
+ const d = await this.urlHandler.get(r, this.fetchingOptions), g = Math.round(Date.now() - u);
781
+ if (i("VAST-resolved", { url: r, previousUrl: n, wrapperDepth: o, error: (d == null ? void 0 : d.error) || null, duration: g, statusCode: (d == null ? void 0 : d.statusCode) || null, ...d == null ? void 0 : d.details }), z(d == null || (t = d.details) === null || t === void 0 ? void 0 : t.byteLength, g), d.error) throw new Error(d.error);
782
+ return d.xml;
783
+ }
784
+ }
785
+ class ce {
786
+ constructor() {
787
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, r = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : new ne();
788
+ this.cappingFreeLunch = e, this.cappingMinimumTimeInterval = t, this.fetcher = new le(), this.vastParser = new se({ fetcher: this.fetcher }), this.storage = r, this.lastSuccessfulAd === void 0 && (this.lastSuccessfulAd = 0), this.totalCalls === void 0 && (this.totalCalls = 0), this.totalCallsTimeout === void 0 && (this.totalCallsTimeout = 0);
789
+ }
790
+ addURLTemplateFilter(e) {
791
+ this.fetcher.addURLTemplateFilter(e);
792
+ }
793
+ removeLastURLTemplateFilter() {
794
+ this.fetcher.removeLastURLTemplateFilter();
795
+ }
796
+ countURLTemplateFilters() {
797
+ return this.fetcher.countURLTemplateFilters();
798
+ }
799
+ clearURLTemplateFilters() {
800
+ this.fetcher.clearURLTemplateFilters();
801
+ }
802
+ getParser() {
803
+ return this.vastParser;
804
+ }
805
+ get lastSuccessfulAd() {
806
+ return this.storage.getItem("vast-client-last-successful-ad");
807
+ }
808
+ set lastSuccessfulAd(e) {
809
+ this.storage.setItem("vast-client-last-successful-ad", e);
810
+ }
811
+ get totalCalls() {
812
+ return this.storage.getItem("vast-client-total-calls");
813
+ }
814
+ set totalCalls(e) {
815
+ this.storage.setItem("vast-client-total-calls", e);
816
+ }
817
+ get totalCallsTimeout() {
818
+ return this.storage.getItem("vast-client-total-calls-timeout");
819
+ }
820
+ set totalCallsTimeout(e) {
821
+ this.storage.setItem("vast-client-total-calls-timeout", e);
822
+ }
823
+ hasRemainingAds() {
824
+ return this.vastParser.remainingAds.length > 0;
825
+ }
826
+ getNextAds(e) {
827
+ return this.vastParser.getRemainingAds(e);
828
+ }
829
+ parseVAST(e) {
830
+ let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
831
+ return this.fetcher.setOptions(t), this.vastParser.parseVAST(e, t);
832
+ }
833
+ get(e) {
834
+ let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
835
+ const r = Date.now();
836
+ return t.hasOwnProperty("resolveAll") || (t.resolveAll = !1), this.totalCallsTimeout < r ? (this.totalCalls = 1, this.totalCallsTimeout = r + 36e5) : this.totalCalls++, new Promise((s, i) => {
837
+ if (this.cappingFreeLunch >= this.totalCalls) return i(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(this.totalCalls, "/").concat(this.cappingFreeLunch)));
838
+ const o = r - this.lastSuccessfulAd;
839
+ if (o < 0) this.lastSuccessfulAd = 0;
840
+ else if (o < this.cappingMinimumTimeInterval) return i(new Error("VAST call canceled – (".concat(this.cappingMinimumTimeInterval, ")ms minimum interval reached")));
841
+ this.vastParser.initParsingStatus(t), this.fetcher.setOptions(t), this.vastParser.rootURL = e, this.fetcher.fetchVAST({ url: e, emitter: this.vastParser.emit.bind(this.vastParser), maxWrapperDepth: this.vastParser.maxWrapperDepth }).then((n) => (t.previousUrl = e, t.isRootVAST = !0, t.url = e, this.vastParser.parse(n, t).then((c) => {
842
+ const u = this.vastParser.buildVASTResponse(c);
843
+ s(u);
844
+ }))).catch((n) => i(n));
845
+ });
846
+ }
847
+ }
848
+ class ue extends _ {
849
+ constructor(e, t, r) {
850
+ var s;
851
+ let i = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null, o = arguments.length > 4 && arguments[4] !== void 0 && arguments[4];
852
+ super(), this.ad = t, this.creative = r, this.variation = i, this.muted = o, this.impressed = !1, this.skippable = !1, this.trackingEvents = {}, this.trackedProgressEvents = [], this.lastPercentage = 0, this._alreadyTriggeredQuartiles = {}, this.emitAlwaysEvents = ["creativeView", "start", "firstQuartile", "midpoint", "thirdQuartile", "complete", "resume", "pause", "rewind", "skip", "closeLinear", "close"];
853
+ for (const n in this.creative.trackingEvents) {
854
+ const c = this.creative.trackingEvents[n];
855
+ this.trackingEvents[n] = c.slice(0);
856
+ }
857
+ this.viewableImpressionTrackers = ((s = this.ad.viewableImpression) === null || s === void 0 ? void 0 : s.reduce((n, c) => (n.notViewable.push(...c.notViewable), n.viewUndetermined.push(...c.viewUndetermined), n.viewable.push(...c.viewable), n), { notViewable: [], viewUndetermined: [], viewable: [] })) || {}, Object.entries(this.viewableImpressionTrackers).forEach((n) => {
858
+ let [c, u] = n;
859
+ u.length && (this.trackingEvents[c] = u);
860
+ }), function(n) {
861
+ return n.type === "linear";
862
+ }(this.creative) ? this._initLinearTracking() : this._initVariationTracking(), e && this.on("start", () => {
863
+ e.lastSuccessfulAd = Date.now();
864
+ });
865
+ }
866
+ _initLinearTracking() {
867
+ this.linear = !0, this.skipDelay = this.creative.skipDelay, this.setDuration(this.creative.duration), this.clickThroughURLTemplate = this.creative.videoClickThroughURLTemplate, this.clickTrackingURLTemplates = this.creative.videoClickTrackingURLTemplates;
868
+ }
869
+ _initVariationTracking() {
870
+ if (this.linear = !1, this.skipDelay = -1, this.variation) {
871
+ for (const e in this.variation.trackingEvents) {
872
+ const t = this.variation.trackingEvents[e];
873
+ this.trackingEvents[e] ? this.trackingEvents[e] = this.trackingEvents[e].concat(t.slice(0)) : this.trackingEvents[e] = t.slice(0);
874
+ }
875
+ this.variation.adType === "nonLinearAd" ? (this.clickThroughURLTemplate = this.variation.nonlinearClickThroughURLTemplate, this.clickTrackingURLTemplates = this.variation.nonlinearClickTrackingURLTemplates, this.setDuration(this.variation.minSuggestedDuration)) : function(e) {
876
+ return e.adType === "companionAd";
877
+ }(this.variation) && (this.clickThroughURLTemplate = this.variation.companionClickThroughURLTemplate, this.clickTrackingURLTemplates = this.variation.companionClickTrackingURLTemplates);
878
+ }
879
+ }
880
+ setDuration(e) {
881
+ T.isValidTimeValue(e) ? (this.assetDuration = e, this.quartiles = { firstQuartile: Math.round(25 * this.assetDuration) / 100, midpoint: Math.round(50 * this.assetDuration) / 100, thirdQuartile: Math.round(75 * this.assetDuration) / 100 }) : this.emit("TRACKER-error", { message: "the duration provided is not valid. duration: ".concat(e) });
882
+ }
883
+ setProgress(e) {
884
+ let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r = !(arguments.length > 2 && arguments[2] !== void 0) || arguments[2];
885
+ if (!T.isValidTimeValue(e) || typeof t != "object") return void this.emit("TRACKER-error", { message: "One given setProgress parameter has the wrong type. progress: ".concat(e, ", macros: ").concat(T.formatMacrosValues(t)) });
886
+ const s = this.skipDelay || -1;
887
+ if (s === -1 || this.skippable || (s > e ? this.emit("skip-countdown", s - e) : (this.skippable = !0, this.emit("skip-countdown", 0))), this.assetDuration > 0) {
888
+ const i = Math.round(e / this.assetDuration * 100), o = [];
889
+ if (e > 0) {
890
+ o.push("start");
891
+ for (let n = this.lastPercentage; n < i; n++) o.push("progress-".concat(n + 1, "%"));
892
+ o.push("progress-".concat(e));
893
+ for (const n in this.quartiles) this.isQuartileReached(n, this.quartiles[n], e) && (o.push(n), this._alreadyTriggeredQuartiles[n] = !0);
894
+ this.lastPercentage = i;
895
+ }
896
+ o.forEach((n) => {
897
+ this.track(n, { macros: t, once: r });
898
+ }), e < this.progress && (this.track("rewind", { macros: t }), this.trackedProgressEvents && this.trackedProgressEvents.splice(0));
899
+ }
900
+ this.progress = e;
901
+ }
902
+ isQuartileReached(e, t, r) {
903
+ let s = !1;
904
+ return t <= r && !this._alreadyTriggeredQuartiles[e] && (s = !0), s;
905
+ }
906
+ setMuted(e) {
907
+ let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
908
+ typeof e == "boolean" && typeof t == "object" ? (this.muted !== e && this.track(e ? "mute" : "unmute", { macros: t }), this.muted = e) : this.emit("TRACKER-error", { message: "One given setMuted parameter has the wrong type. muted: ".concat(e, ", macros: ").concat(T.formatMacrosValues(t)) });
909
+ }
910
+ setPaused(e) {
911
+ let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
912
+ typeof e == "boolean" && typeof t == "object" ? (this.paused !== e && this.track(e ? "pause" : "resume", { macros: t }), this.paused = e) : this.emit("TRACKER-error", { message: "One given setPaused parameter has the wrong type. paused: ".concat(e, ", macros: ").concat(T.formatMacrosValues(t)) });
913
+ }
914
+ setFullscreen(e) {
915
+ let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
916
+ typeof e == "boolean" && typeof t == "object" ? (this.fullscreen !== e && this.track(e ? "fullscreen" : "exitFullscreen", { macros: t }), this.fullscreen = e) : this.emit("TRACKER-error", { message: "One given setFullScreen parameter has the wrong type. fullscreen: ".concat(e, ", macros: ").concat(T.formatMacrosValues(t)) });
917
+ }
918
+ setExpand(e) {
919
+ let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
920
+ typeof e == "boolean" && typeof t == "object" ? (this.expanded !== e && (this.track(e ? "expand" : "collapse", { macros: t }), this.track(e ? "playerExpand" : "playerCollapse", { macros: t })), this.expanded = e) : this.emit("TRACKER-error", { message: "One given setExpand parameter has the wrong type. expanded: ".concat(e, ", macros: ").concat(T.formatMacrosValues(t)) });
921
+ }
922
+ setSkipDelay(e) {
923
+ T.isValidTimeValue(e) ? this.skipDelay = e : this.emit("TRACKER-error", { message: "setSkipDelay parameter does not have a valid value. duration: ".concat(e) });
924
+ }
925
+ trackImpression() {
926
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
927
+ typeof e == "object" ? this.impressed || (this.impressed = !0, this.trackURLs(this.ad.impressionURLTemplates, e), this.track("creativeView", { macros: e })) : this.emit("TRACKER-error", { message: "trackImpression parameter has the wrong type. macros: ".concat(e) });
928
+ }
929
+ trackViewableImpression() {
930
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 && arguments[1] !== void 0 && arguments[1];
931
+ typeof e == "object" ? this.track("viewable", { macros: e, once: t }) : this.emit("TRACKER-error", { message: "trackViewableImpression given macros has the wrong type. macros: ".concat(e) });
932
+ }
933
+ trackNotViewableImpression() {
934
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 && arguments[1] !== void 0 && arguments[1];
935
+ typeof e == "object" ? this.track("notViewable", { macros: e, once: t }) : this.emit("TRACKER-error", { message: "trackNotViewableImpression given macros has the wrong type. macros: ".concat(e) });
936
+ }
937
+ trackUndeterminedImpression() {
938
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 && arguments[1] !== void 0 && arguments[1];
939
+ typeof e == "object" ? this.track("viewUndetermined", { macros: e, once: t }) : this.emit("TRACKER-error", { message: "trackUndeterminedImpression given macros has the wrong type. macros: ".concat(e) });
940
+ }
941
+ error() {
942
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 && arguments[1] !== void 0 && arguments[1];
943
+ typeof e == "object" && typeof t == "boolean" ? this.trackURLs(this.ad.errorURLTemplates, e, { isCustomCode: t }) : this.emit("TRACKER-error", { message: "One given error parameter has the wrong type. macros: ".concat(T.formatMacrosValues(e), ", isCustomCode: ").concat(t) });
944
+ }
945
+ errorWithCode(e) {
946
+ let t = arguments.length > 1 && arguments[1] !== void 0 && arguments[1];
947
+ typeof e == "string" && typeof t == "boolean" ? (this.error({ ERRORCODE: e }, t), console.log("The method errorWithCode is deprecated, please use vast tracker error method instead")) : this.emit("TRACKER-error", { message: "One given errorWithCode parameter has the wrong type. errorCode: ".concat(e, ", isCustomCode: ").concat(t) });
948
+ }
949
+ complete() {
950
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
951
+ typeof e == "object" ? this.track("complete", { macros: e }) : this.emit("TRACKER-error", { message: "complete given macros has the wrong type. macros: ".concat(e) });
952
+ }
953
+ notUsed() {
954
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
955
+ typeof e == "object" ? (this.track("notUsed", { macros: e }), this.trackingEvents = []) : this.emit("TRACKER-error", { message: "notUsed given macros has the wrong type. macros: ".concat(e) });
956
+ }
957
+ otherAdInteraction() {
958
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
959
+ typeof e == "object" ? this.track("otherAdInteraction", { macros: e }) : this.emit("TRACKER-error", { message: "otherAdInteraction given macros has the wrong type. macros: ".concat(e) });
960
+ }
961
+ acceptInvitation() {
962
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
963
+ typeof e == "object" ? this.track("acceptInvitation", { macros: e }) : this.emit("TRACKER-error", { message: "acceptInvitation given macros has the wrong type. macros: ".concat(e) });
964
+ }
965
+ adExpand() {
966
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
967
+ typeof e == "object" ? this.track("adExpand", { macros: e }) : this.emit("TRACKER-error", { message: "adExpand given macros has the wrong type. macros: ".concat(e) });
968
+ }
969
+ adCollapse() {
970
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
971
+ typeof e == "object" ? this.track("adCollapse", { macros: e }) : this.emit("TRACKER-error", { message: "adCollapse given macros has the wrong type. macros: ".concat(e) });
972
+ }
973
+ minimize() {
974
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
975
+ typeof e == "object" ? this.track("minimize", { macros: e }) : this.emit("TRACKER-error", { message: "minimize given macros has the wrong type. macros: ".concat(e) });
976
+ }
977
+ verificationNotExecuted(e) {
978
+ let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
979
+ if (typeof e != "string" || typeof t != "object") return void this.emit("TRACKER-error", { message: "One given verificationNotExecuted parameter has to wrong type. vendor: ".concat(e, ", macros: ").concat(T.formatMacrosValues(t)) });
980
+ if (!this.ad || !this.ad.adVerifications || !this.ad.adVerifications.length) throw new Error("No adVerifications provided");
981
+ if (!e) throw new Error("No vendor provided, unable to find associated verificationNotExecuted");
982
+ const r = this.ad.adVerifications.find((i) => i.vendor === e);
983
+ if (!r) throw new Error("No associated verification element found for vendor: ".concat(e));
984
+ const s = r.trackingEvents;
985
+ if (s && s.verificationNotExecuted) {
986
+ const i = s.verificationNotExecuted;
987
+ this.trackURLs(i, t), this.emit("verificationNotExecuted", { trackingURLTemplates: i });
988
+ }
989
+ }
990
+ overlayViewDuration(e) {
991
+ let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
992
+ typeof e == "string" && typeof t == "object" ? (t.ADPLAYHEAD = e, this.track("overlayViewDuration", { macros: t })) : this.emit("TRACKER-error", { message: "One given overlayViewDuration parameters has the wrong type. formattedDuration: ".concat(e, ", macros: ").concat(T.formatMacrosValues(t)) });
993
+ }
994
+ close() {
995
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
996
+ typeof e == "object" ? this.track(this.linear ? "closeLinear" : "close", { macros: e }) : this.emit("TRACKER-error", { message: "close given macros has the wrong type. macros: ".concat(e) });
997
+ }
998
+ skip() {
999
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1000
+ typeof e == "object" ? this.track("skip", { macros: e }) : this.emit("TRACKER-error", { message: "skip given macros has the wrong type. macros: ".concat(e) });
1001
+ }
1002
+ load() {
1003
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
1004
+ typeof e == "object" ? this.track("loaded", { macros: e }) : this.emit("TRACKER-error", { message: "load given macros has the wrong type. macros: ".concat(e) });
1005
+ }
1006
+ click() {
1007
+ let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : null, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1008
+ if (e !== null && typeof e != "string" || typeof t != "object") return void this.emit("TRACKER-error", { message: "One given click parameter has the wrong type. fallbackClickThroughURL: ".concat(e, ", macros: ").concat(T.formatMacrosValues(t)) });
1009
+ this.clickTrackingURLTemplates && this.clickTrackingURLTemplates.length && this.trackURLs(this.clickTrackingURLTemplates, t);
1010
+ const r = this.clickThroughURLTemplate || e, s = { ...t };
1011
+ if (r) {
1012
+ this.progress && (s.ADPLAYHEAD = this.progressFormatted());
1013
+ const i = T.resolveURLTemplates([r], s)[0];
1014
+ this.emit("clickthrough", i);
1015
+ }
1016
+ }
1017
+ trackProgressEvents(e, t, r) {
1018
+ const s = parseFloat(e.split("-")[1]);
1019
+ Object.entries(this.trackingEvents).filter((i) => {
1020
+ let [o] = i;
1021
+ return o.startsWith("progress-");
1022
+ }).map((i) => {
1023
+ let [o, n] = i;
1024
+ return { name: o, time: parseFloat(o.split("-")[1]), urls: n };
1025
+ }).filter((i) => {
1026
+ let { time: o } = i;
1027
+ return o <= s && o > this.progress;
1028
+ }).forEach((i) => {
1029
+ let { name: o, urls: n } = i;
1030
+ !r && this.trackedProgressEvents.includes(o) || (this.emit(o, { trackingURLTemplates: n }), this.trackURLs(n, t), r ? delete this.trackingEvents[o] : this.trackedProgressEvents.push(o));
1031
+ });
1032
+ }
1033
+ track(e) {
1034
+ let { macros: t = {}, once: r = !1 } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
1035
+ if (typeof t != "object") return void this.emit("TRACKER-error", { message: "track given macros has the wrong type. macros: ".concat(t) });
1036
+ e === "closeLinear" && !this.trackingEvents[e] && this.trackingEvents.close && (e = "close"), e.startsWith("progress-") && !e.endsWith("%") && this.trackProgressEvents(e, t, r);
1037
+ const s = this.trackingEvents[e], i = this.emitAlwaysEvents.indexOf(e) > -1;
1038
+ s ? (this.emit(e, { trackingURLTemplates: s }), this.trackURLs(s, t)) : i && this.emit(e, null), r && (delete this.trackingEvents[e], i && this.emitAlwaysEvents.splice(this.emitAlwaysEvents.indexOf(e), 1));
1039
+ }
1040
+ trackURLs(e) {
1041
+ var t;
1042
+ let r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, s = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
1043
+ const { validUrls: i, invalidUrls: o } = T.filterUrlTemplates(e);
1044
+ o.length && this.emit("TRACKER-error", { message: "Provided urls are malformed. url: ".concat(o) });
1045
+ const n = { ...r };
1046
+ this.linear && (this.creative && this.creative.mediaFiles && this.creative.mediaFiles[0] && this.creative.mediaFiles[0].fileURL && (n.ASSETURI = this.creative.mediaFiles[0].fileURL), this.progress && (n.ADPLAYHEAD = this.progressFormatted())), (t = this.creative) !== null && t !== void 0 && (t = t.universalAdIds) !== null && t !== void 0 && t.length && (n.UNIVERSALADID = this.creative.universalAdIds.map((c) => c.idRegistry.concat(" ", c.value)).join(",")), this.ad && (this.ad.sequence && (n.PODSEQUENCE = this.ad.sequence), this.ad.adType && (n.ADTYPE = this.ad.adType), this.ad.adServingId && (n.ADSERVINGID = this.ad.adServingId), this.ad.categories && this.ad.categories.length && (n.ADCATEGORIES = this.ad.categories.map((c) => c.value).join(",")), this.ad.blockedAdCategories && this.ad.blockedAdCategories.length && (n.BLOCKEDADCATEGORIES = this.ad.blockedAdCategories.map((c) => c.value).join(","))), T.track(i, n, s);
1047
+ }
1048
+ convertToTimecode(e) {
1049
+ if (!T.isValidTimeValue(e)) return "";
1050
+ const t = 1e3 * e, r = Math.floor(t / 36e5), s = Math.floor(t / 6e4 % 60), i = Math.floor(t / 1e3 % 60), o = Math.floor(t % 1e3);
1051
+ return "".concat(T.addLeadingZeros(r, 2), ":").concat(T.addLeadingZeros(s, 2), ":").concat(T.addLeadingZeros(i, 2), ".").concat(T.addLeadingZeros(o, 3));
1052
+ }
1053
+ progressFormatted() {
1054
+ return this.convertToTimecode(this.progress);
1055
+ }
1056
+ }
1057
+ export {
1058
+ ce as c,
1059
+ ue as u
1060
+ };