@streamlayer/react-ui 1.32.3 → 1.33.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/lib/app/app/Advertisement/index.d.ts +1 -1
  2. package/lib/app/app/Advertisement/index.js +14 -15
  3. package/lib/app/app/Banner/index.d.ts +1 -1
  4. package/lib/app/app/Features/FeatureProvider.d.ts +2 -2
  5. package/lib/app/app/Features/Gamification/Leaderboard.d.ts +1 -1
  6. package/lib/app/app/Features/Gamification/Leaderboard.js +46 -36
  7. package/lib/app/app/Features/Gamification/Question.d.ts +2 -2
  8. package/lib/app/app/Features/Gamification/Question.js +42 -42
  9. package/lib/app/app/Features/Gamification/QuestionAdvertisement.js +19 -25
  10. package/lib/app/app/Features/Gamification/QuestionsList.d.ts +1 -1
  11. package/lib/app/app/Features/Gamification/Tabs.d.ts +1 -1
  12. package/lib/app/app/Features/Gamification/UserSummary.d.ts +1 -1
  13. package/lib/app/app/Features/Gamification/index.d.ts +2 -2
  14. package/lib/app/app/Features/Gamification/index.js +29 -28
  15. package/lib/app/app/Features/index.d.ts +2 -2
  16. package/lib/app/app/InApp/index.d.ts +1 -1
  17. package/lib/app/app/Insight/index.d.ts +2 -2
  18. package/lib/app/app/Layout/index.d.ts +1 -1
  19. package/lib/app/app/Navigation/index.d.ts +1 -1
  20. package/lib/app/app/Notifications/Onboarding/Notification/index.d.ts +2 -2
  21. package/lib/app/app/Notifications/Onboarding/index.d.ts +2 -2
  22. package/lib/app/app/Notifications/Onboarding/index.js +45 -42
  23. package/lib/app/app/Notifications/index.d.ts +1 -1
  24. package/lib/app/app/Points/index.d.ts +1 -1
  25. package/lib/app/app/index.d.ts +1 -1
  26. package/lib/app/app/story/index.js +24 -24
  27. package/lib/app/app/story/insight/index.js +14 -15
  28. package/lib/app/app/story/insight/video.js +3 -3
  29. package/lib/app/app/story/promotion/content.js +5 -5
  30. package/lib/app/app/story/promotion/index.d.ts +1 -0
  31. package/lib/app/app/story/promotion/index.js +24 -25
  32. package/lib/app/app/story/promotion/video.d.ts +0 -1
  33. package/lib/app/app/story/promotion/video.js +41 -43
  34. package/lib/app/app/story/promotion-notification/index.js +15 -16
  35. package/lib/app/app/story/promotion-notification/video.d.ts +0 -1
  36. package/lib/app/app/story/promotion-notification/video.js +22 -30
  37. package/lib/app/app/story/settings/index.js +6 -6
  38. package/lib/app/app/story/settings/login.js +1 -1
  39. package/lib/app/app/story/video.js +28 -28
  40. package/lib/app/app/useApp.d.ts +1 -1
  41. package/lib/app/app/useAppContext.d.ts +1 -1
  42. package/lib/app/login/demo.js +19 -18
  43. package/lib/app/masters/BetPack/BetPackContent/EndScreen/index.d.ts +0 -1
  44. package/lib/app/masters/BetPack/BetPackContent/EndScreen/index.js +17 -17
  45. package/lib/app/masters/BetPack/BetPackContent/QuestionScreen/index.d.ts +2 -2
  46. package/lib/app/masters/BetPack/BetPackContent/index.d.ts +1 -1
  47. package/lib/app/masters/BetPack/BetPackOverlay/index.d.ts +1 -1
  48. package/lib/app/masters/BetPack/index.d.ts +1 -1
  49. package/lib/app/masters/Features/FeatureProvider.d.ts +2 -2
  50. package/lib/app/masters/Features/Gamification/Question.d.ts +1 -1
  51. package/lib/app/masters/Features/Gamification/QuestionsList.d.ts +1 -1
  52. package/lib/app/masters/Features/Gamification/Tabs.d.ts +1 -1
  53. package/lib/app/masters/Features/Gamification/UserSummary.d.ts +1 -1
  54. package/lib/app/masters/Features/Gamification/index.d.ts +1 -1
  55. package/lib/app/masters/Features/index.d.ts +2 -2
  56. package/lib/app/masters/Notifications/Onboarding/Notification/index.d.ts +2 -2
  57. package/lib/app/masters/Notifications/Onboarding/index.d.ts +2 -2
  58. package/lib/app/masters/Notifications/Onboarding/index.js +42 -39
  59. package/lib/app/masters/Notifications/index.d.ts +1 -1
  60. package/lib/app/masters/Points/index.d.ts +1 -1
  61. package/lib/app/masters/masters.d.ts +2 -1
  62. package/lib/app/masters/masters.js +34 -32
  63. package/lib/app/masters/provider.d.ts +4 -0
  64. package/lib/app/masters/provider.js +23 -0
  65. package/lib/app/masters/story/components.js +48 -52
  66. package/lib/app/masters/story/index.js +16 -15
  67. package/lib/app/masters/useMastersApp.d.ts +1 -1
  68. package/lib/app/masters/useMastersContext.d.ts +1 -1
  69. package/lib/app/tgl/index.d.ts +1 -0
  70. package/lib/app/tgl/index.js +19 -20
  71. package/lib/app/tgl/video.d.ts +0 -1
  72. package/lib/app/tgl/video.js +40 -42
  73. package/lib/app/useSdkFeature.d.ts +3 -3
  74. package/lib/app/webos/Advertisement/AdvertisementUI.d.ts +1 -1
  75. package/lib/app/webos/Advertisement/index.d.ts +1 -1
  76. package/lib/app/webos/ExposedPauseAd/PauseAd.d.ts +1 -1
  77. package/lib/app/webos/ExposedPauseAd/PauseAd.js +68 -68
  78. package/lib/app/webos/Question/index.d.ts +1 -1
  79. package/lib/app/webos/index.d.ts +1 -1
  80. package/lib/app/webos/story.js +26 -26
  81. package/lib/app/webos/ui/Sidebar/PromoAction.d.ts +1 -1
  82. package/lib/app/webos/ui/Sidebar/index.d.ts +2 -2
  83. package/lib/app/webos/ui/Sidebar/styles.js +82 -888
  84. package/lib/app/webos/ui/insight/index.d.ts +1 -1
  85. package/lib/assets/style.css +1 -1
  86. package/lib/core/app.d.ts +7 -0
  87. package/lib/core/app.js +14 -0
  88. package/lib/core/event.d.ts +6 -0
  89. package/lib/core/event.js +5 -0
  90. package/lib/core/hooks.d.ts +16 -0
  91. package/lib/core/hooks.js +8 -0
  92. package/lib/core/provider.d.ts +49 -0
  93. package/lib/core/provider.js +9 -0
  94. package/lib/hooks/analytics.d.ts +1 -1
  95. package/lib/hooks-B0Qttldg.js +99 -0
  96. package/lib/index.d.ts +0 -1
  97. package/lib/index.js +2 -4
  98. package/lib/ui/advertisement/banner/index.d.ts +3 -3
  99. package/lib/ui/advertisement/index.d.ts +1 -1
  100. package/lib/ui/advertisement/mock.d.ts +1 -1
  101. package/lib/ui/advertisement/notification/index.d.ts +1 -1
  102. package/lib/ui/advertisement/notification/lower-third/index.d.ts +1 -1
  103. package/lib/ui/advertisement/notification/lower-third/index.js +34 -30
  104. package/lib/ui/advertisement/overlay/externalAd/vast-player/useGAMPlayer.js +100 -33212
  105. package/lib/ui/advertisement/overlay/externalAd/vast-player/useGAMStatic.js +13 -13
  106. package/lib/ui/advertisement/overlay/externalAd/vast-player/useVastAds.d.ts +1 -1
  107. package/lib/ui/advertisement/overlay/externalAd/vast-player/useVastAds.js +63 -204
  108. package/lib/ui/advertisement/overlay/index.d.ts +2 -2
  109. package/lib/ui/close-btn/index.d.ts +1 -1
  110. package/lib/ui/gamification/constants.d.ts +1 -1
  111. package/lib/ui/gamification/detail/header/index.d.ts +1 -1
  112. package/lib/ui/gamification/insight/index.d.ts +1 -1
  113. package/lib/ui/gamification/insight-list/index.d.ts +1 -1
  114. package/lib/ui/gamification/leaderboard/list-item/index.d.ts +1 -1
  115. package/lib/ui/gamification/leaderboard/static.d.ts +1 -1
  116. package/lib/ui/gamification/onboarding/index.d.ts +2 -2
  117. package/lib/ui/gamification/question/inapp/notification/AdNotification/NotificationMedia/index.d.ts +2 -2
  118. package/lib/ui/gamification/question/inapp/notification/AdNotification/NotificationMedia/index.js +1 -1
  119. package/lib/ui/gamification/question/inapp/notification/AdNotification/index.d.ts +1 -1
  120. package/lib/ui/gamification/question/inapp/notification/NotificationMedia/index.d.ts +1 -1
  121. package/lib/ui/gamification/question/inapp/notification/index.d.ts +1 -1
  122. package/lib/ui/gamification/question/inapp/onboarding/index.d.ts +1 -1
  123. package/lib/ui/gamification/question/inapp/prediction-result/frames/index.d.ts +1 -1
  124. package/lib/ui/gamification/question/inapp/prediction-result/index.d.ts +1 -1
  125. package/lib/ui/gamification/question/inapp/prediction-result-ad/frames/index.d.ts +1 -1
  126. package/lib/ui/gamification/question/inapp/prediction-result-ad/index.d.ts +1 -1
  127. package/lib/ui/gamification/question/index.d.ts +1 -1
  128. package/lib/ui/gamification/question/list/index.d.ts +1 -1
  129. package/lib/ui/gamification/question/notification/index.d.ts +1 -1
  130. package/lib/ui/gamification/question/notification/insight/index.d.ts +2 -2
  131. package/lib/ui/gamification/question/notification/prediction-result/index.d.ts +1 -1
  132. package/lib/ui/gamification/question/notification/tweet/index.d.ts +1 -1
  133. package/lib/ui/gamification/vote/feedback/index.d.ts +1 -1
  134. package/lib/ui/gamification/vote/index.d.ts +1 -1
  135. package/lib/ui/gamification/vote/vote-option/index.d.ts +1 -1
  136. package/lib/ui/gamification/vote/win-bar/index.d.ts +1 -1
  137. package/lib/ui/icons/index.d.ts +198 -66
  138. package/lib/ui/navigation/button/index.d.ts +1 -1
  139. package/lib/ui/questions/insight/index.d.ts +1 -1
  140. package/lib/ui/questions/twitter/index.d.ts +1 -1
  141. package/lib/ui/video-player/index.js +26 -23
  142. package/lib/useStreamLayerApp.d.ts +23 -0
  143. package/lib/useStreamLayerApp.js +167 -0
  144. package/lib/utils/debug/components/bypassLogin.d.ts +1 -1
  145. package/lib/utils/debug/components/developer.d.ts +1 -1
  146. package/lib/utils/debug/components/eventInput.d.ts +1 -1
  147. package/lib/utils/debug/index.js +8 -8
  148. package/lib/utils/debug/storage.d.ts +1 -1
  149. package/lib/utils/storage.d.ts +1 -1
  150. package/package.json +42 -35
  151. package/lib/index-l-eyvmpL.js +0 -3758
  152. package/lib/utils/createDemo.d.ts +0 -12
  153. package/lib/utils/createDemo.js +0 -49
  154. package/lib/vast-client.min-B0NUra1B.js +0 -1060
