import { i as e } from "./enums-De8CDKZ1.js";
import { t } from "./vue-i18n-Db_oYfO8.js";
import { computed as n, isReactive as r } from "vue";
//#region src/mixins/validationMixin/regle/useRegleValidation.ts
var i = ({ field: e }) => ({
	invalid: n(() => e.value.$error),
	validationText: n(() => e.value?.$errors?.at(0))
}), a = ({ field: e, customValidators: i }) => {
	let { t: a } = t(), o = e, s = i;
	r(o) && (o = n(() => e), s = n(() => i));
	let c = n(() => !!o && !!o.value && !!Object.keys(o.value).length), l = n(() => c.value && o.value.$error);
	return {
		isValidation: c,
		invalid: l,
		validationText: n(() => {
			let e = "";
			if (c.value && l.value && (o.value.required?.$invalid ? e = a("validation.required") : o.value.numeric?.$invalid ? e = a("validation.numeric") : o.value.email?.$invalid ? e = a("validation.email") : o.value.gatewayHostValidator?.$invalid ? e = a("validation.gatewayHostValidator") : o.value.ipValidator?.$invalid ? e = a("validation.ipValidator") : o.value.macValidator?.$invalid ? e = a("validation.macValidator") : o.value.minValue?.$invalid ? e = a("validation.minValue", { min: o.value.minValue.$params.min }) : o.value.maxValue?.$invalid ? e = a("validation.maxValue", { max: o.value.maxValue.$params.max }) : o.value.maxLength?.$invalid ? e = a("validation.maxLength", { max: o.value.maxLength.$params.max }) : o.value.sipAccountValidator?.$invalid ? e = a("validation.sipAccountValidator") : o.value.minLength?.$invalid ? e = a("validation.minLength", { min: o.value.minLength.$params.min }) : o.value.url?.$invalid ? e = `${a("validation.url")}` : o.value.regExpValidator?.$invalid ? e = `${a("validation.regExpValidator")}` : o.value.sameAs?.$invalid ? e = `${a("validation.sameAs")}` : o.value.domainValidator?.$invalid ? e = `${a("validation.domainValidator")}` : o.value.decimalValidator?.$invalid ? e = `${a("validation.decimalValidator")} ${o.value.decimalValidator.$params.count}` : o.value.websocketValidator?.$invalid ? e = `${a("validation.websocketValidator")}` : o.value.integer?.$invalid ? e = `${a("validation.integer")}` : o.value.regex?.$invalid ? e = o.value.regex?.$message || `${a("validation.isRegExpMatched")} ${o.value.regex?.$params?.regex}` : o.value.nameAlreadyInUse?.$invalid && (e = a("validation.nameAlreadyInUse"))), s?.value) {
				for (let { name: t, text: n } of s.value) o.value[t]?.$invalid && (e = n);
				return e;
			}
			return e;
		})
	};
}, o = ({ v: t, customValidators: r, regleValidation: o }) => {
	let { isValidation: s, invalid: c, validationText: l } = a({
		field: t,
		customValidators: r
	}), { invalid: u, validationText: d } = i({ field: o }), f = n(() => !!o?.value), p = n(() => f.value || s.value), m = n(() => f.value ? u.value : c.value);
	return {
		isValidation: p,
		invalid: m,
		validationText: n(() => f.value ? d.value : l.value),
		validationTextColor: n(() => m.value ? e.ERROR : e.SECONDARY)
	};
};
//#endregion
export { o as t };
