var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { h } from '@stencil/core';
import { MapToComponentField, VegaSlimmer } from 'vega-slimmer/core';
import { VegaCalendarDayViewTimedEventLayoutGenerator } from './layout/day-view-timed-event-layout-generator';
import { VegaCalendarEventSorter } from '../../../common/helpers/calendar-event-sorter';
/** The `VegaCalendarTimedEventRenderer` class in TypeScript React renders timed events for a calendar view based on the current day's events. timed events render for day view and week view */
export class VegaCalendarTimedEventRenderer extends VegaSlimmer {
  constructor() {
    super(...arguments);
    this.calendarEventSorter = new VegaCalendarEventSorter();
    this.dayViewTimedEventLayoutGenerator = new VegaCalendarDayViewTimedEventLayoutGenerator();
  }
  /**
   * render current preiod normal events
   *
   * @returns {HTMLElement} events element
   */
  render() {
    const viewSource = this.calendarView.dateItems[0];
    return (h("div", { class: "day-event-container" }, viewSource.map((item) => {
      return (h("div", { key: `${item.month}-${item.date}`, class: "day-event-col" }, this.renderTimedEvents(item)));
    })));
  }
  /**
   * render current day events
   *
   * @param {CalendarDate} date calendar Date
   * @returns {HTMLElement[]} event elements
   */
  renderTimedEvents(date) {
    const events = this.calendarEventController
      .getCurrentDateEvents(date)
      .filter((eventItem) => !eventItem.isAllDayEvent && !eventItem.isGroupEvent());
    const sortEvents = this.calendarEventSorter.sortCalendarEventByTime(events);
    const layout = this.dayViewTimedEventLayoutGenerator.generate(sortEvents);
    return this.dayViewEventLayoutRenderer.render(layout, date);
  }
}
__decorate([
  MapToComponentField()
], VegaCalendarTimedEventRenderer.prototype, "calendarView", void 0);
__decorate([
  MapToComponentField()
], VegaCalendarTimedEventRenderer.prototype, "calendarEventController", void 0);
__decorate([
  MapToComponentField()
], VegaCalendarTimedEventRenderer.prototype, "dayViewEventLayoutRenderer", void 0);
