stormcloud-video-player 0.8.81 → 0.8.83

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/stormcloud-vp.min.js +1 -1
  2. package/lib/Player.d.cts +1 -1
  3. package/lib/StormcloudPlayer.cjs +145 -10
  4. package/lib/StormcloudPlayer.cjs.map +1 -1
  5. package/lib/index.cjs +145 -10
  6. package/lib/index.cjs.map +1 -1
  7. package/lib/index.d.ts +5 -0
  8. package/lib/index.js +145 -10
  9. package/lib/index.js.map +1 -1
  10. package/lib/player/AdBreakOrchestrator.cjs +63 -3
  11. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  12. package/lib/player/AdBreakOrchestrator.d.cts +1 -0
  13. package/lib/player/AdConfigManager.cjs +54 -3
  14. package/lib/player/AdConfigManager.cjs.map +1 -1
  15. package/lib/player/StormcloudVideoPlayer.cjs +145 -10
  16. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  17. package/lib/player/StormcloudVideoPlayer.d.cts +2 -0
  18. package/lib/players/HlsPlayer.cjs +145 -10
  19. package/lib/players/HlsPlayer.cjs.map +1 -1
  20. package/lib/players/index.cjs +145 -10
  21. package/lib/players/index.cjs.map +1 -1
  22. package/lib/sdk/hlsAdPlayer.cjs +13 -0
  23. package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
  24. package/lib/types.d.cts +1 -0
  25. package/lib/ui/StormcloudVideoPlayer.cjs +145 -10
  26. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  27. package/lib/utils/__tests__/adSignals.test.cjs +30 -3
  28. package/lib/utils/__tests__/adSignals.test.cjs.map +1 -1
  29. package/lib/utils/adIdentity.cjs +34 -1
  30. package/lib/utils/adIdentity.cjs.map +1 -1
  31. package/lib/utils/adIdentity.d.cts +2 -1
  32. package/lib/utils/browserCompat.cjs +33 -0
  33. package/lib/utils/browserCompat.cjs.map +1 -1
  34. package/lib/utils/browserCompat.d.cts +3 -1
  35. package/lib/utils/contentMetadata.cjs +15 -4
  36. package/lib/utils/contentMetadata.cjs.map +1 -1
  37. package/lib/utils/contentMetadata.d.cts +2 -0
  38. package/lib/utils/partnerSignals.cjs +13 -2
  39. package/lib/utils/partnerSignals.cjs.map +1 -1
  40. package/lib/utils/partnerSignals.d.cts +2 -1
  41. package/lib/utils/vastMacros.cjs +1 -0
  42. package/lib/utils/vastMacros.cjs.map +1 -1
  43. package/lib/utils/vastMacros.d.cts +1 -0
  44. package/package.json +1 -1
package/lib/index.cjs CHANGED
@@ -588,6 +588,9 @@ var DEFAULT_LGUDID_TIMEOUT_MS = 1500;
588
588
  var FALLBACK_DEVICE_ID_KEY = "stormcloud.ad.dpid.v2";
589
589
  var SESSION_ID_KEY = "stormcloud.ad.sid.v2";
590
590
  var LEGACY_SESSION_KEY = "stormcloud.ctv.sid";
