import { p as phoneRegExp, e as emailRegExp } from "./validation-Ds00Zghx.js";
import { u as usePasswordSchema } from "./useGeneratePolicy-B4rO5xUa.js";
import { n as numberType, a as arrayType, o as objectType, s as stringType, u as unionType, l as literalType, p as preprocessType, f as dateType } from "./types-espwwxTQ.js";
const validateSchemeStatus = (t) => numberType({
  invalid_type_error: t("validation.selectUserStatus"),
  required_error: t("validation.statusRequired")
});
const validateSchemeCustomer = (t) => objectType({
  Id: numberType({
    invalid_type_error: t("validation.selectDepartment"),
    required_error: t("validation.divisionRequired")
  }).positive({
    message: t("validation.selectDepartment")
  })
});
const validateSchemePositions = (t) => arrayType(objectType({
  Position: objectType({
    Name: stringType().max(64, {
      message: t("validation.maxLengthSymbolsWithCount.symbols", {
        count: 64
      })
    }).refine((data) => /\S/.test(data), {
      message: t("validation.enterPosition")
    })
  })
})).nullable();
const validateSchemeDataStorageQuota = (t) => objectType({
  Id: numberType({
    invalid_type_error: t("validation.selectQuota"),
    required_error: t("validation.quotaMandatory")
  }).optional().nullable()
});
function validateAdditionalEmailNotEqual(data) {
  if (!(data == null ? void 0 : data.Email) || !(data == null ? void 0 : data.AdditionalEmail)) {
    return true;
  }
  return (data == null ? void 0 : data.AdditionalEmail) !== (data == null ? void 0 : data.Email);
}
const validateAdditionalEmailScheme = (t) => objectType({
  AdditionalEmail: stringType().regex(emailRegExp, {
    message: t("validation.wrongEmailFormat")
  }).or(literalType("")).optional().nullable(),
  Email: stringType().or(literalType("")).optional().nullable()
}).refine(validateAdditionalEmailNotEqual, {
  message: t("validation.emailsShouldNotBeTheSame"),
  path: ["AdditionalEmail"]
});
const validateLoginScheme = (t) => objectType({
  Login: stringType().min(1, {
    message: t("validation.enterLogin")
  }).max(150, {
    message: t("validation.maxLengthSymbolsWithCount.symbols", {
      count: 150
    })
  }).refine((data) => !/\s/.test(data), {
    message: t("validation.loginWithoutSpaces")
  }).refine((data) => /^[a-zA-Z0-9._@-]+$/.test(data), {
    message: t("validation.loginInvalidChars")
  })
});
const isSaasScheme = (t) => objectType({
  isSaaS: literalType(true),
  Email: stringType().regex(emailRegExp, {
    message: t("validation.wrongEmailFormat")
  }).min(1, {
    message: t("validation.enterEmail")
  }).max(255, {
    message: t("validation.maxLengthSymbolsWithCount.symbols", {
      count: 255
    })
  })
});
const noSaasScheme = (t) => objectType({
  isSaaS: literalType(false),
  Email: stringType().regex(emailRegExp, {
    message: t("validation.wrongEmailFormat")
  }).max(255, {
    message: t("validation.maxLengthSymbolsWithCount.symbols", {
      count: 255
    })
  }).or(literalType("")).optional().nullable()
});
const validateCreateCredentialsNoSaas = (t, passwordRules, isPasswordEnabled) => {
  const passwordRulesZ = usePasswordSchema(passwordRules, t);
  return objectType({
    isSaas: literalType(false),
    Email: stringType().max(255, {
      message: t("validation.maxLengthSymbolsWithCount.symbols", {
        count: 255
      })
    }).regex(emailRegExp, {
      message: t("validation.wrongEmailFormat")
    }).or(literalType("")).optional().nullable(),
    AdditionalEmail: stringType().regex(emailRegExp, {
      message: t("validation.wrongEmailFormat")
    }).or(literalType("")).optional().nullable(),
    Login: stringType().min(1, {
      message: t("validation.enterLogin")
    }).max(150, {
      message: t("validation.maxLengthSymbolsWithCount.symbols", {
        count: 150
      })
    }).refine((data) => !/\s/.test(data), {
      message: t("validation.loginWithoutSpaces")
    }).refine((data) => /^[a-zA-Z0-9._@-]+$/.test(data), {
      message: t("validation.loginInvalidChars")
    }),
    Password: isPasswordEnabled ? passwordRulesZ : stringType().nullable().default("")
  }).refine((data) => data.Email === "" && data.AdditionalEmail === "" || data.Email !== data.AdditionalEmail, {
    message: t("validation.emailsShouldNotBeTheSame"),
    path: ["AdditionalEmail"]
  });
};
const validateCreateCredentialsSaas = (t, passwordRules, isPasswordEnabled) => {
  const passwordRulesZ = usePasswordSchema(passwordRules, t);
  return objectType({
    isSaas: literalType(true),
    Email: stringType().regex(emailRegExp, {
      message: t("validation.wrongEmailFormat")
    }).min(1, {
      message: t("validation.enterEmail")
    }).max(255, {
      message: t("validation.maxLengthSymbolsWithCount.symbols", {
        count: 255
      })
    }),
    AdditionalEmail: stringType().regex(emailRegExp, {
      message: t("validation.wrongEmailFormat")
    }).or(literalType("")).optional().nullable(),
    Login: stringType().optional().nullable(),
    Password: isPasswordEnabled ? passwordRulesZ : stringType().nullable().default("")
  }).refine((data) => data.Email === "" && data.AdditionalEmail === "" || data.Email !== data.AdditionalEmail, {
    message: t("validation.emailsShouldNotBeTheSame"),
    path: ["AdditionalEmail"]
  });
};
const validateSchemeCreateCredentials = (t, passwordRules, isPasswordEnabled) => {
  return unionType([validateCreateCredentialsNoSaas(t, passwordRules, isPasswordEnabled), validateCreateCredentialsSaas(t, passwordRules, isPasswordEnabled)]);
};
const validateSchemeEditUserInfo = (t) => objectType({
  SurName: stringType().max(85, {
    message: t("validation.maxLengthSymbolsWithCount.symbols", {
      count: 85
    })
  }).refine((data) => /\S/.test(data), {
    message: t("validation.enterLastName")
  }).refine((data) => /^[\p{L}\s\-']+$/u.test(data), {
    message: t("validation.nameInvalidChars")
  }),
  FirstName: stringType().max(85, {
    message: t("validation.maxLengthSymbolsWithCount.symbols", {
      count: 85
    })
  }).refine((data) => /\S/.test(data), {
    message: t("validation.enterFirstName")
  }).refine((data) => /^[\p{L}\s\-']+$/u.test(data), {
    message: t("validation.nameInvalidChars")
  }),
  MiddleName: stringType().max(85, {
    message: t("validation.maxLengthSymbolsWithCount.symbols", {
      count: 85
    })
  }).refine((data) => /\S/.test(data), {
    message: t("validation.enterFirstName")
  }).refine((data) => /^[\p{L}\s\-']+$/u.test(data), {
    message: t("validation.nameInvalidChars")
  }).optional().or(literalType("")).nullable(),
  Gender: numberType().min(1, {
    message: t("validation.chooseGender")
  }).or(numberType().default(0)).optional(),
  BirthDate: preprocessType((arg) => typeof arg === "string" ? new Date(arg) : " ", dateType({
    invalid_type_error: t("validation.indicateBirthday")
  }).min(/* @__PURE__ */ new Date("1900-01-01"), {
    message: t("validation.enteredDateSmall")
  }).max(/* @__PURE__ */ new Date(), {
    message: t("validation.dateLessCurrent")
  }).or(stringType().optional()).nullable()).nullable(),
  Address: stringType().max(255, {
    message: t("validation.maxLengthSymbolsWithCount.symbols", {
      count: 255
    })
  }).optional().nullable(),
  Phone: stringType().regex(phoneRegExp, {
    message: t("validation.wrongMobilePhoneFormat")
  }).or(literalType("")).optional().nullable(),
  AdditionalPhone: stringType().regex(/^[0-9]*$/, {
    message: t("validation.extensionPhoneContainNumbers")
  }).or(literalType("")).optional().nullable()
});
export {
  validateSchemePositions as a,
  validateSchemeCustomer as b,
  validateSchemeCreateCredentials as c,
  validateSchemeEditUserInfo as d,
  validateSchemeDataStorageQuota as e,
  validateLoginScheme as f,
  validateAdditionalEmailScheme as g,
  isSaasScheme as i,
  noSaasScheme as n,
  validateSchemeStatus as v
};
//# sourceMappingURL=validate-Bw-sUlFj.js.map
