stormcloud-video-player 0.8.80 → 0.8.82

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 (64) hide show
  1. package/dist/stormcloud-vp.min.js +2 -2
  2. package/lib/Player.d.cts +1 -0
  3. package/lib/StormcloudPlayer.cjs +527 -142
  4. package/lib/StormcloudPlayer.cjs.map +1 -1
  5. package/lib/StormcloudPlayer.d.cts +1 -0
  6. package/lib/index.cjs +553 -143
  7. package/lib/index.cjs.map +1 -1
  8. package/lib/index.d.cts +1 -0
  9. package/lib/index.d.ts +33 -5
  10. package/lib/index.js +553 -143
  11. package/lib/index.js.map +1 -1
  12. package/lib/player/AdBreakOrchestrator.cjs +100 -12
  13. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  14. package/lib/player/AdBreakOrchestrator.d.cts +2 -0
  15. package/lib/player/AdConfigManager.cjs +413 -123
  16. package/lib/player/AdConfigManager.cjs.map +1 -1
  17. package/lib/player/AdConfigManager.d.cts +2 -0
  18. package/lib/player/AdTimingService.d.cts +1 -0
  19. package/lib/player/EdgePodRequest.d.cts +1 -0
  20. package/lib/player/FloorLadder.d.cts +1 -0
  21. package/lib/player/HlsEngine.d.cts +1 -0
  22. package/lib/player/OptimizedPodRequest.cjs +17 -5
  23. package/lib/player/OptimizedPodRequest.cjs.map +1 -1
  24. package/lib/player/PlayerControls.d.cts +1 -0
  25. package/lib/player/Scte35CueManager.d.cts +1 -0
  26. package/lib/player/Scte35Parser.d.cts +1 -0
  27. package/lib/player/StormcloudVideoPlayer.cjs +527 -142
  28. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  29. package/lib/player/StormcloudVideoPlayer.d.cts +5 -4
  30. package/lib/player/playerTypes.d.cts +1 -0
  31. package/lib/players/HlsPlayer.cjs +527 -142
  32. package/lib/players/HlsPlayer.cjs.map +1 -1
  33. package/lib/players/HlsPlayer.d.cts +1 -0
  34. package/lib/players/index.cjs +527 -142
  35. package/lib/players/index.cjs.map +1 -1
  36. package/lib/props.d.cts +1 -0
  37. package/lib/sdk/hlsAdPlayer.cjs +13 -0
  38. package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
  39. package/lib/sdk/hlsAdPlayer.d.cts +1 -0
  40. package/lib/types.d.cts +8 -1
  41. package/lib/ui/StormcloudVideoPlayer.cjs +553 -143
  42. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  43. package/lib/ui/StormcloudVideoPlayer.d.cts +1 -0
  44. package/lib/utils/__tests__/adSignals.test.cjs +174 -15
  45. package/lib/utils/__tests__/adSignals.test.cjs.map +1 -1
  46. package/lib/utils/browserCompat.cjs +33 -0
  47. package/lib/utils/browserCompat.cjs.map +1 -1
  48. package/lib/utils/browserCompat.d.cts +3 -1
  49. package/lib/utils/contentMetadata.cjs +132 -5
  50. package/lib/utils/contentMetadata.cjs.map +1 -1
  51. package/lib/utils/contentMetadata.d.cts +39 -1
  52. package/lib/utils/deviceInfo.cjs +24 -4
  53. package/lib/utils/deviceInfo.cjs.map +1 -1
  54. package/lib/utils/deviceInfo.d.cts +3 -0
  55. package/lib/utils/partnerSignals.cjs +296 -0
  56. package/lib/utils/partnerSignals.cjs.map +1 -0
  57. package/lib/utils/partnerSignals.d.cts +12 -0
  58. package/lib/utils/tracking.cjs +24 -4
  59. package/lib/utils/tracking.cjs.map +1 -1
  60. package/lib/utils/tracking.d.cts +1 -0
  61. package/lib/utils/vastMacros.cjs +51 -1
  62. package/lib/utils/vastMacros.cjs.map +1 -1
  63. package/lib/utils/vastMacros.d.cts +20 -0
  64. package/package.json +1 -1
@@ -1296,6 +1296,319 @@ function normalizeBoolean(value) {
1296
1296
  }
1297
1297
  return void 0;
1298
1298
  }
