stormcloud-video-player 0.8.18 → 0.8.19

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 (34) hide show
  1. package/README.md +67 -83
  2. package/dist/stormcloud-vp.min.js +1 -1
  3. package/lib/index.cjs +635 -346
  4. package/lib/index.cjs.map +1 -1
  5. package/lib/index.d.cts +1 -1
  6. package/lib/index.d.ts +1 -1
  7. package/lib/index.js +635 -346
  8. package/lib/index.js.map +1 -1
  9. package/lib/player/AdBreakOrchestrator.cjs +11 -11
  10. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  11. package/lib/player/AdBreakOrchestrator.d.cts +3 -3
  12. package/lib/player/{VmapManager.cjs → AdConfigManager.cjs} +503 -214
  13. package/lib/player/AdConfigManager.cjs.map +1 -0
  14. package/lib/player/{VmapManager.d.cts → AdConfigManager.d.cts} +2 -2
  15. package/lib/player/StormcloudVideoPlayer.cjs +635 -346
  16. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  17. package/lib/player/StormcloudVideoPlayer.d.cts +1 -1
  18. package/lib/players/HlsPlayer.cjs +635 -346
  19. package/lib/players/HlsPlayer.cjs.map +1 -1
  20. package/lib/players/index.cjs +635 -346
  21. package/lib/players/index.cjs.map +1 -1
  22. package/lib/ui/StormcloudVideoPlayer.cjs +635 -346
  23. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  24. package/lib/utils/ctvVastSignals.cjs +92 -33
  25. package/lib/utils/ctvVastSignals.cjs.map +1 -1
  26. package/lib/utils/ctvVastSignals.d.cts +1 -13
  27. package/lib/utils/vastEnvironmentSignals.cjs +439 -0
  28. package/lib/utils/vastEnvironmentSignals.cjs.map +1 -0
  29. package/lib/utils/vastEnvironmentSignals.d.cts +16 -0
  30. package/lib/utils/vastMacros.cjs +299 -25
  31. package/lib/utils/vastMacros.cjs.map +1 -1
  32. package/lib/utils/vastMacros.d.cts +3 -1
  33. package/package.json +1 -1
  34. package/lib/player/VmapManager.cjs.map +0 -1
@@ -2358,22 +2358,326 @@ function initializePolyfills() {
2358
2358
  polyfillTextEncoder();
2359
2359
  polyfillPromiseFinally();
2360
2360
  }
2361
- // src/utils/vastMacros.ts
2362
- function generateCorrelator() {
2363
- if (typeof crypto !== "undefined" && crypto.getRandomValues) {
2361
+ // src/utils/vastEnvironmentSignals.ts
2362
+ var AIRY_ANDROID_APP_ID = "com.freeairytv.android";
2363
+ var AIRY_APP_NAME = "AiryTV Movies & TV";
2364
+ var AIRY_DEFAULT_CONTENT_URL = "https://live.airy.tv";
2365
+ var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
2366
+ var DEVICE_ID_STORAGE_KEYS = [
2367
+ "rdid",
2368
+ "ifa",
2369
+ "advertisingId",
2370
+ "advertising_id",
2371
+ "deviceAdvertisingId",
2372
+ "aaid",
2373
+ "adid",
2374
+ "rida",
2375
+ "tifa",
2376
+ "lgudid"
2377
+ ];
2378
+ var ANDROID_ID_TYPES = /* @__PURE__ */ new Set([
2379
+ "aaid",
2380
+ "adid"
2381
+ ]);
2382
+ function resolveVastEnvironmentSignals(isCtv) {
2383
+ var _ref, _bridgeSignals_limitAdTracking;
2384
+ var bridgeSignals = readNativeBridgeSignals();
2385
+ var deviceId = bridgeSignals.deviceId || readStoredDeviceId();
2386
+ var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || readStoredString("idtype") || inferDeviceIdType();
2387
+ var limitAdTracking = deviceId != null ? (_ref = (_bridgeSignals_limitAdTracking = bridgeSignals.limitAdTracking) !== null && _bridgeSignals_limitAdTracking !== void 0 ? _bridgeSignals_limitAdTracking : readStoredLimitAdTracking()) !== null && _ref !== void 0 ? _ref : false : void 0;
2388
+ if (isCtv) {
2389
+ return _object_spread_props(_object_spread({
2390
+ isCtv: true,
2391
+ contentUrl: bridgeSignals.contentUrl || readStoredString("contentUrl") || AIRY_DEFAULT_CONTENT_URL,
2392
+ appId: bridgeSignals.appId || readStoredString("appId") || readStoredString("msid") || AIRY_ANDROID_APP_ID,
2393
+ appName: bridgeSignals.appName || readStoredString("appName") || readStoredString("an") || AIRY_APP_NAME,
2394
+ sessionId: getOrCreateCtvSessionId()
2395
+ }, deviceId ? {
2396
+ deviceId: deviceId
2397
+ } : {}, deviceIdType ? {
2398
+ deviceIdType: deviceIdType
2399
+ } : {}, limitAdTracking != null ? {
2400
+ limitAdTracking: limitAdTracking
2401
+ } : {}), {
2402
+ deviceTypeHint: 5
2403
+ });
2404
+ }
2405
+ return _object_spread({
2406
+ isCtv: false
2407
+ }, deviceId ? {
2408
+ deviceId: deviceId
2409
+ } : {}, deviceIdType ? {
2410
+ deviceIdType: deviceIdType
2411
+ } : {}, limitAdTracking != null ? {
2412
+ limitAdTracking: limitAdTracking
2413
+ } : {});
2414
+ }
2415
+ function inferDeviceIdType() {
2416
+ if (typeof navigator === "undefined") {
2417
+ return void 0;
2418
+ }
2419
+ var ua = navigator.userAgent;
2420
+ if (/Roku/i.test(ua)) return "rida";
2421
+ if (/Tizen|Samsung/i.test(ua)) return "tifa";
2422
+ if (/AppleTV|Apple TV/i.test(ua)) return "tvOS";
2423
+ if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
2424
+ if (/Web0S|webOS|LG Browser|LGSTB|LGE/i.test(ua)) return "lgudid";
2425
+ if (/Android|Google TV/i.test(ua)) return "aaid";
2426
+ if (/iPhone|iPad|iPod/i.test(ua)) return "idfa";
2427
+ return void 0;
2428
+ }
2429
+ function isEquivalentDeviceIdType(tagType, runtimeType) {
2430
+ if (!tagType || !runtimeType) return false;
2431
+ var tag = tagType.toLowerCase();
2432
+ var runtime = runtimeType.toLowerCase();
2433
+ if (tag === runtime) return true;
2434
+ return ANDROID_ID_TYPES.has(tag) && ANDROID_ID_TYPES.has(runtime);
2435
+ }
2436
+ function getOrCreateCtvSessionId() {
2437
+ var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
2438
+ if (existing) {
2439
+ return existing;
2440
+ }
2441
+ var sessionId = createUuid();
2442
+ try {
2443
+ var _window_localStorage;
2444
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
2445
+ } catch (unused) {}
2446
+ return sessionId;
2447
+ }
2448
+ function createUuid() {
2449
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2450
+ return crypto.randomUUID();
2451
+ }
2452
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
2453
+ var value = Math.floor(Math.random() * 16);
2454
+ var nibble = char === "x" ? value : value & 3 | 8;
2455
+ return nibble.toString(16);
2456
+ });
2457
+ }
2458
+ function readNativeBridgeSignals() {
2459
+ if (typeof window === "undefined") {
2460
+ return {};
2461
+ }
2462
+ var candidates = [
2463
+ window.__STORMCLOUD_CTV_AD_INFO__,
2464
+ window.__STORMCLOUD_CTV__,
2465
+ window.stormcloudCtv,
2466
+ window.AiryTV,
2467
+ window.Android,
2468
+ window.webOS,
2469
+ window.tizen,
2470
+ window.amazon
2471
+ ].filter(Boolean);
2472
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2473
+ try {
2474
+ for(var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2475
+ var source = _step.value;
2476
+ var contentUrl = readBridgeValue(source, [
2477
+ "contentUrl",
2478
+ "url",
2479
+ "videoUrl",
2480
+ "canonicalUrl"
2481
+ ]) || void 0;
2482
+ var appId = readBridgeValue(source, [
2483
+ "appId",
2484
+ "msid",
2485
+ "applicationId",
2486
+ "packageName"
2487
+ ]) || void 0;
2488
+ var appName = readBridgeValue(source, [
2489
+ "appName",
2490
+ "an",
2491
+ "applicationName"
2492
+ ]) || void 0;
2493
+ var deviceId = readBridgeValue(source, [
2494
+ "rdid",
2495
+ "ifa",
2496
+ "advertisingId",
2497
+ "adId",
2498
+ "deviceId",
2499
+ "lgudid",
2500
+ "LGUDID",
2501
+ "tifa",
2502
+ "rida",
2503
+ "afai",
2504
+ "aaid"
2505
+ ]) || void 0;
2506
+ if (!contentUrl && !deviceId && !appId && !appName) continue;
2507
+ var deviceIdType = readBridgeValue(source, [
2508
+ "idtype",
2509
+ "deviceIdType",
2510
+ "advertisingIdType",
2511
+ "idType"
2512
+ ]) || inferDeviceIdType();
2513
+ var limitAdTracking = readBridgeBoolean(source, [
2514
+ "is_lat",
2515
+ "limitAdTracking",
2516
+ "limitedAdTracking",
2517
+ "lat"
2518
+ ]);
2519
+ return _object_spread({}, contentUrl ? {
2520
+ contentUrl: contentUrl
2521
+ } : {}, appId ? {
2522
+ appId: appId
2523
+ } : {}, appName ? {
2524
+ appName: appName
2525
+ } : {}, deviceId ? {
2526
+ deviceId: deviceId
2527
+ } : {}, deviceId && deviceIdType ? {
2528
+ deviceIdType: deviceIdType
2529
+ } : {}, deviceId && limitAdTracking != null ? {
2530
+ limitAdTracking: limitAdTracking
2531
+ } : {});
2532
+ }
2533
+ } catch (err) {
2534
+ _didIteratorError = true;
2535
+ _iteratorError = err;
2536
+ } finally{
2364
2537
  try {
2365
- var _buf_, _buf_1;
2366
- var buf = new Uint32Array(2);
2367
- crypto.getRandomValues(buf);
2368
- var value = ((_buf_ = buf[0]) !== null && _buf_ !== void 0 ? _buf_ : 0) * 2097152 + (((_buf_1 = buf[1]) !== null && _buf_1 !== void 0 ? _buf_1 : 0) & 2097151);
2369
- if (value > 0) {
2370
- return String(value);
2538
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2539
+ _iterator.return();
2371
2540
  }
2372
- } catch (unused) {}
2541
+ } finally{
2542
+ if (_didIteratorError) {
2543
+ throw _iteratorError;
2544
+ }
2545
+ }
2373
2546
  }
