stormcloud-video-player 0.8.73 → 0.8.75

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 (61) hide show
  1. package/README.md +10 -70
  2. package/dist/stormcloud-vp.min.js +1 -1
  3. package/lib/Player.d.cts +2 -1
  4. package/lib/StormcloudPlayer.cjs +988 -273
  5. package/lib/StormcloudPlayer.cjs.map +1 -1
  6. package/lib/StormcloudPlayer.d.cts +1 -0
  7. package/lib/index.cjs +999 -278
  8. package/lib/index.cjs.map +1 -1
  9. package/lib/index.d.cts +1 -0
  10. package/lib/index.d.ts +40 -3
  11. package/lib/index.js +992 -279
  12. package/lib/index.js.map +1 -1
  13. package/lib/player/AdBreakOrchestrator.cjs +767 -67
  14. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  15. package/lib/player/AdBreakOrchestrator.d.cts +7 -9
  16. package/lib/player/AdConfigManager.cjs +315 -62
  17. package/lib/player/AdConfigManager.cjs.map +1 -1
  18. package/lib/player/AdConfigManager.d.cts +7 -12
  19. package/lib/player/AdTimingService.cjs +37 -1
  20. package/lib/player/AdTimingService.cjs.map +1 -1
  21. package/lib/player/AdTimingService.d.cts +8 -1
  22. package/lib/player/EdgePodRequest.d.cts +1 -0
  23. package/lib/player/FloorLadder.d.cts +1 -0
  24. package/lib/player/HlsEngine.d.cts +1 -0
  25. package/lib/player/OptimizedPodRequest.cjs +719 -0
  26. package/lib/player/OptimizedPodRequest.cjs.map +1 -0
  27. package/lib/player/OptimizedPodRequest.d.cts +101 -0
  28. package/lib/player/PlayerControls.d.cts +1 -0
  29. package/lib/player/Scte35CueManager.d.cts +1 -0
  30. package/lib/player/Scte35Parser.d.cts +1 -0
  31. package/lib/player/StormcloudVideoPlayer.cjs +988 -273
  32. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  33. package/lib/player/StormcloudVideoPlayer.d.cts +1 -0
  34. package/lib/player/playerTypes.d.cts +1 -0
  35. package/lib/players/HlsPlayer.cjs +988 -273
  36. package/lib/players/HlsPlayer.cjs.map +1 -1
  37. package/lib/players/HlsPlayer.d.cts +1 -0
  38. package/lib/players/index.cjs +988 -273
  39. package/lib/players/index.cjs.map +1 -1
  40. package/lib/props.d.cts +1 -0
  41. package/lib/sdk/hlsAdPlayer.cjs +316 -51
  42. package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
  43. package/lib/sdk/hlsAdPlayer.d.cts +3 -1
  44. package/lib/sdk/pal.cjs +108 -83
  45. package/lib/sdk/pal.cjs.map +1 -1
  46. package/lib/sdk/pal.d.cts +1 -0
  47. package/lib/types.d.cts +9 -2
  48. package/lib/ui/StormcloudVideoPlayer.cjs +991 -278
  49. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  50. package/lib/ui/StormcloudVideoPlayer.d.cts +1 -0
  51. package/lib/utils/ctvVastSignals.cjs +9 -7
  52. package/lib/utils/ctvVastSignals.cjs.map +1 -1
  53. package/lib/utils/tracking.cjs +17 -3
  54. package/lib/utils/tracking.cjs.map +1 -1
  55. package/lib/utils/tracking.d.cts +2 -1
  56. package/lib/utils/vastEnvironmentSignals.cjs +9 -7
  57. package/lib/utils/vastEnvironmentSignals.cjs.map +1 -1
  58. package/lib/utils/vastMacros.cjs +251 -10
  59. package/lib/utils/vastMacros.cjs.map +1 -1
  60. package/lib/utils/vastMacros.d.cts +13 -4
  61. package/package.json +5 -3
@@ -383,21 +383,20 @@ var ANDROID_ID_TYPES = /* @__PURE__ */ new Set([
383
383
  "adid"
384
384
  ]);
385
385
  function resolveVastEnvironmentSignals(isCtv) {
386
- var _ref;
387
386
  var bridgeSignals = readNativeBridgeSignals();
388
387
  var platformDevice = readPlatformNativeDeviceId();
389
- var realDeviceId = bridgeSignals.deviceId || (isCtv ? readStoredDeviceId() : void 0) || platformDevice.deviceId;
388
+ var bridgeDeviceId = validDeviceId(bridgeSignals.deviceId);
389
+ var realDeviceId = bridgeDeviceId || (isCtv ? validDeviceId(readStoredDeviceId()) : void 0) || validDeviceId(platformDevice.deviceId);
390
390
  var deviceId = realDeviceId;
391
- var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || readStoredString("idtype") || platformDevice.deviceIdType || inferDeviceIdType();
392
- var platformLat = bridgeSignals.deviceId ? bridgeSignals.limitAdTracking : platformDevice.limitAdTracking;
393
- var limitAdTracking = deviceId != null ? (_ref = platformLat !== null && platformLat !== void 0 ? platformLat : readStoredLimitAdTracking()) !== null && _ref !== void 0 ? _ref : false : void 0;
391
+ var deviceIdType = (bridgeDeviceId ? bridgeSignals.deviceIdType : void 0) || readStoredString("deviceIdType") || readStoredString("idtype") || platformDevice.deviceIdType || inferDeviceIdType();
392
+ var platformLat = bridgeDeviceId ? bridgeSignals.limitAdTracking : platformDevice.limitAdTracking;
393
+ var limitAdTracking = deviceId != null ? platformLat !== null && platformLat !== void 0 ? platformLat : readStoredLimitAdTracking() : void 0;
394
394
  if (!deviceId && isCtv) {
395
395
  var dpid = getOrCreateStoredUuid(PLAYER_ID_STORAGE_KEY);
396
396
  if (dpid) {
397
- var _ref1;
398
397
  deviceId = dpid;
399
398
  deviceIdType = "dpid";
400
- limitAdTracking = (_ref1 = platformLat !== null && platformLat !== void 0 ? platformLat : readStoredLimitAdTracking()) !== null && _ref1 !== void 0 ? _ref1 : false;
399
+ limitAdTracking = platformLat !== null && platformLat !== void 0 ? platformLat : readStoredLimitAdTracking();
401
400
  }
402
401
  }
403
402
  var deviceTypeHint = resolveDeviceTypeHint(isCtv);
@@ -762,6 +761,9 @@ function isMacroPlaceholder(value) {
762
761
  var t = value.trim();
763
762
  return !t || /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/.test(t) || /^(unknown|null|undefined|none|n\/a|\$\{[^}]+\})$/i.test(t) || ZEROED_AD_ID_PATTERNS.has(t.toLowerCase());
764
763
  }
764
+ function validDeviceId(value) {
765
+ return value && !isMacroPlaceholder(value) ? value : void 0;
766
+ }
765
767
  function isZeroedAdId(value) {
766
768
  return ZEROED_AD_ID_PATTERNS.has(value.trim().toLowerCase());
767
769
  }
@@ -1294,6 +1296,199 @@ function ensureVideoAdType(rawUrl) {
1294
1296
  return rawUrl;
1295
1297
  }
1296
1298
  }
