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
@@ -1246,6 +1246,319 @@ function normalizeBoolean(value) {
1246
1246
  }
1247
1247
  return void 0;
1248
1248
  }
1249
+ // src/utils/contentMetadata.ts
1250
+ var MAX_CONTENT_VALUE_LENGTH = 128;
1251
+ var BRIDGE_KEYS = {
1252
+ channelName: [
1253
+ "channelName",
1254
+ "ct_ch"
1255
+ ],
1256
+ programTitle: [
1257
+ "programTitle",
1258
+ "ct_ti"
1259
+ ],
1260
+ contentNetwork: [
1261
+ "contentNetwork",
1262
+ "ct_ne"
1263
+ ],
1264
+ contentType: [
1265
+ "contentType",
1266
+ "ctt"
1267
+ ],
1268
+ contentCategory: [
1269
+ "contentCategory",
1270
+ "ctc"
1271
+ ],
1272
+ contentGenre: [
1273
+ "contentGenre",
1274
+ "ctgr"
1275
+ ],
1276
+ contentLanguage: [
1277
+ "contentLanguage",
1278
+ "ctlg"
1279
+ ],
1280
+ contentDuration: [
1281
+ "contentDuration",
1282
+ "ctd"
1283
+ ],
1284
+ contentSeason: [
1285
+ "contentSeason",
1286
+ "cts"
1287
+ ],
1288
+ contentEpisode: [
1289
+ "contentEpisode",
1290
+ "cte"
1291
+ ],
1292
+ contentRating: [
1293
+ "contentRating",
1294
+ "ctr",
1295
+ "programRating",
1296
+ "rating"
1297
+ ],
1298
+ contentId: [
1299
+ "contentId",
1300
+ "ctid"
1301
+ ]
1302
+ };
1303
+ function sanitizeContentValue(value) {
1304
+ if (typeof value !== "string") return void 0;
1305
+ var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1306
+ if (!cleaned) return void 0;
1307
+ if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
1308
+ if (/^(unknown|null|undefined|none|n\/a|-|tbd|tba|to be (announced|determined))$/i.test(cleaned)) {
1309
+ return void 0;
1310
+ }
1311
+ return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
1312
+ }
1313
+ function sanitizeContentScalar(value) {
1314
+ if (typeof value === "number") {
1315
+ return Number.isFinite(value) ? String(value) : void 0;
1316
+ }
1317
+ return sanitizeContentValue(value);
1318
+ }
1319
+ function normalizeContentLanguage(value) {
1320
+ var cleaned = sanitizeContentValue(value);
1321
+ if (!cleaned) return void 0;
1322
+ var match = cleaned.match(/^([A-Za-z]{2})(?:[-_][A-Za-z0-9]{1,8})*$/);
1323
+ return match && match[1] ? match[1].toLowerCase() : void 0;
1324
+ }
1325
+ function normalizeContentDuration(value) {
1326
+ var raw = sanitizeContentScalar(value);
1327
+ if (raw == null || !/^-?\d+(\.\d+)?$/.test(raw)) return void 0;
1328
+ var seconds = Number(raw);
1329
+ if (seconds === -1) return -1;
1330
+ return seconds > 0 ? Math.round(seconds) : void 0;
1331
+ }
1332
+ function bridgeSources() {
1333
+ if (typeof window === "undefined") return [];
1334
+ var w = window;
1335
+ return [
1336
+ w.__STORMCLOUD_CTV__,
1337
+ w.__STORMCLOUD_CTV_AD_INFO__,
1338
+ w.stormcloudCtv
1339
+ ].filter(Boolean);
1340
+ }
1341
+ function readBridgeValue2(keys, sanitize) {
1342
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1343
+ try {
1344
+ for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1345
+ var source = _step.value;
1346
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
1347
+ try {
1348
+ for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
1349
+ var key = _step1.value;
1350
+ var value = void 0;
1351
+ try {
1352
+ value = source === null || source === void 0 ? void 0 : source[key];
1353
+ if (typeof value === "function") value = value.call(source);
1354
+ } catch (unused) {
1355
+ value = void 0;
1356
+ }
1357
+ var sanitized = sanitize(value);
1358
+ if (sanitized != null) return sanitized;
1359
+ }
1360
+ } catch (err) {
1361
+ _didIteratorError1 = true;
1362
+ _iteratorError1 = err;
1363
+ } finally{
1364
+ try {
1365
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
1366
+ _iterator1.return();
1367
+ }
1368
+ } finally{
1369
+ if (_didIteratorError1) {
1370
+ throw _iteratorError1;
1371
+ }
1372
+ }
1373
+ }
1374
+ }
1375
+ } catch (err) {
1376
+ _didIteratorError = true;
1377
+ _iteratorError = err;
1378
+ } finally{
1379
+ try {
1380
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1381
+ _iterator.return();
1382
+ }
1383
+ } finally{
1384
+ if (_didIteratorError) {
1385
+ throw _iteratorError;
1386
+ }
1387
+ }
1388
+ }
1389
+ return void 0;
1390
+ }
1391
+ function readBridgeContentValue(keys) {
1392
+ return readBridgeValue2(keys, sanitizeContentValue);
1393
+ }
1394
+ function resolveContentMetadata(config) {
1395
+ var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2, _config_contentDetails, _sanitizeContentValue3, _sanitizeContentValue4, _sanitizeContentValue5, _normalizeContentLanguage, _normalizeContentDuration, _sanitizeContentScalar, _sanitizeContentScalar1, _sanitizeContentValue6, _sanitizeContentValue7;
1396
+ var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
1397
+ var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
1398
+ var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
1399
+ var details = (_config_contentDetails = config.contentDetails) !== null && _config_contentDetails !== void 0 ? _config_contentDetails : {};
1400
+ var contentType = (_sanitizeContentValue3 = sanitizeContentValue(details.contentType)) !== null && _sanitizeContentValue3 !== void 0 ? _sanitizeContentValue3 : readBridgeContentValue(BRIDGE_KEYS.contentType);
1401
+ var contentCategory = (_sanitizeContentValue4 = sanitizeContentValue(details.category)) !== null && _sanitizeContentValue4 !== void 0 ? _sanitizeContentValue4 : readBridgeContentValue(BRIDGE_KEYS.contentCategory);
1402
+ var contentGenre = (_sanitizeContentValue5 = sanitizeContentValue(details.genre)) !== null && _sanitizeContentValue5 !== void 0 ? _sanitizeContentValue5 : readBridgeContentValue(BRIDGE_KEYS.contentGenre);
1403
+ var contentLanguage = (_normalizeContentLanguage = normalizeContentLanguage(details.language)) !== null && _normalizeContentLanguage !== void 0 ? _normalizeContentLanguage : readBridgeValue2(BRIDGE_KEYS.contentLanguage, normalizeContentLanguage);
1404
+ var contentDurationSeconds = (_normalizeContentDuration = normalizeContentDuration(details.durationSeconds)) !== null && _normalizeContentDuration !== void 0 ? _normalizeContentDuration : readBridgeValue2(BRIDGE_KEYS.contentDuration, normalizeContentDuration);
1405
+ var contentSeason = (_sanitizeContentScalar = sanitizeContentScalar(details.season)) !== null && _sanitizeContentScalar !== void 0 ? _sanitizeContentScalar : readBridgeValue2(BRIDGE_KEYS.contentSeason, sanitizeContentScalar);
1406
+ var contentEpisode = (_sanitizeContentScalar1 = sanitizeContentScalar(details.episode)) !== null && _sanitizeContentScalar1 !== void 0 ? _sanitizeContentScalar1 : readBridgeValue2(BRIDGE_KEYS.contentEpisode, sanitizeContentScalar);
1407
+ var contentRating = (_sanitizeContentValue6 = sanitizeContentValue(details.rating)) !== null && _sanitizeContentValue6 !== void 0 ? _sanitizeContentValue6 : readBridgeContentValue(BRIDGE_KEYS.contentRating);
1408
+ var contentId = (_sanitizeContentValue7 = sanitizeContentValue(details.contentId)) !== null && _sanitizeContentValue7 !== void 0 ? _sanitizeContentValue7 : readBridgeContentValue(BRIDGE_KEYS.contentId);
1409
+ return _object_spread({}, channelName ? {
1410
+ channelName: channelName
1411
+ } : {}, programTitle ? {
1412
+ programTitle: programTitle
1413
+ } : {}, contentNetwork ? {
1414
+ contentNetwork: contentNetwork
1415
+ } : {}, contentType ? {
1416
+ contentType: contentType
1417
+ } : {}, contentCategory ? {
1418
+ contentCategory: contentCategory
1419
+ } : {}, contentGenre ? {
1420
+ contentGenre: contentGenre
1421
+ } : {}, contentLanguage ? {
1422
+ contentLanguage: contentLanguage
1423
+ } : {}, contentDurationSeconds != null ? {
1424
+ contentDurationSeconds: contentDurationSeconds
1425
+ } : {}, contentSeason ? {
1426
+ contentSeason: contentSeason
1427
+ } : {}, contentEpisode ? {
1428
+ contentEpisode: contentEpisode
1429
+ } : {}, contentRating ? {
1430
+ contentRating: contentRating
1431
+ } : {}, contentId ? {
1432
+ contentId: contentId
1433
+ } : {});
1434
+ }
1435
+ function applyContentMetadataUpdate(target, meta) {
1436
+ var _target_contentDetails;
1437
+ var apply = function apply(key, value) {
1438
+ if (value === void 0) return;
1439
+ var clean = value === null ? void 0 : sanitizeContentValue(value);
1440
+ if (clean) target[key] = clean;
1441
+ else delete target[key];
1442
+ };
1443
+ apply("channelName", meta.channelName);
1444
+ apply("programTitle", meta.programTitle);
1445
+ apply("contentNetwork", meta.contentNetwork);
1446
+ if (meta.details === null) delete target.contentDetails;
1447
+ else if (meta.details !== void 0) target.contentDetails = _object_spread({}, meta.details);
1448
+ var rating = meta.programRating !== void 0 ? meta.programRating : meta.contentRating;
1449
+ if (rating === void 0) return;
1450
+ var cleanRating = rating === null ? void 0 : sanitizeContentValue(rating);
1451
+ var details = _object_spread({}, (_target_contentDetails = target.contentDetails) !== null && _target_contentDetails !== void 0 ? _target_contentDetails : {});
1452
+ if (cleanRating) details.rating = cleanRating;
1453
+ else delete details.rating;
1454
+ target.contentDetails = details;
1455
+ }
1456
+ function appendMissingContentParams(url, meta) {
1457
+ if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
1458
+ try {
1459
+ var parsed = new URL(url);
1460
+ var add = function add(key, value) {
1461
+ if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
1462
+ };
1463
+ add("ct_ch", meta.channelName);
1464
+ add("ct_ti", meta.programTitle);
1465
+ add("ct_ne", meta.contentNetwork);
1466
+ return parsed.toString();
1467
+ } catch (unused) {
1468
+ return url;
1469
+ }
1470
+ }
1471
+ // src/utils/partnerSignals.ts
1472
+ var PLATFORM_IFA_TYPES = /* @__PURE__ */ new Set([
1473
+ "aaid",
1474
+ "adid",
1475
+ "afai",
1476
+ "idfa",
1477
+ "lgudid",
1478
+ "msai",
1479
+ "rida",
1480
+ "tifa",
1481
+ "tvos",
1482
+ "vaid",
1483
+ "vida"
1484
+ ]);
1485
+ function toIabIfaType(deviceIdType, source) {
1486
+ if (!deviceIdType) return void 0;
1487
+ var type = deviceIdType.trim().toLowerCase();
1488
+ if (source === "generated") return "sessionid";
1489
+ if (PLATFORM_IFA_TYPES.has(type)) return type;
1490
+ if (source === "platform") return "dpid";
1491
+ return "ppid";
1492
+ }
1493
+ function playbackMethodCode(autoPlay, muted) {
1494
+ if (autoPlay === false) return 3;
1495
+ if (autoPlay !== true || muted == null) return void 0;
1496
+ return muted ? 2 : 1;
1497
+ }
1498
+ function resolvePlayerSize(video) {
1499
+ var width = video ? video.clientWidth : 0;
1500
+ var height = video ? video.clientHeight : 0;
1501
+ if (!(width > 0 && height > 0) && typeof window !== "undefined") {
1502
+ width = window.innerWidth;
1503
+ height = window.innerHeight;
1504
+ }
1505
+ if (!(width > 0 && height > 0)) return {};
1506
+ return {
1507
+ width: Math.round(width),
1508
+ height: Math.round(height)
1509
+ };
1510
+ }
1511
+ function sanitizeUserId(value) {
1512
+ var cleaned = sanitizeContentValue(value);
1513
+ if (!cleaned || /\s/.test(cleaned)) return void 0;
1514
+ return cleaned;
1515
+ }
1516
+ function isPublicIpv4(ip) {
1517
+ var parts = ip.split(".");
1518
+ if (parts.length !== 4) return false;
1519
+ var nums = parts.map(function(p) {
1520
+ return /^\d{1,3}$/.test(p) ? Number(p) : NaN;
1521
+ });
1522
+ if (nums.some(function(n) {
1523
+ return !(n >= 0 && n <= 255);
1524
+ })) return false;
1525
+ var _nums = _sliced_to_array(nums, 2), a = _nums[0], b = _nums[1];
1526
+ if (a === 0 || a === 10 || a === 127 || a >= 224) return false;
1527
+ if (a === 100 && b >= 64 && b <= 127) return false;
1528
+ if (a === 169 && b === 254) return false;
1529
+ if (a === 172 && b >= 16 && b <= 31) return false;
1530
+ if (a === 192 && b === 168) return false;
1531
+ return true;
1532
+ }
1533
+ function isPublicIpv6(ip) {
1534
+ var lower = ip.toLowerCase();
1535
+ if (!/^[0-9a-f:]+$/.test(lower) || lower.split(":").length < 3) return false;
1536
+ if (lower === "::" || lower === "::1") return false;
1537
+ if (/^fe[89ab]/.test(lower)) return false;
1538
+ if (/^f[cd]/.test(lower)) return false;
1539
+ return true;
1540
+ }
1541
+ function sanitizePublicIp(value) {
1542
+ var cleaned = sanitizeContentValue(value);
1543
+ if (!cleaned) return void 0;
1544
+ if (cleaned.includes(".")) return isPublicIpv4(cleaned) ? cleaned : void 0;
1545
+ return isPublicIpv6(cleaned) ? cleaned : void 0;
1546
+ }
1547
+ function resolveUserId(configValue) {
1548
+ var _sanitizeUserId;
1549
+ return (_sanitizeUserId = sanitizeUserId(configValue)) !== null && _sanitizeUserId !== void 0 ? _sanitizeUserId : readBridgeValue2([
1550
+ "userId",
1551
+ "uid"
1552
+ ], sanitizeUserId);
1553
+ }
1554
+ function resolveClientIp(configValue) {
1555
+ var _sanitizePublicIp;
1556
+ return (_sanitizePublicIp = sanitizePublicIp(configValue)) !== null && _sanitizePublicIp !== void 0 ? _sanitizePublicIp : readBridgeValue2([
1557
+ "ipAddress",
1558
+ "clientIp",
1559
+ "ip"
1560
+ ], sanitizePublicIp);
1561
+ }
1249
1562
  // src/utils/vastMacros.ts
