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