import { E as ErrorHelper, T as Trans, H as translateServiceError } from "./index.js";
import { s as starBgGradient } from "./starBgGradient.js";
import React__default from "react";
import "./CommonError2.js";
const CommonError = (props) => {
  var _a;
  const { error } = props;
  if (!error)
    return null;
  if (ErrorHelper.isAxiosNetworkError(error)) {
    return /* @__PURE__ */ React__default.createElement(Trans, {
      i18nKey: "CommonError.networkError"
    }, "The server cannot be reached. Please try again.");
  }
  const errorCode = ErrorHelper.extractServiceErrorCode(error) || 0;
  const errorMessage = translateServiceError(errorCode);
  if (errorMessage)
    return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, errorMessage);
  const responseStatus = ErrorHelper.isAxiosError(error) && ((_a = error == null ? void 0 : error.response) == null ? void 0 : _a.status);
  if (responseStatus === 403) {
    return /* @__PURE__ */ React__default.createElement(Trans, {
      i18nKey: "CommonError.playerPortal.forbidden"
    }, "You cannot access this page. Please go back.");
  }
  if (ErrorHelper.isAxiosServerError(error)) {
    return /* @__PURE__ */ React__default.createElement(Trans, {
      i18nKey: "CommonError.serverError"
    }, "We are experiencing some technical issues right now. Please try again later.");
  }
  return /* @__PURE__ */ React__default.createElement(Trans, {
    i18nKey: "CommonError.unknownError"
  }, "Something went wrong. Please contact support for assistance.");
};
const NoMatchingGameError = ({ error, appId, isWithBackground = true }) => {
  var _a;
  if (ErrorHelper.isAxiosError(error) && appId && ((_a = error.response) == null ? void 0 : _a.status) === 404) {
    return /* @__PURE__ */ React__default.createElement("div", {
      className: "noMatchingGameError",
      style: { backgroundImage: isWithBackground ? `url(${starBgGradient})` : void 0 }
    }, /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement("h2", {
      className: "heading"
    }, /* @__PURE__ */ React__default.createElement(Trans, {
      i18nKey: "CommonError.noMatchingGame"
    }, 'Game "', { appId }, `" doesn't exist in the store.`)), /* @__PURE__ */ React__default.createElement("p", {
      className: "paragraph"
    }, /* @__PURE__ */ React__default.createElement(Trans, {
      i18nKey: "CommonError.noMatchingGameResolution"
    }, "To fix this, do one of the following:")), /* @__PURE__ */ React__default.createElement("ol", {
      className: "list"
    }, /* @__PURE__ */ React__default.createElement("li", null, /* @__PURE__ */ React__default.createElement(Trans, {
      i18nKey: "CommonError.noMatchingGameResolutionEnsure"
    }, 'Ensure the game "', { appId }, '" exists in the store,')), /* @__PURE__ */ React__default.createElement("li", null, /* @__PURE__ */ React__default.createElement(Trans, {
      i18nKey: "CommonError.noMatchingGameResolutionChangeAppID"
    }, "Change the App ID to an existing game, or")), /* @__PURE__ */ React__default.createElement("li", null, /* @__PURE__ */ React__default.createElement(Trans, {
      i18nKey: "CommonError.noMatchingGameResolutionChangeTemplateConfig"
    }, "Change the Template Config to multiple game.")))));
  }
  return /* @__PURE__ */ React__default.createElement(CommonError, {
    error
  });
};
export { CommonError as C, NoMatchingGameError as N };
