'use strict';
'use client';
import { jsx, jsxs } from 'react/jsx-runtime';
import { cn } from '../../../fd-toolbox/lib/utils.js';
import { getCalendarDays, buildEventsByDateMap, getDayCellData, todayDate, weekDays, formatEventTime } from './BigCalendar.funcs.js';

var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", {
  value,
  configurable: true
});
function BigCalendar({
  dateWindow,
  events
}) {
  const year = dateWindow.getFullYear();
  const month = dateWindow.getMonth();
  const days = getCalendarDays(year, month);
  const eventsByDate = buildEventsByDateMap(events);
  return /* @__PURE__ */jsx("div", {
    className: "border-border bg-background w-full overflow-hidden rounded-xl border",
    children: /* @__PURE__ */jsx("div", {
      className: "grid auto-rows-fr grid-cols-7",
      children: days.map((_, index) => {
        const {
          date,
          dateKey,
          dayEvents,
          isLastColumn,
          isLastRow
        } = getDayCellData(days, index, eventsByDate);
        const isToday = dateKey === todayDate;
        const weekDayLabel = weekDays[index % 7];
        const isFirstRow = index < 7;
        return /* @__PURE__ */jsxs("div", {
          className: cn("border-border relative flex h-34 flex-col p-1.5 text-xs", !isLastColumn && "border-r", !isLastRow && "border-b"),
          children: [isFirstRow && /* @__PURE__ */jsx("div", {
            className: "text-muted-foreground text-center text-sm font-medium",
            children: weekDayLabel
          }), /* @__PURE__ */jsx("div", {
            className: "mt-1 mb-1.5 flex justify-center",
            children: isToday ? /* @__PURE__ */jsx("span", {
              className: "bg-fd-tertiary-900 text-primary-foreground inline-flex h-6 w-6 items-center justify-center rounded-full text-sm font-semibold",
              children: date.getDate()
            }) : /* @__PURE__ */jsx("span", {
              className: "text-foreground text-sm font-semibold",
              children: date.getDate()
            })
          }), /* @__PURE__ */jsx("div", {
            className: "space-y-1",
            children: dayEvents.map(event => /* @__PURE__ */jsxs("div", {
              className: "bg-accent text-accent-foreground truncate rounded px-2 py-0.5 text-xs",
              children: [/* @__PURE__ */jsx("span", {
                className: "mr-1 opacity-70",
                children: formatEventTime(event)
              }), event.title]
            }, event.id))
          })]
        }, dateKey);
      })
    })
  });
}
__name(BigCalendar, "BigCalendar");

export { BigCalendar };
