import { jsxs as m, jsx as t } from "react/jsx-runtime";
import { s as P, a as $, b as B } from "../lite.js";
import { useState as d, useMemo as E, useCallback as O, useEffect as L } from "react";
import { c as R } from "../tools/icons.js";
import { c as V, s as _, a as q } from "../tools/tools.js";
const N = /* @__PURE__ */ new Date(), s = (u) => u.toString().padStart(2, "0"), z = function(S) {
  const {
    as: k = "div",
    className: p,
    dropOldClass: h,
    onDateClick: o,
    selectedDate: M,
    style: g,
    variables: y,
    ...H
  } = S, n = M ?? N, [a, f] = d(s(n.getHours())), [c, x] = d(s(n.getMinutes())), [r, C] = d(s(n.getSeconds())), I = E(() => {
    const e = V(!h && "card card-body border-0 p-0", p), l = _((b, v) => ({ tKey: q(v) }), y, g);
    return {
      className: e,
      style: l
    };
  }, [p, h, g, y]), D = O(() => {
    const e = parseInt(a, 10) || 0, l = parseInt(c, 10) || 0, b = parseInt(r, 10) || 0, j = { date: P($(B(N, e), l), b) };
    o == null || o(j);
  }, [a, c, o, r]), K = (e) => {
    f(e.target.value.trim());
  }, w = (e) => {
    x(e.target.value.trim());
  }, T = (e) => {
    C(e.target.value.trim());
  }, i = (e) => {
    e.key === "Enter" && D();
  };
  return L(() => {
    f(s(n.getHours())), x(s(n.getMinutes())), C(s(n.getSeconds()));
  }, [n]), /* @__PURE__ */ m(k, { ...H, ...I, children: [
    /* @__PURE__ */ m("div", { className: "input-group", children: [
      /* @__PURE__ */ t(
        "input",
        {
          className: "form-control",
          onChange: K,
          onKeyDown: i,
          placeholder: "HH",
          type: "text",
          value: a
        }
      ),
      /* @__PURE__ */ t("span", { className: "input-group-text text-secondary", children: ":" }),
      /* @__PURE__ */ t(
        "input",
        {
          className: "form-control",
          onChange: w,
          onKeyDown: i,
          placeholder: "MM",
          type: "text",
          value: c
        }
      ),
      /* @__PURE__ */ t("span", { className: "input-group-text text-secondary", children: ":" }),
      /* @__PURE__ */ t(
        "input",
        {
          className: "form-control",
          onChange: T,
          onKeyDown: i,
          placeholder: "SS",
          type: "text",
          value: r
        }
      )
    ] }),
    /* @__PURE__ */ m(
      "button",
      {
        className: "btn btn-outline-primary btn-sm mt-4 mb-1 d-flex justify-content-center align-items-center gap-1",
        onClick: D,
        type: "button",
        children: [
          /* @__PURE__ */ t("span", { className: "d-inline-flex", children: /* @__PURE__ */ t(R, {}) }),
          /* @__PURE__ */ t("span", { children: "Confirm" })
        ]
      }
    )
  ] });
};
z.displayName = "BRL.DatePickerTime";
export {
  z as D
};
//# sourceMappingURL=date-picker-time.js.map
