stormcloud-video-player 0.8.79 → 0.8.81

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 (90) hide show
  1. package/dist/stormcloud-vp.min.js +2 -2
  2. package/lib/Player.cjs +6 -0
  3. package/lib/Player.cjs.map +1 -1
  4. package/lib/Player.d.cts +4 -1
  5. package/lib/StormcloudPlayer.cjs +1459 -167
  6. package/lib/StormcloudPlayer.cjs.map +1 -1
  7. package/lib/StormcloudPlayer.d.cts +3 -0
  8. package/lib/index.cjs +1547 -169
  9. package/lib/index.cjs.map +1 -1
  10. package/lib/index.d.cts +3 -0
  11. package/lib/index.d.ts +89 -3
  12. package/lib/index.js +1547 -169
  13. package/lib/index.js.map +1 -1
  14. package/lib/player/AdBreakOrchestrator.cjs +452 -88
  15. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  16. package/lib/player/AdBreakOrchestrator.d.cts +1 -0
  17. package/lib/player/AdConfigManager.cjs +1024 -97
  18. package/lib/player/AdConfigManager.cjs.map +1 -1
  19. package/lib/player/AdConfigManager.d.cts +2 -0
  20. package/lib/player/AdTimingService.cjs +0 -9
  21. package/lib/player/AdTimingService.cjs.map +1 -1
  22. package/lib/player/AdTimingService.d.cts +1 -0
  23. package/lib/player/EdgePodRequest.d.cts +1 -0
  24. package/lib/player/FloorLadder.cjs +3 -0
  25. package/lib/player/FloorLadder.cjs.map +1 -1
  26. package/lib/player/FloorLadder.d.cts +1 -0
  27. package/lib/player/HlsEngine.cjs +7 -1
  28. package/lib/player/HlsEngine.cjs.map +1 -1
  29. package/lib/player/HlsEngine.d.cts +2 -0
  30. package/lib/player/OptimizedPodRequest.cjs +21 -6
  31. package/lib/player/OptimizedPodRequest.cjs.map +1 -1
  32. package/lib/player/OptimizedPodRequest.d.cts +1 -1
  33. package/lib/player/PlayerControls.d.cts +1 -0
  34. package/lib/player/Scte35CueManager.d.cts +1 -0
  35. package/lib/player/Scte35Parser.d.cts +1 -0
  36. package/lib/player/StormcloudVideoPlayer.cjs +1459 -167
  37. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  38. package/lib/player/StormcloudVideoPlayer.d.cts +19 -1
  39. package/lib/player/playerTypes.d.cts +1 -0
  40. package/lib/players/HlsPlayer.cjs +1459 -167
  41. package/lib/players/HlsPlayer.cjs.map +1 -1
  42. package/lib/players/HlsPlayer.d.cts +1 -0
  43. package/lib/players/index.cjs +1459 -167
  44. package/lib/players/index.cjs.map +1 -1
  45. package/lib/props.cjs +6 -0
  46. package/lib/props.cjs.map +1 -1
  47. package/lib/props.d.cts +3 -0
  48. package/lib/sdk/hlsAdPlayer.cjs +32 -3
  49. package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
  50. package/lib/sdk/hlsAdPlayer.d.cts +1 -0
  51. package/lib/sdk/pal.cjs +10 -3
  52. package/lib/sdk/pal.cjs.map +1 -1
  53. package/lib/sdk/pal.d.cts +3 -0
  54. package/lib/types.d.cts +29 -1
  55. package/lib/ui/StormcloudVideoPlayer.cjs +1547 -169
  56. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  57. package/lib/ui/StormcloudVideoPlayer.d.cts +3 -0
  58. package/lib/utils/__tests__/adSignals.test.cjs +25817 -0
  59. package/lib/utils/__tests__/adSignals.test.cjs.map +1 -0
  60. package/lib/utils/__tests__/adSignals.test.d.cts +2 -0
  61. package/lib/utils/adIdentity.cjs +421 -0
  62. package/lib/utils/adIdentity.cjs.map +1 -0
  63. package/lib/utils/adIdentity.d.cts +30 -0
  64. package/lib/utils/browserCompat.cjs +13 -0
  65. package/lib/utils/browserCompat.cjs.map +1 -1
  66. package/lib/utils/browserCompat.d.cts +2 -1
  67. package/lib/utils/contentMetadata.cjs +324 -0
  68. package/lib/utils/contentMetadata.cjs.map +1 -0
  69. package/lib/utils/contentMetadata.d.cts +51 -0
  70. package/lib/utils/ctvVastSignals.cjs +250 -181
  71. package/lib/utils/ctvVastSignals.cjs.map +1 -1
  72. package/lib/utils/deviceInfo.cjs +698 -0
  73. package/lib/utils/deviceInfo.cjs.map +1 -0
  74. package/lib/utils/deviceInfo.d.cts +46 -0
  75. package/lib/utils/partnerSignals.cjs +294 -0
  76. package/lib/utils/partnerSignals.cjs.map +1 -0
  77. package/lib/utils/partnerSignals.d.cts +12 -0
  78. package/lib/utils/screenActivity.cjs +125 -0
  79. package/lib/utils/screenActivity.cjs.map +1 -0
  80. package/lib/utils/screenActivity.d.cts +5 -0
  81. package/lib/utils/tracking.cjs +406 -56
  82. package/lib/utils/tracking.cjs.map +1 -1
  83. package/lib/utils/tracking.d.cts +2 -1
  84. package/lib/utils/vastEnvironmentSignals.cjs +255 -85
  85. package/lib/utils/vastEnvironmentSignals.cjs.map +1 -1
  86. package/lib/utils/vastEnvironmentSignals.d.cts +8 -2
  87. package/lib/utils/vastMacros.cjs +58 -1
  88. package/lib/utils/vastMacros.cjs.map +1 -1
  89. package/lib/utils/vastMacros.d.cts +21 -0
  90. package/package.json +1 -1
@@ -363,8 +363,264 @@ __export(StormcloudVideoPlayer_exports, {
363
363
  });
364
364
  module.exports = __toCommonJS(StormcloudVideoPlayer_exports);
365
365
  var import_react = __toESM(require("react"), 1);
