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
package/lib/index.js CHANGED
@@ -1227,6 +1227,319 @@ function normalizeBoolean(value) {
1227
1227
  }
1228
1228
  return void 0;
1229
1229
  }
1230
+ // src/utils/contentMetadata.ts
1231
+ var MAX_CONTENT_VALUE_LENGTH = 128;
1232
+ var BRIDGE_KEYS = {
1233
+ channelName: [
1234
+ "channelName",
1235
+ "ct_ch"
1236
+ ],
1237
+ programTitle: [
1238
+ "programTitle",
1239
+ "ct_ti"
1240
+ ],
1241
+ contentNetwork: [
1242
+ "contentNetwork",
1243
+ "ct_ne"
1244
+ ],
1245
+ contentType: [
1246
+ "contentType",
1247
+ "ctt"
1248
+ ],
1249
+ contentCategory: [
1250
+ "contentCategory",
1251
+ "ctc"
1252
+ ],
1253
+ contentGenre: [
1254
+ "contentGenre",
1255
+ "ctgr"
1256
+ ],
1257
+ contentLanguage: [
1258
+ "contentLanguage",
1259
+ "ctlg"
1260
+ ],
1261
+ contentDuration: [
1262
+ "contentDuration",
1263
+ "ctd"
1264
+ ],
1265
+ contentSeason: [
1266
+ "contentSeason",
1267
+ "cts"
1268
+ ],
1269
+ contentEpisode: [
1270
+ "contentEpisode",
1271
+ "cte"
1272
+ ],
1273
+ contentRating: [
1274
+ "contentRating",
1275
+ "ctr",
1276
+ "programRating",
1277
+ "rating"
1278
+ ],
1279
+ contentId: [
1280
+ "contentId",
1281
+ "ctid"
1282
+ ]
1283
+ };
1284
+ function sanitizeContentValue(value) {
1285
+ if (typeof value !== "string") return void 0;
1286
+ var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1287
+ if (!cleaned) return void 0;
1288
+ if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
1289
+ if (/^(unknown|null|undefined|none|n\/a|-|tbd|tba|to be (announced|determined))$/i.test(cleaned)) {
1290
+ return void 0;
1291
+ }
1292
+ return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
1293
+ }
1294
+ function sanitizeContentScalar(value) {
1295
+ if (typeof value === "number") {
1296
+ return Number.isFinite(value) ? String(value) : void 0;
1297
+ }
1298
+ return sanitizeContentValue(value);
1299
+ }
1300
+ function normalizeContentLanguage(value) {
1301
+ var cleaned = sanitizeContentValue(value);
1302
+ if (!cleaned) return void 0;
1303
+ var match = cleaned.match(/^([A-Za-z]{2})(?:[-_][A-Za-z0-9]{1,8})*$/);
1304
+ return match && match[1] ? match[1].toLowerCase() : void 0;
1305
+ }
1306
+ function normalizeContentDuration(value) {
1307
+ var raw = sanitizeContentScalar(value);
1308
+ if (raw == null || !/^-?\d+(\.\d+)?$/.test(raw)) return void 0;
1309
+ var seconds = Number(raw);
1310
+ if (seconds === -1) return -1;
1311
+ return seconds > 0 ? Math.round(seconds) : void 0;
1312
+ }
1313
+ function bridgeSources() {
1314
+ if (typeof window === "undefined") return [];
1315
+ var w = window;
1316
+ return [
1317
+ w.__STORMCLOUD_CTV__,
1318
+ w.__STORMCLOUD_CTV_AD_INFO__,
1319
+ w.stormcloudCtv
1320
+ ].filter(Boolean);
1321
+ }
1322
+ function readBridgeValue2(keys, sanitize) {
1323
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1324
+ try {
1325
+ for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1326
+ var source = _step.value;
1327
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
1328
+ try {
1329
+ for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
1330
+ var key = _step1.value;
1331
+ var value = void 0;
1332
+ try {
1333
+ value = source === null || source === void 0 ? void 0 : source[key];
1334
+ if (typeof value === "function") value = value.call(source);
1335
+ } catch (unused) {
1336
+ value = void 0;
1337
+ }
1338
+ var sanitized = sanitize(value);
1339
+ if (sanitized != null) return sanitized;
1340
+ }
1341
+ } catch (err) {
1342
+ _didIteratorError1 = true;
1343
+ _iteratorError1 = err;
1344
+ } finally{
1345
+ try {
1346
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
1347
+ _iterator1.return();
1348
+ }
1349
+ } finally{
1350
+ if (_didIteratorError1) {
1351
+ throw _iteratorError1;
1352
+ }
1353
+ }
1354
+ }
1355
+ }
1356
+ } catch (err) {
1357
+ _didIteratorError = true;
1358
+ _iteratorError = err;
1359
+ } finally{
1360
+ try {
1361
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1362
+ _iterator.return();
1363
+ }
1364
+ } finally{
1365
+ if (_didIteratorError) {
1366
+ throw _iteratorError;
1367
+ }
1368
+ }
1369
+ }
1370
+ return void 0;
1371
+ }
1372
+ function readBridgeContentValue(keys) {
1373
+ return readBridgeValue2(keys, sanitizeContentValue);
1374
+ }
1375
+ function resolveContentMetadata(config) {
1376
+ var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2, _config_contentDetails, _sanitizeContentValue3, _sanitizeContentValue4, _sanitizeContentValue5, _normalizeContentLanguage, _normalizeContentDuration, _sanitizeContentScalar, _sanitizeContentScalar1, _sanitizeContentValue6, _sanitizeContentValue7;
1377
+ var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
1378
+ var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
1379
+ var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
1380
+ var details = (_config_contentDetails = config.contentDetails) !== null && _config_contentDetails !== void 0 ? _config_contentDetails : {};
1381
+ var contentType = (_sanitizeContentValue3 = sanitizeContentValue(details.contentType)) !== null && _sanitizeContentValue3 !== void 0 ? _sanitizeContentValue3 : readBridgeContentValue(BRIDGE_KEYS.contentType);
1382
+ var contentCategory = (_sanitizeContentValue4 = sanitizeContentValue(details.category)) !== null && _sanitizeContentValue4 !== void 0 ? _sanitizeContentValue4 : readBridgeContentValue(BRIDGE_KEYS.contentCategory);
1383
+ var contentGenre = (_sanitizeContentValue5 = sanitizeContentValue(details.genre)) !== null && _sanitizeContentValue5 !== void 0 ? _sanitizeContentValue5 : readBridgeContentValue(BRIDGE_KEYS.contentGenre);
1384
+ var contentLanguage = (_normalizeContentLanguage = normalizeContentLanguage(details.language)) !== null && _normalizeContentLanguage !== void 0 ? _normalizeContentLanguage : readBridgeValue2(BRIDGE_KEYS.contentLanguage, normalizeContentLanguage);
1385
+ var contentDurationSeconds = (_normalizeContentDuration = normalizeContentDuration(details.durationSeconds)) !== null && _normalizeContentDuration !== void 0 ? _normalizeContentDuration : readBridgeValue2(BRIDGE_KEYS.contentDuration, normalizeContentDuration);
1386
+ var contentSeason = (_sanitizeContentScalar = sanitizeContentScalar(details.season)) !== null && _sanitizeContentScalar !== void 0 ? _sanitizeContentScalar : readBridgeValue2(BRIDGE_KEYS.contentSeason, sanitizeContentScalar);
1387
+ var contentEpisode = (_sanitizeContentScalar1 = sanitizeContentScalar(details.episode)) !== null && _sanitizeContentScalar1 !== void 0 ? _sanitizeContentScalar1 : readBridgeValue2(BRIDGE_KEYS.contentEpisode, sanitizeContentScalar);
1388
+ var contentRating = (_sanitizeContentValue6 = sanitizeContentValue(details.rating)) !== null && _sanitizeContentValue6 !== void 0 ? _sanitizeContentValue6 : readBridgeContentValue(BRIDGE_KEYS.contentRating);
1389
+ var contentId = (_sanitizeContentValue7 = sanitizeContentValue(details.contentId)) !== null && _sanitizeContentValue7 !== void 0 ? _sanitizeContentValue7 : readBridgeContentValue(BRIDGE_KEYS.contentId);
1390
+ return _object_spread({}, channelName ? {
1391
+ channelName: channelName
1392
+ } : {}, programTitle ? {
1393
+ programTitle: programTitle
1394
+ } : {}, contentNetwork ? {
1395
+ contentNetwork: contentNetwork
1396
+ } : {}, contentType ? {
1397
+ contentType: contentType
1398
+ } : {}, contentCategory ? {
1399
+ contentCategory: contentCategory
1400
+ } : {}, contentGenre ? {
1401
+ contentGenre: contentGenre
1402
+ } : {}, contentLanguage ? {
1403
+ contentLanguage: contentLanguage
1404
+ } : {}, contentDurationSeconds != null ? {
1405
+ contentDurationSeconds: contentDurationSeconds
1406
+ } : {}, contentSeason ? {
1407
+ contentSeason: contentSeason
1408
+ } : {}, contentEpisode ? {
1409
+ contentEpisode: contentEpisode
1410
+ } : {}, contentRating ? {
1411
+ contentRating: contentRating
1412
+ } : {}, contentId ? {
1413
+ contentId: contentId
1414
+ } : {});
1415
+ }
1416
+ function applyContentMetadataUpdate(target, meta) {
1417
+ var _target_contentDetails;
1418
+ var apply = function apply(key, value) {
1419
+ if (value === void 0) return;
1420
+ var clean = value === null ? void 0 : sanitizeContentValue(value);
1421
+ if (clean) target[key] = clean;
1422
+ else delete target[key];
1423
+ };
1424
+ apply("channelName", meta.channelName);
1425
+ apply("programTitle", meta.programTitle);
1426
+ apply("contentNetwork", meta.contentNetwork);
1427
+ if (meta.details === null) delete target.contentDetails;
1428
+ else if (meta.details !== void 0) target.contentDetails = _object_spread({}, meta.details);
1429
+ var rating = meta.programRating !== void 0 ? meta.programRating : meta.contentRating;
1430
+ if (rating === void 0) return;
1431
+ var cleanRating = rating === null ? void 0 : sanitizeContentValue(rating);
1432
+ var details = _object_spread({}, (_target_contentDetails = target.contentDetails) !== null && _target_contentDetails !== void 0 ? _target_contentDetails : {});
1433
+ if (cleanRating) details.rating = cleanRating;
1434
+ else delete details.rating;
1435
+ target.contentDetails = details;
1436
+ }
1437
+ function appendMissingContentParams(url, meta) {
1438
+ if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
1439
+ try {
1440
+ var parsed = new URL(url);
1441
+ var add = function add(key, value) {
1442
+ if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
1443
+ };
1444
+ add("ct_ch", meta.channelName);
1445
+ add("ct_ti", meta.programTitle);
1446
+ add("ct_ne", meta.contentNetwork);
1447
+ return parsed.toString();
1448
+ } catch (unused) {
1449
+ return url;
1450
+ }
1451
+ }
1452
+ // src/utils/partnerSignals.ts
1453
+ var PLATFORM_IFA_TYPES = /* @__PURE__ */ new Set([
1454
+ "aaid",
1455
+ "adid",
1456
+ "afai",
1457
+ "idfa",
1458
+ "lgudid",
1459
+ "msai",
1460
+ "rida",
1461
+ "tifa",
1462
+ "tvos",
1463
+ "vaid",
1464
+ "vida"
1465
+ ]);
1466
+ function toIabIfaType(deviceIdType, source) {
1467
+ if (!deviceIdType) return void 0;
1468
+ var type = deviceIdType.trim().toLowerCase();
1469
+ if (source === "generated") return "sessionid";
1470
+ if (PLATFORM_IFA_TYPES.has(type)) return type;
1471
+ if (source === "platform") return "dpid";
1472
+ return "ppid";
1473
+ }
1474
+ function playbackMethodCode(autoPlay, muted) {
1475
+ if (autoPlay === false) return 3;
1476
+ if (autoPlay !== true || muted == null) return void 0;
1477
+ return muted ? 2 : 1;
1478
+ }
1479
+ function resolvePlayerSize(video) {
1480
+ var width = video ? video.clientWidth : 0;
1481
+ var height = video ? video.clientHeight : 0;
1482
+ if (!(width > 0 && height > 0) && typeof window !== "undefined") {
1483
+ width = window.innerWidth;
1484
+ height = window.innerHeight;
1485
+ }
1486
+ if (!(width > 0 && height > 0)) return {};
1487
+ return {
1488
+ width: Math.round(width),
1489
+ height: Math.round(height)
1490
+ };
1491
+ }
1492
+ function sanitizeUserId(value) {
1493
+ var cleaned = sanitizeContentValue(value);
1494
+ if (!cleaned || /\s/.test(cleaned)) return void 0;
1495
+ return cleaned;
1496
+ }
1497
+ function isPublicIpv4(ip) {
1498
+ var parts = ip.split(".");
1499
+ if (parts.length !== 4) return false;
1500
+ var nums = parts.map(function(p) {
1501
+ return /^\d{1,3}$/.test(p) ? Number(p) : NaN;
1502
+ });
1503
+ if (nums.some(function(n) {
1504
+ return !(n >= 0 && n <= 255);
1505
+ })) return false;
1506
+ var _nums = _sliced_to_array(nums, 2), a = _nums[0], b = _nums[1];
1507
+ if (a === 0 || a === 10 || a === 127 || a >= 224) return false;
1508
+ if (a === 100 && b >= 64 && b <= 127) return false;
1509
+ if (a === 169 && b === 254) return false;
1510
+ if (a === 172 && b >= 16 && b <= 31) return false;
1511
+ if (a === 192 && b === 168) return false;
1512
+ return true;
1513
+ }
1514
+ function isPublicIpv6(ip) {
1515
+ var lower = ip.toLowerCase();
1516
+ if (!/^[0-9a-f:]+$/.test(lower) || lower.split(":").length < 3) return false;
1517
+ if (lower === "::" || lower === "::1") return false;
1518
+ if (/^fe[89ab]/.test(lower)) return false;
1519
+ if (/^f[cd]/.test(lower)) return false;
1520
+ return true;
1521
+ }
1522
+ function sanitizePublicIp(value) {
1523
+ var cleaned = sanitizeContentValue(value);
1524
+ if (!cleaned) return void 0;
1525
+ if (cleaned.includes(".")) return isPublicIpv4(cleaned) ? cleaned : void 0;
1526
+ return isPublicIpv6(cleaned) ? cleaned : void 0;
1527
+ }
1528
+ function resolveUserId(configValue) {
1529
+ var _sanitizeUserId;
1530
+ return (_sanitizeUserId = sanitizeUserId(configValue)) !== null && _sanitizeUserId !== void 0 ? _sanitizeUserId : readBridgeValue2([
1531
+ "userId",
1532
+ "uid"
1533
+ ], sanitizeUserId);
1534
+ }
1535
+ function resolveClientIp(configValue) {
1536
+ var _sanitizePublicIp;
1537
+ return (_sanitizePublicIp = sanitizePublicIp(configValue)) !== null && _sanitizePublicIp !== void 0 ? _sanitizePublicIp : readBridgeValue2([
1538
+ "ipAddress",
1539
+ "clientIp",
1540
+ "ip"
1541
+ ], sanitizePublicIp);
1542
+ }
1230
1543
  // src/utils/vastMacros.ts