1299
+ var SCVP_MACRO_DETECT = /\[SCVP-|%5BSCVP-|\(SCVP-|%28SCVP-/i;
1300
+ var SCVP_MACRO_PATTERN = /\[SCVP-([A-Z0-9-]+)\]|\(SCVP-([A-Z0-9-]+)\)/gi;
1301
+ var SCVP_WHOLE_VALUE_PATTERN = /^\s*(?:\[SCVP-([A-Z0-9-]+)\]|\(SCVP-([A-Z0-9-]+)\))\s*$/i;
1302
+ var NESTED_QUERY_PARAM_KEYS = /* @__PURE__ */ new Set([
1303
+ "cust_params"
1304
+ ]);
1305
+ var SCVP_POD_MACROS = /* @__PURE__ */ new Set([
1306
+ "PMND",
1307
+ "PMXD",
1308
+ "PMAD"
1309
+ ]);
1310
+ function hasScvpMacros(url) {
1311
+ return !!url && SCVP_MACRO_DETECT.test(url);
1312
+ }
1313
+ function safeDecode(value) {
1314
+ try {
1315
+ return decodeURIComponent(value.replace(/\+/g, " "));
1316
+ } catch (unused) {
1317
+ return value;
1318
+ }
1319
+ }
1320
+ function findScvpMacroNames(url) {
1321
+ if (!url) return [];
1322
+ var names = /* @__PURE__ */ new Set();
1323
+ var text = url;
1324
+ for(var pass = 0; pass < 3; pass++){
1325
+ text.replace(SCVP_MACRO_PATTERN, function(_m, bracketName, parenName) {
1326
+ names.add(String(bracketName || parenName).toUpperCase());
1327
+ return "";
1328
+ });
1329
+ var decoded = safeDecode(text);
1330
+ if (decoded === text) break;
1331
+ text = decoded;
1332
+ }
1333
+ return Array.from(names);
1334
+ }
1335
+ function resolveScvpMacroValues(ctx) {
1336
+ var _ctx_deviceId, _ctx_deviceIdType, _ctx_consent, _ctx_consent1, _ctx_consent2;
1337
+ var values = /* @__PURE__ */ new Map();
1338
+ var set = function set(name, value) {
1339
+ if (value == null) return;
1340
+ var str = String(value).trim();
1341
+ if (str) values.set(name, str);
1342
+ };
1343
+ var toFlag = function toFlag(value) {
1344
+ return value == null ? void 0 : value ? "1" : "0";
1345
+ };
1346
+ var deviceId = (_ctx_deviceId = ctx.deviceId) === null || _ctx_deviceId === void 0 ? void 0 : _ctx_deviceId.trim();
1347
+ var deviceIdType = deviceId ? ((_ctx_deviceIdType = ctx.deviceIdType) === null || _ctx_deviceIdType === void 0 ? void 0 : _ctx_deviceIdType.trim()) || inferDeviceIdType() : void 0;
1348
+ if (deviceId && deviceIdType) {
1349
+ var _toFlag;
1350
+ set("RDID", deviceId);
1351
+ set("IDTYPE", deviceIdType);
1352
+ set("IS-LAT", (_toFlag = toFlag(ctx.limitAdTracking)) !== null && _toFlag !== void 0 ? _toFlag : "0");
1353
+ }
1354
+ set("SID", ctx.sessionId);
1355
+ set("DTH", ctx.deviceTypeHint);
1356
+ set("GIVN", ctx.palNonce);
1357
+ set("CT-TI", ctx.programTitle);
1358
+ set("CT-CH", ctx.channelName);
1359
+ set("POD", ctx.pod);
1360
+ set("CORRELATOR", ctx.correlator);
1361
+ set("SCOR", ctx.streamCorrelator);
1362
+ set("VPMUTE", toFlag(ctx.adWillPlayMuted));
1363
+ if (ctx.adWillAutoPlay != null) {
1364
+ set("VPA", ctx.adWillAutoPlay ? "auto" : "click");
1365
+ }
1366
+ set("GDPR", (_ctx_consent = ctx.consent) === null || _ctx_consent === void 0 ? void 0 : _ctx_consent.gdpr);
1367
+ set("GDPR-CONSENT", (_ctx_consent1 = ctx.consent) === null || _ctx_consent1 === void 0 ? void 0 : _ctx_consent1.gdprConsent);
1368
+ set("US-PRIVACY", (_ctx_consent2 = ctx.consent) === null || _ctx_consent2 === void 0 ? void 0 : _ctx_consent2.usPrivacy);
1369
+ return values;
1370
+ }
1371
+ var keepNone = function keepNone() {
1372
+ return false;
1373
+ };
1374
+ function substituteScvpParams(params, values, unresolved, keep, nested) {
1375
+ var out = [];
1376
+ var replaceMacro = function replaceMacro(match, bracketName, parenName) {
1377
+ var name = String(bracketName || parenName).toUpperCase();
1378
+ var value = values.get(name);
1379
+ if (value != null) return value;
1380
+ if (keep(name)) return match;
1381
+ unresolved.add(name);
1382
+ return "";
1383
+ };
1384
+ params.forEach(function(value, key) {
1385
+ var whole = value.match(SCVP_WHOLE_VALUE_PATTERN);
1386
+ if (whole) {
1387
+ var name = String(whole[1] || whole[2]).toUpperCase();
1388
+ var resolved = values.get(name);
1389
+ if (resolved != null) {
1390
+ out.push([
1391
+ key,
1392
+ resolved
1393
+ ]);
1394
+ } else if (keep(name)) {
1395
+ out.push([
1396
+ key,
1397
+ value
1398
+ ]);
1399
+ } else {
1400
+ unresolved.add(name);
1401
+ }
1402
+ return;
1403
+ }
1404
+ if (!SCVP_MACRO_DETECT.test(value)) {
1405
+ out.push([
1406
+ key,
1407
+ value
1408
+ ]);
1409
+ return;
1410
+ }
1411
+ if (!nested && NESTED_QUERY_PARAM_KEYS.has(key)) {
1412
+ var inner = substituteScvpParams(new URLSearchParams(value), values, unresolved, keep, true);
1413
+ if (inner.length > 0) {
1414
+ out.push([
1415
+ key,
1416
+ inner.map(function(param) {
1417
+ var _param = _sliced_to_array(param, 2), k = _param[0], v = _param[1];
1418
+ return "".concat(encodeURIComponent(k), "=").concat(encodeURIComponent(v));
1419
+ }).join("&")
1420
+ ]);
1421
+ }
1422
+ return;
1423
+ }
1424
+ out.push([
1425
+ key,
1426
+ value.replace(SCVP_MACRO_PATTERN, replaceMacro)
1427
+ ]);
1428
+ });
1429
+ return out;
1430
+ }
1431
+ function substituteScvpMacros(baseUrl, values) {
1432
+ var keep = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : keepNone;
1433
+ var unresolved = /* @__PURE__ */ new Set();
1434
+ var url;
1435
+ try {
1436
+ url = new URL(normalizeVastTagUrl(baseUrl));
1437
+ } catch (unused) {
1438
+ var replaced = baseUrl.replace(SCVP_MACRO_PATTERN, function(match, bracketName, parenName) {
1439
+ var name = String(bracketName || parenName).toUpperCase();
1440
+ var value = values.get(name);
1441
+ if (value != null) return encodeURIComponent(value);
1442
+ if (keep(name)) return match;
1443
+ unresolved.add(name);
1444
+ return "";
1445
+ });
1446
+ return {
1447
+ url: replaced,
1448
+ unresolved: Array.from(unresolved)
1449
+ };
1450
+ }
1451
+ var entries = substituteScvpParams(url.searchParams, values, unresolved, keep, false);
1452
+ var search = new URLSearchParams();
1453
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1454
+ try {
1455
+ for(var _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1456
+ var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
1457
+ search.append(key, value);
1458
+ }
1459
+ } catch (err) {
1460
+ _didIteratorError = true;
1461
+ _iteratorError = err;
1462
+ } finally{
1463
+ try {
1464
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1465
+ _iterator.return();
1466
+ }
1467
+ } finally{
1468
+ if (_didIteratorError) {
1469
+ throw _iteratorError;
1470
+ }
1471
+ }
1472
+ }
1473
+ url.search = search.toString();
1474
+ return {
1475
+ url: url.toString(),
1476
+ unresolved: Array.from(unresolved)
1477
+ };
1478
+ }
1479
+ function applyScvpMacros(baseUrl, ctx) {
1480
+ var deferred = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : /* @__PURE__ */ new Set();
1481
+ return substituteScvpMacros(baseUrl, resolveScvpMacroValues(ctx), function(name) {
1482
+ return deferred.has(name);
1483
+ });
1484
+ }
1485
+ function stripScvpMacros(url) {
1486
+ if (findScvpMacroNames(url).length === 0) return {
1487
+ url: url,
1488
+ unresolved: []
1489
+ };
1490
+ return substituteScvpMacros(url, /* @__PURE__ */ new Map());
1491
+ }
1297
1492
  function applyVastMacros(baseUrl, ctx) {
1298
1493
  var expandedUrl = expandInlineMacroPlaceholders(baseUrl, ctx);
1299
1494
  var url;
@@ -1335,15 +1530,6 @@ function applyVastMacros(baseUrl, ctx) {
1335
1530
  }
1336
1531
  params.delete("ppos");
1337
1532
  params.delete("lip");
1338
- if (ctx.podMinDurationMs != null) {
1339
- params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
1340
- }
1341
- if (ctx.podMaxDurationMs != null) {
1342
- params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
1343
- }
1344
- if (ctx.podMaxAds != null) {
1345
- params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
1346
- }
1347
1533
  var existingUrl = params.get("url") || "";
1348
1534
  if (EXAMPLE_COM_URL.test(existingUrl)) {
1349
1535
  params.delete("url");
@@ -2173,6 +2359,309 @@ function substituteVastTrackingMacros(url) {
2173
2359
  return KNOWN_VAST_MACROS.has(name) ? "" : match;
2174
2360
  });
2175
2361
  }
2362
+ // src/player/OptimizedPodRequest.ts
2363
+ var DEFAULT_REQUEST_SAFETY_MS = 1500;
2364
+ var GAM_AD_OPPORTUNITY_DURATION_MS = 3e4;
2365
+ var POD_PARAM_KEYS = [
2366
+ "pmnd",
2367
+ "pmxd",
2368
+ "pmad"
2369
+ ];
2370
+ var POSITIVE_INT = /^[1-9]\d*$/;
2371
+ var NON_NEGATIVE_INT = /^(0|[1-9]\d*)$/;
2372
+ function nonNegativeInt(value) {
2373
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.floor(value) : void 0;
2374
+ }
2375
+ function positiveInt(value) {
2376
+ return typeof value === "number" && Number.isFinite(value) && value >= 1 ? Math.floor(value) : void 0;
2377
+ }
2378
+ function resolveAdPodConfig(config) {
2379
+ var _config_adPodConfig, _nonNegativeInt, _nonNegativeInt1, _positiveInt;
2380
+ var pod = (_config_adPodConfig = config.adPodConfig) !== null && _config_adPodConfig !== void 0 ? _config_adPodConfig : {};
2381
+ return {
2382
+ requestSafetyMs: (_nonNegativeInt = nonNegativeInt(pod.requestSafetyMs)) !== null && _nonNegativeInt !== void 0 ? _nonNegativeInt : DEFAULT_REQUEST_SAFETY_MS,
2383
+ minPodDurationMs: (_nonNegativeInt1 = nonNegativeInt(pod.minPodDurationMs)) !== null && _nonNegativeInt1 !== void 0 ? _nonNegativeInt1 : 0,
2384
+ maxAdsPerBreak: pod.maxAdsPerBreak === void 0 ? positiveInt(config.podMaxAds) : positiveInt(pod.maxAdsPerBreak),
2385
+ maxPodDurationMs: (_positiveInt = positiveInt(pod.maxPodDurationMs)) !== null && _positiveInt !== void 0 ? _positiveInt : positiveInt(config.podMaxDurationMs),
2386
+ exactDuration: config.podExactDuration === true
2387
+ };
2388
+ }
2389
+ function measureBreakCapacity(timing, nowMonoMs) {
2390
+ var _timing_breakEndMonoMs;
2391
+ var scheduled = timing.scheduledBreakDurationMs;
2392
+ if (scheduled == null || !(scheduled > 0) || timing.breakStartMonoMs == null) {
2393
+ return void 0;
2394
+ }
2395
+ var endMonoMs = (_timing_breakEndMonoMs = timing.breakEndMonoMs) !== null && _timing_breakEndMonoMs !== void 0 ? _timing_breakEndMonoMs : timing.breakStartMonoMs + scheduled;
2396
+ var untilEnd = Math.min(scheduled, endMonoMs - nowMonoMs);
2397
+ var unplayed = scheduled - Math.max(0, timing.playedDurationMs);
2398
+ return {
2399
+ scheduledBreakDurationMs: scheduled,
2400
+ elapsedBeforeGamRequestMs: Math.max(0, nowMonoMs - timing.breakStartMonoMs),
2401
+ remainingAtGamDispatchMs: Math.max(0, Math.min(untilEnd, unplayed))
2402
+ };
2403
+ }
2404
+ function resolvePodParams(input) {
2405
+ var capacity = input.capacity, config = input.config;
2406
+ var pmxd;
2407
+ var source;
2408
+ if (capacity) {
2409
+ pmxd = Math.floor(capacity.remainingAtGamDispatchMs - config.requestSafetyMs);
2410
+ source = "break_remaining";
2411
+ } else if (config.maxPodDurationMs != null) {
2412
+ pmxd = config.maxPodDurationMs;
2413
+ source = "configured_cap";
2414
+ } else if (input.tagMaxDurationMs != null) {
2415
+ pmxd = input.tagMaxDurationMs;
2416
+ source = "tag_cap";
2417
+ } else {
2418
+ return {
2419
+ kind: "omit"
2420
+ };
2421
+ }
2422
+ var minUsable = Math.max(1, Math.floor(input.minUsablePmxdMs));
2423
+ if (!Number.isFinite(pmxd) || pmxd < minUsable) {
2424
+ return {
2425
+ kind: "abort",
2426
+ reason: capacity ? "insufficient_break_capacity" : "invalid_pod_cap",
2427
+ pmxdCandidateMs: Number.isFinite(pmxd) ? pmxd : 0
2428
+ };
2429
+ }
2430
+ var pmnd = config.exactDuration ? pmxd : Math.min(config.minPodDurationMs, pmxd);
2431
+ return {
2432
+ kind: "send",
2433
+ params: {
2434
+ pmnd: pmnd,
2435
+ pmxd: pmxd,
2436
+ pmad: config.maxAdsPerBreak
2437
+ },
2438
+ source: source
2439
+ };
2440
+ }
2441
+ function podRequestAborted(reason, message, diagnostics) {
2442
+ var error = new Error("Optimized pod request not sent (".concat(reason, "): ").concat(message));
2443
+ error.podRequestAborted = true;
2444
+ error.reason = reason;
2445
+ error.diagnostics = diagnostics;
2446
+ return error;
2447
+ }
2448
+ function isPodRequestAbortedError(error) {
2449
+ return !!error && error.podRequestAborted === true;
2450
+ }
2451
+ function firstPositiveIntParam(params, key) {
2452
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2453
+ try {
2454
+ for(var _iterator = params.getAll(key)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2455
+ var value = _step.value;
2456
+ if (POSITIVE_INT.test(value.trim())) return Number(value.trim());
2457
+ }
2458
+ } catch (err) {
2459
+ _didIteratorError = true;
2460
+ _iteratorError = err;
2461
+ } finally{
2462
+ try {
2463
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2464
+ _iterator.return();
2465
+ }
2466
+ } finally{
2467
+ if (_didIteratorError) {
2468
+ throw _iteratorError;
2469
+ }
2470
+ }
2471
+ }
2472
+ return void 0;
2473
+ }
2474
+ function isOptimizedPodUrl(url) {
2475
+ if (findScvpMacroNames(url).some(function(name) {
2476
+ return SCVP_POD_MACROS.has(name);
2477
+ })) return true;
2478
+ try {
2479
+ var params = new URL(url).searchParams;
2480
+ return POD_PARAM_KEYS.some(function(key) {
2481
+ return params.has(key);
2482
+ });
2483
+ } catch (unused) {
2484
+ return false;
2485
+ }
2486
+ }
2487
+ function finalizeGamRequestUrl(rawUrl, ctx) {
2488
+ var nowEpochMs = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : Date.now();
2489
+ var optimizedPod = isOptimizedPodUrl(rawUrl);
2490
+ var capacity = ctx.capacity;
2491
+ var base = {
2492
+ breakId: ctx.breakId,
2493
+ optimizedPod: optimizedPod,
2494
+ scteBreakDurationMs: capacity === null || capacity === void 0 ? void 0 : capacity.scheduledBreakDurationMs,
2495
+ elapsedBeforeGamRequestMs: capacity === null || capacity === void 0 ? void 0 : capacity.elapsedBeforeGamRequestMs,
2496
+ remainingAtGamDispatchMs: capacity === null || capacity === void 0 ? void 0 : capacity.remainingAtGamDispatchMs,
2497
+ safetyReserveMs: ctx.config.requestSafetyMs
2498
+ };
2499
+ var decision = {
2500
+ kind: "omit"
2501
+ };
2502
+ if (optimizedPod) {
2503
+ var tagMaxDurationMs;
2504
+ try {
2505
+ tagMaxDurationMs = firstPositiveIntParam(new URL(rawUrl).searchParams, "pmxd");
2506
+ } catch (unused) {}
2507
+ decision = resolvePodParams({
2508
+ capacity: capacity,
2509
+ config: ctx.config,
2510
+ minUsablePmxdMs: ctx.minUsablePmxdMs,
2511
+ tagMaxDurationMs: tagMaxDurationMs
2512
+ });
2513
+ if (decision.kind === "abort") {
2514
+ throw podRequestAborted(decision.reason, "pmxd would be ".concat(decision.pmxdCandidateMs, "ms (minimum ").concat(ctx.minUsablePmxdMs, "ms)"), base);
2515
+ }
2516
+ }
2517
+ var pod = decision.kind === "send" ? decision.params : void 0;
2518
+ var values = /* @__PURE__ */ new Map();
2519
+ if (pod) {
2520
+ values.set("PMND", String(pod.pmnd));
2521
+ values.set("PMXD", String(pod.pmxd));
2522
+ if (pod.pmad != null) values.set("PMAD", String(pod.pmad));
2523
+ }
2524
+ var substituted = substituteScvpMacros(rawUrl, values);
2525
+ var finalUrl;
2526
+ try {
2527
+ var url = new URL(normalizeVastTagUrl(substituted.url));
2528
+ if (pod) {
2529
+ url.searchParams.set("pmnd", String(pod.pmnd));
2530
+ url.searchParams.set("pmxd", String(pod.pmxd));
2531
+ if (pod.pmad != null) url.searchParams.set("pmad", String(pod.pmad));
2532
+ else url.searchParams.delete("pmad");
2533
+ } else {
2534
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2535
+ try {
2536
+ for(var _iterator = POD_PARAM_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2537
+ var key = _step.value;
2538
+ url.searchParams.delete(key);
2539
+ }
2540
+ } catch (err) {
2541
+ _didIteratorError = true;
2542
+ _iteratorError = err;
2543
+ } finally{
2544
+ try {
2545
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2546
+ _iterator.return();
2547
+ }
2548
+ } finally{
2549
+ if (_didIteratorError) {
2550
+ throw _iteratorError;
2551
+ }
2552
+ }
2553
+ }
2554
+ }
2555
+ finalUrl = url.toString();
2556
+ } catch (unused) {
2557
+ throw podRequestAborted("invalid_url", "GAM request URL could not be parsed", base);
2558
+ }
2559
+ var problems = validateGamRequestUrl(finalUrl, {
2560
+ optimizedPod: !!pod,
2561
+ remainingMs: decision.kind === "send" && decision.source === "break_remaining" ? capacity === null || capacity === void 0 ? void 0 : capacity.remainingAtGamDispatchMs : void 0
2562
+ });
2563
+ if (problems.length > 0) {
2564
+ throw podRequestAborted("invalid_url", problems.join("; "), base);
2565
+ }
2566
+ var givn = null;
2567
+ try {
2568
+ givn = new URL(finalUrl).searchParams.get("givn");
2569
+ } catch (unused) {}
2570
+ return {
2571
+ url: finalUrl,
2572
+ diagnostics: {
2573
+ breakId: ctx.breakId,
2574
+ optimizedPod: !!pod,
2575
+ pmxdSource: decision.kind === "send" ? decision.source : void 0,
2576
+ scteBreakDurationMs: capacity === null || capacity === void 0 ? void 0 : capacity.scheduledBreakDurationMs,
2577
+ elapsedBeforeGamRequestMs: capacity === null || capacity === void 0 ? void 0 : capacity.elapsedBeforeGamRequestMs,
2578
+ remainingAtGamDispatchMs: capacity === null || capacity === void 0 ? void 0 : capacity.remainingAtGamDispatchMs,
2579
+ safetyReserveMs: ctx.config.requestSafetyMs,
2580
+ pmndSent: pod === null || pod === void 0 ? void 0 : pod.pmnd,
2581
+ pmxdSent: pod === null || pod === void 0 ? void 0 : pod.pmxd,
2582
+ pmadSent: pod === null || pod === void 0 ? void 0 : pod.pmad,
2583
+ palNoncePresent: !!givn,
2584
+ gamRequestDispatchTimestamp: new Date(nowEpochMs).toISOString(),
2585
+ strippedMacros: substituted.unresolved.filter(function(name) {
2586
+ return !SCVP_POD_MACROS.has(name);
2587
+ })
2588
+ }
2589
+ };
2590
+ }
2591
+ function validateGamRequestUrl(url, expect) {
2592
+ var problems = [];
2593
+ var leftover = findScvpMacroNames(url);
2594
+ if (leftover.length > 0) problems.push("unresolved SCVP macros: ".concat(leftover.join(", ")));
2595
+ var params;
2596
+ try {
2597
+ params = new URL(url).searchParams;
2598
+ } catch (unused) {
2599
+ return problems.concat("URL could not be parsed");
2600
+ }
2601
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2602
+ try {
2603
+ for(var _iterator = POD_PARAM_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2604
+ var key = _step.value;
2605
+ if (params.getAll(key).length > 1) problems.push("duplicate ".concat(key));
2606
+ }
2607
+ } catch (err) {
2608
+ _didIteratorError = true;
2609
+ _iteratorError = err;
2610
+ } finally{
2611
+ try {
2612
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2613
+ _iterator.return();
2614
+ }
2615
+ } finally{
2616
+ if (_didIteratorError) {
2617
+ throw _iteratorError;
2618
+ }
2619
+ }
2620
+ }
2621
+ if (!expect.optimizedPod) {
2622
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2623
+ try {
2624
+ for(var _iterator1 = POD_PARAM_KEYS[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2625
+ var key1 = _step1.value;
2626
+ if (params.has(key1)) problems.push("".concat(key1, " present on a non-pod request"));
2627
+ }
2628
+ } catch (err) {
2629
+ _didIteratorError1 = true;
2630
+ _iteratorError1 = err;
2631
+ } finally{
2632
+ try {
2633
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2634
+ _iterator1.return();
2635
+ }
2636
+ } finally{
2637
+ if (_didIteratorError1) {
2638
+ throw _iteratorError1;
2639
+ }
2640
+ }
2641
+ }
2642
+ return problems;
2643
+ }
2644
+ var pmxd = params.get("pmxd");
2645
+ var pmnd = params.get("pmnd");
2646
+ var pmad = params.get("pmad");
2647
+ if (pmxd == null || !POSITIVE_INT.test(pmxd)) problems.push("pmxd must be a positive integer (got ".concat(pmxd, ")"));
2648
+ if (pmnd == null || !NON_NEGATIVE_INT.test(pmnd)) problems.push("pmnd must be a non-negative integer (got ".concat(pmnd, ")"));
2649
+ if (pmxd != null && pmnd != null && Number(pmnd) > Number(pmxd)) problems.push("pmnd exceeds pmxd");
2650
+ if (pmad != null && !POSITIVE_INT.test(pmad)) problems.push("pmad must be a positive integer or absent (got ".concat(pmad, ")"));
2651
+ if (expect.remainingMs != null && pmxd != null && Number(pmxd) > expect.remainingMs) {
2652
+ problems.push("pmxd ".concat(pmxd, " exceeds remaining break ").concat(expect.remainingMs, "ms"));
2653
+ }
2654
+ return problems;
2655
+ }
2656
+ function computePodResponseDiagnostics(pmxdSent, vastAdCount, totalVastCreativeDurationMs) {
2657
+ var estimatedUnusedPodMs = Math.max(0, pmxdSent - totalVastCreativeDurationMs);
2658
+ return {
2659
+ vastAdCount: vastAdCount,
2660
+ totalVastCreativeDurationMs: totalVastCreativeDurationMs,
2661
+ estimatedUnusedPodMs: estimatedUnusedPodMs,
2662
+ estimatedUnmatchedCount: Math.floor(estimatedUnusedPodMs / GAM_AD_OPPORTUNITY_DURATION_MS)
2663
+ };
2664
+ }
2176
2665
  // src/sdk/hlsAdPlayer.ts
