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 { MapToComponentField, MapToComponentMethod, VegaSlimmer } from 'vega-slimmer/core';
import { DayViewGenerator, MonthViewGenerator, WeekViewGenerator, } from '../../../../../helpers/calendar';
/** The `VegaCalendarViewController` class manages the calendar view based on the current period and view mode in TypeScript. */
export class VegaCalendarViewController extends VegaSlimmer {
  constructor() {
    super(...arguments);
    this.monthViewGenerator = new MonthViewGenerator();
    this.weekViewGenerator = new WeekViewGenerator();
    this.dayViewGenerator = new DayViewGenerator();
  }
  /**
   * set default calendar view
   */
  initialCalendarView() {
    this.setCalendarView(this.getCalendarViewByPeriod(this.currentPeriod));
  }
  /**
   * generator new calendar view if the calendar current period changes
   *
   * @param {CalendarPeriod} newValue the new calendar period
   */
  generateCalendarView(newValue) {
    this.setCalendarView(this.getCalendarViewByPeriod(newValue));
  }
  /**
   * The function `getCalendarViewByPeriod` returns a specific calendar view based on the current period.
   *
   * @param {CalendarPeriod} newPeriod the new period
   * @returns {CalendarView} get the match calendar view by the period
   */
  getCalendarViewByPeriod(newPeriod) {
    switch (newPeriod.type) {
      case 'week':
        return this.weekViewGenerator.generate(newPeriod);
      case 'day':
        return this.dayViewGenerator.generate(newPeriod);
      default:
        return this.monthViewGenerator.generate(newPeriod);
    }
  }
  /**
   * update the calendar view
   *
   * @param {CalendarView} newView new calendar view
   */
  setCalendarView(newView) {
    this.calendarView = newView;
  }
}
__decorate([
  MapToComponentField({ writable: true })
], VegaCalendarViewController.prototype, "calendarView", void 0);
__decorate([
  MapToComponentField()
], VegaCalendarViewController.prototype, "currentPeriod", void 0);
__decorate([
  MapToComponentField()
], VegaCalendarViewController.prototype, "showWeekends", void 0);
__decorate([
  MapToComponentField()
], VegaCalendarViewController.prototype, "currentPeriodController", void 0);
__decorate([
  MapToComponentMethod('componentWillLoad')
], VegaCalendarViewController.prototype, "initialCalendarView", null);
__decorate([
  MapToComponentMethod('watchCurrentPeriodChange')
], VegaCalendarViewController.prototype, "generateCalendarView", null);