2374
- return String(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1);
2547
+ return {};
2548
+ }
2549
+ function readBridgeValue(source, keys) {
2550
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2551
+ try {
2552
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2553
+ var key = _step.value;
2554
+ var value = source === null || source === void 0 ? void 0 : source[key];
2555
+ if (typeof value === "string" && value) {
2556
+ return value;
2557
+ }
2558
+ if (typeof value === "function") {
2559
+ try {
2560
+ var result = value.call(source);
2561
+ if (typeof result === "string" && result) {
2562
+ return result;
2563
+ }
2564
+ } catch (unused) {}
2565
+ }
2566
+ }
2567
+ } catch (err) {
2568
+ _didIteratorError = true;
2569
+ _iteratorError = err;
2570
+ } finally{
2571
+ try {
2572
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2573
+ _iterator.return();
2574
+ }
2575
+ } finally{
2576
+ if (_didIteratorError) {
2577
+ throw _iteratorError;
2578
+ }
2579
+ }
2580
+ }
2581
+ return void 0;
2582
+ }
2583
+ function readBridgeBoolean(source, keys) {
2584
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2585
+ try {
2586
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2587
+ var key = _step.value;
2588
+ var value = source === null || source === void 0 ? void 0 : source[key];
2589
+ var normalized = normalizeBoolean(value);
2590
+ if (normalized != null) {
2591
+ return normalized;
2592
+ }
2593
+ if (typeof value === "function") {
2594
+ try {
2595
+ var result = normalizeBoolean(value.call(source));
2596
+ if (result != null) {
2597
+ return result;
2598
+ }
2599
+ } catch (unused) {}
2600
+ }
2601
+ }
2602
+ } catch (err) {
2603
+ _didIteratorError = true;
2604
+ _iteratorError = err;
2605
+ } finally{
2606
+ try {
2607
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2608
+ _iterator.return();
2609
+ }
2610
+ } finally{
2611
+ if (_didIteratorError) {
2612
+ throw _iteratorError;
2613
+ }
2614
+ }
2615
+ }
2616
+ return void 0;
2375
2617
  }