2177
2666
  var LINEAR_TRACKING_EVENTS = [
2178
2667
  "creativeView",
@@ -2253,6 +2742,7 @@ function toVastMediaErrorCode(error) {
2253
2742
  return VAST_ERROR_MEDIA_DISPLAY;
2254
2743
  }
2255
2744
  }
2745
+ var gamCredentialsMode = "include";
2256
2746
  function createHlsAdPlayer(contentVideo, options) {
2257
2747
  var _contentVideo_AD_VIDEO_PROP, _contentVideo_AD_CONTAINER_PROP, _ref;
2258
2748
  var adPlaying = false;
@@ -3124,9 +3614,9 @@ function createHlsAdPlayer(contentVideo, options) {
3124
3614
  }
3125
3615
  }
3126
3616
  function fetchVastXml(vastTagUrl) {
3127
- var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include", kind = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "gam";
3617
+ var credentials = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "include", kind = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "gam", finalizeRequestUrl = arguments.length > 3 ? arguments[3] : void 0;
3128
3618
  return _async_to_generator(function() {
3129
- var controller, timeoutId, startedAt, attempt, requestVast, response, error, error1;
3619
+ var controller, timeoutId, startedAt, attempt, resolveDispatchUrl, requestVast, response, error, error1;
3130
3620
  return _ts_generator(this, function(_state) {
3131
3621
  switch(_state.label){
3132
3622
  case 0:
@@ -3140,13 +3630,32 @@ function createHlsAdPlayer(contentVideo, options) {
3140
3630
  }, VAST_REQUEST_TIMEOUT_MS) : void 0;
3141
3631
  startedAt = Date.now();
3142
3632
  attempt = 0;
3633
+ resolveDispatchUrl = function resolveDispatchUrl() {
3634
+ if (kind === "wrapper") return vastTagUrl;
3635
+ if (finalizeRequestUrl) return finalizeRequestUrl(vastTagUrl, attempt);
3636
+ var _stripScvpMacros = stripScvpMacros(vastTagUrl), url = _stripScvpMacros.url, unresolved = _stripScvpMacros.unresolved;
3637
+ if (unresolved.length > 0) {
3638
+ console.warn("[HlsAdPlayer] Removed unresolved SCVP macros before dispatch:", unresolved.join(", "));
3639
+ }
3640
+ return url;
3641
+ };
3143
3642
  requestVast = function requestVast(creds) {
3144
3643
  return _async_to_generator(function() {
3145
- var response;
3644
+ var pending, response;
3146
3645
  return _ts_generator(this, function(_state) {
3147
3646
  switch(_state.label){
3148
3647
  case 0:
3149
3648
  attempt++;
3649
+ pending = fetch(resolveDispatchUrl(), _object_spread({
3650
+ mode: "cors",
3651
+ credentials: creds,
3652
+ headers: {
3653
+ "Accept": "application/xml, text/xml, */*"
3654
+ },
3655
+ referrerPolicy: "no-referrer-when-downgrade"
3656
+ }, controller ? {
3657
+ signal: controller.signal
3658
+ } : {}));
3150
3659
  if (kind !== "wrapper") {
3151
3660
  logFunnel("".concat(kind, "_http_request_sent"), {
3152
3661
  attempt: attempt,
@@ -3155,16 +3664,7 @@ function createHlsAdPlayer(contentVideo, options) {
3155
3664
  }
3156
3665
  return [
3157
3666
  4,
3158
- fetch(vastTagUrl, _object_spread({
3159
- mode: "cors",
3160
- credentials: creds,
3161
- headers: {
3162
- "Accept": "application/xml, text/xml, */*"
3163
- },
3164
- referrerPolicy: "no-referrer-when-downgrade"
3165
- }, controller ? {
3166
- signal: controller.signal
3167
- } : {}))
3667
+ pending
3168
3668
  ];
3169
3669
  case 1:
3170
3670
  response = _state.sent();
@@ -3188,9 +3688,9 @@ function createHlsAdPlayer(contentVideo, options) {
3188
3688
  case 1:
3189
3689
  _state.trys.push([
3190
3690
  1,
3191
- 10,
3192
- 11,
3193
- 12
3691
+ 7,
3692
+ 8,
3693
+ 9
3194
3694
  ]);
3195
3695
  _state.label = 2;
3196
3696
  case 2:
@@ -3198,7 +3698,7 @@ function createHlsAdPlayer(contentVideo, options) {
3198
3698
  2,
3199
3699
  4,
3200
3700
  ,
3201
- 8
3701
+ 5
3202
3702
  ]);
3203
3703
  return [
3204
3704
  4,
@@ -3208,36 +3708,21 @@ function createHlsAdPlayer(contentVideo, options) {
3208
3708
  response = _state.sent();
3209
3709
  return [
3210
3710
  3,
3211
- 8
3711
+ 5
3212
3712
  ];
3213
3713
  case 4:
3214
3714
  error = _state.sent();
3215
- if (!(credentials !== "omit" && !(controller === null || controller === void 0 ? void 0 : controller.signal.aborted))) return [
3216
- 3,
3217
- 6
3218
- ];
3219
- console.warn('[HlsAdPlayer] VAST fetch failed with credentials="'.concat(credentials, '", retrying without credentials:'), error);
3220
- logFunnel("vast_credentials_retry", {
3221
- errorMessage: error === null || error === void 0 ? void 0 : error.message
3222
- });
3223
- return [
3224
- 4,
3225
- requestVast("omit")
3226
- ];
3227
- case 5:
3228
- response = _state.sent();
3229
- return [
3230
- 3,
3231
- 7
3232
- ];
3233
- case 6:
3715
+ if (kind === "gam" && !(controller === null || controller === void 0 ? void 0 : controller.signal.aborted) && !isPodRequestAbortedError(error)) {
3716
+ gamCredentialsMode = credentials === "include" ? "omit" : "include";
3717
+ console.warn('[HlsAdPlayer] GAM fetch failed with credentials="'.concat(credentials, '"; next GAM request will use credentials="').concat(gamCredentialsMode, '":'), error);
3718
+ logFunnel("gam_credentials_mode_changed", {
3719
+ from: credentials,
3720
+ to: gamCredentialsMode,
3721
+ errorMessage: error === null || error === void 0 ? void 0 : error.message
3722
+ });
3723
+ }
3234
3724
  throw error;
3235
- case 7:
3236
- return [
3237
- 3,
3238
- 8
3239
- ];
3240
- case 8:
3725
+ case 5:
3241
3726
  if (!response.ok) {
3242
3727
  throw new Error("Failed to fetch VAST: HTTP ".concat(response.status, " ").concat(response.statusText));
3243
3728
  }
@@ -3245,12 +3730,12 @@ function createHlsAdPlayer(contentVideo, options) {
3245
3730
  4,
3246
3731
  response.text()
3247
3732
  ];
3248
- case 9:
3733
+ case 6:
3249
3734
  return [
3250
3735
  2,
3251
3736
  _state.sent()
3252
3737
  ];
3253
- case 10:
3738
+ case 7:
3254
3739
  error1 = _state.sent();
3255
3740
  if (controller === null || controller === void 0 ? void 0 : controller.signal.aborted) {
3256
3741
  if (pendingRequestAbortReason) {
@@ -3259,13 +3744,13 @@ function createHlsAdPlayer(contentVideo, options) {
3259
3744
  throw new Error("VAST request timeout after ".concat(VAST_REQUEST_TIMEOUT_MS, "ms: ").concat(vastTagUrl));
3260
3745
  }
3261
3746
  throw error1;
3262
- case 11:
3747
+ case 8:
3263
3748
  if (timeoutId !== void 0) clearTimeout(timeoutId);
3264
3749
  if (controller) pendingVastRequests.delete(controller);
3265
3750
  return [
3266
3751
  7
3267
3752
  ];
3268
- case 12:
3753
+ case 9:
3269
3754
  return [
3270
3755
  2
3271
3756
  ];
@@ -3398,7 +3883,7 @@ function createHlsAdPlayer(contentVideo, options) {
3398
3883
  });
3399
3884
  }
3400
3885
  function fetchAndParsePod(vastTagUrl) {
3401
- var source = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "gam";
3886
+ var source = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "gam", finalizeRequestUrl = arguments.length > 2 ? arguments[2] : void 0;
3402
3887
  return _async_to_generator(function() {
3403
3888
  var _root_getAttribute, _root_getAttribute1, isEdge, vastXml, trimmedXml, xmlDoc, root, adElements, _root_getAttribute2, _empty_errorUrls, empty, _empty_errorCode, resolveAd, candidates, podElements, buffet, resolveAll, ads, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, ad, err, _iteratorNormalCompletion1, _didIteratorError1, _iteratorError1, _iterator1, _step1, ad1, err;
3404
3889
  return _ts_generator(this, function(_state) {
@@ -3408,7 +3893,7 @@ function createHlsAdPlayer(contentVideo, options) {
3408
3893
  isEdge = source === "edge";
3409
3894
  return [
3410
3895
  4,
3411
- fetchVastXml(vastTagUrl, isEdge ? "omit" : "include", source)
3896
+ fetchVastXml(vastTagUrl, isEdge ? "omit" : gamCredentialsMode, source, finalizeRequestUrl)
3412
3897
  ];
3413
3898
  case 1:
3414
3899
  vastXml = _state.sent();
@@ -4731,7 +5216,7 @@ function createHlsAdPlayer(contentVideo, options) {
4731
5216
  case 2:
4732
5217
  return [
4733
5218
  4,
4734
- fetchAndParsePod(vastTagUrl, source)
5219
+ fetchAndParsePod(vastTagUrl, source, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.finalizeRequestUrl)
4735
5220
  ];
4736
5221
  case 3:
4737
5222
  ads = _state.sent();
@@ -5308,95 +5793,38 @@ function getOrCreateNonceLoader(allowStorage) {
5308
5793
  function createPalNonceManager() {
5309
5794
  var currentNonce = "";
5310
5795
  var currentNonceManager;
5796
+ var pendingNonce;
5311
5797
  return {
5312
5798
  generateNonce: function generateNonce() {
5313
- return _async_to_generator(function() {
5314
- var options, _options_allowStorage, _options_adWillAutoPlay, _options_adWillPlayMuted, _options_playerVolume, _options_continuousPlayback, loader, goog, request, manager, error;
5315
- var _arguments = arguments;
5316
- return _ts_generator(this, function(_state) {
5317
- switch(_state.label){
5318
- case 0:
5319
- options = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {};
5320
- _state.label = 1;
5321
- case 1:
5322
- _state.trys.push([
5323
- 1,
5324
- 4,
5325
- ,
5326
- 5
5327
- ]);
5328
- return [
5329
- 4,
5330
- loadPalSdk()
5331
- ];
5332
- case 2:
5333
- _state.sent();
5334
- loader = getOrCreateNonceLoader((_options_allowStorage = options.allowStorage) !== null && _options_allowStorage !== void 0 ? _options_allowStorage : true);
5335
- goog = window.goog;
5336
- request = new goog.pal.NonceRequest();
5337
- request.adWillAutoPlay = (_options_adWillAutoPlay = options.adWillAutoPlay) !== null && _options_adWillAutoPlay !== void 0 ? _options_adWillAutoPlay : true;
5338
- request.adWillPlayMuted = (_options_adWillPlayMuted = options.adWillPlayMuted) !== null && _options_adWillPlayMuted !== void 0 ? _options_adWillPlayMuted : false;
5339
- request.playerVolume = (_options_playerVolume = options.playerVolume) !== null && _options_playerVolume !== void 0 ? _options_playerVolume : request.adWillPlayMuted ? 0 : 1;
5340
- request.continuousPlayback = (_options_continuousPlayback = options.continuousPlayback) !== null && _options_continuousPlayback !== void 0 ? _options_continuousPlayback : true;
5341
- request.descriptionUrl = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
5342
- request.iconsSupported = true;
5343
- request.playerType = "StormcloudVideoPlayer";
5344
- request.playerVersion = "1.0";
5345
- request.supportedApiFrameworks = "2,7,9";
5346
- request.url = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
5347
- request.videoWidth = options.videoWidth || 640;
5348
- request.videoHeight = options.videoHeight || 480;
5349
- if (options.ppid) request.ppid = options.ppid;
5350
- if (options.sessionId) request.sessionId = options.sessionId;
5351
- console.log("[PAL] NonceRequest before generateNonce:", JSON.stringify({
5352
- adWillAutoPlay: request.adWillAutoPlay,
5353
- adWillPlayMuted: request.adWillPlayMuted,
5354
- playerVolume: request.playerVolume,
5355
- continuousPlayback: request.continuousPlayback,
5356
- descriptionUrl: request.descriptionUrl,
5357
- iconsSupported: request.iconsSupported,
5358
- playerType: request.playerType,
5359
- playerVersion: request.playerVersion,
5360
- supportedApiFrameworks: request.supportedApiFrameworks,
5361
- url: request.url,
5362
- videoWidth: request.videoWidth,
5363
- videoHeight: request.videoHeight,
5364
- ppid: request.ppid,
5365
- sessionId: request.sessionId
5366
- }, null, 2));
5367
- return [
5368
- 4,
5369
- loader.loadNonceManager(request)
5370
- ];
5371
- case 3:
5372
- manager = _state.sent();
5373
- currentNonceManager = manager;
5374
- currentNonce = manager.getNonce();
5375
- console.log("[PAL] Nonce generated successfully");
5376
- return [
5377
- 2,
5378
- currentNonce
5379
- ];
5380
- case 4:
5381
- error = _state.sent();
5382
- console.warn("[PAL] Failed to generate nonce:", error);
5383
- currentNonce = "";
5384
- currentNonceManager = void 0;
5385
- return [
5386
- 2,
5387
- ""
5388
- ];
5389
- case 5:
5390
- return [
5391
- 2
5392
- ];
5393
- }
5394
- });
5395
- }).apply(this, arguments);
5799
+ var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
5800
+ var run = generate(options);
5801
+ pendingNonce = run;
5802
+ var settle = function settle() {
5803
+ if (pendingNonce === run) pendingNonce = void 0;
5804
+ };
5805
+ run.then(settle, settle);
5806
+ return run;
5396
5807
  },
5397
5808
  getCurrentNonce: function getCurrentNonce() {
5398
5809
  return currentNonce;
5399
5810
  },
5811
+ waitForNonce: function waitForNonce(maxWaitMs) {
5812
+ if (currentNonce) return Promise.resolve(currentNonce);
5813
+ var pending = pendingNonce;
5814
+ if (!pending || !(maxWaitMs > 0)) return Promise.resolve("");
5815
+ return new Promise(function(resolve) {
5816
+ var timer = setTimeout(function() {
5817
+ return resolve(currentNonce);
5818
+ }, maxWaitMs);
5819
+ pending.then(function(nonce) {
5820
+ clearTimeout(timer);
5821
+ resolve(nonce);
5822
+ }, function() {
5823
+ clearTimeout(timer);
5824
+ resolve("");
5825
+ });
5826
+ });
5827
+ },
5400
5828
  injectNonce: function injectNonce(vastTagUrl) {
5401
5829
  if (!currentNonce || !vastTagUrl) return vastTagUrl;
5402
5830
  try {
@@ -5433,8 +5861,90 @@ function createPalNonceManager() {
5433
5861
  reset: function reset() {
5434
5862
  currentNonce = "";
5435
5863
  currentNonceManager = void 0;
5864
+ pendingNonce = void 0;
5436
5865
  }
5437
5866
  };
5867
+ function generate(options) {
5868
+ return _async_to_generator(function() {
5869
+ var _options_allowStorage, _options_adWillAutoPlay, _options_adWillPlayMuted, _options_playerVolume, _options_continuousPlayback, loader, goog, request, manager, error;
5870
+ return _ts_generator(this, function(_state) {
5871
+ switch(_state.label){
5872
+ case 0:
5873
+ _state.trys.push([
5874
+ 0,
5875
+ 3,
5876
+ ,
5877
+ 4
5878
+ ]);
5879
+ return [
5880
+ 4,
5881
+ loadPalSdk()
5882
+ ];
5883
+ case 1:
5884
+ _state.sent();
5885
+ loader = getOrCreateNonceLoader((_options_allowStorage = options.allowStorage) !== null && _options_allowStorage !== void 0 ? _options_allowStorage : true);
5886
+ goog = window.goog;
5887
+ request = new goog.pal.NonceRequest();
5888
+ request.adWillAutoPlay = (_options_adWillAutoPlay = options.adWillAutoPlay) !== null && _options_adWillAutoPlay !== void 0 ? _options_adWillAutoPlay : true;
5889
+ request.adWillPlayMuted = (_options_adWillPlayMuted = options.adWillPlayMuted) !== null && _options_adWillPlayMuted !== void 0 ? _options_adWillPlayMuted : false;
5890
+ request.playerVolume = (_options_playerVolume = options.playerVolume) !== null && _options_playerVolume !== void 0 ? _options_playerVolume : request.adWillPlayMuted ? 0 : 1;
5891
+ request.continuousPlayback = (_options_continuousPlayback = options.continuousPlayback) !== null && _options_continuousPlayback !== void 0 ? _options_continuousPlayback : true;
5892
+ request.descriptionUrl = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
5893
+ request.iconsSupported = true;
5894
+ request.playerType = "StormcloudVideoPlayer";
5895
+ request.playerVersion = "1.0";
5896
+ request.supportedApiFrameworks = "2,7,9";
5897
+ request.url = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
5898
+ request.videoWidth = options.videoWidth || 640;
5899
+ request.videoHeight = options.videoHeight || 480;
5900
+ if (options.ppid) request.ppid = options.ppid;
5901
+ if (options.sessionId) request.sessionId = options.sessionId;
5902
+ console.log("[PAL] NonceRequest before generateNonce:", JSON.stringify({
5903
+ adWillAutoPlay: request.adWillAutoPlay,
5904
+ adWillPlayMuted: request.adWillPlayMuted,
5905
+ playerVolume: request.playerVolume,
5906
+ continuousPlayback: request.continuousPlayback,
5907
+ descriptionUrl: request.descriptionUrl,
5908
+ iconsSupported: request.iconsSupported,
5909
+ playerType: request.playerType,
5910
+ playerVersion: request.playerVersion,
5911
+ supportedApiFrameworks: request.supportedApiFrameworks,
5912
+ url: request.url,
5913
+ videoWidth: request.videoWidth,
5914
+ videoHeight: request.videoHeight,
5915
+ ppid: request.ppid,
5916
+ sessionId: request.sessionId
5917
+ }, null, 2));
5918
+ return [
5919
+ 4,
5920
+ loader.loadNonceManager(request)
5921
+ ];
5922
+ case 2:
5923
+ manager = _state.sent();
5924
+ currentNonceManager = manager;
5925
+ currentNonce = manager.getNonce();
5926
+ console.log("[PAL] Nonce generated successfully");
5927
+ return [
5928
+ 2,
5929
+ currentNonce
5930
+ ];
5931
+ case 3:
5932
+ error = _state.sent();
5933
+ console.warn("[PAL] Failed to generate nonce:", error);
5934
+ currentNonce = "";
5935
+ currentNonceManager = void 0;
5936
+ return [
5937
+ 2,
5938
+ ""
5939
+ ];
5940
+ case 4:
5941
+ return [
5942
+ 2
5943
+ ];
5944
+ }
5945
+ });
5946
+ })();
5947
+ }
5438
5948
  }
5439
5949
  // src/utils/trackingIngest.ts
5440
5950
  var DEFAULT_TRACKING_INGEST_CONFIG = {
@@ -5517,7 +6027,14 @@ function ingestPlayerTracking(licenseKey, channel, body) {
5517
6027
  // src/utils/tracking.ts
5518
6028
  var cachedBrowserId = null;
5519
6029
  function buildAnalyticsContext(config) {
6030
+ var _config_contentNetwork, _config_channelName, _config_programTitle;
5520
6031
  var context = {};
6032
+ var contentNetwork = (_config_contentNetwork = config.contentNetwork) === null || _config_contentNetwork === void 0 ? void 0 : _config_contentNetwork.trim();
6033
+ var contentChannel = (_config_channelName = config.channelName) === null || _config_channelName === void 0 ? void 0 : _config_channelName.trim();
6034
+ var contentTitle = (_config_programTitle = config.programTitle) === null || _config_programTitle === void 0 ? void 0 : _config_programTitle.trim();
6035
+ if (contentNetwork) context.contentNetwork = contentNetwork;
6036
+ if (contentChannel) context.contentChannel = contentChannel;
6037
+ if (contentTitle) context.contentTitle = contentTitle;
5521
6038
  if (config.debugAdTiming) {
5522
6039
  context.debugAdTiming = true;
5523
6040
  }
@@ -6008,12 +6525,19 @@ function sendAdImpressionTracking(_0, _1) {
6008
6525
  4,
6009
6526
  ingestPlayerTracking(licenseKey, "impressions", {
6010
6527
  events: [
6011
- {
6528
+ _object_spread({
6012
6529
  player_id: metricEvent.player_id,
6013
6530
  ad_played_count: 1,
6014
6531
  ad_url: adImpressionInfo.adUrl,
6015
- capture_at: adImpressionInfo.timestamp
6016
- }
6532
+ capture_at: adImpressionInfo.timestamp,
6533
+ source: "gam"
6534
+ }, context.contentNetwork ? {
6535
+ content_network: context.contentNetwork
6536
+ } : {}, context.contentChannel ? {
6537
+ content_channel: context.contentChannel
6538
+ } : {}, context.contentTitle ? {
6539
+ content_title: context.contentTitle
6540
+ } : {})
6017
6541
  ]
6018
6542
  })
6019
6543
  ];
@@ -7362,6 +7886,21 @@ var Scte35CueManager = /*#__PURE__*/ function() {
7362
7886
  return Scte35CueManager;
7363
7887
  }();
7364
7888
  // src/player/AdConfigManager.ts
7889
+ function withDeferredPodParams(rawUrl, deferNonce) {
7890
+ try {
7891
+ var url = new URL(rawUrl);
7892
+ url.searchParams.set("pmnd", "[SCVP-PMND]");
7893
+ url.searchParams.set("pmxd", "[SCVP-PMXD]");
7894
+ url.searchParams.set("pmad", "[SCVP-PMAD]");
7895
+ if (deferNonce && !url.searchParams.get("givn")) {
7896
+ url.searchParams.delete("paln");
7897
+ url.searchParams.set("givn", "[SCVP-GIVN]");
7898
+ }
7899
+ return url.toString();
7900
+ } catch (unused) {
7901
+ return rawUrl;
7902
+ }
7903
+ }
7365
7904
  var AdConfigManager = /*#__PURE__*/ function() {
7366
7905
  function AdConfigManager(config, video) {
7367
7906
  _class_call_check(this, AdConfigManager);
@@ -7372,8 +7911,8 @@ var AdConfigManager = /*#__PURE__*/ function() {
7372
7911
  this.podCounter = 0;
7373
7912
  this.podAssignedByPrefetch = false;
7374
7913
  this.lastHeartbeatTime = 0;
7375
- this.defaultPodMaxAds = 6;
7376
- this.defaultPodMaxDurationMs = 12e4;
7914
+ this.defaultEdgePodMaxAds = 6;
7915
+ this.palNonceDispatchWaitMs = 1500;
7377
7916
  this.config = config;
7378
7917
  this.video = video;
7379
7918
  }
@@ -7401,7 +7940,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
7401
7940
  key: "fetchAdConfiguration",
7402
7941
  value: function fetchAdConfiguration() {
7403
7942
  return _async_to_generator(function() {
7404
- var _data_response_ima_publisherdeskima, _data_response_ima, _data_response, _data_response_options_vast_cue_tones, _data_response_options_vast, _data_response_options, _data_response1, vastMode, vastEndpoint, apiUrl, headers, response, data, imaPayload, decodedPayload, numberAds;
7943
+ var _data_response_ima_publisherdeskima, _data_response_ima, _data_response, _data_response_options_vast_cue_tones, _data_response_options_vast, _data_response_options, _data_response1, apiUrl, headers, response, data, imaPayload, decodedPayload, numberAds;
7405
7944
  return _ts_generator(this, function(_state) {
7406
7945
  switch(_state.label){
7407
7946
  case 0:
@@ -7422,28 +7961,6 @@ var AdConfigManager = /*#__PURE__*/ function() {
7422
7961
  2
7423
7962
  ];
7424
7963
  case 2:
7425
- vastMode = this.config.vastMode || "default";
7426
- if (this.debug) {
7427
- console.log("[StormcloudVideoPlayer] VAST mode:", vastMode);
7428
- }
7429
- if (vastMode === "adstorm") {
7430
- if (!this.config.licenseKey) {
7431
- if (this.debug) {
7432
- console.warn("[StormcloudVideoPlayer] AdStorm mode requires a license key");
7433
- }
7434
- return [
7435
- 2
7436
- ];
7437
- }
7438
- vastEndpoint = "https://adstorm.co/api-adstorm-dev/adstorm/vast/".concat(this.config.licenseKey);
7439
- this.apiVastTagUrl = vastEndpoint;
7440
- if (this.debug) {
7441
- console.log("[StormcloudVideoPlayer] Using AdStorm VAST endpoint (adstorm mode):", vastEndpoint);
7442
- }
7443
- return [
7444
- 2
7445
- ];
7446
- }
7447
7964
  if (this.config.vastTagUrl) {
7448
7965
  this.apiVastTagUrl = normalizeVastTagUrl(this.config.vastTagUrl);
7449
7966
  if (this.debug) {
@@ -7453,7 +7970,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
7453
7970
  2
7454
7971
  ];
7455
7972
  }
7456
- apiUrl = "https://adstorm.co/api-adstorm-dev/adstorm/ads/web";
7973
+ apiUrl = "https://edge.stormcloudhub.com/api/v1/adstorm/ads/web";
7457
7974
  if (this.debug) {
7458
7975
  console.log("[StormcloudVideoPlayer] Fetching ad configuration from:", apiUrl);
7459
7976
  }
@@ -7800,16 +8317,16 @@ var AdConfigManager = /*#__PURE__*/ function() {
7800
8317
  }
7801
8318
  },
7802
8319
  {
7803
- key: "resolvePodParams",
7804
- value: function resolvePodParams(breakDurationMs) {
7805
- var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs != null && this.config.podMaxDurationMs > 0 ? this.config.podMaxDurationMs : this.defaultPodMaxDurationMs;
7806
- var maxAds = this.config.podMaxAds && this.config.podMaxAds > 0 ? this.config.podMaxAds : this.apiNumberAds && this.apiNumberAds > 0 ? this.apiNumberAds : this.defaultPodMaxAds;
7807
- var minDurationMs = this.config.podExactDuration && maxDurationMs != null ? maxDurationMs : 0;
7808
- return {
7809
- maxAds: maxAds,
7810
- minDurationMs: minDurationMs,
7811
- maxDurationMs: maxDurationMs
7812
- };
8320
+ key: "resolveAdPodConfig",
8321
+ value: function resolveAdPodConfig1() {
8322
+ return resolveAdPodConfig(this.config);
8323
+ }
8324
+ },
8325
+ {
8326
+ key: "resolveEdgeMaxAds",
8327
+ value: function resolveEdgeMaxAds() {
8328
+ var _this_resolveAdPodConfig_maxAdsPerBreak;
8329
+ return (_this_resolveAdPodConfig_maxAdsPerBreak = this.resolveAdPodConfig().maxAdsPerBreak) !== null && _this_resolveAdPodConfig_maxAdsPerBreak !== void 0 ? _this_resolveAdPodConfig_maxAdsPerBreak : this.apiNumberAds && this.apiNumberAds > 0 ? this.apiNumberAds : this.defaultEdgePodMaxAds;
7813
8330
  }
7814
8331
  },
7815
8332
  {
@@ -7826,17 +8343,13 @@ var AdConfigManager = /*#__PURE__*/ function() {
7826
8343
  },
7827
8344
  {
7828
8345
  key: "generatePodVastUrl",
7829
- value: function generatePodVastUrl(baseUrl, podParams, adPlayer, palNonce, inAdBreak) {
7830
- var _podParams_maxDurationMs;
8346
+ value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
7831
8347
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
7832
8348
  var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
7833
- var urlWithMacros = applyVastMacros(baseUrl, _object_spread_props(_object_spread({
8349
+ var macroContext = _object_spread_props(_object_spread({
7834
8350
  correlator: this.viewCorrelator,
7835
8351
  streamCorrelator: this.streamCorrelator,
7836
8352
  pod: this.podCounter > 0 ? this.podCounter : void 0,
7837
- podMaxAds: podParams.maxAds,
7838
- podMinDurationMs: podParams.minDurationMs,
7839
- podMaxDurationMs: podParams.maxDurationMs,
7840
8353
  isCtv: envSignals.isCtv,
7841
8354
  pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? toDevSafeUrl(window.location.href) : void 0,
7842
8355
  adWillPlayMuted: adWillPlayMuted,
@@ -7852,13 +8365,72 @@ var AdConfigManager = /*#__PURE__*/ function() {
7852
8365
  } : {}, this.config.channelName ? {
7853
8366
  channelName: this.config.channelName
7854
8367
  } : {}), {
7855
- consent: this.consentSignals
7856
- }));
7857
- var finalUrl = palNonce.injectNonce(ensureVideoAdType(urlWithMacros));
7858
- console.log("[StormcloudVideoPlayer] Resolved optimized-pod request URL (pod=".concat(this.podCounter, ", pmad=").concat(podParams.maxAds, ", pmnd=").concat(podParams.minDurationMs, ", pmxd=").concat((_podParams_maxDurationMs = podParams.maxDurationMs) !== null && _podParams_maxDurationMs !== void 0 ? _podParams_maxDurationMs : "?", "):"), finalUrl);
8368
+ consent: this.consentSignals,
8369
+ palNonce: palNonce.getCurrentNonce() || void 0
8370
+ });
8371
+ var nonceReady = !!macroContext.palNonce;
8372
+ var finalUrl;
8373
+ if (hasScvpMacros(baseUrl)) {
8374
+ var deferred = new Set(SCVP_POD_MACROS);
8375
+ if (!nonceReady) deferred.add("GIVN");
8376
+ var _applyScvpMacros = applyScvpMacros(baseUrl, macroContext, deferred), url = _applyScvpMacros.url, unresolved = _applyScvpMacros.unresolved;
8377
+ if (unresolved.length > 0) {
8378
+ console.warn("[StormcloudVideoPlayer] Unresolved SCVP macros (removed from request):", unresolved.join(", "));
8379
+ }
8380
+ finalUrl = ensureVideoAdType(url);
8381
+ } else {
8382
+ finalUrl = withDeferredPodParams(palNonce.injectNonce(ensureVideoAdType(applyVastMacros(baseUrl, macroContext))), !nonceReady);
8383
+ }
8384
+ console.log("[StormcloudVideoPlayer] Prepared optimized-pod request URL (pod=".concat(this.podCounter, "; pmnd/pmxd/pmad resolved at dispatch):"), finalUrl);
7859
8385
  return finalUrl;
7860
8386
  }
7861
8387
  },
8388
+ {
8389
+ key: "completeDeferredRequestSignals",
8390
+ value: function completeDeferredRequestSignals(url, palNonce) {
8391
+ return _async_to_generator(function() {
8392
+ var nonce, _tmp;
8393
+ return _ts_generator(this, function(_state) {
8394
+ switch(_state.label){
8395
+ case 0:
8396
+ if (findScvpMacroNames(url).indexOf("GIVN") === -1) return [
8397
+ 2,
8398
+ url
8399
+ ];
8400
+ _tmp = palNonce.getCurrentNonce();
8401
+ if (_tmp) return [
8402
+ 3,
8403
+ 2
8404
+ ];
8405
+ return [
8406
+ 4,
8407
+ palNonce.waitForNonce(this.palNonceDispatchWaitMs)
8408
+ ];
8409
+ case 1:
8410
+ _tmp = _state.sent();
8411
+ _state.label = 2;
8412
+ case 2:
8413
+ nonce = _tmp;
8414
+ if (!nonce) return [
8415
+ 2,
8416
+ url
8417
+ ];
8418
+ return [
8419
+ 2,
8420
+ substituteScvpMacros(url, /* @__PURE__ */ new Map([
8421
+ [
8422
+ "GIVN",
8423
+ nonce
8424
+ ]
8425
+ ]), function(name) {
8426
+ return name !== "GIVN";
8427
+ }).url
8428
+ ];
8429
+ }
8430
+ });
8431
+ }).call(this);
8432
+ }
8433
+ },
7862
8434
  {
7863
8435
  // --- Tracking ---
7864
8436
  key: "initializeTracking",
@@ -7906,6 +8478,9 @@ var AdConfigManager = /*#__PURE__*/ function() {
7906
8478
  return AdConfigManager;
7907
8479
  }();
7908
8480
  // src/player/AdTimingService.ts
8481
+ function monotonicNow() {
8482
+ return typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
8483
+ }
7909
8484
  var AdTimingService = /*#__PURE__*/ function() {
7910
8485
  function AdTimingService(config, video, callbacks) {
7911
8486
  _class_call_check(this, AdTimingService);
@@ -8036,6 +8611,21 @@ var AdTimingService = /*#__PURE__*/ function() {
8036
8611
  },
8037
8612
  {
8038
8613
  // --- Duration boundary ---
8614
+ key: "beginBreakTiming",
8615
+ value: function beginBreakTiming(startWallClockMs) {
8616
+ this.currentAdBreakStartWallClockMs = startWallClockMs;
8617
+ this.breakStartMonoMs = monotonicNow() + (startWallClockMs - Date.now());
8618
+ this.breakEndMonoMs = void 0;
8619
+ }
8620
+ },
8621
+ {
8622
+ key: "markBreakEndedNow",
8623
+ value: function markBreakEndedNow() {
8624
+ this.scteAdBreakEndWallClockMs = Date.now();
8625
+ this.breakEndMonoMs = monotonicNow();
8626
+ }
8627
+ },
8628
+ {
8039
8629
  key: "setAdBreakDurationBoundary",
8040
8630
  value: function setAdBreakDurationBoundary(durationMs) {
8041
8631
  this.expectedAdBreakDurationMs = durationMs;
@@ -8044,6 +8634,18 @@ var AdTimingService = /*#__PURE__*/ function() {
8044
8634
  } else {
8045
8635
  this.scteAdBreakEndWallClockMs = void 0;
8046
8636
  }
8637
+ this.breakEndMonoMs = durationMs != null && this.breakStartMonoMs != null ? this.breakStartMonoMs + durationMs : void 0;
8638
+ }
8639
+ },
8640
+ {
8641
+ key: "getBreakTimingSnapshot",
8642
+ value: function getBreakTimingSnapshot() {
8643
+ return {
8644
+ scheduledBreakDurationMs: this.expectedAdBreakDurationMs,
8645
+ breakStartMonoMs: this.breakStartMonoMs,
8646
+ breakEndMonoMs: this.breakEndMonoMs,
8647
+ playedDurationMs: this.adBreakPlayedDurationMs
8648
+ };
8047
8649
  }
8048
8650
  },
8049
8651
  {
@@ -8457,6 +9059,8 @@ var AdTimingService = /*#__PURE__*/ function() {
8457
9059
  this.expectedAdBreakDurationMs = void 0;
8458
9060
  this.currentAdBreakStartWallClockMs = void 0;
8459
9061
  this.scteAdBreakEndWallClockMs = void 0;
9062
+ this.breakStartMonoMs = void 0;
9063
+ this.breakEndMonoMs = void 0;
8460
9064
  this.adBreakPlayedDurationMs = 0;
8461
9065
  this.currentAdIndex = 0;
8462
9066
  this.totalAdsInBreak = 0;
@@ -9470,9 +10074,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9470
10074
  // ───────────────────────────────────────────────────────────────
9471
10075
  key: "nextAdRequestUrl",
9472
10076
  value: function nextAdRequestUrl(baseVastUrl) {
9473
- var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
9474
- var breakDurationMs = remaining > 0 ? remaining : void 0;
9475
- return this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
10077
+ return this.host.generatePodVastUrl(baseVastUrl);
9476
10078
  }
9477
10079
  },
9478
10080
  {
@@ -9735,7 +10337,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9735
10337
  key: "handleAdStart",
9736
10338
  value: function handleAdStart(marker) {
9737
10339
  return _async_to_generator(function() {
9738
- var baseVastUrl, edgeConfigured, adBreakDurationMs, currentMuted, currentVolume, epoch, hasPrefetchedUrl, mode, edgeUrl, outcome, podPlayed;
10340
+ var baseVastUrl, edgeConfigured, adBreakDurationMs, currentMuted, currentVolume, epoch, mode, edgeUrl, outcome, podPlayed;
9739
10341
  return _ts_generator(this, function(_state) {
9740
10342
  switch(_state.label){
9741
10343
  case 0:
@@ -9787,8 +10389,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9787
10389
  }
9788
10390
  this.noteOpportunity("scte35", this.cueManager.activeScte35BreakKey, "midroll");
9789
10391
  epoch = this.timing.adBreakEpoch;
9790
- hasPrefetchedUrl = !!(this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0);
9791
- if (!(adBreakDurationMs == null && (!hasPrefetchedUrl || edgeConfigured))) return [
10392
+ if (!(adBreakDurationMs == null)) return [
9792
10393
  3,
9793
10394
  2
9794
10395
  ];
@@ -9844,7 +10445,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9844
10445
  }
9845
10446
  return [
9846
10447
  4,
9847
- this.startOptimizedPod(baseVastUrl, adBreakDurationMs)
10448
+ this.startOptimizedPod(baseVastUrl)
9848
10449
  ];
9849
10450
  case 6:
9850
10451
  podPlayed = _state.sent();
@@ -9912,9 +10513,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9912
10513
  value: // ───────────────────────────────────────────────────────────────
9913
10514
  // Optimized pod (single multi-ad request)
9914
10515
  // ───────────────────────────────────────────────────────────────
9915
- function startOptimizedPod(baseVastUrl, breakDurationMs) {
10516
+ function startOptimizedPod(baseVastUrl) {
9916
10517
  return _async_to_generator(function() {
9917
- var podUrl, prefetched, epoch, generation, adPlayer, requestToken, requestUrl, _ref, _adPlayer_getPodAdCount, podCount, error;
10518
+ var podUrl, prefetched, epoch, generation, adPlayer, requestToken, requestUrl, _ref, _this_currentVastUrl, _adPlayer_getPodAdCount, finalizeRequestUrl, podCount, error;
9918
10519
  return _ts_generator(this, function(_state) {
9919
10520
  switch(_state.label){
9920
10521
  case 0:
@@ -9923,7 +10524,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9923
10524
  podUrl = this.pendingAdBreak.vastUrls[0];
9924
10525
  this.clearPendingAdBreak();
9925
10526
  } else {
9926
- podUrl = this.host.generatePodVastUrl(baseVastUrl, breakDurationMs);
10527
+ podUrl = this.host.generatePodVastUrl(baseVastUrl);
9927
10528
  }
9928
10529
  if (!podUrl) {
9929
10530
  return [
@@ -9947,9 +10548,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9947
10548
  case 1:
9948
10549
  _state.trys.push([
9949
10550
  1,
9950
- 5,
10551
+ 9,
9951
10552
  ,
9952
- 6
10553
+ 10
9953
10554
  ]);
9954
10555
  return [
9955
10556
  4,
@@ -9961,15 +10562,46 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9961
10562
  2,
9962
10563
  true
9963
10564
  ];
10565
+ return [
10566
+ 4,
10567
+ this.host.completeGamRequestSignals(requestUrl)
10568
+ ];
10569
+ case 3:
10570
+ requestUrl = _state.sent();
10571
+ if (this.isStale(epoch, generation)) return [
10572
+ 2,
10573
+ true
10574
+ ];
9964
10575
  this.timing.startAdRequestWatchdog(requestToken);
10576
+ finalizeRequestUrl = this.createGamDispatchFinalizer(requestToken);
10577
+ _state.label = 4;
10578
+ case 4:
10579
+ _state.trys.push([
10580
+ 4,
10581
+ ,
10582
+ 6,
10583
+ 7
10584
+ ]);
9965
10585
  return [
9966
10586
  4,
9967
10587
  this.callController(function() {
9968
- return adPlayer.requestAds(requestUrl);
10588
+ return adPlayer.requestAds(requestUrl, {
10589
+ finalizeRequestUrl: finalizeRequestUrl
10590
+ });
9969
10591
  })
9970
10592
  ];
9971
- case 3:
10593
+ case 5:
9972
10594
  _state.sent();
10595
+ return [
10596
+ 3,
10597
+ 7
10598
+ ];
10599
+ case 6:
10600
+ this.recordPodResponseDiagnostics(requestToken, adPlayer);
10601
+ return [
10602
+ 7
10603
+ ];
10604
+ case 7:
9973
10605
  this.timing.clearAdRequestWatchdog();
9974
10606
  if (this.isStale(epoch, generation)) {
9975
10607
  this.logOrchestratorFunnel("stale_request_result_ignored", {
@@ -9997,7 +10629,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
9997
10629
  }
9998
10630
  sendAdLoadedTracking(this.host.config.licenseKey, {
9999
10631
  source: "hls",
10000
- vastUrl: requestUrl,
10632
+ vastUrl: (_this_currentVastUrl = this.currentVastUrl) !== null && _this_currentVastUrl !== void 0 ? _this_currentVastUrl : requestUrl,
10001
10633
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
10002
10634
  }, this.analyticsContext).catch(function() {});
10003
10635
  this.timing.startAdFailsafeTimer(requestToken);
@@ -10007,7 +10639,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10007
10639
  return adPlayer.play();
10008
10640
  })
10009
10641
  ];
10010
- case 4:
10642
+ case 8:
10011
10643
  _state.sent();
10012
10644
  if (this.isStale(epoch, generation)) return [
10013
10645
  2,
@@ -10021,7 +10653,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10021
10653
  2,
10022
10654
  true
10023
10655
  ];
10024
- case 5:
10656
+ case 9:
10025
10657
  error = _state.sent();
10026
10658
  this.timing.clearAdRequestWatchdog();
10027
10659
  this.timing.clearAdFailsafeTimer();
@@ -10041,12 +10673,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10041
10673
  if (this.debug) {
10042
10674
  console.warn("[POD] Optimized pod request/play failed:", error);
10043
10675
  }
10676
+ if (this.handlePodRequestNotSent(error)) return [
10677
+ 2,
10678
+ false
10679
+ ];
10044
10680
  this.recordRequestFailure(error, podUrl);
10045
10681
  return [
10046
10682
  2,
10047
10683
  false
10048
10684
  ];
10049
- case 6:
10685
+ case 10:
10050
10686
  return [
10051
10687
  2
10052
10688
  ];
@@ -10092,17 +10728,12 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10092
10728
  }
10093
10729
  },
10094
10730
  {
10095
- /**
10096
- * Builds the next Edge request from the budget left right now, or marks Edge
10097
- * exhausted for this break. Synchronous on purpose: callers must reach the
10098
- * REQUESTING state in the same tick so a second completion event cannot race
10099
- * in a parallel request.
10100
- */ key: "prepareEdgePodRequest",
10731
+ key: "prepareEdgePodRequest",
10101
10732
  value: function prepareEdgePodRequest() {
10102
10733
  var baseUrl = this.host.getEdgePodBaseUrl();
10103
10734
  if (!baseUrl) return void 0;
10104
10735
  var remainingMs = this.timing.getRemainingAdMs();
10105
- var remainingAds = Math.min(EDGE_POD_MAX_ADS, this.adConfig.resolvePodParams().maxAds - this.timing.totalAdsInBreak);
10736
+ var remainingAds = Math.min(EDGE_POD_MAX_ADS, this.adConfig.resolveEdgeMaxAds() - this.timing.totalAdsInBreak);
10106
10737
  if (remainingAds < 1) {
10107
10738
  this.markEdgeExhausted("ad_capacity_reached", {
10108
10739
  adsInBreak: this.timing.totalAdsInBreak
@@ -10181,7 +10812,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10181
10812
  ];
10182
10813
  }
10183
10814
  remainingMs = this.timing.getRemainingAdMs();
10184
- remainingAds = Math.max(1, Math.min(EDGE_POD_MAX_ADS, this.adConfig.resolvePodParams().maxAds - this.timing.totalAdsInBreak));
10815
+ remainingAds = Math.max(1, Math.min(EDGE_POD_MAX_ADS, this.adConfig.resolveEdgeMaxAds() - this.timing.totalAdsInBreak));
10185
10816
  overrunAllowanceMs = Math.max(0, (_this_host_config_maxAdBreakExtensionMs = this.host.config.maxAdBreakExtensionMs) !== null && _this_host_config_maxAdBreakExtensionMs !== void 0 ? _this_host_config_maxAdBreakExtensionMs : 0);
10186
10817
  podCount = adPlayer.limitPodToBudget ? adPlayer.limitPodToBudget(remainingMs + overrunAllowanceMs, remainingAds) : (_ref = (_adPlayer_getPodAdCount = adPlayer.getPodAdCount) === null || _adPlayer_getPodAdCount === void 0 ? void 0 : _adPlayer_getPodAdCount.call(adPlayer)) !== null && _ref !== void 0 ? _ref : 0;
10187
10818
  if (classifyEdgeVastResponse({
@@ -10528,7 +11159,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10528
11159
  {
10529
11160
  key: "noteVastUrlGenerated",
10530
11161
  value: function noteVastUrlGenerated(url, source) {
10531
- var _ref, _ref1, _ref2, _ref3, _ref4;
11162
+ var _ref, _ref1;
10532
11163
  var params;
10533
11164
  try {
10534
11165
  params = new URL(url).searchParams;
@@ -10538,9 +11169,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10538
11169
  requestId: void 0,
10539
11170
  source: source,
10540
11171
  pod: (_ref1 = params === null || params === void 0 ? void 0 : params.get("pod")) !== null && _ref1 !== void 0 ? _ref1 : void 0,
10541
- pmad: (_ref2 = params === null || params === void 0 ? void 0 : params.get("pmad")) !== null && _ref2 !== void 0 ? _ref2 : void 0,
10542
- pmnd: (_ref3 = params === null || params === void 0 ? void 0 : params.get("pmnd")) !== null && _ref3 !== void 0 ? _ref3 : void 0,
10543
- pmxd: (_ref4 = params === null || params === void 0 ? void 0 : params.get("pmxd")) !== null && _ref4 !== void 0 ? _ref4 : void 0,
11172
+ podParamsDeferredToDispatch: findScvpMacroNames(url).some(function(name) {
11173
+ return SCVP_POD_MACROS.has(name);
11174
+ }),
10544
11175
  adType: adType
10545
11176
  });
10546
11177
  if (adType === "audio" || adType === "audio_video") {
@@ -10581,10 +11212,13 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10581
11212
  if (diag && !diag.failureReason) {
10582
11213
  diag.failureReason = "".concat(outcome, ": ").concat(message);
10583
11214
  }
11215
+ var failureKey = (diag === null || diag === void 0 ? void 0 : diag.dispatchedUrl) && findScvpMacroNames(vastTagUrl).some(function(name) {
11216
+ return SCVP_POD_MACROS.has(name);
11217
+ }) ? diag.dispatchedUrl : vastTagUrl;
10584
11218
  if (this.timing.isTemporaryAdError(error)) {
10585
- this.timing.temporaryFailureUrls.set(vastTagUrl, Date.now());
11219
+ this.timing.temporaryFailureUrls.set(failureKey, Date.now());
10586
11220
  } else if (outcome !== "discarded_budget") {
10587
- this.timing.failedVastUrls.add(vastTagUrl);
11221
+ this.timing.failedVastUrls.add(failureKey);
10588
11222
  }
10589
11223
  this.countFunnelStage("request_outcome:".concat(outcome));
10590
11224
  this.logOrchestratorFunnel("request_outcome", _object_spread({
@@ -10610,6 +11244,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10610
11244
  switch(payload.stage){
10611
11245
  case "gam_http_request_sent":
10612
11246
  diag.gamRequestSent++;
11247
+ this.logPodDispatch(diag);
10613
11248
  break;
10614
11249
  case "edge_http_request_sent":
10615
11250
  diag.edgeRequestSent++;
@@ -10661,8 +11296,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10661
11296
  if (gamReturnedAdWithoutImpression) {
10662
11297
  this.countFunnelStage("gam_ad_without_impression");
10663
11298
  }
10664
- var startedAt = diag.startedAt, fields = _object_without_properties(diag, [
10665
- "startedAt"
11299
+ var startedAt = diag.startedAt, _dispatchedUrl = diag.dispatchedUrl, _logged = diag.podDispatchLogged, fields = _object_without_properties(diag, [
11300
+ "startedAt",
11301
+ "dispatchedUrl",
11302
+ "podDispatchLogged"
10666
11303
  ]);
10667
11304
  console.log("[AdBreak][REQUEST] summary", _object_spread_props(_object_spread({}, fields), {
10668
11305
  durationMs: Date.now() - startedAt,
@@ -10674,24 +11311,71 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10674
11311
  // ───────────────────────────────────────────────────────────────
10675
11312
  // Single ad playback
10676
11313
  // ───────────────────────────────────────────────────────────────
10677
- key: "withCurrentPodBudget",
10678
- value: function withCurrentPodBudget(rawVastTagUrl) {
10679
- var vastTagUrl = ensureVideoAdType(rawVastTagUrl);
10680
- var remaining = Math.min(this.timing.getWallClockRemainingAdMs(), this.timing.getDurationBudgetRemainingMs());
10681
- if (!(remaining > 0)) return vastTagUrl;
10682
- try {
10683
- var url = new URL(vastTagUrl);
10684
- if (!url.searchParams.has("pmxd")) return vastTagUrl;
10685
- var maxMs = Math.round(remaining);
10686
- url.searchParams.set("pmxd", String(maxMs));
10687
- var minMs = Number(url.searchParams.get("pmnd"));
10688
- if (Number.isFinite(minMs) && minMs > maxMs) {
10689
- url.searchParams.set("pmnd", String(maxMs));
10690
- }
10691
- return url.toString();
10692
- } catch (unused) {
10693
- return vastTagUrl;
10694
- }
11314
+ key: "createGamDispatchFinalizer",
11315
+ value: function createGamDispatchFinalizer(requestToken) {
11316
+ var _this = this;
11317
+ var breakId = this.timing.adBreakEpoch;
11318
+ var config = this.adConfig.resolveAdPodConfig();
11319
+ var minUsablePmxdMs = this.timing.getMinRemainingMsToStartAd();
11320
+ return function(url) {
11321
+ var capacity = measureBreakCapacity(_this.timing.getBreakTimingSnapshot(), monotonicNow());
11322
+ var diag = _this.requestDiagnostics.get(requestToken);
11323
+ try {
11324
+ var result = finalizeGamRequestUrl(url, {
11325
+ breakId: breakId,
11326
+ capacity: capacity,
11327
+ config: config,
11328
+ minUsablePmxdMs: minUsablePmxdMs
11329
+ });
11330
+ if (diag) {
11331
+ diag.pod = result.diagnostics;
11332
+ diag.dispatchedUrl = result.url;
11333
+ diag.podDispatchLogged = false;
11334
+ }
11335
+ _this.currentVastUrl = result.url;
11336
+ return result.url;
11337
+ } catch (error) {
11338
+ if (diag && isPodRequestAbortedError(error)) {
11339
+ diag.failureReason = "pod_request_not_sent:".concat(error.reason);
11340
+ }
11341
+ throw error;
11342
+ }
11343
+ };
11344
+ }
11345
+ },
11346
+ {
11347
+ key: "logPodDispatch",
11348
+ value: function logPodDispatch(diag) {
11349
+ if (!diag.pod || diag.podDispatchLogged) return;
11350
+ diag.podDispatchLogged = true;
11351
+ this.logOrchestratorFunnel(diag.pod.optimizedPod ? "optimized_pod_request_dispatched" : "gam_request_dispatched", _object_spread({}, diag.pod));
11352
+ }
11353
+ },
11354
+ {
11355
+ key: "recordPodResponseDiagnostics",
11356
+ value: function recordPodResponseDiagnostics(requestToken, adPlayer) {
11357
+ var _diag_vastAdCount, _ref;
11358
+ var _adPlayer_getPodTotalDurationMs;
11359
+ var diag = this.requestDiagnostics.get(requestToken);
11360
+ if (!(diag === null || diag === void 0 ? void 0 : diag.pod) || diag.pod.pmxdSent == null || diag.podResponse) return;
11361
+ if (diag.gamRequestSent === 0 && diag.vastHttpStatus == null) return;
11362
+ diag.podResponse = computePodResponseDiagnostics(diag.pod.pmxdSent, (_diag_vastAdCount = diag.vastAdCount) !== null && _diag_vastAdCount !== void 0 ? _diag_vastAdCount : 0, (_ref = (_adPlayer_getPodTotalDurationMs = adPlayer.getPodTotalDurationMs) === null || _adPlayer_getPodTotalDurationMs === void 0 ? void 0 : _adPlayer_getPodTotalDurationMs.call(adPlayer)) !== null && _ref !== void 0 ? _ref : 0);
11363
+ this.logOrchestratorFunnel("optimized_pod_response", _object_spread({
11364
+ pmxdSent: diag.pod.pmxdSent
11365
+ }, diag.podResponse));
11366
+ }
11367
+ },
11368
+ {
11369
+ key: "handlePodRequestNotSent",
11370
+ value: function handlePodRequestNotSent(error) {
11371
+ if (!isPodRequestAbortedError(error) || error.reason === "invalid_url") return false;
11372
+ var aborted = error;
11373
+ this.countFunnelStage("request_outcome:pod_request_not_sent");
11374
+ this.logOrchestratorFunnel("pod_request_not_sent", _object_spread({
11375
+ reason: aborted.reason,
11376
+ errorMessage: aborted.message
11377
+ }, aborted.diagnostics));
11378
+ return true;
10695
11379
  }
10696
11380
  },
10697
11381
  {
@@ -10911,7 +11595,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10911
11595
  value: function playSingleAd(vastTagUrl) {
10912
11596
  var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
10913
11597
  return _async_to_generator(function() {
10914
- var epoch, generation, requestToken, ap, budgetedUrl, requestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
11598
+ var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, finalizeRequestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
10915
11599
  return _ts_generator(this, function(_state) {
10916
11600
  switch(_state.label){
10917
11601
  case 0:
@@ -10949,19 +11633,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10949
11633
  requestToken = ++this.timing.adRequestTokenCounter;
10950
11634
  this.timing.activeAdRequestToken = requestToken;
10951
11635
  ap = this.host.getAdPlayer();
10952
- budgetedUrl = this.withCurrentPodBudget(vastTagUrl);
10953
11636
  this.currentPodSource = "gam";
10954
11637
  this.setSlotState("REQUESTING", trigger);
10955
11638
  this.beginFunnelRequest(ap, requestToken, trigger);
10956
- requestUrl = this.applyOpportunityFloor(budgetedUrl);
11639
+ requestUrl = this.applyOpportunityFloor(ensureVideoAdType(vastTagUrl));
10957
11640
  this.currentVastUrl = requestUrl;
10958
11641
  _state.label = 1;
10959
11642
  case 1:
10960
11643
  _state.trys.push([
10961
11644
  1,
10962
- 5,
11645
+ 9,
10963
11646
  ,
10964
- 6
11647
+ 10
10965
11648
  ]);
10966
11649
  return [
10967
11650
  4,
@@ -10972,15 +11655,45 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10972
11655
  if (this.isStale(epoch, generation)) return [
10973
11656
  2
10974
11657
  ];
11658
+ return [
11659
+ 4,
11660
+ this.host.completeGamRequestSignals(requestUrl)
11661
+ ];
11662
+ case 3:
11663
+ requestUrl = _state.sent();
11664
+ if (this.isStale(epoch, generation)) return [
11665
+ 2
11666
+ ];
10975
11667
  this.timing.startAdRequestWatchdog(requestToken);
11668
+ finalizeRequestUrl = this.createGamDispatchFinalizer(requestToken);
11669
+ _state.label = 4;
11670
+ case 4:
11671
+ _state.trys.push([
11672
+ 4,
11673
+ ,
11674
+ 6,
11675
+ 7
11676
+ ]);
10976
11677
  return [
10977
11678
  4,
10978
11679
  this.callController(function() {
10979
- return ap.requestAds(requestUrl);
11680
+ return ap.requestAds(requestUrl, {
11681
+ finalizeRequestUrl: finalizeRequestUrl
11682
+ });
10980
11683
  })
10981
11684
  ];
10982
- case 3:
11685
+ case 5:
10983
11686
  _state.sent();
11687
+ return [
11688
+ 3,
11689
+ 7
11690
+ ];
11691
+ case 6:
11692
+ this.recordPodResponseDiagnostics(requestToken, ap);
11693
+ return [
11694
+ 7
11695
+ ];
11696
+ case 7:
10984
11697
  this.timing.clearAdRequestWatchdog();
10985
11698
  if (this.isStale(epoch, generation)) {
10986
11699
  this.logOrchestratorFunnel("stale_request_result_ignored", {
@@ -10992,7 +11705,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
10992
11705
  }
10993
11706
  sendAdLoadedTracking(this.host.config.licenseKey, {
10994
11707
  source: "hls",
10995
- vastUrl: requestUrl,
11708
+ vastUrl: (_this_currentVastUrl = this.currentVastUrl) !== null && _this_currentVastUrl !== void 0 ? _this_currentVastUrl : requestUrl,
10996
11709
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
10997
11710
  }, this.analyticsContext).catch(function() {});
10998
11711
  if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
@@ -11013,7 +11726,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11013
11726
  return ap.play();
11014
11727
  })
11015
11728
  ];
11016
- case 4:
11729
+ case 8:
11017
11730
  _state.sent();
11018
11731
  if (this.isStale(epoch, generation)) return [
11019
11732
  2
@@ -11025,9 +11738,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11025
11738
  this.timing.temporaryFailureUrls.delete(vastTagUrl);
11026
11739
  return [
11027
11740
  3,
11028
- 6
11741
+ 10
11029
11742
  ];
11030
- case 5:
11743
+ case 9:
11031
11744
  error = _state.sent();
11032
11745
  this.timing.clearAdRequestWatchdog();
11033
11746
  this.timing.clearAdFailsafeTimer();
@@ -11044,12 +11757,13 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11044
11757
  ];
11045
11758
  }
11046
11759
  if (this.debug) console.error("[AD-ERROR] Ad request failed:", error === null || error === void 0 ? void 0 : error.message);
11760
+ if (this.handlePodRequestNotSent(error)) throw error;
11047
11761
  this.recordRequestFailure(error, vastTagUrl);
11048
11762
  if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
11049
11763
  this.recreateAdController("discarded_budget");
11050
11764
  }
11051
11765
  throw error;
11052
- case 6:
11766
+ case 10:
11053
11767
  return [
11054
11768
  2
11055
11769
  ];
@@ -11111,7 +11825,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11111
11825
  playbackFailedAfterFill: count("request_outcome:playback_failed"),
11112
11826
  requestFailed: count("request_failed"),
11113
11827
  requestAbortedTimeout: count("request_aborted_timeout"),
11114
- credentialsRetries: count("vast_credentials_retry"),
11828
+ credentialsModeChanges: count("gam_credentials_mode_changed"),
11115
11829
  wrapperFailures: count("wrapper_fetch:failure"),
11116
11830
  noSupportedMedia: count("vast_no_supported_media"),
11117
11831
  vpaidOnly: count("vast_no_supported_media:vpaid"),
@@ -11647,8 +12361,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
11647
12361
  requiresMediaPipelineResetAfterAds: function requiresMediaPipelineResetAfterAds1() {
11648
12362
  return requiresMediaPipelineResetAfterAds();
11649
12363
  },
11650
- generatePodVastUrl: function generatePodVastUrl(base, breakDurationMs) {
11651
- return _this.generatePodVastUrl(base, breakDurationMs);
12364
+ generatePodVastUrl: function generatePodVastUrl(base) {
12365
+ return _this.generatePodVastUrl(base);
12366
+ },
12367
+ completeGamRequestSignals: function completeGamRequestSignals(url) {
12368
+ return _this.adConfig.completeDeferredRequestSignals(url, _this.palNonce);
11652
12369
  },
11653
12370
  getEdgePodBaseUrl: function getEdgePodBaseUrl() {
11654
12371
  return _this.edgePodBaseUrl;
@@ -11772,9 +12489,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
11772
12489
  },
11773
12490
  {
11774
12491
  key: "generatePodVastUrl",
11775
- value: function generatePodVastUrl(baseUrl, breakDurationMs) {
11776
- var podParams = this.adConfig.resolvePodParams(breakDurationMs);
11777
- return this.adConfig.generatePodVastUrl(baseUrl, podParams, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
12492
+ value: function generatePodVastUrl(baseUrl) {
12493
+ return this.adConfig.generatePodVastUrl(baseUrl, this.adPlayer, this.palNonce, this.adBreak.inAdBreak);
11778
12494
  }
11779
12495
  },
11780
12496
  {
@@ -12128,7 +12844,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12128
12844
  activeAdRequest: this.timing.activeAdRequestToken !== null
12129
12845
  });
12130
12846
  }
12131
- this.timing.scteAdBreakEndWallClockMs = Date.now();
12847
+ this.timing.markBreakEndedNow();
12132
12848
  this.timing.clearAdStartTimer();
12133
12849
  this.timing.clearAdStopTimer();
12134
12850
  if (adPlaying) {
@@ -12155,7 +12871,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12155
12871
  this.adBreak.inAdBreak = true;
12156
12872
  this.cueManager.activeScte35BreakKey = cueKey !== null && cueKey !== void 0 ? cueKey : this.cueManager.pendingScte35CueKey;
12157
12873
  this.cueManager.scheduledScte35BreakKey = void 0;
12158
- this.timing.currentAdBreakStartWallClockMs = this.timing.resolveScteBreakStartWallClockMs(marker);
12874
+ this.timing.beginBreakTiming(this.timing.resolveScteBreakStartWallClockMs(marker));
12159
12875
  this.timing.setAdBreakDurationBoundary(durationMs);
12160
12876
  this.adBreak.handleAdStart(marker);
12161
12877
  this.timing.scheduleAdStopAtBreakBoundary();
@@ -12201,9 +12917,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12201
12917
  }
12202
12918
  this.adConfig.beginNewAdPod();
12203
12919
  this.adConfig.podAssignedByPrefetch = true;
12204
- var breakDurationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : void 0;
12205
12920
  var generatedUrls = [
12206
- this.generatePodVastUrl(baseVastUrl, breakDurationMs)
12921
+ this.generatePodVastUrl(baseVastUrl)
12207
12922
  ];
12208
12923
  this.adBreak.pendingAdBreak = _object_spread_props(_object_spread({
12209
12924
  marker: marker
@@ -12302,7 +13017,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
12302
13017
  this.adPlayer.updateOriginalMutedState(this.video.muted, this.video.volume);
12303
13018
  this.adBreak.showAds = true;
12304
13019
  this.adBreak.inAdBreak = true;
12305
- this.timing.currentAdBreakStartWallClockMs = Date.now();
13020
+ this.timing.beginBreakTiming(Date.now());
12306
13021
  if (durationMs > 0) {
12307
13022
  this.timing.setAdBreakDurationBoundary(durationMs);
12308
13023
  }
@@ -12574,7 +13289,6 @@ var CRITICAL_PROPS = [
12574
13289
  "vmapUrl",
12575
13290
  "lowLatencyMode",
12576
13291
  "driftToleranceMs",
12577
- "vastMode",
12578
13292
  "ctvAdRequest",
12579
13293
  "adFloorMinCents",
12580
13294
  "adFloorMaxCents",
@@ -12583,7 +13297,7 @@ var CRITICAL_PROPS = [
12583
13297
  var CONTROLS_HIDE_DELAY = 3e3;
12584
13298
  var DEFAULT_PLAYER_ASPECT_RATIO = 16 / 9;
12585
13299
  var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
12586
- 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, vastMode = props.vastMode, vastTagUrl = props.vastTagUrl, isVmap = props.isVmap, vmapUrl = props.vmapUrl, minSegmentsBeforePlay = props.minSegmentsBeforePlay, ctvAdRequest = props.ctvAdRequest, programTitle = props.programTitle, channelName = props.channelName, minRemainingMsToStartAd = props.minRemainingMsToStartAd, minRemainingMsToRequestAd = props.minRemainingMsToRequestAd, maxNoFillsPerBreak = props.maxNoFillsPerBreak, maxAdBreakExtensionMs = props.maxAdBreakExtensionMs, adFloorLadderEnabled = props.adFloorLadderEnabled, adFloorLadder = props.adFloorLadder, adFloorMinCents = props.adFloorMinCents, adFloorMaxCents = props.adFloorMaxCents, adFloorStepCents = props.adFloorStepCents, enableEdgePodRequest = props.enableEdgePodRequest, edgePodUrl = props.edgePodUrl, restVideoAttrs = _object_without_properties(props, [
13300
+ 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, adFloorLadderEnabled = props.adFloorLadderEnabled, adFloorLadder = props.adFloorLadder, adFloorMinCents = props.adFloorMinCents, adFloorMaxCents = props.adFloorMaxCents, adFloorStepCents = props.adFloorStepCents, enableEdgePodRequest = props.enableEdgePodRequest, edgePodUrl = props.edgePodUrl, restVideoAttrs = _object_without_properties(props, [
12587
13301
  "src",
12588
13302
  "autoplay",
12589
13303
  "muted",
@@ -12609,7 +13323,6 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
12609
13323
  "poster",
12610
13324
  "children",
12611
13325
  "licenseKey",
12612
- "vastMode",
12613
13326
  "vastTagUrl",
12614
13327
  "isVmap",
12615
13328
  "vmapUrl",
@@ -12617,6 +13330,7 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
12617
13330
  "ctvAdRequest",
12618
13331
  "programTitle",
12619
13332
  "channelName",
13333
+ "contentNetwork",
12620
13334
  "minRemainingMsToStartAd",
12621
13335
  "minRemainingMsToRequestAd",
12622
13336
  "maxNoFillsPerBreak",
@@ -12775,7 +13489,6 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
12775
13489
  vmapUrl,
12776
13490
  lowLatencyMode,
12777
13491
  driftToleranceMs,
12778
- vastMode,
12779
13492
  adFloorMinCents,
12780
13493
  adFloorMaxCents,
12781
13494
  adFloorStepCents
@@ -12817,7 +13530,6 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
12817
13530
  if (onFullscreenToggle !== void 0) cfg.onFullscreenToggle = onFullscreenToggle;
12818
13531
  if (onControlClick !== void 0) cfg.onControlClick = onControlClick;
12819
13532
  if (licenseKey !== void 0) cfg.licenseKey = licenseKey;
12820
- if (vastMode !== void 0) cfg.vastMode = vastMode;
12821
13533
  if (vastTagUrl !== void 0) cfg.vastTagUrl = vastTagUrl;
12822
13534
  if (isVmap !== void 0) cfg.isVmap = isVmap;
12823
13535
  if (vmapUrl !== void 0) cfg.vmapUrl = vmapUrl;
@@ -12825,6 +13537,7 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
12825
13537
  if (ctvAdRequest !== void 0) cfg.ctvAdRequest = ctvAdRequest;
12826
13538
  if (programTitle !== void 0) cfg.programTitle = programTitle;
12827
13539
  if (channelName !== void 0) cfg.channelName = channelName;
13540
+ if (contentNetwork !== void 0) cfg.contentNetwork = contentNetwork;
12828
13541
  if (minRemainingMsToStartAd !== void 0) cfg.minRemainingMsToStartAd = minRemainingMsToStartAd;
12829
13542
  if (minRemainingMsToRequestAd !== void 0) cfg.minRemainingMsToRequestAd = minRemainingMsToRequestAd;
12830
13543
  if (maxNoFillsPerBreak !== void 0) cfg.maxNoFillsPerBreak = maxNoFillsPerBreak;