stormcloud-video-player 0.7.11 → 0.7.13

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.
package/lib/index.js CHANGED
@@ -1413,7 +1413,6 @@ function createAdStormPlayer(contentVideo, options) {
1413
1413
  contentVideo.muted = originalMutedState;
1414
1414
  contentVideo.volume = originalVolume;
1415
1415
  currentAd = void 0;
1416
- tornDown = false;
1417
1416
  return [
1418
1417
  2,
1419
1418
  Promise.resolve()
@@ -1528,6 +1527,15 @@ function createAdStormPlayer(contentVideo, options) {
1528
1527
  if (!token) return [
1529
1528
  2
1530
1529
  ];
1530
+ if (currentAd) {
1531
+ preloadSlots.set(token, {
1532
+ ad: currentAd
1533
+ });
1534
+ currentAd = void 0;
1535
+ return [
1536
+ 2
1537
+ ];
1538
+ }
1531
1539
  requestContext = typeof arg1 === "string" ? arg2 : arg1;
1532
1540
  return [
1533
1541
  4,
@@ -2021,56 +2029,6 @@ function sendInitialTracking(licenseKey) {
2021
2029
  });
2022
2030
  })();
2023
2031
  }
2024
- function sendAdDetectTracking(licenseKey, adDetectInfo) {
2025
- return _async_to_generator(function() {
2026
- var clientInfo, browserId, trackingData, error;
2027
- return _ts_generator(this, function(_state) {
2028
- switch(_state.label){
2029
- case 0:
2030
- _state.trys.push([
2031
- 0,
2032
- 3,
2033
- ,
2034
- 4
2035
- ]);
2036
- clientInfo = getClientInfo();
2037
- return [
2038
- 4,
2039
- getBrowserID(clientInfo)
2040
- ];
2041
- case 1:
2042
- browserId = _state.sent();
2043
- trackingData = _object_spread({
2044
- browserId: browserId
2045
- }, clientInfo);
2046
- return [
2047
- 4,
2048
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2049
- licenseKey: licenseKey,
2050
- adDetectInfo: adDetectInfo
2051
- }))
2052
- ];
2053
- case 2:
2054
- _state.sent();
2055
- return [
2056
- 3,
2057
- 4
2058
- ];
2059
- case 3:
2060
- error = _state.sent();
2061
- console.error("[StormcloudVideoPlayer] Error sending ad detect tracking:", error);
2062
- return [
2063
- 3,
2064
- 4
2065
- ];
2066
- case 4:
2067
- return [
2068
- 2
2069
- ];
2070
- }
2071
- });
2072
- })();
2073
- }
2074
2032
  function sendAdLoadedTracking(licenseKey, adLoadedInfo) {
2075
2033
  return _async_to_generator(function() {
2076
2034
  var clientInfo, browserId, trackingData, error;
@@ -2783,7 +2741,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2783
2741
  this.continuousFetchLoopPromise = null;
2784
2742
  this.attached = false;
2785
2743
  this.inAdBreak = false;
2786
- this.ptsDriftEmaMs = 0;
2787
2744
  this.adPodQueue = [];
2788
2745
  this.lastHeartbeatTime = 0;
2789
2746
  this.currentAdIndex = 0;
@@ -2807,7 +2764,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2807
2764
  this.totalAdRequestsInBreak = 0;
2808
2765
  this.maxTotalAdRequestsPerBreak = 20;
2809
2766
  this.pendingAdBreak = null;
2810
- this.savedMutedStateBeforeScte = null;
2767
+ this.savedMutedStateBeforeAd = null;
2811
2768
  this.consecutiveFailures = 0;
2812
2769
  this.maxConsecutiveFailures = 5;
2813
2770
  this.lastAdRequestTime = 0;
@@ -2820,7 +2777,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2820
2777
  this.adRequestRetryBackoffMs = 1500;
2821
2778
  this.preloadedTokens = [];
2822
2779
  this.debugLogEntries = [];
2823
- this.scteMarkerHistory = [];
2824
2780
  this.adInsertionDebugHistory = [];
2825
2781
  initializePolyfills();
2826
2782
  var browserOverrides = getBrowserConfigOverrides();
@@ -3109,18 +3065,44 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3109
3065
  _this.pushAdInsertionDebug("ad_triggered", segmentName, {
3110
3066
  detail: "ad break started (60s)"
3111
3067
  });
3112
- var marker = {
3113
- type: "start",
3114
- durationSeconds: 60,
3115
- raw: {
3116
- apiInsertionPoint: _this.lastAdInsertionPoint
3117
- }
3118
- };
3119
- _this.onScte35Marker(marker);
3068
+ void _this.handleAdStart(60);
3120
3069
  }, offsetMs);
3121
3070
  }
3122
3071
  }
3123
3072
  });
