import { j as d } from "../../node_modules/react/jsx-runtime.mjs";
import { useState as y, useEffect as j, useMemo as D } from "react";
import C from "../../node_modules/dayjs/plugin/isToday.mjs";
import n from "../../node_modules/dayjs/dayjs.min.mjs";
import M, { CalendarTypeEnum as S } from "./BitzFuiCalendarStore.mjs";
import N from "./CalendarAgendumItem.mjs";
import x from "./CalendarAgendum.module.less.mjs";
import A from "../../node_modules/classnames/index.mjs";
import z from "../BitzNoData/index.mjs";
n.extend(C);
const g = (e) => e.reduce((r, s) => {
  let u = n(s.startTime).format("YYYY-MM-DD"), l = r.find((t) => t.date === u);
  return l || (l = { date: u, list: [] }, r.push(l)), l.list.push(s), r;
}, []), E = (e) => {
  const { CalendarType: c, currentDay: r } = M((t) => t), [s, u] = y([]);
  j(() => {
    var t, f;
    if ((t = e == null ? void 0 : e.list) != null && t.length) {
      let i = (f = e == null ? void 0 : e.list) == null ? void 0 : f.filter((a) => {
        let o = n(a.startTime), T = n(a.endTime);
        return o.isSame(r, "day") || T.isSame(r, "day");
      });
      const m = i == null ? void 0 : i.map((a) => ({
        ...a,
        startTime: n(a.startTime).utc(),
        endTime: n(a.endTime).utc()
      }));
      m.sort((a, o) => n(a.startTime).isAfter(n(o.startTime)) ? 1 : -1), console.log("list2", g(m)), u(g(m));
    }
  }, [e == null ? void 0 : e.list, r]);
  const l = D(() => c === S.agendum ? r.locale("zh-cn").format("MM月DD日dddd") : "", [r, c]);
  return /* @__PURE__ */ d.jsxs("ul", { className: "calendarAgendumBlock", children: [
    s == null ? void 0 : s.map((t, f) => {
      var o;
      const i = n(t == null ? void 0 : t.date), m = i.locale("zh-cn").format("DD日dddd"), a = n().isSame(i, "day");
      return [
        /* @__PURE__ */ d.jsxs("div", { className: A(x.timeContainer, {
          [x.istoday]: a
        }), children: [
          /* @__PURE__ */ d.jsx("span", { children: m }),
          a ? [
            /* @__PURE__ */ d.jsx("span", { className: x.splitLine, children: " | " }, "1"),
            /* @__PURE__ */ d.jsx("span", { children: "今天" }, "1")
          ] : null
        ] }, t == null ? void 0 : t.date),
        (o = t == null ? void 0 : t.list) == null ? void 0 : o.map((T, h) => /* @__PURE__ */ d.jsx(N, { data: T }, h))
      ];
    }),
    s.length ? null : /* @__PURE__ */ d.jsx(z, { title: `你在 ${l} 没有任何会议。` })
  ] });
}, L = E;
export {
  L as default
};
