peertube-plugin-vast-loop-ads 1.0.2

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.

Potentially problematic release.


This version of peertube-plugin-vast-loop-ads might be problematic. Click here for more details.

@@ -0,0 +1,2964 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __commonJS = (cb, mod) => function __require() {
25
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
36
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
37
+ mod
38
+ ));
39
+ var __accessCheck = (obj, member, msg) => {
40
+ if (!member.has(obj))
41
+ throw TypeError("Cannot " + msg);
42
+ };
43
+ var __privateGet = (obj, member, getter) => {
44
+ __accessCheck(obj, member, "read from private field");
45
+ return getter ? getter.call(obj) : member.get(obj);
46
+ };
47
+ var __privateAdd = (obj, member, value) => {
48
+ if (member.has(obj))
49
+ throw TypeError("Cannot add the same private member more than once");
50
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
51
+ };
52
+ var __privateSet = (obj, member, value, setter) => {
53
+ __accessCheck(obj, member, "write to private field");
54
+ setter ? setter.call(obj, value) : member.set(obj, value);
55
+ return value;
56
+ };
57
+
58
+ // external-global-plugin:video.js
59
+ var require_video = __commonJS({
60
+ "external-global-plugin:video.js"(exports, module) {
61
+ module.exports = window.videojs;
62
+ }
63
+ });
64
+
65
+ // node_modules/global/window.js
66
+ var require_window = __commonJS({
67
+ "node_modules/global/window.js"(exports, module) {
68
+ var win;
69
+ if (typeof window !== "undefined") {
70
+ win = window;
71
+ } else if (typeof global !== "undefined") {
72
+ win = global;
73
+ } else if (typeof self !== "undefined") {
74
+ win = self;
75
+ } else {
76
+ win = {};
77
+ }
78
+ module.exports = win;
79
+ }
80
+ });
81
+
82
+ // (disabled):node_modules/min-document/index.js
83
+ var require_min_document = __commonJS({
84
+ "(disabled):node_modules/min-document/index.js"() {
85
+ }
86
+ });
87
+
88
+ // node_modules/global/document.js
89
+ var require_document = __commonJS({
90
+ "node_modules/global/document.js"(exports, module) {
91
+ var topLevel = typeof global !== "undefined" ? global : typeof window !== "undefined" ? window : {};
92
+ var minDoc = require_min_document();
93
+ var doccy;
94
+ if (typeof document !== "undefined") {
95
+ doccy = document;
96
+ } else {
97
+ doccy = topLevel["__GLOBAL_DOCUMENT_CACHE@4"];
98
+ if (!doccy) {
99
+ doccy = topLevel["__GLOBAL_DOCUMENT_CACHE@4"] = minDoc;
100
+ }
101
+ }
102
+ module.exports = doccy;
103
+ }
104
+ });
105
+
106
+ // public/scripts/videojs.ads.min.js
107
+ var require_videojs_ads_min = __commonJS({
108
+ "public/scripts/videojs.ads.min.js"(exports, module) {
109
+ !function(e, t) {
110
+ "object" == typeof exports && "undefined" != typeof module ? module.exports = t(require_video(), require_window(), require_document()) : "function" == typeof define && define.amd ? define(["video.js", "global/window", "global/document"], t) : (e = e || self).videojsContribAds = t(e.videojs, e.window, e.document);
111
+ }(exports, function(e, t, n) {
112
+ "use strict";
113
+ e = e && e.hasOwnProperty("default") ? e.default : e, t = t && t.hasOwnProperty("default") ? t.default : t, n = n && n.hasOwnProperty("default") ? n.default : n;
114
+ var a = "6.9.0";
115
+ var o = function(e2, t2) {
116
+ t2.isImmediatePropagationStopped = function() {
117
+ return true;
118
+ }, t2.cancelBubble = true, t2.isPropagationStopped = function() {
119
+ return true;
120
+ };
121
+ }, r = function(e2, t2, n2) {
122
+ o(0, n2), e2.trigger({ type: t2 + n2.type, originalEvent: n2 });
123
+ }, i = function(e2, t2) {
124
+ e2.ads.isInAdMode() && (e2.ads.isContentResuming() ? e2.ads._contentEnding && r(e2, "content", t2) : r(e2, "ad", t2));
125
+ }, s = function(e2, t2) {
126
+ e2.ads.isInAdMode() ? e2.ads.isContentResuming() ? (o(0, t2), e2.trigger("resumeended")) : r(e2, "ad", t2) : e2.ads._contentHasEnded || e2.ads.stitchedAds() || (r(e2, "content", t2), e2.trigger("readyforpostroll"));
127
+ }, d = function(e2, t2) {
128
+ if (!("loadstart" === t2.type && !e2.ads._hasThereBeenALoadStartDuringPlayerLife || "loadeddata" === t2.type && !e2.ads._hasThereBeenALoadedData || "loadedmetadata" === t2.type && !e2.ads._hasThereBeenALoadedMetaData))
129
+ if (e2.ads.inAdBreak())
130
+ r(e2, "ad", t2);
131
+ else {
132
+ if (e2.currentSrc() !== e2.ads.contentSrc)
133
+ return;
134
+ r(e2, "content", t2);
135
+ }
136
+ }, l = function(e2, t2) {
137
+ e2.ads.inAdBreak() ? r(e2, "ad", t2) : e2.ads.isContentResuming() && r(e2, "content", t2);
138
+ };
139
+ function u(e2) {
140
+ "playing" === e2.type ? i(this, e2) : "ended" === e2.type ? s(this, e2) : "loadstart" === e2.type || "loadeddata" === e2.type || "loadedmetadata" === e2.type ? d(this, e2) : "play" === e2.type ? l(this, e2) : this.ads.isInAdMode() && (this.ads.isContentResuming() ? r(this, "content", e2) : r(this, "ad", e2));
141
+ }
142
+ var c = {}, f = function() {
143
+ !function(n2) {
144
+ if (e.dom.isInFrame() && "function" != typeof t.__tcfapi) {
145
+ for (var a2, o2 = t, r2 = {}; o2; ) {
146
+ try {
147
+ if (o2.frames.__tcfapiLocator) {
148
+ a2 = o2;
149
+ break;
150
+ }
151
+ } catch (e2) {
152
+ }
153
+ if (o2 === t.top)
154
+ break;
155
+ o2 = o2.parent;
156
+ }
157
+ if (!a2)
158
+ return;
159
+ t.__tcfapi = function(e2, t2, n3, o3) {
160
+ var i2 = Math.random() + "", s2 = { __tcfapiCall: { command: e2, parameter: o3, version: t2, callId: i2 } };
161
+ r2[i2] = n3, a2.postMessage(s2, "*");
162
+ }, t.addEventListener("message", function(e2) {
163
+ var t2 = {};
164
+ try {
165
+ t2 = "string" == typeof e2.data ? JSON.parse(e2.data) : e2.data;
166
+ } catch (e3) {
167
+ }
168
+ var n3 = t2.__tcfapiReturn;
169
+ n3 && "function" == typeof r2[n3.callId] && (r2[n3.callId](n3.returnValue, n3.success), r2[n3.callId] = null);
170
+ }, false);
171
+ }
172
+ }(), "function" == typeof t.__tcfapi && t.__tcfapi("addEventListener", 2, function(e2, t2) {
173
+ t2 && (c = e2);
174
+ });
175
+ }, h = function(e2, t2) {
176
+ return t2 ? encodeURIComponent(e2) : e2;
177
+ }, p = function(e2, t2, n2) {
178
+ if (e2 && e2[n2])
179
+ for (var a2 = e2[n2], o2 = Object.keys(a2), r2 = 0; r2 < o2.length; r2++) {
180
+ t2["{mediainfo." + n2 + "." + o2[r2] + "}"] = a2[o2[r2]];
181
+ }
182
+ };
183
+ var g = { processMetadataTracks: function(e2, t2) {
184
+ for (var n2 = e2.textTracks(), a2 = function(n3) {
185
+ "metadata" === n3.kind && (e2.ads.cueTextTracks.setMetadataTrackMode(n3), t2(e2, n3));
186
+ }, o2 = 0; o2 < n2.length; o2++)
187
+ a2(n2[o2]);
188
+ n2.addEventListener("addtrack", function(e3) {
189
+ a2(e3.track);
190
+ });
191
+ }, setMetadataTrackMode: function(e2) {
192
+ }, getSupportedAdCue: function(e2, t2) {
193
+ return t2;
194
+ }, isSupportedAdCue: function(e2, t2) {
195
+ return true;
196
+ }, getCueId: function(e2, t2) {
197
+ return t2.id;
198
+ } }, y = function(e2, t2) {
199
+ return void 0 !== t2 && e2.ads.includedCues[t2];
200
+ }, v = function(e2, t2) {
201
+ void 0 !== t2 && "" !== t2 && (e2.ads.includedCues[t2] = true);
202
+ };
203
+ function m() {
204
+ false !== this.ads._shouldBlockPlay && (this.paused() || (this.ads.debug("Playback was canceled by cancelContentPlay"), this.pause()), this.ads._cancelledPlay = true);
205
+ }
206
+ g.processAdTrack = function(t2, n2, a2, o2) {
207
+ t2.ads.includedCues = {};
208
+ for (var r2 = 0; r2 < n2.length; r2++) {
209
+ var i2 = n2[r2], s2 = this.getSupportedAdCue(t2, i2);
210
+ if (!this.isSupportedAdCue(t2, i2))
211
+ return void e.log.warn("Skipping as this is not a supported ad cue.", i2);
212
+ var d2 = this.getCueId(t2, i2), l2 = i2.startTime;
213
+ if (y(t2, d2))
214
+ return void e.log("Skipping ad already seen with ID " + d2);
215
+ o2 && o2(t2, s2, d2, l2), a2(t2, s2, d2, l2), v(t2, d2);
216
+ }
217
+ };
218
+ var A = {}, S = e;
219
+ A.isMiddlewareMediatorSupported = function() {
220
+ return !S.browser.IS_IOS && !S.browser.IS_ANDROID && !!(S.use && S.middleware && S.middleware.TERMINATOR);
221
+ }, A.playMiddleware = function(t2) {
222
+ return { setSource: function(e2, t3) {
223
+ t3(null, e2);
224
+ }, callPlay: function() {
225
+ if (t2.ads && true === t2.ads._shouldBlockPlay)
226
+ return t2.ads.debug("Using playMiddleware to block content playback"), t2.ads._playBlocked = true, S.middleware.TERMINATOR;
227
+ }, play: function(n2, a2) {
228
+ t2.ads && t2.ads._playBlocked && n2 ? (t2.ads.debug("Play call to Tech was terminated."), t2.trigger("play"), t2.addClass("vjs-has-started"), t2.ads._playBlocked = false) : a2 && a2.catch && a2.catch(function(n3) {
229
+ "NotAllowedError" !== n3.name || e.browser.IS_SAFARI || t2.trigger("pause");
230
+ });
231
+ } };
232
+ }, A.testHook = function(e2) {
233
+ S = e2;
234
+ };
235
+ var _ = A.playMiddleware, P = A.isMiddlewareMediatorSupported, b = function() {
236
+ if (e.getPlugin)
237
+ return Boolean(e.getPlugin("ads"));
238
+ var t2 = e.getComponent("Player");
239
+ return Boolean(t2 && t2.prototype.ads);
240
+ };
241
+ var k = function() {
242
+ function e2() {
243
+ }
244
+ return e2.getState = function(t2) {
245
+ if (t2)
246
+ return e2.states_ && e2.states_[t2] ? e2.states_[t2] : void 0;
247
+ }, e2.registerState = function(t2, n2) {
248
+ if ("string" != typeof t2 || !t2)
249
+ throw new Error('Illegal state name, "' + t2 + '"; must be a non-empty string.');
250
+ return e2.states_ || (e2.states_ = {}), e2.states_[t2] = n2, n2;
251
+ }, e2;
252
+ }(), C = function() {
253
+ function t2(e2) {
254
+ this.player = e2;
255
+ }
256
+ t2._getName = function() {
257
+ return "Anonymous State";
258
+ };
259
+ var n2 = t2.prototype;
260
+ return n2.transitionTo = function(e2) {
261
+ var t3 = this.player;
262
+ this.cleanup(t3);
263
+ var n3 = new e2(t3);
264
+ t3.ads._state = n3, t3.ads.debug(this.constructor._getName() + " -> " + n3.constructor._getName());
265
+ for (var a2 = arguments.length, o2 = new Array(a2 > 1 ? a2 - 1 : 0), r2 = 1; r2 < a2; r2++)
266
+ o2[r2 - 1] = arguments[r2];
267
+ n3.init.apply(n3, [t3].concat(o2));
268
+ }, n2.init = function() {
269
+ }, n2.cleanup = function() {
270
+ }, n2.onPlay = function() {
271
+ }, n2.onPlaying = function() {
272
+ }, n2.onEnded = function() {
273
+ }, n2.onAdEnded = function() {
274
+ }, n2.onAdsReady = function() {
275
+ e.log.warn("Unexpected adsready event");
276
+ }, n2.onAdsError = function() {
277
+ }, n2.onAdsCanceled = function() {
278
+ }, n2.onAdTimeout = function() {
279
+ }, n2.onAdStarted = function() {
280
+ }, n2.onContentChanged = function() {
281
+ }, n2.onContentResumed = function() {
282
+ }, n2.onReadyForPostroll = function() {
283
+ e.log.warn("Unexpected readyforpostroll event");
284
+ }, n2.onNoPreroll = function() {
285
+ }, n2.onNoPostroll = function() {
286
+ }, n2.startLinearAdMode = function() {
287
+ e.log.warn("Unexpected startLinearAdMode invocation (State via " + this.constructor._getName() + ")");
288
+ }, n2.endLinearAdMode = function() {
289
+ e.log.warn("Unexpected endLinearAdMode invocation (State via " + this.constructor._getName() + ")");
290
+ }, n2.skipLinearAdMode = function() {
291
+ e.log.warn("Unexpected skipLinearAdMode invocation (State via " + this.constructor._getName() + ")");
292
+ }, n2.isAdState = function() {
293
+ throw new Error("isAdState unimplemented for " + this.constructor._getName());
294
+ }, n2.isWaitingForAdBreak = function() {
295
+ return false;
296
+ }, n2.isContentResuming = function() {
297
+ return false;
298
+ }, n2.inAdBreak = function() {
299
+ return false;
300
+ }, n2.handleEvent = function(e2) {
301
+ var t3 = this.player;
302
+ "play" === e2 ? this.onPlay(t3) : "adsready" === e2 ? this.onAdsReady(t3) : "adserror" === e2 ? this.onAdsError(t3) : "adscanceled" === e2 ? this.onAdsCanceled(t3) : "adtimeout" === e2 ? this.onAdTimeout(t3) : "ads-ad-started" === e2 ? this.onAdStarted(t3) : "contentchanged" === e2 ? this.onContentChanged(t3) : "contentresumed" === e2 ? this.onContentResumed(t3) : "readyforpostroll" === e2 ? this.onReadyForPostroll(t3) : "playing" === e2 ? this.onPlaying(t3) : "ended" === e2 ? this.onEnded(t3) : "nopreroll" === e2 ? this.onNoPreroll(t3) : "nopostroll" === e2 ? this.onNoPostroll(t3) : "adended" === e2 && this.onAdEnded(t3);
303
+ }, t2;
304
+ }();
305
+ function T(e2, t2) {
306
+ e2.prototype = Object.create(t2.prototype), e2.prototype.constructor = e2, e2.__proto__ = t2;
307
+ }
308
+ k.registerState("State", C);
309
+ var w = function(e2) {
310
+ function t2(t3) {
311
+ var n3;
312
+ return (n3 = e2.call(this, t3) || this).contentResuming = false, n3.waitingForAdBreak = false, n3;
313
+ }
314
+ T(t2, e2);
315
+ var n2 = t2.prototype;
316
+ return n2.isAdState = function() {
317
+ return true;
318
+ }, n2.onPlaying = function() {
319
+ var e3 = k.getState("ContentPlayback");
320
+ this.contentResuming && this.transitionTo(e3);
321
+ }, n2.onContentResumed = function() {
322
+ var e3 = k.getState("ContentPlayback");
323
+ this.contentResuming && this.transitionTo(e3);
324
+ }, n2.isWaitingForAdBreak = function() {
325
+ return this.waitingForAdBreak;
326
+ }, n2.isContentResuming = function() {
327
+ return this.contentResuming;
328
+ }, n2.inAdBreak = function() {
329
+ return true === this.player.ads._inLinearAdMode;
330
+ }, t2;
331
+ }(C);
332
+ k.registerState("AdState", w);
333
+ var R = function(e2) {
334
+ function t2() {
335
+ return e2.apply(this, arguments) || this;
336
+ }
337
+ T(t2, e2);
338
+ var n2 = t2.prototype;
339
+ return n2.isAdState = function() {
340
+ return false;
341
+ }, n2.onContentChanged = function(e3) {
342
+ var t3 = k.getState("BeforePreroll"), n3 = k.getState("Preroll");
343
+ e3.ads.debug("Received contentchanged event (ContentState)"), e3.paused() ? this.transitionTo(t3) : (this.transitionTo(n3, false), e3.pause(), e3.ads._pausedOnContentupdate = true);
344
+ }, t2;
345
+ }(C);
346
+ k.registerState("ContentState", R);
347
+ var L, B = function(t2) {
348
+ function n2() {
349
+ return t2.apply(this, arguments) || this;
350
+ }
351
+ T(n2, t2), n2._getName = function() {
352
+ return "AdsDone";
353
+ };
354
+ var a2 = n2.prototype;
355
+ return a2.init = function(e2) {
356
+ e2.ads._contentHasEnded = true, e2.trigger("ended");
357
+ }, a2.startLinearAdMode = function() {
358
+ e.log.warn("Unexpected startLinearAdMode invocation (AdsDone)");
359
+ }, n2;
360
+ }(k.getState("ContentState"));
361
+ k.registerState("AdsDone", B);
362
+ var M = { start: function(t2) {
363
+ t2.ads.debug("Starting ad break"), t2.ads._inLinearAdMode = true, t2.trigger("adstart"), t2.ads.shouldTakeSnapshots() && (t2.ads.snapshot = function(t3) {
364
+ var n2;
365
+ n2 = e.browser.IS_IOS && t3.ads.isLive(t3) && t3.seekable().length > 0 ? t3.currentTime() - t3.seekable().end(0) : t3.currentTime();
366
+ var a2 = t3.$(".vjs-tech"), o2 = t3.textTracks ? t3.textTracks() : [], r2 = [], i2 = { ended: t3.ended(), currentSrc: t3.currentSrc(), sources: t3.currentSources(), src: t3.tech_.src(), currentTime: n2, type: t3.currentType() };
367
+ a2 && (i2.style = a2.getAttribute("style"));
368
+ for (var s2 = 0; s2 < o2.length; s2++) {
369
+ var d2 = o2[s2];
370
+ r2.push({ track: d2, mode: d2.mode }), d2.mode = "disabled";
371
+ }
372
+ return i2.suppressedTracks = r2, i2;
373
+ }(t2)), t2.ads.shouldPlayContentBehindAd(t2) && (t2.ads.preAdVolume_ = t2.volume(), t2.volume(0)), t2.addClass("vjs-ad-playing"), t2.hasClass("vjs-live") && t2.removeClass("vjs-live"), t2.ads.removeNativePoster();
374
+ }, end: function(t2, n2) {
375
+ t2.ads.debug("Ending ad break"), void 0 === n2 && (n2 = function() {
376
+ }), t2.ads.adType = null, t2.ads._inLinearAdMode = false, t2.trigger("adend"), t2.removeClass("vjs-ad-playing"), t2.ads.isLive(t2) && t2.addClass("vjs-live"), t2.ads.shouldTakeSnapshots() ? function(t3, n3) {
377
+ var a2 = t3.ads.snapshot;
378
+ if (void 0 === n3 && (n3 = function() {
379
+ }), true === t3.ads.disableNextSnapshotRestore)
380
+ return t3.ads.disableNextSnapshotRestore = false, delete t3.ads.snapshot, void n3();
381
+ var o2, r2 = t3.$(".vjs-tech"), i2 = 20, s2 = a2.suppressedTracks, d2 = function() {
382
+ for (var e2 = 0; e2 < s2.length; e2++)
383
+ (o2 = s2[e2]).track.mode = o2.mode;
384
+ }, l2 = function() {
385
+ var n4;
386
+ if (e.browser.IS_IOS && t3.ads.isLive(t3)) {
387
+ if (a2.currentTime < 0 && (n4 = t3.seekable().length > 0 ? t3.seekable().end(0) + a2.currentTime : t3.currentTime(), t3.currentTime(n4)), t3.paused()) {
388
+ var o3 = t3.play();
389
+ o3 && o3.catch && o3.catch(function(t4) {
390
+ e.log.warn("Play promise rejected in IOS snapshot resume", t4);
391
+ });
392
+ }
393
+ } else if (a2.ended)
394
+ t3.currentTime(t3.duration());
395
+ else {
396
+ t3.currentTime(a2.currentTime);
397
+ var r3 = t3.play();
398
+ r3 && r3.catch && r3.catch(function(t4) {
399
+ e.log.warn("Play promise rejected in snapshot resume", t4);
400
+ });
401
+ }
402
+ t3.ads.shouldRemoveAutoplay_ && (t3.autoplay(false), t3.ads.shouldRemoveAutoplay_ = false);
403
+ }, u2 = function n4() {
404
+ if (t3.off("contentcanplay", n4), L && t3.clearTimeout(L), (r2 = t3.el().querySelector(".vjs-tech")).readyState > 1)
405
+ return l2();
406
+ if (void 0 === r2.seekable)
407
+ return l2();
408
+ if (r2.seekable.length > 0)
409
+ return l2();
410
+ if (i2--)
411
+ t3.setTimeout(n4, 50);
412
+ else
413
+ try {
414
+ l2();
415
+ } catch (t4) {
416
+ e.log.warn("Failed to resume the content after an advertisement", t4);
417
+ }
418
+ };
419
+ if ("style" in a2 && r2.setAttribute("style", a2.style || ""), t3.ads.videoElementRecycled())
420
+ t3.one("resumeended", function() {
421
+ delete t3.ads.snapshot, n3();
422
+ }), t3.one("contentloadedmetadata", d2), e.browser.IS_IOS && !t3.autoplay() && (t3.autoplay(true), t3.ads.shouldRemoveAutoplay_ = true), t3.src(a2.sources), t3.one("contentcanplay", u2), L = t3.setTimeout(u2, 2e3);
423
+ else {
424
+ if (d2(), !t3.ended()) {
425
+ var c2 = t3.play();
426
+ c2 && c2.catch && c2.catch(function(t4) {
427
+ e.log.warn("Play promise rejected in snapshot restore", t4);
428
+ });
429
+ }
430
+ delete t3.ads.snapshot, n3();
431
+ }
432
+ }(t2, n2) : (t2.volume(t2.ads.preAdVolume_), n2());
433
+ } }, j = function(t2) {
434
+ function n2() {
435
+ return t2.apply(this, arguments) || this;
436
+ }
437
+ T(n2, t2), n2._getName = function() {
438
+ return "Preroll";
439
+ };
440
+ var a2 = n2.prototype;
441
+ return a2.init = function(e2, t3, n3) {
442
+ if (this.waitingForAdBreak = true, e2.addClass("vjs-ad-loading"), n3 || e2.ads.nopreroll_)
443
+ return this.resumeAfterNoPreroll(e2);
444
+ var a3 = e2.ads.settings.timeout;
445
+ "number" == typeof e2.ads.settings.prerollTimeout && (a3 = e2.ads.settings.prerollTimeout), this._timeout = e2.setTimeout(function() {
446
+ e2.trigger("adtimeout");
447
+ }, a3), t3 ? this.handleAdsReady() : this.adsReady = false;
448
+ }, a2.onAdsReady = function(t3) {
449
+ t3.ads.inAdBreak() ? e.log.warn("Unexpected adsready event (Preroll)") : (t3.ads.debug("Received adsready event (Preroll)"), this.handleAdsReady());
450
+ }, a2.handleAdsReady = function() {
451
+ this.adsReady = true, this.readyForPreroll();
452
+ }, a2.afterLoadStart = function(e2) {
453
+ var t3 = this.player;
454
+ t3.ads._hasThereBeenALoadStartDuringPlayerLife ? e2() : (t3.ads.debug("Waiting for loadstart..."), t3.one("loadstart", function() {
455
+ t3.ads.debug("Received loadstart event"), e2();
456
+ }));
457
+ }, a2.noPreroll = function() {
458
+ var e2 = this;
459
+ this.afterLoadStart(function() {
460
+ e2.player.ads.debug("Skipping prerolls due to nopreroll event (Preroll)"), e2.resumeAfterNoPreroll(e2.player);
461
+ });
462
+ }, a2.readyForPreroll = function() {
463
+ var e2 = this.player;
464
+ this.afterLoadStart(function() {
465
+ e2.ads.debug("Triggered readyforpreroll event (Preroll)"), e2.trigger("readyforpreroll");
466
+ });
467
+ }, a2.onAdsCanceled = function(e2) {
468
+ var t3 = this;
469
+ e2.ads.debug("adscanceled (Preroll)"), this.afterLoadStart(function() {
470
+ t3.resumeAfterNoPreroll(e2);
471
+ });
472
+ }, a2.onAdsError = function(t3) {
473
+ var n3 = this;
474
+ e.log("adserror (Preroll)"), this.inAdBreak() ? t3.ads.endLinearAdMode() : this.afterLoadStart(function() {
475
+ n3.resumeAfterNoPreroll(t3);
476
+ });
477
+ }, a2.startLinearAdMode = function() {
478
+ var t3 = this.player;
479
+ !this.adsReady || t3.ads.inAdBreak() || this.isContentResuming() ? e.log.warn("Unexpected startLinearAdMode invocation (Preroll)") : (this.clearTimeout(t3), t3.ads.adType = "preroll", this.waitingForAdBreak = false, M.start(t3), t3.ads._shouldBlockPlay = false);
480
+ }, a2.onAdStarted = function(e2) {
481
+ e2.removeClass("vjs-ad-loading");
482
+ }, a2.endLinearAdMode = function() {
483
+ var e2 = this.player;
484
+ this.inAdBreak() && (e2.removeClass("vjs-ad-loading"), e2.addClass("vjs-ad-content-resuming"), this.contentResuming = true, M.end(e2));
485
+ }, a2.skipLinearAdMode = function() {
486
+ var t3 = this, n3 = this.player;
487
+ n3.ads.inAdBreak() || this.isContentResuming() ? e.log.warn("Unexpected skipLinearAdMode invocation") : this.afterLoadStart(function() {
488
+ n3.trigger("adskip"), n3.ads.debug("skipLinearAdMode (Preroll)"), t3.resumeAfterNoPreroll(n3);
489
+ });
490
+ }, a2.onAdTimeout = function(e2) {
491
+ var t3 = this;
492
+ this.afterLoadStart(function() {
493
+ e2.ads.debug("adtimeout (Preroll)"), t3.resumeAfterNoPreroll(e2);
494
+ });
495
+ }, a2.onNoPreroll = function(t3) {
496
+ t3.ads.inAdBreak() || this.isContentResuming() ? e.log.warn("Unexpected nopreroll event (Preroll)") : this.noPreroll();
497
+ }, a2.resumeAfterNoPreroll = function(e2) {
498
+ if (this.contentResuming = true, e2.ads._shouldBlockPlay = false, this.cleanupPartial(e2), e2.ads._playRequested || e2.ads._pausedOnContentupdate)
499
+ if (e2.paused()) {
500
+ e2.ads.debug("resumeAfterNoPreroll: attempting to resume playback (Preroll)");
501
+ var t3 = e2.play();
502
+ t3 && t3.then && t3.then(null, function(e3) {
503
+ });
504
+ } else
505
+ e2.ads.debug("resumeAfterNoPreroll: already playing (Preroll)"), e2.trigger("play"), e2.trigger("playing");
506
+ }, a2.cleanup = function(t3) {
507
+ t3.ads._hasThereBeenALoadStartDuringPlayerLife || e.log.warn("Leaving Preroll state before loadstart event can cause issues."), this.cleanupPartial(t3);
508
+ }, a2.cleanupPartial = function(e2) {
509
+ e2.removeClass("vjs-ad-loading"), e2.removeClass("vjs-ad-content-resuming"), this.clearTimeout(e2);
510
+ }, a2.clearTimeout = function(e2) {
511
+ e2.clearTimeout(this._timeout), this._timeout = null;
512
+ }, n2;
513
+ }(k.getState("AdState"));
514
+ k.registerState("Preroll", j);
515
+ var I = function(e2) {
516
+ function t2() {
517
+ return e2.apply(this, arguments) || this;
518
+ }
519
+ T(t2, e2), t2._getName = function() {
520
+ return "BeforePreroll";
521
+ };
522
+ var n2 = t2.prototype;
523
+ return n2.init = function(e3) {
524
+ this.adsReady = false, this.shouldResumeToContent = false, e3.ads._shouldBlockPlay = !e3.ads.settings.allowVjsAutoplay || !e3.autoplay();
525
+ }, n2.onAdsReady = function(e3) {
526
+ e3.ads.debug("Received adsready event (BeforePreroll)"), this.adsReady = true;
527
+ }, n2.onPlay = function(e3) {
528
+ var t3 = k.getState("Preroll");
529
+ e3.ads.debug("Received play event (BeforePreroll)"), this.transitionTo(t3, this.adsReady, this.shouldResumeToContent);
530
+ }, n2.onAdsCanceled = function(e3) {
531
+ e3.ads.debug("adscanceled (BeforePreroll)"), this.shouldResumeToContent = true;
532
+ }, n2.onAdsError = function() {
533
+ this.player.ads.debug("adserror (BeforePreroll)"), this.shouldResumeToContent = true;
534
+ }, n2.onNoPreroll = function() {
535
+ this.player.ads.debug("Skipping prerolls due to nopreroll event (BeforePreroll)"), this.shouldResumeToContent = true;
536
+ }, n2.skipLinearAdMode = function() {
537
+ var e3 = this.player;
538
+ e3.trigger("adskip"), e3.ads.debug("skipLinearAdMode (BeforePreroll)"), this.shouldResumeToContent = true;
539
+ }, n2.onContentChanged = function() {
540
+ this.init(this.player);
541
+ }, t2;
542
+ }(k.getState("ContentState"));
543
+ k.registerState("BeforePreroll", I);
544
+ var N = function(e2) {
545
+ function t2() {
546
+ return e2.apply(this, arguments) || this;
547
+ }
548
+ T(t2, e2), t2._getName = function() {
549
+ return "Midroll";
550
+ };
551
+ var n2 = t2.prototype;
552
+ return n2.init = function(e3) {
553
+ e3.ads.adType = "midroll", M.start(e3), e3.addClass("vjs-ad-loading");
554
+ }, n2.onAdStarted = function(e3) {
555
+ e3.removeClass("vjs-ad-loading");
556
+ }, n2.endLinearAdMode = function() {
557
+ var e3 = this.player;
558
+ this.inAdBreak() && (this.contentResuming = true, e3.addClass("vjs-ad-content-resuming"), e3.removeClass("vjs-ad-loading"), M.end(e3));
559
+ }, n2.onAdsError = function(e3) {
560
+ this.inAdBreak() && e3.ads.endLinearAdMode();
561
+ }, n2.cleanup = function(e3) {
562
+ e3.removeClass("vjs-ad-loading"), e3.removeClass("vjs-ad-content-resuming");
563
+ }, t2;
564
+ }(k.getState("AdState"));
565
+ k.registerState("Midroll", N);
566
+ var E = function(t2) {
567
+ function n2() {
568
+ return t2.apply(this, arguments) || this;
569
+ }
570
+ T(n2, t2), n2._getName = function() {
571
+ return "Postroll";
572
+ };
573
+ var a2 = n2.prototype;
574
+ return a2.init = function(e2) {
575
+ if (this.waitingForAdBreak = true, e2.ads._contentEnding = true, e2.ads.nopostroll_) {
576
+ this.resumeContent(e2);
577
+ var t3 = k.getState("AdsDone");
578
+ this.transitionTo(t3);
579
+ } else {
580
+ e2.addClass("vjs-ad-loading");
581
+ var n3 = e2.ads.settings.timeout;
582
+ "number" == typeof e2.ads.settings.postrollTimeout && (n3 = e2.ads.settings.postrollTimeout), this._postrollTimeout = e2.setTimeout(function() {
583
+ e2.trigger("adtimeout");
584
+ }, n3);
585
+ }
586
+ }, a2.startLinearAdMode = function() {
587
+ var t3 = this.player;
588
+ t3.ads.inAdBreak() || this.isContentResuming() ? e.log.warn("Unexpected startLinearAdMode invocation (Postroll)") : (t3.ads.adType = "postroll", t3.clearTimeout(this._postrollTimeout), this.waitingForAdBreak = false, M.start(t3));
589
+ }, a2.onAdStarted = function(e2) {
590
+ e2.removeClass("vjs-ad-loading");
591
+ }, a2.endLinearAdMode = function() {
592
+ var e2 = this, t3 = this.player, n3 = k.getState("AdsDone");
593
+ this.inAdBreak() && (t3.removeClass("vjs-ad-loading"), this.resumeContent(t3), M.end(t3, function() {
594
+ e2.transitionTo(n3);
595
+ }));
596
+ }, a2.skipLinearAdMode = function() {
597
+ var t3 = this.player;
598
+ t3.ads.inAdBreak() || this.isContentResuming() ? e.log.warn("Unexpected skipLinearAdMode invocation") : (t3.ads.debug("Postroll abort (skipLinearAdMode)"), t3.trigger("adskip"), this.abort(t3));
599
+ }, a2.onAdTimeout = function(e2) {
600
+ e2.ads.debug("Postroll abort (adtimeout)"), this.abort(e2);
601
+ }, a2.onAdsError = function(e2) {
602
+ e2.ads.debug("Postroll abort (adserror)"), e2.ads.inAdBreak() ? e2.ads.endLinearAdMode() : this.abort(e2);
603
+ }, a2.onContentChanged = function(e2) {
604
+ if (this.isContentResuming()) {
605
+ var t3 = k.getState("BeforePreroll");
606
+ this.transitionTo(t3);
607
+ } else if (!this.inAdBreak()) {
608
+ var n3 = k.getState("Preroll");
609
+ this.transitionTo(n3);
610
+ }
611
+ }, a2.onNoPostroll = function(t3) {
612
+ this.isContentResuming() || this.inAdBreak() ? e.log.warn("Unexpected nopostroll event (Postroll)") : this.abort(t3);
613
+ }, a2.resumeContent = function(e2) {
614
+ this.contentResuming = true, e2.addClass("vjs-ad-content-resuming");
615
+ }, a2.abort = function(e2) {
616
+ var t3 = k.getState("AdsDone");
617
+ this.resumeContent(e2), e2.removeClass("vjs-ad-loading"), this.transitionTo(t3);
618
+ }, a2.cleanup = function(e2) {
619
+ e2.removeClass("vjs-ad-content-resuming"), e2.clearTimeout(this._postrollTimeout), e2.ads._contentEnding = false;
620
+ }, n2;
621
+ }(k.getState("AdState"));
622
+ k.registerState("Postroll", E);
623
+ var x = function(e2) {
624
+ function t2() {
625
+ return e2.apply(this, arguments) || this;
626
+ }
627
+ T(t2, e2), t2._getName = function() {
628
+ return "ContentPlayback";
629
+ };
630
+ var n2 = t2.prototype;
631
+ return n2.init = function(e3) {
632
+ e3.ads._shouldBlockPlay = false;
633
+ }, n2.onAdsReady = function(e3) {
634
+ e3.ads.debug("Received adsready event (ContentPlayback)"), e3.ads.nopreroll_ || (e3.ads.debug("Triggered readyforpreroll event (ContentPlayback)"), e3.trigger("readyforpreroll"));
635
+ }, n2.onReadyForPostroll = function(e3) {
636
+ var t3 = k.getState("Postroll");
637
+ e3.ads.debug("Received readyforpostroll event"), this.transitionTo(t3);
638
+ }, n2.startLinearAdMode = function() {
639
+ var e3 = k.getState("Midroll");
640
+ this.transitionTo(e3);
641
+ }, t2;
642
+ }(k.getState("ContentState"));
643
+ k.registerState("ContentPlayback", x);
644
+ var D = function(e2) {
645
+ function t2() {
646
+ return e2.apply(this, arguments) || this;
647
+ }
648
+ T(t2, e2), t2._getName = function() {
649
+ return "StitchedContentPlayback";
650
+ };
651
+ var n2 = t2.prototype;
652
+ return n2.init = function() {
653
+ this.player.ads._shouldBlockPlay = false;
654
+ }, n2.onContentChanged = function() {
655
+ this.player.ads.debug("Received contentchanged event (" + this.constructor._getName() + ")");
656
+ }, n2.startLinearAdMode = function() {
657
+ var e3 = k.getState("StitchedAdRoll");
658
+ this.transitionTo(e3);
659
+ }, t2;
660
+ }(k.getState("ContentState"));
661
+ k.registerState("StitchedContentPlayback", D);
662
+ var O = function(e2) {
663
+ function t2() {
664
+ return e2.apply(this, arguments) || this;
665
+ }
666
+ T(t2, e2), t2._getName = function() {
667
+ return "StitchedAdRoll";
668
+ };
669
+ var n2 = t2.prototype;
670
+ return n2.init = function() {
671
+ this.waitingForAdBreak = false, this.contentResuming = false, this.player.ads.adType = "stitched", M.start(this.player);
672
+ }, n2.onPlaying = function() {
673
+ }, n2.onContentResumed = function() {
674
+ }, n2.onAdEnded = function() {
675
+ this.endLinearAdMode(), this.player.trigger("ended");
676
+ }, n2.endLinearAdMode = function() {
677
+ var e3 = k.getState("StitchedContentPlayback");
678
+ M.end(this.player), this.transitionTo(e3);
679
+ }, t2;
680
+ }(k.getState("AdState"));
681
+ k.registerState("StitchedAdRoll", O);
682
+ var F = A.isMiddlewareMediatorSupported, U = e.getTech("Html5").Events, V = { timeout: 5e3, prerollTimeout: void 0, postrollTimeout: void 0, debug: false, stitchedAds: false, contentIsLive: void 0, liveCuePoints: true, allowVjsAutoplay: e.options.normalizeAutoplay || false }, q = function(o2) {
683
+ var r2 = this, i2 = e.mergeOptions(V, o2), s2 = [];
684
+ U.concat(["firstplay", "loadedalldata"]).forEach(function(e2) {
685
+ -1 === s2.indexOf(e2) && s2.push(e2);
686
+ }), r2.on(s2, u), F() || function(t2, n2) {
687
+ n2 && e.log("Using cancelContentPlay to block content playback"), t2.on("play", m);
688
+ }(r2, i2.debug), r2.setTimeout(function() {
689
+ r2.ads._hasThereBeenALoadStartDuringPlayerLife || "" === r2.src() || e.log.error("videojs-contrib-ads has not seen a loadstart event 5 seconds after being initialized, but a source is present. This indicates that videojs-contrib-ads was initialized too late. It must be initialized immediately after video.js in the same tick. As a result, some ads will not play and some media events will be incorrect. For more information, see http://videojs.github.io/videojs-contrib-ads/integrator/getting-started.html");
690
+ }, 5e3), r2.on("ended", function() {
691
+ r2.hasClass("vjs-has-started") || r2.addClass("vjs-has-started");
692
+ }), r2.on("contenttimeupdate", function() {
693
+ r2.removeClass("vjs-waiting");
694
+ }), r2.on(["addurationchange", "adcanplay"], function() {
695
+ if (!r2.ads.settings.stitchedAds && !r2.hasStarted() && (!r2.ads.snapshot || r2.currentSrc() !== r2.ads.snapshot.currentSrc) && r2.ads.inAdBreak()) {
696
+ var t2 = r2.play();
697
+ t2 && t2.catch && t2.catch(function(t3) {
698
+ e.log.warn("Play promise rejected when playing ad", t3);
699
+ });
700
+ }
701
+ }), r2.on("nopreroll", function() {
702
+ r2.ads.debug("Received nopreroll event"), r2.ads.nopreroll_ = true;
703
+ }), r2.on("nopostroll", function() {
704
+ r2.ads.debug("Received nopostroll event"), r2.ads.nopostroll_ = true;
705
+ }), r2.on("playing", function() {
706
+ r2.ads._cancelledPlay = false, r2.ads._pausedOnContentupdate = false;
707
+ }), r2.on("play", function() {
708
+ r2.ads._playRequested = true;
709
+ }), r2.one("loadstart", function() {
710
+ r2.ads._hasThereBeenALoadStartDuringPlayerLife = true;
711
+ }), r2.on("loadeddata", function() {
712
+ r2.ads._hasThereBeenALoadedData = true;
713
+ }), r2.on("loadedmetadata", function() {
714
+ r2.ads._hasThereBeenALoadedMetaData = true;
715
+ }), r2.ads = function(t2) {
716
+ return { disableNextSnapshotRestore: false, _contentEnding: false, _contentHasEnded: false, _hasThereBeenALoadStartDuringPlayerLife: false, _hasThereBeenALoadedData: false, _hasThereBeenALoadedMetaData: false, _inLinearAdMode: false, _shouldBlockPlay: false, _playBlocked: false, _playRequested: false, adType: null, VERSION: a, reset: function() {
717
+ t2.ads.disableNextSnapshotRestore = false, t2.ads._contentEnding = false, t2.ads._contentHasEnded = false, t2.ads.snapshot = null, t2.ads.adType = null, t2.ads._hasThereBeenALoadedData = false, t2.ads._hasThereBeenALoadedMetaData = false, t2.ads._cancelledPlay = false, t2.ads._shouldBlockPlay = false, t2.ads._playBlocked = false, t2.ads.nopreroll_ = false, t2.ads.nopostroll_ = false, t2.ads._playRequested = false;
718
+ }, startLinearAdMode: function() {
719
+ t2.ads._state.startLinearAdMode();
720
+ }, endLinearAdMode: function() {
721
+ t2.ads._state.endLinearAdMode();
722
+ }, skipLinearAdMode: function() {
723
+ t2.ads._state.skipLinearAdMode();
724
+ }, stitchedAds: function(t3) {
725
+ return void 0 !== t3 && (e.log.warn("Using player.ads.stitchedAds() as a setter is deprecated, it should be set as an option upon initialization of contrib-ads."), this.settings.stitchedAds = !!t3), this.settings.stitchedAds;
726
+ }, videoElementRecycled: function() {
727
+ if (t2.ads.shouldPlayContentBehindAd(t2))
728
+ return false;
729
+ if (!this.snapshot)
730
+ throw new Error("You cannot use videoElementRecycled while there is no snapshot.");
731
+ var e2 = t2.tech_.src() !== this.snapshot.src, n2 = t2.currentSrc() !== this.snapshot.currentSrc;
732
+ return e2 || n2;
733
+ }, isLive: function(n2) {
734
+ return void 0 === n2 && (n2 = t2), "boolean" == typeof n2.ads.settings.contentIsLive ? n2.ads.settings.contentIsLive : n2.duration() === 1 / 0 || "8" === e.browser.IOS_VERSION && 0 === n2.duration();
735
+ }, shouldPlayContentBehindAd: function(n2) {
736
+ if (void 0 === n2 && (n2 = t2), n2)
737
+ return !!n2.ads.settings.liveCuePoints && !e.browser.IS_IOS && !e.browser.IS_ANDROID && n2.duration() === 1 / 0;
738
+ throw new Error("shouldPlayContentBehindAd requires a player as a param");
739
+ }, shouldTakeSnapshots: function(e2) {
740
+ return void 0 === e2 && (e2 = t2), !this.shouldPlayContentBehindAd(e2) && !this.stitchedAds();
741
+ }, isInAdMode: function() {
742
+ return this._state.isAdState();
743
+ }, isWaitingForAdBreak: function() {
744
+ return this._state.isWaitingForAdBreak();
745
+ }, isContentResuming: function() {
746
+ return this._state.isContentResuming();
747
+ }, isAdPlaying: function() {
748
+ return this._state.inAdBreak();
749
+ }, inAdBreak: function() {
750
+ return this._state.inAdBreak();
751
+ }, removeNativePoster: function() {
752
+ var e2 = t2.$(".vjs-tech");
753
+ e2 && e2.removeAttribute("poster");
754
+ }, debug: function() {
755
+ if (this.settings.debug) {
756
+ for (var t3 = arguments.length, n2 = new Array(t3), a2 = 0; a2 < t3; a2++)
757
+ n2[a2] = arguments[a2];
758
+ 1 === n2.length && "string" == typeof n2[0] ? e.log("ADS: " + n2[0]) : e.log.apply(e, ["ADS:"].concat(n2));
759
+ }
760
+ } };
761
+ }(r2), r2.ads.settings = i2, i2.stitchedAds = !!i2.stitchedAds, i2.stitchedAds ? r2.ads._state = new (k.getState("StitchedContentPlayback"))(r2) : r2.ads._state = new (k.getState("BeforePreroll"))(r2), r2.ads._state.init(r2), r2.ads.cueTextTracks = g, r2.ads.adMacroReplacement = function(a2, o3, r3) {
762
+ var i3 = this, s3 = {};
763
+ a2 = a2.replace(/{([^}=]+)=([^}]+)}/g, function(e2, t2, n2) {
764
+ return s3["{" + t2 + "}"] = n2, "{" + t2 + "}";
765
+ }), void 0 === o3 && (o3 = false);
766
+ var d3 = {};
767
+ for (var l2 in void 0 !== r3 && (d3 = r3), d3["{player.id}"] = this.options_["data-player"] || this.id_, d3["{player.height}"] = this.currentHeight(), d3["{player.width}"] = this.currentWidth(), d3["{mediainfo.id}"] = this.mediainfo ? this.mediainfo.id : "", d3["{mediainfo.name}"] = this.mediainfo ? this.mediainfo.name : "", d3["{mediainfo.duration}"] = this.mediainfo ? this.mediainfo.duration : "", d3["{player.duration}"] = this.duration(), d3["{player.pageUrl}"] = e.dom.isInFrame() ? n.referrer : t.location.href, d3["{playlistinfo.id}"] = this.playlistinfo ? this.playlistinfo.id : "", d3["{playlistinfo.name}"] = this.playlistinfo ? this.playlistinfo.name : "", d3["{timestamp}"] = new Date().getTime(), d3["{document.referrer}"] = n.referrer, d3["{window.location.href}"] = t.location.href, d3["{random}"] = Math.floor(1e12 * Math.random()), ["description", "tags", "reference_id", "ad_keys"].forEach(function(e2) {
768
+ i3.mediainfo && i3.mediainfo[e2] ? d3["{mediainfo." + e2 + "}"] = i3.mediainfo[e2] : s3["{mediainfo." + e2 + "}"] ? d3["{mediainfo." + e2 + "}"] = s3["{mediainfo." + e2 + "}"] : d3["{mediainfo." + e2 + "}"] = "";
769
+ }), p(this.mediainfo, d3, "custom_fields"), p(this.mediainfo, d3, "customFields"), Object.keys(c).forEach(function(e2) {
770
+ d3["{tcf." + e2 + "}"] = c[e2];
771
+ }), d3["{tcf.gdprAppliesInt}"] = c.gdprApplies ? 1 : 0, d3)
772
+ a2 = a2.split(l2).join(h(d3[l2], o3));
773
+ for (var u2 in a2 = a2.replace(/{pageVariable\.([^}]+)}/g, function(n2, a3) {
774
+ for (var r4, i4 = t, d4 = a3.split("."), l3 = 0; l3 < d4.length; l3++)
775
+ l3 === d4.length - 1 ? r4 = i4[d4[l3]] : i4 = i4[d4[l3]];
776
+ var u3 = typeof r4;
777
+ return null === r4 ? "null" : void 0 === r4 ? s3["{pageVariable." + a3 + "}"] ? s3["{pageVariable." + a3 + "}"] : (e.log.warn('Page variable "' + a3 + '" not found'), "") : "string" !== u3 && "number" !== u3 && "boolean" !== u3 ? (e.log.warn('Page variable "' + a3 + '" is not a supported type'), "") : h(String(r4), o3);
778
+ }), s3)
779
+ a2 = a2.replace(u2, s3[u2]);
780
+ return a2;
781
+ }.bind(r2), function(e2) {
782
+ e2.ads.contentSrc = e2.currentSrc(), e2.ads._seenInitialLoadstart = false, e2.on("loadstart", function() {
783
+ if (!e2.ads.inAdBreak()) {
784
+ var t2 = e2.currentSrc();
785
+ t2 !== e2.ads.contentSrc && (e2.ads._seenInitialLoadstart && e2.trigger({ type: "contentchanged" }), e2.trigger({ type: "contentupdate", oldValue: e2.ads.contentSrc, newValue: t2 }), e2.ads.contentSrc = t2), e2.ads._seenInitialLoadstart = true;
786
+ }
787
+ });
788
+ }(r2), r2.on("contentchanged", r2.ads.reset);
789
+ var d2 = function() {
790
+ var t2 = r2.textTracks();
791
+ if (!r2.ads.shouldPlayContentBehindAd(r2) && r2.ads.inAdBreak() && r2.tech_.featuresNativeTextTracks && e.browser.IS_IOS && !Array.isArray(r2.textTracks()))
792
+ for (var n2 = 0; n2 < t2.length; n2++) {
793
+ var a2 = t2[n2];
794
+ "showing" === a2.mode && (a2.mode = "disabled");
795
+ }
796
+ };
797
+ r2.ready(function() {
798
+ r2.textTracks().addEventListener("change", d2);
799
+ }), r2.on(["play", "playing", "ended", "adsready", "adscanceled", "adskip", "adserror", "adtimeout", "adended", "ads-ad-started", "contentchanged", "dispose", "contentresumed", "readyforpostroll", "nopreroll", "nopostroll"], function(e2) {
800
+ r2.ads._state.handleEvent(e2.type);
801
+ }), r2.on("dispose", function() {
802
+ r2.ads.reset(), r2.textTracks().removeEventListener("change", d2);
803
+ }), f(), r2.ads.listenToTcf = f;
804
+ };
805
+ return q.VERSION = a, function(t2) {
806
+ !b(e) && ((e.registerPlugin || e.plugin)("ads", t2), P() && !e.usingContribAdsMiddleware_ && (e.use("*", _), e.usingContribAdsMiddleware_ = true, e.log.debug("Play middleware has been registered with videojs")));
807
+ }(q), q;
808
+ });
809
+ }
810
+ });
811
+
812
+ // public/scripts/videojsx.vast.js
813
+ var require_videojsx_vast = __commonJS({
814
+ "public/scripts/videojsx.vast.js"() {
815
+ (() => {
816
+ var e = { 248: function(e2, t2) {
817
+ !function(e3) {
818
+ "use strict";
819
+ function t3(e4, t4) {
820
+ var i3 = Object.keys(e4);
821
+ if (Object.getOwnPropertySymbols) {
822
+ var r2 = Object.getOwnPropertySymbols(e4);
823
+ t4 && (r2 = r2.filter(function(t5) {
824
+ return Object.getOwnPropertyDescriptor(e4, t5).enumerable;
825
+ })), i3.push.apply(i3, r2);
826
+ }
827
+ return i3;
828
+ }
829
+ function i2(e4) {
830
+ for (var i3 = 1; i3 < arguments.length; i3++) {
831
+ var r2 = null != arguments[i3] ? arguments[i3] : {};
832
+ i3 % 2 ? t3(Object(r2), true).forEach(function(t4) {
833
+ s(e4, t4, r2[t4]);
834
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e4, Object.getOwnPropertyDescriptors(r2)) : t3(Object(r2)).forEach(function(t4) {
835
+ Object.defineProperty(e4, t4, Object.getOwnPropertyDescriptor(r2, t4));
836
+ });
837
+ }
838
+ return e4;
839
+ }
840
+ function r(e4) {
841
+ return r = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e5) {
842
+ return typeof e5;
843
+ } : function(e5) {
844
+ return e5 && "function" == typeof Symbol && e5.constructor === Symbol && e5 !== Symbol.prototype ? "symbol" : typeof e5;
845
+ }, r(e4);
846
+ }
847
+ function n(e4, t4) {
848
+ if (!(e4 instanceof t4))
849
+ throw new TypeError("Cannot call a class as a function");
850
+ }
851
+ function a(e4, t4) {
852
+ for (var i3 = 0; i3 < t4.length; i3++) {
853
+ var r2 = t4[i3];
854
+ r2.enumerable = r2.enumerable || false, r2.configurable = true, "value" in r2 && (r2.writable = true), Object.defineProperty(e4, r2.key, r2);
855
+ }
856
+ }
857
+ function o(e4, t4, i3) {
858
+ return t4 && a(e4.prototype, t4), i3 && a(e4, i3), Object.defineProperty(e4, "prototype", { writable: false }), e4;
859
+ }
860
+ function s(e4, t4, i3) {
861
+ return t4 in e4 ? Object.defineProperty(e4, t4, { value: i3, enumerable: true, configurable: true, writable: true }) : e4[t4] = i3, e4;
862
+ }
863
+ function l(e4, t4) {
864
+ if ("function" != typeof t4 && null !== t4)
865
+ throw new TypeError("Super expression must either be null or a function");
866
+ e4.prototype = Object.create(t4 && t4.prototype, { constructor: { value: e4, writable: true, configurable: true } }), Object.defineProperty(e4, "prototype", { writable: false }), t4 && u(e4, t4);
867
+ }
868
+ function c(e4) {
869
+ return c = Object.setPrototypeOf ? Object.getPrototypeOf : function(e5) {
870
+ return e5.__proto__ || Object.getPrototypeOf(e5);
871
+ }, c(e4);
872
+ }
873
+ function u(e4, t4) {
874
+ return u = Object.setPrototypeOf || function(e5, t5) {
875
+ return e5.__proto__ = t5, e5;
876
+ }, u(e4, t4);
877
+ }
878
+ function d(e4, t4) {
879
+ if (t4 && ("object" == typeof t4 || "function" == typeof t4))
880
+ return t4;
881
+ if (void 0 !== t4)
882
+ throw new TypeError("Derived constructors may only return object or undefined");
883
+ return function(e5) {
884
+ if (void 0 === e5)
885
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
886
+ return e5;
887
+ }(e4);
888
+ }
889
+ function p(e4) {
890
+ var t4 = function() {
891
+ if ("undefined" == typeof Reflect || !Reflect.construct)
892
+ return false;
893
+ if (Reflect.construct.sham)
894
+ return false;
895
+ if ("function" == typeof Proxy)
896
+ return true;
897
+ try {
898
+ return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
899
+ })), true;
900
+ } catch (e5) {
901
+ return false;
902
+ }
903
+ }();
904
+ return function() {
905
+ var i3, r2 = c(e4);
906
+ if (t4) {
907
+ var n2 = c(this).constructor;
908
+ i3 = Reflect.construct(r2, arguments, n2);
909
+ } else
910
+ i3 = r2.apply(this, arguments);
911
+ return d(this, i3);
912
+ };
913
+ }
914
+ function h(e4) {
915
+ return function(e5) {
916
+ if (Array.isArray(e5))
917
+ return f(e5);
918
+ }(e4) || function(e5) {
919
+ if ("undefined" != typeof Symbol && null != e5[Symbol.iterator] || null != e5["@@iterator"])
920
+ return Array.from(e5);
921
+ }(e4) || function(e5, t4) {
922
+ if (e5) {
923
+ if ("string" == typeof e5)
924
+ return f(e5, t4);
925
+ var i3 = Object.prototype.toString.call(e5).slice(8, -1);
926
+ return "Object" === i3 && e5.constructor && (i3 = e5.constructor.name), "Map" === i3 || "Set" === i3 ? Array.from(e5) : "Arguments" === i3 || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i3) ? f(e5, t4) : void 0;
927
+ }
928
+ }(e4) || function() {
929
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
930
+ }();
931
+ }
932
+ function f(e4, t4) {
933
+ (null == t4 || t4 > e4.length) && (t4 = e4.length);
934
+ for (var i3 = 0, r2 = new Array(t4); i3 < t4; i3++)
935
+ r2[i3] = e4[i3];
936
+ return r2;
937
+ }
938
+ function m() {
939
+ var e4 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
940
+ return { id: e4.id || null, adId: e4.adId || null, sequence: e4.sequence || null, apiFramework: e4.apiFramework || null, universalAdIds: [], creativeExtensions: [] };
941
+ }
942
+ var v = ["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"];
943
+ function g(e4) {
944
+ var t4 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, i3 = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {}, r2 = [], n2 = T(e4);
945
+ for (var a2 in !t4.ERRORCODE || i3.isCustomCode || /^[0-9]{3}$/.test(t4.ERRORCODE) || (t4.ERRORCODE = 900), t4.CACHEBUSTING = R(Math.round(1e8 * Math.random())), t4.TIMESTAMP = new Date().toISOString(), t4.RANDOM = t4.random = t4.CACHEBUSTING, t4)
946
+ t4[a2] = E(t4[a2]);
947
+ for (var o2 in n2) {
948
+ var s2 = n2[o2];
949
+ "string" == typeof s2 && r2.push(y(s2, t4));
950
+ }
951
+ return r2;
952
+ }
953
+ function y(e4, t4) {
954
+ var i3 = (e4 = A(e4, t4)).match(/[^[\]]+(?=])/g);
955
+ if (!i3)
956
+ return e4;
957
+ var r2 = i3.filter(function(e5) {
958
+ return v.indexOf(e5) > -1;
959
+ });
960
+ return 0 === r2.length ? e4 : A(e4, r2 = r2.reduce(function(e5, t5) {
961
+ return e5[t5] = -1, e5;
962
+ }, {}));
963
+ }
964
+ function A(e4, t4) {
965
+ var i3 = e4;
966
+ for (var r2 in t4) {
967
+ var n2 = t4[r2];
968
+ i3 = i3.replace(new RegExp("(?:\\[|%%)(".concat(r2, ")(?:\\]|%%)"), "g"), n2);
969
+ }
970
+ return i3;
971
+ }
972
+ function T(e4) {
973
+ return Array.isArray(e4) ? e4.map(function(e5) {
974
+ return e5 && e5.hasOwnProperty("url") ? e5.url : e5;
975
+ }) : e4;
976
+ }
977
+ function k(e4, t4) {
978
+ for (var i3 = 0; i3 < t4.length; i3++)
979
+ if (b(t4[i3], e4))
980
+ return true;
981
+ return false;
982
+ }
983
+ function b(e4, t4) {
984
+ if (e4 && t4) {
985
+ var i3 = Object.getOwnPropertyNames(e4), r2 = Object.getOwnPropertyNames(t4);
986
+ return i3.length === r2.length && e4.id === t4.id && e4.url === t4.url;
987
+ }
988
+ return false;
989
+ }
990
+ function E(e4) {
991
+ return encodeURIComponent(e4).replace(/[!'()*]/g, function(e5) {
992
+ return "%".concat(e5.charCodeAt(0).toString(16));
993
+ });
994
+ }
995
+ function R(e4) {
996
+ var t4 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 8;
997
+ return e4.toString().padStart(t4, "0");
998
+ }
999
+ var w = { track: function(e4, t4, i3) {
1000
+ g(e4, t4, i3).forEach(function(e5) {
1001
+ "undefined" != typeof window && null !== window && (new Image().src = e5);
1002
+ });
1003
+ }, resolveURLTemplates: g, extractURLsFromTemplates: T, containsTemplateObject: k, isTemplateObjectEqual: b, encodeURIComponentRFC3986: E, replaceUrlMacros: y, isNumeric: function(e4) {
1004
+ return !isNaN(parseFloat(e4)) && isFinite(e4);
1005
+ }, flatten: function e4(t4) {
1006
+ return t4.reduce(function(t5, i3) {
1007
+ return t5.concat(Array.isArray(i3) ? e4(i3) : i3);
1008
+ }, []);
1009
+ }, joinArrayOfUniqueTemplateObjs: function() {
1010
+ var e4 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [], t4 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : [], i3 = Array.isArray(e4) ? e4 : [], r2 = Array.isArray(t4) ? t4 : [];
1011
+ return i3.concat(r2).reduce(function(e5, t5) {
1012
+ return k(t5, e5) || e5.push(t5), e5;
1013
+ }, []);
1014
+ }, isValidTimeValue: function(e4) {
1015
+ return Number.isFinite(e4) && e4 >= -2;
1016
+ }, addLeadingZeros: R };
1017
+ function N(e4) {
1018
+ return -1 !== ["true", "TRUE", "True", "1"].indexOf(e4);
1019
+ }
1020
+ var C = { childByName: function(e4, t4) {
1021
+ var i3 = e4.childNodes;
1022
+ for (var r2 in i3) {
1023
+ var n2 = i3[r2];
1024
+ if (n2.nodeName === t4)
1025
+ return n2;
1026
+ }
1027
+ }, childrenByName: function(e4, t4) {
1028
+ var i3 = [], r2 = e4.childNodes;
1029
+ for (var n2 in r2) {
1030
+ var a2 = r2[n2];
1031
+ a2.nodeName === t4 && i3.push(a2);
1032
+ }
1033
+ return i3;
1034
+ }, resolveVastAdTagURI: function(e4, t4) {
1035
+ if (!t4)
1036
+ return e4;
1037
+ if (0 === e4.indexOf("//")) {
1038
+ var i3 = location.protocol;
1039
+ return "".concat(i3).concat(e4);
1040
+ }
1041
+ if (-1 === e4.indexOf("://")) {
1042
+ var r2 = t4.slice(0, t4.lastIndexOf("/"));
1043
+ return "".concat(r2, "/").concat(e4);
1044
+ }
1045
+ return e4;
1046
+ }, parseBoolean: N, parseNodeText: function(e4) {
1047
+ return e4 && (e4.textContent || e4.text || "").trim();
1048
+ }, copyNodeAttribute: function(e4, t4, i3) {
1049
+ var r2 = t4.getAttribute(e4);
1050
+ r2 && i3.setAttribute(e4, r2);
1051
+ }, parseAttributes: function(e4) {
1052
+ for (var t4 = e4.attributes, i3 = {}, r2 = 0; r2 < t4.length; r2++)
1053
+ i3[t4[r2].nodeName] = t4[r2].nodeValue;
1054
+ return i3;
1055
+ }, parseDuration: function(e4) {
1056
+ if (null == e4)
1057
+ return -1;
1058
+ if (w.isNumeric(e4))
1059
+ return parseInt(e4);
1060
+ var t4 = e4.split(":");
1061
+ if (3 !== t4.length)
1062
+ return -1;
1063
+ var i3 = t4[2].split("."), r2 = parseInt(i3[0]);
1064
+ 2 === i3.length && (r2 += parseFloat("0.".concat(i3[1])));
1065
+ var n2 = parseInt(60 * t4[1]), a2 = parseInt(60 * t4[0] * 60);
1066
+ return isNaN(a2) || isNaN(n2) || isNaN(r2) || n2 > 3600 || r2 > 60 ? -1 : a2 + n2 + r2;
1067
+ }, splitVAST: function(e4) {
1068
+ var t4 = [], i3 = null;
1069
+ return e4.forEach(function(r2, n2) {
1070
+ if (r2.sequence && (r2.sequence = parseInt(r2.sequence, 10)), r2.sequence > 1) {
1071
+ var a2 = e4[n2 - 1];
1072
+ if (a2 && a2.sequence === r2.sequence - 1)
1073
+ return void (i3 && i3.push(r2));
1074
+ delete r2.sequence;
1075
+ }
1076
+ i3 = [r2], t4.push(i3);
1077
+ }), t4;
1078
+ }, assignAttributes: function(e4, t4) {
1079
+ if (e4)
1080
+ for (var i3 in e4) {
1081
+ var r2 = e4[i3];
1082
+ if (r2.nodeName && r2.nodeValue && t4.hasOwnProperty(r2.nodeName)) {
1083
+ var n2 = r2.nodeValue;
1084
+ "boolean" == typeof t4[r2.nodeName] && (n2 = N(n2)), t4[r2.nodeName] = n2;
1085
+ }
1086
+ }
1087
+ }, mergeWrapperAdData: function(e4, t4) {
1088
+ e4.errorURLTemplates = t4.errorURLTemplates.concat(e4.errorURLTemplates), e4.impressionURLTemplates = t4.impressionURLTemplates.concat(e4.impressionURLTemplates), e4.extensions = t4.extensions.concat(e4.extensions), t4.viewableImpression.length > 0 && (e4.viewableImpression = [].concat(h(e4.viewableImpression), h(t4.viewableImpression))), e4.followAdditionalWrappers = t4.followAdditionalWrappers, e4.allowMultipleAds = t4.allowMultipleAds, e4.fallbackOnNoAd = t4.fallbackOnNoAd;
1089
+ var i3 = (t4.creatives || []).filter(function(e5) {
1090
+ return e5 && "companion" === e5.type;
1091
+ }), r2 = i3.reduce(function(e5, t5) {
1092
+ return (t5.variations || []).forEach(function(t6) {
1093
+ (t6.companionClickTrackingURLTemplates || []).forEach(function(t7) {
1094
+ w.containsTemplateObject(t7, e5) || e5.push(t7);
1095
+ });
1096
+ }), e5;
1097
+ }, []);
1098
+ e4.creatives = i3.concat(e4.creatives);
1099
+ var n2 = t4.videoClickTrackingURLTemplates && t4.videoClickTrackingURLTemplates.length, a2 = t4.videoCustomClickURLTemplates && t4.videoCustomClickURLTemplates.length;
1100
+ e4.creatives.forEach(function(e5) {
1101
+ if (t4.trackingEvents && t4.trackingEvents[e5.type])
1102
+ for (var i4 in t4.trackingEvents[e5.type]) {
1103
+ var o2 = t4.trackingEvents[e5.type][i4];
1104
+ Array.isArray(e5.trackingEvents[i4]) || (e5.trackingEvents[i4] = []), e5.trackingEvents[i4] = e5.trackingEvents[i4].concat(o2);
1105
+ }
1106
+ "linear" === e5.type && (n2 && (e5.videoClickTrackingURLTemplates = e5.videoClickTrackingURLTemplates.concat(t4.videoClickTrackingURLTemplates)), a2 && (e5.videoCustomClickURLTemplates = e5.videoCustomClickURLTemplates.concat(t4.videoCustomClickURLTemplates)), !t4.videoClickThroughURLTemplate || null !== e5.videoClickThroughURLTemplate && void 0 !== e5.videoClickThroughURLTemplate || (e5.videoClickThroughURLTemplate = t4.videoClickThroughURLTemplate)), "companion" === e5.type && r2.length && (e5.variations || []).forEach(function(e6) {
1107
+ e6.companionClickTrackingURLTemplates = w.joinArrayOfUniqueTemplateObjs(e6.companionClickTrackingURLTemplates, r2);
1108
+ });
1109
+ }), t4.adVerifications && (e4.adVerifications = e4.adVerifications.concat(t4.adVerifications)), t4.blockedAdCategories && (e4.blockedAdCategories = e4.blockedAdCategories.concat(t4.blockedAdCategories));
1110
+ } };
1111
+ function L(e4, t4) {
1112
+ var i3 = function() {
1113
+ var e5 = m(arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {});
1114
+ return { id: e5.id, adId: e5.adId, sequence: e5.sequence, apiFramework: e5.apiFramework, type: "companion", required: null, variations: [] };
1115
+ }(t4);
1116
+ return i3.required = e4.getAttribute("required") || null, i3.variations = C.childrenByName(e4, "Companion").map(function(e5) {
1117
+ var t5 = function() {
1118
+ var e6 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
1119
+ return { id: e6.id || null, adType: "companionAd", width: e6.width || 0, height: e6.height || 0, assetWidth: e6.assetWidth || null, assetHeight: e6.assetHeight || null, expandedWidth: e6.expandedWidth || null, expandedHeight: e6.expandedHeight || null, apiFramework: e6.apiFramework || null, adSlotID: e6.adSlotID || null, pxratio: e6.pxratio || "1", renderingMode: e6.renderingMode || "default", staticResources: [], htmlResources: [], iframeResources: [], adParameters: null, xmlEncoded: null, altText: null, companionClickThroughURLTemplate: null, companionClickTrackingURLTemplates: [], trackingEvents: {} };
1120
+ }(C.parseAttributes(e5));
1121
+ t5.htmlResources = C.childrenByName(e5, "HTMLResource").reduce(function(e6, t6) {
1122
+ var i5 = C.parseNodeText(t6);
1123
+ return i5 ? e6.concat(i5) : e6;
1124
+ }, []), t5.iframeResources = C.childrenByName(e5, "IFrameResource").reduce(function(e6, t6) {
1125
+ var i5 = C.parseNodeText(t6);
1126
+ return i5 ? e6.concat(i5) : e6;
1127
+ }, []), t5.staticResources = C.childrenByName(e5, "StaticResource").reduce(function(e6, t6) {
1128
+ var i5 = C.parseNodeText(t6);
1129
+ return i5 ? e6.concat({ url: i5, creativeType: t6.getAttribute("creativeType") || null }) : e6;
1130
+ }, []), t5.altText = C.parseNodeText(C.childByName(e5, "AltText")) || null;
1131
+ var i4 = C.childByName(e5, "TrackingEvents");
1132
+ i4 && C.childrenByName(i4, "Tracking").forEach(function(e6) {
1133
+ var i5 = e6.getAttribute("event"), r3 = C.parseNodeText(e6);
1134
+ i5 && r3 && (Array.isArray(t5.trackingEvents[i5]) || (t5.trackingEvents[i5] = []), t5.trackingEvents[i5].push(r3));
1135
+ }), t5.companionClickTrackingURLTemplates = C.childrenByName(e5, "CompanionClickTracking").map(function(e6) {
1136
+ return { id: e6.getAttribute("id") || null, url: C.parseNodeText(e6) };
1137
+ }), t5.companionClickThroughURLTemplate = C.parseNodeText(C.childByName(e5, "CompanionClickThrough")) || null;
1138
+ var r2 = C.childByName(e5, "AdParameters");
1139
+ return r2 && (t5.adParameters = C.parseNodeText(r2), t5.xmlEncoded = r2.getAttribute("xmlEncoded") || null), t5;
1140
+ }), i3;
1141
+ }
1142
+ function I(e4) {
1143
+ return "linear" === e4.type;
1144
+ }
1145
+ function U(e4, t4) {
1146
+ var i3, r2 = function() {
1147
+ var e5 = m(arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {});
1148
+ return { id: e5.id, adId: e5.adId, sequence: e5.sequence, apiFramework: e5.apiFramework, type: "linear", duration: 0, skipDelay: null, mediaFiles: [], mezzanine: null, interactiveCreativeFile: null, closedCaptionFiles: [], videoClickThroughURLTemplate: null, videoClickTrackingURLTemplates: [], videoCustomClickURLTemplates: [], adParameters: null, icons: [], trackingEvents: {} };
1149
+ }(t4);
1150
+ r2.duration = C.parseDuration(C.parseNodeText(C.childByName(e4, "Duration")));
1151
+ var n2 = e4.getAttribute("skipoffset");
1152
+ if (null == n2)
1153
+ r2.skipDelay = null;
1154
+ else if ("%" === n2.charAt(n2.length - 1) && -1 !== r2.duration) {
1155
+ var a2 = parseInt(n2, 10);
1156
+ r2.skipDelay = r2.duration * (a2 / 100);
1157
+ } else
1158
+ r2.skipDelay = C.parseDuration(n2);
1159
+ var o2 = C.childByName(e4, "VideoClicks");
1160
+ if (o2) {
1161
+ var s2 = C.childByName(o2, "ClickThrough");
1162
+ r2.videoClickThroughURLTemplate = s2 ? { id: s2.getAttribute("id") || null, url: C.parseNodeText(s2) } : null, C.childrenByName(o2, "ClickTracking").forEach(function(e5) {
1163
+ r2.videoClickTrackingURLTemplates.push({ id: e5.getAttribute("id") || null, url: C.parseNodeText(e5) });
1164
+ }), C.childrenByName(o2, "CustomClick").forEach(function(e5) {
1165
+ r2.videoCustomClickURLTemplates.push({ id: e5.getAttribute("id") || null, url: C.parseNodeText(e5) });
1166
+ });
1167
+ }
1168
+ var l2 = C.childByName(e4, "AdParameters");
1169
+ l2 && (r2.adParameters = C.parseNodeText(l2)), C.childrenByName(e4, "TrackingEvents").forEach(function(e5) {
1170
+ C.childrenByName(e5, "Tracking").forEach(function(e6) {
1171
+ var t5 = e6.getAttribute("event"), n3 = C.parseNodeText(e6);
1172
+ if (t5 && n3) {
1173
+ if ("progress" === t5) {
1174
+ if (!(i3 = e6.getAttribute("offset")))
1175
+ return;
1176
+ t5 = "%" === i3.charAt(i3.length - 1) ? "progress-".concat(i3) : "progress-".concat(Math.round(C.parseDuration(i3)));
1177
+ }
1178
+ Array.isArray(r2.trackingEvents[t5]) || (r2.trackingEvents[t5] = []), r2.trackingEvents[t5].push(n3);
1179
+ }
1180
+ });
1181
+ }), C.childrenByName(e4, "MediaFiles").forEach(function(e5) {
1182
+ C.childrenByName(e5, "MediaFile").forEach(function(e6) {
1183
+ r2.mediaFiles.push(function(e7) {
1184
+ var t6 = { 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 };
1185
+ t6.id = e7.getAttribute("id"), t6.fileURL = C.parseNodeText(e7), t6.deliveryType = e7.getAttribute("delivery"), t6.codec = e7.getAttribute("codec"), t6.mimeType = e7.getAttribute("type"), t6.mediaType = e7.getAttribute("mediaType") || "2D", t6.apiFramework = e7.getAttribute("apiFramework"), t6.fileSize = parseInt(e7.getAttribute("fileSize") || 0), t6.bitrate = parseInt(e7.getAttribute("bitrate") || 0), t6.minBitrate = parseInt(e7.getAttribute("minBitrate") || 0), t6.maxBitrate = parseInt(e7.getAttribute("maxBitrate") || 0), t6.width = parseInt(e7.getAttribute("width") || 0), t6.height = parseInt(e7.getAttribute("height") || 0);
1186
+ var i5 = e7.getAttribute("scalable");
1187
+ i5 && "string" == typeof i5 && (t6.scalable = C.parseBoolean(i5));
1188
+ var r3 = e7.getAttribute("maintainAspectRatio");
1189
+ return r3 && "string" == typeof r3 && (t6.maintainAspectRatio = C.parseBoolean(r3)), t6;
1190
+ }(e6));
1191
+ });
1192
+ var t5 = C.childByName(e5, "InteractiveCreativeFile");
1193
+ t5 && (r2.interactiveCreativeFile = function(e6) {
1194
+ var t6 = function() {
1195
+ var e7 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
1196
+ return { type: e7.type || null, apiFramework: e7.apiFramework || null, variableDuration: C.parseBoolean(e7.variableDuration), fileURL: null };
1197
+ }(C.parseAttributes(e6));
1198
+ return t6.fileURL = C.parseNodeText(e6), t6;
1199
+ }(t5));
1200
+ var i4 = C.childByName(e5, "ClosedCaptionFiles");
1201
+ i4 && C.childrenByName(i4, "ClosedCaptionFile").forEach(function(e6) {
1202
+ var t6 = function() {
1203
+ var e7 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
1204
+ return { type: e7.type || null, language: e7.language || null, fileURL: null };
1205
+ }(C.parseAttributes(e6));
1206
+ t6.fileURL = C.parseNodeText(e6), r2.closedCaptionFiles.push(t6);
1207
+ });
1208
+ var n3, a3, o3, s3 = C.childByName(e5, "Mezzanine"), l3 = (n3 = s3, a3 = {}, o3 = false, ["delivery", "type", "width", "height"].forEach(function(e6) {
1209
+ n3 && n3.getAttribute(e6) ? a3[e6] = n3.getAttribute(e6) : o3 = true;
1210
+ }), o3 ? null : a3);
1211
+ if (l3) {
1212
+ var c3 = { id: null, fileURL: null, delivery: null, codec: null, type: null, width: 0, height: 0, fileSize: 0, mediaType: "2D" };
1213
+ c3.id = s3.getAttribute("id"), c3.fileURL = C.parseNodeText(s3), c3.delivery = l3.delivery, c3.codec = s3.getAttribute("codec"), c3.type = l3.type, c3.width = parseInt(l3.width, 10), c3.height = parseInt(l3.height, 10), c3.fileSize = parseInt(s3.getAttribute("fileSize"), 10), c3.mediaType = s3.getAttribute("mediaType") || "2D", r2.mezzanine = c3;
1214
+ }
1215
+ });
1216
+ var c2 = C.childByName(e4, "Icons");
1217
+ return c2 && C.childrenByName(c2, "Icon").forEach(function(e5) {
1218
+ r2.icons.push(function(e6) {
1219
+ var t5 = { 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 };
1220
+ t5.program = e6.getAttribute("program"), t5.height = parseInt(e6.getAttribute("height") || 0), t5.width = parseInt(e6.getAttribute("width") || 0), t5.xPosition = function(e7) {
1221
+ return -1 !== ["left", "right"].indexOf(e7) ? e7 : parseInt(e7 || 0);
1222
+ }(e6.getAttribute("xPosition")), t5.yPosition = function(e7) {
1223
+ return -1 !== ["top", "bottom"].indexOf(e7) ? e7 : parseInt(e7 || 0);
1224
+ }(e6.getAttribute("yPosition")), t5.apiFramework = e6.getAttribute("apiFramework"), t5.pxratio = e6.getAttribute("pxratio") || "1", t5.offset = C.parseDuration(e6.getAttribute("offset")), t5.duration = C.parseDuration(e6.getAttribute("duration")), C.childrenByName(e6, "HTMLResource").forEach(function(e7) {
1225
+ t5.type = e7.getAttribute("creativeType") || "text/html", t5.htmlResource = C.parseNodeText(e7);
1226
+ }), C.childrenByName(e6, "IFrameResource").forEach(function(e7) {
1227
+ t5.type = e7.getAttribute("creativeType") || 0, t5.iframeResource = C.parseNodeText(e7);
1228
+ }), C.childrenByName(e6, "StaticResource").forEach(function(e7) {
1229
+ t5.type = e7.getAttribute("creativeType") || 0, t5.staticResource = C.parseNodeText(e7);
1230
+ });
1231
+ var i4 = C.childByName(e6, "IconClicks");
1232
+ return i4 && (t5.iconClickThroughURLTemplate = C.parseNodeText(C.childByName(i4, "IconClickThrough")), C.childrenByName(i4, "IconClickTracking").forEach(function(e7) {
1233
+ t5.iconClickTrackingURLTemplates.push({ id: e7.getAttribute("id") || null, url: C.parseNodeText(e7) });
1234
+ })), t5.iconViewTrackingURLTemplate = C.parseNodeText(C.childByName(e6, "IconViewTracking")), t5;
1235
+ }(e5));
1236
+ }), r2;
1237
+ }
1238
+ function S(e4, t4) {
1239
+ var i3 = function() {
1240
+ var e5 = m(arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {});
1241
+ return { id: e5.id, adId: e5.adId, sequence: e5.sequence, apiFramework: e5.apiFramework, type: "nonlinear", variations: [], trackingEvents: {} };
1242
+ }(t4);
1243
+ return C.childrenByName(e4, "TrackingEvents").forEach(function(e5) {
1244
+ var t5, r2;
1245
+ C.childrenByName(e5, "Tracking").forEach(function(e6) {
1246
+ t5 = e6.getAttribute("event"), r2 = C.parseNodeText(e6), t5 && r2 && (Array.isArray(i3.trackingEvents[t5]) || (i3.trackingEvents[t5] = []), i3.trackingEvents[t5].push(r2));
1247
+ });
1248
+ }), C.childrenByName(e4, "NonLinear").forEach(function(e5) {
1249
+ var t5 = { id: null, width: 0, height: 0, expandedWidth: 0, expandedHeight: 0, scalable: true, maintainAspectRatio: true, minSuggestedDuration: 0, apiFramework: "static", adType: "nonLinearAd", type: null, staticResource: null, htmlResource: null, iframeResource: null, nonlinearClickThroughURLTemplate: null, nonlinearClickTrackingURLTemplates: [], adParameters: null };
1250
+ t5.id = e5.getAttribute("id") || null, t5.width = e5.getAttribute("width"), t5.height = e5.getAttribute("height"), t5.expandedWidth = e5.getAttribute("expandedWidth"), t5.expandedHeight = e5.getAttribute("expandedHeight"), t5.scalable = C.parseBoolean(e5.getAttribute("scalable")), t5.maintainAspectRatio = C.parseBoolean(e5.getAttribute("maintainAspectRatio")), t5.minSuggestedDuration = C.parseDuration(e5.getAttribute("minSuggestedDuration")), t5.apiFramework = e5.getAttribute("apiFramework"), C.childrenByName(e5, "HTMLResource").forEach(function(e6) {
1251
+ t5.type = e6.getAttribute("creativeType") || "text/html", t5.htmlResource = C.parseNodeText(e6);
1252
+ }), C.childrenByName(e5, "IFrameResource").forEach(function(e6) {
1253
+ t5.type = e6.getAttribute("creativeType") || 0, t5.iframeResource = C.parseNodeText(e6);
1254
+ }), C.childrenByName(e5, "StaticResource").forEach(function(e6) {
1255
+ t5.type = e6.getAttribute("creativeType") || 0, t5.staticResource = C.parseNodeText(e6);
1256
+ });
1257
+ var r2 = C.childByName(e5, "AdParameters");
1258
+ r2 && (t5.adParameters = C.parseNodeText(r2)), t5.nonlinearClickThroughURLTemplate = C.parseNodeText(C.childByName(e5, "NonLinearClickThrough")), C.childrenByName(e5, "NonLinearClickTracking").forEach(function(e6) {
1259
+ t5.nonlinearClickTrackingURLTemplates.push({ id: e6.getAttribute("id") || null, url: C.parseNodeText(e6) });
1260
+ }), i3.variations.push(t5);
1261
+ }), i3;
1262
+ }
1263
+ function x(e4) {
1264
+ var t4 = [];
1265
+ return e4.forEach(function(e5) {
1266
+ var i3 = D(e5);
1267
+ i3 && t4.push(i3);
1268
+ }), t4;
1269
+ }
1270
+ function D(e4) {
1271
+ if ("#comment" === e4.nodeName)
1272
+ return null;
1273
+ var t4, i3 = { name: null, value: null, attributes: {}, children: [] }, r2 = e4.attributes, n2 = e4.childNodes;
1274
+ if (i3.name = e4.nodeName, e4.attributes) {
1275
+ for (var a2 in r2)
1276
+ if (r2.hasOwnProperty(a2)) {
1277
+ var o2 = r2[a2];
1278
+ o2.nodeName && o2.nodeValue && (i3.attributes[o2.nodeName] = o2.nodeValue);
1279
+ }
1280
+ }
1281
+ for (var s2 in n2)
1282
+ if (n2.hasOwnProperty(s2)) {
1283
+ var l2 = D(n2[s2]);
1284
+ l2 && i3.children.push(l2);
1285
+ }
1286
+ if (0 === i3.children.length || 1 === i3.children.length && ["#cdata-section", "#text"].indexOf(i3.children[0].name) >= 0) {
1287
+ var c2 = C.parseNodeText(e4);
1288
+ "" !== c2 && (i3.value = c2), i3.children = [];
1289
+ }
1290
+ return null === (t4 = i3).value && 0 === Object.keys(t4.attributes).length && 0 === t4.children.length ? null : i3;
1291
+ }
1292
+ function O(e4) {
1293
+ var t4 = [];
1294
+ return e4.forEach(function(e5) {
1295
+ var i3, r2 = { id: e5.getAttribute("id") || null, adId: V(e5), sequence: e5.getAttribute("sequence") || null, apiFramework: e5.getAttribute("apiFramework") || null }, n2 = [];
1296
+ C.childrenByName(e5, "UniversalAdId").forEach(function(e6) {
1297
+ var t5 = { idRegistry: e6.getAttribute("idRegistry") || "unknown", value: C.parseNodeText(e6) };
1298
+ n2.push(t5);
1299
+ });
1300
+ var a2 = C.childByName(e5, "CreativeExtensions");
1301
+ for (var o2 in a2 && (i3 = x(C.childrenByName(a2, "CreativeExtension"))), e5.childNodes) {
1302
+ var s2 = e5.childNodes[o2], l2 = void 0;
1303
+ switch (s2.nodeName) {
1304
+ case "Linear":
1305
+ l2 = U(s2, r2);
1306
+ break;
1307
+ case "NonLinearAds":
1308
+ l2 = S(s2, r2);
1309
+ break;
1310
+ case "CompanionAds":
1311
+ l2 = L(s2, r2);
1312
+ }
1313
+ l2 && (n2 && (l2.universalAdIds = n2), i3 && (l2.creativeExtensions = i3), t4.push(l2));
1314
+ }
1315
+ }), t4;
1316
+ }
1317
+ function V(e4) {
1318
+ return e4.getAttribute("AdID") || e4.getAttribute("adID") || e4.getAttribute("adId") || null;
1319
+ }
1320
+ var P = { 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"] } };
1321
+ function M(e4, t4) {
1322
+ if (P[e4.nodeName] && P[e4.nodeName].attributes) {
1323
+ var i3 = P[e4.nodeName].attributes.filter(function(t5) {
1324
+ return !e4.getAttribute(t5);
1325
+ });
1326
+ i3.length > 0 && F({ name: e4.nodeName, parentName: e4.parentNode.nodeName, attributes: i3 }, t4);
1327
+ }
1328
+ }
1329
+ function B(e4, t4, i3) {
1330
+ var r2 = P[e4.nodeName], n2 = !i3 && "Wrapper" !== e4.nodeName;
1331
+ if (r2 && !n2) {
1332
+ if (r2.subElements) {
1333
+ var a2 = r2.subElements.filter(function(t5) {
1334
+ return !C.childByName(e4, t5);
1335
+ });
1336
+ a2.length > 0 && F({ name: e4.nodeName, parentName: e4.parentNode.nodeName, subElements: a2 }, t4);
1337
+ }
1338
+ i3 && r2.oneOfinLineResources && (r2.oneOfinLineResources.some(function(t5) {
1339
+ return C.childByName(e4, t5);
1340
+ }) || F({ name: e4.nodeName, parentName: e4.parentNode.nodeName, oneOfResources: r2.oneOfinLineResources }, t4));
1341
+ }
1342
+ }
1343
+ function _(e4) {
1344
+ return e4.children && 0 !== e4.children.length;
1345
+ }
1346
+ function F(e4, t4) {
1347
+ var i3 = e4.name, r2 = e4.parentName, n2 = e4.attributes, a2 = e4.subElements, o2 = e4.oneOfResources, s2 = "Element '".concat(i3, "'");
1348
+ t4("VAST-warning", { message: s2 += n2 ? " missing required attribute(s) '".concat(n2.join(", "), "' ") : a2 ? " missing required sub element(s) '".concat(a2.join(", "), "' ") : o2 ? " must provide one of the following '".concat(o2.join(", "), "' ") : " is empty", parentElement: r2, specVersion: 4.1 });
1349
+ }
1350
+ var j = { verifyRequiredValues: function e4(t4, i3, r2) {
1351
+ if (t4 && t4.nodeName)
1352
+ if ("InLine" === t4.nodeName && (r2 = true), M(t4, i3), _(t4)) {
1353
+ B(t4, i3, r2);
1354
+ for (var n2 = 0; n2 < t4.children.length; n2++)
1355
+ e4(t4.children[n2], i3, r2);
1356
+ } else
1357
+ 0 === C.parseNodeText(t4).length && F({ name: t4.nodeName, parentName: t4.parentNode.nodeName }, i3);
1358
+ }, hasSubElements: _, emitMissingValueWarning: F, verifyRequiredAttributes: M, verifyRequiredSubElements: B };
1359
+ function W(e4, t4) {
1360
+ var i3 = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {}, r2 = i3.allowMultipleAds, n2 = i3.followAdditionalWrappers, a2 = e4.childNodes;
1361
+ for (var o2 in a2) {
1362
+ var s2 = a2[o2];
1363
+ if (-1 !== ["Wrapper", "InLine"].indexOf(s2.nodeName) && ("Wrapper" !== s2.nodeName || false !== n2)) {
1364
+ if (C.copyNodeAttribute("id", e4, s2), C.copyNodeAttribute("sequence", e4, s2), C.copyNodeAttribute("adType", e4, s2), "Wrapper" === s2.nodeName)
1365
+ return { ad: z(s2, t4), type: "WRAPPER" };
1366
+ if ("InLine" === s2.nodeName)
1367
+ return { ad: H(s2, t4, { allowMultipleAds: r2 }), type: "INLINE" };
1368
+ }
1369
+ }
1370
+ }
1371
+ function H(e4, t4) {
1372
+ return false === (arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {}).allowMultipleAds && e4.getAttribute("sequence") ? null : q(e4, t4);
1373
+ }
1374
+ function q(e4, t4) {
1375
+ var i3 = [];
1376
+ t4 && j.verifyRequiredValues(e4, t4);
1377
+ var r2 = e4.childNodes, n2 = function() {
1378
+ var e5 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
1379
+ return { id: e5.id || null, sequence: e5.sequence || null, adType: e5.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: true, allowMultipleAds: false, fallbackOnNoAd: null };
1380
+ }(C.parseAttributes(e4));
1381
+ for (var a2 in r2) {
1382
+ var o2 = r2[a2];
1383
+ switch (o2.nodeName) {
1384
+ case "Error":
1385
+ n2.errorURLTemplates.push(C.parseNodeText(o2));
1386
+ break;
1387
+ case "Impression":
1388
+ n2.impressionURLTemplates.push({ id: o2.getAttribute("id") || null, url: C.parseNodeText(o2) });
1389
+ break;
1390
+ case "Creatives":
1391
+ n2.creatives = O(C.childrenByName(o2, "Creative"));
1392
+ break;
1393
+ case "Extensions":
1394
+ var s2 = C.childrenByName(o2, "Extension");
1395
+ n2.extensions = x(s2), n2.adVerifications.length || (i3 = Q(s2));
1396
+ break;
1397
+ case "AdVerifications":
1398
+ n2.adVerifications = G(C.childrenByName(o2, "Verification"));
1399
+ break;
1400
+ case "AdSystem":
1401
+ n2.system = { value: C.parseNodeText(o2), version: o2.getAttribute("version") || null };
1402
+ break;
1403
+ case "AdTitle":
1404
+ n2.title = C.parseNodeText(o2);
1405
+ break;
1406
+ case "AdServingId":
1407
+ n2.adServingId = C.parseNodeText(o2);
1408
+ break;
1409
+ case "Category":
1410
+ n2.categories.push({ authority: o2.getAttribute("authority") || null, value: C.parseNodeText(o2) });
1411
+ break;
1412
+ case "Expires":
1413
+ n2.expires = parseInt(C.parseNodeText(o2), 10);
1414
+ break;
1415
+ case "ViewableImpression":
1416
+ n2.viewableImpression.push(X(o2));
1417
+ break;
1418
+ case "Description":
1419
+ n2.description = C.parseNodeText(o2);
1420
+ break;
1421
+ case "Advertiser":
1422
+ n2.advertiser = { id: o2.getAttribute("id") || null, value: C.parseNodeText(o2) };
1423
+ break;
1424
+ case "Pricing":
1425
+ n2.pricing = { value: C.parseNodeText(o2), model: o2.getAttribute("model") || null, currency: o2.getAttribute("currency") || null };
1426
+ break;
1427
+ case "Survey":
1428
+ n2.survey = C.parseNodeText(o2);
1429
+ break;
1430
+ case "BlockedAdCategories":
1431
+ n2.blockedAdCategories.push({ authority: o2.getAttribute("authority") || null, value: C.parseNodeText(o2) });
1432
+ }
1433
+ }
1434
+ return i3.length && (n2.adVerifications = n2.adVerifications.concat(i3)), n2;
1435
+ }
1436
+ function z(e4, t4) {
1437
+ var i3 = q(e4, t4), r2 = e4.getAttribute("followAdditionalWrappers"), n2 = e4.getAttribute("allowMultipleAds"), a2 = e4.getAttribute("fallbackOnNoAd");
1438
+ i3.followAdditionalWrappers = !r2 || C.parseBoolean(r2), i3.allowMultipleAds = !!n2 && C.parseBoolean(n2), i3.fallbackOnNoAd = a2 ? C.parseBoolean(a2) : null;
1439
+ var o2 = C.childByName(e4, "VASTAdTagURI");
1440
+ if (o2 ? i3.nextWrapperURL = C.parseNodeText(o2) : (o2 = C.childByName(e4, "VASTAdTagURL")) && (i3.nextWrapperURL = C.parseNodeText(C.childByName(o2, "URL"))), i3.creatives.forEach(function(e5) {
1441
+ if (-1 !== ["linear", "nonlinear"].indexOf(e5.type)) {
1442
+ if (e5.trackingEvents) {
1443
+ i3.trackingEvents || (i3.trackingEvents = {}), i3.trackingEvents[e5.type] || (i3.trackingEvents[e5.type] = {});
1444
+ var t5 = function(t6) {
1445
+ var r4 = e5.trackingEvents[t6];
1446
+ Array.isArray(i3.trackingEvents[e5.type][t6]) || (i3.trackingEvents[e5.type][t6] = []), r4.forEach(function(r5) {
1447
+ i3.trackingEvents[e5.type][t6].push(r5);
1448
+ });
1449
+ };
1450
+ for (var r3 in e5.trackingEvents)
1451
+ t5(r3);
1452
+ }
1453
+ e5.videoClickTrackingURLTemplates && (Array.isArray(i3.videoClickTrackingURLTemplates) || (i3.videoClickTrackingURLTemplates = []), e5.videoClickTrackingURLTemplates.forEach(function(e6) {
1454
+ i3.videoClickTrackingURLTemplates.push(e6);
1455
+ })), e5.videoClickThroughURLTemplate && (i3.videoClickThroughURLTemplate = e5.videoClickThroughURLTemplate), e5.videoCustomClickURLTemplates && (Array.isArray(i3.videoCustomClickURLTemplates) || (i3.videoCustomClickURLTemplates = []), e5.videoCustomClickURLTemplates.forEach(function(e6) {
1456
+ i3.videoCustomClickURLTemplates.push(e6);
1457
+ }));
1458
+ }
1459
+ }), i3.nextWrapperURL)
1460
+ return i3;
1461
+ }
1462
+ function G(e4) {
1463
+ var t4 = [];
1464
+ return e4.forEach(function(e5) {
1465
+ var i3 = { resource: null, vendor: null, browserOptional: false, apiFramework: null, type: null, parameters: null, trackingEvents: {} }, r2 = e5.childNodes;
1466
+ for (var n2 in C.assignAttributes(e5.attributes, i3), r2) {
1467
+ var a2 = r2[n2];
1468
+ switch (a2.nodeName) {
1469
+ case "JavaScriptResource":
1470
+ case "ExecutableResource":
1471
+ i3.resource = C.parseNodeText(a2), C.assignAttributes(a2.attributes, i3);
1472
+ break;
1473
+ case "VerificationParameters":
1474
+ i3.parameters = C.parseNodeText(a2);
1475
+ }
1476
+ }
1477
+ var o2 = C.childByName(e5, "TrackingEvents");
1478
+ o2 && C.childrenByName(o2, "Tracking").forEach(function(e6) {
1479
+ var t5 = e6.getAttribute("event"), r3 = C.parseNodeText(e6);
1480
+ t5 && r3 && (Array.isArray(i3.trackingEvents[t5]) || (i3.trackingEvents[t5] = []), i3.trackingEvents[t5].push(r3));
1481
+ }), t4.push(i3);
1482
+ }), t4;
1483
+ }
1484
+ function Q(e4) {
1485
+ var t4 = null, i3 = [];
1486
+ return e4.some(function(e5) {
1487
+ return t4 = C.childByName(e5, "AdVerifications");
1488
+ }), t4 && (i3 = G(C.childrenByName(t4, "Verification"))), i3;
1489
+ }
1490
+ function X(e4) {
1491
+ var t4 = {};
1492
+ t4.id = e4.getAttribute("id") || null;
1493
+ var i3 = e4.childNodes;
1494
+ for (var r2 in i3) {
1495
+ var n2 = i3[r2], a2 = n2.nodeName, o2 = C.parseNodeText(n2);
1496
+ if (("Viewable" === a2 || "NotViewable" === a2 || "ViewUndetermined" === a2) && o2) {
1497
+ var s2 = a2.toLowerCase();
1498
+ Array.isArray(t4[s2]) || (t4[s2] = []), t4[s2].push(o2);
1499
+ }
1500
+ }
1501
+ return t4;
1502
+ }
1503
+ var Y = function() {
1504
+ function e4() {
1505
+ n(this, e4), this._handlers = [];
1506
+ }
1507
+ return o(e4, [{ key: "on", value: function(e5, t4) {
1508
+ if ("function" != typeof t4)
1509
+ throw new TypeError("The handler argument must be of type Function. Received type ".concat(r(t4)));
1510
+ if (!e5)
1511
+ throw new TypeError("The event argument must be of type String. Received type ".concat(r(e5)));
1512
+ return this._handlers.push({ event: e5, handler: t4 }), this;
1513
+ } }, { key: "once", value: function(e5, t4) {
1514
+ return this.on(e5, function(e6, t5, i3) {
1515
+ var r2 = { fired: false, wrapFn: void 0 };
1516
+ function n2() {
1517
+ r2.fired || (e6.off(t5, r2.wrapFn), r2.fired = true, i3.bind(e6).apply(void 0, arguments));
1518
+ }
1519
+ return r2.wrapFn = n2, n2;
1520
+ }(this, e5, t4));
1521
+ } }, { key: "off", value: function(e5, t4) {
1522
+ return this._handlers = this._handlers.filter(function(i3) {
1523
+ return i3.event !== e5 || i3.handler !== t4;
1524
+ }), this;
1525
+ } }, { key: "emit", value: function(e5) {
1526
+ for (var t4 = arguments.length, i3 = new Array(t4 > 1 ? t4 - 1 : 0), r2 = 1; r2 < t4; r2++)
1527
+ i3[r2 - 1] = arguments[r2];
1528
+ var n2 = false;
1529
+ return this._handlers.forEach(function(t5) {
1530
+ "*" === t5.event && (n2 = true, t5.handler.apply(t5, [e5].concat(i3))), t5.event === e5 && (n2 = true, t5.handler.apply(t5, i3));
1531
+ }), n2;
1532
+ } }, { key: "removeAllListeners", value: function(e5) {
1533
+ return e5 ? (this._handlers = this._handlers.filter(function(t4) {
1534
+ return t4.event !== e5;
1535
+ }), this) : (this._handlers = [], this);
1536
+ } }, { key: "listenerCount", value: function(e5) {
1537
+ return this._handlers.filter(function(t4) {
1538
+ return t4.event === e5;
1539
+ }).length;
1540
+ } }, { key: "listeners", value: function(e5) {
1541
+ return this._handlers.reduce(function(t4, i3) {
1542
+ return i3.event === e5 && t4.push(i3.handler), t4;
1543
+ }, []);
1544
+ } }, { key: "eventNames", value: function() {
1545
+ return this._handlers.map(function(e5) {
1546
+ return e5.event;
1547
+ });
1548
+ } }]), e4;
1549
+ }(), K = { get: function(e4, t4, i3) {
1550
+ i3(new Error("Please bundle the library for node to use the node urlHandler"));
1551
+ } }, J = 12e4;
1552
+ function Z() {
1553
+ try {
1554
+ var e4 = new window.XMLHttpRequest();
1555
+ return "withCredentials" in e4 ? e4 : null;
1556
+ } catch (e5) {
1557
+ return null;
1558
+ }
1559
+ }
1560
+ function $(e4, t4, i3) {
1561
+ var r2 = i3 ? 408 : e4.status, n2 = i3 ? "XHRURLHandler: Request timed out after ".concat(e4.timeout, " ms (").concat(r2, ")") : "XHRURLHandler: ".concat(e4.statusText, " (").concat(r2, ")");
1562
+ t4(new Error(n2), null, { statusCode: r2 });
1563
+ }
1564
+ var ee = { get: function(e4, t4, i3) {
1565
+ if ("https:" === window.location.protocol && 0 === e4.indexOf("http://"))
1566
+ return i3(new Error("XHRURLHandler: Cannot go from HTTPS to HTTP."));
1567
+ try {
1568
+ var r2 = Z();
1569
+ r2.open("GET", e4), r2.timeout = t4.timeout || J, r2.withCredentials = t4.withCredentials || false, r2.overrideMimeType && r2.overrideMimeType("text/xml"), r2.onload = function() {
1570
+ return function(e5, t5) {
1571
+ 200 === e5.status ? t5(null, e5.responseXML, { byteLength: e5.response.length, statusCode: e5.status }) : $(e5, t5, false);
1572
+ }(r2, i3);
1573
+ }, r2.onerror = function() {
1574
+ return $(r2, i3, false);
1575
+ }, r2.onabort = function() {
1576
+ return $(r2, i3, false);
1577
+ }, r2.ontimeout = function() {
1578
+ return $(r2, i3, true);
1579
+ }, r2.send();
1580
+ } catch (e5) {
1581
+ i3(new Error("XHRURLHandler: Unexpected error"));
1582
+ }
1583
+ }, supported: function() {
1584
+ return !!Z();
1585
+ } }, te = { get: function(e4, t4, i3) {
1586
+ return i3 || ("function" == typeof t4 && (i3 = t4), t4 = {}), "undefined" == typeof window || null === window ? K.get(e4, t4, i3) : ee.supported() ? ee.get(e4, t4, i3) : i3(new Error("Current context is not supported by any of the default URLHandlers. Please provide a custom URLHandler"));
1587
+ } }, ie = 0, re = 0, ne = function(e4, t4) {
1588
+ !e4 || !t4 || e4 <= 0 || t4 <= 0 || (re = (re * ie + 8 * e4 / t4) / ++ie);
1589
+ }, ae = { ERRORCODE: 900, extensions: [] }, oe = function(e4) {
1590
+ l(i3, e4);
1591
+ var t4 = p(i3);
1592
+ function i3() {
1593
+ var e5;
1594
+ return n(this, i3), (e5 = t4.call(this)).remainingAds = [], e5.parentURLs = [], e5.errorURLTemplates = [], e5.rootErrorURLTemplates = [], e5.maxWrapperDepth = null, e5.URLTemplateFilters = [], e5.fetchingOptions = {}, e5.parsingOptions = {}, e5;
1595
+ }
1596
+ return o(i3, [{ key: "addURLTemplateFilter", value: function(e5) {
1597
+ "function" == typeof e5 && this.URLTemplateFilters.push(e5);
1598
+ } }, { key: "removeURLTemplateFilter", value: function() {
1599
+ this.URLTemplateFilters.pop();
1600
+ } }, { key: "countURLTemplateFilters", value: function() {
1601
+ return this.URLTemplateFilters.length;
1602
+ } }, { key: "clearURLTemplateFilters", value: function() {
1603
+ this.URLTemplateFilters = [];
1604
+ } }, { key: "trackVastError", value: function(e5, t5) {
1605
+ for (var i4 = arguments.length, r2 = new Array(i4 > 2 ? i4 - 2 : 0), n2 = 2; n2 < i4; n2++)
1606
+ r2[n2 - 2] = arguments[n2];
1607
+ this.emit("VAST-error", Object.assign.apply(Object, [{}, ae, t5].concat(r2))), w.track(e5, t5);
1608
+ } }, { key: "getErrorURLTemplates", value: function() {
1609
+ return this.rootErrorURLTemplates.concat(this.errorURLTemplates);
1610
+ } }, { key: "getEstimatedBitrate", value: function() {
1611
+ return re;
1612
+ } }, { key: "fetchVAST", value: function(e5) {
1613
+ var t5 = this, i4 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : 0, r2 = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : null, n2 = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : null;
1614
+ return new Promise(function(a2, o2) {
1615
+ t5.URLTemplateFilters.forEach(function(t6) {
1616
+ e5 = t6(e5);
1617
+ }), t5.parentURLs.push(e5);
1618
+ var s2 = Date.now();
1619
+ t5.emit("VAST-resolving", { url: e5, previousUrl: r2, wrapperDepth: i4, maxWrapperDepth: t5.maxWrapperDepth, timeout: t5.fetchingOptions.timeout, wrapperAd: n2 }), t5.urlHandler.get(e5, t5.fetchingOptions, function(n3, l2) {
1620
+ var c2 = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {}, u2 = Math.round(Date.now() - s2), d2 = Object.assign({ url: e5, previousUrl: r2, wrapperDepth: i4, error: n3, duration: u2 }, c2);
1621
+ t5.emit("VAST-resolved", d2), ne(c2.byteLength, u2), n3 ? o2(n3) : a2(l2);
1622
+ });
1623
+ });
1624
+ } }, { key: "initParsingStatus", value: function() {
1625
+ var e5 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
1626
+ this.errorURLTemplates = [], this.fetchingOptions = { timeout: e5.timeout || J, withCredentials: e5.withCredentials }, this.maxWrapperDepth = e5.wrapperLimit || 10, this.parentURLs = [], this.parsingOptions = { allowMultipleAds: e5.allowMultipleAds }, this.remainingAds = [], this.rootErrorURLTemplates = [], this.rootURL = "", this.urlHandler = e5.urlHandler || e5.urlhandler || te, this.vastVersion = null, ne(e5.byteLength, e5.requestDuration);
1627
+ } }, { key: "getRemainingAds", value: function(e5) {
1628
+ var t5 = this;
1629
+ if (0 === this.remainingAds.length)
1630
+ return Promise.reject(new Error("No more ads are available for the given VAST"));
1631
+ var i4 = e5 ? w.flatten(this.remainingAds) : this.remainingAds.shift();
1632
+ return this.errorURLTemplates = [], this.parentURLs = [], this.resolveAds(i4, { wrapperDepth: 0, url: this.rootURL }).then(function(e6) {
1633
+ return t5.buildVASTResponse(e6);
1634
+ });
1635
+ } }, { key: "getAndParseVAST", value: function(e5) {
1636
+ var t5 = this, i4 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
1637
+ return this.initParsingStatus(i4), this.URLTemplateFilters.forEach(function(t6) {
1638
+ e5 = t6(e5);
1639
+ }), this.rootURL = e5, this.fetchVAST(e5).then(function(r2) {
1640
+ return i4.previousUrl = e5, i4.isRootVAST = true, i4.url = e5, t5.parse(r2, i4).then(function(e6) {
1641
+ return t5.buildVASTResponse(e6);
1642
+ });
1643
+ });
1644
+ } }, { key: "parseVAST", value: function(e5) {
1645
+ var t5 = this, i4 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
1646
+ return this.initParsingStatus(i4), i4.isRootVAST = true, this.parse(e5, i4).then(function(e6) {
1647
+ return t5.buildVASTResponse(e6);
1648
+ });
1649
+ } }, { key: "buildVASTResponse", value: function(e5) {
1650
+ var t5, i4 = { ads: (t5 = { ads: e5, errorURLTemplates: this.getErrorURLTemplates(), version: this.vastVersion }).ads || [], errorURLTemplates: t5.errorURLTemplates || [], version: t5.version || null };
1651
+ return this.completeWrapperResolving(i4), i4;
1652
+ } }, { key: "parseVastXml", value: function(e5, t5) {
1653
+ var i4 = t5.isRootVAST, r2 = void 0 !== i4 && i4, n2 = t5.url, a2 = void 0 === n2 ? null : n2, o2 = t5.wrapperDepth, s2 = void 0 === o2 ? 0 : o2, l2 = t5.allowMultipleAds, c2 = t5.followAdditionalWrappers;
1654
+ if (!e5 || !e5.documentElement || "VAST" !== e5.documentElement.nodeName)
1655
+ throw this.emit("VAST-ad-parsed", { type: "ERROR", url: a2, wrapperDepth: s2 }), new Error("Invalid VAST XMLDocument");
1656
+ var u2 = [], d2 = e5.documentElement.childNodes, p2 = e5.documentElement.getAttribute("version");
1657
+ for (var h2 in r2 && p2 && (this.vastVersion = p2), d2) {
1658
+ var f2 = d2[h2];
1659
+ if ("Error" === f2.nodeName) {
1660
+ var m2 = C.parseNodeText(f2);
1661
+ r2 ? this.rootErrorURLTemplates.push(m2) : this.errorURLTemplates.push(m2);
1662
+ } else if ("Ad" === f2.nodeName) {
1663
+ if (this.vastVersion && parseFloat(this.vastVersion) < 3)
1664
+ l2 = true;
1665
+ else if (false === l2 && u2.length > 1)
1666
+ break;
1667
+ var v2 = W(f2, this.emit.bind(this), { allowMultipleAds: l2, followAdditionalWrappers: c2 });
1668
+ v2.ad ? (u2.push(v2.ad), this.emit("VAST-ad-parsed", { type: v2.type, url: a2, wrapperDepth: s2, adIndex: u2.length - 1, vastVersion: p2 })) : this.trackVastError(this.getErrorURLTemplates(), { ERRORCODE: 101 });
1669
+ }
1670
+ }
1671
+ return u2;
1672
+ } }, { key: "parse", value: function(e5) {
1673
+ var t5 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, i4 = t5.url, r2 = void 0 === i4 ? null : i4, n2 = t5.resolveAll, a2 = void 0 === n2 || n2, o2 = t5.wrapperSequence, s2 = void 0 === o2 ? null : o2, l2 = t5.previousUrl, c2 = void 0 === l2 ? null : l2, u2 = t5.wrapperDepth, d2 = void 0 === u2 ? 0 : u2, p2 = t5.isRootVAST, h2 = void 0 !== p2 && p2, f2 = t5.followAdditionalWrappers, m2 = t5.allowMultipleAds, v2 = [];
1674
+ this.vastVersion && parseFloat(this.vastVersion) < 3 && h2 && (m2 = true);
1675
+ try {
1676
+ v2 = this.parseVastXml(e5, { isRootVAST: h2, url: r2, wrapperDepth: d2, allowMultipleAds: m2, followAdditionalWrappers: f2 });
1677
+ } catch (e6) {
1678
+ return Promise.reject(e6);
1679
+ }
1680
+ return 1 === v2.length && null != s2 && (v2[0].sequence = s2), false === a2 && (this.remainingAds = C.splitVAST(v2), v2 = this.remainingAds.shift()), this.resolveAds(v2, { wrapperDepth: d2, previousUrl: c2, url: r2 });
1681
+ } }, { key: "resolveAds", value: function() {
1682
+ var e5 = this, t5 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [], i4 = arguments.length > 1 ? arguments[1] : void 0, r2 = i4.wrapperDepth, n2 = i4.previousUrl, a2 = i4.url, o2 = [];
1683
+ return n2 = a2, t5.forEach(function(t6) {
1684
+ var i5 = e5.resolveWrappers(t6, r2, n2);
1685
+ o2.push(i5);
1686
+ }), Promise.all(o2).then(function(t6) {
1687
+ var i5 = w.flatten(t6);
1688
+ if (!i5 && e5.remainingAds.length > 0) {
1689
+ var o3 = e5.remainingAds.shift();
1690
+ return e5.resolveAds(o3, { wrapperDepth: r2, previousUrl: n2, url: a2 });
1691
+ }
1692
+ return i5;
1693
+ });
1694
+ } }, { key: "resolveWrappers", value: function(e5, t5, i4) {
1695
+ var r2 = this;
1696
+ return new Promise(function(n2) {
1697
+ var a2;
1698
+ if (t5++, !e5.nextWrapperURL)
1699
+ return delete e5.nextWrapperURL, n2(e5);
1700
+ if (t5 >= r2.maxWrapperDepth || -1 !== r2.parentURLs.indexOf(e5.nextWrapperURL))
1701
+ return e5.errorCode = 302, delete e5.nextWrapperURL, n2(e5);
1702
+ e5.nextWrapperURL = C.resolveVastAdTagURI(e5.nextWrapperURL, i4), r2.URLTemplateFilters.forEach(function(t6) {
1703
+ e5.nextWrapperURL = t6(e5.nextWrapperURL);
1704
+ });
1705
+ var o2 = null !== (a2 = r2.parsingOptions.allowMultipleAds) && void 0 !== a2 ? a2 : e5.allowMultipleAds, s2 = e5.sequence;
1706
+ r2.fetchVAST(e5.nextWrapperURL, t5, i4, e5).then(function(a3) {
1707
+ return r2.parse(a3, { url: e5.nextWrapperURL, previousUrl: i4, wrapperSequence: s2, wrapperDepth: t5, followAdditionalWrappers: e5.followAdditionalWrappers, allowMultipleAds: o2 }).then(function(t6) {
1708
+ if (delete e5.nextWrapperURL, 0 === t6.length)
1709
+ return e5.creatives = [], n2(e5);
1710
+ t6.forEach(function(t7) {
1711
+ t7 && C.mergeWrapperAdData(t7, e5);
1712
+ }), n2(t6);
1713
+ });
1714
+ }).catch(function(t6) {
1715
+ e5.errorCode = 301, e5.errorMessage = t6.message, n2(e5);
1716
+ });
1717
+ });
1718
+ } }, { key: "completeWrapperResolving", value: function(e5) {
1719
+ if (0 === e5.ads.length)
1720
+ this.trackVastError(e5.errorURLTemplates, { ERRORCODE: 303 });
1721
+ else
1722
+ for (var t5 = e5.ads.length - 1; t5 >= 0; t5--) {
1723
+ var i4 = e5.ads[t5];
1724
+ (i4.errorCode || 0 === i4.creatives.length) && (this.trackVastError(i4.errorURLTemplates.concat(e5.errorURLTemplates), { ERRORCODE: i4.errorCode || 303 }, { ERRORMESSAGE: i4.errorMessage || "" }, { extensions: i4.extensions }, { system: i4.system }), e5.ads.splice(t5, 1));
1725
+ }
1726
+ } }]), i3;
1727
+ }(Y), se = null, le = { data: {}, length: 0, getItem: function(e4) {
1728
+ return this.data[e4];
1729
+ }, setItem: function(e4, t4) {
1730
+ this.data[e4] = t4, this.length = Object.keys(this.data).length;
1731
+ }, removeItem: function(e4) {
1732
+ delete this.data[e4], this.length = Object.keys(this.data).length;
1733
+ }, clear: function() {
1734
+ this.data = {}, this.length = 0;
1735
+ } }, ce = function() {
1736
+ function e4() {
1737
+ n(this, e4), this.storage = this.initStorage();
1738
+ }
1739
+ return o(e4, [{ key: "initStorage", value: function() {
1740
+ if (se)
1741
+ return se;
1742
+ try {
1743
+ se = "undefined" != typeof window && null !== window ? window.localStorage || window.sessionStorage : null;
1744
+ } catch (e5) {
1745
+ se = null;
1746
+ }
1747
+ return se && !this.isStorageDisabled(se) || (se = le).clear(), se;
1748
+ } }, { key: "isStorageDisabled", value: function(e5) {
1749
+ var t4 = "__VASTStorage__";
1750
+ try {
1751
+ if (e5.setItem(t4, t4), e5.getItem(t4) !== t4)
1752
+ return e5.removeItem(t4), true;
1753
+ } catch (e6) {
1754
+ return true;
1755
+ }
1756
+ return e5.removeItem(t4), false;
1757
+ } }, { key: "getItem", value: function(e5) {
1758
+ return this.storage.getItem(e5);
1759
+ } }, { key: "setItem", value: function(e5, t4) {
1760
+ return this.storage.setItem(e5, t4);
1761
+ } }, { key: "removeItem", value: function(e5) {
1762
+ return this.storage.removeItem(e5);
1763
+ } }, { key: "clear", value: function() {
1764
+ return this.storage.clear();
1765
+ } }]), e4;
1766
+ }(), ue = function() {
1767
+ function e4(t4, i3, r2) {
1768
+ n(this, e4), this.cappingFreeLunch = t4 || 0, this.cappingMinimumTimeInterval = i3 || 0, this.defaultOptions = { withCredentials: false, timeout: 0 }, this.vastParser = new oe(), this.storage = r2 || new ce(), void 0 === this.lastSuccessfulAd && (this.lastSuccessfulAd = 0), void 0 === this.totalCalls && (this.totalCalls = 0), void 0 === this.totalCallsTimeout && (this.totalCallsTimeout = 0);
1769
+ }
1770
+ return o(e4, [{ key: "getParser", value: function() {
1771
+ return this.vastParser;
1772
+ } }, { key: "lastSuccessfulAd", get: function() {
1773
+ return this.storage.getItem("vast-client-last-successful-ad");
1774
+ }, set: function(e5) {
1775
+ this.storage.setItem("vast-client-last-successful-ad", e5);
1776
+ } }, { key: "totalCalls", get: function() {
1777
+ return this.storage.getItem("vast-client-total-calls");
1778
+ }, set: function(e5) {
1779
+ this.storage.setItem("vast-client-total-calls", e5);
1780
+ } }, { key: "totalCallsTimeout", get: function() {
1781
+ return this.storage.getItem("vast-client-total-calls-timeout");
1782
+ }, set: function(e5) {
1783
+ this.storage.setItem("vast-client-total-calls-timeout", e5);
1784
+ } }, { key: "hasRemainingAds", value: function() {
1785
+ return this.vastParser.remainingAds.length > 0;
1786
+ } }, { key: "getNextAds", value: function(e5) {
1787
+ return this.vastParser.getRemainingAds(e5);
1788
+ } }, { key: "get", value: function(e5) {
1789
+ var t4 = this, i3 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, r2 = Date.now();
1790
+ return (i3 = Object.assign({}, this.defaultOptions, i3)).hasOwnProperty("resolveAll") || (i3.resolveAll = false), this.totalCallsTimeout < r2 ? (this.totalCalls = 1, this.totalCallsTimeout = r2 + 36e5) : this.totalCalls++, new Promise(function(n2, a2) {
1791
+ if (t4.cappingFreeLunch >= t4.totalCalls)
1792
+ return a2(new Error("VAST call canceled \u2013 FreeLunch capping not reached yet ".concat(t4.totalCalls, "/").concat(t4.cappingFreeLunch)));
1793
+ var o2 = r2 - t4.lastSuccessfulAd;
1794
+ if (o2 < 0)
1795
+ t4.lastSuccessfulAd = 0;
1796
+ else if (o2 < t4.cappingMinimumTimeInterval)
1797
+ return a2(new Error("VAST call canceled \u2013 (".concat(t4.cappingMinimumTimeInterval, ")ms minimum interval reached")));
1798
+ t4.vastParser.getAndParseVAST(e5, i3).then(function(e6) {
1799
+ return n2(e6);
1800
+ }).catch(function(e6) {
1801
+ return a2(e6);
1802
+ });
1803
+ });
1804
+ } }]), e4;
1805
+ }(), de = function(e4) {
1806
+ l(a2, e4);
1807
+ var t4 = p(a2);
1808
+ function a2(e5, i3, r2) {
1809
+ var o2, s2 = arguments.length > 3 && void 0 !== arguments[3] ? arguments[3] : null;
1810
+ for (var l2 in n(this, a2), (o2 = t4.call(this)).ad = i3, o2.creative = r2, o2.variation = s2, o2.muted = false, o2.impressed = false, o2.skippable = false, o2.trackingEvents = {}, o2.lastPercentage = 0, o2._alreadyTriggeredQuartiles = {}, o2.emitAlwaysEvents = ["creativeView", "start", "firstQuartile", "midpoint", "thirdQuartile", "complete", "resume", "pause", "rewind", "skip", "closeLinear", "close"], o2.creative.trackingEvents) {
1811
+ var c2 = o2.creative.trackingEvents[l2];
1812
+ o2.trackingEvents[l2] = c2.slice(0);
1813
+ }
1814
+ return I(o2.creative) ? o2._initLinearTracking() : o2._initVariationTracking(), e5 && o2.on("start", function() {
1815
+ e5.lastSuccessfulAd = Date.now();
1816
+ }), o2;
1817
+ }
1818
+ return o(a2, [{ key: "_initLinearTracking", value: function() {
1819
+ this.linear = true, this.skipDelay = this.creative.skipDelay, this.setDuration(this.creative.duration), this.clickThroughURLTemplate = this.creative.videoClickThroughURLTemplate, this.clickTrackingURLTemplates = this.creative.videoClickTrackingURLTemplates;
1820
+ } }, { key: "_initVariationTracking", value: function() {
1821
+ if (this.linear = false, this.skipDelay = -1, this.variation) {
1822
+ for (var e5 in this.variation.trackingEvents) {
1823
+ var t5 = this.variation.trackingEvents[e5];
1824
+ this.trackingEvents[e5] ? this.trackingEvents[e5] = this.trackingEvents[e5].concat(t5.slice(0)) : this.trackingEvents[e5] = t5.slice(0);
1825
+ }
1826
+ "nonLinearAd" === this.variation.adType ? (this.clickThroughURLTemplate = this.variation.nonlinearClickThroughURLTemplate, this.clickTrackingURLTemplates = this.variation.nonlinearClickTrackingURLTemplates, this.setDuration(this.variation.minSuggestedDuration)) : function(e6) {
1827
+ return "companionAd" === e6.adType;
1828
+ }(this.variation) && (this.clickThroughURLTemplate = this.variation.companionClickThroughURLTemplate, this.clickTrackingURLTemplates = this.variation.companionClickTrackingURLTemplates);
1829
+ }
1830
+ } }, { key: "setDuration", value: function(e5) {
1831
+ w.isValidTimeValue(e5) && (this.assetDuration = e5, this.quartiles = { firstQuartile: Math.round(25 * this.assetDuration) / 100, midpoint: Math.round(50 * this.assetDuration) / 100, thirdQuartile: Math.round(75 * this.assetDuration) / 100 });
1832
+ } }, { key: "setProgress", value: function(e5) {
1833
+ var t5 = this, i3 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
1834
+ if (w.isValidTimeValue(e5) && "object" === r(i3)) {
1835
+ var n2 = this.skipDelay || -1;
1836
+ if (-1 === n2 || this.skippable || (n2 > e5 ? this.emit("skip-countdown", n2 - e5) : (this.skippable = true, this.emit("skip-countdown", 0))), this.assetDuration > 0) {
1837
+ var a3 = Math.round(e5 / this.assetDuration * 100), o2 = [];
1838
+ if (e5 > 0) {
1839
+ o2.push("start");
1840
+ for (var s2 = this.lastPercentage; s2 < a3; s2++)
1841
+ o2.push("progress-".concat(s2 + 1, "%"));
1842
+ for (var l2 in o2.push("progress-".concat(Math.round(e5))), this.quartiles)
1843
+ this.isQuartileReached(l2, this.quartiles[l2], e5) && (o2.push(l2), this._alreadyTriggeredQuartiles[l2] = true);
1844
+ this.lastPercentage = a3;
1845
+ }
1846
+ o2.forEach(function(e6) {
1847
+ t5.track(e6, { macros: i3, once: true });
1848
+ }), e5 < this.progress && this.track("rewind", { macros: i3 });
1849
+ }
1850
+ this.progress = e5;
1851
+ }
1852
+ } }, { key: "isQuartileReached", value: function(e5, t5, i3) {
1853
+ var r2 = false;
1854
+ return t5 <= i3 && !this._alreadyTriggeredQuartiles[e5] && (r2 = true), r2;
1855
+ } }, { key: "setMuted", value: function(e5) {
1856
+ var t5 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
1857
+ "boolean" == typeof e5 && "object" === r(t5) && (this.muted !== e5 && this.track(e5 ? "mute" : "unmute", { macros: t5 }), this.muted = e5);
1858
+ } }, { key: "setPaused", value: function(e5) {
1859
+ var t5 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
1860
+ "boolean" == typeof e5 && "object" === r(t5) && (this.paused !== e5 && this.track(e5 ? "pause" : "resume", { macros: t5 }), this.paused = e5);
1861
+ } }, { key: "setFullscreen", value: function(e5) {
1862
+ var t5 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
1863
+ "boolean" == typeof e5 && "object" === r(t5) && (this.fullscreen !== e5 && this.track(e5 ? "fullscreen" : "exitFullscreen", { macros: t5 }), this.fullscreen = e5);
1864
+ } }, { key: "setExpand", value: function(e5) {
1865
+ var t5 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
1866
+ "boolean" == typeof e5 && "object" === r(t5) && (this.expanded !== e5 && (this.track(e5 ? "expand" : "collapse", { macros: t5 }), this.track(e5 ? "playerExpand" : "playerCollapse", { macros: t5 })), this.expanded = e5);
1867
+ } }, { key: "setSkipDelay", value: function(e5) {
1868
+ w.isValidTimeValue(e5) && (this.skipDelay = e5);
1869
+ } }, { key: "trackImpression", value: function() {
1870
+ var e5 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
1871
+ "object" === r(e5) && (this.impressed || (this.impressed = true, this.trackURLs(this.ad.impressionURLTemplates, e5), this.track("creativeView", { macros: e5 })));
1872
+ } }, { key: "error", value: function() {
1873
+ var e5 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, t5 = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];
1874
+ "object" === r(e5) && "boolean" == typeof t5 && this.trackURLs(this.ad.errorURLTemplates, e5, { isCustomCode: t5 });
1875
+ } }, { key: "errorWithCode", value: function(e5) {
1876
+ var t5 = arguments.length > 1 && void 0 !== arguments[1] && arguments[1];
1877
+ "string" == typeof e5 && "boolean" == typeof t5 && this.error({ ERRORCODE: e5 }, t5);
1878
+ } }, { key: "complete", value: function() {
1879
+ var e5 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
1880
+ "object" === r(e5) && this.track("complete", { macros: e5 });
1881
+ } }, { key: "notUsed", value: function() {
1882
+ var e5 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
1883
+ "object" === r(e5) && (this.track("notUsed", { macros: e5 }), this.trackingEvents = []);
1884
+ } }, { key: "otherAdInteraction", value: function() {
1885
+ var e5 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
1886
+ "object" === r(e5) && this.track("otherAdInteraction", { macros: e5 });
1887
+ } }, { key: "acceptInvitation", value: function() {
1888
+ var e5 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
1889
+ "object" === r(e5) && this.track("acceptInvitation", { macros: e5 });
1890
+ } }, { key: "adExpand", value: function() {
1891
+ var e5 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
1892
+ "object" === r(e5) && this.track("adExpand", { macros: e5 });
1893
+ } }, { key: "adCollapse", value: function() {
1894
+ var e5 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
1895
+ "object" === r(e5) && this.track("adCollapse", { macros: e5 });
1896
+ } }, { key: "minimize", value: function() {
1897
+ var e5 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
1898
+ "object" === r(e5) && this.track("minimize", { macros: e5 });
1899
+ } }, { key: "verificationNotExecuted", value: function(e5) {
1900
+ var t5 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
1901
+ if ("string" == typeof e5 && "object" === r(t5)) {
1902
+ if (!this.ad || !this.ad.adVerifications || !this.ad.adVerifications.length)
1903
+ throw new Error("No adVerifications provided");
1904
+ if (!e5)
1905
+ throw new Error("No vendor provided, unable to find associated verificationNotExecuted");
1906
+ var i3 = this.ad.adVerifications.find(function(t6) {
1907
+ return t6.vendor === e5;
1908
+ });
1909
+ if (!i3)
1910
+ throw new Error("No associated verification element found for vendor: ".concat(e5));
1911
+ var n2 = i3.trackingEvents;
1912
+ if (n2 && n2.verificationNotExecuted) {
1913
+ var a3 = n2.verificationNotExecuted;
1914
+ this.trackURLs(a3, t5), this.emit("verificationNotExecuted", { trackingURLTemplates: a3 });
1915
+ }
1916
+ }
1917
+ } }, { key: "overlayViewDuration", value: function(e5) {
1918
+ var t5 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
1919
+ "string" == typeof e5 && "object" === r(t5) && (t5.ADPLAYHEAD = e5, this.track("overlayViewDuration", { macros: t5 }));
1920
+ } }, { key: "close", value: function() {
1921
+ var e5 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
1922
+ "object" === r(e5) && this.track(this.linear ? "closeLinear" : "close", { macros: e5 });
1923
+ } }, { key: "skip", value: function() {
1924
+ var e5 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
1925
+ "object" === r(e5) && this.track("skip", { macros: e5 });
1926
+ } }, { key: "load", value: function() {
1927
+ var e5 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
1928
+ "object" === r(e5) && this.track("loaded", { macros: e5 });
1929
+ } }, { key: "click", value: function() {
1930
+ var e5 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null, t5 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
1931
+ if ((null === e5 || "string" == typeof e5) && "object" === r(t5)) {
1932
+ this.clickTrackingURLTemplates && this.clickTrackingURLTemplates.length && this.trackURLs(this.clickTrackingURLTemplates, t5);
1933
+ var n2 = this.clickThroughURLTemplate || e5, a3 = i2({}, t5);
1934
+ if (n2) {
1935
+ this.progress && (a3.ADPLAYHEAD = this.progressFormatted());
1936
+ var o2 = w.resolveURLTemplates([n2], a3)[0];
1937
+ this.emit("clickthrough", o2);
1938
+ }
1939
+ }
1940
+ } }, { key: "track", value: function(e5) {
1941
+ var t5 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}, i3 = t5.macros, n2 = void 0 === i3 ? {} : i3, a3 = t5.once, o2 = void 0 !== a3 && a3;
1942
+ if ("object" === r(n2)) {
1943
+ "closeLinear" === e5 && !this.trackingEvents[e5] && this.trackingEvents.close && (e5 = "close");
1944
+ var s2 = this.trackingEvents[e5], l2 = this.emitAlwaysEvents.indexOf(e5) > -1;
1945
+ s2 ? (this.emit(e5, { trackingURLTemplates: s2 }), this.trackURLs(s2, n2)) : l2 && this.emit(e5, null), o2 && (delete this.trackingEvents[e5], l2 && this.emitAlwaysEvents.splice(this.emitAlwaysEvents.indexOf(e5), 1));
1946
+ }
1947
+ } }, { key: "trackURLs", value: function(e5) {
1948
+ var t5, r2, n2 = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {}, a3 = i2({}, arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {});
1949
+ this.linear && (this.creative && this.creative.mediaFiles && this.creative.mediaFiles[0] && this.creative.mediaFiles[0].fileURL && (a3.ASSETURI = this.creative.mediaFiles[0].fileURL), this.progress && (a3.ADPLAYHEAD = this.progressFormatted())), null !== (t5 = this.creative) && void 0 !== t5 && null !== (r2 = t5.universalAdIds) && void 0 !== r2 && r2.length && (a3.UNIVERSALADID = this.creative.universalAdIds.map(function(e6) {
1950
+ return e6.idRegistry.concat(" ", e6.value);
1951
+ }).join(",")), this.ad && (this.ad.sequence && (a3.PODSEQUENCE = this.ad.sequence), this.ad.adType && (a3.ADTYPE = this.ad.adType), this.ad.adServingId && (a3.ADSERVINGID = this.ad.adServingId), this.ad.categories && this.ad.categories.length && (a3.ADCATEGORIES = this.ad.categories.map(function(e6) {
1952
+ return e6.value;
1953
+ }).join(",")), this.ad.blockedAdCategories && this.ad.blockedAdCategories.length && (a3.BLOCKEDADCATEGORIES = this.ad.blockedAdCategories)), w.track(e5, a3, n2);
1954
+ } }, { key: "convertToTimecode", value: function(e5) {
1955
+ if (!w.isValidTimeValue(e5))
1956
+ return "";
1957
+ var t5 = 1e3 * e5, i3 = Math.floor(t5 / 36e5), r2 = Math.floor(t5 / 6e4 % 60), n2 = Math.floor(t5 / 1e3 % 60), a3 = Math.floor(t5 % 1e3);
1958
+ return "".concat(w.addLeadingZeros(i3, 2), ":").concat(w.addLeadingZeros(r2, 2), ":").concat(w.addLeadingZeros(n2, 2), ".").concat(w.addLeadingZeros(a3, 3));
1959
+ } }, { key: "progressFormatted", value: function() {
1960
+ return this.convertToTimecode(this.progress);
1961
+ } }]), a2;
1962
+ }(Y);
1963
+ e3.VASTClient = ue, e3.VASTParser = oe, e3.VASTTracker = de, Object.defineProperty(e3, "__esModule", { value: true });
1964
+ }(t2);
1965
+ }, 144: (e2, t2, i2) => {
1966
+ var r, n = void 0 !== i2.g ? i2.g : "undefined" != typeof window ? window : {}, a = i2(893);
1967
+ "undefined" != typeof document ? r = document : (r = n["__GLOBAL_DOCUMENT_CACHE@4"]) || (r = n["__GLOBAL_DOCUMENT_CACHE@4"] = a), e2.exports = r;
1968
+ }, 908: (e2, t2, i2) => {
1969
+ var r;
1970
+ r = "undefined" != typeof window ? window : void 0 !== i2.g ? i2.g : "undefined" != typeof self ? self : {}, e2.exports = r;
1971
+ }, 596: (e2) => {
1972
+ "use strict";
1973
+ var t2 = ["handshakeVersion", "initAd", "startAd", "stopAd", "skipAd", "resizeAd", "pauseAd", "resumeAd", "expandAd", "collapseAd", "subscribe", "unsubscribe"];
1974
+ function i2(e3, t3, i3) {
1975
+ }
1976
+ i2.prototype.handshakeVersion = function(e3, t3) {
1977
+ }, i2.prototype.initAd = function(e3, t3, i3, r2, n2, a, o) {
1978
+ }, i2.prototype.startAd = function(e3) {
1979
+ }, i2.prototype.stopAd = function(e3) {
1980
+ }, i2.prototype.skipAd = function(e3) {
1981
+ }, i2.prototype.resizeAd = function(e3, t3, i3, r2) {
1982
+ }, i2.prototype.pauseAd = function(e3) {
1983
+ }, i2.prototype.resumeAd = function(e3) {
1984
+ }, i2.prototype.expandAd = function(e3) {
1985
+ }, i2.prototype.collapseAd = function(e3) {
1986
+ }, i2.prototype.subscribe = function(e3, t3, i3) {
1987
+ }, i2.prototype.unsubscribe = function(e3, t3) {
1988
+ }, i2.prototype.getAdLinear = function(e3) {
1989
+ }, i2.prototype.getAdWidth = function(e3) {
1990
+ }, i2.prototype.getAdHeight = function(e3) {
1991
+ }, i2.prototype.getAdExpanded = function(e3) {
1992
+ }, i2.prototype.getAdSkippableState = function(e3) {
1993
+ }, i2.prototype.getAdRemainingTime = function(e3) {
1994
+ }, i2.prototype.getAdDuration = function(e3) {
1995
+ }, i2.prototype.getAdVolume = function(e3) {
1996
+ }, i2.prototype.getAdCompanions = function(e3) {
1997
+ }, i2.prototype.getAdIcons = function(e3) {
1998
+ }, i2.prototype.setAdVolume = function(e3, t3) {
1999
+ }, n(i2, "METHODS", t2), n(i2, "GETTERS", ["getAdLinear", "getAdWidth", "getAdHeight", "getAdExpanded", "getAdSkippableState", "getAdRemainingTime", "getAdDuration", "getAdVolume", "getAdCompanions", "getAdIcons"]), n(i2, "SETTERS", ["setAdVolume"]), n(i2, "EVENTS", ["AdLoaded", "AdStarted", "AdStopped", "AdSkipped", "AdSkippableStateChange", "AdSizeChange", "AdLinearChange", "AdDurationChange", "AdExpandedChange", "AdRemainingTimeChange", "AdVolumeChange", "AdImpression", "AdVideoStart", "AdVideoFirstQuartile", "AdVideoMidpoint", "AdVideoThirdQuartile", "AdVideoComplete", "AdClickThru", "AdInteraction", "AdUserAcceptInvitation", "AdUserMinimize", "AdUserClose", "AdPaused", "AdPlaying", "AdLog", "AdError"]);
2000
+ var r = t2.filter(function(e3) {
2001
+ return -1 === ["skipAd"].indexOf(e3);
2002
+ });
2003
+ function n(e3, t3, i3) {
2004
+ Object.defineProperty(e3, t3, { writable: false, configurable: false, value: i3 });
2005
+ }
2006
+ n(i2, "checkVPAIDInterface", function(e3) {
2007
+ return r.every(function(t3) {
2008
+ return "function" == typeof e3[t3];
2009
+ });
2010
+ }), e2.exports = i2;
2011
+ }, 13: (e2, t2, i2) => {
2012
+ "use strict";
2013
+ var r = i2(596), n = i2(437), a = r.checkVPAIDInterface, o = i2(77), s = (r.METHODS, "AdClickThru"), l = r.EVENTS.filter(function(e3) {
2014
+ return e3 != s;
2015
+ });
2016
+ function c(e3, t3, i3, r2) {
2017
+ this._isValid = a(e3), this._isValid && (this._creative = e3, this._el = t3, this._videoEl = i3, this._iframe = r2, this._subscribers = new n(), o.setFullSizeStyle(t3), u.call(this));
2018
+ }
2019
+ function u() {
2020
+ if (l.forEach(function(e4) {
2021
+ this._creative.subscribe(p.bind(this, e4), e4);
2022
+ }.bind(this)), this._creative.subscribe(d.bind(this), s), this._videoEl) {
2023
+ var e3 = this._iframe.contentDocument.documentElement, t3 = this._videoEl;
2024
+ e3.addEventListener("click", function(i3) {
2025
+ i3.target === e3 && t3.click();
2026
+ });
2027
+ }
2028
+ }
2029
+ function d(e3, t3, i3) {
2030
+ this._subscribers.triggerSync(s, { url: e3, id: t3, playerHandles: i3 });
2031
+ }
2032
+ function p(e3) {
2033
+ this._subscribers.trigger.apply(this._subscribers, Array.prototype.slice.call(arguments));
2034
+ }
2035
+ function h(e3, t3, i3, r2) {
2036
+ e3 ? e3(i3, r2) : i3 && t3.trigger("AdError", i3);
2037
+ }
2038
+ c.prototype = Object.create(r.prototype), c.prototype.isValidVPAIDAd = function() {
2039
+ return this._isValid;
2040
+ }, r.METHODS.forEach(function(e3) {
2041
+ -1 === ["subscribe", "unsubscribe", "initAd"].indexOf(e3) && (c.prototype[e3] = function() {
2042
+ var t3 = r.prototype[e3].length, i3 = Array.prototype.slice.call(arguments), n2 = t3 === i3.length ? i3.pop() : void 0;
2043
+ setTimeout(function() {
2044
+ var t4, r2 = null;
2045
+ try {
2046
+ t4 = this._creative[e3].apply(this._creative, i3);
2047
+ } catch (e4) {
2048
+ r2 = e4;
2049
+ }
2050
+ h(n2, this._subscribers, r2, t4);
2051
+ }.bind(this), 0);
2052
+ });
2053
+ }), c.prototype.initAd = function(e3, t3, i3, r2, n2, a2, s2) {
2054
+ n2 = n2 || {}, a2 = o.extend({ slot: this._el, videoSlot: this._videoEl }, a2 || {}), setTimeout(function() {
2055
+ var o2;
2056
+ try {
2057
+ this._creative.initAd(e3, t3, i3, r2, n2, a2);
2058
+ } catch (e4) {
2059
+ o2 = e4;
2060
+ }
2061
+ h(s2, this._subscribers, o2);
2062
+ }.bind(this), 0);
2063
+ }, c.prototype.subscribe = function(e3, t3, i3) {
2064
+ this._subscribers.subscribe(t3, e3, i3);
2065
+ }, c.prototype.unsubscribe = function(e3, t3) {
2066
+ this._subscribers.unsubscribe(t3, e3);
2067
+ }, c.prototype.on = c.prototype.subscribe, c.prototype.off = c.prototype.unsubscribe, r.GETTERS.forEach(function(e3) {
2068
+ c.prototype[e3] = function(t3) {
2069
+ setTimeout(function() {
2070
+ var i3, r2 = null;
2071
+ try {
2072
+ i3 = this._creative[e3]();
2073
+ } catch (e4) {
2074
+ r2 = e4;
2075
+ }
2076
+ h(t3, this._subscribers, r2, i3);
2077
+ }.bind(this), 0);
2078
+ };
2079
+ }), c.prototype.setAdVolume = function(e3, t3) {
2080
+ setTimeout(function() {
2081
+ var i3, r2 = null;
2082
+ try {
2083
+ this._creative.setAdVolume(e3), i3 = this._creative.getAdVolume();
2084
+ } catch (e4) {
2085
+ r2 = e4;
2086
+ }
2087
+ r2 || (r2 = o.validate(i3 === e3, "failed to apply volume: " + e3)), h(t3, this._subscribers, r2, i3);
2088
+ }.bind(this), 0);
2089
+ }, c.prototype._destroy = function() {
2090
+ this.stopAd(), this._subscribers.unsubscribeAll();
2091
+ }, e2.exports = c;
2092
+ }, 178: (e2, t2, i2) => {
2093
+ "use strict";
2094
+ var r = i2(77), n = r.unique("vpaidIframe"), a = i2(13);
2095
+ function o(e3, t3, i3, a2) {
2096
+ i3 = i3 || {}, this._id = n(), this._destroyed = false, this._frameContainer = r.createElementInEl(e3, "div"), this._videoEl = t3, this._vpaidOptions = a2 || { timeout: 1e4 }, this._templateConfig = { template: i3.template || `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"></head><body style="margin:0;padding:0"><div class="ad-element"></div><script type="text/javascript" src="{{iframeURL_JS}}"><\/script><script type="text/javascript">window.parent.postMessage('{"event": "ready", "id": "{{iframeID}}"}', '{{origin}}');<\/script></body></html>`, extraOptions: i3.extraOptions || {} };
2097
+ }
2098
+ function s(e3) {
2099
+ var t3 = this[e3];
2100
+ t3 && t3.parentNode && (t3.parentNode.removeChild(t3), delete this[e3]);
2101
+ }
2102
+ function l() {
2103
+ u.call(this), delete this._adUnit;
2104
+ }
2105
+ function c() {
2106
+ u.call(this), p.call(this);
2107
+ }
2108
+ function u() {
2109
+ s.call(this, "_frame"), d.call(this);
2110
+ }
2111
+ function d() {
2112
+ this._onLoad && (window.removeEventListener("message", this._onLoad), delete this._onLoad);
2113
+ }
2114
+ function p() {
2115
+ this._adUnit && (this._adUnit.stopAd(), delete this._adUnit);
2116
+ }
2117
+ function h() {
2118
+ if (this._destroyed)
2119
+ throw new Error("VPAIDHTML5Client already destroyed!");
2120
+ }
2121
+ function f() {
2122
+ return window.location.origin ? window.location.origin : window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
2123
+ }
2124
+ o.prototype.destroy = function() {
2125
+ this._destroyed || (this._destroyed = true, c.call(this));
2126
+ }, o.prototype.isDestroyed = function() {
2127
+ return this._destroyed;
2128
+ }, o.prototype.loadAdUnit = function(e3, t3) {
2129
+ if (!this._onLoad) {
2130
+ h.call(this), c.call(this);
2131
+ var i3 = this, n2 = r.createIframeWithContent(this._frameContainer, this._templateConfig.template, r.extend({ iframeURL_JS: e3, iframeID: this.getID(), origin: f() }, this._templateConfig.extraOptions));
2132
+ this._frame = n2, this._onLoad = r.callbackTimeout(this._vpaidOptions.timeout, function(e4) {
2133
+ if (e4.origin !== f())
2134
+ return;
2135
+ var n3, o2, s2, c2;
2136
+ try {
2137
+ n3 = JSON.parse(e4.data);
2138
+ } catch (e5) {
2139
+ throw e5;
2140
+ }
2141
+ if (n3.id !== i3.getID())
2142
+ return;
2143
+ i3._frame.contentWindow ? (c2 = i3._frame.contentWindow.getVPAIDAd, s2 = r.validate("function" == typeof c2, "the ad didn't return a function to create an ad")) : s2 = "the iframe is not anymore in the DOM tree";
2144
+ if (!s2) {
2145
+ var u2 = i3._frame.contentWindow.document.querySelector(".ad-element");
2146
+ (o2 = new a(c2(), u2, i3._videoEl, i3._frame)).subscribe("AdStopped", l.bind(i3)), s2 = r.validate(o2.isValidVPAIDAd(), "the add is not fully complaint with VPAID specification");
2147
+ }
2148
+ return i3._adUnit = o2, d.call(i3), t3(s2, s2 ? null : o2), true;
2149
+ }.bind(this), function() {
2150
+ t3("timeout", null);
2151
+ }.bind(this)), window.addEventListener("message", this._onLoad);
2152
+ }
2153
+ }, o.prototype.unloadAdUnit = function() {
2154
+ c.call(this);
2155
+ }, o.prototype.getID = function() {
2156
+ return this._id;
2157
+ }, e2.exports = o, window.VPAIDHTML5Client = o;
2158
+ }, 437: (e2) => {
2159
+ "use strict";
2160
+ function t2() {
2161
+ this._subscribers = {};
2162
+ }
2163
+ t2.prototype.subscribe = function(e3, t3, i2) {
2164
+ this.isHandlerAttached(e3, t3) || this.get(t3).push({ handler: e3, context: i2, eventName: t3 });
2165
+ }, t2.prototype.unsubscribe = function(e3, t3) {
2166
+ this._subscribers[t3] = this.get(t3).filter(function(t4) {
2167
+ return e3 !== t4.handler;
2168
+ });
2169
+ }, t2.prototype.unsubscribeAll = function() {
2170
+ this._subscribers = {};
2171
+ }, t2.prototype.trigger = function(e3, t3) {
2172
+ var i2 = this;
2173
+ this.get(e3).concat(this.get("*")).forEach(function(e4) {
2174
+ setTimeout(function() {
2175
+ i2.isHandlerAttached(e4.handler, e4.eventName) && e4.handler.call(e4.context, t3);
2176
+ }, 0);
2177
+ });
2178
+ }, t2.prototype.triggerSync = function(e3, t3) {
2179
+ this.get(e3).concat(this.get("*")).forEach(function(e4) {
2180
+ e4.handler.call(e4.context, t3);
2181
+ });
2182
+ }, t2.prototype.get = function(e3) {
2183
+ return this._subscribers[e3] || (this._subscribers[e3] = []), this._subscribers[e3];
2184
+ }, t2.prototype.isHandlerAttached = function(e3, t3) {
2185
+ return this.get(t3).some(function(t4) {
2186
+ return e3 === t4.handler;
2187
+ });
2188
+ }, e2.exports = t2;
2189
+ }, 77: (e2) => {
2190
+ "use strict";
2191
+ function t2() {
2192
+ }
2193
+ function i2(e3, t3, i3) {
2194
+ var n2 = document.createElement("iframe");
2195
+ return n2.src = t3 || "about:blank", n2.marginWidth = "0", n2.marginHeight = "0", n2.frameBorder = "0", n2.width = "100%", n2.height = "100%", r(n2), i3 && (n2.style.zIndex = i3), n2.setAttribute("SCROLLING", "NO"), e3.innerHTML = "", e3.appendChild(n2), n2;
2196
+ }
2197
+ function r(e3) {
2198
+ e3 && (e3.style.position = "absolute", e3.style.left = "0", e3.style.top = "0", e3.style.margin = "0px", e3.style.padding = "0px", e3.style.border = "none", e3.style.width = "100%", e3.style.height = "100%");
2199
+ }
2200
+ function n(e3, t3) {
2201
+ return Object.keys(t3).forEach(function(i3) {
2202
+ var r2 = "object" == typeof r2 ? JSON.stringify(t3[i3]) : t3[i3];
2203
+ e3 = e3.replace(new RegExp("{{" + i3 + "}}", "g"), r2);
2204
+ }), e3;
2205
+ }
2206
+ function a(e3, t3) {
2207
+ var i3 = e3.contentWindow && e3.contentWindow.document;
2208
+ return !!i3 && (i3.write(t3), true);
2209
+ }
2210
+ e2.exports = { noop: t2, validate: function(e3, t3) {
2211
+ return e3 ? null : new Error(t3);
2212
+ }, callbackTimeout: function(e3, i3, r2) {
2213
+ var n2;
2214
+ return n2 = setTimeout(function() {
2215
+ i3 = t2, r2();
2216
+ }, e3), function() {
2217
+ var e4 = Array.prototype.slice.call(arguments);
2218
+ i3.apply(this, e4) && clearTimeout(n2);
2219
+ };
2220
+ }, createElementInEl: function(e3, t3, i3) {
2221
+ var r2 = document.createElement(t3);
2222
+ return i3 && (r2.id = i3), e3.appendChild(r2), r2;
2223
+ }, createIframeWithContent: function(e3, t3, r2) {
2224
+ var o = i2(e3, null, r2.zIndex);
2225
+ if (a(o, n(t3, r2)))
2226
+ return o;
2227
+ }, createIframe: i2, setFullSizeStyle: r, simpleTemplate: n, setIframeContent: a, extend: function(e3, t3) {
2228
+ return Object.keys(t3).forEach(function(i3) {
2229
+ e3[i3] = t3[i3];
2230
+ }), e3;
2231
+ }, unique: function(e3) {
2232
+ var t3 = -1;
2233
+ return function() {
2234
+ return e3 + "_" + ++t3;
2235
+ };
2236
+ } };
2237
+ }, 893: () => {
2238
+ } }, t = {};
2239
+ function i(r) {
2240
+ var n = t[r];
2241
+ if (void 0 !== n)
2242
+ return n.exports;
2243
+ var a = t[r] = { exports: {} };
2244
+ return e[r].call(a.exports, a, a.exports, i), a.exports;
2245
+ }
2246
+ i.g = function() {
2247
+ if ("object" == typeof globalThis)
2248
+ return globalThis;
2249
+ try {
2250
+ return this || new Function("return this")();
2251
+ } catch (e2) {
2252
+ if ("object" == typeof window)
2253
+ return window;
2254
+ }
2255
+ }(), (() => {
2256
+ var _e, _t, _i, _r, _n, _a, _o, _s, _l, _c, _u, _d, _p, _h, _s2, _f;
2257
+ "use strict";
2258
+ const e2 = videojs;
2259
+ var t2 = i(248), r = i(144), n = i(908);
2260
+ class a extends e2.EventTarget {
2261
+ constructor(e3, t3) {
2262
+ super();
2263
+ __privateAdd(this, _e, () => {
2264
+ const e3 = this.options.skip, t3 = this.player;
2265
+ e3 > 0 && (t3.duration() || this.duration) >= e3 && (this.skipButtonElement.style.display = "block", this.options.displayRemainingTime && (this.remainingTimeElement.style.display = "block"), this.options.displayRemainingTimeIcons && (this.remainingTimePlayElement.classList.remove("vjs-hidden"), this.remainingTimeMuteElement.classList.remove("vjs-hidden")), t3.on("adtimeupdate", __privateGet(this, _t))), t3.loadingSpinner.el().style.display = "none";
2266
+ });
2267
+ __privateAdd(this, _t, () => {
2268
+ this.player.loadingSpinner.el().style.display = "none";
2269
+ const e3 = Math.ceil(this.options.skip - this.player.currentTime());
2270
+ if (this.options.displayRemainingTime) {
2271
+ const e4 = Math.ceil(this.player.remainingTime());
2272
+ this.remainingTimeElement.innerHTML = this.options.messages.remainingTime.replace("{seconds}", e4);
2273
+ }
2274
+ var t3;
2275
+ e3 > 0 ? (o(t3 = this.skipButtonElement) && (t3.className = t3.className.replace(" enabled ", "")), this.skipButtonElement.innerHTML = this.options.messages.skipCountdown.replace("{seconds}", e3)) : (!function(e4) {
2276
+ o(e4) || (e4.className += " enabled ");
2277
+ }(this.skipButtonElement), this.skipButtonElement.innerHTML = this.options.messages.skip);
2278
+ });
2279
+ this.player = e3, this.options = t3, this.duration = 0, this.originalState = { controlsEnabled: e3.controls(), seekEnabled: e3.controlBar.progressControl.enabled() };
2280
+ }
2281
+ setUp() {
2282
+ const e3 = this.player, t3 = this.options, i2 = (i3) => {
2283
+ if (!t3.displayRemainingTimeIcons)
2284
+ return;
2285
+ const { className: r2, action: n2, toggleClasses: a2, events: o2, initialState: s2 } = { play: { className: "vjs-icon-play vast-remaining-time-icon-play", action: (e4) => e4.paused() ? e4.play() : e4.pause(), toggleClasses: ["vjs-icon-pause", "vjs-icon-play"], events: ["adplay", "adpause"], initialState: (e4) => e4.paused() ? "vjs-icon-play" : "vjs-icon-pause" }, mute: { className: "vast-remaining-time-icon-mute", action: (e4) => e4.muted(!e4.muted()), toggleClasses: ["vjs-icon-volume-high", "vjs-icon-volume-mute"], events: ["advolumechange"], initialState: (e4) => e4.muted() ? "vjs-icon-volume-mute" : "vjs-icon-volume-high" } }[i3], l2 = e3.addChild("button", { className: `vjs-hidden vjs-visible-text vjs-button vast-remaining-time-icon ${r2}`, clickHandler: function() {
2286
+ n2(this.player);
2287
+ }.bind(this) });
2288
+ l2.removeClass("vjs-control"), l2.addClass(s2(e3));
2289
+ const c2 = () => {
2290
+ a2.forEach((e4) => l2.toggleClass(e4));
2291
+ };
2292
+ this[`remainingTime${i3.charAt(0).toUpperCase() + i3.slice(1)}Element`] = l2.el(), o2.forEach((t4) => e3.on(t4, c2));
2293
+ };
2294
+ e3.controls(t3.controlsEnabled), t3.seekEnabled ? e3.controlBar.progressControl.enable() : e3.controlBar.progressControl.disable(), (() => {
2295
+ const t4 = this.blocker = n.document.createElement("div");
2296
+ t4.className = "vast-blocker", t4.onclick = () => {
2297
+ if (e3.paused())
2298
+ return e3.play(), false;
2299
+ this.trigger("click");
2300
+ }, e3.el().insertBefore(t4, e3.controlBar.el());
2301
+ })(), (() => {
2302
+ const t4 = this.skipButtonElement = n.document.createElement("div");
2303
+ t4.className = "vast-skip-button", t4.style.display = "none", e3.el().appendChild(t4), e3.one("adplay", __privateGet(this, _e)), t4.onclick = (e4) => {
2304
+ if ((" " + t4.className + " ").indexOf(" enabled ") >= 0 && this.trigger("skip"), void 0 === n.Event.prototype.stopPropagation)
2305
+ return false;
2306
+ e4.stopPropagation();
2307
+ };
2308
+ })(), (() => {
2309
+ if (!t3.displayRemainingTime)
2310
+ return;
2311
+ const i3 = this.remainingTimeElement = n.document.createElement("div");
2312
+ i3.className = "vast-remaining-time", i3.style.display = "none", e3.el().appendChild(i3);
2313
+ })(), i2("play"), i2("mute");
2314
+ }
2315
+ tearDown() {
2316
+ const e3 = this.player, t3 = this.originalState;
2317
+ e3.controls(t3.controlsEnabled), t3.seekEnabled ? e3.controlBar.progressControl.enable() : e3.controlBar.progressControl.disable(), this.blocker.parentElement.removeChild(this.blocker), this.skipButtonElement.parentElement.removeChild(this.skipButtonElement), this.options.displayRemainingTime && this.remainingTimeElement.parentElement.removeChild(this.remainingTimeElement), this.options.displayRemainingTimeIcons && (this.remainingTimePlayElement.parentElement.removeChild(this.remainingTimePlayElement), this.remainingTimeMuteElement.parentElement.removeChild(this.remainingTimeMuteElement)), e3.off("adtimeupdate", __privateGet(this, _t)), e3.off("adplay", __privateGet(this, _e));
2318
+ }
2319
+ }
2320
+ _e = new WeakMap();
2321
+ _t = new WeakMap();
2322
+ function o(e3) {
2323
+ return (" " + e3.className + " ").indexOf(" enabled ") > -1;
2324
+ }
2325
+ function s(e3, t3 = null) {
2326
+ let i2;
2327
+ return function() {
2328
+ return e3 && (i2 = e3.apply(t3 || this, arguments), e3 = null), i2;
2329
+ };
2330
+ }
2331
+ function l(e3) {
2332
+ return "linear" === e3.type && e3.mediaFiles.length;
2333
+ }
2334
+ function c(e3) {
2335
+ return "companion" === e3.type;
2336
+ }
2337
+ function u(e3, t3 = null) {
2338
+ let i2 = null;
2339
+ if ("string" == typeof e3)
2340
+ if (e3.includes("%")) {
2341
+ if (null != t3) {
2342
+ i2 = e3.replace("%", "") / 100 * t3;
2343
+ }
2344
+ } else if (e3.includes(":")) {
2345
+ const [t4, r2, n2] = e3.split(":").slice(-3);
2346
+ i2 = 3600 * parseInt(t4 || 0, 10) + 60 * parseInt(r2 || 0, 10) + parseInt(n2 || 0, 10);
2347
+ } else
2348
+ i2 = parseInt(e3);
2349
+ return null == i2 && (i2 = Number(e3)), isNaN(i2) ? null : i2;
2350
+ }
2351
+ class d {
2352
+ constructor(e3, t3) {
2353
+ __privateAdd(this, _i, void 0);
2354
+ __privateAdd(this, _r, void 0);
2355
+ __privateAdd(this, _n, void 0);
2356
+ __privateSet(this, _i, e3), __privateSet(this, _r, t3), __privateSet(this, _n, false);
2357
+ }
2358
+ get linearCreative() {
2359
+ return __privateGet(this, _i).creative;
2360
+ }
2361
+ get linearAdTracker() {
2362
+ return __privateGet(this, _i);
2363
+ }
2364
+ get companionTracker() {
2365
+ return __privateGet(this, _r);
2366
+ }
2367
+ get skipAfterDuration() {
2368
+ return __privateGet(this, _n);
2369
+ }
2370
+ set skipAfterDuration(e3) {
2371
+ __privateSet(this, _n, e3);
2372
+ }
2373
+ hasVideoMedia() {
2374
+ return this.linearCreative.mediaFiles.some((e3) => e3 && null == e3.apiFramework);
2375
+ }
2376
+ }
2377
+ _i = new WeakMap();
2378
+ _r = new WeakMap();
2379
+ _n = new WeakMap();
2380
+ class p {
2381
+ constructor(e3, t3, i2, r2) {
2382
+ __privateAdd(this, _a, void 0);
2383
+ __privateAdd(this, _o, void 0);
2384
+ __privateAdd(this, _s, void 0);
2385
+ __privateAdd(this, _l, void 0);
2386
+ __privateAdd(this, _c, (e3) => e3.map((e4) => {
2387
+ const i2 = new t2.VASTTracker(__privateGet(this, _a), e4, e4.creatives.find(l), e4.creatives.find(c));
2388
+ i2.on("clickthrough", h);
2389
+ let r2 = null;
2390
+ const n2 = e4.creatives.find(c);
2391
+ if (n2) {
2392
+ const i3 = __privateGet(this, _s), a2 = n2.variations.filter((e5) => e5.staticResource).filter((e5) => 0 === e5.type.indexOf("image")).find((e5) => parseInt(e5.width, 10) <= i3.companion.maxWidth && parseInt(e5.height, 10) <= i3.companion.maxHeight);
2393
+ a2 && (r2 = new t2.VASTTracker(__privateGet(this, _a), e4, n2, a2), r2.on("clickthrough", h));
2394
+ }
2395
+ return new d(i2, r2);
2396
+ }));
2397
+ __privateSet(this, _a, e3), __privateSet(this, _o, t3), __privateSet(this, _l, i2), __privateSet(this, _s, r2);
2398
+ }
2399
+ loadAds(e3 = {}) {
2400
+ return new Promise((t3, i2) => {
2401
+ const { url: r2, xml: n2 } = e3, a2 = (Array.isArray(r2) ? r2 : [r2]).filter((e4) => null != e4);
2402
+ let o2;
2403
+ if (a2.length)
2404
+ o2 = Promise.resolve([]), a2.forEach((e4) => {
2405
+ o2 = o2.then((t4) => null == t4 || 0 === t4.length ? this.loadAdsWithUrl(e4) : t4).catch((e5) => []);
2406
+ });
2407
+ else {
2408
+ if (null == n2)
2409
+ throw new Error("xml or url must be set");
2410
+ o2 = this.loadAdsWithXml(n2);
2411
+ }
2412
+ o2.then(t3).catch(i2);
2413
+ });
2414
+ }
2415
+ loadAdsWithXml(e3) {
2416
+ return new Promise((t3, i2) => {
2417
+ let r2;
2418
+ if (e3.constructor === n.XMLDocument)
2419
+ r2 = e3;
2420
+ else {
2421
+ if (e3.constructor !== String)
2422
+ throw new Error("xml config option must be a String or XMLDocument");
2423
+ r2 = new n.DOMParser().parseFromString(e3, "application/xml");
2424
+ }
2425
+ __privateGet(this, _o).parseVAST(r2).then(__privateGet(this, _l).selectAds).then(__privateGet(this, _c)).then(t3).catch(i2);
2426
+ });
2427
+ }
2428
+ loadAdsWithUrl(e3) {
2429
+ return new Promise((t3, i2) => {
2430
+ __privateGet(this, _a).get(e3, { withCredentials: __privateGet(this, _s).withCredentials, wrapperLimit: __privateGet(this, _s).wrapperLimit }).then(__privateGet(this, _l).selectAds).then(__privateGet(this, _c)).then(t3).catch(i2);
2431
+ });
2432
+ }
2433
+ }
2434
+ _a = new WeakMap();
2435
+ _o = new WeakMap();
2436
+ _s = new WeakMap();
2437
+ _l = new WeakMap();
2438
+ _c = new WeakMap();
2439
+ function h(e3) {
2440
+ n.open(e3, "_blank");
2441
+ }
2442
+ class f {
2443
+ selectAds(e3) {
2444
+ if (!e3.ads || 0 === e3.ads.length)
2445
+ throw new Error("no ads found in VAST");
2446
+ const t3 = e3.ads.filter((e4) => e4.creatives.some(l));
2447
+ if (!t3.length)
2448
+ throw new Error("no linear ads found in VAST");
2449
+ const i2 = t3.filter((e4) => e4.sequence);
2450
+ if (i2.length)
2451
+ return i2.sort((e4, t4) => e4.sequence - t4.sequence);
2452
+ return t3.filter((e4) => !i2.includes(e4)).slice(0, 1);
2453
+ }
2454
+ }
2455
+ var m = i(178);
2456
+ function v(e3) {
2457
+ if (e3) {
2458
+ const t3 = e3.ad, i2 = e3.creative;
2459
+ return { mediaFiles: i2.mediaFiles.map((e4) => Object.assign({}, e4)), adSequenceId: t3.sequence, adId: t3.id, creativeAdId: i2.id };
2460
+ }
2461
+ }
2462
+ const g = ["application/x-javascript", "text/javascript", "application/javascript"];
2463
+ class y {
2464
+ constructor(e3, t3) {
2465
+ __privateAdd(this, _u, void 0);
2466
+ __privateAdd(this, _d, void 0);
2467
+ __privateAdd(this, _p, void 0);
2468
+ __privateAdd(this, _h, void 0);
2469
+ __privateAdd(this, _s2, void 0);
2470
+ __privateAdd(this, _f, void 0);
2471
+ __privateSet(this, _h, e3), __privateSet(this, _s2, t3), __privateSet(this, _f, new videojs.EventTarget());
2472
+ }
2473
+ handle(e3) {
2474
+ return __privateSet(this, _d, false), __privateSet(this, _p, false), __privateSet(this, _u, false), new Promise((t3, i2) => {
2475
+ const a2 = __privateGet(this, _s2), o2 = __privateGet(this, _h);
2476
+ let l2 = null, c2 = {}, u2 = false;
2477
+ const d2 = e3.creative, p2 = d2.mediaFiles.find((e4) => "VPAID" === e4.apiFramework && function(e5) {
2478
+ return g.indexOf(e5.mimeType.trim()) > -1;
2479
+ }(e4));
2480
+ if (!p2)
2481
+ throw new Error("Invalid VPAID media file: only JavaScript is supported");
2482
+ const h2 = o2.el().querySelector(".vjs-tech");
2483
+ l2 = function(e4) {
2484
+ const t4 = e4.vpaid.containerId, i3 = e4.vpaid.containerClass;
2485
+ let n2 = r.getElementById(t4);
2486
+ n2 || (n2 = r.getElementsByClassName(i3)[0]);
2487
+ return n2;
2488
+ }(a2), l2 ? u2 = true : (l2 = function(e4) {
2489
+ const t4 = e4.vpaid.containerId, i3 = e4.vpaid.containerClass, n2 = r.createElement("div");
2490
+ t4 && n2.setAttribute("id", t4);
2491
+ i3 && n2.classList.add(i3);
2492
+ return n2;
2493
+ }(a2), u2 = false), c2 = A(l2), o2.el().insertBefore(l2, o2.controlBar.el());
2494
+ const f2 = new m(l2, h2, {});
2495
+ f2.loadAdUnit(p2.fileURL, (r2, p3) => {
2496
+ let h3;
2497
+ if (r2)
2498
+ return void i2(r2);
2499
+ const m2 = () => {
2500
+ y2(), t3(), o2.trigger("vpaid.AdStopped"), o2.trigger({ type: "vast.adEnd", vast: v(e3) });
2501
+ };
2502
+ p3.subscribe("AdStopped", m2);
2503
+ const g2 = (e4) => {
2504
+ if (p3 && !__privateGet(this, _u)) {
2505
+ p3.unsubscribe("AdStopped", m2);
2506
+ const t4 = () => {
2507
+ __privateSet(this, _u, true), y2(), i2(e4), o2.trigger("vpaid.AdStopped");
2508
+ };
2509
+ k(p3, "AdStopped", t4, t4), p3.stopAd();
2510
+ } else
2511
+ __privateSet(this, _u, true), i2(e4);
2512
+ };
2513
+ if (__privateGet(this, _f).on("forceStopAd", g2), __privateGet(this, _d))
2514
+ return void g2("Received cancel signal from player");
2515
+ function y2() {
2516
+ if (o2.controlBar.show(), o2.off("playerresize", R), "new" === a2.vpaid.videoInstance && h3.parentElement && h3.parentElement.removeChild(h3), f2.destroy(), l2) {
2517
+ if (u2) {
2518
+ l2.innerHTML = "";
2519
+ const e4 = c2, t4 = A(l2);
2520
+ for (const [i3, r3] of Object.entries(t4))
2521
+ e4.hasOwnProperty(i3) ? e4[i3] !== r3 && l2.setAttribute(i3, e4[i3]) : l2.removeAttribute(i3);
2522
+ for (const [i3, r3] of Object.entries(e4))
2523
+ t4.hasOwnProperty(i3) || l2.setAttribute(i3, r3);
2524
+ } else
2525
+ l2.parentElement && l2.parentElement.removeChild(l2);
2526
+ l2 = null;
2527
+ }
2528
+ }
2529
+ const b2 = () => {
2530
+ if (__privateGet(this, _d))
2531
+ return void g2("Received cancel signal");
2532
+ p3.subscribe("AdSkipped", () => {
2533
+ e3.skip(), o2.trigger("vpaid.AdSkipped"), o2.trigger({ type: "vast.adSkip", vast: v(e3) });
2534
+ }), p3.subscribe("AdVolumeChange", () => {
2535
+ const t5 = o2.volume();
2536
+ p3.getAdVolume((i3, r3) => {
2537
+ i3 || (0 === r3 && t5 > 0 ? e3.setMuted(true) : r3 > 0 && 0 === t5 && e3.setMuted(false), o2.volume(r3), o2.trigger("vpaid.AdVolumeChange"));
2538
+ });
2539
+ }), p3.subscribe("AdImpression", () => {
2540
+ e3.trackImpression(), o2.trigger("vpaid.AdImpression");
2541
+ }), p3.subscribe("AdClickThru", (t5, i3, r3) => {
2542
+ r3 && e3.once("clickthrough", (e4) => {
2543
+ n.open(e4, "_blank");
2544
+ }), e3.click(t5), o2.trigger("vpaid.AdClickThru");
2545
+ }), p3.subscribe("AdVideoFirstQuartile", () => {
2546
+ e3.track("firstQuartile"), o2.trigger("vpaid.AdVideoFirstQuartile");
2547
+ }), p3.subscribe("AdVideoMidpoint", () => {
2548
+ e3.track("midpoint"), o2.trigger("vpaid.AdVideoMidpoint");
2549
+ }), p3.subscribe("AdVideoThirdQuartile", () => {
2550
+ e3.track("thirdQuartile"), o2.trigger("vpaid.AdVideoThirdQuartile");
2551
+ }), p3.subscribe("AdVideoComplete", () => {
2552
+ e3.track("complete"), o2.trigger("vpaid.AdVideoComplete");
2553
+ }), p3.subscribe("AdUserAcceptInvitation", () => {
2554
+ e3.acceptInvitation(), o2.trigger("vpaid.AdUserAcceptInvitation");
2555
+ }), p3.subscribe("AdUserMinimize", () => {
2556
+ e3.minimize(), o2.trigger("vpaid.AdUserMinimize");
2557
+ }), p3.subscribe("AdUserClose", () => {
2558
+ e3.close(), o2.trigger("vpaid.AdUserClose");
2559
+ }), p3.subscribe("AdPaused", () => {
2560
+ e3.setPaused(true), o2.trigger("vpaid.AdPaused");
2561
+ }), p3.subscribe("AdPlaying", () => {
2562
+ e3.setPaused(false), o2.trigger("vpaid.AdPlaying");
2563
+ }), p3.getAdLinear(T((e4, i3) => {
2564
+ __privateGet(this, _d) ? g2("Received cancel signal") : e4 ? g2(e4) : i3 ? t4() : g2("Non-linear not supported");
2565
+ }, () => {
2566
+ g2("Unable to get mode of operation: linear or non-linear");
2567
+ }));
2568
+ const t4 = () => {
2569
+ o2.controlBar.hide();
2570
+ const e4 = s(E2);
2571
+ k(p3, "AdStarted", e4, g2), p3.startAd();
2572
+ };
2573
+ }, E2 = () => {
2574
+ __privateGet(this, _d) ? g2("Received cancel signal") : (__privateSet(this, _p, true), e3.track("start"), o2.on("playerresize", R), o2.trigger("ads-ad-started"), o2.trigger({ type: "vast.adStart", vast: v(e3) }));
2575
+ }, R = () => {
2576
+ p3.resizeAd(o2.currentWidth(), o2.currentHeight(), o2.isFullscreen() ? "fullscreen" : "normal");
2577
+ };
2578
+ p3.handshakeVersion("2.0", (t4, r3) => {
2579
+ if (t4)
2580
+ return log.console(t4), void g2("Error on VPAID handshake");
2581
+ const s2 = { AdParameters: d2.adParameters || "" }, c3 = a2.vpaid.videoInstance;
2582
+ "same" === c3 ? h3 = o2.tech({ kindaKnowWhatImDoing: true }).el() : "new" === c3 ? (h3 = n.document.createElement("video"), h3.style.cssText = "position:absolute; top:0; left:0; z-index:2 !important;", l2.appendChild(h3)) : h3 = null;
2583
+ const u3 = { slot: l2, videoSlot: h3 };
2584
+ k(p3, "AdLoaded", b2, g2);
2585
+ const f3 = o2.isFullscreen() ? "fullscreen" : "normal";
2586
+ p3.subscribe("AdError", (t5) => {
2587
+ e3.error({ ERRORCODE: 901 }), __privateSet(this, _u, true), y2(), i2(`Fatal VPAID Error: ${"object" == typeof t5 ? JSON.stringify(t5) : t5}`), o2.trigger({ type: "vpaid.AdError", error: t5 });
2588
+ }), p3.initAd(o2.currentWidth(), o2.currentHeight(), f3, -1, s2, u3);
2589
+ });
2590
+ });
2591
+ });
2592
+ }
2593
+ cancel() {
2594
+ __privateSet(this, _d, true), __privateGet(this, _p) && __privateGet(this, _f).trigger("forceStopAd");
2595
+ }
2596
+ }
2597
+ _u = new WeakMap();
2598
+ _d = new WeakMap();
2599
+ _p = new WeakMap();
2600
+ _h = new WeakMap();
2601
+ _s2 = new WeakMap();
2602
+ _f = new WeakMap();
2603
+ function A(e3) {
2604
+ const t3 = {};
2605
+ for (const i2 of e3.attributes)
2606
+ t3[i2.name] = i2.value;
2607
+ return t3;
2608
+ }
2609
+ function T(e3, t3 = null) {
2610
+ const i2 = setTimeout(() => {
2611
+ e3 = () => {
2612
+ }, t3 && t3();
2613
+ }, 1e4);
2614
+ return function() {
2615
+ clearTimeout(i2), e3.apply(null, arguments);
2616
+ };
2617
+ }
2618
+ function k(e3, t3, i2, r2) {
2619
+ const n2 = T(i2, () => {
2620
+ r2 && r2(new Error(`Timeout while waiting for ${t3} event.`));
2621
+ });
2622
+ e3.subscribe(t3, n2);
2623
+ }
2624
+ const b = e2.getPlugin("plugin"), E = Object.freeze({ seekEnabled: false, controlsEnabled: false, wrapperLimit: 10, withCredentials: true, skip: 0, displayRemainingTime: false, displayRemainingTimeIcons: false, messages: { skip: "Skip", skipCountdown: "Skip in {seconds}...", remainingTime: "This ad will end in {seconds}" }, vpaid: { containerId: void 0, containerClass: "vjs-vpaid-container", videoInstance: "none" }, companion: { elementId: null, maxWidth: 0, maxHeight: 0 } });
2625
+ e2.registerPlugin("vast", class extends b {
2626
+ constructor(i2, n2) {
2627
+ super(i2), "function" == typeof i2.ads && i2.ads({ debug: false, liveCuePoints: false }), i2.on("play", function() {
2628
+ });
2629
+ const o2 = parseInt(e2.VERSION, 10) >= 8 ? e2.obj.merge : e2.mergeOptions;
2630
+ n2 = o2(E, n2 || {});
2631
+ const l2 = new t2.VASTClient(), c2 = [];
2632
+ let d2 = null, h2 = 0, m2 = 0;
2633
+ const g2 = new y(i2, n2);
2634
+ let A2 = false, T2 = n2.schedule;
2635
+ var k2;
2636
+ null == T2 || 0 === T2.length ? T2 = [{ offset: 0, url: n2.url || null, xml: n2.xml || null }] : (k2 = T2, T2 = JSON.parse(JSON.stringify(k2)), T2.forEach((e3) => delete e3.offsetInSeconds));
2637
+ const b2 = function(e3) {
2638
+ return e3.find(B);
2639
+ }(T2), R = function(e3) {
2640
+ return e3.find(_);
2641
+ }(T2), w = function(e3) {
2642
+ return e3.filter((e4) => !B(e4) && !_(e4));
2643
+ }(T2).sort((e3, t3) => e3.offset - t3.offset), N = i2.autoplay();
2644
+ i2.on("adtimeout", () => {
2645
+ A2 = true;
2646
+ });
2647
+ const C = new a(i2, n2);
2648
+ function L() {
2649
+ (d2 == null ? void 0 : d2.hasVideoMedia()) && (d2.linearAdTracker.skip(), i2.trigger({ type: "vast.skipAd", vast: v(d2.linearAdTracker) }), D());
2650
+ }
2651
+ C.on("skip", L), C.on("click", () => {
2652
+ d2.linearAdTracker.click();
2653
+ });
2654
+ const I = (() => {
2655
+ let e3 = false;
2656
+ return () => {
2657
+ if (e3)
2658
+ return;
2659
+ let t3 = null;
2660
+ for (; w.length > 0 && (t3 = w[0].offsetInSeconds, null == t3); ) {
2661
+ const { offset: e4 } = w[0];
2662
+ t3 = u(e4, i2.duration()), null == t3 ? w.shift() : w[0].offsetInSeconds = t3;
2663
+ }
2664
+ if (null != t3 && this.player.currentTime() > t3) {
2665
+ e3 = true;
2666
+ const t4 = w.shift();
2667
+ S.loadAds(t4).then((e4) => {
2668
+ e4.length > 0 && (c2.push(...e4), d2 = null, M());
2669
+ }).catch((e4) => {
2670
+ }).finally(() => {
2671
+ e3 = false;
2672
+ });
2673
+ }
2674
+ };
2675
+ })();
2676
+ w.length > 0 && i2.on("timeupdate", I), i2.on("readyforpostroll", () => {
2677
+ A2 = false, S.loadAds(R).then((e3) => {
2678
+ A2 ? e3.forEach((e4) => {
2679
+ e4.linearAdTracker.error({ ERRORCODE: 301 });
2680
+ }) : e3.length > 0 ? (c2.push(...e3), d2 = null, M()) : i2.trigger("nopostroll");
2681
+ }).catch((e3) => {
2682
+ i2.trigger("nopostroll");
2683
+ });
2684
+ }), i2.on("readyforpreroll", () => {
2685
+ M();
2686
+ });
2687
+ const U = s(() => {
2688
+ i2.trigger("adsready");
2689
+ });
2690
+ setTimeout(U, 3e3);
2691
+ const S = new p(l2, new t2.VASTParser(), new f(), n2);
2692
+ S.loadAds(b2).then((e3) => {
2693
+ A2 ? e3.forEach((e4) => {
2694
+ e4.linearAdTracker.error({ ERRORCODE: 301 });
2695
+ }) : e3.length > 0 ? (c2.push(...e3), d2 = null) : i2.trigger("nopreroll");
2696
+ }).catch((e3) => {
2697
+ i2.trigger("nopreroll");
2698
+ }).finally(() => {
2699
+ U(), N && i2.play();
2700
+ });
2701
+ const x = (e3) => e3.filter((e4) => null == e4.apiFramework).map((e4) => ({ type: e4.mimeType, src: e4.fileURL })), D = () => {
2702
+ const e3 = c2.shift();
2703
+ if ((e3 == null ? void 0 : e3.hasVideoMedia()) ? (d2 == null ? void 0 : d2.hasVideoMedia()) || C.setUp() : (d2 == null ? void 0 : d2.hasVideoMedia()) && C.tearDown(), e3) {
2704
+ if (d2 = e3, h2++, d2.hasVideoMedia()) {
2705
+ const e4 = d2.linearCreative.mediaFiles, t3 = e4.filter((e5) => "streaming" === e5.deliveryType), r2 = e4.filter((e5) => "streaming" !== e5.deliveryType);
2706
+ if (r2.length > 0)
2707
+ i2.src(x(r2));
2708
+ else if (t3.length > 0) {
2709
+ let e5 = d2.linearAdTracker.assetDuration;
2710
+ if (null == e5 || e5 < 1)
2711
+ return void D();
2712
+ i2.src(x(t3)), d2.skipAfterDuration = true;
2713
+ }
2714
+ C.duration = d2.linearAdTracker.assetDuration || 0;
2715
+ } else
2716
+ g2.handle(d2.linearAdTracker).then(() => {
2717
+ D();
2718
+ }).catch((e4) => {
2719
+ D();
2720
+ });
2721
+ P();
2722
+ } else
2723
+ d2 = null, h2 = 0, F();
2724
+ }, { setUpEvents: O, tearDownEvents: V } = (() => {
2725
+ const e3 = () => {
2726
+ if (d2.skipAfterDuration) {
2727
+ const e4 = d2;
2728
+ setTimeout(() => {
2729
+ d2 === e4 && L();
2730
+ }, 1e3 * e4.linearAdTracker.assetDuration);
2731
+ }
2732
+ !d2.linearAdTracker.impressed && d2.hasVideoMedia() && (d2.linearAdTracker.trackImpression(), i2.trigger({ type: "vast.adStart", vast: v(d2.linearAdTracker) }));
2733
+ }, t3 = () => {
2734
+ d2 && (isNaN(d2.linearAdTracker.assetDuration) && (d2.linearAdTracker.assetDuration = i2.duration()), d2.linearAdTracker.setProgress(i2.currentTime()));
2735
+ }, r2 = () => {
2736
+ i2.remainingTime() > 0 && (d2.linearAdTracker.setPaused(true), i2.one("adplay", () => {
2737
+ d2.linearAdTracker.setPaused(false);
2738
+ }));
2739
+ }, n3 = () => {
2740
+ d2.linearAdTracker.error({ ERRORCODE: 405 }), i2.error(null), D();
2741
+ }, a2 = () => {
2742
+ d2.linearAdTracker.setFullscreen(i2.isFullscreen());
2743
+ }, o3 = (() => {
2744
+ let e4 = i2.muted(), t4 = i2.volume();
2745
+ return () => {
2746
+ const r3 = i2.volume(), n4 = i2.muted();
2747
+ e4 !== n4 ? (d2.linearAdTracker.setMuted(n4), e4 = n4) : t4 !== r3 && (t4 > 0 && 0 === r3 ? d2.linearAdTracker.setMuted(true) : 0 === t4 && r3 > 0 && d2.linearAdTracker.setMuted(false), t4 = r3);
2748
+ };
2749
+ })(), s2 = () => {
2750
+ d2.hasVideoMedia() && (d2.linearAdTracker.complete(), i2.trigger({ type: "vast.adEnd", vast: v(d2.linearAdTracker) }), D());
2751
+ };
2752
+ return { setUpEvents: () => {
2753
+ i2.on("adended", s2), i2.on("adplay", e3), i2.on("adtimeupdate", t3), i2.on("adpause", r2), i2.on("aderror", n3), i2.on("advolumechange", o3), i2.on("fullscreenchange", a2);
2754
+ }, tearDownEvents: () => {
2755
+ i2.off("adended", s2), i2.off("adplay", e3), i2.off("adtimeupdate", t3), i2.off("adpause", r2), i2.off("aderror", n3), i2.off("advolumechange", o3), i2.off("fullscreenchange", a2);
2756
+ } };
2757
+ })(), P = () => {
2758
+ const e3 = d2.companionTracker, t3 = r.getElementById(n2.companion.elementId);
2759
+ if (e3 && e3.variation && t3) {
2760
+ const i3 = e3.variation, n3 = () => {
2761
+ e3.click();
2762
+ }, a2 = r.createElement("a");
2763
+ a2.src = "#", a2.addEventListener("click", n3);
2764
+ const o3 = r.createElement("img");
2765
+ o3.src = i3.staticResource, a2.appendChild(o3), t3.innerHTML = "", t3.appendChild(a2);
2766
+ } else
2767
+ t3 && (t3.innerHTML = "");
2768
+ }, M = () => {
2769
+ m2 = c2.length, i2.ads.startLinearAdMode(), O(), D();
2770
+ };
2771
+ function B(e3) {
2772
+ return 0 === e3.offset || null == e3.offset || "pre" === e3.offset;
2773
+ }
2774
+ function _(e3) {
2775
+ return "post" === e3.offset;
2776
+ }
2777
+ const F = () => {
2778
+ i2.ads.endLinearAdMode(), V();
2779
+ };
2780
+ }
2781
+ });
2782
+ })();
2783
+ })();
2784
+ }
2785
+ });
2786
+
2787
+ // lib/shared.js
2788
+ var DEFAULT_SKIP_TIME = 5;
2789
+ var DEFAULT_SKIP_COUNTDOWN_MESSAGE = "Skip in {seconds}...";
2790
+ var DEFAULT_SKIP_MESSAGE = "Skip";
2791
+ var settings = (s) => {
2792
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i;
2793
+ return {
2794
+ preroll: {
2795
+ enabled: (_a = s["vast-preroll-enabled"]) != null ? _a : false,
2796
+ url: s["vast-preroll-url"]
2797
+ },
2798
+ midroll: {
2799
+ enabled: (_b = s["vast-midroll-enabled"]) != null ? _b : false,
2800
+ url: s["vast-midroll-url"],
2801
+ offset: (_c = s["vast-midroll-offset"]) != null ? _c : "25%"
2802
+ },
2803
+ postroll: {
2804
+ enabled: (_d = s["vast-postroll-enabled"]) != null ? _d : false,
2805
+ url: s["vast-postroll-url"]
2806
+ },
2807
+ embededEnabled: (_e = s["vast-embeded-enabled"]) != null ? _e : true,
2808
+ controlsEnabled: (_f = s["vast-player-controls-enabled"]) != null ? _f : true,
2809
+ skipTime: (_g = s["vast-skip-time"]) != null ? _g : DEFAULT_SKIP_TIME,
2810
+ messageSkipCountdown: (_h = s["vast-message-skip-countdown"]) != null ? _h : DEFAULT_SKIP_COUNTDOWN_MESSAGE,
2811
+ messageSkip: (_i = s["vast-message-skip"]) != null ? _i : DEFAULT_SKIP_MESSAGE,
2812
+ messageRemainingTime: s["vast-message-remainingTime"]
2813
+ };
2814
+ };
2815
+ var loadContribAds = async (player) => {
2816
+ try {
2817
+ await Promise.resolve().then(() => __toESM(require_videojs_ads_min()));
2818
+ await Promise.resolve().then(() => __toESM(require_videojsx_vast()));
2819
+ if (typeof player.ads === "function") {
2820
+ player.ads({
2821
+ debug: false,
2822
+ allowVjsAutoplay: true,
2823
+ playAdAlways: true,
2824
+ timeout: 5e3
2825
+ });
2826
+ console.log("VAST Plugin: Ads infrastructure ready.");
2827
+ } else {
2828
+ console.error("VAST Plugin: player.ads is still not defined after import");
2829
+ }
2830
+ } catch (e) {
2831
+ console.error("VAST Plugin: Error loading ads scripts", e);
2832
+ }
2833
+ };
2834
+ var getRollsStatus = (pluginSettings2) => {
2835
+ const isRollEnabled = (roll) => roll.url && roll.enabled;
2836
+ const rolls = {
2837
+ preroll: isRollEnabled(pluginSettings2.preroll),
2838
+ midroll: isRollEnabled(pluginSettings2.midroll),
2839
+ postroll: isRollEnabled(pluginSettings2.postroll)
2840
+ };
2841
+ return __spreadProps(__spreadValues({}, rolls), {
2842
+ hasAtLeastOneRollEnabled: Object.values(rolls).some(Boolean)
2843
+ });
2844
+ };
2845
+ var createVastSettings = (pluginSettings2) => {
2846
+ const { skipTime, controlsEnabled, messageSkip, messageSkipCountdown, messageRemainingTime } = pluginSettings2;
2847
+ const vastSettings = {
2848
+ skip: skipTime,
2849
+ controlsEnabled,
2850
+ seekEnabled: controlsEnabled,
2851
+ withCredentials: false,
2852
+ messages: {
2853
+ skip: messageSkip,
2854
+ skipCountdown: messageSkipCountdown
2855
+ },
2856
+ schedule: []
2857
+ };
2858
+ if (messageRemainingTime == null ? void 0 : messageRemainingTime.includes("{seconds}")) {
2859
+ Object.assign(vastSettings, {
2860
+ displayRemainingTime: true,
2861
+ displayRemainingTimeIcons: true,
2862
+ messages: __spreadProps(__spreadValues({}, vastSettings.messages), { remainingTime: messageRemainingTime })
2863
+ });
2864
+ }
2865
+ const rollsStatus2 = getRollsStatus(pluginSettings2);
2866
+ const rollConfigs = {
2867
+ preroll: { offset: "pre", roll: "pre" },
2868
+ midroll: { offset: pluginSettings2.midroll.offset, roll: "mid" },
2869
+ postroll: { offset: "post", roll: "post" }
2870
+ };
2871
+ Object.entries(rollConfigs).forEach(([rollType, { offset, roll }]) => {
2872
+ if (rollsStatus2[rollType]) {
2873
+ const rollUrl = pluginSettings2[rollType].url;
2874
+ if (rollUrl && offset) {
2875
+ if (rollType === "midroll") {
2876
+ const intervalStr = String(offset).trim();
2877
+ if (intervalStr.endsWith("%")) {
2878
+ let percentVal = parseFloat(intervalStr.replace("%", ""));
2879
+ if (!isNaN(percentVal) && percentVal >= 5) {
2880
+ let currentPercent = percentVal;
2881
+ while (currentPercent < 100) {
2882
+ vastSettings.schedule.push({ offset: currentPercent + "%", url: rollUrl });
2883
+ currentPercent += percentVal;
2884
+ }
2885
+ }
2886
+ } else {
2887
+ let intervalSec = parseFloat(intervalStr);
2888
+ if (!isNaN(intervalSec) && intervalSec >= 30) {
2889
+ let currentSec = intervalSec;
2890
+ const MAX_SECONDS = 604800;
2891
+ while (currentSec < MAX_SECONDS) {
2892
+ vastSettings.schedule.push({ offset: currentSec, url: rollUrl });
2893
+ currentSec += intervalSec;
2894
+ }
2895
+ }
2896
+ }
2897
+ } else {
2898
+ vastSettings.schedule.push({
2899
+ offset,
2900
+ url: rollUrl
2901
+ });
2902
+ }
2903
+ }
2904
+ }
2905
+ });
2906
+ return vastSettings;
2907
+ };
2908
+ var buildVastPlayer = async (vastSettings, player) => {
2909
+ try {
2910
+ const { default: VastPlugin } = await Promise.resolve().then(() => __toESM(require_videojsx_vast()));
2911
+ player.vast(vastSettings);
2912
+ } catch (error) {
2913
+ console.error("Error loading VastPlugin:", error);
2914
+ }
2915
+ };
2916
+
2917
+ // client/embed-client-plugin.js
2918
+ var pluginSettings = null;
2919
+ var rollsStatus = null;
2920
+ var initializationPromise = null;
2921
+ function register({ registerHook, peertubeHelpers }) {
2922
+ initializationPromise = init(peertubeHelpers);
2923
+ registerHook({
2924
+ target: "action:embed.player.loaded",
2925
+ handler: async ({ videojs: videojs2, player, video }) => {
2926
+ window.videojs = videojs2;
2927
+ window.player = player;
2928
+ loadContribAds(player);
2929
+ await initializationPromise;
2930
+ if (!pluginSettings.embededEnabled) {
2931
+ player.trigger("nopreroll");
2932
+ player.trigger("nopostroll");
2933
+ return;
2934
+ }
2935
+ if (rollsStatus.hasAtLeastOneRollEnabled) {
2936
+ try {
2937
+ const vastSettings = createVastSettings(pluginSettings);
2938
+ await buildVastPlayer(vastSettings, player);
2939
+ } catch (error) {
2940
+ console.error("[VAST PLUGIN] Error:", error);
2941
+ }
2942
+ }
2943
+ }
2944
+ });
2945
+ }
2946
+ async function init(peertubeHelpers) {
2947
+ if (pluginSettings && rollsStatus)
2948
+ return;
2949
+ try {
2950
+ const s = await peertubeHelpers.getSettings();
2951
+ if (!s) {
2952
+ console.error("Could not find settings.");
2953
+ return;
2954
+ }
2955
+ pluginSettings = settings(s);
2956
+ rollsStatus = getRollsStatus(pluginSettings);
2957
+ } catch (error) {
2958
+ console.error("[VAST PLUGIN] Error initializing settings:", error);
2959
+ }
2960
+ }
2961
+ export {
2962
+ register
2963
+ };
2964
+ /*! @name videojs-contrib-ads @version 6.9.0 @license Apache-2.0 */