import * as t from "react";
import m from "react";
import { M as S, a as K, b as C } from "./Modal-05e5e3d2.mjs";
import { B as w, b as D, a as M, t as o } from "./useRoutes-367960a3.mjs";
import { F as a } from "./Select-934e9e99.mjs";
import { Trans as n } from "react-i18next";
import { V as s, C as b, a as T, i as W, v as G, t as X, b as H, c as R, d as _, e as N } from "./validateNotEmpty-815360bd.mjs";
import { z as $ } from "zod";
import { M as O, a as V, b as B } from "./numbers-bf855d8f.mjs";
const Y = /[a-zA-Z]/, z = /([a-z].*[A-Z])|([A-Z].*[a-z])/, Z = /^[^a-z]*$/, U = /^[^A-Z]*$/, j = /[^a-zA-Z\d\s]/, q = /[^a-zA-Z\d\s\u007e-\uFFFF$]/, J = /[\u007e-\uFFFF$]/, Q = /^\W|\W$/, ee = /^\W\u007e-\uFFFF$|\W\u007e-\uFFFF$/, I = (e) => `([^a-zA-Zds])\\1{${e},}`, te = (e, r) => `([${e.join("\\")}])\\1{${r},}`, l = $.enum([
  ...s.options,
  b.enum.invalidFormat,
  T.enum.containsBadWords
]), ce = (e, {
  allowUnicode: r = !1,
  isRequired: d = !0,
  maxLength: A = O,
  minLength: y = V,
  isCustomRegex: f = !1,
  customRegex: P = "",
  specialCharacterLocation: u = "middle",
  allowSpace: F = !0,
  allowAllSpecialCharacters: p,
  maxRepeatingSpecialCharacter: E = 1,
  // prettier-ignore
  // eslint-disable-next-line
  specialCharacters: i = ["'", ",", ".", "-"],
  letterCase: h = "any",
  validateBadWord: v = !1
} = {}) => {
  if (W(e))
    return d ? l.enum.empty : null;
  if (f)
    return G(e, P, {
      allowUnicode: r || f
    });
  if (F) {
    if (/^\s|\s$|\s{2,}/.test(e))
      return l.enum.invalidFormat;
  } else if (/\s/.test(e))
    return l.enum.invalidFormat;
  if (!r && J.test(e) || p && u === "middle" && ((r ? ee : Q).test(e) || E && new RegExp(I(E), "g").test(e)) || !p && (i == null ? void 0 : i.length) === 0 && (r ? q : j).test(e))
    return l.enum.invalidFormat;
  if (i && i.length > 0) {
    const c = `[^a-zA-Z0-9${r ? "~-$" : ""}${i.join("")}${F ? "\\s" : ""}]`;
    if (new RegExp(c).test(e) || u === "middle" && new RegExp(`^[${i == null ? void 0 : i.join("")}]|[${i == null ? void 0 : i.join("")}]$`).test(e) || E && i.length > 0 && new RegExp(te(i, E), "g").test(e) || p && E && new RegExp(I(E), "g").test(e))
      return l.enum.invalidFormat;
  }
  let g = Y;
  switch (h) {
    case "mixed":
      g = z;
      break;
    case "uppercase":
      g = Z;
      break;
    case "lowercase":
      g = U;
      break;
  }
  return h !== "any" && !g.test(e) ? l.enum.invalidFormat : v && X(e) ? l.Enum.containsBadWords : H(e, {
    max: A,
    min: y
  });
}, L = ({ title: e, subtitle: r, visible: d, cancelText: A, submitText: y, onClose: f, onSubmit: P, isSubmitDisabled: u }) => /* @__PURE__ */ m.createElement(S, { visible: d, className: "alertDialog" }, /* @__PURE__ */ m.createElement(K, { tag: "h3", onClose: u ? void 0 : f }, e), /* @__PURE__ */ m.createElement(C, null, /* @__PURE__ */ m.createElement("p", { className: "text-center" }, r), /* @__PURE__ */ m.createElement("div", { className: "my-8 flex justify-center gap-14" }, /* @__PURE__ */ m.createElement(
  w,
  {
    onClick: f,
    buttonType: D.PLAIN,
    buttonStyle: M.TEXT,
    hasOutline: !1,
    className: "uppercase",
    disabled: u
  },
  A
), /* @__PURE__ */ m.createElement(
  w,
  {
    onClick: P,
    buttonType: D.FLAT,
    buttonStyle: M.PRIMARY,
    className: "uppercase",
    disabled: u
  },
  y
)))), ue = (e) => /* @__PURE__ */ m.createElement(
  L,
  {
    title: o("AlertDialog.title.delete"),
    cancelText: o("AlertDialog.button.cancel"),
    submitText: o("AlertDialog.button.delete"),
    ...e
  }
), Ee = (e) => /* @__PURE__ */ m.createElement(
  L,
  {
    title: o("AlertDialog.title.leavePage"),
    subtitle: o("AlertDialog.subtitle.leavePage"),
    cancelText: o("AlertDialog.button.stayPage"),
    submitText: o("AlertDialog.button.leavePage"),
    ...e
  }
), de = (e) => /* @__PURE__ */ m.createElement(
  L,
  {
    title: o("AlertDialog.title.unpublish"),
    subtitle: o("AlertDialog.subtitle.unpublish"),
    cancelText: o("AlertDialog.button.cancel"),
    submitText: o("AlertDialog.button.unpublish"),
    ...e
  }
), Ae = (e) => /* @__PURE__ */ m.createElement(
  L,
  {
    title: o("AlertDialog.title.discard"),
    subtitle: o("AlertDialog.subtitle.discard"),
    cancelText: o("AlertDialog.button.cancel"),
    submitText: o("AlertDialog.button.discard"),
    ...e
  }
), fe = (e, r) => {
  if (!e || !r.min || !r.max)
    return null;
  switch (e) {
    case s.enum.empty:
      return /* @__PURE__ */ t.createElement(a, null, /* @__PURE__ */ t.createElement(n, { i18nKey: "linkPlatformAccountPage.LinkNewAccount.form.passwordEmptyError" }, "You must fill in a password"));
    case s.enum.lessThanLengthLimit:
      return /* @__PURE__ */ t.createElement(a, null, /* @__PURE__ */ t.createElement(n, { i18nKey: "linkPlatformAccountPage.LinkNewAccount.form.passwordLessThanLengthLimit" }, "Your password must contain at least ", { PASSWORD_MIN_LIMIT: r.min }, " characters"));
    case s.enum.exceedLengthLimit:
      return /* @__PURE__ */ t.createElement(a, null, /* @__PURE__ */ t.createElement(n, { i18nKey: "linkPlatformAccountPage.LinkNewAccount.form.passwordExceedLimit" }, "Your password must not exceed ", { PASSWORD_MAX_LENGTH: r.max }, " characters"));
    case R.enum.invalidFormat:
      return /* @__PURE__ */ t.createElement(a, null, /* @__PURE__ */ t.createElement(n, { i18nKey: "linkPlatformAccountPage.LinkNewAccount.form.passwordInvalidFormat" }, "Please enter a valid password"));
    default:
      return /* @__PURE__ */ t.createElement(n, { i18nKey: "CommonError.unknownError" }, "Something went wrong. Please contact support for assistance.");
  }
}, ge = (e, r = {}) => {
  if (!e)
    return null;
  switch (e) {
    case s.enum.empty:
      return /* @__PURE__ */ t.createElement(a, null, /* @__PURE__ */ t.createElement(n, { i18nKey: "AccountMyProfilePage.form.displayNameEmptyError" }, "The display name cannot be empty."));
    case s.enum.lessThanLengthLimit:
      return /* @__PURE__ */ t.createElement(a, null, /* @__PURE__ */ t.createElement(n, { i18nKey: "AccountMyProfilePage.form.lessThanLengthLimit" }, "Your display name must contain at least ", { DISPLAY_NAME_MIN_LIMIT: r.min }, " characters"));
    case s.enum.exceedLengthLimit:
      return /* @__PURE__ */ t.createElement(a, null, /* @__PURE__ */ t.createElement(n, { i18nKey: "AccountMyProfilePage.form.displayNameExceedLimit" }, "Display name must not exceed ", { MAX_DISPLAY_NAME_LENGTH: r.max }, " characters"));
    case R.enum.invalidFormat:
      return /* @__PURE__ */ t.createElement(a, null, /* @__PURE__ */ t.createElement(n, { i18nKey: "AccountMyProfilePage.form.displayNameInvalidFormat" }, "Please enter a valid display name format"));
    case T.enum.containsBadWords:
      return /* @__PURE__ */ t.createElement(n, { i18nKey: "AccountMyProfilePage.form.displayNameBadWord" }, "Contains inappropriate words. Please try again.");
    default:
      return /* @__PURE__ */ t.createElement(n, { i18nKey: "CommonError.unknownError" }, "Something went wrong. Please contact support for assistance.");
  }
}, Le = (e, r = {}) => {
  if (!e)
    return null;
  switch (e) {
    case s.enum.empty:
      return /* @__PURE__ */ t.createElement(a, null, /* @__PURE__ */ t.createElement(n, { i18nKey: "AccountMyProfilePage.form.userName.emptyError" }, "The username cannot be empty"));
    case s.enum.lessThanLengthLimit:
      return /* @__PURE__ */ t.createElement(a, null, /* @__PURE__ */ t.createElement(n, { i18nKey: "AccountMyProfilePage.form.userName.lessThanLengthLimit" }, "Your username must contain at least ", { MIN_USERNAME_LENGTH: r.min }, " characters"));
    case s.enum.exceedLengthLimit:
      return /* @__PURE__ */ t.createElement(a, null, /* @__PURE__ */ t.createElement(n, { i18nKey: "AccountMyProfilePage.form.userName.exceedLimit" }, "Your username must not exceed ", { MAX_USERNAME_LENGTH: r.max }, " characters"));
    case R.enum.invalidFormat:
      return /* @__PURE__ */ t.createElement(a, null, /* @__PURE__ */ t.createElement(n, { i18nKey: "AccountMyProfilePage.form.userName.invalidFormat" }, "Please enter a valid username format"));
    case T.enum.containsBadWords:
      return /* @__PURE__ */ t.createElement(n, { i18nKey: "AccountMyProfilePage.form.userName.badWord" }, "Contains inappropriate words. Please try again.");
    default:
      return /* @__PURE__ */ t.createElement(n, { i18nKey: "CommonError.unknownError" }, "Something went wrong. Please contact administrator.");
  }
}, ye = (e) => {
  if (!e)
    return null;
  switch (e) {
    case N.enum.empty:
      return /* @__PURE__ */ t.createElement(a, null, /* @__PURE__ */ t.createElement(n, { i18nKey: "linkPlatformAccountPage.LinkNewAccount.verifyCodeError.empty" }, "You must enter your verification code"));
    case N.enum.exceedLengthLimit:
      return /* @__PURE__ */ t.createElement(a, null, /* @__PURE__ */ t.createElement(n, { i18nKey: "linkPlatformAccountPage.LinkNewAccount.verifyCodeError.ExceedLimit" }, "Verification code must not exceed ", { MAX_SHORT_TEXT_LENGTH: B }, " characters"));
    case N.enum.invalidFormat:
      return /* @__PURE__ */ t.createElement(a, null, /* @__PURE__ */ t.createElement(n, { i18nKey: "linkPlatformAccountPage.LinkNewAccount.verifyCodeError.invalidFormat" }, "Please enter a valid verification code"));
    default:
      return /* @__PURE__ */ t.createElement(n, { i18nKey: "CommonError.unknownError" }, "Something went wrong. Please contact support for assistance.");
  }
}, Pe = (e, { minLength: r, maxLength: d } = {}) => {
  if (!e)
    return null;
  const A = {
    [_.enum.empty]: /* @__PURE__ */ t.createElement(n, { i18nKey: "LinkPlatformAccountPage.LinkNewAccount.emailError.empty" }, "Email is required"),
    [_.enum.lessThanLengthLimit]: /* @__PURE__ */ t.createElement(n, { i18nKey: "LinkPlatformAccountPage.LinkNewAccount.emailError.lessThanLengthLimit" }, "Email must not less than ", { MIN_EMAIL_LENGTH: r }, " characters"),
    [_.enum.exceedLengthLimit]: /* @__PURE__ */ t.createElement(n, { i18nKey: "LinkPlatformAccountPage.LinkNewAccount.emailError.ExceedLimit" }, "Email must not exceed ", { MAX_EMAIL_LENGTH: d }, " characters"),
    [l.enum.invalidFormat]: /* @__PURE__ */ t.createElement(n, { i18nKey: "LinkPlatformAccountPage.LinkNewAccount.emailError.InvalidFormat" }, "Please provide a valid Email format"),
    [b.enum.containsForbiddenWords]: /* @__PURE__ */ t.createElement(n, { i18nKey: "LinkPlatformAccountPage.LinkNewAccount.emailError.containsForbiddenWords" }, "Email contains prohibited word or use blocked domain")
  };
  return /* @__PURE__ */ t.createElement(a, null, A[e]);
};
export {
  ue as A,
  ge as D,
  fe as P,
  Le as U,
  Pe as a,
  de as b,
  Ee as c,
  Ae as d,
  L as e,
  ye as f,
  ce as v
};
