import { bK as Y, w as R, a0 as a, ba as v, bd as Z, bL as z, bv as D, bM as T, bB as E, bN as G, bO as J, be as ee, bf as te, bP as C, U as F, bQ as i, bR as d, V as c, bS as b, bT as V, bD as p, bU as K, P as l, bh as f, bi as s, bj as r, bg as o, bV as q, bk as A, bl as k, bW as B, bn as _, bX as m, bp as j, bY as ae, bZ as oe, b_ as ne, b$ as ie, c0 as le, c1 as se, c2 as re, c3 as de, c4 as ue, c5 as me, c6 as ce, c7 as fe, c8 as be, c9 as M } from "./684d2f28.js";
import { formDataChildren as ye, FormDataPropertyView as ve } from "./00dac55d.js";
import { useContext as n } from "react";
import { disabledTime as H, handleDateChange as g, dateRefMethods as U } from "./f2000b8a.js";
import { DateUIView as Ve } from "./9a0dfa2c.js";
import { DateRangeUIView as he } from "./fe1e08e9.js";
import "react-dom";
import "./d6402597.js";
import "./6aa2c0e1.js";
const we = [oe, ne, ie], Se = {
  required: D,
  minDate: v,
  maxDate: v,
  minTime: v,
  maxTime: v,
  customRule: le
}, O = {
  label: Y,
  placeholder: R(v, a("date.placeholder")),
  format: v,
  disabled: Z,
  onEvent: z(we),
  showTime: D,
  use12Hours: D,
  hourStep: T.closed(1, 24, 1),
  minuteStep: T.closed(1, 60, 1),
  secondStep: T.closed(1, 60, 1),
  style: E(G),
  labelStyle: E(J.filter((e) => ["accent", "validate"].includes(e.name) === !1)),
  suffixIcon: R(ee, "/icon:regular/calendar"),
  ...Se,
  viewRef: te
}, L = (e) => se.pick(e, "format", "showTime", "use12Hours", "hourStep", "minuteStep", "secondStep", "placeholder"), N = (e, t) => [e.showTime.propertyView({
  label: a("date.showTime")
}), !t && e.use12Hours.propertyView({
  label: a("prop.use12Hours")
})], $ = (e, t = !0) => {
  if (t && e.showTime.getView())
    return /* @__PURE__ */ l(s, {
      name: r.advanced,
      children: [re(e), de(e), ue(e)]
    });
}, Q = (e, t = "date") => {
  if (t === "date")
    return [me(e), ce(e)];
}, W = (e, t = "date") => {
  if (t === "date" && e.showTime.getView())
    return [fe(e), be(e)];
};
function h(e) {
  if (e.customRule)
    return {
      validateStatus: "error",
      help: e.customRule
    };
  const t = i(i(e.value.value), b);
  return e.required && !t.isValid() ? {
    validateStatus: "error",
    help: a("prop.required")
  } : {
    validateStatus: "success"
  };
}
const ge = {
  value: C("value"),
  ...O,
  ...ye
}, xe = new F(ge, (e) => {
  let t = i(null);
  return e.value.value !== "" && (t = i(e.value.value, d)), e.label({
    required: e.required,
    style: e.style,
    labelStyle: e.labelStyle,
    children: /* @__PURE__ */ c(Ve, {
      viewRef: e.viewRef,
      disabledTime: () => H(e.minTime, e.maxTime),
      $style: e.style,
      disabled: e.disabled,
      ...L(e),
      minDate: e.minDate,
      maxDate: e.maxDate,
      placeholder: e.placeholder,
      value: t.isValid() ? t : null,
      onChange: (u) => {
        g(u && u.isValid() ? u.format(e.showTime ? b : V) : "", e.value.onChange, e.onEvent);
      },
      onPanelChange: () => {
        g("", e.value.onChange, M.noop);
      },
      onFocus: () => e.onEvent("focus"),
      onBlur: () => e.onEvent("blur"),
      suffixIcon: p(e.suffixIcon) && e.suffixIcon
    }),
    ...h(e)
  });
}).setPropertyViewFn((e) => {
  const t = K();
  return /* @__PURE__ */ l(f, {
    children: [/* @__PURE__ */ c(s, {
      name: r.basic,
      children: e.value.propertyView({
        label: a("prop.defaultValue"),
        placeholder: "2022-04-07 21:39:59",
        tooltip: a("date.formatTip")
      })
    }), /* @__PURE__ */ c(ve, {
      ...e
    }), (n(o).editorModeStatus === "logic" || n(o).editorModeStatus === "both") && /* @__PURE__ */ l(f, {
      children: [/* @__PURE__ */ l(s, {
        name: r.validation,
        children: [q(e), Q(e), W(e), e.customRule.propertyView({})]
      }), /* @__PURE__ */ l(s, {
        name: r.interaction,
        children: [e.onEvent.getPropertyView(), A(e), k(e)]
      })]
    }), (n(o).editorModeStatus === "layout" || n(o).editorModeStatus === "both") && e.label.getPropertyView(), (n(o).editorModeStatus === "layout" || n(o).editorModeStatus === "both") && /* @__PURE__ */ l(s, {
      name: r.layout,
      children: [B({
        children: e
      }), e.placeholder.propertyView({
        label: a("date.placeholderText")
      })]
    }), (n(o).editorModeStatus === "logic" || n(o).editorModeStatus === "both") && /* @__PURE__ */ c(f, {
      children: /* @__PURE__ */ l(s, {
        name: r.advanced,
        children: [N(e, t), e.suffixIcon.propertyView({
          label: a("button.suffixIcon")
        })]
      })
    }), (n(o).editorModeStatus === "logic" || n(o).editorModeStatus === "both") && !t && $(e), (n(o).editorModeStatus === "layout" || n(o).editorModeStatus === "both") && /* @__PURE__ */ l(f, {
      children: [/* @__PURE__ */ c(s, {
        name: r.style,
        children: e.style.getPropertyView()
      }), /* @__PURE__ */ c(s, {
        name: r.labelStyle,
        children: e.labelStyle.getPropertyView()
      })]
    })]
  });
}).setExposeMethodConfigs(U).build(), Te = function() {
  const e = {
    start: C("start"),
    end: C("end"),
    ...O
  };
  return new F(e, (t) => {
    let u = i(null), w = i(null);
    t.start.value !== "" && (u = i(t.start.value, d)), t.end.value !== "" && (w = i(t.end.value, d));
    const X = /* @__PURE__ */ c(he, {
      viewRef: t.viewRef,
      $style: t.style,
      disabled: t.disabled,
      ...L(t),
      start: u.isValid() ? u : null,
      end: w.isValid() ? w : null,
      minDate: t.minDate,
      maxDate: t.maxDate,
      placeholder: [t.placeholder, t.placeholder],
      disabledTime: () => H(t.minTime, t.maxTime),
      onChange: (S, y) => {
        t.start.onChange(S && S.isValid() ? S.format(t.showTime ? b : V) : ""), t.end.onChange(y && y.isValid() ? y.format(t.showTime ? b : V) : ""), t.onEvent("change");
      },
      onPanelChange: (S, y) => {
        y[0] !== "date" && g("", t.start.onChange, M.noop), y[1] !== "date" && g("", t.end.onChange, M.noop);
      },
      onFocus: () => t.onEvent("focus"),
      onBlur: () => t.onEvent("blur"),
      suffixIcon: p(t.suffixIcon) && t.suffixIcon
    }), x = h({
      ...t,
      value: t.start
    }), P = h({
      ...t,
      value: t.end
    });
    return t.label({
      required: t.required,
      style: t.style,
      labelStyle: t.labelStyle,
      children: X,
      ...x.validateStatus !== "success" ? x : P.validateStatus !== "success" ? P : x
    });
  }).setPropertyViewFn((t) => {
    const u = K();
    return /* @__PURE__ */ l(f, {
      children: [/* @__PURE__ */ l(s, {
        name: r.basic,
        children: [t.start.propertyView({
          label: a("date.start"),
          placeholder: "2022-04-07 21:39:59",
          tooltip: a("date.formatTip")
        }), t.end.propertyView({
          label: a("date.end"),
          placeholder: "2022-04-07 21:39:59",
          tooltip: a("date.formatTip")
        })]
      }), (n(o).editorModeStatus === "logic" || n(o).editorModeStatus === "both") && /* @__PURE__ */ l(f, {
        children: [/* @__PURE__ */ l(s, {
          name: r.validation,
          children: [q(t), Q(t), W(t), t.customRule.propertyView({})]
        }), /* @__PURE__ */ l(s, {
          name: r.interaction,
          children: [t.onEvent.getPropertyView(), A(t), k(t)]
        })]
      }), (n(o).editorModeStatus === "layout" || n(o).editorModeStatus === "both") && t.label.getPropertyView(), (n(o).editorModeStatus === "layout" || n(o).editorModeStatus === "both") && /* @__PURE__ */ l(s, {
        name: r.layout,
        children: [B({
          children: t
        }), t.placeholder.propertyView({
          label: a("date.placeholderText")
        })]
      }), (n(o).editorModeStatus === "logic" || n(o).editorModeStatus === "both") && /* @__PURE__ */ c(f, {
        children: /* @__PURE__ */ l(s, {
          name: r.advanced,
          children: [N(t, u), t.suffixIcon.propertyView({
            label: a("button.suffixIcon")
          })]
        })
      }), (n(o).editorModeStatus === "logic" || n(o).editorModeStatus === "both") && $(t), (n(o).editorModeStatus === "layout" || n(o).editorModeStatus === "both") && /* @__PURE__ */ l(f, {
        children: [/* @__PURE__ */ c(s, {
          name: r.style,
          children: t.style.getPropertyView()
        }), /* @__PURE__ */ c(s, {
          name: r.labelStyle,
          children: t.labelStyle.getPropertyView()
        })]
      })]
    });
  }).build();
}(), Ke = _(xe, [m({
  name: "value",
  desc: a("export.datePickerValueDesc"),
  depKeys: ["value", "showTime"],
  func: (e) => {
    const t = i(e.value, d);
    return t.isValid() ? t.format(e.showTime ? b : V) : "";
  }
}), m({
  name: "formattedValue",
  desc: a("export.datePickerFormattedValueDesc"),
  depKeys: ["value", "format"],
  func: (e) => {
    const t = i(e.value, d);
    return t.isValid() ? t.format(e.format) : "";
  }
}), m({
  name: "timestamp",
  desc: a("export.datePickerTimestampDesc"),
  depKeys: ["value"],
  func: (e) => {
    const t = i(e.value, d);
    return t.isValid() ? t.unix() : "";
  }
}), m({
  name: "invalid",
  desc: a("export.invalidDesc"),
  depKeys: ["value", "required", "minTime", "maxTime", "minDate", "maxDate", "customRule"],
  func: (e) => h({
    ...e,
    value: {
      value: e.value
    }
  }).validateStatus !== "success"
}), ...j]);
let I = _(Te, [m({
  name: "start",
  desc: a("export.dateRangeStartDesc"),
  depKeys: ["start", "showTime"],
  func: (e) => {
    const t = i(e.start, d);
    return t.isValid() ? t.format(e.showTime ? b : V) : "";
  }
}), m({
  name: "end",
  desc: a("export.dateRangeEndDesc"),
  depKeys: ["end", "showTime"],
  func: (e) => {
    const t = i(e.end, d);
    return t.isValid() ? t.format(e.showTime ? b : V) : "";
  }
}), m({
  name: "startTimestamp",
  desc: a("export.dateRangeStartTimestampDesc"),
  depKeys: ["start"],
  func: (e) => {
    const t = i(e.start, d);
    return t.isValid() ? t.unix() : "";
  }
}), m({
  name: "endTimestamp",
  desc: a("export.dateRangeEndTimestampDesc"),
  depKeys: ["end"],
  func: (e) => {
    const t = i(e.end, d);
    return t.isValid() ? t.unix() : "";
  }
}), m({
  name: "formattedValue",
  desc: a("export.dateRangeFormattedValueDesc"),
  depKeys: ["start", "end", "format"],
  func: (e) => {
    const t = i(e.start, d), u = i(e.end, d);
    return [t.isValid() && t.format(e.format), u.isValid() && u.format(e.format)].filter((w) => w).join(" - ");
  }
}), m({
  name: "formattedStartValue",
  desc: a("export.dateRangeFormattedStartValueDesc"),
  depKeys: ["start", "format"],
  func: (e) => {
    const t = i(e.start, d);
    return t.isValid() && t.format(e.format);
  }
}), m({
  name: "formattedEndValue",
  desc: a("export.dateRangeFormattedEndValueDesc"),
  depKeys: ["end", "format"],
  func: (e) => {
    const t = i(e.end, d);
    return t.isValid() && t.format(e.format);
  }
}), m({
  name: "invalid",
  desc: a("export.invalidDesc"),
  depKeys: ["start", "end", "required", "minTime", "maxTime", "minDate", "maxDate", "customRule"],
  func: (e) => h({
    ...e,
    value: {
      value: e.start
    }
  }).validateStatus !== "success" || h({
    ...e,
    value: {
      value: e.end
    }
  }).validateStatus !== "success"
}), ...j]);
I = ae(I, [...U, {
  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 {
  Ke as DatePickerComp,
  I as DateRangeComp,
  xe as datePickerControl,
  Te as dateRangeControl
};