3073
+ this.hls.on(Hls.Events.FRAG_PARSING_USERDATA, function(_evt, data) {
3074
+ var _ref;
3075
+ var samples = (_ref = data === null || data === void 0 ? void 0 : data.samples) !== null && _ref !== void 0 ? _ref : [];
3076
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3077
+ try {
3078
+ for(var _iterator = samples[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
3079
+ var sample = _step.value;
3080
+ var _ref1, _ref2;
3081
+ var _data_frag, _data_frag1;
3082
+ var bytes = sample === null || sample === void 0 ? void 0 : sample.data;
3083
+ if (!bytes || bytes.length < 5) continue;
3084
+ var isSCTE35 = bytes[0] === 252;
3085
+ if (!isSCTE35) continue;
3086
+ var segName = (_ref1 = (_ref2 = data === null || data === void 0 ? void 0 : (_data_frag = data.frag) === null || _data_frag === void 0 ? void 0 : _data_frag.relurl) !== null && _ref2 !== void 0 ? _ref2 : data === null || data === void 0 ? void 0 : (_data_frag1 = data.frag) === null || _data_frag1 === void 0 ? void 0 : _data_frag1.url) !== null && _ref1 !== void 0 ? _ref1 : "";
3087
+ _this.pushAdInsertionDebug("scte35_inserted", segName, {
3088
+ detail: "len=".concat(bytes.length, "B")
3089
+ });
3090
+ }
3091
+ } catch (err) {
3092
+ _didIteratorError = true;
3093
+ _iteratorError = err;
3094
+ } finally{
3095
+ try {
3096
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
3097
+ _iterator.return();
3098
+ }
3099
+ } finally{
3100
+ if (_didIteratorError) {
3101
+ throw _iteratorError;
3102
+ }
3103
+ }
3104
+ }
3105
+ });
3124
3106
  this.hls.on(Hls.Events.ERROR, function(_evt, data) {
3125
3107
  if (data === null || data === void 0 ? void 0 : data.fatal) {
3126
3108
  switch(data.type){
@@ -3195,8 +3177,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3195
3177
  _this.activeAdRequestToken = null;
3196
3178
  _this.showAds = true;
3197
3179
  if (_this.config.disableFiller) {
3198
- if (_this.savedMutedStateBeforeScte == null) {
3199
- _this.savedMutedStateBeforeScte = {
3180
+ if (_this.savedMutedStateBeforeAd == null) {
3181
+ _this.savedMutedStateBeforeAd = {
3200
3182
  muted: _this.video.muted,
3201
3183
  volume: _this.video.volume
3202
3184
  };
@@ -3224,10 +3206,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3224
3206
  });
3225
3207
  this.adLayer.on("content_resume", function() {
3226
3208
  var _ref, _ref1;
3227
- var _this_savedMutedStateBeforeScte, _this_savedMutedStateBeforeScte1;
3209
+ var _this_savedMutedStateBeforeAd, _this_savedMutedStateBeforeAd1;
3228
3210
  var remaining = _this.getRemainingAdMs();
3229
- var breakMuted = (_ref = (_this_savedMutedStateBeforeScte = _this.savedMutedStateBeforeScte) === null || _this_savedMutedStateBeforeScte === void 0 ? void 0 : _this_savedMutedStateBeforeScte.muted) !== null && _ref !== void 0 ? _ref : _this.adLayer.getOriginalMutedState();
3230
- var breakVolume = (_ref1 = (_this_savedMutedStateBeforeScte1 = _this.savedMutedStateBeforeScte) === null || _this_savedMutedStateBeforeScte1 === void 0 ? void 0 : _this_savedMutedStateBeforeScte1.volume) !== null && _ref1 !== void 0 ? _ref1 : _this.adLayer.getOriginalVolume();
3211
+ var breakMuted = (_ref = (_this_savedMutedStateBeforeAd = _this.savedMutedStateBeforeAd) === null || _this_savedMutedStateBeforeAd === void 0 ? void 0 : _this_savedMutedStateBeforeAd.muted) !== null && _ref !== void 0 ? _ref : _this.adLayer.getOriginalMutedState();
3212
+ var breakVolume = (_ref1 = (_this_savedMutedStateBeforeAd1 = _this.savedMutedStateBeforeAd) === null || _this_savedMutedStateBeforeAd1 === void 0 ? void 0 : _this_savedMutedStateBeforeAd1.volume) !== null && _ref1 !== void 0 ? _ref1 : _this.adLayer.getOriginalVolume();
3231
3213
  if (_this.config.debugAdTiming) {
3232
3214
  console.log("[StormcloudVideoPlayer] content_resume received, inAdBreak=%s, remaining=%s, preloadedTokens=%d, pendingNext=%s", _this.inAdBreak, remaining, _this.preloadedTokens.length, !!_this.pendingNextAdBids);
3233
3215
  }
@@ -3304,7 +3286,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3304
3286
  var remainingFinal = _this.getRemainingAdMs();
3305
3287
  if (_this.inAdBreak && remainingFinal > _this.MIN_AD_REMAINING_MS) {
3306
3288
  if (_this.config.debugAdTiming) {
3307
- console.log("[StormcloudVideoPlayer] content_resume: no more ads, showing filler for", remainingFinal, "ms");
3289
+ console.log("[StormcloudVideoPlayer] content_resume: ad ended/failed with time remaining, showing filler and continuing fetch for", remainingFinal, "ms");
3308
3290
  }
3309
3291
  if (!_this.config.disableFiller) {
3310
3292
  _this.showPlaceholderLayer();
@@ -3322,7 +3304,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3322
3304
  (_this_video_play = _this.video.play()) === null || _this_video_play === void 0 ? void 0 : _this_video_play.catch(function() {});
3323
3305
  }
3324
3306
  }
3325
- _this.stopContinuousFetching();
3307
+ _this.continuousFetchingActive = true;
3308
+ _this.startContinuousFetchLoop();
3326
3309
  return;
3327
3310
  }
3328
3311
  if (_this.config.debugAdTiming) {
@@ -3469,547 +3452,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3469
3452
  return !!(this.config.allowNativeHls && canNative);
3470
3453
  }
3471
3454
  },
3472
- {
3473
- key: "onId3Tag",
3474
- value: function onId3Tag(tag) {
3475
- if (typeof tag.ptsSeconds === "number") {
3476
- this.updatePtsDrift(tag.ptsSeconds);
3477
- }
3478
- var marker = this.parseScte35FromId3(tag);
3479
- if (marker) {
3480
- this.onScte35Marker(marker);
3481
- }
3482
- }
3483
- },
3484
- {
3485
- key: "parseScte35FromId3",
3486
- value: function parseScte35FromId3(tag) {
3487
- var text = this.decodeId3ValueToText(tag.value);
3488
- if (!text) return void 0;
3489
- var cueOutMatch = text.match(/EXT-X-CUE-OUT(?::([^\r\n]*))?/i) || text.match(/CUE-OUT(?::([^\r\n]*))?/i);
3490
- if (cueOutMatch) {
3491
- var _cueOutMatch_;
3492
- var arg = ((_cueOutMatch_ = cueOutMatch[1]) !== null && _cueOutMatch_ !== void 0 ? _cueOutMatch_ : "").trim();
3493
- var dur = this.parseCueOutDuration(arg);
3494
- var marker = _object_spread_props(_object_spread({
3495
- type: "start"
3496
- }, tag.ptsSeconds !== void 0 ? {
3497
- ptsSeconds: tag.ptsSeconds
3498
- } : {}, dur !== void 0 ? {
3499
- durationSeconds: dur
3500
- } : {}), {
3501
- raw: {
3502
- id3: text
3503
- }
3504
- });
3505
- return marker;
3506
- }
3507
- var cueOutContMatch = text.match(/EXT-X-CUE-OUT-CONT:([^\r\n]*)/i);
3508
- if (cueOutContMatch) {
3509
- var _cueOutContMatch_;
3510
- var arg1 = ((_cueOutContMatch_ = cueOutContMatch[1]) !== null && _cueOutContMatch_ !== void 0 ? _cueOutContMatch_ : "").trim();
3511
- var cont = this.parseCueOutCont(arg1);
3512
- var marker1 = _object_spread_props(_object_spread({
3513
- type: "progress"
3514
- }, tag.ptsSeconds !== void 0 ? {
3515
- ptsSeconds: tag.ptsSeconds
3516
- } : {}, (cont === null || cont === void 0 ? void 0 : cont.duration) !== void 0 ? {
3517
- durationSeconds: cont.duration
3518
- } : {}), {
3519
- raw: {
3520
- id3: text
3521
- }
3522
- });
3523
- return marker1;
3524
- }
3525
- var cueInMatch = text.match(/EXT-X-CUE-IN\b/i) || text.match(/CUE-IN\b/i);
3526
- if (cueInMatch) {
3527
- var marker2 = _object_spread_props(_object_spread({
3528
- type: "end"
3529
- }, tag.ptsSeconds !== void 0 ? {
3530
- ptsSeconds: tag.ptsSeconds
3531
- } : {}), {
3532
- raw: {
3533
- id3: text
3534
- }
3535
- });
3536
- return marker2;
3537
- }
3538
- var daterangeMatch = text.match(/EXT-X-DATERANGE:([^\r\n]*)/i);
3539
- if (daterangeMatch) {
3540
- var _daterangeMatch_, _attrs_CLASS;
3541
- var attrs = this.parseAttributeList((_daterangeMatch_ = daterangeMatch[1]) !== null && _daterangeMatch_ !== void 0 ? _daterangeMatch_ : "");
3542
- var hasScteOut = "SCTE35-OUT" in attrs || attrs["SCTE35-OUT"] !== void 0;
3543
- var hasScteIn = "SCTE35-IN" in attrs || attrs["SCTE35-IN"] !== void 0;
3544
- var klass = String((_attrs_CLASS = attrs["CLASS"]) !== null && _attrs_CLASS !== void 0 ? _attrs_CLASS : "");
3545
- var duration = this.toNumber(attrs["DURATION"]);
3546
- if (hasScteOut || /com\.apple\.hls\.cue/i.test(klass)) {
3547
- var marker3 = _object_spread_props(_object_spread({
3548
- type: "start"
3549
- }, tag.ptsSeconds !== void 0 ? {
3550
- ptsSeconds: tag.ptsSeconds
3551
- } : {}, duration !== void 0 ? {
3552
- durationSeconds: duration
3553
- } : {}), {
3554
- raw: {
3555
- id3: text,
3556
- attrs: attrs
3557
- }
3558
- });
3559
- return marker3;
3560
- }
3561
- if (hasScteIn) {
3562
- var marker4 = _object_spread_props(_object_spread({
3563
- type: "end"
3564
- }, tag.ptsSeconds !== void 0 ? {
3565
- ptsSeconds: tag.ptsSeconds
3566
- } : {}), {
3567
- raw: {
3568
- id3: text,
3569
- attrs: attrs
3570
- }
3571
- });
3572
- return marker4;
3573
- }
3574
- }
3575
- if (/SCTE35-OUT/i.test(text)) {
3576
- var marker5 = _object_spread_props(_object_spread({
3577
- type: "start"
3578
- }, tag.ptsSeconds !== void 0 ? {
3579
- ptsSeconds: tag.ptsSeconds
3580
- } : {}), {
3581
- raw: {
3582
- id3: text
3583
- }
3584
- });
3585
- return marker5;
3586
- }
3587
- if (/SCTE35-IN/i.test(text)) {
3588
- var marker6 = _object_spread_props(_object_spread({
3589
- type: "end"
3590
- }, tag.ptsSeconds !== void 0 ? {
3591
- ptsSeconds: tag.ptsSeconds
3592
- } : {}), {
3593
- raw: {
3594
- id3: text
3595
- }
3596
- });
3597
- return marker6;
3598
- }
3599
- if (_instanceof(tag.value, Uint8Array)) {
3600
- var bin = this.parseScte35Binary(tag.value);
3601
- if (bin) return bin;
3602
- }
3603
- return void 0;
3604
- }
3605
- },
3606
- {
3607
- key: "decodeId3ValueToText",
3608
- value: function decodeId3ValueToText(value) {
3609
- try {
3610
- if (typeof value === "string") return value;
3611
- var decoder = new TextDecoder("utf-8", {
3612
- fatal: false
3613
- });
3614
- var text = decoder.decode(value);
3615
- if (text && /[\x20-\x7E]/.test(text)) return text;
3616
- var out = "";
3617
- for(var i = 0; i < value.length; i++)out += String.fromCharCode(value[i]);
3618
- return out;
3619
- } catch (unused) {
3620
- return void 0;
3621
- }
3622
- }
3623
- },
3624
- {
3625
- key: "onScte35Marker",
3626
- value: function onScte35Marker(marker) {
3627
- var _this = this;
3628
- if (this.config.disableAds) return;
3629
- this.pushScteMarker(marker);
3630
- this.pushDebugLog("info", "scte35", "SCTE-35 marker detected", {
3631
- type: marker.type,
3632
- ptsSeconds: marker.ptsSeconds,
3633
- durationSeconds: marker.durationSeconds,
3634
- currentTime: this.video.currentTime
3635
- });
3636
- if (this.config.debugAdTiming) {
3637
- console.log("[StormcloudVideoPlayer] SCTE-35 marker detected:", {
3638
- type: marker.type,
3639
- ptsSeconds: marker.ptsSeconds,
3640
- durationSeconds: marker.durationSeconds,
3641
- currentTime: this.video.currentTime,
3642
- raw: marker.raw,
3643
- hasPendingAdBreak: !!this.pendingAdBreak
3644
- });
3645
- }
3646
- if (marker.type === "start") {
3647
- var _this_config_immediateManifestAds;
3648
- var _this_pendingAdBreak;
3649
- if (this.savedMutedStateBeforeScte == null) {
3650
- this.savedMutedStateBeforeScte = {
3651
- muted: this.video.muted,
3652
- volume: this.video.volume
3653
- };
3654
- this.adLayer.updateOriginalMutedState(this.video.muted, this.video.volume);
3655
- }
3656
- if (!this.config.disableFiller && !this.video.muted && !this.adLayer.isAdPlaying()) {
3657
- this.video.muted = true;
3658
- this.video.volume = 0;
3659
- if (this.config.debugAdTiming) {
3660
- console.log("[StormcloudVideoPlayer] Muted video on SCTE start marker");
3661
- }
3662
- }
3663
- if (this.inAdBreak) {
3664
- if (marker.durationSeconds != null) {
3665
- var newDurationMs = marker.durationSeconds * 1e3;
3666
- if (this.expectedAdBreakDurationMs == null || newDurationMs > this.expectedAdBreakDurationMs) {
3667
- this.expectedAdBreakDurationMs = newDurationMs;
3668
- var elapsedMs = this.currentAdBreakStartWallClockMs != null ? Date.now() - this.currentAdBreakStartWallClockMs : 0;
3669
- var remainingMs = Math.max(0, newDurationMs - elapsedMs);
3670
- this.scheduleAdStopCountdown(remainingMs);
3671
- if (this.config.debugAdTiming) {
3672
- console.log("[StormcloudVideoPlayer] Updated ad break duration from subsequent marker: ".concat(newDurationMs, "ms, remaining: ").concat(remainingMs, "ms"));
3673
- }
3674
- }
3675
- }
3676
- return;
3677
- }
3678
- this.inAdBreak = true;
3679
- var durationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : ((_this_pendingAdBreak = this.pendingAdBreak) === null || _this_pendingAdBreak === void 0 ? void 0 : _this_pendingAdBreak.marker.durationSeconds) != null ? this.pendingAdBreak.marker.durationSeconds * 1e3 : void 0;
3680
- this.expectedAdBreakDurationMs = durationMs;
3681
- this.currentAdBreakStartWallClockMs = Date.now();
3682
- if (this.config.licenseKey) {
3683
- var _this_pendingAdBreak1;
3684
- var adDetectInfo = _object_spread({
3685
- source: "scte35",
3686
- timestamp: /* @__PURE__ */ new Date().toISOString()
3687
- }, marker.durationSeconds != null && {
3688
- durationSeconds: marker.durationSeconds
3689
- }, marker.ptsSeconds != null && {
3690
- ptsSeconds: marker.ptsSeconds
3691
- }, ((_this_pendingAdBreak1 = this.pendingAdBreak) === null || _this_pendingAdBreak1 === void 0 ? void 0 : _this_pendingAdBreak1.detectedAtFragmentSn) != null && {
3692
- detectedAtFragmentSn: this.pendingAdBreak.detectedAtFragmentSn
3693
- });
3694
- sendAdDetectTracking(this.config.licenseKey, adDetectInfo);
3695
- }
3696
- var isManifestMarker = this.isManifestBasedMarker(marker);
3697
- var forceImmediate = (_this_config_immediateManifestAds = this.config.immediateManifestAds) !== null && _this_config_immediateManifestAds !== void 0 ? _this_config_immediateManifestAds : true;
3698
- if (this.config.debugAdTiming) {
3699
- console.log("[StormcloudVideoPlayer] Ad start decision:", {
3700
- isManifestMarker: isManifestMarker,
3701
- forceImmediate: forceImmediate,
3702
- hasPts: typeof marker.ptsSeconds === "number"
3703
- });
3704
- }
3705
- if (isManifestMarker && forceImmediate) {
3706
- if (this.config.debugAdTiming) {
3707
- console.log("[StormcloudVideoPlayer] Starting ad immediately (manifest-based)");
3708
- }
3709
- this.clearAdStartTimer();
3710
- this.handleAdStart(marker);
3711
- } else if (typeof marker.ptsSeconds === "number") {
3712
- var _this_config_driftToleranceMs;
3713
- var tol = (_this_config_driftToleranceMs = this.config.driftToleranceMs) !== null && _this_config_driftToleranceMs !== void 0 ? _this_config_driftToleranceMs : 1e3;
3714
- var nowMs = this.video.currentTime * 1e3;
3715
- var estCurrentPtsMs = nowMs - this.ptsDriftEmaMs;
3716
- var deltaMs = Math.floor(marker.ptsSeconds * 1e3 - estCurrentPtsMs);
3717
- if (this.config.debugAdTiming) {
3718
- console.log("[StormcloudVideoPlayer] PTS-based timing calculation:", {
3719
- nowMs: nowMs,
3720
- estCurrentPtsMs: estCurrentPtsMs,
3721
- markerPtsMs: marker.ptsSeconds * 1e3,
3722
- deltaMs: deltaMs,
3723
- tolerance: tol
3724
- });
3725
- }
3726
- if (deltaMs > tol) {
3727
- if (this.config.debugAdTiming) {
3728
- console.log("[StormcloudVideoPlayer] Scheduling ad start in ".concat(deltaMs, "ms"));
3729
- }
3730
- this.scheduleAdStartIn(deltaMs);
3731
- } else {
3732
- if (this.config.debugAdTiming) {
3733
- console.log("[StormcloudVideoPlayer] Starting ad immediately (within tolerance)");
3734
- }
3735
- this.clearAdStartTimer();
3736
- this.handleAdStart(marker);
3737
- }
3738
- } else {
3739
- if (this.config.debugAdTiming) {
3740
- console.log("[StormcloudVideoPlayer] Starting ad immediately (fallback)");
3741
- }
3742
- this.clearAdStartTimer();
3743
- this.handleAdStart(marker);
3744
- }
3745
- if (this.expectedAdBreakDurationMs != null) {
3746
- this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
3747
- }
3748
- return;
3749
- }
3750
- if (marker.type === "progress" && this.inAdBreak) {
3751
- if (marker.durationSeconds != null) {
3752
- this.expectedAdBreakDurationMs = marker.durationSeconds * 1e3;
3753
- }
3754
- if (this.expectedAdBreakDurationMs != null && this.currentAdBreakStartWallClockMs != null) {
3755
- var elapsedMs1 = Date.now() - this.currentAdBreakStartWallClockMs;
3756
- var remainingMs1 = Math.max(0, this.expectedAdBreakDurationMs - elapsedMs1);
3757
- this.scheduleAdStopCountdown(remainingMs1);
3758
- }
3759
- if (!this.adLayer.isAdPlaying() && this.pendingNextAdBids != null && this.pendingNextAdBids.length > 0) {
3760
- var bids = this.pendingNextAdBids;
3761
- this.pendingNextAdBids = null;
3762
- this.currentAdIndex++;
3763
- this.adLayer.playAd(bids).catch(function() {
3764
- return _this.handleAdFailure();
3765
- });
3766
- }
3767
- return;
3768
- }
3769
- if (marker.type === "end") {
3770
- var remaining = this.getRemainingAdMs();
3771
- var adPlaying = this.adLayer.isAdPlaying();
3772
- var hasQueuedAds = this.pendingNextAdBids != null && this.pendingNextAdBids.length > 0;
3773
- if (this.config.debugAdTiming) {
3774
- console.log("[StormcloudVideoPlayer] SCTE-35 end marker received:", {
3775
- inAdBreak: this.inAdBreak,
3776
- remaining: remaining,
3777
- adPlaying: adPlaying,
3778
- hasQueuedAds: hasQueuedAds,
3779
- activeAdRequest: this.activeAdRequestToken !== null
3780
- });
3781
- }
3782
- if (!this.inAdBreak) {
3783
- if (this.config.debugAdTiming) {
3784
- console.log("[StormcloudVideoPlayer] Ignoring SCTE-35 end marker - not in ad break");
3785
- }
3786
- return;
3787
- }
3788
- if (adPlaying || remaining > 500) {
3789
- if (this.config.debugAdTiming) {
3790
- console.log("[StormcloudVideoPlayer] Ignoring premature SCTE-35 end marker - ads still active or time remaining");
3791
- }
3792
- return;
3793
- }
3794
- this.inAdBreak = false;
3795
- this.expectedAdBreakDurationMs = void 0;
3796
- this.currentAdBreakStartWallClockMs = void 0;
3797
- this.clearAdStartTimer();
3798
- this.clearAdStopTimer();
3799
- if (adPlaying) {
3800
- this.adLayer.stop().catch(function() {});
3801
- }
3802
- this.handleAdPodComplete();
3803
- return;
3804
- }
3805
- }
3806
- },
3807
- {
3808
- key: "parseCueOutDuration",
3809
- value: function parseCueOutDuration(value) {
3810
- var num = parseFloat(value.trim());
3811
- if (!Number.isNaN(num)) return num;
3812
- var match = value.match(/(?:^|[,\s])DURATION\s*=\s*([0-9.]+)/i) || value.match(/Duration\s*=\s*([0-9.]+)/i);
3813
- if (match && match[1] != null) {
3814
- var dStr = match[1];
3815
- var d = parseFloat(dStr);
3816
- return Number.isNaN(d) ? void 0 : d;
3817
- }
3818
- return void 0;
3819
- }
3820
- },
3821
- {
3822
- key: "parseCueOutCont",
3823
- value: function parseCueOutCont(value) {
3824
- var res = {};
3825
- var elapsedMatch = value.match(/Elapsed\s*=\s*([0-9.]+)/i);
3826
- var durationMatch = value.match(/Duration\s*=\s*([0-9.]+)/i);
3827
- if (elapsedMatch && elapsedMatch[1] != null) {
3828
- var e = parseFloat(elapsedMatch[1]);
3829
- if (!Number.isNaN(e)) res.elapsed = e;
3830
- }
3831
- if (durationMatch && durationMatch[1] != null) {
3832
- var d = parseFloat(durationMatch[1]);
3833
- if (!Number.isNaN(d)) res.duration = d;
3834
- }
3835
- if (!("elapsed" in res) || !("duration" in res)) {
3836
- var slashMatch = value.match(/([0-9.]+)\s*\/\s*([0-9.]+)/);
3837
- if (slashMatch && slashMatch[1] && slashMatch[2]) {
3838
- var elapsed = parseFloat(slashMatch[1]);
3839
- var duration = parseFloat(slashMatch[2]);
3840
- if (!Number.isNaN(elapsed) && !("elapsed" in res)) res.elapsed = elapsed;
3841
- if (!Number.isNaN(duration) && !("duration" in res)) res.duration = duration;
3842
- }
3843
- }
3844
- if ("elapsed" in res || "duration" in res) return res;
3845
- return void 0;
3846
- }
3847
- },
3848
- {
3849
- key: "parseAttributeList",
3850
- value: function parseAttributeList(value) {
3851
- var attrs = {};
3852
- var regex = /([A-Z0-9-]+)=(("[^"]*")|([^",]*))(?:,|$)/gi;
3853
- var match;
3854
- while((match = regex.exec(value)) !== null){
3855
- var _match_, _ref, _match_1;
3856
- var key = (_match_ = match[1]) !== null && _match_ !== void 0 ? _match_ : "";
3857
- var rawVal = (_ref = (_match_1 = match[3]) !== null && _match_1 !== void 0 ? _match_1 : match[4]) !== null && _ref !== void 0 ? _ref : "";
3858
- if (rawVal.startsWith('"') && rawVal.endsWith('"')) {
3859
- rawVal = rawVal.slice(1, -1);
3860
- }
3861
- if (key) {
3862
- attrs[key] = rawVal;
3863
- }
3864
- }
3865
- return attrs;
3866
- }
3867
- },
3868
- {
3869
- key: "toNumber",
3870
- value: function toNumber(val) {
3871
- if (val == null) return void 0;
3872
- var n = typeof val === "string" ? parseFloat(val) : Number(val);
3873
- return Number.isNaN(n) ? void 0 : n;
3874
- }
3875
- },
3876
- {
3877
- key: "isManifestBasedMarker",
3878
- value: function isManifestBasedMarker(marker) {
3879
- var raw = marker.raw;
3880
- if (!raw) return false;
3881
- if (raw.tag) {
3882
- var tag = String(raw.tag);
3883
- return tag.includes("EXT-X-CUE-OUT") || tag.includes("EXT-X-CUE-IN") || tag.includes("EXT-X-DATERANGE");
3884
- }
3885
- if (raw.id3) return false;
3886
- if (raw.splice_command_type) return false;
3887
- return false;
3888
- }
3889
- },
3890
- {
3891
- key: "parseScte35Binary",
3892
- value: function parseScte35Binary(data) {
3893
- var BitReader = /*#__PURE__*/ function() {
3894
- function BitReader(buf) {
3895
- _class_call_check(this, BitReader);
3896
- this.buf = buf;
3897
- this.bytePos = 0;
3898
- this.bitPos = 0;
3899
- }
3900
- _create_class(BitReader, [
3901
- {
3902
- key: "readBits",
3903
- value: function readBits(numBits) {
3904
- var result = 0;
3905
- while(numBits > 0){
3906
- if (this.bytePos >= this.buf.length) return result;
3907
- var remainingInByte = 8 - this.bitPos;
3908
- var toRead = Math.min(numBits, remainingInByte);
3909
- var currentByte = this.buf[this.bytePos];
3910
- var shift = remainingInByte - toRead;
3911
- var mask = (1 << toRead) - 1 & 255;
3912
- var bits = currentByte >> shift & mask;
3913
- result = result << toRead | bits;
3914
- this.bitPos += toRead;
3915
- if (this.bitPos >= 8) {
3916
- this.bitPos = 0;
3917
- this.bytePos += 1;
3918
- }
3919
- numBits -= toRead;
3920
- }
3921
- return result >>> 0;
3922
- }
3923
- },
3924
- {
3925
- key: "skipBits",
3926
- value: function skipBits(n) {
3927
- this.readBits(n);
3928
- }
3929
- }
3930
- ]);
3931
- return BitReader;
3932
- }();
3933
- var r = new BitReader(data);
3934
- var tableId = r.readBits(8);
3935
- if (tableId !== 252) return void 0;
3936
- r.readBits(1);
3937
- r.readBits(1);
3938
- r.readBits(2);
3939
- var sectionLength = r.readBits(12);
3940
- r.readBits(8);
3941
- r.readBits(1);
3942
- r.readBits(6);
3943
- var ptsAdjHigh = r.readBits(1);
3944
- var ptsAdjLow = r.readBits(32);
3945
- void ptsAdjHigh;
3946
- void ptsAdjLow;
3947
- r.readBits(8);
3948
- r.readBits(12);
3949
- var spliceCommandLength = r.readBits(12);
3950
- var spliceCommandType = r.readBits(8);
3951
- if (spliceCommandType !== 5) {
3952
- return void 0;
3953
- }
3954
- r.readBits(32);
3955
- var cancel = r.readBits(1) === 1;
3956
- r.readBits(7);
3957
- if (cancel) return void 0;
3958
- var outOfNetwork = r.readBits(1) === 1;
3959
- var programSpliceFlag = r.readBits(1) === 1;
3960
- var durationFlag = r.readBits(1) === 1;
3961
- var spliceImmediateFlag = r.readBits(1) === 1;
3962
- r.readBits(4);
3963
- if (programSpliceFlag && !spliceImmediateFlag) {
3964
- var timeSpecifiedFlag = r.readBits(1) === 1;
3965
- if (timeSpecifiedFlag) {
3966
- r.readBits(6);
3967
- r.readBits(33);
3968
- } else {
3969
- r.readBits(7);
3970
- }
3971
- } else if (!programSpliceFlag) {
3972
- var componentCount = r.readBits(8);
3973
- for(var i = 0; i < componentCount; i++){
3974
- r.readBits(8);
3975
- if (!spliceImmediateFlag) {
3976
- var timeSpecifiedFlag1 = r.readBits(1) === 1;
3977
- if (timeSpecifiedFlag1) {
3978
- r.readBits(6);
3979
- r.readBits(33);
3980
- } else {
3981
- r.readBits(7);
3982
- }
3983
- }
3984
- }
3985
- }
3986
- var durationSeconds = void 0;
3987
- if (durationFlag) {
3988
- r.readBits(6);
3989
- r.readBits(1);
3990
- var high = r.readBits(1);
3991
- var low = r.readBits(32);
3992
- var durationTicks = high * 4294967296 + low;
3993
- durationSeconds = durationTicks / 9e4;
3994
- }
3995
- r.readBits(16);
3996
- r.readBits(8);
3997
- r.readBits(8);
3998
- if (outOfNetwork) {
3999
- var marker = _object_spread_props(_object_spread({
4000
- type: "start"
4001
- }, durationSeconds !== void 0 ? {
4002
- durationSeconds: durationSeconds
4003
- } : {}), {
4004
- raw: {
4005
- splice_command_type: 5
4006
- }
4007
- });
4008
- return marker;
4009
- }
4010
- return void 0;
4011
- }
4012
- },
4013
3455
  {
4014
3456
  key: "initializeTracking",
4015
3457
  value: function initializeTracking() {
@@ -4131,35 +3573,35 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4131
3573
  },
4132
3574
  {
4133
3575
  key: "startAdPrefetch",
4134
- value: function startAdPrefetch(marker, fragmentSn) {
3576
+ value: function startAdPrefetch(durationSeconds, fragmentSn) {
4135
3577
  if (this.config.disableAds) return;
4136
3578
  if (this.pendingAdBreak || this.inAdBreak) {
4137
3579
  return;
4138
3580
  }
4139
- this.pendingAdBreak = _object_spread_props(_object_spread({
4140
- marker: marker
4141
- }, fragmentSn !== void 0 ? {
3581
+ this.pendingAdBreak = _object_spread_props(_object_spread({}, durationSeconds !== void 0 ? {
3582
+ durationSeconds: durationSeconds
3583
+ } : {}, fragmentSn !== void 0 ? {
4142
3584
  detectedAtFragmentSn: fragmentSn
4143
3585
  } : {}), {
4144
3586
  isFetching: false,
4145
3587
  fetchStartTime: Date.now()
4146
3588
  });
4147
- void this.runAdPrefetch(marker);
3589
+ void this.runAdPrefetch(durationSeconds);
4148
3590
  if (this.config.debugAdTiming) {
4149
- console.log("[PREFETCH] Ad break marker registered, multi-ad prefetch started");
3591
+ console.log("[PREFETCH] Ad break registered, multi-ad prefetch started");
4150
3592
  }
4151
3593
  }
4152
3594
  },
4153
3595
  {
4154
3596
  key: "runAdPrefetch",
4155
- value: function runAdPrefetch(marker) {
3597
+ value: function runAdPrefetch(durationSeconds) {
4156
3598
  return _async_to_generator(function() {
4157
- var _this, _marker_durationSeconds, _ref, _firstBids_, durSec, context, firstBids, unused, adDurationSec, estimatedCount, firstToken, remaining, results, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, result, token;
3599
+ var _this, _ref, _firstBids_, durSec, context, firstBids, unused, adDurationSec, estimatedCount, firstToken, unused1, remaining, results, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, result, token, unused2, err;
4158
3600
  return _ts_generator(this, function(_state) {
4159
3601
  switch(_state.label){
4160
3602
  case 0:
4161
3603
  _this = this;
4162
- durSec = (_marker_durationSeconds = marker.durationSeconds) !== null && _marker_durationSeconds !== void 0 ? _marker_durationSeconds : 60;
3604
+ durSec = durationSeconds !== null && durationSeconds !== void 0 ? durationSeconds : 60;
4163
3605
  context = {
4164
3606
  breakDurationSec: durSec,
4165
3607
  remainingBreakSec: durSec
@@ -4199,6 +3641,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4199
3641
  if (this.config.debugAdTiming) {
4200
3642
  console.log("[PREFETCH] First VAST request returned no ad, aborting prefetch");
4201
3643
  }
3644
+ this.clearPendingAdBreak();
4202
3645
  return [
4203
3646
  2
4204
3647
  ];
@@ -4209,14 +3652,43 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4209
3652
  console.log("[PREFETCH] Ad duration=".concat(adDurationSec, "s, break=").concat(durSec, "s → ").concat(estimatedCount, " ad(s) needed"));
4210
3653
  }
4211
3654
  firstToken = "preload_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 7));
4212
- this.preloadedTokens.push(firstToken);
4213
- void this.adLayer.preloadAd(firstBids, firstToken);
3655
+ _state.label = 5;
3656
+ case 5:
3657
+ _state.trys.push([
3658
+ 5,
3659
+ 7,
3660
+ ,
3661
+ 8
3662
+ ]);
3663
+ return [
3664
+ 4,
3665
+ this.adLayer.preloadAd(firstBids, firstToken)
3666
+ ];
3667
+ case 6:
3668
+ _state.sent();
3669
+ if (!this.inAdBreak) {
3670
+ this.preloadedTokens.push(firstToken);
3671
+ if (this.config.debugAdTiming) {
3672
+ console.log("[PREFETCH] First ad preloaded and queued, token=".concat(firstToken));
3673
+ }
3674
+ }
3675
+ return [
3676
+ 3,
3677
+ 8
3678
+ ];
3679
+ case 7:
3680
+ unused1 = _state.sent();
4214
3681
  if (this.config.debugAdTiming) {
4215
- console.log("[PREFETCH] First ad preloading, token=".concat(firstToken));
3682
+ console.warn("[PREFETCH] First ad preload failed, token=".concat(firstToken));
4216
3683
  }
3684
+ return [
3685
+ 3,
3686
+ 8
3687
+ ];
3688
+ case 8:
4217
3689
  if (!(estimatedCount > 1)) return [
4218
3690
  3,
4219
- 6
3691
+ 19
4220
3692
  ];
4221
3693
  remaining = Array.from({
4222
3694
  length: estimatedCount - 1
@@ -4238,38 +3710,100 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4238
3710
  4,
4239
3711
  Promise.all(remaining)
4240
3712
  ];
4241
- case 5:
3713
+ case 9:
4242
3714
  results = _state.sent();
4243
3715
  _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
3716
+ _state.label = 10;
3717
+ case 10:
3718
+ _state.trys.push([
3719
+ 10,
3720
+ 17,
3721
+ 18,
3722
+ 19
3723
+ ]);
3724
+ _iterator = results[Symbol.iterator]();
3725
+ _state.label = 11;
3726
+ case 11:
3727
+ if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
3728
+ 3,
3729
+ 16
3730
+ ];
3731
+ result = _step.value;
3732
+ if (this.inAdBreak) return [
3733
+ 3,
3734
+ 16
3735
+ ];
3736
+ if (!(result.ok && result.value.length > 0)) return [
3737
+ 3,
3738
+ 15
3739
+ ];
3740
+ token = "preload_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 7));
3741
+ _state.label = 12;
3742
+ case 12:
3743
+ _state.trys.push([
3744
+ 12,
3745
+ 14,
3746
+ ,
3747
+ 15
3748
+ ]);
3749
+ return [
3750
+ 4,
3751
+ this.adLayer.preloadAd(result.value, token)
3752
+ ];
3753
+ case 13:
3754
+ _state.sent();
3755
+ if (!this.inAdBreak) {
3756
+ this.preloadedTokens.push(token);
3757
+ if (this.config.debugAdTiming) {
3758
+ console.log("[PREFETCH] Additional ad preloaded and queued, token=".concat(token));
3759
+ }
3760
+ }
3761
+ return [
3762
+ 3,
3763
+ 15
3764
+ ];
3765
+ case 14:
3766
+ unused2 = _state.sent();
3767
+ if (this.config.debugAdTiming) {
3768
+ console.warn("[PREFETCH] Additional ad preload failed, token=".concat(token));
3769
+ }
3770
+ return [
3771
+ 3,
3772
+ 15
3773
+ ];
3774
+ case 15:
3775
+ _iteratorNormalCompletion = true;
3776
+ return [
3777
+ 3,
3778
+ 11
3779
+ ];
3780
+ case 16:
3781
+ return [
3782
+ 3,
3783
+ 19
3784
+ ];
3785
+ case 17:
3786
+ err = _state.sent();
3787
+ _didIteratorError = true;
3788
+ _iteratorError = err;
3789
+ return [
3790
+ 3,
3791
+ 19
3792
+ ];
3793
+ case 18:
4244
3794
  try {
4245
- for(_iterator = results[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
4246
- result = _step.value;
4247
- if (this.inAdBreak) break;
4248
- if (result.ok && result.value.length > 0) {
4249
- token = "preload_".concat(Date.now(), "_").concat(Math.random().toString(36).slice(2, 7));
4250
- this.preloadedTokens.push(token);
4251
- void this.adLayer.preloadAd(result.value, token);
4252
- if (this.config.debugAdTiming) {
4253
- console.log("[PREFETCH] Additional ad preloading, token=".concat(token));
4254
- }
4255
- }
3795
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
3796
+ _iterator.return();
4256
3797
  }
4257
- } catch (err) {
4258
- _didIteratorError = true;
4259
- _iteratorError = err;
4260
3798
  } finally{
4261
- try {
4262
- if (!_iteratorNormalCompletion && _iterator.return != null) {
4263
- _iterator.return();
4264
- }
4265
- } finally{
4266
- if (_didIteratorError) {
4267
- throw _iteratorError;
4268
- }
3799
+ if (_didIteratorError) {
3800
+ throw _iteratorError;
4269
3801
  }
4270
3802
  }
4271
- _state.label = 6;
4272
- case 6:
3803
+ return [
3804
+ 7
3805
+ ];
3806
+ case 19:
4273
3807
  if (this.config.debugAdTiming) {
4274
3808
  console.log("[PREFETCH] Pre-fetch complete: ".concat(this.preloadedTokens.length, " ad(s) queued"));
4275
3809
  }
@@ -4341,7 +3875,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4341
3875
  key: "fetchAdInsertionPoint",
4342
3876
  value: function fetchAdInsertionPoint() {
4343
3877
  return _async_to_generator(function() {
4344
- var _this_lastAdInsertionPoint, resp, data, isNew, unused;
3878
+ var _this_lastAdInsertionPoint, _this_lastAdInsertionPoint1, resp, data, prevSegment, isNew, segmentChanged, unused;
4345
3879
  return _ts_generator(this, function(_state) {
4346
3880
  switch(_state.label){
4347
3881
  case 0:
@@ -4371,7 +3905,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4371
3905
  ];
4372
3906
  case 3:
4373
3907
  data = _state.sent();
4374
- isNew = data.updated_at !== ((_this_lastAdInsertionPoint = this.lastAdInsertionPoint) === null || _this_lastAdInsertionPoint === void 0 ? void 0 : _this_lastAdInsertionPoint.updated_at);
3908
+ prevSegment = (_this_lastAdInsertionPoint = this.lastAdInsertionPoint) === null || _this_lastAdInsertionPoint === void 0 ? void 0 : _this_lastAdInsertionPoint.segment_ts_name;
3909
+ isNew = data.updated_at !== ((_this_lastAdInsertionPoint1 = this.lastAdInsertionPoint) === null || _this_lastAdInsertionPoint1 === void 0 ? void 0 : _this_lastAdInsertionPoint1.updated_at);
3910
+ segmentChanged = prevSegment !== data.segment_ts_name;
4375
3911
  this.lastAdInsertionPoint = data;
4376
3912
  if (isNew) {
4377
3913
  this.pushAdInsertionDebug("api_response", data.segment_ts_name, {
@@ -4379,6 +3915,15 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4379
3915
  updatedAt: data.updated_at,
4380
3916
  detail: "project=".concat(data.project_id)
4381
3917
  });
3918
+ if (segmentChanged && (this.pendingAdBreak || this.adInsertionOffsetTimerId != null)) {
3919
+ this.clearAdInsertionOffsetTimer();
3920
+ this.clearPendingAdBreak();
3921
+ this.cancelAndClearPreloadedTokens();
3922
+ if (this.config.debugAdTiming) {
3923
+ console.log("[StormcloudVideoPlayer] Insertion segment changed (".concat(prevSegment, " → ").concat(data.segment_ts_name, "), stale pending state cleared"));
3924
+ }
3925
+ }
3926
+ this.checkAdInsertionInManifest();
4382
3927
  }
4383
3928
  if (this.config.debugAdTiming) {
4384
3929
  console.log("[StormcloudVideoPlayer] Ad insertion point API response:", data);
@@ -4408,6 +3953,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4408
3953
  {
4409
3954
  key: "checkAdInsertionInManifest",
4410
3955
  value: function checkAdInsertionInManifest() {
3956
+ var _this = this;
4411
3957
  var _this_hls;
4412
3958
  if (!this.lastAdInsertionPoint) return;
4413
3959
  if (this.inAdBreak || this.pendingAdBreak) return;
@@ -4427,22 +3973,42 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4427
3973
  for(var _iterator1 = fragments[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
4428
3974
  var frag = _step1.value;
4429
3975
  if (this.fragmentMatchesSegment(frag, segmentName)) {
4430
- var _ref;
3976
+ var _frag_start, _frag_duration, _ref;
3977
+ var currentTime = this.video.currentTime;
3978
+ var fragStart = (_frag_start = frag.start) !== null && _frag_start !== void 0 ? _frag_start : 0;
3979
+ var fragDuration = (_frag_duration = frag.duration) !== null && _frag_duration !== void 0 ? _frag_duration : 0;
3980
+ var isCurrentlyPlaying = fragDuration > 0 && currentTime >= fragStart && currentTime < fragStart + fragDuration;
4431
3981
  this.pushAdInsertionDebug("segment_found", segmentName, {
4432
- detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?")
3982
+ detail: "sn=".concat((_ref = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref !== void 0 ? _ref : "?", " ").concat(isCurrentlyPlaying ? "(playing)" : "(future)")
4433
3983
  });
4434
3984
  if (this.config.debugAdTiming) {
4435
- console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" found in manifest — starting pre-fetch'));
3985
+ console.log('[StormcloudVideoPlayer] Ad insertion segment "'.concat(segmentName, '" found in manifest — ') + (isCurrentlyPlaying ? "currently playing, scheduling directly" : "starting pre-fetch"));
3986
+ }
3987
+ this.startAdPrefetch(60, frag === null || frag === void 0 ? void 0 : frag.sn);
3988
+ if (isCurrentlyPlaying && !this.inAdBreak) {
3989
+ var _this_lastAdInsertionPoint_offset_seconds, _ref1;
3990
+ this.processedAdInsertionUpdatedAt = this.lastAdInsertionPoint.updated_at;
3991
+ var rawOffsetMs = ((_this_lastAdInsertionPoint_offset_seconds = this.lastAdInsertionPoint.offset_seconds) !== null && _this_lastAdInsertionPoint_offset_seconds !== void 0 ? _this_lastAdInsertionPoint_offset_seconds : 0) * 1e3;
3992
+ var elapsedInFragMs = (currentTime - fragStart) * 1e3;
3993
+ var remainingOffsetMs = Math.max(0, rawOffsetMs - elapsedInFragMs);
3994
+ this.pushAdInsertionDebug("segment_playing", segmentName, {
3995
+ offsetSeconds: this.lastAdInsertionPoint.offset_seconds,
3996
+ detail: "sn=".concat((_ref1 = frag === null || frag === void 0 ? void 0 : frag.sn) !== null && _ref1 !== void 0 ? _ref1 : "?", " (caught in manifest check)")
3997
+ });
3998
+ this.pushAdInsertionDebug("ad_scheduled", segmentName, {
3999
+ offsetSeconds: this.lastAdInsertionPoint.offset_seconds,
4000
+ detail: "in ".concat(remainingOffsetMs, "ms (adjusted for elapsed ").concat(Math.round(elapsedInFragMs), "ms)")
4001
+ });
4002
+ this.clearAdInsertionOffsetTimer();
4003
+ this.adInsertionOffsetTimerId = window.setTimeout(function() {
4004
+ _this.adInsertionOffsetTimerId = void 0;
4005
+ if (_this.inAdBreak) return;
4006
+ _this.pushAdInsertionDebug("ad_triggered", segmentName, {
4007
+ detail: "ad break started (60s, via manifest-check path)"
4008
+ });
4009
+ void _this.handleAdStart(60);
4010
+ }, remainingOffsetMs);
4436
4011
  }
4437
- var marker = {
4438
- type: "start",
4439
- durationSeconds: 60,
4440
- raw: {
4441
- apiInsertionPoint: this.lastAdInsertionPoint,
4442
- earlyDetection: true
4443
- }
4444
- };
4445
- this.startAdPrefetch(marker, frag === null || frag === void 0 ? void 0 : frag.sn);
4446
4012
  return;
4447
4013
  }
4448
4014
  }
@@ -4480,8 +4046,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4480
4046
  {
4481
4047
  key: "fragmentMatchesSegment",
4482
4048
  value: function fragmentMatchesSegment(frag, segmentName) {
4483
- var url = (frag === null || frag === void 0 ? void 0 : frag.url) || (frag === null || frag === void 0 ? void 0 : frag.relurl) || "";
4484
- return url.endsWith(segmentName) || url.includes("/" + segmentName);
4049
+ var _rawUrl_split_;
4050
+ var rawUrl = (frag === null || frag === void 0 ? void 0 : frag.url) || (frag === null || frag === void 0 ? void 0 : frag.relurl) || "";
4051
+ var url = (_rawUrl_split_ = rawUrl.split("?")[0]) !== null && _rawUrl_split_ !== void 0 ? _rawUrl_split_ : "";
4052
+ var name = segmentName.startsWith("/") ? segmentName : "/" + segmentName;
4053
+ return url.endsWith(name) || url.includes(name);
4485
4054
  }
4486
4055
  },
4487
4056
  {
@@ -4818,13 +4387,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4818
4387
  },
4819
4388
  {
4820
4389
  key: "handleAdStart",
4821
- value: function handleAdStart(_marker) {
4390
+ value: function handleAdStart(durationSeconds) {
4822
4391
  return _async_to_generator(function() {
4823
- var _this_savedMutedStateBeforeScte, adBreakDurationMs, mode, state, adBreakToken, adVolume, token, remaining, err;
4392
+ var _this_savedMutedStateBeforeAd, adBreakDurationMs, mode, state, adBreakToken, adVolume, token, remaining, err;
4824
4393
  return _ts_generator(this, function(_state) {
4825
4394
  switch(_state.label){
4826
4395
  case 0:
4827
- adBreakDurationMs = _marker.durationSeconds != null ? _marker.durationSeconds * 1e3 : void 0;
4396
+ adBreakDurationMs = durationSeconds != null ? durationSeconds * 1e3 : void 0;
4828
4397
  if (this.config.debugAdTiming) {
4829
4398
  mode = this.isLiveStream ? "LIVE" : "VOD";
4830
4399
  console.log("[CONTINUOUS-FETCH] \uD83D\uDCFA ".concat(mode, " MODE: Target duration=").concat(adBreakDurationMs, "ms"));
@@ -4835,13 +4404,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4835
4404
  this.pendingNextAdBids = null;
4836
4405
  this.isShowingPlaceholder = false;
4837
4406
  this.totalAdRequestsInBreak = 0;
4838
- if (this.savedMutedStateBeforeScte == null && !this.video.muted) {
4839
- this.savedMutedStateBeforeScte = {
4407
+ if (this.savedMutedStateBeforeAd == null && !this.video.muted) {
4408
+ this.savedMutedStateBeforeAd = {
4840
4409
  muted: false,
4841
4410
  volume: this.video.volume
4842
4411
  };
4843
4412
  }
4844
- state = (_this_savedMutedStateBeforeScte = this.savedMutedStateBeforeScte) !== null && _this_savedMutedStateBeforeScte !== void 0 ? _this_savedMutedStateBeforeScte : {
4413
+ state = (_this_savedMutedStateBeforeAd = this.savedMutedStateBeforeAd) !== null && _this_savedMutedStateBeforeAd !== void 0 ? _this_savedMutedStateBeforeAd : {
4845
4414
  muted: this.video.muted,
4846
4415
  volume: this.video.volume
4847
4416
  };
@@ -4868,6 +4437,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4868
4437
  if (this.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
4869
4438
  this.expectedAdBreakDurationMs = adBreakDurationMs;
4870
4439
  }
4440
+ if (this.expectedAdBreakDurationMs != null) {
4441
+ this.scheduleAdStopCountdown(this.expectedAdBreakDurationMs);
4442
+ }
4871
4443
  this.clearPendingAdBreak();
4872
4444
  adBreakToken = Date.now();
4873
4445
  this.activeAdRequestToken = adBreakToken;
@@ -5366,49 +4938,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5366
4938
  this.handleAdPodComplete();
5367
4939
  }
5368
4940
  },
5369
- {
5370
- key: "scheduleAdStartIn",
5371
- value: function scheduleAdStartIn(delayMs) {
5372
- var _this = this;
5373
- this.clearAdStartTimer();
5374
- var ms = Math.max(0, Math.floor(delayMs));
5375
- if (ms === 0) {
5376
- this.handleAdStart({
5377
- type: "start"
5378
- }).catch(function() {});
5379
- return;
5380
- }
5381
- this.adStartTimerId = window.setTimeout(function() {
5382
- _this.handleAdStart({
5383
- type: "start"
5384
- }).catch(function() {});
5385
- }, ms);
5386
- }
5387
- },
5388
- {
5389
- key: "clearAdStartTimer",
5390
- value: function clearAdStartTimer() {
5391
- if (this.adStartTimerId != null) {
5392
- clearTimeout(this.adStartTimerId);
5393
- this.adStartTimerId = void 0;
5394
- }
5395
- }
5396
- },
5397
- {
5398
- key: "updatePtsDrift",
5399
- value: function updatePtsDrift(ptsSecondsSample) {
5400
- var sampleMs = (this.video.currentTime - ptsSecondsSample) * 1e3;
5401
- if (!Number.isFinite(sampleMs) || Math.abs(sampleMs) > 6e4) return;
5402
- var alpha = 0.1;
5403
- this.ptsDriftEmaMs = this.ptsDriftEmaMs * (1 - alpha) + sampleMs * alpha;
5404
- }
5405
- },
5406
4941
  {
5407
4942
  key: "handleAdPodComplete",
5408
4943
  value: function handleAdPodComplete() {
5409
4944
  var _this = this;
5410
4945
  var _ref, _ref1;
5411
- var _this_savedMutedStateBeforeScte, _this_savedMutedStateBeforeScte1;
4946
+ var _this_savedMutedStateBeforeAd, _this_savedMutedStateBeforeAd1;
5412
4947
  if (this.config.debugAdTiming) {
5413
4948
  console.log("[StormcloudVideoPlayer] \uD83C\uDFC1 Ad pod complete - cleaning up");
5414
4949
  }
@@ -5430,7 +4965,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5430
4965
  this.inAdBreak = false;
5431
4966
  this.expectedAdBreakDurationMs = void 0;
5432
4967
  this.currentAdBreakStartWallClockMs = void 0;
5433
- this.clearAdStartTimer();
5434
4968
  this.clearAdStopTimer();
5435
4969
  this.adPodQueue = [];
5436
4970
  this.showAds = false;
@@ -5438,8 +4972,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5438
4972
  this.totalAdsInBreak = 0;
5439
4973
  this.totalAdRequestsInBreak = 0;
5440
4974
  this.consecutiveFailures = 0;
5441
- var restoredMuted = (_ref = (_this_savedMutedStateBeforeScte = this.savedMutedStateBeforeScte) === null || _this_savedMutedStateBeforeScte === void 0 ? void 0 : _this_savedMutedStateBeforeScte.muted) !== null && _ref !== void 0 ? _ref : this.adLayer.getOriginalMutedState();
5442
- var restoredVolume = (_ref1 = (_this_savedMutedStateBeforeScte1 = this.savedMutedStateBeforeScte) === null || _this_savedMutedStateBeforeScte1 === void 0 ? void 0 : _this_savedMutedStateBeforeScte1.volume) !== null && _ref1 !== void 0 ? _ref1 : this.adLayer.getOriginalVolume();
4975
+ var restoredMuted = (_ref = (_this_savedMutedStateBeforeAd = this.savedMutedStateBeforeAd) === null || _this_savedMutedStateBeforeAd === void 0 ? void 0 : _this_savedMutedStateBeforeAd.muted) !== null && _ref !== void 0 ? _ref : this.adLayer.getOriginalMutedState();
4976
+ var restoredVolume = (_ref1 = (_this_savedMutedStateBeforeAd1 = this.savedMutedStateBeforeAd) === null || _this_savedMutedStateBeforeAd1 === void 0 ? void 0 : _this_savedMutedStateBeforeAd1.volume) !== null && _ref1 !== void 0 ? _ref1 : this.adLayer.getOriginalVolume();
5443
4977
  this.adLayer.updateOriginalMutedState(restoredMuted, restoredVolume);
5444
4978
  this.adLayer.stop().catch(function() {});
5445
4979
  if (this.video.muted !== restoredMuted) {
@@ -5548,7 +5082,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5548
5082
  }, delay);
5549
5083
  });
5550
5084
  }
5551
- this.savedMutedStateBeforeScte = null;
5085
+ this.savedMutedStateBeforeAd = null;
5552
5086
  }
5553
5087
  },
5554
5088
  {
@@ -5698,19 +5232,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5698
5232
  return Math.max(0, this.expectedAdBreakDurationMs - elapsed);
5699
5233
  }
5700
5234
  },
5701
- {
5702
- key: "pushScteMarker",
5703
- value: function pushScteMarker(marker) {
5704
- if (!this.config.debugAdTiming) return;
5705
- this.scteMarkerHistory.push({
5706
- timestampMs: Date.now(),
5707
- marker: marker
5708
- });
5709
- if (this.scteMarkerHistory.length > DEBUG_HISTORY_LIMIT) {
5710
- this.scteMarkerHistory = this.scteMarkerHistory.slice(-DEBUG_HISTORY_LIMIT);
5711
- }
5712
- }
5713
- },
5714
5235
  {
5715
5236
  key: "pushDebugLog",
5716
5237
  value: function pushDebugLog(level, category, message, details) {
@@ -5728,23 +5249,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5728
5249
  }
5729
5250
  }
5730
5251
  },
5731
- {
5732
- key: "getRecentScteMarkers",
5733
- value: function getRecentScteMarkers() {
5734
- return this.scteMarkerHistory.map(function(entry) {
5735
- return _object_spread({
5736
- timestampMs: entry.timestampMs,
5737
- type: entry.marker.type
5738
- }, entry.marker.ptsSeconds !== void 0 ? {
5739
- ptsSeconds: entry.marker.ptsSeconds
5740
- } : {}, entry.marker.durationSeconds !== void 0 ? {
5741
- durationSeconds: entry.marker.durationSeconds
5742
- } : {}, entry.marker.raw !== void 0 ? {
5743
- raw: entry.marker.raw
5744
- } : {});
5745
- });
5746
- }
5747
- },
5748
5252
  {
5749
5253
  key: "pushAdInsertionDebug",
5750
5254
  value: function pushAdInsertionDebug(event, segmentName, opts) {
@@ -6041,7 +5545,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6041
5545
  this.clearAdInsertionOffsetTimer();
6042
5546
  this.stopContinuousFetching();
6043
5547
  this.stopFillerBreakTimer();
6044
- this.clearAdStartTimer();
6045
5548
  this.clearAdStopTimer();
6046
5549
  this.clearAdFailsafeTimer();
6047
5550
  this.clearAdRequestWatchdog();
@@ -6069,7 +5572,6 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6069
5572
  (_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
6070
5573
  this.consecutiveFailures = 0;
6071
5574
  this.debugLogEntries = [];
6072
- this.scteMarkerHistory = [];
6073
5575
  this.adInsertionDebugHistory = [];
6074
5576
  }
6075
5577
  }
@@ -6077,7 +5579,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6077
5579
  return StormcloudVideoPlayer;
6078
5580
  }();
6079
5581
  // src/ui/StormcloudVideoPlayer.tsx
6080
- import { FaPlay, FaPause, FaVolumeUp, FaVolumeMute, FaVolumeDown, FaExpand, FaCompress, FaCog, FaTimes } from "react-icons/fa";
5582
+ import { FaPlay, FaPause, FaVolumeUp, FaVolumeMute, FaVolumeDown, FaExpand, FaCompress, FaCog, FaTimes, FaCopy } from "react-icons/fa";
6081
5583
  // src/ui/OverlayRenderer.tsx
6082
5584
  import React, { useEffect, useRef, useState, useCallback, useMemo } from "react";
6083
5585
  // src/utils/overlays.ts
@@ -7546,6 +7048,11 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7546
7048
  label: "API",
7547
7049
  color: "#60a5fa"
7548
7050
  };
7051
+ case "scte35_inserted":
7052
+ return {
7053
+ label: "SCTE-35",
7054
+ color: "#f43f5e"
7055
+ };
7549
7056
  case "segment_found":
7550
7057
  return {
7551
7058
  label: "FOUND",
@@ -7716,6 +7223,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7716
7223
  if (minSegmentsBeforePlay !== void 0) cfg.minSegmentsBeforePlay = minSegmentsBeforePlay;
7717
7224
  if (disableAds !== void 0) cfg.disableAds = disableAds;
7718
7225
  cfg.disableFiller = disableFiller !== null && disableFiller !== void 0 ? disableFiller : true;
7226
+ if (swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
7719
7227
  var player = new StormcloudVideoPlayer(cfg);
7720
7228
  playerRef.current = player;
7721
7229
  player.load().then(function() {
@@ -8589,9 +8097,13 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
8589
8097
  overflowX: "hidden",
8590
8098
  height: "calc(100% - 46px)",
8591
8099
  display: "grid",
8592
- gap: "12px"
8100
+ gap: "12px",
8101
+ minWidth: 0
8593
8102
  },
8594
8103
  children: /* @__PURE__ */ jsxs2("div", {
8104
+ style: {
8105
+ minWidth: 0
8106
+ },
8595
8107
  children: [
8596
8108
  /* @__PURE__ */ jsx2("div", {
8597
8109
  style: {
@@ -8607,7 +8119,8 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
8607
8119
  /* @__PURE__ */ jsx2("div", {
8608
8120
  style: {
8609
8121
  display: "grid",
8610
- gap: "6px"
8122
+ gap: "6px",
8123
+ minWidth: 0
8611
8124
  },
8612
8125
  children: debugMarkers.length === 0 ? /* @__PURE__ */ jsx2("div", {
8613
8126
  style: {
@@ -8617,53 +8130,129 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
8617
8130
  children: "No ad insertion events yet."
8618
8131
  }) : debugMarkers.map(function(entry, idx) {
8619
8132
  var evt = formatAdInsertionEvent(entry.event);
8133
+ var fileName = entry.segmentName ? entry.segmentName.split("/").pop() || entry.segmentName : "";
8620
8134
  return /* @__PURE__ */ jsxs2("div", {
8621
8135
  style: {
8622
- display: "grid",
8623
- gridTemplateColumns: "56px 54px 1fr",
8624
- gap: "8px",
8625
- alignItems: "center",
8136
+ minWidth: 0,
8626
8137
  fontFamily: "'SF Mono', 'Cascadia Code', monospace",
8627
8138
  fontSize: "11px",
8628
8139
  background: "rgba(255,255,255,0.05)",
8629
8140
  border: "1px solid rgba(255,255,255,0.08)",
8630
8141
  borderRadius: "8px",
8631
- padding: "6px 8px"
8142
+ padding: "6px 8px",
8143
+ display: "flex",
8144
+ flexDirection: "column",
8145
+ gap: "4px"
8632
8146
  },
8633
8147
  children: [
8634
- /* @__PURE__ */ jsx2("span", {
8148
+ /* @__PURE__ */ jsxs2("div", {
8635
8149
  style: {
8636
- color: "rgba(255,255,255,0.68)"
8150
+ display: "grid",
8151
+ gridTemplateColumns: "56px 54px minmax(0, 1fr) 20px",
8152
+ gap: "6px",
8153
+ alignItems: "center",
8154
+ minWidth: 0
8637
8155
  },
8638
- children: formatDebugClock(entry.timestampMs)
8156
+ children: [
8157
+ /* @__PURE__ */ jsx2("span", {
8158
+ style: {
8159
+ color: "rgba(255,255,255,0.68)"
8160
+ },
8161
+ children: formatDebugClock(entry.timestampMs)
8162
+ }),
8163
+ /* @__PURE__ */ jsx2("span", {
8164
+ style: {
8165
+ fontWeight: 700,
8166
+ color: evt.color,
8167
+ fontSize: "10px"
8168
+ },
8169
+ children: evt.label
8170
+ }),
8171
+ /* @__PURE__ */ jsx2("span", {
8172
+ style: {
8173
+ color: "rgba(255,255,255,0.88)",
8174
+ overflow: "hidden",
8175
+ textOverflow: "ellipsis",
8176
+ whiteSpace: "nowrap",
8177
+ minWidth: 0
8178
+ },
8179
+ title: entry.segmentName,
8180
+ children: fileName
8181
+ }),
8182
+ /* @__PURE__ */ jsx2("button", {
8183
+ onClick: function onClick() {
8184
+ return navigator.clipboard.writeText(entry.segmentName);
8185
+ },
8186
+ title: entry.segmentName,
8187
+ style: {
8188
+ background: "none",
8189
+ border: "none",
8190
+ cursor: "pointer",
8191
+ padding: "2px",
8192
+ color: "rgba(255,255,255,0.45)",
8193
+ display: "flex",
8194
+ alignItems: "center",
8195
+ justifyContent: "center",
8196
+ borderRadius: "4px",
8197
+ flexShrink: 0
8198
+ },
8199
+ onMouseEnter: function onMouseEnter(e) {
8200
+ return e.currentTarget.style.color = "rgba(255,255,255,0.9)";
8201
+ },
8202
+ onMouseLeave: function onMouseLeave(e) {
8203
+ return e.currentTarget.style.color = "rgba(255,255,255,0.45)";
8204
+ },
8205
+ children: /* @__PURE__ */ jsx2(FaCopy, {
8206
+ size: 10
8207
+ })
8208
+ })
8209
+ ]
8639
8210
  }),
8640
- /* @__PURE__ */ jsx2("span", {
8211
+ (entry.offsetSeconds != null || entry.detail || entry.updatedAt) && /* @__PURE__ */ jsxs2("div", {
8641
8212
  style: {
8642
- fontWeight: 700,
8643
- color: evt.color,
8213
+ display: "flex",
8214
+ flexWrap: "wrap",
8215
+ gap: "6px",
8216
+ paddingLeft: "0px",
8644
8217
  fontSize: "10px"
8645
8218
  },
8646
- children: evt.label
8647
- }),
8648
- /* @__PURE__ */ jsx2("span", {
8649
- style: {
8650
- color: "rgba(255,255,255,0.88)"
8651
- },
8652
- children: /* @__PURE__ */ jsxs2("span", {
8653
- style: {
8654
- display: "inline-block",
8655
- maxWidth: "100%",
8656
- verticalAlign: "bottom",
8657
- overflow: "hidden",
8658
- textOverflow: "ellipsis",
8659
- whiteSpace: "nowrap"
8660
- },
8661
- children: [
8662
- entry.segmentName,
8663
- entry.offsetSeconds != null ? " +".concat(entry.offsetSeconds, "s") : "",
8664
- entry.detail ? " (".concat(entry.detail, ")") : ""
8665
- ]
8666
- })
8219
+ children: [
8220
+ entry.offsetSeconds != null && /* @__PURE__ */ jsxs2("span", {
8221
+ style: {
8222
+ color: "rgba(255,255,255,0.55)",
8223
+ background: "rgba(255,255,255,0.06)",
8224
+ borderRadius: "4px",
8225
+ padding: "1px 5px"
8226
+ },
8227
+ children: [
8228
+ "+",
8229
+ entry.offsetSeconds.toFixed(2),
8230
+ "s"
8231
+ ]
8232
+ }),
8233
+ entry.detail && /* @__PURE__ */ jsx2("span", {
8234
+ style: {
8235
+ color: "rgba(255,255,255,0.55)",
8236
+ background: "rgba(255,255,255,0.06)",
8237
+ borderRadius: "4px",
8238
+ padding: "1px 5px",
8239
+ overflow: "hidden",
8240
+ textOverflow: "ellipsis",
8241
+ whiteSpace: "nowrap",
8242
+ maxWidth: "100%"
8243
+ },
8244
+ children: entry.detail
8245
+ }),
8246
+ entry.updatedAt && /* @__PURE__ */ jsx2("span", {
8247
+ style: {
8248
+ color: "rgba(255,255,255,0.38)",
8249
+ background: "rgba(255,255,255,0.04)",
8250
+ borderRadius: "4px",
8251
+ padding: "1px 5px"
8252
+ },
8253
+ children: formatAiRelativeTime(entry.updatedAt)
8254
+ })
8255
+ ]
8667
8256
  })
8668
8257
  ]
8669
8258
  }, "".concat(entry.timestampMs, "-").concat(idx));