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
package/lib/index.cjs CHANGED
@@ -566,8 +566,264 @@ __export(index_exports, {
566
566
  module.exports = __toCommonJS(index_exports);
567
567
  // src/ui/StormcloudVideoPlayer.tsx
568
568
  var import_react = __toESM(require("react"), 1);
569
+ // src/utils/adIdentity.ts
570
+ var GOOGLE_ID_TYPES = [
571
+ "aaid",
572
+ "adid",
573
+ "afai",
574
+ "idfa",
575
+ "lgudid",
576
+ "msai",
577
+ "rida",
578
+ "tifa",
579
+ "tvOS",
580
+ "vaid",
581
+ "vida",
582
+ "dpid"
583
+ ];
584
+ var MAX_SESSION_ID_AGE_MS = 6 * 60 * 60 * 1e3;
585
+ var DEFAULT_SESSION_ID_MAX_AGE_MS = MAX_SESSION_ID_AGE_MS;
586
+ var DEFAULT_FALLBACK_DEVICE_ID_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
587
+ var DEFAULT_LGUDID_TIMEOUT_MS = 1500;
588
+ var FALLBACK_DEVICE_ID_KEY = "stormcloud.ad.dpid.v2";
589
+ var SESSION_ID_KEY = "stormcloud.ad.sid.v2";
590
+ var LEGACY_SESSION_KEY = "stormcloud.ctv.sid";
591
+ var ZEROED_IDS = /* @__PURE__ */ new Set([
592
+ "00000000-0000-0000-0000-000000000000",
593
+ "38400000-8cf0-11bd-b23e-10b96e40000d"
594
+ ]);
595
+ var hostIdentity;
596
+ var memoryStore = {};
597
+ var lgUdidResult;
598
+ var lgUdidPromise;
599
+ var legacyCleared = false;
600
+ function isUsableAdId(value) {
601
+ if (typeof value !== "string") return false;
602
+ var t = value.trim();
603
+ if (!t) return false;
604
+ if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(t)) return false;
605
+ if (/^(unknown|null|undefined|none|n\/a)$/i.test(t)) return false;
606
+ return !ZEROED_IDS.has(t.toLowerCase());
607
+ }
608
+ function isZeroedAdId(value) {
609
+ return typeof value === "string" && ZEROED_IDS.has(value.trim().toLowerCase());
610
+ }
611
+ function normalizeIdType(value) {
612
+ if (typeof value !== "string") return void 0;
613
+ var lower = value.trim().toLowerCase();
614
+ if (!lower) return void 0;
615
+ var match = GOOGLE_ID_TYPES.find(function(t) {
616
+ return t.toLowerCase() === lower;
617
+ });
618
+ return match !== null && match !== void 0 ? match : "dpid";
619
+ }
620
+ function createUuid() {
621
+ var _bytes_, _bytes_1, _bytes_i;
622
+ var c = typeof crypto !== "undefined" ? crypto : void 0;
623
+ if (c && typeof c.randomUUID === "function") return c.randomUUID();
624
+ var bytes = new Uint8Array(16);
625
+ if (c && typeof c.getRandomValues === "function") {
626
+ c.getRandomValues(bytes);
627
+ } else {
628
+ for(var i = 0; i < 16; i++)bytes[i] = Math.floor(Math.random() * 256);
629
+ }
630
+ bytes[6] = ((_bytes_ = bytes[6]) !== null && _bytes_ !== void 0 ? _bytes_ : 0) & 15 | 64;
631
+ bytes[8] = ((_bytes_1 = bytes[8]) !== null && _bytes_1 !== void 0 ? _bytes_1 : 0) & 63 | 128;
632
+ var hex = "";
633
+ 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");
634
+ 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));
635
+ }
636
+ function readStored(key) {
637
+ try {
638
+ var _window_localStorage;
639
+ var raw = typeof window !== "undefined" ? (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key) : null;
640
+ if (raw) {
641
+ var parsed = JSON.parse(raw);
642
+ if (parsed && typeof parsed.id === "string" && typeof parsed.createdAt === "number" && isFinite(parsed.createdAt)) {
643
+ return {
644
+ id: parsed.id,
645
+ createdAt: parsed.createdAt
646
+ };
647
+ }
648
+ }
649
+ } catch (unused) {}
650
+ return memoryStore[key];
651
+ }
652
+ function writeStored(key, value) {
653
+ memoryStore[key] = value;
654
+ try {
655
+ if (typeof window !== "undefined") {
656
+ var _window_localStorage;
657
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(key, JSON.stringify(value));
658
+ }
659
+ } catch (unused) {}
660
+ }
661
+ function removeStored(key) {
662
+ delete memoryStore[key];
663
+ try {
664
+ var _window_localStorage;
665
+ if (typeof window !== "undefined") (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.removeItem(key);
666
+ } catch (unused) {}
667
+ }
668
+ function clearLegacyIdsOnce() {
669
+ if (legacyCleared) return;
670
+ legacyCleared = true;
671
+ try {
672
+ var _window_localStorage;
673
+ if (typeof window !== "undefined") (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.removeItem(LEGACY_SESSION_KEY);
674
+ } catch (unused) {}
675
+ try {
676
+ if (typeof document !== "undefined") {
677
+ document.cookie = "".concat(encodeURIComponent(LEGACY_SESSION_KEY), "=;path=/;max-age=0;SameSite=Lax");
678
+ }
679
+ } catch (unused) {}
680
+ }
681
+ function clampAge(value, fallback, max) {
682
+ var v = typeof value === "number" && isFinite(value) && value > 0 ? value : fallback;
683
+ if (max != null) v = Math.min(v, max);
684
+ return v;
685
+ }
686
+ function setHostAdIdentity(identity) {
687
+ var _normalizeIdType;
688
+ if (!identity || !isUsableAdId(identity.deviceId)) {
689
+ hostIdentity = void 0;
690
+ return;
691
+ }
692
+ var deviceId = identity.deviceId.trim();
693
+ var changed = !hostIdentity || hostIdentity.deviceId !== deviceId;
694
+ hostIdentity = _object_spread({
695
+ deviceId: deviceId,
696
+ deviceIdType: (_normalizeIdType = normalizeIdType(identity.deviceIdType)) !== null && _normalizeIdType !== void 0 ? _normalizeIdType : "dpid"
697
+ }, typeof identity.limitAdTracking === "boolean" ? {
698
+ limitAdTracking: identity.limitAdTracking
699
+ } : {});
700
+ if (changed) {
701
+ removeStored(SESSION_ID_KEY);
702
+ removeStored(FALLBACK_DEVICE_ID_KEY);
703
+ }
704
+ }
705
+ function getHostAdIdentity() {
706
+ return hostIdentity ? _object_spread({}, hostIdentity) : void 0;
707
+ }
708
+ function resetAdIdentity() {
709
+ removeStored(SESSION_ID_KEY);
710
+ removeStored(FALLBACK_DEVICE_ID_KEY);
711
+ }
712
+ function readSamsungTifa() {
713
+ try {
714
+ var _window_webapis;
715
+ var adinfo = typeof window !== "undefined" ? (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.adinfo : void 0;
716
+ if (!adinfo) return void 0;
717
+ var tifa = typeof adinfo.getTIFA === "function" ? adinfo.getTIFA() : adinfo.tifa;
718
+ var lat = typeof adinfo.isLATEnabled === "function" ? adinfo.isLATEnabled() : void 0;
719
+ if (isZeroedAdId(tifa)) return {
720
+ deviceIdType: "tifa",
721
+ limitAdTracking: true
722
+ };
723
+ if (!isUsableAdId(tifa)) return void 0;
724
+ return _object_spread({
725
+ deviceId: tifa.trim(),
726
+ deviceIdType: "tifa"
727
+ }, typeof lat === "boolean" ? {
728
+ limitAdTracking: lat
729
+ } : {});
730
+ } catch (unused) {
731
+ return void 0;
732
+ }
733
+ }
734
+ function primeLgUdid() {
735
+ var timeoutMs = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : DEFAULT_LGUDID_TIMEOUT_MS;
736
+ if (lgUdidResult || lgUdidPromise) return lgUdidPromise !== null && lgUdidPromise !== void 0 ? lgUdidPromise : Promise.resolve();
737
+ var dev = typeof window !== "undefined" ? window.webOSDev : void 0;
738
+ if (!dev) return Promise.resolve();
739
+ if (typeof dev.LGUDID !== "function") {
740
+ var _dev_lgudid;
741
+ var direct = (_dev_lgudid = dev.lgudid) !== null && _dev_lgudid !== void 0 ? _dev_lgudid : dev.LGUDID;
742
+ if (isZeroedAdId(direct)) lgUdidResult = {
743
+ deviceIdType: "lgudid",
744
+ limitAdTracking: true
745
+ };
746
+ else if (isUsableAdId(direct)) {
747
+ lgUdidResult = {
748
+ deviceId: direct.trim(),
749
+ deviceIdType: "lgudid",
750
+ limitAdTracking: false
751
+ };
752
+ }
753
+ return Promise.resolve();
754
+ }
755
+ lgUdidPromise = new Promise(function(resolve) {
756
+ var settled = false;
757
+ var finish = function finish() {
758
+ if (settled) return;
759
+ settled = true;
760
+ clearTimeout(timer);
761
+ resolve();
762
+ };
763
+ var timer = setTimeout(finish, Math.max(0, timeoutMs));
764
+ try {
765
+ dev.LGUDID({
766
+ onSuccess: function onSuccess(res) {
767
+ var id = res === null || res === void 0 ? void 0 : res.id;
768
+ if (isZeroedAdId(id)) {
769
+ lgUdidResult = {
770
+ deviceIdType: "lgudid",
771
+ limitAdTracking: true
772
+ };
773
+ } else if (isUsableAdId(id)) {
774
+ lgUdidResult = {
775
+ deviceId: id.trim(),
776
+ deviceIdType: "lgudid",
777
+ limitAdTracking: false
778
+ };
779
+ }
780
+ finish();
781
+ },
782
+ onFailure: function onFailure() {
783
+ return finish();
784
+ }
785
+ });
786
+ } catch (unused) {
787
+ finish();
788
+ }
789
+ });
790
+ return lgUdidPromise;
791
+ }
792
+ function readCachedLgUdid() {
793
+ return lgUdidResult ? _object_spread({}, lgUdidResult) : void 0;
794
+ }
795
+ function getOrRotateFallbackDeviceId() {
796
+ 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();
797
+ clearLegacyIdsOnce();
798
+ var age = clampAge(maxAgeMs, DEFAULT_FALLBACK_DEVICE_ID_MAX_AGE_MS);
799
+ var stored = readStored(FALLBACK_DEVICE_ID_KEY);
800
+ if (stored && isUsableAdId(stored.id) && now - stored.createdAt >= 0 && now - stored.createdAt < age) {
801
+ return stored.id;
802
+ }
803
+ var id = createUuid();
804
+ writeStored(FALLBACK_DEVICE_ID_KEY, {
805
+ id: id,
806
+ createdAt: now
807
+ });
808
+ return id;
809
+ }
810
+ function getOrRotateSessionId() {
811
+ 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();
812
+ clearLegacyIdsOnce();
813
+ var age = clampAge(maxAgeMs, DEFAULT_SESSION_ID_MAX_AGE_MS, MAX_SESSION_ID_AGE_MS);
814
+ var stored = readStored(SESSION_ID_KEY);
815
+ if (stored && isUsableAdId(stored.id) && stored.id !== avoidValue && now - stored.createdAt >= 0 && now - stored.createdAt < age) {
816
+ return stored.id;
817
+ }
818
+ var id = createUuid();
819
+ while(id === avoidValue)id = createUuid();
820
+ writeStored(SESSION_ID_KEY, {
821
+ id: id,
822
+ createdAt: now
823
+ });
824
+ return id;
825
+ }
569
826
  // src/utils/vastEnvironmentSignals.ts
570
- var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
571
827
  var PLAYER_ID_STORAGE_KEY = "stormcloud.player.id";
572
828
  var DEVICE_ID_STORAGE_KEYS = [
573
829
  "rdid",
@@ -586,49 +842,96 @@ var ANDROID_ID_TYPES = /* @__PURE__ */ new Set([
586
842
  "adid"
587
843
  ]);
588
844
  function resolveVastEnvironmentSignals(isCtv) {
589
- var bridgeSignals = readNativeBridgeSignals();
590
- var platformDevice = readPlatformNativeDeviceId();
591
- var bridgeDeviceId = validDeviceId(bridgeSignals.deviceId);
592
- var realDeviceId = bridgeDeviceId || (isCtv ? validDeviceId(readStoredDeviceId()) : void 0) || validDeviceId(platformDevice.deviceId);
593
- var deviceId = realDeviceId;
594
- var deviceIdType = (bridgeDeviceId ? bridgeSignals.deviceIdType : void 0) || readStoredString("deviceIdType") || readStoredString("idtype") || platformDevice.deviceIdType || inferDeviceIdType();
595
- var platformLat = bridgeDeviceId ? bridgeSignals.limitAdTracking : platformDevice.limitAdTracking;
596
- var limitAdTracking = deviceId != null ? platformLat !== null && platformLat !== void 0 ? platformLat : readStoredLimitAdTracking() : void 0;
597
- if (!deviceId && isCtv) {
598
- var dpid = getOrCreateStoredUuid(PLAYER_ID_STORAGE_KEY);
599
- if (dpid) {
600
- deviceId = dpid;
601
- deviceIdType = "dpid";
602
- limitAdTracking = platformLat !== null && platformLat !== void 0 ? platformLat : readStoredLimitAdTracking();
603
- }
604
- }
845
+ var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
605
846
  var deviceTypeHint = resolveDeviceTypeHint(isCtv);
847
+ var identity = resolveDeviceIdentity(isCtv, options);
848
+ var identityFields = _object_spread({}, identity.deviceId ? {
849
+ deviceId: identity.deviceId
850
+ } : {}, identity.deviceId && identity.deviceIdType ? {
851
+ deviceIdType: identity.deviceIdType
852
+ } : {}, identity.deviceId && identity.limitAdTracking != null ? {
853
+ limitAdTracking: identity.limitAdTracking
854
+ } : {}, identity.source ? {
855
+ deviceIdSource: identity.source
856
+ } : {});
606
857
  if (isCtv) {
607
858
  return _object_spread_props(_object_spread({
608
859
  isCtv: true,
609
- sessionId: getOrCreateCtvSessionId()
610
- }, deviceId ? {
611
- deviceId: deviceId
612
- } : {}, deviceId && deviceIdType ? {
613
- deviceIdType: deviceIdType
614
- } : {}, deviceId && limitAdTracking != null ? {
615
- limitAdTracking: limitAdTracking
616
- } : {}), {
860
+ sessionId: getOrRotateSessionId(options.sessionIdMaxAgeMs, identity.deviceId)
861
+ }, identityFields), {
617
862
  deviceTypeHint: deviceTypeHint
618
863
  });
619
864
  }
620
865
  return _object_spread_props(_object_spread({
621
866
  isCtv: false
622
- }, deviceId ? {
623
- deviceId: deviceId
624
- } : {}, deviceId && deviceIdType ? {
625
- deviceIdType: deviceIdType
626
- } : {}, deviceId && limitAdTracking != null ? {
627
- limitAdTracking: limitAdTracking
628
- } : {}), {
867
+ }, identityFields), {
629
868
  deviceTypeHint: deviceTypeHint
630
869
  });
631
870
  }
871
+ function resolveDeviceIdentity(isCtv, options) {
872
+ var _platform_limitAdTracking;
873
+ var host = getHostAdIdentity();
874
+ if (host) {
875
+ var _host_deviceIdType;
876
+ return _object_spread_props(_object_spread({
877
+ deviceId: host.deviceId,
878
+ deviceIdType: (_host_deviceIdType = host.deviceIdType) !== null && _host_deviceIdType !== void 0 ? _host_deviceIdType : "dpid"
879
+ }, host.limitAdTracking != null ? {
880
+ limitAdTracking: host.limitAdTracking
881
+ } : {}), {
882
+ source: "host"
883
+ });
884
+ }
885
+ var bridge = readNativeBridgeSignals();
886
+ var bridgeDeviceId = validDeviceId(bridge.deviceId);
887
+ if (bridgeDeviceId) {
888
+ var _normalizeIdType;
889
+ return _object_spread_props(_object_spread({
890
+ deviceId: bridgeDeviceId,
891
+ deviceIdType: (_normalizeIdType = normalizeIdType(bridge.deviceIdType)) !== null && _normalizeIdType !== void 0 ? _normalizeIdType : "dpid"
892
+ }, bridge.limitAdTracking != null ? {
893
+ limitAdTracking: bridge.limitAdTracking
894
+ } : {}), {
895
+ source: "bridge"
896
+ });
897
+ }
898
+ var platform = readPlatformNativeDeviceId();
899
+ var platformDeviceId = validDeviceId(platform.deviceId);
900
+ if (platformDeviceId) {
901
+ var _platform_deviceIdType;
902
+ return _object_spread_props(_object_spread({
903
+ deviceId: platformDeviceId,
904
+ deviceIdType: (_platform_deviceIdType = platform.deviceIdType) !== null && _platform_deviceIdType !== void 0 ? _platform_deviceIdType : "dpid"
905
+ }, platform.limitAdTracking != null ? {
906
+ limitAdTracking: platform.limitAdTracking
907
+ } : {}), {
908
+ source: "platform"
909
+ });
910
+ }
911
+ if (!isCtv) return {};
912
+ var storedDeviceId = validDeviceId(readStoredDeviceId());
913
+ if (storedDeviceId) {
914
+ var _normalizeIdType1;
915
+ var storedLat = readStoredLimitAdTracking();
916
+ return _object_spread_props(_object_spread({
917
+ deviceId: storedDeviceId,
918
+ deviceIdType: (_normalizeIdType1 = normalizeIdType(readStoredString("deviceIdType") || readStoredString("idtype"))) !== null && _normalizeIdType1 !== void 0 ? _normalizeIdType1 : "dpid"
919
+ }, storedLat != null ? {
920
+ limitAdTracking: storedLat
921
+ } : {}), {
922
+ source: "stored"
923
+ });
924
+ }
925
+ var fallbackLat = (_platform_limitAdTracking = platform.limitAdTracking) !== null && _platform_limitAdTracking !== void 0 ? _platform_limitAdTracking : readStoredLimitAdTracking();
926
+ return _object_spread_props(_object_spread({
927
+ deviceId: getOrRotateFallbackDeviceId(options.fallbackDeviceIdMaxAgeMs),
928
+ deviceIdType: "dpid"
929
+ }, fallbackLat != null ? {
930
+ limitAdTracking: fallbackLat
931
+ } : {}), {
932
+ source: "generated"
933
+ });
934
+ }
632
935
  var DEVICE_TYPE_HINT = {
633
936
  FEATURE_PHONE: 1,
634
937
  SMARTPHONE: 2,
@@ -789,7 +1092,7 @@ function resolveNativeDeviceId() {
789
1092
  var bridgeSignals = readNativeBridgeSignals();
790
1093
  var platformDevice = readPlatformNativeDeviceId();
791
1094
  var deviceId = bridgeSignals.deviceId || (includeStored ? readStoredDeviceId() : void 0) || platformDevice.deviceId;
792
- if (!deviceId || isMacroPlaceholder(deviceId) || isZeroedAdId(deviceId)) {
1095
+ if (!deviceId || isMacroPlaceholder(deviceId) || isZeroedAdId2(deviceId)) {
793
1096
  return void 0;
794
1097
  }
795
1098
  return deviceId;
@@ -803,20 +1106,10 @@ function getOrCreateStoredUuid(storageKey) {
803
1106
  writePersistentId(storageKey, existing);
804
1107
  return existing;
805
1108
  }
806
- var id = createUuid();
1109
+ var id = createUuid2();
807
1110
  writePersistentId(storageKey, id);
808
1111
  return id;
809
1112
  }
810
- function getOrCreateCtvSessionId() {
811
- var existing = readPersistentId(CTV_SESSION_STORAGE_KEY);
812
- if (existing) {
813
- writePersistentId(CTV_SESSION_STORAGE_KEY, existing);
814
- return existing;
815
- }
816
- var sessionId = createUuid();
817
- writePersistentId(CTV_SESSION_STORAGE_KEY, sessionId);
818
- return sessionId;
819
- }
820
1113
  function readPersistentId(storageKey) {
821
1114
  return readStoredString(storageKey) || readCookie(storageKey);
822
1115
  }
@@ -869,7 +1162,7 @@ function writeCookie(name, value) {
869
1162
  document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + ";path=/;max-age=" + PERSISTENT_ID_COOKIE_MAX_AGE + ";SameSite=Lax";
870
1163
  } catch (unused) {}
871
1164
  }
872
- function createUuid() {
1165
+ function createUuid2() {
873
1166
  var _bytes_, _bytes_1;
874
1167
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
875
1168
  return crypto.randomUUID();
@@ -903,44 +1196,10 @@ function performanceNow() {
903
1196
  }
904
1197
  function readPlatformNativeDeviceId() {
905
1198
  if (typeof window === "undefined") return {};
906
- try {
907
- var _window_webapis;
908
- var adinfo = (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.adinfo;
909
- if (adinfo) {
910
- var tifa = typeof adinfo.getTIFA === "function" ? adinfo.getTIFA() : adinfo.tifa;
911
- if (typeof tifa === "string" && tifa && !isMacroPlaceholder(tifa)) {
912
- var lat = typeof adinfo.isLATEnabled === "function" ? adinfo.isLATEnabled() : void 0;
913
- return _object_spread({
914
- deviceId: tifa,
915
- deviceIdType: "tifa"
916
- }, typeof lat === "boolean" ? {
917
- limitAdTracking: lat
918
- } : {});
919
- }
920
- }
921
- } catch (unused) {}
922
- try {
923
- var webOSDev = window.webOSDev;
924
- if (webOSDev) {
925
- var _webOSDev_lgudid;
926
- var lgudid = typeof webOSDev.LGUDID === "function" ? webOSDev.LGUDID() : (_webOSDev_lgudid = webOSDev.lgudid) !== null && _webOSDev_lgudid !== void 0 ? _webOSDev_lgudid : webOSDev.LGUDID;
927
- if (typeof lgudid === "string" && lgudid) {
928
- if (isZeroedAdId(lgudid)) {
929
- return {
930
- deviceIdType: "lgudid",
931
- limitAdTracking: true
932
- };
933
- }
934
- if (!isMacroPlaceholder(lgudid)) {
935
- return {
936
- deviceId: lgudid,
937
- deviceIdType: "lgudid",
938
- limitAdTracking: false
939
- };
940
- }
941
- }
942
- }
943
- } catch (unused) {}
1199
+ var tifa = readSamsungTifa();
1200
+ if (tifa) return tifa;
1201
+ var lgudid = readCachedLgUdid();
1202
+ if (lgudid) return lgudid;
944
1203
  try {
945
1204
  var roku = window.Roku;
946
1205
  if (roku) {
@@ -967,7 +1226,7 @@ function isMacroPlaceholder(value) {
967
1226
  function validDeviceId(value) {
968
1227
  return value && !isMacroPlaceholder(value) ? value : void 0;
969
1228
  }
970
- function isZeroedAdId(value) {
1229
+ function isZeroedAdId2(value) {
971
1230
  return ZEROED_AD_ID_PATTERNS.has(value.trim().toLowerCase());
972
1231
  }
973
1232
  function readNativeBridgeSignals() {
@@ -1011,7 +1270,7 @@ function readNativeBridgeSignals() {
1011
1270
  "deviceIdType",
1012
1271
  "advertisingIdType",
1013
1272
  "idType"
1014
- ]) || inferDeviceIdType();
1273
+ ]) || void 0;
1015
1274
  var limitAdTracking = readBridgeBoolean(source, [
1016
1275
  "is_lat",
1017
1276
  "limitAdTracking",
@@ -1191,6 +1450,308 @@ function normalizeBoolean(value) {
1191
1450
  }
1192
1451
  return void 0;
1193
1452
  }
1453
+ // src/utils/contentMetadata.ts
1454
+ var MAX_CONTENT_VALUE_LENGTH = 128;
1455
+ var BRIDGE_KEYS = {
1456
+ channelName: [
1457
+ "channelName",
1458
+ "ct_ch"
1459
+ ],
1460
+ programTitle: [
1461
+ "programTitle",
1462
+ "ct_ti"
1463
+ ],
1464
+ contentNetwork: [
1465
+ "contentNetwork",
1466
+ "ct_ne"
1467
+ ],
1468
+ contentType: [
1469
+ "contentType",
1470
+ "ctt"
1471
+ ],
1472
+ contentCategory: [
1473
+ "contentCategory",
1474
+ "ctc"
1475
+ ],
1476
+ contentGenre: [
1477
+ "contentGenre",
1478
+ "ctgr"
1479
+ ],
1480
+ contentLanguage: [
1481
+ "contentLanguage",
1482
+ "ctlg"
1483
+ ],
1484
+ contentDuration: [
1485
+ "contentDuration",
1486
+ "ctd"
1487
+ ],
1488
+ contentSeason: [
1489
+ "contentSeason",
1490
+ "cts"
1491
+ ],
1492
+ contentEpisode: [
1493
+ "contentEpisode",
1494
+ "cte"
1495
+ ],
1496
+ contentRating: [
1497
+ "contentRating",
1498
+ "ctr"
1499
+ ],
1500
+ contentId: [
1501
+ "contentId",
1502
+ "ctid"
1503
+ ]
1504
+ };
1505
+ function sanitizeContentValue(value) {
1506
+ if (typeof value !== "string") return void 0;
1507
+ var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1508
+ if (!cleaned) return void 0;
1509
+ if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
1510
+ if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
1511
+ return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
1512
+ }
1513
+ function sanitizeContentScalar(value) {
1514
+ if (typeof value === "number") {
1515
+ return Number.isFinite(value) ? String(value) : void 0;
1516
+ }
1517
+ return sanitizeContentValue(value);
1518
+ }
1519
+ function normalizeContentLanguage(value) {
1520
+ var cleaned = sanitizeContentValue(value);
1521
+ if (!cleaned) return void 0;
1522
+ var match = cleaned.match(/^([A-Za-z]{2})(?:[-_][A-Za-z0-9]{1,8})*$/);
1523
+ return match && match[1] ? match[1].toLowerCase() : void 0;
1524
+ }
1525
+ function normalizeContentDuration(value) {
1526
+ var raw = sanitizeContentScalar(value);
1527
+ if (raw == null || !/^-?\d+(\.\d+)?$/.test(raw)) return void 0;
1528
+ var seconds = Number(raw);
1529
+ if (seconds === -1) return -1;
1530
+ return seconds > 0 ? Math.round(seconds) : void 0;
1531
+ }
1532
+ function bridgeSources() {
1533
+ if (typeof window === "undefined") return [];
1534
+ var w = window;
1535
+ return [
1536
+ w.__STORMCLOUD_CTV__,
1537
+ w.__STORMCLOUD_CTV_AD_INFO__,
1538
+ w.stormcloudCtv
1539
+ ].filter(Boolean);
1540
+ }
1541
+ function readBridgeValue2(keys, sanitize) {
1542
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1543
+ try {
1544
+ for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1545
+ var source = _step.value;
1546
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
1547
+ try {
1548
+ for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
1549
+ var key = _step1.value;
1550
+ var value = void 0;
1551
+ try {
1552
+ value = source === null || source === void 0 ? void 0 : source[key];
1553
+ if (typeof value === "function") value = value.call(source);
1554
+ } catch (unused) {
1555
+ value = void 0;
1556
+ }
1557
+ var sanitized = sanitize(value);
1558
+ if (sanitized != null) return sanitized;
1559
+ }
1560
+ } catch (err) {
1561
+ _didIteratorError1 = true;
1562
+ _iteratorError1 = err;
1563
+ } finally{
1564
+ try {
1565
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
1566
+ _iterator1.return();
1567
+ }
1568
+ } finally{
1569
+ if (_didIteratorError1) {
1570
+ throw _iteratorError1;
1571
+ }
1572
+ }
1573
+ }
1574
+ }
1575
+ } catch (err) {
1576
+ _didIteratorError = true;
1577
+ _iteratorError = err;
1578
+ } finally{
1579
+ try {
1580
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1581
+ _iterator.return();
1582
+ }
1583
+ } finally{
1584
+ if (_didIteratorError) {
1585
+ throw _iteratorError;
1586
+ }
1587
+ }
1588
+ }
1589
+ return void 0;
1590
+ }
1591
+ function readBridgeContentValue(keys) {
1592
+ return readBridgeValue2(keys, sanitizeContentValue);
1593
+ }
1594
+ function resolveContentMetadata(config) {
1595
+ var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2, _config_contentDetails, _sanitizeContentValue3, _sanitizeContentValue4, _sanitizeContentValue5, _normalizeContentLanguage, _normalizeContentDuration, _sanitizeContentScalar, _sanitizeContentScalar1, _sanitizeContentValue6, _sanitizeContentValue7;
1596
+ var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
1597
+ var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
1598
+ var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
1599
+ var details = (_config_contentDetails = config.contentDetails) !== null && _config_contentDetails !== void 0 ? _config_contentDetails : {};
1600
+ var contentType = (_sanitizeContentValue3 = sanitizeContentValue(details.contentType)) !== null && _sanitizeContentValue3 !== void 0 ? _sanitizeContentValue3 : readBridgeContentValue(BRIDGE_KEYS.contentType);
1601
+ var contentCategory = (_sanitizeContentValue4 = sanitizeContentValue(details.category)) !== null && _sanitizeContentValue4 !== void 0 ? _sanitizeContentValue4 : readBridgeContentValue(BRIDGE_KEYS.contentCategory);
1602
+ var contentGenre = (_sanitizeContentValue5 = sanitizeContentValue(details.genre)) !== null && _sanitizeContentValue5 !== void 0 ? _sanitizeContentValue5 : readBridgeContentValue(BRIDGE_KEYS.contentGenre);
1603
+ var contentLanguage = (_normalizeContentLanguage = normalizeContentLanguage(details.language)) !== null && _normalizeContentLanguage !== void 0 ? _normalizeContentLanguage : readBridgeValue2(BRIDGE_KEYS.contentLanguage, normalizeContentLanguage);
1604
+ var contentDurationSeconds = (_normalizeContentDuration = normalizeContentDuration(details.durationSeconds)) !== null && _normalizeContentDuration !== void 0 ? _normalizeContentDuration : readBridgeValue2(BRIDGE_KEYS.contentDuration, normalizeContentDuration);
1605
+ var contentSeason = (_sanitizeContentScalar = sanitizeContentScalar(details.season)) !== null && _sanitizeContentScalar !== void 0 ? _sanitizeContentScalar : readBridgeValue2(BRIDGE_KEYS.contentSeason, sanitizeContentScalar);
1606
+ var contentEpisode = (_sanitizeContentScalar1 = sanitizeContentScalar(details.episode)) !== null && _sanitizeContentScalar1 !== void 0 ? _sanitizeContentScalar1 : readBridgeValue2(BRIDGE_KEYS.contentEpisode, sanitizeContentScalar);
1607
+ var contentRating = (_sanitizeContentValue6 = sanitizeContentValue(details.rating)) !== null && _sanitizeContentValue6 !== void 0 ? _sanitizeContentValue6 : readBridgeContentValue(BRIDGE_KEYS.contentRating);
1608
+ var contentId = (_sanitizeContentValue7 = sanitizeContentValue(details.contentId)) !== null && _sanitizeContentValue7 !== void 0 ? _sanitizeContentValue7 : readBridgeContentValue(BRIDGE_KEYS.contentId);
1609
+ return _object_spread({}, channelName ? {
1610
+ channelName: channelName
1611
+ } : {}, programTitle ? {
1612
+ programTitle: programTitle
1613
+ } : {}, contentNetwork ? {
1614
+ contentNetwork: contentNetwork
1615
+ } : {}, contentType ? {
1616
+ contentType: contentType
1617
+ } : {}, contentCategory ? {
1618
+ contentCategory: contentCategory
1619
+ } : {}, contentGenre ? {
1620
+ contentGenre: contentGenre
1621
+ } : {}, contentLanguage ? {
1622
+ contentLanguage: contentLanguage
1623
+ } : {}, contentDurationSeconds != null ? {
1624
+ contentDurationSeconds: contentDurationSeconds
1625
+ } : {}, contentSeason ? {
1626
+ contentSeason: contentSeason
1627
+ } : {}, contentEpisode ? {
1628
+ contentEpisode: contentEpisode
1629
+ } : {}, contentRating ? {
1630
+ contentRating: contentRating
1631
+ } : {}, contentId ? {
1632
+ contentId: contentId
1633
+ } : {});
1634
+ }
1635
+ function applyContentMetadataUpdate(target, meta) {
1636
+ var apply = function apply(key, value) {
1637
+ if (value === void 0) return;
1638
+ var clean = value === null ? void 0 : sanitizeContentValue(value);
1639
+ if (clean) target[key] = clean;
1640
+ else delete target[key];
1641
+ };
1642
+ apply("channelName", meta.channelName);
1643
+ apply("programTitle", meta.programTitle);
1644
+ apply("contentNetwork", meta.contentNetwork);
1645
+ if (meta.details === void 0) return;
1646
+ if (meta.details === null) delete target.contentDetails;
1647
+ else target.contentDetails = _object_spread({}, meta.details);
1648
+ }
1649
+ function appendMissingContentParams(url, meta) {
1650
+ if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
1651
+ try {
1652
+ var parsed = new URL(url);
1653
+ var add = function add(key, value) {
1654
+ if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
1655
+ };
1656
+ add("ct_ch", meta.channelName);
1657
+ add("ct_ti", meta.programTitle);
1658
+ add("ct_ne", meta.contentNetwork);
1659
+ return parsed.toString();
1660
+ } catch (unused) {
1661
+ return url;
1662
+ }
1663
+ }
1664
+ // src/utils/partnerSignals.ts
1665
+ var PLATFORM_IFA_TYPES = /* @__PURE__ */ new Set([
1666
+ "aaid",
1667
+ "adid",
1668
+ "afai",
1669
+ "idfa",
1670
+ "lgudid",
1671
+ "msai",
1672
+ "rida",
1673
+ "tifa",
1674
+ "tvos",
1675
+ "vaid",
1676
+ "vida"
1677
+ ]);
1678
+ function toIabIfaType(deviceIdType, source) {
1679
+ if (!deviceIdType) return void 0;
1680
+ var type = deviceIdType.trim().toLowerCase();
1681
+ if (source === "generated") return "sessionid";
1682
+ if (PLATFORM_IFA_TYPES.has(type)) return type;
1683
+ if (source === "platform") return "dpid";
1684
+ return "ppid";
1685
+ }
1686
+ function playbackMethodCode(autoPlay, muted) {
1687
+ if (autoPlay === false) return 3;
1688
+ if (autoPlay !== true || muted == null) return void 0;
1689
+ return muted ? 2 : 1;
1690
+ }
1691
+ function resolvePlayerSize(video) {
1692
+ var width = video ? video.clientWidth : 0;
1693
+ var height = video ? video.clientHeight : 0;
1694
+ if (!(width > 0 && height > 0) && typeof window !== "undefined") {
1695
+ width = window.innerWidth;
1696
+ height = window.innerHeight;
1697
+ }
1698
+ if (!(width > 0 && height > 0)) return {};
1699
+ return {
1700
+ width: Math.round(width),
1701
+ height: Math.round(height)
1702
+ };
1703
+ }
1704
+ function sanitizeUserId(value) {
1705
+ var cleaned = sanitizeContentValue(value);
1706
+ if (!cleaned || /\s/.test(cleaned)) return void 0;
1707
+ return cleaned;
1708
+ }
1709
+ function isPublicIpv4(ip) {
1710
+ var parts = ip.split(".");
1711
+ if (parts.length !== 4) return false;
1712
+ var nums = parts.map(function(p) {
1713
+ return /^\d{1,3}$/.test(p) ? Number(p) : NaN;
1714
+ });
1715
+ if (nums.some(function(n) {
1716
+ return !(n >= 0 && n <= 255);
1717
+ })) return false;
1718
+ var _nums = _sliced_to_array(nums, 2), a = _nums[0], b = _nums[1];
1719
+ if (a === 0 || a === 10 || a === 127 || a >= 224) return false;
1720
+ if (a === 100 && b >= 64 && b <= 127) return false;
1721
+ if (a === 169 && b === 254) return false;
1722
+ if (a === 172 && b >= 16 && b <= 31) return false;
1723
+ if (a === 192 && b === 168) return false;
1724
+ return true;
1725
+ }
1726
+ function isPublicIpv6(ip) {
1727
+ var lower = ip.toLowerCase();
1728
+ if (!/^[0-9a-f:]+$/.test(lower) || lower.split(":").length < 3) return false;
1729
+ if (lower === "::" || lower === "::1") return false;
1730
+ if (/^fe[89ab]/.test(lower)) return false;
1731
+ if (/^f[cd]/.test(lower)) return false;
1732
+ return true;
1733
+ }
1734
+ function sanitizePublicIp(value) {
1735
+ var cleaned = sanitizeContentValue(value);
1736
+ if (!cleaned) return void 0;
1737
+ if (cleaned.includes(".")) return isPublicIpv4(cleaned) ? cleaned : void 0;
1738
+ return isPublicIpv6(cleaned) ? cleaned : void 0;
1739
+ }
1740
+ function resolveUserId(configValue) {
1741
+ var _sanitizeUserId;
1742
+ return (_sanitizeUserId = sanitizeUserId(configValue)) !== null && _sanitizeUserId !== void 0 ? _sanitizeUserId : readBridgeValue2([
1743
+ "userId",
1744
+ "uid"
1745
+ ], sanitizeUserId);
1746
+ }
1747
+ function resolveClientIp(configValue) {
1748
+ var _sanitizePublicIp;
1749
+ return (_sanitizePublicIp = sanitizePublicIp(configValue)) !== null && _sanitizePublicIp !== void 0 ? _sanitizePublicIp : readBridgeValue2([
1750
+ "ipAddress",
1751
+ "clientIp",
1752
+ "ip"
1753
+ ], sanitizePublicIp);
1754
+ }
1194
1755
  // src/utils/vastMacros.ts
1195
1756
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
1196
1757
  var INVALID_VAST_PARAM_KEY = /^\s|\s$/;
@@ -1508,7 +2069,8 @@ var NESTED_QUERY_PARAM_KEYS = /* @__PURE__ */ new Set([
1508
2069
  var SCVP_POD_MACROS = /* @__PURE__ */ new Set([
1509
2070
  "PMND",
1510
2071
  "PMXD",
1511
- "PMAD"
2072
+ "PMAD",
2073
+ "MABD"
1512
2074
  ]);
1513
2075
  function hasScvpMacros(url) {
1514
2076
  return !!url && SCVP_MACRO_DETECT.test(url);
@@ -1553,12 +2115,15 @@ function resolveScvpMacroValues(ctx) {
1553
2115
  set("RDID", deviceId);
1554
2116
  set("IDTYPE", deviceIdType);
1555
2117
  set("IS-LAT", (_toFlag = toFlag(ctx.limitAdTracking)) !== null && _toFlag !== void 0 ? _toFlag : "0");
2118
+ set("IFA", deviceId);
2119
+ set("IFA-TYPE", toIabIfaType(deviceIdType, ctx.deviceIdSource));
1556
2120
  }
1557
2121
  set("SID", ctx.sessionId);
1558
2122
  set("DTH", ctx.deviceTypeHint);
1559
2123
  set("GIVN", ctx.palNonce);
1560
2124
  set("CT-TI", ctx.programTitle);
1561
2125
  set("CT-CH", ctx.channelName);
2126
+ set("CT-NE", ctx.contentNetwork);
1562
2127
  set("POD", ctx.pod);
1563
2128
  set("CORRELATOR", ctx.correlator);
1564
2129
  set("SCOR", ctx.streamCorrelator);
@@ -1569,6 +2134,26 @@ function resolveScvpMacroValues(ctx) {
1569
2134
  set("GDPR", (_ctx_consent = ctx.consent) === null || _ctx_consent === void 0 ? void 0 : _ctx_consent.gdpr);
1570
2135
  set("GDPR-CONSENT", (_ctx_consent1 = ctx.consent) === null || _ctx_consent1 === void 0 ? void 0 : _ctx_consent1.gdprConsent);
1571
2136
  set("US-PRIVACY", (_ctx_consent2 = ctx.consent) === null || _ctx_consent2 === void 0 ? void 0 : _ctx_consent2.usPrivacy);
2137
+ set("PLAYER-WIDTH", ctx.playerWidth);
2138
+ set("PLAYER-HEIGHT", ctx.playerHeight);
2139
+ set("TIMESTAMP", ctx.timestamp);
2140
+ set("LIVE", toFlag(ctx.isLive));
2141
+ set("VPMT", playbackMethodCode(ctx.isCtv ? true : ctx.adWillAutoPlay, ctx.adWillPlayMuted));
2142
+ set("DEVICE-MAKE", ctx.deviceMake);
2143
+ set("DEVICE-MODEL", ctx.deviceModel);
2144
+ set("DEVICE-HWV", ctx.deviceHardwareVersion);
2145
+ set("UA", ctx.userAgent);
2146
+ set("IP", ctx.ipAddress);
2147
+ set("UID", ctx.userId);
2148
+ set("CT-TYPE", ctx.contentType);
2149
+ set("CT-CATEGORY", ctx.contentCategory);
2150
+ set("CT-GENRE", ctx.contentGenre);
2151
+ set("CT-LANGUAGE", ctx.contentLanguage);
2152
+ set("CT-DURATION", ctx.contentDurationSeconds != null ? ctx.contentDurationSeconds : ctx.isLive ? -1 : void 0);
2153
+ set("CT-SEASON", ctx.contentSeason);
2154
+ set("CT-EPISODE", ctx.contentEpisode);
2155
+ set("CT-RATING", ctx.contentRating);
2156
+ set("CT-ID", ctx.contentId);
1572
2157
  return values;
1573
2158
  }
1574
2159
  var keepNone = function keepNone() {
@@ -1787,6 +2372,9 @@ function applyVastMacros(baseUrl, ctx) {
1787
2372
  if (ctx.channelName) {
1788
2373
  params.set("ct_ch", ctx.channelName);
1789
2374
  }
2375
+ if (ctx.contentNetwork) {
2376
+ params.set("ct_ne", ctx.contentNetwork);
2377
+ }
1790
2378
  var staleKeys = [];
1791
2379
  params.forEach(function(value, key) {
1792
2380
  if (isMacroPlaceholder2(value)) {
@@ -2460,8 +3048,17 @@ function detectBrowser() {
2460
3048
  chromeVersion: chromeVersionNum
2461
3049
  };
2462
3050
  }
3051
+ var singleDecoderOverride;
3052
+ function setSingleDecoderOverride(value) {
3053
+ singleDecoderOverride = value;
3054
+ }
2463
3055
  function requiresMediaPipelineResetAfterAds() {
2464
3056
  var _browser_tizenVersion;
3057
+ if (singleDecoderOverride != null) return singleDecoderOverride;
3058
+ try {
3059
+ var globalOverride = typeof window !== "undefined" ? window.__STORMCLOUD_SINGLE_DECODER__ : void 0;
3060
+ if (typeof globalOverride === "boolean") return globalOverride;
3061
+ } catch (unused) {}
2465
3062
  var browser = detectBrowser();
2466
3063
  return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
2467
3064
  }
@@ -2644,7 +3241,7 @@ function substituteVastTrackingMacros(url) {
2644
3241
  });
2645
3242
  }
2646
3243
  // src/player/OptimizedPodRequest.ts
2647
- var DEFAULT_REQUEST_SAFETY_MS = 1500;
3244
+ var DEFAULT_REQUEST_SAFETY_MS = 2500;
2648
3245
  var GAM_AD_OPPORTUNITY_DURATION_MS = 3e4;
2649
3246
  var POD_PARAM_KEYS = [
2650
3247
  "pmnd",
@@ -2804,15 +3401,20 @@ function finalizeGamRequestUrl(rawUrl, ctx) {
2804
3401
  values.set("PMND", String(pod.pmnd));
2805
3402
  values.set("PMXD", String(pod.pmxd));
2806
3403
  if (pod.pmad != null) values.set("PMAD", String(pod.pmad));
3404
+ values.set("MABD", String(Math.max(1, Math.floor(pod.pmxd / 1e3))));
2807
3405
  }
2808
3406
  var substituted = substituteScvpMacros(rawUrl, values);
2809
3407
  var finalUrl;
2810
3408
  try {
2811
3409
  var url = new URL(normalizeVastTagUrl(substituted.url));
3410
+ var isGam = GAM_AD_HOSTS.has(url.hostname);
3411
+ var setPodParam = function setPodParam(key, value) {
3412
+ if (isGam || url.searchParams.has(key)) url.searchParams.set(key, String(value));
3413
+ };
2812
3414
  if (pod) {
2813
- url.searchParams.set("pmnd", String(pod.pmnd));
2814
- url.searchParams.set("pmxd", String(pod.pmxd));
2815
- if (pod.pmad != null) url.searchParams.set("pmad", String(pod.pmad));
3415
+ setPodParam("pmnd", pod.pmnd);
3416
+ setPodParam("pmxd", pod.pmxd);
3417
+ if (pod.pmad != null) setPodParam("pmad", pod.pmad);
2816
3418
  else url.searchParams.delete("pmad");
2817
3419
  } else {
2818
3420
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2878,7 +3480,9 @@ function validateGamRequestUrl(url, expect) {
2878
3480
  if (leftover.length > 0) problems.push("unresolved SCVP macros: ".concat(leftover.join(", ")));
2879
3481
  var params;
2880
3482
  try {
2881
- params = new URL(url).searchParams;
3483
+ var parsed = new URL(url);
3484
+ if (!GAM_AD_HOSTS.has(parsed.hostname)) return problems;
3485
+ params = parsed.searchParams;
2882
3486
  } catch (unused) {
2883
3487
  return problems.concat("URL could not be parsed");
2884
3488
  }
@@ -3068,6 +3672,9 @@ function createHlsAdPlayer(contentVideo, options) {
3068
3672
  var mediaCandidateIndex = 0;
3069
3673
  var mediaStartTimerId;
3070
3674
  var MEDIA_START_TIMEOUT_MS = (_ref = options === null || options === void 0 ? void 0 : options.mediaStartTimeoutMs) !== null && _ref !== void 0 ? _ref : 8e3;
3675
+ var MAX_MEDIA_START_ATTEMPTS = 2;
3676
+ var MEDIA_START_TOTAL_BUDGET_MS = Math.max(MEDIA_START_TIMEOUT_MS, 1e4);
3677
+ var mediaStartBudgetStartedAt = 0;
3071
3678
  var VAST_ERROR_MEDIA_TIMEOUT = 402;
3072
3679
  var pendingVastRequests = /* @__PURE__ */ new Set();
3073
3680
  var pendingRequestAbortReason;
@@ -5082,12 +5689,14 @@ function createHlsAdPlayer(contentVideo, options) {
5082
5689
  clearMediaStartTimer();
5083
5690
  if (!(MEDIA_START_TIMEOUT_MS > 0)) return;
5084
5691
  var startedAt = Date.now();
5692
+ var budgetLeftMs = mediaStartBudgetStartedAt > 0 ? MEDIA_START_TOTAL_BUDGET_MS - (startedAt - mediaStartBudgetStartedAt) : MEDIA_START_TIMEOUT_MS;
5693
+ var timeoutMs = Math.max(1e3, Math.min(MEDIA_START_TIMEOUT_MS, budgetLeftMs));
5085
5694
  mediaStartTimerId = setTimeout(function() {
5086
5695
  mediaStartTimerId = void 0;
5087
5696
  if (!adPlaying || trackingFired.impression) return;
5088
- console.warn("[HlsAdPlayer] Ad media did not start playing within ".concat(MEDIA_START_TIMEOUT_MS, "ms"));
5697
+ console.warn("[HlsAdPlayer] Ad media did not start playing within ".concat(timeoutMs, "ms"));
5089
5698
  logFunnel("play_resolved_but_never_started", {
5090
- timeoutMs: MEDIA_START_TIMEOUT_MS,
5699
+ timeoutMs: timeoutMs,
5091
5700
  elapsedMs: Date.now() - startedAt,
5092
5701
  readyState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.readyState,
5093
5702
  networkState: adVideoElement === null || adVideoElement === void 0 ? void 0 : adVideoElement.networkState,
@@ -5096,7 +5705,7 @@ function createHlsAdPlayer(contentVideo, options) {
5096
5705
  vastErrorCode: VAST_ERROR_MEDIA_TIMEOUT
5097
5706
  });
5098
5707
  recoverFromAdFailure(VAST_ERROR_MEDIA_TIMEOUT);
5099
- }, MEDIA_START_TIMEOUT_MS);
5708
+ }, timeoutMs);
5100
5709
  }
5101
5710
  function resetVideoElementForNextSource() {
5102
5711
  clearStallWatchdog();
@@ -5111,6 +5720,20 @@ function createHlsAdPlayer(contentVideo, options) {
5111
5720
  function tryNextMediaCandidate() {
5112
5721
  if (!currentAd || trackingFired.impression) return false;
5113
5722
  if (mediaCandidateIndex >= mediaCandidates.length - 1) return false;
5723
+ if (mediaCandidateIndex + 1 >= MAX_MEDIA_START_ATTEMPTS) {
5724
+ logFunnel("media_fallback_capped", {
5725
+ reason: "max_attempts",
5726
+ attempts: mediaCandidateIndex + 1
5727
+ });
5728
+ return false;
5729
+ }
5730
+ if (mediaStartBudgetStartedAt > 0 && Date.now() - mediaStartBudgetStartedAt >= MEDIA_START_TOTAL_BUDGET_MS) {
5731
+ logFunnel("media_fallback_capped", {
5732
+ reason: "time_budget",
5733
+ elapsedMs: Date.now() - mediaStartBudgetStartedAt
5734
+ });
5735
+ return false;
5736
+ }
5114
5737
  var failedUrl = currentAdMediaFile === null || currentAdMediaFile === void 0 ? void 0 : currentAdMediaFile.url;
5115
5738
  mediaCandidateIndex++;
5116
5739
  var next = mediaCandidates[mediaCandidateIndex];
@@ -5144,6 +5767,7 @@ function createHlsAdPlayer(contentVideo, options) {
5144
5767
  }
5145
5768
  mediaCandidates = rankMediaCandidates(currentAd.mediaFiles);
5146
5769
  mediaCandidateIndex = 0;
5770
+ mediaStartBudgetStartedAt = Date.now();
5147
5771
  var mediaFile = mediaCandidates[0];
5148
5772
  if (!mediaFile) {
5149
5773
  logFunnel("media_unsupported", {
@@ -6083,6 +6707,7 @@ function getOrCreateNonceLoader(allowStorage) {
6083
6707
  }
6084
6708
  function createPalNonceManager() {
6085
6709
  var currentNonce = "";
6710
+ var currentNonceCreatedAt = 0;
6086
6711
  var currentNonceManager;
6087
6712
  var pendingNonce;
6088
6713
  return {
@@ -6099,6 +6724,9 @@ function createPalNonceManager() {
6099
6724
  getCurrentNonce: function getCurrentNonce() {
6100
6725
  return currentNonce;
6101
6726
  },
6727
+ getNonceAgeMs: function getNonceAgeMs() {
6728
+ return currentNonce ? Date.now() - currentNonceCreatedAt : void 0;
6729
+ },
6102
6730
  waitForNonce: function waitForNonce(maxWaitMs) {
6103
6731
  if (currentNonce) return Promise.resolve(currentNonce);
6104
6732
  var pending = pendingNonce;
@@ -6151,13 +6779,14 @@ function createPalNonceManager() {
6151
6779
  },
6152
6780
  reset: function reset() {
6153
6781
  currentNonce = "";
6782
+ currentNonceCreatedAt = 0;
6154
6783
  currentNonceManager = void 0;
6155
6784
  pendingNonce = void 0;
6156
6785
  }
6157
6786
  };
6158
6787
  function generate(options) {
6159
6788
  return _async_to_generator(function() {
6160
- var _options_allowStorage, _options_adWillAutoPlay, _options_adWillPlayMuted, _options_playerVolume, _options_continuousPlayback, loader, goog, request, manager, error;
6789
+ var _options_allowStorage, _options_adWillAutoPlay, _options_adWillPlayMuted, _options_playerVolume, _options_continuousPlayback, _options_iconsSupported, _options_supportedApiFrameworks, loader, goog, request, apiFrameworks, manager, error;
6161
6790
  return _ts_generator(this, function(_state) {
6162
6791
  switch(_state.label){
6163
6792
  case 0:
@@ -6181,10 +6810,11 @@ function createPalNonceManager() {
6181
6810
  request.playerVolume = (_options_playerVolume = options.playerVolume) !== null && _options_playerVolume !== void 0 ? _options_playerVolume : request.adWillPlayMuted ? 0 : 1;
6182
6811
  request.continuousPlayback = (_options_continuousPlayback = options.continuousPlayback) !== null && _options_continuousPlayback !== void 0 ? _options_continuousPlayback : true;
6183
6812
  request.descriptionUrl = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
6184
- request.iconsSupported = true;
6813
+ request.iconsSupported = (_options_iconsSupported = options.iconsSupported) !== null && _options_iconsSupported !== void 0 ? _options_iconsSupported : false;
6185
6814
  request.playerType = "StormcloudVideoPlayer";
6186
6815
  request.playerVersion = "1.0";
6187
- request.supportedApiFrameworks = "2,7,9";
6816
+ apiFrameworks = ((_options_supportedApiFrameworks = options.supportedApiFrameworks) !== null && _options_supportedApiFrameworks !== void 0 ? _options_supportedApiFrameworks : "").trim();
6817
+ if (apiFrameworks) request.supportedApiFrameworks = apiFrameworks;
6188
6818
  request.url = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
6189
6819
  request.videoWidth = options.videoWidth || 640;
6190
6820
  request.videoHeight = options.videoHeight || 480;
@@ -6214,6 +6844,7 @@ function createPalNonceManager() {
6214
6844
  manager = _state.sent();
6215
6845
  currentNonceManager = manager;
6216
6846
  currentNonce = manager.getNonce();
6847
+ currentNonceCreatedAt = Date.now();
6217
6848
  console.log("[PAL] Nonce generated successfully");
6218
6849
  return [
6219
6850
  2,
@@ -6237,6 +6868,458 @@ function createPalNonceManager() {
6237
6868
  })();
6238
6869
  }
6239
6870
  }
6871
+ // src/utils/deviceInfo.ts
6872
+ var CATEGORY_CODES = {
6873
+ "LG TV": "lg_tv",
6874
+ "LG Set-Top Box": "lg_stb",
6875
+ "Samsung TV": "samsung_tv",
6876
+ Other: "other"
6877
+ };
6878
+ var DEVICE_CATEGORIES = [
6879
+ "LG TV",
6880
+ "LG Set-Top Box",
6881
+ "Samsung TV",
6882
+ "Other"
6883
+ ];
6884
+ var hostDeviceInfo;
6885
+ var lgDeviceInfo;
6886
+ var platformCache;
6887
+ var primePromise;
6888
+ function cleanString(value) {
6889
+ var maxLength = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 128;
6890
+ if (typeof value !== "string") return void 0;
6891
+ var t = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
6892
+ if (!t || /^(unknown|null|undefined|none|n\/a|-|0)$/i.test(t)) return void 0;
6893
+ return t.length > maxLength ? t.slice(0, maxLength) : t;
6894
+ }
6895
+ function safeCall2(fn, thisArg) {
6896
+ if (typeof fn !== "function") return void 0;
6897
+ try {
6898
+ return fn.call(thisArg);
6899
+ } catch (unused) {
6900
+ return void 0;
6901
+ }
6902
+ }
6903
+ function userAgent() {
6904
+ return typeof navigator !== "undefined" ? navigator.userAgent || "" : "";
6905
+ }
6906
+ function bridgeSources2() {
6907
+ if (typeof window === "undefined") return [];
6908
+ var w = window;
6909
+ return [
6910
+ w.__STORMCLOUD_CTV__,
6911
+ w.__STORMCLOUD_CTV_AD_INFO__,
6912
+ w.stormcloudCtv
6913
+ ].filter(Boolean);
6914
+ }
6915
+ function readBridge(keys) {
6916
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6917
+ try {
6918
+ for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6919
+ var source = _step.value;
6920
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6921
+ try {
6922
+ for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
6923
+ var key = _step1.value;
6924
+ var value = void 0;
6925
+ try {
6926
+ value = source === null || source === void 0 ? void 0 : source[key];
6927
+ if (typeof value === "function") value = value.call(source);
6928
+ } catch (unused) {
6929
+ value = void 0;
6930
+ }
6931
+ var clean = cleanString(value);
6932
+ if (clean) return clean;
6933
+ }
6934
+ } catch (err) {
6935
+ _didIteratorError1 = true;
6936
+ _iteratorError1 = err;
6937
+ } finally{
6938
+ try {
6939
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
6940
+ _iterator1.return();
6941
+ }
6942
+ } finally{
6943
+ if (_didIteratorError1) {
6944
+ throw _iteratorError1;
6945
+ }
6946
+ }
6947
+ }
6948
+ }
6949
+ } catch (err) {
6950
+ _didIteratorError = true;
6951
+ _iteratorError = err;
6952
+ } finally{
6953
+ try {
6954
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
6955
+ _iterator.return();
6956
+ }
6957
+ } finally{
6958
+ if (_didIteratorError) {
6959
+ throw _iteratorError;
6960
+ }
6961
+ }
6962
+ }
6963
+ return void 0;
6964
+ }
6965
+ function makeForCategory(category) {
6966
+ if (category === "LG TV" || category === "LG Set-Top Box") return "LG";
6967
+ if (category === "Samsung TV") return "Samsung";
6968
+ return void 0;
6969
+ }
6970
+ function normalizeCategory(value) {
6971
+ var v = cleanString(value);
6972
+ if (!v) return void 0;
6973
+ var exact = DEVICE_CATEGORIES.find(function(c) {
6974
+ return c.toLowerCase() === v.toLowerCase();
6975
+ });
6976
+ if (exact) return exact;
6977
+ var code = v.toLowerCase().replace(/[\s-]+/g, "_");
6978
+ var byCode = Object.keys(CATEGORY_CODES).find(function(c) {
6979
+ return CATEGORY_CODES[c] === code;
6980
+ });
6981
+ return byCode;
6982
+ }
6983
+ function parseUserAgentDeviceInfo(ua) {
6984
+ var sources = [];
6985
+ var out = {
6986
+ platform: "other",
6987
+ sources: sources
6988
+ };
6989
+ var chrome = ua.match(/(?:Chrome|PCBR)\/(\d+)\./) || ua.match(/\s(\d{2,3})\.\d+\.\d+\.\d+\/[\d.]+\s+TV\b/);
6990
+ if (chrome && chrome[1]) out.browserMajorVersion = parseInt(chrome[1], 10);
6991
+ if (/Web0S|webOS/i.test(ua)) {
6992
+ out.platform = "webos";
6993
+ var lg = ua.match(/LGE\s*;\s*([A-Za-z0-9][A-Za-z0-9._-]*)\s*;\s*(\d{2}\.\d{2}\.\d{2})/);
6994
+ if (lg && lg[1] && lg[2]) {
6995
+ out.model = lg[1];
6996
+ out.firmware = lg[2];
6997
+ sources.push("user_agent");
6998
+ }
6999
+ } else if (/Tizen/i.test(ua)) {
7000
+ out.platform = "tizen";
7001
+ var tizen = ua.match(/Tizen\s+(\d+(?:\.\d+)*)/i);
7002
+ if (tizen && tizen[1]) {
7003
+ out.osVersion = "Tizen ".concat(tizen[1]);
7004
+ sources.push("user_agent");
7005
+ }
7006
+ }
7007
+ return out;
7008
+ }
7009
+ function readSamsungProductInfo() {
7010
+ var _cleanString;
7011
+ var _window_webapis;
7012
+ if (typeof window === "undefined") return void 0;
7013
+ var productinfo = (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.productinfo;
7014
+ if (!productinfo) return void 0;
7015
+ var model = (_cleanString = cleanString(safeCall2(productinfo.getRealModel, productinfo), 40)) !== null && _cleanString !== void 0 ? _cleanString : cleanString(safeCall2(productinfo.getModel, productinfo), 40);
7016
+ var firmware = cleanString(safeCall2(productinfo.getFirmware, productinfo), 64);
7017
+ var duid = cleanString(safeCall2(productinfo.getDuid, productinfo), 128);
7018
+ if (!model && !firmware && !duid) return void 0;
7019
+ return _object_spread({}, model ? {
7020
+ model: model
7021
+ } : {}, firmware ? {
7022
+ firmware: firmware
7023
+ } : {}, duid ? {
7024
+ internalDeviceId: duid,
7025
+ internalDeviceIdSource: "samsung_duid"
7026
+ } : {});
7027
+ }
7028
+ function readLgDeviceInfo(timeoutMs) {
7029
+ var webOS = typeof window !== "undefined" ? window.webOS : void 0;
7030
+ if (lgDeviceInfo || !webOS || typeof webOS.deviceInfo !== "function") return Promise.resolve();
7031
+ return new Promise(function(resolve) {
7032
+ var settled = false;
7033
+ var finish = function finish() {
7034
+ if (settled) return;
7035
+ settled = true;
7036
+ clearTimeout(timer);
7037
+ resolve();
7038
+ };
7039
+ var timer = setTimeout(finish, Math.max(0, timeoutMs));
7040
+ try {
7041
+ webOS.deviceInfo(function(info) {
7042
+ var model = cleanString(info === null || info === void 0 ? void 0 : info.modelName, 40);
7043
+ var firmware = cleanString(info === null || info === void 0 ? void 0 : info.version, 64);
7044
+ var sdkVersion = cleanString(info === null || info === void 0 ? void 0 : info.sdkVersion, 32);
7045
+ lgDeviceInfo = _object_spread({}, model ? {
7046
+ model: model
7047
+ } : {}, firmware ? {
7048
+ firmware: firmware
7049
+ } : {}, sdkVersion ? {
7050
+ sdkVersion: sdkVersion
7051
+ } : {});
7052
+ finish();
7053
+ });
7054
+ } catch (unused) {
7055
+ finish();
7056
+ }
7057
+ });
7058
+ }
7059
+ function computePlatformInfo() {
7060
+ var info = parseUserAgentDeviceInfo(userAgent());
7061
+ var sources = _to_consumable_array(info.sources);
7062
+ var samsung = readSamsungProductInfo();
7063
+ if (samsung) {
7064
+ info.platform = "tizen";
7065
+ if (samsung.model) info.model = samsung.model;
7066
+ if (samsung.firmware) info.firmware = samsung.firmware;
7067
+ if (samsung.internalDeviceId) {
7068
+ info.internalDeviceId = samsung.internalDeviceId;
7069
+ info.internalDeviceIdSource = "samsung_duid";
7070
+ }
7071
+ sources.push("samsung_productinfo");
7072
+ }
7073
+ if (lgDeviceInfo) {
7074
+ info.platform = "webos";
7075
+ if (!info.model && lgDeviceInfo.model) info.model = lgDeviceInfo.model;
7076
+ if (!info.firmware && lgDeviceInfo.firmware) info.firmware = lgDeviceInfo.firmware;
7077
+ if (lgDeviceInfo.sdkVersion) info.osVersion = "webOS TV ".concat(lgDeviceInfo.sdkVersion);
7078
+ sources.push("lg_deviceinfo");
7079
+ }
7080
+ var lgUdid = readCachedLgUdid();
7081
+ if ((lgUdid === null || lgUdid === void 0 ? void 0 : lgUdid.deviceId) && !info.internalDeviceId) {
7082
+ info.internalDeviceId = lgUdid.deviceId;
7083
+ info.internalDeviceIdSource = "lg_udid";
7084
+ sources.push("lg_udid");
7085
+ }
7086
+ info.sources = sources;
7087
+ return info;
7088
+ }
7089
+ function categorize(platform, model) {
7090
+ if (platform === "tizen") return "Samsung TV";
7091
+ if (platform === "webos") {
7092
+ var ua = userAgent();
7093
+ if (model && /^STB-/i.test(model) || /\bSTB-\d{4}|LGSTB/i.test(ua)) return "LG Set-Top Box";
7094
+ return "LG TV";
7095
+ }
7096
+ return "Other";
7097
+ }
7098
+ function setHostDeviceInfo(info) {
7099
+ hostDeviceInfo = info ? _object_spread({}, info) : void 0;
7100
+ }
7101
+ function primeDeviceInfo() {
7102
+ var timeoutMs = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1500;
7103
+ if (!primePromise) {
7104
+ primePromise = Promise.all([
7105
+ readLgDeviceInfo(timeoutMs),
7106
+ primeLgUdid(timeoutMs)
7107
+ ]).catch(function() {
7108
+ return void 0;
7109
+ }).then(function() {
7110
+ platformCache = computePlatformInfo();
7111
+ return getDeviceInfo();
7112
+ });
7113
+ }
7114
+ return primePromise;
7115
+ }
7116
+ function getDeviceInfo() {
7117
+ var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory, _ref3, _cleanString4, _cleanString5;
7118
+ var platform = platformCache !== null && platformCache !== void 0 ? platformCache : computePlatformInfo();
7119
+ if (primePromise && !platformCache) {} else {
7120
+ platformCache = platform;
7121
+ }
7122
+ var host = hostDeviceInfo !== null && hostDeviceInfo !== void 0 ? hostDeviceInfo : {};
7123
+ var bridge = {
7124
+ terminalId: readBridge([
7125
+ "terminalId",
7126
+ "terminal_id"
7127
+ ]),
7128
+ internalDeviceId: readBridge([
7129
+ "internalDeviceId",
7130
+ "internal_device_id"
7131
+ ]),
7132
+ model: readBridge([
7133
+ "deviceModel"
7134
+ ]),
7135
+ firmware: readBridge([
7136
+ "firmwareVersion"
7137
+ ]),
7138
+ category: normalizeCategory(readBridge([
7139
+ "deviceCategory"
7140
+ ])),
7141
+ make: readBridge([
7142
+ "deviceMake"
7143
+ ]),
7144
+ hardwareVersion: readBridge([
7145
+ "deviceHardwareVersion",
7146
+ "hardwareVersion"
7147
+ ])
7148
+ };
7149
+ var terminalId = (_cleanString = cleanString(host.terminalId)) !== null && _cleanString !== void 0 ? _cleanString : bridge.terminalId;
7150
+ var hostInternalId = (_cleanString1 = cleanString(host.internalDeviceId)) !== null && _cleanString1 !== void 0 ? _cleanString1 : bridge.internalDeviceId;
7151
+ var model = (_ref = (_cleanString2 = cleanString(host.model, 40)) !== null && _cleanString2 !== void 0 ? _cleanString2 : bridge.model) !== null && _ref !== void 0 ? _ref : platform.model;
7152
+ var firmware = (_ref1 = (_cleanString3 = cleanString(host.firmware, 64)) !== null && _cleanString3 !== void 0 ? _cleanString3 : bridge.firmware) !== null && _ref1 !== void 0 ? _ref1 : platform.firmware;
7153
+ var category = (_ref2 = (_normalizeCategory = normalizeCategory(host.category)) !== null && _normalizeCategory !== void 0 ? _normalizeCategory : bridge.category) !== null && _ref2 !== void 0 ? _ref2 : categorize(platform.platform, model);
7154
+ var sources = _to_consumable_array(platform.sources);
7155
+ var bridgeValues = [
7156
+ bridge.terminalId,
7157
+ bridge.internalDeviceId,
7158
+ bridge.model,
7159
+ bridge.firmware,
7160
+ bridge.category,
7161
+ bridge.make,
7162
+ bridge.hardwareVersion
7163
+ ];
7164
+ if (bridgeValues.some(function(v) {
7165
+ return v !== void 0;
7166
+ })) sources.unshift("bridge");
7167
+ if (hostDeviceInfo) sources.unshift("host");
7168
+ var internalDeviceId = hostInternalId !== null && hostInternalId !== void 0 ? hostInternalId : platform.internalDeviceId;
7169
+ var internalDeviceIdSource = hostInternalId ? "host" : platform.internalDeviceIdSource;
7170
+ var make = (_ref3 = (_cleanString4 = cleanString(host.make, 40)) !== null && _cleanString4 !== void 0 ? _cleanString4 : bridge.make) !== null && _ref3 !== void 0 ? _ref3 : makeForCategory(category);
7171
+ var hardwareVersion = (_cleanString5 = cleanString(host.hardwareVersion, 40)) !== null && _cleanString5 !== void 0 ? _cleanString5 : bridge.hardwareVersion;
7172
+ var sonifiModel = model && category === "Samsung TV" && !/^SAMSUNG-IPTV-/i.test(model) ? "SAMSUNG-IPTV-".concat(model) : model;
7173
+ return _object_spread_props(_object_spread({
7174
+ category: category,
7175
+ categoryCode: CATEGORY_CODES[category]
7176
+ }, make ? {
7177
+ make: make
7178
+ } : {}, model ? {
7179
+ model: model
7180
+ } : {}, hardwareVersion ? {
7181
+ hardwareVersion: hardwareVersion
7182
+ } : {}, sonifiModel ? {
7183
+ sonifiModel: sonifiModel
7184
+ } : {}, firmware ? {
7185
+ firmware: firmware
7186
+ } : {}, platform.osVersion ? {
7187
+ osVersion: platform.osVersion
7188
+ } : {}, platform.browserMajorVersion != null ? {
7189
+ browserMajorVersion: platform.browserMajorVersion
7190
+ } : {}, internalDeviceId ? {
7191
+ internalDeviceId: internalDeviceId
7192
+ } : {}, internalDeviceId && internalDeviceIdSource ? {
7193
+ internalDeviceIdSource: internalDeviceIdSource
7194
+ } : {}, terminalId ? {
7195
+ terminalId: terminalId
7196
+ } : {}), {
7197
+ sources: sources
7198
+ });
7199
+ }
7200
+ var DEVICE_KEY_VALUE_KEYS = {
7201
+ category: "sc_dev",
7202
+ model: "sc_model",
7203
+ firmware: "sc_fw"
7204
+ };
7205
+ function sanitizeKeyValue(value) {
7206
+ if (typeof value !== "string") return void 0;
7207
+ var v = value.trim().replace(/[^A-Za-z0-9._-]+/g, "_").replace(/^_+|_+$/g, "");
7208
+ return v ? v.slice(0, 40) : void 0;
7209
+ }
7210
+ function deviceKeyValuePairs(info) {
7211
+ var pairs = [
7212
+ [
7213
+ DEVICE_KEY_VALUE_KEYS.category,
7214
+ info.categoryCode
7215
+ ]
7216
+ ];
7217
+ var model = sanitizeKeyValue(info.model);
7218
+ var firmware = sanitizeKeyValue(info.firmware);
7219
+ if (model) pairs.push([
7220
+ DEVICE_KEY_VALUE_KEYS.model,
7221
+ model
7222
+ ]);
7223
+ if (firmware) pairs.push([
7224
+ DEVICE_KEY_VALUE_KEYS.firmware,
7225
+ firmware
7226
+ ]);
7227
+ return pairs;
7228
+ }
7229
+ function applyDeviceKeyValues(url, info) {
7230
+ try {
7231
+ var parsed = new URL(url);
7232
+ var pairs = deviceKeyValuePairs(info);
7233
+ var ours = new Set(pairs.map(function(param) {
7234
+ var _param = _sliced_to_array(param, 1), k = _param[0];
7235
+ return k;
7236
+ }));
7237
+ var existing = (parsed.searchParams.get("cust_params") || "").split("&").filter(function(p) {
7238
+ var _p_split_;
7239
+ return p !== "" && !ours.has((_p_split_ = p.split("=")[0]) !== null && _p_split_ !== void 0 ? _p_split_ : "");
7240
+ });
7241
+ var merged = existing.concat(pairs.map(function(param) {
7242
+ var _param = _sliced_to_array(param, 2), k = _param[0], v = _param[1];
7243
+ return "".concat(k, "=").concat(v);
7244
+ })).join("&");
7245
+ parsed.searchParams.set("cust_params", merged);
7246
+ return parsed.toString();
7247
+ } catch (unused) {
7248
+ return url;
7249
+ }
7250
+ }
7251
+ function deviceInfoAnalyticsFields(info) {
7252
+ return _object_spread({
7253
+ device_category: info.category
7254
+ }, info.model ? {
7255
+ device_model: info.model
7256
+ } : {}, info.sonifiModel ? {
7257
+ sonifi_model: info.sonifiModel
7258
+ } : {}, info.firmware ? {
7259
+ firmware_version: info.firmware
7260
+ } : {}, info.osVersion ? {
7261
+ os_version: info.osVersion
7262
+ } : {}, info.browserMajorVersion != null ? {
7263
+ browser_major_version: info.browserMajorVersion
7264
+ } : {}, info.internalDeviceId ? {
7265
+ internal_device_id: info.internalDeviceId
7266
+ } : {}, info.internalDeviceIdSource ? {
7267
+ internal_device_id_source: info.internalDeviceIdSource
7268
+ } : {}, info.terminalId ? {
7269
+ terminal_id: info.terminalId
7270
+ } : {});
7271
+ }
7272
+ // src/utils/screenActivity.ts
7273
+ var hostStandby = false;
7274
+ function setHostStandby(standby) {
7275
+ hostStandby = !!standby;
7276
+ }
7277
+ function toBoolean(value) {
7278
+ if (typeof value === "boolean") return value;
7279
+ if (typeof value === "number") return value === 1;
7280
+ if (typeof value === "string") {
7281
+ var v = value.trim().toLowerCase();
7282
+ if (v === "true" || v === "1" || v === "yes") return true;
7283
+ if (v === "false" || v === "0" || v === "no") return false;
7284
+ }
7285
+ return void 0;
7286
+ }
7287
+ function bridgeSaysStandby() {
7288
+ if (typeof window === "undefined") return false;
7289
+ var w = window;
7290
+ for(var _i = 0, _iter = [
7291
+ w.__STORMCLOUD_CTV__,
7292
+ w.__STORMCLOUD_CTV_AD_INFO__,
7293
+ w.stormcloudCtv
7294
+ ]; _i < _iter.length; _i++){
7295
+ var source = _iter[_i];
7296
+ if (!source) continue;
7297
+ for(var _i1 = 0, _iter1 = [
7298
+ "standby",
7299
+ "isStandby",
7300
+ "screenOff"
7301
+ ]; _i1 < _iter1.length; _i1++){
7302
+ var key = _iter1[_i1];
7303
+ var value = void 0;
7304
+ try {
7305
+ value = source[key];
7306
+ if (typeof value === "function") value = value.call(source);
7307
+ } catch (unused) {
7308
+ value = void 0;
7309
+ }
7310
+ if (toBoolean(value) === true) return true;
7311
+ }
7312
+ }
7313
+ return false;
7314
+ }
7315
+ function getScreenInactiveReason() {
7316
+ if (hostStandby) return "host_standby";
7317
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") {
7318
+ return "document_hidden";
7319
+ }
7320
+ if (bridgeSaysStandby()) return "bridge_standby";
7321
+ return void 0;
7322
+ }
6240
7323
  // src/utils/trackingIngest.ts
6241
7324
  var DEFAULT_TRACKING_INGEST_CONFIG = {
6242
7325
  enabled: true,
@@ -6340,6 +7423,9 @@ function buildAnalyticsContext(config) {
6340
7423
  if (config.isLiveStream !== void 0) {
6341
7424
  context.inputStreamType = config.isLiveStream ? "live" : "vod";
6342
7425
  }
7426
+ if (config.sendDeviceInfoToAnalytics) {
7427
+ context.includeDeviceInfo = true;
7428
+ }
6343
7429
  return context;
6344
7430
  }
6345
7431
  function getClientInfo() {
@@ -6635,7 +7721,7 @@ function buildPlayerMetricEvent() {
6635
7721
  capture_at: captureAt
6636
7722
  }, context.inputStreamType ? {
6637
7723
  input_stream_type: context.inputStreamType
6638
- } : {})
7724
+ } : {}, context.includeDeviceInfo ? deviceInfoAnalyticsFields(getDeviceInfo()) : {})
6639
7725
  ];
6640
7726
  }
6641
7727
  });
@@ -8190,6 +9276,13 @@ var Scte35CueManager = /*#__PURE__*/ function() {
8190
9276
  return Scte35CueManager;
8191
9277
  }();
8192
9278
  // src/player/AdConfigManager.ts
9279
+ function isGamAdUrl(rawUrl) {
9280
+ try {
9281
+ return GAM_AD_HOSTS.has(new URL(rawUrl).hostname);
9282
+ } catch (unused) {
9283
+ return false;
9284
+ }
9285
+ }
8193
9286
  function withDeferredPodParams(rawUrl, deferNonce) {
8194
9287
  try {
8195
9288
  var url = new URL(rawUrl);
@@ -8207,11 +9300,15 @@ function withDeferredPodParams(rawUrl, deferNonce) {
8207
9300
  }
8208
9301
  var AdConfigManager = /*#__PURE__*/ function() {
8209
9302
  function AdConfigManager(config, video) {
9303
+ var _this = this;
8210
9304
  _class_call_check(this, AdConfigManager);
8211
9305
  this.vmapBreaks = [];
8212
9306
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
8213
9307
  this.streamCorrelator = generateCorrelator();
8214
9308
  this.consentSignals = {};
9309
+ this.isLiveStream = function() {
9310
+ return !!_this.config.isLiveStream;
9311
+ };
8215
9312
  this.podCounter = 0;
8216
9313
  this.podAssignedByPrefetch = false;
8217
9314
  this.lastHeartbeatTime = 0;
@@ -8662,9 +9759,22 @@ var AdConfigManager = /*#__PURE__*/ function() {
8662
9759
  {
8663
9760
  key: "generatePodVastUrl",
8664
9761
  value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
9762
+ var _content_contentDurationSeconds;
8665
9763
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
8666
- var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
8667
- var macroContext = _object_spread_props(_object_spread({
9764
+ var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
9765
+ fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
9766
+ sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
9767
+ });
9768
+ var content = resolveContentMetadata(this.config);
9769
+ var isLive = this.isLiveStream();
9770
+ var device = getDeviceInfo();
9771
+ var playerSize = resolvePlayerSize(this.video);
9772
+ var videoDuration = this.video.duration;
9773
+ var contentDurationSeconds = (_content_contentDurationSeconds = content.contentDurationSeconds) !== null && _content_contentDurationSeconds !== void 0 ? _content_contentDurationSeconds : !isLive && Number.isFinite(videoDuration) && videoDuration > 0 ? Math.round(videoDuration) : void 0;
9774
+ var userId = resolveUserId(this.config.adUserId);
9775
+ var ipAddress = resolveClientIp(this.config.clientIpAddress);
9776
+ var userAgent2 = typeof navigator !== "undefined" && navigator.userAgent ? navigator.userAgent : void 0;
9777
+ var macroContext = _object_spread(_object_spread_props(_object_spread(_object_spread_props(_object_spread({
8668
9778
  correlator: this.viewCorrelator,
8669
9779
  streamCorrelator: this.streamCorrelator,
8670
9780
  pod: this.podCounter > 0 ? this.podCounter : void 0,
@@ -8678,14 +9788,54 @@ var AdConfigManager = /*#__PURE__*/ function() {
8678
9788
  limitAdTracking: envSignals.limitAdTracking,
8679
9789
  deviceTypeHint: envSignals.deviceTypeHint,
8680
9790
  adTest: this.config.adTest
8681
- }, this.config.programTitle ? {
8682
- programTitle: this.config.programTitle
8683
- } : {}, this.config.channelName ? {
8684
- channelName: this.config.channelName
9791
+ }, content.programTitle ? {
9792
+ programTitle: content.programTitle
9793
+ } : {}, content.channelName ? {
9794
+ channelName: content.channelName
9795
+ } : {}, content.contentNetwork ? {
9796
+ contentNetwork: content.contentNetwork
8685
9797
  } : {}), {
8686
9798
  consent: this.consentSignals,
8687
- palNonce: palNonce.getCurrentNonce() || void 0
8688
- });
9799
+ palNonce: palNonce.getCurrentNonce() || void 0,
9800
+ deviceIdSource: envSignals.deviceIdSource,
9801
+ isLive: isLive
9802
+ }), playerSize.width ? {
9803
+ playerWidth: playerSize.width
9804
+ } : {}, playerSize.height ? {
9805
+ playerHeight: playerSize.height
9806
+ } : {}), {
9807
+ timestamp: String(Date.now())
9808
+ }), device.make ? {
9809
+ deviceMake: device.make
9810
+ } : {}, device.model ? {
9811
+ deviceModel: device.model
9812
+ } : {}, device.hardwareVersion ? {
9813
+ deviceHardwareVersion: device.hardwareVersion
9814
+ } : {}, userAgent2 ? {
9815
+ userAgent: userAgent2
9816
+ } : {}, ipAddress ? {
9817
+ ipAddress: ipAddress
9818
+ } : {}, userId ? {
9819
+ userId: userId
9820
+ } : {}, content.contentType ? {
9821
+ contentType: content.contentType
9822
+ } : {}, content.contentCategory ? {
9823
+ contentCategory: content.contentCategory
9824
+ } : {}, content.contentGenre ? {
9825
+ contentGenre: content.contentGenre
9826
+ } : {}, content.contentLanguage ? {
9827
+ contentLanguage: content.contentLanguage
9828
+ } : {}, contentDurationSeconds != null ? {
9829
+ contentDurationSeconds: contentDurationSeconds
9830
+ } : {}, content.contentSeason ? {
9831
+ contentSeason: content.contentSeason
9832
+ } : {}, content.contentEpisode ? {
9833
+ contentEpisode: content.contentEpisode
9834
+ } : {}, content.contentRating ? {
9835
+ contentRating: content.contentRating
9836
+ } : {}, content.contentId ? {
9837
+ contentId: content.contentId
9838
+ } : {});
8689
9839
  var nonceReady = !!macroContext.palNonce;
8690
9840
  var finalUrl;
8691
9841
  if (hasScvpMacros(baseUrl)) {
@@ -8699,6 +9849,31 @@ var AdConfigManager = /*#__PURE__*/ function() {
8699
9849
  } else {
8700
9850
  finalUrl = withDeferredPodParams(palNonce.injectNonce(ensureVideoAdType(applyVastMacros(baseUrl, macroContext))), !nonceReady);
8701
9851
  }
9852
+ if (isGamAdUrl(finalUrl)) {
9853
+ finalUrl = appendMissingContentParams(finalUrl, content);
9854
+ if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9855
+ finalUrl = applyDeviceKeyValues(finalUrl, device);
9856
+ }
9857
+ }
9858
+ if (this.debug) {
9859
+ var id = envSignals.deviceId;
9860
+ console.log("[AD-IDENTITY]", {
9861
+ source: envSignals.deviceIdSource,
9862
+ idtype: envSignals.deviceIdType,
9863
+ rdidTail: id ? id.slice(-4) : void 0,
9864
+ isLat: envSignals.limitAdTracking,
9865
+ dth: envSignals.deviceTypeHint,
9866
+ sidTail: envSignals.sessionId ? envSignals.sessionId.slice(-4) : void 0,
9867
+ ct_ch: content.channelName,
9868
+ ct_ti: content.programTitle,
9869
+ ct_ne: content.contentNetwork,
9870
+ ifaType: toIabIfaType(envSignals.deviceIdType, envSignals.deviceIdSource),
9871
+ live: isLive,
9872
+ player: playerSize,
9873
+ make: device.make,
9874
+ model: device.model
9875
+ });
9876
+ }
8702
9877
  console.log("[StormcloudVideoPlayer] Prepared optimized-pod request URL (pod=".concat(this.podCounter, "; pmnd/pmxd/pmad resolved at dispatch):"), finalUrl);
8703
9878
  return finalUrl;
8704
9879
  }
@@ -8750,7 +9925,6 @@ var AdConfigManager = /*#__PURE__*/ function() {
8750
9925
  }
8751
9926
  },
8752
9927
  {
8753
- // --- Tracking ---
8754
9928
  key: "initializeTracking",
8755
9929
  value: function initializeTracking() {
8756
9930
  var _this = this;
@@ -8842,7 +10016,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8842
10016
  }
8843
10017
  },
8844
10018
  {
8845
- // --- Ad stop timer ---
8846
10019
  key: "scheduleAdStopCountdown",
8847
10020
  value: function scheduleAdStopCountdown(remainingMs) {
8848
10021
  var _this = this;
@@ -8874,7 +10047,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8874
10047
  }
8875
10048
  },
8876
10049
  {
8877
- // --- Ad start timer ---
8878
10050
  key: "scheduleAdStartIn",
8879
10051
  value: function scheduleAdStartIn(delayMs) {
8880
10052
  var _this = this;
@@ -8902,7 +10074,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8902
10074
  }
8903
10075
  },
8904
10076
  {
8905
- // --- PTS drift ---
8906
10077
  key: "updatePtsDrift",
8907
10078
  value: function updatePtsDrift(ptsSecondsSample) {
8908
10079
  var sampleMs = (this.video.currentTime - ptsSecondsSample) * 1e3;
@@ -8928,7 +10099,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8928
10099
  }
8929
10100
  },
8930
10101
  {
8931
- // --- Duration boundary ---
8932
10102
  key: "beginBreakTiming",
8933
10103
  value: function beginBreakTiming(startWallClockMs) {
8934
10104
  this.currentAdBreakStartWallClockMs = startWallClockMs;
@@ -8976,7 +10146,6 @@ var AdTimingService = /*#__PURE__*/ function() {
8976
10146
  }
8977
10147
  },
8978
10148
  {
8979
- // --- Duration budget ---
8980
10149
  key: "getWallClockRemainingAdMs",
8981
10150
  value: function getWallClockRemainingAdMs() {
8982
10151
  var endWallClockMs = this.getAdBreakEndWallClockMs();
@@ -9125,7 +10294,6 @@ var AdTimingService = /*#__PURE__*/ function() {
9125
10294
  }
9126
10295
  },
9127
10296
  {
9128
- // --- Circuit breaker ---
9129
10297
  key: "isTemporaryAdError",
9130
10298
  value: function isTemporaryAdError(error) {
9131
10299
  var _error_message;
@@ -9259,7 +10427,6 @@ var AdTimingService = /*#__PURE__*/ function() {
9259
10427
  }
9260
10428
  },
9261
10429
  {
9262
- // --- Watchdog ---
9263
10430
  key: "startAdRequestWatchdog",
9264
10431
  value: function startAdRequestWatchdog(token) {
9265
10432
  var _this = this;
@@ -9304,7 +10471,6 @@ var AdTimingService = /*#__PURE__*/ function() {
9304
10471
  }
9305
10472
  },
9306
10473
  {
9307
- // --- Failsafe ---
9308
10474
  key: "startAdFailsafeTimer",
9309
10475
  value: function startAdFailsafeTimer(token) {
9310
10476
  var _this = this;
@@ -9366,7 +10532,6 @@ var AdTimingService = /*#__PURE__*/ function() {
9366
10532
  }
9367
10533
  },
9368
10534
  {
9369
- // --- Reset for ad break end ---
9370
10535
  key: "resetForBreakEnd",
9371
10536
  value: function resetForBreakEnd() {
9372
10537
  this.clearAdStopTimer();
@@ -9565,7 +10730,7 @@ var HlsEngine = /*#__PURE__*/ function() {
9565
10730
  adBehavior: adBehavior
9566
10731
  });
9567
10732
  }
9568
- if (!this.config.autoplay) return [
10733
+ if (!(this.config.autoplay && !this.callbacks.shouldHoldContentForAds())) return [
9569
10734
  3,
9570
10735
  2
9571
10736
  ];
@@ -9756,6 +10921,12 @@ var HlsEngine = /*#__PURE__*/ function() {
9756
10921
  2
9757
10922
  ];
9758
10923
  this.hasInitialBufferCompleted = true;
10924
+ if (this.shouldAutoplayAfterBuffering && this.callbacks.shouldHoldContentForAds()) {
10925
+ this.shouldAutoplayAfterBuffering = false;
10926
+ if (this.debug) {
10927
+ console.log("[StormcloudVideoPlayer] Buffer ready during an ad break; content stays paused until the break ends");
10928
+ }
10929
+ }
9759
10930
  if (!this.shouldAutoplayAfterBuffering) return [
9760
10931
  3,
9761
10932
  2
@@ -10413,9 +11584,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10413
11584
  }
10414
11585
  },
10415
11586
  {
10416
- // ───────────────────────────────────────────────────────────────
10417
- // IMA event listeners
10418
- // ───────────────────────────────────────────────────────────────
10419
11587
  key: "nextAdRequestUrl",
10420
11588
  value: function nextAdRequestUrl(baseVastUrl) {
10421
11589
  return this.host.generatePodVastUrl(baseVastUrl);
@@ -10651,9 +11819,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10651
11819
  }
10652
11820
  },
10653
11821
  {
10654
- // ───────────────────────────────────────────────────────────────
10655
- // Ad break start
10656
- // ───────────────────────────────────────────────────────────────
10657
11822
  key: "isBreakActive",
10658
11823
  value: function isBreakActive() {
10659
11824
  return this.slotState !== "IDLE";
@@ -10681,7 +11846,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10681
11846
  key: "handleAdStart",
10682
11847
  value: function handleAdStart(marker) {
10683
11848
  return _async_to_generator(function() {
10684
- var baseVastUrl, edgeConfigured, adBreakDurationMs, currentMuted, currentVolume, epoch, mode, edgeUrl, outcome, podPlayed;
11849
+ var screenInactiveReason, baseVastUrl, edgeConfigured, adBreakDurationMs, currentMuted, currentVolume, epoch, mode, edgeUrl, outcome, podPlayed;
10685
11850
  return _ts_generator(this, function(_state) {
10686
11851
  switch(_state.label){
10687
11852
  case 0:
@@ -10694,6 +11859,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10694
11859
  2
10695
11860
  ];
10696
11861
  }
11862
+ screenInactiveReason = getScreenInactiveReason();
11863
+ if (screenInactiveReason) {
11864
+ this.logOrchestratorFunnel("break_skipped_screen_inactive", {
11865
+ reason: screenInactiveReason
11866
+ });
11867
+ this.clearPendingAdBreak();
11868
+ return [
11869
+ 2
11870
+ ];
11871
+ }
10697
11872
  baseVastUrl = this.adConfig.apiVastTagUrl;
10698
11873
  edgeConfigured = !!this.host.getEdgePodBaseUrl();
10699
11874
  if (!baseVastUrl && !edgeConfigured) {
@@ -10854,12 +12029,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10854
12029
  },
10855
12030
  {
10856
12031
  key: "startOptimizedPod",
10857
- value: // ───────────────────────────────────────────────────────────────
10858
- // Optimized pod (single multi-ad request)
10859
- // ───────────────────────────────────────────────────────────────
10860
- function startOptimizedPod(baseVastUrl) {
12032
+ value: function startOptimizedPod(baseVastUrl) {
10861
12033
  return _async_to_generator(function() {
10862
- var podUrl, prefetched, epoch, generation, adPlayer, requestToken, requestUrl, _ref, _this_currentVastUrl, _adPlayer_getPodAdCount, finalizeRequestUrl, podCount, error;
12034
+ var podUrl, prefetched, epoch, generation, adPlayer, requestToken, requestUrl, _ref, _this_currentVastUrl, _adPlayer_getPodAdCount, finalizeRequestUrl, podCount, _this_host_config_maxAdBreakExtensionMs, remainingMs, overrunAllowanceMs, maxAdsCap, maxAds, error;
10863
12035
  return _ts_generator(this, function(_state) {
10864
12036
  switch(_state.label){
10865
12037
  case 0:
@@ -10967,6 +12139,26 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10967
12139
  false
10968
12140
  ];
10969
12141
  }
12142
+ if (this.isBreakTimeBounded() && adPlayer.limitPodToBudget) {
12143
+ ;
12144
+ remainingMs = this.timing.getRemainingAdMs();
12145
+ overrunAllowanceMs = Math.max(0, (_this_host_config_maxAdBreakExtensionMs = this.host.config.maxAdBreakExtensionMs) !== null && _this_host_config_maxAdBreakExtensionMs !== void 0 ? _this_host_config_maxAdBreakExtensionMs : 0);
12146
+ maxAdsCap = this.adConfig.resolveAdPodConfig().maxAdsPerBreak;
12147
+ maxAds = maxAdsCap != null ? Math.max(1, maxAdsCap - this.timing.totalAdsInBreak) : Number.MAX_SAFE_INTEGER;
12148
+ if (Number.isFinite(remainingMs)) {
12149
+ podCount = adPlayer.limitPodToBudget(remainingMs + overrunAllowanceMs, maxAds);
12150
+ if (podCount < 1) {
12151
+ if (this.timing.activeAdRequestToken === requestToken) {
12152
+ this.timing.activeAdRequestToken = null;
12153
+ }
12154
+ this.recordRequestFailure(new Error("No GAM ad fits the ".concat(Math.round(remainingMs), "ms left in the break")), podUrl);
12155
+ return [
12156
+ 2,
12157
+ false
12158
+ ];
12159
+ }
12160
+ }
12161
+ }
10970
12162
  this.setSlotState("READY", "vast_ready");
10971
12163
  if (this.debug) {
10972
12164
  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"));
@@ -11036,9 +12228,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11036
12228
  }
11037
12229
  },
11038
12230
  {
11039
- // ───────────────────────────────────────────────────────────────
11040
- // Edge-first pods (live SCTE-35 only, GAM fallback)
11041
- // ───────────────────────────────────────────────────────────────
11042
12231
  key: "resetEdgeStateForBreak",
11043
12232
  value: function resetEdgeStateForBreak() {
11044
12233
  this.edgeExhaustedForBreak = false;
@@ -11256,9 +12445,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11256
12445
  }
11257
12446
  },
11258
12447
  {
11259
- // ───────────────────────────────────────────────────────────────
11260
- // Next-ad scheduling (single flight)
11261
- // ───────────────────────────────────────────────────────────────
11262
12448
  key: "setSlotState",
11263
12449
  value: function setSlotState(next, reason) {
11264
12450
  if (this.slotState === next) return;
@@ -11308,6 +12494,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11308
12494
  {
11309
12495
  key: "getStopRequestingReason",
11310
12496
  value: function getStopRequestingReason(remainingMs) {
12497
+ var screenInactiveReason = getScreenInactiveReason();
12498
+ if (screenInactiveReason) return "screen_inactive:".concat(screenInactiveReason);
11311
12499
  if (this.breakSource === "vmap") {
11312
12500
  if (this.adPodQueue.length === 0) return "vmap_queue_empty";
11313
12501
  } else if (this.breakSource !== "scte35" || !this.followUpBaseVastUrl && !this.canRequestEdge()) {
@@ -11581,9 +12769,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11581
12769
  }
11582
12770
  },
11583
12771
  {
11584
- // ───────────────────────────────────────────────────────────────
11585
- // Per-request diagnostics
11586
- // ───────────────────────────────────────────────────────────────
11587
12772
  key: "recordRequestDiagnostic",
11588
12773
  value: function recordRequestDiagnostic(payload) {
11589
12774
  var requestId = payload.requestId;
@@ -11657,9 +12842,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11657
12842
  }
11658
12843
  },
11659
12844
  {
11660
- // ───────────────────────────────────────────────────────────────
11661
- // Single ad playback
11662
- // ───────────────────────────────────────────────────────────────
11663
12845
  key: "createGamDispatchFinalizer",
11664
12846
  value: function createGamDispatchFinalizer(requestToken) {
11665
12847
  var _this = this;
@@ -12122,9 +13304,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12122
13304
  }
12123
13305
  },
12124
13306
  {
12125
- // ───────────────────────────────────────────────────────────────
12126
- // Ad break completion
12127
- // ───────────────────────────────────────────────────────────────
12128
13307
  key: "logBreakFunnel",
12129
13308
  value: function logBreakFunnel(endReason) {
12130
13309
  var funnel = this.breakFunnel;
@@ -12770,6 +13949,8 @@ var ContentHealthWatchdog = /*#__PURE__*/ function() {
12770
13949
  return ContentHealthWatchdog;
12771
13950
  }();
12772
13951
  // src/player/StormcloudVideoPlayer.ts
13952
+ var DEFAULT_PAL_NONCE_MAX_AGE_MS = 5.5 * 60 * 60 * 1e3;
13953
+ var PAL_NONCE_CHECK_INTERVAL_MS = 5 * 60 * 1e3;
12773
13954
  var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12774
13955
  function StormcloudVideoPlayer(config) {
12775
13956
  var _this = this;
@@ -12780,6 +13961,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12780
13961
  var browserOverrides = getBrowserConfigOverrides();
12781
13962
  this.config = _object_spread({}, browserOverrides, config);
12782
13963
  this.video = config.videoElement;
13964
+ if (this.config.forceSingleDecoderMode != null) {
13965
+ setSingleDecoderOverride(this.config.forceSingleDecoderMode);
13966
+ }
13967
+ if (this.config.adDeviceId) {
13968
+ setHostAdIdentity({
13969
+ deviceId: this.config.adDeviceId,
13970
+ deviceIdType: this.config.adDeviceIdType,
13971
+ limitAdTracking: this.config.adLimitAdTracking
13972
+ });
13973
+ }
13974
+ if (this.config.deviceInfo) {
13975
+ setHostDeviceInfo(this.config.deviceInfo);
13976
+ }
12783
13977
  logBrowserInfo(config.debugAdTiming);
12784
13978
  this.floorLadder = new FloorLadderController();
12785
13979
  this.adPlayer = this.createAdPlayer(false);
@@ -12843,8 +14037,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12843
14037
  },
12844
14038
  hasPendingAdBreak: function hasPendingAdBreak() {
12845
14039
  return _this.adBreak.pendingAdBreak !== null;
14040
+ },
14041
+ shouldHoldContentForAds: function shouldHoldContentForAds() {
14042
+ return !!_this.adBreak && _this.adBreak.inAdBreak && !_this.shouldContinueLiveStreamDuringAds();
12846
14043
  }
12847
14044
  });
14045
+ this.adConfig.isLiveStream = function() {
14046
+ return _this.hlsEngine.isLiveStream;
14047
+ };
12848
14048
  this.adBreak = new AdBreakOrchestrator({
12849
14049
  config: this.config,
12850
14050
  video: this.video,
@@ -13038,10 +14238,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13038
14238
  },
13039
14239
  {
13040
14240
  key: "load",
13041
- value: // ───────────────────────────────────────────────────────────────
13042
- // Lifecycle
13043
- // ───────────────────────────────────────────────────────────────
13044
- function load() {
14241
+ value: function load() {
13045
14242
  return _async_to_generator(function() {
13046
14243
  var _this, error, palDescriptionUrl, continueLiveStreamDuringAds;
13047
14244
  return _ts_generator(this, function(_state) {
@@ -13051,6 +14248,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13051
14248
  if (!this.attached) {
13052
14249
  this.attach();
13053
14250
  }
14251
+ primeDeviceInfo().then(function(info) {
14252
+ if (_this.debug) {
14253
+ console.log("[DEVICE-INFO]", _object_spread_props(_object_spread({}, info), {
14254
+ internalDeviceId: info.internalDeviceId ? "...".concat(info.internalDeviceId.slice(-4)) : void 0
14255
+ }));
14256
+ }
14257
+ }).catch(function() {});
13054
14258
  _state.label = 1;
13055
14259
  case 1:
13056
14260
  _state.trys.push([
@@ -13085,21 +14289,30 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13085
14289
  fetchConsentSignals().catch(function() {
13086
14290
  return {};
13087
14291
  }).then(function(signals) {
13088
- var _this_config_lowLatencyMode;
14292
+ var _this_config_palContinuousPlayback, _this_config_lowLatencyMode, _this_config_palIconsSupported, _this_config_palSupportedApiFrameworks;
13089
14293
  _this.adConfig.consentSignals = signals;
13090
14294
  var muted = _this.video.muted;
13091
- return _this.palNonce.generateNonce(_object_spread({
14295
+ var palSessionId = _this.config.ctvAdRequest ? getOrRotateSessionId(_this.config.sessionIdMaxAgeMs) : void 0;
14296
+ var palOptions = _object_spread({
13092
14297
  videoWidth: _this.video.offsetWidth || _this.video.clientWidth || 640,
13093
14298
  videoHeight: _this.video.offsetHeight || _this.video.clientHeight || 480,
13094
14299
  adWillAutoPlay: !!_this.config.autoplay,
13095
14300
  adWillPlayMuted: muted,
13096
14301
  playerVolume: muted ? 0 : _this.video.volume,
13097
- continuousPlayback: (_this_config_lowLatencyMode = _this.config.lowLatencyMode) !== null && _this_config_lowLatencyMode !== void 0 ? _this_config_lowLatencyMode : false
14302
+ 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,
14303
+ iconsSupported: (_this_config_palIconsSupported = _this.config.palIconsSupported) !== null && _this_config_palIconsSupported !== void 0 ? _this_config_palIconsSupported : false,
14304
+ supportedApiFrameworks: (_this_config_palSupportedApiFrameworks = _this.config.palSupportedApiFrameworks) !== null && _this_config_palSupportedApiFrameworks !== void 0 ? _this_config_palSupportedApiFrameworks : ""
13098
14305
  }, palDescriptionUrl ? {
13099
14306
  descriptionUrl: palDescriptionUrl
13100
14307
  } : {}, signals.storageAllowed != null ? {
13101
14308
  allowStorage: signals.storageAllowed
13102
- } : {}));
14309
+ } : {}, palSessionId ? {
14310
+ sessionId: palSessionId
14311
+ } : {});
14312
+ _this.lastPalOptions = palOptions;
14313
+ _this.palSessionId = palSessionId;
14314
+ _this.startPalNonceRefresh();
14315
+ return _this.palNonce.generateNonce(palOptions);
13103
14316
  }).catch(function() {});
13104
14317
  this.adConfig.initializeTracking();
13105
14318
  if (!this.hlsEngine.shouldUseNativeHls(function() {
@@ -13137,6 +14350,96 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13137
14350
  }).call(this);
13138
14351
  }
13139
14352
  },
14353
+ {
14354
+ key: "startPalNonceRefresh",
14355
+ value: function startPalNonceRefresh() {
14356
+ var _this = this;
14357
+ if (this.palRefreshTimer != null || typeof window === "undefined") return;
14358
+ this.palRefreshTimer = window.setInterval(function() {
14359
+ return _this.refreshPalNonceIfStale();
14360
+ }, PAL_NONCE_CHECK_INTERVAL_MS);
14361
+ }
14362
+ },
14363
+ {
14364
+ key: "refreshPalNonceIfStale",
14365
+ value: function refreshPalNonceIfStale() {
14366
+ var force = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
14367
+ var _this_config_palNonceMaxAgeMs;
14368
+ var options = this.lastPalOptions;
14369
+ if (!options) return;
14370
+ var maxAgeMs = (_this_config_palNonceMaxAgeMs = this.config.palNonceMaxAgeMs) !== null && _this_config_palNonceMaxAgeMs !== void 0 ? _this_config_palNonceMaxAgeMs : DEFAULT_PAL_NONCE_MAX_AGE_MS;
14371
+ var ageMs = this.palNonce.getNonceAgeMs();
14372
+ var sessionId = this.config.ctvAdRequest ? getOrRotateSessionId(this.config.sessionIdMaxAgeMs) : void 0;
14373
+ var sessionChanged = sessionId !== this.palSessionId;
14374
+ var stale = ageMs === void 0 || ageMs >= maxAgeMs;
14375
+ if (!force && !stale && !sessionChanged) return;
14376
+ var next = _object_spread({}, options);
14377
+ if (sessionId) next.sessionId = sessionId;
14378
+ else delete next.sessionId;
14379
+ this.lastPalOptions = next;
14380
+ this.palSessionId = sessionId;
14381
+ if (this.debug) {
14382
+ console.log("[PAL] Regenerating nonce", {
14383
+ force: force,
14384
+ stale: stale,
14385
+ sessionChanged: sessionChanged,
14386
+ ageMs: ageMs
14387
+ });
14388
+ }
14389
+ this.palNonce.generateNonce(next).catch(function() {});
14390
+ }
14391
+ },
14392
+ {
14393
+ key: "setAdIdentity",
14394
+ value: function setAdIdentity(identity) {
14395
+ setHostAdIdentity(identity);
14396
+ this.refreshPalNonceIfStale();
14397
+ }
14398
+ },
14399
+ {
14400
+ key: "resetAdIdentity",
14401
+ value: function resetAdIdentity1() {
14402
+ resetAdIdentity();
14403
+ this.refreshPalNonceIfStale(true);
14404
+ }
14405
+ },
14406
+ {
14407
+ key: "setContentMetadata",
14408
+ value: function setContentMetadata(meta) {
14409
+ applyContentMetadataUpdate(this.config, meta);
14410
+ }
14411
+ },
14412
+ {
14413
+ key: "setRequestSignals",
14414
+ value: function setRequestSignals(signals) {
14415
+ if (signals.userId !== void 0) {
14416
+ if (signals.userId) this.config.adUserId = signals.userId;
14417
+ else delete this.config.adUserId;
14418
+ }
14419
+ if (signals.ipAddress !== void 0) {
14420
+ if (signals.ipAddress) this.config.clientIpAddress = signals.ipAddress;
14421
+ else delete this.config.clientIpAddress;
14422
+ }
14423
+ }
14424
+ },
14425
+ {
14426
+ key: "setScreenStandby",
14427
+ value: function setScreenStandby(standby) {
14428
+ setHostStandby(standby);
14429
+ }
14430
+ },
14431
+ {
14432
+ key: "getDeviceInfo",
14433
+ value: function getDeviceInfo1() {
14434
+ return getDeviceInfo();
14435
+ }
14436
+ },
14437
+ {
14438
+ key: "setDeviceInfo",
14439
+ value: function setDeviceInfo(info) {
14440
+ setHostDeviceInfo(info);
14441
+ }
14442
+ },
13140
14443
  {
13141
14444
  key: "onManifestParsed",
13142
14445
  value: function onManifestParsed(isLive) {
@@ -13271,9 +14574,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13271
14574
  }
13272
14575
  },
13273
14576
  {
13274
- // ───────────────────────────────────────────────────────────────
13275
- // SCTE-35 marker orchestration
13276
- // ───────────────────────────────────────────────────────────────
13277
14577
  key: "onScte35Marker",
13278
14578
  value: function onScte35Marker(marker, cueKey) {
13279
14579
  if (this.debug) {
@@ -13452,9 +14752,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13452
14752
  }
13453
14753
  },
13454
14754
  {
13455
- // ───────────────────────────────────────────────────────────────
13456
- // Ad prefetch
13457
- // ───────────────────────────────────────────────────────────────
13458
14755
  key: "startAdPrefetch",
13459
14756
  value: function startAdPrefetch(marker, fragmentSn, cueKey) {
13460
14757
  if (this.adBreak.pendingAdBreak || this.adBreak.inAdBreak) return;
@@ -13493,9 +14790,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13493
14790
  }
13494
14791
  },
13495
14792
  {
13496
- // ───────────────────────────────────────────────────────────────
13497
- // VMAP time-based ad breaks
13498
- // ───────────────────────────────────────────────────────────────
13499
14793
  key: "onTimeUpdate",
13500
14794
  value: function onTimeUpdate(currentTimeSec) {
13501
14795
  var _this = this;
@@ -13609,9 +14903,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13609
14903
  }
13610
14904
  },
13611
14905
  {
13612
- // ───────────────────────────────────────────────────────────────
13613
- // Public API
13614
- // ───────────────────────────────────────────────────────────────
13615
14906
  key: "getCurrentAdIndex",
13616
14907
  value: function getCurrentAdIndex() {
13617
14908
  return this.timing.currentAdIndex;
@@ -13730,12 +15021,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13730
15021
  }
13731
15022
  },
13732
15023
  {
13733
- // ───────────────────────────────────────────────────────────────
13734
- // Destroy
13735
- // ───────────────────────────────────────────────────────────────
13736
15024
  key: "destroy",
13737
15025
  value: function destroy() {
13738
15026
  var _this_adPlayer;
15027
+ if (this.palRefreshTimer != null) {
15028
+ clearInterval(this.palRefreshTimer);
15029
+ this.palRefreshTimer = void 0;
15030
+ }
13739
15031
  this.contentWatchdog.stop();
13740
15032
  this.adBreak.cancelScheduledRequest();
13741
15033
  this.timing.destroy();
@@ -13843,7 +15135,7 @@ var CRITICAL_PROPS = [
13843
15135
  var CONTROLS_HIDE_DELAY = 3e3;
13844
15136
  var DEFAULT_PLAYER_ASPECT_RATIO = 16 / 9;
13845
15137
  var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
13846
- 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, [
15138
+ 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, [
13847
15139
  "src",
13848
15140
  "autoplay",
13849
15141
  "muted",
@@ -13877,10 +15169,26 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
13877
15169
  "programTitle",
13878
15170
  "channelName",
13879
15171
  "contentNetwork",
15172
+ "contentDetails",
15173
+ "adUserId",
15174
+ "clientIpAddress",
13880
15175
  "minRemainingMsToStartAd",
13881
15176
  "minRemainingMsToRequestAd",
13882
15177
  "maxNoFillsPerBreak",
13883
- "maxAdBreakExtensionMs"
15178
+ "maxAdBreakExtensionMs",
15179
+ "adDeviceId",
15180
+ "adDeviceIdType",
15181
+ "adLimitAdTracking",
15182
+ "fallbackDeviceIdMaxAgeMs",
15183
+ "sessionIdMaxAgeMs",
15184
+ "palIconsSupported",
15185
+ "palSupportedApiFrameworks",
15186
+ "palContinuousPlayback",
15187
+ "palNonceMaxAgeMs",
15188
+ "forceSingleDecoderMode",
15189
+ "deviceInfo",
15190
+ "sendDeviceKeyValues",
15191
+ "sendDeviceInfoToAnalytics"
13884
15192
  ]);
13885
15193
  var videoRef = (0, import_react.useRef)(null);
13886
15194
  var playerRef = (0, import_react.useRef)(null);
@@ -14072,10 +15380,26 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
14072
15380
  if (programTitle !== void 0) cfg.programTitle = programTitle;
14073
15381
  if (channelName !== void 0) cfg.channelName = channelName;
14074
15382
  if (contentNetwork !== void 0) cfg.contentNetwork = contentNetwork;
15383
+ if (contentDetails !== void 0) cfg.contentDetails = contentDetails;
15384
+ if (adUserId !== void 0) cfg.adUserId = adUserId;
15385
+ if (clientIpAddress !== void 0) cfg.clientIpAddress = clientIpAddress;
14075
15386
  if (minRemainingMsToStartAd !== void 0) cfg.minRemainingMsToStartAd = minRemainingMsToStartAd;
14076
15387
  if (minRemainingMsToRequestAd !== void 0) cfg.minRemainingMsToRequestAd = minRemainingMsToRequestAd;
14077
15388
  if (maxNoFillsPerBreak !== void 0) cfg.maxNoFillsPerBreak = maxNoFillsPerBreak;
14078
15389
  if (maxAdBreakExtensionMs !== void 0) cfg.maxAdBreakExtensionMs = maxAdBreakExtensionMs;
15390
+ if (adDeviceId !== void 0) cfg.adDeviceId = adDeviceId;
15391
+ if (adDeviceIdType !== void 0) cfg.adDeviceIdType = adDeviceIdType;
15392
+ if (adLimitAdTracking !== void 0) cfg.adLimitAdTracking = adLimitAdTracking;
15393
+ if (fallbackDeviceIdMaxAgeMs !== void 0) cfg.fallbackDeviceIdMaxAgeMs = fallbackDeviceIdMaxAgeMs;
15394
+ if (sessionIdMaxAgeMs !== void 0) cfg.sessionIdMaxAgeMs = sessionIdMaxAgeMs;
15395
+ if (palIconsSupported !== void 0) cfg.palIconsSupported = palIconsSupported;
15396
+ if (palSupportedApiFrameworks !== void 0) cfg.palSupportedApiFrameworks = palSupportedApiFrameworks;
15397
+ if (palContinuousPlayback !== void 0) cfg.palContinuousPlayback = palContinuousPlayback;
15398
+ if (palNonceMaxAgeMs !== void 0) cfg.palNonceMaxAgeMs = palNonceMaxAgeMs;
15399
+ if (forceSingleDecoderMode !== void 0) cfg.forceSingleDecoderMode = forceSingleDecoderMode;
15400
+ if (deviceInfo !== void 0) cfg.deviceInfo = deviceInfo;
15401
+ if (sendDeviceKeyValues !== void 0) cfg.sendDeviceKeyValues = sendDeviceKeyValues;
15402
+ if (sendDeviceInfoToAnalytics !== void 0) cfg.sendDeviceInfoToAnalytics = sendDeviceInfoToAnalytics;
14079
15403
  var player = new StormcloudVideoPlayer(cfg);
14080
15404
  playerRef.current = player;
14081
15405
  player.load().then(function() {
@@ -14115,6 +15439,60 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
14115
15439
  autoplay,
14116
15440
  muted
14117
15441
  ]);
15442
+ (0, import_react.useEffect)(function() {
15443
+ var _playerRef_current;
15444
+ (_playerRef_current = playerRef.current) === null || _playerRef_current === void 0 ? void 0 : _playerRef_current.setContentMetadata({
15445
+ channelName: channelName !== null && channelName !== void 0 ? channelName : null,
15446
+ programTitle: programTitle !== null && programTitle !== void 0 ? programTitle : null,
15447
+ contentNetwork: contentNetwork !== null && contentNetwork !== void 0 ? contentNetwork : null
15448
+ });
15449
+ }, [
15450
+ channelName,
15451
+ programTitle,
15452
+ contentNetwork
15453
+ ]);
15454
+ var contentDetailsKey = contentDetails ? JSON.stringify(contentDetails) : "";
15455
+ (0, import_react.useEffect)(function() {
15456
+ var _playerRef_current;
15457
+ (_playerRef_current = playerRef.current) === null || _playerRef_current === void 0 ? void 0 : _playerRef_current.setContentMetadata({
15458
+ details: contentDetailsKey ? JSON.parse(contentDetailsKey) : null
15459
+ });
15460
+ }, [
15461
+ contentDetailsKey
15462
+ ]);
15463
+ (0, import_react.useEffect)(function() {
15464
+ var _playerRef_current;
15465
+ (_playerRef_current = playerRef.current) === null || _playerRef_current === void 0 ? void 0 : _playerRef_current.setRequestSignals({
15466
+ userId: adUserId !== null && adUserId !== void 0 ? adUserId : null,
15467
+ ipAddress: clientIpAddress !== null && clientIpAddress !== void 0 ? clientIpAddress : null
15468
+ });
15469
+ }, [
15470
+ adUserId,
15471
+ clientIpAddress
15472
+ ]);
15473
+ var lastAdDeviceIdRef = (0, import_react.useRef)(void 0);
15474
+ (0, import_react.useEffect)(function() {
15475
+ var player = playerRef.current;
15476
+ if (!player) return;
15477
+ if (adDeviceId === void 0 && lastAdDeviceIdRef.current === void 0) return;
15478
+ lastAdDeviceIdRef.current = adDeviceId;
15479
+ player.setAdIdentity(adDeviceId ? {
15480
+ deviceId: adDeviceId,
15481
+ deviceIdType: adDeviceIdType,
15482
+ limitAdTracking: adLimitAdTracking
15483
+ } : null);
15484
+ }, [
15485
+ adDeviceId,
15486
+ adDeviceIdType,
15487
+ adLimitAdTracking
15488
+ ]);
15489
+ var deviceInfoKey = deviceInfo ? JSON.stringify(deviceInfo) : "";
15490
+ (0, import_react.useEffect)(function() {
15491
+ if (!playerRef.current || !deviceInfoKey) return;
15492
+ playerRef.current.setDeviceInfo(JSON.parse(deviceInfoKey));
15493
+ }, [
15494
+ deviceInfoKey
15495
+ ]);
14118
15496
  (0, import_react.useEffect)(function() {
14119
15497
  if (!playerRef.current) return;
14120
15498
  var checkAdStatus = function checkAdStatus() {