@@ -1,1060 +0,0 @@
1
- function N() {
2
- let i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
3
- return { id: i.id || null, adId: i.adId || null, sequence: i.sequence || null, apiFramework: i.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(i) {
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 = [], a = M(i);
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 s in e) e[s] = j(e[s]);
11
- for (const s in a) {
12
- const o = a[s];
13
- typeof o == "string" && r.push(B(o, e));
14
- }
15
- return r;
16
- }
17
- function B(i, e) {
18
- const t = (i = L(i, e)).match(/[^[\]]+(?=])/g);
19
- if (!t) return i;
20
- let r = t.filter((a) => G.indexOf(a) > -1);
21
- return r.length === 0 ? i : (r = r.reduce((a, s) => (a[s] = -1, a), {}), L(i, r));
22
- }
23
- function L(i, e) {
24
- let t = i;
25
- for (const r in e) {
26
- const a = e[r];
27
- t = t.replace(new RegExp("(?:\\[|%%)(".concat(r, ")(?:\\]|%%)"), "g"), a);
28
- }
29
- return t;
30
- }
31
- function M(i) {
32
- return Array.isArray(i) ? i.map((e) => e && e.hasOwnProperty("url") ? e.url : e) : i;
33
- }
34
- function C(i) {
35
- return /^(https?:\/\/|\/\/)/.test(i);
36
- }
37
- function U(i, e) {
38
- for (let t = 0; t < e.length; t++) if (W(e[t], i)) return !0;
39
- return !1;
40
- }
41
- function W(i, e) {
42
- if (i && e) {
43
- const t = Object.getOwnPropertyNames(i), r = Object.getOwnPropertyNames(e);
44
- return t.length === r.length && i.id === e.id && i.url === e.url;
45
- }
46
- return !1;
47
- }
48
- function j(i) {
49
- return encodeURIComponent(i).replace(/[!'()*]/g, (e) => "%".concat(e.charCodeAt(0).toString(16)));
50
- }
51
- function q(i) {
52
- let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 8;
53
- return i.toString().padStart(e, "0");
54
- }
55
- const f = { track: function(i, e, t) {
56
- w(i, e, t).forEach((r) => {
57
- typeof window < "u" && window !== null && (new Image().src = r);
58
- });
59
- }, resolveURLTemplates: w, extractURLsFromTemplates: M, filterUrlTemplates: function(i) {
60
- return i.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(i) {
65
- return !isNaN(parseFloat(i)) && isFinite(i);
66
- }, flatten: function i(e) {
67
- return e.reduce((t, r) => t.concat(Array.isArray(r) ? i(r) : r), []);
68
- }, joinArrayOfUniqueTemplateObjs: function() {
69
- let i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
70
- const t = Array.isArray(i) ? i : [], r = Array.isArray(e) ? e : [];
71
- return t.concat(r).reduce((a, s) => (U(s, a) || a.push(s), a), []);
72
- }, isValidTimeValue: function(i) {
73
- return Number.isFinite(i) && i >= -2;
74
- }, addLeadingZeros: q, isValidUrl: C, isBrowserEnvironment: function() {
75
- return typeof window < "u";
76
- }, formatMacrosValues: function(i) {
77
- return typeof i != "object" ? i : JSON.stringify(i);
78
- } };
79
- function I(i) {
80
- return ["true", "TRUE", "True", "1"].includes(i);
81
- }
82
- function Y(i) {
83
- if (i == null) return -1;
84
- if (f.isNumeric(i)) return parseInt(i);
85
- const e = i.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 a = parseInt(60 * e[1]), s = parseInt(60 * e[0] * 60);
91
- return isNaN(s) || isNaN(a) || isNaN(r) || a > 3600 || r > 60 ? -1 : s + a + r;
92
- }
93
- const l = { childByName: function(i, e) {
94
- return Array.from(i.childNodes).find((t) => t.nodeName === e);
95
- }, childrenByName: function(i, e) {
96
- return Array.from(i.childNodes).filter((t) => t.nodeName === e);
97
- }, resolveVastAdTagURI: function(i, e) {
98
- if (!e) return i;
99
- if (i.startsWith("//")) {
100
- const { protocol: t } = location;
101
- return "".concat(t).concat(i);
102
- }
103
- if (!i.includes("://")) {
104
- const t = e.slice(0, e.lastIndexOf("/"));
105
- return "".concat(t, "/").concat(i);
106
- }
107
- return i;
108
- }, parseBoolean: I, parseNodeText: function(i) {
109
- return i && (i.textContent || i.text || "").trim();
110
- }, copyNodeAttribute: function(i, e, t) {
111
- const r = e.getAttribute(i);
112
- r && t.setAttribute(i, r);
113
- }, parseAttributes: function(i) {
114
- return Array.from(i.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((i) => !parseInt(i.sequence, 10));
117
- }, getSortedAdPods: function() {
118
- return (arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []).filter((i) => parseInt(i.sequence, 10)).sort((i, e) => i.sequence - e.sequence);
119
- }, assignAttributes: function(i, e) {
120
- i && Array.from(i).forEach((t) => {
121
- let { nodeName: r, nodeValue: a } = t;
122
- if (r && a && e.hasOwnProperty(r)) {
123
- let s = a;
124
- typeof e[r] == "boolean" && (s = I(s)), e[r] = s;
125
- }
126
- });
127
- }, mergeWrapperAdData: function(i, e) {
128
- var t;
129
- i.errorURLTemplates = e.errorURLTemplates.concat(i.errorURLTemplates), i.impressionURLTemplates = e.impressionURLTemplates.concat(i.impressionURLTemplates), i.extensions = e.extensions.concat(i.extensions), e.viewableImpression.length > 0 && (i.viewableImpression = [...i.viewableImpression, ...e.viewableImpression]), i.followAdditionalWrappers = e.followAdditionalWrappers, i.allowMultipleAds = e.allowMultipleAds, i.fallbackOnNoAd = e.fallbackOnNoAd;
130
- const r = (e.creatives || []).filter((n) => n && n.type === "companion"), a = r.reduce((n, c) => ((c.variations || []).forEach((u) => {
131
- (u.companionClickTrackingURLTemplates || []).forEach((d) => {
132
- f.containsTemplateObject(d, n) || n.push(d);
133
- });
134
- }), n), []);
135
- i.creatives = r.concat(i.creatives);
136
- const s = e.videoClickTrackingURLTemplates && e.videoClickTrackingURLTemplates.length, o = e.videoCustomClickURLTemplates && e.videoCustomClickURLTemplates.length;
137
- if (i.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" && (s && (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" && a.length && (n.variations || []).forEach((c) => {
143
- c.companionClickTrackingURLTemplates = f.joinArrayOfUniqueTemplateObjs(c.companionClickTrackingURLTemplates, a);
144
- });
145
- }), e.adVerifications && (i.adVerifications = i.adVerifications.concat(e.adVerifications)), e.blockedAdCategories && (i.blockedAdCategories = i.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 && (i.creatives = i.creatives.concat(n));
151
- }
152
- } };
153
- function Q(i, e) {
154
- const t = function() {
155
- let r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
156
- const { id: a, adId: s, sequence: o, apiFramework: n } = N(r);
157
- return { id: a, adId: s, sequence: o, apiFramework: n, type: "companion", required: null, variations: [] };
158
- }(e);
159
- return t.required = i.getAttribute("required") || null, t.variations = l.childrenByName(i, "Companion").map((r) => {
160
- const a = 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
- a.htmlResources = l.childrenByName(r, "HTMLResource").reduce((n, c) => {
165
- const u = l.parseNodeText(c);
166
- return u ? n.concat(u) : n;
167
- }, []), a.iframeResources = l.childrenByName(r, "IFrameResource").reduce((n, c) => {
168
- const u = l.parseNodeText(c);
169
- return u ? n.concat(u) : n;
170
- }, []), a.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
- }, []), a.altText = l.parseNodeText(l.childByName(r, "AltText")) || null;
174
- const s = l.childByName(r, "TrackingEvents");
175
- s && l.childrenByName(s, "Tracking").forEach((n) => {
176
- const c = n.getAttribute("event"), u = l.parseNodeText(n);
177
- c && u && (Array.isArray(a.trackingEvents[c]) || (a.trackingEvents[c] = []), a.trackingEvents[c].push(u));
178
- }), a.companionClickTrackingURLTemplates = l.childrenByName(r, "CompanionClickTracking").map((n) => ({ id: n.getAttribute("id") || null, url: l.parseNodeText(n) })), a.companionClickThroughURLTemplate = l.parseNodeText(l.childByName(r, "CompanionClickThrough")) || null;
179
- const o = l.childByName(r, "AdParameters");
180
- return o && (a.adParameters = { value: l.parseNodeText(o), xmlEncoded: o.getAttribute("xmlEncoded") || null }), a;
181
- }), t;
182
- }
183
- function X(i, 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(i, "Duration")));
191
- const a = i.getAttribute("skipoffset");
192
- if (a == null) r.skipDelay = null;
193
- else if (a.charAt(a.length - 1) === "%" && r.duration !== -1) {
194
- const c = parseInt(a, 10);
195
- r.skipDelay = r.duration * (c / 100);
196
- } else r.skipDelay = l.parseDuration(a);
197
- const s = l.childByName(i, "VideoClicks");
198
- if (s) {
199
- const c = l.childByName(s, "ClickThrough");
200
- r.videoClickThroughURLTemplate = c ? { id: c.getAttribute("id") || null, url: l.parseNodeText(c) } : null, l.childrenByName(s, "ClickTracking").forEach((u) => {
201
- r.videoClickTrackingURLTemplates.push({ id: u.getAttribute("id") || null, url: l.parseNodeText(u) });
202
- }), l.childrenByName(s, "CustomClick").forEach((u) => {
203
- r.videoCustomClickURLTemplates.push({ id: u.getAttribute("id") || null, url: l.parseNodeText(u) });
204
- });
205
- }
206
- const o = l.childByName(i, "AdParameters");
207
- o && (r.adParameters = { value: l.parseNodeText(o), xmlEncoded: o.getAttribute("xmlEncoded") || null }), l.childrenByName(i, "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(i, "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(i, "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(i, e) {
288
- const t = function() {
289
- let r = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
290
- const { id: a, adId: s, sequence: o, apiFramework: n } = N(r);
291
- return { id: a, adId: s, sequence: o, apiFramework: n, type: "nonlinear", variations: [], trackingEvents: {} };
292
- }(e);
293
- return l.childrenByName(i, "TrackingEvents").forEach((r) => {
294
- let a, s;
295
- l.childrenByName(r, "Tracking").forEach((o) => {
296
- a = o.getAttribute("event"), s = l.parseNodeText(o), a && s && (Array.isArray(t.trackingEvents[a]) || (t.trackingEvents[a] = []), t.trackingEvents[a].push(s));
297
- });
298
- }), l.childrenByName(i, "NonLinear").forEach((r) => {
299
- const a = { 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
- a.id = r.getAttribute("id") || null, a.width = r.getAttribute("width"), a.height = r.getAttribute("height"), a.expandedWidth = r.getAttribute("expandedWidth"), a.expandedHeight = r.getAttribute("expandedHeight"), a.scalable = l.parseBoolean(r.getAttribute("scalable")), a.maintainAspectRatio = l.parseBoolean(r.getAttribute("maintainAspectRatio")), a.minSuggestedDuration = l.parseDuration(r.getAttribute("minSuggestedDuration")), a.apiFramework = r.getAttribute("apiFramework"), l.childrenByName(r, "HTMLResource").forEach((o) => {
301
- a.type = o.getAttribute("creativeType") || "text/html", a.htmlResource = l.parseNodeText(o);
302
- }), l.childrenByName(r, "IFrameResource").forEach((o) => {
303
- a.type = o.getAttribute("creativeType") || 0, a.iframeResource = l.parseNodeText(o);
304
- }), l.childrenByName(r, "StaticResource").forEach((o) => {
305
- a.type = o.getAttribute("creativeType") || 0, a.staticResource = l.parseNodeText(o);
306
- });
307
- const s = l.childByName(r, "AdParameters");
308
- s && (a.adParameters = { value: l.parseNodeText(s), xmlEncoded: s.getAttribute("xmlEncoded") || null }), a.nonlinearClickThroughURLTemplate = l.parseNodeText(l.childByName(r, "NonLinearClickThrough")), l.childrenByName(r, "NonLinearClickTracking").forEach((o) => {
309
- a.nonlinearClickTrackingURLTemplates.push({ id: o.getAttribute("id") || null, url: l.parseNodeText(o) });
310
- }), t.variations.push(a);
311
- }), t;
312
- }
313
- function x(i) {
314
- const e = [];
315
- return i.forEach((t) => {
316
- const r = K(t);
317
- r && e.push(r);
318
- }), e;
319
- }
320
- function K(i) {
321
- if (i.nodeName === "#comment") return null;
322
- const e = { name: null, value: null, attributes: {}, children: [] }, t = i.attributes, r = i.childNodes;
323
- if (e.name = i.nodeName, i.attributes) {
324
- for (const s in t) if (t.hasOwnProperty(s)) {
325
- const o = t[s];
326
- o.nodeName && o.nodeValue && (e.attributes[o.nodeName] = o.nodeValue);
327
- }
328
- }
329
- for (const s in r) if (r.hasOwnProperty(s)) {
330
- const o = K(r[s]);
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 s = l.parseNodeText(i);
335
- s !== "" && (e.value = s), e.children = [];
336
- }
337
- return (a = e).value === null && Object.keys(a.attributes).length === 0 && a.children.length === 0 ? null : e;
338
- var a;
339
- }
340
- function J(i) {
341
- return i.getAttribute("AdID") || i.getAttribute("adID") || i.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(i, e) {
345
- if (!y[i.nodeName] || !y[i.nodeName].attributes) return;
346
- const t = y[i.nodeName].attributes.filter((r) => !i.getAttribute(r));
347
- t.length > 0 && k({ name: i.nodeName, parentName: i.parentNode.nodeName, attributes: t }, e);
348
- }
349
- function V(i, e, t) {
350
- const r = y[i.nodeName], a = !t && i.nodeName !== "Wrapper";
351
- if (!(!r || a)) {
352
- if (r.subElements) {
353
- const s = r.subElements.filter((o) => !l.childByName(i, o));
354
- s.length > 0 && k({ name: i.nodeName, parentName: i.parentNode.nodeName, subElements: s }, e);
355
- }
356
- !t || !r.oneOfinLineResources || r.oneOfinLineResources.some((s) => l.childByName(i, s)) || k({ name: i.nodeName, parentName: i.parentNode.nodeName, oneOfResources: r.oneOfinLineResources }, e);
357
- }
358
- }
359
- function D(i) {
360
- return i.children && i.children.length !== 0;
361
- }
362
- function k(i, e) {
363
- let { name: t, parentName: r, attributes: a, subElements: s, oneOfResources: o } = i, n = "Element '".concat(t, "'");
364
- n += a ? " missing required attribute(s) '".concat(a.join(", "), "' ") : s ? " missing required sub element(s) '".concat(s.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 i(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 a = 0; a < e.children.length; a++) i(e.children[a], 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(i, e) {
373
- let { allowMultipleAds: t, followAdditionalWrappers: r } = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
374
- const a = Array.from(i.childNodes).filter((s) => {
375
- const o = s.nodeName.toLowerCase();
376
- return o === "inline" || r !== !1 && o === "wrapper";
377
- });
378
- for (const s of a) {
379
- if (l.copyNodeAttribute("id", i, s), l.copyNodeAttribute("sequence", i, s), l.copyNodeAttribute("adType", i, s), s.nodeName === "Wrapper") return { ad: re(s, e), type: "WRAPPER" };
380
- if (s.nodeName === "InLine") return { ad: te(s, e, { allowMultipleAds: t }), type: "INLINE" };
381
- const o = s.nodeName.toLowerCase();
382
- e("VAST-warning", { message: "<".concat(s.nodeName, o === "inline" ? "> must be written <InLine>" : "> must be written <Wrapper>"), wrongNode: s });
383
- }
384
- }
385
- function te(i, e) {
386
- let { allowMultipleAds: t } = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
387
- return t === !1 && i.getAttribute("sequence") ? null : H(i, e);
388
- }
389
- function H(i, e) {
390
- let t = [];
391
- e && $.verifyRequiredValues(i, e);
392
- const r = Array.from(i.childNodes), a = function() {
393
- let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
394
- return { id: s.id || null, sequence: s.sequence || null, adType: s.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(i));
396
- return r.forEach((s) => {
397
- switch (s.nodeName) {
398
- case "Error":
399
- a.errorURLTemplates.push(l.parseNodeText(s));
400
- break;
401
- case "Impression":
402
- a.impressionURLTemplates.push({ id: s.getAttribute("id") || null, url: l.parseNodeText(s) });
403
- break;
404
- case "Creatives":
405
- a.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(s, "Creative"));
433
- break;
434
- case "Extensions": {
435
- const o = l.childrenByName(s, "Extension");
436
- a.extensions = x(o), a.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
- a.adVerifications = O(l.childrenByName(s, "Verification"));
444
- break;
445
- case "AdSystem":
446
- a.system = { value: l.parseNodeText(s), version: s.getAttribute("version") || null };
447
- break;
448
- case "AdTitle":
449
- a.title = l.parseNodeText(s);
450
- break;
451
- case "AdServingId":
452
- a.adServingId = l.parseNodeText(s);
453
- break;
454
- case "Category":
455
- a.categories.push({ authority: s.getAttribute("authority") || null, value: l.parseNodeText(s) });
456
- break;
457
- case "Expires":
458
- a.expires = parseInt(l.parseNodeText(s), 10);
459
- break;
460
- case "ViewableImpression":
461
- a.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
- }(s));
468
- break;
469
- case "Description":
470
- a.description = l.parseNodeText(s);
471
- break;
472
- case "Advertiser":
473
- a.advertiser = { id: s.getAttribute("id") || null, value: l.parseNodeText(s) };
474
- break;
475
- case "Pricing":
476
- a.pricing = { value: l.parseNodeText(s), model: s.getAttribute("model") || null, currency: s.getAttribute("currency") || null };
477
- break;
478
- case "Survey":
479
- a.survey = { value: l.parseNodeText(s), type: s.getAttribute("type") || null };
480
- break;
481
- case "BlockedAdCategories":
482
- a.blockedAdCategories.push({ authority: s.getAttribute("authority") || null, value: l.parseNodeText(s) });
483
- }
484
- }), t.length && (a.adVerifications = a.adVerifications.concat(t)), a;
485
- }
486
- function re(i, e) {
487
- const t = H(i, e), r = i.getAttribute("followAdditionalWrappers"), a = i.getAttribute("allowMultipleAds"), s = i.getAttribute("fallbackOnNoAd");
488
- t.followAdditionalWrappers = !r || l.parseBoolean(r), t.allowMultipleAds = !!a && l.parseBoolean(a), t.fallbackOnNoAd = s ? l.parseBoolean(s) : null;
489
- let o = l.childByName(i, "VASTAdTagURI");
490
- if (o ? t.nextWrapperURL = l.parseNodeText(o) : (o = l.childByName(i, "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(i) {
510
- const e = [];
511
- return i.forEach((t) => {
512
- const r = { resource: null, vendor: null, browserOptional: !1, apiFramework: null, type: null, parameters: null, trackingEvents: {} }, a = Array.from(t.childNodes);
513
- l.assignAttributes(t.attributes, r), a.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 s = l.childByName(t, "TrackingEvents");
525
- s && l.childrenByName(s, "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, a, s) {
542
- const o = { fired: !1, wrapFn: void 0 };
543
- function n() {
544
- o.fired || (r.off(a, o.wrapFn), o.fired = !0, s.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), a = 1; a < t; a++) r[a - 1] = arguments[a];
554
- let s = !1;
555
- return this._handlers.forEach((o) => {
556
- o.event === "*" && (s = !0, o.handler(e, ...r)), o.event === e && (s = !0, o.handler(...r));
557
- }), s;
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 = (i, e) => {
574
- !i || !e || i <= 0 || e <= 0 || (E = (E * F + 8 * i / e) / ++F);
575
- }, ie = { ERRORCODE: 900, extensions: [] }, P = "VAST response version not supported";
576
- class ae 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, a = new Array(r > 2 ? r - 2 : 0), s = 2; s < r; s++) a[s - 2] = arguments[s];
583
- this.emit("VAST-error", Object.assign({}, ie, t, ...a)), f.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: a, errorURLTemplates: s, version: o } = r;
610
- return { ads: a || [], errorURLTemplates: s || [], 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: a = null, wrapperDepth: s = 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: a, wrapperDepth: s });
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: a, wrapperDepth: s, 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: a = null, previousUrl: s = 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 && a != null && (d[0].sequence = a), 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: s, url: t });
651
- }
652
- resolveAds() {
653
- let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], { wrapperDepth: t, previousUrl: r, url: a } = arguments.length > 1 ? arguments[1] : void 0;
654
- const s = [];
655
- return r = a, e.forEach((o) => {
656
- const n = this.resolveWrappers(o, t, r);
657
- s.push(n);
658
- }), Promise.all(s).then((o) => f.flatten(o));
659
- }
660
- resolveWrappers(e, t, r) {
661
- const a = { ...e };
662
- return new Promise((s) => {
663
- var o;
664
- if (t++, !a.nextWrapperURL) return delete a.nextWrapperURL, s(a);
665
- if (!this.fetcher) return a.VASTAdTagURI = a.nextWrapperURL, delete a.nextWrapperURL, s(a);
666
- if (t >= this.maxWrapperDepth) return a.errorCode = 302, delete a.nextWrapperURL, s(a);
667
- a.nextWrapperURL = l.resolveVastAdTagURI(a.nextWrapperURL, r);
668
- const n = (o = this.parsingOptions.allowMultipleAds) !== null && o !== void 0 ? o : a.allowMultipleAds, c = a.sequence;
669
- this.fetcher.fetchVAST({ url: a.nextWrapperURL, emitter: this.emit.bind(this), maxWrapperDepth: this.maxWrapperDepth }).then((u) => this.parse(u, { url: a.nextWrapperURL, previousUrl: r, wrapperSequence: c, wrapperDepth: t, followAdditionalWrappers: a.followAdditionalWrappers, allowMultipleAds: n }).then((d) => {
670
- if (delete a.nextWrapperURL, d.length === 0) return a.creatives = [], s(a);
671
- d.forEach((g) => {
672
- g && l.mergeWrapperAdData(g, a);
673
- }), s(d);
674
- })).catch((u) => {
675
- a.errorCode = u.message === P ? 102 : 301, a.errorMessage = u.message, s(a);
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], a = !r.creatives.some((s) => {
683
- var o, n;
684
- return ((o = s.mediaFiles) === null || o === void 0 ? void 0 : o.length) > 0 || ((n = s.variations) === null || n === void 0 ? void 0 : n.length) > 0;
685
- });
686
- !r.errorCode && !a || 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 T = null;
691
- const se = { data: {}, length: 0, getItem(i) {
692
- return this.data[i];
693
- }, setItem(i, e) {
694
- this.data[i] = e, this.length = Object.keys(this.data).length;
695
- }, removeItem(i) {
696
- delete this.data[i], 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 (T) return T;
706
- try {
707
- T = typeof window < "u" && window !== null ? window.localStorage || window.sessionStorage : null;
708
- } catch {
709
- T = null;
710
- }
711
- return T && !this.isStorageDisabled(T) || (T = se, T.clear()), T;
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(i, 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), a = await fetch(i, { ...e, signal: t.signal, credentials: e.withCredentials ? "include" : "omit" }).finally(() => {
740
- clearTimeout(r);
741
- }), s = function(o) {
742
- return f.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
- }(a);
744
- return s ? { error: new Error(s), statusCode: a.status } : async function(o) {
745
- const n = await o.text();
746
- let c;
747
- return c = f.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
- }(a);
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: a, emitter: s, 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
- }), s("VAST-resolving", { url: r, previousUrl: n, wrapperDepth: o, maxWrapperDepth: a, timeout: this.fetchingOptions.timeout, wrapperAd: c });
780
- const d = await this.urlHandler.get(r, this.fetchingOptions), g = Math.round(Date.now() - u);
781
- if (s("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 ae({ 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((a, s) => {
837
- if (this.cappingFreeLunch >= this.totalCalls) return s(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 s(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
- a(u);
844
- }))).catch((n) => s(n));
845
- });
846
- }
847
- }
848
- class ue extends _ {
849
- constructor(e, t, r) {
850
- var a;
851
- let s = 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 = s, 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 = ((a = this.ad.viewableImpression) === null || a === void 0 ? void 0 : a.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
- f.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 (!f.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(f.formatMacrosValues(t)) });
886
- const a = this.skipDelay || -1;
887
- if (a === -1 || this.skippable || (a > e ? this.emit("skip-countdown", a - e) : (this.skippable = !0, this.emit("skip-countdown", 0))), this.assetDuration > 0) {
888
- const s = Math.round(e / this.assetDuration * 100), o = [];
889
- if (e > 0) {
890
- o.push("start");
891
- for (let n = this.lastPercentage; n < s; 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 = s;
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 a = !1;
904
- return t <= r && !this._alreadyTriggeredQuartiles[e] && (a = !0), a;
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(f.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(f.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(f.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(f.formatMacrosValues(t)) });
921
- }
922
- setSkipDelay(e) {
923
- f.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(f.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(f.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((s) => s.vendor === e);
983
- if (!r) throw new Error("No associated verification element found for vendor: ".concat(e));
984
- const a = r.trackingEvents;
985
- if (a && a.verificationNotExecuted) {
986
- const s = a.verificationNotExecuted;
987
- this.trackURLs(s, t), this.emit("verificationNotExecuted", { trackingURLTemplates: s });
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(f.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(f.formatMacrosValues(t)) });
1009
- this.clickTrackingURLTemplates && this.clickTrackingURLTemplates.length && this.trackURLs(this.clickTrackingURLTemplates, t);
1010
- const r = this.clickThroughURLTemplate || e, a = { ...t };
1011
- if (r) {
1012
- this.progress && (a.ADPLAYHEAD = this.progressFormatted());
1013
- const s = f.resolveURLTemplates([r], a)[0];
1014
- this.emit("clickthrough", s);
1015
- }
1016
- }
1017
- trackProgressEvents(e, t, r) {
1018
- const a = parseFloat(e.split("-")[1]);
1019
- Object.entries(this.trackingEvents).filter((s) => {
1020
- let [o] = s;
1021
- return o.startsWith("progress-");
1022
- }).map((s) => {
1023
- let [o, n] = s;
1024
- return { name: o, time: parseFloat(o.split("-")[1]), urls: n };
1025
- }).filter((s) => {
1026
- let { time: o } = s;
1027
- return o <= a && o > this.progress;
1028
- }).forEach((s) => {
1029
- let { name: o, urls: n } = s;
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 a = this.trackingEvents[e], s = this.emitAlwaysEvents.indexOf(e) > -1;
1038
- a ? (this.emit(e, { trackingURLTemplates: a }), this.trackURLs(a, t)) : s && this.emit(e, null), r && (delete this.trackingEvents[e], s && 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] : {}, a = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
1043
- const { validUrls: s, invalidUrls: o } = f.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(","))), f.track(s, n, a);
1047
- }
1048
- convertToTimecode(e) {
1049
- if (!f.isValidTimeValue(e)) return "";
1050
- const t = 1e3 * e, r = Math.floor(t / 36e5), a = Math.floor(t / 6e4 % 60), s = Math.floor(t / 1e3 % 60), o = Math.floor(t % 1e3);
1051
- return "".concat(f.addLeadingZeros(r, 2), ":").concat(f.addLeadingZeros(a, 2), ":").concat(f.addLeadingZeros(s, 2), ".").concat(f.addLeadingZeros(o, 3));
1052
- }
1053
- progressFormatted() {
1054
- return this.convertToTimecode(this.progress);
1055
- }
1056
- }
1057
- export {
1058
- ce as _,
1059
- ue as z
1060
- };