366
+ // src/utils/adIdentity.ts
367
+ var GOOGLE_ID_TYPES = [
368
+ "aaid",
369
+ "adid",
370
+ "afai",
371
+ "idfa",
372
+ "lgudid",
373
+ "msai",
374
+ "rida",
375
+ "tifa",
376
+ "tvOS",
377
+ "vaid",
378
+ "vida",
379
+ "dpid"
380
+ ];
381
+ var MAX_SESSION_ID_AGE_MS = 6 * 60 * 60 * 1e3;
382
+ var DEFAULT_SESSION_ID_MAX_AGE_MS = MAX_SESSION_ID_AGE_MS;
383
+ var DEFAULT_FALLBACK_DEVICE_ID_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
384
+ var DEFAULT_LGUDID_TIMEOUT_MS = 1500;
385
+ var FALLBACK_DEVICE_ID_KEY = "stormcloud.ad.dpid.v2";
386
+ var SESSION_ID_KEY = "stormcloud.ad.sid.v2";
387
+ var LEGACY_SESSION_KEY = "stormcloud.ctv.sid";
388
+ var ZEROED_IDS = /* @__PURE__ */ new Set([
389
+ "00000000-0000-0000-0000-000000000000",
390
+ "38400000-8cf0-11bd-b23e-10b96e40000d"
391
+ ]);
392
+ var hostIdentity;
393
+ var memoryStore = {};
394
+ var lgUdidResult;
395
+ var lgUdidPromise;
396
+ var legacyCleared = false;
397
+ function isUsableAdId(value) {
398
+ if (typeof value !== "string") return false;
399
+ var t = value.trim();
400
+ if (!t) return false;
401
+ if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(t)) return false;
402
+ if (/^(unknown|null|undefined|none|n\/a)$/i.test(t)) return false;
403
+ return !ZEROED_IDS.has(t.toLowerCase());
404
+ }
405
+ function isZeroedAdId(value) {
406
+ return typeof value === "string" && ZEROED_IDS.has(value.trim().toLowerCase());
407
+ }
408
+ function normalizeIdType(value) {
409
+ if (typeof value !== "string") return void 0;
410
+ var lower = value.trim().toLowerCase();
411
+ if (!lower) return void 0;
412
+ var match = GOOGLE_ID_TYPES.find(function(t) {
413
+ return t.toLowerCase() === lower;
414
+ });
415
+ return match !== null && match !== void 0 ? match : "dpid";
416
+ }
417
+ function createUuid() {
418
+ var _bytes_, _bytes_1, _bytes_i;
419
+ var c = typeof crypto !== "undefined" ? crypto : void 0;
420
+ if (c && typeof c.randomUUID === "function") return c.randomUUID();
421
+ var bytes = new Uint8Array(16);
422
+ if (c && typeof c.getRandomValues === "function") {
423
+ c.getRandomValues(bytes);
424
+ } else {
425
+ for(var i = 0; i < 16; i++)bytes[i] = Math.floor(Math.random() * 256);
426
+ }
427
+ bytes[6] = ((_bytes_ = bytes[6]) !== null && _bytes_ !== void 0 ? _bytes_ : 0) & 15 | 64;
428
+ bytes[8] = ((_bytes_1 = bytes[8]) !== null && _bytes_1 !== void 0 ? _bytes_1 : 0) & 63 | 128;
429
+ var hex = "";
430
+ for(var i1 = 0; i1 < 16; i1++)hex += ((_bytes_i = bytes[i1]) !== null && _bytes_i !== void 0 ? _bytes_i : 0).toString(16).padStart(2, "0");
431
+ return "".concat(hex.slice(0, 8), "-").concat(hex.slice(8, 12), "-").concat(hex.slice(12, 16), "-").concat(hex.slice(16, 20), "-").concat(hex.slice(20));
432
+ }
433
+ function readStored(key) {
434
+ try {
435
+ var _window_localStorage;
436
+ var raw = typeof window !== "undefined" ? (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key) : null;
437
+ if (raw) {
438
+ var parsed = JSON.parse(raw);
439
+ if (parsed && typeof parsed.id === "string" && typeof parsed.createdAt === "number" && isFinite(parsed.createdAt)) {
440
+ return {
441
+ id: parsed.id,
442
+ createdAt: parsed.createdAt
443
+ };
444
+ }
445
+ }
446
+ } catch (unused) {}
447
+ return memoryStore[key];
448
+ }
449
+ function writeStored(key, value) {
450
+ memoryStore[key] = value;
451
+ try {
452
+ if (typeof window !== "undefined") {
453
+ var _window_localStorage;
454
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(key, JSON.stringify(value));
455
+ }
456
+ } catch (unused) {}
457
+ }
458
+ function removeStored(key) {
459
+ delete memoryStore[key];
460
+ try {
461
+ var _window_localStorage;
462
+ if (typeof window !== "undefined") (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.removeItem(key);
463
+ } catch (unused) {}
464
+ }
465
+ function clearLegacyIdsOnce() {
466
+ if (legacyCleared) return;
467
+ legacyCleared = true;
468
+ try {
469
+ var _window_localStorage;
470
+ if (typeof window !== "undefined") (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.removeItem(LEGACY_SESSION_KEY);
471
+ } catch (unused) {}
472
+ try {
473
+ if (typeof document !== "undefined") {
474
+ document.cookie = "".concat(encodeURIComponent(LEGACY_SESSION_KEY), "=;path=/;max-age=0;SameSite=Lax");
475
+ }
476
+ } catch (unused) {}
477
+ }
478
+ function clampAge(value, fallback, max) {
479
+ var v = typeof value === "number" && isFinite(value) && value > 0 ? value : fallback;
480
+ if (max != null) v = Math.min(v, max);
481
+ return v;
482
+ }
483
+ function setHostAdIdentity(identity) {
484
+ var _normalizeIdType;
485
+ if (!identity || !isUsableAdId(identity.deviceId)) {
486
+ hostIdentity = void 0;
487
+ return;
488
+ }
489
+ var deviceId = identity.deviceId.trim();
490
+ var changed = !hostIdentity || hostIdentity.deviceId !== deviceId;
491
+ hostIdentity = _object_spread({
492
+ deviceId: deviceId,
493
+ deviceIdType: (_normalizeIdType = normalizeIdType(identity.deviceIdType)) !== null && _normalizeIdType !== void 0 ? _normalizeIdType : "dpid"
494
+ }, typeof identity.limitAdTracking === "boolean" ? {
495
+ limitAdTracking: identity.limitAdTracking
496
+ } : {});
497
+ if (changed) {
498
+ removeStored(SESSION_ID_KEY);
499
+ removeStored(FALLBACK_DEVICE_ID_KEY);
500
+ }
501
+ }
502
+ function getHostAdIdentity() {
503
+ return hostIdentity ? _object_spread({}, hostIdentity) : void 0;
504
+ }
505
+ function resetAdIdentity() {
506
+ removeStored(SESSION_ID_KEY);
507
+ removeStored(FALLBACK_DEVICE_ID_KEY);
508
+ }
509
+ function readSamsungTifa() {
510
+ try {
511
+ var _window_webapis;
512
+ var adinfo = typeof window !== "undefined" ? (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.adinfo : void 0;
513
+ if (!adinfo) return void 0;
514
+ var tifa = typeof adinfo.getTIFA === "function" ? adinfo.getTIFA() : adinfo.tifa;
515
+ var lat = typeof adinfo.isLATEnabled === "function" ? adinfo.isLATEnabled() : void 0;
516
+ if (isZeroedAdId(tifa)) return {
517
+ deviceIdType: "tifa",
518
+ limitAdTracking: true
519
+ };
520
+ if (!isUsableAdId(tifa)) return void 0;
521
+ return _object_spread({
522
+ deviceId: tifa.trim(),
523
+ deviceIdType: "tifa"
524
+ }, typeof lat === "boolean" ? {
525
+ limitAdTracking: lat
526
+ } : {});
527
+ } catch (unused) {
528
+ return void 0;
529
+ }
530
+ }
531
+ function primeLgUdid() {
532
+ var timeoutMs = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : DEFAULT_LGUDID_TIMEOUT_MS;
533
+ if (lgUdidResult || lgUdidPromise) return lgUdidPromise !== null && lgUdidPromise !== void 0 ? lgUdidPromise : Promise.resolve();
534
+ var dev = typeof window !== "undefined" ? window.webOSDev : void 0;
535
+ if (!dev) return Promise.resolve();
536
+ if (typeof dev.LGUDID !== "function") {
537
+ var _dev_lgudid;
538
+ var direct = (_dev_lgudid = dev.lgudid) !== null && _dev_lgudid !== void 0 ? _dev_lgudid : dev.LGUDID;
539
+ if (isZeroedAdId(direct)) lgUdidResult = {
540
+ deviceIdType: "lgudid",
541
+ limitAdTracking: true
542
+ };
543
+ else if (isUsableAdId(direct)) {
544
+ lgUdidResult = {
545
+ deviceId: direct.trim(),
546
+ deviceIdType: "lgudid",
547
+ limitAdTracking: false
548
+ };
549
+ }
550
+ return Promise.resolve();
551
+ }
552
+ lgUdidPromise = new Promise(function(resolve) {
553
+ var settled = false;
554
+ var finish = function finish() {
555
+ if (settled) return;
556
+ settled = true;
557
+ clearTimeout(timer);
558
+ resolve();
559
+ };
560
+ var timer = setTimeout(finish, Math.max(0, timeoutMs));
561
+ try {
562
+ dev.LGUDID({
563
+ onSuccess: function onSuccess(res) {
564
+ var id = res === null || res === void 0 ? void 0 : res.id;
565
+ if (isZeroedAdId(id)) {
566
+ lgUdidResult = {
567
+ deviceIdType: "lgudid",
568
+ limitAdTracking: true
569
+ };
570
+ } else if (isUsableAdId(id)) {
571
+ lgUdidResult = {
572
+ deviceId: id.trim(),
573
+ deviceIdType: "lgudid",
574
+ limitAdTracking: false
575
+ };
576
+ }
577
+ finish();
578
+ },
579
+ onFailure: function onFailure() {
580
+ return finish();
581
+ }
582
+ });
583
+ } catch (unused) {
584
+ finish();
585
+ }
586
+ });
587
+ return lgUdidPromise;
588
+ }
589
+ function readCachedLgUdid() {
590
+ return lgUdidResult ? _object_spread({}, lgUdidResult) : void 0;
591
+ }
592
+ function getOrRotateFallbackDeviceId() {
593
+ var maxAgeMs = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : DEFAULT_FALLBACK_DEVICE_ID_MAX_AGE_MS, now = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Date.now();
594
+ clearLegacyIdsOnce();
595
+ var age = clampAge(maxAgeMs, DEFAULT_FALLBACK_DEVICE_ID_MAX_AGE_MS);
596
+ var stored = readStored(FALLBACK_DEVICE_ID_KEY);
597
+ if (stored && isUsableAdId(stored.id) && now - stored.createdAt >= 0 && now - stored.createdAt < age) {
598
+ return stored.id;
599
+ }
600
+ var id = createUuid();
601
+ writeStored(FALLBACK_DEVICE_ID_KEY, {
602
+ id: id,
603
+ createdAt: now
604
+ });
605
+ return id;
606
+ }
607
+ function getOrRotateSessionId() {
608
+ var maxAgeMs = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : DEFAULT_SESSION_ID_MAX_AGE_MS, avoidValue = arguments.length > 1 ? arguments[1] : void 0, now = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : Date.now();
609
+ clearLegacyIdsOnce();
610
+ var age = clampAge(maxAgeMs, DEFAULT_SESSION_ID_MAX_AGE_MS, MAX_SESSION_ID_AGE_MS);
611
+ var stored = readStored(SESSION_ID_KEY);
612
+ if (stored && isUsableAdId(stored.id) && stored.id !== avoidValue && now - stored.createdAt >= 0 && now - stored.createdAt < age) {
613
+ return stored.id;
614
+ }
615
+ var id = createUuid();
616
+ while(id === avoidValue)id = createUuid();
617
+ writeStored(SESSION_ID_KEY, {
618
+ id: id,
619
+ createdAt: now
620
+ });
621
+ return id;
622
+ }
366
623
  // src/utils/vastEnvironmentSignals.ts
367
- var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
368
624
  var PLAYER_ID_STORAGE_KEY = "stormcloud.player.id";
369
625
  var DEVICE_ID_STORAGE_KEYS = [
370
626
  "rdid",
@@ -383,49 +639,96 @@ var ANDROID_ID_TYPES = /* @__PURE__ */ new Set([
383
639
  "adid"
384
640
  ]);
385
641
  function resolveVastEnvironmentSignals(isCtv) {
386
- var bridgeSignals = readNativeBridgeSignals();
387
- var platformDevice = readPlatformNativeDeviceId();
388
- var bridgeDeviceId = validDeviceId(bridgeSignals.deviceId);
389
- var realDeviceId = bridgeDeviceId || (isCtv ? validDeviceId(readStoredDeviceId()) : void 0) || validDeviceId(platformDevice.deviceId);
390
- var deviceId = realDeviceId;
391
- var deviceIdType = (bridgeDeviceId ? bridgeSignals.deviceIdType : void 0) || readStoredString("deviceIdType") || readStoredString("idtype") || platformDevice.deviceIdType || inferDeviceIdType();
392
- var platformLat = bridgeDeviceId ? bridgeSignals.limitAdTracking : platformDevice.limitAdTracking;
393
- var limitAdTracking = deviceId != null ? platformLat !== null && platformLat !== void 0 ? platformLat : readStoredLimitAdTracking() : void 0;
394
- if (!deviceId && isCtv) {
395
- var dpid = getOrCreateStoredUuid(PLAYER_ID_STORAGE_KEY);
396
- if (dpid) {
397
- deviceId = dpid;
398
- deviceIdType = "dpid";
399
- limitAdTracking = platformLat !== null && platformLat !== void 0 ? platformLat : readStoredLimitAdTracking();
400
- }
401
- }
642
+ var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
402
643
  var deviceTypeHint = resolveDeviceTypeHint(isCtv);
644
+ var identity = resolveDeviceIdentity(isCtv, options);
645
+ var identityFields = _object_spread({}, identity.deviceId ? {
646
+ deviceId: identity.deviceId
647
+ } : {}, identity.deviceId && identity.deviceIdType ? {
648
+ deviceIdType: identity.deviceIdType
649
+ } : {}, identity.deviceId && identity.limitAdTracking != null ? {
650
+ limitAdTracking: identity.limitAdTracking
651
+ } : {}, identity.source ? {
652
+ deviceIdSource: identity.source
653
+ } : {});
403
654
  if (isCtv) {
404
655
  return _object_spread_props(_object_spread({
405
656
  isCtv: true,
406
- sessionId: getOrCreateCtvSessionId()
407
- }, deviceId ? {
408
- deviceId: deviceId
409
- } : {}, deviceId && deviceIdType ? {
410
- deviceIdType: deviceIdType
411
- } : {}, deviceId && limitAdTracking != null ? {
412
- limitAdTracking: limitAdTracking
413
- } : {}), {
657
+ sessionId: getOrRotateSessionId(options.sessionIdMaxAgeMs, identity.deviceId)
658
+ }, identityFields), {
414
659
  deviceTypeHint: deviceTypeHint
415
660
  });
416
661
  }
417
662
  return _object_spread_props(_object_spread({
418
663
  isCtv: false
419
- }, deviceId ? {
420
- deviceId: deviceId
421
- } : {}, deviceId && deviceIdType ? {
422
- deviceIdType: deviceIdType
423
- } : {}, deviceId && limitAdTracking != null ? {
424
- limitAdTracking: limitAdTracking
425
- } : {}), {
664
+ }, identityFields), {
426
665
  deviceTypeHint: deviceTypeHint
427
666
  });
428
667
  }
668
+ function resolveDeviceIdentity(isCtv, options) {
669
+ var _platform_limitAdTracking;
670
+ var host = getHostAdIdentity();
671
+ if (host) {
672
+ var _host_deviceIdType;
673
+ return _object_spread_props(_object_spread({
674
+ deviceId: host.deviceId,
675
+ deviceIdType: (_host_deviceIdType = host.deviceIdType) !== null && _host_deviceIdType !== void 0 ? _host_deviceIdType : "dpid"
676
+ }, host.limitAdTracking != null ? {
677
+ limitAdTracking: host.limitAdTracking
678
+ } : {}), {
679
+ source: "host"
680
+ });
681
+ }
682
+ var bridge = readNativeBridgeSignals();
683
+ var bridgeDeviceId = validDeviceId(bridge.deviceId);
684
+ if (bridgeDeviceId) {
685
+ var _normalizeIdType;
686
+ return _object_spread_props(_object_spread({
687
+ deviceId: bridgeDeviceId,
688
+ deviceIdType: (_normalizeIdType = normalizeIdType(bridge.deviceIdType)) !== null && _normalizeIdType !== void 0 ? _normalizeIdType : "dpid"
689
+ }, bridge.limitAdTracking != null ? {
690
+ limitAdTracking: bridge.limitAdTracking
691
+ } : {}), {
692
+ source: "bridge"
693
+ });
694
+ }
695
+ var platform = readPlatformNativeDeviceId();
696
+ var platformDeviceId = validDeviceId(platform.deviceId);
697
+ if (platformDeviceId) {
698
+ var _platform_deviceIdType;
699
+ return _object_spread_props(_object_spread({
700
+ deviceId: platformDeviceId,
701
+ deviceIdType: (_platform_deviceIdType = platform.deviceIdType) !== null && _platform_deviceIdType !== void 0 ? _platform_deviceIdType : "dpid"
702
+ }, platform.limitAdTracking != null ? {
703
+ limitAdTracking: platform.limitAdTracking
704
+ } : {}), {
705
+ source: "platform"
706
+ });
707
+ }
708
+ if (!isCtv) return {};
709
+ var storedDeviceId = validDeviceId(readStoredDeviceId());
710
+ if (storedDeviceId) {
711
+ var _normalizeIdType1;
712
+ var storedLat = readStoredLimitAdTracking();
713
+ return _object_spread_props(_object_spread({
714
+ deviceId: storedDeviceId,
715
+ deviceIdType: (_normalizeIdType1 = normalizeIdType(readStoredString("deviceIdType") || readStoredString("idtype"))) !== null && _normalizeIdType1 !== void 0 ? _normalizeIdType1 : "dpid"
716
+ }, storedLat != null ? {
717
+ limitAdTracking: storedLat
718
+ } : {}), {
719
+ source: "stored"
720
+ });
721
+ }
722
+ var fallbackLat = (_platform_limitAdTracking = platform.limitAdTracking) !== null && _platform_limitAdTracking !== void 0 ? _platform_limitAdTracking : readStoredLimitAdTracking();
723
+ return _object_spread_props(_object_spread({
724
+ deviceId: getOrRotateFallbackDeviceId(options.fallbackDeviceIdMaxAgeMs),
725
+ deviceIdType: "dpid"
726
+ }, fallbackLat != null ? {
727
+ limitAdTracking: fallbackLat
728
+ } : {}), {
729
+ source: "generated"
730
+ });
731
+ }
429
732
  var DEVICE_TYPE_HINT = {
430
733
  FEATURE_PHONE: 1,
431
734
  SMARTPHONE: 2,
@@ -586,7 +889,7 @@ function resolveNativeDeviceId() {
586
889
  var bridgeSignals = readNativeBridgeSignals();
587
890
  var platformDevice = readPlatformNativeDeviceId();
588
891
  var deviceId = bridgeSignals.deviceId || (includeStored ? readStoredDeviceId() : void 0) || platformDevice.deviceId;
589
- if (!deviceId || isMacroPlaceholder(deviceId) || isZeroedAdId(deviceId)) {
892
+ if (!deviceId || isMacroPlaceholder(deviceId) || isZeroedAdId2(deviceId)) {
590
893
  return void 0;
591
894
  }
592
895
  return deviceId;
@@ -600,20 +903,10 @@ function getOrCreateStoredUuid(storageKey) {
600
903
  writePersistentId(storageKey, existing);
601
904
  return existing;
602
905
  }
603
- var id = createUuid();
906
+ var id = createUuid2();
604
907
  writePersistentId(storageKey, id);
605
908
  return id;
606
909
  }
607
- function getOrCreateCtvSessionId() {
608
- var existing = readPersistentId(CTV_SESSION_STORAGE_KEY);
609
- if (existing) {
610
- writePersistentId(CTV_SESSION_STORAGE_KEY, existing);
611
- return existing;
612
- }
613
- var sessionId = createUuid();
614
- writePersistentId(CTV_SESSION_STORAGE_KEY, sessionId);
615
- return sessionId;
616
- }
617
910
  function readPersistentId(storageKey) {
618
911
  return readStoredString(storageKey) || readCookie(storageKey);
619
912
  }
@@ -666,7 +959,7 @@ function writeCookie(name, value) {
666
959
  document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + ";path=/;max-age=" + PERSISTENT_ID_COOKIE_MAX_AGE + ";SameSite=Lax";
667
960
  } catch (unused) {}
668
961
  }
669
- function createUuid() {
962
+ function createUuid2() {
670
963
  var _bytes_, _bytes_1;
671
964
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
672
965
  return crypto.randomUUID();
@@ -700,44 +993,10 @@ function performanceNow() {
700
993
  }
701
994
  function readPlatformNativeDeviceId() {
702
995
  if (typeof window === "undefined") return {};
703
- try {
704
- var _window_webapis;
705
- var adinfo = (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.adinfo;
706
- if (adinfo) {
707
- var tifa = typeof adinfo.getTIFA === "function" ? adinfo.getTIFA() : adinfo.tifa;
708
- if (typeof tifa === "string" && tifa && !isMacroPlaceholder(tifa)) {
709
- var lat = typeof adinfo.isLATEnabled === "function" ? adinfo.isLATEnabled() : void 0;
710
- return _object_spread({
711
- deviceId: tifa,
712
- deviceIdType: "tifa"
713
- }, typeof lat === "boolean" ? {
714
- limitAdTracking: lat
715
- } : {});
716
- }
717
- }
718
- } catch (unused) {}
719
- try {
720
- var webOSDev = window.webOSDev;
721
- if (webOSDev) {
722
- var _webOSDev_lgudid;
723
- var lgudid = typeof webOSDev.LGUDID === "function" ? webOSDev.LGUDID() : (_webOSDev_lgudid = webOSDev.lgudid) !== null && _webOSDev_lgudid !== void 0 ? _webOSDev_lgudid : webOSDev.LGUDID;
724
- if (typeof lgudid === "string" && lgudid) {
725
- if (isZeroedAdId(lgudid)) {
726
- return {
727
- deviceIdType: "lgudid",
728
- limitAdTracking: true
729
- };
730
- }
731
- if (!isMacroPlaceholder(lgudid)) {
732
- return {
733
- deviceId: lgudid,
734
- deviceIdType: "lgudid",
735
- limitAdTracking: false
736
- };
737
- }
738
- }
739
- }
740
- } catch (unused) {}
996
+ var tifa = readSamsungTifa();
997
+ if (tifa) return tifa;
998
+ var lgudid = readCachedLgUdid();
999
+ if (lgudid) return lgudid;
741
1000
  try {
742
1001
  var roku = window.Roku;
743
1002
  if (roku) {
@@ -764,7 +1023,7 @@ function isMacroPlaceholder(value) {
764
1023
  function validDeviceId(value) {
765
1024
  return value && !isMacroPlaceholder(value) ? value : void 0;
766
1025
  }
767
- function isZeroedAdId(value) {
1026
+ function isZeroedAdId2(value) {
768
1027
  return ZEROED_AD_ID_PATTERNS.has(value.trim().toLowerCase());
769
1028
  }
770
1029
  function readNativeBridgeSignals() {
@@ -808,7 +1067,7 @@ function readNativeBridgeSignals() {
808
1067
  "deviceIdType",
809
1068
  "advertisingIdType",
810
1069
  "idType"
811
- ]) || inferDeviceIdType();
1070
+ ]) || void 0;
812
1071
  var limitAdTracking = readBridgeBoolean(source, [
813
1072
  "is_lat",
814
1073
  "limitAdTracking",
@@ -988,6 +1247,308 @@ function normalizeBoolean(value) {
988
1247
  }
989
1248
  return void 0;
990
1249
  }
1250
+ // src/utils/contentMetadata.ts
1251
+ var MAX_CONTENT_VALUE_LENGTH = 128;
1252
+ var BRIDGE_KEYS = {
1253
+ channelName: [
1254
+ "channelName",
1255
+ "ct_ch"
1256
+ ],
1257
+ programTitle: [
1258
+ "programTitle",
1259
+ "ct_ti"
1260
+ ],
1261
+ contentNetwork: [
1262
+ "contentNetwork",
1263
+ "ct_ne"
1264
+ ],
1265
+ contentType: [
1266
+ "contentType",
1267
+ "ctt"
1268
+ ],
1269
+ contentCategory: [
1270
+ "contentCategory",
1271
+ "ctc"
1272
+ ],
1273
+ contentGenre: [
1274
+ "contentGenre",
1275
+ "ctgr"
1276
+ ],
1277
+ contentLanguage: [
1278
+ "contentLanguage",
1279
+ "ctlg"
1280
+ ],
1281
+ contentDuration: [
1282
+ "contentDuration",
1283
+ "ctd"
1284
+ ],
1285
+ contentSeason: [
1286
+ "contentSeason",
1287
+ "cts"
1288
+ ],
1289
+ contentEpisode: [
1290
+ "contentEpisode",
1291
+ "cte"
1292
+ ],
1293
+ contentRating: [
1294
+ "contentRating",
1295
+ "ctr"
1296
+ ],
1297
+ contentId: [
1298
+ "contentId",
1299
+ "ctid"
1300
+ ]
1301
+ };
1302
+ function sanitizeContentValue(value) {
1303
+ if (typeof value !== "string") return void 0;
1304
+ var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1305
+ if (!cleaned) return void 0;
1306
+ if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
1307
+ if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
1308
+ return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
1309
+ }
1310
+ function sanitizeContentScalar(value) {
1311
+ if (typeof value === "number") {
1312
+ return Number.isFinite(value) ? String(value) : void 0;
1313
+ }
1314
+ return sanitizeContentValue(value);
1315
+ }
1316
+ function normalizeContentLanguage(value) {
1317
+ var cleaned = sanitizeContentValue(value);
1318
+ if (!cleaned) return void 0;
1319
+ var match = cleaned.match(/^([A-Za-z]{2})(?:[-_][A-Za-z0-9]{1,8})*$/);
1320
+ return match && match[1] ? match[1].toLowerCase() : void 0;
1321
+ }
1322
+ function normalizeContentDuration(value) {
1323
+ var raw = sanitizeContentScalar(value);
1324
+ if (raw == null || !/^-?\d+(\.\d+)?$/.test(raw)) return void 0;
1325
+ var seconds = Number(raw);
1326
+ if (seconds === -1) return -1;
1327
+ return seconds > 0 ? Math.round(seconds) : void 0;
1328
+ }
1329
+ function bridgeSources() {
1330
+ if (typeof window === "undefined") return [];
1331
+ var w = window;
1332
+ return [
1333
+ w.__STORMCLOUD_CTV__,
1334
+ w.__STORMCLOUD_CTV_AD_INFO__,
1335
+ w.stormcloudCtv
1336
+ ].filter(Boolean);
1337
+ }
1338
+ function readBridgeValue2(keys, sanitize) {
1339
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1340
+ try {
1341
+ for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1342
+ var source = _step.value;
1343
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
1344
+ try {
1345
+ for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
1346
+ var key = _step1.value;
1347
+ var value = void 0;
1348
+ try {
1349
+ value = source === null || source === void 0 ? void 0 : source[key];
1350
+ if (typeof value === "function") value = value.call(source);
1351
+ } catch (unused) {
1352
+ value = void 0;
1353
+ }
1354
+ var sanitized = sanitize(value);
1355
+ if (sanitized != null) return sanitized;
1356
+ }
1357
+ } catch (err) {
1358
+ _didIteratorError1 = true;
1359
+ _iteratorError1 = err;
1360
+ } finally{
1361
+ try {
1362
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
1363
+ _iterator1.return();
1364
+ }
1365
+ } finally{
1366
+ if (_didIteratorError1) {
1367
+ throw _iteratorError1;
1368
+ }
1369
+ }
1370
+ }
1371
+ }
1372
+ } catch (err) {
1373
+ _didIteratorError = true;
1374
+ _iteratorError = err;
1375
+ } finally{
1376
+ try {
1377
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1378
+ _iterator.return();
1379
+ }
1380
+ } finally{
1381
+ if (_didIteratorError) {
1382
+ throw _iteratorError;
1383
+ }
1384
+ }
1385
+ }
1386
+ return void 0;
1387
+ }
1388
+ function readBridgeContentValue(keys) {
1389
+ return readBridgeValue2(keys, sanitizeContentValue);
1390
+ }
1391
+ function resolveContentMetadata(config) {
1392
+ var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2, _config_contentDetails, _sanitizeContentValue3, _sanitizeContentValue4, _sanitizeContentValue5, _normalizeContentLanguage, _normalizeContentDuration, _sanitizeContentScalar, _sanitizeContentScalar1, _sanitizeContentValue6, _sanitizeContentValue7;
1393
+ var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
1394
+ var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
1395
+ var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
1396
+ var details = (_config_contentDetails = config.contentDetails) !== null && _config_contentDetails !== void 0 ? _config_contentDetails : {};
1397
+ var contentType = (_sanitizeContentValue3 = sanitizeContentValue(details.contentType)) !== null && _sanitizeContentValue3 !== void 0 ? _sanitizeContentValue3 : readBridgeContentValue(BRIDGE_KEYS.contentType);
1398
+ var contentCategory = (_sanitizeContentValue4 = sanitizeContentValue(details.category)) !== null && _sanitizeContentValue4 !== void 0 ? _sanitizeContentValue4 : readBridgeContentValue(BRIDGE_KEYS.contentCategory);
1399
+ var contentGenre = (_sanitizeContentValue5 = sanitizeContentValue(details.genre)) !== null && _sanitizeContentValue5 !== void 0 ? _sanitizeContentValue5 : readBridgeContentValue(BRIDGE_KEYS.contentGenre);
1400
+ var contentLanguage = (_normalizeContentLanguage = normalizeContentLanguage(details.language)) !== null && _normalizeContentLanguage !== void 0 ? _normalizeContentLanguage : readBridgeValue2(BRIDGE_KEYS.contentLanguage, normalizeContentLanguage);
1401
+ var contentDurationSeconds = (_normalizeContentDuration = normalizeContentDuration(details.durationSeconds)) !== null && _normalizeContentDuration !== void 0 ? _normalizeContentDuration : readBridgeValue2(BRIDGE_KEYS.contentDuration, normalizeContentDuration);
1402
+ var contentSeason = (_sanitizeContentScalar = sanitizeContentScalar(details.season)) !== null && _sanitizeContentScalar !== void 0 ? _sanitizeContentScalar : readBridgeValue2(BRIDGE_KEYS.contentSeason, sanitizeContentScalar);
1403
+ var contentEpisode = (_sanitizeContentScalar1 = sanitizeContentScalar(details.episode)) !== null && _sanitizeContentScalar1 !== void 0 ? _sanitizeContentScalar1 : readBridgeValue2(BRIDGE_KEYS.contentEpisode, sanitizeContentScalar);
1404
+ var contentRating = (_sanitizeContentValue6 = sanitizeContentValue(details.rating)) !== null && _sanitizeContentValue6 !== void 0 ? _sanitizeContentValue6 : readBridgeContentValue(BRIDGE_KEYS.contentRating);
1405
+ var contentId = (_sanitizeContentValue7 = sanitizeContentValue(details.contentId)) !== null && _sanitizeContentValue7 !== void 0 ? _sanitizeContentValue7 : readBridgeContentValue(BRIDGE_KEYS.contentId);
1406
+ return _object_spread({}, channelName ? {
1407
+ channelName: channelName
1408
+ } : {}, programTitle ? {
1409
+ programTitle: programTitle
1410
+ } : {}, contentNetwork ? {
1411
+ contentNetwork: contentNetwork
1412
+ } : {}, contentType ? {
1413
+ contentType: contentType
1414
+ } : {}, contentCategory ? {
1415
+ contentCategory: contentCategory
1416
+ } : {}, contentGenre ? {
1417
+ contentGenre: contentGenre
1418
+ } : {}, contentLanguage ? {
1419
+ contentLanguage: contentLanguage
1420
+ } : {}, contentDurationSeconds != null ? {
1421
+ contentDurationSeconds: contentDurationSeconds
1422
+ } : {}, contentSeason ? {
1423
+ contentSeason: contentSeason
1424
+ } : {}, contentEpisode ? {
1425
+ contentEpisode: contentEpisode
1426
+ } : {}, contentRating ? {
1427
+ contentRating: contentRating
1428
+ } : {}, contentId ? {
1429
+ contentId: contentId
1430
+ } : {});
1431
+ }
1432
+ function applyContentMetadataUpdate(target, meta) {
1433
+ var apply = function apply(key, value) {
1434
+ if (value === void 0) return;
1435
+ var clean = value === null ? void 0 : sanitizeContentValue(value);
1436
+ if (clean) target[key] = clean;
1437
+ else delete target[key];
1438
+ };
1439
+ apply("channelName", meta.channelName);
1440
+ apply("programTitle", meta.programTitle);
1441
+ apply("contentNetwork", meta.contentNetwork);
1442
+ if (meta.details === void 0) return;
1443
+ if (meta.details === null) delete target.contentDetails;
1444
+ else target.contentDetails = _object_spread({}, meta.details);
1445
+ }
1446
+ function appendMissingContentParams(url, meta) {
1447
+ if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
1448
+ try {
1449
+ var parsed = new URL(url);
1450
+ var add = function add(key, value) {
1451
+ if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
1452
+ };
1453
+ add("ct_ch", meta.channelName);
1454
+ add("ct_ti", meta.programTitle);
1455
+ add("ct_ne", meta.contentNetwork);
1456
+ return parsed.toString();
1457
+ } catch (unused) {
1458
+ return url;
1459
+ }
1460
+ }
1461
+ // src/utils/partnerSignals.ts
1462
+ var PLATFORM_IFA_TYPES = /* @__PURE__ */ new Set([
1463
+ "aaid",
1464
+ "adid",
1465
+ "afai",
1466
+ "idfa",
1467
+ "lgudid",
1468
+ "msai",
1469
+ "rida",
1470
+ "tifa",
1471
+ "tvos",
1472
+ "vaid",
1473
+ "vida"
1474
+ ]);
1475
+ function toIabIfaType(deviceIdType, source) {
1476
+ if (!deviceIdType) return void 0;
1477
+ var type = deviceIdType.trim().toLowerCase();
1478
+ if (source === "generated") return "sessionid";
1479
+ if (PLATFORM_IFA_TYPES.has(type)) return type;
1480
+ if (source === "platform") return "dpid";
1481
+ return "ppid";
1482
+ }
1483
+ function playbackMethodCode(autoPlay, muted) {
1484
+ if (autoPlay === false) return 3;
1485
+ if (autoPlay !== true || muted == null) return void 0;
1486
+ return muted ? 2 : 1;
1487
+ }
1488
+ function resolvePlayerSize(video) {
1489
+ var width = video ? video.clientWidth : 0;
1490
+ var height = video ? video.clientHeight : 0;
1491
+ if (!(width > 0 && height > 0) && typeof window !== "undefined") {
1492
+ width = window.innerWidth;
1493
+ height = window.innerHeight;
1494
+ }
1495
+ if (!(width > 0 && height > 0)) return {};
1496
+ return {
1497
+ width: Math.round(width),
1498
+ height: Math.round(height)
1499
+ };
1500
+ }
1501
+ function sanitizeUserId(value) {
1502
+ var cleaned = sanitizeContentValue(value);
1503
+ if (!cleaned || /\s/.test(cleaned)) return void 0;
1504
+ return cleaned;
1505
+ }
1506
+ function isPublicIpv4(ip) {
1507
+ var parts = ip.split(".");
1508
+ if (parts.length !== 4) return false;
1509
+ var nums = parts.map(function(p) {
1510
+ return /^\d{1,3}$/.test(p) ? Number(p) : NaN;
1511
+ });
1512
+ if (nums.some(function(n) {
1513
+ return !(n >= 0 && n <= 255);
1514
+ })) return false;
1515
+ var _nums = _sliced_to_array(nums, 2), a = _nums[0], b = _nums[1];
1516
+ if (a === 0 || a === 10 || a === 127 || a >= 224) return false;
1517
+ if (a === 100 && b >= 64 && b <= 127) return false;
1518
+ if (a === 169 && b === 254) return false;
1519
+ if (a === 172 && b >= 16 && b <= 31) return false;
1520
+ if (a === 192 && b === 168) return false;
1521
+ return true;
1522
+ }
1523
+ function isPublicIpv6(ip) {
1524
+ var lower = ip.toLowerCase();
1525
+ if (!/^[0-9a-f:]+$/.test(lower) || lower.split(":").length < 3) return false;
1526
+ if (lower === "::" || lower === "::1") return false;
1527
+ if (/^fe[89ab]/.test(lower)) return false;
1528
+ if (/^f[cd]/.test(lower)) return false;
1529
+ return true;
1530
+ }
1531
+ function sanitizePublicIp(value) {
1532
+ var cleaned = sanitizeContentValue(value);
1533
+ if (!cleaned) return void 0;
1534
+ if (cleaned.includes(".")) return isPublicIpv4(cleaned) ? cleaned : void 0;
1535
+ return isPublicIpv6(cleaned) ? cleaned : void 0;
1536
+ }
1537
+ function resolveUserId(configValue) {
1538
+ var _sanitizeUserId;
1539
+ return (_sanitizeUserId = sanitizeUserId(configValue)) !== null && _sanitizeUserId !== void 0 ? _sanitizeUserId : readBridgeValue2([
1540
+ "userId",
1541
+ "uid"
1542
+ ], sanitizeUserId);
1543
+ }
1544
+ function resolveClientIp(configValue) {
1545
+ var _sanitizePublicIp;
1546
+ return (_sanitizePublicIp = sanitizePublicIp(configValue)) !== null && _sanitizePublicIp !== void 0 ? _sanitizePublicIp : readBridgeValue2([
1547
+ "ipAddress",
1548
+ "clientIp",
1549
+ "ip"
1550
+ ], sanitizePublicIp);
1551
+ }
991
1552
  // src/utils/vastMacros.ts
992
1553
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
993
1554
  var INVALID_VAST_PARAM_KEY = /^\s|\s$/;
@@ -1305,7 +1866,8 @@ var NESTED_QUERY_PARAM_KEYS = /* @__PURE__ */ new Set([
1305
1866
  var SCVP_POD_MACROS = /* @__PURE__ */ new Set([
1306
1867
  "PMND",
1307
1868
  "PMXD",
1308
- "PMAD"
1869
+ "PMAD",
1870
+ "MABD"
1309
1871
  ]);
1310
1872
  function hasScvpMacros(url) {
1311
1873
  return !!url && SCVP_MACRO_DETECT.test(url);
@@ -1350,12 +1912,15 @@ function resolveScvpMacroValues(ctx) {
1350
1912
  set("RDID", deviceId);
1351
1913
  set("IDTYPE", deviceIdType);
1352
1914
  set("IS-LAT", (_toFlag = toFlag(ctx.limitAdTracking)) !== null && _toFlag !== void 0 ? _toFlag : "0");
1915
+ set("IFA", deviceId);
1916
+ set("IFA-TYPE", toIabIfaType(deviceIdType, ctx.deviceIdSource));
1353
1917
  }
1354
1918
  set("SID", ctx.sessionId);
1355
1919
  set("DTH", ctx.deviceTypeHint);
1356
1920
  set("GIVN", ctx.palNonce);
1357
1921
  set("CT-TI", ctx.programTitle);
1358
1922
  set("CT-CH", ctx.channelName);
1923
+ set("CT-NE", ctx.contentNetwork);
1359
1924
  set("POD", ctx.pod);
1360
1925
  set("CORRELATOR", ctx.correlator);
1361
1926
  set("SCOR", ctx.streamCorrelator);
@@ -1366,6 +1931,26 @@ function resolveScvpMacroValues(ctx) {
1366
1931
  set("GDPR", (_ctx_consent = ctx.consent) === null || _ctx_consent === void 0 ? void 0 : _ctx_consent.gdpr);
1367
1932
  set("GDPR-CONSENT", (_ctx_consent1 = ctx.consent) === null || _ctx_consent1 === void 0 ? void 0 : _ctx_consent1.gdprConsent);
1368
1933
  set("US-PRIVACY", (_ctx_consent2 = ctx.consent) === null || _ctx_consent2 === void 0 ? void 0 : _ctx_consent2.usPrivacy);
1934
+ set("PLAYER-WIDTH", ctx.playerWidth);
1935
+ set("PLAYER-HEIGHT", ctx.playerHeight);
1936
+ set("TIMESTAMP", ctx.timestamp);
1937
+ set("LIVE", toFlag(ctx.isLive));
1938
+ set("VPMT", playbackMethodCode(ctx.isCtv ? true : ctx.adWillAutoPlay, ctx.adWillPlayMuted));
1939
+ set("DEVICE-MAKE", ctx.deviceMake);
1940
+ set("DEVICE-MODEL", ctx.deviceModel);
1941
+ set("DEVICE-HWV", ctx.deviceHardwareVersion);
1942
+ set("UA", ctx.userAgent);
1943
+ set("IP", ctx.ipAddress);
1944
+ set("UID", ctx.userId);
1945
+ set("CT-TYPE", ctx.contentType);
1946
+ set("CT-CATEGORY", ctx.contentCategory);
1947
+ set("CT-GENRE", ctx.contentGenre);
1948
+ set("CT-LANGUAGE", ctx.contentLanguage);
1949
+ set("CT-DURATION", ctx.contentDurationSeconds != null ? ctx.contentDurationSeconds : ctx.isLive ? -1 : void 0);
1950
+ set("CT-SEASON", ctx.contentSeason);
1951
+ set("CT-EPISODE", ctx.contentEpisode);
1952
+ set("CT-RATING", ctx.contentRating);
1953
+ set("CT-ID", ctx.contentId);
1369
1954
  return values;
1370
1955
  }
1371
1956
  var keepNone = function keepNone() {
@@ -1584,6 +2169,9 @@ function applyVastMacros(baseUrl, ctx) {
1584
2169
  if (ctx.channelName) {
1585
2170
  params.set("ct_ch", ctx.channelName);
1586
2171
  }
2172
+ if (ctx.contentNetwork) {
2173
+ params.set("ct_ne", ctx.contentNetwork);
2174
+ }
1587
2175
  var staleKeys = [];
1588
2176
  params.forEach(function(value, key) {
1589
2177
  if (isMacroPlaceholder2(value)) {
@@ -2248,8 +2836,17 @@ function detectBrowser() {
2248
2836
  chromeVersion: chromeVersionNum
2249
2837
  };
2250
2838
  }
2839
+ var singleDecoderOverride;
2840
+ function setSingleDecoderOverride(value) {
2841
+ singleDecoderOverride = value;
2842
+ }
2251
2843
  function requiresMediaPipelineResetAfterAds() {
2252
2844
  var _browser_tizenVersion;
2845
+ if (singleDecoderOverride != null) return singleDecoderOverride;
2846
+ try {
2847
+ var globalOverride = typeof window !== "undefined" ? window.__STORMCLOUD_SINGLE_DECODER__ : void 0;
2848
+ if (typeof globalOverride === "boolean") return globalOverride;
2849
+ } catch (unused) {}
2253
2850
  var browser = detectBrowser();
2254
2851
  return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
2255
2852
  }
@@ -2409,7 +3006,7 @@ function substituteVastTrackingMacros(url) {
2409
3006
  });
2410
3007
  }
2411
3008
  // src/player/OptimizedPodRequest.ts
2412
- var DEFAULT_REQUEST_SAFETY_MS = 1500;
3009
+ var DEFAULT_REQUEST_SAFETY_MS = 2500;
2413
3010
  var GAM_AD_OPPORTUNITY_DURATION_MS = 3e4;
2414
3011
  var POD_PARAM_KEYS = [
2415
3012
  "pmnd",
@@ -2569,15 +3166,20 @@ function finalizeGamRequestUrl(rawUrl, ctx) {
2569
3166
  values.set("PMND", String(pod.pmnd));
2570
3167
  values.set("PMXD", String(pod.pmxd));
2571
3168
  if (pod.pmad != null) values.set("PMAD", String(pod.pmad));
3169
+ values.set("MABD", String(Math.max(1, Math.floor(pod.pmxd / 1e3))));
2572
3170
  }
2573
3171
  var substituted = substituteScvpMacros(rawUrl, values);
2574
3172
  var finalUrl;
2575
3173
  try {
2576
3174
  var url = new URL(normalizeVastTagUrl(substituted.url));
3175
+ var isGam = GAM_AD_HOSTS.has(url.hostname);
3176
+ var setPodParam = function setPodParam(key, value) {
3177
+ if (isGam || url.searchParams.has(key)) url.searchParams.set(key, String(value));
3178
+ };
2577
3179
  if (pod) {
2578
- url.searchParams.set("pmnd", String(pod.pmnd));
2579
- url.searchParams.set("pmxd", String(pod.pmxd));
2580
- if (pod.pmad != null) url.searchParams.set("pmad", String(pod.pmad));
3180
+ setPodParam("pmnd", pod.pmnd);
3181
+ setPodParam("pmxd", pod.pmxd);
3182
+ if (pod.pmad != null) setPodParam("pmad", pod.pmad);
2581
3183
  else url.searchParams.delete("pmad");
2582
3184
  } else {
2583
3185
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2643,7 +3245,9 @@ function validateGamRequestUrl(url, expect) {
2643
3245
  if (leftover.length > 0) problems.push("unresolved SCVP macros: ".concat(leftover.join(", ")));
2644
3246
  var params;
2645
3247
  try {
2646
- params = new URL(url).searchParams;
3248
+ var parsed = new URL(url);
3249
+ if (!GAM_AD_HOSTS.has(parsed.hostname)) return problems;
3250
+ params = parsed.searchParams;
2647
3251
  } catch (unused) {
2648
3252
  return problems.concat("URL could not be parsed");
2649
3253
  }
@@ -2833,6 +3437,9 @@ function createHlsAdPlayer(contentVideo, options) {
2833
3437
  var mediaCandidateIndex = 0;
2834
3438
  var mediaStartTimerId;
2835
3439
  var MEDIA_START_TIMEOUT_MS = (_ref = options === null || options === void 0 ? void 0 : options.mediaStartTimeoutMs) !== null && _ref !== void 0 ? _ref : 8e3;
3440
+ var MAX_MEDIA_START_ATTEMPTS = 2;
3441
+ var MEDIA_START_TOTAL_BUDGET_MS = Math.max(MEDIA_START_TIMEOUT_MS, 1e4);
3442
+ var mediaStartBudgetStartedAt = 0;
2836
3443
  var VAST_ERROR_MEDIA_TIMEOUT = 402;
2837
3444
  var pendingVastRequests = /* @__PURE__ */ new Set();
2838
3445
  var pendingRequestAbortReason;
@@ -4847,12 +5454,14 @@ function createHlsAdPlayer(contentVideo, options) {
4847
5454
  clearMediaStartTimer();
4848
5455
  if (!(MEDIA_START_TIMEOUT_MS > 0)) return;
4849
5456
  var startedAt = Date.now();
5457
+ var budgetLeftMs = mediaStartBudgetStartedAt > 0 ? MEDIA_START_TOTAL_BUDGET_MS - (startedAt - mediaStartBudgetStartedAt) : MEDIA_START_TIMEOUT_MS;
5458
+ var timeoutMs = Math.max(1e3, Math.min(MEDIA_START_TIMEOUT_MS, budgetLeftMs));
4850
5459
  mediaStartTimerId = setTimeout(function() {
4851
5460
  mediaStartTimerId = void 0;
4852
5461
  if (!adPlaying || trackingFired.impression) return;
4853
- console.warn("[HlsAdPlayer] Ad media did not start playing within ".concat(MEDIA_START_TIMEOUT_MS, "ms"));
5462
+ console.warn("[HlsAdPlayer] Ad media did not start playing within ".concat(timeoutMs, "ms"));
4854
5463
  logFunnel("play_resolved_but_never_started", {
4855
- timeoutMs: MEDIA_START_TIMEOUT_MS,
5464
+ timeoutMs: timeoutMs,
4856
5465
  elapsedMs: Date.now() - startedAt,
4857
5466
  readyState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.readyState,
4858
5467
  networkState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.networkState,
@@ -4861,7 +5470,7 @@ function createHlsAdPlayer(contentVideo, options) {
4861
5470
  vastErrorCode: VAST_ERROR_MEDIA_TIMEOUT
4862
5471
  });
4863
5472
  recoverFromAdFailure(VAST_ERROR_MEDIA_TIMEOUT);
4864
- }, MEDIA_START_TIMEOUT_MS);
5473
+ }, timeoutMs);
4865
5474
  }
4866
5475
  function resetVideoElementForNextSource() {
4867
5476
  clearStallWatchdog();
@@ -4876,6 +5485,20 @@ function createHlsAdPlayer(contentVideo, options) {
4876
5485
  function tryNextMediaCandidate() {
4877
5486
  if (!currentAd || trackingFired.impression) return false;
4878
5487
  if (mediaCandidateIndex >= mediaCandidates.length - 1) return false;
5488
+ if (mediaCandidateIndex + 1 >= MAX_MEDIA_START_ATTEMPTS) {
5489
+ logFunnel("media_fallback_capped", {
5490
+ reason: "max_attempts",
5491
+ attempts: mediaCandidateIndex + 1
5492
+ });
5493
+ return false;
5494
+ }
5495
+ if (mediaStartBudgetStartedAt > 0 && Date.now() - mediaStartBudgetStartedAt >= MEDIA_START_TOTAL_BUDGET_MS) {
5496
+ logFunnel("media_fallback_capped", {
5497
+ reason: "time_budget",
5498
+ elapsedMs: Date.now() - mediaStartBudgetStartedAt
5499
+ });
5500
+ return false;
5501
+ }
4879
5502
  var failedUrl = currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url;
4880
5503
  mediaCandidateIndex++;
4881
5504
  var next = mediaCandidates[mediaCandidateIndex];
@@ -4909,6 +5532,7 @@ function createHlsAdPlayer(contentVideo, options) {
4909
5532
  }
4910
5533
  mediaCandidates = rankMediaCandidates(currentAd.mediaFiles);
4911
5534
  mediaCandidateIndex = 0;
5535
+ mediaStartBudgetStartedAt = Date.now();
4912
5536
  var mediaFile = mediaCandidates[0];
4913
5537
  if (!mediaFile) {
4914
5538
  logFunnel("media_unsupported", {
@@ -5848,6 +6472,7 @@ function getOrCreateNonceLoader(allowStorage) {
5848
6472
  }
5849
6473
  function createPalNonceManager() {
5850
6474
  var currentNonce = "";
6475
+ var currentNonceCreatedAt = 0;
5851
6476
  var currentNonceManager;
5852
6477
  var pendingNonce;
5853
6478
  return {
@@ -5864,6 +6489,9 @@ function createPalNonceManager() {
5864
6489
  getCurrentNonce: function getCurrentNonce() {
5865
6490
  return currentNonce;
5866
6491
  },
6492
+ getNonceAgeMs: function getNonceAgeMs() {
6493
+ return currentNonce ? Date.now() - currentNonceCreatedAt : void 0;
6494
+ },
5867
6495
  waitForNonce: function waitForNonce(maxWaitMs) {
5868
6496
  if (currentNonce) return Promise.resolve(currentNonce);
5869
6497
  var pending = pendingNonce;
@@ -5916,13 +6544,14 @@ function createPalNonceManager() {
5916
6544
  },
5917
6545
  reset: function reset() {
5918
6546
  currentNonce = "";
6547
+ currentNonceCreatedAt = 0;
5919
6548
  currentNonceManager = void 0;
5920
6549
  pendingNonce = void 0;
5921
6550
  }
5922
6551
  };
5923
6552
  function generate(options) {
5924
6553
  return _async_to_generator(function() {
5925
- var _options_allowStorage, _options_adWillAutoPlay, _options_adWillPlayMuted, _options_playerVolume, _options_continuousPlayback, loader, goog, request, manager, error;
6554
+ var _options_allowStorage, _options_adWillAutoPlay, _options_adWillPlayMuted, _options_playerVolume, _options_continuousPlayback, _options_iconsSupported, _options_supportedApiFrameworks, loader, goog, request, apiFrameworks, manager, error;
5926
6555
  return _ts_generator(this, function(_state) {
5927
6556
  switch(_state.label){
5928
6557
  case 0:
@@ -5946,10 +6575,11 @@ function createPalNonceManager() {
5946
6575
  request.playerVolume = (_options_playerVolume = options.playerVolume) !== null && _options_playerVolume !== void 0 ? _options_playerVolume : request.adWillPlayMuted ? 0 : 1;
5947
6576
  request.continuousPlayback = (_options_continuousPlayback = options.continuousPlayback) !== null && _options_continuousPlayback !== void 0 ? _options_continuousPlayback : true;
5948
6577
  request.descriptionUrl = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
5949
- request.iconsSupported = true;
6578
+ request.iconsSupported = (_options_iconsSupported = options.iconsSupported) !== null && _options_iconsSupported !== void 0 ? _options_iconsSupported : false;
5950
6579
  request.playerType = "StormcloudVideoPlayer";
5951
6580
  request.playerVersion = "1.0";
5952
- request.supportedApiFrameworks = "2,7,9";
6581
+ apiFrameworks = ((_options_supportedApiFrameworks = options.supportedApiFrameworks) !== null && _options_supportedApiFrameworks !== void 0 ? _options_supportedApiFrameworks : "").trim();
6582
+ if (apiFrameworks) request.supportedApiFrameworks = apiFrameworks;
5953
6583
  request.url = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
5954
6584
  request.videoWidth = options.videoWidth || 640;
5955
6585
  request.videoHeight = options.videoHeight || 480;
@@ -5979,6 +6609,7 @@ function createPalNonceManager() {
5979
6609
  manager = _state.sent();
5980
6610
  currentNonceManager = manager;
5981
6611
  currentNonce = manager.getNonce();
6612
+ currentNonceCreatedAt = Date.now();
5982
6613
  console.log("[PAL] Nonce generated successfully");
5983
6614
  return [
5984
6615
  2,
@@ -6002,6 +6633,458 @@ function createPalNonceManager() {
6002
6633
  })();
6003
6634
  }
6004
6635
  }
6636
+ // src/utils/deviceInfo.ts
6637
+ var CATEGORY_CODES = {
6638
+ "LG TV": "lg_tv",
6639
+ "LG Set-Top Box": "lg_stb",
6640
+ "Samsung TV": "samsung_tv",
6641
+ Other: "other"
6642
+ };
6643
+ var DEVICE_CATEGORIES = [
6644
+ "LG TV",
6645
+ "LG Set-Top Box",
6646
+ "Samsung TV",
6647
+ "Other"
6648
+ ];
6649
+ var hostDeviceInfo;
6650
+ var lgDeviceInfo;
6651
+ var platformCache;
6652
+ var primePromise;
6653
+ function cleanString(value) {
6654
+ var maxLength = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 128;
6655
+ if (typeof value !== "string") return void 0;
6656
+ var t = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
6657
+ if (!t || /^(unknown|null|undefined|none|n\/a|-|0)$/i.test(t)) return void 0;
6658
+ return t.length > maxLength ? t.slice(0, maxLength) : t;
6659
+ }
6660
+ function safeCall2(fn, thisArg) {
6661
+ if (typeof fn !== "function") return void 0;
6662
+ try {
6663
+ return fn.call(thisArg);
6664
+ } catch (unused) {
6665
+ return void 0;
6666
+ }
6667
+ }
6668
+ function userAgent() {
6669
+ return typeof navigator !== "undefined" ? navigator.userAgent || "" : "";
6670
+ }
6671
+ function bridgeSources2() {
6672
+ if (typeof window === "undefined") return [];
6673
+ var w = window;
6674
+ return [
6675
+ w.__STORMCLOUD_CTV__,
6676
+ w.__STORMCLOUD_CTV_AD_INFO__,
6677
+ w.stormcloudCtv
6678
+ ].filter(Boolean);
6679
+ }
6680
+ function readBridge(keys) {
6681
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6682
+ try {
6683
+ for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6684
+ var source = _step.value;
6685
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6686
+ try {
6687
+ for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
6688
+ var key = _step1.value;
6689
+ var value = void 0;
6690
+ try {
6691
+ value = source === null || source === void 0 ? void 0 : source[key];
6692
+ if (typeof value === "function") value = value.call(source);
6693
+ } catch (unused) {
6694
+ value = void 0;
6695
+ }
6696
+ var clean = cleanString(value);
6697
+ if (clean) return clean;
6698
+ }
6699
+ } catch (err) {
6700
+ _didIteratorError1 = true;
6701
+ _iteratorError1 = err;
6702
+ } finally{
6703
+ try {
6704
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
6705
+ _iterator1.return();
6706
+ }
6707
+ } finally{
6708
+ if (_didIteratorError1) {
6709
+ throw _iteratorError1;
6710
+ }
6711
+ }
6712
+ }
6713
+ }
6714
+ } catch (err) {
6715
+ _didIteratorError = true;
6716
+ _iteratorError = err;
6717
+ } finally{
6718
+ try {
6719
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
6720
+ _iterator.return();
6721
+ }
6722
+ } finally{
6723
+ if (_didIteratorError) {
6724
+ throw _iteratorError;
6725
+ }
6726
+ }
6727
+ }
6728
+ return void 0;
6729
+ }
6730
+ function makeForCategory(category) {
6731
+ if (category === "LG TV" || category === "LG Set-Top Box") return "LG";
6732
+ if (category === "Samsung TV") return "Samsung";
6733
+ return void 0;
6734
+ }
6735
+ function normalizeCategory(value) {
6736
+ var v = cleanString(value);
6737
+ if (!v) return void 0;
6738
+ var exact = DEVICE_CATEGORIES.find(function(c) {
6739
+ return c.toLowerCase() === v.toLowerCase();
6740
+ });
6741
+ if (exact) return exact;
6742
+ var code = v.toLowerCase().replace(/[\s-]+/g, "_");
6743
+ var byCode = Object.keys(CATEGORY_CODES).find(function(c) {
6744
+ return CATEGORY_CODES[c] === code;
6745
+ });
6746
+ return byCode;
6747
+ }
6748
+ function parseUserAgentDeviceInfo(ua) {
6749
+ var sources = [];
6750
+ var out = {
6751
+ platform: "other",
6752
+ sources: sources
6753
+ };
6754
+ var chrome = ua.match(/(?:Chrome|PCBR)\/(\d+)\./) || ua.match(/\s(\d{2,3})\.\d+\.\d+\.\d+\/[\d.]+\s+TV\b/);
6755
+ if (chrome && chrome[1]) out.browserMajorVersion = parseInt(chrome[1], 10);
6756
+ if (/Web0S|webOS/i.test(ua)) {
6757
+ out.platform = "webos";
6758
+ var lg = ua.match(/LGE\s*;\s*([A-Za-z0-9][A-Za-z0-9._-]*)\s*;\s*(\d{2}\.\d{2}\.\d{2})/);
6759
+ if (lg && lg[1] && lg[2]) {
6760
+ out.model = lg[1];
6761
+ out.firmware = lg[2];
6762
+ sources.push("user_agent");
6763
+ }
6764
+ } else if (/Tizen/i.test(ua)) {
6765
+ out.platform = "tizen";
6766
+ var tizen = ua.match(/Tizen\s+(\d+(?:\.\d+)*)/i);
6767
+ if (tizen && tizen[1]) {
6768
+ out.osVersion = "Tizen ".concat(tizen[1]);
6769
+ sources.push("user_agent");
6770
+ }
6771
+ }
6772
+ return out;
6773
+ }
6774
+ function readSamsungProductInfo() {
6775
+ var _cleanString;
6776
+ var _window_webapis;
6777
+ if (typeof window === "undefined") return void 0;
6778
+ var productinfo = (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.productinfo;
6779
+ if (!productinfo) return void 0;
6780
+ var model = (_cleanString = cleanString(safeCall2(productinfo.getRealModel, productinfo), 40)) !== null && _cleanString !== void 0 ? _cleanString : cleanString(safeCall2(productinfo.getModel, productinfo), 40);
6781
+ var firmware = cleanString(safeCall2(productinfo.getFirmware, productinfo), 64);
6782
+ var duid = cleanString(safeCall2(productinfo.getDuid, productinfo), 128);
6783
+ if (!model && !firmware && !duid) return void 0;
6784
+ return _object_spread({}, model ? {
6785
+ model: model
6786
+ } : {}, firmware ? {
6787
+ firmware: firmware
6788
+ } : {}, duid ? {
6789
+ internalDeviceId: duid,
6790
+ internalDeviceIdSource: "samsung_duid"
6791
+ } : {});
6792
+ }
6793
+ function readLgDeviceInfo(timeoutMs) {
6794
+ var webOS = typeof window !== "undefined" ? window.webOS : void 0;
6795
+ if (lgDeviceInfo || !webOS || typeof webOS.deviceInfo !== "function") return Promise.resolve();
6796
+ return new Promise(function(resolve) {
6797
+ var settled = false;
6798
+ var finish = function finish() {
6799
+ if (settled) return;
6800
+ settled = true;
6801
+ clearTimeout(timer);
6802
+ resolve();
6803
+ };
6804
+ var timer = setTimeout(finish, Math.max(0, timeoutMs));
6805
+ try {
6806
+ webOS.deviceInfo(function(info) {
6807
+ var model = cleanString(info === null || info === void 0 ? void 0 : info.modelName, 40);
6808
+ var firmware = cleanString(info === null || info === void 0 ? void 0 : info.version, 64);
6809
+ var sdkVersion = cleanString(info === null || info === void 0 ? void 0 : info.sdkVersion, 32);
6810
+ lgDeviceInfo = _object_spread({}, model ? {
6811
+ model: model
6812
+ } : {}, firmware ? {
6813
+ firmware: firmware
6814
+ } : {}, sdkVersion ? {
6815
+ sdkVersion: sdkVersion
6816
+ } : {});
6817
+ finish();
6818
+ });
6819
+ } catch (unused) {
6820
+ finish();
6821
+ }
6822
+ });
6823
+ }
6824
+ function computePlatformInfo() {
6825
+ var info = parseUserAgentDeviceInfo(userAgent());
6826
+ var sources = _to_consumable_array(info.sources);
6827
+ var samsung = readSamsungProductInfo();
6828
+ if (samsung) {
6829
+ info.platform = "tizen";
6830
+ if (samsung.model) info.model = samsung.model;
6831
+ if (samsung.firmware) info.firmware = samsung.firmware;
6832
+ if (samsung.internalDeviceId) {
6833
+ info.internalDeviceId = samsung.internalDeviceId;
6834
+ info.internalDeviceIdSource = "samsung_duid";
6835
+ }
6836
+ sources.push("samsung_productinfo");
6837
+ }
6838
+ if (lgDeviceInfo) {
6839
+ info.platform = "webos";
6840
+ if (!info.model && lgDeviceInfo.model) info.model = lgDeviceInfo.model;
6841
+ if (!info.firmware && lgDeviceInfo.firmware) info.firmware = lgDeviceInfo.firmware;
6842
+ if (lgDeviceInfo.sdkVersion) info.osVersion = "webOS TV ".concat(lgDeviceInfo.sdkVersion);
6843
+ sources.push("lg_deviceinfo");
6844
+ }
6845
+ var lgUdid = readCachedLgUdid();
6846
+ if ((lgUdid === null || lgUdid === void 0 ? void 0 : lgUdid.deviceId) && !info.internalDeviceId) {
6847
+ info.internalDeviceId = lgUdid.deviceId;
6848
+ info.internalDeviceIdSource = "lg_udid";
6849
+ sources.push("lg_udid");
6850
+ }
6851
+ info.sources = sources;
6852
+ return info;
6853
+ }
6854
+ function categorize(platform, model) {
6855
+ if (platform === "tizen") return "Samsung TV";
6856
+ if (platform === "webos") {
6857
+ var ua = userAgent();
6858
+ if (model && /^STB-/i.test(model) || /\bSTB-\d{4}|LGSTB/i.test(ua)) return "LG Set-Top Box";
6859
+ return "LG TV";
6860
+ }
6861
+ return "Other";
6862
+ }
6863
+ function setHostDeviceInfo(info) {
6864
+ hostDeviceInfo = info ? _object_spread({}, info) : void 0;
6865
+ }
6866
+ function primeDeviceInfo() {
6867
+ var timeoutMs = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1500;
6868
+ if (!primePromise) {
6869
+ primePromise = Promise.all([
6870
+ readLgDeviceInfo(timeoutMs),
6871
+ primeLgUdid(timeoutMs)
6872
+ ]).catch(function() {
6873
+ return void 0;
6874
+ }).then(function() {
6875
+ platformCache = computePlatformInfo();
6876
+ return getDeviceInfo();
6877
+ });
6878
+ }
6879
+ return primePromise;
6880
+ }
6881
+ function getDeviceInfo() {
6882
+ var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory, _ref3, _cleanString4, _cleanString5;
6883
+ var platform = platformCache !== null && platformCache !== void 0 ? platformCache : computePlatformInfo();
6884
+ if (primePromise && !platformCache) {} else {
6885
+ platformCache = platform;
6886
+ }
6887
+ var host = hostDeviceInfo !== null && hostDeviceInfo !== void 0 ? hostDeviceInfo : {};
6888
+ var bridge = {
6889
+ terminalId: readBridge([
6890
+ "terminalId",
6891
+ "terminal_id"
6892
+ ]),
6893
+ internalDeviceId: readBridge([
6894
+ "internalDeviceId",
6895
+ "internal_device_id"
6896
+ ]),
6897
+ model: readBridge([
6898
+ "deviceModel"
6899
+ ]),
6900
+ firmware: readBridge([
6901
+ "firmwareVersion"
6902
+ ]),
6903
+ category: normalizeCategory(readBridge([
6904
+ "deviceCategory"
6905
+ ])),
6906
+ make: readBridge([
6907
+ "deviceMake"
6908
+ ]),
6909
+ hardwareVersion: readBridge([
6910
+ "deviceHardwareVersion",
6911
+ "hardwareVersion"
6912
+ ])
6913
+ };
6914
+ var terminalId = (_cleanString = cleanString(host.terminalId)) !== null && _cleanString !== void 0 ? _cleanString : bridge.terminalId;
6915
+ var hostInternalId = (_cleanString1 = cleanString(host.internalDeviceId)) !== null && _cleanString1 !== void 0 ? _cleanString1 : bridge.internalDeviceId;
6916
+ var model = (_ref = (_cleanString2 = cleanString(host.model, 40)) !== null && _cleanString2 !== void 0 ? _cleanString2 : bridge.model) !== null && _ref !== void 0 ? _ref : platform.model;
6917
+ var firmware = (_ref1 = (_cleanString3 = cleanString(host.firmware, 64)) !== null && _cleanString3 !== void 0 ? _cleanString3 : bridge.firmware) !== null && _ref1 !== void 0 ? _ref1 : platform.firmware;
6918
+ var category = (_ref2 = (_normalizeCategory = normalizeCategory(host.category)) !== null && _normalizeCategory !== void 0 ? _normalizeCategory : bridge.category) !== null && _ref2 !== void 0 ? _ref2 : categorize(platform.platform, model);
6919
+ var sources = _to_consumable_array(platform.sources);
6920
+ var bridgeValues = [
6921
+ bridge.terminalId,
6922
+ bridge.internalDeviceId,
6923
+ bridge.model,
6924
+ bridge.firmware,
6925
+ bridge.category,
6926
+ bridge.make,
6927
+ bridge.hardwareVersion
6928
+ ];
6929
+ if (bridgeValues.some(function(v) {
6930
+ return v !== void 0;
6931
+ })) sources.unshift("bridge");
6932
+ if (hostDeviceInfo) sources.unshift("host");
6933
+ var internalDeviceId = hostInternalId !== null && hostInternalId !== void 0 ? hostInternalId : platform.internalDeviceId;
6934
+ var internalDeviceIdSource = hostInternalId ? "host" : platform.internalDeviceIdSource;
6935
+ var make = (_ref3 = (_cleanString4 = cleanString(host.make, 40)) !== null && _cleanString4 !== void 0 ? _cleanString4 : bridge.make) !== null && _ref3 !== void 0 ? _ref3 : makeForCategory(category);
6936
+ var hardwareVersion = (_cleanString5 = cleanString(host.hardwareVersion, 40)) !== null && _cleanString5 !== void 0 ? _cleanString5 : bridge.hardwareVersion;
6937
+ var sonifiModel = model && category === "Samsung TV" && !/^SAMSUNG-IPTV-/i.test(model) ? "SAMSUNG-IPTV-".concat(model) : model;
6938
+ return _object_spread_props(_object_spread({
6939
+ category: category,
6940
+ categoryCode: CATEGORY_CODES[category]
6941
+ }, make ? {
6942
+ make: make
6943
+ } : {}, model ? {
6944
+ model: model
6945
+ } : {}, hardwareVersion ? {
6946
+ hardwareVersion: hardwareVersion
6947
+ } : {}, sonifiModel ? {
6948
+ sonifiModel: sonifiModel
6949
+ } : {}, firmware ? {
6950
+ firmware: firmware
6951
+ } : {}, platform.osVersion ? {
6952
+ osVersion: platform.osVersion
6953
+ } : {}, platform.browserMajorVersion != null ? {
6954
+ browserMajorVersion: platform.browserMajorVersion
6955
+ } : {}, internalDeviceId ? {
6956
+ internalDeviceId: internalDeviceId
6957
+ } : {}, internalDeviceId && internalDeviceIdSource ? {
6958
+ internalDeviceIdSource: internalDeviceIdSource
6959
+ } : {}, terminalId ? {
6960
+ terminalId: terminalId
6961
+ } : {}), {
6962
+ sources: sources
6963
+ });
6964
+ }
6965
+ var DEVICE_KEY_VALUE_KEYS = {
6966
+ category: "sc_dev",
6967
+ model: "sc_model",
6968
+ firmware: "sc_fw"
6969
+ };
6970
+ function sanitizeKeyValue(value) {
6971
+ if (typeof value !== "string") return void 0;
6972
+ var v = value.trim().replace(/[^A-Za-z0-9._-]+/g, "_").replace(/^_+|_+$/g, "");
6973
+ return v ? v.slice(0, 40) : void 0;
6974
+ }
6975
+ function deviceKeyValuePairs(info) {
6976
+ var pairs = [
6977
+ [
6978
+ DEVICE_KEY_VALUE_KEYS.category,
6979
+ info.categoryCode
6980
+ ]
6981
+ ];
6982
+ var model = sanitizeKeyValue(info.model);
6983
+ var firmware = sanitizeKeyValue(info.firmware);
6984
+ if (model) pairs.push([
6985
+ DEVICE_KEY_VALUE_KEYS.model,
6986
+ model
6987
+ ]);
6988
+ if (firmware) pairs.push([
6989
+ DEVICE_KEY_VALUE_KEYS.firmware,
6990
+ firmware
6991
+ ]);
6992
+ return pairs;
6993
+ }
6994
+ function applyDeviceKeyValues(url, info) {
6995
+ try {
6996
+ var parsed = new URL(url);
6997
+ var pairs = deviceKeyValuePairs(info);
6998
+ var ours = new Set(pairs.map(function(param) {
6999
+ var _param = _sliced_to_array(param, 1), k = _param[0];
7000
+ return k;
7001
+ }));
7002
+ var existing = (parsed.searchParams.get("cust_params") || "").split("&").filter(function(p) {
7003
+ var _p_split_;
7004
+ return p !== "" && !ours.has((_p_split_ = p.split("=")[0]) !== null && _p_split_ !== void 0 ? _p_split_ : "");
7005
+ });
7006
+ var merged = existing.concat(pairs.map(function(param) {
7007
+ var _param = _sliced_to_array(param, 2), k = _param[0], v = _param[1];
7008
+ return "".concat(k, "=").concat(v);
7009
+ })).join("&");
7010
+ parsed.searchParams.set("cust_params", merged);
7011
+ return parsed.toString();
7012
+ } catch (unused) {
7013
+ return url;
7014
+ }
7015
+ }
7016
+ function deviceInfoAnalyticsFields(info) {
7017
+ return _object_spread({
7018
+ device_category: info.category
7019
+ }, info.model ? {
7020
+ device_model: info.model
7021
+ } : {}, info.sonifiModel ? {
7022
+ sonifi_model: info.sonifiModel
7023
+ } : {}, info.firmware ? {
7024
+ firmware_version: info.firmware
7025
+ } : {}, info.osVersion ? {
7026
+ os_version: info.osVersion
7027
+ } : {}, info.browserMajorVersion != null ? {
7028
+ browser_major_version: info.browserMajorVersion
7029
+ } : {}, info.internalDeviceId ? {
7030
+ internal_device_id: info.internalDeviceId
7031
+ } : {}, info.internalDeviceIdSource ? {
7032
+ internal_device_id_source: info.internalDeviceIdSource
7033
+ } : {}, info.terminalId ? {
7034
+ terminal_id: info.terminalId
7035
+ } : {});
7036
+ }
7037
+ // src/utils/screenActivity.ts
7038
+ var hostStandby = false;
7039
+ function setHostStandby(standby) {
7040
+ hostStandby = !!standby;
7041
+ }
7042
+ function toBoolean(value) {
7043
+ if (typeof value === "boolean") return value;
7044
+ if (typeof value === "number") return value === 1;
7045
+ if (typeof value === "string") {
7046
+ var v = value.trim().toLowerCase();
7047
+ if (v === "true" || v === "1" || v === "yes") return true;
7048
+ if (v === "false" || v === "0" || v === "no") return false;
7049
+ }
7050
+ return void 0;
7051
+ }
7052
+ function bridgeSaysStandby() {
7053
+ if (typeof window === "undefined") return false;
7054
+ var w = window;
7055
+ for(var _i = 0, _iter = [
7056
+ w.__STORMCLOUD_CTV__,
7057
+ w.__STORMCLOUD_CTV_AD_INFO__,
7058
+ w.stormcloudCtv
7059
+ ]; _i < _iter.length; _i++){
7060
+ var source = _iter[_i];
7061
+ if (!source) continue;
7062
+ for(var _i1 = 0, _iter1 = [
7063
+ "standby",
7064
+ "isStandby",
7065
+ "screenOff"
7066
+ ]; _i1 < _iter1.length; _i1++){
7067
+ var key = _iter1[_i1];
7068
+ var value = void 0;
7069
+ try {
7070
+ value = source[key];
7071
+ if (typeof value === "function") value = value.call(source);
7072
+ } catch (unused) {
7073
+ value = void 0;
7074
+ }
7075
+ if (toBoolean(value) === true) return true;
7076
+ }
7077
+ }
7078
+ return false;
7079
+ }
7080
+ function getScreenInactiveReason() {
7081
+ if (hostStandby) return "host_standby";
7082
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") {
7083
+ return "document_hidden";
7084
+ }
7085
+ if (bridgeSaysStandby()) return "bridge_standby";
7086
+ return void 0;
7087
+ }
6005
7088
  // src/utils/trackingIngest.ts
6006
7089
  var DEFAULT_TRACKING_INGEST_CONFIG = {
6007
7090
  enabled: true,
@@ -6099,6 +7182,9 @@ function buildAnalyticsContext(config) {
6099
7182
  if (config.isLiveStream !== void 0) {
6100
7183
  context.inputStreamType = config.isLiveStream ? "live" : "vod";
6101
7184
  }
7185
+ if (config.sendDeviceInfoToAnalytics) {
7186
+ context.includeDeviceInfo = true;
7187
+ }
6102
7188
  return context;
6103
7189
  }
6104
7190
  function getClientInfo() {
@@ -6394,7 +7480,7 @@ function buildPlayerMetricEvent() {
6394
7480
  capture_at: captureAt
6395
7481
  }, context.inputStreamType ? {
6396
7482
  input_stream_type: context.inputStreamType
6397
- } : {})
7483
+ } : {}, context.includeDeviceInfo ? deviceInfoAnalyticsFields(getDeviceInfo()) : {})
6398
7484
  ];
6399
7485
  }
6400
7486
  });
@@ -7949,6 +9035,13 @@ var Scte35CueManager = /*#__PURE__*/ function() {
7949
9035
  return Scte35CueManager;
7950
9036
  }();
7951
9037
  // src/player/AdConfigManager.ts
9038
+ function isGamAdUrl(rawUrl) {
9039
+ try {
9040
+ return GAM_AD_HOSTS.has(new URL(rawUrl).hostname);
9041
+ } catch (unused) {
9042
+ return false;
9043
+ }
9044
+ }
7952
9045
  function withDeferredPodParams(rawUrl, deferNonce) {
7953
9046
  try {
7954
9047
  var url = new URL(rawUrl);
@@ -7966,11 +9059,15 @@ function withDeferredPodParams(rawUrl, deferNonce) {
7966
9059
  }
7967
9060
  var AdConfigManager = /*#__PURE__*/ function() {
7968
9061
  function AdConfigManager(config, video) {
9062
+ var _this = this;
7969
9063
  _class_call_check(this, AdConfigManager);
7970
9064
  this.vmapBreaks = [];
7971
9065
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
7972
9066
  this.streamCorrelator = generateCorrelator();
7973
9067
  this.consentSignals = {};
9068
+ this.isLiveStream = function() {
9069
+ return !!_this.config.isLiveStream;
9070
+ };
7974
9071
  this.podCounter = 0;
7975
9072
  this.podAssignedByPrefetch = false;
7976
9073
  this.lastHeartbeatTime = 0;
@@ -8421,9 +9518,22 @@ var AdConfigManager = /*#__PURE__*/ function() {
8421
9518
  {
8422
9519
  key: "generatePodVastUrl",
8423
9520
  value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
9521
+ var _content_contentDurationSeconds;
8424
9522
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
8425
- var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
8426
- var macroContext = _object_spread_props(_object_spread({
9523
+ var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
9524
+ fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
9525
+ sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
9526
+ });
9527
+ var content = resolveContentMetadata(this.config);
9528
+ var isLive = this.isLiveStream();
9529
+ var device = getDeviceInfo();
9530
+ var playerSize = resolvePlayerSize(this.video);
9531
+ var videoDuration = this.video.duration;
9532
+ var contentDurationSeconds = (_content_contentDurationSeconds = content.contentDurationSeconds) !== null && _content_contentDurationSeconds !== void 0 ? _content_contentDurationSeconds : !isLive && Number.isFinite(videoDuration) && videoDuration > 0 ? Math.round(videoDuration) : void 0;
9533
+ var userId = resolveUserId(this.config.adUserId);
9534
+ var ipAddress = resolveClientIp(this.config.clientIpAddress);
9535
+ var userAgent2 = typeof navigator !== "undefined" && navigator.userAgent ? navigator.userAgent : void 0;
9536
+ var macroContext = _object_spread(_object_spread_props(_object_spread(_object_spread_props(_object_spread({
8427
9537
  correlator: this.viewCorrelator,
8428
9538
  streamCorrelator: this.streamCorrelator,
8429
9539
  pod: this.podCounter > 0 ? this.podCounter : void 0,
@@ -8437,14 +9547,54 @@ var AdConfigManager = /*#__PURE__*/ function() {
8437
9547
  limitAdTracking: envSignals.limitAdTracking,
8438
9548
  deviceTypeHint: envSignals.deviceTypeHint,
8439
9549
  adTest: this.config.adTest
8440
- }, this.config.programTitle ? {
8441
- programTitle: this.config.programTitle
8442
- } : {}, this.config.channelName ? {
8443
- channelName: this.config.channelName
9550
+ }, content.programTitle ? {
9551
+ programTitle: content.programTitle
9552
+ } : {}, content.channelName ? {
9553
+ channelName: content.channelName
9554
+ } : {}, content.contentNetwork ? {
9555
+ contentNetwork: content.contentNetwork
8444
9556
  } : {}), {
8445
9557
  consent: this.consentSignals,
8446
- palNonce: palNonce.getCurrentNonce() || void 0
8447
- });
9558
+ palNonce: palNonce.getCurrentNonce() || void 0,
9559
+ deviceIdSource: envSignals.deviceIdSource,
9560
+ isLive: isLive
9561
+ }), playerSize.width ? {
9562
+ playerWidth: playerSize.width
9563
+ } : {}, playerSize.height ? {
9564
+ playerHeight: playerSize.height
9565
+ } : {}), {
9566
+ timestamp: String(Date.now())
9567
+ }), device.make ? {
9568
+ deviceMake: device.make
9569
+ } : {}, device.model ? {
9570
+ deviceModel: device.model
9571
+ } : {}, device.hardwareVersion ? {
9572
+ deviceHardwareVersion: device.hardwareVersion
9573
+ } : {}, userAgent2 ? {
9574
+ userAgent: userAgent2
9575
+ } : {}, ipAddress ? {
9576
+ ipAddress: ipAddress
9577
+ } : {}, userId ? {
9578
+ userId: userId
9579
+ } : {}, content.contentType ? {
9580
+ contentType: content.contentType
9581
+ } : {}, content.contentCategory ? {
9582
+ contentCategory: content.contentCategory
9583
+ } : {}, content.contentGenre ? {
9584
+ contentGenre: content.contentGenre
9585
+ } : {}, content.contentLanguage ? {
9586
+ contentLanguage: content.contentLanguage
9587
+ } : {}, contentDurationSeconds != null ? {
9588
+ contentDurationSeconds: contentDurationSeconds
9589
+ } : {}, content.contentSeason ? {
9590
+ contentSeason: content.contentSeason
9591
+ } : {}, content.contentEpisode ? {
9592
+ contentEpisode: content.contentEpisode
9593
+ } : {}, content.contentRating ? {
9594
+ contentRating: content.contentRating
9595
+ } : {}, content.contentId ? {
9596
+ contentId: content.contentId
9597
+ } : {});
8448
9598
  var nonceReady = !!macroContext.palNonce;
8449
9599
  var finalUrl;
8450
9600
  if (hasScvpMacros(baseUrl)) {
@@ -8458,6 +9608,31 @@ var AdConfigManager = /*#__PURE__*/ function() {
8458
9608
  } else {
8459
9609
  finalUrl = withDeferredPodParams(palNonce.injectNonce(ensureVideoAdType(applyVastMacros(baseUrl, macroContext))), !nonceReady);
8460
9610
  }
9611
+ if (isGamAdUrl(finalUrl)) {
9612
+ finalUrl = appendMissingContentParams(finalUrl, content);
9613
+ if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9614
+ finalUrl = applyDeviceKeyValues(finalUrl, device);
9615
+ }
9616
+ }
9617
+ if (this.debug) {
9618
+ var id = envSignals.deviceId;
9619
+ console.log("[AD-IDENTITY]", {
9620
+ source: envSignals.deviceIdSource,
9621
+ idtype: envSignals.deviceIdType,
9622
+ rdidTail: id ? id.slice(-4) : void 0,
9623
+ isLat: envSignals.limitAdTracking,
9624
+ dth: envSignals.deviceTypeHint,
9625
+ sidTail: envSignals.sessionId ? envSignals.sessionId.slice(-4) : void 0,
9626
+ ct_ch: content.channelName,
9627
+ ct_ti: content.programTitle,
9628
+ ct_ne: content.contentNetwork,
9629
+ ifaType: toIabIfaType(envSignals.deviceIdType, envSignals.deviceIdSource),
9630
+ live: isLive,
9631
+ player: playerSize,
9632
+ make: device.make,
9633
+ model: device.model
9634
+ });
9635
+ }
8461
9636
  console.log("[StormcloudVideoPlayer] Prepared optimized-pod request URL (pod=".concat(this.podCounter, "; pmnd/pmxd/pmad resolved at dispatch):"), finalUrl);
8462
9637
  return finalUrl;
8463
9638
  }
@@ -8509,7 +9684,6 @@ var AdConfigManager = /*#__PURE__*/ function() {
8509
9684
  }
8510
9685
  },
8511
9686
  {
8512
- // --- Tracking ---
8513
9687
  key: "initializeTracking",
8514
9688
  value: function initializeTracking() {
8515
9689
  var _this = this;
@@ -8601,7 +9775,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8601
9775
  }
8602
9776
  },
8603
9777
  {
8604
- // --- Ad stop timer ---
8605
9778
  key: "scheduleAdStopCountdown",
8606
9779
  value: function scheduleAdStopCountdown(remainingMs) {
8607
9780
  var _this = this;
@@ -8633,7 +9806,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8633
9806
  }
8634
9807
  },
8635
9808
  {
8636
- // --- Ad start timer ---
8637
9809
  key: "scheduleAdStartIn",
8638
9810
  value: function scheduleAdStartIn(delayMs) {
8639
9811
  var _this = this;
@@ -8661,7 +9833,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8661
9833
  }
8662
9834
  },
8663
9835
  {
8664
- // --- PTS drift ---
8665
9836
  key: "updatePtsDrift",
8666
9837
  value: function updatePtsDrift(ptsSecondsSample) {
8667
9838
  var sampleMs = (this.video.currentTime - ptsSecondsSample) * 1e3;
@@ -8687,7 +9858,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8687
9858
  }
8688
9859
  },
8689
9860
  {
8690
- // --- Duration boundary ---
8691
9861
  key: "beginBreakTiming",
8692
9862
  value: function beginBreakTiming(startWallClockMs) {
8693
9863
  this.currentAdBreakStartWallClockMs = startWallClockMs;
@@ -8735,7 +9905,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8735
9905
  }
8736
9906
  },
8737
9907
  {
8738
- // --- Duration budget ---
8739
9908
  key: "getWallClockRemainingAdMs",
8740
9909
  value: function getWallClockRemainingAdMs() {
8741
9910
  var endWallClockMs = this.getAdBreakEndWallClockMs();
@@ -8884,7 +10053,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8884
10053
  }
8885
10054
  },
8886
10055
  {
8887
- // --- Circuit breaker ---
8888
10056
  key: "isTemporaryAdError",
8889
10057
  value: function isTemporaryAdError(error) {
8890
10058
  var _error_message;
@@ -9018,7 +10186,6 @@ var AdTimingService = /*#__PURE__*/ function() {
9018
10186
  }
9019
10187
  },
9020
10188
  {
9021
- // --- Watchdog ---
9022
10189
  key: "startAdRequestWatchdog",
9023
10190
  value: function startAdRequestWatchdog(token) {
9024
10191
  var _this = this;
@@ -9063,7 +10230,6 @@ var AdTimingService = /*#__PURE__*/ function() {
9063
10230
  }
9064
10231
  },
9065
10232
  {
9066
- // --- Failsafe ---
9067
10233
  key: "startAdFailsafeTimer",
9068
10234
  value: function startAdFailsafeTimer(token) {
9069
10235
  var _this = this;
@@ -9125,7 +10291,6 @@ var AdTimingService = /*#__PURE__*/ function() {
9125
10291
  }
9126
10292
  },
9127
10293
  {
9128
- // --- Reset for ad break end ---
9129
10294
  key: "resetForBreakEnd",
9130
10295
  value: function resetForBreakEnd() {
9131
10296
  this.clearAdStopTimer();
@@ -9324,7 +10489,7 @@ var HlsEngine = /*#__PURE__*/ function() {
9324
10489
  adBehavior: adBehavior
9325
10490
  });
9326
10491
  }
9327
- if (!this.config.autoplay) return [
10492
+ if (!(this.config.autoplay && !this.callbacks.shouldHoldContentForAds())) return [
9328
10493
  3,
9329
10494
  2
9330
10495
  ];
@@ -9515,6 +10680,12 @@ var HlsEngine = /*#__PURE__*/ function() {
9515
10680
  2
9516
10681
  ];
9517
10682
  this.hasInitialBufferCompleted = true;
10683
+ if (this.shouldAutoplayAfterBuffering && this.callbacks.shouldHoldContentForAds()) {
10684
+ this.shouldAutoplayAfterBuffering = false;
10685
+ if (this.debug) {
10686
+ console.log("[StormcloudVideoPlayer] Buffer ready during an ad break; content stays paused until the break ends");
10687
+ }
10688
+ }
9518
10689
  if (!this.shouldAutoplayAfterBuffering) return [
9519
10690
  3,
9520
10691
  2
@@ -10172,9 +11343,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10172
11343
  }
10173
11344
  },
10174
11345
  {
10175
- // ───────────────────────────────────────────────────────────────
10176
- // IMA event listeners
10177
- // ───────────────────────────────────────────────────────────────
10178
11346
  key: "nextAdRequestUrl",
10179
11347
  value: function nextAdRequestUrl(baseVastUrl) {
10180
11348
  return this.host.generatePodVastUrl(baseVastUrl);
@@ -10410,9 +11578,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10410
11578
  }
10411
11579
  },
10412
11580
  {
10413
- // ───────────────────────────────────────────────────────────────
10414
- // Ad break start
10415
- // ───────────────────────────────────────────────────────────────
10416
11581
  key: "isBreakActive",
10417
11582
  value: function isBreakActive() {
10418
11583
  return this.slotState !== "IDLE";
@@ -10440,7 +11605,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10440
11605
  key: "handleAdStart",
10441
11606
  value: function handleAdStart(marker) {
10442
11607
  return _async_to_generator(function() {
10443
- var baseVastUrl, edgeConfigured, adBreakDurationMs, currentMuted, currentVolume, epoch, mode, edgeUrl, outcome, podPlayed;
11608
+ var screenInactiveReason, baseVastUrl, edgeConfigured, adBreakDurationMs, currentMuted, currentVolume, epoch, mode, edgeUrl, outcome, podPlayed;
10444
11609
  return _ts_generator(this, function(_state) {
10445
11610
  switch(_state.label){
10446
11611
  case 0:
@@ -10453,6 +11618,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10453
11618
  2
10454
11619
  ];
10455
11620
  }
11621
+ screenInactiveReason = getScreenInactiveReason();
11622
+ if (screenInactiveReason) {
11623
+ this.logOrchestratorFunnel("break_skipped_screen_inactive", {
11624
+ reason: screenInactiveReason
11625
+ });
11626
+ this.clearPendingAdBreak();
11627
+ return [
11628
+ 2
11629
+ ];
11630
+ }
10456
11631
  baseVastUrl = this.adConfig.apiVastTagUrl;
10457
11632
  edgeConfigured = !!this.host.getEdgePodBaseUrl();
10458
11633
  if (!baseVastUrl && !edgeConfigured) {
@@ -10613,12 +11788,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10613
11788
  },
10614
11789
  {
10615
11790
  key: "startOptimizedPod",
10616
- value: // ───────────────────────────────────────────────────────────────
10617
- // Optimized pod (single multi-ad request)
10618
- // ───────────────────────────────────────────────────────────────
10619
- function startOptimizedPod(baseVastUrl) {
11791
+ value: function startOptimizedPod(baseVastUrl) {
10620
11792
  return _async_to_generator(function() {
10621
- var podUrl, prefetched, epoch, generation, adPlayer, requestToken, requestUrl, _ref, _this_currentVastUrl, _adPlayer_getPodAdCount, finalizeRequestUrl, podCount, error;
11793
+ var podUrl, prefetched, epoch, generation, adPlayer, requestToken, requestUrl, _ref, _this_currentVastUrl, _adPlayer_getPodAdCount, finalizeRequestUrl, podCount, _this_host_config_maxAdBreakExtensionMs, remainingMs, overrunAllowanceMs, maxAdsCap, maxAds, error;
10622
11794
  return _ts_generator(this, function(_state) {
10623
11795
  switch(_state.label){
10624
11796
  case 0:
@@ -10726,6 +11898,26 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10726
11898
  false
10727
11899
  ];
10728
11900
  }
11901
+ if (this.isBreakTimeBounded() && adPlayer.limitPodToBudget) {
11902
+ ;
11903
+ remainingMs = this.timing.getRemainingAdMs();
11904
+ overrunAllowanceMs = Math.max(0, (_this_host_config_maxAdBreakExtensionMs = this.host.config.maxAdBreakExtensionMs) !== null && _this_host_config_maxAdBreakExtensionMs !== void 0 ? _this_host_config_maxAdBreakExtensionMs : 0);
11905
+ maxAdsCap = this.adConfig.resolveAdPodConfig().maxAdsPerBreak;
11906
+ maxAds = maxAdsCap != null ? Math.max(1, maxAdsCap - this.timing.totalAdsInBreak) : Number.MAX_SAFE_INTEGER;
11907
+ if (Number.isFinite(remainingMs)) {
11908
+ podCount = adPlayer.limitPodToBudget(remainingMs + overrunAllowanceMs, maxAds);
11909
+ if (podCount < 1) {
11910
+ if (this.timing.activeAdRequestToken === requestToken) {
11911
+ this.timing.activeAdRequestToken = null;
11912
+ }
11913
+ this.recordRequestFailure(new Error("No GAM ad fits the ".concat(Math.round(remainingMs), "ms left in the break")), podUrl);
11914
+ return [
11915
+ 2,
11916
+ false
11917
+ ];
11918
+ }
11919
+ }
11920
+ }
10729
11921
  this.setSlotState("READY", "vast_ready");
10730
11922
  if (this.debug) {
10731
11923
  console.log(podCount === 1 ? "[POD] Response contained a single ad; playing it and enabling pod top-up" : "[POD] Optimized pod returned ".concat(podCount, " ads; playing pod in one controller"));
@@ -10795,9 +11987,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10795
11987
  }
10796
11988
  },
10797
11989
  {
10798
- // ───────────────────────────────────────────────────────────────
10799
- // Edge-first pods (live SCTE-35 only, GAM fallback)
10800
- // ───────────────────────────────────────────────────────────────
10801
11990
  key: "resetEdgeStateForBreak",
10802
11991
  value: function resetEdgeStateForBreak() {
10803
11992
  this.edgeExhaustedForBreak = false;
@@ -11015,9 +12204,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11015
12204
  }
11016
12205
  },
11017
12206
  {
11018
- // ───────────────────────────────────────────────────────────────
11019
- // Next-ad scheduling (single flight)
11020
- // ───────────────────────────────────────────────────────────────
11021
12207
  key: "setSlotState",
11022
12208
  value: function setSlotState(next, reason) {
11023
12209
  if (this.slotState === next) return;
@@ -11067,6 +12253,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11067
12253
  {
11068
12254
  key: "getStopRequestingReason",
11069
12255
  value: function getStopRequestingReason(remainingMs) {
12256
+ var screenInactiveReason = getScreenInactiveReason();
12257
+ if (screenInactiveReason) return "screen_inactive:".concat(screenInactiveReason);
11070
12258
  if (this.breakSource === "vmap") {
11071
12259
  if (this.adPodQueue.length === 0) return "vmap_queue_empty";
11072
12260
  } else if (this.breakSource !== "scte35" || !this.followUpBaseVastUrl && !this.canRequestEdge()) {
@@ -11340,9 +12528,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11340
12528
  }
11341
12529
  },
11342
12530
  {
11343
- // ───────────────────────────────────────────────────────────────
11344
- // Per-request diagnostics
11345
- // ───────────────────────────────────────────────────────────────
11346
12531
  key: "recordRequestDiagnostic",
11347
12532
  value: function recordRequestDiagnostic(payload) {
11348
12533
  var requestId = payload.requestId;
@@ -11416,9 +12601,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11416
12601
  }
11417
12602
  },
11418
12603
  {
11419
- // ───────────────────────────────────────────────────────────────
11420
- // Single ad playback
11421
- // ───────────────────────────────────────────────────────────────
11422
12604
  key: "createGamDispatchFinalizer",
11423
12605
  value: function createGamDispatchFinalizer(requestToken) {
11424
12606
  var _this = this;
@@ -11881,9 +13063,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11881
13063
  }
11882
13064
  },
11883
13065
  {
11884
- // ───────────────────────────────────────────────────────────────
11885
- // Ad break completion
11886
- // ───────────────────────────────────────────────────────────────
11887
13066
  key: "logBreakFunnel",
11888
13067
  value: function logBreakFunnel(endReason) {
11889
13068
  var funnel = this.breakFunnel;
@@ -12529,6 +13708,8 @@ var ContentHealthWatchdog = /*#__PURE__*/ function() {
12529
13708
  return ContentHealthWatchdog;
12530
13709
  }();
12531
13710
  // src/player/StormcloudVideoPlayer.ts
13711
+ var DEFAULT_PAL_NONCE_MAX_AGE_MS = 5.5 * 60 * 60 * 1e3;
13712
+ var PAL_NONCE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
12532
13713
  var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12533
13714
  function StormcloudVideoPlayer(config) {
12534
13715
  var _this = this;
@@ -12539,6 +13720,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12539
13720
  var browserOverrides = getBrowserConfigOverrides();
12540
13721
  this.config = _object_spread({}, browserOverrides, config);
12541
13722
  this.video = config.videoElement;
13723
+ if (this.config.forceSingleDecoderMode != null) {
13724
+ setSingleDecoderOverride(this.config.forceSingleDecoderMode);
13725
+ }
13726
+ if (this.config.adDeviceId) {
13727
+ setHostAdIdentity({
13728
+ deviceId: this.config.adDeviceId,
13729
+ deviceIdType: this.config.adDeviceIdType,
13730
+ limitAdTracking: this.config.adLimitAdTracking
13731
+ });
13732
+ }
13733
+ if (this.config.deviceInfo) {
13734
+ setHostDeviceInfo(this.config.deviceInfo);
13735
+ }
12542
13736
  logBrowserInfo(config.debugAdTiming);
12543
13737
  this.floorLadder = new FloorLadderController();
12544
13738
  this.adPlayer = this.createAdPlayer(false);
@@ -12602,8 +13796,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12602
13796
  },
12603
13797
  hasPendingAdBreak: function hasPendingAdBreak() {
12604
13798
  return _this.adBreak.pendingAdBreak !== null;
13799
+ },
13800
+ shouldHoldContentForAds: function shouldHoldContentForAds() {
13801
+ return !!_this.adBreak && _this.adBreak.inAdBreak && !_this.shouldContinueLiveStreamDuringAds();
12605
13802
  }
12606
13803
  });
13804
+ this.adConfig.isLiveStream = function() {
13805
+ return _this.hlsEngine.isLiveStream;
13806
+ };
12607
13807
  this.adBreak = new AdBreakOrchestrator({
12608
13808
  config: this.config,
12609
13809
  video: this.video,
@@ -12797,10 +13997,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12797
13997
  },
12798
13998
  {
12799
13999
  key: "load",
12800
- value: // ───────────────────────────────────────────────────────────────
12801
- // Lifecycle
12802
- // ───────────────────────────────────────────────────────────────
12803
- function load() {
14000
+ value: function load() {
12804
14001
  return _async_to_generator(function() {
12805
14002
  var _this, error, palDescriptionUrl, continueLiveStreamDuringAds;
12806
14003
  return _ts_generator(this, function(_state) {
@@ -12810,6 +14007,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12810
14007
  if (!this.attached) {
12811
14008
  this.attach();
12812
14009
  }
14010
+ primeDeviceInfo().then(function(info) {
14011
+ if (_this.debug) {
14012
+ console.log("[DEVICE-INFO]", _object_spread_props(_object_spread({}, info), {
14013
+ internalDeviceId: info.internalDeviceId ? "...".concat(info.internalDeviceId.slice(-4)) : void 0
14014
+ }));
14015
+ }
14016
+ }).catch(function() {});
12813
14017
  _state.label = 1;
12814
14018
  case 1:
12815
14019
  _state.trys.push([
@@ -12844,21 +14048,30 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12844
14048
  fetchConsentSignals().catch(function() {
12845
14049
  return {};
12846
14050
  }).then(function(signals) {
12847
- var _this_config_lowLatencyMode;
14051
+ var _this_config_palContinuousPlayback, _this_config_lowLatencyMode, _this_config_palIconsSupported, _this_config_palSupportedApiFrameworks;
12848
14052
  _this.adConfig.consentSignals = signals;
12849
14053
  var muted = _this.video.muted;
12850
- return _this.palNonce.generateNonce(_object_spread({
14054
+ var palSessionId = _this.config.ctvAdRequest ? getOrRotateSessionId(_this.config.sessionIdMaxAgeMs) : void 0;
14055
+ var palOptions = _object_spread({
12851
14056
  videoWidth: _this.video.offsetWidth || _this.video.clientWidth || 640,
12852
14057
  videoHeight: _this.video.offsetHeight || _this.video.clientHeight || 480,
12853
14058
  adWillAutoPlay: !!_this.config.autoplay,
12854
14059
  adWillPlayMuted: muted,
12855
14060
  playerVolume: muted ? 0 : _this.video.volume,
12856
- continuousPlayback: (_this_config_lowLatencyMode = _this.config.lowLatencyMode) !== null && _this_config_lowLatencyMode !== void 0 ? _this_config_lowLatencyMode : false
14061
+ continuousPlayback: (_this_config_palContinuousPlayback = _this.config.palContinuousPlayback) !== null && _this_config_palContinuousPlayback !== void 0 ? _this_config_palContinuousPlayback : _this.config.ctvAdRequest ? true : (_this_config_lowLatencyMode = _this.config.lowLatencyMode) !== null && _this_config_lowLatencyMode !== void 0 ? _this_config_lowLatencyMode : false,
14062
+ iconsSupported: (_this_config_palIconsSupported = _this.config.palIconsSupported) !== null && _this_config_palIconsSupported !== void 0 ? _this_config_palIconsSupported : false,
14063
+ supportedApiFrameworks: (_this_config_palSupportedApiFrameworks = _this.config.palSupportedApiFrameworks) !== null && _this_config_palSupportedApiFrameworks !== void 0 ? _this_config_palSupportedApiFrameworks : ""
12857
14064
  }, palDescriptionUrl ? {
12858
14065
  descriptionUrl: palDescriptionUrl
12859
14066
  } : {}, signals.storageAllowed != null ? {
12860
14067
  allowStorage: signals.storageAllowed
12861
- } : {}));
14068
+ } : {}, palSessionId ? {
14069
+ sessionId: palSessionId
14070
+ } : {});
14071
+ _this.lastPalOptions = palOptions;
14072
+ _this.palSessionId = palSessionId;
14073
+ _this.startPalNonceRefresh();
14074
+ return _this.palNonce.generateNonce(palOptions);
12862
14075
  }).catch(function() {});
12863
14076
  this.adConfig.initializeTracking();
12864
14077
  if (!this.hlsEngine.shouldUseNativeHls(function() {
@@ -12896,6 +14109,96 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12896
14109
  }).call(this);
12897
14110
  }
12898
14111
  },
14112
+ {
14113
+ key: "startPalNonceRefresh",
14114
+ value: function startPalNonceRefresh() {
14115
+ var _this = this;
14116
+ if (this.palRefreshTimer != null || typeof window === "undefined") return;
14117
+ this.palRefreshTimer = window.setInterval(function() {
14118
+ return _this.refreshPalNonceIfStale();
14119
+ }, PAL_NONCE_CHECK_INTERVAL_MS);
14120
+ }
14121
+ },
14122
+ {
14123
+ key: "refreshPalNonceIfStale",
14124
+ value: function refreshPalNonceIfStale() {
14125
+ var force = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
14126
+ var _this_config_palNonceMaxAgeMs;
14127
+ var options = this.lastPalOptions;
14128
+ if (!options) return;
14129
+ var maxAgeMs = (_this_config_palNonceMaxAgeMs = this.config.palNonceMaxAgeMs) !== null && _this_config_palNonceMaxAgeMs !== void 0 ? _this_config_palNonceMaxAgeMs : DEFAULT_PAL_NONCE_MAX_AGE_MS;
14130
+ var ageMs = this.palNonce.getNonceAgeMs();
14131
+ var sessionId = this.config.ctvAdRequest ? getOrRotateSessionId(this.config.sessionIdMaxAgeMs) : void 0;
14132
+ var sessionChanged = sessionId !== this.palSessionId;
14133
+ var stale = ageMs === void 0 || ageMs >= maxAgeMs;
14134
+ if (!force && !stale && !sessionChanged) return;
14135
+ var next = _object_spread({}, options);
14136
+ if (sessionId) next.sessionId = sessionId;
14137
+ else delete next.sessionId;
14138
+ this.lastPalOptions = next;
14139
+ this.palSessionId = sessionId;
14140
+ if (this.debug) {
14141
+ console.log("[PAL] Regenerating nonce", {
14142
+ force: force,
14143
+ stale: stale,
14144
+ sessionChanged: sessionChanged,
14145
+ ageMs: ageMs
14146
+ });
14147
+ }
14148
+ this.palNonce.generateNonce(next).catch(function() {});
14149
+ }
14150
+ },
14151
+ {
14152
+ key: "setAdIdentity",
14153
+ value: function setAdIdentity(identity) {
14154
+ setHostAdIdentity(identity);
14155
+ this.refreshPalNonceIfStale();
14156
+ }
14157
+ },
14158
+ {
14159
+ key: "resetAdIdentity",
14160
+ value: function resetAdIdentity1() {
14161
+ resetAdIdentity();
14162
+ this.refreshPalNonceIfStale(true);
14163
+ }
14164
+ },
14165
+ {
14166
+ key: "setContentMetadata",
14167
+ value: function setContentMetadata(meta) {
14168
+ applyContentMetadataUpdate(this.config, meta);
14169
+ }
14170
+ },
14171
+ {
14172
+ key: "setRequestSignals",
14173
+ value: function setRequestSignals(signals) {
14174
+ if (signals.userId !== void 0) {
14175
+ if (signals.userId) this.config.adUserId = signals.userId;
14176
+ else delete this.config.adUserId;
14177
+ }
14178
+ if (signals.ipAddress !== void 0) {
14179
+ if (signals.ipAddress) this.config.clientIpAddress = signals.ipAddress;
14180
+ else delete this.config.clientIpAddress;
14181
+ }
14182
+ }
14183
+ },
14184
+ {
14185
+ key: "setScreenStandby",
14186
+ value: function setScreenStandby(standby) {
14187
+ setHostStandby(standby);
14188
+ }
14189
+ },
14190
+ {
14191
+ key: "getDeviceInfo",
14192
+ value: function getDeviceInfo1() {
14193
+ return getDeviceInfo();
14194
+ }
14195
+ },
14196
+ {
14197
+ key: "setDeviceInfo",
14198
+ value: function setDeviceInfo(info) {
14199
+ setHostDeviceInfo(info);
14200
+ }
14201
+ },
12899
14202
  {
12900
14203
  key: "onManifestParsed",
12901
14204
  value: function onManifestParsed(isLive) {
@@ -13030,9 +14333,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13030
14333
  }
13031
14334
  },
13032
14335
  {
13033
- // ───────────────────────────────────────────────────────────────
13034
- // SCTE-35 marker orchestration
13035
- // ───────────────────────────────────────────────────────────────
13036
14336
  key: "onScte35Marker",
13037
14337
  value: function onScte35Marker(marker, cueKey) {
13038
14338
  if (this.debug) {
@@ -13211,9 +14511,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13211
14511
  }
13212
14512
  },
13213
14513
  {
13214
- // ───────────────────────────────────────────────────────────────
13215
- // Ad prefetch
13216
- // ───────────────────────────────────────────────────────────────
13217
14514
  key: "startAdPrefetch",
13218
14515
  value: function startAdPrefetch(marker, fragmentSn, cueKey) {
13219
14516
  if (this.adBreak.pendingAdBreak || this.adBreak.inAdBreak) return;
@@ -13252,9 +14549,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13252
14549
  }
13253
14550
  },
13254
14551
  {
13255
- // ───────────────────────────────────────────────────────────────
13256
- // VMAP time-based ad breaks
13257
- // ───────────────────────────────────────────────────────────────
13258
14552
  key: "onTimeUpdate",
13259
14553
  value: function onTimeUpdate(currentTimeSec) {
13260
14554
  var _this = this;
@@ -13368,9 +14662,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13368
14662
  }
13369
14663
  },
13370
14664
  {
13371
- // ───────────────────────────────────────────────────────────────
13372
- // Public API
13373
- // ───────────────────────────────────────────────────────────────
13374
14665
  key: "getCurrentAdIndex",
13375
14666
  value: function getCurrentAdIndex() {
13376
14667
  return this.timing.currentAdIndex;
@@ -13489,12 +14780,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13489
14780
  }
13490
14781
  },
13491
14782
  {
13492
- // ───────────────────────────────────────────────────────────────
13493
- // Destroy
13494
- // ───────────────────────────────────────────────────────────────
13495
14783
  key: "destroy",
13496
14784
  value: function destroy() {
13497
14785
  var _this_adPlayer;
14786
+ if (this.palRefreshTimer != null) {
14787
+ clearInterval(this.palRefreshTimer);
14788
+ this.palRefreshTimer = void 0;
14789
+ }
13498
14790
  this.contentWatchdog.stop();
13499
14791
  this.adBreak.cancelScheduledRequest();
13500
14792
  this.timing.destroy();
@@ -13602,7 +14894,7 @@ var CRITICAL_PROPS = [
13602
14894
  var CONTROLS_HIDE_DELAY = 3e3;
13603
14895
  var DEFAULT_PLAYER_ASPECT_RATIO = 16 / 9;
13604
14896
  var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
13605
- 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, restVideoAttrs = _object_without_properties(props, [
14897
+ 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, [
13606
14898
  "src",
13607
14899
  "autoplay",
13608
14900
  "muted",
@@ -13636,10 +14928,26 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
13636
14928
  "programTitle",
13637
14929
  "channelName",
13638
14930
  "contentNetwork",
14931
+ "contentDetails",
14932
+ "adUserId",
14933
+ "clientIpAddress",
13639
14934
  "minRemainingMsToStartAd",
13640
14935
  "minRemainingMsToRequestAd",
13641
14936
  "maxNoFillsPerBreak",
13642
- "maxAdBreakExtensionMs"
14937
+ "maxAdBreakExtensionMs",
14938
+ "adDeviceId",
14939
+ "adDeviceIdType",
14940
+ "adLimitAdTracking",
14941
+ "fallbackDeviceIdMaxAgeMs",
14942
+ "sessionIdMaxAgeMs",
14943
+ "palIconsSupported",
14944
+ "palSupportedApiFrameworks",
14945
+ "palContinuousPlayback",
14946
+ "palNonceMaxAgeMs",
14947
+ "forceSingleDecoderMode",
14948
+ "deviceInfo",
14949
+ "sendDeviceKeyValues",
14950
+ "sendDeviceInfoToAnalytics"
13643
14951
  ]);
13644
14952
  var videoRef = (0, import_react.useRef)(null);
13645
14953
  var playerRef = (0, import_react.useRef)(null);
@@ -13831,10 +15139,26 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
13831
15139
  if (programTitle !== void 0) cfg.programTitle = programTitle;
13832
15140
  if (channelName !== void 0) cfg.channelName = channelName;
13833
15141
  if (contentNetwork !== void 0) cfg.contentNetwork = contentNetwork;
15142
+ if (contentDetails !== void 0) cfg.contentDetails = contentDetails;
15143
+ if (adUserId !== void 0) cfg.adUserId = adUserId;
15144
+ if (clientIpAddress !== void 0) cfg.clientIpAddress = clientIpAddress;
13834
15145
  if (minRemainingMsToStartAd !== void 0) cfg.minRemainingMsToStartAd = minRemainingMsToStartAd;
13835
15146
  if (minRemainingMsToRequestAd !== void 0) cfg.minRemainingMsToRequestAd = minRemainingMsToRequestAd;
13836
15147
  if (maxNoFillsPerBreak !== void 0) cfg.maxNoFillsPerBreak = maxNoFillsPerBreak;
13837
15148
  if (maxAdBreakExtensionMs !== void 0) cfg.maxAdBreakExtensionMs = maxAdBreakExtensionMs;
15149
+ if (adDeviceId !== void 0) cfg.adDeviceId = adDeviceId;
15150
+ if (adDeviceIdType !== void 0) cfg.adDeviceIdType = adDeviceIdType;
15151
+ if (adLimitAdTracking !== void 0) cfg.adLimitAdTracking = adLimitAdTracking;
15152
+ if (fallbackDeviceIdMaxAgeMs !== void 0) cfg.fallbackDeviceIdMaxAgeMs = fallbackDeviceIdMaxAgeMs;
15153
+ if (sessionIdMaxAgeMs !== void 0) cfg.sessionIdMaxAgeMs = sessionIdMaxAgeMs;
15154
+ if (palIconsSupported !== void 0) cfg.palIconsSupported = palIconsSupported;
15155
+ if (palSupportedApiFrameworks !== void 0) cfg.palSupportedApiFrameworks = palSupportedApiFrameworks;
15156
+ if (palContinuousPlayback !== void 0) cfg.palContinuousPlayback = palContinuousPlayback;
15157
+ if (palNonceMaxAgeMs !== void 0) cfg.palNonceMaxAgeMs = palNonceMaxAgeMs;
15158
+ if (forceSingleDecoderMode !== void 0) cfg.forceSingleDecoderMode = forceSingleDecoderMode;
15159
+ if (deviceInfo !== void 0) cfg.deviceInfo = deviceInfo;
15160
+ if (sendDeviceKeyValues !== void 0) cfg.sendDeviceKeyValues = sendDeviceKeyValues;
15161
+ if (sendDeviceInfoToAnalytics !== void 0) cfg.sendDeviceInfoToAnalytics = sendDeviceInfoToAnalytics;
13838
15162
  var player = new StormcloudVideoPlayer(cfg);
13839
15163
  playerRef.current = player;
13840
15164
  player.load().then(function() {
@@ -13874,6 +15198,60 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
13874
15198
  autoplay,
13875
15199
  muted
13876
15200
  ]);
15201
+ (0, import_react.useEffect)(function() {
15202
+ var _playerRef_current;
15203
+ (_playerRef_current = playerRef.current) === null || _playerRef_current === void 0 ? void 0 : _playerRef_current.setContentMetadata({
15204
+ channelName: channelName !== null && channelName !== void 0 ? channelName : null,
15205
+ programTitle: programTitle !== null && programTitle !== void 0 ? programTitle : null,
15206
+ contentNetwork: contentNetwork !== null && contentNetwork !== void 0 ? contentNetwork : null
15207
+ });
15208
+ }, [
15209
+ channelName,
15210
+ programTitle,
15211
+ contentNetwork
15212
+ ]);
15213
+ var contentDetailsKey = contentDetails ? JSON.stringify(contentDetails) : "";
15214
+ (0, import_react.useEffect)(function() {
15215
+ var _playerRef_current;
15216
+ (_playerRef_current = playerRef.current) === null || _playerRef_current === void 0 ? void 0 : _playerRef_current.setContentMetadata({
15217
+ details: contentDetailsKey ? JSON.parse(contentDetailsKey) : null
15218
+ });
15219
+ }, [
15220
+ contentDetailsKey
15221
+ ]);
15222
+ (0, import_react.useEffect)(function() {
15223
+ var _playerRef_current;
15224
+ (_playerRef_current = playerRef.current) === null || _playerRef_current === void 0 ? void 0 : _playerRef_current.setRequestSignals({
15225
+ userId: adUserId !== null && adUserId !== void 0 ? adUserId : null,
15226
+ ipAddress: clientIpAddress !== null && clientIpAddress !== void 0 ? clientIpAddress : null
15227
+ });
15228
+ }, [
15229
+ adUserId,
15230
+ clientIpAddress
15231
+ ]);
15232
+ var lastAdDeviceIdRef = (0, import_react.useRef)(void 0);
15233
+ (0, import_react.useEffect)(function() {
15234
+ var player = playerRef.current;
15235
+ if (!player) return;
15236
+ if (adDeviceId === void 0 && lastAdDeviceIdRef.current === void 0) return;
15237
+ lastAdDeviceIdRef.current = adDeviceId;
15238
+ player.setAdIdentity(adDeviceId ? {
15239
+ deviceId: adDeviceId,
15240
+ deviceIdType: adDeviceIdType,
15241
+ limitAdTracking: adLimitAdTracking
15242
+ } : null);
15243
+ }, [
15244
+ adDeviceId,
15245
+ adDeviceIdType,
15246
+ adLimitAdTracking
15247
+ ]);
15248
+ var deviceInfoKey = deviceInfo ? JSON.stringify(deviceInfo) : "";
15249
+ (0, import_react.useEffect)(function() {
15250
+ if (!playerRef.current || !deviceInfoKey) return;
15251
+ playerRef.current.setDeviceInfo(JSON.parse(deviceInfoKey));
15252
+ }, [
15253
+ deviceInfoKey
15254
+ ]);
13877
15255
  (0, import_react.useEffect)(function() {
13878
15256
  if (!playerRef.current) return;
13879
15257
  var checkAdStatus = function checkAdStatus() {