2618
+ function readStoredDeviceId() {
2619
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2620
+ try {
2621
+ for(var _iterator = DEVICE_ID_STORAGE_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2622
+ var key = _step.value;
2623
+ var value = readStoredString(key);
2624
+ if (value) {
2625
+ return value;
2626
+ }
2627
+ }
2628
+ } catch (err) {
2629
+ _didIteratorError = true;
2630
+ _iteratorError = err;
2631
+ } finally{
2632
+ try {
2633
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2634
+ _iterator.return();
2635
+ }
2636
+ } finally{
2637
+ if (_didIteratorError) {
2638
+ throw _iteratorError;
2639
+ }
2640
+ }
2641
+ }
2642
+ return void 0;
2643
+ }
2644
+ function readStoredString(key) {
2645
+ if (typeof window === "undefined") {
2646
+ return void 0;
2647
+ }
2648
+ try {
2649
+ var _window_localStorage;
2650
+ var value = (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key);
2651
+ return value || void 0;
2652
+ } catch (unused) {
2653
+ return void 0;
2654
+ }
2655
+ }
2656
+ function readStoredLimitAdTracking() {
2657
+ return normalizeBoolean(readStoredString("limitAdTracking") || readStoredString("limitedAdTracking") || readStoredString("is_lat"));
2658
+ }
2659
+ function normalizeBoolean(value) {
2660
+ if (typeof value === "boolean") {
2661
+ return value;
2662
+ }
2663
+ if (typeof value === "number") {
2664
+ return value === 1;
2665
+ }
2666
+ if (typeof value === "string") {
2667
+ var normalized = value.toLowerCase();
2668
+ if (normalized === "1" || normalized === "true" || normalized === "yes") {
2669
+ return true;
2670
+ }
2671
+ if (normalized === "0" || normalized === "false" || normalized === "no") {
2672
+ return false;
2673
+ }
2674
+ }
2675
+ return void 0;
2676
+ }
2677
+ // src/utils/vastMacros.ts
2376
2678
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
2679
+ var INVALID_VAST_PARAM_KEY = /^\s|\s$/;
2680
+ var EXAMPLE_COM_URL = /example\.com/i;
2377
2681
  var CTV_UNSUPPORTED_PARAMS = [
2378
2682
  "description_url",
2379
2683
  "tfcd",
@@ -2388,14 +2692,265 @@ var CTV_UNSUPPORTED_PARAMS = [
2388
2692
  "gdpr_consent",
2389
2693
  "us_privacy"
2390
2694
  ];
2695
+ var INLINE_DEVICE_MACRO_REPLACEMENTS = [
2696
+ {
2697
+ pattern: /\[RDID\]/gi,
2698
+ getValue: function getValue(ctx) {
2699
+ return ctx.deviceId;
2700
+ }
2701
+ },
2702
+ {
2703
+ pattern: /\[IFA\]/gi,
2704
+ getValue: function getValue(ctx) {
2705
+ return ctx.deviceId;
2706
+ }
2707
+ },
2708
+ {
2709
+ pattern: /\[ADVERTISING[_-]?ID(?:ENTIFIER)?\]/gi,
2710
+ getValue: function getValue(ctx) {
2711
+ return ctx.deviceId;
2712
+ }
2713
+ },
2714
+ {
2715
+ pattern: /\[DEVICE[_-]?ID\]/gi,
2716
+ getValue: function getValue(ctx) {
2717
+ return ctx.deviceId;
2718
+ }
2719
+ },
2720
+ {
2721
+ pattern: /\[IDTYPE\]/gi,
2722
+ getValue: function getValue(ctx) {
2723
+ return ctx.deviceIdType;
2724
+ }
2725
+ },
2726
+ {
2727
+ pattern: /\{rdid\}/gi,
2728
+ getValue: function getValue(ctx) {
2729
+ return ctx.deviceId;
2730
+ }
2731
+ },
2732
+ {
2733
+ pattern: /\{device[_-]?id\}/gi,
2734
+ getValue: function getValue(ctx) {
2735
+ return ctx.deviceId;
2736
+ }
2737
+ },
2738
+ {
2739
+ pattern: /\{idtype\}/gi,
2740
+ getValue: function getValue(ctx) {
2741
+ return ctx.deviceIdType;
2742
+ }
2743
+ },
2744
+ {
2745
+ pattern: /%%ADVERTISING_IDENTIFIER_PLAIN%%/gi,
2746
+ getValue: function getValue(ctx) {
2747
+ return ctx.deviceId;
2748
+ }
2749
+ },
2750
+ {
2751
+ pattern: /%%ADVERTISING_ID_OPT_OUT%%/gi,
2752
+ getValue: function getValue(ctx) {
2753
+ return ctx.limitAdTracking != null ? ctx.limitAdTracking ? "1" : "0" : void 0;
2754
+ }
2755
+ },
2756
+ {
2757
+ pattern: /%%ADVERTISING_ID_TYPE%%/gi,
2758
+ getValue: function getValue(ctx) {
2759
+ return ctx.deviceIdType;
2760
+ }
2761
+ },
2762
+ {
2763
+ pattern: /%%ADVERTISING_ID%%/gi,
2764
+ getValue: function getValue(ctx) {
2765
+ return ctx.deviceId;
2766
+ }
2767
+ },
2768
+ {
2769
+ pattern: /%%LIMIT_AD_TRACKING%%/gi,
2770
+ getValue: function getValue(ctx) {
2771
+ return ctx.limitAdTracking != null ? ctx.limitAdTracking ? "1" : "0" : void 0;
2772
+ }
2773
+ },
2774
+ {
2775
+ pattern: /%%MSID%%/gi,
2776
+ getValue: function getValue(ctx) {
2777
+ return ctx.appId;
2778
+ }
2779
+ },
2780
+ {
2781
+ pattern: /%%APP_NAME%%/gi,
2782
+ getValue: function getValue(ctx) {
2783
+ return ctx.appName;
2784
+ }
2785
+ },
2786
+ {
2787
+ pattern: /%%SESSION_ID%%/gi,
2788
+ getValue: function getValue(ctx) {
2789
+ return ctx.sessionId;
2790
+ }
2791
+ },
2792
+ {
2793
+ pattern: /%%CORRELATOR%%/gi,
2794
+ getValue: function getValue(ctx) {
2795
+ return ctx.correlator;
2796
+ }
2797
+ }
2798
+ ];
2799
+ function isMacroPlaceholder(value) {
2800
+ if (value == null) return true;
2801
+ var trimmed = value.trim();
2802
+ if (!trimmed) return true;
2803
+ if (UNEXPANDED_MACRO_PATTERN.test(trimmed)) return true;
2804
+ return /^(unknown|null|undefined|none|n\/a|\$\{[^}]+\})$/i.test(trimmed);
2805
+ }
2806
+ function generateCorrelator() {
2807
+ if (typeof crypto !== "undefined" && crypto.getRandomValues) {
2808
+ try {
2809
+ var _buf_, _buf_1;
2810
+ var buf = new Uint32Array(2);
2811
+ crypto.getRandomValues(buf);
2812
+ var value = ((_buf_ = buf[0]) !== null && _buf_ !== void 0 ? _buf_ : 0) * 2097152 + (((_buf_1 = buf[1]) !== null && _buf_1 !== void 0 ? _buf_1 : 0) & 2097151);
2813
+ if (value > 0) {
2814
+ return String(value);
2815
+ }
2816
+ } catch (unused) {}
2817
+ }
2818
+ return String(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1);
2819
+ }
2820
+ function expandInlineMacroPlaceholders(baseUrl, ctx) {
2821
+ var url = baseUrl;
2822
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2823
+ try {
2824
+ for(var _iterator = INLINE_DEVICE_MACRO_REPLACEMENTS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2825
+ var _step_value = _step.value, pattern = _step_value.pattern, getValue = _step_value.getValue;
2826
+ var value = getValue(ctx);
2827
+ if (value != null && value !== "") {
2828
+ url = url.replace(pattern, encodeURIComponent(value));
2829
+ }
2830
+ }
2831
+ } catch (err) {
2832
+ _didIteratorError = true;
2833
+ _iteratorError = err;
2834
+ } finally{
2835
+ try {
2836
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2837
+ _iterator.return();
2838
+ }
2839
+ } finally{
2840
+ if (_didIteratorError) {
2841
+ throw _iteratorError;
2842
+ }
2843
+ }
2844
+ }
2845
+ return url;
2846
+ }
2847
+ function applyDeviceIdentityParams(params, ctx) {
2848
+ var _ctx_deviceId, _ctx_deviceIdType;
2849
+ var runtimeId = (_ctx_deviceId = ctx.deviceId) === null || _ctx_deviceId === void 0 ? void 0 : _ctx_deviceId.trim();
2850
+ var runtimeType = ((_ctx_deviceIdType = ctx.deviceIdType) === null || _ctx_deviceIdType === void 0 ? void 0 : _ctx_deviceIdType.trim()) || inferDeviceIdType();
2851
+ var tagRdid = params.get("rdid");
2852
+ var tagType = params.get("idtype");
2853
+ var tagLat = params.get("is_lat");
2854
+ var latValue = ctx.limitAdTracking != null ? ctx.limitAdTracking ? "1" : "0" : void 0;
2855
+ if (runtimeId) {
2856
+ params.set("rdid", runtimeId);
2857
+ params.set("idtype", runtimeType || tagType || "aaid");
2858
+ params.set("is_lat", latValue !== null && latValue !== void 0 ? latValue : isMacroPlaceholder(tagLat) ? "0" : tagLat);
2859
+ return;
2860
+ }
2861
+ var tagRdidValid = Boolean(tagRdid && !isMacroPlaceholder(tagRdid));
2862
+ var tagTypeValid = Boolean(tagType && !isMacroPlaceholder(tagType));
2863
+ if (tagRdidValid && tagTypeValid && runtimeType && !isEquivalentDeviceIdType(tagType, runtimeType)) {
2864
+ params.delete("rdid");
2865
+ params.delete("idtype");
2866
+ params.delete("is_lat");
2867
+ return;
2868
+ }
2869
+ if (tagRdidValid) {
2870
+ if (isMacroPlaceholder(tagType) && runtimeType) {
2871
+ params.set("idtype", runtimeType);
2872
+ }
2873
+ if (isMacroPlaceholder(tagLat)) {
2874
+ params.set("is_lat", latValue !== null && latValue !== void 0 ? latValue : "0");
2875
+ }
2876
+ return;
2877
+ }
2878
+ params.delete("rdid");
2879
+ params.delete("idtype");
2880
+ params.delete("is_lat");
2881
+ }
2882
+ function removeBrokenAppNameOrphans(params, appName) {
2883
+ var toDelete = [];
2884
+ params.forEach(function(_value, key) {
2885
+ if (!key || INVALID_VAST_PARAM_KEY.test(key)) {
2886
+ toDelete.push(key);
2887
+ }
2888
+ });
2889
+ if (appName && appName.includes("&")) {
2890
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2891
+ try {
2892
+ for(var _iterator = appName.split("&").slice(1)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2893
+ var suffix = _step.value;
2894
+ var trimmed = suffix.trimStart();
2895
+ if (!trimmed) continue;
2896
+ toDelete.push(suffix, " ".concat(trimmed), trimmed);
2897
+ }
2898
+ } catch (err) {
2899
+ _didIteratorError = true;
2900
+ _iteratorError = err;
2901
+ } finally{
2902
+ try {
2903
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2904
+ _iterator.return();
2905
+ }
2906
+ } finally{
2907
+ if (_didIteratorError) {
2908
+ throw _iteratorError;
2909
+ }
2910
+ }
2911
+ }
2912
+ }
2913
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2914
+ try {
2915
+ for(var _iterator1 = new Set(toDelete)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2916
+ var key = _step1.value;
2917
+ if (key) params.delete(key);
2918
+ }
2919
+ } catch (err) {
2920
+ _didIteratorError1 = true;
2921
+ _iteratorError1 = err;
2922
+ } finally{
2923
+ try {
2924
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2925
+ _iterator1.return();
2926
+ }
2927
+ } finally{
2928
+ if (_didIteratorError1) {
2929
+ throw _iteratorError1;
2930
+ }
2931
+ }
2932
+ }
2933
+ }
2934
+ function normalizeVastTagUrl(raw) {
2935
+ if (!raw) return raw;
2936
+ try {
2937
+ var url = new URL(raw);
2938
+ removeBrokenAppNameOrphans(url.searchParams);
2939
+ return url.toString();
2940
+ } catch (unused) {
2941
+ return raw;
2942
+ }
2943
+ }
2391
2944
  function applyVastMacros(baseUrl, ctx) {
2945
+ var expandedUrl = expandInlineMacroPlaceholders(baseUrl, ctx);
2392
2946
  var url;
2393
2947
  try {
2394
- url = new URL(baseUrl);
2948
+ url = new URL(normalizeVastTagUrl(expandedUrl));
2395
2949
  } catch (unused) {
2396
- return replaceCorrelatorFallback(baseUrl, ctx.correlator);
2950
+ return replaceCorrelatorFallback(expandedUrl, ctx.correlator);
2397
2951
  }
2398
2952
  var params = url.searchParams;
2953
+ removeBrokenAppNameOrphans(params, ctx.appName);
2399
2954
  params.set("correlator", ctx.correlator);
2400
2955
  if (ctx.isCtv) {
2401
2956
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2433,6 +2988,12 @@ function applyVastMacros(baseUrl, ctx) {
2433
2988
  if (!ctx.isCtv) {
2434
2989
  params.set("description_url", requestUrl);
2435
2990
  }
2991
+ } else {
2992
+ var existingUrl = params.get("url") || "";
2993
+ if (EXAMPLE_COM_URL.test(existingUrl)) {
2994
+ params.delete("url");
2995
+ params.delete("description_url");
2996
+ }
2436
2997
  }
2437
2998
  if (ctx.adWillPlayMuted != null) {
2438
2999
  params.set("vpmute", ctx.adWillPlayMuted ? "1" : "0");
@@ -2444,6 +3005,7 @@ function applyVastMacros(baseUrl, ctx) {
2444
3005
  params.set("msid", ctx.appId);
2445
3006
  }
2446
3007
  if (ctx.appName) {
3008
+ removeBrokenAppNameOrphans(params, ctx.appName);
2447
3009
  params.set("an", ctx.appName);
2448
3010
  }
2449
3011
  if (ctx.sessionId) {
@@ -2454,15 +3016,7 @@ function applyVastMacros(baseUrl, ctx) {
2454
3016
  } else if (ctx.isCtv) {
2455
3017
  params.set("dth", "5");
2456
3018
  }
2457
- if (ctx.deviceId && ctx.deviceIdType) {
2458
- params.set("rdid", ctx.deviceId);
2459
- params.set("idtype", ctx.deviceIdType);
2460
- params.set("is_lat", ctx.limitAdTracking ? "1" : "0");
2461
- } else {
2462
- params.delete("rdid");
2463
- params.delete("idtype");
2464
- params.delete("is_lat");
2465
- }
3019
+ applyDeviceIdentityParams(params, ctx);
2466
3020
  if (!ctx.isCtv) {
2467
3021
  var consent = ctx.consent;
2468
3022
  if ((consent === null || consent === void 0 ? void 0 : consent.gdpr) != null) {
@@ -2480,7 +3034,7 @@ function applyVastMacros(baseUrl, ctx) {
2480
3034
  }
2481
3035
  var staleKeys = [];
2482
3036
  params.forEach(function(value, key) {
2483
- if (UNEXPANDED_MACRO_PATTERN.test(value)) {
3037
+ if (isMacroPlaceholder(value)) {
2484
3038
  staleKeys.push(key);
2485
3039
  }
2486
3040
  });
@@ -2504,6 +3058,7 @@ function applyVastMacros(baseUrl, ctx) {
2504
3058
  }
2505
3059
  }
2506
3060
  }
3061
+ removeBrokenAppNameOrphans(params, ctx.appName);
2507
3062
  return url.toString();
2508
3063
  }
2509
3064
  function replaceCorrelatorFallback(baseUrl, correlator) {
@@ -3754,276 +4309,10 @@ var Scte35CueManager = /*#__PURE__*/ function() {
3754
4309
  ]);
3755
4310
  return Scte35CueManager;
3756
4311
  }();
3757
- // src/utils/ctvVastSignals.ts
3758
- var AIRY_ANDROID_APP_ID = "com.freeairytv.android";
3759
- var AIRY_APP_NAME = "AiryTV Movies & TV";
3760
- var AIRY_DEFAULT_CONTENT_URL = "https://live.airy.tv";
3761
- var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
3762
- var DEVICE_ID_STORAGE_KEYS = [
3763
- "rdid",
3764
- "ifa",
3765
- "advertisingId",
3766
- "advertising_id",
3767
- "deviceAdvertisingId",
3768
- "aaid",
3769
- "adid",
3770
- "rida",
3771
- "tifa"
3772
- ];
3773
- function resolveCtvVastSignals() {
3774
- var _ref, _bridgeSignals_limitAdTracking;
3775
- var bridgeSignals = readNativeBridgeSignals();
3776
- var deviceId = bridgeSignals.deviceId || readStoredDeviceId();
3777
- var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || inferDeviceIdType();
3778
- var contentUrl = bridgeSignals.contentUrl || readStoredString("contentUrl") || AIRY_DEFAULT_CONTENT_URL;
3779
- return _object_spread_props(_object_spread({
3780
- contentUrl: contentUrl,
3781
- appId: AIRY_ANDROID_APP_ID,
3782
- appName: AIRY_APP_NAME,
3783
- sessionId: getOrCreateCtvSessionId()
3784
- }, deviceId ? {
3785
- deviceId: deviceId
3786
- } : {}, deviceId && deviceIdType ? {
3787
- deviceIdType: deviceIdType
3788
- } : {}, deviceId ? {
3789
- limitAdTracking: (_ref = (_bridgeSignals_limitAdTracking = bridgeSignals.limitAdTracking) !== null && _bridgeSignals_limitAdTracking !== void 0 ? _bridgeSignals_limitAdTracking : readStoredLimitAdTracking()) !== null && _ref !== void 0 ? _ref : false
3790
- } : {}), {
3791
- deviceTypeHint: 5
3792
- });
3793
- }
3794
- function getOrCreateCtvSessionId() {
3795
- var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
3796
- if (existing) {
3797
- return existing;
3798
- }
3799
- var sessionId = createUuid();
3800
- try {
3801
- var _window_localStorage;
3802
- (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
3803
- } catch (unused) {}
3804
- return sessionId;
3805
- }
3806
- function createUuid() {
3807
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
3808
- return crypto.randomUUID();
3809
- }
3810
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
3811
- var value = Math.floor(Math.random() * 16);
3812
- var nibble = char === "x" ? value : value & 3 | 8;
3813
- return nibble.toString(16);
3814
- });
3815
- }
3816
- function readNativeBridgeSignals() {
3817
- if (typeof window === "undefined") {
3818
- return {};
3819
- }
3820
- var candidates = [
3821
- window.__STORMCLOUD_CTV_AD_INFO__,
3822
- window.__STORMCLOUD_CTV__,
3823
- window.stormcloudCtv,
3824
- window.AiryTV,
3825
- window.Android
3826
- ].filter(Boolean);
3827
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3828
- try {
3829
- for(var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3830
- var source = _step.value;
3831
- var contentUrl = readBridgeValue(source, [
3832
- "contentUrl",
3833
- "url",
3834
- "videoUrl",
3835
- "canonicalUrl"
3836
- ]) || void 0;
3837
- var deviceId = readBridgeValue(source, [
3838
- "rdid",
3839
- "ifa",
3840
- "advertisingId",
3841
- "adId",
3842
- "deviceId"
3843
- ]) || void 0;
3844
- if (!contentUrl && !deviceId) continue;
3845
- var deviceIdType = readBridgeValue(source, [
3846
- "idtype",
3847
- "deviceIdType",
3848
- "advertisingIdType"
3849
- ]) || inferDeviceIdType();
3850
- var limitAdTracking = readBridgeBoolean(source, [
3851
- "is_lat",
3852
- "limitAdTracking",
3853
- "limitedAdTracking",
3854
- "lat"
3855
- ]);
3856
- return _object_spread({}, contentUrl ? {
3857
- contentUrl: contentUrl
3858
- } : {}, deviceId ? {
3859
- deviceId: deviceId
3860
- } : {}, deviceId && deviceIdType ? {
3861
- deviceIdType: deviceIdType
3862
- } : {}, deviceId && limitAdTracking != null ? {
3863
- limitAdTracking: limitAdTracking
3864
- } : {});
3865
- }
3866
- } catch (err) {
3867
- _didIteratorError = true;
3868
- _iteratorError = err;
3869
- } finally{
3870
- try {
3871
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3872
- _iterator.return();
3873
- }
3874
- } finally{
3875
- if (_didIteratorError) {
3876
- throw _iteratorError;
3877
- }
3878
- }
3879
- }
3880
- return {};
3881
- }
3882
- function readBridgeValue(source, keys) {
3883
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3884
- try {
3885
- for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3886
- var key = _step.value;
3887
- var value = source === null || source === void 0 ? void 0 : source[key];
3888
- if (typeof value === "string" && value) {
3889
- return value;
3890
- }
3891
- if (typeof value === "function") {
3892
- try {
3893
- var result = value.call(source);
3894
- if (typeof result === "string" && result) {
3895
- return result;
3896
- }
3897
- } catch (unused) {}
3898
- }
3899
- }
3900
- } catch (err) {
3901
- _didIteratorError = true;
3902
- _iteratorError = err;
3903
- } finally{
3904
- try {
3905
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3906
- _iterator.return();
3907
- }
3908
- } finally{
3909
- if (_didIteratorError) {
3910
- throw _iteratorError;
3911
- }
3912
- }
3913
- }
3914
- return void 0;
3915
- }
3916
- function readBridgeBoolean(source, keys) {
3917
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3918
- try {
3919
- for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3920
- var key = _step.value;
3921
- var value = source === null || source === void 0 ? void 0 : source[key];
3922
- var normalized = normalizeBoolean(value);
3923
- if (normalized != null) {
3924
- return normalized;
3925
- }
3926
- if (typeof value === "function") {
3927
- try {
3928
- var result = normalizeBoolean(value.call(source));
3929
- if (result != null) {
3930
- return result;
3931
- }
3932
- } catch (unused) {}
3933
- }
3934
- }
3935
- } catch (err) {
3936
- _didIteratorError = true;
3937
- _iteratorError = err;
3938
- } finally{
3939
- try {
3940
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3941
- _iterator.return();
3942
- }
3943
- } finally{
3944
- if (_didIteratorError) {
3945
- throw _iteratorError;
3946
- }
3947
- }
3948
- }
3949
- return void 0;
3950
- }
3951
- function readStoredDeviceId() {
3952
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3953
- try {
3954
- for(var _iterator = DEVICE_ID_STORAGE_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3955
- var key = _step.value;
3956
- var value = readStoredString(key);
3957
- if (value) {
3958
- return value;
3959
- }
3960
- }
3961
- } catch (err) {
3962
- _didIteratorError = true;
3963
- _iteratorError = err;
3964
- } finally{
3965
- try {
3966
- if (!_iteratorNormalCompletion && _iterator.return != null) {
3967
- _iterator.return();
3968
- }
3969
- } finally{
3970
- if (_didIteratorError) {
3971
- throw _iteratorError;
3972
- }
3973
- }
3974
- }
3975
- return void 0;
3976
- }
3977
- function readStoredString(key) {
3978
- if (typeof window === "undefined") {
3979
- return void 0;
3980
- }
3981
- try {
3982
- var _window_localStorage;
3983
- var value = (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key);
3984
- return value || void 0;
3985
- } catch (unused) {
3986
- return void 0;
3987
- }
3988
- }
3989
- function readStoredLimitAdTracking() {
3990
- return normalizeBoolean(readStoredString("limitAdTracking") || readStoredString("limitedAdTracking") || readStoredString("is_lat"));
3991
- }
3992
- function normalizeBoolean(value) {
3993
- if (typeof value === "boolean") {
3994
- return value;
3995
- }
3996
- if (typeof value === "number") {
3997
- return value === 1;
3998
- }
3999
- if (typeof value === "string") {
4000
- var normalized = value.toLowerCase();
4001
- if (normalized === "1" || normalized === "true" || normalized === "yes") {
4002
- return true;
4003
- }
4004
- if (normalized === "0" || normalized === "false" || normalized === "no") {
4005
- return false;
4006
- }
4007
- }
4008
- return void 0;
4009
- }
4010
- function inferDeviceIdType() {
4011
- if (typeof navigator === "undefined") {
4012
- return void 0;
4013
- }
4014
- var ua = navigator.userAgent;
4015
- if (/Roku/i.test(ua)) return "rida";
4016
- if (/Tizen|Samsung/i.test(ua)) return "tifa";
4017
- if (/AppleTV/i.test(ua)) return "tvOS";
4018
- if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
4019
- if (/Web0S|webOS|LG/i.test(ua)) return "lgudid";
4020
- if (/Android|Google TV/i.test(ua)) return "aaid";
4021
- return void 0;
4022
- }
4023
- // src/player/VmapManager.ts
4024
- var VmapManager = /*#__PURE__*/ function() {
4025
- function VmapManager(config, video) {
4026
- _class_call_check(this, VmapManager);
4312
+ // src/player/AdConfigManager.ts
4313
+ var AdConfigManager = /*#__PURE__*/ function() {
4314
+ function AdConfigManager(config, video) {
4315
+ _class_call_check(this, AdConfigManager);
4027
4316
  this.vmapBreaks = [];
4028
4317
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
4029
4318
  this.streamCorrelator = generateCorrelator();
@@ -4035,7 +4324,7 @@ var VmapManager = /*#__PURE__*/ function() {
4035
4324
  this.config = config;
4036
4325
  this.video = video;
4037
4326
  }
4038
- _create_class(VmapManager, [
4327
+ _create_class(AdConfigManager, [
4039
4328
  {
4040
4329
  key: "debug",
4041
4330
  get: function get() {
@@ -4097,7 +4386,7 @@ var VmapManager = /*#__PURE__*/ function() {
4097
4386
  ];
4098
4387
  }
4099
4388
  if (this.config.vastTagUrl) {
4100
- this.apiVastTagUrl = this.config.vastTagUrl;
4389
+ this.apiVastTagUrl = normalizeVastTagUrl(this.config.vastTagUrl);
4101
4390
  if (this.debug) {
4102
4391
  console.log("[StormcloudVideoPlayer] Using custom VAST tag URL:", this.apiVastTagUrl);
4103
4392
  }
@@ -4137,7 +4426,7 @@ var VmapManager = /*#__PURE__*/ function() {
4137
4426
  data = _state.sent();
4138
4427
  imaPayload = (_data_response = data.response) === null || _data_response === void 0 ? void 0 : (_data_response_ima = _data_response.ima) === null || _data_response_ima === void 0 ? void 0 : (_data_response_ima_publisherdeskima = _data_response_ima["publisherdesk.ima"]) === null || _data_response_ima_publisherdeskima === void 0 ? void 0 : _data_response_ima_publisherdeskima.payload;
4139
4428
  if (imaPayload) {
4140
- this.apiVastTagUrl = decodeURIComponent(imaPayload);
4429
+ this.apiVastTagUrl = normalizeVastTagUrl(imaPayload);
4141
4430
  if (this.debug) {
4142
4431
  console.log("[StormcloudVideoPlayer] Extracted VAST tag URL from /ads/web:", this.apiVastTagUrl);
4143
4432
  }
@@ -4452,24 +4741,24 @@ var VmapManager = /*#__PURE__*/ function() {
4452
4741
  for(var i = 0; i < count; i++){
4453
4742
  this.adRequestPositionInBreak++;
4454
4743
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
4455
- var ctvSignals = this.config.ctvAdRequest ? resolveCtvVastSignals() : void 0;
4744
+ var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
4456
4745
  var urlWithMacros = applyVastMacros(baseUrl, {
4457
4746
  correlator: generateCorrelator(),
4458
4747
  streamCorrelator: this.streamCorrelator,
4459
4748
  pod: this.podCounter > 0 ? this.podCounter : void 0,
4460
4749
  adPosition: this.adRequestPositionInBreak,
4461
- isCtv: this.config.ctvAdRequest,
4462
- contentUrl: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.contentUrl,
4463
- pageUrl: !this.config.ctvAdRequest && typeof window !== "undefined" ? window.location.href : void 0,
4750
+ isCtv: envSignals.isCtv,
4751
+ contentUrl: envSignals.contentUrl,
4752
+ pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
4464
4753
  adWillPlayMuted: adWillPlayMuted,
4465
4754
  adWillAutoPlay: !!this.config.autoplay,
4466
- appId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.appId,
4467
- appName: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.appName,
4468
- sessionId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.sessionId,
4469
- deviceId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceId,
4470
- deviceIdType: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceIdType,
4471
- limitAdTracking: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.limitAdTracking,
4472
- deviceTypeHint: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceTypeHint,
4755
+ appId: envSignals.appId,
4756
+ appName: envSignals.appName,
4757
+ sessionId: envSignals.sessionId,
4758
+ deviceId: envSignals.deviceId,
4759
+ deviceIdType: envSignals.deviceIdType,
4760
+ limitAdTracking: envSignals.limitAdTracking,
4761
+ deviceTypeHint: envSignals.deviceTypeHint,
4473
4762
  adTest: this.config.adTest,
4474
4763
  consent: this.consentSignals
4475
4764
  });
@@ -4522,7 +4811,7 @@ var VmapManager = /*#__PURE__*/ function() {
4522
4811
  }
4523
4812
  }
4524
4813
  ]);
4525
- return VmapManager;
4814
+ return AdConfigManager;
4526
4815
  }();
4527
4816
  // src/player/AdTimingService.ts
4528
4817
  var AdTimingService = /*#__PURE__*/ function() {
@@ -6249,7 +6538,7 @@ function resizePlayer(video, adPlayer, debug) {
6249
6538
  }
6250
6539
  // src/player/AdBreakOrchestrator.ts
6251
6540
  var AdBreakOrchestrator = /*#__PURE__*/ function() {
6252
- function AdBreakOrchestrator(host, timing, preloadPool, vmap, cueManager, placeholder) {
6541
+ function AdBreakOrchestrator(host, timing, preloadPool, adConfig, cueManager, placeholder) {
6253
6542
  _class_call_check(this, AdBreakOrchestrator);
6254
6543
  this.inAdBreak = false;
6255
6544
  this.showAds = false;
@@ -6264,7 +6553,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6264
6553
  this.host = host;
6265
6554
  this.timing = timing;
6266
6555
  this.preloadPool = preloadPool;
6267
- this.vmap = vmap;
6556
+ this.adConfig = adConfig;
6268
6557
  this.cueManager = cueManager;
6269
6558
  this.placeholder = placeholder;
6270
6559
  }
@@ -6430,7 +6719,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6430
6719
  }
6431
6720
  this.pendingAdBreak = null;
6432
6721
  this.cueManager.pendingScte35CueKey = void 0;
6433
- this.vmap.podAssignedByPrefetch = false;
6722
+ this.adConfig.podAssignedByPrefetch = false;
6434
6723
  }
6435
6724
  },
6436
6725
  {
@@ -6444,15 +6733,15 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6444
6733
  return _ts_generator(this, function(_state) {
6445
6734
  switch(_state.label){
6446
6735
  case 0:
6447
- scheduled = this.vmap.findCurrentOrNextBreak(this.host.video.currentTime * 1e3);
6736
+ scheduled = this.adConfig.findCurrentOrNextBreak(this.host.video.currentTime * 1e3);
6448
6737
  if (scheduled) {
6449
- this.vmap.consumedVmapBreakIds.add(this.vmap.getAdBreakKey(scheduled));
6738
+ this.adConfig.consumedVmapBreakIds.add(this.adConfig.getAdBreakKey(scheduled));
6450
6739
  }
6451
- tags = this.vmap.selectVastTagsForBreak(scheduled);
6740
+ tags = this.adConfig.selectVastTagsForBreak(scheduled);
6452
6741
  if (tags && tags.length > 0 && tags[0]) {
6453
6742
  baseVastUrl = tags[0];
6454
- } else if (this.vmap.apiVastTagUrl) {
6455
- baseVastUrl = this.vmap.apiVastTagUrl;
6743
+ } else if (this.adConfig.apiVastTagUrl) {
6744
+ baseVastUrl = this.adConfig.apiVastTagUrl;
6456
6745
  } else {
6457
6746
  this.clearPendingAdBreak();
6458
6747
  return [
@@ -6470,10 +6759,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6470
6759
  this.continuousFetchingActive = true;
6471
6760
  this.isShowingPlaceholder = false;
6472
6761
  this.timing.totalAdRequestsInBreak = 0;
6473
- if (this.vmap.podAssignedByPrefetch) {
6474
- this.vmap.podAssignedByPrefetch = false;
6762
+ if (this.adConfig.podAssignedByPrefetch) {
6763
+ this.adConfig.podAssignedByPrefetch = false;
6475
6764
  } else {
6476
- this.vmap.beginNewAdPod();
6765
+ this.adConfig.beginNewAdPod();
6477
6766
  }
6478
6767
  currentMuted = this.host.video.muted;
6479
6768
  currentVolume = this.host.video.volume;
@@ -7745,7 +8034,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7745
8034
  return _this.adBreak.inAdBreak;
7746
8035
  }
7747
8036
  });
7748
- this.vmap = new VmapManager(this.config, this.video);
8037
+ this.adConfig = new AdConfigManager(this.config, this.video);
7749
8038
  this.timing = new AdTimingService(this.config, this.video, {
7750
8039
  onAdStopTimerFired: function onAdStopTimerFired() {
7751
8040
  return _this.onAdStopTimerFired();
@@ -7825,7 +8114,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7825
8114
  generateVastUrls: function generateVastUrls(base, count) {
7826
8115
  return _this.generateVastUrls(base, count);
7827
8116
  }
7828
- }, this.timing, this.preloadPool, this.vmap, this.cueManager, this.placeholder);
8117
+ }, this.timing, this.preloadPool, this.adConfig, this.cueManager, this.placeholder);
7829
8118
  }
7830
8119
  _create_class(StormcloudVideoPlayer, [
7831
8120
  {
@@ -7853,7 +8142,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7853
8142
  {
7854
8143
  key: "generateVastUrls",
7855
8144
  value: function generateVastUrls(baseUrl, count) {
7856
- return this.vmap.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
8145
+ return this.adConfig.generateVastUrlsWithCorrelators(baseUrl, count, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
7857
8146
  }
7858
8147
  },
7859
8148
  {
@@ -7881,7 +8170,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7881
8170
  ]);
7882
8171
  return [
7883
8172
  4,
7884
- this.vmap.fetchAdConfiguration()
8173
+ this.adConfig.fetchAdConfiguration()
7885
8174
  ];
7886
8175
  case 2:
7887
8176
  _state.sent();
@@ -7908,9 +8197,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7908
8197
  continuousPlayback: (_this_config_lowLatencyMode = this.config.lowLatencyMode) !== null && _this_config_lowLatencyMode !== void 0 ? _this_config_lowLatencyMode : false
7909
8198
  }).catch(function() {});
7910
8199
  fetchConsentSignals().then(function(signals) {
7911
- _this.vmap.consentSignals = signals;
8200
+ _this.adConfig.consentSignals = signals;
7912
8201
  }).catch(function() {});
7913
- this.vmap.initializeTracking();
8202
+ this.adConfig.initializeTracking();
7914
8203
  if (!this.hlsEngine.shouldUseNativeHls(function() {
7915
8204
  return _this.getStreamType();
7916
8205
  })) return [
@@ -7945,14 +8234,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
7945
8234
  return _async_to_generator(function() {
7946
8235
  var prerollKey, adBehavior;
7947
8236
  return _ts_generator(this, function(_state) {
7948
- if (!this.vmap.isVmapEnabled() && !isLive && this.vmap.vmapBreaks.length === 0 && this.vmap.apiVastTagUrl) {
8237
+ if (!this.adConfig.isVmapEnabled() && !isLive && this.adConfig.vmapBreaks.length === 0 && this.adConfig.apiVastTagUrl) {
7949
8238
  prerollKey = "synthetic-vod-preroll";
7950
- if (!this.vmap.consumedVmapBreakIds.has(prerollKey)) {
7951
- this.vmap.vmapBreaks = [
8239
+ if (!this.adConfig.consumedVmapBreakIds.has(prerollKey)) {
8240
+ this.adConfig.vmapBreaks = [
7952
8241
  {
7953
8242
  id: prerollKey,
7954
8243
  startTimeMs: 0,
7955
- vastTagUrl: this.vmap.apiVastTagUrl
8244
+ vastTagUrl: this.adConfig.apiVastTagUrl
7956
8245
  }
7957
8246
  ];
7958
8247
  if (this.debug) {
@@ -8219,19 +8508,19 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8219
8508
  key: "startAdPrefetch",
8220
8509
  value: function startAdPrefetch(marker, fragmentSn, cueKey) {
8221
8510
  if (this.adBreak.pendingAdBreak || this.adBreak.inAdBreak) return;
8222
- var scheduled = this.vmap.findCurrentOrNextBreak(this.video.currentTime * 1e3);
8223
- var tags = this.vmap.selectVastTagsForBreak(scheduled);
8511
+ var scheduled = this.adConfig.findCurrentOrNextBreak(this.video.currentTime * 1e3);
8512
+ var tags = this.adConfig.selectVastTagsForBreak(scheduled);
8224
8513
  var baseVastUrl;
8225
8514
  if (tags && tags.length > 0 && tags[0]) {
8226
8515
  baseVastUrl = tags[0];
8227
- } else if (this.vmap.apiVastTagUrl) {
8228
- baseVastUrl = this.vmap.apiVastTagUrl;
8516
+ } else if (this.adConfig.apiVastTagUrl) {
8517
+ baseVastUrl = this.adConfig.apiVastTagUrl;
8229
8518
  } else {
8230
8519
  if (this.debug) console.warn("[StormcloudVideoPlayer] No VAST URL available for prefetch");
8231
8520
  return;
8232
8521
  }
8233
- this.vmap.beginNewAdPod();
8234
- this.vmap.podAssignedByPrefetch = true;
8522
+ this.adConfig.beginNewAdPod();
8523
+ this.adConfig.podAssignedByPrefetch = true;
8235
8524
  var generatedUrls = this.generateVastUrls(baseVastUrl, 1);
8236
8525
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
8237
8526
  marker: marker
@@ -8266,10 +8555,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8266
8555
  key: "onTimeUpdate",
8267
8556
  value: function onTimeUpdate(currentTimeSec) {
8268
8557
  var _this = this;
8269
- if (!this.vmap.isVmapEnabled() || this.vmap.vmapBreaks.length === 0) return;
8558
+ if (!this.adConfig.isVmapEnabled() || this.adConfig.vmapBreaks.length === 0) return;
8270
8559
  if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
8271
8560
  var nowMs = currentTimeSec * 1e3;
8272
- var breakToPlay = this.vmap.findBreakForTime(nowMs);
8561
+ var breakToPlay = this.adConfig.findBreakForTime(nowMs);
8273
8562
  if (breakToPlay) {
8274
8563
  void this.handleVmapAdBreak(breakToPlay, nowMs).catch(function(error) {
8275
8564
  if (_this.debug) {
@@ -8283,11 +8572,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8283
8572
  key: "onVideoEnded",
8284
8573
  value: function onVideoEnded() {
8285
8574
  var _this = this;
8286
- if (!this.vmap.isVmapEnabled() || this.vmap.vmapBreaks.length === 0) return;
8575
+ if (!this.adConfig.isVmapEnabled() || this.adConfig.vmapBreaks.length === 0) return;
8287
8576
  if (this.adPlayer.isAdPlaying() || this.adBreak.inAdBreak) return;
8288
8577
  var durationMs = Number.isFinite(this.video.duration) ? Math.floor(this.video.duration * 1e3) : 0;
8289
- var postroll = this.vmap.vmapBreaks.find(function(b) {
8290
- return b.startTimeMs === -1 && !_this.vmap.consumedVmapBreakIds.has(_this.vmap.getAdBreakKey(b));
8578
+ var postroll = this.adConfig.vmapBreaks.find(function(b) {
8579
+ return b.startTimeMs === -1 && !_this.adConfig.consumedVmapBreakIds.has(_this.adConfig.getAdBreakKey(b));
8291
8580
  });
8292
8581
  if (postroll) {
8293
8582
  void this.handleVmapAdBreak(postroll, durationMs).catch(function(error) {
@@ -8306,11 +8595,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8306
8595
  return _ts_generator(this, function(_state) {
8307
8596
  switch(_state.label){
8308
8597
  case 0:
8309
- key = this.vmap.getAdBreakKey(adBreak);
8310
- if (this.vmap.consumedVmapBreakIds.has(key)) return [
8598
+ key = this.adConfig.getAdBreakKey(adBreak);
8599
+ if (this.adConfig.consumedVmapBreakIds.has(key)) return [
8311
8600
  2
8312
8601
  ];
8313
- breakStartMs = this.vmap.resolveBreakStartMs(adBreak);
8602
+ breakStartMs = this.adConfig.resolveBreakStartMs(adBreak);
8314
8603
  if (breakStartMs == null) return [
8315
8604
  2
8316
8605
  ];
@@ -8321,8 +8610,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8321
8610
  3,
8322
8611
  4
8323
8612
  ];
8324
- this.vmap.consumedVmapBreakIds.add(key);
8325
- tags = this.vmap.selectVastTagsForBreak(adBreak);
8613
+ this.adConfig.consumedVmapBreakIds.add(key);
8614
+ tags = this.adConfig.selectVastTagsForBreak(adBreak);
8326
8615
  if (!tags || tags.length === 0) return [
8327
8616
  2
8328
8617
  ];
@@ -8514,7 +8803,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8514
8803
  this.video.removeEventListener("emptied", this.emptiedHandler);
8515
8804
  delete this.emptiedHandler;
8516
8805
  }
8517
- this.vmap.destroyTracking();
8806
+ this.adConfig.destroyTracking();
8518
8807
  this.hlsEngine.destroy();
8519
8808
  (_this_adPlayer = this.adPlayer) === null || _this_adPlayer === void 0 ? void 0 : _this_adPlayer.destroy();
8520
8809
  if (this.palPlaybackStarted) {