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
@@ -26,6 +26,7 @@ declare class StormcloudVideoPlayer {
26
26
  private edgePodBaseUrl;
27
27
  private lastPalOptions;
28
28
  private palSessionId;
29
+ private palPpid;
29
30
  private palRefreshTimer;
30
31
  constructor(config: StormcloudVideoPlayerConfig);
31
32
  private get debug();
@@ -42,6 +43,7 @@ declare class StormcloudVideoPlayer {
42
43
  load(): Promise<void>;
43
44
  private startPalNonceRefresh;
44
45
  private refreshPalNonceIfStale;
46
+ private currentPpid;
45
47
  setAdIdentity(identity: HostAdIdentity | null): void;
46
48
  resetAdIdentity(): void;
47
49
  setContentMetadata(meta: ContentMetadataUpdate): void;
@@ -431,6 +431,9 @@ var DEFAULT_LGUDID_TIMEOUT_MS = 1500;
431
431
  var FALLBACK_DEVICE_ID_KEY = "stormcloud.ad.dpid.v2";
432
432
  var SESSION_ID_KEY = "stormcloud.ad.sid.v2";
433
433
  var LEGACY_SESSION_KEY = "stormcloud.ctv.sid";
434
+ var STAY_ID_KEY = "stormcloud.ad.stay.v1";
435
+ var HOST_ID_KEY = "stormcloud.ad.host.v1";
436
+ var memoryMarkers = {};
434
437
  var ZEROED_IDS = /* @__PURE__ */ new Set([
435
438
  "00000000-0000-0000-0000-000000000000",
436
439
  "38400000-8cf0-11bd-b23e-10b96e40000d"
@@ -533,7 +536,7 @@ function setHostAdIdentity(identity) {
533
536
  return;
534
537
  }
535
538
  var deviceId = identity.deviceId.trim();
536
- var changed = !hostIdentity || hostIdentity.deviceId !== deviceId;
539
+ var changed = writeMarkerIfChanged(HOST_ID_KEY, deviceId);
537
540
  hostIdentity = _object_spread({
538
541
  deviceId: deviceId,
539
542
  deviceIdType: (_normalizeIdType = normalizeIdType(identity.deviceIdType)) !== null && _normalizeIdType !== void 0 ? _normalizeIdType : "dpid"
@@ -552,6 +555,31 @@ function resetAdIdentity() {
552
555
  removeStored(SESSION_ID_KEY);
553
556
  removeStored(FALLBACK_DEVICE_ID_KEY);
554
557
  }
558
+ function writeMarkerIfChanged(key, value) {
559
+ var _memoryMarkers_key;
560
+ var previous = (_memoryMarkers_key = memoryMarkers[key]) !== null && _memoryMarkers_key !== void 0 ? _memoryMarkers_key : "";
561
+ try {
562
+ var _window_localStorage;
563
+ var stored = typeof window !== "undefined" ? (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key) : null;
564
+ if (typeof stored === "string") previous = stored;
565
+ } catch (unused) {}
566
+ if (value === previous) return false;
567
+ memoryMarkers[key] = value;
568
+ try {
569
+ if (typeof window !== "undefined") {
570
+ var _window_localStorage1, _window_localStorage2;
571
+ if (value) (_window_localStorage1 = window.localStorage) === null || _window_localStorage1 === void 0 ? void 0 : _window_localStorage1.setItem(key, value);
572
+ else (_window_localStorage2 = window.localStorage) === null || _window_localStorage2 === void 0 ? void 0 : _window_localStorage2.removeItem(key);
573
+ }
574
+ } catch (unused) {}
575
+ return true;
576
+ }
577
+ function noteStayId(stayId) {
578
+ if (!writeMarkerIfChanged(STAY_ID_KEY, stayId ? stayId.trim() : "")) return false;
579
+ removeStored(SESSION_ID_KEY);
580
+ removeStored(FALLBACK_DEVICE_ID_KEY);
581
+ return true;
582
+ }
555
583
  function readSamsungTifa() {
556
584
  try {
557
585
  var _window_webapis;
@@ -1338,7 +1366,9 @@ var BRIDGE_KEYS = {
1338
1366
  ],
1339
1367
  contentRating: [
1340
1368
  "contentRating",
1341
- "ctr"
1369
+ "ctr",
1370
+ "programRating",
1371
+ "rating"
1342
1372
  ],
1343
1373
  contentId: [
1344
1374
  "contentId",
@@ -1350,7 +1380,9 @@ function sanitizeContentValue(value) {
1350
1380
  var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1351
1381
  if (!cleaned) return void 0;
1352
1382
  if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
1353
- if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
1383
+ if (/^(unknown|null|undefined|none|n\/a|-|tbd|tba|to be (announced|determined))$/i.test(cleaned)) {
1384
+ return void 0;
1385
+ }
1354
1386
  return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
1355
1387
  }
1356
1388
  function sanitizeContentScalar(value) {
@@ -1476,6 +1508,7 @@ function resolveContentMetadata(config) {
1476
1508
  } : {});
1477
1509
  }
1478
1510
  function applyContentMetadataUpdate(target, meta) {
1511
+ var _target_contentDetails;
1479
1512
  var apply = function apply(key, value) {
1480
1513
  if (value === void 0) return;
1481
1514
  var clean = value === null ? void 0 : sanitizeContentValue(value);
@@ -1485,9 +1518,15 @@ function applyContentMetadataUpdate(target, meta) {
1485
1518
  apply("channelName", meta.channelName);
1486
1519
  apply("programTitle", meta.programTitle);
1487
1520
  apply("contentNetwork", meta.contentNetwork);
1488
- if (meta.details === void 0) return;
1489
1521
  if (meta.details === null) delete target.contentDetails;
1490
- else target.contentDetails = _object_spread({}, meta.details);
1522
+ else if (meta.details !== void 0) target.contentDetails = _object_spread({}, meta.details);
1523
+ var rating = meta.programRating !== void 0 ? meta.programRating : meta.contentRating;
1524
+ if (rating === void 0) return;
1525
+ var cleanRating = rating === null ? void 0 : sanitizeContentValue(rating);
1526
+ var details = _object_spread({}, (_target_contentDetails = target.contentDetails) !== null && _target_contentDetails !== void 0 ? _target_contentDetails : {});
1527
+ if (cleanRating) details.rating = cleanRating;
1528
+ else delete details.rating;
1529
+ target.contentDetails = details;
1491
1530
  }
1492
1531
  function appendMissingContentParams(url, meta) {
1493
1532
  if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
@@ -1580,6 +1619,11 @@ function sanitizePublicIp(value) {
1580
1619
  if (cleaned.includes(".")) return isPublicIpv4(cleaned) ? cleaned : void 0;
1581
1620
  return isPublicIpv6(cleaned) ? cleaned : void 0;
1582
1621
  }
1622
+ var PPID_PATTERN = /^[0-9a-zA-Z+.=\/_\-$,{}]{22,150}$/;
1623
+ function toPpid(userId, limitAdTracking) {
1624
+ if (!userId || limitAdTracking === true) return void 0;
1625
+ return PPID_PATTERN.test(userId) ? userId : void 0;
1626
+ }
1583
1627
  function resolveUserId(configValue) {
1584
1628
  var _sanitizeUserId;
1585
1629
  return (_sanitizeUserId = sanitizeUserId(configValue)) !== null && _sanitizeUserId !== void 0 ? _sanitizeUserId : readBridgeValue2([
@@ -1988,6 +2032,7 @@ function resolveScvpMacroValues(ctx) {
1988
2032
  set("UA", ctx.userAgent);
1989
2033
  set("IP", ctx.ipAddress);
1990
2034
  set("UID", ctx.userId);
2035
+ set("PPID", ctx.ppid);
1991
2036
  set("CT-TYPE", ctx.contentType);
1992
2037
  set("CT-CATEGORY", ctx.contentCategory);
1993
2038
  set("CT-GENRE", ctx.contentGenre);
@@ -2883,9 +2928,30 @@ function detectBrowser() {
2883
2928
  };
2884
2929
  }
2885
2930
  var singleDecoderOverride;
2931
+ var LEARNED_SINGLE_DECODER_KEY = "stormcloud.singleDecoder.learned.v1";
2932
+ var learnedSingleDecoder;
2886
2933
  function setSingleDecoderOverride(value) {
2887
2934
  singleDecoderOverride = value;
2888
2935
  }
2936
+ function readLearnedSingleDecoder() {
2937
+ if (learnedSingleDecoder !== void 0) return learnedSingleDecoder;
2938
+ try {
2939
+ var _window_localStorage;
2940
+ learnedSingleDecoder = typeof window !== "undefined" && ((_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(LEARNED_SINGLE_DECODER_KEY)) === "1";
2941
+ } catch (unused) {
2942
+ learnedSingleDecoder = false;
2943
+ }
2944
+ return learnedSingleDecoder;
2945
+ }
2946
+ function markSingleDecoderLearned() {
2947
+ if (readLearnedSingleDecoder()) return false;
2948
+ learnedSingleDecoder = true;
2949
+ try {
2950
+ var _window_localStorage;
2951
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(LEARNED_SINGLE_DECODER_KEY, "1");
2952
+ } catch (unused) {}
2953
+ return true;
2954
+ }
2889
2955
  function requiresMediaPipelineResetAfterAds() {
2890
2956
  var _browser_tizenVersion;
2891
2957
  if (singleDecoderOverride != null) return singleDecoderOverride;
@@ -2893,6 +2959,7 @@ function requiresMediaPipelineResetAfterAds() {
2893
2959
  var globalOverride = typeof window !== "undefined" ? window.__STORMCLOUD_SINGLE_DECODER__ : void 0;
2894
2960
  if (typeof globalOverride === "boolean") return globalOverride;
2895
2961
  } catch (unused) {}
2962
+ if (readLearnedSingleDecoder()) return true;
2896
2963
  var browser = detectBrowser();
2897
2964
  return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
2898
2965
  }
@@ -9566,6 +9633,8 @@ var AdConfigManager = /*#__PURE__*/ function() {
9566
9633
  value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
9567
9634
  var _content_contentDurationSeconds;
9568
9635
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
9636
+ var stayUserId = resolveUserId(this.config.adUserId);
9637
+ noteStayId(stayUserId);
9569
9638
  var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
9570
9639
  fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
9571
9640
  sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
@@ -9576,7 +9645,8 @@ var AdConfigManager = /*#__PURE__*/ function() {
9576
9645
  var playerSize = resolvePlayerSize(this.video);
9577
9646
  var videoDuration = this.video.duration;
9578
9647
  var contentDurationSeconds = (_content_contentDurationSeconds = content.contentDurationSeconds) !== null && _content_contentDurationSeconds !== void 0 ? _content_contentDurationSeconds : !isLive && Number.isFinite(videoDuration) && videoDuration > 0 ? Math.round(videoDuration) : void 0;
9579
- var userId = resolveUserId(this.config.adUserId);
9648
+ var userId = envSignals.limitAdTracking === true ? void 0 : stayUserId;
9649
+ var ppid = toPpid(stayUserId, envSignals.limitAdTracking);
9580
9650
  var ipAddress = resolveClientIp(this.config.clientIpAddress);
9581
9651
  var userAgent2 = typeof navigator !== "undefined" && navigator.userAgent ? navigator.userAgent : void 0;
9582
9652
  var macroContext = _object_spread(_object_spread_props(_object_spread(_object_spread_props(_object_spread({
@@ -9622,6 +9692,8 @@ var AdConfigManager = /*#__PURE__*/ function() {
9622
9692
  ipAddress: ipAddress
9623
9693
  } : {}, userId ? {
9624
9694
  userId: userId
9695
+ } : {}, ppid ? {
9696
+ ppid: ppid
9625
9697
  } : {}, content.contentType ? {
9626
9698
  contentType: content.contentType
9627
9699
  } : {}, content.contentCategory ? {
@@ -9669,9 +9741,11 @@ var AdConfigManager = /*#__PURE__*/ function() {
9669
9741
  isLat: envSignals.limitAdTracking,
9670
9742
  dth: envSignals.deviceTypeHint,
9671
9743
  sidTail: envSignals.sessionId ? envSignals.sessionId.slice(-4) : void 0,
9744
+ ppidTail: ppid ? ppid.slice(-4) : void 0,
9672
9745
  ct_ch: content.channelName,
9673
9746
  ct_ti: content.programTitle,
9674
9747
  ct_ne: content.contentNetwork,
9748
+ rating: content.contentRating,
9675
9749
  ifaType: toIabIfaType(envSignals.deviceIdType, envSignals.deviceIdSource),
9676
9750
  live: isLive,
9677
9751
  player: playerSize,
@@ -11355,6 +11429,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11355
11429
  this.adDetectSentForCurrentBreak = false;
11356
11430
  this.slotState = "IDLE";
11357
11431
  this.unusableResponsesInBreak = 0;
11432
+ this.playedAdIdsInBreak = /* @__PURE__ */ new Set();
11358
11433
  this.controllerGeneration = 0;
11359
11434
  this.requestDiagnostics = /* @__PURE__ */ new Map();
11360
11435
  this.breakFunnel = {};
@@ -11451,6 +11526,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11451
11526
  _this.recordRequestDiagnostic(payload);
11452
11527
  });
11453
11528
  adPlayer.on("ad_impression", function() {
11529
+ var _this_host_getAdPlayer_getLoadedAdId, _this_host_getAdPlayer;
11530
+ 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);
11531
+ if (impressionAdId != null && impressionAdId !== "") {
11532
+ _this.playedAdIdsInBreak.add(String(impressionAdId));
11533
+ }
11454
11534
  _this.timing.consecutiveFailures = 0;
11455
11535
  _this.setSlotState("PLAYING", "impression");
11456
11536
  if (!_this.playbackStartedForCurrentRequest) {
@@ -11642,6 +11722,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11642
11722
  this.resetEdgeStateForBreak();
11643
11723
  this.followUpBaseVastUrl = void 0;
11644
11724
  this.unusableResponsesInBreak = 0;
11725
+ this.playedAdIdsInBreak.clear();
11645
11726
  this.timing.totalAdRequestsInBreak = 0;
11646
11727
  this.setSlotState("NEEDS_NEXT_AD", "vmap_break_start");
11647
11728
  this.noteOpportunity("vmap", breakKey, position);
@@ -11692,6 +11773,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11692
11773
  this.breakSource = "scte35";
11693
11774
  this.followUpBaseVastUrl = baseVastUrl;
11694
11775
  this.unusableResponsesInBreak = 0;
11776
+ this.playedAdIdsInBreak.clear();
11695
11777
  this.resetEdgeStateForBreak();
11696
11778
  this.setSlotState("NEEDS_NEXT_AD", "scte35_break_start");
11697
11779
  if (this.adConfig.podAssignedByPrefetch) {
@@ -12531,6 +12613,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12531
12613
  var outcome;
12532
12614
  if (message.includes("ad_duration_exceeds_budget")) {
12533
12615
  outcome = "discarded_budget";
12616
+ } else if (message.includes("ad_repeated_in_break")) {
12617
+ outcome = "discarded_duplicate";
12534
12618
  } else if (message.includes("VAST fill rejected")) {
12535
12619
  outcome = "fill_rejected";
12536
12620
  } else if (/no ads available|no fill|nofill/i.test(message)) {
@@ -12545,7 +12629,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12545
12629
  outcome = "request_failed";
12546
12630
  }
12547
12631
  this.timing.consecutiveFailures++;
12548
- if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget") {
12632
+ if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget" || outcome === "discarded_duplicate") {
12549
12633
  this.unusableResponsesInBreak++;
12550
12634
  }
12551
12635
  if (outcome === "no_fill") {
@@ -12559,7 +12643,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12559
12643
  }) ? diag.dispatchedUrl : vastTagUrl;
12560
12644
  if (this.timing.isTemporaryAdError(error)) {
12561
12645
  this.timing.temporaryFailureUrls.set(failureKey, Date.now());
12562
- } else if (outcome !== "discarded_budget") {
12646
+ } else if (outcome !== "discarded_budget" && outcome !== "discarded_duplicate") {
12563
12647
  this.timing.failedVastUrls.add(failureKey);
12564
12648
  }
12565
12649
  this.countFunnelStage("request_outcome:".concat(outcome));
@@ -12931,7 +13015,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12931
13015
  value: function playSingleAd(vastTagUrl) {
12932
13016
  var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
12933
13017
  return _async_to_generator(function() {
12934
- var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, finalizeRequestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
13018
+ var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, _ref, _ap_getLoadedAdId, _ap_getPodAdCount, finalizeRequestUrl, loadedAdId, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
12935
13019
  return _ts_generator(this, function(_state) {
12936
13020
  switch(_state.label){
12937
13021
  case 0:
@@ -13044,6 +13128,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13044
13128
  vastUrl: (_this_currentVastUrl = this.currentVastUrl) !== null && _this_currentVastUrl !== void 0 ? _this_currentVastUrl : requestUrl,
13045
13129
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
13046
13130
  }, this.analyticsContext).catch(function() {});
13131
+ loadedAdId = (_ap_getLoadedAdId = ap.getLoadedAdId) === null || _ap_getLoadedAdId === void 0 ? void 0 : _ap_getLoadedAdId.call(ap);
13132
+ 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))) {
13133
+ if (this.debug) {
13134
+ console.log("[AD-DURATION] Rejected ad id=".concat(loadedAdId, ": already played in this break — requesting another ad"));
13135
+ }
13136
+ this.logOrchestratorFunnel("discarded_duplicate", {
13137
+ adId: String(loadedAdId)
13138
+ });
13139
+ throw new Error("ad_repeated_in_break");
13140
+ }
13047
13141
  if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
13048
13142
  ;
13049
13143
  adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
@@ -13097,6 +13191,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13097
13191
  this.recordRequestFailure(error, vastTagUrl);
13098
13192
  if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
13099
13193
  this.recreateAdController("discarded_budget");
13194
+ } else if ((error === null || error === void 0 ? void 0 : error.message) === "ad_repeated_in_break") {
13195
+ this.recreateAdController("discarded_duplicate");
13100
13196
  }
13101
13197
  throw error;
13102
13198
  case 10:
@@ -13170,6 +13266,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13170
13266
  tagAllowsAudio: count("tag_allows_audio"),
13171
13267
  missingImpression: count("vast_missing_impression"),
13172
13268
  discardedBudget: count("discarded_budget"),
13269
+ discardedDuplicate: count("discarded_duplicate"),
13173
13270
  mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
13174
13271
  mediaRejected: count("media_candidate:rejected"),
13175
13272
  mediaFallbacks: count("media_fallback"),
@@ -13245,6 +13342,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13245
13342
  this.breakSource = void 0;
13246
13343
  this.followUpBaseVastUrl = void 0;
13247
13344
  this.unusableResponsesInBreak = 0;
13345
+ this.playedAdIdsInBreak.clear();
13248
13346
  this.resetEdgeStateForBreak();
13249
13347
  adPlayer.stop().catch(function() {});
13250
13348
  if (!alreadyEnded) this.logBreakFunnel(reason);
@@ -13345,9 +13443,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13345
13443
  var maxMonitorMs = 45e3;
13346
13444
  var startTime = Date.now();
13347
13445
  var baseline = resumeBaseline;
13446
+ var lastSeenTime = resumeBaseline;
13348
13447
  var recoveries = 0;
13349
13448
  var lastRecoveryAt = 0;
13350
13449
  var video = this.host.video;
13450
+ var onDecodeError = function onDecodeError() {
13451
+ var _video_error;
13452
+ if (needsReset || ((_video_error = video.error) === null || _video_error === void 0 ? void 0 : _video_error.code) !== 3) return;
13453
+ if (markSingleDecoderLearned() && _this.debug) {
13454
+ console.warn("[StormcloudVideoPlayer] Decoder error while resuming after ads \u2014 using single-decoder mode on this device from the next break");
13455
+ }
13456
+ };
13457
+ video.addEventListener("error", onDecodeError);
13351
13458
  var listenersAttached = false;
13352
13459
  var onMediaEvent;
13353
13460
  var diagEvents = [
@@ -13397,6 +13504,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13397
13504
  console.log("[ResumeDiag] +0.0s monitor start — ".concat(this.describeVideoState()));
13398
13505
  }
13399
13506
  var cleanup = function cleanup() {
13507
+ video.removeEventListener("error", onDecodeError);
13400
13508
  if (listenersAttached && onMediaEvent) {
13401
13509
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
13402
13510
  try {
@@ -13427,6 +13535,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13427
13535
  return;
13428
13536
  }
13429
13537
  var currentTime = video.currentTime;
13538
+ if (currentTime + 1 < lastSeenTime) {
13539
+ baseline = currentTime;
13540
+ }
13541
+ lastSeenTime = currentTime;
13430
13542
  var advanced = currentTime > baseline + 0.5;
13431
13543
  var playing = !video.paused && video.readyState >= 3;
13432
13544
  if (advanced && playing) {
@@ -14097,6 +14209,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
14097
14209
  var _this_config_palContinuousPlayback, _this_config_lowLatencyMode, _this_config_palIconsSupported, _this_config_palSupportedApiFrameworks;
14098
14210
  _this.adConfig.consentSignals = signals;
14099
14211
  var muted = _this.video.muted;
14212
+ var palPpid = _this.currentPpid();
14100
14213
  var palSessionId = _this.config.ctvAdRequest ? getOrRotateSessionId(_this.config.sessionIdMaxAgeMs) : void 0;
14101
14214
  var palOptions = _object_spread({
14102
14215
  videoWidth: _this.video.offsetWidth || _this.video.clientWidth || 640,
@@ -14113,9 +14226,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
14113
14226
  allowStorage: signals.storageAllowed
14114
14227
  } : {}, palSessionId ? {
14115
14228
  sessionId: palSessionId
14229
+ } : {}, palPpid ? {
14230
+ ppid: palPpid
14116
14231
  } : {});
14117
14232
  _this.lastPalOptions = palOptions;
14118
14233
  _this.palSessionId = palSessionId;
14234
+ _this.palPpid = palPpid;
14119
14235
  _this.startPalNonceRefresh();
14120
14236
  return _this.palNonce.generateNonce(palOptions);
14121
14237
  }).catch(function() {});
@@ -14174,26 +14290,44 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
14174
14290
  if (!options) return;
14175
14291
  var maxAgeMs = (_this_config_palNonceMaxAgeMs = this.config.palNonceMaxAgeMs) !== null && _this_config_palNonceMaxAgeMs !== void 0 ? _this_config_palNonceMaxAgeMs : DEFAULT_PAL_NONCE_MAX_AGE_MS;
14176
14292
  var ageMs = this.palNonce.getNonceAgeMs();
14293
+ var ppid = this.currentPpid();
14294
+ var ppidChanged = ppid !== this.palPpid;
14177
14295
  var sessionId = this.config.ctvAdRequest ? getOrRotateSessionId(this.config.sessionIdMaxAgeMs) : void 0;
14178
14296
  var sessionChanged = sessionId !== this.palSessionId;
14179
14297
  var stale = ageMs === void 0 || ageMs >= maxAgeMs;
14180
- if (!force && !stale && !sessionChanged) return;
14298
+ if (!force && !stale && !sessionChanged && !ppidChanged) return;
14181
14299
  var next = _object_spread({}, options);
14182
14300
  if (sessionId) next.sessionId = sessionId;
14183
14301
  else delete next.sessionId;
14302
+ if (ppid) next.ppid = ppid;
14303
+ else delete next.ppid;
14184
14304
  this.lastPalOptions = next;
14185
14305
  this.palSessionId = sessionId;
14306
+ this.palPpid = ppid;
14186
14307
  if (this.debug) {
14187
14308
  console.log("[PAL] Regenerating nonce", {
14188
14309
  force: force,
14189
14310
  stale: stale,
14190
14311
  sessionChanged: sessionChanged,
14312
+ ppidChanged: ppidChanged,
14191
14313
  ageMs: ageMs
14192
14314
  });
14193
14315
  }
14194
14316
  this.palNonce.generateNonce(next).catch(function() {});
14195
14317
  }
14196
14318
  },
14319
+ {
14320
+ key: "currentPpid",
14321
+ value: function currentPpid() {
14322
+ var userId = resolveUserId(this.config.adUserId);
14323
+ noteStayId(userId);
14324
+ var signals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
14325
+ fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
14326
+ sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
14327
+ });
14328
+ return toPpid(userId, signals.limitAdTracking);
14329
+ }
14330
+ },
14197
14331
  {
14198
14332
  key: "setAdIdentity",
14199
14333
  value: function setAdIdentity(identity) {
@@ -14225,6 +14359,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
14225
14359
  if (signals.ipAddress) this.config.clientIpAddress = signals.ipAddress;
14226
14360
  else delete this.config.clientIpAddress;
14227
14361
  }
14362
+ if (signals.userId !== void 0) this.refreshPalNonceIfStale();
14228
14363
  }
14229
14364
  },
14230
14365
  {