import { c5 as r, gv as v, X as o, cm as w, c6 as c, F as a, gw as y, gx as f, gy as g, a6 as C, G as V, Y as D, cb as E, c8 as h, S as p, w as F, f2 as P } from "./603b75d9.js";
import { C as R } from "./4963ac97.js";
import { ColumnValueTooltip as S } from "./62f393ec.js";
import { useRef as T, useState as s, useEffect as I } from "react";
import "react-dom";
import "./ffcffc16.js";
import "./26dac75c.js";
r.extend(v);
const N = o(f)`
  transform: rotate(180deg);
`, O = o(g)`
  transform: rotate(180deg);
`, $ = o(P)`
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  padding: 0;
  padding-left: 11px;
  .ant-picker-input {
    height: 100%;
  }
  input {
    padding-right: 18px;
    cursor: pointer;
  }
  &.ant-picker-focused .ant-picker-suffix svg g {
    stroke: ${(e) => e.$open && "#315EFB"};
  }
  .ant-picker-suffix {
    height: calc(100% - 1px);
    position: absolute;
    right: 0;
    top: 0.5px;
    display: flex;
    align-items: center;
    // background: #fff;
    padding: 0 3px;
    // border-left: 1px solid #d7d9e0;
  }
`, j = o.div`
  .ant-picker-header {
    padding: 0 12px;
    .ant-picker-header-super-prev-btn,
    .ant-picker-header-prev-btn,
    .ant-picker-header-next-btn,
    .ant-picker-header-super-next-btn {
      display: flex;
      align-items: center;
      justify-content: center;
      svg {
        max-width: 12px;
        max-height: 12px;
      }
      &:hover svg g {
        fill: #315efb;
      }
    }
  }
  .ant-picker-date-panel .ant-picker-body {
    padding: 8px 16px;
  }
  .ant-picker-ranges {
    padding: 10px 16px;
  }
  .ant-picker-now-btn {
    color: #4965f2;
    &:hover {
      color: #315efb;
    }
  }
  .ant-picker-cell {
    color: #b8b9bf;
  }
  .ant-picker-cell-in-view {
    color: rgba(0, 0, 0, 0.85);
  }
  .ant-picker-cell-in-view.ant-picker-cell-selected .ant-picker-cell-inner,
  .ant-picker-ok .ant-btn-primary {
    background: #4965f2;
    border: none;
    box-shadow: none;
    &:hover {
      background: #315efb;
      border: none;
      box-shadow: none;
    }
  }
  .ant-picker-cell:hover:not(.ant-picker-cell-in-view) .ant-picker-cell-inner,
  .ant-picker-cell:hover:not(.ant-picker-cell-selected):not(.ant-picker-cell-range-start):not(.ant-picker-cell-range-end):not(.ant-picker-cell-range-hover-start):not(.ant-picker-cell-range-hover-end)
    .ant-picker-cell-inner {
    background-color: #f2f7fc;
    color: #4965f2;
  }
  .ant-picker-year-panel,
  .ant-picker-month-panel {
    & + div .ant-picker-now {
      display: none;
    }
  }
`, B = o.div`
  background: transparent !important;
`;
function d(e, i) {
  let t = r(e);
  return w.isNumber(Number(e)) && e !== "" && (t = r(Number(e))), t.isValid() || (t = r.utc(e).local()), t.isValid() ? t.format(i) : "";
}
const M = {
  text: p,
  format: F(p, h)
}, u = (e) => e.text, A = (e) => {
  const i = T(), [t, k] = s(!0);
  let l = r(e.value, c);
  l.isValid() || (l = r(0, c));
  const [m, x] = s(l);
  return I(() => {
    const n = e.value ? r(e.value, c) : null;
    x(n);
  }, [e.value]), /* @__PURE__ */ a(B, {
    onKeyDown: (n) => {
      n.key === "Enter" && !t && e.onChangeEnd();
    },
    onMouseDown: (n) => {
      n.stopPropagation(), n.preventDefault();
    },
    children: /* @__PURE__ */ a($, {
      ref: i,
      $open: t,
      suffixIcon: /* @__PURE__ */ a(y, {}),
      prevIcon: /* @__PURE__ */ a(f, {}),
      nextIcon: /* @__PURE__ */ a(N, {}),
      superNextIcon: /* @__PURE__ */ a(O, {}),
      superPrevIcon: /* @__PURE__ */ a(g, {}),
      allowClear: !0,
      variant: "borderless",
      autoFocus: !0,
      value: m,
      showTime: e.showTime,
      showNow: !0,
      defaultOpen: !0,
      panelRender: (n) => /* @__PURE__ */ a(j, {
        children: n
      }),
      popupStyle: {
        borderRadius: "8px",
        boxShadow: "0 0 10px 0 rgba(0,0,0,0.10)",
        overflow: "hidden"
      },
      onOpenChange: (n) => k(n),
      onChange: (n, b) => {
        e.onChange(b);
      },
      onBlur: () => e.onChangeEnd()
    })
  });
}, z = function() {
  return new R(M, (e, i) => {
    const t = e.changeValue ?? u(e);
    return d(t, e.format);
  }, (e) => d(e.text.value, e.format.value), u).setEditViewFn((e) => /* @__PURE__ */ a(A, {
    value: e.value,
    onChange: e.onChange,
    onChangeEnd: e.onChangeEnd,
    showTime: !1
  })).setPropertyViewFn((e) => /* @__PURE__ */ C(V, {
    children: [e.text.propertyView({
      label: D("table.columnValue"),
      tooltip: S
    }), E({
      children: e,
      placeholder: h
    })]
  })).build();
}();
export {
  z as DateComp,
  A as DateEdit,
  d as formatDate
};