1299
+ // src/utils/contentMetadata.ts
1300
+ var MAX_CONTENT_VALUE_LENGTH = 128;
1301
+ var BRIDGE_KEYS = {
1302
+ channelName: [
1303
+ "channelName",
1304
+ "ct_ch"
1305
+ ],
1306
+ programTitle: [
1307
+ "programTitle",
1308
+ "ct_ti"
1309
+ ],
1310
+ contentNetwork: [
1311
+ "contentNetwork",
1312
+ "ct_ne"
1313
+ ],
1314
+ contentType: [
1315
+ "contentType",
1316
+ "ctt"
1317
+ ],
1318
+ contentCategory: [
1319
+ "contentCategory",
1320
+ "ctc"
1321
+ ],
1322
+ contentGenre: [
1323
+ "contentGenre",
1324
+ "ctgr"
1325
+ ],
1326
+ contentLanguage: [
1327
+ "contentLanguage",
1328
+ "ctlg"
1329
+ ],
1330
+ contentDuration: [
1331
+ "contentDuration",
1332
+ "ctd"
1333
+ ],
1334
+ contentSeason: [
1335
+ "contentSeason",
1336
+ "cts"
1337
+ ],
1338
+ contentEpisode: [
1339
+ "contentEpisode",
1340
+ "cte"
1341
+ ],
1342
+ contentRating: [
1343
+ "contentRating",
1344
+ "ctr",
1345
+ "programRating",
1346
+ "rating"
1347
+ ],
1348
+ contentId: [
1349
+ "contentId",
1350
+ "ctid"
1351
+ ]
1352
+ };
1353
+ function sanitizeContentValue(value) {
1354
+ if (typeof value !== "string") return void 0;
1355
+ var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1356
+ if (!cleaned) return void 0;
1357
+ if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
1358
+ if (/^(unknown|null|undefined|none|n\/a|-|tbd|tba|to be (announced|determined))$/i.test(cleaned)) {
1359
+ return void 0;
1360
+ }
1361
+ return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
1362
+ }
1363
+ function sanitizeContentScalar(value) {
1364
+ if (typeof value === "number") {
1365
+ return Number.isFinite(value) ? String(value) : void 0;
1366
+ }
1367
+ return sanitizeContentValue(value);
1368
+ }
1369
+ function normalizeContentLanguage(value) {
1370
+ var cleaned = sanitizeContentValue(value);
1371
+ if (!cleaned) return void 0;
1372
+ var match = cleaned.match(/^([A-Za-z]{2})(?:[-_][A-Za-z0-9]{1,8})*$/);
1373
+ return match && match[1] ? match[1].toLowerCase() : void 0;
1374
+ }
1375
+ function normalizeContentDuration(value) {
1376
+ var raw = sanitizeContentScalar(value);
1377
+ if (raw == null || !/^-?\d+(\.\d+)?$/.test(raw)) return void 0;
1378
+ var seconds = Number(raw);
1379
+ if (seconds === -1) return -1;
1380
+ return seconds > 0 ? Math.round(seconds) : void 0;
1381
+ }
1382
+ function bridgeSources() {
1383
+ if (typeof window === "undefined") return [];
1384
+ var w = window;
1385
+ return [
1386
+ w.__STORMCLOUD_CTV__,
1387
+ w.__STORMCLOUD_CTV_AD_INFO__,
1388
+ w.stormcloudCtv
1389
+ ].filter(Boolean);
1390
+ }
1391
+ function readBridgeValue2(keys, sanitize) {
1392
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1393
+ try {
1394
+ for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1395
+ var source = _step.value;
1396
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
1397
+ try {
1398
+ for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
1399
+ var key = _step1.value;
1400
+ var value = void 0;
1401
+ try {
1402
+ value = source === null || source === void 0 ? void 0 : source[key];
1403
+ if (typeof value === "function") value = value.call(source);
1404
+ } catch (unused) {
1405
+ value = void 0;
1406
+ }
1407
+ var sanitized = sanitize(value);
1408
+ if (sanitized != null) return sanitized;
1409
+ }
1410
+ } catch (err) {
1411
+ _didIteratorError1 = true;
1412
+ _iteratorError1 = err;
1413
+ } finally{
1414
+ try {
1415
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
1416
+ _iterator1.return();
1417
+ }
1418
+ } finally{
1419
+ if (_didIteratorError1) {
1420
+ throw _iteratorError1;
1421
+ }
1422
+ }
1423
+ }
1424
+ }
1425
+ } catch (err) {
1426
+ _didIteratorError = true;
1427
+ _iteratorError = err;
1428
+ } finally{
1429
+ try {
1430
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1431
+ _iterator.return();
1432
+ }
1433
+ } finally{
1434
+ if (_didIteratorError) {
1435
+ throw _iteratorError;
1436
+ }
1437
+ }
1438
+ }
1439
+ return void 0;
1440
+ }
1441
+ function readBridgeContentValue(keys) {
1442
+ return readBridgeValue2(keys, sanitizeContentValue);
1443
+ }
1444
+ function resolveContentMetadata(config) {
1445
+ var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2, _config_contentDetails, _sanitizeContentValue3, _sanitizeContentValue4, _sanitizeContentValue5, _normalizeContentLanguage, _normalizeContentDuration, _sanitizeContentScalar, _sanitizeContentScalar1, _sanitizeContentValue6, _sanitizeContentValue7;
1446
+ var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
1447
+ var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
1448
+ var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
1449
+ var details = (_config_contentDetails = config.contentDetails) !== null && _config_contentDetails !== void 0 ? _config_contentDetails : {};
1450
+ var contentType = (_sanitizeContentValue3 = sanitizeContentValue(details.contentType)) !== null && _sanitizeContentValue3 !== void 0 ? _sanitizeContentValue3 : readBridgeContentValue(BRIDGE_KEYS.contentType);
1451
+ var contentCategory = (_sanitizeContentValue4 = sanitizeContentValue(details.category)) !== null && _sanitizeContentValue4 !== void 0 ? _sanitizeContentValue4 : readBridgeContentValue(BRIDGE_KEYS.contentCategory);
1452
+ var contentGenre = (_sanitizeContentValue5 = sanitizeContentValue(details.genre)) !== null && _sanitizeContentValue5 !== void 0 ? _sanitizeContentValue5 : readBridgeContentValue(BRIDGE_KEYS.contentGenre);
1453
+ var contentLanguage = (_normalizeContentLanguage = normalizeContentLanguage(details.language)) !== null && _normalizeContentLanguage !== void 0 ? _normalizeContentLanguage : readBridgeValue2(BRIDGE_KEYS.contentLanguage, normalizeContentLanguage);
1454
+ var contentDurationSeconds = (_normalizeContentDuration = normalizeContentDuration(details.durationSeconds)) !== null && _normalizeContentDuration !== void 0 ? _normalizeContentDuration : readBridgeValue2(BRIDGE_KEYS.contentDuration, normalizeContentDuration);
1455
+ var contentSeason = (_sanitizeContentScalar = sanitizeContentScalar(details.season)) !== null && _sanitizeContentScalar !== void 0 ? _sanitizeContentScalar : readBridgeValue2(BRIDGE_KEYS.contentSeason, sanitizeContentScalar);
1456
+ var contentEpisode = (_sanitizeContentScalar1 = sanitizeContentScalar(details.episode)) !== null && _sanitizeContentScalar1 !== void 0 ? _sanitizeContentScalar1 : readBridgeValue2(BRIDGE_KEYS.contentEpisode, sanitizeContentScalar);
1457
+ var contentRating = (_sanitizeContentValue6 = sanitizeContentValue(details.rating)) !== null && _sanitizeContentValue6 !== void 0 ? _sanitizeContentValue6 : readBridgeContentValue(BRIDGE_KEYS.contentRating);
1458
+ var contentId = (_sanitizeContentValue7 = sanitizeContentValue(details.contentId)) !== null && _sanitizeContentValue7 !== void 0 ? _sanitizeContentValue7 : readBridgeContentValue(BRIDGE_KEYS.contentId);
1459
+ return _object_spread({}, channelName ? {
1460
+ channelName: channelName
1461
+ } : {}, programTitle ? {
1462
+ programTitle: programTitle
1463
+ } : {}, contentNetwork ? {
1464
+ contentNetwork: contentNetwork
1465
+ } : {}, contentType ? {
1466
+ contentType: contentType
1467
+ } : {}, contentCategory ? {
1468
+ contentCategory: contentCategory
1469
+ } : {}, contentGenre ? {
1470
+ contentGenre: contentGenre
1471
+ } : {}, contentLanguage ? {
1472
+ contentLanguage: contentLanguage
1473
+ } : {}, contentDurationSeconds != null ? {
1474
+ contentDurationSeconds: contentDurationSeconds
1475
+ } : {}, contentSeason ? {
1476
+ contentSeason: contentSeason
1477
+ } : {}, contentEpisode ? {
1478
+ contentEpisode: contentEpisode
1479
+ } : {}, contentRating ? {
1480
+ contentRating: contentRating
1481
+ } : {}, contentId ? {
1482
+ contentId: contentId
1483
+ } : {});
1484
+ }
1485
+ function applyContentMetadataUpdate(target, meta) {
1486
+ var _target_contentDetails;
1487
+ var apply = function apply(key, value) {
1488
+ if (value === void 0) return;
1489
+ var clean = value === null ? void 0 : sanitizeContentValue(value);
1490
+ if (clean) target[key] = clean;
1491
+ else delete target[key];
1492
+ };
1493
+ apply("channelName", meta.channelName);
1494
+ apply("programTitle", meta.programTitle);
1495
+ apply("contentNetwork", meta.contentNetwork);
1496
+ if (meta.details === null) delete target.contentDetails;
1497
+ else if (meta.details !== void 0) target.contentDetails = _object_spread({}, meta.details);
1498
+ var rating = meta.programRating !== void 0 ? meta.programRating : meta.contentRating;
1499
+ if (rating === void 0) return;
1500
+ var cleanRating = rating === null ? void 0 : sanitizeContentValue(rating);
1501
+ var details = _object_spread({}, (_target_contentDetails = target.contentDetails) !== null && _target_contentDetails !== void 0 ? _target_contentDetails : {});
1502
+ if (cleanRating) details.rating = cleanRating;
1503
+ else delete details.rating;
1504
+ target.contentDetails = details;
1505
+ }
1506
+ function appendMissingContentParams(url, meta) {
1507
+ if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
1508
+ try {
1509
+ var parsed = new URL(url);
1510
+ var add = function add(key, value) {
1511
+ if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
1512
+ };
1513
+ add("ct_ch", meta.channelName);
1514
+ add("ct_ti", meta.programTitle);
1515
+ add("ct_ne", meta.contentNetwork);
1516
+ return parsed.toString();
1517
+ } catch (unused) {
1518
+ return url;
1519
+ }
1520
+ }
1521
+ // src/utils/partnerSignals.ts
1522
+ var PLATFORM_IFA_TYPES = /* @__PURE__ */ new Set([
1523
+ "aaid",
1524
+ "adid",
1525
+ "afai",
1526
+ "idfa",
1527
+ "lgudid",
1528
+ "msai",
1529
+ "rida",
1530
+ "tifa",
1531
+ "tvos",
1532
+ "vaid",
1533
+ "vida"
1534
+ ]);
1535
+ function toIabIfaType(deviceIdType, source) {
1536
+ if (!deviceIdType) return void 0;
1537
+ var type = deviceIdType.trim().toLowerCase();
1538
+ if (source === "generated") return "sessionid";
1539
+ if (PLATFORM_IFA_TYPES.has(type)) return type;
1540
+ if (source === "platform") return "dpid";
1541
+ return "ppid";
1542
+ }
1543
+ function playbackMethodCode(autoPlay, muted) {
1544
+ if (autoPlay === false) return 3;
1545
+ if (autoPlay !== true || muted == null) return void 0;
1546
+ return muted ? 2 : 1;
1547
+ }
1548
+ function resolvePlayerSize(video) {
1549
+ var width = video ? video.clientWidth : 0;
1550
+ var height = video ? video.clientHeight : 0;
1551
+ if (!(width > 0 && height > 0) && typeof window !== "undefined") {
1552
+ width = window.innerWidth;
1553
+ height = window.innerHeight;
1554
+ }
1555
+ if (!(width > 0 && height > 0)) return {};
1556
+ return {
1557
+ width: Math.round(width),
1558
+ height: Math.round(height)
1559
+ };
1560
+ }
1561
+ function sanitizeUserId(value) {
1562
+ var cleaned = sanitizeContentValue(value);
1563
+ if (!cleaned || /\s/.test(cleaned)) return void 0;
1564
+ return cleaned;
1565
+ }
1566
+ function isPublicIpv4(ip) {
1567
+ var parts = ip.split(".");
1568
+ if (parts.length !== 4) return false;
1569
+ var nums = parts.map(function(p) {
1570
+ return /^\d{1,3}$/.test(p) ? Number(p) : NaN;
1571
+ });
1572
+ if (nums.some(function(n) {
1573
+ return !(n >= 0 && n <= 255);
1574
+ })) return false;
1575
+ var _nums = _sliced_to_array(nums, 2), a = _nums[0], b = _nums[1];
1576
+ if (a === 0 || a === 10 || a === 127 || a >= 224) return false;
1577
+ if (a === 100 && b >= 64 && b <= 127) return false;
1578
+ if (a === 169 && b === 254) return false;
1579
+ if (a === 172 && b >= 16 && b <= 31) return false;
1580
+ if (a === 192 && b === 168) return false;
1581
+ return true;
1582
+ }
1583
+ function isPublicIpv6(ip) {
1584
+ var lower = ip.toLowerCase();
1585
+ if (!/^[0-9a-f:]+$/.test(lower) || lower.split(":").length < 3) return false;
1586
+ if (lower === "::" || lower === "::1") return false;
1587
+ if (/^fe[89ab]/.test(lower)) return false;
1588
+ if (/^f[cd]/.test(lower)) return false;
1589
+ return true;
1590
+ }
1591
+ function sanitizePublicIp(value) {
1592
+ var cleaned = sanitizeContentValue(value);
1593
+ if (!cleaned) return void 0;
1594
+ if (cleaned.includes(".")) return isPublicIpv4(cleaned) ? cleaned : void 0;
1595
+ return isPublicIpv6(cleaned) ? cleaned : void 0;
1596
+ }
1597
+ function resolveUserId(configValue) {
1598
+ var _sanitizeUserId;
1599
+ return (_sanitizeUserId = sanitizeUserId(configValue)) !== null && _sanitizeUserId !== void 0 ? _sanitizeUserId : readBridgeValue2([
1600
+ "userId",
1601
+ "uid"
1602
+ ], sanitizeUserId);
1603
+ }
1604
+ function resolveClientIp(configValue) {
1605
+ var _sanitizePublicIp;
1606
+ return (_sanitizePublicIp = sanitizePublicIp(configValue)) !== null && _sanitizePublicIp !== void 0 ? _sanitizePublicIp : readBridgeValue2([
1607
+ "ipAddress",
1608
+ "clientIp",
1609
+ "ip"
1610
+ ], sanitizePublicIp);
1611
+ }
1299
1612
  // src/utils/vastMacros.ts
