import { bK as $, w as R, a0 as a, ba as v, bd as L, bL as O, bv as g, bM as h, bB as Q, bN as X, be as Y, bf as Z, bP as x, U as E, bQ as d, dw as u, V as c, dx as C, bD as p, P as l, bh as y, bi as n, bj as s, bg as o, bV as D, c7 as I, c8 as F, bk as q, bl as k, bn as H, bo as T, bX as f, bp as K, bY as z, bZ as G, b_ as J, b$ as W, c0 as ee, c1 as te, c2 as ae, c3 as oe, c4 as ie } from "./684d2f28.js";
import { formDataChildren as le, FormDataPropertyView as re } from "./00dac55d.js";
import { useContext as i } from "react";
import { disabledTime as A, handleDateChange as ne, dateRefMethods as B } from "./f2000b8a.js";
import { TimeUIView as se } from "./5cbbee2b.js";
import { TimeRangeUIView as de } from "./fe6a83c2.js";
import "react-dom";
import "./d6402597.js";
import "./6aa2c0e1.js";
const ue = [G, J, W], me = {
  required: g,
  minTime: v,
  maxTime: v,
  customRule: ee
}, j = {
  label: $,
  placeholder: R(v, a("time.placeholder")),
  format: v,
  disabled: L,
  onEvent: O(ue),
  showTime: g,
  use12Hours: g,
  hourStep: h.closed(1, 24, 1),
  minuteStep: h.closed(1, 60, 1),
  secondStep: h.closed(1, 60, 1),
  style: Q(X),
  suffixIcon: R(Y, "/icon:regular/clock"),
  viewRef: Z,
  ...me
}, N = (e) => te.pick(e, "format", "use12Hours", "minuteStep", "secondStep", "placeholder"), U = (e) => [ae(e), oe(e), ie(e)];
function b(e) {
  if (e.customRule)
    return {
      validateStatus: "error",
      help: e.customRule
    };
  const t = d(e.value.value, u);
  return e.required && !t.isValid() ? {
    validateStatus: "error",
    help: a("prop.required")
  } : {
    validateStatus: "success"
  };
}
const ce = {
  value: x("value"),
  ...j,
  ...le
}, fe = new E(ce, (e) => {
  let t = d(null);
  return e.value.value !== "" && (t = d(e.value.value, u)), e.label({
    required: e.required,
    style: e.style,
    children: /* @__PURE__ */ c(se, {
      viewRef: e.viewRef,
      $style: e.style,
      disabled: e.disabled,
      value: t.isValid() ? t : null,
      disabledTime: () => A(e.minTime, e.maxTime),
      ...N(e),
      hourStep: e.hourStep,
      minuteStep: e.minuteStep,
      secondStep: e.secondStep,
      placeholder: e.placeholder,
      onChange: (r) => {
        ne(r && r.isValid() ? r.format(C) : "", e.value.onChange, e.onEvent);
      },
      onFocus: () => e.onEvent("focus"),
      onBlur: () => e.onEvent("blur"),
      suffixIcon: p(e.suffixIcon) && e.suffixIcon
    }),
    ...b(e)
  });
}).setPropertyViewFn((e) => /* @__PURE__ */ l(y, {
  children: [/* @__PURE__ */ c(n, {
    name: s.basic,
    children: e.value.propertyView({
      label: a("prop.defaultValue"),
      tooltip: a("time.formatTip")
    })
  }), /* @__PURE__ */ c(re, {
    ...e
  }), (i(o).editorModeStatus === "logic" || i(o).editorModeStatus === "both") && /* @__PURE__ */ l(y, {
    children: [/* @__PURE__ */ l(n, {
      name: s.validation,
      children: [D(e), I(e), F(e), e.customRule.propertyView({})]
    }), /* @__PURE__ */ l(n, {
      name: s.interaction,
      children: [e.onEvent.getPropertyView(), q(e), k(e)]
    })]
  }), (i(o).editorModeStatus === "layout" || i(o).editorModeStatus === "both") && e.label.getPropertyView(), (i(o).editorModeStatus === "layout" || i(o).editorModeStatus === "both") && /* @__PURE__ */ l(n, {
    name: s.layout,
    children: [e.format.propertyView({
      label: a("time.format")
    }), e.placeholder.propertyView({
      label: a("time.placeholderText")
    })]
  }), (i(o).editorModeStatus === "logic" || i(o).editorModeStatus === "both") && /* @__PURE__ */ l(n, {
    name: s.advanced,
    children: [U(e), e.use12Hours.propertyView({
      label: a("prop.use12Hours")
    }), e.suffixIcon.propertyView({
      label: a("button.suffixIcon")
    })]
  }), (i(o).editorModeStatus === "layout" || i(o).editorModeStatus === "both") && /* @__PURE__ */ c(n, {
    name: s.style,
    children: e.style.getPropertyView()
  })]
})).setExposeMethodConfigs(B).build(), be = function() {
  const e = {
    start: x("start"),
    end: x("end"),
    ...j
  };
  return new E(e, (t) => {
    let r = null;
    t.start.value !== "" && (r = d(t.start.value, u));
    let m = null;
    t.end.value !== "" && (m = d(t.end.value, u));
    const _ = /* @__PURE__ */ c(de, {
      viewRef: t.viewRef,
      $style: t.style,
      disabled: t.disabled,
      start: r != null && r.isValid() ? r : null,
      end: m != null && m.isValid() ? m : null,
      disabledTime: () => A(t.minTime, t.maxTime),
      ...N(t),
      hourStep: t.hourStep,
      minuteStep: t.minuteStep,
      secondStep: t.secondStep,
      placeholder: [t.placeholder, t.placeholder],
      onChange: (S, w) => {
        t.start.onChange(S && S.isValid() ? S.format(C) : ""), t.end.onChange(w && w.isValid() ? w.format(C) : ""), t.onEvent("change");
      },
      onFocus: () => t.onEvent("focus"),
      onBlur: () => t.onEvent("blur"),
      suffixIcon: p(t.suffixIcon) && t.suffixIcon
    }), V = b({
      ...t,
      value: t.start
    }), M = b({
      ...t,
      value: t.end
    });
    return t.label({
      required: t.required,
      style: t.style,
      children: _,
      ...V.validateStatus !== "success" ? V : M.validateStatus !== "success" ? M : V
    });
  }).setPropertyViewFn((t) => /* @__PURE__ */ l(y, {
    children: [/* @__PURE__ */ l(n, {
      name: s.basic,
      children: [t.start.propertyView({
        label: a("time.start"),
        tooltip: a("time.formatTip")
      }), t.end.propertyView({
        label: a("time.end"),
        tooltip: a("time.formatTip")
      })]
    }), (i(o).editorModeStatus === "logic" || i(o).editorModeStatus === "both") && /* @__PURE__ */ l(y, {
      children: [/* @__PURE__ */ l(n, {
        name: s.validation,
        children: [D(t), I(t), F(t), t.customRule.propertyView({})]
      }), /* @__PURE__ */ l(n, {
        name: s.interaction,
        children: [t.onEvent.getPropertyView(), q(t), k(t)]
      })]
    }), (i(o).editorModeStatus === "layout" || i(o).editorModeStatus === "both") && t.label.getPropertyView(), (i(o).editorModeStatus === "layout" || i(o).editorModeStatus === "both") && /* @__PURE__ */ l(n, {
      name: s.layout,
      children: [t.format.propertyView({
        label: a("time.format")
      }), t.placeholder.propertyView({
        label: a("time.placeholderText")
      })]
    }), (i(o).editorModeStatus === "logic" || i(o).editorModeStatus === "both") && /* @__PURE__ */ l(n, {
      name: s.advanced,
      children: [U(t), t.use12Hours.propertyView({
        label: a("prop.use12Hours")
      }), t.suffixIcon.propertyView({
        label: a("button.suffixIcon")
      })]
    }), (i(o).editorModeStatus === "layout" || i(o).editorModeStatus === "both") && /* @__PURE__ */ c(n, {
      name: s.style,
      children: t.style.getPropertyView()
    })]
  })).build();
}(), Te = H(fe, [new T("value", a("export.timePickerValueDesc")), f({
  name: "formattedValue",
  desc: a("export.timePickerFormattedValueDesc"),
  depKeys: ["value", "format"],
  func: (e) => {
    const t = d(e.value, u);
    return t.isValid() ? t.format(e.format) : "";
  }
}), f({
  name: "invalid",
  desc: a("export.invalidDesc"),
  depKeys: ["value", "required", "minTime", "maxTime", "customRule"],
  func: (e) => b({
    ...e,
    value: {
      value: e.value
    }
  }).validateStatus !== "success"
}), ...K]);
let P = H(be, [new T("start", a("export.timeRangeStartDesc")), new T("end", a("export.timeRangeEndDesc")), f({
  name: "formattedValue",
  desc: a("export.timeRangeFormattedValueDesc"),
  depKeys: ["start", "end", "format"],
  func: (e) => {
    const t = d(e.start, u), r = d(e.end, u);
    return [t.isValid() && t.format(e.format), r.isValid() && r.format(e.format)].filter((m) => m).join(" - ");
  }
}), f({
  name: "formattedStartValue",
  desc: a("export.timeRangeFormattedStartValueDesc"),
  depKeys: ["start", "format"],
  func: (e) => {
    const t = d(e.start, u);
    return t.isValid() && t.format(e.format);
  }
}), f({
  name: "formattedEndValue",
  desc: a("export.timeRangeFormattedEndValueDesc"),
  depKeys: ["end", "format"],
  func: (e) => {
    const t = d(e.end, u);
    return t.isValid() && t.format(e.format);
  }
}), f({
  name: "invalid",
  desc: a("export.invalidDesc"),
  depKeys: ["start", "end", "required", "minTime", "maxTime", "customRule"],
  func: (e) => b({
    ...e,
    value: {
      value: e.start
    }
  }).validateStatus !== "success" || b({
    ...e,
    value: {
      value: e.end
    }
  }).validateStatus !== "success"
}), ...K]);
P = z(P, [...B, {
  method: {
    name: "clearAll",
    description: a("date.clearAllDesc"),
    params: []
  },
  execute: (e) => {
    e.children.start.getView().onChange(""), e.children.end.getView().onChange("");
  }
}, {
  method: {
    name: "resetAll",
    description: a("date.resetAllDesc"),
    params: []
  },
  execute: (e) => {
    e.children.start.getView().reset(), e.children.end.getView().reset();
  }
}]);
export {
  Te as TimePickerComp,
  P as TimeRangeComp,
  fe as timePickerControl,
  be as timeRangeControl
};
