import { OsSettingsKey as a } from "./accelbyte-widgets148.mjs";
import { DBKeys as s } from "./accelbyte-widgets150.mjs";
import { DesktopChecker as l } from "@accelbyte/sdk";
import { Container as o } from "unstated";
class p extends o {
  constructor(e, t) {
    super(), this.persistDB = e, this.DEFAULT_SETTINGS = {
      installDir: null,
      downloadSpeedLimit: "",
      hideLauncherTray: !1,
      autoUpdateGame: !0,
      showAddressBar: !1,
      enableStartUp: !1,
      closeToTray: !0
    }, this.state = {
      isVisible: !1,
      isChangelogVisible: !1
    }, l.isDesktopApp() && (this.DEFAULT_SETTINGS.installDir = t.get(a.APPDIR), this.setSettings(this.getSettings()));
  }
  toggleVisible() {
    this.setState({
      isVisible: !this.state.isVisible
    });
  }
  toggleChangelogVisible() {
    this.setState({
      isVisible: !this.state.isVisible,
      isChangelogVisible: !this.state.isChangelogVisible
    });
  }
  setSettings(e) {
    this.persistDB.set(s.SETTINGS, e);
    const i = (e.downloadSpeedLimit ? Number(e.downloadSpeedLimit) : 0) * 1024;
    Device.downloadManager.setSpeedLimit(i);
  }
  getSettings() {
    let e = this.persistDB.get(s.SETTINGS);
    return e || (e = this.DEFAULT_SETTINGS), e;
  }
  clear() {
    this.setSettings(this.DEFAULT_SETTINGS);
  }
}
export {
  p as SettingsState
};
