define([
  "exports",
  "./../modules/common/playback/playbackmanager.js",
  "./../modules/focusmanager.js",
  "./../modules/cardbuilder/cardbuilder.js",
  "./../modules/imageloader/imageloader.js",
  "./../modules/dom.js",
  "./../modules/browser.js",
  "./../modules/common/globalize.js",
  "./../modules/common/datetime.js",
  "./../modules/layoutmanager.js",
  "./../modules/common/itemmanager/itemmanager.js",
  "./../modules/loading/loading.js",
  "./../modules/emby-apiclient/events.js",
  "./../modules/emby-apiclient/connectionmanager.js",
  "./../modules/appheader/appheader.js",
  "./../modules/mediainfo/mediainfo.js",
  "./../modules/backdrop/backdrop.js",
  "./playqueue.js",
  "./tvplayqueue.js",
  "./lyrics.js",
  "./../modules/approuter.js",
  "./../modules/itemcontextmenu.js",
  "./../modules/shortcuts.js",
  "./../modules/common/inputmanager.js",
  "./../modules/common/usersettings/usersettings.js",
  "./../modules/input/mouse.js",
  "./../modules/emby-elements/emby-scroller/emby-scroller.js",
  "./../modules/emby-elements/emby-button/paper-icon-button-light.js",
  "./../modules/emby-elements/emby-tabs/emby-tabs.js",
  "./../modules/emby-elements/emby-slider/emby-slider.js",
  "./../modules/common/appsettings.js",
  "./../modules/common/servicelocator.js",
  "./../modules/input/keyboard.js",
  "./../modules/viewmanager/baseview.js",
], function (
  _exports,
  _playbackmanager,
  _focusmanager,
  _cardbuilder,
  _imageloader,
  _dom,
  _browser,
  _globalize,
  _datetime,
  _layoutmanager,
  _itemmanager,
  _loading,
  _events,
  _connectionmanager,
  _appheader,
  _mediainfo,
  _backdrop,
  _playqueue,
  _tvplayqueue,
  _lyrics,
  _approuter,
  _itemcontextmenu,
  _shortcuts,
  _inputmanager,
  _usersettings,
  _mouse,
  _embyScroller,
  _paperIconButtonLight,
  _embyTabs,
  _embySlider,
  _appsettings,
  _servicelocator,
  _keyboard,
  _baseview,
) {
  Object.defineProperty(_exports, "__esModule", { value: !0 }),
    (_exports.default = void 0),
    require(["css!videoosd/videoosd.css"]);
  var useBackdropFilterForBlur = _dom.default.allowBackdropFilter(),
    headerElement = document.querySelector(".skinHeader"),
    backdropContainer = document.querySelector(".backdropContainer"),
    backgroundContainer = document.querySelector(".backgroundContainer");
  function showActionSheet(options) {
    return Emby.importModule("./modules/actionsheet/actionsheet.js").then(
      function (ActionSheet) {
        return ActionSheet.show(options);
      },
    );
  }
  var deviceMemory,
    platform,
    cores,
    enableHighResBlur = !(
      (cores = navigator.hardwareConcurrency || 4) < 6 ||
      (deviceMemory = navigator.deviceMemory || 2) < 2 ||
      ((platform = (navigator.platform || "").toLowerCase()),
      "android" === globalThis.appMode &&
        (cores < 4 || deviceMemory < 2 || platform.includes("armv7")))
    );
  function isDisplayingLocalVideo(player, mediaType) {
    return (
      !(!player || !player.isLocalPlayer) &&
      ("Video" === mediaType ||
        (!mediaType &&
          _playbackmanager.default.isPlayingMediaType(["Video"], player)))
    );
  }
  function getRewindIconLTR() {
    switch (_usersettings.default.skipBackLength()) {
      case 5e3:
        return "&#xe05b;";
      case 1e4:
        return "&#xe059;";
      case 3e4:
        return "&#xe05a;";
      default:
        return "&#xE042;";
    }
  }
  function getForwardIconLTR() {
    switch (_usersettings.default.skipForwardLength()) {
      case 5e3:
        return "&#xe058;";
      case 1e4:
        return "&#xe056;";
      case 3e4:
        return "&#xe057;";
      default:
        return "&#xE042;";
    }
  }
  function showMoreMenu(item, button) {
    _connectionmanager.default
      .getApiClient(item.ServerId)
      .getCurrentUser()
      .then(function (user) {
        return _itemcontextmenu.default.show(
          (function (item, user, button) {
            return {
              items: [item],
              open: !1,
              play: !1,
              playAllFromHere: !1,
              queueAllFromHere: !1,
              positionTo: button,
              cancelTimer: !1,
              record: !1,
              deleteItem: !1,
              shuffle: !1,
              instantMix: !1,
              user: user,
              share: !0,
              queue: !1,
              editSubtitles: !1,
              positionY: "above",
              transformOrigin: "center bottom",
              convert: !1,
              refreshMetadata: !1,
              identify: !1,
              autoTvLayout: !1,
            };
          })(item, user, button),
        );
      });
  }
  function focusMainOsdControls(instance) {
    _focusmanager.default.focus(instance.nowPlayingPositionSlider);
  }
  function hideOrShowAll(instance, elems, hide, focusedElement) {
    for (var wasFocused, i = 0, length = elems.length; i < length; i++) {
      var elem = elems[i];
      hide
        ? (focusedElement && focusedElement === elem && (wasFocused = !0),
          elem.classList.add("hide"))
        : elem.classList.remove("hide");
    }
    wasFocused && focusMainOsdControls(instance);
  }
  function getTextActionButton(item, text) {
    return (
      (text = text || _itemmanager.default.getDisplayName(item, {})),
      _layoutmanager.default.tv
        ? text
        : "<button " +
          _shortcuts.default.getShortcutAttributesHtml(item, {}) +
          ' type="button" class="itemAction button-link osdTextActionButton" is="emby-button" data-action="link">' +
          text +
          "</button>"
    );
  }
  function getSecondaryName(item, enableLinkButton) {
    var title = _itemmanager.default.getDisplayName(item, {
      includeParentInfo: "Program" !== item.Type,
      includeIndexNumber: "Program" !== item.Type,
    });
    return enableLinkButton ? getTextActionButton(item, title) : title;
  }
  function getDefaultOsdContentSection() {
    return _layoutmanager.default.tv ||
      1056 <= _dom.default.getWindowSize().innerWidth
      ? "playqueue"
      : null;
  }
  function destroyPlayQueue(instance) {
    var playQueue = instance.playQueue;
    playQueue && (playQueue.destroy(), (instance.playQueue = null));
  }
  function destroyLyricsRenderer(instance) {
    var lyricsRenderer = instance.lyricsRenderer;
    lyricsRenderer &&
      (lyricsRenderer.destroy(), (instance.lyricsRenderer = null));
  }
  function destroyStats(instance) {
    var statsOverlay = instance.statsOverlay;
    statsOverlay && (statsOverlay.destroy(), (instance.statsOverlay = null));
  }
  function destroySubtitleOffsetOverlay(instance) {
    var subtitleOffsetOverlay = instance.subtitleOffsetOverlay;
    subtitleOffsetOverlay &&
      (subtitleOffsetOverlay.destroy(),
      (instance.subtitleOffsetOverlay = null));
  }
  function clearBlurFromDocumentElement() {
    document.documentElement.classList.remove("doc-nowplaying-blur"),
      (document.documentElement.style.backgroundImage = null),
      backgroundContainer && (backgroundContainer.style.backgroundImage = null);
  }
  function shouldOsdBeShown(instance) {
    return (
      !_layoutmanager.default.tv ||
      !!instance.currentVisibleMenu ||
      !(instance = instance.currentPlayer) ||
      isDisplayingLocalVideo(instance)
    );
  }
  var supportsTouchEvent = "ontouchstart" in document.documentElement;
  function rewind(instance, animate) {
    var player = instance.currentPlayer;
    animate &&
      (((animate = instance.view.querySelector(
        ".osd-rew-animationtext",
      )).innerHTML =
        "-" + parseInt(_usersettings.default.skipBackLength() / 1e3)),
      fadeInAndOut(animate)),
      _playbackmanager.default.rewind(player);
  }
  function fadeInAndOut(elem) {
    if (elem.animate)
      try {
        elem.animate(
          [
            { opacity: "1", offset: 0.5 },
            { opacity: "0", transform: "none", offset: 1 },
          ],
          { duration: 600, iterations: 1, easing: "ease-out" },
        );
      } catch (err) {
        console.log("error animating element: " + err);
      }
  }
  function fastForward(instance, animate) {
    var player = instance.currentPlayer;
    animate &&
      (((animate = instance.view.querySelector(
        ".osd-ff-animationtext",
      )).innerHTML =
        "+" + parseInt(_usersettings.default.skipForwardLength() / 1e3)),
      fadeInAndOut(animate)),
      _playbackmanager.default.fastForward(player);
  }
  function onOsdClick(e, instance, elementToFocusIfShowing, showOsdIfNoEvent) {
    var target = e.target;
    if (target.closest(".videoOsdBottom"))
      showOsdIfNoEvent && instance.showOsd();
    else if (!target.closest("button"))
      return (
        (target = instance.currentPlayer),
        !e.button && target && isDisplayingLocalVideo(target)
          ? (instance.showOsd(null, elementToFocusIfShowing),
            _playbackmanager.default.playPause(target))
          : showOsdIfNoEvent && instance.showOsd(),
        1
      );
  }
  function toggleStats(instance) {
    require(["playerStats"], function (PlayerStats) {
      var player = instance.currentPlayer;
      player &&
        (instance.statsOverlay
          ? instance.statsOverlay.toggle()
          : ((instance.statsOverlay = new PlayerStats({
              player: player,
              view: instance.view,
            })),
            _events.default.on(
              instance.statsOverlay,
              "close",
              function () {
                this.currentVisibleMenu &&
                  !this.upNextContainer._visible &&
                  _focusmanager.default.focus(this.btnVideoOsdSettingsRight);
              }.bind(instance),
            )));
    });
  }
  function setBottomTabIndex(instance, index) {
    var bottomTabButtons,
      bottomTabs = instance.bottomTabs;
    -1 === index
      ? bottomTabs.selectedIndex(index)
      : ((bottomTabButtons = instance.bottomTabButtons),
        instance.showOsd(null, bottomTabButtons[index]),
        bottomTabs.selectedIndex(index),
        _focusmanager.default.focus(bottomTabButtons[index]));
  }
  function onRewindInputCommand(e, instance) {
    instance.currentVisibleMenu ||
      e.detail.repeat ||
      (rewind(instance), e.preventDefault()),
      shouldOsdBeShown(instance) && instance.showOsd();
  }
  function onFastForwardInputCommand(e, instance) {
    instance.currentVisibleMenu ||
      e.detail.repeat ||
      (fastForward(instance), e.preventDefault()),
      shouldOsdBeShown(instance) && instance.showOsd();
  }
  function startOsdHideTimer(instance, timeoutMs) {
    var isLocalVideo;
    stopOsdHideTimer(instance),
      instance.paused ||
        !(isLocalVideo = isDisplayingLocalVideo(instance.currentPlayer)) ||
        0 === timeoutMs ||
        _focusmanager.default.hasExclusiveFocusScope() ||
        (instance.osdHideTimeout = setTimeout(
          instance.boundOnOsdHideTimeout,
          timeoutMs || (isLocalVideo ? 4e3 : 1e4),
        ));
  }
  function stopOsdHideTimer(instance) {
    var osdHideTimeout = instance.osdHideTimeout;
    osdHideTimeout &&
      (clearTimeout(osdHideTimeout), (instance.osdHideTimeout = null));
  }
  var systemUIHidden,
    orientationLocked = !1;
  function onOrientationChangeSuccess() {
    orientationLocked = !0;
  }
  function onOrientationChangeError(err) {
    (orientationLocked = !0), console.log("error locking orientation: " + err);
  }
  function setSystemUIHidden(hidden) {
    if (
      systemUIHidden !== hidden &&
      ((systemUIHidden = hidden), _servicelocator.appHost.setSystemUIHidden)
    )
      try {
        _servicelocator.appHost.setSystemUIHidden(hidden);
      } catch (err) {
        console.log("Error in setSystemUIHidden: " + err);
      }
  }
  var enableOrientationLock = !_browser.default.tv;
  function lockOrientation(type) {
    var _screen$orientation;
    enableOrientationLock &&
      !(function (orientation) {
        var promise;
        try {
          return (promise =
            screen.orientation && screen.orientation.lock
              ? screen.orientation.lock(orientation)
              : promise) && promise.then
            ? promise
            : Promise.resolve();
        } catch (err) {
          return Promise.reject(err);
        }
      })(
        (type =
          type ||
          (null == (_screen$orientation = screen.orientation)
            ? void 0
            : _screen$orientation.type) ||
          "landscape"),
      ).then(onOrientationChangeSuccess, onOrientationChangeError);
  }
  function unlockOrientation() {
    if (
      enableOrientationLock &&
      orientationLocked &&
      screen.orientation &&
      screen.orientation.unlock
    ) {
      try {
        screen.orientation.unlock();
      } catch (err) {
        console.log("error unlocking orientation: " + err);
      }
      orientationLocked = !1;
    }
  }
  function VideoOsd(view, params) {
    _baseview.default.apply(this, arguments);
    var comingUpNextDisplayed,
      isEnabled,
      currentDisplayItem,
      currentDisplayChapters,
      currentIntroInfo,
      currentCreditsInfo,
      currentMediaSource,
      currentItemThumbnails,
      currentItemThumbnailsPromise,
      enableProgressByTimeOfDay,
      skipIntroValidated,
      enableAutoSkipIntro,
      lastPointerUpType,
      currentOsdContentSectionName,
      self = this,
      currentPlayerSupportedCommands = [],
      currentRuntimeTicks = 0,
      lastUpdateTime = 0,
      ratingTextNeedsUpdate = !0,
      programStartDateMs = 0,
      programEndDateMs = 0,
      playbackStartTimeTicks = 0,
      nowPlayingVolumeSlider =
        ((this.currentLockState = 0),
        view.querySelector(".videoOsdVolumeSlider")),
      videoOsdVolumeSliderWrapper = view.querySelector(
        ".videoOsdVolumeSliderWrapper",
      ),
      brightnessSlider = view.querySelector(".videoOsdBrightnessSlider"),
      brightnessSliderContainer = view.querySelector(
        ".brightnessSliderContainer",
      ),
      videoOsdPositionText =
        ((this.nowPlayingPositionSlider = view.querySelector(
          ".videoOsdPositionSlider",
        )),
        view.querySelector(".videoOsdPositionText")),
      videoOsdDurationText = view.querySelector(".videoOsdDurationText"),
      rewindButtons = view.querySelectorAll(".btnRewind"),
      fastForwardButtons = view.querySelectorAll(".btnOsdFastForward"),
      stopButtons =
        ((this.btnPause = view.querySelector(".videoOsd-btnPause")),
        view.querySelectorAll(".btnVideoOsd-stop")),
      btnRepeatMode = view.querySelector(".btnOsdRepeatMode"),
      btnOsdMoreBottom = view.querySelector(".btnOsdMore-bottom"),
      btnOsdMoreTitle = view.querySelector(".btnOsdMore-title"),
      transitionEndEventName = _dom.default.whichTransitionEvent(),
      btnPreviousTrack =
        ((this.osdBottomElement = view.querySelector(".videoOsdBottom")),
        view.querySelector(".btnPreviousTrack")),
      btnNextTrack = view.querySelector(".btnNextTrack"),
      buttonMute = view.querySelector(".buttonMute"),
      btnSubtitles = view.querySelector(".btnSubtitles"),
      btnAudio = view.querySelector(".btnAudio"),
      btnFullscreen = view.querySelector(".btnFullscreen"),
      videoOsdSecondaryText = view.querySelector(".videoOsdSecondaryText"),
      videoOsdBottomButtons =
        ((this.videoOsdText = view.querySelector(".videoOsdText")),
        view.querySelector(".videoOsdBottom-buttons")),
      mainTransportButtons = view.querySelector(
        ".videoOsd-maintransportbuttons",
      ),
      videoOsdPositionContainer = view.querySelector(
        ".videoOsdPositionContainer",
      ),
      osdTitle = view.querySelector(".videoOsdTitle"),
      videoOsdThirdTitle = view.querySelector(".videoOsdThirdTitle"),
      videoOsdParentTitle = view.querySelector(".videoOsdParentTitle-small"),
      videoOsdParentTitleLarge = view.querySelector(
        ".videoOsdParentTitle-large",
      ),
      osdPosterContainer = view.querySelector(".osdPosterContainer"),
      videoOsdSecondaryMediaInfo = view.querySelector(
        ".videoOsdSecondaryMediaInfo",
      ),
      videoOsdAudioInfo = view.querySelector(".videoOsd-audioInfo"),
      mainLockButton = view.querySelector(".videoOsd-btnLock"),
      tabContainers =
        ((this.bottomTabs = view.querySelector(".videoOsdBottom-tabs")),
        (this.bottomTabButtons = view.querySelectorAll(".videoosd-tab-button")),
        view.querySelectorAll(".videoosd-tab")),
      btnCloseTabContent =
        ((this.bottomTabControllers = []),
        (this.bottomTabControllers.length = tabContainers.length),
        view.querySelector(".btnCloseTabContent")),
      tabContainersElem = view.querySelector(".videoosd-tabcontainers"),
      videoOsdBottomContentbuttons = view.querySelector(
        ".videoOsdBottom-contentbuttons",
      ),
      videoOsdBottomMaincontrols =
        ((this.upNextContainer = view.querySelector(".upNextContainer")),
        view.querySelector(".videoOsdBottom-maincontrols")),
      videoOsdVolumeControls = view.querySelector(".videoOsdVolumeControls"),
      videoOsdButtomButtonsTopRight = view.querySelector(
        ".videoOsdBottom-buttons-topright",
      ),
      ratingInfoContainer = view.querySelector(".videoOsd-ratingInfo"),
      ratingTextElement = view.querySelector(".videoOsd-ratingText"),
      btnSkipIntro = view.querySelector(".btnSkipIntro"),
      skipIntroContainer = view.querySelector(".skipIntroContainer"),
      btnLyrics = view.querySelector(".btnLyrics"),
      btnVideoOsdSettingsTransportButton =
        ((this.btnRecord = view.querySelector(".btnRecord")),
        (this.btnVideoOsdSettingsRight = view.querySelector(
          ".btnVideoOsdSettings-right",
        )),
        view.querySelector(".btnVideoOsdSettings-transport")),
      btnPlayNextFromUpNextProgress = view.querySelector(
        ".btnPlayNextFromUpNext-progress",
      ),
      btnHideUpNext = view.querySelector(".btnHideUpNext"),
      enableSkipIntro = !0;
    _layoutmanager.default.tv
      ? videoOsdBottomButtons.classList.add("videoOsdBottom-buttons-tv")
      : (videoOsdPositionText.classList.add("videoOsd-customFont-x0"),
        videoOsdDurationText.classList.add("videoOsd-customFont-x0"),
        ratingTextElement.classList.add("videoOsd-customFont-x2"),
        videoOsdBottomButtons.classList.add("videoOsd-customFont-x2"),
        videoOsdButtomButtonsTopRight.classList.add("videoOsd-customFont-x2"),
        skipIntroContainer.classList.add("videoOsd-customFont-x2"),
        this.upNextContainer.classList.add("videoOsd-customFont-x2"),
        this.osdBottomElement.classList.add("videoOsd-nobuttonmargin"));
    for (var i = 0, length = fastForwardButtons.length; i < length; i++) {
      icon = btnFastForward = void 0;
      var btnFastForward = fastForwardButtons[i],
        icon = btnFastForward.querySelector("i");
      switch (
        ((icon.innerHTML = (
          "rtl" === document.dir ? getRewindIconLTR : getForwardIconLTR
        )()),
        _usersettings.default.skipForwardLength())
      ) {
        case 5e3:
        case 1e4:
        case 3e4:
          break;
        default:
          icon.classList.add("videoOsd-forwardIcon-flipped");
      }
    }
    for (var _i = 0, _length = rewindButtons.length; _i < _length; _i++)
      rewindButtons[_i].querySelector("i").innerHTML = (
        "rtl" === document.dir ? getForwardIconLTR : getRewindIconLTR
      )();
    function updateRecordingButton(item, user) {
      item && "Program" === item.Type
        ? user.Policy.EnableLiveTvManagement &&
          require(["recordingButton"], function (RecordingButton) {
            var recordingButtonManager = self.recordingButtonManager;
            recordingButtonManager
              ? recordingButtonManager.refreshItem(item)
              : ((recordingButtonManager = self.recordingButtonManager =
                  new RecordingButton({ item: item, button: self.btnRecord })),
                self.btnRecord.classList.remove("hide"));
          })
        : ((user = self.recordingButtonManager) &&
            (user.destroy(), (self.recordingButtonManager = null)),
          self.btnRecord.classList.add("hide"));
    }
    function updateButtomTabsVisibility(state, item, displayItem) {
      var apiClient;
      item
        ? ((apiClient = _connectionmanager.default.getApiClient(item)),
          ("Video" === item.MediaType
            ? apiClient.getUserViews({}, apiClient.getCurrentUserId())
            : Promise.resolve({ Items: [] })
          ).then(function (result) {
            var bottomTabButtons = self.bottomTabButtons,
              result =
                ("Video" === item.MediaType
                  ? bottomTabButtons[0].classList.remove("hide")
                  : bottomTabButtons[0].classList.add("hide"),
                currentDisplayChapters && currentDisplayChapters.length
                  ? bottomTabButtons[1].classList.remove("hide")
                  : bottomTabButtons[1].classList.add("hide"),
                displayItem.People && displayItem.People.length
                  ? bottomTabButtons[2].classList.remove("hide")
                  : bottomTabButtons[2].classList.add("hide"),
                !(function (userViews) {
                  for (
                    var _i2 = 0, _length2 = userViews.length;
                    _i2 < _length2;
                    _i2++
                  )
                    if ("livetv" === userViews[_i2].CollectionType) return 1;
                })(result.Items)
                  ? (bottomTabButtons[3].classList.add("hide"),
                    bottomTabButtons[4].classList.add("hide"))
                  : (bottomTabButtons[3].classList.remove("hide"),
                    bottomTabButtons[4].classList.remove("hide")),
                self.bottomTabs),
              selectedIndex =
                (view.querySelector(".videoosd-tab-button:not(.hide)")
                  ? (tabContainersElem.classList.remove("hide"),
                    result.classList.remove("hide"))
                  : (tabContainersElem.classList.add("hide"),
                    result.classList.add("hide")),
                result.selectedIndex());
            0 <= selectedIndex &&
              (bottomTabButtons[selectedIndex].classList.contains("hide")
                ? result.selectedIndex(-1)
                : loadBottomTabController(selectedIndex, !0));
          }))
        : (self.bottomTabs.selectedIndex(-1),
          tabContainersElem.classList.add("hide"),
          self.bottomTabs.classList.add("hide"));
    }
    function updateDisplayItem(state, itemInfo, user) {
      var item = itemInfo.originalItem,
        itemInfo =
          ((self.currentItem = item),
          (currentItemThumbnails = currentItemThumbnailsPromise = null),
          itemInfo.displayItem || item);
      (currentDisplayChapters = (function (chapters) {
        for (
          var list = [], _i3 = 0, _length3 = chapters.length;
          _i3 < _length3;
          _i3++
        ) {
          var chapter = chapters[_i3];
          (chapter.MarkerType && "Chapter" !== chapter.MarkerType) ||
            list.push(chapter);
        }
        return list;
      })((currentDisplayItem = itemInfo).Chapters || [])),
        updateRecordingButton(itemInfo, user);
      var user = isDisplayingLocalVideo(self.currentPlayer, item.MediaType),
        item =
          (updateButtomTabsVisibility(0, item, itemInfo),
          itemInfo.EpisodeTitle || itemInfo.IsSeries
            ? (primaryNameText = itemInfo.Name)
            : itemInfo.SeriesName
            ? ((primaryNameText = itemInfo.SeriesName),
              itemInfo.SeriesId &&
                !user &&
                (primaryNameHtml = getTextActionButton({
                  Id: itemInfo.SeriesId,
                  Type: "Series",
                  IsFolder: !0,
                  ServerId: itemInfo.ServerId,
                  Name: itemInfo.SeriesName,
                  ParentId: itemInfo.ParentId,
                })))
            : itemInfo.ArtistItems &&
              itemInfo.ArtistItems.length &&
              ((primaryNameText = itemInfo.Name),
              (primaryNameHtml = (function (displayItem) {
                var html = [],
                  artistItems = displayItem.ArtistItems;
                if (artistItems)
                  for (var i = 0, length = artistItems.length; i < length; i++)
                    html.push(
                      getTextActionButton({
                        Id: artistItems[i].Id,
                        ServerId: displayItem.ServerId,
                        Name: artistItems[i].Name,
                        Type: "MusicArtist",
                        IsFolder: !0,
                      }),
                    );
                return html;
              })(itemInfo).join(", "))),
          (primaryNameHtml = primaryNameHtml || primaryNameText),
          !(function (item, originalItem, title) {
            _appheader.default.setLogoTitle({
              items: [item, originalItem],
              titleText: "",
              preferredLogoImageTypes: ["LogoLightColor", "LogoLight", "Logo"],
            });
            originalItem = title || (item ? item.Name : null);
            originalItem && (document.title = originalItem);
          })(itemInfo, item, primaryNameText),
          !(function (displayItem, item, displayingLocalVideo, mediaType) {
            var backdropItems = [displayItem];
            if (
              (item.Id !== displayItem.Id && backdropItems.push(item),
              displayingLocalVideo)
            )
              _backdrop.default.setBackdrops(backdropItems),
                view.classList.add(
                  "darkContentContainer",
                  "graphicContentContainer",
                ),
                headerElement.classList.add("headroom-scrolling"),
                clearBlurFromDocumentElement();
            else {
              displayItem =
                "Video" === mediaType
                  ? "nowPlayingVideoBackgroundStyle"
                  : "nowPlayingAudioBackgroundStyle";
              if (
                "blur" === _usersettings.default[displayItem]() &&
                (item = (backdropItems = getDetailImageItemsSync().Items)[0])
              ) {
                displayingLocalVideo = _imageloader.default.getImageUrl(
                  item,
                  _connectionmanager.default.getApiClient(item),
                  { width: 100, adjustForPixelRatio: !1 },
                ).imgUrl;
                if (displayingLocalVideo)
                  return (
                    _backdrop.default.setBackdrop(displayingLocalVideo),
                    displayingLocalVideo
                      ? (view.classList.add("darkContentContainer"),
                        view.classList.remove("graphicContentContainer"),
                        headerElement.classList.remove("headroom-scrolling"),
                        document.documentElement.classList.add(
                          "doc-nowplaying-blur",
                        ))
                      : (view.classList.remove(
                          "darkContentContainer",
                          "graphicContentContainer",
                        ),
                        headerElement.classList.remove("headroom-scrolling"),
                        clearBlurFromDocumentElement())
                  );
              }
              _backdrop.default.setBackdrops(backdropItems),
                clearBlurFromDocumentElement(),
                headerElement.classList.remove("headroom-scrolling"),
                _backdrop.default.hasBackdrop()
                  ? view.classList.add(
                      "darkContentContainer",
                      "graphicContentContainer",
                    )
                  : view.classList.remove(
                      "darkContentContainer",
                      "graphicContentContainer",
                    );
            }
          })(itemInfo, item, user, item.MediaType),
          user ? setPoster(null) : setPoster(itemInfo),
          (primaryNameText = osdTitle),
          (secondaryName =
            "Audio" === item.MediaType
              ? ((item = primaryNameHtml),
                (primaryNameHtml = secondaryName =
                  getSecondaryName(itemInfo, !1)),
                item)
              : getSecondaryName(itemInfo, !user)),
          primaryNameHtml ||
            ((primaryNameHtml = secondaryName), (secondaryName = null)),
          (videoOsdParentTitle.innerHTML = primaryNameHtml),
          (videoOsdParentTitleLarge.innerHTML = primaryNameHtml)
            ? videoOsdSecondaryText.classList.add(
                "videoOsdSecondaryText-withparentname",
              )
            : videoOsdSecondaryText.classList.remove(
                "videoOsdSecondaryText-withparentname",
              ),
          secondaryName || itemInfo.Type,
          (primaryNameText.innerHTML = secondaryName)
            ? primaryNameText.classList.remove("hide")
            : primaryNameText.classList.add("hide"),
          videoOsdSecondaryMediaInfo),
        primaryNameHtml =
          "Audio" === itemInfo.MediaType ||
          ("Program" !== itemInfo.Type && !secondaryName)
            ? _mediainfo.default.getMediaInfoHtml(itemInfo, {
                runtime: !1,
                endsAt: !1,
                container: !user,
                year: "Audio" !== itemInfo.MediaType,
                CommunityRating: !1,
                criticRating: !1,
              })
            : _mediainfo.default.getSecondaryMediaInfoHtml(itemInfo, {
                startDate: !1,
                programTime: !1,
              });
      "Audio" === itemInfo.MediaType && itemInfo.Album && itemInfo.AlbumId
        ? ((videoOsdThirdTitle.innerHTML = getTextActionButton({
            Type: "MusicAlbum",
            Id: itemInfo.AlbumId,
            ServerId: itemInfo.ServerId,
            Name: itemInfo.Album,
          })),
          videoOsdThirdTitle.classList.remove("hide"))
        : videoOsdThirdTitle.classList.add("hide"),
        (function (item) {
          for (
            var mediaStreams =
                (
                  ((
                    (item = item && "Audio" !== item.MediaType ? null : item) ||
                    {}
                  ).MediaSources || [])[0] || {}
                ).MediaStreams || [],
              _i4 = 0,
              _length4 = mediaStreams.length;
            _i4 < _length4;
            _i4++
          )
            if ("Subtitle" === mediaStreams[_i4].Type)
              return btnLyrics.classList.remove("hide");
          btnLyrics.classList.add("hide"),
            "lyrics" === currentOsdContentSectionName &&
              setContentSection(getDefaultOsdContentSection(), !1);
        })(itemInfo),
        (item.innerHTML = primaryNameHtml),
        (videoOsdAudioInfo.innerHTML = primaryNameHtml)
          ? "Audio" === itemInfo.MediaType
            ? (item.classList.add("hide"),
              videoOsdAudioInfo.classList.remove("hide"))
            : (item.classList.remove("hide"),
              videoOsdAudioInfo.classList.add("hide"))
          : (item.classList.add("hide"),
            videoOsdAudioInfo.classList.add("hide")),
        (programEndDateMs = enableProgressByTimeOfDay
          ? (setDisplayTime(videoOsdPositionText, itemInfo.StartDate),
            setDisplayTime(videoOsdDurationText, itemInfo.EndDate),
            (programStartDateMs = itemInfo.StartDate
              ? _datetime.default.parseISO8601Date(itemInfo.StartDate).getTime()
              : 0),
            itemInfo.EndDate
              ? _datetime.default.parseISO8601Date(itemInfo.EndDate).getTime()
              : 0)
          : (programStartDateMs = 0));
      for (
        var introStart,
          introEnd,
          creditsStart,
          secondaryName,
          primaryNameText = self.lyricsRenderer,
          chapters =
            (primaryNameText && primaryNameText.updateItem(itemInfo),
            itemInfo.Chapters || []),
          _i5 = 0,
          _length5 = chapters.length;
        _i5 < _length5;
        _i5++
      ) {
        var chapter = chapters[_i5];
        "IntroStart" === chapter.MarkerType
          ? ((introStart = chapter.StartPositionTicks),
            _i5 < chapters.length - 1 &&
              (introEnd = chapters[_i5 + 1].StartPositionTicks))
          : "IntroEnd" === chapter.MarkerType
          ? (introEnd = chapter.StartPositionTicks)
          : "CreditsStart" === chapter.MarkerType &&
            (creditsStart = chapter.StartPositionTicks);
      }
      creditsStart &&
        (secondaryName = introEnd || introStart) &&
        creditsStart <= secondaryName &&
        (creditsStart = null),
        (currentIntroInfo =
          null != introStart && introEnd
            ? { start: introStart, end: introEnd }
            : null),
        (currentCreditsInfo =
          null != creditsStart ? { start: creditsStart } : null);
      for (
        var bottomTabControllers = self.bottomTabControllers,
          _i6 = 0,
          _length6 = bottomTabControllers.length;
        _i6 < _length6;
        _i6++
      )
        bottomTabControllers[_i6] &&
          bottomTabControllers[_i6].onItemUpdated({
            item: self.currentItem,
            displayItem: currentDisplayItem,
            mediaSource: currentMediaSource,
          });
    }
    function getDisplayTimeWithoutAmPm(date, showSeconds) {
      return (
        showSeconds
          ? _datetime.default.toLocaleTimeString(date, {
              hour: "numeric",
              minute: "2-digit",
              second: "2-digit",
            })
          : _datetime.default.getDisplayTime(date)
      )
        .toLowerCase()
        .replace("am", "")
        .replace("pm", "")
        .trim();
    }
    function setDisplayTime(elem, date) {
      var html;
      date &&
        (html = getDisplayTimeWithoutAmPm(
          (date = _datetime.default.parseISO8601Date(date)),
        )),
        (elem.innerHTML = html || "");
    }
    function supportsSubtitleDownloading() {
      return currentPlayerSupportedCommands.includes("RefreshMediaSource");
    }
    function updateNowPlayingInfo(event, player, state) {
      var item = state.NowPlayingItem;
      if (
        ((self.currentItem = item),
        (currentItemThumbnails = currentItemThumbnailsPromise = null),
        item)
      ) {
        (currentMediaSource = state.MediaSource),
          (enableProgressByTimeOfDay = (function (item, mediaSource) {
            return !(
              "TvChannel" !== item.Type ||
              !item.CurrentProgram ||
              !mediaSource ||
              mediaSource.RunTimeTicks
            );
          })(item, state.MediaSource))
            ? self.nowPlayingPositionSlider
                .getTrackBackgroundUpper()
                .classList.add("emby-slider-background-upper-accent")
            : self.nowPlayingPositionSlider
                .getTrackBackgroundUpper()
                .classList.remove("emby-slider-background-upper-accent");
        var apiClient = _connectionmanager.default.getApiClient(item);
        Promise.all([
          (function (item, currentDisplayItem) {
            return item.Id
              ? currentDisplayItem && currentDisplayItem.Id === item.Id
                ? Promise.resolve({
                    originalItem: currentDisplayItem,
                    displayItem:
                      currentDisplayItem.CurrentProgram || currentDisplayItem,
                  })
                : (currentDisplayItem = _connectionmanager.default.getApiClient(
                    item.ServerId,
                  ))
                    .getItem(currentDisplayItem.getCurrentUserId(), item.Id)
                    .then(function (refreshedItem) {
                      return {
                        originalItem: refreshedItem,
                        displayItem:
                          refreshedItem.CurrentProgram || refreshedItem,
                      };
                    })
              : Promise.resolve({ originalItem: item });
          })(item, currentDisplayItem),
          apiClient.getCurrentUser(),
        ]).then(function (responses) {
          var user = responses[1];
          if (
            (updateDisplayItem(0, responses[0], user),
            (nowPlayingVolumeSlider.disabled = !1),
            (self.nowPlayingPositionSlider.disabled =
              !0 === state.IsInitialRequest),
            "Video" === item.MediaType || item.SupportsResume)
          ) {
            for (
              var _i9 = 0, _length9 = fastForwardButtons.length;
              _i9 < _length9;
              _i9++
            )
              fastForwardButtons[_i9].classList.remove("hide"),
                (fastForwardButtons[_i9].disabled =
                  !0 === state.IsInitialRequest);
            for (
              var _i10 = 0, _length10 = rewindButtons.length;
              _i10 < _length10;
              _i10++
            )
              rewindButtons[_i10].classList.remove("hide"),
                (rewindButtons[_i10].disabled = !0 === state.IsInitialRequest);
          } else {
            for (
              var _i11 = 0, _length11 = fastForwardButtons.length;
              _i11 < _length11;
              _i11++
            )
              fastForwardButtons[_i11].classList.add("hide");
            for (
              var _i12 = 0, _length12 = rewindButtons.length;
              _i12 < _length12;
              _i12++
            )
              rewindButtons[_i12].classList.add("hide");
          }
          1 < _playbackmanager.default.audioTracks(player).length
            ? btnAudio.classList.remove("hide")
            : btnAudio.classList.add("hide"),
            (enableSkipIntro = "None" !== user.Configuration.IntroSkipMode),
            (enableAutoSkipIntro =
              "AutoSkip" === user.Configuration.IntroSkipMode),
            enableSkipIntro && validateSkipIntroFeature({ showDialog: !1 }, !0),
            _playbackmanager.default.subtitleTracks(player).length ||
            (_itemmanager.default.canDownloadSubtitles(item, user) &&
              supportsSubtitleDownloading())
              ? btnSubtitles.classList.remove("hide")
              : btnSubtitles.classList.add("hide");
        });
      } else {
        (ratingTextNeedsUpdate = !(currentCreditsInfo =
          currentIntroInfo =
          currentDisplayChapters =
          currentDisplayItem =
            null)),
          setPoster((currentMediaSource = null)),
          updateRecordingButton(null),
          _appheader.default.setTitle(""),
          (nowPlayingVolumeSlider.disabled = !0),
          (self.nowPlayingPositionSlider.disabled = !0);
        for (
          var _i7 = 0, _length7 = fastForwardButtons.length;
          _i7 < _length7;
          _i7++
        )
          fastForwardButtons[_i7].classList.add("hide");
        for (
          var _i8 = 0, _length8 = rewindButtons.length;
          _i8 < _length8;
          _i8++
        )
          rewindButtons[_i8].classList.add("hide");
        btnSubtitles.classList.add("hide"),
          btnAudio.classList.add("hide"),
          ratingInfoContainer.classList.add("hide"),
          updateButtomTabsVisibility(0, null, null),
          (osdTitle.innerHTML = ""),
          (view.querySelector(".videoOsdMediaInfo").innerHTML = "");
      }
    }
    function setPoster(item) {
      var posterContainer = osdPosterContainer;
      item
        ? (posterContainer.classList.remove("hide"),
          posterContainer.resume({ refresh: !0 }))
        : (posterContainer.classList.add("hide"),
          (posterContainer.innerHTML = ""));
    }
    var endEditTimeoutForPositionSlider,
      itemsContainer,
      nowPlayingSliderValue = 0,
      nowPlayingSliderRunTimeTicks = 0;
    function endEditsForPositionSlider() {
      self.nowPlayingPositionSlider.endEditing(!0, nowPlayingSliderValue);
    }
    function clearEndEditTimeoutForPositionSlider() {
      endEditTimeoutForPositionSlider &&
        (clearTimeout(endEditTimeoutForPositionSlider),
        (endEditTimeoutForPositionSlider = null));
    }
    function startEndEditTimeoutForPositionSlider() {
      clearEndEditTimeoutForPositionSlider(),
        (endEditTimeoutForPositionSlider = setTimeout(
          endEditsForPositionSlider,
          800,
        ));
    }
    function convertMsToNowPlayingSliderStep(ms) {
      return nowPlayingSliderRunTimeTicks
        ? ((1e4 * ms) / nowPlayingSliderRunTimeTicks) * 100
        : self.nowPlayingPositionSlider.step;
    }
    function cancelPositionSliderEditing() {
      clearEndEditTimeoutForPositionSlider();
      var elem = self.nowPlayingPositionSlider;
      elem.dragging && elem.cancelEditing();
    }
    function updateFullscreenIcon() {
      var title;
      _playbackmanager.default.isFullscreen(self.currentPlayer)
        ? ((title = _globalize.default.translate("ExitFullscreen")),
          (btnFullscreen.querySelector("i").innerHTML = "&#xE5D1;"))
        : ((title = _globalize.default.translate("Fullscreen")),
          (btnFullscreen.querySelector("i").innerHTML = "&#xE5D0;")),
        (btnFullscreen.title = title),
        btnFullscreen.setAttribute("aria-label", title);
    }
    function updateTransparency(player, state, mediaType) {
      var hideTransportButtons,
        isLocalVideo = isDisplayingLocalVideo(player, mediaType),
        videoOsdText =
          (console.log(
            "updateTransparency: isLocalVideo:" +
              isLocalVideo +
              ", mediaType:" +
              mediaType,
          ),
          _layoutmanager.default.tv
            ? videoOsdSecondaryText.classList.add("videoOsdSecondaryText-tv")
            : videoOsdSecondaryText.classList.remove(
                "videoOsdSecondaryText-tv",
              ),
          self.videoOsdText),
        bottomTabs = self.bottomTabs,
        osdBottomElement = self.osdBottomElement;
      if (isLocalVideo) {
        if (
          !player.isLocalPlayer ||
          player.isExternalPlayer ||
          state.IsBackgroundPlayback
        )
          unlockOrientation(), setSystemUIHidden(!1);
        else {
          switch (_usersettings.default.videoOrientation()) {
            case "device":
              unlockOrientation();
              break;
            case "landscape":
              lockOrientation("landscape");
              break;
            default:
              lockOrientation("any");
          }
          setSystemUIHidden(!0);
        }
        self.currentVisibleMenu ||
          (headerElement.classList.add("videoOsdHeader-hidden", "hide"),
          osdBottomElement.classList.add("hide", "videoOsdBottom-hidden")),
          osdBottomElement.classList.add("videoOsdBottom-video"),
          osdPosterContainer.classList.remove("osdPosterContainer-autoexpand"),
          videoOsdSecondaryText.classList.remove(
            "videoOsdSecondaryText-remotecontrol",
          ),
          videoOsdBottomMaincontrols.classList.remove(
            "videoOsdBottomMaincontrols-autoexpand",
          ),
          videoOsdPositionContainer.classList.remove(
            "videoOsdPositionContainer-autosmall",
          ),
          videoOsdPositionContainer.classList.add("focuscontainer-x"),
          _layoutmanager.default.tv
            ? ((function () {
                var val;
                if (!_usersettings.default.enableVideoUnderUI())
                  return "true" ===
                    (val = _usersettings.default.hideMediaTransportButtons())
                    ? 1
                    : "false" !== val && !_mouse.default.lastMouseInputTime();
              })() && (hideTransportButtons = !0),
              mainLockButton.classList.add("hide"))
            : mainLockButton.classList.remove("hide"),
          videoOsdButtomButtonsTopRight.classList.remove(
            "videoOsdBottom-buttons-topright-remotecontrol",
            "videoOsdBottom-buttons-topright-remotecontrol-tv",
          ),
          tabContainersElem.classList.remove(
            "videoosd-tabcontainers-autosmall",
          ),
          bottomTabs.classList.remove("videoOsdBottom-tabs-remotecontrol"),
          videoOsdVolumeControls.classList.add(
            "videoOsdVolumeControls-showhover",
            "videoOsdVolumeControls-hidetouch",
          ),
          videoOsdParentTitle.classList.add("hide"),
          videoOsdParentTitleLarge.classList.remove("hide"),
          state.IsInitialRequest
            ? _approuter.default.setTransparency(0)
            : _approuter.default.setTransparency("full"),
          hideOrShowAll(
            self,
            stopButtons,
            !_layoutmanager.default.tv ||
              !_usersettings.default.enableVideoUnderUI(),
            null,
          ),
          videoOsdText.classList.remove(
            "videoOsdText-remotecontrol",
            "videoOsdText-autosmall",
            "videoOsdText-remotecontrol-tv",
          ),
          videoOsdBottomButtons.classList.remove(
            "videoOsdBottom-buttons-remotecontrol",
            "videoOsdBottom-buttons-remotecontrol-tv",
          ),
          osdBottomElement.classList.remove(
            "videoOsdBottom-remotecontrol",
            "videoOsdBottom-safe",
            "padded-top-page",
            "videoOsdBottom-tvnowplaying",
          ),
          view.classList.remove("justify-content-flex-end"),
          osdTitle.classList.remove("secondaryText"),
          videoOsdSecondaryMediaInfo.classList.remove(
            "videoOsdSecondaryMediaInfo-remotecontrol",
          ),
          videoOsdPositionText.classList.remove(
            "videoOsd-customFont-remotecontrol",
          ),
          videoOsdDurationText.classList.remove(
            "videoOsd-customFont-remotecontrol",
          ),
          videoOsdBottomButtons.classList.remove(
            "videoOsd-customFont-remotecontrol",
            "videoOsd-customFont-remotecontrol-buttons",
          ),
          videoOsdButtomButtonsTopRight.classList.remove(
            "videoOsd-customFont-remotecontrol",
            "videoOsd-customFont-remotecontrol-buttons",
          ),
          headerElement.classList.remove(
            "videoOsd-customFont-remotecontrol",
            "videoosd-header-safe",
          ),
          videoOsdBottomContentbuttons.classList.add("hide"),
          videoOsdBottomContentbuttons.classList.remove(
            "focusable",
            "videoOsd-customFont-remotecontrol-buttons",
            "videoOsd-customFont-remotecontrol",
            "videoOsd-customFont-remotecontrol-buttons",
            "videoOsdBottom-contentbuttons-tv",
          ),
          videoOsdVolumeSliderWrapper.classList.remove(
            "videoOsdVolumeSliderWrapper-customfont",
          ),
          buttonMute.classList.remove("btnMuteOSD-remotecontrol"),
          videoOsdPositionContainer.classList.remove(
            "videoOsdPositionContainer-limitwidth",
          ),
          backdropContainer.classList.remove(
            "nowplaying-backdropcontainer-blur",
            "nowplaying-backdropcontainer-blur-high",
            "nowplaying-backdropcontainer-blur-extrasaturation",
            "nowplaying-backdropcontainer-blur-backdropfilter",
          ),
          backgroundContainer.classList.remove(
            "nowplaying-backgroundcontainer-blur",
            "nowplaying-backgroundcontainer-blur-backdropfilter",
          ),
          backgroundContainer.classList.remove(
            "nowplaying-backgroundcontainer-brighter",
          ),
          (self.enableStopOnBack = !0),
          (self.enableBackOnStop = !0),
          btnOsdMoreTitle.classList.add("hide"),
          btnOsdMoreBottom.classList.add("hide");
      } else
        unlockOrientation(),
          setSystemUIHidden(!1),
          osdTitle.classList.add("secondaryText"),
          osdBottomElement.classList.remove(
            "videoOsdBottom-video",
            "videoOsdBottom-hidden",
            "hide",
            "videoosd-withupnext",
          ),
          self.showOsd(),
          "blur" ===
          _usersettings.default[
            "Video" === mediaType
              ? "nowPlayingVideoBackgroundStyle"
              : "nowPlayingAudioBackgroundStyle"
          ]()
            ? (backdropContainer.classList.add(
                "nowplaying-backdropcontainer-blur",
              ),
              enableHighResBlur &&
                backdropContainer.classList.add(
                  "nowplaying-backdropcontainer-blur-high",
                ),
              _browser.default.chrome
                ? backdropContainer.classList.add(
                    "nowplaying-backdropcontainer-blur-extrasaturation",
                  )
                : backdropContainer.classList.remove(
                    "nowplaying-backdropcontainer-blur-extrasaturation",
                  ),
              backgroundContainer.classList.add(
                "nowplaying-backgroundcontainer-blur",
              ),
              useBackdropFilterForBlur &&
                (backgroundContainer.classList.add(
                  "nowplaying-backgroundcontainer-blur-backdropfilter",
                ),
                backdropContainer.classList.add(
                  "nowplaying-backdropcontainer-blur-backdropfilter",
                )),
              backgroundContainer.classList.remove(
                "nowplaying-backgroundcontainer-brighter",
              ))
            : (backdropContainer.classList.remove(
                "nowplaying-backdropcontainer-blur",
                "nowplaying-backdropcontainer-blur-high",
                "nowplaying-backdropcontainer-blur-extrasaturation",
                "nowplaying-backdropcontainer-blur-backdropfilter",
              ),
              backgroundContainer.classList.remove(
                "nowplaying-backgroundcontainer-blur",
                "nowplaying-backgroundcontainer-blur-backdropfilter",
              ),
              backgroundContainer.classList.add(
                "nowplaying-backgroundcontainer-brighter",
              )),
          videoOsdParentTitleLarge.classList.add("hide"),
          videoOsdParentTitle.classList.remove("hide"),
          videoOsdSecondaryMediaInfo.classList.add(
            "videoOsdSecondaryMediaInfo-remotecontrol",
          ),
          mainLockButton.classList.add("hide"),
          headerElement.classList.add("videoosd-header-safe"),
          _layoutmanager.default.tv
            ? (osdBottomElement.classList.add(
                "videoOsdBottom-safe",
                "padded-top-page",
                "videoOsdBottom-tvnowplaying",
                "videoOsdBottom-remotecontrol",
              ),
              view.classList.remove("justify-content-flex-end"),
              videoOsdText.classList.add(
                "videoOsdText-remotecontrol",
                "videoOsdText-remotecontrol-tv",
              ),
              videoOsdText.classList.remove("videoOsdText-autosmall"),
              osdPosterContainer.classList.remove(
                "osdPosterContainer-autoexpand",
              ),
              videoOsdSecondaryText.classList.add(
                "videoOsdSecondaryText-remotecontrol",
              ),
              videoOsdBottomButtons.classList.remove(
                "videoOsdBottom-buttons-remotecontrol",
                "videoOsd-customFont-remotecontrol",
                "videoOsd-customFont-remotecontrol-buttons",
              ),
              videoOsdBottomButtons.classList.add(
                "videoOsdBottom-buttons-remotecontrol-tv",
              ),
              videoOsdBottomMaincontrols.classList.remove(
                "videoOsdBottomMaincontrols-autoexpand",
              ),
              videoOsdPositionContainer.classList.add("focuscontainer-x"),
              videoOsdPositionContainer.classList.remove(
                "videoOsdPositionContainer-autosmall",
              ),
              tabContainersElem.classList.remove(
                "videoosd-tabcontainers-autosmall",
              ),
              bottomTabs.classList.add("videoOsdBottom-tabs-remotecontrol"),
              videoOsdPositionText.classList.remove(
                "videoOsd-customFont-remotecontrol",
              ),
              videoOsdDurationText.classList.remove(
                "videoOsd-customFont-remotecontrol",
              ),
              headerElement.classList.remove(
                "videoOsd-customFont-remotecontrol",
              ),
              videoOsdBottomContentbuttons.classList.add(
                "focusable",
                "videoOsdBottom-contentbuttons-tv",
              ),
              videoOsdBottomContentbuttons.classList.remove(
                "hide",
                "videoOsd-customFont-remotecontrol-buttons",
                "videoOsd-customFont-remotecontrol",
                "videoOsd-customFont-remotecontrol-buttons",
              ),
              videoOsdVolumeSliderWrapper.classList.remove(
                "videoOsdVolumeSliderWrapper-customfont",
              ),
              videoOsdVolumeControls.classList.add(
                "videoOsdVolumeControls-showhover",
                "videoOsdVolumeControls-hidetouch",
              ),
              buttonMute.classList.remove("btnMuteOSD-remotecontrol"),
              videoOsdButtomButtonsTopRight.classList.remove(
                "videoOsd-customFont-remotecontrol",
                "videoOsd-customFont-remotecontrol-buttons",
                "videoOsdBottom-buttons-topright-remotecontrol",
              ),
              videoOsdButtomButtonsTopRight.classList.add(
                "videoOsdBottom-buttons-topright-remotecontrol-tv",
              ),
              btnOsdMoreTitle.classList.add("hide"),
              btnOsdMoreBottom.classList.remove("hide"))
            : (osdBottomElement.classList.add(
                "videoOsdBottom-remotecontrol",
                "videoOsdBottom-safe",
                "padded-top-page",
              ),
              view.classList.remove("justify-content-flex-end"),
              osdPosterContainer.classList.add("osdPosterContainer-autoexpand"),
              videoOsdText.classList.add(
                "videoOsdText-remotecontrol",
                "videoOsdText-autosmall",
              ),
              videoOsdText.classList.remove("videoOsdText-remotecontrol-tv"),
              videoOsdBottomMaincontrols.classList.add(
                "videoOsdBottomMaincontrols-autoexpand",
              ),
              videoOsdPositionContainer.classList.add(
                "videoOsdPositionContainer-autosmall",
              ),
              videoOsdPositionContainer.classList.remove("focuscontainer-x"),
              tabContainersElem.classList.add(
                "videoosd-tabcontainers-autosmall",
              ),
              bottomTabs.classList.add("videoOsdBottom-tabs-remotecontrol"),
              videoOsdSecondaryText.classList.add(
                "videoOsdSecondaryText-remotecontrol",
              ),
              videoOsdBottomButtons.classList.add(
                "videoOsdBottom-buttons-remotecontrol",
              ),
              videoOsdBottomButtons.classList.remove(
                "videoOsdBottom-buttons-remotecontrol-tv",
              ),
              videoOsdPositionText.classList.add(
                "videoOsd-customFont-remotecontrol",
              ),
              videoOsdDurationText.classList.add(
                "videoOsd-customFont-remotecontrol",
              ),
              videoOsdBottomButtons.classList.add(
                "videoOsd-customFont-remotecontrol",
                "videoOsd-customFont-remotecontrol-buttons",
              ),
              videoOsdButtomButtonsTopRight.classList.add(
                "videoOsd-customFont-remotecontrol",
                "videoOsd-customFont-remotecontrol-buttons",
              ),
              headerElement.classList.add("videoOsd-customFont-remotecontrol"),
              videoOsdBottomContentbuttons.classList.remove(
                "hide",
                "videoOsdBottom-contentbuttons-tv",
              ),
              videoOsdBottomContentbuttons.classList.add(
                "focusable",
                "videoOsd-customFont-remotecontrol-buttons",
                "videoOsd-customFont-remotecontrol",
              ),
              videoOsdVolumeSliderWrapper.classList.add(
                "videoOsdVolumeSliderWrapper-customfont",
              ),
              videoOsdVolumeControls.classList.remove(
                "videoOsdVolumeControls-showhover",
                "videoOsdVolumeControls-hidetouch",
              ),
              buttonMute.classList.add("btnMuteOSD-remotecontrol"),
              videoOsdButtomButtonsTopRight.classList.add(
                "videoOsdBottom-buttons-topright-remotecontrol",
              ),
              videoOsdButtomButtonsTopRight.classList.remove(
                "videoOsdBottom-buttons-topright-remotecontrol-tv",
              ),
              videoOsdPositionContainer.classList.add(
                "videoOsdPositionContainer-limitwidth",
              ),
              btnOsdMoreTitle.classList.remove("hide"),
              btnOsdMoreBottom.classList.add("hide")),
          _approuter.default.setTransparency(0),
          hideOrShowAll(self, stopButtons, !1, null),
          (self.enableStopOnBack = !1),
          (self.enableBackOnStop = !0);
      hideTransportButtons
        ? (videoOsdBottomButtons.classList.add("hide"),
          videoOsdBottomButtons.classList.remove("focusable"),
          self.bottomTabs.classList.add("videoOsdTabs-margintop"))
        : (videoOsdBottomButtons.classList.add("focusable"),
          videoOsdBottomButtons.classList.remove("hide"),
          self.bottomTabs.classList.remove("videoOsdTabs-margintop")),
        isLocalVideo
          ? (destroyPlayQueue(self), destroyLyricsRenderer(self))
          : (self.lyricsRenderer ||
              (self.lyricsRenderer = new _lyrics.default({
                parent: view.querySelector(".lyricsSection"),
              })),
            self.playQueue ||
              ((player = view.querySelector(".osdPlayQueue")),
              (state =
                _usersettings.default.osdContentSection() ||
                getDefaultOsdContentSection()),
              _layoutmanager.default.tv
                ? ((self.playQueue = new _tvplayqueue.default({
                    parent: player,
                  })),
                  (state = "playqueue"))
                : (self.playQueue = new _playqueue.default({ parent: player })),
              setContentSection(
                (state =
                  "lyrics" === state ? getDefaultOsdContentSection() : state),
                !1,
              )));
      mediaType = self.btnPause;
      isLocalVideo && !_layoutmanager.default.tv
        ? (mainTransportButtons.classList.add(
            "videoOsd-centerButtons-autolayout",
          ),
          mediaType.classList.add("videoOsd-btnPause-autolayout"),
          stopButtons[0].classList.add("btnVideoOsd-stop-center-autolayout"))
        : (mainTransportButtons.classList.remove(
            "videoOsd-centerButtons-autolayout",
          ),
          mediaType.classList.remove("videoOsd-btnPause-autolayout"),
          stopButtons[0].classList.remove(
            "btnVideoOsd-stop-center-autolayout",
          ));
    }
    function getDetailImageItemsSync() {
      var item = currentDisplayItem,
        items = [];
      return (
        item &&
          (item.SeriesPrimaryImageTag &&
            (item = {
              Id: item.SeriesId,
              Name: item.SeriesName,
              ServerId: item.ServerId,
              ImageTags: { Primary: item.SeriesPrimaryImageTag },
              IsFolder: !0,
              PrimaryImageAspectRatio: 2 / 3,
            }),
          items.push(item)),
        { Items: items, TotalRecordCount: items.length }
      );
    }
    function getDetailImageItems() {
      return Promise.resolve(getDetailImageItemsSync());
    }
    function getDetailImageListOptions(items) {
      var cardClass = "osdRemoteControlImageCard";
      return (
        _layoutmanager.default.tv ||
          (cardClass += " osdRemoteControlImageCard-automargin"),
        {
          renderer: _cardbuilder.default,
          options: {
            overlayText: !0,
            fields: [],
            action: "none",
            multiSelect: !1,
            contextMenu: !_layoutmanager.default.tv,
            ratingButton: !_layoutmanager.default.tv,
            playedButton: !1,
            cardClass: cardClass,
            cardBoxClass: "osdRemoteControlImageCardBox",
            cardContentClass:
              "osdRemoteControlImageCardContent legacyLazyLoadImmediate",
            defaultIcon: !0,
            typeIndicator: !1,
            playedIndicator: !1,
            syncIndicator: !1,
            timerIndicator: !1,
            randomDefaultBackground: !1,
            staticElement: !0,
            progress: !1,
            hoverPlayButton: !1,
            moreButton: !1,
            enableUserData: !_layoutmanager.default.tv,
            shape: "auto",
          },
          virtualScrollLayout: "vertical-grid",
        }
      );
    }
    function onStateChanged(event, state) {
      state.NowPlayingItem &&
        ((isEnabled = !0),
        (function (player, state) {
          var playState = (self.lastPlayerState = state).PlayState || {},
            supportedCommands =
              (updatePlayPauseState(playState.IsPaused, state.IsInitialRequest),
              _playbackmanager.default.getSupportedCommands(player)),
            nowPlayingPositionSlider =
              ((currentPlayerSupportedCommands = supportedCommands),
              updatePlayerVolumeState(
                0,
                playState.IsMuted,
                playState.VolumeLevel,
                supportedCommands,
              ),
              updatePlayerBrightnessState(player),
              self.nowPlayingPositionSlider);
          nowPlayingPositionSlider &&
            !nowPlayingPositionSlider.dragging &&
            (nowPlayingPositionSlider.disabled = !playState.CanSeek);
          for (
            var _i13 = 0, _length13 = fastForwardButtons.length;
            _i13 < _length13;
            _i13++
          )
            fastForwardButtons[_i13].disabled = !playState.CanSeek;
          for (
            var _i14 = 0, _length14 = rewindButtons.length;
            _i14 < _length14;
            _i14++
          )
            rewindButtons[_i14].disabled = !playState.CanSeek;
          var nowPlayingItem = state.NowPlayingItem || {},
            displayingLocalVideo = isDisplayingLocalVideo(
              player,
              nowPlayingItem.MediaType,
            ),
            focusedElement =
              (updateTransparency(player, state, nowPlayingItem.MediaType),
              (playbackStartTimeTicks = playState.PlaybackStartTimeTicks),
              updateTimeDisplay(
                playState.PositionTicks,
                nowPlayingItem.RunTimeTicks,
                playState.PlaybackStartTimeTicks,
                playState.BufferedRanges || [],
              ),
              updateNowPlayingInfo(0, player, state),
              document.activeElement);
          state.MediaSource && !state.IsInitialRequest
            ? displayingLocalVideo || _layoutmanager.default.tv
              ? (hideButton(btnVideoOsdSettingsTransportButton, focusedElement),
                self.btnVideoOsdSettingsRight.classList.remove("hide"))
              : (btnVideoOsdSettingsTransportButton.classList.remove("hide"),
                hideButton(self.btnVideoOsdSettingsRight, focusedElement))
            : (hideButton(self.btnVideoOsdSettingsRight, focusedElement),
              hideButton(btnVideoOsdSettingsTransportButton, focusedElement));
          var isProgressClear =
            state.MediaSource && null == state.MediaSource.RunTimeTicks;
          nowPlayingPositionSlider.setIsClear(isProgressClear),
            !supportedCommands.includes("ToggleFullscreen") ||
            !displayingLocalVideo ||
            (player.isLocalPlayer &&
              _layoutmanager.default.tv &&
              _playbackmanager.default.isFullscreen(player))
              ? hideButton(btnFullscreen, focusedElement)
              : btnFullscreen.classList.remove("hide");
          state.IsInitialRequest ||
          !supportedCommands.includes("PictureInPicture") ||
          _layoutmanager.default.tv ||
          supportedCommands.includes("AutoPictureInPicture")
            ? hideButton(view.querySelector(".btnPip"), focusedElement)
            : view.querySelector(".btnPip").classList.remove("hide");
          updateRepeatModeDisplay(playState.RepeatMode),
            supportedCommands.includes("SetRepeatMode") &&
            "Video" !== nowPlayingItem.MediaType &&
            _layoutmanager.default.tv
              ? btnRepeatMode.classList.remove("hide")
              : hideButton(btnRepeatMode, focusedElement);
          updateFullscreenIcon();
          (nowPlayingPositionSlider = state.PlaylistIndex),
            (isProgressClear = state.PlaylistLength),
            updatePlaylistButtons(
              nowPlayingPositionSlider,
              isProgressClear,
              focusedElement,
            ),
            (displayingLocalVideo = self.playQueue);
          displayingLocalVideo &&
            ((supportedCommands = state.PlaylistItemId),
            displayingLocalVideo.updatePlaylist(
              player,
              supportedCommands,
              nowPlayingPositionSlider,
              isProgressClear,
            ));
        })(this, state));
    }
    function onPlayPauseStateChanged(e) {
      isEnabled && updatePlayPauseState(this.paused());
    }
    function onVolumeChanged(e) {
      isEnabled &&
        updatePlayerVolumeState(
          0,
          this.isMuted(),
          this.getVolume(),
          currentPlayerSupportedCommands,
        );
    }
    function onBrightnessChanged(e) {
      isEnabled && updatePlayerBrightnessState(this);
    }
    function onPlaybackStart(e, state) {
      console.log("nowplaying event: " + e.type), cancelPositionSliderEditing();
      onStateChanged.call(this, e, state),
        resetUpNextDialog(),
        resetRatingText(),
        showHideSkipIntro(!1),
        "Video" !==
          (null == (e = state.NowPlayingItem) ? void 0 : e.MediaType) &&
          self.bottomTabs.selectedIndex(-1);
    }
    function onRepeatModeChange(e) {
      updateRepeatModeDisplay(_playbackmanager.default.getRepeatMode(this));
    }
    function onSubtitleTrackChange() {
      destroySubtitleOffsetOverlay(self);
    }
    function onPlaylistItemAdd(e) {
      var playlistItemId,
        playlistIndex = _playbackmanager.default.getCurrentPlaylistIndex(this),
        playlistLength =
          _playbackmanager.default.getCurrentPlaylistLength(this),
        playQueue =
          (updatePlaylistButtons(
            playlistIndex,
            playlistLength,
            document.activeElement,
          ),
          self.playQueue);
      playQueue &&
        ((playlistItemId =
          _playbackmanager.default.getCurrentPlaylistItemId(this)),
        playQueue.updatePlaylist(
          this,
          playlistItemId,
          playlistIndex,
          playlistLength,
        ));
    }
    function onPlaylistItemMove(e, info) {
      updatePlaylistButtons(
        _playbackmanager.default.getCurrentPlaylistIndex(this),
        _playbackmanager.default.getCurrentPlaylistLength(this),
        document.activeElement,
      );
      var playQueue = self.playQueue;
      playQueue && playQueue.onPlaylistItemMoved(this, e, info);
    }
    function onPlaylistItemRemove(e, info) {
      updatePlaylistButtons(
        _playbackmanager.default.getCurrentPlaylistIndex(this),
        _playbackmanager.default.getCurrentPlaylistLength(this),
        document.activeElement,
      );
      var playQueue = self.playQueue;
      playQueue && playQueue.onPlaylistItemRemoved(this, e, info);
    }
    function resetUpNextDialog() {
      showHideUpNext((comingUpNextDisplayed = !1)),
        btnHideUpNext.classList.remove("hide");
    }
    function onPlaybackStopped(e, state) {
      hideWaiting(),
        cancelPositionSliderEditing(),
        (currentRuntimeTicks = null),
        resetRatingText();
      self.currentItem &&
        showComingUpNextIfNeeded(
          0,
          self.currentItem,
          1,
          1,
          !0,
          currentCreditsInfo,
        );
      var hideUpNextHasFocus = btnHideUpNext === document.activeElement;
      btnHideUpNext.classList.add("hide"),
        hideUpNextHasFocus &&
          _focusmanager.default.autoFocus(self.upNextContainer),
        showHideSkipIntro(!1),
        console.log("nowplaying event: " + e.type),
        state.NextMediaType ||
          ((hideUpNextHasFocus = self.playQueue) &&
            hideUpNextHasFocus.onPlaybackStopped(),
          (e = self.lyricsRenderer) && e.onPlaybackStopped(),
          (self.enableStopOnBack = !1),
          self.enableBackOnStop && ((self.enableBackOnStop = !1), self.exit()));
    }
    function onMediaStreamsChanged(e) {
      var state = _playbackmanager.default.getPlayerState(this);
      onStateChanged.call(this, e, state);
    }
    function releaseCurrentPlayer() {
      cancelPositionSliderEditing(),
        destroyStats(self),
        destroySubtitleOffsetOverlay(self),
        resetUpNextDialog(),
        resetRatingText(),
        showHideSkipIntro(!1);
      var player = self.currentPlayer;
      player &&
        (hideWaiting(),
        _events.default.off(player, "playbackrequest", onPlaybackStart),
        _events.default.off(player, "playbackstart", onPlaybackStart),
        _events.default.off(player, "playbackstop", onPlaybackStopped),
        _events.default.off(player, "volumechange", onVolumeChanged),
        _events.default.off(player, "brightnesschange", onBrightnessChanged),
        _events.default.off(player, "pause", onPlayPauseStateChanged),
        _events.default.off(player, "unpause", onPlayPauseStateChanged),
        _events.default.off(player, "timeupdate", onTimeUpdate),
        _events.default.off(player, "waiting", onWaiting),
        _events.default.off(player, "playing", onPlaying),
        _events.default.off(player, "fullscreenchange", updateFullscreenIcon),
        _events.default.off(
          player,
          "mediastreamschange",
          onMediaStreamsChanged,
        ),
        _events.default.off(player, "statechange", onStateChanged),
        _events.default.off(player, "repeatmodechange", onRepeatModeChange),
        _events.default.off(
          player,
          "subtitletrackchange",
          onSubtitleTrackChange,
        ),
        _events.default.off(player, "playlistitemadd", onPlaylistItemAdd),
        _events.default.off(player, "playlistitemmove", onPlaylistItemMove),
        _events.default.off(player, "playlistitemremove", onPlaylistItemRemove),
        (self.currentPlayer = null));
    }
    function resetRatingText() {
      ratingInfoContainer.classList.add("hide"), (ratingTextNeedsUpdate = !0);
    }
    function showHideSkipIntro(show) {
      var needToRefocus;
      show
        ? skipIntroContainer._visible ||
          ((skipIntroContainer._visible = !0),
          skipIntroContainer.classList.remove("hide"),
          self.currentVisibleMenu) ||
          (_focusmanager.default.focus(btnSkipIntro),
          enableAutoSkipIntro && btnSkipIntro.click())
        : skipIntroContainer._visible &&
          ((skipIntroContainer._visible = !1),
          (show = btnSkipIntro === document.activeElement),
          (needToRefocus = !!self.currentVisibleMenu && show),
          skipIntroContainer.classList.add("hide"),
          needToRefocus
            ? focusMainOsdControls(self)
            : show && btnSkipIntro.blur());
    }
    function showHideUpNext(show, timeRemainingTicks) {
      var upNextContainer = self.upNextContainer;
      show
        ? upNextContainer._visible ||
          ((btnPlayNextFromUpNextProgress.style.transform = "scaleX(0)"),
          (upNextContainer._visible = !0),
          (upNextContainer._timeRemainingTicks = timeRemainingTicks),
          upNextContainer.classList.remove("hide"),
          self.osdBottomElement.classList.add("videoosd-withupnext"),
          _focusmanager.default.focus(
            upNextContainer.querySelector(".btnPlayNextFromUpNext"),
          ))
        : upNextContainer._visible &&
          ((upNextContainer._visible = !1),
          (upNextContainer._timeRemainingTicks = null),
          (show =
            !!self.currentVisibleMenu &&
            upNextContainer.contains(document.activeElement)),
          upNextContainer.classList.add("hide"),
          self.osdBottomElement.classList.remove("videoosd-withupnext"),
          show) &&
          focusMainOsdControls(self);
    }
    function validateSkipIntroFeature(options, incrementAppSettings) {
      return require(["registrationServices"]).then(function (responses) {
        return responses[0]
          .validateFeature("dvr", Object.assign({ viewOnly: !0 }, options))
          .then(
            function () {
              (skipIntroValidated = !0),
                _appsettings.default.introSkipDisplayCount(0);
            },
            function (err) {
              return (
                (skipIntroValidated = !1),
                incrementAppSettings &&
                  _appsettings.default.introSkipDisplayCount(
                    _appsettings.default.introSkipDisplayCount() + 1,
                  ),
                Promise.reject(err)
              );
            },
          );
      });
    }
    (self.updateTransparency = updateTransparency),
      ((itemsContainer = osdPosterContainer).fetchData = getDetailImageItems),
      (itemsContainer.getListOptions = getDetailImageListOptions),
      _dom.default.addEventListener(
        btnFullscreen,
        "click",
        function () {
          _playbackmanager.default.toggleFullscreen(self.currentPlayer);
        },
        { passive: !0 },
      ),
      view.querySelector(".btnPip").addEventListener("click", function () {
        _playbackmanager.default.togglePictureInPicture(self.currentPlayer);
      }),
      self.btnVideoOsdSettingsRight.addEventListener(
        "click",
        onSettingsButtonClick,
      ),
      btnVideoOsdSettingsTransportButton.addEventListener(
        "click",
        onSettingsButtonClick,
      ),
      (self.bindToPlayer = function (player, forceStateChange) {
        player === self.currentPlayer
          ? forceStateChange &&
            player &&
            onStateChanged.call(
              player,
              { type: "viewresume" },
              _playbackmanager.default.getPlayerState(player),
            )
          : (releaseCurrentPlayer(),
            (self.currentPlayer = player) &&
              (onStateChanged.call(
                player,
                { type: "init" },
                _playbackmanager.default.getPlayerState(player),
              ),
              _events.default.on(player, "playbackrequest", onPlaybackStart),
              _events.default.on(player, "playbackstart", onPlaybackStart),
              _events.default.on(player, "playbackstop", onPlaybackStopped),
              _events.default.on(player, "volumechange", onVolumeChanged),
              _events.default.on(
                player,
                "brightnesschange",
                onBrightnessChanged,
              ),
              _events.default.on(player, "pause", onPlayPauseStateChanged),
              _events.default.on(player, "unpause", onPlayPauseStateChanged),
              _events.default.on(player, "timeupdate", onTimeUpdate),
              _events.default.on(player, "waiting", onWaiting),
              _events.default.on(player, "playing", onPlaying),
              _events.default.on(
                player,
                "fullscreenchange",
                updateFullscreenIcon,
              ),
              _events.default.on(
                player,
                "mediastreamschange",
                onMediaStreamsChanged,
              ),
              _events.default.on(player, "statechange", onStateChanged),
              _events.default.on(
                player,
                "repeatmodechange",
                onRepeatModeChange,
              ),
              _events.default.on(
                player,
                "subtitletrackchange",
                onSubtitleTrackChange,
              ),
              _events.default.on(player, "playlistitemadd", onPlaylistItemAdd),
              _events.default.on(
                player,
                "playlistitemmove",
                onPlaylistItemMove,
              ),
              _events.default.on(
                player,
                "playlistitemremove",
                onPlaylistItemRemove,
              ),
              resetUpNextDialog(),
              resetRatingText(),
              showHideSkipIntro(!1)));
      }),
      (self.releaseCurrentPlayer = releaseCurrentPlayer);
    var IntroEndToleranceTicks = 2e7;
    function onWaiting(e) {
      (self.timeWhenWaiting = _playbackmanager.default.currentTime(this)),
        _loading.default.show();
    }
    function hideWaiting() {
      (self.timeWhenWaiting = null), _loading.default.hide();
    }
    function onPlaying(e) {
      hideWaiting();
    }
    function onTimeUpdate(e) {
      var now, currentTime, item;
      !isEnabled ||
        (now = Date.now()) - lastUpdateTime < 200 ||
        ((currentTime = _playbackmanager.default.currentTime(this)) !==
          self.timeWhenWaiting && hideWaiting(),
        showComingUpNextIfNeeded(
          0,
          (item = self.currentItem),
          currentTime,
          (currentRuntimeTicks = _playbackmanager.default.duration(this)),
          !1,
          currentCreditsInfo,
        ),
        now - lastUpdateTime < 600) ||
        ((lastUpdateTime = now),
        (function (currentTime) {
          var introInfo = currentIntroInfo;
          introInfo &&
          enableSkipIntro &&
          currentTime >= introInfo.start &&
          currentTime < introInfo.end - IntroEndToleranceTicks &&
          (!1 !== skipIntroValidated ||
            _appsettings.default.introSkipDisplayCount() < 5)
            ? (!0 === skipIntroValidated &&
                _appsettings.default.introSkipDisplayCount(0),
              showHideSkipIntro(!0))
            : showHideSkipIntro(!1);
        })(currentTime),
        (function () {
          var item;
          ratingTextNeedsUpdate &&
            (item = currentDisplayItem) &&
            ((ratingTextNeedsUpdate = !1),
            item.OfficialRating &&
            "Trailer" !== item.Type &&
            "Video" === item.MediaType &&
            _usersettings.default.enableRatingInfoOnPlaybackStart()
              ? ((ratingTextElement.innerHTML = _globalize.default.translate(
                  "RatedValue",
                  item.OfficialRating,
                )),
                ratingInfoContainer.classList.add("hide"),
                ratingInfoContainer.offsetWidth,
                ratingInfoContainer.classList.remove("hide"))
              : ratingInfoContainer.classList.add("hide"));
        })(),
        updateTimeDisplay(
          currentTime,
          currentRuntimeTicks,
          _playbackmanager.default.playbackStartTime(this),
          _playbackmanager.default.getBufferedRanges(this),
        ),
        (function (player, item) {
          if ("TvChannel" === item.Type) {
            item = item.CurrentProgram;
            if (item && item.EndDate)
              try {
                var state,
                  endDate = _datetime.default.parseISO8601Date(item.EndDate);
                Date.now() >= endDate.getTime() &&
                  (console.log("program info needs to be refreshed"),
                  (state = _playbackmanager.default.getPlayerState(player)),
                  onStateChanged.call(
                    player,
                    { type: "updatemetadata" },
                    state,
                  ));
              } catch (e) {
                console.log("Error parsing date: " + item.EndDate);
              }
          }
        })(this, item));
    }
    var fiftyMinuteTicks = 3e10,
      fortyMinuteTicks = 24e9;
    function showComingUpNextIfNeeded(
      player,
      currentItem,
      currentTimeTicks,
      runtimeTicks,
      isStopped,
      creditsInfo,
    ) {
      ((runtimeTicks && currentTimeTicks) || isStopped) &&
        "Episode" === currentItem.Type &&
        self.hasNextTrack &&
        ((currentItem = runtimeTicks - currentTimeTicks),
        (!comingUpNextDisplayed || isStopped) &&
          ((creditsInfo = (function (runtimeTicks, creditsInfo) {
            return (creditsInfo =
              (null == creditsInfo ? void 0 : creditsInfo.start) || 0) &&
              creditsInfo < runtimeTicks
              ? creditsInfo
              : runtimeTicks -
                  1e3 *
                    (fiftyMinuteTicks <= runtimeTicks
                      ? 40
                      : fortyMinuteTicks <= runtimeTicks
                      ? 35
                      : 30) *
                    1e4;
          })(runtimeTicks, creditsInfo)),
          isStopped ||
            (creditsInfo <= currentTimeTicks &&
              3e9 <= runtimeTicks &&
              2e8 <= currentItem &&
              _usersettings.default.enableNextVideoInfoOverlay())) &&
          (isStopped && btnHideUpNext.classList.add("hide"),
          showHideUpNext((comingUpNextDisplayed = !0), currentItem)),
        self.upNextContainer._visible) &&
        (creditsInfo = self.upNextContainer._timeRemainingTicks) &&
        ((currentTimeTicks = isStopped
          ? 1
          : (creditsInfo - currentItem + 15e6) / creditsInfo),
        (currentTimeTicks *= 100),
        (currentTimeTicks = (currentTimeTicks = Math.min(
          currentTimeTicks,
          100,
        )).toFixed(2)),
        (btnPlayNextFromUpNextProgress.style.transform =
          "scaleX(" + currentTimeTicks + "%)"));
    }
    function updatePlayPauseState(isPaused, isInitialRequest) {
      var btnPause = self.btnPause,
        title = isPaused
          ? ((btnPause.querySelector("i").innerHTML = "&#xE037;"),
            _globalize.default.translate("Play"))
          : ((btnPause.querySelector("i").innerHTML = "&#xE034;"),
            _globalize.default.translate("Pause")),
        title =
          ((btnPause.title = title),
          btnPause.setAttribute("aria-label", title),
          (btnPause.disabled = !0 === isInitialRequest),
          self.playQueue);
      title && title.setPausedState(isPaused);
    }
    function hideButton(btn, focusedElement) {
      focusedElement = btn === focusedElement;
      btn.classList.add("hide"), focusedElement && focusMainOsdControls(self);
    }
    function updatePlaylistButtons(
      playlistIndex,
      playlistLength,
      focusedElement,
    ) {
      playlistIndex
        ? btnPreviousTrack.classList.remove("hide")
        : hideButton(btnPreviousTrack, focusedElement),
        null != playlistIndex &&
        playlistLength &&
        playlistIndex < playlistLength - 1
          ? ((self.hasNextTrack = !0), btnNextTrack.classList.remove("hide"))
          : ((self.hasNextTrack = !1),
            hideButton(btnNextTrack, focusedElement));
    }
    function updateRepeatModeDisplay(repeatMode) {
      var icon = btnRepeatMode.querySelector("i"),
        icon =
          ("RepeatAll" === repeatMode
            ? ((icon.innerHTML = "&#xE040;"),
              icon.classList.add("toggleButtonIcon-active"),
              btnRepeatMode.classList.add("toggleButton-active"))
            : "RepeatOne" === repeatMode
            ? ((icon.innerHTML = "&#xE041;"),
              icon.classList.add("toggleButtonIcon-active"),
              btnRepeatMode.classList.add("toggleButton-active"))
            : ((icon.innerHTML = "&#xE040;"),
              icon.classList.remove("toggleButtonIcon-active"),
              btnRepeatMode.classList.remove("toggleButton-active")),
          self.playQueue);
      icon && icon.updateRepeatModeDisplay(repeatMode);
    }
    function getDisplayPercentByTimeOfDay(
      programStartDateMs,
      programRuntimeMs,
      currentTimeMs,
    ) {
      return ((currentTimeMs - programStartDateMs) / programRuntimeMs) * 100;
    }
    function getStep(runtimeTicks) {
      runtimeTicks = (runtimeTicks =
        ((1e7 * (_layoutmanager.default.tv ? 10 : 1)) / runtimeTicks) *
        100).toFixed(3);
      return (
        (runtimeTicks = Math.max(0.01, runtimeTicks)),
        (runtimeTicks = Math.min(1, runtimeTicks))
      );
    }
    function updateTimeDisplay(
      positionTicks,
      runtimeTicks,
      playbackStartTimeTicks,
      bufferedRanges,
    ) {
      for (
        var programRuntimeMs,
          dash,
          nowPlayingPositionSlider = self.nowPlayingPositionSlider,
          bottomTabControllers =
            (enableProgressByTimeOfDay
              ? nowPlayingPositionSlider &&
                !nowPlayingPositionSlider.dragging &&
                (programStartDateMs && programEndDateMs
                  ? ((currentTimeMs =
                      (playbackStartTimeTicks + (positionTicks || 0)) / 1e4),
                    (nowPlayingSliderRunTimeTicks =
                      1e4 *
                      (programRuntimeMs =
                        programEndDateMs - programStartDateMs)),
                    (nowPlayingPositionSlider.step = getStep(
                      nowPlayingSliderRunTimeTicks,
                    )),
                    (nowPlayingSliderValue =
                      ((currentTimeMs - programStartDateMs) /
                        programRuntimeMs) *
                      100),
                    nowPlayingPositionSlider.setValue(nowPlayingSliderValue),
                    bufferedRanges.length
                      ? ((currentTimeMs = getDisplayPercentByTimeOfDay(
                          programStartDateMs,
                          programRuntimeMs,
                          (playbackStartTimeTicks +
                            (bufferedRanges[0].start || 0)) /
                            1e4,
                        )),
                        (programRuntimeMs = getDisplayPercentByTimeOfDay(
                          programStartDateMs,
                          programRuntimeMs,
                          (playbackStartTimeTicks +
                            (bufferedRanges[0].end || 0)) /
                            1e4,
                        )),
                        nowPlayingPositionSlider.setBufferedRanges([
                          { start: currentTimeMs, end: programRuntimeMs },
                        ]))
                      : nowPlayingPositionSlider.setBufferedRanges([]))
                  : ((nowPlayingPositionSlider.step = 0.01),
                    (nowPlayingSliderRunTimeTicks = null),
                    (nowPlayingSliderValue = 0),
                    nowPlayingPositionSlider.setValue(0),
                    nowPlayingPositionSlider.setBufferedRanges([])))
              : ((nowPlayingSliderRunTimeTicks = runtimeTicks),
                nowPlayingPositionSlider &&
                  !nowPlayingPositionSlider.dragging &&
                  ((playbackStartTimeTicks = currentDisplayItem),
                  runtimeTicks &&
                  null != (bufferedRanges = currentMediaSource) &&
                  bufferedRanges.RunTimeTicks
                    ? ((currentTimeMs = positionTicks / runtimeTicks),
                      (currentTimeMs *= 100),
                      (nowPlayingPositionSlider.step = getStep(runtimeTicks)),
                      (nowPlayingSliderValue = currentTimeMs),
                      nowPlayingPositionSlider.setValue(currentTimeMs),
                      updateDurationText(
                        runtimeTicks - positionTicks,
                        playbackStartTimeTicks,
                        !0,
                      ))
                    : ((nowPlayingPositionSlider.step = 0.01),
                      (nowPlayingSliderValue = 0),
                      nowPlayingPositionSlider.setValue(0),
                      updateDurationText(
                        runtimeTicks,
                        playbackStartTimeTicks,
                      ))),
                nowPlayingPositionSlider &&
                  nowPlayingPositionSlider.setBufferedRanges([]),
                (programRuntimeMs = videoOsdPositionText),
                null == (bufferedRanges = positionTicks) ||
                isNaN(bufferedRanges)
                  ? (programRuntimeMs.innerHTML = "")
                  : ((bufferedRanges =
                      _datetime.default.getDisplayRunningTime(bufferedRanges)),
                    dash && (bufferedRanges = "-" + bufferedRanges),
                    (programRuntimeMs.innerHTML = bufferedRanges))),
            self.bottomTabControllers),
          _i15 = 0,
          _length15 = bottomTabControllers.length;
        _i15 < _length15;
        _i15++
      )
        bottomTabControllers[_i15] &&
          bottomTabControllers[_i15].onTimeUpdate(positionTicks, runtimeTicks);
      var currentTimeMs = self.lyricsRenderer;
      currentTimeMs &&
        currentTimeMs.onTimeUpdate(positionTicks, currentRuntimeTicks);
    }
    function updateDurationText(
      durationTicks,
      displayItem,
      enableTimeRemaining,
    ) {
      var html,
        elem = videoOsdDurationText;
      null == durationTicks || isNaN(durationTicks)
        ? (elem.innerHTML = "")
        : ((html = _datetime.default.getDisplayRunningTime(durationTicks)),
          enableTimeRemaining &&
            ((html = "-" + html),
            enableProgressByTimeOfDay ||
              "Video" !==
                (null == displayItem ? void 0 : displayItem.MediaType) ||
              (html +=
                '<span class="osd-endsat"><span class="osd-endsat-dot">/</span>' +
                _mediainfo.default
                  .getEndsAtFromPosition(durationTicks, 0, !1)
                  .toLowerCase() +
                "</span>")),
          (elem.innerHTML = html));
    }
    function updatePlayerBrightnessState(player) {
      var showSlider =
        !_layoutmanager.default.tv &&
        currentPlayerSupportedCommands.includes("SetBrightness");
      brightnessSlider &&
        (showSlider
          ? (brightnessSliderContainer.classList.remove("hide"),
            brightnessSlider.dragging ||
              brightnessSlider.setValue(
                _playbackmanager.default.getBrightness(player),
              ))
          : brightnessSliderContainer.classList.add("hide"));
    }
    function updatePlayerVolumeState(
      player,
      isMuted,
      volumeLevel,
      supportedCommands,
    ) {
      var showMuteButton = !0,
        showVolumeSlider = !0;
      supportedCommands.includes("Mute") || (showMuteButton = !1),
        supportedCommands.includes("SetVolume") || (showVolumeSlider = !1),
        isMuted
          ? (buttonMute.setAttribute(
              "title",
              _globalize.default.translate("Unmute"),
            ),
            (buttonMute.querySelector("i").innerHTML = "&#xE04F;"))
          : (buttonMute.setAttribute(
              "title",
              _globalize.default.translate("Mute"),
            ),
            (buttonMute.querySelector("i").innerHTML = "&#xE050;")),
        showMuteButton
          ? buttonMute.classList.remove("hide")
          : buttonMute.classList.add("hide"),
        nowPlayingVolumeSlider &&
          (showVolumeSlider
            ? videoOsdVolumeControls.classList.remove("hide")
            : videoOsdVolumeControls.classList.add("hide"),
          nowPlayingVolumeSlider.dragging ||
            nowPlayingVolumeSlider.setValue(volumeLevel));
    }
    function onSettingsButtonClick(e) {
      var btn = this;
      require(["playerSettingsMenu"], function (playerSettingsMenu) {
        var player = self.currentPlayer;
        player &&
          playerSettingsMenu
            .show({
              player: player,
              positionTo: btn,
              stats: !0,
              onOption: onSettingsOption,
              mediaType: self.currentItem.MediaType,
            })
            .then(
              self.boundShowOsdDefaultParams,
              self.boundShowOsdDefaultParams,
            );
      });
    }
    function onSettingsOption(selectedOption) {
      "stats" === selectedOption
        ? toggleStats(self)
        : "subtitleoffset" === selectedOption && toggleSubtitleOffset();
    }
    function toggleSubtitleOffset() {
      require(["subtitleOffsetOverlay"], function (SubtitleOffsetOverlay) {
        var player = self.currentPlayer;
        player &&
          (self.subtitleOffsetOverlay ||
            (self.subtitleOffsetOverlay = new SubtitleOffsetOverlay({
              player: player,
            })),
          self.subtitleOffsetOverlay.show());
      });
    }
    var lastPointerEvent = 0;
    function refreshThumbnailsIfNeeded(
      item,
      mediaSourceId,
      apiClient,
      maxThumbnailWidth,
    ) {
      !item.Id ||
        "Audio" === item.MediaType ||
        currentItemThumbnails ||
        currentItemThumbnailsPromise ||
        !(function (itemId, mediaSourceId, apiClient, maxThumbnailWidth) {
          currentItemThumbnailsPromise ||
            (currentItemThumbnailsPromise = apiClient
              .getThumbnails(itemId, {
                MediaSourceId: mediaSourceId,
                Width: maxThumbnailWidth,
              })
              .then(
                function (result) {
                  return (
                    (currentItemThumbnails = result), Promise.resolve(result)
                  );
                },
                function () {
                  currentItemThumbnailsPromise = null;
                },
              ));
        })(item.Id, mediaSourceId, apiClient, maxThumbnailWidth);
    }
    function getThumbnailBubbleHtml(
      apiClient,
      itemId,
      mediaSourceId,
      thumbnailSet,
      chapters,
      positionTicks,
      maxThumbnailWidth,
    ) {
      var thumbnail,
        thumbnails = (thumbnailSet = thumbnailSet || {}).Thumbnails || {},
        bubbleElement = self.nowPlayingPositionSlider.getBubbleElement();
      thumbnails.length
        ? (bubbleElement.classList.add("chapterThumbImageContainer"),
          thumbnailSet.AspectRatio && thumbnailSet.AspectRatio < 1.4
            ? bubbleElement.classList.add(
                "chapterThumbImageContainer-fourthree",
              )
            : bubbleElement.classList.remove(
                "chapterThumbImageContainer-fourthree",
              ),
          bubbleElement.classList.remove("chapterThumbImageContainer-noimg"))
        : (bubbleElement.classList.remove(
            "chapterThumbImageContainer",
            "chapterThumbImageContainer-fourthree",
          ),
          bubbleElement.classList.add("chapterThumbImageContainer-noimg")),
        _layoutmanager.default.tv
          ? bubbleElement.classList.add("chapterThumbImageContainer-tv")
          : bubbleElement.classList.remove("chapterThumbImageContainer-tv");
      for (
        var _i16 = 0, _length16 = thumbnails.length;
        _i16 < _length16;
        _i16++
      ) {
        var currentThumbnail = thumbnails[_i16];
        if (positionTicks >= currentThumbnail.PositionTicks)
          thumbnail = currentThumbnail;
        else if (thumbnail) break;
      }
      for (
        var _i17 = 0, _length17 = chapters.length;
        _i17 < _length17;
        _i17++
      ) {
        var currentChapter = chapters[_i17];
        if (positionTicks >= currentChapter.StartPositionTicks)
          chapter = currentChapter;
        else if (chapter) break;
      }
      var chapter = chapter || { Name: "&nbsp;" },
        thumbnailSet = thumbnail
          ? (function (itemId, thumbnail, maxWidth, apiClient) {
              return thumbnail.ImageTag
                ? apiClient.getImageUrl(itemId, {
                    maxWidth: maxWidth,
                    tag: thumbnail.ImageTag,
                    type: "Thumbnail",
                    PositionTicks: thumbnail.PositionTicks,
                  })
                : null;
            })(itemId, thumbnail, maxThumbnailWidth, apiClient)
          : null,
        bubbleElement = "",
        itemId = "chapterThumbTextContainer";
      return (
        thumbnailSet || (itemId += " chapterThumbTextContainer-noimg"),
        (self.nowPlayingPositionSlider.getBubbleElement().style.backgroundImage =
          thumbnailSet ? "url('" + thumbnailSet + "')" : null),
        (bubbleElement =
          (bubbleElement =
            (bubbleElement =
              (bubbleElement =
                (bubbleElement =
                  bubbleElement +
                  ('<div class="' + itemId + '">') +
                  '<div class="chapterThumbText">') +
                (chapter ? _dom.default.htmlEncode(chapter.Name) : "&nbsp;")) +
              "</div>" +
              (thumbnailSet
                ? '<div class="chapterThumbText">'
                : '<div class="chapterThumbText secondaryText">')) +
            _datetime.default.getDisplayRunningTime(positionTicks)) +
          "</div>" +
          "</div>")
      );
    }
    function onStop() {
      _playbackmanager.default.stop(self.currentPlayer);
    }
    _dom.default.addEventListener(
      view,
      window.PointerEvent && !_dom.default.supportsPointerTypeInClickEvent()
        ? "pointerup"
        : "click",
      function (e) {
        var isEnoughTimeSinceLastTap,
          pointerType = e.pointerType;
        "touch" ===
        (lastPointerUpType = pointerType =
          pointerType || (supportsTouchEvent ? "touch" : "mouse"))
          ? e.target.closest("BUTTON,INPUT,.videoosd-tabcontainers")
            ? self.showOsd()
            : (!(isEnoughTimeSinceLastTap =
                300 < (pointerType = Date.now()) - lastPointerEvent) &&
                "click" !== e.type) ||
              ((lastPointerEvent = pointerType),
              self.currentVisibleMenu
                ? setTimeout(self.boundHideOsd, 10)
                : self.currentVisibleMenu ||
                  (isEnoughTimeSinceLastTap &&
                    setTimeout(self.boundShowOsdDefaultParams, 100)))
          : onOsdClick(e, self, null, !0);
      },
      { passive: !0 },
    ),
      _dom.default.addEventListener(
        view,
        "dblclick",
        function (e) {
          e.target.closest("BUTTON") ||
            ("mouse" === lastPointerUpType &&
              _playbackmanager.default.toggleFullscreen(self.currentPlayer));
        },
        { passive: !0 },
      ),
      _dom.default.addEventListener(
        buttonMute,
        "click",
        function () {
          _playbackmanager.default.toggleMute(self.currentPlayer);
        },
        { passive: !0 },
      ),
      _dom.default.addEventListener(
        brightnessSlider,
        "change",
        function () {
          _playbackmanager.default.setBrightness(
            parseFloat(this.value),
            self.currentPlayer,
          ),
            self.showOsd();
        },
        { passive: !0 },
      ),
      _dom.default.addEventListener(
        brightnessSlider,
        "input",
        function () {
          _playbackmanager.default.setBrightness(
            parseFloat(this.value),
            self.currentPlayer,
          ),
            self.showOsd();
        },
        { passive: !0 },
      ),
      _dom.default.addEventListener(
        nowPlayingVolumeSlider,
        "change",
        function () {
          _playbackmanager.default.setVolume(
            parseFloat(this.value),
            self.currentPlayer,
          ),
            self.showOsd();
        },
        { passive: !0 },
      ),
      _dom.default.addEventListener(
        self.nowPlayingPositionSlider,
        "change",
        function () {
          var newPercent,
            seekAirTimeTicks,
            player = self.currentPlayer;
          player &&
            ((newPercent = parseFloat(this.value)),
            enableProgressByTimeOfDay
              ? ((seekAirTimeTicks =
                  (seekAirTimeTicks =
                    (newPercent / 100) *
                    (programEndDateMs - programStartDateMs) *
                    1e4) +
                  1e4 * programStartDateMs -
                  playbackStartTimeTicks),
                _playbackmanager.default.seek(seekAirTimeTicks, player))
              : _playbackmanager.default.seekPercent(newPercent, player));
        },
        { passive: !0 },
      ),
      (self.nowPlayingPositionSlider.getBubbleHtml = function (value) {
        if ((self.showOsd(), enableProgressByTimeOfDay))
          return programStartDateMs && programEndDateMs
            ? ((ms = programEndDateMs - programStartDateMs),
              (ms = (ms /= 100) * value + programStartDateMs),
              '<h3 class="sliderBubbleText">' +
                getDisplayTimeWithoutAmPm(new Date(parseInt(ms)), !0) +
                "</h3>")
            : "--:--";
        if (!currentRuntimeTicks) return "--:--";
        var ms = currentRuntimeTicks,
          value = ((ms = (ms / 100) * value), self.currentItem);
        if (value) {
          var apiClient = _connectionmanager.default.getApiClient(
              value.ServerId,
            ),
            thumbnails =
              (refreshThumbnailsIfNeeded(value, "", apiClient, 400),
              currentItemThumbnails),
            chapters = currentDisplayChapters || [];
          if (chapters.length) {
            apiClient = getThumbnailBubbleHtml(
              apiClient,
              value.Id,
              0,
              thumbnails,
              chapters,
              ms,
              400,
            );
            if (apiClient) return apiClient;
          }
        }
        return (
          '<h2 class="sliderBubbleText">' +
          _datetime.default.getDisplayRunningTime(ms) +
          "</h2>"
        );
      }),
      _dom.default.addEventListener(
        self.osdBottomElement,
        transitionEndEventName,
        function (e) {
          var elem = e.currentTarget;
          elem === e.target &&
            elem.classList.contains("videoOsdBottom-hidden") &&
            (elem.classList.add("hide"),
            headerElement.classList.add("hide"),
            self.bottomTabs.selectedIndex(-1),
            onTabTransitionEnd.call(tabContainersElem, {
              target: tabContainersElem,
              currentTarget: tabContainersElem,
            }),
            2 === self.currentLockState && self.setLockState(1),
            view.dispatchEvent(
              new CustomEvent("video-osd-hide", { bubbles: !0 }),
            ));
        },
        { passive: !0 },
      ),
      _dom.default.addEventListener(
        btnPreviousTrack,
        "click",
        function () {
          _playbackmanager.default.previousTrack(self.currentPlayer);
        },
        { passive: !0 },
      );
    for (var _i18 = 0, _length18 = stopButtons.length; _i18 < _length18; _i18++)
      stopButtons[_i18].addEventListener("click", onStop);
    function onNextTrackClick() {
      _playbackmanager.default.nextTrack(self.currentPlayer);
    }
    function onRewindButtonClick() {
      rewind(self, !0);
    }
    _dom.default.addEventListener(
      self.btnPause,
      "click",
      function () {
        _playbackmanager.default.playPause(self.currentPlayer);
      },
      { passive: !0 },
    ),
      _dom.default.addEventListener(btnNextTrack, "click", onNextTrackClick, {
        passive: !0,
      });
    for (
      var _i19 = 0, _length19 = rewindButtons.length;
      _i19 < _length19;
      _i19++
    )
      _dom.default.addEventListener(
        rewindButtons[_i19],
        "click",
        onRewindButtonClick,
        { passive: !0 },
      );
    function onFastForwardButtonClick() {
      fastForward(self, !0);
    }
    for (
      var _i20 = 0, _length20 = fastForwardButtons.length;
      _i20 < _length20;
      _i20++
    )
      _dom.default.addEventListener(
        fastForwardButtons[_i20],
        "click",
        onFastForwardButtonClick,
        { passive: !0 },
      );
    function onMoreClick() {
      showMoreMenu(self.currentItem, this);
    }
    function onCloseRequestedFromTab() {
      self.bottomTabs.selectedIndex(-1);
    }
    function loadBottomTabController(index, forceRefresh) {
      var tabResumeOptions = {
          refresh: forceRefresh,
          item: self.currentItem,
          displayItem: currentDisplayItem,
          mediaSource: currentMediaSource,
          enableProgressByTimeOfDay: enableProgressByTimeOfDay,
          currentPlayer: self.currentPlayer,
        },
        bottomTabControllers = self.bottomTabControllers;
      if (bottomTabControllers[index])
        return bottomTabControllers[index].onResume(tabResumeOptions);
      require([
        [
          "videoosd_infotab",
          "videoosd_chapterstab",
          "videoosd_peopletab",
          "videoosd_onnowtab",
          "videoosd_guidetab",
        ][index],
      ]).then(function (responses) {
        responses = new responses[0](tabContainers[index]);
        return (
          (bottomTabControllers[index] = responses),
          (tabResumeOptions.refresh = !0),
          _events.default.on(
            responses,
            "closerequested",
            onCloseRequestedFromTab,
          ),
          responses.onResume(tabResumeOptions)
        );
      });
    }
    function onTabTransitionEnd(e) {
      var elem = e.currentTarget;
      elem === e.target &&
        elem.classList.contains("videoosd-tabcontainers-hidden") &&
        (elem.classList.add("hide"),
        self.osdBottomElement.classList.remove("videoosd-bottom-with-opentab"),
        (e = elem.querySelector(".videoosd-activetab")) &&
          e.classList.remove("videoosd-activetab"),
        focusMainOsdControls(self));
    }
    function setContentSection(sectionName, saveToUserSettings) {
      currentOsdContentSectionName = sectionName;
      for (
        var sections = view.querySelectorAll(".osdContentSection"),
          _i21 = 0,
          _length21 = sections.length;
        _i21 < _length21;
        _i21++
      ) {
        var section = sections[_i21];
        section.getAttribute("data-contentsection") === sectionName
          ? section.classList.remove("hide")
          : section.classList.add("hide");
      }
      for (
        var buttons = view.querySelectorAll(".osdContentSectionToggleButton"),
          _i22 = 0,
          _length22 = buttons.length;
        _i22 < _length22;
        _i22++
      ) {
        var button = buttons[_i22],
          icon = button.querySelector("i");
        button.getAttribute("data-contentsection") === sectionName
          ? (button.classList.add("toggleButton-active"),
            icon.classList.add("toggleButtonIcon-active"))
          : (button.classList.remove("toggleButton-active"),
            icon.classList.remove("toggleButtonIcon-active"));
      }
      var playQueue = self.playQueue,
        playQueue =
          ("playqueue" === sectionName
            ? playQueue && playQueue.resume({})
            : playQueue && playQueue.pause(),
          self.lyricsRenderer),
        playQueue =
          ("lyrics" === sectionName
            ? playQueue && playQueue.resume({})
            : playQueue && playQueue.pause(),
          self.osdBottomElement);
      _layoutmanager.default.tv
        ? (sectionName && "playqueue" !== sectionName && "art" !== sectionName
            ? playQueue.classList.add("videoOsdBottom-split")
            : playQueue.classList.remove("videoOsdBottom-split"),
          sectionName && "lyrics" !== sectionName && "art" !== sectionName
            ? playQueue.classList.remove("videoOsdBottom-art")
            : playQueue.classList.add("videoOsdBottom-art"))
        : sectionName && "art" !== sectionName
        ? (playQueue.classList.add("videoOsdBottom-split"),
          playQueue.classList.remove("videoOsdBottom-art"))
        : (playQueue.classList.remove("videoOsdBottom-split"),
          playQueue.classList.add("videoOsdBottom-art")),
        !1 !== saveToUserSettings &&
          _usersettings.default.osdContentSection(sectionName);
    }
    function onContentSectionToggleButtonClick(e) {
      this.classList.contains("toggleButton-active")
        ? setContentSection("art")
        : setContentSection(this.getAttribute("data-contentsection"));
    }
    function onSkipIntroClickInternal() {
      var info = currentIntroInfo,
        player = self.currentPlayer;
      info &&
        player &&
        (_playbackmanager.default.seek(info.end, player),
        showHideSkipIntro(!1),
        self.hideOsd());
    }
    function onLockClick() {
      var lockState = self.currentLockState;
      switch (lockState) {
        case 0:
        case 1:
          lockState++;
          break;
        default:
          lockState = 0;
      }
      self.setLockState(lockState);
    }
    _dom.default.addEventListener(
      btnRepeatMode,
      "click",
      function () {
        var player;
        (player = self.currentPlayer) &&
          _playbackmanager.default.toggleRepeatMode(player);
      },
      { passive: !0 },
    ),
      _dom.default.addEventListener(btnOsdMoreBottom, "click", onMoreClick, {
        passive: !0,
      }),
      _dom.default.addEventListener(btnOsdMoreTitle, "click", onMoreClick, {
        passive: !0,
      }),
      _dom.default.addEventListener(
        btnAudio,
        "click",
        function () {
          var currentIndex,
            audioTracks,
            player = self.currentPlayer;
          player &&
            ((audioTracks = _playbackmanager.default.audioTracks(player)),
            (currentIndex =
              _playbackmanager.default.getAudioStreamIndex(player)),
            (audioTracks = audioTracks.map(function (stream) {
              var opt = {
                name: stream.DisplayTitle,
                secondaryText:
                  stream.Title &&
                  !(stream.DisplayTitle || "")
                    .toLowerCase()
                    .includes((stream.Title || "").toLowerCase())
                    ? stream.Title
                    : null,
                id: stream.Index,
              };
              return stream.Index === currentIndex && (opt.selected = !0), opt;
            })),
            self.showOsd(),
            showActionSheet({
              items: audioTracks,
              title: _globalize.default.translate("Audio"),
              positionTo: this,
              positionY: "above",
              transformOrigin: "center bottom",
              hasItemSelectionState: !0,
              autoTvLayout: !1,
            }).then(function (id) {
              self.showOsd();
              id = parseInt(id);
              id !== currentIndex &&
                _playbackmanager.default.setAudioStreamIndex(id, player);
            }, self.boundShowOsdDefaultParams));
        },
        { passive: !0 },
      ),
      _dom.default.addEventListener(
        btnSubtitles,
        "click",
        function () {
          var player = self.currentPlayer,
            streams = _playbackmanager.default.subtitleTracks(player),
            currentIndex =
              _playbackmanager.default.getSubtitleStreamIndex(player),
            menuItems =
              (null == currentIndex && (currentIndex = -1),
              streams.unshift({
                Index: -1,
                DisplayTitle: _globalize.default.translate("Off"),
              }),
              streams.map(function (stream) {
                var opt = {
                  name: stream.DisplayTitle,
                  secondaryText:
                    stream.Title &&
                    !(stream.DisplayTitle || "")
                      .toLowerCase()
                      .includes((stream.Title || "").toLowerCase())
                      ? stream.Title
                      : null,
                  id: stream.Index,
                };
                return (
                  stream.Index === currentIndex && (opt.selected = !0), opt
                );
              })),
            positionTo = this;
          (streams = _connectionmanager.default.getApiClient(self.currentItem))
            .getCurrentUser()
            .then(function (user) {
              supportsSubtitleDownloading() &&
                _itemmanager.default.canDownloadSubtitles(
                  self.currentItem,
                  user,
                ) &&
                self.showOsd(),
                showActionSheet({
                  title: _globalize.default.translate("Subtitles"),
                  items: menuItems,
                  positionTo: positionTo,
                  positionY: "above",
                  transformOrigin: "center bottom",
                  hasItemSelectionState: !0,
                  hasItemAsideIcon: !0,
                  autoTvLayout: !1,
                }).then(function (id) {
                  var item, mediaSource;
                  self.showOsd(),
                    "search" === id
                      ? ((item = self.currentItem),
                        (mediaSource = currentMediaSource),
                        require([
                          "registrationServices",
                          "subtitleEditor",
                        ]).then(function (responses) {
                          return responses[0]
                            .validateFeature("sync")
                            .then(function () {
                              return responses[1]
                                .show({
                                  item: item,
                                  mediaSource: mediaSource,
                                  showCurrentSubtitles: !1,
                                  autoSearch: !0,
                                  closeOnDownload: !0,
                                })
                                .then(function (result) {
                                  self.showOsd(),
                                    _playbackmanager.default.setSubtitleStreamIndex(
                                      result.NewIndex,
                                      self.currentPlayer,
                                      !0,
                                    );
                                }, self.boundShowOsdDefaultParams);
                            });
                        }))
                      : "subtitleoffset" === id
                      ? toggleSubtitleOffset()
                      : (id = parseInt(id)) !== currentIndex &&
                        _playbackmanager.default.setSubtitleStreamIndex(
                          id,
                          player,
                        );
                }, self.boundShowOsdDefaultParams);
            });
        },
        { passive: !0 },
      ),
      (videoOsdBottomContentbuttons.getFocusableElements =
        videoOsdBottomButtons.getFocusableElements =
          function (parent, activeElement, direction, options) {
            if (!_layoutmanager.default.tv) return null;
            switch (direction) {
              case 0:
              case 1:
                return Array.prototype.slice
                  .call(videoOsdBottomButtons.querySelectorAll("button"), 0)
                  .concat(
                    Array.prototype.slice.call(
                      videoOsdBottomContentbuttons.querySelectorAll("button"),
                      0,
                    ),
                  );
              default:
                return null;
            }
          }),
      self.bottomTabs.addEventListener("beforetabchange", function (e) {
        var previousPanel,
          newPanel = tabContainers[e.detail.selectedTabIndex];
        null != e.detail.previousIndex &&
          ((previousPanel = tabContainers[e.detail.previousIndex]) &&
            newPanel &&
            previousPanel.classList.remove("videoosd-activetab"),
          (previousPanel =
            self.bottomTabControllers[e.detail.previousIndex])) &&
          previousPanel.onPause(),
          newPanel
            ? (loadBottomTabController(e.detail.selectedTabIndex),
              newPanel.classList.add("videoosd-activetab"),
              tabContainersElem.classList.remove("hide"),
              tabContainersElem.offsetWidth,
              tabContainersElem.classList.remove(
                "videoosd-tabcontainers-hidden",
              ),
              self.osdBottomElement.classList.add(
                "videoosd-bottom-with-opentab",
              ),
              btnCloseTabContent.classList.remove("hide"))
            : (tabContainersElem.classList.add("videoosd-tabcontainers-hidden"),
              btnCloseTabContent.classList.add("hide"));
      }),
      btnCloseTabContent.addEventListener("click", function () {
        self.bottomTabs.selectedIndex(-1);
      }),
      _dom.default.addEventListener(
        tabContainersElem,
        transitionEndEventName,
        onTabTransitionEnd,
        { passive: !0 },
      ),
      _inputmanager.default.on(self.bottomTabs, function (e) {
        switch (e.detail.command) {
          case "up":
            -1 !== self.bottomTabs.selectedIndex() &&
              (self.bottomTabs.selectedIndex(-1),
              e.preventDefault(),
              e.stopPropagation(),
              self.showOsd());
            break;
          case "down":
            var btn;
            -1 === self.bottomTabs.selectedIndex() &&
              ((btn = e.target.closest(".videoosd-tab-button"))
                ? self.bottomTabs.selectedIndex(
                    parseInt(btn.getAttribute("data-index")),
                  )
                : self.bottomTabs.selectedIndex(-1));
        }
      });
    for (
      var lockButtons = view.querySelectorAll(".videoOsd-btnToggleLock"),
        _i24 = 0,
        _length24 = lockButtons.length;
      _i24 < _length24;
      _i24++
    )
      _dom.default.addEventListener(lockButtons[_i24], "click", onLockClick, {
        passive: !0,
      });
    if (
      (_dom.default.addEventListener(
        btnHideUpNext,
        "click",
        function () {
          showHideUpNext(!1);
        },
        { passive: !0 },
      ),
      _dom.default.addEventListener(
        view.querySelector(".btnPlayNextFromUpNext"),
        "click",
        onNextTrackClick,
        { passive: !0 },
      ),
      _dom.default.addEventListener(
        btnSkipIntro,
        "click",
        function () {
          if (!skipIntroValidated)
            return validateSkipIntroFeature().then(onSkipIntroClickInternal);
          onSkipIntroClickInternal();
        },
        { passive: !0 },
      ),
      _dom.default.addEventListener(
        view.querySelector(".btnPlayQueue"),
        "click",
        onContentSectionToggleButtonClick,
        { passive: !0 },
      ),
      _dom.default.addEventListener(
        btnLyrics,
        "click",
        onContentSectionToggleButtonClick,
        { passive: !0 },
      ),
      _dom.default.allowBackdropFilter())
    )
      for (
        var toggleButtonIcons = view.querySelectorAll(".toggleButtonIcon"),
          _i25 = 0,
          _length25 = toggleButtonIcons.length;
        _i25 < _length25;
        _i25++
      )
        toggleButtonIcons[_i25].classList.add(
          "toggleButtonIcon-backdropfilter",
        );
    _inputmanager.default.on(self.nowPlayingPositionSlider, function (e) {
      var stepUpCommand,
        stepDownCommand =
          "rtl" === document.dir
            ? ((stepUpCommand = "left"), "right")
            : ((stepUpCommand = "right"), "left");
      switch (e.detail.command) {
        case stepDownCommand:
        case "rewind":
          e.preventDefault(),
            (nowPlayingSliderValue = e.detail.repeat
              ? Math.min(
                  Math.max(
                    nowPlayingSliderValue - parseFloat(this.step),
                    this.min,
                  ),
                  this.max,
                )
              : Math.min(
                  Math.max(
                    nowPlayingSliderValue -
                      convertMsToNowPlayingSliderStep(
                        _usersettings.default.skipBackLength(),
                      ),
                    this.min,
                  ),
                  this.max,
                )),
            this.beginEditing(nowPlayingSliderValue),
            startEndEditTimeoutForPositionSlider();
          break;
        case stepUpCommand:
        case "fastforward":
          e.preventDefault(),
            (nowPlayingSliderValue = e.detail.repeat
              ? Math.min(
                  Math.max(
                    nowPlayingSliderValue + parseFloat(this.step),
                    this.min,
                  ),
                  this.max,
                )
              : Math.min(
                  Math.max(
                    nowPlayingSliderValue +
                      convertMsToNowPlayingSliderStep(
                        _usersettings.default.skipForwardLength(),
                      ),
                    this.min,
                  ),
                  this.max,
                )),
            this.beginEditing(nowPlayingSliderValue),
            startEndEditTimeoutForPositionSlider();
          break;
        case "pageup":
          e.preventDefault(),
            _playbackmanager.default.nextChapter(self.currentPlayer);
          break;
        case "pagedown":
          e.preventDefault(),
            _playbackmanager.default.previousChapter(self.currentPlayer);
          break;
        case "back":
          cancelPositionSliderEditing();
          break;
        case "play":
        case "playpause":
          self.nowPlayingPositionSlider.dragging &&
            (e.preventDefault(),
            e.stopPropagation(),
            self.nowPlayingPositionSlider.endEditing(
              !0,
              nowPlayingSliderValue,
            ));
          break;
        case "select":
          self.nowPlayingPositionSlider.dragging
            ? (e.preventDefault(),
              e.stopPropagation(),
              self.nowPlayingPositionSlider.endEditing(
                !0,
                nowPlayingSliderValue,
              ))
            : _playbackmanager.default.playPause(self.currentPlayer);
      }
    }),
      self.nowPlayingPositionSlider.addEventListener("keydown", function (e) {
        var key = _keyboard.default.normalizeKeyFromEvent(e);
        ("Enter" !== key && " " !== key) ||
          (this.dragging &&
            (e.preventDefault(),
            e.stopPropagation(),
            this.endEditing(!0, nowPlayingSliderValue)));
      }),
      self.nowPlayingPositionSlider.addEventListener("blur", function (e) {
        cancelPositionSliderEditing();
      });
    for (
      var sections = view.querySelectorAll(".osdContentSection"),
        _i23 = 0,
        _length23 = sections.length;
      _i23 < _length23;
      _i23++
    ) {
      var section = sections[_i23];
      (_layoutmanager.default.tv &&
        "lyrics" !== section.getAttribute("data-contentsection")) ||
        section.classList.add("osdContentSection-split"),
        _layoutmanager.default.tv &&
          "lyrics" === section.getAttribute("data-contentsection") &&
          section.classList.add("osdContentSection-tv-split");
    }
    _shortcuts.default.on(this.videoOsdText),
      (this.boundHideOsd = this.hideOsd.bind(this)),
      (this.boundShowOsdDefaultParams = function () {
        this.showOsd();
      }.bind(this)),
      (this.boundOnOsdHideTimeout = function () {
        _focusmanager.default.hasExclusiveFocusScope() ||
        0 <= this.bottomTabs.selectedIndex()
          ? startOsdHideTimer(this)
          : this.mouseOverButton || this.hideOsd();
      }.bind(this));
  }
  Object.assign(VideoOsd.prototype, _baseview.default.prototype),
    (VideoOsd.prototype.enableWindowInputCommands = function () {
      return !0;
    }),
    (VideoOsd.prototype.onWindowInputCommand = function (e) {
      var mediaType;
      switch (e.detail.command) {
        case "back":
          var upNextContainer = e.target.closest(".upNextContainer");
          return upNextContainer
            ? (e.preventDefault(),
              void upNextContainer.querySelector(".btnHideUpNext").click())
            : void (
                !_layoutmanager.default.tv ||
                _focusmanager.default.hasExclusiveFocusScope() ||
                ((upNextContainer =
                  null == (upNextContainer = e.detail.originalEvent)
                    ? void 0
                    : upNextContainer.target) &&
                  headerElement.contains(upNextContainer)) ||
                (isDisplayingLocalVideo(this.currentPlayer)
                  ? this.currentVisibleMenu &&
                    !this.upNextContainer._visible &&
                    (e.preventDefault(), this.hideOsd())
                  : !this.currentVisibleMenu &&
                    (upNextContainer = this.currentPlayer) &&
                    upNextContainer.isLocalPlayer &&
                    (mediaType ||
                      _playbackmanager.default.isPlaying(upNextContainer)) &&
                    (e.preventDefault(), this.showOsd()))
              );
        case "left":
          return e.target.closest(".skipIntroContainer,.upNextContainer")
            ? void 0
            : void (
                "rtl" === document.dir
                  ? onFastForwardInputCommand
                  : onRewindInputCommand
              )(e, this);
        case "rewind":
          return void onRewindInputCommand(e, this);
        case "right":
          return e.target.closest(".skipIntroContainer,.upNextContainer")
            ? void 0
            : void (
                "rtl" === document.dir
                  ? onRewindInputCommand
                  : onFastForwardInputCommand
              )(e, this);
        case "fastforward":
          return void onFastForwardInputCommand(e, this);
        case "pageup":
          return void _playbackmanager.default.nextChapter(this.currentPlayer);
        case "pagedown":
          return void _playbackmanager.default.previousChapter(
            this.currentPlayer,
          );
        case "playpause":
          e.preventDefault(), e.stopPropagation();
          var isPaused =
            null == (upNextContainer = this.currentPlayer)
              ? void 0
              : upNextContainer.paused();
          return (
            _playbackmanager.default.playPause(this.currentPlayer),
            void (
              (this.currentVisibleMenu ||
                (shouldOsdBeShown(this) && !isPaused)) &&
              this.showOsd()
            )
          );
        case "play":
          e.preventDefault(), e.stopPropagation();
          isPaused =
            null == (isPaused = this.currentPlayer)
              ? void 0
              : isPaused.paused();
          return (
            _playbackmanager.default.unpause(this.currentPlayer),
            void (
              (this.currentVisibleMenu ||
                (shouldOsdBeShown(this) && !isPaused)) &&
              this.showOsd()
            )
          );
        case "select":
          return void (
            onOsdClick(e, this, null, shouldOsdBeShown(this)) &&
            e.preventDefault()
          );
        case "up":
        case "down":
          return void (shouldOsdBeShown(this) && this.showOsd());
        case "menu":
        case "pause":
        case "nowplaying":
          return void (shouldOsdBeShown(this) && this.showOsd());
        case "record":
          return (
            shouldOsdBeShown(this) && this.showOsd(),
            void (function (instance) {
              (instance = instance.btnRecord).classList.contains("hide") ||
                instance.click();
            })(this)
          );
        case "togglestats":
          return void toggleStats(this);
        case "movies":
        case "music":
        case "tv":
        case "settings":
        case "search":
        case "favorites":
        case "recordedtv":
          return void e.preventDefault();
        case "info":
          return setBottomTabIndex(this, 0), void e.preventDefault();
        case "livetv":
        case "guide":
          return (
            this.bottomTabButtons[3].classList.contains("hide") ||
              setBottomTabIndex(this, 3),
            void e.preventDefault()
          );
      }
      _baseview.default.prototype.onWindowInputCommand.apply(this, arguments);
    }),
    (VideoOsd.prototype.setLockState = function (lockState) {
      ((this.currentLockState = lockState)
        ? (headerElement.classList.add("videoOsdHeader-locked"),
          this.osdBottomElement.classList.add("videoosd-bottom-locked"),
          this.view
            .querySelector(".videoOsdUnlockControls")
            .classList.remove("hide"),
          1 === lockState
            ? (this.view
                .querySelector(".videoOsd-btnUnlock1")
                .classList.remove("hide"),
              this.view
                .querySelector(".videoOsd-btnUnlock2")
                .classList.add("hide"))
            : (this.view
                .querySelector(".videoOsd-btnUnlock1")
                .classList.add("hide"),
              this.view
                .querySelector(".videoOsd-btnUnlock2")
                .classList.remove("hide")),
          lockOrientation)
        : (headerElement.classList.remove("videoOsdHeader-locked"),
          this.osdBottomElement.classList.remove("videoosd-bottom-locked"),
          this.view
            .querySelector(".videoOsdUnlockControls")
            .classList.add("hide"),
          this.view.querySelector(".videoOsd-btnUnlock1").classList.add("hide"),
          this.view.querySelector(".videoOsd-btnUnlock2").classList.add("hide"),
          unlockOrientation))();
    }),
    (VideoOsd.prototype.showOsd = function (timeoutMs, elementToFocus) {
      this.paused ||
        (headerElement.classList.remove("hide"),
        headerElement.offsetWidth,
        headerElement.classList.remove("videoOsdHeader-hidden"),
        (function (instance, elementToFocus) {
          var elem;
          instance.currentVisibleMenu ||
            ((elem = instance.osdBottomElement),
            (instance.currentVisibleMenu = "osd"),
            elem.classList.remove("hide"),
            elem.offsetWidth,
            elem.classList.remove("videoOsdBottom-hidden"),
            _focusmanager.default.hasExclusiveFocusScope() ||
              (elementToFocus
                ? _focusmanager.default.focus(elementToFocus)
                : focusMainOsdControls(instance)),
            console.log(
              "showMainOsdControls activeElement: " +
                document.activeElement.className,
            ),
            instance.view.dispatchEvent(
              new CustomEvent("video-osd-show", { bubbles: !0 }),
            ));
        })(this, elementToFocus),
        startOsdHideTimer(this, timeoutMs));
    }),
    (VideoOsd.prototype.hideOsd = function () {
      var instance, elem;
      isDisplayingLocalVideo(this.currentPlayer) &&
        (headerElement.classList.add("videoOsdHeader-hidden"),
        (instance = this).currentVisibleMenu &&
          ((elem = instance.osdBottomElement).offsetWidth,
          elem.classList.add("videoOsdBottom-hidden"),
          (instance.currentVisibleMenu = null)),
        (elem = this.lyricsRenderer)) &&
        !elem.paused &&
        _layoutmanager.default.tv &&
        elem.focus();
    }),
    (VideoOsd.prototype.exit = function () {
      _approuter.default.back();
    }),
    (VideoOsd.prototype.onResume = function (options) {
      _baseview.default.prototype.onResume.apply(this, arguments),
        _layoutmanager.default.tv
          ? headerElement.classList.add("videoOsdHeader")
          : headerElement.classList.add(
              "videoOsdHeader",
              "videoOsd-customFont-x2",
            );
      var boundOnPlayerChange =
          (boundOnPlayerChange = this.boundOnPlayerChange) ||
          (this.boundOnPlayerChange = function (e, player) {
            this.bindToPlayer(player), this.bottomTabs.selectedIndex(-1);
          }.bind(this)),
        boundOnPlayerChange =
          (_events.default.on(
            _playbackmanager.default,
            "playerchange",
            boundOnPlayerChange,
          ),
          this.bindToPlayer(_playbackmanager.default.getCurrentPlayer(), !0),
          this.currentPlayer),
        boundOnPlayerChange =
          (boundOnPlayerChange &&
            !options.refresh &&
            this.updateTransparency(
              boundOnPlayerChange,
              this.lastPlayerState || {},
              null == (boundOnPlayerChange = this.currentItem)
                ? void 0
                : boundOnPlayerChange.MediaType,
            ),
          this.view),
        boundPointerMove =
          (boundPointerMove = this.boundPointerMove) ||
          (this.boundPointerMove = function (e) {
            var obj,
              pointerType = e.pointerType;
            "touch" === pointerType ||
              (!pointerType && supportsTouchEvent) ||
              ((pointerType = e.screenX || 0),
              (e = e.screenY || 0),
              (obj = this.lastPointerMoveData)
                ? (Math.abs(pointerType - obj.x) < 10 &&
                    Math.abs(e - obj.y) < 10) ||
                  ((obj.x = pointerType), (obj.y = e), this.showOsd())
                : ((this.lastPointerMoveData = { x: pointerType, y: e }),
                  this.showOsd()));
          }.bind(this));
      _dom.default.addEventListener(
        document,
        window.PointerEvent ? "pointermove" : "mousemove",
        boundPointerMove,
        { passive: !0 },
      );
      boundPointerMove =
        (boundPointerMove = this.boundPointerEnter) ||
        (this.boundPointerEnter = function (e) {
          var pointerType = e.pointerType;
          "touch" === pointerType ||
            (!pointerType && supportsTouchEvent) ||
            (this.mouseOverButton = null != e.target.closest("button,a"));
        }.bind(this));
      _dom.default.addEventListener(
        boundOnPlayerChange,
        window.PointerEvent ? "pointerenter" : "mouseenter",
        boundPointerMove,
        { passive: !0, capture: !0 },
      );
      boundPointerMove =
        (boundPointerMove = this.boundPointerLeave) ||
        (this.boundPointerLeave = function (e) {
          this.mouseOverButton = null;
        }.bind(this));
      _dom.default.addEventListener(
        boundOnPlayerChange,
        window.PointerEvent ? "pointerleave" : "mouseleave",
        boundPointerMove,
        { passive: !0, capture: !0 },
      ),
        (function (view) {
          var activeElement = document.activeElement;
          if (activeElement && !view.contains(activeElement))
            try {
              activeElement.blur();
            } catch (err) {
              console.log("Error blurring element from previous view: " + err);
            }
        })(boundOnPlayerChange);
      boundPointerMove =
        (boundPointerMove = this.boundWindowKeyDown) ||
        (this.boundWindowKeyDown = function (e) {
          switch (_keyboard.default.normalizeKeyFromEvent(e)) {
            case "Enter":
            case " ":
              return _focusmanager.default.hasExclusiveFocusScope()
                ? void 0
                : void (this.currentVisibleMenu &&
                  !e.target.closest(".videoOsdPositionSlider")
                    ? this.showOsd()
                    : e.target.closest("BUTTON") ||
                      this.nowPlayingPositionSlider.dragging ||
                      (_playbackmanager.default.playPause(this.currentPlayer),
                      shouldOsdBeShown(this) &&
                        setTimeout(this.boundShowOsdDefaultParams, 100),
                      _browser.default.edge &&
                        (e.preventDefault(), e.stopPropagation())));
            case "b":
            case "B":
              if (!_focusmanager.default.hasExclusiveFocusScope() && e.ctrlKey)
                return e.shiftKey
                  ? (e.preventDefault(), void rewind(this))
                  : (e.preventDefault(),
                    void _playbackmanager.default.previousChapter(
                      this.currentPlayer,
                    ));
              break;
            case "f":
            case "F":
              if (!_focusmanager.default.hasExclusiveFocusScope()) {
                if (e.ctrlKey)
                  return e.shiftKey
                    ? (e.preventDefault(), void fastForward(this))
                    : (e.preventDefault(),
                      void _playbackmanager.default.nextChapter(
                        this.currentPlayer,
                      ));
                _playbackmanager.default.toggleFullscreen(this.currentPlayer);
              }
              break;
            case "m":
            case "M":
              _focusmanager.default.hasExclusiveFocusScope() ||
                _playbackmanager.default.toggleMute(this.currentPlayer);
          }
        }.bind(this));
      _dom.default.addEventListener(window, "keydown", boundPointerMove, {}),
        _mouse.default.requestMouseListening("videoosd");
    }),
    (VideoOsd.prototype.onPause = function () {
      _baseview.default.prototype.onPause.apply(this, arguments);
      var statsOverlay = this.statsOverlay;
      statsOverlay && statsOverlay.enabled(!1);
      this.subtitleOffsetOverlay && destroySubtitleOffsetOverlay(this);
      var statsOverlay = this.boundWindowKeyDown,
        statsOverlay =
          (statsOverlay &&
            _dom.default.removeEventListener(
              window,
              "keydown",
              statsOverlay,
              {},
            ),
          headerElement.classList.remove(
            "videoOsdHeader",
            "videoosd-header-safe",
            "videoOsdHeader-hidden",
            "videoOsdHeader-locked",
            "hide",
            "videoOsd-customFont-x2",
            "videoOsd-customFont-remotecontrol",
          ),
          backdropContainer.classList.remove(
            "nowplaying-backdropcontainer-blur",
            "nowplaying-backdropcontainer-blur-high",
            "nowplaying-backdropcontainer-blur-extrasaturation",
            "nowplaying-backdropcontainer-blur-backdropfilter",
          ),
          backgroundContainer.classList.remove(
            "nowplaying-backgroundcontainer-blur",
            "nowplaying-backgroundcontainer-brighter",
            "nowplaying-backgroundcontainer-blur-backdropfilter",
          ),
          clearBlurFromDocumentElement(),
          this.boundPointerMove),
        statsOverlay =
          (statsOverlay &&
            _dom.default.removeEventListener(
              document,
              window.PointerEvent ? "pointermove" : "mousemove",
              statsOverlay,
              { passive: !0 },
            ),
          this.boundOnPlayerChange);
      statsOverlay &&
        _events.default.off(
          _playbackmanager.default,
          "playerchange",
          statsOverlay,
        ),
        this.enableStopOnBack &&
          ((this.enableStopOnBack = !1),
          (this.enableBackOnStop = !1),
          null != (statsOverlay = this.currentPlayer) &&
          statsOverlay.isLocalPlayer &&
          _usersettings.default.enableVideoUnderUI()
            ? _approuter.default.setTransparency("backdrop")
            : _playbackmanager.default.stop(statsOverlay)),
        this.releaseCurrentPlayer(),
        _mouse.default.releaseMouseListening("videoosd"),
        stopOsdHideTimer(this),
        _backdrop.default.clear(),
        this.setLockState(0),
        unlockOrientation(),
        setSystemUIHidden(!1);
    }),
    (VideoOsd.prototype.destroy = function () {
      _baseview.default.prototype.destroy.apply(this, arguments);
      var videoOsdText = this.videoOsdText,
        videoOsdText =
          (videoOsdText &&
            (_shortcuts.default.off(videoOsdText), (this.videoOsdText = null)),
          destroyPlayQueue(this),
          destroyLyricsRenderer(this),
          this.recordingButtonManager),
        bottomTabControllers =
          (videoOsdText &&
            (videoOsdText.destroy(), (this.recordingButtonManager = null)),
          destroyStats(this),
          destroySubtitleOffsetOverlay(this),
          this.bottomTabControllers);
      if (bottomTabControllers) {
        for (var i = 0, length = bottomTabControllers.length; i < length; i++)
          bottomTabControllers[i] && bottomTabControllers[i].destroy();
        this.bottomTabControllers = null;
      }
      (this.boundPointerMove = null),
        (this.boundWindowKeyDown = null),
        (this.boundInputCommand = null),
        (this.boundHideOsd = null),
        (this.boundShowOsdDefaultParams = null),
        (this.boundOnOsdHideTimeout = null),
        (this.boundOnPlayerChange = null),
        (this.upNextContainer = null),
        (this.lastPlayerState = null);
    }),
    (_exports.default = VideoOsd);
});