591
+ var STAY_ID_KEY = "stormcloud.ad.stay.v1";
592
+ var HOST_ID_KEY = "stormcloud.ad.host.v1";
593
+ var memoryMarkers = {};
591
594
  var ZEROED_IDS = /* @__PURE__ */ new Set([
592
595
  "00000000-0000-0000-0000-000000000000",
593
596
  "38400000-8cf0-11bd-b23e-10b96e40000d"
@@ -690,7 +693,7 @@ function setHostAdIdentity(identity) {
690
693
  return;
691
694
  }
692
695
  var deviceId = identity.deviceId.trim();
693
- var changed = !hostIdentity || hostIdentity.deviceId !== deviceId;
696
+ var changed = writeMarkerIfChanged(HOST_ID_KEY, deviceId);
694
697
  hostIdentity = _object_spread({
695
698
  deviceId: deviceId,
696
699
  deviceIdType: (_normalizeIdType = normalizeIdType(identity.deviceIdType)) !== null && _normalizeIdType !== void 0 ? _normalizeIdType : "dpid"
@@ -709,6 +712,31 @@ function resetAdIdentity() {
709
712
  removeStored(SESSION_ID_KEY);
710
713
  removeStored(FALLBACK_DEVICE_ID_KEY);
711
714
  }
715
+ function writeMarkerIfChanged(key, value) {
716
+ var _memoryMarkers_key;
717
+ var previous = (_memoryMarkers_key = memoryMarkers[key]) !== null && _memoryMarkers_key !== void 0 ? _memoryMarkers_key : "";
718
+ try {
719
+ var _window_localStorage;
720
+ var stored = typeof window !== "undefined" ? (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key) : null;
721
+ if (typeof stored === "string") previous = stored;
722
+ } catch (unused) {}
723
+ if (value === previous) return false;
724
+ memoryMarkers[key] = value;
725
+ try {
726
+ if (typeof window !== "undefined") {
727
+ var _window_localStorage1, _window_localStorage2;
728
+ if (value) (_window_localStorage1 = window.localStorage) === null || _window_localStorage1 === void 0 ? void 0 : _window_localStorage1.setItem(key, value);
729
+ else (_window_localStorage2 = window.localStorage) === null || _window_localStorage2 === void 0 ? void 0 : _window_localStorage2.removeItem(key);
730
+ }
731
+ } catch (unused) {}
732
+ return true;
733
+ }
734
+ function noteStayId(stayId) {
735
+ if (!writeMarkerIfChanged(STAY_ID_KEY, stayId ? stayId.trim() : "")) return false;
736
+ removeStored(SESSION_ID_KEY);
737
+ removeStored(FALLBACK_DEVICE_ID_KEY);
738
+ return true;
739
+ }
712
740
  function readSamsungTifa() {
713
741
  try {
714
742
  var _window_webapis;
@@ -1495,7 +1523,9 @@ var BRIDGE_KEYS = {
1495
1523
  ],
1496
1524
  contentRating: [
1497
1525
  "contentRating",
1498
- "ctr"
1526
+ "ctr",
1527
+ "programRating",
1528
+ "rating"
1499
1529
  ],
1500
1530
  contentId: [
1501
1531
  "contentId",
@@ -1507,7 +1537,9 @@ function sanitizeContentValue(value) {
1507
1537
  var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1508
1538
  if (!cleaned) return void 0;
1509
1539
  if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
1510
- if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
1540
+ if (/^(unknown|null|undefined|none|n\/a|-|tbd|tba|to be (announced|determined))$/i.test(cleaned)) {
1541
+ return void 0;
1542
+ }
1511
1543
  return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
1512
1544
  }
1513
1545
  function sanitizeContentScalar(value) {
@@ -1633,6 +1665,7 @@ function resolveContentMetadata(config) {
1633
1665
  } : {});
1634
1666
  }
1635
1667
  function applyContentMetadataUpdate(target, meta) {
1668
+ var _target_contentDetails;
1636
1669
  var apply = function apply(key, value) {
1637
1670
  if (value === void 0) return;
1638
1671
  var clean = value === null ? void 0 : sanitizeContentValue(value);
@@ -1642,9 +1675,15 @@ function applyContentMetadataUpdate(target, meta) {
1642
1675
  apply("channelName", meta.channelName);
1643
1676
  apply("programTitle", meta.programTitle);
1644
1677
  apply("contentNetwork", meta.contentNetwork);
1645
- if (meta.details === void 0) return;
1646
1678
  if (meta.details === null) delete target.contentDetails;
1647
- else target.contentDetails = _object_spread({}, meta.details);
1679
+ else if (meta.details !== void 0) target.contentDetails = _object_spread({}, meta.details);
1680
+ var rating = meta.programRating !== void 0 ? meta.programRating : meta.contentRating;
1681
+ if (rating === void 0) return;
1682
+ var cleanRating = rating === null ? void 0 : sanitizeContentValue(rating);
1683
+ var details = _object_spread({}, (_target_contentDetails = target.contentDetails) !== null && _target_contentDetails !== void 0 ? _target_contentDetails : {});
1684
+ if (cleanRating) details.rating = cleanRating;
1685
+ else delete details.rating;
1686
+ target.contentDetails = details;
1648
1687
  }
1649
1688
  function appendMissingContentParams(url, meta) {
1650
1689
  if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
@@ -1737,6 +1776,11 @@ function sanitizePublicIp(value) {
1737
1776
  if (cleaned.includes(".")) return isPublicIpv4(cleaned) ? cleaned : void 0;
1738
1777
  return isPublicIpv6(cleaned) ? cleaned : void 0;
1739
1778
  }
1779
+ var PPID_PATTERN = /^[0-9a-zA-Z+.=\/_\-$,{}]{22,150}$/;
1780
+ function toPpid(userId, limitAdTracking) {
1781
+ if (!userId || limitAdTracking === true) return void 0;
1782
+ return PPID_PATTERN.test(userId) ? userId : void 0;
1783
+ }
1740
1784
  function resolveUserId(configValue) {
1741
1785
  var _sanitizeUserId;
1742
1786
  return (_sanitizeUserId = sanitizeUserId(configValue)) !== null && _sanitizeUserId !== void 0 ? _sanitizeUserId : readBridgeValue2([
@@ -2145,6 +2189,7 @@ function resolveScvpMacroValues(ctx) {
2145
2189
  set("UA", ctx.userAgent);
2146
2190
  set("IP", ctx.ipAddress);
2147
2191
  set("UID", ctx.userId);
2192
+ set("PPID", ctx.ppid);
2148
2193
  set("CT-TYPE", ctx.contentType);
2149
2194
  set("CT-CATEGORY", ctx.contentCategory);
2150
2195
  set("CT-GENRE", ctx.contentGenre);
@@ -3049,9 +3094,30 @@ function detectBrowser() {
3049
3094
  };
3050
3095
  }
3051
3096
  var singleDecoderOverride;
3097
+ var LEARNED_SINGLE_DECODER_KEY = "stormcloud.singleDecoder.learned.v1";
3098
+ var learnedSingleDecoder;
3052
3099
  function setSingleDecoderOverride(value) {
3053
3100
  singleDecoderOverride = value;
3054
3101
  }
3102
+ function readLearnedSingleDecoder() {
3103
+ if (learnedSingleDecoder !== void 0) return learnedSingleDecoder;
3104
+ try {
3105
+ var _window_localStorage;
3106
+ learnedSingleDecoder = typeof window !== "undefined" && ((_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(LEARNED_SINGLE_DECODER_KEY)) === "1";
3107
+ } catch (unused) {
3108
+ learnedSingleDecoder = false;
3109
+ }
3110
+ return learnedSingleDecoder;
3111
+ }
3112
+ function markSingleDecoderLearned() {
3113
+ if (readLearnedSingleDecoder()) return false;
3114
+ learnedSingleDecoder = true;
3115
+ try {
3116
+ var _window_localStorage;
3117
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(LEARNED_SINGLE_DECODER_KEY, "1");
3118
+ } catch (unused) {}
3119
+ return true;
3120
+ }
3055
3121
  function requiresMediaPipelineResetAfterAds() {
3056
3122
  var _browser_tizenVersion;
3057
3123
  if (singleDecoderOverride != null) return singleDecoderOverride;
@@ -3059,6 +3125,7 @@ function requiresMediaPipelineResetAfterAds() {
3059
3125
  var globalOverride = typeof window !== "undefined" ? window.__STORMCLOUD_SINGLE_DECODER__ : void 0;
3060
3126
  if (typeof globalOverride === "boolean") return globalOverride;
3061
3127
  } catch (unused) {}
3128
+ if (readLearnedSingleDecoder()) return true;
3062
3129
  var browser = detectBrowser();
3063
3130
  return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
3064
3131
  }
@@ -9761,6 +9828,8 @@ var AdConfigManager = /*#__PURE__*/ function() {
9761
9828
  value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
9762
9829
  var _content_contentDurationSeconds;
9763
9830
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
9831
+ var stayUserId = resolveUserId(this.config.adUserId);
9832
+ noteStayId(stayUserId);
9764
9833
  var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
9765
9834
  fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
9766
9835
  sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
@@ -9771,7 +9840,8 @@ var AdConfigManager = /*#__PURE__*/ function() {
9771
9840
  var playerSize = resolvePlayerSize(this.video);
9772
9841
  var videoDuration = this.video.duration;
9773
9842
  var contentDurationSeconds = (_content_contentDurationSeconds = content.contentDurationSeconds) !== null && _content_contentDurationSeconds !== void 0 ? _content_contentDurationSeconds : !isLive && Number.isFinite(videoDuration) && videoDuration > 0 ? Math.round(videoDuration) : void 0;
9774
- var userId = resolveUserId(this.config.adUserId);
9843
+ var userId = envSignals.limitAdTracking === true ? void 0 : stayUserId;
9844
+ var ppid = toPpid(stayUserId, envSignals.limitAdTracking);
9775
9845
  var ipAddress = resolveClientIp(this.config.clientIpAddress);
9776
9846
  var userAgent2 = typeof navigator !== "undefined" && navigator.userAgent ? navigator.userAgent : void 0;
9777
9847
  var macroContext = _object_spread(_object_spread_props(_object_spread(_object_spread_props(_object_spread({
@@ -9817,6 +9887,8 @@ var AdConfigManager = /*#__PURE__*/ function() {
9817
9887
  ipAddress: ipAddress
9818
9888
  } : {}, userId ? {
9819
9889
  userId: userId
9890
+ } : {}, ppid ? {
9891
+ ppid: ppid
9820
9892
  } : {}, content.contentType ? {
9821
9893
  contentType: content.contentType
9822
9894
  } : {}, content.contentCategory ? {
@@ -9864,9 +9936,11 @@ var AdConfigManager = /*#__PURE__*/ function() {
9864
9936
  isLat: envSignals.limitAdTracking,
9865
9937
  dth: envSignals.deviceTypeHint,
9866
9938
  sidTail: envSignals.sessionId ? envSignals.sessionId.slice(-4) : void 0,
9939
+ ppidTail: ppid ? ppid.slice(-4) : void 0,
9867
9940
  ct_ch: content.channelName,
9868
9941
  ct_ti: content.programTitle,
9869
9942
  ct_ne: content.contentNetwork,
9943
+ rating: content.contentRating,
9870
9944
  ifaType: toIabIfaType(envSignals.deviceIdType, envSignals.deviceIdSource),
9871
9945
  live: isLive,
9872
9946
  player: playerSize,
@@ -11550,6 +11624,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11550
11624
  this.adDetectSentForCurrentBreak = false;
11551
11625
  this.slotState = "IDLE";
11552
11626
  this.unusableResponsesInBreak = 0;
11627
+ this.playedAdIdsInBreak = /* @__PURE__ */ new Set();
11553
11628
  this.controllerGeneration = 0;
11554
11629
  this.requestDiagnostics = /* @__PURE__ */ new Map();
11555
11630
  this.breakFunnel = {};
@@ -11646,6 +11721,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11646
11721
  _this.recordRequestDiagnostic(payload);
11647
11722
  });
11648
11723
  adPlayer.on("ad_impression", function() {
11724
+ var _this_host_getAdPlayer_getLoadedAdId, _this_host_getAdPlayer;
11725
+ var impressionAdId = (_this_host_getAdPlayer_getLoadedAdId = (_this_host_getAdPlayer = _this.host.getAdPlayer()).getLoadedAdId) === null || _this_host_getAdPlayer_getLoadedAdId === void 0 ? void 0 : _this_host_getAdPlayer_getLoadedAdId.call(_this_host_getAdPlayer);
11726
+ if (impressionAdId != null && impressionAdId !== "") {
11727
+ _this.playedAdIdsInBreak.add(String(impressionAdId));
11728
+ }
11649
11729
  _this.timing.consecutiveFailures = 0;
11650
11730
  _this.setSlotState("PLAYING", "impression");
11651
11731
  if (!_this.playbackStartedForCurrentRequest) {
@@ -11837,6 +11917,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11837
11917
  this.resetEdgeStateForBreak();
11838
11918
  this.followUpBaseVastUrl = void 0;
11839
11919
  this.unusableResponsesInBreak = 0;
11920
+ this.playedAdIdsInBreak.clear();
11840
11921
  this.timing.totalAdRequestsInBreak = 0;
11841
11922
  this.setSlotState("NEEDS_NEXT_AD", "vmap_break_start");
11842
11923
  this.noteOpportunity("vmap", breakKey, position);
@@ -11887,6 +11968,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11887
11968
  this.breakSource = "scte35";
11888
11969
  this.followUpBaseVastUrl = baseVastUrl;
11889
11970
  this.unusableResponsesInBreak = 0;
11971
+ this.playedAdIdsInBreak.clear();
11890
11972
  this.resetEdgeStateForBreak();
11891
11973
  this.setSlotState("NEEDS_NEXT_AD", "scte35_break_start");
11892
11974
  if (this.adConfig.podAssignedByPrefetch) {
@@ -12726,6 +12808,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12726
12808
  var outcome;
12727
12809
  if (message.includes("ad_duration_exceeds_budget")) {
12728
12810
  outcome = "discarded_budget";
12811
+ } else if (message.includes("ad_repeated_in_break")) {
12812
+ outcome = "discarded_duplicate";
12729
12813
  } else if (message.includes("VAST fill rejected")) {
12730
12814
  outcome = "fill_rejected";
12731
12815
  } else if (/no ads available|no fill|nofill/i.test(message)) {
@@ -12740,7 +12824,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12740
12824
  outcome = "request_failed";
12741
12825
  }
12742
12826
  this.timing.consecutiveFailures++;
12743
- if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget") {
12827
+ if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget" || outcome === "discarded_duplicate") {
12744
12828
  this.unusableResponsesInBreak++;
12745
12829
  }
12746
12830
  if (outcome === "no_fill") {
@@ -12754,7 +12838,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12754
12838
  }) ? diag.dispatchedUrl : vastTagUrl;
12755
12839
  if (this.timing.isTemporaryAdError(error)) {
12756
12840
  this.timing.temporaryFailureUrls.set(failureKey, Date.now());
12757
- } else if (outcome !== "discarded_budget") {
12841
+ } else if (outcome !== "discarded_budget" && outcome !== "discarded_duplicate") {
12758
12842
  this.timing.failedVastUrls.add(failureKey);
12759
12843
  }
12760
12844
  this.countFunnelStage("request_outcome:".concat(outcome));
@@ -13126,7 +13210,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13126
13210
  value: function playSingleAd(vastTagUrl) {
13127
13211
  var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
13128
13212
  return _async_to_generator(function() {
13129
- var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, finalizeRequestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
13213
+ var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, _ref, _ap_getLoadedAdId, _ap_getPodAdCount, finalizeRequestUrl, loadedAdId, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
13130
13214
  return _ts_generator(this, function(_state) {
13131
13215
  switch(_state.label){
13132
13216
  case 0:
@@ -13239,6 +13323,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13239
13323
  vastUrl: (_this_currentVastUrl = this.currentVastUrl) !== null && _this_currentVastUrl !== void 0 ? _this_currentVastUrl : requestUrl,
13240
13324
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
13241
13325
  }, this.analyticsContext).catch(function() {});
13326
+ loadedAdId = (_ap_getLoadedAdId = ap.getLoadedAdId) === null || _ap_getLoadedAdId === void 0 ? void 0 : _ap_getLoadedAdId.call(ap);
13327
+ if (!this.host.config.allowRepeatAdsInBreak && loadedAdId != null && loadedAdId !== "" && ((_ref = (_ap_getPodAdCount = ap.getPodAdCount) === null || _ap_getPodAdCount === void 0 ? void 0 : _ap_getPodAdCount.call(ap)) !== null && _ref !== void 0 ? _ref : 1) <= 1 && this.playedAdIdsInBreak.has(String(loadedAdId))) {
13328
+ if (this.debug) {
13329
+ console.log("[AD-DURATION] Rejected ad id=".concat(loadedAdId, ": already played in this break — requesting another ad"));
13330
+ }
13331
+ this.logOrchestratorFunnel("discarded_duplicate", {
13332
+ adId: String(loadedAdId)
13333
+ });
13334
+ throw new Error("ad_repeated_in_break");
13335
+ }
13242
13336
  if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
13243
13337
  ;
13244
13338
  adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
@@ -13292,6 +13386,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13292
13386
  this.recordRequestFailure(error, vastTagUrl);
13293
13387
  if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
13294
13388
  this.recreateAdController("discarded_budget");
13389
+ } else if ((error === null || error === void 0 ? void 0 : error.message) === "ad_repeated_in_break") {
13390
+ this.recreateAdController("discarded_duplicate");
13295
13391
  }
13296
13392
  throw error;
13297
13393
  case 10:
@@ -13365,6 +13461,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13365
13461
  tagAllowsAudio: count("tag_allows_audio"),
13366
13462
  missingImpression: count("vast_missing_impression"),
13367
13463
  discardedBudget: count("discarded_budget"),
13464
+ discardedDuplicate: count("discarded_duplicate"),
13368
13465
  mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
13369
13466
  mediaRejected: count("media_candidate:rejected"),
13370
13467
  mediaFallbacks: count("media_fallback"),
@@ -13440,6 +13537,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13440
13537
  this.breakSource = void 0;
13441
13538
  this.followUpBaseVastUrl = void 0;
13442
13539
  this.unusableResponsesInBreak = 0;
13540
+ this.playedAdIdsInBreak.clear();
13443
13541
  this.resetEdgeStateForBreak();
13444
13542
  adPlayer.stop().catch(function() {});
13445
13543
  if (!alreadyEnded) this.logBreakFunnel(reason);
@@ -13540,9 +13638,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13540
13638
  var maxMonitorMs = 45e3;
13541
13639
  var startTime = Date.now();
13542
13640
  var baseline = resumeBaseline;
13641
+ var lastSeenTime = resumeBaseline;
13543
13642
  var recoveries = 0;
13544
13643
  var lastRecoveryAt = 0;
13545
13644
  var video = this.host.video;
13645
+ var onDecodeError = function onDecodeError() {
13646
+ var _video_error;
13647
+ if (needsReset || ((_video_error = video.error) === null || _video_error === void 0 ? void 0 : _video_error.code) !== 3) return;
13648
+ if (markSingleDecoderLearned() && _this.debug) {
13649
+ console.warn("[StormcloudVideoPlayer] Decoder error while resuming after ads \u2014 using single-decoder mode on this device from the next break");
13650
+ }
13651
+ };
13652
+ video.addEventListener("error", onDecodeError);
13546
13653
  var listenersAttached = false;
13547
13654
  var onMediaEvent;
13548
13655
  var diagEvents = [
@@ -13592,6 +13699,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13592
13699
  console.log("[ResumeDiag] +0.0s monitor start — ".concat(this.describeVideoState()));
13593
13700
  }
13594
13701
  var cleanup = function cleanup() {
13702
+ video.removeEventListener("error", onDecodeError);
13595
13703
  if (listenersAttached && onMediaEvent) {
13596
13704
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
13597
13705
  try {
@@ -13622,6 +13730,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13622
13730
  return;
13623
13731
  }
13624
13732
  var currentTime = video.currentTime;
13733
+ if (currentTime + 1 < lastSeenTime) {
13734
+ baseline = currentTime;
13735
+ }
13736
+ lastSeenTime = currentTime;
13625
13737
  var advanced = currentTime > baseline + 0.5;
13626
13738
  var playing = !video.paused && video.readyState >= 3;
13627
13739
  if (advanced && playing) {
@@ -14292,6 +14404,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
14292
14404
  var _this_config_palContinuousPlayback, _this_config_lowLatencyMode, _this_config_palIconsSupported, _this_config_palSupportedApiFrameworks;
14293
14405
  _this.adConfig.consentSignals = signals;
14294
14406
  var muted = _this.video.muted;
14407
+ var palPpid = _this.currentPpid();
14295
14408
  var palSessionId = _this.config.ctvAdRequest ? getOrRotateSessionId(_this.config.sessionIdMaxAgeMs) : void 0;
14296
14409
  var palOptions = _object_spread({
14297
14410
  videoWidth: _this.video.offsetWidth || _this.video.clientWidth || 640,
@@ -14308,9 +14421,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
14308
14421
  allowStorage: signals.storageAllowed
14309
14422
  } : {}, palSessionId ? {
14310
14423
  sessionId: palSessionId
14424
+ } : {}, palPpid ? {
14425
+ ppid: palPpid
14311
14426
  } : {});
14312
14427
  _this.lastPalOptions = palOptions;
14313
14428
  _this.palSessionId = palSessionId;
14429
+ _this.palPpid = palPpid;
14314
14430
  _this.startPalNonceRefresh();
14315
14431
  return _this.palNonce.generateNonce(palOptions);
14316
14432
  }).catch(function() {});
@@ -14369,26 +14485,44 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
14369
14485
  if (!options) return;
14370
14486
  var maxAgeMs = (_this_config_palNonceMaxAgeMs = this.config.palNonceMaxAgeMs) !== null && _this_config_palNonceMaxAgeMs !== void 0 ? _this_config_palNonceMaxAgeMs : DEFAULT_PAL_NONCE_MAX_AGE_MS;
14371
14487
  var ageMs = this.palNonce.getNonceAgeMs();
14488
+ var ppid = this.currentPpid();
14489
+ var ppidChanged = ppid !== this.palPpid;
14372
14490
  var sessionId = this.config.ctvAdRequest ? getOrRotateSessionId(this.config.sessionIdMaxAgeMs) : void 0;
14373
14491
  var sessionChanged = sessionId !== this.palSessionId;
14374
14492
  var stale = ageMs === void 0 || ageMs >= maxAgeMs;
14375
- if (!force && !stale && !sessionChanged) return;
14493
+ if (!force && !stale && !sessionChanged && !ppidChanged) return;
14376
14494
  var next = _object_spread({}, options);
14377
14495
  if (sessionId) next.sessionId = sessionId;
14378
14496
  else delete next.sessionId;
14497
+ if (ppid) next.ppid = ppid;
14498
+ else delete next.ppid;
14379
14499
  this.lastPalOptions = next;
14380
14500
  this.palSessionId = sessionId;
14501
+ this.palPpid = ppid;
14381
14502
  if (this.debug) {
14382
14503
  console.log("[PAL] Regenerating nonce", {
14383
14504
  force: force,
14384
14505
  stale: stale,
14385
14506
  sessionChanged: sessionChanged,
14507
+ ppidChanged: ppidChanged,
14386
14508
  ageMs: ageMs
14387
14509
  });
14388
14510
  }
14389
14511
  this.palNonce.generateNonce(next).catch(function() {});
14390
14512
  }
14391
14513
  },
14514
+ {
14515
+ key: "currentPpid",
14516
+ value: function currentPpid() {
14517
+ var userId = resolveUserId(this.config.adUserId);
14518
+ noteStayId(userId);
14519
+ var signals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
14520
+ fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
14521
+ sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
14522
+ });
14523
+ return toPpid(userId, signals.limitAdTracking);
14524
+ }
14525
+ },
14392
14526
  {
14393
14527
  key: "setAdIdentity",
14394
14528
  value: function setAdIdentity(identity) {
@@ -14420,6 +14554,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
14420
14554
  if (signals.ipAddress) this.config.clientIpAddress = signals.ipAddress;
14421
14555
  else delete this.config.clientIpAddress;
14422
14556
  }
14557
+ if (signals.userId !== void 0) this.refreshPalNonceIfStale();
14423
14558
  }
14424
14559
  },
14425
14560
  {