define([
  "exports",
  "./../emby-apiclient/connectionmanager.js",
  "./../emby-apiclient/events.js",
  "./../common/textencoding.js",
  "./../common/globalize.js",
  "./../common/datetime.js",
  "./../common/itemmanager/itemmanager.js",
  "./../common/playback/playbackmanager.js",
  "./../dom.js",
  "./../browser.js",
  "./../focusmanager.js",
  "./../layoutmanager.js",
  "./../mediainfo/mediainfo.js",
  "./../common/dataformatter.js",
  "./../indicators/indicators.js",
  "./../shortcuts.js",
  "./../common/servicelocator.js",
  "./../imageloader/imageloader.js",
  "./../emby-elements/userdatabuttons/emby-playstatebutton.js",
  "./../emby-elements/userdatabuttons/emby-ratingbutton.js",
  "./../emby-elements/emby-checkbox/emby-checkbox.js",
  "./../emby-elements/emby-button/paper-icon-button-light.js",
  "./../common/usersettings/usersettings.js",
], function (
  _exports,
  _connectionmanager,
  _events,
  _textencoding,
  _globalize,
  _datetime,
  _itemmanager,
  _playbackmanager,
  _dom,
  _browser,
  _focusmanager,
  _layoutmanager,
  _mediainfo,
  _dataformatter,
  _indicators,
  _shortcuts,
  _servicelocator,
  _imageloader,
  _embyPlaystatebutton,
  _embyRatingbutton,
  _embyCheckbox,
  _paperIconButtonLight,
  _usersettings,
) {
  Object.defineProperty(_exports, "__esModule", { value: !0 }),
    (_exports.default = void 0),
    require([
      "css!modules/cardbuilder/card.css",
      "programStyles",
      "embyProgressBarStyle",
    ]);
  var decodingAttribute = _dom.default.supportsAsyncDecodedImages()
      ? ' decoding="async"'
      : "",
    supportsObjectFit =
      CSS.supports("object-fit", "contain") && !_browser.default.edge,
    supportsCssVariables = CSS.supports("color", "var(--fake-var)"),
    supportsCalc = CSS.supports("width", "min(45.2%,calc(100% - .65em))"),
    supportsMin = CSS.supports("width", "min(10em, 5vw)"),
    EnableFocusTransfrom = _dom.default.allowFocusScaling(),
    supportsNativeLazyLoading = "loading" in HTMLImageElement.prototype;
  var refreshIndicatorLoaded,
    cachedWidths = {};
  function setListOptions(items, options) {
    null == options.isBoundListItem && (options.isBoundListItem = !0),
      options.horizontal,
      (options.loadingLazyAttribute = ' loading="lazy"'),
      (options.cardSize && "default" !== options.cardSize) ||
        (options.cardSize = _usersettings.default.cardSize()),
      (options.itemSelector = ".card"),
      (options.imageFallback = !1 !== options.imageFallback);
    for (
      var shape = options.shape || "auto",
        fieldMap =
          (options.sideFooter && (options.textLinks = !(shape = "banner")),
          options.fields || (options.fields = []),
          {}),
        i = 0,
        length = options.fields.length;
      i < length;
      i++
    )
      fieldMap[options.fields[i]] = !0;
    (options.fieldMap = fieldMap),
      (options.fieldMapWithForceName = Object.assign(
        Object.assign({}, fieldMap),
        { ParentNameOrName: !0 },
      ));
    var tagName,
      templateLines = (function (options) {
        var options = options.fieldMap,
          lines = [];
        return (
          options.Name && lines.push(""),
          options.ParentNameOrName && lines.push(""),
          (options.ProductionYear ||
            options.OfficialRating ||
            options.Runtime) &&
            lines.push(""),
          (options.CommunityRating || options.CriticRating) &&
            lines.push(
              '<div class="mediaInfoItems cardMediaInfoItems"><div class="mediaInfoItem mediaInfoCriticRating cardMediaInfoItem"><div class="mediaInfoCriticRatingImage mediaInfoCriticRatingFresh" style="visibility:hidden;"></div>91%</div></div>',
            ),
          options.PersonRole && lines.push(""),
          options.ChapterTime && lines.push(""),
          options.ChannelName && lines.push(""),
          options.LastServerAddress && lines.push(""),
          options.Overview && lines.push(getOverviewText("")),
          options.Album && lines.push(""),
          options.Type && lines.push(""),
          options.LastActivityDateRelative && lines.push(""),
          options.DateCreated && lines.push(""),
          options.DateModified && lines.push(""),
          options.Size && lines.push(""),
          options.Version && lines.push(""),
          options.Url && lines.push(""),
          options.InstalledVersion && lines.push(""),
          options.ItemImageName && lines.push(""),
          options.Filename && lines.push(""),
          options.FilenameOrName && lines.push(""),
          (options.Resolution || options.Container || options.Bitrate) &&
            lines.push(""),
          options.ParentName && lines.push(""),
          options.CollectionType && lines.push(""),
          options.LibraryFolders && lines.push(""),
          options.AppNameVersion && lines.push(""),
          options.AppName && lines.push(""),
          options.DeviceUserInfo && lines.push(""),
          options.CurrentProgramTime && lines.push(""),
          options.CurrentProgramParentName && lines.push(""),
          options.CurrentProgramName && lines.push(""),
          options.SeriesTimerChannel && lines.push(""),
          options.SeriesTimerTime && lines.push(""),
          options.ImageEditorStandardButtons && lines.push(""),
          options.ImageEditorBackdropButtons && lines.push(""),
          options.Genres && lines.push(""),
          options.Tags && lines.push(""),
          options.Studios && lines.push(""),
          options.SessionNowPlayingInfo &&
            (lines.push(""), lines.push(""), lines.push("")),
          options.AirTime && lines.push(""),
          options.AccessToken && lines.push(""),
          options.DownloadableImageInfo && (lines.push(""), lines.push("")),
          lines
        );
      })(options),
      autoShape =
        (options.lines ||
          options.overlayText ||
          (options.lines = templateLines.length),
        "auto" === shape || "autooverflow" === shape),
      items = (shape = autoShape
        ? _imageloader.default.getShape(items, options)
        : shape),
      autoShape =
        (options.sideFooter && (items = "square"),
        "auto" === options.preferThumb &&
          (options.preferThumb =
            "square" === items
              ? null
              : "backdrop" === items || "fourThree" === items),
        !0 === options.preferThumb &&
          autoShape &&
          ((items = "backdrop"), options.sideFooter || (shape = "backdrop")),
        (options.uiAspect = _imageloader.default.getAspectFromShape(
          items,
          options,
        ).aspect),
        !options.width &&
          options.widths &&
          (options.width = options.widths[items]),
        options.rows &&
          "number" != typeof options.rows &&
          (options.rows = options.rows[items]),
        "card"),
      isLayoutTV =
        (shape && (autoShape += " " + shape + "Card"),
        options.horizontal &&
          (autoShape += " card-horiz " + shape + "Card-horiz"),
        options.cardClass && (autoShape += " " + options.cardClass),
        _layoutmanager.default.tv),
      isSingleClickElement =
        (isLayoutTV || (autoShape += " card-hoverable"),
        (options.enableFocusScaling =
          !1 !== options.enableFocusScaling &&
          isLayoutTV &&
          EnableFocusTransfrom),
        (options.enableCardBox =
          options.enableFocusScaling ||
          options.cardLayout ||
          options.sideFooter ||
          !isLayoutTV ||
          !options.isVirtualList),
        (isLayoutTV && !options.staticElement) ||
          (!1 === options.hoverMenu && "none" !== options.action)),
      lineContents =
        (options.enableFocusScaling && (autoShape += " card-focustransform"),
        options.sideFooter &&
          ((autoShape += " sideFooterCard"), options.horizontal) &&
          (autoShape += " sideFooterCard-horiz"),
        options.smallSideFooter &&
          ((autoShape += " smallSideFooterCard"), options.horizontal) &&
          (autoShape += " smallSideFooterCard-horiz"),
        isSingleClickElement
          ? ((tagName = "button"), (autoShape += " itemAction"))
          : ((tagName = "div"),
            options.staticElement || (options.addTabIndex = !0)),
        isLayoutTV
          ? ((options.draggable = !1),
            (options.dropTarget = !1),
            (options.dragReorder = !1))
          : ((options.draggable = !1 !== options.draggable),
            options.dragReorder && options.draggable
              ? (autoShape += " drop-target ordered-drop-target-x")
              : options.dropTarget &&
                (autoShape += " drop-target full-drop-target")),
        []);
    for (
      options.lines && (lineContents.length = options.lines),
        i = 0,
        length = lineContents.length;
      i < length;
      i++
    )
      lineContents[i] = templateLines[i] || "&nbsp;";
    var cardBoxClass = ((options.cardBoxClass || "") + " cardBox").trim(),
      lines =
        (options.sideFooter &&
          ((cardBoxClass += " cardBox-sideFooter"),
          isLayoutTV && (cardBoxClass += " cardBox-sideFooter-f"),
          !0 !== options.centerText) &&
          (options.centerText = !1),
        null == options.centerText &&
          (options.centerText = !options.overlayText),
        (options.cardTextCssClass = options.centerText
          ? "cardText"
          : "cardText text-align-start"),
        lineContents.length
          ? getCardTextLines(
              lineContents,
              options.cardTextCssClass,
              !options.overlayText,
              !0,
              lineContents.length,
              options,
            )
          : ""),
      cardDefaultTextClass = (
        (options.cardDefaultTextClass || "") + " cardText cardDefaultText"
      ).trim(),
      cardDefaultTextClass =
        ((options.cardDefaultTextClass = cardDefaultTextClass),
        (options.cardLayout || options.sideFooter) &&
          ((cardBoxClass += " visualCardBox"), options.vibrant) &&
          ((cardBoxClass += " visualCardBox-vibrant"),
          "large" === options.vibrantMode) &&
          (cardBoxClass += " visualCardBox-vibrant-lg"),
        isLayoutTV &&
          options.enableFocusScaling &&
          ((cardBoxClass += " cardBox-focustransform"),
          !options.focusTransformTitleAdjust ||
            ("portrait" !== shape &&
              "square" !== shape &&
              "fourThree" !== shape) ||
            (cardBoxClass += " cardBox-focustransform-titleadjust")),
        isSingleClickElement ||
          !1 === options.moreButton ||
          options.staticElement ||
          (cardBoxClass += " cardBox-touchzoom"),
        !lineContents.length ||
          options.overlayText ||
          options.cardLayout ||
          options.sideFooter ||
          !1 === options.allowBottomPadding ||
          (options.enableCardBox
            ? (cardBoxClass += " cardBox-bottompadded")
            : (autoShape += " card-bottompadded")),
        options.enableCardBox || (autoShape += " card-padded"),
        []),
      innerCardFooterClass =
        (options.sideFooter || cardDefaultTextClass.push("cardPadder-" + shape),
        options.cardPadderClass &&
          cardDefaultTextClass.push(options.cardPadderClass),
        ["innerCardFooter"]),
      cardContentClass =
        (options.innerCardFooterClass &&
          innerCardFooterClass.push(options.innerCardFooterClass),
        (options.round = options.round && "square" === shape),
        (
          (options.cardContentClass || "") + " cardContent cardImageContainer"
        ).trim()),
      screenWidth =
        (options.cardLayout ||
          options.sideFooter ||
          ((cardContentClass += " cardContent-shadow"),
          "black" === options.background &&
            (cardContentClass += " cardContent-bg-black")),
        options.paddedImage && (cardContentClass += " paddedImage"),
        options.defaultBackground &&
          !options.cardLayout &&
          (cardContentClass += " defaultCardBackground"),
        options.imageClass && (cardContentClass += " " + options.imageClass),
        options.sideFooter &&
          ((cardContentClass += " cardImageContainer-sideFooter"),
          options.smallSideFooter) &&
          (cardContentClass += " cardImageContainer-smallSideFooter"),
        options.round && (cardContentClass += " cardContent-round"),
        options.enableFocusScaling ||
          options.sideFooter ||
          (isSingleClickElement || options.action,
          isLayoutTV
            ? options.cardLayout
              ? (cardBoxClass += " cardContent-bxsborder")
              : (cardContentClass += " cardContent-bxsborder")
            : (cardContentClass += " cardContent-bxsborder-fv")),
        options.width ||
          ((screenWidth = _dom.default.getWindowSize().innerWidth),
          (options.width = (function (
            cardClass,
            cardBoxClass,
            cardContentClass,
            options,
            screenWidth,
          ) {
            options.sideFooter && (cardClass += " withsidefooter"),
              options.imageWidthTestClass &&
                (cardClass += " " + options.imageWidthTestClass);
            var cardSize = options.cardSize,
              key = cardClass + screenWidth + cardSize;
            switch (cardSize) {
              case "":
              case "normal":
              case "default":
                break;
              default:
                key += "-" + cardSize;
            }
            (screenWidth = _layoutmanager.default.tv) && (key += "-tv");
            var itemsContainerClass,
              width = cachedWidths[key];
            return (
              width ||
                (console.log("getImageWidth: " + key),
                (itemsContainerClass =
                  "itemsContainer padded-left padded-right"),
                screenWidth && (itemsContainerClass += " itemsContainer-tv"),
                ((screenWidth = document.createElement("div")).className =
                  itemsContainerClass),
                (screenWidth.style.visibility = "hidden"),
                options.sideFooter
                  ? (screenWidth.innerHTML =
                      '<div class="' +
                      cardClass +
                      '"><div class="' +
                      cardBoxClass +
                      '"><div class="' +
                      cardContentClass +
                      '"></div></div></div>')
                  : (screenWidth.innerHTML =
                      '<div class="' +
                      cardClass +
                      '"><div class="' +
                      cardBoxClass +
                      ' cardScalable"></div></div>'),
                (itemsContainerClass = document.body).appendChild(screenWidth),
                (width = options.sideFooter
                  ? (cachedWidths[key] =
                      screenWidth.querySelector(".cardImageContainer")
                        .offsetWidth || 400)
                  : (cachedWidths[key] =
                      screenWidth.querySelector(".cardScalable").offsetWidth ||
                      400)),
                itemsContainerClass.removeChild(screenWidth),
                console.log("width: " + width)),
              width
            );
          })(autoShape, cardBoxClass, cardContentClass, options, screenWidth)),
          (windowWidth = screenWidth),
          (screen = window.screen) &&
            20 < screen.availWidth - windowWidth &&
            (options.width = 50 * Math.ceil(options.width / 50))),
        options.enableCardBox ? '<div class="' + cardBoxClass + '">' : ""),
      cardDefaultTextClass = cardDefaultTextClass.join(" "),
      innerCardFooterClass = innerCardFooterClass.join(" "),
      screen =
        (isSingleClickElement || "none" === options.action
          ? (screenWidth +=
              '<div class="' +
              cardContentClass +
              " " +
              cardDefaultTextClass +
              '"></div>')
          : (screenWidth +=
              '<button type="button" tabindex="-1" class="cardContent-button ' +
              cardContentClass +
              " " +
              cardDefaultTextClass +
              '"></button>'),
        "cardFooter"),
      windowWidth =
        (options.vibrant && (screen += " cardFooter-vibrant"),
        (options.outerFooterClass = screen),
        options.cardLayout && (screenWidth += '<div class="' + screen + '">'),
        (screenWidth += lines),
        options.cardLayout && (screenWidth += "</div>"),
        options.enableCardBox && (screenWidth += "</div>"),
        null == options.defaultIcon &&
          (options.sideFooter || options.lines || fieldMap.Name
            ? (options.defaultIcon = !0)
            : (options.defaultIcon = !1)),
        (options.moreTitle = _globalize.default.translate("More")),
        (options.multiSelectTitle =
          _globalize.default.translate("MultiSelect")),
        (options.multiSelect = !1 !== options.multiSelect && !isLayoutTV),
        (options.contextMenu = !1 !== options.contextMenu),
        (options.enableUserData = !1 !== options.enableUserData),
        "");
    options.addTabIndex && (windowWidth += ' tabindex="0"'),
      options.draggable && (windowWidth += ' draggable="true"'),
      "button" === tagName && (windowWidth += ' type="button"'),
      (options.fixedAttributes = windowWidth.trim()),
      (options.templateInnerHTML = screenWidth),
      (options.cardPadderClass = cardDefaultTextClass),
      (options.innerCardFooterClass = innerCardFooterClass),
      (options.tagName = tagName),
      (options.shape = shape),
      (options.imageShape = items),
      (options.className = autoShape),
      (options.isSingleClickElement = isSingleClickElement),
      (options.cardContentClass = cardContentClass),
      (options.cardBoxClass = cardBoxClass);
  }
  function buildCardsHtmlInternal(items, options) {
    setListOptions(items, options);
    for (
      var hasOpenRow,
        html = "",
        itemsInRow = 0,
        rows = options.rows,
        i = 0,
        length = items.length;
      i < length;
      i++
    )
      rows &&
        0 === itemsInRow &&
        (hasOpenRow && ((html += "</div>"), (hasOpenRow = !1)),
        (html += '<div class="cardColumn">'),
        (hasOpenRow = !0)),
        (html += getCardHtml(items[i], i, options)),
        itemsInRow++,
        rows &&
          rows <= itemsInRow &&
          ((html += "</div>"), (hasOpenRow = !1), (itemsInRow = 0));
    return hasOpenRow && (html += "</div>"), html;
  }
  function getCardTextLines(
    lines,
    cssClass,
    forceLines,
    isOuterFooter,
    maxLines,
    options,
  ) {
    for (
      var html = "",
        valid = 0,
        currentCssClass = cssClass,
        i = 0,
        length = lines.length;
      i < length;
      i++
    ) {
      var currentCssClass = cssClass,
        text = lines[i];
      if (text && text.html) valid++, (html += text.html);
      else if (
        (0 < valid && isOuterFooter
          ? (currentCssClass += " cardText-secondary")
          : 0 === valid &&
            isOuterFooter &&
            (options.sideFooter ||
              (currentCssClass += " cardText-first-padded"),
            (currentCssClass += " cardText-first")),
        text &&
          ((html =
            (html += '<div class="' + currentCssClass + '">') +
            text +
            "</div>"),
          valid++,
          maxLines) &&
          maxLines <= valid)
      )
        break;
    }
    if (forceLines)
      for (
        length = maxLines || Math.min(lines.length, maxLines || lines.length);
        valid < length;

      )
        (currentCssClass = cssClass),
          0 < valid && isOuterFooter
            ? (currentCssClass += " cardText-secondary")
            : 0 === valid &&
              isOuterFooter &&
              (options.sideFooter ||
                (currentCssClass += " cardText-first-padded"),
              (currentCssClass += " cardText-first")),
          (html += '<div class="' + currentCssClass + '">&nbsp;</div>'),
          valid++;
    return html;
  }
  function isUsingLiveTvNaming(itemType) {
    return (
      "Program" === itemType || "Timer" === itemType || "Recording" === itemType
    );
  }
  function getAirTimeText(item, showAirDateTime, showAirEndTime) {
    var airTimeText = "";
    if (item.StartDate)
      try {
        var date = new Date(Date.parse(item.StartDate));
        showAirDateTime &&
          (airTimeText +=
            _datetime.default.toLocaleDateString(date, {
              weekday: "short",
              month: "short",
              day: "numeric",
            }) + " "),
          (airTimeText += _datetime.default.getDisplayTime(date)),
          item.EndDate &&
            showAirEndTime &&
            ((date = new Date(Date.parse(item.EndDate))),
            (airTimeText +=
              " &ndash; " + _datetime.default.getDisplayTime(date)));
      } catch (e) {
        console.log("Error parsing date: " + item.StartDate);
      }
    return airTimeText;
  }
  function getOverviewText(text) {
    var html = '<div class="cardText cardText-secondary cardText-overview">';
    return {
      html: html + _textencoding.default.htmlEncode(text || "") + "</div>",
    };
  }
  function getTextLinksLine(options, item, linkItems, linkItemType, limit) {
    linkItems = linkItems || [];
    for (
      var html = "",
        i = 0,
        length = (limit = Math.min(linkItems.length, limit));
      i < length;
      i++
    ) {
      var linkItem = linkItems[i],
        text = linkItem.Name;
      i < limit - 1 && (text += ","),
        (html += getTextActionButton(
          options,
          linkItem,
          text,
          item.ServerId,
          null,
          !1,
        ));
    }
    return '<div class="cardTextLinksLine">' + html + "</div>";
  }
  function getCardFooterText(
    item,
    itemController,
    options,
    fieldMap,
    imgUrl,
    footerClass,
    progressHtml,
    logoUrl,
    isOuterFooter,
  ) {
    var parentTitleUnderneath,
      itemType = item.Type,
      html = "",
      lines =
        (logoUrl &&
          (html +=
            '<div class="lazy cardFooterLogo" loading="lazy" style="background-image:url(' +
            logoUrl +
            ');"></div>'),
        []);
    switch (itemType) {
      case "MusicAlbum":
      case "Audio":
      case "MusicVideo":
      case "Game":
        parentTitleUnderneath = !0;
    }
    var serverId = item.ServerId || options.serverId,
      parentTitle =
        (fieldMap.Album &&
          options.albumFirst &&
          (isOuterFooter && item.AlbumId && item.Album
            ? lines.push(
                getTextActionButton(options, {
                  Id: item.AlbumId,
                  ServerId: serverId,
                  Name: item.Album,
                  Type: "MusicAlbum",
                  IsFolder: !0,
                }),
              )
            : lines.push(item.Album || "")),
        (!fieldMap.ParentName && !fieldMap.ParentNameOrName) ||
          parentTitleUnderneath ||
          (isOuterFooter && "Episode" === itemType && item.SeriesName
            ? item.SeriesId
              ? lines.push(
                  getTextActionButton(options, {
                    Id: item.SeriesId,
                    ServerId: serverId,
                    Name: item.SeriesName,
                    Type: "Series",
                    IsFolder: !0,
                  }),
                )
              : lines.push(_textencoding.default.htmlEncode(item.SeriesName))
            : isUsingLiveTvNaming(itemType)
            ? (lines.push(_textencoding.default.htmlEncode(item.Name)),
              item.EpisodeTitle || (titleAdded = !0))
            : ((parentTitle =
                item.SeriesName ||
                item.Series ||
                item.Album ||
                (item.AlbumArtist
                  ? item.AlbumArtist.Name || item.AlbumArtist
                  : null) ||
                item.GameSystem ||
                "") ||
                fieldMap.Name) &&
              lines.push(_textencoding.default.htmlEncode(parentTitle))),
        (fieldMap.Name && !titleAdded) ||
          (fieldMap.ParentNameOrName && !lines.length));
    if (
      ((parentTitle =
        parentTitle || titleAdded || !fieldMap.Name ? parentTitle : !0) &&
        (titleAdded = itemController.getDisplayName(item, {
          includeParentInfo: options.includeParentInfoInTitle,
          channelNumberFirst: options.channelNumberFirst,
        })) &&
        (isOuterFooter
          ? lines.push(
              getTextActionButton(
                options,
                item,
                titleAdded,
                serverId,
                options.parentId,
                !0,
              ),
            )
          : lines.push(_textencoding.default.htmlEncode(titleAdded))),
      fieldMap.Type && lines.push(itemController.getItemTypeName(itemType)),
      fieldMap.ParentName &&
        parentTitleUnderneath &&
        (isOuterFooter &&
        item.AlbumArtists &&
        item.AlbumArtists.length &&
        "MusicAlbum" === itemType
          ? ((item.AlbumArtists[0].Type = "MusicArtist"),
            (item.AlbumArtists[0].IsFolder = !0),
            lines.push(
              getTextActionButton(
                options,
                item.AlbumArtists[0],
                null,
                serverId,
              ),
            ))
          : isOuterFooter && item.ArtistItems && item.ArtistItems.length
          ? ((item.ArtistItems[0].Type = "MusicArtist"),
            (item.ArtistItems[0].IsFolder = !0),
            lines.push(
              getTextActionButton(options, item.ArtistItems[0], null, serverId),
            ))
          : isOuterFooter && item.AlbumArtists && item.AlbumArtists.length
          ? ((item.AlbumArtists[0].Type = "MusicArtist"),
            (item.AlbumArtists[0].IsFolder = !0),
            lines.push(
              getTextActionButton(
                options,
                item.AlbumArtists[0],
                null,
                serverId,
              ),
            ))
          : isOuterFooter && item.GameSystem && item.GameSystemId
          ? lines.push(
              getTextActionButton(options, {
                Id: item.GameSystemId,
                ServerId: serverId,
                Name: item.GameSystem,
                Type: "GameSystem",
                IsFolder: !0,
              }),
            )
          : lines.push(
              _textencoding.default.htmlEncode(
                isUsingLiveTvNaming(itemType)
                  ? item.Name
                  : item.SeriesName ||
                      item.Series ||
                      item.Album ||
                      (item.AlbumArtist
                        ? item.AlbumArtist.Name || item.AlbumArtist
                        : null) ||
                      item.GameSystem ||
                      "",
              ),
            )),
      options.textLines)
    )
      for (
        var additionalLines = options.textLines(item),
          i = 0,
          length = additionalLines.length;
        i < length;
        i++
      )
        lines.push(additionalLines[i]);
    fieldMap.Album &&
      !options.albumFirst &&
      (isOuterFooter && item.AlbumId && item.Album
        ? lines.push(
            getTextActionButton(options, {
              Id: item.AlbumId,
              ServerId: serverId,
              Name: item.Album,
              Type: "MusicAlbum",
              IsFolder: !0,
            }),
          )
        : lines.push(item.Album || ""));
    var _lineParts,
      parentTitle = fieldMap.CommunityRating,
      titleAdded = fieldMap.CriticRating,
      emptyLines = [],
      parentTitle =
        ((parentTitle || titleAdded) &&
          ((lineParts = []),
          parentTitle &&
            item.CommunityRating &&
            lineParts.push(
              _mediainfo.default.getCommunityRating(item, {
                outerClass: "cardMediaInfoItem",
              }),
            ),
          titleAdded &&
            item.CriticRating &&
            lineParts.push(
              _mediainfo.default.getCriticRating(item, {
                outerClass: "cardMediaInfoItem",
              }),
            ),
          (lineParts.length
            ? lines
            : (lineParts.push("&nbsp;"), emptyLines)
          ).push(
            '<div class="mediaInfoItems cardMediaInfoItems">' +
              lineParts.join("") +
              "</div>",
          )),
        fieldMap.ProductionYear),
      titleAdded = fieldMap.OfficialRating,
      lineParts = fieldMap.Runtime;
    if (
      ((parentTitle || titleAdded || lineParts) &&
        ((_lineParts = []),
        parentTitle &&
          ("Series" === itemType
            ? "Continuing" === item.Status
              ? item.ProductionYear &&
                _lineParts.push(
                  _globalize.default.translate(
                    "SeriesYearToPresent",
                    item.ProductionYear || "",
                  ),
                )
              : (parentTitle = item.EndDate
                  ? new Date(Date.parse(item.EndDate)).getFullYear()
                  : null) &&
                item.ProductionYear &&
                parentTitle !== item.ProductionYear
              ? _lineParts.push(item.ProductionYear + " &ndash; " + parentTitle)
              : item.ProductionYear && _lineParts.push(item.ProductionYear)
            : item.ProductionYear && _lineParts.push(item.ProductionYear)),
        lineParts &&
          item.RunTimeTicks &&
          _lineParts.push(
            _datetime.default.getHumanReadableRuntime(item.RunTimeTicks),
          ),
        titleAdded &&
          item.OfficialRating &&
          _lineParts.push(item.OfficialRating),
        lines.push(_lineParts.join("&nbsp; "))),
      fieldMap.Genres)
    )
      if (null != (parentTitle = item.GenreItems) && parentTitle.length) {
        switch (itemType) {
          case "Audio":
          case "MusicAlbum":
          case "MusicArtist":
          case "MusicVideo":
            0;
            break;
          case "Game":
          case "GameSystem":
            0;
            break;
          default:
            0;
        }
        lines.push(getTextLinksLine(options, item, item.GenreItems, 0, 2));
      } else
        emptyLines.push(
          '<div class="mediaInfoItems cardMediaInfoItems">&nbsp;</div>',
        );
    return (
      fieldMap.Studios &&
        (null != (lineParts = item.Studios) && lineParts.length
          ? lines.push(getTextLinksLine(options, item, item.Studios, 0, 1))
          : emptyLines.push(
              '<div class="mediaInfoItems cardMediaInfoItems">&nbsp;</div>',
            )),
      fieldMap.Tags &&
        (null != (titleAdded = item.TagItems) && titleAdded.length
          ? lines.push(getTextLinksLine(options, item, item.TagItems, 0, 2))
          : emptyLines.push(
              '<div class="mediaInfoItems cardMediaInfoItems">&nbsp;</div>',
            )),
      fieldMap.AirTime &&
        lines.push(
          getAirTimeText(
            item,
            options.showAirDateTime,
            options.showAirEndTime,
          ) || "",
        ),
      fieldMap.ChannelName &&
        (item.ChannelId
          ? lines.push(
              getTextActionButton(options, {
                Id: item.ChannelId,
                ServerId: serverId,
                Name: item.ChannelName,
                ChannelNumber: item.ChannelNumber,
                Type: "TvChannel",
                MediaType: item.MediaType,
                IsFolder: !1,
              }),
            )
          : lines.push(item.ChannelName || "&nbsp;")),
      fieldMap.CurrentProgramParentName &&
        (item.CurrentProgram
          ? lines.push(item.CurrentProgram.Name || "")
          : lines.push("")),
      fieldMap.CurrentProgramName &&
        (item.CurrentProgram
          ? lines.push(item.CurrentProgram.EpisodeTitle || "")
          : lines.push(item.Name || "")),
      fieldMap.CurrentProgramTime &&
        (item.CurrentProgram
          ? lines.push(getAirTimeText(item.CurrentProgram, !1, !0) || "")
          : lines.push("")),
      fieldMap.SeriesTimerTime &&
        (item.RecordAnyTime
          ? lines.push(_globalize.default.translate("Anytime"))
          : item.StartDate
          ? lines.push(_datetime.default.getDisplayTime(item.StartDate))
          : lines.push("")),
      fieldMap.SeriesTimerChannel &&
        (item.RecordAnyChannel ||
        null == (_lineParts = item.ChannelIds) ||
        !_lineParts.length
          ? lines.push(_globalize.default.translate("AllChannels"))
          : 1 <
            (null == (parentTitle = item.ChannelIds)
              ? void 0
              : parentTitle.length)
          ? lines.push(
              _globalize.default.translate(
                "NumberChannelsValue",
                null == (itemType = item.ChannelIds) ? void 0 : itemType.length,
              ),
            )
          : item.ChannelName
          ? lines.push(
              _itemmanager.default.getDisplayName(
                {
                  Id: item.ChannelId,
                  ServerId: serverId,
                  Name: item.ChannelName,
                  ChannelNumber: item.ChannelNumber,
                  Type: "TvChannel",
                  MediaType: item.MediaType,
                  IsFolder: !1,
                },
                {},
              ),
            )
          : lines.push(_globalize.default.translate("OneChannel"))),
      fieldMap.PersonRole &&
        (item.Role
          ? lines.push(_globalize.default.translate("ActorAsRole", item.Role))
          : item.PersonType
          ? lines.push(_globalize.default.translate(item.PersonType))
          : lines.push("")),
      fieldMap.ChapterTime &&
        lines.push(
          _datetime.default.getDisplayRunningTime(item.StartPositionTicks),
        ),
      fieldMap.LastActivityDateRelative &&
        lines.push(
          itemController.resolveField(item, "LastActivityDateRelative"),
        ),
      fieldMap.AppName &&
        lines.push(itemController.resolveField(item, "AppName")),
      fieldMap.AccessToken &&
        lines.push(itemController.resolveField(item, "AccessToken")),
      fieldMap.DateCreated &&
        lines.push(itemController.resolveField(item, "DateCreated")),
      fieldMap.Url && lines.push(item.Url || ""),
      fieldMap.Version && lines.push(item.Version || ""),
      fieldMap.CollectionType &&
        (item.Id
          ? lines.push(
              _itemmanager.default.getContentTypeName(item.CollectionType),
            )
          : lines.push("")),
      fieldMap.LibraryFolders &&
        (item.Locations && "boxsets" !== item.CollectionType
          ? 1 === item.Locations.length
            ? lines.push(item.Locations[0])
            : lines.push(
                _globalize.default.translate(
                  "NumLocationsValue",
                  item.Locations.length,
                ),
              )
          : lines.push("")),
      fieldMap.AppNameVersion &&
        lines.push(itemController.resolveField(item, "AppNameVersion")),
      fieldMap.InstalledVersion &&
        (item.InstalledVersion
          ? lines.push(
              _globalize.default.translate(
                "LabelVersionInstalled",
                item.InstalledVersion,
              ),
            )
          : lines.push("")),
      fieldMap.InstalledVersion && lines.push(item.Version || ""),
      fieldMap.ItemImageName &&
        (item.ImageTag ? lines.push(item.Name) : lines.push("&nbsp;")),
      fieldMap.Filename && lines.push(item.FileName || item.Filename),
      fieldMap.FilenameOrName &&
        lines.push(
          _textencoding.default.htmlEncode(
            item.FileName || item.Filename || item.Name || "",
          ),
        ),
      fieldMap.MediaInfo &&
        lines.push({
          html:
            '<div class="cardText cardText-secondary mediaInfoItems">' +
            _mediainfo.default.getPrimaryMediaInfoHtml(item, {
              episodeTitle: !1,
              subtitles: !1,
              endsAt: !1,
            }) +
            "</div>",
        }),
      fieldMap.Overview && lines.push(getOverviewText(item.Overview)),
      (fieldMap.Resolution || fieldMap.Container || fieldMap.Bitrate) &&
        ((lineParts = []),
        fieldMap.Container &&
          item.Container &&
          lineParts.push(item.Container.toUpperCase()),
        fieldMap.Resolution &&
          item.Width &&
          item.Height &&
          (titleAdded = _dataformatter.default.getResolutionText(item)) &&
          lineParts.push(titleAdded),
        fieldMap.Bitrate &&
          item.Bitrate &&
          lineParts.push(_dataformatter.default.bitrateToString(item.Bitrate)),
        lines.push(lineParts.join("&nbsp; ") || "&nbsp;")),
      fieldMap.DownloadableImageInfo &&
        (lines.push(
          (function (item) {
            var text = "",
              lang = item.DisplayLanguage || item.Language;
            return (
              item.Width && item.Height
                ? ((text += item.Width + "x" + item.Height),
                  lang && (text += " - " + lang))
                : lang && (text += lang),
              text
            );
          })(item) || "",
        ),
        lines.push(
          (function (item) {
            var text;
            return (
              "Likes" === item.RatingType
                ? (text =
                    1 === item.CommunityRating
                      ? _globalize.default.translate("OneLike")
                      : _globalize.default.translate(
                          "LikeCountValue",
                          item.CommunityRating,
                        ))
                : item.CommunityRating
                ? ((text = _dataformatter.default.numberToString(
                    item.CommunityRating,
                    1,
                  )),
                  item.VoteCount &&
                    (text +=
                      " - " +
                      (1 === item.VoteCount
                        ? _globalize.default.translate("OneVote")
                        : _globalize.default.translate(
                            "VoteCountValue",
                            item.VoteCount,
                          ))))
                : (text = _globalize.default.translate("Unrated")),
              text
            );
          })(item) || "",
        )),
      fieldMap.DateModified &&
        lines.push(itemController.resolveField(item, "DateModified")),
      fieldMap.Size && lines.push(itemController.resolveField(item, "Size")),
      fieldMap.DeviceUserInfo &&
        ((_lineParts = ""),
        item.LastUserName &&
          (item.LastUserId
            ? (_lineParts += getTextActionButton(
                options,
                {
                  Id: item.LastUserId,
                  Name: item.LastUserName,
                  ServerId: serverId,
                  Type: "User",
                },
                item.LastUserName +
                  ", " +
                  _dataformatter.default.formatRelativeTime(
                    item.DateLastActivity,
                  ),
                null,
                null,
              ))
            : item.LastUserName &&
              (_lineParts +=
                item.LastUserName +
                ", " +
                _dataformatter.default.formatRelativeTime(
                  item.DateLastActivity,
                ))),
        lines.push(_lineParts)),
      fieldMap.MediaStreamInfo &&
        _mediainfo.default.pushMediaStreamLines(
          item,
          options,
          lines,
          itemController.getDefaultIcon(item),
        ),
      fieldMap.ImageEditorStandardButtons &&
        lines.push(
          (function (item) {
            var searchText,
              html = "";
            return (
              item.Providers.length &&
                (html +=
                  '<button type="button" is="paper-icon-button-light" class="itemAction" data-action="searchimageproviders" title="' +
                  (searchText = item.ImageTag
                    ? _globalize.default.translate("HeaderSearchNewImage")
                    : _globalize.default.translate("HeaderSearchForAnImage")) +
                  '" aria-label="' +
                  searchText +
                  '"><i class="md-icon autortl">search</i></button>'),
              item.ImageTag ||
                (_servicelocator.appHost.supports("fileinput") &&
                  (html +=
                    '<button type="button" is="paper-icon-button-light" class="itemAction" data-action="addimage" title="' +
                    _globalize.default.translate("HeaderSelectImageFile") +
                    '" aria-label="' +
                    _globalize.default.translate("HeaderSelectImageFile") +
                    '"><i class="md-icon autortl">add_circle_outline</i></button>')),
              item.ImageTag &&
                (html +=
                  '<button type="button" is="paper-icon-button-light" class="itemAction" data-action="delete" title="' +
                  _globalize.default.translate("Delete") +
                  '" aria-label="' +
                  _globalize.default.translate("Delete") +
                  '"><i class="md-icon autortl">delete</i></button>'),
              html
            );
          })(item),
        ),
      fieldMap.ImageEditorBackdropButtons &&
        lines.push(
          (function () {
            var html = "";
            return (html +=
              '<button type="button" is="paper-icon-button-light" class="itemAction" data-action="delete" title="' +
              _globalize.default.translate("Delete") +
              '" aria-label="' +
              _globalize.default.translate("Delete") +
              '"><i class="md-icon autortl">delete</i></button>');
          })(),
        ),
      fieldMap.SessionNowPlayingInfo &&
        (function (lines, item) {
          var playstate = item.PlayState,
            item = item.NowPlayingItem || {};
          lines.push(item.SeriesName || item.Name),
            "Episode" === item.Type
              ? lines.push(
                  _itemmanager.default.getDisplayName(item, {
                    includeParentInfo: !0,
                  }),
                )
              : item.ArtistItems && item.ArtistItems.length
              ? lines.push(item.ArtistItems[0].Name)
              : item.ProductionYear && lines.push(item.ProductionYear),
            item.RunTimeTicks &&
              lines.push(
                _datetime.default.getDisplayRunningTime(
                  playstate.PositionTicks || 0,
                ) +
                  " / " +
                  _datetime.default.getDisplayRunningTime(item.RunTimeTicks),
              );
        })(lines, item),
      fieldMap.LastServerAddress &&
        ("Server" === item.Type
          ? ((parentTitle = _connectionmanager.default.getApiClient(item)),
            lines.push((parentTitle && parentTitle.serverAddress()) || ""))
          : lines.push("")),
      (html += getCardTextLines(
        (lines = lines.concat(emptyLines)),
        options.cardTextCssClass,
        isOuterFooter,
        isOuterFooter,
        options.lines,
        options,
      )),
      progressHtml && (html += progressHtml),
      html &&
        (!isOuterFooter || logoUrl || options.cardLayout) &&
        ((html = '<div class="' + footerClass + '">' + html),
        (html += "</div>")),
      html
    );
  }
  function getTextActionButton(
    options,
    item,
    text,
    serverId,
    parentId,
    isSameItemAsCard,
  ) {
    var dataAttributes;
    return (
      (text = text || _itemmanager.default.getDisplayName(item)),
      _layoutmanager.default.tv || !1 === options.textLinks
        ? _textencoding.default.htmlEncode(text)
        : ((text = _textencoding.default.htmlEncode(text)),
          (item = isSameItemAsCard
            ? ((dataAttributes = ""), options.linkButtonAction || "link")
            : ((dataAttributes = _shortcuts.default.getShortcutAttributesHtml(
                item,
                {
                  serverId: serverId,
                  parentId: parentId,
                  isBoundListItem: options.isBoundListItem && isSameItemAsCard,
                },
              )),
              "link")),
          '<button tabindex="-1" title="' +
            text +
            '" ' +
            dataAttributes +
            ' type="button"' +
            (!options.draggable || isSameItemAsCard
              ? ""
              : ' draggable="true"') +
            ' class="cardMediaInfoItem itemAction textActionButton cardTextActionButton emby-button button-link" data-action="' +
            item +
            '">' +
            text +
            "</button>")
    );
  }
  function getActiveSessionFooterHtml(options, item, apiClient) {
    var html = "";
    return (
      (html +=
        '<div class="cardSideFooter-bottomsections activeSession-bottomsections">') +
      (function (item) {
        var imgClass,
          imageUrl,
          html = "";
        return (
          item.NowPlayingItem &&
            ((html +=
              '<div class="cardSideFooter-bottomsection activeSession-bottomsection activeSession-deviceSection itemAction" data-action="link" ' +
              _shortcuts.default.getShortcutAttributesHtml(
                { Type: "Device", ServerId: item.ServerId, Id: item.DeviceId },
                {},
              ) +
              ">"),
            (imgClass = "secondaryText activeSession-deviceimage"),
            (html = (imageUrl = item.AppIconUrl)
              ? html +
                ('<div class="' +
                  (imgClass =
                    (imgClass += " activeSession-deviceimage-bg") +
                    (" activeSession-deviceimage-bg-" +
                      _imageloader.default.getShapeFromAspect(1)))) +
                '" style="aspect-ratio:1;background-image:url(' +
                imageUrl +
                ');"></div>'
              : (html =
                  html +
                  '<div class="' +
                  imgClass +
                  '"><i class="activeSession-deviceimage-icon md-icon autortl">') +
                _itemmanager.default.getDefaultIcon(item) +
                "</i></div>"),
            (html += "<div>"),
            item.Client &&
              (html =
                (html += "<div>") +
                item.Client +
                " " +
                item.ApplicationVersion +
                "</div>"),
            item.DeviceName &&
              (html =
                (html += '<div class="secondaryText">') +
                _textencoding.default.htmlEncode(item.DeviceName) +
                "</div>"),
            item.RemoteEndPoint &&
              ((html =
                html +
                '<div class="secondaryText flex align-items-center">' +
                item.RemoteEndPoint),
              (imageUrl = (item.Protocol || "").toLowerCase()) &&
                (html += " " + imageUrl),
              imageUrl.includes("https") &&
                (html +=
                  '<i class="md-icon button-icon button-icon-right autortl" style="font-size:inherit;" title="HTTPS">https</i>'),
              (html += "</div>")),
            (html += "</div></div>")),
          html
        );
      })(item) +
      (function (item) {
        for (
          var html = "",
            playstate = item.PlayState || {},
            nowplayingItem = item.NowPlayingItem || {},
            item = item.TranscodingInfo || {},
            transcodeReasons =
              ((html =
                (html =
                  (html =
                    html +
                    '<div class="cardSideFooter-bottomsection activeSession-bottomsection">' +
                    '<div class="secondaryText activeSession-bottomsection-title">') +
                  _globalize.default.translate("Stream")) +
                "</div>" +
                "<div>"),
              nowplayingItem.Container &&
                ((html =
                  (html += "<div>") + nowplayingItem.Container.toUpperCase()),
                nowplayingItem.Bitrate &&
                  (html +=
                    " (" +
                    _dataformatter.default.bitrateToString(
                      nowplayingItem.Bitrate,
                    ) +
                    ")"),
                (html += "</div>")),
              (html =
                html +
                "<div>" +
                '<i class="md-icon activeSessionStreamIcon autortl">&#xe941;</i>'),
              "Transcode" === playstate.PlayMethod
                ? ((nowplayingItem = []),
                  item.SubProtocol && "progressive" !== item.SubProtocol
                    ? nowplayingItem.push(item.SubProtocol.toUpperCase())
                    : item.Container &&
                      nowplayingItem.push(item.Container.toUpperCase()),
                  item.Bitrate &&
                    ((playstate = "("),
                    item.Bitrate &&
                      (playstate += _dataformatter.default.bitrateToString(
                        item.Bitrate,
                      )),
                    item.Framerate &&
                      (playstate +=
                        " " +
                        _dataformatter.default.numberToString(
                          item.Framerate,
                          3,
                        ) +
                        " fps"),
                    nowplayingItem.push((playstate += ")"))),
                  item.CurrentThrottle &&
                    nowplayingItem.push(
                      '<span class="secondaryText">Throttling</span>',
                    ),
                  (html += nowplayingItem.join(" ")))
                : (html += _globalize.default.translate("HeaderDirectPlay")),
              (html += "</div>"),
              item.TranscodeReasons || []),
            i = 0,
            length = transcodeReasons.length;
          i < length;
          i++
        )
          html =
            (html += "<div>") +
            _globalize.default.translate(transcodeReasons[i]) +
            "</div>";
        return (html = html + "</div>" + "</div>");
      })(item) +
      (function (item) {
        for (
          var mediaStream,
            html = "",
            playstate = item.PlayState || {},
            mediaStreams = (item.NowPlayingItem || {}).MediaStreams || [],
            videoStreamIndex = playstate.VideoStreamIndex,
            playstate = item.TranscodingInfo || {},
            i = 0,
            length = mediaStreams.length;
          i < length;
          i++
        )
          if (
            "Video" === mediaStreams[i].Type &&
            (null == videoStreamIndex ||
              videoStreamIndex === mediaStreams[i].Index)
          ) {
            mediaStream = mediaStreams[i];
            break;
          }
        if (mediaStream) {
          if (
            ((html =
              (html =
                (html =
                  html +
                  '<div class="cardSideFooter-bottomsection activeSession-bottomsection">' +
                  '<div class="secondaryText activeSession-bottomsection-title">') +
                _globalize.default.translate("Video")) +
              "</div>" +
              "<div>"),
            mediaStream.DisplayTitle &&
              ((html =
                html +
                '<div class="flex align-items-center flex-wrap-wrap">' +
                mediaStream.DisplayTitle),
              playstate.VideoDecoderHwAccel &&
                (html +=
                  '<i class="md-icon activeSession-hwaccelIcon autortl" title="' +
                  _globalize.default.translate(
                    "HeaderHardwareAcceleratedDecoding",
                  ) +
                  " (" +
                  (playstate.VideoDecoderHwAccel ||
                    _globalize.default.translate("Software")) +
                  ')">&#xe30d;</i>'),
              (html += "</div>")),
            (html =
              html +
              '<div class="flex align-items-center flex-wrap-wrap">' +
              '<i class="md-icon activeSessionStreamIcon autortl">&#xe941;</i>'),
            !1 === playstate.IsVideoDirect
              ? ((html =
                  (html =
                    html + _globalize.default.translate("Transcode") + " (") +
                  (playstate.VideoCodec || "").toUpperCase() +
                  " "),
                playstate.VideoBitrate &&
                  (html += _dataformatter.default.bitrateToString(
                    playstate.VideoBitrate,
                  )),
                (html += ")"),
                playstate.VideoEncoderHwAccel &&
                  (html +=
                    '<i class="md-icon activeSession-hwaccelIcon autortl" title="' +
                    _globalize.default.translate(
                      "HeaderHardwareAcceleratedEncoding",
                    ) +
                    " (" +
                    (playstate.VideoEncoderHwAccel ||
                      _globalize.default.translate("Software")) +
                    ')">&#xe30d;</i>'))
              : ((html += _globalize.default.translate("HeaderDirectPlay")),
                mediaStream.BitRate &&
                  (html +=
                    " (" +
                    _dataformatter.default.bitrateToString(
                      mediaStream.BitRate,
                    ) +
                    ")")),
            (html += "</div>"),
            !1 === playstate.IsVideoDirect)
          )
            for (
              var pipeline = playstate.VideoPipelineInfo || [],
                _i = 0,
                _length = pipeline.length;
              _i < _length;
              _i++
            ) {
              var extra,
                step = pipeline[_i];
              ("ToneMapping" !== step.StepType &&
                "Deinterlace" !== step.StepType &&
                "SubTitleBurnIn" !== step.StepType &&
                "SubtitleOverlay" !== step.StepType) ||
                ((html +=
                  '<div><i class="md-icon activeSessionStreamIcon autortl">&#xe941;</i>'),
                "ToneMapping" === step.StepType
                  ? (html += _globalize.default.translate("HeaderToneMapping"))
                  : "Deinterlace" === step.StepType
                  ? (html += _globalize.default.translate("Deinterlacing"))
                  : ("SubTitleBurnIn" !== step.StepType &&
                      "SubtitleOverlay" !== step.StepType) ||
                    (html += _globalize.default.translate(
                      "HeaderBurningInSubtitles",
                    )),
                (extra = []),
                step.ParamShort
                  ? extra.push(step.ParamShort)
                  : step.Param
                  ? "Subtitles" !== step.Param && extra.push(step.Param)
                  : step.FfmpegOptions && extra.push(step.FfmpegOptions),
                extra.length &&
                  (html +=
                    ' <span class="secondaryText">(' +
                    extra.join(" ") +
                    ")</span>"),
                (html += "</div>"));
            }
          html = html + "</div>" + "</div>";
        }
        return html;
      })(item) +
      (function (item) {
        for (
          var mediaStream,
            html = "",
            playstate = item.PlayState || {},
            mediaStreams = (item.NowPlayingItem || {}).MediaStreams || [],
            audioStreamIndex = playstate.AudioStreamIndex,
            playstate = item.TranscodingInfo || {},
            i = 0,
            length = mediaStreams.length;
          i < length;
          i++
        )
          if (
            "Audio" === mediaStreams[i].Type &&
            (null == audioStreamIndex ||
              audioStreamIndex === mediaStreams[i].Index)
          ) {
            mediaStream = mediaStreams[i];
            break;
          }
        return (
          mediaStream &&
            ((html =
              (html +=
                '<div class="cardSideFooter-bottomsection activeSession-bottomsection"><div class="secondaryText activeSession-bottomsection-title">') +
              _globalize.default.translate("Audio") +
              "</div><div>"),
            (html =
              (mediaStream.DisplayTitle
                ? (html += "<div>") + mediaStream.DisplayTitle + "</div>"
                : html) +
              '<div><i class="md-icon activeSessionStreamIcon autortl">&#xe941;</i>'),
            !1 === playstate.IsAudioDirect
              ? ((html =
                  (html =
                    html + _globalize.default.translate("Transcode") + " (") +
                  (playstate.AudioCodec || "").toUpperCase() +
                  " "),
                playstate.AudioBitrate &&
                  (html += _dataformatter.default.bitrateToString(
                    playstate.AudioBitrate,
                  )),
                (html += ")"))
              : ((html += _globalize.default.translate("HeaderDirectPlay")),
                mediaStream.BitRate &&
                  (html +=
                    " (" +
                    _dataformatter.default.bitrateToString(
                      mediaStream.BitRate,
                    ) +
                    ")")),
            (html += "</div></div></div>")),
          html
        );
      })(item) +
      (function (item, apiClient) {
        var html = "";
        if (item.UserId) {
          html +=
            '<div class="cardSideFooter-bottomsection activeSession-bottomsection activeSession-usersection align-items-center justify-content-center itemAction" data-action="link" ' +
            _shortcuts.default.getShortcutAttributesHtml(
              { Type: "User", ServerId: item.ServerId, Id: item.UserId },
              {},
            ) +
            ">";
          var names = [];
          item.UserId && names.push(item.UserName);
          for (var i = 0, length = item.AdditionalUsers.length; i < length; i++)
            names.push(item.AdditionalUsers[i].UserName);
          apiClient =
            item.UserId && item.UserPrimaryImageTag
              ? apiClient.getUserImageUrl(item.UserId, {
                  tag: item.UserPrimaryImageTag,
                  height: 24,
                  type: "Primary",
                })
              : null;
          apiClient &&
            (html +=
              '<img draggable="false" loading="lazy"' +
              decodingAttribute +
              ' class="activeSessionUserImage" src="' +
              apiClient +
              '" />'),
            (html = html + ("<div>" + names.join(", ") + "</div>") + "</div>");
        }
        return html;
      })(item, apiClient) +
      (function (options, item) {
        var html = "";
        return (
          options.isSingleClickElement ||
            item.DeviceId === _connectionmanager.default.deviceId() ||
            (item.ServerId &&
              item.NowPlayingItem &&
              item.SupportsRemoteControl &&
              (html =
                (html +=
                  '<button is="paper-icon-button-light" class="sessionCardButton btnSessionPlayPause paper-icon-button-light md-icon autortl itemAction" data-action="session_playpause">' +
                  (item.PlayState && item.PlayState.IsPaused
                    ? "&#xE037;"
                    : "&#xE034;") +
                  "</button>") +
                '<button is="paper-icon-button-light" class="sessionCardButton btnSessionStop paper-icon-button-light md-icon autortl itemAction" data-action="session_stop" title="' +
                _globalize.default.translate("Stop") +
                '" aria-label="' +
                _globalize.default.translate("Stop") +
                '">&#xE047;</button>'),
            item.ServerId &&
              item.SupportedCommands.includes("DisplayMessage") &&
              item.DeviceId !== _connectionmanager.default.deviceId() &&
              (html +=
                '<button is="paper-icon-button-light" class="sessionCardButton btnSessionSendMessage paper-icon-button-light md-icon autortl itemAction" data-action="session_sendmessage" title="' +
                _globalize.default.translate("SendMessage") +
                '" aria-label="' +
                _globalize.default.translate("SendMessage") +
                '">&#xE0C9;</button>'),
            html &&
              ((html =
                '<div class="cardSideFooter-bottomsection activeSession-bottomsection activeSession-commandsection align-items-center">' +
                html),
              (html += "</div>"))),
          html
        );
      })(options, item) +
      "</div>"
    );
  }
  function getCardHtml(item, index, options) {
    var itemType = item.Type,
      action = options.action || "link",
      shape =
        ("none" !== action &&
          (item.IsFolder && "play" === action
            ? (action = "link")
            : "Photo" === item.MediaType
            ? (action = "playallfromhere")
            : ("AddServer" !== itemType &&
                "EmbyConnect" !== itemType &&
                "Downloads" !== itemType) ||
              (action = "link")),
        options.shape),
      imageShape = options.imageShape,
      isSingleClickElement = options.isSingleClickElement,
      serverId = item.ServerId || options.serverId,
      serverId = serverId
        ? _connectionmanager.default.getApiClient(serverId)
        : null,
      imageItem = options.showCurrentProgramImage
        ? item.CurrentProgram || item
        : "ActiveSession" === itemType
        ? item.NowPlayingItem
        : item.ProgramInfo || item,
      blurImageOptions =
        (!1 !== options.image && imageItem
          ? ((imgInfo = _imageloader.default.getImageUrl(
              imageItem,
              serverId,
              options,
              imageShape,
            )),
            (blurImageOptions =
              "large" === options.vibrantMode
                ? { width: 12, blur: 2, adjustForPixelRatio: !1 }
                : { width: 1, adjustForPixelRatio: !1 }),
            (vibrantImgInfo = options.vibrant
              ? _imageloader.default.getImageUrl(
                  imageItem,
                  serverId,
                  blurImageOptions,
                  imageShape,
                )
              : null),
            imgInfo.imgUrl ||
              imageItem === item ||
              ((imgInfo = _imageloader.default.getImageUrl(
                (imageItem = item),
                serverId,
                options,
                imageShape,
              )),
              (vibrantImgInfo = options.vibrant
                ? _imageloader.default.getImageUrl(
                    imageItem,
                    serverId,
                    blurImageOptions,
                    imageShape,
                  )
                : null)))
          : (imgInfo = {}),
        imgInfo.imgUrl),
      imageShape = (vibrantImgInfo || imgInfo).imgUrl,
      vibrantImgInfo = imgInfo.forceName && "Photo" !== item.MediaType,
      overlayText = options.overlayText,
      fieldMap = options.fieldMap,
      cardContentClass = options.cardContentClass,
      cardImageClass = "cardImage",
      imageItem =
        !1 === options.coverImage
          ? null
          : _imageloader.default.getCoveredImageClass(
              imageItem,
              imgInfo.aspect,
              options.uiAspect,
              options.coverImage,
            );
    imageItem &&
      ((cardContentClass += imageItem), (cardImageClass += imageItem)),
      options.paddedImage && (cardImageClass += " cardImage-padded"),
      item.Policy &&
        item.Policy.IsDisabled &&
        (cardContentClass += " grayscaleImage"),
      options.defaultBackground ||
        blurImageOptions ||
        options.cardLayout ||
        (cardContentClass += " defaultCardBackground");
    options.round ||
      "MusicArtist" !== itemType ||
      "square" !== shape ||
      (cardContentClass += " cardContent-round");
    var cardImageContainerOpen,
      footerCssClass,
      logoUrl,
      imgInfo = options.cardBoxClass,
      imageItem =
        (options.playQueueIndicator &&
          item.PlaylistItemId &&
          (_playbackmanager.default.currentItem() || {}).PlaylistItemId ===
            item.PlaylistItemId &&
          (imgInfo += " activePlaylistCardBox"),
        !1 === options.progress
          ? null
          : _indicators.default.getProgressBarHtml(item, {
              containerClass: "cardProgressBarContainer",
              animated: !1,
            })),
      shape = "",
      itemController =
        (options.showChannelLogo &&
          item.ChannelPrimaryImageTag &&
          (logoUrl = serverId.getImageUrl(item.ChannelId, {
            type: "Primary",
            height: 40,
            tag: item.ChannelPrimaryImageTag,
          })),
        !1 === options.programIndicators ||
          ("Program" !== itemType &&
            "Timer" !== itemType &&
            "TvChannel" !== itemType) ||
          (imageItem =
            (function (item) {
              var html = "";
              return (
                (item = item.CurrentProgram || item).IsLive
                  ? (html +=
                      '<div class="cardProgramIndicator liveTvProgram">' +
                      _globalize.default.translate("Live") +
                      "</div>")
                  : item.IsPremiere &&
                    (html +=
                      '<div class="cardProgramIndicator premiereTvProgram">' +
                      _globalize.default.translate("Premiere") +
                      "</div>"),
                html
              );
            })(item) + (imageItem || "")),
        _itemmanager.default.getItemController(itemType)),
      vibrantImgInfo =
        (overlayText || vibrantImgInfo
          ? ((footerCssClass = options.innerCardFooterClass),
            (shape += getCardFooterText(
              item,
              itemController,
              options,
              (function (options, fieldMap, overlayText, forceName) {
                return overlayText
                  ? !forceName ||
                    fieldMap.Name ||
                    fieldMap.ParentNameOrName ||
                    fieldMap.ParentName
                    ? fieldMap
                    : options.fieldMapWithForceName
                  : !forceName ||
                    fieldMap.Name ||
                    fieldMap.ParentNameOrName ||
                    fieldMap.ParentName
                  ? {}
                  : { ParentNameOrName: !0 };
              })(options, fieldMap, overlayText, vibrantImgInfo),
              0,
              footerCssClass,
              imageItem,
              (logoUrl = null),
              !1,
            )),
            (imageItem = ""))
          : imageItem &&
            ((shape =
              (shape += '<div class="' + options.innerCardFooterClass + '">') +
              imageItem +
              "</div>"),
            (imageItem = "")),
        ""),
      fieldMap =
        (overlayText ||
          ((footerCssClass = options.cardLayout
            ? options.outerFooterClass
            : "cardFooter cardFooter-transparent"),
          options.sideFooter && (footerCssClass += " cardFooter-side"),
          logoUrl && (footerCssClass += " cardFooter-withlogo"),
          options.vibrant &&
            imageShape &&
            "large" !== options.vibrantMode &&
            (footerCssClass += " darkContentContainer"),
          (vibrantImgInfo = getCardFooterText(
            item,
            itemController,
            options,
            fieldMap,
            0,
            footerCssClass,
            imageItem,
            (logoUrl = options.cardLayout ? logoUrl : null),
            !0,
          )),
          options.sideFooter &&
            ((overlayText = "cardFooterContent"),
            options.centerText || (overlayText += " cardFooterContent-start"),
            (vibrantImgInfo =
              '<div class="' +
              overlayText +
              ' itemAction" data-action="' +
              action +
              '">' +
              vibrantImgInfo +
              "</div>"),
            "ActiveSession" === itemType) &&
            (vibrantImgInfo += getActiveSessionFooterHtml(
              options,
              item,
              serverId,
            ))),
        "");
    return (
      options.sideFooter || (cardContentClass += " " + options.cardPadderClass),
      (fieldMap = isSingleClickElement
        ? ((cardImageContainerOpen = blurImageOptions
            ? 2 === options.lazy
              ? supportsObjectFit
                ? '<div class="' +
                  cardContentClass +
                  '"><img draggable="false" alt=" " class="' +
                  cardImageClass +
                  '"' +
                  options.loadingLazyAttribute +
                  decodingAttribute +
                  ' src="' +
                  blurImageOptions +
                  '" />'
                : '<div class="' +
                  cardContentClass +
                  '" style="background-image:url(' +
                  blurImageOptions +
                  ');">'
              : supportsNativeLazyLoading
              ? '<div class="' +
                cardContentClass +
                '"><img draggable="false" alt=" " class="' +
                cardImageClass +
                '" loading="lazy"' +
                decodingAttribute +
                ' src="' +
                blurImageOptions +
                '" />'
              : '<div class="' +
                cardContentClass +
                ' lazy" style="background-image:url(' +
                blurImageOptions +
                ');">'
            : '<div class="' + cardContentClass + '">'),
          "</div>")
        : "none" === action
        ? ((cardImageContainerOpen = blurImageOptions
            ? 2 === options.lazy
              ? supportsObjectFit
                ? '<div data-action="' +
                  action +
                  '" class="itemAction ' +
                  cardContentClass +
                  '"><img draggable="false" alt=" " class="' +
                  cardImageClass +
                  '"' +
                  options.loadingLazyAttribute +
                  decodingAttribute +
                  ' src="' +
                  blurImageOptions +
                  '" />'
                : '<div data-action="' +
                  action +
                  '" class="itemAction ' +
                  cardContentClass +
                  '" style="background-image:url(' +
                  blurImageOptions +
                  ');">'
              : supportsNativeLazyLoading
              ? '<div data-action="' +
                action +
                '" class="itemAction ' +
                cardContentClass +
                '"><img draggable="false" alt=" " class="' +
                cardImageClass +
                '" loading="lazy"' +
                decodingAttribute +
                ' src="' +
                blurImageOptions +
                '" />'
              : '<div data-action="' +
                action +
                '" class="itemAction lazy ' +
                cardContentClass +
                '" style="background-image:url(' +
                blurImageOptions +
                ');">'
            : '<div data-action="' +
              action +
              '" class="' +
              cardContentClass +
              ' itemAction">'),
          "</div>")
        : ((cardImageContainerOpen = blurImageOptions
            ? 2 === options.lazy
              ? supportsObjectFit
                ? '<button type="button" data-action="' +
                  action +
                  '" tabindex="-1" class="itemAction cardContent-button ' +
                  cardContentClass +
                  '"><img draggable="false" alt=" " class="' +
                  cardImageClass +
                  '"' +
                  options.loadingLazyAttribute +
                  decodingAttribute +
                  ' src="' +
                  blurImageOptions +
                  '" />'
                : '<button type="button" data-action="' +
                  action +
                  '" tabindex="-1" class="itemAction cardContent-button ' +
                  cardContentClass +
                  '" style="background-image:url(' +
                  blurImageOptions +
                  ');">'
              : supportsNativeLazyLoading
              ? '<button type="button" data-action="' +
                action +
                '" tabindex="-1" class="itemAction cardContent-button ' +
                cardContentClass +
                '"><img draggable="false" alt=" " class="' +
                cardImageClass +
                '" loading="lazy"' +
                decodingAttribute +
                ' src="' +
                blurImageOptions +
                '" />'
              : '<button type="button" data-action="' +
                action +
                '" tabindex="-1" class="itemAction cardContent-button lazy ' +
                cardContentClass +
                '" style="background-image:url(' +
                blurImageOptions +
                ');">'
            : '<button type="button" data-action="' +
              action +
              '" tabindex="-1" class="cardContent-button ' +
              cardContentClass +
              ' itemAction">'),
          "</button>")),
      !1 === options.image &&
        !1 === options.imageContainer &&
        (cardImageContainerOpen = fieldMap = ""),
      options.vibrant && imageShape
        ? ("large" === options.vibrantMode &&
            (imgInfo += " darkContentContainer"),
          (cardImageContainerOpen =
            '<div style="background-image:url(' +
            imageShape +
            ');" class="' +
            imgInfo +
            '">' +
            cardImageContainerOpen))
        : options.enableCardBox &&
          (cardImageContainerOpen =
            '<div class="' + imgInfo + '">' + cardImageContainerOpen),
      options.typeIndicator &&
        ("Video" === itemType
          ? (cardImageContainerOpen +=
              '<i class="md-icon autortl cardIndicator cardIndicatorIcon">&#xE04B;</i>')
          : "Folder" === itemType || "PhotoAlbum" === itemType
          ? (cardImageContainerOpen +=
              '<i class="md-icon autortl cardIndicator cardIndicatorIcon">&#xE2C7;</i>')
          : "Photo" === itemType &&
            (cardImageContainerOpen +=
              '<i class="md-icon autortl cardIndicator cardIndicatorIcon">&#xE410;</i>')),
      !1 !== options.missingIndicator &&
        (cardImageContainerOpen += _indicators.default.getMissingIndicator(
          item,
          "cardIndicator cardMissingIndicator",
        )),
      !1 !== options.syncIndicator &&
        (100 === (footerCssClass = item.SyncPercent)
          ? (cardImageContainerOpen +=
              '<i class="cardIndicator md-icon autortl cardSyncIndicator syncIndicator fullSyncIndicator">&#xf090;</i>')
          : null != footerCssClass &&
            (cardImageContainerOpen +=
              '<i class="cardIndicator md-icon autortl cardSyncIndicator syncIndicator emptySyncIndicator">&#xf090;</i>')),
      !1 !== options.playedIndicator &&
        (cardImageContainerOpen += _indicators.default.getPlayedIndicatorHtml(
          item,
          "cardIndicator card",
        )),
      !1 !== options.timerIndicator &&
        (cardImageContainerOpen += _indicators.default.getTimerIndicator(
          item,
          "cardIndicator card",
        )),
      "CollectionFolder" === itemType || item.CollectionType
        ? ((imageItem = item.RefreshProgress ? "" : "hide"),
          options.sideFooter &&
            (imageItem += " cardRefreshIndicator-sideFooter"),
          (cardImageContainerOpen +=
            '<div is="emby-itemrefreshindicator" class="' +
            imageItem.trim() +
            '" data-progress="' +
            (item.RefreshProgress || 0) +
            '"></div>'),
          refreshIndicatorLoaded ||
            ((refreshIndicatorLoaded = !0),
            require(["emby-itemrefreshindicator"])))
        : "User" === itemType &&
          item.ConnectLinkType &&
          (cardImageContainerOpen +=
            '<i class="md-icon cardPlayedIndicator cardIndicator playedIndicator" title="' +
            _globalize.default.translate("LinkedToEmbyConnect") +
            '">cloud</i>'),
      !blurImageOptions &&
        options.imageFallback &&
        (cardImageContainerOpen += (function (item, options) {
          if (null != options.defaultTextContent)
            return (
              '<div class="' +
              options.cardDefaultTextClass +
              '">' +
              options.defaultTextContent +
              "</div>"
            );
          if ("ItemImage" === item.Type)
            return (function (item, options) {
              return (
                '<h2 class="' +
                options.cardDefaultTextClass +
                ' secondaryText">' +
                item.Name +
                "</h2>"
              );
            })(item, options);
          var icon =
            item.Icon ||
            (!1 === options.defaultIcon
              ? null
              : _itemmanager.default.getDefaultIcon(item, options));
          if (icon)
            return options.smallSideFooter
              ? '<i class="cardImageIcon cardImageIcon-sideFooter cardImageIcon-smallSideFooter md-icon autortl">' +
                  icon +
                  "</i>"
              : options.sideFooter
              ? '<i class="cardImageIcon cardImageIcon-sideFooter md-icon autortl">' +
                icon +
                "</i>"
              : '<i class="cardImageIcon cardImageIcon-center md-icon autortl">' +
                icon +
                "</i>";
          icon = isUsingLiveTvNaming(item.Type)
            ? item.Name
            : _itemmanager.default.getDisplayName(item, {
                includeParentInfo: options.includeParentInfoInTitle,
                channelNumberFirst: options.channelNumberFirst,
              });
          return (
            '<div class="' +
            options.cardDefaultTextClass +
            '">' +
            icon +
            "</div>"
          );
        })(item, options)),
      (logoUrl =
        _layoutmanager.default.tv || !1 === options.hoverMenu
          ? ""
          : (function (item, itemController, action, options, menuClass) {
              var html = "",
                hasContent = !1,
                menuClass =
                  ((html +=
                    '<div class="cardOverlayContainer itemAction ' +
                    menuClass +
                    ' cardPadder-margin" data-action="' +
                    action +
                    '">'),
                  "cardOverlayButton cardOverlayButton-hover itemAction"),
                action = item.Type;
              options.multiSelect &&
                ((hasContent = !0),
                (html +=
                  '<label tabindex="-1" title="' +
                  options.multiSelectTitle +
                  '" aria-label="' +
                  options.multiSelectTitle +
                  '" data-action="multiselect" class="chkItemSelectContainer chkCardSelectContainer cardOverlayButton cardOverlayButton-hover itemAction emby-checkbox-label"><input tabindex="-1" class="chkItemSelect chkCardSelect emby-checkbox  emby-checkbox-notext" is="emby-checkbox" type="checkbox" data-classes="true" /><span class="checkboxLabel chkCardSelect-checkboxLabel"></span></label>'));
              !1 !== options.hoverPlayButton &&
                _playbackmanager.default.canPlay(item) &&
                ((hasContent = !0),
                (playButtonAction = item.IsFolder
                  ? "resume"
                  : options.playAction ||
                    ("Photo" === item.MediaType ? "playallfromhere" : "play")),
                (html +=
                  '<button tabindex="-1" type="button" is="paper-icon-button-light" class="paper-icon-button-light ' +
                  menuClass +
                  ' cardOverlayFab-primary md-icon autortl cardOverlayButtonIcon" data-action="' +
                  playButtonAction +
                  '">&#xE037;</button>'));
              options.hoverDownloadButton &&
                ((hasContent = !0),
                (html +=
                  '<button tabindex="-1" type="button" is="paper-icon-button-light" class="paper-icon-button-light ' +
                  menuClass +
                  ' cardOverlayFab-primary" data-action="custom"><i class="md-icon cardOverlayButtonIcon">&#xf090;</i></button>'));
              html += '<div class="cardOverlayButton-br">';
              var playButtonAction = item.UserData || {};
              !1 !== options.playedButton &&
                _itemmanager.default.canMarkPlayed(item) &&
                "CollectionFolder" !== action &&
                ((hasContent = !0),
                (html += _embyPlaystatebutton.default.getHtml(
                  playButtonAction.Played,
                  menuClass,
                  "cardOverlayButtonIcon cardOverlayButtonIcon-hover",
                )));
              !1 !== options.ratingButton &&
                _itemmanager.default.canRate(item) &&
                ((hasContent = !0),
                (html += _embyRatingbutton.default.getHtml(
                  playButtonAction.IsFavorite,
                  menuClass,
                  "cardOverlayButtonIcon cardOverlayButtonIcon-hover",
                )));
              options.contextMenu &&
                itemController.supportsContextMenu(item) &&
                ((hasContent = !0),
                (html +=
                  '<button tabindex="-1" type="button" title="' +
                  options.moreTitle +
                  '" aria-label="' +
                  options.moreTitle +
                  '" is="paper-icon-button-light" class="paper-icon-button-light ' +
                  menuClass +
                  ' md-icon cardOverlayButtonIcon cardOverlayButtonIcon-hover" data-action="menu">&#xE5D3;</button>'));
              options.previewImageButton &&
                supportsTargetBlank &&
                ((hasContent = !0),
                (html +=
                  '<a href="' +
                  item.OriginalImageUrl +
                  '" target="_blank" tabindex="-1" type="button" title="' +
                  _globalize.default.translate("HeaderOpenInNewWindow") +
                  '" aria-label="' +
                  _globalize.default.translate("HeaderOpenInNewWindow") +
                  '" is="emby-linkbutton" class="paper-icon-button-light ' +
                  menuClass +
                  ' md-icon cardOverlayButtonIcon cardOverlayButtonIcon-hover autortl" data-action="openlink">&#xe89e;</a>'));
              return hasContent ? (html += "</div></div>") : "";
            })(item, itemController, action, options, options.cardPadderClass)),
      options.dragReorder &&
        (logoUrl +=
          '<i title="' +
          _globalize.default.translate("DragDropToReorder") +
          '" class="md-icon cardIndicator cardIndicatorIcon cardIndicatorIcon-dragHandle dragHandle">&#xE25D;</i>'),
      options.cardParts
        ? ((overlayText = _shortcuts.default.getShortcutAttributes(
            item,
            options,
          )),
          options.isSingleClickElement &&
            overlayText.push({ name: "data-action", value: action }),
          options.isVirtualList ||
            overlayText.push({ name: "data-index", value: index }),
          options.sideFooter
            ? (fieldMap += shape)
            : (fieldMap = shape + fieldMap),
          (serverId =
            cardImageContainerOpen + fieldMap + logoUrl + vibrantImgInfo),
          options.enableCardBox && (serverId += "</div>"),
          { attributes: overlayText, html: serverId })
        : ((isSingleClickElement = _shortcuts.default.getShortcutAttributesHtml(
            item,
            options,
          )),
          options.isSingleClickElement &&
            (isSingleClickElement += ' data-action="' + action + '"'),
          options.isVirtualList ||
            (isSingleClickElement += ' data-index="' + index + '"'),
          (cardImageClass = options.tagName),
          options.sideFooter
            ? (fieldMap += shape)
            : (fieldMap = shape + fieldMap),
          (cardContentClass = options.fixedAttributes) &&
            (isSingleClickElement += " " + cardContentClass),
          (imageShape =
            "<" +
            cardImageClass +
            isSingleClickElement +
            ' class="' +
            options.className +
            '">' +
            cardImageContainerOpen +
            fieldMap +
            logoUrl +
            vibrantImgInfo),
          options.enableCardBox && (imageShape += "</div>"),
          imageShape + "</" + cardImageClass + ">")
    );
  }
  var supportsTargetBlank = _servicelocator.appHost.supports("targetblank");
  function setUserPreferredSize(element, cardSize) {
    if (supportsCalc && supportsMin && supportsCssVariables) {
      var value = element ? cardSize : _usersettings.default.cardSize();
      switch (value) {
        case "extrasmall":
          value = "3";
          break;
        case "smaller":
          value = "2";
          break;
        case "small":
          value = "1";
          break;
        case "large":
          value = "-1";
          break;
        case "larger":
          value = "-2";
          break;
        case "extralarge":
          value = "-3";
          break;
        case "normal":
          value = "0";
          break;
        default:
          value = element ? "null" : "0";
      }
      try {
        element && "null" === value
          ? element.style.removeProperty("--user-cards-size-adjust")
          : (element || document.documentElement).style.setProperty(
              "--user-cards-size-adjust",
              value,
            );
      } catch (err) {
        console.log("error in setUserPreferredSize: " + err);
      }
    }
  }
  _events.default.on(
    _connectionmanager.default,
    "localusersignedin",
    function () {
      setUserPreferredSize();
    },
  ),
    _events.default.on(
      _usersettings.default,
      "change",
      function (e, name, value) {
        "cardSize" === name && setUserPreferredSize();
      },
    ),
    (_exports.default = {
      setListOptions: setListOptions,
      getItemsHtml: function (items, options) {
        return buildCardsHtmlInternal(
          (items =
            1 === arguments.length ? (options = arguments[0]).items : items),
          options,
        );
      },
      getItemParts: function (item, index, options) {
        return (options.cardParts = !0), getCardHtml(item, index, options);
      },
      buildCards: function (items, options) {
        var itemsContainer = options.itemsContainer;
        if (document.body.contains(itemsContainer)) {
          var parentContainer = options.parentContainer;
          if (parentContainer) {
            if (!items.length)
              return void parentContainer.classList.add("hide");
            parentContainer.classList.remove("hide");
          }
          parentContainer = buildCardsHtmlInternal(items, options);
          (itemsContainer.innerHTML = parentContainer),
            (itemsContainer.items = items),
            options.multiSelect &&
              (itemsContainer.enableMultiSelect
                ? itemsContainer.enableMultiSelect(!0)
                : itemsContainer.setAttribute("data-multiselect", "true")),
            options.contextMenu &&
              (itemsContainer.enableContextMenu
                ? itemsContainer.enableContextMenu(!0)
                : itemsContainer.setAttribute("data-contextmenu", "true")),
            parentContainer &&
              _imageloader.default.lazyChildren(itemsContainer),
            options.autoFocus &&
              _focusmanager.default.autoFocus(itemsContainer);
        }
      },
      virtualChunkSize: 50,
      setListClasses: function (elem, listOptions) {
        var _listOptions$options,
          elem = elem.classList;
        (null != (_listOptions$options = listOptions.options) &&
          _listOptions$options.rows) ||
        (listOptions.virtualScrollLayout || "").includes("horizontal")
          ? elem.remove("vertical-wrap")
          : elem.add("vertical-wrap"),
          elem.remove("vertical-list");
      },
      setUserPreferredSize: setUserPreferredSize,
    });
});
