import { ChangeDetectorRef, Component, computed, ElementRef, inject, input } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core';
import { DatepickerComponent } from '@seniorsistemas/angular-components/datepicker';
import { FieldLabelComponent } from '../../../components/field-label/field-label.component';
import { TooltipDirective } from '@seniorsistemas/angular-components/tooltip';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
import * as i2 from "@ngx-translate/core";
export class CalendarFieldComponent {
    changeDetectorRef = inject(ChangeDetectorRef);
    elementRef = inject(ElementRef);
    field = input.required();
    formControl = input.required();
    inputRef = null;
    mode = computed(() => {
        const f = this.field();
        if (f?.type === 'time')
            return 'time';
        if (f?.view === 'year')
            return 'year';
        if (f?.view === 'month')
            return 'month';
        if (f?.type === 'dateTime' || f?.type === 'localDateTime')
            return 'datetime';
        return 'date';
    });
    ngAfterViewInit() {
        this.inputRef = this.elementRef.nativeElement.querySelector('input');
        this.changeDetectorRef.detectChanges();
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: CalendarFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: CalendarFieldComponent, isStandalone: true, selector: "ng-component", inputs: { field: { classPropertyName: "field", publicName: "field", isSignal: true, isRequired: true, transformFunction: null }, formControl: { classPropertyName: "formControl", publicName: "formControl", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "@let _field = field();\n@if (inputRef) {\n    <s-field-label\n        [field]=\"_field\"\n        [fieldContainerRef]=\"inputRef\"\n    >\n    </s-field-label>\n}\n\n@if (_field) {\n    <div [sTooltip]=\"_field.tooltip\">\n        <s-datepicker\n            [inputId]=\"_field.id || _field.name\"\n            [name]=\"_field.name\"\n            [showIcon]=\"true\"\n            [mode]=\"mode()\"\n            [selectionMode]=\"_field.selectionMode === 'multiple' ? 'multiple' : 'single'\"\n            [multipleSeparator]=\"_field.multipleSeparator || ', '\"\n            [rangeSeparator]=\"_field.rangeSeparator || ' \u2014 '\"\n            [showSeconds]=\"_field.showSeconds ?? false\"\n            [showOnFocus]=\"_field.showOnFocus ?? true\"\n            [readonlyInput]=\"_field.readonlyInput ?? false\"\n            [minuteStep]=\"_field.minuteStep ?? 5\"\n            [stepHour]=\"_field.stepHour ?? 1\"\n            [stepSecond]=\"_field.stepSecond ?? 1\"\n            [firstDayOfWeek]=\"_field.firstDayOfWeek ?? 0\"\n            [showButtonBar]=\"_field.showButtonBar ?? true\"\n            [showClear]=\"_field.showClear ?? false\"\n            [showOtherMonths]=\"_field.showOtherMonths ?? true\"\n            [selectOtherMonths]=\"_field.selectOtherMonths ?? false\"\n            [hideOnDateTimeSelect]=\"_field.hideOnDateTimeSelect ?? false\"\n            [disabledDates]=\"_field.disabledDates ?? []\"\n            [disabledDays]=\"_field.disabledDays ?? []\"\n            [tabindex]=\"_field.tabindex\"\n            [autofocus]=\"_field.autofocus ?? false\"\n            [formControl]=\"formControl()\"\n            [min]=\"_field.minDate ?? null\"\n            [max]=\"_field.maxDate ?? null\"\n            [defaultDate]=\"_field.defaultDate ?? null\"\n            [dateFormat]=\"_field.dateFormat || _field.calendarLocaleOptions?.dateFormat || ('platform.angular_components.date_format' | translate)\"\n            [hourFormat]=\"$any(_field.hourFormat || _field.calendarLocaleOptions?.hourFormat || ('platform.angular_components.hour_format' | translate))\"\n            [placeholder]=\"_field.placeholder\"\n            (blurred)=\"_field.onBlur ? _field.onBlur($event) : null\"\n            (focused)=\"_field.onFocus ? _field.onFocus($event) : null\"\n            (selected)=\"_field.onSelect ? _field.onSelect($event) : null\"\n            (valueInput)=\"_field.onInput ? _field.onInput($event) : null\"\n            (closed)=\"_field.onClose ? _field.onClose($event) : null\"\n            (show)=\"_field.onShow ? _field.onShow() : null\"\n            (todayClick)=\"_field.onTodayClick ? _field.onTodayClick($event) : null\"\n            (clearClick)=\"_field.onClearClick ? _field.onClearClick($event) : null\"\n            (monthChange)=\"_field.onMonthChange ? _field.onMonthChange($event) : null\"\n            (yearChange)=\"_field.onYearChange ? _field.onYearChange($event) : null\"\n        >\n        </s-datepicker>\n    </div>\n}\n", dependencies: [{ kind: "component", type: FieldLabelComponent, selector: "s-field-label", inputs: ["field", "fieldContainerRef"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: DatepickerComponent, selector: "s-datepicker", inputs: ["inputId", "name", "placeholder", "mode", "selectionMode", "multipleSeparator", "showIcon", "icon", "min", "max", "defaultDate", "dateFormat", "hourFormat", "minuteStep", "showSeconds", "rangeSeparator", "showOnFocus", "readonlyInput", "firstDayOfWeek", "showButtonBar", "showClear", "showOtherMonths", "selectOtherMonths", "hideOnDateTimeSelect", "stepHour", "stepSecond", "tabindex", "autofocus", "disabledDates", "disabledDays", "disabled"], outputs: ["disabledChange", "blurred", "focused", "selected", "closed", "todayClick", "clearClick", "monthChange", "yearChange", "show", "valueInput"] }, { kind: "directive", type: TooltipDirective, selector: "[sTooltip]", inputs: ["sTooltip", "tooltipPosition", "showDelay", "displayTime", "tooltipEvent", "escape", "visible", "mobileBehavior", "focusedInputRef", "checkTruncatedText"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "pipe", type: i2.TranslatePipe, name: "translate" }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: CalendarFieldComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [FieldLabelComponent, ReactiveFormsModule, DatepickerComponent, TooltipDirective, TranslateModule], template: "@let _field = field();\n@if (inputRef) {\n    <s-field-label\n        [field]=\"_field\"\n        [fieldContainerRef]=\"inputRef\"\n    >\n    </s-field-label>\n}\n\n@if (_field) {\n    <div [sTooltip]=\"_field.tooltip\">\n        <s-datepicker\n            [inputId]=\"_field.id || _field.name\"\n            [name]=\"_field.name\"\n            [showIcon]=\"true\"\n            [mode]=\"mode()\"\n            [selectionMode]=\"_field.selectionMode === 'multiple' ? 'multiple' : 'single'\"\n            [multipleSeparator]=\"_field.multipleSeparator || ', '\"\n            [rangeSeparator]=\"_field.rangeSeparator || ' \u2014 '\"\n            [showSeconds]=\"_field.showSeconds ?? false\"\n            [showOnFocus]=\"_field.showOnFocus ?? true\"\n            [readonlyInput]=\"_field.readonlyInput ?? false\"\n            [minuteStep]=\"_field.minuteStep ?? 5\"\n            [stepHour]=\"_field.stepHour ?? 1\"\n            [stepSecond]=\"_field.stepSecond ?? 1\"\n            [firstDayOfWeek]=\"_field.firstDayOfWeek ?? 0\"\n            [showButtonBar]=\"_field.showButtonBar ?? true\"\n            [showClear]=\"_field.showClear ?? false\"\n            [showOtherMonths]=\"_field.showOtherMonths ?? true\"\n            [selectOtherMonths]=\"_field.selectOtherMonths ?? false\"\n            [hideOnDateTimeSelect]=\"_field.hideOnDateTimeSelect ?? false\"\n            [disabledDates]=\"_field.disabledDates ?? []\"\n            [disabledDays]=\"_field.disabledDays ?? []\"\n            [tabindex]=\"_field.tabindex\"\n            [autofocus]=\"_field.autofocus ?? false\"\n            [formControl]=\"formControl()\"\n            [min]=\"_field.minDate ?? null\"\n            [max]=\"_field.maxDate ?? null\"\n            [defaultDate]=\"_field.defaultDate ?? null\"\n            [dateFormat]=\"_field.dateFormat || _field.calendarLocaleOptions?.dateFormat || ('platform.angular_components.date_format' | translate)\"\n            [hourFormat]=\"$any(_field.hourFormat || _field.calendarLocaleOptions?.hourFormat || ('platform.angular_components.hour_format' | translate))\"\n            [placeholder]=\"_field.placeholder\"\n            (blurred)=\"_field.onBlur ? _field.onBlur($event) : null\"\n            (focused)=\"_field.onFocus ? _field.onFocus($event) : null\"\n            (selected)=\"_field.onSelect ? _field.onSelect($event) : null\"\n            (valueInput)=\"_field.onInput ? _field.onInput($event) : null\"\n            (closed)=\"_field.onClose ? _field.onClose($event) : null\"\n            (show)=\"_field.onShow ? _field.onShow() : null\"\n            (todayClick)=\"_field.onTodayClick ? _field.onTodayClick($event) : null\"\n            (clearClick)=\"_field.onClearClick ? _field.onClearClick($event) : null\"\n            (monthChange)=\"_field.onMonthChange ? _field.onMonthChange($event) : null\"\n            (yearChange)=\"_field.onYearChange ? _field.onYearChange($event) : null\"\n        >\n        </s-datepicker>\n    </div>\n}\n" }]
        }] });
//# sourceMappingURL=data:application/json;base64, 