import { M as o, a as i, H as c, N as n, U as p, Q as r, L as g, R as h, i as R } from "./index-162fd1aa.mjs";
import a, { Component as d } from "react";
import { s as U } from "./URLGenerator.module-fa874451.mjs";
import "./dateFns-2367ee5b.mjs";
import "./validator-61879ab7.mjs";
import "./reactPlayer-2f69f369.mjs";
import "react-router-dom";
import "./reactSlick-cb4a2d39.mjs";
class N extends d {
  constructor(t) {
    super(t), this.randString = o(), this.state = { error: null }, this.randString = o(), this.appState = i.getAppState();
  }
  componentDidMount() {
    this.tryRegister();
  }
  async tryRegister() {
    try {
      if (c.isDesktopApp()) {
        const t = this.appState;
        if (t.getUser() !== null)
          return t.state.appHistory.replace(n.Home.link);
        const e = p.silentSearchParamsBuilder(t.state.appHistory.location.search), l = e.get(r.LoginURLGeneratorParamKeys.RETURN_PATH_PARAMS_KEY), s = e.get(r.LoginURLGeneratorParamKeys.RANDOM_NUMBER_KEY);
        if (s && s !== this.randString) {
          e.delete(r.LoginURLGeneratorParamKeys.RANDOM_NUMBER_KEY), t.state.appHistory.replace(`${l || n.Home.link}`);
          return;
        }
        e.set(r.LoginURLGeneratorParamKeys.RANDOM_NUMBER_KEY, this.randString), t.state.appHistory.replace(`${p.makeAbsolutePath(t.state.appHistory.location.pathname)}?${e.toString()}`);
        const m = i.getAppState().getSdk().IAM.UserAuthorization().createLoginURL(null, "register");
        window.location.replace(m);
      }
    } catch (t) {
      this.setState({ error: t });
    }
  }
  render() {
    const { error: t } = this.state;
    return /* @__PURE__ */ a.createElement("div", { className: U.registerURLGenerator }, !t && /* @__PURE__ */ a.createElement(g, { className: h.tall }), t && /* @__PURE__ */ a.createElement(R, { error: t }));
  }
}
export {
  N as default
};
