import { t as e } from "./_plugin-vue_export-helper-B3ysoDQm.js";
import { l as t, r as n } from "./enums-De8CDKZ1.js";
import { t as r } from "./vue-i18n-Db_oYfO8.js";
import { t as i } from "./useValidation-DGl2otXJ.js";
import { computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as u, defineComponent as d, guardReactiveProps as f, mergeProps as p, nextTick as m, normalizeClass as h, normalizeProps as g, openBlock as _, renderSlot as v, resolveComponent as y, toDisplayString as b, toRefs as x, unref as S, withCtx as C } from "vue";
//#region src/components/wt-timepicker/wt-timepicker.vue?vue&type=script&setup=true&lang.ts
var w = { class: "wt-timepicker__wrapper" }, T = 3600, E = 60, D = /*#__PURE__*/ e(/* @__PURE__ */ d({
	__name: "wt-timepicker",
	props: {
		modelValue: { default: 0 },
		dateMode: {
			type: Boolean,
			default: !1
		},
		label: { default: "" },
		format: { default: "hh:mm:ss" },
		disabled: {
			type: Boolean,
			default: !1
		},
		labelProps: { default: () => ({}) },
		noLabel: {
			type: Boolean,
			default: !1
		},
		required: {
			type: Boolean,
			default: !1
		},
		v: { default: null },
		regleValidation: { default: null },
		customValidators: { default: () => [] },
		noMaxHours: {
			type: Boolean,
			default: !1
		}
	},
	emits: ["update:modelValue"],
	setup(e, { emit: d }) {
		let D = e, O = d, { t: k } = r(), { v: A, customValidators: j, regleValidation: M } = x(D), { isValidation: N, invalid: P, validationText: F, validationTextColor: I } = i({
			v: A,
			customValidators: j,
			regleValidation: M
		}), L = a(() => D.format.includes("hh")), R = a(() => D.format.includes("mm")), z = a(() => D.format.includes("ss")), B = a(() => D.noMaxHours || D.dateMode ? null : 23), V = a(() => D.noLabel || D.label ? null : k("webitelUI.timepicker.hour")), H = a(() => D.noLabel || D.label ? null : k("webitelUI.timepicker.min")), U = a(() => D.noLabel || D.label ? null : k("webitelUI.timepicker.sec")), W = a({
			get() {
				return D.dateMode ? (/* @__PURE__ */ new Date(+D.modelValue)).getHours() : Math.floor(+D.modelValue / T);
			},
			set(e) {
				let t = D.dateMode ? (/* @__PURE__ */ new Date(+D.modelValue)).setHours(e) : +D.modelValue - W.value * T + e * T;
				O("update:modelValue", t);
			}
		}), G = a({
			get() {
				return D.dateMode ? (/* @__PURE__ */ new Date(+D.modelValue)).getMinutes() : Math.floor(+D.modelValue / E % 60);
			},
			set(e) {
				let t = D.dateMode ? (/* @__PURE__ */ new Date(+D.modelValue)).setMinutes(e) : +D.modelValue - G.value * E + e * E;
				O("update:modelValue", t);
			}
		}), K = a({
			get() {
				return D.dateMode ? (/* @__PURE__ */ new Date(+D.modelValue)).getSeconds() : Math.floor(D.modelValue % 60);
			},
			set(e) {
				let t = D.dateMode ? (/* @__PURE__ */ new Date(+D.modelValue)).setSeconds(e) : +D.modelValue - K.value + +e;
				O("update:modelValue", t);
			}
		}), q = a(() => D.required ? `${D.label} (${D.format})*` : `${D.label} (${D.format})`), J = () => {
			let e = D.dateMode ? (/* @__PURE__ */ new Date(+D.modelValue)).setHours(W.value) : +D.modelValue - W.value * T + W.value * T;
			O("update:modelValue", 0), m(() => {
				O("update:modelValue", e);
			});
		};
		return (r, i) => {
			let a = y("wt-label"), d = y("wt-time-input"), m = y("wt-message");
			return _(), c("div", { class: h([{ "wt-timepicker--invalid": S(P) }, "wt-timepicker"]) }, [
				e.label || !e.noLabel ? (_(), o(a, p({ key: 0 }, e.labelProps, { invalid: S(P) }), {
					default: C(() => [v(r.$slots, "label", g(f({ label: e.label })), () => [u(b(q.value), 1)], !0)], void 0, !0),
					_: 3
				}, 16, ["invalid"])) : s("", !0),
				l("div", w, [
					L.value ? (_(), o(d, {
						key: 0,
						"model-value": W.value,
						"onUpdate:modelValue": i[0] ||= (e) => W.value = e,
						disabled: e.disabled,
						label: V.value,
						"max-value": B.value,
						v: S(A),
						"hide-input-info": "",
						onBlur: J
					}, null, 8, [
						"model-value",
						"disabled",
						"label",
						"max-value",
						"v"
					])) : s("", !0),
					R.value ? (_(), o(d, {
						key: 1,
						"model-value": G.value,
						"onUpdate:modelValue": i[1] ||= (e) => G.value = e,
						disabled: e.disabled,
						label: H.value,
						"max-value": 59,
						v: S(A),
						"hide-input-info": ""
					}, null, 8, [
						"model-value",
						"disabled",
						"label",
						"v"
					])) : s("", !0),
					z.value ? (_(), o(d, {
						key: 2,
						"model-value": K.value,
						"onUpdate:modelValue": i[2] ||= (e) => K.value = e,
						disabled: e.disabled,
						label: U.value,
						"max-value": 59,
						v: S(A),
						"hide-input-info": ""
					}, null, 8, [
						"model-value",
						"disabled",
						"label",
						"v"
					])) : s("", !0)
				]),
				S(N) && S(F) ? (_(), o(m, {
					key: 1,
					color: S(I),
					variant: S(n).SIMPLE,
					size: S(t).SM
				}, {
					default: C(() => [u(b(S(F)), 1)], void 0, !0),
					_: 1
				}, 8, [
					"color",
					"variant",
					"size"
				])) : s("", !0)
			], 2);
		};
	}
}), [["__scopeId", "data-v-3b807528"]]);
//#endregion
export { D as default };