1300
1613
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
1301
1614
  var INVALID_VAST_PARAM_KEY = /^\s|\s$/;
@@ -1613,7 +1926,8 @@ var NESTED_QUERY_PARAM_KEYS = /* @__PURE__ */ new Set([
1613
1926
  var SCVP_POD_MACROS = /* @__PURE__ */ new Set([
1614
1927
  "PMND",
1615
1928
  "PMXD",
1616
- "PMAD"
1929
+ "PMAD",
1930
+ "MABD"
1617
1931
  ]);
1618
1932
  function hasScvpMacros(url) {
1619
1933
  return !!url && SCVP_MACRO_DETECT.test(url);
@@ -1658,6 +1972,8 @@ function resolveScvpMacroValues(ctx) {
1658
1972
  set("RDID", deviceId);
1659
1973
  set("IDTYPE", deviceIdType);
1660
1974
  set("IS-LAT", (_toFlag = toFlag(ctx.limitAdTracking)) !== null && _toFlag !== void 0 ? _toFlag : "0");
1975
+ set("IFA", deviceId);
1976
+ set("IFA-TYPE", toIabIfaType(deviceIdType, ctx.deviceIdSource));
1661
1977
  }
1662
1978
  set("SID", ctx.sessionId);
1663
1979
  set("DTH", ctx.deviceTypeHint);
@@ -1675,6 +1991,26 @@ function resolveScvpMacroValues(ctx) {
1675
1991
  set("GDPR", (_ctx_consent = ctx.consent) === null || _ctx_consent === void 0 ? void 0 : _ctx_consent.gdpr);
1676
1992
  set("GDPR-CONSENT", (_ctx_consent1 = ctx.consent) === null || _ctx_consent1 === void 0 ? void 0 : _ctx_consent1.gdprConsent);
1677
1993
  set("US-PRIVACY", (_ctx_consent2 = ctx.consent) === null || _ctx_consent2 === void 0 ? void 0 : _ctx_consent2.usPrivacy);
1994
+ set("PLAYER-WIDTH", ctx.playerWidth);
1995
+ set("PLAYER-HEIGHT", ctx.playerHeight);
1996
+ set("TIMESTAMP", ctx.timestamp);
1997
+ set("LIVE", toFlag(ctx.isLive));
1998
+ set("VPMT", playbackMethodCode(ctx.isCtv ? true : ctx.adWillAutoPlay, ctx.adWillPlayMuted));
1999
+ set("DEVICE-MAKE", ctx.deviceMake);
2000
+ set("DEVICE-MODEL", ctx.deviceModel);
2001
+ set("DEVICE-HWV", ctx.deviceHardwareVersion);
2002
+ set("UA", ctx.userAgent);
2003
+ set("IP", ctx.ipAddress);
2004
+ set("UID", ctx.userId);
2005
+ set("CT-TYPE", ctx.contentType);
2006
+ set("CT-CATEGORY", ctx.contentCategory);
2007
+ set("CT-GENRE", ctx.contentGenre);
2008
+ set("CT-LANGUAGE", ctx.contentLanguage);
2009
+ set("CT-DURATION", ctx.contentDurationSeconds != null ? ctx.contentDurationSeconds : ctx.isLive ? -1 : void 0);
2010
+ set("CT-SEASON", ctx.contentSeason);
2011
+ set("CT-EPISODE", ctx.contentEpisode);
2012
+ set("CT-RATING", ctx.contentRating);
2013
+ set("CT-ID", ctx.contentId);
1678
2014
  return values;
1679
2015
  }
1680
2016
  var keepNone = function keepNone() {
@@ -2561,9 +2897,30 @@ function detectBrowser() {
2561
2897
  };
2562
2898
  }
2563
2899
  var singleDecoderOverride;
2900
+ var LEARNED_SINGLE_DECODER_KEY = "stormcloud.singleDecoder.learned.v1";
2901
+ var learnedSingleDecoder;
2564
2902
  function setSingleDecoderOverride(value) {
2565
2903
  singleDecoderOverride = value;
2566
2904
  }
2905
+ function readLearnedSingleDecoder() {
2906
+ if (learnedSingleDecoder !== void 0) return learnedSingleDecoder;
2907
+ try {
2908
+ var _window_localStorage;
2909
+ learnedSingleDecoder = typeof window !== "undefined" && ((_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(LEARNED_SINGLE_DECODER_KEY)) === "1";
2910
+ } catch (unused) {
2911
+ learnedSingleDecoder = false;
2912
+ }
2913
+ return learnedSingleDecoder;
2914
+ }
2915
+ function markSingleDecoderLearned() {
2916
+ if (readLearnedSingleDecoder()) return false;
2917
+ learnedSingleDecoder = true;
2918
+ try {
2919
+ var _window_localStorage;
2920
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(LEARNED_SINGLE_DECODER_KEY, "1");
2921
+ } catch (unused) {}
2922
+ return true;
2923
+ }
2567
2924
  function requiresMediaPipelineResetAfterAds() {
2568
2925
  var _browser_tizenVersion;
2569
2926
  if (singleDecoderOverride != null) return singleDecoderOverride;
@@ -2571,6 +2928,7 @@ function requiresMediaPipelineResetAfterAds() {
2571
2928
  var globalOverride = typeof window !== "undefined" ? window.__STORMCLOUD_SINGLE_DECODER__ : void 0;
2572
2929
  if (typeof globalOverride === "boolean") return globalOverride;
2573
2930
  } catch (unused) {}
2931
+ if (readLearnedSingleDecoder()) return true;
2574
2932
  var browser = detectBrowser();
2575
2933
  return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
2576
2934
  }
@@ -2890,15 +3248,20 @@ function finalizeGamRequestUrl(rawUrl, ctx) {
2890
3248
  values.set("PMND", String(pod.pmnd));
2891
3249
  values.set("PMXD", String(pod.pmxd));
2892
3250
  if (pod.pmad != null) values.set("PMAD", String(pod.pmad));
3251
+ values.set("MABD", String(Math.max(1, Math.floor(pod.pmxd / 1e3))));
2893
3252
  }
2894
3253
  var substituted = substituteScvpMacros(rawUrl, values);
2895
3254
  var finalUrl;
2896
3255
  try {
2897
3256
  var url = new URL(normalizeVastTagUrl(substituted.url));
3257
+ var isGam = GAM_AD_HOSTS.has(url.hostname);
3258
+ var setPodParam = function setPodParam(key, value) {
3259
+ if (isGam || url.searchParams.has(key)) url.searchParams.set(key, String(value));
3260
+ };
2898
3261
  if (pod) {
2899
- url.searchParams.set("pmnd", String(pod.pmnd));
2900
- url.searchParams.set("pmxd", String(pod.pmxd));
2901
- if (pod.pmad != null) url.searchParams.set("pmad", String(pod.pmad));
3262
+ setPodParam("pmnd", pod.pmnd);
3263
+ setPodParam("pmxd", pod.pmxd);
3264
+ if (pod.pmad != null) setPodParam("pmad", pod.pmad);
2902
3265
  else url.searchParams.delete("pmad");
2903
3266
  } else {
2904
3267
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2964,7 +3327,9 @@ function validateGamRequestUrl(url, expect) {
2964
3327
  if (leftover.length > 0) problems.push("unresolved SCVP macros: ".concat(leftover.join(", ")));
2965
3328
  var params;
2966
3329
  try {
2967
- params = new URL(url).searchParams;
3330
+ var parsed = new URL(url);
3331
+ if (!GAM_AD_HOSTS.has(parsed.hostname)) return problems;
3332
+ params = parsed.searchParams;
2968
3333
  } catch (unused) {
2969
3334
  return problems.concat("URL could not be parsed");
2970
3335
  }
@@ -6385,7 +6750,7 @@ function safeCall2(fn, thisArg) {
6385
6750
  function userAgent() {
6386
6751
  return typeof navigator !== "undefined" ? navigator.userAgent || "" : "";
6387
6752
  }
6388
- function bridgeSources() {
6753
+ function bridgeSources2() {
6389
6754
  if (typeof window === "undefined") return [];
6390
6755
  var w = window;
6391
6756
  return [
@@ -6397,7 +6762,7 @@ function bridgeSources() {
6397
6762
  function readBridge(keys) {
6398
6763
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6399
6764
  try {
6400
- for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6765
+ for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6401
6766
  var source = _step.value;
6402
6767
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6403
6768
  try {
@@ -6444,6 +6809,11 @@ function readBridge(keys) {
6444
6809
  }
6445
6810
  return void 0;
6446
6811
  }
6812
+ function makeForCategory(category) {
6813
+ if (category === "LG TV" || category === "LG Set-Top Box") return "LG";
6814
+ if (category === "Samsung TV") return "Samsung";
6815
+ return void 0;
6816
+ }
6447
6817
  function normalizeCategory(value) {
6448
6818
  var v = cleanString(value);
6449
6819
  if (!v) return void 0;
@@ -6591,7 +6961,7 @@ function primeDeviceInfo() {
6591
6961
  return primePromise;
6592
6962
  }
6593
6963
  function getDeviceInfo() {
6594
- var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory;
6964
+ var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory, _ref3, _cleanString4, _cleanString5;
6595
6965
  var platform = platformCache !== null && platformCache !== void 0 ? platformCache : computePlatformInfo();
6596
6966
  if (primePromise && !platformCache) {} else {
6597
6967
  platformCache = platform;
@@ -6614,7 +6984,14 @@ function getDeviceInfo() {
6614
6984
  ]),
6615
6985
  category: normalizeCategory(readBridge([
6616
6986
  "deviceCategory"
6617
- ]))
6987
+ ])),
6988
+ make: readBridge([
6989
+ "deviceMake"
6990
+ ]),
6991
+ hardwareVersion: readBridge([
6992
+ "deviceHardwareVersion",
6993
+ "hardwareVersion"
6994
+ ])
6618
6995
  };
6619
6996
  var terminalId = (_cleanString = cleanString(host.terminalId)) !== null && _cleanString !== void 0 ? _cleanString : bridge.terminalId;
6620
6997
  var hostInternalId = (_cleanString1 = cleanString(host.internalDeviceId)) !== null && _cleanString1 !== void 0 ? _cleanString1 : bridge.internalDeviceId;
@@ -6627,7 +7004,9 @@ function getDeviceInfo() {
6627
7004
  bridge.internalDeviceId,
6628
7005
  bridge.model,
6629
7006
  bridge.firmware,
6630
- bridge.category
7007
+ bridge.category,
7008
+ bridge.make,
7009
+ bridge.hardwareVersion
6631
7010
  ];
6632
7011
  if (bridgeValues.some(function(v) {
6633
7012
  return v !== void 0;
@@ -6635,12 +7014,18 @@ function getDeviceInfo() {
6635
7014
  if (hostDeviceInfo) sources.unshift("host");
6636
7015
  var internalDeviceId = hostInternalId !== null && hostInternalId !== void 0 ? hostInternalId : platform.internalDeviceId;
6637
7016
  var internalDeviceIdSource = hostInternalId ? "host" : platform.internalDeviceIdSource;
7017
+ var make = (_ref3 = (_cleanString4 = cleanString(host.make, 40)) !== null && _cleanString4 !== void 0 ? _cleanString4 : bridge.make) !== null && _ref3 !== void 0 ? _ref3 : makeForCategory(category);
7018
+ var hardwareVersion = (_cleanString5 = cleanString(host.hardwareVersion, 40)) !== null && _cleanString5 !== void 0 ? _cleanString5 : bridge.hardwareVersion;
6638
7019
  var sonifiModel = model && category === "Samsung TV" && !/^SAMSUNG-IPTV-/i.test(model) ? "SAMSUNG-IPTV-".concat(model) : model;
6639
7020
  return _object_spread_props(_object_spread({
6640
7021
  category: category,
6641
7022
  categoryCode: CATEGORY_CODES[category]
6642
- }, model ? {
7023
+ }, make ? {
7024
+ make: make
7025
+ } : {}, model ? {
6643
7026
  model: model
7027
+ } : {}, hardwareVersion ? {
7028
+ hardwareVersion: hardwareVersion
6644
7029
  } : {}, sonifiModel ? {
6645
7030
  sonifiModel: sonifiModel
6646
7031
  } : {}, firmware ? {
@@ -6731,117 +7116,6 @@ function deviceInfoAnalyticsFields(info) {
6731
7116
  terminal_id: info.terminalId
6732
7117
  } : {});
6733
7118
  }
6734
- // src/utils/contentMetadata.ts
6735
- var MAX_CONTENT_VALUE_LENGTH = 128;
6736
- var BRIDGE_KEYS = {
6737
- channelName: [
6738
- "channelName",
6739
- "ct_ch"
6740
- ],
6741
- programTitle: [
6742
- "programTitle",
6743
- "ct_ti"
6744
- ],
6745
- contentNetwork: [
6746
- "contentNetwork",
6747
- "ct_ne"
6748
- ]
6749
- };
6750
- function sanitizeContentValue(value) {
6751
- if (typeof value !== "string") return void 0;
6752
- var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
6753
- if (!cleaned) return void 0;
6754
- if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
6755
- if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
6756
- return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
6757
- }
6758
- function bridgeSources2() {
6759
- if (typeof window === "undefined") return [];
6760
- var w = window;
6761
- return [
6762
- w.__STORMCLOUD_CTV__,
6763
- w.__STORMCLOUD_CTV_AD_INFO__,
6764
- w.stormcloudCtv
6765
- ].filter(Boolean);
6766
- }
6767
- function readBridgeContentValue(keys) {
6768
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6769
- try {
6770
- for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6771
- var source = _step.value;
6772
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6773
- try {
6774
- for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
6775
- var key = _step1.value;
6776
- var value = void 0;
6777
- try {
6778
- value = source === null || source === void 0 ? void 0 : source[key];
6779
- if (typeof value === "function") value = value.call(source);
6780
- } catch (unused) {
6781
- value = void 0;
6782
- }
6783
- var sanitized = sanitizeContentValue(value);
6784
- if (sanitized) return sanitized;
6785
- }
6786
- } catch (err) {
6787
- _didIteratorError1 = true;
6788
- _iteratorError1 = err;
6789
- } finally{
6790
- try {
6791
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
6792
- _iterator1.return();
6793
- }
6794
- } finally{
6795
- if (_didIteratorError1) {
6796
- throw _iteratorError1;
6797
- }
6798
- }
6799
- }
6800
- }
6801
- } catch (err) {
6802
- _didIteratorError = true;
6803
- _iteratorError = err;
6804
- } finally{
6805
- try {
6806
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6807
- _iterator.return();
6808
- }
6809
- } finally{
6810
- if (_didIteratorError) {
6811
- throw _iteratorError;
6812
- }
6813
- }
6814
- }
6815
- return void 0;
6816
- }
6817
- function resolveContentMetadata(config) {
6818
- var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2;
6819
- var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
6820
- var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
6821
- var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
6822
- return _object_spread({}, channelName ? {
6823
- channelName: channelName
6824
- } : {}, programTitle ? {
6825
- programTitle: programTitle
6826
- } : {}, contentNetwork ? {
6827
- contentNetwork: contentNetwork
6828
- } : {});
6829
- }
6830
- function appendMissingContentParams(url, meta) {
6831
- if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
6832
- try {
6833
- var parsed = new URL(url);
6834
- var add = function add(key, value) {
6835
- if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
6836
- };
6837
- add("ct_ch", meta.channelName);
6838
- add("ct_ti", meta.programTitle);
6839
- add("ct_ne", meta.contentNetwork);
6840
- return parsed.toString();
6841
- } catch (unused) {
6842
- return url;
6843
- }
6844
- }
6845
7119
  // src/utils/screenActivity.ts
6846
7120
  var hostStandby = false;
6847
7121
  function setHostStandby(standby) {
@@ -8843,6 +9117,13 @@ var Scte35CueManager = /*#__PURE__*/ function() {
8843
9117
  return Scte35CueManager;
8844
9118
  }();
8845
9119
  // src/player/AdConfigManager.ts
9120
+ function isGamAdUrl(rawUrl) {
9121
+ try {
9122
+ return GAM_AD_HOSTS.has(new URL(rawUrl).hostname);
9123
+ } catch (unused) {
9124
+ return false;
9125
+ }
9126
+ }
8846
9127
  function withDeferredPodParams(rawUrl, deferNonce) {
8847
9128
  try {
8848
9129
  var url = new URL(rawUrl);
@@ -8860,11 +9141,15 @@ function withDeferredPodParams(rawUrl, deferNonce) {
8860
9141
  }
8861
9142
  var AdConfigManager = /*#__PURE__*/ function() {
8862
9143
  function AdConfigManager(config, video) {
9144
+ var _this = this;
8863
9145
  _class_call_check(this, AdConfigManager);
8864
9146
  this.vmapBreaks = [];
8865
9147
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
8866
9148
  this.streamCorrelator = generateCorrelator();
8867
9149
  this.consentSignals = {};
9150
+ this.isLiveStream = function() {
9151
+ return !!_this.config.isLiveStream;
9152
+ };
8868
9153
  this.podCounter = 0;
8869
9154
  this.podAssignedByPrefetch = false;
8870
9155
  this.lastHeartbeatTime = 0;
@@ -9315,13 +9600,22 @@ var AdConfigManager = /*#__PURE__*/ function() {
9315
9600
  {
9316
9601
  key: "generatePodVastUrl",
9317
9602
  value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
9603
+ var _content_contentDurationSeconds;
9318
9604
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
9319
9605
  var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
9320
9606
  fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
9321
9607
  sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
9322
9608
  });
9323
9609
  var content = resolveContentMetadata(this.config);
9324
- var macroContext = _object_spread_props(_object_spread({
9610
+ var isLive = this.isLiveStream();
9611
+ var device = getDeviceInfo();
9612
+ var playerSize = resolvePlayerSize(this.video);
9613
+ var videoDuration = this.video.duration;
9614
+ var contentDurationSeconds = (_content_contentDurationSeconds = content.contentDurationSeconds) !== null && _content_contentDurationSeconds !== void 0 ? _content_contentDurationSeconds : !isLive && Number.isFinite(videoDuration) && videoDuration > 0 ? Math.round(videoDuration) : void 0;
9615
+ var userId = resolveUserId(this.config.adUserId);
9616
+ var ipAddress = resolveClientIp(this.config.clientIpAddress);
9617
+ var userAgent2 = typeof navigator !== "undefined" && navigator.userAgent ? navigator.userAgent : void 0;
9618
+ var macroContext = _object_spread(_object_spread_props(_object_spread(_object_spread_props(_object_spread({
9325
9619
  correlator: this.viewCorrelator,
9326
9620
  streamCorrelator: this.streamCorrelator,
9327
9621
  pod: this.podCounter > 0 ? this.podCounter : void 0,
@@ -9343,8 +9637,46 @@ var AdConfigManager = /*#__PURE__*/ function() {
9343
9637
  contentNetwork: content.contentNetwork
9344
9638
  } : {}), {
9345
9639
  consent: this.consentSignals,
9346
- palNonce: palNonce.getCurrentNonce() || void 0
9347
- });
9640
+ palNonce: palNonce.getCurrentNonce() || void 0,
9641
+ deviceIdSource: envSignals.deviceIdSource,
9642
+ isLive: isLive
9643
+ }), playerSize.width ? {
9644
+ playerWidth: playerSize.width
9645
+ } : {}, playerSize.height ? {
9646
+ playerHeight: playerSize.height
9647
+ } : {}), {
9648
+ timestamp: String(Date.now())
9649
+ }), device.make ? {
9650
+ deviceMake: device.make
9651
+ } : {}, device.model ? {
9652
+ deviceModel: device.model
9653
+ } : {}, device.hardwareVersion ? {
9654
+ deviceHardwareVersion: device.hardwareVersion
9655
+ } : {}, userAgent2 ? {
9656
+ userAgent: userAgent2
9657
+ } : {}, ipAddress ? {
9658
+ ipAddress: ipAddress
9659
+ } : {}, userId ? {
9660
+ userId: userId
9661
+ } : {}, content.contentType ? {
9662
+ contentType: content.contentType
9663
+ } : {}, content.contentCategory ? {
9664
+ contentCategory: content.contentCategory
9665
+ } : {}, content.contentGenre ? {
9666
+ contentGenre: content.contentGenre
9667
+ } : {}, content.contentLanguage ? {
9668
+ contentLanguage: content.contentLanguage
9669
+ } : {}, contentDurationSeconds != null ? {
9670
+ contentDurationSeconds: contentDurationSeconds
9671
+ } : {}, content.contentSeason ? {
9672
+ contentSeason: content.contentSeason
9673
+ } : {}, content.contentEpisode ? {
9674
+ contentEpisode: content.contentEpisode
9675
+ } : {}, content.contentRating ? {
9676
+ contentRating: content.contentRating
9677
+ } : {}, content.contentId ? {
9678
+ contentId: content.contentId
9679
+ } : {});
9348
9680
  var nonceReady = !!macroContext.palNonce;
9349
9681
  var finalUrl;
9350
9682
  if (hasScvpMacros(baseUrl)) {
@@ -9358,9 +9690,11 @@ var AdConfigManager = /*#__PURE__*/ function() {
9358
9690
  } else {
9359
9691
  finalUrl = withDeferredPodParams(palNonce.injectNonce(ensureVideoAdType(applyVastMacros(baseUrl, macroContext))), !nonceReady);
9360
9692
  }
9361
- finalUrl = appendMissingContentParams(finalUrl, content);
9362
- if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9363
- finalUrl = applyDeviceKeyValues(finalUrl, getDeviceInfo());
9693
+ if (isGamAdUrl(finalUrl)) {
9694
+ finalUrl = appendMissingContentParams(finalUrl, content);
9695
+ if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9696
+ finalUrl = applyDeviceKeyValues(finalUrl, device);
9697
+ }
9364
9698
  }
9365
9699
  if (this.debug) {
9366
9700
  var id = envSignals.deviceId;
@@ -9373,7 +9707,13 @@ var AdConfigManager = /*#__PURE__*/ function() {
9373
9707
  sidTail: envSignals.sessionId ? envSignals.sessionId.slice(-4) : void 0,
9374
9708
  ct_ch: content.channelName,
9375
9709
  ct_ti: content.programTitle,
9376
- ct_ne: content.contentNetwork
9710
+ ct_ne: content.contentNetwork,
9711
+ rating: content.contentRating,
9712
+ ifaType: toIabIfaType(envSignals.deviceIdType, envSignals.deviceIdSource),
9713
+ live: isLive,
9714
+ player: playerSize,
9715
+ make: device.make,
9716
+ model: device.model
9377
9717
  });
9378
9718
  }
9379
9719
  console.log("[StormcloudVideoPlayer] Prepared optimized-pod request URL (pod=".concat(this.podCounter, "; pmnd/pmxd/pmad resolved at dispatch):"), finalUrl);
@@ -11052,6 +11392,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11052
11392
  this.adDetectSentForCurrentBreak = false;
11053
11393
  this.slotState = "IDLE";
11054
11394
  this.unusableResponsesInBreak = 0;
11395
+ this.playedAdIdsInBreak = /* @__PURE__ */ new Set();
11055
11396
  this.controllerGeneration = 0;
11056
11397
  this.requestDiagnostics = /* @__PURE__ */ new Map();
11057
11398
  this.breakFunnel = {};
@@ -11148,6 +11489,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11148
11489
  _this.recordRequestDiagnostic(payload);
11149
11490
  });
11150
11491
  adPlayer.on("ad_impression", function() {
11492
+ var _this_host_getAdPlayer_getLoadedAdId, _this_host_getAdPlayer;
11493
+ 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);
11494
+ if (impressionAdId != null && impressionAdId !== "") {
11495
+ _this.playedAdIdsInBreak.add(String(impressionAdId));
11496
+ }
11151
11497
  _this.timing.consecutiveFailures = 0;
11152
11498
  _this.setSlotState("PLAYING", "impression");
11153
11499
  if (!_this.playbackStartedForCurrentRequest) {
@@ -11339,6 +11685,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11339
11685
  this.resetEdgeStateForBreak();
11340
11686
  this.followUpBaseVastUrl = void 0;
11341
11687
  this.unusableResponsesInBreak = 0;
11688
+ this.playedAdIdsInBreak.clear();
11342
11689
  this.timing.totalAdRequestsInBreak = 0;
11343
11690
  this.setSlotState("NEEDS_NEXT_AD", "vmap_break_start");
11344
11691
  this.noteOpportunity("vmap", breakKey, position);
@@ -11389,6 +11736,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11389
11736
  this.breakSource = "scte35";
11390
11737
  this.followUpBaseVastUrl = baseVastUrl;
11391
11738
  this.unusableResponsesInBreak = 0;
11739
+ this.playedAdIdsInBreak.clear();
11392
11740
  this.resetEdgeStateForBreak();
11393
11741
  this.setSlotState("NEEDS_NEXT_AD", "scte35_break_start");
11394
11742
  if (this.adConfig.podAssignedByPrefetch) {
@@ -12228,6 +12576,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12228
12576
  var outcome;
12229
12577
  if (message.includes("ad_duration_exceeds_budget")) {
12230
12578
  outcome = "discarded_budget";
12579
+ } else if (message.includes("ad_repeated_in_break")) {
12580
+ outcome = "discarded_duplicate";
12231
12581
  } else if (message.includes("VAST fill rejected")) {
12232
12582
  outcome = "fill_rejected";
12233
12583
  } else if (/no ads available|no fill|nofill/i.test(message)) {
@@ -12242,7 +12592,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12242
12592
  outcome = "request_failed";
12243
12593
  }
12244
12594
  this.timing.consecutiveFailures++;
12245
- if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget") {
12595
+ if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget" || outcome === "discarded_duplicate") {
12246
12596
  this.unusableResponsesInBreak++;
12247
12597
  }
12248
12598
  if (outcome === "no_fill") {
@@ -12256,7 +12606,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12256
12606
  }) ? diag.dispatchedUrl : vastTagUrl;
12257
12607
  if (this.timing.isTemporaryAdError(error)) {
12258
12608
  this.timing.temporaryFailureUrls.set(failureKey, Date.now());
12259
- } else if (outcome !== "discarded_budget") {
12609
+ } else if (outcome !== "discarded_budget" && outcome !== "discarded_duplicate") {
12260
12610
  this.timing.failedVastUrls.add(failureKey);
12261
12611
  }
12262
12612
  this.countFunnelStage("request_outcome:".concat(outcome));
@@ -12628,7 +12978,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12628
12978
  value: function playSingleAd(vastTagUrl) {
12629
12979
  var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
12630
12980
  return _async_to_generator(function() {
12631
- var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, finalizeRequestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
12981
+ var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, _ref, _ap_getLoadedAdId, _ap_getPodAdCount, finalizeRequestUrl, loadedAdId, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
12632
12982
  return _ts_generator(this, function(_state) {
12633
12983
  switch(_state.label){
12634
12984
  case 0:
@@ -12741,6 +13091,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12741
13091
  vastUrl: (_this_currentVastUrl = this.currentVastUrl) !== null && _this_currentVastUrl !== void 0 ? _this_currentVastUrl : requestUrl,
12742
13092
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
12743
13093
  }, this.analyticsContext).catch(function() {});
13094
+ loadedAdId = (_ap_getLoadedAdId = ap.getLoadedAdId) === null || _ap_getLoadedAdId === void 0 ? void 0 : _ap_getLoadedAdId.call(ap);
13095
+ 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))) {
13096
+ if (this.debug) {
13097
+ console.log("[AD-DURATION] Rejected ad id=".concat(loadedAdId, ": already played in this break — requesting another ad"));
13098
+ }
13099
+ this.logOrchestratorFunnel("discarded_duplicate", {
13100
+ adId: String(loadedAdId)
13101
+ });
13102
+ throw new Error("ad_repeated_in_break");
13103
+ }
12744
13104
  if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
12745
13105
  ;
12746
13106
  adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
@@ -12794,6 +13154,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12794
13154
  this.recordRequestFailure(error, vastTagUrl);
12795
13155
  if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
12796
13156
  this.recreateAdController("discarded_budget");
13157
+ } else if ((error === null || error === void 0 ? void 0 : error.message) === "ad_repeated_in_break") {
13158
+ this.recreateAdController("discarded_duplicate");
12797
13159
  }
12798
13160
  throw error;
12799
13161
  case 10:
@@ -12867,6 +13229,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12867
13229
  tagAllowsAudio: count("tag_allows_audio"),
12868
13230
  missingImpression: count("vast_missing_impression"),
12869
13231
  discardedBudget: count("discarded_budget"),
13232
+ discardedDuplicate: count("discarded_duplicate"),
12870
13233
  mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
12871
13234
  mediaRejected: count("media_candidate:rejected"),
12872
13235
  mediaFallbacks: count("media_fallback"),
@@ -12942,6 +13305,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12942
13305
  this.breakSource = void 0;
12943
13306
  this.followUpBaseVastUrl = void 0;
12944
13307
  this.unusableResponsesInBreak = 0;
13308
+ this.playedAdIdsInBreak.clear();
12945
13309
  this.resetEdgeStateForBreak();
12946
13310
  adPlayer.stop().catch(function() {});
12947
13311
  if (!alreadyEnded) this.logBreakFunnel(reason);
@@ -13042,9 +13406,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13042
13406
  var maxMonitorMs = 45e3;
13043
13407
  var startTime = Date.now();
13044
13408
  var baseline = resumeBaseline;
13409
+ var lastSeenTime = resumeBaseline;
13045
13410
  var recoveries = 0;
13046
13411
  var lastRecoveryAt = 0;
13047
13412
  var video = this.host.video;
13413
+ var onDecodeError = function onDecodeError() {
13414
+ var _video_error;
13415
+ if (needsReset || ((_video_error = video.error) === null || _video_error === void 0 ? void 0 : _video_error.code) !== 3) return;
13416
+ if (markSingleDecoderLearned() && _this.debug) {
13417
+ console.warn("[StormcloudVideoPlayer] Decoder error while resuming after ads \u2014 using single-decoder mode on this device from the next break");
13418
+ }
13419
+ };
13420
+ video.addEventListener("error", onDecodeError);
13048
13421
  var listenersAttached = false;
13049
13422
  var onMediaEvent;
13050
13423
  var diagEvents = [
@@ -13094,6 +13467,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13094
13467
  console.log("[ResumeDiag] +0.0s monitor start — ".concat(this.describeVideoState()));
13095
13468
  }
13096
13469
  var cleanup = function cleanup() {
13470
+ video.removeEventListener("error", onDecodeError);
13097
13471
  if (listenersAttached && onMediaEvent) {
13098
13472
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
13099
13473
  try {
@@ -13124,6 +13498,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13124
13498
  return;
13125
13499
  }
13126
13500
  var currentTime = video.currentTime;
13501
+ if (currentTime + 1 < lastSeenTime) {
13502
+ baseline = currentTime;
13503
+ }
13504
+ lastSeenTime = currentTime;
13127
13505
  var advanced = currentTime > baseline + 0.5;
13128
13506
  var playing = !video.paused && video.readyState >= 3;
13129
13507
  if (advanced && playing) {
@@ -13544,6 +13922,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13544
13922
  return !!_this.adBreak && _this.adBreak.inAdBreak && !_this.shouldContinueLiveStreamDuringAds();
13545
13923
  }
13546
13924
  });
13925
+ this.adConfig.isLiveStream = function() {
13926
+ return _this.hlsEngine.isLiveStream;
13927
+ };
13547
13928
  this.adBreak = new AdBreakOrchestrator({
13548
13929
  config: this.config,
13549
13930
  video: this.video,
@@ -13905,16 +14286,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13905
14286
  {
13906
14287
  key: "setContentMetadata",
13907
14288
  value: function setContentMetadata(meta) {
13908
- var _this = this;
13909
- var apply = function apply(key, value) {
13910
- if (value === void 0) return;
13911
- var clean = value === null ? void 0 : sanitizeContentValue(value);
13912
- if (clean) _this.config[key] = clean;
13913
- else delete _this.config[key];
13914
- };
13915
- apply("channelName", meta.channelName);
13916
- apply("programTitle", meta.programTitle);
13917
- apply("contentNetwork", meta.contentNetwork);
14289
+ applyContentMetadataUpdate(this.config, meta);
14290
+ }
14291
+ },
14292
+ {
14293
+ key: "setRequestSignals",
14294
+ value: function setRequestSignals(signals) {
14295
+ if (signals.userId !== void 0) {
14296
+ if (signals.userId) this.config.adUserId = signals.userId;
14297
+ else delete this.config.adUserId;
14298
+ }
14299
+ if (signals.ipAddress !== void 0) {
14300
+ if (signals.ipAddress) this.config.clientIpAddress = signals.ipAddress;
14301
+ else delete this.config.clientIpAddress;
14302
+ }
13918
14303
  }
13919
14304
  },
13920
14305
  {