define([
  "exports",
  "./dom.js",
  "./common/globalize.js",
  "./loading/loading.js",
  "./approuter.js",
  "./common/appsettings.js",
  "./common/playback/playbackmanager.js",
  "./emby-apiclient/connectionmanager.js",
  "./common/itemmanager/itemmanager.js",
  "./formhelper.js",
], function (
  _exports,
  _dom,
  _globalize,
  _loading,
  _approuter,
  _appsettings,
  _playbackmanager,
  _connectionmanager,
  _itemmanager,
  _formhelper,
) {
  function showPrompt(options) {
    return Emby.importModule("./modules/prompt/prompt.js").then(
      function (prompt) {
        return prompt(options);
      },
    );
  }
  function showAlertAndResolve(options) {
    return (function (options) {
      return Emby.importModule("./modules/common/dialogs/alert.js").then(
        function (alert) {
          return alert(options);
        },
      );
    })(options).catch(function () {
      return Promise.resolve();
    });
  }
  function showConfirm(options) {
    return Emby.importModule("./modules/common/dialogs/confirm.js").then(
      function (confirm) {
        return confirm(options);
      },
    );
  }
  function downloadItems(items, options) {
    var apiClient = _connectionmanager.default.getApiClient(items[0]);
    if (((options = options || {}), "RemoteSubtitle" === items[0].Type))
      return (function (item, apiClient) {
        return (
          _loading.default.show(),
          apiClient
            .downloadSubtitles(item.ItemId, item.MediaSourceId, item.Id)
            .then(function (result) {
              return (
                _loading.default.hide(),
                showToast(_globalize.default.translate("SubtitlesDownloaded")),
                result
              );
            }, _formhelper.default.handleErrorResponse)
        );
      })(items[0], apiClient);
    for (
      var urls, downloadUrls = [], i = 0, length = items.length;
      i < length;
      i++
    ) {
      var url,
        item = items[i];
      "Log" === item.Type
        ? downloadUrls.push(
            apiClient.getLogDownloadUrl({
              Name: item.Name,
              Sanitize: options.Sanitize,
              SetFilename: !0,
            }),
          )
        : "MediaStream" === item.Type && "Subtitle" === item.StreamType
        ? ((url =
            "Videos/" +
            item.ItemId +
            "/" +
            item.MediaSourceId +
            "/Subtitles/" +
            item.Index +
            "/Stream." +
            item.Codec),
          downloadUrls.push(apiClient.getUrl(url, { SetFilename: !0 })))
        : ((url = options.mediaSourceId),
          (item = apiClient.getItemDownloadUrl(item.Id, url)),
          downloadUrls.push(item));
    }
    return (
      (urls = downloadUrls),
      require(["multi-download"]).then(function (responses) {
        (0, responses[0])(urls);
      })
    );
  }
  function removeFromResume(items) {
    var item = items[0],
      confirmHeader =
        "Audio" === item.MediaType
          ? _globalize.default.translate("HeaderRemoveFromContinueListening")
          : _globalize.default.translate("HeaderRemoveFromContinueWatching"),
      apiClient = _connectionmanager.default.getApiClient(item);
    return showConfirm({
      title: confirmHeader,
      text:
        "Audio" === item.MediaType
          ? _globalize.default.translate("RemoveThisTitleFromContinueListening")
          : _globalize.default.translate("RemoveThisTitleFromContinueWatching"),
      confirmText: _globalize.default.translate("Remove"),
      primary: "cancel",
    }).then(function () {
      return apiClient.updateHideFromResume(items.map(mapToId), !0);
    });
  }
  function mapToId(i) {
    return i.Id;
  }
  function markFavorite(items, isFavorite) {
    var apiClient = _connectionmanager.default.getApiClient(items[0]);
    return apiClient.updateFavoriteStatus(
      apiClient.getCurrentUserId(),
      items.map(mapToId),
      isFavorite,
    );
  }
  function afterWakeAttempt() {
    var timeMs,
      apiClient = this;
    return (
      (timeMs = 12e3),
      new Promise(function (resolve, reject) {
        setTimeout(resolve, timeMs);
      }).then(function () {
        return apiClient.getPublicSystemInfo();
      })
    );
  }
  function wakeServer(apiClient) {
    return require(["loadingDialog"]).then(function (responses) {
      var responses = new responses[0]({
          title: _globalize.default.translate("HeaderWakeServer"),
          text: _globalize.default.translate("AttemptingWakeServer"),
        }),
        showDialogPromise = responses.show(),
        responses = { dlg: responses, showDialogPromise: showDialogPromise },
        showDialogPromise = afterWakeAttempt.bind(apiClient);
      return apiClient
        .wakeOnLan()
        .then(showDialogPromise, showDialogPromise)
        .then(
          function () {
            var promise = this.showDialogPromise.then(function () {
                return showAlertAndResolve({
                  text: _globalize.default.translate("WakeServerSuccess"),
                  title: _globalize.default.translate("HeaderWakeServer"),
                });
              }),
              dlg = this.dlg;
            return dlg.hide(), dlg.destroy(), promise;
          }.bind(responses),
          function () {
            var promise = this.showDialogPromise.then(function () {
                return showAlertAndResolve({
                  text: _globalize.default.translate("WakeServerError"),
                  title: _globalize.default.translate("HeaderWakeServer"),
                });
              }),
              dlg = this.dlg;
            return dlg.hide(), dlg.destroy(), promise;
          }.bind(responses),
        );
    });
  }
  function playAllFromHere(itemElement, serverId, queue) {
    var fetchAll,
      itemsContainer = itemElement.closest(".itemsContainer"),
      startIndex = itemsContainer.indexOfElement(itemElement);
    if (itemsContainer && itemsContainer.fetchData)
      return (
        (limit = 1e3),
        queue || (limit += startIndex || 0),
        (limit = (fetchAll = !queue && startIndex < limit)
          ? { Limit: limit }
          : { StartIndex: startIndex, Limit: limit }),
        itemsContainer.fetchData(limit).then(function (result) {
          return queue
            ? _playbackmanager.default.queue({ items: result.Items || result })
            : _playbackmanager.default.play({
                items: result.Items || result,
                startIndex: fetchAll ? startIndex : null,
              });
        })
      );
    for (
      var itemsContainer = itemElement.parentNode,
        limit = itemElement.classList.length
          ? "." + itemElement.classList[0]
          : "",
        cards = itemsContainer.querySelectorAll(limit + "[data-id]"),
        ids = [],
        foundCard = !1,
        i = 0,
        length = cards.length;
      i < length;
      i++
    )
      cards[i] === itemElement && ((foundCard = !0), (startIndex = i)),
        (!foundCard && queue) || ids.push(cards[i].getAttribute("data-id"));
    return ids.length
      ? queue
        ? _playbackmanager.default.queue({ ids: ids, serverId: serverId })
        : _playbackmanager.default.play({
            ids: ids,
            serverId: serverId,
            startIndex: startIndex,
          })
      : void 0;
  }
  function showToast(options) {
    Emby.importModule("./modules/toast/toast.js").then(function (toast) {
      return toast(options);
    });
  }
  function notifyAddedToPlayQueue() {
    return (
      showToast({
        text: _globalize.default.translate("HeaderAddedToPlayQueue"),
        icon: "&#xe03b;",
      }),
      Promise.resolve()
    );
  }
  function notifyPlayingNext() {
    return (
      showToast({
        text: _globalize.default.translate("HeaderPlayingNext"),
        icon: "&#xe03b;",
      }),
      Promise.resolve()
    );
  }
  function play(items, resume, queue, queueNext) {
    var method = queue ? (queueNext ? "queueNext" : "queue") : "play",
      item = items[0],
      resume = {
        startPositionTicks: !1 === resume ? 0 : item.StartPositionTicks,
      },
      item =
        (null != item.ChapterIndex
          ? ((resume.ids = [item.Id]), (resume.serverId = item.ServerId))
          : ((resume.items = items), (resume.autoplay = 1 < items.length)),
        _playbackmanager.default[method](resume));
    return (
      queueNext
        ? (item = item.then(notifyPlayingNext))
        : queue && (item = item.then(notifyAddedToPlayQueue)),
      item
    );
  }
  function showItem(item, options) {
    var itemsContainer;
    return (
      options &&
        !options.parentId &&
        (options.itemElement || options.positionTo) &&
        (itemsContainer = (options.itemElement || options.positionTo).closest(
          ".itemsContainer",
        )) &&
        (options.parentId =
          itemsContainer.getAttribute("data-parentid") || null),
      _approuter.default.showItem(item, options)
    );
  }
  function moveImage(item, options, newIndex) {
    return _connectionmanager.default
      .getApiClient(item)
      .updateItemImageIndex(item.Id, item.ImageType, item.ImageIndex, newIndex)
      .catch(_formhelper.default.handleErrorResponse);
  }
  function moveChannel(item, options, newIndex) {
    return _connectionmanager.default
      .getApiClient(item)
      .setChannelSortIndex(item, newIndex);
  }
  function record(item, options) {
    return "TvChannel" === item.Type
      ? (function (item, options) {
          return require(["channelRecordingCreator"]).then(
            function (responses) {
              return responses[0].createRecordingForChannel(item, options);
            },
          );
        })(item, options)
      : (function (item) {
          var type = item.Type,
            id = item.Id,
            serverId = item.ServerId,
            timerId = "Timer" === type ? item.Id : item.TimerId,
            seriesTimerId = item.SeriesTimerId,
            programId = "Program" === type ? id : item.ProgramId,
            status = item.Status;
          return programId || timerId || seriesTimerId
            ? require(["recordingHelper"]).then(function (responses) {
                return responses[0].toggleRecording(
                  serverId,
                  "Program" === type ? id : null,
                  timerId,
                  status,
                  seriesTimerId,
                );
              })
            : Promise.resolve();
        })(item);
  }
  function editSubtitles(item, options) {
    return require(["subtitleEditor"]).then(function (responses) {
      return responses[0].show({
        item: item,
        mediaSource: (function (mediaSources, mediaSourceId) {
          for (var i = 0, length = mediaSources.length; i < length; i++)
            if (mediaSources[i].Id === mediaSourceId) return mediaSources[i];
          return mediaSources[0];
        })(item.MediaSources, options.mediaSourceId),
      });
    });
  }
  function shareItems(items) {
    var title,
      items = items[0],
      shareTitle = _itemmanager.default.getDisplayName(items),
      shareText = shareTitle,
      apiClient =
        (items.Overview && (shareText += " - " + items.Overview),
        _connectionmanager.default.getApiClient(items));
    if ("Photo" === items.Type) {
      var shareUrl = apiClient.getImageUrl(items.Id, {
        type: "Primary",
        tag: null == (items = items.ImageTags) ? void 0 : items.Primary,
        format: "png",
      });
      if ("android" !== globalThis.appMode && "ios" !== globalThis.appMode)
        return (
          (title = shareTitle),
          fetch(shareUrl, { credentials: "same-origin" })
            .then(function (r) {
              return r.blob();
            })
            .then(function (blob) {
              blob = new File([blob], "image.png", { type: "image/png" });
              return navigator.share({ files: [blob], title: title });
            })
        );
    } else {
      items =
        null == (items = apiClient.serverInfo()) ? void 0 : items.RemoteAddress;
      shareUrl = apiClient.getUrl("share", {}, items).replace("/share", "");
    }
    return navigator.share({
      title: shareTitle,
      text: shareText,
      url: shareUrl,
    });
  }
  function getLyricsTrackEventHtml(item, index) {
    var html = '<div style="margin:.5em 0;">';
    return html + item.Text + "</div>";
  }
  function showLyrics(item) {
    var apiClient = _connectionmanager.default.getApiClient(item);
    return apiClient
      .getItem(apiClient.getCurrentUserId(), item.Id)
      .then(function (item) {
        var mediaSource = item.MediaSources[0],
          stream = (function (item, mediaSource) {
            return (
              mediaSource.MediaStreams.filter(function (s) {
                return (
                  "Subtitle" === s.Type &&
                  s.Index === item.DefaultSubtitleStreamIndex
                );
              })[0] ||
              mediaSource.MediaStreams.filter(function (s) {
                return "Subtitle" === s.Type;
              })[0]
            );
          })(item, mediaSource);
        return apiClient
          .getJSON(
            apiClient.getUrl(
              "Items/" +
                item.Id +
                "/" +
                mediaSource.Id +
                "/Subtitles/" +
                stream.Index +
                "/Stream.js",
            ),
          )
          .then(function (result) {
            return showAlertAndResolve({
              html: result.TrackEvents.map(getLyricsTrackEventHtml).join(""),
              confirmButton: !1,
              title: _itemmanager.default.getDisplayName(item),
              centerText: !1,
              confirmText: _globalize.default.translate("Close"),
              item: item,
            });
          });
      });
  }
  Object.defineProperty(_exports, "__esModule", { value: !0 }),
    (_exports.default = void 0),
    (_exports.default = {
      executeCommand: function (command, items, options) {
        var apiClient,
          virtualFolder,
          button,
          item = items[0];
        if ("open" === command || "link" === command) {
          if ("photo" !== item.MediaType) return showItem(item, options);
          command = "play";
        }
        if ("download" === command) return downloadItems(items, options);
        if ("identify" === command)
          return (function (item) {
            return require(["itemIdentifier"]).then(function (responses) {
              return responses[0].show(item);
            });
          })(item);
        if ("resetmetadata" === command)
          return (function (items) {
            return require(["itemIdentifier"]).then(function (responses) {
              return responses[0].resetMetadata(items);
            });
          })(items);
        if ("preview" === command)
          return (function (item) {
            var apiClient = _connectionmanager.default.getApiClient(item),
              url =
                "RemoteSubtitle" === item.Type
                  ? apiClient.getUrl("Providers/Subtitles/Subtitles/" + item.Id)
                  : apiClient.getUrl(
                      "Videos/" +
                        item.ItemId +
                        "/" +
                        item.MediaSourceId +
                        "/Subtitles/" +
                        item.Index +
                        "/Stream." +
                        item.Codec,
                    );
            return apiClient.getText(url).then(function (result) {
              return showAlertAndResolve({
                preFormattedText: _dom.default.stripScripts(result),
                confirmButton: !1,
                title: _globalize.default.translate("Subtitles"),
                item: item,
              });
            });
          })(item);
        if ("removefromresume" === command) return removeFromResume(items);
        if ("removefromnextup" === command) return removeFromResume(items);
        if ("playtrailer" === command)
          return (function (item) {
            var apiClient = _connectionmanager.default.getApiClient(item);
            return apiClient
              .getLocalTrailers(apiClient.getCurrentUserId(), item.Id)
              .then(function (trailers) {
                _playbackmanager.default.play({ items: trailers });
              });
          })(item);
        if ("connecttoserver" === command)
          return (function (item) {
            return "AddServer" === item.Type || "Downloads" === item.Type
              ? _approuter.default.showItem(item)
              : "EmbyConnect" === item.Type
              ? _approuter.default.showConnectLogin()
              : (_loading.default.show(),
                (item =
                  _connectionmanager.default.getServerInfo(item.Id) || item),
                _connectionmanager.default
                  .connectToServer(item, {
                    enableAutoLogin: _appsettings.default.enableAutoLogin(),
                  })
                  .then(function (result) {
                    return _approuter.default.handleConnectionResult(result);
                  }));
          })(item);
        if ("setplaylistindex" === command)
          return _playbackmanager.default.setCurrentPlaylistItem(
            item.PlaylistItemId,
          );
        if ("multiselect" === command)
          return (function (options) {
            return (
              options.positionTo
                .closest(".itemsContainer")
                .showMultiSelect(options.positionTo, !0),
              Promise.resolve()
            );
          })(options);
        if ("wakeserver" === command)
          return wakeServer(_connectionmanager.default.getApiClient(item));
        switch (command) {
          case "delete":
          case "canceltimer":
          case "cancelseriestimer":
            return _itemmanager.default.deleteItems({
              items: items,
              navigate: options.navigateOnDelete || !1,
              positionTo: options.positionTo,
            });
          case "edit":
            return (function (items, options) {
              var item = items[0];
              return "Device" === item.Type ||
                "User" === item.Type ||
                "ActiveSession" === item.Type ||
                "SeriesTimer" === item.Type ||
                "Timer" === item.Type ||
                "LiveTVTunerDevice" === item.Type ||
                "LiveTVGuideSource" === item.Type
                ? showItem(item, options)
                : _itemmanager.default.editItems(items, options);
            })(items, options);
          case "editimages":
            return (function (item) {
              return require(["imageEditor"]).then(function (responses) {
                return responses[0].show({
                  itemId: item.Id,
                  serverId: item.ServerId,
                });
              });
            })(item);
          case "instantmix":
            return _playbackmanager.default.instantMix(item);
          case "shuffle":
            return _playbackmanager.default.shuffle(item);
          case "playallfromhere":
            return playAllFromHere(options.itemElement, item.ServerId);
          case "queueallfromhere":
            return playAllFromHere(options.itemElement, item.ServerId, !0);
          case "play":
            return play(items, !0);
          case "playfrombeginning":
            return play(items, !1);
          case "resume":
          case "playpause":
            return play(items, !0);
          case "queue":
            return play(items, !1, !0);
          case "queuenext":
            return play(items, !1, !0, !0);
          case "artist":
            return (
              _approuter.default.showItem(
                item.ArtistItems[0].Id,
                item.ServerId,
              ),
              Promise.resolve()
            );
          case "album":
            return (
              _approuter.default.showItem(item.AlbumId, item.ServerId),
              Promise.resolve()
            );
          case "series":
            return (
              _approuter.default.showItem(item.SeriesId, item.ServerId),
              Promise.resolve()
            );
          case "season":
            return (
              _approuter.default.showItem(item.SeasonId, item.ServerId),
              Promise.resolve()
            );
          case "overview":
            return showAlertAndResolve(
              _dom.default.stripScripts(item.Overview || ""),
            );
          case "programlink":
            var program = item.CurrentProgram || item;
            return (
              program.ServerId || (program.ServerId = item.ServerId),
              showItem(program, options)
            );
          case "addtoplaylist":
            return _itemmanager.default.addToPlaylist(items, options);
          case "addtocollection":
            return _itemmanager.default.addToCollection(items, options);
          case "markplayed":
            return (function (items) {
              var apiClient = _connectionmanager.default.getApiClient(items[0]);
              return apiClient.markPlayed(
                apiClient.getCurrentUserId(),
                items.map(mapToId),
              );
            })(items);
          case "markunplayed":
            return (function (items) {
              var apiClient = _connectionmanager.default.getApiClient(items[0]);
              return apiClient.markUnplayed(
                apiClient.getCurrentUserId(),
                items.map(mapToId),
              );
            })(items);
          case "favorite":
            return markFavorite(items, !0);
          case "unfavorite":
            return markFavorite(items, !1);
          case "searchimageproviders":
            return (function (item) {
              return require(["imageDownloader"]).then(function (responses) {
                return new responses[0]().show({
                  item: item.OwnerItem,
                  imageType: item.ImageType,
                });
              });
            })(item);
          case "addimage":
            return (function (item) {
              return require(["imageUploader"]).then(function (responses) {
                return responses[0].show({
                  imageType: item.ImageType,
                  item: item.OwnerItem,
                });
              });
            })(item);
          case "moveimageleft":
            return moveImage(item, 0, item.ImageIndex - 1);
          case "moveimageright":
            return moveImage(item, 0, item.ImageIndex + 1);
          case "addimagefromurl":
            return (function (item) {
              return showPrompt({
                title: _globalize.default.translate(
                  item.ImageTag
                    ? "HeaderSetImageFromUrl"
                    : "HeaderAddImageFromUrl",
                ),
                label: _globalize.default.translate("LabelUrl"),
              }).then(function (url) {
                return _connectionmanager.default
                  .getApiClient(item)
                  .updateItemImageFromUrl(
                    item.Id,
                    item.ImageType,
                    item.ImageIndex,
                    url,
                  )
                  .catch(_formhelper.default.handleErrorResponse);
              });
            })(item);
          case "togglechanneldisabled":
            return (function (item, options) {
              var apiClient;
              return options.eventType && "change" === options.eventType
                ? ((options = options.eventTarget.checked),
                  (apiClient = _connectionmanager.default.getApiClient(item)),
                  _loading.default.show(),
                  apiClient
                    .setChannelDisabled(item, !options)
                    .then(function (updatedChannel) {
                      _loading.default.hide();
                    }))
                : Promise.resolve();
            })(item, options);
          case "toggleitemselected":
            return (function (item, options) {
              var checked;
              return (
                options.eventType &&
                  "change" === options.eventType &&
                  ((checked = options.eventTarget.checked),
                  (item.Selected = checked),
                  (checked = options.itemElement)) &&
                  (options = checked.closest(".itemsContainer")) &&
                  -1 !== (checked = options.indexOfElement(checked)) &&
                  options.onItemUpdated(checked, item),
                Promise.resolve()
              );
            })(item, options);
          case "togglecheckbox":
            return (function (options) {
              return (
                ((options =
                  options.itemElement.querySelector(
                    ".chkItemCheckbox",
                  )).checked = !options.checked),
                options.dispatchEvent(
                  new CustomEvent("change", { cancelable: !0, bubbles: !0 }),
                ),
                Promise.resolve()
              );
            })(options);
          case "movechannelup":
            return moveChannel(item, 0, item.SortIndexNumber - 1);
          case "movechanneldown":
            return moveChannel(item, 0, item.SortIndexNumber + 1);
          case "copytoclipboard":
            return (function (item) {
              return navigator.clipboard.writeText(item.AccessToken);
            })(item);
          case "share":
            return shareItems(items);
          case "seektoposition":
            return (function (item) {
              return "LyricsLine" === item.Type &&
                null == item.StartPositionTicks
                ? Promise.resolve()
                : _playbackmanager.default.seek(item.StartPositionTicks || 0);
            })(item);
          case "sync":
            return (function (items) {
              return require(["syncDialog"]).then(function (responses) {
                return responses[0].showMenu({ items: items, mode: "sync" });
              });
            })(items);
          case "synclocal":
            return (function (items) {
              return require(["syncDialog"]).then(function (responses) {
                return responses[0].showMenu({
                  items: items,
                  mode: "download",
                });
              });
            })(items);
          case "convert":
            return (function (items) {
              return require(["syncDialog"]).then(function (responses) {
                return responses[0].showMenu({ items: items, mode: "convert" });
              });
            })(items);
          case "editsubtitles":
            return editSubtitles(item, options);
          case "changelibrarycontenttype":
            return (
              _connectionmanager.default.getApiClient(item),
              options.positionTo,
              showAlertAndResolve({
                title: _globalize.default.translate("HeaderChangeFolderType"),
                text: _globalize.default.translate(
                  "HeaderChangeFolderTypeHelp",
                ),
              })
            );
          case "renamelibrary":
            return (
              (apiClient = _connectionmanager.default.getApiClient(item)),
              (virtualFolder = item),
              (button = options.positionTo),
              showPrompt({
                label: _globalize.default.translate("LabelNewName"),
                confirmText: _globalize.default.translate("ButtonRename"),
                value: virtualFolder.Name,
              }).then(function (newName) {
                var refreshAfterChange;
                if (newName && newName !== virtualFolder.Name)
                  return (
                    (refreshAfterChange =
                      "true" ===
                      button
                        .closest(".page")
                        .getAttribute("data-refreshlibrary")),
                    apiClient.renameVirtualFolder(
                      virtualFolder,
                      newName,
                      refreshAfterChange,
                    )
                  );
              })
            );
          case "refresh":
            return _itemmanager.default.refreshMetadata(items, options);
          case "scan":
            return _itemmanager.default.scanLibraryFiles(items, options);
          case "removefromplayqueue":
            return _itemmanager.default.removeFromPlayQueue(items, options);
          case "removefromplaylist":
            return _connectionmanager.default
              .getApiClient(item)
              .removeItemsFromPlaylist(item.PlaylistId, items);
          case "removefromcollection":
            return _connectionmanager.default
              .getApiClient(item)
              .removeItemsFromCollection(item.CollectionId, items);
          case "session_stop":
            return _connectionmanager.default
              .getApiClient(item)
              .sendPlayStateCommand(item.Id, "Stop");
          case "session_playpause":
            return _connectionmanager.default
              .getApiClient(item)
              .sendPlayStateCommand(item.Id, "PlayPause");
          case "session_sendmessage":
            return (function (item) {
              return showPrompt({
                title: _globalize.default.translate("HeaderSendMessage"),
                label: _globalize.default.translate("LabelMessageText"),
                confirmText: _globalize.default.translate("ButtonSend"),
              }).then(function (text) {
                return text
                  ? _connectionmanager.default
                      .getApiClient(item)
                      .sendMessageCommand(item.Id, {
                        Text: text,
                        TimeoutMs: 5e3,
                      })
                  : Promise.reject();
              });
            })(item);
          case "session_shownowplayingitem":
            return item.NowPlayingItem
              ? showItem(item.NowPlayingItem, options)
              : Promise.reject();
          case "serverinfo":
            return (function (item) {
              var apiClient = _connectionmanager.default.getApiClient(item),
                html = "";
              return (
                (html += '<div style="overflow-x:hidden;">'),
                apiClient.serverVersion() &&
                  (html =
                    (html +=
                      '<h4 style="margin:0;" class="secondaryText">' +
                      _globalize.default.translate("Version") +
                      "</h4>") +
                    "<div>" +
                    apiClient.serverVersion() +
                    "</div>"),
                item.LastConnectionMode
                  ? (html +=
                      '<h4 style="margin-bottom:0;" class="secondaryText">' +
                      _globalize.default.translate("HeaderLastConnectedTo") +
                      "</h4>")
                  : (html +=
                      '<h4 style="margin-bottom:0;" class="secondaryText">' +
                      _globalize.default.translate("HeaderServerAddress") +
                      "</h4>"),
                (html += "<div>" + apiClient.serverAddress() + "</div>"),
                item.RemoteAddress &&
                  (html =
                    (html +=
                      '<h4 style="margin-bottom:0;" class="secondaryText">' +
                      _globalize.default.translate("RemoteWAN") +
                      "</h4>") +
                    "<div>" +
                    item.RemoteAddress +
                    "</div>"),
                showAlertAndResolve({
                  title: item.Name,
                  html: (html += "</div>"),
                  centerText: !1,
                })
              );
            })(item);
          case "record":
            return record(item, options);
          case "lyrics":
            return showLyrics(item);
          case "manageaccess":
            return (function (item) {
              return require(["ItemAccessDialog"]).then(function (responses) {
                return new responses[0]().show({ item: item });
              });
            })(item);
          case "makepublic":
            return (function (item) {
              return showConfirm({
                title: _globalize.default.translate("HeaderMakePublic"),
                text: _globalize.default.translate("MakePublicConfirmation"),
                confirmText: _globalize.default.translate("HeaderMakePublic"),
                primary: "cancel",
              }).then(function () {
                return _connectionmanager.default
                  .getApiClient(item)
                  .makePublic(item.Id)
                  .then(function (result) {
                    return (
                      showToast(_globalize.default.translate("MakingPublic")),
                      Promise.resolve(result)
                    );
                  });
              });
            })(item);
          case "makeprivate":
            return (function (item) {
              return showConfirm({
                title: _globalize.default.translate("HeaderMakePrivate"),
                text: _globalize.default.translate("MakePrivateConfirmation"),
                confirmText: _globalize.default.translate("HeaderMakePrivate"),
                primary: "cancel",
              }).then(function () {
                return _connectionmanager.default
                  .getApiClient(item)
                  .makePrivate(item.Id)
                  .then(function (result) {
                    return (
                      showToast(_globalize.default.translate("MakingPrivate")),
                      Promise.resolve(result)
                    );
                  });
              });
            })(item);
          case "none":
            return Promise.resolve();
          case "mergeversions":
            return _itemmanager.default.groupVersions(items, options);
          default:
            return _itemmanager.default.executeCommand(command, items, options);
        }
      },
    });
});
