stormcloud-video-player 0.3.53 → 0.3.55

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.
@@ -227,9 +227,17 @@ function _ts_generator(thisArg, body) {
227
227
  },
228
228
  trys: [],
229
229
  ops: []
230
- }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
231
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
232
- return this;
230
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
231
+ return d(g, "next", {
232
+ value: verb(0)
233
+ }), d(g, "throw", {
234
+ value: verb(1)
235
+ }), d(g, "return", {
236
+ value: verb(2)
237
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
238
+ value: function() {
239
+ return this;
240
+ }
233
241
  }), g;
234
242
  function verb(n) {
235
243
  return function(v) {
@@ -329,20 +337,20 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
329
337
  var __getOwnPropNames = Object.getOwnPropertyNames;
330
338
  var __getProtoOf = Object.getPrototypeOf;
331
339
  var __hasOwnProp = Object.prototype.hasOwnProperty;
332
- var __export = function(target, all) {
340
+ var __export = function __export(target, all) {
333
341
  for(var name in all)__defProp(target, name, {
334
342
  get: all[name],
335
343
  enumerable: true
336
344
  });
337
345
  };
338
- var __copyProps = function(to, from, except, desc) {
346
+ var __copyProps = function __copyProps(to, from, except, desc) {
339
347
  if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
340
348
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
341
349
  try {
342
350
  var _loop = function() {
343
351
  var key = _step.value;
344
352
  if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
345
- get: function() {
353
+ get: function get() {
346
354
  return from[key];
347
355
  },
348
356
  enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
@@ -366,7 +374,7 @@ var __copyProps = function(to, from, except, desc) {
366
374
  }
367
375
  return to;
368
376
  };
369
- var __toESM = function(mod, isNodeMode, target) {
377
+ var __toESM = function __toESM(mod, isNodeMode, target) {
370
378
  return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
371
379
  // file that has been converted to a CommonJS file using a Babel-
372
380
  // compatible transform (i.e. "__esModule" has not been set), then set
@@ -376,7 +384,7 @@ var __toESM = function(mod, isNodeMode, target) {
376
384
  enumerable: true
377
385
  }) : target, mod);
378
386
  };
379
- var __toCommonJS = function(mod) {
387
+ var __toCommonJS = function __toCommonJS(mod) {
380
388
  return __copyProps(__defProp({}, "__esModule", {
381
389
  value: true
382
390
  }), mod);
@@ -384,7 +392,7 @@ var __toCommonJS = function(mod) {
384
392
  // src/players/index.ts
385
393
  var players_exports = {};
386
394
  __export(players_exports, {
387
- default: function() {
395
+ default: function _default() {
388
396
  return players_default;
389
397
  }
390
398
  });
@@ -403,23 +411,23 @@ var DASH_EXTENSIONS = /\.(mpd)($|\?)/i;
403
411
  var VIDEO_EXTENSIONS = /\.(mp4|webm|ogg|avi|mov|wmv|flv|mkv)($|\?)/i;
404
412
  var AUDIO_EXTENSIONS = /\.(mp3|wav|ogg|aac|wma|flac|m4a)($|\?)/i;
405
413
  var canPlay = {
406
- hls: function(url) {
414
+ hls: function hls(url) {
407
415
  if (!url || typeof url !== "string") return false;
408
416
  return HLS_EXTENSIONS.test(url) || HLS_PATHS.test(url);
409
417
  },
410
- dash: function(url) {
418
+ dash: function dash(url) {
411
419
  if (!url || typeof url !== "string") return false;
412
420
  return DASH_EXTENSIONS.test(url);
413
421
  },
414
- video: function(url) {
422
+ video: function video(url) {
415
423
  if (!url || typeof url !== "string") return false;
416
424
  return VIDEO_EXTENSIONS.test(url);
417
425
  },
418
- audio: function(url) {
426
+ audio: function audio(url) {
419
427
  if (!url || typeof url !== "string") return false;
420
428
  return AUDIO_EXTENSIONS.test(url);
421
429
  },
422
- file: function(url) {
430
+ file: function file(url) {
423
431
  if (!url || typeof url !== "string") return false;
424
432
  return VIDEO_EXTENSIONS.test(url) || AUDIO_EXTENSIONS.test(url);
425
433
  }
@@ -755,7 +763,7 @@ function createImaController(video, options) {
755
763
  var fn = _step.value;
756
764
  try {
757
765
  fn(payload);
758
- } catch (e) {}
766
+ } catch (unused) {}
759
767
  }
760
768
  } catch (err) {
761
769
  _didIteratorError = true;
@@ -793,7 +801,7 @@ function createImaController(video, options) {
793
801
  console.error("StormcloudVideoPlayer: The host page is inside a sandboxed iframe without 'allow-scripts'. Google IMA cannot run ads within sandboxed frames. Remove the sandbox attribute or include 'allow-scripts allow-same-origin'.");
794
802
  }
795
803
  }
796
- } catch (e) {}
804
+ } catch (unused) {}
797
805
  if (typeof window !== "undefined" && ((_window_google = window.google) === null || _window_google === void 0 ? void 0 : _window_google.ima)) return Promise.resolve();
798
806
  var existing = document.querySelector('script[data-ima="true"]');
799
807
  if (existing) {
@@ -835,9 +843,6 @@ function createImaController(video, options) {
835
843
  var adDisplayContainer;
836
844
  var adContainerEl;
837
845
  var lastAdTagUrl;
838
- var retryAttempts = 0;
839
- var maxRetries = 2;
840
- var backoffBaseMs = 500;
841
846
  var adsLoadedPromise;
842
847
  var adsLoadedResolve;
843
848
  var adsLoadedReject;
@@ -1041,7 +1046,7 @@ function createImaController(video, options) {
1041
1046
  if (adsManager) {
1042
1047
  try {
1043
1048
  adsManager.destroy();
1044
- } catch (e) {}
1049
+ } catch (unused) {}
1045
1050
  adsManager = void 0;
1046
1051
  }
1047
1052
  if (adVideoElement) {
@@ -1052,7 +1057,7 @@ function createImaController(video, options) {
1052
1057
  if (adsLoader) {
1053
1058
  try {
1054
1059
  adsLoader.destroy();
1055
- } catch (e) {}
1060
+ } catch (unused) {}
1056
1061
  adsLoader = void 0;
1057
1062
  }
1058
1063
  }
@@ -1070,7 +1075,7 @@ function createImaController(video, options) {
1070
1075
  try {
1071
1076
  var _adDisplayContainer_initialize;
1072
1077
  (_adDisplayContainer_initialize = adDisplayContainer.initialize) === null || _adDisplayContainer_initialize === void 0 ? void 0 : _adDisplayContainer_initialize.call(adDisplayContainer);
1073
- } catch (e) {}
1078
+ } catch (unused) {}
1074
1079
  }
1075
1080
  }).catch(function() {});
1076
1081
  },
@@ -1134,7 +1139,6 @@ function createImaController(video, options) {
1134
1139
  _state.sent();
1135
1140
  google = window.google;
1136
1141
  lastAdTagUrl = vastTagUrl;
1137
- retryAttempts = 0;
1138
1142
  if (!adDisplayContainer) {
1139
1143
  container = document.createElement("div");
1140
1144
  container.style.position = "absolute";
@@ -1218,32 +1222,23 @@ function createImaController(video, options) {
1218
1222
  }
1219
1223
  }, 300);
1220
1224
  }
1221
- hideContentVideo();
1225
+ showContentVideo();
1222
1226
  if (adsLoadedReject) {
1223
1227
  adsLoadedReject(new Error("Ad playback error"));
1224
1228
  adsLoadedReject = void 0;
1225
1229
  adsLoadedResolve = void 0;
1226
1230
  }
1227
- if (lastAdTagUrl && retryAttempts < maxRetries && !isNoFill) {
1228
- var delay = backoffBaseMs * Math.pow(2, retryAttempts++);
1229
- window.setTimeout(function() {
1230
- try {
1231
- makeAdsRequest(google, lastAdTagUrl);
1232
- } catch (e) {}
1233
- }, delay);
1234
- } else {
1235
- emit("ad_error", {
1236
- code: errorCode,
1237
- vastErrorCode: vastErrorCode,
1238
- message: errorMessage,
1239
- cause: innerError,
1240
- isNoFill: isNoFill
1241
- });
1242
- if (!(options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds)) {
1243
- if (video.paused) {
1244
- var _video_play;
1245
- (_video_play = video.play()) === null || _video_play === void 0 ? void 0 : _video_play.catch(function() {});
1246
- }
1231
+ emit("ad_error", {
1232
+ code: errorCode,
1233
+ vastErrorCode: vastErrorCode,
1234
+ message: errorMessage,
1235
+ cause: innerError,
1236
+ isNoFill: isNoFill
1237
+ });
1238
+ if (!(options === null || options === void 0 ? void 0 : options.continueLiveStreamDuringAds)) {
1239
+ if (video.paused) {
1240
+ var _video_play;
1241
+ (_video_play = video.play()) === null || _video_play === void 0 ? void 0 : _video_play.catch(function() {});
1247
1242
  }
1248
1243
  }
1249
1244
  });
@@ -1261,7 +1256,7 @@ function createImaController(video, options) {
1261
1256
  if (adsManager) {
1262
1257
  try {
1263
1258
  adsManager.setVolume(adVolume);
1264
- } catch (e) {}
1259
+ } catch (unused) {}
1265
1260
  }
1266
1261
  emit("content_pause");
1267
1262
  });
@@ -1275,7 +1270,7 @@ function createImaController(video, options) {
1275
1270
  if (adsManager) {
1276
1271
  try {
1277
1272
  adsManager.setVolume(originalMutedState ? 0 : adVolume);
1278
- } catch (e) {}
1273
+ } catch (unused) {}
1279
1274
  }
1280
1275
  }
1281
1276
  if (adContainerEl) {
@@ -1289,7 +1284,7 @@ function createImaController(video, options) {
1289
1284
  adsManager.addEventListener(AdEvent.CONTENT_RESUME_REQUESTED, function() {
1290
1285
  adPlaying = false;
1291
1286
  setAdPlayingFlag(false);
1292
- hideContentVideo();
1287
+ showContentVideo();
1293
1288
  emit("content_resume");
1294
1289
  });
1295
1290
  adsManager.addEventListener(AdEvent.ALL_ADS_COMPLETED, function() {
@@ -1305,7 +1300,7 @@ function createImaController(video, options) {
1305
1300
  }
1306
1301
  }, 300);
1307
1302
  }
1308
- hideContentVideo();
1303
+ showContentVideo();
1309
1304
  emit("all_ads_completed");
1310
1305
  });
1311
1306
  if (adsLoadedResolve) {
@@ -1327,7 +1322,7 @@ function createImaController(video, options) {
1327
1322
  }
1328
1323
  }, 300);
1329
1324
  }
1330
- hideContentVideo();
1325
+ showContentVideo();
1331
1326
  if (adsLoadedReject) {
1332
1327
  adsLoadedReject(new Error("Failed to setup ads manager"));
1333
1328
  adsLoadedReject = void 0;
@@ -1370,7 +1365,7 @@ function createImaController(video, options) {
1370
1365
  }
1371
1366
  }, 300);
1372
1367
  }
1373
- hideContentVideo();
1368
+ showContentVideo();
1374
1369
  if (adsLoadedReject) {
1375
1370
  adsLoadedReject(new Error(isNoFill ? "No ads available" : "Ads loader error"));
1376
1371
  adsLoadedReject = void 0;
@@ -1436,7 +1431,7 @@ function createImaController(video, options) {
1436
1431
  }
1437
1432
  try {
1438
1433
  adsManager.setVolume(originalMutedState ? 0 : adVolume);
1439
- } catch (e) {}
1434
+ } catch (unused) {}
1440
1435
  adsManager.start();
1441
1436
  return [
1442
1437
  2,
@@ -1518,7 +1513,7 @@ function createImaController(video, options) {
1518
1513
  try {
1519
1514
  ;
1520
1515
  adsManager === null || adsManager === void 0 ? void 0 : (_adsManager_stop = adsManager.stop) === null || _adsManager_stop === void 0 ? void 0 : _adsManager_stop.call(adsManager);
1521
- } catch (e) {}
1516
+ } catch (unused) {}
1522
1517
  destroyAdsManager();
1523
1518
  return [
1524
1519
  2
@@ -1549,7 +1544,7 @@ function createImaController(video, options) {
1549
1544
  try {
1550
1545
  var _adsLoader_destroy;
1551
1546
  adsLoader === null || adsLoader === void 0 ? void 0 : (_adsLoader_destroy = adsLoader.destroy) === null || _adsLoader_destroy === void 0 ? void 0 : _adsLoader_destroy.call(adsLoader);
1552
- } catch (e) {}
1547
+ } catch (unused) {}
1553
1548
  adDisplayContainer = void 0;
1554
1549
  adsLoader = void 0;
1555
1550
  contentVideoHidden = false;
@@ -1598,7 +1593,7 @@ function createImaController(video, options) {
1598
1593
  if (adsManager && adPlaying) {
1599
1594
  try {
1600
1595
  adsManager.setVolume(clampedVolume);
1601
- } catch (e) {}
1596
+ } catch (unused) {}
1602
1597
  }
1603
1598
  },
1604
1599
  getAdVolume: function getAdVolume() {
@@ -2702,9 +2697,6 @@ function sendInitialTracking(licenseKey) {
2702
2697
  headers = {
2703
2698
  "Content-Type": "application/json"
2704
2699
  };
2705
- if (licenseKey) {
2706
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2707
- }
2708
2700
  return [
2709
2701
  4,
2710
2702
  fetch("https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track", {
@@ -2810,6 +2802,234 @@ function sendHeartbeat(licenseKey) {
2810
2802
  });
2811
2803
  })();
2812
2804
  }
2805
+ var TRACK_API_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track";
2806
+ function mapToAdTrackingSource(source, adPlayerType) {
2807
+ if (source === "prebid" || source === "ima" || source === "hls") {
2808
+ return source;
2809
+ }
2810
+ if (source === "preload" || source === "ssp") {
2811
+ return source === "ssp" ? "prebid" : "ima";
2812
+ }
2813
+ return adPlayerType === "hls" ? "hls" : "ima";
2814
+ }
2815
+ function postAdTracking(licenseKey, body) {
2816
+ return _async_to_generator(function() {
2817
+ var headers, response;
2818
+ return _ts_generator(this, function(_state) {
2819
+ switch(_state.label){
2820
+ case 0:
2821
+ headers = {
2822
+ "Content-Type": "application/json"
2823
+ };
2824
+ if (licenseKey) {
2825
+ headers["Authorization"] = "Bearer ".concat(licenseKey);
2826
+ }
2827
+ return [
2828
+ 4,
2829
+ fetch(TRACK_API_URL, {
2830
+ method: "POST",
2831
+ headers: headers,
2832
+ body: JSON.stringify(body)
2833
+ })
2834
+ ];
2835
+ case 1:
2836
+ response = _state.sent();
2837
+ if (!response.ok) {
2838
+ throw new Error("HTTP error! status: ".concat(response.status));
2839
+ }
2840
+ return [
2841
+ 4,
2842
+ response.json()
2843
+ ];
2844
+ case 2:
2845
+ _state.sent();
2846
+ return [
2847
+ 2
2848
+ ];
2849
+ }
2850
+ });
2851
+ })();
2852
+ }
2853
+ function sendAdDetectTracking(licenseKey, payload) {
2854
+ return _async_to_generator(function() {
2855
+ var _payload_source, _payload_timestamp, clientInfo, browserId, adDetectInfo, body, error;
2856
+ return _ts_generator(this, function(_state) {
2857
+ switch(_state.label){
2858
+ case 0:
2859
+ _state.trys.push([
2860
+ 0,
2861
+ 3,
2862
+ ,
2863
+ 4
2864
+ ]);
2865
+ clientInfo = getClientInfo();
2866
+ return [
2867
+ 4,
2868
+ getBrowserID(clientInfo)
2869
+ ];
2870
+ case 1:
2871
+ browserId = _state.sent();
2872
+ adDetectInfo = _object_spread({
2873
+ source: (_payload_source = payload.source) !== null && _payload_source !== void 0 ? _payload_source : "scte35",
2874
+ timestamp: (_payload_timestamp = payload.timestamp) !== null && _payload_timestamp !== void 0 ? _payload_timestamp : /* @__PURE__ */ new Date().toISOString()
2875
+ }, payload.durationSeconds != null && {
2876
+ durationSeconds: payload.durationSeconds
2877
+ }, payload.ptsSeconds != null && {
2878
+ ptsSeconds: payload.ptsSeconds
2879
+ }, payload.detectedAtFragmentSn != null && {
2880
+ detectedAtFragmentSn: payload.detectedAtFragmentSn
2881
+ });
2882
+ body = _object_spread_props(_object_spread({
2883
+ browserId: browserId
2884
+ }, clientInfo, licenseKey && {
2885
+ licenseKey: licenseKey
2886
+ }), {
2887
+ adDetectInfo: adDetectInfo
2888
+ });
2889
+ return [
2890
+ 4,
2891
+ postAdTracking(licenseKey, body)
2892
+ ];
2893
+ case 2:
2894
+ _state.sent();
2895
+ return [
2896
+ 3,
2897
+ 4
2898
+ ];
2899
+ case 3:
2900
+ error = _state.sent();
2901
+ console.error("[StormcloudVideoPlayer] Error sending ad-detect tracking:", error);
2902
+ return [
2903
+ 3,
2904
+ 4
2905
+ ];
2906
+ case 4:
2907
+ return [
2908
+ 2
2909
+ ];
2910
+ }
2911
+ });
2912
+ })();
2913
+ }
2914
+ function sendAdLoadedTracking(licenseKey, payload, adPlayerType) {
2915
+ return _async_to_generator(function() {
2916
+ var clientInfo, browserId, source, adLoadedInfo, body, error;
2917
+ return _ts_generator(this, function(_state) {
2918
+ switch(_state.label){
2919
+ case 0:
2920
+ _state.trys.push([
2921
+ 0,
2922
+ 3,
2923
+ ,
2924
+ 4
2925
+ ]);
2926
+ clientInfo = getClientInfo();
2927
+ return [
2928
+ 4,
2929
+ getBrowserID(clientInfo)
2930
+ ];
2931
+ case 1:
2932
+ browserId = _state.sent();
2933
+ source = mapToAdTrackingSource(payload.source, adPlayerType);
2934
+ adLoadedInfo = _object_spread({
2935
+ source: source,
2936
+ timestamp: /* @__PURE__ */ new Date().toISOString()
2937
+ }, payload.vastUrl != null && {
2938
+ vastUrl: payload.vastUrl
2939
+ }, payload.durationSeconds != null && {
2940
+ durationSeconds: payload.durationSeconds
2941
+ });
2942
+ body = _object_spread_props(_object_spread({
2943
+ browserId: browserId
2944
+ }, clientInfo, licenseKey && {
2945
+ licenseKey: licenseKey
2946
+ }), {
2947
+ adLoadedInfo: adLoadedInfo
2948
+ });
2949
+ return [
2950
+ 4,
2951
+ postAdTracking(licenseKey, body)
2952
+ ];
2953
+ case 2:
2954
+ _state.sent();
2955
+ return [
2956
+ 3,
2957
+ 4
2958
+ ];
2959
+ case 3:
2960
+ error = _state.sent();
2961
+ console.error("[StormcloudVideoPlayer] Error sending ad-loaded tracking:", error);
2962
+ return [
2963
+ 3,
2964
+ 4
2965
+ ];
2966
+ case 4:
2967
+ return [
2968
+ 2
2969
+ ];
2970
+ }
2971
+ });
2972
+ })();
2973
+ }
2974
+ function sendAdImpressionTracking(licenseKey, payload, adPlayerType) {
2975
+ return _async_to_generator(function() {
2976
+ var clientInfo, browserId, source, adImpressionInfo, body, error;
2977
+ return _ts_generator(this, function(_state) {
2978
+ switch(_state.label){
2979
+ case 0:
2980
+ _state.trys.push([
2981
+ 0,
2982
+ 3,
2983
+ ,
2984
+ 4
2985
+ ]);
2986
+ clientInfo = getClientInfo();
2987
+ return [
2988
+ 4,
2989
+ getBrowserID(clientInfo)
2990
+ ];
2991
+ case 1:
2992
+ browserId = _state.sent();
2993
+ source = mapToAdTrackingSource(payload.source, adPlayerType);
2994
+ adImpressionInfo = _object_spread({
2995
+ source: source,
2996
+ adIndex: payload.adIndex,
2997
+ timestamp: /* @__PURE__ */ new Date().toISOString()
2998
+ }, payload.durationSeconds != null && {
2999
+ durationSeconds: payload.durationSeconds
3000
+ });
3001
+ body = _object_spread_props(_object_spread({
3002
+ browserId: browserId
3003
+ }, clientInfo, licenseKey && {
3004
+ licenseKey: licenseKey
3005
+ }), {
3006
+ adImpressionInfo: adImpressionInfo
3007
+ });
3008
+ return [
3009
+ 4,
3010
+ postAdTracking(licenseKey, body)
3011
+ ];
3012
+ case 2:
3013
+ _state.sent();
3014
+ return [
3015
+ 3,
3016
+ 4
3017
+ ];
3018
+ case 3:
3019
+ error = _state.sent();
3020
+ console.error("[StormcloudVideoPlayer] Error sending ad-impression tracking:", error);
3021
+ return [
3022
+ 3,
3023
+ 4
3024
+ ];
3025
+ case 4:
3026
+ return [
3027
+ 2
3028
+ ];
3029
+ }
3030
+ });
3031
+ })();
3032
+ }
2813
3033
  // src/utils/polyfills.ts
2814
3034
  function polyfillURLSearchParams() {
2815
3035
  if (typeof URLSearchParams !== "undefined") {
@@ -3091,18 +3311,26 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3091
3311
  this.maxPlaceholderDurationMs = 5e3;
3092
3312
  this.isShowingPlaceholder = false;
3093
3313
  this.totalAdRequestsInBreak = 0;
3094
- this.maxTotalAdRequestsPerBreak = 20;
3314
+ this.maxTotalAdRequestsPerBreak = 10;
3095
3315
  this.pendingAdBreak = null;
3096
3316
  this.consecutiveFailures = 0;
3097
3317
  this.maxConsecutiveFailures = 5;
3098
3318
  this.lastAdRequestTime = 0;
3099
- this.minAdRequestIntervalMs = 2500;
3319
+ this.minAdRequestIntervalMs = 3e3;
3100
3320
  this.backoffBaseMs = 1e3;
3101
3321
  this.maxBackoffMs = 15e3;
3322
+ this.globalConsecutiveNoFills = 0;
3323
+ this.globalNoFillThreshold = 3;
3324
+ this.globalNoFillCooldownUntil = 0;
3325
+ this.globalNoFillBackoffBaseMs = 5e3;
3326
+ this.globalNoFillBackoffMaxMs = 6e4;
3327
+ this.globalLastGamRequestTime = 0;
3328
+ this.globalMinGamIntervalMs = 3e3;
3102
3329
  this.preloadPool = [];
3103
- this.maxPreloadPoolSize = 3;
3330
+ this.maxPreloadPoolSize = 2;
3104
3331
  this.preloadPoolActive = false;
3105
3332
  this.preloadPoolLoopRunning = false;
3333
+ this.adDetectSentForCurrentBreak = false;
3106
3334
  this.continuousFetchLoopRunning = false;
3107
3335
  initializePolyfills();
3108
3336
  var browserOverrides = getBrowserConfigOverrides();
@@ -3243,7 +3471,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3243
3471
  });
3244
3472
  this.hls.on(import_hls2.default.Events.MANIFEST_PARSED, function(_, data) {
3245
3473
  return _async_to_generator(function() {
3246
- var _this_hls_levels, _this_hls, _this_hls_levels_some, adBehavior, _this_config_minSegmentsBeforePlay, minSegments, _this_video_play;
3474
+ var _this_config_minSegmentsBeforePlay, _ref, _this_hls_levels, _this_hls, adBehavior, minSegments, _this_video_play;
3247
3475
  return _ts_generator(this, function(_state) {
3248
3476
  switch(_state.label){
3249
3477
  case 0:
@@ -3252,10 +3480,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3252
3480
  } else {
3253
3481
  ;
3254
3482
  ;
3255
- this.isLiveStream = (_this_hls_levels_some = (_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : (_this_hls_levels = _this_hls.levels) === null || _this_hls_levels === void 0 ? void 0 : _this_hls_levels.some(function(level) {
3483
+ this.isLiveStream = (_ref = (_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : (_this_hls_levels = _this_hls.levels) === null || _this_hls_levels === void 0 ? void 0 : _this_hls_levels.some(function(level) {
3256
3484
  var _level_details, _level_details1;
3257
3485
  return (level === null || level === void 0 ? void 0 : (_level_details = level.details) === null || _level_details === void 0 ? void 0 : _level_details.live) === true || (level === null || level === void 0 ? void 0 : (_level_details1 = level.details) === null || _level_details1 === void 0 ? void 0 : _level_details1.type) === "LIVE";
3258
- })) !== null && _this_hls_levels_some !== void 0 ? _this_hls_levels_some : false;
3486
+ })) !== null && _ref !== void 0 ? _ref : false;
3259
3487
  }
3260
3488
  if (this.config.debugAdTiming) {
3261
3489
  adBehavior = this.shouldContinueLiveStreamDuringAds() ? "live (main video continues muted during ads)" : "vod (main video pauses during ads)";
@@ -3319,9 +3547,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3319
3547
  var tag = "";
3320
3548
  var value = "";
3321
3549
  if (Array.isArray(entry)) {
3322
- var _entry_;
3550
+ var _entry_, _entry_1;
3323
3551
  tag = String((_entry_ = entry[0]) !== null && _entry_ !== void 0 ? _entry_ : "");
3324
- var _entry_1;
3325
3552
  value = String((_entry_1 = entry[1]) !== null && _entry_1 !== void 0 ? _entry_1 : "");
3326
3553
  } else if (typeof entry === "string") {
3327
3554
  var idx = entry.indexOf(":");
@@ -3444,9 +3671,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3444
3671
  var tag = "";
3445
3672
  var value = "";
3446
3673
  if (Array.isArray(entry)) {
3447
- var _entry_;
3674
+ var _entry_, _entry_1;
3448
3675
  tag = String((_entry_ = entry[0]) !== null && _entry_ !== void 0 ? _entry_ : "");
3449
- var _entry_1;
3450
3676
  value = String((_entry_1 = entry[1]) !== null && _entry_1 !== void 0 ? _entry_1 : "");
3451
3677
  } else if (typeof entry === "string") {
3452
3678
  var idx = entry.indexOf(":");
@@ -3496,10 +3722,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3496
3722
  }
3497
3723
  });
3498
3724
  } else if (tag.includes("EXT-X-DATERANGE")) {
3725
+ var _attrs_CLASS;
3499
3726
  var attrs = _this.parseAttributeList(value);
3500
3727
  var hasScteOut = "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
3501
3728
  var hasScteIn = "SCTE35-IN" in attrs || attrs["SCTE35-IN"] !== void 0;
3502
- var _attrs_CLASS;
3503
3729
  var klass = String((_attrs_CLASS = attrs["CLASS"]) !== null && _attrs_CLASS !== void 0 ? _attrs_CLASS : "");
3504
3730
  var duration = _this.toNumber(attrs["DURATION"]);
3505
3731
  if (hasScteOut || /com\.apple\.hls\.cue/i.test(klass)) {
@@ -3574,6 +3800,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3574
3800
  value: function attachImaEventListeners() {
3575
3801
  var _this = this;
3576
3802
  this.ima.on("all_ads_completed", function() {
3803
+ sendAdImpressionTracking(_this.config.licenseKey, {
3804
+ adIndex: _this.currentAdIndex
3805
+ }, _this.config.adPlayerType).catch(function() {});
3577
3806
  var remaining = _this.getRemainingAdMs();
3578
3807
  _this.consecutiveFailures = 0;
3579
3808
  if (_this.config.debugAdTiming) {
@@ -3613,6 +3842,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3613
3842
  _this.clearAdRequestWatchdog();
3614
3843
  _this.activeAdRequestToken = null;
3615
3844
  _this.showAds = true;
3845
+ _this.resetGamNoFillCounter();
3616
3846
  if (_this.inAdBreak && _this.expectedAdBreakDurationMs != null) {
3617
3847
  if (_this.adStopTimerId == null) {
3618
3848
  _this.currentAdBreakStartWallClockMs = Date.now();
@@ -3635,6 +3865,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3635
3865
  }
3636
3866
  });
3637
3867
  this.ima.on("content_resume", function() {
3868
+ sendAdImpressionTracking(_this.config.licenseKey, {
3869
+ adIndex: _this.currentAdIndex
3870
+ }, _this.config.adPlayerType).catch(function() {});
3638
3871
  if (!_this.video.muted) {
3639
3872
  _this.video.muted = true;
3640
3873
  _this.video.volume = 0;
@@ -3901,11 +4134,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3901
4134
  }
3902
4135
  var daterangeMatch = text.match(/EXT-X-DATERANGE:([^\r\n]*)/i);
3903
4136
  if (daterangeMatch) {
3904
- var _daterangeMatch_;
4137
+ var _daterangeMatch_, _attrs_CLASS;
3905
4138
  var attrs = this.parseAttributeList((_daterangeMatch_ = daterangeMatch[1]) !== null && _daterangeMatch_ !== void 0 ? _daterangeMatch_ : "");
3906
4139
  var hasScteOut = "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
3907
4140
  var hasScteIn = "SCTE35-IN" in attrs || attrs["SCTE35-IN"] !== void 0;
3908
- var _attrs_CLASS;
3909
4141
  var klass = String((_attrs_CLASS = attrs["CLASS"]) !== null && _attrs_CLASS !== void 0 ? _attrs_CLASS : "");
3910
4142
  var duration = this.toNumber(attrs["DURATION"]);
3911
4143
  if (hasScteOut || /com\.apple\.hls\.cue/i.test(klass)) {
@@ -3981,7 +4213,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3981
4213
  var out = "";
3982
4214
  for(var i = 0; i < value.length; i++)out += String.fromCharCode(value[i]);
3983
4215
  return out;
3984
- } catch (e) {
4216
+ } catch (unused) {
3985
4217
  return void 0;
3986
4218
  }
3987
4219
  }
@@ -4000,6 +4232,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4000
4232
  });
4001
4233
  }
4002
4234
  if (marker.type === "start") {
4235
+ var _this_config_immediateManifestAds;
4003
4236
  var _this_pendingAdBreak;
4004
4237
  if (!this.video.muted) {
4005
4238
  this.video.muted = true;
@@ -4018,13 +4251,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4018
4251
  }
4019
4252
  return;
4020
4253
  }
4254
+ if (!this.adDetectSentForCurrentBreak) {
4255
+ this.adDetectSentForCurrentBreak = true;
4256
+ var detectPayload = {};
4257
+ if (marker.durationSeconds != null) detectPayload.durationSeconds = marker.durationSeconds;
4258
+ if (marker.ptsSeconds != null) detectPayload.ptsSeconds = marker.ptsSeconds;
4259
+ sendAdDetectTracking(this.config.licenseKey, detectPayload).catch(function() {});
4260
+ }
4021
4261
  var hasPrefetchedAds = this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0;
4022
4262
  this.inAdBreak = true;
4023
4263
  var durationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : ((_this_pendingAdBreak = this.pendingAdBreak) === null || _this_pendingAdBreak === void 0 ? void 0 : _this_pendingAdBreak.marker.durationSeconds) != null ? this.pendingAdBreak.marker.durationSeconds * 1e3 : void 0;
4024
4264
  this.expectedAdBreakDurationMs = durationMs;
4025
4265
  this.currentAdBreakStartWallClockMs = Date.now();
4026
4266
  var isManifestMarker = this.isManifestBasedMarker(marker);
4027
- var _this_config_immediateManifestAds;
4028
4267
  var forceImmediate = (_this_config_immediateManifestAds = this.config.immediateManifestAds) !== null && _this_config_immediateManifestAds !== void 0 ? _this_config_immediateManifestAds : true;
4029
4268
  if (this.config.debugAdTiming) {
4030
4269
  console.log("[StormcloudVideoPlayer] Ad start decision:", {
@@ -4179,9 +4418,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4179
4418
  var regex = /([A-Z0-9-]+)=(("[^"]*")|([^",]*))(?:,|$)/gi;
4180
4419
  var match;
4181
4420
  while((match = regex.exec(value)) !== null){
4182
- var _match_;
4421
+ var _match_, _ref, _match_1;
4183
4422
  var key = (_match_ = match[1]) !== null && _match_ !== void 0 ? _match_ : "";
4184
- var _match_1, _ref;
4185
4423
  var rawVal = (_ref = (_match_1 = match[3]) !== null && _match_1 !== void 0 ? _match_1 : match[4]) !== null && _ref !== void 0 ? _ref : "";
4186
4424
  if (rawVal.startsWith('"') && rawVal.endsWith('"')) {
4187
4425
  rawVal = rawVal.slice(1, -1);
@@ -4526,13 +4764,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4526
4764
  {
4527
4765
  key: "shouldShowNativeControls",
4528
4766
  value: function shouldShowNativeControls() {
4767
+ var _this_config_showCustomControls;
4529
4768
  var streamType = this.getStreamType();
4530
4769
  if (streamType === "other") {
4531
- var _this_config_showCustomControls;
4532
- return !((_this_config_showCustomControls = this.config.showCustomControls) !== null && _this_config_showCustomControls !== void 0 ? _this_config_showCustomControls : false);
4770
+ var _this_config_showCustomControls1;
4771
+ return !((_this_config_showCustomControls1 = this.config.showCustomControls) !== null && _this_config_showCustomControls1 !== void 0 ? _this_config_showCustomControls1 : false);
4533
4772
  }
4534
- var _this_config_showCustomControls1;
4535
- return !!(this.config.allowNativeHls && !((_this_config_showCustomControls1 = this.config.showCustomControls) !== null && _this_config_showCustomControls1 !== void 0 ? _this_config_showCustomControls1 : false));
4773
+ return !!(this.config.allowNativeHls && !((_this_config_showCustomControls = this.config.showCustomControls) !== null && _this_config_showCustomControls !== void 0 ? _this_config_showCustomControls : false));
4536
4774
  }
4537
4775
  },
4538
4776
  {
@@ -4577,6 +4815,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4577
4815
  isFetching: false,
4578
4816
  fetchStartTime: Date.now()
4579
4817
  });
4818
+ this.adDetectSentForCurrentBreak = true;
4819
+ var detectPayload = {};
4820
+ if (marker.durationSeconds != null) detectPayload.durationSeconds = marker.durationSeconds;
4821
+ if (marker.ptsSeconds != null) detectPayload.ptsSeconds = marker.ptsSeconds;
4822
+ if (fragmentSn !== void 0) detectPayload.detectedAtFragmentSn = fragmentSn;
4823
+ sendAdDetectTracking(this.config.licenseKey, detectPayload).catch(function() {});
4580
4824
  if (this.config.debugAdTiming) {
4581
4825
  console.log("[PREFETCH] \uD83D\uDD04 Starting ad prefetch for upcoming ad break");
4582
4826
  console.log("[PREFETCH] \uD83D\uDCCB Pre-generated ".concat(generatedUrls.length, " VAST URLs"));
@@ -4640,6 +4884,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4640
4884
  var _this, loadPromise;
4641
4885
  return _ts_generator(this, function(_state) {
4642
4886
  _this = this;
4887
+ if (this.isGamInCooldown()) {
4888
+ if (this.config.debugAdTiming) {
4889
+ console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping preload");
4890
+ }
4891
+ return [
4892
+ 2
4893
+ ];
4894
+ }
4643
4895
  if (this.preloadPool.some(function(entry) {
4644
4896
  return entry.vastUrl === vastUrl;
4645
4897
  }) || this.failedVastUrls.has(vastUrl) || this.isUrlInCooldown(vastUrl)) {
@@ -4669,26 +4921,32 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4669
4921
  case 1:
4670
4922
  _state.trys.push([
4671
4923
  1,
4672
- 4,
4924
+ 5,
4673
4925
  ,
4674
- 5
4926
+ 6
4675
4927
  ]);
4676
4928
  continueLiveStreamDuringAds = this.shouldContinueLiveStreamDuringAds();
4677
4929
  preloadIma = this.createAdPlayer(continueLiveStreamDuringAds);
4678
4930
  preloadIma.initialize();
4679
- errorListener = function(payload) {
4931
+ errorListener = function errorListener(payload) {
4680
4932
  hasAdError = true;
4681
4933
  adErrorPayload = payload;
4682
4934
  };
4683
4935
  preloadIma.on("ad_error", errorListener);
4684
- errorListenerCleanup = function() {
4936
+ errorListenerCleanup = function errorListenerCleanup() {
4685
4937
  return preloadIma.off("ad_error", errorListener);
4686
4938
  };
4687
4939
  return [
4688
4940
  4,
4689
- preloadIma.requestAds(vastUrl)
4941
+ this.enforceGlobalRateLimit()
4690
4942
  ];
4691
4943
  case 2:
4944
+ _state.sent();
4945
+ return [
4946
+ 4,
4947
+ preloadIma.requestAds(vastUrl)
4948
+ ];
4949
+ case 3:
4692
4950
  _state.sent();
4693
4951
  preloadIma.pause();
4694
4952
  return [
@@ -4697,7 +4955,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4697
4955
  return setTimeout(resolve, 1500);
4698
4956
  })
4699
4957
  ];
4700
- case 3:
4958
+ case 4:
4701
4959
  _state.sent();
4702
4960
  preloadIma.pause();
4703
4961
  if (hasAdError) {
@@ -4706,6 +4964,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4706
4964
  errorListenerCleanup();
4707
4965
  }
4708
4966
  preloadIma.destroy();
4967
+ this.recordGamNoFill();
4709
4968
  if (isNoFill) {
4710
4969
  if (this.config.debugAdTiming) {
4711
4970
  console.log("[PRELOAD-POOL] ⚠️ Ad preload returned no-fill: ".concat(vastUrl));
@@ -4732,7 +4991,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4732
4991
  isReady: true,
4733
4992
  loadPromise: Promise.resolve()
4734
4993
  };
4735
- lateErrorListener = function(payload) {
4994
+ lateErrorListener = function lateErrorListener(payload) {
4736
4995
  var index = _this.preloadPool.findIndex(function(entry) {
4737
4996
  return entry.vastUrl === vastUrl;
4738
4997
  });
@@ -4743,7 +5002,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4743
5002
  }
4744
5003
  try {
4745
5004
  preloadIma.destroy();
4746
- } catch (e) {}
5005
+ } catch (unused) {}
4747
5006
  }
4748
5007
  };
4749
5008
  preloadIma.on("ad_error", lateErrorListener);
@@ -4756,13 +5015,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4756
5015
  }
4757
5016
  return [
4758
5017
  3,
4759
- 5
5018
+ 6
4760
5019
  ];
4761
- case 4:
5020
+ case 5:
4762
5021
  error = _state.sent();
4763
5022
  if (errorListenerCleanup) {
4764
5023
  errorListenerCleanup();
4765
5024
  }
5025
+ this.recordGamNoFill();
4766
5026
  if (this.config.debugAdTiming) {
4767
5027
  console.warn("[PRELOAD-POOL] ⚠️ Failed to preload ad: ".concat(vastUrl), error);
4768
5028
  }
@@ -4773,9 +5033,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4773
5033
  }
4774
5034
  return [
4775
5035
  3,
4776
- 5
5036
+ 6
4777
5037
  ];
4778
- case 5:
5038
+ case 6:
4779
5039
  return [
4780
5040
  2
4781
5041
  ];
@@ -4814,6 +5074,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4814
5074
  3,
4815
5075
  10
4816
5076
  ];
5077
+ if (this.isGamInCooldown()) {
5078
+ if (this.config.debugAdTiming) {
5079
+ console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping preload pool loop");
5080
+ }
5081
+ return [
5082
+ 3,
5083
+ 10
5084
+ ];
5085
+ }
4817
5086
  if (!(!this.inAdBreak && this.preloadPool.length >= this.maxPreloadPoolSize)) return [
4818
5087
  3,
4819
5088
  3
@@ -4846,7 +5115,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4846
5115
  3,
4847
5116
  8
4848
5117
  ];
4849
- if (!this.preloadPoolActive) {
5118
+ if (!this.preloadPoolActive || this.isGamInCooldown()) {
4850
5119
  return [
4851
5120
  3,
4852
5121
  8
@@ -5027,6 +5296,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5027
5296
  firstAdUrl = preloaded.vastUrl;
5028
5297
  preloadedController = preloaded.imaController;
5029
5298
  usePreloadedAd = true;
5299
+ sendAdLoadedTracking(this.config.licenseKey, {
5300
+ source: "preload",
5301
+ vastUrl: firstAdUrl
5302
+ }, this.config.adPlayerType).catch(function() {});
5030
5303
  if (this.config.debugAdTiming) {
5031
5304
  console.log("[CONTINUOUS-FETCH] \uD83D\uDE80 Using preloaded ad from pool (preloaded in advance, ready immediately!)");
5032
5305
  console.log("[CONTINUOUS-FETCH] Pool still has ".concat(this.preloadPool.length, " preloaded ads ready"));
@@ -5062,9 +5335,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5062
5335
  case 1:
5063
5336
  _state.trys.push([
5064
5337
  1,
5065
- 7,
5338
+ 8,
5066
5339
  ,
5067
- 13
5340
+ 14
5068
5341
  ]);
5069
5342
  if (!(usePreloadedAd && preloadedController)) return [
5070
5343
  3,
@@ -5100,16 +5373,26 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5100
5373
  this.ima.setAdVolume(adVolume);
5101
5374
  return [
5102
5375
  3,
5103
- 6
5376
+ 7
5104
5377
  ];
5105
5378
  case 3:
5379
+ return [
5380
+ 4,
5381
+ this.enforceGlobalRateLimit()
5382
+ ];
5383
+ case 4:
5384
+ _state.sent();
5106
5385
  this.lastAdRequestTime = Date.now();
5107
5386
  return [
5108
5387
  4,
5109
5388
  this.ima.requestAds(firstAdUrl)
5110
5389
  ];
5111
- case 4:
5390
+ case 5:
5112
5391
  _state.sent();
5392
+ sendAdLoadedTracking(this.config.licenseKey, {
5393
+ source: "ssp",
5394
+ vastUrl: firstAdUrl
5395
+ }, this.config.adPlayerType).catch(function() {});
5113
5396
  if (this.config.debugAdTiming) {
5114
5397
  console.log("[CONTINUOUS-FETCH] \u2705 First ad request successful, starting playback");
5115
5398
  }
@@ -5123,7 +5406,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5123
5406
  4,
5124
5407
  this.ima.play()
5125
5408
  ];
5126
- case 5:
5409
+ case 6:
5127
5410
  _state.sent();
5128
5411
  if (this.expectedAdBreakDurationMs != null) {
5129
5412
  this.currentAdBreakStartWallClockMs = Date.now();
@@ -5131,36 +5414,36 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5131
5414
  }
5132
5415
  adVolume1 = currentMuted ? 0 : currentVolume;
5133
5416
  this.ima.setAdVolume(adVolume1);
5134
- _state.label = 6;
5135
- case 6:
5417
+ _state.label = 7;
5418
+ case 7:
5136
5419
  return [
5137
5420
  3,
5138
- 13
5421
+ 14
5139
5422
  ];
5140
- case 7:
5423
+ case 8:
5141
5424
  error = _state.sent();
5142
5425
  if (this.config.debugAdTiming) {
5143
5426
  console.warn("[CONTINUOUS-FETCH] \u26A0\uFE0F First ad request failed:", error);
5144
5427
  }
5145
5428
  if (!!usePreloadedAd) return [
5146
5429
  3,
5147
- 11
5430
+ 12
5148
5431
  ];
5149
5432
  fallbackPreloaded = this.getPreloadedAd();
5150
5433
  if (!fallbackPreloaded) return [
5151
5434
  3,
5152
- 11
5435
+ 12
5153
5436
  ];
5154
5437
  if (this.config.debugAdTiming) {
5155
5438
  console.log("[CONTINUOUS-FETCH] \uD83D\uDD04 First ad failed, using preloaded fallback");
5156
5439
  }
5157
- _state.label = 8;
5158
- case 8:
5440
+ _state.label = 9;
5441
+ case 9:
5159
5442
  _state.trys.push([
5160
- 8,
5161
- 10,
5443
+ 9,
5444
+ 11,
5162
5445
  ,
5163
- 11
5446
+ 12
5164
5447
  ]);
5165
5448
  this.ima.destroy();
5166
5449
  this.video.muted = true;
@@ -5179,7 +5462,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5179
5462
  4,
5180
5463
  this.ima.play()
5181
5464
  ];
5182
- case 9:
5465
+ case 10:
5183
5466
  _state.sent();
5184
5467
  if (this.expectedAdBreakDurationMs != null) {
5185
5468
  this.currentAdBreakStartWallClockMs = Date.now();
@@ -5190,16 +5473,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5190
5473
  return [
5191
5474
  2
5192
5475
  ];
5193
- case 10:
5476
+ case 11:
5194
5477
  fallbackError = _state.sent();
5195
5478
  if (this.config.debugAdTiming) {
5196
5479
  console.warn("[CONTINUOUS-FETCH] \u26A0\uFE0F Preloaded fallback also failed:", fallbackError);
5197
5480
  }
5198
5481
  return [
5199
5482
  3,
5200
- 11
5483
+ 12
5201
5484
  ];
5202
- case 11:
5485
+ case 12:
5203
5486
  if (this.isTemporaryAdError(error)) {
5204
5487
  this.temporaryFailureUrls.set(firstAdUrl, Date.now());
5205
5488
  if (this.config.debugAdTiming) {
@@ -5217,13 +5500,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5217
5500
  4,
5218
5501
  this.tryNextAvailableAdWithRateLimit()
5219
5502
  ];
5220
- case 12:
5503
+ case 13:
5221
5504
  _state.sent();
5222
5505
  return [
5223
5506
  3,
5224
- 13
5507
+ 14
5225
5508
  ];
5226
- case 13:
5509
+ case 14:
5227
5510
  return [
5228
5511
  2
5229
5512
  ];
@@ -5274,6 +5557,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5274
5557
  "break"
5275
5558
  ];
5276
5559
  }
5560
+ if (_this.isGamInCooldown()) {
5561
+ if (_this.config.debugAdTiming) {
5562
+ console.log("[CIRCUIT-BREAKER] GAM in cooldown, stopping URL generation");
5563
+ }
5564
+ return [
5565
+ 2,
5566
+ "break"
5567
+ ];
5568
+ }
5277
5569
  if (_this.consecutiveFailures >= _this.maxConsecutiveFailures) {
5278
5570
  if (_this.config.debugAdTiming) {
5279
5571
  console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive failures (".concat(_this.consecutiveFailures, "), stopping URL generation"));
@@ -5470,6 +5762,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5470
5762
  2
5471
5763
  ];
5472
5764
  }
5765
+ if (this.isGamInCooldown()) {
5766
+ if (this.config.debugAdTiming) {
5767
+ console.log("[CIRCUIT-BREAKER] GAM in cooldown, ending ad break gracefully");
5768
+ }
5769
+ this.handleAdPodComplete();
5770
+ return [
5771
+ 2
5772
+ ];
5773
+ }
5473
5774
  if (this.consecutiveFailures >= this.maxConsecutiveFailures) {
5474
5775
  if (this.config.debugAdTiming) {
5475
5776
  console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Too many consecutive failures (".concat(this.consecutiveFailures, "), ending ad break"));
@@ -5488,6 +5789,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5488
5789
  if (this.config.debugAdTiming) {
5489
5790
  console.log("[CONTINUOUS-FETCH] \uD83C\uDFAF Using preloaded ad from pool (".concat(this.preloadPool.length, " remaining in pool)"));
5490
5791
  }
5792
+ sendAdLoadedTracking(this.config.licenseKey, {
5793
+ source: "preload",
5794
+ vastUrl: preloaded.vastUrl
5795
+ }, this.config.adPlayerType).catch(function() {});
5491
5796
  _state.label = 1;
5492
5797
  case 1:
5493
5798
  _state.trys.push([
@@ -5666,6 +5971,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5666
5971
  case 0:
5667
5972
  remaining = this.getRemainingAdMs();
5668
5973
  waitTime = Math.min(this.maxPlaceholderDurationMs, remaining);
5974
+ if (this.isGamInCooldown()) {
5975
+ if (this.config.debugAdTiming) {
5976
+ console.log("[CIRCUIT-BREAKER] GAM in cooldown, skipping placeholder wait");
5977
+ }
5978
+ this.handleAdPodComplete();
5979
+ return [
5980
+ 2
5981
+ ];
5982
+ }
5669
5983
  if (this.consecutiveFailures >= this.maxConsecutiveFailures) {
5670
5984
  if (this.config.debugAdTiming) {
5671
5985
  console.log("[CONTINUOUS-FETCH] \uD83D\uDED1 Skipping placeholder - too many consecutive failures");
@@ -5929,11 +6243,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5929
6243
  {
5930
6244
  key: "ensureAdStoppedByTimer",
5931
6245
  value: function ensureAdStoppedByTimer() {
6246
+ var _this_config_adBreakCheckIntervalMs, _this_expectedAdBreakDurationMs;
5932
6247
  if (!this.inAdBreak) return;
5933
6248
  this.adStopTimerId = void 0;
5934
6249
  var adPlaying = this.ima.isAdPlaying();
5935
6250
  var pendingAds = this.adPodQueue.length > 0;
5936
- var _this_config_adBreakCheckIntervalMs;
5937
6251
  var checkIntervalMs = Math.max(250, Math.floor((_this_config_adBreakCheckIntervalMs = this.config.adBreakCheckIntervalMs) !== null && _this_config_adBreakCheckIntervalMs !== void 0 ? _this_config_adBreakCheckIntervalMs : 1e3));
5938
6252
  var maxExtensionMsConfig = this.config.maxAdBreakExtensionMs;
5939
6253
  var maxExtensionMs = typeof maxExtensionMsConfig === "number" && maxExtensionMsConfig > 0 ? maxExtensionMsConfig : 6e4;
@@ -5941,7 +6255,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5941
6255
  if (this.currentAdBreakStartWallClockMs != null) {
5942
6256
  elapsedSinceStartMs = Date.now() - this.currentAdBreakStartWallClockMs;
5943
6257
  }
5944
- var _this_expectedAdBreakDurationMs;
5945
6258
  var expectedDurationMs = (_this_expectedAdBreakDurationMs = this.expectedAdBreakDurationMs) !== null && _this_expectedAdBreakDurationMs !== void 0 ? _this_expectedAdBreakDurationMs : 0;
5946
6259
  var overrunMs = Math.max(0, elapsedSinceStartMs - expectedDurationMs);
5947
6260
  var shouldExtendAdBreak = (adPlaying || pendingAds || this.showAds) && overrunMs < maxExtensionMs;
@@ -6055,6 +6368,73 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6055
6368
  }
6056
6369
  }
6057
6370
  },
6371
+ {
6372
+ key: "isGamInCooldown",
6373
+ value: function isGamInCooldown() {
6374
+ return Date.now() < this.globalNoFillCooldownUntil;
6375
+ }
6376
+ },
6377
+ {
6378
+ key: "recordGamNoFill",
6379
+ value: function recordGamNoFill() {
6380
+ this.globalConsecutiveNoFills++;
6381
+ if (this.globalConsecutiveNoFills >= this.globalNoFillThreshold) {
6382
+ var exponent = this.globalConsecutiveNoFills - this.globalNoFillThreshold;
6383
+ var backoff = Math.min(this.globalNoFillBackoffBaseMs * Math.pow(2, exponent), this.globalNoFillBackoffMaxMs);
6384
+ this.globalNoFillCooldownUntil = Date.now() + backoff;
6385
+ if (this.config.debugAdTiming) {
6386
+ console.log("[CIRCUIT-BREAKER] GAM cooldown activated: ".concat(backoff, "ms (").concat(this.globalConsecutiveNoFills, " consecutive no-fills)"));
6387
+ }
6388
+ }
6389
+ }
6390
+ },
6391
+ {
6392
+ key: "resetGamNoFillCounter",
6393
+ value: function resetGamNoFillCounter() {
6394
+ if (this.globalConsecutiveNoFills > 0 && this.config.debugAdTiming) {
6395
+ console.log("[CIRCUIT-BREAKER] Resetting no-fill counter (was ".concat(this.globalConsecutiveNoFills, ")"));
6396
+ }
6397
+ this.globalConsecutiveNoFills = 0;
6398
+ this.globalNoFillCooldownUntil = 0;
6399
+ }
6400
+ },
6401
+ {
6402
+ key: "enforceGlobalRateLimit",
6403
+ value: function enforceGlobalRateLimit() {
6404
+ return _async_to_generator(function() {
6405
+ var now, elapsed, waitMs;
6406
+ return _ts_generator(this, function(_state) {
6407
+ switch(_state.label){
6408
+ case 0:
6409
+ now = Date.now();
6410
+ elapsed = now - this.globalLastGamRequestTime;
6411
+ if (!(elapsed < this.globalMinGamIntervalMs)) return [
6412
+ 3,
6413
+ 2
6414
+ ];
6415
+ waitMs = this.globalMinGamIntervalMs - elapsed;
6416
+ if (this.config.debugAdTiming) {
6417
+ console.log("[RATE-LIMIT] Waiting ".concat(waitMs, "ms before next GAM request"));
6418
+ }
6419
+ return [
6420
+ 4,
6421
+ new Promise(function(resolve) {
6422
+ return setTimeout(resolve, waitMs);
6423
+ })
6424
+ ];
6425
+ case 1:
6426
+ _state.sent();
6427
+ _state.label = 2;
6428
+ case 2:
6429
+ this.globalLastGamRequestTime = Date.now();
6430
+ return [
6431
+ 2
6432
+ ];
6433
+ }
6434
+ });
6435
+ }).call(this);
6436
+ }
6437
+ },
6058
6438
  {
6059
6439
  key: "playSingleAd",
6060
6440
  value: function playSingleAd(vastTagUrl) {
@@ -6086,6 +6466,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6086
6466
  }
6087
6467
  throw new Error("Too many consecutive failures");
6088
6468
  }
6469
+ if (this.isGamInCooldown()) {
6470
+ if (this.config.debugAdTiming) {
6471
+ console.warn("[CIRCUIT-BREAKER] GAM in cooldown, skipping ad request");
6472
+ }
6473
+ throw new Error("GAM in cooldown");
6474
+ }
6089
6475
  this.recreateImaController();
6090
6476
  requestToken = ++this.adRequestTokenCounter;
6091
6477
  this.activeAdRequestToken = requestToken;
@@ -6094,37 +6480,47 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6094
6480
  case 1:
6095
6481
  _state.trys.push([
6096
6482
  1,
6097
- 11,
6483
+ 12,
6098
6484
  ,
6099
- 16
6485
+ 17
6100
6486
  ]);
6487
+ return [
6488
+ 4,
6489
+ this.enforceGlobalRateLimit()
6490
+ ];
6491
+ case 2:
6492
+ _state.sent();
6101
6493
  this.lastAdRequestTime = Date.now();
6102
6494
  return [
6103
6495
  4,
6104
6496
  this.ima.requestAds(vastTagUrl)
6105
6497
  ];
6106
- case 2:
6498
+ case 3:
6107
6499
  _state.sent();
6500
+ sendAdLoadedTracking(this.config.licenseKey, {
6501
+ source: "ssp",
6502
+ vastUrl: vastTagUrl
6503
+ }, this.config.adPlayerType).catch(function() {});
6108
6504
  this.clearAdRequestWatchdog();
6109
6505
  if (this.activeAdRequestToken !== requestToken) {
6110
6506
  return [
6111
6507
  2
6112
6508
  ];
6113
6509
  }
6114
- _state.label = 3;
6115
- case 3:
6510
+ _state.label = 4;
6511
+ case 4:
6116
6512
  _state.trys.push([
6117
- 3,
6118
- 5,
6513
+ 4,
6514
+ 6,
6119
6515
  ,
6120
- 10
6516
+ 11
6121
6517
  ]);
6122
6518
  this.startAdFailsafeTimer(requestToken);
6123
6519
  return [
6124
6520
  4,
6125
6521
  this.ima.play()
6126
6522
  ];
6127
- case 4:
6523
+ case 5:
6128
6524
  _state.sent();
6129
6525
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6130
6526
  this.currentAdBreakStartWallClockMs = Date.now();
@@ -6138,9 +6534,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6138
6534
  this.temporaryFailureUrls.delete(vastTagUrl);
6139
6535
  return [
6140
6536
  3,
6141
- 10
6537
+ 11
6142
6538
  ];
6143
- case 5:
6539
+ case 6:
6144
6540
  playError = _state.sent();
6145
6541
  if (this.config.debugAdTiming) {
6146
6542
  console.error("[AD-ERROR] Failed to play ad:", playError);
@@ -6148,18 +6544,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6148
6544
  preloadedFallback = this.getPreloadedAd();
6149
6545
  if (!preloadedFallback) return [
6150
6546
  3,
6151
- 9
6547
+ 10
6152
6548
  ];
6153
6549
  if (this.config.debugAdTiming) {
6154
6550
  console.log("[AD-ERROR] Play failed, trying preloaded fallback ad");
6155
6551
  }
6156
- _state.label = 6;
6157
- case 6:
6552
+ _state.label = 7;
6553
+ case 7:
6158
6554
  _state.trys.push([
6159
- 6,
6160
- 8,
6555
+ 7,
6556
+ 9,
6161
6557
  ,
6162
- 9
6558
+ 10
6163
6559
  ]);
6164
6560
  this.clearAdFailsafeTimer();
6165
6561
  this.ima.destroy();
@@ -6175,7 +6571,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6175
6571
  4,
6176
6572
  this.ima.play()
6177
6573
  ];
6178
- case 7:
6574
+ case 8:
6179
6575
  _state.sent();
6180
6576
  if (this.expectedAdBreakDurationMs != null && this.adStopTimerId == null) {
6181
6577
  this.currentAdBreakStartWallClockMs = Date.now();
@@ -6188,16 +6584,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6188
6584
  return [
6189
6585
  2
6190
6586
  ];
6191
- case 8:
6587
+ case 9:
6192
6588
  fallbackError = _state.sent();
6193
6589
  if (this.config.debugAdTiming) {
6194
6590
  console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError);
6195
6591
  }
6196
6592
  return [
6197
6593
  3,
6198
- 9
6594
+ 10
6199
6595
  ];
6200
- case 9:
6596
+ case 10:
6201
6597
  if (this.isTemporaryAdError(playError)) {
6202
6598
  this.temporaryFailureUrls.set(vastTagUrl, Date.now());
6203
6599
  if (this.config.debugAdTiming) {
@@ -6214,12 +6610,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6214
6610
  this.activeAdRequestToken = null;
6215
6611
  }
6216
6612
  throw playError;
6217
- case 10:
6613
+ case 11:
6218
6614
  return [
6219
6615
  3,
6220
- 16
6616
+ 17
6221
6617
  ];
6222
- case 11:
6618
+ case 12:
6223
6619
  error = _state.sent();
6224
6620
  errorMessage = (error === null || error === void 0 ? void 0 : error.message) || "";
6225
6621
  if (this.config.debugAdTiming) {
@@ -6228,18 +6624,18 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6228
6624
  preloadedFallback1 = this.getPreloadedAd();
6229
6625
  if (!preloadedFallback1) return [
6230
6626
  3,
6231
- 15
6627
+ 16
6232
6628
  ];
6233
6629
  if (this.config.debugAdTiming) {
6234
6630
  console.log("[AD-ERROR] Request failed, trying preloaded fallback ad");
6235
6631
  }
6236
- _state.label = 12;
6237
- case 12:
6632
+ _state.label = 13;
6633
+ case 13:
6238
6634
  _state.trys.push([
6239
- 12,
6240
- 14,
6635
+ 13,
6636
+ 15,
6241
6637
  ,
6242
- 15
6638
+ 16
6243
6639
  ]);
6244
6640
  this.clearAdRequestWatchdog();
6245
6641
  this.clearAdFailsafeTimer();
@@ -6256,7 +6652,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6256
6652
  4,
6257
6653
  this.ima.play()
6258
6654
  ];
6259
- case 13:
6655
+ case 14:
6260
6656
  _state.sent();
6261
6657
  currentMuted2 = this.video.muted;
6262
6658
  currentVolume2 = this.video.volume;
@@ -6265,16 +6661,16 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6265
6661
  return [
6266
6662
  2
6267
6663
  ];
6268
- case 14:
6664
+ case 15:
6269
6665
  fallbackError1 = _state.sent();
6270
6666
  if (this.config.debugAdTiming) {
6271
6667
  console.warn("[AD-ERROR] Preloaded fallback also failed:", fallbackError1);
6272
6668
  }
6273
6669
  return [
6274
6670
  3,
6275
- 15
6671
+ 16
6276
6672
  ];
6277
- case 15:
6673
+ case 16:
6278
6674
  if (this.isTemporaryAdError(error)) {
6279
6675
  this.temporaryFailureUrls.set(vastTagUrl, Date.now());
6280
6676
  if (this.config.debugAdTiming) {
@@ -6292,7 +6688,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6292
6688
  this.activeAdRequestToken = null;
6293
6689
  }
6294
6690
  throw error;
6295
- case 16:
6691
+ case 17:
6296
6692
  return [
6297
6693
  2
6298
6694
  ];
@@ -6319,6 +6715,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6319
6715
  }
6320
6716
  this.adRequestQueue = [];
6321
6717
  this.inAdBreak = false;
6718
+ this.adDetectSentForCurrentBreak = false;
6322
6719
  this.expectedAdBreakDurationMs = void 0;
6323
6720
  this.currentAdBreakStartWallClockMs = void 0;
6324
6721
  this.clearAdStartTimer();
@@ -6328,6 +6725,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6328
6725
  this.currentAdIndex = 0;
6329
6726
  this.totalAdsInBreak = 0;
6330
6727
  this.consecutiveFailures = 0;
6728
+ this.globalConsecutiveNoFills = 0;
6331
6729
  this.ima.stop().catch(function() {});
6332
6730
  var restoredMuted = this.ima.getOriginalMutedState();
6333
6731
  var restoredVolume = this.ima.getOriginalVolume();
@@ -6359,6 +6757,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6359
6757
  key: "handleAdFailure",
6360
6758
  value: function handleAdFailure() {
6361
6759
  this.consecutiveFailures++;
6760
+ this.recordGamNoFill();
6362
6761
  var remaining = this.getRemainingAdMs();
6363
6762
  if (this.config.debugAdTiming) {
6364
6763
  console.log("[CONTINUOUS-FETCH] Ad failure: remaining=".concat(remaining, "ms, queued ads=").concat(this.adRequestQueue.length, ", consecutiveFailures=").concat(this.consecutiveFailures), this.adRequestQueue.length > 0 ? {
@@ -6386,8 +6785,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6386
6785
  key: "startAdRequestWatchdog",
6387
6786
  value: function startAdRequestWatchdog(token) {
6388
6787
  var _this = this;
6389
- this.clearAdRequestWatchdog();
6390
6788
  var _this_config_adFailsafeTimeoutMs;
6789
+ this.clearAdRequestWatchdog();
6391
6790
  var timeoutMs = (_this_config_adFailsafeTimeoutMs = this.config.adFailsafeTimeoutMs) !== null && _this_config_adFailsafeTimeoutMs !== void 0 ? _this_config_adFailsafeTimeoutMs : 1e4;
6392
6791
  this.adRequestWatchdogToken = token;
6393
6792
  this.adRequestWatchdogId = window.setTimeout(function() {
@@ -6430,8 +6829,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6430
6829
  key: "startAdFailsafeTimer",
6431
6830
  value: function startAdFailsafeTimer(token) {
6432
6831
  var _this = this;
6433
- this.clearAdFailsafeTimer();
6434
6832
  var _this_config_adFailsafeTimeoutMs;
6833
+ this.clearAdFailsafeTimer();
6435
6834
  var failsafeMs = (_this_config_adFailsafeTimeoutMs = this.config.adFailsafeTimeoutMs) !== null && _this_config_adFailsafeTimeoutMs !== void 0 ? _this_config_adFailsafeTimeoutMs : 1e4;
6436
6835
  this.adFailsafeToken = token;
6437
6836
  this.adFailsafeTimerId = window.setTimeout(function() {
@@ -6751,11 +7150,11 @@ var HlsPlayer = /*#__PURE__*/ function(_import_react2_Component) {
6751
7150
  function HlsPlayer() {
6752
7151
  _class_call_check(this, HlsPlayer);
6753
7152
  var _this;
6754
- var _this1, _arguments = arguments;
6755
- _this = _call_super(this, HlsPlayer, _to_consumable_array(_arguments)), _this1 = _this;
6756
- _this1.player = null;
6757
- _this1.mounted = false;
6758
- _this1.load = function() {
7153
+ var _this1;
7154
+ _this = _call_super(this, HlsPlayer, arguments), _this1 = _this;
7155
+ _this.player = null;
7156
+ _this.mounted = false;
7157
+ _this.load = function() {
6759
7158
  return _async_to_generator(function() {
6760
7159
  var _this_props_onMount, _this_props, config, _this_props_onReady, _this_props1, error, _this_props_onError, _this_props2;
6761
7160
  return _ts_generator(this, function(_state) {
@@ -6828,87 +7227,87 @@ var HlsPlayer = /*#__PURE__*/ function(_import_react2_Component) {
6828
7227
  });
6829
7228
  })();
6830
7229
  };
6831
- _this1.play = function() {
6832
- if (_this1.props.videoElement) {
6833
- var video = _this1.props.videoElement;
7230
+ _this.play = function() {
7231
+ if (_this.props.videoElement) {
7232
+ var video = _this.props.videoElement;
6834
7233
  var hasValidSource = video.src || video.currentSrc && video.currentSrc !== "" || video.readyState >= 1;
6835
7234
  if (hasValidSource) {
6836
7235
  var _video_play, _this_props_onPlay, _this_props;
6837
7236
  (_video_play = video.play()) === null || _video_play === void 0 ? void 0 : _video_play.catch(function(error) {
6838
7237
  var _this_props_onError, _this_props;
6839
7238
  console.error("[HlsPlayer] Failed to play:", error);
6840
- (_this_props_onError = (_this_props = _this1.props).onError) === null || _this_props_onError === void 0 ? void 0 : _this_props_onError.call(_this_props, error);
7239
+ (_this_props_onError = (_this_props = _this.props).onError) === null || _this_props_onError === void 0 ? void 0 : _this_props_onError.call(_this_props, error);
6841
7240
  });
6842
- (_this_props_onPlay = (_this_props = _this1.props).onPlay) === null || _this_props_onPlay === void 0 ? void 0 : _this_props_onPlay.call(_this_props);
7241
+ (_this_props_onPlay = (_this_props = _this.props).onPlay) === null || _this_props_onPlay === void 0 ? void 0 : _this_props_onPlay.call(_this_props);
6843
7242
  } else {
6844
7243
  console.warn("[HlsPlayer] Cannot play: video has no valid source");
6845
7244
  }
6846
7245
  }
6847
7246
  };
6848
- _this1.pause = function() {
6849
- if (_this1.props.videoElement) {
7247
+ _this.pause = function() {
7248
+ if (_this.props.videoElement) {
6850
7249
  var _this_props_onPause, _this_props;
6851
- _this1.props.videoElement.pause();
6852
- (_this_props_onPause = (_this_props = _this1.props).onPause) === null || _this_props_onPause === void 0 ? void 0 : _this_props_onPause.call(_this_props);
7250
+ _this.props.videoElement.pause();
7251
+ (_this_props_onPause = (_this_props = _this.props).onPause) === null || _this_props_onPause === void 0 ? void 0 : _this_props_onPause.call(_this_props);
6853
7252
  }
6854
7253
  };
6855
- _this1.stop = function() {
6856
- _this1.pause();
6857
- if (_this1.props.videoElement) {
6858
- _this1.props.videoElement.currentTime = 0;
7254
+ _this.stop = function() {
7255
+ _this.pause();
7256
+ if (_this.props.videoElement) {
7257
+ _this.props.videoElement.currentTime = 0;
6859
7258
  }
6860
7259
  };
6861
- _this1.seekTo = function(seconds, keepPlaying) {
6862
- if (_this1.props.videoElement) {
6863
- _this1.props.videoElement.currentTime = seconds;
7260
+ _this.seekTo = function(seconds, keepPlaying) {
7261
+ if (_this.props.videoElement) {
7262
+ _this.props.videoElement.currentTime = seconds;
6864
7263
  if (!keepPlaying) {
6865
- _this1.pause();
7264
+ _this.pause();
6866
7265
  }
6867
7266
  }
6868
7267
  };
6869
- _this1.setVolume = function(volume) {
6870
- if (_this1.props.videoElement) {
6871
- _this1.props.videoElement.volume = Math.max(0, Math.min(1, volume));
7268
+ _this.setVolume = function(volume) {
7269
+ if (_this.props.videoElement) {
7270
+ _this.props.videoElement.volume = Math.max(0, Math.min(1, volume));
6872
7271
  }
6873
7272
  };
6874
- _this1.mute = function() {
6875
- if (_this1.props.videoElement) {
6876
- _this1.props.videoElement.muted = true;
7273
+ _this.mute = function() {
7274
+ if (_this.props.videoElement) {
7275
+ _this.props.videoElement.muted = true;
6877
7276
  }
6878
7277
  };
6879
- _this1.unmute = function() {
6880
- if (_this1.props.videoElement) {
6881
- _this1.props.videoElement.muted = false;
7278
+ _this.unmute = function() {
7279
+ if (_this.props.videoElement) {
7280
+ _this.props.videoElement.muted = false;
6882
7281
  }
6883
7282
  };
6884
- _this1.setPlaybackRate = function(rate) {
6885
- if (_this1.props.videoElement && rate > 0) {
6886
- _this1.props.videoElement.playbackRate = rate;
7283
+ _this.setPlaybackRate = function(rate) {
7284
+ if (_this.props.videoElement && rate > 0) {
7285
+ _this.props.videoElement.playbackRate = rate;
6887
7286
  }
6888
7287
  };
6889
- _this1.getDuration = function() {
6890
- if (_this1.props.videoElement && isFinite(_this1.props.videoElement.duration)) {
6891
- return _this1.props.videoElement.duration;
7288
+ _this.getDuration = function() {
7289
+ if (_this.props.videoElement && isFinite(_this.props.videoElement.duration)) {
7290
+ return _this.props.videoElement.duration;
6892
7291
  }
6893
7292
  return null;
6894
7293
  };
6895
- _this1.getCurrentTime = function() {
6896
- if (_this1.props.videoElement && isFinite(_this1.props.videoElement.currentTime)) {
6897
- return _this1.props.videoElement.currentTime;
7294
+ _this.getCurrentTime = function() {
7295
+ if (_this.props.videoElement && isFinite(_this.props.videoElement.currentTime)) {
7296
+ return _this.props.videoElement.currentTime;
6898
7297
  }
6899
7298
  return null;
6900
7299
  };
6901
- _this1.getSecondsLoaded = function() {
6902
- if (_this1.props.videoElement && _this1.props.videoElement.buffered.length > 0) {
6903
- return _this1.props.videoElement.buffered.end(_this1.props.videoElement.buffered.length - 1);
7300
+ _this.getSecondsLoaded = function() {
7301
+ if (_this.props.videoElement && _this.props.videoElement.buffered.length > 0) {
7302
+ return _this.props.videoElement.buffered.end(_this.props.videoElement.buffered.length - 1);
6904
7303
  }
6905
7304
  return null;
6906
7305
  };
6907
- _this1.getInternalPlayer = function() {
7306
+ _this.getInternalPlayer = function() {
6908
7307
  var key = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "player";
6909
- if (key === "player") return _this1.player;
6910
- if (key === "video") return _this1.props.videoElement;
6911
- if (key === "hls" && _this1.player) return _this1.player.hls;
7308
+ if (key === "player") return _this.player;
7309
+ if (key === "video") return _this.props.videoElement;
7310
+ if (key === "hls" && _this.player) return _this.player.hls;
6912
7311
  return null;
6913
7312
  };
6914
7313
  return _this;
@@ -6957,49 +7356,49 @@ var FilePlayer = /*#__PURE__*/ function(_import_react3_Component) {
6957
7356
  function FilePlayer() {
6958
7357
  _class_call_check(this, FilePlayer);
6959
7358
  var _this;
6960
- var _this1, _arguments = arguments;
6961
- _this = _call_super(this, FilePlayer, _to_consumable_array(_arguments)), _this1 = _this;
6962
- _this1.mounted = false;
6963
- _this1.ready = false;
6964
- _this1.load = function() {
7359
+ var _this1;
7360
+ _this = _call_super(this, FilePlayer, arguments), _this1 = _this;
7361
+ _this.mounted = false;
7362
+ _this.ready = false;
7363
+ _this.load = function() {
6965
7364
  var _this_props_onMount, _this_props;
6966
- if (!_this1.props.videoElement || !_this1.props.src) return;
6967
- var video = _this1.props.videoElement;
6968
- var handleLoadedMetadata = function() {
6969
- if (_this1.mounted && !_this1.ready) {
7365
+ if (!_this.props.videoElement || !_this.props.src) return;
7366
+ var video = _this.props.videoElement;
7367
+ var handleLoadedMetadata = function handleLoadedMetadata() {
7368
+ if (_this.mounted && !_this.ready) {
6970
7369
  var _this_props_onReady, _this_props;
6971
- _this1.ready = true;
6972
- (_this_props_onReady = (_this_props = _this1.props).onReady) === null || _this_props_onReady === void 0 ? void 0 : _this_props_onReady.call(_this_props);
7370
+ _this.ready = true;
7371
+ (_this_props_onReady = (_this_props = _this.props).onReady) === null || _this_props_onReady === void 0 ? void 0 : _this_props_onReady.call(_this_props);
6973
7372
  }
6974
7373
  };
6975
- var handlePlay = function() {
6976
- if (_this1.mounted) {
7374
+ var handlePlay = function handlePlay() {
7375
+ if (_this.mounted) {
6977
7376
  var _this_props_onPlay, _this_props;
6978
- (_this_props_onPlay = (_this_props = _this1.props).onPlay) === null || _this_props_onPlay === void 0 ? void 0 : _this_props_onPlay.call(_this_props);
7377
+ (_this_props_onPlay = (_this_props = _this.props).onPlay) === null || _this_props_onPlay === void 0 ? void 0 : _this_props_onPlay.call(_this_props);
6979
7378
  }
6980
7379
  };
6981
- var handlePause = function() {
6982
- if (_this1.mounted) {
7380
+ var handlePause = function handlePause() {
7381
+ if (_this.mounted) {
6983
7382
  var _this_props_onPause, _this_props;
6984
- (_this_props_onPause = (_this_props = _this1.props).onPause) === null || _this_props_onPause === void 0 ? void 0 : _this_props_onPause.call(_this_props);
7383
+ (_this_props_onPause = (_this_props = _this.props).onPause) === null || _this_props_onPause === void 0 ? void 0 : _this_props_onPause.call(_this_props);
6985
7384
  }
6986
7385
  };
6987
- var handleEnded = function() {
6988
- if (_this1.mounted) {
7386
+ var handleEnded = function handleEnded() {
7387
+ if (_this.mounted) {
6989
7388
  var _this_props_onEnded, _this_props;
6990
- (_this_props_onEnded = (_this_props = _this1.props).onEnded) === null || _this_props_onEnded === void 0 ? void 0 : _this_props_onEnded.call(_this_props);
7389
+ (_this_props_onEnded = (_this_props = _this.props).onEnded) === null || _this_props_onEnded === void 0 ? void 0 : _this_props_onEnded.call(_this_props);
6991
7390
  }
6992
7391
  };
6993
- var handleError = function(error) {
6994
- if (_this1.mounted) {
7392
+ var handleError = function handleError(error) {
7393
+ if (_this.mounted) {
6995
7394
  var _this_props_onError, _this_props;
6996
- (_this_props_onError = (_this_props = _this1.props).onError) === null || _this_props_onError === void 0 ? void 0 : _this_props_onError.call(_this_props, error);
7395
+ (_this_props_onError = (_this_props = _this.props).onError) === null || _this_props_onError === void 0 ? void 0 : _this_props_onError.call(_this_props, error);
6997
7396
  }
6998
7397
  };
6999
- var handleLoadedData = function() {
7000
- if (_this1.mounted) {
7398
+ var handleLoadedData = function handleLoadedData() {
7399
+ if (_this.mounted) {
7001
7400
  var _this_props_onLoaded, _this_props;
7002
- (_this_props_onLoaded = (_this_props = _this1.props).onLoaded) === null || _this_props_onLoaded === void 0 ? void 0 : _this_props_onLoaded.call(_this_props);
7401
+ (_this_props_onLoaded = (_this_props = _this.props).onLoaded) === null || _this_props_onLoaded === void 0 ? void 0 : _this_props_onLoaded.call(_this_props);
7003
7402
  }
7004
7403
  };
7005
7404
  video.addEventListener("loadedmetadata", handleLoadedMetadata);
@@ -7008,15 +7407,15 @@ var FilePlayer = /*#__PURE__*/ function(_import_react3_Component) {
7008
7407
  video.addEventListener("ended", handleEnded);
7009
7408
  video.addEventListener("error", handleError);
7010
7409
  video.addEventListener("loadeddata", handleLoadedData);
7011
- video.src = _this1.props.src;
7012
- if (_this1.props.autoplay !== void 0) video.autoplay = _this1.props.autoplay;
7013
- if (_this1.props.muted !== void 0) video.muted = _this1.props.muted;
7014
- if (_this1.props.loop !== void 0) video.loop = _this1.props.loop;
7015
- if (_this1.props.controls !== void 0) video.controls = _this1.props.controls;
7016
- if (_this1.props.playsInline !== void 0) video.playsInline = _this1.props.playsInline;
7017
- if (_this1.props.preload !== void 0) video.preload = _this1.props.preload;
7018
- if (_this1.props.poster !== void 0) video.poster = _this1.props.poster;
7019
- (_this_props_onMount = (_this_props = _this1.props).onMount) === null || _this_props_onMount === void 0 ? void 0 : _this_props_onMount.call(_this_props, _this1);
7410
+ video.src = _this.props.src;
7411
+ if (_this.props.autoplay !== void 0) video.autoplay = _this.props.autoplay;
7412
+ if (_this.props.muted !== void 0) video.muted = _this.props.muted;
7413
+ if (_this.props.loop !== void 0) video.loop = _this.props.loop;
7414
+ if (_this.props.controls !== void 0) video.controls = _this.props.controls;
7415
+ if (_this.props.playsInline !== void 0) video.playsInline = _this.props.playsInline;
7416
+ if (_this.props.preload !== void 0) video.preload = _this.props.preload;
7417
+ if (_this.props.poster !== void 0) video.poster = _this.props.poster;
7418
+ (_this_props_onMount = (_this_props = _this.props).onMount) === null || _this_props_onMount === void 0 ? void 0 : _this_props_onMount.call(_this_props, _this);
7020
7419
  return function() {
7021
7420
  video.removeEventListener("loadedmetadata", handleLoadedMetadata);
7022
7421
  video.removeEventListener("play", handlePlay);
@@ -7026,90 +7425,90 @@ var FilePlayer = /*#__PURE__*/ function(_import_react3_Component) {
7026
7425
  video.removeEventListener("loadeddata", handleLoadedData);
7027
7426
  };
7028
7427
  };
7029
- _this1.play = function() {
7030
- if (_this1.props.videoElement) {
7031
- var video = _this1.props.videoElement;
7428
+ _this.play = function() {
7429
+ if (_this.props.videoElement) {
7430
+ var video = _this.props.videoElement;
7032
7431
  var hasValidSource = video.src || video.currentSrc && video.currentSrc !== "" || video.readyState >= 1;
7033
7432
  if (hasValidSource) {
7034
7433
  var _video_play;
7035
7434
  (_video_play = video.play()) === null || _video_play === void 0 ? void 0 : _video_play.catch(function(error) {
7036
7435
  var _this_props_onError, _this_props;
7037
7436
  console.error("[FilePlayer] Failed to play:", error);
7038
- (_this_props_onError = (_this_props = _this1.props).onError) === null || _this_props_onError === void 0 ? void 0 : _this_props_onError.call(_this_props, error);
7437
+ (_this_props_onError = (_this_props = _this.props).onError) === null || _this_props_onError === void 0 ? void 0 : _this_props_onError.call(_this_props, error);
7039
7438
  });
7040
7439
  } else {
7041
7440
  console.warn("[FilePlayer] Cannot play: video has no valid source");
7042
7441
  }
7043
7442
  }
7044
7443
  };
7045
- _this1.pause = function() {
7046
- if (_this1.props.videoElement) {
7047
- _this1.props.videoElement.pause();
7444
+ _this.pause = function() {
7445
+ if (_this.props.videoElement) {
7446
+ _this.props.videoElement.pause();
7048
7447
  }
7049
7448
  };
7050
- _this1.stop = function() {
7051
- _this1.pause();
7052
- if (_this1.props.videoElement) {
7053
- _this1.props.videoElement.currentTime = 0;
7449
+ _this.stop = function() {
7450
+ _this.pause();
7451
+ if (_this.props.videoElement) {
7452
+ _this.props.videoElement.currentTime = 0;
7054
7453
  }
7055
7454
  };
7056
- _this1.seekTo = function(seconds, keepPlaying) {
7057
- if (_this1.props.videoElement) {
7058
- _this1.props.videoElement.currentTime = seconds;
7455
+ _this.seekTo = function(seconds, keepPlaying) {
7456
+ if (_this.props.videoElement) {
7457
+ _this.props.videoElement.currentTime = seconds;
7059
7458
  if (!keepPlaying) {
7060
- _this1.pause();
7459
+ _this.pause();
7061
7460
  }
7062
7461
  }
7063
7462
  };
7064
- _this1.setVolume = function(volume) {
7065
- if (_this1.props.videoElement) {
7066
- _this1.props.videoElement.volume = Math.max(0, Math.min(1, volume));
7463
+ _this.setVolume = function(volume) {
7464
+ if (_this.props.videoElement) {
7465
+ _this.props.videoElement.volume = Math.max(0, Math.min(1, volume));
7067
7466
  }
7068
7467
  };
7069
- _this1.mute = function() {
7070
- if (_this1.props.videoElement) {
7071
- _this1.props.videoElement.muted = true;
7468
+ _this.mute = function() {
7469
+ if (_this.props.videoElement) {
7470
+ _this.props.videoElement.muted = true;
7072
7471
  }
7073
7472
  };
7074
- _this1.unmute = function() {
7075
- if (_this1.props.videoElement) {
7076
- _this1.props.videoElement.muted = false;
7473
+ _this.unmute = function() {
7474
+ if (_this.props.videoElement) {
7475
+ _this.props.videoElement.muted = false;
7077
7476
  }
7078
7477
  };
7079
- _this1.setPlaybackRate = function(rate) {
7080
- if (_this1.props.videoElement && rate > 0) {
7081
- _this1.props.videoElement.playbackRate = rate;
7478
+ _this.setPlaybackRate = function(rate) {
7479
+ if (_this.props.videoElement && rate > 0) {
7480
+ _this.props.videoElement.playbackRate = rate;
7082
7481
  }
7083
7482
  };
7084
- _this1.setLoop = function(loop) {
7085
- if (_this1.props.videoElement) {
7086
- _this1.props.videoElement.loop = loop;
7483
+ _this.setLoop = function(loop) {
7484
+ if (_this.props.videoElement) {
7485
+ _this.props.videoElement.loop = loop;
7087
7486
  }
7088
7487
  };
7089
- _this1.getDuration = function() {
7090
- if (_this1.props.videoElement && isFinite(_this1.props.videoElement.duration)) {
7091
- return _this1.props.videoElement.duration;
7488
+ _this.getDuration = function() {
7489
+ if (_this.props.videoElement && isFinite(_this.props.videoElement.duration)) {
7490
+ return _this.props.videoElement.duration;
7092
7491
  }
7093
7492
  return null;
7094
7493
  };
7095
- _this1.getCurrentTime = function() {
7096
- if (_this1.props.videoElement && isFinite(_this1.props.videoElement.currentTime)) {
7097
- return _this1.props.videoElement.currentTime;
7494
+ _this.getCurrentTime = function() {
7495
+ if (_this.props.videoElement && isFinite(_this.props.videoElement.currentTime)) {
7496
+ return _this.props.videoElement.currentTime;
7098
7497
  }
7099
7498
  return null;
7100
7499
  };
7101
- _this1.getSecondsLoaded = function() {
7102
- if (_this1.props.videoElement && _this1.props.videoElement.buffered.length > 0) {
7103
- return _this1.props.videoElement.buffered.end(_this1.props.videoElement.buffered.length - 1);
7500
+ _this.getSecondsLoaded = function() {
7501
+ if (_this.props.videoElement && _this.props.videoElement.buffered.length > 0) {
7502
+ return _this.props.videoElement.buffered.end(_this.props.videoElement.buffered.length - 1);
7104
7503
  }
7105
7504
  return null;
7106
7505
  };
7107
- _this1.getInternalPlayer = function() {
7506
+ _this.getInternalPlayer = function() {
7108
7507
  var key = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "player";
7109
- if (key === "video") return _this1.props.videoElement;
7508
+ if (key === "video") return _this.props.videoElement;
7110
7509
  return null;
7111
7510
  };
7112
- _this1.enablePIP = function() {
7511
+ _this.enablePIP = function() {
7113
7512
  return _async_to_generator(function() {
7114
7513
  var error;
7115
7514
  return _ts_generator(this, function(_state) {
@@ -7152,7 +7551,7 @@ var FilePlayer = /*#__PURE__*/ function(_import_react3_Component) {
7152
7551
  });
7153
7552
  })();
7154
7553
  };
7155
- _this1.disablePIP = function() {
7554
+ _this.disablePIP = function() {
7156
7555
  return _async_to_generator(function() {
7157
7556
  var error;
7158
7557
  return _ts_generator(this, function(_state) {
@@ -7246,7 +7645,7 @@ var players = [
7246
7645
  key: "file",
7247
7646
  name: "File Player",
7248
7647
  canPlay: canPlay.file,
7249
- canEnablePIP: function(url) {
7648
+ canEnablePIP: function canEnablePIP(url) {
7250
7649
  return canPlay.file(url) && (document.pictureInPictureEnabled || typeof document.webkitSupportsPresentationMode === "function");
7251
7650
  },
7252
7651
  lazyPlayer: lazy(function() {