import { ProgressStatus as n } from "./accelbyte-widgets552.mjs";
const r = class {
};
let l = r;
l.isProgressBroken = (s) => s.status === n.BROKEN;
l.isProgressFinished = (s) => s.status === n.INSTALLED;
l.isProgressInstalling = (s) => s.status === n.INSTALLING;
l.isProgressBeingRepaired = (s) => s.status === n.REPAIRING;
l.isPreparingInstallation = (s) => s.installing && !s.progressShortSummary;
l.isInstalling = (s) => s.installing;
l.isUninstalling = (s) => s.uninstalling;
l.isVerifying = (s) => s.verifying;
l.isPreparing = (s) => s.preparing;
l.isModifyingStorage = (s) => r.isInstalling(s) || r.isUninstalling(s);
l.isIdle = (s) => !r.isModifyingStorage(s) && !r.isVerifying(s);
l.isBackgroundPreparation = (s) => {
  var i;
  return !!((i = s.control) != null && i.isBackgroundPreparation);
};
l.isAutoPaused = (s) => {
  var i;
  return !!((i = s.control) != null && i.isAutoPaused);
};
l.isInstallationCorrupt = (s) => {
  var o;
  const { control: i, progressShortSummary: e, installing: t, uninstalling: a } = s;
  return (!((o = e == null ? void 0 : e.data) != null && o.written) || e.data.written === 0) && !!i && !t && !a;
};
l.controlUnhealthy = (s) => s.control !== null && s.progressShortSummary === null;
l.isInstalledSuccessfully = (s) => !!s.control && !!s.progressShortSummary && !r.isModifyingStorage(s) && r.isProgressFinished(s.progressShortSummary);
l.canRemoveControl = ({ own: s }) => r.isIdle(s) && r.controlUnhealthy(s);
l.canExecute = ({ own: s, children: i }) => s.control !== null && r.isIdle(s) && i.map(r.isIdle).filter((e) => !e).length === 0 && r.isInstalledSuccessfully(s) && i.map(r.isInstalledSuccessfully).filter((e) => !e).length === 0;
l.canInstall = ({ parent: s, own: i, children: e }) => i.control === null && (s ? r.isInstalledSuccessfully(s) : !0) && r.isIdle(i) && (s ? r.isIdle(s) : !0) && e.map(r.isIdle).filter((t) => !t).length === 0;
l.canPauseInstallation = ({ own: s }) => s.progressShortSummary && r.isInstalling(s);
l.canResumeInstallation = ({ own: s, parent: i, children: e }) => s.progressShortSummary && (r.isProgressInstalling(s.progressShortSummary) || r.isProgressBeingRepaired(s.progressShortSummary)) && r.isIdle(s) && (i ? r.isIdle(i) : !0) && e.map(r.isIdle).filter((t) => !t).length === 0;
l.canUpdate = ({ own: s, parent: i, children: e }) => s.progressShortSummary && r.isProgressFinished(s.progressShortSummary) && r.isIdle(s) && (i ? r.isIdle(i) : !0) && e.map(r.isIdle).filter((t) => !t).length === 0;
l.canVerify = ({ own: s, parent: i }) => s.progressShortSummary && (r.isProgressBroken(s.progressShortSummary) || r.isProgressFinished(s.progressShortSummary) || r.isProgressBeingRepaired(s.progressShortSummary)) && r.isIdle(s) && (i ? !r.isModifyingStorage(i) : !0);
l.canRepair = ({ own: s }) => s.progressShortSummary && (r.isProgressBroken(s.progressShortSummary) || r.isProgressBeingRepaired(s.progressShortSummary));
l.canUninstall = ({ own: s, children: i }) => s.control && s.progressShortSummary && r.isIdle(s) && i.map(r.isIdle).filter((e) => !e).length === 0;
l.deducePossibleActions = (s) => {
  const i = [];
  return r.canExecute(s) && i.push("play"), r.canInstall(s) && i.push("install"), r.canUpdate(s) && i.push("update"), r.canRepair(s) && i.push("repair"), r.canPauseInstallation(s) && i.push("pauseInstall"), r.canResumeInstallation(s) && i.push("resumeInstall"), r.canVerify(s) && i.push("verify"), r.canUninstall(s) && i.push("uninstall"), r.canRemoveControl(s) && i.push("removeControl"), i;
};
export {
  l as DownloadControlRule
};
