import { defineComponent as q, toRefs as R, computed as o, resolveComponent as w, createElementBlock as O, openBlock as d, normalizeClass as j, unref as t, createBlock as r, createCommentVNode as m, createElementVNode as A, mergeProps as F, withCtx as x, renderSlot as G, normalizeProps as J, guardReactiveProps as K, createTextVNode as S, toDisplayString as y, nextTick as Q } from "vue";
import { B as W, z as X, C as Y, M as Z, _ as ee } from "./install-BuMO14Rb.js";
const le = { class: "wt-timepicker__wrapper" }, c = 3600, M = 60, ae = /* @__PURE__ */ q({
  __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: () => [] }
  },
  emits: ["update:modelValue"],
  setup(u, { emit: B }) {
    const e = u, i = B, { t: b } = W(), { v, customValidators: C, regleValidation: h } = R(e), { isValidation: I, invalid: k, validationText: g, validationTextColor: D } = X({
      v,
      customValidators: C,
      regleValidation: h
    }), _ = o(() => e.format.includes("hh")), H = o(() => e.format.includes("mm")), L = o(() => e.format.includes("ss")), U = o(() => e.noLabel || e.label ? null : b("webitelUI.timepicker.hour")), z = o(() => e.noLabel || e.label ? null : b("webitelUI.timepicker.min")), E = o(() => e.noLabel || e.label ? null : b("webitelUI.timepicker.sec")), n = o({
      get() {
        return e.dateMode ? (/* @__PURE__ */ new Date(+e.modelValue)).getHours() : Math.floor(+e.modelValue / c);
      },
      set(l) {
        const a = e.dateMode ? (/* @__PURE__ */ new Date(+e.modelValue)).setHours(l) : +e.modelValue - n.value * c + l * c;
        i("update:modelValue", a);
      }
    }), f = o({
      get() {
        return e.dateMode ? (/* @__PURE__ */ new Date(+e.modelValue)).getMinutes() : Math.floor(+e.modelValue / M % 60);
      },
      set(l) {
        const a = e.dateMode ? (/* @__PURE__ */ new Date(+e.modelValue)).setMinutes(l) : +e.modelValue - f.value * M + l * M;
        i("update:modelValue", a);
      }
    }), V = o({
      get() {
        return e.dateMode ? (/* @__PURE__ */ new Date(+e.modelValue)).getSeconds() : Math.floor(+e.modelValue % 60);
      },
      set(l) {
        const a = e.dateMode ? (/* @__PURE__ */ new Date(+e.modelValue)).setSeconds(l) : +e.modelValue - V.value + +l;
        i("update:modelValue", a);
      }
    }), N = o(() => e.required ? `${e.label} (${e.format})*` : `${e.label} (${e.format})`), P = () => {
      const l = e.dateMode ? (/* @__PURE__ */ new Date(+e.modelValue)).setHours(n.value) : +e.modelValue - n.value * c + n.value * c;
      i("update:modelValue", 0), Q(() => {
        i("update:modelValue", l);
      });
    };
    return (l, a) => {
      const T = w("wt-label"), p = w("wt-time-input"), $ = w("wt-message");
      return d(), O("div", {
        class: j([{ "wt-timepicker--invalid": t(k) }, "wt-timepicker"])
      }, [
        u.label || !u.noLabel ? (d(), r(T, F({ key: 0 }, u.labelProps, { invalid: t(k) }), {
          default: x(() => [
            G(l.$slots, "label", J(K({ label: u.label })), () => [
              S(y(N.value), 1)
            ], !0)
          ], void 0, !0),
          _: 3
        }, 16, ["invalid"])) : m("", !0),
        A("div", le, [
          _.value ? (d(), r(p, {
            key: 0,
            "model-value": n.value,
            "onUpdate:modelValue": a[0] || (a[0] = (s) => n.value = s),
            disabled: u.disabled,
            label: U.value,
            "max-value": u.dateMode ? null : 23,
            v: t(v),
            "hide-input-info": "",
            onBlur: P
          }, null, 8, ["model-value", "disabled", "label", "max-value", "v"])) : m("", !0),
          H.value ? (d(), r(p, {
            key: 1,
            "model-value": f.value,
            "onUpdate:modelValue": a[1] || (a[1] = (s) => f.value = s),
            disabled: u.disabled,
            label: z.value,
            "max-value": 59,
            v: t(v),
            "hide-input-info": ""
          }, null, 8, ["model-value", "disabled", "label", "v"])) : m("", !0),
          L.value ? (d(), r(p, {
            key: 2,
            "model-value": V.value,
            "onUpdate:modelValue": a[2] || (a[2] = (s) => V.value = s),
            disabled: u.disabled,
            label: E.value,
            "max-value": 59,
            v: t(v),
            "hide-input-info": ""
          }, null, 8, ["model-value", "disabled", "label", "v"])) : m("", !0)
        ]),
        t(I) && t(g) ? (d(), r($, {
          key: 1,
          color: t(D),
          variant: t(Z).SIMPLE,
          size: t(Y).SM
        }, {
          default: x(() => [
            S(y(t(g)), 1)
          ], void 0, !0),
          _: 1
        }, 8, ["color", "variant", "size"])) : m("", !0)
      ], 2);
    };
  }
}), ue = /* @__PURE__ */ ee(ae, [["__scopeId", "data-v-35e5a4db"]]);
export {
  ue as default
};