1250
1563
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
1251
1564
  var INVALID_VAST_PARAM_KEY = /^\s|\s$/;
@@ -1563,7 +1876,8 @@ var NESTED_QUERY_PARAM_KEYS = /* @__PURE__ */ new Set([
1563
1876
  var SCVP_POD_MACROS = /* @__PURE__ */ new Set([
1564
1877
  "PMND",
1565
1878
  "PMXD",
1566
- "PMAD"
1879
+ "PMAD",
1880
+ "MABD"
1567
1881
  ]);
1568
1882
  function hasScvpMacros(url) {
1569
1883
  return !!url && SCVP_MACRO_DETECT.test(url);
@@ -1608,6 +1922,8 @@ function resolveScvpMacroValues(ctx) {
1608
1922
  set("RDID", deviceId);
1609
1923
  set("IDTYPE", deviceIdType);
1610
1924
  set("IS-LAT", (_toFlag = toFlag(ctx.limitAdTracking)) !== null && _toFlag !== void 0 ? _toFlag : "0");
1925
+ set("IFA", deviceId);
1926
+ set("IFA-TYPE", toIabIfaType(deviceIdType, ctx.deviceIdSource));
1611
1927
  }
1612
1928
  set("SID", ctx.sessionId);
1613
1929
  set("DTH", ctx.deviceTypeHint);
@@ -1625,6 +1941,26 @@ function resolveScvpMacroValues(ctx) {
1625
1941
  set("GDPR", (_ctx_consent = ctx.consent) === null || _ctx_consent === void 0 ? void 0 : _ctx_consent.gdpr);
1626
1942
  set("GDPR-CONSENT", (_ctx_consent1 = ctx.consent) === null || _ctx_consent1 === void 0 ? void 0 : _ctx_consent1.gdprConsent);
1627
1943
  set("US-PRIVACY", (_ctx_consent2 = ctx.consent) === null || _ctx_consent2 === void 0 ? void 0 : _ctx_consent2.usPrivacy);
1944
+ set("PLAYER-WIDTH", ctx.playerWidth);
1945
+ set("PLAYER-HEIGHT", ctx.playerHeight);
1946
+ set("TIMESTAMP", ctx.timestamp);
1947
+ set("LIVE", toFlag(ctx.isLive));
1948
+ set("VPMT", playbackMethodCode(ctx.isCtv ? true : ctx.adWillAutoPlay, ctx.adWillPlayMuted));
1949
+ set("DEVICE-MAKE", ctx.deviceMake);
1950
+ set("DEVICE-MODEL", ctx.deviceModel);
1951
+ set("DEVICE-HWV", ctx.deviceHardwareVersion);
1952
+ set("UA", ctx.userAgent);
1953
+ set("IP", ctx.ipAddress);
1954
+ set("UID", ctx.userId);
1955
+ set("CT-TYPE", ctx.contentType);
1956
+ set("CT-CATEGORY", ctx.contentCategory);
1957
+ set("CT-GENRE", ctx.contentGenre);
1958
+ set("CT-LANGUAGE", ctx.contentLanguage);
1959
+ set("CT-DURATION", ctx.contentDurationSeconds != null ? ctx.contentDurationSeconds : ctx.isLive ? -1 : void 0);
1960
+ set("CT-SEASON", ctx.contentSeason);
1961
+ set("CT-EPISODE", ctx.contentEpisode);
1962
+ set("CT-RATING", ctx.contentRating);
1963
+ set("CT-ID", ctx.contentId);
1628
1964
  return values;
1629
1965
  }
1630
1966
  var keepNone = function keepNone() {
@@ -2511,9 +2847,30 @@ function detectBrowser() {
2511
2847
  };
2512
2848
  }
2513
2849
  var singleDecoderOverride;
2850
+ var LEARNED_SINGLE_DECODER_KEY = "stormcloud.singleDecoder.learned.v1";
2851
+ var learnedSingleDecoder;
2514
2852
  function setSingleDecoderOverride(value) {
2515
2853
  singleDecoderOverride = value;
2516
2854
  }
2855
+ function readLearnedSingleDecoder() {
2856
+ if (learnedSingleDecoder !== void 0) return learnedSingleDecoder;
2857
+ try {
2858
+ var _window_localStorage;
2859
+ learnedSingleDecoder = typeof window !== "undefined" && ((_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(LEARNED_SINGLE_DECODER_KEY)) === "1";
2860
+ } catch (unused) {
2861
+ learnedSingleDecoder = false;
2862
+ }
2863
+ return learnedSingleDecoder;
2864
+ }
2865
+ function markSingleDecoderLearned() {
2866
+ if (readLearnedSingleDecoder()) return false;
2867
+ learnedSingleDecoder = true;
2868
+ try {
2869
+ var _window_localStorage;
2870
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(LEARNED_SINGLE_DECODER_KEY, "1");
2871
+ } catch (unused) {}
2872
+ return true;
2873
+ }
2517
2874
  function requiresMediaPipelineResetAfterAds() {
2518
2875
  var _browser_tizenVersion;
2519
2876
  if (singleDecoderOverride != null) return singleDecoderOverride;
@@ -2521,6 +2878,7 @@ function requiresMediaPipelineResetAfterAds() {
2521
2878
  var globalOverride = typeof window !== "undefined" ? window.__STORMCLOUD_SINGLE_DECODER__ : void 0;
2522
2879
  if (typeof globalOverride === "boolean") return globalOverride;
2523
2880
  } catch (unused) {}
2881
+ if (readLearnedSingleDecoder()) return true;
2524
2882
  var browser = detectBrowser();
2525
2883
  return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
2526
2884
  }
@@ -2840,15 +3198,20 @@ function finalizeGamRequestUrl(rawUrl, ctx) {
2840
3198
  values.set("PMND", String(pod.pmnd));
2841
3199
  values.set("PMXD", String(pod.pmxd));
2842
3200
  if (pod.pmad != null) values.set("PMAD", String(pod.pmad));
3201
+ values.set("MABD", String(Math.max(1, Math.floor(pod.pmxd / 1e3))));
2843
3202
  }
2844
3203
  var substituted = substituteScvpMacros(rawUrl, values);
2845
3204
  var finalUrl;
2846
3205
  try {
2847
3206
  var url = new URL(normalizeVastTagUrl(substituted.url));
3207
+ var isGam = GAM_AD_HOSTS.has(url.hostname);
3208
+ var setPodParam = function setPodParam(key, value) {
3209
+ if (isGam || url.searchParams.has(key)) url.searchParams.set(key, String(value));
3210
+ };
2848
3211
  if (pod) {
2849
- url.searchParams.set("pmnd", String(pod.pmnd));
2850
- url.searchParams.set("pmxd", String(pod.pmxd));
2851
- if (pod.pmad != null) url.searchParams.set("pmad", String(pod.pmad));
3212
+ setPodParam("pmnd", pod.pmnd);
3213
+ setPodParam("pmxd", pod.pmxd);
3214
+ if (pod.pmad != null) setPodParam("pmad", pod.pmad);
2852
3215
  else url.searchParams.delete("pmad");
2853
3216
  } else {
2854
3217
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2914,7 +3277,9 @@ function validateGamRequestUrl(url, expect) {
2914
3277
  if (leftover.length > 0) problems.push("unresolved SCVP macros: ".concat(leftover.join(", ")));
2915
3278
  var params;
2916
3279
  try {
2917
- params = new URL(url).searchParams;
3280
+ var parsed = new URL(url);
3281
+ if (!GAM_AD_HOSTS.has(parsed.hostname)) return problems;
3282
+ params = parsed.searchParams;
2918
3283
  } catch (unused) {
2919
3284
  return problems.concat("URL could not be parsed");
2920
3285
  }
@@ -6335,7 +6700,7 @@ function safeCall2(fn, thisArg) {
6335
6700
  function userAgent() {
6336
6701
  return typeof navigator !== "undefined" ? navigator.userAgent || "" : "";
6337
6702
  }
6338
- function bridgeSources() {
6703
+ function bridgeSources2() {
6339
6704
  if (typeof window === "undefined") return [];
6340
6705
  var w = window;
6341
6706
  return [
@@ -6347,7 +6712,7 @@ function bridgeSources() {
6347
6712
  function readBridge(keys) {
6348
6713
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6349
6714
  try {
6350
- for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6715
+ for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6351
6716
  var source = _step.value;
6352
6717
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6353
6718
  try {
@@ -6394,6 +6759,11 @@ function readBridge(keys) {
6394
6759
  }
6395
6760
  return void 0;
6396
6761
  }
6762
+ function makeForCategory(category) {
6763
+ if (category === "LG TV" || category === "LG Set-Top Box") return "LG";
6764
+ if (category === "Samsung TV") return "Samsung";
6765
+ return void 0;
6766
+ }
6397
6767
  function normalizeCategory(value) {
6398
6768
  var v = cleanString(value);
6399
6769
  if (!v) return void 0;
@@ -6541,7 +6911,7 @@ function primeDeviceInfo() {
6541
6911
  return primePromise;
6542
6912
  }
6543
6913
  function getDeviceInfo() {
6544
- var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory;
6914
+ var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory, _ref3, _cleanString4, _cleanString5;
6545
6915
  var platform = platformCache !== null && platformCache !== void 0 ? platformCache : computePlatformInfo();
6546
6916
  if (primePromise && !platformCache) {} else {
6547
6917
  platformCache = platform;
@@ -6564,7 +6934,14 @@ function getDeviceInfo() {
6564
6934
  ]),
6565
6935
  category: normalizeCategory(readBridge([
6566
6936
  "deviceCategory"
6567
- ]))
6937
+ ])),
6938
+ make: readBridge([
6939
+ "deviceMake"
6940
+ ]),
6941
+ hardwareVersion: readBridge([
6942
+ "deviceHardwareVersion",
6943
+ "hardwareVersion"
6944
+ ])
6568
6945
  };
6569
6946
  var terminalId = (_cleanString = cleanString(host.terminalId)) !== null && _cleanString !== void 0 ? _cleanString : bridge.terminalId;
6570
6947
  var hostInternalId = (_cleanString1 = cleanString(host.internalDeviceId)) !== null && _cleanString1 !== void 0 ? _cleanString1 : bridge.internalDeviceId;
@@ -6577,7 +6954,9 @@ function getDeviceInfo() {
6577
6954
  bridge.internalDeviceId,
6578
6955
  bridge.model,
6579
6956
  bridge.firmware,
6580
- bridge.category
6957
+ bridge.category,
6958
+ bridge.make,
6959
+ bridge.hardwareVersion
6581
6960
  ];
6582
6961
  if (bridgeValues.some(function(v) {
6583
6962
  return v !== void 0;
@@ -6585,12 +6964,18 @@ function getDeviceInfo() {
6585
6964
  if (hostDeviceInfo) sources.unshift("host");
6586
6965
  var internalDeviceId = hostInternalId !== null && hostInternalId !== void 0 ? hostInternalId : platform.internalDeviceId;
6587
6966
  var internalDeviceIdSource = hostInternalId ? "host" : platform.internalDeviceIdSource;
6967
+ var make = (_ref3 = (_cleanString4 = cleanString(host.make, 40)) !== null && _cleanString4 !== void 0 ? _cleanString4 : bridge.make) !== null && _ref3 !== void 0 ? _ref3 : makeForCategory(category);
6968
+ var hardwareVersion = (_cleanString5 = cleanString(host.hardwareVersion, 40)) !== null && _cleanString5 !== void 0 ? _cleanString5 : bridge.hardwareVersion;
6588
6969
  var sonifiModel = model && category === "Samsung TV" && !/^SAMSUNG-IPTV-/i.test(model) ? "SAMSUNG-IPTV-".concat(model) : model;
6589
6970
  return _object_spread_props(_object_spread({
6590
6971
  category: category,
6591
6972
  categoryCode: CATEGORY_CODES[category]
6592
- }, model ? {
6973
+ }, make ? {
6974
+ make: make
6975
+ } : {}, model ? {
6593
6976
  model: model
6977
+ } : {}, hardwareVersion ? {
6978
+ hardwareVersion: hardwareVersion
6594
6979
  } : {}, sonifiModel ? {
6595
6980
  sonifiModel: sonifiModel
6596
6981
  } : {}, firmware ? {
@@ -6681,117 +7066,6 @@ function deviceInfoAnalyticsFields(info) {
6681
7066
  terminal_id: info.terminalId
6682
7067
  } : {});
6683
7068
  }
6684
- // src/utils/contentMetadata.ts
6685
- var MAX_CONTENT_VALUE_LENGTH = 128;
6686
- var BRIDGE_KEYS = {
6687
- channelName: [
6688
- "channelName",
6689
- "ct_ch"
6690
- ],
6691
- programTitle: [
6692
- "programTitle",
6693
- "ct_ti"
6694
- ],
6695
- contentNetwork: [
6696
- "contentNetwork",
6697
- "ct_ne"
6698
- ]
6699
- };
6700
- function sanitizeContentValue(value) {
6701
- if (typeof value !== "string") return void 0;
6702
- var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
6703
- if (!cleaned) return void 0;
6704
- if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
6705
- if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
6706
- return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
6707
- }
6708
- function bridgeSources2() {
6709
- if (typeof window === "undefined") return [];
6710
- var w = window;
6711
- return [
6712
- w.__STORMCLOUD_CTV__,
6713
- w.__STORMCLOUD_CTV_AD_INFO__,
6714
- w.stormcloudCtv
6715
- ].filter(Boolean);
6716
- }
6717
- function readBridgeContentValue(keys) {
6718
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6719
- try {
6720
- for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6721
- var source = _step.value;
6722
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6723
- try {
6724
- for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
6725
- var key = _step1.value;
6726
- var value = void 0;
6727
- try {
6728
- value = source === null || source === void 0 ? void 0 : source[key];
6729
- if (typeof value === "function") value = value.call(source);
6730
- } catch (unused) {
6731
- value = void 0;
6732
- }
6733
- var sanitized = sanitizeContentValue(value);
6734
- if (sanitized) return sanitized;
6735
- }
6736
- } catch (err) {
6737
- _didIteratorError1 = true;
6738
- _iteratorError1 = err;
6739
- } finally{
6740
- try {
6741
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
6742
- _iterator1.return();
6743
- }
6744
- } finally{
6745
- if (_didIteratorError1) {
6746
- throw _iteratorError1;
6747
- }
6748
- }
6749
- }
6750
- }
6751
- } catch (err) {
6752
- _didIteratorError = true;
6753
- _iteratorError = err;
6754
- } finally{
6755
- try {
6756
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6757
- _iterator.return();
6758
- }
6759
- } finally{
6760
- if (_didIteratorError) {
6761
- throw _iteratorError;
6762
- }
6763
- }
6764
- }
6765
- return void 0;
6766
- }
6767
- function resolveContentMetadata(config) {
6768
- var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2;
6769
- var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
6770
- var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
6771
- var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
6772
- return _object_spread({}, channelName ? {
6773
- channelName: channelName
6774
- } : {}, programTitle ? {
6775
- programTitle: programTitle
6776
- } : {}, contentNetwork ? {
6777
- contentNetwork: contentNetwork
6778
- } : {});
6779
- }
6780
- function appendMissingContentParams(url, meta) {
6781
- if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
6782
- try {
6783
- var parsed = new URL(url);
6784
- var add = function add(key, value) {
6785
- if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
6786
- };
6787
- add("ct_ch", meta.channelName);
6788
- add("ct_ti", meta.programTitle);
6789
- add("ct_ne", meta.contentNetwork);
6790
- return parsed.toString();
6791
- } catch (unused) {
6792
- return url;
6793
- }
6794
- }
6795
7069
  // src/utils/screenActivity.ts
6796
7070
  var hostStandby = false;
6797
7071
  function setHostStandby(standby) {
@@ -8793,6 +9067,13 @@ var Scte35CueManager = /*#__PURE__*/ function() {
8793
9067
  return Scte35CueManager;
8794
9068
  }();
8795
9069
  // src/player/AdConfigManager.ts
9070
+ function isGamAdUrl(rawUrl) {
9071
+ try {
9072
+ return GAM_AD_HOSTS.has(new URL(rawUrl).hostname);
9073
+ } catch (unused) {
9074
+ return false;
9075
+ }
9076
+ }
8796
9077
  function withDeferredPodParams(rawUrl, deferNonce) {
8797
9078
  try {
8798
9079
  var url = new URL(rawUrl);
@@ -8810,11 +9091,15 @@ function withDeferredPodParams(rawUrl, deferNonce) {
8810
9091
  }
8811
9092
  var AdConfigManager = /*#__PURE__*/ function() {
8812
9093
  function AdConfigManager(config, video) {
9094
+ var _this = this;
8813
9095
  _class_call_check(this, AdConfigManager);
8814
9096
  this.vmapBreaks = [];
8815
9097
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
8816
9098
  this.streamCorrelator = generateCorrelator();
8817
9099
  this.consentSignals = {};
9100
+ this.isLiveStream = function() {
9101
+ return !!_this.config.isLiveStream;
9102
+ };
8818
9103
  this.podCounter = 0;
8819
9104
  this.podAssignedByPrefetch = false;
8820
9105
  this.lastHeartbeatTime = 0;
@@ -9265,13 +9550,22 @@ var AdConfigManager = /*#__PURE__*/ function() {
9265
9550
  {
9266
9551
  key: "generatePodVastUrl",
9267
9552
  value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
9553
+ var _content_contentDurationSeconds;
9268
9554
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
9269
9555
  var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
9270
9556
  fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
9271
9557
  sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
9272
9558
  });
9273
9559
  var content = resolveContentMetadata(this.config);
9274
- var macroContext = _object_spread_props(_object_spread({
9560
+ var isLive = this.isLiveStream();
9561
+ var device = getDeviceInfo();
9562
+ var playerSize = resolvePlayerSize(this.video);
9563
+ var videoDuration = this.video.duration;
9564
+ var contentDurationSeconds = (_content_contentDurationSeconds = content.contentDurationSeconds) !== null && _content_contentDurationSeconds !== void 0 ? _content_contentDurationSeconds : !isLive && Number.isFinite(videoDuration) && videoDuration > 0 ? Math.round(videoDuration) : void 0;
9565
+ var userId = resolveUserId(this.config.adUserId);
9566
+ var ipAddress = resolveClientIp(this.config.clientIpAddress);
9567
+ var userAgent2 = typeof navigator !== "undefined" && navigator.userAgent ? navigator.userAgent : void 0;
9568
+ var macroContext = _object_spread(_object_spread_props(_object_spread(_object_spread_props(_object_spread({
9275
9569
  correlator: this.viewCorrelator,
9276
9570
  streamCorrelator: this.streamCorrelator,
9277
9571
  pod: this.podCounter > 0 ? this.podCounter : void 0,
@@ -9293,8 +9587,46 @@ var AdConfigManager = /*#__PURE__*/ function() {
9293
9587
  contentNetwork: content.contentNetwork
9294
9588
  } : {}), {
9295
9589
  consent: this.consentSignals,
9296
- palNonce: palNonce.getCurrentNonce() || void 0
9297
- });
9590
+ palNonce: palNonce.getCurrentNonce() || void 0,
9591
+ deviceIdSource: envSignals.deviceIdSource,
9592
+ isLive: isLive
9593
+ }), playerSize.width ? {
9594
+ playerWidth: playerSize.width
9595
+ } : {}, playerSize.height ? {
9596
+ playerHeight: playerSize.height
9597
+ } : {}), {
9598
+ timestamp: String(Date.now())
9599
+ }), device.make ? {
9600
+ deviceMake: device.make
9601
+ } : {}, device.model ? {
9602
+ deviceModel: device.model
9603
+ } : {}, device.hardwareVersion ? {
9604
+ deviceHardwareVersion: device.hardwareVersion
9605
+ } : {}, userAgent2 ? {
9606
+ userAgent: userAgent2
9607
+ } : {}, ipAddress ? {
9608
+ ipAddress: ipAddress
9609
+ } : {}, userId ? {
9610
+ userId: userId
9611
+ } : {}, content.contentType ? {
9612
+ contentType: content.contentType
9613
+ } : {}, content.contentCategory ? {
9614
+ contentCategory: content.contentCategory
9615
+ } : {}, content.contentGenre ? {
9616
+ contentGenre: content.contentGenre
9617
+ } : {}, content.contentLanguage ? {
9618
+ contentLanguage: content.contentLanguage
9619
+ } : {}, contentDurationSeconds != null ? {
9620
+ contentDurationSeconds: contentDurationSeconds
9621
+ } : {}, content.contentSeason ? {
9622
+ contentSeason: content.contentSeason
9623
+ } : {}, content.contentEpisode ? {
9624
+ contentEpisode: content.contentEpisode
9625
+ } : {}, content.contentRating ? {
9626
+ contentRating: content.contentRating
9627
+ } : {}, content.contentId ? {
9628
+ contentId: content.contentId
9629
+ } : {});
9298
9630
  var nonceReady = !!macroContext.palNonce;
9299
9631
  var finalUrl;
9300
9632
  if (hasScvpMacros(baseUrl)) {
@@ -9308,9 +9640,11 @@ var AdConfigManager = /*#__PURE__*/ function() {
9308
9640
  } else {
9309
9641
  finalUrl = withDeferredPodParams(palNonce.injectNonce(ensureVideoAdType(applyVastMacros(baseUrl, macroContext))), !nonceReady);
9310
9642
  }
9311
- finalUrl = appendMissingContentParams(finalUrl, content);
9312
- if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9313
- finalUrl = applyDeviceKeyValues(finalUrl, getDeviceInfo());
9643
+ if (isGamAdUrl(finalUrl)) {
9644
+ finalUrl = appendMissingContentParams(finalUrl, content);
9645
+ if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9646
+ finalUrl = applyDeviceKeyValues(finalUrl, device);
9647
+ }
9314
9648
  }
9315
9649
  if (this.debug) {
9316
9650
  var id = envSignals.deviceId;
@@ -9323,7 +9657,13 @@ var AdConfigManager = /*#__PURE__*/ function() {
9323
9657
  sidTail: envSignals.sessionId ? envSignals.sessionId.slice(-4) : void 0,
9324
9658
  ct_ch: content.channelName,
9325
9659
  ct_ti: content.programTitle,
9326
- ct_ne: content.contentNetwork
9660
+ ct_ne: content.contentNetwork,
9661
+ rating: content.contentRating,
9662
+ ifaType: toIabIfaType(envSignals.deviceIdType, envSignals.deviceIdSource),
9663
+ live: isLive,
9664
+ player: playerSize,
9665
+ make: device.make,
9666
+ model: device.model
9327
9667
  });
9328
9668
  }
9329
9669
  console.log("[StormcloudVideoPlayer] Prepared optimized-pod request URL (pod=".concat(this.podCounter, "; pmnd/pmxd/pmad resolved at dispatch):"), finalUrl);
@@ -11002,6 +11342,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11002
11342
  this.adDetectSentForCurrentBreak = false;
11003
11343
  this.slotState = "IDLE";
11004
11344
  this.unusableResponsesInBreak = 0;
11345
+ this.playedAdIdsInBreak = /* @__PURE__ */ new Set();
11005
11346
  this.controllerGeneration = 0;
11006
11347
  this.requestDiagnostics = /* @__PURE__ */ new Map();
11007
11348
  this.breakFunnel = {};
@@ -11098,6 +11439,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11098
11439
  _this.recordRequestDiagnostic(payload);
11099
11440
  });
11100
11441
  adPlayer.on("ad_impression", function() {
11442
+ var _this_host_getAdPlayer_getLoadedAdId, _this_host_getAdPlayer;
11443
+ 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);
11444
+ if (impressionAdId != null && impressionAdId !== "") {
11445
+ _this.playedAdIdsInBreak.add(String(impressionAdId));
11446
+ }
11101
11447
  _this.timing.consecutiveFailures = 0;
11102
11448
  _this.setSlotState("PLAYING", "impression");
11103
11449
  if (!_this.playbackStartedForCurrentRequest) {
@@ -11289,6 +11635,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11289
11635
  this.resetEdgeStateForBreak();
11290
11636
  this.followUpBaseVastUrl = void 0;
11291
11637
  this.unusableResponsesInBreak = 0;
11638
+ this.playedAdIdsInBreak.clear();
11292
11639
  this.timing.totalAdRequestsInBreak = 0;
11293
11640
  this.setSlotState("NEEDS_NEXT_AD", "vmap_break_start");
11294
11641
  this.noteOpportunity("vmap", breakKey, position);
@@ -11339,6 +11686,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11339
11686
  this.breakSource = "scte35";
11340
11687
  this.followUpBaseVastUrl = baseVastUrl;
11341
11688
  this.unusableResponsesInBreak = 0;
11689
+ this.playedAdIdsInBreak.clear();
11342
11690
  this.resetEdgeStateForBreak();
11343
11691
  this.setSlotState("NEEDS_NEXT_AD", "scte35_break_start");
11344
11692
  if (this.adConfig.podAssignedByPrefetch) {
@@ -12178,6 +12526,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12178
12526
  var outcome;
12179
12527
  if (message.includes("ad_duration_exceeds_budget")) {
12180
12528
  outcome = "discarded_budget";
12529
+ } else if (message.includes("ad_repeated_in_break")) {
12530
+ outcome = "discarded_duplicate";
12181
12531
  } else if (message.includes("VAST fill rejected")) {
12182
12532
  outcome = "fill_rejected";
12183
12533
  } else if (/no ads available|no fill|nofill/i.test(message)) {
@@ -12192,7 +12542,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12192
12542
  outcome = "request_failed";
12193
12543
  }
12194
12544
  this.timing.consecutiveFailures++;
12195
- if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget") {
12545
+ if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget" || outcome === "discarded_duplicate") {
12196
12546
  this.unusableResponsesInBreak++;
12197
12547
  }
12198
12548
  if (outcome === "no_fill") {
@@ -12206,7 +12556,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12206
12556
  }) ? diag.dispatchedUrl : vastTagUrl;
12207
12557
  if (this.timing.isTemporaryAdError(error)) {
12208
12558
  this.timing.temporaryFailureUrls.set(failureKey, Date.now());
12209
- } else if (outcome !== "discarded_budget") {
12559
+ } else if (outcome !== "discarded_budget" && outcome !== "discarded_duplicate") {
12210
12560
  this.timing.failedVastUrls.add(failureKey);
12211
12561
  }
12212
12562
  this.countFunnelStage("request_outcome:".concat(outcome));
@@ -12578,7 +12928,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12578
12928
  value: function playSingleAd(vastTagUrl) {
12579
12929
  var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
12580
12930
  return _async_to_generator(function() {
12581
- var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, finalizeRequestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
12931
+ var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, _ref, _ap_getLoadedAdId, _ap_getPodAdCount, finalizeRequestUrl, loadedAdId, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
12582
12932
  return _ts_generator(this, function(_state) {
12583
12933
  switch(_state.label){
12584
12934
  case 0:
@@ -12691,6 +13041,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12691
13041
  vastUrl: (_this_currentVastUrl = this.currentVastUrl) !== null && _this_currentVastUrl !== void 0 ? _this_currentVastUrl : requestUrl,
12692
13042
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
12693
13043
  }, this.analyticsContext).catch(function() {});
13044
+ loadedAdId = (_ap_getLoadedAdId = ap.getLoadedAdId) === null || _ap_getLoadedAdId === void 0 ? void 0 : _ap_getLoadedAdId.call(ap);
13045
+ 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))) {
13046
+ if (this.debug) {
13047
+ console.log("[AD-DURATION] Rejected ad id=".concat(loadedAdId, ": already played in this break — requesting another ad"));
13048
+ }
13049
+ this.logOrchestratorFunnel("discarded_duplicate", {
13050
+ adId: String(loadedAdId)
13051
+ });
13052
+ throw new Error("ad_repeated_in_break");
13053
+ }
12694
13054
  if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
12695
13055
  ;
12696
13056
  adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
@@ -12744,6 +13104,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12744
13104
  this.recordRequestFailure(error, vastTagUrl);
12745
13105
  if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
12746
13106
  this.recreateAdController("discarded_budget");
13107
+ } else if ((error === null || error === void 0 ? void 0 : error.message) === "ad_repeated_in_break") {
13108
+ this.recreateAdController("discarded_duplicate");
12747
13109
  }
12748
13110
  throw error;
12749
13111
  case 10:
@@ -12817,6 +13179,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12817
13179
  tagAllowsAudio: count("tag_allows_audio"),
12818
13180
  missingImpression: count("vast_missing_impression"),
12819
13181
  discardedBudget: count("discarded_budget"),
13182
+ discardedDuplicate: count("discarded_duplicate"),
12820
13183
  mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
12821
13184
  mediaRejected: count("media_candidate:rejected"),
12822
13185
  mediaFallbacks: count("media_fallback"),
@@ -12892,6 +13255,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12892
13255
  this.breakSource = void 0;
12893
13256
  this.followUpBaseVastUrl = void 0;
12894
13257
  this.unusableResponsesInBreak = 0;
13258
+ this.playedAdIdsInBreak.clear();
12895
13259
  this.resetEdgeStateForBreak();
12896
13260
  adPlayer.stop().catch(function() {});
12897
13261
  if (!alreadyEnded) this.logBreakFunnel(reason);
@@ -12992,9 +13356,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12992
13356
  var maxMonitorMs = 45e3;
12993
13357
  var startTime = Date.now();
12994
13358
  var baseline = resumeBaseline;
13359
+ var lastSeenTime = resumeBaseline;
12995
13360
  var recoveries = 0;
12996
13361
  var lastRecoveryAt = 0;
12997
13362
  var video = this.host.video;
13363
+ var onDecodeError = function onDecodeError() {
13364
+ var _video_error;
13365
+ if (needsReset || ((_video_error = video.error) === null || _video_error === void 0 ? void 0 : _video_error.code) !== 3) return;
13366
+ if (markSingleDecoderLearned() && _this.debug) {
13367
+ console.warn("[StormcloudVideoPlayer] Decoder error while resuming after ads \u2014 using single-decoder mode on this device from the next break");
13368
+ }
13369
+ };
13370
+ video.addEventListener("error", onDecodeError);
12998
13371
  var listenersAttached = false;
12999
13372
  var onMediaEvent;
13000
13373
  var diagEvents = [
@@ -13044,6 +13417,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13044
13417
  console.log("[ResumeDiag] +0.0s monitor start — ".concat(this.describeVideoState()));
13045
13418
  }
13046
13419
  var cleanup = function cleanup() {
13420
+ video.removeEventListener("error", onDecodeError);
13047
13421
  if (listenersAttached && onMediaEvent) {
13048
13422
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
13049
13423
  try {
@@ -13074,6 +13448,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13074
13448
  return;
13075
13449
  }
13076
13450
  var currentTime = video.currentTime;
13451
+ if (currentTime + 1 < lastSeenTime) {
13452
+ baseline = currentTime;
13453
+ }
13454
+ lastSeenTime = currentTime;
13077
13455
  var advanced = currentTime > baseline + 0.5;
13078
13456
  var playing = !video.paused && video.readyState >= 3;
13079
13457
  if (advanced && playing) {
@@ -13494,6 +13872,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13494
13872
  return !!_this.adBreak && _this.adBreak.inAdBreak && !_this.shouldContinueLiveStreamDuringAds();
13495
13873
  }
13496
13874
  });
13875
+ this.adConfig.isLiveStream = function() {
13876
+ return _this.hlsEngine.isLiveStream;
13877
+ };
13497
13878
  this.adBreak = new AdBreakOrchestrator({
13498
13879
  config: this.config,
13499
13880
  video: this.video,
@@ -13855,16 +14236,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13855
14236
  {
13856
14237
  key: "setContentMetadata",
13857
14238
  value: function setContentMetadata(meta) {
13858
- var _this = this;
13859
- var apply = function apply(key, value) {
13860
- if (value === void 0) return;
13861
- var clean = value === null ? void 0 : sanitizeContentValue(value);
13862
- if (clean) _this.config[key] = clean;
13863
- else delete _this.config[key];
13864
- };
13865
- apply("channelName", meta.channelName);
13866
- apply("programTitle", meta.programTitle);
13867
- apply("contentNetwork", meta.contentNetwork);
14239
+ applyContentMetadataUpdate(this.config, meta);
14240
+ }
14241
+ },
14242
+ {
14243
+ key: "setRequestSignals",
14244
+ value: function setRequestSignals(signals) {
14245
+ if (signals.userId !== void 0) {
14246
+ if (signals.userId) this.config.adUserId = signals.userId;
14247
+ else delete this.config.adUserId;
14248
+ }
14249
+ if (signals.ipAddress !== void 0) {
14250
+ if (signals.ipAddress) this.config.clientIpAddress = signals.ipAddress;
14251
+ else delete this.config.clientIpAddress;
14252
+ }
13868
14253
  }
13869
14254
  },
13870
14255
  {