import { AppName as s, ConfigKeys as c, OverrideCSS as l } from "./accelbyte-widgets78.mjs";
import { mockLauncherDownloadLink as m } from "./accelbyte-widgets209.mjs";
import { Ctx as o } from "./accelbyte-widgets33.mjs";
import p from "classnames";
import * as r from "react";
import "./accelbyte-widgets615.mjs";
import { FetchConfigsUtils as h } from "./accelbyte-widgets241.mjs";
import { LauncherLink as u } from "./accelbyte-widgets616.mjs";
class w extends r.Component {
  constructor(n) {
    super(n), this.fetchLauncherLink = async () => {
      var t;
      const e = await h.fetchConfigs({
        sdk: o.getAppState().sdk,
        appName: s.LAUNCHER
      });
      if (!e)
        return;
      const a = await u.getLauncherDownloadLink((t = e[c.LAUNCHER_UPDATE_URL_CONFIG]) == null ? void 0 : t.data.value);
      this.setState({ launcherLink: a });
    }, this.state = {
      launcherLink: ""
    };
  }
  componentDidMount() {
    this.fetchLauncherLink();
  }
  render() {
    const { children: n, className: e } = this.props, t = location.pathname.includes("/player-portal") ? m : this.state.launcherLink || o.getAppState().getLauncherDownloadLink();
    return /* @__PURE__ */ r.createElement(
      "a",
      {
        className: p(
          e,
          "btn small btn-primary",
          "launcherDownloadButton",
          !t && "disabled",
          l.TITLE_FONT
        ),
        title: t || "Not available",
        target: "_blank",
        rel: "noreferrer",
        href: t || "",
        onClick: (i) => {
          t || i.preventDefault();
        }
      },
      n
    );
  }
}
export {
  w as LauncherDownloadButton
};