1231
1544
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
1232
1545
  var INVALID_VAST_PARAM_KEY = /^\s|\s$/;
@@ -1544,7 +1857,8 @@ var NESTED_QUERY_PARAM_KEYS = /* @__PURE__ */ new Set([
1544
1857
  var SCVP_POD_MACROS = /* @__PURE__ */ new Set([
1545
1858
  "PMND",
1546
1859
  "PMXD",
1547
- "PMAD"
1860
+ "PMAD",
1861
+ "MABD"
1548
1862
  ]);
1549
1863
  function hasScvpMacros(url) {
1550
1864
  return !!url && SCVP_MACRO_DETECT.test(url);
@@ -1589,6 +1903,8 @@ function resolveScvpMacroValues(ctx) {
1589
1903
  set("RDID", deviceId);
1590
1904
  set("IDTYPE", deviceIdType);
1591
1905
  set("IS-LAT", (_toFlag = toFlag(ctx.limitAdTracking)) !== null && _toFlag !== void 0 ? _toFlag : "0");
1906
+ set("IFA", deviceId);
1907
+ set("IFA-TYPE", toIabIfaType(deviceIdType, ctx.deviceIdSource));
1592
1908
  }
1593
1909
  set("SID", ctx.sessionId);
1594
1910
  set("DTH", ctx.deviceTypeHint);
@@ -1606,6 +1922,26 @@ function resolveScvpMacroValues(ctx) {
1606
1922
  set("GDPR", (_ctx_consent = ctx.consent) === null || _ctx_consent === void 0 ? void 0 : _ctx_consent.gdpr);
1607
1923
  set("GDPR-CONSENT", (_ctx_consent1 = ctx.consent) === null || _ctx_consent1 === void 0 ? void 0 : _ctx_consent1.gdprConsent);
1608
1924
  set("US-PRIVACY", (_ctx_consent2 = ctx.consent) === null || _ctx_consent2 === void 0 ? void 0 : _ctx_consent2.usPrivacy);
1925
+ set("PLAYER-WIDTH", ctx.playerWidth);
1926
+ set("PLAYER-HEIGHT", ctx.playerHeight);
1927
+ set("TIMESTAMP", ctx.timestamp);
1928
+ set("LIVE", toFlag(ctx.isLive));
1929
+ set("VPMT", playbackMethodCode(ctx.isCtv ? true : ctx.adWillAutoPlay, ctx.adWillPlayMuted));
1930
+ set("DEVICE-MAKE", ctx.deviceMake);
1931
+ set("DEVICE-MODEL", ctx.deviceModel);
1932
+ set("DEVICE-HWV", ctx.deviceHardwareVersion);
1933
+ set("UA", ctx.userAgent);
1934
+ set("IP", ctx.ipAddress);
1935
+ set("UID", ctx.userId);
1936
+ set("CT-TYPE", ctx.contentType);
1937
+ set("CT-CATEGORY", ctx.contentCategory);
1938
+ set("CT-GENRE", ctx.contentGenre);
1939
+ set("CT-LANGUAGE", ctx.contentLanguage);
1940
+ set("CT-DURATION", ctx.contentDurationSeconds != null ? ctx.contentDurationSeconds : ctx.isLive ? -1 : void 0);
1941
+ set("CT-SEASON", ctx.contentSeason);
1942
+ set("CT-EPISODE", ctx.contentEpisode);
1943
+ set("CT-RATING", ctx.contentRating);
1944
+ set("CT-ID", ctx.contentId);
1609
1945
  return values;
1610
1946
  }
1611
1947
  var keepNone = function keepNone() {
@@ -2502,9 +2838,30 @@ function detectBrowser() {
2502
2838
  };
2503
2839
  }
2504
2840
  var singleDecoderOverride;
2841
+ var LEARNED_SINGLE_DECODER_KEY = "stormcloud.singleDecoder.learned.v1";
2842
+ var learnedSingleDecoder;
2505
2843
  function setSingleDecoderOverride(value) {
2506
2844
  singleDecoderOverride = value;
2507
2845
  }
2846
+ function readLearnedSingleDecoder() {
2847
+ if (learnedSingleDecoder !== void 0) return learnedSingleDecoder;
2848
+ try {
2849
+ var _window_localStorage;
2850
+ learnedSingleDecoder = typeof window !== "undefined" && ((_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(LEARNED_SINGLE_DECODER_KEY)) === "1";
2851
+ } catch (unused) {
2852
+ learnedSingleDecoder = false;
2853
+ }
2854
+ return learnedSingleDecoder;
2855
+ }
2856
+ function markSingleDecoderLearned() {
2857
+ if (readLearnedSingleDecoder()) return false;
2858
+ learnedSingleDecoder = true;
2859
+ try {
2860
+ var _window_localStorage;
2861
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(LEARNED_SINGLE_DECODER_KEY, "1");
2862
+ } catch (unused) {}
2863
+ return true;
2864
+ }
2508
2865
  function requiresMediaPipelineResetAfterAds() {
2509
2866
  var _browser_tizenVersion;
2510
2867
  if (singleDecoderOverride != null) return singleDecoderOverride;
@@ -2512,6 +2869,7 @@ function requiresMediaPipelineResetAfterAds() {
2512
2869
  var globalOverride = typeof window !== "undefined" ? window.__STORMCLOUD_SINGLE_DECODER__ : void 0;
2513
2870
  if (typeof globalOverride === "boolean") return globalOverride;
2514
2871
  } catch (unused) {}
2872
+ if (readLearnedSingleDecoder()) return true;
2515
2873
  var browser = detectBrowser();
2516
2874
  return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
2517
2875
  }
@@ -2854,15 +3212,20 @@ function finalizeGamRequestUrl(rawUrl, ctx) {
2854
3212
  values.set("PMND", String(pod.pmnd));
2855
3213
  values.set("PMXD", String(pod.pmxd));
2856
3214
  if (pod.pmad != null) values.set("PMAD", String(pod.pmad));
3215
+ values.set("MABD", String(Math.max(1, Math.floor(pod.pmxd / 1e3))));
2857
3216
  }
2858
3217
  var substituted = substituteScvpMacros(rawUrl, values);
2859
3218
  var finalUrl;
2860
3219
  try {
2861
3220
  var url = new URL(normalizeVastTagUrl(substituted.url));
3221
+ var isGam = GAM_AD_HOSTS.has(url.hostname);
3222
+ var setPodParam = function setPodParam(key, value) {
3223
+ if (isGam || url.searchParams.has(key)) url.searchParams.set(key, String(value));
3224
+ };
2862
3225
  if (pod) {
2863
- url.searchParams.set("pmnd", String(pod.pmnd));
2864
- url.searchParams.set("pmxd", String(pod.pmxd));
2865
- if (pod.pmad != null) url.searchParams.set("pmad", String(pod.pmad));
3226
+ setPodParam("pmnd", pod.pmnd);
3227
+ setPodParam("pmxd", pod.pmxd);
3228
+ if (pod.pmad != null) setPodParam("pmad", pod.pmad);
2866
3229
  else url.searchParams.delete("pmad");
2867
3230
  } else {
2868
3231
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2928,7 +3291,9 @@ function validateGamRequestUrl(url, expect) {
2928
3291
  if (leftover.length > 0) problems.push("unresolved SCVP macros: ".concat(leftover.join(", ")));
2929
3292
  var params;
2930
3293
  try {
2931
- params = new URL(url).searchParams;
3294
+ var parsed = new URL(url);
3295
+ if (!GAM_AD_HOSTS.has(parsed.hostname)) return problems;
3296
+ params = parsed.searchParams;
2932
3297
  } catch (unused) {
2933
3298
  return problems.concat("URL could not be parsed");
2934
3299
  }
@@ -6349,7 +6714,7 @@ function safeCall2(fn, thisArg) {
6349
6714
  function userAgent() {
6350
6715
  return typeof navigator !== "undefined" ? navigator.userAgent || "" : "";
6351
6716
  }
6352
- function bridgeSources() {
6717
+ function bridgeSources2() {
6353
6718
  if (typeof window === "undefined") return [];
6354
6719
  var w = window;
6355
6720
  return [
@@ -6361,7 +6726,7 @@ function bridgeSources() {
6361
6726
  function readBridge(keys) {
6362
6727
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6363
6728
  try {
6364
- for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6729
+ for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6365
6730
  var source = _step.value;
6366
6731
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6367
6732
  try {
@@ -6408,6 +6773,11 @@ function readBridge(keys) {
6408
6773
  }
6409
6774
  return void 0;
6410
6775
  }
6776
+ function makeForCategory(category) {
6777
+ if (category === "LG TV" || category === "LG Set-Top Box") return "LG";
6778
+ if (category === "Samsung TV") return "Samsung";
6779
+ return void 0;
6780
+ }
6411
6781
  function normalizeCategory(value) {
6412
6782
  var v = cleanString(value);
6413
6783
  if (!v) return void 0;
@@ -6555,7 +6925,7 @@ function primeDeviceInfo() {
6555
6925
  return primePromise;
6556
6926
  }
6557
6927
  function getDeviceInfo() {
6558
- var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory;
6928
+ var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory, _ref3, _cleanString4, _cleanString5;
6559
6929
  var platform = platformCache !== null && platformCache !== void 0 ? platformCache : computePlatformInfo();
6560
6930
  if (primePromise && !platformCache) {} else {
6561
6931
  platformCache = platform;
@@ -6578,7 +6948,14 @@ function getDeviceInfo() {
6578
6948
  ]),
6579
6949
  category: normalizeCategory(readBridge([
6580
6950
  "deviceCategory"
6581
- ]))
6951
+ ])),
6952
+ make: readBridge([
6953
+ "deviceMake"
6954
+ ]),
6955
+ hardwareVersion: readBridge([
6956
+ "deviceHardwareVersion",
6957
+ "hardwareVersion"
6958
+ ])
6582
6959
  };
6583
6960
  var terminalId = (_cleanString = cleanString(host.terminalId)) !== null && _cleanString !== void 0 ? _cleanString : bridge.terminalId;
6584
6961
  var hostInternalId = (_cleanString1 = cleanString(host.internalDeviceId)) !== null && _cleanString1 !== void 0 ? _cleanString1 : bridge.internalDeviceId;
@@ -6591,7 +6968,9 @@ function getDeviceInfo() {
6591
6968
  bridge.internalDeviceId,
6592
6969
  bridge.model,
6593
6970
  bridge.firmware,
6594
- bridge.category
6971
+ bridge.category,
6972
+ bridge.make,
6973
+ bridge.hardwareVersion
6595
6974
  ];
6596
6975
  if (bridgeValues.some(function(v) {
6597
6976
  return v !== void 0;
@@ -6599,12 +6978,18 @@ function getDeviceInfo() {
6599
6978
  if (hostDeviceInfo) sources.unshift("host");
6600
6979
  var internalDeviceId = hostInternalId !== null && hostInternalId !== void 0 ? hostInternalId : platform.internalDeviceId;
6601
6980
  var internalDeviceIdSource = hostInternalId ? "host" : platform.internalDeviceIdSource;
6981
+ var make = (_ref3 = (_cleanString4 = cleanString(host.make, 40)) !== null && _cleanString4 !== void 0 ? _cleanString4 : bridge.make) !== null && _ref3 !== void 0 ? _ref3 : makeForCategory(category);
6982
+ var hardwareVersion = (_cleanString5 = cleanString(host.hardwareVersion, 40)) !== null && _cleanString5 !== void 0 ? _cleanString5 : bridge.hardwareVersion;
6602
6983
  var sonifiModel = model && category === "Samsung TV" && !/^SAMSUNG-IPTV-/i.test(model) ? "SAMSUNG-IPTV-".concat(model) : model;
6603
6984
  return _object_spread_props(_object_spread({
6604
6985
  category: category,
6605
6986
  categoryCode: CATEGORY_CODES[category]
6606
- }, model ? {
6987
+ }, make ? {
6988
+ make: make
6989
+ } : {}, model ? {
6607
6990
  model: model
6991
+ } : {}, hardwareVersion ? {
6992
+ hardwareVersion: hardwareVersion
6608
6993
  } : {}, sonifiModel ? {
6609
6994
  sonifiModel: sonifiModel
6610
6995
  } : {}, firmware ? {
@@ -6695,117 +7080,6 @@ function deviceInfoAnalyticsFields(info) {
6695
7080
  terminal_id: info.terminalId
6696
7081
  } : {});
6697
7082
  }
6698
- // src/utils/contentMetadata.ts
6699
- var MAX_CONTENT_VALUE_LENGTH = 128;
6700
- var BRIDGE_KEYS = {
6701
- channelName: [
6702
- "channelName",
6703
- "ct_ch"
6704
- ],
6705
- programTitle: [
6706
- "programTitle",
6707
- "ct_ti"
6708
- ],
6709
- contentNetwork: [
6710
- "contentNetwork",
6711
- "ct_ne"
6712
- ]
6713
- };
6714
- function sanitizeContentValue(value) {
6715
- if (typeof value !== "string") return void 0;
6716
- var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
6717
- if (!cleaned) return void 0;
6718
- if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
6719
- if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
6720
- return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
6721
- }
6722
- function bridgeSources2() {
6723
- if (typeof window === "undefined") return [];
6724
- var w = window;
6725
- return [
6726
- w.__STORMCLOUD_CTV__,
6727
- w.__STORMCLOUD_CTV_AD_INFO__,
6728
- w.stormcloudCtv
6729
- ].filter(Boolean);
6730
- }
6731
- function readBridgeContentValue(keys) {
6732
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6733
- try {
6734
- for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6735
- var source = _step.value;
6736
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6737
- try {
6738
- for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
6739
- var key = _step1.value;
6740
- var value = void 0;
6741
- try {
6742
- value = source === null || source === void 0 ? void 0 : source[key];
6743
- if (typeof value === "function") value = value.call(source);
6744
- } catch (unused) {
6745
- value = void 0;
6746
- }
6747
- var sanitized = sanitizeContentValue(value);
6748
- if (sanitized) return sanitized;
6749
- }
6750
- } catch (err) {
6751
- _didIteratorError1 = true;
6752
- _iteratorError1 = err;
6753
- } finally{
6754
- try {
6755
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
6756
- _iterator1.return();
6757
- }
6758
- } finally{
6759
- if (_didIteratorError1) {
6760
- throw _iteratorError1;
6761
- }
6762
- }
6763
- }
6764
- }
6765
- } catch (err) {
6766
- _didIteratorError = true;
6767
- _iteratorError = err;
6768
- } finally{
6769
- try {
6770
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6771
- _iterator.return();
6772
- }
6773
- } finally{
6774
- if (_didIteratorError) {
6775
- throw _iteratorError;
6776
- }
6777
- }
6778
- }
6779
- return void 0;
6780
- }
6781
- function resolveContentMetadata(config) {
6782
- var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2;
6783
- var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
6784
- var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
6785
- var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
6786
- return _object_spread({}, channelName ? {
6787
- channelName: channelName
6788
- } : {}, programTitle ? {
6789
- programTitle: programTitle
6790
- } : {}, contentNetwork ? {
6791
- contentNetwork: contentNetwork
6792
- } : {});
6793
- }
6794
- function appendMissingContentParams(url, meta) {
6795
- if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
6796
- try {
6797
- var parsed = new URL(url);
6798
- var add = function add(key, value) {
6799
- if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
6800
- };
6801
- add("ct_ch", meta.channelName);
6802
- add("ct_ti", meta.programTitle);
6803
- add("ct_ne", meta.contentNetwork);
6804
- return parsed.toString();
6805
- } catch (unused) {
6806
- return url;
6807
- }
6808
- }
6809
7083
  // src/utils/screenActivity.ts
6810
7084
  var hostStandby = false;
6811
7085
  function setHostStandby(standby) {
@@ -8817,6 +9091,13 @@ var Scte35CueManager = /*#__PURE__*/ function() {
8817
9091
  return Scte35CueManager;
8818
9092
  }();
8819
9093
  // src/player/AdConfigManager.ts
9094
+ function isGamAdUrl(rawUrl) {
9095
+ try {
9096
+ return GAM_AD_HOSTS.has(new URL(rawUrl).hostname);
9097
+ } catch (unused) {
9098
+ return false;
9099
+ }
9100
+ }
8820
9101
  function withDeferredPodParams(rawUrl, deferNonce) {
8821
9102
  try {
8822
9103
  var url = new URL(rawUrl);
@@ -8835,11 +9116,15 @@ function withDeferredPodParams(rawUrl, deferNonce) {
8835
9116
  var AdConfigManager = /*#__PURE__*/ function() {
8836
9117
  "use strict";
8837
9118
  function AdConfigManager(config, video) {
9119
+ var _this = this;
8838
9120
  _class_call_check(this, AdConfigManager);
8839
9121
  this.vmapBreaks = [];
8840
9122
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
8841
9123
  this.streamCorrelator = generateCorrelator();
8842
9124
  this.consentSignals = {};
9125
+ this.isLiveStream = function() {
9126
+ return !!_this.config.isLiveStream;
9127
+ };
8843
9128
  this.podCounter = 0;
8844
9129
  this.podAssignedByPrefetch = false;
8845
9130
  this.lastHeartbeatTime = 0;
@@ -9290,13 +9575,22 @@ var AdConfigManager = /*#__PURE__*/ function() {
9290
9575
  {
9291
9576
  key: "generatePodVastUrl",
9292
9577
  value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
9578
+ var _content_contentDurationSeconds;
9293
9579
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
9294
9580
  var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
9295
9581
  fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
9296
9582
  sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
9297
9583
  });
9298
9584
  var content = resolveContentMetadata(this.config);
9299
- var macroContext = _object_spread_props(_object_spread({
9585
+ var isLive = this.isLiveStream();
9586
+ var device = getDeviceInfo();
9587
+ var playerSize = resolvePlayerSize(this.video);
9588
+ var videoDuration = this.video.duration;
9589
+ var contentDurationSeconds = (_content_contentDurationSeconds = content.contentDurationSeconds) !== null && _content_contentDurationSeconds !== void 0 ? _content_contentDurationSeconds : !isLive && Number.isFinite(videoDuration) && videoDuration > 0 ? Math.round(videoDuration) : void 0;
9590
+ var userId = resolveUserId(this.config.adUserId);
9591
+ var ipAddress = resolveClientIp(this.config.clientIpAddress);
9592
+ var userAgent2 = typeof navigator !== "undefined" && navigator.userAgent ? navigator.userAgent : void 0;
9593
+ var macroContext = _object_spread(_object_spread_props(_object_spread(_object_spread_props(_object_spread({
9300
9594
  correlator: this.viewCorrelator,
9301
9595
  streamCorrelator: this.streamCorrelator,
9302
9596
  pod: this.podCounter > 0 ? this.podCounter : void 0,
@@ -9318,8 +9612,46 @@ var AdConfigManager = /*#__PURE__*/ function() {
9318
9612
  contentNetwork: content.contentNetwork
9319
9613
  } : {}), {
9320
9614
  consent: this.consentSignals,
9321
- palNonce: palNonce.getCurrentNonce() || void 0
9322
- });
9615
+ palNonce: palNonce.getCurrentNonce() || void 0,
9616
+ deviceIdSource: envSignals.deviceIdSource,
9617
+ isLive: isLive
9618
+ }), playerSize.width ? {
9619
+ playerWidth: playerSize.width
9620
+ } : {}, playerSize.height ? {
9621
+ playerHeight: playerSize.height
9622
+ } : {}), {
9623
+ timestamp: String(Date.now())
9624
+ }), device.make ? {
9625
+ deviceMake: device.make
9626
+ } : {}, device.model ? {
9627
+ deviceModel: device.model
9628
+ } : {}, device.hardwareVersion ? {
9629
+ deviceHardwareVersion: device.hardwareVersion
9630
+ } : {}, userAgent2 ? {
9631
+ userAgent: userAgent2
9632
+ } : {}, ipAddress ? {
9633
+ ipAddress: ipAddress
9634
+ } : {}, userId ? {
9635
+ userId: userId
9636
+ } : {}, content.contentType ? {
9637
+ contentType: content.contentType
9638
+ } : {}, content.contentCategory ? {
9639
+ contentCategory: content.contentCategory
9640
+ } : {}, content.contentGenre ? {
9641
+ contentGenre: content.contentGenre
9642
+ } : {}, content.contentLanguage ? {
9643
+ contentLanguage: content.contentLanguage
9644
+ } : {}, contentDurationSeconds != null ? {
9645
+ contentDurationSeconds: contentDurationSeconds
9646
+ } : {}, content.contentSeason ? {
9647
+ contentSeason: content.contentSeason
9648
+ } : {}, content.contentEpisode ? {
9649
+ contentEpisode: content.contentEpisode
9650
+ } : {}, content.contentRating ? {
9651
+ contentRating: content.contentRating
9652
+ } : {}, content.contentId ? {
9653
+ contentId: content.contentId
9654
+ } : {});
9323
9655
  var nonceReady = !!macroContext.palNonce;
9324
9656
  var finalUrl;
9325
9657
  if (hasScvpMacros(baseUrl)) {
@@ -9333,9 +9665,11 @@ var AdConfigManager = /*#__PURE__*/ function() {
9333
9665
  } else {
9334
9666
  finalUrl = withDeferredPodParams(palNonce.injectNonce(ensureVideoAdType(applyVastMacros(baseUrl, macroContext))), !nonceReady);
9335
9667
  }
9336
- finalUrl = appendMissingContentParams(finalUrl, content);
9337
- if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9338
- finalUrl = applyDeviceKeyValues(finalUrl, getDeviceInfo());
9668
+ if (isGamAdUrl(finalUrl)) {
9669
+ finalUrl = appendMissingContentParams(finalUrl, content);
9670
+ if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9671
+ finalUrl = applyDeviceKeyValues(finalUrl, device);
9672
+ }
9339
9673
  }
9340
9674
  if (this.debug) {
9341
9675
  var id = envSignals.deviceId;
@@ -9348,7 +9682,13 @@ var AdConfigManager = /*#__PURE__*/ function() {
9348
9682
  sidTail: envSignals.sessionId ? envSignals.sessionId.slice(-4) : void 0,
9349
9683
  ct_ch: content.channelName,
9350
9684
  ct_ti: content.programTitle,
9351
- ct_ne: content.contentNetwork
9685
+ ct_ne: content.contentNetwork,
9686
+ rating: content.contentRating,
9687
+ ifaType: toIabIfaType(envSignals.deviceIdType, envSignals.deviceIdSource),
9688
+ live: isLive,
9689
+ player: playerSize,
9690
+ make: device.make,
9691
+ model: device.model
9352
9692
  });
9353
9693
  }
9354
9694
  console.log("[StormcloudVideoPlayer] Prepared optimized-pod request URL (pod=".concat(this.podCounter, "; pmnd/pmxd/pmad resolved at dispatch):"), finalUrl);
@@ -11031,6 +11371,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11031
11371
  this.adDetectSentForCurrentBreak = false;
11032
11372
  this.slotState = "IDLE";
11033
11373
  this.unusableResponsesInBreak = 0;
11374
+ this.playedAdIdsInBreak = /* @__PURE__ */ new Set();
11034
11375
  this.controllerGeneration = 0;
11035
11376
  this.requestDiagnostics = /* @__PURE__ */ new Map();
11036
11377
  this.breakFunnel = {};
@@ -11127,6 +11468,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11127
11468
  _this.recordRequestDiagnostic(payload);
11128
11469
  });
11129
11470
  adPlayer.on("ad_impression", function() {
11471
+ var _this_host_getAdPlayer_getLoadedAdId, _this_host_getAdPlayer;
11472
+ 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);
11473
+ if (impressionAdId != null && impressionAdId !== "") {
11474
+ _this.playedAdIdsInBreak.add(String(impressionAdId));
11475
+ }
11130
11476
  _this.timing.consecutiveFailures = 0;
11131
11477
  _this.setSlotState("PLAYING", "impression");
11132
11478
  if (!_this.playbackStartedForCurrentRequest) {
@@ -11318,6 +11664,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11318
11664
  this.resetEdgeStateForBreak();
11319
11665
  this.followUpBaseVastUrl = void 0;
11320
11666
  this.unusableResponsesInBreak = 0;
11667
+ this.playedAdIdsInBreak.clear();
11321
11668
  this.timing.totalAdRequestsInBreak = 0;
11322
11669
  this.setSlotState("NEEDS_NEXT_AD", "vmap_break_start");
11323
11670
  this.noteOpportunity("vmap", breakKey, position);
@@ -11368,6 +11715,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11368
11715
  this.breakSource = "scte35";
11369
11716
  this.followUpBaseVastUrl = baseVastUrl;
11370
11717
  this.unusableResponsesInBreak = 0;
11718
+ this.playedAdIdsInBreak.clear();
11371
11719
  this.resetEdgeStateForBreak();
11372
11720
  this.setSlotState("NEEDS_NEXT_AD", "scte35_break_start");
11373
11721
  if (this.adConfig.podAssignedByPrefetch) {
@@ -12207,6 +12555,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12207
12555
  var outcome;
12208
12556
  if (message.includes("ad_duration_exceeds_budget")) {
12209
12557
  outcome = "discarded_budget";
12558
+ } else if (message.includes("ad_repeated_in_break")) {
12559
+ outcome = "discarded_duplicate";
12210
12560
  } else if (message.includes("VAST fill rejected")) {
12211
12561
  outcome = "fill_rejected";
12212
12562
  } else if (/no ads available|no fill|nofill/i.test(message)) {
@@ -12221,7 +12571,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12221
12571
  outcome = "request_failed";
12222
12572
  }
12223
12573
  this.timing.consecutiveFailures++;
12224
- if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget") {
12574
+ if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget" || outcome === "discarded_duplicate") {
12225
12575
  this.unusableResponsesInBreak++;
12226
12576
  }
12227
12577
  if (outcome === "no_fill") {
@@ -12235,7 +12585,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12235
12585
  }) ? diag.dispatchedUrl : vastTagUrl;
12236
12586
  if (this.timing.isTemporaryAdError(error)) {
12237
12587
  this.timing.temporaryFailureUrls.set(failureKey, Date.now());
12238
- } else if (outcome !== "discarded_budget") {
12588
+ } else if (outcome !== "discarded_budget" && outcome !== "discarded_duplicate") {
12239
12589
  this.timing.failedVastUrls.add(failureKey);
12240
12590
  }
12241
12591
  this.countFunnelStage("request_outcome:".concat(outcome));
@@ -12607,7 +12957,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12607
12957
  value: function playSingleAd(vastTagUrl) {
12608
12958
  var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
12609
12959
  return _async_to_generator(function() {
12610
- var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, finalizeRequestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
12960
+ var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, _ref, _ap_getLoadedAdId, _ap_getPodAdCount, finalizeRequestUrl, loadedAdId, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
12611
12961
  return _ts_generator(this, function(_state) {
12612
12962
  switch(_state.label){
12613
12963
  case 0:
@@ -12720,6 +13070,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12720
13070
  vastUrl: (_this_currentVastUrl = this.currentVastUrl) !== null && _this_currentVastUrl !== void 0 ? _this_currentVastUrl : requestUrl,
12721
13071
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
12722
13072
  }, this.analyticsContext).catch(function() {});
13073
+ loadedAdId = (_ap_getLoadedAdId = ap.getLoadedAdId) === null || _ap_getLoadedAdId === void 0 ? void 0 : _ap_getLoadedAdId.call(ap);
13074
+ 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))) {
13075
+ if (this.debug) {
13076
+ console.log("[AD-DURATION] Rejected ad id=".concat(loadedAdId, ": already played in this break — requesting another ad"));
13077
+ }
13078
+ this.logOrchestratorFunnel("discarded_duplicate", {
13079
+ adId: String(loadedAdId)
13080
+ });
13081
+ throw new Error("ad_repeated_in_break");
13082
+ }
12723
13083
  if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
12724
13084
  ;
12725
13085
  adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
@@ -12773,6 +13133,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12773
13133
  this.recordRequestFailure(error, vastTagUrl);
12774
13134
  if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
12775
13135
  this.recreateAdController("discarded_budget");
13136
+ } else if ((error === null || error === void 0 ? void 0 : error.message) === "ad_repeated_in_break") {
13137
+ this.recreateAdController("discarded_duplicate");
12776
13138
  }
12777
13139
  throw error;
12778
13140
  case 10:
@@ -12846,6 +13208,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12846
13208
  tagAllowsAudio: count("tag_allows_audio"),
12847
13209
  missingImpression: count("vast_missing_impression"),
12848
13210
  discardedBudget: count("discarded_budget"),
13211
+ discardedDuplicate: count("discarded_duplicate"),
12849
13212
  mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
12850
13213
  mediaRejected: count("media_candidate:rejected"),
12851
13214
  mediaFallbacks: count("media_fallback"),
@@ -12921,6 +13284,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12921
13284
  this.breakSource = void 0;
12922
13285
  this.followUpBaseVastUrl = void 0;
12923
13286
  this.unusableResponsesInBreak = 0;
13287
+ this.playedAdIdsInBreak.clear();
12924
13288
  this.resetEdgeStateForBreak();
12925
13289
  adPlayer.stop().catch(function() {});
12926
13290
  if (!alreadyEnded) this.logBreakFunnel(reason);
@@ -13021,9 +13385,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13021
13385
  var maxMonitorMs = 45e3;
13022
13386
  var startTime = Date.now();
13023
13387
  var baseline = resumeBaseline;
13388
+ var lastSeenTime = resumeBaseline;
13024
13389
  var recoveries = 0;
13025
13390
  var lastRecoveryAt = 0;
13026
13391
  var video = this.host.video;
13392
+ var onDecodeError = function onDecodeError() {
13393
+ var _video_error;
13394
+ if (needsReset || ((_video_error = video.error) === null || _video_error === void 0 ? void 0 : _video_error.code) !== 3) return;
13395
+ if (markSingleDecoderLearned() && _this.debug) {
13396
+ console.warn("[StormcloudVideoPlayer] Decoder error while resuming after ads \u2014 using single-decoder mode on this device from the next break");
13397
+ }
13398
+ };
13399
+ video.addEventListener("error", onDecodeError);
13027
13400
  var listenersAttached = false;
13028
13401
  var onMediaEvent;
13029
13402
  var diagEvents = [
@@ -13073,6 +13446,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13073
13446
  console.log("[ResumeDiag] +0.0s monitor start — ".concat(this.describeVideoState()));
13074
13447
  }
13075
13448
  var cleanup = function cleanup() {
13449
+ video.removeEventListener("error", onDecodeError);
13076
13450
  if (listenersAttached && onMediaEvent) {
13077
13451
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
13078
13452
  try {
@@ -13103,6 +13477,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13103
13477
  return;
13104
13478
  }
13105
13479
  var currentTime = video.currentTime;
13480
+ if (currentTime + 1 < lastSeenTime) {
13481
+ baseline = currentTime;
13482
+ }
13483
+ lastSeenTime = currentTime;
13106
13484
  var advanced = currentTime > baseline + 0.5;
13107
13485
  var playing = !video.paused && video.readyState >= 3;
13108
13486
  if (advanced && playing) {
@@ -13525,6 +13903,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13525
13903
  return !!_this.adBreak && _this.adBreak.inAdBreak && !_this.shouldContinueLiveStreamDuringAds();
13526
13904
  }
13527
13905
  });
13906
+ this.adConfig.isLiveStream = function() {
13907
+ return _this.hlsEngine.isLiveStream;
13908
+ };
13528
13909
  this.adBreak = new AdBreakOrchestrator({
13529
13910
  config: this.config,
13530
13911
  video: this.video,
@@ -13886,16 +14267,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13886
14267
  {
13887
14268
  key: "setContentMetadata",
13888
14269
  value: function setContentMetadata(meta) {
13889
- var _this = this;
13890
- var apply = function apply(key, value) {
13891
- if (value === void 0) return;
13892
- var clean = value === null ? void 0 : sanitizeContentValue(value);
13893
- if (clean) _this.config[key] = clean;
13894
- else delete _this.config[key];
13895
- };
13896
- apply("channelName", meta.channelName);
13897
- apply("programTitle", meta.programTitle);
13898
- apply("contentNetwork", meta.contentNetwork);
14270
+ applyContentMetadataUpdate(this.config, meta);
14271
+ }
14272
+ },
14273
+ {
14274
+ key: "setRequestSignals",
14275
+ value: function setRequestSignals(signals) {
14276
+ if (signals.userId !== void 0) {
14277
+ if (signals.userId) this.config.adUserId = signals.userId;
14278
+ else delete this.config.adUserId;
14279
+ }
14280
+ if (signals.ipAddress !== void 0) {
14281
+ if (signals.ipAddress) this.config.clientIpAddress = signals.ipAddress;
14282
+ else delete this.config.clientIpAddress;
14283
+ }
13899
14284
  }
13900
14285
  },
13901
14286
  {
@@ -14611,7 +14996,7 @@ var CRITICAL_PROPS = [
14611
14996
  var CONTROLS_HIDE_DELAY = 3e3;
14612
14997
  var DEFAULT_PLAYER_ASPECT_RATIO = 16 / 9;
14613
14998
  var StormcloudVideoPlayerComponent = React.memo(function(props) {
14614
- var src = props.src, autoplay = props.autoplay, muted = props.muted, lowLatencyMode = props.lowLatencyMode, allowNativeHls = props.allowNativeHls, isLiveStream = props.isLiveStream, driftToleranceMs = props.driftToleranceMs, immediateManifestAds = props.immediateManifestAds, debugAdTiming = props.debugAdTiming, showCustomControls = props.showCustomControls, hideLoadingIndicator = props.hideLoadingIndicator, onVolumeToggle = props.onVolumeToggle, onFullscreenToggle = props.onFullscreenToggle, onControlClick = props.onControlClick, onReady = props.onReady, wrapperClassName = props.wrapperClassName, wrapperStyle = props.wrapperStyle, className = props.className, style = props.style, controls = props.controls, playsInline = props.playsInline, preload = props.preload, poster = props.poster, children = props.children, licenseKey = props.licenseKey, vastTagUrl = props.vastTagUrl, isVmap = props.isVmap, vmapUrl = props.vmapUrl, minSegmentsBeforePlay = props.minSegmentsBeforePlay, ctvAdRequest = props.ctvAdRequest, programTitle = props.programTitle, channelName = props.channelName, contentNetwork = props.contentNetwork, minRemainingMsToStartAd = props.minRemainingMsToStartAd, minRemainingMsToRequestAd = props.minRemainingMsToRequestAd, maxNoFillsPerBreak = props.maxNoFillsPerBreak, maxAdBreakExtensionMs = props.maxAdBreakExtensionMs, adDeviceId = props.adDeviceId, adDeviceIdType = props.adDeviceIdType, adLimitAdTracking = props.adLimitAdTracking, fallbackDeviceIdMaxAgeMs = props.fallbackDeviceIdMaxAgeMs, sessionIdMaxAgeMs = props.sessionIdMaxAgeMs, palIconsSupported = props.palIconsSupported, palSupportedApiFrameworks = props.palSupportedApiFrameworks, palContinuousPlayback = props.palContinuousPlayback, palNonceMaxAgeMs = props.palNonceMaxAgeMs, forceSingleDecoderMode = props.forceSingleDecoderMode, deviceInfo = props.deviceInfo, sendDeviceKeyValues = props.sendDeviceKeyValues, sendDeviceInfoToAnalytics = props.sendDeviceInfoToAnalytics, restVideoAttrs = _object_without_properties(props, [
14999
+ var src = props.src, autoplay = props.autoplay, muted = props.muted, lowLatencyMode = props.lowLatencyMode, allowNativeHls = props.allowNativeHls, isLiveStream = props.isLiveStream, driftToleranceMs = props.driftToleranceMs, immediateManifestAds = props.immediateManifestAds, debugAdTiming = props.debugAdTiming, showCustomControls = props.showCustomControls, hideLoadingIndicator = props.hideLoadingIndicator, onVolumeToggle = props.onVolumeToggle, onFullscreenToggle = props.onFullscreenToggle, onControlClick = props.onControlClick, onReady = props.onReady, wrapperClassName = props.wrapperClassName, wrapperStyle = props.wrapperStyle, className = props.className, style = props.style, controls = props.controls, playsInline = props.playsInline, preload = props.preload, poster = props.poster, children = props.children, licenseKey = props.licenseKey, vastTagUrl = props.vastTagUrl, isVmap = props.isVmap, vmapUrl = props.vmapUrl, minSegmentsBeforePlay = props.minSegmentsBeforePlay, ctvAdRequest = props.ctvAdRequest, programTitle = props.programTitle, channelName = props.channelName, contentNetwork = props.contentNetwork, contentDetails = props.contentDetails, adUserId = props.adUserId, clientIpAddress = props.clientIpAddress, minRemainingMsToStartAd = props.minRemainingMsToStartAd, minRemainingMsToRequestAd = props.minRemainingMsToRequestAd, maxNoFillsPerBreak = props.maxNoFillsPerBreak, maxAdBreakExtensionMs = props.maxAdBreakExtensionMs, adDeviceId = props.adDeviceId, adDeviceIdType = props.adDeviceIdType, adLimitAdTracking = props.adLimitAdTracking, fallbackDeviceIdMaxAgeMs = props.fallbackDeviceIdMaxAgeMs, sessionIdMaxAgeMs = props.sessionIdMaxAgeMs, palIconsSupported = props.palIconsSupported, palSupportedApiFrameworks = props.palSupportedApiFrameworks, palContinuousPlayback = props.palContinuousPlayback, palNonceMaxAgeMs = props.palNonceMaxAgeMs, forceSingleDecoderMode = props.forceSingleDecoderMode, deviceInfo = props.deviceInfo, sendDeviceKeyValues = props.sendDeviceKeyValues, sendDeviceInfoToAnalytics = props.sendDeviceInfoToAnalytics, restVideoAttrs = _object_without_properties(props, [
14615
15000
  "src",
14616
15001
  "autoplay",
14617
15002
  "muted",
@@ -14645,6 +15030,9 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
14645
15030
  "programTitle",
14646
15031
  "channelName",
14647
15032
  "contentNetwork",
15033
+ "contentDetails",
15034
+ "adUserId",
15035
+ "clientIpAddress",
14648
15036
  "minRemainingMsToStartAd",
14649
15037
  "minRemainingMsToRequestAd",
14650
15038
  "maxNoFillsPerBreak",
@@ -14853,6 +15241,9 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
14853
15241
  if (programTitle !== void 0) cfg.programTitle = programTitle;
14854
15242
  if (channelName !== void 0) cfg.channelName = channelName;
14855
15243
  if (contentNetwork !== void 0) cfg.contentNetwork = contentNetwork;
15244
+ if (contentDetails !== void 0) cfg.contentDetails = contentDetails;
15245
+ if (adUserId !== void 0) cfg.adUserId = adUserId;
15246
+ if (clientIpAddress !== void 0) cfg.clientIpAddress = clientIpAddress;
14856
15247
  if (minRemainingMsToStartAd !== void 0) cfg.minRemainingMsToStartAd = minRemainingMsToStartAd;
14857
15248
  if (minRemainingMsToRequestAd !== void 0) cfg.minRemainingMsToRequestAd = minRemainingMsToRequestAd;
14858
15249
  if (maxNoFillsPerBreak !== void 0) cfg.maxNoFillsPerBreak = maxNoFillsPerBreak;
@@ -14921,6 +15312,25 @@ var StormcloudVideoPlayerComponent = React.memo(function(props) {
14921
15312
  programTitle,
14922
15313
  contentNetwork
14923
15314
  ]);
15315
+ var contentDetailsKey = contentDetails ? JSON.stringify(contentDetails) : "";
15316
+ useEffect(function() {
15317
+ var _playerRef_current;
15318
+ (_playerRef_current = playerRef.current) === null || _playerRef_current === void 0 ? void 0 : _playerRef_current.setContentMetadata({
15319
+ details: contentDetailsKey ? JSON.parse(contentDetailsKey) : null
15320
+ });
15321
+ }, [
15322
+ contentDetailsKey
15323
+ ]);
15324
+ useEffect(function() {
15325
+ var _playerRef_current;
15326
+ (_playerRef_current = playerRef.current) === null || _playerRef_current === void 0 ? void 0 : _playerRef_current.setRequestSignals({
15327
+ userId: adUserId !== null && adUserId !== void 0 ? adUserId : null,
15328
+ ipAddress: clientIpAddress !== null && clientIpAddress !== void 0 ? clientIpAddress : null
15329
+ });
15330
+ }, [
15331
+ adUserId,
15332
+ clientIpAddress
15333
+ ]);
14924
15334
  var lastAdDeviceIdRef = useRef(void 0);
14925
15335
  useEffect(function() {
14926
15336
  var player = playerRef.current;