{"version":3,"file":"ajf-core-calendar.mjs","sources":["../../../projects/core/calendar/src/calendar-service.ts","../../../projects/core/calendar/src/calendar-entry-label.ts","../../../projects/core/calendar/src/calendar-interfaces.ts","../../../projects/core/calendar/src/calendar-module.ts","../../../projects/core/calendar/src/calendar.ts","../../../projects/core/calendar/src/public_api.ts","../../../projects/core/calendar/src/ajf-core-calendar.ts"],"sourcesContent":["/**\n * @license\n * Copyright (C) Gnucoop soc. coop.\n *\n * This file is part of the Advanced JSON forms (ajf).\n *\n * Advanced JSON forms (ajf) is free software: you can redistribute it and/or\n * modify it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the License,\n * or (at your option) any later version.\n *\n * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero\n * General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with Advanced JSON forms (ajf).\n * If not, see http://www.gnu.org/licenses/.\n *\n */\n\nimport {Injectable} from '@angular/core';\nimport {\n  addDays,\n  addMonths,\n  addWeeks,\n  addYears,\n  endOfDay,\n  endOfISOWeek,\n  endOfMonth,\n  endOfWeek,\n  endOfYear,\n  format,\n  getISODay,\n  isAfter,\n  isBefore,\n  isSameDay,\n  setISODay,\n  startOfDay,\n  startOfISOWeek,\n  startOfMonth,\n  startOfWeek,\n  startOfYear,\n  subMonths,\n  subWeeks,\n  subYears,\n} from 'date-fns';\n\nimport {\n  AjfCalendarEntry,\n  AjfCalendarEntrySelectedState,\n  AjfCalendarPeriod,\n  AjfCalendarPeriodType,\n  AjfCalendarView,\n  AjfCalendarViewMode,\n} from './calendar-interfaces';\n\nexport interface AjfCalendarParams {\n  viewMode: AjfCalendarViewMode;\n  viewDate: Date;\n  selection: AjfCalendarPeriod | null;\n  isoMode: boolean;\n  minDate: Date | null;\n  maxDate: Date | null;\n}\n\nfunction isBetween(date: Date, rangeLeft: Date, rangeRight: Date): boolean {\n  return (\n    (isAfter(date, rangeLeft) || isSameDay(date, rangeLeft)) &&\n    (isBefore(date, rangeRight) || isSameDay(date, rangeRight))\n  );\n}\n\nfunction periodOrder(entryType: AjfCalendarPeriodType): number {\n  return ['day', 'week', 'month', 'year'].indexOf(entryType);\n}\n\n@Injectable({providedIn: 'root'})\nexport class AjfCalendarService {\n  buildView(params: AjfCalendarParams): AjfCalendarView {\n    const {viewMode, viewDate} = params;\n    switch (viewMode) {\n      case 'decade':\n        let curYear: number = viewDate.getFullYear();\n        let firstYear = curYear - (curYear % 10) + 1;\n        let lastYear = firstYear + 11;\n        return {\n          header: `${firstYear} - ${lastYear}`,\n          headerRow: [],\n          rows: this._decadeCalendarRows(params),\n        };\n      case 'year':\n        return {\n          header: `${viewDate.getFullYear()}`,\n          headerRow: [],\n          rows: this._yearCalendarRows(params),\n        };\n      case 'month':\n        return {\n          header: format(viewDate, 'MMM yyyy'),\n          headerRow: this._monthHeaderRow(params),\n          rows: this._monthCalendarRows(params),\n        };\n    }\n    return {\n      header: '',\n      headerRow: [],\n      rows: [],\n    };\n  }\n\n  monthBounds(date: Date, isoMode: boolean): {start: Date; end: Date} {\n    if (!isoMode) {\n      return {\n        start: startOfMonth(date),\n        end: endOfMonth(date),\n      };\n    }\n    const isoDay = getISODay(date);\n    date = isoDay < 4 ? endOfISOWeek(date) : startOfISOWeek(date);\n    let startDate = startOfMonth(date);\n    let endDate = endOfMonth(startDate);\n    const startWeekDay = startDate.getDay();\n    const endWeekDay = endDate.getDay();\n    if (startWeekDay == 0 || startWeekDay > 4) {\n      startDate = addWeeks(startDate, 1);\n    }\n    if (endWeekDay > 0 && endWeekDay < 4) {\n      endDate = subWeeks(endDate, 1);\n    }\n    startDate = startOfISOWeek(startDate);\n    endDate = endOfISOWeek(endDate);\n    return {start: startDate, end: endDate};\n  }\n\n  getEntryRange(entry: AjfCalendarEntry): {start: Date; end: Date} {\n    if (entry.type === 'day') {\n      return {start: new Date(entry.date), end: new Date(entry.date)};\n    } else {\n      let curDate: Date = new Date(entry.date);\n      return {\n        start: entry.type === 'month' ? startOfMonth(curDate) : startOfYear(curDate),\n        end: entry.type === 'month' ? endOfMonth(curDate) : endOfYear(curDate),\n      };\n    }\n  }\n\n  isEntrySelected(\n    entry: AjfCalendarEntry,\n    selection: AjfCalendarPeriod | null,\n  ): AjfCalendarEntrySelectedState {\n    if (selection != null && selection.startDate != null && selection.endDate != null) {\n      let selectionStart: Date = startOfDay(selection.startDate);\n      let selectionEnd: Date = endOfDay(selection.endDate);\n      let selectionPeriodOrder: number = periodOrder(selection.type);\n\n      let entryPeriodOrder: number = periodOrder(entry.type);\n      let entryRange: {start: Date; end: Date} = this.getEntryRange(entry);\n\n      if (\n        entryPeriodOrder <= selectionPeriodOrder &&\n        isBetween(entryRange.start, selectionStart, selectionEnd) &&\n        isBetween(entryRange.end, selectionStart, selectionEnd)\n      ) {\n        return 'full';\n      } else if (\n        entryPeriodOrder > selectionPeriodOrder &&\n        isBetween(selectionStart, entryRange.start, entryRange.end) &&\n        isBetween(selectionEnd, entryRange.start, entryRange.end)\n      ) {\n        return 'partial';\n      }\n    }\n\n    return 'none';\n  }\n\n  entryLabel(entry: AjfCalendarEntry): string {\n    if (entry.type === 'day') {\n      return `${entry.date.getDate()}`;\n    }\n    if (entry.type === 'month') {\n      return format(entry.date, 'MMM');\n    }\n    return `${entry.date.getFullYear()}`;\n  }\n\n  nextView(viewDate: Date, viewMode: AjfCalendarViewMode): Date {\n    if (viewMode == 'month') {\n      return addMonths(viewDate, 1);\n    } else if (viewMode == 'year') {\n      return addYears(viewDate, 1);\n    } else if (viewMode == 'decade') {\n      return addYears(viewDate, 10);\n    }\n    return viewDate;\n  }\n\n  previousView(viewDate: Date, viewMode: AjfCalendarViewMode): Date {\n    if (viewMode == 'month') {\n      return subMonths(viewDate, 1);\n    } else if (viewMode == 'year') {\n      return subYears(viewDate, 1);\n    } else if (viewMode == 'decade') {\n      return subYears(viewDate, 10);\n    }\n    return viewDate;\n  }\n\n  private _monthHeaderRow(params: AjfCalendarParams): string[] {\n    const {isoMode, viewDate} = params;\n    let curDate: Date;\n    if (isoMode) {\n      curDate = setISODay(startOfWeek(viewDate), 1);\n    } else {\n      curDate = startOfWeek(viewDate);\n    }\n    let weekDayNames: string[] = [];\n    for (let i = 0; i < 7; i++) {\n      weekDayNames.push(format(curDate, 'EEE'));\n      curDate = addDays(curDate, 1);\n    }\n    return weekDayNames;\n  }\n\n  private _decadeCalendarRows(params: AjfCalendarParams): AjfCalendarEntry[][] {\n    const {viewDate, selection} = params;\n    let curYear: number = viewDate.getFullYear();\n    let firstYear = curYear - (curYear % 10) + 1;\n    let curDate: Date = startOfYear(viewDate);\n    curDate.setFullYear(firstYear);\n\n    let rows: AjfCalendarEntry[][] = [];\n    for (let i = 0; i < 4; i++) {\n      let row: AjfCalendarEntry[] = [];\n      for (let j = 0; j < 3; j++) {\n        let date = new Date(curDate);\n        let newEntry: AjfCalendarEntry = {type: 'year', date: date, selected: 'none'};\n        newEntry.selected = this.isEntrySelected(newEntry, selection);\n        row.push(newEntry);\n        curDate = addYears(curDate, 1);\n      }\n      rows.push(row);\n    }\n\n    return rows;\n  }\n\n  private _yearCalendarRows(params: AjfCalendarParams): AjfCalendarEntry[][] {\n    const {viewDate, selection} = params;\n    let curDate: Date = startOfYear(viewDate);\n\n    let rows: AjfCalendarEntry[][] = [];\n    for (let i = 0; i < 4; i++) {\n      let row: AjfCalendarEntry[] = [];\n      for (let j = 0; j < 3; j++) {\n        let date = new Date(curDate);\n        let newEntry: AjfCalendarEntry = {type: 'month', date: date, selected: 'none'};\n        newEntry.selected = this.isEntrySelected(newEntry, selection);\n        row.push(newEntry);\n        curDate = addMonths(curDate, 1);\n      }\n      rows.push(row);\n    }\n\n    return rows;\n  }\n\n  private _monthCalendarRows(params: AjfCalendarParams): AjfCalendarEntry[][] {\n    const {viewDate, selection, isoMode, minDate, maxDate} = params;\n    const monthBounds = this.monthBounds(viewDate, isoMode);\n    let viewStartDate: Date = new Date(monthBounds.start);\n    let viewEndDate: Date = new Date(monthBounds.end);\n    if (!isoMode) {\n      viewStartDate = startOfWeek(viewStartDate);\n      viewEndDate = endOfWeek(viewEndDate);\n    }\n\n    let rows: AjfCalendarEntry[][] = [];\n    let todayDate = new Date();\n    let curDate = new Date(viewStartDate);\n    while (curDate < viewEndDate) {\n      let row: AjfCalendarEntry[] = [];\n      for (let i = 0; i < 7; i++) {\n        let disabled =\n          (minDate != null && isBefore(curDate, minDate)) ||\n          (maxDate != null && isAfter(curDate, maxDate));\n        let date = new Date(curDate);\n        let newEntry: AjfCalendarEntry = {\n          type: 'day',\n          date: date,\n          selected: 'none',\n          highlight: format(todayDate, 'yyyy-MM-dd') === format(curDate, 'yyyy-MM-dd'),\n          disabled: disabled,\n        };\n        newEntry.selected = this.isEntrySelected(newEntry, selection);\n        row.push(newEntry);\n        curDate = addDays(curDate, 1);\n      }\n      rows.push(row);\n    }\n    return rows;\n  }\n}\n","/**\n * @license\n * Copyright (C) Gnucoop soc. coop.\n *\n * This file is part of the Advanced JSON forms (ajf).\n *\n * Advanced JSON forms (ajf) is free software: you can redistribute it and/or\n * modify it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the License,\n * or (at your option) any later version.\n *\n * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero\n * General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with Advanced JSON forms (ajf).\n * If not, see http://www.gnu.org/licenses/.\n *\n */\n\nimport {Injectable, Pipe, PipeTransform} from '@angular/core';\n\nimport {AjfCalendarEntry} from './calendar-interfaces';\nimport {AjfCalendarService} from './calendar-service';\n\n@Injectable()\n@Pipe({name: 'ajfCalendarEntryLabel'})\nexport class AjfCalendarEntryLabelPipe implements PipeTransform {\n  constructor(private _service: AjfCalendarService) {}\n\n  transform(entry: AjfCalendarEntry): string {\n    return this._service.entryLabel(entry);\n  }\n}\n","/**\n * @license\n * Copyright (C) Gnucoop soc. coop.\n *\n * This file is part of the Advanced JSON forms (ajf).\n *\n * Advanced JSON forms (ajf) is free software: you can redistribute it and/or\n * modify it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the License,\n * or (at your option) any later version.\n *\n * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero\n * General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with Advanced JSON forms (ajf).\n * If not, see http://www.gnu.org/licenses/.\n *\n */\n\nexport type AjfCalendarEntrySelectedState = 'none' | 'partial' | 'full';\n\nexport type AjfCalendarEntryType = 'day' | 'month' | 'year';\n\nexport interface AjfCalendarEntry {\n  type: AjfCalendarEntryType;\n  date: Date;\n  selected: AjfCalendarEntrySelectedState;\n  disabled?: boolean;\n  highlight?: boolean;\n}\n\nexport type AjfCalendarPeriodType = 'day' | 'week' | 'month' | 'year';\n\nexport interface AjfCalendarPeriod {\n  type: AjfCalendarPeriodType;\n  startDate: Date;\n  endDate: Date;\n}\n\nexport type AjfCalendarViewMode = 'month' | 'year' | 'decade';\n\nexport interface AjfCalendarView {\n  header: string;\n  headerRow: string[];\n  rows: AjfCalendarEntry[][];\n}\n","/**\n * @license\n * Copyright (C) Gnucoop soc. coop.\n *\n * This file is part of the Advanced JSON forms (ajf).\n *\n * Advanced JSON forms (ajf) is free software: you can redistribute it and/or\n * modify it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the License,\n * or (at your option) any later version.\n *\n * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero\n * General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with Advanced JSON forms (ajf).\n * If not, see http://www.gnu.org/licenses/.\n *\n */\n\nimport {NgModule} from '@angular/core';\n\nimport {AjfCalendarEntryLabelPipe} from './calendar-entry-label';\nimport {AjfCalendarService} from './calendar-service';\n\n@NgModule({\n  declarations: [AjfCalendarEntryLabelPipe],\n  exports: [AjfCalendarEntryLabelPipe],\n})\nexport class AjfCalendarModule {}\n\n@NgModule({\n  providers: [AjfCalendarService],\n})\nexport class AjfGregorianCalendarModule {}\n","/**\n * @license\n * Copyright (C) Gnucoop soc. coop.\n *\n * This file is part of the Advanced JSON forms (ajf).\n *\n * Advanced JSON forms (ajf) is free software: you can redistribute it and/or\n * modify it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the License,\n * or (at your option) any later version.\n *\n * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero\n * General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with Advanced JSON forms (ajf).\n * If not, see http://www.gnu.org/licenses/.\n *\n */\n\nimport {\n  AfterContentInit,\n  ChangeDetectorRef,\n  Directive,\n  EventEmitter,\n  Input,\n  OnInit,\n  Output,\n} from '@angular/core';\nimport {ControlValueAccessor} from '@angular/forms';\nimport {\n  endOfISOWeek,\n  endOfWeek,\n  endOfYear,\n  parseISO as parse,\n  startOfISOWeek,\n  startOfWeek,\n  startOfYear,\n} from 'date-fns';\nimport {Observable} from 'rxjs';\n\nimport {\n  AjfCalendarEntry,\n  AjfCalendarPeriod,\n  AjfCalendarPeriodType,\n  AjfCalendarViewMode,\n} from './calendar-interfaces';\nimport {AjfCalendarService} from './calendar-service';\n\nexport type AjfCalendarWeekDay =\n  | 'monday'\n  | 'tuesday'\n  | 'wednesday'\n  | 'thursday'\n  | 'friday'\n  | 'saturday'\n  | 'sunday';\n\nconst weekDays: string[] = [\n  '',\n  'monday',\n  'tuesday',\n  'wednesday',\n  'thursday',\n  'friday',\n  'saturday',\n  'sunday',\n];\n\nexport interface AjfCalendarChange {\n  source: AjfCalendar;\n  period: AjfCalendarPeriod | null;\n}\n\n@Directive()\nexport abstract class AjfCalendar implements AfterContentInit, ControlValueAccessor, OnInit {\n  get viewDate(): Date {\n    return this._viewDate;\n  }\n  @Input()\n  set viewDate(viewDate: Date) {\n    this._setViewDate(viewDate);\n    this._cdr.markForCheck();\n  }\n\n  private _disabled = false;\n  get disabled(): boolean {\n    return this._disabled;\n  }\n  @Input()\n  set disabled(disabled: boolean) {\n    const newDisabled = disabled != null && `${disabled}` !== 'false';\n    if (newDisabled !== this._disabled) {\n      this._disabled = newDisabled;\n      this._cdr.markForCheck();\n    }\n  }\n\n  private _dateOnlyForDay = false;\n  get dateOnlyForDay(): boolean {\n    return this._disabled;\n  }\n  @Input()\n  set dateOnlyForDay(dateOnlyForDay: boolean) {\n    this._dateOnlyForDay = dateOnlyForDay != null && `${dateOnlyForDay}` !== 'false';\n    this._cdr.markForCheck();\n  }\n\n  private _viewMode: AjfCalendarViewMode = 'month';\n  get viewMode(): AjfCalendarViewMode {\n    return this._viewMode;\n  }\n  @Input()\n  set viewMode(viewMode: AjfCalendarViewMode) {\n    this._viewMode = viewMode;\n    this._buildCalendar();\n    this._cdr.markForCheck();\n  }\n\n  private _selectionMode: AjfCalendarPeriodType = 'day';\n  get selectionMode(): AjfCalendarPeriodType {\n    return this._selectionMode;\n  }\n  @Input()\n  set selectionMode(selectionMode: AjfCalendarPeriodType) {\n    this._selectionMode = selectionMode;\n    this._cdr.markForCheck();\n  }\n\n  private _startOfWeekDay = 1;\n  get startOfWeekDay(): AjfCalendarWeekDay {\n    return <AjfCalendarWeekDay>weekDays[this._startOfWeekDay];\n  }\n  @Input()\n  set startOfWeekDay(weekDay: AjfCalendarWeekDay) {\n    this._startOfWeekDay = weekDays.indexOf(weekDay);\n\n    if (this._viewMode === 'month') {\n      this._buildCalendar();\n    }\n    this._cdr.markForCheck();\n  }\n\n  private _isoMode: boolean = false;\n\n  get isoMode(): boolean {\n    return this._isoMode;\n  }\n  @Input()\n  set isoMode(isoMode: boolean) {\n    this._isoMode = isoMode;\n    this._buildCalendar();\n  }\n\n  private _minDate: Date | null = null;\n  get minDate(): Date | null {\n    return this._minDate;\n  }\n  @Input()\n  set minDate(minDate: Date | null) {\n    this._minDate = minDate != null ? new Date(minDate.valueOf()) : null;\n    this._cdr.markForCheck();\n  }\n\n  private _maxDate: Date | null = null;\n  get maxDate(): Date | null {\n    return this._maxDate;\n  }\n  @Input()\n  set maxDate(maxDate: Date | null) {\n    this._maxDate = maxDate != null ? new Date(maxDate.valueOf()) : null;\n    this._cdr.markForCheck();\n  }\n\n  private _change: EventEmitter<AjfCalendarChange> = new EventEmitter<AjfCalendarChange>();\n  @Output()\n  readonly change: Observable<AjfCalendarChange> = this._change as Observable<AjfCalendarChange>;\n\n  private _selectedPeriod: AjfCalendarPeriod | null = null;\n  @Input()\n  set selectedPeriod(period: AjfCalendarPeriod | null) {\n    this._selectedPeriod = period;\n    this._change.emit({source: this, period: period});\n    this._refreshSelection();\n    this._cdr.markForCheck();\n  }\n\n  get value(): AjfCalendarPeriod | Date | null {\n    if (this._dateOnlyForDay && this.selectionMode === 'day') {\n      return this._selectedPeriod != null ? this._selectedPeriod.startDate : null;\n    }\n    return this._selectedPeriod;\n  }\n  @Input()\n  set value(period: AjfCalendarPeriod | Date | null) {\n    if (\n      this._dateOnlyForDay &&\n      this.selectionMode === 'day' &&\n      period instanceof Date &&\n      (this._selectedPeriod == null || period !== this._selectedPeriod.startDate)\n    ) {\n      this.selectedPeriod = {type: 'day', startDate: period, endDate: period};\n    } else if (period instanceof Object && period !== this._selectedPeriod) {\n      this.selectedPeriod = <AjfCalendarPeriod>period;\n      this._onChangeCallback(period);\n    }\n    this._cdr.markForCheck();\n  }\n\n  get calendarHeaders(): string[] {\n    return this._calendarHeaders;\n  }\n  get calendarRows(): AjfCalendarEntry[][] {\n    return this._calendarRows;\n  }\n  get viewHeader(): string {\n    return this._viewHeader;\n  }\n\n  private _viewDate: Date = new Date();\n  private _viewHeader = '';\n\n  private _calendarRows: AjfCalendarEntry[][] = [];\n  private _calendarHeaders: string[] = [];\n\n  constructor(private _cdr: ChangeDetectorRef, private _service: AjfCalendarService) {}\n\n  prevPage(): void {\n    this.viewDate = this._service.previousView(this._viewDate, this._viewMode);\n    this._buildCalendar();\n  }\n\n  nextPage(): void {\n    this.viewDate = this._service.nextView(this._viewDate, this._viewMode);\n    this._buildCalendar();\n  }\n\n  previousViewMode(): void {\n    if (this._viewMode == 'decade') {\n      return;\n    } else if (this._viewMode == 'year') {\n      this._viewMode = 'decade';\n    } else if (this._viewMode == 'month') {\n      this._viewMode = 'year';\n    }\n    this._buildCalendar();\n  }\n\n  selectEntry(entry: AjfCalendarEntry): void {\n    if (!this._canSelectEntry(entry)) {\n      return this._nextViewMode(entry);\n    }\n\n    let newPeriod: AjfCalendarPeriod | null = null;\n    if (this._service.isEntrySelected(entry, this._selectedPeriod) == 'full') {\n      newPeriod = null;\n    } else if (this._selectionMode == 'day') {\n      newPeriod = {type: 'day', startDate: entry.date, endDate: entry.date};\n    } else if (this._selectionMode == 'week') {\n      newPeriod = {\n        type: 'week',\n        startDate: this._isoMode\n          ? startOfISOWeek(entry.date)\n          : startOfWeek(entry.date, {\n              weekStartsOn: this._startOfWeekDay as 0 | 1 | 2 | 3 | 4 | 5 | 6,\n            }),\n        endDate: this._isoMode\n          ? endOfISOWeek(entry.date)\n          : endOfWeek(entry.date, {\n              weekStartsOn: this._startOfWeekDay as 0 | 1 | 2 | 3 | 4 | 5 | 6,\n            }),\n      };\n    } else if (this._selectionMode == 'month') {\n      const monthBounds = this._service.monthBounds(entry.date, this._isoMode);\n      newPeriod = {\n        type: 'month',\n        startDate: new Date(monthBounds.start),\n        endDate: new Date(monthBounds.end),\n      };\n    } else if (this._selectionMode == 'year') {\n      newPeriod = {\n        type: 'year',\n        startDate: startOfYear(entry.date),\n        endDate: endOfYear(entry.date),\n      };\n    }\n    this.value = newPeriod;\n\n    this._onTouchedCallback();\n    this._cdr.markForCheck();\n  }\n\n  registerOnChange(fn: (value: any) => void) {\n    this._onChangeCallback = fn;\n  }\n\n  registerOnTouched(fn: any) {\n    this._onTouchedCallback = fn;\n  }\n\n  writeValue(value: any) {\n    if (typeof value === 'string') {\n      value = parse(value);\n    }\n    this.value = value;\n  }\n\n  ngOnInit(): void {\n    this._buildCalendar();\n  }\n\n  ngAfterContentInit(): void {\n    this._refreshSelection();\n  }\n\n  private _onChangeCallback: (_: any) => void = (_: any) => {};\n  private _onTouchedCallback: () => void = () => {};\n\n  private _setViewDate(date: Date): void {\n    this._viewDate = date;\n  }\n\n  private _buildCalendar(): void {\n    const calendarView = this._service.buildView({\n      viewMode: this._viewMode,\n      viewDate: this._viewDate,\n      selection: this._selectedPeriod,\n      isoMode: this._isoMode,\n      minDate: this._minDate == null ? null : new Date(this._minDate),\n      maxDate: this._maxDate == null ? null : new Date(this._maxDate),\n    });\n    this._viewHeader = calendarView.header;\n    this._calendarHeaders = calendarView.headerRow;\n    this._calendarRows = calendarView.rows;\n    this._cdr.markForCheck();\n  }\n\n  private _refreshSelection(): void {\n    for (let row of this._calendarRows) {\n      for (let entry of row) {\n        entry.selected = this._service.isEntrySelected(entry, this._selectedPeriod);\n      }\n    }\n  }\n\n  private _canSelectEntry(entry: AjfCalendarEntry): boolean {\n    if (['day', 'week'].indexOf(this._selectionMode) >= 0 && entry.type != 'day') {\n      return false;\n    }\n    if (this._selectionMode == 'month' && entry.type == 'year') {\n      return false;\n    }\n    return true;\n  }\n\n  private _nextViewMode(entry: AjfCalendarEntry): void {\n    if (this._viewMode == 'decade') {\n      this._viewMode = 'year';\n    } else if (this._viewMode == 'year') {\n      this._viewMode = 'month';\n    } else if (this._viewMode == 'month') {\n      return;\n    }\n    this._viewDate = entry.date;\n    this._buildCalendar();\n  }\n}\n","/**\n * @license\n * Copyright (C) Gnucoop soc. coop.\n *\n * This file is part of the Advanced JSON forms (ajf).\n *\n * Advanced JSON forms (ajf) is free software: you can redistribute it and/or\n * modify it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the License,\n * or (at your option) any later version.\n *\n * Advanced JSON forms (ajf) is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero\n * General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public License\n * along with Advanced JSON forms (ajf).\n * If not, see http://www.gnu.org/licenses/.\n *\n */\n\nexport * from './calendar-entry-label';\nexport * from './calendar-interfaces';\nexport * from './calendar-module';\nexport * from './calendar-service';\nexport * from './calendar';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["i1.AjfCalendarService","parse"],"mappings":";;;;AAAA;;;;;;;;;;;;;;;;;;;;AAoBG;AA+CH,SAAS,SAAS,CAAC,IAAU,EAAE,SAAe,EAAE,UAAgB,EAAA;AAC9D,IAAA,QACE,CAAC,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC;AACvD,SAAC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAE/D;AAEA,SAAS,WAAW,CAAC,SAAgC,EAAA;AACnD,IAAA,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;AAC5D;MAGa,kBAAkB,CAAA;AAC7B,IAAA,SAAS,CAAC,MAAyB,EAAA;AACjC,QAAA,MAAM,EAAC,QAAQ,EAAE,QAAQ,EAAC,GAAG,MAAM;QACnC,QAAQ,QAAQ;AACd,YAAA,KAAK,QAAQ;AACX,gBAAA,IAAI,OAAO,GAAW,QAAQ,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