import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, ViewEncapsulation, } from '@angular/core';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
/**
 * An internal class that represents the data corresponding to a single calendar cell.
 * @docs-private
 */
export class AswCalendarCell {
    value;
    displayValue;
    ariaLabel;
    enabled;
    constructor(value, displayValue, ariaLabel, enabled) {
        this.value = value;
        this.displayValue = displayValue;
        this.ariaLabel = ariaLabel;
        this.enabled = enabled;
    }
}
/**
 * An internal component used to display calendar data in a table.
 * @docs-private
 */
export class AswCalendarBody {
    /** The label for the table. (e.g. "Jan 2017"). */
    label;
    /** The cells to display in the table. */
    rows;
    /** The value in the table that corresponds to today. */
    todayValue;
    /** The value in the table that is currently selected. */
    selectedValue;
    /** The minimum number of free cells needed to fit the label in the first row. */
    labelMinRequiredCells;
    /** The number of columns in the table. */
    numCols = 7;
    /** Whether to allow selection of disabled cells. */
    allowDisabledSelection = false;
    /** The cell number of the active cell in the table. */
    activeCell = 0;
    /** Emits when a new value is selected. */
    selectedValueChange = new EventEmitter();
    /** The number of blank cells to put at the beginning for the first row. */
    get _firstRowOffset() {
        return this.rows && this.rows.length && this.rows[0].length
            ? this.numCols - this.rows[0].length
            : 0;
    }
    _cellClicked(cell) {
        if (!this.allowDisabledSelection && !cell.enabled) {
            return;
        }
        this.selectedValueChange.emit(cell.value);
    }
    _isActiveCell(rowIndex, colIndex) {
        let cellNumber = rowIndex * this.numCols + colIndex;
        // Account for the fact that the first row may not have as many cells.
        if (rowIndex) {
            cellNumber -= this._firstRowOffset;
        }
        return cellNumber === this.activeCell;
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: AswCalendarBody, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.2", type: AswCalendarBody, selector: "[asw-calendar-body]", inputs: { label: "label", rows: "rows", todayValue: "todayValue", selectedValue: "selectedValue", labelMinRequiredCells: "labelMinRequiredCells", numCols: "numCols", allowDisabledSelection: "allowDisabledSelection", activeCell: "activeCell" }, outputs: { selectedValueChange: "selectedValueChange" }, host: { classAttribute: "asw-calendar-body" }, exportAs: ["aswCalendarBody"], ngImport: i0, template: "<!--\r\n  If there's not enough space in the first row, create a separate label row. We mark this row as\r\n  aria-hidden because we don't want it to be read out as one of the weeks in the month.\r\n-->\r\n<tr *ngIf=\"_firstRowOffset < labelMinRequiredCells\" aria-hidden=\"true\">\r\n    <td class=\"asw-calendar-body-label\" [attr.colspan]=\"numCols\">{{ label }}</td>\r\n</tr>\r\n\r\n<!-- Create the first row separately so we can include a special spacer cell. -->\r\n<tr *ngFor=\"let row of rows; let rowIndex = index\" role=\"row\">\r\n    <!--\r\n        We mark this cell as aria-hidden so it doesn't get read out as one of the days in the week.\r\n    -->\r\n    <td *ngIf=\"rowIndex === 0 && _firstRowOffset\"\r\n        class=\"asw-calendar-body-label\" [attr.colspan]=\"_firstRowOffset\" aria-hidden=\"true\">\r\n        {{ _firstRowOffset >= labelMinRequiredCells ? label : '' }}\r\n    </td>\r\n    <td *ngFor=\"let item of row; let colIndex = index\"\r\n        role=\"gridcell\"\r\n        class=\"asw-calendar-body-cell\"\r\n        [class.asw-calendar-body-active]=\"_isActiveCell(rowIndex, colIndex)\"\r\n        [class.asw-calendar-body-disabled]=\"!item.enabled\"\r\n        [tabindex]=\"_isActiveCell(rowIndex, colIndex) ? 0 : -1\"\r\n        [attr.data-mat-row]=\"rowIndex\"\r\n        [attr.data-mat-col]=\"colIndex\"\r\n        [attr.aria-label]=\"item.ariaLabel\"\r\n        [attr.aria-disabled]=\"!item.enabled || null\"\r\n        (click)=\"_cellClicked(item)\">\r\n        <div class=\"asw-calendar-body-cell-content\"\r\n            [class.asw-calendar-body-selected]=\"selectedValue === item.value\"\r\n            [class.asw-calendar-body-today]=\"todayValue === item.value\"\r\n            [attr.aria-selected]=\"selectedValue === item.value\">\r\n        {{ item.displayValue }}\r\n        </div>\r\n    </td>\r\n</tr>\r\n", styles: [".asw-calendar-body{min-width:224px}.asw-calendar-body-label{height:0;line-height:0;text-align:left;padding:7.1428571429% 4.7142857143%}[dir=rtl] .asw-calendar-body-label{text-align:right}.asw-calendar-body-cell{position:relative;width:14.2857142857%;height:0;line-height:0;padding:7.1428571429% 0;text-align:center;outline:none;cursor:pointer}.asw-calendar-body-disabled{cursor:default;pointer-events:none}.asw-calendar-body-cell-content{position:absolute;top:5%;left:5%;display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:90%;height:90%;border:1px solid transparent;border-radius:999px}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: AswCalendarBody, decorators: [{
            type: Component,
            args: [{ selector: '[asw-calendar-body]', host: {
                        class: 'asw-calendar-body',
                    }, exportAs: 'aswCalendarBody', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, template: "<!--\r\n  If there's not enough space in the first row, create a separate label row. We mark this row as\r\n  aria-hidden because we don't want it to be read out as one of the weeks in the month.\r\n-->\r\n<tr *ngIf=\"_firstRowOffset < labelMinRequiredCells\" aria-hidden=\"true\">\r\n    <td class=\"asw-calendar-body-label\" [attr.colspan]=\"numCols\">{{ label }}</td>\r\n</tr>\r\n\r\n<!-- Create the first row separately so we can include a special spacer cell. -->\r\n<tr *ngFor=\"let row of rows; let rowIndex = index\" role=\"row\">\r\n    <!--\r\n        We mark this cell as aria-hidden so it doesn't get read out as one of the days in the week.\r\n    -->\r\n    <td *ngIf=\"rowIndex === 0 && _firstRowOffset\"\r\n        class=\"asw-calendar-body-label\" [attr.colspan]=\"_firstRowOffset\" aria-hidden=\"true\">\r\n        {{ _firstRowOffset >= labelMinRequiredCells ? label : '' }}\r\n    </td>\r\n    <td *ngFor=\"let item of row; let colIndex = index\"\r\n        role=\"gridcell\"\r\n        class=\"asw-calendar-body-cell\"\r\n        [class.asw-calendar-body-active]=\"_isActiveCell(rowIndex, colIndex)\"\r\n        [class.asw-calendar-body-disabled]=\"!item.enabled\"\r\n        [tabindex]=\"_isActiveCell(rowIndex, colIndex) ? 0 : -1\"\r\n        [attr.data-mat-row]=\"rowIndex\"\r\n        [attr.data-mat-col]=\"colIndex\"\r\n        [attr.aria-label]=\"item.ariaLabel\"\r\n        [attr.aria-disabled]=\"!item.enabled || null\"\r\n        (click)=\"_cellClicked(item)\">\r\n        <div class=\"asw-calendar-body-cell-content\"\r\n            [class.asw-calendar-body-selected]=\"selectedValue === item.value\"\r\n            [class.asw-calendar-body-today]=\"todayValue === item.value\"\r\n            [attr.aria-selected]=\"selectedValue === item.value\">\r\n        {{ item.displayValue }}\r\n        </div>\r\n    </td>\r\n</tr>\r\n", styles: [".asw-calendar-body{min-width:224px}.asw-calendar-body-label{height:0;line-height:0;text-align:left;padding:7.1428571429% 4.7142857143%}[dir=rtl] .asw-calendar-body-label{text-align:right}.asw-calendar-body-cell{position:relative;width:14.2857142857%;height:0;line-height:0;padding:7.1428571429% 0;text-align:center;outline:none;cursor:pointer}.asw-calendar-body-disabled{cursor:default;pointer-events:none}.asw-calendar-body-cell-content{position:absolute;top:5%;left:5%;display:flex;align-items:center;justify-content:center;box-sizing:border-box;width:90%;height:90%;border:1px solid transparent;border-radius:999px}\n"] }]
        }], propDecorators: { label: [{
                type: Input
            }], rows: [{
                type: Input
            }], todayValue: [{
                type: Input
            }], selectedValue: [{
                type: Input
            }], labelMinRequiredCells: [{
                type: Input
            }], numCols: [{
                type: Input
            }], allowDisabledSelection: [{
                type: Input
            }], activeCell: [{
                type: Input
            }], selectedValueChange: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 